DedekindReals.Order
Andrew Sneap, March 2021 Updated March 2022 In this file I define order of Dedekind Reals, and prove some key properties.{-# OPTIONS --safe --without-K #-} open import MLTT.Spartan renaming (_+_ to _โ_) open import Notation.CanonicalMap open import Notation.Order open import Rationals.Order open import UF.FunExt open import UF.PropTrunc open import UF.Powerset open import UF.Subsingletons open import UF.Subsingletons-FunExt open import Rationals.Type module DedekindReals.Order (fe : Fun-Ext) (pe : Prop-Ext) (pt : propositional-truncations-exist) where open import DedekindReals.Type fe pe pt open PropositionalTruncation pt _<โ_ : โ โ โ โ ๐คโ ฬ x <โ y = โ q ๊ โ , (x < q) ร (q < y) instance Strict-Order-โ-โ : Strict-Order โ โ _<_ {{Strict-Order-โ-โ}} = _<โ_ Strict-Order-Chain-โ-โ-โ : Strict-Order-Chain โ โ โ _<_ _<_ _<_<_ {{Strict-Order-Chain-โ-โ-โ}} p q r = (p < q) ร (q < r) <-is-prop : (x y : โ) โ is-prop (x < y) <-is-prop x y = โ-is-prop โ<-trans : (x y z : โ) โ x < y โ y < z โ x < z โ<-trans x y z x<y y<z = โฅโฅ-functor I (binary-choice x<y y<z) where I : (ฮฃ k ๊ โ , x < k < y) ร (ฮฃ l ๊ โ , y < l < z) โ ฮฃ m ๊ โ , x < m < z I ((k , (x<k , k<y)) , l , (y<l , l<z)) = k , (x<k , k<z) where k<l : k < l k<l = disjoint-from-real y k l (k<y , y<l) k<z : k < z k<z = rounded-left-c (lower-cut-of z) (rounded-from-real-L z) k l k<l l<z _โคโ_ : โ โ โ โ ๐คโ ฬ x โคโ y = (q : โ) โ q < x โ q < y instance Order-โ-โ : Order โ โ _โค_ {{Order-โ-โ}} = _โคโ_ โค-is-prop : (x y : โ) โ is-prop (x โค y) โค-is-prop ((Lx , Rx) , isCutx) ((Ly , Ry) , isCuty) = ฮ โ-is-prop fe (ฮป q _ โ โ-is-prop Ly q) โโค-trans : (x y z : โ) โ x โค y โ y โค z โ x โค z โโค-trans ((Lx , Rx) , _) ((Ly , Ry) , _) ((Lz , Rz) , _) f g = ฮป q qLx โ g q (f q qLx) โ-archimedean : (x y : โ) โ x < y โ โ q ๊ โ , (x < q) ร (q < y) โ-archimedean x y l = l weak-linearity : (x y z : โ) โ x < y โ (x < z) โจ (z < y) weak-linearity x y z l = โฅโฅ-rec โจ-is-prop I l where I : ฮฃ q ๊ โ , q > x ร q < y โ (x < z) โจ (z < y) I (q , qRx , qLy) = โฅโฅ-rec โจ-is-prop II (binary-choice exists-r exists-s) where exists-r : โ r ๊ โ , r < q ร r > x exists-r = rounded-right-b (upper-cut-of x) (rounded-from-real-R x) q qRx exists-s : โ s ๊ โ , q < s < y exists-s = rounded-left-b (lower-cut-of y) (rounded-from-real-L y) q qLy II : (ฮฃ r ๊ โ , r < q ร r > x) ร (ฮฃ s ๊ โ , q < s < y) โ (x < z) โจ (z < y) II ((r , r<q , rRx) , s , q<s , sLy) = โฅโฅ-rec โจ-is-prop IV III where III : (r < z) โจ (z < s) III = โ-locatedness z r s (โ<-trans r q s r<q q<s) IV : (r < z) โ (z < s) โ (x < z) โจ (z < y) IV (inl rLz) = โฃ inl โฃ r , rRx , rLz โฃ โฃ IV (inr sRz) = โฃ inr โฃ s , sRz , sLy โฃ โฃ weak-linearity' : (x y z : โ) โ x < y โ (x < z) โจ (z < y) weak-linearity' x y z l = do (q , x<q , q<y) โ l (r , r<q , x<r) โ rounded-right-b (upper-cut-of x) (rounded-from-real-R x) q x<q (s , q<s , s<y) โ rounded-left-b (lower-cut-of y) (rounded-from-real-L y) q q<y t โ โ-locatedness z r s (โ<-trans r q s r<q q<s) Cases t (ฮป r<z โ โฃ inl โฃ r , x<r , r<z โฃ โฃ) (ฮป z<s โ โฃ inr โฃ s , z<s , s<y โฃ โฃ) _โฏ_ : (x y : โ) โ ๐คโ ฬ x โฏ y = (x < y) โจ (y < x) apartness-gives-inequality : (x y : โ) โ x โฏ y โ ยฌ (x ๏ผ y) apartness-gives-inequality x y apart e = โฅโฅ-rec ๐-is-prop I apart where I : ยฌ ((x < y) โ (y < x)) I (inl l) = โฅโฅ-rec ๐-is-prop III II where II : x < x II = transport (x <_) (e โปยน) l III : ยฌ (ฮฃ q ๊ โ , (x < q) ร (q < x)) III (q , x<q , q<x) = โ<-not-itself-from-โ q x (q<x , x<q) I (inr r) = โฅโฅ-rec ๐-is-prop III II where II : y < y II = transport (y <_) e r III : ยฌ (ฮฃ p ๊ โ , (p > y) ร (p < y)) III (p , y<p , p<y) = โ<-not-itself-from-โ p y (p<y , y<p) โ<-โค-trans : (x y z : โ) โ x < y โ y โค z โ x < z โ<-โค-trans x y z x<y yโคz = โฅโฅ-functor I x<y where I : ฮฃ q ๊ โ , q > x ร q < y โ ฮฃ q' ๊ โ , q' > x ร q' < z I (q , qRx , qLy) = q , qRx , yโคz q qLy โ-less-than-or-equal-not-greater : (x y : โ) โ x โค y โ ยฌ (y < x) โ-less-than-or-equal-not-greater x y xโคy y<x = โฅโฅ-rec ๐-is-prop I y<x where I : ยฌ (ฮฃ q ๊ โ , y < q < x) I (q , y<q , q<x) = โ<-not-itself-from-โ q y (xโคy q q<x , y<q) โ-less-than-not-greater-or-equal : (x y : โ) โ x < y โ ยฌ (y โค x) โ-less-than-not-greater-or-equal x y lโ lโ = โ-less-than-or-equal-not-greater y x lโ lโ โ-not-less-is-greater-or-equal : (x y : โ) โ ยฌ (x < y) โ y โค x โ-not-less-is-greater-or-equal x y nl p pLy = โฅโฅ-rec (โ-is-prop (lower-cut-of x) p) I (rounded-left-b (lower-cut-of y) (rounded-from-real-L y) p pLy) where I : ฮฃ q ๊ โ , p < q < y โ p < x I (q , l , q<y) = โฅโฅ-rec (โ-is-prop (lower-cut-of x) p) II (โ-locatedness x p q l) where II : p < x โ q > x โ p < x II (inl p<x) = p<x II (inr x<q) = ๐-elim (nl โฃ q , (x<q , q<y) โฃ) โโค-<-trans : (x y z : โ) โ x โค y โ y < z โ x < z โโค-<-trans x y z xโคy y<z = โฅโฅ-functor I y<z where I : ฮฃ q ๊ โ , q > y ร q < z โ ฮฃ q' ๊ โ , q' > x ร q' < z I (q , qRy , qLz) = q , โฅโฅ-rec (โ-is-prop (upper-cut-of x) q) III II , qLz where II : โ k ๊ โ , k < q ร k > y II = rounded-right-b (upper-cut-of y) (rounded-from-real-R y) q qRy III : ฮฃ k ๊ โ , k < q ร k > y โ q > x III (k , k<q , kRy) = โฅโฅ-rec (โ-is-prop (upper-cut-of x) q) IV (โ-locatedness x k q k<q) where IV : k < x โ q > x โ q > x IV (inl kLx) = ๐-elim (โ<-irrefl k (disjoint-from-real y k k (xโคy k kLx , kRy))) IV (inr qRx) = qRx <โ-irreflexive : (x : โ) โ x โฎ x <โ-irreflexive x l = โฅโฅ-rec ๐-is-prop I l where I : ยฌ (ฮฃ k ๊ โ , x < k < x) I (k , x<k , k<x) = โ<-not-itself-from-โ k x (k<x , x<k) โ-zero-less-than-one : 0โ < 1โ โ-zero-less-than-one = โฃ 1/2 , 0<1/2 , 1/2<1 โฃ โ-zero-apart-from-one : 0โ โฏ 1โ โ-zero-apart-from-one = โฃ inl โ-zero-less-than-one โฃ embedding-preserves-order : (p q : โ) โ p < q โ ฮน p < ฮน q embedding-preserves-order p q l = I (use-rationals-density) where use-rationals-density : ฮฃ k ๊ โ , p < k < q use-rationals-density = โ-dense p q l I : (ฮฃ k ๊ โ , p < k < q) โ โ k ๊ โ , p < k < q I (k , p<k , k<q) = โฃ k , p<k , k<q โฃAdded by Martin Escardo 24th August 2023, adapted from Various.Dedekind.โค-โ-โ-antisym : (x y : โ) โ x โค y โ y โค x โ x ๏ผ y โค-โ-โ-antisym = โ-equality-from-left-cut' โฏ-is-tight : (x y : โ) โ ยฌ (x โฏ y) โ x ๏ผ y โฏ-is-tight x y ฮฝ = โค-โ-โ-antisym x y III IV where I : x โฎ y I โ = ฮฝ โฃ inl โ โฃ II : y โฎ x II โ = ฮฝ โฃ inr โ โฃ III : x โค y III = โ-not-less-is-greater-or-equal y x II IV : y โค x IV = โ-not-less-is-greater-or-equal x y I โ-is-ยฌยฌ-separated : (x y : โ) โ ยฌยฌ (x ๏ผ y) โ x ๏ผ y โ-is-ยฌยฌ-separated x y ฯ = โฏ-is-tight x y (c ฯ) where c : ยฌยฌ (x ๏ผ y) โ ยฌ (x โฏ y) c = contrapositive (apartness-gives-inequality x y)