import Euler.MeanBoundaryOperator import Euler.MeanHarmonicDerivatives /-! Ordinary smooth vector-calculus identities with the canonical Mathlib Laplacian. -/ /-! ## From `Euler/MeanCurlTensor.lean` The text of `Euler/MeanCurlTensor.lean`, folded into this file, which was its only importer. -/ section /-! The ordinary curl as a bounded antisymmetrization of actual L² gradient tensors. -/ noncomputable section namespace EulerMeanCurlTensor open MeasureTheory EulerSmoothLimit EulerVectorCalculus EulerMeanSolenoidal EulerMeanCutoffCurl EulerMeanGradientTest EulerMeanBoundary open scoped ContDiff ENNReal NNReal def coordinateInsertion (i j : Fin 3) : Space →L[ℝ] Space := (EuclideanSpace.proj j).smulRight (EuclideanSpace.single i 1) theorem coordinateInsertion_norm_le (i j : Fin 3) : ‖coordinateInsertion i j‖ ≤ 1 := by apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) intro v simpa [coordinateInsertion, ContinuousLinearMap.smulRight_apply, norm_smul] using PiLp.norm_apply_le v j def coordinateL2 (i j : Fin 3) : L2 →L[ℝ] L2 := (coordinateInsertion i j).compLpL 2 volume theorem coordinateL2_ae (i j : Fin 3) (u : L2) : coordinateL2 i j u =ᵐ[volume] fun x => (u x j) • EuclideanSpace.single i 1 := (coordinateInsertion i j).coeFn_compLpL (p := 2) (μ := volume) u theorem coordinateL2_apply_norm_le (i j : Fin 3) (u : L2) : ‖coordinateL2 i j u‖ ≤ ‖u‖ := by refine ((coordinateInsertion i j).norm_compLp_le u).trans ?_ simpa only [one_mul] using mul_le_mul_of_nonneg_right (coordinateInsertion_norm_le i j) (norm_nonneg u) /-- Each output component is the difference of the two off-diagonal derivative entries. -/ def curlTensor : GradientTensor →L[ℝ] L2 := ∑ i : Fin 3, ((coordinateL2 i (i+2)).comp (PiLp.proj 2 (fun _ : Fin 3 => L2) (i+1)) - (coordinateL2 i (i+1)).comp (PiLp.proj 2 (fun _ : Fin 3 => L2) (i+2))) theorem curlTensor_apply (G : GradientTensor) : curlTensor G = ∑ i : Fin 3, (coordinateL2 i (i+2) (G (i+1)) - coordinateL2 i (i+1) (G (i+2))) := by simp [curlTensor] /-- A fixed universal contraction bound; sharpness is not needed for localization. -/ theorem curlTensor_norm_le (G : GradientTensor) : ‖curlTensor G‖ ≤ 6 * ‖G‖ := by rw [curlTensor_apply] calc _ ≤ ∑ i : Fin 3, ‖coordinateL2 i (i+2) (G (i+1)) - coordinateL2 i (i+1) (G (i+2))‖ := norm_sum_le _ _ _ ≤ ∑ _i : Fin 3, 2 * ‖G‖ := by apply Finset.sum_le_sum intro i _ have h1 := (coordinateL2_apply_norm_le i (i+2) (G (i+1))).trans (PiLp.norm_apply_le G (i+1)) have h2 := (coordinateL2_apply_norm_le i (i+1) (G (i+2))).trans (PiLp.norm_apply_le G (i+2)) exact (norm_sub_le _ _).trans (by linarith) _ = 6 * ‖G‖ := by simp; ring theorem curlTensor_ae (G : GradientTensor) : curlTensor G =ᵐ[volume] fun x => WithLp.toLp 2 (fun i : Fin 3 => (G (i+1) x) (i+2) - (G (i+2) x) (i+1)) := by rw [curlTensor_apply] have hpart (i : Fin 3) : (coordinateL2 i (i+2) (G (i+1)) - coordinateL2 i (i+1) (G (i+2))) =ᵐ[volume] fun x => ((G (i+1) x) (i+2) - (G (i+2) x) (i+1)) • EuclideanSpace.single i 1 := by filter_upwards [Lp.coeFn_sub (coordinateL2 i (i+2) (G (i+1))) (coordinateL2 i (i+1) (G (i+2))), coordinateL2_ae i (i+2) (G (i+1)), coordinateL2_ae i (i+1) (G (i+2))] with x hs h1 h2 simp only [Pi.sub_apply] at hs rw [hs, h1, h2, sub_smul] filter_upwards [Lp.coeFn_finsetSum Finset.univ (fun i : Fin 3 => coordinateL2 i (i+2) (G (i+1)) - coordinateL2 i (i+1) (G (i+2))), ae_all_iff.mpr hpart] with x hs hp simp only [Finset.sum_apply] at hs rw [hs] simp_rw [hp] ext j fin_cases j <;> simp [Fin.sum_univ_three] /-- On genuine test gradients the tensor operator is exactly the ordinary classical curl. -/ theorem curlTensor_test_ae (f : Test) : curlTensor (testGradient f) =ᵐ[volume] vectorCurl (f : Space → Space) := by filter_upwards [curlTensor_ae (testGradient f), ae_all_iff.mpr (fun i => derivativeColumn_ae f i)] with x hc hd rw [hc, vectorCurl_eq_matrix _ x ((f.smooth.differentiable (by simp)).differentiableAt)] ext i change (derivativeColumn f (i+1) x) (i+2) - (derivativeColumn f (i+2) x) (i+1) = _ rw [hd, hd] rfl /-- The source's field `w`, formed directly from the weak potential's gradient tensor. -/ def harmonicPart (χ : Cutoff) (z : L2) : L2 := curlTensor (weakPotential χ z : GradientTensor) theorem harmonicPart_norm_le (χ : Cutoff) (z : L2) : ‖harmonicPart χ z‖ ≤ 6 * ‖weakPotential χ z‖ := curlTensor_norm_le (weakPotential χ z : GradientTensor) end EulerMeanCurlTensor end end noncomputable section namespace EulerMeanVectorIdentities open MeasureTheory InnerProductSpace Laplacian EulerSmoothLimit EulerVectorCalculus EulerMeanSolenoidal EulerMeanCutoffCurl EulerMeanGradientTest EulerMeanHarmonic open scoped ContDiff def vectorPartial (f : Space → Space) (i : Fin 3) (x : Space) : Space := fderiv ℝ f x (EuclideanSpace.single i 1) theorem vectorPartial_smooth (f : Space → Space) (hf : ContDiff ℝ ∞ f) (i : Fin 3) : ContDiff ℝ ∞ (vectorPartial f i) := (hf.fderiv_right (m := ∞) (by simp)).clm_apply contDiff_const theorem vectorPartial_compact (f : Space → Space) (hc : HasCompactSupport f) (i : Fin 3) : HasCompactSupport (vectorPartial f i) := hc.fderiv_apply ℝ (EuclideanSpace.single i 1) theorem vector_laplacian_coordinate (f : Space → Space) (hf : ContDiff ℝ ∞ f) (x : Space) (i : Fin 3) : (Δ f x) i = Δ (fun y => f y i) x := by have h2 : ContDiffAt ℝ 2 f x := (hf.of_le (by simp)).contDiffAt exact (h2.laplacian_CLM_comp_left (l := EuclideanSpace.proj i)).symm theorem vector_laplacian_eq_sum (f : Space → Space) (hf : ContDiff ℝ ∞ f) : Δ f = fun x => ∑ i : Fin 3, vectorPartial (vectorPartial f i) i x := by funext x rw [laplacian_eq_iteratedFDeriv_orthonormalBasis f (EuclideanSpace.basisFun (Fin 3) ℝ)] apply Finset.sum_congr rfl intro i _ have hdf : DifferentiableAt ℝ (fderiv ℝ f) x := ((hf.fderiv_right (m := ∞) (by simp)).differentiable (by simp)).differentiableAt simp only [EuclideanSpace.basisFun_apply, iteratedFDeriv_two_apply, Matrix.cons_val_zero, Matrix.cons_val_one, vectorPartial] change _ = (fderiv ℝ (fun y => fderiv ℝ f y (EuclideanSpace.single i 1)) x) (EuclideanSpace.single i 1) rw [fderiv_clm_apply hdf (differentiableAt_const _)] simp theorem vector_laplacian_smooth (f : Space → Space) (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (Δ f) := by rw [vector_laplacian_eq_sum f hf] exact ContDiff.sum (fun i _ => vectorPartial_smooth _ (vectorPartial_smooth f hf i) i) theorem vector_laplacian_compact (f : Space → Space) (hf : ContDiff ℝ ∞ f) (hc : HasCompactSupport f) : HasCompactSupport (Δ f) := by rw [vector_laplacian_eq_sum f hf] simp only [Fin.sum_univ_three] exact ((vectorPartial_compact _ (vectorPartial_compact f hc 0) 0).add (vectorPartial_compact _ (vectorPartial_compact f hc 1) 1)).add (vectorPartial_compact _ (vectorPartial_compact f hc 2) 2) theorem vectorCurl_smooth (f : Space → Space) (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (vectorCurl f) := contDiff_curl _ ((contDiff_piLp 2).mp hf) theorem vectorCurl_support (f : Space → Space) : tsupport (vectorCurl f) ⊆ tsupport f := tsupport_curl_subset _ _ (isClosed_tsupport f) (fun i => tsupport_comp_subset (g := fun v : Space => v i) rfl f) theorem vectorCurl_compact (f : Space → Space) (hc : HasCompactSupport f) : HasCompactSupport (vectorCurl f) := hc.of_isClosed_subset (isClosed_tsupport _) (vectorCurl_support f) def curlTest (f : Test) : Test := ⟨vectorCurl (f : Space → Space), vectorCurl_smooth f f.smooth, vectorCurl_compact f f.compact⟩ def laplacianTest (f : Test) : Test := ⟨Δ (f : Space → Space), vector_laplacian_smooth f f.smooth, vector_laplacian_compact f f.smooth f.compact⟩ theorem divergence_coordinate_sum (f : Space → Space) (hf : ContDiff ℝ ∞ f) : divergence f = fun x => ∑ i : Fin 3, partialDerivative (fun y => f y i) i x := by funext x rw [divergence_eq_coordinate_sum] apply Finset.sum_congr rfl intro i _ exact (fderiv_coordinate f x ((hf.differentiable (by simp)).differentiableAt) i (EuclideanSpace.single i 1)).symm theorem divergence_smooth (f : Space → Space) (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (divergence f) := by rw [divergence_coordinate_sum f hf] exact ContDiff.sum (fun i _ => contDiff_partialDerivative _ ((contDiff_piLp 2).mp hf i) i) theorem partialDerivative_sub (f g : Space → ℝ) (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (i : Fin 3) (x : Space) : partialDerivative (fun y => f y - g y) i x = partialDerivative f i x - partialDerivative g i x := by unfold partialDerivative rw [fderiv_fun_sub ((hf.differentiable (by simp)).differentiableAt) ((hg.differentiable (by simp)).differentiableAt)] rfl /-- The classical curl-curl identity, with genuine Fréchet derivatives and canonical Laplacian. -/ theorem vectorCurl_vectorCurl (f : Space → Space) (hf : ContDiff ℝ ∞ f) : vectorCurl (vectorCurl f) = gradient (divergence f) - Δ f := by have hc (i : Fin 3) : ContDiff ℝ ∞ (fun y => f y i) := (contDiff_piLp 2).mp hf i have hsub (a b c d e : Fin 3) (x : Space) : partialDerivative (fun y => partialDerivative (fun z => f z a) b y - partialDerivative (fun z => f z c) d y) e x = partialDerivative (partialDerivative (fun z => f z a) b) e x - partialDerivative (partialDerivative (fun z => f z c) d) e x := partialDerivative_sub _ _ (contDiff_partialDerivative _ (hc a) b) (contDiff_partialDerivative _ (hc c) d) e x have hcomm (a i j : Fin 3) (x : Space) : partialDerivative (partialDerivative (fun z => f z a) i) j x = partialDerivative (partialDerivative (fun z => f z a) j) i x := partialDerivative_comm _ ((hc a).of_le (by simp)) i j x funext x let d (a i j : Fin 3) := partialDerivative (partialDerivative (fun z => f z a) i) j x ext i simp only [Pi.sub_apply, PiLp.sub_apply, gradient_coordinate, vector_laplacian_coordinate f hf, divergence_coordinate_sum f hf, partialDerivative_sum _ (fun j => contDiff_partialDerivative _ (hc j) j), laplacian_eq_coordinate_sum _ (hc i), vectorCurl, curl_apply, hsub] fin_cases i · norm_num [Fin.sum_univ_three, Fin.add_def] change d 1 0 1 - d 0 1 1 - (d 0 2 2 - d 2 0 2) = d 0 0 0 + d 1 1 0 + d 2 2 0 - (d 0 0 0 + d 0 1 1 + d 0 2 2) have h₁ : d 1 0 1 = d 1 1 0 := hcomm 1 0 1 x have h₂ : d 2 0 2 = d 2 2 0 := hcomm 2 0 2 x linarith · norm_num [Fin.sum_univ_three, Fin.add_def] change d 2 1 2 - d 1 2 2 - (d 1 0 0 - d 0 1 0) = d 0 0 1 + d 1 1 1 + d 2 2 1 - (d 1 0 0 + d 1 1 1 + d 1 2 2) have h₁ : d 0 1 0 = d 0 0 1 := hcomm 0 1 0 x have h₂ : d 2 1 2 = d 2 2 1 := hcomm 2 1 2 x linarith · norm_num [Fin.sum_univ_three, Fin.add_def] change d 0 2 0 - d 2 0 0 - (d 2 1 1 - d 1 2 1) = d 0 0 2 + d 1 1 2 + d 2 2 2 - (d 2 0 0 + d 2 1 1 + d 2 2 2) have h₁ : d 0 2 0 = d 0 0 2 := hcomm 0 2 0 x have h₂ : d 1 2 1 = d 1 1 2 := hcomm 1 2 1 x linarith theorem divergence_compact (f : Space → Space) (hf : ContDiff ℝ ∞ f) (hc : HasCompactSupport f) : HasCompactSupport (divergence f) := by rw [divergence_coordinate_sum f hf] have hpart (i : Fin 3) : HasCompactSupport (partialDerivative (fun y => f y i) i) := (hc.comp_left (g := fun v : Space => v i) rfl).fderiv_apply ℝ (EuclideanSpace.single i 1) simp only [Fin.sum_univ_three] change HasCompactSupport (partialDerivative (fun y => f y 0) 0 + partialDerivative (fun y => f y 1) 1 + partialDerivative (fun y => f y 2) 2) exact ((hpart 0).add (hpart 1)).add (hpart 2) /-- The ordinary curl commutes with the canonical vector-valued Laplacian. -/ theorem laplacian_vectorCurl (f : Space → Space) (hf : ContDiff ℝ ∞ f) : Δ (vectorCurl f) = vectorCurl (Δ f) := by have hc (i : Fin 3) : ContDiff ℝ ∞ (fun y => f y i) := (contDiff_piLp 2).mp hf i have heq (i : Fin 3) : (fun y => (Δ f y) i) = Δ (fun y => f y i) := funext fun y => vector_laplacian_coordinate f hf y i funext x ext i rw [vector_laplacian_coordinate _ (vectorCurl_smooth f hf)] change Δ (partialDerivative (fun y => f y (i+2)) (i+1) - partialDerivative (fun y => f y (i+1)) (i+2)) x = partialDerivative (fun y => (Δ f y) (i+2)) (i+1) x - partialDerivative (fun y => (Δ f y) (i+1)) (i+2) x rw [((contDiff_partialDerivative _ (hc (i+2)) (i+1)).of_le (by simp)).contDiffAt.laplacian_sub ((contDiff_partialDerivative _ (hc (i+1)) (i+2)).of_le (by simp)).contDiffAt] simp only [laplacian_partialDerivative _ (hc _), heq] end EulerMeanVectorIdentities