Debian Codegraph @

src/Relation/Binary/Construct/Add/Point/Equality.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- A pointwise lifting of a relation to incorporate an additional point.
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 -- This module is designed to be used with
10 -- Relation.Nullary.Construct.Add.Point
11
12 open import Relation.Binary.Core using (Rel)
13
14 module Relation.Binary.Construct.Add.Point.Equality
15 {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where
16
17 open import Level using (_⊔_)
18 open import Function.Base using (id; _∘_; _∘′_)
19 import Relation.Binary.PropositionalEquality.Core as ≡
20 open import Relation.Binary.Structures using (IsEquivalence; IsDecEquivalence)
21 open import Relation.Binary.Definitions
22 using (Reflexive; Symmetric; Transitive; Decidable; Irrelevant; Substitutive)
23 open import Relation.Nullary.Negation.Core using (¬_)
24 open import Relation.Nullary.Decidable.Core using (yes; no)
25 open import Relation.Nullary.Construct.Add.Point as Point using (Pointed; ∙ ;[_])
26 import Relation.Nullary.Decidable.Core as Dec using (map′)
27
28 ------------------------------------------------------------------------
29 -- Definition
30
31 infix 4 _≈∙_
32
33 data _≈∙_ : Rel (Pointed A) (a ⊔ ℓ) where
34 ∙≈∙ : ∙ ≈∙ ∙
35 [_] : {k l : A} → k ≈ l → [ k ] ≈∙ [ l ]
36
37 ------------------------------------------------------------------------
38 -- Relational properties
39
40 [≈]-injective : ∀ {k l} → [ k ] ≈∙ [ l ] → k ≈ l
41 [≈]-injective [ k≈l ] = k≈l
42
43 ≈∙-refl : Reflexive _≈_ → Reflexive _≈∙_
44 ≈∙-refl ≈-refl {∙} = ∙≈∙
45 ≈∙-refl ≈-refl {[ k ]} = [ ≈-refl ]
46
47 ≈∙-sym : Symmetric _≈_ → Symmetric _≈∙_
48 ≈∙-sym ≈-sym ∙≈∙ = ∙≈∙
49 ≈∙-sym ≈-sym [ x≈y ] = [ ≈-sym x≈y ]
50
51 ≈∙-trans : Transitive _≈_ → Transitive _≈∙_
52 ≈∙-trans ≈-trans ∙≈∙ ∙≈z = ∙≈z
53 ≈∙-trans ≈-trans [ x≈y ] [ y≈z ] = [ ≈-trans x≈y y≈z ]
54
55 ≈∙-dec : Decidable _≈_ → Decidable _≈∙_
56 ≈∙-dec _≟_ ∙ ∙ = yes ∙≈∙
57 ≈∙-dec _≟_ ∙ [ l ] = no (λ ())
58 ≈∙-dec _≟_ [ k ] ∙ = no (λ ())
59 ≈∙-dec _≟_ [ k ] [ l ] = Dec.map′ [_] [≈]-injective (k ≟ l)
60
61 ≈∙-irrelevant : Irrelevant _≈_ → Irrelevant _≈∙_
62 ≈∙-irrelevant ≈-irr ∙≈∙ ∙≈∙ = ≡.refl
63 ≈∙-irrelevant ≈-irr [ p ] [ q ] = ≡.cong _ (≈-irr p q)
64
65 ≈∙-substitutive : ∀ {ℓ} → Substitutive _≈_ ℓ → Substitutive _≈∙_ ℓ
66 ≈∙-substitutive ≈-subst P ∙≈∙ = id
67 ≈∙-substitutive ≈-subst P [ p ] = ≈-subst (P ∘′ [_]) p
68
69 ------------------------------------------------------------------------
70 -- Structures
71
72 ≈∙-isEquivalence : IsEquivalence _≈_ → IsEquivalence _≈∙_
73 ≈∙-isEquivalence ≈-isEquivalence = record
74 { refl = ≈∙-refl refl
75 ; sym = ≈∙-sym sym
76 ; trans = ≈∙-trans trans
77 } where open IsEquivalence ≈-isEquivalence
78
79 ≈∙-isDecEquivalence : IsDecEquivalence _≈_ → IsDecEquivalence _≈∙_
80 ≈∙-isDecEquivalence ≈-isDecEquivalence = record
81 { isEquivalence = ≈∙-isEquivalence isEquivalence
82 ; _≟_ = ≈∙-dec _≟_
83 } where open IsDecEquivalence ≈-isDecEquivalence