Skip to content

Commit 9a71200

Browse files
committed
Change to using strict inverses
1 parent 82d5f19 commit 9a71200

File tree

3 files changed

+50
-56
lines changed

3 files changed

+50
-56
lines changed

src/Function/Construct/Composition.agda

+24-30
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,33 @@ module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) (≈₃ : Rel C ℓ₃)
3535
Injective ≈₁ ≈₃ (g ∘ f)
3636
injective f-inj g-inj = f-inj ∘ g-inj
3737

38-
surjective : Transitive ≈₃ Congruent ≈₂ ≈₃ g
39-
Surjective ≈₁ ≈₂ f Surjective ≈₂ ≈₃ g
38+
surjective : Surjective ≈₁ ≈₂ f Surjective ≈₂ ≈₃ g
4039
Surjective ≈₁ ≈₃ (g ∘ f)
41-
surjective trans g-cong f-sur g-sur x with g-sur x
42-
... | y , fy≈x with f-sur y
43-
... | z , fz≈y = z , trans (g-cong fz≈y) fy≈x
40+
surjective f-sur g-sur x with g-sur x
41+
... | y , gproof with f-sur y
42+
... | z , fproof = z , λ a a≈z gproof (f a) (fproof a a≈z)
4443

45-
bijective : Transitive ≈₃ Congruent ≈₂ ≈₃ g
46-
Bijective ≈₁ ≈₂ f Bijective ≈₂ ≈₃ g
44+
bijective : Bijective ≈₁ ≈₂ f Bijective ≈₂ ≈₃ g
4745
Bijective ≈₁ ≈₃ (g ∘ f)
48-
bijective trans g-cong (f-inj , f-sur) (g-inj , g-sur) =
49-
injective f-inj g-inj , surjective trans g-cong f-sur g-sur
46+
bijective (f-inj , f-sur) (g-inj , g-sur) =
47+
injective f-inj g-inj , surjective f-sur g-sur
5048

5149
module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) (≈₃ : Rel C ℓ₃)
5250
(f : A B) {f⁻¹ : B A} {g : B C} (g⁻¹ : C B)
5351
where
5452

55-
inverseˡ : Transitive ≈₃ Congruent ≈₂ ≈₃ g
56-
Inverseˡ ≈₁ ≈₂ f f⁻¹ Inverseˡ ≈₂ ≈₃ g g⁻¹
53+
inverseˡ : Inverseˡ ≈₁ ≈₂ f f⁻¹ Inverseˡ ≈₂ ≈₃ g g⁻¹
5754
Inverseˡ ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹)
58-
inverseˡ trn g-cong f-inv g-inv x = trn (g-cong (f-inv _)) (g-inv x)
55+
inverseˡ f-inv g-inv x y y≈gfx = g-inv x (f y) (f-inv (g⁻¹ x) y y≈gfx)
5956

60-
inverseʳ : Transitive ≈₁ Congruent ≈₂ ≈₁ f⁻¹
61-
Inverseʳ ≈₁ ≈₂ f f⁻¹ Inverseʳ ≈₂ ≈₃ g g⁻¹
57+
inverseʳ : Inverseʳ ≈₁ ≈₂ f f⁻¹ Inverseʳ ≈₂ ≈₃ g g⁻¹
6258
Inverseʳ ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹)
63-
inverseʳ trn f⁻¹-cong f-inv g-inv x = trn (f⁻¹-cong (g-inv _)) (f-inv x)
59+
inverseʳ f-inv g-inv x y y≈gfx = f-inv x (g⁻¹ y) (g-inv (f x) y y≈gfx)
6460

65-
inverseᵇ : Transitive ≈₁ Transitive ≈₃
66-
Congruent ≈₂ ≈₃ g Congruent ≈₂ ≈₁ f⁻¹
67-
Inverseᵇ ≈₁ ≈₂ f f⁻¹ Inverseᵇ ≈₂ ≈₃ g g⁻¹
61+
inverseᵇ : Inverseᵇ ≈₁ ≈₂ f f⁻¹ Inverseᵇ ≈₂ ≈₃ g g⁻¹
6862
Inverseᵇ ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹)
69-
inverseᵇ trn₁ trn₃ g-cong f⁻¹-cong (f-invˡ , f-invʳ) (g-invˡ , g-invʳ) =
70-
inverseˡ trn₃ g-cong f-invˡ g-invˡ , inverseʳ trn₁ f⁻¹-cong f-invʳ g-invʳ
63+
inverseᵇ (f-invˡ , f-invʳ) (g-invˡ , g-invʳ) =
64+
inverseˡ f-invˡ g-invˡ , inverseʳ f-invʳ g-invʳ
7165

