Imports
module import Mathlib.Tactic

Introduction

Analysis

The Peano Axioms

namespace PEANO_AXIOMS

Assumption 2.6 (Existence of natural numbers)

inductive Nat where | zero : Nat | succ : Nat → Nat

Axiom 2.1 (0 is a natural number)

instance : Zero Nat where zero := Nat.zero
0 : Nat#check (0 : Nat)
0 : Nat

Axiom 2.2 (Successor of a natural number is a natural number)

fun n ↦ n.succ : Nat → Nat#check fun (n : Nat) => Nat.succ n
fun n ↦ n.succ : Nat → Nat

Definition 2.1.3 (Definition of 0, 1, 2, etc.)

instance {n : _root_.Nat} : OfNat Nat n where ofNat := let rec nat (n : _root_.Nat) : Nat := match n with | 0 => Nat.zero | k + 1 => Nat.succ (nat k) nat n

Proposition 2.1.4 (3 is a natural number)

3 : Nat#check (3 : Nat)
3 : Nat

Axiom 2.3 (0 is not the successor of any natural number)

theorem Nat.succ_ne (n : Nat) : Nat.succ n ≠ (0 : Nat) := n:Nat⊢ n.succ ≠ 0 n:Nath:n.succ = 0⊢ False All goals completed! 🐙

Proposition 2.1.6 (4 is not equal to 0)

theorem Nat.four_ne : (4 : Nat) ≠ (0 : Nat) := ⊢ 4 ≠ 0 ⊢ succ 3 ≠ 0 All goals completed! 🐙

Axiom 2.4 (Different natural numbers have different successors)

theorem Nat.succ_cancel {n m : Nat} (h : Nat.succ n = Nat.succ m) : n = m := n:Natm:Nath:n.succ = m.succ⊢ n = m All goals completed! 🐙
theorem Nat.succ_ne_succ {n m : Nat} (h : n ≠ m) : Nat.succ n ≠ Nat.succ m := n:Natm:Nath:n ≠ m⊢ n.succ ≠ m.succ n:Natm:Nath:n.succ = m.succ⊢ n = m All goals completed! 🐙

Proposition 2.1.8 (Six is not equal to two)

theorem Nat.six_ne_two : (6 : Nat) ≠ (2 : Nat) := ⊢ 6 ≠ 2 ⊢ succ 5 ≠ succ 1 ⊢ 5 ≠ 1 ⊢ succ 4 ≠ succ 0 ⊢ 4 ≠ 0 All goals completed! 🐙

Axiom 2.5 (Principle of mathematical induction)

theorem Nat.induction (P : Nat → Prop) (hbase : P 0) (hind : ∀ n, P n → P (Nat.succ n)) : -- (n : Nat) → P n → P n.succ ∀ n, P n := P:Nat → Prophbase:P 0hind:∀ (n : Nat), P n → P n.succ⊢ ∀ (n : Nat), P n P:Nat → Prophbase:P 0hind:∀ (n : Nat), P n → P n.succn:Nat⊢ P n induction n with P:Nat → Prophbase:P 0hind:∀ (n : Nat), P n → P n.succ⊢ P zero All goals completed! 🐙 P:Nat → Prophbase:P 0hind:∀ (n : Nat), P n → P n.succn:Natih:P n⊢ P n.succ All goals completed! 🐙 -- ih is P n

Recursion.

abbrev Nat.recurse (f : Nat → Nat → Nat) (c : Nat) : Nat → Nat := fun n => match n with | 0 => c | Nat.succ k => f k (Nat.recurse f c k)
theorem Nat.recurse_zero (f : Nat → Nat → Nat) (c : Nat) : Nat.recurse f c 0 = c := f:Nat → Nat → Natc:Nat⊢ recurse f c 0 = c All goals completed! 🐙theorem Nat.recurse_succ (f : Nat → Nat → Nat) (c : Nat) (n : Nat) : Nat.recurse f c (Nat.succ n) = f n (Nat.recurse f c n) := f:Nat → Nat → Natc:Natn:Nat⊢ recurse f c n.succ = f n (recurse f c n) All goals completed! 🐙

Proposition 2.1.16 (recursive definitions)

theorem declaration uses `sorry`Nat.eq_recurse (f : Nat → Nat → Nat) (c : Nat) (a : Nat → Nat) : (a 0 = c ∧ ∀ n, a (Nat.succ n) = f n (a n)) ↔ a = Nat.recurse f c := f:Nat → Nat → Natc:Nata:Nat → Nat⊢ (a 0 = c ∧ ∀ (n : Nat), a n.succ = f n (a n)) ↔ a = recurse f c All goals completed! 🐙
end PEANO_AXIOMS