-
Notifications
You must be signed in to change notification settings - Fork 257
[Add] Initial files for Domain theory - Continuation of #2721 #2809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4486fd0
34be6b0
502e288
63810b7
87d5f16
51954b6
85192d0
ceb39d6
2384bd3
b753478
1e41d41
a679d07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Order-theoretic Domains | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
module Relation.Binary.Domain where | ||
|
||
------------------------------------------------------------------------ | ||
-- Re-export various components of the Domain hierarchy | ||
|
||
open import Relation.Binary.Domain.Definitions public | ||
open import Relation.Binary.Domain.Structures public | ||
open import Relation.Binary.Domain.Bundles public |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Bundles for domain theory | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
module Relation.Binary.Domain.Bundles where | ||
|
||
open import Level using (Level; _⊔_; suc) | ||
open import Relation.Binary.Bundles using (Poset) | ||
open import Relation.Binary.Structures using (IsDirectedFamily) | ||
open import Relation.Binary.Domain.Structures | ||
using (IsDirectedCompletePartialOrder; IsScottContinuous | ||
; IsLub) | ||
|
||
private | ||
variable | ||
o ℓ e o' ℓ' e' ℓ₂ : Level | ||
Ix A B : Set o | ||
|
||
------------------------------------------------------------------------ | ||
-- Directed Complete Partial Orders | ||
------------------------------------------------------------------------ | ||
|
||
record DirectedFamily {c ℓ₁ ℓ₂ : Level} {P : Poset c ℓ₁ ℓ₂} {B : Set c} : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where | ||
field | ||
f : B → Poset.Carrier P | ||
isDirectedFamily : IsDirectedFamily (Poset._≈_ P) (Poset._≤_ P) f | ||
|
||
open IsDirectedFamily isDirectedFamily public | ||
|
||
record DirectedCompletePartialOrder (c ℓ₁ ℓ₂ : Level) : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where | ||
field | ||
poset : Poset c ℓ₁ ℓ₂ | ||
isDirectedCompletePartialOrder : IsDirectedCompletePartialOrder poset | ||
|
||
open Poset poset public | ||
open IsDirectedCompletePartialOrder isDirectedCompletePartialOrder public | ||
|
||
------------------------------------------------------------------------ | ||
-- Scott-continuous functions | ||
------------------------------------------------------------------------ | ||
|
||
record ScottContinuous | ||
{c₁ ℓ₁₁ ℓ₁₂ c₂ ℓ₂₁ ℓ₂₂ : Level} | ||
(P : Poset c₁ ℓ₁₁ ℓ₁₂) | ||
(Q : Poset c₂ ℓ₂₁ ℓ₂₂) | ||
(κ : Level) : Set (suc (κ ⊔ c₁ ⊔ ℓ₁₁ ⊔ ℓ₁₂ ⊔ c₂ ⊔ ℓ₂₁ ⊔ ℓ₂₂)) where | ||
field | ||
f : Poset.Carrier P → Poset.Carrier Q | ||
isScottContinuous : IsScottContinuous P Q f κ | ||
|
||
open IsScottContinuous isScottContinuous public | ||
|
||
------------------------------------------------------------------------ | ||
-- Lubs | ||
------------------------------------------------------------------------ | ||
|
||
record Lub {c ℓ₁ ℓ₂ : Level} {P : Poset c ℓ₁ ℓ₂} {B : Set c} | ||
(f : B → Poset.Carrier P) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where | ||
open Poset P | ||
field | ||
lub : Carrier | ||
isLub : IsLub P f lub |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Definitions for domain theory | ||
------------------------------------------------------------------------ | ||
|
||
|
||
|
||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
module Relation.Binary.Domain.Definitions where | ||
|
||
open import Data.Product using (∃-syntax; _×_; _,_) | ||
open import Function using (_∘_) | ||
open import Level using (Level; _⊔_; suc) | ||
open import Relation.Binary.Core using (Rel) | ||
|
||
private | ||
variable | ||
a b i ℓ ℓ₁ ℓ₂ : Level | ||
A : Set a | ||
B : Set b | ||
I : Set ℓ | ||
|
||
------------------------------------------------------------------------ | ||
-- Upper bound | ||
------------------------------------------------------------------------ | ||
|
||
UpperBound : {A : Set a} → Rel A ℓ → {B : Set b} → (f : B → A) → A → Set _ | ||
UpperBound _≤_ f x = ∀ i → f i ≤ x |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,64 @@ | ||||||
------------------------------------------------------------------------ | ||||||
-- The Agda standard library | ||||||
-- | ||||||
-- Structures for domain theory | ||||||
------------------------------------------------------------------------ | ||||||
|
||||||
{-# OPTIONS --cubical-compatible --safe #-} | ||||||
|
||||||
module Relation.Binary.Domain.Structures where | ||||||
|
||||||
open import Data.Product using (_×_; _,_; proj₁; proj₂) | ||||||
open import Function using (_∘_) | ||||||
open import Level using (Level; _⊔_; suc) | ||||||
open import Relation.Binary.Bundles using (Poset) | ||||||
open import Relation.Binary.Structures using (IsDirectedFamily) | ||||||
open import Relation.Binary.Domain.Definitions using (UpperBound) | ||||||
open import Relation.Binary.Morphism.Structures using (IsOrderHomomorphism) | ||||||
|
||||||
private variable | ||||||
a b c c₁ c₂ ℓ ℓ₁ ℓ₂ ℓ₁₁ ℓ₁₂ ℓ₂₁ ℓ₂₂ : Level | ||||||
A B : Set a | ||||||
|
||||||
|
||||||
module _ (P : Poset c ℓ₁ ℓ₂) where | ||||||
open Poset P | ||||||
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this has come up before in this context; we tend to define this kind of parametrised record on the underlying Raw structure (because none of the axioms for a Not least because domain theory ought better to be built on Anyway: meta design principle is/ought to be 'structures don't depend on bundles' I think (but happy to be contradicted) that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can blame this on me 😁 In setoid-based foundations, it doesn't really make sense to found order theory on preorders. To see why, let's look at a very relevant example: uniqueness of lubs. In a poset module PosetAPI (P : Poset) where
open Poset P
Lub-unique : ∀ {Ix : Set} {f : Ix → Carrier} {x y} → IsLub f x → IsLub f y → x ≈ y
Lub-unique = ...
module PreorderAPI (P : Preorder) where
open Preorder P
Lub-unique : ∀ {Ix : Set} {f : Ix → Carrier} {x y} → IsLub f x → IsLub f y → (x ≤ y) × (y ≤ x)
Lub-unique = ... However, we can complete any preorder As for parameterising by raw structures, my comments about poor inference from the last PR are still relevant. I don't really see anyone considering least-upper bounds in a raw structure, so the tradeoff of generality for inference performance doesn't seem worth it here. There is a lot of precedence for this choice in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I commented on posetal completion on #2721 , sorry for that. As for parametrisation by a |
||||||
|
||||||
record IsLub {b : Level} {B : Set b} (f : B → Carrier) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
(lub : Carrier) : Set (b ⊔ c ⊔ ℓ₁ ⊔ ℓ₂) where | ||||||
field | ||||||
isUpperBound : UpperBound _≤_ f lub | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
isLeast : ∀ y → UpperBound _≤_ f y → lub ≤ y | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
because being least only follows from the |
||||||
|
||||||
record IsDirectedCompletePartialOrder : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where | ||||||
field | ||||||
⋁ : ∀ {B : Set c} → | ||||||
(f : B → Carrier) → | ||||||
IsDirectedFamily _≈_ _≤_ f → | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The definition you give of As this stands, I think the design doesn't quite fit properly with the existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moreover, it's not a priori obvious that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would no longer be a DCPO if that were the case. |
||||||
Carrier | ||||||
⋁-isLub : ∀ {B : Set c} | ||||||
→ (f : B → Carrier) | ||||||
→ (dir : IsDirectedFamily _≈_ _≤_ f) | ||||||
→ IsLub f (⋁ f dir) | ||||||
|
||||||
module _ {B : Set c} {f : B → Carrier} {dir : IsDirectedFamily _≈_ _≤_ f} where | ||||||
open IsLub (⋁-isLub f dir) | ||||||
renaming (isUpperBound to ⋁-≤; isLeast to ⋁-least) | ||||||
public | ||||||
|
||||||
------------------------------------------------------------------------ | ||||||
-- Scott‐continuous maps between two (possibly different‐universe) posets | ||||||
------------------------------------------------------------------------ | ||||||
|
||||||
module _ (P : Poset c₁ ℓ₁₁ ℓ₁₂) (Q : Poset c₂ ℓ₂₁ ℓ₂₂) | ||||||
where | ||||||
module P = Poset P | ||||||
module Q = Poset Q | ||||||
|
||||||
record IsScottContinuous (f : P.Carrier → Q.Carrier) (κ : Level) : Set (suc (κ ⊔ c₁ ⊔ ℓ₁₁ ⊔ ℓ₁₂ ⊔ c₂ ⊔ ℓ₂₁ ⊔ ℓ₂₂)) | ||||||
where | ||||||
field | ||||||
preservelub : ∀ {I : Set κ} → ∀ {g : I → _} → ∀ lub → IsLub P g lub → IsLub Q (f ∘ g) (f lub) | ||||||
isOrderHomomorphism : IsOrderHomomorphism P._≈_ Q._≈_ P._≤_ Q._≤_ f | ||||||
|
||||||
open IsOrderHomomorphism isOrderHomomorphism public | ||||||
Comment on lines
+58
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks as though it better belongs under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See also: #2812 . Can the definition be simplified to exploit that:
and hence that |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -317,6 +317,17 @@ record IsDenseLinearOrder (_<_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) wher | |||||
open IsStrictTotalOrder isStrictTotalOrder public | ||||||
|
||||||
|
||||||
------------------------------------------------------------------------ | ||||||
-- DirectedFamily | ||||||
------------------------------------------------------------------------ | ||||||
|
||||||
record IsDirectedFamily {b : Level} {B : Set b} (_≤_ : Rel A ℓ₂) (f : B → A) : | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that this definition belongs in |
||||||
Set (a ⊔ b ⊔ ℓ₂) where | ||||||
field | ||||||
elt : B | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to revisit this name before committing to it? eg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Else reuse the symbol from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, why make the point explicit (in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the definition much clunkier to use for types that are already inhabited. For example, every DCPO is an omega-CPO, but proving this with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #2811 for comparison. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two are not equivalent: it's important that the distinguished point be in the set/family we are taking a join of. Joins over the empty set give you a bottom element, and not every DCPO has a bottom. A good counter example of this is the order on non-empty subsets of Nat (though any type with at least two distinct elements will do). This actually has joins of all nonempty subsets via union, and is nonempty. However, it does not have a bottom. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I'm clear about making the bottom-/non-bottom- containing distinction in #2811 ; my real concern with making There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it currently stands, #2811 has the problem I mentioned with bottoms. You can try and ask for an element of A along with a point in the setoidal fibre of the family (EG, an The definition here already has too much data to begin with, as we should only require the mere existence of an element of B and the mere existence of upper bounds. A 100% correct definition would impose an equivalence relation on the type of directed families that essentially truncates away the point and upper bounds, and then require that the joins be congruent with respect to that relation. However, this seems to be against the stdlib style, as these sorts of truncations don't seem common. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the last paragraph, one way to introduce truncation, at least as I imperfectly understand it, would be to mark fields as But such considerations are taking us well beyond this individual PR... so I think in the interests of making progress on it, I'm going to step back from the reviewing discussion. |
||||||
isSemidirected : SemiDirected _≤_ f | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be consistent... wrt our naming conventions
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last thoughts on this/suggestion:
yielding: ⋁ : ∀ {I : Set c} → .I → (f : I → Carrier) → Directed (_≤_ on f) → Carrier
⋁-isLub : ∀ {I : Set c} .(i : I) (f : I → Carrier) (d : Directed (_≤_ on f)) → IsLub f (⋁ i f dir) |
||||||
|
||||||
|
||||||
------------------------------------------------------------------------ | ||||||
-- Apartness relations | ||||||
------------------------------------------------------------------------ | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... after thinking about this for quite a bit, would it make (better) sense to factorise this definition so that
SemiDirected
refers only to the underlying relation, as:∀ (x y : A) → ∃[ z ] (x ≤ z × y ≤ z)
_≤_ : Rel A ℓ
, andf : B → A
we obtain an ordering_≤[ f ]_
onB
byi ≤[ f ] k = f i ≤ f k
(given by_≤_ on f
usingFunction.Base._on_
)SemiDirected _≤[ f ]_
UPDATED: see #2813