indexsource

open import 1Lab.Prelude
open import Data.Bool
open import Data.Sum
open import Data.Dec
open import Order.Base
open import Homotopy.Space.Suspension
open import Homotopy.Space.Suspension.Properties

open Poset

module StrongTotalOrder where

is-right :  {a b} {A : Type a} {B : Type b}  A  B  Bool
is-right (inl _) = false
is-right (inr _) = true

strong total orders

The point of this module is to answer the following question:

In the definition of a total order, why do we need to truncate the disjunction (xy)+(yx)\| (x ≤ y) + (y ≤ x) \|?

One immediate answer is that we want totality to be a property of an order, not a structure on it. However, we could be tempted to achieve this by placing the truncation outside of the quantification, defining totality of an order as xy.(xy)+(yx)\| \forall x y. (x ≤ y) + (y ≤ x) \|. To avoid ambiguity, let us refer to this (stronger) definition as a strong total order. What follows is an example which separates the two notions: a total order which is a strong total order if and only if excluded middle holds.

We assume given a proposition PP and consider its suspension ΣP\Sigma P: a set with two points north\mathsf{north} and south\mathsf{south} and a unique path between them if and only PP holds. This set has one element if PP and two elements if ¬P\neg P, so deciding its cardinality amounts to deciding PP. This is a recurrent protagonist in constructive counterexamples: it is also used e.g. to prove that the axiom of choice implies excluded middle.

module _ {} (P : Type ) (P-prop : is-prop P) where
  ΣP = Susp P

  ΣP-is-set : is-set ΣP
  ΣP-is-set = Susp-prop-is-set P-prop

We then define a total order on ΣP\Sigma P by declaring that the north pole is higher than the south pole (hence that it is strictly higher if and only if ¬P\neg P).

  _≤'_ : ΣP  ΣP  Prop 
  _≤'_ = Susp-elim _
    (Susp-elim _
      (el! (Lift _ )) -- N ≤ N
      (el P P-prop)    -- N ≤ S
       p  n-ua (P→⊤≃P p)))
     _  el! (Lift _ )) -- S ≤ _
     p  ext (Susp-elim-prop  _  hlevel 1) refl (n-ua (P→⊤≃P p e⁻¹))))
    where
      P→⊤≃P : P  Lift _   P
      P→⊤≃P p = is-contr→≃ (hlevel 0) (is-prop∙→is-contr P-prop p)

It is straightforward to show that this is a total partial order.

  ≤'-refl :  x   x ≤' x 
  ≤'-refl = Susp-elim-prop  _  hlevel 1) _ _

  ≤'-trans :  x y z   x ≤' y    y ≤' z    x ≤' z 
  ≤'-trans = Susp-elim-prop  _  hlevel 1)
    (Susp-elim-prop  _  hlevel 1)
       _ _ p  p)
      (Susp-elim-prop  _  hlevel 1)
        _
         p _  p)))
    _

  ≤'-antisym :  x y   x ≤' y    y ≤' x   x  y
  ≤'-antisym = Susp-elim-prop
     _  Π-is-hlevel 1 λ _  Π-is-hlevel² 1 λ _ _  ΣP-is-set _ _)
    (Susp-elim-prop  _  Π-is-hlevel² 1 λ _ _  ΣP-is-set _ _)
       _ _  refl)
       p _  merid p))
    (Susp-elim-prop  _  Π-is-hlevel² 1 λ _ _  ΣP-is-set _ _)
       _ p  sym (merid p))
       _ _  refl))

  ΣP' : Poset  
  ΣP' .Ob = ΣP
  ΣP' ._≤_ x y =  x ≤' y 
  ΣP' .≤-thin {x} {y} = (x ≤' y) .is-tr
  ΣP' .≤-refl {x} = ≤'-refl x
  ΣP' .≤-trans {x} {y} {z} = ≤'-trans x y z
  ΣP' .≤-antisym {x} {y} = ≤'-antisym x y

  ΣP'-total :  x y    x ≤' y    y ≤' x  
  ΣP'-total = Susp-elim-prop  _  hlevel 1)
    (Susp-elim-prop  _  hlevel 1)
      (inc (inl _))
      (inc (inr _)))
     _  inc (inl _))

However, assuming that ΣP\Sigma P is strongly totally ordered allows us to decide PP. Letting t(x,y)t(x, y) be the boolean-valued function that returns false if xyx ≤ y and true if yxy ≤ x, we reason by cases:

  not-strongly-total : (∀ x y   x ≤' y    y ≤' x )  Dec P
  not-strongly-total t with t south north in e₁ | t north south in e₂
  ... | inr p | _     = yes p
  ... | inl _ | inl p = yes p
  ... | inl _ | inr _ = no λ p  false≠true $
       sym (ap is-right (Id≃path.to e₁))
    ∙∙ ap₂  x y  is-right (t x y)) (sym (merid p)) (merid p)
    ∙∙ ap is-right (Id≃path.to e₂)