Zulip Chat Archive

Stream: Is there code for X?

Topic: Induction principles


Bolton Bailey (Sep 25 2023 at 17:12):

Do we have something like

lemma list_induction (P : List α → Prop) :
    (∀ (l : List α), P l) ↔ ( P [] ∧ (∀ (a : α) (l : List α), P l → P (a :: l))) := by
  sorry

Bolton Bailey (Sep 25 2023 at 17:13):

I feel like I was told once that when an inductive datatype is declared, a lemma like this is automatically generated.

Junyan Xu (Sep 25 2023 at 17:18):

#check List.rec
/- List.rec.{u_1, u} {α : Type u} {motive : List α → Sort u_1} (nil : motive [])
  (cons : (head : α) → (tail : List α) → motive tail → motive (head :: tail)) (t : List α) : motive t -/
lemma list_induction {α} (P : List α → Prop) :
    (∀ (l : List α), P l) ↔ ( P [] ∧ (∀ (a : α) (l : List α), P l → P (a :: l))) :=
  ⟨fun h ↦ ⟨h _, fun _ _ _ ↦ h _⟩, fun h ↦ List.rec h.1 h.2⟩

Last updated: Feb 28 2026 at 14:05 UTC