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

Commit 3da777a

Browse files
committed
chore(linear_algebra/basis): use dot notation, simplify some proofs (#2671)
1 parent d0beb49 commit 3da777a

File tree

4 files changed

+69
-126
lines changed

4 files changed

+69
-126
lines changed

src/analysis/normed_space/finite_dimension.lean

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ variables {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
7777
/-- In finite dimension over a complete field, the canonical identification (in terms of a basis)
7878
with `𝕜^n` together with its sup norm is continuous. This is the nontrivial part in the fact that
7979
all norms are equivalent in finite dimension.
80-
Do not use this statement as its formulation is awkward (in terms of the dimension `n`, as the proof
81-
is done by induction over `n`) and it is superceded by the fact that every linear map on a
82-
finite-dimensional space is continuous, in `linear_map.continuous_of_finite_dimensional`. -/
83-
lemma continuous_equiv_fun_basis {n : ℕ} {ι : Type v} [fintype ι] (ξ : ι → E)
84-
(hn : fintype.card ι = n) (hξ : is_basis 𝕜 ξ) : continuous (equiv_fun_basis hξ) :=
80+
81+
This statement is superceded by the fact that every linear map on a finite-dimensional space is
82+
continuous, in `linear_map.continuous_of_finite_dimensional`. -/
83+
lemma continuous_equiv_fun_basis {ι : Type v} [fintype ι] (ξ : ι → E) (hξ : is_basis 𝕜 ξ) :
84+
continuous (equiv_fun_basis hξ) :=
8585
begin
8686
unfreezeI,
87-
induction n with n IH generalizing ι E,
87+
induction hn : fintype.card ι with n IH generalizing ι E,
8888
{ apply linear_map.continuous_of_bound _ 0 (λx, _),
8989
have : equiv_fun_basis hξ x = 0,
9090
by { ext i, exact (fintype.card_eq_zero_iff.1 hn i).elim },
@@ -101,7 +101,7 @@ begin
101101
have U : uniform_embedding (equiv_fun_basis b_basis).symm.to_equiv,
102102
{ have : fintype.card b = n,
103103
by { rw ← s_dim, exact (findim_eq_card_basis b_basis).symm },
104-
have : continuous (equiv_fun_basis b_basis) := IH (subtype.val : b → s) this b_basis,
104+
have : continuous (equiv_fun_basis b_basis) := IH (subtype.val : b → s) b_basis this,
105105
exact (equiv_fun_basis b_basis).symm.uniform_embedding (linear_map.continuous_on_pi _) this },
106106
have : is_complete (s : set E),
107107
from complete_space_coe_iff_is_complete.1 ((complete_space_congr U).1 (by apply_instance)),
@@ -158,7 +158,7 @@ begin
158158
rcases exists_is_basis_finite 𝕜 E with ⟨b, b_basis, b_finite⟩,
159159
letI : fintype b := finite.fintype b_finite,
160160
have A : continuous (equiv_fun_basis b_basis) :=
161-
continuous_equiv_fun_basis _ rfl b_basis,
161+
continuous_equiv_fun_basis _ b_basis,
162162
have B : continuous (f.comp ((equiv_fun_basis b_basis).symm : (b → 𝕜) →ₗ[𝕜] E)) :=
163163
linear_map.continuous_on_pi _,
164164
have : continuous ((f.comp ((equiv_fun_basis b_basis).symm : (b → 𝕜) →ₗ[𝕜] E))
@@ -202,20 +202,19 @@ variables {𝕜 E}
202202
/-- A finite-dimensional subspace is complete. -/
203203
lemma submodule.complete_of_finite_dimensional (s : submodule 𝕜 E) [finite_dimensional 𝕜 s] :
204204
is_complete (s : set E) :=
205-
begin
206-
haveI : complete_space s := finite_dimensional.complete 𝕜 s,
207-
have : is_complete (range (subtype.val : s → E)),
208-
{ rw [← image_univ, is_complete_image_iff],
209-
{ exact complete_univ },
210-
{ exact isometry_subtype_val.uniform_embedding } },
211-
rwa subtype.val_range at this
212-
end
205+
complete_space_coe_iff_is_complete.1 (finite_dimensional.complete 𝕜 s)
213206

214207
/-- A finite-dimensional subspace is closed. -/
215208
lemma submodule.closed_of_finite_dimensional (s : submodule 𝕜 E) [finite_dimensional 𝕜 s] :
216209
is_closed (s : set E) :=
217210
is_closed_of_is_complete s.complete_of_finite_dimensional
218211

212+
lemma continuous_linear_map.exists_right_inverse_of_surjective [finite_dimensional 𝕜 F]
213+
(f : E →L[𝕜] F) (hf : f.range = ⊤) :
214+
∃ g : F →L[𝕜] E, f.comp g = continuous_linear_map.id 𝕜 F :=
215+
let ⟨g, hg⟩ := (f : E →ₗ[𝕜] F).exists_right_inverse_of_surjective hf in
216+
⟨g.to_continuous_linear_map, continuous_linear_map.ext $ linear_map.ext_iff.1 hg⟩
217+
219218
end complete_field
220219

221220
section proper_field

src/linear_algebra/basis.lean

Lines changed: 41 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ begin
106106
exact false.elim (not_nonempty_iff_imp_false.1 h i)
107107
end
108108

109-
lemma ne_zero_of_linear_independent
109+
lemma linear_independent.ne_zero
110110
{i : ι} (ne : 0 ≠ (1:R)) (hv : linear_independent R v) : v i ≠ 0 :=
111111
λ h, ne $ eq.symm begin
112112
suffices : (finsupp.single i 1 : ι →₀ R) i = 0, {simpa},
@@ -301,7 +301,7 @@ begin
301301
exact (disjoint.mono_left (finsupp.supported_mono h))
302302
end
303303

304-
lemma linear_independent_union {s t : set M}
304+
lemma linear_independent.union {s t : set M}
305305
(hs : linear_independent R (λ x, x : s → M)) (ht : linear_independent R (λ x, x : t → M))
306306
(hst : disjoint (span R s) (span R t)) :
307307
linear_independent R (λ x, x : (s ∪ t) → M) :=
@@ -346,7 +346,6 @@ lemma linear_independent_Union_of_directed {η : Type*}
346346
(h : ∀ i, linear_independent R (λ x, x : s i → M)) :
347347
linear_independent R (λ x, x : (⋃ i, s i) → M) :=
348348
begin
349-
haveI := classical.dec (nonempty η),
350349
by_cases hη : nonempty η,
351350
{ refine linear_independent_of_finite (⋃ i, s i) (λ t ht ft, _),
352351
rcases finite_subset_Union ft ht with ⟨I, fi, hI⟩,
@@ -389,9 +388,7 @@ begin
389388
exact λ x, set.not_mem_empty x (subtype.mem x) },
390389
{ rintros ⟨i⟩ s his ih,
391390
rw [finset.sup_insert],
392-
apply linear_independent_union,
393-
{ apply hl },
394-
{ apply ih },
391+
refine (hl _).union ih _,
395392
rw [finset.sup_eq_supr],
396393
refine (hd i _ _ his).mono_right _,
397394
{ simp only [(span_Union _).symm],
@@ -424,7 +421,7 @@ begin
424421
simp only [] at hxy,
425422
rw hxy,
426423
exact (subset_span (mem_range_self y₂)) },
427-
exact false.elim (ne_zero_of_linear_independent zero_eq_one (hindep x₁) h0) } },
424+
exact false.elim ((hindep x₁).ne_zero zero_eq_one h0) } },
428425
rw range_sigma_eq_Union_range,
429426
apply linear_independent_Union_finite_subtype (λ j, (hindep j).to_subtype_range) hd,
430427
end
@@ -592,16 +589,14 @@ begin
592589
{ simp }
593590
end
594591

595-
lemma linear_independent_inl_union_inr {s : set M} {t : set M'}
592+
lemma linear_independent.inl_union_inr {s : set M} {t : set M'}
596593
(hs : linear_independent R (λ x, x : s → M))
597594
(ht : linear_independent R (λ x, x : t → M')) :
598595
linear_independent R (λ x, x : inl R M M' '' s ∪ inr R M M' '' t → M × M') :=
599596
begin
600-
apply linear_independent_union,
601-
exact (hs.image_subtype $ by simp),
602-
exact (ht.image_subtype $ by simp),
603-
rw [span_image, span_image];
604-
simp [disjoint_iff, prod_inf_prod]
597+
refine (hs.image_subtype _).union (ht.image_subtype _) _; [simp, simp, skip],
598+
simp only [span_image],
599+
simp [disjoint_iff, prod_inf_prod]
605600
end
606601

607602
lemma linear_independent_inl_union_inr' {v : ι → M} {v' : ι' → M'}
@@ -616,20 +611,12 @@ begin
616611
{ apply sum.elim_injective,
617612
{ exact injective_comp prod.injective_inl inj_v },
618613
{ exact injective_comp prod.injective_inr inj_v' },
619-
{ intros, simp [ne_zero_of_linear_independent zero_eq_one hv] } },
614+
{ intros, simp [hv.ne_zero zero_eq_one] } },
620615
{ rw sum.elim_range,
621-
apply linear_independent_union,
622-
{ apply linear_independent.to_subtype_range,
623-
apply linear_independent.image hv,
624-
simp [ker_inl] },
625-
{ apply linear_independent.to_subtype_range,
626-
apply linear_independent.image hv',
627-
simp [ker_inr] },
628-
{ apply disjoint_inl_inr.mono _ _,
629-
{ rw [set.range_comp, span_image],
630-
apply linear_map.map_le_range },
631-
{ rw [set.range_comp, span_image],
632-
apply linear_map.map_le_range } } }
616+
refine (hv.image _).to_subtype_range.union (hv'.image _).to_subtype_range _;
617+
[simp, simp, skip],
618+
apply disjoint_inl_inr.mono _ _;
619+
simp only [set.range_comp, span_image, linear_map.map_le_range] }
633620
end
634621

635622
/-- Dedekind's linear independence of characters -/
@@ -781,7 +768,7 @@ begin
781768
exact (λ y hy, exists.elim (set.mem_range.1 hy) (λ i hi, by rw ←hi; exact h i))
782769
end
783770

784-
lemma constr_basis {f : ι → M'} {i : ι} (hv : is_basis R v) :
771+
@[simp] lemma constr_basis {f : ι → M'} {i : ι} (hv : is_basis R v) :
785772
(hv.constr f : M → M') (v i) = f i :=
786773
by simp [is_basis.constr_apply, hv.repr_eq_single, finsupp.sum_single_index]
787774

@@ -797,10 +784,10 @@ constr_eq hv $ λ x, rfl
797784

798785
lemma constr_add {g f : ι → M'} (hv : is_basis R v) :
799786
hv.constr (λi, f i + g i) = hv.constr f + hv.constr g :=
800-
constr_eq hv $ by simp [constr_basis hv] {contextual := tt}
787+
constr_eq hv $ λ b, by simp
801788

802789
lemma constr_neg {f : ι → M'} (hv : is_basis R v) : hv.constr (λi, - f i) = - hv.constr f :=
803-
constr_eq hv $ by simp [constr_basis hv] {contextual := tt}
790+
constr_eq hv $ λ b, by simp
804791

805792
lemma constr_sub {g f : ι → M'} (hs : is_basis R v) :
806793
hv.constr (λi, f i - g i) = hs.constr f - hs.constr g :=
@@ -1022,7 +1009,7 @@ lemma linear_independent.insert (hs : linear_independent K (λ b, b : s → V))
10221009
begin
10231010
rw ← union_singleton,
10241011
have x0 : x ≠ 0 := mt (by rintro rfl; apply zero_mem _) hx,
1025-
apply linear_independent_union hs (linear_independent_singleton x0),
1012+
apply hs.union (linear_independent_singleton x0),
10261013
rwa [disjoint_span_singleton x0]
10271014
end
10281015

@@ -1032,7 +1019,6 @@ begin
10321019
rcases zorn.zorn_subset₀ {b | b ⊆ t ∧ linear_independent K (λ x, x : b → V)} _ _
10331020
⟨hst, hs⟩ with ⟨b, ⟨bt, bi⟩, sb, h⟩,
10341021
{ refine ⟨b, bt, sb, λ x xt, _, bi⟩,
1035-
haveI := classical.dec (x ∈ span K b),
10361022
by_contra hn,
10371023
apply hn,
10381024
rw ← h _ ⟨insert_subset.2 ⟨xt, bt⟩, bi.insert hn⟩ (subset_insert _ _),
@@ -1044,14 +1030,14 @@ begin
10441030
end
10451031

10461032
lemma exists_subset_is_basis (hs : linear_independent K (λ x, x : s → V)) :
1047-
∃b, s ⊆ b ∧ is_basis K (λ i : b, i.val) :=
1033+
∃b, s ⊆ b ∧ is_basis K (coe : b → V) :=
10481034
let ⟨b, hb₀, hx, hb₂, hb₃⟩ := exists_linear_independent hs (@subset_univ _ _) in
10491035
⟨ b, hx,
10501036
@linear_independent.restrict_of_comp_subtype _ _ _ id _ _ _ _ hb₃,
10511037
by simp; exact eq_top_iff.2 hb₂⟩
10521038

10531039
variables (K V)
1054-
lemma exists_is_basis : ∃b : set V, is_basis K (λ i : b, i.val) :=
1040+
lemma exists_is_basis : ∃b : set V, is_basis K (λ i, i : b → V) :=
10551041
let ⟨b, _, hb⟩ := exists_subset_is_basis linear_independent_empty in ⟨b, hb⟩
10561042

10571043
variables {K V}
@@ -1101,11 +1087,10 @@ assume t, finset.induction_on t
11011087
⟨u, subset.trans hust $ union_subset_union (subset.refl _) (by simp [subset_insert]),
11021088
hsu, by simp [eq, hb₂t', hb₁t, hb₁s']⟩)),
11031089
begin
1104-
letI := classical.dec_pred (λx, x ∈ s),
11051090
have eq : t.filter (λx, x ∈ s) ∪ t.filter (λx, x ∉ s) = t,
11061091
{ apply finset.ext.mpr,
11071092
intro x,
1108-
by_cases x ∈ s; simp *, finish },
1093+
by_cases x ∈ s; simp * },
11091094
apply exists.elim (this (t.filter (λx, x ∉ s)) (t.filter (λx, x ∈ s))
11101095
(by simp [set.subset_def]) (by simp [set.ext_iff] {contextual := tt}) (by rwa [eq])),
11111096
intros u h,
@@ -1121,50 +1106,42 @@ let ⟨u, hust, hsu, eq⟩ := exists_of_linear_independent_of_finite_span hs thi
11211106
have finite s, from finite_subset u.finite_to_set hsu,
11221107
this, by rw [←eq]; exact (finset.card_le_of_subset $ finset.coe_subset.mp $ by simp [hsu])⟩
11231108

1124-
lemma exists_left_inverse_linear_map_of_injective {f : V →ₗ[K] V'}
1109+
lemma linear_map.exists_left_inverse_of_injective (f : V →ₗ[K] V')
11251110
(hf_inj : f.ker = ⊥) : ∃g:V' →ₗ V, g.comp f = linear_map.id :=
11261111
begin
11271112
rcases exists_is_basis K V with ⟨B, hB⟩,
11281113
have hB₀ : _ := hB.1.to_subtype_range,
11291114
have : linear_independent K (λ x, x : f '' B → V'),
11301115
{ have h₁ := hB₀.image_subtype
11311116
(show disjoint (span K (range (λ i : B, i.val))) (linear_map.ker f), by simp [hf_inj]),
1132-
have h₂ : range (λ (i : B), i.val) = B := subtype.range_val B,
1133-
rwa h₂ at h₁ },
1117+
rwa B.range_coe_subtype at h₁ },
11341118
rcases exists_subset_is_basis this with ⟨C, BC, hC⟩,
11351119
haveI : inhabited V := ⟨0⟩,
11361120
use hC.constr (C.restrict (inv_fun f)),
1137-
apply @is_basis.ext _ _ _ _ _ _ _ _ _ _ _ _ hB,
1138-
intros b,
1121+
refine hB.ext (λ b, _),
11391122
rw image_subset_iff at BC,
1140-
simp,
1141-
have := BC (subtype.mem b),
1142-
rw mem_preimage at this,
1143-
have : f (b.val) = (subtype.mk (f ↑b) (begin rw ←mem_preimage, exact BC (subtype.mem b) end) : C).val,
1144-
by simp; unfold_coes,
1145-
rw this,
1146-
rw [constr_basis hC],
1147-
exact left_inverse_inv_fun (linear_map.ker_eq_bot.1 hf_inj) _,
1123+
have : f b = (⟨f b, BC b.2⟩ : C) := rfl,
1124+
dsimp,
1125+
rw [this, constr_basis hC],
1126+
exact left_inverse_inv_fun (linear_map.ker_eq_bot.1 hf_inj) _
11481127
end
11491128

1150-
lemma exists_right_inverse_linear_map_of_surjective {f : V →ₗ[K] V'}
1129+
lemma linear_map.exists_right_inverse_of_surjective (f : V →ₗ[K] V')
11511130
(hf_surj : f.range = ⊤) : ∃g:V' →ₗ V, f.comp g = linear_map.id :=
11521131
begin
11531132
rcases exists_is_basis K V' with ⟨C, hC⟩,
11541133
haveI : inhabited V := ⟨0⟩,
11551134
use hC.constr (C.restrict (inv_fun f)),
1156-
apply @is_basis.ext _ _ _ _ _ _ _ _ _ _ _ _ hC,
1157-
intros c,
1158-
simp [constr_basis hC],
1159-
exact right_inverse_inv_fun (linear_map.range_eq_top.1 hf_surj) _
1135+
refine hC.ext (λ c, _),
1136+
simp [constr_basis hC, right_inverse_inv_fun (linear_map.range_eq_top.1 hf_surj) c]
11601137
end
11611138

11621139
open submodule linear_map
1140+
11631141
theorem quotient_prod_linear_equiv (p : submodule K V) :
11641142
nonempty ((p.quotient × p) ≃ₗ[K] V) :=
11651143
begin
1166-
haveI := classical.dec_eq (quotient p),
1167-
rcases exists_right_inverse_linear_map_of_surjective p.range_mkq with ⟨f, hf⟩,
1144+
rcases p.mkq.exists_right_inverse_of_surjective p.range_mkq with ⟨f, hf⟩,
11681145
have mkf : ∀ x, submodule.quotient.mk (f x) = x := linear_map.ext_iff.1 hf,
11691146
have fp : ∀ x, x - f (p.mkq x) ∈ p :=
11701147
λ x, (submodule.quotient.eq p).1 (mkf (p.mkq x)).symm,
@@ -1182,13 +1159,7 @@ open fintype
11821159

11831160
theorem vector_space.card_fintype [fintype K] [fintype V] :
11841161
∃ n : ℕ, card V = (card K) ^ n :=
1185-
begin
1186-
apply exists.elim (exists_is_basis K V),
1187-
intros b hb,
1188-
haveI := classical.dec_pred (λ x, x ∈ b),
1189-
use card b,
1190-
exact module.card_fintype hb,
1191-
end
1162+
exists.elim (exists_is_basis K V) $ λ b hb, ⟨card b, module.card_fintype hb⟩
11921163

11931164
end vector_space
11941165

@@ -1255,22 +1226,19 @@ section
12551226
variables (R η)
12561227

12571228
lemma is_basis_fun₀ : is_basis R
1258-
(λ (ji : Σ (j : η), (λ _, unit) j),
1229+
(λ (ji : Σ (j : η), unit),
12591230
(std_basis R (λ (i : η), R) (ji.fst)) 1) :=
1260-
begin
1261-
haveI := classical.dec_eq,
1262-
apply @is_basis_std_basis R η (λi:η, unit) (λi:η, R) _ _ _ _ (λ _ _, (1 : R))
1263-
(assume i, @is_basis_singleton_one _ _ _ _),
1264-
end
1231+
@is_basis_std_basis R η (λi:η, unit) (λi:η, R) _ _ _ _ (λ _ _, (1 : R))
1232+
(assume i, @is_basis_singleton_one _ _ _ _)
12651233

12661234
lemma is_basis_fun : is_basis R (λ i, std_basis R (λi:η, R) i 1) :=
12671235
begin
1268-
apply is_basis.comp (is_basis_fun₀ R η) (λ i, ⟨i, punit.star⟩),
1236+
apply (is_basis_fun₀ R η).comp (λ i, ⟨i, punit.star⟩),
12691237
apply bijective_iff_has_inverse.2,
1270-
use (λ x, x.1),
1271-
simp [function.left_inverse, function.right_inverse],
1272-
intros _ b,
1273-
rw [unique.eq_default b, unique.eq_default punit.star]
1238+
use sigma.fst,
1239+
suffices : ∀ (a : η) (b : unit), punit.star = b,
1240+
{ simpa [function.left_inverse, function.right_inverse] },
1241+
exact λ _, punit_eq _
12741242
end
12751243

12761244
end

0 commit comments

Comments
 (0)