8000 [Add] Initial files for Domain theory by jmougeot · Pull Request #2721 · agda/agda-stdlib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Add] Initial files for Domain theory #2721

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
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
63 changes: 63 additions & 0 deletions src/Relation/Binary/Domain/Bundles.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
------------------------------------------------------------------------
-- 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.Domain.Structures
open import Relation.Binary.Domain.Definitions

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} (f : B → Poset.Carrier P) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
field
isDirectedFamily : IsDirectedFamily 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₂ ℓ₂₁ ℓ₂₂)
: 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
38 changes: 38 additions & 0 deletions src/Relation/Binary/Domain/Definitions.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
------------------------------------------------------------------------
-- 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 Level using (Level; _⊔_)
open import Relation.Binary.Core using (Rel)

private
variable
a b ℓ : Level
A B : Set a

------------------------------------------------------------------------
-- Directed families
------------------------------------------------------------------------

-- IsSemidirectedFamily : (P : Poset c ℓ₁ ℓ₂) → ∀ {Ix : Set c} → (s : Ix → Poset.Carrier P) → Set _
-- IsSemidirectedFamily P {Ix} s = ∀ i j → ∃[ k ] (Poset._≤_ P (s i) (s k) × Poset._≤_ P (s j) (s k))

semidirected : {A : Set a} → Rel A ℓ → (B : Set b) → (B → A) → Set _
semidirected _≤_ B f = ∀ i j → ∃[ k ] (f i ≤ f k × f j ≤ f k)

------------------------------------------------------------------------
-- Least upper bounds
------------------------------------------------------------------------

leastupperbound : {A : Set a} → Rel A ℓ → (B : Set b) → (B → A) → A → Set _
leastupperbound _≤_ B f lub = (∀ i → f i ≤ lub) × (∀ y → (∀ i → f i ≤ y) → lub ≤ y)
79 changes: 79 additions & 0 deletions src/Relation/Binary/Domain/Structures.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
------------------------------------------------------------------------
-- 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.Domain.Definitions

private variable
a b c ℓ ℓ₁ ℓ₂ : Level
A B : Set a


module _ {c ℓ₁ ℓ₂ : Level} (P : Poset c ℓ₁ ℓ₂) where
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these definitions really need a Poset or just a relation? I don't immediately see the use of any of the other fields of Poset below.

open Poset P

record IsLub {b : Level} {B : Set b} (f : B → Carrier)
(lub : Carrier) : Set (b ⊔ c ⊔ ℓ₁ ⊔ ℓ₂) where
field
isLeastUpperBound : leastupperbound _≤_ B f lub

isUpperBound : ∀ i → f i ≤ lub
isUpperBound = proj₁ isLeastUpperBound

isLeast : ∀ y → (∀ i → f i ≤ y) → lub ≤ y
isLeast = proj₂ isLeastUpperBound

record IsDirectedFamily {b : Level} {B : Set b} (f : B → Carrier)
: Set (b ⊔ c ⊔ ℓ₁ ⊔ ℓ₂) where
no-eta-equality
field
elt : B
isSemidirected : semidirected _≤_ B f

record IsDirectedCompletePartialOrder : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
field
⋁ : ∀ {B : Set c}
→ (f : B → Carrier)
→ IsDirectedFamily f
→ 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 _ {c₁ ℓ₁₁ ℓ₁₂ c₂ ℓ₂₁ ℓ₂₂ : Level}
(P : Poset c₁ ℓ₁₁ ℓ₁₂)
(Q : Poset c₂ ℓ₂₁ ℓ₂₂) where

private
module P = Poset P
module Q = Poset Q

record IsScottContinuous (f : P.Carrier → Q.Carrier)
: Set (suc (c₁ ⊔ ℓ₁₁ ⊔ ℓ₁₂ ⊔ c₂ ⊔ ℓ₂₁ ⊔ ℓ₂₂)) where
field
preserveLub : ∀ {B : Set c₁} {g : B → P.Carrier}
→ (dir : IsDirectedFamily P g)
→ (lub : P.Carrier)
→ IsLub P g lub
→ IsLub Q (f ∘ g) (f lub)
preserveEquality : ∀ {x y} → x P.≈ y → f x Q.≈ f y
0