Skip to content

Commit 6522369

Browse files
committed
refactor: simplify Quotients
1 parent 3ac84f3 commit 6522369

File tree

3 files changed

+94
-87
lines changed

3 files changed

+94
-87
lines changed

src/Algebra/Construct/Quotient/AbelianGroup.agda

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
open import Algebra.Bundles using (Group; AbelianGroup)
1010
import Algebra.Construct.Sub.AbelianGroup as AbelianSubgroup
11+
import Algebra.Construct.Quotient.Group as Quotient
1112

1213
module Algebra.Construct.Quotient.AbelianGroup
1314
{c ℓ} (G : AbelianGroup c ℓ)
@@ -20,16 +21,19 @@ private
2021

2122
-- Re-export the quotient group
2223

23-
open import Algebra.Construct.Quotient.Group G.group (normalSubgroup N) public
24+
open Quotient G.group (normalSubgroup N) public
25+
hiding (_/_)
2426

2527
-- With its additional bundle
2628

27-
quotientAbelianGroup : AbelianGroup c _
28-
quotientAbelianGroup = record
29+
abelianGroup : AbelianGroup c _
30+
abelianGroup = record
2931
{ isAbelianGroup = record
3032
{ isGroup = isGroup
3133
; comm = λ g h ≈⇒≋ (G.comm g h)
3234
}
33-
} where open Group quotientGroup
35+
} where open Group group
3436

35-
-- Public re-exports, as needed?
37+
-- Public re-exports
38+
39+
_/_ = abelianGroup

src/Algebra/Construct/Quotient/Group.agda

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ module Algebra.Construct.Quotient.Group
1313
{c ℓ} (G : Group c ℓ) {c′ ℓ′} (N : NormalSubgroup G c′ ℓ′) where
1414

1515
open import Algebra.Definitions using (Congruent₁; Congruent₂)
16-
open import Algebra.Morphism.Structures
17-
using (IsMagmaHomomorphism; IsMonoidHomomorphism; IsGroupHomomorphism)
16+
open import Algebra.Morphism.Structures using (IsGroupHomomorphism)
1817
open import Data.Product.Base using (_,_)
1918
open import Function.Base using (_∘_)
2019
open import Function.Definitions using (Surjective)
@@ -24,103 +23,106 @@ open import Relation.Binary.Definitions using (Reflexive; Symmetric; Transitive)
2423

2524
private
2625
open module G = Group G
27-
28-
open import Algebra.Properties.Group G using (⁻¹-anti-homo-∙)
29-
open import Algebra.Properties.Monoid monoid
30-
open import Relation.Binary.Reasoning.Setoid setoid
31-
32-
private
26+
using (_≈_; _∙_; ε; _⁻¹)
3327
open module N = NormalSubgroup N
3428
using (ι; module ι; conjugate; normal)
3529

30+
open import Algebra.Properties.Group G using (⁻¹-anti-homo-∙)
31+
open import Algebra.Properties.Monoid G.monoid
32+
open import Relation.Binary.Reasoning.Setoid G.setoid
33+
3634
infix 0 _by_
3735

38-
data _≋_ (x y : Carrier) : Set (c ⊔ ℓ ⊔ c′) where
36+
data _≋_ (x y : G.Carrier) : Set (c ⊔ ℓ ⊔ c′) where
3937
_by_ : g ι g ∙ x ≈ y x ≋ y
4038

4139
≈⇒≋ : _≈_ ⇒ _≋_
42-
≈⇒≋ x≈y = N.ε by trans (∙-cong ι.ε-homo x≈y) (identityˡ _)
40+
≈⇒≋ x≈y = N.ε by G.trans (G.∙-cong ι.ε-homo x≈y) (G.identityˡ _)
4341

44-
≋-refl : Reflexive _≋_
45-
≋-refl = ≈⇒≋ refl
42+
refl : Reflexive _≋_
43+
refl = ≈⇒≋ G.refl
4644

47-
≋-sym : Symmetric _≋_
48-
≋-sym {x} {y} (g by ιg∙x≈y) = g N.⁻¹ by begin
49-
ι (g N.⁻¹) ∙ y ≈⟨ ∙-cong (ι.⁻¹-homo g) (sym ιg∙x≈y) ⟩
50-
ι g ⁻¹ ∙ (ι g ∙ x) ≈⟨ cancelˡ (inverseˡ (ι g)) x ⟩
45+
sym : Symmetric _≋_
46+
sym {x} {y} (g by ιg∙x≈y) = g N.⁻¹ by begin
47+
ι (g N.⁻¹) ∙ y ≈⟨ G.∙-cong (ι.⁻¹-homo g) (G.sym ιg∙x≈y) ⟩
48+
ι g ⁻¹ ∙ (ι g ∙ x) ≈⟨ cancelˡ (G.inverseˡ (ι g)) x ⟩
5149
x ∎
5250

