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

Class Tactic

lean_py/z3/tactic.py:77–107  ·  view source on GitHub ↗

A named tactic that dispatches to Pantograph.

Source from the content-addressed store, hash-verified

75
76
77class Tactic:
78 """A named tactic that dispatches to Pantograph."""
79
80 __slots__ = ("_name",)
81
82 def __init__(self, name: str) -> None:
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."""
104 return Solver()
105
106 def __repr__(self) -> str:
107 return f"Tactic({self._name})"
108
109
110# ---------------------------------------------------------------------------

Callers 15

test_tactic_creationMethod · 0.90
test_then_combinatorMethod · 0.90
test_andthen_aliasMethod · 0.90
test_tactic_solverMethod · 0.90
test_par_orMethod · 0.90
test_par_thenMethod · 0.90
test_par_or_applyMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_tactic_creationMethod · 0.72
test_then_combinatorMethod · 0.72
test_andthen_aliasMethod · 0.72
test_tactic_solverMethod · 0.72
test_par_orMethod · 0.72
test_par_thenMethod · 0.72
test_par_or_applyMethod · 0.72