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

Commit 9fba817

Browse files
committed
refactor(algebra/*): move commute below ring in imports (#2973)
Fixes #1865 API changes: * drop lemmas about unbundled `center`; * add `to_additive` to `semiconj_by` and `commute`; * drop `inv_comm_of_comm` in favor of `commute.left_inv`, same with `inv_comm_of_comm` and `commute.left_inv'`; * rename `monoid_hom.map_commute` to `commute.map`, same with `semiconj_by`; * drop `commute.cast_*_*` and `nat/int/rat.mul_cast_comm`, add `nat/int/rat.cast_commute` and `nat.int.rat.commute_cast`; * add `commute.mul_fpow`.
1 parent 2caf479 commit 9fba817

16 files changed

+666
-747
lines changed

src/algebra/commute.lean

Lines changed: 0 additions & 411 deletions
This file was deleted.

src/algebra/geom_sum.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Authors: Neil Strickland
55
66
Sums of finite geometric series
77
-/
8-
import algebra.commute
98
import algebra.group_with_zero_power
9+
import algebra.big_operators
1010

1111
universe u
1212
variable {α : Type u}

src/algebra/group/basic.lean

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,6 @@ by rw [mul_eq_one_iff_eq_inv, inv_inv]
194194
theorem inv_mul_eq_one : a⁻¹ * b = 1 ↔ a = b :=
195195
by rw [mul_eq_one_iff_eq_inv, inv_inj']
196196

197-
@[to_additive]
198-
theorem inv_comm_of_comm (H : a * b = b * a) : a⁻¹ * b = b * a⁻¹ :=
199-
begin
200-
have : a⁻¹ * (b * a) * a⁻¹ = a⁻¹ * (a * b) * a⁻¹ :=
201-
congr_arg (λ x:G, a⁻¹ * x * a⁻¹) H.symm,
202-
rwa [inv_mul_cancel_left, mul_assoc, mul_inv_cancel_right] at this
203-
end
204-
205197
@[simp, to_additive]
206198
lemma mul_left_eq_self : a * b = b ↔ a = 1 :=
207199
⟨λ h, @mul_right_cancel _ _ a b 1 (by simp [h]), λ h, by simp [h]⟩

src/algebra/group/commute.lean

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/-
2+
Copyright (c) 2019 Neil Strickland. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Neil Strickland, Yury Kudryashov
5+
-/
6+
import algebra.group.semiconj
7+
8+
/-!
9+
# Commuting pairs of elements in monoids
10+
11+
We define the predicate `commute a b := a * b = b * a` and provide some operations on terms `(h :
12+
commute a b)`. E.g., if `a`, `b`, and c are elements of a semiring, and that `hb : commute a b` and
13+
`hc : commute a c`. Then `hb.pow_left 5` proves `commute (a ^ 5) b` and `(hb.pow_right 2).add_right
14+
(hb.mul_right hc)` proves `commute a (b ^ 2 + b * c)`.
15+
16+
Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like
17+
`rw [(hb.pow_left 5).eq]` rather than just `rw [hb.pow_left 5]`.
18+
19+
This file defines only a few operations (`mul_left`, `inv_right`, etc). Other operations
20+
(`pow_right`, field inverse etc) are in the files that define corresponding notions.
21+
22+
## Implementation details
23+
24+
Most of the proofs come from the properties of `semiconj_by`.
25+
-/
26+
27+
/-- Two elements commute if `a * b = b * a`. -/
28+
@[to_additive add_commute "Two elements additively commute if `a + b = b + a`"]
29+
def commute {S : Type*} [has_mul S] (a b : S) : Prop := semiconj_by a b b
30+
31+
namespace commute
32+
33+
section has_mul
34+
35+
variables {S : Type*} [has_mul S]
36+
37+
/-- Equality behind `commute a b`; useful for rewriting. -/
38+
@[to_additive] protected theorem eq {a b : S} (h : commute a b) : a * b = b * a := h
39+
40+
/-- Any element commutes with itself. -/
41+
@[refl, simp, to_additive] protected theorem refl (a : S) : commute a a := eq.refl (a * a)
42+
43+
/-- If `a` commutes with `b`, then `b` commutes with `a`. -/
44+
@[symm, to_additive] protected theorem symm {a b : S} (h : commute a b) : commute b a :=
45+
eq.symm h
46+
47+
@[to_additive]
48+
protected theorem symm_iff {a b : S} : commute a b ↔ commute b a :=
49+
⟨commute.symm, commute.symm⟩
50+
51+
end has_mul
52+
53+
section semigroup
54+
55+
variables {S : Type*} [semigroup S] {a b c : S}
56+
57+
/-- If `a` commutes with both `b` and `c`, then it commutes with their product. -/
58+
@[simp, to_additive] theorem mul_right (hab : commute a b) (hac : commute a c) :
59+
commute a (b * c) :=
60+
hab.mul_right hac
61+
62+
/-- If both `a` and `b` commute with `c`, then their product commutes with `c`. -/
63+
@[simp, to_additive] theorem mul_left (hac : commute a c) (hbc : commute b c) :
64+
commute (a * b) c :=
65+
hac.mul_left hbc
66+
67+
@[to_additive] protected lemma right_comm (h : commute b c) (a : S) :
68+
a * b * c = a * c * b :=
69+
by simp only [mul_assoc, h.eq]
70+
71+
@[to_additive] protected lemma left_comm (h : commute a b) (c) :
72+
a * (b * c) = b * (a * c) :=
73+
by simp only [← mul_assoc, h.eq]
74+
75+
end semigroup
76+
77+
@[to_additive]
78+
protected theorem all {S : Type*} [comm_semigroup S] (a b : S) : commute a b := mul_comm a b
79+
80+
section monoid
81+
82+
variables {M : Type*} [monoid M]
83+
84+
@[simp, to_additive] theorem one_right (a : M) : commute a 1 := semiconj_by.one_right a
85+
@[simp, to_additive] theorem one_left (a : M) : commute 1 a := semiconj_by.one_left a
86+
87+
@[to_additive] theorem units_inv_right {a : M} {u : units M} : commute a u → commute a ↑u⁻¹ :=
88+
semiconj_by.units_inv_right
89+
90+
@[simp, to_additive] theorem units_inv_right_iff {a : M} {u : units M} :
91+
commute a ↑u⁻¹ ↔ commute a u :=
92+
semiconj_by.units_inv_right_iff
93+
94+
@[to_additive] theorem units_inv_left {u : units M} {a : M} : commute ↑u a → commute ↑u⁻¹ a :=
95+
semiconj_by.units_inv_symm_left
96+
97+
@[simp, to_additive]
98+
theorem units_inv_left_iff {u : units M} {a : M}: commute ↑u⁻¹ a ↔ commute ↑u a :=
99+
semiconj_by.units_inv_symm_left_iff
100+
101+
variables {u₁ u₂ : units M}
102+
103+
@[to_additive]
104+
theorem units_coe : commute u₁ u₂ → commute (u₁ : M) u₂ := semiconj_by.units_coe
105+
@[to_additive]
106+
theorem units_of_coe : commute (u₁ : M) u₂ → commute u₁ u₂ := semiconj_by.units_of_coe
107+
@[simp, to_additive]
108+
theorem units_coe_iff : commute (u₁ : M) u₂ ↔ commute u₁ u₂ := semiconj_by.units_coe_iff
109+
110+
end monoid
111+
112+
section group
113+
114+
variables {G : Type*} [group G] {a b : G}
115+
116+
@[to_additive]
117+
theorem inv_right : commute a b → commute a b⁻¹ := semiconj_by.inv_right
118+
@[simp, to_additive]
119+
theorem inv_right_iff : commute a b⁻¹ ↔ commute a b := semiconj_by.inv_right_iff
120+
121+
@[to_additive] theorem inv_left : commute a b → commute a⁻¹ b := semiconj_by.inv_symm_left
122+
@[simp, to_additive]
123+
theorem inv_left_iff : commute a⁻¹ b ↔ commute a b := semiconj_by.inv_symm_left_iff
124+
125+
@[to_additive]
126+
theorem inv_inv : commute a b → commute a⁻¹ b⁻¹ := semiconj_by.inv_inv_symm
127+
@[simp, to_additive]
128+
theorem inv_inv_iff : commute a⁻¹ b⁻¹ ↔ commute a b := semiconj_by.inv_inv_symm_iff
129+
130+
end group
131+
132+
end commute

src/algebra/group/hom.lean

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hughes,
55
Johannes Hölzl, Yury Kudryashov
66
-/
7-
import algebra.group.basic
7+
import algebra.group.commute
88
import tactic.ext
99

1010
/-!
@@ -294,3 +294,17 @@ namespace add_monoid_hom
294294
f (g - h) = (f g) - (f h) := f.map_add_neg g h
295295

296296
end add_monoid_hom
297+
298+
section commute
299+
300+
variables [monoid M] [monoid N] {a x y : M}
301+
302+
@[simp, to_additive]
303+
protected lemma semiconj_by.map (h : semiconj_by a x y) (f : M →* N) :
304+
semiconj_by (f a) (f x) (f y) :=
305+
by simpa only [semiconj_by, f.map_mul] using congr_arg f h
306+
307+
@[simp, to_additive]
308+
protected lemma commute.map (h : commute x y) (f : M →* N) : commute (f x) (f y) := h.map f
309+
310+
end commute

src/algebra/group/semiconj.lean

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/-
2+
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yury Kudryashov
5+
6+
Some proofs and docs came from `algebra/commute` (c) Neil Strickland
7+
-/
8+
import algebra.group.units
9+
import tactic.rewrite
10+
11+
/-!
12+
# Semiconjugate elements of a semigroup
13+
14+
## Main definitions
15+
16+
We say that `x` is semiconjugate to `y` by `a` (`semiconj_by a x y`), if `a * x = y * a`.
17+
In this file we provide operations on `semiconj_by _ _ _`.
18+
19+
In the names of these operations, we treat `a` as the “left” argument, and both `x` and `y` as
20+
“right” arguments. This way most names in this file agree with the names of the corresponding lemmas
21+
for `commute a b = semiconj_by a b b`. As a side effect, some lemmas have only `_right` version.
22+
23+
Lean does not immediately recognise these terms as equations, so for rewriting we need syntax like
24+
`rw [(h.pow_right 5).eq]` rather than just `rw [h.pow_right 5]`.
25+
26+
This file provides only basic operations (`mul_left`, `mul_right`, `inv_right` etc). Other
27+
operations (`pow_right`, field inverse etc) are in the files that define corresponding notions.
28+
-/
29+
30+
universes u v
31+
32+
/-- `x` is semiconjugate to `y` by `a`, if `a * x = y * a`. -/
33+
@[to_additive add_semiconj_by "`x` is additive semiconjugate to `y` by `a` if `a + x = y + a`"]
34+
def semiconj_by {M : Type u} [has_mul M] (a x y : M) : Prop := a * x = y * a
35+
36+
namespace semiconj_by
37+
38+
/-- Equality behind `semiconj_by a x y`; useful for rewriting. -/
39+
@[to_additive]
40+
protected lemma eq {S : Type u} [has_mul S] {a x y : S} (h : semiconj_by a x y) :
41+
a * x = y * a := h
42+
43+
section semigroup
44+
45+
variables {S : Type u} [semigroup S] {a b x y z x' y' : S}
46+
47+
/-- If `a` semiconjugates `x` to `y` and `x'` to `y'`,
48+
then it semiconjugates `x * x'` to `y * y'`. -/
49+
@[to_additive, simp] lemma mul_right (h : semiconj_by a x y) (h' : semiconj_by a x' y') :
50+
semiconj_by a (x * x') (y * y') :=
51+
by unfold semiconj_by; assoc_rw [h.eq, h'.eq]
52+
53+
/-- If both `a` and `b` semiconjugate `x` to `y`, then so does `a * b`. -/
54+
@[to_additive]
55+
lemma mul_left (ha : semiconj_by a y z) (hb : semiconj_by b x y) :
56+
semiconj_by (a * b) x z :=
57+
by unfold semiconj_by; assoc_rw [hb.eq, ha.eq, mul_assoc]
58+
59+
end semigroup
60+
61+
section monoid
62+
63+
variables {M : Type u} [monoid M]
64+
65+
/-- Any element semiconjugates `1` to `1`. -/
66+
@[simp, to_additive]
67+
lemma one_right (a : M) : semiconj_by a 1 1 := by rw [semiconj_by, mul_one, one_mul]
68+
69+
/-- One semiconjugates any element to itself. -/
70+
@[simp, to_additive]
71+
lemma one_left (x : M) : semiconj_by 1 x x := eq.symm $ one_right x
72+
73+
/-- If `a` semiconjugates a unit `x` to a unit `y`, then it semiconjugates `x⁻¹` to `y⁻¹`. -/
74+
@[to_additive] lemma units_inv_right {a : M} {x y : units M} (h : semiconj_by a x y) :
75+
semiconj_by a ↑x⁻¹ ↑y⁻¹ :=
76+
calc a * ↑x⁻¹ = ↑y⁻¹ * (y * a) * ↑x⁻¹ : by rw [units.inv_mul_cancel_left]
77+
... = ↑y⁻¹ * a : by rw [← h.eq, mul_assoc, units.mul_inv_cancel_right]
78+
79+
@[simp, to_additive] lemma units_inv_right_iff {a : M} {x y : units M} :
80+
semiconj_by a ↑x⁻¹ ↑y⁻¹ ↔ semiconj_by a x y :=
81+
⟨units_inv_right, units_inv_right⟩
82+
83+
/-- If a unit `a` semiconjugates `x` to `y`, then `a⁻¹` semiconjugates `y` to `x`. -/
84+
@[to_additive] lemma units_inv_symm_left {a : units M} {x y : M} (h : semiconj_by ↑a x y) :
85+
semiconj_by ↑a⁻¹ y x :=
86+
calc ↑a⁻¹ * y = ↑a⁻¹ * (y * a * ↑a⁻¹) : by rw [units.mul_inv_cancel_right]
87+
... = x * ↑a⁻¹ : by rw [← h.eq, ← mul_assoc, units.inv_mul_cancel_left]
88+
89+
@[simp, to_additive] lemma units_inv_symm_left_iff {a : units M} {x y : M} :
90+
semiconj_by ↑a⁻¹ y x ↔ semiconj_by ↑a x y :=
91+
⟨units_inv_symm_left, units_inv_symm_left⟩
92+
93+
@[to_additive] theorem units_coe {a x y : units M} (h : semiconj_by a x y) :
94+
semiconj_by (a : M) x y :=
95+
congr_arg units.val h
96+
97+
@[to_additive] theorem units_of_coe {a x y : units M} (h : semiconj_by (a : M) x y) :
98+
semiconj_by a x y :=
99+
units.ext h
100+
101+
@[simp, to_additive] theorem units_coe_iff {a x y : units M} :
102+
semiconj_by (a : M) x y ↔ semiconj_by a x y :=
103+
⟨units_of_coe, units_coe⟩
104+
105+
end monoid
106+
107+
section group
108+
109+
variables {G : Type u} [group G] {a x y : G}
110+
111+
@[simp, to_additive] lemma inv_right_iff : semiconj_by a x⁻¹ y⁻¹ ↔ semiconj_by a x y :=
112+
@units_inv_right_iff G _ a ⟨x, x⁻¹, mul_inv_self x, inv_mul_self x⟩
113+
⟨y, y⁻¹, mul_inv_self y, inv_mul_self y⟩
114+
115+
@[to_additive] lemma inv_right : semiconj_by a x y → semiconj_by a x⁻¹ y⁻¹ :=
116+
inv_right_iff.2
117+
118+
@[simp, to_additive] lemma inv_symm_left_iff : semiconj_by a⁻¹ y x ↔ semiconj_by a x y :=
119+
@units_inv_symm_left_iff G _ ⟨a, a⁻¹, mul_inv_self a, inv_mul_self a⟩ _ _
120+
121+
@[to_additive] lemma inv_symm_left : semiconj_by a x y → semiconj_by a⁻¹ y x :=
122+
inv_symm_left_iff.2
123+
124+
@[to_additive] lemma inv_inv_symm (h : semiconj_by a x y) : semiconj_by a⁻¹ y⁻¹ x⁻¹ :=
125+
h.inv_right.inv_symm_left
126+
127+
-- this is not a simp lemma because it can be deduced from other simp lemmas
128+
@[to_additive] lemma inv_inv_symm_iff : semiconj_by a⁻¹ y⁻¹ x⁻¹ ↔ semiconj_by a x y :=
129+
inv_right_iff.trans inv_symm_left_iff
130+
131+
/-- `a` semiconjugates `x` to `a * x * a⁻¹`. -/
132+
@[to_additive] lemma conj_mk (a x : G) : semiconj_by a x (a * x * a⁻¹) :=
133+
by unfold semiconj_by; rw [mul_assoc, inv_mul_self, mul_one]
134+
135+
end group
136+
137+
end semiconj_by
138+
139+
/-- `a` semiconjugates `x` to `a * x * a⁻¹`. -/
140+
@[to_additive]
141+
lemma units.mk_semiconj_by {M : Type u} [monoid M] (u : units M) (x : M) :
142+
semiconj_by ↑u x (u * x * ↑u⁻¹) :=
143+
by unfold semiconj_by; rw [units.inv_mul_cancel_right]

0 commit comments

Comments
 (0)