Ordinals are linearly ordered

Of any two ordinals, one belongs to the other or the two are equal. This is the fact everyone expects from ordinals, and it is the last thing about them the book has left to prove. It is also the first place where the constructible universe costs classical logic, so it deserves to be said plainly why.

Everything about ordinals up to now has been closure: zero is one, successors are, unions are, bounds exist. Closure statements build; they never have to decide anything. Trichotomy decides. Given two ordinals with no relation assumed between them, it returns which of three mutually exclusive cases holds, and there is no construction that could produce that answer from the data: the statement implies the excluded middle. So the chapter takes the excluded middle as a module parameter, in the packaging Part 0 fixed, and every later chapter that consumes it inherits the parameter visibly, at every import site.

Two ingredients from the ambient hierarchy make the proof shorter than the textbook version. Regularity gives a well-founded induction, and it is used twice over, once in each argument. Extensionality means that mutual inclusion is equality, so the equal case needs no separate work. What the excluded middle then supplies is exactly one thing: the decision whether one ordinal is included in the other, and, when it is not, a member witnessing the failure.

{-# OPTIONS --cubical --safe --guardedness #-}

open import Base.Prelude
open import Base.Truth
open import Base.Classical using ( LEM )

module L.Ordinal.Linear { : Level} (lem : LEM (ℓ-suc )) where

open import FOL.ZFStructure using ( module hPropStructure )
open import V.Hierarchy {} using ( 𝒮ᵥ; extensionalV; regularityV )
open import L.Constructible {} using ( IsOrd )
open import L.Ordinal {} using ( mem-ord )

open import Cubical.Data.Sum using ( _⊎_; inl; inr )
open import Cubical.Functions.Logic using ( ⇔toPath )
import Cubical.Data.Empty as Empty
import Cubical.HITs.PropositionalTruncation as PT
open PT using ( ∣_∣₁; ∥_∥₁ )
import Cubical.Induction.WellFounded as WF

open TruthAlgebra (hPropAlgebra (ℓ-suc ))
open hPropStructure 𝒮ᵥ

Inclusion, and what fails it

Inclusion is written pointwise, and packaged as a proposition so that the excluded middle can be applied to it directly: quantifying over a carrier that lives one universe up is why the interface was stated levelwise in Part 0. Mutual inclusion gives equality, by the hierarchy's extensionality.

_⊆ᵇ_ : S  S  Type (ℓ-suc )
A ⊆ᵇ B = (x : S)   x ∈ˢ A    x ∈ˢ B 

⊆ᵇ-prop : (A B : S)  hProp (ℓ-suc )
⊆ᵇ-prop A B = (A ⊆ᵇ B) , isPropΠ  x  isPropΠ  _  snd (x ∈ˢ B)))

ext-⊆ᵇ : {A B : S}  A ⊆ᵇ B  B ⊆ᵇ A  A  B
ext-⊆ᵇ {A} {B} s₁ s₂ = extensionalV  x  ⇔toPath (s₁ x) (s₂ x))

Here is the one genuinely classical step. From a failure of inclusion the proof needs a member witnessing it, and passing from "not every member is in B" to "some member is not in B" is not constructive. The excluded middle decides the existence statement directly: were there no such witness, every member would be in B after all, decided one member at a time.

¬⊆ᵇ→witness : (A B : S)  (A ⊆ᵇ B  Empty.⊥)
              Σ[ a  S ] ( a ∈ˢ A  × ( a ∈ˢ B   Empty.⊥)) ∥₁
¬⊆ᵇ→witness A B ¬sub = decide (lem Witness)
  where
  Witness : hProp (ℓ-suc )
  Witness =  Σ[ a  S ] ( a ∈ˢ A  × ( a ∈ˢ B   Empty.⊥)) ∥₁
          , PT.isPropPropTrunc
  decide :  Witness   ( Witness   Empty.⊥)   Witness 
  decide (inl wit)  = wit
  decide (inr ¬wit) = Empty.rec (¬sub sub)
    where
    sub : A ⊆ᵇ B
    sub x x∈A = at (lem (x ∈ˢ B))
      where
      at :  x ∈ˢ B   ( x ∈ˢ B   Empty.⊥)   x ∈ˢ B 
      at (inl x∈B)  = x∈B
      at (inr ¬x∈B) = Empty.rec (¬wit  x , (x∈A , ¬x∈B) ∣₁)

