------------------------------------------------------------------------ -- The Agda standard library -- -- Bundles for homogeneous binary relations ------------------------------------------------------------------------ -- The contents of this module should be accessed via `Relation.Binary`. {-# OPTIONS --cubical-compatible --safe #-} module Relation.Binary.Bundles where open import Function.Base using (flip) open import Level using (Level; suc; _⊔_) open import Relation.Binary.Core using (Rel) open import Relation.Binary.Bundles.Raw using (RawRelation; RawSetoid) open import Relation.Binary.Structures -- most of it open import Relation.Nullary.Negation.Core using (¬_) ------------------------------------------------------------------------ -- Setoids ------------------------------------------------------------------------ record PartialSetoid a ℓ : Set (suc (a ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ isPartialEquivalence : IsPartialEquivalence _≈_ open IsPartialEquivalence isPartialEquivalence public rawSetoid : RawSetoid _ _ rawSetoid = record { _≈_ = _≈_ } open RawSetoid rawSetoid public hiding (Carrier; _≈_ ) record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ isEquivalence : IsEquivalence _≈_ open IsEquivalence isEquivalence public using (refl; reflexive; isPartialEquivalence) partialSetoid : PartialSetoid c ℓ partialSetoid = record { isPartialEquivalence = isPartialEquivalence } open PartialSetoid partialSetoid public hiding (Carrier; _≈_; isPartialEquivalence) record DecSetoid c ℓ : Set (suc (c ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ isDecEquivalence : IsDecEquivalence _≈_ open IsDecEquivalence isDecEquivalence public using (_≟_; isEquivalence) setoid : Setoid c ℓ setoid = record { isEquivalence = isEquivalence } open Setoid setoid public hiding (Carrier; _≈_; isEquivalence) ------------------------------------------------------------------------ -- Preorders ------------------------------------------------------------------------ record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _≲_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ -- The underlying equality. _≲_ : Rel Carrier ℓ₂ -- The relation. isPreorder : IsPreorder _≈_ _≲_ open IsPreorder isPreorder public hiding (module Eq) module Eq where setoid : Setoid c ℓ₁ setoid = record { isEquivalence = isEquivalence } open Setoid setoid public rawRelation : RawRelation _ _ _ rawRelation = record { _≈_ = _≈_ ; _∼_ = _≲_ } open RawRelation rawRelation public renaming (_≁_ to _⋦_; _∼ᵒ_ to _≳_; _≁ᵒ_ to _⋧_) hiding (Carrier; _≈_) -- Deprecated. {-# WARNING_ON_USAGE _∼_ "Warning: _∼_ was deprecated in v2.0. Please use _≲_ instead. " #-} record TotalPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _≲_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ -- The underlying equality. _≲_ : Rel Carrier ℓ₂ -- The relation. isTotalPreorder : IsTotalPreorder _≈_ _≲_ open IsTotalPreorder isTotalPreorder public using (total; isPreorder) preorder : Preorder c ℓ₁ ℓ₂ preorder = record { isPreorder = isPreorder } open Preorder preorder public hiding (Carrier; _≈_; _≲_; isPreorder) record DecPreorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where field Carrier : Set c _≈_ : Rel Carrier ℓ₁ -- The underlying equality. _≲_ : Rel Carrier ℓ₂ -- The relation. isDecPreorder : IsDecPreorder _≈_ _≲_ private module DPO = IsDecPreorder isDecPreorder open DPO public using (_≟_; _≲?_; isPreorder) preorder : Preorder c ℓ₁ ℓ₂ preorder = record { isPreorder = isPreorder } open Preorder preorder public hiding (Carrier; _≈_; _≲_; isPreorder; module Eq) module Eq where decSetoid : DecSetoid c ℓ₁ decSetoid = record { isDecEquivalence = DPO.Eq.isDecEquivalence } open DecSetoid decSetoid public ------------------------------------------------------------------------ -- Partial orders ------------------------------------------------------------------------ record Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _≤_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ _≤_ : Rel Carrier ℓ₂ isPartialOrder : IsPartialOrder _≈_ _≤_ open IsPartialOrder isPartialOrder public using (antisym; isPreorder) preorder : Preorder c ℓ₁ ℓ₂ preorder = record { isPreorder = isPreorder } open Preorder preorder public hiding (Carrier; _≈_; _≲_; isPreorder; _⋦_; _≳_; _⋧_) renaming ( ≲-respˡ-≈ to ≤-respˡ-≈ ; ≲-respʳ-≈ to ≤-respʳ-≈ ; ≲-resp-≈ to ≤-resp-≈ ) open RawRelation rawRelation public renaming (_≁_ to _≰_; _∼ᵒ_ to _≥_; _≁ᵒ_ to _≱_) hiding (Carrier; _≈_ ; _∼_; _≉_; rawSetoid) record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _≤_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ _≤_ : Rel Carrier ℓ₂ isDecPartialOrder : IsDecPartialOrder _≈_ _≤_ private module DPO = IsDecPartialOrder isDecPartialOrder open DPO public using (_≟_; _≤?_; isPartialOrder; isDecPreorder) poset : Poset c ℓ₁ ℓ₂ poset = record { isPartialOrder = isPartialOrder } open Poset poset public hiding (Carrier; _≈_; _≤_; isPartialOrder; module Eq) decPreorder : DecPreorder c ℓ₁ ℓ₂ decPreorder = record { isDecPreorder = isDecPreorder } open DecPreorder decPreorder public using (module Eq) record StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _<_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ _<_ : Rel Carrier ℓ₂ isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ open IsStrictPartialOrder isStrictPartialOrder public hiding (module Eq) module Eq where setoid : Setoid c ℓ₁ setoid = record { isEquivalence = isEquivalence } open Setoid setoid public rawRelation : RawRelation _ _ _ rawRelation = record { _≈_ = _≈_ ; _∼_ = _<_ } open RawRelation rawRelation public renaming (_≁_ to _≮_; _∼ᵒ_ to _>_; _≁ᵒ_ to _≯_) hiding (Carrier; _≈_ ; _∼_) record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _<_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ _<_ : Rel Carrier ℓ₂ isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_ private module DSPO = IsDecStrictPartialOrder isDecStrictPartialOrder open DSPO public using (_