theorem_proving_in_lean4 icon indicating copy to clipboard operation
theorem_proving_in_lean4 copied to clipboard

recursion depth problem in chapter 7 examples

Open ketilwright opened this issue 3 months ago • 0 comments

These examples in Chapter 7, Inductive Types raise recursion depth errors:

namespace Hidden
theorem add_zero (n : Nat) : n + 0 = n := Nat.add_zero n
open Nat

theorem zero_add (n : Nat) : 0 + n = n := by
  induction n <;> simp [*, add_zero, add_succ]

theorem succ_add (m n : Nat) : succ m + n = succ (m + n) := by
  induction n <;> simp [*, add_zero, add_succ]

theorem add_comm (m n : Nat) : m + n = n + m := by
  induction n <;> simp [*, add_zero, add_succ, succ_add, zero_add]

theorem add_assoc (m n k : Nat) : m + n + k = m + (n + k) := by
  induction k <;> simp [*, add_zero, add_succ]
end Hidden

As suggested, I tried set_option maxRecDepth 10000 (which I pulled out of thin air) which didn't help. So I set it to 1000000, at which point we get a "stack overflow detected" message.

ketilwright avatar Oct 30 '24 22:10 ketilwright