Trichotomy

A double induction on membership, once in each argument, with the excluded middle deciding the two inclusions at the leaves. If both hold, the ordinals are equal. If A is included in B but not conversely, take a member b of B outside A; the inner hypothesis compares A with b, and each of the three outcomes puts A inside B: below b and hence below B by transitivity, equal to b and hence a member, or a member of A, which contradicts the choice of b. The remaining case is the mirror image, decided by the outer hypothesis.

Tri : S  S  Type (ℓ-suc )
Tri A B =  A ∈ˢ B   ((A  B)   B ∈ˢ A )

ord-tri : (A : S)  IsOrd A  (B : S)  IsOrd B  Tri A B
ord-tri = WF.WFI.induction regularityV {P = P} stepA
  where
  P : S  Type (ℓ-suc )
  P A = IsOrd A  (B : S)  IsOrd B  Tri A B

  stepA : (A : S)  (∀ A'   A' ∈ˢ A   P A')  P A
  stepA A IHA ordA =
    WF.WFI.induction regularityV {P = λ B  IsOrd B  Tri A B} stepB
    where
    stepB : (B : S)  (∀ B'   B' ∈ˢ B   IsOrd B'  Tri A B')
           IsOrd B  Tri A B
    stepB B IHB ordB = decide (lem (⊆ᵇ-prop A B)) (lem (⊆ᵇ-prop B A))
      where
      fromB : Σ[ b  S ] ( b ∈ˢ B  × ( b ∈ˢ A   Empty.⊥))   A ∈ˢ B 
      fromB (b , (b∈B , ¬b∈A)) = at (IHB b b∈B (mem-ord {A = B} ordB b b∈B))
        where
        at : Tri A b   A ∈ˢ B 
        at (inl A∈b)       = ordB .fst A∈b b∈B
        at (inr (inl A≡b)) = subst  w   w ∈ˢ B ) (sym A≡b) b∈B
        at (inr (inr b∈A)) = Empty.rec (¬b∈A b∈A)

      fromA : Σ[ a  S ] ( a ∈ˢ A  × ( a ∈ˢ B   Empty.⊥))   B ∈ˢ A 
      fromA (a , (a∈A , ¬a∈B)) =
        at (IHA a a∈A (mem-ord {A = A} ordA a a∈A) B ordB)
        where
        at : Tri a B   B ∈ˢ A 
        at (inl a∈B)       = Empty.rec (¬a∈B a∈B)
        at (inr (inl a≡B)) = subst  w   w ∈ˢ A ) a≡B a∈A
        at (inr (inr B∈a)) = ordA .fst B∈a a∈A

      decide : (A ⊆ᵇ B)  ((A ⊆ᵇ B)  Empty.⊥)
              (B ⊆ᵇ A)  ((B ⊆ᵇ A)  Empty.⊥)  Tri A B
      decide (inl A⊆B) (inl B⊆A) = inr (inl (ext-⊆ᵇ A⊆B B⊆A))
      decide (inl A⊆B) (inr ¬B⊆A) =
        inl (PT.rec (snd (A ∈ˢ B)) fromB (¬⊆ᵇ→witness B A ¬B⊆A))
      decide (inr ¬A⊆B) _ =
        inr (inr (PT.rec (snd (B ∈ˢ A)) fromA (¬⊆ᵇ→witness A B ¬A⊆B)))

Recap

ord-tri compares any two ordinals, and the book pays for it with one instance of the excluded middle, taken as a module parameter and therefore visible in the type of every chapter downstream. This is the boundary the groundwork was built to make auditable: nothing is postulated, and a reader can tell whether a theorem is classical by reading its imports. The next chapter spends the comparison on the question it was needed for, which ordinals appear at which stage of the tower.