lean4-htt/tests/elab/grind_12812.lean
Leonardo de Moura dbfd0d35f2
fix: simp +arith and grind loop on normalized Int equalities (#13033)
This PR adds `r == e` guards to the `norm_eq_var` and
`norm_eq_var_const` branches of `Int.Linear.simpEq?`. Without these
guards, `simpEq?` returns a non-trivial proof for already-normalized
equations like `x = -1`, causing `exists_prop_congr` to fire repeatedly
and build an infinitely growing term.

The existing `Nat.simpCnstrPos?` already had the equivalent guard (`if r
!= lhs then ... else return none`).

Closes #12812

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 04:04:56 +00:00

15 lines
678 B
Text

-- Tests for https://github.com/leanprover/lean4/issues/12812
-- `grind` and `simp +arith` should not loop on already-normalized Int equalities
-- The original report: deep recursion on negative integer literal
example (xs : List Int) (h : xs[0]? = some (-1)) : xs[0]? = some (-1) := by grind
-- Variant with simp +arith
example (xs : List Int) (h : xs[0]? = some (-1)) : xs[0]? = some (-1) := by simp +arith [h]
-- norm_eq_var branch: x = y already normalized
example (a b : Int) (h : a = b) : a = b := by grind
-- norm_eq_var_const branch: x = -k already normalized
example (a : Int) (h : a = -1) : a = -1 := by grind
example (a : Int) (h : a = -42) : a = -42 := by grind