Analysis I, Section 2.1: The Peano Axioms #
This file is a translation of Section 2.1 of Analysis I to Lean 4. All numbering refers to the original text.
I have attempted to make the translation as faithful a paraphrasing as possible of the original text. When there is a choice between a more idiomatic Lean solution and a more faithful translation, I have generally chosen the latter. In particular, there will be places where the Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided doing so.
Main constructions and results of this section:
- Definition of the "Chapter 2" natural numbers,
Chapter2.Nat, abbreviated asNatwithin the Chapter2 namespace. (In the book, the natural numbers are treated in a purely axiomatic fashion, as a type that obeys the Peano axioms; but here we take advantage of Lean's native inductive types to explicitly construct a version of the natural numbers that obey those axioms. One could also proceed more axiomatically, as is done in Section 3 for set theory: see the epilogue to this chapter.) - Establishment of the Peano axioms for
Chapter2.Nat. - Recursive definitions for
Chapter2.Nat.
Note: at the end of this chapter, the Chapter2.Nat class will be deprecated in favor of the
standard Mathlib class _root_.Nat, or ℕ. However, we will develop the properties of
Chapter2.Nat "by hand" in the next few sections for pedagogical purposes.
Equations
- Chapter2.instReprNat = { reprPrec := Chapter2.reprNat✝ }
Axiom 2.1 (0 is a natural number)
Equations
- Chapter2.Nat.instZero = { zero := Chapter2.Nat.zero }
Axiom 2.2 (Successor of a natural number is a natural number)
Equations
- Chapter2.«term_++» = Lean.ParserDescr.trailingNode `Chapter2.«term_++» 100 100 (Lean.ParserDescr.symbol "++")
Instances For
Definition 2.1.3 (Definition of the numerals 0, 1, 2, etc.). Note: to avoid ambiguity, one may need to use explicit casts such as (0:Nat), (1:Nat), etc. to refer to this chapter's version of the natural numbers.
Equations
- Chapter2.Nat.instOfNat = { ofNat := Nat.rec 0 (fun (x : ℕ) (n : Chapter2.Nat) => n++) n }
Axiom 2.3 (0 is not the successor of any natural number).
Compare with Lean's Nat.succ_ne_zero.
Axiom 2.4 (Different natural numbers have different successors).
Compare with Mathlib's Nat.succ_inj.
Axiom 2.4 (Different natural numbers have different successors).
Compare with Mathlib's Nat.succ_ne_succ.
One can also prove this sort of result by the decide tactic
Recursion. Analogous to the inbuilt Mathlib method Nat.rec associated to
the Mathlib natural numbers
Equations
- Chapter2.Nat.recurse f c Chapter2.Nat.zero = c
- Chapter2.Nat.recurse f c (a++) = f a (Chapter2.Nat.recurse f c a)
Instances For
Proposition 2.1.16 (recursive definitions). Compare with Mathlib's Nat.rec_zero.