This PR implements the option `revert`, which is set to `false` by default. To recover the old `grind` behavior, you should use `grind +revert`. Previously, `grind` used the `RevSimpIntro` idiom, i.e., it would revert all hypotheses and then re-introduce them while simplifying and applying eager `cases`. This idiom created several problems: * Users reported that `grind` would include unnecessary parameters. See [here](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Grind.20aggressively.20includes.20local.20hypotheses.2E/near/554887715). * Unnecessary section variables were also being introduced. See the new test contributed by Sebastian Graf. * Finally, it prevented us from supporting arbitrary parameters as we do in `simp`. In `simp`, I implemented a mechanism that simulates local universe-polymorphic theorems, but this approach could not be used in `grind` because there is no mechanism for reverting (and re-introducing) local universe-polymorphic theorems. Adding such a mechanism would require substantial work: I would need to modify the local context object. I considered maintaining a substitution from the original variables to the new ones, but this is also tricky, because the mapping would have to be stored in the `grind` goal objects, and it is not just a simple mapping. After reverting everything, I would need to keep a sequence of original variables that must be added to the mapping as we re-introduce them, but eager case splits complicate this quite a bit. The whole approach felt overly messy. The new behavior `grind -revert` addresses all these issues. None of the `grind` proofs in our test suite broke after we fixed the bugs exposed by the new feature. That said, the traces and counterexamples produced by `grind` are different. The new proof terms are also different.
39 lines
839 B
Text
39 lines
839 B
Text
module
|
|
set_option grind.debug true
|
|
open Int.Linear
|
|
|
|
example (a b c d e : Int) :
|
|
2*a + b ≥ 1 → b ≥ 0 → c ≥ 0 → d ≥ 0 → e ≥ 0
|
|
→ a ≥ 3*c → c ≥ 6*e → d - e*5 ≥ 0
|
|
→ a + b + 3*c + d + 2*e ≥ 0 := by
|
|
grind
|
|
|
|
set_option trace.grind.lia.model true
|
|
|
|
/--
|
|
trace: [grind.lia.model] a := 7
|
|
[grind.lia.model] b := 0
|
|
[grind.lia.model] c := 3
|
|
[grind.lia.model] d := 2
|
|
[grind.lia.model] e := 4
|
|
-/
|
|
#guard_msgs (trace) in
|
|
example (a b c d e : Int) :
|
|
a + b ≥ 0 →
|
|
a = 2*c + 1 →
|
|
c*2 = 3*d →
|
|
c + d ≤ 0 := by
|
|
(fail_if_success grind); sorry
|
|
|
|
/--
|
|
trace: [grind.lia.model] a := 17
|
|
[grind.lia.model] b := -9
|
|
[grind.lia.model] c := -9
|
|
-/
|
|
#guard_msgs (trace) in
|
|
example (a b c : Int) :
|
|
2*a + 3*b = 7 →
|
|
4*a + 7*c = 5 →
|
|
a ≥ 10 →
|
|
False := by
|
|
(fail_if_success grind); sorry
|