ToppedArithmetic
Martin Escardo, 29 June 2018 To get closure under sums constructively, we need to restrict to particular kinds of ordinals. Having a top element is a simple sufficient condition, which holds in the applications we have in mind (for compact ordinals). Classically, ordinals with a top element are precisely the successor ordinals. Constructively, ββ is an example of an ordinal with a top element, which "is not" a successor ordinal, as its top element is not isolated. TODO. Generalize this from π€β to an arbitrary universe. The (practical) problem is that the type of natural numbers is defined at π€β. We could (1) either using universe lifting, or (2) define the type in any universe (like we did for the the types π and π). But (1) is cumbersome and (2) requires much work in other modules.{-# OPTIONS --safe --without-K #-} open import UF.FunExt module Ordinals.ToppedArithmetic (fe : FunExt) where open import CoNaturals.Type open import MLTT.Spartan open import Notation.CanonicalMap open import Ordinals.Arithmetic fe open import Ordinals.Injectivity open import Ordinals.Notions open import Ordinals.ToppedType fe open import Ordinals.Type open import Ordinals.Underlying open import Ordinals.WellOrderArithmetic open import TypeTopology.SquashedSum fe open import UF.ClassicalLogic open import UF.Subsingletons open import UF.Subsingletons-FunExt open import UF.SubtypeClassifier private feβ = fe π€β π€β Ordα΅ = Ordinalα΅ π€β succβ : Ordinal π€ β Ordinalα΅ π€ succβ Ξ± = Ξ± +β πβ , plus.top-preservation (underlying-order Ξ±) (underlying-order πβ) (prop.topped π π-is-prop β) succβ-is-trichotomous : (Ξ± : Ordinal π€) β is-trichotomous Ξ± β is-trichotomous [ succβ Ξ± ] succβ-is-trichotomous Ξ± t = +β-is-trichotomous Ξ± πβ t πβ-is-trichotomous πα΅ πα΅ : Ordinalα΅ π€ πα΅ = πβ , prop.topped π π-is-prop β πα΅ = succβ πβ ββα΅ : Ordα΅ ββα΅ = (βββ , β , β-top)Sum of an ordinal-indexed family of ordinals:β : (Ο : Ordinalα΅ π€) β (β¨ Ο β© β Ordinalα΅ π€) β Ordinalα΅ π€ β {π€} ((X , _<_ , o) , t) Ο = ((Ξ£ x κ X , β¨ Ο x β©) , Sum.order , Sum.well-order o (Ξ» x β tis-well-ordered (Ο x))) , Sum.top-preservation t where _βΊ_ : {x : X} β β¨ Ο x β© β β¨ Ο x β© β π€ Μ y βΊ z = y βΊβ¨ Ο _ β© z module Sum = sum-top fe _<_ _βΊ_ (Ξ» x β top (Ο x)) (Ξ» x β top-is-top (Ο x)) β-is-trichotomous : (Ο : Ordinalα΅ π€) (Ο : β¨ Ο β© β Ordinalα΅ π€) β is-trichotomous [ Ο ] β ((x : β¨ Ο β©) β is-trichotomous [ Ο x ]) β is-trichotomous [ β Ο Ο ] β-is-trichotomous Ο Ο = sum.trichotomy-preservation _ _Added by Martin Escardo 2nd September 2026. The top of the index is needed only for the sum to have a top, and the sum over an index without one is still an ordinal.ββ : (Ξ± : Ordinal π€) β (β¨ Ξ± β© β Ordinalα΅ π€) β Ordinal π€ ββ {π€} (X , _<_ , o) Ο = (Ξ£ x κ X , β¨ Ο x β©) , Sum.order , Sum.well-order o (Ξ» x β tis-well-ordered (Ο x)) where _βΊ_ : {x : X} β β¨ Ο x β© β β¨ Ο x β© β π€ Μ y βΊ z = y βΊβ¨ Ο _ β© z module Sum = sum-top fe _<_ _βΊ_ (Ξ» x β top (Ο x)) (Ξ» x β top-is-top (Ο x)) β-is-ββ : (Ο : Ordinalα΅ π€) (Ο : β¨ Ο β© β Ordinalα΅ π€) β [ β Ο Ο ] οΌ ββ [ Ο ] Ο β-is-ββ Ο Ο = reflEnd of addition. Some restriction is needed to get extensionality of the lexicographic order on sums. Two such restrictions are trichotomy and having top. Without a restriction, the lexicographic order on the sum of an ordinal-indexed family of ordinals need not be extensional, and asking that it always be gives excluded middle, by Shulman's example in Ordinals.ShulmanTaboo.Extensionality-of-Ordinal-Indexed-Sums : (π€ : Universe) β π€ βΊ Μ Extensionality-of-Ordinal-Indexed-Sums π€ = (Ο : Ordinal π€) (Ο : β¨ Ο β© β Ordinal π€) β is-extensional (sum.order (underlying-order Ο) (Ξ» {x} β underlying-order (Ο x))) module _ (pe : propext π€β) where open import Ordinals.OrdinalOfTruthValues fe π€β pe open import Ordinals.ShulmanTaboo fe pe extensionality-of-ordinal-indexed-sums-gives-EM : Extensionality-of-Ordinal-Indexed-Sums π€β β EM π€β extensionality-of-ordinal-indexed-sums-gives-EM h = shulmans-taboo e where Ο : β¨ Ξ©β β© β Ordinal π€β Ο p = prop-ordinal (Β¬ (p οΌ β₯)) (negations-are-props (fe π€β π€β)) _β_ : X β X β π€β Μ _β_ = sum.order (underlying-order Ξ©β) (Ξ» {p} β underlying-order (Ο p)) lex-gives-βΊ : (z w : X) β z β w β z βΊ w lex-gives-βΊ z w (inl l) = l lex-gives-βΊ z w (inr (r , l)) = π-elim l e : is-extensional _βΊ_ e x y f g = h Ξ©β Ο x y (Ξ» z l β inl (f z (lex-gives-βΊ z x l))) (Ξ» z l β inl (g z (lex-gives-βΊ z y l)))Addition and multiplication can be reduced to β, given the ordinal πα΅ defined above:_+α΅_ : Ordinalα΅ π€ β Ordinalα΅ π€ β Ordinalα΅ π€ Ο +α΅ Ο = β πα΅ (cases (Ξ» _ β Ο) (Ξ» _ β Ο )) +α΅-is-trichotomous : (Ο Ο : Ordinalα΅ π€) β is-trichotomous [ Ο ] β is-trichotomous [ Ο ] β is-trichotomous [ Ο +α΅ Ο ] +α΅-is-trichotomous Ο Ο t u = β-is-trichotomous πα΅ (cases (Ξ» _ β Ο) (Ξ» _ β Ο )) πβ-is-trichotomous (dep-cases (Ξ» _ β t) (Ξ» _ β u)) _Γα΅_ : Ordinalα΅ π€ β Ordinalα΅ π€ β Ordinalα΅ π€ Ο Γα΅ Ο = β Ο (Ξ» (_ : β¨ Ο β©) β Ο ) Γα΅-is-trichotomous : (Ο Ο : Ordinalα΅ π€) β is-trichotomous [ Ο ] β is-trichotomous [ Ο ] β is-trichotomous [ Ο Γα΅ Ο ] Γα΅-is-trichotomous Ο Ο t u = β-is-trichotomous Ο (Ξ» _ β Ο ) t (Ξ» _ β u)Extension of a family X β Ordα΅ along an embedding j : X β A to get a family A β Ordα΅. (This can also be done for Ord-valued families.) This uses the module InjectiveTypes.Blackboard to calculate Y / j. Sum of a countable family with an added non-isolated top element. We first extend the family to ββ and then take the ordinal-indexed sum of ordinals defined above.open topped-ordinals-injectivity fe βΒΉ : (β β Ordα΅) β Ordα΅ βΒΉ Ο = β ββα΅ (Ο β embedding-β-to-ββ feβ)And now with an isolated top element:ββ : (β β Ordα΅) β Ordα΅ ββ Ο = β (succβ Ο) (Ο β (over , over-embedding))The sum with an isolated top element preserves trichotomy, because the fibers of the map over are decidable. There is no such statement for the sum with a non-isolated top element, because the fibers of the map β β ββ used there are decidable only under LPO.ββ-is-trichotomous : (Ο : β β Ordα΅) β ((n : β) β is-trichotomous [ Ο n ]) β is-trichotomous [ ββ Ο ] ββ-is-trichotomous Ο t = β-is-trichotomous (succβ Ο) (Ο β (over , over-embedding)) (succβ-is-trichotomous Ο Ο-is-trichotomous) (β-is-trichotomous Ο (over , over-embedding) over-fibers-are-decidable t)Added 4th May 2022.module Omega {π€} (pe : propext π€) where open import Ordinals.OrdinalOfTruthValues fe π€ pe open import Ordinals.Notions open import UF.SubtypeClassifier Ξ©α΅ : Ordinalα΅ (π€ βΊ) Ξ©α΅ = Ξ©β , β€ , h where h : is-top (underlying-order Ξ©β) β€ h y (p , _) = β₯-is-not-β€ (p β»ΒΉ)