@@ -5,6 +5,8 @@ Authors: Patrick Massot, Michael Rothgang
55-/
66import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho
77import Mathlib.Geometry.Manifold.VectorBundle.Riemannian
8+ import Mathlib.Geometry.Manifold.VectorBundle.SmoothSection
9+ import Mathlib.Geometry.Manifold.Elaborators
810
911/-!
1012# Gram-Schmidt orthonormalization on sections of Riemannian vector bundles
@@ -14,7 +16,6 @@ for sections of Riemannian vector bundles: this produces a system of sections wh
1416with respect to the bundle metric. If the initial sections were linearly independent (resp.
1517formed a basis) at the point, so do the normalised sections.
1618
17- # TODO
1819If the bundle metric is `C^k`, then the procedure preserves regularity of sections:
1920if all sections are `C^k`, so are their normalised versions.
2021
@@ -70,7 +71,7 @@ theorem gramSchmidt_def'' (s : ι → (x : B) → E x) (n : ι) (x) :
7071 s n x = gramSchmidt s n x + ∑ i ∈ Iio n,
7172 (⟪gramSchmidt s i x, s n x⟫ / (‖gramSchmidt s i x‖) ^ 2 ) • gramSchmidt s i x := by
7273 convert gramSchmidt_def' s n x
73- simp [Submodule. orthogonalProjection_singleton, RCLike.ofReal_pow]
74+ simp [orthogonalProjection_singleton, RCLike.ofReal_pow]
7475
7576@[simp]
7677lemma gramSchmidt_apply (s : ι → (x : B) → E x) (n : ι) (x) :
@@ -83,8 +84,7 @@ theorem gramSchmidt_bot {ι : Type*} [LinearOrder ι] [LocallyFiniteOrder ι] [O
8384 apply InnerProductSpace.gramSchmidt_bot
8485
8586@[simp]
86- theorem gramSchmidt_zero (n : ι) :
87- gramSchmidt (0 : ι → (x : B) → E x) n = 0 := by
87+ theorem gramSchmidt_zero (n : ι) : gramSchmidt (0 : ι → (x : B) → E x) n = 0 := by
8888 ext x
8989 simpa using InnerProductSpace.gramSchmidt_zero ..
9090
@@ -180,8 +180,6 @@ theorem coe_gramSchmidtBasis (hs : LinearIndependent ℝ (s · x))
180180 (gramSchmidtBasis hs hs') = (gramSchmidt s · x) :=
181181 Basis.coe_mk _ _
182182
183- /-- The normalized `gramSchmidt`, i.e. each resulting section has unit length (or vanishes)
184- at each point -/
185183noncomputable def gramSchmidtNormed
186184 (s : ι → (x : B) → E x) (n : ι) : (x : B) → E x := fun x ↦
187185 InnerProductSpace.gramSchmidtNormed ℝ (s · x) n
@@ -215,8 +213,7 @@ theorem gramSchmidtNormed_orthonormal' (s : ι → (x : B) → E x) (x) :
215213 Orthonormal ℝ fun i : { i | gramSchmidtNormed s i x ≠ 0 } => gramSchmidtNormed s i x :=
216214 InnerProductSpace.gramSchmidtNormed_orthonormal' _
217215
218-
219- theorem span_gramSchmidtNormed (s : ι → (x : B) → E x) (t : Set ι) :
216+ theorem span_gramSchmidtNormed (s : ι → (x : B) → E x) (t : Set ι) (x) :
220217 span ℝ ((gramSchmidtNormed s · x) '' t) = span ℝ ((gramSchmidt s · x) '' t) :=
221218 InnerProductSpace.span_gramSchmidtNormed (s · x) t
222219
@@ -277,3 +274,119 @@ theorem gramSchmidtOrthonormalBasis_apply_of_orthonormal [Fintype ι]
277274 simp [gramSchmidtNormed_apply_of_orthonormal hs]
278275
279276end VectorBundle
277+
278+ #exit
279+
280+ /-! The Gram-Schmidt process preserves smoothness of sections -/
281+
282+ variable {n : WithTop ℕ∞}
283+
284+ -- TODO: fix pretty-printing of my new elaborators!
285+ set_option linter.style.commandStart false
286+
287+ variable [IsContMDiffRiemannianBundle IB n F E]
288+
289+ section helper
290+
291+ variable {s t : (x : B) → E x} {u : Set B} {x : B}
292+
293+ -- TODO: give a much better name!
294+ lemma contMDiffWithinAt_aux
295+ (hs : CMDiffAt[u] n (T% s) x) (ht : CMDiffAt[u] n (T% t) x) (hs' : s x ≠ 0 ) :
296+ CMDiffAt[u] n (fun x ↦ ⟪s x, t x⟫ / (‖s x‖ ^ 2 )) x := by
297+ have := (hs.inner_bundle ht).smul ((hs.inner_bundle hs).inv₀ (inner_self_ne_zero.mpr hs'))
298+ apply this.congr
299+ · intro y hy
300+ congr
301+ simp [inner_self_eq_norm_sq_to_K]
302+ · congr
303+ rw [← real_inner_self_eq_norm_sq]
304+
305+ lemma contMDiffAt_aux (hs : CMDiffAt n (T% s) x) (ht : CMDiffAt n (T% t) x) (hs' : s x ≠ 0 ) :
306+ CMDiffAt n (fun x ↦ ⟪s x, t x⟫ / (‖s x‖ ^ 2 )) x := by
307+ rw [← contMDiffWithinAt_univ] at hs ht ⊢
308+ exact contMDiffWithinAt_aux hs ht hs'
309+
310+ def ContMDiffWithinAt.orthogonalProjection
311+ (hs : CMDiffAt[u] n (T% s) x) (ht : CMDiffAt[u] n (T% t) x) (hs' : s x ≠ 0 ) :
312+ -- TODO: leaving out the type ascription yields a horrible error message, add test and fix!
313+ letI S : (x : B) → E x := fun x ↦ (Submodule.span ℝ {s x}).orthogonalProjection (t x);
314+ CMDiffAt[u] n (T% S) x := by
315+ simp_rw [Submodule.orthogonalProjection_singleton]
316+ exact (contMDiffWithinAt_aux hs ht hs').smul_section hs
317+
318+ lemma contMDiffWithinAt_inner (hs : CMDiffAt[u] n (T% s) x) (hs' : s x ≠ 0 ) :
319+ CMDiffAt[u] n (‖s ·‖) x := by
320+ let F (x) := ⟪s x, s x⟫
321+ have aux : CMDiffAt[u] n (Real.sqrt ∘ F) x := by
322+ have h1 : CMDiffAt[(F '' u)] n (Real.sqrt) (F x) := by
323+ apply ContMDiffAt.contMDiffWithinAt
324+ rw [contMDiffAt_iff_contDiffAt]
325+ exact Real.contDiffAt_sqrt (by simp [F, hs'])
326+ exact h1.comp x (hs.inner_bundle hs) (Set.mapsTo_image _ u)
327+ convert aux
328+ simp [F, ← norm_eq_sqrt_real_inner]
329+
330+ end helper
331+
332+ variable {s : ι → (x : B) → E x} {u : Set B} {x : B} {i : ι}
333+
334+ lemma gramSchmidt_contMDiffWithinAt (hs : ∀ i, CMDiffAt[u] n (T% (s i)) x)
335+ {i : ι} (hs' : LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
336+ CMDiffAt[u] n (T% (VectorBundle.gramSchmidt s i)) x := by
337+ simp_rw [VectorBundle.gramSchmidt_def]
338+ apply (hs i).sub_section
339+ apply ContMDiffWithinAt.sum_section
340+ intro i' hi'
341+ let aux : { x // x ∈ Set.Iic i' } → { x // x ∈ Set.Iic i } :=
342+ fun ⟨x, hx⟩ ↦ ⟨x, hx.trans (Finset.mem_Iio.mp hi').le⟩
343+ have : LinearIndependent ℝ ((fun x_1 ↦ s x_1 x) ∘ @Subtype.val ι fun x ↦ x ∈ Set.Iic i') := by
344+ apply hs'.comp aux
345+ intro ⟨x, hx⟩ ⟨x', hx'⟩ h
346+ simp_all only [Subtype.mk.injEq, aux]
347+ apply ContMDiffWithinAt.orthogonalProjection (gramSchmidt_contMDiffWithinAt hs this) (hs i)
348+ apply VectorBundle.gramSchmidt_ne_zero_coe _ _ this
349+ termination_by i
350+ decreasing_by exact (LocallyFiniteOrderBot.finset_mem_Iio i i').mp hi'
351+
352+ lemma gramSchmidt_contMDiffAt (hs : ∀ i, CMDiffAt n (T% (s i)) x)
353+ (hs' : LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
354+ CMDiffAt n (T% (VectorBundle.gramSchmidt s i)) x :=
355+ contMDiffWithinAt_univ.mpr <| gramSchmidt_contMDiffWithinAt (fun i ↦ hs i) hs'
356+
357+ lemma gramSchmidt_contMDiffOn (hs : ∀ i, CMDiff[u] n (T% (s i)))
358+ (hs' : ∀ x ∈ u, LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
359+ CMDiff[u] n (T% (VectorBundle.gramSchmidt s i)) :=
360+ fun x hx ↦ gramSchmidt_contMDiffWithinAt (fun i ↦ hs i x hx) (hs' _ hx)
361+
362+ lemma gramSchmidt_contMDiff (hs : ∀ i, CMDiff n (T% (s i)))
363+ (hs' : ∀ x, LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
364+ CMDiff n (T% (VectorBundle.gramSchmidt s i)) :=
365+ fun x ↦ gramSchmidt_contMDiffAt (fun i ↦ hs i x) (hs' x)
366+
367+ lemma gramSchmidtNormed_contMDiffWithinAt (hs : ∀ i, CMDiffAt[u] n (T% (s i)) x)
368+ (hs' : LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
369+ CMDiffAt[u] n (T% (VectorBundle.gramSchmidtNormed s i)) x := by
370+ have : CMDiffAt[u] n (T%
371+ (fun x ↦ ‖VectorBundle.gramSchmidt s i x‖⁻¹ • VectorBundle.gramSchmidt s i x)) x := by
372+ refine ContMDiffWithinAt.smul_section ?_ (gramSchmidt_contMDiffWithinAt hs hs')
373+ refine ContMDiffWithinAt.inv₀ ?_ ?_
374+ · refine contMDiffWithinAt_inner (gramSchmidt_contMDiffWithinAt hs hs') ?_
375+ simpa using InnerProductSpace.gramSchmidt_ne_zero_coe i hs'
376+ · simpa using InnerProductSpace.gramSchmidt_ne_zero_coe i hs'
377+ exact this.congr (fun y hy ↦ by congr) (by congr)
378+
379+ lemma gramSchmidtNormed_contMDiffAt (hs : ∀ i, CMDiffAt n (T% (s i)) x)
380+ (hs' : LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι)))
381+ : CMDiffAt n (T% (VectorBundle.gramSchmidtNormed s i)) x :=
382+ contMDiffWithinAt_univ.mpr <| gramSchmidtNormed_contMDiffWithinAt (fun i ↦ hs i) hs'
383+
384+ lemma gramSchmidtNormed_contMDiffOn (hs : ∀ i, CMDiff[u] n (T% (s i)))
385+ (hs' : ∀ x ∈ u, LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
386+ CMDiff[u] n (T% (VectorBundle.gramSchmidtNormed s i)) :=
387+ fun x hx ↦ gramSchmidtNormed_contMDiffWithinAt (fun i ↦ hs i x hx) (hs' _ hx)
388+
389+ lemma gramSchmidtNormed_contMDiff (hs : ∀ i, CMDiff n (T% (s i)))
390+ (hs' : ∀ x, LinearIndependent ℝ ((s · x) ∘ ((↑) : Set.Iic i → ι))) :
391+ CMDiff n (T% (VectorBundle.gramSchmidtNormed s i)) :=
392+ fun x ↦ gramSchmidtNormed_contMDiffAt (fun i ↦ hs i x) (hs' x)
0 commit comments