Skip to content

Commit 72c54c5

Browse files
committed
feat(Algebra/Group/GreensRelations): add Quotient API and PartialOrder instances
1 parent dfdae48 commit 72c54c5

2 files changed

Lines changed: 75 additions & 37 deletions

File tree

Mathlib/Algebra/Group/GreensRelations/Basic.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace IsGreenL
108108
⟨IsGreenLeftDvd.trans hab.left hbc.left, IsGreenLeftDvd.trans hbc.right hab.right⟩
109109

110110
/-- Green's L relation defines a setoid on `S`. -/
111-
protected def setoid (S : Type*) [Semigroup S] : Setoid S where
111+
protected abbrev setoid (S : Type*) [Semigroup S] : Setoid S where
112112
r := IsGreenL
113113
iseqv := { refl := refl, symm := symm, trans := trans }
114114

@@ -137,7 +137,7 @@ namespace IsGreenR
137137
⟨IsGreenRightDvd.trans hab.left hbc.left, IsGreenRightDvd.trans hbc.right hab.right⟩
138138

139139
/-- Green's R relation defines a setoid on `S`. -/
140-
protected def setoid (S : Type*) [Semigroup S] : Setoid S where
140+
protected abbrev setoid (S : Type*) [Semigroup S] : Setoid S where
141141
r := IsGreenR
142142
iseqv := { refl := refl, symm := symm, trans := trans }
143143

@@ -168,7 +168,7 @@ namespace IsGreenH
168168
⟨hab.left.trans hbc.left, hab.right.trans hbc.right⟩
169169

170170
/-- Green's H relation defines a setoid on `S`. -/
171-
protected def setoid (S : Type*) [Semigroup S] : Setoid S where
171+
protected abbrev setoid (S : Type*) [Semigroup S] : Setoid S where
172172
r := IsGreenH
173173
iseqv := { refl := refl, symm := symm, trans := trans }
174174

@@ -207,7 +207,7 @@ namespace IsGreenD
207207
⟨z, hL1.trans hL3.symm, hR3.symm.trans hR2⟩
208208

209209
/-- Green's D relation defines a setoid on `S`. -/
210-
protected def setoid (S : Type*) [Semigroup S] : Setoid S where
210+
protected abbrev setoid (S : Type*) [Semigroup S] : Setoid S where
211211
r := IsGreenD
212212
iseqv := { refl := refl, symm := symm, trans := trans }
213213

@@ -237,7 +237,7 @@ namespace IsGreenJ
237237
⟨hab.left.trans hbc.left, hbc.right.trans hab.right⟩
238238

239239
/-- Green's J relation defines a setoid on `S`. -/
240-
protected def setoid (S : Type*) [Semigroup S] : Setoid S where
240+
protected abbrev setoid (S : Type*) [Semigroup S] : Setoid S where
241241
r := IsGreenJ
242242
iseqv := { refl := refl, symm := symm, trans := trans }
243243

Mathlib/Algebra/Group/GreensRelations/Classes.lean

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ section SetsAndRegularity
3939
namespace IsGreenL
4040

4141
/-- The equivalence class of `x` under Green's L relation as a `Set S`. -/
42-
def eqvClass (x : S) : Set S := setOf (IsGreenL · x)
42+
abbrev eqvClass (x : S) : Set S := setOf (IsGreenL · x)
4343

4444
end IsGreenL
4545

4646
namespace IsGreenR
4747

4848
/-- The equivalence class of `x` under Green's R relation as a `Set S`. -/
49-
def eqvClass (x : S) : Set S := setOf (IsGreenR · x)
49+
abbrev eqvClass (x : S) : Set S := setOf (IsGreenR · x)
5050

5151
end IsGreenR
5252

5353
namespace IsGreenH
5454

5555
/-- The equivalence class of `x` under Green's H relation as a `Set S`. -/
56-
def eqvClass (x : S) : Set S := setOf (IsGreenH · x)
56+
abbrev eqvClass (x : S) : Set S := setOf (IsGreenH · x)
5757

