Add a lattice instance for Map
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
40
Lattice.agda
40
Lattice.agda
@@ -42,7 +42,7 @@ record IsLattice {a} (A : Set a)
|
||||
absorb-⊓-⊔ : (x y : A) → (x ⊓ (x ⊔ y)) ≈ x
|
||||
|
||||
open IsSemilattice joinSemilattice public
|
||||
open IsSemilattice meetSemilattice public renaming
|
||||
open IsSemilattice meetSemilattice public hiding (≈-equiv; ≈-refl; ≈-sym; ≈-trans) renaming
|
||||
( ⊔-assoc to ⊓-assoc
|
||||
; ⊔-comm to ⊓-comm
|
||||
; ⊔-idemp to ⊓-idemp
|
||||
@@ -350,3 +350,41 @@ module IsLatticeInstances where
|
||||
; absorb-⊔-⊓ = absorb-⊔-⊓
|
||||
; absorb-⊓-⊔ = absorb-⊓-⊔
|
||||
}
|
||||
|
||||
module ForMap {a} {A B : Set a}
|
||||
(≡-dec-A : Decidable (_≡_ {a} {A}))
|
||||
(_≈₂_ : B → B → Set a)
|
||||
(_⊔₂_ : B → B → B)
|
||||
(_⊓₂_ : B → B → B)
|
||||
(lB : IsLattice B _≈₂_ _⊔₂_ _⊓₂_) where
|
||||
|
||||
open import Map A B ≡-dec-A
|
||||
open IsLattice lB renaming
|
||||
( ≈-refl to ≈₂-refl; ≈-sym to ≈₂-sym
|
||||
; ⊔-idemp to ⊔₂-idemp; ⊓-idemp to ⊓₂-idemp
|
||||
; absorb-⊔-⊓ to absorb-⊔₂-⊓₂; absorb-⊓-⊔ to absorb-⊓₂-⊔₂
|
||||
)
|
||||
|
||||
private
|
||||
module MapJoin = IsSemilatticeInstances.ForMap ≡-dec-A _≈₂_ _⊔₂_ (IsLattice.joinSemilattice lB)
|
||||
module MapMeet = IsSemilatticeInstances.ForMap ≡-dec-A _≈₂_ _⊓₂_ (IsLattice.meetSemilattice lB)
|
||||
|
||||
infix 4 _≈_
|
||||
infixl 20 _⊔_
|
||||
|
||||
_≈_ : Map → Map → Set a
|
||||
_≈_ = lift (_≈₂_)
|
||||
|
||||
_⊔_ : Map → Map → Map
|
||||
m₁ ⊔ m₂ = union _⊔₂_ m₁ m₂
|
||||
|
||||
_⊓_ : Map → Map → Map
|
||||
m₁ ⊓ m₂ = intersect _⊓₂_ m₁ m₂
|
||||
|
||||
MapIsLattice : IsLattice Map _≈_ _⊔_ _⊓_
|
||||
MapIsLattice = record
|
||||
{ joinSemilattice = MapJoin.MapIsUnionSemilattice
|
||||
; meetSemilattice = MapMeet.MapIsIntersectSemilattice
|
||||
; absorb-⊔-⊓ = union-intersect-absorb _≈₂_ ≈₂-refl ≈₂-sym _⊔₂_ _⊓₂_ ⊔₂-idemp ⊓₂-idemp absorb-⊔₂-⊓₂ absorb-⊓₂-⊔₂
|
||||
; absorb-⊓-⊔ = intersect-union-absorb _≈₂_ ≈₂-refl ≈₂-sym _⊔₂_ _⊓₂_ ⊔₂-idemp ⊓₂-idemp absorb-⊔₂-⊓₂ absorb-⊓₂-⊔₂
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user