lean4-htt/tests/lean/run/5064.lean
Kyle Miller 23236ef520
fix: have Lean.Meta.isConstructorApp'? be aware of n + k Nat offsets (#6270)
This PR fixes a bug that could cause the `injectivity` tactic to fail in
reducible mode, which could cause unfolding lemma generation to fail
(used by tactics such as `unfold`). In particular,
`Lean.Meta.isConstructorApp'?` was not aware that `n + 1` is equivalent
to `Nat.succ n`.

Closes #5064
2024-12-01 18:04:32 +00:00

27 lines
578 B
Text

/-!
# Make sure `injection` tactic can handle `0 = n + 1`
https://github.com/leanprover/lean4/issues/5064
-/
/-!
Motivating example from #5064.
This failed when generating the splitter theorem for `thingy`.
-/
def thingy : List (Nat ⊕ Nat) → List Bool
| Sum.inr (_n + 2) :: l => thingy l
| _ => []
termination_by l => l.length
/-- info: ⊢ [] = [] -/
#guard_msgs in
theorem thingy_empty : thingy [] = [] := by
unfold thingy
trace_state
rfl
/-!
Test using `injection` directly.
-/
example (n : Nat) (h : 0 = n + 1) : False := by
with_reducible injection h