Zulip Chat Archive
Stream: general
Topic: fin.induction
Patrick Massot (May 16 2022 at 20:53):
Does anyone know what are the equations for fin.induction_on
? I was expecting something like:
import data.fin.basic
variables {n : ℕ}
@[simp] lemma fin.induction_on_zero
{C : fin (n + 1) → Sort*}
(h0 : C 0)
(hs : ∀ i : fin n, C i.cast_succ → C i.succ) :
@fin.induction_on n 0 C h0 hs = h0 :=
rfl
@[simp] lemma fin.induction_on_succ
{C : fin (n + 1) → Sort*}
(h0 : C 0)
(hs : ∀ i : fin n, C i.cast_succ → C i.succ)
(i : fin n) :
@fin.induction_on n i.succ C h0 hs = hs i (@fin.induction_on n i.cast_succ C h0 hs) :=
rfl
But the second one fails.
Patrick Massot (May 16 2022 at 20:53):
Am I confused with my fin.succ
, fin.cast_succ
etc?
Patrick Massot (May 16 2022 at 20:54):
I find it rather suspicious that docs#fin.induction is defined in tactic mode. This seems to ask for trouble when writing the above lemmas.
Kyle Miller (May 16 2022 at 20:56):
It's the rcases
at the beginning I think. If you do cases i
it unsticks the rfl
.
lemma fin.induction_on_succ
{C : fin (n + 1) → Sort*}
(h0 : C 0)
(hs : ∀ i : fin n, C i.cast_succ → C i.succ)
(i : fin n) (j : C i.cast_succ) :
@fin.induction_on n i.succ C h0 hs = hs i (@fin.induction_on n i.cast_succ C h0 hs) :=
begin
cases i,
refl,
end
Patrick Massot (May 16 2022 at 21:03):
Nice!
Patrick Massot (May 16 2022 at 21:03):
Arguably we should fix docs#fin.induction anyway
Eric Wieser (May 16 2022 at 21:12):
I suspect it's done in tactic mode as the version generated by the equation compiler doesn't reduce in the kernel
Kyle Miller (May 16 2022 at 21:13):
I had some troubles with using the equation compiler for this (as in it didn't reduce nicely when trying to prove fin.induction_on_succ
)
Kyle Miller (May 16 2022 at 21:13):
Here's the tactic proof as a term mode proof:
@[elab_as_eliminator]
def fin.induction'
{C : fin (n + 1) → Sort*}
(h0 : C 0)
(hs : ∀ i : fin n, C i.cast_succ → C i.succ)
(i : fin (n + 1)) : C i :=
subtype.cases_on i $ λ i hi,
nat.rec (λ hi, h0)
(λ i IH hi, hs ⟨i, nat.lt_of_succ_lt_succ hi⟩ (IH (nat.lt_of_succ_lt hi)))
i hi
Eric Wieser (May 16 2022 at 21:15):
Is there any advantage to that proof over the one we have?
Kyle Miller (May 16 2022 at 21:16):
It's pretty much exactly the same.
Eric Wieser (May 16 2022 at 21:16):
I guess it doesn't have the eq.mpr in it, which is nice
Kyle Miller (May 16 2022 at 21:17):
At the h0
? That's along a rfl
lemma anyway, so I'm not sure it matters
Last updated: Dec 20 2023 at 11:08 UTC