Skip to content

Commit 99337d9

Browse files
committed
refactor: v3.0 version of agda#2569
1 parent 94906c0 commit 99337d9

File tree

7 files changed

+189
-156
lines changed

7 files changed

+189
-156
lines changed

src/Function/Bundles.agda

+45-12
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
module Function.Bundles where
2121

2222
open import Function.Base using (_∘_)
23+
open import Function.Consequences.Propositional
24+
using (strictlySurjective⇒surjective; strictlyInverseˡ⇒inverseˡ; strictlyInverseʳ⇒inverseʳ)
2325
open import Function.Definitions
2426
import Function.Structures as FunctionStructures
2527
open import Level using (Level; _⊔_; suc)
2628
open import Data.Product.Base using (_,_; proj₁; proj₂)
2729
open import Relation.Binary.Bundles using (Setoid)
28-
open import Relation.Binary.Core using (_Preserves_⟶_)
2930
open import Relation.Binary.PropositionalEquality.Core as ≡
3031
using (_≡_)
3132
import Relation.Binary.PropositionalEquality.Properties as ≡
32-
open import Function.Consequences.Propositional
3333
open Setoid using (isEquivalence)
3434

3535
private
@@ -113,13 +113,24 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
113113
open IsSurjection isSurjection public
114114
using
115115
( strictlySurjective
116+
; from
117+
; inverseˡ
118+
; strictlyInverseˡ
116119
)
117120

