Skip to content

Commit beae48a

Browse files
committed
[ new ] add properties of algebraic semilattices and update dependencies.
1 parent 8467abe commit beae48a

File tree

6 files changed

+201
-77
lines changed

6 files changed

+201
-77
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Splitting up `Data.Maybe` into the standard hierarchy.
6161
* The record `BooleanAlgebra` now exports `∨-isSemigroup`, `∧-isSemigroup`
6262
directly so `Algebra.Properties.BooleanAlgebra` no longer does so.
6363

64+
* The proof that every algebraic lattice induces a partial order has been
65+
moved from `Algebra.Properties.Lattice` to
66+
`Algebra.Properties.Semilattice`. The corresponding `poset` instance is
67+
re-exported in `Algebra.Properties.Lattice`.
68+
6469
#### Relaxation of ring solvers requirements
6570

6671
* In the ring solvers below, the assumption that equality is `Decidable`
@@ -90,6 +95,8 @@ Splitting up `Data.Maybe` into the standard hierarchy.
9095
Other major changes
9196
-------------------
9297

98+
* Added new module `Algebra.Properties.Semilattice`
99+
93100
* Added new module `Algebra.FunctionProperties.Consequences.Propositional`
94101

95102
* Added new module `Codata.Cowriter`
@@ -123,6 +130,14 @@ Other minor additions
123130
wlog : Commutative f → Total _R_ → (∀ a b → a R b → P (f a b)) → ∀ a b → P (f a b)
124131
```
125132

133+
* Added new proofs to `Algebra.Properties.Lattice`:
134+
```agda
135+
∧-isSemilattice : IsSemilattice _≈_ _∧_
136+
∧-semilattice : Semilattice l₁ l₂
137+
∨-isSemilattice : IsSemilattice _≈_ _∨_
138+
∨-semilattice : Semilattice l₁ l₂
139+
```
140+
126141
* Added new operator to `Algebra.Solver.Ring`.
127142
```agda
128143
_:×_

src/Algebra/Properties/Lattice.agda

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Algebra.Properties.Lattice {l₁ l₂} (L : Lattice l₁ l₂) where
1111
open Lattice L
1212
open import Algebra.Structures
1313
open import Algebra.FunctionProperties _≈_
14+
import Algebra.Properties.Semilattice as SL
1415
open import Relation.Binary
1516
import Relation.Binary.Lattice as R
1617
open import Relation.Binary.EqReasoning setoid
@@ -19,6 +20,9 @@ open import Function.Equality using (_⟨$⟩_)
1920
open import Function.Equivalence using (_⇔_; module Equivalence)
2021
open import Data.Product using (_,_; swap)
2122

23+
------------------------------------------------------------------------
24+
-- Every lattice contains two semilattices.
25+
2226
∧-idempotent : Idempotent _∧_
2327
∧-idempotent x = begin
2428
x ∧ x ≈⟨ refl ⟨ ∧-cong ⟩ sym (∨-absorbs-∧ _ _) ⟩
@@ -31,6 +35,45 @@ open import Data.Product using (_,_; swap)
3135
x ∨ x ∧ x ≈⟨ ∨-absorbs-∧ _ _ ⟩
3236
x ∎
3337

38+
∧-isSemilattice : IsSemilattice _≈_ _∧_
39+
∧-isSemilattice = record
40+
{ isBand = record
41+
{ isSemigroup = record
42+
{ isMagma = record
43+
{ isEquivalence = isEquivalence
44+
; ∙-cong = ∧-cong
45+
}
46+
; assoc = ∧-assoc
47+
}
48+
; idem = ∧-idempotent
49+
}
50+
; comm = ∧-comm
51+
}
52+
53+
∧-semilattice : Semilattice l₁ l₂
54+
∧-semilattice = record { isSemilattice = ∧-isSemilattice }
55+
56+
∨-isSemilattice : IsSemilattice _≈_ _∨_
57+
∨-isSemilattice = record
58+
{ isBand = record
59+
{ isSemigroup = record
60+
{ isMagma = record
61+
{ isEquivalence = isEquivalence
62+
; ∙-cong = ∨-cong
63+
}
64+
; assoc = ∨-assoc
65+
}
66+
; idem = ∨-idempotent
67+
}
68+
; comm = ∨-comm
69+
}
70+
71+
∨-semilattice : Semilattice l₁ l₂
72+
∨-semilattice = record { isSemilattice = ∨-isSemilattice }
73+
74+
open SL ∧-semilattice public using (poset)
75+
open Poset poset using (_≤_; isPartialOrder)
76+
3477
------------------------------------------------------------------------
3578
-- The dual construction is also a lattice.
3679

