Debian Codegraph @

src/Relation/Binary/Lattice/Bundles.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Bundles for order-theoretic lattices
5 ------------------------------------------------------------------------
6
7 -- The contents of this module should be accessed via
8 -- `Relation.Binary.Lattice`.
9
10 {-# OPTIONS --cubical-compatible --safe #-}
11
12 module Relation.Binary.Lattice.Bundles where
13
14 open import Algebra.Core using (Op₁; Op₂)
15 open import Level using (suc; _⊔_)
16 open import Relation.Binary.Core using (Rel)
17 open import Relation.Binary.Bundles using (Poset; Setoid)
18 open import Relation.Binary.Lattice.Structures
19
20 ------------------------------------------------------------------------
21 -- Join semilattices
22
23 record JoinSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
24 infix 4 _≈_ _≤_
25 infixr 6 _∨_
26 field
27 Carrier : Set c
28 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
29 _≤_ : Rel Carrier ℓ₂ -- The partial order.
30 _∨_ : Op₂ Carrier -- The join operation.
31 isJoinSemilattice : IsJoinSemilattice _≈_ _≤_ _∨_
32
33 open IsJoinSemilattice isJoinSemilattice public
34
35 poset : Poset c ℓ₁ ℓ₂
36 poset = record { isPartialOrder = isPartialOrder }
37
38 open Poset poset public using (preorder)
39
40
41 record BoundedJoinSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
42 infix 4 _≈_ _≤_
43 infixr 6 _∨_
44 field
45 Carrier : Set c
46 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
47 _≤_ : Rel Carrier ℓ₂ -- The partial order.
48 _∨_ : Op₂ Carrier -- The join operation.
49 ⊥ : Carrier -- The minimum.
50 isBoundedJoinSemilattice : IsBoundedJoinSemilattice _≈_ _≤_ _∨_ ⊥
51
52 open IsBoundedJoinSemilattice isBoundedJoinSemilattice public
53
54 joinSemilattice : JoinSemilattice c ℓ₁ ℓ₂
55 joinSemilattice = record { isJoinSemilattice = isJoinSemilattice }
56
57 open JoinSemilattice joinSemilattice public using (preorder; poset)
58
59 ------------------------------------------------------------------------
60 -- Meet semilattices
61
62 record MeetSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
63 infix 4 _≈_ _≤_
64 infixr 7 _∧_
65 field
66 Carrier : Set c
67 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
68 _≤_ : Rel Carrier ℓ₂ -- The partial order.
69 _∧_ : Op₂ Carrier -- The meet operation.
70 isMeetSemilattice : IsMeetSemilattice _≈_ _≤_ _∧_
71
72 open IsMeetSemilattice isMeetSemilattice public
73
74 poset : Poset c ℓ₁ ℓ₂
75 poset = record { isPartialOrder = isPartialOrder }
76
77 open Poset poset public using (preorder)
78
79 record BoundedMeetSemilattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
80 infix 4 _≈_ _≤_
81 infixr 7 _∧_
82 field
83 Carrier : Set c
84 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
85 _≤_ : Rel Carrier ℓ₂ -- The partial order.
86 _∧_ : Op₂ Carrier -- The join operation.
87 ⊤ : Carrier -- The maximum.
88 isBoundedMeetSemilattice : IsBoundedMeetSemilattice _≈_ _≤_ _∧_ ⊤
89
90 open IsBoundedMeetSemilattice isBoundedMeetSemilattice public
91
92 meetSemilattice : MeetSemilattice c ℓ₁ ℓ₂
93 meetSemilattice = record { isMeetSemilattice = isMeetSemilattice }
94
95 open MeetSemilattice meetSemilattice public using (preorder; poset)
96
97 ------------------------------------------------------------------------
98 -- Lattices
99
100 record Lattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
101 infix 4 _≈_ _≤_
102 infixr 6 _∨_
103 infixr 7 _∧_
104 field
105 Carrier : Set c
106 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
107 _≤_ : Rel Carrier ℓ₂ -- The partial order.
108 _∨_ : Op₂ Carrier -- The join operation.
109 _∧_ : Op₂ Carrier -- The meet operation.
110 isLattice : IsLattice _≈_ _≤_ _∨_ _∧_
111
112 open IsLattice isLattice public
113
114 setoid : Setoid c ℓ₁
115 setoid = record { isEquivalence = isEquivalence }
116
117 joinSemilattice : JoinSemilattice c ℓ₁ ℓ₂
118 joinSemilattice = record { isJoinSemilattice = isJoinSemilattice }
119
120 meetSemilattice : MeetSemilattice c ℓ₁ ℓ₂
121 meetSemilattice = record { isMeetSemilattice = isMeetSemilattice }
122
123 open JoinSemilattice joinSemilattice public using (poset; preorder)
124
125 record DistributiveLattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
126 infix 4 _≈_ _≤_
127 infixr 6 _∨_
128 infixr 7 _∧_
129 field
130 Carrier : Set c
131 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
132 _≤_ : Rel Carrier ℓ₂ -- The partial order.
133 _∨_ : Op₂ Carrier -- The join operation.
134 _∧_ : Op₂ Carrier -- The meet operation.
135 isDistributiveLattice : IsDistributiveLattice _≈_ _≤_ _∨_ _∧_
136
137 open IsDistributiveLattice isDistributiveLattice using (∧-distribˡ-∨) public
138 open IsDistributiveLattice isDistributiveLattice using (isLattice)
139
140 lattice : Lattice c ℓ₁ ℓ₂
141 lattice = record { isLattice = isLattice }
142
143 open Lattice lattice hiding (Carrier; _≈_; _≤_; _∨_; _∧_) public
144
145 record BoundedLattice c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
146 infix 4 _≈_ _≤_
147 infixr 6 _∨_
148 infixr 7 _∧_
149 field
150 Carrier : Set c
151 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
152 _≤_ : Rel Carrier ℓ₂ -- The partial order.
153 _∨_ : Op₂ Carrier -- The join operation.
154 _∧_ : Op₂ Carrier -- The meet operation.
155 ⊤ : Carrier -- The maximum.
156 ⊥ : Carrier -- The minimum.
157 isBoundedLattice : IsBoundedLattice _≈_ _≤_ _∨_ _∧_ ⊤ ⊥
158
159 open IsBoundedLattice isBoundedLattice public
160
161 boundedJoinSemilattice : BoundedJoinSemilattice c ℓ₁ ℓ₂
162 boundedJoinSemilattice = record
163 { isBoundedJoinSemilattice = isBoundedJoinSemilattice }
164
165 boundedMeetSemilattice : BoundedMeetSemilattice c ℓ₁ ℓ₂
166 boundedMeetSemilattice = record
167 { isBoundedMeetSemilattice = isBoundedMeetSemilattice }
168
169 lattice : Lattice c ℓ₁ ℓ₂
170 lattice = record { isLattice = isLattice }
171
172 open Lattice lattice public
173 using (joinSemilattice; meetSemilattice; poset; preorder; setoid)
174
175 ------------------------------------------------------------------------
176 -- Heyting algebras (a bounded lattice with exponential operator)
177
178 record HeytingAlgebra c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
179 infix 4 _≈_ _≤_
180 infixr 5 _⇨_
181 infixr 6 _∨_
182 infixr 7 _∧_
183 field
184 Carrier : Set c
185 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
186 _≤_ : Rel Carrier ℓ₂ -- The partial order.
187 _∨_ : Op₂ Carrier -- The join operation.
188 _∧_ : Op₂ Carrier -- The meet operation.
189 _⇨_ : Op₂ Carrier -- The exponential operation.
190 ⊤ : Carrier -- The maximum.
191 ⊥ : Carrier -- The minimum.
192 isHeytingAlgebra : IsHeytingAlgebra _≈_ _≤_ _∨_ _∧_ _⇨_ ⊤ ⊥
193
194 boundedLattice : BoundedLattice c ℓ₁ ℓ₂
195 boundedLattice = record
196 { isBoundedLattice = IsHeytingAlgebra.isBoundedLattice isHeytingAlgebra }
197
198 open IsHeytingAlgebra isHeytingAlgebra
199 using (exponential; transpose-⇨; transpose-∧) public
200 open BoundedLattice boundedLattice
201 hiding (Carrier; _≈_; _≤_; _∨_; _∧_; ⊤; ⊥) public
202
203 ------------------------------------------------------------------------
204 -- Boolean algebras (a specialized Heyting algebra)
205
206 record BooleanAlgebra c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
207 infix 4 _≈_ _≤_
208 infixr 6 _∨_
209 infixr 7 _∧_
210 infix 8 ¬_
211 field
212 Carrier : Set c
213 _≈_ : Rel Carrier ℓ₁ -- The underlying equality.
214 _≤_ : Rel Carrier ℓ₂ -- The partial order.
215 _∨_ : Op₂ Carrier -- The join operation.
216 _∧_ : Op₂ Carrier -- The meet operation.
217 ¬_ : Op₁ Carrier -- The negation operation.
218 ⊤ : Carrier -- The maximum.
219 ⊥ : Carrier -- The minimum.
220 isBooleanAlgebra : IsBooleanAlgebra _≈_ _≤_ _∨_ _∧_ ¬_ ⊤ ⊥
221
222 open IsBooleanAlgebra isBooleanAlgebra using (isHeytingAlgebra)
223
224 heytingAlgebra : HeytingAlgebra c ℓ₁ ℓ₂
225 heytingAlgebra = record { isHeytingAlgebra = isHeytingAlgebra }
226
227 open HeytingAlgebra heytingAlgebra public
228 hiding (Carrier; _≈_; _≤_; _∨_; _∧_; ⊤; ⊥)