Zulip Chat Archive

Stream: mathlib4

Topic: recursion limit in `exact?`


Eric Wieser (Jan 15 2025 at 01:59):

This causes a maximum recursion depth error:

import Mathlib

example (n : Nat) : n = 55 := by
  exact?

Eric Wieser (Jan 15 2025 at 02:06):

Is this expected? It doesn't do it with import Batteries, even for much larger constants

llllvvuu (Jan 15 2025 at 23:32):

minimized a bit:

import Mathlib.SetTheory.Ordinal.Basic

theorem natCast_inj {m n : } : (m : Ordinal) = n  m = n := sorry

example (n : Nat) : n = 55 := by
  exact?

Eric Wieser (Jan 16 2025 at 00:03):

Thanks! That's not what I expected at all, I was sure the 55 would have to decrease with the number of imports!

Eric Wieser (Jan 16 2025 at 00:06):

Adding natCast := Nat.unaryCast to docs#Ordinal.addMonoidWithOne fixes it

Eric Wieser (Jan 16 2025 at 00:10):

#20784

llllvvuu (Jan 16 2025 at 00:40):

I guess I should have considered that multiple things can trigger this:

def factorial : Nat  Nat
  | 0 => 1
  | .succ n => .succ n * factorial n

theorem factorial_inj (hn : 1 < n) : factorial n = factorial m  n = m := by sorry

example (n : Nat) : n = 125 := by
  exact?

Probably it is just hard to reduce the Nat.rec:

import Mathlib.SetTheory.Ordinal.Basic

#reduce inferInstanceAs (NatCast Ordinal)
#reduce (inferInstanceAs (NatCast Ordinal)).natCast 84

Eric Wieser (Jan 16 2025 at 00:42):

I guess this is an argument for with_reducible exact?

Violeta Hernández (Jan 16 2025 at 04:07):

Dammit! Is this my fault?


Last updated: May 02 2025 at 03:31 UTC