Skip to content

Commit 044bc75

Browse files
committed
chore(Algebra): replace NoZeroSMulDivisors with Module.IsTorsionFree, losing generality (#33873)
`NoZeroSMulDivisors R M` is mathematically wrong when `R` isn't a domain, so we replace it with the better definition `Module.IsTorsionFree R M` whenever they are equivalent. This PR continues #30563, replacing `NoZeroSMulDivisors R M` with `Module.IsTorsionFree R M` even when this loses generality.
1 parent 3b17c8f commit 044bc75

File tree

68 files changed

+243
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+243
-502
lines changed

Mathlib/Algebra/Algebra/Basic.lean

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ open Function Module
3131

3232
namespace Algebra
3333

34-
variable {R : Type u} {A : Type w}
34+
variable {R A M : Type*}
3535

3636
section Semiring
3737

@@ -368,26 +368,27 @@ namespace NoZeroSMulDivisors
368368

369369
-- see Note [lower instance priority]
370370
instance (priority := 100) instOfFaithfulSMul {R A : Type*}
371-
[CommSemiring R] [Semiring A] [Algebra R A] [NoZeroDivisors A] [FaithfulSMul R A] :
372-
NoZeroSMulDivisors R A :=
373-
fun hcx => (mul_eq_zero.mp ((Algebra.smul_def _ _).symm.trans hcx)).imp_left
374-
(map_eq_zero_iff (algebraMap R A) <| FaithfulSMul.algebraMap_injective R A).mp⟩
371+
[CommSemiring R] [Nontrivial R] [Ring A] [Algebra R A] [NoZeroDivisors A] [FaithfulSMul R A] :
372+
IsTorsionFree R A where
373+
isSMulRegular r hr a b hab := by
374+
rw [← sub_eq_zero, ← smul_sub] at hab
375+
simpa [Algebra.smul_def, FaithfulSMul.algebraMap_eq_zero_iff, sub_eq_zero, hr.ne_zero] using hab
375376

376-
variable {R A : Type*} [CommRing R] [Ring A] [Algebra R A]
377+
variable {R A : Type*} [CommRing R] [IsDomain R] [Ring A] [Algebra R A]
377378

378-
instance [Nontrivial A] [NoZeroSMulDivisors R A] : FaithfulSMul R A where
379+
instance [Nontrivial A] [IsTorsionFree R A] : FaithfulSMul R A where
379380
eq_of_smul_eq_smul {r₁ r₂} h := by
380381
specialize h 1
381382
rw [← sub_eq_zero, ← sub_smul, smul_eq_zero, sub_eq_zero] at h
382383
exact h.resolve_right one_ne_zero
383384

384-
theorem iff_faithfulSMul [IsDomain A] : NoZeroSMulDivisors R A ↔ FaithfulSMul R A :=
385-
fun _ ↦ inferInstance, fun _ ↦ inferInstance⟩
385+
lemma iff_faithfulSMul [IsDomain A] : IsTorsionFree R A ↔ FaithfulSMul R A where
386+
mp _ := inferInstance
387+
mpr _ := inferInstance
386388

387389
theorem iff_algebraMap_injective [IsDomain A] :
388-
NoZeroSMulDivisors R A ↔ Injective (algebraMap R A) := by
389-
rw [iff_faithfulSMul]
390-
exact faithfulSMul_iff_algebraMap_injective R A
390+
IsTorsionFree R A ↔ Injective (algebraMap R A) := by
391+
rw [iff_faithfulSMul, faithfulSMul_iff_algebraMap_injective]
391392

392393
end NoZeroSMulDivisors
393394

@@ -408,15 +409,6 @@ lemma isSMulRegular_algebraMap_iff {r : R} :
408409
IsSMulRegular M (algebraMap R A r) ↔ IsSMulRegular M r :=
409410
(Equiv.refl M).isSMulRegular_congr (algebraMap_smul A r)
410411

411-
/-- If `M` is `A`-torsion free and `algebraMap R A` is injective, `M` is also `R`-torsion free. -/
412-
theorem NoZeroSMulDivisors.trans_faithfulSMul (R A M : Type*) [CommSemiring R] [Semiring A]
413-
[Algebra R A] [FaithfulSMul R A] [AddCommMonoid M] [Module R M] [Module A M]
414-
[IsScalarTower R A M] [NoZeroSMulDivisors A M] : NoZeroSMulDivisors R M where
415-
eq_zero_or_eq_zero_of_smul_eq_zero hx := by
416-
rw [← algebraMap_smul (A := A)] at hx
417-
simpa only [map_eq_zero_iff _ <| FaithfulSMul.algebraMap_injective R A] using
418-
eq_zero_or_eq_zero_of_smul_eq_zero hx
419-
420412
variable {A}
421413

422414
-- see Note [lower instance priority]

Mathlib/Algebra/Algebra/NonUnitalSubalgebra.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,8 @@ instance instSMulCommClass' [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTow
287287
instance instSMulCommClass [SMulCommClass R A A] : SMulCommClass R S S where
288288
smul_comm r x y := Subtype.ext <| smul_comm r (x : A) (y : A)
289289

290-
instance noZeroSMulDivisors_bot [NoZeroSMulDivisors R A] : NoZeroSMulDivisors R S :=
291-
fun {c x} h =>
292-
have : c = 0 ∨ (x : A) = 0 := eq_zero_or_eq_zero_of_smul_eq_zero (congr_arg ((↑) : S → A) h)
293-
this.imp_right Subtype.ext⟩
290+
instance instIsTorsionFree [Module.IsTorsionFree R A] : Module.IsTorsionFree R S :=
291+
S.toSubmodule.instIsTorsionFree
294292

295293
end
296294

Mathlib/Algebra/Algebra/Subalgebra/Basic.lean

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,6 @@ end
336336
instance instIsTorsionFree [IsTorsionFree R A] : IsTorsionFree R S :=
337337
S.toSubmodule.instIsTorsionFree
338338

339-
instance noZeroSMulDivisors_bot [NoZeroSMulDivisors R A] : NoZeroSMulDivisors R S :=
340-
fun {c} {x : S} h =>
341-
have : c = 0 ∨ (x : A) = 0 := eq_zero_or_eq_zero_of_smul_eq_zero (congr_arg Subtype.val h)
342-
this.imp_right (@Subtype.ext_iff _ _ x 0).mpr⟩
343-
344339
protected theorem coe_add (x y : S) : (↑(x + y) : A) = ↑x + ↑y := rfl
345340

346341
protected theorem coe_mul (x y : S) : (↑(x * y) : A) = ↑x * ↑y := rfl
@@ -881,11 +876,6 @@ instance instIsTorsionFree' [IsDomain A] (S : Subalgebra R A) : IsTorsionFree S
881876
.comap Subtype.val (fun r hr ↦ by simpa [isRegular_iff_ne_zero] using hr.ne_zero)
882877
(by simp [smul_def])
883878

884-
instance noZeroSMulDivisors_top [NoZeroDivisors A] (S : Subalgebra R A) : NoZeroSMulDivisors S A :=
885-
fun {c} x h =>
886-
have : (c : A) = 0 ∨ x = 0 := eq_zero_or_eq_zero_of_mul_eq_zero h
887-
this.imp_left (@Subtype.ext_iff _ _ c 0).mpr⟩
888-
889879
end Actions
890880

891881
section Center

Mathlib/Algebra/Algebra/Tower.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ section Ring
386386

387387
namespace Algebra
388388

389-
variable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
389+
variable [CommSemiring R] [Semiring A] [IsDomain A] [Semiring B] [Algebra R A] [Algebra R B]
390390
variable [AddCommGroup M] [Module R M] [Module A M] [Module B M]
391391
variable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]
392392

