Skip to content

Commit

Permalink
[ new ] generic "diag" for decidable equality (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
gallais authored and MatthewDaggitt committed Apr 13, 2018
1 parent 630311b commit 5914224
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -249,6 +249,12 @@ Backwards compatible changes
trans∧tri⟶respˡ≈ : Transitive _<_ → Trichotomous _≈_ _<_ → _<_ Respectsˡ _≈_
```

* Added new proof to `Relation.Binary.PropositionalEquality`:
```agda
≡-≟-identity : (eq : a ≡ b) → a ≟ b ≡ yes eq
≢-≟-identity : a ≢ b → ∃ λ ¬eq → a ≟ b ≡ no ¬eq
```

* The types `Maximum` and `Minimum` are now exported by `Relation.Binary` as well
as `Relation.Binary.Lattice`.

Expand Down
15 changes: 15 additions & 0 deletions src/Relation/Binary/PropositionalEquality.agda
Expand Up @@ -9,6 +9,9 @@ module Relation.Binary.PropositionalEquality where
open import Function
open import Function.Equality using (Π; _⟶_; ≡-setoid)
open import Level
open import Data.Empty
open import Data.Product
open import Relation.Nullary using (yes ; no)
open import Relation.Unary using (Pred)
open import Relation.Binary
import Relation.Binary.Indexed as I
Expand Down Expand Up @@ -191,6 +194,18 @@ IrrelevantRel _~_ = ∀ {x y} → isPropositional (x ~ y)
≡-irrelevance : {a} {A : Set a} IrrelevantRel (_≡_ {A = A})
≡-irrelevance refl refl = refl

module _ {a} {A : Set a} (_≟_ : Decidable (_≡_ {A = A})) {a b : A} where

≡-≟-identity : (eq : a ≡ b) a ≟ b ≡ yes eq
≡-≟-identity eq with a ≟ b
... | yes p = cong yes (≡-irrelevance p eq)
... | no ¬p = ⊥-elim (¬p eq)

≢-≟-identity : a ≢ b λ ¬eq a ≟ b ≡ no ¬eq
≢-≟-identity ¬eq with a ≟ b
... | yes p = ⊥-elim (¬eq p)
... | no ¬p = ¬p , refl

------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
Expand Down

0 comments on commit 5914224

Please sign in to comment.