Todd Waugh Ambridge, January 2024
# Orders
\begin{code}
{-# OPTIONS --without-K --safe #-}
open import MLTT.Spartan
open import UF.FunExt
open import UF.DiscreteAndSeparated
open import UF.Subsingletons
open import UF.PropTrunc
open import Quotient.Type
using (is-prop-valued;is-equiv-relation;EqRel)
open import Notation.Order
open import Naturals.Order
module TWA.Thesis.Chapter4.ApproxOrder (fe : FunExt) where
open import TWA.Thesis.Chapter3.ClosenessSpaces fe
\end{code}
## Traditional orders
\begin{code}
is-preorder : {X : π€ Μ } β (X β X β π¦ Μ ) β π€ β π¦ Μ
is-preorder _β€_ = reflexive _β€_
Γ transitive _β€_
Γ is-prop-valued _β€_
is-partial-order : {X : π€ Μ } β (X β X β π¦ Μ ) β π€ β π¦ Μ
is-partial-order {_} {_} {X} _β€_
= is-preorder _β€_ Γ antisymmetric _β€_
linear : {X : π€ Μ } β (X β X β π¦ Μ ) β π€ β π¦ Μ
linear {_} {_} {X} _β€_ = (x y : X) β (x β€ y) + (y β€ x)
is-linear-preorder : {X : π€ Μ } β (X β X β π¦ Μ ) β π€ β π¦ Μ
is-linear-preorder {_} {_} {X} _β€_
= is-preorder _β€_ Γ linear _β€_
is-linear-order : {X : π€ Μ } β (X β X β π¦ Μ ) β π€ β π¦ Μ
is-linear-order {_} {_} {X} _β€_
= is-partial-order _β€_ Γ linear _β€_
discrete-reflexive-antisym-linear-order-is-decidable
: {X : π€ Μ }
β is-discrete X
β (_β€_ : X β X β π¦ Μ )
β reflexive _β€_
β antisymmetric _β€_
β linear _β€_
β (x y : X)
β is-decidable (x β€ y)
discrete-reflexive-antisym-linear-order-is-decidable
ds _β€_ r a l x y
= Cases (ds x y) (Ξ» x=y β inl (transport (x β€_) x=y (r x)))
(Ξ» xβ y β Cases (l x y) inl
(inr β (Ξ» yβ€x xβ€y β xβ y (a x y xβ€y yβ€x))))
\end{code}
## Approximate orders
\begin{code}
is-approx-order : (X : ClosenessSpace π€)
β (_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ )
β π€ β π¦' Μ
is-approx-order X _β€βΏ_
= ((Ο΅ : β) β is-linear-preorder (Ξ» x y β (x β€βΏ y) Ο΅))
Γ ((Ο΅ : β) (x y : β¨ X β©) β is-decidable ((x β€βΏ y) Ο΅))
Γ ((Ο΅ : β) (x y : β¨ X β©) β C X Ο΅ x y β (x β€βΏ y) Ο΅)
β€-reflβ¨_β©
: {X : π€ Μ } {_β€_ : X β X β π¦ Μ }
β is-preorder _β€_
β reflexive _β€_
β€-reflβ¨ r , t , p β© = r
β€-transβ¨_β©
: {X : π€ Μ } {_β€_ : X β X β π¦ Μ }
β is-preorder _β€_
β transitive _β€_
β€-transβ¨ r , t , p β© = t
β€-propβ¨_β©
: {X : π€ Μ } {_β€_ : X β X β π¦ Μ }
β is-preorder _β€_
β is-prop-valued _β€_
β€-propβ¨ r , t , p β© = p
β€-preβ¨_β©
: {X : π€ Μ } {_β€_ : X β X β π¦ Μ }
β is-linear-preorder _β€_
β is-preorder _β€_
β€-preβ¨ pre , l β© = pre
β€-linearβ¨_β©
: {X : π€ Μ } {_β€_ : X β X β π¦ Μ }
β is-linear-preorder _β€_
β (x y : X) β (x β€ y) + (y β€ x)
β€-linearβ¨ pre , l β© = l
β€βΏ-all-linear
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β) β is-linear-preorder (Ξ» x y β (x β€βΏ y) Ο΅)
β€βΏ-all-linear X (l , d , c) = l
β€βΏ-refl
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β)
β (x : β¨ X β©) β (x β€βΏ x) Ο΅
β€βΏ-refl X (l , d , c) Ο΅ = (prβ β prβ) (l Ο΅)
β€βΏ-trans
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦ Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (x y z : β¨ X β©)
β (x β€βΏ y) Ο΅ β (y β€βΏ z) Ο΅ β (x β€βΏ z) Ο΅
β€βΏ-trans X (l , d , c) Ο΅ = (prβ β prβ β prβ) (l Ο΅)
β€βΏ-prop
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (x y : β¨ X β©)
β is-prop ((x β€βΏ y) Ο΅)
β€βΏ-prop X (l , d , c) Ο΅ = (prβ β prβ β prβ) (l Ο΅)
β€βΏ-linear
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (x y : β¨ X β©)
β (x β€βΏ y) Ο΅ + (y β€βΏ x) Ο΅
β€βΏ-linear X (l , d , c) Ο΅ = prβ (l Ο΅)
β€βΏ-decidable
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (x y : β¨ X β©)
β is-decidable ((x β€βΏ y) Ο΅)
β€βΏ-decidable X (l , d , c) = d
β€βΏ-close
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (x y : β¨ X β©)
β C X Ο΅ x y β (x β€βΏ y) Ο΅
β€βΏ-close X (l , d , c) = c
module ApproxOrder-Relates (pt : propositional-truncations-exist) where
open PropositionalTruncation pt
_relates-toβ_ : {X : π€ Μ }
β (_β€βΏ_ : X β X β β β π¦' Μ )
β (_β€_ : X β X β π¦ Μ )
β π€ β π¦ β π¦' Μ
_β€βΏx_ relates-toβ _β€x_
= β x y β ((n : β) β (x β€βΏx y) n) β x β€x y
_relates-toβ_ : {X : π€ Μ }
β (_β€βΏ_ : X β X β β β π¦' Μ )
β (_β€_ : X β X β π¦ Μ )
β π€ β π¦ β π¦' Μ
_β€βΏx_ relates-toβ _β€x_
= β x y β x β€x y β β n κ β , ((Ο΅ : β) β n β€ Ο΅ β (x β€βΏx y) Ο΅)
approx-order-relates : (X : ClosenessSpace π€)
β (_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ )
β is-approx-order X _β€βΏ_
β (_β€_ : β¨ X β© β β¨ X β© β π¦ Μ )
β is-preorder _β€_
β π€ β π¦ β π¦' Μ
approx-order-relates X _β€βΏ_ _ _β€_ _
= _β€βΏ_ relates-toβ _β€_
Γ _β€βΏ_ relates-toβ _β€_
\end{code}
## Predicates from approximate orders
\begin{code}
approx-order-ucontinuous-l
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β (a : is-approx-order X _β€βΏ_)
β (Ξ΅ : β) (y : β¨ X β©)
β p-ucontinuous X (Ξ» x β (x β€βΏ y) Ξ΅ , β€βΏ-prop X a Ξ΅ x y)
approx-order-ucontinuous-l X a Ξ΅ y
= Ξ΅ , (Ξ» xβ xβ Cxβxβ xββ€βΏy
β β€βΏ-trans X a Ξ΅ xβ xβ y
(β€βΏ-close X a Ξ΅ xβ xβ (C-sym X Ξ΅ xβ xβ Cxβxβ))
xββ€βΏy)
approx-order-ucontinuous-r
: (X : ClosenessSpace π€)
β {_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦' Μ }
β (a : is-approx-order X _β€βΏ_)
β (Ξ΅ : β) (y : β¨ X β©)
β p-ucontinuous X (Ξ» x β (y β€βΏ x) Ξ΅ , β€βΏ-prop X a Ξ΅ y x)
approx-order-ucontinuous-r X a Ξ΅ y
= Ξ΅ , (Ξ» xβ xβ Cxβxβ xββ€βΏy
β β€βΏ-trans X a Ξ΅ y xβ xβ
xββ€βΏy
(β€βΏ-close X a Ξ΅ xβ xβ Cxβxβ))
approx-order-uc-predicate-l : (X : ClosenessSpace π€)
β (_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦ Μ )
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (y : β¨ X β©)
β decidable-uc-predicate π¦ X
approx-order-uc-predicate-l X _β€βΏ_ a Ο΅ y
= ((Ξ» x β (x β€βΏ y) Ο΅ , β€βΏ-prop X a Ο΅ x y)
, Ξ» x β β€βΏ-decidable X a Ο΅ x y)
, approx-order-ucontinuous-l X a Ο΅ y
approx-order-uc-predicate-r : (X : ClosenessSpace π€)
β (_β€βΏ_ : β¨ X β© β β¨ X β© β β β π¦ Μ )
β is-approx-order X _β€βΏ_
β (Ο΅ : β) (y : β¨ X β©)
β decidable-uc-predicate π¦ X
approx-order-uc-predicate-r X _β€βΏ_ a Ο΅ y
= ((Ξ» x β (y β€βΏ x) Ο΅ , β€βΏ-prop X a Ο΅ y x)
, Ξ» x β β€βΏ-decidable X a Ο΅ y x)
, approx-order-ucontinuous-r X a Ο΅ y
approx-order-f-uc-predicate-l : (X : ClosenessSpace π€)
β (Y : ClosenessSpace π₯)
β (f : β¨ X β© β β¨ Y β©)
β f-ucontinuous X Y f
β (_β€βΏ_ : β¨ Y β© β β¨ Y β© β β β π¦ Μ )
β is-approx-order Y _β€βΏ_
β (Ο΅ : β) (y : β¨ Y β©)
β decidable-uc-predicate π¦ X
approx-order-f-uc-predicate-l X Y f Ο _β€βΏ_ a Ο΅ y
= ((Ξ» x β (f x β€βΏ y) Ο΅ , β€βΏ-prop Y a Ο΅ (f x) y)
, (Ξ» x β β€βΏ-decidable Y a Ο΅ (f x) y))
, p-ucontinuous-comp X Y f Ο
(Ξ» x β (x β€βΏ y) Ο΅ , β€βΏ-prop Y a Ο΅ x y)
(approx-order-ucontinuous-l Y a Ο΅ y)
approx-order-f-uc-predicate-r : (X : ClosenessSpace π€)
β (Y : ClosenessSpace π₯)
β (f : β¨ X β© β β¨ Y β©)
β f-ucontinuous X Y f
β (_β€βΏ_ : β¨ Y β© β β¨ Y β© β β β π¦ Μ )
β is-approx-order Y _β€βΏ_
β (Ο΅ : β) (y : β¨ Y β©)
β decidable-uc-predicate π¦ X
approx-order-f-uc-predicate-r X Y f Ο _β€βΏ_ a Ο΅ y
= ((Ξ» x β (y β€βΏ f x) Ο΅ , β€βΏ-prop Y a Ο΅ y (f x))
, (Ξ» x β β€βΏ-decidable Y a Ο΅ y (f x)))
, p-ucontinuous-comp X Y f Ο
(Ξ» x β (y β€βΏ x) Ο΅ , β€βΏ-prop Y a Ο΅ y x)
(approx-order-ucontinuous-r Y a Ο΅ y)
\end{code}