53-
≋-trans : Transitive _≋_
54-
≋-trans {x} {y} {z} (g by ιg∙x≈y) (h by ιh∙y≈z) = h N.∙ g by begin
55-
ι (h N.∙ g) ∙ x ≈⟨ ∙-congʳ (ι.∙-homo h g) ⟩
51+
trans : Transitive _≋_
52+
trans {x} {y} {z} (g by ιg∙x≈y) (h by ιh∙y≈z) = h N.∙ g by begin
53+
ι (h N.∙ g) ∙ x ≈⟨ G.∙-congʳ (ι.∙-homo h g) ⟩
5654
(ι h ∙ ι g) ∙ x ≈⟨ uv≈w⇒xu∙v≈xw ιg∙x≈y (ι h) ⟩
5755
ι h ∙ y ≈⟨ ιh∙y≈z ⟩
5856
z ∎
5957

60-
≋-∙-cong : Congruent₂ _≋_ _∙_
61-
≋-∙-cong {x} {y} {u} {v} (g by ιg∙x≈y) (h by ιh∙u≈v) = g N.∙ h′ by begin
62-
ι (g N.∙ h′) ∙ (x ∙ u) ≈⟨ ∙-congʳ (ι.∙-homo g h′) ⟩
58+
∙-cong : Congruent₂ _≋_ _∙_
59+
∙-cong {x} {y} {u} {v} (g by ιg∙x≈y) (h by ιh∙u≈v) = g N.∙ h′ by begin
60+
ι (g N.∙ h′) ∙ (x ∙ u) ≈⟨ G.∙-congʳ (ι.∙-homo g h′) ⟩
6361
(ι g ∙ ι h′) ∙ (x ∙ u) ≈⟨ uv≈wx⇒yu∙vz≈yw∙xz (normal h x) (ι g) u ⟩
64-
(ι g ∙ x) ∙ (ι h ∙ u) ≈⟨ ∙-cong ιg∙x≈y ιh∙u≈v ⟩
62+
(ι g ∙ x) ∙ (ι h ∙ u) ≈⟨ G.∙-cong ιg∙x≈y ιh∙u≈v ⟩
6563
y ∙ v ∎
6664
where h′ = conjugate h x
6765

68-
≋-⁻¹-cong : Congruent₁ _≋_ _⁻¹
69-
≋-⁻¹-cong {x} {y} (g by ιg∙x≈y) = h by begin
66+
⁻¹-cong : Congruent₁ _≋_ _⁻¹
67+
⁻¹-cong {x} {y} (g by ιg∙x≈y) = h by begin
7068
ι h ∙ x ⁻¹ ≈⟨ normal (g N.⁻¹) (x ⁻¹) ⟩
71-
x ⁻¹ ∙ ι (g N.⁻¹) ≈⟨ ∙-congˡ (ι.⁻¹-homo g) ⟩
69+
x ⁻¹ ∙ ι (g N.⁻¹) ≈⟨ G.∙-congˡ (ι.⁻¹-homo g) ⟩
7270
x ⁻¹ ∙ ι g ⁻¹ ≈⟨ ⁻¹-anti-homo-∙ (ι g) x ⟨
73-
(ι g ∙ x) ⁻¹ ≈⟨ ⁻¹-cong ιg∙x≈y ⟩
71+
(ι g ∙ x) ⁻¹ ≈⟨ G.⁻¹-cong ιg∙x≈y ⟩
7472
y ⁻¹ ∎
7573
where h = conjugate (g N.⁻¹) (x ⁻¹)
7674

