------------------------------------------------------------------------ -- The Agda standard library -- -- Conversion of ≤ to <, along with a number of properties ------------------------------------------------------------------------ -- Possible TODO: Prove that a conversion ≤ → < → ≤ returns a -- relation equivalent to the original one (and similarly for -- < → ≤ → <). open import Relation.Binary module Relation.Binary.NonStrictToStrict {a ℓ₁ ℓ₂} {A : Set a} (_≈_ : Rel A ℓ₁) (_≤_ : Rel A ℓ₂) where open import Relation.Nullary open import Relation.Binary.Consequences open import Function open import Data.Product open import Data.Sum ------------------------------------------------------------------------ -- Conversion -- _≤_ can be turned into _<_ as follows: _<_ : Rel A _ x < y = (x ≤ y) × ¬ (x ≈ y) ------------------------------------------------------------------------ -- The converted relations have certain properties -- (if the original relations have certain other properties) irrefl : Irreflexive _≈_ _<_ irrefl x≈y x (x≉y ∘ flip antisym x≥y ∘ proj₁) x≉y (x≥y , x≉y ∘ ≈-sym) decidable : Decidable _≈_ → Decidable _≤_ → Decidable _<_ decidable ≈-dec ≤-dec x y with ≈-dec x y | ≤-dec x y ... | yes x≈y | _ = no (flip proj₂ x≈y) ... | no x≉y | yes x≤y = yes (x≤y , x≉y) ... | no x≉y | no x≰y = no (x≰y ∘ proj₁) isPartialOrder⟶isStrictPartialOrder : IsPartialOrder _≈_ _≤_ → IsStrictPartialOrder _≈_ _<_ isPartialOrder⟶isStrictPartialOrder po = record { isEquivalence = PO.isEquivalence ; irrefl = irrefl ; trans = trans po ; <-resp-≈ = <-resp-≈ PO.isEquivalence PO.≤-resp-≈ } where module PO = IsPartialOrder po isTotalOrder⟶isStrictTotalOrder : Decidable _≈_ → IsTotalOrder _≈_ _≤_ → IsStrictTotalOrder _≈_ _<_ isTotalOrder⟶isStrictTotalOrder dec-≈ tot = record { isEquivalence = TO.isEquivalence ; trans = trans TO.isPartialOrder ; compare = trichotomous TO.Eq.sym dec-≈ TO.antisym TO.total ; <-resp-≈ = <-resp-≈ TO.isEquivalence TO.≤-resp-≈ } where module TO = IsTotalOrder tot isDecTotalOrder⟶isStrictTotalOrder : IsDecTotalOrder _≈_ _≤_ → IsStrictTotalOrder _≈_ _<_ isDecTotalOrder⟶isStrictTotalOrder dtot = isTotalOrder⟶isStrictTotalOrder DTO._≟_ DTO.isTotalOrder where module DTO = IsDecTotalOrder dtot