import Mathlib import OAI.Geometry.CubicTorus.Profiles.FirstSeamFunction namespace OAI section section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus def firstAxisShift (t : ℝ) : Cover := t • EuclideanSpace.single 0 1 def firstHalfMass (E : Set Torus) (t : ℝ) : ℝ := ∫ z in E,characteristic (sublevelRegion firstSeamFunction 0) (z+quotientMap (firstAxisShift t)) ∂torusVolume lemma integrable_shifted_characteristic {A : Set Torus} (hA : MeasurableSet A) (a : Torus) : Integrable (fun z ↦ characteristic A (z+a)) torusVolume := Integrable.of_bound ((measurable_characteristic hA).comp (measurable_id.add_const a)).aestronglyMeasurable 1 (Eventually.of_forall fun z ↦ by simpa only [Real.norm_eq_abs] using characteristic_bound A (z+a)) lemma firstHalfMass_lipschitz {E : Set Torus} (hE : MeasurableSet E) (hP : perimeter E≠⊤) : LipschitzWith ⟨(perimeter E).toReal,ENNReal.toReal_nonneg⟩ (firstHalfMass E) := by apply LipschitzWith.of_dist_le_mul intro t s rw [Real.dist_eq,Real.dist_eq] have hB := measurableSet_sublevelRegion firstSeamFunction_contDiff.continuous.measurable 0 let g : Torus → ℝ := fun z ↦ characteristic (sublevelRegion firstSeamFunction 0) (z+quotientMap (firstAxisShift s)) have hg : Measurable g := (measurable_characteristic hB).comp (measurable_id.add_const _) have hb : ∀ z,|g z|≤1 := fun z ↦ characteristic_bound _ _ have hh := torus_test_translation_bound hE hP hg hb (firstAxisShift t-firstAxisShift s) have he (z : Torus) : g (z+quotientMap (firstAxisShift t-firstAxisShift s))= characteristic (sublevelRegion firstSeamFunction 0) (z+quotientMap (firstAxisShift t)) := by dsimp [g] rw [quotientMap_sub] congr 1 abel simp_rw [he] at hh rw [integral_sub (integrable_shifted_characteristic hB _).integrableOn (integrable_shifted_characteristic hB _).integrableOn] at hh have he2 : ‖firstAxisShift t-firstAxisShift s‖=|t-s| := by rw [firstAxisShift,firstAxisShift,← sub_smul,norm_smul,Real.norm_eq_abs] simp rw [he2] at hh change |firstHalfMass E t-firstHalfMass E s|≤(perimeter E).toReal*|t-s| change |firstHalfMass E t-firstHalfMass E s|≤|t-s| * (perimeter E).toReal at hh simpa only [mul_comm] using hh lemma firstSeam_shift_half (z : Torus) : firstSeamFunction (representative (z+quotientMap (firstAxisShift (1/2))))= -firstSeamFunction (representative z) := by rw [← quotientMap_representative z,← quotientMap_add, periodic_representative firstSeamFunction_periodic, periodic_representative firstSeamFunction_periodic] unfold firstSeamFunction firstAxisShift simp only [PiLp.add_apply,PiLp.smul_apply,PiLp.single_apply,ite_true,smul_eq_mul,mul_one] convert Real.sin_add_pi (2*Real.pi*representative z 0) using 1 congr 1 ring lemma firstHalfMass_pair (E : Set Torus) : firstHalfMass E 0+firstHalfMass E (1/2)=(torusVolume E).toReal := by have hB := measurableSet_sublevelRegion firstSeamFunction_contDiff.continuous.measurable 0 have hi0 := (integrable_shifted_characteristic hB (quotientMap (firstAxisShift 0))).integrableOn (s := E) have hi1 := (integrable_shifted_characteristic hB (quotientMap (firstAxisShift (1/2)))).integrableOn (s := E) rw [firstHalfMass,firstHalfMass,← integral_add hi0 hi1] have he : ∀ᵐ z ∂torusVolume, characteristic (sublevelRegion firstSeamFunction 0) (z+quotientMap (firstAxisShift 0))+ characteristic (sublevelRegion firstSeamFunction 0) (z+quotientMap (firstAxisShift (1/2)))=1 := by have hn : ∀ᵐ z ∂torusVolume,firstSeamFunction (representative z)≠0 := by simpa only [ae_iff,not_not] using firstSeam_null filter_upwards [hn] with z hz have hz0 : quotientMap (firstAxisShift 0)=0 := by ext i; simp [firstAxisShift,quotientMap] rw [hz0,add_zero] have he := firstSeam_shift_half z classical rcases lt_or_gt_of_ne hz with hneg | hpos · have hm : z∈sublevelRegion firstSeamFunction 0 := hneg have hnm : z+quotientMap (firstAxisShift (1/2))∉sublevelRegion firstSeamFunction 0 := by change ¬firstSeamFunction (representative (z+quotientMap (firstAxisShift (1/2))))<0 rw [he]; linarith simp only [characteristic,indicator_of_mem hm,indicator_of_notMem hnm,add_zero] · have hnm : z∉sublevelRegion firstSeamFunction 0 := not_lt.mpr hpos.le have hm : z+quotientMap (firstAxisShift (1/2))∈sublevelRegion firstSeamFunction 0 := by change firstSeamFunction (representative (z+quotientMap (firstAxisShift (1/2))))<0 rw [he]; linarith simp only [characteristic,indicator_of_mem hm,indicator_of_notMem hnm,zero_add] rw [integral_congr_ae (ae_restrict_of_ae he),setIntegral_const] simp [Measure.real_def] lemma firstHalfMass_eq_volume {E : Set Torus} (hE : MeasurableSet E) (t : ℝ) : firstHalfMass E t=(torusVolume (((fun z ↦ z-quotientMap (firstAxisShift t)) ⁻¹' E)∩sublevelRegion firstSeamFunction 0)).toReal := by let a := quotientMap (firstAxisShift t) let E' := (fun z : Torus ↦ z-a) ⁻¹' E have hE' : MeasurableSet E' := hE.preimage (measurable_id.sub_const a) have hB := measurableSet_sublevelRegion firstSeamFunction_contDiff.continuous.measurable 0 have he : E=(fun z : Torus ↦ z+a) ⁻¹' E' := by ext z; simp [E'] unfold firstHalfMass change (∫ z in E,characteristic (sublevelRegion firstSeamFunction 0) (z+a) ∂torusVolume)=_ conv_lhs => rw [he] rw [(measurePreserving_add_right torusVolume a).setIntegral_preimage_emb (Homeomorph.addRight a).measurableEmbedding] change (∫ z in E',characteristic (sublevelRegion firstSeamFunction 0) z ∂torusVolume)=_ change (∫ z in E',(sublevelRegion firstSeamFunction 0).indicator (fun _ ↦ (1:ℝ)) z ∂torusVolume)=_ rw [integral_indicator hB,Measure.restrict_restrict hB,setIntegral_const] simp only [smul_eq_mul,mul_one,Measure.real_def] rw [inter_comm] theorem exists_first_half_bisection {E : Set Torus} (hE : MeasurableSet E) (hP : perimeter E≠⊤) : ∃ a : Torus,(torusVolume (((fun z ↦ z+a) ⁻¹' E)∩sublevelRegion firstSeamFunction 0)).toReal= (torusVolume E).toReal/2 := by have hc := (firstHalfMass_lipschitz hE hP).continuous have hv := firstHalfMass_pair E have hr : (torusVolume E).toReal/2∈Set.range (firstHalfMass E) := by by_cases h : firstHalfMass E 0≤(torusVolume E).toReal/2 · exact intermediate_value_univ 0 (1/2) hc ⟨h,by linarith⟩ · exact intermediate_value_univ (1/2) 0 hc ⟨by linarith,by linarith⟩ obtain ⟨t,ht⟩ := hr refine ⟨-quotientMap (firstAxisShift t),?_⟩ simpa only [firstHalfMass_eq_volume hE,sub_eq_add_neg] using ht theorem exists_bisected_reflection_minimizers {V : ℝ} {E : Set Torus} (hE : MeasurableSet E) (hmin : IsMinimizerAt V E) : ∃ a : Torus,let E' := (fun z ↦ z+a) ⁻¹' E IsMinimizerAt V (reflectionClosure (E'∩sublevelRegion firstSeamFunction 0)) ∧ IsMinimizerAt V (reflectionClosure (E'\sublevelRegion firstSeamFunction 0)) := by obtain ⟨a,ha⟩ := exists_first_half_bisection hE hmin.1.2.ne refine ⟨a,bisected_reflection_minimizers (hE.preimage (measurable_id.add_const a)) (isMinimizerAt_translation hmin a) ?_⟩ rw [volume_translation hE.nullMeasurableSet] exact ha end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma firstSeam_sign {t : ℝ} (ht : t∈Ico (0:ℝ) 1) : Real.sin (2*Real.pi*t)<0 ↔ (1/2:ℝ)] (0 : ℝ)] fun t ↦ c*f t) (hminus : ∀ᶠ t in 𝓝[<] (0 : ℝ),f t<0 → g t=0) : False := by have hleft : g=ᶠ[𝓝[<] (0 : ℝ)] fun _ ↦ (0 : ℝ) := by filter_upwards [positive_derivative_negative_on_left hf hd hf0,hminus] with t ht hm exact hm ht have hl : Tendsto (fun t : ℝ ↦ t⁻¹*(g t-g 0)) (𝓝[<] 0) (𝓝 (0 : ℝ)) := by apply tendsto_const_nhds.congr' filter_upwards [hleft] with t ht simp only [ht,hg0,sub_self,mul_zero] have hgl : Tendsto (fun t : ℝ ↦ t⁻¹*(g t-g 0)) (𝓝[<] 0) (𝓝 (deriv g 0)) := by simpa only [zero_add,smul_eq_mul] using hg.hasDerivAt.tendsto_slope_zero_left have hdz : deriv g 0=0 := tendsto_nhds_unique hgl hl have hgradR : Tendsto (fun t : ℝ ↦ t⁻¹*(g t-g 0)) (𝓝[>] 0) (𝓝 (deriv g 0)) := by simpa only [zero_add,smul_eq_mul] using hg.hasDerivAt.tendsto_slope_zero_right have hfr : Tendsto (fun t : ℝ ↦ t⁻¹*(c*f t-c*f 0)) (𝓝[>] 0) (𝓝 (c*d)) := by simpa only [zero_add,smul_eq_mul] using (hf.const_mul c).tendsto_slope_zero_right have hgr : Tendsto (fun t : ℝ ↦ t⁻¹*(g t-g 0)) (𝓝[>] 0) (𝓝 (c*d)) := by apply hfr.congr' filter_upwards [hplus] with t ht simp only [ht,hf0,hg0,mul_zero] have he : deriv g 0=c*d := tendsto_nhds_unique hgradR hgr exact (mul_ne_zero hc hd.ne') (he.symm.trans hdz) end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma line_to_ball_inside {a x : Plane} {R t : ℝ} (hR : 0] (0 : ℝ),t<1 := (eventually_lt_nhds (show (0 : ℝ)<1 by norm_num)).filter_mono nhdsWithin_le_nhds filter_upwards [ht1,self_mem_nhdsWithin,hLS.filter_mono nhdsWithin_le_nhds] with t ht1 ht htS exact hmul (l t) (hBO (line_to_ball_inside hR hxR ht ht1)) htS · filter_upwards [hLS.filter_mono nhdsWithin_le_nhds] with t ht hn exact hvanish (l t) ht hn.le end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus theorem CenteredJacobiChart.nodal_truncation_impossible {E : Set Torus} (hE : MeasurableSet E) {μ : FiniteMeasure NormalBundle} (hμ : IsNormalMeasure E μ) {N : Cover → Cover} (hN : ContDiff ℝ (⊤ : ℕ∞) N) (hp : ∀ m x,N (x+latticeVector m)=N x) (haeN : ∀ᵐ z ∂(μ : Measure NormalBundle),N z.1=(z.2 : Cover)) (c : CenteredJacobiChart E μ N) (q : Lp ℝ ∞ (μ : Measure NormalBundle)) (f : smoothPeriodicScalars) (hjf : ∀ v∈surfaceH1 μ,surfaceJacobiB μ q (surfaceSmoothJet μ f) v=0) (hjw : ∀ v∈surfaceH1 μ,surfaceJacobiB μ q (surfaceSmoothJet μ (directionalNormalScalar N hN hp c.n)) v=0) {u : SurfaceJet μ} (hu : u∈surfaceH1 μ) (hju : ∀ v∈surfaceH1 μ,surfaceJacobiB μ q u v=0) {F : Torus → ℝ} (hFm : Measurable F) (hF : ContinuousOn F (frontier (openRepresentative E))) (haeF : ∀ᵐ z ∂(μ : Measure NormalBundle),u.1 z=F (normalProjection z)) {D : Set Torus} (hD : IsPositiveNodalPiece f (frontier (openRepresentative E)) D) (hcl : quotientMap cubeCenter∈closure D) (hnot : quotientMap cubeCenter∉D) {k : ℝ} (hk : k≠0) (hFD : ∀ a∈D,F a=k*f.val (representative a)) (hFzero : ∀ a∈frontier (openRepresentative E),f.val (representative a)≤0 → F a=0) : False := by obtain ⟨s,hs,hsr,hC1⟩ := c.boundary_continuous_C1 hE hμ hN hp haeN q hu hju hjw hFm hF haeF let O : Set Plane := Metric.ball 0 c.r∩(fun y ↦ quotientMap (c.parameter y)) ⁻¹' D let f' : Plane → ℝ := fun y ↦ c.weight y*f.val (c.parameter y) let g' : Plane → ℝ := fun y ↦ c.weight y*F (quotientMap (c.parameter y)) have hsrad : s≤c.r := by linarith [c.r_pos] have hs₂ : s≤c.r/2 := by linarith [c.r_pos] have hwb (y : Plane) : 0