@@ -49,88 +92,43 @@ open import Data.Product using (_,_; swap)
4992
∧-∨-lattice : Lattice _ _
5093
∧-∨-lattice = record { isLattice = ∧-∨-isLattice }
5194

52-
------------------------------------------------------------------------
53-
-- Every lattice can be turned into a poset.
54-
55-
poset : Poset _ _ _
56-
poset = record
57-
{ Carrier = Carrier
58-
; _≈_ = _≈_
59-
; _≤_ = λ x y x ≈ x ∧ y
60-
; isPartialOrder = record
61-
{ isPreorder = record
62-
{ isEquivalence = isEquivalence
63-
; reflexive = λ {i} {j} i≈j begin
64-
i ≈⟨ sym $ ∧-idempotent _ ⟩
65-
i ∧ i ≈⟨ ∧-cong refl i≈j ⟩
66-
i ∧ j ∎
67-
; trans = λ {i} {j} {k} i≈i∧j j≈j∧k begin
68-
i ≈⟨ i≈i∧j ⟩
69-
i ∧ j ≈⟨ ∧-cong refl j≈j∧k ⟩
70-
i ∧ (j ∧ k) ≈⟨ sym (∧-assoc _ _ _) ⟩
71-
(i ∧ j) ∧ k ≈⟨ ∧-cong (sym i≈i∧j) refl ⟩
72-
i ∧ k ∎
73-
}
74-
; antisym = λ {x} {y} x≈x∧y y≈y∧x begin
75-
x ≈⟨ x≈x∧y ⟩
76-
x ∧ y ≈⟨ ∧-comm _ _ ⟩
77-
y ∧ x ≈⟨ sym y≈y∧x ⟩
78-
y ∎
79-
}
80-
}
81-
82-
open Poset poset using (_≤_; isPartialOrder)
83-
8495
------------------------------------------------------------------------
8596
-- Every algebraic lattice can be turned into an order-theoretic one.
8697

8798
isOrderTheoreticLattice : R.IsLattice _≈_ _≤_ _∨_ _∧_
8899
isOrderTheoreticLattice = record
89100
{ isPartialOrder = isPartialOrder
90-
; supremum = λ x y
91-
sym (∧-absorbs-∨ x y) ,
92-
(begin
93-
y ≈⟨ sym (∧-absorbs-∨ y x) ⟩
94-
y ∧ (y ∨ x) ≈⟨ ∧-cong refl (∨-comm y x) ⟩
95-
y ∧ (x ∨ y) ∎) ,
96-
(λ z x≤z y≤z sound (begin
97-
(x ∨ y) ∨ z ≈⟨ ∨-assoc x y z ⟩
98-
x ∨ (y ∨ z) ≈⟨ ∨-cong refl (complete y≤z) ⟩
99-
x ∨ z ≈⟨ complete x≤z ⟩
100-
z ∎))
101-
; infimum = λ x y
102-
(begin
103-
x ∧ y ≈⟨ ∧-cong (sym (∧-idempotent x)) refl ⟩
104-
(x ∧ x) ∧ y ≈⟨ ∧-assoc x x y ⟩
105-
x ∧ (x ∧ y) ≈⟨ ∧-comm x (x ∧ y) ⟩
106-
(x ∧ y) ∧ x ∎) ,
107-
(begin
108-
x ∧ y ≈⟨ ∧-cong refl (sym (∧-idempotent y)) ⟩
109-
x ∧ (y ∧ y) ≈⟨ sym (∧-assoc x y y) ⟩
110-
(x ∧ y) ∧ y ∎) ,
111-
(λ z z≈z∧x z≈z∧y begin
112-
z ≈⟨ z≈z∧y ⟩
113-
z ∧ y ≈⟨ ∧-cong z≈z∧x refl ⟩
114-
(z ∧ x) ∧ y ≈⟨ ∧-assoc z x y ⟩
115-
z ∧ (x ∧ y) ∎)
101+
; supremum = supremum
102+
; infimum = infimum
116103
}
117104
where
105+
∧-meetSemilattice = SL.orderTheoreticMeetSemilattice ∧-semilattice
106+
∨-joinSemilattice = SL.orderTheoreticJoinSemilattice ∨-semilattice
107+
open R.MeetSemilattice ∧-meetSemilattice using (infimum)
108+
open R.JoinSemilattice ∨-joinSemilattice using ()
109+
renaming (supremum to supremum′; _≤_ to _≤′_)
118110

119111
-- An alternative but equivalent interpretation of the order _≤_.
120112

