Skip to content

Commit fde1991

Browse files
committed
first step
1 parent 4871f37 commit fde1991

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
module Relation.Binary.Domain.Definitions where
2+
3+
open import Relation.Binary.Core
4+
open import Relation.Binary.Bundles
5+
open import Relation.Binary.Structures
6+
open import Relation.Binary.Lattice.Bundles
7+
open import Relation.Binary.Lattice.Structures
8+
open import Level using (Level; _⊔_; suc; Lift; lift)
9+
open import Function using (_∘_; id)
10+
open import Data.Product using (∃-syntax; _×_; _,_; proj₁; proj₂)
11+
open import Relation.Unary using (Pred)
12+
open import Relation.Nullary using (¬_)
13+
open import Relation.Binary.PropositionalEquality using (_≡_)
14+
open import Relation.Binary.Reasoning.PartialOrder
15+
open import Data.Bool using (Bool; true; false)
16+
17+
private variable
18+
o ℓ ℓ' ℓ₂ : Level
19+
Ix A B : Set o
20+
21+
22+
module _ {c ℓ₁ ℓ₂ : Level} (P : Poset c ℓ₁ ℓ₂) where
23+
open Poset P
24+
25+
module PartialOrderReasoning = Relation.Binary.Reasoning.PartialOrder P
26+
27+
is-semidirected-family : {Ix : Set c} (f : Ix Carrier) Set _
28+
is-semidirected-family f = i j ∃[ k ] (f i ≤ f k × f j ≤ f k)
29+
30+
record is-directed-family {Ix : Set c} (f : Ix Carrier) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
31+
no-eta-equality
32+
field
33+
elt : Ix
34+
semidirected : is-semidirected-family f
35+
36+
record is-dcpo : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
37+
field
38+
has-directed-lub : {Ix : Set c} {f : Ix Carrier}
39+
is-directed-family f
40+
∃[ lub ] (( i f i ≤ lub) × y ( i f i ≤ y) lub ≤ y)
41+
42+
record DCPO : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
43+
field
44+
poset : Poset c ℓ₁ ℓ₂
45+
dcpo-str : is-dcpo
46+
47+
module _ {c ℓ₁ ℓ₂ : Level} {P : Poset c ℓ₁ ℓ₂} {Q : Poset c ℓ₁ ℓ₂} where
48+
49+
private
50+
module P = Poset P
51+
module Q = Poset Q
52+
53+
record is-monotone (f : P.Carrier Q.Carrier) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
54+
field
55+
monotone : {x y} x P.≤ y f x Q.≤ f y
56+
57+
record is-scott-continuous (f : P.Carrier Q.Carrier) : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
58+
field
59+
monotone : is-monotone f
60+
preserve-lub : {Ix : Set c} {g : Ix P.Carrier}
61+
(df : is-directed-family P g)
62+
(dlub : ∃[ lub ] (( i g i P.≤ lub) × y ( i g i P.≤ y) lub P.≤ y))
63+
∃[ qlub ] (( i f (g i) Q.≤ qlub) × y ( i f (g i) Q.≤ y) qlub Q.≤ y)
64+
65+
dcpo+scott→monotone : (P-dcpo : is-dcpo P)
66+
(f : P.Carrier Q.Carrier)
67+
(scott : is-scott-continuous f)
68+
{x y} x P.≤ y f x Q.≤ f y
69+
70+
dcpo+scott→monotone P-dcpo f scott {x} {y} p =
71+
Q.trans (ub-proof (lift true)) (least-proof (f y) upper-bound-proof)
72+
where
73+
s : Lift c Bool P.Carrier
74+
s (lift true) = x
75+
s (lift false) = y
76+
77+
s-directed : is-directed-family P s
78+
s-directed .is-directed-family.elt = lift true
79+
s-directed .is-directed-family.semidirected i j =
80+
lift false , p' i , p' j
81+
where
82+
p' : (i : Lift c Bool) s i P.≤ s (lift false)
83+
p' (lift true) = p
84+
p' (lift false) = P.refl
85+
86+
s-lub = is-dcpo.has-directed-lub P-dcpo s-directed
87+
q-lub = is-scott-continuous.preserve-lub scott s-directed s-lub
88+
89+
ub-proof : i f (s i) Q.≤ proj₁ q-lub
90+
ub-proof = proj₁ (proj₂ q-lub)
91+
92+
least-proof : y ( i f (s i) Q.≤ y) proj₁ q-lub Q.≤ y
93+
least-proof = proj₂ (proj₂ q-lub)
94+
95+
upper-bound-proof : i f (s i) Q.≤ f y
96+
upper-bound-proof (lift true) = is-monotone.monotone (is-scott-continuous.monotone scott) p
97+
upper-bound-proof (lift false) = Q.refl
98+
99+
monotone∘directed : {Ix : Set c} {s : Ix P.Carrier}
100+
(f : P.Carrier Q.Carrier)
101+
(mon : is-monotone f)
102+
is-directed-family P s
103+
is-directed-family Q (f ∘ s)
104+
monotone∘directed f mon dir .is-directed-family.elt = dir .is-directed-family.elt
105+
monotone∘directed f mon dir .is-directed-family.semidirected i j =
106+
let k , p = dir .is-directed-family.semidirected i j
107+
in k , mon .is-monotone.monotone (proj₁ p) , mon .is-monotone.monotone (proj₂ p)
108+
109+
110+
111+
{-module _ where
112+
open import Relation.Binary.Bundles using (Poset)
113+
open import Function using (_∘_)
114+
115+
private
116+
module P {o ℓ₁ ℓ₂} (P : Poset o ℓ₁ ℓ₂) = Poset P
117+
module Q {o ℓ₁ ℓ₂} (Q : Poset o ℓ₁ ℓ₂) = Poset Q
118+
module R {o ℓ₁ ℓ₂} (R : Poset o ℓ₁ ℓ₂) = Poset R
119+
120+
scott-id : ∀ {o ℓ₁ ℓ₂} {P : Poset o ℓ₁ ℓ₂}
121+
→ is-scott-continuous (id {A = Poset.Carrier P})
122+
scott-id = record
123+
{ monotone = record { monotone = λ {x} {y} z → x }
124+
; preserve-lub = λ {Ix} {g} df dlub → dlub
125+
}
126+
127+
scott-∘
128+
: ∀ {o ℓ₁ ℓ₂} {P Q R : Poset o ℓ₁ ℓ₂}
129+
→ (f : Q.Carrier Q → R.Carrier R) (g : P.Carrier P → Q.Carrier Q)
130+
→ is-scott-continuous f → is-scott-continuous g
131+
→ is-scott-continuous (f ∘ g)
132+
scott-∘ {P = P} {Q} {R} f g f-scott g-scott s dir x lub =
133+
f-scott (g ∘ s)
134+
(monotone∘directed g (is-scott-continuous.monotone g-scott) dir)
135+
(g x)
136+
(g-scott s dir x lub)-}

0 commit comments

Comments
 (0)