77-
quotientGroup : Group c (c ⊔ ℓ ⊔ c′)
78-
quotientGroup = record
75+
group : Group c (c ⊔ ℓ ⊔ c′)
76+
group = record
7977
{ isGroup = record
8078
{ isMonoid = record
8179
{ isSemigroup = record
8280
{ isMagma = record
8381
{ isEquivalence = record
84-
{ refl = ≋-refl
85-
; sym = ≋-sym
86-
; trans = ≋-trans
82+
{ refl = refl
83+
; sym = sym
84+
; trans = trans
8785
}
88-
; ∙-cong = ≋-∙-cong
86+
; ∙-cong = ∙-cong
8987
}
90-
; assoc = λ x y z ≈⇒≋ (assoc x y z)
88+
; assoc = λ x y z ≈⇒≋ (G.assoc x y z)
9189
}
92-
; identity = ≈⇒≋ ∘ identityˡ , ≈⇒≋ ∘ identityʳ
90+
; identity = ≈⇒≋ ∘ G.identityˡ , ≈⇒≋ ∘ G.identityʳ
9391
}
94-
; inverse = ≈⇒≋ ∘ inverseˡ , ≈⇒≋ ∘ inverseʳ
95-
; ⁻¹-cong = ≋-⁻¹-cong
92+
; inverse = ≈⇒≋ ∘ G.inverseˡ , ≈⇒≋ ∘ G.inverseʳ
93+
; ⁻¹-cong = ⁻¹-cong
9694
}
9795
}
9896

99-
_/_ : Group c (c ⊔ ℓ ⊔ c′)
100-
_/_ = quotientGroup
97+
private module Q = Group group
10198

102-
π : Group.Carrier G Group.Carrier quotientGroup
103-
π x = x -- because we do all the work in the relation
99+
-- Public re-exports
104100

105-
π-isMagmaHomomorphism : IsMagmaHomomorphism rawMagma (Group.rawMagma quotientGroup) π
106-
π-isMagmaHomomorphism = record
107-
{ isRelHomomorphism = record
108-
{ cong = ≈⇒≋
109-
}
110-
; homo = λ _ _ ≋-refl
111-
}
101+
_/_ : Group c (c ⊔ ℓ ⊔ c′)
102+
_/_ = group
112103

113-
π-isMonoidHomomorphism : IsMonoidHomomorphism rawMonoid (Group.rawMonoid quotientGroup) π
114-
π-isMonoidHomomorphism = record
115-
{ isMagmaHomomorphism = π-isMagmaHomomorphism
116-
; ε-homo = ≋-refl
117-
}
104+
π : G.Carrier Q.Carrier
105+
π x = x -- because we do all the work in the relation _≋_
118106

119-
π-isGroupHomomorphism : IsGroupHomomorphism rawGroup (Group.rawGroup quotientGroup) π
107+
π-surjective : Surjective _≈_ _≋_ π
108+
π-surjective g = g , ≈⇒≋
109+
110+
π-isGroupHomomorphism : IsGroupHomomorphism G.rawGroup Q.rawGroup π
120111
π-isGroupHomomorphism = record
121-
{ isMonoidHomomorphism = π-isMonoidHomomorphism
122-
; ⁻¹-homo = λ _ ≋-refl
112+
{ isMonoidHomomorphism = record
113+
{ isMagmaHomomorphism = record
114+
{ isRelHomomorphism = record
115+
{ cong = ≈⇒≋
116+
}
117+
; homo = λ _ _ refl
118+
}
119+
; ε-homo = refl
120+
}
121+
; ⁻¹-homo = λ _ refl
123122
}
124123

125-
π-surjective : Surjective _≈_ _≋_ π
126-
π-surjective g = g , ≈⇒≋
124+
open IsGroupHomomorphism π-isGroupHomomorphism public
125+
using ()
126+
renaming (isMonoidHomomorphism to π-isMonoidHomomorphism
127+
; isMagmaHomomorphism to π-isMagmaHomomorphism
128+
)

src/Algebra/Construct/Quotient/Ring.agda

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,72 @@
66

77
{-# OPTIONS --safe --cubical-compatible #-}
88

9-
open import Algebra.Bundles using (AbelianGroup; Ring; RawRing)
9+
open import Algebra.Bundles using (AbelianGroup; Ring)
1010
open import Algebra.Construct.Sub.Ring.Ideal using (Ideal)
11+
import Algebra.Construct.Quotient.AbelianGroup as Quotient
1112

1213
module Algebra.Construct.Quotient.Ring
1314
{c ℓ} (R : Ring c ℓ) {c′ ℓ′} (I : Ideal R c′ ℓ′)
1415
where
1516

17+
open import Algebra.Definitions using (Congruent₂)
1618
open import Algebra.Morphism.Structures using (IsRingHomomorphism)
1719
open import Data.Product.Base using (_,_)
1820
open import Function.Base using (_∘_)
1921
open import Level using (_⊔_)
2022

21-
import Algebra.Construct.Quotient.AbelianGroup as Quotient
22-
2323
private
2424
module R = Ring R
2525
module I = Ideal I
2626
module R/I = Quotient R.+-abelianGroup I.subgroup
2727

2828

2929
open R/I public
30-
using (_≋_; _by_; ≋-refl; ≈⇒≋
31-
; quotientAbelianGroup
32-
; π; π-isMonoidHomomorphism; π-surjective
33-
)
34-
35-
open import Algebra.Definitions _≋_ using (Congruent₂)
30+
using (_≋_; _by_; ≈⇒≋; π; π-isMonoidHomomorphism; π-surjective)
31+
renaming (abelianGroup to +-abelianGroup)
3632

37-
≋-*-cong : Congruent₂ R._*_
38-
≋-*-cong {x} {y} {u} {v} (j by ιj+x≈y) (k by ιk+u≈v) = ι j *ₗ k +ᴹ j *ᵣ u +ᴹ x *ₗ k by begin
33+
*-cong : Congruent₂ _≋_ R._*_
34+
*-cong {x} {y} {u} {v} (j by ιj+x≈y) (k by ιk+u≈v) =
35+
ι j *ₗ k +ᴹ j *ᵣ u +ᴹ x *ₗ k by begin
3936
ι (ι j *ₗ k +ᴹ j *ᵣ u +ᴹ x *ₗ k) + x * u ≈⟨ +-congʳ (ι.+ᴹ-homo (ι j *ₗ k +ᴹ j *ᵣ u) (x *ₗ k)) ⟩
4037
ι (ι j *ₗ k +ᴹ j *ᵣ u) + ι (x *ₗ k) + x * u ≈⟨ +-congʳ (+-congʳ (ι.+ᴹ-homo (ι j *ₗ k) (j *ᵣ u))) ⟩
4138
ι (ι j *ₗ k) + ι (j *ᵣ u) + ι (x *ₗ k) + x * u ≈⟨ +-congʳ (+-cong (+-cong (ι.*ₗ-homo (ι j) k) (ι.*ᵣ-homo u j)) (ι.*ₗ-homo x k)) ⟩
4239
ι j * ι k + ι j * u + x * ι k + x * u ≈⟨ binomial-expansion (ι j) x (ι k) u ⟨
43-
(ι j + x) * (ι k + u) ≈⟨ *-cong ιj+x≈y ιk+u≈v ⟩
40+
(ι j + x) * (ι k + u) ≈⟨ R.*-cong ιj+x≈y ιk+u≈v ⟩
4441
y * v ∎
4542
where
46-
open R using (_+_; _*_; +-congʳ ;+-cong; *-cong)
43+
open R using (_+_; _*_; +-congʳ ;+-cong)
4744
open import Algebra.Properties.Semiring R.semiring using (binomial-expansion)
4845
open import Relation.Binary.Reasoning.Setoid R.setoid
4946
open I using (ι; _*ₗ_; _*ᵣ_; _+ᴹ_)
5047

51-
quotientRawRing : RawRing c (c ⊔ ℓ ⊔ c′)
52-
quotientRawRing = record { RawRing R.rawRing hiding (_≈_) ; _≈_ = _≋_ }
53-
54-
quotientRing : Ring c (c ⊔ ℓ ⊔ c′)
55-
quotientRing = record
48+
ring : Ring c (c ⊔ ℓ ⊔ c′)
49+
ring = record
5650
{ isRing = record
5751
{ +-isAbelianGroup = isAbelianGroup
58-
; *-cong = ≋-*-cong
52+
; *-cong = *-cong
5953
; *-assoc = λ x y z ≈⇒≋ (R.*-assoc x y z)
6054
; *-identity = ≈⇒≋ ∘ R.*-identityˡ , ≈⇒≋ ∘ R.*-identityʳ
6155
; distrib = (λ x y z ≈⇒≋ (R.distribˡ x y z)) , (λ x y z ≈⇒≋ (R.distribʳ x y z))
6256
}
63-
} where open AbelianGroup quotientAbelianGroup using (isAbelianGroup)
57+
} where open AbelianGroup +-abelianGroup using (isAbelianGroup)
58+
59+
private module Q = Ring ring
60+
61+
-- Public re-exports
62+
63+
_/_ : Ring c (c ⊔ ℓ ⊔ c′)
64+
_/_ = ring
6465

65-
π-isRingHomomorphism : IsRingHomomorphism R.rawRing quotientRawRing π
66+
π-isRingHomomorphism : IsRingHomomorphism R.rawRing Q.rawRing π
6667
π-isRingHomomorphism = record
6768
{ isSemiringHomomorphism = record
6869
{ isNearSemiringHomomorphism = record
6970
{ +-isMonoidHomomorphism = π-isMonoidHomomorphism
70-
; *-homo = λ _ _ ≋-refl
71+
; *-homo = λ _ _ Q.refl
7172
}
72-
; 1#-homo = ≋-refl
73+
; 1#-homo = Q.refl
7374
}
74-
; -‿homo = λ _ ≋-refl
75+
; -‿homo = λ _ Q.refl
7576
}
7677

0 commit comments

Comments
 (0)