Skip to content

Commit cf181c4

Browse files
committed
fixes agda#2568
1 parent 34f5009 commit cf181c4

File tree

8 files changed

+46
-34
lines changed

8 files changed

+46
-34
lines changed

src/Data/Product/Function/Dependent/Propositional.agda

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module _ where
5757
Σ I A ⇔ Σ J B
5858
Σ-⇔ {B = B} I↠J A⇔B = mk⇔
5959
(map (to I↠J) (Equivalence.to A⇔B))
60-
(map (to⁻ I↠J) (Equivalence.from A⇔B ∘ ≡.subst B (≡.sym (proj₂ (surjective I↠J _) ≡.refl))))
60+
(map (section I↠J) (Equivalence.from A⇔B ∘ ≡.subst B (≡.sym (proj₂ (surjective I↠J _) ≡.refl))))
6161

6262
-- See also Data.Product.Relation.Binary.Pointwise.Dependent.WithK.↣.
6363

@@ -193,16 +193,16 @@ module _ where
193193
to′ : Σ I A Σ J B
194194
to′ = map (to I↠J) (to A↠B)
195195

196-
backcast : {i} B i B (to I↠J (to⁻ I↠J i))
196+
backcast : {i} B i B (to I↠J (section I↠J i))
197197
backcast = ≡.subst B (≡.sym (to∘to⁻ I↠J _))
198198

199199
to⁻′ : Σ J B Σ I A
200-
to⁻′ = map (to⁻ I↠J) (Surjection.to⁻ A↠B ∘ backcast)
200+
to⁻′ = map (section I↠J) (Surjection.section A↠B ∘ backcast)
201201