121-
complete : {x y} x ≤ y x ∨ y ≈ y
122-
complete {x} {y} x≈x∧y = begin
123-
x ∨ y ≈⟨ ∨-cong x≈x∧y refl ⟩
124-
(x ∧ y) ∨ y ≈⟨ ∨-cong (∧-comm x y) refl ⟩
125-
(y ∧ x) ∨ y ≈⟨ ∨-comm (y ∧ x) y ⟩
113+
sound : {x y} x ≤′ y x ≤ y
114+
sound {x} {y} y≈y∨x = sym $ begin
115+
x ∧ y ≈⟨ ∧-cong refl y≈y∨x ⟩
116+
x ∧ (y ∨ x) ≈⟨ ∧-cong refl (∨-comm y x) ⟩
117+
x ∧ (x ∨ y) ≈⟨ ∧-absorbs-∨ x y ⟩
118+
x ∎
119+
120+
complete : {x y} x ≤ y x ≤′ y
121+
complete {x} {y} x≈x∧y = sym $ begin
122+
y ∨ x ≈⟨ ∨-cong refl x≈x∧y ⟩
123+
y ∨ (x ∧ y) ≈⟨ ∨-cong refl (∧-comm x y) ⟩
126124
y ∨ (y ∧ x) ≈⟨ ∨-absorbs-∧ y x ⟩
127125
y ∎
128126

129-
sound : {x y} x ∨ y ≈ y x ≤ y
130-
sound {x} {y} x∨y≈y = begin
131-
x ≈⟨ sym (∧-absorbs-∨ x y) ⟩
132-
x ∧ (x ∨ y) ≈⟨ ∧-cong refl x∨y≈y ⟩
133-
x ∧ y ∎
127+
supremum : R.Supremum _≤_ _∨_
128+
supremum x y =
129+
let x∨y≥x , x∨y≥y , greatest = supremum′ x y
130+
in sound x∨y≥x , sound x∨y≥y ,
131+
λ z x≤z y≤z sound (greatest z (complete x≤z) (complete y≤z))
134132

135133
orderTheoreticLattice : R.Lattice _ _ _
136134
orderTheoreticLattice = record { isLattice = isOrderTheoreticLattice }
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Some derivable properties
5+
------------------------------------------------------------------------
6+
7+
open import Algebra
8+
9+
module Algebra.Properties.Semilattice {l₁ l₂} (L : Semilattice l₁ l₂) where
10+
11+
open Semilattice L
12+
open import Algebra.Structures
13+
open import Relation.Binary
14+
import Relation.Binary.Lattice as R
15+
import Relation.Binary.Properties.Poset as R
16+
import Relation.Binary.EqReasoning as EqR; open EqR setoid
17+
open import Function
18+
open import Data.Product
19+
20+
-- Every semilattice can be turned into a poset.
21+
22+
poset : Poset _ _ _
23+
poset = record
24+
{ Carrier = Carrier
25+
; _≈_ = _≈_
26+
; _≤_ = λ x y x ≈ x ∧ y
27+
; isPartialOrder = record
28+
{ isPreorder = record
29+
{ isEquivalence = isEquivalence
30+
; reflexive = λ {i} {j} i≈j begin
31+
i ≈⟨ sym $ idem _ ⟩
32+
i ∧ i ≈⟨ ∧-cong refl i≈j ⟩
33+
i ∧ j ∎
34+
; trans = λ {i} {j} {k} i≈i∧j j≈j∧k begin
35+
i ≈⟨ i≈i∧j ⟩
36+
i ∧ j ≈⟨ ∧-cong refl j≈j∧k ⟩
37+
i ∧ (j ∧ k) ≈⟨ sym (assoc _ _ _) ⟩
38+
(i ∧ j) ∧ k ≈⟨ ∧-cong (sym i≈i∧j) refl ⟩
39+
i ∧ k ∎
40+
}
41+
; antisym = λ {x} {y} x≈x∧y y≈y∧x begin
42+
x ≈⟨ x≈x∧y ⟩
43+
x ∧ y ≈⟨ comm _ _ ⟩
44+
y ∧ x ≈⟨ sym y≈y∧x ⟩
45+
y ∎
46+
}
47+
}
48+
49+
open Poset poset using (_≤_; isPartialOrder)
50+
51+
-- Every algebraic semilattice can be turned into an order-theoretic one.
52+
53+
isOrderTheoreticMeetSemilattice : R.IsMeetSemilattice _≈_ _≤_ _∧_
54+
isOrderTheoreticMeetSemilattice = record
55+
{ isPartialOrder = isPartialOrder
56+
; infimum = λ x y
57+
(begin
58+
x ∧ y ≈⟨ ∧-cong (sym (idem x)) refl ⟩
59+
(x ∧ x) ∧ y ≈⟨ assoc x x y ⟩
60+
x ∧ (x ∧ y) ≈⟨ comm x (x ∧ y) ⟩
61+
(x ∧ y) ∧ x ∎) ,
62+
(begin
63+
x ∧ y ≈⟨ ∧-cong refl (sym (idem y)) ⟩
64+
x ∧ (y ∧ y) ≈⟨ sym (assoc x y y) ⟩
65+
(x ∧ y) ∧ y ∎) ,
66+
λ z z≈z∧x z≈z∧y begin
67+
z ≈⟨ z≈z∧y ⟩
68+
z ∧ y ≈⟨ ∧-cong z≈z∧x refl ⟩
69+
(z ∧ x) ∧ y ≈⟨ assoc z x y ⟩
70+
z ∧ (x ∧ y) ∎
71+
}
72+
73+
orderTheoreticMeetSemilattice : R.MeetSemilattice _ _ _
74+
orderTheoreticMeetSemilattice = record
75+
{ isMeetSemilattice = isOrderTheoreticMeetSemilattice }
76+
77+
isOrderTheoreticJoinSemilattice : R.IsJoinSemilattice _≈_ (flip _≤_) _∧_
78+
isOrderTheoreticJoinSemilattice = record
79+
{ isPartialOrder = R.invIsPartialOrder poset
80+
; supremum = R.IsMeetSemilattice.infimum
81+
isOrderTheoreticMeetSemilattice
82+
}
83+
84+
orderTheoreticJoinSemilattice : R.JoinSemilattice _ _ _
85+
orderTheoreticJoinSemilattice = record
86+
{ isJoinSemilattice = isOrderTheoreticJoinSemilattice }