5858
open MulOpposite in
5959
/-- An equivalence between the H-class of `a` and the H-class of `op a`. -/
60-
def equivHClassOp (a : S) : eqvClass a ≃ eqvClass (op a) where
60+
abbrev equivHClassOp (a : S) : eqvClass a ≃ eqvClass (op a) where
6161
toFun := fun ⟨x, hx⟩ ↦ ⟨op x, isGreenH_iff_isGreenH_op.mp hx⟩
6262
invFun := fun ⟨y, hy⟩ ↦ ⟨unop y, isGreenH_iff_isGreenH_op.mpr (by rwa [op_unop])⟩
6363
left_inv := fun ⟨x, _⟩ ↦ Subtype.ext (unop_op x)
@@ -68,26 +68,25 @@ end IsGreenH
6868
namespace IsGreenD
6969

7070
/-- The equivalence class of `x` under Green's D relation as a `Set S`. -/
71-
def eqvClass (x : S) : Set S := setOf (IsGreenD · x)
71+
abbrev eqvClass (x : S) : Set S := setOf (IsGreenD · x)
7272

7373
end IsGreenD
7474

7575
namespace IsGreenJ
7676

7777
/-- The equivalence class of `x` under Green's J relation as a `Set S`. -/
78-
def eqvClass (x : S) : Set S := setOf (IsGreenJ · x)
78+
abbrev eqvClass (x : S) : Set S := setOf (IsGreenJ · x)
7979

8080
end IsGreenJ
8181

8282
/-- An element `a` is regular if there exists `s` such that `a * s * a = a`. -/
83-
def IsGreenRegular (a : S) := ∃ s, a * s * a = a
83+
abbrev IsGreenRegular (a : S) := ∃ s, a * s * a = a
8484

8585
/-- A D-class is regular if all its elements are regular. -/
86-
def IsRegularDClass (D : Set S) := ∀ x ∈ D, IsGreenRegular x
86+
abbrev IsRegularDClass (D : Set S) := ∀ x ∈ D, IsGreenRegular x
8787

8888
end SetsAndRegularity
8989

90-
9190
section QuotientAPI
9291

9392
/-- The quotient type of `S` by Green's L relation. -/
@@ -96,15 +95,16 @@ abbrev GreenLClass (S : Type*) [Semigroup S] := Quotient (IsGreenL.setoid S)
9695
namespace GreenLClass
9796

9897
/-- Constructs the Green's L-class of an element `x`. -/
99-
def mk (x : S) : GreenLClass S := Quotient.mk (IsGreenL.setoid S) x
98+
abbrev mk (x : S) : GreenLClass S := Quotient.mk (IsGreenL.setoid S) x
10099

101100
/-- The projection map to Green's L-classes is surjective. -/
102101
lemma mk_surjective : Function.Surjective (mk : S → GreenLClass S) :=
103102
@Quotient.exists_rep _ (IsGreenL.setoid S)
104103

105104
/-- Two elements have the same Green's L-class if and only if they are L-related. -/
106-
lemma mk_eq_mk_iff {a b : S} : mk a = mk b ↔ IsGreenL a b :=
107-
@Quotient.eq _ (IsGreenL.setoid S) _ _
105+
lemma mk_eq_mk_iff {a b : S} : mk a = mk b ↔ IsGreenL a b := by
106+
dsimp [mk, IsGreenL.setoid]
107+
exact Quotient.eq
108108

109109
instance [Inhabited S] : Inhabited (GreenLClass S) := ⟨mk default⟩
110110

@@ -117,12 +117,25 @@ lemma isGreenLeftDvd_respects (a₁ b₁ a₂ b₂ : S)
117117
fun h ↦ h1.left.trans (h.trans h2.right)
118118
119119

