import Mathlib import OAI.Analysis.HardSphere.Allocation.CoarsePhysical namespace OAI section noncomputable section open MeasureTheory ProbabilityTheory Set open scoped ENNReal NNReal Topology namespace HardSphere.Groups open Wiener Bridge Sampling Comparison GaussianPacking PathCutoff CellOrbital attribute [local instance] Classical.propDecidable lemma label_endpoints_ae {N : ℕ} {L : Length} (T : ℝ) (μ : Measure (BridgeEndpoints N L)) : ∀ᵐ z ∂μ.prod (Measure.pi fun _ : Fin N ↦ Bridge.law), labelBridgePath N L T z 0=z.1.2 ∧ labelBridgePath N L T z 1=bridgeEnd N L T z.1 := by apply (Measure.ae_prod_iff_ae_ae ((measurableSet_eq_fun ((continuous_eval_const (0:Time)).measurable.comp (labelBridgePath_measurable N L T)) measurable_fst.snd).inter (measurableSet_eq_fun ((continuous_eval_const (1:Time)).measurable.comp (labelBridgePath_measurable N L T)) ((bridgeEnd_continuous N L T).measurable.comp measurable_fst)))).mpr exact ae_of_all _ (exposed_endpoints T) lemma physicalDatum_branch_of {N K M G : ℕ} {L : Length} (g : Fin G) (b : Fin N→Bool) (a : GridAllocation N K (G*M)) (m : ℕ) (r R C S s₀ T : ℝ) (u : Time) (z : BridgeEndpoints N L × (Fin N→Bridge.Noise)) (h0 : labelBridgePath N L T z 0=z.1.2) (h1 : labelBridgePath N L T z 1=bridgeEnd N L T z.1) (hb : z∈flagEvent (eligibilityFlag (K:=K) m r R C S s₀ T u) b) : physicalDatum g m r R C S s₀ u (labelBridgePath N L T z,a)= physicalBranchDatum g b a T (blockExpose (fun i ↦ i∈groupUnion g a) z) := by have hf : (fun i ↦ decide (∃v : Fin 3→Fin K, Eligible m r R C S s₀ u v i (labelBridgePath N L T z)))=b := by funext i have hi := hb i simpa only [eligibilityFlag,ownEligible,Eligible,h0,h1,ownPath_eq] using hi simp only [physicalDatum,physicalBranchDatum,h0,h1,hf,blockExpose] refine Prod.ext rfl (Prod.ext rfl (Prod.ext rfl (Prod.ext rfl ?_))) funext i by_cases hi : i∈groupUnion g a · simp only [ite_eq_left hi,dite_eq_left hi] · simp only [ite_eq_right hi,dite_eq_right hi] rw [labelBridgePath_lift] rfl theorem actual_physical_branch_joint {N K M G : ℕ} {L : Length} (hL : L.val=(K:ℝ)) (hK : 1≤K) (h50 : 50