Skip to content

Commit cca0eb8

Browse files
committed
feat: add Solvers.mkAction
1 parent 6c56bcc commit cca0eb8

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/Lean/Meta/Tactic/Grind/Action.lean

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,6 @@ protected def orElse (x y : Action) : Action := fun goal kna kp => do
111111
instance : OrElse Action where
112112
orElse x y := Action.orElse x (y ())
113113

114-
/--
115-
Sequential conjunction: executes both `x` and `y`.
116-
117-
- Runs `x` and always runs `y` afterward, regardless of whether `x` made progress.
118-
- It is not applicable only if both `x` and `y` are not applicable.
119-
-/
120-
protected def andAlso (x y : Action) : Action := fun goal kna kp => do
121-
x goal (fun goal => y goal kna kp) (fun goal => y goal kp kp)
122-
123114
/--
124115
Repeats `x` up to `n` times while it remains applicable.
125116
-/

src/Lean/Meta/Tactic/Grind/Types.lean

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,31 @@ def Solvers.mbtc : GoalM Bool := do
16541654
result := true
16551655
return result
16561656

1657+
/--
1658+
Sequential conjunction: executes both `x` and `y`.
1659+
1660+
- Runs `x` and always runs `y` afterward, regardless of whether `x` made progress.
1661+
- It is not applicable only if both `x` and `y` are not applicable.
1662+
-/
1663+
def Action.andAlso (x y : Action) : Action := fun goal kna kp => do
1664+
x goal (fun goal => y goal kna kp) (fun goal => y goal kp kp)
1665+
1666+
/-
1667+
Creates an action that tries all solver extensions. It uses the `Action.andAlso`
1668+
to combine them.
1669+
-/
1670+
def Solvers.mkAction : IO Action := do
1671+
let exts ← solverExtensionsRef.get
1672+
let rec go (i : Nat) (acc : Action) : Action :=
1673+
if h : i < exts.size then
1674+
go (i+1) (acc.andAlso exts[i].action)
1675+
else
1676+
acc
1677+
if h : 0 < exts.size then
1678+
return go 1 exts[0].action
1679+
else
1680+
return Action.notApplicable
1681+
16571682
/--
16581683
Given a new disequality `lhs ≠ rhs`, propagates it to relevant theories.
16591684
-/

0 commit comments

Comments
 (0)