MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / Lambda

Function Lambda

lean_py/z3/core.py:2184–2201  ·  view source on GitHub ↗

Build a lambda expression (maps to Lean lambda).

(vars: ExprRef | Sequence[ExprRef], body: ExprRef)

Source from the content-addressed store, hash-verified

2182
2183
2184def Lambda(vars: ExprRef | Sequence[ExprRef], body: ExprRef) -> ExprRef:
2185 """Build a lambda expression (maps to Lean lambda)."""
2186 vs = [vars] if isinstance(vars, ExprRef) else list(vars)
2187 bound_names = frozenset(
2188 (v._ast.name, v._sort._ast_sort) for v in vs if isinstance(v._ast, _AstVar)
2189 )
2190 free = body._vars - bound_names
2191 for v in vs:
2192 free = free | v._vars - bound_names
2193
2194 ast: ASTNode = body._ast
2195 for v in reversed(vs):
2196 ast = LambdaNode(
2197 name=v._ast.name if isinstance(v._ast, _AstVar) else str(v._ast),
2198 sort=v._sort._ast_sort,
2199 body=ast,
2200 )
2201 return ExprRef(ast, body._sort, free)
2202
2203
2204# ---------------------------------------------------------------------------

Callers 15

test_lambda_arrayMethod · 0.90
test_lambda_singleMethod · 0.90
test_lambda_multiMethod · 0.90
test_lambda_free_varsMethod · 0.90
test_lambda_multi_varMethod · 0.90
test_lambda_free_varsMethod · 0.90
test_lambda_selectMethod · 0.90
test_lambda_constantMethod · 0.90
test_lambda_squareMethod · 0.90
MapFunction · 0.85
AsArrayFunction · 0.85

Calls 2

LambdaNodeClass · 0.90
ExprRefClass · 0.85

Tested by 10

test_lambda_arrayMethod · 0.72
test_lambda_singleMethod · 0.72
test_lambda_multiMethod · 0.72
test_lambda_free_varsMethod · 0.72
test_lambda_multi_varMethod · 0.72
test_lambda_free_varsMethod · 0.72
test_lambda_selectMethod · 0.72
test_lambda_constantMethod · 0.72
test_lambda_squareMethod · 0.72