2
module SemiLattice where
5
open import PartialOrder as PO
10
{A : Set}(po : PartialOrder A)(_⊓_ : A -> A -> A) where
11
private open module PO = PartialOrder po
13
record IsSemiLattice : Set where
15
⊓-lbL : forall {x y} -> (x ⊓ y) ≤ x
16
⊓-lbR : forall {x y} -> (x ⊓ y) ≤ y
17
⊓-glb : forall {x y z} -> z ≤ x -> z ≤ y -> z ≤ (x ⊓ y)
21
record SemiLattice (A : Set) : Set1 where
25
prf : IsSemiLattice po _⊓_
27
module SemiLat {A : Set}(L : SemiLattice A) where
29
private module SL = SemiLattice L
30
private module SLPO = POrder SL.po
31
private module IsSL = IsSemiLattice SL.po SL._⊓_ SL.prf
34
open SL public hiding (prf)
37
private open module C≤ = Chain _≤_ (\x -> ≤-refl) (\x y z -> ≤-trans)
38
renaming (_===_ to _-≤-_; chain>_ to trans>_)
40
⊓-commute : forall {x y} -> (x ⊓ y) == (y ⊓ x)
41
⊓-commute = ≤-antisym lem lem
43
lem : forall {x y} -> (x ⊓ y) ≤ (y ⊓ x)
44
lem = ⊓-glb ⊓-lbR ⊓-lbL
46
⊓-assoc : forall {x y z} -> (x ⊓ (y ⊓ z)) == ((x ⊓ y) ⊓ z)
47
⊓-assoc = ≤-antisym lem₁ lem₂
49
lem₁ : forall {x y z} -> (x ⊓ (y ⊓ z)) ≤ ((x ⊓ y) ⊓ z)
50
lem₁ = ⊓-glb (⊓-glb ⊓-lbL (≤-trans ⊓-lbR ⊓-lbL))
53
lem₂ : forall {x y z} -> ((x ⊓ y) ⊓ z) ≤ (x ⊓ (y ⊓ z))
54
lem₂ = ⊓-glb (≤-trans ⊓-lbL ⊓-lbL)
55
(⊓-glb (≤-trans ⊓-lbL ⊓-lbR) ⊓-lbR)
57
⊓-idem : forall {x} -> (x ⊓ x) == x
58
⊓-idem = ≤-antisym ⊓-lbL (⊓-glb ≤-refl ≤-refl)
60
≤⊓-L : forall {x y} -> (x ≤ y) ⇐⇒ ((x ⊓ y) == x)
63
fwd = \x≤y -> ≤-antisym ⊓-lbL (⊓-glb ≤-refl x≤y)
64
bwd = \x⊓y=x -> ≤-trans (==≤-R x⊓y=x) ⊓-lbR
66
≤⊓-R : forall {x y} -> (y ≤ x) ⇐⇒ ((x ⊓ y) == y)
67
≤⊓-R {x}{y} = (fwd , bwd)
69
lem : (y ≤ x) ⇐⇒ ((y ⊓ x) == y)
72
fwd = \y≤x -> ==-trans ⊓-commute (fst lem y≤x)
73
bwd = \x⊓y=y -> snd lem (==-trans ⊓-commute x⊓y=y)
75
⊓-monotone-R : forall {a} -> Monotone (\x -> a ⊓ x)
76
⊓-monotone-R x≤y = ⊓-glb ⊓-lbL (≤-trans ⊓-lbR x≤y)
78
⊓-monotone-L : forall {a} -> Monotone (\x -> x ⊓ a)
79
⊓-monotone-L {a}{x}{y} x≤y =
81
-≤- a ⊓ x by ==≤-L ⊓-commute
82
-≤- a ⊓ y by ⊓-monotone-R x≤y
83
-≤- y ⊓ a by ==≤-L ⊓-commute
85
≤⊓-compat : forall {w x y z} -> w ≤ y -> x ≤ z -> (w ⊓ x) ≤ (y ⊓ z)
86
≤⊓-compat {w}{x}{y}{z} w≤y x≤z =
88
-≤- w ⊓ z by ⊓-monotone-R x≤z
89
-≤- y ⊓ z by ⊓-monotone-L w≤y
91
⊓-cong : forall {w x y z} -> w == y -> x == z -> (w ⊓ x) == (y ⊓ z)
92
⊓-cong wy xz = ≤-antisym (≤⊓-compat (==≤-L wy) (==≤-L xz))
93
(≤⊓-compat (==≤-R wy) (==≤-R xz))
95
⊓-cong-L : forall {x y z} -> x == y -> (x ⊓ z) == (y ⊓ z)
96
⊓-cong-L xy = ⊓-cong xy ==-refl
98
⊓-cong-R : forall {x y z} -> x == y -> (z ⊓ x) == (z ⊓ y)
99
⊓-cong-R xy = ⊓-cong ==-refl xy