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

Method apply

lean_py/z3/tactic.py:85–100  ·  view source on GitHub ↗

Apply this tactic to a goal via Pantograph.

(self, goal: Goal)

Source from the content-addressed store, hash-verified

83 self._name = name
84
85 def apply(self, goal: Goal) -> ApplyResult:
86 """Apply this tactic to a goal via Pantograph."""
87 expr = goal.as_expr()
88 k = _get_kernel()
89 lib = k._lib
90
91 ast = _wrap_free_vars(expr)
92 z3_expr = _marshal_expr(lib, ast)
93 lean_expr = lib.z3_compile(z3_expr)
94 gs = k.goal_create_expr(lean_expr)
95
96 result = gs.try_tactic(self._name)
97 if result.ok and result.state is not None and result.state.is_solved():
98 return ApplyResult([]) # proved
99 # Tactic produced subgoals or failed
100 return ApplyResult([goal]) # unchanged
101
102 def solver(self):
103 """Create a Solver that uses this tactic."""

Callers 13

applyMethod · 0.45
applyMethod · 0.45
applyMethod · 0.45
test_par_or_applyMethod · 0.45
test_par_then_applyMethod · 0.45
test_concat_assocMethod · 0.45

Calls 8

_get_kernelFunction · 0.90
_wrap_free_varsFunction · 0.90
_marshal_exprFunction · 0.90
ApplyResultClass · 0.85
goal_create_exprMethod · 0.80
try_tacticMethod · 0.80
is_solvedMethod · 0.80
as_exprMethod · 0.45

Tested by 10

test_par_or_applyMethod · 0.36
test_par_then_applyMethod · 0.36
test_concat_assocMethod · 0.36