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

Commit bc2bcac

Browse files
committed
chore(algebra/module): Move submodule to its own file (#3696)
1 parent 224e0f8 commit bc2bcac

File tree

4 files changed

+198
-173
lines changed

4 files changed

+198
-173
lines changed

src/algebra/module/basic.lean

Lines changed: 1 addition & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@ In this file we define
2525
2626
* `is_linear_map R f` : predicate saying that `f : M → M₂` is a linear map.
2727
28-
* `submodule R M` : a subset of `M` that contains zero and is closed with respect to addition and
29-
scalar multiplication.
30-
31-
* `subspace k M` : an abbreviation for `submodule` assuming that `k` is a `field`.
32-
3328
## Implementation notes
3429
3530
* `vector_space` and `module` are abbreviations for `semimodule R M`.
3631
3732
## Tags
3833
39-
semimodule, module, vector space, submodule, subspace, linear map
34+
semimodule, module, vector space, linear map
4035
-/
4136

4237
open function
@@ -417,157 +412,6 @@ end is_linear_map
417412
abbreviation module.End (R : Type u) (M : Type v)
418413
[semiring R] [add_comm_monoid M] [semimodule R M] := M →ₗ[R] M
419414

420-
set_option old_structure_cmd true
421-
422-
/-- A submodule of a module is one which is closed under vector operations.
423-
This is a sufficient condition for the subset of vectors in the submodule
424-
to themselves form a module. -/
425-
structure submodule (R : Type u) (M : Type v) [semiring R]
426-
[add_comm_monoid M] [semimodule R M] extends add_submonoid M : Type v :=
427-
(smul_mem' : ∀ (c:R) {x}, x ∈ carrier → c • x ∈ carrier)
428-
429-
/-- Reinterpret a `submodule` as an `add_submonoid`. -/
430-
add_decl_doc submodule.to_add_submonoid
431-
432-
namespace submodule
433-
434-
variables [semiring R] [add_comm_monoid M] [semimodule R M]
435-
436-
instance : has_coe_t (submodule R M) (set M) := ⟨λ s, s.carrier⟩
437-
instance : has_mem M (submodule R M) := ⟨λ x p, x ∈ (p : set M)⟩
438-
instance : has_coe_to_sort (submodule R M) := ⟨_, λ p, {x : M // x ∈ p}⟩
439-
440-
variables (p q : submodule R M)
441-
442-
@[simp, norm_cast] theorem coe_sort_coe : ↥(p : set M) = p := rfl
443-
444-
variables {p q}
445-
446-
protected theorem «exists» {q : p → Prop} : (∃ x, q x) ↔ (∃ x ∈ p, q ⟨x, ‹_›⟩) := set_coe.exists
447-
448-
protected theorem «forall» {q : p → Prop} : (∀ x, q x) ↔ (∀ x ∈ p, q ⟨x, ‹_›⟩) := set_coe.forall
449-
450-
theorem coe_injective : injective (coe : submodule R M → set M) :=
451-
λ p q h, by cases p; cases q; congr'
452-
453-
@[simp, norm_cast] theorem coe_set_eq : (p : set M) = q ↔ p = q := coe_injective.eq_iff
454-
455-
theorem ext'_iff : p = q ↔ (p : set M) = q := coe_set_eq.symm
456-
457-
@[ext] theorem ext (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := coe_injective $ set.ext h
458-
459-
theorem to_add_submonoid_injective :
460-
injective (to_add_submonoid : submodule R M → add_submonoid M) :=
461-
λ p q h, ext'_iff.2 $ add_submonoid.ext'_iff.1 h
462-
463-
@[simp] theorem to_add_submonoid_eq : p.to_add_submonoid = q.to_add_submonoid ↔ p = q :=
464-
to_add_submonoid_injective.eq_iff
465-
466-
end submodule
467-
468-
namespace submodule
469-
470-
section add_comm_monoid
471-
472-
variables [semiring R] [add_comm_monoid M]
473-
474-
-- We can infer the module structure implicitly from the bundled submodule,
475-
-- rather than via typeclass resolution.
476-
variables {semimodule_M : semimodule R M}
477-
variables {p q : submodule R M}
478-
variables {r : R} {x y : M}
479-
480-
variables (p)
481-
@[simp] theorem mem_coe : x ∈ (p : set M) ↔ x ∈ p := iff.rfl
482-
483-
@[simp] lemma zero_mem : (0 : M) ∈ p := p.zero_mem'
484-
485-
lemma add_mem (h₁ : x ∈ p) (h₂ : y ∈ p) : x + y ∈ p := p.add_mem' h₁ h₂
486-
487-
lemma smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul_mem' r h
488-
489-
lemma sum_mem {t : finset ι} {f : ι → M} : (∀c∈t, f c ∈ p) → (∑ i in t, f i) ∈ p :=
490-
p.to_add_submonoid.sum_mem
491-
492-
lemma sum_smul_mem {t : finset ι} {f : ι → M} (r : ι → R)
493-
(hyp : ∀ c ∈ t, f c ∈ p) : (∑ i in t, r i • f i) ∈ p :=
494-
submodule.sum_mem _ (λ i hi, submodule.smul_mem _ _ (hyp i hi))
495-
496-
@[simp] lemma smul_mem_iff' (u : units R) : (u:R) • x ∈ p ↔ x ∈ p :=
497-
⟨λ h, by simpa only [smul_smul, u.inv_mul, one_smul] using p.smul_mem ↑u⁻¹ h, p.smul_mem u⟩
498-
499-
instance : has_add p := ⟨λx y, ⟨x.1 + y.1, add_mem _ x.2 y.2⟩⟩
500-
instance : has_zero p := ⟨⟨0, zero_mem _⟩⟩
501-
instance : inhabited p := ⟨0
502-
instance : has_scalar R p := ⟨λ c x, ⟨c • x.1, smul_mem _ c x.2⟩⟩
503-
504-
@[simp] lemma mk_eq_zero {x} (h : x ∈ p) : (⟨x, h⟩ : p) = 0 ↔ x = 0 := subtype.ext_iff_val
505-
506-
variables {p}
507-
@[simp, norm_cast] lemma coe_eq_coe {x y : p} : (x : M) = y ↔ x = y := subtype.ext_iff_val.symm
508-
@[simp, norm_cast] lemma coe_eq_zero {x : p} : (x : M) = 0 ↔ x = 0 := @coe_eq_coe _ _ _ _ _ _ x 0
509-
@[simp, norm_cast] lemma coe_add (x y : p) : (↑(x + y) : M) = ↑x + ↑y := rfl
510-
@[simp, norm_cast] lemma coe_zero : ((0 : p) : M) = 0 := rfl
511-
@[simp, norm_cast] lemma coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • ↑x := rfl
512-
@[simp, norm_cast] lemma coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl
513-
@[simp] lemma coe_mem (x : p) : (x : M) ∈ p := x.2
514-
515-
@[simp] protected lemma eta (x : p) (hx : (x : M) ∈ p) : (⟨x, hx⟩ : p) = x := subtype.eta x hx
516-
517-
variables (p)
518-
519-
instance : add_comm_monoid p :=
520-
{ add := (+), zero := 0, .. p.to_add_submonoid.to_add_comm_monoid }
521-
522-
instance : semimodule R p :=
523-
by refine {smul := (•), ..};
524-
{ intros, apply set_coe.ext, simp [smul_add, add_smul, mul_smul] }
525-
526-
/-- Embedding of a submodule `p` to the ambient space `M`. -/
527-
protected def subtype : p →ₗ[R] M :=
528-
by refine {to_fun := coe, ..}; simp [coe_smul]
529-
530-
@[simp] theorem subtype_apply (x : p) : p.subtype x = x := rfl
531-
532-
lemma subtype_eq_val : ((submodule.subtype p) : p → M) = subtype.val := rfl
533-
534-
end add_comm_monoid
535-
536-
section add_comm_group
537-
538-
variables [ring R] [add_comm_group M]
539-
variables {semimodule_M : semimodule R M}
540-
variables (p p' : submodule R M)
541-
variables {r : R} {x y : M}
542-
543-
lemma neg_mem (hx : x ∈ p) : -x ∈ p := by rw ← neg_one_smul R; exact p.smul_mem _ hx
544-
545-
/-- Reinterpret a submodule as an additive subgroup. -/
546-
def to_add_subgroup : add_subgroup M :=
547-
{ neg_mem' := λ _, p.neg_mem , .. p.to_add_submonoid }
548-
549-
@[simp] lemma coe_to_add_subgroup : (p.to_add_subgroup : set M) = p := rfl
550-
551-
lemma sub_mem : x ∈ p → y ∈ p → x - y ∈ p := p.to_add_subgroup.sub_mem
552-
553-
@[simp] lemma neg_mem_iff : -x ∈ p ↔ x ∈ p := p.to_add_subgroup.neg_mem_iff
554-
555-
lemma add_mem_iff_left : y ∈ p → (x + y ∈ p ↔ x ∈ p) := p.to_add_subgroup.add_mem_cancel_right
556-
557-
lemma add_mem_iff_right : x ∈ p → (x + y ∈ p ↔ y ∈ p) := p.to_add_subgroup.add_mem_cancel_left
558-
559-
instance : has_neg p := ⟨λx, ⟨-x.1, neg_mem _ x.2⟩⟩
560-
561-
@[simp, norm_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl
562-
563-
instance : add_comm_group p :=
564-
{ add := (+), zero := 0, neg := has_neg.neg, ..p.to_add_subgroup.to_add_comm_group }
565-
566-
@[simp, norm_cast] lemma coe_sub (x y : p) : (↑(x - y) : M) = ↑x - ↑y := rfl
567-
568-
end add_comm_group
569-
570-
end submodule
571415

572416
/--
573417
Vector spaces are defined as an `abbreviation` for semimodules,
@@ -591,21 +435,6 @@ library_note "vector space definition"
591435
abbreviation vector_space (R : Type u) (M : Type v) [field R] [add_comm_group M] :=
592436
semimodule R M
593437

594-
/-- Subspace of a vector space. Defined to equal `submodule`. -/
595-
abbreviation subspace (R : Type u) (M : Type v)
596-
[field R] [add_comm_group M] [vector_space R M] :=
597-
submodule R M
598-
599-
namespace submodule
600-
601-
variables [division_ring R] [add_comm_group M] [module R M]
602-
variables (p : submodule R M) {r : R} {x y : M}
603-
604-
theorem smul_mem_iff (r0 : r ≠ 0) : r • x ∈ p ↔ x ∈ p :=
605-
p.smul_mem_iff' (units.mk0 r r0)
606-
607-
end submodule
608-
609438
namespace add_comm_monoid
610439
open add_monoid
611440

src/algebra/module/default.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Chris Hughes
55
-/
66
import algebra.module.basic
7+
import algebra.module.submodule
78

89
/-!
910
# Default file for module
10-
This file imports `algebra.module.basic`
11+
This file imports `algebra.module.basic` and `algebra.module.submodule`.
1112
-/

0 commit comments

Comments
 (0)