diff --git a/src/1Lab/Path/IdentitySystem.lagda.md b/src/1Lab/Path/IdentitySystem.lagda.md index 26cbf5ce0..208c17e7a 100644 --- a/src/1Lab/Path/IdentitySystem.lagda.md +++ b/src/1Lab/Path/IdentitySystem.lagda.md @@ -176,6 +176,18 @@ identity-system-gives-path {R = R} {r = r} ids = ∙ transport-refl _ ) ``` +In particular, swapping the arguments of the relation in an identity system +yields another identity system. + +```agda +flip-identity-system : + ∀ {ℓ ℓ'} {A : Type ℓ} {R : A → A → Type ℓ'} {r : ∀ a → R a a} + → is-identity-system R r + → is-identity-system (flip R) r +flip-identity-system ids = + equiv-path→identity-system $ identity-system-gives-path ids ∙e sym-equiv +``` + ## Based identity systems {defines="based-identity-system unary-identity-system"} It is sometimes useful to characterise the *based* identity type at diff --git a/src/Data/Wellfounded/Properties.lagda.md b/src/Data/Wellfounded/Properties.lagda.md index be45fc391..d3dd97fb8 100644 --- a/src/Data/Wellfounded/Properties.lagda.md +++ b/src/Data/Wellfounded/Properties.lagda.md @@ -34,6 +34,14 @@ Wf-is-prop : is-prop (Wf R) Wf-is-prop = Π-is-hlevel 1 Acc-is-prop ``` + + ## Instances The usual induction principle for the natural numbers is equivalent to diff --git a/src/HoTT.lagda.md b/src/HoTT.lagda.md index 2a4d8e9ac..50b6470d0 100644 --- a/src/HoTT.lagda.md +++ b/src/HoTT.lagda.md @@ -43,7 +43,9 @@ open import Cat.Bi.Base open import Cat.Prelude open import Cat.Gaunt +open import Data.Wellfounded.Properties open import Data.Set.Material.HIT +open import Data.Wellfounded.Base open import Data.Set.Surjection open import Data.Wellfounded.W open import Data.Fin.Finite using (Listing→choice) @@ -65,6 +67,7 @@ open import Homotopy.Pushout open import Homotopy.Wedge open import Homotopy.Base +open import Order.Ordinal.Base open import Order.Base import Algebra.Monoid.Category as Monoid @@ -1072,6 +1075,39 @@ _ = AC→LEM * Lemma 10.1.13: `Susp-prop-is-set`{.Agda}, `Susp-prop-path`{.Agda} * Theorem 10.1.14: `AC→LEM`{.Agda} +### 10.3: Ordinal Numbers + + + +* Definition 10.3.1: `Acc`{.Agda} +* Lemma 10.3.2: `Acc-is-prop`{.Agda} +* Definition 10.3.3: `Wf`{.Agda} +* Lemma 10.3.4: `Wf-is-prop`{.Agda} +* Example 10.3.5: `<-wf`{.Agda} +* Example 10.3.6: `W-well-founded`{.Agda} +* Several theorems about extensional well-founded sets are stated only for ordinals. + * Definition 10.3.11: `is-simulation`{.Agda} + * Lemma 10.3.12: `is-simulation.has-injective`{.Agda} + * Corollary 10.3.15: `Ordinal-poset`{.Agda} + * Lemma 10.3.16: `simulation-unique`{.Agda} +* Definition 10.3.17: `Ordinal`{.Agda} +* Theorem 10.3.20: `Ord`{.Agda} + ### 10.5: The cumulative hierarchy + +```agda +module Order.Ordinal.Base where +``` + +# Ordinals {defines="well-order ordinal"} + +An **ordinal** captures the concept of a [[well-founded]] order. +Such an order is necessarily a *strict* order (like `_<_`, not `_≤_`), +since a well-founded relation cannot be reflexive. + +The conditions for a well-order an be expressed fairly concisely. +A relation `_<_ : X → X → Type` is a well order +if all of the following hold: + +* It is propositional. + +* It is well-founded. + +* It is transitive. + +* Whenever `{z | z < x} ≡ {z | z < y}`, we have `x ≡ y`. + +Every ordinal is in fact a poset, +where `x ≤ y` iff `∀ {z} → z < x → z < y`. +We choose to use a somewhat redundant definition of ordinal, +where this poset is part of the *structure*, +since it often lines up with a preexisting order. + +```agda +record Ordinal (ℓ : Level) : Type (lsuc ℓ) where + no-eta-equality + field + poset : Poset ℓ ℓ + open Poset poset public + field + _<_ : Ob → Ob → Type ℓ + <-thin : ∀ {x y} → is-prop (x < y) + <-wf : Wf _<_ + <→≤ : ∀ {x y} → x < y → x ≤ y + <→≤→< : ∀ {x y z} → x < y → y ≤ z → x < z + [<→<]→≤ : ∀ {x y} → (∀ {z} → z < x → z < y) → (x ≤ y) + <-trans : ∀ {x y z} → x < y → y < z → x < z + <-trans x + +For example, the ordinal `ω` is given by the natural numbers, +under their standard ordering. + +```agda +ω : Ordinal lzero +ω = record where + poset = Nat-poset + _<_ = Nat._<_ + <-thin = Nat.≤-is-prop + <→≤ = Nat.<-weaken + <→≤→< = Nat.≤-trans + [<→<]→≤ {x} {y} h = + let + h' : {z : Nat} → z Nat.≤ x → z Nat.≤ y + h' = λ { {zero} _ → 0≤x; {suc z} → h {z} } + in h' Nat.≤-refl + <-wf = Data.Wellfounded.Properties.<-wf +``` + +As mentioned above, this representation is rather redundant. +We confirm that ordinals are determined +by their underlying type and strict order, +and can be constructed from the same. + +```agda +record _≃ₒ_ (α : Ordinal ℓ₁) (β : Ordinal ℓ₂) : Type (ℓ₁ ⊔ ℓ₂) where + field + equiv : ⌞ α ⌟ ≃ ⌞ β ⌟ + pres-< : ∀ {x y} → Ordinal._<_ α x y ≃ Ordinal._<_ β (equiv · x) (equiv · y) +``` + +```agda +≃ₒ→≡ : {α β : Ordinal ℓ} → α ≃ₒ β → α ≡ β +≃ₒ→≡ {ℓ} {α} {β} e = p where +``` +
+Long proof. +```agda + module α = Ordinal α + module β = Ordinal β + open _≃ₒ_ e + p₀ : ⌞ α ⌟ ≡ ⌞ β ⌟ + p₀ = ua equiv + + p₁ : PathP (λ i → p₀ i → p₀ i → Type ℓ) α._<_ β._<_ + p₁ = ua→ λ x → ua→ λ y → ua pres-< + + p₂ : PathP + (λ i → (x y : p₀ i) → + Σ (Type ℓ) λ le → (∀ {z : p₀ i} → p₁ i z x → p₁ i z y) ≃ le) + (λ x y → x α.≤ y , prop-ext (hlevel 1) (hlevel 1) + α.[<→<]→≤ (λ h₁ h₂ → α.<→≤→< h₂ h₁)) + (λ x y → x β.≤ y , prop-ext (hlevel 1) (hlevel 1) + β.[<→<]→≤ (λ h₁ h₂ → β.<→≤→< h₂ h₁)) + p₂ = is-prop→pathp (λ i → + is-contr→is-prop $ Π-is-hlevel 0 λ _ → Π-is-hlevel 0 λ _ → + is-contr-ΣR univalence-identity-system) _ _ + + p₃ : PathP (λ i → ∀ {x y} → is-prop (fst (p₂ i x y))) α.≤-thin β.≤-thin + p₃ = is-prop→pathp (λ _ → hlevel 1) _ _ + + p₄ : PathP (λ i → ∀ {x} → fst (p₂ i x x)) α.≤-refl β.≤-refl + p₄ = is-prop→pathp (λ i → Π-is-hlevel' 1 λ x → p₃ i {x} {x}) _ _ + + p₅ : PathP (λ i → ∀ {x y z} → fst (p₂ i x y) → fst (p₂ i y z) → fst (p₂ i x z)) + α.≤-trans β.≤-trans + p₅ = is-prop→pathp (λ i → + Π-is-hlevel' 1 λ x → Π-is-hlevel' 1 λ y → Π-is-hlevel' 1 λ z → + Π-is-hlevel 1 λ _ → Π-is-hlevel 1 λ _ → p₃ i {x} {z}) _ _ + + p₆ : PathP (λ i → ∀ {x y} → fst (p₂ i x y) → fst (p₂ i y x) → x ≡ y) + α.≤-antisym β.≤-antisym + p₆ = is-prop-i0→pathp ( + Π-is-hlevel' 1 λ x → Π-is-hlevel' 1 λ y → + Π-is-hlevel 1 λ _ → Π-is-hlevel 1 λ _ → α.Ob-is-set x y) _ _ + + p₇ : PathP (λ i → ∀ {x y} → is-prop (p₁ i x y)) α.<-thin β.<-thin + p₇ = is-prop→pathp (λ _ → hlevel 1) _ _ + + p₈ : PathP (λ i → ∀ {x y} → p₁ i x y → fst (p₂ i x y)) α.<→≤ β.<→≤ + p₈ = is-prop→pathp (λ i → + Π-is-hlevel' 1 λ x → Π-is-hlevel' 1 λ y → Π-is-hlevel 1 λ _ → p₃ i {x} {y}) _ _ + + p₉ : PathP (λ i → Wf (p₁ i)) α.<-wf β.<-wf + p₉ = is-prop→pathp (λ _ → Π-is-hlevel 1 Acc-is-prop) _ _ + + p : α ≡ β + p i .Ordinal.poset .Poset.Ob = p₀ i + p i .Ordinal.poset .Poset._≤_ x y = fst (p₂ i x y) + p i .Ordinal.poset .Poset.≤-thin {x} {y} = p₃ i {x} {y} + p i .Ordinal.poset .Poset.≤-refl {x} = p₄ i {x} + p i .Ordinal.poset .Poset.≤-trans {x} {y} {z} = p₅ i {x} {y} {z} + p i .Ordinal.poset .Poset.≤-antisym {x} {y} = p₆ i {x} {y} + p i .Ordinal._<_ = p₁ i + p i .Ordinal.<-thin {x} {y} = p₇ i {x} {y} + p i .Ordinal.<→≤ {x} {y} = p₈ i {x} {y} + p i .Ordinal.<→≤→< {z} {x} {y} h₁ h₂ = Equiv.from (snd (p₂ i x y)) h₂ {z} h₁ + p i .Ordinal.[<→<]→≤ {x} {y} = Equiv.to (snd (p₂ i x y)) + p i .Ordinal.<-wf = p₉ i +``` +
+```agda +record make-ordinal (ℓ : Level) : Type (lsuc ℓ) where + no-eta-equality + field + Ob : Type ℓ + _<_ : Ob → Ob → Type ℓ + <-thin : ∀ {x y} → is-prop (x < y) + <-wf : Wf _<_ + <-trans : ∀ {x y z} → x < y → y < z → x < z + <-extensional : ∀ {x y} → (∀ {z} → (z < x → z < y) × (z < y → z < x)) → x ≡ y + + to-ordinal : Ordinal ℓ + to-ordinal = record where + poset = record where + Ob = Ob + _≤_ x y = ∀ {z} → z < x → z < y + ≤-thin = Π-is-hlevel' 1 λ _ → Π-is-hlevel 1 λ _ → <-thin + ≤-refl = id + ≤-trans h₁ h₂ = h₂ ∘ h₁ + ≤-antisym h₁ h₂ = <-extensional (h₁ , h₂) + _<_ = _<_ + <-thin = <-thin + <→≤ x + +If a simulation is also an equivalence, it forces the ordinals to be equal. + +```agda +is-simulation→is-equiv→≃ₒ : {α : Ordinal ℓ₁} {β : Ordinal ℓ₂} {f : ⌞ α ⌟ → ⌞ β ⌟} + (sim : is-simulation α β f) (e : is-equiv f) → α ≃ₒ β +is-simulation→is-equiv→≃ₒ _ e ._≃ₒ_.equiv = _ , e +is-simulation→is-equiv→≃ₒ {_} {_} {α} {β} sim _ ._≃ₒ_.pres-< = prop-ext + (Ordinal.<-thin α) (Ordinal.<-thin β) + (is-simulation.pres-< sim) (is-simulation.reflect-< sim) +``` + +## Ordering + +Intriguingly, simulations are *unique*. + +```agda +simulation-unique : {α : Ordinal ℓ₁} {β : Ordinal ℓ₂} {f g : ⌞ α ⌟ → ⌞ β ⌟} → + is-simulation α β f → is-simulation α β g → f ≡ g +simulation-unique {_} {_} {α} {β} {f} {g} f-sim g-sim = + let + module α = Ordinal α + module β = Ordinal β + open is-simulation + in ext $ Wf-induction α._<_ α.<-wf (λ x → f x ≡ g x) λ x ih → + β.≤-antisym + (β.[<→<]→≤ λ z + + +We conclude with the ways in which subordinals interact with the order. + +```agda +module _ {α : Ordinal ℓ} {x : ⌞ α ⌟} {y : ⌞ Subordinal α x ⌟} where + open Ordinal α + Subsubordinal : Subordinal (Subordinal α x) y ≃ₒ Subordinal α (fst y) + Subsubordinal ._≃ₒ_.equiv = Iso→Equiv + $ (λ ((z , z