Open
Description
I was expecting that DecTotalOrder
gives me operations to compute the minimum and maximum, but could not find them. (These are declared in the Lattice
hierarchy.)
I think it would make sense to provide standard implementations for these operations using the total
function. I have done this for minimum below.
Question to the architects: How should that be integrated into the current DecTotalOrder
?
------------------------------------------------------------------------
-- Infimum from decidable total order on A.
open import Relation.Binary.Bundles using (DecTotalOrder)
module Infimum {ℓ₁ ℓ₂ ℓ₃} (O : DecTotalOrder ℓ₁ ℓ₂ ℓ₃) where
open import Data.Product using (_,_)
open import Data.Sum using (inj₁; inj₂)
open import Function using (case_of_)
open import Relation.Binary.Lattice.Bundles using (MeetSemilattice)
open import Relation.Binary.Lattice.Definitions using (Infimum)
-- We create a module for record O (with the same name, O).
-- This allows us to use the content of O conveniently
-- when constructing new records.
module O where
open DecTotalOrder O public
_∧_ : (x y : Carrier) → Carrier
x ∧ y = case total x y of λ where
(inj₁ x≤y) → x
(inj₂ y≤x) → y
infimum : Infimum _≤_ _∧_
infimum x y with total x y
... | inj₁ x≤y = refl , x≤y , λ _ z≤x _ → z≤x
... | inj₂ y≤x = y≤x , refl , λ _ _ z≤y → z≤y
meetSemilattice : MeetSemilattice _ _ _
meetSemilattice = record
{ O
; isMeetSemilattice = record { O }
}