Skip to content

Commit 73a3870

Browse files
committed
chore: Delete Algebra.GroupPower.Basic, Algebra.GroupWithZero.Bitwise (#11855)
The entire `Algebra.GroupPower` folder is problematic in that it treats `pow` as an advanced subject while the rest of mathlib wants to treat it as a primitive. As such, its existence is an obstacle to developing the theory of `pow` transversally. This PR scatters the lemmas in `Algebra.GroupPower.Basic` to earlier files and deletes it. Also delete `Algebra.GroupWithZero.Bitwise` whose lemmas are completely deprecated (and hard to rehome). See #9411 for previous work.
1 parent da9a27f commit 73a3870

File tree

34 files changed

+166
-382
lines changed

34 files changed

+166
-382
lines changed

Mathlib.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ import Mathlib.Algebra.Group.Units.Equiv
248248
import Mathlib.Algebra.Group.Units.Hom
249249
import Mathlib.Algebra.Group.WithOne.Basic
250250
import Mathlib.Algebra.Group.WithOne.Defs
251-
import Mathlib.Algebra.GroupPower.Basic
252251
import Mathlib.Algebra.GroupPower.CovariantClass
253252
import Mathlib.Algebra.GroupPower.Identities
254253
import Mathlib.Algebra.GroupPower.IterateHom
@@ -258,7 +257,6 @@ import Mathlib.Algebra.GroupRingAction.Basic
258257
import Mathlib.Algebra.GroupRingAction.Invariant
259258
import Mathlib.Algebra.GroupRingAction.Subobjects
260259
import Mathlib.Algebra.GroupWithZero.Basic
261-
import Mathlib.Algebra.GroupWithZero.Bitwise
262260
import Mathlib.Algebra.GroupWithZero.Commute
263261
import Mathlib.Algebra.GroupWithZero.Defs
264262
import Mathlib.Algebra.GroupWithZero.Divisibility

Mathlib/Algebra/Divisibility/Prod.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Johan Commelin
55
-/
66
import Mathlib.Algebra.Divisibility.Basic
77
import Mathlib.Algebra.Group.Prod
8+
import Mathlib.Tactic.Common
89

910
/-!
1011
# Lemmas about the divisibility relation in product (semi)groups

Mathlib/Algebra/Field/Power.lean

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ Copyright (c) 2014 Robert Lewis. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro
55
-/
6-
import Mathlib.Algebra.Field.Defs
7-
import Mathlib.Algebra.GroupWithZero.Commute
8-
import Mathlib.Algebra.GroupWithZero.Bitwise
9-
import Mathlib.Algebra.Ring.Parity
6+
import Mathlib.Data.Int.Parity
107

118
#align_import algebra.field.power from "leanprover-community/mathlib"@"1e05171a5e8cf18d98d9cf7b207540acb044acae"
129

@@ -25,15 +22,11 @@ section DivisionRing
2522

2623
variable [DivisionRing α] {n : ℤ}
2724

28-
set_option linter.deprecated false in
29-
@[simp]
30-
theorem zpow_bit1_neg (a : α) (n : ℤ) : (-a) ^ bit1 n = -a ^ bit1 n := by
31-
rw [zpow_bit1', zpow_bit1', neg_mul_neg, neg_mul_eq_mul_neg]
32-
#align zpow_bit1_neg zpow_bit1_neg
33-
3425
theorem Odd.neg_zpow (h : Odd n) (a : α) : (-a) ^ n = -a ^ n := by
35-
obtain ⟨k, rfl⟩ := h.exists_bit1
36-
exact zpow_bit1_neg _ _
26+
have hn : n ≠ 0 := by rintro rfl; exact Int.odd_iff_not_even.1 h even_zero
27+
obtain ⟨k, rfl⟩ := h
28+
simp_rw [zpow_add' (.inr (.inl hn)), zpow_one, zpow_mul, zpow_two, neg_mul_neg,
29+
neg_mul_eq_mul_neg]
3730
#align odd.neg_zpow Odd.neg_zpow
3831

3932
theorem Odd.neg_one_zpow (h : Odd n) : (-1 : α) ^ n = -1 := by rw [h.neg_zpow, one_zpow]

Mathlib/Algebra/Group/Basic.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,13 @@ lemma zpow_mul' (a : α) (m n : ℤ) : a ^ (m * n) = (a ^ n) ^ m := by rw [Int.m
678678
#align zpow_mul' zpow_mul'
679679
#align mul_zsmul mul_zsmul
680680

681+
#noalign zpow_bit0
682+
#noalign bit0_zsmul
683+
#noalign zpow_bit0'
684+
#noalign bit0_zsmul'
685+
#noalign zpow_bit1
686+
#noalign bit1_zsmul
687+
681688
variable (a b c)
682689

683690
@[to_additive, field_simps] -- The attributes are out of order on purpose

Mathlib/Algebra/Group/Commute/Basic.lean

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,44 @@ protected theorem conj_iff (h : G) : Commute (h * a * h⁻¹) (h * b * h⁻¹)
9999
protected theorem conj (comm : Commute a b) (h : G) : Commute (h * a * h⁻¹) (h * b * h⁻¹) :=
100100
(Commute.conj_iff h).mpr comm
101101

102+
@[to_additive (attr := simp)]
103+
lemma zpow_right (h : Commute a b) (m : ℤ) : Commute a (b ^ m) := SemiconjBy.zpow_right h m
104+
#align commute.zpow_right Commute.zpow_right
105+
#align add_commute.zsmul_right AddCommute.zsmul_right
106+
107+
@[to_additive (attr := simp)]
108+
lemma zpow_left (h : Commute a b) (m : ℤ) : Commute (a ^ m) b := (h.symm.zpow_right m).symm
109+
#align commute.zpow_left Commute.zpow_left
110+
#align add_commute.zsmul_left AddCommute.zsmul_left
111+
112+
@[to_additive] lemma zpow_zpow (h : Commute a b) (m n : ℤ) : Commute (a ^ m) (b ^ n) :=
113+
(h.zpow_left m).zpow_right n
114+
#align commute.zpow_zpow Commute.zpow_zpow
115+
#align add_commute.zsmul_zsmul AddCommute.zsmul_zsmul
116+
117+
variable (a) (m n : ℤ)
118+
119+
@[to_additive] lemma self_zpow : Commute a (a ^ n) := (Commute.refl a).zpow_right n
120+
#align commute.self_zpow Commute.self_zpow
121+
#align add_commute.self_zsmul AddCommute.self_zsmul
122+
123+
@[to_additive] lemma zpow_self : Commute (a ^ n) a := (Commute.refl a).zpow_left n
124+
#align commute.zpow_self Commute.zpow_self
125+
#align add_commute.zsmul_self AddCommute.zsmul_self
126+
127+
@[to_additive] lemma zpow_zpow_self : Commute (a ^ m) (a ^ n) := (Commute.refl a).zpow_zpow m n
128+
#align commute.zpow_zpow_self Commute.zpow_zpow_self
129+
#align add_commute.zsmul_zsmul_self AddCommute.zsmul_zsmul_self
130+
102131
end Group
103132
end Commute
133+
134+
section Group
135+
variable [Group G]
136+
137+
@[to_additive] lemma pow_inv_comm (a : G) (m n : ℕ) : a⁻¹ ^ m * a ^ n = a ^ n * a⁻¹ ^ m :=
138+
(Commute.refl a).inv_left.pow_pow _ _
139+
#align pow_inv_comm pow_inv_comm
140+
#align nsmul_neg_comm nsmul_neg_comm
141+
142+
end Group

Mathlib/Algebra/Group/Commute/Defs.lean

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Most of the proofs come from the properties of `SemiconjBy`.
2828
-/
2929

3030

31-
variable {G : Type*}
31+
variable {G M S : Type*}
3232

3333
/-- Two elements commute if `a * b = b * a`. -/
3434
@[to_additive "Two elements additively commute if `a + b = b + a`"]
35-
def Commute {S : Type*} [Mul S] (a b : S) : Prop :=
35+
def Commute [Mul S] (a b : S) : Prop :=
3636
SemiconjBy a b b
3737
#align commute Commute
3838
#align add_commute AddCommute
@@ -41,13 +41,13 @@ def Commute {S : Type*} [Mul S] (a b : S) : Prop :=
4141
Two elements `a` and `b` commute if `a * b = b * a`.
4242
-/
4343
@[to_additive]
44-
theorem commute_iff_eq {S : Type*} [Mul S] (a b : S) : Commute a b ↔ a * b = b * a := Iff.rfl
44+
theorem commute_iff_eq [Mul S] (a b : S) : Commute a b ↔ a * b = b * a := Iff.rfl
4545

4646
namespace Commute
4747

4848
section Mul
4949

50-
variable {S : Type*} [Mul S]
50+
variable [Mul S]
5151

5252
/-- Equality behind `Commute a b`; useful for rewriting. -/
5353
@[to_additive "Equality behind `AddCommute a b`; useful for rewriting."]
@@ -97,7 +97,7 @@ end Mul
9797

9898
section Semigroup
9999

100-
variable {S : Type*} [Semigroup S] {a b c : S}
100+
variable [Semigroup S] {a b c : S}
101101

102102
/-- If `a` commutes with both `b` and `c`, then it commutes with their product. -/
103103
@[to_additive (attr := simp)
@@ -140,15 +140,15 @@ protected theorem mul_mul_mul_comm (hbc : Commute b c) (a d : S) :
140140
end Semigroup
141141

142142
@[to_additive]
143-
protected theorem all {S : Type*} [CommMagma S] (a b : S) : Commute a b :=
143+
protected theorem all [CommMagma S] (a b : S) : Commute a b :=
144144
mul_comm a b
145145
#align commute.all Commute.allₓ
146146
#align add_commute.all AddCommute.allₓ
147147
-- not sure why this needs an `ₓ`, maybe instance names not aligned?
148148

149149
section MulOneClass
150150

151-
variable {M : Type*} [MulOneClass M]
151+
variable [MulOneClass M]
152152

153153
@[to_additive (attr := simp)]
154154
theorem one_right (a : M) : Commute a 1 :=
@@ -168,7 +168,7 @@ end MulOneClass
168168

169169
section Monoid
170170

171-
variable {M : Type*} [Monoid M] {a b : M}
171+
variable [Monoid M] {a b : M}
172172

173173
@[to_additive (attr := simp)]
174174
theorem pow_right (h : Commute a b) (n : ℕ) : Commute a (b ^ n) :=
@@ -216,6 +216,11 @@ theorem pow_pow_self (a : M) (m n : ℕ) : Commute (a ^ m) (a ^ n) :=
216216
#align add_commute.nsmul_nsmul_self AddCommute.nsmul_nsmul_selfₓ
217217
-- `MulOneClass.toHasMul` vs. `MulOneClass.toMul`
218218

219+
@[to_additive] lemma mul_pow (h : Commute a b) : ∀ n, (a * b) ^ n = a ^ n * b ^ n
220+
| 0 => by rw [pow_zero, pow_zero, pow_zero, one_mul]
221+
| n + 1 => by simp only [pow_succ', h.mul_pow n, ← mul_assoc, (h.pow_left n).right_comm]
222+
#align commute.mul_pow Commute.mul_pow
223+
219224
end Monoid
220225

221226
section DivisionMonoid
@@ -232,6 +237,13 @@ protected theorem inv (hab : Commute a b) : (a * b)⁻¹ = a⁻¹ * b⁻¹ := by
232237
#align commute.inv Commute.inv
233238
#align add_commute.neg AddCommute.neg
234239

240+
@[to_additive AddCommute.zsmul_add]
241+
protected lemma mul_zpow (h : Commute a b) : ∀ n : ℤ, (a * b) ^ n = a ^ n * b ^ n
242+
| (n : ℕ) => by simp [zpow_natCast, h.mul_pow n]
243+
| .negSucc n => by simp [h.mul_pow, (h.pow_pow _ _).eq, mul_inv_rev]
244+
#align commute.mul_zpow Commute.mul_zpow
245+
#align add_commute.zsmul_add AddCommute.zsmul_add
246+
235247
end DivisionMonoid
236248

237249
section Group
@@ -253,3 +265,31 @@ theorem mul_inv_cancel_assoc (h : Commute a b) : a * (b * a⁻¹) = b := by
253265
end Group
254266

255267
end Commute
268+
269+
set_option linter.deprecated false
270+
271+
section Monoid
272+
variable [Monoid M]
273+
274+
@[to_additive bit0_nsmul]
275+
lemma pow_bit0 (a : M) (n : ℕ) : a ^ bit0 n = a ^ n * a ^ n := pow_add _ _ _
276+
#align pow_bit0 pow_bit0
277+
#align bit0_nsmul bit0_nsmul
278+
279+
@[to_additive bit1_nsmul]
280+
lemma pow_bit1 (a : M) (n : ℕ) : a ^ bit1 n = a ^ n * a ^ n * a := by rw [bit1, pow_succ, pow_bit0]
281+
#align pow_bit1 pow_bit1
282+
#align bit1_nsmul bit1_nsmul
283+
284+
@[to_additive bit0_nsmul']
285+
lemma pow_bit0' (a : M) (n : ℕ) : a ^ bit0 n = (a * a) ^ n := by
286+
rw [pow_bit0, (Commute.refl a).mul_pow]
287+
#align pow_bit0' pow_bit0'
288+
#align bit0_nsmul' bit0_nsmul'
289+
290+
@[to_additive bit1_nsmul']
291+
lemma pow_bit1' (a : M) (n : ℕ) : a ^ bit1 n = (a * a) ^ n * a := by rw [bit1, pow_succ, pow_bit0']
292+
#align pow_bit1' pow_bit1'
293+
#align bit1_nsmul' bit1_nsmul'
294+
295+
end Monoid

Mathlib/Algebra/Group/Defs.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,6 @@ monoids. To work, it has to map fields to fields. This means that we should also
582582
fields to the multiplicative structure `Monoid`, which could solve defeq problems for powers if
583583
needed. These problems do not come up in practice, so most of the time we will not need to adjust
584584
the `npow` field when defining multiplicative objects.
585-
586-
A basic theory for the power function on monoids and the `ℕ`-action on additive monoids is built in
587-
the file `Algebra.GroupPower.Basic`. For now, we only register the most basic properties that we
588-
need right away.
589585
-/
590586

591587

Mathlib/Algebra/Group/Even.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ This file defines square and even elements in a monoid.
3131
`Mathlib.Algebra.Ring.Parity` for the definition of odd elements.
3232
-/
3333

34-
-- TODO: After #11855
35-
-- assert_not_exists MonoidWithZero
36-
assert_not_exists Ring
34+
assert_not_exists MonoidWithZero
3735

3836
open MulOpposite
3937

Mathlib/Algebra/Group/Hom/End.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ end AddMonoid.End
5959
/-!
6060
### Miscellaneous definitions
6161
62-
Due to the fact this file imports `Algebra.GroupPower.Basic`, it is not possible to import it in
63-
some of the lower-level files like `Algebra.Ring.Basic`. The following lemmas should be rehomed
64-
if the import structure permits them to be.
62+
This file used to import `Algebra.GroupPower.Basic`, hence it was not possible to import it in
63+
some of the lower-level files like `Algebra.Ring.Basic`. The following lemmas should be rehomed now
64+
that `Algebra.GroupPower.Basic` was deleted.
6565
-/
6666

6767

Mathlib/Algebra/Group/Int.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Jeremy Avigad
55
-/
66
import Mathlib.Algebra.Group.Nat
77
import Mathlib.Order.Monotone.Basic
8+
import Mathlib.Tactic.Common
89

910
#align_import data.int.basic from "leanprover-community/mathlib"@"00d163e35035c3577c1c79fa53b68de17781ffc1"
1011
#align_import data.int.units from "leanprover-community/mathlib"@"641b6a82006416ec431b2987b354af9311fed4f2"

0 commit comments

Comments
 (0)