Skip to content

Commit b41dfbe

Browse files
committed
Using grind helps
1 parent 69eeb49 commit b41dfbe

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/Lean/Meta/Match/MatchEqs.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Lean.Meta.Match.NamedPatterns
1919
import Lean.Meta.Tactic.Rewrite
2020
import Lean.Meta.Constructions.SparseCasesOn
2121
import Lean.Meta.Constructions.SparseCasesOnEq
22+
import Lean.Meta.Tactic.Grind.Main
2223

2324
public section
2425

@@ -165,6 +166,10 @@ where
165166
<|>
166167
(substSomeVar mvarId)
167168
<|>
169+
(do let r ← Grind.main mvarId (← Grind.mkParams {})
170+
if r.hasFailed then throwError "grind failed"
171+
return #[])
172+
<|>
168173
(throwError "failed to generate equality theorem {thmName} for `match` expression `{matchDeclName}`\n{MessageData.ofGoal mvarId}")
169174
subgoals.forM (go · (depth+1))
170175

tests/lean/run/issue11342.lean

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1+
opaque double (n : Nat) : Nat
2+
13
inductive Parity : Nat -> Type
2-
| even (n) : Parity (n + n)
3-
| odd (n) : Parity (Nat.succ (n + n))
4+
| even (n) : Parity (double n)
5+
| odd (n) : Parity (Nat.succ (double n))
46

5-
set_option trace.Meta.Match.matchEqs true
7+
-- set_option trace.Meta.Match.matchEqs true
68

79
partial def natToBin3 : (n : Nat) → Parity n → List Bool
810
| 0, _ => []
911
| _, Parity.even j => [false, false]
1012
| _, Parity.odd j => [true, true]
1113

12-
-- #guard_msgs in
13-
-- #print sig natToBin3.match_1.splitter
14-
1514
/--
16-
error: Failed to realize constant natToBin3.match_1.congr_eq_1:
17-
failed to generate equality theorem _private.lean.run.issue11342.0.natToBin3.match_1.congr_eq_2 for `match` expression `natToBin3.match_1`
18-
case else.even
19-
motive✝ : (x : Nat) → Parity x → Sort u_1
20-
h_1✝ : (x : Parity 0) → motive✝ 0 x
21-
h_2✝ : (j : Nat) → motive✝ (j + j) (Parity.even j)
22-
h_3✝ : (j : Nat) → motive✝ (j + j).succ (Parity.odd j)
23-
j✝ n✝ : Nat
24-
h✝ : Nat.hasNotBit 1 (n✝ + n✝).ctorIdx
25-
heq_1✝ : n✝ + n✝ = j✝ + j✝
26-
heq_2✝ : Parity.even n✝ ≍ Parity.even j✝
27-
x✝ : ∀ (x : Parity 0), n✝ + n✝ = 0 → Parity.even n✝ ≍ x → False
28-
⊢ h_2✝ n✝ ≍ h_2✝ j✝
29-
---
30-
error: Unknown constant `natToBin3.match_1.congr_eq_1`
15+
info: private theorem natToBin3.match_1.congr_eq_1.{u_1} : ∀ (motive : (x : Nat) → Parity x → Sort u_1) (x : Nat)
16+
(x_1 : Parity x) (h_1 : (x : Parity 0) → motive 0 x) (h_2 : (j : Nat) → motive (double j) (Parity.even j))
17+
(h_3 : (j : Nat) → motive (double j).succ (Parity.odd j)) (x_2 : Parity 0),
18+
x = 0 →
19+
x_1 ≍ x_2 →
20+
(match x, x_1 with
21+
| 0, x => h_1 x
22+
| .(double j), Parity.even j => h_2 j
23+
| .((double j).succ), Parity.odd j => h_3 j) ≍
24+
h_1 x_2
3125
-/
3226
#guard_msgs(pass trace, all) in
3327
#print sig natToBin3.match_1.congr_eq_1

0 commit comments

Comments
 (0)