import Mathlib import OAI.Geometry.CubicTorus.Regularity.TranslateNormal namespace OAI section section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma volumeQuadratic_smulRight (l : Cover →L[ℝ] ℝ) (v : Cover) : volumeQuadratic (l.smulRight v)=0 := by have hc : (l.smulRight v).comp (l.smulRight v)=l v • l.smulRight v := by apply ContinuousLinearMap.ext intro x simp only [ContinuousLinearMap.comp_apply,ContinuousLinearMap.smulRight_apply, map_smul,smul_apply] module simp only [volumeQuadratic,hc,coverTrace_smulRight,coverTrace_smul] ring lemma normal_jet_acceleration_step (D L M K : Cover →L[ℝ] Cover) (n : Cover) (hM : cofactorQuadratic M n=0) : cofactorLinear D n+cofactorQuadratic L n+ 2 • (cofactorLinear K n+cofactorLinear M (cofactorLinear L n))= cofactorLinear (D+2 • (K+M.comp L)) n+cofactorQuadratic (L+M) n := by rw [cofactorQuadratic_add,hM] simp only [two_smul,cofactorLinear_add] module lemma mass_jet_acceleration_step (D L M K : Cover →L[ℝ] Cover) (hM : volumeQuadratic M=0) : coverTrace D+volumeQuadratic L+2*(coverTrace K+coverTrace L*coverTrace M)= coverTrace (D+2 • (K+M.comp L))+volumeQuadratic (L+M) := by rw [volumeQuadratic_add,hM] simp only [two_smul,coverTrace_add] ring lemma divergence_smooth {F : Cover → Cover} (hF : ContDiff ℝ (⊤ : ℕ∞) F) : ContDiff ℝ (⊤ : ℕ∞) (divergence F) := by have hd : ContDiff ℝ (⊤ : ℕ∞) (fderiv ℝ F) := hF.fderiv_right (by simp) exact coverTraceCLM.contDiff.comp hd lemma divergence_derivative {F : Cover → Cover} (hF : ContDiff ℝ (⊤ : ℕ∞) F) (x v : Cover) : fderiv ℝ (divergence F) x v=coverTrace (fderiv ℝ (fderiv ℝ F) x v) := by have hd : ContDiff ℝ (⊤ : ℕ∞) (fderiv ℝ F) := hF.fderiv_right (by simp) have he := (coverTraceCLM.hasFDerivAt.comp x (hd.differentiable (by simp) x).hasFDerivAt).fderiv change fderiv ℝ (fun y ↦ coverTraceCLM (fderiv ℝ F y)) x v=_ simp only [Function.comp_def] at he rw [he] rfl end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus namespace Periodic def chainAcceleration (l : List Variation) (x : Cover) : Cover := (motionJet l x).2 lemma chainAcceleration_smooth (l : List Variation) : ContDiff ℝ (⊤ : ℕ∞) (chainAcceleration l) := (motionJet_smooth l).snd lemma chainAcceleration_periodic (l : List Variation) (m : Fin 3 → ℤ) (x : Cover) : chainAcceleration l (x+latticeVector m)=chainAcceleration l x := by simp only [chainAcceleration,motionJet_periodic] lemma chainAcceleration_append (l : List Variation) (a : Variation) : chainAcceleration (l++[a])=fun x ↦ chainAcceleration l x+ 2 • fderiv ℝ (variationField a) x (chainVelocity l x) := by funext x simp only [chainAcceleration,motionJet_append,motionJet_first] lemma chainAcceleration_derivative_append (l : List Variation) (a : Variation) (x : Cover) : fderiv ℝ (chainAcceleration (l++[a])) x=fderiv ℝ (chainAcceleration l) x+ 2 • (fderiv ℝ (fderiv ℝ (variationField a)) x (chainVelocity l x)+ (fderiv ℝ (variationField a) x).comp (fderiv ℝ (chainVelocity l) x)) := by have hd : ContDiff ℝ (⊤ : ℕ∞) (fderiv ℝ (variationField a)) := (variationField_smooth a).fderiv_right (by simp) have ht := hd.clm_apply (chainVelocity_smooth l) have h2 : fderiv ℝ (fun y ↦ 2 • fderiv ℝ (variationField a) y (chainVelocity l y)) x= 2 • fderiv ℝ (fun y ↦ fderiv ℝ (variationField a) y (chainVelocity l y)) x := by simp only [two_smul] exact fderiv_fun_add (ht.differentiable (by simp) x) (ht.differentiable (by simp) x) rw [chainAcceleration_append,fderiv_fun_add ((chainAcceleration_smooth l).differentiable (by simp) x) ((ht.const_smul 2).differentiable (by simp) x), h2, derivative_transport (chainVelocity_smooth l) (variationField_smooth a)] lemma variation_normal_derivative (a : Variation) (x n u v : Cover) : fderiv ℝ (fun p : Cover×Cover ↦ coordinateNormalVelocity a.coordinate a.function p.1 p.2) (x,n) (u,v)=cofactorLinear (fderiv ℝ (fderiv ℝ (variationField a)) x u) n+ cofactorLinear (fderiv ℝ (variationField a) x) v := by have he : (fun p : Cover×Cover ↦ coordinateNormalVelocity a.coordinate a.function p.1 p.2)= (fun p : Cover×Cover ↦ cofactorLinear (fderiv ℝ (variationField a) p.1) p.2) := by funext p exact (cofactorLinear_coordinate (a.smooth.differentiable (by simp) p.1) a.coordinate p.2).symm rw [he,cofactor_field_derivative (variationField_smooth a)] lemma variation_cofactor_quadratic (a : Variation) (x n : Cover) : cofactorQuadratic (fderiv ℝ (variationField a) x) n=0 := by unfold variationField rw [fderiv_smul_const (a.smooth.differentiable (by simp) x)] exact cofactorQuadratic_smulRight _ _ _ theorem normalJet_second (l : List Variation) (x n : Cover) : (normalJet l x n).2.2=cofactorLinear (fderiv ℝ (chainAcceleration l) x) n+ cofactorQuadratic (fderiv ℝ (chainVelocity l) x) n := by induction l using List.reverseRecOn with | nil => change 0=cofactorLinear (fderiv ℝ (fun _ : Cover ↦ (0 : Cover)) x) n+ cofactorQuadratic (fderiv ℝ (fun _ : Cover ↦ (0 : Cover)) x) n simp [cofactorLinear,cofactorQuadratic] | append_singleton l a ih => rw [normalJet_append] dsimp only rw [ih,(normalJet_first l x n).1,(normalJet_first l x n).2, variation_normal_derivative,chainNormalVelocity_eq_cofactor, chainAcceleration_derivative_append,chainVelocity_append, fderiv_fun_add ((chainVelocity_smooth l).differentiable (by simp) x) ((variationField_smooth a).differentiable (by simp) x)] exact normal_jet_acceleration_step _ _ _ _ _ (variation_cofactor_quadratic a x n) lemma componentDivergence_eq (a : Variation) : componentDivergence a=divergence (variationField a) := by funext x exact (divergence_smul_const (a.smooth.differentiable (by simp) x) _).symm lemma variation_volume_quadratic (a : Variation) (x : Cover) : volumeQuadratic (fderiv ℝ (variationField a) x)=0 := by unfold variationField rw [fderiv_smul_const (a.smooth.differentiable (by simp) x)] exact volumeQuadratic_smulRight _ _ lemma massJet_divergence (l : List Variation) (x : Cover) : (massJet l x).2.1=coverTrace (fderiv ℝ (chainVelocity l) x) := by induction l using List.reverseRecOn with | nil => change 0=coverTrace (fderiv ℝ (fun _ : Cover ↦ (0 : Cover)) x) simp | append_singleton l a ih => rw [massJet_append] dsimp only rw [ih,componentDivergence_eq,chainVelocity_append, fderiv_fun_add ((chainVelocity_smooth l).differentiable (by simp) x) ((variationField_smooth a).differentiable (by simp) x),coverTrace_add] rfl theorem massJet_second (l : List Variation) (x : Cover) : (massJet l x).2.2=coverTrace (fderiv ℝ (chainAcceleration l) x)+ volumeQuadratic (fderiv ℝ (chainVelocity l) x) := by induction l using List.reverseRecOn with | nil => change 0=coverTrace (fderiv ℝ (fun _ : Cover ↦ (0 : Cover)) x)+ volumeQuadratic (fderiv ℝ (fun _ : Cover ↦ (0 : Cover)) x) simp [volumeQuadratic] | append_singleton l a ih => rw [massJet_append] dsimp only rw [ih,massJet_first,massJet_divergence,componentDivergence_eq, divergence_derivative (variationField_smooth a),divergence_eq_coverTrace, chainAcceleration_derivative_append,chainVelocity_append, fderiv_fun_add ((chainVelocity_smooth l).differentiable (by simp) x) ((variationField_smooth a).differentiable (by simp) x)] exact mass_jet_acceleration_step _ _ _ _ (variation_volume_quadratic a x) end Periodic end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus def ambientAreaQuadratic (L : Cover →L[ℝ] Cover) (n : Cover) : ℝ := ‖cofactorLinear L n‖^2-⟪n,cofactorLinear L n⟫^2+⟪n,cofactorQuadratic L n⟫ def ambientQuadratic (E : Set Torus) (μ : FiniteMeasure NormalBundle) (H : ℝ) (F : Cover → Cover) : ℝ := (∫ z,ambientAreaQuadratic (fderiv ℝ F z.1) z.2 ∂(μ : Measure NormalBundle))- H*(∫ x in fundamentalCube∩quotientMap ⁻¹' E,volumeQuadratic (fderiv ℝ F x)) lemma volumeQuadratic_continuous : Continuous volumeQuadratic := by exact (coverTraceCLM.continuous.pow 2).sub (coverTraceCLM.continuous.comp (continuous_id.clm_comp continuous_id)) lemma cofactorQuadratic_continuous : Continuous (fun p : (Cover →L[ℝ] Cover)×Cover ↦ cofactorQuadratic p.1 p.2) := by have ht : Continuous (fun p : (Cover →L[ℝ] Cover)×Cover ↦ coverTrace p.1) := coverTraceCLM.continuous.comp continuous_fst have ha : Continuous (fun p : (Cover →L[ℝ] Cover)×Cover ↦ p.1.adjoint) := ContinuousLinearMap.adjoint.continuous.comp continuous_fst exact (((volumeQuadratic_continuous.comp continuous_fst).smul continuous_snd).sub ((continuous_const.mul ht).smul (ha.clm_apply continuous_snd))).add ((ha.clm_apply (ha.clm_apply continuous_snd)).const_smul 2) lemma ambientAreaQuadratic_continuous : Continuous (fun p : (Cover →L[ℝ] Cover)×Cover ↦ ambientAreaQuadratic p.1 p.2) := by have hc : Continuous (fun p : (Cover →L[ℝ] Cover)×Cover ↦ cofactorLinear p.1 p.2) := (cofactorOperator.continuous.comp continuous_fst).clm_apply continuous_snd exact ((hc.norm.pow 2).sub ((continuous_snd.inner hc).pow 2)).add (continuous_snd.inner cofactorQuadratic_continuous) lemma ambientAreaQuadratic_integrable (μ : FiniteMeasure NormalBundle) {F : Cover → Cover} (hF : ContDiff ℝ (⊤ : ℕ∞) F) : Integrable (fun z : NormalBundle ↦ ambientAreaQuadratic (fderiv ℝ F z.1) z.2) (μ : Measure NormalBundle) := by exact (ambientAreaQuadratic_continuous.comp (((hF.continuous_fderiv (by simp)).comp normalEmbedding_continuous.fst).prodMk continuous_normalUnit)).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) lemma cube_integrable_continuous (E : Set Torus) {f : Cover → ℝ} (hf : Continuous f) : IntegrableOn f (fundamentalCube∩quotientMap ⁻¹' E) := integrable_of_continuous_compact_carrier isCompact_closedFundamentalCube (cubeIntersection_compact_carrier E) hf lemma periodic_normal_flux {E : Set Torus} {μ : FiniteMeasure NormalBundle} (hμ : IsNormalMeasure E μ) {F : Cover → Cover} (hF : ContDiff ℝ (⊤ : ℕ∞) F) (hp : ∀ m x,F (x+latticeVector m)=F x) : (∫ z,⟪(z.2 : Cover),F z.1⟫ ∂(μ : Measure NormalBundle))= ∫ x in fundamentalCube∩quotientMap ⁻¹' E,divergence F x := by obtain ⟨C,_,hb⟩ := periodic_bounded hF.continuous hp have hc : 0