/- Lecture 3 — the same proofs as in the kernel from the lecture (directory kernel/), this time in Lean 4. Boolean algebra in Huntington's eight axioms (1904), the complement written as a function `n`. Every `calc` step is closed by the tactic `rw` with one axiom — just like `rw("H6")` in boolean.py. No Mathlib: Lean alone is enough. Check: lean Lecture03.lean Compiled without errors: Lean 4.33.1 (the version in which the proof of the Riemann hypothesis was written). -/ /-- A Boolean algebra: operations `+`, `*`, the complement `n`, constants `0` and `1`, axioms H1–H8. -/ class HuntingtonAlgebra (α : Type) extends Add α, Mul α, Zero α, One α where n : α → α H1 : ∀ x y : α, x + y = y + x H2 : ∀ x y : α, x * y = y * x H3 : ∀ x y z : α, x + y * z = (x + y) * (x + z) H4 : ∀ x y z : α, x * (y + z) = x * y + x * z H5 : ∀ x : α, x + 0 = x H6 : ∀ x : α, x * 1 = x H7 : ∀ x : α, x + n x = 1 H8 : ∀ x : α, x * n x = 0 open HuntingtonAlgebra variable {α : Type} [HuntingtonAlgebra α] /-- Idempotence of the sum: the same chain as on the slides and in `boolean.py`. -/ theorem add_idem (x : α) : x + x = x := calc x + x = (x + x) * 1 := by rw [H6] _ = (x + x) * (x + n x) := by rw [H7] _ = x + x * n x := by rw [H3] _ = x + 0 := by rw [H8] _ = x := by rw [H5] theorem add_one (x : α) : x + 1 = 1 := calc x + 1 = (x + 1) * 1 := by rw [H6] _ = 1 * (x + 1) := by rw [H2] _ = (x + n x) * (x + 1) := by rw [H7] _ = x + n x * 1 := by rw [H3] _ = x + n x := by rw [H6] _ = 1 := by rw [H7] /-- Absorption uses an earlier theorem just like an axiom. -/ theorem absorb (x y : α) : x + x * y = x := calc x + x * y = x * 1 + x * y := by rw [H6] _ = x * (1 + y) := by rw [H4] _ = x * (y + 1) := by rw [H1] _ = x * 1 := by rw [add_one] _ = x := by rw [H6] /-- Involution: nine links of the chain. -/ theorem compl_compl (x : α) : n (n x) = x := calc n (n x) = n (n x) * 1 := by rw [H6] _ = n (n x) * (x + n x) := by rw [H7] _ = n (n x) * x + n (n x) * n x := by rw [H4] _ = n (n x) * x + 0 := by rw [H2 (n (n x)) (n x), H8] _ = n (n x) * x + x * n x := by rw [H8] _ = x * n (n x) + x * n x := by rw [H2] _ = x * (n (n x) + n x) := by rw [H4] _ = x * 1 := by rw [H1, H7] _ = x := by rw [H6] -- Which assumptions? The axioms H1–H8 are fields of the class, i.e. hypotheses of the theorems, not Lean axioms. #print axioms add_idem #print axioms compl_compl -- The proof term checked by Lean's kernel (Eq.mpr, congrArg, Eq.trans — like the rules of our kernel). #print add_idem