import Mathlib import OAI.Analysis.HardSphere.Geometry.LocalCloseLabels namespace OAI noncomputable section open MeasureTheory Filter Set open scoped ENNReal Topology BigOperators open scoped BigOperators ComplexConjugate open MeasureTheory ProbabilityTheory Filter Set open scoped ENNReal NNReal Topology BigOperators open MeasureTheory ProbabilityTheory Real Complex open scoped ENNReal ComplexConjugate open ProbabilityTheory open MeasureTheory Filter Set open scoped ENNReal Topology open MeasureTheory Set open scoped ENNReal namespace HardSphere open MeasureTheory Set Filter private def flattenLinear (n : ℕ) : LiftedConfiguration n→ₗ[ℝ] EuclideanConfiguration (Fin n) where toFun X := WithLp.toLp 2 (fun p ↦ X p.1 p.2) map_add' _ _ := rfl map_smul' _ _ := rfl def euclideanFlatten (n : ℕ) : LiftedConfiguration n→L[ℝ] EuclideanConfiguration (Fin n) := (flattenLinear n).toContinuousLinearMap lemma euclideanFlatten_apply (n : ℕ) (X : LiftedConfiguration n) (p : Direction n) : euclideanFlatten n X p=X p.1 p.2 := rfl lemma euclideanFlatten_project (n : ℕ) (L : Length) (X : LiftedConfiguration n) : euclideanProject L (euclideanFlatten n X)=project n L X := rfl lemma euclideanFlatten_single (n : ℕ) (p : Direction n) : euclideanFlatten n (Pi.single p.1 (Pi.single p.2 1))=EuclideanSpace.basisFun (Direction n) ℝ p := by ext q by_cases h1 : q.1=p.1 <;> by_cases h2 : q.2=p.2 <;> simp [euclideanFlatten_apply,EuclideanSpace.basisFun_apply,Prod.ext_iff,h1,h2] lemma realEuclidean_lift_smooth {n : ℕ} (L : Length) (f : Configuration n L→ℝ) (hf : ContDiff ℝ ((⊤:ℕ∞):WithTop ℕ∞) (fun x : EuclideanConfiguration (Fin n) ↦ f (euclideanProject L x))) : ContDiff ℝ ((⊤:ℕ∞):WithTop ℕ∞) (fun x : LiftedConfiguration n ↦ (f (project n L x):ℂ)) := Complex.ofRealCLM.contDiff.comp (hf.comp (euclideanFlatten n).contDiff) def realEuclideanMultiplier {n : ℕ} (L : Length) (f : Configuration n L→ℝ) (hf : ContDiff ℝ ((⊤:ℕ∞):WithTop ℕ∞) (fun x : EuclideanConfiguration (Fin n) ↦ f (euclideanProject L x))) : SmoothMultiplier n L := SmoothMultiplier.ofSmooth (fun X ↦ (f X:ℂ)) (realEuclidean_lift_smooth L f hf) lemma coordDerivative_real_euclidean {n : ℕ} (L : Length) (f : Configuration n L→ℝ) (hf : Differentiable ℝ (fun x : EuclideanConfiguration (Fin n) ↦ f (euclideanProject L x))) (p : Direction n) (X : Configuration n L) : coordDerivative n L (fun Y ↦ (f Y:ℂ)) p X= ((fderiv ℝ (fun x : EuclideanConfiguration (Fin n) ↦ f (euclideanProject L x)) (euclideanFlatten n (representative n L X)) (EuclideanSpace.basisFun (Direction n) ℝ p)):ℂ) := by have hh := (Complex.ofRealCLM.hasFDerivAt.comp _ (hf _).hasFDerivAt).comp (representative n L X) (euclideanFlatten n).hasFDerivAt have he : ((Complex.ofRealCLM ∘ (fun x : EuclideanConfiguration (Fin n) ↦ f (euclideanProject L x))) ∘ euclideanFlatten n)= (fun x : LiftedConfiguration n ↦ (f (project n L x):ℂ)) := by funext x rfl rw [he] at hh unfold coordDerivative rw [hh.fderiv] simp only [ContinuousLinearMap.comp_apply,euclideanFlatten_single,Complex.ofRealCLM_apply] end HardSphere namespace HardSphere open MeasureTheory Set Filter variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nontrivial ι] lemma clippedNearest_le (L : Length) (X Y : ι→Torus L) (i k : ι) (t : ℝ) (hi : X i=Y i) (hrest : ∀ j, j≠k → X j=Y j) (hfar : t≤torusDistance L (Y i) (Y k)) : min (nearestParticleDistance L X i) t≤nearestParticleDistance L Y i := by by_cases he : nearestLabel L Y i=k · simpa only [nearestParticleDistance,he] using (min_le_right (nearestParticleDistance L X i) t).trans hfar · have hn := nearestParticleDistance_le L X i (nearestLabel L Y i) (nearestLabel_ne L Y i) rw [hi,hrest _ he] at hn exact (min_le_left _ _).trans hn lemma clippedNearest_eq (L : Length) (X Y : ι→Torus L) (i k : ι) (t : ℝ) (hi : X i=Y i) (hrest : ∀ j, j≠k → X j=Y j) (hXfar : t≤torusDistance L (X i) (X k)) (hYfar : t≤torusDistance L (Y i) (Y k)) : min (nearestParticleDistance L X i) t=min (nearestParticleDistance L Y i) t := le_antisymm (le_min (clippedNearest_le L X Y i k t hi hrest hYfar) (min_le_right _ _)) (le_min (clippedNearest_le L Y X i k t hi.symm (fun j h ↦ (hrest j h).symm) hXfar) (min_le_right _ _)) lemma closeRamp_clipped {s d : ℝ} (hs : 0