| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Additional properties for setoids |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Relation.Binary.Bundles using (Setoid; Preorder; Poset) |
| 10 |
|
| 11 |
module Relation.Binary.Properties.Setoid {a ℓ} (S : Setoid a ℓ) where |
| 12 |
|
| 13 |
open import Data.Product.Base using (_,_) |
| 14 |
open import Function.Base using (_∘_; id; _$_; flip) |
| 15 |
open import Relation.Binary.Core using (_⇒_) |
| 16 |
open import Relation.Binary.Construct.Composition |
| 17 |
using (_;_; impliesˡ; transitive⇒≈;≈⊆≈) |
| 18 |
open import Relation.Binary.Definitions |
| 19 |
using (Symmetric; _Respectsˡ_; _Respectsʳ_; _Respects₂_; Irreflexive) |
| 20 |
open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_) |
| 21 |
open import Relation.Binary.Structures using (IsPreorder; IsPartialOrder) |
| 22 |
open import Relation.Nullary.Negation.Core using (¬_; contradiction) |
| 23 |
|
| 24 |
open Setoid S |
| 25 |
|
| 26 |
------------------------------------------------------------------------ |
| 27 |
-- Every setoid is a preorder and partial order with respect to |
| 28 |
-- propositional equality |
| 29 |
|
| 30 |
isPreorder : IsPreorder _≡_ _≈_ |
| 31 |
isPreorder = record |
| 32 |
{ isEquivalence = record |
| 33 |
{ refl = ≡.refl |
| 34 |
; sym = ≡.sym |
| 35 |
; trans = ≡.trans |
| 36 |
} |
| 37 |
; reflexive = reflexive |
| 38 |
; trans = trans |
| 39 |
} |
| 40 |
|
| 41 |
≈-isPreorder : IsPreorder _≈_ _≈_ |
| 42 |
≈-isPreorder = record |
| 43 |
{ isEquivalence = isEquivalence |
| 44 |
; reflexive = id |
| 45 |
; trans = trans |
| 46 |
} |
| 47 |
|
| 48 |
≈-isPartialOrder : IsPartialOrder _≈_ _≈_ |
| 49 |
≈-isPartialOrder = record |
| 50 |
{ isPreorder = ≈-isPreorder |
| 51 |
; antisym = λ i≈j _ → i≈j |
| 52 |
} |
| 53 |
|
| 54 |
preorder : Preorder a a ℓ |
| 55 |
preorder = record |
| 56 |
{ isPreorder = isPreorder |
| 57 |
} |
| 58 |
|
| 59 |
≈-preorder : Preorder a ℓ ℓ |
| 60 |
≈-preorder = record |
| 61 |
{ isPreorder = ≈-isPreorder |
| 62 |
} |
| 63 |
|
| 64 |
≈-poset : Poset a ℓ ℓ |
| 65 |
≈-poset = record |
| 66 |
{ isPartialOrder = ≈-isPartialOrder |
| 67 |
} |
| 68 |
|
| 69 |
------------------------------------------------------------------------ |
| 70 |
-- Properties of _≉_ |
| 71 |
|
| 72 |
≉-sym : Symmetric _≉_ |
| 73 |
≉-sym x≉y = x≉y ∘ sym |
| 74 |
|
| 75 |
≉-respˡ : _≉_ Respectsˡ _≈_ |
| 76 |
≉-respˡ x≈x′ x≉y = x≉y ∘ trans x≈x′ |
| 77 |
|
| 78 |
≉-respʳ : _≉_ Respectsʳ _≈_ |
| 79 |
≉-respʳ y≈y′ x≉y x≈y′ = x≉y $ trans x≈y′ (sym y≈y′) |
| 80 |
|
| 81 |
≉-resp₂ : _≉_ Respects₂ _≈_ |
| 82 |
≉-resp₂ = ≉-respʳ , ≉-respˡ |
| 83 |
|
| 84 |
≉-irrefl : Irreflexive _≈_ _≉_ |
| 85 |
≉-irrefl x≈y x≉y = contradiction x≈y x≉y |
| 86 |
|
| 87 |
------------------------------------------------------------------------ |
| 88 |
-- Equality is closed under composition |
| 89 |
|
| 90 |
≈;≈⇒≈ : _≈_ ; _≈_ ⇒ _≈_ |
| 91 |
≈;≈⇒≈ = transitive⇒≈;≈⊆≈ _ trans |
| 92 |
|
| 93 |
≈⇒≈;≈ : _≈_ ⇒ _≈_ ; _≈_ |
| 94 |
≈⇒≈;≈ = impliesˡ _≈_ _≈_ refl id |
| 95 |
|
| 96 |
------------------------------------------------------------------------ |
| 97 |
-- Other properties |
| 98 |
|
| 99 |
respʳ-flip : _≈_ Respectsʳ (flip _≈_) |
| 100 |
respʳ-flip y≈z x≈z = trans x≈z (sym y≈z) |
| 101 |
|
| 102 |
respˡ-flip : _≈_ Respectsˡ (flip _≈_) |
| 103 |
respˡ-flip = trans |
| 104 |
|