Skip to content

Commit dbdc6d8

Browse files
committed
chore: use IsAddTorsionFree M instead of NoZeroSMulDivisors ℕ M/NoZeroSMulDivisors ℤ M (#30683)
These are all equivalent spellings, but the former works without knowing about `Module`.
1 parent 1680f0b commit dbdc6d8

File tree

30 files changed

+101
-100
lines changed

30 files changed

+101
-100
lines changed

Mathlib/Algebra/Lie/Sl2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ structure HasPrimitiveVectorWith (t : IsSl2Triple h e f) (m : M) (μ : R) : Prop
8181

8282
/-- Given a representation of a Lie algebra with distinguished `sl₂` triple, a simultaneous
8383
eigenvector for the action of both `h` and `e` necessarily has eigenvalue zero for `e`. -/
84-
lemma HasPrimitiveVectorWith.mk' [NoZeroSMulDivisors ℤ M] (t : IsSl2Triple h e f) (m : M) (μ ρ : R)
84+
lemma HasPrimitiveVectorWith.mk' [IsAddTorsionFree M] (t : IsSl2Triple h e f) (m : M) (μ ρ : R)
8585
(hm : m ≠ 0) (hm' : ⁅h, m⁆ = μ • m) (he : ⁅e, m⁆ = ρ • m) :
8686
HasPrimitiveVectorWith t m μ where
8787
ne_zero := hm

Mathlib/Algebra/Lie/Weights/Chain.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ variable [LieRing.IsNilpotent L] (χ₁ χ₂ : L → R) (p q : ℤ)
6666

6767
section
6868

69-
variable [NoZeroSMulDivisors ℤ R] [NoZeroSMulDivisors R M] [IsNoetherian R M] (hχ₁ : χ₁ ≠ 0)
69+
variable [IsAddTorsionFree R] [NoZeroSMulDivisors R M] [IsNoetherian R M] (hχ₁ : χ₁ ≠ 0)
7070
include hχ₁
7171

7272
lemma eventually_genWeightSpace_smul_add_eq_bot :
@@ -249,7 +249,7 @@ section
249249

250250
variable {M}
251251
variable [LieRing.IsNilpotent L]
252-
variable [NoZeroSMulDivisors ℤ R] [NoZeroSMulDivisors R M] [IsNoetherian R M]
252+
variable [IsAddTorsionFree R] [NoZeroSMulDivisors R M] [IsNoetherian R M]
253253
variable (α : L → R) (β : Weight R L M)
254254

255255
/-- This is the largest `n : ℕ` such that `i • α + β` is a weight for all `0 ≤ i ≤ n`. -/

Mathlib/Algebra/Lie/Weights/Killing.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ lemma exists_isSl2Triple_of_weight_isNonZero {α : Weight K H L} (hα : α.IsNon
556556
mul_one, two_smul, two_smul]
557557
refine ⟨⁅e, f⁆, e, f, ⟨fun contra ↦ ?_, rfl, hef, ?_⟩, heα, Submodule.smul_mem _ _ hfα⟩
558558
· rw [contra] at hef
559-
have _i : NoZeroSMulDivisors ℤ L := NoZeroSMulDivisors.int_of_charZero K L
559+
have : IsAddTorsionFree L := .of_noZeroSMulDivisors K L
560560
simp only [zero_lie, eq_comm (a := (0 : L)), smul_eq_zero, OfNat.ofNat_ne_zero, false_or] at hef
561561
contradiction
562562
· have : ⁅⁅e, f'⁆, f'⁆ = - α h • f' := lie_eq_smul_of_mem_rootSpace hfα h

Mathlib/Algebra/Module/Rat.lean

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro
55
-/
66
import Mathlib.Algebra.Module.Basic
7-
import Mathlib.Algebra.NoZeroSMulDivisors.Basic
7+
import Mathlib.Algebra.Module.End
88
import Mathlib.Algebra.Field.Rat
99

1010
/-!
@@ -104,12 +104,18 @@ instance SMulCommClass.rat' [Monoid α] [AddCommGroup M] [DistribMulAction α M]
104104

105105
end
106106

107-
-- see note [lower instance priority]
108-
instance (priority := 100) NNRatModule.noZeroSMulDivisors [AddCommMonoid M] [Module ℚ≥0 M] :
109-
NoZeroSMulDivisors ℕ M :=
110-
fun {k} {x : M} h => by simpa [← Nat.cast_smul_eq_nsmul ℚ≥0 k x] using h⟩
107+
variable (M) in
108+
/-- A `ℚ≥0`-module is torsion-free as a group.
111109
112-
-- see note [lower instance priority]
113-
instance (priority := 100) RatModule.noZeroSMulDivisors [AddCommGroup M] [Module ℚ M] :
114-
NoZeroSMulDivisors ℤ M :=
115-
fun {k} {x : M} h => by simpa [← Int.cast_smul_eq_zsmul ℚ k x] using h⟩
110+
This instance will fire for any monoid `M`, so is local unless needed elsewhere. -/
111+
lemma IsAddTorsionFree.of_module_nnrat [AddCommMonoid M] [Module ℚ≥0 M] : IsAddTorsionFree M where
112+
nsmul_right_injective n hn x y hxy := by
113+
simpa [← Nat.cast_smul_eq_nsmul ℚ≥0 n, *] using congr((n⁻¹ : ℚ≥0) • $hxy)
114+
115+
variable (M) in
116+
/-- A `ℚ≥0`-module is torsion-free as a group.
117+
118+
This instance will fire for any monoid `M`, so is local unless needed elsewhere. -/
119+
lemma IsAddTorsionFree.of_module_rat [AddCommGroup M] [Module ℚ M] : IsAddTorsionFree M where
120+
nsmul_right_injective n hn x y hxy := by
121+
simpa [← Nat.cast_smul_eq_nsmul ℚ n, *] using congr((n⁻¹ : ℚ) • $hxy)

Mathlib/Algebra/Module/Torsion.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ lemma infinite_range_add_smul_iff
10001000
exact smul_left_injective _ h hrs
10011001

10021002
@[simp]
1003-
lemma infinite_range_add_nsmul_iff [AddCommGroup M] [NoZeroSMulDivisors ℤ M] (x y : M) :
1003+
lemma infinite_range_add_nsmul_iff [AddCommGroup M] [IsAddTorsionFree M] (x y : M) :
10041004
(Set.range <| fun n : ℕ ↦ x + n • y).Infinite ↔ y ≠ 0 := by
10051005
refine ⟨fun h hy ↦ by simp [hy] at h, fun h ↦ Set.infinite_range_of_injective fun r s hrs ↦ ?_⟩
10061006
rw [add_right_inj, ← natCast_zsmul, ← natCast_zsmul] at hrs

Mathlib/Algebra/Module/ZLattice/Basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,18 +508,21 @@ instance instModuleFinite_of_discrete_submodule {E : Type*} [NormedAddCommGroup
508508
theorem ZLattice.module_free [IsZLattice K L] : Module.Free ℤ L := by
509509
have : Module.Finite ℤ L := module_finite K L
510510
have : Module ℚ E := Module.compHom E (algebraMap ℚ K)
511+
have : IsAddTorsionFree E := .of_module_rat _
511512
infer_instance
512513

513514
instance instModuleFree_of_discrete_submodule {E : Type*} [NormedAddCommGroup E]
514515
[NormedSpace ℝ E] [FiniteDimensional ℝ E] (L : Submodule ℤ E) [DiscreteTopology L] :
515516
Module.Free ℤ L := by
516517
have : Module ℚ E := Module.compHom E (algebraMap ℚ ℝ)
518+
have : IsAddTorsionFree E := .of_module_rat _
517519
infer_instance
518520

519521
theorem ZLattice.rank [hs : IsZLattice K L] : finrank ℤ L = finrank K E := by
520522
classical
521523
have : Module.Finite ℤ L := module_finite K L
522524
have : Module ℚ E := Module.compHom E (algebraMap ℚ K)
525+
have : IsAddTorsionFree E := .of_module_rat _
523526
let b₀ := Module.Free.chooseBasis ℤ L
524527
-- Let `b` be a `ℤ`-basis of `L` formed of vectors of `E`
525528
let b := Subtype.val ∘ b₀

Mathlib/Algebra/NoZeroSMulDivisors/Basic.lean

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ variable {R M : Type*}
2222

2323
section Module
2424

25-
section Nat
26-
27-
theorem Nat.noZeroSMulDivisors
28-
(R) (M) [Semiring R] [CharZero R] [AddCommMonoid M] [Module R M] [NoZeroSMulDivisors R M] :
29-
NoZeroSMulDivisors ℕ M where
30-
eq_zero_or_eq_zero_of_smul_eq_zero {c x} := by rw [← Nat.cast_smul_eq_nsmul R, smul_eq_zero]; simp
31-
32-
end Nat
33-
3425
variable [Semiring R]
3526
variable (R M)
3627

@@ -59,6 +50,22 @@ theorem smul_right_inj [NoZeroSMulDivisors R M] {c : R} (hc : c ≠ 0) {x y : M}
5950
(smul_right_injective M hc).eq_iff
6051

6152
end SMulInjective
53+
54+
section Nat
55+
variable (R M) [CharZero R] [NoZeroSMulDivisors R M]
56+
57+
include R in
58+
lemma IsAddTorsionFree.of_noZeroSMulDivisors : IsAddTorsionFree M where
59+
nsmul_right_injective n hn := by
60+
simp_rw [← Nat.cast_smul_eq_nsmul R]; apply smul_right_injective; simpa
61+
62+
@[deprecated IsAddTorsionFree.of_noZeroSMulDivisors (since := "2025-10-19")]
63+
theorem Nat.noZeroSMulDivisors
64+
(R) (M) [Semiring R] [CharZero R] [AddCommMonoid M] [Module R M] [NoZeroSMulDivisors R M] :
65+
NoZeroSMulDivisors ℕ M where
66+
eq_zero_or_eq_zero_of_smul_eq_zero {c x} := by rw [← Nat.cast_smul_eq_nsmul R, smul_eq_zero]; simp
67+
68+
end Nat
6269
end AddCommGroup
6370

6471
section Module
@@ -82,27 +89,22 @@ theorem smul_left_injective {x : M} (hx : x ≠ 0) : Function.Injective fun c :
8289

8390
end SMulInjective
8491

85-
instance [NoZeroSMulDivisors ℤ M] : NoZeroSMulDivisors ℕ M :=
86-
fun {c x} hcx ↦ by rwa [← Nat.cast_smul_eq_nsmul ℤ, smul_eq_zero, Nat.cast_eq_zero] at hcx⟩
87-
8892
variable (R M)
8993

94+
@[deprecated IsAddTorsionFree.of_noZeroSMulDivisors (since := "2025-10-19")]
9095
theorem NoZeroSMulDivisors.int_of_charZero
9196
(R) (M) [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] [CharZero R] :
9297
NoZeroSMulDivisors ℤ M :=
9398
fun {z x} h ↦ by simpa [← smul_one_smul R z x] using h⟩
9499

95100
/-- Only a ring of characteristic zero can have a non-trivial module without additive or
96101
scalar torsion. -/
97-
theorem CharZero.of_noZeroSMulDivisors [Nontrivial M] [NoZeroSMulDivisors ℤ M] : CharZero R := by
102+
theorem CharZero.of_noZeroSMulDivisors [Nontrivial M] [IsAddTorsionFree M] : CharZero R := by
98103
refine ⟨fun {n m h} ↦ ?_⟩
99104
obtain ⟨x, hx⟩ := exists_ne (0 : M)
100105
replace h : (n : ℤ) • x = (m : ℤ) • x := by simp [← Nat.cast_smul_eq_nsmul R, h]
101106
simpa using smul_left_injective ℤ hx h
102107

103-
instance [AddCommGroup M] [NoZeroSMulDivisors ℤ M] : NoZeroSMulDivisors ℕ M :=
104-
fun {c x} hcx ↦ by rwa [← Nat.cast_smul_eq_nsmul ℤ c x, smul_eq_zero, Nat.cast_eq_zero] at hcx⟩
105-
106108
end Module
107109

108110
section GroupWithZero

Mathlib/Algebra/Polynomial/Derivative.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ theorem iterate_derivative_one {k} (h : 0 < k) : derivative^[k] (1 : R[X]) = 0 :
220220
theorem iterate_derivative_X {k} (h : 1 < k) : derivative^[k] (X : R[X]) = 0 :=
221221
iterate_derivative_eq_zero <| natDegree_X_le.trans_lt h
222222

223-
theorem natDegree_eq_zero_of_derivative_eq_zero [NoZeroSMulDivisors ℕ R] {f : R[X]}
223+
theorem natDegree_eq_zero_of_derivative_eq_zero [IsAddTorsionFree R] {f : R[X]}
224224
(h : derivative f = 0) : f.natDegree = 0 := by
225225
rcases eq_or_ne f 0 with (rfl | hf)
226226
· exact natDegree_zero
@@ -236,7 +236,7 @@ theorem natDegree_eq_zero_of_derivative_eq_zero [NoZeroSMulDivisors ℕ R] {f :
236236
rw [hm, ← leadingCoeff, leadingCoeff_eq_zero] at h2
237237
exact hf h2
238238

239-
theorem eq_C_of_derivative_eq_zero [NoZeroSMulDivisors ℕ R] {f : R[X]} (h : derivative f = 0) :
239+
theorem eq_C_of_derivative_eq_zero [IsAddTorsionFree R] {f : R[X]} (h : derivative f = 0) :
240240
f = C (f.coeff 0) :=
241241
eq_C_of_natDegree_eq_zero <| natDegree_eq_zero_of_derivative_eq_zero h
242242

@@ -289,15 +289,15 @@ theorem iterate_derivative_natCast_mul {n k : ℕ} {f : R[X]} :
289289
derivative^[k] ((n : R[X]) * f) = n * derivative^[k] f := by
290290
induction k generalizing f <;> simp [*]
291291

292-
theorem mem_support_derivative [NoZeroSMulDivisors ℕ R] (p : R[X]) (n : ℕ) :
292+
theorem mem_support_derivative [IsAddTorsionFree R] (p : R[X]) (n : ℕ) :
293293
n ∈ (derivative p).support ↔ n + 1 ∈ p.support := by
294294
suffices ¬p.coeff (n + 1) * (n + 1 : ℕ) = 0 ↔ coeff p (n + 1) ≠ 0 by
295295
simpa only [mem_support_iff, coeff_derivative, Ne, Nat.cast_succ]
296296
rw [← nsmul_eq_mul', smul_eq_zero]
297297
simp only [Nat.succ_ne_zero, false_or]
298298

299299
@[simp]
300-
theorem degree_derivative_eq [NoZeroSMulDivisors ℕ R] (p : R[X]) (hp : 0 < natDegree p) :
300+
theorem degree_derivative_eq [IsAddTorsionFree R] (p : R[X]) (hp : 0 < natDegree p) :
301301
degree (derivative p) = (natDegree p - 1 : ℕ) := by
302302
apply le_antisymm
303303
· rw [derivative_apply]

Mathlib/Algebra/Polynomial/HasseDeriv.lean

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,12 @@ theorem hasseDeriv_natDegree_eq_C : f.hasseDeriv f.natDegree = C f.leadingCoeff
189189
rw [eq_C_of_natDegree_le_zero this, hasseDeriv_coeff, zero_add, Nat.choose_self,
190190
Nat.cast_one, one_mul, leadingCoeff]
191191

192-
theorem natDegree_hasseDeriv [NoZeroSMulDivisors ℕ R] (p : R[X]) (n : ℕ) :
192+
theorem natDegree_hasseDeriv [IsAddTorsionFree R] (p : R[X]) (n : ℕ) :
193193
natDegree (hasseDeriv n p) = natDegree p - n := by
194-
rcases lt_or_ge p.natDegree n with hn | hn
195-
· simpa [hasseDeriv_eq_zero_of_lt_natDegree, hn] using (tsub_eq_zero_of_le hn.le).symm
196-
· refine map_natDegree_eq_sub ?_ ?_
197-
· exact fun h => hasseDeriv_eq_zero_of_lt_natDegree _ _
198-
· classical
199-
simp only [ite_eq_right_iff, Ne, natDegree_monomial, hasseDeriv_monomial]
200-
intro k c c0 hh
201-
-- this is where we use the `smul_eq_zero` from `NoZeroSMulDivisors`
202-
rw [← nsmul_eq_mul, smul_eq_zero, Nat.choose_eq_zero_iff] at hh
203-
exact (tsub_eq_zero_of_le (Or.resolve_right hh c0).le).symm
194+
classical
195+
refine map_natDegree_eq_sub (fun h => hasseDeriv_eq_zero_of_lt_natDegree _ _) ?_
196+
simp only [Ne, hasseDeriv_monomial, natDegree_monomial, ite_eq_right_iff]
197+
simp +contextual [← nsmul_eq_mul, Nat.choose_eq_zero_iff, le_of_lt]
204198

205199
section
206200

Mathlib/Algebra/Ring/CharZero.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ variable [Semiring R] [CharZero R]
7373
@[simp] lemma Nat.cast_pow_eq_one {a : ℕ} (hn : n ≠ 0) : (a : R) ^ n = 1 ↔ a = 1 := by
7474
simp [← cast_pow, cast_eq_one, hn]
7575

76+
variable [IsCancelMulZero R]
77+
78+
/-- A characteristic zero domain is torsion-free. -/
79+
instance (priority := 100) IsAddTorsionFree.of_isCancelMulZero_charZero : IsAddTorsionFree R where
80+
nsmul_right_injective n hn a b hab := by let : CancelMonoidWithZero R := {}; simpa [hn] using hab
81+
7682
end Semiring
7783

7884
section NonAssocRing

0 commit comments

Comments
 (0)