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

Commit 0e95cad

Browse files
committed
chore(algebra/group_power/basic): generalisation linter (#13095)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent 6652766 commit 0e95cad

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

src/algebra/group_power/basic.lean

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ First we prove some facts about `semiconj_by` and `commute`. They do not require
4141
`pow` and/or `nsmul` and will be useful later in this file.
4242
-/
4343

44+
section has_pow
45+
variables [has_pow M ℕ]
46+
47+
@[simp] lemma pow_ite (P : Prop) [decidable P] (a : M) (b c : ℕ) :
48+
a ^ (if P then b else c) = if P then a ^ b else a ^ c :=
49+
by split_ifs; refl
50+
51+
@[simp] lemma ite_pow (P : Prop) [decidable P] (a b : M) (c : ℕ) :
52+
(if P then a else b) ^ c = if P then a ^ c else b ^ c :=
53+
by split_ifs; refl
54+
55+
end has_pow
56+
4457
section monoid
4558
variables [monoid M] [monoid N] [add_monoid A] [add_monoid B]
4659

@@ -63,14 +76,6 @@ theorem pow_add (a : M) (m n : ℕ) : a^(m + n) = a^m * a^n :=
6376
by induction n with n ih; [rw [nat.add_zero, pow_zero, mul_one],
6477
rw [pow_succ', ← mul_assoc, ← ih, ← pow_succ', nat.add_assoc]]
6578

66-
@[simp] lemma pow_ite (P : Prop) [decidable P] (a : M) (b c : ℕ) :
67-
a ^ (if P then b else c) = if P then a ^ b else a ^ c :=
68-
by split_ifs; refl
69-
70-
@[simp] lemma ite_pow (P : Prop) [decidable P] (a b : M) (c : ℕ) :
71-
(if P then a else b) ^ c = if P then a ^ c else b ^ c :=
72-
by split_ifs; refl
73-
7479
@[simp] lemma pow_boole (P : Prop) [decidable P] (a : M) :
7580
a ^ (if P then 1 else 0) = if P then a else 1 :=
7681
by simp
@@ -127,6 +132,16 @@ by rw [pow_bit0, (commute.refl a).mul_pow]
127132
theorem pow_bit1' (a : M) (n : ℕ) : a ^ bit1 n = (a * a) ^ n * a :=
128133
by rw [bit1, pow_succ', pow_bit0']
129134

135+
lemma dvd_pow {x y : M} (hxy : x ∣ y) :
136+
∀ {n : ℕ} (hn : n ≠ 0), x ∣ y^n
137+
| 0 hn := (hn rfl).elim
138+
| (n + 1) hn := by { rw pow_succ, exact hxy.mul_right _ }
139+
140+
alias dvd_pow ← has_dvd.dvd.pow
141+
142+
lemma dvd_pow_self (a : M) {n : ℕ} (hn : n ≠ 0) : a ∣ a^n :=
143+
dvd_rfl.pow hn
144+
130145
end monoid
131146

132147
/-!
@@ -153,16 +168,6 @@ def pow_monoid_hom (n : ℕ) : M →* M :=
153168
-- the below line causes the linter to complain :-/
154169
-- attribute [simps] pow_monoid_hom nsmul_add_monoid_hom
155170

156-
lemma dvd_pow {x y : M} (hxy : x ∣ y) :
157-
∀ {n : ℕ} (hn : n ≠ 0), x ∣ y^n
158-
| 0 hn := (hn rfl).elim
159-
| (n + 1) hn := by { rw pow_succ, exact hxy.mul_right _ }
160-
161-
alias dvd_pow ← has_dvd.dvd.pow
162-
163-
lemma dvd_pow_self (a : M) {n : ℕ} (hn : n ≠ 0) : a ∣ a^n :=
164-
dvd_rfl.pow hn
165-
166171
end comm_monoid
167172

168173
section div_inv_monoid
@@ -407,7 +412,8 @@ by rw [sq, sq, mul_self_sub_mul_self]
407412

408413
alias sq_sub_sq ← pow_two_sub_pow_two
409414

410-
lemma eq_or_eq_neg_of_sq_eq_sq [is_domain R] (a b : R) (h : a ^ 2 = b ^ 2) : a = b ∨ a = -b :=
415+
lemma eq_or_eq_neg_of_sq_eq_sq [no_zero_divisors R] (a b : R) (h : a ^ 2 = b ^ 2) :
416+
a = b ∨ a = -b :=
411417
by rwa [← add_eq_zero_iff_eq_neg, ← sub_eq_zero, or_comm, ← mul_eq_zero,
412418
← sq_sub_sq a b, sub_eq_zero]
413419

@@ -419,7 +425,8 @@ alias sub_sq ← sub_pow_two
419425
/- Copies of the above comm_ring lemmas for `units R`. -/
420426
namespace units
421427

422-
lemma eq_or_eq_neg_of_sq_eq_sq [is_domain R] (a b : Rˣ) (h : a ^ 2 = b ^ 2) : a = b ∨ a = -b :=
428+
lemma eq_or_eq_neg_of_sq_eq_sq [no_zero_divisors R] (a b : Rˣ) (h : a ^ 2 = b ^ 2) :
429+
a = b ∨ a = -b :=
423430
begin
424431
refine (eq_or_eq_neg_of_sq_eq_sq _ _ _).imp (λ h, units.ext h) (λ h, units.ext h),
425432
replace h := congr_arg (coe : Rˣ → R) h,
@@ -433,13 +440,14 @@ end comm_ring
433440
lemma of_add_nsmul [add_monoid A] (x : A) (n : ℕ) :
434441
multiplicative.of_add (n • x) = (multiplicative.of_add x)^n := rfl
435442

436-
lemma of_add_zsmul [add_group A] (x : A) (n : ℤ) :
443+
lemma of_add_zsmul [sub_neg_monoid A] (x : A) (n : ℤ) :
437444
multiplicative.of_add (n • x) = (multiplicative.of_add x)^n := rfl
438445

439446
lemma of_mul_pow [monoid A] (x : A) (n : ℕ) :
440447
additive.of_mul (x ^ n) = n • (additive.of_mul x) := rfl
441448

442-
lemma of_mul_zpow [group G] (x : G) (n : ℤ) : additive.of_mul (x ^ n) = n • additive.of_mul x :=
449+
lemma of_mul_zpow [div_inv_monoid G] (x : G) (n : ℤ) :
450+
additive.of_mul (x ^ n) = n • additive.of_mul x :=
443451
rfl
444452

445453
@[simp] lemma semiconj_by.zpow_right [group G] {a x y : G} (h : semiconj_by a x y) :

0 commit comments

Comments
 (0)