import Mathlib import OAI.Geometry.BallPacking.Moser.SmoothManifoldIntegral import OAI.Geometry.BallPacking.RelativeJets.SymplecticProjectionNaturality namespace OAI noncomputable section namespace PackingSufficiencySupport.Hamiltonian section open scoped ContDiff Manifold Topology open Set Function Manifold variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {M N : Type*} [TopologicalSpace M] [ChartedSpace E M] [TopologicalSpace N] [ChartedSpace F N] theorem embedding_adapted_neighborhood {e : N β†’ M} (he : IsSmoothEmbedding π“˜(ℝ,F) π“˜(ℝ,E) ∞ e) (a : N) : let h := he.isImmersion.isImmersionAt a βˆƒ U : Set M, IsOpen U ∧ e a ∈ U ∧ U βŠ† h.codChart.source ∧ βˆ€ b : N, e b ∈ U β†’ b ∈ h.domChart.source ∧ h.equiv.symm ((h.codChart.extend π“˜(ℝ,E)) (e b)) = ((h.domChart.extend π“˜(ℝ,F)) b,0) := by let h := he.isImmersion.isImmersionAt a obtain ⟨V,hV,hpre⟩ := he.isEmbedding.isInducing.isOpen_iff.mp h.domChart.open_source refine ⟨V ∩ h.codChart.source,hV.inter h.codChart.open_source,?_,inter_subset_right,?_⟩ Β· constructor Β· have ha := h.mem_domChart_source rw [←hpre] at ha exact ha Β· exact h.mem_codChart_source Β· intro b hb have hb' : b ∈ h.domChart.source := by rw [←hpre]; exact hb.1 refine ⟨hb',?_⟩ have hz : b ∈ (h.domChart.extend π“˜(ℝ,F)).source := by simpa only [OpenPartialHomeomorph.extend_source] using hb' have hh := h.writtenInCharts ((h.domChart.extend π“˜(ℝ,F)).map_source hz) simp only [Function.comp_apply,(h.domChart.extend π“˜(ℝ,F)).left_inv hz] at hh rw [hh,h.equiv.symm_apply_apply] end section open scoped ContDiff Manifold Topology open Set Function Manifold IsManifold variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {M N : Type*} [TopologicalSpace M] [ChartedSpace E M] [IsManifold π“˜(ℝ,E) ∞ M] [TopologicalSpace N] [ChartedSpace F N] [IsManifold π“˜(ℝ,F) ∞ N] omit [IsManifold π“˜(ℝ,F) ∞ N] in theorem exists_relative_jet_patch {Ξ© : ℝ β†’ ManifoldTwoForm E M} {Ξ± : ℝ β†’ ManifoldOneForm E M} {e : N β†’ M} (hΞ© : βˆ€ c, ContDiffOn ℝ ∞ (fun q : ℝ Γ— E => chartTwoForm (Ξ© q.1) c q.2) (univ Γ—Λ’ (extChartAt π“˜(ℝ,E) c).target)) (hΞ± : βˆ€ c, ContDiffOn ℝ ∞ (fun q : ℝ Γ— E => chartOneForm (Ξ± q.1) c q.2) (univ Γ—Λ’ (extChartAt π“˜(ℝ,E) c).target)) (he : IsSmoothEmbedding π“˜(ℝ,F) π“˜(ℝ,E) ∞ e) {T : Set ℝ} (hi : βˆ€ t ∈ T, βˆ€ b, ((Ξ© t (e b)).bilinearComp (manifoldMapDifferential (E := E) (F := F) e b) (manifoldMapDifferential (E := E) (F := F) e b)).IsInvertible) (a : N) : βˆƒ U : Set (ℝ Γ— M), βˆƒ f : ℝ Γ— M β†’ ℝ, IsOpen U ∧ (βˆ€ t ∈ T, (t,e a) ∈ U) ∧ ContMDiffOn ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) ∞ f U ∧ βˆ€ t ∈ T, βˆ€ b, (t,e b) ∈ U β†’ f (t,e b) = 0 ∧ HasMFDerivAt ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) f (t,e b) ((symplecticNormalJet (Ξ© t (e b)) (manifoldMapDifferential (E := E) (F := F) e b) (Ξ± t (e b))).comp (ContinuousLinearMap.snd ℝ ℝ E)) := by let h := he.isImmersion.isImmersionAt a obtain ⟨V,hV,ha,hVd,hVb⟩ := embedding_adapted_neighborhood he a have hw : EqOn (h.codChart ∘ e ∘ h.domChart.symm) (fun y => h.equiv (y,0)) h.domChart.target := by simpa only [Function.comp_def, mfld_simps] using h.writtenInCharts let U := relativeLocalDomain Ξ© h.codChart h.equiv ∩ (univ Γ—Λ’ V) refine ⟨U,relativeLocalPotential Ξ© Ξ± h.codChart h.equiv,?_,?_,?_,?_⟩ Β· exact (relativeLocalDomain_isOpen hΞ© h.codChart_mem_maximalAtlas h.equiv).inter (isOpen_univ.prod hV) Β· intro t ht exact ⟨relativeLocalDomain_mem Ξ© h.domChart_mem_maximalAtlas h.codChart_mem_maximalAtlas h.equiv hw h.mem_domChart_source h.mem_codChart_source (he.contMDiff.mdifferentiable (by simp) a) (hi t ht a),mem_univ _,ha⟩ Β· exact (relativeLocalPotential_contMDiffOn hΞ© hΞ± h.codChart_mem_maximalAtlas h.equiv).mono inter_subset_left Β· intro t ht b hb have hbb := hVb b hb.2.2 have hbd := hVd hb.2.2 constructor Β· apply localSymplecticPotential_zero simpa using congrArg Prod.snd hbb.2 Β· exact relativeLocalPotential_hasMFDerivAt hΞ© hΞ± h.domChart_mem_maximalAtlas h.codChart_mem_maximalAtlas h.equiv hw hbb.1 hbd (he.contMDiff.mdifferentiable (by simp) b) (hi t ht b) end section open scoped ContDiff Manifold Topology open Set Function Manifold variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [IsManifold I ∞ M] {ΞΉ : Type} omit [IsManifold I ∞ M] in theorem smoothPartition_eventually_finite_sum {S : Set M} (ρ : SmoothPartitionOfUnity ΞΉ I M S) (g : ΞΉ β†’ M β†’ ℝ) (x : M) : (fun y => βˆ‘αΆ  i, ρ i y β€’ g i y) =αΆ [𝓝 x] (fun y => βˆ‘ i ∈ ρ.fintsupport x, ρ i y β€’ g i y) := by classical filter_upwards [ρ.eventually_finsupport_subset x] with y hy rw [←ρ.sum_finsupport_smul_eq_finsum y g] apply Finset.sum_subset hy intro i hi hni have hz : ρ i y = 0 := by simpa only [ρ.mem_finsupport,mem_support,not_not] using hni rw [hz,zero_smul] omit [IsManifold I ∞ M] in theorem smoothPartition_glues_zero_first_jet {S : Set M} (ρ : SmoothPartitionOfUnity ΞΉ I M S) {U : ΞΉ β†’ Set M} (hρ : ρ.IsSubordinate U) {g : ΞΉ β†’ M β†’ ℝ} {Ξ² : (x : M) β†’ TangentSpace I x β†’L[ℝ] ℝ} (hzero : βˆ€ i x, x ∈ S β†’ x ∈ U i β†’ g i x = 0) (hjet : βˆ€ i x, x ∈ S β†’ x ∈ U i β†’ HasMFDerivAt I π“˜(ℝ,ℝ) (g i) x (Ξ² x)) (x : M) (hx : x ∈ S) : (βˆ‘αΆ  i, ρ i x β€’ g i x) = 0 ∧ HasMFDerivAt I π“˜(ℝ,ℝ) (fun y => βˆ‘αΆ  i, ρ i y β€’ g i y) x (Ξ² x) := by classical have hloc := smoothPartition_eventually_finite_sum ρ g x have hmem (i : ΞΉ) (hi : i ∈ ρ.fintsupport x) : x ∈ U i := hρ i ((ρ.mem_fintsupport_iff x i).1 hi) constructor Β· rw [hloc.eq_of_nhds] apply Finset.sum_eq_zero intro i hi rw [hzero i x hx (hmem i hi),smul_zero] Β· have hd (i : ΞΉ) (hi : i ∈ ρ.fintsupport x) : HasMFDerivAt I π“˜(ℝ,ℝ) (fun y => ρ i y β€’ g i y) x (ρ i x β€’ Ξ² x) := by have hp := ((ρ i).contMDiff.mdifferentiable (by simp) x).hasMFDerivAt refine (hp.mul (hjet i x hx (hmem i hi))).congr_mfderiv ?_ let A : TangentSpace I x β†’L[ℝ] ℝ := mfderiv I π“˜(ℝ,ℝ) (ρ i) x change ρ i x β€’ Ξ² x + g i x β€’ A = ρ i x β€’ Ξ² x rw [hzero i x hx (hmem i hi), zero_smul, add_zero] have hsum := HasMFDerivAt.sum (I := I) (t := ρ.fintsupport x) (f := fun i y => ρ i y β€’ g i y) (f' := fun i => ρ i x β€’ Ξ² x) hd have hweights : (βˆ‘ i ∈ ρ.fintsupport x, ρ i x β€’ Ξ² x) = Ξ² x := by rw [←Finset.sum_smul,ρ.sum_finsupport' x hx (ρ.finsupport_subset_fintsupport x),one_smul] rw [hweights] at hsum exact hsum.congr_of_eventuallyEq (by filter_upwards [hloc] with y hy simpa only [Finset.sum_apply] using hy) variable [FiniteDimensional ℝ E] [T2Space M] [SigmaCompactSpace M] theorem exists_smooth_zero_first_jet {S : Set M} (hS : IsClosed S) {U : ΞΉ β†’ Set M} (hU : βˆ€ i, IsOpen (U i)) (hcover : S βŠ† ⋃ i, U i) {g : ΞΉ β†’ M β†’ ℝ} (hg : βˆ€ i, ContMDiffOn I π“˜(ℝ,ℝ) ∞ (g i) (U i)) {Ξ² : (x : M) β†’ TangentSpace I x β†’L[ℝ] ℝ} (hzero : βˆ€ i x, x ∈ S β†’ x ∈ U i β†’ g i x = 0) (hjet : βˆ€ i x, x ∈ S β†’ x ∈ U i β†’ HasMFDerivAt I π“˜(ℝ,ℝ) (g i) x (Ξ² x)) : βˆƒ f : M β†’ ℝ, ContMDiff I π“˜(ℝ,ℝ) ∞ f ∧ βˆ€ x ∈ S, f x = 0 ∧ HasMFDerivAt I π“˜(ℝ,ℝ) f x (Ξ² x) := by obtain ⟨ρ,hρ⟩ := SmoothPartitionOfUnity.exists_isSubordinate I hS U hU hcover exact ⟨_,hρ.contMDiff_finsum_smul hU hg, fun x hx => smoothPartition_glues_zero_first_jet ρ hρ hzero hjet x hx⟩ end section open scoped ContDiff Manifold Topology open Set Function Manifold IsManifold variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {M : Type*} {N : Type} [TopologicalSpace M] [ChartedSpace E M] [IsManifold π“˜(ℝ,E) ∞ M] [TopologicalSpace N] [ChartedSpace F N] [IsManifold π“˜(ℝ,F) ∞ N] def embeddedNormalJet (Ξ© : ℝ β†’ ManifoldTwoForm E M) (Ξ± : ℝ β†’ ManifoldOneForm E M) (e : N β†’ M) (p : ℝ Γ— M) : (ℝ Γ— E) β†’L[ℝ] ℝ := by classical exact if h : βˆƒ b, e b = p.2 then (symplecticNormalJet (Ξ© p.1 p.2) (manifoldMapDifferential (E := E) (F := F) e h.choose) (Ξ± p.1 p.2)).comp (ContinuousLinearMap.snd ℝ ℝ E) else 0 omit [IsManifold π“˜(ℝ,E) ∞ M] [IsManifold π“˜(ℝ,F) ∞ N] in theorem embeddedNormalJet_apply (Ξ© : ℝ β†’ ManifoldTwoForm E M) (Ξ± : ℝ β†’ ManifoldOneForm E M) {e : N β†’ M} (he : Injective e) (t : ℝ) (b : N) : embeddedNormalJet (F := F) Ξ© Ξ± e (t,e b) = (symplecticNormalJet (Ξ© t (e b)) (manifoldMapDifferential (E := E) (F := F) e b) (Ξ± t (e b))).comp (ContinuousLinearMap.snd ℝ ℝ E) := by classical have hx : βˆƒ a, e a = (t,e b).2 := ⟨b,rfl⟩ have hy : hx.choose = b := he hx.choose_spec simp only [embeddedNormalJet,dite_eq_left hx,hy] variable [CompleteSpace F] [FiniteDimensional ℝ E] [T2Space M] [SigmaCompactSpace M] omit [IsManifold π“˜(ℝ,F) ∞ N] in theorem exists_relative_global_potential {Ξ© : ℝ β†’ ManifoldTwoForm E M} {Ξ± : ℝ β†’ ManifoldOneForm E M} {e : N β†’ M} (hΞ© : βˆ€ c, ContDiffOn ℝ ∞ (fun q : ℝ Γ— E => chartTwoForm (Ξ© q.1) c q.2) (univ Γ—Λ’ (extChartAt π“˜(ℝ,E) c).target)) (hΞ± : βˆ€ c, ContDiffOn ℝ ∞ (fun q : ℝ Γ— E => chartOneForm (Ξ± q.1) c q.2) (univ Γ—Λ’ (extChartAt π“˜(ℝ,E) c).target)) (he : IsSmoothEmbedding π“˜(ℝ,F) π“˜(ℝ,E) ∞ e) (hclosed : IsClosed (range e)) {T : Set ℝ} (hT : IsClosed T) (hi : βˆ€ t ∈ T, βˆ€ b, ((Ξ© t (e b)).bilinearComp (manifoldMapDifferential (E := E) (F := F) e b) (manifoldMapDifferential (E := E) (F := F) e b)).IsInvertible) : βˆƒ f : ℝ Γ— M β†’ ℝ, ContMDiff ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) ∞ f ∧ βˆ€ t ∈ T, βˆ€ b, f (t,e b) = 0 ∧ HasMFDerivAt ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) f (t,e b) ((symplecticNormalJet (Ξ© t (e b)) (manifoldMapDifferential (E := E) (F := F) e b) (Ξ± t (e b))).comp (ContinuousLinearMap.snd ℝ ℝ E)) := by classical choose U g hU hcover hg hjet using exists_relative_jet_patch hΞ© hΞ± he hi have hcov : (T Γ—Λ’ range e) βŠ† ⋃ a, U a := by rintro ⟨t,x⟩ ⟨ht,b,rfl⟩ exact mem_iUnion.mpr ⟨b,hcover b t ht⟩ obtain ⟨f,hf,hfjet⟩ := exists_smooth_zero_first_jet (I := (π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) (Ξ² := embeddedNormalJet (F := F) Ξ© Ξ± e) (hT.prod hclosed) hU hcov hg (by rintro a ⟨t,x⟩ ⟨ht,b,rfl⟩ hp exact (hjet a t ht b hp).1) (by rintro a ⟨t,x⟩ ⟨ht,b,rfl⟩ hp rw [embeddedNormalJet_apply Ξ© Ξ± he.isEmbedding.injective] exact (hjet a t ht b hp).2) refine ⟨f,hf,?_⟩ intro t ht b have h := hfjet (t,e b) ⟨ht,mem_range_self b⟩ rw [embeddedNormalJet_apply Ξ© Ξ± he.isEmbedding.injective] at h exact h end section open scoped ContDiff Manifold Topology open Set Function Manifold variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {M : Type*} [TopologicalSpace M] [ChartedSpace E M] [IsManifold π“˜(ℝ,E) ∞ M] def correctedOneForm (Ξ± : ℝ β†’ ManifoldOneForm E M) (f : ℝ Γ— M β†’ ℝ) (t : ℝ) (x : M) : E β†’L[ℝ] ℝ := Ξ± t x + manifoldSpatialDifferential f t x theorem chartOneForm_corrected {Ξ± : ℝ β†’ ManifoldOneForm E M} {f : ℝ Γ— M β†’ ℝ} (hf : ContMDiff ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) ∞ f) {c : M} {p : ℝ Γ— E} (hp : p.2 ∈ (extChartAt π“˜(ℝ,E) c).target) : chartOneForm (correctedOneForm Ξ± f p.1) c p.2 = chartOneForm (Ξ± p.1) c p.2 + spatialDifferential (manifoldPotentialChart f c) p := by rw [←chartOneForm_manifoldSpatialDifferential hf hp] exact ContinuousLinearMap.add_comp _ _ _ theorem ManifoldMoserData.corrected {Ξ© : ℝ β†’ ManifoldTwoForm E M} {Ξ± : ℝ β†’ ManifoldOneForm E M} (h : ManifoldMoserData Ξ© Ξ±) {f : ℝ Γ— M β†’ ℝ} (hf : ContMDiff ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) ∞ f) : ManifoldMoserData Ξ© (correctedOneForm Ξ± f) := by have he (c : M) (p : ℝ Γ— E) (hp : p.2 ∈ (extChartAt π“˜(ℝ,E) c).target) : (fun q : ℝ Γ— E => chartOneForm (correctedOneForm Ξ± f q.1) c q.2) =αΆ [𝓝 p] (fun q => chartOneForm (Ξ± q.1) c q.2 + spatialDifferential (manifoldPotentialChart f c) q) := by have ht := continuousAt_snd.preimage_mem_nhds ((isOpen_extChartAt_target (I := π“˜(ℝ,E)) c).mem_nhds hp) filter_upwards [ht] with q hq exact chartOneForm_corrected hf hq have hs (c : M) (p : ℝ Γ— E) (hp : p.2 ∈ (extChartAt π“˜(ℝ,E) c).target) : ContDiffAt ℝ ∞ (fun q : ℝ Γ— E => chartOneForm (Ξ± q.1) c q.2) p := (h.smooth_one c).contDiffAt ((isOpen_univ.prod (isOpen_extChartAt_target (I := π“˜(ℝ,E)) c)).mem_nhds ⟨mem_univ _,hp⟩) refine ⟨h.smooth_two,?_,h.nondegenerate,h.skew,h.closed,?_⟩ Β· intro c p hp exact (((hs c p hp.2).add (spatialDifferential_contDiffAt (manifoldPotentialChart_contDiffAt hf hp.2))).congr_of_eventuallyEq (he c p hp.2)).contDiffWithinAt Β· intro t ht c y hy v w have hd := (he c (t,y) hy).fderiv_eq (π•œ := ℝ) rw [hd] have ha := fderiv_add ((hs c (t,y) hy).differentiableAt (by simp)) ((spatialDifferential_contDiffAt (manifoldPotentialChart_contDiffAt hf hy)).differentiableAt (by simp)) change fderiv ℝ (fun q : ℝ Γ— E => chartOneForm (Ξ± q.1) c q.2 + spatialDifferential (manifoldPotentialChart f c) q) (t,y) = _ at ha rw [ha] simp only [add_apply] have hz := spatialDifferential_closedAt (manifoldPotentialChart_contDiffAt hf (p := (t,y)) hy) v w have ho := h.exact_time t ht c y hy v w linarith end open scoped ContDiff Manifold Topology open Set Function Manifold variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {M N : Type*} [TopologicalSpace M] [ChartedSpace E M] [IsManifold π“˜(ℝ,E) ∞ M] [TopologicalSpace N] [ChartedSpace F N] omit [IsManifold π“˜(ℝ,E) ∞ M] in theorem manifoldSpatialDifferential_of_jet {f : ℝ Γ— M β†’ ℝ} {t : ℝ} {x : M} {Ξ² : E β†’L[ℝ] ℝ} (hf : HasMFDerivAt ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) f (t,x) (Ξ².comp (ContinuousLinearMap.snd ℝ ℝ E))) : manifoldSpatialDifferential f t x = Ξ² := by have hc : HasMFDerivAt π“˜(ℝ,E) ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) (fun z : M => (t,z)) x (ContinuousLinearMap.inr ℝ ℝ E) := by convert! (hasMFDerivAt_const (I := π“˜(ℝ,E)) (I' := π“˜(ℝ,ℝ)) t x).prodMk (hasMFDerivAt_id (I := π“˜(ℝ,E)) x) using 1 have h := (hf.comp x hc).mfderiv change mfderiv π“˜(ℝ,E) π“˜(ℝ,ℝ) (f ∘ fun z => (t,z)) x = Ξ² rw [h] ext v rfl theorem ManifoldMoserData.skew_intrinsic {Ξ© : ℝ β†’ ManifoldTwoForm E M} {Ξ± : ℝ β†’ ManifoldOneForm E M} (h : ManifoldMoserData Ξ© Ξ±) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (x : M) (u v : E) : Ξ© t x u v = -Ξ© t x v u := by have hx : x ∈ (extChartAt π“˜(ℝ,E) x).source := mem_extChartAt_source x have hs := h.skew t ht x _ (mem_extChartAt_target x) (chartDifferential x x u) (chartDifferential x x v) have h1 := chartTwoForm_apply_chart (Ξ© := Ξ© t) hx u v have h2 := chartTwoForm_apply_chart (Ξ© := Ξ© t) hx v u exact h1.symm.trans (hs.trans (congrArg (fun r : ℝ => -r) h2)) theorem relative_moser_field_related {Ξ© : ℝ β†’ ManifoldTwoForm E M} {Ξ± : ℝ β†’ ManifoldOneForm E M} {e : N β†’ M} {f : ℝ Γ— M β†’ ℝ} (h : ManifoldMoserData Ξ© Ξ±) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (b : N) (hi : (manifoldPullbackTwoForm (F := F) Ξ© e t b).IsInvertible) (hf : HasMFDerivAt ((π“˜(ℝ,ℝ)).prod π“˜(ℝ,E)) π“˜(ℝ,ℝ) f (t,e b) ((symplecticNormalJet (Ξ© t (e b)) (manifoldMapDifferential (E := E) (F := F) e b) (Ξ± t (e b))).comp (ContinuousLinearMap.snd ℝ ℝ E))) : manifoldMapDifferential (E := E) (F := F) e b (manifoldMoserField (manifoldPullbackTwoForm (F := F) Ξ© e) (manifoldPullbackOneForm (F := F) Ξ± e) (t,b)) = manifoldMoserField Ξ© (correctedOneForm Ξ± f) (t,e b) := by dsimp only [manifoldMoserField,correctedOneForm] rw [manifoldSpatialDifferential_of_jet hf] exact (corrected_moser_vector_tangent (h.nondegenerate t ht (e b)) hi (h.skew_intrinsic ht (e b)) (Ξ± t (e b))).symm end PackingSufficiencySupport.Hamiltonian end end OAI