Switch maps (and consequently most of the code) to using instances
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
@@ -79,8 +79,9 @@ data _≈_ : AboveBelow → AboveBelow → Set a where
|
||||
≈-dec [ x ] ⊥ = no λ ()
|
||||
≈-dec [ x ] ⊤ = no λ ()
|
||||
|
||||
≈-Decidable : IsDecidable _≈_
|
||||
≈-Decidable = record { R-dec = ≈-dec }
|
||||
instance
|
||||
≈-Decidable : IsDecidable _≈_
|
||||
≈-Decidable = record { R-dec = ≈-dec }
|
||||
|
||||
-- Any object can be wrapped in an 'above below' to make it a lattice,
|
||||
-- since ⊤ and ⊥ are the largest and least elements, and the rest are left
|
||||
@@ -175,14 +176,15 @@ module Plain (x : A) where
|
||||
⊔-idemp ⊥ = ≈-⊥-⊥
|
||||
⊔-idemp [ x ] rewrite x≈y⇒[x]⊔[y]≡[x] (≈₁-refl {x}) = ≈-refl
|
||||
|
||||
isJoinSemilattice : IsSemilattice AboveBelow _≈_ _⊔_
|
||||
isJoinSemilattice = record
|
||||
{ ≈-equiv = ≈-equiv
|
||||
; ≈-⊔-cong = ≈-⊔-cong
|
||||
; ⊔-assoc = ⊔-assoc
|
||||
; ⊔-comm = ⊔-comm
|
||||
; ⊔-idemp = ⊔-idemp
|
||||
}
|
||||
instance
|
||||
isJoinSemilattice : IsSemilattice AboveBelow _≈_ _⊔_
|
||||
isJoinSemilattice = record
|
||||
{ ≈-equiv = ≈-equiv
|
||||
; ≈-⊔-cong = ≈-⊔-cong
|
||||
; ⊔-assoc = ⊔-assoc
|
||||
; ⊔-comm = ⊔-comm
|
||||
; ⊔-idemp = ⊔-idemp
|
||||
}
|
||||
|
||||
_⊓_ : AboveBelow → AboveBelow → AboveBelow
|
||||
⊥ ⊓ x = ⊥
|
||||
@@ -268,14 +270,15 @@ module Plain (x : A) where
|
||||
⊓-idemp ⊤ = ≈-⊤-⊤
|
||||
⊓-idemp [ x ] rewrite x≈y⇒[x]⊓[y]≡[x] (≈₁-refl {x}) = ≈-refl
|
||||
|
||||
isMeetSemilattice : IsSemilattice AboveBelow _≈_ _⊓_
|
||||
isMeetSemilattice = record
|
||||
{ ≈-equiv = ≈-equiv
|
||||
; ≈-⊔-cong = ≈-⊓-cong
|
||||
; ⊔-assoc = ⊓-assoc
|
||||
; ⊔-comm = ⊓-comm
|
||||
; ⊔-idemp = ⊓-idemp
|
||||
}
|
||||
instance
|
||||
isMeetSemilattice : IsSemilattice AboveBelow _≈_ _⊓_
|
||||
isMeetSemilattice = record
|
||||
{ ≈-equiv = ≈-equiv
|
||||
; ≈-⊔-cong = ≈-⊓-cong
|
||||
; ⊔-assoc = ⊓-assoc
|
||||
; ⊔-comm = ⊓-comm
|
||||
; ⊔-idemp = ⊓-idemp
|
||||
}
|
||||
|
||||
absorb-⊔-⊓ : ∀ (ab₁ ab₂ : AboveBelow) → (ab₁ ⊔ (ab₁ ⊓ ab₂)) ≈ ab₁
|
||||
absorb-⊔-⊓ ⊥ ab₂ rewrite ⊥⊓x≡⊥ ab₂ = ≈-⊥-⊥
|
||||
@@ -300,21 +303,22 @@ module Plain (x : A) where
|
||||
... | no x̷≈y rewrite x̷≈y⇒[x]⊔[y]≡⊤ x̷≈y rewrite x⊓⊤≡x [ x ] = ≈-refl
|
||||
|
||||
|
||||
isLattice : IsLattice AboveBelow _≈_ _⊔_ _⊓_
|
||||
isLattice = record
|
||||
{ joinSemilattice = isJoinSemilattice
|
||||
; meetSemilattice = isMeetSemilattice
|
||||
; absorb-⊔-⊓ = absorb-⊔-⊓
|
||||
; absorb-⊓-⊔ = absorb-⊓-⊔
|
||||
}
|
||||
instance
|
||||
isLattice : IsLattice AboveBelow _≈_ _⊔_ _⊓_
|
||||
isLattice = record
|
||||
{ joinSemilattice = isJoinSemilattice
|
||||
; meetSemilattice = isMeetSemilattice
|
||||
; absorb-⊔-⊓ = absorb-⊔-⊓
|
||||
; absorb-⊓-⊔ = absorb-⊓-⊔
|
||||
}
|
||||
|
||||
lattice : Lattice AboveBelow
|
||||
lattice = record
|
||||
{ _≈_ = _≈_
|
||||
; _⊔_ = _⊔_
|
||||
; _⊓_ = _⊓_
|
||||
; isLattice = isLattice
|
||||
}
|
||||
lattice : Lattice AboveBelow
|
||||
lattice = record
|
||||
{ _≈_ = _≈_
|
||||
; _⊔_ = _⊔_
|
||||
; _⊓_ = _⊓_
|
||||
; isLattice = isLattice
|
||||
}
|
||||
|
||||
open IsLattice isLattice using (_≼_; _≺_; ⊔-Monotonicˡ; ⊔-Monotonicʳ) public
|
||||
|
||||
@@ -360,25 +364,26 @@ module Plain (x : A) where
|
||||
isLongest {⊥} (step {_} {[ x ]} _ (≈-lift _) (step [x]≺y y≈z c@(step _ _ _)))
|
||||
rewrite [x]≺y⇒y≡⊤ _ _ [x]≺y with ≈-⊤-⊤ ← y≈z = ⊥-elim (¬-Chain-⊤ c)
|
||||
|
||||
fixedHeight : IsLattice.FixedHeight isLattice 2
|
||||
fixedHeight = record
|
||||
{ ⊥ = ⊥
|
||||
; ⊤ = ⊤
|
||||
; longestChain = longestChain
|
||||
; bounded = isLongest
|
||||
}
|
||||
instance
|
||||
fixedHeight : IsLattice.FixedHeight isLattice 2
|
||||
fixedHeight = record
|
||||
{ ⊥ = ⊥
|
||||
; ⊤ = ⊤
|
||||
; longestChain = longestChain
|
||||
; bounded = isLongest
|
||||
}
|
||||
|
||||
isFiniteHeightLattice : IsFiniteHeightLattice AboveBelow 2 _≈_ _⊔_ _⊓_
|
||||
isFiniteHeightLattice = record
|
||||
{ isLattice = isLattice
|
||||
; fixedHeight = fixedHeight
|
||||
}
|
||||
isFiniteHeightLattice : IsFiniteHeightLattice AboveBelow 2 _≈_ _⊔_ _⊓_
|
||||
isFiniteHeightLattice = record
|
||||
{ isLattice = isLattice
|
||||
; fixedHeight = fixedHeight
|
||||
}
|
||||
|
||||
finiteHeightLattice : FiniteHeightLattice AboveBelow
|
||||
finiteHeightLattice = record
|
||||
{ height = 2
|
||||
; _≈_ = _≈_
|
||||
; _⊔_ = _⊔_
|
||||
; _⊓_ = _⊓_
|
||||
; isFiniteHeightLattice = isFiniteHeightLattice
|
||||
}
|
||||
finiteHeightLattice : FiniteHeightLattice AboveBelow
|
||||
finiteHeightLattice = record
|
||||
{ height = 2
|
||||
; _≈_ = _≈_
|
||||
; _⊔_ = _⊔_
|
||||
; _⊓_ = _⊓_
|
||||
; isFiniteHeightLattice = isFiniteHeightLattice
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user