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

Commit 9078914

Browse files
committed
feat(algebra/group): make map_[z]pow generic in monoid_hom_class (#10749)
This PR makes `map_pow` take a `monoid_hom_class` instead of specifically a `monoid_hom`.
1 parent f46a7a0 commit 9078914

File tree

15 files changed

+78
-56
lines changed

15 files changed

+78
-56
lines changed

src/algebra/group/hom.lean

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,25 @@ by rw [map_mul, map_inv]
281281
(f : F) (x y : G) : f (x / y) = f x / f y :=
282282
by rw [div_eq_mul_inv, div_eq_mul_inv, map_mul_inv]
283283

284+
@[simp, to_additive map_nsmul] theorem map_pow [monoid G] [monoid H] [monoid_hom_class F G H]
285+
(f : F) (a : G) :
286+
∀ (n : ℕ), f (a ^ n) = (f a) ^ n
287+
| 0 := by rw [pow_zero, pow_zero, map_one]
288+
| (n+1) := by rw [pow_succ, pow_succ, map_mul, map_pow]
289+
290+
@[to_additive]
291+
theorem map_zpow' [div_inv_monoid G] [div_inv_monoid H] [monoid_hom_class F G H]
292+
(f : F) (hf : ∀ (x : G), f (x⁻¹) = (f x)⁻¹) (a : G) :
293+
∀ n : ℤ, f (a ^ n) = (f a) ^ n
294+
| (n : ℕ) := by rw [zpow_coe_nat, map_pow, zpow_coe_nat]
295+
| -[1+n] := by rw [zpow_neg_succ_of_nat, hf, map_pow, ← zpow_neg_succ_of_nat]
296+
297+
/-- Group homomorphisms preserve integer power. -/
298+
@[simp, to_additive /-" Additive group homomorphisms preserve integer scaling. "-/]
299+
theorem map_zpow [group G] [group H] [monoid_hom_class F G H] (f : F) (g : G) (n : ℤ) :
300+
f (g ^ n) = (f g) ^ n :=
301+
map_zpow' f (map_inv f) g n
302+
284303
end mul_one
285304

286305
section mul_zero_one
@@ -760,18 +779,16 @@ monoid_with_zero_hom.ext $ λ x, rfl
760779
(f : monoid_with_zero_hom M N) : (monoid_with_zero_hom.id N).comp f = f :=
761780
monoid_with_zero_hom.ext $ λ x, rfl
762781

763-
@[simp, to_additive add_monoid_hom.map_nsmul]
764-
theorem monoid_hom.map_pow [monoid M] [monoid N] (f : M →* N) (a : M) :
765-
∀(n : ℕ), f (a ^ n) = (f a) ^ n
766-
| 0 := by rw [pow_zero, pow_zero, f.map_one]
767-
| (n+1) := by rw [pow_succ, pow_succ, f.map_mul, monoid_hom.map_pow]
782+
@[to_additive add_monoid_hom.map_nsmul]
783+
protected theorem monoid_hom.map_pow [monoid M] [monoid N] (f : M →* N) (a : M) (n : ℕ) :
784+
f (a ^ n) = (f a) ^ n :=
785+
map_pow f a n
768786

769787
@[to_additive]
770-
theorem monoid_hom.map_zpow' [div_inv_monoid M] [div_inv_monoid N] (f : M →* N)
771-
(hf : ∀ x, f (x⁻¹) = (f x)⁻¹) (a : M) :
772-
∀ n : ℤ, f (a ^ n) = (f a) ^ n
773-
| (n : ℕ) := by rw [zpow_coe_nat, f.map_pow, zpow_coe_nat]
774-
| -[1+n] := by rw [zpow_neg_succ_of_nat, hf, f.map_pow, ← zpow_neg_succ_of_nat]
788+
protected theorem monoid_hom.map_zpow' [div_inv_monoid M] [div_inv_monoid N] (f : M →* N)
789+
(hf : ∀ x, f (x⁻¹) = (f x)⁻¹) (a : M) (n : ℤ) :
790+
f (a ^ n) = (f a) ^ n :=
791+
map_zpow' f hf a n
775792

776793
@[to_additive]
777794
theorem monoid_hom.map_div' [div_inv_monoid M] [div_inv_monoid N] (f : M →* N)
@@ -926,9 +943,10 @@ protected theorem map_inv {G H} [group G] [group H] (f : G →* H) (g : G) : f g
926943
map_inv f g
927944

928945
/-- Group homomorphisms preserve integer power. -/
929-
@[simp, to_additive /-" Additive group homomorphisms preserve integer scaling. "-/]
930-
theorem map_zpow {G H} [group G] [group H] (f : G →* H) (g : G) (n : ℤ) : f (g ^ n) = (f g) ^ n :=
931-
f.map_zpow' f.map_inv g n
946+
@[to_additive /-" Additive group homomorphisms preserve integer scaling. "-/]
947+
protected theorem map_zpow {G H} [group G] [group H] (f : G →* H) (g : G) (n : ℤ) :
948+
f (g ^ n) = (f g) ^ n :=
949+
map_zpow f g n
932950

933951
/-- Group homomorphisms preserve division. -/
934952
@[to_additive /-" Additive group homomorphisms preserve subtraction. "-/]

src/algebra/group_power/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ namespace ring_hom
286286

287287
variables [semiring R] [semiring S]
288288

289-
@[simp] lemma map_pow (f : R →+* S) (a) :
289+
protected lemma map_pow (f : R →+* S) (a) :
290290
∀ n : ℕ, f (a ^ n) = (f a) ^ n :=
291-
f.to_monoid_hom.map_pow a
291+
map_pow f a
292292

293293
end ring_hom
294294

src/category_theory/preadditive/default.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ map_neg (left_comp R f) g
133133
by simp
134134

135135
lemma nsmul_comp (n : ℕ) : (n • f) ≫ g = n • (f ≫ g) :=
136-
map_nsmul (right_comp _ _) _ _
136+
map_nsmul (right_comp P g) f n
137137

138138
lemma comp_nsmul (n : ℕ) : f ≫ (n • g) = n • (f ≫ g) :=
139-
map_nsmul (left_comp _ _) _ _
139+
map_nsmul (left_comp R f) g n
140140

141141
lemma zsmul_comp (n : ℤ) : (n • f) ≫ g = n • (f ≫ g) :=
142-
map_zsmul (right_comp _ _) _ _
142+
map_zsmul (right_comp P g) f n
143143

144144
lemma comp_zsmul (n : ℤ) : f ≫ (n • g) = n • (f ≫ g) :=
145-
map_zsmul (left_comp _ _) _ _
145+
map_zsmul (left_comp R f) g n
146146

147147
@[reassoc] lemma comp_sum {P Q R : C} {J : Type*} (s : finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) :
148148
f ≫ ∑ j in s, g j = ∑ j in s, f ≫ g j :=

src/data/polynomial/derivative.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ theorem derivative_map [comm_semiring S] (p : polynomial R) (f : R →+* S) :
214214
polynomial.induction_on p
215215
(λ r, by rw [map_C, derivative_C, derivative_C, map_zero])
216216
(λ p q ihp ihq, by rw [map_add, derivative_add, ihp, ihq, derivative_add, map_add])
217-
(λ n r ih, by rw [map_mul, map_C, map_pow, map_X,
217+
(λ n r ih, by rw [map_mul, map_C, polynomial.map_pow, map_X,
218218
derivative_mul, derivative_pow_succ, derivative_C, zero_mul, zero_add, derivative_X, mul_one,
219219
derivative_mul, derivative_pow_succ, derivative_C, zero_mul, zero_add, derivative_X, mul_one,
220-
map_mul, map_C, map_mul, map_pow, map_add, map_nat_cast, map_one, map_X])
220+
map_mul, map_C, map_mul, polynomial.map_pow, map_add, map_nat_cast, map_one, map_X])
221221

222222
@[simp]
223223
theorem iterate_derivative_map [comm_semiring S] (p : polynomial R) (f : R →+* S) (k : ℕ):

src/data/polynomial/eval.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@ ring_hom.ext $ map_map g f
594594
lemma map_list_prod (L : list (polynomial R)) : L.prod.map f = (L.map $ map f).prod :=
595595
eq.symm $ list.prod_hom _ (map_ring_hom f).to_monoid_hom
596596

597-
@[simp] lemma map_pow (n : ℕ) : (p ^ n).map f = p.map f ^ n := (map_ring_hom f).map_pow _ _
597+
@[simp] protected lemma map_pow (n : ℕ) : (p ^ n).map f = p.map f ^ n :=
598+
(map_ring_hom f).map_pow _ _
598599

599600
lemma mem_map_srange {p : polynomial S} :
600601
p ∈ (map_ring_hom f).srange ↔ ∀ n, p.coeff n ∈ f.srange :=
@@ -606,7 +607,7 @@ begin
606607
intros i hi,
607608
rcases h i with ⟨c, hc⟩,
608609
use [C c * X^i],
609-
rw [coe_map_ring_hom, map_mul, map_C, hc, map_pow, map_X] }
610+
rw [coe_map_ring_hom, map_mul, map_C, hc, polynomial.map_pow, map_X] }
610611
end
611612

