Debian Codegraph @

src/Function/Construct/Identity.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- The identity function
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Function.Construct.Identity where
10
11 open import Data.Product.Base using (_,_)
12 open import Function.Base using (id)
13 open import Function.Bundles
14 import Function.Definitions as Definitions
15 using (Congruent; Injective; Surjective; Bijective; Inverseʳ; Inverseˡ
16 ; Inverseᵇ)
17 import Function.Structures as Structures
18 using (IsCongruent; IsInjection; IsSurjection; IsBijection; IsLeftInverse
19 ; IsRightInverse; IsInverse)
20 open import Level using (Level)
21 open import Relation.Binary.Core using (Rel)
22 open import Relation.Binary.Bundles using (Setoid)
23 open import Relation.Binary.Structures as B hiding (IsEquivalence)
24 open import Relation.Binary.Definitions using (Reflexive)
25 open import Relation.Binary.PropositionalEquality.Core using (_≡_)
26 open import Relation.Binary.PropositionalEquality.Properties using (setoid)
27
28 private
29 variable
30 a ℓ : Level
31 A : Set a
32
33 ------------------------------------------------------------------------
34 -- Properties
35
36 module _ (_≈_ : Rel A ℓ) where
37
38 open Definitions
39
40 congruent : Congruent _≈_ _≈_ id
41 congruent = id
42
43 injective : Injective _≈_ _≈_ id
44 injective = id
45
46 surjective : Surjective _≈_ _≈_ id
47 surjective x = x , id
48
49 bijective : Bijective _≈_ _≈_ id
50 bijective = injective , surjective
51
52 inverseˡ : Inverseˡ _≈_ _≈_ id id
53 inverseˡ = id
54
55 inverseʳ : Inverseʳ _≈_ _≈_ id id
56 inverseʳ = id
57
58 inverseᵇ : Inverseᵇ _≈_ _≈_ id id
59 inverseᵇ = inverseˡ , inverseʳ
60
61 ------------------------------------------------------------------------
62 -- Structures
63
64 module _ {_≈_ : Rel A ℓ} (isEq : B.IsEquivalence _≈_) where
65
66 open Structures _≈_ _≈_
67 open B.IsEquivalence isEq
68
69 isCongruent : IsCongruent id
70 isCongruent = record
71 { cong = id
72 ; isEquivalence₁ = isEq
73 ; isEquivalence₂ = isEq
74 }
75
76 isInjection : IsInjection id
77 isInjection = record
78 { isCongruent = isCongruent
79 ; injective = injective _≈_
80 }
81
82 isSurjection : IsSurjection id
83 isSurjection = record
84 { isCongruent = isCongruent
85 ; surjective = surjective _≈_
86 }
87
88 isBijection : IsBijection id
89 isBijection = record
90 { isInjection = isInjection
91 ; surjective = surjective _≈_
92 }
93
94 isLeftInverse : IsLeftInverse id id
95 isLeftInverse = record
96 { isCongruent = isCongruent
97 ; from-cong = id
98 ; inverseˡ = inverseˡ _≈_
99 }
100
101 isRightInverse : IsRightInverse id id
102 isRightInverse = record
103 { isCongruent = isCongruent
104 ; from-cong = id
105 ; inverseʳ = inverseʳ _≈_
106 }
107
108 isInverse : IsInverse id id
109 isInverse = record
110 { isLeftInverse = isLeftInverse
111 ; inverseʳ = inverseʳ _≈_
112 }
113
114 ------------------------------------------------------------------------
115 -- Setoid bundles
116
117 module _ (S : Setoid a ℓ) where
118
119 open Setoid S
120
121 function : Func S S
122 function = record
123 { to = id
124 ; cong = id
125 }
126
127 injection : Injection S S
128 injection = record
129 { to = id
130 ; cong = id
131 ; injective = injective _≈_
132 }
133
134 surjection : Surjection S S
135 surjection = record
136 { to = id
137 ; cong = id
138 ; surjective = surjective _≈_
139 }
140
141 bijection : Bijection S S
142 bijection = record
143 { to = id
144 ; cong = id
145 ; bijective = bijective _≈_
146 }
147
148 equivalence : Equivalence S S
149 equivalence = record
150 { to = id
151 ; from = id
152 ; to-cong = id
153 ; from-cong = id
154 }
155
156 leftInverse : LeftInverse S S
157 leftInverse = record
158 { to = id
159 ; from = id
160 ; to-cong = id
161 ; from-cong = id
162 ; inverseˡ = inverseˡ _≈_
163 }
164
165 rightInverse : RightInverse S S
166 rightInverse = record
167 { to = id
168 ; from = id
169 ; to-cong = id
170 ; from-cong = id
171 ; inverseʳ = inverseʳ _≈_
172 }
173
174 inverse : Inverse S S
175 inverse = record
176 { to = id
177 ; from = id
178 ; to-cong = id
179 ; from-cong = id
180 ; inverse = inverseᵇ _≈_
181 }
182
183 ------------------------------------------------------------------------
184 -- Propositional bundles
185
186 module _ (A : Set a) where
187
188 ⟶-id : A ⟶ A
189 ⟶-id = function (setoid A)
190
191 ↣-id : A ↣ A
192 ↣-id = injection (setoid A)
193
194 ↠-id : A ↠ A
195 ↠-id = surjection (setoid A)
196
197 ⤖-id : A ⤖ A
198 ⤖-id = bijection (setoid A)
199
200 ⇔-id : A ⇔ A
201 ⇔-id = equivalence (setoid A)
202
203 ↩-id : A ↩ A
204 ↩-id = leftInverse (setoid A)
205
206 ↪-id : A ↪ A
207 ↪-id = rightInverse (setoid A)
208
209 ↔-id : A ↔ A
210 ↔-id = inverse (setoid A)
211
212
213 ------------------------------------------------------------------------
214 -- DEPRECATED NAMES
215 ------------------------------------------------------------------------
216 -- Please use the new names as continuing support for the old names is
217 -- not guaranteed.
218
219 -- Version v2.0
220
221 id-⟶ = ⟶-id
222 {-# WARNING_ON_USAGE id-⟶
223 "Warning: id-⟶ was deprecated in v2.0.
224 Please use ⟶-id instead."
225 #-}
226
227 id-↣ = ↣-id
228 {-# WARNING_ON_USAGE id-↣
229 "Warning: id-↣ was deprecated in v2.0.
230 Please use ↣-id instead."
231 #-}
232
233 id-↠ = ↠-id
234 {-# WARNING_ON_USAGE id-↠
235 "Warning: id-↠ was deprecated in v2.0.
236 Please use ↠-id instead."
237 #-}
238
239 id-⤖ = ⤖-id
240 {-# WARNING_ON_USAGE id-⤖
241 "Warning: id-⤖ was deprecated in v2.0.
242 Please use ⤖-id instead."
243 #-}
244
245 id-⇔ = ⇔-id
246 {-# WARNING_ON_USAGE id-⇔
247 "Warning: id-⇔ was deprecated in v2.0.
248 Please use ⇔-id instead."
249 #-}
250
251 id-↩ = ↩-id
252 {-# WARNING_ON_USAGE id-↩
253 "Warning: id-↩ was deprecated in v2.0.
254 Please use ↩-id instead."
255 #-}
256
257 id-↪ = ↪-id
258 {-# WARNING_ON_USAGE id-↪
259 "Warning: id-↪ was deprecated in v2.0.
260 Please use ↪-id instead."
261 #-}
262
263 id-↔ = ↔-id
264 {-# WARNING_ON_USAGE id-↔
265 "Warning: id-↔ was deprecated in v2.0.
266 Please use ↔-id instead."
267 #-}