/- Adapted from Mapher `PoincareMT/Proofs/M03/Existence/DeTurckCompletedOutputNative.lean` at f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See `references/ricci-flow/mapher/local-theory/port.json`. -/ import PoincareLib.Geometry.RicciFlow.Local.DeTurck.Jets.DeTurckJetCoordinates import PoincareLib.Analysis.Parabolic.Quasilinear.Tensor.SymmetricTensorHilbert import PoincareLib.Analysis.Parabolic.Quasilinear.Frames.ParsevalTensorL2 import PoincareLib.Analysis.Parabolic.Quasilinear.Operators.LpFiniteCoordinates /-! # The fixed even-order output of the native DeTurck residual Ordered native derivatives expand every power of one plus the fixed tensor generator. The resulting finite coefficient map sends arbitrary L2 tuples to spectral coordinates, and agrees with the actual smooth tensor output. -/ set_option autoImplicit false set_option maxHeartbeats 1600000 set_option backward.isDefEq.respectTransparency false noncomputable section open MeasureTheory Set Filter open scoped Manifold ContDiff Bundle BigOperators namespace PoincareMT.DeTurckCompletedOutputNative open TensorProbeNative ParsevalTensorNative ChartMeasureNative TensorHilbertNative DeTurckJetCoordinatesNative LpFiniteCoordinatesNative variable {n : β„•} {M iota : Type*} [TopologicalSpace M] [T2Space M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] [CompactSpace M] [Fintype iota] def multiplyTerms (c : M β†’ ℝ) (hc : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ c) (terms : List (DirectionalTerm (n := n) (M := M) (iota := iota))) : List (DirectionalTerm (n := n) (M := M) (iota := iota)) := terms.map (fun t => ⟨fun x => c x * t.coefficient x, by exact (hc.mul t.smooth).congr (fun x => rfl), t.word⟩) theorem directionalTerms_multiply (F : iota β†’ SmoothField (n := n) (M := M)) (c : M β†’ ℝ) (hc : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ c) (terms : List (DirectionalTerm (n := n) (M := M) (iota := iota))) (f : M β†’ ℝ) (x : M) : directionalTerms F (multiplyTerms c hc terms) f x = c x * directionalTerms F terms f x := by induction terms with | nil => simp only [multiplyTerms, List.map_nil, directionalTerms_nil, mul_zero] | cons t terms ih => simp only [multiplyTerms, List.map_cons, directionalTerms_cons] at ih ⊒ rw [ih] ring theorem multiplyTerms_order (c : M β†’ ℝ) (hc : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ c) (terms : List (DirectionalTerm (n := n) (M := M) (iota := iota))) {k : β„•} (h : βˆ€ t ∈ terms, t.word.length ≀ k) : βˆ€ t ∈ multiplyTerms c hc terms, t.word.length ≀ k := by intro t ht obtain ⟨q, hq, rfl⟩ := List.mem_map.mp ht exact h q hq def sumTerms {Ξ± : Type*} [Fintype Ξ±] (terms : Ξ± β†’ List (DirectionalTerm (n := n) (M := M) (iota := iota))) : List (DirectionalTerm (n := n) (M := M) (iota := iota)) := by classical exact Finset.univ.toList.flatMap terms private theorem directionalTerms_flatMap {Ξ± : Type*} (F : iota β†’ SmoothField (n := n) (M := M)) (s : List Ξ±) (terms : Ξ± β†’ List (DirectionalTerm (n := n) (M := M) (iota := iota))) (f : M β†’ ℝ) (x : M) : directionalTerms F (s.flatMap terms) f x = (s.map (fun a => directionalTerms F (terms a) f x)).sum := by induction s with | nil => rfl | cons a s ih => simp only [List.flatMap_cons, directionalTerms_append, List.map_cons, List.sum_cons, ih] theorem directionalTerms_sum {Ξ± : Type*} [Fintype Ξ±] (F : iota β†’ SmoothField (n := n) (M := M)) (terms : Ξ± β†’ List (DirectionalTerm (n := n) (M := M) (iota := iota))) (f : M β†’ ℝ) (x : M) : directionalTerms F (sumTerms terms) f x = βˆ‘ a, directionalTerms F (terms a) f x := by classical rw [sumTerms, directionalTerms_flatMap, Finset.sum_map_toList] theorem sumTerms_order {Ξ± : Type*} [Fintype Ξ±] (terms : Ξ± β†’ List (DirectionalTerm (n := n) (M := M) (iota := iota))) {k : β„•} (h : βˆ€ a t, t ∈ terms a β†’ t.word.length ≀ k) : βˆ€ t ∈ sumTerms terms, t.word.length ≀ k := by classical intro t ht obtain ⟨a, _, ha⟩ := List.mem_flatMap.mp ht exact h a t ha /-- Both applications of a field differentiate all previously formed coefficients. -/ def laplacianTerms (F : iota β†’ SmoothField (n := n) (M := M)) (charts : FiniteChartData (n := n) (M := M)) (terms : List (DirectionalTerm (n := n) (M := M) (iota := iota))) : List (DirectionalTerm (n := n) (M := M) (iota := iota)) := sumTerms (fun i : iota => multiplyTerms (fun _ : M => (-1 : ℝ)) contMDiff_const (differentiateDirectionalTerms F i (differentiateDirectionalTerms F i terms)) ++ multiplyTerms (fun x => -charts.fieldDivergence (F i) x) (charts.fieldDivergence_contMDiff (F i)).neg (differentiateDirectionalTerms F i terms)) theorem directionalTerms_laplacian (F : iota β†’ SmoothField (n := n) (M := M)) (charts : FiniteChartData (n := n) (M := M)) (terms : List (DirectionalTerm (n := n) (M := M) (iota := iota))) {f : M β†’ ℝ} (hf : ContMDiff (𝓑 n) π“˜(ℝ, ℝ) ∞ f) (x : M) : directionalTerms F (laplacianTerms F charts terms) f x = scalarLaplacian F charts (directionalTerms F terms f) x := by classical rw [laplacianTerms, directionalTerms_sum] unfold scalarLaplacian apply Finset.sum_congr rfl intro i _ have hfirst : directionalTerms F (differentiateDirectionalTerms F i terms) f = scalarDirectional (F i) (directionalTerms F terms f) := funext (directionalTerms_differentiate F i terms hf) have hsecond := directionalTerms_differentiate F i (differentiateDirectionalTerms F i terms) hf x rw [hfirst] at hsecond rw [directionalTerms_append, directionalTerms_multiply, directionalTerms_multiply, hsecond, hfirst] simp only [FiniteChartData.fieldAdjoint] ring theorem laplacianTerms_order (F : iota β†’ SmoothField (n := n) (M := M)) (charts : FiniteChartData (n := n) (M := M)) (terms : List (DirectionalTerm (n := n) (M := M) (iota := iota))) {k : β„•} (h : βˆ€ t ∈ terms, t.word.length ≀ k) : βˆ€ t ∈ laplacianTerms F charts terms, t.word.length ≀ k + 2 := by apply sumTerms_order intro i t ht have hfirst := differentiateDirectionalTerms_order F i terms h have hsecond := differentiateDirectionalTerms_order F i (differentiateDirectionalTerms F i terms) hfirst rcases List.mem_append.mp ht with ht | ht Β· have hbound := multiplyTerms_order (fun _ : M => (-1 : ℝ)) contMDiff_const (differentiateDirectionalTerms F i (differentiateDirectionalTerms F i terms)) hsecond t ht omega Β· have hbound := multiplyTerms_order (fun x => -charts.fieldDivergence (F i) x) (charts.fieldDivergence_contMDiff (F i)).neg (differentiateDirectionalTerms F i terms) hfirst t ht omega variable {g0 : RiemannianMetric n M} (d : TensorHilbertNative.Data g0) [MeasurableSpace M] [BorelSpace M] /-- Fixed coefficients for the actual power `(1 + generator)^r`. -/ def shiftedPowerTerms : β„• β†’ d.ProbeIndex β†’ d.ProbeIndex β†’ List (DirectionalTerm (n := n) (M := M) (iota := Fin d.fieldCount)) | 0, a, b => if a = b then [⟨fun _ => 1, contMDiff_const, []⟩] else [] | r + 1, a, b => shiftedPowerTerms r a b ++ sumTerms (fun c : d.ProbeIndex => multiplyTerms (fun x => projectionKernel g0 d.fields x a c) (projectionKernel_contMDiff d.fields g0 a c) (laplacianTerms d.fields d.charts (shiftedPowerTerms r c b))) theorem shiftedPowerTerms_order (r : β„•) (a b : d.ProbeIndex) : βˆ€ t ∈ shiftedPowerTerms d r a b, t.word.length ≀ 2 * r := by induction r generalizing a b with | zero => intro t ht by_cases hab : a = b Β· simp only [shiftedPowerTerms, if_pos hab, List.mem_cons, List.not_mem_nil, or_false] at ht subst t exact Nat.zero_le _ Β· simp only [shiftedPowerTerms, if_neg hab, List.not_mem_nil] at ht | succ r ih => intro t ht rcases List.mem_append.mp ht with ht | ht Β· have hbound := ih a b t ht omega Β· have hbound : t.word.length ≀ 2 * r + 2 := by apply sumTerms_order _ (fun c => multiplyTerms_order _ _ _ (laplacianTerms_order d.fields d.charts _ (ih c b))) t ht omega theorem scalarProbe_shiftedSmoothTensor (h : SmoothTensor (n := n) (M := M)) (a : d.ProbeIndex) (x : M) : scalarProbe d.fields (d.shiftedSmoothTensor h) a x = scalarProbe d.fields h a x + βˆ‘ c : d.ProbeIndex, projectionKernel g0 d.fields x a c * scalarLaplacian d.fields d.charts (scalarProbe d.fields h c) x := by classical change scalarProbe d.fields h a x + probes d.fields (smoothTensorLaplacian d.fields d.charts g0 h) x a = _ rw [probes_smoothTensorLaplacian, nativeProjection_eq_kernel] congr 1 apply Finset.sum_congr rfl intro c _ exact mul_comm _ _ /-- The recurrence identifies the complete smooth output, including projection derivatives. -/ theorem scalarProbe_shiftedSmoothPower (r : β„•) (h : SmoothTensor (n := n) (M := M)) (a : d.ProbeIndex) (x : M) : scalarProbe d.fields (d.shiftedSmoothPower r h) a x = βˆ‘ b : d.ProbeIndex, directionalTerms d.fields (shiftedPowerTerms d r a b) (scalarProbe d.fields h b) x := by classical induction r generalizing a x with | zero => have hz (b : d.ProbeIndex) : directionalTerms d.fields (shiftedPowerTerms d 0 a b) (scalarProbe d.fields h b) x = if a = b then scalarProbe d.fields h b x else 0 := by by_cases hab : a = b <;> simp [shiftedPowerTerms, hab, directionalTerms, directionalWord] simp only [TensorHilbertNative.Data.shiftedSmoothPower] simp_rw [hz] simp | succ r ih => rw [TensorHilbertNative.Data.shiftedSmoothPower, scalarProbe_shiftedSmoothTensor, ih] simp only [shiftedPowerTerms, directionalTerms_append, directionalTerms_sum, directionalTerms_multiply, directionalTerms_laplacian d.fields d.charts _ (scalarProbe_contMDiff d.fields h _)] rw [Finset.sum_add_distrib] congr 1 rw [Finset.sum_comm] apply Finset.sum_congr rfl intro c _ rw [← Finset.mul_sum] congr 1 have heq : scalarProbe d.fields (d.shiftedSmoothPower r h) c = fun y => βˆ‘ b : d.ProbeIndex, directionalTerms d.fields (shiftedPowerTerms d r c b) (scalarProbe d.fields h b) y := funext (ih c) rw [heq] exact scalarLaplacian_finsetSum d.fields d.charts Finset.univ isOpen_univ _ (fun b _ => (directionalTerms_contMDiff d.fields _ (scalarProbe_contMDiff d.fields h b)).contMDiffOn) (mem_univ x) abbrev ProbeTuples (k : β„•) := d.ProbeIndex β†’ WordIndex (Fin d.fieldCount) k β†’ Lp ℝ 2 d.charts.measure /-- The scalar output for one probe is a finite sum of existing bounded coefficient maps. -/ def powerProbeL2 (r : β„•) (a : d.ProbeIndex) : ProbeTuples d (2 * r) β†’L[ℝ] Lp ℝ 2 d.charts.measure := βˆ‘ b : d.ProbeIndex, (termsL2 d.charts.measure (shiftedPowerTerms d r a b) (shiftedPowerTerms_order d r a b)).comp (ContinuousLinearMap.proj b) theorem powerProbeL2_ae_eq (r : β„•) (a : d.ProbeIndex) (Q : ProbeTuples d (2 * r)) (h : SmoothTensor (n := n) (M := M)) (hQ : βˆ€ b w (hw : w.length ≀ 2 * r), Q b (wordIndex w hw) =ᡐ[d.charts.measure] directionalWord d.fields w (scalarProbe d.fields h b)) : powerProbeL2 d r a Q =ᡐ[d.charts.measure] scalarProbe d.fields (d.shiftedSmoothPower r h) a := by let q (b : d.ProbeIndex) : Lp ℝ 2 d.charts.measure := termsL2 d.charts.measure (shiftedPowerTerms d r a b) (shiftedPowerTerms_order d r a b) (Q b) have hq (b : d.ProbeIndex) : q b =ᡐ[d.charts.measure] directionalTerms d.fields (shiftedPowerTerms d r a b) (scalarProbe d.fields h b) := termsL2_ae_eq d.fields d.charts.measure (shiftedPowerTerms d r a b) (shiftedPowerTerms_order d r a b) (Q b) (scalarProbe d.fields h b) (hQ b) filter_upwards [Lp.coeFn_fun_finsetSum Finset.univ q, ae_all_iff.mpr hq] with x hsum hterms simp only [powerProbeL2, ContinuousLinearMap.sum_apply, ContinuousLinearMap.comp_apply, ContinuousLinearMap.proj_apply] change (βˆ‘ b : d.ProbeIndex, q b) x = _ rw [hsum] simp only [hterms] exact (scalarProbe_shiftedSmoothPower d r h a x).symm /-- The actual ambient tensor L2 output uses the fixed finite-coordinate insertion. -/ def powerTensorL2 (r : β„•) : ProbeTuples d (2 * r) β†’L[ℝ] Lp (Coefficients (Fin d.fieldCount)) 2 d.charts.measure := βˆ‘ a : d.ProbeIndex, (insertionLp d.charts.measure a).comp (powerProbeL2 d r a) theorem powerTensorL2_eq (r : β„•) (Q : ProbeTuples d (2 * r)) (h : SmoothTensor (n := n) (M := M)) (hQ : βˆ€ b w (hw : w.length ≀ 2 * r), Q b (wordIndex w hw) =ᡐ[d.charts.measure] directionalWord d.fields w (scalarProbe d.fields h b)) : powerTensorL2 d r Q = tensorToLp d.fields d.charts.measure (d.shiftedSmoothPower r h) := by let q (a : d.ProbeIndex) := powerProbeL2 d r a Q apply Lp.ext filter_upwards [Lp.coeFn_fun_finsetSum Finset.univ (fun a : d.ProbeIndex => insertionLp d.charts.measure a (q a)), ae_all_iff.mpr (fun a : d.ProbeIndex => insertionLp_coe d.charts.measure a (q a)), ae_all_iff.mpr (fun a : d.ProbeIndex => powerProbeL2_ae_eq d r a Q h hQ), tensorToLp_coe d.fields d.charts.measure (d.shiftedSmoothPower r h)] with x hsum hinsert hprobe htensor simp only [powerTensorL2, ContinuousLinearMap.sum_apply, ContinuousLinearMap.comp_apply] change (βˆ‘ a : d.ProbeIndex, insertionLp d.charts.measure a (q a)) x = _ rw [hsum, htensor] calc _ = βˆ‘ a : d.ProbeIndex, scalarProbe d.fields (d.shiftedSmoothPower r h) a x β€’ EuclideanSpace.basisFun d.ProbeIndex ℝ a := by apply Finset.sum_congr rfl intro a _ rw [hinsert a] change powerProbeL2 d r a Q x β€’ _ = _ rw [hprobe a] _ = _ := sum_coordinates (probes d.fields (d.shiftedSmoothPower r h) x) def projectedValue : Lp (Coefficients (Fin d.fieldCount)) 2 d.charts.measure β†’L[ℝ] d.Value := (tensorL2 d.fields d.charts.measure).orthogonalProjectionOnto @[simp] theorem projectedValue_eq_self (v : d.Value) : projectedValue d (v : Lp (Coefficients (Fin d.fieldCount)) 2 d.charts.measure) = v := (tensorL2 d.fields d.charts.measure).orthogonalProjectionOnto_mem_subspace_eq_self v /-- Only an identified tensor output needs to agree with the coefficient projection. -/ theorem projectedValue_eq_of_projection (f : Lp (Coefficients (Fin d.fieldCount)) 2 d.charts.measure) (v : d.Value) (hf : projectionL2 g0 d.fields d.parseval d.charts.measure f = (v : Lp (Coefficients (Fin d.fieldCount)) 2 d.charts.measure)) : projectedValue d f = v := by apply Subtype.ext change (tensorL2 d.fields d.charts.measure).starProjection f = (v : Lp _ 2 _) apply (tensorL2 d.fields d.charts.measure).eq_starProjection_of_mem_of_inner_eq_zero v.property intro w hw rw [inner_sub_left, ← hf, projectionL2_selfadjoint, projectionL2_eq_self_of_mem_tensorL2 g0 d.fields d.parseval d.charts.measure hw, sub_self] /-- This map is defined on every raw tuple; compatibility is needed only for its core identity. -/ def evenOutput (r : β„•) : ProbeTuples d (2 * r) β†’L[ℝ] SpectralHeatNative.State d.SymmetricIndex := d.symmetricBasis.repr.toContinuousLinearEquiv.toContinuousLinearMap.comp ((d.valueSymmetrize.codRestrict d.symmetricValue d.valueSymmetrize_mem).comp ((projectedValue d).comp (powerTensorL2 d r))) theorem evenOutput_eq (r : β„•) (Q : ProbeTuples d (2 * r)) (h : SmoothTensor (n := n) (M := M)) (hsymm : βˆ€ (x : M) (v w : TangentSpace (𝓑 n) x), h x v w = h x w v) (hQ : βˆ€ b w (hw : w.length ≀ 2 * r), Q b (wordIndex w hw) =ᡐ[d.charts.measure] directionalWord d.fields w (scalarProbe d.fields h b)) : evenOutput d r Q = d.smoothTensorCoordinates (2 * r) h hsymm := by have hvalue : projectedValue d (powerTensorL2 d r Q) = intoTensorL2 d.fields d.charts.measure (d.shiftedSmoothPower r h) := by rw [powerTensorL2_eq d r Q h hQ] exact projectedValue_eq_self d (intoTensorL2 d.fields d.charts.measure (d.shiftedSmoothPower r h)) have hsym : (d.valueSymmetrize.codRestrict d.symmetricValue d.valueSymmetrize_mem) (projectedValue d (powerTensorL2 d r Q)) = d.intoSymmetricValue (d.shiftedSmoothPower r h) (d.shiftedSmoothPower_symm r h hsymm) := by apply Subtype.ext change d.valueSymmetrize (projectedValue d (powerTensorL2 d r Q)) = _ rw [hvalue] exact d.valueSymmetrize_eq_self_of_mem (d.intoSymmetricValue (d.shiftedSmoothPower r h) (d.shiftedSmoothPower_symm r h hsymm)).property change d.symmetricBasis.repr ((d.valueSymmetrize.codRestrict d.symmetricValue d.valueSymmetrize_mem) (projectedValue d (powerTensorL2 d r Q))) = _ rw [hsym] exact (d.scaleEncode_even_smoothTensor r h hsymm).symm theorem evenOutput_norm_le (r : β„•) (Q : ProbeTuples d (2 * r)) : β€–evenOutput d r Qβ€– ≀ β€–evenOutput d rβ€– * β€–Qβ€– := (evenOutput d r).le_opNorm Q def smoothProbeTuples (k : β„•) (h : SmoothTensor (n := n) (M := M)) : ProbeTuples d k := fun b w => ContinuousMap.toLp 2 d.charts.measure ℝ ⟨directionalWord d.fields (List.ofFn w.2) (scalarProbe d.fields h b), (directionalWord_contMDiff d.fields (List.ofFn w.2) (scalarProbe_contMDiff d.fields h b)).continuous⟩ theorem smoothProbeTuples_ae_eq (k : β„•) (h : SmoothTensor (n := n) (M := M)) (b : d.ProbeIndex) (w : List (Fin d.fieldCount)) (hw : w.length ≀ k) : smoothProbeTuples d k h b (wordIndex w hw) =ᡐ[d.charts.measure] directionalWord d.fields w (scalarProbe d.fields h b) := by simpa only [smoothProbeTuples, wordIndex_word, ContinuousMap.coe_mk] using ContinuousMap.coeFn_toLp (p := (2 : ENNReal)) (ΞΌ := d.charts.measure) (π•œ := ℝ) (⟨directionalWord d.fields w (scalarProbe d.fields h b), (directionalWord_contMDiff d.fields w (scalarProbe_contMDiff d.fields h b)).continuous⟩ : C(M, ℝ)) theorem evenOutput_smoothProbeTuples (r : β„•) (h : SmoothTensor (n := n) (M := M)) (hsymm : βˆ€ (x : M) (v w : TangentSpace (𝓑 n) x), h x v w = h x w v) : evenOutput d r (smoothProbeTuples d (2 * r) h) = d.smoothTensorCoordinates (2 * r) h hsymm := evenOutput_eq d r _ h hsymm (smoothProbeTuples_ae_eq d (2 * r) h) end PoincareMT.DeTurckCompletedOutputNative end