Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 1749a8d

Browse files
101damnationsmergify[bot]
authored andcommitted
feat(group_theory/submonoid): add bundled submonoids and various lemmas (#1623)
* WIP -- removing and everything is broken * test * test * tidy * fixed localization * starting on coset * WIP * submonoid.lean now compiles but no to_additive stuff * submonoid.lean compiles * putting is_submonoid back * docstrings * terrible docstrings up to line 370 * finished docstrings * more to_additive stuff * WIP -- removing and everything is broken * test * test * tidy * fixed localization * starting on coset * WIP * submonoid.lean now compiles but no to_additive stuff * submonoid.lean compiles * putting is_submonoid back * docstrings * terrible docstrings up to line 370 * finished docstrings * more to_additive stuff * WIP quotient monoids * quotient monoids WIP * quotient_monoid w/o ideals.lean all compiles * removing lemma * adjunction * some tidying * remove pointless equiv * completion compiles (very slowly) * add lemma * tidying * more tidying * mul -> smul oops * might now compile * tidied! I think * fix * breaking/adding stuff & switching branch * add Inf relation * removing sorrys * nearly updated quotient_monoid * updated quotient_monoid * resurrecting computability * tidied congruence.lean, added some docstrings * extending setoids instead, WIP * starting Galois insertion * a few more bits of to_additive and docs * no battery * up to line 800 * congruence'll compile when data.setoid exists now * more updates modulo existence of data.setoid * rearranging stuff * docstrings * starting additive docstrings * using newer additive docstring format in submonoid * docstrings, tidying * fixes and to_additive stuff, all WIP * temporary congruence fixes * slightly better approach to kernels, general chaos * aahh * more mess * deleting doomed inductive congruence closure * many fixes and better char pred isoms * docstrings for group_theory.submonoid * removing everything but bundled submonoids/lemmas * removing things etc * removing random empty folder * tidy * adding lemma back * tidying * responding to PR comments * change 2 defs to lemmas * @[simp] group_power.lean lemmas * responding to commute.lean comments * Remove unnecessary add_semiconj_by.eq * Change prod.submonoid to submonoid.prod * replacing a / at the end of docstring Sorry - don't make commits on your phone when your laptop's playing up :/ * removing some not very useful to_additives * fix pi_instances namespaces * remove unnecessary prefix * change extensionality to ext not sure this is necessary because surely merging will change this automatically, but Travis told me to, and I really want it to compile, and I am not at my laptop
1 parent 7b07932 commit 1749a8d

File tree

9 files changed

+807
-43
lines changed

9 files changed

+807
-43
lines changed

src/algebra/commute.lean

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ rather than just `rw [hb.pow_left 5]`.
3131
Most of the proofs come from the properties of `semiconj_by`.
3232
-/
3333

34-
/-- Two elements commute, if `a * b = b * a`. -/
34+
/-- Two elements commute iff `a * b = b * a`. -/
3535
def commute {S : Type*} [has_mul S] (a b : S) : Prop := semiconj_by a b b
3636

3737
open_locale smul
@@ -225,12 +225,14 @@ section centralizer
225225

226226
variables {S : Type*} [has_mul S]
227227

228-
/-- Centralizer of an element `a : S` is the set of elements that commute with `a`. -/
228+
/-- Centralizer of an element `a : S` as the set of elements that commute with `a`; for `S` a
229+
monoid, `submonoid.centralizer` is the centralizer as a submonoid. -/
229230
def centralizer (a : S) : set S := { x | commute a x }
230231

231232
@[simp] theorem mem_centralizer {a b : S} : b ∈ centralizer a ↔ commute a b := iff.rfl
232233

233-
/-- Centralizer of a set `T` is the set of elements that commute with all `a ∈ T`. -/
234+
/-- Centralizer of a set `T` as the set of elements of `S` that commute with all `a ∈ T`; for
235+
`S` a monoid, `submonoid.set.centralizer` is the set centralizer as a submonoid. -/
234236
protected def set.centralizer (s : set S) : set S := { x | ∀ a ∈ s, commute a x }
235237

236238
@[simp] protected theorem set.mem_centralizer (s : set S) {x : S} :
@@ -260,9 +262,22 @@ instance centralizer.is_submonoid : is_submonoid (centralizer a) :=
260262
{ one_mem := commute.one_right a,
261263
mul_mem := λ _ _, commute.mul_right }
262264

265+
/-- Centralizer of an element `a` of a monoid is the submonoid of elements that commute with `a`. -/
266+
def submonoid.centralizer : submonoid M :=
267+
{ carrier := centralizer a,
268+
one_mem' := commute.one_right a,
269+
mul_mem' := λ _ _, commute.mul_right }
270+
263271
instance set.centralizer.is_submonoid : is_submonoid s.centralizer :=
264272
by rw s.centralizer_eq; apply_instance
265273

274+
/-- Centralizer of a subset `T` of a monoid is the submonoid of elements that commute with
275+
all `a ∈ T`. -/
276+
def submonoid.set.centralizer : submonoid M :=
277+
{ carrier := s.centralizer,
278+
one_mem' := λ _ _, commute.one_right _,
279+
mul_mem' := λ _ _ h1 h2 a h, commute.mul_right (h1 a h) $ h2 a h }
280+
266281
@[simp] theorem monoid.centralizer_closure : (monoid.closure s).centralizer = s.centralizer :=
267282
set.subset.antisymm
268283
(set.centralizer_decreasing monoid.subset_closure)
@@ -310,9 +325,19 @@ instance centralizer.is_add_submonoid : is_add_submonoid (centralizer a) :=
310325
{ zero_mem := commute.zero_right a,
311326
add_mem := λ _ _, commute.add_right }
312327

328+
def centralizer.add_submonoid : add_submonoid A :=
329+
{ carrier := centralizer a,
330+
zero_mem' := commute.zero_right a,
331+
add_mem' := λ _ _, commute.add_right }
332+
313333
instance set.centralizer.is_add_submonoid : is_add_submonoid s.centralizer :=
314334
by rw s.centralizer_eq; apply_instance
315335

336+
def set.centralizer.add_submonoid : add_submonoid A :=
337+
{ carrier := s.centralizer,
338+
zero_mem' := λ _ _, commute.zero_right _,
339+
add_mem' := λ _ _ h1 h2 a h, commute.add_right (h1 a h) $ h2 a h }
340+
316341
@[simp] lemma add_monoid.centralizer_closure : (add_monoid.closure s).centralizer = s.centralizer :=
317342
set.subset.antisymm
318343
(set.centralizer_decreasing add_monoid.subset_closure)

src/algebra/group/hom.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,13 @@ def comp (hnp : N →* P) (hmn : M →* N) : M →* P :=
315315
map_one' := by simp,
316316
map_mul' := by simp }
317317

318+
@[simp, to_additive] lemma comp_apply (g : N →* P) (f : M →* N) (x : M) :
319+
g.comp f x = g (f x) := rfl
320+
321+
/-- Composition of monoid homomorphisms is associative. -/
322+
@[to_additive] lemma comp_assoc {Q : Type*} [monoid Q] (f : M →* N) (g : N →* P) (h : P →* Q) :
323+
(h.comp g).comp f = h.comp (g.comp f) := rfl
324+
318325
omit mP
319326
variables [mM] [mN]
320327

@@ -360,6 +367,15 @@ eq_inv_of_mul_eq_one $ by rw [←f.map_mul, inv_mul_self, f.map_one]
360367
theorem map_mul_inv {G H} [group G] [group H] (f : G →* H) (g h : G) :
361368
f (g * h⁻¹) = (f g) * (f h)⁻¹ := by rw [f.map_mul, f.map_inv]
362369

370+
/-- A group homomorphism is injective iff its kernel is trivial. -/
371+
@[to_additive]
372+
lemma injective_iff {G H} [group G] [group H] (f : G →* H) :
373+
function.injective f ↔ (∀ a, f a = 1 → a = 1) :=
374+
⟨λ h _, by rw ← f.map_one; exact @h _ _,
375+
λ h x y hxy, by rw [← inv_inv (f x), inv_eq_iff_mul_eq_one, ← f.map_inv,
376+
← f.map_mul] at hxy;
377+
simpa using inv_eq_of_mul_eq_one (h _ hxy)⟩
378+
363379
include mM
364380
/-- Makes a group homomomorphism from a proof that the map preserves multiplication. -/
365381
@[to_additive]

src/algebra/group/units.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ instance [has_repr α] : has_repr (units α) := ⟨repr ∘ val⟩
8585
@[simp] theorem mul_right_inj (a : units α) {b c : α} : b * a = c * a ↔ b = c :=
8686
⟨λ h, by simpa only [mul_inv_cancel_right] using congr_arg (* ↑(a⁻¹ : units α)) h, congr_arg _⟩
8787

88+
theorem eq_mul_inv_iff_mul_eq {a b : α} : a = b * ↑c⁻¹ ↔ a * c = b :=
89+
⟨λ h, by rw [h, inv_mul_cancel_right], λ h, by rw [← h, mul_inv_cancel_right]⟩
90+
91+
theorem eq_inv_mul_iff_mul_eq {a c : α} : a = ↑b⁻¹ * c ↔ ↑b * a = c :=
92+
⟨λ h, by rw [h, mul_inv_cancel_left], λ h, by rw [← h, inv_mul_cancel_left]⟩
93+
94+
theorem inv_mul_eq_iff_eq_mul {b c : α} : ↑a⁻¹ * b = c ↔ b = a * c :=
95+
⟨λ h, by rw [← h, mul_inv_cancel_left], λ h, by rw [h, inv_mul_cancel_left]⟩
96+
97+
theorem mul_inv_eq_iff_eq_mul {a c : α} : a * ↑b⁻¹ = c ↔ a = c * b :=
98+
⟨λ h, by rw [← h, inv_mul_cancel_right], λ h, by rw [h, mul_inv_cancel_right]⟩
99+
88100
end units
89101

90102
theorem nat.units_eq_one (u : units ℕ) : u = 1 :=

src/algebra/group_power.lean

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ theorem map_smul (a : α) : ∀(n : ℕ), f (n • a) = n • (f a)
124124

125125
end is_add_monoid_hom
126126

127+
namespace monoid_hom
128+
variables {β : Type v} [monoid α] [monoid β] (f : α →* β)
129+
130+
@[simp] theorem map_pow (a : α) : ∀(n : ℕ), f (a ^ n) = (f a) ^ n
131+
| 0 := f.map_one
132+
| (nat.succ n) := by rw [pow_succ, f.map_mul, map_pow n]; refl
133+
134+
end monoid_hom
135+
136+
namespace add_monoid_hom
137+
variables {β : Type*} [add_monoid α] [add_monoid β] (f : α →+ β)
138+
139+
@[simp] theorem map_smul (a : α) : ∀(n : ℕ), f (n • a) = n • (f a)
140+
| 0 := f.map_zero
141+
| (nat.succ n) := by rw [succ_smul, f.map_add, map_smul n]; refl
142+
143+
end add_monoid_hom
144+
127145
@[simp] theorem nat.pow_eq_pow (p q : ℕ) :
128146
@has_pow.pow _ _ monoid.has_pow p q = p ^ q :=
129147
by induction q with q ih; [refl, rw [nat.pow_succ, pow_succ, mul_comm, ih]]
@@ -340,6 +358,24 @@ theorem map_gsmul (a : α) (n : ℤ) : f (gsmul n a) = gsmul n (f a) :=
340358

341359
end is_add_group_hom
342360

361+
namespace monoid_hom
362+
variables {β : Type v} [group α] [group β] (f : α →* β)
363+
364+
@[simp] theorem map_gpow (a : α) (n : ℤ) : f (a ^ n) = f a ^ n :=
365+
by cases n; [exact f.map_pow _ _,
366+
exact (f.map_inv _).trans (congr_arg _ $ f.map_pow _ _)]
367+
368+
end monoid_hom
369+
370+
namespace add_monoid_hom
371+
variables {β : Type v} [add_group α] [add_group β] (f : α →+ β)
372+
373+
@[simp] theorem map_gsmul (a : α) (n : ℤ) : f (gsmul n a) = gsmul n (f a) :=
374+
by cases n; [exact f.map_smul _ _,
375+
exact (f.map_neg _).trans (congr_arg _ $ f.map_smul _ _)]
376+
377+
end add_monoid_hom
378+
local infix ` •ℤ `:70 := gsmul
343379
open_locale smul
344380

345381
section comm_monoid
@@ -406,6 +442,10 @@ theorem is_semiring_hom.map_pow {β} [semiring α] [semiring β]
406442
by induction n with n ih; [exact is_semiring_hom.map_one f,
407443
rw [pow_succ, pow_succ, is_semiring_hom.map_mul f, ih]]
408444

445+
@[simp] lemma ring_hom.map_pow {β} [semiring α] [semiring β] (f : α →+* β) (a) :
446+
∀ n : ℕ, f (a ^ n) = (f a) ^ n :=
447+
monoid_hom.map_pow f.to_monoid_hom a
448+
409449
theorem neg_one_pow_eq_or {R} [ring R] : ∀ n : ℕ, (-1 : R)^n = 1 ∨ (-1 : R)^n = -1
410450
| 0 := or.inl rfl
411451
| (n+1) := (neg_one_pow_eq_or n).swap.imp

src/algebra/pi_instances.lean

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ lemma fst.is_monoid_hom [monoid α] [monoid β] : is_monoid_hom (prod.fst : α
241241
lemma snd.is_monoid_hom [monoid α] [monoid β] : is_monoid_hom (prod.snd : α × β → β) :=
242242
{ map_mul := λ _ _, rfl, map_one := rfl }
243243

244+
/-- Given monoids `α, β`, the natural projection homomorphism from `α × β` to `α`. -/
245+
@[to_additive prod.add_monoid_hom.fst "Given add_monoids `α, β`, the natural projection homomorphism from `α × β` to `α`."]
246+
def monoid_hom.fst [monoid α] [monoid β] : α × β →* α :=
247+
⟨λ x, x.1, rfl, λ _ _, prod.fst_mul⟩
248+
249+
/-- Given monoids `α, β`, the natural projection homomorphism from `α × β` to `β`.-/
250+
@[to_additive prod.add_monoid_hom.snd "Given add_monoids `α, β`, the natural projection homomorphism from `α × β` to `β`."]
251+
def monoid_hom.snd [monoid α] [monoid β] : α × β →* β :=
252+
⟨λ x, x.2, rfl, λ _ _, prod.snd_mul⟩
253+
244254
@[to_additive is_add_group_hom]
245255
lemma fst.is_group_hom [group α] [group β] : is_group_hom (prod.fst : α × β → α) :=
246256
{ map_mul := λ _ _, rfl }
@@ -370,6 +380,18 @@ end substructures
370380

371381
end prod
372382

383+
namespace submonoid
384+
385+
/-- Given submonoids `s, t` of monoids `α, β` respectively, `s × t` as a submonoid of `α × β`. -/
386+
@[to_additive prod "Given `add_submonoids` `s, t` of `add_monoids` `α, β` respectively, `s × t` as an `add_submonoid` of `α × β`."]
387+
def prod {α : Type*} {β : Type*} [monoid α] [monoid β] (s : submonoid α) (t : submonoid β) :
388+
submonoid (α × β) :=
389+
{ carrier := (s : set α).prod t,
390+
one_mem' := ⟨s.one_mem, t.one_mem⟩,
391+
mul_mem' := λ _ _ h1 h2, ⟨s.mul_mem h1.1 h2.1, t.mul_mem h1.2 h2.2⟩ }
392+
393+
end submonoid
394+
373395
namespace finset
374396

375397
@[to_additive prod_mk_sum]

src/algebra/ring.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ def comp (hnp : β →+* γ) (hmn : α →+* β) : α →+* γ :=
396396
map_add' := λ x y, by simp,
397397
map_mul' := λ x y, by simp}
398398

399+
/-- Composition of semiring homomorphisms is associative. -/
400+
lemma comp_assoc {δ} {rδ: semiring δ} (f : α →+* β) (g : β →+* γ) (h : γ →+* δ) :
401+
(h.comp g).comp f = h.comp (g.comp f) := rfl
402+
399403
@[simp] lemma coe_comp (hnp : β →+* γ) (hmn : α →+* β) : (hnp.comp hmn : α → γ) = hnp ∘ hmn := rfl
400404

401405
@[simp] lemma comp_apply (hnp : β →+* γ) (hmn : α →+* β) (x : α) : (hnp.comp hmn : α → γ) x =
@@ -411,6 +415,10 @@ eq_neg_of_add_eq_zero $ by rw [←f.map_add, neg_add_self, f.map_zero]
411415
@[simp] theorem map_sub {α β} [ring α] [ring β] (f : α →+* β) (x y : α) :
412416
f (x - y) = (f x) - (f y) := by simp
413417

418+
/-- A ring homomorphism is injective iff its kernel is trivial. -/
419+
theorem injective_iff {α β} [ring α] [ring β] (f : α →+* β) :
420+
function.injective f ↔ (∀ a, f a = 0 → a = 0) :=
421+
add_monoid_hom.injective_iff f.to_add_monoid_hom
414422
include
415423

416424
/-- Makes a ring homomorphism from a monoid homomorphism of rings which preserves addition. -/

src/data/equiv/algebra.lean

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ lemma map_mul (f : α ≃* β) : ∀ x y : α, f (x * y) = f x * f y := f.map_m
252252
@[to_additive]
253253
instance (h : α ≃* β) : is_mul_hom h := ⟨h.map_mul⟩
254254

255+
/-- Makes a multiplicative isomorphism from a bijection which preserves multiplication. -/
256+
@[to_additive]
257+
def mk' (f : α ≃ β) (h : ∀ x y, f (x * y) = f x * f y) : α ≃* β :=
258+
⟨f.1, f.2, f.3, f.4, h⟩
259+
255260
/-- The identity map is a multiplicative isomorphism. -/
256261
@[refl, to_additive]
257262
def refl (α : Type*) [has_mul α] : α ≃* α :=
@@ -518,6 +523,12 @@ variables [semiring α] [semiring β]
518523
def to_ring_hom (e : α ≃+* β) : α →+* β :=
519524
{ .. e.to_mul_equiv.to_monoid_hom, .. e.to_add_equiv.to_add_monoid_hom }
520525

526+
/-- Reinterpret a ring equivalence as a monoid homomorphism. -/
527+
abbreviation to_monoid_hom (e : α ≃+* β) : α →* β := e.to_ring_hom.to_monoid_hom
528+
529+
/-- Reinterpret a ring equivalence as an `add_monoid` homomorphism. -/
530+
abbreviation to_add_monoid_hom (e : α ≃+* β) : α →+ β := e.to_ring_hom.to_add_monoid_hom
531+
521532
/-- Interpret an equivalence `f : α ≃ β` as a ring equivalence `α ≃+* β`. -/
522533
def of (e : α ≃ β) [is_semiring_hom e] : α ≃+* β :=
523534
{ .. e, .. monoid_hom.of e, .. add_monoid_hom.of e }
@@ -536,6 +547,33 @@ equiv.symm_apply_apply (e.to_equiv)
536547

537548
end semiring_hom
538549

550+
end ring_equiv
551+
552+
namespace mul_equiv
553+
554+
/-- Gives an `is_semiring_hom` instance from a `mul_equiv` of semirings that preserves addition. -/
555+
protected lemma to_semiring_hom {R : Type*} {S : Type*} [semiring R] [semiring S]
556+
(h : R ≃* S) (H : ∀ x y : R, h (x + y) = h x + h y) : is_semiring_hom h :=
557+
⟨add_equiv.map_zero $ add_equiv.mk' h.to_equiv H, h.map_one, H, h.5
558+
559+
/-- Gives a `ring_equiv` from a `mul_equiv` preserving addition.-/
560+
def to_ring_equiv {R : Type*} {S : Type*} [has_add R] [has_add S] [has_mul R] [has_mul S]
561+
(h : R ≃* S) (H : ∀ x y : R, h (x + y) = h x + h y) : R ≃+* S :=
562+
{..h.to_equiv, ..h, ..add_equiv.mk' h.to_equiv H }
563+
564+
end mul_equiv
565+
566+
namespace add_equiv
567+
568+
/-- Gives an `is_semiring_hom` instance from a `mul_equiv` of semirings that preserves addition. -/
569+
protected lemma to_semiring_hom {R : Type*} {S : Type*} [semiring R] [semiring S]
570+
(h : R ≃+ S) (H : ∀ x y : R, h (x * y) = h x * h y) : is_semiring_hom h :=
571+
⟨h.map_zero, mul_equiv.map_one $ mul_equiv.mk' h.to_equiv H, h.5, H⟩
572+
573+
end add_equiv
574+
575+
namespace ring_equiv
576+
539577
section ring_hom
540578

541579
variables [ring α] [ring β]

src/group_theory/coset.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ attribute [to_additive right_add_coset_zero] right_coset_one
7070
end coset_monoid
7171

7272
section coset_submonoid
73-
open is_submonoid
74-
variables [monoid α] (s : set α) [is_submonoid s]
73+
open submonoid
74+
variables [monoid α] (s : submonoid α)
7575

7676
@[to_additive mem_own_left_add_coset]
7777
lemma mem_own_left_coset (a : α) : a ∈ a *l s :=
7878
suffices a * 1 ∈ a *l s, by simpa,
7979
mem_left_coset a (one_mem s)
8080

8181
@[to_additive mem_own_right_add_coset]
82-
lemma mem_own_right_coset (a : α) : a ∈ s *r a :=
83-
suffices 1 * a ∈ s *r a, by simpa,
82+
lemma mem_own_right_coset (a : α) : a ∈ (s : set α) *r a :=
83+
suffices 1 * a ∈ (s : set α) *r a, by simpa,
8484
mem_right_coset a (one_mem s)
8585

8686
@[to_additive mem_left_add_coset_left_add_coset]
8787
lemma mem_left_coset_left_coset {a : α} (ha : a *l s = s) : a ∈ s :=
88-
by rw [←ha]; exact mem_own_left_coset s a
88+
by rw [←submonoid.mem_coe, ←ha]; exact mem_own_left_coset s a
8989

9090
@[to_additive mem_right_add_coset_right_add_coset]
91-
lemma mem_right_coset_right_coset {a : α} (ha : s *r a = s) : a ∈ s :=
92-
by rw [←ha]; exact mem_own_right_coset s a
91+
lemma mem_right_coset_right_coset {a : α} (ha : (s : set α) *r a = s) : a ∈ s :=
92+
by rw [←submonoid.mem_coe, ←ha]; exact mem_own_right_coset s a
9393

9494
end coset_submonoid
9595

@@ -111,7 +111,7 @@ iff.intro
111111
end coset_group
112112

113113
section coset_subgroup
114-
open is_submonoid
114+
open submonoid
115115
open is_subgroup
116116
variables [group α] (s : set α) [is_subgroup s]
117117

0 commit comments

Comments
 (0)