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

Commit a285049

Browse files
committed
chore(algebra/group_hom): rename add_monoid.smul to nsmul (#2861)
Also drop `•` as a notation for two `smul`s declared in this file, use `•ℕ` and `•ℤ` instead. This way one can immediately see that a lemma uses `nsmul`/`gsmul`, not `has_scalar.smul`.
1 parent 28e79d4 commit a285049

29 files changed

+242
-256
lines changed

src/algebra/archimedean.lean

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import data.rat
1010

1111
variables {α : Type*}
1212

13-
open_locale add_monoid
14-
1513
class archimedean (α) [ordered_add_comm_monoid α] : Prop :=
16-
(arch : ∀ (x : α) {y}, 0 < y → ∃ n : ℕ, x ≤ n • y)
14+
(arch : ∀ (x : α) {y}, 0 < y → ∃ n : ℕ, x ≤ n • y)
1715

1816
theorem exists_nat_gt [linear_ordered_semiring α] [archimedean α]
1917
(x : α) : ∃ n : ℕ, x < n :=
2018
let ⟨n, h⟩ := archimedean.arch x zero_lt_one in
21-
⟨n+1, lt_of_le_of_lt (by rwa ← add_monoid.smul_one)
19+
⟨n+1, lt_of_le_of_lt (by rwa ← nsmul_one)
2220
(nat.cast_lt.2 (nat.lt_succ_self _))⟩
2321

2422
section linear_ordered_ring
@@ -30,8 +28,8 @@ have hy0 : 0 < y - 1 := sub_pos_of_lt hy1,
3028
-- TODO `by linarith` fails to prove hy1'
3129
have hy1' : (-1:α) ≤ y, from le_trans (neg_le_self zero_le_one) (le_of_lt hy1),
3230
let ⟨n, h⟩ := archimedean.arch x hy0 in
33-
⟨n, calc x ≤ n • (y - 1) : h
34-
... < 1 + n • (y - 1) : lt_one_add _
31+
⟨n, calc x ≤ n • (y - 1) : h
32+
... < 1 + n • (y - 1) : lt_one_add _
3533
... ≤ y ^ n : one_add_sub_mul_le_pow hy1' n⟩
3634

3735
/-- Every x greater than 1 is between two successive natural-number
@@ -124,11 +122,11 @@ end
124122
end linear_ordered_field
125123

126124
instance : archimedean ℕ :=
127-
⟨λ n m m0, ⟨n, by simpa only [mul_one, nat.smul_eq_mul] using nat.mul_le_mul_left n m0⟩⟩
125+
⟨λ n m m0, ⟨n, by simpa only [mul_one, nat.nsmul_eq_mul] using nat.mul_le_mul_left n m0⟩⟩
128126

129127
instance : archimedean ℤ :=
130128
⟨λ n m m0, ⟨n.to_nat, le_trans (int.le_to_nat _) $
131-
by simpa only [add_monoid.smul_eq_mul, int.nat_cast_eq_coe_nat, zero_add, mul_one] using mul_le_mul_of_nonneg_left
129+
by simpa only [nsmul_eq_mul, int.nat_cast_eq_coe_nat, zero_add, mul_one] using mul_le_mul_of_nonneg_left
132130
(int.add_one_le_iff.2 m0) (int.coe_zero_le n.to_nat)⟩⟩
133131

134132
noncomputable def archimedean.floor_ring (α)
@@ -143,7 +141,7 @@ theorem archimedean_iff_nat_lt :
143141
archimedean α ↔ ∀ x : α, ∃ n : ℕ, x < n :=
144142
⟨@exists_nat_gt α _, λ H, ⟨λ x y y0,
145143
(H (x / y)).imp $ λ n h, le_of_lt $
146-
by rwa [div_lt_iff y0, ← add_monoid.smul_eq_mul] at h⟩⟩
144+
by rwa [div_lt_iff y0, ← nsmul_eq_mul] at h⟩⟩
147145

148146
theorem archimedean_iff_nat_le :
149147
archimedean α ↔ ∀ x : α, ∃ n : ℕ, x ≤ n :=

src/algebra/big_operators.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -742,26 +742,26 @@ lemma sum_update_of_mem [add_comm_monoid β] [decidable_eq α] {s : finset α} {
742742
by { rw [update_eq_piecewise, sum_piecewise], simp [h] }
743743
attribute [to_additive] prod_update_of_mem
744744

745-
lemma sum_smul' [add_comm_monoid β] (s : finset α) (n : ℕ) (f : α → β) :
746-
(∑ x in s, add_monoid.smul n (f x)) = add_monoid.smul n ((∑ x in s, f x)) :=
745+
lemma sum_nsmul [add_comm_monoid β] (s : finset α) (n : ℕ) (f : α → β) :
746+
(∑ x in s, n •ℕ (f x)) = n •ℕ ((∑ x in s, f x)) :=
747747
@prod_pow _ (multiplicative β) _ _ _ _
748-
attribute [to_additive sum_smul'] prod_pow
748+
attribute [to_additive sum_nsmul] prod_pow
749749

750750
@[simp] lemma sum_const [add_comm_monoid β] (b : β) :
751-
(∑ x in s, b) = add_monoid.smul s.card b :=
751+
(∑ x in s, b) = s.card •ℕ b :=
752752
@prod_const _ (multiplicative β) _ _ _
753753
attribute [to_additive] prod_const
754754

755755
lemma sum_comp [add_comm_monoid β] [decidable_eq γ] {s : finset α} (f : γ → β) (g : α → γ) :
756-
∑ a in s, f (g a) = ∑ b in s.image g, add_monoid.smul (s.filter (λ a, g a = b)).card (f b) :=
756+
∑ a in s, f (g a) = ∑ b in s.image g, (s.filter (λ a, g a = b)).card •ℕ (f b) :=
757757
@prod_comp _ (multiplicative β) _ _ _ _ _ _
758758
attribute [to_additive "The sum of the composition of functions `f` and `g`, is the sum
759759
over `b ∈ s.image g` of `f b` times of the cardinality of the fibre of `b`"] prod_comp
760760

761761
lemma sum_const_nat {m : ℕ} {f : α → ℕ} (h₁ : ∀x ∈ s, f x = m) :
762762
(∑ x in s, f x) = card s * m :=
763763
begin
764-
rw [← nat.smul_eq_mul, ← sum_const],
764+
rw [← nat.nsmul_eq_mul, ← sum_const],
765765
apply sum_congr rfl h₁
766766
end
767767

@@ -1238,7 +1238,7 @@ calc (∑ i in range n, i) * 2 = (∑ i in range n, i) + (∑ i in range n, (n -
12381238
... = ∑ i in range n, (i + (n - 1 - i)) : sum_add_distrib.symm
12391239
... = ∑ i in range n, (n - 1) : sum_congr rfl $ λ i hi, nat.add_sub_cancel' $
12401240
nat.le_pred_of_lt $ mem_range.1 hi
1241-
... = n * (n - 1) : by rw [sum_const, card_range, nat.smul_eq_mul]
1241+
... = n * (n - 1) : by rw [sum_const, card_range, nat.nsmul_eq_mul]
12421242

12431243
/-- Gauss' summation formula -/
12441244
lemma sum_range_id (n : ℕ) : (∑ i in range n, i) = (n * (n - 1)) / 2 :=

src/algebra/commute.lean

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ Most of the proofs come from the properties of `semiconj_by`.
3434
/-- Two elements commute iff `a * b = b * a`. -/
3535
def commute {S : Type*} [has_mul S] (a b : S) : Prop := semiconj_by a b b
3636

37-
open_locale smul
38-
3937
namespace commute
4038

4139
section has_mul
@@ -167,15 +165,15 @@ semiconj_by.add_left
167165

168166
variables [semiring A] {a b : A} (hab : commute a b) (m n : ℕ)
169167

170-
@[simp] theorem smul_right : commute a (n •ℕ b) := hab.smul_right n
171-
@[simp] theorem smul_left : commute (n •ℕ a) b := hab.smul_left n
172-
@[simp] theorem smul_smul : commute (m •ℕ a) (n •ℕ b) := hab.smul_smul m n
168+
@[simp] theorem nsmul_right : commute a (n •ℕ b) := hab.nsmul_right n
169+
@[simp] theorem nsmul_left : commute (n •ℕ a) b := hab.nsmul_left n
170+
@[simp] theorem nsmul_nsmul : commute (m •ℕ a) (n •ℕ b) := hab.nsmul_nsmul m n
173171

174172
variable (a)
175173

176-
@[simp] theorem self_smul : commute a (n •ℕ a) := (commute.refl a).smul_right n
177-
@[simp] theorem smul_self : commute (n •ℕ a) a := (commute.refl a).smul_left n
178-
@[simp] theorem self_smul_smul : commute (m •ℕ a) (n •ℕ a) := (commute.refl a).smul_smul m n
174+
@[simp] theorem self_nsmul : commute a (n •ℕ a) := (commute.refl a).nsmul_right n
175+
@[simp] theorem nsmul_self : commute (n •ℕ a) a := (commute.refl a).nsmul_left n
176+
@[simp] theorem self_nsmul_nsmul : commute (m •ℕ a) (n •ℕ a) := (commute.refl a).nsmul_nsmul m n
179177

180178
@[simp] theorem cast_nat_right : commute a (n : A) := semiconj_by.cast_nat_right a n
181179
@[simp] theorem cast_nat_left : commute (n : A) a := semiconj_by.cast_nat_left n a

src/algebra/geom_sum.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ calc (finset.range n).sum (λ i, x ^ i * x ^ (n - 1 - i))
8484
= (finset.range n).sum (λ i, x ^ (i + (n - 1 - i))) : by simp_rw [← pow_add]
8585
... = (finset.range n).sum (λ i, x ^ (n - 1)) : finset.sum_congr rfl
8686
(λ i hi, congr_arg _ $ nat.add_sub_cancel' $ nat.le_pred_of_lt $ finset.mem_range.1 hi)
87-
... = add_monoid.smul (finset.range n).card (x ^ (n - 1)) : finset.sum_const _
88-
... = n * x ^ (n - 1) : by rw [finset.card_range, add_monoid.smul_eq_mul]
87+
... = (finset.range n).card •ℕ (x ^ (n - 1)) : finset.sum_const _
88+
... = n * x ^ (n - 1) : by rw [finset.card_range, nsmul_eq_mul]
8989

9090
/-- $x^n-y^n = (x-y) \sum x^ky^{n-1-k}$ reformulated without `-` signs. -/
9191
theorem geom_sum₂_mul_add [comm_semiring α] (x y : α) (n : ℕ) :

0 commit comments

Comments
 (0)