------------------------------------------------------------------------ -- The Agda standard library -- -- Many properties which hold for `_∼_` also hold for `_∼_ on f` ------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} module Relation.Binary.Construct.On where open import Data.Product.Base using (_,_) open import Function.Base using (_on_; _∘_) open import Induction.WellFounded using (WellFounded; Acc; acc) open import Level using (Level) open import Relation.Binary.Core using (Rel; _⇒_) open import Relation.Binary.Bundles using (Preorder; Setoid; DecSetoid; Poset; DecPoset; StrictPartialOrder ; TotalOrder; DecTotalOrder; StrictTotalOrder) open import Relation.Binary.Structures using (IsEquivalence; IsDecEquivalence; IsPreorder; IsPartialOrder ; IsDecPartialOrder; IsStrictPartialOrder; IsTotalOrder ; IsDecTotalOrder; IsStrictTotalOrder) open import Relation.Binary.Definitions using (Reflexive; Irreflexive; Symmetric; Transitive; Antisymmetric ; Asymmetric; Decidable; Total; Trichotomous; _Respects_; _Respects₂_) private variable a b p ℓ ℓ₁ ℓ₂ : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Definitions module _ (f : B → A) where implies : (≈ : Rel A ℓ₁) (∼ : Rel A ℓ₂) → ≈ ⇒ ∼ → (≈ on f) ⇒ (∼ on f) implies _ _ impl = impl reflexive : (∼ : Rel A ℓ) → Reflexive ∼ → Reflexive (∼ on f) reflexive _ refl = refl irreflexive : (≈ : Rel A ℓ₁) (∼ : Rel A ℓ₂) → Irreflexive ≈ ∼ → Irreflexive (≈ on f) (∼ on f) irreflexive _ _ irrefl = irrefl symmetric : (∼ : Rel A ℓ) → Symmetric ∼ → Symmetric (∼ on f) symmetric _ sym = sym transitive : (∼ : Rel A ℓ) → Transitive ∼ → Transitive (∼ on f) transitive _ trans = trans antisymmetric : (≈ : Rel A ℓ₁) (≤ : Rel A ℓ₂) → Antisymmetric ≈ ≤ → Antisymmetric (≈ on f) (≤ on f) antisymmetric _ _ antisym = antisym asymmetric : (< : Rel A ℓ) → Asymmetric < → Asymmetric (< on f) asymmetric _ asym = asym respects : (∼ : Rel A ℓ) (P : A → Set p) → P Respects ∼ → (P ∘ f) Respects (∼ on f) respects _ _ resp = resp respects₂ : (∼₁ : Rel A ℓ₁) (∼₂ : Rel A ℓ₂) → ∼₁ Respects₂ ∼₂ → (∼₁ on f) Respects₂ (∼₂ on f) respects₂ _ _ (resp₁ , resp₂) = (resp₁ , resp₂) decidable : (∼ : Rel A ℓ) → Decidable ∼ → Decidable (∼ on f) decidable _ dec x y = dec (f x) (f y) total : (∼ : Rel A ℓ) → Total ∼ → Total (∼ on f) total _ tot x y = tot (f x) (f y) trichotomous : (≈ : Rel A ℓ₁) (< : Rel A ℓ₂) → Trichotomous ≈ < → Trichotomous (≈ on f) (< on f) trichotomous _ _ compare x y = compare (f x) (f y) accessible : ∀ {∼ : Rel A ℓ} {x} → Acc ∼ (f x) → Acc (∼ on f) x accessible (acc rs) = acc (λ fy