Skip to content

Commit

Permalink
tutorial update
Browse files Browse the repository at this point in the history
  • Loading branch information
philzook58 committed Jan 22, 2025
1 parent faddef7 commit 7cb558b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions kdrag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ def is_value(t: smt.ExprRef):
)


def ast_size_sexpr(t: smt.AstRef) -> int:
"""
Get an approximate size of an AST node by its s-expression length.
This is probably faster than any python layer traversal one can do.
Pretty printed ast size will be correlated to expression size, maybe even DAG size,
since Z3 inserts `let`s to avoid duplication.
>>> ast_size_sexpr(smt.Int("x"))
1
>>> ast_size_sexpr(smt.Int("x") + smt.Int("y"))
7
"""
return len(t.sexpr())


def lemma_db():
"""Scan all modules for Proof objects and return a dictionary of them."""
db = {}
Expand Down

0 comments on commit 7cb558b

Please sign in to comment.