@@ -11,7 +11,7 @@ module Function.Construct.Symmetry where
11
11
open import Data.Product.Base using (_,_; swap; proj₁; proj₂)
12
12
open import Function.Base using (_∘_)
13
13
open import Function.Consequences
14
- using (module IsSurjective )
14
+ using (module Section )
15
15
open import Function.Definitions
16
16
using (Bijective; Injective; Surjective; Inverseˡ; Inverseʳ; Inverseᵇ; Congruent)
17
17
open import Function.Structures
@@ -33,31 +33,6 @@ private
33
33
------------------------------------------------------------------------
34
34
-- Properties
35
35
36
- module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A → B}
37
- ((inj , surj) : Bijective ≈₁ ≈₂ f) (refl : Reflexive ≈₁)
38
- where
39
-
40
- open IsSurjective {≈₂ = ≈₂} surj
41
- using (section; section-strictInverseˡ)
42
-
43
- private f∘section≡id = section-strictInverseˡ refl
44
-
45
- section-cong : Symmetric ≈₂ → Transitive ≈₂ → Congruent ≈₂ ≈₁ section
46
- section-cong sym trans =
47
- inj ∘ trans (f∘section≡id _) ∘ sym ∘ trans (f∘section≡id _) ∘ sym
48
-
49
- injective : Symmetric ≈₂ → Transitive ≈₂ →
50
- Congruent ≈₁ ≈₂ f → Injective ≈₂ ≈₁ section
51
- injective sym trans cong gx≈gy =
52
- trans (trans (sym (f∘section≡id _)) (cong gx≈gy)) (f∘section≡id _)
53
-
54
- surjective : Transitive ≈₂ → Surjective ≈₂ ≈₁ section
55
- surjective trans x = f x , inj ∘ trans (f∘section≡id _)
56
-
57
- bijective : Symmetric ≈₂ → Transitive ≈₂ →
58
- Congruent ≈₁ ≈₂ f → Bijective ≈₂ ≈₁ section
59
- bijective sym trans cong = injective sym trans cong , surjective trans
60
-
61
36
module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) {f : A → B} {f⁻¹ : B → A} where
62
37
63
38
inverseʳ : Inverseˡ ≈₁ ≈₂ f f⁻¹ → Inverseʳ ≈₂ ≈₁ f⁻¹ f
@@ -76,31 +51,22 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂}
76
51
{f : A → B} (isBij : IsBijection ≈₁ ≈₂ f)
77
52
where
78
53
79
- private
80
- module IB = IsBijection isBij
54
+ private module B = IsBijection isBij
81
55
82
- -- We can only flip a bijection if the witness produced by the
83
- -- surjection proof respects the equality on the codomain.
84
- isBijection : Congruent ≈₂ ≈₁ IB.section → IsBijection ≈₂ ≈₁ IB .section
85
- isBijection section-cong = record
56
+ -- We can ALWAYS flip a bijection, WITHOUT knowing the witness produced
57
+ -- by the surjection proof respects the equality on the codomain.
58
+ isBijectionWithoutCongruence : IsBijection ≈₂ ≈₁ B .section
59
+ isBijectionWithoutCongruence = record
86
60
{ isInjection = record
87
61
{ isCongruent = record
88
- { cong = section- cong
89
- ; isEquivalence₁ = IB .Eq₂.isEquivalence
90
- ; isEquivalence₂ = IB .Eq₁.isEquivalence
62
+ { cong = S. cong B.injective B.Eq₁.refl B.Eq₂.sym B.Eq₂.trans
63
+ ; isEquivalence₁ = B .Eq₂.isEquivalence
64
+ ; isEquivalence₂ = B .Eq₁.isEquivalence
91
65
}
92
- ; injective = injective IB.bijective IB. Eq₁.refl IB .Eq₂.sym IB .Eq₂.trans IB.cong
66
+ ; injective = S. injective B. Eq₁.refl B .Eq₂.sym B .Eq₂.trans
93
67
}
94
- ; surjective = surjective IB.bijective IB.Eq₁.refl IB.Eq₂.trans
95
- }
96
-
97
- module _ {≈₁ : Rel A ℓ₁} {f : A → B} (isBij : IsBijection ≈₁ _≡_ f) where
98
-
99
- -- We can always flip a bijection if using the equality over the
100
- -- codomain is propositional equality.
101
- isBijection-≡ : IsBijection _≡_ ≈₁ _
102
- isBijection-≡ = isBijection isBij (IB.Eq₁.reflexive ∘ cong IB.section)
103
- where module IB = IsBijection isBij
68
+ ; surjective = S.surjective B.injective B.Eq₁.refl B.Eq₂.trans
69
+ } where module S = Section ≈₂ B.surjective
104
70
105
71
module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A → B} {f⁻¹ : B → A} where
106
72
@@ -136,24 +102,14 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A → B} {f⁻¹ :
136
102
137
103
module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} (bij : Bijection R S) where
138
104
139
- private
140
- module IB = Bijection bij
141
-
142
- -- We can only flip a bijection if the witness produced by the
143
- -- surjection proof respects the equality on the codomain.
144
- bijection : Congruent IB.Eq₂._≈_ IB.Eq₁._≈_ IB.section → Bijection S R
145
- bijection cong = record
146
- { to = IB.section
147
- ; cong = cong
148
- ; bijective = bijective IB.bijective IB.Eq₁.refl IB.Eq₂.sym IB.Eq₂.trans IB.cong
149
- }
150
-
151
- -- We can always flip a bijection if using the equality over the
152
- -- codomain is propositional equality.
153
- bijection-≡ : {R : Setoid a ℓ₁} {B : Set b} →
154
- Bijection R (setoid B) → Bijection (setoid B) R
155
- bijection-≡ bij = bijection bij (B.Eq₁.reflexive ∘ cong _)
156
- where module B = Bijection bij
105
+ -- We can always flip a bijection WITHOUT knowing if the witness produced
106
+ -- by the surjection proof respects the equality on the codomain.
107
+ bijectionWithoutCongruence : Bijection S R
108
+ bijectionWithoutCongruence = record
109
+ { to = B.section
110
+ ; cong = S.cong B.injective B.Eq₁.refl B.Eq₂.sym B.Eq₂.trans
111
+ ; bijective = S.bijective B.injective B.Eq₁.refl B.Eq₂.sym B.Eq₂.trans
112
+ } where module B = Bijection bij ; module S = Section (Setoid._≈_ S) B.surjective
157
113
158
114
module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
159
115
@@ -196,7 +152,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
196
152
-- Propositional bundles
197
153
198
154
⤖-sym : A ⤖ B → B ⤖ A
199
- ⤖-sym b = bijection b (cong section) where open Bijection b using (section)
155
+ ⤖-sym = bijectionWithoutCongruence
200
156
201
157
⇔-sym : A ⇔ B → B ⇔ A
202
158
⇔-sym = equivalence
@@ -217,7 +173,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
217
173
-- Please use the new names as continuing support for the old names is
218
174
-- not guaranteed.
219
175
220
- -- Version v2 .0
176
+ -- Version 2 .0
221
177
222
178
sym-⤖ = ⤖-sym
223
179
{-# WARNING_ON_USAGE sym-⤖
@@ -248,3 +204,68 @@ sym-↔ = ↔-sym
248
204
"Warning: sym-↔ was deprecated in v2.0.
249
205
Please use ↔-sym instead."
250
206
#-}
207
+
208
+ -- Version 2.3
209
+
210
+ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A → B}
211
+ ((inj , surj) : Bijective ≈₁ ≈₂ f) (refl : Reflexive ≈₁)
212
+ where
213
+
214
+ private
215
+ module S = Section ≈₂ surj
216
+
217
+ injective : Symmetric ≈₂ → Transitive ≈₂ →
218
+ Congruent ≈₁ ≈₂ f → Injective ≈₂ ≈₁ S.section
219
+ injective sym trans _ = S.injective refl sym trans
220
+
221
+ surjective : Transitive ≈₂ → Surjective ≈₂ ≈₁ S.section
222
+ surjective = S.surjective inj refl
223
+
224
+ bijective : Symmetric ≈₂ → Transitive ≈₂ →
225
+ Congruent ≈₁ ≈₂ f → Bijective ≈₂ ≈₁ S.section
226
+ bijective sym trans _ = S.injective refl sym trans , surjective trans
227
+ {-# WARNING_ON_USAGE injective
228
+ "Warning: injective was deprecated in v2.0.
229
+ Please use Function.Consequences.Section.injective instead, with a sharper type."
230
+ #-}
231
+ {-# WARNING_ON_USAGE surjective
232
+ "Warning: surjective was deprecated in v2.0.
233
+ Please use Function.Consequences.Section.surjective instead."
234
+ #-}
235
+ {-# WARNING_ON_USAGE bijective
236
+ "Warning: bijective was deprecated in v2.0.
237
+ Please use Function.Consequences.Section.bijective instead, with a sharper type."
238
+ #-}
239
+
240
+ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂}
241
+ {f : A → B} (isBij : IsBijection ≈₁ ≈₂ f)
242
+ where
243
+ private module B = IsBijection isBij
244
+ isBijection : Congruent ≈₂ ≈₁ B.section → IsBijection ≈₂ ≈₁ B.section
245
+ isBijection _ = isBijectionWithoutCongruence isBij
246
+ {-# WARNING_ON_USAGE isBijection
247
+ "Warning: isBijection was deprecated in v2.3.
248
+ Please use isBijectionWithoutCongruence instead, with a sharper type."
249
+ #-}
250
+
251
+ module _ {≈₁ : Rel A ℓ₁} {f : A → B} (isBij : IsBijection ≈₁ _≡_ f) where
252
+ isBijection-≡ : IsBijection _≡_ ≈₁ _
253
+ isBijection-≡ = isBijectionWithoutCongruence isBij
254
+ {-# WARNING_ON_USAGE isBijection-≡
255
+ "Warning: isBijection-≡ was deprecated in v2.3.
256
+ Please use isBijectionWithoutCongruence instead, with a sharper type."
257
+ #-}
258
+
259
+ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} (bij : Bijection R S) where
260
+ private module B = Bijection bij
261
+ bijection : Congruent B.Eq₂._≈_ B.Eq₁._≈_ B.section → Bijection S R
262
+ bijection _ = bijectionWithoutCongruence bij
263
+
264
+ bijection-≡ : {R : Setoid a ℓ₁} {B : Set b} →
265
+ Bijection R (setoid B) → Bijection (setoid B) R
266
+ bijection-≡ = bijectionWithoutCongruence
267
+ {-# WARNING_ON_USAGE bijection-≡
268
+ "Warning: bijection-≡ was deprecated in v2.3.
269
+ Please use bijectionWithoutCongruence instead, with a sharper type."
270
+ #-}
271
+
0 commit comments