@@ -184,7 +184,19 @@ private def isCheapInductive (type : Expr) : CoreM Bool := do
184184 let .inductInfo info ← getConstInfo declName | return false
185185 return info.numCtors <= 1
186186
187- private def applyCases? (goal : Goal) (fvarId : FVarId) : GrindM (Option (List Goal)) := goal.mvarId.withContext do
187+ private def applyInjection? (goal : Goal) (fvarId : FVarId) : MetaM (Option Goal) := do
188+ if let some mvarId ← injection? goal.mvarId fvarId then
189+ return some { goal with mvarId }
190+ else
191+ return none
192+
193+ private def exfalsoIfNotProp (goal : Goal) : MetaM Goal := goal.mvarId.withContext do
194+ if (← isProp (← goal.mvarId.getType)) then
195+ return goal
196+ else
197+ return { goal with mvarId := (← goal.mvarId.exfalso) }
198+
199+ private def applyCasesOld? (goal : Goal) (fvarId : FVarId) : GrindM (Option (List Goal)) := goal.mvarId.withContext do
188200 /-
189201 Remark: we used to use `whnfD`. This was a mistake, we don't want to unfold user-defined abstractions.
190202 Example: `a ∣ b` is defined as `∃ x, b = a * x`
@@ -201,20 +213,8 @@ private def applyCases? (goal : Goal) (fvarId : FVarId) : GrindM (Option (List G
201213 else
202214 return none
203215
204- private def applyInjection? (goal : Goal) (fvarId : FVarId) : MetaM (Option Goal) := do
205- if let some mvarId ← injection? goal.mvarId fvarId then
206- return some { goal with mvarId }
207- else
208- return none
209-
210- private def exfalsoIfNotProp (goal : Goal) : MetaM Goal := goal.mvarId.withContext do
211- if (← isProp (← goal.mvarId.getType)) then
212- return goal
213- else
214- return { goal with mvarId := (← goal.mvarId.exfalso) }
215-
216216/-- Introduce new hypotheses (and apply `by_contra`) until goal is of the form `... ⊢ False` -/
217- partial def intros (generation : Nat) : GrindTactic' := fun goal => do
217+ partial def introsOld (generation : Nat) : GrindTactic' := fun goal => do
218218 let rec go (goal : Goal) : StateRefT (Array Goal) GrindM Unit := do
219219 if goal.inconsistent then
220220 return ()
@@ -226,7 +226,7 @@ partial def intros (generation : Nat) : GrindTactic' := fun goal => do
226226 else
227227 modify fun s => s.push goal
228228 | .newHyp fvarId goal =>
229- if let some goals ← applyCases ? goal fvarId then
229+ if let some goals ← applyCasesOld ? goal fvarId then
230230 goals.forM go
231231 else if let some goal ← applyInjection? goal fvarId then
232232 go goal
@@ -235,19 +235,19 @@ partial def intros (generation : Nat) : GrindTactic' := fun goal => do
235235 | .newDepHyp goal =>
236236 go goal
237237 | .newLocal fvarId goal =>
238- if let some goals ← applyCases ? goal fvarId then
238+ if let some goals ← applyCasesOld ? goal fvarId then
239239 goals.forM go
240240 else
241241 go goal
242242 let (_, goals) ← (go goal).run #[]
243243 return goals.toList
244244
245245/-- Asserts a new fact `prop` with proof `proof` to the given `goal`. -/
246- def assertAt (proof : Expr) (prop : Expr) (generation : Nat) : GrindTactic' := fun goal => do
246+ def assertAtOld (proof : Expr) (prop : Expr) (generation : Nat) : GrindTactic' := fun goal => do
247247 if isEagerCasesCandidate goal prop then
248248 let mvarId ← goal.mvarId.assert (← mkFreshUserName `h) prop proof
249249 let goal := { goal with mvarId }
250- intros generation goal
250+ introsOld generation goal
251251 else
252252 let goal ← GoalM.run' goal do
253253 let r ← preprocess prop
@@ -257,16 +257,16 @@ def assertAt (proof : Expr) (prop : Expr) (generation : Nat) : GrindTactic' := f
257257 if goal.inconsistent then return [] else return [goal]
258258
259259/-- Asserts next fact in the `goal` fact queue. -/
260- def assertNext : GrindTactic := fun goal => do
260+ def assertNextOld : GrindTactic := fun goal => do
261261 let some (fact, newRawFacts) := goal.newRawFacts.dequeue?
262262 | return none
263- assertAt fact.proof fact.prop fact.generation { goal with newRawFacts }
263+ assertAtOld fact.proof fact.prop fact.generation { goal with newRawFacts }
264264
265265/-- Asserts all facts in the `goal` fact queue. -/
266- partial def assertAll : GrindTactic := fun goal =>
266+ partial def assertAllOld : GrindTactic := fun goal =>
267267 if goal.newRawFacts.isEmpty then
268268 return none
269269 else
270- assertNext .iterate goal
270+ assertNextOld .iterate goal
271271
272272end Lean.Meta.Grind
0 commit comments