118121
to⁻ : B A
119-
to⁻ = proj₁ ∘ surjective
122+
to⁻ = from
123+
{-# WARNING_ON_USAGE to⁻
124+
"Warning: to⁻ was deprecated in v2.3.
125+
Please use Function.Structures.IsSurjection.from instead. "
126+
#-}
120127

121-
to∘to⁻ : x to (to⁻ x) ≈₂ x
122-
to∘to⁻ = proj₂ ∘ strictlySurjective
128+
to∘to⁻ : StrictlyInverseˡ _≈₂_ to from
129+
to∘to⁻ = strictlyInverseˡ
130+
{-# WARNING_ON_USAGE to∘to⁻
131+
"Warning: to∘to⁻ was deprecated in v2.3.
132+
Please use Function.Structures.IsSurjection.strictlyInverseˡ instead. "
133+
#-}
123134

124135

125136
record Bijection : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
@@ -146,16 +157,27 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
146157
; surjective = surjective
147158
}
148159

149-
open Injection injection public using (isInjection)
150-
open Surjection surjection public using (isSurjection; to⁻; strictlySurjective)
160+
open Injection injection public
161+
using (isInjection)
162+
open Surjection surjection public
163+
using (isSurjection
164+
; strictlySurjective
165+
; from
166+
; inverseˡ
167+
; strictlyInverseˡ
168+
)
151169

152170
isBijection : IsBijection to
153171
isBijection = record
154172
{ isInjection = isInjection
155173
; surjective = surjective
156174
}
157175

158-
open IsBijection isBijection public using (module Eq₁; module Eq₂)
176+
open IsBijection isBijection public
177+
using (module Eq₁; module Eq₂
178+
; inverseʳ; strictlyInverseʳ
179+
; from-cong; from-injective; from-surjective; from-bijective
180+
)
159181

160182

161183
------------------------------------------------------------------------
@@ -220,6 +242,8 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
220242
open IsLeftInverse isLeftInverse public
221243
using (module Eq₁; module Eq₂; strictlyInverseˡ; isSurjection)
222244

245+
open IsSurjection isSurjection public using (surjective)
246+
223247
equivalence : Equivalence
224248
equivalence = record
225249
{ to-cong = to-cong
@@ -236,7 +260,7 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
236260
surjection = record
237261
{ to = to
238262
; cong = to-cong
239-
; surjective = λ y from y , inverseˡ
263+
; surjective = surjective
240264
}
241265

242266

@@ -246,7 +270,7 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
246270
to : A B
247271
from : B A
248272
to-cong : Congruent _≈₁_ _≈₂_ to
249-
from-cong : from Preserves _≈₂_ _≈₁_
273+
from-cong : Congruent _≈₂_ _≈₁_ from
250274
inverseʳ : Inverseʳ _≈₁_ _≈₂_ to from
251275

252276
isCongruent : IsCongruent to
@@ -264,14 +288,23 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
264288
}
265289

266290
open IsRightInverse isRightInverse public
267-
using (module Eq₁; module Eq₂; strictlyInverseʳ)
291+
using (module Eq₁; module Eq₂; strictlyInverseʳ; isInjection)
292+
293+
open IsInjection isInjection public using (injective)
268294

269295
equivalence : Equivalence
270296
equivalence = record
271297
{ to-cong = to-cong
272298
; from-cong = from-cong
273299
}
274300

301+
injection : Injection From To
302+
injection = record
303+
{ to = to
304+
; cong = to-cong
305+
; injective = injective
306+
}
307+
275308

276309
record Inverse : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where
277310
field
@@ -370,7 +403,7 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
370403
-- function for elements `x₁` and `x₂` are equal if `x₁ ≈ x₂` .
371404
--
372405
-- The difference is the `from-cong` law --- generally, the section
373-
-- (called `Surjection.to⁻` or `SplitSurjection.from`) of a surjection
406+
-- (called `Surjection.from` or `SplitSurjection.from`) of a surjection
374407
-- need not respect equality, whereas it must in a split surjection.
375408
--
376409
-- The two notions coincide when the equivalence relation on `B` is

src/Function/Consequences.agda

+12-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
module Function.Consequences where
1212

1313
open import Data.Product.Base as Product
14+
open import Function.Base using (_∘_)
1415
open import Function.Definitions
1516
open import Level using (Level)
1617
open import Relation.Binary.Core using (Rel)
@@ -23,22 +24,23 @@ private
2324
a b ℓ₁ ℓ₂ : Level
2425
A B : Set a
2526
≈₁ ≈₂ : Rel A ℓ₁
26-
f f⁻¹ : A B
27+
f : A B
28+
f⁻¹ : B A
2729

2830
------------------------------------------------------------------------
2931
-- Injective
3032

3133
contraInjective : (≈₂ : Rel B ℓ₂) Injective ≈₁ ≈₂ f
3234
{x y} ¬ (≈₁ x y) ¬ (≈₂ (f x) (f y))
33-
contraInjective _ inj p = contraposition inj p
35+
contraInjective _ inj = contraposition inj
3436

3537
------------------------------------------------------------------------
3638
-- Inverseˡ
3739

3840
inverseˡ⇒surjective : (≈₂ : Rel B ℓ₂)
3941
Inverseˡ ≈₁ ≈₂ f f⁻¹
4042
Surjective ≈₁ ≈₂ f
41-
inverseˡ⇒surjective ≈₂ invˡ y = (_ , invˡ)
43+
inverseˡ⇒surjective ≈₂ invˡ _ = (_ , invˡ)
4244

4345
------------------------------------------------------------------------
4446
-- Inverseʳ
@@ -49,8 +51,7 @@ inverseʳ⇒injective : ∀ (≈₂ : Rel B ℓ₂) f →
4951
Transitive ≈₁
5052
Inverseʳ ≈₁ ≈₂ f f⁻¹
5153
Injective ≈₁ ≈₂ f
52-
inverseʳ⇒injective ≈₂ f refl sym trans invʳ {x} {y} fx≈fy =
53-
trans (sym (invʳ refl)) (invʳ fx≈fy)
54+
inverseʳ⇒injective ≈₂ f refl sym trans invʳ = trans (sym (invʳ refl)) ∘ invʳ
5455

5556
------------------------------------------------------------------------
5657
-- Inverseᵇ
@@ -71,8 +72,7 @@ surjective⇒strictlySurjective : ∀ (≈₂ : Rel B ℓ₂) →
7172
Reflexive ≈₁
7273
Surjective ≈₁ ≈₂ f
7374
StrictlySurjective ≈₂ f
74-
surjective⇒strictlySurjective _ refl surj x =
75-
Product.map₂ (λ v v refl) (surj x)
75+
surjective⇒strictlySurjective _ refl surj = Product.map₂ (λ v v refl) ∘ surj
7676

7777
strictlySurjective⇒surjective : Transitive ≈₂
7878
Congruent ≈₁ ≈₂ f
@@ -104,11 +104,13 @@ inverseʳ⇒strictlyInverseʳ : ∀ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ
104104
Reflexive ≈₂
105105
Inverseʳ ≈₁ ≈₂ f f⁻¹
106106
StrictlyInverseʳ ≈₁ f f⁻¹
107-
inverseʳ⇒strictlyInverseʳ _ _ refl sinv x = sinv refl
107+
inverseʳ⇒strictlyInverseʳ {f = f} {f⁻¹ = f⁻¹} ≈₁ ≈₂ =
108+
inverseˡ⇒strictlyInverseˡ {f = f⁻¹} {f⁻¹ = f} ≈₂ ≈₁
108109

109110
strictlyInverseʳ⇒inverseʳ : Transitive ≈₁
110111
Congruent ≈₂ ≈₁ f⁻¹
111112
StrictlyInverseʳ ≈₁ f f⁻¹
112113
Inverseʳ ≈₁ ≈₂ f f⁻¹
113-
strictlyInverseʳ⇒inverseʳ trans cong sinv {x} y≈f⁻¹x =
114-
trans (cong y≈f⁻¹x) (sinv x)
114+
strictlyInverseʳ⇒inverseʳ {≈₁ = ≈₁} {≈₂ = ≈₂} {f⁻¹ = f⁻¹} {f = f} =
115+
strictlyInverseˡ⇒inverseˡ {≈₂ = ≈₁} {≈₁ = ≈₂} {f = f⁻¹} {f⁻¹ = f}
116+

src/Function/Consequences/Propositional.agda

+9-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ module Function.Consequences.Propositional
1111
{a b} {A : Set a} {B : Set b}
1212
where
1313

14-
open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_; cong)
14+
open import Data.Product.Base using (_,_)
15+
open import Function.Definitions
16+
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)
1517
open import Relation.Binary.PropositionalEquality.Properties
1618
using (setoid)
17-
open import Function.Definitions
18-
open import Relation.Nullary.Negation.Core using (contraposition)
19-
20-
import Function.Consequences.Setoid (setoid A) (setoid B) as Setoid
2119