612613
lemma mem_map_range {R S : Type*} [ring R] [ring S] (f : R →+* S)

src/data/polynomial/lifts.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ begin
199199
{ rw [← erase_lead_add_C_mul_X_pow p, er_zero, zero_add, monic.def.1 hmonic, C_1, one_mul],
200200
use X ^ p.nat_degree,
201201
repeat {split},
202-
{ simp only [map_pow, map_X] },
202+
{ simp only [polynomial.map_pow, map_X] },
203203
{ rw [@degree_X_pow R _ Rtrivial, degree_X_pow] },
204204
{exact monic_pow monic_X p.nat_degree } },
205205
obtain ⟨q, hq⟩ := mem_lifts_and_degree_eq (erase_mem_lifts p.nat_degree hlifts),
@@ -210,7 +210,7 @@ begin
210210
← @degree_X_pow R _ Rtrivial p.nat_degree] at deg_er,
211211
use q + X ^ p.nat_degree,
212212
repeat {split},
213-
{ simp only [hq, map_add, map_pow, map_X],
213+
{ simp only [hq, map_add, polynomial.map_pow, map_X],
214214
nth_rewrite 3 [← erase_lead_add_C_mul_X_pow p],
215215
rw [erase_lead, monic.leading_coeff hmonic, C_1, one_mul] },
216216
{ rw [degree_add_eq_right_of_degree_lt deg_er, @degree_X_pow R _ Rtrivial p.nat_degree,

src/field_theory/abel_ruffini.lean

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ begin
182182
have C_mul_C : (C (i a⁻¹)) * (C (i a)) = 1,
183183
{ rw [←C_mul, ←i.map_mul, inv_mul_cancel ha, i.map_one, C_1] },
184184
have key1 : (X ^ n - 1).map i = C (i a⁻¹) * ((X ^ n - C a).map i).comp (C b * X),
185-
{ rw [polynomial.map_sub, polynomial.map_sub, map_pow, map_X, map_C, polynomial.map_one, sub_comp,
186-
pow_comp, X_comp, C_comp, mul_pow, ←C_pow, hb, mul_sub, ←mul_assoc, C_mul_C, one_mul] },
185+
{ rw [polynomial.map_sub, polynomial.map_sub, polynomial.map_pow, map_X, map_C,
186+
polynomial.map_one, sub_comp, pow_comp, X_comp, C_comp, mul_pow, ←C_pow, hb, mul_sub,
187+
←mul_assoc, C_mul_C, one_mul] },
187188
have key2 : (λ q : polynomial E, q.comp (C b * X)) ∘ (λ c : E, X - C c) =
188189
(λ c : E, C b * (X - C (c / b))),
189190
{ ext1 c,
@@ -202,10 +203,11 @@ begin
202203
apply gal_is_solvable_tower (X ^ n - 1) (X ^ n - C x),
203204
{ exact splits_X_pow_sub_one_of_X_pow_sub_C _ n hx (splitting_field.splits _) },
204205
{ exact gal_X_pow_sub_one_is_solvable n },
205-
{ rw [polynomial.map_sub, map_pow, map_X, map_C],
206+
{ rw [polynomial.map_sub, polynomial.map_pow, map_X, map_C],
206207
apply gal_X_pow_sub_C_is_solvable_aux,
207208
have key := splitting_field.splits (X ^ n - 1 : polynomial F),
208-
rwa [←splits_id_iff_splits, polynomial.map_sub, map_pow, map_X, polynomial.map_one] at key }
209+
rwa [←splits_id_iff_splits, polynomial.map_sub, polynomial.map_pow, map_X, polynomial.map_one]
210+
at key }
209211
end
210212

211213
end gal_X_pow_sub_C
@@ -311,7 +313,7 @@ begin
311313
{ refine gal_is_solvable_tower p (p.comp (X ^ n)) _ hα _,
312314
{ exact gal.splits_in_splitting_field_of_comp _ _ (by rwa [nat_degree_X_pow]) },
313315
{ obtain ⟨s, hs⟩ := exists_multiset_of_splits _ (splitting_field.splits p),
314-
rw [map_comp, map_pow, map_X, hs, mul_comp, C_comp],
316+
rw [map_comp, polynomial.map_pow, map_X, hs, mul_comp, C_comp],
315317
apply gal_mul_is_solvable (gal_C_is_solvable _),
316318
rw prod_comp,
317319
apply gal_prod_is_solvable,

src/field_theory/finite/basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@ instance : is_splitting_field (zmod p) K (X^q - X) :=
276276
begin
277277
have h : (X^q - X : polynomial K).nat_degree = q :=
278278
X_pow_card_sub_X_nat_degree_eq K fintype.one_lt_card,
279-
rw [←splits_id_iff_splits, splits_iff_card_roots, polynomial.map_sub, map_pow, map_X, h,
280-
roots_X_pow_card_sub_X K, ←finset.card_def, finset.card_univ],
279+
rw [←splits_id_iff_splits, splits_iff_card_roots, polynomial.map_sub, polynomial.map_pow,
280+
map_X, h, roots_X_pow_card_sub_X K, ←finset.card_def, finset.card_univ],
281281
end,
282282
adjoin_roots :=
283283
begin
284284
classical,
285285
transitivity algebra.adjoin (zmod p) ((roots (X^q - X : polynomial K)).to_finset : set K),
286-
{ simp only [map_pow, map_X, polynomial.map_sub], convert rfl },
286+
{ simp only [polynomial.map_pow, map_X, polynomial.map_sub], convert rfl },
287287
{ rw [roots_X_pow_card_sub_X, val_to_finset, coe_univ, algebra.adjoin_univ], }
288288
end }
289289

src/field_theory/finite/galois_field.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ begin
9393
apply subring.closure_induction hx; clear_dependent x; simp_rw mem_root_set aux,
9494
{ rintros x (⟨r, rfl⟩ | hx),
9595
{ simp only [aeval_X_pow, aeval_X, alg_hom.map_sub],
96-
rw [← ring_hom.map_pow, zmod.pow_card_pow, sub_self], },
96+
rw [← map_pow, zmod.pow_card_pow, sub_self], },
9797
{ dsimp only [galois_field] at hx,
9898
rwa mem_root_set aux at hx, }, },
9999
{ dsimp only [g_poly],
@@ -144,7 +144,7 @@ by exactI (is_splitting_field.alg_equiv (zmod p) (X ^ (p ^ 1) - X : polynomial (
144144
variables {K : Type*} [field K] [fintype K] [algebra (zmod p) K]
145145

146146
theorem splits_X_pow_card_sub_X : splits (algebra_map (zmod p) K) (X ^ fintype.card K - X) :=
147-
by rw [←splits_id_iff_splits, polynomial.map_sub, map_pow, map_X, splits_iff_card_roots,
147+
by rw [←splits_id_iff_splits, polynomial.map_sub, polynomial.map_pow, map_X, splits_iff_card_roots,
148148
finite_field.roots_X_pow_card_sub_X, ←finset.card_def, finset.card_univ,
149149
finite_field.X_pow_card_sub_X_nat_degree_eq]; exact fintype.one_lt_card
150150

@@ -157,8 +157,8 @@ lemma is_splitting_field_of_card_eq (h : fintype.card K = p ^ n) :
157157
{ rintro rfl, rw [pow_zero, fintype.card_eq_one_iff_nonempty_unique] at h,
158158
cases h, resetI, exact false_of_nontrivial_of_subsingleton K },
159159
refine algebra.eq_top_iff.mpr (λ x, algebra.subset_adjoin _),
160-
rw [polynomial.map_sub, map_pow, map_X, finset.mem_coe, multiset.mem_to_finset, mem_roots,
161-
is_root.def, eval_sub, eval_pow, eval_X, ← h, finite_field.pow_card, sub_self],
160+
rw [polynomial.map_sub, polynomial.map_pow, map_X, finset.mem_coe, multiset.mem_to_finset,
161+
mem_roots, is_root.def, eval_sub, eval_pow, eval_X, ← h, finite_field.pow_card, sub_self],
162162
exact finite_field.X_pow_card_pow_sub_X_ne_zero K hne (fact.out _)
163163
end }
164164

src/linear_algebra/tensor_product.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ lemma map_mul (f₁ f₂ : M →ₗ[R] M) (g₁ g₂ : N →ₗ[R] N) :
643643
map (f₁ * f₂) (g₁ * g₂) = (map f₁ g₁) * (map f₂ g₂) :=
644644
map_comp f₁ f₂ g₁ g₂
645645

646-
@[simp] lemma map_pow (f : M →ₗ[R] M) (g : N →ₗ[R] N) (n : ℕ) :
646+
@[simp] protected lemma map_pow (f : M →ₗ[R] M) (g : N →ₗ[R] N) (n : ℕ) :
647647
(map f g)^n = map (f^n) (g^n) :=
648648
begin
649649
induction n with n ih,
@@ -827,10 +827,10 @@ by simp only [ltensor, rtensor, ← map_comp, id_comp, comp_id]
827827
variables {M}
828828

829829
@[simp] lemma rtensor_pow (f : M →ₗ[R] M) (n : ℕ) : (f.rtensor N)^n = (f^n).rtensor N :=
830-
by { have h := map_pow f (id : N →ₗ[R] N) n, rwa id_pow at h, }
830+
by { have h := tensor_product.map_pow f (id : N →ₗ[R] N) n, rwa id_pow at h, }
831831

832832
@[simp] lemma ltensor_pow (f : N →ₗ[R] N) (n : ℕ) : (f.ltensor M)^n = (f^n).ltensor M :=
833-
by { have h := map_pow (id : M →ₗ[R] M) f n, rwa id_pow at h, }
833+
by { have h := tensor_product.map_pow (id : M →ₗ[R] M) f n, rwa id_pow at h, }
834834

835835
end linear_map
836836

0 commit comments

Comments
 (0)