@@ -3,10 +3,11 @@ Copyright (c) 2015 Nathaniel Thomas. All rights reserved.
3
3
Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro
5
5
-/
6
- import Mathlib.Algebra.GroupWithZero.Action.End
7
- import Mathlib.Algebra.GroupWithZero.Action.Units
6
+ import Mathlib.Algebra.Group.Action.End
7
+ import Mathlib.Algebra.Group.Equiv.Basic
8
+ import Mathlib.Algebra.GroupWithZero.Action.Defs
9
+ import Mathlib.Algebra.Ring.Defs
8
10
import Mathlib.Algebra.SMulWithZero
9
- import Mathlib.Data.Int.Cast.Lemmas
10
11
11
12
/-!
12
13
# Modules over a ring
@@ -39,7 +40,9 @@ assert_not_exists Field
39
40
assert_not_exists Invertible
40
41
assert_not_exists Multiset
41
42
assert_not_exists Pi.single_smul₀
43
+ assert_not_exists RingHom
42
44
assert_not_exists Set.indicator
45
+ assert_not_exists Units
43
46
44
47
open Function Set
45
48
@@ -72,14 +75,6 @@ instance (priority := 100) Module.toMulActionWithZero
72
75
smul_zero := smul_zero
73
76
zero_smul := Module.zero_smul }
74
77
75
- instance AddCommGroup.toNatModule : Module ℕ M where
76
- one_smul := one_nsmul
77
- mul_smul m n a := mul_nsmul' a m n
78
- smul_add n a b := nsmul_add a b n
79
- smul_zero := nsmul_zero
80
- zero_smul := zero_nsmul
81
- add_smul r s x := add_nsmul x r s
82
-
83
78
theorem add_smul : (r + s) • x = r • x + s • x :=
84
79
Module.add_smul r s x
85
80
@@ -111,31 +106,7 @@ protected abbrev Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (
111
106
rcases hf x with ⟨x, rfl⟩
112
107
rw [← f.map_zero, ← smul, zero_smul] }
113
108
114
- /-- Push forward the action of `R` on `M` along a compatible surjective map `f : R →+* S`.
115
-
116
- See also `Function.Surjective.mulActionLeft` and `Function.Surjective.distribMulActionLeft`.
117
- -/
118
- abbrev Function.Surjective.moduleLeft {R S M : Type *} [Semiring R] [AddCommMonoid M] [Module R M]
119
- [Semiring S] [SMul S M] (f : R →+* S) (hf : Function.Surjective f)
120
- (hsmul : ∀ (c) (x : M), f c • x = c • x) : Module S M :=
121
- { hf.distribMulActionLeft f.toMonoidHom hsmul with
122
- zero_smul := fun x => by rw [← f.map_zero, hsmul, zero_smul]
123
- add_smul := hf.forall₂.mpr fun a b x => by simp only [← f.map_add, hsmul, add_smul] }
124
-
125
- variable {R} (M)
126
-
127
- /-- Compose a `Module` with a `RingHom`, with action `f s • m`.
128
-
129
- See note [reducible non-instances]. -/
130
- abbrev Module.compHom [Semiring S] (f : S →+* R) : Module S M :=
131
- { MulActionWithZero.compHom M f.toMonoidWithZeroHom, DistribMulAction.compHom M (f : S →* R) with
132
- -- Porting note: the `show f (r + s) • x = f r • x + f s • x` wasn't needed in mathlib3.
133
- -- Somehow, now that `SMul` is heterogeneous, it can't unfold earlier fields of a definition for
134
- -- use in later fields. See
135
- -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Heterogeneous.20scalar.20multiplication
136
- add_smul := fun r s x => show f (r + s) • x = f r • x + f s • x by simp [add_smul] }
137
-
138
- variable {M}
109
+ variable {R}
139
110
140
111
theorem Module.eq_zero_of_zero_eq_one (zero_eq_one : (0 : R) = 1 ) : x = 0 := by
141
112
rw [← one_smul R x, ← zero_eq_one, zero_smul]
@@ -146,20 +117,9 @@ theorem smul_add_one_sub_smul {R : Type*} [Ring R] [Module R M] {r : R} {m : M}
146
117
147
118
end AddCommMonoid
148
119
149
-
150
120
section AddCommGroup
151
121
152
- variable (R M) [Semiring R] [AddCommGroup M]
153
-
154
- instance AddCommGroup.toIntModule : Module ℤ M where
155
- one_smul := one_zsmul
156
- mul_smul m n a := mul_zsmul a m n
157
- smul_add n a b := zsmul_add a b n
158
- smul_zero := zsmul_zero
159
- zero_smul := zero_zsmul
160
- add_smul r s x := add_zsmul x r s
161
-
162
- variable {R M}
122
+ variable [Semiring R] [AddCommGroup M]
163
123
164
124
theorem Convex.combo_eq_smul_sub_add [Module R M] {x y : M} {a b : R} (h : a + b = 1 ) :
165
125
a • x + b • y = b • (y - x) + x :=
@@ -187,10 +147,6 @@ theorem neg_smul : -r • x = -(r • x) :=
187
147
188
148
theorem neg_smul_neg : -r • -x = r • x := by rw [neg_smul, smul_neg, neg_neg]
189
149
190
- @[simp]
191
- theorem Units.neg_smul (u : Rˣ) (x : M) : -u • x = -(u • x) := by
192
- rw [Units.smul_def, Units.val_neg, _root_.neg_smul, Units.smul_def]
193
-
194
150
variable (R)
195
151
196
152
theorem neg_one_smul (x : M) : (-1 : R) • x = -x := by simp
@@ -202,26 +158,6 @@ theorem sub_smul (r s : R) (y : M) : (r - s) • y = r • y - s • y := by
202
158
203
159
end Module
204
160
205
- variable (R)
206
-
207
- /-- An `AddCommMonoid` that is a `Module` over a `Ring` carries a natural `AddCommGroup`
208
- structure.
209
- See note [reducible non-instances]. -/
210
- abbrev Module.addCommMonoidToAddCommGroup
211
- [Ring R] [AddCommMonoid M] [Module R M] : AddCommGroup M :=
212
- { (inferInstance : AddCommMonoid M) with
213
- neg := fun a => (-1 : R) • a
214
- neg_add_cancel := fun a =>
215
- show (-1 : R) • a + a = 0 by
216
- nth_rw 2 [← one_smul R a]
217
- rw [← add_smul, neg_add_cancel, zero_smul]
218
- zsmul := fun z a => (z : R) • a
219
- zsmul_zero' := fun a => by simpa only [Int.cast_zero] using zero_smul R a
220
- zsmul_succ' := fun z a => by simp [add_comm, add_smul]
221
- zsmul_neg' := fun z a => by simp [← smul_assoc, neg_one_smul] }
222
-
223
- variable {R}
224
-
225
161
/-- A module over a `Subsingleton` semiring is a `Subsingleton`. We cannot register this
226
162
as an instance because Lean has no way to guess `R`. -/
227
163
protected theorem Module.subsingleton (R M : Type *) [Semiring R] [Subsingleton R] [AddCommMonoid M]
@@ -242,87 +178,3 @@ instance (priority := 910) Semiring.toModule [Semiring R] : Module R R where
242
178
243
179
instance [NonUnitalNonAssocSemiring R] : DistribSMul R R where
244
180
smul_add := left_distrib
245
-
246
- /-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`. -/
247
- def RingHom.toModule [Semiring R] [Semiring S] (f : R →+* S) : Module R S :=
248
- Module.compHom S f
249
-
250
- /-- If the module action of `R` on `S` is compatible with multiplication on `S`, then
251
- `fun x ↦ x • 1` is a ring homomorphism from `R` to `S`.
252
-
253
- This is the `RingHom` version of `MonoidHom.smulOneHom`.
254
-
255
- When `R` is commutative, usually `algebraMap` should be preferred. -/
256
- @[simps!] def RingHom.smulOneHom
257
- [Semiring R] [NonAssocSemiring S] [Module R S] [IsScalarTower R S S] : R →+* S where
258
- __ := MonoidHom.smulOneHom
259
- map_zero' := zero_smul R 1
260
- map_add' := (add_smul · · 1 )
261
-
262
- /-- A homomorphism between semirings R and S can be equivalently specified by a R-module
263
- structure on S such that S/S/R is a scalar tower. -/
264
- def ringHomEquivModuleIsScalarTower [Semiring R] [Semiring S] :
265
- (R →+* S) ≃ {_inst : Module R S // IsScalarTower R S S} where
266
- toFun f := ⟨Module.compHom S f, SMul.comp.isScalarTower _⟩
267
- invFun := fun ⟨_, _⟩ ↦ RingHom.smulOneHom
268
- left_inv f := RingHom.ext fun r ↦ mul_one (f r)
269
- right_inv := fun ⟨_, _⟩ ↦ Subtype.ext <| Module.ext <| funext₂ <| smul_one_smul S
270
-
271
- section AddCommMonoid
272
-
273
- variable [Semiring R] [AddCommMonoid M] [Module R M]
274
-
275
- section
276
-
277
- variable (R)
278
-
279
- /-- `nsmul` is equal to any other module structure via a cast. -/
280
- lemma Nat.cast_smul_eq_nsmul (n : ℕ) (b : M) : (n : R) • b = n • b := by
281
- induction n with
282
- | zero => rw [Nat.cast_zero, zero_smul, zero_smul]
283
- | succ n ih => rw [Nat.cast_succ, add_smul, add_smul, one_smul, ih, one_smul]
284
-
285
- /-- `nsmul` is equal to any other module structure via a cast. -/
286
- -- See note [no_index around OfNat.ofNat]
287
- lemma ofNat_smul_eq_nsmul (n : ℕ) [n.AtLeastTwo] (b : M) :
288
- (no_index (OfNat.ofNat n) : R) • b = OfNat.ofNat n • b := Nat.cast_smul_eq_nsmul ..
289
-
290
- /-- `nsmul` is equal to any other module structure via a cast. -/
291
- @[deprecated Nat.cast_smul_eq_nsmul (since := "2024-07-23")]
292
- lemma nsmul_eq_smul_cast (n : ℕ) (b : M) : n • b = (n : R) • b := (Nat.cast_smul_eq_nsmul ..).symm
293
-
294
- end
295
-
296
- /-- Convert back any exotic `ℕ`-smul to the canonical instance. This should not be needed since in
297
- mathlib all `AddCommMonoid`s should normally have exactly one `ℕ`-module structure by design.
298
- -/
299
- theorem nat_smul_eq_nsmul (h : Module ℕ M) (n : ℕ) (x : M) : @SMul.smul ℕ M h.toSMul n x = n • x :=
300
- Nat.cast_smul_eq_nsmul ..
301
-
302
- /-- All `ℕ`-module structures are equal. Not an instance since in mathlib all `AddCommMonoid`
303
- should normally have exactly one `ℕ`-module structure by design. -/
304
- def AddCommMonoid.uniqueNatModule : Unique (Module ℕ M) where
305
- default := by infer_instance
306
- uniq P := (Module.ext' P _) fun n => by convert nat_smul_eq_nsmul P n
307
-
308
- instance AddCommMonoid.nat_isScalarTower : IsScalarTower ℕ R M where
309
- smul_assoc n x y := by
310
- induction n with
311
- | zero => simp only [zero_smul]
312
- | succ n ih => simp only [add_smul, one_smul, ih]
313
-
314
- end AddCommMonoid
315
-
316
- theorem map_natCast_smul [AddCommMonoid M] [AddCommMonoid M₂] {F : Type *} [FunLike F M M₂]
317
- [AddMonoidHomClass F M M₂] (f : F) (R S : Type *) [Semiring R] [Semiring S] [Module R M]
318
- [Module S M₂] (x : ℕ) (a : M) : f ((x : R) • a) = (x : S) • f a := by
319
- simp only [Nat.cast_smul_eq_nsmul, AddMonoidHom.map_nsmul, map_nsmul]
320
-
321
- theorem Nat.smul_one_eq_cast {R : Type *} [NonAssocSemiring R] (m : ℕ) : m • (1 : R) = ↑m := by
322
- rw [nsmul_eq_mul, mul_one]
323
-
324
- theorem Int.smul_one_eq_cast {R : Type *} [NonAssocRing R] (m : ℤ) : m • (1 : R) = ↑m := by
325
- rw [zsmul_eq_mul, mul_one]
326
-
327
- @[deprecated (since := "2024-05-03")] alias Nat.smul_one_eq_coe := Nat.smul_one_eq_cast
328
- @[deprecated (since := "2024-05-03")] alias Int.smul_one_eq_coe := Int.smul_one_eq_cast
0 commit comments