7266
------------------------------------------------------------------------
7367
-- Structures
@@ -95,14 +89,14 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {≈₃ : Rel C ℓ₃}
9589
IsSurjection ≈₁ ≈₃ (g ∘ f)
9690
isSurjection f-surj g-surj = record
9791
{ isCongruent = isCongruent F.isCongruent G.isCongruent
98-
; surjective = surjective ≈₁ ≈₂ ≈₃ G.Eq₂.trans G.cong F.surjective G.surjective
92+
; surjective = surjective ≈₁ ≈₂ ≈₃ F.surjective G.surjective
9993
} where module F = IsSurjection f-surj; module G = IsSurjection g-surj
10094

10195
isBijection : IsBijection ≈₁ ≈₂ f IsBijection ≈₂ ≈₃ g
10296
IsBijection ≈₁ ≈₃ (g ∘ f)
10397
isBijection f-bij g-bij = record
10498
{ isInjection = isInjection F.isInjection G.isInjection
105-
; surjective = surjective ≈₁ ≈₂ ≈₃ G.Eq₂.trans G.cong F.surjective G.surjective
99+
; surjective = surjective ≈₁ ≈₂ ≈₃ F.surjective G.surjective
106100
} where module F = IsBijection f-bij; module G = IsBijection g-bij
107101

108102
module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {≈₃ : Rel C ℓ₃}
@@ -114,22 +108,22 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {≈₃ : Rel C ℓ₃}
114108
isLeftInverse f-invˡ g-invˡ = record
115109
{ isCongruent = isCongruent F.isCongruent G.isCongruent
116110
; cong₂ = congruent ≈₃ ≈₂ ≈₁ G.cong₂ F.cong₂
117-
; inverseˡ = inverseˡ ≈₁ ≈₂ ≈₃ f _ G.Eq₂.trans G.cong₁ F.inverseˡ G.inverseˡ
111+
; inverseˡ = inverseˡ ≈₁ ≈₂ ≈₃ f _ F.inverseˡ G.inverseˡ
118112
} where module F = IsLeftInverse f-invˡ; module G = IsLeftInverse g-invˡ
119113

120114
isRightInverse : IsRightInverse ≈₁ ≈₂ f f⁻¹ IsRightInverse ≈₂ ≈₃ g g⁻¹
121115
IsRightInverse ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹)
122116
isRightInverse f-invʳ g-invʳ = record
123117
{ isCongruent = isCongruent F.isCongruent G.isCongruent
124118
; cong₂ = congruent ≈₃ ≈₂ ≈₁ G.cong₂ F.cong₂
125-
; inverseʳ = inverseʳ ≈₁ ≈₂ ≈₃ _ g⁻¹ F.Eq₁.trans F.cong₂ F.inverseʳ G.inverseʳ
119+
; inverseʳ = inverseʳ ≈₁ ≈₂ ≈₃ _ g⁻¹ F.inverseʳ G.inverseʳ
126120
} where module F = IsRightInverse f-invʳ; module G = IsRightInverse g-invʳ
127121

128122
isInverse : IsInverse ≈₁ ≈₂ f f⁻¹ IsInverse ≈₂ ≈₃ g g⁻¹
129123
IsInverse ≈₁ ≈₃ (g ∘ f) (f⁻¹ ∘ g⁻¹)
130124
isInverse f-inv g-inv = record
131125
{ isLeftInverse = isLeftInverse F.isLeftInverse G.isLeftInverse
132-
; inverseʳ = inverseʳ ≈₁ ≈₂ ≈₃ _ g⁻¹ F.Eq₁.trans F.cong₂ F.inverseʳ G.inverseʳ
126+
; inverseʳ = inverseʳ ≈₁ ≈₂ ≈₃ _ g⁻¹ F.inverseʳ G.inverseʳ
133127
} where module F = IsInverse f-inv; module G = IsInverse g-inv
134128