393-
theorem lsmul_injective [NoZeroSMulDivisors A M] {x : A} (hx : x ≠ 0) :
393+
theorem lsmul_injective [Module.IsTorsionFree A M] {x : A} (hx : x ≠ 0) :
394394
Function.Injective (lsmul R B M x) :=
395-
NoZeroSMulDivisors.smul_right_injective M hx
395+
smul_right_injective M hx
396396

397397
end Algebra
398398

Mathlib/Algebra/BigOperators/Finprod.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,13 @@ theorem finsum_smul {R M : Type*} [Ring R] [IsDomain R] [AddCommGroup M] [Module
314314
· simp
315315
· exact ((smulAddHom R M).flip x).map_finsum_of_injective (smul_left_injective R hx) _
316316

317-
/-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is
317+
/-- The torsion-free assumption makes sure that the result holds even when the support of `f` is
318318
infinite. For a more usual version assuming `(support f).Finite` instead, see `smul_finsum'`. -/
319-
theorem smul_finsum {R M : Type*} [Semiring R] [AddCommGroup M] [Module R M]
320-
[NoZeroSMulDivisors R M] (c : R) (f : ι → M) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i := by
319+
theorem smul_finsum {R M : Type*} [Semiring R] [IsDomain R] [AddCommGroup M] [Module R M]
320+
[Module.IsTorsionFree R M] (c : R) (f : ι → M) : c • ∑ᶠ i, f i = ∑ᶠ i, c • f i := by
321321
rcases eq_or_ne c 0 with (rfl | hc)
322322
· simp
323-
· exact (smulAddHom R M c).map_finsum_of_injective
324-
(NoZeroSMulDivisors.smul_right_injective M hc) _
323+
· exact (smulAddHom R M c).map_finsum_of_injective (smul_right_injective M hc) _
325324

326325
@[to_additive]
327326
theorem finprod_inv_distrib [DivisionCommMonoid G] (f : α → G) : (∏ᶠ x, (f x)⁻¹) = (∏ᶠ x, f x)⁻¹ :=

Mathlib/Algebra/Central/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Kevin Buzzard, Jujian Zhang, Yunzhou Xie
66
module
77

88
public import Mathlib.Algebra.Central.Defs
9+
public import Mathlib.Algebra.Module.Torsion.Field
910

1011
import Mathlib.Algebra.Module.Torsion.Field
1112

Mathlib/Algebra/GroupWithZero/Action/Pointwise/Finset.lean

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ scoped[Pointwise] attribute [instance] Finset.smulZeroClass Finset.distribSMul
5454
instance [DecidableEq α] [Zero α] [Mul α] [NoZeroDivisors α] : NoZeroDivisors (Finset α) :=
5555
Function.Injective.noZeroDivisors _ coe_injective coe_zero coe_mul
5656

57-
instance noZeroSMulDivisors [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors α β] :
58-
NoZeroSMulDivisors (Finset α) (Finset β) where
59-
eq_zero_or_eq_zero_of_smul_eq_zero {s t} := by
60-
exact_mod_cast eq_zero_or_eq_zero_of_smul_eq_zero (c := (s : Set α)) (x := (t : Set β))
61-
62-
instance noZeroSMulDivisors_finset [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors α β] :
63-
NoZeroSMulDivisors α (Finset β) :=
64-
Function.Injective.noZeroSMulDivisors _ coe_injective coe_zero coe_smul_finset
65-
6657
section SMulZeroClass
6758
variable [Zero β] [SMulZeroClass α β] {s : Finset α} {t : Finset β} {a : α}
6859

@@ -74,11 +65,6 @@ lemma Nonempty.smul_zero (hs : s.Nonempty) : s • (0 : Finset β) = 0 :=
7465
lemma zero_mem_smul_finset (h : (0 : β) ∈ t) : (0 : β) ∈ a • t :=
7566
mem_smul_finset.20, h, smul_zero _⟩
7667

77-
variable [Zero α] [NoZeroSMulDivisors α β]
78-
79-
lemma zero_mem_smul_finset_iff (ha : a ≠ 0) : (0 : β) ∈ a • t ↔ (0 : β) ∈ t := by
80-
rw [← mem_coe, coe_smul_finset, Set.zero_mem_smul_set_iff ha, mem_coe]
81-
8268
end SMulZeroClass
8369

8470
section SMulWithZero
@@ -101,12 +87,6 @@ lemma Nonempty.zero_smul (ht : t.Nonempty) : (0 : Finset α) • t = 0 :=
10187
lemma zero_smul_finset_subset (s : Finset β) : (0 : α) • s ⊆ 0 :=
10288
image_subset_iff.2 fun x _ ↦ mem_zero.2 <| zero_smul α x
10389

104-
variable [NoZeroSMulDivisors α β]
105-
106-
lemma zero_mem_smul_iff :
107-
(0 : β) ∈ s • t ↔ (0 : α) ∈ s ∧ t.Nonempty ∨ (0 : β) ∈ t ∧ s.Nonempty := by
108-
rw [← mem_coe, coe_smul, Set.zero_mem_smul_iff]; rfl
109-
11090
end SMulWithZero
11191

11292
section GroupWithZero

Mathlib/Algebra/GroupWithZero/Action/Pointwise/Set.lean

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic
99
public import Mathlib.Algebra.GroupWithZero.Action.Basic
1010
public import Mathlib.Algebra.GroupWithZero.Action.Units
1111
public import Mathlib.Algebra.GroupWithZero.Pointwise.Set.Basic
12-
public import Mathlib.Algebra.NoZeroSMulDivisors.Defs
1312

1413
/-!
1514
# Pointwise operations of sets in a group with zero
@@ -59,13 +58,6 @@ lemma Nonempty.smul_zero (hs : s.Nonempty) : s • (0 : Set β) = 0 :=
5958

6059
lemma zero_mem_smul_set (h : (0 : β) ∈ t) : (0 : β) ∈ a • t := ⟨0, h, smul_zero _⟩
6160

62-
variable [Zero α] [NoZeroSMulDivisors α β]
63-
64-
lemma zero_mem_smul_set_iff (ha : a ≠ 0) : (0 : β) ∈ a • t ↔ (0 : β) ∈ t := by
65-
refine ⟨?_, zero_mem_smul_set⟩
66-
rintro ⟨b, hb, h⟩
67-
rwa [(eq_zero_or_eq_zero_of_smul_eq_zero h).resolve_left ha] at hb
68-
6961
end SMulZeroClass
7062
section SMulWithZero
7163

@@ -91,19 +83,6 @@ lemma zero_smul_set_subset (s : Set β) : (0 : α) • s ⊆ 0 :=
9183
lemma subsingleton_zero_smul_set (s : Set β) : ((0 : α) • s).Subsingleton :=
9284
subsingleton_singleton.anti <| zero_smul_set_subset s
9385

94-
variable [NoZeroSMulDivisors α β] {a : α}
95-
96-
lemma zero_mem_smul_iff : 0 ∈ s • t ↔ 0 ∈ s ∧ t.Nonempty ∨ 0 ∈ t ∧ s.Nonempty where
97-
mp := by
98-
rintro ⟨a, ha, b, hb, h⟩
99-
obtain rfl | rfl := eq_zero_or_eq_zero_of_smul_eq_zero h
100-
· exact Or.inl ⟨ha, b, hb⟩
101-
· exact Or.inr ⟨hb, a, ha⟩
102-
mpr := by
103-
rintro (⟨hs, b, hb⟩ | ⟨ht, a, ha⟩)
104-
· exact ⟨0, hs, b, hb, zero_smul _ _⟩
105-
· exact ⟨a, ha, 0, ht, smul_zero _⟩
106-
10786
end SMulWithZero
10887

10988
/-- If the scalar multiplication `(· • ·) : α → β → β` is distributive,
@@ -129,28 +108,14 @@ protected noncomputable def mulDistribMulActionSet [Monoid α] [Monoid β] [MulD
129108

130109
scoped[Pointwise] attribute [instance] Set.distribMulActionSet Set.mulDistribMulActionSet
131110

132-
instance instNoZeroSMulDivisors [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors α β] :
133-
NoZeroSMulDivisors (Set α) (Set β) where
134-
eq_zero_or_eq_zero_of_smul_eq_zero {s t} h := by
111+
instance [Zero α] [Mul α] [NoZeroDivisors α] : NoZeroDivisors (Set α) where
112+
eq_zero_or_eq_zero_of_mul_eq_zero {s t} h := by
135113
by_contra! H
136-
have hst : (s • t).Nonempty := h.symm.subst zero_nonempty
137-
rw [Ne, ← hst.of_smul_left.subset_zero_iff, Ne,
138-
← hst.of_smul_right.subset_zero_iff] at H
114+
have hst : (s * t).Nonempty := h.symm.subst zero_nonempty
115+
rw [Ne, ← hst.of_smul_left.subset_zero_iff, Ne, ← hst.of_smul_right.subset_zero_iff] at H
139116
simp only [not_subset, mem_zero] at H
140117
obtain ⟨⟨a, hs, ha⟩, b, ht, hb⟩ := H
141-
exact (eq_zero_or_eq_zero_of_smul_eq_zero <| h.subset <| smul_mem_smul hs ht).elim ha hb
142-
143-
instance noZeroSMulDivisors_set [Zero α] [Zero β] [SMul α β] [NoZeroSMulDivisors α β] :
144-
NoZeroSMulDivisors α (Set β) where
145-
eq_zero_or_eq_zero_of_smul_eq_zero {a s} h := by
146-
by_contra! H
147-
have hst : (a • s).Nonempty := h.symm.subst zero_nonempty
148-
rw [Ne, Ne, ← hst.of_image.subset_zero_iff, not_subset] at H
149-
obtain ⟨ha, b, ht, hb⟩ := H
150-
exact (eq_zero_or_eq_zero_of_smul_eq_zero <| h.subset <| smul_mem_smul_set ht).elim ha hb
151-
152-
instance [Zero α] [Mul α] [NoZeroDivisors α] : NoZeroDivisors (Set α) where
153-
eq_zero_or_eq_zero_of_mul_eq_zero h := eq_zero_or_eq_zero_of_smul_eq_zero h
118+
exact (eq_zero_or_eq_zero_of_mul_eq_zero <| h.subset <| mul_mem_mul hs ht).elim ha hb
154119

155120
section GroupWithZero
156121
variable [GroupWithZero α] [MulAction α β] {s t : Set β} {a : α}

Mathlib/Algebra/GroupWithZero/NonZeroDivisors.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module
88
public import Mathlib.Algebra.Group.Submonoid.Membership
99
public import Mathlib.Algebra.GroupWithZero.Associated
1010
public import Mathlib.Algebra.GroupWithZero.Regular
11-
public import Mathlib.Algebra.NoZeroSMulDivisors.Defs
1211
public import Mathlib.Algebra.Regular.SMul
1312
public import Mathlib.Algebra.BigOperators.Group.Finset.Defs
1413

@@ -246,10 +245,6 @@ lemma noZeroDivisors_iff_forall_mem_nonZeroDivisors :
246245
NoZeroDivisors M₀ ↔ ∀ x : M₀, x ≠ 0 → x ∈ M₀⁰ :=
247246
noZeroDivisors_iff_eq_zero_of_mul
248247

249-
lemma noZeroSMulDivisors_iff_forall_mem_nonZeroSMulDivisors {M : Type*} [Zero M] [MulAction M₀ M] :
250-
NoZeroSMulDivisors M₀ M ↔ ∀ x : M₀, x ≠ 0 → x ∈ nonZeroSMulDivisors M₀ M :=
251-
noZeroSMulDivisors_iff_right_eq_zero_of_smul
252-
253248
lemma IsSMulRegular.mem_nonZeroSMulDivisors {M : Type*} [Zero M] [MulActionWithZero M₀ M] {m₀ : M₀}
254249
(h : IsSMulRegular M m₀) : m₀ ∈ nonZeroSMulDivisors M₀ M :=
255250
fun _ ↦ h.right_eq_zero_of_smul

Mathlib/Algebra/Module/Basic.lean

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ module
77

88
public import Mathlib.Algebra.Field.Defs
99
public import Mathlib.Algebra.Group.Action.Pi
10-
public import Mathlib.Algebra.Notation.Indicator
1110
public import Mathlib.Algebra.GroupWithZero.Action.Units
12-
public import Mathlib.Algebra.Module.NatInt
13-
public import Mathlib.Algebra.NoZeroSMulDivisors.Defs
11+
public import Mathlib.Algebra.Module.Torsion.Free
12+
public import Mathlib.Algebra.Notation.Indicator
1413
public import Mathlib.Algebra.Ring.Invertible
1514

1615
/-!
@@ -103,12 +102,12 @@ lemma support_smul_subset_right [Zero M] [SMulZeroClass R M] (f : α → R) (g :
103102
support (f • g) ⊆ support g :=
104103
fun x hbf hf ↦ hbf <| by rw [Pi.smul_apply', hf, smul_zero]
105104

106-
lemma support_const_smul_of_ne_zero [Zero R] [Zero M] [SMulWithZero R M] [NoZeroSMulDivisors R M]
107-
(c : R) (g : α → M) (hc : c ≠ 0) : support (c • g) = support g :=
108-
ext fun xby simp only [hc, mem_support, Pi.smul_apply, Ne, smul_eq_zero, false_or]
105+
lemma support_const_smul_of_ne_zero [Semiring R] [IsDomain R] [AddCommMonoid M] [Module R M]
106+
[Module.IsTorsionFree R M] (c : R) (g : α → M) (hc : c ≠ 0) : support (c • g) = support g :=
107+
ext fun _smul_ne_zero_iff_right hc
109108

110-
lemma support_smul [Zero R] [Zero M] [SMulWithZero R M] [NoZeroSMulDivisors R M] (f : α → R)
111-
(g : α → M) : support (f • g) = support f ∩ support g :=
109+
lemma support_smul [Semiring R] [IsDomain R] [AddCommMonoid M] [Module R M]
110+
[Module.IsTorsionFree R M] (f : α → R) (g : α → M) : support (f • g) = support f ∩ support g :=
112111
ext fun _ => smul_ne_zero_iff
113112

114113
lemma support_const_smul_subset [Zero M] [SMulZeroClass R M] (a : R) (f : α → M) :

0 commit comments

Comments
 (0)