Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add derived (pre-)groupoid operations to Relation.Binary.Is(Partial)Equivalence #2249

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ Additions to existing modules

* In `Function.Bundles`, added `_⟶ₛ_` as a synonym for `Func` that can
be used infix.

* In `Relation.Binary.Structures.IsPartialEquivalence`, added
commonly occurring derived combinations of `trans` and `sym`:
```agda
infixr 5 _ᵒ⊗_ _⊗ᵒ_
transᵒ : RightTrans _≈_ (flip _≈_)
_⊗ᵒ_ = transᵒ
ᵒtrans : Trans (flip _≈_) _≈_ _≈_
_ᵒ⊗_ = ᵒtrans
```

20 changes: 17 additions & 3 deletions src/Relation/Binary/Structures.agda
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ module Relation.Binary.Structures
where

open import Data.Product.Base using (proj₁; proj₂; _,_)
open import Function.Base using (flip)
open import Level using (Level; _⊔_)
open import Relation.Nullary.Negation.Core using (¬_)
open import Relation.Binary.PropositionalEquality.Core as P using (_≡_)
open import Relation.Binary.PropositionalEquality.Core as using (_≡_)
open import Relation.Binary.Consequences
open import Relation.Binary.Definitions

Expand All @@ -33,15 +34,26 @@ private
-- as a module parameter at the top of this file.

record IsPartialEquivalence : Set (a ⊔ ℓ) where
infixr 5 _ᵒ⊗_ _⊗ᵒ_
field
sym : Symmetric _≈_
trans : Transitive _≈_

transᵒ : RightTrans _≈_ (flip _≈_)
transᵒ eq₁ eq₂ = trans eq₁ (sym eq₂)

_⊗ᵒ_ = transᵒ

ᵒtrans : Trans (flip _≈_) _≈_ _≈_
ᵒtrans eq₁ eq₂ = trans (sym eq₁) eq₂

_ᵒ⊗_ = ᵒtrans

-- The preorders of this library are defined in terms of an underlying
-- equivalence relation, and hence equivalence relations are not
-- defined in terms of preorders.

-- To preserve backwards compatability, equivalence relations are
-- To preserve backwards compatibility, equivalence relations are
-- not defined in terms of their partial counterparts.

record IsEquivalence : Set (a ⊔ ℓ) where
Expand All @@ -51,14 +63,16 @@ record IsEquivalence : Set (a ⊔ ℓ) where
trans : Transitive _≈_

reflexive : _≡_ ⇒ _≈_
reflexive P.refl = refl
reflexive .refl = refl

isPartialEquivalence : IsPartialEquivalence
isPartialEquivalence = record
{ sym = sym
; trans = trans
}

open IsPartialEquivalence isPartialEquivalence public
using (transᵒ; ᵒtrans; _ᵒ⊗_; _⊗ᵒ_)

record IsDecEquivalence : Set (a ⊔ ℓ) where
infix 4 _≟_
Expand Down