Martin Escardo 4th May 2022.

\begin{code}

{-# OPTIONS --safe --without-K --lossy-unification #-}

open import UF.Univalence

module Ordinals.ToppedAdditionProperties
       (ua : Univalence)
       where

open import UF.Equiv
open import UF.FunExt
open import UF.Subsingletons
open import UF.UA-FunExt

private
 fe : FunExt
 fe = Univalence-gives-FunExt ua

 fe' : Fun-Ext
 fe' {𝓀} {π“₯} = fe 𝓀 π“₯

 pe : PropExt
 pe = Univalence-gives-PropExt ua

open import MLTT.Spartan
open import Notation.CanonicalMap
open import Ordinals.Arithmetic fe
open import Ordinals.Equivalence
open import Ordinals.Maps
open import Ordinals.ToppedArithmetic fe
open import Ordinals.ToppedType fe
open import Ordinals.Type
open import Ordinals.Underlying

alternative-plusβ‚’ : (Ο„β‚€ τ₁ : Ordinalα΅€ 𝓀)
                  β†’ [ Ο„β‚€ +α΅’ τ₁ ] ≃ₒ ([ Ο„β‚€ ] +β‚’ [ τ₁ ])
alternative-plusβ‚’ Ο„β‚€ τ₁ = e
 where
  Ο… = cases (Ξ» ⋆ β†’ Ο„β‚€) (Ξ» ⋆ β†’ τ₁)

  f : ⟨ βˆ‘ πŸšα΅’ Ο… ⟩ β†’ ⟨ [ Ο„β‚€ ] +β‚’ [ τ₁ ] ⟩
  f (inl ⋆ , x) = inl x
  f (inr ⋆ , y) = inr y

  g : ⟨ [ Ο„β‚€ ] +β‚’ [ τ₁ ] ⟩ β†’ ⟨ βˆ‘ πŸšα΅’ Ο… ⟩
  g (inl x) = (inl ⋆ , x)
  g (inr y) = (inr ⋆ , y)

  η : g ∘ f ∼ id
  Ξ· (inl ⋆ , x) = refl
  Ξ· (inr ⋆ , y) = refl

  Ρ : f ∘ g ∼ id
  Ξ΅ (inl x) = refl
  Ξ΅ (inr y) = refl

  f-is-equiv : is-equiv f
  f-is-equiv = qinvs-are-equivs f (g , Ξ· , Ξ΅)
  f-is-op : is-order-preserving [ βˆ‘ πŸšα΅’ Ο… ] ([ Ο„β‚€ ] +β‚’ [ τ₁ ]) f

  f-is-op (inl ⋆ , _) (inl ⋆ , _) (inr (refl , l)) = l
  f-is-op (inl ⋆ , _) (inr ⋆ , _) (inl ⋆)          = ⋆
  f-is-op (inr ⋆ , _) (inl ⋆ , _) (inl l)          = l
  f-is-op (inr ⋆ , _) (inr ⋆ , _) (inr (refl , l)) = l

  g-is-op : is-order-preserving ([ Ο„β‚€ ] +β‚’ [ τ₁ ]) [ βˆ‘ πŸšα΅’ Ο… ] g
  g-is-op (inl _) (inl _) l = inr (refl , l)
  g-is-op (inl _) (inr _) ⋆ = inl ⋆
  g-is-op (inr _) (inl _) ()
  g-is-op (inr _) (inr _) l = inr (refl , l)

  e : [ βˆ‘ πŸšα΅’ Ο… ] ≃ₒ ([ Ο„β‚€ ] +β‚’ [ τ₁ ])
  e = f , f-is-op , f-is-equiv , g-is-op

alternative-plus : (Ο„β‚€ τ₁ : Ordinalα΅€ 𝓀)
                 β†’ [ Ο„β‚€ +α΅’ τ₁ ] = ([ Ο„β‚€ ] +β‚’ [ τ₁ ])
alternative-plus Ο„β‚€ τ₁ = eqtoidβ‚’ (ua _) fe' _ _ (alternative-plusβ‚’ Ο„β‚€ τ₁)

\end{code}