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

Commit f8fe596

Browse files
committed
chore(algebra/*): missing simp/inj lemmas (#2557)
Sometimes I have a specialized `ext` lemma for `A →+ B` that uses structure of `A` (e.g., `A = monoid_algebra α R`) and want to apply it to `A →+* B` or `A →ₐ[R] B`. These `coe_*_inj` lemmas make it easier. Also add missing `simp` lemmas for bundled multiplication and rename `pow_of_add` and `gpow_of_add` to `of_add_smul` and `of_add_gsmul`, respectively.
1 parent cb3a017 commit f8fe596

File tree

4 files changed

+53
-17
lines changed

4 files changed

+53
-17
lines changed

src/algebra/group/hom.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,15 @@ def mul_left {R : Type*} [semiring R] (r : R) : R →+ R :=
271271
map_zero' := mul_zero r,
272272
map_add' := mul_add r }
273273

274+
@[simp] lemma coe_mul_left {R : Type*} [semiring R] (r : R) : ⇑(mul_left r) = (*) r := rfl
275+
274276
/-- Right multiplication by an element of a (semi)ring is an `add_monoid_hom` -/
275277
def mul_right {R : Type*} [semiring R] (r : R) : R →+ R :=
276278
{ to_fun := λ a, a * r,
277279
map_zero' := zero_mul r,
278280
map_add' := λ _ _, add_mul _ _ r }
279281

282+
@[simp] lemma mul_right_apply {R : Type*} [semiring R] (a r : R) :
283+
(mul_right r : R → R) a = a * r := rfl
284+
280285
end add_monoid_hom

src/algebra/group_power.lean

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,10 @@ end int
671671
@[simp] lemma neg_square {α} [ring α] (z : α) : (-z)^2 = z^2 :=
672672
by simp [pow, monoid.pow]
673673

674-
@[simp] lemma pow_of_add [add_monoid A] (x : A) (n : ℕ) :
674+
lemma of_add_smul [add_monoid A] (x : A) (n : ℕ) :
675675
multiplicative.of_add (n • x) = (multiplicative.of_add x)^n := rfl
676676

677-
@[simp] lemma gpow_of_add [add_group A] (x : A) (n : ℤ) :
677+
lemma of_add_gsmul [add_group A] (x : A) (n : ℤ) :
678678
multiplicative.of_add (n •ℤ x) = (multiplicative.of_add x)^n := rfl
679679

680680
variables (M G A)
@@ -685,15 +685,15 @@ def powers_hom [monoid M] : M ≃ (multiplicative ℕ →* M) :=
685685
{ to_fun := λ x, ⟨λ n, x ^ n.to_add, pow_zero x, λ m n, pow_add x m n⟩,
686686
inv_fun := λ f, f (multiplicative.of_add 1),
687687
left_inv := pow_one,
688-
right_inv := λ f, monoid_hom.ext $ λ n, by { simp [← f.map_pow, ← pow_of_add] } }
688+
right_inv := λ f, monoid_hom.ext $ λ n, by { simp [← f.map_pow, ← of_add_smul] } }
689689

690690
/-- Monoid homomorphisms from `multiplicative ℤ` are defined by the image
691691
of `multiplicative.of_add 1`. -/
692692
def gpowers_hom [group G] : G ≃ (multiplicative ℤ →* G) :=
693693
{ to_fun := λ x, ⟨λ n, x ^ n.to_add, gpow_zero x, λ m n, gpow_add x m n⟩,
694694
inv_fun := λ f, f (multiplicative.of_add 1),
695695
left_inv := gpow_one,
696-
right_inv := λ f, monoid_hom.ext $ λ n, by { simp [← f.map_gpow, ← gpow_of_add] } }
696+
right_inv := λ f, monoid_hom.ext $ λ n, by { simp [← f.map_gpow, ← of_add_gsmul ] } }
697697

698698
/-- Additive homomorphisms from `ℕ` are defined by the image of `1`. -/
699699
def multiples_hom [add_monoid A] : A ≃ (ℕ →+ A) :=
@@ -708,3 +708,19 @@ def gmultiples_hom [add_group A] : A ≃ (ℤ →+ A) :=
708708
inv_fun := λ f, f 1,
709709
left_inv := one_gsmul,
710710
right_inv := λ f, add_monoid_hom.ext $ λ n, by simp [← f.map_gsmul] }
711+
712+
variables {M G A}
713+
714+
@[simp] lemma powers_hom_apply [monoid M] (x : M) (n : multiplicative ℕ) :
715+
powers_hom M x n = x ^ n.to_add := rfl
716+
717+
@[simp] lemma powers_hom_symm_apply [monoid M] (f : multiplicative ℕ →* M) :
718+
(powers_hom M).symm f = f (multiplicative.of_add 1) := rfl
719+
720+
lemma mnat_monoid_hom_eq [monoid M] (f : multiplicative ℕ →* M) (n : multiplicative ℕ) :
721+
f n = (f (multiplicative.of_add 1)) ^ n.to_add :=
722+
by rw [← powers_hom_symm_apply, ← powers_hom_apply, equiv.apply_symm_apply]
723+
724+
lemma mnat_monoid_hom_ext [monoid M] ⦃f g : multiplicative ℕ →* M⦄
725+
(h : f (multiplicative.of_add 1) = g (multiplicative.of_add 1)) : f = g :=
726+
monoid_hom.ext $ λ n, by rw [mnat_monoid_hom_eq f, mnat_monoid_hom_eq g, h]

src/algebra/ring.lean

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,21 +357,13 @@ instance {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} : has
357357
instance {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} : has_coe (α →+* β) (α →+ β) :=
358358
⟨ring_hom.to_add_monoid_hom⟩
359359

360-
lemma coe_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β}
361-
(f : α →+* β) (a : α) :
362-
((f : α →* β) : α → β) a = (f : α → β) a := rfl
363-
lemma coe_add_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β}
364-
(f : α →+* β) (a : α) :
365-
((f : α →+ β) : α → β) a = (f : α → β) a := rfl
366-
367360
@[simp, norm_cast]
368-
lemma coe_monoid_hom' {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) :
369-
((f : α →* β) : α → β) = (f : α → β) := rfl
361+
lemma coe_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) :
362+
⇑(f : α →* β) = f := rfl
370363

371364
@[simp, norm_cast]
372-
lemma coe_add_monoid_hom' {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β}
373-
(f : α →+* β) :
374-
((f : α →+ β) : α → β) = (f : α → β) := rfl
365+
lemma coe_add_monoid_hom {α : Type*} {β : Type*} {rα : semiring α} {rβ : semiring β} (f : α →+* β) :
366+
⇑(f : α →+ β) = f := rfl
375367

376368
namespace ring_hom
377369

@@ -400,6 +392,12 @@ coe_inj (funext h)
400392
theorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=
401393
⟨λ h x, h ▸ rfl, λ h, ext h⟩
402394

395+
theorem coe_add_monoid_hom_inj : function.injective (coe : (α →+* β) → (α →+ β)) :=
396+
λ f g h, coe_inj $ show ((f : α →+ β) : α → β) = (g : α →+ β), from congr_arg coe_fn h
397+
398+
theorem coe_monoid_hom_inj : function.injective (coe : (α →+* β) → (α →* β)) :=
399+
λ f g h, coe_inj $ show ((f : α →* β) : α → β) = (g : α →* β), from congr_arg coe_fn h
400+
403401
/-- Ring homomorphisms map zero to zero. -/
404402
@[simp] lemma map_zero (f : α →+* β) : f 0 = 0 := f.map_zero'
405403

src/ring_theory/algebra.lean

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,35 @@ instance coe_ring_hom : has_coe (A →ₐ[R] B) (A →+* B) := ⟨alg_hom.to_rin
208208

209209
instance coe_monoid_hom : has_coe (A →ₐ[R] B) (A →* B) := ⟨λ f, ↑(f : A →+* B)⟩
210210

211+
instance coe_add_monoid_hom : has_coe (A →ₐ[R] B) (A →+ B) := ⟨λ f, ↑(f : A →+* B)⟩
212+
211213
@[simp, norm_cast] lemma coe_mk {f : A → B} (h₁ h₂ h₃ h₄ h₅) :
212214
⇑(⟨f, h₁, h₂, h₃, h₄, h₅⟩ : A →ₐ[R] B) = f := rfl
213215

214216
@[simp, norm_cast] lemma coe_to_ring_hom (f : A →ₐ[R] B) : ⇑(f : A →+* B) = f := rfl
215217

216218
@[simp, norm_cast] lemma coe_to_monoid_hom (f : A →ₐ[R] B) : ⇑(f : A →* B) = f := rfl
217219

220+
@[simp, norm_cast] lemma coe_to_add_monoid_hom (f : A →ₐ[R] B) : ⇑(f : A →+ B) = f := rfl
221+
218222
variables (φ : A →ₐ[R] B)
219223

224+
theorem coe_fn_inj ⦃φ₁ φ₂ : A →ₐ[R] B⦄ (H : ⇑φ₁ = φ₂) : φ₁ = φ₂ :=
225+
by { cases φ₁, cases φ₂, congr, exact H }
226+
227+
theorem coe_ring_hom_inj : function.injective (coe : (A →ₐ[R] B) → (A →+* B)) :=
228+
λ φ₁ φ₂ H, coe_fn_inj $ show ((φ₁ : (A →+* B)) : A → B) = ((φ₂ : (A →+* B)) : A → B),
229+
from congr_arg _ H
230+
231+
theorem coe_monoid_hom_inj : function.injective (coe : (A →ₐ[R] B) → (A →* B)) :=
232+
function.injective_comp ring_hom.coe_monoid_hom_inj coe_ring_hom_inj
233+
234+
theorem coe_add_monoid_hom_inj : function.injective (coe : (A →ₐ[R] B) → (A →+ B)) :=
235+
function.injective_comp ring_hom.coe_add_monoid_hom_inj coe_ring_hom_inj
236+
220237
@[ext]
221238
theorem ext ⦃φ₁ φ₂ : A →ₐ[R] B⦄ (H : ∀ x, φ₁ x = φ₂ x) : φ₁ = φ₂ :=
222-
by cases φ₁; cases φ₂; congr' 1; ext; apply H
239+
coe_fn_inj $ funext H
223240

224241
theorem commutes (r : R) : φ (algebra_map R A r) = algebra_map R B r := φ.commutes' r
225242

0 commit comments

Comments
 (0)