This PR fixes a bug in the equality-resolution procedure used by `grind`. The procedure now performs a topological sort so that every simplified theorem declaration is emitted **before** any place where it is referenced. Previously, applying equality resolution to ```lean h : ∀ x, p x a → ∀ y, p y b → x ≠ y ``` in the example ```lean example (p : Nat → Nat → Prop) (a b c : Nat) (h : ∀ x, p x a → ∀ y, p y b → x ≠ y) (h₁ : p c a) (h₂ : p c b) : False := by grind ``` caused `grind` to produce the incorrect term ```lean p ?y a → ∀ y, p y b → False ``` The patch eliminates this error, and the following correct simplified theorem is generated ```lean ∀ y, p y a → p y b → False ```
17 lines
509 B
Text
17 lines
509 B
Text
set_option grind.warning false
|
|
|
|
/--
|
|
trace: [grind.eqResolution] ∀ (x : Nat), p x a → ∀ (y : Nat), p y b → ¬x = y, ∀ (y : Nat), p y a → p y b → False
|
|
[grind.ematch.instance] local_0: p c a → ¬p c b
|
|
-/
|
|
#guard_msgs (trace) in
|
|
example
|
|
(p : Nat → Nat → Prop)
|
|
(a b c : Nat)
|
|
(h : ∀ x, p x a → ∀ y, p y b → x ≠ y)
|
|
(h₁ : p c a)
|
|
(h₂ : p c b)
|
|
: False := by
|
|
set_option trace.grind.eqResolution true in
|
|
set_option trace.grind.ematch.instance true in
|
|
grind
|