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

Commit 591c34b

Browse files
committed
refactor(linear_algebra/basic): move the lattice structure to its own file (#6767)
The entire lattice structure is thoroughly uninteresting. By moving it to its own shorter file, it should be easier to unify with the lattice of `submonoid` I'd hope in future we can generate this automatically for any `subobject A` with an injection into `set A`.
1 parent ce107da commit 591c34b

File tree

2 files changed

+183
-146
lines changed

2 files changed

+183
-146
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/-
2+
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov
5+
-/
6+
import algebra.module.submodule
7+
8+
/-!
9+
# The lattice structure on `submodule`s
10+
11+
This file defines the lattice structure on submodules, `submodule.complete_lattice`, with `⊥`
12+
defined as `{0}` and `⊓` defined as intersection of the underlying carrier.
13+
If `p` and `q` are submodules of a module, `p ≤ q` means that `p ⊆ q`.
14+
15+
Many results about operations on this lattice structure are defined in `linear_algebra/basic.lean`,
16+
most notably those which use `span`.
17+
18+
## Implementation notes
19+
20+
This structure should match the `add_submonoid.complete_lattice` structure, and we should try
21+
to unify the APIs where possible.
22+
23+
-/
24+
25+
variables {R : Type*} {M : Type*}
26+
27+
section add_comm_monoid
28+
variables [semiring R] [add_comm_monoid M] [semimodule R M]
29+
variables {p q : submodule R M}
30+
31+
namespace submodule
32+
33+
instance : partial_order (submodule R M) :=
34+
{ le := λ p q, ∀ ⦃x⦄, x ∈ p → x ∈ q,
35+
..partial_order.lift (coe : submodule R M → set M) coe_injective }
36+
37+
lemma le_def : p ≤ q ↔ (p : set M) ⊆ q := iff.rfl
38+
39+
@[simp, norm_cast] lemma coe_subset_coe : (p : set M) ⊆ q ↔ p ≤ q := iff.rfl
40+
41+
lemma le_def' : p ≤ q ↔ ∀ x ∈ p, x ∈ q := iff.rfl
42+
43+
lemma lt_def : p < q ↔ (p : set M) ⊂ q := iff.rfl
44+
45+
lemma not_le_iff_exists : ¬ (p ≤ q) ↔ ∃ x ∈ p, x ∉ q := set.not_subset
46+
47+
lemma exists_of_lt {p q : submodule R M} : p < q → ∃ x ∈ q, x ∉ p := set.exists_of_ssubset
48+
49+
lemma lt_iff_le_and_exists : p < q ↔ p ≤ q ∧ ∃ x ∈ q, x ∉ p :=
50+
by rw [lt_iff_le_not_le, not_le_iff_exists]
51+
52+
/-- The set `{0}` is the bottom element of the lattice of submodules. -/
53+
instance : has_bot (submodule R M) :=
54+
⟨{ carrier := {0}, smul_mem' := by simp { contextual := tt }, .. (⊥ : add_submonoid M)}⟩
55+
56+
instance inhabited' : inhabited (submodule R M) := ⟨⊥⟩
57+
58+
@[simp] lemma bot_coe : ((⊥ : submodule R M) : set M) = {0} := rfl
59+
@[simp] lemma bot_to_add_submonoid : (⊥ : submodule R M).to_add_submonoid = ⊥ := rfl
60+
61+
section
62+
variables (R)
63+
@[simp] lemma mem_bot {x : M} : x ∈ (⊥ : submodule R M) ↔ x = 0 := set.mem_singleton_iff
64+
end
65+
66+
instance unique_bot : unique (⊥ : submodule R M) :=
67+
⟨infer_instance, λ x, subtype.ext $ (mem_bot R).1 x.mem⟩
68+
69+
lemma nonzero_mem_of_bot_lt {I : submodule R M} (bot_lt : ⊥ < I) : ∃ a : I, a ≠ 0 :=
70+
begin
71+
have h := (submodule.lt_iff_le_and_exists.1 bot_lt).2,
72+
tidy,
73+
end
74+
75+
instance : order_bot (submodule R M) :=
76+
{ bot := ⊥,
77+
bot_le := λ p x, by simp {contextual := tt},
78+
..submodule.partial_order }
79+
80+
protected lemma eq_bot_iff (p : submodule R M) : p = ⊥ ↔ ∀ x ∈ p, x = (0 : M) :=
81+
⟨ λ h, h.symm ▸ λ x hx, (mem_bot R).mp hx,
82+
λ h, eq_bot_iff.mpr (λ x hx, (mem_bot R).mpr (h x hx)) ⟩
83+
84+
protected lemma ne_bot_iff (p : submodule R M) : p ≠ ⊥ ↔ ∃ x ∈ p, x ≠ (0 : M) :=
85+
by { haveI := classical.prop_decidable, simp_rw [ne.def, p.eq_bot_iff, not_forall] }
86+
87+
/-- The universal set is the top element of the lattice of submodules. -/
88+
instance : has_top (submodule R M) :=
89+
⟨{ carrier := set.univ, smul_mem' := λ _ _ _, trivial, .. (⊤ : add_submonoid M)}⟩
90+
91+
@[simp] lemma top_coe : ((⊤ : submodule R M) : set M) = set.univ := rfl
92+
93+
@[simp] lemma top_to_add_submonoid : (⊤ : submodule R M).to_add_submonoid = ⊤ := rfl
94+
95+
@[simp] lemma mem_top {x : M} : x ∈ (⊤ : submodule R M) := trivial
96+
97+
instance : order_top (submodule R M) :=
98+
{ top := ⊤,
99+
le_top := λ p x _, trivial,
100+
..submodule.partial_order }
101+
102+
lemma eq_top_iff' {p : submodule R M} : p = ⊤ ↔ ∀ x, x ∈ p :=
103+
eq_top_iff.trans ⟨λ h x, h trivial, λ h x _, h x⟩
104+
105+
instance : has_Inf (submodule R M) :=
106+
⟨λ S, {
107+
carrier := ⋂ s ∈ S, (s : set M),
108+
zero_mem' := by simp,
109+
add_mem' := by simp [add_mem] {contextual := tt},
110+
smul_mem' := by simp [smul_mem] {contextual := tt} }⟩
111+
112+
private lemma Inf_le' {S : set (submodule R M)} {p} : p ∈ S → Inf S ≤ p :=
113+
set.bInter_subset_of_mem
114+
115+
private lemma le_Inf' {S : set (submodule R M)} {p} : (∀q ∈ S, p ≤ q) → p ≤ Inf S :=
116+
set.subset_bInter
117+
118+
instance : has_inf (submodule R M) :=
119+
⟨λ p q, {
120+
carrier := p ∩ q,
121+
zero_mem' := by simp,
122+
add_mem' := by simp [add_mem] {contextual := tt},
123+
smul_mem' := by simp [smul_mem] {contextual := tt} }⟩
124+
125+
instance : complete_lattice (submodule R M) :=
126+
{ sup := λ a b, Inf {x | a ≤ x ∧ b ≤ x},
127+
le_sup_left := λ a b, le_Inf' $ λ x ⟨ha, hb⟩, ha,
128+
le_sup_right := λ a b, le_Inf' $ λ x ⟨ha, hb⟩, hb,
129+
sup_le := λ a b c h₁ h₂, Inf_le' ⟨h₁, h₂⟩,
130+
inf := (⊓),
131+
le_inf := λ a b c, set.subset_inter,
132+
inf_le_left := λ a b, set.inter_subset_left _ _,
133+
inf_le_right := λ a b, set.inter_subset_right _ _,
134+
Sup := λtt, Inf {t | ∀t'∈tt, t' ≤ t},
135+
le_Sup := λ s p hs, le_Inf' $ λ q hq, hq _ hs,
136+
Sup_le := λ s p hs, Inf_le' hs,
137+
Inf := Inf,
138+
le_Inf := λ s a, le_Inf',
139+
Inf_le := λ s a, Inf_le',
140+
..submodule.order_top,
141+
..submodule.order_bot }
142+
143+
@[simp] theorem inf_coe : (p ⊓ q : set M) = p ∩ q := rfl
144+
145+
@[simp] theorem mem_inf {p q : submodule R M} {x : M} :
146+
x ∈ p ⊓ q ↔ x ∈ p ∧ x ∈ q := iff.rfl
147+
148+
@[simp] theorem Inf_coe (P : set (submodule R M)) : (↑(Inf P) : set M) = ⋂ p ∈ P, ↑p := rfl
149+
150+
@[simp] theorem infi_coe {ι} (p : ι → submodule R M) :
151+
(↑⨅ i, p i : set M) = ⋂ i, ↑(p i) :=
152+
by rw [infi, Inf_coe]; ext a; simp; exact
153+
⟨λ h i, h _ i rfl, λ h i x e, e ▸ h _⟩
154+
155+
@[simp] lemma mem_Inf {S : set (submodule R M)} {x : M} : x ∈ Inf S ↔ ∀ p ∈ S, x ∈ p :=
156+
set.mem_bInter_iff
157+
158+
@[simp] theorem mem_infi {ι} (p : ι → submodule R M) {x} :
159+
x ∈ (⨅ i, p i) ↔ ∀ i, x ∈ p i :=
160+
by rw [← mem_coe, infi_coe, set.mem_Inter]; refl
161+
162+
lemma mem_sup_left {S T : submodule R M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T :=
163+
show S ≤ S ⊔ T, from le_sup_left
164+
165+
lemma mem_sup_right {S T : submodule R M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T :=
166+
show T ≤ S ⊔ T, from le_sup_right
167+
168+
lemma mem_supr_of_mem {ι : Sort*} {b : M} {p : ι → submodule R M} (i : ι) (h : b ∈ p i) :
169+
b ∈ (⨆i, p i) :=
170+
have p i ≤ (⨆i, p i) := le_supr p i,
171+
@this b h
172+
173+
/-! Note that `submodule.mem_supr` is provided in `linear_algebra/basic.lean`. -/
174+
175+
lemma mem_Sup_of_mem {S : set (submodule R M)} {s : submodule R M}
176+
(hs : s ∈ S) : ∀ {x : M}, x ∈ s → x ∈ Sup S :=
177+
show s ≤ Sup S, from le_Sup hs
178+
179+
end submodule
180+
181+
end add_comm_monoid

src/linear_algebra/basic.lean

Lines changed: 2 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import algebra.big_operators.pi
77
import algebra.module.pi
88
import algebra.module.prod
99
import algebra.module.submodule
10+
import algebra.module.submodule_lattice
1011
import algebra.group.prod
1112
import data.finsupp.basic
1213
import data.dfinsupp
@@ -17,8 +18,7 @@ import order.compactly_generated
1718
# Linear algebra
1819
1920
This file defines the basics of linear algebra. It sets up the "categorical/lattice structure" of
20-
modules over a ring, submodules, and linear maps. If `p` and `q` are submodules of a module, `p ≤ q`
21-
means that `p ⊆ q`.
21+
modules over a ring, submodules, and linear maps.
2222
2323
Many of the relevant definitions, including `module`, `submodule`, and `linear_map`, are found in
2424
`src/algebra/module`.
@@ -487,27 +487,8 @@ variables (p p' : submodule R M) (q q' : submodule R M₂)
487487
variables {r : R} {x y : M}
488488
open set
489489

490-
instance : partial_order (submodule R M) :=
491-
{ le := λ p p', ∀ ⦃x⦄, x ∈ p → x ∈ p',
492-
..partial_order.lift (coe : submodule R M → set M) coe_injective }
493-
494490
variables {p p'}
495491

496-
lemma le_def : p ≤ p' ↔ (p : set M) ⊆ p' := iff.rfl
497-
498-
@[simp, norm_cast] lemma coe_subset_coe : (p : set M) ⊆ p' ↔ p ≤ p' := iff.rfl
499-
500-
lemma le_def' : p ≤ p' ↔ ∀ x ∈ p, x ∈ p' := iff.rfl
501-
502-
lemma lt_def : p < p' ↔ (p : set M) ⊂ p' := iff.rfl
503-
504-
lemma not_le_iff_exists : ¬ (p ≤ p') ↔ ∃ x ∈ p, x ∉ p' := not_subset
505-
506-
lemma exists_of_lt {p p' : submodule R M} : p < p' → ∃ x ∈ p', x ∉ p := exists_of_ssubset
507-
508-
lemma lt_iff_le_and_exists : p < p' ↔ p ≤ p' ∧ ∃ x ∈ p', x ∉ p :=
509-
by rw [lt_iff_le_not_le, not_le_iff_exists]
510-
511492
/-- If two submodules `p` and `p'` satisfy `p ⊆ p'`, then `of_le p p'` is the linear map version of
512493
this inclusion. -/
513494
def of_le (h : p ≤ p') : p →ₗ[R] p' :=
@@ -524,90 +505,6 @@ lemma subtype_comp_of_le (p q : submodule R M) (h : p ≤ q) :
524505
q.subtype.comp (of_le h) = p.subtype :=
525506
by { ext ⟨b, hb⟩, refl }
526507

527-
/-- The set `{0}` is the bottom element of the lattice of submodules. -/
528-
instance : has_bot (submodule R M) :=
529-
⟨{ carrier := {0}, smul_mem' := by simp { contextual := tt }, .. (⊥ : add_submonoid M)}⟩
530-
531-
instance inhabited' : inhabited (submodule R M) := ⟨⊥⟩
532-
533-
@[simp] lemma bot_coe : ((⊥ : submodule R M) : set M) = {0} := rfl
534-
535-
section
536-
variables (R)
537-
@[simp] lemma mem_bot : x ∈ (⊥ : submodule R M) ↔ x = 0 := mem_singleton_iff
538-
end
539-
540-
instance unique_bot : unique (⊥ : submodule R M) :=
541-
⟨infer_instance, λ x, subtype.ext $ (mem_bot R).1 x.mem⟩
542-
543-
lemma nonzero_mem_of_bot_lt {I : submodule R M} (bot_lt : ⊥ < I) : ∃ a : I, a ≠ 0 :=
544-
begin
545-
have h := (submodule.lt_iff_le_and_exists.1 bot_lt).2,
546-
tidy,
547-
end
548-
549-
instance : order_bot (submodule R M) :=
550-
{ bot := ⊥,
551-
bot_le := λ p x, by simp {contextual := tt},
552-
..submodule.partial_order }
553-
554-
protected lemma eq_bot_iff (p : submodule R M) : p = ⊥ ↔ ∀ x ∈ p, x = (0 : M) :=
555-
⟨ λ h, h.symm ▸ λ x hx, (mem_bot R).mp hx,
556-
λ h, eq_bot_iff.mpr (λ x hx, (mem_bot R).mpr (h x hx)) ⟩
557-
558-
protected lemma ne_bot_iff (p : submodule R M) : p ≠ ⊥ ↔ ∃ x ∈ p, x ≠ (0 : M) :=
559-
by { haveI := classical.prop_decidable, simp_rw [ne.def, p.eq_bot_iff, not_forall] }
560-
561-
/-- The universal set is the top element of the lattice of submodules. -/
562-
instance : has_top (submodule R M) :=
563-
⟨{ carrier := univ, smul_mem' := λ _ _ _, trivial, .. (⊤ : add_submonoid M)}⟩
564-
565-
@[simp] lemma top_coe : ((⊤ : submodule R M) : set M) = univ := rfl
566-
567-
@[simp] lemma mem_top : x ∈ (⊤ : submodule R M) := trivial
568-
569-
instance : order_top (submodule R M) :=
570-
{ top := ⊤,
571-
le_top := λ p x _, trivial,
572-
..submodule.partial_order }
573-
574-
instance : has_Inf (submodule R M) :=
575-
⟨λ S, {
576-
carrier := ⋂ s ∈ S, (s : set M),
577-
zero_mem' := by simp,
578-
add_mem' := by simp [add_mem] {contextual := tt},
579-
smul_mem' := by simp [smul_mem] {contextual := tt} }⟩
580-
581-
private lemma Inf_le' {S : set (submodule R M)} {p} : p ∈ S → Inf S ≤ p :=
582-
bInter_subset_of_mem
583-
584-
private lemma le_Inf' {S : set (submodule R M)} {p} : (∀p' ∈ S, p ≤ p') → p ≤ Inf S :=
585-
subset_bInter
586-
587-
instance : has_inf (submodule R M) :=
588-
⟨λ p p', {
589-
carrier := p ∩ p',
590-
zero_mem' := by simp,
591-
add_mem' := by simp [add_mem] {contextual := tt},
592-
smul_mem' := by simp [smul_mem] {contextual := tt} }⟩
593-
594-
instance : complete_lattice (submodule R M) :=
595-
{ sup := λ a b, Inf {x | a ≤ x ∧ b ≤ x},
596-
le_sup_left := λ a b, le_Inf' $ λ x ⟨ha, hb⟩, ha,
597-
le_sup_right := λ a b, le_Inf' $ λ x ⟨ha, hb⟩, hb,
598-
sup_le := λ a b c h₁ h₂, Inf_le' ⟨h₁, h₂⟩,
599-
inf := (⊓),
600-
le_inf := λ a b c, subset_inter,
601-
inf_le_left := λ a b, inter_subset_left _ _,
602-
inf_le_right := λ a b, inter_subset_right _ _,
603-
Sup := λtt, Inf {t | ∀t'∈tt, t' ≤ t},
604-
le_Sup := λ s p hs, le_Inf' $ λ p' hp', hp' _ hs,
605-
Sup_le := λ s p hs, Inf_le' hs,
606-
Inf := Inf,
607-
le_Inf := λ s a, le_Inf',
608-
Inf_le := λ s a, Inf_le',
609-
..submodule.order_top,
610-
..submodule.order_bot }
611508

612509
instance add_comm_monoid_submodule : add_comm_monoid (submodule R M) :=
613510
{ add := (⊔),
@@ -620,15 +517,8 @@ instance add_comm_monoid_submodule : add_comm_monoid (submodule R M) :=
620517
@[simp] lemma add_eq_sup (p q : submodule R M) : p + q = p ⊔ q := rfl
621518
@[simp] lemma zero_eq_bot : (0 : submodule R M) = ⊥ := rfl
622519

623-
lemma eq_top_iff' {p : submodule R M} : p = ⊤ ↔ ∀ x, x ∈ p :=
624-
eq_top_iff.trans ⟨λ h x, @h x trivial, λ h x _, h x⟩
625-
626520
variables (R)
627521

628-
@[simp] lemma bot_to_add_submonoid : (⊥ : submodule R M).to_add_submonoid = ⊥ := rfl
629-
630-
@[simp] lemma top_to_add_submonoid : (⊤ : submodule R M).to_add_submonoid = ⊤ := rfl
631-
632522
lemma subsingleton_iff : subsingleton M ↔ subsingleton (submodule R M) :=
633523
add_submonoid.subsingleton_iff.trans $ begin
634524
rw [←subsingleton_iff_bot_eq_top, ←subsingleton_iff_bot_eq_top],
@@ -650,25 +540,6 @@ by haveI := semimodule.subsingleton R M; apply_instance
650540

651541
instance [nontrivial M] : nontrivial (submodule R M) := (nontrivial_iff R).mp ‹_›
652542

653-
@[simp] theorem inf_coe : (p ⊓ p' : set M) = p ∩ p' := rfl
654-
655-
@[simp] theorem mem_inf {p p' : submodule R M} :
656-
x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' := iff.rfl
657-
658-
@[simp] theorem Inf_coe (P : set (submodule R M)) : (↑(Inf P) : set M) = ⋂ p ∈ P, ↑p := rfl
659-
660-
@[simp] theorem infi_coe {ι} (p : ι → submodule R M) :
661-
(↑⨅ i, p i : set M) = ⋂ i, ↑(p i) :=
662-
by rw [infi, Inf_coe]; ext a; simp; exact
663-
⟨λ h i, h _ i rfl, λ h i x e, e ▸ h _⟩
664-
665-
@[simp] lemma mem_Inf {S : set (submodule R M)} {x : M} : x ∈ Inf S ↔ ∀ p ∈ S, x ∈ p :=
666-
set.mem_bInter_iff
667-
668-
@[simp] theorem mem_infi {ι} (p : ι → submodule R M) :
669-
x ∈ (⨅ i, p i) ↔ ∀ i, x ∈ p i :=
670-
by rw [← mem_coe, infi_coe, mem_Inter]; refl
671-
672543
theorem disjoint_def {p p' : submodule R M} :
673544
disjoint p p' ↔ ∀ x ∈ p, x ∈ p' → x = (0:M) :=
674545
show (∀ x, x ∈ p ∧ x ∈ p' → x ∈ ({0} : set M)) ↔ _, by simp
@@ -875,17 +746,6 @@ begin
875746
{ exact λ a x i hi, ⟨i, smul_mem _ a hi⟩ },
876747
end
877748

878-
lemma mem_sup_left {S T : submodule R M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T :=
879-
show S ≤ S ⊔ T, from le_sup_left
880-
881-
lemma mem_sup_right {S T : submodule R M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T :=
882-
show T ≤ S ⊔ T, from le_sup_right
883-
884-
lemma mem_supr_of_mem {ι : Sort*} {b : M} {p : ι → submodule R M} (i : ι) (h : b ∈ p i) :
885-
b ∈ (⨆i, p i) :=
886-
have p i ≤ (⨆i, p i) := le_supr p i,
887-
@this b h
888-
889749
lemma sum_mem_bsupr {ι : Type*} {s : finset ι} {f : ι → M} {p : ι → submodule R M}
890750
(h : ∀ i ∈ s, f i ∈ p i) :
891751
∑ i in s, f i ∈ ⨆ i ∈ s, p i :=
@@ -896,10 +756,6 @@ lemma sum_mem_supr {ι : Type*} [fintype ι] {f : ι → M} {p : ι → submodul
896756
∑ i, f i ∈ ⨆ i, p i :=
897757
sum_mem _ $ λ i hi, mem_supr_of_mem i (h i)
898758

899-
lemma mem_Sup_of_mem {S : set (submodule R M)} {s : submodule R M}
900-
(hs : s ∈ S) : ∀ {x : M}, x ∈ s → x ∈ Sup S :=
901-
show s ≤ Sup S, from le_Sup hs
902-
903759
@[simp] theorem mem_supr_of_directed {ι} [nonempty ι]
904760
(S : ι → submodule R M) (H : directed (≤) S) {x} :
905761
x ∈ supr S ↔ ∃ i, x ∈ S i :=

0 commit comments

Comments
 (0)