Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: Johannes HΓΆlzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov | |
-/ | |
import algebra.module.submodule.basic | |
import algebra.punit_instances | |
/-! | |
# The lattice structure on `submodule`s | |
This file defines the lattice structure on submodules, `submodule.complete_lattice`, with `β₯` | |
defined as `{0}` and `β` defined as intersection of the underlying carrier. | |
If `p` and `q` are submodules of a module, `p β€ q` means that `p β q`. | |
Many results about operations on this lattice structure are defined in `linear_algebra/basic.lean`, | |
most notably those which use `span`. | |
## Implementation notes | |
This structure should match the `add_submonoid.complete_lattice` structure, and we should try | |
to unify the APIs where possible. | |
-/ | |
variables {R S M : Type*} | |
section add_comm_monoid | |
variables [semiring R] [semiring S] [add_comm_monoid M] [module R M] [module S M] | |
variables [has_smul S R] [is_scalar_tower S R M] | |
variables {p q : submodule R M} | |
namespace submodule | |
/-- The set `{0}` is the bottom element of the lattice of submodules. -/ | |
instance : has_bot (submodule R M) := | |
β¨{ carrier := {0}, smul_mem' := by simp { contextual := tt }, .. (β₯ : add_submonoid M)}β© | |
instance inhabited' : inhabited (submodule R M) := β¨β₯β© | |
@[simp] lemma bot_coe : ((β₯ : submodule R M) : set M) = {0} := rfl | |
@[simp] lemma bot_to_add_submonoid : (β₯ : submodule R M).to_add_submonoid = β₯ := rfl | |
section | |
variables (R) | |
@[simp] lemma restrict_scalars_bot : restrict_scalars S (β₯ : submodule R M) = β₯ := rfl | |
@[simp] lemma mem_bot {x : M} : x β (β₯ : submodule R M) β x = 0 := set.mem_singleton_iff | |
end | |
@[simp] lemma restrict_scalars_eq_bot_iff {p : submodule R M} : | |
restrict_scalars S p = β₯ β p = β₯ := | |
by simp [set_like.ext_iff] | |
instance unique_bot : unique (β₯ : submodule R M) := | |
β¨infer_instance, Ξ» x, subtype.ext $ (mem_bot R).1 x.memβ© | |
instance : order_bot (submodule R M) := | |
{ bot := β₯, | |
bot_le := Ξ» p x, by simp [zero_mem] {contextual := tt} } | |
protected lemma eq_bot_iff (p : submodule R M) : p = β₯ β β x β p, x = (0 : M) := | |
β¨ Ξ» h, h.symm βΈ Ξ» x hx, (mem_bot R).mp hx, | |
Ξ» h, eq_bot_iff.mpr (Ξ» x hx, (mem_bot R).mpr (h x hx)) β© | |
@[ext] protected lemma bot_ext (x y : (β₯ : submodule R M)) : x = y := | |
begin | |
rcases x with β¨x, xmβ©, rcases y with β¨y, ymβ©, congr, | |
rw (submodule.eq_bot_iff _).mp rfl x xm, | |
rw (submodule.eq_bot_iff _).mp rfl y ym, | |
end | |
protected lemma ne_bot_iff (p : submodule R M) : p β β₯ β β x β p, x β (0 : M) := | |
by { haveI := classical.prop_decidable, simp_rw [ne.def, p.eq_bot_iff, not_forall] } | |
lemma nonzero_mem_of_bot_lt {p : submodule R M} (bot_lt : β₯ < p) : β a : p, a β 0 := | |
let β¨b, hbβ, hbββ© := p.ne_bot_iff.mp bot_lt.ne' in β¨β¨b, hbββ©, hbβ β (congr_arg coe)β© | |
lemma exists_mem_ne_zero_of_ne_bot {p : submodule R M} (h : p β β₯) : β b : M, b β p β§ b β 0 := | |
let β¨b, hbβ, hbββ© := p.ne_bot_iff.mp h in β¨b, hbβ, hbββ© | |
/-- The bottom submodule is linearly equivalent to punit as an `R`-module. -/ | |
@[simps] def bot_equiv_punit : (β₯ : submodule R M) ββ[R] punit := | |
{ to_fun := Ξ» x, punit.star, | |
inv_fun := Ξ» x, 0, | |
map_add' := by { intros, ext, }, | |
map_smul' := by { intros, ext, }, | |
left_inv := by { intro x, ext, }, | |
right_inv := by { intro x, ext, }, } | |
lemma eq_bot_of_subsingleton (p : submodule R M) [subsingleton p] : p = β₯ := | |
begin | |
rw eq_bot_iff, | |
intros v hv, | |
exact congr_arg coe (subsingleton.elim (β¨v, hvβ© : p) 0) | |
end | |
/-- The universal set is the top element of the lattice of submodules. -/ | |
instance : has_top (submodule R M) := | |
β¨{ carrier := set.univ, smul_mem' := Ξ» _ _ _, trivial, .. (β€ : add_submonoid M)}β© | |
@[simp] lemma top_coe : ((β€ : submodule R M) : set M) = set.univ := rfl | |
@[simp] lemma top_to_add_submonoid : (β€ : submodule R M).to_add_submonoid = β€ := rfl | |
@[simp] lemma mem_top {x : M} : x β (β€ : submodule R M) := trivial | |
section | |
variables (R) | |
@[simp] lemma restrict_scalars_top : restrict_scalars S (β€ : submodule R M) = β€ := rfl | |
end | |
@[simp] lemma restrict_scalars_eq_top_iff {p : submodule R M} : | |
restrict_scalars S p = β€ β p = β€ := | |
by simp [set_like.ext_iff] | |
instance : order_top (submodule R M) := | |
{ top := β€, | |
le_top := Ξ» p x _, trivial } | |
lemma eq_top_iff' {p : submodule R M} : p = β€ β β x, x β p := | |
eq_top_iff.trans β¨Ξ» h x, h trivial, Ξ» h x _, h xβ© | |
/-- The top submodule is linearly equivalent to the module. | |
This is the module version of `add_submonoid.top_equiv`. -/ | |
@[simps] def top_equiv : (β€ : submodule R M) ββ[R] M := | |
{ to_fun := Ξ» x, x, | |
inv_fun := Ξ» x, β¨x, by simpβ©, | |
map_add' := by { intros, refl, }, | |
map_smul' := by { intros, refl, }, | |
left_inv := by { intro x, ext, refl, }, | |
right_inv := by { intro x, refl, }, } | |
instance : has_Inf (submodule R M) := | |
β¨Ξ» S, | |
{ carrier := β s β S, (s : set M), | |
zero_mem' := by simp [zero_mem], | |
add_mem' := by simp [add_mem] {contextual := tt}, | |
smul_mem' := by simp [smul_mem] {contextual := tt} }β© | |
private lemma Inf_le' {S : set (submodule R M)} {p} : p β S β Inf S β€ p := | |
set.bInter_subset_of_mem | |
private lemma le_Inf' {S : set (submodule R M)} {p} : (βq β S, p β€ q) β p β€ Inf S := | |
set.subset_Interβ | |
instance : has_inf (submodule R M) := | |
β¨Ξ» p q, | |
{ carrier := p β© q, | |
zero_mem' := by simp [zero_mem], | |
add_mem' := by simp [add_mem] {contextual := tt}, | |
smul_mem' := by simp [smul_mem] {contextual := tt} }β© | |
instance : complete_lattice (submodule R M) := | |
{ sup := Ξ» a b, Inf {x | a β€ x β§ b β€ x}, | |
le_sup_left := Ξ» a b, le_Inf' $ Ξ» x β¨ha, hbβ©, ha, | |
le_sup_right := Ξ» a b, le_Inf' $ Ξ» x β¨ha, hbβ©, hb, | |
sup_le := Ξ» a b c hβ hβ, Inf_le' β¨hβ, hββ©, | |
inf := (β), | |
le_inf := Ξ» a b c, set.subset_inter, | |
inf_le_left := Ξ» a b, set.inter_subset_left _ _, | |
inf_le_right := Ξ» a b, set.inter_subset_right _ _, | |
Sup := Ξ»tt, Inf {t | βt'βtt, t' β€ t}, | |
le_Sup := Ξ» s p hs, le_Inf' $ Ξ» q hq, hq _ hs, | |
Sup_le := Ξ» s p hs, Inf_le' hs, | |
Inf := Inf, | |
le_Inf := Ξ» s a, le_Inf', | |
Inf_le := Ξ» s a, Inf_le', | |
..submodule.order_top, | |
..submodule.order_bot, | |
..set_like.partial_order } | |
@[simp] theorem inf_coe : β(p β q) = (p β© q : set M) := rfl | |
@[simp] theorem mem_inf {p q : submodule R M} {x : M} : | |
x β p β q β x β p β§ x β q := iff.rfl | |
@[simp] theorem Inf_coe (P : set (submodule R M)) : (β(Inf P) : set M) = β p β P, βp := rfl | |
@[simp] theorem finset_inf_coe {ΞΉ} (s : finset ΞΉ) (p : ΞΉ β submodule R M) : | |
(β(s.inf p) : set M) = β i β s, β(p i) := | |
begin | |
letI := classical.dec_eq ΞΉ, | |
refine s.induction_on _ (Ξ» i s hi ih, _), | |
{ simp }, | |
{ rw [finset.inf_insert, inf_coe, ih], | |
simp }, | |
end | |
@[simp] theorem infi_coe {ΞΉ} (p : ΞΉ β submodule R M) : | |
(ββ¨ i, p i : set M) = β i, β(p i) := | |
by rw [infi, Inf_coe]; ext a; simp; exact | |
β¨Ξ» h i, h _ i rfl, Ξ» h i x e, e βΈ h _β© | |
@[simp] lemma mem_Inf {S : set (submodule R M)} {x : M} : x β Inf S β β p β S, x β p := | |
set.mem_Interβ | |
@[simp] theorem mem_infi {ΞΉ} (p : ΞΉ β submodule R M) {x} : | |
x β (β¨ i, p i) β β i, x β p i := | |
by rw [β set_like.mem_coe, infi_coe, set.mem_Inter]; refl | |
@[simp] theorem mem_finset_inf {ΞΉ} {s : finset ΞΉ} {p : ΞΉ β submodule R M} {x : M} : | |
x β s.inf p β β i β s, x β p i := | |
by simp only [β set_like.mem_coe, finset_inf_coe, set.mem_Inter] | |
lemma mem_sup_left {S T : submodule R M} : β {x : M}, x β S β x β S β T := | |
show S β€ S β T, from le_sup_left | |
lemma mem_sup_right {S T : submodule R M} : β {x : M}, x β T β x β S β T := | |
show T β€ S β T, from le_sup_right | |
lemma add_mem_sup {S T : submodule R M} {s t : M} (hs : s β S) (ht : t β T) : s + t β S β T := | |
add_mem (mem_sup_left hs) (mem_sup_right ht) | |
lemma sub_mem_sup {R' M' : Type*} [ring R'] [add_comm_group M'] [module R' M'] | |
{S T : submodule R' M'} {s t : M'} (hs : s β S) (ht : t β T) : | |
s - t β S β T := | |
begin | |
rw sub_eq_add_neg, | |
exact add_mem_sup hs (neg_mem ht), | |
end | |
lemma mem_supr_of_mem {ΞΉ : Sort*} {b : M} {p : ΞΉ β submodule R M} (i : ΞΉ) (h : b β p i) : | |
b β (β¨i, p i) := | |
have p i β€ (β¨i, p i) := le_supr p i, | |
@this b h | |
open_locale big_operators | |
lemma sum_mem_supr {ΞΉ : Type*} [fintype ΞΉ] {f : ΞΉ β M} {p : ΞΉ β submodule R M} | |
(h : β i, f i β p i) : | |
β i, f i β β¨ i, p i := | |
sum_mem $ Ξ» i hi, mem_supr_of_mem i (h i) | |
lemma sum_mem_bsupr {ΞΉ : Type*} {s : finset ΞΉ} {f : ΞΉ β M} {p : ΞΉ β submodule R M} | |
(h : β i β s, f i β p i) : | |
β i in s, f i β β¨ i β s, p i := | |
sum_mem $ Ξ» i hi, mem_supr_of_mem i $ mem_supr_of_mem hi (h i hi) | |
/-! Note that `submodule.mem_supr` is provided in `linear_algebra/basic.lean`. -/ | |
lemma mem_Sup_of_mem {S : set (submodule R M)} {s : submodule R M} | |
(hs : s β S) : β {x : M}, x β s β x β Sup S := | |
show s β€ Sup S, from le_Sup hs | |
theorem disjoint_def {p p' : submodule R M} : | |
disjoint p p' β β x β p, x β p' β x = (0:M) := | |
show (β x, x β p β§ x β p' β x β ({0} : set M)) β _, by simp | |
theorem disjoint_def' {p p' : submodule R M} : | |
disjoint p p' β β (x β p) (y β p'), x = y β x = (0:M) := | |
disjoint_def.trans β¨Ξ» h x hx y hy hxy, h x hx $ hxy.symm βΈ hy, | |
Ξ» h x hx hx', h _ hx x hx' rflβ© | |
lemma eq_zero_of_coe_mem_of_disjoint (hpq : disjoint p q) {a : p} (ha : (a : M) β q) : | |
a = 0 := | |
by exact_mod_cast disjoint_def.mp hpq a (coe_mem a) ha | |
end submodule | |
section nat_submodule | |
/-- An additive submonoid is equivalent to a β-submodule. -/ | |
def add_submonoid.to_nat_submodule : add_submonoid M βo submodule β M := | |
{ to_fun := Ξ» S, | |
{ smul_mem' := Ξ» r s hs, show r β’ s β S, from nsmul_mem hs _, ..S }, | |
inv_fun := submodule.to_add_submonoid, | |
left_inv := Ξ» β¨S, _, _β©, rfl, | |
right_inv := Ξ» β¨S, _, _, _β©, rfl, | |
map_rel_iff' := Ξ» a b, iff.rfl } | |
@[simp] | |
lemma add_submonoid.to_nat_submodule_symm : | |
β(add_submonoid.to_nat_submodule.symm : _ βo add_submonoid M) = submodule.to_add_submonoid := rfl | |
@[simp] | |
lemma add_submonoid.coe_to_nat_submodule (S : add_submonoid M) : | |
(S.to_nat_submodule : set M) = S := rfl | |
@[simp] | |
lemma add_submonoid.to_nat_submodule_to_add_submonoid (S : add_submonoid M) : | |
S.to_nat_submodule.to_add_submonoid = S := | |
add_submonoid.to_nat_submodule.symm_apply_apply S | |
@[simp] | |
lemma submodule.to_add_submonoid_to_nat_submodule (S : submodule β M) : | |
S.to_add_submonoid.to_nat_submodule = S := | |
add_submonoid.to_nat_submodule.apply_symm_apply S | |
end nat_submodule | |
end add_comm_monoid | |
section int_submodule | |
variables [add_comm_group M] | |
/-- An additive subgroup is equivalent to a β€-submodule. -/ | |
def add_subgroup.to_int_submodule : add_subgroup M βo submodule β€ M := | |
{ to_fun := Ξ» S, | |
{ smul_mem' := Ξ» r s hs, S.zsmul_mem hs _, ..S}, | |
inv_fun := submodule.to_add_subgroup, | |
left_inv := Ξ» β¨S, _, _, _β©, rfl, | |
right_inv := Ξ» β¨S, _, _, _β©, rfl, | |
map_rel_iff' := Ξ» a b, iff.rfl } | |
@[simp] | |
lemma add_subgroup.to_int_submodule_symm : | |
β(add_subgroup.to_int_submodule.symm : _ βo add_subgroup M) = submodule.to_add_subgroup := rfl | |
@[simp] | |
lemma add_subgroup.coe_to_int_submodule (S : add_subgroup M) : | |
(S.to_int_submodule : set M) = S := rfl | |
@[simp] | |
lemma add_subgroup.to_int_submodule_to_add_subgroup (S : add_subgroup M) : | |
S.to_int_submodule.to_add_subgroup = S := | |
add_subgroup.to_int_submodule.symm_apply_apply S | |
@[simp] | |
lemma submodule.to_add_subgroup_to_int_submodule (S : submodule β€ M) : | |
S.to_add_subgroup.to_int_submodule = S := | |
add_subgroup.to_int_submodule.apply_symm_apply S | |
end int_submodule | |