Skip to content

[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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ New modules

* `Data.Sign.Show` to show a sign

* Added a new domain theory section to the library under `Relation.Binary.Domain.*`:
- Introduced new modules and bundles for domain theory, including `DirectedCompletePartialOrder`, `Lub`, and `ScottContinuous`.
- All files for domain theory are now available in `src/Relation/Binary/Domain/`.

Additions to existing modules
-----------------------------

Expand Down
5 changes: 5 additions & 0 deletions src/Relation/Binary/Definitions.agda
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ Min R = Max (flip R)
Minimum : Rel A ℓ → A → Set _
Minimum = Min

-- Directed families

SemiDirected : Rel A ℓ → (B → A) → Set _
SemiDirected _≤_ f = ∀ i j → ∃[ k ] (f i ≤ f k × f j ≤ f k)

-- Definitions for apartness relations

-- Note that Cotransitive's arguments are permuted with respect to Transitive's.
Expand Down
16 changes: 16 additions & 0 deletions src/Relation/Binary/Domain.agda
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
66 changes: 66 additions & 0 deletions src/Relation/Binary/Domain/Bundles.agda
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
31 changes: 31 additions & 0 deletions src/Relation/Binary/Domain/Definitions.agda
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
64 changes: 64 additions & 0 deletions src/Relation/Binary/Domain/Structures.agda
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 Poset are involved in the definition, only the underlying relations).

Not least because domain theory ought better to be built on Preorder-based foundations? Antisymmetry plays almost no direct role in the axiomatisation of the concepts you define?

Anyway: meta design principle is/ought to be 'structures don't depend on bundles'

I think (but happy to be contradicted) that UpperBound, Lub, DirectedFamily all belong in Relation.Binary.Domain.Definitions


record IsLub {b : Level} {B : Set b} (f : B → Carrier)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b is already implicitly bound by a variable declaration, so shouldn't need explicit mention here.

(lub : Carrier) : Set (b ⊔ c ⊔ ℓ₁ ⊔ ℓ₂) where
field
isUpperBound : UpperBound _≤_ f lub
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase : CamelCase is the usual convention in stdlib, accordingly:

Suggested change
isUpperBound : UpperBound _≤_ f lub
upperBound : UpperBound _≤_ f lub

isLeast : ∀ y → UpperBound _≤_ f y → lub ≤ y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isLeast : y UpperBound _≤_ f y lub ≤ y
minimal : y UpperBound _≤_ f y lub ≤ y

because being least only follows from the Poset axioms, whereas in their absence (as above), we only have/need a minimal upper bound?


record IsDirectedCompletePartialOrder : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
field
⋁ : ∀ {B : Set c} →
(f : B → Carrier) →
IsDirectedFamily _≈_ _≤_ f →
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition you give of IsDirectedFamily is only accidentally dependent on the underlying Setoid equality relation _≈_, so either you need to involve it by making f a suitable congruence wrt it, or else reconsider whether IsDirectedFamily really belongs in Relation.Binary.Structures?

As this stands, I think the design doesn't quite fit properly with the existing stdlib hierarchy.

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
11 changes: 11 additions & 0 deletions src/Relation/Binary/Structures.agda
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this definition belongs in Relation.Binary.Structures, because it's not actually (an extension of) any of the existing relational structures, rather it's a property that any one of them might additionally possess?

Set (a ⊔ b ⊔ ℓ₂) where
field
elt : B
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to revisit this name before committing to it? eg inhabitant as an alternative?

isSemidirected : SemiDirected _≤_ f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be consistent... wrt our naming conventions camelCase : CamelCase, nor wrt use of isX to refer to an IsX *structure...

Suggested change
isSemidirected : SemiDirected _≤_ f
semiDirected : SemiDirected _≤_ f



------------------------------------------------------------------------
-- Apartness relations
------------------------------------------------------------------------
Expand Down