| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Definitions of algebraic structures like semilattices and lattices |
| 5 |
-- (packed in records together with sets, operations, etc.), defined via |
| 6 |
-- meet/join operations and their properties |
| 7 |
-- |
| 8 |
-- For lattices defined via an order relation, see |
| 9 |
-- Relation.Binary.Lattice. |
| 10 |
------------------------------------------------------------------------ |
| 11 |
|
| 12 |
-- The contents of this module should be accessed via `Algebra.Lattice`. |
| 13 |
|
| 14 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 15 |
|
| 16 |
module Algebra.Lattice.Bundles where |
| 17 |
|
| 18 |
open import Algebra.Core using (Op₁; Op₂) |
| 19 |
open import Algebra.Bundles using (Band) |
| 20 |
import Algebra.Lattice.Bundles.Raw as Raw |
| 21 |
open import Algebra.Lattice.Structures |
| 22 |
using ( IsSemilattice; IsMeetSemilattice; IsJoinSemilattice |
| 23 |
; IsBoundedSemilattice; IsBoundedMeetSemilattice |
| 24 |
; IsBoundedJoinSemilattice; IsLattice; IsDistributiveLattice |
| 25 |
; IsBooleanAlgebra) |
| 26 |
open import Level using (suc; _⊔_) |
| 27 |
open import Relation.Binary.Bundles using (Setoid) |
| 28 |
open import Relation.Binary.Core using (Rel) |
| 29 |
|
| 30 |
------------------------------------------------------------------------ |
| 31 |
-- Re-export definitions of 'raw' bundles |
| 32 |
|
| 33 |
open Raw public |
| 34 |
using (RawLattice) |
| 35 |
|
| 36 |
------------------------------------------------------------------------ |
| 37 |
-- Bundles |
| 38 |
------------------------------------------------------------------------ |
| 39 |
|
| 40 |
record Semilattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 41 |
infixr 7 _∙_ |
| 42 |
infix 4 _≈_ |
| 43 |
field |
| 44 |
Carrier : Set c |
| 45 |
_≈_ : Rel Carrier ℓ |
| 46 |
_∙_ : Op₂ Carrier |
| 47 |
isSemilattice : IsSemilattice _≈_ _∙_ |
| 48 |
|
| 49 |
open IsSemilattice _≈_ isSemilattice public |
| 50 |
|
| 51 |
band : Band c ℓ |
| 52 |
band = record { isBand = isBand } |
| 53 |
|
| 54 |
open Band band public |
| 55 |
using (_≉_; rawMagma; magma; isMagma; semigroup; isSemigroup; isBand) |
| 56 |
|
| 57 |
|
| 58 |
record MeetSemilattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 59 |
infixr 7 _∧_ |
| 60 |
infix 4 _≈_ |
| 61 |
field |
| 62 |
Carrier : Set c |
| 63 |
_≈_ : Rel Carrier ℓ |
| 64 |
_∧_ : Op₂ Carrier |
| 65 |
isMeetSemilattice : IsSemilattice _≈_ _∧_ |
| 66 |
|
| 67 |
open IsMeetSemilattice _≈_ isMeetSemilattice public |
| 68 |
|
| 69 |
semilattice : Semilattice c ℓ |
| 70 |
semilattice = record { isSemilattice = isMeetSemilattice } |
| 71 |
|
| 72 |
open Semilattice semilattice public |
| 73 |
using (rawMagma; magma; semigroup; band) |
| 74 |
|
| 75 |
|
| 76 |
record JoinSemilattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 77 |
infixr 7 _∨_ |
| 78 |
infix 4 _≈_ |
| 79 |
field |
| 80 |
Carrier : Set c |
| 81 |
_≈_ : Rel Carrier ℓ |
| 82 |
_∨_ : Op₂ Carrier |
| 83 |
isJoinSemilattice : IsSemilattice _≈_ _∨_ |
| 84 |
|
| 85 |
open IsJoinSemilattice _≈_ isJoinSemilattice public |
| 86 |
|
| 87 |
semilattice : Semilattice c ℓ |
| 88 |
semilattice = record { isSemilattice = isJoinSemilattice } |
| 89 |
|
| 90 |
open Semilattice semilattice public |
| 91 |
using (rawMagma; magma; semigroup; band) |
| 92 |
|
| 93 |
|
| 94 |
record BoundedSemilattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 95 |
infixr 7 _∙_ |
| 96 |
infix 4 _≈_ |
| 97 |
field |
| 98 |
Carrier : Set c |
| 99 |
_≈_ : Rel Carrier ℓ |
| 100 |
_∙_ : Op₂ Carrier |
| 101 |
ε : Carrier |
| 102 |
isBoundedSemilattice : IsBoundedSemilattice _≈_ _∙_ ε |
| 103 |
|
| 104 |
open IsBoundedSemilattice _≈_ isBoundedSemilattice public |
| 105 |
|
| 106 |
semilattice : Semilattice c ℓ |
| 107 |
semilattice = record { isSemilattice = isSemilattice } |
| 108 |
|
| 109 |
open Semilattice semilattice public using (rawMagma; magma; semigroup; band) |
| 110 |
|
| 111 |
|
| 112 |
record BoundedMeetSemilattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 113 |
infixr 7 _∧_ |
| 114 |
infix 4 _≈_ |
| 115 |
field |
| 116 |
Carrier : Set c |
| 117 |
_≈_ : Rel Carrier ℓ |
| 118 |
_∧_ : Op₂ Carrier |
| 119 |
⊤ : Carrier |
| 120 |
isBoundedMeetSemilattice : IsBoundedSemilattice _≈_ _∧_ ⊤ |
| 121 |
|
| 122 |
open IsBoundedMeetSemilattice _≈_ isBoundedMeetSemilattice public |
| 123 |
|
| 124 |
boundedSemilattice : BoundedSemilattice c ℓ |
| 125 |
boundedSemilattice = record |
| 126 |
{ isBoundedSemilattice = isBoundedMeetSemilattice } |
| 127 |
|
| 128 |
open BoundedSemilattice boundedSemilattice public |
| 129 |
using (rawMagma; magma; semigroup; band; semilattice) |
| 130 |
|
| 131 |
|
| 132 |
record BoundedJoinSemilattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 133 |
infixr 7 _∨_ |
| 134 |
infix 4 _≈_ |
| 135 |
field |
| 136 |
Carrier : Set c |
| 137 |
_≈_ : Rel Carrier ℓ |
| 138 |
_∨_ : Op₂ Carrier |
| 139 |
⊥ : Carrier |
| 140 |
isBoundedJoinSemilattice : IsBoundedSemilattice _≈_ _∨_ ⊥ |
| 141 |
|
| 142 |
open IsBoundedJoinSemilattice _≈_ isBoundedJoinSemilattice public |
| 143 |
|
| 144 |
boundedSemilattice : BoundedSemilattice c ℓ |
| 145 |
boundedSemilattice = record |
| 146 |
{ isBoundedSemilattice = isBoundedJoinSemilattice } |
| 147 |
|
| 148 |
open BoundedSemilattice boundedSemilattice public |
| 149 |
using (rawMagma; magma; semigroup; band; semilattice) |
| 150 |
|
| 151 |
|
| 152 |
record Lattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 153 |
infixr 7 _∧_ |
| 154 |
infixr 6 _∨_ |
| 155 |
infix 4 _≈_ |
| 156 |
field |
| 157 |
Carrier : Set c |
| 158 |
_≈_ : Rel Carrier ℓ |
| 159 |
_∨_ : Op₂ Carrier |
| 160 |
_∧_ : Op₂ Carrier |
| 161 |
isLattice : IsLattice _≈_ _∨_ _∧_ |
| 162 |
|
| 163 |
open IsLattice isLattice public |
| 164 |
|
| 165 |
rawLattice : RawLattice c ℓ |
| 166 |
rawLattice = record |
| 167 |
{ _≈_ = _≈_ |
| 168 |
; _∧_ = _∧_ |
| 169 |
; _∨_ = _∨_ |
| 170 |
} |
| 171 |
|
| 172 |
open RawLattice rawLattice public |
| 173 |
using (∨-rawMagma; ∧-rawMagma) |
| 174 |
|
| 175 |
setoid : Setoid c ℓ |
| 176 |
setoid = record { isEquivalence = isEquivalence } |
| 177 |
|
| 178 |
open Setoid setoid public |
| 179 |
using (_≉_) |
| 180 |
|
| 181 |
|
| 182 |
record DistributiveLattice c ℓ : Set (suc (c ⊔ ℓ)) where |
| 183 |
infixr 7 _∧_ |
| 184 |
infixr 6 _∨_ |
| 185 |
infix 4 _≈_ |
| 186 |
field |
| 187 |
Carrier : Set c |
| 188 |
_≈_ : Rel Carrier ℓ |
| 189 |
_∨_ : Op₂ Carrier |
| 190 |
_∧_ : Op₂ Carrier |
| 191 |
isDistributiveLattice : IsDistributiveLattice _≈_ _∨_ _∧_ |
| 192 |
|
| 193 |
open IsDistributiveLattice isDistributiveLattice public |
| 194 |
|
| 195 |
lattice : Lattice _ _ |
| 196 |
lattice = record { isLattice = isLattice } |
| 197 |
|
| 198 |
open Lattice lattice public |
| 199 |
using |
| 200 |
( _≉_; setoid; rawLattice |
| 201 |
; ∨-rawMagma; ∧-rawMagma |
| 202 |
) |
| 203 |
|
| 204 |
|
| 205 |
record BooleanAlgebra c ℓ : Set (suc (c ⊔ ℓ)) where |
| 206 |
infix 8 ¬_ |
| 207 |
infixr 7 _∧_ |
| 208 |
infixr 6 _∨_ |
| 209 |
infix 4 _≈_ |
| 210 |
field |
| 211 |
Carrier : Set c |
| 212 |
_≈_ : Rel Carrier ℓ |
| 213 |
_∨_ : Op₂ Carrier |
| 214 |
_∧_ : Op₂ Carrier |
| 215 |
¬_ : Op₁ Carrier |
| 216 |
⊤ : Carrier |
| 217 |
⊥ : Carrier |
| 218 |
isBooleanAlgebra : IsBooleanAlgebra _≈_ _∨_ _∧_ ¬_ ⊤ ⊥ |
| 219 |
|
| 220 |
open IsBooleanAlgebra isBooleanAlgebra public |
| 221 |
|
| 222 |
distributiveLattice : DistributiveLattice _ _ |
| 223 |
distributiveLattice = record |
| 224 |
{ isDistributiveLattice = isDistributiveLattice |
| 225 |
} |
| 226 |
|
| 227 |
open DistributiveLattice distributiveLattice public |
| 228 |
using |
| 229 |
( _≉_; setoid; rawLattice |
| 230 |
; ∨-rawMagma; ∧-rawMagma |
| 231 |
; lattice |
| 232 |
) |