@@ -223,11 +223,11 @@ def ring_hom.to_semimodule [semiring R] [semiring S] (f : R →+* S) : semimodul
223
223
`f (x + y) = f x + f y` and `f (c • x) = c • f x`. The predicate `is_linear_map R f` asserts this
224
224
property. A bundled version is available with `linear_map`, and should be favored over
225
225
`is_linear_map` most of the time. -/
226
- class is_linear_map (R : Type u) {M : Type v} {M₂ : Type w}
226
+ structure is_linear_map (R : Type u) {M : Type v} {M₂ : Type w}
227
227
[semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]
228
228
(f : M → M₂) : Prop :=
229
- (add [] : ∀ x y, f (x + y) = f x + f y)
230
- (smul [] : ∀ (c : R) x, f (c • x) = c • f x)
229
+ (map_add : ∀ x y, f (x + y) = f x + f y)
230
+ (map_smul : ∀ (c : R) x, f (c • x) = c • f x)
231
231
232
232
/-- A map `f` between semimodules over a semiring is linear if it satisfies the two properties
233
233
`f (x + y) = f x + f y` and `f (c • x) = c • f x`. Elements of `linear_map R M M₂` (available under
@@ -236,8 +236,8 @@ the predicate `is_linear_map`, but it should be avoided most of the time. -/
236
236
structure linear_map (R : Type u) (M : Type v) (M₂ : Type w)
237
237
[semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :=
238
238
(to_fun : M → M₂)
239
- (add : ∀x y, to_fun (x + y) = to_fun x + to_fun y)
240
- (smul : ∀(c : R) x, to_fun (c • x) = c • to_fun x)
239
+ (map_add' : ∀x y, to_fun (x + y) = to_fun x + to_fun y)
240
+ (map_smul' : ∀(c : R) x, to_fun (c • x) = c • to_fun x)
241
241
242
242
infixr ` →ₗ `:25 := linear_map _
243
243
notation M ` →ₗ[`:25 R:25 `] `:0 M₂:0 := linear_map R M M₂
@@ -274,7 +274,7 @@ variables (f g : M →ₗ[R] M₂)
274
274
275
275
@[simp] lemma to_fun_eq_coe : f.to_fun = ⇑f := rfl
276
276
277
- theorem is_linear : is_linear_map R f := {..f}
277
+ theorem is_linear : is_linear_map R f := ⟨f. 2 , f. 3 ⟩
278
278
279
279
variables {f g}
280
280
@[ext] theorem ext (H : ∀ x, f x = g x) : f = g :=
@@ -288,9 +288,9 @@ theorem ext_iff : f = g ↔ ∀ x, f x = g x :=
288
288
289
289
variables (f g)
290
290
291
- @[simp] lemma map_add (x y : M) : f (x + y) = f x + f y := f.add x y
291
+ @[simp] lemma map_add (x y : M) : f (x + y) = f x + f y := f.map_add' x y
292
292
293
- @[simp] lemma map_smul (c : R) (x : M) : f (c • x) = c • f x := f.smul c x
293
+ @[simp] lemma map_smul (c : R) (x : M) : f (c • x) = c • f x := f.map_smul' c x
294
294
295
295
@[simp] lemma map_zero : f 0 = 0 :=
296
296
by rw [← zero_smul R, map_smul f 0 0 , zero_smul]
@@ -356,7 +356,7 @@ variables [semimodule R M] [semimodule R M₂]
356
356
include R
357
357
358
358
/-- Convert an `is_linear_map` predicate to a `linear_map` -/
359
- def mk' (f : M → M₂) (H : is_linear_map R f) : M →ₗ M₂ := {to_fun := f, ..H}
359
+ def mk' (f : M → M₂) (H : is_linear_map R f) : M →ₗ M₂ := ⟨ f, H. 1 , H. 2 ⟩
360
360
361
361
@[simp] theorem mk'_apply {f : M → M₂} (H : is_linear_map R f) (x : M) :
362
362
mk' f H x = f x := rfl
@@ -379,10 +379,6 @@ include M M₂ lin
379
379
380
380
lemma map_zero : f (0 : M) = (0 : M₂) := (lin.mk' f).map_zero
381
381
382
- lemma map_add : ∀ x y, f (x + y) = f x + f y := lin.add
383
-
384
- lemma map_smul (c : R) (x : M) : f (c • x) = c • f x := (lin.mk' f).map_smul c x
385
-
386
382
end add_comm_monoid
387
383
388
384
section add_comm_group
@@ -410,35 +406,53 @@ end is_linear_map
410
406
abbreviation module.End (R : Type u) (M : Type v)
411
407
[semiring R] [add_comm_monoid M] [semimodule R M] := M →ₗ[R] M
412
408
409
+ set_option old_structure_cmd true
410
+
413
411
/-- A submodule of a module is one which is closed under vector operations.
414
412
This is a sufficient condition for the subset of vectors in the submodule
415
413
to themselves form a module. -/
416
414
structure submodule (R : Type u) (M : Type v) [semiring R]
417
- [add_comm_monoid M] [semimodule R M] : Type v :=
418
- (carrier : set M )
419
- (zero : ( 0 :M) ∈ carrier)
420
- (add : ∀ {x y}, x ∈ carrier → y ∈ carrier → x + y ∈ carrier)
421
- (smul : ∀ (c:R) {x}, x ∈ carrier → c • x ∈ carrier)
415
+ [add_comm_monoid M] [semimodule R M] extends add_submonoid M : Type v :=
416
+ (smul_mem' : ∀ (c:R) {x}, x ∈ carrier → c • x ∈ carrier )
417
+
418
+ /-- Reinterpret a `submodule` as an `add_submonoid`. -/
419
+ add_decl_doc submodule.to_add_submonoid
422
420
423
421
namespace submodule
424
422
425
423
variables [semiring R] [add_comm_monoid M] [semimodule R M]
426
424
427
- instance : has_coe (submodule R M) (set M) := ⟨submodule .carrier⟩
425
+ instance : has_coe_t (submodule R M) (set M) := ⟨λ s, s .carrier⟩
428
426
instance : has_mem M (submodule R M) := ⟨λ x p, x ∈ (p : set M)⟩
429
427
instance : has_coe_to_sort (submodule R M) := ⟨_, λ p, {x : M // x ∈ p}⟩
430
428
431
- end submodule
429
+ variables (p q : submodule R M)
430
+
431
+ @[simp, norm_cast] theorem coe_sort_coe : ↥(p : set M) = p := rfl
432
+
433
+ variables {p q}
434
+
435
+ protected theorem «exists » {q : p → Prop } : (∃ x, q x) ↔ (∃ x ∈ p, q ⟨x, ‹_›⟩) := set_coe.exists
436
+
437
+ protected theorem «forall » {q : p → Prop } : (∀ x, q x) ↔ (∀ x ∈ p, q ⟨x, ‹_›⟩) := set_coe.forall
438
+
439
+ theorem ext' : injective (coe : submodule R M → set M) :=
440
+ λ p q h, by cases p; cases q; congr'
441
+
442
+ @[simp, norm_cast] theorem coe_set_eq : (p : set M) = q ↔ p = q := ext'.eq_iff
443
+
444
+ theorem ext'_iff : p = q ↔ (p : set M) = q := coe_set_eq.symm
432
445
433
- protected theorem submodule.exists [semiring R] [add_comm_monoid M] [semimodule R M] {p : submodule R M}
434
- {q : p → Prop } :
435
- (∃ x, q x) ↔ (∃ x (hx : x ∈ p), q ⟨x, hx⟩) :=
436
- set_coe.exists
446
+ @[ext] theorem ext (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := ext' $ set.ext h
437
447
438
- protected theorem submodule.forall [semiring R] [add_comm_monoid M] [semimodule R M] {p : submodule R M}
439
- {q : p → Prop } :
440
- (∀ x, q x) ↔ (∀ x (hx : x ∈ p), q ⟨x, hx⟩) :=
441
- set_coe.forall
448
+ theorem to_add_submonoid_injective :
449
+ injective (to_add_submonoid : submodule R M → add_submonoid M) :=
450
+ λ p q h, ext'_iff.2 $ add_submonoid.ext'_iff.1 h
451
+
452
+ @[simp] theorem to_add_submonoid_eq : p.to_add_submonoid = q.to_add_submonoid ↔ p = q :=
453
+ to_add_submonoid_injective.eq_iff
454
+
455
+ end submodule
442
456
443
457
namespace submodule
444
458
@@ -452,30 +466,17 @@ variables {semimodule_M : semimodule R M}
452
466
variables {p q : submodule R M}
453
467
variables {r : R} {x y : M}
454
468
455
- theorem ext' (h : (p : set M) = q) : p = q :=
456
- by cases p; cases q; congr'
457
-
458
- protected theorem ext'_iff : (p : set M) = q ↔ p = q :=
459
- ⟨ext', λ h, h ▸ rfl⟩
460
-
461
- @[ext] theorem ext
462
- (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := ext' $ set.ext h
463
-
464
469
variables (p)
465
470
@[simp] theorem mem_coe : x ∈ (p : set M) ↔ x ∈ p := iff.rfl
466
471
467
- @[simp] lemma zero_mem : (0 : M) ∈ p := p.zero
472
+ @[simp] lemma zero_mem : (0 : M) ∈ p := p.zero_mem'
468
473
469
- lemma add_mem (h₁ : x ∈ p) (h₂ : y ∈ p) : x + y ∈ p := p.add h₁ h₂
474
+ lemma add_mem (h₁ : x ∈ p) (h₂ : y ∈ p) : x + y ∈ p := p.add_mem' h₁ h₂
470
475
471
- lemma smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul r h
476
+ lemma smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul_mem' r h
472
477
473
- lemma sum_mem {t : finset ι} {f : ι → M} :
474
- (∀c∈t, f c ∈ p) → (∑ i in t, f i) ∈ p :=
475
- begin
476
- classical,
477
- exact finset.induction_on t (by simp [p.zero_mem]) (by simp [p.add_mem] {contextual := tt})
478
- end
478
+ lemma sum_mem {t : finset ι} {f : ι → M} : (∀c∈t, f c ∈ p) → (∑ i in t, f i) ∈ p :=
479
+ p.to_add_submonoid.sum_mem
479
480
480
481
@[simp] lemma smul_mem_iff' (u : units R) : (u:R) • x ∈ p ↔ x ∈ p :=
481
482
⟨λ h, by simpa only [smul_smul, u.inv_mul, one_smul] using p.smul_mem ↑u⁻¹ h, p.smul_mem u⟩
@@ -501,8 +502,7 @@ variables {p}
501
502
variables (p)
502
503
503
504
instance : add_comm_monoid p :=
504
- by refine {add := (+), zero := 0 , ..};
505
- { intros, apply set_coe.ext, simp [add_comm, add_left_comm] }
505
+ { add := (+), zero := 0 , .. p.to_add_submonoid.to_add_comm_monoid }
506
506
507
507
instance : semimodule R p :=
508
508
by refine {smul := (•), ..};
@@ -527,10 +527,15 @@ variables {r : R} {x y : M}
527
527
528
528
lemma neg_mem (hx : x ∈ p) : -x ∈ p := by rw ← neg_one_smul R; exact p.smul_mem _ hx
529
529
530
+ /-- Reinterpret a submodule as an additive subgroup. -/
531
+ def to_add_subgroup : add_subgroup M :=
532
+ { neg_mem' := λ _, p.neg_mem , .. p.to_add_submonoid }
533
+
534
+ @[simp] lemma coe_to_add_subgroup : (p.to_add_subgroup : set M) = p := rfl
535
+
530
536
lemma sub_mem (hx : x ∈ p) (hy : y ∈ p) : x - y ∈ p := p.add_mem hx (p.neg_mem hy)
531
537
532
- lemma neg_mem_iff : -x ∈ p ↔ x ∈ p :=
533
- ⟨λ h, by simpa using neg_mem p h, neg_mem p⟩
538
+ @[simp] lemma neg_mem_iff : -x ∈ p ↔ x ∈ p := p.to_add_subgroup.neg_mem_iff
534
539
535
540
lemma add_mem_iff_left (h₁ : y ∈ p) : x + y ∈ p ↔ x ∈ p :=
536
541
⟨λ h₂, by simpa using sub_mem _ h₂ h₁, λ h₂, add_mem _ h₂ h₁⟩
@@ -543,13 +548,7 @@ instance : has_neg p := ⟨λx, ⟨-x.1, neg_mem _ x.2⟩⟩
543
548
@[simp, norm_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl
544
549
545
550
instance : add_comm_group p :=
546
- by refine {add := (+), zero := 0 , neg := has_neg.neg, ..};
547
- { intros, apply set_coe.ext, simp [add_comm, add_left_comm] }
548
-
549
- instance submodule_is_add_subgroup : is_add_subgroup (p : set M) :=
550
- { zero_mem := p.zero,
551
- add_mem := p.add,
552
- neg_mem := λ _, p.neg_mem }
551
+ { add := (+), zero := 0 , neg := has_neg.neg, ..p.to_add_subgroup.to_add_comm_group }
553
552
554
553
@[simp, norm_cast] lemma coe_sub (x y : p) : (↑(x - y) : M) = ↑x - ↑y := rfl
555
554
0 commit comments