import Mathlib import OAI.Probability.Ballisticity.Coupling.SeedIteration namespace OAI section open MeasureTheory ProbabilityTheory Filter open scoped ENNReal NNReal BigOperators Topology Classical namespace DirectionalTransience def SeedOptions {d : ℕ} (f : Direction d) (k : ℕ) (s : ℤ) (g : ℝ) (δ : ℝ≥0∞) (ρ : Measure (Lattice d)) : Prop := ∃ μ : Fin k → ProbabilityMeasure (Lattice d), (∀ i, δ • (μ i).toMeasure ≤ ρ) ∧ ∀ i j, i μ) J ω).1=k) (hp : ∀ t μ) t ω) ω) (ht : ∀ i μ) J ω).2 i).measure ω Set.univ).toReal) : SeedOptions f k s (b-z-2*(J:ℝ)*z) (((ENNReal.ofReal (min c j)/2)^J)*ENNReal.ofReal c) (seedEndpointRaw e (J*h+L) (fun _ _ => True) μ.measure ω) := by let q := seedRun e f a s k h θ z b j (1,fun _ => μ) J ω refine ⟨fun i => (seedAdvance e (seedHeight a h J) L (SeedCentral f L θ z) (q.2 i) ω).val,?_,?_⟩ · intro i have hr := seedRun_retained e f a s k h θ z b j c μ hk hj.le hc.le J ω hp i.val (hcount.symm ▸ i.isLt) have hm : ENNReal.ofReal c ≤ seedEndpointRaw e L (SeedCentral f L θ z) (q.2 i).measure ω Set.univ := by rw [← ENNReal.ofReal_toReal (measure_ne_top _ _)] exact ENNReal.ofReal_le_ofReal (ht i.val i.isLt) exact seedAdvance_retained e (seedHeight a h J) (J*h) L (SeedCentral f L θ z) μ.measure (q.2 i) ω _ _ hr hm · intro i t hit have ho := seedRun_ordered e f a s k h θ z b j c μ hk hj hc hs hz J ω hg hp i.val t.val hit (hcount.symm ▸ t.isLt) have hm (i : Fin k) : seedEndpointRaw e L (SeedCentral f L θ z) (q.2 i).measure ω Set.univ≠0 := by intro he have hh := ht i.val i.isLt change c≤(seedEndpointRaw e L (SeedCentral f L θ z) (q.2 i).measure ω Set.univ).toReal at hh rw [he,ENNReal.toReal_zero] at hh exact (not_le_of_gt hc) hh have hh := seedOrdered_central e f (seedHeight a h J) s L θ z (b+z-2*(J:ℝ)*z) hs (q.2 i) (q.2 t) ω (hm i) (hm t) ho convert hh using 1 <;> first | rfl | ring lemma seed_tail_failure_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] (e f : Direction d) (a : ℤ) (k : ℕ) {L : ℕ} (hL : 0 μ ω i) ((measurable_pi_apply i).comp hμ) Set.univ MeasurableSet.univ {p : SeedProfile e a × Environment d | (seedEndpointRaw e L (SeedCentral f L θ z) p.1.measure p.2 Set.univ).toReal hc (μ η i).val) simpa only [Set.mem_univ,true_and,Set.mem_ofPred_eq,measure_univ,mul_one] using hh have he : {ω | ∃ i hb i).trans_eq (by simp)) lemma seedOptions_failure_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] (e f : Direction d) (a s : ℤ) (k N : ℕ) {h L : ℕ} (hh : 0 True) μ.measure ω)} ≤ (k-1:ℕ)*ρ^N+((k-1)*N:ℕ)*(k*ε)+k*ε := by let J := (k-1)*N let run := seedRun e f a s k h θ z b j (1,fun _ => μ) let A := {ω | (run J ω).1 (run J ω).2) (measurable_snd.comp (seedRun_measurable e f a s k hh θ z b j _ J)) (hclip L (by simp)) have he : {ω | ¬SeedOptions f k s (b-z-2*(J:ℝ)*z) (((ENNReal.ofReal (min c j)/2)^J)*ENNReal.ofReal c) (seedEndpointRaw e (J*h+L) (fun _ _ => True) μ.measure ω)} ⊆ (A∪B)∪C := by intro ω hω by_contra hn have ha : ω∉A := fun ha => hn (Or.inl (Or.inl ha)) have hb : ω∉B := fun hb => hn (Or.inl (Or.inr hb)) have hc' : ω∉C := fun hc => hn (Or.inr hc) apply hω apply seedOptions_of_run e f a s k h J L θ z b j c μ hk hj hc hs hz ω hg · have hcount := (seedRun_count_bounds e f a s k h θ z b j (1,fun _ => μ) (by norm_num) hk J ω).2 exact le_antisymm hcount (Nat.le_of_not_gt ha) · intro t ht exact not_not.mp (fun hbad => hb ⟨t,ht,hbad⟩) · intro i hi exact le_of_not_gt (fun hbad => hc' ⟨i,hi,hbad⟩) exact (measure_mono he).trans ((measure_union_le _ _).trans (add_le_add ((measure_union_le _ _).trans (add_le_add hA hB)) hC)) end DirectionalTransience end section open MeasureTheory ProbabilityTheory Filter open scoped ENNReal NNReal BigOperators Topology Classical namespace DirectionalTransience lemma seedOrdered_near_impossible {d : ℕ} (f : Direction d) (s : ℤ) (g r : ℝ) (hs : s=1 ∨ s= -1) (hg : 2*r norm_num at hh <;> linarith [hxn.1,hxn.2,hyn.1,hyn.2] lemma seedOptions_avoid_mass {d k n : ℕ} (f : Direction d) (s : ℤ) (g r : ℝ) (hs : s=1 ∨ s= -1) (hg : 2*r hnex ⟨i,hi⟩ push Not at hi obtain ⟨x,hx,j,hj⟩ := hi exact ⟨j,x,hx,hj⟩ choose j x hx hnear using hbad have hj : Function.Injective j := by intro i t he by_contra hit rcases lt_or_gt_of_ne hit with hit | hti · exact seedOrdered_near_impossible f s g r hs hg _ _ (hord i t hit) (x i) (x t) (v (j i)) (hx i) (hx t) (hnear i) (he.symm ▸ hnear t) · exact seedOrdered_near_impossible f s g r hs hg _ _ (hord t i hti) (x t) (x i) (v (j i)) (hx t) (hx i) (he.symm ▸ hnear t) (hnear i) have hc := Fintype.card_le_of_injective j hj simp only [Fintype.card_fin] at hc omega obtain ⟨i,hi⟩ := hex have hae : ∀ᵐ x ∂(μ i).toMeasure, ∀ j, r≤|signedCoordinate f x-signedCoordinate f (v j)| := ae_iff_of_countable.mpr hi have hm : (μ i).toMeasure {x | ∀ j, r≤|signedCoordinate f x-signedCoordinate f (v j)|}=1 := (prob_compl_eq_zero_iff (Set.to_countable _).measurableSet).mp (ae_iff.mp hae) have hh := hdom i {x | ∀ j, r≤|signedCoordinate f x-signedCoordinate f (v j)|} simpa only [Measure.smul_apply,smul_eq_mul,hm,mul_one] using hh lemma countable_pi_cons_apply {A : Type*} [MeasurableSpace A] [Countable A] [MeasurableSingletonClass A] (n : ℕ) (μ : Fin (n+1) → Measure A) [∀ i, SigmaFinite (μ i)] (S : Set (Fin (n+1) → A)) : Measure.pi μ S = ∫⁻ t, μ 0 {x | Fin.cons x t∈S} ∂Measure.pi (fun j => μ j.succ) := by have hm := (measurePreserving_piFinSuccAbove μ 0).symm.map_eq rw [← hm,Measure.map_apply (measurable_of_countable _) (Set.to_countable _).measurableSet, Measure.prod_apply_symm (Set.to_countable _).measurableSet] simp only [MeasurableEquiv.piFinSuccAbove_symm_apply,Fin.insertNthEquiv,Fin.insertNth_zero,Fin.zero_succAbove] rfl lemma tupleSeparated_cons {d n : ℕ} (f : Direction d) (r : ℝ) (x : Lattice d) (v : Fin n → Lattice d) (hv : TupleSeparated f r v) (hx : ∀ j, r≤|signedCoordinate f x-signedCoordinate f (v j)|) : TupleSeparated f r (Fin.cons x v) := by intro i j hij cases i using Fin.cases with | zero => cases j using Fin.cases with | zero => exact (hij rfl).elim | succ j => simpa using hx j | succ i => cases j using Fin.cases with | zero => simpa only [Fin.cons_succ,Fin.cons_zero,abs_sub_comm] using hx i | succ j => simpa only [Fin.cons_succ] using hv i j (fun he => hij (congrArg Fin.succ he)) lemma seedOptions_product_mass {d k n : ℕ} (f : Direction d) (s : ℤ) (g r : ℝ) (hs : s=1 ∨ s= -1) (hg : 2*r have he : {v : Fin 0 → Lattice d | TupleSeparated f r v}=Set.univ := by ext v; simp only [Set.mem_ofPred_eq,Set.mem_univ,iff_true]; intro i; exact Fin.elim0 i rw [he,Measure.pi_univ,pow_zero] simp | succ n ih => have hi := ih (fun i => μ i.succ) (by omega) (fun i => ho i.succ) rw [countable_pi_cons_apply] have hb (v : Fin n → Lattice d) : {v | TupleSeparated f r v}.indicator (fun _ => δ) v ≤ μ 0 {x | TupleSeparated f r (Fin.cons x v)} := by by_cases hv : TupleSeparated f r v · simp only [Set.indicator,Set.mem_ofPred_eq,ite_eq_left hv] exact (seedOptions_avoid_mass f s g r hs hg δ (μ 0) (ho 0) (by omega) v).trans (measure_mono fun x hx => tupleSeparated_cons f r x v hv hx) · simp only [Set.indicator,Set.mem_ofPred_eq,ite_eq_right hv]; exact bot_le calc δ^(n+1) = δ*δ^n := by rw [pow_succ,mul_comm] _ ≤ δ*Measure.pi (fun i => μ i.succ) {v | TupleSeparated f r v} := by gcongr _ = ∫⁻ v, {v | TupleSeparated f r v}.indicator (fun _ => δ) v ∂Measure.pi (fun i => μ i.succ) := by rw [lintegral_indicator (Set.to_countable _).measurableSet,lintegral_const,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] _ ≤ _ := lintegral_mono hb end DirectionalTransience end end OAI