Skip to content

Commit 97e5872

Browse files
authored
fix: simplify isCasesAttrCandidate? in grind (#8415)
The behavior was counterintuitive.
1 parent 6395d69 commit 97e5872

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,9 @@ def getCasesTypes : CoreM CasesTypes :=
7070
def isSplit (declName : Name) : CoreM Bool := do
7171
return (← getCasesTypes).isSplit declName
7272

73-
private def getAlias? (value : Expr) : MetaM (Option Name) :=
74-
lambdaTelescope value fun _ body => do
75-
if let .const declName _ := body.getAppFn' then
76-
return some declName
77-
else
78-
return none
79-
8073
partial def isCasesAttrCandidate? (declName : Name) (eager : Bool) : CoreM (Option Name) := do
8174
match (← getConstInfo declName) with
8275
| .inductInfo info => if !info.isRec || !eager then return some declName else return none
83-
| .defnInfo info =>
84-
let some declName ← getAlias? info.value |>.run' {} {}
85-
| return none
86-
isCasesAttrCandidate? declName eager
8776
| _ => return none
8877

8978
def isCasesAttrCandidate (declName : Name) (eager : Bool) : CoreM Bool := do

tests/lean/run/grind_palindrome2.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ example (xs : Array Nat) (w : xs.reverse = xs) (j : Nat) (hj : 0 ≤ j) (hj' : j
1818
xs[j] = xs[xs.size - 1 - j] := by
1919
grind
2020

21+
attribute [grind ext] Array.ext -- TODO: should we mark it by default?
22+
2123
theorem checkPalin1_correct' : checkPalin1 xs = true ↔ IsPalindrome xs := by
2224
unfold checkPalin1
2325
suffices ∀ i, checkPalin1.go xs i = true ↔ ∀ j, i ≤ j → (_ : j < xs.size / 2) → xs[j] = xs[xs.size - 1 - j] by
24-
-- We need array extensionality. TODO: easy way to enable array extensionality, `extAll` enables all [ext] theorems
25-
-- TODO: `IsPalindrome` (without `.eq_1`) produces bad error message.
26-
grind +extAll [IsPalindrome.eq_1]
26+
grind [IsPalindrome]
2727
intro i
2828
fun_induction checkPalin1.go <;> grind

0 commit comments

Comments
 (0)