import Mathlib import OAI.Geometry.CubicTorus.Profiles.SmoothSeamProbability namespace OAI section section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus lemma circle_ae_of_upper_half {P : AxisCircle → Prop} (hm : MeasurableSet {t | P t}) (hs : ∀ t,P (-t) ↔ P t) (hP : ∀ᵐ t : ℝ ∂volume.restrict (Icc (1/2 : ℝ) 1),P (t : AxisCircle)) : ∀ᵐ t : AxisCircle,P t := by have hneg := ((volume : Measure ℝ).measurePreserving_sub_left (1 : ℝ)).quasiMeasurePreserving.ae ((ae_restrict_iff' measurableSet_Icc).mp hP) have hlo : ∀ᵐ t : ℝ,t∈Icc 0 (1/2 : ℝ) → P (t : AxisCircle) := by filter_upwards [hneg] with t ht hmem have hh := ht ⟨by linarith [hmem.2],by linarith [hmem.1]⟩ have he : ((1-t : ℝ) : AxisCircle)=-(t : AxisCircle) := by rw [AddCircle.coe_sub] simp rw [he] at hh exact (hs _).mp hh have hall : ∀ᵐ t : ℝ ∂volume.restrict (Ioc (0 : ℝ) 1),P (t : AxisCircle) := by filter_upwards [ae_restrict_of_ae hlo,ae_restrict_of_ae ((ae_restrict_iff' measurableSet_Icc).mp hP), ae_restrict_mem measurableSet_Ioc] with t hl hu ht by_cases h : t≤1/2 · exact hl ⟨le_of_lt ht.1,h⟩ · exact hu ⟨le_of_lt (lt_of_not_ge h),ht.2⟩ have hp : MeasurePreserving (fun t : ℝ ↦ (t : AxisCircle)) (volume.restrict (Ioc (0 : ℝ) 1)) volume := by simpa using AddCircle.measurePreserving_mk (1 : ℝ) 0 rw [←hp.map_eq] exact ae_map_iff hp.measurable.aemeasurable hm |>.mpr hall theorem isMinimizerAt_planar_profile_circle {V : ℝ} (hV : V∈Ioo 0 1) {E : Set Torus} (hE : MeasurableSet E) (hmin : IsMinimizerAt V E) (hR : ∀ i : Fin 3,E=ᵐ[torusVolume]((axisReflection i).torus ⁻¹' E)) {b : Fin 3 →Bool} (hd : ∀ x∈upperOctant,∀ y∈upperOctant,OrientedCoordinateLE b x y → quotientMap y∈openRepresentative E →quotientMap x∈openRepresentative E) (i : Fin 3) : ∀ᵐ t : AxisCircle, ENNReal.ofReal (unitPlanarProfile (volume.real (axialSlice (openRepresentative E) i t)))≤ planarTorusPerimeter (axialSlice (openRepresentative E) i t) := by apply circle_ae_of_upper_half · apply measurableSet_le · apply Measurable.ennreal_ofReal have hc : Continuous unitPlanarProfile := by unfold unitPlanarProfile; fun_prop exact hc.measurable.comp (axialSliceVolume_measurable (isOpen_openRepresentative E).measurableSet i).ennreal_toReal · exact planarTorusPerimeter_slice_measurable (isOpen_openRepresentative E).measurableSet i · intro t rw [axialSlice_neg_of_reflection (reflection_invariant_openRepresentative hmin.1.1 hR)] · exact isMinimizerAt_planar_profile_ae hV hE hmin hR hd i end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus theorem isMinimizerAt_nesting_improved_profile_circle {V : ℝ} (hV : V∈Ioo 0 1) {E : Set Torus} (hE : MeasurableSet E) (hmin : IsMinimizerAt V E) (hR : ∀ i : Fin 3,E=ᵐ[torusVolume]((axisReflection i).torus ⁻¹' E)) (b : Fin 3 →Bool) (hd : ∀ x∈upperOctant,∀ y∈upperOctant,OrientedCoordinateLE b x y → quotientMap y∈openRepresentative E →quotientMap x∈openRepresentative E) {μ : FiniteMeasure NormalBundle} (hμ : IsNormalMeasure E μ) {H : ℝ} (hCMC : ∀ F : Cover → Cover,ContDiff ℝ (⊤ : ℕ∞) F → (∀ m x,F (x+latticeVector m)=F x) → (∫ z,tangentialDivergence F z.1 z.2 ∂(μ : Measure NormalBundle))= H*(∫ z,⟪(z.2 : Cover),F z.1⟫ ∂(μ : Measure NormalBundle))) (i : Fin 3) (ha : (axialAreaMarginal μ i : Measure AxisCircle)≪volume) (hv : quotientMap (orientedUpperVertex b (fun j ↦ if j=i then true else false))∉openRepresentative E) (hout : quotientMap (axialSectionCorner b i (octantHeight b i 0) (fun _ ↦ true))∉closure (openRepresentative E)) (hin0 : quotientMap (axialSectionCorner b i (octantHeight b i 0) (fun j ↦ j==0))∈openRepresentative E) (hin1 : quotientMap (axialSectionCorner b i (octantHeight b i 0) (fun j ↦ j==1))∈openRepresentative E) (hH : H/2∈Icc (51/50 : ℝ) (81/50 : ℝ)) : let s := volume.real (axialSlice (openRepresentative E) i (octantHeight b i 0 : AxisCircle)) let δ := nestingDelta (H/2) s 0<δ →∀ᵐ t : AxisCircle, let v := volume.real (axialSlice (openRepresentative E) i t) v∈Icc (Shape.u (H/2)-δ) (Shape.u (H/2)) → ENNReal.ofReal (2*Real.sqrt (1+Shape.c*δ^2*Shape.shape ((v-Shape.u (H/2)+δ)/δ)))≤ planarTorusPerimeter (axialSlice (openRepresentative E) i t) := by intro s δ hδpos apply circle_ae_of_upper_half · let v : AxisCircle →ℝ := fun t ↦ volume.real (axialSlice (openRepresentative E) i t) have hm : Measurable v := (axialSliceVolume_measurable (isOpen_openRepresentative E).measurableSet i).ennreal_toReal have hf : Measurable (fun t : AxisCircle ↦ ENNReal.ofReal (2*Real.sqrt (1+Shape.c*δ^2*Shape.shape ((v t-Shape.u (H/2)+δ)/δ)))) := by apply Measurable.ennreal_ofReal apply measurable_const.mul apply Real.continuous_sqrt.measurable.comp exact measurable_const.add (measurable_const.mul (Shape.continuous_shape.measurable.comp ((hm.sub_const _).add_const _ |>.div_const _))) have hi := measurableSet_le hf (planarTorusPerimeter_slice_measurable (isOpen_openRepresentative E).measurableSet i) have hr : MeasurableSet {t : AxisCircle | v t∈Icc (Shape.u (H/2)-δ) (Shape.u (H/2))} := hm measurableSet_Icc convert hr.compl.union hi using 1 ext t simp only [mem_ofPred_eq,mem_union,mem_compl_iff] tauto · intro t rw [axialSlice_neg_of_reflection (reflection_invariant_openRepresentative hmin.1.1 hR)] · exact isMinimizerAt_nesting_improved_profile_ae hV hE hmin hR b hd hμ hCMC i ha hv hout hin0 hin1 hH hδpos end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus def sharpSectionWeight (H s : ℝ) : ℝ := if s∈Ico 0 1 then Nesting.weight (H*s/unitPlanarProfile s) else Nesting.ell lemma unitPlanarProfile_pos {s : ℝ} (hs : s∈Ioo 0 1) : 0 rfl simp only [hlift,Pi.neg_apply,abs_neg,AddCircle.coe_zero] at hb have hsmall : Integrable (fun t ↦ γ (v t)*|axialNormalDensity μ i t|) := by simpa only [mul_comm,Function.comp_apply] using integrable_mul_unit (axialNormalDensity_integrable μ i).abs (hγ.comp hv).measurable (fun t ↦ by change |γ (v t)|≤1; rw [abs_of_nonneg (hγb _).1]; exact (hγb _).2) have hwEq : (fun t ↦ Nesting.weight (actualAxialFlux O μ H i t/axialPerimeterDensity μ i t)* |axialNormalDensity μ i t|)=ᵐ[volume](fun t ↦ Nesting.weight (axialSecondDensity μ i t/axialPerimeterDensity μ i t)*|axialNormalDensity μ i t|) := by filter_upwards [axialSurface_density_eq_flux hO hHO i] with t ht rw [←ht] rfl have hlarge := (axial_weighted_normal_integrable μ i).congr hwEq.symm have him := integral_mono_ae hsmall hlarge (by filter_upwards [hγw] with t ht exact mul_le_mul_of_nonneg_right ht (abs_nonneg _)) have hflux := axial_integrated_flux_actual hO hμO hHO i ha rw [perimeter_congr_ae hOE] at hflux change _≤(perimeter E).toReal have hh := hb.trans him exact (add_le_add le_rfl hh).trans hflux end CubicTorus end end section noncomputable section open MeasureTheory Set open scoped ENNReal NNReal Topology namespace CubicTorus lemma real_measure_le_of_unit_continuous {μ ν : Measure ℝ} [IsFiniteMeasure μ] [IsFiniteMeasure ν] (hh : ∀ f : ℝ → ℝ,Continuous f → (∀ x,f x∈Icc 0 1) → (∫ x,f x ∂μ)≤∫ x,f x ∂ν) : μ≤ν := by have hcompact ⦃K : Set ℝ⦄ (hK : IsCompact K) : μ K≤ν K := by refine ENNReal.le_of_forall_pos_le_add fun ε hε hν ↦ ?_ have hνK : ν K≠⊤ := hν.ne have hμK : μ K≠⊤ := hK.measure_lt_top.ne obtain ⟨V,pV1,pV2,pV3⟩ : ∃ V⊇K,IsOpen V ∧ ν V≤ν K+ε := exists_isOpen_le_add K ν (ne_of_gt (ENNReal.coe_lt_coe.mpr hε)) suffices μ.real K≤ν.real K+ε by rwa [←ENNReal.toReal_le_toReal,ENNReal.toReal_add,ENNReal.coe_toReal] all_goals finiteness obtain ⟨f,hf1,hf2,hf3⟩ := exists_continuousMap_one_of_isCompact_subset_isOpen hK pV2 pV1 have hfiμ : Integrable f μ := (f.continuous.integrable_of_hasCompactSupport (hasCompactSupport_def.mpr hf2)) have hfiν : Integrable f ν := (f.continuous.integrable_of_hasCompactSupport (hasCompactSupport_def.mpr hf2)) have hfV (x : ℝ) : f x≤V.indicator 1 x := by by_cases hx : x∈tsupport f · simp [(hf3.1 hx),(hf3.2 x).2] · simp [image_eq_zero_of_notMem_tsupport hx,Set.indicator_nonneg] have hfK (x : ℝ) : K.indicator 1 x≤f x := by by_cases hx : x∈K · simp [hx,hf1 hx] · simp [hx,(hf3.2 x).1] calc μ.real K=(∫ x,K.indicator 1 x ∂μ) := (integral_indicator_one hK.measurableSet).symm _≤∫ x,f x ∂μ := integral_mono ((integrable_const (1 : ℝ)).indicator hK.measurableSet) hfiμ hfK _≤∫ x,f x ∂ν := hh f f.continuous hf3.2 _≤∫ x,V.indicator 1 x ∂ν := integral_mono hfiν ((integrable_const (1 : ℝ)).indicator pV2.measurableSet) hfV _≤(ν K).toReal+↑ε := by rwa [integral_indicator_one pV2.measurableSet,measureReal_def, ←ENNReal.coe_toReal,←ENNReal.toReal_add,ENNReal.toReal_le_toReal] all_goals finiteness intro s apply (measure_mono (subset_toMeasurable ν s)).trans have hsm := measurableSet_toMeasurable ν s rw [hsm.measure_eq_iSup_isCompact μ] apply iSup_le intro K apply iSup_le intro hKs apply iSup_le intro hK exact (hcompact hK).trans (by simpa only [measure_toMeasurable] using measure_mono (μ := ν) hKs) end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology namespace CubicTorus theorem circle_ac_measurable_weight_integrable {f : ℝ → ℝ} {g : AxisCircle → ℝ} (hp : Function.Periodic f 1) (hc : Continuous f) (hf : ∀ a b,AbsolutelyContinuousOnInterval f a b) (hgi : Integrable g) (hd : ∀ᵐ t : ℝ,t∈Icc (0 : ℝ) 1 → HasDerivAt f (g (t : AxisCircle)) t) {γ : ℝ → ℝ} (hγ : Measurable γ) (hγn : ∀ x,0≤γ x) (hγgi : Integrable (fun s ↦ γ (hp.lift s)*|g s|)) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1) : 2*|∫ y in f 0..f t,γ y|≤∫ s,γ (hp.lift s)*|g s| := by let ρ : Measure AxisCircle := volume.withDensity (fun s ↦ ENNReal.ofReal |g s|) have hfin : (∫⁻ s,ENNReal.ofReal |g s|)≠⊤ := ((hasFiniteIntegral_iff_ofReal (Eventually.of_forall (fun s ↦ abs_nonneg (g s)))).mp hgi.abs.2).ne let : IsFiniteMeasure ρ := isFiniteMeasure_withDensity hfin let ν : Measure ℝ := Measure.map hp.lift ρ let μ : Measure ℝ := (2 : ℝ≥0∞) • volume.restrict (uIoc (f 0) (f t)) have : IsFiniteMeasure (volume.restrict (uIoc (f 0) (f t))) := by unfold uIoc infer_instance have : IsFiniteMeasure μ := by exact Measure.smul_finite _ (by norm_num) have hpc : Continuous hp.lift := continuous_periodic_lift hp hc have hpair (ψ : ℝ → ℝ) (hψ : Measurable ψ) : (∫ y,ψ y ∂ν)=∫ s,ψ (hp.lift s)*|g s| := by rw [show ν=Measure.map hp.lift ρ from rfl, integral_map hpc.measurable.aemeasurable hψ.aestronglyMeasurable] rw [show ρ=volume.withDensity (fun s ↦ ENNReal.ofReal |g s|) from rfl, integral_withDensity_eq_integral_toReal_smul₀ hgi.aemeasurable.abs.ennreal_ofReal (Eventually.of_forall (fun s ↦ ENNReal.ofReal_lt_top))] simp only [ENNReal.toReal_ofReal (abs_nonneg _),smul_eq_mul,mul_comm] have hleft (ψ : ℝ → ℝ) (hn : ∀ x,0≤ψ x) : (∫ y,ψ y ∂μ)=2*|∫ y in f 0..f t,ψ y| := by rw [show μ=(2 : ℝ≥0∞) • volume.restrict (uIoc (f 0) (f t)) from rfl, integral_smul_measure,intervalIntegral.abs_integral_eq_abs_integral_uIoc, abs_of_nonneg (integral_nonneg hn)] norm_num have horder : μ≤ν := by apply real_measure_le_of_unit_continuous intro ψ hψ hb rw [hpair ψ hψ.measurable,hleft ψ (fun x ↦ (hb x).1)] exact circle_ac_weighted_oscillation hp hc hf hgi hd hψ hb ht have hγi : Integrable γ ν := by apply (integrable_map_measure hγ.aestronglyMeasurable hpc.measurable.aemeasurable).mpr apply (integrable_withDensity_iff_integrable_smul₀' hgi.aemeasurable.abs.ennreal_ofReal (Eventually.of_forall (fun s ↦ ENNReal.ofReal_lt_top))).mpr simpa only [Function.comp_apply,ENNReal.toReal_ofReal (abs_nonneg _),smul_eq_mul,mul_comm] using hγgi have hh := integral_mono_measure horder (Eventually.of_forall hγn) hγi rwa [hpair γ hγ,hleft γ hγn] at hh theorem circle_ac_measurable_weight {f : ℝ → ℝ} {g : AxisCircle → ℝ} (hp : Function.Periodic f 1) (hc : Continuous f) (hf : ∀ a b,AbsolutelyContinuousOnInterval f a b) (hgi : Integrable g) (hd : ∀ᵐ t : ℝ,t∈Icc (0 : ℝ) 1 → HasDerivAt f (g (t : AxisCircle)) t) {γ : ℝ → ℝ} (hγ : Measurable γ) (hγb : ∀ x,γ x∈Icc 0 1) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1) : 2*|∫ y in f 0..f t,γ y|≤∫ s,γ (hp.lift s)*|g s| := by apply circle_ac_measurable_weight_integrable hp hc hf hgi hd hγ (fun x ↦ (hγb x).1) ?_ ht simpa only [mul_comm,Function.comp_apply] using integrable_mul_unit hgi.abs (hγ.comp (continuous_periodic_lift hp hc).measurable) (fun x ↦ by change |γ (hp.lift x)|≤1; rw [abs_of_nonneg (hγb _).1]; exact (hγb _).2) end CubicTorus end end section noncomputable section open MeasureTheory Set Filter open scoped ENNReal NNReal Topology RealInnerProductSpace namespace CubicTorus end CubicTorus end end end end OAI