src/Algebra/Structures.agda

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ record IsLattice (∨ ∧ : Op₂ A) : Set (a ⊔ ℓ) where
439439
-- because the idempotence laws of ∨ and ∧ can be derived from the
440440
-- absorption laws, which makes the corresponding "idem" fields
441441
-- redundant. The derived idempotence laws are stated and proved in
442-
-- Algebra.Properties.Lattice.
442+
-- Algebra.Properties.Lattice along with the fact that every lattice
443+
-- consists of two semilattices.
443444

444445
∨-absorbs-∧ : ∨ Absorbs ∧
445446
∨-absorbs-∧ = proj₁ absorptive

src/Relation/Binary/Properties/JoinSemilattice.agda

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module Relation.Binary.Properties.JoinSemilattice
1111

1212
open JoinSemilattice J
1313

14+
import Algebra as Alg
15+
import Algebra.Structures as Alg
1416
import Algebra.FunctionProperties as P; open P _≈_
1517
open import Data.Product
1618
open import Function using (_∘_; flip)
@@ -64,6 +66,26 @@ x≤y⇒x∨y≈y {x} {y} x≤y = antisym
6466
(y≤x∨y _ _)
6567
where open PoR poset
6668

69+
-- Every order-theoretic semilattice can be turned into an algebraic one.
70+
71+
isAlgSemilattice : Alg.IsSemilattice _≈_ _∨_
72+
isAlgSemilattice = record
73+
{ isBand = record
74+
{ isSemigroup = record
75+
{ isMagma = record
76+
{ isEquivalence = isEquivalence
77+
; ∙-cong = ∨-cong
78+
}
79+
; assoc = ∨-assoc
80+
}
81+
; idem = ∨-idempotent
82+
}
83+
; comm = ∨-comm
84+
}
85+
86+
algSemilattice : Alg.Semilattice c ℓ₁
87+
algSemilattice = record { isSemilattice = isAlgSemilattice }
88+
6789
-- The dual construction is a meet semilattice.
6890

6991
dualIsMeetSemilattice : IsMeetSemilattice _≈_ (flip _≤_) _∨_

src/Relation/Binary/Properties/MeetSemilattice.agda

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ dualJoinSemilattice = record
3232
; isJoinSemilattice = dualIsJoinSemilattice
3333
}
3434

35-
open J dualJoinSemilattice public using () renaming
36-
( ∨-monotonic to ∧-monotonic
37-
; ∨-cong to ∧-cong
38-
; ∨-comm to ∧-comm
39-
; ∨-assoc to ∧-assoc
40-
; ∨-idempotent to ∧-idempotent
41-
; x≤y⇒x∨y≈y to y≤x⇒x∧y≈y
42-
)
35+
open J dualJoinSemilattice public
36+
using (isAlgSemilattice; algSemilattice)
37+
renaming
38+
( ∨-monotonic to ∧-monotonic
39+
; ∨-cong to ∧-cong
40+
; ∨-comm to ∧-comm
41+
; ∨-assoc to ∧-assoc
42+
; ∨-idempotent to ∧-idempotent
43+
; x≤y⇒x∨y≈y to y≤x⇒x∧y≈y
44+
)

0 commit comments

Comments
 (0)