1-- Natural numbers as von Neumann ordinals2-- Part of Cumulus, the Grace17 mathematics library.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Cumulus.Nat.Foundation8import Core.Nat9import Set.Ordinal1011-- Natural numbers compute compactly, while these theorems expose their12-- von Neumann set interpretation whenever a proof needs raw membership.13lemma membership.successor (m n : Nat)14shows m ∈ succ(n) ↔ (m ∈ n ∨ m = n)15proof16simp1718lemma membership.successor_set (x : Set) {n : Nat}19shows x ∈ succ(n) ↔ (x ∈ n ∨ x = n)20proof21simp2223lemma membership.successor_forward (x : Set) {n : Nat}24requires h : x ∈ succ(n)25shows x ∈ n ∨ x = n26proof27simp2829lemma membership.successor_backward (x : Set) {n : Nat}30requires h : x ∈ n ∨ x = n31shows x ∈ succ(n)32proof33simp3435-- Every position in a finite ordinal is itself a natural number.36theorem natural.member (n : Nat)37shows∀ i ∈ n, Nat(i)38proof39induction n40| zero =>41intros i hi42rw nat.zero at hi43exfalso44exactset.empty with hi45| succ(k) using ih =>46intros i hi47have alternatives := membership.successor_forward{n := k} with hi48cases alternatives with before | equal49 . exact ih with i, before50 . rw equal51assumption5253lemma membership.self_successor (n : Nat)54shows n ∈ succ(n)55proof56simp5758lemma membership.two_in_five59shows2∈560proof61simp [next.natural, next.membership]6263theorem membership.one (x : Set)64shows x ∈1↔ x =065proof66have successorZero := next.natural at067rw successorZero68simp [next.membership, nat.zero, set.empty]6970theorem membership.two (x : Set)71shows x ∈2↔ (x =0∨ x =1)72proof73havesplit:= membership.successor_set{n :=1} at x74have one := membership.one at x75tauto7677theorem membership.three (x : Set)78shows x ∈3↔ (x =0∨ x =1∨ x =2)79proof80havesplit:= membership.successor_set{n :=2} at x81have two := membership.two at x82tauto8384theorem natural.zero_one_or_above_one (n : Nat)85shows n =0∨ n =1∨1∈ n86proof87induction n88| zero =>89left90rfl91| succ(k) using ih =>92cases ih with hkZero | hkRest93 . right94left95rw hkZero96rfl97 . cases hkRest with hkOne | hkAbove98 . right99right100rw hkOne101settlewith membership.successor,102 Naturals.constructor.zero, Naturals.constructor.succ103 . right104right105settlewith membership.successor, hkAbove,106 Naturals.constructor.zero, Naturals.constructor.succ107108theorem natural.zero_or_successor (n : Nat)109shows n =0∨∃ k, Nat(k) ∧ n = succ(k)110proof111induction n112| zero =>113left114rfl115| succ(k) using ih =>116right117refine⟨k, assumption, rfl⟩118119-- Every member of a natural number is a natural number.120theorem natural.member_natural (n : Nat)121shows∀ x ∈ n, Nat(x)122proof123induction n124| zero =>125intros x hx126have z := nat.zero127rw z at hx128exfalso129exactset.empty with hx130| succ(k) using ih =>131intros x hx132have d := membership.successor_forward{n := k} with hx133cases d with inner | same134 . exact ih with x, inner135 . rw same136assumption137138-- ω, the set of all natural numbers, is an ordinal: it is transitive, and139-- so is each of its members.140theoremOrdinal.omega141shows ω ∈Ordinal142proof143constructor144intros n hn x hx145have hnat := nat.omega.backward with hn146have members := natural.member_natural with hnat147have xnat := members with x, hx148exact nat.omega.forward with xnat149 . intros n hn150have hnat := nat.omega.backward with hn151have ord :=Ordinal.natural with hnat152exactOrdinal.transitive with ord153154-- ω is a limit ordinal: nonempty and closed under successor.155theorem Limit.omega156shows Limit(ω)157proof158constructor159 . exactOrdinal.omega160 . constructor161 . intro e162have zeroNat := Naturals.constructor.zero163have z := nat.omega.forward with zeroNat164rw e at z165exactset.empty with z166 . intros n hn167have hnat := nat.omega.backward with hn168have step := next.natural with hnat169rw← step170have snat := Naturals.constructor.succ with hnat171exact nat.omega.forward with snat172