Martin Escardo, August 2026
The Brouwer ordinal codes are embedded into the inductive-recursive
universe E of ordinal codes of the module
Ordinals.InductiveRecursiveCodesInterpretations.
The embedding commutes with both the discrete and the compact
interpretations, in each case up to order equivalence rather than on
the nose.
\begin{code}
{-# OPTIONS --safe --without-K #-}
open import MLTT.Spartan
open import UF.FunExt
module Ordinals.BrouwerCodesIntoInductiveRecursiveCodes
(fe : FunExt)
where
open import CoNaturals.Type
open import MLTT.Plus-Properties
open import Notation.CanonicalMap hiding (ΞΉ)
open import Ordinals.Arithmetic fe
open import Ordinals.BrouwerCodes
open import Ordinals.BrouwerCodesDiscreteAndCompactInterpretations fe
using (Ξ ; Ξ)
open import Ordinals.Closure fe
open import Ordinals.Equivalence
open import Ordinals.InductiveRecursiveCodesInterpretations fe
using (E ; βπβ ; βΟ+πβ ; _β+β_ ; _βΓβ_ ; βΞ£β ; E-is-set ; π)
renaming (Ξ to Ξα΄± ; Ξ to Ξα΄±)
open import Ordinals.Injectivity
open import Ordinals.ToppedArithmetic fe
open import Ordinals.ToppedType fe
open import Ordinals.Type
open import Ordinals.Underlying
open import TypeTopology.SquashedSum fe
open import UF.Base
open import UF.Embeddings
open import UF.Equiv
open topped-ordinals-injectivity fe
private
feβ : funext π€β π€β
feβ = fe π€β π€β
\end{code}
The translation of the limit constructor works because the discrete
interpretation of the code for Ο + 1 has underlying type β + π, which
is exactly the index that ββ sums over, so that the family can be
given by cases, with the added point sent to the code for π.
\begin{code}
B-to-E : B β E
B-to-E Z = βπβ
B-to-E (S b) = B-to-E b β+β βπβ
B-to-E (L b) = βΞ£β βΟ+πβ (cases (Ξ» n β B-to-E (b n)) (Ξ» _ β βπβ))
B-to-E-lc : left-cancellable B-to-E
B-to-E-lc {Z} {Z} p = refl
B-to-E-lc {S b} {S b'} p = ap S (B-to-E-lc (ap plus-left p))
where
plus-left : E β E
plus-left βπβ = βπβ
plus-left βΟ+πβ = βπβ
plus-left (Ξ½ β+β ΞΌ) = Ξ½
plus-left (Ξ½ βΓβ ΞΌ) = βπβ
plus-left (βΞ£β Ξ½ A) = βπβ
B-to-E-lc {L b} {L b'} p = ap L (dfunext feβ I)
where
sigma-family : E β (β + π β E)
sigma-family βπβ = Ξ» _ β βπβ
sigma-family βΟ+πβ = Ξ» _ β βπβ
sigma-family (Ξ½ β+β ΞΌ) = Ξ» _ β βπβ
sigma-family (Ξ½ βΓβ ΞΌ) = Ξ» _ β βπβ
sigma-family (βΞ£β βπβ A) = Ξ» _ β βπβ
sigma-family (βΞ£β βΟ+πβ A) = A
sigma-family (βΞ£β (Ξ½ β+β ΞΌ) A) = Ξ» _ β βπβ
sigma-family (βΞ£β (Ξ½ βΓβ ΞΌ) A) = Ξ» _ β βπβ
sigma-family (βΞ£β (βΞ£β Ξ½ A) A') = Ξ» _ β βπβ
I : (n : β) β b n οΌ b' n
I n = B-to-E-lc (happly (ap sigma-family p) (inl n))
\end{code}
Since the inductive-recursive universe is a set, this makes the
inclusion an embedding.
\begin{code}
B-to-E-is-embedding : is-embedding B-to-E
B-to-E-is-embedding = lc-maps-into-sets-are-embeddings
B-to-E
B-to-E-lc
E-is-set
\end{code}
The inclusion commutes with the discrete interpretations, up to order
equivalence.
\begin{code}
Ξ-agreement : (b : B) β [ Ξ b ] ββ [ Ξα΄± (B-to-E b) ]
Ξ-agreement Z = ββ-refl [ πα΅ ]
Ξ-agreement (S b) = β-ββ
πα΅
(cases (Ξ» _ β Ξ b) (Ξ» _ β πα΅))
(cases (Ξ» _ β Ξα΄± (B-to-E b)) (Ξ» _ β πα΅))
(dep-cases
(Ξ» _ β Ξ-agreement b)
(Ξ» _ β ββ-refl [ πα΅ ]))
Ξ-agreement (L b) = β-ββ
(succβ Ο)
((Ξ β b) β (over , over-embedding))
(Ξα΄± β cases (Ξ» n β B-to-E (b n)) (Ξ» _ β βπβ))
I
where
I : (z : β + π)
β [ ((Ξ β b) β (over , over-embedding)) z ]
ββ [ Ξα΄± (cases (Ξ» n β B-to-E (b n)) (Ξ» _ β βπβ) z) ]
I (inl n) = ββ-trans
[ ((Ξ β b) β (over , over-embedding)) (inl n) ]
[ Ξ (b n) ]
[ Ξα΄± (B-to-E (b n)) ]
(β-propertyβ (Ξ β b) (over , over-embedding) n)
(Ξ-agreement (b n))
I (inr β) = β-out-of-range
(Ξ β b)
(over , over-embedding)
(inr β)
(Ξ» n β +disjoint)
\end{code}
The inclusion also commutes with the compact interpretations.
\begin{code}
Ξ-agreement : (b : B) β [ Ξ b ] ββ [ Ξα΄± (B-to-E b) ]
Ξ-agreement Z = ββ-refl [ πα΅ ]
Ξ-agreement (S b) = β-ββ
πα΅
(cases (Ξ» _ β Ξ b) (Ξ» _ β πα΅))
(cases (Ξ» _ β Ξα΄± (B-to-E b)) (Ξ» _ β πα΅))
(dep-cases
(Ξ» _ β Ξ-agreement b)
(Ξ» _ β ββ-refl [ πα΅ ]))
Ξ-agreement (L b) = β-ββ ββα΅ ((Ξ β b) β embedding-β-to-ββ feβ) (π βΟ+πβ A) I
where
A : β + π β E
A = cases (Ξ» n β B-to-E (b n)) (Ξ» _ β βπβ)
ΞΊ ΞΊα΄± : β β Ordinal π€β
ΞΊ n = [ Ξ (b n) ]
ΞΊα΄± n = [ Ξα΄± (B-to-E (b n)) ]
h : (n : β) β β¨ ΞΊ n β© β β¨ ΞΊα΄± n β©
h n = ββ-to-fun (ΞΊ n) (ΞΊα΄± n) (Ξ-agreement (b n))
hβ»ΒΉ : (n : β) β β¨ ΞΊα΄± n β© β β¨ ΞΊ n β©
hβ»ΒΉ n = ββ-to-funβ»ΒΉ (ΞΊ n) (ΞΊα΄± n) (Ξ-agreement (b n))
he : (n : β) β is-order-equiv (ΞΊ n) (ΞΊα΄± n) (h n)
he n = ββ-to-fun-is-order-equiv (ΞΊ n) (ΞΊα΄± n) (Ξ-agreement (b n))
hi : (n : β) β is-equiv (h n)
hi n = order-equivs-are-equivs (ΞΊ n) (ΞΊα΄± n) (he n)
I : (u : ββ)
β [ ((Ξ β b) β embedding-β-to-ββ feβ) u ] ββ [ π βΟ+πβ A u ]
I u = f ,
order-preserving-reflecting-equivs-are-order-equivs
[ ((Ξ β b) β embedding-β-to-ββ feβ) u ]
[ π βΟ+πβ A u ]
f
f-is-equiv
f-is-order-preserving
f-is-order-reflecting
where
f : β¨ ((Ξ β b) β embedding-β-to-ββ feβ) u β© β β¨ π βΟ+πβ A u β©
f Ο (inl n , p) = h n (Ο (n , p))
f Ο (inr β , p) = β
g : β¨ π βΟ+πβ A u β© β β¨ ((Ξ β b) β embedding-β-to-ββ feβ) u β©
g Ο (n , p) = hβ»ΒΉ n (Ο (inl n , p))
gf : g β f βΌ id
gf Ο = dfunext feβ
(Ξ» (n , p) β inverses-are-retractions (h n) (hi n) (Ο (n , p)))
fg : f β g βΌ id
fg Ο = dfunext feβ Ξ³
where
Ξ³ : (w : fiber ΞΉπ u) β f (g Ο) w οΌ Ο w
Ξ³ (inl n , p) = inverses-are-sections (h n) (hi n) (Ο (inl n , p))
Ξ³ (inr β , p) = refl
f-is-equiv : is-equiv f
f-is-equiv = qinvs-are-equivs f (g , gf , fg)
f-is-order-preserving : is-order-preserving
(((Ξ β b) β embedding-β-to-ββ feβ) u)
(π βΟ+πβ A u)
f
f-is-order-preserving Ο Ο' ((n , p) , l) =
(inl n , p) ,
order-equivs-are-order-preserving (ΞΊ n) (ΞΊα΄± n) (he n)
(Ο (n , p)) (Ο' (n , p)) l
f-is-order-reflecting : is-order-reflecting
(((Ξ β b) β embedding-β-to-ββ feβ) u)
(π βΟ+πβ A u)
f
f-is-order-reflecting Ο Ο' ((inl n , p) , l) =
(n , p) ,
order-equivs-are-order-reflecting (ΞΊ n) (ΞΊα΄± n) (h n) (he n)
(Ο (n , p)) (Ο' (n , p)) l
f-is-order-reflecting Ο Ο' ((inr β , p) , l) = π-elim l
\end{code}