Debian Codegraph @

src/Relation/Binary/PropositionalEquality/Core.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Propositional equality
5 --
6 -- This file contains some core definitions which are re-exported by
7 -- Relation.Binary.PropositionalEquality.
8 ------------------------------------------------------------------------
9
10 {-# OPTIONS --cubical-compatible --safe #-}
11
12 module Relation.Binary.PropositionalEquality.Core where
13
14 open import Data.Product.Base using (_,_)
15 open import Function.Base using (_∘_)
16 open import Level using (Level; _⊔_)
17 open import Relation.Binary.Core using (Rel; REL)
18 open import Relation.Binary.Definitions
19 using (Symmetric; Transitive; Substitutive
20 ; _Respects_; _Respectsˡ_; _Respectsʳ_; _Respects₂_)
21 open import Relation.Nullary.Negation.Core using (¬_)
22
23 private
24 variable
25 a b ℓ : Level
26 A B C : Set a
27
28 ------------------------------------------------------------------------
29 -- Propositional equality
30
31 open import Agda.Builtin.Equality public
32
33 infix 4 _≢_
34 _≢_ : {A : Set a} → Rel A a
35 x ≢ y = ¬ x ≡ y
36
37 ------------------------------------------------------------------------
38 -- Pointwise equality
39
40 infix 4 _≗_
41
42 _≗_ : (f g : A → B) → Set _
43 _≗_ {A = A} {B = B} f g = ∀ x → f x ≡ g x
44
45
46 ------------------------------------------------------------------------
47 -- A variant of `refl` where the argument is explicit
48
49 pattern erefl x = refl {x = x}
50
51 ------------------------------------------------------------------------
52 -- Congruence lemmas
53
54 cong : ∀ (f : A → B) {x y} → x ≡ y → f x ≡ f y
55 cong f refl = refl
56
57 cong′ : ∀ {f : A → B} x → f x ≡ f x
58 cong′ _ = refl
59
60 icong : ∀ {f : A → B} {x y} → x ≡ y → f x ≡ f y
61 icong = cong _
62
63 icong′ : ∀ {f : A → B} x → f x ≡ f x
64 icong′ _ = refl
65
66 cong₂ : ∀ (f : A → B → C) {x y u v} → x ≡ y → u ≡ v → f x u ≡ f y v
67 cong₂ f refl refl = refl
68
69 cong-app : ∀ {A : Set a} {B : A → Set b} {f g : (x : A) → B x} →
70 f ≡ g → (x : A) → f x ≡ g x
71 cong-app refl x = refl
72
73 ------------------------------------------------------------------------
74 -- Properties of _≡_
75
76 sym : Symmetric {A = A} _≡_
77 sym refl = refl
78
79 trans : Transitive {A = A} _≡_
80 trans refl eq = eq
81
82 subst : Substitutive {A = A} _≡_ ℓ
83 subst P refl p = p
84
85 subst₂ : ∀ (_∼_ : REL A B ℓ) {x y u v} → x ≡ y → u ≡ v → x ∼ u → y ∼ v
86 subst₂ _ refl refl p = p
87
88 resp : ∀ (P : A → Set ℓ) → P Respects _≡_
89 resp P refl p = p
90
91 respˡ : ∀ (∼ : Rel A ℓ) → ∼ Respectsˡ _≡_
92 respˡ _∼_ refl x∼y = x∼y
93
94 respʳ : ∀ (∼ : Rel A ℓ) → ∼ Respectsʳ _≡_
95 respʳ _∼_ refl x∼y = x∼y
96
97 resp₂ : ∀ (∼ : Rel A ℓ) → ∼ Respects₂ _≡_
98 resp₂ _∼_ = respʳ _∼_ , respˡ _∼_
99
100 ------------------------------------------------------------------------
101 -- Properties of _≢_
102
103 ≢-sym : Symmetric {A = A} _≢_
104 ≢-sym x≢y = x≢y ∘ sym