Zulip Chat Archive

Stream: new members

Topic: unfold does not work on simple inductive definition


Gabin Kolly (Oct 24 2024 at 16:16):

Here is a simplified version of an inductive construction that I'm trying to do. I want to prove some simple properties about this definition, but Lean does not want to simplify certain expressions, and does not want to unfold.

import Mathlib.Data.Nat.Notation
universe u

noncomputable def A : (n : ) 
    (A : Type u) × (  (B : Type u) × (B  A))
  | 0 => sorry
  | n + 1 => by
    let An := A n -- removing this line solves the problem
    exact sorry

theorem simple_lemma {n : } :
    (A n).2 = sorry := by
  match n with
    | 0 =>
        sorry
    | n + 1 =>
        unfold A
        -- tactic 'unfold' failed to unfold 'A' at
        -- (A (n + 1)).snd= sorryAx (Type u_1)

Is there a reason why Lean does not want to do this, and is there a simple solution? I cannot really use a simpler inductive construction.

Kyle Miller (Oct 24 2024 at 16:44):

It seems to be that Sigma.snd making it impossible to rewrite. You can check by trying to use conv to navigate into that argument. Roughly speaking, if conv can't navigate there, neither can simp or unfold.

Removing the let looks like it solves the problem, but all that's doing is making the definition non-recursive. That means the lemma A.eq_def (which unfold uses) is now a definitional equality. The simp and unfold tactics can rewrite the argument to Sigma.snd when this is a definitional equality.

Kyle Miller (Oct 24 2024 at 16:44):

Can you make a more representative mwe? There are probably ways around this, but it depends on more details.

Kyle Miller (Oct 24 2024 at 16:46):

Actually, maybe rw [A] is sufficient?

Gabin Kolly (Oct 24 2024 at 16:48):

Yes, and that also works in the real version! Thank you!


Last updated: May 02 2025 at 03:31 UTC