Skip to content

Commit b35b5a1

Browse files
committed
refactor: fix names, deprecations for v2.3
1 parent dfce04f commit b35b5a1

File tree

1 file changed

+87
-66
lines changed

1 file changed

+87
-66
lines changed

src/Function/Construct/Symmetry.agda

Lines changed: 87 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Function.Construct.Symmetry where
1111
open import Data.Product.Base using (_,_; swap; proj₁; proj₂)
1212
open import Function.Base using (_∘_)
1313
open import Function.Consequences
14-
using (module IsSurjective)
14+
using (module Section)
1515
open import Function.Definitions
1616
using (Bijective; Injective; Surjective; Inverseˡ; Inverseʳ; Inverseᵇ; Congruent)
1717
open import Function.Structures
@@ -33,31 +33,6 @@ private
3333
------------------------------------------------------------------------
3434
-- Properties
3535

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-
6136
module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) {f : A B} {f⁻¹ : B A} where
6237

6338
inverseʳ : Inverseˡ ≈₁ ≈₂ f f⁻¹ Inverseʳ ≈₂ ≈₁ f⁻¹ f
@@ -76,31 +51,22 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂}
7651
{f : A B} (isBij : IsBijection ≈₁ ≈₂ f)
7752
where
7853

79-
private
80-
module IB = IsBijection isBij
54+
private module B = IsBijection isBij
8155

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
8660
{ isInjection = record
8761
{ 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
9165
}
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
9367
}
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
10470

10571
module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A B} {f⁻¹ : B A} where
10672

@@ -136,24 +102,14 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A → B} {f⁻¹ :
136102

137103
module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} (bij : Bijection R S) where
138104

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
157113

158114
module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
159115

@@ -196,7 +152,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
196152
-- Propositional bundles
197153

198154
⤖-sym : A ⤖ B B ⤖ A
199-
⤖-sym b = bijection b (cong section) where open Bijection b using (section)
155+
⤖-sym = bijectionWithoutCongruence
200156

201157
⇔-sym : A ⇔ B B ⇔ A
202158
⇔-sym = equivalence
@@ -217,7 +173,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
217173
-- Please use the new names as continuing support for the old names is
218174
-- not guaranteed.
219175

220-
-- Version v2.0
176+
-- Version 2.0
221177

222178
sym-⤖ = ⤖-sym
223179
{-# WARNING_ON_USAGE sym-⤖
@@ -248,3 +204,68 @@ sym-↔ = ↔-sym
248204
"Warning: sym-↔ was deprecated in v2.0.
249205
Please use ↔-sym instead."
250206
#-}
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

Comments
 (0)