OrderedTypes.sigma-sup-lattice
Martin Escardo, 15 June 2020 We consider ฯ-sup-lattices. We have โ-indexed joins and โฅ (and hence finite joins).{-# OPTIONS --safe --without-K #-} open import MLTT.Spartan open import UF.FunExt open import UF.Subsingletons module OrderedTypes.sigma-sup-lattice (fe : Fun-Ext) where open import UF.HedbergApplications open import UF.SIP open import UF.Sets open import UF.Subsingletons-FunExt ฯ-suplat-structure : ๐ค ฬ โ ๐ค ฬ ฯ-suplat-structure X = X ร ((โ โ X) โ X)A compatible order for ฯ-suplat structure (โค , โฅ , โ) is a partial order (prop-valued, reflexive, transitive and antisymmetric binary relation) such that โฅ is the smallest element, โค is the largest element, and โ x is the least upper bound of the sequence x.is-ฯ-sup-compatible-order : {X : ๐ค ฬ } โ ฯ-suplat-structure X โ (X โ X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ is-ฯ-sup-compatible-order {๐ค} {๐ฅ} {X} (โฅ , โ) _โค_ = I ร II ร III ร IV ร V ร VI ร VII where I = (x y : X) โ is-prop (x โค y) II = (x : X) โ x โค x III = (x y z : X) โ x โค y โ y โค z โ x โค z IV = (x y : X) โ x โค y โ y โค x โ x ๏ผ y V = (x : X) โ โฅ โค x VI = (x : โ โ X) (n : โ) โ x n โค โ x VII = (x : โ โ X) (u : X) โ ((n : โ) โ x n โค u) โ โ x โค uWe can define the binary sup x โจ y of two elements x and y by โ (x * y) where x * y is the infinite sequence consisting of x followed by infinitely many y's. Then we can define the intrinsic order by x โค y iff x โจ y = y.private _*_ : {X : ๐ค ฬ } โ X โ X โ (โ โ X) (x * y) 0 = x (x * y) (succ _) = y intrinsic-order : {X : ๐ค ฬ } โ ฯ-suplat-structure X โ (X โ X โ ๐ค ฬ ) intrinsic-order (โฅ , โ) x y = โ (x * y) ๏ผ y syntax intrinsic-order s x y = x โค[ s ] yAny compatible order is logically equivalent to the intrinsic order:any-ฯ-sup-order-is-intrinsic-order : {X : ๐ค ฬ } (s : ฯ-suplat-structure X) (_โค_ : X โ X โ ๐ฅ ฬ ) โ is-ฯ-sup-compatible-order s _โค_ โ (x y : X) โ x โค y โ x โค[ s ] y any-ฯ-sup-order-is-intrinsic-order {๐ฅ} {X} (โฅ , โ) _โค_ (โค-prop-valued , โค-refl , โค-trans , โค-anti , bottom , โ-is-ub , โ-is-lb-of-ubs) x y = a , b where s = (โฅ , โ) a : x โค y โ x โค[ s ] y a l = iv where i : (n : โ) โ (x * y) n โค y i 0 = l i (succ n) = โค-refl y ii : โ (x * y) โค y ii = โ-is-lb-of-ubs (x * y) y i iii : y โค โ (x * y) iii = โ-is-ub (x * y) (succ 0) iv : โ (x * y) ๏ผ y iv = โค-anti (โ (x * y)) y ii iii b : x โค[ s ] y โ x โค y b l = iii where i : โ (x * y) โค y i = transport (โ (x * y) โค_) l (โค-refl (โ (x * y))) ii : x โค โ (x * y) ii = โ-is-ub (x * y) 0 iii : x โค y iii = โค-trans _ _ _ ii iTherefore, by functional and propositional extensionality, there is at most one compatible order:at-most-one-ฯ-sup-order : Prop-Ext โ {X : ๐ค ฬ } (s : ฯ-suplat-structure X) (_โค_ _โค'_ : X โ X โ ๐ฅ ฬ ) โ is-ฯ-sup-compatible-order s _โค_ โ is-ฯ-sup-compatible-order s _โค'_ โ _โค_ ๏ผ _โค'_ at-most-one-ฯ-sup-order pe s _โค_ _โค'_ (i , i') (j , j') = ฮณ where a : โ x y โ x โค y โ x โค' y a x y = v โ u where u : x โค y โ x โค[ s ] y u = lr-implication (any-ฯ-sup-order-is-intrinsic-order s _โค_ (i , i') x y) v : x โค[ s ] y โ x โค' y v = rl-implication (any-ฯ-sup-order-is-intrinsic-order s _โค'_ (j , j') x y) b : โ x y โ x โค' y โ x โค y b x y = v โ u where u : x โค' y โ x โค[ s ] y u = lr-implication (any-ฯ-sup-order-is-intrinsic-order s _โค'_ (j , j') x y) v : x โค[ s ] y โ x โค y v = rl-implication (any-ฯ-sup-order-is-intrinsic-order s _โค_ (i , i') x y) ฮณ : _โค_ ๏ผ _โค'_ ฮณ = dfunext fe (ฮป x โ dfunext fe (ฮป y โ pe (i x y) (j x y) (a x y) (b x y)))Hence being order compatible is property (rather than just data):being-ฯ-sup-order-is-prop : {X : ๐ค ฬ } (s : ฯ-suplat-structure X) (_โค_ : X โ X โ ๐ฅ ฬ ) โ is-prop (is-ฯ-sup-compatible-order s _โค_) being-ฯ-sup-order-is-prop (โฅ , โ) _โค_ = prop-criterion ฮณ where s = (โฅ , โ) ฮณ : is-ฯ-sup-compatible-order s _โค_ โ is-prop (is-ฯ-sup-compatible-order s _โค_) ฮณ (โค-prop-valued , โค-refl , โค-trans , โค-anti , bottom , โ-is-ub , โ-is-lb-of-ubs) = รโ-is-prop (ฮ โ-is-prop fe (ฮป x y โ being-prop-is-prop fe)) (ฮ -is-prop fe (ฮป x โ โค-prop-valued x x)) (ฮ โ -is-prop fe (ฮป x _ z _ _ โ โค-prop-valued x z)) (ฮ โ-is-prop fe (ฮป x y _ _ โ type-with-prop-valued-refl-antisym-rel-is-set _โค_ โค-prop-valued โค-refl โค-anti)) (ฮ -is-prop fe (ฮป x โ โค-prop-valued โฅ x)) (ฮ โ-is-prop fe (ฮป x n โ โค-prop-valued (x n) (โ x))) (ฮ โ-is-prop fe (ฮป x u _ โ โค-prop-valued (โ x) u))The ฯ-suplat axiom says that there exists a compatible order, which is then unique by the above:ฯ-suplat-axiom : (๐ฅ : Universe) {X : ๐ค ฬ } โ ฯ-suplat-structure X โ ๐ค โ (๐ฅ โบ) ฬ ฯ-suplat-axiom ๐ฅ {X} s = ฮฃ _โค_ ๊ (X โ X โ ๐ฅ ฬ ) , (is-ฯ-sup-compatible-order s _โค_) ฯ-suplat-axiom-gives-is-set : {X : ๐ค ฬ } {s : ฯ-suplat-structure X} โ ฯ-suplat-axiom ๐ฅ s โ is-set X ฯ-suplat-axiom-gives-is-set (_โค_ , โค-prop-valued , โค-refl , _ , โค-anti , _) = type-with-prop-valued-refl-antisym-rel-is-set _โค_ โค-prop-valued โค-refl โค-anti ฯ-suplat-axiom-is-prop : Prop-Ext โ {๐ฅ : Universe} โ {X : ๐ค ฬ } (s : ฯ-suplat-structure X) โ is-prop (ฯ-suplat-axiom ๐ฅ {X} s) ฯ-suplat-axiom-is-prop pe s (_โค_ , a) (_โค'_ , a') = to-subtype-๏ผ (being-ฯ-sup-order-is-prop s) (at-most-one-ฯ-sup-order pe s _โค_ _โค'_ a a') ฯ-SupLat : (๐ค ๐ฅ : Universe) โ (๐ค โ ๐ฅ)โบ ฬ ฯ-SupLat ๐ค ๐ฅ = ฮฃ X ๊ ๐ค ฬ , ฮฃ s ๊ ฯ-suplat-structure X , ฯ-suplat-axiom ๐ฅ s open sip public โฅโจ_โฉ : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ โจ ๐ โฉ โฅโจ A , (โฅ , โ) , _ โฉ = โฅ โโจ_โฉ : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ (โ โ โจ ๐ โฉ) โ โจ ๐ โฉ โโจ A , (โฅ , โ) , _ โฉ = โ โจ_โฉ-is-set : (L : ฯ-SupLat ๐ค ๐ฅ) โ is-set โจ L โฉ โจ_โฉ-is-set (X , s , a) = ฯ-suplat-axiom-gives-is-set a โจ_โฉ-order : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ โจ ๐ โฉ โ โจ ๐ โฉ โ ๐ฅ ฬ โจ A , (โฅ , โ) , (_โค_ , _) โฉ-order = _โค_ order : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ โจ ๐ โฉ โ โจ ๐ โฉ โ ๐ฅ ฬ order = โจ_โฉ-order syntax order ๐ x y = x โคโจ ๐ โฉ y โจ_โฉ-structure : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ ฯ-suplat-structure โจ ๐ โฉ โจ A , s , (_โค_ , i-viii) โฉ-structure = s โจ_โฉ-โค-is-ฯ-sup-compatible-order : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ is-ฯ-sup-compatible-order โจ ๐ โฉ-structure (โจ ๐ โฉ-order) โจ A , _ , (_โค_ , i-viii) โฉ-โค-is-ฯ-sup-compatible-order = i-viii โจ_โฉ-order-is-prop-valued : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a b : โจ ๐ โฉ) โ is-prop (a โคโจ ๐ โฉ b) โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-order-is-prop-valued = i โจ_โฉ-refl : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a : โจ ๐ โฉ) โ a โคโจ ๐ โฉ a โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-refl = ii โจ_โฉ-trans : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a b c : โจ ๐ โฉ) โ a โคโจ ๐ โฉ b โ b โคโจ ๐ โฉ c โ a โคโจ ๐ โฉ c โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-trans = iii โจ_โฉ-antisym : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a b : โจ ๐ โฉ) โ a โคโจ ๐ โฉ b โ b โคโจ ๐ โฉ a โ a ๏ผ b โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-antisym = iv โจ_โฉ-โฅ-is-minimum : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a : โจ ๐ โฉ) โ โฅโจ ๐ โฉ โคโจ ๐ โฉ a โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-โฅ-is-minimum = v โจ_โฉ-โ-is-ub : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a : โ โ โจ ๐ โฉ) (n : โ) โ a n โคโจ ๐ โฉ โโจ ๐ โฉ a โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-โ-is-ub = vi โจ_โฉ-โ-is-lb-of-ubs : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a : โ โ โจ ๐ โฉ) (u : โจ ๐ โฉ) โ ((n : โ) โ a n โคโจ ๐ โฉ u) โ โโจ ๐ โฉ a โคโจ ๐ โฉ u โจ A , _ , (_โค_ , i , ii , iii , iv , v , vi , vii) โฉ-โ-is-lb-of-ubs = vii โจ_โฉ-๏ผ-gives-โค : (๐ : ฯ-SupLat ๐ค ๐ฅ) {a b : โจ ๐ โฉ} โ a ๏ผ b โ a โคโจ ๐ โฉ b โจ ๐ โฉ-๏ผ-gives-โค {a} refl = โจ ๐ โฉ-refl a binary-join : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ โจ ๐ โฉ โ โจ ๐ โฉ โ โจ ๐ โฉ binary-join ๐ a b = โโจ ๐ โฉ (a * b) syntax binary-join ๐ a b = a โจโจ ๐ โฉ b infixl 100 binary-join โจ_โฉ-โจ-is-ub-left : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a b : โจ ๐ โฉ) โ a โคโจ ๐ โฉ a โจโจ ๐ โฉ b โจ_โฉ-โจ-is-ub-left ๐ a b = โจ ๐ โฉ-โ-is-ub (a * b) 0 โจ_โฉ-โจ-is-ub-right : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a b : โจ ๐ โฉ) โ b โคโจ ๐ โฉ a โจโจ ๐ โฉ b โจ_โฉ-โจ-is-ub-right ๐ a b = โจ ๐ โฉ-โ-is-ub (a * b) 1 โจ_โฉ-โจ-is-lb-of-ubs : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a b u : โจ ๐ โฉ) โ a โคโจ ๐ โฉ u โ b โคโจ ๐ โฉ u โ a โจโจ ๐ โฉ b โคโจ ๐ โฉ u โจ_โฉ-โจ-is-lb-of-ubs ๐ a b u l m = โจ ๐ โฉ-โ-is-lb-of-ubs (a * b) u f where f : (n : โ) โ (a * b) n โคโจ ๐ โฉ u f 0 = l f (succ n) = m โจ_โฉ-โ-idempotent : (๐ : ฯ-SupLat ๐ค ๐ฅ) (a : โจ ๐ โฉ) โ โโจ ๐ โฉ (n โฆ a) ๏ผ a โจ_โฉ-โ-idempotent ๐ a = โจ ๐ โฉ-antisym _ _ (โจ ๐ โฉ-โ-is-lb-of-ubs (n โฆ a) a (ฮป n โ โจ ๐ โฉ-refl a)) (โจ ๐ โฉ-โ-is-ub (n โฆ a) 0) โจ_โฉ-โ-transp : (๐ : ฯ-SupLat ๐ค ๐ฅ) (c : โ โ โ โ โจ ๐ โฉ) โ โโจ ๐ โฉ (i โฆ โโจ ๐ โฉ (j โฆ c i j)) ๏ผ โโจ ๐ โฉ (j โฆ โโจ ๐ โฉ (i โฆ c i j)) โจ_โฉ-โ-transp {๐ค} {๐ฅ} ๐ c = โจ ๐ โฉ-antisym _ _ m l where โ = โโจ ๐ โฉ _โค_ : โจ ๐ โฉ โ โจ ๐ โฉ โ ๐ฅ ฬ a โค b = a โคโจ ๐ โฉ b p : โ iโ jโ โ c iโ jโ โค โ (i โฆ โ (j โฆ c i j)) p iโ jโ = โจ ๐ โฉ-trans _ _ _ pโ pโ where pโ : c iโ jโ โค โ (j โฆ c iโ j) pโ = โจ ๐ โฉ-โ-is-ub (ฮป j โ c iโ j) jโ pโ : โ (j โฆ c iโ j) โค โ (i โฆ โ (j โฆ c i j)) pโ = โจ ๐ โฉ-โ-is-ub (ฮป i โ โ (j โฆ c i j)) iโ l : โ (j โฆ โ (i โฆ c i j)) โค โ (i โฆ โ (j โฆ c i j)) l = โจ ๐ โฉ-โ-is-lb-of-ubs _ _ (ฮป j โ โจ ๐ โฉ-โ-is-lb-of-ubs _ _ (ฮป i โ p i j)) q : โ iโ jโ โ c iโ jโ โค โ (j โฆ โ (i โฆ c i j)) q iโ jโ = โจ ๐ โฉ-trans _ _ _ qโ qโ where qโ : c iโ jโ โค โ (i โฆ c i jโ) qโ = โจ ๐ โฉ-โ-is-ub (ฮป i โ c i jโ) iโ qโ : โ (i โฆ c i jโ) โค โ (j โฆ โ (i โฆ c i j)) qโ = โจ ๐ โฉ-โ-is-ub (ฮป j โ โ (i โฆ c i j)) jโ m : โ (i โฆ โ (j โฆ c i j)) โค โ (j โฆ โ (i โฆ c i j)) m = โจ ๐ โฉ-โ-is-lb-of-ubs _ _ (ฮป i โ โจ ๐ โฉ-โ-is-lb-of-ubs _ _ (ฮป j โ q i j)) is-ฯ-suplat-hom : (๐ : ฯ-SupLat ๐ค ๐ฆ) (๐ : ฯ-SupLat ๐ฅ ๐ฃ) โ (โจ ๐ โฉ โ โจ ๐ โฉ) โ ๐ค โ ๐ฅ ฬ is-ฯ-suplat-hom (_ , (โฅ , โ) , _) (_ , (โฅ' , โ') , _) f = (f โฅ ๏ผ โฅ') ร (โ ๐ โ f (โ ๐) ๏ผ โ' (n โฆ f (๐ n))) being-ฯ-suplat-hom-is-prop : (๐ : ฯ-SupLat ๐ค ๐ฆ) (๐ : ฯ-SupLat ๐ฅ ๐ฃ) (f : โจ ๐ โฉ โ โจ ๐ โฉ) โ is-prop (is-ฯ-suplat-hom ๐ ๐ f) being-ฯ-suplat-hom-is-prop ๐ ๐ f = ร-is-prop โจ ๐ โฉ-is-set (ฮ -is-prop fe (ฮป _ โ โจ ๐ โฉ-is-set)) ฯ-suplat-hom-โฅ : (๐ : ฯ-SupLat ๐ค ๐ฆ) (๐ : ฯ-SupLat ๐ฅ ๐ฃ) โ (f : โจ ๐ โฉ โ โจ ๐ โฉ) โ is-ฯ-suplat-hom ๐ ๐ f โ f โฅโจ ๐ โฉ ๏ผ โฅโจ ๐ โฉ ฯ-suplat-hom-โฅ ๐ ๐ f (i , ii) = i ฯ-suplat-hom-โ : (๐ : ฯ-SupLat ๐ค ๐ฆ) (๐ : ฯ-SupLat ๐ฅ ๐ฃ) โ (f : โจ ๐ โฉ โ โจ ๐ โฉ) โ is-ฯ-suplat-hom ๐ ๐ f โ โ ๐ โ f (โโจ ๐ โฉ ๐) ๏ผ โโจ ๐ โฉ (n โฆ f (๐ n)) ฯ-suplat-hom-โ ๐ ๐ f (i , ii) = ii is-monotone : (๐ : ฯ-SupLat ๐ค ๐ฆ) (๐ : ฯ-SupLat ๐ฅ ๐ฃ) โ (โจ ๐ โฉ โ โจ ๐ โฉ) โ ๐ค โ ๐ฆ โ ๐ฃ ฬ is-monotone ๐ ๐ f = โ a b โ a โคโจ ๐ โฉ b โ f a โคโจ ๐ โฉ f b ฯ-suplat-hom-โค : (๐ : ฯ-SupLat ๐ค ๐ฆ) (๐ : ฯ-SupLat ๐ฅ ๐ฃ) โ (f : โจ ๐ โฉ โ โจ ๐ โฉ) โ is-ฯ-suplat-hom ๐ ๐ f โ is-monotone ๐ ๐ f ฯ-suplat-hom-โค ๐ ๐ f i a b l = m where c : f a * f b โผ f โ (a * b) c 0 = refl c (succ n) = refl l' : โโจ ๐ โฉ (a * b) ๏ผ b l' = lr-implication (any-ฯ-sup-order-is-intrinsic-order _ (โจ ๐ โฉ-order) โจ ๐ โฉ-โค-is-ฯ-sup-compatible-order a b) l m' : โโจ ๐ โฉ (f a * f b) ๏ผ f b m' = โโจ ๐ โฉ (f a * f b) ๏ผโจ ap โโจ ๐ โฉ (dfunext fe c) โฉ โโจ ๐ โฉ (f โ (a * b)) ๏ผโจ (ฯ-suplat-hom-โ ๐ ๐ f i (a * b))โปยน โฉ f (โโจ ๐ โฉ (a * b)) ๏ผโจ ap f l' โฉ f b โ m : f a โคโจ ๐ โฉ f b m = rl-implication (any-ฯ-sup-order-is-intrinsic-order _ (โจ ๐ โฉ-order) โจ ๐ โฉ-โค-is-ฯ-sup-compatible-order (f a) (f b)) m' id-is-ฯ-suplat-hom : (๐ : ฯ-SupLat ๐ค ๐ฅ) โ is-ฯ-suplat-hom ๐ ๐ id id-is-ฯ-suplat-hom ๐ = refl , (ฮป ๐ โ refl) โ-ฯ-suplat-hom : (๐ : ฯ-SupLat ๐ค ๐ค') (๐ : ฯ-SupLat ๐ฅ ๐ฅ') (๐ : ฯ-SupLat ๐ฆ ๐ฆ') (f : โจ ๐ โฉ โ โจ ๐ โฉ) (g : โจ ๐ โฉ โ โจ ๐ โฉ) โ is-ฯ-suplat-hom ๐ ๐ f โ is-ฯ-suplat-hom ๐ ๐ g โ is-ฯ-suplat-hom ๐ ๐ (g โ f) โ-ฯ-suplat-hom ๐ ๐ ๐ f g (rโ , sโ) (rโ , sโ) = (rโ , sโ) where rโ = g (f โฅโจ ๐ โฉ) ๏ผโจ ap g rโ โฉ g โฅโจ ๐ โฉ ๏ผโจ rโ โฉ โฅโจ ๐ โฉ โ sโ = ฮป ๐ โ g (f (โโจ ๐ โฉ ๐)) ๏ผโจ ap g (sโ ๐) โฉ g (โโจ ๐ โฉ (ฮป n โ f (๐ n))) ๏ผโจ sโ (ฮป n โ f (๐ n)) โฉ โโจ ๐ โฉ (ฮป n โ g (f (๐ n))) โ