| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties of These |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.These.Properties where |
| 10 |
|
| 11 |
open import Data.Product.Base using (_×_; _,_; <_,_>; uncurry) |
| 12 |
open import Data.These.Base using (These; this; that; these) |
| 13 |
open import Function.Base using (_∘_) |
| 14 |
open import Relation.Binary.Definitions using (DecidableEquality) |
| 15 |
open import Relation.Binary.PropositionalEquality.Core |
| 16 |
using (_≡_; refl; cong; cong₂) |
| 17 |
open import Relation.Nullary.Decidable using (yes; no; map′; _×-dec_) |
| 18 |
|
| 19 |
------------------------------------------------------------------------ |
| 20 |
-- Equality |
| 21 |
|
| 22 |
module _ {a b} {A : Set a} {B : Set b} where |
| 23 |
|
| 24 |
this-injective : ∀ {x y : A} → this {B = B} x ≡ this y → x ≡ y |
| 25 |
this-injective refl = refl |
| 26 |
|
| 27 |
that-injective : ∀ {a b : B} → that {A = A} a ≡ that b → a ≡ b |
| 28 |
that-injective refl = refl |
| 29 |
|
| 30 |
these-injectiveˡ : ∀ {x y : A} {a b : B} → these x a ≡ these y b → x ≡ y |
| 31 |
these-injectiveˡ refl = refl |
| 32 |
|
| 33 |
these-injectiveʳ : ∀ {x y : A} {a b : B} → these x a ≡ these y b → a ≡ b |
| 34 |
these-injectiveʳ refl = refl |
| 35 |
|
| 36 |
these-injective : ∀ {x y : A} {a b : B} → these x a ≡ these y b → x ≡ y × a ≡ b |
| 37 |
these-injective = < these-injectiveˡ , these-injectiveʳ > |
| 38 |
|
| 39 |
≡-dec : DecidableEquality A → DecidableEquality B → DecidableEquality (These A B) |
| 40 |
≡-dec dec₁ dec₂ (this x) (this y) = |
| 41 |
map′ (cong this) this-injective (dec₁ x y) |
| 42 |
≡-dec dec₁ dec₂ (this x) (that y) = no λ() |
| 43 |
≡-dec dec₁ dec₂ (this x) (these y b) = no λ() |
| 44 |
≡-dec dec₁ dec₂ (that x) (this y) = no λ() |
| 45 |
≡-dec dec₁ dec₂ (that x) (that y) = |
| 46 |
map′ (cong that) that-injective (dec₂ x y) |
| 47 |
≡-dec dec₁ dec₂ (that x) (these y b) = no λ() |
| 48 |
≡-dec dec₁ dec₂ (these x a) (this y) = no λ() |
| 49 |
≡-dec dec₁ dec₂ (these x a) (that y) = no λ() |
| 50 |
≡-dec dec₁ dec₂ (these x a) (these y b) = |
| 51 |
map′ (uncurry (cong₂ these)) these-injective (dec₁ x y ×-dec dec₂ a b) |