book/TPiL/InductiveTypes.lean
Explanation legend Lean4 Domain Explanation Language (L4DEL)
L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.
- L4DEL
- Lean4 Domain Explanation Language
Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.
Project sources: Pinned Theorem Proving in Lean documentation, Pinned Theorem Proving in Lean 4 book index
152 declarations, 6 contain sorry, 0 declared as axioms
Imports (2)
VersoManualTPiL.Examples
- inductive
Fooline 40 sourceDistinct definitions of this name: book/TPiL/PropositionsAndProofs.lean:608 (same statement text; different proof or body). Qualify references as Foo@path.
- inductive
Fooline 48 sourceDistinct definitions of this name: book/TPiL/PropositionsAndProofs.lean:608 (same statement text; different proof or body). Qualify references as Foo@path.
- inductive
Weekdayline 101 source - inductive
Weekdayline 115 source - inductive
Weekdayline 138 source - inductive
Weekdayline 150 source - inductive
Weekdayline 190 source - def
numberOfDayline 201 source - inductive
Weekdayline 224 source - def
numberOfDayline 235 source - inductive
Weekdayline 262 source - structure
inline 279 source - inductive
Weekdayline 287 source - def
Weekday.nextline 298 source - def
Weekday.previousline 308 source - example
Weekday.(example at line 322)line 322 source - inductive
Weekdayline 335 source - def
Weekday.nextline 345 source - def
Weekday.previousline 354 source - theorem
Weekday.next_previousnext undoes previous, by cases on the constructors line 364 sourceSource comment
----L4DEL explanation
Weekday has seven constructors, so match gives seven cases, each true by computation.
- Weekday is an inductive type with constructors sunday through saturday, and next and previous move one day forward and back.
- theorem next_previous (d : Weekday) : next (previous d) = d is proved with match d with.
- In each of the seven cases the two sides reduce to the same constructor, so the proof is rfl.
- The book follows this with a shorter version of the proof.
Sources and attribution: Pinned Lean source (4e28129fdd58)
inductive type: a type generated freely by a list of constructors, such as the seven weekdays.
theorem next_previous (d : Weekday) : next (previous d) = d := …
Mentions: Weekday.Weekday, Weekday.next, Weekday.previous
- inductive
Weekday.Weekdayline 379 source - def
Weekday.Weekday.nextline 389 source - def
Weekday.Weekday.previousline 398 source - theorem
Weekday.Weekday.next_previousline 408 sourceSource comment
----theorem next_previous (d : Weekday) : next (previous d) = d := by …
Mentions: Weekday.Weekday, Weekday.Weekday.next, Weekday.Weekday.previous
- inductive
Weekday.Weekday.Hidden.Boolline 427 sourceSource comment
----inductive Bool where …
- def
Weekday.Weekday.Hidden.andline 450 sourceSource comment
----def and (a b : Bool) : Bool := …
Mentions: b, Weekday.Weekday.Hidden.Bool
- inductive
Weekday.Weekday.Hidden.Prodline 480 sourceSource comment
----inductive Prod (α : Type u) (β : Type v) | mk : α → β → Prod α β
- inductive
Weekday.Weekday.Hidden.Sumline 483 source - inductive
Weekday.Weekday.Hidden.Prodline 501 source - def
Weekday.Weekday.Hidden.fstline 504 sourceSource comment
----def fst {α : Type u} {β : Type v} (p : Prod α β) : α := …Mentions: α, β, Weekday.Weekday.Hidden.Prod
- def
Weekday.Weekday.Hidden.sndline 508 source - def
Weekday.Weekday.prod_exampleline 531 source - def
Weekday.Weekday.sum_exampleline 564 source - inductive
Weekday.Weekday.Hidden.Prodline 623 sourceSource comment
----inductive Prod (α : Type u) (β : Type v) where …
- inductive
Weekday.Weekday.Hidden.Sumline 626 source - structure
Weekday.Weekday.Hidden.Prodline 646 sourceSource comment
----structure Prod (α : Type u) (β : Type v) where …
- example
Weekday.Weekday.(example at line 660)line 660 source - structure
Weekday.Weekday.Colorline 664 source - def
Weekday.Weekday.yellowline 670 source - structure
Weekday.Weekday.Semigroupline 684 source - inductive
Weekday.Weekday.Hidden.Sigmaline 698 sourceSource comment
----inductive Sigma {α : Type u} (β : α → Type v) where … - inductive
Weekday.Weekday.Hidden.Optionline 710 sourceSource comment
----inductive Option (α : Type u) where …
Mentions: α
- inductive
Weekday.Weekday.Hidden.Inhabitedline 714 source - inductive
Weekday.Weekday.Hidden.Falseline 762 sourceSource comment
----inductive False : Prop
- inductive
Weekday.Weekday.Hidden.Trueline 764 source - inductive
Weekday.Weekday.Hidden.Andline 767 source - inductive
Weekday.Weekday.Hidden.Orline 770 source - inductive
Weekday.Weekday.Hidden.Existsline 798 sourceSource comment
----inductive Exists {α : Sort u} (p : α → Prop) : Prop where …Mentions: α
- inductive
Weekday.Weekday.Hidden.Subtypeline 828 sourceSource comment
----inductive Subtype {α : Type u} (p : α → Prop) where …Mentions: α
- structure
Weekday.Weekday.Hidden.Subtypeline 845 sourceSource comment
----structure Subtype {α : Sort u} (p : α → Prop) where …Mentions: α
- inductive
Weekday.Weekday.Hidden.Natline 875 sourceSource comment
----inductive Nat where …
- def
Weekday.Weekday.addline 939 source - inductive
Weekday.Weekday.Hidden.Natline 957 sourceSource comment
----inductive Nat where …
- def
Weekday.Weekday.Hidden.addline 962 source - inductive
Weekday.Weekday.Hidden.Natline 981 source - def
Weekday.Weekday.Hidden.Nat.addline 988 source - instance
Weekday.Weekday.Hidden.Nat.(instance at line 993)line 993 source - theorem
Weekday.Weekday.Hidden.Nat.add_zeroline 996 source - theorem
Weekday.Weekday.Hidden.Nat.add_succline 997 source - theorem
Weekday.Weekday.Hidden.zero_addline 1027 source - theorem
Weekday.Weekday.Hidden.zero_addline 1053 source - theorem
Weekday.Weekday.Hidden.add_assocline 1077 source - theorem
Weekday.Weekday.add_assocline 1095 source - theorem
Weekday.Weekday.add_commFirst attempt at commutativity of Nat addition (contains sorry) sorry line 1105 sourceL4DEL explanation
Induct on the second argument; one equation in the step is not yet proved and is left as sorry.
- This is a work-in-progress block in the book: the last calc step ends with := sorry, so Lean accepts it only with a warning.
- Nat.recOn with motive fun x => m + x = x + m does induction on n; the base case m + 0 = 0 + m is proved with Nat.zero_add and Nat.add_zero.
- In the inductive step a calc rewrites m + succ n to succ (m + n), then to succ (n + m) using the induction hypothesis.
- The missing step succ (n + m) = succ n + m is what the book proves next as succ_add, then plugs in to replace the sorry.
See also: Weekday.Weekday.succ_add
Sources and attribution: Pinned Lean source (4e28129fdd58)
induction hypothesis: in the inductive step, the assumption that the property holds for n, used to prove it for succ n.
theorem add_comm (m n : Nat) : m + n = n + m := …
- theorem
Weekday.Weekday.succ_addsorry line 1122 source - inductive
Weekday.Weekday.Hidden.Natline 1137 source - def
Weekday.Weekday.Hidden.addline 1142 source - instance
Weekday.Weekday.Hidden.(instance at line 1147)line 1147 source - theorem
Weekday.Weekday.Hidden.Nat.add_zeroline 1151 source - theorem
Weekday.Weekday.Hidden.Nat.add_succline 1153 source - theorem
Weekday.Weekday.Hidden.Nat.zero_addline 1155 source - theorem
Weekday.Weekday.Hidden.succ_addline 1163 source - theorem
Weekday.Weekday.Hidden.add_commline 1168 source - inductive
Weekday.Weekday.Hidden.Listline 1189 sourceSource comment
----inductive List (α : Type u) where …
Mentions: α
- def
Weekday.Weekday.Hidden.List.appendline 1195 source - theorem
Weekday.Weekday.Hidden.List.nil_appendline 1200 source - theorem
Weekday.Weekday.Hidden.List.cons_appendline 1203 source - inductive
Weekday.Weekday.Hidden.Listline 1222 source - def
Weekday.Weekday.Hidden.List.appendline 1226 source - theorem
Weekday.Weekday.Hidden.List.nil_appendline 1230 source - theorem
Weekday.Weekday.Hidden.List.cons_appendline 1232 source - theorem
Weekday.Weekday.Hidden.List.append_nilsorry line 1236 sourceSource comment
----theorem append_nil (as : List α) : append as nil = as := …Mentions: as, Weekday.Weekday.Hidden.List, α, Weekday.Weekday.Hidden.List.append
- theorem
Weekday.Weekday.Hidden.List.append_assocsorry line 1240 source - def
Weekday.Weekday.lengthline 1251 source - def
Weekday.Weekday.appendline 1252 source - inductive
Weekday.Weekday.BinaryTreeline 1263 source - inductive
Weekday.Weekday.CBTreeline 1271 source - def
Weekday.Weekday.CBTree.succline 1277 source - def
Weekday.Weekday.CBTree.toCBTreeline 1280 source - def
Weekday.Weekday.CBTree.omegaline 1284 source - example
Weekday.Weekday.(example at line 1312)line 1312 source - example
Weekday.Weekday.(example at line 1355)line 1355 source - def
Weekday.Weekday.fline 1369 source - example
Weekday.Weekday.(example at line 1372)line 1372 source - example
Weekday.Weekday.(example at line 1373)line 1373 source - def
Weekday.Weekday.Tupleline 1379 source - def
Weekday.Weekday.fline 1382 source - def
Weekday.Weekday.myTupleline 1385 source - example
Weekday.Weekday.(example at line 1388)line 1388 source - inductive
Weekday.Weekday.Fooline 1395 source - def
Weekday.Weekday.sillyline 1399 source - inductive
Weekday.Weekday.Fooline 1409 source - def
Weekday.Weekday.sillyline 1413 sourceSource comment
----def silly (x : Foo) : Nat := by …
Mentions: x, Weekday.Weekday.Foo
- inductive
Weekday.Weekday.Fooline 1425 source - def
Weekday.Weekday.sillyline 1429 sourceSource comment
----def silly (x : Foo) : Nat := by …
Mentions: x, Weekday.Weekday.Foo
- inductive
Weekday.Weekday.Fooline 1439 source - def
Weekday.Weekday.sillyline 1443 sourceSource comment
----def silly (x : Foo) : Nat := by …
Mentions: x, Weekday.Weekday.Foo
- example
Weekday.Weekday.(example at line 1457)line 1457 source - example
Weekday.Weekday.(example at line 1471)line 1471 source - example
Weekday.Weekday.(example at line 1493)line 1493 source - example
Weekday.Weekday.(example at line 1509)line 1509 source - example
Weekday.Weekday.(example at line 1527)line 1527 source - theorem
Weekday.Weekday.Hidden.zero_addline 1549 sourceSource comment
----theorem zero_add (n : Nat) : 0 + n = n := by …
Mentions: n, Weekday.Weekday.Hidden.Nat
- theorem
Weekday.Weekday.Hidden.zero_addline 1564 sourceSource comment
----theorem zero_add (n : Nat) : 0 + n = n := by …
Mentions: n, Weekday.Weekday.Hidden.Nat
- inductive
Weekday.Weekday.Hidden.Natline 1579 source - def
Weekday.Weekday.Hidden.Nat.toNatline 1583 source - def
Weekday.Weekday.Hidden.Nat.ofNatline 1587 source - def
Weekday.Weekday.Hidden.addline 1591 source - instance
Weekday.Weekday.Hidden.(instance at line 1596)line 1596 source - instance
Weekday.Weekday.Hidden.(instance at line 1599)line 1599 source - theorem
Weekday.Weekday.Hidden.zero_zeroline 1603 source - theorem
Weekday.Weekday.Hidden.add_zeroline 1604 source - theorem
Weekday.Weekday.Hidden.add_succline 1605 source - theorem
Weekday.Weekday.Hidden.zero_addline 1609 source - theorem
Weekday.Weekday.Hidden.succ_addline 1612 source - theorem
Weekday.Weekday.Hidden.add_commline 1615 source - theorem
Weekday.Weekday.Hidden.add_assocline 1618 source - example
Weekday.Weekday.(example at line 1637)line 1637 source - example
Weekday.Weekday.(example at line 1655)line 1655 source - example
Weekday.Weekday.(example at line 1666)line 1666 source - example
Weekday.Weekday.(example at line 1670)line 1670 source - example
Weekday.Weekday.(example at line 1691)line 1691 source - example
Weekday.Weekday.(example at line 1708)line 1708 source - example
Weekday.Weekday.(example at line 1711)line 1711 source - example
Weekday.Weekday.(example at line 1714)line 1714 source - inductive
Weekday.Weekday.fooline 1735 source - inductive
Weekday.Weekday.Vectline 1756 source - inductive
Weekday.Weekday.Hidden.Eqline 1772 sourceSource comment
----inductive Eq {α : Sort u} (a : α) : α → Prop where …Mentions: α
- theorem
Weekday.Weekday.Hidden.substline 1813 sourceSource comment
----theorem subst {α : Type u} {a b : α} {p : α → Prop} (h₁ : Eq a b) (h₂ : p a) : p b := …Mentions: α, b, Weekday.Weekday.Hidden.Eq
- theorem
Weekday.Weekday.Hidden.substline 1825 sourceSource comment
----theorem subst {α : Type u} {a b : α} {p : α → Prop} (h₁ : Eq a b) (h₂ : p a) : p b := …Mentions: α, b, Weekday.Weekday.Hidden.Eq
- theorem
Weekday.Weekday.substline 1837 source - theorem
Weekday.Weekday.Hidden.symmline 1864 source - theorem
Weekday.Weekday.Hidden.transsorry line 1868 source - theorem
Weekday.Weekday.Hidden.congrsorry line 1871 source - inductive
Weekday.Weekday.definitions,line 1879 source - inductive
Weekday.Weekday.typeline 1902 source - inductive
Weekday.Weekday.typesline 1909 source - inductive
Weekday.Weekday.definitionsline 1972 source - inductive
Weekday.Treeline 2027 source - def
Weekday.lengthline 2048 source - def
Weekday.reverseline 2051 source - inductive
Weekday.Termline 2058 source