Zulip Chat Archive

Stream: lean4

Topic: Nested unfolding


Siddhartha Gadgil (Jun 09 2021 at 06:08):

I had hoped (perhaps unreasonably) that the following should unfold and be proved by reflexivity (actually a little more complicated case, but this is after minimization. Could someone help me with the best approach (lean 4 stable build)?

def shiftAtNat : (n : Nat)   (k: Nat)  Nat  Nat :=
      fun n =>
        match n with
        | 0 =>
          fun k =>
                  fun _ =>
                    0
        | m + 1 =>
          fun k =>
            match k with
            | 0 =>
                fun i =>
                  i + 1
            | l+1 =>
                fun j =>
                  match j with
                  | 0 => 0
                  | i + 1 =>
                      (shiftAtNat m l i) + 1

theorem seqShiftNatLemma: (m: Nat)  (l: Nat)  (i : Nat) 
     (shiftAtNat (m + 1) (l + 1)  (i + 1)) =
      (shiftAtNat m l  i) + 1 := sorry

Thanks.

Mario Carneiro (Jun 09 2021 at 06:20):

I believe this to be a bug, leanprover/lean4#445

Mario Carneiro (Jun 09 2021 at 06:21):

The proof is rfl but you have to circumvent the elaborator to get the proof to be accepted

Siddhartha Gadgil (Jun 09 2021 at 06:26):

Thanks. How do I circumvent the elaborator?

Mario Carneiro (Jun 09 2021 at 06:26):

Actually, I tested this and the generated smart unfolding lemma is fine; the only issue is you didn't intro the arguments

Mario Carneiro (Jun 09 2021 at 06:26):

theorem seqShiftNatLemma (m l i : Nat) :
     (shiftAtNat (m + 1) (l + 1)  (i + 1)) =
      (shiftAtNat m l  i) + 1 := rfl

Siddhartha Gadgil (Jun 09 2021 at 06:29):

Thanks a lot. I now see that fun m => fun l => fun i => rfl also works.

Mario Carneiro (Jun 09 2021 at 06:29):

you can also write fun m l i => rfl fyi

Mario Carneiro (Jun 09 2021 at 06:30):

same thing with the (m l i : Nat) → ... binder

Siddhartha Gadgil (Jun 09 2021 at 06:41):

Yes, thanks. I am learning lean and so tend to be very verbose.


Last updated: Dec 20 2023 at 11:08 UTC