202202
strictlySurjective′ : StrictlySurjective _≡_ to′
203203
strictlySurjective′ (x , y) = to⁻′ (x , y) , Σ-≡,≡→≡
204204
( to∘to⁻ I↠J x
205-
, (≡.subst B (to∘to⁻ I↠J x) (to A↠B (to⁻ A↠B (backcast y))) ≡⟨ ≡.cong (≡.subst B _) (to∘to⁻ A↠B _) ⟩
205+
, (≡.subst B (to∘to⁻ I↠J x) (to A↠B (section A↠B (backcast y))) ≡⟨ ≡.cong (≡.subst B _) (to∘to⁻ A↠B _) ⟩
206206
≡.subst B (to∘to⁻ I↠J x) (backcast y) ≡⟨ ≡.subst-subst-sym (to∘to⁻ I↠J x) ⟩
207207
y ∎)
208208
) where open ≡.≡-Reasoning
@@ -249,7 +249,7 @@ module _ where
249249
Σ I A ↔ Σ J B
250250
Σ-↔ {I = I} {J = J} {A = A} {B = B} I↔J A↔B = mk↔ₛ′
251251
(Surjection.to surjection′)
252-
(Surjection.to⁻ surjection′)
252+
(Surjection.section surjection′)
253253
(Surjection.to∘to⁻ surjection′)
254254
left-inverse-of
255255
where
@@ -260,7 +260,7 @@ module _ where
260260
surjection′ : Σ I A ↠ Σ J B
261261
surjection′ = Σ-↠ (↔⇒↠ (≃⇒↔ I≃J)) (↔⇒↠ A↔B)
262262

263-
left-inverse-of : p Surjection.to⁻ surjection′ (Surjection.to surjection′ p) ≡ p
263+
left-inverse-of : p Surjection.section surjection′ (Surjection.to surjection′ p) ≡ p
264264
left-inverse-of (x , y) = to Σ-≡,≡↔≡
265265
( _≃_.left-inverse-of I≃J x
266266
, (≡.subst A (_≃_.left-inverse-of I≃J x)

src/Data/Product/Function/Dependent/Setoid.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module _ where
117117
B-to : {x} Func (A atₛ x) (B atₛ (Surjection.to I↠J x))
118118
B-to = toFunction A⇔B
119119

120-
B-from : {y} Func (B atₛ y) (A atₛ (Surjection.to⁻ I↠J y))
120+
B-from : {y} Func (B atₛ y) (A atₛ (Surjection.section I↠J y))
121121
B-from = record
122122
{ to = from A⇔B ∘ cast B (Surjection.to∘to⁻ I↠J _)
123123
; cong = from-cong A⇔B ∘ cast-cong B (Surjection.to∘to⁻ I↠J _)
@@ -169,7 +169,7 @@ module _ where
169169
func = function (Surjection.function I↠J) (Surjection.function A↠B)
170170

171171
to⁻′ : Carrier (J ×ₛ B) Carrier (I ×ₛ A)
172-
to⁻′ (j , y) = to⁻ I↠J j , to⁻ A↠B (cast B (Surjection.to∘to⁻ I↠J _) y)
172+
to⁻′ (j , y) = section I↠J j , section A↠B (cast B (Surjection.to∘to⁻ I↠J _) y)
173173

174174
strictlySurj : StrictlySurjective (Func.Eq₂._≈_ func) (Func.to func)
175175
strictlySurj (j , y) = to⁻′ (j , y) ,

src/Function/Bundles.agda

+10-3
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,17 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
113113
open IsSurjection isSurjection public
114114
using
115115
( strictlySurjective
116+
; section
116117
)
117118

118119
to⁻ : B A
119120
to⁻ = proj₁ ∘ surjective
121+
{-# WARNING_ON_USAGE to⁻
122+
"Warning: to⁻ was deprecated in v2.3.
123+
Please use Function.Structures.IsSurjection.section instead. "
124+
#-}
120125

121-
to∘to⁻ : x to (to⁻ x) ≈₂ x
126+
to∘to⁻ : x to (section x) ≈₂ x
122127
to∘to⁻ = proj₂ ∘ strictlySurjective
123128

124129

@@ -146,8 +151,10 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
146151
; surjective = surjective
147152
}
148153

149-
open Injection injection public using (isInjection)
150-
open Surjection surjection public using (isSurjection; to⁻; strictlySurjective)
154+
open Injection injection public
155+
using (isInjection)
156+
open Surjection surjection public
157+
using (isSurjection; section; to∘to⁻; strictlySurjective)
151158

152159
isBijection : IsBijection to
153160
isBijection = record

src/Function/Construct/Composition.agda

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) (≈₃ : Rel C ℓ₃)
4040

4141
surjective : Surjective ≈₁ ≈₂ f Surjective ≈₂ ≈₃ g
4242
Surjective ≈₁ ≈₃ (g ∘ f)
43-
surjective f-sur g-sur x with g-sur x
44-
... | y , gproof with f-sur y
45-
... | z , fproof = z , gproof ∘ fproof
43+
surjective f-sur g-sur x =
44+
let y , gproof = g-sur x in
45+
let z , fproof = f-sur y in
46+
z , gproof ∘ fproof
4647

4748
bijective : Bijective ≈₁ ≈₂ f Bijective ≈₂ ≈₃ g
4849
Bijective ≈₁ ≈₃ (g ∘ f)

src/Function/Construct/Symmetry.agda

+7-9
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,14 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂}
7171

7272
private
7373
module IB = IsBijection isBij
74-
f⁻¹ = proj₁ ∘ IB.surjective
7574

7675
-- We can only flip a bijection if the witness produced by the
7776
-- surjection proof respects the equality on the codomain.
78-
isBijection : Congruent ≈₂ ≈₁ f⁻¹ IsBijection ≈₂ ≈₁ f⁻¹
79-
isBijection f⁻¹-cong = record
77+
isBijection : Congruent ≈₂ ≈₁ IB.section IsBijection ≈₂ ≈₁ IB.section
78+
isBijection section-cong = record
8079
{ isInjection = record
8180
{ isCongruent = record
82-
{ cong = f⁻¹-cong
81+
{ cong = section-cong
8382
; isEquivalence₁ = IB.Eq₂.isEquivalence
8483
; isEquivalence₂ = IB.Eq₁.isEquivalence
8584
}
@@ -93,7 +92,7 @@ module _ {≈₁ : Rel A ℓ₁} {f : A → B} (isBij : IsBijection ≈₁ _≡_
9392
-- We can always flip a bijection if using the equality over the
9493
-- codomain is propositional equality.
9594
isBijection-≡ : IsBijection _≡_ ≈₁ _
96-
isBijection-≡ = isBijection isBij (IB.Eq₁.reflexive ∘ cong _)
95+
isBijection-≡ = isBijection isBij (IB.Eq₁.reflexive ∘ cong IB.section)
9796
where module IB = IsBijection isBij
9897

9998
module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A B} {f⁻¹ : B A} where
@@ -132,13 +131,12 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} (bij : Bijection R S) where
132131

133132
private
134133
module IB = Bijection bij
135-
from = proj₁ ∘ IB.surjective
136134

137135
-- We can only flip a bijection if the witness produced by the
138136
-- surjection proof respects the equality on the codomain.
139-
bijection : Congruent IB.Eq₂._≈_ IB.Eq₁._≈_ from Bijection S R
137+
bijection : Congruent IB.Eq₂._≈_ IB.Eq₁._≈_ IB.section Bijection S R
140138
bijection cong = record
141-
{ to = from
139+
{ to = IB.section
142140
; cong = cong
143141
; bijective = bijective IB.bijective IB.Eq₁.refl IB.Eq₂.sym IB.Eq₂.trans IB.cong
144142
}
@@ -191,7 +189,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} where
191189
-- Propositional bundles
192190

193191
⤖-sym : A ⤖ B B ⤖ A
194-
⤖-sym b = bijection b (cong _)
192+
⤖-sym b = bijection b (cong section) where open Bijection b using (section)
195193

196194
⇔-sym : A ⇔ B B ⇔ A
197195
⇔-sym = equivalence

src/Function/Properties/Bijection.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ trans = Composition.bijection
6060
Bijection⇒Inverse : Bijection S T Inverse S T
6161
Bijection⇒Inverse bij = record
6262
{ to = to
63-
; from = to⁻
63+
; from = section
6464
; to-cong = cong
6565
; from-cong = injective⇒to⁻-cong surjection injective
6666
; inverse = (λ y≈to⁻[x] Eq₂.trans (cong y≈to⁻[x]) (to∘to⁻ _)) ,
6767
(λ y≈to[x] injective (Eq₂.trans (to∘to⁻ _) y≈to[x]))
6868
}
69-
where open Bijection bij; to∘to⁻ = proj₂ ∘ strictlySurjective
69+
where open Bijection bij
7070

7171
Bijection⇒Equivalence : Bijection T S Equivalence T S
7272
Bijection⇒Equivalence = Inverse⇒Equivalence ∘ Bijection⇒Inverse

src/Function/Properties/Surjection.agda

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ mkSurjection f surjective = record
4545
↠⇒⟶ = Surjection.function
4646

4747
↠⇒↪ : A ↠ B B ↪ A
48-
↠⇒↪ s = mk↪ {from = to} λ { ≡.refl proj₂ (strictlySurjective _)}
48+
↠⇒↪ s = mk↪ {from = to} λ { ≡.refl to∘to⁻ _ }
4949
where open Surjection s
5050

5151
↠⇒⇔ : A ↠ B A ⇔ B
52-
↠⇒⇔ s = mk⇔ to (proj₁ ∘ surjective)
52+
↠⇒⇔ s = mk⇔ to section
5353
where open Surjection s
5454

5555
------------------------------------------------------------------------
@@ -69,12 +69,12 @@ trans = Compose.surjection
6969
injective⇒to⁻-cong : (surj : Surjection S T)
7070
(open Surjection surj)
7171
Injective Eq₁._≈_ Eq₂._≈_ to
72-
Congruent Eq₂._≈_ Eq₁._≈_ to⁻
72+
Congruent Eq₂._≈_ Eq₁._≈_ section
7373
injective⇒to⁻-cong {T = T} surj injective {x} {y} x≈y = injective $ begin
74-
to (to⁻ x) ≈⟨ to∘to⁻ x ⟩
75-
x ≈⟨ x≈y ⟩
76-
y ≈⟨ to∘to⁻ y ⟨
77-
to (to⁻ y) ∎
74+
to (section x) ≈⟨ to∘to⁻ x ⟩
75+
x ≈⟨ x≈y ⟩
76+
y ≈⟨ to∘to⁻ y ⟨
77+
to (section y) ∎
7878
where
7979
open ≈-Reasoning T
8080
open Surjection surj

src/Function/Structures.agda

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Function.Structures {a b ℓ₁ ℓ₂}
1717
{B : Set b} (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain
1818
where
1919

20-
open import Data.Product.Base as Product using (∃; _×_; _,_)
20+
open import Data.Product.Base as Product using (∃; _×_; _,_; proj₁; proj₂)
2121
open import Function.Base
2222
open import Function.Definitions
2323
open import Level using (_⊔_)
@@ -69,6 +69,12 @@ record IsSurjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
6969
strictlySurjective : StrictlySurjective _≈₂_ f
7070
strictlySurjective x = Product.map₂ (λ v v Eq₁.refl) (surjective x)
7171

72+
section : B A
73+
section = proj₁ ∘ surjective
74+
75+
section-inverseˡ : Inverseˡ _≈₁_ _≈₂_ f section
76+
section-inverseˡ = λ y≈fx (proj₂ ∘ surjective) _ y≈fx
77+
7278

7379
record IsBijection (f : A B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
7480
field
@@ -87,7 +93,7 @@ record IsBijection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
8793
}
8894

8995
open IsSurjection isSurjection public
90-
using (strictlySurjective)
96+
using (strictlySurjective; section)
9197

9298

9399
------------------------------------------------------------------------

0 commit comments

Comments
 (0)