import Mathlib import OAI.Analysis.HardSphere.Geometry.PointFin import OAI.Analysis.HardSphere.Geometry.SubsetPointLinear namespace OAI section section noncomputable section open MeasureTheory Filter Set open scoped ENNReal Topology BigOperators noncomputable section open scoped BigOperators ComplexConjugate noncomputable section open MeasureTheory ProbabilityTheory Filter Set open scoped ENNReal NNReal Topology BigOperators noncomputable section open MeasureTheory ProbabilityTheory Real Complex open scoped ENNReal ComplexConjugate open ProbabilityTheory noncomputable section open MeasureTheory Filter Set open scoped ENNReal Topology noncomputable section open MeasureTheory Set open scoped ENNReal noncomputable section open MeasureTheory Filter Set open scoped ENNReal Topology BigOperators namespace HardSphere open SphericalCoordinates open scoped BigOperators abbrev CubeCell (K : ℕ) := Fin K × Fin K × Fin K noncomputable def unitSectorMeasure (n K : ℕ) (σ : Fin n → CubeCell K) : Measure (Fin n → Point) := Measure.pi (fun i ↦ volume.restrict (cube (subcubeBase 0 1 (σ i)) 1)) lemma unitSectorMeasure_le {n K : ℕ} {L : Length} (hL : L.val=(K:ℝ)) (σ : Fin n → CubeCell K) : unitSectorMeasure n K σ≤Measure.pi (fun _ : Fin n ↦ volume.restrict (cube 0 L.val)) := by rw [hL,← mul_one (K:ℝ),cube_configuration_subdivision 0 (by norm_num : (0:ℝ)≤1)] exact Measure.le_sum _ σ noncomputable def unitSectorRestriction {n K : ℕ} {L : Length} (hL : L.val=(K:ℝ)) (σ : Fin n → CubeCell K) : ScalarL2 n L →L[ℝ] Lp ℂ 2 (unitSectorMeasure n K σ) := (Lp.LpToLpOfMeasureLeSMul (c := (1:ℝ≥0∞)) (by norm_num) (show unitSectorMeasure n K σ≤1 • Measure.pi (fun _ : Fin n ↦ volume.restrict (cube 0 L.val)) by simpa only [one_smul] using unitSectorMeasure_le hL σ)).comp (Lp.compMeasurePreservingₗᵢ ℝ (cubeParameter n L) (cubeParameter_preserving n L)).toContinuousLinearMap lemma unitSectorRestriction_ae {n K : ℕ} {L : Length} (hL : L.val=(K:ℝ)) (σ : Fin n → CubeCell K) (u : ScalarL2 n L) : unitSectorRestriction hL σ u=ᵐ[unitSectorMeasure n K σ] fun X ↦ u (cubeParameter n L X) := by have h₁ := Lp.coeFn_LpToLpOfMeasureLeSMul (c := (1:ℝ≥0∞)) (by norm_num) (show unitSectorMeasure n K σ≤1 • Measure.pi (fun _ : Fin n ↦ volume.restrict (cube 0 L.val)) by simpa only [one_smul] using unitSectorMeasure_le hL σ) ((Lp.compMeasurePreservingₗᵢ ℝ (cubeParameter n L) (cubeParameter_preserving n L)) u) apply h₁.trans apply (Measure.absolutelyContinuous_of_le (unitSectorMeasure_le hL σ)).ae_eq exact Lp.coeFn_compMeasurePreserving u (cubeParameter_preserving n L) lemma SmoothTest.unitSector_norm {n K : ℕ} {L : Length} {a : ℝ} (f : SmoothTest n L a) (hL : L.val=(K:ℝ)) (σ : Fin n → CubeCell K) : ENNReal.ofReal (‖unitSectorRestriction hL σ f.jet.1‖^2)= ∫⁻ X,ENNReal.ofReal (‖f.toFun (cubeParameter n L X)‖^2) ∂unitSectorMeasure n K σ := by have h₁ := unitSectorRestriction_ae hL σ f.jet.1 have h₂ : (fun X ↦ f.jet.1 (cubeParameter n L X))=ᵐ[unitSectorMeasure n K σ] fun X ↦ f.toFun (cubeParameter n L X) := by apply (Measure.absolutelyContinuous_of_le (unitSectorMeasure_le hL σ)).ae_eq exact (cubeParameter_preserving n L).quasiMeasurePreserving.ae_eq_comp f.memLp.coeFn_toLp have hn := smooth_norm_lintegral (Lp.memLp (unitSectorRestriction hL σ f.jet.1)) rw [Lp.toLp_coeFn] at hn rw [hn] apply lintegral_congr_ae filter_upwards [h₁.trans h₂] with X hX rw [hX] noncomputable def unitCellPenalty {n K : ℕ} {L : Length} (hL : L.val=(K:ℝ)) (a : ℝ) (u : ScalarL2 n L) : ℝ := ∑ σ : Fin n → CubeCell K, (∑ v : CubeCell K,1/(64*Real.sqrt 3)*a*(Fintype.card {i // σ i=v}:ℝ)* ((Fintype.card {i // σ i=v}:ℝ)-1))*‖unitSectorRestriction hL σ u‖^2 lemma continuous_unitCellPenalty {n K : ℕ} {L : Length} (hL : L.val=(K:ℝ)) (a : ℝ) : Continuous (unitCellPenalty (n := n) hL a) := by apply continuous_finsetSum intro σ _ exact continuous_const.mul ((unitSectorRestriction hL σ).continuous.norm.pow 2) lemma SmoothTest.cell_energy {n K : ℕ} {L : Length} {a : ℝ} (f : SmoothTest n L a) (hL : L.val=(K:ℝ)) (ha : 0