135129
------------------------------------------------------------------------
@@ -150,14 +144,14 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} {T : Setoid c ℓ₃} where
150144
surjection surj₁ surj₂ = record
151145
{ f = G.f ∘ F.f
152146
; cong = congruent (≈ R) (≈ S) (≈ T) F.cong G.cong
153-
; surjective = surjective (≈ R) (≈ S) (≈ T) G.Eq₂.trans G.cong F.surjective G.surjective
147+
; surjective = surjective (≈ R) (≈ S) (≈ T) F.surjective G.surjective
154148
} where module F = Surjection surj₁; module G = Surjection surj₂
155149

156150
bijection : Bijection R S Bijection S T Bijection R T
157151
bijection bij₁ bij₂ = record
158152
{ f = G.f ∘ F.f
159153
; cong = congruent (≈ R) (≈ S) (≈ T) F.cong G.cong
160-
; bijective = bijective (≈ R) (≈ S) (≈ T) (trans T) G.cong F.bijective G.bijective
154+
; bijective = bijective (≈ R) (≈ S) (≈ T) F.bijective G.bijective
161155
} where module F = Bijection bij₁; module G = Bijection bij₂
162156

163157
equivalence : Equivalence R S Equivalence S T Equivalence R T
@@ -174,7 +168,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} {T : Setoid c ℓ₃} where
174168
; g = F.g ∘ G.g
175169
; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁
176170
; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂
177-
; inverseˡ = inverseˡ (≈ R) (≈ S) (≈ T) F.f _ (trans T) G.cong₁ F.inverseˡ G.inverseˡ
171+
; inverseˡ = inverseˡ (≈ R) (≈ S) (≈ T) F.f _ F.inverseˡ G.inverseˡ
178172
} where module F = LeftInverse invˡ₁; module G = LeftInverse invˡ₂
179173

180174
rightInverse : RightInverse R S RightInverse S T RightInverse R T
@@ -183,7 +177,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} {T : Setoid c ℓ₃} where
183177
; g = F.g ∘ G.g
184178
; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁
185179
; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂
186-
; inverseʳ = inverseʳ (≈ R) (≈ S) (≈ T) _ G.g (trans R) F.cong₂ F.inverseʳ G.inverseʳ
180+
; inverseʳ = inverseʳ (≈ R) (≈ S) (≈ T) _ G.g F.inverseʳ G.inverseʳ
187181
} where module F = RightInverse invʳ₁; module G = RightInverse invʳ₂
188182

189183
inverse : Inverse R S Inverse S T Inverse R T
@@ -192,7 +186,7 @@ module _ {R : Setoid a ℓ₁} {S : Setoid b ℓ₂} {T : Setoid c ℓ₃} where
192186
; f⁻¹ = F.f⁻¹ ∘ G.f⁻¹
193187
; cong₁ = congruent (≈ R) (≈ S) (≈ T) F.cong₁ G.cong₁
194188
; cong₂ = congruent (≈ T) (≈ S) (≈ R) G.cong₂ F.cong₂
195-
; inverse = inverseᵇ (≈ R) (≈ S) (≈ T) _ G.f⁻¹ (trans R) (trans T) G.cong₁ F.cong₂ F.inverse G.inverse
189+
; inverse = inverseᵇ (≈ R) (≈ S) (≈ T) _ G.f⁻¹ F.inverse G.inverse
196190
} where module F = Inverse inv₁; module G = Inverse inv₂
197191

198192
------------------------------------------------------------------------

src/Function/Construct/Identity.agda

+20-20
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ module _ (_≈_ : Rel A ℓ) where
3232
injective : Injective id
3333
injective = id
3434

35-
surjective : Reflexive _≈_ Surjective id
36-
surjective refl x = x , refl
35+
surjective : Surjective id
36+
surjective x = x , λ z z≈x z≈x
3737

38-
bijective : Reflexive _≈_ Bijective id
39-
bijective refl = injective , surjective refl
38+
bijective : Bijective id
39+
bijective = injective , surjective
4040

41-
inverseˡ : Reflexive _≈_ Inverseˡ id id
42-
inverseˡ refl x = refl
41+
inverseˡ : Inverseˡ id id
42+
inverseˡ x y y≈x = y≈x
4343

44-
inverseʳ : Reflexive _≈_ Inverseʳ id id
45-
inverseʳ refl x = refl
44+
inverseʳ : Inverseʳ id id
45+
inverseʳ x y y≈x = y≈x
4646

47-
inverseᵇ : Reflexive _≈_ Inverseᵇ id id
48-
inverseᵇ refl = inverseˡ refl , inverseʳ refl
47+
inverseᵇ : Inverseᵇ id id
48+
inverseᵇ = inverseˡ , inverseʳ
4949