120-
/-- The partial order on L-classes. `[a] ≤ [b]` iff `a` is a left multiple of `b`. -/
121-
instance : PartialOrder (GreenLClass S) where
120+
/-- Green's L relation induces a natural left-multiplication order on L-classes.
121+
`[a] ≤ [b]` iff `a` is a left multiple of `b`. -/
122+
instance : LE (GreenLClass S) where
122123
le := Quotient.lift₂ IsGreenLeftDvd isGreenLeftDvd_respects
123-
le_refl := by rintro ⟨a⟩; exact IsGreenLeftDvd.refl a
124-
le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hab hbc; exact hab.trans hbc
125-
le_antisymm := by rintro ⟨a⟩ ⟨b⟩ hab hba; exact mk_eq_mk_iff.mpr ⟨hab, hba⟩
124+
125+
/-- The partial order on L-classes. -/
126+
instance : PartialOrder (GreenLClass S) where
127+
le_refl := by
128+
rintro ⟨a⟩
129+
dsimp [LE.le]
130+
exact IsGreenLeftDvd.refl a
131+
le_trans := by
132+
rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hab hbc
133+
dsimp [LE.le] at hab hbc ⊢
134+
exact hab.trans hbc
135+
le_antisymm := by
136+
rintro ⟨a⟩ ⟨b⟩ hab hba
137+
dsimp [LE.le] at hab hba
138+
exact mk_eq_mk_iff.mpr ⟨hab, hba⟩
126139

127140
end GreenLClass
128141

@@ -133,7 +146,7 @@ abbrev GreenRClass (S : Type*) [Semigroup S] := Quotient (IsGreenR.setoid S)
133146
namespace GreenRClass
134147

135148
/-- Constructs the Green's R-class of an element `x`. -/
136-
def mk (x : S) : GreenRClass S := Quotient.mk (IsGreenR.setoid S) x
149+
abbrev mk (x : S) : GreenRClass S := Quotient.mk (IsGreenR.setoid S) x
137150

138151
/-- The projection map to Green's R-classes is surjective. -/
139152
lemma mk_surjective : Function.Surjective (mk : S → GreenRClass S) :=
@@ -154,12 +167,25 @@ lemma isGreenRightDvd_respects (a₁ b₁ a₂ b₂ : S)
154167
fun h ↦ IsGreenRightDvd.trans (IsGreenRightDvd.trans ha.left h) hb.right
155168
156169

157-
/-- The partial order on R-classes. `[a] ≤ [b]` iff `a` is a right multiple of `b`. -/
158-
instance : PartialOrder (GreenRClass S) where
170+
/-- Green's R relation induces a natural right-multiplication order on R-classes.
171+
`[a] ≤ [b]` iff `a` is a right multiple of `b`. -/
172+
instance : LE (GreenRClass S) where
159173
le := Quotient.lift₂ IsGreenRightDvd isGreenRightDvd_respects
160-
le_refl := by rintro ⟨a⟩; exact IsGreenRightDvd.refl a
161-
le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hab hbc; exact IsGreenRightDvd.trans hab hbc
162-
le_antisymm := by rintro ⟨a⟩ ⟨b⟩ hab hba; exact mk_eq_mk_iff.mpr ⟨hab, hba⟩
174+
175+
/-- The partial order on R-classes. -/
176+
instance : PartialOrder (GreenRClass S) where
177+
le_refl := by
178+
rintro ⟨a⟩
179+
dsimp [LE.le]
180+
exact IsGreenRightDvd.refl a
181+
le_trans := by
182+
rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hab hbc
183+
dsimp [LE.le] at hab hbc ⊢
184+
exact IsGreenRightDvd.trans hab hbc
185+
le_antisymm := by
186+
rintro ⟨a⟩ ⟨b⟩ hab hba
187+
dsimp [LE.le] at hab hba
188+
exact mk_eq_mk_iff.mpr ⟨hab, hba⟩
163189

164190
end GreenRClass
165191

