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