5050
------------------------------------------------------------------------
5151
-- Structures
@@ -71,33 +71,33 @@ module _ {_≈_ : Rel A ℓ} (isEq : IsEquivalence _≈_) where
7171
isSurjection : IsSurjection id
7272
isSurjection = record
7373
{ isCongruent = isCongruent
74-
; surjective = surjective _≈_ refl
74+
; surjective = surjective _≈_
7575
}
7676

7777
isBijection : IsBijection id
7878
isBijection = record
7979
{ isInjection = isInjection
80-
; surjective = surjective _≈_ refl
80+
; surjective = surjective _≈_
8181
}
8282

8383
isLeftInverse : IsLeftInverse id id
8484
isLeftInverse = record
8585
{ isCongruent = isCongruent
8686
; cong₂ = id
87-
; inverseˡ = inverseˡ _≈_ refl
87+
; inverseˡ = inverseˡ _≈_
8888
}
8989

9090
isRightInverse : IsRightInverse id id
9191
isRightInverse = record
9292
{ isCongruent = isCongruent
9393
; cong₂ = id
94-
; inverseʳ = inverseʳ _≈_ refl
94+
; inverseʳ = inverseʳ _≈_
9595
}
9696

9797
isInverse : IsInverse id id
9898
isInverse = record
9999
{ isLeftInverse = isLeftInverse
100-
; inverseʳ = inverseʳ _≈_ refl
100+
; inverseʳ = inverseʳ _≈_
101101
}
102102

103103
------------------------------------------------------------------------
@@ -118,14 +118,14 @@ module _ (S : Setoid a ℓ) where
118118
surjection = record
119119
{ f = id
120120
; cong = id
121-
; surjective = surjective _≈_ refl
121+
; surjective = surjective _≈_
122122
}
123123

124124
bijection : Bijection S S
125125
bijection = record
126126
{ f = id
127127
; cong = id
128-
; bijective = bijective _≈_ refl
128+
; bijective = bijective _≈_
129129
}
130130

131131
equivalence : Equivalence S S
@@ -142,7 +142,7 @@ module _ (S : Setoid a ℓ) where
142142
; g = id
143143
; cong₁ = id
144144
; cong₂ = id
145-
; inverseˡ = inverseˡ _≈_ refl
145+
; inverseˡ = inverseˡ _≈_
146146
}
147147

148148
rightInverse : RightInverse S S
@@ -151,7 +151,7 @@ module _ (S : Setoid a ℓ) where
151151
; g = id
152152
; cong₁ = id
153153
; cong₂ = id
154-
; inverseʳ = inverseʳ _≈_ refl
154+
; inverseʳ = inverseʳ _≈_
155155
}
156156

157157
inverse : Inverse S S
@@ -160,7 +160,7 @@ module _ (S : Setoid a ℓ) where
160160
; f⁻¹ = id
161161
; cong₁ = id
162162
; cong₂ = id
163-
; inverse = inverseᵇ _≈_ refl
163+
; inverse = inverseᵇ _≈_
164164
}
165165

166166
------------------------------------------------------------------------

src/Function/Definitions.agda

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ Congruent f = ∀ {x y} → x ≈₁ y → f x ≈₂ f y
3030
Injective : (A B) Set (a ⊔ ℓ₁ ⊔ ℓ₂)
3131
Injective f = {x y} f x ≈₂ f y x ≈₁ y
3232

33-
open Core₂ _≈₂_ public
34-
using (Surjective)
33+
Surjective : (A B) Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
34+
Surjective f = y λ x z z ≈₁ x f z ≈₂ y
3535

3636
Bijective : (A B) Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
3737
Bijective f = Injective f × Surjective f
3838

39-
open Core₂ _≈₂_ public
40-
using (Inverseˡ)
39+
Inverseˡ : (A B) (B A) Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
40+
Inverseˡ f g = x y y ≈₁ g x f y ≈₂ x
4141

42-
open Core₁ _≈₁_ public
43-
using (Inverseʳ)
42+
Inverseʳ : (A B) (B A) Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
43+
Inverseʳ f g = x y y ≈₂ f x g y ≈₁ x
4444

4545
Inverseᵇ : (A B) (B A) Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂)
4646
Inverseᵇ f g = Inverseˡ f g × Inverseʳ f g

0 commit comments

Comments
 (0)