@@ -170,7 +196,7 @@ abbrev GreenJClass (S : Type*) [Semigroup S] := Quotient (IsGreenJ.setoid S)
170196
namespace GreenJClass
171197

172198
/-- Constructs the Green's J-class of an element `x`. -/
173-
def mk (x : S) : GreenJClass S := Quotient.mk (IsGreenJ.setoid S) x
199+
abbrev mk (x : S) : GreenJClass S := Quotient.mk (IsGreenJ.setoid S) x
174200

175201
/-- The projection map to Green's J-classes is surjective. -/
176202
lemma mk_surjective : Function.Surjective (mk : S → GreenJClass S) :=
@@ -191,12 +217,25 @@ lemma isGreenJRel_respects (a₁ b₁ a₂ b₂ : S)
191217
fun h ↦ IsGreenJRel.trans (IsGreenJRel.trans ha.left h) hb.right
192218
193219

194-
/-- The partial order on J-classes. `[a] ≤ [b]` iff `a` is a two-sided multiple of `b`. -/
195-
instance : PartialOrder (GreenJClass S) where
220+
/-- Green's J relation induces a natural two-sided order on J-classes.
221+
`[a] ≤ [b]` iff `a` is a two-sided multiple of `b`. -/
222+
instance : LE (GreenJClass S) where
196223
le := Quotient.lift₂ IsGreenJRel isGreenJRel_respects
197-
le_refl := by rintro ⟨a⟩; exact IsGreenJRel.refl a
198-
le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hab hbc; exact IsGreenJRel.trans hab hbc
199-
le_antisymm := by rintro ⟨a⟩ ⟨b⟩ hab hba; exact mk_eq_mk_iff.mpr ⟨hab, hba⟩
224+
225+
/-- The partial order on J-classes. -/
226+
instance : PartialOrder (GreenJClass S) where
227+
le_refl := by
228+
rintro ⟨a⟩
229+
dsimp [LE.le]
230+
exact IsGreenJRel.refl a
231+
le_trans := by
232+
rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hab hbc
233+
dsimp [LE.le] at hab hbc ⊢
234+
exact IsGreenJRel.trans hab hbc
235+
le_antisymm := by
236+
rintro ⟨a⟩ ⟨b⟩ hab hba
237+
dsimp [LE.le] at hab hba
238+
exact mk_eq_mk_iff.mpr ⟨hab, hba⟩
200239

201240
end GreenJClass
202241

@@ -207,7 +246,7 @@ abbrev GreenHClass (S : Type*) [Semigroup S] := Quotient (IsGreenH.setoid S)
207246
namespace GreenHClass
208247

209248
/-- Constructs the Green's H-class of an element `x`. -/
210-
def mk (x : S) : GreenHClass S := Quotient.mk (IsGreenH.setoid S) x
249+
abbrev mk (x : S) : GreenHClass S := Quotient.mk (IsGreenH.setoid S) x
211250

212251
/-- The projection map to Green's H-classes is surjective. -/
213252
lemma mk_surjective : Function.Surjective (mk : S → GreenHClass S) :=
@@ -221,14 +260,13 @@ instance [Inhabited S] : Inhabited (GreenHClass S) := ⟨mk default⟩
221260

222261
end GreenHClass
223262

224-
225263
/-- The quotient type of `S` by Green's D relation. -/
226264
abbrev GreenDClass (S : Type*) [Semigroup S] := Quotient (IsGreenD.setoid S)
227265

228266
namespace GreenDClass
229267

230268
/-- Constructs the Green's D-class of an element `x`. -/
231-
def mk (x : S) : GreenDClass S := Quotient.mk (IsGreenD.setoid S) x
269+
abbrev mk (x : S) : GreenDClass S := Quotient.mk (IsGreenD.setoid S) x
232270

233271
/-- The projection map to Green's D-classes is surjective. -/
234272
lemma mk_surjective : Function.Surjective (mk : S → GreenDClass S) :=

0 commit comments

Comments
 (0)