2220
------------------------------------------------------------------------
2321
-- Re-export setoid properties
2422

25-
open Setoid public
23+
open import Function.Consequences.Setoid (setoid A) (setoid B) public
2624
hiding
2725
( strictlySurjective⇒surjective
2826
; strictlyInverseˡ⇒inverseˡ
@@ -39,15 +37,14 @@ private
3937

4038
strictlySurjective⇒surjective : StrictlySurjective _≡_ f
4139
Surjective _≡_ _≡_ f
42-
strictlySurjective⇒surjective =
43-
Setoid.strictlySurjective⇒surjective (cong _)
40+
strictlySurjective⇒surjective surj y =
41+
let x , fx≡y = surj y in x , λ where refl fx≡y
4442

4543
strictlyInverseˡ⇒inverseˡ : f StrictlyInverseˡ _≡_ f f⁻¹
4644
Inverseˡ _≡_ _≡_ f f⁻¹
47-
strictlyInverseˡ⇒inverseˡ f =
48-
Setoid.strictlyInverseˡ⇒inverseˡ (cong _)
45+
strictlyInverseˡ⇒inverseˡ _ inv refl = inv _
4946

5047
strictlyInverseʳ⇒inverseʳ : f StrictlyInverseʳ _≡_ f f⁻¹
5148
Inverseʳ _≡_ _≡_ f f⁻¹
52-
strictlyInverseʳ⇒inverseʳ f =
53-
Setoid.strictlyInverseʳ⇒inverseʳ (cong _)
49+
strictlyInverseʳ⇒inverseʳ _ inv refl = inv _
50+

0 commit comments

Comments
 (0)