diff --git a/lean/OAI/Probability/Ballisticity/Estimates/InputMarginal.lean b/lean/OAI/Probability/Ballisticity/Estimates/InputMarginal.lean new file mode 100644 index 0000000000000000000000000000000000000000..897c86427cb8d9aa8f5bb22e7363e970f8a84cee --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/InputMarginal.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.LocalStoppedSplice +import OAI.Probability.Ballisticity.Entropy.AnchorEntropy + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +noncomputable def currentInput {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) + (X : EpisodeInput e) : (Environment d × (ℕ → HorizontalSpace e)) × LocalUpperField e := + ((X.1.1,fun a => X.1.2 (i,a)),X.2 (i,m)) + +lemma currentInput_measurable {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) : + Measurable (currentInput e i m) := by + exact ((measurable_fst.comp measurable_fst).prodMk + (Measurable.of_eval fun a => (measurable_pi_apply (i,a)).comp + (measurable_snd.comp measurable_fst))).prodMk + ((measurable_pi_apply (i,m)).comp measurable_snd) + +theorem episodeInputLaw_current {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (i : ℤ) (m : ℕ) : + (episodeInputLaw e ν Q t ht).map (currentInput e i m) = + (Q.compProd (currentAnchorKernel e (fun ω => t ω i) (ht i))).prod + (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν)) := by + let f : EpisodeAnchors e → ℕ → HorizontalSpace e := fun U a => U (i,a) + have hf : Measurable f := Measurable.of_eval fun a => measurable_pi_apply (i,a) + have hK : (globalEpisodeAnchors e t ht).map f = + currentAnchorKernel e (fun ω => t ω i) (ht i) := by + ext ω : 1 + rw [Kernel.map_apply _ hf] + exact globalEpisodeAnchors_current e t ht ω i + have hπ : (episodeAuxiliaryLaw e ν).map (fun V => V (i,m)) = + Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν) := by + exact Measure.infinitePi_map_eval _ (i,m) + change ((Q.compProd (globalEpisodeAnchors e t ht)).prod (episodeAuxiliaryLaw e ν)).map + (Prod.map (Prod.map id f) (fun V => V (i,m))) = _ + rw [← Measure.map_prod_map _ _ (measurable_id.prodMap hf) (measurable_pi_apply (i,m)), + ← Measure.compProd_map hf,hK,hπ] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/IntegerMedian.lean b/lean/OAI/Probability/Ballisticity/Estimates/IntegerMedian.lean new file mode 100644 index 0000000000000000000000000000000000000000..05e22c8b552689c6768b2d9ef6064e423138991b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/IntegerMedian.lean @@ -0,0 +1,435 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RecordIndexTime + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +noncomputable def integerMedian (μ : Measure ℤ) [IsProbabilityMeasure μ] : ℤ := + (exists_integer_median μ).choose + +lemma integerMedian_spec (μ : Measure ℤ) [IsProbabilityMeasure μ] : + (1/2 : ℝ≥0∞) ≤ μ (Set.Iic (integerMedian μ)) ∧ + (1/2 : ℝ≥0∞) ≤ μ (Set.Ici (integerMedian μ)) := + (exists_integer_median μ).choose_spec + +lemma median_family_symmetrization {Ω ι : Type*} [MeasurableSpace Ω] [Countable ι] + (μ : Measure Ω) [IsProbabilityMeasure μ] (f : ι → Ω → ℝ) + (hf : ∀ i, Measurable (f i)) (b : ι → ℝ) + (hb : ∀ i, (1/2 : ℝ≥0∞) ≤ μ {x | f i x ≤ b i} ∧ + (1/2 : ℝ≥0∞) ≤ μ {x | b i ≤ f i x}) (s : Set ι) (z : ℝ) : + (1/2 : ℝ≥0∞) * μ {x | ∃ i ∈ s, z < |f i x-b i|} ≤ + μ.prod μ {P | ∃ i ∈ s, z < |f i P.1-f i P.2|} := by + classical + let A : Set Ω := {x | ∃ i ∈ s, z < |f i x-b i|} + let E : Set (Ω × Ω) := {P | ∃ i ∈ s, z < |f i P.1-f i P.2|} + have hA : MeasurableSet A := by + simp only [A,Set.ofPred_exists,Set.ofPred_and] + exact MeasurableSet.iUnion fun i => (MeasurableSet.const _).inter + (measurableSet_lt measurable_const ((hf i).sub_const (b i)).abs) + have hE : MeasurableSet E := by + simp only [E,Set.ofPred_exists,Set.ofPred_and] + exact MeasurableSet.iUnion fun i => (MeasurableSet.const _).inter + (measurableSet_lt measurable_const + (((hf i).comp measurable_fst).sub ((hf i).comp measurable_snd)).abs) + change (1/2 : ℝ≥0∞) * μ A ≤ μ.prod μ E + rw [Measure.prod_apply hE] + calc + _ = ∫⁻ x, A.indicator (fun _ => (1/2 : ℝ≥0∞)) x ∂μ := by + rw [lintegral_indicator hA,lintegral_const,Measure.restrict_apply_univ] + _ ≤ _ := by + apply lintegral_mono + intro x + by_cases hx : x ∈ A + · rw [Set.indicator_of_mem hx] + obtain ⟨i,hi,hlarge⟩ := hx + rcases (lt_abs.mp hlarge) with hright | hleft + · apply (hb i).1.trans (measure_mono ?_) + intro y hy + change f i y ≤ b i at hy + refine ⟨i,hi,?_⟩ + exact lt_of_lt_of_le (by linarith : z < f i x-f i y) (le_abs_self _) + · apply (hb i).2.trans (measure_mono ?_) + intro y hy + change b i ≤ f i y at hy + refine ⟨i,hi,?_⟩ + exact lt_of_lt_of_le (by linarith : z < -(f i x-f i y)) (neg_le_abs _) + · rw [Set.indicator_of_notMem hx] + exact bot_le + +def signedIntegerCoordinate {d : ℕ} (e : Direction d) (x : Lattice d) : ℤ := + if e.2 then x e.1 else -x e.1 + +lemma signedIntegerCoordinate_cast {d : ℕ} (e : Direction d) (x : Lattice d) : + (signedIntegerCoordinate e x : ℝ) = signedCoordinate e x := by + simp only [signedIntegerCoordinate,signedCoordinate] + split <;> simp + +noncomputable def recordMedian {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (e : Direction d) (r : ℕ) : ℤ := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + let f : Path d → ℤ := fun X => signedIntegerCoordinate e (recordIndexPosition ℓ r X) + have hf : Measurable f := (measurable_of_countable (signedIntegerCoordinate e)).comp (measurable_recordIndexPosition ℓ r) + let : IsProbabilityMeasure ((conditionedLaw ν ℓ).map f) := + (Measure.isProbabilityMeasure_map_iff hf.aemeasurable).mpr inferInstance + exact integerMedian ((conditionedLaw ν ℓ).map f) + +lemma recordMedian_spec {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (e : Direction d) (r : ℕ) : + (1/2 : ℝ≥0∞) ≤ conditionedLaw ν ℓ + {X | signedCoordinate e (recordIndexPosition ℓ r X) ≤ (recordMedian ν ℓ hp e r : ℝ)} ∧ + (1/2 : ℝ≥0∞) ≤ conditionedLaw ν ℓ + {X | (recordMedian ν ℓ hp e r : ℝ) ≤ signedCoordinate e (recordIndexPosition ℓ r X)} := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + let f : Path d → ℤ := fun X => signedIntegerCoordinate e (recordIndexPosition ℓ r X) + have hf : Measurable f := (measurable_of_countable (signedIntegerCoordinate e)).comp (measurable_recordIndexPosition ℓ r) + let : IsProbabilityMeasure ((conditionedLaw ν ℓ).map f) := + (Measure.isProbabilityMeasure_map_iff hf.aemeasurable).mpr inferInstance + have h := integerMedian_spec ((conditionedLaw ν ℓ).map f) + rw [Measure.map_apply hf measurableSet_Iic,Measure.map_apply hf measurableSet_Ici] at h + have he (X : Path d) : signedCoordinate e (recordIndexPosition ℓ r X) = (f X : ℝ) := + (signedIntegerCoordinate_cast e _).symm + simp only [he,Int.cast_le] at ⊢ + exact h + +lemma conditioned_firstHit_median_maximum {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) (H : ℕ) (z : ℝ) : + (annealedLaw ν (NoDrop ℓ 0))^2 * (1/2 : ℝ≥0∞) * conditionedLaw ν ℓ + {X | ∃ r, 0 < r ∧ r ≤ H ∧ + z < |signedCoordinate e (recordIndexPosition ℓ r X) - + (recordMedian ν ℓ (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) e r : ℝ)|} ≤ + independentConditionedPairLaw ν ℓ + {P | z < partialSumMax (fun n => commonIncrementProcess ℓ e n P) H} := by + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + have hs := median_family_symmetrization (conditionedLaw ν ℓ) + (fun r X => signedCoordinate e (recordIndexPosition ℓ r X)) + (fun r => (measurable_of_countable (signedCoordinate e)).comp (measurable_recordIndexPosition ℓ r)) + (fun r => (recordMedian ν ℓ hp e r : ℝ)) (recordMedian_spec ν ℓ hp e) + {r | 0 < r ∧ r ≤ H} z + simp only [Set.mem_ofPred_eq,and_assoc] at hs + rw [mul_assoc] + exact (mul_le_mul_right hs _).trans + (independent_firstHit_pair_maximum ν ℓ htrans height hproj hstep e H z) + +def IsGaussianSequence {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (S : Ω → ℝ) (r : ℕ → ℝ) : Prop := + Tendsto r atTop atTop ∧ ∀ a : ℝ, 0 < a → + Tendsto (fun i => fluctuationScale μ S (r i) * μ.real {x | a*r i < |S x|}) + atTop (𝓝 0) + +lemma one_sub_cos_sinc (x : ℝ) : + 1-Real.cos x = x^2/2*(Real.sinc (x/2))^2 := by + by_cases hx : x = 0 + · simp [hx] + · rw [Real.sinc_of_ne_zero (div_ne_zero hx (by norm_num))] + have hc := Real.cos_two_mul (x/2) + have hs := Real.sin_sq_add_cos_sq (x/2) + have he : 2*(x/2) = x := by ring + rw [he] at hc + field_simp + nlinarith + +lemma cosine_quadratic_local (t : ℝ) {ε : ℝ} (hε : 0 < ε) : + ∃ δ : ℝ, 0 < δ ∧ δ ≤ 1 ∧ ∀ y : ℝ, |y| ≤ δ → + |(1-Real.cos (t*y)) - (t^2/2)*y^2| ≤ ε*y^2 := by + let c : ℝ → ℝ := fun y => t^2/2*((Real.sinc (t*y/2))^2-1) + have hc : Continuous c := by fun_prop + have hc0 : c 0 = 0 := by simp [c] + obtain ⟨δ,hδ,hd⟩ := (Metric.continuousAt_iff.mp hc.continuousAt) ε hε + refine ⟨min (δ/2) 1,lt_min (by positivity) zero_lt_one,min_le_right ..,?_⟩ + intro y hy + have hyd : dist y 0 < δ := by + rw [Real.dist_eq,sub_zero] + exact lt_of_le_of_lt (hy.trans (min_le_left ..)) (by linarith) + have hcy : |c y| < ε := by simpa [Real.dist_eq,hc0] using hd hyd + have he : (1-Real.cos (t*y)) - (t^2/2)*y^2 = c y*y^2 := by + rw [one_sub_cos_sinc] + dsimp [c] + ring + rw [he,abs_mul,abs_of_nonneg (sq_nonneg y)] + exact mul_le_mul_of_nonneg_right hcy.le (sq_nonneg y) + +lemma truncatedVariance_div {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (S : Ω → ℝ) {r : ℝ} (hr : 0 < r) : + truncatedVariance μ (fun x => S x/r) 1 = truncatedVariance μ S r / r^2 := by + unfold truncatedVariance + rw [← integral_div] + apply integral_congr_ae + filter_upwards [] with x + rw [one_pow,div_pow,← min_div_div_right (le_of_lt (sq_pos_of_pos hr)),div_self (pow_ne_zero 2 (ne_of_gt hr))] + +lemma gaussian_quadratic_integral {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) (r : ℕ → ℝ) (hr : IsGaussianSequence μ S r) + (g : ℝ → ℝ) (hg : Measurable g) (c C : ℝ) (hC : ∀ y, |g y| ≤ C) + (hc : ∀ ε : ℝ, 0 < ε → ∃ δ : ℝ, 0 < δ ∧ δ ≤ 1 ∧ + ∀ y, |y| ≤ δ → |g y-c*y^2| ≤ ε*y^2) : + Tendsto (fun i => fluctuationScale μ S (r i) * ∫ x, g (S x/r i) ∂μ) + atTop (𝓝 c) := by + have hC0 : 0 ≤ C := (abs_nonneg (g 0)).trans (hC 0) + have hIg (i : ℕ) : Integrable (fun x => g (S x/r i)) μ := + (integrable_const C).mono' ((hg.comp (hS.div_const _)).aestronglyMeasurable) + (Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs] using hC (S x/r i)) + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨δ,hδ,hδ1,hlocal⟩ := hc (ε/2) (by positivity) + have htail : Tendsto (fun i => (C+|c|) * + (fluctuationScale μ S (r i) * μ.real {x | δ*r i < |S x|})) atTop (𝓝 0) := by + simpa using (hr.2 δ hδ).const_mul (C+|c|) + have ht := (tendsto_order.mp htail).2 (ε/2) (by positivity) + filter_upwards [hr.1.eventually (eventually_gt_atTop (0:ℝ)),ht] with i hri hti + let Y : Ω → ℝ := fun x => S x/r i + let A : Set Ω := {x | δ*r i < |S x|} + have hA : MeasurableSet A := measurableSet_lt measurable_const hS.abs + have hY : Measurable Y := hS.div_const _ + have hmt : Integrable (fun x => min ((Y x)^2) 1) μ := by + simpa using integrable_truncated_square μ Y hY 1 + have hE : ∀ x, |g (Y x)-c*min ((Y x)^2) 1| ≤ + (ε/2)*min ((Y x)^2) 1 + A.indicator (fun _ => C+|c|) x := by + intro x + by_cases hx : x ∈ A + · rw [Set.indicator_of_mem hx] + have hm0 : 0 ≤ min ((Y x)^2) 1 := le_min (sq_nonneg _) zero_le_one + have hm1 : min ((Y x)^2) 1 ≤ 1 := min_le_right .. + have hb := (abs_sub (g (Y x)) (c*min ((Y x)^2) 1)).trans + (add_le_add (hC (Y x)) (le_of_eq (abs_mul c _))) + rw [abs_of_nonneg hm0] at hb + nlinarith [abs_nonneg c] + · rw [Set.indicator_of_notMem hx,add_zero] + have hxy : |Y x| ≤ δ := by + rw [show Y x = S x/r i from rfl,abs_div,abs_of_pos hri,div_le_iff₀ hri] + exact le_of_not_gt hx + have hx1 : (Y x)^2 ≤ 1 := by nlinarith [sq_abs (Y x),abs_nonneg (Y x)] + rw [min_eq_left hx1] + exact hlocal _ hxy + have hInt : |(∫ x, g (Y x) ∂μ)-c*truncatedVariance μ Y 1| ≤ + ε/2*truncatedVariance μ Y 1 + (C+|c|)*μ.real A := by + simp only [truncatedVariance,one_pow] + rw [← integral_const_mul,← integral_sub (hIg i) (hmt.const_mul c)] + calc + _ ≤ ∫ x, |g (Y x)-c*min ((Y x)^2) 1| ∂μ := abs_integral_le_integral_abs + _ ≤ ∫ x, (ε/2)*min ((Y x)^2) 1 + A.indicator (fun _ => C+|c|) x ∂μ := + integral_mono ((hIg i).sub (hmt.const_mul c)).abs + ((hmt.const_mul (ε/2)).add ((integrable_const (C+|c|)).indicator hA)) hE + _ = _ := by + rw [integral_add (hmt.const_mul (ε/2)) ((integrable_const (C+|c|)).indicator hA), + integral_const_mul,integral_indicator hA,integral_const] + simp [smul_eq_mul,mul_comm,Measure.real] + have hmpos := truncatedVariance_pos μ S hS hne hri + have hnpos : 0 < fluctuationScale μ S (r i) := div_pos (sq_pos_of_pos hri) hmpos + have hnorm : fluctuationScale μ S (r i)*truncatedVariance μ Y 1 = 1 := by + rw [show Y = (fun x => S x/r i) from rfl,truncatedVariance_div μ S hri,fluctuationScale] + field_simp + have hbound := mul_le_mul_of_nonneg_left hInt hnpos.le + rw [Real.dist_eq] + have hrew : fluctuationScale μ S (r i)*( (∫ x, g (Y x) ∂μ)-c*truncatedVariance μ Y 1) = + fluctuationScale μ S (r i)*(∫ x, g (Y x) ∂μ)-c := by + rw [mul_sub] + congr 1 + calc + _ = c*(fluctuationScale μ S (r i)*truncatedVariance μ Y 1) := by ring + _ = c := by rw [hnorm,mul_one] + have hab : |fluctuationScale μ S (r i)*( (∫ x, g (Y x) ∂μ)-c*truncatedVariance μ Y 1)| = + fluctuationScale μ S (r i)*|(∫ x, g (Y x) ∂μ)-c*truncatedVariance μ Y 1| := by + rw [abs_mul,abs_of_pos hnpos] + rw [← hab,hrew] at hbound + have hrw : fluctuationScale μ S (r i) * + (ε/2*truncatedVariance μ Y 1 + (C+|c|)*μ.real A) = + ε/2+(C+|c|)*(fluctuationScale μ S (r i)*μ.real A) := by + calc + _ = ε/2*(fluctuationScale μ S (r i)*truncatedVariance μ Y 1) + + (C+|c|)*(fluctuationScale μ S (r i)*μ.real A) := by ring + _ = _ := by rw [hnorm,mul_one] + rw [hrw] at hbound + exact hbound.trans_lt (by linarith) + +lemma gaussian_cosine_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) (r : ℕ → ℝ) (hr : IsGaussianSequence μ S r) (t : ℝ) : + Tendsto (fun i => fluctuationScale μ S (r i) * ∫ x, 1-Real.cos (t*(S x/r i)) ∂μ) + atTop (𝓝 (t^2/2)) := by + apply gaussian_quadratic_integral μ S hS hne r hr + (fun y => 1-Real.cos (t*y)) (by fun_prop) (t^2/2) 2 + · intro y + rw [abs_of_nonneg (sub_nonneg.mpr (Real.cos_le_one _))] + linarith [Real.neg_one_le_cos (t*y)] + · exact fun ε hε => cosine_quadratic_local t hε + +lemma symmetric_sine_integral {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (S : Ω → ℝ) (hsym : IdentDistrib S (fun x => -S x) μ μ) (t : ℝ) : + (∫ x, Real.sin (t*S x) ∂μ) = 0 := by + have he := (hsym.comp (u := fun y : ℝ => Real.sin (t*y)) (by fun_prop)).integral_eq + simp only [Function.comp_def,mul_neg,Real.sin_neg,integral_neg] at he + linarith + +lemma symmetric_charFun_cosine {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hsym : IdentDistrib S (fun x => -S x) μ μ) (t : ℝ) : + charFun (μ.map S) t = ((∫ x, Real.cos (t*S x) ∂μ : ℝ) : ℂ) := by + have hI : Integrable (fun x => Complex.exp ((t*S x : ℝ)*Complex.I)) μ := by + apply (integrable_const (1:ℝ)).mono' (by fun_prop) + exact Eventually.of_forall fun x => (Complex.norm_exp_ofReal_mul_I (t*S x)).le + rw [charFun_apply_real,integral_map hS.aemeasurable (by fun_prop)] + simp only [← Complex.ofReal_mul] + apply Complex.ext + · simpa only [RCLike.re_to_complex, Complex.exp_ofReal_mul_I, Complex.add_re, + Complex.ofReal_re, Complex.mul_re, Complex.ofReal_im, Complex.I_re, Complex.I_im, + mul_zero, zero_mul, sub_zero, add_zero] using (integral_re hI).symm + · have he := (integral_im hI).symm + simpa only [RCLike.im_to_complex, Complex.exp_ofReal_mul_I, Complex.add_im, + Complex.ofReal_im, Complex.mul_im, Complex.ofReal_re, Complex.I_re, Complex.I_im, + mul_zero, mul_one, zero_mul, add_zero, zero_add, + symmetric_sine_integral μ S hsym t] using he + +lemma gaussian_cosine_drift {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) (r : ℕ → ℝ) (hr : IsGaussianSequence μ S r) (t : ℝ) : + Tendsto (fun i => fluctuationScale μ S (r i) * + ((∫ x, Real.cos (t*(S x/r i)) ∂μ)-1)) atTop (𝓝 (-(t^2/2))) := by + have hcos (i : ℕ) : Integrable (fun x => Real.cos (t*(S x/r i))) μ := + (integrable_const (1:ℝ)).mono' (by fun_prop) + (Eventually.of_forall fun _ => by simpa only [Real.norm_eq_abs] using Real.abs_cos_le_one _) + convert (gaussian_cosine_limit μ S hS hne r hr t).neg using 1 + ext i + rw [integral_sub (integrable_const 1) (hcos i),integral_const] + simp only [probReal_univ,one_smul] + ring + +lemma tendsto_pow_variable_of_drift {a : ℕ → ℝ} {k : ℕ → ℕ} {c : ℝ} + (ha : Tendsto a atTop (𝓝 1)) + (hd : Tendsto (fun i => (k i : ℝ)*(a i-1)) atTop (𝓝 c)) : + Tendsto (fun i => (a i)^(k i)) atTop (𝓝 (Real.exp c)) := by + have hds : Tendsto (fun i => dslope Real.log 1 (a i)) atTop (𝓝 1) := by + have h := (continuousAt_dslope_same.mpr (Real.differentiableAt_log one_ne_zero)).tendsto.comp ha + simpa [Real.deriv_log,Function.comp_def] using h + have hlog : Tendsto (fun i => (k i : ℝ)*Real.log (a i)) atTop (𝓝 c) := by + convert hd.mul hds using 1 + · ext i + have he := sub_smul_dslope Real.log 1 (a i) + simp only [smul_eq_mul,Real.log_one,sub_zero] at he + rw [mul_assoc,he] + · simp + apply (Real.continuous_exp.tendsto c |>.comp hlog).congr' + filter_upwards [(tendsto_order.mp ha).1 0 zero_lt_one] with i hi + dsimp only [Function.comp_def] + rw [Real.exp_nat_mul,Real.exp_log hi] + +lemma gaussian_cosine_power_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hI : Integrable S μ) (hne : 0 < μ {x | S x ≠ 0}) (r : ℕ → ℝ) + (hr : IsGaussianSequence μ S r) {τ : ℝ} (hτ : 0 ≤ τ) (t : ℝ) : + Tendsto (fun i => (∫ x, Real.cos (t*(S x/r i)) ∂μ)^(⌊τ*fluctuationScale μ S (r i)⌋₊)) + atTop (𝓝 (Real.exp (-(τ*t^2/2)))) := by + have hn : Tendsto (fun i => fluctuationScale μ S (r i)) atTop atTop := + (fluctuationScale_tendsto μ S hS hI hne).comp hr.1 + have hd := gaussian_cosine_drift μ S hS hne r hr t + have hzero : Tendsto (fun i => (∫ x, Real.cos (t*(S x/r i)) ∂μ)-1) atTop (𝓝 0) := by + have hz := hd.mul (tendsto_inv_atTop_zero.comp hn) + simp only [mul_zero] at hz + apply hz.congr' + filter_upwards [hn.eventually (eventually_gt_atTop (0:ℝ))] with i hi + dsimp only [Function.comp_def] + field_simp + have ha : Tendsto (fun i => ∫ x, Real.cos (t*(S x/r i)) ∂μ) atTop (𝓝 1) := by + simpa using hzero.add_const 1 + have hk := (tendsto_nat_floor_mul_div_atTop hτ).comp hn + have hdk : Tendsto (fun i => (⌊τ*fluctuationScale μ S (r i)⌋₊ : ℝ)* + ((∫ x, Real.cos (t*(S x/r i)) ∂μ)-1)) atTop (𝓝 (-(τ*t^2/2))) := by + have hc := hk.mul hd + have he : τ * (-(t^2/2)) = -(τ*t^2/2) := by ring + rw [he] at hc + apply hc.congr' + filter_upwards [hn.eventually (eventually_gt_atTop (0:ℝ))] with i hi + dsimp only [Function.comp_def] + field_simp + exact tendsto_pow_variable_of_drift ha hdk + +lemma gaussian_charFun_power_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hI : Integrable S μ) (hne : 0 < μ {x | S x ≠ 0}) + (hsym : IdentDistrib S (fun x => -S x) μ μ) (r : ℕ → ℝ) + (hr : IsGaussianSequence μ S r) {τ : ℝ} (hτ : 0 ≤ τ) (t : ℝ) : + Tendsto (fun i => (charFun (μ.map S) (t/r i))^(⌊τ*fluctuationScale μ S (r i)⌋₊)) + atTop (𝓝 (Complex.exp (-(τ*t^2/2 : ℝ)))) := by + convert (gaussian_cosine_power_limit μ S hS hI hne r hr hτ t).ofReal using 1 + · ext i + rw [symmetric_charFun_cosine μ S hS hsym] + rw [← Complex.ofReal_pow] + congr 2 + apply integral_congr_ae + filter_upwards [] with x + congr 1 + ring + · simp + +lemma charFun_div_partialSum {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : ℕ → Ω → ℝ) (hind : iIndepFun X μ) + (hident : ∀ i, IdentDistrib (X i) (X 0) μ μ) (n : ℕ) (r t : ℝ) : + charFun (μ.map (fun ω => realPartialSum (fun k => X k ω) n / r)) t = + (charFun (μ.map (X 0)) (t/r)) ^ n := by + have hm i := (hident i).aemeasurable_fst + simp only [realPartialSum,div_eq_inv_mul] + rw [charFun_map_mul_comp, (hind.restrict _).charFun_map_fun_finsetSum_eq_prod (fun _ _ => hm _)] + · simp [fun i => (hident i).map_eq] + · exact Finset.aemeasurable_fun_sum _ fun _ _ => hm _ + +theorem gaussian_iid_marginal_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {x | X 0 x ≠ 0}) + (hsym : IdentDistrib (X 0) (fun x => -X 0 x) μ μ) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) (τ : ℝ≥0) : + TendstoInDistribution + (fun i ω => realPartialSum (fun k => X k ω) + (⌊(τ:ℝ)*fluctuationScale μ (X 0) (r i)⌋₊) / r i) + atTop id (fun _ => μ) (gaussianReal 0 τ) where + forall_aemeasurable i := + (Finset.aemeasurable_fun_sum _ fun k _ => (hX k).aemeasurable).div_const _ + tendsto := by + refine ProbabilityMeasure.tendsto_iff_tendsto_charFun.2 fun t => ?_ + change Tendsto (fun i => charFun (μ.map (fun ω => realPartialSum (fun k => X k ω) + (⌊(τ:ℝ)*fluctuationScale μ (X 0) (r i)⌋₊) / r i)) t) atTop + (𝓝 (charFun ((gaussianReal 0 τ).map id) t)) + simp only [Measure.map_id, charFun_div_partialSum μ X hind hident, + charFun_gaussianReal, Complex.ofReal_zero, mul_zero, zero_mul, zero_sub] + convert gaussian_charFun_power_limit μ (X 0) (hX 0) hI hne hsym r hr τ.coe_nonneg t using 1 + norm_cast + +theorem independent_common_gaussian_marginal {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) + (hne : 0 < independentConditionedPairLaw ν ℓ {P | commonIncrementProcess ℓ e 0 P ≠ 0}) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ e 0) r) (τ : ℝ≥0) : + letI : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + TendstoInDistribution + (fun i P => realPartialSum (fun k => commonIncrementProcess ℓ e k P) + (⌊(τ:ℝ)*fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ e 0) (r i)⌋₊) / r i) + atTop id (fun _ => independentConditionedPairLaw ν ℓ) (gaussianReal 0 τ) := by + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + exact gaussian_iid_marginal_limit _ _ (measurable_commonIncrementProcess ℓ e) + (commonIncrements_independent ν ℓ htrans height hproj hstep e) + (commonIncrements_identDistrib ν ℓ htrans height hproj hstep e) + (independent_commonWordIncrement_integrable ν hue ℓ hℓ htrans height hproj hstep e) hne + (independent_commonWordIncrement_symmetric ν ℓ htrans e) r hr τ + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/InteriorPairMeasureExt.lean b/lean/OAI/Probability/Ballisticity/Estimates/InteriorPairMeasureExt.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9227c6dce795ec461094fddba43b3cb79a4f8b5 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/InteriorPairMeasureExt.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ProductNormalJointPast + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def shrinkTime (n : ℕ) (t : unitInterval) : unitInterval := + ⟨((n:ℝ)+1)/((n:ℝ)+2)*(t:ℝ),by + have hn : 0 ≤ ((n:ℝ)+1)/((n:ℝ)+2) := by positivity + have hle : ((n:ℝ)+1)/((n:ℝ)+2) ≤ 1 := (div_le_one (by positivity)).mpr (by linarith) + exact ⟨mul_nonneg hn t.property.1,(mul_le_mul_of_nonneg_left t.property.2 hn).trans (by simpa using hle)⟩⟩ + +lemma shrinkTime_lt_one (n : ℕ) (t : unitInterval) : (shrinkTime n t:ℝ) < 1 := by + have hn : 0 ≤ ((n:ℝ)+1)/((n:ℝ)+2) := by positivity + have hlt : ((n:ℝ)+1)/((n:ℝ)+2) < 1 := (div_lt_one (by positivity)).mpr (by linarith) + exact (mul_le_mul_of_nonneg_left t.property.2 hn).trans_lt (by simpa using hlt) + +lemma shrinkTime_tendsto (t : unitInterval) : Tendsto (fun n => shrinkTime n t) atTop (𝓝 t) := by + have hh : Tendsto (fun n : ℕ => (1:ℝ)/((n:ℝ)+2)) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop (tendsto_atTop_add_const_right atTop 2 tendsto_natCast_atTop_atTop) + apply tendsto_subtype_rng.mpr + have hc := ((tendsto_const_nhds (x := (1:ℝ))).sub hh).mul_const (t:ℝ) + simp only [sub_zero,one_mul] at hc + convert hc using 1 + funext n + change ((n:ℝ)+1)/((n:ℝ)+2)*(t:ℝ)=(1-1/((n:ℝ)+2))*(t:ℝ) + field_simp + ring + +lemma interior_pair_measure_ext (μ ν : Measure RealPathPair) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] + (h : ∀ I : Finset unitInterval, (∀ t ∈ I,(t:ℝ) < 1) → + μ.map (pairRestricted I)=ν.map (pairRestricted I)) : μ=ν := by + let e := TopologicalSpace.denseSeq unitInterval + let f := fun j : ℕ × ℕ => shrinkTime j.2 (e j.1) + let E := fun P : RealPathPair => fun j : ℕ × ℕ => (P.1 (f j),P.2 (f j)) + have hE : Continuous E := by fun_prop + have hEinj : Function.Injective E := by + intro P Q hPQ + have hcoord (n : ℕ) : (P.1 (e n),P.2 (e n))=(Q.1 (e n),Q.2 (e n)) := by + have hp : Tendsto (fun m => (P.1 (shrinkTime m (e n)),P.2 (shrinkTime m (e n)))) atTop + (𝓝 (P.1 (e n),P.2 (e n))) := + ((P.1.continuous.prodMk P.2.continuous).tendsto (e n)).comp (shrinkTime_tendsto (e n)) + have hq : Tendsto (fun m => (Q.1 (shrinkTime m (e n)),Q.2 (shrinkTime m (e n)))) atTop + (𝓝 (Q.1 (e n),Q.2 (e n))) := + ((Q.1.continuous.prodMk Q.2.continuous).tendsto (e n)).comp (shrinkTime_tendsto (e n)) + apply tendsto_nhds_unique hp + apply hq.congr + intro m + exact (congrFun hPQ (n,m)).symm + apply Prod.ext + · apply ContinuousMap.coe_injective + exact (TopologicalSpace.denseRange_denseSeq unitInterval).equalizer P.1.continuous Q.1.continuous + (funext fun n => congrArg Prod.fst (hcoord n)) + · apply ContinuousMap.coe_injective + exact (TopologicalSpace.denseRange_denseSeq unitInterval).equalizer P.2.continuous Q.2.continuous + (funext fun n => congrArg Prod.snd (hcoord n)) + apply hE.measurableEmbedding hEinj |>.map_injective + let P := fun J : Finset (ℕ × ℕ) => (μ.map E).map J.restrict + have : ∀ J, IsFiniteMeasure (P J) := fun _ => inferInstance + apply IsProjectiveLimit.unique (P := P) (fun _ => rfl) + intro J + let I := J.image f + let g := fun z : I → ℝ × ℝ => fun j : J => z ⟨f j,Finset.mem_image_of_mem f j.property⟩ + have hg : Measurable g := by fun_prop + have hm : Measurable (J.restrict : ((ℕ × ℕ) → ℝ × ℝ) → (J → ℝ × ℝ)) := by fun_prop + change (ν.map E).map J.restrict=(μ.map E).map J.restrict + rw [Measure.map_map hm hE.measurable,Measure.map_map hm hE.measurable] + have he : J.restrict ∘ E=g ∘ pairRestricted I := rfl + rw [he,← Measure.map_map hg (pairRestricted I).continuous.measurable, + ← Measure.map_map hg (pairRestricted I).continuous.measurable,h I] + intro t ht + obtain ⟨j,hj,rfl⟩ := Finset.mem_image.mp ht + exact shrinkTime_lt_one j.2 (e j.1) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/JointMeshPhase.lean b/lean/OAI/Probability/Ballisticity/Estimates/JointMeshPhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ffca15755fc35d821af9d5578673595cf07ad1e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/JointMeshPhase.lean @@ -0,0 +1,156 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.PastPhaseExtension +import OAI.Probability.Ballisticity.Crossings.CutoffTimeAverages + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma normalJointPast_mesh_phase_bound {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + {A K : ℝ} (hK : 0 ≤ K) (hcross : SeparatedCrossBound μ A K) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) + {ρ : ℝ} (hρ : 0 < ρ) {n : ℕ} (hn : 0 < n) + (hnlarge : ((c:ℝ)*(a^2+b^2)/2)*(((t:ℝ)-s)/n) ≤ 1) : + ‖(∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)- + (1-((((c:ℝ)*(a^2+b^2)/2)*(((t:ℝ)-s)/n):ℝ):ℂ))^n* + (∫ P, F (pairPastCoordinates v P) ∂μ)‖ ≤ + ‖F‖*(2*|a*b| *K*(n:ℝ)*Real.exp (-A*ρ^2/(((t:ℝ)-s)/n))+ + jointTaylorCoeff a b*(n:ℝ)*(Real.sqrt ((c:ℝ)*(((t:ℝ)-s)/n)))^3+ + 2*|a*b| *(c:ℝ)*(∑ j ∈ Finset.range n, ((t:ℝ)-s)/n* + cutoffMeanExtension μ ρ (realMesh s t n j))) := by + let δ := ((t:ℝ)-s)/n + let r : ℂ := 1-((((c:ℝ)*(a^2+b^2)/2)*δ:ℝ):ℂ) + let z : ℕ → ℂ := fun j => ∫ P, F (pairPastCoordinates v P)* + charPhase (pairLinearIncrement a b s (unitMesh s t n j) P) ∂μ + let D := 2*|a*b| *K*Real.exp (-A*ρ^2/δ)+jointTaylorCoeff a b*(Real.sqrt ((c:ℝ)*δ))^3 + let C := 2*|a*b| *(c:ℝ) + let e : ℕ → ℝ := fun j => ‖F‖*(D+C*δ*cutoffMeanExtension μ ρ (realMesh s t n j)) + have hz0 : z 0=∫ P, F (pairPastCoordinates v P) ∂μ := by + dsimp [z] + rw [unitMesh_zero] + simp only [pairLinearIncrement,pairPathIncrement,ContinuousMap.coe_mk,Bool.false_eq_true, + ↓reduceIte,sub_self,mul_zero,add_zero,charPhase,Complex.ofReal_zero,zero_mul,Complex.exp_zero,mul_one] + have hzn : z n=∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ := by + simp only [z,unitMesh_last s t hn] + have hδ : 0 ≤ δ := div_nonneg (sub_nonneg.mpr (show (s:ℝ) ≤ t from hst.le)) (Nat.cast_nonneg n) + have hc : 0 ≤ (c:ℝ)*(a^2+b^2)/2 := by positivity + have hr : ‖r‖ ≤ 1 := realEulerCoefficient_norm hc hδ hnlarge + have he : ∀ j < n, ‖z (j+1)-r*z j‖ ≤ e j := by + intro j hj + have hju := unitMesh_between s t hst.le hn hj.le + have hjv := unitMesh_between s t hst.le hn (Nat.succ_le_of_lt hj) + have hh := normalJointPast_cumulative_phase_step μ c h hK hcross v s + (unitMesh s t n j) (unitMesh s t n (j+1)) hv hju.1 + (unitMesh_step_lt s t hst hn hj) (lt_of_le_of_lt hjv.2 ht) F a b hρ + rw [unitMesh_sub s t hst.le hn hj] at hh + have hcoef : 1-((((c:ℝ)*δ*(a^2+b^2)/2):ℝ):ℂ)=r := by + dsimp [r] + congr 1 + ring_nf + change ‖z (j+1)-(1-((((c:ℝ)*δ*(a^2+b^2)/2):ℝ):ℂ))*z j‖ ≤ _ at hh + rw [hcoef] at hh + have hcut : (∫ P : RealPathPair, nearDiagonalCutoff ρ + (P.1 (unitMesh s t n j)-P.2 (unitMesh s t n j)) ∂μ)= + cutoffMeanExtension μ ρ (realMesh s t n j) := rfl + rw [hcut] at hh + convert hh using 1 + have hh := contraction_recurrence_error z r e n hr he + rw [hz0,hzn] at hh + calc + _ ≤ ∑ j ∈ Finset.range n, e j := hh + _ = _ := by + simp only [e,mul_add,Finset.sum_add_distrib,← Finset.mul_sum,Finset.sum_const, + Finset.card_range,nsmul_eq_mul] + dsimp [D,C,δ] + ring + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma complexEuler_tendsto (lam L : ℝ) : + Tendsto (fun n : ℕ => (1-((lam*(L/n):ℝ):ℂ))^n) atTop + (𝓝 (Complex.exp ((-lam*L:ℝ):ℂ))) := by + convert Complex.tendsto_one_add_div_pow_exp (((-lam*L:ℝ):ℂ)) using 1 + funext n + congr 1 + push_cast + ring + +lemma normalJointPast_phase_bound {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + {A K : ℝ} (hA : 0 < A) (hK : 0 ≤ K) (hcross : SeparatedCrossBound μ A K) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) + {ρ : ℝ} (hρ : 0 < ρ) : + ‖(∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)- + Complex.exp ((-((c:ℝ)*(a^2+b^2)/2)*((t:ℝ)-s):ℝ):ℂ)* + (∫ P, F (pairPastCoordinates v P) ∂μ)‖ ≤ + ‖F‖*(2*|a*b| *(c:ℝ)*(∫ u in (s:ℝ)..t, cutoffMeanExtension μ ρ u)) := by + let lam := (c:ℝ)*(a^2+b^2)/2 + let L := (t:ℝ)-s + have hL : 0 < L := sub_pos.mpr hst + have hEu := complexEuler_tendsto lam L + have hleft := ((tendsto_const_nhds.sub (hEu.mul_const + (∫ P, F (pairPastCoordinates v P) ∂μ))).norm : + Tendsto (fun n : ℕ => ‖(∫ P, F (pairPastCoordinates v P)* + charPhase (pairLinearIncrement a b s t P) ∂μ)- + (1-((lam*(L/n):ℝ):ℂ))^n*(∫ P, F (pairPastCoordinates v P) ∂μ)‖) atTop + (𝓝 ‖(∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)- + Complex.exp ((-lam*L:ℝ):ℂ)*(∫ P, F (pairPastCoordinates v P) ∂μ)‖)) + have hex := (scaled_exp_tendsto_zero (mul_pos hA (sq_pos_of_pos hρ)) hL).const_mul (2*|a*b| *K) + have hcu := (scaled_sqrt_cube_tendsto_zero c.coe_nonneg hL.le).const_mul (jointTaylorCoeff a b) + have hri := (cutoff_riemann_tendsto μ ρ hst).const_mul (2*|a*b| *(c:ℝ)) + have hr := ((hex.add hcu).add hri).const_mul ‖F‖ + simp only [mul_zero,zero_add] at hr + have hnlarge : ∀ᶠ n : ℕ in atTop, lam*(L/n) ≤ 1 := by + have hh : Tendsto (fun n : ℕ => lam*(L/n)) atTop (𝓝 0) := by + simpa using (tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop : + Tendsto (fun n : ℕ => L/(n:ℝ)) atTop (𝓝 0)).const_mul lam + exact (hh.eventually_lt_const zero_lt_one).mono (fun n hn => hn.le) + apply le_of_tendsto_of_tendsto hleft hr + filter_upwards [eventually_gt_atTop 0,hnlarge] with n hn hnl + have hh := normalJointPast_mesh_phase_bound μ c h hK hcross v s t hv hst ht F a b hρ hn hnl + simpa only [lam,L,neg_mul,mul_assoc] using hh + +lemma normalJointPast_joint_characteristic {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + {A K : ℝ} (hA : 0 < A) (hK : 0 ≤ K) (hcross : SeparatedCrossBound μ A K) + (hz : (μ.prod volume) {z : RealPathPair × unitInterval | z.1.1 z.2-z.1.2 z.2=0}=0) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + (∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)= + Complex.exp ((-((c:ℝ)*(a^2+b^2)/2)*((t:ℝ)-s):ℝ):ℂ)* + (∫ P, F (pairPastCoordinates v P) ∂μ) := by + apply sub_eq_zero.mp + apply norm_eq_zero.mp + apply le_antisymm _ (norm_nonneg _) + have hh := ((diagonal_zero_subinterval_cutoff_tendsto μ hz s t hst.le).const_mul + (2*|a*b| *(c:ℝ))).const_mul ‖F‖ + simp only [mul_zero] at hh + apply ge_of_tendsto hh + filter_upwards [] with n + exact normalJointPast_phase_bound μ c h hA hK hcross v s t hv hst ht F a b + (by positivity : 0 < 1/((n:ℝ)+1)) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/JointPastMoments.lean b/lean/OAI/Probability/Ballisticity/Estimates/JointPastMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd21d49015df3268f1803fae9b107f9f269efce0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/JointPastMoments.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ConditionalLawTests + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +noncomputable def pairPastCoordinates {q : ℕ} (v : Fin q → unitInterval) : + C(RealPathPair,Fin q → ℝ × ℝ) := + ⟨fun P z => (P.1 (v z),P.2 (v z)),by fun_prop⟩ + +noncomputable def pairPathIncrement (b : Bool) (s t : unitInterval) : C(RealPathPair,ℝ) := + ⟨fun P => if b then P.2 t-P.2 s else P.1 t-P.1 s,by cases b <;> simp <;> fun_prop⟩ + +lemma jointPastIncrementMap_eq {q : ℕ} (b : Bool) (P : RealPathPair) + (v : Fin q → unitInterval) (s t : unitInterval) : + jointPastIncrementMap b (P,(v,s,t))=(pairPastCoordinates v P,pairPathIncrement b s t P) := rfl + +def NormalJointPast (μ : Measure RealPathPair) (c : ℝ≥0) : Prop := + ∀ (q : ℕ) (v : Fin q → unitInterval) (s t : unitInterval), + (∀ z, v z ≤ s) → s < t → (t:ℝ) < 1 → ∀ b : Bool, + μ.map (fun P => (pairPastCoordinates v P,pairPathIncrement b s t P)) = + (μ.map (pairPastCoordinates v)).prod (gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s))) + +lemma normal_past_of_uc_tests (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) + (h : ∀ (q : ℕ) (v : Fin q → unitInterval) (s t : unitInterval), + (∀ z, v z ≤ s) → s < t → (t:ℝ) < 1 → ∀ (b : Bool) + (F : (Fin q → ℝ × ℝ) →ᵇ ℝ) (G : ℝ →ᵇ ℝ), UniformContinuous G → + (∫ P, jointPastProductTest F G (∫ z, G z ∂gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s))) + (jointPastIncrementMap b (P,(v,s,t))) ∂μ)=0) : NormalJointPast μ c := by + intro q v s t hv hst ht b + apply product_law_of_uc_decorrelation μ _ (pairPastCoordinates v) (pairPathIncrement b s t) + (pairPastCoordinates v).continuous.measurable (pairPathIncrement b s t).continuous.measurable + intro F G hG + exact h q v s t hv hst ht b F G hG + +lemma product_law_integral_mul {Ω E : Type*} [MeasurableSpace Ω] [MeasurableSpace E] + {K : Type*} [RCLike K] (μ : Measure Ω) [IsFiniteMeasure μ] (γ : Measure ℝ) [SFinite γ] + (Z : Ω → E) (X : Ω → ℝ) (hZ : Measurable Z) (hX : Measurable X) + (hlaw : μ.map (fun ω => (Z ω,X ω))=(μ.map Z).prod γ) + (F : E → K) (G : ℝ → K) (hF : Measurable F) (hG : Measurable G) : + (∫ ω, F (Z ω)*G (X ω) ∂μ)=(∫ ω, F (Z ω) ∂μ)*(∫ z, G z ∂γ) := by + have hi := integral_map (μ := μ) (hZ.prodMk hX).aemeasurable + ((hF.comp measurable_fst).mul (hG.comp measurable_snd)).aestronglyMeasurable + change (∫ z : E × ℝ, F z.1*G z.2 ∂μ.map (fun ω => (Z ω,X ω)))= + (∫ ω, F (Z ω)*G (X ω) ∂μ) at hi + rw [← hi,hlaw,integral_prod_mul,integral_map hZ.aemeasurable hF.aestronglyMeasurable] + +lemma product_law_integrable_mul {Ω E : Type*} [MeasurableSpace Ω] [MeasurableSpace E] + {K : Type*} [RCLike K] (μ : Measure Ω) [IsFiniteMeasure μ] (γ : Measure ℝ) [SFinite γ] + (Z : Ω → E) (X : Ω → ℝ) (hZ : Measurable Z) (hX : Measurable X) + (hlaw : μ.map (fun ω => (Z ω,X ω))=(μ.map Z).prod γ) + (F : E → K) (G : ℝ → K) (hF : Measurable F) (hG : Measurable G) + (hIF : Integrable F (μ.map Z)) (hIG : Integrable G γ) : + Integrable (fun ω => F (Z ω)*G (X ω)) μ := by + have hi : Integrable (fun z : E × ℝ => F z.1*G z.2) ((μ.map Z).prod γ) := hIF.mul_prod hIG + rw [← hlaw] at hi + exact (integrable_map_measure ((hF.comp measurable_fst).mul (hG.comp measurable_snd)).aestronglyMeasurable + (hZ.prodMk hX).aemeasurable).mp hi + +lemma normalJointPast_moment {q k : ℕ} (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) (v : Fin q → unitInterval) (s t : unitInterval) + (hv : ∀ z, v z ≤ s) (hst : s < t) (ht : (t:ℝ) < 1) (b : Bool) + (F : (Fin q → ℝ × ℝ) →ᵇ ℝ) : + (∫ P, F (pairPastCoordinates v P)*(pairPathIncrement b s t P)^k ∂μ)= + (∫ P, F (pairPastCoordinates v P) ∂μ)*(∫ z : ℝ, z^k ∂gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s))) := by + exact product_law_integral_mul μ _ _ _ (pairPastCoordinates v).continuous.measurable + (pairPathIncrement b s t).continuous.measurable (h q v s t hv hst ht b) F (fun z => z^k) + F.continuous.measurable (by fun_prop) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma gaussianReal_second_moment (v : ℝ≥0) : + (∫ z : ℝ, z^2 ∂gaussianReal 0 v) = v := by + have h := variance_fun_id_gaussianReal (μ := 0) (v := v) + rw [variance_eq_integral measurable_id'.aemeasurable] at h + simpa using h + +lemma normalJointPast_hasLaw {q : ℕ} (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) (v : Fin q → unitInterval) (s t : unitInterval) + (hv : ∀ z, v z ≤ s) (hst : s < t) (ht : (t:ℝ) < 1) (b : Bool) : + HasLaw (pairPathIncrement b s t) (gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s))) μ := by + have hp := h q v s t hv hst ht b + have he := congrArg (fun ξ : Measure ((Fin q → ℝ × ℝ) × ℝ) => ξ.map Prod.snd) hp + rw [Measure.map_map measurable_snd ((pairPastCoordinates v).continuous.measurable.prodMk + (pairPathIncrement b s t).continuous.measurable)] at he + refine ⟨(pairPathIncrement b s t).continuous.measurable.aemeasurable,?_⟩ + simpa [Measure.map_apply (pairPastCoordinates v).continuous.measurable,Function.comp_def] using he + +lemma normalJointPast_integrable_abs_pow (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) (s t : unitInterval) + (hst : s < t) (ht : (t:ℝ) < 1) (b : Bool) (k : ℕ) : + Integrable (fun P => |pairPathIncrement b s t P|^k) μ := by + have hl := normalJointPast_hasLaw μ c h (fun _ : Fin 0 => s) s t (by simp) hst ht b + have hi := gaussian_absolute_moment_integrable (c*Real.toNNReal ((t:ℝ)-s)) k + rw [← hl.map_eq] at hi + exact (integrable_map_measure (by fun_prop : Measurable (fun z : ℝ => |z|^k)).aestronglyMeasurable + hl.aemeasurable).mp hi + +lemma normalJointPast_absolute_third_moment (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) (s t : unitInterval) + (hst : s < t) (ht : (t:ℝ) < 1) (b : Bool) : + (∫ P, |pairPathIncrement b s t P|^3 ∂μ)= + (Real.sqrt ((c:ℝ)*((t:ℝ)-s)))^3*normalThirdMoment := by + have hl := normalJointPast_hasLaw μ c h (fun _ : Fin 0 => s) s t (by simp) hst ht b + have hi := hl.integral_comp (by fun_prop : Measurable (fun z : ℝ => |z|^3)).aestronglyMeasurable + change (∫ P, |pairPathIncrement b s t P|^3 ∂μ) = _ at hi + rw [hi,gaussian_absolute_third_moment] + rw [NNReal.coe_mul,Real.toNNReal_of_nonneg (sub_nonneg.mpr (show (s:ℝ) ≤ t from hst.le))] + rfl + +lemma normalJointPast_mean {q : ℕ} (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) (v : Fin q → unitInterval) (s t : unitInterval) + (hv : ∀ z, v z ≤ s) (hst : s < t) (ht : (t:ℝ) < 1) (b : Bool) + (F : (Fin q → ℝ × ℝ) →ᵇ ℝ) : + (∫ P, F (pairPastCoordinates v P)*pairPathIncrement b s t P ∂μ)=0 := by + simpa using normalJointPast_moment (k := 1) μ c h v s t hv hst ht b F + +lemma normalJointPast_second {q : ℕ} (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) (v : Fin q → unitInterval) (s t : unitInterval) + (hv : ∀ z, v z ≤ s) (hst : s < t) (ht : (t:ℝ) < 1) (b : Bool) + (F : (Fin q → ℝ × ℝ) →ᵇ ℝ) : + (∫ P, F (pairPastCoordinates v P)*(pairPathIncrement b s t P)^2 ∂μ)= + (∫ P, F (pairPastCoordinates v P) ∂μ)*((c:ℝ)*((t:ℝ)-s)) := by + rw [normalJointPast_moment μ c h v s t hv hst ht b F,gaussianReal_second_moment, + NNReal.coe_mul,Real.toNNReal_of_nonneg (sub_nonneg.mpr (show (s:ℝ) ≤ t from hst.le))] + rfl + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/JointPastRestart.lean b/lean/OAI/Probability/Ballisticity/Estimates/JointPastRestart.lean new file mode 100644 index 0000000000000000000000000000000000000000..629d0aaf173ca76a712cabbb510bba0900076bb2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/JointPastRestart.lean @@ -0,0 +1,187 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CommonBoundaryRestart + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +def BoundaryData (d : ℕ) := Σ q : ℕ × ℕ, + (((i : Finset.Iic q.1) → Lattice d) × ((i : Finset.Iic q.2) → Lattice d)) + +instance {d : ℕ} : Countable (BoundaryData d) := by unfold BoundaryData; infer_instance +instance {d : ℕ} : MeasurableSpace (BoundaryData d) := ⊤ +instance {d : ℕ} : DiscreteMeasurableSpace (BoundaryData d) := ⟨fun _ => trivial⟩ + +noncomputable def boundaryData {d : ℕ} (ℓ : Vector d) (H : ℝ) (P : Path d × Path d) : + BoundaryData d := ⟨boundaryTimes ℓ H P, + pairPrefix (boundaryTimes ℓ H P).1 (boundaryTimes ℓ H P).2 P⟩ + +lemma boundaryData_fiber {d : ℕ} (ℓ : Vector d) (H : ℝ) (F : BoundaryData d) : + boundaryData ℓ H ⁻¹' {F} = + (boundaryTimes ℓ H ⁻¹' {F.1}) ∩ (pairPrefix F.1.1 F.1.2 ⁻¹' {F.2}) := by + ext P + simp only [Set.mem_preimage,Set.mem_singleton_iff,Set.mem_inter_iff] + constructor + · intro he + have ht : boundaryTimes ℓ H P = F.1 := congrArg Sigma.fst he + refine ⟨ht,?_⟩ + cases F with + | mk q f => + dsimp only at ht ⊢ + unfold boundaryData at he + cases ht + exact Sigma.mk.inj_iff.mp he |>.2 |> eq_of_heq + · rintro ⟨ht,hf⟩ + cases F with + | mk q f => + dsimp only at ht hf ⊢ + unfold boundaryData + cases ht + exact congrArg (Sigma.mk _) hf + +lemma measurable_boundaryData {d : ℕ} (ℓ : Vector d) (H : ℝ) : + Measurable (boundaryData ℓ H) := by + apply measurable_to_countable' + intro F + rw [boundaryData_fiber] + exact ((measurable_boundaryTimes ℓ H) (measurableSet_singleton _)).inter + ((measurable_pairPrefix _ _) (measurableSet_singleton _)) + +noncomputable def boundarySuffix {d : ℕ} (ℓ : Vector d) (H : ℝ) (P : Path d × Path d) : + Path d × Path d := commonPairSuffix (boundaryTimes ℓ H P).1 (boundaryTimes ℓ H P).2 P + +lemma measurable_boundarySuffix {d : ℕ} (ℓ : Vector d) (H : ℝ) : + Measurable (boundarySuffix ℓ H) := by + have hm : Measurable (fun Z : (Path d × Path d) × (ℕ × ℕ) => + commonPairSuffix Z.2.1 Z.2.2 Z.1) := + measurable_from_prod_countable_left fun q => measurable_commonPairSuffix q.1 q.2 + exact hm.comp (measurable_id.prodMk (measurable_boundaryTimes ℓ H)) + +lemma boundaryData_times {d : ℕ} (ℓ : Vector d) (H : ℝ) (P : Path d × Path d) + (F : BoundaryData d) (hF : boundaryData ℓ H P = F) : + boundaryTimes ℓ H P = F.1 := congrArg Sigma.fst hF + +lemma boundaryAtom_fiber_ae {d : ℕ} (μ : Measure (Path d × Path d)) + (ℓ : Vector d) (H : ℝ) (x y : Lattice d) + (hD : ∀ᵐ P ∂μ, P.1 ∈ NoDrop ℓ x ∧ P.2 ∈ NoDrop ℓ y) + (hS : ∀ᵐ P ∂μ, BoundaryAt ℓ H P (boundaryTimes ℓ H P).1 (boundaryTimes ℓ H P).2) + (F : BoundaryData d) : + (boundaryData ℓ H ⁻¹' {F}) =ᵐ[μ] + boundaryAtom ℓ H x y (extendPrefix F.1.1 F.2.1) (extendPrefix F.1.2 F.2.2) F.1.1 F.1.2 := by + filter_upwards [hD,hS] with P hDP hSP + rw [boundaryData_fiber,pairPrefix_fiber] + apply propext + change (boundaryTimes ℓ H P = F.1 ∧ _) ↔ _ + constructor + · rintro ⟨ht,hpre⟩ + refine ⟨hpre,hDP,?_⟩ + change BoundaryAt ℓ H P F.1.1 F.1.2 + simpa only [ht] using hSP + · rintro ⟨hpre,hno,hB⟩ + exact ⟨boundaryTimes_eq ℓ H P hB,hpre⟩ + +lemma shared_boundaryData_map {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) + (x y : Lattice d) (hxy : height x = height y) (H : ℕ) (hH : 0 < H) + (F : BoundaryData d) : + ((sharedConditionedPairLaw ν ℓ x y).restrict + (boundaryData ℓ ((height x+H : ℤ) : ℝ) ⁻¹' {F})).map + (boundarySuffix ℓ ((height x+H : ℤ) : ℝ)) = + sharedConditionedPairLaw ν ℓ x y + (boundaryData ℓ ((height x+H : ℤ) : ℝ) ⁻¹' {F}) • + sharedConditionedPairLaw ν ℓ + (extendPrefix F.1.1 F.2.1 F.1.1) (extendPrefix F.1.2 F.2.2 F.1.2) := by + let μ := sharedConditionedPairLaw ν ℓ x y + let h : ℝ := ((height x+H : ℤ) : ℝ) + have hae := boundaryAtom_fiber_ae μ ℓ h x y (sharedConditionedPairLaw_noDrop ν ℓ x y) + (shared_boundaryTimes_spec ν hue ℓ hℓ htrans height hproj hstep x y hxy H hH) F + have hmap : (μ.restrict (boundaryData ℓ h ⁻¹' {F})).map (boundarySuffix ℓ h) = + (μ.restrict (boundaryData ℓ h ⁻¹' {F})).map (commonPairSuffix F.1.1 F.1.2) := by + apply Measure.map_congr + filter_upwards [ae_restrict_mem ((measurable_boundaryData ℓ h) (measurableSet_singleton F))] with P hP + have ht := boundaryData_times ℓ h P F hP + simp only [boundarySuffix,ht] + change (μ.restrict (boundaryData ℓ h ⁻¹' {F})).map _ = _ + rw [hmap,Measure.restrict_congr_set hae,measure_congr hae] + exact shared_boundaryAtom_map ν hue ℓ hℓ htrans h x y _ _ _ _ + +lemma lintegral_partition_countable {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [Countable I] [MeasurableSingletonClass I] (μ : Measure Ω) (D : Ω → I) (hD : Measurable D) + (f : Ω → ℝ≥0∞) : (∫⁻ a, f a ∂μ) = ∑' i, ∫⁻ a in D ⁻¹' {i}, f a ∂μ := by + have hu : (⋃ i, D ⁻¹' {i}) = Set.univ := by ext a; simp + have hd : Pairwise (fun i j : I => Disjoint (D ⁻¹' {i}) (D ⁻¹' {j})) := by + intro i j hij + apply Set.disjoint_left.mpr + intro a hi hj + exact hij (hi.symm.trans hj) + have hh := lintegral_iUnion (μ := μ) (fun i => hD (measurableSet_singleton i)) hd f + simpa only [hu,Measure.restrict_univ] using hh + +lemma lintegral_countable_restart {Ω I S : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [MeasurableSpace S] [Countable I] [MeasurableSingletonClass I] + (μ : Measure Ω) (D : Ω → I) (Y : Ω → S) (κ : I → Measure S) + (hD : Measurable D) (hY : Measurable Y) + (hrestart : ∀ i, (μ.restrict (D ⁻¹' {i})).map Y = μ (D ⁻¹' {i}) • κ i) + (f : I → ℝ≥0∞) (g : S → ℝ≥0∞) (hg : Measurable g) : + (∫⁻ a, f (D a) * g (Y a) ∂μ) = + ∫⁻ a, f (D a) * (∫⁻ z, g z ∂κ (D a)) ∂μ := by + rw [lintegral_partition_countable μ D hD,lintegral_partition_countable μ D hD] + apply tsum_congr + intro i + have ha : ∀ᵐ a ∂μ.restrict (D ⁻¹' {i}), D a = i := + ae_restrict_mem (hD (measurableSet_singleton i)) + calc + (∫⁻ a in D ⁻¹' {i}, f (D a) * g (Y a) ∂μ) = + ∫⁻ a in D ⁻¹' {i}, f i * g (Y a) ∂μ := + lintegral_congr_ae (ha.mono fun a ha => by dsimp only; rw [ha]) + _ = f i * ∫⁻ a in D ⁻¹' {i}, g (Y a) ∂μ := + lintegral_const_mul _ (hg.comp hY) + _ = f i * ∫⁻ z, g z ∂(μ.restrict (D ⁻¹' {i})).map Y := by + rw [lintegral_map hg hY] + _ = f i * (μ (D ⁻¹' {i}) * ∫⁻ z, g z ∂κ i) := by + rw [hrestart i,lintegral_smul_measure,smul_eq_mul] + _ = ∫⁻ a in D ⁻¹' {i}, f i * (∫⁻ z, g z ∂κ i) ∂μ := by + rw [lintegral_const,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] + ac_rfl + _ = ∫⁻ a in D ⁻¹' {i}, f (D a) * (∫⁻ z, g z ∂κ (D a)) ∂μ := + lintegral_congr_ae (ha.mono fun a ha => by dsimp only; rw [ha]) + +theorem shared_jointPast_restart {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) + (x y : Lattice d) (hxy : height x = height y) (H : ℕ) (hH : 0 < H) + (f : BoundaryData d → ℝ≥0∞) (g : (Path d × Path d) → ℝ≥0∞) (hg : Measurable g) : + (∫⁻ P, f (boundaryData ℓ ((height x+H : ℤ) : ℝ) P) * + g (boundarySuffix ℓ ((height x+H : ℤ) : ℝ) P) ∂sharedConditionedPairLaw ν ℓ x y) = + ∫⁻ P, f (boundaryData ℓ ((height x+H : ℤ) : ℝ) P) * + (∫⁻ Q, g Q ∂sharedConditionedPairLaw ν ℓ + (extendPrefix (boundaryData ℓ ((height x+H : ℤ) : ℝ) P).1.1 + (boundaryData ℓ ((height x+H : ℤ) : ℝ) P).2.1 + (boundaryData ℓ ((height x+H : ℤ) : ℝ) P).1.1) + (extendPrefix (boundaryData ℓ ((height x+H : ℤ) : ℝ) P).1.2 + (boundaryData ℓ ((height x+H : ℤ) : ℝ) P).2.2 + (boundaryData ℓ ((height x+H : ℤ) : ℝ) P).1.2)) + ∂sharedConditionedPairLaw ν ℓ x y := by + exact lintegral_countable_restart _ _ _ _ (measurable_boundaryData ℓ _) + (measurable_boundarySuffix ℓ _) + (shared_boundaryData_map ν hue ℓ hℓ htrans height hproj hstep x y hxy H hH) f g hg + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/LateMoment.lean b/lean/OAI/Probability/Ballisticity/Estimates/LateMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c51943117ba675b045ad86489764ecb4f1f3571 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/LateMoment.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BudgetLoss +import OAI.Probability.Ballisticity.Estimates.CappedLoss + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma measurable_relativeBudgetMass_fixed {d k : ℕ} (e f : Direction d) + (base G : ℝ) (H : ℕ) (b : ℝ) (π : BudgetProfile (k:=k) e f base G) : + Measurable (fun ω => relativeBudgetMass e f H b π.val ω) := by + have hm : @Measurable _ _ (rowSigma Set.univ) _ + (fun ω => relativeBudgetMass e f H b π.val ω) := + (budgetProfileMass_joint_rows e f base G H b Set.univ + (fun _ _ _ => Set.subset_univ _)).comp (measurable_const.prodMk measurable_id) + exact hm.mono (rowSigma_le _) le_rfl + +lemma relativeBudgetMass_bounds {d k : ℕ} (e f : Direction d) (H : ℕ) (b : ℝ) + (π : Measure (Fin k → Lattice d)) [IsProbabilityMeasure π] (ω : Environment d) : + 0≤relativeBudgetMass e f H b π ω ∧ relativeBudgetMass e f H b π ω≤1 := by + rw [← relativeBudgetMassENN_toReal] + exact ⟨ENNReal.toReal_nonneg,by + have := ENNReal.toReal_mono (by norm_num : (1:ℝ≥0∞)≠∞) (relativeBudgetMassENN_le_one e f H b π ω) + simpa using this⟩ + +lemma relativeBudgetMass_lt_exp {d k : ℕ} (e f : Direction d) (H : ℕ) (b x : ℝ) + (π : Measure (Fin k → Lattice d)) [IsProbabilityMeasure π] (ω : Environment d) : + relativeBudgetMass e f H b π ω C*k*D L + have hD' : ∀ L, 0≤D' L := fun L => mul_nonneg (mul_nonneg hC.le (Nat.cast_nonneg k)) (hD L) + obtain ⟨l₀,hl₀⟩ := harith k hk1 a ha D' hD' + refine ⟨l₀,fun Bstar hB => ?_⟩ + obtain ⟨Gzero,hGzero⟩ := hloss Bstar hB k hk1 + refine ⟨Gzero,?_⟩ + intro l hl hcap H base G b hb hhalf hG hratio π + let T := fun x => (environmentLaw ν).real {ω | relativeBudgetMassENN e f H b π.val ω by + exact measureReal_le_one + have htail (L : ℕ) (hL : 1≤L) (x : ℝ) (hx : (k:ℝ)*L*K≤x) (hxa : x≤a*(l+1)) : + T x≤(Real.exp (C*k-lam*x/L)+D' L*Real.exp (x/L-θ*l))^L := by + apply (hGzero L H base G b x hL hb hhalf hG hx (hxa.trans hcap) π).trans + have hn := fluctuationScale_nonneg + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (b/(2*L)) + apply pow_le_pow_left₀ (by positivity) + apply add_le_add_right + calc + C*k*Real.exp (x/L)*H/fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (b/(2*L)) = + (C*k*Real.exp (x/L))*((H:ℝ)/fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (b/(2*L))) := by ring + _ ≤ (C*k*Real.exp (x/L))*(D L*Real.exp (-θ*l)) := + mul_le_mul_of_nonneg_left (hratio L hL) (by positivity) + _ = D' L*Real.exp (x/L-θ*l) := by dsimp [D']; rw [sub_eq_add_neg,Real.exp_add]; ring_nf + obtain ⟨hsmall,hlarge⟩ := hl₀ l hl T hT htail + refine ⟨?_,hlarge⟩ + let q := fun ω => relativeBudgetMass e f H b π.val ω + let X := fun ω => cappedLogLoss (a*(l+1)) (q ω) + have hq : Measurable q := measurable_relativeBudgetMass_fixed e f base G H b π + have hqa : ∀ ω, 0≤q ω ∧ q ω≤1 := relativeBudgetMass_bounds e f H b π.val + have hcap0 : 0≤a*(l+1) := mul_nonneg (by linarith only [ha]) (by positivity) + have hX : Measurable X := measurable_cappedLogLoss _ q hq + have hX0 : ∀ ω, 0≤X ω := fun ω => (cappedLogLoss_bounds hcap0 (hqa ω).1 (hqa ω).2).1 + have hXa : ∀ ω, X ω≤a*(l+1) := fun ω => (cappedLogLoss_bounds hcap0 (hqa ω).1 (hqa ω).2).2 + have hbound (x : ℝ) (hx : 0≤x) : environmentLaw ν {ω | x (not_lt_of_ge ((hXa ω).trans (not_lt.mp hxc))) hω) + rw [he,measure_empty] + exact bot_le + have hm := exp_moment_of_tail (environmentLaw ν) X hX hX0 (a*(l+1)) hXa + (lam/4) (Real.exp (C₀*k)) (by positivity) (Real.exp_pos _).le hbound + apply hm.trans + calc + 1+Real.exp (C₀*k) ≤ 2*Real.exp (C₀*k) := by + have hh := Real.one_le_exp_iff.mpr (mul_nonneg hC₀.le (Nat.cast_nonneg k)) + linarith only [hh] + _ ≤ Real.exp ((C₀+1)*k) := by + have he : (2:ℝ)≤Real.exp (k:ℝ) := by + have hh := Real.add_one_le_exp (k:ℝ) + linarith only [hh,hk1r] + calc + _ ≤ Real.exp (k:ℝ)*Real.exp (C₀*k) := mul_le_mul_of_nonneg_right he (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/LayerPairTruthEventMono.lean b/lean/OAI/Probability/Ballisticity/Estimates/LayerPairTruthEventMono.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4e7c00882a83418d61ceab11003e29d4ffbbe95 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/LayerPairTruthEventMono.lean @@ -0,0 +1,435 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SharedEndpointOverlapRight +import OAI.Probability.Ballisticity.Crossings.FirstLayerHitConcat + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma layerPairTruthEvent_mono {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) {E F : Set (Lattice d × Lattice d)} (hEF : E ⊆ F) : + layerPairTruthEvent ℓ height x y H E ⊆ layerPairTruthEvent ℓ height x y H F := by + intro P hP + obtain ⟨nm,hP⟩ := Set.mem_iUnion.mp hP + exact Set.mem_iUnion.mpr ⟨nm,⟨⟨⟨hP.1.1.1,hEF hP.1.1.2⟩,hP.1.2⟩,hP.2⟩⟩ + +lemma shared_raw_layer_truth_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) + (c : ℝ≥0∞) (hc : ∀ u v, c ≤ sharedNoDropMass ν ℓ u v) : + c*sharedPairLaw ν x y (layerPairEvent ℓ height x y H E) ≤ + sharedPairLaw ν x y (layerPairTruthEvent ℓ height x y H E) := by + apply shared_layer_restart_lower ν ℓ height hproj x y H E + (fun u v => NoDrop ℓ u ×ˢ NoDrop ℓ v) + (fun u v => (measurableSet_noDrop ℓ u).prod (measurableSet_noDrop ℓ v)) + (fun _ _ => Set.Subset.rfl) c + · intro u v _ _ _ + simpa only [sharedNoDropMass_eq] using hc u v + · intro nm P hP hQ + exact Set.mem_iUnion.mpr ⟨nm,hP,hQ⟩ + +lemma shared_layer_gap_iterate {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (coord : Lattice d → ℝ) (H : ℤ) (hH : 0 < H) (a : ℝ) + (q c : ℝ≥0∞) (hc : ∀ u v, c ≤ sharedNoDropMass ν ℓ u v) + (hone : ∀ x y, height x=height y → + q ≤ sharedPairLaw ν x y (layerPairEvent ℓ height x y (height x+H) + {uv | |coord x-coord y|+a < |coord uv.1-coord uv.2|})) : + ∀ N : ℕ, 0 < N → ∀ x y, height x=height y → + c*q^N ≤ sharedPairLaw ν x y (layerPairTruthEvent ℓ height x y (height x+(N:ℤ)*H) + {uv | |coord x-coord y|+(N:ℝ)*a < |coord uv.1-coord uv.2|}) := by + intro N + induction N with + | zero => intro h; omega + | succ N ih => + intro hN x y hxy + by_cases hN0 : N=0 + · subst N + simpa only [Nat.zero_add,Nat.cast_one,one_mul,pow_one] using + (mul_le_mul_right (hone x y hxy) c).trans + (shared_raw_layer_truth_lower ν ℓ height hproj x y (height x+H) _ c hc) + · have hn : 0 < N := by omega + let E := {uv : Lattice d × Lattice d | |coord x-coord y|+a < |coord uv.1-coord uv.2|} + let F := {uv : Lattice d × Lattice d | |coord x-coord y|+((N+1:ℕ):ℝ)*a < |coord uv.1-coord uv.2|} + let B := fun u v => layerPairTruthEvent ℓ height u v (height u+(N:ℤ)*H) + {uv | |coord u-coord v|+(N:ℝ)*a < |coord uv.1-coord uv.2|} + have hstep : (c*q^N)*sharedPairLaw ν x y (layerPairEvent ℓ height x y (height x+H) E) ≤ + sharedPairLaw ν x y (layerPairTruthEvent ℓ height x y (height x+((N+1:ℕ):ℤ)*H) F) := by + apply shared_layer_restart_lower ν ℓ height hproj x y (height x+H) E B + (fun _ _ => measurableSet_layerPairTruthEvent _ _ _ _ _ _) + (fun _ _ => layerPairTruthEvent_subset_noDrop _ _ _ _ _ _) (c*q^N) + · intro u v hu hv _ + exact ih hn u v (hu.trans hv.symm) + · intro nm P hP hQ + have hu : height (P.1 (nm.1+1))=height x+H := hP.1.1.1.1 + have hK : height (P.1 (nm.1+1))+(N:ℤ)*H = height x+((N+1:ℕ):ℤ)*H := by + rw [hu,Nat.cast_add,Nat.cast_one] + ring + have hHK : height x+H < height x+((N+1:ℕ):ℤ)*H := by + have hnz : (0:ℤ) < N := by exact_mod_cast hn + rw [Nat.cast_add,Nat.cast_one] + nlinarith + change commonPairSuffix (nm.1+1) (nm.2+1) P ∈ layerPairTruthEvent ℓ height _ _ _ _ at hQ + rw [hK] at hQ + have hQ' := layerPairPrefix_truth_concat ℓ height x y hHK E _ nm P hP hQ + apply layerPairTruthEvent_mono ℓ height x y _ _ hQ' + intro uv huv + change |coord x-coord y|+((N+1:ℕ):ℝ)*a < |coord uv.1-coord uv.2| + have hp : |coord x-coord y|+a < |coord (P.1 (nm.1+1))-coord (P.2 (nm.2+1))| := hP.1.2 + change |coord (P.1 (nm.1+1))-coord (P.2 (nm.2+1))|+(N:ℝ)*a < |coord uv.1-coord uv.2| at huv + rw [Nat.cast_add,Nat.cast_one] + nlinarith + have hh := (mul_le_mul_right (hone x y hxy) (c*q^N)).trans hstep + simpa only [pow_succ,mul_assoc,F] using hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma shared_conditioned_event_ge_raw {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) (A : Set (Path d × Path d)) (hA : MeasurableSet A) + (hAD : A ⊆ NoDrop ℓ x ×ˢ NoDrop ℓ y) : + sharedPairLaw ν x y A ≤ sharedConditionedPairLaw ν ℓ x y A := by + have hle : sharedNoDropMass ν ℓ x y ≤ 1 := by + rw [sharedNoDropMass_eq] + exact prob_le_one + have hi : 1 ≤ (sharedNoDropMass ν ℓ x y)⁻¹ := by + simpa using ENNReal.inv_le_inv.mpr hle + rw [sharedConditionedPairLaw,Measure.smul_apply,Measure.restrict_apply hA, + Set.inter_eq_left.mpr hAD] + exact le_mul_of_one_le_left' hi + +theorem bad_radius_lower_cutoff_escape {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) {l ε : ℝ} + (hl : 0 < l) (hl1 : l ≤ 1) (hε : 0 < ε) + (hbad : ∀ᶠ i in atTop, + ε ≤ fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)* + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*r i < |commonIncrementProcess (realPosition (step e)) f 0 P|}) : + ∃ C q : ℝ, 0 < C ∧ 0 < q ∧ ∀ᶠ i in atTop, + ∃ K : ℕ, 0 < K ∧ (K:ℝ) ≤ C*fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (4*r i) ∧ + ∀ x y : Lattice d, signedHeight e x=signedHeight e y → + q ≤ (sharedConditionedPairLaw ν (realPosition (step e)) x y).real + (layerPairTruthEvent (realPosition (step e)) (signedHeight e) x y + (signedHeight e x+K) {uv | 8*r i ≤ |signedCoordinate f uv.1-signedCoordinate f uv.2|}) := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + obtain ⟨t,q₀,ht,hq₀,hblock⟩ := bad_radius_raw_gap_growth ν hue e f hef htrans r hr hl hl1 hε hbad + obtain ⟨c,hc,htruth⟩ := sharedNoDropMass_uniform_positive ν hue ℓ (signed_direction_unit e) htrans + have hc1 : c ≤ 1 := (htruth 0 0).trans (sharedNoDropMass_le_one ν ℓ 0 0) + have hcfin : c ≠ ∞ := ne_top_of_le_ne_top (by norm_num) hc1 + obtain ⟨N,hN⟩ := exists_nat_gt (128/l) + have hNpos : 0 < N := by + have hpos : (0:ℝ) < N := (by positivity : (0:ℝ) < 128/l).trans hN + exact_mod_cast hpos + have hNl : 128 < (N:ℝ)*l := (div_lt_iff₀ hl).mp hN + let Q : ℝ≥0∞ := c*(ENNReal.ofReal q₀)^N + have hQ : 0 < Q := ENNReal.mul_pos hc.ne' (pow_ne_zero _ (ENNReal.ofReal_pos.mpr hq₀).ne') + have hQfin : Q ≠ ∞ := ENNReal.mul_ne_top hcfin (ENNReal.pow_ne_top ENNReal.ofReal_ne_top) + refine ⟨(N:ℝ)*t,Q.toReal,mul_pos (by exact_mod_cast hNpos) ht, + ENNReal.toReal_pos hQ.ne' hQfin,?_⟩ + filter_upwards [hblock,hr.eventually (eventually_gt_atTop 0)] with i hi hri + let H := ⌊t*fluctuationScale μ S (r i)⌋₊ + change 0 < H ∧ _ at hi + refine ⟨N*H,Nat.mul_pos hNpos hi.1,?_,?_⟩ + · have hHle : (H:ℝ) ≤ t*fluctuationScale μ S (r i) := + Nat.floor_le (mul_nonneg ht.le (fluctuationScale_nonneg μ S (r i))) + have hmono := fluctuationScale_mono μ S (measurable_commonIncrementProcess ℓ f 0) hne hri + (show r i ≤ 4*r i by linarith) + change ((N*H:ℕ):ℝ) ≤ (N:ℝ)*t*fluctuationScale μ S (4*r i) + rw [Nat.cast_mul,mul_assoc] + exact mul_le_mul_of_nonneg_left (hHle.trans (mul_le_mul_of_nonneg_left hmono ht.le)) (Nat.cast_nonneg _) + · intro x y hxy + let : IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ x y) := + sharedConditionedPairLaw_probability ν ℓ x y (ne_of_gt (hc.trans_le (htruth x y))) + have hone : ∀ u v : Lattice d, signedHeight e u=signedHeight e v → + ENNReal.ofReal q₀ ≤ sharedPairLaw ν u v (layerPairEvent ℓ (signedHeight e) u v + (signedHeight e u+H) {uv | |signedCoordinate f u-signedCoordinate f v|+l*r i/16 < + |signedCoordinate f uv.1-signedCoordinate f uv.2|}) := by + intro u v huv + exact (ENNReal.ofReal_le_iff_le_toReal (measure_ne_top _ _)).mpr (hi.2 u v huv) + have hg := shared_layer_gap_iterate ν ℓ (signedHeight e) (signedHeight_projection e) + (fun z => signedCoordinate f z) H (by exact_mod_cast hi.1) (l*r i/16) + (ENNReal.ofReal q₀) c htruth hone N hNpos x y hxy + have hsub : layerPairTruthEvent ℓ (signedHeight e) x y (signedHeight e x+(N:ℤ)*(H:ℤ)) + {uv | |signedCoordinate f x-signedCoordinate f y|+(N:ℝ)*(l*r i/16) < + |signedCoordinate f uv.1-signedCoordinate f uv.2|} ⊆ + layerPairTruthEvent ℓ (signedHeight e) x y (signedHeight e x+(N*H:ℕ)) + {uv | 8*r i ≤ |signedCoordinate f uv.1-signedCoordinate f uv.2|} := by + rw [Nat.cast_mul] + apply layerPairTruthEvent_mono + intro uv huv + change 8*r i ≤ |signedCoordinate f uv.1-signedCoordinate f uv.2| + change |signedCoordinate f x-signedCoordinate f y|+(N:ℝ)*(l*r i/16) < + |signedCoordinate f uv.1-signedCoordinate f uv.2| at huv + have hh : 8*r i < (N:ℝ)*(l*r i/16) := by nlinarith + linarith [abs_nonneg (signedCoordinate f x-signedCoordinate f y)] + have hraw := hg.trans (measure_mono hsub) + have hcond := hraw.trans (shared_conditioned_event_ge_raw ν ℓ x y _ + (measurableSet_layerPairTruthEvent _ _ _ _ _ _) (layerPairTruthEvent_subset_noDrop _ _ _ _ _ _)) + exact ENNReal.toReal_mono (measure_ne_top _ _) hcond + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ListPrefixSum.lean b/lean/OAI/Probability/Ballisticity/Estimates/ListPrefixSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..5def28131c2a2ca5e7ac79b79e57ff8ecb26834f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ListPrefixSum.lean @@ -0,0 +1,46 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.IidListProcess + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma realPartialSum_list {G : Type*} (F : G → ℝ) (c : ℝ) (w : List G) {k : ℕ} (hk : k ≤ w.length) : + realPartialSum (fun j => if h : j < w.length then F (w.get ⟨j,h⟩)-c else 0) k = + ((w.take k).map F).sum-(k:ℝ)*c := by + induction k with + | zero => simp [realPartialSum] + | succ k ih => + rw [realPartialSum_succ,ih (by omega)] + have hkl : k < w.length := by omega + rw [dite_eq_left hkl] + rw [List.take_add_one,List.getElem?_eq_getElem hkl] + simp only [List.get_eq_getElem,Option.toList_some,List.map_append,List.sum_append,List.map_singleton,List.sum_singleton,Nat.cast_add,Nat.cast_one] + ring + +lemma signedCoordinate_list_sum {d : ℕ} (f : Direction d) (w : List (Lattice d)) : + (w.map (signedCoordinate f)).sum=signedCoordinate f w.sum := by + induction w with + | nil => simp [signedCoordinate] + | cons u w ih => simp only [List.map_cons,List.sum_cons,signedCoordinate_add,ih] + +lemma listCenteredMax_prefix {d : ℕ} (f : Direction d) (c : ℝ) (w : List (Lattice d)) + {k : ℕ} (hk : k ≤ w.length) : + |signedCoordinate f (w.take k).sum-(k:ℝ)*c| ≤ listCenteredMax (signedCoordinate f) c w := by + rw [← signedCoordinate_list_sum] + rw [← realPartialSum_list _ c w hk] + exact (abs_partialSum_le_max _ k).trans (partialSumMax_mono _ hk) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/LocalRadiusOrder.lean b/lean/OAI/Probability/Ballisticity/Estimates/LocalRadiusOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f843121acae73ed6f7ffc25452652cce325cfd7 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/LocalRadiusOrder.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeRandomStart + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma fluctuationRadius_order_above {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hI : Integrable S μ) (hne : 0<μ {x | S x≠0}) {s t : ℝ} + (hs : fluctuationScale μ S 1 f p.1 p.2)) + (h : ∀ a, ν.map (f a) = ρ) : + (μ.prod ν).map (fun p => (p.1, f p.1 p.2)) = μ.prod ρ := by + apply Measure.ext_prod + intro s t hs ht + rw [Measure.map_apply (measurable_fst.prodMk hf) (hs.prod ht), + Measure.prod_apply ((hs.prod ht).preimage (measurable_fst.prodMk hf)), + Measure.prod_prod] + have inner (a : A) : ν (Prod.mk a ⁻¹' ((fun p : A × B => (p.1,f p.1 p.2)) ⁻¹' (s ×ˢ t))) = + s.indicator (fun _ => ρ t) a := by + by_cases ha : a ∈ s + · rw [Set.indicator_of_mem ha] + have he : Prod.mk a ⁻¹' ((fun p : A × B => (p.1,f p.1 p.2)) ⁻¹' (s ×ˢ t)) = + f a ⁻¹' t := by ext b; simp [ha] + have hfa : Measurable (f a) := hf.comp measurable_prodMk_left + rw [he, ← Measure.map_apply hfa ht, h a] + · have he : Prod.mk a ⁻¹' ((fun p : A × B => (p.1,f p.1 p.2)) ⁻¹' (s ×ˢ t)) = ∅ := by + ext b; simp [ha] + simp [he,ha] + simp_rw [inner] + rw [lintegral_indicator hs, lintegral_const] + simp [mul_comm] + +abbrev LocalUpperField {d : ℕ} (e : Direction d) := (ℕ × HorizontalSpace e) → Row d + +noncomputable def localStoppedField {d : ℕ} (e : Direction d) + (τ σ : Environment d → ℕ) (p : Environment d × LocalUpperField e) : LocalUpperField e := + fun q => if q.1 < σ p.1 - τ p.1 then + p.1 (horizontalLift e (τ p.1 + q.1) q.2) else p.2 q + +lemma localStoppedField_measurable {d : ℕ} (e : Direction d) + (τ σ : Environment d → ℕ) (hτ : Measurable τ) (hσ : Measurable σ) : + Measurable (localStoppedField e τ σ) := by + apply Measurable.of_eval + intro q + apply Measurable.ite (measurableSet_lt measurable_const ((hσ.comp measurable_fst).sub + (hτ.comp measurable_fst))) + · have hx : Measurable (fun p : Environment d × LocalUpperField e => + horizontalLift e (τ p.1 + q.1) q.2) := + (measurable_of_countable (fun n : ℕ => horizontalLift e (n + q.1) q.2)).comp + (hτ.comp measurable_fst) + exact measurable_current_row.comp (measurable_fst.prodMk hx) + · exact (measurable_pi_apply q).comp measurable_snd + +lemma localStoppedField_full_graft {d : ℕ} (e : Direction d) + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω ≤ σ ω) (ω η : Environment d) : + localStoppedField e τ σ (ω, upperField e (τ ω) η) = + upperField e (τ ω) + (stoppedRowGraft (fun n => BelowHeight (realPosition (step e)) n) σ ω η) := by + funext q + have hn : horizontalLift e (τ ω + q.1) q.2 ∈ + BelowHeight (realPosition (step e)) (σ ω) ↔ q.1 < σ ω - τ ω := by + simp only [BelowHeight, Set.mem_ofPred_eq, signedHeight_projection, signedHeight_horizontalLift] + have hle := hτσ ω + norm_cast + omega + change (if q.1 < σ ω - τ ω then _ else _) = + (if horizontalLift e (τ ω + q.1) q.2 ∈ BelowHeight (realPosition (step e)) (σ ω) then _ else _) + simp only [hn, upperField] + +theorem localStoppedField_law {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω ≤ σ ω) + (hτ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | τ ω=n}) + (hσ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | σ ω=n}) + (filler : Environment d) : + (Q.prod (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν))).map + (fun p => (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) τ filler p.1, + localStoppedField e τ σ p)) = stoppedWindowLaw e ν Q τ σ filler := by + let S : ℕ → Set (Lattice d) := fun n => BelowHeight (realPosition (step e)) n + have hτm := measurable_of_stop_events S τ hτ + have hσm := measurable_of_stop_events S σ hσ + have hf : Measurable (fun p : Environment d × Environment d => upperField e (τ p.1) p.2) := + (upperField_joint_measurable e).comp (measurable_snd.prodMk (hτm.comp measurable_fst)) + have hh := prod_dependent_map_const Q (environmentLaw ν) + (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν)) + (fun ω η => upperField e (τ ω) η) hf (fun ω => upperField_map e ν (τ ω)) + have hF : Measurable (fun p : Environment d × LocalUpperField e => + (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) τ filler p.1, + localStoppedField e τ σ p)) := + ((stoppedObservation_measurable S τ hτ filler).comp measurable_fst).prodMk + (localStoppedField_measurable e τ σ hτm hσm) + rw [← hh, Measure.map_map hF (measurable_fst.prodMk hf)] + unfold stoppedWindowLaw + congr 1 + funext p + exact Prod.ext rfl (localStoppedField_full_graft e τ σ hτσ p.1 p.2) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped ENNReal Topology +namespace DirectionalTransience.ReferenceClasses + +variable {H : Type*} [AddCommGroup H] + +abbrev Offsets (H : Type*) := (ℕ × ℕ) → OnePoint H + +structure Consistent (O : Offsets H) : Prop where + self : ∀ a, O (a,a) = (0 : H) + symm : ∀ (a b : ℕ) (z : H), O (a,b) = (z : OnePoint H) → O (b,a) = ((-z : H) : OnePoint H) + add : ∀ (a b c : ℕ) (z w : H), O (a,b) = (z : OnePoint H) → O (b,c) = (w : OnePoint H) → + O (a,c) = ((z+w : H) : OnePoint H) + +abbrev Data (H : Type*) [AddCommGroup H] := {O : Offsets H // Consistent O} + +def related (O : Data H) (a b : ℕ) : Prop := ∃ z : H, O.1 (a,b) = (z : OnePoint H) + +lemma related_self (O : Data H) (a : ℕ) : related O a a := ⟨0,O.2.self a⟩ +lemma related_symm {O : Data H} {a b : ℕ} (h : related O a b) : related O b a := by + obtain ⟨z,hz⟩ := h + exact ⟨-z,O.2.symm a b z hz⟩ +lemma related_trans {O : Data H} {a b c : ℕ} + (hab : related O a b) (hbc : related O b c) : related O a c := by + obtain ⟨z,hz⟩ := hab + obtain ⟨w,hw⟩ := hbc + exact ⟨z+w,O.2.add a b c z w hz hw⟩ + +noncomputable def representative (O : Data H) (a : ℕ) : ℕ := + @Nat.find (fun b => related O b a) (Classical.decPred _) ⟨a, related_self O a⟩ + +lemma representative_related (O : Data H) (a : ℕ) : related O (representative O a) a := + by + classical + exact Nat.find_spec (p := fun b => related O b a) ⟨a,related_self O a⟩ + +lemma representative_le {O : Data H} {a b : ℕ} (h : related O b a) : + representative O a ≤ b := by + classical + exact Nat.find_min' (p := fun b => related O b a) ⟨a,related_self O a⟩ h + +lemma representative_eq_iff (O : Data H) (a b : ℕ) : + representative O a = representative O b ↔ related O a b := by + constructor + · intro h + exact related_trans (related_symm (representative_related O a)) + (h ▸ representative_related O b) + · intro hab + exact le_antisymm (representative_le (related_trans (representative_related O b) + (related_symm hab))) (representative_le (related_trans (representative_related O a) hab)) + +noncomputable def displacement (O : Data H) (a : ℕ) : H := + Classical.choose (representative_related O a) + +lemma displacement_spec (O : Data H) (a : ℕ) : + O.1 (representative O a,a) = (↑(displacement O a) : OnePoint H) := + Classical.choose_spec (representative_related O a) + +lemma offset_eq (O : Data H) {a b : ℕ} {z : H} + (h : O.1 (a,b) = (z : OnePoint H)) : + displacement O b = displacement O a + z := by + have hr := (representative_eq_iff O a b).mpr ⟨z,h⟩ + have hh := O.2.add (representative O a) a b (displacement O a) z (displacement_spec O a) h + rw [hr, displacement_spec] at hh + exact OnePoint.coe_injective hh + +noncomputable def inputSite (O : Data H) (p : ℕ × ℕ × H) : ℕ × ℕ × H := + (representative O p.1,p.2.1,displacement O p.1+p.2.2) + +lemma inputSite_eq_iff (O : Data H) (a b l l' : ℕ) (z z' : H) : + inputSite O (a,l,z) = inputSite O (b,l',z') ↔ + l = l' ∧ O.1 (a,b) = ((z-z' : H) : OnePoint H) := by + constructor + · intro h + have hr : representative O a = representative O b := congrArg Prod.fst h + have hl : l = l' := congrArg (fun p : ℕ × ℕ × H => p.2.1) h + have hx : displacement O a+z = displacement O b+z' := + congrArg (fun p : ℕ × ℕ × H => p.2.2) h + obtain ⟨u,hu⟩ := (representative_eq_iff O a b).mp hr + have hd := offset_eq O hu + have hu' : u = z-z' := (eq_sub_iff_add_eq).mpr (by + apply add_left_cancel (a := displacement O a) + simpa only [hd,add_assoc] using hx.symm) + exact ⟨hl,by simpa only [hu'] using hu⟩ + · rintro ⟨rfl,h⟩ + have hr := (representative_eq_iff O a b).mpr ⟨z-z',h⟩ + have hd := offset_eq O h + dsimp only [inputSite] + apply Prod.ext hr + change (l,displacement O a+z) = (l,displacement O b+z') + congr 1 + rw [hd] + abel + +section Measurable +variable [Countable H] [TopologicalSpace H] [DiscreteTopology H] + [MeasurableSpace H] [BorelSpace H] + [MeasurableSpace (OnePoint H)] [BorelSpace (OnePoint H)] + +omit [Countable H] [TopologicalSpace H] [DiscreteTopology H] [MeasurableSpace H] + [BorelSpace H] [BorelSpace (OnePoint H)] in +lemma measurable_offset (a b : ℕ) : Measurable (fun O : Data H => O.1 (a,b)) := + (measurable_pi_apply (a,b)).comp measurable_subtype_coe + +omit [MeasurableSpace H] [BorelSpace H] in +lemma measurable_related (a b : ℕ) : MeasurableSet {O : Data H | related O a b} := by + simp only [related,Set.ofPred_exists] + exact MeasurableSet.iUnion fun z => (measurable_offset a b) (measurableSet_singleton _) + +omit [MeasurableSpace H] [BorelSpace H] in +lemma measurable_representative (a : ℕ) : Measurable (fun O : Data H => representative O a) := by + classical + exact measurable_find (p := fun O b => related O b a) (fun O => ⟨a,related_self O a⟩) (fun b => measurable_related b a) + +omit [BorelSpace H] in +lemma measurable_displacement (a : ℕ) : Measurable (fun O : Data H => displacement O a) := by + apply measurable_to_countable' + intro z + have hm : Measurable (fun O : Data H => O.1 (representative O a,a)) := by + have h : Measurable (fun p : Data H × ℕ => p.1.1 (p.2,a)) := + measurable_from_prod_countable_left fun b => measurable_offset b a + exact h.comp (measurable_id.prodMk (measurable_representative a)) + have heq : {O : Data H | displacement O a = z} = + {O | O.1 (representative O a,a) = (z : OnePoint H)} := by + ext O + simp only [Set.mem_ofPred_eq,displacement_spec,OnePoint.coe_eq_coe] + change MeasurableSet {O : Data H | displacement O a = z} + rw [heq] + exact hm (measurableSet_singleton _) + +lemma measurable_inputSite (p : ℕ × ℕ × H) : Measurable (fun O : Data H => inputSite O p) := by + exact (measurable_representative p.1).prodMk + (measurable_const.prodMk ((measurable_displacement p.1).add measurable_const)) + +variable {R : Type*} [MeasurableSpace R] + +abbrev Site (H : Type*) := ℕ × ℕ × H +abbrev UpperField (H R : Type*) := (ℕ × H) → R +abbrev AllFields (H R : Type*) := Site H → R + +noncomputable def fields (O : Data H) (ξ : AllFields H R) : AllFields H R := + fun p => ξ (inputSite O p) + +lemma measurable_fields : Measurable (fun p : Data H × AllFields H R => fields p.1 p.2) := by + apply Measurable.of_eval + intro p + have hm : Measurable (fun u : AllFields H R × Site H => u.1 u.2) := + measurable_from_prod_countable_left fun q => measurable_pi_apply q + exact hm.comp (measurable_snd.prodMk ((measurable_inputSite p).comp measurable_fst)) + +noncomputable def reference (ν : Measure R) [IsProbabilityMeasure ν] : + Kernel (Data H) (AllFields H R) := + ((Kernel.id : Kernel (Data H) (Data H)).prod + (Kernel.const (Data H) (Measure.infinitePi (fun _ : Site H => ν)))).map + (fun p => fields p.1 p.2) + +instance reference_markov (ν : Measure R) [IsProbabilityMeasure ν] : IsMarkovKernel (reference (H := H) ν) := by + unfold reference + exact Kernel.IsMarkovKernel.map _ measurable_fields + +lemma reference_apply (ν : Measure R) [IsProbabilityMeasure ν] (O : Data H) : + reference ν O = (Measure.infinitePi (fun _ : Site H => ν)).map (fields O) := by + rw [reference,Kernel.map_apply _ measurable_fields,Kernel.prod_apply,Kernel.id_apply, + Kernel.const_apply,Measure.dirac_prod,Measure.map_map measurable_fields measurable_prodMk_left] + rfl + +omit [Countable H] [TopologicalSpace H] [DiscreteTopology H] [MeasurableSpace H] + [BorelSpace H] [MeasurableSpace (OnePoint H)] [BorelSpace (OnePoint H)] in +lemma inputSite_injective_at_label (O : Data H) (a : ℕ) : + Function.Injective (fun p : ℕ × H => inputSite O (a,p)) := by + rintro ⟨l,z⟩ ⟨l',z'⟩ h + have hh := (inputSite_eq_iff O a a l l' z z').mp h + rw [O.2.self,OnePoint.coe_eq_coe] at hh + exact Prod.ext hh.1 (sub_eq_zero.mp hh.2.symm) + +lemma reference_single_field (ν : Measure R) [IsProbabilityMeasure ν] (O : Data H) (a : ℕ) : + (reference ν O).map (fun φ => fun p : ℕ × H => φ (a,p)) = + Measure.infinitePi (fun _ : ℕ × H => ν) := by + have hm : Measurable (fields O : AllFields H R → _) := + Measurable.of_eval fun _ => measurable_pi_apply _ + rw [reference_apply,Measure.map_map (by fun_prop) hm] + exact Measure.map_infinitePi_infinitePi_of_inj (inputSite_injective_at_label O a) + +omit [Countable H] [TopologicalSpace H] [DiscreteTopology H] [MeasurableSpace H] + [BorelSpace H] [MeasurableSpace (OnePoint H)] [BorelSpace (OnePoint H)] in +lemma inputSite_injective_distinct_classes {I : Type*} (O : Data H) (a : I → ℕ) + (ha : ∀ i j, i ≠ j → ¬ related O (a i) (a j)) : + Function.Injective (fun p : I × (ℕ × H) => inputSite O (a p.1,p.2)) := by + rintro ⟨i,l,z⟩ ⟨j,l',z'⟩ h + have hh := (inputSite_eq_iff O (a i) (a j) l l' z z').mp h + have hij : i = j := by + by_contra he + exact ha i j he ⟨z-z',hh.2⟩ + subst j + exact Prod.ext rfl (inputSite_injective_at_label O (a i) h) + +lemma reference_distinct_classes {I : Type*} (ν : Measure R) [IsProbabilityMeasure ν] + (O : Data H) (a : I → ℕ) (ha : ∀ i j, i ≠ j → ¬ related O (a i) (a j)) : + (reference ν O).map (fun φ => fun p : I × (ℕ × H) => φ (a p.1,p.2)) = + Measure.infinitePi (fun _ : I × (ℕ × H) => ν) := by + have hm : Measurable (fields O : AllFields H R → _) := + Measurable.of_eval fun _ => measurable_pi_apply _ + rw [reference_apply,Measure.map_map (by fun_prop) hm] + exact Measure.map_infinitePi_infinitePi_of_inj (inputSite_injective_distinct_classes O a ha) + +end Measurable +end DirectionalTransience.ReferenceClasses + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/LowerClip.lean b/lean/OAI/Probability/Ballisticity/Estimates/LowerClip.lean new file mode 100644 index 0000000000000000000000000000000000000000..95d152f9c2aea4bcd61fb69f97f92a57d4e3a7d2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/LowerClip.lean @@ -0,0 +1,434 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.FirstBelow + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma inverse_moment_of_geometric_tail {α : Type*} [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) (hf : Measurable f) + (hp : ∀ᵐ x ∂μ, 0 < f x ∧ f x ≠ ∞) + {δ : ℝ≥0} (hδ : 0 < δ) (hδ1 : δ < 1) {ρ : ℝ≥0∞} (hρ : ρ < 1) + (htail : ∀ j : ℕ, μ {x | f x < ((δ ^ (j + 1) : ℝ≥0) : ℝ≥0∞)} ≤ ρ ^ j) : + ∃ lam : ℝ, 0 < lam ∧ (∫⁻ x, f x ^ (-lam) ∂μ) < ∞ := by + obtain ⟨lam, hlam, hr⟩ := exists_inverse_geometric_ratio hδ hρ + let c : ℝ≥0∞ := ((δ ^ (-lam) : ℝ≥0) : ℝ≥0∞) + let E := fun j : ℕ => {x | f x < ((δ ^ (j + 1) : ℝ≥0) : ℝ≥0∞)} + have hE (j : ℕ) : MeasurableSet (E j) := measurableSet_lt hf measurable_const + have hbound : ∀ᵐ x ∂μ, f x ^ (-lam) ≤ c + ∑' j : ℕ, (E j).indicator (fun _ => c ^ (j + 2)) x := by + filter_upwards [hp] with x hx + have hh := inverse_power_le_series hδ hδ1 hlam (ENNReal.toNNReal_pos hx.1.ne' hx.2) + rw [ENNReal.coe_rpow_of_ne_zero (ENNReal.toNNReal_pos hx.1.ne' hx.2).ne', ENNReal.coe_toNNReal hx.2] at hh + convert hh using 1 + congr 1 + apply tsum_congr + intro j + simp only [Set.indicator, E, Set.mem_ofPred_eq, Set.mem_Iio] + have heq : (f x).toNNReal < δ ^ (j + 1) ↔ f x < ((δ ^ (j + 1) : ℝ≥0) : ℝ≥0∞) := by + rw [← ENNReal.coe_lt_coe, ENNReal.coe_toNNReal hx.2] + simp only [heq, c] + have hi : (∫⁻ x, f x ^ (-lam) ∂μ) ≤ c + ∑' j : ℕ, c ^ (j + 2) * ρ ^ j := by + apply (lintegral_mono_ae hbound).trans + rw [lintegral_add_left measurable_const, lintegral_const, measure_univ, mul_one, + lintegral_tsum (fun j => (measurable_const.indicator (hE j)).aemeasurable)] + refine add_le_add le_rfl ?_ + apply ENNReal.tsum_le_tsum + intro j + rw [lintegral_indicator (hE j), lintegral_const, Measure.restrict_apply_univ] + exact mul_le_mul' le_rfl (htail j) + have heq : (∑' j : ℕ, c ^ (j + 2) * ρ ^ j) = c ^ 2 * (1 - c * ρ)⁻¹ := by + simp_rw [pow_add, mul_right_comm (c ^ _) (c ^ 2), ← mul_pow] + rw [ENNReal.tsum_mul_right, ENNReal.tsum_geometric, mul_comm] + refine ⟨lam, hlam, lt_of_le_of_lt hi ?_⟩ + rw [heq] + apply ENNReal.add_lt_top.mpr + constructor + · exact ENNReal.coe_lt_top + · apply ENNReal.mul_lt_top (by simp [c]) + exact ENNReal.inv_lt_top.mpr (tsub_pos_iff_lt.mpr (by simpa [mul_comm] using hr)) + +lemma exists_positive_step {d : ℕ} (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) : + ∃ e : Direction d, 0 < dot (realPosition (step e)) ℓ := by + have hn : ∃ i, ℓ i ≠ 0 := by + by_contra h + push Not at h + have hz : dot ℓ ℓ = 0 := by simp [dot, h] + linarith + obtain ⟨i, hi⟩ := hn + rcases lt_or_gt_of_ne hi with hi | hi + · refine ⟨(i, false), ?_⟩ + simpa [dot, realPosition, step] using neg_pos.mpr hi + · refine ⟨(i, true), ?_⟩ + simpa [dot, realPosition, step] using hi + +lemma quenched_noDrop_positive_of_directionallyTransient {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ ω ∂environmentLaw ν, ∀ x, 0 < noDropQuenched ℓ x ω := by + obtain ⟨e, he⟩ := exists_positive_step ℓ hℓ + exact noDropQuenched_positive_ae ν hue ℓ e he + (noDrop_positive_of_directionallyTransient ν ℓ htrans) + +lemma noDrop_inverse_moment {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : + ∃ lam : ℝ, 0 < lam ∧ + (∫⁻ ω, noDropQuenched ℓ 0 ω ^ (-lam) ∂environmentLaw ν) < ∞ := by + obtain ⟨e, he⟩ := exists_positive_step ℓ hℓ + obtain ⟨δ, ρ, hδ, hδ1, hρ, htail⟩ := noDrop_geometric_tail ν hue ℓ e he htrans + apply inverse_moment_of_geometric_tail (environmentLaw ν) (noDropQuenched ℓ 0) + (measurable_noDropQuenched ℓ 0) _ hδ hδ1 hρ htail + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans] with ω hω + exact ⟨hω 0, measure_ne_top _ _⟩ + +lemma integer_quantile (μ : Measure ℤ) [IsFiniteMeasure μ] + {t : ℝ≥0∞} (ht : 0 < t) (htμ : t < μ Set.univ) : + ∃ j : ℤ, t ≤ μ (Set.Iic j) ∧ μ (Set.Iio j) < t := by + have hbot : Tendsto (fun j : ℤ => μ (Set.Iic j)) atBot (𝓝 0) := by + have hi : (⋂ j : ℤ, Set.Iic j) = ∅ := by + ext z + simp only [Set.mem_iInter, Set.mem_Iic, Set.mem_empty_iff_false, iff_false] + push Not + exact ⟨z - 1, by omega⟩ + have h := tendsto_measure_iInter_atBot + (μ := μ) (s := fun j : ℤ => Set.Iic j) + (fun _ => (measurableSet_Iic).nullMeasurableSet) + (fun _ _ hab => Set.Iic_subset_Iic.mpr hab) + ⟨0, measure_ne_top μ _⟩ + simpa only [hi, measure_empty, Function.comp_def] using h + obtain ⟨b, hb⟩ := (hbot.eventually_lt_const ht).exists + obtain ⟨k, hk⟩ := ((tendsto_measure_Iic_atTop μ).eventually_const_lt htμ).exists + obtain ⟨j, hj, hleast⟩ := Int.exists_least_of_bdd + (P := fun j => t ≤ μ (Set.Iic j)) + ⟨b, fun z hz => by + by_contra hzb + have hzμ : μ (Set.Iic z) ≤ μ (Set.Iic b) := + measure_mono (Set.Iic_subset_Iic.mpr (by omega)) + exact (not_lt_of_ge (hz.trans hzμ)) hb⟩ + ⟨k, hk.le⟩ + refine ⟨j, hj, ?_⟩ + have hi : Set.Iio j = Set.Iic (j - 1) := by + ext z + simp only [Set.mem_Iio, Set.mem_Iic] + omega + rw [hi] + apply lt_of_not_ge + intro h + have := hleast (j - 1) h + omega + +lemma order_mass_cut (μ ν : Measure ℤ) [IsFiniteMeasure μ] [IsFiniteMeasure ν] + (hμ : μ Set.univ ≤ 1) (hν : ν Set.univ ≤ 1) (R : ℤ) : + let Q := (μ.prod ν) {p : ℤ × ℤ | p.1 + R ≤ p.2} + ∃ j : ℤ, Q / 2 ≤ μ (Set.Iic j) ∧ Q / 2 ≤ ν (Set.Ici (j + R)) := by + dsimp only + let Q := (μ.prod ν) {p : ℤ × ℤ | p.1 + R ≤ p.2} + change ∃ j : ℤ, Q / 2 ≤ μ (Set.Iic j) ∧ Q / 2 ≤ ν (Set.Ici (j + R)) + by_cases hQ : Q = 0 + · exact ⟨0, by simp [hQ], by simp [hQ]⟩ + have hQμ : Q ≤ μ Set.univ := by + calc + Q ≤ (μ.prod ν) (Set.univ ×ˢ Set.univ) := measure_mono (by simp) + _ = μ Set.univ * ν Set.univ := Measure.prod_prod _ _ + _ ≤ μ Set.univ := mul_le_of_le_one_right zero_le hν + have hQt : Q ≠ ∞ := ne_top_of_le_ne_top (measure_ne_top μ _) hQμ + obtain ⟨j, hj, hjprev⟩ := integer_quantile μ (ENNReal.half_pos hQ) + ((ENNReal.half_lt_self hQ hQt).trans_le hQμ) + refine ⟨j, hj, ?_⟩ + by_contra hnot + have hjright : ν (Set.Ici (j + R)) < Q / 2 := lt_of_not_ge hnot + have hsub : {p : ℤ × ℤ | p.1 + R ≤ p.2} ⊆ + (Set.Iio j ×ˢ Set.univ) ∪ (Set.univ ×ˢ Set.Ici (j + R)) := by + intro p hp + by_cases h : p.1 < j + · exact Or.inl ⟨h, Set.mem_univ _⟩ + · refine Or.inr ⟨Set.mem_univ _, ?_⟩ + change p.1 + R ≤ p.2 at hp + change j + R ≤ p.2 + omega + have bound : Q < Q := calc + Q ≤ (μ.prod ν) ((Set.Iio j ×ˢ Set.univ) ∪ + (Set.univ ×ˢ Set.Ici (j + R))) := measure_mono hsub + _ ≤ (μ.prod ν) (Set.Iio j ×ˢ Set.univ) + + (μ.prod ν) (Set.univ ×ˢ Set.Ici (j + R)) := measure_union_le _ _ + _ = μ (Set.Iio j) * ν Set.univ + μ Set.univ * ν (Set.Ici (j + R)) := by + rw [Measure.prod_prod, Measure.prod_prod] + _ ≤ μ (Set.Iio j) + ν (Set.Ici (j + R)) := + add_le_add (mul_le_of_le_one_right zero_le hν) + (mul_le_of_le_one_left zero_le hμ) + _ < Q / 2 + Q / 2 := ENNReal.add_lt_add hjprev hjright + _ = Q := ENNReal.add_halves Q + exact (lt_irrefl Q) bound + +def lowerClip (n : ℕ) (x : ℝ) : ℝ := max x (-(n : ℝ)) + +lemma lowerClip_tendsto (x : ℝ) : + Tendsto (fun n => lowerClip n x) atTop (𝓝 x) := by + obtain ⟨N, hN⟩ := exists_nat_ge (-x) + have heq : (fun n => lowerClip n x) =ᶠ[atTop] (fun _ => x) := by + filter_upwards [eventually_ge_atTop N] with n hn + have hcast : (N : ℝ) ≤ n := by exact_mod_cast hn + exact max_eq_left (by linarith) + exact (tendsto_congr' heq).mpr tendsto_const_nhds + +lemma lowerClip_sub_bound (n : ℕ) (x y g : ℝ) (hg : g ≤ y - x) : + |min g (lowerClip n y - lowerClip n x)| ≤ |g| := by + have hd : min g 0 ≤ lowerClip n y - lowerClip n x := by + rcases le_total x (-(n : ℝ)) with hx | hx + · rw [lowerClip, lowerClip, max_eq_right hx] + have := le_max_right y (-(n : ℝ)) + have := min_le_right g 0 + linarith + · rw [lowerClip, lowerClip, max_eq_left hx] + have := le_max_left y (-(n : ℝ)) + have := min_le_left g 0 + linarith + apply abs_le.mpr + constructor + · apply le_min + · exact neg_abs_le g + · exact (le_min (neg_abs_le g) (by simp)).trans hd + · exact (min_le_left _ _).trans (le_abs_self g) + +lemma integral_le_zero_of_identDistrib_lower_bound + {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsFiniteMeasure μ] + {X Y G : α → ℝ} (hXY : IdentDistrib X Y μ μ) + (hX : ∀ᵐ a ∂μ, X a ≤ 0) (hY : ∀ᵐ a ∂μ, Y a ≤ 0) + (hG : Integrable G μ) (hlower : ∀ᵐ a ∂μ, G a ≤ Y a - X a) : + ∫ a, G a ∂μ ≤ 0 := by + let D : ℕ → α → ℝ := fun n a => lowerClip n (Y a) - lowerClip n (X a) + let F : ℕ → α → ℝ := fun n a => min (G a) (D n a) + have hclipmeas (n : ℕ) : Measurable (lowerClip n) := + measurable_id.max measurable_const + have hclipint (Z : α → ℝ) (hZm : AEMeasurable Z μ) + (hZ : ∀ᵐ a ∂μ, Z a ≤ 0) (n : ℕ) : + Integrable (fun a => lowerClip n (Z a)) μ := by + apply Integrable.of_bound ((hclipmeas n).comp_aemeasurable hZm).aestronglyMeasurable n + filter_upwards [hZ] with a ha + rw [Real.norm_eq_abs] + apply abs_le.mpr + constructor + · exact le_max_right _ _ + · show max (Z a) (-(n : ℝ)) ≤ (n : ℝ) + exact max_le (ha.trans (Nat.cast_nonneg n)) (by linarith [Nat.cast_nonneg (α := ℝ) n]) + have hDX (n : ℕ) := hclipint X hXY.aemeasurable_fst hX n + have hDY (n : ℕ) := hclipint Y hXY.aemeasurable_snd hY n + have hDint (n : ℕ) : Integrable (D n) μ := (hDY n).sub (hDX n) + have hFm (n : ℕ) : AEStronglyMeasurable (F n) μ := + (hG.aemeasurable.min (hDint n).aemeasurable).aestronglyMeasurable + have hFbound (n : ℕ) : ∀ᵐ a ∂μ, ‖F n a‖ ≤ |G a| := by + filter_upwards [hlower] with a ha + exact lowerClip_sub_bound n (X a) (Y a) (G a) ha + have hFint (n : ℕ) : Integrable (F n) μ := + hG.abs.mono' (hFm n) (hFbound n) + have hDzero (n : ℕ) : ∫ a, D n a ∂μ = 0 := by + rw [show D n = (fun a => lowerClip n (Y a) - lowerClip n (X a)) from rfl, + integral_sub (hDY n) (hDX n)] + have hid := (hXY.comp (hclipmeas n)).integral_eq + change (∫ a, lowerClip n (X a) ∂μ) = (∫ a, lowerClip n (Y a) ∂μ) at hid + rw [hid, sub_self] + have hFnonpos (n : ℕ) : ∫ a, F n a ∂μ ≤ 0 := by + rw [← hDzero n] + exact integral_mono_ae (hFint n) (hDint n) (Eventually.of_forall fun a => min_le_right _ _) + have hlim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (G a)) := by + filter_upwards [hlower] with a ha + have hDlim := (lowerClip_tendsto (Y a)).sub (lowerClip_tendsto (X a)) + simpa only [min_eq_left ha] using (tendsto_const_nhds (x := G a)).min hDlim + exact le_of_tendsto + (tendsto_integral_of_dominated_convergence (fun a => |G a|) hFm hG.abs hFbound hlim) + (Eventually.of_forall hFnonpos) + +def prefixMax (z : ℕ → ℝ) : ℕ → ℝ + | 0 => 0 + | n + 1 => max (prefixMax z n) (z n) + +lemma prefixMax_nonneg (z : ℕ → ℝ) (n : ℕ) : 0 ≤ prefixMax z n := by + induction n with + | zero => rfl + | succ n ih => exact ih.trans (le_max_left _ _) + +lemma prefixMax_le_truncation (z : ℕ → ℝ) {T : ℝ} (hT : 0 ≤ T) (n : ℕ) : + prefixMax z n ≤ T + ∑ j ∈ Finset.range n, max (z j - T) 0 := by + induction n with + | zero => simpa [prefixMax] using hT + | succ n ih => + rw [prefixMax, Finset.sum_range_succ] + apply max_le + · linarith [le_max_right (z n - T) 0] + · have hsum : 0 ≤ ∑ j ∈ Finset.range n, max (z j - T) 0 := + Finset.sum_nonneg fun j _ => le_max_right _ _ + linarith [le_max_left (z n - T) 0] + +lemma integrable_prefixMax + {α : Type*} [MeasurableSpace α] (μ : Measure α) + {Z : ℕ → α → ℝ} (hZ : ∀ j, Integrable (Z j) μ) (n : ℕ) : + Integrable (fun a => prefixMax (fun j => Z j a) n) μ := by + induction n with + | zero => exact integrable_zero α ℝ μ + | succ n ih => exact ih.sup (hZ n) + +lemma integral_prefixMax_le + {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + {Z : ℕ → α → ℝ} (hZ : Integrable (Z 0) μ) + (hid : ∀ j, IdentDistrib (Z j) (Z 0) μ μ) {T : ℝ} (hT : 0 ≤ T) (n : ℕ) : + (∫ a, prefixMax (fun j => Z j a) n ∂μ) ≤ + T + n * ∫ a, max (Z 0 a - T) 0 ∂μ := by + have hint (j : ℕ) : Integrable (Z j) μ := (hid j).integrable_iff.mpr hZ + have htail (j : ℕ) : Integrable (fun a => max (Z j a - T) 0) μ := + ((hint j).sub (integrable_const _)).sup (integrable_const _) + calc + (∫ a, prefixMax (fun j => Z j a) n ∂μ) + ≤ ∫ a, T + ∑ j ∈ Finset.range n, max (Z j a - T) 0 ∂μ := by + apply integral_mono (integrable_prefixMax μ hint n) + ((integrable_const T).add (integrable_finsetSum _ fun j _ => htail j)) + intro a + exact prefixMax_le_truncation _ hT _ + _ = T + ∑ j ∈ Finset.range n, ∫ a, max (Z j a - T) 0 ∂μ := by + rw [integral_add (integrable_const T) + (integrable_finsetSum _ fun j _ => htail j), integral_const, + integral_finsetSum _ fun j _ => htail j] + simp + _ = T + n * ∫ a, max (Z 0 a - T) 0 ∂μ := by + congr 1 + have heq (j : ℕ) : (∫ a, max (Z j a - T) 0 ∂μ) = + ∫ a, max (Z 0 a - T) 0 ∂μ := + ((hid j).comp ((measurable_id.sub_const T).max measurable_const)).integral_eq + simp_rw [heq] + simp + +lemma integral_prefixMax_div_tendsto_zero + {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + {Z : ℕ → α → ℝ} (hZ : Integrable (Z 0) μ) + (hid : ∀ j, IdentDistrib (Z j) (Z 0) μ μ) : + Tendsto (fun n : ℕ => (∫ a, prefixMax (fun j => Z j a) n ∂μ) / n) + atTop (𝓝 0) := by + have htail : Tendsto (fun T : ℕ => ∫ a, max (Z 0 a - T) 0 ∂μ) atTop (𝓝 0) := by + have hbound (T : ℕ) : ∀ᵐ a ∂μ, ‖max (Z 0 a - T) 0‖ ≤ |Z 0 a| := by + apply Eventually.of_forall + intro a + rw [Real.norm_eq_abs, abs_of_nonneg (le_max_right _ _)] + apply max_le + · linarith [le_abs_self (Z 0 a), Nat.cast_nonneg (α := ℝ) T] + · exact abs_nonneg _ + have hlim : ∀ᵐ a ∂μ, + Tendsto (fun T : ℕ => max (Z 0 a - T) 0) atTop (𝓝 0) := by + apply Eventually.of_forall + intro a + obtain ⟨N, hN⟩ := exists_nat_ge (Z 0 a) + apply tendsto_const_nhds.congr' + filter_upwards [eventually_ge_atTop N] with n hn + have hcast : (N : ℝ) ≤ n := by exact_mod_cast hn + exact (max_eq_right (by linarith)).symm + simpa only [integral_zero] using tendsto_integral_of_dominated_convergence + (fun a => |Z 0 a|) + (fun T => (hZ.aemeasurable.sub_const T |>.max aemeasurable_const).aestronglyMeasurable) + hZ.abs hbound hlim + have hnonneg (n : ℕ) : 0 ≤ (∫ a, prefixMax (fun j => Z j a) n ∂μ) / n := + div_nonneg (integral_nonneg fun a => prefixMax_nonneg _ _) (Nat.cast_nonneg _) + apply tendsto_order.mpr + constructor + · intro a ha + exact Eventually.of_forall fun n => ha.trans_le (hnonneg n) + · intro ε hε + obtain ⟨T, hT⟩ := (htail.eventually (gt_mem_nhds (half_pos hε))).exists + have hdiv : Tendsto (fun n : ℕ => (T : ℝ) / n) atTop (𝓝 0) := + tendsto_natCast_atTop_atTop.const_div_atTop _ + filter_upwards [hdiv.eventually (gt_mem_nhds (half_pos hε)), + eventually_ge_atTop 1] with n hn hn1 + have hnpos : 0 < (n : ℝ) := by exact_mod_cast hn1 + have hbd := div_le_div_of_nonneg_right + (integral_prefixMax_le μ hZ hid (Nat.cast_nonneg T) n) hnpos.le + rw [add_div, mul_div_cancel_left₀ _ hnpos.ne'] at hbd + linarith + +lemma le_prefixMax (z : ℕ → ℝ) {j n : ℕ} (hj : j < n) : z j ≤ prefixMax z n := by + induction n with + | zero => omega + | succ n ih => + rcases lt_or_eq_of_le (Nat.le_of_lt_succ hj) with h | rfl + · exact (ih h).trans (le_max_left _ _) + · exact le_max_right _ _ + +lemma log_sum_le_log_add_prefixMax (h : ℕ → ℝ) (hh : ∀ j, 0 ≤ h j) + {n : ℕ} (hn : 0 < n) : + Real.log (1 + ∑ j ∈ Finset.range n, h j) ≤ + Real.log n + prefixMax (fun j => Real.log (1 + h j)) n := by + let M := prefixMax (fun j => Real.log (1 + h j)) n + have hnR : 0 < (n : ℝ) := by exact_mod_cast hn + have hsum : 0 ≤ ∑ j ∈ Finset.range n, h j := Finset.sum_nonneg fun j _ => hh j + apply (Real.log_le_iff_le_exp (by linarith)).mpr + rw [Real.exp_add, Real.exp_log hnR] + have hterm : ∀ j ∈ Finset.range n, 1 + h j ≤ Real.exp M := by + intro j hj + exact (Real.log_le_iff_le_exp (by linarith [hh j])).mp + (le_prefixMax (fun j => Real.log (1 + h j)) (Finset.mem_range.mp hj)) + have hbd := Finset.sum_le_sum hterm + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_range, + nsmul_eq_mul, mul_one] at hbd + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn + linarith + +lemma integral_log_sum_div_tendsto_zero + {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + {h : ℕ → α → ℝ} (hh : ∀ᵐ a ∂μ, ∀ j, 0 ≤ h j a) + (hid : ∀ j, IdentDistrib (h j) (h 0) μ μ) + (hint : Integrable (fun a => Real.log (1 + h 0 a)) μ) : + Tendsto (fun n : ℕ => (∫ a, Real.log (1 + ∑ j ∈ Finset.range n, h j a) ∂μ) / n) + atTop (𝓝 0) := by + let Z : ℕ → α → ℝ := fun j a => Real.log (1 + h j a) + have hZid (j : ℕ) : IdentDistrib (Z j) (Z 0) μ μ := + (hid j).comp (Real.measurable_log.comp (measurable_const.add measurable_id)) + have hZint (j : ℕ) : Integrable (Z j) μ := (hZid j).integrable_iff.mpr hint + have hnonneg (n : ℕ) : + 0 ≤ (∫ a, Real.log (1 + ∑ j ∈ Finset.range n, h j a) ∂μ) / n := by + apply div_nonneg _ (Nat.cast_nonneg _) + apply integral_nonneg_of_ae + filter_upwards [hh] with a ha + apply Real.log_nonneg + have := Finset.sum_nonneg (s := Finset.range n) (fun j _ => ha j) + linarith + have hupper : ∀ᶠ n : ℕ in atTop, + (∫ a, Real.log (1 + ∑ j ∈ Finset.range n, h j a) ∂μ) / n ≤ + Real.log n / n + (∫ a, prefixMax (fun j => Z j a) n ∂μ) / n := by + filter_upwards [eventually_ge_atTop 1] with n hn + have hn0 : 0 < n := by omega + have hm : AEStronglyMeasurable + (fun a => Real.log (1 + ∑ j ∈ Finset.range n, h j a)) μ := + (Real.measurable_log.comp_aemeasurable + (aemeasurable_const.add (Finset.aemeasurable_fun_sum _ fun j _ => (hid j).aemeasurable_fst))).aestronglyMeasurable + have hbd : ∀ᵐ a ∂μ, + Real.log (1 + ∑ j ∈ Finset.range n, h j a) ≤ + Real.log n + prefixMax (fun j => Z j a) n := by + filter_upwards [hh] with a ha + exact log_sum_le_log_add_prefixMax _ ha hn0 + have hubint : Integrable (fun a => Real.log n + prefixMax (fun j => Z j a) n) μ := + (integrable_const _).add (integrable_prefixMax μ hZint n) + have hsint : Integrable (fun a => Real.log (1 + ∑ j ∈ Finset.range n, h j a)) μ := by + apply hubint.mono' hm + filter_upwards [hh, hbd] with a ha hb + rw [Real.norm_eq_abs, abs_of_nonneg (Real.log_nonneg (by + have := Finset.sum_nonneg (s := Finset.range n) (fun j _ => ha j) + linarith))] + exact hb + have hbint := integral_mono_ae hsint hubint hbd + rw [integral_add (integrable_const _) (integrable_prefixMax μ hZint n)] at hbint + simp only [integral_const] at hbint + simp at hbint + have hd := div_le_div_of_nonneg_right hbint (Nat.cast_nonneg n) + simpa only [add_div] using hd + apply squeeze_zero' (Eventually.of_forall hnonneg) hupper + have hlog : Tendsto (fun n : ℕ => Real.log n / (n : ℝ)) atTop (𝓝 0) := by + simpa only [pow_one, one_mul, add_zero, Function.comp_def] using + (Real.tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero).comp + (tendsto_natCast_atTop_atTop (R := ℝ)) + simpa using hlog.add (integral_prefixMax_div_tendsto_zero μ hint hZid) + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MarkedObservables.lean b/lean/OAI/Probability/Ballisticity/Estimates/MarkedObservables.lean new file mode 100644 index 0000000000000000000000000000000000000000..588cb023cbaf733c77a6dfb0b8b369821c04ae78 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MarkedObservables.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.StationaryProfile +import OAI.Probability.Ballisticity.Stationary.ArrayMarkedIterate +import OAI.Probability.Ballisticity.Estimates.ProfileMeasureUpdate +import OAI.Probability.Ballisticity.Entropy.EntropyDensity + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +noncomputable def arrayNatHeight {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) : ℕ := + (Y.1 0).1.toNat +lemma arrayNatHeight_measurable {d : ℕ} (e : Direction d) : Measurable (arrayNatHeight e) := + (measurable_of_countable ENat.toNat).comp (by fun_prop) +lemma arrayNatHeight_positive {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h0 : 0<(Y.1 0).1) (ht : (Y.1 0).1<⊤) : 1≤arrayNatHeight e Y := by + have he := ENat.natCast_toNat ht.ne + rw [←he] at h0 + exact_mod_cast h0 + +lemma markedArrayLaw_integrable {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (E : Set (ActualEpisodeArray e)) (hE : μ E≠0) + (F : ActualEpisodeArray e → ℝ) (hF : Measurable F) (hFi : Integrable F μ) : + Integrable (fun p : MarkedArray e => F p.1) (markedArrayLaw e μ E) := by + have hi : Integrable F μ[|E] := hFi.integrableOn.smul_measure (ENNReal.inv_ne_top.mpr hE) + apply (integrable_map_measure hF.aestronglyMeasurable measurable_fst.aemeasurable).mp + change Integrable F (markedArrayLaw e μ E).fst + rwa [markedArrayLaw_fst] + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma marked_proper_entropy (L : StationaryArrayLaw ν e) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) + (w₀ : ProperProfile e) (n : ℕ) : + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + let data := fun p => properData e w₀ (markedData e p) + klDiv (μ.map (fun p => (data p,markedUpper e n p))) + ((μ.map data).prod (Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)))≠∞ := by + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + have := markedArrayLaw_probability e (L.law : Measure (ActualEpisodeArray e)) G.event G.positive_event.ne' + let U := Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν) + have hk := L.marked_upper_entropy G n + dsimp only at hk ⊢ + rw [Measure.fst_map_prodMk (markedData_measurable e) (markedUpper_measurable e n)] at hk + have h := klDiv_map_le (μ.map (fun p => (markedData e p,markedUpper e n p))) + ((μ.map (markedData e)).prod U) ((properData_measurable e w₀).prodMap measurable_id) + have hprod := Measure.map_prod_map (μ.map (markedData e)) U (properData_measurable e w₀) measurable_id + rw [Measure.map_id] at hprod + rw [←hprod,Measure.map_map (properData_measurable e w₀) (markedData_measurable e), + Measure.map_map ((properData_measurable e w₀).prodMap measurable_id) + ((markedData_measurable e).prodMk (markedUpper_measurable e n))] at h + exact ne_top_of_le_ne_top hk h + +lemma marked_full_entropy (L : StationaryArrayLaw ν e) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) + (w₀ : ProperProfile e) (n : ℕ) : + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + let data := fun p : MarkedArray e × Environment d => properData e w₀ (markedData e p.1) + let field := fun p : MarkedArray e × Environment d => fillUpper e (markedUpper e n p.1,p.2) + ∃ g : ProperProfile e × Environment d → ℝ, Measurable g ∧ (∀ z,0≤g z) ∧ + Integrable g (((μ.prod (environmentLaw ν)).map data).prod (environmentLaw ν)) ∧ + (∫ z, g z ∂((μ.prod (environmentLaw ν)).map data).prod (environmentLaw ν))=1 ∧ + Integrable (fun z => TailDecorrelation.entropyPlus (g z)) + (((μ.prod (environmentLaw ν)).map data).prod (environmentLaw ν)) ∧ + (μ.prod (environmentLaw ν)).map (fun p => (data p,field p))= + (((μ.prod (environmentLaw ν)).map data).prod (environmentLaw ν)).withDensity (fun z => ENNReal.ofReal (g z)) := by + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + have := markedArrayLaw_probability e (L.law : Measure (ActualEpisodeArray e)) G.event G.positive_event.ne' + let data := fun p : MarkedArray e => properData e w₀ (markedData e p) + have hd : Measurable data := (properData_measurable e w₀).comp (markedData_measurable e) + have hf : Measurable (fun p : MarkedArray e × Environment d => fillUpper e (markedUpper e n p.1,p.2)) := + (fillUpper_measurable e).comp (((markedUpper_measurable e n).comp measurable_fst).prodMk measurable_snd) + have hkl := fillUpper_finite_entropy e ν μ data hd (markedUpper e n) (markedUpper_measurable e n) + (L.marked_proper_entropy G w₀ n) + have hdata : (μ.prod (environmentLaw ν)).map (fun p => data p.1)=μ.map data := by + rw [show (fun p : MarkedArray e × Environment d => data p.1)=data ∘ Prod.fst from rfl, + ←Measure.map_map hd measurable_fst,Measure.map_fst_prod,measure_univ,one_smul] + have : IsProbabilityMeasure ((μ.prod (environmentLaw ν)).map + (fun p => (data p.1,fillUpper e (markedUpper e n p.1,p.2)))) := + (Measure.isProbabilityMeasure_map_iff + ((hd.comp measurable_fst).prodMk hf).aemeasurable).mpr inferInstance + have : IsProbabilityMeasure (μ.map data) := + (Measure.isProbabilityMeasure_map_iff hd.aemeasurable).mpr inferInstance + have h := Entropy.density_of_finite_kl _ _ hkl + dsimp only [μ,data] at hdata h ⊢ + simpa only [hdata] using h + +end StationaryArrayLaw +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical BigOperators +namespace DirectionalTransience + +lemma arrayProfileMeasure_translation {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hp : ArrayProfilesConsistent e Y) (j : ℤ) (p q : StationaryCompact.Label) + (v : HorizontalSpace e) (hv : Y.2.1 (p,q)=(v:OnePoint (HorizontalSpace e))) : + (arrayProfileMeasure e j q Y).map (fun x => x+v)=arrayProfileMeasure e j p Y := by + apply Measure.ext_of_singleton + intro x + rw [Measure.map_apply (measurable_of_countable _) (measurableSet_singleton _)] + have he : (fun y : HorizontalSpace e => y+v) ⁻¹' {x}={x-v} := by + ext y + simp only [Set.mem_preimage,Set.mem_singleton_iff] + exact eq_sub_iff_add_eq.symm + rw [he,arrayProfileMeasure_atom,arrayProfileMeasure_atom] + unfold arrayProfileMass + rw [←hp.1 j p q v (x-v) hv] + congr 2 + abel_nf + +lemma arrayProfileMeasure_iterate {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (n a : ℕ) : arrayProfileMeasure e 0 (0,a) (StationaryCompact.shift^[n] Y)= + arrayProfileMeasure e n (n,a) Y := by + apply Measure.ext_of_singleton + intro z + simp only [arrayProfileMeasure_atom,arrayProfileMass,arrayProfile_iterate,zero_add] + +lemma arrayHeight_sum {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hf : ∀ j, (Y.1 j).1<⊤) (n : ℕ) : + arrayWindowHeight e 0 n Y=(∑ i∈Finset.range n, arrayNatHeight e (StationaryCompact.shift^[i] Y):ℕ) := by + simp only [arrayWindowHeight,Nat.cast_sum,arrayNatHeight,arrayMark_iterate,zero_add] + apply Finset.sum_congr rfl + intro j _ + exact (ENat.natCast_toNat (hf j).ne).symm + +lemma exp_sum_discount {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hf : ∀ j, (Y.1 j).2.2≠⊤) (n : ℕ) : + ENNReal.ofReal (Real.exp (∑ i∈Finset.range n, arrayRealCost e (StationaryCompact.shift^[i] Y))) * + expNeg (arrayWindowCost e 0 n Y)=1 := by + have hc : arrayWindowCost e 0 n Y≠⊤ := ENNReal.sum_ne_top.mpr fun j _ => hf _ + rw [←ENNReal.ofReal_toReal (expNeg_ne_top _),expNeg_toReal_of_ne_top _ hc, + arrayWindowCost_toReal e Y hf,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + simp + +lemma markedCoordinateProfile_eq {d : ℕ} (e : Direction d) (f : Fin d) (w₀ : ProperProfile e) + (p : MarkedArray e) (hp : IsProperProfile e (markedProfile e (markedData e p))) : + coordinateProfile e f (properProfileKernel e) (properData e w₀ (markedData e p))= + (arrayProfileMeasure e 0 (0,p.2) p.1).map (fun x => x.1 f) := by + rw [coordinateProfile_apply,properData_kernel_eq e w₀ p hp, + Measure.map_map (measurable_of_countable _) (measurable_of_countable _)] + rfl + +lemma markedProfile_update {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1≠f) + (w₀ : ProperProfile e) (p : MarkedArray e) (ω : Environment d) (n : ℕ) + (hp : ArrayProfilesConsistent e p.1) (hc : ArrayContinuation e p.1) + (hh : ∀ j, (p.1.1 j).1<⊤) (hcost : ∀ j, (p.1.1 j).2.2≠⊤) + (hrel : ArrayRelated e p.1 (0,p.2) (n,((markedShift e)^[n] p).2)) + (h0 : IsProperProfile e (markedProfile e (markedData e p))) + (hn : IsProperProfile e (markedProfile e (markedData e ((markedShift e)^[n] p)))) : + ENNReal.ofReal (Real.exp (∑ i∈Finset.range n, arrayRealCost e (((markedShift e)^[i] p).1))) • + (horizontalCoordinateKernel e f (∑ i∈Finset.range n, arrayNatHeight e (((markedShift e)^[i] p).1)) + (fillUpper e (markedUpper e n p,ω)) ∘ₘ properProfileKernel e (properData e w₀ (markedData e p))) ≤ + (coordinateProfile e f (properProfileKernel e) (properData e w₀ (markedData e ((markedShift e)^[n] p)))).map + (fun x => x+(markedDisplacement e n p).val f) := by + simp only [markedShift_iterate_fst] + rw [properData_kernel_eq e w₀ p h0,horizontalProfileImage_fill e f hef] + have hu := arrayProfile_measure_update e 0 n p.2 _ p.1 hc (arrayHeight_sum e p.1 hh n) + have hu' := smul_le_smul_left (ENNReal.ofReal (Real.exp (∑ i∈Finset.range n, arrayRealCost e (StationaryCompact.shift^[i] p.1)))) hu + rw [smul_smul,exp_sum_discount e p.1 hcost n,one_smul] at hu' + have hu'' := Measure.map_mono hu' (measurable_of_countable (fun x : HorizontalSpace e => x.1 f)) + rw [Measure.map_smul _ (measurable_of_countable _).aemeasurable] at hu'' + change _≤(arrayProfileMeasure e (0+n) (0,p.2) p.1).map (fun x => x.1 f) at hu'' + simp only [zero_add] at hu'' + refine hu''.trans_eq ?_ + rw [markedCoordinateProfile_eq e f w₀ _ hn,markedShift_iterate_fst,arrayProfileMeasure_iterate] + rw [←arrayProfileMeasure_translation e p.1 hp n (0,p.2) (n,((markedShift e)^[n] p).2) + (markedDisplacement e n p) (markedDisplacement_spec e n p hrel)] + rw [Measure.map_map (measurable_of_countable _) (measurable_of_countable _), + Measure.map_map (measurable_of_countable _) (measurable_of_countable _)] + rfl + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MartingaleExponentialSubmartingale.lean b/lean/OAI/Probability/Ballisticity/Estimates/MartingaleExponentialSubmartingale.lean new file mode 100644 index 0000000000000000000000000000000000000000..6825a5de6e27ed34a4fdd94d8ff548cf8898398f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MartingaleExponentialSubmartingale.lean @@ -0,0 +1,429 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma martingale_exponential_submartingale {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F : Filtration ℕ ‹MeasurableSpace Ω›) + (X : ℕ → Ω → ℝ) (hX : Martingale X F μ) + (hi : ∀ n, Integrable (fun ω => Real.exp (X n ω)) μ) : + Submartingale (fun n ω => Real.exp (X n ω)) F μ := by + refine ⟨fun n => Real.continuous_exp.comp_stronglyMeasurable (hX.stronglyMeasurable n), ?_, hi⟩ + intro i j hij + have h := ConvexOn.map_condExp_le_univ (F.le i) convexOn_exp + Real.continuous_exp.lowerSemicontinuous (hX.integrable j) (hi j) + filter_upwards [h,hX.condExp_ae_eq hij] with ω hω he + simpa only [Function.comp_def,he] using hω + +lemma martingale_exponential_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F : Filtration ℕ ‹MeasurableSpace Ω›) + (X : ℕ → Ω → ℝ) (hX : Martingale X F μ) + (hi : ∀ n, Integrable (fun ω => Real.exp (X n ω)) μ) (n : ℕ) (a : ℝ) : + μ.real {ω | ∃ k≤n, a≤X k ω} ≤ + Real.exp (-a)*(∫ ω, Real.exp (X n ω) ∂μ) := by + let Y := fun n ω => Real.exp (X n ω) + have hY : Submartingale Y F μ := martingale_exponential_submartingale μ F X hX hi + let ε : ℝ≥0 := ⟨Real.exp a,(Real.exp_pos a).le⟩ + have h := maximal_ineq hY (fun _ _ => (Real.exp_pos _).le) (ε:=ε) n + have hset : {ω | (ε:ℝ) ≤ (Finset.range (n+1)).sup' Finset.nonempty_range_add_one (fun k => Y k ω)} = + {ω | ∃ k≤n, a≤X k ω} := by + ext ω + simp only [Set.mem_ofPred_eq,Finset.le_sup'_iff,Finset.mem_range,Nat.lt_succ_iff] + exact exists_congr fun k => and_congr_right fun _ => Real.exp_le_exp + rw [hset] at h + have hr := ENNReal.toReal_mono ENNReal.ofReal_ne_top h + simp only [ENNReal.toReal_mul,ENNReal.coe_toReal] at hr + rw [ENNReal.toReal_ofReal (show 0 ≤ ∫ ω in {ω | ∃ k≤n, a≤X k ω}, Y n ω ∂μ from + integral_nonneg (fun ω => (Real.exp_pos (X n ω)).le))] at hr + change Real.exp a * μ.real {ω | ∃ k≤n, a≤X k ω} ≤ + ∫ ω in {ω | ∃ k≤n, a≤X k ω}, Real.exp (X n ω) ∂μ at hr + have hb := hr.trans (setIntegral_le_integral (hi n) (Eventually.of_forall fun _ => (Real.exp_pos _).le)) + have hb' : μ.real {ω | ∃ k≤n, a≤X k ω} ≤ (∫ ω,Real.exp (X n ω) ∂μ)/Real.exp a := + (le_div_iff₀ (Real.exp_pos a)).2 (by simpa only [mul_comm] using hb) + simpa only [div_eq_mul_inv,← Real.exp_neg,mul_comm] using hb' + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma gaussian_martingale_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Filtration ℕ ‹MeasurableSpace Ω›) + (X : ℕ → Ω → ℝ) (hX : Martingale X F μ) (v : ℕ → ℝ≥0) + (hLaw : ∀ n, μ.map (X n) = gaussianReal 0 (v n)) + (n : ℕ) (hv : 0 < (v n:ℝ)) (a : ℝ) (ha : 0 Real.exp (c*X j ω)) μ := by + have hh : Integrable (fun z : ℝ => Real.exp (c*z)) (μ.map (X j)) := by + rw [hLaw j] + exact integrable_exp_mul_gaussianReal c + exact (integrable_map_measure (by fun_prop) (hXm j).aemeasurable).mp hh + have hh := martingale_exponential_maximal μ F (c • X) (hX.smul c) hi n (c*a) + have hs : {ω | ∃ k≤n, c*a ≤ (c • X) k ω} = {ω | ∃ k≤n, a≤X k ω} := by + ext ω + simp only [Set.mem_ofPred_eq,Pi.smul_apply,smul_eq_mul,mul_le_mul_iff_right₀ hc] + rw [hs] at hh + have he : (∫ ω, Real.exp ((c • X) n ω) ∂μ) = Real.exp ((v n:ℝ)*c^2/2) := by + simpa only [mgf,Pi.smul_apply,smul_eq_mul,zero_mul,zero_add] using + mgf_gaussianReal ⟨(hXm n).aemeasurable, hLaw n⟩ c + rw [he,← Real.exp_add] at hh + convert hh using 1 + congr 1 + dsimp [c] + field_simp + ring + +lemma gaussian_martingale_abs_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Filtration ℕ ‹MeasurableSpace Ω›) + (X : ℕ → Ω → ℝ) (hX : Martingale X F μ) (v : ℕ → ℝ≥0) + (hLaw : ∀ n, μ.map (X n) = gaussianReal 0 (v n)) + (n : ℕ) (hv : 0 < (v n:ℝ)) (a : ℝ) (ha : 0 ∑ j ∈ Finset.range (n+1), X j ω) + (Filtration.natural X (fun n => (hXm n).stronglyMeasurable)) μ := by + let F := Filtration.natural X (fun n => (hXm n).stronglyMeasurable) + have hA : StronglyAdapted F X := Filtration.stronglyAdapted_natural _ + have hsum (n : ℕ) : StronglyMeasurable[F n] (fun ω => ∑ j ∈ Finset.range (n+1), X j ω) := by + have he : (fun ω => ∑ j ∈ Finset.range (n+1), X j ω) = + ∑ j ∈ Finset.range (n+1), X j := by funext ω; simp + rw [he] + exact Finset.stronglyMeasurable_sum (Finset.range (n+1)) + (fun j hj => (hA j).mono (F.mono (Nat.lt_succ_iff.mp (Finset.mem_range.mp hj)))) + have hsi (n : ℕ) : Integrable (fun ω => ∑ j ∈ Finset.range (n+1), X j ω) μ := + integrable_finsetSum _ (fun j _ => hi j) + apply martingale_nat hsum hsi + intro n + have he : (fun ω => ∑ j ∈ Finset.range (n+1+1), X j ω) = + (fun ω => ∑ j ∈ Finset.range (n+1), X j ω) + X (n+1) := by + funext ω + simp only [Finset.sum_range_succ,Pi.add_apply] + rw [he] + have hh := condExp_add (hsi n) (hi (n+1)) (F n) + have hx := hind.condExp_natural_ae_eq_of_lt (fun n => (hXm n).stronglyMeasurable) + (Nat.lt_succ_self n) + have hs := condExp_of_stronglyMeasurable (F.le n) (hsum n) (hsi n) + filter_upwards [hh,hx] with ω hω hxω + rw [hω,hs] + simpa only [Pi.add_apply,hmean,add_zero] using (congrArg + (fun z => (∑ j ∈ Finset.range (n+1), X j ω)+z) hxω).symm + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MaxTailDecomposition.lean b/lean/OAI/Probability/Ballisticity/Estimates/MaxTailDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..89a96d0ddd6392f00dcff99f233e118c1d35c002 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MaxTailDecomposition.lean @@ -0,0 +1,166 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SmallScaleGaussianMass + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma partialSumMax_add_le (X Y : ℕ → ℝ) (n : ℕ) : + partialSumMax (fun k => X k+Y k) n ≤ partialSumMax X n+partialSumMax Y n := by + induction n with + | zero => simp [partialSumMax] + | succ n ih => + apply max_le + · exact ih.trans (add_le_add (partialSumMax_mono X (Nat.le_succ n)) (partialSumMax_mono Y (Nat.le_succ n))) + · rw [show realPartialSum (fun k => X k+Y k) (n+1) = realPartialSum X (n+1)+realPartialSum Y (n+1) from by simp [realPartialSum,Finset.sum_add_distrib]] + exact (abs_add_le _ _).trans (add_le_add (abs_partialSum_le_max X _) (abs_partialSum_le_max Y _)) + +lemma square_tail_le_fourth_add {M U V a : ℝ} (hM0 : 0 ≤ M) (hU0 : 0 ≤ U) (hV0 : 0 ≤ V) + (ha : 0 < a) (hM : M ≤ U+V) : + (if a < M then M^2 else 0) ≤ (16/a^2)*U^4+4*V^2 := by + have ha2 : 0 < a^2 := sq_pos_of_pos ha + have hnon : 0 ≤ (16/a^2)*U^4 := mul_nonneg (by positivity) (pow_nonneg hU0 _) + by_cases ham : a < M + · rw [ite_eq_left ham] + by_cases hau : a/2 < U + · have hs : a^2 ≤ 4*U^2 := by nlinarith + have hp := mul_le_mul_of_nonneg_right hs (sq_nonneg U) + have hu : 4*U^2 ≤ (16/a^2)*U^4 := by + rw [show (16/a^2)*U^4 = (16*U^4)/a^2 by ring] + apply (le_div_iff₀ ha2).mpr + nlinarith [hp] + have hm2 : M^2 ≤ 2*U^2+2*V^2 := by nlinarith [sq_nonneg (U-V),pow_le_pow_left₀ hM0 hM 2] + nlinarith [sq_nonneg U,sq_nonneg V] + · have hUV : U ≤ V := by linarith [le_of_not_gt hau] + have hm2 : M^2 ≤ 4*V^2 := by nlinarith [pow_le_pow_left₀ hM0 hM 2,sq_nonneg (V-U)] + linarith + · rw [ite_eq_right ham] + exact add_nonneg hnon (mul_nonneg (by norm_num) (pow_nonneg hV0 2)) + +lemma capped_max_tail_decomposition (X : ℕ → ℝ) (n : ℕ) {z R a : ℝ} + (hz : 0 ≤ z) (hzR : z ≤ R) (ha : 0 < a) : + (if a < partialSumMax X n then min ((partialSumMax X n)^2) (R^2) else 0) ≤ + (16/a^2)*(partialSumMax (fun k => symmetricTruncate z (X k)) n)^4+ + 4*(partialSumMax (fun k => bandTruncate z R (X k)) n)^2+ + ∑ k ∈ Finset.range n, truncatedTailCost R (X k) := by + have hcost0 : 0 ≤ ∑ k ∈ Finset.range n, truncatedTailCost R (X k) := + Finset.sum_nonneg (fun k _ => truncatedTailCost_nonneg _ _) + have hfirst0 : 0 ≤ (16/a^2)*(partialSumMax (fun k => symmetricTruncate z (X k)) n)^4 := by positivity + have hsecond0 : 0 ≤ 4*(partialSumMax (fun k => bandTruncate z R (X k)) n)^2 := by positivity + by_cases hbig : ∃ k < n, R < |X k| + · obtain ⟨k,hkn,hk⟩ := hbig + have hcost : R^2 ≤ ∑ j ∈ Finset.range n, truncatedTailCost R (X j) := by + have hh := Finset.single_le_sum (f := fun j => truncatedTailCost R (X j)) + (fun j _ => truncatedTailCost_nonneg _ _) (Finset.mem_range.mpr hkn) + simpa only [truncatedTailCost,ite_eq_left hk] using hh + split_ifs + · exact (min_le_right _ _).trans (by linarith) + · exact (pow_nonneg (hz.trans hzR) 2).trans + (hcost.trans (le_add_of_nonneg_left (add_nonneg hfirst0 hsecond0))) + · have hc (k) (hk : k < n) : X k = symmetricTruncate z (X k)+bandTruncate z R (X k) := by + have hR : |X k| ≤ R := le_of_not_gt (fun hh => hbig ⟨k,hk,hh⟩) + simp only [bandTruncate,symmetricTruncate,ite_eq_left hR] + ring + have heq := partialSumMax_congr n hc + have hM : partialSumMax X n ≤ partialSumMax (fun k => symmetricTruncate z (X k)) n+ + partialSumMax (fun k => bandTruncate z R (X k)) n := by + rw [heq] + exact partialSumMax_add_le _ _ n + have hh := square_tail_le_fourth_add (partialSumMax_nonneg X n) + (partialSumMax_nonneg _ _) (partialSumMax_nonneg _ _) ha hM + have hcap : (if a < partialSumMax X n then min ((partialSumMax X n)^2) (R^2) else 0) ≤ + (if a < partialSumMax X n then (partialSumMax X n)^2 else 0) := by + split_ifs <;> first | exact min_le_left _ _ | rfl + exact hcap.trans (hh.trans (le_add_of_nonneg_right hcost0)) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma integrable_truncatedTailCost_comp {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (hS : Measurable S) (R : ℝ) : + Integrable (fun x => truncatedTailCost R (S x)) μ := by + apply integrable_of_abs_bound μ _ ((measurable_truncatedTailCost R).comp hS) (R^2) + intro x + change |truncatedTailCost R (S x)| ≤ R^2 + unfold truncatedTailCost + split_ifs <;> simp [abs_of_nonneg (sq_nonneg R),sq_nonneg R] + +lemma integral_iid_max_tail_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {z R a : ℝ} (hz : 0 ≤ z) (hzR : z ≤ R) (ha : 0 < a) (n : ℕ) : + (∫ ω, (if a < partialSumMax (fun k => X k ω) n then + min ((partialSumMax (fun k => X k ω) n)^2) (R^2) else 0) ∂μ) ≤ + (16/a^2)*(32*(n:ℝ)*z^2*truncatedVariance μ (X 0) z+ + 96*(n:ℝ)^2*(truncatedVariance μ (X 0) z)^2)+ + 16*(n:ℝ)*(truncatedVariance μ (X 0) R-truncatedVariance μ (X 0) z+ + z^2*μ.real {ω | z < |X 0 ω|}) := by + let Y := fun k ω => symmetricTruncate z (X k ω) + let B := fun k ω => bandTruncate z R (X k ω) + have hY (k) : Measurable (Y k) := (measurable_symmetricTruncate z).comp (hX k) + have hB (k) : Measurable (B k) := (measurable_bandTruncate z R).comp (hX k) + have hBb (k) (ω) : |B k ω| ≤ R := bandTruncate_bound hz hzR _ + have hYi : Integrable (fun ω => (partialSumMax (fun k => Y k ω) n)^4) μ := + integrable_partialSumMax_pow μ Y hY hz (fun k ω => symmetricTruncate_bound hz _) n 4 + have hBi : Integrable (fun ω => (partialSumMax (fun k => B k ω) n)^2) μ := + integrable_partialSumMax_pow μ B hB (hz.trans hzR) hBb n 2 + have hTi (k) := integrable_truncatedTailCost_comp μ (X k) (hX k) R + have hM : Measurable (fun ω => partialSumMax (fun k => X k ω) n) := measurable_partialSumMax X hX n + have hLeft : Integrable (fun ω => if a < partialSumMax (fun k => X k ω) n then + min ((partialSumMax (fun k => X k ω) n)^2) (R^2) else 0) μ := by + apply integrable_of_abs_bound μ _ (Measurable.ite (measurableSet_lt measurable_const hM) + ((hM.pow_const 2).min measurable_const) measurable_const) (R^2) + intro ω + split_ifs + · rw [abs_of_nonneg (le_min (sq_nonneg _) (sq_nonneg R))] + exact min_le_right _ _ + · simpa using sq_nonneg R + have hDom := integral_mono hLeft (((hYi.const_mul (16/a^2)).add (hBi.const_mul 4)).add + (integrable_finsetSum (Finset.range n) (fun k _ => hTi k))) + (fun ω => capped_max_tail_decomposition (fun k => X k ω) n hz hzR ha) + have hAdd₁ := integral_add ((hYi.const_mul (16/a^2)).add (hBi.const_mul 4)) + (integrable_finsetSum (Finset.range n) (fun k _ => hTi k)) + have hAdd₂ := integral_add (hYi.const_mul (16/a^2)) (hBi.const_mul 4) + simp only [Pi.add_apply] at hDom hAdd₁ hAdd₂ + rw [hAdd₁,hAdd₂,integral_const_mul,integral_const_mul, + integral_finsetSum _ (fun k _ => hTi k)] at hDom + have hYbound := integral_iid_truncated_max_fourth_le μ X hX hind hident hsym hz le_rfl n + have hBind : iIndepFun B μ := hind.comp (fun _ => bandTruncate z R) (fun _ => measurable_bandTruncate z R) + have hBid (k) : IdentDistrib (B k) (B 0) μ μ := (hident k).comp (measurable_bandTruncate z R) + have hBm0 : ∫ ω, B 0 ω ∂μ = 0 := integral_bandTruncate_zero μ (X 0) z R hsym + have hBmean (k) : ∫ ω, B k ω ∂μ = 0 := (hBid k).integral_eq.trans hBm0 + have hBbound := integral_partialSumMax_square_le_sum μ B hB hBind hBmean (hz.trans hzR) hBb n + have hBeq (k) : (∫ ω, (B k ω)^2 ∂μ) = ∫ ω, (B 0 ω)^2 ∂μ := + ((hBid k).comp (measurable_id.pow_const 2)).integral_eq + simp only [hBeq,Finset.sum_const,Finset.card_range,nsmul_eq_mul] at hBbound + have hTeq (k) : (∫ ω, truncatedTailCost R (X k ω) ∂μ) = R^2*μ.real {ω | R < |X 0 ω|} := + ((hident k).comp (measurable_truncatedTailCost R)).integral_eq.trans (integral_truncatedTailCost μ (X 0) (hX 0) R) + simp only [hTeq,Finset.sum_const,Finset.card_range,nsmul_eq_mul] at hDom + have heq := integral_bandTruncate_cost μ (X 0) (hX 0) hz hzR + have htail0 : 0 ≤ R^2*μ.real {ω | R < |X 0 ω|} := mul_nonneg (sq_nonneg _) (measureReal_nonneg) + have hproduct := mul_le_mul_of_nonneg_left hYbound (show 0 ≤ 16/a^2 by positivity) + change (∫ ω, (B 0 ω)^2 ∂μ)+R^2*μ.real {ω | R < |X 0 ω|} = _ at heq + rw [← heq] + nlinarith [mul_nonneg (show 0 ≤ (n:ℝ) by positivity) htail0] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MeasurableCountableSample.lean b/lean/OAI/Probability/Ballisticity/Estimates/MeasurableCountableSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c2bcd300b35151e080988953950707f42a2e34c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MeasurableCountableSample.lean @@ -0,0 +1,245 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OutwardCapL1 +import OAI.Probability.Ballisticity.Entropy.EntropyDecorrelation + +namespace OAI + +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BigOperators +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace TailDecorrelation + +section SampledSites + +variable {D I A J : Type*} [MeasurableSpace D] [MeasurableSpace A] [Encodable I] +variable [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J] +variable (δ : Measure D) (ν : Measure A) [IsProbabilityMeasure δ] [IsProbabilityMeasure ν] + +omit [Encodable I] in +lemma measurable_countable_sample {Z : J → (I → A) → ℝ} + (hZ : ∀ j, Measurable (Z j)) {j : D → J} (hj : Measurable j) : + Measurable (fun x : D × (I → A) => Z (j x.1) x.2) := by + have hm : Measurable (Function.uncurry Z) := measurable_from_prod_countable_right hZ + exact hm.comp ((hj.comp measurable_fst).prodMk measurable_snd) + +omit [Encodable I] in +lemma sampled_exponential_integrable {Z : J → (I → A) → ℝ} {s Q : ℝ} + (hZ : ∀ j, Measurable (Z j)) + (he : ∀ j, Integrable (fun ω => Real.exp (s * Z j ω)) (Measure.infinitePi (fun _ : I => ν))) + (heQ : ∀ j, (∫ ω, Real.exp (s * Z j ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q) + {j : D → J} (hj : Measurable j) : + Integrable (fun x : D × (I → A) => Real.exp (s * Z (j x.1) x.2)) + (δ.prod (Measure.infinitePi (fun _ : I => ν))) ∧ + (∫ x : D × (I → A), Real.exp (s * Z (j x.1) x.2) + ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) ≤ Q := by + let P := Measure.infinitePi (fun _ : I => ν) + let F : D × (I → A) → ℝ := fun x => Real.exp (s * Z (j x.1) x.2) + have hF : Measurable F := Real.measurable_exp.comp + (measurable_const.mul (measurable_countable_sample hZ hj)) + have hFm : Measurable (fun d => ∫ ω, F (d, ω) ∂P) := hF.stronglyMeasurable.integral_prod_right.measurable + have hFi : Integrable (fun d => ∫ ω, F (d, ω) ∂P) δ := + integrable_bounded_nonneg hFm (fun d => integral_nonneg fun ω => (Real.exp_pos _).le) + (fun d => heQ (j d)) + have hi : Integrable F (δ.prod P) := by + apply (integrable_prod_iff hF.aestronglyMeasurable).mpr + refine ⟨Eventually.of_forall (fun d => he (j d)), ?_⟩ + simpa only [F, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] using hFi + refine ⟨hi, ?_⟩ + change (∫ x, F x ∂δ.prod P) ≤ Q + rw [integral_prod _ hi] + calc + (∫ d, ∫ ω, F (d, ω) ∂P ∂δ) ≤ (∫ _ : D, Q ∂δ) := integral_mono hFi (integrable_const Q) (fun d => heQ (j d)) + _ = Q := by simp + +omit [Encodable I] [IsProbabilityMeasure δ] [IsProbabilityMeasure ν] in +lemma sampled_locality {Z : J → (I → A) → ℝ} + (N : ℕ → J → Set I) (j : ℕ → D → J) (hj : ∀ r, Measurable (j r)) + (hloc : ∀ K η : ℝ, 0 < K → 0 < η → ∃ n : ℕ, ∃ F : J → (I → A) → ℝ, + (∀ a, @Measurable _ _ (rows (N n a)) _ (F a)) ∧ + (∀ a ω, 0 ≤ F a ω ∧ F a ω ≤ K) ∧ + (∀ a, (∫ ω, |min K (Z a ω) - F a ω| ∂Measure.infinitePi (fun _ : I => ν)) ≤ η)) + (hescape : ∀ n (S : Set I), S.Finite → ∀ᵐ d ∂δ, + ∀ᶠ r in atTop, Disjoint S (N n (j r d))) : + ∀ K > 0, EscapingLocalApproximation δ ν + (fun r x => min K (Z (j r x.1) x.2)) K := by + intro K hK η hη + obtain ⟨n, F, hFm, hFb, hFerr⟩ := hloc K η hK hη + refine ⟨fun r x => F (j r x.1) x.2, fun r d => N n (j r d), ?_, ?_, ?_, ?_, ?_⟩ + · intro r + exact measurable_countable_sample (fun a => (hFm a).mono (rows_le _) le_rfl) (hj r) + · exact fun r x => hFb _ _ + · exact fun r d => hFm _ + · exact fun r d => hFerr (j r d) + · exact fun S hS => hescape n S hS + +lemma sampled_entropy_decorrelation {f : D × (I → A) → ℝ} {Z : J → (I → A) → ℝ} + {c Q C : ℝ} (hc : 0 < c) (hC : 0 ≤ C) + (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) + (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hf1 : (∫ x, f x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) = 1) + (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hZ : ∀ a, Measurable (Z a)) (hZ0 : ∀ a ω, 0 ≤ Z a ω) + (he : ∀ a, Integrable (fun ω => Real.exp ((2 * c) * Z a ω)) (Measure.infinitePi (fun _ : I => ν))) + (heQ : ∀ a, (∫ ω, Real.exp ((2 * c) * Z a ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q) + (hZi : ∀ a, Integrable (Z a) (Measure.infinitePi (fun _ : I => ν))) + (hZC : ∀ a, (∫ ω, Z a ω ∂Measure.infinitePi (fun _ : I => ν)) ≤ C) + (N : ℕ → J → Set I) (j : ℕ → D → J) (hj : ∀ r, Measurable (j r)) + (hloc : ∀ K η : ℝ, 0 < K → 0 < η → ∃ n : ℕ, ∃ F : J → (I → A) → ℝ, + (∀ a, @Measurable _ _ (rows (N n a)) _ (F a)) ∧ + (∀ a ω, 0 ≤ F a ω ∧ F a ω ≤ K) ∧ + (∀ a, (∫ ω, |min K (Z a ω) - F a ω| ∂Measure.infinitePi (fun _ : I => ν)) ≤ η)) + (hescape : ∀ n (S : Set I), S.Finite → ∀ᵐ d ∂δ, + ∀ᶠ r in atTop, Disjoint S (N n (j r d))) : + ∀ ε > 0, ∀ᶠ r in atTop, + (∫ x : D × (I → A), f x * Z (j r x.1) x.2 + ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) ≤ C + ε := by + exact entropy_decorrelation δ ν hc hC hf hf0 hfi hf1 hH + (fun r => measurable_countable_sample hZ (hj r)) (fun r x => hZ0 _ _) + (fun r => (sampled_exponential_integrable δ ν hZ he heQ (hj r)).1) + (fun r => (sampled_exponential_integrable δ ν hZ he heQ (hj r)).2) + (fun r d => hZi (j r d)) (fun r d => hZC (j r d)) + (sampled_locality δ ν N j hj hloc hescape) + +end SampledSites + +lemma limsup_le_of_nonneg_eventual {a : ℕ → ℝ} {C : ℝ} + (h0 : ∀ r, 0 ≤ a r) (h : ∀ ε > 0, ∀ᶠ r in atTop, a r ≤ C + ε) : + Filter.limsup a atTop ≤ C := by + apply (Filter.limsup_le_iff' (isCoboundedUnder_le_of_le atTop h0) + (isBoundedUnder_of_eventually_le (h 1 zero_lt_one))).mpr + intro y hy + simpa only [add_sub_cancel] using h (y - C) (sub_pos.mpr hy) + +end TailDecorrelation + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma analytic_rows_eq {d : ℕ} (S : Set (Lattice d)) : + TailDecorrelation.rows (A := Row d) S = rowSigma S := + TailDecorrelation.rows_eq_iSup_two S + +lemma pair_neighborhoods_escape {d : ℕ} (e : Direction d) (a : ℝ) + (k : Fin d) (x : ℕ → Lattice d × Lattice d) + (hx : Tendsto (fun r => (x r).1 k) atTop atBot) + (hy : Tendsto (fun r => (x r).2 k) atTop atTop) + (N : ℕ) (S : Set (Lattice d)) (hS : S.Finite) : + ∀ᶠ r in atTop, Disjoint S (upperPairNeighborhood e a (x r) N) := by + have hz : ∀ z ∈ S, ∀ᶠ r in atTop, + z ∉ LatticeBall (x r).1 N ∪ LatticeBall (x r).2 N := by + intro z _ + filter_upwards [(tendsto_atBot.mp hx) (z k - (N : ℤ) - 1), + (tendsto_atTop.mp hy) (z k + (N : ℤ) + 1)] with r hrx hry + intro hz + rcases hz with hz | hz + · have hh := (abs_le.mp (hz k)).2 + omega + · have hh := (abs_le.mp (hz k)).1 + omega + filter_upwards [hS.eventually_all.mpr hz] with r hr + exact Set.disjoint_left.mpr fun z hz hz' => hr z hz hz'.1 + +lemma integrable_and_mean_le_of_exp {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) {Z : Ω → ℝ} {c B : ℝ} (hc : 0 < c) + (hZ : Measurable Z) (hZ0 : ∀ ω, 0 ≤ Z ω) + (hi : Integrable (fun ω => Real.exp (c * Z ω)) μ) + (hB : (∫ ω, Real.exp (c * Z ω) ∂μ) ≤ B) : + Integrable Z μ ∧ (∫ ω, Z ω ∂μ) ≤ B / c := by + have hb : ∀ ω, Z ω ≤ Real.exp (c * Z ω) / c := by + intro ω + apply (le_div_iff₀ hc).mpr + have h := Real.add_one_le_exp (c * Z ω) + nlinarith + have hz : Integrable Z μ := (hi.div_const c).mono' hZ.aestronglyMeasurable + (Eventually.of_forall (fun ω => by + rw [Real.norm_eq_abs, abs_of_nonneg (hZ0 ω)] + exact hb ω)) + refine ⟨hz, ?_⟩ + calc + (∫ ω, Z ω ∂μ) ≤ (∫ ω, Real.exp (c * Z ω) / c ∂μ) := integral_mono hz (hi.div_const c) hb + _ = (∫ ω, Real.exp (c * Z ω) ∂μ) / c := integral_div _ _ + _ ≤ B / c := div_le_div_of_nonneg_right hB hc.le + +end DirectionalTransience + +namespace DirectionalTransience + +theorem actual_sampled_tail_decorrelation {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A M : ℝ, 0 < A ∧ 0 ≤ M ∧ + ∀ (D : Type) [MeasurableSpace D] (δ : Measure D) [IsProbabilityMeasure δ] + (g : D × Environment d → ℝ), + Measurable g → (∀ x, 0 ≤ g x) → Integrable g (δ.prod (environmentLaw ν)) → + (∫ x, g x ∂δ.prod (environmentLaw ν)) = 1 → + Integrable (fun x => TailDecorrelation.entropyPlus (g x)) (δ.prod (environmentLaw ν)) → + ∀ (x : ℕ → D → {p : Lattice d × Lattice d // p ∈ PairAtHeight (realPosition (step e)) 0}), + (∀ r, Measurable (x r)) → + (∀ᵐ z ∂δ, Tendsto (fun r => (x r z).1.1 f.1) atTop atBot ∧ + Tendsto (fun r => (x r z).1.2 f.1) atTop atTop) → + Filter.limsup (fun r => ∫ z, g z * outwardCanonicalExcess e f A (x r z.1).1 z.2 + ∂δ.prod (environmentLaw ν)) atTop ≤ M := by + classical + obtain ⟨A,c,B,hA,hc,hB,hbound,hloc⟩ := actual_outward_order ν hue e f hef htrans + let J := {p : Lattice d × Lattice d // p ∈ PairAtHeight (realPosition (step e)) 0} + let Z : J → Environment d → ℝ := fun p => outwardCanonicalExcess e f A p.1 + have hZm : ∀ p : J, Measurable (Z p) := fun p => + ((hbound 0 p.1 p.2).2.1).mono (rowSigma_le _) le_rfl + have hZ0 : ∀ p : J, ∀ ω, 0 ≤ Z p ω := fun p => (hbound 0 p.1 p.2).1 + have he : ∀ p : J, Integrable (fun ω => Real.exp (c * Z p ω)) (environmentLaw ν) := + fun p => (hbound 0 p.1 p.2).2.2.1 + have heB : ∀ p : J, (∫ ω, Real.exp (c * Z p ω) ∂environmentLaw ν) ≤ B := + fun p => (hbound 0 p.1 p.2).2.2.2.1 + have hZi : ∀ p : J, Integrable (Z p) (environmentLaw ν) := fun p => + (integrable_and_mean_le_of_exp (environmentLaw ν) hc (hZm p) (hZ0 p) (he p) (heB p)).1 + have hZB : ∀ p : J, (∫ ω, Z p ω ∂environmentLaw ν) ≤ B / c := fun p => + (integrable_and_mean_le_of_exp (environmentLaw ν) hc (hZm p) (hZ0 p) (he p) (heB p)).2 + refine ⟨A,B/c,hA,div_nonneg hB.le hc.le,?_⟩ + intro D mD δ hδ g hgm hg0 hgi hg1 hgH x hxm hxe + have hcap : ∀ K η : ℝ, 0 < K → 0 < η → ∃ N : ℕ, + ∃ F : J → Environment d → ℝ, + (∀ p, @Measurable _ _ (TailDecorrelation.rows (upperPairNeighborhood e 0 p.1 N)) _ (F p)) ∧ + (∀ p ω, 0 ≤ F p ω ∧ F p ω ≤ K) ∧ + (∀ p, (∫ ω, |min K (Z p ω) - F p ω| ∂environmentLaw ν) ≤ η) := by + intro K η hK hη + obtain ⟨N,hN⟩ := outward_cap_locality_L1 ν e f A hloc hK hη + have hh : ∀ p : J, ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e 0 p.1 N)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ K) ∧ + (∫ ω, |min (Z p ω) K - F ω| ∂environmentLaw ν) < η := + fun p => hN 0 p.1 p.2 + choose F hFm hFb hFe using hh + refine ⟨N,F,?_,hFb,?_⟩ + · intro p + rw [analytic_rows_eq] + exact hFm p + · intro p + simpa only [min_comm] using (hFe p).le + have hesc : ∀ N (S : Set (Lattice d)), S.Finite → ∀ᵐ z ∂δ, + ∀ᶠ r in atTop, Disjoint S (upperPairNeighborhood e 0 (x r z).1 N) := by + intro N S hS + filter_upwards [hxe] with z hz + exact pair_neighborhoods_escape e 0 f.1 (fun r => (x r z).1) hz.1 hz.2 N S hS + have he' : ∀ p : J, Integrable (fun ω => Real.exp ((2*(c/2)) * Z p ω)) (environmentLaw ν) := by + simpa only [mul_div_cancel₀ _ (by norm_num : (2:ℝ) ≠ 0)] using he + have heB' : ∀ p : J, (∫ ω, Real.exp ((2*(c/2)) * Z p ω) ∂environmentLaw ν) ≤ B := by + simpa only [show 2*(c/2) = c by ring] using heB + apply TailDecorrelation.limsup_le_of_nonneg_eventual + · exact fun r => integral_nonneg fun z => mul_nonneg (hg0 z) (hZ0 _ _) + · exact TailDecorrelation.sampled_entropy_decorrelation δ ν (by linarith) (div_nonneg hB.le hc.le) + hgm hg0 hgi hg1 hgH hZm hZ0 he' heB' hZi hZB + (fun N p => upperPairNeighborhood e 0 p.1 N) x hxm hcap hesc + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MeasureAdd.lean b/lean/OAI/Probability/Ballisticity/Estimates/MeasureAdd.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f385f7fcda73185a68e680456cdac90af06dfd2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MeasureAdd.lean @@ -0,0 +1,423 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CommonOffset +import OAI.Probability.Ballisticity.Geometry.SumWindowDifference + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma inMeasure_add_zero {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F G : ℕ → Ω → ℝ) (hF : TendstoInMeasure μ F atTop 0) + (hG : TendstoInMeasure μ G atTop 0) : + TendstoInMeasure μ (fun i ω => F i ω+G i ω) atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + have hf := tendstoInMeasure_iff_measureReal_norm.mp hF (ε/2) (by positivity) + have hg := tendstoInMeasure_iff_measureReal_norm.mp hG (ε/2) (by positivity) + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at hf hg ⊢ + apply squeeze_zero (fun i => measureReal_nonneg) _ (by simpa only [add_zero] using hf.add hg) + intro i + apply (measureReal_mono (μ := μ) _).trans (measureReal_union_le _ _) + intro ω hω + change ε ≤ |F i ω+G i ω| at hω + change ε/2 ≤ |F i ω| ∨ ε/2 ≤ |G i ω| + by_contra! hn + have hh := abs_add_le (F i ω) (G i ω) + linarith + +lemma common_count_fixed_error {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) + (n : ℕ → ℝ) (hn : Tendsto n atTop atTop) (H : ℕ → ℕ) + {T : ℝ} (hT : 0 ≤ T) (hH : ∀ᶠ i in atTop, (H i:ℝ) ≤ T*n i) : + TendstoInMeasure (independentConditionedPairLaw ν ℓ) (fun i P => + ((renewalCount (fun j => commonWidthProcess ℓ j P) (H i) : ℝ)- + ⌊(H i:ℝ)/commonMeanWidth ν ℓ⌋₊)/n i) atTop 0 := by + let μ := independentConditionedPairLaw ν ℓ + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + have hc : 0 < commonMeanWidth ν ℓ := zero_lt_one.trans_le + (commonMeanWidth_ge_one ν ℓ htrans height hproj hstep) + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] + have ht := common_boundary_count_uniform ν ℓ htrans height hproj hstep n hn hT + (show 0 < ε/2 by positivity) + have ht' := (ENNReal.tendsto_toReal (by simp : (0:ℝ≥0∞) ≠ ⊤)).comp ht + simp only [ENNReal.toReal_zero] at ht' + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ ht' + filter_upwards [hH,hn.eventually (eventually_gt_atTop (2/ε))] with i hHi hni + have hn0 : 0 < n i := (div_pos (by norm_num) hε).trans hni + apply ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono _) + intro P hP + change ε ≤ |((renewalCount (fun j => commonWidthProcess ℓ j P) (H i) : ℝ)- + ⌊(H i:ℝ)/commonMeanWidth ν ℓ⌋₊)/n i| at hP + refine ⟨H i,hHi,?_⟩ + have hf := Nat.floor_le (div_nonneg (Nat.cast_nonneg (H i)) hc.le) + have hf' := Nat.lt_floor_add_one ((H i:ℝ)/commonMeanWidth ν ℓ) + let C : ℝ := renewalCount (fun j => commonWidthProcess ℓ j P) (H i) + let c := commonMeanWidth ν ℓ + have he : (C-⌊(H i:ℝ)/c⌋₊)/n i = + (C/n i-(H i:ℝ)/(c*n i))+(((H i:ℝ)/c)-⌊(H i:ℝ)/c⌋₊)/n i := by ring + have hb : |(((H i:ℝ)/c)-⌊(H i:ℝ)/c⌋₊)/n i| < ε/2 := by + rw [abs_div,abs_of_pos hn0,abs_of_nonneg (sub_nonneg.mpr hf),div_lt_iff₀ hn0] + have hh : 2 < n i*ε := (div_lt_iff₀ hε).mp hni + nlinarith + change ε ≤ |(C-⌊(H i:ℝ)/c⌋₊)/n i| at hP + rw [he] at hP + have hh := abs_add_le (C/n i-(H i:ℝ)/(c*n i)) + ((((H i:ℝ)/c)-⌊(H i:ℝ)/c⌋₊)/n i) + change ε/2 < |C/n i-(H i:ℝ)/(c*n i)| + linarith + +theorem transverse_firstHit_fixed_sum_error {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) (H : ℕ → ℕ) + {T : ℝ} (hT : 0 ≤ T) (hH : ∀ᶠ i in atTop, + (H i:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) : + TendstoInMeasure (independentConditionedPairLaw ν (realPosition (step e))) (fun i P => + (firstHitPairGap (realPosition (step e)) f (H i) P- + realPartialSum (fun j => commonIncrementProcess (realPosition (step e)) f j P) + ⌊(H i:ℝ)/commonMeanWidth ν (realPosition (step e))⌋₊)/r i) atTop 0 := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let X := commonIncrementProcess ℓ f + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + have hI := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn := (fluctuationScale_tendsto μ (X 0) (measurable_commonIncrementProcess ℓ f 0) hI hne).comp hr + have hc := common_count_fixed_error ν ℓ htrans (signedHeight e) (signedHeight_projection e) + (signedHeight_step_le e) _ hn H hT hH + have hs := iid_random_clock_error μ X (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) hI hne r hr _ _ hc + have hd := independent_firstHit_decoration_small ν ℓ f htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) r hr H + have hh := inMeasure_add_zero μ _ _ hd hs + apply hh.congr_left + intro i + apply Eventually.of_forall + intro P + dsimp only [X] + ring + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +namespace DirectionalTransience + +lemma fluctuation_tail_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {ω | S ω ≠ 0}) {r l : ℝ} (hr : 0 < r) (hl : 0 < l) (hl1 : l ≤ 1) : + fluctuationScale μ S r*μ.real {ω | l*r < |S ω|} ≤ 1/l^2 := by + let A := {ω | l*r < |S ω|} + have hA : MeasurableSet A := measurableSet_lt measurable_const hS.abs + have hb : (l*r)^2*μ.real A ≤ truncatedVariance μ S r := by + have hh := integral_mono ((integrable_const ((l*r)^2)).indicator hA) + (integrable_truncated_square μ S hS r) (fun ω => ?_) + · simpa only [truncatedVariance,integral_indicator hA,integral_const,Measure.real,Measure.restrict_apply_univ,smul_eq_mul,mul_comm] + using hh + · by_cases hω : ω ∈ A + · rw [Set.indicator_of_mem hω] + change l*r < |S ω| at hω + apply le_min + · nlinarith [sq_abs (S ω),abs_nonneg (S ω),mul_pos hl hr] + · exact pow_le_pow_left₀ (mul_nonneg hl.le hr.le) (by nlinarith) 2 + · rw [Set.indicator_of_notMem hω] + exact le_min (sq_nonneg _) (sq_nonneg _) + have hm := truncatedVariance_pos μ S hS hne hr + rw [fluctuationScale,div_mul_eq_mul_div,div_le_div_iff₀ hm (sq_pos_of_pos hl)] + nlinarith [hb] + +lemma double_floor_count_bounds {n t c : ℝ} (hn : 0 < n) (ht : 0 < t) (hc : 0 < c) + (hlarge : 2*(c+1)/t ≤ n) : + t/(2*c)*n ≤ (⌊(⌊t*n⌋₊:ℝ)/c⌋₊:ℝ) ∧ + (⌊(⌊t*n⌋₊:ℝ)/c⌋₊:ℝ) ≤ t/c*n := by + have hH := Nat.floor_le (mul_nonneg ht.le hn.le) + have hH' := Nat.lt_floor_add_one (t*n) + have hK := Nat.floor_le (div_nonneg (Nat.cast_nonneg ⌊t*n⌋₊) hc.le) + have hK' := Nat.lt_floor_add_one ((⌊t*n⌋₊:ℝ)/c) + have hnt : 2*(c+1) ≤ n*t := (div_le_iff₀ ht).mp hlarge + constructor + · rw [div_mul_eq_mul_div] + apply (div_le_iff₀ (mul_pos (by norm_num : (0:ℝ)<2) hc)).mpr + have hKc : (⌊t*n⌋₊:ℝ) < ((⌊(⌊t*n⌋₊:ℝ)/c⌋₊:ℝ)+1)*c := (div_lt_iff₀ hc).mp hK' + nlinarith + · have hKc := (le_div_iff₀ hc).mp hK + rw [div_mul_eq_mul_div] + exact (le_div_iff₀ hc).mpr (by nlinarith) + +theorem transverse_bad_radius_spread {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) {l ε t : ℝ} + (hl : 0 < l) (hl1 : l ≤ 1) (hε : 0 < ε) (ht : 0 < t) + (htsmall : t ≤ commonMeanWidth ν (realPosition (step e))*l^2/4) + (hbad : ∀ᶠ i in atTop, + ε ≤ fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)* + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*r i < |commonIncrementProcess (realPosition (step e)) f 0 P|}) : + ∀ᶠ i in atTop, t*ε/(16*commonMeanWidth ν (realPosition (step e))) ≤ + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*r i/4 < |firstHitPairGap (realPosition (step e)) f + ⌊t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)⌋₊ P|} := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let X := commonIncrementProcess ℓ f + let n := fun i => fluctuationScale μ (X 0) (r i) + let c := commonMeanWidth ν ℓ + let H := fun i => ⌊t*n i⌋₊ + let K := fun i => ⌊(H i:ℝ)/c⌋₊ + let p := fun i => μ.real {P | l*r i < |X 0 P|} + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + have hc : 0 < c := zero_lt_one.trans_le (commonMeanWidth_ge_one ν ℓ htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)) + have hI := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn := (fluctuationScale_tendsto μ (X 0) (measurable_commonIncrementProcess ℓ f 0) hI hne).comp hr + have hH : ∀ᶠ i in atTop, (H i:ℝ) ≤ t*n i := by + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ))] with i hri + exact Nat.floor_le (mul_nonneg ht.le (fluctuationScale_nonneg μ (X 0) (r i))) + have herr := transverse_firstHit_fixed_sum_error ν hue e f hef htrans r hr H ht.le hH + have herror := tendstoInMeasure_iff_measureReal_norm.mp herr (l/2) (by positivity) + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at herror + have hconst : 0 < t*ε/(16*c) := by positivity + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ)),hbad, + hn.eventually (eventually_ge_atTop (2*(c+1)/t)), + herror.eventually (gt_mem_nhds hconst)] with i hri hbi hni hei + have hn0 : 0 < n i := div_pos (sq_pos_of_pos hri) + (truncatedVariance_pos μ (X 0) (measurable_commonIncrementProcess ℓ f 0) hne hri) + have hnp : n i*p i ≤ 1/l^2 := fluctuation_tail_bound μ (X 0) + (measurable_commonIncrementProcess ℓ f 0) hne hri hl hl1 + have hk := double_floor_count_bounds hn0 ht hc hni + change t/(2*c)*n i ≤ (K i:ℝ) ∧ (K i:ℝ) ≤ t/c*n i at hk + have hp : 0 ≤ p i := measureReal_nonneg + have hqlo : t*ε/(2*c) ≤ (K i:ℝ)*p i := by + have hh1 := mul_le_mul_of_nonneg_right hk.1 hp + have hh2 := mul_le_mul_of_nonneg_left hbi (le_of_lt (div_pos ht (by positivity : 0 < 2*c))) + calc + t*ε/(2*c) = t/(2*c)*ε := by ring + _ ≤ t/(2*c)*(n i*p i) := hh2 + _ = (t/(2*c)*n i)*p i := by ring + _ ≤ _ := hh1 + have hqhi : (K i:ℝ)*p i ≤ 1/4 := by + have hh1 := mul_le_mul_of_nonneg_right hk.2 hp + have hh2 := mul_le_mul_of_nonneg_left hnp (le_of_lt (div_pos ht hc)) + have hh3 : t/c*(1/l^2) ≤ 1/4 := by + rw [div_mul_div_comm,mul_one,div_le_iff₀ (mul_pos hc (sq_pos_of_pos hl))] + change t ≤ _ + nlinarith [htsmall] + calc + (K i:ℝ)*p i ≤ (t/c*n i)*p i := hh1 + _ = t/c*(n i*p i) := by ring + _ ≤ t/c*(1/l^2) := hh2 + _ ≤ _ := hh3 + have hs := iid_symmetric_sum_spread μ X (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) (l*r i) (K i) + have hslow : t*ε/(8*c) ≤ μ.real {P | l*r i < |realPartialSum (fun j => X j P) (K i)|} := by + change (1/2:ℝ)*(K i*p i)-(K i*p i)^2/2 ≤ + μ.real {P | l*r i < |realPartialSum (fun j => X j P) (K i)|} at hs + have hq0 : 0 ≤ (K i:ℝ)*p i := mul_nonneg (Nat.cast_nonneg _) hp + have heq : t*ε/(8*c) = (t*ε/(2*c))/4 := by ring + rw [heq] + nlinarith [mul_nonneg hq0 (sub_nonneg.mpr hqhi)] + let A := {P | l*r i/4 < |firstHitPairGap ℓ f (H i) P|} + let E := {P | l/2 ≤ |(firstHitPairGap ℓ f (H i) P-realPartialSum (fun j => X j P) (K i))/r i|} + have hsub : {P | l*r i < |realPartialSum (fun j => X j P) (K i)|} ⊆ A ∪ E := by + intro P hP + change l*r i < |realPartialSum (fun j => X j P) (K i)| at hP + by_cases ha : P ∈ A + · exact Or.inl ha + · apply Or.inr + change l/2 ≤ |(firstHitPairGap ℓ f (H i) P-realPartialSum (fun j => X j P) (K i))/r i| + change ¬l*r i/4 < |firstHitPairGap ℓ f (H i) P| at ha + rw [abs_div,abs_of_pos hri,le_div_iff₀ hri] + have hh := abs_sub_le (realPartialSum (fun j => X j P) (K i)) (firstHitPairGap ℓ f (H i) P) 0 + simp only [sub_zero,abs_sub_comm] at hh + nlinarith + have hh := hslow.trans ((measureReal_mono (μ := μ) hsub).trans (measureReal_union_le _ _)) + change μ.real E < t*ε/(16*c) at hei + change t*ε/(16*c) ≤ μ.real A + have heq : t*ε/(8*c) = 2*(t*ε/(16*c)) := by ring + rw [heq] at hh + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MedianAeConst.lean b/lean/OAI/Probability/Ballisticity/Estimates/MedianAeConst.lean new file mode 100644 index 0000000000000000000000000000000000000000..66cec90d8d14a642d3447118f3b3a111d3405948 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MedianAeConst.lean @@ -0,0 +1,289 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.TransverseFirstHitSinglePathLimit +import OAI.Probability.Ballisticity.Geometry.CenteredHeightAdditiveUniform + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma median_eq_of_ae_const {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (F : Ω → ℝ) {c b : ℝ} (hF : ∀ᵐ x ∂μ, F x = c) + (hl : (1/2 : ℝ≥0∞) ≤ μ {x | F x ≤ b}) + (hr : (1/2 : ℝ≥0∞) ≤ μ {x | b ≤ F x}) : b = c := by + apply le_antisymm + · by_contra! hh + have hz : μ {x | b ≤ F x} = 0 := by + apply measure_eq_zero_iff_ae_notMem.mpr + filter_upwards [hF] with x hx + simpa only [Set.mem_ofPred_eq,hx,not_le] using hh + rw [hz] at hr + norm_num at hr + · by_contra! hh + have hz : μ {x | F x ≤ b} = 0 := by + apply measure_eq_zero_iff_ae_notMem.mpr + filter_upwards [hF] with x hx + simpa only [Set.mem_ofPred_eq,hx,not_le] using hh + rw [hz] at hl + norm_num at hl + +lemma recordMedian_zero {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (f : Direction d) : + recordMedian ν ℓ hp f 0 = 0 := by + have hx := (conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_initial ν) + have h0 : ∀ᵐ X ∂conditionedLaw ν ℓ, signedCoordinate f (recordIndexPosition ℓ 0 X) = 0 := by + filter_upwards [hx] with X hX + simp [recordIndexPosition,recordIndexTime_zero,hX,signedCoordinate] + have he := median_eq_of_ae_const _ _ h0 (recordMedian_spec ν ℓ hp f 0).1 + (recordMedian_spec ν ℓ hp f 0).2 + exact_mod_cast he + +theorem recordMedian_additive_uniform {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (T : ℝ) {ε : ℝ} (hε : 0 < ε) : + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans) + ∀ᶠ i in atTop, ∀ k j : ℕ, + ((k+j:ℕ):ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i) → + |((recordMedian ν (realPosition (step e)) hp f (k+j):ℝ)- + recordMedian ν (realPosition (step e)) hp f k-recordMedian ν (realPosition (step e)) hp f j)/r i| < ε := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ hp + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ hp + let F := fun h X => signedCoordinate f (recordIndexPosition ℓ h X) + have hF (h : ℕ) : Measurable (F h) := + (measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ h) + let b := fun h => (recordMedian ν ℓ hp f h:ℝ) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + have hi := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto _ _ + (measurable_commonIncrementProcess ℓ f 0) hi hne).comp hr.1 + have hc := commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) + apply centered_height_additive_uniform μ F hF b + (by simp [b,recordMedian_zero]) r n hn (1/(2*commonMeanWidth ν ℓ)) (by positivity) + _ (annealedLaw ν (NoDrop ℓ 0)).toReal (ENNReal.toReal_pos hp (measure_ne_top _ _)) _ T hε + · intro S hS + obtain ⟨W,hW,hWf⟩ := transverse_firstHit_single_path_limit ν hue e f hef htrans r hr hS.le + refine ⟨W,hW,?_⟩ + intro I + simpa only [div_eq_mul_inv,one_mul] using hWf I + · intro k j hk hj + have hh := Measure.map_mono (conditioned_record_convolution_domination ν ℓ htrans hk hj) + (measurable_of_countable (signedCoordinate f)) + have hsum : Measurable (fun P : Path d × Path d => + recordIndexPosition ℓ k P.1+recordIndexPosition ℓ j P.2) := + ((measurable_recordIndexPosition ℓ k).comp measurable_fst).add + ((measurable_recordIndexPosition ℓ j).comp measurable_snd) + rw [Measure.map_smul _ (measurable_of_countable (signedCoordinate f)).aemeasurable, + Measure.map_map (measurable_of_countable _) hsum, + Measure.map_map (measurable_of_countable _) (measurable_recordIndexPosition ℓ (k+j))] at hh + simpa only [ENNReal.ofReal_toReal (measure_ne_top _ _),Function.comp_def,signedCoordinate_add,independentConditionedPairLaw,μ,F] using hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma approximate_additive_linear_on_interval (b : ℕ → ℝ) (hb0 : b 0 = 0) + {N : ℕ} (hN : 0 < N) {E : ℝ} (hE : 0 ≤ E) + (ha : ∀ i j : ℕ, i+j ≤ 2*N → |b (i+j)-b i-b j| ≤ E) : + ∀ j ≤ N, |b j-(j:ℝ)*b N/N| ≤ 2*E := by + let D := fun j : ℕ => b j-(j:ℝ)*b N/N + have hNreal : (N:ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (by omega) + have hDz : D 0 = 0 := by simp [D,hb0] + have hDN : D N = 0 := by simp [D,mul_div_cancel_left₀ _ hNreal] + obtain ⟨k,hk,hmax⟩ := (Finset.range (N+1)).exists_max_image (fun j => |D j|) + ⟨0,by simp⟩ + have hkN : k ≤ N := by simpa using hk + have hmax' (j : ℕ) (hj : j ≤ N) : |D j| ≤ |D k| := hmax j (by simpa using hj) + have hkbound : |D k| ≤ 2*E := by + by_cases hkeq : k = N + · simpa only [hkeq,hDN,abs_zero] using mul_nonneg (by norm_num : (0:ℝ) ≤ 2) hE + have hklt : k < N := lt_of_le_of_ne hkN hkeq + by_cases h2 : k+k ≤ N + · have he : |D (k+k)-2*D k| ≤ E := by + convert ha k k (by omega) using 1 + congr 1 + simp only [D,Nat.cast_add] + ring + have ht := abs_sub (2*D k) (D (k+k)-2*D k) + have he' := abs_add_le (D (k+k)) (-(D (k+k)-2*D k)) + have heq : D (k+k)+ -(D (k+k)-2*D k) = 2*D k := by ring + rw [heq,abs_neg] at he' + have hn := hmax' (k+k) h2 + rw [abs_mul,show |(2:ℝ)| = 2 by norm_num] at he' + linarith + · let l := k+k-N + have hl : l ≤ N := by dsimp [l]; omega + have hsum : N+l = k+k := by dsimp [l]; omega + have hcast : (N:ℝ)+(l:ℝ) = (k:ℝ)+(k:ℝ) := by exact_mod_cast hsum + have he1 := ha k k (by omega) + have he2 := ha N l (by omega) + rw [hsum] at he2 + have he : |D l-2*D k| ≤ 2*E := by + have heq : D l-2*D k = + (b (k+k)-b k-b k)-(b (k+k)-b N-b l) := by + dsimp [D] + rw [show (l:ℝ) = (k:ℝ)+(k:ℝ)-N by linarith] + field_simp + ring + rw [heq] + exact le_trans (abs_sub _ _) (by linarith) + have he' := abs_add_le (D l) (-(D l-2*D k)) + have heq : D l+ -(D l-2*D k) = 2*D k := by ring + rw [heq,abs_neg,abs_mul,show |(2:ℝ)| = 2 by norm_num] at he' + have hn := hmax' l hl + linarith + intro j hj + exact (hmax' j hj).trans hkbound + +lemma approximate_additive_common_slope (b : ℕ → ℝ) (hb0 : b 0 = 0) + {M N : ℕ} (hN : 0 < N) (hNM : N ≤ M) {E : ℝ} (hE : 0 ≤ E) + (ha : ∀ i j : ℕ, i+j ≤ 2*M → |b (i+j)-b i-b j| ≤ E) + {j : ℕ} (hj : j ≤ M) : + |b j-(j:ℝ)*b N/N| ≤ 2*E*(1+(j:ℝ)/N) := by + have hb := approximate_additive_linear_on_interval b hb0 (lt_of_lt_of_le hN hNM) hE ha + have hNr : (N:ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (by omega) + have he : b j-(j:ℝ)*b N/N = (b j-(j:ℝ)*b M/M) + + ((j:ℝ)/N)*((N:ℝ)*b M/M-b N) := by field_simp; ring + rw [he] + calc + _ ≤ |b j-(j:ℝ)*b M/M|+|((j:ℝ)/N)*((N:ℝ)*b M/M-b N)| := abs_add_le _ _ + _ = |b j-(j:ℝ)*b M/M|+((j:ℝ)/N)*|b N-(N:ℝ)*b M/M| := by + rw [abs_mul,abs_of_nonneg (show 0 ≤ (j:ℝ)/(N:ℝ) from div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)), + show |(N:ℝ)*b M/M-b N| = |b N-(N:ℝ)*b M/M| from abs_sub_comm _ _] + _ ≤ 2*E+((j:ℝ)/N)*(2*E) := by gcongr; exact hb j hj; exact hb N hNM + _ = _ := by ring + +theorem height_center_linearization (b : ℕ → ℝ) (hb0 : b 0 = 0) (r n : ℕ → ℝ) + (hn : Tendsto n atTop atTop) + (ha : ∀ T : ℝ, ∀ ε > 0, ∀ᶠ i in atTop, ∀ k j : ℕ, + ((k+j:ℕ):ℝ) ≤ T*n i → |(b (k+j)-b k-b j)/r i| < ε) + (T : ℝ) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ i in atTop, ∀ h : ℕ, (h:ℝ) ≤ T*n i → + |(b h-(h:ℝ)*(b ⌊n i⌋₊/⌊n i⌋₊))/r i| < ε := by + let S := max T 1 + have hS : 1 ≤ S := le_max_right _ _ + let δ := ε/(8*(S+1)) + have hδ : 0 < δ := div_pos hε (by positivity) + filter_upwards [ha (2*S) δ hδ,hn.eventually (eventually_ge_atTop (1:ℝ))] with i hi hni + let N := ⌊n i⌋₊ + let M := ⌊S*n i⌋₊ + have hN : 0 < N := Nat.lt_of_lt_of_le (by omega : 0 < 1) (Nat.le_floor (by exact_mod_cast hni)) + have hNM : N ≤ M := Nat.floor_mono (by nlinarith : n i ≤ S*n i) + have hSn : 0 ≤ S*n i := by positivity + have hM : (M:ℝ) ≤ S*n i := Nat.floor_le hSn + have hNl : n i < (N:ℝ)+1 := Nat.lt_floor_add_one _ + have hNr : 0 < (N:ℝ) := Nat.cast_pos.mpr hN + have hN1 : (1:ℝ) ≤ N := by exact_mod_cast hN + have hn2 : n i ≤ 2*(N:ℝ) := by linarith + let B := fun h => b h/r i + have hB0 : B 0 = 0 := by simp [B,hb0] + have hBa (k j : ℕ) (hkj : k+j ≤ 2*M) : |B (k+j)-B k-B j| ≤ δ := by + have hbnd : ((k+j:ℕ):ℝ) ≤ (2*S)*n i := by + have hkk : ((k+j:ℕ):ℝ) ≤ 2*(M:ℝ) := by exact_mod_cast hkj + nlinarith + simpa only [B,← sub_div] using (hi k j hbnd).le + intro h hh + have hhS : (h:ℝ) ≤ S*n i := hh.trans (mul_le_mul_of_nonneg_right (le_max_left _ _) (by positivity)) + have hhM : h ≤ M := Nat.le_floor hhS + have hhN : (h:ℝ)/(N:ℝ) ≤ 2*S := (div_le_iff₀ hNr).mpr (by nlinarith) + have hb := approximate_additive_common_slope B hB0 hN hNM hδ.le hBa hhM + have he : (b h-(h:ℝ)*(b N/N))/r i = B h-(h:ℝ)*B N/N := by dsimp [B]; ring + change |(b h-(h:ℝ)*(b N/N))/r i| < ε + rw [he] + apply lt_of_le_of_lt hb + calc + _ ≤ 2*δ*(1+2*S) := by gcongr + _ < ε := by + dsimp [δ] + have hden : 0 < 8*(S+1) := by positivity + rw [show 2*(ε/(8*(S+1)))*(1+2*S) = (2*ε*(1+2*S))/(8*(S+1)) by ring] + apply (div_lt_iff₀ hden).mpr + nlinarith + +lemma height_center_slope_small (b : ℕ → ℝ) (r n : ℕ → ℝ) + (hr : Tendsto r atTop atTop) (hn : Tendsto n atTop atTop) + (hl : ∀ ε > 0, ∀ᶠ i in atTop, ∀ h : ℕ, (h:ℝ) ≤ n i → + |(b h-(h:ℝ)*(b ⌊n i⌋₊/⌊n i⌋₊))/r i| < ε) : + Tendsto (fun i => (b ⌊n i⌋₊/⌊n i⌋₊)/r i) atTop (𝓝 0) := by + have he : Tendsto (fun i => (b 1-b ⌊n i⌋₊/⌊n i⌋₊)/r i) atTop (𝓝 0) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + filter_upwards [hl ε hε,hn.eventually (eventually_ge_atTop (1:ℝ))] with i hi hni + simpa only [Real.dist_eq,sub_zero,Nat.cast_one,one_mul] using hi 1 (by simpa using hni) + have hh := (hr.const_div_atTop (b 1)).sub he + simpa only [zero_sub,neg_zero,sub_div,sub_sub_cancel] using hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MixtureSmallMassProbability.lean b/lean/OAI/Probability/Ballisticity/Estimates/MixtureSmallMassProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b90753bb56f0ed876f59d4ed23f2f37c091fc73 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MixtureSmallMassProbability.lean @@ -0,0 +1,351 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.RawMedianTubeSingleSite + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma mixture_small_mass_probability {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + (μ : Measure Ω) (π : Measure I) [IsProbabilityMeasure μ] [IsProbabilityMeasure π] + (F : Ω → I → ℝ) (hF : Measurable (Function.uncurry F)) + (hF0 : ∀ ω x, 0 ≤ F ω x) (hF1 : ∀ ω x, F ω x ≤ 1) + {δ α : ℝ} (hδ : 0 < δ) + (hbad : ∀ x, μ.real {ω | F ω x < 2*δ} ≤ α) : + μ.real {ω | (∫ x, F ω x ∂π) < δ} ≤ 2*α := by + have hFw (ω : Ω) : Measurable (F ω) := hF.comp (measurable_const.prodMk measurable_id) + have hFx (x : I) : Measurable (fun ω => F ω x) := hF.comp (measurable_id.prodMk measurable_const) + have hBw (ω : Ω) : MeasurableSet {x | F ω x < 2*δ} := measurableSet_lt (hFw ω) measurable_const + have hBx (x : I) : MeasurableSet {ω | F ω x < 2*δ} := measurableSet_lt (hFx x) measurable_const + let B : Set (Ω × I) := {z | F z.1 z.2 < 2*δ} + have hB : MeasurableSet B := hF measurableSet_Iio + let G : Ω × I → ℝ := B.indicator (fun _ => 1) + have hG : Measurable G := measurable_const.indicator hB + have hG0 (z : Ω × I) : 0 ≤ G z := by by_cases h : z ∈ B <;> simp [G,h] + have hG1 (z : Ω × I) : ‖G z‖ ≤ 1 := by by_cases h : z ∈ B <;> simp [G,h] + have hGi : Integrable G (μ.prod π) := + (integrable_const (1:ℝ)).mono' hG.aestronglyMeasurable (ae_of_all _ hG1) + let T : Ω → ℝ := fun ω => ∫ x, G (ω,x) ∂π + have hT (ω : Ω) : T ω = π.real {x | F ω x < 2*δ} := by + change (∫ x, ({x | F ω x < 2*δ}).indicator (fun _ => (1:ℝ)) x ∂π) = _ + rw [integral_indicator (hBw ω)] + simp + have hswap : (∫ ω, T ω ∂μ) = ∫ x, μ.real {ω | F ω x < 2*δ} ∂π := by + rw [show (∫ ω, T ω ∂μ) = ∫ ω, ∫ x, G (ω,x) ∂π ∂μ from rfl, + integral_integral_swap (f := fun ω x => G (ω,x)) hGi] + apply integral_congr_ae + exact ae_of_all _ fun x => by + change (∫ ω, ({ω | F ω x < 2*δ}).indicator (fun _ => (1:ℝ)) ω ∂μ) = _ + rw [integral_indicator (hBx x)] + simp + have hmean : (∫ ω, T ω ∂μ) ≤ α := by + rw [hswap] + have hh := integral_mono_ae hGi.integral_prod_right (integrable_const α) + (ae_of_all π fun x => by + change (∫ ω, G (ω,x) ∂μ) ≤ α + have he : (∫ ω, G (ω,x) ∂μ) = μ.real {ω | F ω x < 2*δ} := by + change (∫ ω, ({ω | F ω x < 2*δ}).indicator (fun _ => (1:ℝ)) ω ∂μ) = _ + rw [integral_indicator (hBx x)] + simp + rw [he]; exact hbad x) + have he (x : I) : (∫ ω, G (ω,x) ∂μ) = μ.real {ω | F ω x < 2*δ} := by + change (∫ ω, ({ω | F ω x < 2*δ}).indicator (fun _ => (1:ℝ)) ω ∂μ) = _ + rw [integral_indicator (hBx x)] + simp + simpa only [he, integral_const, probReal_univ, one_smul] using hh + have hinter (ω : Ω) : Integrable (F ω) π := + (integrable_const (1:ℝ)).mono' (hF.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable + (ae_of_all _ fun x => by rw [Real.norm_eq_abs,abs_of_nonneg (hF0 ω x)]; exact hF1 ω x) + have hsub : {ω | (∫ x, F ω x ∂π) < δ} ⊆ {ω | (1:ℝ)/2 ≤ T ω} := by + intro ω hsmall + have hh := mul_meas_ge_le_integral_of_nonneg (ae_of_all π (hF0 ω)) (hinter ω) (2*δ) + have he : {x | 2*δ ≤ F ω x} = {x | F ω x < 2*δ}ᶜ := by ext x; simp + rw [he,measureReal_compl (hBw ω), + probReal_univ,← hT ω] at hh + change (1:ℝ)/2 ≤ T ω + change (∫ x, F ω x ∂π) < δ at hsmall + nlinarith + have hmark := mul_meas_ge_le_integral_of_nonneg + (ae_of_all μ fun ω => integral_nonneg fun x => hG0 (ω,x)) hGi.integral_prod_left (1/2) + have hm := ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (μ := μ) hsub) + change μ.real {ω | (∫ x, F ω x ∂π) < δ} ≤ μ.real {ω | (1:ℝ)/2 ≤ T ω} at hm + change (1/2)*μ.real {ω | (1:ℝ)/2 ≤ T ω} ≤ ∫ ω, T ω ∂μ at hmark + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def relativeGoodMass {d : ℕ} (ℓ : Vector d) (A : Set (Path d)) + (ω : Environment d) (x : Lattice d) : ℝ := + (quenchedKernel (ω,x)).real (((fun X : Path d => fun n => X n-x) ⁻¹' Aᶜ) ∩ NoDrop ℓ x) + +lemma relativeGoodMass_translation {d : ℕ} (ℓ : Vector d) (A : Set (Path d)) + (hA : MeasurableSet A) (ω : Environment d) (x : Lattice d) : + relativeGoodMass ℓ A ω x = + (quenchedKernel ((fun y => ω (x+y)),0)).real (Aᶜ ∩ NoDrop ℓ 0) := by + have hm : Measurable (fun X : Path d => fun n => X n-x) := by fun_prop + have he : ((fun X : Path d => fun n => X n-x) ⁻¹' Aᶜ) ∩ NoDrop ℓ x = + (fun X : Path d => fun n => X n-x) ⁻¹' (Aᶜ ∩ NoDrop ℓ 0) := by + rw [Set.preimage_inter,noDrop_translation,add_zero] + have hmap : (quenchedKernel (ω,x)).map (fun X : Path d => fun n => X n-x) = + quenchedKernel ((fun y => ω (x+y)),0) := by + simpa only [add_zero] using quenched_translation ω x 0 + rw [relativeGoodMass,Measure.real,he,← Measure.map_apply hm (hA.compl.inter (measurableSet_noDrop ℓ 0)),hmap] + rfl + +lemma measurable_relativeGoodMass {d : ℕ} (ℓ : Vector d) (A : Set (Path d)) + (hA : MeasurableSet A) : Measurable (Function.uncurry (relativeGoodMass ℓ A)) := by + apply measurable_from_prod_countable_left + intro x + have hm : Measurable (fun X : Path d => fun n => X n-x) := by fun_prop + have hs : MeasurableSet (((fun X : Path d => fun n => X n-x) ⁻¹' Aᶜ) ∩ NoDrop ℓ x) := + (hA.compl.preimage hm).inter (measurableSet_noDrop ℓ x) + exact ((Kernel.measurable_coe quenchedKernel hs).comp + (measurable_id.prodMk measurable_const)).ennreal_toReal + +lemma relativeGoodMass_bad_probability_translation {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (A : Set (Path d)) (hA : MeasurableSet A) + (x : Lattice d) (c : ℝ) : + (environmentLaw ν).real {ω | relativeGoodMass ℓ A ω x < c} = + (environmentLaw ν).real {ω | (quenchedKernel (ω,0)).real (Aᶜ ∩ NoDrop ℓ 0) < c} := by + let F := fun ω : Environment d => (quenchedKernel (ω,0)).real (Aᶜ ∩ NoDrop ℓ 0) + have hF : Measurable F := ((Kernel.measurable_coe quenchedKernel + (hA.compl.inter (measurableSet_noDrop ℓ 0))).comp + (measurable_id.prodMk measurable_const)).ennreal_toReal + have he := congrArg (fun μ : Measure (Environment d) => μ {ω | F ω < c}) (environment_translation ν x) + rw [Measure.map_apply (by fun_prop) (measurableSet_lt hF measurable_const)] at he + apply congrArg ENNReal.toReal + change environmentLaw ν {ω | relativeGoodMass ℓ A ω x < c} = environmentLaw ν {ω | F ω < c} + convert he using 1 + congr 1 + ext ω + exact Iff.of_eq (congrArg (fun y : ℝ => y < c) (relativeGoodMass_translation ℓ A hA ω x)) + +theorem raw_median_tube_single_threat {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {w : ℝ} (hw : 0 < w) (hw1 : w ≤ 10) : + ∃ C : ℝ, 0 < C ∧ ∀ t : ℝ, 0 < t → ∃ δ : ℝ, 0 < δ ∧ δ < 1/4 ∧ + ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → + ∀ H : ℕ, (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + ∀ π : Measure (Lattice d), IsProbabilityMeasure π → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let A := MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (w*r) + (environmentLaw ν).real {ω | (∫ x, relativeGoodMass ℓ A ω x ∂π) < δ} ≤ C*t := by + obtain ⟨C,hC,hCbound⟩ := raw_median_tube_single_site ν hue e f hef htrans hw hw1 + refine ⟨2*C,by positivity,?_⟩ + intro t ht + obtain ⟨δ,hδ,hδ1,R,hR,hbound⟩ := hCbound t ht + refine ⟨δ,hδ,hδ1,R,hR,?_⟩ + intro r hr H hH π hπ + let := hπ + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let A := MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (w*r) + have hA : MeasurableSet A := measurableSet_medianTubeFailure ℓ f _ H _ + have hh := mixture_small_mass_probability (environmentLaw ν) π (relativeGoodMass ℓ A) + (measurable_relativeGoodMass ℓ A hA) + (fun _ _ => measureReal_nonneg) (fun _ _ => measureReal_le_one) hδ + (fun x => (relativeGoodMass_bad_probability_translation ν ℓ A hA x (2*δ)).le.trans (hbound r hr H hH)) + change (environmentLaw ν).real {ω | (∫ x, relativeGoodMass ℓ A ω x ∂π) < δ} ≤ 2*C*t + nlinarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/MomentRescaling.lean b/lean/OAI/Probability/Ballisticity/Estimates/MomentRescaling.lean new file mode 100644 index 0000000000000000000000000000000000000000..49d2fbd2d6ea3079fea7af3306b269392926e633 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/MomentRescaling.lean @@ -0,0 +1,160 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CurvePolicyAverageMoment + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +noncomputable def cappedMoment {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : Ω → ℝ) (L : ℝ) : ℝ := ∫ x, (min (X x) L)^2 ∂μ +noncomputable def cappedTailMoment {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : Ω → ℝ) (A L : ℝ) : ℝ := ∫ x, (if A < X x then (min (X x) L)^2 else 0) ∂μ + +lemma min_rescale {L : ℝ} (hL : 0 < L) (x : ℝ) : min x L = L*min (x/L) 1 := by + rw [← div_self (ne_of_gt hL),min_div_div_right hL.le] + field_simp + +lemma cappedMoment_scale {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : Ω → ℝ) {L : ℝ} (hL : 0 < L) : + cappedMoment μ X L = L^2*cappedMoment μ (fun x => X x/L) 1 := by + unfold cappedMoment + rw [← integral_const_mul] + congr 1 + funext x + rw [min_rescale hL] + ring + +lemma cappedTailMoment_scale {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : Ω → ℝ) (A : ℝ) {L : ℝ} (hL : 0 < L) : + cappedTailMoment μ X A L = L^2*cappedTailMoment μ (fun x => X x/L) (A/L) 1 := by + unfold cappedTailMoment + rw [← integral_const_mul] + congr 1 + funext x + simp only [div_lt_div_iff_of_pos_right hL] + split_ifs + · rw [min_rescale hL]; ring + · ring + +lemma cappedMoment_unit_bounds {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) + (hX : Measurable X) (hX0 : ∀ x, 0 ≤ X x) : + 0 ≤ cappedMoment μ X 1 ∧ cappedMoment μ X 1 ≤ 1 := by + have hb (x) : 0 ≤ (min (X x) 1)^2 ∧ (min (X x) 1)^2 ≤ 1 := by + have h0 := le_min (hX0 x) zero_le_one + have h1 := min_le_right (X x) 1 + constructor <;> nlinarith + have hi : Integrable (fun x => (min (X x) 1)^2) μ := + (integrable_const (1:ℝ)).mono' ((hX.min measurable_const).pow_const 2).aestronglyMeasurable + (Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs,abs_of_nonneg (hb x).1] using (hb x).2)) + constructor + · exact integral_nonneg (fun x => (hb x).1) + · calc + _ ≤ ∫ x, (1:ℝ) ∂μ := integral_mono hi (integrable_const _) (fun x => (hb x).2) + _ = 1 := by simp + +lemma cappedTailMoment_unit_bounds {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) + (hX : Measurable X) (hX0 : ∀ x, 0 ≤ X x) (A : ℝ) : + 0 ≤ cappedTailMoment μ X A 1 ∧ cappedTailMoment μ X A 1 ≤ 1 := by + let f := fun x => if A < X x then (min (X x) 1)^2 else 0 + have hb (x) : 0 ≤ f x ∧ f x ≤ 1 := by + have h0 := le_min (hX0 x) zero_le_one + have h1 := min_le_right (X x) 1 + dsimp [f] + split_ifs <;> constructor <;> nlinarith + have hm : Measurable f := Measurable.ite (measurableSet_lt measurable_const hX) + ((hX.min measurable_const).pow_const 2) measurable_const + have hi : Integrable f μ := (integrable_const (1:ℝ)).mono' hm.aestronglyMeasurable + (Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs,abs_of_nonneg (hb x).1] using (hb x).2)) + constructor + · exact integral_nonneg (fun x => (hb x).1) + · calc + _ ≤ ∫ x, (1:ℝ) ∂μ := integral_mono hi (integrable_const _) (fun x => (hb x).2) + _ = 1 := by simp + +lemma limsup_cappedMoment_scale {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ n, IsProbabilityMeasure (μ n)] (X : ℕ → Ω → ℝ) + (hX : ∀ n, Measurable (X n)) (hX0 : ∀ n x, 0 ≤ X n x) {L : ℝ} (hL : 0 < L) : + limsup (fun n => cappedMoment (μ n) (X n) L) atTop = + L^2*limsup (fun n => cappedMoment (μ n) (fun x => X n x/L) 1) atTop := by + simp only [cappedMoment_scale _ _ hL] + apply limsup_nonneg_const_mul _ (sq_nonneg L) + (fun n => (cappedMoment_unit_bounds (μ n) _ ((hX n).div_const L) (fun x => div_nonneg (hX0 n x) hL.le)).1) + (fun n => (cappedMoment_unit_bounds (μ n) _ ((hX n).div_const L) (fun x => div_nonneg (hX0 n x) hL.le)).2) + +lemma limsup_cappedTailMoment_scale {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ n, IsProbabilityMeasure (μ n)] (X : ℕ → Ω → ℝ) + (hX : ∀ n, Measurable (X n)) (hX0 : ∀ n x, 0 ≤ X n x) (A : ℝ) {L : ℝ} (hL : 0 < L) : + limsup (fun n => cappedTailMoment (μ n) (X n) A L) atTop = + L^2*limsup (fun n => cappedTailMoment (μ n) (fun x => X n x/L) (A/L) 1) atTop := by + simp only [cappedTailMoment_scale _ _ _ hL] + apply limsup_nonneg_const_mul _ (sq_nonneg L) + (fun n => (cappedTailMoment_unit_bounds (μ n) _ ((hX n).div_const L) (fun x => div_nonneg (hX0 n x) hL.le) _).1) + (fun n => (cappedTailMoment_unit_bounds (μ n) _ ((hX n).div_const L) (fun x => div_nonneg (hX0 n x) hL.le) _).2) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience +lemma cappedMoment_bounds {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (X : Ω → ℝ) (hX : Measurable X) (hX0 : ∀ x, 0 ≤ X x) {B : ℝ} (hB : 0 < B) : + 0 ≤ cappedMoment μ X B ∧ cappedMoment μ X B ≤ B^2 := by + rw [cappedMoment_scale μ X hB] + have hh := cappedMoment_unit_bounds μ (fun x => X x/B) (hX.div_const B) + (fun x => div_nonneg (hX0 x) hB.le) + constructor + · exact mul_nonneg (sq_nonneg B) hh.1 + · simpa only [mul_one] using mul_le_mul_of_nonneg_left hh.2 (sq_nonneg B) + +lemma cappedMoment_descaled {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (X : Ω → ℝ) {r B : ℝ} (hr : 0 < r) : + (∫ x, (min (X x) (B*r))^2 ∂μ)=r^2*cappedMoment μ (fun x => X x/r) B := by + rw [cappedMoment,←integral_const_mul] + congr 1 + funext x + have hh : min (X x) (B*r) = r*min (X x/r) B := by + rw [mul_min_of_nonneg _ _ hr.le,mul_div_cancel₀ _ hr.ne',mul_comm r B] + rw [hh] + ring +lemma cappedTailMoment_descaled {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (X : Ω → ℝ) {r A B : ℝ} (hr : 0 < r) : + (∫ x, (if A*r < X x then (min (X x) (B*r))^2 else 0) ∂μ)= + r^2*cappedTailMoment μ (fun x => X x/r) A B := by + rw [cappedTailMoment,←integral_const_mul] + congr 1 + funext x + simp only [lt_div_iff₀ hr] + split_ifs + · have hh : min (X x) (B*r) = r*min (X x/r) B := by + rw [mul_min_of_nonneg _ _ hr.le,mul_div_cancel₀ _ hr.ne',mul_comm r B] + rw [hh] + ring + · ring +lemma cappedTailMoment_bounds {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (X : Ω → ℝ) (hX : Measurable X) (hX0 : ∀ x, 0 ≤ X x) (A : ℝ) {B : ℝ} (hB : 0 < B) : + 0 ≤ cappedTailMoment μ X A B ∧ cappedTailMoment μ X A B ≤ B^2 := by + rw [cappedTailMoment_scale μ X A hB] + have hh := cappedTailMoment_unit_bounds μ (fun x => X x/B) (hX.div_const B) + (fun x => div_nonneg (hX0 x) hB.le) (A/B) + constructor + · exact mul_nonneg (sq_nonneg B) hh.1 + · simpa only [mul_one] using mul_le_mul_of_nonneg_left hh.2 (sq_nonneg B) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/NaturalTailIntegrable.lean b/lean/OAI/Probability/Ballisticity/Estimates/NaturalTailIntegrable.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d9d31631b1de0e3a45c4edd09ec2291daebb19b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/NaturalTailIntegrable.lean @@ -0,0 +1,88 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RapidDecay + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma natural_integrable_of_coarse_tail {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (f : Ω → ℕ) (hf : Measurable f) + (T : ℕ → ℕ) (hT : ∀ k, ∃ n, k ≤ T n) + (hs : Summable (fun n => (T (n+1):ℝ)*μ.real {x | T n < f x})) : + Integrable (fun x => (f x:ℝ)) μ := by + let F : ℕ → Ω → ℝ≥0∞ := fun n => {x | T n < f x}.indicator (fun _ => (T (n+1):ℝ≥0∞)) + have hE (n : ℕ) : MeasurableSet {x | T n < f x} := measurableSet_lt measurable_const hf + have hF (n : ℕ) : Measurable (F n) := measurable_const.indicator (hE n) + have hpoint (x : Ω) : (f x:ℝ≥0∞) ≤ (T 0:ℝ≥0∞)+∑' n,F n x := by + by_cases hh : f x ≤ T 0 + · exact (by exact_mod_cast hh : (f x:ℝ≥0∞) ≤ T 0).trans (le_add_right le_rfl) + · have hex := hT (f x) + have hb := Nat.find_spec hex + cases hk : Nat.find hex with + | zero => exact (hh (hk ▸ hb)).elim + | succ n => + have hlo : T n < f x := Nat.lt_of_not_ge (Nat.find_min hex (by omega : n < Nat.find hex)) + have hterm : F n x=(T (n+1):ℝ≥0∞) := Set.indicator_of_mem (show x ∈ {x | T n < f x} from hlo) _ + calc + _ ≤ (T (n+1):ℝ≥0∞) := by exact_mod_cast (show f x ≤ T (n+1) by simpa only [hk] using hb) + _ = F n x := hterm.symm + _ ≤ ∑' i,F i x := ENNReal.le_tsum (f := fun index => F index x) n + _ ≤ _ := le_add_left le_rfl + have hIf (n : ℕ) : (∫⁻ x,F n x ∂μ) = (T (n+1):ℝ≥0∞)*μ {x | T n < f x} := by + dsimp only [F] + rw [lintegral_indicator (hE n),lintegral_const,Measure.restrict_apply_univ] + have hfinite : (∑' n,(T (n+1):ℝ≥0∞)*μ {x | T n < f x}) < ⊤ := by + have he (n : ℕ) : (T (n+1):ℝ≥0∞)*μ {x | T n < f x} = + ENNReal.ofReal ((T (n+1):ℝ)*μ.real {x | T n < f x}) := by + rw [ENNReal.ofReal_mul (Nat.cast_nonneg _),ENNReal.ofReal_natCast,measureReal_def, + ENNReal.ofReal_toReal (measure_ne_top _ _)] + simp_rw [he] + rw [← ENNReal.ofReal_tsum_of_nonneg (fun n => mul_nonneg (Nat.cast_nonneg _) measureReal_nonneg) hs] + exact ENNReal.ofReal_lt_top + refine ⟨((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp hf).aestronglyMeasurable, + (hasFiniteIntegral_iff_ofReal (Eventually.of_forall (fun x => Nat.cast_nonneg (f x)))).mpr ?_⟩ + calc + (∫⁻ x,ENNReal.ofReal (f x:ℝ) ∂μ) ≤ ∫⁻ x,(T 0:ℝ≥0∞)+∑' n,F n x ∂μ := + lintegral_mono (fun x => by simpa only [ENNReal.ofReal_natCast] using hpoint x) + _ = (T 0:ℝ≥0∞)+∑' n,(T (n+1):ℝ≥0∞)*μ {x | T n < f x} := by + rw [lintegral_add_left measurable_const,lintegral_const,measure_univ,mul_one, + lintegral_tsum (fun n => (hF n).aemeasurable)] + simp_rw [hIf] + _ < ⊤ := ENNReal.add_lt_top.mpr ⟨ENNReal.natCast_lt_top _,hfinite⟩ + +lemma natural_integrable_of_polynomial_rapid_tail {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (f : Ω → ℕ) (hf : Measurable f) + (A q : ℕ) (hA : 0 < A) (hq : 0 < q) + (ht : RapidDecay (fun n => μ.real {x | A*(n+1)^q < f x})) : + Integrable (fun x => (f x:ℝ)) μ := by + apply natural_integrable_of_coarse_tail μ f hf (fun n => A*(n+1)^q) + · intro k + refine ⟨k,?_⟩ + have hpow : k+1 ≤ (k+1)^q := by + obtain ⟨q,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hq) + rw [pow_succ] + have hp : 1 ≤ (k+1)^q := Nat.one_le_pow _ _ (by omega) + nlinarith + nlinarith + · have hs := (ht q).mul_left ((A:ℝ)*2^q) + apply hs.of_norm_bounded + intro n + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (Nat.cast_nonneg _) measureReal_nonneg)] + have hbound : (A*(n+1+1)^q:ℕ) ≤ (A:ℝ)*2^q*(n+1:ℝ)^q := by + push_cast + calc + _ ≤ (A:ℝ)*(2*(n+1:ℝ))^q := mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (by positivity) (by linarith [Nat.cast_nonneg (α := ℝ) n]) _) (Nat.cast_nonneg _) + _ = _ := by rw [mul_pow,mul_assoc] + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hbound + (show 0 ≤ μ.real {x | A*(n+1)^q < f x} from measureReal_nonneg) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/NoDropApproxError.lean b/lean/OAI/Probability/Ballisticity/Estimates/NoDropApproxError.lean new file mode 100644 index 0000000000000000000000000000000000000000..6dded38a4db478fd69a075dd203eed6e473fcf87 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/NoDropApproxError.lean @@ -0,0 +1,272 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.SignedHeight +import OAI.Probability.Ballisticity.Estimates.WeightedConditioned + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma noDropFinite_lower_rows {d : ℕ} (e : Direction d) (y : Lattice d) + (hy : signedHeight e y = 0) (J : ℕ) : + @Measurable _ _ (rowSigma {z | dot (realPosition z) (realPosition (step e)) ≤ (J:ℝ)}) _ + (noDropFinite (realPosition (step e)) y J) := by + apply (noDropFinite_measurable_ball _ y J).mono (rowSigma_mono ?_) le_rfl + intro z hz + change dot (realPosition z) (realPosition (step e)) ≤ (J:ℝ) + rw [signedHeight_projection] + have hh := abs_le.mp (hz e.1) + have hc : signedHeight e z ≤ (J:ℤ) := by + simp only [signedHeight] at hy ⊢ + cases he : e.2 <;> simp only [he,Bool.false_eq_true,ite_false,ite_true] at hy ⊢ <;> omega + exact_mod_cast hc + +noncomputable def noDropApproxError {d : ℕ} (ν : Measure (Row d)) + (ℓ : Vector d) (J : ℕ) : ℝ≥0∞ := + ∫⁻ ω, noDropFinite ℓ 0 J ω-noDropQuenched ℓ 0 ω ∂environmentLaw ν + +lemma noDropApproxError_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (y : Lattice d) (J : ℕ) : + (∫⁻ ω, noDropFinite ℓ y J ω-noDropQuenched ℓ y ω ∂environmentLaw ν) = + noDropApproxError ν ℓ J := by + simp_rw [noDropFinite_translation ℓ _ y J,noDropQuenched_translation ℓ _ y] + have hh := lintegral_map ((noDropFinite_measurable ℓ 0 J).sub (measurable_noDropQuenched ℓ 0)) + (show Measurable (fun ω : Environment d => fun a => ω (y+a)) by fun_prop) + (μ := environmentLaw ν) + rw [environment_translation] at hh + exact hh.symm + +lemma noDropApproxError_le_one {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (J : ℕ) : noDropApproxError ν ℓ J ≤ 1 := by + calc + _ ≤ ∫⁻ _ω, (1 : ℝ≥0∞) ∂environmentLaw ν := + lintegral_mono (fun _ => tsub_le_self.trans prob_le_one) + _ = 1 := by simp + +lemma noDropApproxError_tendsto {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) : Tendsto (noDropApproxError ν ℓ) atTop (𝓝 0) := by + have h := tendsto_lintegral_of_dominated_convergence (μ := environmentLaw ν) + (f := fun _ => (0 : ℝ≥0∞)) (fun _ => (1 : ℝ≥0∞)) + (fun J => (noDropFinite_measurable ℓ 0 J).sub (measurable_noDropQuenched ℓ 0)) + (fun _ => ae_of_all _ (fun _ => tsub_le_self.trans prob_le_one)) + (by simp) (ae_of_all _ (fun ω => ?_)) + · change Tendsto (fun J => ∫⁻ ω, noDropFinite ℓ 0 J ω-noDropQuenched ℓ 0 ω ∂environmentLaw ν) + atTop (𝓝 0) + simpa only [lintegral_zero,Pi.sub_apply] using h + · have ht := ENNReal.Tendsto.sub (noDropFinite_tendsto ℓ 0 ω) + (tendsto_const_nhds : Tendsto (fun _ : ℕ => noDropQuenched ℓ 0 ω) atTop (𝓝 (noDropQuenched ℓ 0 ω))) + (Or.inl (measure_ne_top _ _)) + simpa only [Pi.sub_apply,tsub_self] using ht + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma normalizedMeasure_upper_le {Ω : Type*} [MeasurableSpace Ω] + (μ η : Measure Ω) (hμη : μ ≤ η) (δ c : ℝ≥0∞) + (hc : c ≤ μ Set.univ) (A : Set Ω) (hA : η A ≤ μ A+δ) : + normalizedMeasure η A ≤ normalizedMeasure μ A+c⁻¹*δ := by + change (η Set.univ)⁻¹*η A ≤ (μ Set.univ)⁻¹*μ A+c⁻¹*δ + calc + _ ≤ (μ Set.univ)⁻¹*η A := mul_le_mul_left (ENNReal.inv_le_inv.mpr (hμη Set.univ)) _ + _ ≤ (μ Set.univ)⁻¹*(μ A+δ) := mul_le_mul_right hA _ + _ = (μ Set.univ)⁻¹*μ A+(μ Set.univ)⁻¹*δ := mul_add _ _ _ + _ ≤ (μ Set.univ)⁻¹*μ A+c⁻¹*δ := + add_le_add le_rfl (mul_le_mul_left (ENNReal.inv_le_inv.mpr hc) δ) + +lemma levyProkhorov_normalized_map_le {Ω E : Type*} [MeasurableSpace Ω] + [MetricSpace E] [MeasurableSpace E] [BorelSpace E] + (μ η : Measure Ω) [IsFiniteMeasure μ] [IsFiniteMeasure η] + (hμη : μ ≤ η) (δ c : ℝ≥0∞) (hc : 0 < c) (hδ : δ ≠ ⊤) + (hcmass : c ≤ μ Set.univ) (hbound : ∀ A, MeasurableSet A → η A ≤ μ A+δ) + (F : Ω → E) (hF : Measurable F) : + levyProkhorovDist ((normalizedMeasure η).map F) ((normalizedMeasure μ).map F) ≤ (c⁻¹*δ).toReal := by + let : IsProbabilityMeasure (normalizedMeasure μ) := normalizedMeasure_probability μ + (ne_of_gt (hc.trans_le hcmass)) + let : IsProbabilityMeasure (normalizedMeasure η) := normalizedMeasure_probability η + (ne_of_gt (hc.trans_le (hcmass.trans (hμη Set.univ)))) + let : IsProbabilityMeasure ((normalizedMeasure μ).map F) := inferInstance + let : IsProbabilityMeasure ((normalizedMeasure η).map F) := inferInstance + apply levyProkhorovDist_le_of_forall_le _ _ ENNReal.toReal_nonneg + intro ε B hε hB + rw [Measure.map_apply hF hB] + have hb := normalizedMeasure_upper_le μ η hμη δ c hcmass (F ⁻¹' B) + (hbound _ (hB.preimage hF)) + have he : c⁻¹*δ ≤ ENNReal.ofReal ε := by + rw [← ENNReal.ofReal_toReal (ENNReal.mul_ne_top (ENNReal.inv_ne_top.mpr hc.ne') hδ)] + exact ENNReal.ofReal_le_ofReal hε.le + have hBsub : (normalizedMeasure μ) (F ⁻¹' B) ≤ + ((normalizedMeasure μ).map F) (Metric.thickening ε B) := by + rw [Measure.map_apply hF Metric.isOpen_thickening.measurableSet] + exact measure_mono (Set.preimage_mono (Metric.self_subset_thickening (ENNReal.toReal_nonneg.trans_lt hε) B)) + exact hb.trans (add_le_add hBsub he) + +lemma weak_limit_of_uniform_approximation {E : Type*} [MetricSpace E] + [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + (μ : ℕ → ProbabilityMeasure E) (η : ℕ → ℕ → ProbabilityMeasure E) + (W : ProbabilityMeasure E) (δ : ℕ → ℝ) (hδ : Tendsto δ atTop (𝓝 0)) + (hlim : ∀ J, Tendsto (η J) atTop (𝓝 W)) + (hclose : ∀ J i, levyProkhorovDist (μ i : Measure E) (η J i : Measure E) ≤ δ J) : + Tendsto μ atTop (𝓝 W) := by + have hW : Tendsto (fun i => LevyProkhorov.ofMeasure (μ i)) atTop (𝓝 (LevyProkhorov.ofMeasure W)) := by + apply Metric.tendsto_nhds.2 + intro ε hε + obtain ⟨J,hJ⟩ := (hδ.eventually_lt_const (half_pos hε)).exists + have hη := LevyProkhorov.continuous_ofMeasure_probabilityMeasure.tendsto W |>.comp (hlim J) + filter_upwards [(Metric.tendsto_nhds.mp hη) (ε/2) (half_pos hε)] with i hi + exact (dist_triangle _ (LevyProkhorov.ofMeasure (η J i)) _).trans_lt + (by + have hc := hclose J i + dsimp only [Function.comp_apply] at hi + change dist (LevyProkhorov.ofMeasure (μ i)) (LevyProkhorov.ofMeasure (η J i)) ≤ δ J at hc + linarith) + exact LevyProkhorov.continuous_toMeasure_probabilityMeasure.tendsto + (LevyProkhorov.ofMeasure W) |>.comp hW + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma weightedConditioned_apply {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) (hg : Measurable g) + (A : Set (Path d)) (hA : MeasurableSet A) : + weightedConditioned ν ℓ g A = (annealedLaw ν (NoDrop ℓ 0))⁻¹ * + ∫⁻ ω, g ω * quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0) ∂environmentLaw ν := by + rw [weightedConditioned,Measure.smul_apply,Measure.restrict_apply hA, + weightedAnnealed_apply ν g hg _ (hA.inter (measurableSet_noDrop ℓ 0))] + rfl + +lemma weightedConditioned_mono {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g h : Environment d → ℝ≥0∞) (hg : Measurable g) (hh : Measurable h) + (hgh : ∀ ω, g ω ≤ h ω) : weightedConditioned ν ℓ g ≤ weightedConditioned ν ℓ h := by + apply Measure.le_iff.mpr + intro A hA + rw [weightedConditioned_apply ν ℓ g hg A hA,weightedConditioned_apply ν ℓ h hh A hA] + exact mul_le_mul_right (lintegral_mono (fun ω => mul_le_mul_left (hgh ω) _)) _ + +lemma weightedConditioned_approx {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g h : Environment d → ℝ≥0∞) (hg : Measurable g) (hh : Measurable h) + (hgh : ∀ ω, g ω ≤ h ω) (A : Set (Path d)) (hA : MeasurableSet A) : + weightedConditioned ν ℓ h A ≤ weightedConditioned ν ℓ g A+ + (annealedLaw ν (NoDrop ℓ 0))⁻¹ * ∫⁻ ω, h ω-g ω ∂environmentLaw ν := by + rw [weightedConditioned_apply ν ℓ g hg A hA,weightedConditioned_apply ν ℓ h hh A hA,← mul_add] + apply mul_le_mul_right + have hQ : Measurable (fun ω : Environment d => quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0)) := + (Kernel.measurable_coe _ (hA.inter (measurableSet_noDrop ℓ 0))).comp + (measurable_id.prodMk measurable_const) + rw [← lintegral_add_left (show Measurable (fun ω => g ω * quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0)) from hg.mul hQ) (fun ω => h ω-g ω)] + apply lintegral_mono + intro ω + calc + _ = (g ω+(h ω-g ω))*quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0) := by + rw [add_tsub_cancel_of_le (hgh ω)] + _ = g ω*quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0)+ + (h ω-g ω)*quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0) := add_mul _ _ _ + _ ≤ _ := add_le_add le_rfl (mul_le_of_le_one_right' prob_le_one) + +lemma weightedConditioned_noDrop_mass {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (y : Lattice d) : + weightedConditioned ν ℓ (noDropQuenched ℓ y) Set.univ = + (annealedLaw ν (NoDrop ℓ 0))⁻¹ * sharedNoDropMass ν ℓ 0 y := by + rw [weightedConditioned_apply ν ℓ _ (measurable_noDropQuenched ℓ y) _ MeasurableSet.univ] + simp only [Set.univ_inter,sharedNoDropMass,noDropQuenched] + congr 1 + apply lintegral_congr + intro ω + exact mul_comm _ _ + +lemma weightedConditioned_noDrop_approx {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (y : Lattice d) (J : ℕ) (A : Set (Path d)) (hA : MeasurableSet A) : + weightedConditioned ν ℓ (noDropFinite ℓ y J) A ≤ + weightedConditioned ν ℓ (noDropQuenched ℓ y) A+ + (annealedLaw ν (NoDrop ℓ 0))⁻¹ * noDropApproxError ν ℓ J := by + simpa only [noDropApproxError_translation ν ℓ y J] using + weightedConditioned_approx ν ℓ _ _ (measurable_noDropQuenched ℓ y) + (noDropFinite_measurable ℓ y J) (fun ω => noDropQuenched_le_finite ℓ y ω J) A hA + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/NonCollapsedSums.lean b/lean/OAI/Probability/Ballisticity/Estimates/NonCollapsedSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..179e98172f22b4249a67048d7d8ef62a98ebfb2a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/NonCollapsedSums.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SymmetricPrefixTail + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma iid_fluctuation_not_collapse {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ j, Measurable (X j)) (hind : iIndepFun X μ) + (hid : ∀ j, IdentDistrib (X j) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) (k : ℕ → ℕ) + {τ : ℝ} (hτ : 0 < τ) + (hk : Tendsto (fun i => (k i:ℝ)/fluctuationScale μ (X 0) (r i)) atTop (𝓝 τ)) + (hcollapse : TendstoInMeasure μ + (fun i ω => realPartialSum (fun j => X j ω) (k i)/r i) atTop 0) : False := by + have hg := gaussian_sequence_of_collapsed_sums μ X hX hind hid hsym hI hne r hr k hτ hk (fun a ha => ?_) + · have hcf := gaussian_charFun_power_limit_count μ (X 0) (hX 0) hI hne hsym r hg k hk 1 + have hd := hcollapse.tendstoInDistribution (fun i => by unfold realPartialSum; fun_prop) + have hc := ProbabilityMeasure.tendsto_iff_tendsto_charFun.1 hd.tendsto 1 + change Tendsto (fun i => charFun (μ.map (fun ω => realPartialSum (fun j => X j ω) (k i)/r i)) 1) + atTop (𝓝 (charFun (μ.map (fun _ : Ω => (0:ℝ))) 1)) at hc + simp only [charFun_div_partialSum μ X hind hid,Measure.map_const,measure_univ,one_smul, + charFun_dirac,inner_zero_left,Complex.ofReal_zero,zero_mul,Complex.exp_zero] at hc + have he := tendsto_nhds_unique hcf hc + have he' := congrArg Complex.re he + simp only [one_pow,mul_one,←Complex.ofReal_neg,←Complex.ofReal_exp,Complex.ofReal_re,Complex.one_re] at he' + have hh : Real.exp (-(τ/2)) < 1 := Real.exp_lt_one_iff.mpr (by linarith) + exact hh.ne he' + · have hc := tendstoInMeasure_iff_measureReal_norm.mp hcollapse a ha + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at hc + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ hc + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ))] with i hi + refine measureReal_mono ?_ (measure_ne_top _ _) + intro ω hω + change a*r i < |realPartialSum (fun j => X j ω) (k i)| at hω + change a ≤ |realPartialSum (fun j => X j ω) (k i)/r i| + rw [abs_div,abs_of_pos hi,le_div_iff₀ hi] + exact hω.le +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma double_floor_ratio (n : ℕ → ℝ) (hn : Tendsto n atTop atTop) {c : ℝ} (hc : 0 < c) : + Tendsto (fun i => (⌊(⌊n i⌋₊:ℝ)/c⌋₊:ℝ)/n i) atTop (𝓝 (1/c)) := by + have hH : Tendsto (fun i => (⌊n i⌋₊:ℝ)) atTop atTop := + tendsto_natCast_atTop_atTop.comp (tendsto_nat_floor_atTop.comp hn) + have hin : Tendsto (fun i => (⌊n i⌋₊:ℝ)/n i) atTop (𝓝 1) := by + simpa only [one_mul,Function.comp_def] using (tendsto_nat_floor_mul_div_atTop (show (0:ℝ)≤1 by norm_num)).comp hn + have hout : Tendsto (fun i => (⌊(⌊n i⌋₊:ℝ)/c⌋₊:ℝ)/(⌊n i⌋₊:ℝ)) atTop (𝓝 (1/c)) := by + simpa only [Function.comp_def,one_div,one_mul,mul_comm c⁻¹,div_eq_mul_inv] using + (tendsto_nat_floor_mul_div_atTop (show 0 ≤ 1/c by positivity)).comp hH + have hh := hout.mul hin + simp only [mul_one] at hh + apply hh.congr' + filter_upwards [hH.eventually (eventually_gt_atTop (0:ℝ))] with i hi + exact div_mul_div_cancel₀ (ne_of_gt hi) +lemma inMeasure_sub_zero {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F G : ℕ → Ω → ℝ) (hF : TendstoInMeasure μ F atTop 0) + (hG : TendstoInMeasure μ G atTop 0) : + TendstoInMeasure μ (fun i ω => F i ω-G i ω) atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + have hf := tendstoInMeasure_iff_measureReal_norm.mp hF (ε/2) (by positivity) + have hg := tendstoInMeasure_iff_measureReal_norm.mp hG (ε/2) (by positivity) + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at hf hg ⊢ + apply squeeze_zero (fun i => measureReal_nonneg) _ (by simpa only [add_zero] using hf.add hg) + intro i + apply (measureReal_mono (μ := μ) _).trans (measureReal_union_le _ _) + intro ω hω + change ε ≤ |F i ω-G i ω| at hω + change ε/2 ≤ |F i ω| ∨ ε/2 ≤ |G i ω| + by_contra! hn + have hh := norm_sub_le (F i ω) (G i ω) + simp only [Real.norm_eq_abs] at hh + linarith +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter Set +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +noncomputable def dyadicCut (j : ℕ) : ℝ := (1/2)^j +lemma dyadicCut_pos (j : ℕ) : 0 < dyadicCut j := pow_pos (by norm_num) _ +lemma dyadicCut_le_one (j : ℕ) : dyadicCut j ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) +lemma dyadicCut_antitone : Antitone dyadicCut := by + intro i j hij + exact pow_le_pow_of_le_one (by norm_num) (by norm_num) hij +lemma dyadicCut_tendsto : Tendsto dyadicCut atTop (𝓝 0) := by + exact tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num) + +lemma variance_ratio_unit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {r a : ℝ} (hr : 0 < r) (ha : 0 ≤ a) (ha1 : a ≤ 1) : + truncatedVariance μ S (a*r)/truncatedVariance μ S r ∈ Icc (0:ℝ) 1 := by + have hp := truncatedVariance_pos μ S hS hne hr + constructor + · exact div_nonneg (truncatedVariance_nonneg _ _ _) hp.le + · rw [div_le_one hp] + apply truncatedVariance_mono μ S hS (mul_nonneg ha hr.le) + nlinarith + +lemma exists_dyadic_variance_profile {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) (r : ℕ → ℝ) (hr : ∀ n, 0 < r n) : + ∃ (ns : ℕ → ℕ) (F : ℕ → ℝ) (F₀ : ℝ), StrictMono ns ∧ + (∀ j, Tendsto (fun n => truncatedVariance μ S (dyadicCut j*r (ns n))/truncatedVariance μ S (r (ns n))) atTop (𝓝 (F j))) ∧ + (∀ j, F j ∈ Icc (0:ℝ) 1) ∧ F 0 = 1 ∧ Antitone F ∧ + F₀ ∈ Icc (0:ℝ) 1 ∧ Tendsto F atTop (𝓝 F₀) ∧ (∀ j, F₀ ≤ F j) := by + let R : ℕ → ℕ → Icc (0:ℝ) 1 := fun n j => + ⟨truncatedVariance μ S (dyadicCut j*r n)/truncatedVariance μ S (r n), + variance_ratio_unit μ S hS hne (hr n) (dyadicCut_pos j).le (dyadicCut_le_one j)⟩ + obtain ⟨f,ns,hns,hlim⟩ := CompactSpace.tendsto_subseq R + let F := fun j => (f j:ℝ) + have hF (j) : Tendsto (fun n => truncatedVariance μ S (dyadicCut j*r (ns n))/truncatedVariance μ S (r (ns n))) atTop (𝓝 (F j)) := + continuous_subtype_val.continuousAt.tendsto.comp ((tendsto_pi_nhds.mp hlim) j) + have hbounds (j) : F j ∈ Icc (0:ℝ) 1 := (f j).property + have hFone : F 0 = 1 := by + have heq : (fun n => truncatedVariance μ S (dyadicCut 0*r (ns n))/truncatedVariance μ S (r (ns n))) = fun _ => (1:ℝ) := by + funext n + simp only [dyadicCut,pow_zero,one_mul] + exact div_self (ne_of_gt (truncatedVariance_pos μ S hS hne (hr (ns n)))) + exact tendsto_nhds_unique (heq ▸ hF 0) tendsto_const_nhds + have hanti : Antitone F := by + intro i j hij + apply le_of_tendsto_of_tendsto (hF j) (hF i) + exact Eventually.of_forall fun n => div_le_div_of_nonneg_right + (truncatedVariance_mono μ S hS (mul_nonneg (dyadicCut_pos j).le (hr (ns n)).le) + (mul_le_mul_of_nonneg_right (dyadicCut_antitone hij) (hr (ns n)).le)) + (truncatedVariance_nonneg μ S _) + have hb : BddBelow (range F) := ⟨0,fun x ⟨j,hj⟩ => hj ▸ (hbounds j).1⟩ + have hlimF : Tendsto F atTop (𝓝 (⨅ j, F j)) := tendsto_atTop_ciInf hanti hb + have hinf0 : 0 ≤ ⨅ j, F j := le_ciInf (fun j => (hbounds j).1) + have hinfj (j) : (⨅ i, F i) ≤ F j := ciInf_le hb j + exact ⟨ns,F,⨅ j, F j,hns,hF,hbounds,hFone,hanti,⟨hinf0,(hinfj 0).trans (hbounds 0).2⟩,hlimF,hinfj⟩ + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/NormalLinearPast.lean b/lean/OAI/Probability/Ballisticity/Estimates/NormalLinearPast.lean new file mode 100644 index 0000000000000000000000000000000000000000..9daa0a35c757d279c81d4218664c5882fbab817f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/NormalLinearPast.lean @@ -0,0 +1,229 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CharacteristicTaylor + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +noncomputable def pairLinearIncrement (a b : ℝ) (s t : unitInterval) : C(RealPathPair,ℝ) := + ⟨fun P => a*pairPathIncrement false s t P+b*pairPathIncrement true s t P,by fun_prop⟩ + +lemma normalJointPast_linear_mean_integrable {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (v : Fin q → unitInterval) (s t : unitInterval) (hst : s < t) (ht : (t:ℝ) < 1) + (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + Integrable (fun P => F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)) μ := by + have hx := normalJointPast_complex_weighted_moment_integrable (k := 1) μ c h v s t hst ht false F + have hy := normalJointPast_complex_weighted_moment_integrable (k := 1) μ c h v s t hst ht true F + simp only [pow_one] at hx hy + have hid : (fun P => F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ))= + (fun P => (a:ℂ)*(F (pairPastCoordinates v P)*(pairPathIncrement false s t P:ℂ))+ + (b:ℂ)*(F (pairPastCoordinates v P)*(pairPathIncrement true s t P:ℂ))) := by + funext P + simp only [pairLinearIncrement,ContinuousMap.coe_mk,Complex.ofReal_add,Complex.ofReal_mul] + ring + rw [hid] + exact (hx.const_mul (a:ℂ)).add (hy.const_mul (b:ℂ)) + +lemma normalJointPast_linear_mean {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + (∫ P, F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ) ∂μ)=0 := by + have hx := normalJointPast_complex_weighted_moment_integrable (k := 1) μ c h v s t hst ht false F + have hy := normalJointPast_complex_weighted_moment_integrable (k := 1) μ c h v s t hst ht true F + simp only [pow_one] at hx hy + have hid : (fun P => F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ))= + (fun P => (a:ℂ)*(F (pairPastCoordinates v P)*(pairPathIncrement false s t P:ℂ))+ + (b:ℂ)*(F (pairPastCoordinates v P)*(pairPathIncrement true s t P:ℂ))) := by + funext P + simp only [pairLinearIncrement,ContinuousMap.coe_mk,Complex.ofReal_add,Complex.ofReal_mul] + ring + rw [hid,integral_add (hx.const_mul _) (hy.const_mul _),integral_const_mul,integral_const_mul, + normalJointPast_complex_mean μ c h v s t hv hst ht false, + normalJointPast_complex_mean μ c h v s t hv hst ht true] + simp + +lemma normalJointPast_linear_second_integrable {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (v : Fin q → unitInterval) (s t : unitInterval) (hst : s < t) (ht : (t:ℝ) < 1) + (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + Integrable (fun P => F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)^2) μ := by + have hx := normalJointPast_complex_weighted_moment_integrable (k := 2) μ c h v s t hst ht false F + have hy := normalJointPast_complex_weighted_moment_integrable (k := 2) μ c h v s t hst ht true F + have hxy := normalJointPast_complex_cross_integrable μ c h v s t hst ht F + have hid : (fun P => F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)^2)= + (fun P => (a:ℂ)^2*(F (pairPastCoordinates v P)*(pairPathIncrement false s t P:ℂ)^2)+ + (b:ℂ)^2*(F (pairPastCoordinates v P)*(pairPathIncrement true s t P:ℂ)^2)+ + 2*(a:ℂ)*b*(F (pairPastCoordinates v P)* + ((pairPathIncrement false s t P*pairPathIncrement true s t P:ℝ):ℂ))) := by + funext P + simp only [pairLinearIncrement,ContinuousMap.coe_mk,Complex.ofReal_add,Complex.ofReal_mul] + ring + rw [hid] + exact ((hx.const_mul ((a:ℂ)^2)).add (hy.const_mul ((b:ℂ)^2))).add + (hxy.const_mul (2*(a:ℂ)*b)) + +lemma normalJointPast_linear_second {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + (∫ P, F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)^2 ∂μ)= + (((c:ℝ)*((t:ℝ)-s)*(a^2+b^2):ℝ):ℂ)*(∫ P, F (pairPastCoordinates v P) ∂μ)+ + 2*(a:ℂ)*b*(∫ P, F (pairPastCoordinates v P)* + ((pairPathIncrement false s t P*pairPathIncrement true s t P:ℝ):ℂ) ∂μ) := by + have hx := normalJointPast_complex_weighted_moment_integrable (k := 2) μ c h v s t hst ht false F + have hy := normalJointPast_complex_weighted_moment_integrable (k := 2) μ c h v s t hst ht true F + have hxy := normalJointPast_complex_cross_integrable μ c h v s t hst ht F + have hid : (fun P => F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)^2)= + (fun P => (a:ℂ)^2*(F (pairPastCoordinates v P)*(pairPathIncrement false s t P:ℂ)^2)+ + (b:ℂ)^2*(F (pairPastCoordinates v P)*(pairPathIncrement true s t P:ℂ)^2)+ + 2*(a:ℂ)*b*(F (pairPastCoordinates v P)* + ((pairPathIncrement false s t P*pairPathIncrement true s t P:ℝ):ℂ))) := by + funext P + simp only [pairLinearIncrement,ContinuousMap.coe_mk,Complex.ofReal_add,Complex.ofReal_mul] + ring + have hadd := integral_add ((hx.const_mul ((a:ℂ)^2)).add (hy.const_mul ((b:ℂ)^2))) + (hxy.const_mul (2*(a:ℂ)*b)) + simp only [Pi.add_apply] at hadd + rw [hid,hadd, + integral_add (hx.const_mul ((a:ℂ)^2)) (hy.const_mul ((b:ℂ)^2)),integral_const_mul,integral_const_mul,integral_const_mul, + normalJointPast_complex_second μ c h v s t hv hst ht false, + normalJointPast_complex_second μ c h v s t hv hst ht true] + push_cast + ring + +lemma normalJointPast_linear_absolute_third_bound + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (s t : unitInterval) (hst : s < t) (ht : (t:ℝ) < 1) (a b : ℝ) : + Integrable (fun P => |pairLinearIncrement a b s t P|^3) μ ∧ + (∫ P, |pairLinearIncrement a b s t P|^3 ∂μ) ≤ + 8*(|a|+|b|)^3*(Real.sqrt ((c:ℝ)*((t:ℝ)-s)))^3*normalThirdMoment := by + have hx := normalJointPast_integrable_abs_pow μ c h s t hst ht false 3 + have hy := normalJointPast_integrable_abs_pow μ c h s t hst ht true 3 + have hi := (hx.add hy).const_mul (4*(|a|+|b|)^3) + have hb : ∀ P, |pairLinearIncrement a b s t P|^3 ≤ + 4*(|a|+|b|)^3*(|pairPathIncrement false s t P|^3+|pairPathIncrement true s t P|^3) := by + intro P + exact abs_linear_cube_bound a b _ _ + have hI : Integrable (fun P => |pairLinearIncrement a b s t P|^3) μ := hi.mono (by fun_prop) + (by filter_upwards [] with P + change ‖|(pairLinearIncrement a b s t) P|^3‖ ≤ + ‖4*(|a|+|b|)^3*(|pairPathIncrement false s t P|^3+|pairPathIncrement true s t P|^3)‖ + simp only [norm_pow,Real.norm_eq_abs,abs_abs] + exact (hb P).trans (le_abs_self _)) + refine ⟨hI,?_⟩ + calc + _ ≤ ∫ P, 4*(|a|+|b|)^3*(|pairPathIncrement false s t P|^3+|pairPathIncrement true s t P|^3) ∂μ := + integral_mono hI hi hb + _ = _ := by + rw [integral_const_mul,integral_add hx hy, + normalJointPast_absolute_third_moment μ c h s t hst ht false, + normalJointPast_absolute_third_moment μ c h s t hst ht true] + ring + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma pairPastTest_integrable {q : ℕ} (μ : Measure RealPathPair) [IsFiniteMeasure μ] + (v : Fin q → unitInterval) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) : + Integrable (fun P => F (pairPastCoordinates v P)) μ := by + apply Integrable.of_bound (by fun_prop) ‖F‖ + filter_upwards [] with P + exact F.norm_coe_le_norm _ + +lemma pairPastPhase_integrable {q : ℕ} (μ : Measure RealPathPair) [IsFiniteMeasure μ] + (v : Fin q → unitInterval) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) (s t : unitInterval) : + Integrable (fun P => F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P)) μ := by + apply Integrable.of_bound (by unfold charPhase; fun_prop) ‖F‖ + filter_upwards [] with P + rw [norm_mul,charPhase_norm,mul_one] + exact F.norm_coe_le_norm _ + +lemma normalJointPast_integral_quadratic {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + (∫ P, F (pairPastCoordinates v P)*(1+(pairLinearIncrement a b s t P:ℂ)*Complex.I- + (pairLinearIncrement a b s t P:ℂ)^2/2) ∂μ)= + (1-(((c:ℝ)*((t:ℝ)-s)*(a^2+b^2)/2:ℝ):ℂ))*(∫ P, F (pairPastCoordinates v P) ∂μ)- + (a:ℂ)*b*(∫ P, F (pairPastCoordinates v P)* + ((pairPathIncrement false s t P*pairPathIncrement true s t P:ℝ):ℂ) ∂μ) := by + have h0 := pairPastTest_integrable μ v F + have h1 := normalJointPast_linear_mean_integrable μ c h v s t hst ht F a b + have h2 := normalJointPast_linear_second_integrable μ c h v s t hst ht F a b + have hid : (fun P => F (pairPastCoordinates v P)*(1+(pairLinearIncrement a b s t P:ℂ)*Complex.I- + (pairLinearIncrement a b s t P:ℂ)^2/2))= + (fun P => F (pairPastCoordinates v P)+ + Complex.I*(F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ))- + (1/2:ℂ)*(F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)^2)) := by + funext P; ring + have hadd := integral_sub (h0.add (h1.const_mul Complex.I)) (h2.const_mul (1/2:ℂ)) + simp only [Pi.add_apply] at hadd + rw [hid,hadd,integral_add h0 (h1.const_mul Complex.I),integral_const_mul,integral_const_mul, + normalJointPast_linear_mean μ c h v s t hv hst ht F a b, + normalJointPast_linear_second μ c h v s t hv hst ht F a b] + push_cast + ring + +lemma normalJointPast_taylor_error {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + ‖(∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)- + ((1-(((c:ℝ)*((t:ℝ)-s)*(a^2+b^2)/2:ℝ):ℂ))*(∫ P, F (pairPastCoordinates v P) ∂μ)- + (a:ℂ)*b*(∫ P, F (pairPastCoordinates v P)* + ((pairPathIncrement false s t P*pairPathIncrement true s t P:ℝ):ℂ) ∂μ))‖ ≤ + 8*charTaylorConstant*‖F‖*(|a|+|b|)^3* + (Real.sqrt ((c:ℝ)*((t:ℝ)-s)))^3*normalThirdMoment := by + have h0 := pairPastTest_integrable μ v F + have h1 := normalJointPast_linear_mean_integrable μ c h v s t hst ht F a b + have h2 := normalJointPast_linear_second_integrable μ c h v s t hst ht F a b + have hchar := pairPastPhase_integrable μ v F a b s t + have hQ : Integrable (fun P => F (pairPastCoordinates v P)*(1+(pairLinearIncrement a b s t P:ℂ)*Complex.I- + (pairLinearIncrement a b s t P:ℂ)^2/2)) μ := by + have hid : (fun P => F (pairPastCoordinates v P)*(1+(pairLinearIncrement a b s t P:ℂ)*Complex.I- + (pairLinearIncrement a b s t P:ℂ)^2/2))= + (fun P => F (pairPastCoordinates v P)+ + Complex.I*(F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ))- + (1/2:ℂ)*(F (pairPastCoordinates v P)*(pairLinearIncrement a b s t P:ℂ)^2)) := by + funext P; ring + rw [hid] + exact (h0.add (h1.const_mul Complex.I)).sub (h2.const_mul (1/2:ℂ)) + rw [← normalJointPast_integral_quadratic μ c h v s t hv hst ht F a b,← integral_sub hchar hQ] + have h3 := normalJointPast_linear_absolute_third_bound μ c h s t hst ht a b + have hb : ∀ P, ‖F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P)- + F (pairPastCoordinates v P)*(1+(pairLinearIncrement a b s t P:ℂ)*Complex.I- + (pairLinearIncrement a b s t P:ℂ)^2/2)‖ ≤ + ‖F‖*charTaylorConstant*|pairLinearIncrement a b s t P|^3 := by + intro P + rw [← mul_sub,norm_mul] + exact (mul_le_mul (F.norm_coe_le_norm _) (charPhase_quadratic_error _) (norm_nonneg _) (norm_nonneg F)).trans_eq (by ring) + calc + _ ≤ ∫ P, ‖F‖*charTaylorConstant*|pairLinearIncrement a b s t P|^3 ∂μ := + norm_integral_le_of_norm_le (h3.1.const_mul _) (ae_of_all _ hb) + _ = ‖F‖*charTaylorConstant*(∫ P, |pairLinearIncrement a b s t P|^3 ∂μ) := integral_const_mul _ _ + _ ≤ _ := by + have hh := mul_le_mul_of_nonneg_left h3.2 (mul_nonneg (norm_nonneg F) charTaylorConstant_nonneg) + nlinarith only [hh] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/NormalizedRestrictionContact.lean b/lean/OAI/Probability/Ballisticity/Estimates/NormalizedRestrictionContact.lean new file mode 100644 index 0000000000000000000000000000000000000000..27e3e9aa45c3d811699727999905df46fdcb4977 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/NormalizedRestrictionContact.lean @@ -0,0 +1,201 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightSlab + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma normalized_restriction_contact_le {Ω : Type*} [MeasurableSpace Ω] + (μ η : Measure Ω) [IsFiniteMeasure μ] [IsFiniteMeasure η] + (D C A R : Set Ω) (hC : MeasurableSet C) + (hA : MeasurableSet A) (hAR : A ⊆ R) (c γ δ : ℝ≥0∞) + (hc : 0 < c) (hcD : c ≤ μ D) (hη : η D ≤ μ D+γ) + (hδ : η (R \ D) ≤ δ) (he : μ (A \ C) = η (A \ C)) : + normalizedMeasure (μ.restrict D) A ≤ normalizedMeasure (η.restrict D) A + + normalizedMeasure (μ.restrict D) C + c⁻¹*(γ+δ) := by + have ha : μ D ≠ 0 := ne_of_gt (hc.trans_le hcD) + have hfin : μ D ≠ ⊤ := measure_ne_top _ _ + have hmass : ∀ (ξ : Measure Ω), ξ.restrict D Set.univ = ξ D := by + intro ξ + rw [Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] + have hraw : μ (A ∩ D) ≤ μ (C ∩ D) + η (A ∩ D) + δ := by + calc + _ ≤ μ (C ∩ D)+μ (A \ C) := by + apply (measure_mono (s := A ∩ D) (t := (C ∩ D) ∪ (A \ C)) ?_).trans (measure_union_le _ _) + intro z hz + by_cases hzC : z ∈ C + · exact Or.inl ⟨hzC,hz.2⟩ + · exact Or.inr ⟨hz.1,hzC⟩ + _ = μ (C ∩ D)+η (A \ C) := by rw [he] + _ ≤ μ (C ∩ D)+(η (A ∩ D)+δ) := by + apply add_le_add le_rfl + calc + _ ≤ η ((A ∩ D) ∪ (R \ D)) := by + apply measure_mono + intro z hz + by_cases hzD : z ∈ D + · exact Or.inl ⟨hz.1,hzD⟩ + · exact Or.inr ⟨hAR hz.1,hzD⟩ + _ ≤ η (A ∩ D)+η (R \ D) := measure_union_le _ _ + _ ≤ _ := add_le_add le_rfl hδ + _ = _ := (add_assoc _ _ _).symm + have hηA : (η.restrict D) A ≤ (μ D+γ)* normalizedMeasure (η.restrict D) A := by + by_cases hz : η D = 0 + · have hzero : η (A ∩ D) = 0 := measure_mono_null Set.inter_subset_right hz + rw [Measure.restrict_apply hA,hzero] + exact zero_le + · have heq : (η.restrict D) A = η D * normalizedMeasure (η.restrict D) A := by + change _ = η D*((η.restrict D Set.univ)⁻¹*(η.restrict D) A) + rw [hmass,← mul_assoc,ENNReal.mul_inv_cancel hz (measure_ne_top _ _),one_mul] + rw [heq] + exact mul_le_mul_left hη _ + have hprob : normalizedMeasure (η.restrict D) A ≤ 1 := by + by_cases hz : η D = 0 + · change (η.restrict D Set.univ)⁻¹*(η.restrict D) A ≤ 1 + rw [hmass,Measure.restrict_apply hA,measure_mono_null Set.inter_subset_right hz] + simp + · let := normalizedMeasure_probability (η.restrict D) (by rw [hmass]; exact hz) + exact prob_le_one + have hmid : μ (A ∩ D) ≤ μ D * (normalizedMeasure (η.restrict D) A + + normalizedMeasure (μ.restrict D) C) + (γ+δ) := by + calc + _ ≤ μ (C ∩ D) + (μ D+γ)*normalizedMeasure (η.restrict D) A + δ := + hraw.trans (add_le_add (add_le_add le_rfl (by simpa only [Measure.restrict_apply hA] using hηA)) le_rfl) + _ ≤ μ (C ∩ D) + (μ D*normalizedMeasure (η.restrict D) A+γ) + δ := by + rw [add_mul] + exact add_le_add (add_le_add le_rfl (add_le_add le_rfl + (by simpa only [mul_one] using mul_le_mul_right hprob γ))) le_rfl + _ = _ := by + have hCeq : μ D * normalizedMeasure (μ.restrict D) C = μ (C ∩ D) := by + change μ D*((μ.restrict D Set.univ)⁻¹*(μ.restrict D) C) = _ + rw [hmass,← mul_assoc,ENNReal.mul_inv_cancel ha hfin,one_mul,Measure.restrict_apply hC] + rw [mul_add,hCeq] + ac_rfl + change (μ.restrict D Set.univ)⁻¹*(μ.restrict D) A ≤ _ + rw [hmass,Measure.restrict_apply hA] + calc + _ ≤ (μ D)⁻¹*(μ D*(normalizedMeasure (η.restrict D) A+normalizedMeasure (μ.restrict D) C)+(γ+δ)) := + mul_le_mul_right hmid _ + _ = normalizedMeasure (η.restrict D) A + normalizedMeasure (μ.restrict D) C + (μ D)⁻¹*(γ+δ) := by + rw [mul_add,← mul_assoc,ENNReal.inv_mul_cancel ha hfin,one_mul] + _ ≤ _ := add_le_add le_rfl (mul_le_mul_left (ENNReal.inv_le_inv.mpr hcD) _) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/NormalizedSharedRestrict.lean b/lean/OAI/Probability/Ballisticity/Estimates/NormalizedSharedRestrict.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9ef5494873f9f5b760dfc23c39b7b1709cd3e1f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/NormalizedSharedRestrict.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SharedConditionedPairLawFst +import OAI.Probability.Ballisticity.Crossings.HitWord +import OAI.Probability.Ballisticity.Estimates.NormalizedRestrictionContact +import OAI.Probability.Ballisticity.Crossings.CrossTranslation + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma normalized_shared_restrict {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) (x y : Lattice d) : + normalizedMeasure ((sharedPairLaw ν x y).restrict (NoDrop ℓ x ×ˢ NoDrop ℓ y)) = + sharedConditionedPairLaw ν ℓ x y := by + unfold normalizedMeasure sharedConditionedPairLaw + rw [Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,← sharedNoDropMass_eq] + +lemma normalized_independent_restrict {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) : + normalizedMeasure (((annealedFrom ν x).prod (annealedFrom ν y)).restrict + (NoDrop ℓ x ×ˢ NoDrop ℓ y)) = (conditionedFrom ν ℓ x).prod (conditionedFrom ν ℓ y) := by + unfold normalizedMeasure conditionedFrom + rw [Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,Measure.prod_prod, + annealedFrom_noDrop,annealedFrom_noDrop,Measure.prod_smul_left,Measure.prod_smul_right, + smul_smul,Measure.prod_restrict,ENNReal.mul_inv] + · exact Or.inr (measure_ne_top _ _) + · exact Or.inl (measure_ne_top _ _) + +lemma hitWordsEvent_subset_hit {d : ℕ} (x y : Lattice d) (S T : Set (Lattice d)) + (E : Set (HitWord x S T × HitWord y S T)) : + hitWordsEvent x y S T E ⊆ Hit S T ×ˢ Hit S T := by + intro P hP + obtain ⟨w,hw⟩ := Set.mem_iUnion.mp hP + obtain ⟨_,hcy⟩ := Set.mem_iUnion.mp hw + exact ⟨Set.mem_iUnion.mpr ⟨w.1.val.length,hitWord_prefix x S T w.1 hcy.1⟩, + Set.mem_iUnion.mpr ⟨w.2.val.length,hitWord_prefix y S T w.2 hcy.2⟩⟩ + +theorem conditioned_prefix_comparison {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) + (hxy : dot (realPosition x) ℓ = dot (realPosition y) ℓ) (H : ℝ) + (E : Set (HitWord x (Strip ℓ x H) (Upper ℓ x H) × HitWord y (Strip ℓ x H) (Upper ℓ x H))) : + sharedConditionedPairLaw ν ℓ x y (hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) E) ≤ + ((conditionedFrom ν ℓ x).prod (conditionedFrom ν ℓ y)) + (hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) E) + + sharedConditionedPairLaw ν ℓ x y (PrefixContact (Strip ℓ x H)) + + (sharedNoDropMass ν ℓ x y)⁻¹ * + ((annealedLaw ν (NoDrop ℓ 0))^2-sharedNoDropMass ν ℓ x y + + 2*annealedLaw ν (Cross ℓ 0 H \ NoDrop ℓ 0)) := by + have hs : Strip ℓ x H = Strip ℓ y H := by unfold Strip; rw [hxy] + have ht : Upper ℓ x H = Upper ℓ y H := by unfold Upper; rw [hxy] + have hsub : hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) E ⊆ Cross ℓ x H ×ˢ Cross ℓ y H := by + intro P hP + have hh := hitWordsEvent_subset_hit x y _ _ E hP + rw [cross_eq_hit,cross_eq_hit] + exact ⟨hh.1,by simpa only [hs,ht] using hh.2⟩ + have hmass : ((annealedFrom ν x).prod (annealedFrom ν y)) (NoDrop ℓ x ×ˢ NoDrop ℓ y) = + (annealedLaw ν (NoDrop ℓ 0))^2 := by + rw [Measure.prod_prod,annealedFrom_noDrop,annealedFrom_noDrop,pow_two] + have hh := normalized_restriction_contact_le (sharedPairLaw ν x y) + ((annealedFrom ν x).prod (annealedFrom ν y)) + (NoDrop ℓ x ×ˢ NoDrop ℓ y) (PrefixContact (Strip ℓ x H)) + (hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) E) (Cross ℓ x H ×ˢ Cross ℓ y H) + (measurableSet_prefixContact _) (measurableSet_hitWordsEvent _ _ _ _ _) hsub + (sharedNoDropMass ν ℓ x y) + ((annealedLaw ν (NoDrop ℓ 0))^2-sharedNoDropMass ν ℓ x y) + (2*annealedLaw ν (Cross ℓ 0 H \ NoDrop ℓ 0)) + (sharedNoDropMass_pos ν hue ℓ hℓ htrans x y) + (le_of_eq (sharedNoDropMass_eq ν ℓ x y)) + (by rw [hmass,← sharedNoDropMass_eq]; exact le_add_tsub) + (independent_cross_noDrop_error_bound ν ℓ x y H) + (raw_prefix_off_contact_equal ν x y _ _ (disjoint_strip_upper ℓ x H) E) + simpa only [normalized_shared_restrict,normalized_independent_restrict] using hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ObservedBudget.lean b/lean/OAI/Probability/Ballisticity/Estimates/ObservedBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..17a339b23f4a2e6c76d813ba874273eefd392155 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ObservedBudget.lean @@ -0,0 +1,234 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ObservedCharges + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +theorem observedAdvance_total_charge {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {b R s c q L : ℝ} (hb : 0≤b) (hR : b≤R) (hc : 0≤c) (hq : 0≤q) + (K : ℕ) (hK : 0 pairGap f j pairGap f j sharedConditionedPairLaw ν ℓ j.1 j.2 + let active := fun j => pairGap f j ENNReal.ofReal (observedStateGain f b R c q (pairOrigin P)) + let bound := fun P => ENNReal.ofReal L*reward P + let : ∀ j, IsProbabilityMeasure (μ j) := fun j => + sharedConditionedPairLaw_probability ν ℓ j.1 j.2 + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans j.1 j.2)) + have hK' : ∀ j : Lattice d × Lattice d, + signedHeight e j.1=signedHeight e j.2 → active j → 0 ENNReal.ofReal L*ENNReal.ofReal (observedStateGain f b R c q j)) := by + filter_upwards [pairOrigin_ae ν ℓ htrans j.1 j.2] with P hP + simp only [bound,reward,hP] + rw [lintegral_congr_ae he] + simpa using hmean j hj + have hc' := restart_reward_comparison_total μ pairOrigin next + (fun j => signedHeight e j.1=signedHeight e j.2) + (observedCharge e f b R s K k) bound + (measurable_commonCutObserver ℓ active B) (measurable_observedCharge e f b R s K k) hbound + (fun j hj g hg => commonCutObserver_restart ν hue e htrans active B K' hK' hB j hj g hg) + (fun j hj => commonCutObserver_sameHeight ν hue e htrans active B K' hK' hB j hj) + hm i hi + calc + (∫⁻ P, ⨆ N, observerRewardSum next (observedCharge e f b R s K k) N P ∂μ i) + ≤ ∫⁻ P, ⨆ N, observerRewardSum next bound N P ∂μ i := hc' + _ = ENNReal.ofReal L*(∫⁻ P, ⨆ N, observerRewardSum next reward N P ∂μ i) := by + simp only [bound,observerRewardSum_mul,← ENNReal.mul_iSup] + exact lintegral_const_mul' _ _ (ENNReal.ofReal_ne_top) + _ ≤ ENNReal.ofReal L*ENNReal.ofReal ((2*R)^((3:ℝ)/2)-observedStatePotential f b R i) := + mul_le_mul_right (observedAdvance_total_gain ν hue e f htrans hb hR hc hq K hK k hk hdrift i hi) _ + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +def SmallCommonLayer {d : ℕ} (e f : Direction d) (s : ℝ) (H : ℤ) : + Set (Path d × Path d) := + {P | ∃ n m, P.1 ∈ FirstLayerHit (signedHeight e) H n ∧ + P.2 ∈ FirstLayerHit (signedHeight e) H m ∧ + P.1 ∈ FutureNoDrop (realPosition (step e)) n ∧ + P.2 ∈ FutureNoDrop (realPosition (step e)) m ∧ + |signedCoordinate f (P.1 n-P.2 m)| ≤ s} + +lemma measurableSet_smallCommonLayer {d : ℕ} (e f : Direction d) (s : ℝ) (H : ℤ) : + MeasurableSet (SmallCommonLayer e f s H) := by + unfold SmallCommonLayer + simp only [Set.ofPred_exists,Set.ofPred_and] + apply MeasurableSet.iUnion + intro n + apply MeasurableSet.iUnion + intro m + refine ((measurableSet_firstLayerHit _ _ _).preimage measurable_fst).inter ?_ + refine ((measurableSet_firstLayerHit _ _ _).preimage measurable_snd).inter ?_ + refine ((measurableSet_futureNoDrop _ _).preimage measurable_fst).inter ?_ + refine ((measurableSet_futureNoDrop _ _).preimage measurable_snd).inter ?_ + apply measurableSet_le _ measurable_const + exact ((measurable_of_countable (signedCoordinate f)).comp + (((measurable_pi_apply n).comp measurable_fst).sub + ((measurable_pi_apply m).comp measurable_snd))).abs + +lemma firstLayerHit_suffix_iff_of_record {d : ℕ} (e : Direction d) (X : Path d) + {n k : ℕ} {H : ℤ} (hr : StrictRecord (realPosition (step e)) X n) + (hH : signedHeight e (X n) ≤ H) : + (fun j => X (n+j)) ∈ FirstLayerHit (signedHeight e) H k ↔ + X ∈ FirstLayerHit (signedHeight e) H (n+k) := by + constructor + · rintro ⟨he,hpre⟩ + refine ⟨he,?_⟩ + intro j hj + by_cases hjn : j < n + · have h := hr j hjn + rw [signedHeight_projection,signedHeight_projection] at h + have h' : signedHeight e (X j) < signedHeight e (X n) := by exact_mod_cast h + exact h'.trans_le hH + · have h := hpre (j-n) (by omega) + simpa only [Nat.add_sub_cancel' (Nat.le_of_not_gt hjn)] using h + · rintro ⟨he,hpre⟩ + refine ⟨he,fun j hj => hpre (n+j) (by omega)⟩ + +lemma firstLayerHit_time_ge_record {d : ℕ} (e : Direction d) (X : Path d) + {n k : ℕ} {H : ℤ} (hr : StrictRecord (realPosition (step e)) X n) + (hH : signedHeight e (X n) ≤ H) (hk : X ∈ FirstLayerHit (signedHeight e) H k) : + n ≤ k := by + by_contra hh + have h := hr k (Nat.lt_of_not_ge hh) + rw [signedHeight_projection,signedHeight_projection,hk.1] at h + have : H < signedHeight e (X n) := by exact_mod_cast h + omega + +lemma futureNoDrop_suffix_iff {d : ℕ} (ℓ : Vector d) (X : Path d) (n k : ℕ) : + (fun j => X (n+j)) ∈ FutureNoDrop ℓ k ↔ X ∈ FutureNoDrop ℓ (n+k) := by + simp only [FutureNoDrop,Set.mem_ofPred_eq,Nat.add_assoc] + +lemma smallCommonLayer_suffix_iff {d : ℕ} (e f : Direction d) (s : ℝ) + (P : Path d × Path d) {n m : ℕ} (hc : CommonTrueRecord (realPosition (step e)) P n m) + {H : ℤ} (hH : signedHeight e (P.1 n) ≤ H) : + commonPairSuffix n m P ∈ SmallCommonLayer e f s H ↔ P ∈ SmallCommonLayer e f s H := by + have he : signedHeight e (P.1 n)=signedHeight e (P.2 m) := by + have hh := hc.2.2 + rw [signedHeight_projection,signedHeight_projection] at hh + exact_mod_cast hh + have hH' : signedHeight e (P.2 m) ≤ H := by rwa [← he] + constructor + · rintro ⟨j,k,hj,hk,hD,hE,hgap⟩ + refine ⟨n+j,m+k,(firstLayerHit_suffix_iff_of_record e P.1 hc.1.1 hH).mp hj, + (firstLayerHit_suffix_iff_of_record e P.2 hc.2.1.1 hH').mp hk, + (futureNoDrop_suffix_iff _ _ n j).mp hD,(futureNoDrop_suffix_iff _ _ m k).mp hE,hgap⟩ + · rintro ⟨j,k,hj,hk,hD,hE,hgap⟩ + have hnj := firstLayerHit_time_ge_record e P.1 hc.1.1 hH hj + have hmk := firstLayerHit_time_ge_record e P.2 hc.2.1.1 hH' hk + have hj' : P.1 ∈ FirstLayerHit (signedHeight e) H (n+(j-n)) := by simpa only [Nat.add_sub_cancel' hnj] using hj + have hk' : P.2 ∈ FirstLayerHit (signedHeight e) H (m+(k-m)) := by simpa only [Nat.add_sub_cancel' hmk] using hk + refine ⟨j-n,k-m,(firstLayerHit_suffix_iff_of_record e P.1 hc.1.1 hH).mpr hj', + (firstLayerHit_suffix_iff_of_record e P.2 hc.2.1.1 hH').mpr hk',?_,?_,?_⟩ + · apply (futureNoDrop_suffix_iff _ _ n (j-n)).mpr + simpa only [Nat.add_sub_cancel' hnj] using hD + · apply (futureNoDrop_suffix_iff _ _ m (k-m)).mpr + simpa only [Nat.add_sub_cancel' hmk] using hE + · simpa only [commonPairSuffix,Nat.add_sub_cancel' hnj,Nat.add_sub_cancel' hmk] using hgap + +lemma firstLayerHit_recordIndexPosition_all {d : ℕ} (e : Direction d) + (x : Lattice d) (X : Path d) (hx : X 0=x) + (hD : X ∈ NoDrop (realPosition (step e)) x) + (hnn : ∀ n, ∃ f, X (n+1)=X n+step f) {H n : ℕ} + (hn : X ∈ FirstLayerHit (signedHeight e) (signedHeight e x+H) n) : + recordIndexPosition (realPosition (step e)) H (fun j => X j-x)=X n-x := by + by_cases hH : H=0 + · subst H + have hn0 : n=0 := by + by_contra hh + have h := hn.2 0 (Nat.pos_of_ne_zero hh) + rw [hx] at h + simp only [Nat.cast_zero,add_zero,lt_self_iff_false] at h + subst n + rw [recordIndexPosition,recordIndexTime_zero] + · exact firstLayerHit_recordIndexPosition_translated e x X hx hD hnn (Nat.pos_of_ne_zero hH) hn + +lemma physicalFirstHitGap_at_common {d : ℕ} (e f : Direction d) + (P : Path d × Path d) (hxy : signedHeight e (P.1 0)=signedHeight e (P.2 0)) + (hD : P.1 ∈ NoDrop (realPosition (step e)) (P.1 0)) + (hE : P.2 ∈ NoDrop (realPosition (step e)) (P.2 0)) + (hnn : ∀ n, ∃ g, P.1 (n+1)=P.1 n+step g) + (hmm : ∀ n, ∃ g, P.2 (n+1)=P.2 n+step g) + {H n m : ℕ} (hn : P.1 ∈ FirstLayerHit (signedHeight e) (signedHeight e (P.1 0)+H) n) + (hm : P.2 ∈ FirstLayerHit (signedHeight e) (signedHeight e (P.1 0)+H) m) : + physicalFirstHitGap (realPosition (step e)) f (P.1 0) (P.2 0) H P = + signedCoordinate f (P.1 n-P.2 m) := by + have h1 := firstLayerHit_recordIndexPosition_all e (P.1 0) P.1 rfl hD hnn hn + have h2 := firstLayerHit_recordIndexPosition_all e (P.2 0) P.2 rfl hE hmm (by rwa [← hxy]) + simp only [physicalFirstHitGap,firstHitPairGap,h1,h2,signedCoordinate_sub] + ring + +lemma smallCommonLayer_iff_physical {d : ℕ} (e f : Direction d) (s : ℝ) + (P : Path d × Path d) (hxy : signedHeight e (P.1 0)=signedHeight e (P.2 0)) + (hD : P.1 ∈ NoDrop (realPosition (step e)) (P.1 0)) + (hE : P.2 ∈ NoDrop (realPosition (step e)) (P.2 0)) + (hnn : ∀ n, ∃ g, P.1 (n+1)=P.1 n+step g) + (hmm : ∀ n, ∃ g, P.2 (n+1)=P.2 n+step g) (H : ℕ) : + P ∈ SmallCommonLayer e f s (signedHeight e (P.1 0)+H) ↔ + P ∈ CommonLayer (realPosition (step e)) (signedHeight e) (signedHeight e (P.1 0)+H) ∧ + |physicalFirstHitGap (realPosition (step e)) f (P.1 0) (P.2 0) H P| ≤ s := by + constructor + · rintro ⟨n,m,hn,hm,hF,hG,hgap⟩ + exact ⟨⟨n,m,hn,hm,hF,hG⟩,by rw [physicalFirstHitGap_at_common e f P hxy hD hE hnn hmm hn hm]; exact hgap⟩ + · rintro ⟨⟨n,m,hn,hm,hF,hG⟩,hgap⟩ + exact ⟨n,m,hn,hm,hF,hG,by rw [← physicalFirstHitGap_at_common e f P hxy hD hE hnn hmm hn hm]; exact hgap⟩ + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ObservedCharges.lean b/lean/OAI/Probability/Ballisticity/Estimates/ObservedCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..24077ba4a2591ad90862a2741bca6c4a4702b57b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ObservedCharges.lean @@ -0,0 +1,277 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ObservedDrift + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +def observerShrinkEvent {d : ℕ} (e f : Direction d) (k : ℝ → ℕ) + (i : Lattice d × Lattice d) : Set (Path d × Path d) := + {P | ∃ h ≤ k (pairGap f i), + |physicalFirstHitGap (realPosition (step e)) f i.1 i.2 h P| ≤ pairGap f i/2} + +lemma measurableSet_observerShrinkEvent {d : ℕ} (e f : Direction d) (k : ℝ → ℕ) + (i : Lattice d × Lattice d) : MeasurableSet (observerShrinkEvent e f k i) := by + unfold observerShrinkEvent + simp only [Set.ofPred_exists,Set.ofPred_and] + apply MeasurableSet.iUnion + intro h + exact (MeasurableSet.const _).inter + (measurableSet_le (measurable_physicalFirstHitGap _ _ _ _ h |>.abs) measurable_const) + +noncomputable def observedCharge {d : ℕ} (e f : Direction d) (b R s : ℝ) + (K : ℕ) (k : ℝ → ℕ) (P : Path d × Path d) : ℝ≥0∞ := + let i := pairOrigin P + if pairGap f i (k (pairGap f i) : ℝ≥0∞)) P + else 0 + +lemma measurable_observedCharge {d : ℕ} (e f : Direction d) (b R s : ℝ) + (K : ℕ) (k : ℝ → ℕ) : Measurable (observedCharge e f b R s K k) := by + have h : Measurable (fun Z : (Path d × Path d) × (Lattice d × Lattice d) => + if pairGap f Z.2 (k (pairGap f Z.2):ℝ≥0∞)) Z.1 + else 0) := by + apply measurable_from_prod_countable_left + intro i + dsimp only + by_cases ha : pairGap f i (P,pairOrigin P) + have hg : Measurable g := measurable_id.prodMk measurable_pairOrigin + have hh := h.comp hg + unfold observedCharge + simpa only [Function.comp_def,g] using hh + +lemma observedCharge_mean {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (b R s : ℝ) (K : ℕ) (k : ℝ → ℕ) (i : Lattice d × Lattice d) : + (∫⁻ P, observedCharge e f b R s K k P + ∂sharedConditionedPairLaw ν (realPosition (step e)) i.1 i.2) = + if pairGap f i if pairGap f i (k (pairGap f i):ℝ≥0∞)) P + else 0) := by + filter_upwards [pairOrigin_ae ν ℓ htrans i.1 i.2] with P hP + simp only [observedCharge,hP] + rw [lintegral_congr_ae he] + split_ifs + · simp + · exact lintegral_indicator_const (measurableSet_observerShrinkEvent e f k i) _ + · simp + +lemma observedCharge_mean_le {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {b R s c q L δ : ℝ} (hL : 0≤L) (hbs : b≤2*s) + (K : ℕ) (k : ℝ → ℕ) (i : Lattice d × Lattice d) + (hlower : (K:ℝ)≤L*(q*((2*b)^((3:ℝ)/2)-b^((3:ℝ)/2)))) + (hnear : b hn (h.trans hbs) + simp only [ite_eq_right hn,ite_eq_right hb] + rw [← ENNReal.ofReal_mul hL] + let μ := sharedConditionedPairLaw ν (realPosition (step e)) i.1 i.2 + have : IsProbabilityMeasure μ := sharedConditionedPairLaw_probability ν _ i.1 i.2 + (ne_of_gt (sharedNoDropMass_pos ν hue _ (signed_direction_unit e) htrans i.1 i.2)) + rw [← ofReal_measureReal (μ := μ),← ENNReal.ofReal_natCast, + ← ENNReal.ofReal_mul (Nat.cast_nonneg _)] + apply ENNReal.ofReal_le_ofReal + exact (mul_le_mul_of_nonneg_left (hshrink (lt_of_not_ge hn) ha) (Nat.cast_nonneg _)).trans + (hfar (lt_of_not_ge hn) ha) + · simp only [ite_eq_right ha,observedStateGain,ENNReal.ofReal_zero,mul_zero,le_refl] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma commonLayer_before_selected_bound {d : ℕ} (e : Direction d) + (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + (hxy : signedHeight e (P.1 0)=signedHeight e (P.2 0)) + (K : ℕ) (hK : 0 < K) + (hB : ∀ z w, signedHeight e (P.1 0)+K ≤ signedHeight e z → B (z,w)) + {n m h : ℕ} (hcut : selectedBoundaryAt (realPosition (step e)) B P n m) + (hh : signedHeight e (P.1 0)+h < signedHeight e (P.1 n)) + (hC : P ∈ CommonLayer (realPosition (step e)) (signedHeight e) + (signedHeight e (P.1 0)+h)) : h < K := by + by_contra hnot + have hKh : K ≤ h := Nat.le_of_not_gt hnot + obtain ⟨j,k,hj,hk,hD,hE⟩ := hC + have hposj : 0 < j := by + by_contra hn + have hj0 : j=0 := by omega + have hjH := hj.1 + rw [hj0] at hjH + omega + have hposk : 0 < k := by + by_contra hn + have hk0 : k=0 := by omega + have hkH := hk.1 + rw [hk0] at hkH + omega + have hheq : signedHeight e (P.1 n)=signedHeight e (P.2 m) := by + have he := hcut.2.2.1.2.2 + rw [signedHeight_projection,signedHeight_projection] at he + exact_mod_cast he + have hjn : j < n := by + by_contra h + have hnle : n ≤ j := Nat.le_of_not_gt h + rcases eq_or_lt_of_le hnle with he | hl + · have hjH := hj.1 + rw [← he] at hjH + omega + · have hnH := hj.2 n hl + omega + have hkm : k < m := by + by_contra h + have hmle : m ≤ k := Nat.le_of_not_gt h + rcases eq_or_lt_of_le hmle with he | hl + · have hkH := hk.1 + rw [← he] at hkH + omega + · have hmH := hk.2 m hl + omega + apply hcut.2.2.2.2 j k hposj hjn hposk hkm + · apply hB + rw [hj.1] + exact add_le_add_right (by exact_mod_cast hKh) _ + · refine ⟨⟨firstLayerHit_record _ _ (signedHeight_projection e) _ j P.1 hj,hD⟩, + ⟨firstLayerHit_record _ _ (signedHeight_projection e) _ k P.2 hk,hE⟩,?_⟩ + rw [signedHeight_projection,signedHeight_projection,hj.1,hk.1] + +noncomputable def allocatedSmallCuts {d : ℕ} (e f : Direction d) (s : ℝ) + (P : Path d × Path d) (n : ℕ) : Finset ℕ := + (Finset.range (signedHeight e (P.1 n)-signedHeight e (P.1 0)).toNat).filter fun h => + P ∈ CommonLayer (realPosition (step e)) (signedHeight e) (signedHeight e (P.1 0)+h) ∧ + |physicalFirstHitGap (realPosition (step e)) f (P.1 0) (P.2 0) h P| ≤ s + +lemma allocatedSmallCuts_card_le {d : ℕ} (e f : Direction d) (s : ℝ) + (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + (hxy : signedHeight e (P.1 0)=signedHeight e (P.2 0)) + (K : ℕ) (hK : 0 < K) + (hB : ∀ z w, signedHeight e (P.1 0)+K ≤ signedHeight e z → B (z,w)) + {n m : ℕ} (hcut : selectedBoundaryAt (realPosition (step e)) B P n m) : + (allocatedSmallCuts e f s P n).card ≤ K := by + have hsub : allocatedSmallCuts e f s P n ⊆ Finset.range K := by + intro h hh + obtain ⟨hh,hC,hgap⟩ := Finset.mem_filter.mp hh + apply Finset.mem_range.mpr + apply commonLayer_before_selected_bound e B P hxy K hK hB hcut _ hC + have hh' := Finset.mem_range.mp hh + omega + exact (Finset.card_le_card hsub).trans_eq (Finset.card_range K) + +lemma allocatedSmallCuts_nonempty_shrink {d : ℕ} (e f : Direction d) (b s : ℝ) + (K : ℕ) (k : ℝ → ℕ) (P : Path d × Path d) + (hxy : signedHeight e (P.1 0)=signedHeight e (P.2 0)) + (hbs : b ≤ 2*s) (hfar : 2*s < pairGap f (pairOrigin P)) + (hk : 0 < k (pairGap f (pairOrigin P))) {n m : ℕ} + (hcut : selectedBoundaryAt (realPosition (step e)) + (observedAdvanceRule e f b K k (pairOrigin P)) P n m) + (hex : (allocatedSmallCuts e f s P n).Nonempty) : + P ∈ observerShrinkEvent e f k (pairOrigin P) := by + obtain ⟨h,hh⟩ := hex + obtain ⟨hh,hC,hgap⟩ := Finset.mem_filter.mp hh + have hupper : ¬pairGap f (pairOrigin P) ≤ b := fun h => not_lt_of_ge (h.trans hbs) hfar + have hKn : observedAdvanceBound f b K k (pairOrigin P)=k (pairGap f (pairOrigin P)) := + ite_eq_right hupper + have hlt := commonLayer_before_selected_bound e + (observedAdvanceRule e f b K k (pairOrigin P)) P hxy + (observedAdvanceBound f b K k (pairOrigin P)) (by rwa [hKn]) + (observedAdvanceRule_height e f b K k (pairOrigin P)) hcut + (by have hh' := Finset.mem_range.mp hh; omega) hC + refine ⟨h,?_,?_⟩ + · rw [hKn] at hlt + exact hlt.le + · exact hgap.trans (by linarith) + +lemma allocatedSmallCuts_le_charge {d : ℕ} (e f : Direction d) {b R s : ℝ} + (hbs : b ≤ 2*s) (K : ℕ) (k : ℝ → ℕ) (P : Path d × Path d) + (hxy : signedHeight e (P.1 0)=signedHeight e (P.2 0)) + (ha : pairGap f (pairOrigin P) < R) + (hK : 0 < observedAdvanceBound f b K k (pairOrigin P)) {n m : ℕ} + (hcut : selectedBoundaryAt (realPosition (step e)) + (observedAdvanceRule e f b K k (pairOrigin P)) P n m) : + ((allocatedSmallCuts e f s P n).card : ℝ≥0∞) ≤ observedCharge e f b R s K k P := by + have hcard := allocatedSmallCuts_card_le e f s + (observedAdvanceRule e f b K k (pairOrigin P)) P hxy + (observedAdvanceBound f b K k (pairOrigin P)) hK + (observedAdvanceRule_height e f b K k (pairOrigin P)) hcut + simp only [observedCharge,ite_eq_left ha] + by_cases hn : pairGap f (pairOrigin P) ≤ 2*s + · simp only [ite_eq_left hn] + exact_mod_cast hcard + · simp only [ite_eq_right hn] + have hb : ¬pairGap f (pairOrigin P) ≤ b := fun h => hn (h.trans hbs) + have hKn : observedAdvanceBound f b K k (pairOrigin P)=k (pairGap f (pairOrigin P)) := + ite_eq_right hb + by_cases hex : (allocatedSmallCuts e f s P n).Nonempty + · have hs := allocatedSmallCuts_nonempty_shrink e f b s K k P hxy hbs + (lt_of_not_ge hn) (by rwa [← hKn]) hcut hex + rw [Set.indicator_of_mem hs] + rw [hKn] at hcard + exact_mod_cast hcard + · rw [Finset.not_nonempty_iff_eq_empty.mp hex,Finset.card_empty] + simp only [Nat.cast_zero] + exact zero_le + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ObservedDrift.lean b/lean/OAI/Probability/Ballisticity/Estimates/ObservedDrift.lean new file mode 100644 index 0000000000000000000000000000000000000000..a31d660a9f11d0c7d7df610e141ade0fd6419a41 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ObservedDrift.lean @@ -0,0 +1,185 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.LowerObservedCut +import OAI.Probability.Ballisticity.Estimates.RestartLyapunov +import OAI.Probability.Ballisticity.Crossings.CommonCutObserver + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +def pairGap {d : ℕ} (f : Direction d) (i : Lattice d × Lattice d) : ℝ := + |signedCoordinate f (i.1-i.2)| + +noncomputable def observedAdvanceRule {d : ℕ} (e f : Direction d) (b : ℝ) + (K : ℕ) (k : ℝ → ℕ) (i uv : Lattice d × Lattice d) : Prop := + if pairGap f i ≤ b then lowerCutCriterion e f (signedHeight e i.1) b K uv else + ((signedHeight e i.1+k (pairGap f i) : ℤ) : ℝ) ≤ dot (realPosition uv.1) (realPosition (step e)) + +noncomputable def observedAdvanceBound {d : ℕ} (f : Direction d) (b : ℝ) + (K : ℕ) (k : ℝ → ℕ) (i : Lattice d × Lattice d) : ℕ := + if pairGap f i ≤ b then K else k (pairGap f i) + +lemma observedAdvanceRule_height {d : ℕ} (e f : Direction d) (b : ℝ) + (K : ℕ) (k : ℝ → ℕ) (i : Lattice d × Lattice d) (z w : Lattice d) + (hz : signedHeight e i.1+observedAdvanceBound f b K k i ≤ signedHeight e z) : + observedAdvanceRule e f b K k i (z,w) := by + by_cases hu : pairGap f i≤b + · simpa only [observedAdvanceRule,ite_eq_left hu] using + lowerCutCriterion_height e f (signedHeight e i.1) b K z w + (by simpa only [observedAdvanceBound,ite_eq_left hu] using hz) + · simp only [observedAdvanceRule,ite_eq_right hu,signedHeight_projection] + exact_mod_cast (show signedHeight e i.1+(k (pairGap f i):ℤ) ≤ signedHeight e z from + by simpa only [observedAdvanceBound,ite_eq_right hu] using hz) + +noncomputable def observedStatePotential {d : ℕ} (f : Direction d) (b R : ℝ) + (i : Lattice d × Lattice d) : ℝ := observedPotential b R (signedCoordinate f (i.1-i.2)) + +noncomputable def observedStateGain {d : ℕ} (f : Direction d) (b R c q : ℝ) + (i : Lattice d × Lattice d) : ℝ := + if pairGap f i pairGap f j pairGap f j ((signedHeight e i.1+k (pairGap f i):ℤ):ℝ) ≤ dot (realPosition uv.1) ℓ) := by + funext uv + simp only [observedAdvanceRule,ite_eq_right hu,ℓ] + rw [hRule,selectedBoundaryData_height,hp] + simpa only [observedStateGain,ite_eq_left ha,ite_eq_right hu,add_comm] using hd + · have : IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ i.1 i.2) := + sharedConditionedPairLaw_probability ν ℓ i.1 i.2 + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans i.1 i.2)) + have he : (fun P => observedStatePotential f b R + (pairOrigin (commonCutObserver ℓ (fun j => pairGap f j observedStatePotential f b R i) := by + filter_upwards [pairOrigin_ae ν ℓ htrans i.1 i.2] with P hP + simp only [commonCutObserver,hP,ite_eq_right ha] + rw [integral_congr_ae he,integral_const] + simp only [observedStateGain,ite_eq_right ha,zero_add,probReal_univ,smul_eq_mul,one_mul,le_refl] + +theorem observedAdvance_total_gain {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {b R c q : ℝ} (hb : 0≤b) (hR : b≤R) (hc : 0≤c) (hq : 0≤q) + (K : ℕ) (hK : 0 pairGap f j pairGap f j + ENNReal.ofReal (observedStateGain f b R c q (pairOrigin Q))) N P + ∂sharedConditionedPairLaw ν (realPosition (step e)) i.1 i.2) ≤ + ENNReal.ofReal ((2*R)^((3:ℝ)/2)-observedStatePotential f b R i) := by + let ℓ := realPosition (step e) + let μ := fun j : Lattice d × Lattice d => sharedConditionedPairLaw ν ℓ j.1 j.2 + let active := fun j => pairGap f j + sharedConditionedPairLaw_probability ν ℓ j.1 j.2 + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans j.1 j.2)) + have hK' : ∀ j : Lattice d × Lattice d, + signedHeight e j.1=signedHeight e j.2 → active j → 0 signedHeight e j.1=signedHeight e j.2) + (observedStatePotential f b R) (observedStateGain f b R c q) ((2*R)^((3:ℝ)/2)) + measurable_pairOrigin (measurable_commonCutObserver ℓ active B) + (fun j _ => pairOrigin_ae ν ℓ htrans j.1 j.2) + (fun j hj g hg => commonCutObserver_restart ν hue e htrans active B K' hK' hB j hj g hg) + (fun j hj => commonCutObserver_sameHeight ν hue e htrans active B K' hK' hB j hj) + (fun j => ⟨observedPotential_nonneg' _ _ _ (hb.trans hR),observedPotential_le _ _ _⟩) + (observedStateGain_nonneg f hb hc hq) hdrift i hi + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ObservedPotential.lean b/lean/OAI/Probability/Ballisticity/Estimates/ObservedPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae7708846fba13983b4d856a43b86194570a237a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ObservedPotential.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SmallTimeExponentialError +import OAI.Probability.Ballisticity.Estimates.SelectedBoundaryRestart +import OAI.Probability.Ballisticity.Crossings.BoundaryFirstHits + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +noncomputable def observedPotential (b R z : ℝ) : ℝ := + min ((max |z| b)^((3:ℝ)/2)) ((2*R)^((3:ℝ)/2)) + +lemma observedPotential_nonneg' (b R z : ℝ) (hR : 0 ≤ R) : + 0 ≤ observedPotential b R z := by + exact le_min (Real.rpow_nonneg ((abs_nonneg _).trans (le_max_left _ _)) _) + (Real.rpow_nonneg (by positivity) _) + +lemma observedPotential_le (b R z : ℝ) : observedPotential b R z ≤ (2*R)^((3:ℝ)/2) := + min_le_right _ _ + +lemma measurable_observedPotential (b R : ℝ) : Measurable (observedPotential b R) := by + unfold observedPotential + fun_prop + +lemma integrable_observedPotential {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + [IsFiniteMeasure μ] (g : Ω → ℝ) (hg : Measurable g) (b R : ℝ) (hR : 0 ≤ R) : + Integrable (fun ω => observedPotential b R (g ω)) μ := by + apply Integrable.of_bound ((measurable_observedPotential b R).comp hg).aestronglyMeasurable + ((2*R)^((3:ℝ)/2)) + exact Eventually.of_forall fun ω => by + change ‖observedPotential b R (g ω)‖ ≤ _ + rw [Real.norm_eq_abs,abs_of_nonneg (observedPotential_nonneg' b R (g ω) hR)] + exact observedPotential_le _ _ _ + +lemma observedPotential_upper_start {b R u : ℝ} (hb : b ≤ u) (hu : 0 ≤ u) (hR : u ≤ R) : + observedPotential b R u = u^((3:ℝ)/2) := by + unfold observedPotential + rw [abs_of_nonneg hu,max_eq_left hb,min_eq_left] + apply Real.rpow_le_rpow hu _ (by norm_num) + linarith + +lemma observedPotential_lower_start {b R z : ℝ} (hb : 0 ≤ b) (hz : |z| ≤ b) (hR : b ≤ R) : + observedPotential b R z = b^((3:ℝ)/2) := by + unfold observedPotential + rw [max_eq_right hz,min_eq_left] + apply Real.rpow_le_rpow hb _ (by norm_num) + linarith + +lemma observedPotential_scaled_clip {b R u z : ℝ} (hu : 0 < u) (hR : u ≤ R) : + u^((3:ℝ)/2)*min (|z/u|^((3:ℝ)/2)) ((2:ℝ)^((3:ℝ)/2)) ≤ + observedPotential b R z := by + have hp : 0 ≤ u^((3:ℝ)/2) := Real.rpow_nonneg hu.le _ + rw [mul_min_of_nonneg _ _ hp] + apply min_le_min + · rw [abs_div,abs_of_pos hu,Real.div_rpow (abs_nonneg _) hu.le] + have hn := ne_of_gt (Real.rpow_pos_of_pos hu ((3:ℝ)/2)) + rw [mul_div_cancel₀ _ hn] + exact Real.rpow_le_rpow (abs_nonneg _) (le_max_left _ _) (by norm_num) + · rw [← Real.mul_rpow hu.le (by norm_num)] + apply Real.rpow_le_rpow (by positivity) _ (by norm_num) + linarith + +lemma observedPotential_lower_gain {b R z : ℝ} (hb : 0 ≤ b) (hR : b ≤ R) (hz : 2*b ≤ |z|) : + (2*b)^((3:ℝ)/2) ≤ observedPotential b R z := by + apply le_min + · exact Real.rpow_le_rpow (by positivity) (hz.trans (le_max_left _ _)) (by norm_num) + · exact Real.rpow_le_rpow (by positivity) (by linarith) (by norm_num) + +lemma observedPotential_above_floor {b R z : ℝ} (hb : 0 ≤ b) (hR : b ≤ R) : + b^((3:ℝ)/2) ≤ observedPotential b R z := by + apply le_min + · exact Real.rpow_le_rpow hb (le_max_right _ _) (by norm_num) + · exact Real.rpow_le_rpow hb (by linarith) (by norm_num) + +lemma boundaryData_endpoints {d : ℕ} (ℓ : Vector d) (H : ℝ) (P : Path d × Path d) : + (boundaryData ℓ H P).endpoints = + (P.1 (boundaryTimes ℓ H P).1,P.2 (boundaryTimes ℓ H P).2) := by + simp [boundaryData,BoundaryData.endpoints,pairPrefix,extendPrefix_apply] + +lemma selectedBoundaryData_endpoints {d : ℕ} (ℓ : Vector d) + (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) : + (selectedBoundaryData ℓ B P).endpoints = + (P.1 (selectedBoundaryTimes ℓ B P).1,P.2 (selectedBoundaryTimes ℓ B P).2) := by + simp [selectedBoundaryData,BoundaryData.endpoints,pairPrefix,extendPrefix_apply] + +theorem shared_boundary_potential_drift {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {t : ℝ} (ht : 0 physicalFirstHitGap ℓ f x y + (H+commonOffset ℓ (signedHeight e) (signedHeight e x+H) P) P + have hZ : Measurable Z := measurable_physicalFirstHitGap_random ℓ f x y + (fun P => H+commonOffset ℓ (signedHeight e) (signedHeight e x+H) P) + (measurable_const.add (measurable_commonOffset _ _ _)) + have hcl : Integrable (fun P => min (|Z P/u|^((3:ℝ)/2)) ((2:ℝ)^((3:ℝ)/2))) Q := by + apply Integrable.of_bound (by fun_prop (disch := norm_num)) ((2:ℝ)^((3:ℝ)/2)) + exact Eventually.of_forall fun P => by + rw [Real.norm_eq_abs,abs_of_nonneg (le_min (Real.rpow_nonneg (abs_nonneg _) _) (by positivity))] + exact min_le_right _ _ + have hbound := integral_mono_ae (hcl.const_mul (u^((3:ℝ)/2))) + (integrable_observedPotential Q Z hZ b R (hupos.le.trans hR)) + (Eventually.of_forall fun P => observedPotential_scaled_clip hupos hR (z := Z P) (b := b)) + rw [integral_const_mul] at hbound + have hidentity : (fun P => observedPotential b R + (signedCoordinate f ((boundaryData ℓ ((signedHeight e x+H:ℤ):ℝ) P).endpoints.1- + (boundaryData ℓ ((signedHeight e x+H:ℤ):ℝ) P).endpoints.2))) =ᵐ[Q] + (fun P => observedPotential b R (Z P)) := by + filter_upwards [sharedConditioned_regularPath ν ℓ htrans x y, + shared_common_boundary_exists ν hue ℓ (signed_direction_unit e) htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) x y hxy H] with P hP hC + rw [boundaryData_endpoints,boundaryTimes_firstHit_identity e f x y hxy H hHpos P hP.1 hP.2 hC] + rw [integral_congr_ae hidentity] + have hmult := mul_le_mul_of_nonneg_left hd (Real.rpow_nonneg hupos.le ((3:ℝ)/2)) + change u^((3:ℝ)/2)*(1+t/(128*commonMeanWidth ν ℓ)) ≤ _ at hmult + nlinarith [hmult.trans hbound] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ObserverAlmostSure.lean b/lean/OAI/Probability/Ballisticity/Estimates/ObserverAlmostSure.lean new file mode 100644 index 0000000000000000000000000000000000000000..af8bfc3982d72623358f14c7e5ae49040444c201 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ObserverAlmostSure.lean @@ -0,0 +1,170 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.CommonCutCounting + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma restart_preserves_ae {Ω I : Type*} [MeasurableSpace Ω] + (μ : I → Measure Ω) (state : Ω → I) (next : Ω → Ω) (good : I → Prop) + (hn : Measurable next) + (hrestart : ∀ i, good i → ∀ g : Ω → ℝ≥0∞, Measurable g → + (∫⁻ ω, g (next ω) ∂μ i) = ∫⁻ ω, (∫⁻ η, g η ∂μ (state (next ω))) ∂μ i) + (hgood : ∀ i, good i → ∀ᵐ ω ∂μ i, good (state (next ω))) + (A : Set Ω) (hA : MeasurableSet A) + (hprob : ∀ i, good i → ∀ᵐ ω ∂μ i, ω ∈ A) (i : I) (hi : good i) : + ∀ᵐ ω ∂μ i, next ω ∈ A := by + apply (ae_map_iff hn.aemeasurable hA).mp + change ∀ᵐ y ∂(μ i).map next, y ∈ A + rw [ae_iff] + change (μ i).map next Aᶜ=0 + rw [← lintegral_indicator_one hA.compl] + change (∫⁻ a, Aᶜ.indicator (fun _ => (1:ℝ≥0∞)) a ∂(μ i).map next)=0 + rw [lintegral_map (measurable_const.indicator hA.compl) hn, + hrestart i hi _ (measurable_const.indicator hA.compl)] + apply (lintegral_congr_ae ?_).trans lintegral_zero + filter_upwards [hgood i hi] with ω hω + rw [lintegral_indicator_const hA.compl,one_mul] + exact ae_iff.mp (hprob _ hω) + +lemma restart_iteration_ae {Ω I : Type*} [MeasurableSpace Ω] + (μ : I → Measure Ω) (state : Ω → I) (next : Ω → Ω) (good : I → Prop) + (hn : Measurable next) + (hrestart : ∀ i, good i → ∀ g : Ω → ℝ≥0∞, Measurable g → + (∫⁻ ω, g (next ω) ∂μ i) = ∫⁻ ω, (∫⁻ η, g η ∂μ (state (next ω))) ∂μ i) + (hgood : ∀ i, good i → ∀ᵐ ω ∂μ i, good (state (next ω))) + (A : Set Ω) (hA : MeasurableSet A) + (hprob : ∀ i, good i → ∀ᵐ ω ∂μ i, ω ∈ A) (N : ℕ) (i : I) (hi : good i) : + ∀ᵐ ω ∂μ i, next^[N] ω ∈ A := by + induction N generalizing i with + | zero => exact hprob i hi + | succ N ih => + simpa only [Function.iterate_succ_apply, Set.mem_preimage] using + restart_preserves_ae μ state next good hn hrestart hgood + ((next^[N]) ⁻¹' A) (hA.preimage (hn.iterate N)) ih i hi + +lemma measurableSet_countable_chosen {Ω I : Type*} [MeasurableSpace Ω] + [MeasurableSpace I] [Countable I] [MeasurableSingletonClass I] + (state : Ω → I) (hs : Measurable state) (A : I → Set Ω) (hA : ∀ i, MeasurableSet (A i)) : + MeasurableSet {ω | ω ∈ A (state ω)} := by + have he : {ω | ω ∈ A (state ω)} = ⋃ i, state ⁻¹' {i} ∩ A i := by + ext ω + simp only [Set.mem_iUnion,Set.mem_inter_iff,Set.mem_preimage,Set.mem_singleton_iff,Set.mem_ofPred_eq] + constructor + · intro h; exact ⟨state ω,rfl,h⟩ + · rintro ⟨i,hi,h⟩; rwa [hi] + rw [he] + exact MeasurableSet.iUnion fun i => ((measurableSet_singleton i).preimage hs).inter (hA i) + +lemma measurableSet_validObservation {d : ℕ} (e f : Direction d) (b R : ℝ) + (K : ℕ) (k : ℝ → ℕ) : MeasurableSet {P | ValidObservation e f b R K k P} := by + let ℓ := realPosition (step e) + have hND : MeasurableSet {X : Path d | X ∈ NoDrop ℓ (X 0)} := by + simpa only [NoDrop,FutureNoDrop,Set.mem_ofPred_eq,Nat.zero_add] using + (measurableSet_futureNoDrop ℓ 0) + have hNN : MeasurableSet {X : Path d | ∀ n, ∃ g, X (n+1)=X n+step g} := by + simp only [Set.ofPred_forall,Set.ofPred_exists] + exact MeasurableSet.iInter fun n => MeasurableSet.iUnion fun g => + measurableSet_eq_fun (measurable_pi_apply _) ((measurable_pi_apply _).add_const _) + have hsex : MeasurableSet {P : Path d × Path d | ∃ n m, + selectedBoundaryAt ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P n m} := by + apply measurableSet_countable_chosen pairOrigin measurable_pairOrigin + (fun i => {P | ∃ n m, selectedBoundaryAt ℓ (observedAdvanceRule e f b K k i) P n m}) + intro i + simp only [Set.ofPred_exists] + exact MeasurableSet.iUnion fun n => MeasurableSet.iUnion fun m => + selectedMeasurableSet_boundaryAt ℓ (observedAdvanceRule e f b K k i) n m + have hss : MeasurableSet {P : Path d × Path d | + selectedBoundaryAt ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P + (selectedBoundaryTimes ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P).1 + (selectedBoundaryTimes ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P).2} := by + convert hsex using 1 + ext P + constructor + · intro h; exact ⟨_,_,h⟩ + · exact selectedBoundaryTimes_spec ℓ _ P + have hact : MeasurableSet {P : Path d × Path d | pairGap f (pairOrigin P) < R} := + measurableSet_lt ((measurable_of_countable (pairGap f)).comp measurable_pairOrigin) measurable_const + have hlast : MeasurableSet {P : Path d × Path d | pairGap f (pairOrigin P) < R → + selectedBoundaryAt ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P + (selectedBoundaryTimes ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P).1 + (selectedBoundaryTimes ℓ (observedAdvanceRule e f b K k (pairOrigin P)) P).2} := by + convert hact.compl.union hss using 1 + ext P + change (_ → _) ↔ (¬_ ∨ _) + exact imp_iff_not_or + exact (measurableSet_eq_fun + ((measurable_of_countable (signedHeight e)).comp ((measurable_pi_apply 0).comp measurable_fst)) + ((measurable_of_countable (signedHeight e)).comp ((measurable_pi_apply 0).comp measurable_snd))).inter + ((hND.preimage measurable_fst).inter ((hND.preimage measurable_snd).inter + ((hNN.preimage measurable_fst).inter ((hNN.preimage measurable_snd).inter hlast)))) + +lemma validObservation_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (b R : ℝ) (K : ℕ) (k : ℝ → ℕ) + (hK : ∀ i : Lattice d × Lattice d, signedHeight e i.1=signedHeight e i.2 → + pairGap f i < R → 0 < observedAdvanceBound f b K k i) + (i : Lattice d × Lattice d) (hi : signedHeight e i.1=signedHeight e i.2) : + ∀ᵐ P ∂sharedConditionedPairLaw ν (realPosition (step e)) i.1 i.2, + ValidObservation e f b R K k P := by + let ℓ := realPosition (step e) + have hp : ∀ᵐ P ∂sharedConditionedPairLaw ν ℓ i.1 i.2, + pairGap f i < R → selectedBoundaryAt ℓ (observedAdvanceRule e f b K k i) P + (selectedBoundaryTimes ℓ (observedAdvanceRule e f b K k i) P).1 + (selectedBoundaryTimes ℓ (observedAdvanceRule e f b K k i) P).2 := by + by_cases ha : pairGap f i < R + · exact (shared_selectedBoundaryTimes_spec ν hue ℓ (signed_direction_unit e) htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) + i.1 i.2 hi _ (hK i hi ha) _ (observedAdvanceRule_height e f b K k i)).mono fun P hP _ => hP + · exact Eventually.of_forall fun _ h => (ha h).elim + filter_upwards [sharedConditioned_regularPath ν ℓ htrans i.1 i.2,hp] with P hP hsel + have ho : pairOrigin P=i := Prod.ext hP.1.1.1 hP.2.1.1 + refine ⟨by simpa only [hP.1.1.1,hP.2.1.1] using hi, + by simpa only [hP.1.1.1] using hP.1.2, + by simpa only [hP.2.1.1] using hP.2.2,hP.1.1.2.1,hP.2.1.2.1,?_⟩ + simpa only [ho] using hsel + +theorem validObservation_iterates_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (b R : ℝ) (K : ℕ) (k : ℝ → ℕ) + (hK : ∀ i : Lattice d × Lattice d, signedHeight e i.1=signedHeight e i.2 → + pairGap f i < R → 0 < observedAdvanceBound f b K k i) + (i : Lattice d × Lattice d) (hi : signedHeight e i.1=signedHeight e i.2) : + ∀ᵐ P ∂sharedConditionedPairLaw ν (realPosition (step e)) i.1 i.2, + ∀ N, ValidObservation e f b R K k + ((commonCutObserver (realPosition (step e)) (fun j => pairGap f j < R) + (observedAdvanceRule e f b K k))^[N] P) := by + let ℓ := realPosition (step e) + let μ := fun j : Lattice d × Lattice d => sharedConditionedPairLaw ν ℓ j.1 j.2 + let active := fun j => pairGap f j < R + let B := observedAdvanceRule e f b K k + let next := commonCutObserver ℓ active B + let K' := observedAdvanceBound f b K k + have hB : ∀ j, active j → ∀ z w, signedHeight e j.1+K' j ≤ signedHeight e z → B j (z,w) := + fun j _ => observedAdvanceRule_height e f b K k j + apply ae_all_iff.mpr + intro N + exact restart_iteration_ae μ pairOrigin next + (fun j => signedHeight e j.1=signedHeight e j.2) + (measurable_commonCutObserver ℓ active B) + (fun j hj g hg => commonCutObserver_restart ν hue e htrans active B K' hK hB j hj g hg) + (fun j hj => commonCutObserver_sameHeight ν hue e htrans active B K' hK hB j hj) + {P | ValidObservation e f b R K k P} (measurableSet_validObservation e f b R K k) + (validObservation_ae ν hue e f htrans b R K k hK) N i hi + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OccupationAlgebra.lean b/lean/OAI/Probability/Ballisticity/Estimates/OccupationAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..405c8139768acc9e751761e281468cc69ccb8688 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OccupationAlgebra.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma occupation_scale_factor {nᵤ nᵣ D u r a : ℝ} (hu : 0 < u) (hr : 0 < r) + (hD : 0 ≤ D) (hn : 0 ≤ nᵣ) (hua : u ≤ a*r) + (hcomp : nᵤ ≤ D*nᵣ*(u/r)^((7:ℝ)/4)) : + nᵤ ≤ (D*nᵣ/r^((3:ℝ)/2))*a^((1:ℝ)/4)*u^((3:ℝ)/2) := by + have he : (u/r)^((7:ℝ)/4) = (u/r)^((3:ℝ)/2)*(u/r)^((1:ℝ)/4) := by + rw [← Real.rpow_add (div_pos hu hr)] + norm_num + have hrat : u/r ≤ a := (div_le_iff₀ hr).mpr hua + have hm := Real.rpow_le_rpow (div_nonneg hu.le hr.le) hrat (by norm_num : (0:ℝ) ≤ 1/4) + calc + nᵤ ≤ D*nᵣ*((u/r)^((3:ℝ)/2)*(u/r)^((1:ℝ)/4)) := by simpa only [he] using hcomp + _ ≤ D*nᵣ*((u/r)^((3:ℝ)/2)*a^((1:ℝ)/4)) := by gcongr + _ = _ := by rw [Real.div_rpow hu.le hr.le]; ring + +lemma three_halves_double_factor {b : ℝ} (hb : 0 ≤ b) : + (2*b)^((3:ℝ)/2)-b^((3:ℝ)/2) = ((2:ℝ)^((3:ℝ)/2)-1)*b^((3:ℝ)/2) := by + rw [Real.mul_rpow (by norm_num) hb] + ring + +lemma three_halves_double_pos : 0 < (2:ℝ)^((3:ℝ)/2)-1 := by + have h := Real.one_lt_rpow (by norm_num : (1:ℝ) < 2) (by norm_num : (0:ℝ) < 3/2) + linarith + +noncomputable def occupationCoefficient (J C q M b r ρ A δ : ℝ) : ℝ := + C*J*(b/r)^((1:ℝ)/4)/(q*((2:ℝ)^((3:ℝ)/2)-1)) + + M*J*(2*ρ)^((1:ℝ)/4) + M*J*A^((1:ℝ)/4)*δ + +lemma occupationCoefficient_nonneg {J C q M b r ρ A δ : ℝ} + (hJ : 0 ≤ J) (hC : 0 ≤ C) (hq : 0 < q) (hM : 0 ≤ M) + (hb : 0 ≤ b) (hr : 0 ≤ r) (hρ : 0 ≤ ρ) (hA : 0 ≤ A) (hδ : 0 ≤ δ) : + 0 ≤ occupationCoefficient J C q M b r ρ A δ := by + unfold occupationCoefficient + have hp := three_halves_double_pos + positivity + +lemma occupationCoefficient_lower {J C q M b r ρ A δ z : ℝ} + (hJ : 0 ≤ J) (hC : 0 ≤ C) (hq : 0 < q) (hM : 0 ≤ M) + (hb : 0 ≤ b) (hr : 0 ≤ r) (hρ : 0 ≤ ρ) (hA : 0 ≤ A) (hδ : 0 ≤ δ) + (hz : z ≤ C*J*(b/r)^((1:ℝ)/4)*b^((3:ℝ)/2)) : + z ≤ occupationCoefficient J C q M b r ρ A δ* + (q*((2*b)^((3:ℝ)/2)-b^((3:ℝ)/2))) := by + have hden : 0 < q*((2:ℝ)^((3:ℝ)/2)-1) := mul_pos hq three_halves_double_pos + have hrest : 0 ≤ M*J*(2*ρ)^((1:ℝ)/4)+M*J*A^((1:ℝ)/4)*δ := by positivity + have hp : 0 ≤ b^((3:ℝ)/2) := Real.rpow_nonneg hb _ + rw [three_halves_double_factor hb] + apply hz.trans + have hcoefficient : C*J*(b/r)^((1:ℝ)/4)/(q*((2:ℝ)^((3:ℝ)/2)-1)) ≤ + occupationCoefficient J C q M b r ρ A δ := by + unfold occupationCoefficient + linarith + have hm := mul_le_mul hcoefficient (le_refl (q*((2:ℝ)^((3:ℝ)/2)-1)*b^((3:ℝ)/2))) + (mul_nonneg hden.le hp) (occupationCoefficient_nonneg hJ hC hq hM hb hr hρ hA hδ) + rw [← mul_assoc, div_mul_cancel₀ _ hden.ne'] at hm + simpa only [mul_assoc] using hm + +lemma occupationCoefficient_upper {J C q M b r ρ A δ t u v : ℝ} + (hJ : 0 ≤ J) (hC : 0 ≤ C) (hq : 0 < q) (hM : 0 < M) + (hb : 0 ≤ b) (hr : 0 ≤ r) (hρ : 0 ≤ ρ) (hA : 0 ≤ A) (hδ : 0 ≤ δ) + (ht : 0 ≤ t) (hu : 0 ≤ u) + (hv : v ≤ t*J*(2*ρ)^((1:ℝ)/4)*u^((3:ℝ)/2)) : + v ≤ occupationCoefficient J C q M b r ρ A δ*(t/M*u^((3:ℝ)/2)) := by + have hfirst : 0 ≤ C*J*(b/r)^((1:ℝ)/4)/(q*((2:ℝ)^((3:ℝ)/2)-1)) := by + have hp := three_halves_double_pos + positivity + have hlast : 0 ≤ M*J*A^((1:ℝ)/4)*δ := by positivity + have hcoef : M*J*(2*ρ)^((1:ℝ)/4) ≤ occupationCoefficient J C q M b r ρ A δ := by + unfold occupationCoefficient + linarith + have hm := mul_le_mul hcoef (le_refl (t/M*u^((3:ℝ)/2))) + (by positivity) (occupationCoefficient_nonneg hJ hC hq hM.le hb hr hρ hA hδ) + apply hv.trans + convert hm using 1 + field_simp + +lemma occupationCoefficient_far {J C q M b r ρ A δ t u v : ℝ} + (hJ : 0 ≤ J) (hC : 0 ≤ C) (hq : 0 < q) (hM : 0 < M) + (hb : 0 ≤ b) (hr : 0 ≤ r) (hρ : 0 ≤ ρ) (hA : 0 ≤ A) (hδ : 0 ≤ δ) + (ht : 0 ≤ t) (hu : 0 ≤ u) + (hv : v ≤ t*J*A^((1:ℝ)/4)*u^((3:ℝ)/2)*δ) : + v ≤ occupationCoefficient J C q M b r ρ A δ*(t/M*u^((3:ℝ)/2)) := by + have hfirst : 0 ≤ C*J*(b/r)^((1:ℝ)/4)/(q*((2:ℝ)^((3:ℝ)/2)-1)) := by + have hp := three_halves_double_pos + positivity + have hnear : 0 ≤ M*J*(2*ρ)^((1:ℝ)/4) := by positivity + have hcoef : M*J*A^((1:ℝ)/4)*δ ≤ occupationCoefficient J C q M b r ρ A δ := by + unfold occupationCoefficient + linarith + have hm := mul_le_mul hcoef (le_refl (t/M*u^((3:ℝ)/2))) + (by positivity) (occupationCoefficient_nonneg hJ hC hq hM.le hb hr hρ hA hδ) + apply hv.trans + convert hm using 1 + field_simp + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OccupationLimit.lean b/lean/OAI/Probability/Ballisticity/Estimates/OccupationLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..af837d250140f472051c550971e556d72d225b70 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OccupationLimit.lean @@ -0,0 +1,246 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.OccupationCutoffs +import OAI.Probability.Ballisticity.Crossings.PhysicalExit +import OAI.Probability.Ballisticity.Estimates.AllLayerOccupation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +noncomputable def firstHitOccupationMean {d : ℕ} (ν : Measure (Row d)) (e f : Direction d) + (x y : Lattice d) (s : ℝ) (H : ℕ) : ℝ := + ∑ j ∈ Finset.range H, (sharedConditionedPairLaw ν (realPosition (step e)) x y).real + {P | |physicalFirstHitGap (realPosition (step e)) f x y j P| ≤ s} + +lemma firstHitOccupationMean_nonneg {d : ℕ} (ν : Measure (Row d)) (e f : Direction d) + (x y : Lattice d) (s : ℝ) (H : ℕ) : 0 ≤ firstHitOccupationMean ν e f x y s H := + Finset.sum_nonneg fun _ _ => measureReal_nonneg + +theorem occupation_fixed_parameters {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x : ℕ → Lattice d) {T A t ρ : ℝ} (hT : 0 < T) (hA : 1 ≤ A) + (ht : 0 < t) (htmax : t ≤ 1/1000000) (hρ : 0 < ρ) + {c : ℝ≥0∞} (hc : 0 < c) (hcu : ∀ u v, c ≤ sharedNoDropMass ν (realPosition (step e)) u v) + {η : ℝ} (hη : 0 < η) : + let ℓ := realPosition (step e) + let m := commonMeanWidth ν ℓ + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + ∀ᶠ i in atTop, firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (⌊T*n i⌋₊+1)/n i ≤ + (occupationMacroConstant A*((128*m)*(2*ρ)^((1:ℝ)/4)+ + (128*m)*A^((1:ℝ)/4)*(8*Real.exp (-m/(16*t))))+ + T*(8*Real.exp (-m*A^2/(4*T))))/c.toReal+η := by + dsimp only + let ℓ := realPosition (step e) + let m := commonMeanWidth ν ℓ + let M := 128*m + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let H := fun i => ⌊T*n i⌋₊+1 + let δ := 8*Real.exp (-m/(16*t)) + let a := 8*Real.exp (-m*A^2/(4*T)) + let μ := fun i => sharedConditionedPairLaw ν ℓ (x i) (x i) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => sharedConditionedPairLaw_probability ν ℓ (x i) (x i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (x i))) + have hcfin : c ≠ ⊤ := ne_top_of_le_ne_top + (show sharedNoDropMass ν ℓ 0 0 ≠ ⊤ from ne_top_of_le_ne_top (by simp) + (show sharedNoDropMass ν ℓ 0 0 ≤ 1 from sharedNoDropMass_le_one ν ℓ 0 0)) (hcu 0 0) + have hcr : 0 < c.toReal := ENNReal.toReal_pos hc.ne' hcfin + obtain ⟨D⟩ := exists_occupationData ν hue e f hef htrans ht htmax + obtain ⟨b,K,hb,hb0,hgood,hK⟩ := occupation_cutoff_escape ν hue e f hef htrans D A r hr + have hm : 0 < m := zero_lt_one.trans_le (commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e)) + have hM : 0 < M := by dsimp [M]; positivity + have ha : 0 < a := by dsimp [a]; positivity + have hδ : 0 ≤ δ := by dsimp [δ]; positivity + have hA0 : 0 < A := zero_lt_one.trans_le hA + let C := D.C/(D.q*((2:ℝ)^((3:ℝ)/2)-1)) + let L := occupationMacroConstant A*(M*(2*ρ)^((1:ℝ)/4)+M*A^((1:ℝ)/4)*δ)+T*a + let B := fun i => 1/n i + (occupationMacroConstant A*(C*(b i/r i)^((1:ℝ)/4)+ + M*(2*ρ)^((1:ℝ)/4)+M*A^((1:ℝ)/4)*δ)+(T+1/n i)*a)/c.toReal + have hnInf := recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1 + have hinv : Tendsto (fun i => 1/n i) atTop (𝓝 0) := by + convert tendsto_inv_atTop_zero.comp hnInf using 1 + simp only [Function.comp_def,n,ℓ,one_div] + have hpow : Tendsto (fun i => (b i/r i)^((1:ℝ)/4)) atTop (𝓝 0) := by + simpa only [Real.zero_rpow (by norm_num : (1:ℝ)/4 ≠ 0)] using + hb0.rpow_const (Or.inr (by norm_num : (0:ℝ) ≤ 1/4)) + have hB : Tendsto B atTop (𝓝 (L/c.toReal)) := by + have hh : Tendsto B atTop (𝓝 (0+(occupationMacroConstant A*(C*0+M*(2*ρ)^((1:ℝ)/4)+ + M*A^((1:ℝ)/4)*δ)+(T+0)*a)/c.toReal)) := hinv.add (((tendsto_const_nhds.mul (((tendsto_const_nhds.mul hpow).add tendsto_const_nhds).add + tendsto_const_nhds)).add (((tendsto_const_nhds.add hinv).mul tendsto_const_nhds))).div_const c.toReal) + simpa only [mul_zero,zero_add,add_zero] using hh + have hless := hB.eventually_lt_const (show L/c.toReal < L/c.toReal+η by linarith) + have hexit := shared_physical_exit_gaussian ν hue e f hef htrans r hr x hT hA0 + filter_upwards [hless,hexit,hr.1.eventually_gt_atTop 0, + hb0.eventually_lt_const (by norm_num : (0:ℝ)<1), + hb0.eventually_lt_const (mul_pos (by norm_num : (0:ℝ)<2) hρ)] with i hBi hei hri hbri hbs + have hni : 0 < n i := recordFluctuationScale_pos ν hue e f hef htrans hri + have hbpos : 0 < b i := D.u₀_pos.trans_le (hb i) + have hbr : b i ≤ r i := by exact (div_lt_one hri).mp hbri |>.le + have hbs' : b i ≤ 2*(ρ*r i) := by + have hh := (div_lt_iff₀ hri).mp hbs + nlinarith + let J := max ((2:ℝ)^((7:ℝ)/4)) (A^2)*n i/(r i)^((3:ℝ)/2) + let V := occupationCoefficient J D.C D.q M (b i) (r i) ρ A δ*(2*(A*r i))^((3:ℝ)/2) + have hJ : 0 ≤ J := div_nonneg (mul_nonneg ((sq_nonneg A).trans (le_max_right _ _)) hni.le) + (Real.rpow_nonneg hri.le _) + have hV : 0 ≤ V := mul_nonneg + (occupationCoefficient_nonneg hJ D.C_pos.le D.q_pos hM.le hbpos.le hri.le hρ.le hA0.le hδ) + (Real.rpow_nonneg (by positivity) _) + have hfinite := occupation_finite_bound ν hue e f hef htrans ht D (hb i) hbr hρ.le hA + hbs' (hgood i) (K i) (hK i).1 (hK i).2.1 (hK i).2.2 (H i) (x i,x i) rfl + dsimp only at hfinite + rw [smallCommonCount_lintegral ν e f htrans (x i) (x i) (ρ*r i) (H i)] at hfinite + have hreal := real_sum_le_of_ennreal_count (μ := μ i) + (fun j => SmallCommonLayer e f (ρ*r i) (signedHeight e (x i)+j)) (H i) V + (PhysicalGapExit e f (A*r i) (H i) (x i,x i)) hV hfinite + have hall := all_layers_occupation_le ν hue e f htrans (x i) (x i) rfl (ρ*r i) (H i) c hcu + rw [smallCommonCount_lintegral ν e f htrans (x i) (x i) (ρ*r i) (H i)] at hall + have hallr := real_all_layer_bound (μ := μ i) _ _ (H i) hcfin hall + have htotal : c.toReal*firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (H i) ≤ + c.toReal+V+(H i:ℝ)*a := by + have hh := mul_le_mul_of_nonneg_left hei (Nat.cast_nonneg (H i)) + dsimp only [firstHitOccupationMean] + linarith + have hH : (H i:ℝ)/n i ≤ T+1/n i := by + have hh := Nat.floor_le (mul_nonneg hT.le hni.le) + dsimp only [H] + rw [Nat.cast_add,Nat.cast_one] + apply (div_le_iff₀ hni).mpr + field_simp + nlinarith + have hnorm := occupation_coefficient_normalization hri hni hA0.le D.C D.q M (b i) ρ δ + have hbound : firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (H i)/n i ≤ B i := by + have hh := (div_le_div_iff_of_pos_right hni).mpr htotal + have he : (c.toReal+V+(H i:ℝ)*a)/n i=c.toReal/n i+V/n i+((H i:ℝ)/n i)*a := by ring + rw [he] at hh + have hu := mul_le_mul_of_nonneg_right hH ha.le + have hVN : V/n i=occupationMacroConstant A*(C*(b i/r i)^((1:ℝ)/4)+ + M*(2*ρ)^((1:ℝ)/4)+M*A^((1:ℝ)/4)*δ) := by + simpa only [V,J,C,div_eq_mul_inv,mul_assoc,mul_comm,mul_left_comm] using hnorm + rw [hVN] at hh + dsimp only [B] + have hh' := hh.trans (add_le_add_right hu _) + have heq : c.toReal * (firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (H i)/n i) = + c.toReal * firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (H i)/n i := by ring + have hdiv : c.toReal * ((occupationMacroConstant A * + (C*(b i/r i)^((1:ℝ)/4)+M*(2*ρ)^((1:ℝ)/4)+M*A^((1:ℝ)/4)*δ)+(T+1/n i)*a)/c.toReal) = + occupationMacroConstant A * + (C*(b i/r i)^((1:ℝ)/4)+M*(2*ρ)^((1:ℝ)/4)+M*A^((1:ℝ)/4)*δ)+(T+1/n i)*a := + mul_div_cancel₀ _ hcr.ne' + have hcdiv : c.toReal/n i = c.toReal*(1/n i) := by ring + nlinarith only [hh',heq,hdiv,hcdiv,hcr] + exact hbound.trans hBi.le + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma occupation_parameter_choice {m T c ε : ℝ} (hm : 0 < m) (hT : 0 < T) + (hc : 0 < c) (hε : 0 < ε) : + ∃ A t ρ : ℝ, 1 ≤ A ∧ 0 < t ∧ t ≤ 1/1000000 ∧ 0 < ρ ∧ + (occupationMacroConstant A*((128*m)*(2*ρ)^((1:ℝ)/4)+ + (128*m)*A^((1:ℝ)/4)*(8*Real.exp (-m/(16*t))))+ + T*(8*Real.exp (-m*A^2/(4*T))))/c < ε := by + have hcoef : 0 < m/(4*T) := by positivity + have hexp : Tendsto (fun A : ℝ => Real.exp (-m*A^2/(4*T))) atTop (𝓝 0) := by + have hh := Real.tendsto_exp_atBot.comp + (tendsto_neg_atTop_atBot.comp ((tendsto_pow_atTop (by norm_num : (2:ℕ) ≠ 0)).const_mul_atTop hcoef)) + convert hh using 1 + funext A + simp only [Function.comp_apply] + congr 1 + ring + have hex : ∀ᶠ A : ℝ in atTop, T*(8*Real.exp (-m*A^2/(4*T))) < ε*c/3 := by + have hh : Tendsto (fun A : ℝ => T*(8*Real.exp (-m*A^2/(4*T)))) atTop (𝓝 0) := by + simpa only [mul_zero] using hexp.const_mul 8 |>.const_mul T + exact hh.eventually_lt_const (by positivity) + obtain ⟨A,hA,ha⟩ := ((eventually_ge_atTop (1:ℝ)).and hex).exists + let K := occupationMacroConstant A + let M := 128*m + have htlim : Tendsto (fun z : ℝ => K*(M*A^((1:ℝ)/4)*(8*Real.exp (-m*z/16)))) atTop (𝓝 0) := by + have he : Tendsto (fun z : ℝ => Real.exp (-m*z/16)) atTop (𝓝 0) := by + have hh := Real.tendsto_exp_atBot.comp + (tendsto_neg_atTop_atBot.comp (tendsto_id.const_mul_atTop (by positivity : 0 < m/16))) + convert hh using 1 + funext z + simp only [Function.comp_apply,id_eq] + congr 1 + ring + simpa only [mul_zero] using (he.const_mul 8).const_mul (M*A^((1:ℝ)/4)) |>.const_mul K + obtain ⟨z,hz,hzsmall⟩ := ((eventually_ge_atTop (1000000:ℝ)).and + (htlim.eventually_lt_const (show 0 < ε*c/3 by positivity))).exists + have hzpos : 0 < z := lt_of_lt_of_le (by norm_num) hz + let t := 1/z + have ht : 0 < t := one_div_pos.mpr hzpos + have htmax : t ≤ 1/1000000 := one_div_le_one_div_of_le (by norm_num) hz + have htterm : K*(M*A^((1:ℝ)/4)*(8*Real.exp (-m/(16*t)))) < ε*c/3 := by + have heq : -m/(16*t) = -m*z/16 := by + dsimp [t] + field_simp + rw [heq] + exact hzsmall + have hrpow : Tendsto (fun z : ℝ => (2*(1/z))^((1:ℝ)/4)) atTop (𝓝 0) := by + have hi : Tendsto (fun z : ℝ => 2*(1/z)) atTop (𝓝 0) := by + simpa only [one_div,mul_zero] using (tendsto_inv_atTop_zero (𝕜 := ℝ)).const_mul 2 + simpa only [Real.zero_rpow (by norm_num : (1:ℝ)/4 ≠ 0)] using + hi.rpow_const (Or.inr (by norm_num : (0:ℝ) ≤ 1/4)) + have hrholim : Tendsto (fun z : ℝ => K*(M*(2*(1/z))^((1:ℝ)/4))) atTop (𝓝 0) := by + simpa only [mul_zero] using (hrpow.const_mul M).const_mul K + obtain ⟨w,hw,hwsmall⟩ := ((eventually_gt_atTop (0:ℝ)).and + (hrholim.eventually_lt_const (show 0 < ε*c/3 by positivity))).exists + refine ⟨A,t,1/w,hA,ht,htmax,one_div_pos.mpr hw,?_⟩ + apply (div_lt_iff₀ hc).mpr + dsimp only [K,M] at htterm hwsmall + linarith + +theorem shared_first_hit_occupation_vanishes {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x : ℕ → Lattice d) {T ε : ℝ} (hT : 0 < T) (hε : 0 < ε) : + ∃ ρ : ℝ, 0 < ρ ∧ + let n := fun i => fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i) + ∀ᶠ i in atTop, firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (⌊T*n i⌋₊+1)/n i ≤ ε := by + let ℓ := realPosition (step e) + let m := commonMeanWidth ν ℓ + have hm : 0 < m := zero_lt_one.trans_le (commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e)) + obtain ⟨c,hc,hcu⟩ := sharedNoDropMass_uniform_positive ν hue ℓ (signed_direction_unit e) htrans + have hcfin : c ≠ ⊤ := ne_top_of_le_ne_top + (show sharedNoDropMass ν ℓ 0 0 ≠ ⊤ from ne_top_of_le_ne_top (by simp) + (show sharedNoDropMass ν ℓ 0 0 ≤ 1 from sharedNoDropMass_le_one ν ℓ 0 0)) (hcu 0 0) + have hcr : 0 < c.toReal := ENNReal.toReal_pos hc.ne' hcfin + obtain ⟨A,t,ρ,hA,ht,htmax,hρ,hsmall⟩ := occupation_parameter_choice hm hT hcr + (show 0 < ε/2 by positivity) + refine ⟨ρ,hρ,?_⟩ + have hb := occupation_fixed_parameters ν hue e f hef htrans r hr x hT hA ht htmax hρ + hc hcu (show 0 < ε/2 by positivity) + filter_upwards [hb] with i hi + exact hi.trans (by linarith) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OccupationParameters.lean b/lean/OAI/Probability/Ballisticity/Estimates/OccupationParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..90a0e769882e40f6fa38960df28b540a54cbf350 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OccupationParameters.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.FixedLowerCutoffEscape +import OAI.Probability.Ballisticity.Estimates.SharedShrinking +import OAI.Probability.Ballisticity.Crossings.UniformLowerCutoff +import OAI.Probability.Ballisticity.Estimates.ObservedPotential + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +structure OccupationData {d : ℕ} (ν : Measure (Row d)) (e f : Direction d) (t : ℝ) where + l : ℝ + ε : ℝ + u₀ : ℝ + C : ℝ + q : ℝ + l_pos : 0 < l + l_le_one : l ≤ 1 + ε_pos : 0 < ε + u₀_pos : 0 < u₀ + C_pos : 0 < C + q_pos : 0 < q + doubling : (2:ℝ)^((7:ℝ)/4) ≤ 4/(1+4*ε) + upper : ∀ u : ℝ, u₀ ≤ u → + fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) u* + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*u < |commonIncrementProcess (realPosition (step e)) f 0 P|} ≤ ε → + ∀ x y : Lattice d, signedHeight e x=signedHeight e y → |signedCoordinate f (x-y)|=u → + ∀ b R : ℝ, b ≤ u → u ≤ R → + let H := ⌊t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) u⌋₊ + 0 < H ∧ u^((3:ℝ)/2)+t/(128*commonMeanWidth ν (realPosition (step e)))*u^((3:ℝ)/2) ≤ + ∫ P, observedPotential b R + (signedCoordinate f ((boundaryData (realPosition (step e)) ((signedHeight e x+H:ℤ):ℝ) P).endpoints.1- + (boundaryData (realPosition (step e)) ((signedHeight e x+H:ℤ):ℝ) P).endpoints.2)) + ∂sharedConditionedPairLaw ν (realPosition (step e)) x y + shrink : ∀ u : ℝ, u₀ ≤ u → + fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) u* + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*u < |commonIncrementProcess (realPosition (step e)) f 0 P|} ≤ ε → + ∀ x y : Lattice d, signedHeight e x=signedHeight e y → |signedCoordinate f (x-y)|=u → + (sharedConditionedPairLaw ν (realPosition (step e)) x y).real + {P | ∃ h ≤ ⌊t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) u⌋₊, + |physicalFirstHitGap (realPosition (step e)) f x y h P| ≤ u/2} ≤ + 8*Real.exp (-commonMeanWidth ν (realPosition (step e))/(16*t)) + escape : ∀ b : ℝ, (b=u₀ ∨ ∃ D : ℝ, u₀ ≤ D ∧ + ε ≤ fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) D* + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*D < |commonIncrementProcess (realPosition (step e)) f 0 P|} ∧ b=4*D) → + LowerEscape ν e f b C q + +lemma exists_occupationData {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {t : ℝ} (ht : 0 < t) (htmax : t ≤ 1/1000000) : + Nonempty (OccupationData ν e f t) := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let n := fluctuationScale μ S + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + obtain ⟨l₁,ε₁,R₁,hl₁,hl₁one,hε₁,hR₁,hup⟩ := shared_boundary_potential_drift ν hue e f hef htrans ht htmax + obtain ⟨l₂,ε₂,R₂,hl₂,hl₂one,hε₂,hR₂,hshr⟩ := shared_uniform_good_shrinking ν hue e f hef htrans ht + have hpow : (2:ℝ)^((7:ℝ)/4) < 4 := by + have h := Real.rpow_lt_rpow_of_exponent_lt (by norm_num : (1:ℝ) < 2) + (by norm_num : (7:ℝ)/4 < 2) + norm_num [Real.rpow_two] at h ⊢ + exact h + let ε₀ := (4-(2:ℝ)^((7:ℝ)/4))/16 + have hε₀ : 0 < ε₀ := by dsimp [ε₀]; positivity + let l := min l₁ l₂ + let ε := min ε₁ (min ε₂ ε₀) + have hl : 0 < l := lt_min hl₁ hl₂ + have hl1 : l ≤ 1 := (min_le_left _ _).trans hl₁one.le + have hε : 0 < ε := lt_min hε₁ (lt_min hε₂ hε₀) + have hε₁' : ε ≤ ε₁ := min_le_left _ _ + have hε₂' : ε ≤ ε₂ := (min_le_right _ _).trans (min_le_left _ _) + obtain ⟨Cb,qb,D₀,hCb,hqb,hD₀,hbad⟩ := bad_radius_lower_escape_uniform ν hue e f hef htrans hl hl1 hε + let u₀ := max (max R₁ R₂) D₀ + have hu₀ : 0 < u₀ := hD₀.trans_le (le_max_right _ _) + have hR₁' : R₁ ≤ u₀ := (le_max_left _ _).trans (le_max_left _ _) + have hR₂' : R₂ ≤ u₀ := (le_max_right _ _).trans (le_max_left _ _) + obtain ⟨Cf,qf,hCf,hqf,hfixed⟩ := fixed_lower_cutoff_escape ν hue e f hef htrans hu₀ + refine ⟨{ + l := l, ε := ε, u₀ := u₀, C := max Cb Cf, q := min qb qf, + l_pos := hl, l_le_one := hl1, ε_pos := hε, u₀_pos := hu₀, + C_pos := hCb.trans_le (le_max_left _ _), q_pos := lt_min hqb hqf, + doubling := ?_, upper := ?_, shrink := ?_, escape := ?_ }⟩ + · apply (le_div_iff₀ (by positivity : (0:ℝ) < 1+4*ε)).mpr + have heps : ε ≤ ε₀ := (min_le_right _ _).trans (min_le_right _ _) + have hp : 0 ≤ (2:ℝ)^((7:ℝ)/4) := Real.rpow_nonneg (by norm_num) _ + have hh := mul_le_mul_of_nonneg_left heps hp + dsimp [ε₀] at hh + nlinarith [sq_nonneg ((2:ℝ)^((7:ℝ)/4)-4)] + · intro u hu hg x y hxy hgap b R hb hR + apply hup u (hR₁'.trans hu) _ x y hxy hgap b R hb hR + have ht' : μ.real {P | l₁*u < |S P|} ≤ μ.real {P | l*u < |S P|} := by + apply measureReal_mono _ (measure_ne_top μ _) + intro P hP + exact lt_of_le_of_lt (mul_le_mul_of_nonneg_right (min_le_left _ _) (hu₀.le.trans hu)) hP + exact (mul_le_mul_of_nonneg_left ht' (fluctuationScale_nonneg μ S u)).trans (hg.trans hε₁') + · intro u hu hg x y hxy hgap + apply hshr u (hR₂'.trans hu) _ x y hxy hgap + have ht' : μ.real {P | l₂*u < |S P|} ≤ μ.real {P | l*u < |S P|} := by + apply measureReal_mono _ (measure_ne_top μ _) + intro P hP + exact lt_of_le_of_lt (mul_le_mul_of_nonneg_right (min_le_right _ _) (hu₀.le.trans hu)) hP + exact (mul_le_mul_of_nonneg_left ht' (fluctuationScale_nonneg μ S u)).trans (hg.trans hε₂') + · intro b hb + rcases hb with rfl | ⟨D,hD,hg,rfl⟩ + · exact LowerEscape.mono hfixed (le_max_right _ _) (min_le_right _ _) + · exact (hbad D ((le_max_right _ _).trans hD) hg).mono (le_max_left _ _) (min_le_left _ _) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OccupationSampling.lean b/lean/OAI/Probability/Ballisticity/Estimates/OccupationSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d7902ef469425ca9f9b81d1f5f59d3ef6e29103 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OccupationSampling.lean @@ -0,0 +1,221 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.StationaryCompact +import OAI.Probability.Ballisticity.Estimates.SamplingLimit +import OAI.Probability.Ballisticity.Estimates.SamplingLaw + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience + +noncomputable def actualOccupationRaw {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (N : ℕ) (M : Environment d → ℕ) : Measure (ActualEpisodeArray e) := + StationaryCompact.episodeOccupationRaw N (episodeInputLaw e ν Q t ht) + (actualArrayMap e t J) (fun X => M X.1.1) StationaryCompact.shift + +instance actualOccupationRaw_finite {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (N : ℕ) (M : Environment d → ℕ) : IsFiniteMeasure (actualOccupationRaw e ν Q t J ht N M) := by + unfold actualOccupationRaw + infer_instance + +lemma actualOccupationRaw_integral {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) (F : C(ActualEpisodeArray e,ℝ)) : + (∫ Y, F Y ∂actualOccupationRaw e ν Q t J ht N M)= + ∑ i∈Finset.range N, ∫ X, F (StationaryCompact.shift^[i] (actualArrayMap e t J X)) + ∂episodeInputLaw e ν (Q.restrict {ω | i + F.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _))] + apply Finset.sum_congr rfl + intro i _ + have hm : Measurable (fun X : EpisodeInput e => StationaryCompact.shift^[i] (actualArrayMap e t J X)) := + (StationaryCompact.shift_continuous.measurable.iterate i).comp (actualArrayMap_measurable e t J ht hJ) + rw [integral_map hm.aemeasurable F.continuous.aestronglyMeasurable] + have hr : (episodeInputLaw e ν Q t ht).restrict {X | i t ω i) : + (episodeInputLaw e ν Q t ht).real Set.univ=Q.real Set.univ := by + simp [Measure.real,episodeInputLaw,Measure.prod_apply,Measure.compProd_apply, + measure_univ] + +lemma actualOccupationRaw_mass {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) : + (actualOccupationRaw e ν Q t J ht N M).real Set.univ= + ∑ i∈Finset.range N, (Q.restrict {ω | i t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (p : ℤ×ℕ) (j : ℤ) (z : HorizontalSpace e) (n : ℕ) (hn : 0 (arraySamplingError e p j z n Y)^2,by fun_prop⟩ + change (∫ Y, F Y ∂actualOccupationRaw e ν Q t J ht N M)≤_ + rw [actualOccupationRaw_integral e ν Q t J ht hJ N M hM F, + actualOccupationRaw_mass e ν Q t J ht hJ N M hM,Finset.sum_mul] + apply Finset.sum_le_sum + intro i _ + simp only [F,ContinuousMap.coe_mk,arraySamplingError_iterate] + exact actual_array_sampling_sq_law e ν (Q.restrict {ω | i t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (p q : ℤ×ℕ) (hpq : p≠q) (z : HorizontalSpace e) (g : C(ℝ,ℝ)) : + (∫ Y, g (arrayProfileTest e q.1 p z Y)* + (arrayOffsetTest e p q z Y-arrayProfileTest e q.1 p z Y) + ∂actualOccupationRaw e ν Q t J ht N M)=0 := by + let F : C(ActualEpisodeArray e,ℝ) := ⟨fun Y => g (arrayProfileTest e q.1 p z Y)* + (arrayOffsetTest e p q z Y-arrayProfileTest e q.1 p z Y), + (g.continuous.comp (arrayProfileTest e q.1 p z).continuous).mul + ((arrayOffsetTest e p q z).continuous.sub (arrayProfileTest e q.1 p z).continuous)⟩ + change (∫ Y, F Y ∂actualOccupationRaw e ν Q t J ht N M)=_ + rw [actualOccupationRaw_integral e ν Q t J ht hJ N M hM F] + apply Finset.sum_eq_zero + intro i _ + simp only [F,ContinuousMap.coe_mk,arrayProfileTest_iterate,arrayOffsetTest_iterate] + have hneq : (p.1+(i:ℤ),p.2)≠(q.1+(i:ℤ),q.2) := by + intro he + apply hpq + apply Prod.ext + · exact add_right_cancel (congrArg Prod.fst he) + · have hh := congrArg (fun r : ℤ×ℕ => r.2) he + exact hh + exact actual_array_sampling_test_law e ν (Q.restrict {ω | i t ω i) + (N : ℕ) (M : Environment d → ℕ) : ProbabilityMeasure (ActualEpisodeArray e) := by + haveI : Nonempty (Row d) := nonempty_of_isProbabilityMeasure ν + exact FiniteMeasure.normalize (⟨actualOccupationRaw e ν Q t J ht N M,inferInstance⟩ : FiniteMeasure (ActualEpisodeArray e)) + +lemma actualOccupation_integral {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (N : ℕ) (M : Environment d → ℕ) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (F : ActualEpisodeArray e → ℝ) : + (∫ Y, F Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)))= + ((actualOccupationRaw e ν Q t J ht N M).real Set.univ)⁻¹ * + ∫ Y, F Y ∂actualOccupationRaw e ν Q t J ht N M := by + have : Nonempty (Row d) := nonempty_of_isProbabilityMeasure ν + let ρ : FiniteMeasure (ActualEpisodeArray e) := ⟨actualOccupationRaw e ν Q t J ht N M,inferInstance⟩ + have hn : ρ≠0 := by + intro hz + have hh : (actualOccupationRaw e ν Q t J ht N M).real Set.univ=0 := by + change (ρ : Measure (ActualEpisodeArray e)).real Set.univ=0 + rw [hz] + simp + linarith + change (∫ Y, F Y ∂(ρ.normalize : Measure (ActualEpisodeArray e)))=_ + rw [←ρ.average_eq_integral_normalize hn,average,integral_smul_measure] + simp only [ENNReal.toReal_inv,smul_eq_mul] + rfl + +lemma actualOccupation_sampling_sq {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (p : ℤ×ℕ) (j : ℤ) (z : HorizontalSpace e) (n : ℕ) (hn : 0 t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (p q : ℤ×ℕ) (hpq : p≠q) (z : HorizontalSpace e) (g : C(ℝ,ℝ)) : + (∫ Y, g (arrayProfileTest e q.1 p z Y)* + (arrayOffsetTest e p q z Y-arrayProfileTest e q.1 p z Y) + ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)))=0 := by + rw [actualOccupation_integral e ν Q t J ht N M hpos, + actualOccupationRaw_sampling_test e ν Q t J ht hJ N M hM p q hpq z g,mul_zero] + +section WeakLimit +variable {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : ℕ → Measure (Environment d)) [∀ r, IsFiniteMeasure (Q r)] + (t J : ℕ → Environment d → ℤ → ℕ) + (ht : ∀ r i, Measurable fun ω => t r ω i) (hJ : ∀ r i, Measurable fun ω => J r ω i) + (N : ℕ → ℕ) (M : ℕ → Environment d → ℕ) (hM : ∀ r, Measurable (M r)) + (hpos : ∀ r, 0<(actualOccupationRaw e ν (Q r) (t r) (J r) (ht r) (N r) (M r)).real Set.univ) + (L : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun r => actualOccupation e ν (Q r) (t r) (J r) (ht r) (N r) (M r)) atTop (𝓝 L)) + +include hJ hM hpos hlim + +theorem actualOccupation_limit_sampling (p : ℤ×ℕ) (j : ℤ) (z : HorizontalSpace e) : + ∀ᵐ Y ∂(L : Measure (ActualEpisodeArray e)), + Tendsto (fun n => arraySamplingError e p j z (2^n) Y) atTop (𝓝 0) := by + apply Sampling.ae_sampling_of_weak_limit _ L hlim (fun n => arraySamplingError e p j z (2^n)) + (fun n => ((2:ℕ)^n:ℝ)⁻¹) + · simpa only [Nat.cast_pow,Nat.cast_ofNat,inv_pow] using + summable_geometric_of_norm_lt_one (x:=((2:ℝ)⁻¹)) (by norm_num) + · intro r n + simpa only [Nat.cast_pow,Nat.cast_ofNat] using actualOccupation_sampling_sq e ν (Q r) (t r) (J r) (ht r) (hJ r) (N r) (M r) + (hM r) (hpos r) p j z (2^n) (pow_pos (by norm_num) n) + +theorem actualOccupation_limit_zero (p q : ℤ×ℕ) (hpq : p≠q) (z : HorizontalSpace e) : + ∀ᵐ Y ∂(L : Measure (ActualEpisodeArray e)), + arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0 := by + apply Sampling.ae_zero_of_sampling_tests (arrayProfileTest e q.1 p z) (arrayOffsetTest e p q z) + (arrayProfileTest e q.1 p z).continuous.measurable (arrayOffsetTest e p q z).continuous.measurable + (arrayProfileTest_mem e q.1 p z) (arrayOffsetTest_mem e p q z) + apply Sampling.sampling_tests_weak_limit _ L hlim + intro r g + exact actualOccupation_sampling_test e ν (Q r) (t r) (J r) (ht r) (hJ r) (N r) (M r) + (hM r) (hpos r) p q hpq z g + +end WeakLimit +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OperationalLengthMarks.lean b/lean/OAI/Probability/Ballisticity/Estimates/OperationalLengthMarks.lean new file mode 100644 index 0000000000000000000000000000000000000000..13478b891a675d9f4fbb392e9c72d2f0f6b29792 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OperationalLengthMarks.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BadStageMoment +import OAI.Probability.Ballisticity.Estimates.RawDropBounds +import OAI.Probability.Ballisticity.Stationary.EpisodeLogLength + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +noncomputable def logLengthMark {d : ℕ} (e : Direction d) : C(ActualEpisodeArray e,ℝ≥0∞) := + ⟨fun Y => (ENNReal.log (1+(Y.1 0).1.toENNReal)).toENNReal, + EReal.continuous_toENNReal.comp (ENNReal.continuous_log.comp + (continuous_const.add (ENat.continuous_toENNReal.comp (by fun_prop))))⟩ + +noncomputable def logLengthCut {d : ℕ} (e : Direction d) (B : ℝ≥0) : C(ActualEpisodeArray e,ℝ) := + (cutENNReal B).comp (logLengthMark e) + +lemma raw_actual_test_mono {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (F G : C(ActualEpisodeArray e,ℝ)) + (hFG : ∀ i X, F (StationaryCompact.shift^[i] (actualArrayMap e t J X)) ≤ + G (StationaryCompact.shift^[i] (actualArrayMap e t J X))) : + (∫ Y, F Y ∂actualOccupationRaw e ν Q t J ht N M) ≤ + ∫ Y, G Y ∂actualOccupationRaw e ν Q t J ht N M := by + rw [actualOccupationRaw_integral e ν Q t J ht hJ N M hM F, + actualOccupationRaw_integral e ν Q t J ht hJ N M hM G] + apply Finset.sum_le_sum + intro i _ + have hm : Measurable (fun X => StationaryCompact.shift^[i] (actualArrayMap e t J X)) := + (StationaryCompact.shift_continuous.measurable.iterate i).comp (actualArrayMap_measurable e t J ht hJ) + apply integral_mono + ((F.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)).comp_measurable hm) + ((G.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)).comp_measurable hm) + exact hFG i + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} + {e f : Direction d} {D : ℝ} + +noncomputable def lengthCost (C : OperationalConstants ν e f D) : ℝ := + Real.log 2+Real.log (1+C.sfloor*Real.exp (C.χ*C.b))+1+C.g*C.b + +lemma lengthCost_nonneg (C : OperationalConstants ν e f D) : 0≤C.lengthCost := by + have hs : 0≤C.sfloor := le_trans (by norm_num) C.hs + have hl := Real.log_nonneg (show 1≤1+C.sfloor*Real.exp (C.χ*C.b) by linarith [mul_nonneg hs (Real.exp_pos (C.χ*C.b)).le]) + have ht := Real.log_nonneg (by norm_num : (1:ℝ)≤2) + have hg := mul_nonneg C.hg.le C.hb.le + unfold lengthCost + linarith + +lemma actual_lengthMark (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (X : EpisodeInput e) : + ((StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)).1 0).1 = + ((episodeBoundary (k:=C.k) e f hef (episodeScaleRadius ν e f) C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N X.1.1 (i+1)- + episodeBoundary (k:=C.k) e f hef (episodeScaleRadius ν e f) C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N X.1.1 i:ℕ):ℕ∞) := by + rw [arrayMark_iterate] + simp only [zero_add,actualArrayMap,paddedTimes,EpisodeChainLedger.arrayTime,Int.toNat_natCast, + show (i:ℤ)+1=((i+1:ℕ):ℤ) by omega] + +lemma logLengthCut_actual_le (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (B : ℝ≥0) (X : EpisodeInput e) : + logLengthCut e B (StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)) ≤ C.lengthCost*(1+(C.stagesAt hef N X.1.1 i:ℝ)) := by + let T := episodeBoundary (k:=C.k) e f hef (episodeScaleRadius ν e f) C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N X.1.1 + have hlog : 0≤Real.log (1+(T (i+1)-T i:ℕ)) := Real.log_nonneg (by exact le_add_of_nonneg_right (Nat.cast_nonneg _)) + change (min (ENNReal.log (1+((StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)).1 0).1.toENNReal)).toENNReal (B:ℝ≥0∞)).toReal ≤ _ + rw [C.actual_lengthMark] + change (min (ENNReal.log (1+(T (i+1)-T i:ℕ))).toENNReal (B:ℝ≥0∞)).toReal ≤ _ + have he : (ENNReal.log (1+(T (i+1)-T i:ℕ))).toENNReal = + ENNReal.ofReal (Real.log (1+(T (i+1)-T i:ℕ))) := by + generalize T (i+1)-T i = n + rw [ENNReal.log_pos_real (by positivity) (by finiteness), EReal.real_coe_toENNReal, + ENNReal.toReal_add ENNReal.one_ne_top (ENNReal.natCast_ne_top n)] + simp + rw [he,ENNReal.toReal_min ENNReal.ofReal_ne_top ENNReal.coe_ne_top, + ENNReal.toReal_ofReal hlog] + apply (min_le_left _ _).trans + by_cases ha : T i by + change _ ≤ C.lengthCost*(1+stageMarkCut e (N:ℝ≥0) 0 + (StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) (C.paddedStages hef N) X))) + rw [C.stageMarkCut_actual hef N i] + have hj : (C.stagesAt hef N X.1.1 i:ℝ)≤(N:ℝ) := by + exact_mod_cast EpisodeChainLedger.stepMark_le (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N X.1.1 i + rw [show ((N:ℝ≥0):ℝ)=(N:ℝ) by simp,min_eq_left hj] + exact C.logLengthCut_actual_le hef N i B X) + have hm : (∫ Y, logLengthCut e B Y ∂(μ : Measure (ActualEpisodeArray e)))≤ + ∫ Y, G Y ∂(μ : Measure (ActualEpisodeArray e)) := by + change (∫ Y, logLengthCut e B Y ∂(actualOccupation e ν Q + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) N (C.activeCount hef N):Measure _)) ≤ + ∫ Y, G Y ∂(actualOccupation e ν Q (C.paddedTimes hef N) (C.paddedStages hef N) + (C.paddedTimes_measurable hef N) N (C.activeCount hef N):Measure _) + rw [actualOccupation_integral e ν Q _ _ _ _ _ (C.bad_raw_mass_pos hef N hN hmass), + actualOccupation_integral e ν Q _ _ _ _ _ (C.bad_raw_mass_pos hef N hN hmass)] + exact mul_le_mul_of_nonneg_left hh (inv_nonneg.mpr ENNReal.toReal_nonneg) + apply hm.trans + change (∫ Y, C.lengthCost*(1+stageMarkCut e (N:ℝ≥0) 0 Y) ∂(μ:Measure _))≤_ + rw [integral_const_mul,integral_add (integrable_const _) + ((stageMarkCut e (N:ℝ≥0) 0).continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)), + integral_const,probReal_univ,one_smul] + exact mul_le_mul_of_nonneg_left (add_le_add_right (C.bad_stageMark_bound hef hD N hN hlarge hmass (N:ℝ≥0)) 1) + C.lengthCost_nonneg + +lemma bad_limit_length_moment (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (hD : 0≤D) (Ns : ℕ → ℕ) + (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hlarge : ∀ n, 32*C.b ≤ (1/2:ℝ)*Real.log (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) : + (∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), (Y.1 0).1<⊤) ∧ + Integrable (fun Y => (logLengthMark e Y).toReal) (ρ : Measure (ActualEpisodeArray e)) := by + have hh := mark_lintegral_bound_of_weak_limit _ ρ hlim (logLengthMark e) + (C.lengthCost*(1+C.injectionCost/(6*C.b))) + (fun n B => C.bad_logLengthCut_bound hef hD (Ns n) (hN n) (hlarge n) (hmass n) B) + have hf := mark_integrable_of_lintegral_bound (ρ : Measure (ActualEpisodeArray e)) (logLengthMark e) + (logLengthMark e).continuous.measurable _ hh + refine ⟨hf.1.mono (fun Y h => ?_),hf.2⟩ + by_contra hn + have he : (Y.1 0).1=⊤ := top_le_iff.mp (le_of_not_gt hn) + have ht : logLengthMark e Y=∞ := by simp [logLengthMark,he] + rw [ht] at h + exact (lt_irrefl _ h) + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OperationalMarkBounds.lean b/lean/OAI/Probability/Ballisticity/Estimates/OperationalMarkBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..9307e7ece351ef7c037f0a789700f9ac6051bf4f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OperationalMarkBounds.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BadOccupationLimit +import OAI.Probability.Ballisticity.Stationary.ArrayMarkTests + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} + {e f : Direction d} {D : ℝ} + +lemma stagesAt_measurable (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) : Measurable (fun ω => C.stagesAt hef N ω i) := + EpisodeChainLedger.stepMark_measurable (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N i + +lemma stagesAt_integrable (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] : + Integrable (fun ω => (C.stagesAt hef N ω i:ℝ)) Q := by + apply Integrable.of_bound + (((measurable_of_countable (fun n:ℕ => (n:ℝ))).comp (C.stagesAt_measurable hef N i)).aestronglyMeasurable) N + filter_upwards [] with ω + rw [Real.norm_eq_abs,abs_of_nonneg (Nat.cast_nonneg _)] + change (C.stagesAt hef N ω i:ℝ) ≤ (N:ℝ) + apply Nat.cast_le.mpr + exact EpisodeChainLedger.stepMark_le (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω i + +lemma actual_stageMark (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (X : EpisodeInput e) : + ((StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)).1 0).2.1 = (C.stagesAt hef N X.1.1 i:ℕ∞) := by + rw [arrayMark_iterate] + simp only [zero_add,actualArrayMap,paddedStages,EpisodeChainLedger.arrayStages, + Int.natCast_nonneg,not_lt.mpr,ite_false,Int.toNat_natCast,stagesAt] + +lemma stageMarkCut_actual (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (B : ℝ≥0) (X : EpisodeInput e) : + stageMarkCut e B 0 (StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)) = min (C.stagesAt hef N X.1.1 i:ℝ) B := by + change (min (((StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)).1 0).2.1).toENNReal (B:ℝ≥0∞)).toReal = _ + rw [C.actual_stageMark] + simp only [ENat.toENNReal_coe] + rw [ENNReal.toReal_min (ENNReal.natCast_ne_top _) ENNReal.coe_ne_top] + simp + +variable [IsProbabilityMeasure ν] + +lemma raw_stageMark_bound (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] (B : ℝ≥0) : + (∫ Y, stageMarkCut e B 0 Y ∂actualOccupationRaw e ν Q + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) + N (C.activeCount hef N)) ≤ + ∫ ω, (EpisodeChainLedger.steps (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω N:ℝ) ∂Q := by + rw [actualOccupationRaw_env_test e ν Q (C.paddedTimes hef N) (C.paddedStages hef N) + (C.paddedTimes_measurable hef N) (C.paddedStages_measurable hef N) N (C.activeCount hef N) + (C.activeCount_measurable hef N) (stageMarkCut e B 0) + (fun i ω => min (C.stagesAt hef N ω i:ℝ) B) + (fun i => (((measurable_of_countable (fun n:ℕ => (n:ℝ))).comp (C.stagesAt_measurable hef N i)).min measurable_const)) + (fun i X => C.stageMarkCut_actual hef N i B X)] + have hsum : (∫ ω, (EpisodeChainLedger.steps (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω N:ℝ) ∂Q) = + ∑ i∈Finset.range N, ∫ ω, (C.stagesAt hef N ω i:ℝ) ∂Q := by + rw [←integral_finsetSum (Finset.range N) (fun i _ => C.stagesAt_integrable hef N i Q)] + apply integral_congr_ae + filter_upwards [] with ω + dsimp only [stagesAt] + exact_mod_cast (EpisodeChainLedger.stepMark_sum (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω N).symm + rw [hsum] + apply Finset.sum_le_sum + intro i _ + apply (integral_mono ((C.stagesAt_integrable hef N i Q).inf (integrable_const _)).integrableOn + (C.stagesAt_integrable hef N i Q).integrableOn (fun _ => min_le_left _ _)).trans + exact setIntegral_le_integral (C.stagesAt_integrable hef N i Q) + (Filter.Eventually.of_forall (fun _ => Nat.cast_nonneg _)) + +end OperationalConstants +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} + {e f : Direction d} {D : ℝ} + +lemma dropAt_measurable (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) : Measurable (fun ω => C.dropAt hef N ω i) := + EpisodeChainLedger.dropMark_measurable (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N i + +lemma dropAt_bounds (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (ω : Environment d) (hω : ∀ y u, C.κ ≤ (ω y).1 u) : + 0 ≤ C.dropAt hef N ω i ∧ C.dropAt hef N ω i ≤ C.injectionCost+2*C.b*C.stagesAt hef N ω i := by + have hh := EpisodeChainLedger.dropMark_bounds_local (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N C.order C.hf.le C.hb.le + (lt_of_lt_of_le zero_lt_one C.hs) C.height_pos C.κ C.hκ0 C.hκ1 + (lt_of_lt_of_le (by norm_num) C.hk) C.hbκ ω hω i + refine ⟨hh.1,hh.2.trans ?_⟩ + change C.injectionCost*(if _ then 1 else 0)+_ ≤ _ + split <;> simp only [mul_one,mul_zero,zero_add] + · rfl + · change 2*C.b*(C.stagesAt hef N ω i:ℝ) ≤ C.injectionCost+2*C.b*C.stagesAt hef N ω i + linarith [C.cost_nonneg] + +lemma dropAt_integrable (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (hQ : ∀ᵐ ω ∂Q, ∀ y u, C.κ ≤ (ω y).1 u) : Integrable (fun ω => C.dropAt hef N ω i) Q := + EpisodeChainLedger.dropMark_integrable_local (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N C.order C.hf.le C.hb.le + (lt_of_lt_of_le zero_lt_one C.hs) C.height_pos C.κ C.hκ0 C.hκ1 + (lt_of_lt_of_le (by norm_num) C.hk) C.hbκ Q hQ i + +lemma actual_dropMark (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (X : EpisodeInput e) : + ((StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)).1 0).2.2 = ENNReal.ofReal (C.dropAt hef N X.1.1 i) := by + rw [arrayMark_iterate] + simp only [zero_add,actualArrayMap,episodeCost,paddedTimes,EpisodeChainLedger.arrayTime, + Int.toNat_natCast,show (i:ℤ)+1=((i+1:ℕ):ℤ) by omega,dropAt, EpisodeChainLedger.dropMark] + +lemma dropCut_actual (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (B : ℝ≥0) (X : EpisodeInput e) : + dropMarkCut e B 0 (StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)) = cutENNReal B (ENNReal.ofReal (C.dropAt hef N X.1.1 i)) := by + exact congrArg (cutENNReal B) (C.actual_dropMark hef N i X) + +lemma cut_ofReal_eq_min (B : ℝ≥0) (x : ℝ) (hx : 0≤x) : + cutENNReal B (ENNReal.ofReal x)=min x B := by + change (min (ENNReal.ofReal x) (B:ℝ≥0∞)).toReal=_ + rw [ENNReal.toReal_min ENNReal.ofReal_ne_top ENNReal.coe_ne_top,ENNReal.toReal_ofReal hx] + rfl + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OrderedTimes.lean b/lean/OAI/Probability/Ballisticity/Estimates/OrderedTimes.lean new file mode 100644 index 0000000000000000000000000000000000000000..3af177a82dbb76be5b4c16a5c51e16bc4f891a2a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OrderedTimes.lean @@ -0,0 +1,425 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.PathCompact + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma gaussian_block_count_limit {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) + (n : ℕ → ℝ) (hn : Tendsto n atTop atTop) : + Tendsto (fun i => ((⌊b*n i⌋₊-⌊a*n i⌋₊:ℕ):ℝ)/n i) atTop (𝓝 (b-a)) := by + have he : (fun i => ((⌊b*n i⌋₊-⌊a*n i⌋₊:ℕ):ℝ)/n i) =ᶠ[atTop] + fun i => (⌊b*n i⌋₊:ℝ)/n i-(⌊a*n i⌋₊:ℝ)/n i := by + filter_upwards [hn.eventually (eventually_ge_atTop (0:ℝ))] with i hi + rw [Nat.cast_sub (Nat.floor_mono (mul_le_mul_of_nonneg_right hab hi)),sub_div] + apply Tendsto.congr' he.symm + exact ((tendsto_nat_floor_mul_div_atTop (ha.trans hab)).comp hn).sub + ((tendsto_nat_floor_mul_div_atTop ha).comp hn) + +lemma tendstoInMeasure_sub_zero {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F G : ℕ → Ω → ℝ) + (hF : TendstoInMeasure μ F atTop 0) (hG : TendstoInMeasure μ G atTop 0) : + TendstoInMeasure μ (F-G) atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + have hf := (tendstoInMeasure_iff_measureReal_norm.1 hF) (ε/2) (by positivity) + have hg := (tendstoInMeasure_iff_measureReal_norm.1 hG) (ε/2) (by positivity) + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at hf hg ⊢ + have hs n : {ω | ε ≤ |(F-G) n ω|} ⊆ + {ω | ε/2 ≤ |F n ω|} ∪ {ω | ε/2 ≤ |G n ω|} := by + intro ω hω + by_contra! hc + simp only [Set.mem_union,Set.mem_ofPred_eq,not_or,not_le] at hc + have ht := abs_sub (F n ω) (G n ω) + change ε ≤ |F n ω-G n ω| at hω + exact (not_lt_of_ge hω) (ht.trans_lt (by linarith)) + have hb n := (measureReal_mono (μ := μ) (hs n) (measure_ne_top _ _)).trans (measureReal_union_le (μ := μ) _ _) + exact squeeze_zero (fun _ => measureReal_nonneg) hb (by simpa using hf.add hg) + +lemma fluctuationScale_nonneg {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (S : Ω → ℝ) (r : ℝ) : 0 ≤ fluctuationScale μ S r := by + apply div_nonneg (sq_nonneg _) + exact integral_nonneg (fun x => le_min (sq_nonneg _) (sq_nonneg _)) + +lemma disjoint_blocks_injective {ι : Type*} (a b : ι → ℕ) + (hdisj : ∀ j k, j ≠ k → b j ≤ a k ∨ b k ≤ a j) : + Function.Injective (fun p : (j : ι) × Fin (b j-a j) => a p.1+p.2.1) := by + rintro ⟨j,l⟩ ⟨k,m⟩ he + have hj : l.1 < b j-a j := l.2 + have hk : m.1 < b k-a k := m.2 + by_cases hjk : j = k + · subst k + have hlm : l = m := Fin.ext (by simpa using he) + subst m + rfl + · rcases hdisj j k hjk with h|h <;> simp only at he <;> omega + +lemma realPartialSum_sub_eq_block (x : ℕ → ℝ) {a b : ℕ} (hab : a ≤ b) : + realPartialSum x b-realPartialSum x a = ∑ l : Fin (b-a), x (a+l) := by + have h := realPartialSum_add x a (b-a) + rw [Nat.add_sub_of_le hab] at h + rw [Fin.sum_univ_eq_sum_range (f := fun l => x (a+l))] + change _ = realPartialSum (fun l => x (a+l)) (b-a) + linarith + +theorem gaussian_polygon_increment_limit {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {x | X 0 x ≠ 0}) + (hsym : IdentDistrib (X 0) (fun x => -X 0 x) μ μ) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T : ℝ} (hT : 0 ≤ T) (a b : ι → unitInterval) + (hab : ∀ j, a j ≤ b j) + (hdisj : ∀ j k, j ≠ k → b j ≤ a k ∨ b k ≤ a j) : + TendstoInDistribution (fun i ω (j : ι) => + scaledPolygon (fun k => X k ω) (r i) (fluctuationScale μ (X 0) (r i)) T (b j)- + scaledPolygon (fun k => X k ω) (r i) (fluctuationScale μ (X 0) (r i)) T (a j)) + atTop id (fun _ => μ) (Measure.pi (fun j : ι => gaussianReal 0 + (Real.toNNReal (T*((b j : ℝ)-a j))))) := by + let n := fun i => fluctuationScale μ (X 0) (r i) + have hn := (fluctuationScale_tendsto μ (X 0) (hX 0) hI hne).comp hr.1 + have hn0 i : 0 ≤ n i := fluctuationScale_nonneg _ _ _ + let A := fun i j => ⌊(T*a j)*n i⌋₊ + let B := fun i j => ⌊(T*b j)*n i⌋₊ + have hAB i j : A i j ≤ B i j := Nat.floor_mono + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hab j) hT) (hn0 i)) + have hd i j k (hjk : j ≠ k) : B i j ≤ A i k ∨ B i k ≤ A i j := by + rcases hdisj j k hjk with h|h + · exact Or.inl (Nat.floor_mono (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left h hT) (hn0 i))) + · exact Or.inr (Nat.floor_mono (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left h hT) (hn0 i))) + let τ : ι → ℝ≥0 := fun j => Real.toNNReal (T*((b j : ℝ)-a j)) + have hc j : Tendsto (fun i => ((B i j-A i j:ℕ):ℝ)/n i) atTop (𝓝 (τ j : ℝ)) := by + have h := gaussian_block_count_limit (mul_nonneg hT (a j).2.1) + (mul_le_mul_of_nonneg_left (hab j) hT) n hn + dsimp only [τ] + rw [Real.coe_toNNReal _ (mul_nonneg hT (sub_nonneg.mpr (hab j)))] + simpa only [A,B,mul_sub] using h + have hb := gaussian_iid_finite_block_limit μ X hX hind hident hI hne hsym r hr + (fun i j => B i j-A i j) (fun i j l => A i j+l) + (fun i => disjoint_blocks_injective (A i) (B i) (hd i)) τ hc + have hb' := hb.continuous_comp (g := (WithLp.ofLp : EuclideanSpace ℝ ι → (ι → ℝ))) (by fun_prop) + let Z := fun i ω j => (∑ l : Fin (B i j-A i j), X (A i j+l) ω)/r i + have hZ : TendstoInDistribution Z atTop id (fun _ => μ) + (Measure.pi (fun j => gaussianReal 0 (τ j))) := by + convert hb' using 1 <;> rfl + let Y := fun i ω j => scaledPolygon (fun k => X k ω) (r i) (n i) T (b j)- + scaledPolygon (fun k => X k ω) (r i) (n i) T (a j) + apply tendstoInDistribution_of_tendstoInMeasure_sub Y id hZ + · apply tendstoInMeasure_pi + intro j + have ha := polygon_eval_error_tendstoInMeasure μ X (hX 0) hident r n hr.1 + (Eventually.of_forall hn0) hT (a j) + have hb := polygon_eval_error_tendstoInMeasure μ X (hX 0) hident r n hr.1 + (Eventually.of_forall hn0) hT (b j) + have he := tendstoInMeasure_sub_zero μ _ _ hb ha + convert he using 1 + ext i ω + change Y i ω j-Z i ω j = _ + dsimp [Y,Z] + rw [← realPartialSum_sub_eq_block (fun k => X k ω) (hAB i j)] + dsimp [A,B] + ring + · intro i + apply Measurable.aemeasurable + apply Measurable.of_eval + intro j + exact ((continuous_eval_const _).measurable.comp (measurable_scaledPolygon X hX _ _ _)).sub + ((continuous_eval_const _).measurable.comp (measurable_scaledPolygon X hX _ _ _)) + +noncomputable def orderedTimes (I : Finset unitInterval) (i : Fin (I.card+1)) : unitInterval := + if h : i = 0 then 0 else I.orderEmbOfFin rfl (i.pred h) + +lemma orderedTimes_monotone (I : Finset unitInterval) : Monotone (orderedTimes I) := by + intro i j hij + obtain rfl | hi := eq_or_ne i 0 + · simp [orderedTimes] + have hj : j ≠ 0 := by intro hj; subst j; exact hi (le_antisymm hij (Fin.zero_le _)) + rw [orderedTimes,dite_eq_right hi,orderedTimes,dite_eq_right hj] + exact OrderEmbedding.monotone _ (by simpa) + +lemma orderedTimes_succ (I : Finset unitInterval) (i : Fin I.card) : + orderedTimes I i.succ = I.orderEmbOfFin rfl i := by simp [orderedTimes] + +noncomputable def incrementCumsum (I : Finset unitInterval) : (Fin I.card → ℝ) →L[ℝ] (I → ℝ) := + { toFun x i := ∑ j ≤ (I.orderIsoOfFin rfl).symm i, x j + map_add' x y := by ext; simp [Finset.sum_add_distrib] + map_smul' m x := by ext; simp [Finset.mul_sum] + cont := by fun_prop } + +lemma incrementCumsum_eval (I : Finset unitInterval) (f : unitInterval → ℝ) (hf : f 0 = 0) : + I.restrict f = incrementCumsum I (fun j => f (orderedTimes I j.succ)-f (orderedTimes I j.castSucc)) := by + ext t + simp only [Finset.restrict,incrementCumsum,ContinuousLinearMap.coe_mk',LinearMap.coe_mk,AddHom.coe_mk] + rw [Fin.sum_Iic_sub _ (fun j => f (orderedTimes I j))] + simp [orderedTimes,hf,Finset.orderEmbOfFin] + +noncomputable def gaussianPathFiniteLaw (T : ℝ) (I : Finset unitInterval) : Measure (I → ℝ) := + (Measure.pi (fun j : Fin I.card => gaussianReal 0 + (Real.toNNReal (T*((orderedTimes I j.succ : ℝ)-orderedTimes I j.castSucc))))).map + (incrementCumsum I) + +instance gaussianPathFiniteLaw_probability (T : ℝ) (I : Finset unitInterval) : + IsProbabilityMeasure (gaussianPathFiniteLaw T I) := by + unfold gaussianPathFiniteLaw + infer_instance + +lemma ordered_adjacent_disjoint {m : ℕ} (t : Fin (m+1) → unitInterval) (ht : Monotone t) : + ∀ j k : Fin m, j ≠ k → t j.succ ≤ t k.castSucc ∨ t k.succ ≤ t j.castSucc := by + intro j k hjk + rcases lt_or_gt_of_ne hjk with h|h + · exact Or.inl (ht (by exact_mod_cast h)) + · exact Or.inr (ht (by exact_mod_cast h)) + +theorem gaussian_polygon_finite_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {x | X 0 x ≠ 0}) + (hsym : IdentDistrib (X 0) (fun x => -X 0 x) μ μ) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T : ℝ} (hT : 0 ≤ T) (I : Finset unitInterval) : + TendstoInDistribution (fun i ω => I.restrict + (scaledPolygon (fun k => X k ω) (r i) (fluctuationScale μ (X 0) (r i)) T)) + atTop id (fun _ => μ) (gaussianPathFiniteLaw T I) := by + let Y := fun i ω => scaledPolygon (fun k => X k ω) (r i) + (fluctuationScale μ (X 0) (r i)) T + let t := orderedTimes I + have ht : Monotone t := orderedTimes_monotone I + have hi := gaussian_polygon_increment_limit μ X hX hind hident hI hne hsym r hr hT + (fun j : Fin I.card => t j.castSucc) (fun j => t j.succ) + (fun j => ht (Fin.castSucc_le_succ j)) (ordered_adjacent_disjoint t ht) + have hc := hi.continuous_comp (incrementCumsum I).continuous + have hl i : (fun ω => I.restrict ((Y i ω) ·)) =ᵐ[μ] + (incrementCumsum I) ∘ (fun ω j => Y i ω (t j.succ)-Y i ω (t j.castSucc)) := by + filter_upwards [] with ω + exact incrementCumsum_eval I (Y i ω) (scaledPolygon_zero _ _ _ _) + have hc' := hc.congr (fun i => (hl i).symm) Filter.EventuallyEq.rfl + refine ⟨hc'.forall_aemeasurable,measurable_id.aemeasurable,?_⟩ + convert hc'.tendsto using 1 + simp only [gaussianPathFiniteLaw,Function.comp_def,id_eq,Measure.map_id] + rfl + +lemma continuous_path_restrict (I : Finset unitInterval) : + Continuous (fun f : C(unitInterval,ℝ) => I.restrict f) := by + apply continuous_pi + intro j + exact continuous_eval_const _ + +lemma continuous_path_measure_ext (μ ν : Measure C(unitInterval,ℝ)) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] + (h : ∀ I : Finset unitInterval, μ.map (fun f : C(unitInterval,ℝ) => I.restrict f) = + ν.map (fun f : C(unitInterval,ℝ) => I.restrict f)) : μ = ν := by + classical + let e := TopologicalSpace.denseSeq unitInterval + let E := fun f : C(unitInterval,ℝ) => fun n => f (e n) + have hE : Continuous E := continuous_pi (fun n => continuous_eval_const _) + have hEinj : Function.Injective E := by + intro f g hfg + apply ContinuousMap.coe_injective + exact TopologicalSpace.denseRange_denseSeq unitInterval |>.equalizer + f.continuous g.continuous hfg + apply hE.measurableEmbedding hEinj |>.map_injective + let P := fun J : Finset ℕ => (μ.map E).map J.restrict + have : ∀ J, IsFiniteMeasure (P J) := fun _ => inferInstance + apply IsProjectiveLimit.unique (P := P) (fun _ => rfl) + intro J + let I := J.image e + let g := fun f : I → ℝ => fun j : J => f ⟨e j,Finset.mem_image_of_mem e j.2⟩ + have hg : Measurable g := by fun_prop + have hm : Measurable (J.restrict : (ℕ → ℝ) → (J → ℝ)) := by fun_prop + change (ν.map E).map J.restrict = (μ.map E).map J.restrict + rw [Measure.map_map hm hE.measurable,Measure.map_map hm hE.measurable] + have he : J.restrict ∘ E = g ∘ (fun f : C(unitInterval,ℝ) => I.restrict f) := rfl + rw [he,← Measure.map_map hg (continuous_path_restrict I).measurable, + ← Measure.map_map hg (continuous_path_restrict I).measurable,h I] + +theorem exists_path_limit_of_tight_finite_limit + (μ : ℕ → ProbabilityMeasure C(unitInterval,ℝ)) + (P : (I : Finset unitInterval) → ProbabilityMeasure (I → ℝ)) + (ht : IsTightMeasureSet (Set.range (fun n => (μ n : Measure C(unitInterval,ℝ))))) + (hf : ∀ I, Tendsto (fun n => (μ n).map (fun path : C(unitInterval,ℝ) => I.restrict path)) + atTop (𝓝 (P I))) : + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), Tendsto μ atTop (𝓝 W) ∧ + ∀ I, W.map (fun path : C(unitInterval,ℝ) => I.restrict path) = P I := by + have hc : IsCompact (closure (Set.range μ)) := + isCompact_closure_of_isTightMeasureSet (by + convert ht using 1 + ext x + simp) + have hmem n : μ n ∈ closure (Set.range μ) := subset_closure (Set.mem_range_self n) + obtain ⟨W,_,s,hs,hw⟩ := hc.tendsto_subseq hmem + have hid : ∀ (n : ℕ → ℕ) (hn : Tendsto n atTop atTop) + (V : ProbabilityMeasure C(unitInterval,ℝ)), + Tendsto (μ ∘ n) atTop (𝓝 V) → + ∀ I, V.map (fun path : C(unitInterval,ℝ) => I.restrict path) = P I := by + intro n hn V hv I + exact tendsto_nhds_unique + ((ProbabilityMeasure.continuous_map (continuous_path_restrict I)).tendsto V |>.comp hv) + ((hf I).comp hn) + have hW := hid s hs.tendsto_atTop W hw + refine ⟨W,?_,hW⟩ + apply Filter.tendsto_of_subseq_tendsto + intro n hn + obtain ⟨V,_,s,hs,hv⟩ := hc.tendsto_subseq (fun j => hmem (n j)) + have hV := hid (n ∘ s) (hn.comp hs.tendsto_atTop) V hv + have he : V = W := by + have : IsProbabilityMeasure (V : Measure C(unitInterval,ℝ)) := V.prop + have : IsProbabilityMeasure (W : Measure C(unitInterval,ℝ)) := W.prop + apply Subtype.ext + apply continuous_path_measure_ext (V : Measure C(unitInterval,ℝ)) + (W : Measure C(unitInterval,ℝ)) + intro I + exact congrArg (fun Q : ProbabilityMeasure (I → ℝ) => (Q : Measure (I → ℝ))) + ((hV I).trans (hW I).symm) + subst V + exact ⟨s,hv⟩ + +theorem gaussian_iid_path_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T : ℝ} (hT : 0 ≤ T) : + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i ω => scaledPolygon (fun k => X k ω) + (r i) (fluctuationScale μ (X 0) (r i)) T) atTop id (fun _ => μ) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun f : C(unitInterval,ℝ) => I.restrict f) = + gaussianPathFiniteLaw T I := by + let Y := fun i ω => scaledPolygon (fun k => X k ω) (r i) + (fluctuationScale μ (X 0) (r i)) T + have hY : ∀ i, Measurable (Y i) := fun _ => measurable_scaledPolygon X hX _ _ _ + let M : ℕ → ProbabilityMeasure C(unitInterval,ℝ) := fun i => + ⟨μ.map (Y i),inferInstance⟩ + let P : (I : Finset unitInterval) → ProbabilityMeasure (I → ℝ) := fun I => + ⟨gaussianPathFiniteLaw T I,inferInstance⟩ + have ht : IsTightMeasureSet (Set.range (fun i => (M i : Measure C(unitInterval,ℝ)))) := + gaussian_iid_path_tight μ X hX hind hident hsym hI hne r hr hT + have hf : ∀ I, Tendsto (fun i => (M i).map (fun path : C(unitInterval,ℝ) => I.restrict path)) + atTop (𝓝 (P I)) := by + intro I + have h := (gaussian_polygon_finite_limit μ X hX hind hident hI hne hsym r hr hT I).tendsto + have he : (fun i => (M i).map (fun path : C(unitInterval,ℝ) => I.restrict path)) = + (fun i => (⟨μ.map (fun ω => I.restrict (Y i ω)), + inferInstance⟩ : + ProbabilityMeasure (I → ℝ))) := by + funext i + apply Subtype.ext + exact Measure.map_map (continuous_path_restrict I).measurable (hY i) + rw [he] + simpa only [Measure.map_id] using h + obtain ⟨W,hw,hf⟩ := exists_path_limit_of_tight_finite_limit M P ht hf + refine ⟨W,⟨fun i => (hY i).aemeasurable,measurable_id.aemeasurable,?_⟩,?_⟩ + · convert hw using 1 + apply congrArg + apply Subtype.ext + exact Measure.map_id + · intro I + exact congrArg (fun Q : ProbabilityMeasure (I → ℝ) => (Q : Measure (I → ℝ))) (hf I) + +theorem transverse_common_gaussian_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + letI : IsProbabilityMeasure (independentConditionedPairLaw ν (realPosition (step e))) := + independentConditionedPairLaw_probability ν _ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i P => scaledPolygon + (fun k => commonIncrementProcess (realPosition (step e)) f k P) (r i) + (fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) T) + atTop id (fun _ => independentConditionedPairLaw ν (realPosition (step e))) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw T I := by + let ℓ := realPosition (step e) + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + exact gaussian_iid_path_limit _ _ (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) + (independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_nonzero ν hue e f hef htrans) r hr hT + +noncomputable def renewalSum (L : ℕ → ℕ) (n : ℕ) : ℕ := ∑ k ∈ Finset.range n, L k + +lemma renewalSum_zero (L : ℕ → ℕ) : renewalSum L 0 = 0 := by simp [renewalSum] +lemma renewalSum_succ (L : ℕ → ℕ) (n : ℕ) : renewalSum L (n+1) = renewalSum L n+L n := by + simp [renewalSum,Finset.sum_range_succ] +lemma renewalSum_ge (L : ℕ → ℕ) (hL : ∀ k, 0 < L k) (n : ℕ) : n ≤ renewalSum L n := by + induction n with + | zero => exact Nat.zero_le _ + | succ n ih => rw [renewalSum_succ]; have := hL n; omega +lemma renewalSum_strictMono (L : ℕ → ℕ) (hL : ∀ k, 0 < L k) : StrictMono (renewalSum L) := by + apply strictMono_nat_of_lt_succ + intro n + rw [renewalSum_succ] + exact Nat.lt_add_of_pos_right (hL n) + +open scoped Classical in +noncomputable def renewalCount (L : ℕ → ℕ) (h : ℕ) : ℕ := + Nat.findGreatest (fun k => renewalSum L k ≤ h) h +lemma renewalCount_le (L : ℕ → ℕ) (h : ℕ) : renewalCount L h ≤ h := Nat.findGreatest_le _ +lemma renewalCount_lower (L : ℕ → ℕ) (h : ℕ) : renewalSum L (renewalCount L h) ≤ h := by + classical + exact Nat.findGreatest_spec (P := fun k => renewalSum L k ≤ h) (Nat.zero_le h) + (by rw [renewalSum_zero]; exact Nat.zero_le _) +lemma renewalCount_upper (L : ℕ → ℕ) (hL : ∀ k, 0 < L k) (h : ℕ) : + h < renewalSum L (renewalCount L h+1) := by + classical + by_cases hk : renewalCount L h+1 ≤ h + · exact Nat.lt_of_not_ge (Nat.findGreatest_is_greatest + (P := fun k => renewalSum L k ≤ h) (Nat.lt_succ_self _) hk) + · exact (Nat.lt_of_not_ge hk).trans_le (renewalSum_ge L hL _) +lemma renewalCount_zero (L : ℕ → ℕ) : renewalCount L 0 = 0 := by simp [renewalCount] +lemma renewalCount_monotone (L : ℕ → ℕ) : Monotone (renewalCount L) := by + intro a b hab + exact Nat.findGreatest_mono (fun _ h => h.trans hab) hab + +lemma linear_error_uniform (f : ℕ → ℝ) (c : ℝ) + (hf : Tendsto (fun k : ℕ => f k/k) atTop (𝓝 c)) + {T ε : ℝ} (hT : 0 ≤ T) (hε : 0 < ε) : + ∀ᶠ a : ℝ in atTop, ∀ k : ℕ, (k : ℝ) ≤ T*a → |f k-c*k| ≤ ε*a := by + have hδ : 0 < ε/(T+1) := div_pos hε (by linarith) + obtain ⟨K,hK⟩ := (Metric.tendsto_atTop.1 hf) (ε/(T+1)) hδ + let C := ∑ k ∈ Finset.range (K+1), |f k-c*k| + filter_upwards [eventually_ge_atTop (max 0 (C/ε))] with a ha k hk + have ha0 : 0 ≤ a := (le_max_left _ _).trans ha + by_cases hkK : k ≤ K + · have h1 : |f k-c*k| ≤ C := Finset.single_le_sum (fun j _ => abs_nonneg (f j-c*j)) + (Finset.mem_range.2 (Nat.lt_succ_of_le hkK)) + exact h1.trans (by simpa [mul_comm] using (div_le_iff₀ hε).1 ((le_max_right _ _).trans ha)) + · have hkpos : 0 < (k : ℝ) := by exact_mod_cast (show 0 < k by omega) + have he : f k/(k : ℝ)-c = (f k-c*k)/k := by field_simp + have hbound := hK k (by omega) + rw [Real.dist_eq,he,abs_div,abs_of_pos hkpos] at hbound + have hh := (div_lt_iff₀ hkpos).1 hbound + have h2 : (ε/(T+1))*(k : ℝ) ≤ ε*a := by + calc + _ ≤ (ε/(T+1))*(T*a) := mul_le_mul_of_nonneg_left hk hδ.le + _ ≤ ε*a := by + have hd : T/(T+1) ≤ 1 := (div_le_one (by linarith)).2 (by linarith) + calc + _ = (ε*a)*(T/(T+1)) := by ring + _ ≤ ε*a := mul_le_of_le_one_right (mul_nonneg hε.le ha0) hd + exact hh.le.trans h2 + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OutwardCanonical.lean b/lean/OAI/Probability/Ballisticity/Estimates/OutwardCanonical.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cfc1372123c372e7bb8318540286ef24cb2981e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OutwardCanonical.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.OutwardCanonicalRows + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem actual_outward_canonical_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A c B : ℝ, 0 < A ∧ 0 < c ∧ 0 < B ∧ + ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + let Z := outwardCanonicalExcess e f A x + (∀ ω, 0 ≤ Z ω) ∧ + @Measurable _ _ (rowSigma {y | a ≤ dot (realPosition y) (realPosition (step e))}) _ Z ∧ + Integrable (fun ω => Real.exp (c*Z ω)) (environmentLaw ν) ∧ + (∫ ω, Real.exp (c*Z ω) ∂environmentLaw ν) ≤ B ∧ + (∀ᵐ ω ∂environmentLaw ν, ∀ t : ℕ, + 0 < outwardKernelMass e f (t+1) x ω ∧ + -Real.log (outwardKernelMass e f (t+1) x ω) ≤ 2*A*Real.log ((t:ℝ)+2)+Z ω) := by + obtain ⟨A,D,B,hA,hD,hB,hdata⟩ := actual_outward_log_bound ν hue e f hef htrans + refine ⟨A,D⁻¹,Real.exp 1*B,hA,inv_pos.mpr hD,mul_pos (Real.exp_pos _) hB,?_⟩ + intro a x hx + obtain ⟨W,hW,hW0,hWi,hWB,hbound⟩ := hdata a x hx + let Z := outwardCanonicalExcess e f A x + have hZm : Measurable Z := measurable_outwardCanonicalExcess e f A x + have hZbound : ∀ᵐ ω ∂environmentLaw ν, Z ω ≤ D*(W ω+1) ∧ + ∀ n, -Real.log (outwardKernelMass e f (n+1) x ω) ≤ 2*A*Real.log ((n:ℝ)+2)+Z ω := by + filter_upwards [hbound] with ω hω + exact canonicalLogExcess_bounds hA.le hD.le (hW0 ω) _ ω (fun n => (hω n).2) + have hdom : Integrable (fun ω => Real.exp 1*Real.exp (W ω)) (environmentLaw ν) := hWi.const_mul _ + have hexp : ∀ᵐ ω ∂environmentLaw ν, Real.exp (D⁻¹*Z ω) ≤ Real.exp 1*Real.exp (W ω) := by + filter_upwards [hZbound] with ω hω + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left hω.1 (inv_nonneg.mpr hD.le) + rw [←mul_assoc,inv_mul_cancel₀ hD.ne',one_mul] at hh + linarith + have hZi : Integrable (fun ω => Real.exp (D⁻¹*Z ω)) (environmentLaw ν) := + hdom.mono_nonneg (hZm.const_mul _ |>.exp |>.aestronglyMeasurable) + (Eventually.of_forall (fun ω => (Real.exp_pos _).le)) hexp + refine ⟨fun ω => canonicalLogExcess_nonneg _ _ ω,outwardCanonicalExcess_upper_rows e f A a x hx,hZi,?_,?_⟩ + · calc + _ ≤ ∫ ω, Real.exp 1*Real.exp (W ω) ∂environmentLaw ν := integral_mono_ae hZi hdom hexp + _ = Real.exp 1*(∫ ω, Real.exp (W ω) ∂environmentLaw ν) := integral_const_mul _ _ + _ ≤ Real.exp 1*B := mul_le_mul_of_nonneg_left hWB (Real.exp_pos _).le + · filter_upwards [hbound,hZbound] with ω hω hZω + exact fun n => ⟨(hω n).1,hZω.2 n⟩ +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def truncatedEndpointLaw {d : ℕ} (e : Direction d) (H N : ℕ) + (ω : Environment d) (x : Lattice d) : Measure (Lattice d) := + ((quenchedKernel (ω,x)).restrict (HitThrough (Strip (realPosition (step e)) x H) + (Upper (realPosition (step e)) x H) N)).map (prefixEndpoint (realPosition (step e)) x H) + +instance truncatedEndpointLaw_finite {d : ℕ} (e : Direction d) (H N : ℕ) + (ω : Environment d) (x : Lattice d) : IsFiniteMeasure (truncatedEndpointLaw e H N ω x) := by + unfold truncatedEndpointLaw + infer_instance + +lemma truncatedEndpointLaw_le {d : ℕ} (e : Direction d) {H : ℕ} (hH : 0 < H) + (N : ℕ) (ω : Environment d) (x : Lattice d) : + truncatedEndpointLaw e H N ω x ≤ + hitKernel (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) (ω,x) := by + rw [hitKernel_eq_map_prefixEndpoint e x hH] + exact Measure.map_mono (Measure.restrict_mono (hitThrough_subset_hit _ _ _) le_rfl) + (measurable_prefixEndpoint _ _ _) + +lemma truncatedEndpointLaw_apply {d : ℕ} (e : Direction d) {H : ℕ} (hH : 0 < H) + (N : ℕ) (ω : Environment d) (x : Lattice d) (A : Set (Lattice d)) : + truncatedEndpointLaw e H N ω x A = quenchedKernel (ω,x) + (HitThrough (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H ∩ A) N) := by + rw [truncatedEndpointLaw,Measure.map_apply (measurable_prefixEndpoint _ _ _) (Set.to_countable _).measurableSet, + Measure.restrict_apply ((measurable_prefixEndpoint _ _ _) (Set.to_countable _).measurableSet)] + apply measure_congr + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + apply propext + constructor + · rintro ⟨hA,hhit⟩ + obtain ⟨n,hn,hdet⟩ := Set.mem_iUnion₂.mp hhit + change prefixEndpoint (realPosition (step e)) x H X ∈ A at hA + dsimp [prefixEndpoint] at hA + rw [coordinate_hitAt_record e x X h0 hnn hH hdet] at hA + exact Set.mem_iUnion₂.mpr ⟨n,hn,⟨hdet.1,by simpa only [add_sub_cancel] using hA⟩,hdet.2⟩ + · intro hhit + obtain ⟨n,hn,hdet⟩ := Set.mem_iUnion₂.mp hhit + have hh : X ∈ HitAt (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) n := ⟨hdet.1.1,hdet.2⟩ + refine ⟨?_,Set.mem_iUnion₂.mpr ⟨n,hn,hh⟩⟩ + change prefixEndpoint (realPosition (step e)) x H X ∈ A + dsimp [prefixEndpoint] + rw [coordinate_hitAt_record e x X h0 hnn hH hh] + simpa only [add_sub_cancel] using hdet.1.2 + +lemma truncatedEndpointLaw_locality {d : ℕ} (e : Direction d) {H : ℕ} (hH : 0 < H) + (N : ℕ) (ω η : Environment d) (x : Lattice d) + (he : Set.EqOn ω η (LatticeBall x N)) : + truncatedEndpointLaw e H N ω x = truncatedEndpointLaw e H N η x := by + apply Measure.ext + intro A hA + rw [truncatedEndpointLaw_apply e hH,truncatedEndpointLaw_apply e hH] + exact quenched_hitThrough_locality ω η x _ _ N he +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OutwardCapL1.lean b/lean/OAI/Probability/Ballisticity/Estimates/OutwardCapL1.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc621c76ba0d8ec0118c0b20a838fcbf1e6bdf5e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OutwardCapL1.lean @@ -0,0 +1,133 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.OutwardOrder + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma bounded_probability_error_integral {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (h : Ω → ℝ) (hm : Measurable h) + {C ε : ℝ} (hε : 0 ≤ ε) (hb : ∀ ω, 0 ≤ h ω ∧ h ω ≤ C) : + (∫ ω, h ω ∂μ) ≤ ε+C*μ.real {ω | ε < h ω} := by + let E := {ω | ε < h ω} + have hE : MeasurableSet E := measurableSet_lt measurable_const hm + have hg : Integrable (fun ω => ε+E.indicator (fun _ => C) ω) μ := + (integrable_const _).add ((integrable_const _).indicator hE) + have hh : ∀ ω, h ω ≤ ε+E.indicator (fun _ => C) ω := by + intro ω + by_cases he : ω ∈ E + · rw [Set.indicator_of_mem he] + exact (hb ω).2.trans (by linarith) + · rw [Set.indicator_of_notMem he,add_zero] + exact le_of_not_gt he + have hi : Integrable h μ := hg.mono_nonneg hm.aestronglyMeasurable + (Eventually.of_forall fun ω => (hb ω).1) (Eventually.of_forall hh) + have hle := integral_mono_ae hi hg (Eventually.of_forall hh) + rw [integral_add (integrable_const _) ((integrable_const _).indicator hE), + integral_const,integral_indicator_const _ hE] at hle + simpa only [probReal_univ,smul_eq_mul,one_mul,mul_one,mul_comm] using hle + +lemma outward_cap_locality_L1 {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (e f : Direction d) (A : ℝ) + (hloc : ∀ C ε δ : ℝ, 0 < C → 0 < ε → 0 < δ → ∃ R : ℕ, + ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ C) ∧ + (environmentLaw ν).real {ω | ε < |min (outwardCanonicalExcess e f A x ω) C-F ω|} < δ) + {C ε : ℝ} (hC : 0 < C) (hε : 0 < ε) : + ∃ R : ℕ, ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ C) ∧ + (∫ ω, |min (outwardCanonicalExcess e f A x ω) C-F ω| ∂environmentLaw ν) < ε := by + obtain ⟨R,hR⟩ := hloc C (ε/2) (ε/(2*C)) hC (by positivity) (by positivity) + refine ⟨R,?_⟩ + intro a x hx + obtain ⟨F,hFm,hFb,hFerr⟩ := hR a x hx + refine ⟨F,hFm,hFb,?_⟩ + have hFa : Measurable F := hFm.mono (rowSigma_le _) le_rfl + have hh := bounded_probability_error_integral (environmentLaw ν) + (fun ω => |min (outwardCanonicalExcess e f A x ω) C-F ω|) + (((measurable_outwardCanonicalExcess e f A x).min measurable_const).sub hFa).abs + (show 0 ≤ ε/2 by positivity) (C:=C) (fun ω => by + refine ⟨abs_nonneg _,abs_le.mpr ⟨?_,?_⟩⟩ + · have hz : 0 ≤ min (outwardCanonicalExcess e f A x ω) C := + le_min (canonicalLogExcess_nonneg _ _ ω) hC.le + linarith [(hFb ω).2] + · linarith [min_le_right (outwardCanonicalExcess e f A x ω) C,(hFb ω).1]) + have hmul := mul_lt_mul_of_pos_left hFerr hC + have heq : C*(ε/(2*C)) = ε/2 := by field_simp + rw [heq] at hmul + linarith + +theorem actual_outward_cap_L1_locality {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℝ, 0 < A ∧ ∀ C ε : ℝ, 0 < C → 0 < ε → ∃ R : ℕ, + ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ C) ∧ + (∫ ω, |min (outwardCanonicalExcess e f A x ω) C-F ω| ∂environmentLaw ν) < ε := by + obtain ⟨A,c,B,hA,hc,hB,hbound,hloc⟩ := actual_outward_order ν hue e f hef htrans + exact ⟨A,hA,fun C ε hC hε => outward_cap_locality_L1 ν e f A hloc hC hε⟩ +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma outward_order_countable_event {d : ℕ} + (ν : Measure (Row d)) (e f : Direction d) (A : ℝ) + (hbound : ∀ (a : ℝ) (x : Lattice d × Lattice d), + x ∈ PairAtHeight (realPosition (step e)) a → + ∀ᵐ ω ∂environmentLaw ν, ∀ t : ℕ, + 0 < outwardKernelMass e f (t+1) x ω ∧ + -Real.log (outwardKernelMass e f (t+1) x ω) ≤ + 2*A*Real.log ((t:ℝ)+2)+outwardCanonicalExcess e f A x ω) : + ∀ᵐ ω ∂environmentLaw ν, ∀ x : Lattice d × Lattice d, + dot (realPosition x.1) (realPosition (step e)) = + dot (realPosition x.2) (realPosition (step e)) → + ∀ t : ℕ, 0 < outwardKernelMass e f (t+1) x ω ∧ + -Real.log (outwardKernelMass e f (t+1) x ω) ≤ + 2*A*Real.log ((t:ℝ)+2)+outwardCanonicalExcess e f A x ω := by + apply ae_all_iff.mpr + intro x + by_cases hx : dot (realPosition x.1) (realPosition (step e)) = + dot (realPosition x.2) (realPosition (step e)) + · filter_upwards [hbound (dot (realPosition x.1) (realPosition (step e))) x ⟨rfl,hx.symm⟩] with ω hω + exact fun _ => hω + · exact Eventually.of_forall fun _ h => (hx h).elim + +theorem actual_outward_all_pairs {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℝ, 0 < A ∧ + (∀ᵐ ω ∂environmentLaw ν, ∀ x : Lattice d × Lattice d, + dot (realPosition x.1) (realPosition (step e)) = + dot (realPosition x.2) (realPosition (step e)) → + ∀ t : ℕ, 0 < outwardKernelMass e f (t+1) x ω ∧ + -Real.log (outwardKernelMass e f (t+1) x ω) ≤ + 2*A*Real.log ((t:ℝ)+2)+outwardCanonicalExcess e f A x ω) := by + obtain ⟨A,c,B,hA,hc,hB,hbound,hloc⟩ := actual_outward_order ν hue e f hef htrans + exact ⟨A,hA,outward_order_countable_event ν e f A (fun a x hx => (hbound a x hx).2.2.2.2)⟩ +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OutwardCapLocality.lean b/lean/OAI/Probability/Ballisticity/Estimates/OutwardCapLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..9eb874462b5e5192fdad3c6644de274b32dbbd3c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OutwardCapLocality.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.CanonicalHeightCutoff +import OAI.Probability.Ballisticity.Walk.FiniteOutwardRowApproximation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma outward_canonical_cap_locality_of_log_bound {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e f : Direction d) {A D B : ℝ} (hA : 0 < A) (hD : 0 < D) (hB : 0 < B) + (hdata : ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ W : Environment d → ℝ, Measurable W ∧ (∀ ω, 0 ≤ W ω) ∧ + Integrable (fun ω => Real.exp (W ω)) (environmentLaw ν) ∧ + (∫ ω, Real.exp (W ω) ∂environmentLaw ν) ≤ B ∧ + (∀ᵐ ω ∂environmentLaw ν, ∀ t : ℕ, + 0 < outwardKernelMass e f (t+1) x ω ∧ + -Real.log (outwardKernelMass e f (t+1) x ω) ≤ + A*Real.log ((t:ℝ)+2)+D*(W ω+1))) : + ∀ C ε δ : ℝ, 0 < C → 0 < ε → 0 < δ → ∃ R : ℕ, + ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ C) ∧ + (environmentLaw ν).real {ω | ε < |min (outwardCanonicalExcess e f A x ω) C-F ω|} < δ := by + obtain ⟨κ,hκ,hκae⟩ := environment_uniform_elliptic ν hue + intro C ε δ hC hε hδ + let M := Real.log (B/δ+1) + have harg : 0 < B/δ+1 := by positivity + have heM : Real.exp M = B/δ+1 := Real.exp_log harg + have hprob : B/Real.exp M < δ := by + apply (div_lt_iff₀ (Real.exp_pos M)).mpr + rw [heM,mul_add,mul_one,mul_div_cancel₀ B hδ.ne'] + linarith + obtain ⟨N,hN⟩ := exists_log_height_cutoff (D:=D) (M:=M) hA + obtain ⟨R,hR⟩ := finite_outward_upper_row_approximation hκ e f A N hε hC.le + refine ⟨R,?_⟩ + intro a x hx + obtain ⟨F,hF,hFb,hFerr⟩ := hR a x hx + refine ⟨F,hF,hFb,?_⟩ + obtain ⟨W,hW,hW0,hWi,hWB,hbound⟩ := hdata a x hx + have hcut := canonical_height_cutoff_probability (environmentLaw ν) hA.le hD.le + (fun n => outwardKernelMass e f (n+1) x) W hWi hWB + (hbound.mono fun ω hω n => (hω n).2) N hN + have hs : ∀ᵐ ω ∂environmentLaw ν, + (ε < |min (outwardCanonicalExcess e f A x ω) C-F ω|) → + canonicalLogExcess A (fun n => outwardKernelMass e f (n+1) x) ω ≠ + finiteLogExcess A (fun n => outwardKernelMass e f (n+1) x) N ω := by + filter_upwards [hκae] with ω hω herr heq + have hh := hFerr ω hω + change ε < |min (canonicalLogExcess A (fun n => outwardKernelMass e f (n+1) x) ω) C-F ω| at herr + rw [heq] at herr + exact (not_lt_of_ge hh) herr + have hm := ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hs) + exact (hm.trans hcut).trans_lt hprob + +theorem actual_outward_canonical_cap_locality {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℝ, 0 < A ∧ ∀ C ε δ : ℝ, 0 < C → 0 < ε → 0 < δ → ∃ R : ℕ, + ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ C) ∧ + (environmentLaw ν).real {ω | ε < |min (outwardCanonicalExcess e f A x ω) C-F ω|} < δ := by + obtain ⟨A,D,B,hA,hD,hB,hdata⟩ := actual_outward_log_bound ν hue e f hef htrans + exact ⟨A,hA,outward_canonical_cap_locality_of_log_bound ν hue e f hA hD hB hdata⟩ +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/OwnMarginalOccupation.lean b/lean/OAI/Probability/Ballisticity/Estimates/OwnMarginalOccupation.lean new file mode 100644 index 0000000000000000000000000000000000000000..daeb3088880ac5d70832cff7b90e4c4d121f452a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/OwnMarginalOccupation.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.OccupationEntropy + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical BigOperators +namespace DirectionalTransience.Entropy +variable {Z F I : Type*} [MeasurableSpace Z] [MeasurableSpace F] + +lemma fst_restrict_preimage (μ : Measure (Z × F)) (A : Set Z) (hA : MeasurableSet A) : + (μ.restrict (Prod.fst ⁻¹' A)).fst = μ.fst.restrict A := + (Measure.restrict_map measurable_fst hA).symm + +lemma fresh_restrict (ζ : Measure Z) [SFinite ζ] (π : Measure F) [SFinite π] (A : Set Z) : + (ζ.prod π).restrict (Prod.fst ⁻¹' A) = (ζ.restrict A).prod π := by + have he : (Prod.fst ⁻¹' A : Set (Z × F)) = A ×ˢ Set.univ := by ext p; simp + rw [he,← Measure.prod_restrict,Measure.restrict_univ] + +lemma fresh_activeSum (s : Finset I) (μ : I → Measure (Z × F)) + [∀ i, IsFiniteMeasure (μ i)] (π : Measure F) [IsProbabilityMeasure π] + (A : I → Set Z) (hA : ∀ i ∈ s, MeasurableSet (A i)) : + activeSum s (fun i => (μ i).fst.prod π) (fun i => Prod.fst ⁻¹' A i) = + (activeSum s μ (fun i => Prod.fst ⁻¹' A i)).fst.prod π := by + induction s using Finset.induction_on with + | empty => simp [activeSum,Measure.fst] + | @insert a s ha ih => + have hAa := hA a (Finset.mem_insert_self a s) + have hAs : ∀ i ∈ s, MeasurableSet (A i) := fun i hi => hA i (Finset.mem_insert_of_mem hi) + simp only [activeSum,Finset.sum_insert ha] at ih ⊢ + rw [Measure.fst_add,Measure.add_prod,fst_restrict_preimage _ _ hAa,fresh_restrict] + rw [ih hAs] + +lemma fresh_activeMass (μ : Measure (Z × F)) (π : Measure F) [IsProbabilityMeasure π] + (A : Set Z) (hA : MeasurableSet A) : + μ (Prod.fst ⁻¹' A) = (μ.fst.prod π) (Prod.fst ⁻¹' A) := by + rw [← Measure.fst_apply hA, ← Measure.fst_apply hA,Measure.fst_prod] + +lemma normalize_fst_prod [Nonempty (Z × F)] + (μ : FiniteMeasure (Z × F)) (π : Measure F) [IsProbabilityMeasure π] + (hμ : μ ≠ 0) : + let ν : FiniteMeasure (Z × F) := ⟨(μ : Measure (Z × F)).fst.prod π,inferInstance⟩ + (ν.normalize : Measure (Z × F)) = (μ.normalize : Measure (Z × F)).fst.prod π := by + let ν : FiniteMeasure (Z × F) := ⟨(μ : Measure (Z × F)).fst.prod π,inferInstance⟩ + change (ν.normalize : Measure (Z × F)) = (μ.normalize : Measure (Z × F)).fst.prod π + have hm : ν.mass = μ.mass := by + change ((μ : Measure (Z × F)).fst.prod π Set.univ).toNNReal = _ + rw [← Set.univ_prod_univ,Measure.prod_prod,measure_univ (μ:=π),mul_one,Measure.fst_univ] + rfl + have hν : ν ≠ 0 := by + rw [← FiniteMeasure.mass_nonzero_iff,hm] + exact μ.mass_nonzero_iff.mpr hμ + rw [ν.toMeasure_normalize_eq_of_nonzero hν,μ.toMeasure_normalize_eq_of_nonzero hμ,hm] + change μ.mass⁻¹ • ((μ : Measure (Z × F)).fst.prod π) = + ((μ.mass⁻¹ • (μ : Measure (Z × F))).map Prod.fst).prod π + rw [Measure.map_smul _ measurable_fst.aemeasurable,Measure.prod_smul_left] + rfl + +theorem own_normalized_activeSum_kl_le [Nonempty (Z × F)] + (s : Finset I) (μ : I → Measure (Z × F)) [∀ i, IsProbabilityMeasure (μ i)] + (π : Measure F) [IsProbabilityMeasure π] + (A : I → Set Z) (hA : ∀ i ∈ s, MeasurableSet (A i)) + (hkl : ∀ i ∈ s, klDiv (μ i) ((μ i).fst.prod π) ≠ ∞) + (hpos : 0 < (activeSum s μ (fun i => Prod.fst ⁻¹' A i)).real Set.univ) : + let μs : FiniteMeasure (Z × F) := ⟨activeSum s μ (fun i => Prod.fst ⁻¹' A i),inferInstance⟩ + klDiv (μs.normalize : Measure (Z × F)) ((μs.normalize : Measure (Z × F)).fst.prod π) ≤ + ENNReal.ofReal ((∑ i ∈ s, (klDiv (μ i) ((μ i).fst.prod π)).toReal) / + (activeSum s μ (fun i => Prod.fst ⁻¹' A i)).real Set.univ) := by + let μs : FiniteMeasure (Z × F) := ⟨activeSum s μ (fun i => Prod.fst ⁻¹' A i),inferInstance⟩ + have hμ : μs ≠ 0 := by + intro h + have hz : (activeSum s μ (fun i => Prod.fst ⁻¹' A i)).real Set.univ = 0 := by + change (μs : Measure (Z × F)).real Set.univ = 0 + rw [h]; simp + linarith + have h := normalized_activeSum_kl_le s μ (fun i => (μ i).fst.prod π) hkl + (fun i => Prod.fst ⁻¹' A i) (fun i hi => (hA i hi).preimage measurable_fst) + (fun i hi => fresh_activeMass (μ i) π (A i) (hA i hi)) hpos + let νs : FiniteMeasure (Z × F) := ⟨activeSum s (fun i => (μ i).fst.prod π) + (fun i => Prod.fst ⁻¹' A i),inferInstance⟩ + let νs' : FiniteMeasure (Z × F) := ⟨(μs : Measure (Z × F)).fst.prod π,inferInstance⟩ + have heq : νs = νs' := by + apply Subtype.ext + exact fresh_activeSum s μ π A hA + change klDiv (μs.normalize : Measure (Z × F)) (νs.normalize : Measure (Z × F)) ≤ _ at h + rw [heq] at h + have hnorm : (νs'.normalize : Measure (Z × F)) = + (μs.normalize : Measure (Z × F)).fst.prod π := normalize_fst_prod μs π hμ + rw [hnorm] at h + exact h + +end DirectionalTransience.Entropy + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PairPrefix.lean b/lean/OAI/Probability/Ballisticity/Estimates/PairPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..003ba3d797ab3bd14bfb873e81b6e450dcbaa9be --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PairPrefix.lean @@ -0,0 +1,490 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CommonTrueRecord + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma ae_of_pair_prefix_probability_lower {d : ℕ} (μ : Measure (Path d × Path d)) + [IsFiniteMeasure μ] (E : Set (Path d × Path d)) (hE : MeasurableSet E) + (p : ℝ≥0∞) (hp : 0 < p) (hpt : p ≠ ∞) + (h : ∀ (n : ℕ) (f g : Path d), + p * μ (pathCylinder f n ×ˢ pathCylinder g n) ≤ + μ (E ∩ (pathCylinder f n ×ˢ pathCylinder g n))) : ∀ᵐ P ∂μ, P ∈ E := by + let e := MeasurableEquiv.arrowProdEquivProdArrow (Lattice d) (Lattice d) ℕ + let η := μ.map e.symm + have he : MeasurableSet (e ⁻¹' E) := hE.preimage e.measurable + have hh := ae_of_frestrict_probability_lower η (e ⁻¹' E) he p hp hpt + have hf (n : ℕ) (F : (i : Finset.Iic n) → (Lattice d × Lattice d)) : + e.symm ⁻¹' (Preorder.frestrictLe n ⁻¹' {F}) = + pathCylinder (extendPrefix n (fun j => (F j).1)) n ×ˢ + pathCylinder (extendPrefix n (fun j => (F j).2)) n := by + ext P + change (Preorder.frestrictLe n (e.symm P) = F) ↔ _ + constructor + · intro hF + constructor <;> intro j hj + · have hv := congrArg (fun G => (G ⟨j, Finset.mem_Iic.mpr hj⟩).1) hF + simpa [e, MeasurableEquiv.arrowProdEquivProdArrow, Equiv.arrowProdEquivProdArrow, + Preorder.frestrictLe, extendPrefix_apply n _ j hj] using hv + · have hv := congrArg (fun G => (G ⟨j, Finset.mem_Iic.mpr hj⟩).2) hF + simpa [e, MeasurableEquiv.arrowProdEquivProdArrow, Equiv.arrowProdEquivProdArrow, + Preorder.frestrictLe, extendPrefix_apply n _ j hj] using hv + · rintro ⟨h1,h2⟩ + funext j + apply Prod.ext + · simpa [e, MeasurableEquiv.arrowProdEquivProdArrow, Equiv.arrowProdEquivProdArrow, + Preorder.frestrictLe, extendPrefix_apply _ _ _ (Finset.mem_Iic.mp j.2)] using h1 j (Finset.mem_Iic.mp j.2) + · simpa [e, MeasurableEquiv.arrowProdEquivProdArrow, Equiv.arrowProdEquivProdArrow, + Preorder.frestrictLe, extendPrefix_apply _ _ _ (Finset.mem_Iic.mp j.2)] using h2 j (Finset.mem_Iic.mp j.2) + have hη : ∀ᵐ Z ∂η, Z ∈ e ⁻¹' E := hh (fun n F => by + rw [Measure.map_apply e.symm.measurable ((Preorder.measurable_frestrictLe n) + (measurableSet_singleton F)), + Measure.map_apply e.symm.measurable (he.inter ((Preorder.measurable_frestrictLe n) + (measurableSet_singleton F))), Set.preimage_inter, hf] + simpa only [Set.preimage_preimage, e.apply_symm_apply, Set.preimage_id'] using h n + (extendPrefix n (fun j => (F j).1)) (extendPrefix n (fun j => (F j).2))) + change ∀ᵐ Z ∂μ.map e.symm, Z ∈ e ⁻¹' E at hη + have hμ := (ae_map_iff e.symm.measurable.aemeasurable he).mp hη + simpa only [Set.mem_preimage, e.apply_symm_apply] using hμ + +lemma shared_pair_record_cylinder_noDrop {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (x y : Lattice d) + (f g : Path d) (n m : ℕ) (hn : 0 < n) (hm : 0 < m) + (hrf : StrictRecord ℓ f n) (hrg : StrictRecord ℓ g m) + (he : dot (realPosition (f n)) ℓ = dot (realPosition (g m)) ℓ) : + sharedPairLaw ν x y + (((fun X : Path d => fun j => X (n+j)) ⁻¹' NoDrop ℓ (f n) ∩ pathCylinder f n) ×ˢ + ((fun X : Path d => fun j => X (m+j)) ⁻¹' NoDrop ℓ (g m) ∩ pathCylinder g m)) = + sharedPairLaw ν x y (pathCylinder f n ×ˢ pathCylinder g m) * + sharedNoDropMass ν ℓ (f n) (g m) := by + have hAf := ((measurableSet_noDrop ℓ (f n)).preimage + (show Measurable (fun X : Path d => fun j => X (n+j)) by fun_prop)).inter + (measurableSet_pathCylinder f n) + have hAg := ((measurableSet_noDrop ℓ (g m)).preimage + (show Measurable (fun X : Path d => fun j => X (m+j)) by fun_prop)).inter + (measurableSet_pathCylinder g m) + rw [sharedPairLaw_rectangle ν x y _ _ hAf hAg, + sharedPairLaw_rectangle ν x y _ _ (measurableSet_pathCylinder f n) + (measurableSet_pathCylinder g m)] + by_cases hf : f 0 = x + · by_cases hg : g 0 = y + · let S : Set (Lattice d) := {z | (∃ j < n, z = f j) ∨ (∃ j < m, z = g j)} + let T := {z : Lattice d | dot (realPosition (f n)) ℓ ≤ dot (realPosition z) ℓ} + have hdis : Disjoint S T := by + apply Set.disjoint_left.mpr + rintro z (⟨j,hj,rfl⟩ | ⟨j,hj,rfl⟩) hz + · exact (not_le_of_gt (hrf j hj)) hz + · have hlt := hrg j hj + rw [← he] at hlt + exact (not_le_of_gt hlt) hz + have hfm : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => quenchedKernel (ω,x) (pathCylinder f n)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_pathCylinder f n)).comp + (measurable_id.prodMk measurable_const)) S x (Or.inl ⟨0,hn,hf.symm⟩) + intro ω η hωη + exact pathCylinder_weight_locality S ω η hωη x f n (fun j hj => Or.inl ⟨j,hj,rfl⟩) + have hgm : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => quenchedKernel (ω,y) (pathCylinder g m)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_pathCylinder g m)).comp + (measurable_id.prodMk measurable_const)) S y (Or.inr ⟨0,hm,hg.symm⟩) + intro ω η hωη + exact pathCylinder_weight_locality S ω η hωη y g m (fun j hj => Or.inr ⟨j,hj,rfl⟩) + have hnfm : @Measurable _ _ (rowSigma T) _ (noDropQuenched ℓ (f n)) := + measurable_noDropQuenched_rows ℓ (f n) + have hngm : @Measurable _ _ (rowSigma T) _ (noDropQuenched ℓ (g m)) := by + change @Measurable _ _ (rowSigma {z | dot (realPosition (f n)) ℓ ≤ dot (realPosition z) ℓ}) _ _ + rw [he] + exact measurable_noDropQuenched_rows ℓ (g m) + simp_rw [quenched_prefix_future _ _ _ hf n (measurableSet_noDrop ℓ (f n)), + quenched_prefix_future _ _ _ hg m (measurableSet_noDrop ℓ (g m)), mul_mul_mul_comm] + have hind := lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hdis) + (hfm.mul hgm) (hnfm.mul hngm) + simp only [Pi.mul_apply] at hind + exact hind + · have hz ω : quenchedKernel (ω,y) + ((fun X : Path d => fun j => X (m+j)) ⁻¹' NoDrop ℓ (g m) ∩ pathCylinder g m) = 0 := + measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero ω y g hg m) + simp only [hz, quenched_pathCylinder_zero _ _ _ hg m, mul_zero, lintegral_zero, zero_mul] + · have hz ω : quenchedKernel (ω,x) + ((fun X : Path d => fun j => X (n+j)) ⁻¹' NoDrop ℓ (f n) ∩ pathCylinder f n) = 0 := + measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero ω x f hf n) + simp only [hz, quenched_pathCylinder_zero _ _ _ hf n, zero_mul, lintegral_zero] + +def pairPrefix {d : ℕ} (n m : ℕ) (P : Path d × Path d) : + ((i : Finset.Iic n) → Lattice d) × ((i : Finset.Iic m) → Lattice d) := + (Preorder.frestrictLe n P.1, Preorder.frestrictLe m P.2) + +lemma measurable_pairPrefix {d : ℕ} (n m : ℕ) : Measurable (pairPrefix (d := d) n m) := + ((Preorder.measurable_frestrictLe n).comp measurable_fst).prodMk + ((Preorder.measurable_frestrictLe m).comp measurable_snd) + +lemma pairPrefix_fiber {d : ℕ} (n m : ℕ) + (F : ((i : Finset.Iic n) → Lattice d) × ((i : Finset.Iic m) → Lattice d)) : + pairPrefix n m ⁻¹' {F} = + pathCylinder (extendPrefix n F.1) n ×ˢ pathCylinder (extendPrefix m F.2) m := by + rw [← restrict_prefix_fiber, ← restrict_prefix_fiber] + ext P + simp only [Set.mem_preimage,Set.mem_singleton_iff,Set.mem_prod,pairPrefix,Prod.ext_iff] + +lemma measure_partition_pairprefix {d : ℕ} (μ : Measure (Path d × Path d)) + (A : Set (Path d × Path d)) (n m : ℕ) : + μ A = ∑' F : (((i : Finset.Iic n) → Lattice d) × ((i : Finset.Iic m) → Lattice d)), + μ (A ∩ (pathCylinder (extendPrefix n F.1) n ×ˢ pathCylinder (extendPrefix m F.2) m)) := by + have h := tsum_measure_preimage_singleton (μ := μ.restrict A) + (s := Set.univ) (Set.to_countable _) (f := pairPrefix (d := d) n m) + (fun F _ => (measurable_pairPrefix n m) (measurableSet_singleton F)) + simp only [Set.preimage_univ, Measure.restrict_apply MeasurableSet.univ, Set.univ_inter] at h + rw [tsum_subtype Set.univ (fun F => (μ.restrict A) (pairPrefix n m ⁻¹' {F})), + Set.indicator_univ] at h + rw [← h] + apply tsum_congr + intro F + rw [Measure.restrict_apply ((measurable_pairPrefix n m) (measurableSet_singleton F)), + pairPrefix_fiber, Set.inter_comm] + +def PairPrefixDetermined {d : ℕ} (n m : ℕ) (A : Set (Path d × Path d)) : Prop := + ∀ P Q, (∀ j ≤ n, P.1 j = Q.1 j) → (∀ k ≤ m, P.2 k = Q.2 k) → (P ∈ A ↔ Q ∈ A) + +lemma shared_pair_record_event_noDrop_lower {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (x y : Lattice d) + (c : ℝ≥0∞) (hc : ∀ u v, c ≤ sharedNoDropMass ν ℓ u v) + (n m : ℕ) (hn : 0 < n) (hm : 0 < m) (A : Set (Path d × Path d)) + (hA : PairPrefixDetermined n m A) + (hr : ∀ P ∈ A, StrictRecord ℓ P.1 n ∧ StrictRecord ℓ P.2 m ∧ + dot (realPosition (P.1 n)) ℓ = dot (realPosition (P.2 m)) ℓ) : + c * sharedPairLaw ν x y A ≤ + sharedPairLaw ν x y (A ∩ (FutureNoDrop ℓ n ×ˢ FutureNoDrop ℓ m)) := by + classical + rw [measure_partition_pairprefix (sharedPairLaw ν x y) A n m, + measure_partition_pairprefix (sharedPairLaw ν x y) (A ∩ _) n m, + ← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro F + let P : Path d × Path d := (extendPrefix n F.1,extendPrefix m F.2) + let C := pathCylinder P.1 n ×ˢ pathCylinder P.2 m + by_cases hP : P ∈ A + · have hAc : A ∩ C = C := Set.inter_eq_right.mpr fun Q hQ => (hA Q P hQ.1 hQ.2).mpr hP + have he : (A ∩ (FutureNoDrop ℓ n ×ˢ FutureNoDrop ℓ m)) ∩ C = + (((fun X : Path d => fun j => X (n+j)) ⁻¹' NoDrop ℓ (P.1 n) ∩ pathCylinder P.1 n) ×ˢ + ((fun X : Path d => fun j => X (m+j)) ⁻¹' NoDrop ℓ (P.2 m) ∩ pathCylinder P.2 m)) := by + ext Q + constructor + · rintro ⟨⟨_,h1,h2⟩,hc1,hc2⟩ + refine ⟨⟨?_,hc1⟩,⟨?_,hc2⟩⟩ + · intro j; rw [← hc1 n le_rfl]; exact h1 j + · intro j; rw [← hc2 m le_rfl]; exact h2 j + · rintro ⟨⟨h1,hc1⟩,⟨h2,hc2⟩⟩ + refine ⟨⟨(hA Q P hc1 hc2).mpr hP,?_,?_⟩,hc1,hc2⟩ + · intro j; rw [hc1 n le_rfl]; exact h1 j + · intro j; rw [hc2 m le_rfl]; exact h2 j + change c * sharedPairLaw ν x y (A ∩ C) ≤ sharedPairLaw ν x y ((A ∩ _) ∩ C) + rw [hAc,he,shared_pair_record_cylinder_noDrop ν ℓ x y P.1 P.2 n m hn hm + (hr P hP).1 (hr P hP).2.1 (hr P hP).2.2] + simpa only [mul_comm] using mul_le_mul_right (hc (P.1 n) (P.2 m)) (sharedPairLaw ν x y C) + · have hAc : A ∩ C = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro Q ⟨hQ,hqc1,hqc2⟩ + exact hP ((hA Q P hqc1 hqc2).mp hQ) + change c * sharedPairLaw ν x y (A ∩ C) ≤ _ + rw [hAc,measure_empty,mul_zero] + exact zero_le + +lemma annealedFrom_ae_of_quenched {d : ℕ} (ν : Measure (Row d)) (x : Lattice d) + (A : Set (Path d)) (hA : MeasurableSet A) + (h : ∀ᵐ ω ∂environmentLaw ν, ∀ᵐ X ∂quenchedKernel (ω,x), X ∈ A) : + ∀ᵐ X ∂annealedFrom ν x, X ∈ A := by + rw [ae_iff] + change annealedFrom ν x Aᶜ = 0 + rw [annealedFrom_apply ν x Aᶜ hA.compl] + apply lintegral_eq_zero_of_ae_eq_zero + filter_upwards [h] with ω hω + exact ae_iff.mp hω + +lemma sharedPairLaw_fst {d : ℕ} (ν : Measure (Row d)) (x y : Lattice d) : + (sharedPairLaw ν x y).map Prod.fst = annealedFrom ν x := by + apply Measure.ext + intro A hA + rw [Measure.map_apply measurable_fst hA] + have he : Prod.fst ⁻¹' A = A ×ˢ (Set.univ : Set (Path d)) := by ext P; simp + rw [he,sharedPairLaw_rectangle ν x y A Set.univ hA MeasurableSet.univ, + annealedFrom_apply ν x A hA] + simp only [measure_univ,mul_one] + +lemma sharedPairLaw_snd {d : ℕ} (ν : Measure (Row d)) (x y : Lattice d) : + (sharedPairLaw ν x y).map Prod.snd = annealedFrom ν y := by + apply Measure.ext + intro A hA + rw [Measure.map_apply measurable_snd hA] + have he : Prod.snd ⁻¹' A = (Set.univ : Set (Path d)) ×ˢ A := by ext P; simp + rw [he,sharedPairLaw_rectangle ν x y Set.univ A MeasurableSet.univ hA, + annealedFrom_apply ν y A hA] + simp only [measure_univ,one_mul] + +lemma shared_pair_ae {d : ℕ} (ν : Measure (Row d)) (x y : Lattice d) + (A B : Set (Path d)) (hA : MeasurableSet A) (hB : MeasurableSet B) + (ha : ∀ᵐ X ∂annealedFrom ν x, X ∈ A) (hb : ∀ᵐ Y ∂annealedFrom ν y, Y ∈ B) : + ∀ᵐ P ∂sharedPairLaw ν x y, P.1 ∈ A ∧ P.2 ∈ B := by + rw [← sharedPairLaw_fst ν x y] at ha + rw [← sharedPairLaw_snd ν x y] at hb + exact ((ae_map_iff measurable_fst.aemeasurable hA).mp ha).and + ((ae_map_iff measurable_snd.aemeasurable hB).mp hb) + +def FirstLayerHit {d : ℕ} (h : Lattice d → ℤ) (H : ℤ) (n : ℕ) : Set (Path d) := + {X | h (X n) = H ∧ ∀ j < n, h (X j) < H} + +lemma measurableSet_firstLayerHit {d : ℕ} (h : Lattice d → ℤ) (H : ℤ) (n : ℕ) : + MeasurableSet (FirstLayerHit h H n) := by + simp only [FirstLayerHit,Set.ofPred_and,Set.ofPred_forall] + exact (measurableSet_eq_fun ((measurable_of_countable h).comp (measurable_pi_apply n)) + measurable_const).inter (MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + measurableSet_lt ((measurable_of_countable h).comp (measurable_pi_apply j)) measurable_const) + +lemma firstLayerHit_prefix {d : ℕ} (h : Lattice d → ℤ) (H : ℤ) (n : ℕ) : + PrefixDetermined n (FirstLayerHit h H n) := by + intro X Y hXY + simp only [FirstLayerHit,Set.mem_ofPred_eq,hXY n le_rfl] + apply and_congr Iff.rfl + exact forall_congr' fun j => forall_congr' fun hj => by rw [hXY j hj.le] + +lemma firstLayerHit_disjoint {d : ℕ} (h : Lattice d → ℤ) (H : ℤ) : + Pairwise (fun n m => Disjoint (FirstLayerHit h H n) (FirstLayerHit h H m)) := by + intro n m hnm + apply Set.disjoint_left.mpr + intro X hn hm + rcases lt_or_gt_of_ne hnm with hnlt | hmlt + · have hi := hm.2 n hnlt + rw [hn.1] at hi + exact (lt_irrefl _) hi + · have hi := hn.2 m hmlt + rw [hm.1] at hi + exact (lt_irrefl _) hi + +lemma firstLayerHit_record {d : ℕ} (ℓ : Vector d) (h : Lattice d → ℤ) + (hproj : ∀ x, dot (realPosition x) ℓ = (h x : ℝ)) (H : ℤ) (n : ℕ) + (X : Path d) (hX : X ∈ FirstLayerHit h H n) : StrictRecord ℓ X n := by + intro j hj + rw [hproj,hproj,hX.1] + exact_mod_cast hX.2 j hj + +lemma firstLayerHit_exists {d : ℕ} (h : Lattice d → ℤ) + (hstep : ∀ x e, h (x+step e) ≤ h x+1) (X : Path d) + (hnn : ∀ n, ∃ e, X (n+1) = X n+step e) + (ht : Tendsto (fun n => (h (X n) : ℝ)) atTop atTop) + (H : ℤ) (h0 : h (X 0) < H) : ∃ n, X ∈ FirstLayerHit h H n := by + classical + have hge : ∀ᶠ n : ℕ in atTop, (H : ℝ) ≤ (h (X n) : ℝ) := + ht.eventually (eventually_ge_atTop _) + obtain ⟨k,hk⟩ := hge.exists + have he : ∃ n, H ≤ h (X n) := ⟨k, by exact_mod_cast hk⟩ + let n := Nat.find he + have hn : H ≤ h (X n) := Nat.find_spec he + have hb : ∀ j < n, h (X j) < H := fun j hj => lt_of_not_ge (Nat.find_min he hj) + have hn0 : 0 < n := by + by_contra hh + have hz : n = 0 := by omega + rw [hz] at hn + omega + obtain ⟨e,he⟩ := hnn (n-1) + have hprev := hb (n-1) (by omega) + have hinc := hstep (X (n-1)) e + rw [← he,show n-1+1 = n by omega] at hinc + exact ⟨n,by omega,hb⟩ + +lemma firstLayerHit_after_prefix {d : ℕ} (h : Lattice d → ℤ) (H : ℤ) + (X : Path d) (N : ℕ) (hp : ∀ j ≤ N, h (X j) < H) + {n : ℕ} (hn : X ∈ FirstLayerHit h H n) : N < n := by + by_contra hh + have hl := hp n (by omega) + rw [hn.1] at hl + exact (lt_irrefl _) hl + +lemma shared_pair_layer_hits {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) + (x y : Lattice d) (H : ℤ) (hx : height x < H) (hy : height y < H) : + ∀ᵐ P ∂sharedPairLaw ν x y, + (∃ n, P.1 ∈ FirstLayerHit height H n) ∧ (∃ m, P.2 ∈ FirstLayerHit height H m) := by + let A := {X : Path d | ∃ n, X ∈ FirstLayerHit height H n} + have hA : MeasurableSet A := by + simp only [A,Set.ofPred_exists] + exact MeasurableSet.iUnion (measurableSet_firstLayerHit height H) + apply shared_pair_ae ν x y A A hA hA + all_goals + apply annealedFrom_ae_of_quenched ν _ A hA + filter_upwards [quenched_directionallyTransient_ae ν ℓ htrans] with ω hω + · filter_upwards [hω x,quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X ht h0 hnn + exact firstLayerHit_exists height hstep X hnn (by simpa only [TransientPaths,Set.mem_ofPred_eq,hproj] using ht) + H (by simpa only [h0] using hx) + · filter_upwards [hω y,quenched_initial_ae (ω,y),quenched_nearest_neighbor (ω,y)] with Y ht h0 hnn + exact firstLayerHit_exists height hstep Y hnn (by simpa only [TransientPaths,Set.mem_ofPred_eq,hproj] using ht) + H (by simpa only [h0] using hy) + +def CommonTrueAbove {d : ℕ} (ℓ : Vector d) (K : ℤ) : Set (Path d × Path d) := + {P | ∃ n m, (K : ℝ) < dot (realPosition (P.1 n)) ℓ ∧ CommonTrueRecord ℓ P n m} + +lemma measurableSet_commonTrueAbove {d : ℕ} (ℓ : Vector d) (K : ℤ) : + MeasurableSet (CommonTrueAbove ℓ K) := by + simp only [CommonTrueAbove,Set.ofPred_exists,Set.ofPred_and] + apply MeasurableSet.iUnion + intro n + apply MeasurableSet.iUnion + intro m + exact (measurableSet_lt measurable_const ((measurable_of_countable (fun z : Lattice d => dot (realPosition z) ℓ)).comp + ((measurable_pi_apply n).comp measurable_fst))).inter + (measurableSet_commonTrueRecord ℓ n m) + +lemma finite_pair_prefix_height_bound {d : ℕ} (height : Lattice d → ℤ) + (f g : Path d) (N : ℕ) (K : ℤ) (x y : Lattice d) : + ∃ H : ℤ, K < H ∧ height x < H ∧ height y < H ∧ + ∀ j ≤ N, height (f j) < H ∧ height (g j) < H := by + induction N with + | zero => + let H := max K (max (height x) (max (height y) (max (height (f 0)) (height (g 0)))))+1 + refine ⟨H,?_,?_,?_,?_⟩ + · dsimp [H]; omega + · dsimp [H]; omega + · dsimp [H]; omega + · intro j hj + have : j = 0 := by omega + subst j + dsimp [H]; omega + | succ N ih => + obtain ⟨B,hK,hx,hy,hB⟩ := ih + let H := max B (max (height (f (N+1))) (height (g (N+1))))+1 + have hBH : B < H := by dsimp [H]; omega + refine ⟨H,hK.trans hBH,hx.trans hBH,hy.trans hBH,?_⟩ + intro j hj + by_cases hjN : j ≤ N + · exact ⟨(hB j hjN).1.trans hBH,(hB j hjN).2.trans hBH⟩ + · have : j = N+1 := by omega + subst j + dsimp [H]; omega + +lemma pairPrefixDetermined_inter {d : ℕ} {n m : ℕ} {A B : Set (Path d × Path d)} + (hA : PairPrefixDetermined n m A) (hB : PairPrefixDetermined n m B) : + PairPrefixDetermined n m (A ∩ B) := by + intro P Q hf hg + exact and_congr (hA P Q hf hg) (hB P Q hf hg) + +lemma pairPrefixDetermined_product {d : ℕ} {n m : ℕ} {A B : Set (Path d)} + (hA : PrefixDetermined n A) (hB : PrefixDetermined m B) : + PairPrefixDetermined n m (A ×ˢ B) := by + intro P Q hf hg + exact and_congr (hA P.1 Q.1 hf) (hB P.2 Q.2 hg) + +lemma prefixDetermined_cylinder_of_le {d : ℕ} (f : Path d) {N n : ℕ} (hN : N ≤ n) : + PrefixDetermined n (pathCylinder f N) := by + intro X Y hXY + constructor + · intro hX j hj + exact (hXY j (hj.trans hN)).symm.trans (hX j hj) + · intro hY j hj + exact (hXY j (hj.trans hN)).trans (hY j hj) + +lemma firstLayerHit_pair_disjoint {d : ℕ} (height : Lattice d → ℤ) (H : ℤ) : + Pairwise (fun q r : ℕ × ℕ => Disjoint + (FirstLayerHit height H q.1 ×ˢ FirstLayerHit height H q.2) + (FirstLayerHit height H r.1 ×ˢ FirstLayerHit height H r.2)) := by + intro q r hqr + apply Set.disjoint_left.mpr + rintro P ⟨h1,h2⟩ ⟨h3,h4⟩ + by_cases hq : q.1 = r.1 + · have hq2 : q.2 ≠ r.2 := fun hq2 => hqr (Prod.ext hq hq2) + exact Set.disjoint_left.mp (firstLayerHit_disjoint height H hq2) h2 h4 + · exact Set.disjoint_left.mp (firstLayerHit_disjoint height H hq) h1 h3 + +lemma shared_pair_common_true_after_prefix {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) + (x y : Lattice d) (c : ℝ≥0∞) (hc : ∀ u v, c ≤ sharedNoDropMass ν ℓ u v) + (K : ℤ) (N : ℕ) (f g : Path d) : + c * sharedPairLaw ν x y (pathCylinder f N ×ˢ pathCylinder g N) ≤ + sharedPairLaw ν x y (CommonTrueAbove ℓ K ∩ (pathCylinder f N ×ˢ pathCylinder g N)) := by + classical + let μ := sharedPairLaw ν x y + let C := pathCylinder f N ×ˢ pathCylinder g N + obtain ⟨H,hKH,hx,hy,hH⟩ := finite_pair_prefix_height_bound height f g N K x y + let A (q : ℕ × ℕ) := C ∩ (FirstLayerHit height H q.1 ×ˢ FirstLayerHit height H q.2) + let B (q : ℕ × ℕ) := A q ∩ (FutureNoDrop ℓ q.1 ×ˢ FutureNoDrop ℓ q.2) + have hdisA : Pairwise (fun q r => Disjoint (A q) (A r)) := fun q r hqr => + (firstLayerHit_pair_disjoint height H hqr).mono Set.inter_subset_right Set.inter_subset_right + have hdisB : Pairwise (fun q r => Disjoint (B q) (B r)) := fun q r hqr => + (hdisA hqr).mono Set.inter_subset_left Set.inter_subset_left + have hmA (q : ℕ × ℕ) : MeasurableSet (A q) := + ((measurableSet_pathCylinder f N).prod (measurableSet_pathCylinder g N)).inter + ((measurableSet_firstLayerHit height H q.1).prod (measurableSet_firstLayerHit height H q.2)) + have hmB (q : ℕ × ℕ) : MeasurableSet (B q) := (hmA q).inter + ((measurableSet_futureNoDrop ℓ q.1).prod (measurableSet_futureNoDrop ℓ q.2)) + have hcover : μ C = ∑' q, μ (A q) := by + rw [← measure_iUnion hdisA hmA] + apply measure_congr + filter_upwards [shared_pair_layer_hits ν ℓ htrans height hproj hstep x y H hx hy] with P hP + apply propext + change P ∈ C ↔ P ∈ ⋃ q, A q + simp only [Set.mem_iUnion] + constructor + · intro hC + obtain ⟨n,hn⟩ := hP.1 + obtain ⟨m,hm⟩ := hP.2 + exact ⟨(n,m),hC,hn,hm⟩ + · rintro ⟨q,hq⟩ + exact hq.1 + have hindices (q : ℕ × ℕ) (P : Path d × Path d) (hP : P ∈ A q) : + N < q.1 ∧ N < q.2 := by + constructor + · apply firstLayerHit_after_prefix height H P.1 N _ hP.2.1 + intro j hj + rw [hP.1.1 j hj] + exact (hH j hj).1 + · apply firstLayerHit_after_prefix height H P.2 N _ hP.2.2 + intro j hj + rw [hP.1.2 j hj] + exact (hH j hj).2 + have hlower (q : ℕ × ℕ) : c * μ (A q) ≤ μ (B q) := by + by_cases hne : (A q).Nonempty + · obtain ⟨P,hP⟩ := hne + have hi := hindices q P hP + apply shared_pair_record_event_noDrop_lower ν ℓ x y c hc q.1 q.2 + (lt_of_le_of_lt (Nat.zero_le _) hi.1) (lt_of_le_of_lt (Nat.zero_le _) hi.2) + · exact pairPrefixDetermined_inter + (pairPrefixDetermined_product (prefixDetermined_cylinder_of_le f hi.1.le) + (prefixDetermined_cylinder_of_le g hi.2.le)) + (pairPrefixDetermined_product (firstLayerHit_prefix height H q.1) (firstLayerHit_prefix height H q.2)) + · intro Q hQ + refine ⟨firstLayerHit_record ℓ height hproj H q.1 Q.1 hQ.2.1, + firstLayerHit_record ℓ height hproj H q.2 Q.2 hQ.2.2,?_⟩ + rw [hproj,hproj,hQ.2.1.1,hQ.2.2.1] + · have hz : A q = ∅ := Set.not_nonempty_iff_eq_empty.mp hne + rw [hz,measure_empty,mul_zero] + exact zero_le + have hsub : (⋃ q, B q) ⊆ CommonTrueAbove ℓ K ∩ C := by + intro P hP + obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hP + refine ⟨⟨q.1,q.2,?_,?_⟩,hq.1.1⟩ + · rw [hproj,hq.1.2.1.1] + exact_mod_cast hKH + · refine ⟨?_,?_,?_⟩ + · exact ⟨firstLayerHit_record ℓ height hproj H q.1 P.1 hq.1.2.1,hq.2.1⟩ + · exact ⟨firstLayerHit_record ℓ height hproj H q.2 P.2 hq.1.2.2,hq.2.2⟩ + · rw [hproj,hproj,hq.1.2.1.1,hq.1.2.2.1] + calc + c * μ C = ∑' q, c * μ (A q) := by rw [hcover,ENNReal.tsum_mul_left] + _ ≤ ∑' q, μ (B q) := ENNReal.tsum_le_tsum hlower + _ = μ (⋃ q, B q) := (measure_iUnion hdisB hmB).symm + _ ≤ μ (CommonTrueAbove ℓ K ∩ C) := measure_mono hsub + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PairUpwardRetention.lean b/lean/OAI/Probability/Ballisticity/Estimates/PairUpwardRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f7cbdfd916f1c5f547ab747358df1838b6907cf --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PairUpwardRetention.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RawPairRetention +import OAI.Probability.Ballisticity.Crossings.FirstHitUpward + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def pairUp {d : ℕ} (e : Direction d) (x : Lattice d × Lattice d) : Lattice d × Lattice d := + (x.1+step e,x.2+step e) + +lemma rawPairEndpointLaw_upward {d : ℕ} (e : Direction d) + (H : ℕ) (ω : Environment d) (x : Lattice d × Lattice d) + {κ : ℝ≥0} (hκ : ∀ y, κ ≤ (ω y).1 e) : + (κ : ℝ≥0∞)^2 • (rawPairEndpointLaw (realPosition (step e)) H ω x).map (pairUp e) ≤ + rawPairEndpointLaw (realPosition (step e)) (H+1) ω x := by + let ℓ := realPosition (step e) + have hfinite (y : Lattice d) (h : ℕ) : + IsFiniteMeasure (hitKernel (Strip ℓ y h) (Upper ℓ y h) (ω,y)) := + ⟨lt_of_le_of_lt (hitKernel_total_le_one (disjoint_strip_upper _ _ _) _) ENNReal.one_lt_top⟩ + let := hfinite x.1 H + let := hfinite x.2 H + let := hfinite x.1 (H+1) + let := hfinite x.2 (H+1) + have hp := Measure.prod_mono (coordinate_hitKernel_upward_retention e x.1 H ω hκ) + (coordinate_hitKernel_upward_retention e x.2 H ω hκ) + rw [Measure.prod_smul_left,Measure.prod_smul_right,smul_smul,←pow_two, + Measure.map_prod_map _ _ (measurable_of_countable _) (measurable_of_countable _)] at hp + unfold pairUp + simpa only [rawPairEndpointLaw,Prod.map_def,Nat.cast_add,Nat.cast_one] using hp + +lemma rawPairMixture_upward {d : ℕ} (e : Direction d) (H : ℕ) + (ω : Environment d) (π : Measure (Lattice d × Lattice d)) + {κ : ℝ≥0} (hκ : ∀ y, κ ≤ (ω y).1 e) : + (κ : ℝ≥0∞)^2 • (rawPairMixture (realPosition (step e)) H π ω).map (pairUp e) ≤ + rawPairMixture (realPosition (step e)) (H+1) π ω := by + intro U + have hU := (Set.to_countable U).measurableSet + have hm : Measurable (pairUp e) := measurable_of_countable _ + rw [Measure.smul_apply,smul_eq_mul,Measure.map_apply hm hU,rawPairMixture_apply, + ←lintegral_const_mul _ (measurable_of_countable _),rawPairMixture_apply] + apply lintegral_mono + intro x + have hh := rawPairEndpointLaw_upward e H ω x hκ U + rwa [Measure.smul_apply,smul_eq_mul,Measure.map_apply hm hU] at hh + +lemma pairUp_preserves_gap {d : ℕ} (e f : Direction d) (x : Lattice d × Lattice d) : + signedCoordinate f ((pairUp e x).2-(pairUp e x).1) = signedCoordinate f (x.2-x.1) := by + dsimp [pairUp] + congr 1 + abel + +noncomputable def upwardRetainedLaw {d : ℕ} (e f : Direction d) (H : ℕ) (z : ℝ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) (κ : ℝ≥0) : + Measure (Lattice d × Lattice d) := + (κ : ℝ≥0∞)^2 • (retainedPairLaw (realPosition (step e)) f H z π ω).map (pairUp e) + +lemma upwardRetainedLaw_le {d : ℕ} (e f : Direction d) (H : ℕ) (z : ℝ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y, κ ≤ (ω y).1 e) : + upwardRetainedLaw e f H z π ω κ ≤ rawPairMixture (realPosition (step e)) (H+1) π ω := by + apply le_trans _ (rawPairMixture_upward e H ω π hκ) + intro U + have hU := (Set.to_countable U).measurableSet + simp only [upwardRetainedLaw,Measure.smul_apply,smul_eq_mul, + Measure.map_apply (measurable_of_countable _) hU] + exact mul_le_mul_right (retainedPairLaw_le _ _ _ _ _ _ _) _ + +lemma upwardRetainedLaw_mass {d : ℕ} (e f : Direction d) (H : ℕ) (z : ℝ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) (κ : ℝ≥0) : + upwardRetainedLaw e f H z π ω κ Set.univ = + (κ : ℝ≥0∞)^2 * pairKernelMass (realPosition (step e)) f H z π ω := by + simp only [upwardRetainedLaw,Measure.smul_apply,smul_eq_mul, + Measure.map_apply (measurable_of_countable _) MeasurableSet.univ, + Set.preimage_univ,retainedPairLaw_mass] + +lemma upwardRetainedLaw_support {d : ℕ} (e f : Direction d) (H : ℕ) (z : ℝ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) (κ : ℝ≥0) : + ∀ᵐ y ∂upwardRetainedLaw e f H z π ω κ, z ≤ signedCoordinate f (y.2-y.1) := by + unfold upwardRetainedLaw + apply Measure.ae_smul_measure + rw [ae_map_iff (measurable_of_countable _).aemeasurable (measurableSet_le measurable_const (measurable_of_countable _))] + simpa only [pairUp_preserves_gap] using retainedPairLaw_support (realPosition (step e)) f H z π ω +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PairWeakUniqueness.lean b/lean/OAI/Probability/Ballisticity/Estimates/PairWeakUniqueness.lean new file mode 100644 index 0000000000000000000000000000000000000000..85e37ad6bd79ab8bafdd8fce1d109d796833262b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PairWeakUniqueness.lean @@ -0,0 +1,53 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GridLinear + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma weak_limit_of_tight_identification {E : Type*} [MetricSpace E] [CompleteSpace E] + [SecondCountableTopology E] [MeasurableSpace E] [BorelSpace E] + (μ : ℕ → ProbabilityMeasure E) (W : ProbabilityMeasure E) + (ht : IsTightMeasureSet (Set.range (fun i => (μ i : Measure E)))) + (hid : ∀ (j : ℕ → ℕ), Tendsto j atTop atTop → ∀ V : ProbabilityMeasure E, + Tendsto (μ ∘ j) atTop (𝓝 V) → V=W) : Tendsto μ atTop (𝓝 W) := by + have hc : IsCompact (closure (Set.range μ)) := isCompact_closure_of_isTightMeasureSet (by + convert ht using 1 + ext x + simp) + apply Filter.tendsto_of_subseq_tendsto + intro j hj + obtain ⟨V,hV,k,hk,hlim⟩ := hc.tendsto_subseq (fun n => subset_closure (Set.mem_range_self (j n))) + have he := hid (j ∘ k) (hj.comp hk.tendsto_atTop) V hlim + exact ⟨k,he ▸ hlim⟩ + +lemma pair_weak_tight {E F : Type*} + [MetricSpace E] [CompleteSpace E] [SecondCountableTopology E] [MeasurableSpace E] [BorelSpace E] + [MetricSpace F] [CompleteSpace F] [SecondCountableTopology F] [MeasurableSpace F] [BorelSpace F] + (μ : ℕ → ProbabilityMeasure (E × F)) (W : ProbabilityMeasure E) (V : ProbabilityMeasure F) + (hf : Tendsto (fun i => (μ i).map Prod.fst) atTop (𝓝 W)) + (hg : Tendsto (fun i => (μ i).map Prod.snd) atTop (𝓝 V)) : + IsTightMeasureSet (Set.range (fun i => (μ i : Measure (E × F)))) := by + apply IsTightMeasureSet.prodMk + · convert weak_sequence_tight hf using 1 + ext M + simp only [Set.mem_image,Set.mem_range,exists_exists_eq_and,Measure.fst] + rfl + · convert weak_sequence_tight hg using 1 + ext M + simp only [Set.mem_image,Set.mem_range,exists_exists_eq_and,Measure.snd] + rfl + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PastPhaseExtension.lean b/lean/OAI/Probability/Ballisticity/Estimates/PastPhaseExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e492665c98434ac268458e5b0141f647acbca5a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PastPhaseExtension.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.NormalLinearPast + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma charPhase_continuous : Continuous charPhase := by unfold charPhase; fun_prop + +noncomputable def phaseAugmentedTimes {q : ℕ} (v : Fin q → unitInterval) (s u : unitInterval) : + Fin (q+2) → unitInterval := Fin.cons u (Fin.cons s v) + +noncomputable def phaseAugmentedTest {q : ℕ} (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + (Fin (q+2) → ℝ × ℝ) →ᵇ ℂ := + BoundedContinuousFunction.mkOfBound + ⟨fun z => F (fun i => z i.succ.succ)* + charPhase (a*((z 0).1-(z 1).1)+b*((z 0).2-(z 1).2)),by + apply Continuous.mul (F.continuous.comp (by fun_prop)) + exact charPhase_continuous.comp (by fun_prop)⟩ (2*‖F‖) (by + intro x y + calc + _ ≤ ‖F (fun i => x i.succ.succ)*charPhase (a*((x 0).1-(x 1).1)+b*((x 0).2-(x 1).2))‖+ + ‖F (fun i => y i.succ.succ)*charPhase (a*((y 0).1-(y 1).1)+b*((y 0).2-(y 1).2))‖ := by rw [dist_eq_norm]; exact norm_sub_le _ _ + _ ≤ _ := by + rw [norm_mul,norm_mul,charPhase_norm,charPhase_norm,mul_one,mul_one] + nlinarith only [F.norm_coe_le_norm (fun i => x i.succ.succ),F.norm_coe_le_norm (fun i => y i.succ.succ)]) + +lemma phaseAugmentedTest_norm {q : ℕ} (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) : + ‖phaseAugmentedTest F a b‖ ≤ ‖F‖ := by + apply (BoundedContinuousFunction.norm_le (norm_nonneg F)).mpr + intro z + change ‖F (fun i => z i.succ.succ)*charPhase _‖ ≤ ‖F‖ + rw [norm_mul,charPhase_norm,mul_one] + exact F.norm_coe_le_norm _ + +lemma phaseAugmentedTest_eval {q : ℕ} (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) + (v : Fin q → unitInterval) (s u : unitInterval) (P : RealPathPair) : + phaseAugmentedTest F a b (pairPastCoordinates (phaseAugmentedTimes v s u) P)= + F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s u P) := by + simp [phaseAugmentedTest,phaseAugmentedTimes,pairPastCoordinates,pairLinearIncrement, + pairPathIncrement,Fin.cons_zero,Fin.cons_succ] + +lemma phaseAugmentedTimes_le {q : ℕ} (v : Fin q → unitInterval) (s u : unitInterval) + (hv : ∀ z,v z ≤ s) (hsu : s ≤ u) : ∀ z,phaseAugmentedTimes v s u z ≤ u := by + intro z + refine Fin.cases ?_ (fun z => ?_) z + · exact le_rfl + · refine Fin.cases ?_ (fun z => ?_) z + · exact hsu + · exact (hv z).trans hsu + +lemma pairLinearIncrement_add (a b : ℝ) (s u t : unitInterval) (P : RealPathPair) : + pairLinearIncrement a b s u P+pairLinearIncrement a b u t P=pairLinearIncrement a b s t P := by + simp only [pairLinearIncrement,pairPathIncrement,ContinuousMap.coe_mk,Bool.false_eq_true, + ↓reduceIte] + ring + +lemma phaseAugmentedTest_mul {q : ℕ} (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) + (v : Fin q → unitInterval) (s u t : unitInterval) (P : RealPathPair) : + phaseAugmentedTest F a b (pairPastCoordinates (phaseAugmentedTimes v s u) P)* + charPhase (pairLinearIncrement a b u t P)= + F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) := by + rw [phaseAugmentedTest_eval,mul_assoc,← charPhase_add,pairLinearIncrement_add] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +noncomputable def jointTaylorCoeff (a b : ℝ) : ℝ := + 8*charTaylorConstant*(|a|+|b|)^3*normalThirdMoment+8*|a*b| *normalThirdMoment + +lemma jointTaylorCoeff_nonneg (a b : ℝ) : 0 ≤ jointTaylorCoeff a b := by + have hT := charTaylorConstant_nonneg + have hM := normalThirdMoment_nonneg + unfold jointTaylorCoeff + positivity + +lemma normalJointPast_phase_step {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + {A K : ℝ} (hK : 0 ≤ K) (hcross : SeparatedCrossBound μ A K) + (v : Fin q → unitInterval) (s t : unitInterval) (hv : ∀ z, v z ≤ s) + (hst : s < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) + {ρ : ℝ} (hρ : 0 < ρ) : + ‖(∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)- + (1-(((c:ℝ)*((t:ℝ)-s)*(a^2+b^2)/2:ℝ):ℂ))*(∫ P, F (pairPastCoordinates v P) ∂μ)‖ ≤ + ‖F‖*(2*|a*b| *K*Real.exp (-A*ρ^2/((t:ℝ)-s))+ + jointTaylorCoeff a b*(Real.sqrt ((c:ℝ)*((t:ℝ)-s)))^3+ + 2*|a*b| *(c:ℝ)*((t:ℝ)-s)*(∫ P, nearDiagonalCutoff ρ (P.1 s-P.2 s) ∂μ)) := by + have htay := normalJointPast_taylor_error μ c h v s t hv hst ht F a b + have hcr := normalJointPast_complex_cross_bound μ c h hK hcross v s t hv hst ht F hρ + let Z := ∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ + let W := (1-(((c:ℝ)*((t:ℝ)-s)*(a^2+b^2)/2:ℝ):ℂ))*(∫ P, F (pairPastCoordinates v P) ∂μ) + let Q := ∫ P, F (pairPastCoordinates v P)* + ((pairPathIncrement false s t P*pairPathIncrement true s t P:ℝ):ℂ) ∂μ + have hid : Z-W=(Z-(W-(a:ℂ)*b*Q))-(a:ℂ)*b*Q := by ring + change ‖Z-W‖ ≤ _ + rw [hid] + have hn := norm_sub_le (Z-(W-(a:ℂ)*b*Q)) ((a:ℂ)*b*Q) + have hm : ‖(a:ℂ)*b*Q‖=|a*b| *‖Q‖ := by + simp only [norm_mul,Complex.norm_real,Real.norm_eq_abs,abs_mul] + rw [hm] at hn + have hcr' := mul_le_mul_of_nonneg_left hcr (abs_nonneg (a*b)) + change ‖Z-(W-(a:ℂ)*b*Q)‖ ≤ _ at htay + change |a*b| *‖Q‖ ≤ _ at hcr' + unfold jointTaylorCoeff + nlinarith only [hn,htay,hcr'] + +lemma normalJointPast_cumulative_phase_step {q : ℕ} + (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + {A K : ℝ} (hK : 0 ≤ K) (hcross : SeparatedCrossBound μ A K) + (v : Fin q → unitInterval) (s u t : unitInterval) (hv : ∀ z, v z ≤ s) (hsu : s ≤ u) + (hut : u < t) (ht : (t:ℝ) < 1) (F : (Fin q → ℝ × ℝ) →ᵇ ℂ) (a b : ℝ) + {ρ : ℝ} (hρ : 0 < ρ) : + ‖(∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s t P) ∂μ)- + (1-(((c:ℝ)*((t:ℝ)-u)*(a^2+b^2)/2:ℝ):ℂ))* + (∫ P, F (pairPastCoordinates v P)*charPhase (pairLinearIncrement a b s u P) ∂μ)‖ ≤ + ‖F‖*(2*|a*b| *K*Real.exp (-A*ρ^2/((t:ℝ)-u))+ + jointTaylorCoeff a b*(Real.sqrt ((c:ℝ)*((t:ℝ)-u)))^3+ + 2*|a*b| *(c:ℝ)*((t:ℝ)-u)*(∫ P, nearDiagonalCutoff ρ (P.1 u-P.2 u) ∂μ)) := by + have hh := normalJointPast_phase_step μ c h hK hcross (phaseAugmentedTimes v s u) u t + (phaseAugmentedTimes_le v s u hv hsu) hut ht (phaseAugmentedTest F a b) a b hρ + simp only [phaseAugmentedTest_eval,mul_assoc,← charPhase_add,pairLinearIncrement_add] at hh + have hpos : 0 ≤ 2*|a*b| *K*Real.exp (-A*ρ^2/((t:ℝ)-u))+ + jointTaylorCoeff a b*(Real.sqrt ((c:ℝ)*((t:ℝ)-u)))^3+ + 2*|a*b| *(c:ℝ)*((t:ℝ)-u)*(∫ P : RealPathPair, nearDiagonalCutoff ρ (P.1 u-P.2 u) ∂μ) := by + have hM := jointTaylorCoeff_nonneg a b + have hd : 0 ≤ (t:ℝ)-u := sub_nonneg.mpr (show (u:ℝ) ≤ t from hut.le) + have hi : 0 ≤ ∫ P : RealPathPair, nearDiagonalCutoff ρ (P.1 u-P.2 u) ∂μ := + integral_nonneg (fun P => (nearDiagonalCutoff_unit ρ _).1) + positivity + simpa only [mul_assoc] using hh.trans (by + simpa only [mul_assoc] using + mul_le_mul_of_nonneg_right (phaseAugmentedTest_norm F a b) hpos) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PolicyGoodMass.lean b/lean/OAI/Probability/Ballisticity/Estimates/PolicyGoodMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..30e71f4dcda3700a2300e5d134d01c86c6e22135 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PolicyGoodMass.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CurvePolicyPMF + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma measurable_pmf_dependent_event {Ω G : Type*} [MeasurableSpace Ω] + [MeasurableSpace G] [MeasurableSingletonClass G] [Countable G] + (p : Ω → PMF G) (hp : ∀ w, Measurable (fun ω => p ω w)) + (S : Ω → Set G) (hS : ∀ w, MeasurableSet {ω | w ∈ S ω}) : + Measurable (fun ω => (p ω).toMeasure (S ω)) := by + simp only [PMF.toMeasure_apply _ (Set.to_countable _ |>.measurableSet)] + apply Measurable.tsum + intro w + change Measurable (fun ω => Set.indicator {ω | w ∈ S ω} (fun ω => p ω w) ω) + exact (hp w).indicator (hS w) + +lemma finitePolicy_length_mass {Ω G : Type*} [Add G] + [MeasurableSpace (List G)] [MeasurableSingletonClass (List G)] [Countable G] + (Q : ℕ → Ω → G → PMF G) (ω : Ω) (i : ℕ) (x : G) (n : ℕ) : + ∀ᵐ w ∂(finitePolicyPMF Q ω i x n).toMeasure, w.length=n := by + rw [ae_iff,PMF.toMeasure_apply _ (Set.to_countable _ |>.measurableSet)] + apply ENNReal.tsum_eq_zero.mpr + intro w + simp only [Set.indicator_apply,Set.mem_ofPred_eq] + split_ifs with h + · rfl + · exact finitePolicyPMF_length Q ω i x n w h + +lemma probability_three_cover {G : Type*} [MeasurableSpace G] (μ : Measure G) + [IsProbabilityMeasure μ] (A B C : Set G) + (hc : ∀ᵐ w ∂μ, w ∈ A ∨ w ∈ B ∨ w ∈ C) : + 1 ≤ μ A + (μ B+μ C) := by + calc + 1 = μ Set.univ := (measure_univ).symm + _ ≤ μ (A ∪ (B ∪ C)) := measure_mono_ae (hc.mono (fun w hw _ => hw)) + _ ≤ μ A + μ (B ∪ C) := measure_union_le _ _ + _ ≤ μ A + (μ B+μ C) := add_le_add_right (measure_union_le _ _) _ + +lemma ennreal_half_good {a b : ℝ≥0∞} (hab : 1 ≤ a+b) (hb : b < (1:ℝ≥0∞)/2) : + (1:ℝ≥0∞)/2 ≤ a := by + by_contra h + have ha : a < (1:ℝ≥0∞)/2 := lt_of_not_ge h + have ht : a+b < (1:ℝ≥0∞)/2 + (1:ℝ≥0∞)/2 := ENNReal.add_lt_add ha hb + rw [ENNReal.add_halves] at ht + exact (not_lt_of_ge hab) ht + +lemma policy_good_mass {Ω G : Type*} [AddMonoid G] + [MeasurableSpace (List G)] [MeasurableSingletonClass (List G)] [Countable G] + (Q : ℕ → Ω → G → PMF G) (ω : Ω) (i : ℕ) (x : G) (n : ℕ) + (Good : G → Prop) (M : List G → ℝ) (r : ℝ) + (hcost : (finitePolicyPMF Q ω i x n).toMeasure {w | ¬policySafe Good x w} + + (finitePolicyPMF Q ω i x n).toMeasure {w | r ≤ M w} < (1:ℝ≥0∞)/2) : + (1:ℝ≥0∞)/2 ≤ (finitePolicyPMF Q ω i x n).toMeasure + {w | w.length=n ∧ policySafe Good x w ∧ M w ≤ r} := by + apply ennreal_half_good (probability_three_cover _ _ _ _ ?_) hcost + filter_upwards [finitePolicy_length_mass Q ω i x n] with w hw + by_cases hgood : policySafe Good x w + · by_cases hm : M w ≤ r + · exact Or.inl ⟨hw,hgood,hm⟩ + · exact Or.inr (Or.inr (le_of_lt (lt_of_not_ge hm))) + · exact Or.inr (Or.inl hgood) + +lemma low_mass_probability {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (cost mass : Ω → ℝ≥0∞) (hc : AEMeasurable cost μ) (c : ℝ≥0∞) + (hgood : ∀ ω, cost ω < (1:ℝ≥0∞)/2 → c ≤ mass ω) : + μ {ω | mass ω < c} ≤ 2*(∫⁻ ω, cost ω ∂μ) := by + have hs : {ω | mass ω < c} ⊆ {ω | (1:ℝ≥0∞)/2 ≤ cost ω} := by + intro ω hw + by_contra h + exact (not_lt_of_ge (hgood ω (lt_of_not_ge h))) hw + calc + μ {ω | mass ω < c} ≤ μ {ω | (1:ℝ≥0∞)/2 ≤ cost ω} := measure_mono hs + _ ≤ (∫⁻ ω, cost ω ∂μ)/((1:ℝ≥0∞)/2) := meas_ge_le_lintegral_div hc (by norm_num) (by norm_num) + _ = 2*(∫⁻ ω, cost ω ∂μ) := by simp [div_eq_mul_inv,mul_comm] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +local instance CurvePolicyMeasurableMs {d : ℕ} : MeasurableSpace (List (Lattice d)) := ⊤ +local instance CurvePolicyMeasurableSingleton {d : ℕ} : MeasurableSingletonClass (List (Lattice d)) := ⟨fun _ => trivial⟩ + +lemma policySafe_measurable {Ω G : Type*} [MeasurableSpace Ω] [Add G] + (Good : Ω → G → Prop) (hG : ∀ x, MeasurableSet {ω | Good ω x}) (x : G) (w : List G) : + MeasurableSet {ω | policySafe (Good ω) x w} := by + induction w generalizing x with + | nil => exact MeasurableSet.univ + | cons u w ih => exact (hG x).inter (ih (x+u)) + +lemma curvePolicy_atom_measurable {d : ℕ} (e f : Direction d) (b : ℕ → ℝ) + (B : ℝ) {H : ℕ} (hH : 0 < H) (E : Set (Lattice d)) + {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (dummy : Lattice d) + (i : ℕ) (x : Lattice d) (n : ℕ) (w : List (Lattice d)) : + Measurable (fun ω => finitePolicyPMF (fun _ ω x => curvePolicyPMF + (realPosition (step e)) f x b B H E hδ hα dummy ω) ω i x n w) := by + apply finitePolicyPMF_measurable_atom + intro _ x u + exact (Measure.measurable_coe (measurableSet_singleton u)).comp + ((curvePolicy_rows (realPosition (step e)) f x b B hH E δ α dummy).mono (rowSigma_le _) le_rfl) + +lemma curvePolicy_failure_measurable {d : ℕ} (e f : Direction d) (b : ℕ → ℝ) + (B : ℝ) {H : ℕ} (hH : 0 < H) (E : Set (Lattice d)) + {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (dummy : Lattice d) + (i : ℕ) (x : Lattice d) (n : ℕ) : + Measurable (fun ω => (finitePolicyPMF (fun _ ω x => curvePolicyPMF + (realPosition (step e)) f x b B H E hδ hα dummy ω) ω i x n).toMeasure + {w | ¬policySafe (fun y => δ ≤ curveIncrement (realPosition (step e)) f y b B H ω Set.univ) x w}) := by + apply measurable_pmf_dependent_event _ (curvePolicy_atom_measurable e f b B hH E hδ hα dummy i x n) + intro w + apply MeasurableSet.compl + apply policySafe_measurable + intro y + apply measurableSet_le measurable_const + exact (Measure.measurable_coe MeasurableSet.univ).comp + ((curveIncrement_rows (realPosition (step e)) f y b B hH).mono (rowSigma_le _) le_rfl) + +lemma curvePolicy_fixed_event_measurable {d : ℕ} (e f : Direction d) (b : ℕ → ℝ) + (B : ℝ) {H : ℕ} (hH : 0 < H) (E : Set (Lattice d)) + {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (dummy : Lattice d) + (i : ℕ) (x : Lattice d) (n : ℕ) (S : Set (List (Lattice d))) : + Measurable (fun ω => (finitePolicyPMF (fun _ ω x => curvePolicyPMF + (realPosition (step e)) f x b B H E hδ hα dummy ω) ω i x n).toMeasure S) := + measurable_pmf_dependent_event _ (curvePolicy_atom_measurable e f b B hH E hδ hα dummy i x n) + (fun _ => S) (fun w => MeasurableSet.const (w ∈ S)) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PrefixVariation.lean b/lean/OAI/Probability/Ballisticity/Estimates/PrefixVariation.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd60c7cc136ddfb86b7b54717a263b174db511b0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PrefixVariation.lean @@ -0,0 +1,313 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.NormalizedSharedRestrict +import OAI.Probability.Ballisticity.Walk.RegularPath + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma regularPath_cross {d : ℕ} (ℓ : Vector d) (x : Lattice d) (H : ℝ) + {X : Path d} (hX : X ∈ RegularPath ℓ x) (hD : X ∈ NoDrop ℓ x) : X ∈ Cross ℓ x H := by + obtain ⟨n,hn⟩ := (hX.2.2.eventually_ge_atTop (dot (realPosition x) ℓ+H)).exists + exact ⟨n,hn,fun j _ => hD j⟩ + +lemma hitWordsEvent_compl_on {d : ℕ} (x y : Lattice d) (S T : Set (Lattice d)) + (hST : Disjoint S T) (E : Set (HitWord x S T × HitWord y S T)) + {Z : Path d × Path d} (hZ : Z ∈ hitWordsEvent x y S T Set.univ) : + Z ∈ hitWordsEvent x y S T Eᶜ ↔ Z ∉ hitWordsEvent x y S T E := by + obtain ⟨w,hw⟩ := Set.mem_iUnion.mp hZ + obtain ⟨_,hw⟩ := Set.mem_iUnion.mp hw + have hu (v : HitWord x S T × HitWord y S T) + (hv : Z ∈ wordCylinder x v.1.val ×ˢ wordCylinder y v.2.val) : v = w := by + by_contra h + exact Set.disjoint_left.mp (hitWords_pair_cylinders_disjoint x y S T hST h) hv hw + constructor + · intro hc he + obtain ⟨v,hv⟩ := Set.mem_iUnion.mp hc + obtain ⟨hv,hcy⟩ := Set.mem_iUnion.mp hv + obtain ⟨u,hu'⟩ := Set.mem_iUnion.mp he + obtain ⟨hu',hcy'⟩ := Set.mem_iUnion.mp hu' + rw [hu v hcy] at hv + rw [hu u hcy'] at hu' + exact hv hu' + · intro hn + refine Set.mem_iUnion.mpr ⟨w,Set.mem_iUnion.mpr ⟨?_,hw⟩⟩ + exact fun h => hn (Set.mem_iUnion.mpr ⟨w,Set.mem_iUnion.mpr ⟨h,hw⟩⟩) + +lemma regularPath_hitWords_cover {d : ℕ} (ℓ : Vector d) (x y : Lattice d) + (hxy : dot (realPosition x) ℓ = dot (realPosition y) ℓ) (H : ℝ) + {Z : Path d × Path d} + (hZ : (Z.1 ∈ RegularPath ℓ x ∧ Z.1 ∈ NoDrop ℓ x) ∧ + (Z.2 ∈ RegularPath ℓ y ∧ Z.2 ∈ NoDrop ℓ y)) : + Z ∈ hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) Set.univ := by + have hx := regularPath_cross ℓ x H hZ.1.1 hZ.1.2 + have hy := regularPath_cross ℓ y H hZ.2.1 hZ.2.2 + rw [cross_eq_hit] at hx hy + have hs : Strip ℓ y H = Strip ℓ x H := by unfold Strip; rw [hxy] + have ht : Upper ℓ y H = Upper ℓ x H := by unfold Upper; rw [hxy] + rw [hs,ht] at hy + obtain ⟨u,hu⟩ := (hitWord_cover x _ _ Z.1 hZ.1.1.1 hZ.1.1.2.1).mp hx + obtain ⟨v,hv⟩ := (hitWord_cover y _ _ Z.2 hZ.2.1.1 hZ.2.1.2.1).mp hy + exact Set.mem_iUnion.mpr ⟨(u,v),Set.mem_iUnion.mpr ⟨Set.mem_univ _,hu,hv⟩⟩ + +lemma prefix_event_real_compl {d : ℕ} (μ : Measure (Path d × Path d)) [IsProbabilityMeasure μ] + (x y : Lattice d) (S T : Set (Lattice d)) (hST : Disjoint S T) + (hcover : ∀ᵐ Z ∂μ, Z ∈ hitWordsEvent x y S T Set.univ) + (E : Set (HitWord x S T × HitWord y S T)) : + μ.real (hitWordsEvent x y S T Eᶜ) = 1-μ.real (hitWordsEvent x y S T E) := by + have he : μ (hitWordsEvent x y S T Eᶜ) = μ (hitWordsEvent x y S T E)ᶜ := by + apply measure_congr + filter_upwards [hcover] with Z hZ + exact propext (hitWordsEvent_compl_on x y S T hST E hZ) + change (μ _).toReal = _ + rw [he] + simpa only [Measure.real,measure_univ,ENNReal.toReal_one] using + (measureReal_compl (μ := μ) (measurableSet_hitWordsEvent x y S T E)) + +noncomputable def prefixVariation {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (x y : Lattice d) (H : ℝ) : ℝ := + sSup (Set.range fun E : Set (HitWord x (Strip ℓ x H) (Upper ℓ x H) × + HitWord y (Strip ℓ x H) (Upper ℓ x H)) => + |(sharedConditionedPairLaw ν ℓ x y).real (hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) E)- + ((conditionedFrom ν ℓ x).prod (conditionedFrom ν ℓ y)).real + (hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) E)|) + +lemma prefixVariation_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) + (hxy : dot (realPosition x) ℓ = dot (realPosition y) ℓ) (H : ℝ) : + prefixVariation ν ℓ x y H ≤ + (sharedConditionedPairLaw ν ℓ x y).real (PrefixContact (Strip ℓ x H)) + + ((sharedNoDropMass ν ℓ x y)⁻¹ * + ((annealedLaw ν (NoDrop ℓ 0))^2-sharedNoDropMass ν ℓ x y + + 2*annealedLaw ν (Cross ℓ 0 H \ NoDrop ℓ 0))).toReal := by + let μ := sharedConditionedPairLaw ν ℓ x y + let η := (conditionedFrom ν ℓ x).prod (conditionedFrom ν ℓ y) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hp₂ := ne_of_gt (sharedNoDropMass_pos ν hue ℓ hℓ htrans x y) + let : IsProbabilityMeasure μ := sharedConditionedPairLaw_probability ν ℓ x y hp₂ + let : IsProbabilityMeasure (conditionedFrom ν ℓ x) := conditionedFrom_probability ν ℓ x hp + let : IsProbabilityMeasure (conditionedFrom ν ℓ y) := conditionedFrom_probability ν ℓ y hp + have hc₁ : ∀ᵐ Z ∂μ, Z ∈ hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) Set.univ := + (sharedConditioned_regularPath ν ℓ htrans x y).mono fun _ h => regularPath_hitWords_cover ℓ x y hxy H h + have hc₂ : ∀ᵐ Z ∂η, Z ∈ hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) Set.univ := by + have hmeas : MeasurableSet {Z : Path d × Path d | + (Z.1 ∈ RegularPath ℓ x ∧ Z.1 ∈ NoDrop ℓ x) ∧ + (Z.2 ∈ RegularPath ℓ y ∧ Z.2 ∈ NoDrop ℓ y)} := + ((measurableSet_regularPath ℓ x).inter (measurableSet_noDrop ℓ x)).prod + ((measurableSet_regularPath ℓ y).inter (measurableSet_noDrop ℓ y)) + have hr := (Measure.ae_prod_iff_ae_ae hmeas).mpr (show ∀ᵐ X ∂conditionedFrom ν ℓ x, + ∀ᵐ Y ∂conditionedFrom ν ℓ y, (X ∈ RegularPath ℓ x ∧ X ∈ NoDrop ℓ x) ∧ + (Y ∈ RegularPath ℓ y ∧ Y ∈ NoDrop ℓ y) from + (conditionedFrom_regularPath ν ℓ htrans x).mono fun X hX => + (conditionedFrom_regularPath ν ℓ htrans y).mono fun Y hY => ⟨hX,hY⟩) + exact hr.mono fun _ h => regularPath_hitWords_cover ℓ x y hxy H h + let δ := (sharedNoDropMass ν ℓ x y)⁻¹ * + ((annealedLaw ν (NoDrop ℓ 0))^2-sharedNoDropMass ν ℓ x y + + 2*annealedLaw ν (Cross ℓ 0 H \ NoDrop ℓ 0)) + have hδ : δ ≠ ∞ := by + apply ENNReal.mul_ne_top (ENNReal.inv_ne_top.mpr hp₂) + finiteness + let F := hitWordsEvent x y (Strip ℓ x H) (Upper ℓ x H) + have hb E : μ.real (F E) ≤ η.real (F E)+μ.real (PrefixContact (Strip ℓ x H))+δ.toReal := by + have hh := conditioned_prefix_comparison ν hue ℓ hℓ htrans x y hxy H E + have hh' := ENNReal.toReal_mono (show η (F E)+μ (PrefixContact (Strip ℓ x H))+δ ≠ ∞ by finiteness) hh + simpa only [Measure.real,ENNReal.toReal_add (measure_ne_top _ _) (measure_ne_top _ _), + ENNReal.toReal_add (by finiteness : η (F E)+μ (PrefixContact (Strip ℓ x H)) ≠ ∞) hδ] using hh' + apply csSup_le (Set.range_nonempty _) + rintro _ ⟨E,rfl⟩ + have hb₁ := hb E + have hb₂ := hb Eᶜ + rw [prefix_event_real_compl μ x y _ _ (disjoint_strip_upper ℓ x H) hc₁, + prefix_event_real_compl η x y _ _ (disjoint_strip_upper ℓ x H) hc₂] at hb₂ + exact abs_sub_le_iff.mpr ⟨by linarith,by linarith⟩ + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma sharedNoDropMass_tendsto_gap {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (x y : ℕ → Lattice d) + (hgap : Tendsto (fun i => |signedCoordinate f (y i-x i)|) atTop atTop) : + Tendsto (fun i => (sharedNoDropMass ν ℓ (x i) (y i)).toReal) atTop + (𝓝 ((annealedLaw ν (NoDrop ℓ 0)).toReal^2)) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨N,hN⟩ := sharedNoDropMass_mixing ν ℓ hε + filter_upwards [hgap.eventually_gt_atTop (2*(N:ℝ))] with i hi + rw [Real.dist_eq] + apply hN + apply latticeBall_disjoint_of_coordinate_gap f.1 + have he : |signedCoordinate f (y i-x i)| = (|(x i) f.1-(y i) f.1| : ℝ) := by + simp only [signedCoordinate,Pi.sub_apply,apply_ite abs,abs_neg,ite_self,Int.cast_sub] + exact abs_sub_comm _ _ + rw [he] at hi + exact_mod_cast hi + +lemma prefix_error_tendsto_zero {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (f : Direction d) + (x y : ℕ → Lattice d) (H : ℕ → ℕ) (hH : Tendsto H atTop atTop) + (hgap : Tendsto (fun i => |signedCoordinate f (y i-x i)|) atTop atTop) : + Tendsto (fun i => ((sharedNoDropMass ν ℓ (x i) (y i))⁻¹ * + ((annealedLaw ν (NoDrop ℓ 0))^2-sharedNoDropMass ν ℓ (x i) (y i) + + 2*annealedLaw ν (Cross ℓ 0 (H i) \ NoDrop ℓ 0))).toReal) atTop (𝓝 0) := by + let p := annealedLaw ν (NoDrop ℓ 0) + let q := fun i => sharedNoDropMass ν ℓ (x i) (y i) + have hp : p ≠ 0 := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hpfin : p^2 ≠ ∞ := by finiteness + have hqfin (i : ℕ) : q i ≠ ∞ := ne_of_lt ((sharedNoDropMass_le_one ν ℓ (x i) (y i)).trans_lt (by simp)) + have hq : Tendsto q atTop (𝓝 (p^2)) := (ENNReal.tendsto_toReal_iff hqfin hpfin).mp (by + simpa only [ENNReal.toReal_pow] using sharedNoDropMass_tendsto_gap ν ℓ f x y hgap) + have hdiff : Tendsto (fun i => p^2-q i) atTop (𝓝 0) := by + simpa only [tsub_self,Function.comp_def] using (ENNReal.tendsto_sub (Or.inl hpfin)).comp + (tendsto_const_nhds.prodMk_nhds hq) + have herr : Tendsto (fun i => 2*annealedLaw ν (Cross ℓ 0 (H i) \ NoDrop ℓ 0)) atTop (𝓝 0) := by + simpa only [mul_zero,Function.comp_def] using ENNReal.Tendsto.const_mul ((cross_error_tendsto_zero ν ℓ).comp hH) + (Or.inr (by norm_num : (2:ℝ≥0∞) ≠ ∞)) + have hinv : Tendsto (fun i => (q i)⁻¹) atTop (𝓝 (p^2)⁻¹) := tendsto_inv_iff.mpr hq + have hsum := hdiff.add herr + rw [zero_add] at hsum + have hprod := ENNReal.Tendsto.mul hinv (Or.inr ENNReal.zero_ne_top) hsum + (Or.inr (ENNReal.inv_ne_top.mpr (pow_ne_zero _ hp))) + rw [mul_zero] at hprod + simpa only [ENNReal.toReal_zero,Function.comp_def] using (ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp hprod + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/PrefixVariationNonneg.lean b/lean/OAI/Probability/Ballisticity/Estimates/PrefixVariationNonneg.lean new file mode 100644 index 0000000000000000000000000000000000000000..691fa1f92dc88d082e5885b89d8db36d6dcb6060 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/PrefixVariationNonneg.lean @@ -0,0 +1,331 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.CoordinateLanesDisjoint +import OAI.Probability.Ballisticity.Estimates.PrefixVariation + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma prefixVariation_nonneg {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (x y : Lattice d) (H : ℝ) : 0 ≤ prefixVariation ν ℓ x y H := by + apply Real.sSup_nonneg + rintro _ ⟨E,rfl⟩ + exact abs_nonneg _ + +theorem off_diagonal_comparison {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hrpos : ∀ i, 0 < r i) + (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) + {a t : ℝ} (ha : 0 < a) (ht : 0 < t) + (hsep : ∀ i, a*r i ≤ |signedCoordinate f (y i-x i)|) : + let ℓ := realPosition (step e) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + limsup (fun i => prefixVariation ν ℓ (x i) (y i) (⌊t*n i⌋₊ : ℝ)) atTop ≤ + 8*Real.exp (-commonMeanWidth ν ℓ*a^2/(9*t)) := by + let ℓ := realPosition (step e) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let H := fun i => ⌊t*n i⌋₊ + let v := fun i => prefixVariation ν ℓ (x i) (y i) (H i) + let μ := fun i => sharedConditionedPairLaw ν ℓ (x i) (y i) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + let c := fun i => (μ i).real (PrefixContact (Strip ℓ (x i) (H i))) + let δ := fun i => ((sharedNoDropMass ν ℓ (x i) (y i))⁻¹ * + ((annealedLaw ν (NoDrop ℓ 0))^2-sharedNoDropMass ν ℓ (x i) (y i) + + 2*annealedLaw ν (Cross ℓ 0 (H i) \ NoDrop ℓ 0))).toReal + let R := 8*Real.exp (-commonMeanWidth ν ℓ*a^2/(9*t)) + have hgap : Tendsto (fun i => |signedCoordinate f (y i-x i)|) atTop atTop := + tendsto_atTop_mono hsep (hr.1.const_mul_atTop ha) + have hn := recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1 + have hH : Tendsto H atTop atTop := tendsto_nat_floor_atTop.comp (hn.const_mul_atTop ht) + have hδ : Tendsto δ atTop (𝓝 0) := prefix_error_tendsto_zero ν ℓ htrans f x y H hH hgap + have hb (i : ℕ) : v i ≤ c i+δ i := prefixVariation_bound ν hue ℓ (signed_direction_unit e) + htrans (x i) (y i) (by simp only [ℓ,signedHeight_projection,hxy i]) (H i) + have hc : limsup c atTop ≤ R := shared_contact_limsup ν hue e f hef htrans r hrpos hr x y hxy ha ht hsep + have hcb : IsBoundedUnder (· ≤ ·) atTop c := by + refine ⟨1, ?_⟩ + change ∀ᶠ i in atTop, c i ≤ 1 + exact Eventually.of_forall fun i => measureReal_le_one + have hvb : IsBoundedUnder (· ≤ ·) atTop v := by + refine ⟨2, ?_⟩ + change ∀ᶠ i in atTop, v i ≤ 2 + filter_upwards [hδ.eventually_lt_const (by norm_num : (0:ℝ)<1)] with i hi + have hh : c i ≤ 1 := measureReal_le_one + linarith [hb i] + have hvc : IsCoboundedUnder (· ≤ ·) atTop v := + (show IsBoundedUnder (· ≥ ·) atTop v from ⟨0, + (show ∀ᶠ i in atTop, 0 ≤ v i from Eventually.of_forall fun i => prefixVariation_nonneg ν ℓ (x i) (y i) (H i))⟩).isCoboundedUnder_le + apply (limsup_le_iff hvc hvb).mpr + intro b hb' + have hc' := eventually_lt_of_limsup_lt (hc.trans_lt (show R < R+(b-R)/3 by linarith)) hcb + have hδ' := hδ.eventually_lt_const (show (0:ℝ)<(b-R)/3 by linarith) + filter_upwards [hc',hδ'] with i hi hi' + linarith [hb i] + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def layerPairPrefix {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) (nm : ℕ × ℕ) : + Set (Path d × Path d) := + (FirstLayerHit height H (nm.1+1) ×ˢ FirstLayerHit height H (nm.2+1)) ∩ + {P | (P.1 (nm.1+1),P.2 (nm.2+1)) ∈ E} ∩ + (StayUntil {z | dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ} (nm.1+1) ×ˢ + StayUntil {z | dot (realPosition y) ℓ ≤ dot (realPosition z) ℓ} (nm.2+1)) + +def layerPairEvent {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) : Set (Path d × Path d) := + ⋃ nm, layerPairPrefix ℓ height x y H E nm + +def layerPairTruthEvent {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) : Set (Path d × Path d) := + ⋃ nm, layerPairPrefix ℓ height x y H E nm ∩ + (FutureNoDrop ℓ (nm.1+1) ×ˢ FutureNoDrop ℓ (nm.2+1)) + +lemma measurableSet_layerPairPrefix {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) (nm : ℕ × ℕ) : + MeasurableSet (layerPairPrefix ℓ height x y H E nm) := by + apply MeasurableSet.inter + · exact ((measurableSet_firstLayerHit height H (nm.1+1)).prod + (measurableSet_firstLayerHit height H (nm.2+1))).inter + (by apply E.to_countable.measurableSet.preimage; fun_prop) + · exact (measurableSet_stayUntil _ _).prod (measurableSet_stayUntil _ _) + +lemma layerPairPrefix_determined {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) (nm : ℕ × ℕ) : + PairPrefixDetermined (nm.1+1) (nm.2+1) (layerPairPrefix ℓ height x y H E nm) := by + intro P Q h1 h2 + have he1 := firstLayerHit_prefix height H (nm.1+1) P.1 Q.1 h1 + have he2 := firstLayerHit_prefix height H (nm.2+1) P.2 Q.2 h2 + have hs1 : P.1 ∈ StayUntil {z | dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ} (nm.1+1) ↔ + Q.1 ∈ StayUntil {z | dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ} (nm.1+1) := by + exact forall_congr' fun j => forall_congr' fun hj => by rw [h1 j hj] + have hs2 : P.2 ∈ StayUntil {z | dot (realPosition y) ℓ ≤ dot (realPosition z) ℓ} (nm.2+1) ↔ + Q.2 ∈ StayUntil {z | dot (realPosition y) ℓ ≤ dot (realPosition z) ℓ} (nm.2+1) := by + exact forall_congr' fun j => forall_congr' fun hj => by rw [h2 j hj] + change ((_ ∧ _) ∧ _) ∧ (_ ∧ _) ↔ ((_ ∧ _) ∧ _) ∧ (_ ∧ _) + simp only [Set.mem_ofPred_eq] + rw [he1,he2,hs1,hs2,h1 _ le_rfl,h2 _ le_rfl] + +lemma layerPairPrefix_disjoint {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) : + Pairwise (fun n m => Disjoint (layerPairPrefix ℓ height x y H E n) + (layerPairPrefix ℓ height x y H E m)) := by + intro n m hnm + apply Set.disjoint_left.mpr + intro P hn hm + by_cases he : n.1 = m.1 + · have hf : n.2+1 ≠ m.2+1 := by intro h; apply hnm; exact Prod.ext he (by omega) + exact Set.disjoint_left.mp (firstLayerHit_disjoint height H hf) hn.1.1.2 hm.1.1.2 + · have hf : n.1+1 ≠ m.1+1 := by omega + exact Set.disjoint_left.mp (firstLayerHit_disjoint height H hf) hn.1.1.1 hm.1.1.1 + +lemma layerPairTruthEvent_subset_noDrop {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) : + layerPairTruthEvent ℓ height x y H E ⊆ NoDrop ℓ x ×ˢ NoDrop ℓ y := by + intro P hP + obtain ⟨nm,hP⟩ := Set.mem_iUnion.mp hP + have aux (n : ℕ) (z : Lattice d) (X : Path d) + (hs : X ∈ StayUntil {w | dot (realPosition z) ℓ ≤ dot (realPosition w) ℓ} n) + (ht : X ∈ FutureNoDrop ℓ n) : X ∈ NoDrop ℓ z := by + intro j + by_cases hj : j ≤ n + · exact hs j hj + · have hh := ht (j-n) + rw [Nat.add_sub_of_le (by omega : n ≤ j)] at hh + exact (hs n le_rfl).trans hh + exact ⟨aux _ _ _ hP.1.2.1 hP.2.1,aux _ _ _ hP.1.2.2 hP.2.2⟩ + +theorem shared_layer_truth_domination {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (x y : Lattice d) (H : ℤ) (E : Set (Lattice d × Lattice d)) + (c : ℝ≥0∞) (hc : ∀ u v, c ≤ sharedNoDropMass ν ℓ u v) : + c * sharedConditionedPairLaw ν ℓ x y (layerPairEvent ℓ height x y H E) ≤ + sharedConditionedPairLaw ν ℓ x y (layerPairTruthEvent ℓ height x y H E) := by + let A := layerPairPrefix ℓ height x y H E + let B := fun nm : ℕ × ℕ => A nm ∩ + (FutureNoDrop ℓ (nm.1+1) ×ˢ FutureNoDrop ℓ (nm.2+1)) + have hAm nm : MeasurableSet (A nm) := measurableSet_layerPairPrefix ℓ height x y H E nm + have hBm nm : MeasurableSet (B nm) := (hAm nm).inter + ((measurableSet_futureNoDrop ℓ _).prod (measurableSet_futureNoDrop ℓ _)) + have hdisA := layerPairPrefix_disjoint ℓ height x y H E + have hdisB : Pairwise (fun nm mn => Disjoint (B nm) (B mn)) := by + intro nm mn hne + exact (hdisA hne).mono Set.inter_subset_left Set.inter_subset_left + have hraw : c * sharedPairLaw ν x y (⋃ nm, A nm) ≤ sharedPairLaw ν x y (⋃ nm, B nm) := by + rw [measure_iUnion hdisA hAm,measure_iUnion hdisB hBm,← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro nm + apply shared_pair_record_event_noDrop_lower ν ℓ x y c hc _ _ (by omega) (by omega) + (A nm) (layerPairPrefix_determined ℓ height x y H E nm) + intro P hP + exact ⟨firstLayerHit_record ℓ height hproj H _ _ hP.1.1.1, + firstLayerHit_record ℓ height hproj H _ _ hP.1.1.2, + by rw [hproj,hproj,hP.1.1.1.1,hP.1.1.2.1]⟩ + unfold sharedConditionedPairLaw + change c * ((sharedNoDropMass ν ℓ x y)⁻¹ • (sharedPairLaw ν x y).restrict (NoDrop ℓ x ×ˢ NoDrop ℓ y)) (⋃ nm, A nm) ≤ + ((sharedNoDropMass ν ℓ x y)⁻¹ • (sharedPairLaw ν x y).restrict (NoDrop ℓ x ×ˢ NoDrop ℓ y)) (⋃ nm, B nm) + have hsub : (⋃ nm, B nm) ⊆ NoDrop ℓ x ×ˢ NoDrop ℓ y := + layerPairTruthEvent_subset_noDrop ℓ height x y H E + rw [Measure.smul_apply,Measure.smul_apply, + Measure.restrict_apply (MeasurableSet.iUnion hAm), + Measure.restrict_apply (MeasurableSet.iUnion hBm), + Set.inter_eq_left.mpr hsub] + simp only [smul_eq_mul] + calc + c * ((sharedNoDropMass ν ℓ x y)⁻¹ * sharedPairLaw ν x y + ((⋃ nm, A nm) ∩ (NoDrop ℓ x ×ˢ NoDrop ℓ y))) ≤ + c * ((sharedNoDropMass ν ℓ x y)⁻¹ * sharedPairLaw ν x y (⋃ nm, A nm)) := by + gcongr + exact Set.inter_subset_left + _ = (sharedNoDropMass ν ℓ x y)⁻¹ * (c * sharedPairLaw ν x y (⋃ nm, A nm)) := by ring + _ ≤ _ := by gcongr + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ProbabilityLowerTransfer.lean b/lean/OAI/Probability/Ballisticity/Estimates/ProbabilityLowerTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..99b28eaa5945542d281e7dc980e058def193912d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ProbabilityLowerTransfer.lean @@ -0,0 +1,49 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma probability_lower_transfer {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (p q cost : ℕ → Ω → ℝ) + (c : ℝ) (hc : 0 < c) + (hp : Tendsto (fun i => μ.real {x | p i x < c}) atTop (𝓝 0)) + (hcost : TendstoInMeasure μ cost atTop (fun _ => 0)) + (hb : ∀ i, ∀ᵐ x ∂μ, |p i x-q i x| ≤ cost i x) : + Tendsto (fun i => μ.real {x | q i x < c/2}) atTop (𝓝 0) := by + have hh := (tendstoInMeasure_iff_measureReal_norm.mp hcost) (c/2) (half_pos hc) + simp only [sub_zero] at hh + have hlim : Tendsto (fun i => μ.real {x | p i x < c}+μ.real {x | c/2 ≤ ‖cost i x‖}) atTop (𝓝 0) := by + simpa only [add_zero] using hp.add hh + apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds hlim + (fun _ => measureReal_nonneg) + intro i + apply le_trans _ (measureReal_union_le {x | p i x < c} {x | c/2 ≤ ‖cost i x‖}) + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [hb i] with x hx + intro hqx + change q i x < c/2 at hqx + change p i x < c ∨ c/2 ≤ ‖cost i x‖ + by_cases hpx : p i x < c + · exact Or.inl hpx + · right + have hp' : c ≤ p i x := le_of_not_gt hpx + have h' : p i x-q i x ≤ cost i x := (le_abs_self _).trans hx + have h'' : cost i x ≤ ‖cost i x‖ := by simpa only [Real.norm_eq_abs] using le_abs_self (cost i x) + linarith + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ProductNormalJointPast.lean b/lean/OAI/Probability/Ballisticity/Estimates/ProductNormalJointPast.lean new file mode 100644 index 0000000000000000000000000000000000000000..d949a47866adce5d01d577d862e2463774e663fa --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ProductNormalJointPast.lean @@ -0,0 +1,209 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CharacteristicProductLaw + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +noncomputable def pathPastCoordinates {q : ℕ} (v : Fin q → unitInterval) : + C(C(unitInterval,ℝ),Fin q → ℝ) := ⟨fun P z => P (v z),by fun_prop⟩ + +noncomputable def pathIncrement (s t : unitInterval) : C(C(unitInterval,ℝ),ℝ) := + ⟨fun P => P t-P s,by fun_prop⟩ + +def NormalSinglePast (μ : Measure C(unitInterval,ℝ)) (c : ℝ≥0) : Prop := + ∀ (q : ℕ) (v : Fin q → unitInterval) (s t : unitInterval), + (∀ z, v z ≤ s) → s < t → (t:ℝ) < 1 → + μ.map (fun P => (pathPastCoordinates v P,pathIncrement s t P)) = + (μ.map (pathPastCoordinates v)).prod (gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s))) + +lemma normalJointPast_single (μ : Measure RealPathPair) [IsProbabilityMeasure μ] (c : ℝ≥0) (h : NormalJointPast μ c) + (b : Bool) : NormalSinglePast (μ.map (fun P => if b then P.2 else P.1)) c := by + intro q v s t hv hst ht + let g := fun z : Fin q → ℝ × ℝ => fun j => if b then (z j).2 else (z j).1 + have hg : Measurable g := by cases b <;> simp [g] <;> fun_prop + have hh := congrArg (fun M => M.map (Prod.map g id)) (h q v s t hv hst ht b) + rw [Measure.map_map (hg.prodMap measurable_id) (by fun_prop), + ← Measure.map_prod_map _ _ hg measurable_id,Measure.map_id, + Measure.map_map hg (by fun_prop)] at hh + rw [Measure.map_map (by fun_prop) (by cases b <;> simp <;> fun_prop), + Measure.map_map (by fun_prop) (by cases b <;> simp <;> fun_prop)] + cases b <;> exact hh + +lemma normalSinglePast_prod (μ ν : Measure C(unitInterval,ℝ)) + [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (c : ℝ≥0) + (hμ : NormalSinglePast μ c) (hν : NormalSinglePast ν c) : FullNormalJointPast (μ.prod ν) c := by + intro q v s t hv hst ht + let Z := fun P : C(unitInterval,ℝ) => (pathPastCoordinates v P,pathIncrement s t P) + have hZ : Measurable Z := by fun_prop + let γ := gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s)) + let Q := fun z : ((Fin q → ℝ) × ℝ) × ((Fin q → ℝ) × ℝ) => ((z.1.1,z.2.1),(z.1.2,z.2.2)) + have hQ : Measurable Q := by fun_prop + let zip := fun z : (Fin q → ℝ) × (Fin q → ℝ) => fun j => (z.1 j,z.2 j) + have hzip : Measurable zip := by fun_prop + have hh : ((μ.prod ν).map (Prod.map Z Z)).map Q = + ((μ.map (pathPastCoordinates v)).prod (ν.map (pathPastCoordinates v))).prod (γ.prod γ) := by + rw [← Measure.map_prod_map _ _ hZ hZ,hμ q v s t hv hst ht,hν q v s t hv hst ht] + exact measure_prod_shuffle _ _ _ _ + have he := congrArg (fun M => M.map (Prod.map zip id)) hh + rw [Measure.map_map (hzip.prodMap measurable_id) hQ, + Measure.map_map ((hzip.prodMap measurable_id).comp hQ) (hZ.prodMap hZ), + ← Measure.map_prod_map _ _ hzip measurable_id,Measure.map_id, + Measure.map_prod_map _ _ (pathPastCoordinates v).continuous.measurable (pathPastCoordinates v).continuous.measurable, + Measure.map_map hzip (by fun_prop)] at he + exact he + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def pairRestricted (I : Finset unitInterval) : C(RealPathPair,I → ℝ × ℝ) := + ⟨fun P z => (P.1 z,P.2 z),by fun_prop⟩ + +noncomputable def pairIncrement (s t : unitInterval) : C(RealPathPair,ℝ × ℝ) := + ⟨fun P => (P.1 t-P.1 s,P.2 t-P.2 s),by fun_prop⟩ + +lemma fullNormalJointPast_finset (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : FullNormalJointPast μ c) (I : Finset unitInterval) + (s t : unitInterval) (hv : ∀ z ∈ I,z ≤ s) (hst : s < t) (ht : (t:ℝ) < 1) : + μ.map (fun P => (pairRestricted I P,pairIncrement s t P))= + (μ.map (pairRestricted I)).prod + ((gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s))).prod + (gaussianReal 0 (c*Real.toNNReal ((t:ℝ)-s)))) := by + let e := Fintype.equivFin I + let v := fun j : Fin (Fintype.card I) => ((e.symm j:I):unitInterval) + let g := fun z : Fin (Fintype.card I) → ℝ × ℝ => fun j : I => z (e j) + have hg : Measurable g := by fun_prop + have hh := h (Fintype.card I) v s t (fun j => hv _ (e.symm j).property) hst ht + have hh' := congrArg (fun M => M.map (Prod.map g id)) hh + rw [Measure.map_map (hg.prodMap measurable_id) (by fun_prop),← Measure.map_prod_map _ _ hg measurable_id, + Measure.map_id,Measure.map_map hg (by fun_prop)] at hh' + convert hh' using 1 + · congr 1 + funext P + apply Prod.ext + · funext j + simp [g,v,e,pairRestricted,pairPastCoordinates] + · rfl + · congr 2 + funext P j + simp [g,v,e,pairRestricted,pairPastCoordinates] + +lemma pairRestricted_empty_map (μ : Measure RealPathPair) [IsProbabilityMeasure μ] : + μ.map (pairRestricted ∅)=Measure.dirac 0 := by + have he : (pairRestricted ∅ : RealPathPair → (∅ : Finset unitInterval) → ℝ × ℝ)=fun _ => 0 := by + funext P z + exact False.elim (Finset.notMem_empty _ z.property) + rw [he,Measure.map_const,measure_univ,one_smul] + +lemma pairRestricted_singleton_zero_map (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (hzero : ∀ᵐ P ∂μ, P.1 0=0 ∧ P.2 0=0) : + μ.map (pairRestricted {0})=Measure.dirac 0 := by + have he : (pairRestricted {0} : RealPathPair → ({0} : Finset unitInterval) → ℝ × ℝ)=ᵐ[μ] fun _ => 0 := by + filter_upwards [hzero] with P hP + funext z + have hz : z.val=0 := Finset.mem_singleton.mp z.property + simp [pairRestricted,hz,hP.1,hP.2] + rw [Measure.map_congr he,Measure.map_const,measure_univ,one_smul] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma pairRestricted_mono_eq (μ ν : Measure RealPathPair) {I J : Finset unitInterval} + (hIJ : I ⊆ J) (h : μ.map (pairRestricted J)=ν.map (pairRestricted J)) : + μ.map (pairRestricted I)=ν.map (pairRestricted I) := by + let g := fun z : J → ℝ × ℝ => fun i : I => z ⟨i,hIJ i.property⟩ + have hg : Measurable g := by fun_prop + have hh := congrArg (fun M => M.map g) h + rw [Measure.map_map hg (pairRestricted J).continuous.measurable, + Measure.map_map hg (pairRestricted J).continuous.measurable] at hh + exact hh + +noncomputable def pairExtend (I : Finset unitInterval) (t s : unitInterval) (hs : s ∈ I) : + ((I → ℝ × ℝ) × (ℝ × ℝ)) → (↑(insert t I) → ℝ × ℝ) := + fun z j => if h : j.val=t then z.1 ⟨s,hs⟩+z.2 else + z.1 ⟨j,Finset.mem_of_mem_insert_of_ne j.property h⟩ + +lemma pairExtend_measurable (I : Finset unitInterval) (t s : unitInterval) (hs : s ∈ I) : + Measurable (pairExtend I t s hs) := by + apply Measurable.of_eval + intro j + by_cases h : j.val=t <;> simp [pairExtend,h] <;> fun_prop + +lemma pairExtend_eval (I : Finset unitInterval) (t s : unitInterval) (hs : s ∈ I) (P : RealPathPair) : + pairExtend I t s hs (pairRestricted I P,pairIncrement s t P)=pairRestricted (insert t I) P := by + funext j + by_cases h : j.val=t + · simp [pairExtend,h,pairRestricted,pairIncrement] + · simp [pairExtend,h,pairRestricted] + +lemma pairRestricted_insert_eq (μ ν : Measure RealPathPair) + [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (c : ℝ≥0) + (hμ : FullNormalJointPast μ c) (hν : FullNormalJointPast ν c) + (I : Finset unitInterval) (t s : unitInterval) (hs : s ∈ I) + (hIs : ∀ z ∈ I,z ≤ s) (hst : s < t) (ht : (t:ℝ) < 1) + (hI : μ.map (pairRestricted I)=ν.map (pairRestricted I)) : + μ.map (pairRestricted (insert t I))=ν.map (pairRestricted (insert t I)) := by + have hm := fullNormalJointPast_finset μ c hμ I s t hIs hst ht + have hn := fullNormalJointPast_finset ν c hν I s t hIs hst ht + rw [hI] at hm + have he := hm.trans hn.symm + have he' := congrArg (fun M => M.map (pairExtend I t s hs)) he + rw [Measure.map_map (pairExtend_measurable I t s hs) (by fun_prop), + Measure.map_map (pairExtend_measurable I t s hs) (by fun_prop)] at he' + simpa only [Function.comp_def,pairExtend_eval] using he' + +lemma fullNormalJointPast_finite_uniqueness (μ ν : Measure RealPathPair) + [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (c : ℝ≥0) + (hμ : FullNormalJointPast μ c) (hν : FullNormalJointPast ν c) + (hμ0 : ∀ᵐ P ∂μ, P.1 0=0 ∧ P.2 0=0) (hν0 : ∀ᵐ P ∂ν, P.1 0=0 ∧ P.2 0=0) + (I : Finset unitInterval) (hI : ∀ z ∈ I,(z:ℝ) < 1) : + μ.map (pairRestricted I)=ν.map (pairRestricted I) := by + have hz : μ.map (pairRestricted {0})=ν.map (pairRestricted {0}) := by + rw [pairRestricted_singleton_zero_map μ hμ0,pairRestricted_singleton_zero_map ν hν0] + induction I using Finset.induction_on_max with + | empty => rw [pairRestricted_empty_map,pairRestricted_empty_map] + | insert t I hlt ih => + have ht : (t:ℝ) < 1 := hI t (Finset.mem_insert_self _ _) + have hIp : ∀ z ∈ I,(z:ℝ) < 1 := fun z hz => hI z (Finset.mem_insert_of_mem hz) + rcases I.eq_empty_or_nonempty with he | he + · subst I + simp only [Finset.insert_empty] + by_cases ht0 : t=0 + · subst t + exact hz + · have h0t : (0:unitInterval) < t := lt_of_le_of_ne (show (0:unitInterval) ≤ t from t.property.1) (Ne.symm ht0) + have hh := pairRestricted_insert_eq μ ν c hμ hν {0} t 0 (by simp) + (by intro z hz; rw [Finset.mem_singleton.mp hz]) h0t ht hz + apply pairRestricted_mono_eq μ ν (J := insert t {0}) (by intro z hz; simp_all) + exact hh + · apply pairRestricted_insert_eq μ ν c hμ hν I t (I.max' he) (Finset.max'_mem I he) + (fun z hz => Finset.le_max' I z hz) (hlt _ (Finset.max'_mem I he)) ht + exact ih hIp + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ProductTruncationError.lean b/lean/OAI/Probability/Ballisticity/Estimates/ProductTruncationError.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dc9b2a575d11a0fa3b76fe95ed93115f6956abc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ProductTruncationError.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.SignedStripTruncation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal +namespace DirectionalTransience + +lemma product_submeasure_error {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] + (μ₁ ν₁ : Measure α) (μ₂ ν₂ : Measure β) + [IsFiniteMeasure μ₁] [IsFiniteMeasure ν₁] [IsFiniteMeasure μ₂] [IsFiniteMeasure ν₂] + (h₁ : ν₁ ≤ μ₁) (h₂ : ν₂ ≤ μ₂) (ht₁ : μ₁ Set.univ ≤ 1) (ht₂ : μ₂ Set.univ ≤ 1) + {ε₁ ε₂ : ℝ≥0∞} + (he₁ : μ₁ Set.univ ≤ ν₁ Set.univ+ε₁) (he₂ : μ₂ Set.univ ≤ ν₂ Set.univ+ε₂) + (S : Set (α × β)) : + μ₁.prod μ₂ S ≤ ν₁.prod ν₂ S+ε₁+ε₂ := by + let δ₁ := μ₁-ν₁ + let δ₂ := μ₂-ν₂ + have hd₁ : δ₁+ν₁=μ₁ := Measure.sub_add_cancel_of_le h₁ + have hd₂ : δ₂+ν₂=μ₂ := Measure.sub_add_cancel_of_le h₂ + have hδ₁ : δ₁ Set.univ ≤ ε₁ := by + rw [show δ₁ = μ₁-ν₁ from rfl,Measure.sub_apply MeasurableSet.univ h₁] + exact tsub_le_iff_right.mpr (by simpa only [add_comm] using he₁) + have hδ₂ : δ₂ Set.univ ≤ ε₂ := by + rw [show δ₂ = μ₂-ν₂ from rfl,Measure.sub_apply MeasurableSet.univ h₂] + exact tsub_le_iff_right.mpr (by simpa only [add_comm] using he₂) + have hν₁ : ν₁ Set.univ ≤ 1 := (h₁ Set.univ).trans ht₁ + have hp₁ : δ₁.prod μ₂ S ≤ ε₁ := by + calc + _ ≤ δ₁.prod μ₂ Set.univ := measure_mono (Set.subset_univ _) + _ = δ₁ Set.univ*μ₂ Set.univ := by rw [←Set.univ_prod_univ,Measure.prod_prod] + _ ≤ ε₁*1 := mul_le_mul' hδ₁ ht₂ + _ = ε₁ := mul_one _ + have hp₂ : ν₁.prod δ₂ S ≤ ε₂ := by + calc + _ ≤ ν₁.prod δ₂ Set.univ := measure_mono (Set.subset_univ _) + _ = ν₁ Set.univ*δ₂ Set.univ := by rw [←Set.univ_prod_univ,Measure.prod_prod] + _ ≤ 1*ε₂ := mul_le_mul' hν₁ hδ₂ + _ = ε₂ := one_mul _ + calc + μ₁.prod μ₂ S = δ₁.prod μ₂ S+ν₁.prod μ₂ S := by rw [←hd₁,Measure.add_prod,Measure.add_apply] + _ = δ₁.prod μ₂ S+(ν₁.prod δ₂ S+ν₁.prod ν₂ S) := by + congr 1 + rw [←hd₂,Measure.prod_add,Measure.add_apply] + _ ≤ ε₁+(ε₂+ν₁.prod ν₂ S) := add_le_add hp₁ (add_le_add hp₂ le_rfl) + _ = ν₁.prod ν₂ S+ε₁+ε₂ := by ac_rfl +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma rawPairEndpointLaw_truncation {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (e : Direction d) (x : Lattice d × Lattice d) + {H : ℕ} (hH : 0 < H) (k : ℕ) (S : Set (Lattice d × Lattice d)) : + rawPairEndpointLaw (realPosition (step e)) H ω x S ≤ + (truncatedEndpointLaw e H (k*H) ω x.1).prod (truncatedEndpointLaw e H (k*H) ω x.2) S+ + (1-(κ:ℝ≥0∞)^H)^k+(1-(κ:ℝ≥0∞)^H)^k := by + let (y : Lattice d) : IsFiniteMeasure (hitKernel (Strip (realPosition (step e)) y H) (Upper (realPosition (step e)) y H) (ω,y)) := + ⟨lt_of_le_of_lt (hitKernel_total_le_one (disjoint_strip_upper _ _ _) _) ENNReal.one_lt_top⟩ + apply product_submeasure_error + · exact truncatedEndpointLaw_le e hH _ _ _ + · exact truncatedEndpointLaw_le e hH _ _ _ + · exact hitKernel_total_le_one (disjoint_strip_upper _ _ _) _ + · exact hitKernel_total_le_one (disjoint_strip_upper _ _ _) _ + · exact truncatedEndpointLaw_mass_error ω hκ e x.1 hH k + · exact truncatedEndpointLaw_mass_error ω hκ e x.2 hH k + +lemma rawPairEndpointLaw_compare {d : ℕ} (ω η : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (e : Direction d) (x : Lattice d × Lattice d) + {H : ℕ} (hH : 0 < H) (k : ℕ) + (he : Set.EqOn ω η (LatticeBall x.1 (k*H) ∪ LatticeBall x.2 (k*H))) + (S : Set (Lattice d × Lattice d)) : + rawPairEndpointLaw (realPosition (step e)) H ω x S ≤ + rawPairEndpointLaw (realPosition (step e)) H η x S+ + (1-(κ:ℝ≥0∞)^H)^k+(1-(κ:ℝ≥0∞)^H)^k := by + have ht := rawPairEndpointLaw_truncation ω hκ e x hH k S + rw [truncatedEndpointLaw_locality e hH _ ω η x.1 (he.mono Set.subset_union_left), + truncatedEndpointLaw_locality e hH _ ω η x.2 (he.mono Set.subset_union_right)] at ht + exact ht.trans (add_le_add (add_le_add + ((Measure.prod_mono (truncatedEndpointLaw_le e hH _ _ _) (truncatedEndpointLaw_le e hH _ _ _)) S) le_rfl) le_rfl) + +lemma rawPairEndpointLaw_uniform_locality {d : ℕ} {κ : ℝ≥0} (hκ : 0 < κ) + (e : Direction d) {H : ℕ} (hH : 0 < H) {ε : ℝ≥0∞} (hε : 0 < ε) : + ∃ N : ℕ, ∀ (ω η : Environment d), + (∀ y g, κ ≤ (ω y).1 g) → (∀ y g, κ ≤ (η y).1 g) → + ∀ x : Lattice d × Lattice d, + Set.EqOn ω η (LatticeBall x.1 N ∪ LatticeBall x.2 N) → + ∀ S : Set (Lattice d × Lattice d), + rawPairEndpointLaw (realPosition (step e)) H ω x S ≤ + rawPairEndpointLaw (realPosition (step e)) H η x S+ε ∧ + rawPairEndpointLaw (realPosition (step e)) H η x S ≤ + rawPairEndpointLaw (realPosition (step e)) H ω x S+ε := by + have hc : 1-(κ:ℝ≥0∞)^H < 1 := + ENNReal.sub_lt_self ENNReal.one_ne_top one_ne_zero (pow_ne_zero _ (by exact_mod_cast hκ.ne')) + have heps : 0 < ε/2 := ENNReal.div_pos_iff.mpr ⟨hε.ne',by norm_num⟩ + obtain ⟨k,hk⟩ := ((ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one hc).eventually_lt_const heps).exists + have hs : (1-(κ:ℝ≥0∞)^H)^k+(1-(κ:ℝ≥0∞)^H)^k ≤ ε := by + calc + _ ≤ ε/2+ε/2 := add_le_add hk.le hk.le + _ = ε := ENNReal.add_halves ε + refine ⟨k*H,?_⟩ + intro ω η hω hη x he S + constructor + · exact (rawPairEndpointLaw_compare ω η hω e x hH k he S).trans + (by simpa only [add_assoc] using add_le_add_right hs (rawPairEndpointLaw (realPosition (step e)) H η x S)) + · exact (rawPairEndpointLaw_compare η ω hη e x hH k he.symm S).trans + (by simpa only [add_assoc] using add_le_add_right hs (rawPairEndpointLaw (realPosition (step e)) H ω x S)) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ProfileMeasureUpdate.lean b/lean/OAI/Probability/Ballisticity/Estimates/ProfileMeasureUpdate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e49bdb065d4c29ec9be10c874ead97c1ec12a35 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ProfileMeasureUpdate.lean @@ -0,0 +1,110 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ProperProfile + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical BigOperators +namespace DirectionalTransience + +lemma measure_le_of_atoms {X : Type*} [MeasurableSpace X] [Countable X] + [MeasurableSingletonClass X] {μ ν : Measure X} (h : ∀ x, μ {x}≤ν {x}) : μ≤ν := by + apply Measure.le_iff.mpr + intro s hs + conv_lhs => rw [←μ.sum_smul_dirac] + conv_rhs => rw [←ν.sum_smul_dirac] + simp only [Measure.sum_apply _ hs,Measure.smul_apply,smul_eq_mul] + apply ENNReal.tsum_le_tsum + intro x + exact mul_le_mul (h x) le_rfl zero_le zero_le + +noncomputable def arrayProfileMeasure {d : ℕ} (e : Direction d) (j : ℤ) + (p : StationaryCompact.Label) (Y : ActualEpisodeArray e) : Measure (HorizontalSpace e) := + Measure.sum (fun z => arrayProfileMass e j p z Y • Measure.dirac z) + +lemma arrayProfileMeasure_atom {d : ℕ} (e : Direction d) (j : ℤ) + (p : StationaryCompact.Label) (Y : ActualEpisodeArray e) (z : HorizontalSpace e) : + arrayProfileMeasure e j p Y {z}=arrayProfileMass e j p z Y := + Measure.sum_smul_dirac_singleton + +lemma arrayProfileImage {d : ℕ} (e : Direction d) (i : ℤ) (m a H : ℕ) + (Y : ActualEpisodeArray e) (A : Set (HorizontalSpace e)) : + (upperHorizontalKernel e H (arrayUpperRows e i m a Y) ∘ₘ arrayProfileMeasure e i (i,a) Y) A= + arrayKernelImage e i m a H A Y := by + rw [Measure.comp_eq_sum_of_countable,Measure.sum_apply _ (Set.to_countable A).measurableSet] + simp only [Measure.smul_apply,smul_eq_mul,arrayProfileMeasure_atom] + rfl + +lemma arrayProfile_measure_update {d : ℕ} (e : Direction d) (i : ℤ) (m a H : ℕ) + (Y : ActualEpisodeArray e) (hc : ArrayContinuation e Y) (hh : arrayWindowHeight e i m Y=H) : + upperHorizontalKernel e H (arrayUpperRows e i m a Y) ∘ₘ arrayProfileMeasure e i (i,a) Y ≤ + expNeg (arrayWindowCost e i m Y) • arrayProfileMeasure e (i+m) (i,a) Y := by + apply measure_le_of_atoms + intro z + rw [arrayProfileImage,Measure.smul_apply,smul_eq_mul,arrayProfileMeasure_atom] + exact hc i m a H z hh + +lemma properProfileKernel_eq_map {d : ℕ} (e : Direction d) (w : ProperProfile e) : + properProfileKernel e w=(Measure.sum (fun z => w.1 z • Measure.dirac z)).map (horizontalLayerEquiv e) := by + rw [Measure.map_sum (measurable_of_countable _).aemeasurable] + simp only [Measure.map_smul _ (measurable_of_countable _).aemeasurable, + Measure.map_dirac' (measurable_of_countable _)] + rfl + +lemma properData_kernel_eq {d : ℕ} (e : Direction d) (w₀ : ProperProfile e) (p : MarkedArray e) + (hp : IsProperProfile e (markedProfile e (markedData e p))) : + properProfileKernel e (properData e w₀ (markedData e p))= + (arrayProfileMeasure e 0 (0,p.2) p.1).map (horizontalLayerEquiv e) := by + rw [properProfileKernel_eq_map,properData_eq _ _ _ hp] + rfl + +lemma horizontalKernel_fill {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1≠f) + (H : ℕ) (ξ : UpperRows e) (ω : Environment d) (z : HorizontalSpace e) : + horizontalCoordinateKernel e f H (fillUpper e (ξ,ω)) (horizontalLayerEquiv e z)= + (upperHorizontalKernel e H ξ z).map (fun x => x.1 f) := by + rw [horizontalCoordinateKernel_apply] + change (hitKernel (Strip _ z.val H) (Upper _ z.val H) (fillUpper e (ξ,ω),z.val)).map _= + ((variableHitKernel _ H (upperEnvironment e ξ,horizontalLift e 0 z)).map (horizontalProjection e)).map _ + rw [Measure.map_map (measurable_of_countable _) (measurable_of_countable _)] + have hz : horizontalLift e 0 z=z.val := by simp [horizontalLift] + rw [hz] + have hk : hitKernel (Strip (realPosition (step e)) z.val H) (Upper (realPosition (step e)) z.val H) + (fillUpper e (ξ,ω),z.val)= + hitKernel (Strip (realPosition (step e)) z.val H) (Upper (realPosition (step e)) z.val H) + (upperEnvironment e ξ,z.val) := by + apply hitKernel_congr + intro x hx + apply fillUpper_eq + have h0 : dot (realPosition z.val) (realPosition (step e))=0 := by + rw [signedHeight_projection] + have hz0 : z.val e.1=0 := z.property + simp [signedHeight,hz0] + have hh := hx.1 + rw [h0,signedHeight_projection] at hh + exact_mod_cast hh + rw [hk] + apply congrArg (fun k => Measure.map k (hitKernel (Strip (realPosition (step e)) z.val H) + (Upper (realPosition (step e)) z.val H) (upperEnvironment e ξ,z.val))) + funext x + simp [Function.comp_apply,horizontalProjection,Ne.symm hef] + +lemma horizontalProfileImage_fill {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1≠f) + (H : ℕ) (ξ : UpperRows e) (ω : Environment d) (μ : Measure (HorizontalSpace e)) : + horizontalCoordinateKernel e f H (fillUpper e (ξ,ω)) ∘ₘ μ.map (horizontalLayerEquiv e)= + (upperHorizontalKernel e H ξ ∘ₘ μ).map (fun x => x.1 f) := by + ext A hA + rw [Measure.bind_apply hA (Kernel.aemeasurable _), + lintegral_map ((horizontalCoordinateKernel e f H (fillUpper e (ξ,ω))).measurable_coe hA) + (measurable_of_countable _),Measure.map_apply (measurable_of_countable _) hA, + Measure.bind_apply ((measurable_of_countable _) hA) (Kernel.aemeasurable _)] + apply lintegral_congr + intro z + rw [horizontalKernel_fill e f hef,Measure.map_apply (measurable_of_countable _) hA] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ProperProfile.lean b/lean/OAI/Probability/Ballisticity/Estimates/ProperProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a5162e28d4bb9f20d0bd6ab86cdb12a217b7443 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ProperProfile.lean @@ -0,0 +1,203 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayMarkedEntropy +import OAI.Probability.Ballisticity.Walk.ProfileGrowth2 + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +def horizontalLayerEquiv {d : ℕ} (e : Direction d) : HorizontalSpace e ≃ HorizontalLayer e where + toFun x := ⟨x.val,x.property⟩ + invFun x := ⟨x.val,x.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +def IsProperProfile {d : ℕ} (e : Direction d) (w : HorizontalSpace e → ℝ≥0∞) : Prop := + (∀ z, 0 measurableSet_lt measurable_const (measurable_pi_apply z)).inter + (measurableSet_le (Measurable.tsum fun z => measurable_pi_apply z) measurable_const) + +abbrev ProperProfile {d : ℕ} (e : Direction d) := {w : HorizontalSpace e → ℝ≥0∞ // IsProperProfile e w} + +noncomputable def properProfileKernel {d : ℕ} (e : Direction d) : Kernel (ProperProfile e) (HorizontalLayer e) := + Kernel.mk (fun w => Measure.sum (fun z : HorizontalSpace e => w.1 z • Measure.dirac (horizontalLayerEquiv e z))) (by + apply Measure.measurable_of_measurable_coe + intro s hs + simp only [Measure.sum_apply _ hs,Measure.smul_apply,smul_eq_mul] + exact Measurable.tsum fun z => ((measurable_pi_apply z).comp measurable_subtype_coe).mul_const _) + +lemma properProfileKernel_apply {d : ℕ} (e : Direction d) (w : ProperProfile e) (z : HorizontalSpace e) : + properProfileKernel e w {horizontalLayerEquiv e z}=w.1 z := by + change (Measure.sum (fun y : HorizontalSpace e => w.1 y • Measure.dirac (horizontalLayerEquiv e y))) {horizontalLayerEquiv e z}=_ + rw [Measure.sum_apply _ (measurableSet_singleton _)] + simp only [Measure.smul_apply,smul_eq_mul,Measure.dirac_apply' _ (measurableSet_singleton _)] + rw [tsum_eq_single z] + · simp + · intro y hy + simp [hy,(horizontalLayerEquiv e).injective.eq_iff] + +lemma properProfileKernel_total {d : ℕ} (e : Direction d) (w : ProperProfile e) : + properProfileKernel e w Set.univ≤1 := by + change (Measure.sum (fun z : HorizontalSpace e => w.1 z • Measure.dirac (horizontalLayerEquiv e z))) Set.univ≤1 + simpa only [Measure.sum_apply _ MeasurableSet.univ,Measure.smul_apply,smul_eq_mul,Measure.dirac_apply_of_mem (Set.mem_univ _),mul_one] using w.2.2 + +instance properProfileKernel_finite {d : ℕ} (e : Direction d) : IsFiniteKernel (properProfileKernel e) := + ⟨⟨1,ENNReal.one_lt_top,properProfileKernel_total e⟩⟩ + +lemma properProfileKernel_full {d : ℕ} (e : Direction d) (w : ProperProfile e) (z : HorizontalLayer e) : + 0<(properProfileKernel e w).real {z} := by + change 0<(properProfileKernel e w {z}).toReal + rw [←(horizontalLayerEquiv e).apply_symm_apply z,properProfileKernel_apply] + exact ENNReal.toReal_pos (w.2.1 _).ne' (ne_top_of_le_ne_top ENNReal.one_ne_top ((ENNReal.le_tsum _).trans w.2.2)) + +noncomputable def markedProfile {d : ℕ} (e : Direction d) (p : MarkedCurrentData e) : HorizontalSpace e → ℝ≥0∞ := + fun z => ENNReal.ofReal (p.1.2 (p.2,z):ℝ) + +lemma markedProfile_measurable {d : ℕ} (e : Direction d) : Measurable (markedProfile e) := by + apply Measurable.of_eval + intro z + exact Measurable.ennreal_ofReal ((measurable_from_prod_countable_left fun a => + ((measurable_pi_apply (a,z)).comp measurable_snd).subtype_val)) + +noncomputable def properData {d : ℕ} (e : Direction d) (w₀ : ProperProfile e) (p : MarkedCurrentData e) : ProperProfile e := + if h : IsProperProfile e (markedProfile e p) then ⟨markedProfile e p,h⟩ else w₀ + +lemma properData_measurable {d : ℕ} (e : Direction d) (w₀ : ProperProfile e) : Measurable (properData e w₀) := by + apply Measurable.subtype_mk + have he : (fun p => (properData e w₀ p).val)=(fun p => if IsProperProfile e (markedProfile e p) then markedProfile e p else w₀.1) := by + funext p + by_cases hp : IsProperProfile e (markedProfile e p) <;> simp [properData,hp] + change Measurable (fun p => (properData e w₀ p).val) + rw [he] + exact Measurable.ite ((isProperProfile_measurable e).preimage (markedProfile_measurable e)) + (markedProfile_measurable e) measurable_const + +lemma properData_eq {d : ℕ} (e : Direction d) (w₀ : ProperProfile e) (p : MarkedCurrentData e) + (hp : IsProperProfile e (markedProfile e p)) : (properData e w₀ p).1=markedProfile e p := by + simp only [properData,dite_eq_left hp] + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma marked_profile_proper (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + ∀ᵐ p ∂markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event, + IsProperProfile e (markedProfile e (markedData e p)) := by + have h := markedArrayLaw_ae e (L.law : Measure (ActualEpisodeArray e)) G.event G.measurable_event + (show ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → + ArrayProfilesConsistent e Y ∧ ∀ i a z, 0<(Y.2.2.1 (i,(i,a),z):ℝ) from by + filter_upwards [L.consistent,L.full_profiles hue htrans G] with Y hO hF hY + exact ⟨hO.2,hF hY⟩) + filter_upwards [h] with p hp + exact ⟨fun z => ENNReal.ofReal_pos.mpr (hp.2 0 p.2 z),arrayProfileMass_total_le_one e p.1 hp.1 0 (0,p.2)⟩ + +lemma properProfile_nonempty (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : Nonempty (ProperProfile e) := by + have := markedArrayLaw_probability e (L.law : Measure (ActualEpisodeArray e)) G.event G.positive_event.ne' + obtain ⟨p,hp⟩ := (L.marked_profile_proper hue htrans G).exists + exact ⟨⟨_,hp⟩⟩ + +end StationaryArrayLaw +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +noncomputable def fillUpper {d : ℕ} (e : Direction d) (p : UpperRows e × Environment d) : Environment d := + rowGraft {x | 0 ≤ signedHeight e x} (upperEnvironment e p.1) p.2 + +lemma fillUpper_measurable {d : ℕ} (e : Direction d) : Measurable (fillUpper e) := + (rowGraft_measurable _).comp (((upperEnvironment_continuous e).measurable.comp measurable_fst).prodMk measurable_snd) + +lemma fillUpper_eq {d : ℕ} (e : Direction d) (ξ : UpperRows e) (ω : Environment d) + (x : Lattice d) (hx : 0 ≤ signedHeight e x) : + fillUpper e (ξ,ω) x=upperEnvironment e ξ x := by simp [fillUpper,rowGraft,hx] + +lemma fillUpper_reference {d : ℕ} (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] : + ((Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)).prod (environmentLaw ν)).map (fillUpper e)= + environmentLaw ν := by + apply Measure.ext_of_lintegral + intro f hf + rw [lintegral_map hf (fillUpper_measurable e),lintegral_prod _ (show Measurable (fun p => f (fillUpper e p)) from hf.comp (fillUpper_measurable e)).aemeasurable, + ←upperField_map e ν 0] + rw [lintegral_map ((show Measurable (fun p => f (fillUpper e p)) from hf.comp (fillUpper_measurable e)).lintegral_prod_right') ((upperField_measurable_rows e 0).mono (rowSigma_le _) le_rfl)] + have he (η ξ : Environment d) : fillUpper e (upperField e 0 η,ξ)=rowGraft {x | 0 ≤ signedHeight e x} η ξ := by + funext x + by_cases hx : 0 ≤ signedHeight e x + · simp only [fillUpper,rowGraft,Set.mem_ofPred_eq,ite_eq_left hx,upperEnvironment_restrict_eq e η x (by rw [signedHeight_projection]; exact_mod_cast hx)] + · simp only [fillUpper,rowGraft,Set.mem_ofPred_eq,ite_eq_right hx] + simp_rw [he] + simpa only [Set.indicator_univ] using rowGraft_event_lintegral ν {x | 0 ≤ signedHeight e x} + Set.univ MeasurableSet.univ f hf + +lemma fillUpper_joint_reference {d : ℕ} {D : Type*} [MeasurableSpace D] + (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (δ : Measure D) [IsFiniteMeasure δ] : + ((δ.prod (Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν))).prod (environmentLaw ν)).map + (fun p => (p.1.1,fillUpper e (p.1.2,p.2)))=δ.prod (environmentLaw ν) := by + have hp : Measurable (fun p : (D × UpperRows e) × Environment d => (p.1.1,fillUpper e (p.1.2,p.2))) := + measurable_fst.fst.prodMk ((fillUpper_measurable e).comp (measurable_fst.snd.prodMk measurable_snd)) + apply Measure.ext_of_lintegral + intro f hf + have hfp : Measurable (fun p : (D × UpperRows e) × Environment d => f (p.1.1,fillUpper e (p.1.2,p.2))) := hf.comp hp + rw [lintegral_map hf hp,lintegral_prod _ hfp.aemeasurable, + lintegral_prod _ hfp.lintegral_prod_right'.aemeasurable, + lintegral_prod _ hf.aemeasurable] + apply lintegral_congr + intro a + have hm : Measurable (fun p : UpperRows e × Environment d => f (a,fillUpper e p)) := + hf.comp (measurable_const.prodMk (fillUpper_measurable e)) + rw [←lintegral_prod _ hm.aemeasurable] + simpa only [Function.comp_apply,id_eq,fillUpper_reference e ν] using + (lintegral_map (μ := (Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)).prod (environmentLaw ν)) + (hf.comp (measurable_const.prodMk measurable_id)) (fillUpper_measurable e)).symm + +lemma fillUpper_finite_entropy {d : ℕ} {Ω D : Type*} [MeasurableSpace Ω] [MeasurableSpace D] + (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (μ : Measure Ω) [IsProbabilityMeasure μ] + (u : Ω → D) (hu : Measurable u) (ξ : Ω → UpperRows e) (hξ : Measurable ξ) + (hkl : klDiv (μ.map (fun ω => (u ω,ξ ω))) + ((μ.map u).prod (Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)))≠∞) : + klDiv ((μ.prod (environmentLaw ν)).map (fun p => (u p.1,fillUpper e (ξ p.1,p.2)))) + ((μ.map u).prod (environmentLaw ν))≠∞ := by + have : Nonempty (Row d) := nonempty_of_isProbabilityMeasure ν + let W := μ.map (fun ω => (u ω,ξ ω)) + let R := (μ.map u).prod (Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)) + have : IsProbabilityMeasure W := + (Measure.isProbabilityMeasure_map_iff (hu.prodMk hξ).aemeasurable).mpr inferInstance + have : IsProbabilityMeasure (μ.map u) := + (Measure.isProbabilityMeasure_map_iff hu.aemeasurable).mpr inferInstance + have : IsProbabilityMeasure R := by dsimp only [R]; infer_instance + have hp : Measurable (fun p : (D × UpperRows e) × Environment d => (p.1.1,fillUpper e (p.1.2,p.2))) := + measurable_fst.fst.prodMk ((fillUpper_measurable e).comp (measurable_fst.snd.prodMk measurable_snd)) + have hh := klDiv_map_le (W.prod (environmentLaw ν)) (R.prod (environmentLaw ν)) hp + rw [StoppedWindow.same_auxiliary_cost] at hh + have he : (W.prod (environmentLaw ν)).map (fun p => (p.1.1,fillUpper e (p.1.2,p.2)))= + (μ.prod (environmentLaw ν)).map (fun p => (u p.1,fillUpper e (ξ p.1,p.2))) := by + have hmap := Measure.map_prod_map μ (environmentLaw ν) (hu.prodMk hξ) measurable_id + simp only [Measure.map_id] at hmap + rw [show W.prod (environmentLaw ν)=_ from hmap,Measure.map_map hp ((hu.prodMk hξ).prodMap measurable_id)] + rfl + rw [he,fillUpper_joint_reference] at hh + exact ne_top_of_le_ne_top hkl hh + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ProtectionFirstFailure.lean b/lean/OAI/Probability/Ballisticity/Estimates/ProtectionFirstFailure.lean new file mode 100644 index 0000000000000000000000000000000000000000..84dc6989f641cac0dfc36fa649495ac2de3794fe --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ProtectionFirstFailure.lean @@ -0,0 +1,191 @@ +import Mathlib +import OAI.Probability.Ballisticity.Coupling.FreshBudgetEvent +import OAI.Probability.Ballisticity.Estimates.RadixBudget + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +lemma first_protection_failure_split_offset (q : ℕ → ℝ) (kA : ℝ) (hkA : 0≤kA) + (s : ℝ) (hs : 0 ≤ s) (n : ℕ) (hq : ∀ i≤n, 0≤q i ∧ q i≤1) + (hpass : ∀ j (hq j (by simp only [Finset.mem_range] at hj; omega)).1) + (fun j hj _ => (hq j (by simp only [Finset.mem_range] at hj; omega)).2) + simpa using hh + apply le_trans _ ((hpass i hit).trans hprod) + apply Real.exp_le_exp.mpr + have hi0 : 0 ≤ s+(i:ℝ)+1 := by positivity + nlinarith only [mul_nonneg hkA hi0] + have hprod : (∏ i∈Finset.range (n+1), q i)=Real.exp + (-(∑ i∈Finset.range (n+1), cappedLogLoss (2*kA*(s+i+1)) (q i))) := by + rw [← Finset.sum_neg_distrib,Real.exp_sum] + apply Finset.prod_congr rfl + intro i hi + rw [exp_neg_cappedLogLoss (hq i (by simpa using hi)).1,max_eq_right (hlow i (by simpa using hi))] + rw [hprod,Real.exp_lt_exp] at hfail + linarith only [hfail] + +def firstProtectionFailure {Ω : Type*} (q : ℕ → Ω → ℝ) (kA s : ℝ) (n : ℕ) : Set Ω := + {ω | (∀ j cappedLogLoss (2*kA*(s+i+1)) (q i ω) + have hX : ∀ i, Measurable[ℱ (i+1)] (X i) := fun i => + @measurable_cappedLogLoss Ω (ℱ (i+1)) _ _ (hqm i) + let E : Set Ω := {ω | kA*(s+n+1)≤∑ i∈Finset.range (n+1), X i ω} + have hEm : MeasurableSet E := measurableSet_le measurable_const + (Finset.measurable_fun_sum _ (fun i _ => (hX i).mono (ℱ.le _) le_rfl)) + have hAm : MeasurableSet A := ℱ.le 0 A hA + have hW : Measurable[ℱ 0] (A.indicator (fun _ : Ω => (1:ℝ≥0∞))) := measurable_const.indicator hA + have htail := adapted_weighted_exp_sum_tail μ ℱ X hX _ hW t C ht (n+1) hstep (kA*(s+n+1)) + have heq : μ.withDensity (A.indicator (fun _ : Ω => (1:ℝ≥0∞)))=μ.restrict A := + withDensity_indicator_one hAm + rw [heq,Measure.restrict_apply hEm,lintegral_indicator hAm] at htail + simp only [lintegral_const,one_mul,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,Nat.cast_add,Nat.cast_one] at htail + have hsub : A∩firstProtectionFailure q kA s n ⊆ + (A∩{ω | q n ω q i ω) kA hkA s hs n + (fun i _ => hq i ω) hpass hfail with h|h + · exact Or.inl ⟨hω,h⟩ + · exact Or.inr ⟨hω,h.le⟩ + apply (measure_mono hsub).trans ((measure_union_le _ _).trans _) + rw [add_mul] + apply add_le_add (hcap A (ℱ.mono (Nat.zero_le n) A hA)) + simpa only [Set.inter_comm] using htail + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +lemma protection_failure_exponents {lam Cmg A : ℝ} (hC : 0≤Cmg) + (hA : Cmg+8≤(lam/4)*A) (k s n : ℕ) (hk : 1≤k) : + Real.exp (-lam*((2*A*k)*((s:ℝ)+n+1))/2)+ + Real.exp ((Cmg*k)*((n:ℝ)+1)-(lam/4)*((A*k)*((s:ℝ)+n+1)))≤ + Real.exp (-5*k*((s:ℝ)+n+1)) := by + let T : ℝ := s+n+1 + have hT : 1≤T := by dsimp [T]; linarith [Nat.cast_nonneg (α:=ℝ) s,Nat.cast_nonneg (α:=ℝ) n] + have hk1 : (1:ℝ)≤k := by exact_mod_cast hk + have hkT : 1≤(k:ℝ)*T := one_le_mul_of_one_le_of_one_le hk1 hT + have hCpos : 0≤Cmg*k*T := by positivity + have hah := mul_le_mul_of_nonneg_right hA (show 0≤(k:ℝ)*T by positivity) + have hcap : -lam*((2*A*k)*T)/2≤-8*k*T := by nlinarith only [hah,hCpos,hkT] + have hcount : Cmg*k*((n:ℝ)+1)≤Cmg*k*T := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + dsimp [T]; linarith [Nat.cast_nonneg (α:=ℝ) s] + have hsum : (Cmg*k)*((n:ℝ)+1)-(lam/4)*((A*k)*T)≤-8*k*T := by + nlinarith only [hah,hcount] + have he : 2≤Real.exp (3*k*T) := by + have hh := Real.add_one_le_exp (3*k*T) + nlinarith only [hh,hkT] + calc + _ ≤ 2*Real.exp (-8*k*T) := by + have h1 := Real.exp_le_exp.mpr hcap + have h2 := Real.exp_le_exp.mpr hsum + change Real.exp (-lam*((2*A*k)*T)/2)+Real.exp ((Cmg*k)*((n:ℝ)+1)-(lam/4)*((A*k)*T))≤_ + linarith only [h1,h2] + _ ≤ Real.exp (3*k*T)*Real.exp (-8*k*T) := mul_le_mul_of_nonneg_right he (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; dsimp [T]; ring + +theorem actual_late_protection_first_failure {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1≠f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ lam Cmg : ℝ, 0 (lateBudget_pos hc (lt_of_lt_of_le hR hρR) l₀ i).le) π) + (A*k) l₀ n)≤ENNReal.ofReal (Real.exp (-5*k*((l₀:ℝ)+n+1)))*environmentLaw ν E := by + obtain ⟨lam,Cmg,hlam,hlam1,hCmg,hh⟩ := scheduled_late_step_bounds ν hue e f hef htrans + refine ⟨lam,Cmg,hlam,hlam1,hCmg,?_⟩ + intro A hA hAchoice k hk c C hc hc1 hC + have hk1 : 1≤k := by omega + have hk1r : (1:ℝ)≤k := by exact_mod_cast hk1 + have hak : 1≤2*A*k := by nlinarith + obtain ⟨l₀,hlpos,hl₀⟩ := hh k hk (2*A*k) hak c C hc hc1 hC + refine ⟨l₀,hlpos,fun Bstar hB => ?_⟩ + obtain ⟨R,hR,hbound⟩ := hl₀ Bstar hB + refine ⟨R,hR,?_⟩ + intro ρ hρR n hcap H hH base π hπ E hE + have hρ := hR.trans_le hρR + let r := lateBudget c ρ l₀ + let hr := fun i => (lateBudget_pos hc hρ l₀ i).le + let q := protectionMass e f base (3*c*ρ/4) H r hr π + let ℱ := protectionFiltration e base H + have hqm : ∀ i, Measurable[ℱ (i+1)] (q i) := protectionMass_measurable e f base _ H r hr π hπ + have hqb : ∀ i ω, 0≤q i ω ∧ q i ω≤1 := protectionMass_bounds e f base _ H r hr π + have hiCap (i : ℕ) (hi : i≤n) : (2*A*k)*((l₀:ℝ)+i+1)≤Bstar := by + apply le_trans _ hcap + gcongr + have hb (i : ℕ) (hi : i≤n) (p : BudgetProfile (k:=k) e f (protectionHeight base H i) + (protectionGap (3*c*ρ/4) r i)) := hbound ρ hρR i (hiCap i hi) (H i) (hH i hi) _ p + have hstep : ∀ i (hq j (by simp only [Finset.mem_range] at hj; omega)).1) + (fun j hj _ => (hq j (by simp only [Finset.mem_range] at hj; omega)).2) + simpa using hh + apply le_trans _ ((hpass i hit).trans hprod) + apply Real.exp_le_exp.mpr + have hi0 : 0≤(i:ℝ)+1 := by positivity + nlinarith only [mul_nonneg hkA hi0] + have hprod : (∏ i∈Finset.range (n+1), q i)=Real.exp + (-(∑ i∈Finset.range (n+1), cappedLogLoss (2*kA*(i+1)) (q i))) := by + rw [← Finset.sum_neg_distrib,Real.exp_sum] + apply Finset.prod_congr rfl + intro i hi + rw [exp_neg_cappedLogLoss (hq i (by simpa using hi)).1,max_eq_right (hlow i (by simpa using hi))] + rw [hprod,Real.exp_lt_exp] at hfail + linarith only [hfail] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +def protectionHeight (base : ℝ) (H : ℕ → ℕ) : ℕ → ℝ + | 0 => base + | n+1 => protectionHeight base H n + H n + +def protectionGap (G : ℝ) (r : ℕ → ℝ) : ℕ → ℝ + | 0 => G + | n+1 => protectionGap G r n-r n + +lemma protectionHeight_mono (base : ℝ) (H : ℕ → ℕ) : Monotone (protectionHeight base H) := by + apply monotone_nat_of_le_succ + intro n + exact le_add_of_nonneg_right (Nat.cast_nonneg _) + +lemma protectionHeight_eq (base : ℝ) (H : ℕ → ℕ) (n : ℕ) : + protectionHeight base H n=base+∑ i∈Finset.range n, (H i:ℝ) := by + induction n with + | zero => simp [protectionHeight] + | succ n ih => simp [protectionHeight,ih,Finset.sum_range_succ,add_assoc] + +lemma protectionGap_eq (G : ℝ) (r : ℕ → ℝ) (n : ℕ) : + protectionGap G r n=G-∑ i∈Finset.range n, r i := by + induction n with + | zero => simp [protectionGap] + | succ n ih => simp [protectionGap,ih,Finset.sum_range_succ,sub_sub] + +noncomputable def protectionProfile {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) : + (n : ℕ) → Environment d → BudgetProfile (k:=k) e f + (protectionHeight base H n) (protectionGap G r n) + | 0 => π + | n+1 => fun ω => nextBudgetProfile e f (H n) _ _ (r n) (hr n) + (protectionProfile e f base G H r hr π n ω) ω + +lemma protectionProfile_measurable {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) base)) _ π) (n : ℕ) : + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) + (protectionHeight base H n))) _ (protectionProfile e f base G H r hr π n) := by + induction n with + | zero => exact hπ + | succ n ih => exact nextBudgetProfile_measurable_below e f _ _ _ (hr n) (H n) _ ih + +def protectionFiltration {d : ℕ} (e : Direction d) (base : ℝ) (H : ℕ → ℕ) : + Filtration ℕ (inferInstance : MeasurableSpace (Environment d)) where + seq n := rowSigma (BelowHeight (realPosition (step e)) (protectionHeight base H n)) + mono' _ _ hij := rowSigma_mono (fun _ hx => lt_of_lt_of_le hx (protectionHeight_mono base H hij)) + le' _ := rowSigma_le _ + +noncomputable def protectionMass {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) (n : ℕ) (ω : Environment d) : ℝ := + relativeBudgetMass e f (H n) (r n) (protectionProfile e f base G H r hr π n ω).val ω + +lemma protectionMass_measurable {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) base)) _ π) (n : ℕ) : + Measurable[protectionFiltration e base H (n+1)] (protectionMass e f base G H r hr π n) := by + have hpm := protectionProfile_measurable e f base G H r hr π hπ n + apply (budgetProfileMass_joint_rows e f _ _ (H n) (r n) + (BelowHeight (realPosition (step e)) (protectionHeight base H (n+1))) ?_).comp + ((hpm.mono ((protectionFiltration e base H).mono (Nat.le_succ n)) le_rfl).prodMk measurable_id) + intro x hx j y hy + change dot (realPosition y) (realPosition (step e)) < protectionHeight base H n+H n + simpa only [hx j] using hy.2 + +lemma protectionMass_bounds {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) (n : ℕ) (ω : Environment d) : + 0≤protectionMass e f base G H r hr π n ω ∧ protectionMass e f base G H r hr π n ω≤1 := + relativeBudgetMass_bounds e f (H n) (r n) _ ω + +lemma protection_capped_step {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (base G : ℝ) (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) base)) _ π) + (a t : ℝ) (c : ℝ≥0∞) (n : ℕ) + (hb : ∀ p : BudgetProfile (k:=k) e f (protectionHeight base H n) (protectionGap G r n), + (∫⁻ ω, ENNReal.ofReal (Real.exp (t*cappedLogLoss a + (relativeBudgetMass e f (H n) (r n) p.val ω))) ∂environmentLaw ν)≤c) + (w : Environment d → ℝ≥0∞) (hw : Measurable[protectionFiltration e base H n] w) : + (∫⁻ ω, w ω*ENNReal.ofReal (Real.exp (t*cappedLogLoss a + (protectionMass e f base G H r hr π n ω))) ∂environmentLaw ν)≤c*(∫⁻ ω, w ω ∂environmentLaw ν) := by + apply fresh_budget_capped_moment ν e f _ _ (H n) (r n) a t + (S:=BelowHeight (realPosition (step e)) (protectionHeight base H n)) + (T:={y | protectionHeight base H n≤dot (realPosition y) (realPosition (step e))}) + ?_ ?_ _ (protectionProfile_measurable e f base G H r hr π hπ n) w hw c hb + · apply Set.disjoint_left.mpr + intro x hx hy + exact (not_lt.mpr (show protectionHeight base H n≤dot (realPosition x) (realPosition (step e)) from hy)) + (show dot (realPosition x) (realPosition (step e)) C*x) hp] + _ = _ := by + rw [neg_mul,Real.exp_neg,mul_comm (Real.log 4) (l:ℝ),Real.exp_nat_mul,Real.exp_log (by norm_num : (0:ℝ)<4)] + ring + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +lemma adapted_weighted_product_moment {Ω : Type*} [m : MeasurableSpace Ω] + (μ : Measure Ω) (ℱ : Filtration ℕ m) + (X : ℕ → Ω → ℝ≥0∞) (hX : ∀ n, Measurable[ℱ (n+1)] (X n)) + (W : Ω → ℝ≥0∞) (hW : Measurable[ℱ 0] W) (c : ℝ≥0∞) (N : ℕ) + (hstep : ∀ n W ω*∏ i∈Finset.range n, X i ω) := by + apply (hW.mono (ℱ.mono (Nat.zero_le n)) le_rfl).mul + apply Finset.measurable_fun_prod + intro i hi + exact (hX i).mono (ℱ.mono (by simpa using hi)) le_rfl + induction N with + | zero => simp + | succ N ih => + simp_rw [Finset.prod_range_succ,← mul_assoc] + apply (hstep N (Nat.lt_succ_self N) _ (hm N)).trans + have hh := mul_le_mul_left (ih (fun n hn => hstep n (Nat.lt_trans hn (Nat.lt_succ_self N)))) c + simpa [pow_succ,mul_assoc,mul_comm,mul_left_comm] using hh + +lemma adapted_weighted_exp_sum_tail {Ω : Type*} [m : MeasurableSpace Ω] + (μ : Measure Ω) (ℱ : Filtration ℕ m) + (X : ℕ → Ω → ℝ) (hX : ∀ n, Measurable[ℱ (n+1)] (X n)) + (W : Ω → ℝ≥0∞) (hW : Measurable[ℱ 0] W) + (t C : ℝ) (ht : 0 ENNReal.ofReal (Real.exp (t*X i ω)) + have hY (i : ℕ) : Measurable[ℱ (i+1)] (Y i) := ((hX i).const_mul t).exp.ennreal_ofReal + have hprod := adapted_weighted_product_moment μ ℱ Y hY W hW (ENNReal.ofReal (Real.exp C)) N hstep + have hsum : Measurable (fun ω => ∑ i∈Finset.range N, X i ω) := + Finset.measurable_fun_sum _ (fun i _ => (hX i).mono (ℱ.le _) le_rfl) + have hid (ω : Ω) : (∏ i∈Finset.range N, Y i ω)= + ENNReal.ofReal (Real.exp (t*∑ i∈Finset.range N, X i ω)) := by + simp only [Y,← ENNReal.ofReal_prod_of_nonneg (fun i _ => (Real.exp_pos (t*X i ω)).le), + ← Real.exp_sum,Finset.mul_sum] + simp_rw [hid] at hprod + have hmeas : Measurable (fun ω => ENNReal.ofReal (Real.exp (t*∑ i∈Finset.range N, X i ω))) := + (hsum.const_mul t).exp.ennreal_ofReal + have he : {ω | v≤∑ i∈Finset.range N, X i ω} = + {ω | ENNReal.ofReal (Real.exp (t*v))≤ENNReal.ofReal (Real.exp (t*∑ i∈Finset.range N, X i ω))} := by + ext ω + simp only [Set.mem_ofPred_eq,ENNReal.ofReal_le_ofReal_iff (Real.exp_pos _).le, + Real.exp_le_exp,mul_le_mul_iff_right₀ ht] + rw [he] + apply (meas_ge_le_lintegral_div (μ:=μ.withDensity W) hmeas.aemeasurable + (ne_of_gt (ENNReal.ofReal_pos.mpr (Real.exp_pos _))) ENNReal.ofReal_ne_top).trans + rw [lintegral_withDensity_eq_lintegral_mul μ (hW.mono (ℱ.le 0) le_rfl) hmeas] + calc + _ ≤ (ENNReal.ofReal (Real.exp C)^N*(∫⁻ ω, W ω ∂μ))/ENNReal.ofReal (Real.exp (t*v)) := + ENNReal.div_le_div_right hprod _ + _ = ENNReal.ofReal (Real.exp (C*N-t*v))*(∫⁻ ω, W ω ∂μ) := by + rw [ENNReal.mul_div_right_comm,← ENNReal.ofReal_pow (Real.exp_pos C).le, + ← ENNReal.ofReal_div_of_pos (Real.exp_pos _),← Real.exp_nat_mul,← Real.exp_sub] + congr 2 + ring_nf + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +noncomputable def lateBudget (c ρ : ℝ) (s n : ℕ) : ℝ := (c/16)*ρ/(2:ℝ)^(s+n) + +lemma lateBudget_pos {c ρ : ℝ} (hc : 0 nlinarith [mul_pos hc hρ] + +lemma fixed_budget_momentENN {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (base G : ℝ) (H : ℕ) (b a t C : ℝ) + (ha : 0≤a) (ht : 0≤t) (π : BudgetProfile (k:=k) e f base G) + (hb : (∫ ω, Real.exp (t*cappedLogLoss a (relativeBudgetMass e f H b π.val ω)) + ∂environmentLaw ν)≤Real.exp C) : + (∫⁻ ω, ENNReal.ofReal (Real.exp (t*cappedLogLoss a (relativeBudgetMass e f H b π.val ω))) + ∂environmentLaw ν)≤ENNReal.ofReal (Real.exp C) := by + have hi := integrable_exp_cappedLogLoss (environmentLaw ν) a t ha ht _ + (measurable_relativeBudgetMass_fixed e f base G H b π) + (fun ω => (relativeBudgetMass_bounds e f H b π.val ω).1) + (fun ω => (relativeBudgetMass_bounds e f H b π.val ω).2) + rw [← ofReal_integral_eq_lintegral_ofReal hi (ae_of_all _ fun _ => (Real.exp_pos _).le)] + exact ENNReal.ofReal_le_ofReal hb + +theorem scheduled_late_step_bounds {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1≠f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ lam Cmg : ℝ, 0 3*C*(32*(L:ℝ)/c)^2 + obtain ⟨lmin,hl₀⟩ := hh k hk a ha D (fun L => by dsimp [D]; positivity) + let l₀ := lmin+1 + refine ⟨l₀,by dsimp [l₀]; omega,fun Bstar hB => ?_⟩ + obtain ⟨Gzero,hGzero⟩ := hl₀ Bstar hB + refine ⟨max 1 (2*Gzero/c),lt_of_lt_of_le (by norm_num) (le_max_left _ _),?_⟩ + intro ρ hρR n hn H hH base π + have hρ : 0<ρ := lt_of_lt_of_le (by norm_num) ((le_max_left _ _).trans hρR) + have hG : (Gzero:ℝ)≤c*ρ/2 := by + have hh := (le_max_right 1 (2*Gzero/c)).trans hρR + have hh' := (div_le_iff₀ hc).mp hh + nlinarith only [hh'] + let μ := independentConditionedPairLaw ν (realPosition (step e)) + let S := commonIncrementProcess (realPosition (step e)) f 0 + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν _ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + have hS : Measurable S := measurable_commonIncrementProcess _ _ _ + have hne : 0<μ {x | S x≠0} := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hgaps := lateBudget_gaps hc hρ l₀ n + have hcap : a*((l₀+n:ℕ)+1)≤Bstar := by exact_mod_cast hn + have hb := hGzero (l₀+n) (by dsimp [l₀]; omega) hcap H base _ _ + (lateBudget_pos hc hρ l₀ n) hgaps.1 (hG.trans hgaps.2) + (fun L hL => radix16_budget_ratio μ S hS hne hρ hc hc1 hC.le (l₀+n) L H hL hH) π + constructor + · apply fixed_budget_momentENN ν e f base _ H _ _ _ _ (by positivity) (by positivity) π + simpa only [Nat.cast_add,Nat.cast_one] using hb.1 + · have he : {ω | relativeBudgetMass e f H (lateBudget c ρ l₀ n) π.val ω (n+1:ℝ)^m*a n) + +lemma RapidDecay.of_le {a b : ℕ → ℝ} (hb : RapidDecay b) (ha : ∀ n, 0 ≤ a n) + (hle : ∀ᶠ n in atTop, a n ≤ b n) : RapidDecay a := by + intro m + apply (hb m).of_norm_bounded_eventually_nat + filter_upwards [hle] with n hn + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (by positivity) (ha n))] + exact mul_le_mul_of_nonneg_left hn (by positivity) + +lemma RapidDecay.add {a b : ℕ → ℝ} (ha : RapidDecay a) (hb : RapidDecay b) : + RapidDecay (fun n : ℕ => a n+b n) := by + intro m + simpa only [mul_add] using (ha m).add (hb m) + +lemma RapidDecay.const_mul {a : ℕ → ℝ} (ha : RapidDecay a) (c : ℝ) : + RapidDecay (fun n : ℕ => c*a n) := by + intro m + simpa only [mul_left_comm] using (ha m).mul_left c + +lemma RapidDecay.pow_mul {a : ℕ → ℝ} (ha : RapidDecay a) (k : ℕ) : + RapidDecay (fun n : ℕ => (n+1:ℝ)^k*a n) := by + intro m + simpa only [pow_add,mul_assoc] using ha (m+k) + +lemma RapidDecay.shift {a : ℕ → ℝ} (ha : RapidDecay a) (ha0 : ∀ n, 0 ≤ a n) (k : ℕ) : + RapidDecay (fun n : ℕ => a (n+k)) := by + intro m + apply ((summable_nat_add_iff k).mpr (ha m)).of_norm_bounded + intro n + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (by positivity) (ha0 _))] + apply mul_le_mul_of_nonneg_right _ (ha0 _) + exact pow_le_pow_left₀ (by positivity) (by push_cast; linarith) m + +lemma rapidDecay_of_power_bounds {a : ℕ → ℝ} (ha : ∀ n, 0 ≤ a n) + (h : ∀ D : ℝ, 0 ≤ D → ∀ᶠ n : ℕ in atTop, a n ≤ (n:ℝ)^(-D)) : RapidDecay a := by + intro m + have hs : Summable (fun n : ℕ => (2:ℝ)^m*(n:ℝ)^(-2:ℝ)) := + (Real.summable_nat_rpow.mpr (by norm_num : (-2:ℝ)< -1)).mul_left _ + apply hs.of_norm_bounded_eventually_nat + filter_upwards [h (m+2) (by positivity),eventually_ge_atTop 1] with n hn hn1 + have hn0 : (0:ℝ) (n+1:ℝ)^m*a n) atTop (𝓝 0)) : RapidDecay a := by + intro m + have hs : Summable (fun n : ℕ => ((n+1:ℝ)^2)⁻¹) := by + simpa only [Nat.cast_add,Nat.cast_one] using + (summable_nat_add_iff 1).mpr (Real.summable_nat_pow_inv.mpr (by omega : 1<(2:ℕ))) + apply hs.of_norm_bounded_eventually_nat + filter_upwards [(h (m+2)).eventually (eventually_lt_nhds (by norm_num : (0:ℝ)<1))] with n hn + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (by positivity) (ha n))] + rw [inv_eq_one_div] + apply (le_div_iff₀ (by positivity : (0:ℝ)<(n+1:ℝ)^2)).mpr + simpa only [pow_add,mul_assoc,mul_left_comm,mul_comm] using hn.le + +lemma power_stretchedExp_limit (p q c : ℝ) (hq : 0 x^p*Real.exp (-c*x^q)) atTop (𝓝 0) := by + have hh := (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (p/q) c hc).comp (tendsto_rpow_atTop hq) + apply hh.congr' + filter_upwards [eventually_ge_atTop (0:ℝ)] with x hx + change (x^q)^(p/q)*Real.exp (-c*x^q)=_ + rw [← Real.rpow_mul hx] + congr 2 + field_simp + +lemma rapidDecay_stretchedExp (q c : ℝ) (hq : 0 Real.exp (-c*(n+1:ℝ)^q)) := by + apply rapidDecay_of_weighted_limit (fun _ => (Real.exp_pos _).le) + intro m + have ht : Tendsto (fun n : ℕ => (n+1:ℝ)) atTop atTop := + tendsto_atTop_add_const_right _ 1 tendsto_natCast_atTop_atTop + simpa only [Real.rpow_natCast,Function.comp_def] using (power_stretchedExp_limit m q c hq hc).comp ht + +lemma rapidDecay_geometric (r : ℝ) (hr0 : 0 ≤ r) (hr1 : r<1) : RapidDecay (fun n : ℕ => r^n) := by + intro m + have hs := (summable_pow_mul_geometric_of_norm_lt_one (R := ℝ) (r := r) m (by simpa [Real.norm_eq_abs,abs_of_nonneg hr0] using hr1)).mul_left ((2:ℝ)^m) + apply hs.of_norm_bounded_eventually_nat + filter_upwards [eventually_ge_atTop 1] with n hn + have hn' : (1:ℝ)≤n := by exact_mod_cast hn + rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] + calc + _ ≤ (2*(n:ℝ))^m*r^n := mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (by positivity) (by linarith) m) (pow_nonneg hr0 _) + _ = _ := by rw [mul_pow,mul_assoc] + +lemma descending_probability_bound (N : ℕ) : + (1-((N+1:ℕ):ℝ)^(-(1/2:ℝ)))^(N+1) ≤ + Real.exp (-((N+1:ℕ):ℝ)^(1/2:ℝ)) := by + have hn : (0:ℝ)<(N+1:ℕ) := by positivity + have h1 : (1:ℝ)≤(N+1:ℕ) := by exact_mod_cast Nat.succ_le_succ (Nat.zero_le N) + have ha := Real.rpow_le_one_of_one_le_of_nonpos h1 (by norm_num : -(1/2:ℝ)≤0) + calc + _ ≤ (Real.exp (-((N+1:ℕ):ℝ)^(-(1/2:ℝ))))^(N+1) := + pow_le_pow_left₀ (by linarith) (Real.one_sub_le_exp_neg _) _ + _ = Real.exp (-((N+1:ℕ):ℝ)^(1/2:ℝ)) := by + rw [← Real.exp_nat_mul] + congr 1 + rw [mul_neg] + congr 1 + calc + _ = ((N+1:ℕ):ℝ)^(1:ℝ)*((N+1:ℕ):ℝ)^(-(1/2:ℝ)) := by rw [Real.rpow_one] + _ = _ := by rw [← Real.rpow_add hn]; norm_num + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RapidDecaySubsequence.lean b/lean/OAI/Probability/Ballisticity/Estimates/RapidDecaySubsequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..173657367c1b1964b7892fb9aaf1e6e24817464d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RapidDecaySubsequence.lean @@ -0,0 +1,32 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RapidDecay + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma RapidDecay.comp_strictMono {a : ℕ → ℝ} (ha : RapidDecay a) (ha0 : ∀ n, 0 ≤ a n) + (f : ℕ → ℕ) (hf : StrictMono f) : RapidDecay (fun n => a (f n)) := by + intro m + apply ((ha m).comp_injective hf.injective).of_norm_bounded + intro n + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (by positivity) (ha0 _))] + exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) + (by exact_mod_cast Nat.add_le_add_right (hf.id_le n) 1) m) (ha0 _) + +lemma square_pred_strictMono : StrictMono (fun n : ℕ => (n+1)^2-1) := by + intro n m hnm + have h : (n+1)^2 < (m+1)^2 := by nlinarith + change (n+1)^2-1 < (m+1)^2-1 + have hs : 1 ≤ (n+1)^2 := by nlinarith + omega + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RapidDecayTail.lean b/lean/OAI/Probability/Ballisticity/Estimates/RapidDecayTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..63bc900b723ccb02443084bcf327a8680ce1d4d0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RapidDecayTail.lean @@ -0,0 +1,52 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RapidDecay + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma RapidDecay.summable {a : ℕ → ℝ} (ha : RapidDecay a) : Summable a := by + simpa using ha 0 + +lemma RapidDecay.tail {a : ℕ → ℝ} (ha : RapidDecay a) (ha0 : ∀ n, 0 ≤ a n) : + RapidDecay (fun n => ∑' k, a (n+k)) := by + intro m + let T := ∑' k : ℕ, (k+1:ℝ)^(m+2)*a k + have ht (n : ℕ) : Summable (fun k => a (n+k)) := by + simpa only [Nat.add_comm n] using (summable_nat_add_iff n).mpr ha.summable + have hbound (n : ℕ) : (n+1:ℝ)^(m+2)*(∑' k, a (n+k)) ≤ T := by + rw [← (ht n).tsum_mul_left] + have hshift : Summable (fun k : ℕ => (n+k+1:ℝ)^(m+2)*a (n+k)) := by + simpa only [Nat.cast_add,add_comm (n:ℝ),Nat.add_comm n] using (summable_nat_add_iff n).mpr (ha (m+2)) + calc + _ ≤ ∑' k : ℕ, (n+k+1:ℝ)^(m+2)*a (n+k) := by + apply (ht n |>.mul_left _).tsum_le_tsum _ hshift + intro k + exact mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (by positivity) (by linarith [Nat.cast_nonneg (α := ℝ) k]) _) (ha0 _) + _ ≤ T := by + have hh := (ha (m+2)).sum_add_tsum_nat_add n + have hz : 0 ≤ ∑ k ∈ Finset.range n, (k+1:ℝ)^(m+2)*a k := + Finset.sum_nonneg (fun _ _ => mul_nonneg (by positivity) (ha0 _)) + simpa only [T,Nat.add_comm n,Nat.cast_add,add_comm (n:ℝ)] using (show + (∑' k : ℕ, (↑(k+n)+1:ℝ)^(m+2)*a (k+n)) ≤ T by linarith [hh]) + have hs : Summable (fun n : ℕ => T*((n+1:ℝ)^2)⁻¹) := by + apply Summable.mul_left + simpa only [Nat.cast_add,Nat.cast_one] using (summable_nat_add_iff 1).mpr + (Real.summable_nat_pow_inv.mpr (by omega : 1<(2:ℕ))) + apply hs.of_norm_bounded + intro n + rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (by positivity) (tsum_nonneg (fun k => ha0 _)))] + rw [← div_eq_mul_inv] + apply (le_div_iff₀ (by positivity : (0:ℝ)<(n+1:ℝ)^2)).mpr + simpa only [pow_add,mul_assoc,mul_comm,mul_left_comm] using hbound n + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RawConditionedWeight.lean b/lean/OAI/Probability/Ballisticity/Estimates/RawConditionedWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..1758fbf978d9de164c40f284f13b9a22f9ce5a36 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RawConditionedWeight.lean @@ -0,0 +1,304 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.NoDropApproxError + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def rawConditionedWeight {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) : Measure (Path d) := + (weightedAnnealed ν g).restrict (NoDrop ℓ 0) + +lemma rawConditionedWeight_apply {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) (hg : Measurable g) + (A : Set (Path d)) (hA : MeasurableSet A) : + rawConditionedWeight ν ℓ g A = ∫⁻ ω, g ω * quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0) + ∂environmentLaw ν := by + rw [rawConditionedWeight,Measure.restrict_apply hA, + weightedAnnealed_apply ν g hg _ (hA.inter (measurableSet_noDrop ℓ 0))] + +lemma rawConditionedWeight_mono {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g h : Environment d → ℝ≥0∞) (hg : Measurable g) (hh : Measurable h) + (hgh : ∀ ω, g ω ≤ h ω) : rawConditionedWeight ν ℓ g ≤ rawConditionedWeight ν ℓ h := by + apply Measure.le_iff.mpr + intro A hA + rw [rawConditionedWeight_apply ν ℓ g hg A hA,rawConditionedWeight_apply ν ℓ h hh A hA] + exact lintegral_mono fun ω => mul_le_mul' (hgh ω) le_rfl + +lemma rawConditionedWeight_smul {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) (hg : Measurable g) (c : ℝ≥0∞) : + rawConditionedWeight ν ℓ (fun ω => c*g ω) = c • rawConditionedWeight ν ℓ g := by + apply Measure.ext + intro A hA + rw [rawConditionedWeight_apply ν ℓ (fun ω => c*g ω) + (show Measurable (fun ω => c*g ω) from measurable_const.mul hg) A hA, + Measure.smul_apply,rawConditionedWeight_apply ν ℓ g hg A hA] + simp only [mul_assoc,smul_eq_mul] + exact lintegral_const_mul c (show Measurable (fun ω => g ω * quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0)) from + hg.mul ((Kernel.measurable_coe quenchedKernel + (hA.inter (measurableSet_noDrop ℓ 0))).comp (measurable_id.prodMk measurable_const))) + +lemma rawConditionedWeight_eq_smul {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (g : Environment d → ℝ≥0∞) : + rawConditionedWeight ν ℓ g = annealedLaw ν (NoDrop ℓ 0) • weightedConditioned ν ℓ g := by + rw [weightedConditioned,smul_smul,ENNReal.mul_inv_cancel hp (measure_ne_top _ _),one_smul] + rfl + +noncomputable def quenchedConditionedAverage {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) : + Measure (Path d) := rawConditionedWeight ν ℓ (fun ω => (noDropQuenched ℓ 0 ω)⁻¹) + +lemma quenchedConditionedAverage_apply {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (A : Set (Path d)) (hA : MeasurableSet A) : + quenchedConditionedAverage ν ℓ A = ∫⁻ ω, (noDropQuenched ℓ 0 ω)⁻¹ * + quenchedKernel (ω,0) (A ∩ NoDrop ℓ 0) ∂environmentLaw ν := + rawConditionedWeight_apply ν ℓ _ (measurable_noDropQuenched ℓ 0).inv A hA + +lemma quenchedConditionedAverage_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : IsProbabilityMeasure (quenchedConditionedAverage ν ℓ) := by + constructor + rw [quenchedConditionedAverage_apply ν ℓ Set.univ MeasurableSet.univ] + simp only [Set.univ_inter] + have he : (fun ω : Environment d => (noDropQuenched ℓ 0 ω)⁻¹ * + quenchedKernel (ω,0) (NoDrop ℓ 0)) =ᵐ[environmentLaw ν] fun _ => 1 := by + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans] with ω hω + exact ENNReal.inv_mul_cancel (ne_of_gt (hω 0)) (measure_ne_top _ _) + rw [lintegral_congr_ae he] + simp + +noncomputable def finiteConditionalDensity {d : ℕ} (ℓ : Vector d) (N : ℕ) + (ω : Environment d) : ℝ≥0∞ := + (max ((N+1:ℕ):ℝ≥0∞)⁻¹ (noDropFinite ℓ 0 N ω))⁻¹ + +lemma finiteConditionalDensity_measurable {d : ℕ} (ℓ : Vector d) (N : ℕ) : + Measurable (finiteConditionalDensity ℓ N) := + (measurable_const.max (noDropFinite_measurable ℓ 0 N)).inv + +lemma finiteConditionalDensity_lower_rows {d : ℕ} (e : Direction d) (N : ℕ) : + @Measurable _ _ (rowSigma {z | dot (realPosition z) (realPosition (step e)) ≤ (N:ℝ)}) _ + (finiteConditionalDensity (realPosition (step e)) N) := + (measurable_const.max (noDropFinite_lower_rows e 0 (by simp [signedHeight]) N)).inv + +lemma finiteConditionalDensity_le {d : ℕ} (ℓ : Vector d) (N : ℕ) (ω : Environment d) : + finiteConditionalDensity ℓ N ω ≤ (N+1:ℕ) := by + rw [finiteConditionalDensity] + simpa only [inv_inv] using ENNReal.inv_le_inv.mpr + (le_max_left (((N+1:ℕ):ℝ≥0∞)⁻¹) (noDropFinite ℓ 0 N ω)) + +lemma finiteConditionalDensity_le_inverse {d : ℕ} (ℓ : Vector d) (N : ℕ) (ω : Environment d) : + finiteConditionalDensity ℓ N ω ≤ (noDropQuenched ℓ 0 ω)⁻¹ := + ENNReal.inv_le_inv.mpr ((noDropQuenched_le_finite ℓ 0 ω N).trans (le_max_right _ _)) + +lemma finiteConditionalDensity_tendsto {d : ℕ} (ℓ : Vector d) (ω : Environment d) : + Tendsto (fun N => finiteConditionalDensity ℓ N ω) atTop (𝓝 (noDropQuenched ℓ 0 ω)⁻¹) := by + have hc : Tendsto (fun N : ℕ => ((N+1:ℕ):ℝ≥0∞)⁻¹) atTop (𝓝 0) := + ENNReal.tendsto_inv_nat_nhds_zero.comp (tendsto_add_atTop_nat 1) + have hh := hc.max (noDropFinite_tendsto ℓ 0 ω) + simp only [max_eq_right (show (0:ℝ≥0∞) ≤ noDropQuenched ℓ 0 ω from bot_le)] at hh + exact tendsto_inv_iff.mpr hh + +lemma finiteConditionalDensity_mass_tendsto {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : + Tendsto (fun N => rawConditionedWeight ν ℓ (finiteConditionalDensity ℓ N) Set.univ) + atTop (𝓝 1) := by + have hdom (N : ℕ) (ω : Environment d) : + finiteConditionalDensity ℓ N ω * noDropQuenched ℓ 0 ω ≤ 1 := + (mul_le_mul' (finiteConditionalDensity_le_inverse ℓ N ω) le_rfl).trans + (ENNReal.inv_mul_le_one _) + have hlim : ∀ᵐ ω ∂environmentLaw ν, Tendsto + (fun N => finiteConditionalDensity ℓ N ω * noDropQuenched ℓ 0 ω) atTop (𝓝 1) := by + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans] with ω hω + have hh := ENNReal.Tendsto.mul_const (finiteConditionalDensity_tendsto ℓ ω) + (Or.inr (show noDropQuenched ℓ 0 ω ≠ ∞ from measure_ne_top _ _)) + rwa [ENNReal.inv_mul_cancel (ne_of_gt (hω 0)) (measure_ne_top _ _)] at hh + have hh := tendsto_lintegral_of_dominated_convergence (μ := environmentLaw ν) + (f := fun _ => (1:ℝ≥0∞)) (fun _ => (1:ℝ≥0∞)) + (fun N => (finiteConditionalDensity_measurable ℓ N).mul (measurable_noDropQuenched ℓ 0)) + (fun N => ae_of_all _ (hdom N)) (by simp) hlim + simp only [lintegral_one,measure_univ] at hh + convert hh using 1 + funext N + rw [rawConditionedWeight_apply ν ℓ _ (finiteConditionalDensity_measurable ℓ N) + Set.univ MeasurableSet.univ] + simp only [Set.univ_inter,Pi.mul_apply,noDropQuenched] + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RawDropBounds.lean b/lean/OAI/Probability/Ballisticity/Estimates/RawDropBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c29a63aae306c6366f20b9246a4b81ce0693b364 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RawDropBounds.lean @@ -0,0 +1,184 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OperationalMarkBounds + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +omit [IsProbabilityMeasure ν] in +lemma dropCut_integrable (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] (B : ℝ≥0) : + Integrable (fun ω => cutENNReal B (ENNReal.ofReal (C.dropAt hef N ω i))) Q := by + apply Integrable.of_bound + (((cutENNReal B).continuous.measurable.comp (C.dropAt_measurable hef N i).ennreal_ofReal).aestronglyMeasurable) B + filter_upwards [] with ω + dsimp only [Function.comp_def] + rw [Real.norm_eq_abs,abs_of_nonneg (cutENNReal_nonneg _ _)] + exact cutENNReal_le _ _ + +lemma raw_dropCut_integral (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] (B : ℝ≥0) : + (∫ Y, dropMarkCut e B 0 Y ∂actualOccupationRaw e ν Q + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) + N (C.activeCount hef N)) = + ∫ ω, ∑ i∈Finset.range N, cutENNReal B (ENNReal.ofReal (C.dropAt hef N ω i)) ∂Q := by + rw [actualOccupationRaw_env_test e ν Q (C.paddedTimes hef N) (C.paddedStages hef N) + (C.paddedTimes_measurable hef N) (C.paddedStages_measurable hef N) N (C.activeCount hef N) + (C.activeCount_measurable hef N) (dropMarkCut e B 0) + (fun i ω => cutENNReal B (ENNReal.ofReal (C.dropAt hef N ω i))) + (fun i => (cutENNReal B).continuous.measurable.comp (C.dropAt_measurable hef N i).ennreal_ofReal) + (fun i X => C.dropCut_actual hef N i B X)] + rw [integral_finsetSum (Finset.range N) (fun i _ => C.dropCut_integrable hef N i Q B)] + apply Finset.sum_congr rfl + intro i _ + apply setIntegral_eq_integral_of_forall_compl_eq_zero + intro ω hω + have hi : C.activeCount hef N ω ≤ i := Nat.le_of_not_lt hω + have hz := EpisodeChainLedger.dropMark_inactive (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω i hi + change C.dropAt hef N ω i=0 at hz + rw [hz] + simp [cutENNReal] + +omit [IsProbabilityMeasure ν] in +lemma shortDrop_integrable (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N i L : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (hQ : ∀ᵐ ω ∂Q, ∀ y u, C.κ ≤ (ω y).1 u) : + Integrable (fun ω => if C.stagesAt hef N ω i ≤ L then C.dropAt hef N ω i else 0) Q := by + convert Integrable.piecewise + (measurableSet_le (C.stagesAt_measurable hef N i) (measurable_const : Measurable (fun _ : Environment d => L))) + (C.dropAt_integrable hef N i Q hQ).integrableOn (integrable_const (0:ℝ)).integrableOn using 1 + all_goals rfl + +lemma raw_dropCut_lower (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N L : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (hQ : ∀ᵐ ω ∂Q, ∀ y u, C.κ ≤ (ω y).1 u) + (B : ℝ≥0) (hB : C.injectionCost+2*C.b*L ≤ B) : + (∫ ω, ∑ i∈Finset.range N, if C.stagesAt hef N ω i ≤ L then C.dropAt hef N ω i else 0 ∂Q) ≤ + (∫ Y, dropMarkCut e B 0 Y ∂actualOccupationRaw e ν Q + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) + N (C.activeCount hef N)) := by + rw [C.raw_dropCut_integral] + apply integral_mono_ae + (integrable_finsetSum _ (fun i _ => C.shortDrop_integrable hef N i L Q hQ)) + (integrable_finsetSum _ (fun i _ => C.dropCut_integrable hef N i Q B)) + filter_upwards [hQ] with ω hω + apply Finset.sum_le_sum + intro i _ + obtain ⟨hc,hbound⟩ := C.dropAt_bounds hef N i ω hω + rw [cut_ofReal_eq_min B _ hc] + split + · rename_i hi + have hj : (C.stagesAt hef N ω i:ℝ) ≤ L := Nat.cast_le.mpr hi + have hb : C.dropAt hef N ω i ≤ B := by nlinarith only [hbound,hj,hB,C.hb] + exact le_min le_rfl hb + · exact le_min hc B.coe_nonneg + +end OperationalConstants +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma raw_dropCut_upper (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (hQ : ∀ᵐ ω ∂Q, ∀ y u, C.κ ≤ (ω y).1 u) (B : ℝ≥0) : + (∫ Y, dropMarkCut e B 0 Y ∂actualOccupationRaw e ν Q + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) + N (C.activeCount hef N)) ≤ + C.injectionCost*(∫ ω, (C.activeCount hef N ω:ℝ) ∂Q) + + 2*C.b*(∫ ω, (EpisodeChainLedger.steps (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω N:ℝ) ∂Q) := by + have hiM := EpisodeChainLedger.number_integrable (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N Q N + have hiJ := (EpisodeChainLedger.counts_integrable (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N Q N).1 + change Integrable (fun ω => (C.activeCount hef N ω:ℝ)) Q at hiM + rw [C.raw_dropCut_integral,←integral_const_mul,←integral_const_mul, + ←integral_add (hiM.const_mul _) (hiJ.const_mul _)] + apply integral_mono_ae (integrable_finsetSum _ (fun i _ => C.dropCut_integrable hef N i Q B)) + ((hiM.const_mul _).add (hiJ.const_mul _)) + filter_upwards [hQ] with ω hω + have hc : (∑ i∈Finset.range N, (cutENNReal B) (ENNReal.ofReal (C.dropAt hef N ω i))) ≤ + ∑ i∈Finset.range N, C.dropAt hef N ω i := Finset.sum_le_sum (fun i _ => by + rw [cut_ofReal_eq_min B _ (C.dropAt_bounds hef N i ω hω).1] + exact min_le_left (C.dropAt hef N ω i) (B:ℝ)) + apply hc.trans + change ∑ i∈Finset.range N, EpisodeChainLedger.dropMark (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω i ≤ _ + rw [EpisodeChainLedger.dropMark_total] + exact EpisodeChainLedger.total_drop_bound_local (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N C.order C.hf.le C.hb.le + (lt_of_lt_of_le zero_lt_one C.hs) C.height_pos C.κ C.hκ0 C.hκ1 + (lt_of_lt_of_le (by norm_num) C.hk) C.hbκ ω hω + +end OperationalConstants +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma mark_lintegral_bound_of_weak_limit + {X : Type*} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] + (μs : ℕ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (hlim : Tendsto μs atTop (𝓝 μ)) (F : C(X,ℝ≥0∞)) (A : ℝ) + (hbound : ∀ n (B : ℝ≥0), ∫ x, cutENNReal B (F x) ∂(μs n : Measure X) ≤ A) : + (∫⁻ x, F x ∂(μ : Measure X)) ≤ ENNReal.ofReal A := by + have hcut (B : ℝ≥0) : ∫ x, cutENNReal B (F x) ∂(μ : Measure X) ≤ A := by + let G : C(X,ℝ) := (cutENNReal B).comp F + exact le_of_tendsto ((ProbabilityMeasure.continuous_integral_continuousMap G).continuousAt.tendsto.comp hlim) + (Filter.Eventually.of_forall (fun n => hbound n B)) + have hcut' (n : ℕ) : (∫⁻ x, min (F x) (n:ℝ≥0∞) ∂(μ : Measure X)) ≤ ENNReal.ofReal A := by + let G : C(X,ℝ) := (cutENNReal (n:ℝ≥0)).comp F + have hG : Integrable G (μ : Measure X) := + G.continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + have hn := ENNReal.ofReal_le_ofReal (hcut n) + change ENNReal.ofReal (∫ x, G x ∂(μ : Measure X)) ≤ ENNReal.ofReal A at hn + rw [ofReal_integral_eq_lintegral_ofReal hG (Filter.Eventually.of_forall (fun x => cutENNReal_nonneg _ _))] at hn + convert hn using 1 + apply lintegral_congr + intro x + change min (F x) (n:ℝ≥0∞) = ENNReal.ofReal ((min (F x) ((n:ℝ≥0):ℝ≥0∞)).toReal) + rw [ENNReal.ofReal_toReal (ne_top_of_le_ne_top ENNReal.coe_ne_top (min_le_right _ _))] + simp + have he (x : X) : (⨆ n : ℕ, min (F x) (n:ℝ≥0∞))=F x := by + rw [←inf_iSup_eq,ENNReal.iSup_natCast,inf_top_eq] + rw [show (fun x => F x)=(fun x => ⨆ n : ℕ, min (F x) (n:ℝ≥0∞)) from funext (fun x => (he x).symm)] + rw [lintegral_iSup (fun n => F.continuous.measurable.min measurable_const) + (fun n m h x => min_le_min_left _ (by exact_mod_cast h))] + exact iSup_le hcut' + +lemma mark_integrable_of_lintegral_bound + {X : Type*} [MeasurableSpace X] (μ : Measure X) + (F : X → ℝ≥0∞) (hF : Measurable F) (A : ℝ) + (hbound : (∫⁻ x, F x ∂μ) ≤ ENNReal.ofReal A) : + (∀ᵐ x ∂μ, F x<∞) ∧ Integrable (fun x => (F x).toReal) μ := by + have hfin : (∫⁻ x, F x ∂μ)<∞ := hbound.trans_lt ENNReal.ofReal_lt_top + exact ⟨ae_lt_top' hF.aemeasurable hfin.ne, + integrable_toReal_of_lintegral_ne_top hF.aemeasurable hfin.ne⟩ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RawPair.lean b/lean/OAI/Probability/Ballisticity/Estimates/RawPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb327fd66bfdf107fa68215e67d72356fb2414a8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RawPair.lean @@ -0,0 +1,190 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferFirstFailure +import OAI.Probability.Ballisticity.Estimates.PairUpwardRetention + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma hitKernel_height_zero {d : ℕ} (ℓ : Vector d) (x : Lattice d) (ω : Environment d) : + hitKernel (Strip ℓ x 0) (Upper ℓ x 0) (ω,x) = Measure.dirac x := by + apply Measure.ext + intro U hU + rw [hitKernel_apply_eq_hit (disjoint_strip_upper _ _ _)] + have heq : Hit (Strip ℓ x 0) (Upper ℓ x 0 ∩ U) =ᵐ[quenchedKernel (ω,x)] + (fun _ : Path d => x∈U) := by + filter_upwards [quenched_initial_ae (ω,x)] with X hX + apply propext + constructor + · intro h + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp h + have hn0 : n=0 := by + by_contra hn0 + have hh := hn.2 0 (Nat.pos_of_ne_zero hn0) + exact (not_lt_of_ge hh.1) (by simpa only [add_zero] using hh.2) + subst n + have hxU : x∈U := by simpa only [hX] using hn.1.2 + exact hxU + · intro h + have hxU : x∈U := h + apply Set.mem_iUnion.mpr + refine ⟨0,⟨?_,?_⟩,by intro j hj; omega⟩ + · change dot (realPosition x) ℓ+0 ≤ dot (realPosition (X 0)) ℓ + simp only [hX,add_zero,le_refl] + · simpa only [hX] using hxU + rw [measure_congr heq,Measure.dirac_apply' _ hU] + by_cases hu : x∈U <;> simp [hu] + · change (quenchedKernel (ω,x)) Set.univ = 1 + simp + · change (quenchedKernel (ω,x)) ∅ = 0 + simp + +lemma rawPairEndpointLaw_zero {d : ℕ} (ℓ : Vector d) (ω : Environment d) + (x : Lattice d × Lattice d) : rawPairEndpointLaw ℓ 0 ω x = Measure.dirac x := by + simp only [rawPairEndpointLaw,Nat.cast_zero,hitKernel_height_zero,Measure.dirac_prod_dirac,Prod.mk.eta] + +lemma rawPairMixture_zero {d : ℕ} (ℓ : Vector d) (ω : Environment d) + (π : Measure (Lattice d × Lattice d)) : rawPairMixture ℓ 0 π ω = π := by + unfold rawPairMixture + change π.bind (fun x => rawPairEndpointLaw ℓ 0 ω x) = π + simp_rw [rawPairEndpointLaw_zero] + exact Measure.bind_dirac + +lemma pairKernelMass_zero_of_supported {d : ℕ} (ℓ : Vector d) (f : Direction d) + (ω : Environment d) (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] + (z : ℝ) (hπ : ∀ᵐ x ∂π, z ≤ signedCoordinate f (x.2-x.1)) : + pairKernelMass ℓ f 0 z π ω = 1 := by + unfold pairKernelMass + rw [←rawPairMixture_apply,rawPairMixture_zero] + exact (mem_ae_iff_prob_eq_one (Set.to_countable _ |>.measurableSet)).mp hπ +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def bufferStageRetainedLaw {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (H : ℕ) (ω : Environment d) (κ : ℝ≥0) : Measure (Lattice d × Lattice d) := + let ℓ := realPosition (step e) + let z := z₀+(1-ε)*r + let j := bufferFirstFailure ℓ f a z g π H ω + if pairKernelMass ℓ f j z (π ω).val ω < ENNReal.ofReal g then + upwardRetainedLaw e f (j-1) z (π ω).val ω κ + else if ENNReal.ofReal g ≤ pairKernelMass ℓ f H (z₀+(1+α)*r) (π ω).val ω then + retainedPairLaw ℓ f H (z₀+(1+α)*r) (π ω).val ω + else retainedPairLaw ℓ f H z (π ω).val ω + +lemma bufferFirstFailure_eq_top_of_pass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a z g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight ℓ a)) + {H : ℕ} (hH : 0 < H) (ω : Environment d) + (hp : ENNReal.ofReal g ≤ pairKernelMass ℓ f (bufferFirstFailure ℓ f a z g π H ω) z (π ω).val ω) : + bufferFirstFailure ℓ f a z g π H ω = H := by + have hb := bufferFirstFailure_bounds ℓ f a z g π hH ω + apply le_antisymm hb.2 + by_contra hn + have hlt : bufferFirstFailure ℓ f a z g π H ω < H := lt_of_not_ge hn + exact (not_lt_of_ge hp) (bufferFirstFailure_fails_of_lt ℓ f a z g π hH ω hlt) + +lemma bufferStageEvent_iff_last_tests {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight ℓ a)) + {H : ℕ} (hH : 0 < H) (ω : Environment d) : + BufferStageEvent ℓ f H z₀ r ε α g (π ω).val ω ↔ + ENNReal.ofReal g ≤ pairKernelMass ℓ f + (bufferFirstFailure ℓ f a (z₀+(1-ε)*r) g π H ω) (z₀+(1-ε)*r) (π ω).val ω ∧ + ENNReal.ofReal g ≤ pairKernelMass ℓ f H (z₀+(1+α)*r) (π ω).val ω := by + constructor + · intro h + have hb := bufferFirstFailure_bounds ℓ f a (z₀+(1-ε)*r) g π hH ω + exact ⟨h.1 _ hb.1 hb.2,h.2⟩ + · rintro ⟨hp,hg⟩ + refine ⟨?_,hg⟩ + intro j hj hjH + have heq := bufferFirstFailure_eq_top_of_pass ℓ f a (z₀+(1-ε)*r) g π hH ω hp + rcases lt_or_eq_of_le hjH with hlt|rfl + · apply before_bufferFirstFailure_pass ℓ f a (z₀+(1-ε)*r) g π H ω hj + simpa only [heq] using hlt + · simpa only [heq] using hp + +lemma bufferStageRetainedLaw_le {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + {H : ℕ} (hH : 0 < H) (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y, κ ≤ (ω y).1 e) : + bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ ≤ + rawPairMixture (realPosition (step e)) + (bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω) (π ω).val ω := by + let ℓ := realPosition (step e) + let z := z₀+(1-ε)*r + let j := bufferFirstFailure ℓ f a z g π H ω + have hj : 1 ≤ j := (bufferFirstFailure_bounds ℓ f a z g π hH ω).1 + unfold bufferStageRetainedLaw + dsimp only + split + · have hn : j-1+1=j := by omega + simpa only [hn] using upwardRetainedLaw_le e f (j-1) z (π ω).val ω hκ + · rename_i hp + have hjH : j=H := bufferFirstFailure_eq_top_of_pass ℓ f a z g π hH ω (le_of_not_gt hp) + change _ ≤ rawPairMixture ℓ j (π ω).val ω + rw [hjH] + split <;> exact retainedPairLaw_le _ _ _ _ _ _ + +lemma bufferStageRetainedLaw_mass_lower {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + {H : ℕ} (hH : 0 < H) (ω : Environment d) (κ : ℝ≥0) + (hκ1 : κ ≤ 1) (hg1 : g ≤ 1) (hr : 0 ≤ r) (hε : 0 ≤ ε) + [IsProbabilityMeasure (π ω).val] + (hgap : ∀ᵐ x ∂(π ω).val, z₀+r ≤ signedCoordinate f (x.2-x.1)) : + (κ : ℝ≥0∞)^2 * ENNReal.ofReal g ≤ bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ Set.univ := by + let ℓ := realPosition (step e) + let z := z₀+(1-ε)*r + let j := bufferFirstFailure ℓ f a z g π H ω + have hj : 1 ≤ j := (bufferFirstFailure_bounds ℓ f a z g π hH ω).1 + have hκ2 : (κ : ℝ≥0∞)^2 ≤ 1 := by + have hc : (κ : ℝ≥0∞) ≤ 1 := by exact_mod_cast hκ1 + simpa only [one_pow] using pow_le_pow_left' hc 2 + have hsmall : (κ : ℝ≥0∞)^2 * ENNReal.ofReal g ≤ ENNReal.ofReal g := by + calc + _ ≤ 1*ENNReal.ofReal g := mul_le_mul_left hκ2 _ + _ = _ := one_mul _ + unfold bufferStageRetainedLaw + dsimp only + split + · rw [upwardRetainedLaw_mass] + apply mul_le_mul_right + by_cases hz : j-1=0 + · change ENNReal.ofReal g ≤ pairKernelMass ℓ f (j-1) z (π ω).val ω + rw [hz,pairKernelMass_zero_of_supported ℓ f ω (π ω).val z] + · exact ENNReal.ofReal_le_one.mpr hg1 + · filter_upwards [hgap] with x hx + dsimp [z] + nlinarith + · apply before_bufferFirstFailure_pass ℓ f a z g π H ω (Nat.pos_of_ne_zero hz) + change j-1 X j-x) + +lemma measurable_prefixEndpoint {d : ℕ} (ℓ : Vector d) (x : Lattice d) (H : ℕ) : + Measurable (prefixEndpoint ℓ x H) := by + exact measurable_const.add ((measurable_recordIndexPosition ℓ H).comp + (Measurable.of_eval fun j => (measurable_of_countable (fun u : Lattice d => u-x)).comp (measurable_pi_apply j))) + +def PairEndpointEvent {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x y : Lattice d) (H : ℕ) (z : ℝ) : Set (Path d × Path d) := + {p | p.1 ∈ Hit (Strip ℓ x H) (Upper ℓ x H) ∧ + p.2 ∈ Hit (Strip ℓ y H) (Upper ℓ y H) ∧ + z ≤ signedCoordinate f (prefixEndpoint ℓ y H p.2-prefixEndpoint ℓ x H p.1)} + +lemma measurableSet_pairEndpointEvent {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x y : Lattice d) (H : ℕ) (z : ℝ) : + MeasurableSet (PairEndpointEvent ℓ f x y H z) := by + apply (measurableSet_hit _ _ |>.preimage measurable_fst).inter + apply (measurableSet_hit _ _ |>.preimage measurable_snd).inter + exact measurableSet_le measurable_const ((measurable_of_countable (signedCoordinate f)).comp + (((measurable_prefixEndpoint ℓ y H).comp measurable_snd).sub + ((measurable_prefixEndpoint ℓ x H).comp measurable_fst))) + +noncomputable def rawPairEndpointMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : ℝ := + ∫ x, ((quenchedKernel (ω,x.1)).prod (quenchedKernel (ω,x.2))).real + (PairEndpointEvent ℓ f x.1 x.2 H z) ∂π + +lemma signedCoordinate_sub_add {d : ℕ} (f : Direction d) (x y u v : Lattice d) : + signedCoordinate f ((y+v)-(x+u)) = + signedCoordinate f (y-x)+signedCoordinate f v-signedCoordinate f u := by + simp only [signedCoordinate,Pi.sub_apply,Pi.add_apply,Int.cast_sub,Int.cast_add] + split_ifs <;> ring + +lemma tubePrefix_endpoint_bound {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z : ℝ) {H : ℕ} (hH : 0 < H) (X : Path d) + (h0 : X 0=x) (hnn : ∀ n, ∃ g, X (n+1)=X n+step g) + (hX : X ∈ TubePrefix (realPosition (step e)) f x θ z H) : + X ∈ Hit (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) ∧ + |signedCoordinate f (recordIndexPosition (realPosition (step e)) H (fun j => X j-x))-(H:ℝ)*θ| ≤ z := by + rw [tubePrefix_eq_curvePrefix] at hX + have hh := (curvePrefix_iff e f x _ z hH X h0 hnn).mp hX + exact ⟨hh.1,hh.2 H le_rfl⟩ + +lemma endpointPrefix_endpoint_ae {d : ℕ} (e : Direction d) (x : Lattice d) + {H : ℕ} (hH : 0 < H) (ω : Environment d) (A : Set (Lattice d)) : + ∀ᵐ X ∂quenchedKernel (ω,x), X ∈ EndpointPrefix (realPosition (step e)) x H A → + X ∈ Hit (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) ∧ + prefixEndpoint (realPosition (step e)) x H X ∈ A := by + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + have hh : X ∈ HitAt (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) n := + ⟨hn.1.1,hn.2⟩ + refine ⟨Set.mem_iUnion.mpr ⟨n,hh⟩,?_⟩ + dsimp [prefixEndpoint] + rw [coordinate_hitAt_record e x X h0 hnn hH hh] + simpa only [add_sub_cancel] using hn.1.2 + +lemma quenched_pair_regular {d : ℕ} (ω : Environment d) (x y : Lattice d) : + ∀ᵐ p ∂(quenchedKernel (ω,x)).prod (quenchedKernel (ω,y)), + (p.1 0=x ∧ ∀ n, ∃ g, p.1 (n+1)=p.1 n+step g) ∧ + (p.2 0=y ∧ ∀ n, ∃ g, p.2 (n+1)=p.2 n+step g) := by + exact (Measure.quasiMeasurePreserving_fst.ae (quenched_initial_ae (ω,x) |>.and (quenched_nearest_neighbor (ω,x)))).and + (Measure.quasiMeasurePreserving_snd.ae (quenched_initial_ae (ω,y) |>.and (quenched_nearest_neighbor (ω,y)))) + +lemma central_pair_mass_le {d : ℕ} (e f : Direction d) (x y : Lattice d) + (θ z b : ℝ) {H : ℕ} (hH : 0 < H) (ω : Environment d) + (hgap : b+2*z ≤ signedCoordinate f (y-x)) : + centralPrefixMass (realPosition (step e)) f θ z H ω x* + centralPrefixMass (realPosition (step e)) f θ z H ω y ≤ + ((quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))).real + (PairEndpointEvent (realPosition (step e)) f x y H b) := by + have hs : (TubePrefix (realPosition (step e)) f x θ z H ×ˢ + TubePrefix (realPosition (step e)) f y θ z H) ≤ᵐ[ + (quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))] + PairEndpointEvent (realPosition (step e)) f x y H b := by + filter_upwards [quenched_pair_regular ω x y] with p hp hmem + have hx := tubePrefix_endpoint_bound e f x θ z hH p.1 hp.1.1 hp.1.2 hmem.1 + have hy := tubePrefix_endpoint_bound e f y θ z hH p.2 hp.2.1 hp.2.2 hmem.2 + refine ⟨hx.1,hy.1,?_⟩ + rw [prefixEndpoint,prefixEndpoint,signedCoordinate_sub_add] + have hx' := (abs_le.mp hx.2).2 + have hy' := (abs_le.mp hy.2).1 + linarith + have hh := measure_mono_ae hs + have hr := ENNReal.toReal_mono (measure_ne_top _ _) hh + simpa only [Measure.prod_prod,ENNReal.toReal_mul,centralPrefixMass,Measure.real] using hr +lemma jump_central_pair_mass_le {d : ℕ} (e f : Direction d) (x y : Lattice d) + (θ z a s b : ℝ) (hs : s=1 ∨ s= -1) {H : ℕ} (hH : 0 < H) (ω : Environment d) + (hgap : b+z-a ≤ signedCoordinate f (y-x)) : + jumpPrefixMass (realPosition (step e)) f ((H:ℝ)*θ) a s H ω (if s=1 then y else x)* + centralPrefixMass (realPosition (step e)) f θ z H ω (if s=1 then x else y) ≤ + ((quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))).real + (PairEndpointEvent (realPosition (step e)) f x y H b) := by + let ℓ := realPosition (step e) + let A := fun w => EndpointPrefix ℓ w H {v | a < s*(signedCoordinate f (v-w)-(H:ℝ)*θ)} + have hx := endpointPrefix_endpoint_ae e x hH ω {v | a < s*(signedCoordinate f (v-x)-(H:ℝ)*θ)} + have hy := endpointPrefix_endpoint_ae e y hH ω {v | a < s*(signedCoordinate f (v-y)-(H:ℝ)*θ)} + have hAE := (Measure.quasiMeasurePreserving_fst.ae hx).and (Measure.quasiMeasurePreserving_snd.ae hy) + rcases hs with rfl | rfl + · have hs : (TubePrefix ℓ f x θ z H ×ˢ A y) ≤ᵐ[ + (quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))] + PairEndpointEvent ℓ f x y H b := by + filter_upwards [quenched_pair_regular ω x y,hAE] with p hp he hmem + have hc := tubePrefix_endpoint_bound e f x θ z hH p.1 hp.1.1 hp.1.2 hmem.1 + have hj := he.2 hmem.2 + refine ⟨hc.1,hj.1,?_⟩ + have hb := (abs_le.mp hc.2).2 + have hj' := hj.2 + simp only [prefixEndpoint,add_sub_cancel_left,one_mul] at hj' + rw [prefixEndpoint,prefixEndpoint,signedCoordinate_sub_add] + linarith + have hh := ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hs) + simpa only [Measure.prod_prod,ENNReal.toReal_mul,centralPrefixMass,jumpPrefixMass,A, + Measure.real,ite_true,mul_comm] using hh + · have hs : (A x ×ˢ TubePrefix ℓ f y θ z H) ≤ᵐ[ + (quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))] + PairEndpointEvent ℓ f x y H b := by + filter_upwards [quenched_pair_regular ω x y,hAE] with p hp he hmem + have hj := he.1 hmem.1 + have hc := tubePrefix_endpoint_bound e f y θ z hH p.2 hp.2.1 hp.2.2 hmem.2 + refine ⟨hj.1,hc.1,?_⟩ + have hb := (abs_le.mp hc.2).1 + have hj' := hj.2 + simp only [prefixEndpoint,add_sub_cancel_left,neg_one_mul] at hj' + rw [prefixEndpoint,prefixEndpoint,signedCoordinate_sub_add] + linarith + have hh := ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hs) + simpa only [Measure.prod_prod,ENNReal.toReal_mul,centralPrefixMass,jumpPrefixMass,A, + Measure.real,show (-1:ℝ) ≠ 1 by norm_num,ite_false] using hh +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma integral_lower_from_fraction {I : Type*} [MeasurableSpace I] + (π : Measure I) [IsProbabilityMeasure π] (A : I → Prop) + (hA : MeasurableSet {x | A x}) (G : I → ℝ) (hG : Measurable G) + (hG0 : ∀ x, 0 ≤ G x) (hG1 : ∀ x, G x ≤ 1) + {c g : ℝ} (hg : 0 ≤ g) (hgood : ∀ x, A x → g ≤ G x) + (hfrac : c ≤ ∫ x, if A x then (1:ℝ) else 0 ∂π) : + c*g ≤ ∫ x, G x ∂π := by + have hI : Integrable G π := (integrable_const (1:ℝ)).mono' hG.aestronglyMeasurable + (ae_of_all _ fun x => by rw [Real.norm_eq_abs,abs_of_nonneg (hG0 x)]; exact hG1 x) + have hII : Integrable (fun x => if A x then (1:ℝ) else 0) π := by + have he : (fun x => if A x then (1:ℝ) else 0) = ({x | A x}).indicator (fun _ => (1:ℝ)) := by + funext x; simp [Set.indicator] + rw [he] + exact (integrable_const _).indicator hA + have hh := integral_mono (hII.mul_const g) hI (fun x => ?_) + · rw [integral_mul_const] at hh + exact (mul_le_mul_of_nonneg_right hfrac hg).trans hh + · split_ifs with hx + · simpa using hgood x hx + · simpa using hG0 x + +noncomputable def pairCentralRetainedMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (H : ℕ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : ℝ := + ∫ x, centralPrefixMass ℓ f θ z H ω x.1*centralPrefixMass ℓ f θ z H ω x.2 ∂π +noncomputable def pairJumpRetainedMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z a s : ℝ) (H : ℕ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : ℝ := + ∫ x, jumpPrefixMass ℓ f ((H:ℝ)*θ) a s H ω (if s=1 then x.2 else x.1)* + centralPrefixMass ℓ f θ z H ω (if s=1 then x.1 else x.2) ∂π + +lemma centralPrefixMass_bounds {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (H : ℕ) (ω : Environment d) (x : Lattice d) : + 0 ≤ centralPrefixMass ℓ f θ z H ω x ∧ centralPrefixMass ℓ f θ z H ω x ≤ 1 := + ⟨measureReal_nonneg,measureReal_le_one⟩ +lemma jumpPrefixMass_bounds {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b a s : ℝ) (H : ℕ) (ω : Environment d) (x : Lattice d) : + 0 ≤ jumpPrefixMass ℓ f b a s H ω x ∧ jumpPrefixMass ℓ f b a s H ω x ≤ 1 := + ⟨measureReal_nonneg,measureReal_le_one⟩ +lemma pair_retained_mass_of_favorable_fraction {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z a s : ℝ) (H : ℕ) (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] + (ω : Environment d) {c j d₀ : ℝ} (hj : 0 ≤ j) (hd : 0 ≤ d₀) + (hfrac : c ≤ ∫ x, + if j ≤ jumpPrefixMass ℓ f ((H:ℝ)*θ) a s H ω (if s=1 then x.2 else x.1) ∧ + d₀ ≤ centralPrefixMass ℓ f θ z H ω x.1 ∧ + d₀ ≤ centralPrefixMass ℓ f θ z H ω x.2 + then (1:ℝ) else 0 ∂π) : + c*d₀^2 ≤ pairCentralRetainedMass ℓ f θ z H π ω ∧ + c*(j*d₀) ≤ pairJumpRetainedMass ℓ f θ z a s H π ω := by + let J := jumpPrefixMass ℓ f ((H:ℝ)*θ) a s H ω + let C := centralPrefixMass ℓ f θ z H ω + let A := fun x : Lattice d × Lattice d => j ≤ J (if s=1 then x.2 else x.1) ∧ d₀ ≤ C x.1 ∧ d₀ ≤ C x.2 + have hf : c ≤ ∫ x, @ite ℝ (A x) (Classical.propDecidable _) 1 0 ∂π := by + convert hfrac using 1 + apply integral_congr_ae + filter_upwards [] with x + dsimp [A,J,C] + split_ifs <;> rfl + have hJ (x) := jumpPrefixMass_bounds ℓ f ((H:ℝ)*θ) a s H ω x + have hC (x) := centralPrefixMass_bounds ℓ f θ z H ω x + constructor + · apply integral_lower_from_fraction π A (Set.to_countable _ |>.measurableSet) + (fun x => C x.1*C x.2) (measurable_of_countable _) + (fun x => mul_nonneg (hC x.1).1 (hC x.2).1) + (fun x => (mul_le_of_le_one_left (hC x.2).1 (hC x.1).2).trans (hC x.2).2) + (sq_nonneg d₀) (fun x hx => ?_) hf + simpa only [pow_two] using mul_le_mul hx.2.1 hx.2.2 hd (hd.trans hx.2.1) + · apply integral_lower_from_fraction π A (Set.to_countable _ |>.measurableSet) + (fun x => J (if s=1 then x.2 else x.1)*C (if s=1 then x.1 else x.2)) (measurable_of_countable _) + (fun x => mul_nonneg (hJ _).1 (hC _).1) + (fun x => (mul_le_of_le_one_left (hC (if s=1 then x.1 else x.2)).1 + (hJ (if s=1 then x.2 else x.1)).2).trans (hC (if s=1 then x.1 else x.2)).2) + (mul_nonneg hj hd) (fun x hx => ?_) hf + apply mul_le_mul hx.1 _ hd (hj.trans hx.1) + split_ifs + · exact hx.2.1 + · exact hx.2.2 +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RawPairLocality.lean b/lean/OAI/Probability/Ballisticity/Estimates/RawPairLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..9437bc94d6a2015c727c1f163f35676e7cda07f9 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RawPairLocality.lean @@ -0,0 +1,173 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.RawPairKernel + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def variableHitKernel {d : ℕ} (ℓ : Vector d) (H : ℕ) : + Kernel (Environment d × Lattice d) (Lattice d) where + toFun p := hitKernel (Strip ℓ p.2 H) (Upper ℓ p.2 H) p + measurable' := measurable_from_prod_countable_left fun x => + (hitKernel (Strip ℓ x H) (Upper ℓ x H)).measurable.comp (measurable_id.prodMk measurable_const) + +instance variableHitKernel_finite {d : ℕ} (ℓ : Vector d) (H : ℕ) : + IsFiniteKernel (variableHitKernel ℓ H) where + exists_univ_le := by + refine ⟨1,ENNReal.one_lt_top,fun p => ?_⟩ + change hitKernel (Strip ℓ p.2 H) (Upper ℓ p.2 H) p Set.univ ≤ 1 + exact hitKernel_total_le_one (disjoint_strip_upper ℓ p.2 H) p + +noncomputable def variablePairHitKernel {d : ℕ} (ℓ : Vector d) (H : ℕ) : + Kernel (Environment d × (Lattice d × Lattice d)) (Lattice d × Lattice d) := + ((variableHitKernel ℓ H).comap (fun p => (p.1,p.2.1)) (by fun_prop)).prod + ((variableHitKernel ℓ H).comap (fun p => (p.1,p.2.2)) (by fun_prop)) + +instance variablePairHitKernel_finite {d : ℕ} (ℓ : Vector d) (H : ℕ) : + IsFiniteKernel (variablePairHitKernel ℓ H) := by unfold variablePairHitKernel; infer_instance + +lemma variablePairHitKernel_apply {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d × Lattice d) : + variablePairHitKernel ℓ H (ω,x) = rawPairEndpointLaw ℓ H ω x := by + simp only [variablePairHitKernel,Kernel.prod_apply,Kernel.comap_apply] + rfl + +lemma rawPairEndpointLaw_rows {d : ℕ} (ℓ : Vector d) (x : Lattice d × Lattice d) + {H : ℕ} (hH : 0 < H) {S : Set (Lattice d)} + (h₁ : Strip ℓ x.1 H ⊆ S) (h₂ : Strip ℓ x.2 H ⊆ S) : + @Measurable _ _ (rowSigma S) _ (fun ω => rawPairEndpointLaw ℓ H ω x) := by + have hx (y : Lattice d) : y ∈ Strip ℓ y H := ⟨le_rfl,by exact lt_add_of_pos_right _ (by exact_mod_cast hH)⟩ + let : MeasurableSpace (Environment d) := rowSigma S + let κ₁ : Kernel (Environment d) (Lattice d) := + ⟨fun ω => hitKernel (Strip ℓ x.1 H) (Upper ℓ x.1 H) (ω,x.1), + (measurable_hitKernel_rows _ _ _ (hx x.1)).mono (rowSigma_mono h₁) le_rfl⟩ + let κ₂ : Kernel (Environment d) (Lattice d) := + ⟨fun ω => hitKernel (Strip ℓ x.2 H) (Upper ℓ x.2 H) (ω,x.2), + (measurable_hitKernel_rows _ _ _ (hx x.2)).mono (rowSigma_mono h₂) le_rfl⟩ + have : @IsFiniteKernel (Environment d) (Lattice d) (rowSigma S) _ κ₁ := + ⟨⟨1,ENNReal.one_lt_top,fun ω => hitKernel_total_le_one (disjoint_strip_upper ℓ x.1 H) (ω,x.1)⟩⟩ + have : @IsFiniteKernel (Environment d) (Lattice d) (rowSigma S) _ κ₂ := + ⟨⟨1,ENNReal.one_lt_top,fun ω => hitKernel_total_le_one (disjoint_strip_upper ℓ x.2 H) (ω,x.2)⟩⟩ + have hm := (κ₁.prod κ₂).measurable + change @Measurable _ _ (rowSigma S) _ (fun ω => (κ₁ ω).prod (κ₂ ω)) + convert hm using 1 + funext ω + exact (Kernel.prod_apply κ₁ κ₂ ω).symm + +lemma rawPairEndpointLaw_total_le_one {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d × Lattice d) : + rawPairEndpointLaw ℓ H ω x Set.univ ≤ 1 := by + rw [rawPairEndpointLaw,←Set.univ_prod_univ,Measure.prod_prod] + exact (mul_le_of_le_one_left (by positivity) + (hitKernel_total_le_one (disjoint_strip_upper _ _ _) _)).trans + (hitKernel_total_le_one (disjoint_strip_upper _ _ _) _) + +noncomputable def pairKernelMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : ℝ≥0∞ := + ∫⁻ x, rawPairEndpointLaw ℓ H ω x {y | z ≤ signedCoordinate f (y.2-y.1)} ∂π + +lemma measurable_pairKernelMass {d : ℕ} (ℓ : Vector d) (f : Direction d) (H : ℕ) (z : ℝ) : + Measurable (fun p : Measure (Lattice d × Lattice d) × Environment d => pairKernelMass ℓ f H z p.1 p.2) := by + simp only [pairKernelMass,lintegral_countable'] + apply Measurable.tsum + intro x + have harg : Measurable (fun p : Measure (Lattice d × Lattice d) × Environment d => (p.2,x)) := + measurable_snd.prodMk measurable_const + have hset : MeasurableSet {y : Lattice d × Lattice d | z ≤ signedCoordinate f (y.2-y.1)} := + (Set.to_countable _).measurableSet + have hbase : Measurable (fun q : Environment d × (Lattice d × Lattice d) => + variablePairHitKernel ℓ H q {y | z ≤ signedCoordinate f (y.2-y.1)}) := + Kernel.measurable_coe (variablePairHitKernel ℓ H) hset + have hm := hbase.comp harg + simp only [Function.comp_def,variablePairHitKernel_apply] at hm + exact hm.mul ((Measure.measurable_coe (measurableSet_singleton x)).comp measurable_fst) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma pairKernelMass_le_one {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] + (ω : Environment d) : pairKernelMass ℓ f H z π ω ≤ 1 := by + calc + pairKernelMass ℓ f H z π ω ≤ ∫⁻ _ : Lattice d × Lattice d, (1:ℝ≥0∞) ∂π := by + apply lintegral_mono + intro x + exact (measure_mono (Set.subset_univ _)).trans (rawPairEndpointLaw_total_le_one ℓ H ω x) + _ = 1 := by simp + +lemma pairKernelMass_toReal {d : ℕ} (e f : Direction d) {H : ℕ} (hH : 0 < H) + (z : ℝ) (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] (ω : Environment d) : + (pairKernelMass (realPosition (step e)) f H z π ω).toReal = + rawPairEndpointMass (realPosition (step e)) f H z π ω := by + unfold pairKernelMass + rw [←integral_toReal (measurable_of_countable _).aemeasurable + (ae_of_all _ fun x => lt_of_le_of_lt + ((measure_mono (Set.subset_univ _)).trans (rawPairEndpointLaw_total_le_one _ _ _ x)) ENNReal.one_lt_top)] + apply integral_congr_ae + filter_upwards [] with x + rw [rawPairEndpointLaw_eq e f x hH] + rfl + +lemma pairKernelMass_lower_iff {d : ℕ} (e f : Direction d) {H : ℕ} (hH : 0 < H) + (z : ℝ) (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] + (ω : Environment d) {g : ℝ} (_ : 0 ≤ g) : + ENNReal.ofReal g ≤ pairKernelMass (realPosition (step e)) f H z π ω ↔ + g ≤ rawPairEndpointMass (realPosition (step e)) f H z π ω := by + have hn := ne_top_of_le_ne_top ENNReal.one_ne_top (pairKernelMass_le_one (realPosition (step e)) f H z π ω) + rw [←pairKernelMass_toReal e f hH z π ω] + exact ENNReal.ofReal_le_iff_le_toReal hn + +abbrev SupportedPairMeasures {d : ℕ} (C : Set (Lattice d × Lattice d)) := + {π : Measure (Lattice d × Lattice d) // π Cᶜ = 0} + +lemma supportedPairMeasures_singleton {d : ℕ} (C : Set (Lattice d × Lattice d)) + (π : SupportedPairMeasures C) {x : Lattice d × Lattice d} (hx : x ∉ C) : π.val {x} = 0 := by + apply le_antisymm _ (by positivity) + calc + π.val {x} ≤ π.val Cᶜ := measure_mono (Set.singleton_subset_iff.mpr hx) + _ = 0 := π.property + +lemma pairKernelMass_joint_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + {H : ℕ} (hH : 0 < H) (z : ℝ) (C : Set (Lattice d × Lattice d)) + (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ S ∧ Strip ℓ x.2 H ⊆ S) : + @Measurable (SupportedPairMeasures C × Environment d) ℝ≥0∞ + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) _ + (fun p => pairKernelMass ℓ f H z p.1.val p.2) := by + let : MeasurableSpace (Environment d) := rowSigma S + simp only [pairKernelMass,lintegral_countable'] + apply Measurable.tsum + intro x + by_cases hx : x ∈ C + · have hm : @Measurable (SupportedPairMeasures C × Environment d) ℝ≥0∞ _ _ + (fun p => rawPairEndpointLaw ℓ H p.2 x {y | z ≤ signedCoordinate f (y.2-y.1)}) := + ((Measure.measurable_coe (Set.to_countable _).measurableSet).comp + (rawPairEndpointLaw_rows ℓ x hH (hC x hx).1 (hC x hx).2)).comp measurable_snd + exact hm.mul ((Measure.measurable_coe (measurableSet_singleton x)).comp + (measurable_subtype_coe.comp measurable_fst)) + · have he : (fun p : SupportedPairMeasures C × Environment d => + rawPairEndpointLaw ℓ H p.2 x {y | z ≤ signedCoordinate f (y.2-y.1)}*p.1.val {x}) = + fun _ => 0 := by + funext p + rw [supportedPairMeasures_singleton C p.1 hx,mul_zero] + rw [he] + exact measurable_const +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RawPairMassComposition.lean b/lean/OAI/Probability/Ballisticity/Estimates/RawPairMassComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d162b2041c1f33cb214621ef2a7f6c33ff2488a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RawPairMassComposition.lean @@ -0,0 +1,33 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CountableProdBind + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma rawPair_gap_mass_composition {d : ℕ} (e f : Direction d) (k m : ℕ) + (ω : Environment d) (x : Lattice d × Lattice d) (π : Measure (Lattice d × Lattice d)) + (c b : ℝ≥0∞) (z : ℝ) (hπ : c • π ≤ rawPairEndpointLaw (realPosition (step e)) k ω x) + (hm : b ≤ pairKernelMass (realPosition (step e)) f m z π ω) : + c*b ≤ rawPairEndpointLaw (realPosition (step e)) (k+m) ω x {y | z ≤ signedCoordinate f (y.2-y.1)} := by + have hbound := (rawPairMixture_mono (realPosition (step e)) m ω hπ).trans + (rawPairEndpointLaw_comp_le e k m ω x) + rw [rawPairMixture_smul] at hbound + have hb := hbound {y | z ≤ signedCoordinate f (y.2-y.1)} + simp only [Measure.smul_apply,smul_eq_mul,rawPairMixture_apply] at hb + apply le_trans _ hb + have hm' : b ≤ ∫⁻ y, rawPairEndpointLaw (realPosition (step e)) m ω y + {z' | z ≤ signedCoordinate f (z'.2-z'.1)} ∂π := hm + gcongr +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RawPairRetention.lean b/lean/OAI/Probability/Ballisticity/Estimates/RawPairRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..277dabb731110725f23ec4d55e87c11f003b3e90 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RawPairRetention.lean @@ -0,0 +1,200 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferStageSuccess +import OAI.Probability.Ballisticity.Estimates.RawPairLocality + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def rawPairMixture {d : ℕ} (ℓ : Vector d) (H : ℕ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : Measure (Lattice d × Lattice d) := + π.bind (rawPairEndpointLaw ℓ H ω) + +lemma rawPairMixture_apply {d : ℕ} (ℓ : Vector d) (H : ℕ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) (U : Set (Lattice d × Lattice d)) : + rawPairMixture ℓ H π ω U = ∫⁻ x, rawPairEndpointLaw ℓ H ω x U ∂π := + Measure.bind_apply (Set.to_countable U).measurableSet (measurable_of_countable _).aemeasurable + +lemma rawPairMixture_le_one {d : ℕ} (ℓ : Vector d) (H : ℕ) + (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] (ω : Environment d) : + rawPairMixture ℓ H π ω Set.univ ≤ 1 := by + rw [rawPairMixture_apply] + calc + _ ≤ ∫⁻ _ : Lattice d × Lattice d, (1:ℝ≥0∞) ∂π := + lintegral_mono fun x => rawPairEndpointLaw_total_le_one ℓ H ω x + _ = 1 := by simp + +noncomputable def retainedPairLaw {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : + Measure (Lattice d × Lattice d) := + (rawPairMixture ℓ H π ω).restrict {y | z ≤ signedCoordinate f (y.2-y.1)} + +lemma retainedPairLaw_mass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : + retainedPairLaw ℓ f H z π ω Set.univ = pairKernelMass ℓ f H z π ω := by + rw [retainedPairLaw,Measure.restrict_apply_univ,rawPairMixture_apply] + rfl + +lemma retainedPairLaw_le {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : + retainedPairLaw ℓ f H z π ω ≤ rawPairMixture ℓ H π ω := Measure.restrict_le_self + +lemma retainedPairLaw_support {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : + ∀ᵐ y ∂retainedPairLaw ℓ f H z π ω, z ≤ signedCoordinate f (y.2-y.1) := + ae_restrict_mem (Set.to_countable _).measurableSet + +lemma rawPairMixture_joint_rows {d : ℕ} (ℓ : Vector d) + {H : ℕ} (hH : 0 < H) (C : Set (Lattice d × Lattice d)) (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ S ∧ Strip ℓ x.2 H ⊆ S) : + @Measurable (SupportedPairMeasures C × Environment d) (Measure (Lattice d × Lattice d)) + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) _ + (fun p => rawPairMixture ℓ H p.1.val p.2) := by + let : MeasurableSpace (Environment d) := rowSigma S + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [rawPairMixture_apply,lintegral_countable'] + apply Measurable.tsum + intro x + by_cases hx : x ∈ C + · have hm : @Measurable (SupportedPairMeasures C × Environment d) ℝ≥0∞ _ _ + (fun p => rawPairEndpointLaw ℓ H p.2 x U) := + ((Measure.measurable_coe hU).comp + (rawPairEndpointLaw_rows ℓ x hH (hC x hx).1 (hC x hx).2)).comp measurable_snd + exact hm.mul ((Measure.measurable_coe (measurableSet_singleton x)).comp + (measurable_subtype_coe.comp measurable_fst)) + · have he : (fun p : SupportedPairMeasures C × Environment d => + rawPairEndpointLaw ℓ H p.2 x U*p.1.val {x}) = fun _ => 0 := by + funext p + rw [supportedPairMeasures_singleton C p.1 hx,mul_zero] + rw [he] + exact measurable_const + +lemma retainedPairLaw_joint_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + {H : ℕ} (hH : 0 < H) (z : ℝ) (C : Set (Lattice d × Lattice d)) (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ S ∧ Strip ℓ x.2 H ⊆ S) : + @Measurable (SupportedPairMeasures C × Environment d) (Measure (Lattice d × Lattice d)) + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) _ + (fun p => retainedPairLaw ℓ f H z p.1.val p.2) := by + let : MeasurableSpace (Environment d) := rowSigma S + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [retainedPairLaw,Measure.restrict_apply hU] + exact (Measure.measurable_coe (hU.inter (Set.to_countable _).measurableSet)).comp + (rawPairMixture_joint_rows ℓ hH C S hC) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma measurable_normalizedMeasure {α : Type*} [MeasurableSpace α] : + Measurable (normalizedMeasure (α := α)) := by + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [normalizedMeasure,Measure.smul_apply,smul_eq_mul] + exact (Measure.measurable_coe MeasurableSet.univ).inv.mul (Measure.measurable_coe hU) + +lemma normalizedMeasure_absolutelyContinuous {α : Type*} [MeasurableSpace α] + (μ : Measure α) : normalizedMeasure μ ≪ μ := by + intro U hU + simp only [normalizedMeasure,Measure.smul_apply,hU,mul_zero,smul_eq_mul] + +lemma normalized_retainedPair_probability {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) [IsProbabilityMeasure π] + (ω : Environment d) (hg : 0 < pairKernelMass ℓ f H z π ω) : + IsProbabilityMeasure (normalizedMeasure (retainedPairLaw ℓ f H z π ω)) := by + let : IsFiniteMeasure (retainedPairLaw ℓ f H z π ω) := + ⟨by rw [retainedPairLaw_mass]; exact lt_of_le_of_lt (pairKernelMass_le_one ℓ f H z π ω) ENNReal.one_lt_top⟩ + apply normalizedMeasure_probability + rw [retainedPairLaw_mass] + exact hg.ne' + +lemma normalized_retainedPair_support {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : + ∀ᵐ y ∂normalizedMeasure (retainedPairLaw ℓ f H z π ω), z ≤ signedCoordinate f (y.2-y.1) := + (normalizedMeasure_absolutelyContinuous _).ae_le (retainedPairLaw_support ℓ f H z π ω) + +lemma normalized_retainedPair_joint_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + {H : ℕ} (hH : 0 < H) (z : ℝ) (C : Set (Lattice d × Lattice d)) (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ S ∧ Strip ℓ x.2 H ⊆ S) : + @Measurable (SupportedPairMeasures C × Environment d) (Measure (Lattice d × Lattice d)) + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) _ + (fun p => normalizedMeasure (retainedPairLaw ℓ f H z p.1.val p.2)) := + measurable_normalizedMeasure.comp (retainedPairLaw_joint_rows ℓ f hH z C S hC) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def BufferStageEvent {d : ℕ} (ℓ : Vector d) (f : Direction d) (H : ℕ) + (z₀ r ε a g : ℝ) (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : Prop := + (∀ h : ℕ, 0 < h → h ≤ H → ENNReal.ofReal g ≤ pairKernelMass ℓ f h (z₀+(1-ε)*r) π ω) ∧ + ENNReal.ofReal g ≤ pairKernelMass ℓ f H (z₀+(1+a)*r) π ω + +lemma bufferStageEvent_iff {d : ℕ} (e f : Direction d) {H : ℕ} (hH : 0 < H) + (z₀ r ε a : ℝ) {g : ℝ} (hg : 0 ≤ g) (π : Measure (Lattice d × Lattice d)) + [IsProbabilityMeasure π] (ω : Environment d) : + BufferStageEvent (realPosition (step e)) f H z₀ r ε a g π ω ↔ + BufferStageSuccess (realPosition (step e)) f H z₀ r ε a g π ω := by + unfold BufferStageEvent BufferStageSuccess + apply and_congr + · apply forall_congr' + intro h + apply forall_congr' + intro hh + apply forall_congr' + intro _ + exact pairKernelMass_lower_iff e f hh _ π ω hg + · exact pairKernelMass_lower_iff e f hH _ π ω hg + +lemma strip_mono_nat_height {d : ℕ} (ℓ : Vector d) (x : Lattice d) {h H : ℕ} (hh : h ≤ H) : + Strip ℓ x h ⊆ Strip ℓ x H := by + intro y hy + have hhR : (h:ℝ) ≤ H := by exact_mod_cast hh + exact ⟨hy.1,by dsimp [Strip] at hy ⊢; linarith [hy.2]⟩ + +lemma measurableSet_bufferStageEvent_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + {H : ℕ} (hH : 0 < H) (z₀ r ε a g : ℝ) (C : Set (Lattice d × Lattice d)) + (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ S ∧ Strip ℓ x.2 H ⊆ S) : + @MeasurableSet (SupportedPairMeasures C × Environment d) + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) + {p | BufferStageEvent ℓ f H z₀ r ε a g p.1.val p.2} := by + let : MeasurableSpace (Environment d) := rowSigma S + unfold BufferStageEvent + apply MeasurableSet.inter + · change MeasurableSet {p : SupportedPairMeasures C × Environment d | ∀ h : ℕ, 0 < h → h ≤ H → ENNReal.ofReal g ≤ pairKernelMass ℓ f h (z₀+(1-ε)*r) p.1.val p.2} + simp only [Set.ofPred_forall] + apply MeasurableSet.iInter + intro h + apply MeasurableSet.iInter + intro hh + apply MeasurableSet.iInter + intro hhH + exact measurableSet_le measurable_const (pairKernelMass_joint_rows ℓ f hh _ C S + (fun x hx => ⟨(strip_mono_nat_height ℓ x.1 hhH).trans (hC x hx).1, + (strip_mono_nat_height ℓ x.2 hhH).trans (hC x hx).2⟩)) + · exact measurableSet_le measurable_const (pairKernelMass_joint_rows ℓ f hH _ C S hC) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RealJointPastRestart.lean b/lean/OAI/Probability/Ballisticity/Estimates/RealJointPastRestart.lean new file mode 100644 index 0000000000000000000000000000000000000000..5632a8a9be7ec4651595b81a6a73c5dd35224709 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RealJointPastRestart.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.JointPastRestart + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma integral_partition_countable {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [Countable I] [MeasurableSingletonClass I] (μ : Measure Ω) (D : Ω → I) (hD : Measurable D) + (f : Ω → ℝ) (hf : Integrable f μ) : + (∫ a, f a ∂μ) = ∑' i, ∫ a in D ⁻¹' {i}, f a ∂μ := by + have hu : (⋃ i, D ⁻¹' {i}) = Set.univ := by ext a; simp + have hd : Pairwise (fun i j : I => Disjoint (D ⁻¹' {i}) (D ⁻¹' {j})) := by + intro i j hij + apply Set.disjoint_left.mpr + intro a hi hj + exact hij (hi.symm.trans hj) + have hh := integral_iUnion (μ := μ) (fun i => hD (measurableSet_singleton i)) hd + (show IntegrableOn f (⋃ i, D ⁻¹' {i}) μ by simpa only [hu,IntegrableOn,Measure.restrict_univ] using hf) + simpa only [hu,Measure.restrict_univ] using hh + +lemma integral_countable_restart {Ω I S : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [MeasurableSpace S] [Countable I] [MeasurableSingletonClass I] + (μ : Measure Ω) [IsFiniteMeasure μ] (D : Ω → I) (Y : Ω → S) (κ : I → Measure S) + [∀ i, IsProbabilityMeasure (κ i)] + (hD : Measurable D) (hY : Measurable Y) + (hrestart : ∀ i, (μ.restrict (D ⁻¹' {i})).map Y = μ (D ⁻¹' {i}) • κ i) + (g : I → S → ℝ) (hg : ∀ i, Measurable (g i)) + (C : ℝ) (hC : ∀ i z, ‖g i z‖ ≤ C) : + (∫ a, g (D a) (Y a) ∂μ) = ∫ a, (∫ z, g (D a) z ∂κ (D a)) ∂μ := by + have hgm : Measurable (fun p : S × I => g p.2 p.1) := + measurable_from_prod_countable_left hg + have hm : Measurable (fun a => g (D a) (Y a)) := hgm.comp (hY.prodMk hD) + have hmb : ∀ i, ‖∫ z, g i z ∂κ i‖ ≤ C := fun i => by + simpa using norm_integral_le_of_norm_le_const (μ := κ i) (Filter.Eventually.of_forall (hC i)) + have hri : Integrable (fun a => ∫ z, g (D a) z ∂κ (D a)) μ := + Integrable.of_bound ((measurable_of_countable (fun i => ∫ z, g i z ∂κ i)).comp hD).aestronglyMeasurable + C (Filter.Eventually.of_forall fun a => hmb (D a)) + rw [integral_partition_countable μ D hD _ (Integrable.of_bound hm.aestronglyMeasurable C + (Filter.Eventually.of_forall fun a => hC (D a) (Y a))),integral_partition_countable μ D hD _ hri] + apply tsum_congr + intro i + have ha : ∀ᵐ a ∂μ.restrict (D ⁻¹' {i}), D a = i := + ae_restrict_mem (hD (measurableSet_singleton i)) + calc + (∫ a in D ⁻¹' {i}, g (D a) (Y a) ∂μ) = ∫ a in D ⁻¹' {i}, g i (Y a) ∂μ := + integral_congr_ae (ha.mono fun a ha => by dsimp only; rw [ha]) + _ = ∫ z, g i z ∂(μ.restrict (D ⁻¹' {i})).map Y := by + rw [integral_map hY.aemeasurable (hg i).aestronglyMeasurable] + _ = (μ (D ⁻¹' {i})).toReal * ∫ z, g i z ∂κ i := by + rw [hrestart i,integral_smul_measure,smul_eq_mul] + _ = ∫ a in D ⁻¹' {i}, (∫ z, g i z ∂κ i) ∂μ := by + rw [integral_const,Measure.real,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter,smul_eq_mul] + _ = ∫ a in D ⁻¹' {i}, (∫ z, g (D a) z ∂κ (D a)) ∂μ := + integral_congr_ae (ha.mono fun a ha => by dsimp only; rw [ha]) + +def boundaryTerminal {d : ℕ} (F : BoundaryData d) : Lattice d × Lattice d := + (extendPrefix F.1.1 F.2.1 F.1.1,extendPrefix F.1.2 F.2.2 F.1.2) + +lemma boundaryTerminal_data {d : ℕ} (ℓ : Vector d) (H : ℝ) (P : Path d × Path d) : + boundaryTerminal (boundaryData ℓ H P) = + (P.1 (boundaryTimes ℓ H P).1,P.2 (boundaryTimes ℓ H P).2) := by + simp [boundaryTerminal,boundaryData,pairPrefix,extendPrefix] + +theorem shared_jointPast_real_restart {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) + (x y : Lattice d) (hxy : height x = height y) (H : ℕ) (hH : 0 < H) + (g : BoundaryData d → (Path d × Path d) → ℝ) (hg : ∀ i, Measurable (g i)) + (C : ℝ) (hC : ∀ i z, ‖g i z‖ ≤ C) : + let D := boundaryData ℓ ((height x+H : ℤ) : ℝ) + let Y := boundarySuffix ℓ ((height x+H : ℤ) : ℝ) + (∫ P, g (D P) (Y P) ∂sharedConditionedPairLaw ν ℓ x y) = + ∫ P, (∫ Q, g (D P) Q ∂sharedConditionedPairLaw ν ℓ + (boundaryTerminal (D P)).1 (boundaryTerminal (D P)).2) + ∂sharedConditionedPairLaw ν ℓ x y := by + dsimp only + let : IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ x y) := + sharedConditionedPairLaw_probability ν ℓ x y (ne_of_gt (sharedNoDropMass_positive ν hue ℓ hℓ htrans x y)) + let : ∀ F : BoundaryData d, IsProbabilityMeasure + (sharedConditionedPairLaw ν ℓ (boundaryTerminal F).1 (boundaryTerminal F).2) := fun F => + sharedConditionedPairLaw_probability ν ℓ _ _ (ne_of_gt (sharedNoDropMass_positive ν hue ℓ hℓ htrans _ _)) + exact integral_countable_restart _ _ _ (fun F : BoundaryData d => + sharedConditionedPairLaw ν ℓ (boundaryTerminal F).1 (boundaryTerminal F).2) (measurable_boundaryData ℓ _) + (measurable_boundarySuffix ℓ _) + (shared_boundaryData_map ν hue ℓ hℓ htrans height hproj hstep x y hxy H hH) g hg C hC + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma countable_restart_decorrelation {Ω I S : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [MeasurableSpace S] [Countable I] [MeasurableSingletonClass I] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (D : ℕ → Ω → I) (Y : ℕ → Ω → S) (κ : ℕ → I → Measure S) + [∀ i j, IsProbabilityMeasure (κ i j)] + (hD : ∀ i, Measurable (D i)) (hY : ∀ i, Measurable (Y i)) + (hrestart : ∀ i j, ((μ i).restrict (D i ⁻¹' {j})).map (Y i) = (μ i) (D i ⁻¹' {j}) • κ i j) + (V : ℕ → I → Prop) (hV : ∀ i, ∀ᵐ a ∂μ i, V i (D i a)) + (f : ℕ → I → ℝ) (g : ℕ → I → S → ℝ) (hg : ∀ i j, Measurable (g i j)) + (C M : ℝ) (hC : 0 ≤ C) + (hf : ∀ i j, ‖f i j‖ ≤ C) (hM : ∀ i j z, ‖g i j z‖ ≤ M) + (hunif : ∀ ε > 0, ∀ᶠ i in atTop, ∀ j, V i j → |∫ z, g i j z ∂κ i j| < ε) : + Tendsto (fun i => ∫ a, f i (D i a) * g i (D i a) (Y i a) ∂μ i) atTop (𝓝 0) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + have he : 0 < ε/(C+1) := div_pos hε (by positivity) + filter_upwards [hunif (ε/(C+1)) he] with i hi + have hr := integral_countable_restart (μ i) (D i) (Y i) (κ i) (hD i) (hY i) (hrestart i) + (fun j z => f i j*g i j z) (fun j => (hg i j).const_mul _) (C*M) + (fun j z => by rw [norm_mul]; exact mul_le_mul (hf i j) (hM i j z) (norm_nonneg _) hC) + rw [hr] + simp only [integral_const_mul] + have hb : ‖∫ a, f i (D i a)*(∫ z, g i (D i a) z ∂κ i (D i a)) ∂μ i‖ ≤ C*(ε/(C+1)) := by + simpa using norm_integral_le_of_norm_le_const (μ := μ i) + (f := fun a => f i (D i a)*(∫ z, g i (D i a) z ∂κ i (D i a))) + (C := C*(ε/(C+1))) (hV i |>.mono fun a ha => by + rw [norm_mul,Real.norm_eq_abs] + exact mul_le_mul (hf i _) (le_of_lt (hi _ ha)) (abs_nonneg _) hC) + rw [Real.dist_eq,sub_zero,← Real.norm_eq_abs] + exact hb.trans_lt (by have := div_mul_cancel₀ ε (show C+1 ≠ 0 by positivity); nlinarith [div_pos hε (show 0 < C+1 by positivity)]) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RecordIndexTime.lean b/lean/OAI/Probability/Ballisticity/Estimates/RecordIndexTime.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f39d78fcc3e6f066457368df9b60d1cf750c217 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RecordIndexTime.lean @@ -0,0 +1,455 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SymmetricTruncate + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma common_record_gap_le_max {d : ℕ} (ℓ : Vector d) (e : Direction d) (P : Path d × Path d) + (h0 : P.1 0 = 0) (h0' : P.2 0 = 0) + (hP : ∀ n, ((renewPairSuffix ℓ)^[n] P) ∈ FirstPairWordEvent ℓ (commonWords ℓ P n)) + {j k H : ℕ} (hr : CommonTrueRecord ℓ P j k) (hH : recordCount ℓ P.1 j ≤ H) : + |signedCoordinate e (P.1 j)-signedCoordinate e (P.2 k)| ≤ + partialSumMax (fun n => commonIncrementProcess ℓ e n P) H := by + obtain ⟨n, hn⟩ := commonTrueRecord_eq_commonTimes ℓ P h0 h0' hP hr + have hcoord := common_coordinate_sum ℓ e P h0 h0' hP n + have hnle := commonIndex_le_recordCount ℓ P h0 h0' hP n + rw [hn] at hcoord hnle + rw [hcoord] + exact (abs_partialSum_le_max _ n).trans (partialSumMax_mono _ (hnle.trans hH)) + +lemma conditioned_record_prefix_true {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) {n : ℕ} (hn : 0 < n) + (A : Set (Path d)) (hm : MeasurableSet A) (hA : PrefixDetermined n A) + (hr : ∀ X ∈ A, StrictRecord ℓ X n) + (hpos : ∀ X ∈ A, ∀ j ≤ n, 0 ≤ dot (realPosition (X j)) ℓ) : + conditionedLaw ν ℓ (A ∩ FutureNoDrop ℓ n) = annealedLaw ν A := by + have hsub : A ∩ FutureNoDrop ℓ n ⊆ NoDrop ℓ 0 := by + rintro X ⟨hX,hD⟩ j + simp only [realPosition,dot,Pi.zero_apply,Int.cast_zero,zero_mul,Finset.sum_const_zero] + by_cases hj : j ≤ n + · exact hpos X hX j hj + · have hnj : n ≤ j := by omega + have h := hD (j-n) + change dot (realPosition (X n)) ℓ ≤ dot (realPosition (X (n+(j-n)))) ℓ at h + rw [Nat.add_sub_of_le hnj] at h + exact (hpos X hX n le_rfl).trans h + rw [conditionedLaw,Measure.smul_apply,smul_eq_mul, + Measure.restrict_apply (hm.inter (measurableSet_futureNoDrop ℓ n)), + Set.inter_eq_left.mpr hsub,annealed_record_event_noDrop ν ℓ n hn A hA hr, + mul_comm _ (annealedLaw ν A * _),mul_assoc, + ENNReal.mul_inv_cancel hp (measure_ne_top _ _),mul_one] + +noncomputable def recordIndexTime {d : ℕ} (ℓ : Vector d) (r : ℕ) (X : Path d) : ℕ := by + classical + exact if h : ∃ n, X ∈ RecordIndexPrefix ℓ r n then Nat.find h else 0 + +lemma recordIndexTime_eq {d : ℕ} (ℓ : Vector d) (r n : ℕ) (X : Path d) + (hX : X ∈ RecordIndexPrefix ℓ r n) : recordIndexTime ℓ r X = n := by + classical + have hex : ∃ n, X ∈ RecordIndexPrefix ℓ r n := ⟨n,hX⟩ + rw [recordIndexTime,dite_eq_left hex] + by_contra h + exact Set.disjoint_left.mp (recordIndexPrefix_disjoint ℓ r h) (Nat.find_spec hex) hX + +lemma measurable_recordIndexTime {d : ℕ} (ℓ : Vector d) (r : ℕ) : + Measurable (recordIndexTime ℓ r) := by + classical + apply measurable_to_countable' + intro n + have he : {X : Path d | recordIndexTime ℓ r X = n} = + RecordIndexPrefix ℓ r n ∪ + (if n = 0 then (⋃ m, RecordIndexPrefix ℓ r m)ᶜ else ∅) := by + ext X + simp only [Set.mem_ofPred_eq] + by_cases hx : ∃ m, X ∈ RecordIndexPrefix ℓ r m + · obtain ⟨m,hm⟩ := hx + rw [recordIndexTime_eq ℓ r m X hm] + by_cases hn : n = m + · subst n + simp only [Set.mem_union,true_iff] + exact Or.inl hm + · have hnot : X ∉ RecordIndexPrefix ℓ r n := + fun hn' => Set.disjoint_left.mp (recordIndexPrefix_disjoint ℓ r hn) hn' hm + have hnot' : X ∈ ⋃ j, RecordIndexPrefix ℓ r j := Set.mem_iUnion.mpr ⟨m,hm⟩ + simp only [Ne.symm hn,false_iff,Set.mem_union] + rintro (h | h) + · exact hnot h + · split_ifs at h + · exact h hnot' + · exact h + · have hm : X ∉ ⋃ m, RecordIndexPrefix ℓ r m := by simpa only [Set.mem_iUnion] using hx + have hn : X ∉ RecordIndexPrefix ℓ r n := fun h => hx ⟨n,h⟩ + by_cases hn0 : n = 0 + · subst n + simp only [recordIndexTime,dite_eq_right hx,Set.mem_union,true_iff] + exact Or.inr hm + · simp [recordIndexTime,hx,hn,hn0,Ne.symm hn0] + change MeasurableSet {X : Path d | recordIndexTime ℓ r X = n} + rw [he] + exact (measurableSet_recordIndexPrefix ℓ r n).union (by + split_ifs + · exact (MeasurableSet.iUnion fun m => measurableSet_recordIndexPrefix ℓ r m).compl + · exact MeasurableSet.empty) + +noncomputable def recordIndexPosition {d : ℕ} (ℓ : Vector d) (r : ℕ) (X : Path d) : Lattice d := + X (recordIndexTime ℓ r X) + +lemma measurable_recordIndexPosition {d : ℕ} (ℓ : Vector d) (r : ℕ) : + Measurable (recordIndexPosition ℓ r) := + (measurable_from_prod_countable_left + (f := fun q : Path d × ℕ => q.1 q.2) (fun n => measurable_pi_apply n)).comp + (measurable_id.prodMk (measurable_recordIndexTime ℓ r)) + +lemma conditioned_recordIndexPrefix_exists {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) {r : ℕ} (hr : 0 < r) : + ∀ᵐ X ∂conditionedLaw ν ℓ, ∃ n, X ∈ RecordIndexPrefix ℓ r n := by + filter_upwards [conditionedLaw_noDrop ν ℓ, + (conditionedLaw_absolutelyContinuous ν ℓ).ae_le htrans] with X hD ht + obtain ⟨n,hn,hrec,hcount⟩ := exists_record_at_index ℓ X ht hr + exact ⟨n,hn,hrec,hcount,fun j _ => hD j⟩ + +lemma conditioned_recordIndexTime_spec {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) {r : ℕ} (hr : 0 < r) : + ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ RecordIndexPrefix ℓ r (recordIndexTime ℓ r X) := by + filter_upwards [conditioned_recordIndexPrefix_exists ν ℓ htrans hr] with X hX + obtain ⟨n,hn⟩ := hX + rwa [recordIndexTime_eq ℓ r n X hn] + +lemma independentConditionedPairLaw_eq_restrict {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) : + independentConditionedPairLaw ν ℓ = + ((annealedLaw ν (NoDrop ℓ 0))^2)⁻¹ • + (independentPairLaw ν).restrict (NoDrop ℓ 0 ×ˢ NoDrop ℓ 0) := by + rw [independentConditionedPairLaw,conditionedLaw,Measure.prod_smul_left, + Measure.prod_smul_right,smul_smul,Measure.prod_restrict,← pow_two,← ENNReal.inv_pow] + rfl + +lemma independentConditionedPairLaw_normalization {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (A : Set (Path d × Path d)) (hA : MeasurableSet A) : + (annealedLaw ν (NoDrop ℓ 0))^2 * independentConditionedPairLaw ν ℓ A = + independentPairLaw ν (A ∩ (NoDrop ℓ 0 ×ˢ NoDrop ℓ 0)) := by + rw [independentConditionedPairLaw_eq_restrict,Measure.smul_apply,smul_eq_mul, + Measure.restrict_apply hA,← mul_assoc, + ENNReal.mul_inv_cancel (pow_ne_zero 2 hp) (ENNReal.pow_ne_top (measure_ne_top _ _)),one_mul] + +lemma independentConditionedPairLaw_le_raw {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (A : Set (Path d × Path d)) (hA : MeasurableSet A) : + (annealedLaw ν (NoDrop ℓ 0))^2 * independentConditionedPairLaw ν ℓ A ≤ + independentPairLaw ν A := by + rw [independentConditionedPairLaw_normalization ν ℓ hp A hA] + exact measure_mono Set.inter_subset_left + +lemma independent_conditioned_record_prefix_lower {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + {n m : ℕ} (hn : 0 < n) (hm : 0 < m) (A : Set (Path d × Path d)) + (hAm : MeasurableSet A) (hA : PairPrefixDetermined n m A) + (hr : ∀ P ∈ A, StrictRecord ℓ P.1 n ∧ StrictRecord ℓ P.2 m ∧ + dot (realPosition (P.1 n)) ℓ = dot (realPosition (P.2 m)) ℓ) + (hD : A ∩ (FutureNoDrop ℓ n ×ˢ FutureNoDrop ℓ m) ⊆ NoDrop ℓ 0 ×ˢ NoDrop ℓ 0) : + independentPairLaw ν A ≤ independentConditionedPairLaw ν ℓ + (A ∩ (FutureNoDrop ℓ n ×ˢ FutureNoDrop ℓ m)) := by + have hh := pair_record_event_noDrop_lower (independentPairLaw ν) ℓ + ((annealedLaw ν (NoDrop ℓ 0))^2) + (fun f g n m hn hm hrf hrg _ => + (independent_pair_record_cylinder_noDrop ν ℓ f g n m hn hm hrf hrg).ge) + n m hn hm A hA hr + have he := independentConditionedPairLaw_normalization ν ℓ hp + (A ∩ (FutureNoDrop ℓ n ×ˢ FutureNoDrop ℓ m)) + (hAm.inter ((measurableSet_futureNoDrop ℓ n).prod (measurableSet_futureNoDrop ℓ m))) + rw [Set.inter_eq_left.mpr hD] at he + rw [← he] at hh + exact (ENNReal.mul_le_mul_iff_right (pow_ne_zero 2 hp) + (ENNReal.pow_ne_top (measure_ne_top _ _))).mp hh + +def PairRecordDeviation {d : ℕ} (ℓ : Vector d) (e : Direction d) (H : ℕ) (z : ℝ) + (n m : ℕ) : Set (Path d × Path d) := + {P | (∃ r, 0 < r ∧ r ≤ H ∧ P.1 ∈ RecordIndexPrefix ℓ r n ∧ + P.2 ∈ RecordIndexPrefix ℓ r m) ∧ + dot (realPosition (P.1 n)) ℓ = dot (realPosition (P.2 m)) ℓ ∧ + z < |signedCoordinate e (P.1 n)-signedCoordinate e (P.2 m)|} + +def FirstPairRecordDeviation {d : ℕ} (ℓ : Vector d) (e : Direction d) (H : ℕ) (z : ℝ) + (q : ℕ × ℕ) : Set (Path d × Path d) := + PairRecordDeviation ℓ e H z q.1 q.2 ∩ + {P | ∀ j < q.1, ∀ k < q.2, P ∉ PairRecordDeviation ℓ e H z j k} + +lemma measurableSet_pairRecordDeviation {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) (n m : ℕ) : MeasurableSet (PairRecordDeviation ℓ e H z n m) := by + simp only [PairRecordDeviation,Set.ofPred_and,Set.ofPred_exists] + refine (MeasurableSet.iUnion fun r => (MeasurableSet.const _).inter + ((MeasurableSet.const _).inter ((measurableSet_recordIndexPrefix ℓ r n).prod + (measurableSet_recordIndexPrefix ℓ r m)))).inter ?_ + exact (measurableSet_eq_fun + ((measurable_of_countable (fun x : Lattice d => dot (realPosition x) ℓ)).comp + ((measurable_pi_apply n).comp measurable_fst)) + ((measurable_of_countable (fun x : Lattice d => dot (realPosition x) ℓ)).comp + ((measurable_pi_apply m).comp measurable_snd))).inter + (measurableSet_lt measurable_const + (((measurable_of_countable (signedCoordinate e)).comp + ((measurable_pi_apply n).comp measurable_fst)).sub + ((measurable_of_countable (signedCoordinate e)).comp + ((measurable_pi_apply m).comp measurable_snd))).abs) + +lemma measurableSet_firstPairRecordDeviation {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) (q : ℕ × ℕ) : MeasurableSet (FirstPairRecordDeviation ℓ e H z q) := by + simp only [FirstPairRecordDeviation,Set.ofPred_forall] + exact (measurableSet_pairRecordDeviation ℓ e H z q.1 q.2).inter + (MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + MeasurableSet.iInter fun k => MeasurableSet.iInter fun _ => + (measurableSet_pairRecordDeviation ℓ e H z j k).compl) + +lemma pairRecordDeviation_prefix {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) {j k n m : ℕ} (hj : j ≤ n) (hk : k ≤ m) : + PairPrefixDetermined n m (PairRecordDeviation ℓ e H z j k) := by + intro P Q h1 h2 + have hrec1 (r : ℕ) := recordIndexPrefix_prefix ℓ r j P.1 Q.1 (fun i hi => h1 i (hi.trans hj)) + have hrec2 (r : ℕ) := recordIndexPrefix_prefix ℓ r k P.2 Q.2 (fun i hi => h2 i (hi.trans hk)) + simp only [PairRecordDeviation,Set.mem_ofPred_eq,hrec1,hrec2,h1 j hj,h2 k hk] + +lemma firstPairRecordDeviation_prefix {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) (q : ℕ × ℕ) : + PairPrefixDetermined q.1 q.2 (FirstPairRecordDeviation ℓ e H z q) := by + intro P Q h1 h2 + have he := pairRecordDeviation_prefix ℓ e H z le_rfl le_rfl P Q h1 h2 + simp only [FirstPairRecordDeviation,Set.mem_inter_iff,Set.mem_ofPred_eq,he] + apply and_congr Iff.rfl + exact forall_congr' fun j => forall_congr' fun hj => forall_congr' fun k => + forall_congr' fun hk => not_congr + (pairRecordDeviation_prefix ℓ e H z hj.le hk.le P Q h1 h2) + +lemma recordIndexPrefix_time_lt_iff {d : ℕ} (ℓ : Vector d) (X : Path d) + {r s n m : ℕ} (hn : X ∈ RecordIndexPrefix ℓ r n) + (hm : X ∈ RecordIndexPrefix ℓ s m) : n < m ↔ r < s := by + constructor + · intro h + have hh := recordCount_lt_of_strictRecord ℓ X h hm.2.1 + simpa only [hn.2.2.1,hm.2.2.1] using hh + · intro h + by_contra hh + have he := recordCount_mono ℓ X (Nat.le_of_not_gt hh) + rw [hn.2.2.1,hm.2.2.1] at he + omega + +lemma pairRecordDeviation_time_order {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) {P : Path d × Path d} {n m j k : ℕ} + (hP : P ∈ PairRecordDeviation ℓ e H z n m) + (hQ : P ∈ PairRecordDeviation ℓ e H z j k) : + (n < j ↔ m < k) ∧ (n = j ↔ m = k) := by + obtain ⟨⟨r,_,_,hr,hr'⟩,_⟩ := hP + obtain ⟨⟨s,_,_,hs,hs'⟩,_⟩ := hQ + have h1 := recordIndexPrefix_time_lt_iff ℓ P.1 hr hs + have h2 := recordIndexPrefix_time_lt_iff ℓ P.2 hr' hs' + refine ⟨h1.trans h2.symm,?_⟩ + have h3 := recordIndexPrefix_time_lt_iff ℓ P.1 hs hr + have h4 := recordIndexPrefix_time_lt_iff ℓ P.2 hs' hr' + omega + +lemma firstPairRecordDeviation_disjoint {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) : Pairwise (fun q q' => + Disjoint (FirstPairRecordDeviation ℓ e H z q) (FirstPairRecordDeviation ℓ e H z q')) := by + intro q q' hne + apply Set.disjoint_left.mpr + intro P hP hQ + have hord := pairRecordDeviation_time_order ℓ e H z hP.1 hQ.1 + rcases lt_trichotomy q.1 q'.1 with h | h | h + · exact hQ.2 q.1 h q.2 (hord.1.mp h) hP.1 + · exact hne (Prod.ext h (hord.2.mp h)) + · have hh := (pairRecordDeviation_time_order ℓ e H z hQ.1 hP.1).1.mp h + exact hP.2 q'.1 h q'.2 hh hQ.1 + +lemma iUnion_firstPairRecordDeviation {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) : + (⋃ q, FirstPairRecordDeviation ℓ e H z q) = ⋃ n, ⋃ m, PairRecordDeviation ℓ e H z n m := by + classical + apply Set.Subset.antisymm + · intro P hP + obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hP + exact Set.mem_iUnion.mpr ⟨q.1,Set.mem_iUnion.mpr ⟨q.2,hq.1⟩⟩ + · intro P hP + have hx : ∃ n, ∃ m, P ∈ PairRecordDeviation ℓ e H z n m := by + simpa only [Set.mem_iUnion] using hP + obtain ⟨m,hm⟩ := Nat.find_spec hx + apply Set.mem_iUnion.mpr + refine ⟨(Nat.find hx,m),hm,?_⟩ + intro j hj k _ h + exact Nat.find_min hx hj ⟨k,h⟩ + +lemma firstPairRecordDeviation_force_lower {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (e : Direction d) (H : ℕ) (z : ℝ) (q : ℕ × ℕ) : + independentPairLaw ν (FirstPairRecordDeviation ℓ e H z q) ≤ + independentConditionedPairLaw ν ℓ + (FirstPairRecordDeviation ℓ e H z q ∩ (FutureNoDrop ℓ q.1 ×ˢ FutureNoDrop ℓ q.2)) := by + by_cases hq : 0 < q.1 ∧ 0 < q.2 + · apply independent_conditioned_record_prefix_lower ν ℓ hp hq.1 hq.2 _ + (measurableSet_firstPairRecordDeviation ℓ e H z q) + (firstPairRecordDeviation_prefix ℓ e H z q) + · intro P hP + obtain ⟨r,_,_,hr,hr'⟩ := hP.1.1 + exact ⟨hr.2.1,hr'.2.1,hP.1.2.1⟩ + · rintro P ⟨hP,hF⟩ + obtain ⟨r,_,_,hr,hr'⟩ := hP.1.1 + exact ⟨recordIndexPrefix_noDrop ℓ r q.1 ⟨hr,hF.1⟩, + recordIndexPrefix_noDrop ℓ r q.2 ⟨hr',hF.2⟩⟩ + · have he : FirstPairRecordDeviation ℓ e H z q = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro P hP + obtain ⟨r,_,_,hr,hr'⟩ := hP.1.1 + exact hq ⟨hr.1,hr'.1⟩ + rw [he,measure_empty] + exact bot_le + +lemma independent_pair_deviation_transfer {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) (H : ℕ) (z : ℝ) : + (annealedLaw ν (NoDrop ℓ 0))^2 * independentConditionedPairLaw ν ℓ + (⋃ n, ⋃ m, PairRecordDeviation ℓ e H z n m) ≤ + independentConditionedPairLaw ν ℓ + {P | z < partialSumMax (fun n => commonIncrementProcess ℓ e n P) H} := by + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + let A := FirstPairRecordDeviation ℓ e H z + let B (q : ℕ × ℕ) := A q ∩ (FutureNoDrop ℓ q.1 ×ˢ FutureNoDrop ℓ q.2) + have hAm (q) : MeasurableSet (A q) := measurableSet_firstPairRecordDeviation ℓ e H z q + have hBm (q) : MeasurableSet (B q) := (hAm q).inter + ((measurableSet_futureNoDrop ℓ q.1).prod (measurableSet_futureNoDrop ℓ q.2)) + have hBd : Pairwise (fun q q' => Disjoint (B q) (B q')) := by + intro q q' hne + exact (firstPairRecordDeviation_disjoint ℓ e H z hne).mono + Set.inter_subset_left Set.inter_subset_left + rw [← iUnion_firstPairRecordDeviation] + calc + _ ≤ independentPairLaw ν (⋃ q, A q) := + independentConditionedPairLaw_le_raw ν ℓ hp _ (MeasurableSet.iUnion hAm) + _ = ∑' q, independentPairLaw ν (A q) := + measure_iUnion (firstPairRecordDeviation_disjoint ℓ e H z) hAm + _ ≤ ∑' q, independentConditionedPairLaw ν ℓ (B q) := + ENNReal.tsum_le_tsum (firstPairRecordDeviation_force_lower ν ℓ hp e H z) + _ = independentConditionedPairLaw ν ℓ (⋃ q, B q) := (measure_iUnion hBd hBm).symm + _ ≤ _ := by + apply measure_mono_ae + have hac := conditionedLaw_absolutelyContinuous ν ℓ + have h0 := (Measure.quasiMeasurePreserving_fst.ae (hac.ae_le (annealed_initial ν))).and + (Measure.quasiMeasurePreserving_snd.ae (hac.ae_le (annealed_initial ν))) + filter_upwards [h0,independent_conditioned_all_firstPairWords ν ℓ htrans height hproj hstep] + with P h0 hP hB + obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hB + obtain ⟨r,_,hrH,hr,hr'⟩ := hq.1.1.1 + have htrue : CommonTrueRecord ℓ P q.1 q.2 := + ⟨⟨hr.2.1,hq.2.1⟩,⟨hr'.2.1,hq.2.2⟩,hq.1.1.2.1⟩ + exact hq.1.1.2.2.trans_le (common_record_gap_le_max ℓ e P h0.1 h0.2 hP htrue + (hr.2.2.1.trans_le hrH)) + +lemma measurableSet_pairIndexDeviation {d : ℕ} (ℓ : Vector d) (e : Direction d) + (H : ℕ) (z : ℝ) : MeasurableSet + {P : Path d × Path d | ∃ r, 0 < r ∧ r ≤ H ∧ + z < |signedCoordinate e (recordIndexPosition ℓ r P.1) - + signedCoordinate e (recordIndexPosition ℓ r P.2)|} := by + simp only [Set.ofPred_exists,Set.ofPred_and] + refine MeasurableSet.iUnion fun r => (MeasurableSet.const _).inter + ((MeasurableSet.const _).inter ?_) + exact measurableSet_lt measurable_const + ((((measurable_of_countable (signedCoordinate e)).comp + (measurable_recordIndexPosition ℓ r)).comp measurable_fst).sub + (((measurable_of_countable (signedCoordinate e)).comp + (measurable_recordIndexPosition ℓ r)).comp measurable_snd)).abs + +lemma independent_firstHit_pair_maximum {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) (H : ℕ) (z : ℝ) : + (annealedLaw ν (NoDrop ℓ 0))^2 * independentConditionedPairLaw ν ℓ + {P | ∃ r, 0 < r ∧ r ≤ H ∧ + z < |signedCoordinate e (recordIndexPosition ℓ r P.1) - + signedCoordinate e (recordIndexPosition ℓ r P.2)|} ≤ + independentConditionedPairLaw ν ℓ + {P | z < partialSumMax (fun n => commonIncrementProcess ℓ e n P) H} := by + apply le_trans ?_ (independent_pair_deviation_transfer ν ℓ htrans + height hproj hstep e H z) + apply mul_le_mul_right + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + have hs : ∀ᵐ X ∂conditionedLaw ν ℓ, ∀ r, 0 < r → + X ∈ RecordIndexPrefix ℓ r (recordIndexTime ℓ r X) := + ae_all_iff.mpr fun r => ae_all_iff.mpr fun hr => + conditioned_recordIndexTime_spec ν ℓ htrans hr + have hac := conditionedLaw_absolutelyContinuous ν ℓ + have h0 := (Measure.quasiMeasurePreserving_fst.ae (hac.ae_le (annealed_initial ν))).and + (Measure.quasiMeasurePreserving_snd.ae (hac.ae_le (annealed_initial ν))) + have hNN := (Measure.quasiMeasurePreserving_fst.ae (hac.ae_le (annealed_nearest_neighbor ν))).and + (Measure.quasiMeasurePreserving_snd.ae (hac.ae_le (annealed_nearest_neighbor ν))) + have hs' := (Measure.quasiMeasurePreserving_fst.ae hs).and + (Measure.quasiMeasurePreserving_snd.ae hs) + apply measure_mono_ae + filter_upwards [h0,hNN,hs'] with P h0 hNN hs hP + obtain ⟨r,hr,hrH,hrz⟩ := hP + have h1 := hs.1 r hr + have h2 := hs.2 r hr + have hs1 (j : ℕ) : height (P.1 (j+1)) ≤ height (P.1 j)+1 := by + obtain ⟨v,hv⟩ := hNN.1 j + rw [hv]; exact hstep _ _ + have hs2 (j : ℕ) : height (P.2 (j+1)) ≤ height (P.2 j)+1 := by + obtain ⟨v,hv⟩ := hNN.2 j + rw [hv]; exact hstep _ _ + refine Set.mem_iUnion.mpr ⟨recordIndexTime ℓ r P.1,Set.mem_iUnion.mpr + ⟨recordIndexTime ℓ r P.2,⟨r,hr,hrH,h1,h2⟩,?_,hrz⟩⟩ + rw [hproj,hproj,recordCount_eq_height_at_record ℓ height hproj P.1 hs1 h1.2.1, + recordCount_eq_height_at_record ℓ height hproj P.2 hs2 h2.2.1,h0.1,h0.2,h1.2.2.1,h2.2.2.1] + +lemma exists_integer_median (μ : Measure ℤ) [IsProbabilityMeasure μ] : + ∃ b : ℤ, (1/2 : ℝ≥0∞) ≤ μ (Set.Iic b) ∧ (1/2 : ℝ≥0∞) ≤ μ (Set.Ici b) := by + have hhalf : (1/2 : ℝ≥0∞) < 1 := by norm_num + have ht : ∀ᶠ z : ℤ in atTop, (1/2 : ℝ≥0∞) < μ (Set.Iic z) := + (tendsto_measure_Iic_atTop μ).eventually (Ioi_mem_nhds (by simpa only [measure_univ] using hhalf)) + have hb : ∀ᶠ z : ℤ in atBot, (1/2 : ℝ≥0∞) < μ (Set.Ici z) := + (tendsto_measure_Ici_atBot μ).eventually (Ioi_mem_nhds (by simpa only [measure_univ] using hhalf)) + obtain ⟨b, hb⟩ := hb.exists + have hbound : ∀ z : ℤ, (1/2 : ℝ≥0∞) ≤ μ (Set.Iic z) → b ≤ z := by + intro z hz + by_contra h + have hzb : z < b := lt_of_not_ge h + have hdis : Disjoint (Set.Iic z) (Set.Ici b) := Set.disjoint_left.mpr + (fun x hx hx' => (not_le_of_gt hzb) (hx'.trans hx)) + have hadd : μ (Set.Iic z) + μ (Set.Ici b) ≤ 1 := by + rw [← measure_union hdis measurableSet_Ici] + exact prob_le_one + have hlt : (1 : ℝ≥0∞) < μ (Set.Iic z) + μ (Set.Ici b) := by + calc + 1 = (1/2 : ℝ≥0∞) + (1/2 : ℝ≥0∞) := (ENNReal.add_halves 1).symm + _ < μ (Set.Iic z) + μ (Set.Ici b) := ENNReal.add_lt_add_of_le_of_lt (by simp) hz hb + exact (not_lt_of_ge hadd) hlt + obtain ⟨m, hm, hmin⟩ := Int.exists_least_of_bdd ⟨b,hbound⟩ (ht.exists.imp fun z hz => hz.le) + refine ⟨m,hm,?_⟩ + have hprev : μ (Set.Iic (m-1)) < (1/2 : ℝ≥0∞) := by + by_contra hp + have := hmin (m-1) (le_of_not_gt hp) + omega + have hun : Set.Iic (m-1) ∪ Set.Ici m = Set.univ := by + ext z + simp only [Set.mem_union,Set.mem_Iic,Set.mem_Ici,Set.mem_univ,iff_true] + omega + have hdis : Disjoint (Set.Iic (m-1)) (Set.Ici m) := Set.disjoint_left.mpr (fun z hz hz' => by + simp only [Set.mem_Iic,Set.mem_Ici] at hz hz' + omega) + have hadd : μ (Set.Iic (m-1)) + μ (Set.Ici m) = 1 := by + rw [← measure_union hdis measurableSet_Ici,hun,measure_univ] + by_contra hh + have hm' := lt_of_not_ge hh + have hlt := ENNReal.add_lt_add hprev hm' + rw [hadd] at hlt + rw [ENNReal.add_halves] at hlt + exact (lt_irrefl _) hlt + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RecordMedianSlope.lean b/lean/OAI/Probability/Ballisticity/Estimates/RecordMedianSlope.lean new file mode 100644 index 0000000000000000000000000000000000000000..dad941e8d5bc70bd7ad8f6fc13f7032722072c56 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RecordMedianSlope.lean @@ -0,0 +1,162 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MedianAeConst +import OAI.Probability.Ballisticity.Geometry.NormHeightPolygon + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def recordMedianSlope {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (f : Direction d) (a : ℝ) : ℝ := + (recordMedian ν ℓ hp f ⌊fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ f 0) a⌋₊ : ℝ) / + ⌊fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) a⌋₊ + +lemma recordFluctuationScale_tendsto {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) : + Tendsto (fun i => fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) atTop atTop := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ hp + have hi := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + exact (fluctuationScale_tendsto _ _ (measurable_commonIncrementProcess ℓ f 0) hi hne).comp hr + +theorem recordMedian_linearization {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (T : ℝ) {ε : ℝ} (hε : 0 < ε) : + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans) + ∀ᶠ i in atTop, ∀ h : ℕ, + (h:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i) → + |((recordMedian ν (realPosition (step e)) hp f h:ℝ)- + (h:ℝ)*recordMedianSlope ν (realPosition (step e)) hp f (r i))/r i| < ε := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + exact height_center_linearization (fun h => (recordMedian ν ℓ hp f h:ℝ)) + (by simp [recordMedian_zero]) r _ (recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1) + (fun T ε hε => recordMedian_additive_uniform ν hue e f hef htrans r hr T hε) T hε + +lemma recordMedianSlope_small {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) : + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans) + Tendsto (fun i => recordMedianSlope ν (realPosition (step e)) hp f (r i)/r i) atTop (𝓝 0) := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + apply height_center_slope_small (fun h => (recordMedian ν ℓ hp f h:ℝ)) r _ hr.1 + (recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1) + intro ε hε + simpa only [one_mul, recordMedianSlope] using recordMedian_linearization ν hue e f hef htrans r hr 1 hε + +theorem transverse_firstHit_linear_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans) + letI : IsProbabilityMeasure (conditionedLaw ν (realPosition (step e))) := + conditionedLaw_probability ν _ hp + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i X => heightPolygon + (fun h => signedCoordinate f (recordIndexPosition (realPosition (step e)) h X)- + (h:ℝ)*recordMedianSlope ν (realPosition (step e)) hp f (r i)) (r i) + (fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) T) + atTop id (fun _ => conditionedLaw ν (realPosition (step e))) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw (T/(2*commonMeanWidth ν (realPosition (step e)))) I := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ hp + obtain ⟨W,hW,hWf⟩ := transverse_firstHit_single_path_limit ν hue e f hef htrans r hr hT + refine ⟨W,?_,hWf⟩ + apply height_path_change_center μ _ (fun h => + (measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ h)) + (fun h => (recordMedian ν ℓ hp f h:ℝ)) _ r _ + (recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1) T hT _ W hW + exact fun ε hε => recordMedian_linearization ν hue e f hef htrans r hr (T+1) hε + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RecordOrPrefixAdd.lean b/lean/OAI/Probability/Ballisticity/Estimates/RecordOrPrefixAdd.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7398205047a1c61daef9de0ff2ac4fb5e5e00ab --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RecordOrPrefixAdd.lean @@ -0,0 +1,330 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.RecordIndexPrefixHeight + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma recordOrZeroPrefix_add {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0=0) + (s n k a : ℕ) (hpre : X ∈ RecordOrZeroPrefix ℓ s n) + (hpost : (fun j => X (n+j)-X n) ∈ RecordOrZeroPrefix ℓ k a) : + X ∈ RecordOrZeroPrefix ℓ (s+k) (n+a) := by + by_cases hk : k=0 + · have ha : a=0 := by simpa [RecordOrZeroPrefix,hk] using hpost + simpa only [hk,ha,Nat.add_zero] using hpre + have hpost' : (fun j => X (n+j)-X n) ∈ RecordIndexPrefix ℓ k a := by + simpa only [RecordOrZeroPrefix,ite_eq_right hk] using hpost + have hpreR : StrictRecord ℓ X n := by + by_cases hs : s=0 + · have hn : n=0 := by simpa [RecordOrZeroPrefix,hs] using hpre + subst n + exact fun j hj => by omega + · exact (show X ∈ RecordIndexPrefix ℓ s n by simpa only [RecordOrZeroPrefix,ite_eq_right hs] using hpre).2.1 + have hpreC : recordCount ℓ X n = s := by + by_cases hs : s=0 + · have hn : n=0 := by simpa [RecordOrZeroPrefix,hs] using hpre + simp only [hn,hs,recordCount_zero] + · exact (show X ∈ RecordIndexPrefix ℓ s n by simpa only [RecordOrZeroPrefix,ite_eq_right hs] using hpre).2.2.1 + have hpreD (j : ℕ) (hj : j ≤ n) : dot (realPosition (0:Lattice d)) ℓ ≤ dot (realPosition (X j)) ℓ := by + by_cases hs : s=0 + · have hn : n=0 := by simpa [RecordOrZeroPrefix,hs] using hpre + have hj0 : j=0 := by omega + rw [hj0,h0] + · exact (show X ∈ RecordIndexPrefix ℓ s n by simpa only [RecordOrZeroPrefix,ite_eq_right hs] using hpre).2.2.2 j hj + rw [RecordOrZeroPrefix,ite_eq_right (show s+k ≠ 0 by omega)] + have ha0 := hpost'.1 + refine ⟨by omega,(strictRecord_suffix_iff ℓ X hpreR hpost'.1).mp hpost'.2.1,?_,?_⟩ + · rw [recordCount_add ℓ X hpreR a,hpreC,hpost'.2.2.1] + · intro j hj + by_cases hjn : j ≤ n + · exact hpreD j hjn + · have hh := hpost'.2.2.2 (j-n) (by omega) + change dot (realPosition (0:Lattice d)) ℓ ≤ dot (realPosition (X (n+(j-n))-X n)) ℓ at hh + rw [Nat.add_sub_of_le (show n ≤ j by omega),dot_realPosition_sub] at hh + have hz : dot (realPosition (0:Lattice d)) ℓ=0 := by simp [dot,realPosition] + have hnd := hpreD n le_rfl + rw [hz] at hh hnd ⊢ + linarith + +lemma tubePrefixAt_concatenate {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z₁ z₂ : ℝ) (hz₂ : 0 ≤ z₂) (s n k m : ℕ) (X : Path d) (h0 : X 0=x) + (hnn : ∀ j, ∃ g, X (j+1)=X j+step g) + (hpre : X ∈ TubePrefixAt (realPosition (step e)) f x θ z₁ s n) + (hpost : (fun j => X (n+j)) ∈ TubePrefixAt (realPosition (step e)) f (X n) θ z₂ k m) : + X ∈ TubePrefixAt (realPosition (step e)) f x θ (z₁+z₂) (s+k) (n+m) := by + let ℓ := realPosition (step e) + have hheight : dot (realPosition (X n)) ℓ = dot (realPosition x) ℓ+(s:ℝ) := by + have hh := coordinate_hitAt_exact e x X h0 hnn s n hpre.1 + simp only [ℓ,signedHeight_projection,hh,Int.cast_add,Int.cast_natCast] + obtain ⟨hrec,hgood⟩ := tubePrefixAt_top_witness e f x θ z₁ s n X h0 hnn hpre + refine ⟨⟨?_,?_⟩,?_⟩ + · have hh := hpost.1.1 + change dot (realPosition (X n)) ℓ+(k:ℝ) ≤ dot (realPosition (X (n+m))) ℓ at hh + change dot (realPosition x) ℓ+((s+k:ℕ):ℝ) ≤ dot (realPosition (X (n+m))) ℓ + rw [hheight,Nat.cast_add] at * + linarith + · intro j hj + change dot (realPosition x) ℓ ≤ dot (realPosition (X j)) ℓ ∧ + dot (realPosition (X j)) ℓ < dot (realPosition x) ℓ+((s+k:ℕ):ℝ) + rw [Nat.cast_add] + by_cases hjn : j X b-x) (by rw [h0,sub_self]) s n (j-s) a hrec + (by convert hra using 1; ext b; dsimp; abel) + simpa only [Nat.add_sub_of_le (show s ≤ j by omega)] using hh + · have he : X (n+a)-x = (X n-x)+(X (n+a)-X n) := by abel + have hadd (u v : Lattice d) : signedCoordinate f (u+v)=signedCoordinate f u+signedCoordinate f v := by + simp only [signedCoordinate,Pi.add_apply,Int.cast_add] + split_ifs <;> ring + have hcast : (j:ℝ)=(s:ℝ)+((j-s:ℕ):ℝ) := by exact_mod_cast (Nat.add_sub_of_le (show s ≤ j by omega)).symm + rw [he,hadd,hcast] + calc + _ = |(signedCoordinate f (X n-x)-(s:ℝ)*θ)+ + (signedCoordinate f (X (n+a)-X n)-((j-s:ℕ):ℝ)*θ)| := by congr 1; ring + _ ≤ |signedCoordinate f (X n-x)-(s:ℝ)*θ|+ + |signedCoordinate f (X (n+a)-X n)-((j-s:ℕ):ℝ)*θ| := abs_add_le _ _ + _ ≤ z₁+z₂ := add_le_add hgood hga + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RecordPairFuture.lean b/lean/OAI/Probability/Ballisticity/Estimates/RecordPairFuture.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee8875079e5afe1432f23a6b9356c5d931b1e4f8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RecordPairFuture.lean @@ -0,0 +1,434 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.PairPrefix + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma shared_pair_record_cylinder_rectangle {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (x y : Lattice d) + (f g : Path d) (n m : ℕ) (hn : 0 < n) (hm : 0 < m) + (hrf : StrictRecord ℓ f n) (hrg : StrictRecord ℓ g m) + (he : dot (realPosition (f n)) ℓ = dot (realPosition (g m)) ℓ) + (A B : Set (Path d)) (hA : MeasurableSet A) (hB : MeasurableSet B) + (hAD : A ⊆ NoDrop ℓ (f n)) (hBD : B ⊆ NoDrop ℓ (g m)) : + sharedPairLaw ν x y + (((fun X : Path d => fun j => X (n+j)) ⁻¹' A ∩ pathCylinder f n) ×ˢ + ((fun X : Path d => fun j => X (m+j)) ⁻¹' B ∩ pathCylinder g m)) = + sharedPairLaw ν x y (pathCylinder f n ×ˢ pathCylinder g m) * + sharedPairLaw ν (f n) (g m) (A ×ˢ B) := by + have hAf := (hA.preimage + (show Measurable (fun X : Path d => fun j => X (n+j)) by fun_prop)).inter + (measurableSet_pathCylinder f n) + have hAg := (hB.preimage + (show Measurable (fun X : Path d => fun j => X (m+j)) by fun_prop)).inter + (measurableSet_pathCylinder g m) + rw [sharedPairLaw_rectangle ν x y _ _ hAf hAg, + sharedPairLaw_rectangle ν x y _ _ (measurableSet_pathCylinder f n) + (measurableSet_pathCylinder g m),sharedPairLaw_rectangle ν (f n) (g m) A B hA hB] + by_cases hf : f 0 = x + · by_cases hg : g 0 = y + · let S : Set (Lattice d) := {z | (∃ j < n, z = f j) ∨ (∃ j < m, z = g j)} + let T := {z : Lattice d | dot (realPosition (f n)) ℓ ≤ dot (realPosition z) ℓ} + have hdis : Disjoint S T := by + apply Set.disjoint_left.mpr + rintro z (⟨j,hj,rfl⟩ | ⟨j,hj,rfl⟩) hz + · exact (not_le_of_gt (hrf j hj)) hz + · have hlt := hrg j hj + rw [← he] at hlt + exact (not_le_of_gt hlt) hz + have hfm : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => quenchedKernel (ω,x) (pathCylinder f n)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_pathCylinder f n)).comp + (measurable_id.prodMk measurable_const)) S x (Or.inl ⟨0,hn,hf.symm⟩) + intro ω η hωη + exact pathCylinder_weight_locality S ω η hωη x f n (fun j hj => Or.inl ⟨j,hj,rfl⟩) + have hgm : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => quenchedKernel (ω,y) (pathCylinder g m)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_pathCylinder g m)).comp + (measurable_id.prodMk measurable_const)) S y (Or.inr ⟨0,hm,hg.symm⟩) + intro ω η hωη + exact pathCylinder_weight_locality S ω η hωη y g m (fun j hj => Or.inr ⟨j,hj,rfl⟩) + have hnfm : @Measurable _ _ (rowSigma T) _ (fun ω : Environment d => quenchedKernel (ω,f n) A) := + measurable_quenched_stay_event_rows T (f n) (by + change dot (realPosition (f n)) ℓ ≤ dot (realPosition (f n)) ℓ + exact le_rfl) A hA hAD + have hngm : @Measurable _ _ (rowSigma T) _ (fun ω : Environment d => quenchedKernel (ω,g m) B) := by + apply measurable_quenched_stay_event_rows T (g m) (le_of_eq he) B hB + intro X hX j + change dot (realPosition (f n)) ℓ ≤ dot (realPosition (X j)) ℓ + rw [he] + exact hBD hX j + simp_rw [quenched_prefix_future _ _ _ hf n hA, + quenched_prefix_future _ _ _ hg m hB, mul_mul_mul_comm] + have hind := lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hdis) + (hfm.mul hgm) (hnfm.mul hngm) + simp only [Pi.mul_apply] at hind + exact hind + · have hz ω : quenchedKernel (ω,y) + ((fun X : Path d => fun j => X (m+j)) ⁻¹' B ∩ pathCylinder g m) = 0 := + measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero ω y g hg m) + simp only [hz, quenched_pathCylinder_zero _ _ _ hg m, mul_zero, lintegral_zero, zero_mul] + · have hz ω : quenchedKernel (ω,x) + ((fun X : Path d => fun j => X (n+j)) ⁻¹' A ∩ pathCylinder f n) = 0 := + measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero ω x f hf n) + simp only [hz, quenched_pathCylinder_zero _ _ _ hf n, zero_mul, lintegral_zero] + +lemma shared_pair_record_cylinder_future {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (x y : Lattice d) + (f g : Path d) (n m : ℕ) (hn : 0 < n) (hm : 0 < m) + (hrf : StrictRecord ℓ f n) (hrg : StrictRecord ℓ g m) + (he : dot (realPosition (f n)) ℓ = dot (realPosition (g m)) ℓ) + (E : Set (Path d × Path d)) (hE : MeasurableSet E) + (hED : E ⊆ NoDrop ℓ (f n) ×ˢ NoDrop ℓ (g m)) : + sharedPairLaw ν x y ((commonPairSuffix n m ⁻¹' E) ∩ + (pathCylinder f n ×ˢ pathCylinder g m)) = + sharedPairLaw ν x y (pathCylinder f n ×ˢ pathCylinder g m)* + sharedPairLaw ν (f n) (g m) E := by + let C := pathCylinder f n ×ˢ pathCylinder g m + let D := NoDrop ℓ (f n) ×ˢ NoDrop ℓ (g m) + let M := ((sharedPairLaw ν x y).restrict C).map (commonPairSuffix n m) + have hD : MeasurableSet D := (measurableSet_noDrop ℓ (f n)).prod (measurableSet_noDrop ℓ (g m)) + have hmeasure : M.restrict D = sharedPairLaw ν x y C • (sharedPairLaw ν (f n) (g m)).restrict D := by + apply Measure.ext_prod + intro A B hA hB + rw [Measure.restrict_apply (hA.prod hB),Measure.smul_apply,Measure.restrict_apply (hA.prod hB)] + have hab : (A ×ˢ B) ∩ D = (A ∩ NoDrop ℓ (f n)) ×ˢ (B ∩ NoDrop ℓ (g m)) := by + ext P; simp only [D,Set.mem_inter_iff,Set.mem_prod]; tauto + rw [hab] + change (((sharedPairLaw ν x y).restrict C).map (commonPairSuffix n m)) _ = _ + rw [Measure.map_apply (measurable_commonPairSuffix n m) + ((hA.inter (measurableSet_noDrop ℓ (f n))).prod (hB.inter (measurableSet_noDrop ℓ (g m)))), + Measure.restrict_apply (by exact ((hA.inter (measurableSet_noDrop ℓ (f n))).prod + (hB.inter (measurableSet_noDrop ℓ (g m)))).preimage (measurable_commonPairSuffix n m))] + have hset : commonPairSuffix n m ⁻¹' ((A ∩ NoDrop ℓ (f n)) ×ˢ (B ∩ NoDrop ℓ (g m))) ∩ C = + (((fun X : Path d => fun j => X (n+j)) ⁻¹' (A ∩ NoDrop ℓ (f n)) ∩ pathCylinder f n) ×ˢ + ((fun X : Path d => fun j => X (m+j)) ⁻¹' (B ∩ NoDrop ℓ (g m)) ∩ pathCylinder g m)) := by + ext P + simp only [commonPairSuffix,C,Set.mem_preimage,Set.mem_inter_iff,Set.mem_prod] + tauto + rw [hset] + exact shared_pair_record_cylinder_rectangle ν ℓ x y f g n m hn hm hrf hrg he _ _ + (hA.inter (measurableSet_noDrop ℓ (f n))) (hB.inter (measurableSet_noDrop ℓ (g m))) + Set.inter_subset_right Set.inter_subset_right + have hh := congrArg (fun μ : Measure (Path d × Path d) => μ E) hmeasure + rw [Measure.restrict_apply hE,Measure.smul_apply,Measure.restrict_apply hE, + Set.inter_eq_left.mpr hED] at hh + change (((sharedPairLaw ν x y).restrict C).map (commonPairSuffix n m)) E = _ at hh + rw [Measure.map_apply (measurable_commonPairSuffix n m) hE, + Measure.restrict_apply (hE.preimage (measurable_commonPairSuffix n m))] at hh + exact hh + +def recordPairFuture {d : ℕ} (n m : ℕ) (B : Lattice d → Lattice d → Set (Path d × Path d)) : + Set (Path d × Path d) := {P | commonPairSuffix n m P ∈ B (P.1 n) (P.2 m)} + +lemma measurableSet_recordPairFuture {d : ℕ} (n m : ℕ) + (B : Lattice d → Lattice d → Set (Path d × Path d)) (hB : ∀ u v, MeasurableSet (B u v)) : + MeasurableSet (recordPairFuture n m B) := by + have he : recordPairFuture n m B = ⋃ u, ⋃ v, + {P : Path d × Path d | P.1 n=u ∧ P.2 m=v} ∩ (commonPairSuffix n m ⁻¹' B u v) := by + ext P + simp only [recordPairFuture,Set.mem_ofPred_eq,Set.mem_iUnion,Set.mem_inter_iff,Set.mem_preimage] + constructor + · intro h; exact ⟨P.1 n,P.2 m,⟨rfl,rfl⟩,h⟩ + · rintro ⟨u,v,⟨hu,hv⟩,h⟩; simpa only [hu,hv] using h + rw [he] + apply MeasurableSet.iUnion; intro u + apply MeasurableSet.iUnion; intro v + apply MeasurableSet.inter _ ((hB u v).preimage (measurable_commonPairSuffix n m)) + exact (measurableSet_eq_fun (by fun_prop : Measurable (fun P : Path d × Path d => P.1 n)) measurable_const).inter + (measurableSet_eq_fun (by fun_prop : Measurable (fun P : Path d × Path d => P.2 m)) measurable_const) + +lemma shared_pair_record_event_future_lower {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (x y : Lattice d) + (n m : ℕ) (hn : 0 < n) (hm : 0 < m) (A : Set (Path d × Path d)) + (hA : PairPrefixDetermined n m A) + (hr : ∀ P ∈ A, StrictRecord ℓ P.1 n ∧ StrictRecord ℓ P.2 m ∧ + dot (realPosition (P.1 n)) ℓ = dot (realPosition (P.2 m)) ℓ) + (B : Lattice d → Lattice d → Set (Path d × Path d)) + (hB : ∀ u v, MeasurableSet (B u v)) (hBD : ∀ u v, B u v ⊆ NoDrop ℓ u ×ˢ NoDrop ℓ v) + (q : ℝ≥0∞) (hq : ∀ P ∈ A, q ≤ sharedPairLaw ν (P.1 n) (P.2 m) (B (P.1 n) (P.2 m))) : + q*sharedPairLaw ν x y A ≤ sharedPairLaw ν x y (A ∩ recordPairFuture n m B) := by + rw [measure_partition_pairprefix (sharedPairLaw ν x y) A n m, + measure_partition_pairprefix (sharedPairLaw ν x y) (A ∩ _) n m,← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro F + let P : Path d × Path d := (extendPrefix n F.1,extendPrefix m F.2) + let C := pathCylinder P.1 n ×ˢ pathCylinder P.2 m + by_cases hP : P ∈ A + · have hAc : A ∩ C = C := Set.inter_eq_right.mpr fun Q hQ => (hA Q P hQ.1 hQ.2).mpr hP + have he : (A ∩ recordPairFuture n m B) ∩ C = (commonPairSuffix n m ⁻¹' B (P.1 n) (P.2 m)) ∩ C := by + ext Q + constructor + · rintro ⟨⟨_,hQ⟩,hc1,hc2⟩ + refine ⟨?_,hc1,hc2⟩ + change commonPairSuffix n m Q ∈ B (Q.1 n) (Q.2 m) at hQ + change commonPairSuffix n m Q ∈ B (P.1 n) (P.2 m) + simpa only [hc1 n le_rfl,hc2 m le_rfl] using hQ + · rintro ⟨hQ,hc1,hc2⟩ + refine ⟨⟨(hA Q P hc1 hc2).mpr hP,?_⟩,hc1,hc2⟩ + change commonPairSuffix n m Q ∈ B (Q.1 n) (Q.2 m) + change commonPairSuffix n m Q ∈ B (P.1 n) (P.2 m) at hQ + simpa only [hc1 n le_rfl,hc2 m le_rfl] using hQ + change q*sharedPairLaw ν x y (A ∩ C) ≤ sharedPairLaw ν x y ((A ∩ _) ∩ C) + rw [hAc,he,shared_pair_record_cylinder_future ν ℓ x y P.1 P.2 n m hn hm + (hr P hP).1 (hr P hP).2.1 (hr P hP).2.2 _ (hB _ _) (hBD _ _)] + simpa only [mul_comm] using mul_le_mul_right (hq P hP) (sharedPairLaw ν x y C) + · have hAc : A ∩ C = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro Q ⟨hQ,hqc1,hqc2⟩ + exact hP ((hA Q P hqc1 hqc2).mp hQ) + change q*sharedPairLaw ν x y (A ∩ C) ≤ _ + rw [hAc,measure_empty,mul_zero] + exact zero_le + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RecordPrefixControl.lean b/lean/OAI/Probability/Ballisticity/Estimates/RecordPrefixControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d347fd73294cdac7b3171a02b75c77ca7b21685 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RecordPrefixControl.lean @@ -0,0 +1,283 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.MedianTubeFailure + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma fixed_real_tail_small {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F : Ω → ℝ) (hF : Measurable F) (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) : + Tendsto (fun i => μ.real {x | r i ≤ |F x|}) atTop (𝓝 0) := by + have ht : TendstoInMeasure μ (fun i x => F x/r i) atTop 0 := by + apply tendstoInMeasure_of_tendsto_ae + · exact fun i => (hF.div_const _).aestronglyMeasurable + · exact ae_of_all _ fun x => tendsto_const_nhds.div_atTop hr + have hh := tendstoInMeasure_iff_measureReal_norm.mp ht 1 (by norm_num) + apply hh.congr' + filter_upwards [hr.eventually_gt_atTop 0] with i hi + congr 1 + ext x + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs,abs_div,abs_of_pos hi] + exact (le_div_iff₀ hi).trans (by simp) + +noncomputable def recordPrefixControl {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (J : ℝ) (X : Path d) : ℝ := + (∑ j ∈ Finset.range (highRecordCount ℓ J X+1), + (|signedCoordinate f (recordIndexPosition ℓ j X)|+|b j|))+ + |signedCoordinate f (highRecordPosition ℓ J X)| + +lemma measurable_recordPrefixControl {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (J : ℝ) (hJ : 0 ≤ J) : Measurable (recordPrefixControl ℓ f b J) := by + have hsum : Measurable (fun p : Path d × ℕ => + ∑ j ∈ Finset.range (p.2+1), (|signedCoordinate f (recordIndexPosition ℓ j p.1)|+|b j|)) := + measurable_from_prod_countable_left fun n => Finset.measurable_sum (Finset.range (n+1)) fun j _ => + ((((measurable_of_countable (signedCoordinate f)).comp + (measurable_recordIndexPosition ℓ j)).abs).add_const (|b j|)) + exact (hsum.comp (measurable_id.prodMk (measurable_highRecordCount ℓ J hJ))).add + (((measurable_of_countable (signedCoordinate f)).comp + (measurable_highRecordPosition ℓ J hJ)).abs) + +lemma recordPrefixControl_prefix {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (J : ℝ) (X : Path d) {j : ℕ} (hj : j ≤ highRecordCount ℓ J X) : + |signedCoordinate f (recordIndexPosition ℓ j X)-b j| ≤ recordPrefixControl ℓ f b J X := by + have hs := Finset.single_le_sum (f := fun k => + |signedCoordinate f (recordIndexPosition ℓ k X)|+|b k|) + (fun k (_ : k ∈ Finset.range (highRecordCount ℓ J X+1)) => + add_nonneg (abs_nonneg _) (abs_nonneg _)) (Finset.mem_range.mpr (by omega : j < highRecordCount ℓ J X+1)) + have ht := abs_sub_le (signedCoordinate f (recordIndexPosition ℓ j X)) 0 (b j) + simp only [sub_zero,zero_sub,abs_neg] at ht + dsimp only [recordPrefixControl] + linarith [abs_nonneg (signedCoordinate f (highRecordPosition ℓ J X))] + +lemma recordPrefixControl_endpoint {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (J : ℝ) (X : Path d) : + |signedCoordinate f (highRecordPosition ℓ J X)| ≤ recordPrefixControl ℓ f b J X := by + have hs : 0 ≤ ∑ j ∈ Finset.range (highRecordCount ℓ J X+1), + (|signedCoordinate f (recordIndexPosition ℓ j X)|+|b j|) := + Finset.sum_nonneg fun _ _ => add_nonneg (abs_nonneg _) (abs_nonneg _) + dsimp only [recordPrefixControl] + linarith + +lemma medianTube_suffix_subset_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (htrans : DirectionallyTransient ν ℓ) + (b : ℕ → ℝ) (J : ℝ) (hJ : 0 ≤ J) (H R : ℕ) {z : ℝ} (hz : 0 < z) + (hb : ∀ h s : ℕ, s ≤ R → h+s ≤ H → |b (h+s)-b h| ≤ 3*z/10) : + ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ MedianTubeFailure ℓ f b H z → + X ∈ (highSuffix ℓ J ⁻¹' MedianTubeFailure ℓ f b H (z/10)) ∪ + {X | R < highRecordCount ℓ J X} ∪ {X | z/10 ≤ |recordPrefixControl ℓ f b J X|} := by + filter_upwards [conditioned_highSuffix_recordPosition ν ℓ htrans J hJ] with X hsuf hX + by_contra hn + have hc : highRecordCount ℓ J X ≤ R := by + by_contra! hc + exact hn (Or.inl (Or.inr hc)) + have hp : |recordPrefixControl ℓ f b J X| < z/10 := by + by_contra! hp + exact hn (Or.inr hp) + obtain ⟨j,hj,hbig⟩ := hX + by_cases hjs : j ≤ highRecordCount ℓ J X + · have h := (recordPrefixControl_prefix ℓ f b J X hjs).trans (le_abs_self _) + linarith + · have he : j-highRecordCount ℓ J X+highRecordCount ℓ J X = j := Nat.sub_add_cancel (by omega) + have hpos := hsuf (j-highRecordCount ℓ J X) + rw [he] at hpos + have hd := congrArg (signedCoordinate f) hpos + rw [signedCoordinate_sub] at hd + have hb' := hb (j-highRecordCount ℓ J X) (highRecordCount ℓ J X) hc (by omega) + rw [he] at hb' + have hnew : z/10 < |signedCoordinate f + (recordIndexPosition ℓ (j-highRecordCount ℓ J X) (highSuffix ℓ J X))- + b (j-highRecordCount ℓ J X)| := by + by_contra! hnew + have ht := abs_add_le (signedCoordinate f + (recordIndexPosition ℓ (j-highRecordCount ℓ J X) (highSuffix ℓ J X))- + b (j-highRecordCount ℓ J X)) (signedCoordinate f (highRecordPosition ℓ J X)) + have ht' := abs_sub_le (signedCoordinate f (recordIndexPosition ℓ j X)- + b (j-highRecordCount ℓ J X)) 0 (b j-b (j-highRecordCount ℓ J X)) + have heq : signedCoordinate f (recordIndexPosition ℓ j X)-b j = + (signedCoordinate f (recordIndexPosition ℓ j X)-b (j-highRecordCount ℓ J X))- + (b j-b (j-highRecordCount ℓ J X)) := by ring + rw [← heq,sub_zero,zero_sub,abs_neg] at ht' + have heq' : signedCoordinate f + (recordIndexPosition ℓ (j-highRecordCount ℓ J X) (highSuffix ℓ J X))- + b (j-highRecordCount ℓ J X)+signedCoordinate f (highRecordPosition ℓ J X) = + signedCoordinate f (recordIndexPosition ℓ j X)-b (j-highRecordCount ℓ J X) := by linarith + rw [heq'] at ht + have hp' := (recordPrefixControl_endpoint ℓ f b J X).trans (le_abs_self _) + linarith + exact hn (Or.inl (Or.inl ⟨j-highRecordCount ℓ J X,by omega,hnew⟩)) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ReferenceContinuity.lean b/lean/OAI/Probability/Ballisticity/Estimates/ReferenceContinuity.lean new file mode 100644 index 0000000000000000000000000000000000000000..31587d59cfed2b9c7cc11a761762b085d28d4441 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ReferenceContinuity.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.LocalStoppedSplice + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace Filter +open scoped ENNReal Topology +namespace DirectionalTransience.ReferenceClasses + +section Closed +variable {H : Type*} [AddCommGroup H] [TopologicalSpace H] [DiscreteTopology H] + +omit [AddCommGroup H] in +lemma finite_value_clopen (z : H) : IsClopen ({(z : OnePoint H)} : Set (OnePoint H)) := by + refine ⟨isClosed_singleton,?_⟩ + simpa only [Set.image_singleton] using + (OnePoint.isOpenMap_coe {z} (isOpen_discrete _)) + +omit [AddCommGroup H] in +lemma offset_clopen (a b : ℕ) (z : H) : + IsClopen {O : Offsets H | O (a,b) = (z : OnePoint H)} := + (finite_value_clopen z).preimage (continuous_apply (a,b)) + +lemma consistent_closed : IsClosed {O : Offsets H | Consistent O} := by + have hself : IsClosed {O : Offsets H | ∀ a, O (a,a) = ((0 : H) : OnePoint H)} := by + simp only [Set.ofPred_forall] + exact isClosed_iInter fun a => (offset_clopen a a 0).1 + have hsymm : IsClosed {O : Offsets H | ∀ (a b : ℕ) (z : H), + O (a,b) = (z : OnePoint H) → O (b,a) = ((-z : H) : OnePoint H)} := by + simp only [Set.ofPred_forall] + refine isClosed_iInter fun a => isClosed_iInter fun b => isClosed_iInter fun z => ?_ + have heq : {O : Offsets H | O (a,b) = (z : OnePoint H) → O (b,a) = ((-z : H) : OnePoint H)} = + {O | O (a,b) = (z : OnePoint H)}ᶜ ∪ {O | O (b,a) = ((-z : H) : OnePoint H)} := by + ext; simp [imp_iff_not_or] + rw [heq] + exact (offset_clopen a b z).2.isClosed_compl.union (offset_clopen b a (-z)).1 + have hadd : IsClosed {O : Offsets H | ∀ (a b c : ℕ) (z w : H), + O (a,b) = (z : OnePoint H) → O (b,c) = (w : OnePoint H) → + O (a,c) = ((z+w : H) : OnePoint H)} := by + simp only [Set.ofPred_forall] + refine isClosed_iInter fun a => isClosed_iInter fun b => isClosed_iInter fun c => + isClosed_iInter fun z => isClosed_iInter fun w => ?_ + have heq : {O : Offsets H | O (a,b) = (z : OnePoint H) → O (b,c) = (w : OnePoint H) → + O (a,c) = ((z+w : H) : OnePoint H)} = + {O | O (a,b) = (z : OnePoint H)}ᶜ ∪ + ({O | O (b,c) = (w : OnePoint H)}ᶜ ∪ {O | O (a,c) = ((z+w : H) : OnePoint H)}) := by + ext; simp [imp_iff_not_or] + rw [heq] + exact (offset_clopen a b z).2.isClosed_compl.union + ((offset_clopen b c w).2.isClosed_compl.union (offset_clopen a c (z+w)).1) + have heq : {O : Offsets H | Consistent O} = + {O : Offsets H | ∀ a, O (a,a) = ((0 : H) : OnePoint H)} ∩ + {O : Offsets H | ∀ (a b : ℕ) (z : H), + O (a,b) = (z : OnePoint H) → O (b,a) = ((-z : H) : OnePoint H)} ∩ + {O : Offsets H | ∀ (a b c : ℕ) (z w : H), + O (a,b) = (z : OnePoint H) → O (b,c) = (w : OnePoint H) → + O (a,c) = ((z+w : H) : OnePoint H)} := by + ext O + exact ⟨fun h => ⟨⟨h.self,h.symm⟩,h.add⟩,fun h => ⟨h.1.1,h.1.2,h.2⟩⟩ + rw [heq] + exact (hself.inter hsymm).inter hadd + +instance data_compact : CompactSpace (Data H) := + isCompact_iff_compactSpace.mp consistent_closed.isCompact + +end Closed + +section Reindex +variable {I J K R : Type*} [MeasurableSpace R] + +lemma map_iid_eq_of_same_fibers (ν : Measure R) [IsProbabilityMeasure ν] + (f : I → J) (g : I → K) (h : ∀ i i', f i = f i' ↔ g i = g i') : + (Measure.infinitePi (fun _ : J => ν)).map (fun ξ i => ξ (f i)) = + (Measure.infinitePi (fun _ : K => ν)).map (fun ξ i => ξ (g i)) := by + classical + let t : Set.range f → K := fun x => g (Classical.choose x.2) + have ht (i : I) : t ⟨f i,Set.mem_range_self i⟩ = g i := + (h _ _).mp (Classical.choose_spec (Set.mem_range_self i)) + have htinj : Function.Injective t := by + intro x y hxy + apply Subtype.ext + have hfg := (h (Classical.choose x.2) (Classical.choose y.2)).mpr hxy + rw [Classical.choose_spec x.2,Classical.choose_spec y.2] at hfg + exact hfg + have h1 := Measure.map_infinitePi_infinitePi_of_inj (P := fun _ : J => ν) + (f := (Subtype.val : Set.range f → J)) Subtype.val_injective + have h2 := Measure.map_infinitePi_infinitePi_of_inj (P := fun _ : K => ν) htinj + have hm : Measurable (fun ξ : Set.range f → R => fun i => ξ ⟨f i,Set.mem_range_self i⟩) := by + fun_prop + have hh := congrArg (fun μ : Measure (Set.range f → R) => + μ.map (fun ξ i => ξ ⟨f i,Set.mem_range_self i⟩)) (h1.trans h2.symm) + rw [Measure.map_map hm (by fun_prop),Measure.map_map hm (by fun_prop)] at hh + simpa only [Function.comp_def,ht] using hh + +end Reindex + +section FiniteCoordinates +variable {H R : Type*} [AddCommGroup H] [Countable H] + [TopologicalSpace H] [DiscreteTopology H] [MeasurableSpace H] [BorelSpace H] + [MeasurableSpace (OnePoint H)] [BorelSpace (OnePoint H)] [MeasurableSpace R] + +lemma reference_projection_eq {I : Type*} (ν : Measure R) [IsProbabilityMeasure ν] + (O O' : Data H) (p : I → Site H) + (h : ∀ i j, inputSite O (p i) = inputSite O (p j) ↔ + inputSite O' (p i) = inputSite O' (p j)) : + (reference ν O).map (fun φ i => φ (p i)) = + (reference ν O').map (fun φ i => φ (p i)) := by + have hm (D : Data H) : Measurable (fields D : AllFields H R → _) := + Measurable.of_eval fun _ => measurable_pi_apply _ + rw [reference_apply,reference_apply,Measure.map_map (by fun_prop) (hm O), + Measure.map_map (by fun_prop) (hm O')] + exact map_iid_eq_of_same_fibers ν (inputSite O ∘ p) (inputSite O' ∘ p) h + +omit [Countable H] [MeasurableSpace H] [BorelSpace H] + [MeasurableSpace (OnePoint H)] [BorelSpace (OnePoint H)] in +lemma inputSite_collision_clopen (p q : Site H) : + IsClopen {O : Data H | inputSite O p = inputSite O q} := by + rcases p with ⟨a,l,z⟩ + rcases q with ⟨b,l',z'⟩ + simp only [inputSite_eq_iff] + by_cases h : l = l' + · simp only [h,true_and] + exact (offset_clopen a b (z-z')).preimage continuous_subtype_val + · simp only [h,false_and,Set.ofPred_false] + exact isClopen_empty + +lemma reference_projection_locally_constant {I : Type*} [Finite I] + (ν : Measure R) [IsProbabilityMeasure ν] (O : Data H) (p : I → Site H) : + ∀ᶠ O' in 𝓝 O, (reference ν O').map (fun φ i => φ (p i)) = + (reference ν O).map (fun φ i => φ (p i)) := by + have hh : ∀ᶠ O' in 𝓝 O, ∀ i j, + inputSite O' (p i) = inputSite O' (p j) ↔ inputSite O (p i) = inputSite O (p j) := by + apply eventually_all.mpr + intro i + apply eventually_all.mpr + intro j + have hc := inputSite_collision_clopen (p i) (p j) + by_cases h : inputSite O (p i) = inputSite O (p j) + · filter_upwards [hc.2.mem_nhds h] with O' h' + exact iff_of_true h' h + · filter_upwards [hc.1.isOpen_compl.mem_nhds h] with O' h' + exact iff_of_false h' h + filter_upwards [hh] with O' h' + exact reference_projection_eq ν O' O p h' + +end FiniteCoordinates +end DirectionalTransience.ReferenceClasses + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ReferenceFeller.lean b/lean/OAI/Probability/Ballisticity/Estimates/ReferenceFeller.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e13ec175ba3075b2f0be02405f8aa13fa730760 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ReferenceFeller.lean @@ -0,0 +1,141 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ReferenceContinuity +import OAI.Probability.Ballisticity.Geometry.FiniteCoordinateApproximation + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace Filter +open scoped ENNReal Topology BoundedContinuousFunction +namespace DirectionalTransience.ReferenceClasses + +variable {H R : Type*} [AddCommGroup H] [Countable H] + [TopologicalSpace H] [DiscreteTopology H] [MeasurableSpace H] [BorelSpace H] + [MeasurableSpace (OnePoint H)] [BorelSpace (OnePoint H)] + [UniformSpace R] [CompactSpace R] [SecondCountableTopology R] + [MeasurableSpace R] [BorelSpace R] + +noncomputable def referenceProb (ν : Measure R) [IsProbabilityMeasure ν] + (O : Data H) : ProbabilityMeasure (AllFields H R) := ⟨reference ν O,inferInstance⟩ + +lemma integral_uniform_error {Y : Type*} [TopologicalSpace Y] + [MeasurableSpace Y] [OpensMeasurableSpace Y] + (μ : Measure Y) [IsProbabilityMeasure μ] (f g : Y →ᵇ ℝ) + {ε : ℝ} (h : ∀ x, |f x-g x|≤ε) : + |(∫ x, f x ∂μ)-(∫ x, g x ∂μ)|≤ε := by + rw [← integral_sub (f.integrable μ) (g.integrable μ)] + calc + _ ≤ ∫ x, |f x-g x| ∂μ := abs_integral_le_integral_abs + _ ≤ ∫ _ : Y, ε ∂μ := integral_mono ((f.integrable μ).sub (g.integrable μ)).abs + (integrable_const ε) h + _ = ε := by simp + +lemma reference_integral_continuous (ν : Measure R) [IsProbabilityMeasure ν] + (f : (AllFields H R) →ᵇ ℝ) : + Continuous (fun O : Data H => ∫ φ, f φ ∂reference ν O) := by + have : Nonempty R := nonempty_of_isProbabilityMeasure ν + let r : AllFields H R := fun _ => Classical.choice ‹Nonempty R› + apply continuous_iff_continuousAt.mpr + intro O + apply Metric.tendsto_nhds.mpr + intro ε hε + obtain ⟨S,hS⟩ := Entropy.finiteFiller_approx f.toContinuousMap r (div_pos hε (show (0:ℝ)<3 by norm_num)) + let gf : C((S → R),ℝ) := ⟨fun x => f (Entropy.finiteFiller r S x), + f.continuous.comp (Entropy.finiteFiller_continuous r S)⟩ + let g : (AllFields H R) →ᵇ ℝ := BoundedContinuousFunction.mkOfCompact + ⟨fun φ => gf (fun i : S => φ i),gf.continuous.comp (continuous_pi fun i => continuous_apply (i : Site H))⟩ + have heq : ∀ᶠ O' in 𝓝 O, (∫ φ, g φ ∂reference ν O')=(∫ φ, g φ ∂reference ν O) := by + filter_upwards [reference_projection_locally_constant ν O (fun i : S => (i : Site H))] with O' hO' + have hm : Measurable (fun φ : AllFields H R => fun i : S => φ i) := by fun_prop + have hi (D : Data H) := integral_map hm.aemeasurable gf.continuous.measurable.aestronglyMeasurable + (μ:=reference ν D) + exact (hi O').symm.trans ((congrArg (fun μ => ∫ x, gf x ∂μ) hO').trans (hi O)) + have herr (D : Data H) : |(∫ φ, f φ ∂reference ν D)-(∫ φ, g φ ∂reference ν D)|≤ε/3 := + integral_uniform_error _ f g (fun φ => (hS φ).le) + filter_upwards [heq] with O' hO' + rw [Real.dist_eq] + have h1 := herr O' + have h2 := herr O + rw [hO'] at h1 + have hh := abs_sub_le (∫ φ, f φ ∂reference ν O') (∫ φ, g φ ∂reference ν O) (∫ φ, f φ ∂reference ν O) + rw [abs_sub_comm (∫ φ, g φ ∂reference ν O)] at hh + linarith + +theorem referenceProb_continuous (ν : Measure R) [IsProbabilityMeasure ν] : + Continuous (referenceProb (H:=H) ν) := by + apply ProbabilityMeasure.continuous_iff_forall_continuous_integral.mpr + exact reference_integral_continuous ν + +end DirectionalTransience.ReferenceClasses + +end + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace Filter +open scoped ENNReal Topology BoundedContinuousFunction +namespace DirectionalTransience.Entropy + +variable {X Y I : Type*} [TopologicalSpace X] + [TopologicalSpace Y] [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] + +lemma continuous_joint_integral [MeasurableSpace X] [BorelSpace X] + (P : X → ProbabilityMeasure Y) (hP : Continuous P) + (F : C(X × Y,ℝ)) : Continuous (fun x => ∫ y, F (x,y) ∂(P x : Measure Y)) := by + apply continuous_iff_continuousAt.mpr + intro x + apply Metric.tendsto_nhds.mpr + intro ε hε + have hε2 : 0<ε/2 := half_pos hε + have h1 : ∀ᶠ x' in 𝓝 x, ‖F.curry x'-F.curry x‖<ε/2 := by + have hc : ContinuousAt (fun x' => ‖F.curry x'-F.curry x‖) x := + (F.curry.continuous.sub continuous_const).norm.continuousAt + exact hc.eventually_lt continuousAt_const (by simpa using hε2) + let g : Y →ᵇ ℝ := BoundedContinuousFunction.mkOfCompact (F.curry x) + have hg := (ProbabilityMeasure.continuous_integral_boundedContinuousFunction g).comp hP + have h2 : ∀ᶠ x' in 𝓝 x, dist (∫ y, g y ∂(P x' : Measure Y)) + (∫ y, g y ∂(P x : Measure Y)) < ε/2 := + (Metric.tendsto_nhds.mp hg.continuousAt) (ε/2) hε2 + filter_upwards [h1,h2] with x' hx' hx'' + have hint : |(∫ y, F (x',y) ∂(P x' : Measure Y))-(∫ y, F (x,y) ∂(P x' : Measure Y))| ≤ + ‖F.curry x'-F.curry x‖ := by + exact ReferenceClasses.integral_uniform_error _ + (BoundedContinuousFunction.mkOfCompact (F.curry x')) g + (fun y => by + change |(F.curry x'-F.curry x) y| ≤ _ + simpa only [Real.norm_eq_abs] using (F.curry x'-F.curry x).norm_coe_le_norm y) + rw [Real.dist_eq] at hx'' ⊢ + have hh := abs_sub_le (∫ y, F (x',y) ∂(P x' : Measure Y)) + (∫ y, F (x,y) ∂(P x' : Measure Y)) (∫ y, F (x,y) ∂(P x : Measure Y)) + change |(∫ y, F (x,y) ∂(P x' : Measure Y))-(∫ y, F (x,y) ∂(P x : Measure Y))|<ε/2 at hx'' + linarith + +variable [MeasurableSpace X] [BorelSpace X] + [CompactSpace X] [SecondCountableTopology X] [SecondCountableTopology Y] + +noncomputable def compProdProb (μ : ProbabilityMeasure X) (K : Kernel X Y) [IsMarkovKernel K] : + ProbabilityMeasure (X×Y) := ⟨(μ : Measure X).compProd K,inferInstance⟩ + +noncomputable def kernelProb (K : Kernel X Y) [IsMarkovKernel K] (x : X) : + ProbabilityMeasure Y := ⟨K x,inferInstance⟩ + +lemma compProdProb_tendsto (K : Kernel X Y) [IsMarkovKernel K] + (hK : Continuous (kernelProb K)) + {l : Filter I} {μs : I → ProbabilityMeasure X} {μ : ProbabilityMeasure X} + (hμ : Tendsto μs l (𝓝 μ)) : Tendsto (fun i => compProdProb (μs i) K) l (𝓝 (compProdProb μ K)) := by + apply ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mpr + intro f + let g : X →ᵇ ℝ := BoundedContinuousFunction.mkOfCompact + ⟨fun x => ∫ y, f (x,y) ∂K x,continuous_joint_integral _ hK f.toContinuousMap⟩ + have heq (ρ : ProbabilityMeasure X) : + (∫ p, f p ∂(compProdProb ρ K : Measure (X×Y)))=(∫ x, g x ∂(ρ : Measure X)) := by + exact integral_compProd (f.integrable ((ρ : Measure X).compProd K)) + simp_rw [heq] + exact ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mp hμ g + +end DirectionalTransience.Entropy + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RelativeBudget.lean b/lean/OAI/Probability/Ballisticity/Estimates/RelativeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..79e24df6062dafd585aa9a6bfd6ca88b667c2193 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RelativeBudget.lean @@ -0,0 +1,297 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.WordConcatenation + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def relativeWordDisplacement {d : ℕ} (e f : Direction d) (x : Lattice d) + (s : ℕ) (w : List (Direction d)) : ℝ := + signedCoordinate f (wordFirstHitPosition e x s w - x) + +def TupleRelativeBudget {d k : ℕ} (e f : Direction d) (x : Fin k → Lattice d) + (H : ℕ) (r : ℝ) (w : Fin k → List (Direction d)) : Prop := + ∀ s ≤ H, ∀ i j, |relativeWordDisplacement e f (x i) s (w i) - + relativeWordDisplacement e f (x j) s (w j)| ≤ r + +def TupleSeparated {d k : ℕ} (f : Direction d) (G : ℝ) (x : Fin k → Lattice d) : Prop := + ∀ i j, i ≠ j → G ≤ |signedCoordinate f (x i) - signedCoordinate f (x j)| + +def tupleWordEndpoint {d k : ℕ} (x : Fin k → Lattice d) + (w : Fin k → List (Direction d)) : Fin k → Lattice d := + fun j => wordPath (x j) (w j) (w j).length + +lemma relativeWordDisplacement_endpoint {d : ℕ} (e f : Direction d) (x : Lattice d) + (H : ℕ) (w : HitWord x (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H)) : + relativeWordDisplacement e f x H w.val = signedCoordinate f (wordPath x w.val w.val.length - x) := by + unfold relativeWordDisplacement wordFirstHitPosition + rw [wordFirstHitTime_endpoint] + +lemma relativeWordDisplacement_append_prefix {d : ℕ} (e f : Direction d) (x : Lattice d) + (h s : ℕ) (hs : s ≤ h) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : List (Direction d)) : + relativeWordDisplacement e f x s (u.val++v) = relativeWordDisplacement e f x s u.val := by + unfold relativeWordDisplacement + rw [wordFirstHitPosition_append_prefix e x h s hs u v] + +lemma relativeWordDisplacement_append_suffix {d : ℕ} (e f : Direction d) (x : Lattice d) + (h m t : ℕ) (ht : t ≤ m) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : HitWord (wordPath x u.val u.val.length) + (Strip (realPosition (step e)) (wordPath x u.val u.val.length) m) + (Upper (realPosition (step e)) (wordPath x u.val u.val.length) m)) : + relativeWordDisplacement e f x (h+t) (u.val++v.val) = + relativeWordDisplacement e f x h u.val + + relativeWordDisplacement e f (wordPath x u.val u.val.length) t v.val := by + rw [relativeWordDisplacement_endpoint e f x h u] + unfold relativeWordDisplacement + rw [wordFirstHitPosition_append_suffix e x h m t ht u v] + simp only [signedCoordinate_sub] + ring + +lemma tupleRelativeBudget_append {d k : ℕ} (e f : Direction d) (x : Fin k → Lattice d) + (h m : ℕ) (r q : ℝ) (hq : 0 ≤ q) + (u : ∀ j, HitWord (x j) (Strip (realPosition (step e)) (x j) h) (Upper (realPosition (step e)) (x j) h)) + (v : ∀ j, HitWord (wordPath (x j) (u j).val (u j).val.length) + (Strip (realPosition (step e)) (wordPath (x j) (u j).val (u j).val.length) m) + (Upper (realPosition (step e)) (wordPath (x j) (u j).val (u j).val.length) m)) + (hu : TupleRelativeBudget e f x h r (fun j => (u j).val)) + (hv : TupleRelativeBudget e f (fun j => wordPath (x j) (u j).val (u j).val.length) + m q (fun j => (v j).val)) : + TupleRelativeBudget e f x (h+m) (r+q) (fun j => (u j).val++(v j).val) := by + intro s hs i j + by_cases hsh : s ≤ h + · rw [relativeWordDisplacement_append_prefix e f (x i) h s hsh (u i) (v i).val, + relativeWordDisplacement_append_prefix e f (x j) h s hsh (u j) (v j).val] + exact (hu s hsh i j).trans (le_add_of_nonneg_right hq) + · have he : s = h+(s-h) := by omega + have ht : s-h ≤ m := by omega + rw [he,relativeWordDisplacement_append_suffix e f (x i) h m (s-h) ht (u i) (v i), + relativeWordDisplacement_append_suffix e f (x j) h m (s-h) ht (u j) (v j)] + have h1 := hu h le_rfl i j + have h2 := hv (s-h) ht i j + calc + _ = |(relativeWordDisplacement e f (x i) h (u i).val - + relativeWordDisplacement e f (x j) h (u j).val) + + (relativeWordDisplacement e f (wordPath (x i) (u i).val (u i).val.length) (s-h) (v i).val - + relativeWordDisplacement e f (wordPath (x j) (u j).val (u j).val.length) (s-h) (v j).val)| := by + congr 1; ring + _ ≤ _ := (abs_add_le _ _).trans (add_le_add h1 h2) + +lemma tupleRelativeBudget_separation {d k : ℕ} (e f : Direction d) (x : Fin k → Lattice d) + (H : ℕ) (G r : ℝ) + (w : ∀ j, HitWord (x j) (Strip (realPosition (step e)) (x j) H) (Upper (realPosition (step e)) (x j) H)) + (hG : TupleSeparated f G x) + (hw : TupleRelativeBudget e f x H r (fun j => (w j).val)) : + TupleSeparated f (G-r) (tupleWordEndpoint x (fun j => (w j).val)) := by + intro i j hij + have hb := hw H le_rfl i j + rw [relativeWordDisplacement_endpoint e f (x i) H (w i), + relativeWordDisplacement_endpoint e f (x j) H (w j)] at hb + apply sub_le_iff_le_add.mpr + change G ≤ |signedCoordinate f (wordPath (x i) (w i).val (w i).val.length) - + signedCoordinate f (wordPath (x j) (w j).val (w j).val.length)| + r + calc + G ≤ |signedCoordinate f (x i)-signedCoordinate f (x j)| := hG i j hij + _ = |(signedCoordinate f (wordPath (x i) (w i).val (w i).val.length) - + signedCoordinate f (wordPath (x j) (w j).val (w j).val.length)) - + (signedCoordinate f (wordPath (x i) (w i).val (w i).val.length - x i) - + signedCoordinate f (wordPath (x j) (w j).val (w j).val.length - x j))| := by + simp only [signedCoordinate_sub]; congr 1; ring + _ ≤ _ := (abs_sub _ _).trans (add_le_add le_rfl hb) + +noncomputable def relativeBudgetWordLaw {d k : ℕ} (e f : Direction d) + (H : ℕ) (r : ℝ) (ω : Environment d) (x : Fin k → Lattice d) : + Measure (Fin k → List (Direction d)) := + (rawTupleWordLaw (realPosition (step e)) H ω x).restrict {w | TupleRelativeBudget e f x H r w} + +noncomputable def relativeBudgetEndpointLaw {d k : ℕ} (e f : Direction d) + (H : ℕ) (r : ℝ) (ω : Environment d) (x : Fin k → Lattice d) : + Measure (Fin k → Lattice d) := + (relativeBudgetWordLaw e f H r ω x).map (tupleWordEndpoint x) + +instance relativeBudgetWordLaw_finite {d k : ℕ} (e f : Direction d) + (H : ℕ) (r : ℝ) (ω : Environment d) (x : Fin k → Lattice d) : + IsFiniteMeasure (relativeBudgetWordLaw e f H r ω x) := by + unfold relativeBudgetWordLaw + infer_instance + +instance relativeBudgetEndpointLaw_finite {d k : ℕ} (e f : Direction d) + (H : ℕ) (r : ℝ) (ω : Environment d) (x : Fin k → Lattice d) : + IsFiniteMeasure (relativeBudgetEndpointLaw e f H r ω x) := by + unfold relativeBudgetEndpointLaw + infer_instance + +lemma relativeBudgetEndpointLaw_le {d k : ℕ} (e f : Direction d) + (H : ℕ) (r : ℝ) (ω : Environment d) (x : Fin k → Lattice d) : + relativeBudgetEndpointLaw e f H r ω x ≤ rawTupleEndpointLaw (realPosition (step e)) H ω x := by + rw [← rawTupleWordLaw_endpoint (realPosition (step e)) H ω x] + exact Measure.map_mono Measure.restrict_le_self (measurable_of_countable _) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience +namespace TupleKernel + +noncomputable def dependentPair {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + (μ : Measure A) (K : A → Measure B) : Measure (A × B) := + μ.bind (fun a => (K a).map (fun b => (a,b))) + +lemma dependentPair_singleton {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable A] [Countable B] [MeasurableSingletonClass A] [MeasurableSingletonClass B] + (μ : Measure A) (K : A → Measure B) (a : A) (b : B) : + dependentPair μ K {(a,b)} = μ {a} * K a {b} := by + rw [dependentPair,Measure.bind_apply (measurableSet_singleton _) (measurable_of_countable _).aemeasurable, + lintegral_countable'] + have he (c : A) : ((K c).map (fun b => (c,b))) {(a,b)} = if c=a then K c {b} else 0 := by + rw [Measure.map_apply (measurable_of_countable _) (measurableSet_singleton _)] + by_cases hc : c=a + · subst c + rw [ite_eq_left rfl] + congr 1 + ext y + simp + · rw [ite_eq_right hc] + have hset : (fun y => (c,y)) ⁻¹' {(a,b)} = (∅ : Set B) := by + ext y + simp [hc] + rw [hset,measure_empty] + simp_rw [he] + rw [tsum_eq_single a] + · simp [mul_comm] + · intro c hc + simp [hc] + +lemma restrict_singleton {A : Type*} [MeasurableSpace A] [MeasurableSingletonClass A] + (μ : Measure A) (S : Set A) (a : A) : + μ.restrict S {a} = if a ∈ S then μ {a} else 0 := by + rw [Measure.restrict_apply (measurableSet_singleton a)] + by_cases ha : a ∈ S + · rw [ite_eq_left ha,Set.singleton_inter_of_mem ha] + · rw [ite_eq_right ha,Set.singleton_inter_of_notMem ha,measure_empty] + +end TupleKernel + +noncomputable def rawTupleSplitLaw {d k : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : + Measure ((Fin k → List (Direction d)) × (Fin k → List (Direction d))) := + TupleKernel.dependentPair (rawTupleWordLaw (realPosition (step e)) h ω x) + (fun u => rawTupleWordLaw (realPosition (step e)) m ω (tupleWordEndpoint x u)) + +lemma rawTupleSplitLaw_singleton {d k : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) (u v : Fin k → List (Direction d)) : + rawTupleSplitLaw e h m ω x {(u,v)} = ∏ j, rawWordPairLaw e h m ω (x j) {(u j,v j)} := by + rw [rawTupleSplitLaw,TupleKernel.dependentPair_singleton] + simp only [rawTupleWordLaw_singleton,rawWordPairLaw_singleton,tupleWordEndpoint,Finset.prod_mul_distrib] + +def ValidTupleSplit {d k : ℕ} (e : Direction d) (x : Fin k → Lattice d) (h m : ℕ) + (p : (Fin k → List (Direction d)) × (Fin k → List (Direction d))) : Prop := + ∀ j, ValidWordSplit e (x j) h m (p.1 j,p.2 j) + +def tupleWordConcat {d k : ℕ} + (p : (Fin k → List (Direction d)) × (Fin k → List (Direction d))) : Fin k → List (Direction d) := + fun j => p.1 j++p.2 j + +lemma tupleWordConcat_injOn {d k : ℕ} (e : Direction d) (x : Fin k → Lattice d) (h m : ℕ) : + Set.InjOn (tupleWordConcat (d := d) (k := k)) {p | ValidTupleSplit e x h m p} := by + intro u hu v hv he + have hi (j) : (u.1 j,u.2 j) = (v.1 j,v.2 j) := by + apply congrArg Subtype.val + (coordinateWordConcat_injective e (x j) h m (a₁ := ⟨(u.1 j,u.2 j),hu j⟩) + (a₂ := ⟨(v.1 j,v.2 j),hv j⟩) _) + exact Subtype.ext (congrFun he j) + exact Prod.ext (funext fun j => congrArg Prod.fst (hi j)) (funext fun j => congrArg Prod.snd (hi j)) + +lemma rawTupleSplitLaw_invalid {d k : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) + (p : (Fin k → List (Direction d)) × (Fin k → List (Direction d))) + (hp : ¬ ValidTupleSplit e x h m p) : rawTupleSplitLaw e h m ω x {p} = 0 := by + rw [← Prod.eta p,rawTupleSplitLaw_singleton] + obtain ⟨j,hj⟩ := not_forall.mp hp + exact Finset.prod_eq_zero (Finset.mem_univ j) + (rawWordPairLaw_invalid e h m ω (x j) (p.1 j,p.2 j) hj) + +lemma rawTupleSplitLaw_valid {d k : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) + (p : (Fin k → List (Direction d)) × (Fin k → List (Direction d))) + (hp : ValidTupleSplit e x h m p) : rawTupleSplitLaw e h m ω x {p} = + rawTupleWordLaw (realPosition (step e)) (h+m) ω x {tupleWordConcat p} := by + rw [← Prod.eta p,rawTupleSplitLaw_singleton,rawTupleWordLaw_singleton] + apply Finset.prod_congr rfl + intro j _ + exact rawWordPairLaw_valid e h m ω (x j) ⟨(p.1 j,p.2 j),hp j⟩ + +lemma rawTupleWordLaw_comp_le {d k : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : + (rawTupleSplitLaw e h m ω x).map tupleWordConcat ≤ + rawTupleWordLaw (realPosition (step e)) (h+m) ω x := by + apply TupleKernel.countable_restricted_map_le _ _ {p | ValidTupleSplit e x h m p} + tupleWordConcat (tupleWordConcat_injOn e x h m) + · exact fun p hp => rawTupleSplitLaw_invalid e h m ω x p hp + · exact fun p hp => (rawTupleSplitLaw_valid e h m ω x p hp).le + +noncomputable def relativeBudgetSplitLaw {d k : ℕ} (e f : Direction d) (h m : ℕ) + (r q : ℝ) (ω : Environment d) (x : Fin k → Lattice d) : + Measure ((Fin k → List (Direction d)) × (Fin k → List (Direction d))) := + TupleKernel.dependentPair (relativeBudgetWordLaw e f h r ω x) + (fun u => relativeBudgetWordLaw e f m q ω (tupleWordEndpoint x u)) + +lemma relativeBudgetWordLaw_singleton {d k : ℕ} (e f : Direction d) (H : ℕ) + (r : ℝ) (ω : Environment d) (x : Fin k → Lattice d) (w : Fin k → List (Direction d)) : + relativeBudgetWordLaw e f H r ω x {w} = + if TupleRelativeBudget e f x H r w then rawTupleWordLaw (realPosition (step e)) H ω x {w} else 0 := by + exact TupleKernel.restrict_singleton _ _ _ + +lemma relativeBudgetSplitLaw_singleton {d k : ℕ} (e f : Direction d) (h m : ℕ) + (r q : ℝ) (ω : Environment d) (x : Fin k → Lattice d) + (p : (Fin k → List (Direction d)) × (Fin k → List (Direction d))) : + relativeBudgetSplitLaw e f h m r q ω x {p} = + if TupleRelativeBudget e f x h r p.1 ∧ + TupleRelativeBudget e f (tupleWordEndpoint x p.1) m q p.2 + then rawTupleSplitLaw e h m ω x {p} else 0 := by + rw [← Prod.eta p,relativeBudgetSplitLaw,TupleKernel.dependentPair_singleton, + rawTupleSplitLaw,TupleKernel.dependentPair_singleton] + simp only [relativeBudgetWordLaw_singleton] + split_ifs <;> simp_all + +lemma relativeBudgetWordLaw_comp_le {d k : ℕ} (e f : Direction d) (h m : ℕ) + (r q : ℝ) (hq : 0 ≤ q) (ω : Environment d) (x : Fin k → Lattice d) : + (relativeBudgetSplitLaw e f h m r q ω x).map tupleWordConcat ≤ + relativeBudgetWordLaw e f (h+m) (r+q) ω x := by + let S := {p | ValidTupleSplit e x h m p ∧ TupleRelativeBudget e f x h r p.1 ∧ + TupleRelativeBudget e f (tupleWordEndpoint x p.1) m q p.2} + apply TupleKernel.countable_restricted_map_le _ _ S + · intro a ha b hb he + exact tupleWordConcat_injOn e x h m ha.1 hb.1 he + · intro p hp + rw [relativeBudgetSplitLaw_singleton] + by_cases hbudget : TupleRelativeBudget e f x h r p.1 ∧ + TupleRelativeBudget e f (tupleWordEndpoint x p.1) m q p.2 + · rw [ite_eq_left hbudget] + exact rawTupleSplitLaw_invalid e h m ω x p (fun hval => hp ⟨hval,hbudget⟩) + · exact ite_eq_right hbudget + · intro p hp + rw [relativeBudgetSplitLaw_singleton,ite_eq_left hp.2,rawTupleSplitLaw_valid e h m ω x p hp.1, + relativeBudgetWordLaw_singleton] + have hc : TupleRelativeBudget e f x (h+m) (r+q) (tupleWordConcat p) := + tupleRelativeBudget_append e f x h m r q hq + (fun j => coordinateSplitFirst e (x j) h m ⟨(p.1 j,p.2 j),hp.1 j⟩) + (fun j => coordinateSplitSecond e (x j) h m ⟨(p.1 j,p.2 j),hp.1 j⟩) hp.2.1 hp.2.2 + rw [ite_eq_left hc] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RestartLyapunov.lean b/lean/OAI/Probability/Ballisticity/Estimates/RestartLyapunov.lean new file mode 100644 index 0000000000000000000000000000000000000000..b77b7afa7b1563b66b37d2b7d61683ae58436ed2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RestartLyapunov.lean @@ -0,0 +1,177 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +def observerRewardSum {Ω : Type*} (next : Ω → Ω) (reward : Ω → ℝ≥0∞) : ℕ → Ω → ℝ≥0∞ + | 0, _ => 0 + | N+1, ω => reward ω+observerRewardSum next reward N (next ω) + +lemma measurable_observerRewardSum {Ω : Type*} [MeasurableSpace Ω] + (next : Ω → Ω) (reward : Ω → ℝ≥0∞) (hn : Measurable next) (hr : Measurable reward) + (N : ℕ) : Measurable (observerRewardSum next reward N) := by + induction N with + | zero => exact measurable_const + | succ N ih => exact hr.add (ih.comp hn) + +lemma observerRewardSum_mono {Ω : Type*} (next : Ω → Ω) (reward : Ω → ℝ≥0∞) : + Monotone (observerRewardSum next reward) := by + apply monotone_nat_of_le_succ + intro N + induction N with + | zero => exact fun _ => zero_le + | succ N ih => exact fun ω => add_le_add_right (ih (next ω)) _ + +lemma restart_lyapunov_finite {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [Countable I] [MeasurableSingletonClass I] + (μ : I → Measure Ω) (state : Ω → I) (next : Ω → Ω) (good : I → Prop) + (reward : Ω → ℝ≥0∞) (V : I → ℝ≥0∞) + (hs : Measurable state) (hn : Measurable next) (hr : Measurable reward) + (hrestart : ∀ i, good i → ∀ g : Ω → ℝ≥0∞, Measurable g → + (∫⁻ ω, g (next ω) ∂μ i) = ∫⁻ ω, (∫⁻ η, g η ∂μ (state (next ω))) ∂μ i) + (hgood : ∀ i, good i → ∀ᵐ ω ∂μ i, good (state (next ω))) + (hdrift : ∀ i, good i → (∫⁻ ω, reward ω+V (state (next ω)) ∂μ i) ≤ V i) + (N : ℕ) : ∀ i, good i → (∫⁻ ω, observerRewardSum next reward N ω ∂μ i) ≤ V i := by + induction N with + | zero => intro i hi; simp only [observerRewardSum,lintegral_zero]; exact zero_le + | succ N ih => + intro i hi + have hsum := measurable_observerRewardSum next reward hn hr N + have hV : Measurable V := measurable_of_countable _ + calc + (∫⁻ ω, observerRewardSum next reward (N+1) ω ∂μ i) = + (∫⁻ ω, reward ω ∂μ i)+(∫⁻ ω, observerRewardSum next reward N (next ω) ∂μ i) := + lintegral_add_left hr _ + _ = (∫⁻ ω, reward ω ∂μ i)+ + (∫⁻ ω, (∫⁻ η, observerRewardSum next reward N η ∂μ (state (next ω))) ∂μ i) := by + rw [hrestart i hi _ hsum] + _ ≤ (∫⁻ ω, reward ω ∂μ i)+(∫⁻ ω, V (state (next ω)) ∂μ i) := + add_le_add_right (lintegral_mono_ae ((hgood i hi).mono fun ω hω => ih _ hω)) _ + _ = (∫⁻ ω, reward ω+V (state (next ω)) ∂μ i) := + (lintegral_add_right _ ((hV.comp hs).comp hn)).symm + _ ≤ V i := hdrift i hi + +lemma restart_lyapunov_total {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [Countable I] [MeasurableSingletonClass I] + (μ : I → Measure Ω) (state : Ω → I) (next : Ω → Ω) (good : I → Prop) + (reward : Ω → ℝ≥0∞) (V : I → ℝ≥0∞) + (hs : Measurable state) (hn : Measurable next) (hr : Measurable reward) + (hrestart : ∀ i, good i → ∀ g : Ω → ℝ≥0∞, Measurable g → + (∫⁻ ω, g (next ω) ∂μ i) = ∫⁻ ω, (∫⁻ η, g η ∂μ (state (next ω))) ∂μ i) + (hgood : ∀ i, good i → ∀ᵐ ω ∂μ i, good (state (next ω))) + (hdrift : ∀ i, good i → (∫⁻ ω, reward ω+V (state (next ω)) ∂μ i) ≤ V i) + (i : I) (hi : good i) : + (∫⁻ ω, ⨆ N, observerRewardSum next reward N ω ∂μ i) ≤ V i := by + rw [lintegral_iSup (fun N => measurable_observerRewardSum next reward hn hr N) + (observerRewardSum_mono next reward)] + exact iSup_le fun N => restart_lyapunov_finite μ state next good reward V hs hn hr + hrestart hgood hdrift N i hi + +lemma restart_bounded_potential_total {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [Countable I] [MeasurableSingletonClass I] + (μ : I → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (state : Ω → I) (next : Ω → Ω) (good : I → Prop) + (potential gain : I → ℝ) (C : ℝ) + (hs : Measurable state) (hn : Measurable next) + (horigin : ∀ i, good i → ∀ᵐ ω ∂μ i, state ω=i) + (hrestart : ∀ i, good i → ∀ g : Ω → ℝ≥0∞, Measurable g → + (∫⁻ ω, g (next ω) ∂μ i) = ∫⁻ ω, (∫⁻ η, g η ∂μ (state (next ω))) ∂μ i) + (hgood : ∀ i, good i → ∀ᵐ ω ∂μ i, good (state (next ω))) + (hpot : ∀ i, 0≤potential i ∧ potential i≤C) + (hgain : ∀ i, 0≤gain i) + (hdrift : ∀ i, good i → gain i+potential i ≤ ∫ ω, potential (state (next ω)) ∂μ i) + (i : I) (hi : good i) : + (∫⁻ ω, ⨆ N, observerRewardSum next (fun η => ENNReal.ofReal (gain (state η))) N ω ∂μ i) + ≤ ENNReal.ofReal (C-potential i) := by + let reward := fun ω => ENNReal.ofReal (gain (state ω)) + let V := fun j => ENNReal.ofReal (C-potential j) + have hp : Measurable potential := measurable_of_countable _ + have hg : Measurable gain := measurable_of_countable _ + have hV : Measurable (fun j => C-potential j) := measurable_const.sub hp + have hr : Measurable reward := (hg.comp hs).ennreal_ofReal + apply restart_lyapunov_total μ state next good reward V hs hn hr hrestart hgood + (fun j hj => ?_) i hi + have hiP : Integrable (fun ω => potential (state (next ω))) (μ j) := by + apply Integrable.of_bound ((hp.comp hs).comp hn).aestronglyMeasurable C + exact Eventually.of_forall fun ω => by + change ‖potential (state (next ω))‖ ≤ C + rw [Real.norm_eq_abs,abs_of_nonneg (hpot _).1] + exact (hpot _).2 + have hiV : Integrable (fun ω => C-potential (state (next ω))) (μ j) := + (integrable_const C).sub hiP + have hiG : Integrable (fun ω => gain (state ω)) (μ j) := by + apply (integrable_const (gain j)).congr + exact (horigin j hj).mono fun ω hω => (congrArg gain hω).symm + have hh : (fun ω => reward ω+V (state (next ω))) = + (fun ω => ENNReal.ofReal (gain (state ω)+(C-potential (state (next ω))))) := by + funext ω + exact (ENNReal.ofReal_add (hgain _) (sub_nonneg.mpr (hpot _).2)).symm + have hsum : Integrable (fun ω => gain (state ω)+(C-potential (state (next ω)))) (μ j) := hiG.add hiV + rw [hh,← ofReal_integral_eq_lintegral_ofReal hsum + (Eventually.of_forall fun ω => add_nonneg (hgain _) (sub_nonneg.mpr (hpot _).2))] + apply ENNReal.ofReal_le_ofReal + rw [integral_add hiG hiV,integral_sub (integrable_const C) hiP] + have he : (∫ ω, gain (state ω) ∂μ j)=gain j := by + rw [integral_congr_ae ((horigin j hj).mono fun ω hω => congrArg gain hω),integral_const] + simp + rw [he,integral_const] + simp only [probReal_univ,smul_eq_mul,one_mul] + have hd := hdrift j hj + linarith + +lemma restart_reward_comparison_total {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [Countable I] [MeasurableSingletonClass I] + (μ : I → Measure Ω) (state : Ω → I) (next : Ω → Ω) (good : I → Prop) + (reward bound : Ω → ℝ≥0∞) + (hn : Measurable next) (hr : Measurable reward) (hb : Measurable bound) + (hrestart : ∀ i, good i → ∀ g : Ω → ℝ≥0∞, Measurable g → + (∫⁻ ω, g (next ω) ∂μ i) = ∫⁻ ω, (∫⁻ η, g η ∂μ (state (next ω))) ∂μ i) + (hgood : ∀ i, good i → ∀ᵐ ω ∂μ i, good (state (next ω))) + (hmean : ∀ i, good i → (∫⁻ ω, reward ω ∂μ i) ≤ ∫⁻ ω, bound ω ∂μ i) + (i : I) (hi : good i) : + (∫⁻ ω, ⨆ N, observerRewardSum next reward N ω ∂μ i) ≤ + ∫⁻ ω, ⨆ N, observerRewardSum next bound N ω ∂μ i := by + have hfin : ∀ N i, good i → + (∫⁻ ω, observerRewardSum next reward N ω ∂μ i) ≤ + ∫⁻ ω, observerRewardSum next bound N ω ∂μ i := by + intro N + induction N with + | zero => intro i hi; simp only [observerRewardSum,lintegral_zero,le_refl] + | succ N ih => + intro i hi + change (∫⁻ ω, reward ω+observerRewardSum next reward N (next ω) ∂μ i) ≤ + ∫⁻ ω, bound ω+observerRewardSum next bound N (next ω) ∂μ i + rw [lintegral_add_left hr,lintegral_add_left hb, + hrestart i hi _ (measurable_observerRewardSum next reward hn hr N), + hrestart i hi _ (measurable_observerRewardSum next bound hn hb N)] + exact add_le_add (hmean i hi) + (lintegral_mono_ae ((hgood i hi).mono fun ω hω => ih _ hω)) + rw [lintegral_iSup (fun N => measurable_observerRewardSum next reward hn hr N) + (observerRewardSum_mono next reward), + lintegral_iSup (fun N => measurable_observerRewardSum next bound hn hb N) + (observerRewardSum_mono next bound)] + exact iSup_mono fun N => hfin N i hi + +lemma observerRewardSum_mul {Ω : Type*} (next : Ω → Ω) (reward : Ω → ℝ≥0∞) + (c : ℝ≥0∞) (N : ℕ) (ω : Ω) : + observerRewardSum next (fun η => c*reward η) N ω=c*observerRewardSum next reward N ω := by + induction N generalizing ω with + | zero => simp only [observerRewardSum,mul_zero] + | succ N ih => simp only [observerRewardSum,ih,mul_add] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RestartSupportedBound.lean b/lean/OAI/Probability/Ballisticity/Estimates/RestartSupportedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..deb416bb4d92817137345400ae871b8f60078589 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RestartSupportedBound.lean @@ -0,0 +1,46 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RealJointPastRestart + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma countable_restart_supported_bound {Ω I S : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [MeasurableSpace S] [Countable I] [MeasurableSingletonClass I] + (μ : Measure Ω) [IsProbabilityMeasure μ] + (D : Ω → I) (Y : Ω → S) (κ : I → Measure S) [∀ j, IsProbabilityMeasure (κ j)] + (hD : Measurable D) (hY : Measurable Y) + (hrestart : ∀ j, (μ.restrict (D ⁻¹' {j})).map Y = μ (D ⁻¹' {j}) • κ j) + (V : I → Prop) (hV : ∀ᵐ a ∂μ, V (D a)) + (f : I → ℝ) (g : I → S → ℝ) (hg : ∀ j, Measurable (g j)) + (C M B : ℝ) (hC : 0≤C) (hB : 0≤B) + (hf : ∀ j, ‖f j‖≤C) (hM : ∀ j z, ‖g j z‖≤M) + (hbound : ∀ j, V j → f j ≠ 0 → |∫ z, g j z ∂κ j|≤B) : + |∫ a, f (D a)*g (D a) (Y a) ∂μ|≤C*B := by + rw [integral_countable_restart μ D Y κ hD hY hrestart + (fun j z => f j*g j z) (fun j => (hg j).const_mul _) (C*M) + (fun j z => by rw [norm_mul]; exact mul_le_mul (hf j) (hM j z) (norm_nonneg _) hC)] + simp only [integral_const_mul] + have h := norm_integral_le_of_norm_le_const (μ := μ) + (f := fun a => f (D a)*(∫ z, g (D a) z ∂κ (D a))) (C := C*B) + (hV.mono fun a ha => by + rw [norm_mul] + by_cases hz : f (D a)=0 + · simp only [hz,norm_zero,zero_mul]; exact mul_nonneg hC hB + · rw [Real.norm_eq_abs] + exact mul_le_mul (hf _) (hbound _ ha hz) (abs_nonneg _) hC) + simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using h + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/RetainedComposition.lean b/lean/OAI/Probability/Ballisticity/Estimates/RetainedComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..3734ee79841a664614c94b96c8bc7422c40ccda6 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/RetainedComposition.lean @@ -0,0 +1,198 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RawPair +import OAI.Probability.Ballisticity.Estimates.ProtectionLoss + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +lemma rawTupleMixture_mono {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) {μ ν : Measure (Fin k → Lattice d)} (h : μ≤ν) : + rawTupleMixture ℓ H μ ω≤rawTupleMixture ℓ H ν ω := by + apply Measure.le_iff.mpr + intro U hU + rw [rawTupleMixture_apply,rawTupleMixture_apply] + exact lintegral_mono' h le_rfl + +lemma rawTupleMixture_smul {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (c : ℝ≥0∞) (μ : Measure (Fin k → Lattice d)) : + rawTupleMixture ℓ H (c•μ) ω=c•rawTupleMixture ℓ H μ ω := + Measure.bind_smul c μ (measurable_of_countable _).aemeasurable + +lemma rawTupleMixture_comp_le {d k : ℕ} (e : Direction d) (h m : ℕ) + (π : Measure (Fin k → Lattice d)) (ω : Environment d) : + rawTupleMixture (realPosition (step e)) m + (rawTupleMixture (realPosition (step e)) h π ω) ω≤ + rawTupleMixture (realPosition (step e)) (h+m) π ω := by + unfold rawTupleMixture + rw [Measure.bind_bind (measurable_of_countable _).aemeasurable (measurable_of_countable _).aemeasurable] + apply Measure.le_iff.mpr + intro U hU + rw [Measure.bind_apply hU (measurable_of_countable _).aemeasurable, + Measure.bind_apply hU (measurable_of_countable _).aemeasurable] + apply lintegral_mono + intro x + exact rawTupleEndpointLaw_comp_le e h m ω x U + +lemma rawTupleEndpointLaw_zero {d k : ℕ} (ℓ : Vector d) (ω : Environment d) + (x : Fin k → Lattice d) : rawTupleEndpointLaw ℓ 0 ω x=Measure.dirac x := by + apply Measure.ext_of_singleton + intro y + rw [rawTupleEndpointLaw_singleton] + have hz (j : Fin k) : variableHitKernel ℓ 0 (ω,x j)=Measure.dirac (x j) := by + simpa only [variableHitKernel, Kernel.coe_mk, Nat.cast_zero] using hitKernel_height_zero ℓ (x j) ω + simp_rw [hz] + by_cases h : x=y + · subst y + simp + · obtain ⟨j,hj⟩ : ∃ j, x j ≠ y j := by + by_contra! hn + exact h (funext hn) + simp only [Measure.dirac_apply', measurableSet_singleton, Set.indicator_apply, + Pi.one_apply, Set.mem_singleton_iff, h, ↓reduceIte] + apply Finset.prod_eq_zero (Finset.mem_univ j) + simp [hj] + +lemma rawTupleMixture_zero {d k : ℕ} (ℓ : Vector d) (π : Measure (Fin k → Lattice d)) + (ω : Environment d) : rawTupleMixture ℓ 0 π ω=π := by + unfold rawTupleMixture + have hz : rawTupleEndpointLaw (k:=k) ℓ 0 ω=Measure.dirac := funext (rawTupleEndpointLaw_zero ℓ ω) + rw [hz,Measure.bind_dirac] + +lemma budgetEndpointMixture_le_raw {d k : ℕ} (e f : Direction d) (H : ℕ) (r : ℝ) + (π : Measure (Fin k → Lattice d)) (ω : Environment d) : + budgetEndpointMixture e f H r π ω≤rawTupleMixture (realPosition (step e)) H π ω := by + apply Measure.le_iff.mpr + intro U hU + rw [budgetEndpointMixture_apply,rawTupleMixture_apply] + exact lintegral_mono fun x => relativeBudgetEndpointLaw_le e f H r ω x U + +lemma protectionMass_ennreal {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) (n : ℕ) (ω : Environment d) : + ENNReal.ofReal (protectionMass e f base G H r hr π n ω)= + relativeBudgetMassENN e f (H n) (r n) (protectionProfile e f base G H r hr π n ω).val ω := by + rw [protectionMass,←relativeBudgetMassENN_toReal] + exact ENNReal.ofReal_toReal (lt_of_le_of_lt (relativeBudgetMassENN_le_one e f _ _ _ _) ENNReal.one_lt_top).ne + +lemma protection_retained_succ {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) (n : ℕ) (ω : Environment d) : + ENNReal.ofReal (protectionMass e f base G H r hr π n ω) • + (protectionProfile e f base G H r hr π (n+1) ω).val≤ + rawTupleMixture (realPosition (step e)) (H n) + (protectionProfile e f base G H r hr π n ω).val ω := by + rw [protectionMass_ennreal] + change relativeBudgetMassENN e f (H n) (r n) _ ω • + (nextBudgetProfile e f (H n) _ _ (r n) (hr n) _ ω).val≤_ + rw [nextBudgetProfile_mass] + exact budgetEndpointMixture_le_raw e f _ _ _ ω + +theorem protection_retained_le_raw {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i, 0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) (n : ℕ) (ω : Environment d) : + (∏ i∈Finset.range n, ENNReal.ofReal (protectionMass e f base G H r hr π i ω)) • + (protectionProfile e f base G H r hr π n ω).val≤ + rawTupleMixture (realPosition (step e)) (∑ i∈Finset.range n, H i) (π ω).val ω := by + induction n with + | zero => simp [protectionProfile,rawTupleMixture_zero] + | succ n ih => + rw [Finset.prod_range_succ,Finset.sum_range_succ,mul_smul] + let c := ∏ i∈Finset.range n, ENNReal.ofReal (protectionMass e f base G H r hr π i ω) + let p := (protectionProfile e f base G H r hr π n ω).val + have hs : c • (ENNReal.ofReal (protectionMass e f base G H r hr π n ω) • + (protectionProfile e f base G H r hr π (n+1) ω).val)≤ + c • rawTupleMixture (realPosition (step e)) (H n) p ω := + smul_le_smul_left c (protection_retained_succ e f base G H r hr π n ω) + have hc := rawTupleMixture_smul (realPosition (step e)) (H n) ω c p + have hm := rawTupleMixture_mono (realPosition (step e)) (H n) ω ih + exact hs.trans ((le_of_eq hc.symm).trans + (hm.trans (rawTupleMixture_comp_le e _ _ _ ω))) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +lemma upwardEndpoint_atom {d : ℕ} (e : Direction d) (ω : Environment d) (x : Lattice d) : + ((ω x).val e : ℝ≥0∞) ≤ variableHitKernel (realPosition (step e)) 1 (ω,x) {x+step e} := by + rw [←rawWordLaw_endpoint (realPosition (step e)) 1 ω x, + Measure.map_apply (measurable_of_countable _) (measurableSet_singleton _)] + have hm := measure_mono (μ:=rawWordLaw (realPosition (step e)) 1 ω x) + (show {[e]} ⊆ (fun w => wordPath x w w.length) ⁻¹' {x+step e} by + intro w hw; rcases Set.mem_singleton_iff.mp hw with rfl; simp [wordPath]) + rw [rawWordLaw_singleton,ite_eq_left (upwardWord_successful e x)] at hm + simpa only [wordWeight,mul_one,ENNReal.ofReal_coe_nnreal] using hm + +lemma tupleUpwardEndpoint_atom {d k : ℕ} (e : Direction d) (ω : Environment d) + (x : Fin k → Lattice d) (κ : ℝ≥0) (hκ : ∀ y, κ≤(ω y).val e) : + (κ : ℝ≥0∞)^k ≤ rawTupleEndpointLaw (realPosition (step e)) 1 ω x {tupleShiftUp e 1 x} := by + rw [rawTupleEndpointLaw_singleton] + calc + (κ : ℝ≥0∞)^k = ∏ _j : Fin k, (κ : ℝ≥0∞) := by simp + _ ≤ _ := Finset.prod_le_prod fun j _ => + (ENNReal.coe_le_coe.mpr (hκ (x j))).trans (by simpa only [tupleShiftUp,one_nsmul] using upwardEndpoint_atom e ω (x j)) + +lemma tupleUpwardEndpoint_le {d k : ℕ} (e : Direction d) (ω : Environment d) + (x : Fin k → Lattice d) (κ : ℝ≥0) (hκ : ∀ y, κ≤(ω y).val e) : + (κ : ℝ≥0∞)^k • Measure.dirac (tupleShiftUp e 1 x) ≤ rawTupleEndpointLaw (realPosition (step e)) 1 ω x := by + have h : (κ : ℝ≥0∞)^k • Measure.dirac (tupleShiftUp e 1 x) ≤ + rawTupleEndpointLaw (realPosition (step e)) 1 ω x {tupleShiftUp e 1 x} • Measure.dirac (tupleShiftUp e 1 x) := by + intro U + simp only [Measure.smul_apply,smul_eq_mul] + exact mul_le_mul_left (tupleUpwardEndpoint_atom e ω x κ hκ) _ + rw [←Measure.restrict_singleton] at h + exact h.trans Measure.restrict_le_self + +lemma tupleUpwardMixture_le {d k : ℕ} (e : Direction d) (ω : Environment d) + (μ : Measure (Fin k → Lattice d)) (κ : ℝ≥0) (hκ : ∀ y, κ≤(ω y).val e) : + (κ : ℝ≥0∞)^k • μ.map (tupleShiftUp e 1) ≤ rawTupleMixture (realPosition (step e)) 1 μ ω := by + rw [←Measure.bind_dirac_eq_map μ (measurable_of_countable _), + ←Measure.bind_smul _ _ (measurable_of_countable _).aemeasurable] + apply Measure.le_iff.mpr + intro U hU + rw [Measure.bind_apply hU (measurable_of_countable _).aemeasurable,rawTupleMixture_apply, + lintegral_smul_measure,smul_eq_mul] + rw [←lintegral_const_mul _ (measurable_of_countable _)] + apply lintegral_mono + intro x + exact tupleUpwardEndpoint_le e ω x κ hκ U + +lemma stage_separated_mass_upward {d k : ℕ} (e f : Direction d) (H : ℕ) (G : ℝ) + (π : Measure (Fin k → Lattice d)) (ω : Environment d) + (κ : ℝ≥0) (hκ : ∀ y, κ≤(ω y).val e) : + (κ : ℝ≥0∞)^k * rawTupleMixture (realPosition (step e)) H π ω {y | TupleSeparated f G y} ≤ + rawTupleMixture (realPosition (step e)) (H+1) π ω {y | TupleSeparated f G y} := by + let μ := (rawTupleMixture (realPosition (step e)) H π ω).restrict {y | TupleSeparated f G y} + have hm := (tupleUpwardMixture_le e ω μ κ hκ).trans + ((rawTupleMixture_mono (realPosition (step e)) 1 ω (show μ≤rawTupleMixture (realPosition (step e)) H π ω from Measure.restrict_le_self)).trans + (rawTupleMixture_comp_le e H 1 π ω)) + have he : μ.map (tupleShiftUp e 1) {y | TupleSeparated f G y}=μ Set.univ := by + rw [Measure.map_apply (measurable_of_countable _) (Set.to_countable _).measurableSet] + apply measure_congr + have hs : ∀ᵐ x ∂μ,TupleSeparated f G x := ae_restrict_mem (Set.to_countable _).measurableSet + filter_upwards [hs] with x hx + apply propext + apply iff_true_intro + intro i j hij + change G≤|signedCoordinate f (x i+1 • step e)-signedCoordinate f (x j+1 • step e)| + simp only [one_nsmul,signedCoordinate_add,add_sub_add_right_eq_sub] + exact hx i j hij + have hb := hm {y | TupleSeparated f G y} + rw [Measure.smul_apply,smul_eq_mul,he] at hb + simpa only [μ,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] using hb + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/Sampling.lean b/lean/OAI/Probability/Ballisticity/Estimates/Sampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba513598678411cb31dfbc8049eb6c8a1624f44c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/Sampling.lean @@ -0,0 +1,174 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayMap +import OAI.Probability.Ballisticity.Estimates.AnchorMoments + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped ENNReal NNReal BigOperators Classical Topology +namespace DirectionalTransience + +noncomputable def finiteOffsetTest {H : Type*} (z : H) (o : OnePoint H) : ℝ := + if o=(z:OnePoint H) then 1 else 0 + +lemma finiteOffsetTest_continuous {H : Type*} [TopologicalSpace H] [DiscreteTopology H] + (z : H) : Continuous (finiteOffsetTest z) := by + have ho : IsOpen ({(z:OnePoint H)} : Set (OnePoint H)) := by + simpa only [Set.image_singleton] using OnePoint.isOpenMap_coe {z} (isOpen_discrete _) + have hc : IsClosed ({(z:OnePoint H)} : Set (OnePoint H)) := isClosed_singleton + apply continuous_iff_continuousAt.mpr + intro o + by_cases h : o=(z:OnePoint H) + · apply (continuousAt_const (y:=(1:ℝ))).congr_of_eventuallyEq + filter_upwards [ho.mem_nhds h] with x hx + simp [finiteOffsetTest,Set.mem_singleton_iff.mp hx] + · apply (continuousAt_const (y:=(0:ℝ))).congr_of_eventuallyEq + filter_upwards [hc.isOpen_compl.mem_nhds h] with x hx + have hx' : x≠(z:OnePoint H) := hx + simp [finiteOffsetTest,hx'] + +noncomputable def arrayOffsetTest {d : ℕ} (e : Direction d) + (p q : ℤ×ℕ) (z : HorizontalSpace e) : C(ActualEpisodeArray e,ℝ) := + ⟨fun X => finiteOffsetTest z (X.2.1 (p,q)), + (finiteOffsetTest_continuous z).comp ((continuous_apply _).comp (continuous_fst.comp continuous_snd))⟩ + +noncomputable def arrayProfileTest {d : ℕ} (e : Direction d) + (j : ℤ) (p : ℤ×ℕ) (z : HorizontalSpace e) : C(ActualEpisodeArray e,ℝ) := + ⟨fun X => (X.2.2.1 (j,p,z)).val,by fun_prop⟩ + +noncomputable def arraySamplingError {d : ℕ} (e : Direction d) + (p : ℤ×ℕ) (j : ℤ) (z : HorizontalSpace e) (n : ℕ) : C(ActualEpisodeArray e,ℝ) := + ⟨fun X => (n:ℝ)⁻¹*(∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z X)-arrayProfileTest e j p z X, + by fun_prop⟩ + +lemma arrayOffsetTest_mem {d : ℕ} (e : Direction d) (p q : ℤ×ℕ) (z : HorizontalSpace e) + (X : ActualEpisodeArray e) : arrayOffsetTest e p q z X∈Set.Icc (0:ℝ) 1 := by + change (if _ then (1:ℝ) else 0)∈Set.Icc (0:ℝ) 1 + split_ifs <;> norm_num + +lemma arrayProfileTest_mem {d : ℕ} (e : Direction d) (j : ℤ) (p : ℤ×ℕ) (z : HorizontalSpace e) + (X : ActualEpisodeArray e) : arrayProfileTest e j p z X∈Set.Icc (0:ℝ) 1 := (X.2.2.1 (j,p,z)).property + +lemma arraySamplingError_bound {d : ℕ} (e : Direction d) (p : ℤ×ℕ) (j : ℤ) + (z : HorizontalSpace e) (n : ℕ) (X : ActualEpisodeArray e) : ‖arraySamplingError e p j z n X‖≤1 := by + have hsum0 : 0≤∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z X := + Finset.sum_nonneg (fun b _ => (arrayOffsetTest_mem e p (j,b) z X).1) + have hsum1 : (∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z X)≤(n:ℝ) := by + calc _ ≤ ∑ _b∈Finset.range n, (1:ℝ) := + Finset.sum_le_sum fun b _ => (arrayOffsetTest_mem e p (j,b) z X).2 + _ = _ := by simp + have ha0 : 0≤(n:ℝ)⁻¹*∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z X := + mul_nonneg (inv_nonneg.mpr (Nat.cast_nonneg n)) hsum0 + have ha1 : (n:ℝ)⁻¹*∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z X≤1 := by + apply (mul_le_mul_of_nonneg_left hsum1 (inv_nonneg.mpr (Nat.cast_nonneg n))).trans + by_cases hn : n=0 + · simp [hn] + · rw [inv_mul_cancel₀ (Nat.cast_ne_zero.mpr hn)] + have hw := arrayProfileTest_mem e j p z X + change |(n:ℝ)⁻¹*(∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z X)-arrayProfileTest e j p z X|≤1 + rw [abs_le] + constructor <;> linarith [hw.1,hw.2] + +lemma actual_array_error_atom {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (X : EpisodeInput e) (p : ℤ×ℕ) (j : ℤ) + (z : HorizontalSpace e) (n : ℕ) (hn : 0 u+z) (X.1.2 p) (X.1.2 (j,b)) := by + have he b : arrayOffsetTest e p (j,b) z (actualArrayMap e t J X) = + (if X.1.2 (j,b)=X.1.2 p+z then (1:ℝ) else 0) := by + simp only [arrayOffsetTest,ContinuousMap.coe_mk,actualArrayMap,finiteOffsetTest,OnePoint.coe_injective.eq_iff] + congr 1 + apply propext + constructor + · intro h + exact (sub_eq_iff_eq_add.mp h).trans (add_comm _ _) + · intro h + exact sub_eq_iff_eq_add.mpr (h.trans (add_comm _ _)) + have hw : arrayProfileTest e j p z (actualArrayMap e t J X)= + (episodeProfile e t X.1.1 j).real {X.1.2 p+z} := rfl + change (n:ℝ)⁻¹*(∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z (actualArrayMap e t J X))- + arrayProfileTest e j p z (actualArrayMap e t J X)=_ + simp_rw [he,hw,AnchorSampling.atomError,Finset.sum_sub_distrib] + simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul] + rw [mul_sub,←mul_assoc,inv_mul_cancel₀ (Nat.cast_ne_zero.mpr hn.ne'),one_mul] + congr 2 + apply Finset.sum_congr rfl + intro b hb + split_ifs <;> rfl + +lemma actual_array_sampling_sq_conditional {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (ω : Environment d) (ξ : EpisodeAuxiliary e) (p : ℤ×ℕ) (j : ℤ) + (z : HorizontalSpace e) (n : ℕ) (hn : 0 (j,b),fun a b h => (Prod.mk.inj h).2⟩ + let S := (Finset.range n).map f + have hcard : S.card=n := by simp [S] + have hh := AnchorSampling.infinitePi_sample_average_sq + (fun q : ℤ×ℕ => episodeProfile e t ω q.1) (episodeProfile e t ω j) p S + (fun b hb => by obtain ⟨a,ha,rfl⟩ := Finset.mem_map.mp hb; rfl) (fun u => u+z) + simp only [hcard] at hh + simp only [globalEpisodeAnchors,AnchorSampling.anchorKernel,Kernel.coe_mk] + convert hh using 1 + apply integral_congr_ae + filter_upwards [] with U + rw [actual_array_error_atom e t J _ p j z n hn] + simp only [S,Finset.sum_map,f] + rfl + +lemma actual_array_offset {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (X : EpisodeInput e) (p q : ℤ×ℕ) + (z : HorizontalSpace e) : + arrayOffsetTest e p q z (actualArrayMap e t J X) = + (if X.1.2 q=X.1.2 p+z then (1:ℝ) else 0) := by + simp only [arrayOffsetTest,ContinuousMap.coe_mk,actualArrayMap,finiteOffsetTest, + OnePoint.coe_injective.eq_iff] + congr 1 + apply propext + constructor + · intro h + exact (sub_eq_iff_eq_add.mp h).trans (add_comm _ _) + · intro h + exact sub_eq_iff_eq_add.mpr (h.trans (add_comm _ _)) + +lemma actual_array_profile {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (X : EpisodeInput e) (p : ℤ×ℕ) (j : ℤ) + (z : HorizontalSpace e) : + arrayProfileTest e j p z (actualArrayMap e t J X)= + (episodeProfile e t X.1.1 j).real {X.1.2 p+z} := rfl + +lemma actual_array_sampling_test_conditional {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (ω : Environment d) (ξ : EpisodeAuxiliary e) (p q : ℤ×ℕ) (hpq : p≠q) + (z : HorizontalSpace e) (g : C(ℝ,ℝ)) : + (∫ U, g (arrayProfileTest e q.1 p z (actualArrayMap e t J ((ω,U),ξ)))* + (arrayOffsetTest e p q z (actualArrayMap e t J ((ω,U),ξ))- + arrayProfileTest e q.1 p z (actualArrayMap e t J ((ω,U),ξ))) + ∂globalEpisodeAnchors e t ht ω)=0 := by + obtain ⟨C,hC⟩ := isCompact_Icc.exists_bound_of_continuousOn + (f:=fun x : ℝ => g x) g.continuous.continuousOn + have hG (u : HorizontalSpace e) : + ‖g ((episodeProfile e t ω q.1).real {u+z})‖≤C := by + apply hC + exact ⟨measureReal_nonneg,measureReal_le_one⟩ + have hh := AnchorSampling.infinitePi_sampling_test + (fun q : ℤ×ℕ => episodeProfile e t ω q.1) p q hpq (fun u => u+z) + (fun u => g ((episodeProfile e t ω q.1).real {u+z})) C hG + simp only [globalEpisodeAnchors,AnchorSampling.anchorKernel,Kernel.coe_mk] + convert hh using 1 + apply integral_congr_ae + filter_upwards [] with U + rw [actual_array_offset,actual_array_profile] + unfold AnchorSampling.atomError + congr 2 + split_ifs <;> rfl + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SamplingLaw.lean b/lean/OAI/Probability/Ballisticity/Estimates/SamplingLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba922343dc66e49df17ee31c13c2c5cce3abeb59 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SamplingLaw.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.Sampling + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience + +instance actualArray_borel {d : ℕ} (e : Direction d) : BorelSpace (ActualEpisodeArray e) := by + have : BorelSpace (ℤ → StationaryCompact.MarkSpace) := inferInstance + have : BorelSpace ((StationaryCompact.Label×StationaryCompact.Label) → OnePoint (HorizontalSpace e)) := inferInstance + have : BorelSpace ((ℤ×StationaryCompact.Label×HorizontalSpace e) → Set.Icc (0:ℝ) 1) := inferInstance + have : BorelSpace ((ℤ×ℕ×ℕ×ℕ×HorizontalSpace e) → Row d) := inferInstance + have : BorelSpace (((ℤ×StationaryCompact.Label×HorizontalSpace e) → Set.Icc (0:ℝ) 1) × + ((ℤ×ℕ×ℕ×ℕ×HorizontalSpace e) → Row d)) := inferInstance + have : SecondCountableTopology (((StationaryCompact.Label×StationaryCompact.Label) → OnePoint (HorizontalSpace e))) := inferInstance + have : BorelSpace ((((StationaryCompact.Label×StationaryCompact.Label) → OnePoint (HorizontalSpace e))) × + (((ℤ×StationaryCompact.Label×HorizontalSpace e) → Set.Icc (0:ℝ) 1) × + ((ℤ×ℕ×ℕ×ℕ×HorizontalSpace e) → Row d))) := inferInstance + have : SecondCountableTopology (ℤ → StationaryCompact.MarkSpace) := inferInstance + unfold ActualEpisodeArray StationaryCompact.EpisodeArray + infer_instance + +lemma restrict_compProd_fst {Ω A : Type*} [MeasurableSpace Ω] [MeasurableSpace A] + (Q : Measure Ω) [SFinite Q] (K : Kernel Ω A) [IsSFiniteKernel K] + (s : Set Ω) (hs : MeasurableSet s) : + (Q.compProd K).restrict (Prod.fst ⁻¹' s)=(Q.restrict s).compProd K := by + ext B hB + rw [Measure.restrict_apply hB,Measure.compProd_apply (hB.inter (hs.preimage measurable_fst)), + Measure.compProd_apply hB,←lintegral_indicator hs] + apply lintegral_congr + intro ω + by_cases hω : ω∈s + · have he : Prod.mk ω ⁻¹' Prod.fst ⁻¹' s = (Set.univ : Set A) := by + ext a + simp [hω] + simp [Set.indicator_of_mem hω,he] + · have he : Prod.mk ω ⁻¹' Prod.fst ⁻¹' s = (∅ : Set A) := by + ext a + simp [hω] + simp [Set.indicator_of_notMem hω,he] + +instance episodeInputLaw_finite {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) : + IsFiniteMeasure (episodeInputLaw e ν Q t ht) := by unfold episodeInputLaw; infer_instance + +lemma episodeInputLaw_restrict {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (s : Set (Environment d)) (hs : MeasurableSet s) : + (episodeInputLaw e ν Q t ht).restrict {X | X.1.1∈s}= + episodeInputLaw e ν (Q.restrict s) t ht := by + unfold episodeInputLaw + rw [←restrict_compProd_fst Q (globalEpisodeAnchors e t ht) s hs, + Measure.restrict_prod_eq_prod_univ] + congr 1 + ext X + simp + +lemma actualArray_integrable {d : ℕ} (e : Direction d) + (μ : Measure (EpisodeInput e)) [IsFiniteMeasure μ] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (F : C(ActualEpisodeArray e,ℝ)) : Integrable (fun X => F (actualArrayMap e t J X)) μ := by + obtain ⟨C,hC⟩ := isCompact_univ.exists_bound_of_continuousOn F.continuous.continuousOn + apply (integrable_const C).mono' + ((F.continuous.measurable.comp (actualArrayMap_measurable e t J ht hJ)).aestronglyMeasurable) + exact Eventually.of_forall fun X => hC _ (Set.mem_univ _) + +lemma actual_array_sampling_sq_law {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (p : ℤ×ℕ) (j : ℤ) (z : HorizontalSpace e) (n : ℕ) (hn : 0 (arraySamplingError e p j z n Y)^2,by fun_prop⟩ + have hi := actualArray_integrable e (episodeInputLaw e ν Q t ht) t J ht hJ F + change (∫ X, F (actualArrayMap e t J X) ∂((Q.compProd (globalEpisodeAnchors e t ht)).prod + (episodeAuxiliaryLaw e ν)))≤_ + rw [integral_prod_symm _ hi] + have hc (ξ : EpisodeAuxiliary e) : + (∫ w, F (actualArrayMap e t J (w,ξ)) ∂Q.compProd (globalEpisodeAnchors e t ht))≤ + Q.real Set.univ*(n:ℝ)⁻¹ := by + have hm : Measurable (fun w => F (actualArrayMap e t J (w,ξ))) := + (F.continuous.measurable.comp (actualArrayMap_measurable e t J ht hJ)).comp measurable_prodMk_right + have hib : Integrable (fun w => F (actualArrayMap e t J (w,ξ))) + (Q.compProd (globalEpisodeAnchors e t ht)) := by + apply (integrable_const (1:ℝ)).mono' hm.aestronglyMeasurable + filter_upwards [] with w + change ‖(arraySamplingError e p j z n (actualArrayMap e t J (w,ξ)))^2‖≤1 + rw [norm_pow] + exact (pow_le_pow_left₀ (norm_nonneg _) (arraySamplingError_bound _ _ _ _ _ _) 2).trans_eq (one_pow _) + rw [Measure.integral_compProd hib] + have hbound ω := actual_array_sampling_sq_conditional e t J ht ω ξ p j z n hn + calc + _ ≤ (∫ _ω, (n:ℝ)⁻¹ ∂Q) := by + apply integral_mono_of_nonneg (Eventually.of_forall fun ω => integral_nonneg fun U => sq_nonneg _) + (integrable_const _) + exact Eventually.of_forall hbound + _ = _ := by simp [integral_const,smul_eq_mul] + have hnon : 0≤Q.real Set.univ*(n:ℝ)⁻¹ := mul_nonneg measureReal_nonneg (inv_nonneg.mpr (Nat.cast_nonneg _)) + calc + _ ≤ (∫ _ξ, Q.real Set.univ*(n:ℝ)⁻¹ ∂episodeAuxiliaryLaw e ν) := by + apply integral_mono_of_nonneg (Eventually.of_forall fun ξ => integral_nonneg fun w => sq_nonneg _) + (integrable_const _) + exact Eventually.of_forall hc + _ = _ := by simp [integral_const,smul_eq_mul] + +lemma actual_array_sampling_test_law {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (p q : ℤ×ℕ) (hpq : p≠q) (z : HorizontalSpace e) (g : C(ℝ,ℝ)) : + (∫ X, g (arrayProfileTest e q.1 p z (actualArrayMap e t J X))* + (arrayOffsetTest e p q z (actualArrayMap e t J X)- + arrayProfileTest e q.1 p z (actualArrayMap e t J X)) + ∂episodeInputLaw e ν Q t ht)=0 := by + let F : C(ActualEpisodeArray e,ℝ) := ⟨fun Y => g (arrayProfileTest e q.1 p z Y)* + (arrayOffsetTest e p q z Y-arrayProfileTest e q.1 p z Y),by fun_prop⟩ + have hi := actualArray_integrable e (episodeInputLaw e ν Q t ht) t J ht hJ F + change (∫ X, F (actualArrayMap e t J X) ∂((Q.compProd (globalEpisodeAnchors e t ht)).prod + (episodeAuxiliaryLaw e ν)))=0 + rw [integral_prod_symm _ hi] + have hz (ξ : EpisodeAuxiliary e) : + (∫ w, F (actualArrayMap e t J (w,ξ)) ∂Q.compProd (globalEpisodeAnchors e t ht))=0 := by + obtain ⟨C,hC⟩ := isCompact_univ.exists_bound_of_continuousOn F.continuous.continuousOn + have hm : Measurable (fun w => F (actualArrayMap e t J (w,ξ))) := + (F.continuous.measurable.comp (actualArrayMap_measurable e t J ht hJ)).comp measurable_prodMk_right + have hib := (integrable_const C (μ:=Q.compProd (globalEpisodeAnchors e t ht))).mono' hm.aestronglyMeasurable + (Eventually.of_forall fun w => hC _ (Set.mem_univ _)) + rw [Measure.integral_compProd hib] + have he ω : (∫ U, F (actualArrayMap e t J ((ω,U),ξ)) ∂globalEpisodeAnchors e t ht ω)=0 := + actual_array_sampling_test_conditional e t J ht ω ξ p q hpq z g + simp only [he,integral_zero] + simp only [hz,integral_zero] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience + +lemma arrayOffsetTest_shift {d : ℕ} (e : Direction d) (p q : ℤ×ℕ) + (z : HorizontalSpace e) (Y : ActualEpisodeArray e) : + arrayOffsetTest e p q z (StationaryCompact.shift Y)= + arrayOffsetTest e (p.1+1,p.2) (q.1+1,q.2) z Y := rfl + +lemma arrayProfileTest_shift {d : ℕ} (e : Direction d) (j : ℤ) (p : ℤ×ℕ) + (z : HorizontalSpace e) (Y : ActualEpisodeArray e) : + arrayProfileTest e j p z (StationaryCompact.shift Y)= + arrayProfileTest e (j+1) (p.1+1,p.2) z Y := rfl + +lemma arrayOffsetTest_iterate {d : ℕ} (e : Direction d) (p q : ℤ×ℕ) + (z : HorizontalSpace e) (Y : ActualEpisodeArray e) (r : ℕ) : + arrayOffsetTest e p q z (StationaryCompact.shift^[r] Y)= + arrayOffsetTest e (p.1+r,p.2) (q.1+r,q.2) z Y := by + induction r generalizing p q with + | zero => simp + | succ r ih => + rw [Function.iterate_succ_apply',arrayOffsetTest_shift,ih] + simp only [Nat.cast_add,Nat.cast_one,add_left_comm,add_comm] + +lemma arrayProfileTest_iterate {d : ℕ} (e : Direction d) (j : ℤ) (p : ℤ×ℕ) + (z : HorizontalSpace e) (Y : ActualEpisodeArray e) (r : ℕ) : + arrayProfileTest e j p z (StationaryCompact.shift^[r] Y)= + arrayProfileTest e (j+r) (p.1+r,p.2) z Y := by + induction r generalizing j p with + | zero => simp + | succ r ih => + rw [Function.iterate_succ_apply',arrayProfileTest_shift,ih] + simp only [Nat.cast_add,Nat.cast_one,add_left_comm,add_comm] + +lemma arraySamplingError_iterate {d : ℕ} (e : Direction d) (p : ℤ×ℕ) (j : ℤ) + (z : HorizontalSpace e) (n r : ℕ) (Y : ActualEpisodeArray e) : + arraySamplingError e p j z n (StationaryCompact.shift^[r] Y)= + arraySamplingError e (p.1+r,p.2) (j+r) z n Y := by + change (n:ℝ)⁻¹*(∑ b∈Finset.range n, arrayOffsetTest e p (j,b) z (StationaryCompact.shift^[r] Y))- + arrayProfileTest e j p z (StationaryCompact.shift^[r] Y)=_ + simp only [arrayOffsetTest_iterate,arrayProfileTest_iterate] + rfl + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SamplingLimit.lean b/lean/OAI/Probability/Ballisticity/Estimates/SamplingLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..44d01cd8221172d2b82a53bf1307ddf0c264d998 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SamplingLimit.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal Topology +namespace DirectionalTransience.Sampling + +variable {X : Type*} [MeasurableSpace X] + +theorem ae_tendsto_zero_of_sq_integrals {μ : Measure X} (f : ℕ → X → ℝ) + (hf : ∀ n, AEStronglyMeasurable (f n) μ) + (b : ℕ → ℝ) (hb : Summable b) + (hbound : ∀ n, ∫⁻ x, ENNReal.ofReal ((f n x)^2) ∂μ ≤ ENNReal.ofReal (b n)) : + ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 0) := by + have hm (n) : AEMeasurable (fun x => ENNReal.ofReal ((f n x)^2)) μ := + ENNReal.measurable_ofReal.comp_aemeasurable ((hf n).aemeasurable.pow_const 2) + have hfin : (∫⁻ x, ∑' n, ENNReal.ofReal ((f n x)^2) ∂μ) < ∞ := by + rw [lintegral_tsum hm] + exact (ENNReal.tsum_le_tsum hbound).trans_lt hb.tsum_ofReal_lt_top + filter_upwards [ae_lt_top' (AEMeasurable.tsum hm) hfin.ne] with x hx + have hs := ENNReal.summable_toReal hx.ne + have he : (fun n => (ENNReal.ofReal ((f n x)^2)).toReal) = (fun n => (f n x)^2) := by + funext n + exact ENNReal.toReal_ofReal (sq_nonneg _) + rw [he] at hs + have ht := Real.continuous_sqrt.continuousAt.tendsto.comp hs.tendsto_atTop_zero + simp only [Function.comp_def, Real.sqrt_sq_eq_abs, Real.sqrt_zero] at ht + exact tendsto_zero_iff_norm_tendsto_zero.mpr (by simpa only [Real.norm_eq_abs] using ht) + +section Compact +variable [TopologicalSpace X] [CompactSpace X] [BorelSpace X] + +lemma sq_integral_bound_of_weak_limit (μs : ℕ → ProbabilityMeasure X) + (μ : ProbabilityMeasure X) (hμ : Tendsto μs atTop (𝓝 μ)) + (f : C(X,ℝ)) {b : ℝ} + (hb : ∀ k, ∫ x, (f x)^2 ∂(μs k : Measure X) ≤ b) : + ∫ x, (f x)^2 ∂μ ≤ b := by + let g : C(X,ℝ) := ⟨fun x => (f x)^2, f.continuous.pow 2⟩ + have ht := (ProbabilityMeasure.continuous_integral_continuousMap g).continuousAt.tendsto.comp hμ + exact le_of_tendsto ht (Eventually.of_forall hb) + +theorem ae_sampling_of_weak_limit (μs : ℕ → ProbabilityMeasure X) + (μ : ProbabilityMeasure X) (hμ : Tendsto μs atTop (𝓝 μ)) + (e : ℕ → C(X,ℝ)) (b : ℕ → ℝ) (hb : Summable b) + (he : ∀ k n, ∫ x, (e n x)^2 ∂(μs k : Measure X) ≤ b n) : + ∀ᵐ x ∂(μ : Measure X), Tendsto (fun n => e n x) atTop (𝓝 0) := by + apply ae_tendsto_zero_of_sq_integrals (fun n => e n) (fun n => (e n).continuous.aestronglyMeasurable) b hb + intro n + have hi : Integrable (fun x => (e n x)^2) (μ : Measure X) := + ((e n).continuous.pow 2).integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + rw [← ofReal_integral_eq_lintegral_ofReal hi (Eventually.of_forall (fun x => sq_nonneg _))] + exact ENNReal.ofReal_le_ofReal (sq_integral_bound_of_weak_limit μs μ hμ (e n) (fun k => he k n)) + +end Compact +end DirectionalTransience.Sampling + +end + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal Topology +namespace DirectionalTransience.Sampling + +variable {X : Type*} [MeasurableSpace X] + +lemma cutoff_tendsto (w : ℝ) (hw : 0 ≤ w) : + Tendsto (fun n : ℕ => max 0 (1-(n:ℝ)*w)) atTop (𝓝 (if w=0 then 1 else 0)) := by + by_cases h : w=0 + · simp [h] + · rw [ite_eq_right h] + have hp : 0 < w := lt_of_le_of_ne hw (Ne.symm h) + obtain ⟨N,hN⟩ := exists_nat_gt (1/w) + apply tendsto_const_nhds.congr' + filter_upwards [eventually_ge_atTop N] with n hn + have hn' : (N:ℝ) ≤ n := Nat.cast_le.mpr hn + have hnw : 1 < (n:ℝ)*w := (div_lt_iff₀ hp).mp (hN.trans_le hn') + exact (max_eq_left (by linarith)).symm + +theorem ae_zero_of_sampling_tests {μ : Measure X} [IsFiniteMeasure μ] + (w I : X → ℝ) (hw : Measurable w) (hI : Measurable I) + (hw01 : ∀ x, w x ∈ Set.Icc (0:ℝ) 1) + (hI01 : ∀ x, I x ∈ Set.Icc (0:ℝ) 1) + (htest : ∀ g : C(ℝ,ℝ), (∫ x, g (w x)*(I x-w x) ∂μ)=0) : + ∀ᵐ x ∂μ, w x=0 → I x=0 := by + classical + let F : ℕ → X → ℝ := fun n x => max 0 (1-(n:ℝ)*w x)*(I x-w x) + let G : X → ℝ := fun x => if w x=0 then I x else 0 + have hFm (n : ℕ) : Measurable (F n) := by dsimp [F]; fun_prop + have hGm : Measurable G := by + dsimp [G] + exact Measurable.ite (hw (measurableSet_singleton 0)) hI measurable_const + have hgb x : 0 ≤ G x ∧ G x ≤ 1 := by + dsimp [G] + split_ifs + · exact hI01 x + · norm_num + have hFb (n : ℕ) (x : X) : ‖F n x‖ ≤ 1 := by + have hc0 : 0 ≤ max 0 (1-(n:ℝ)*w x) := le_max_left _ _ + have hc1 : max 0 (1-(n:ℝ)*w x) ≤ 1 := by + apply max_le (by norm_num) + have hh := mul_nonneg (Nat.cast_nonneg n) (hw01 x).1 + linarith + have hsub : |I x-w x| ≤ 1 := by + rw [abs_le] + constructor <;> linarith [(hI01 x).1,(hI01 x).2,(hw01 x).1,(hw01 x).2] + dsimp [F] + rw [abs_mul, abs_of_nonneg hc0] + exact (mul_le_mul_of_nonneg_left hsub hc0).trans (by simpa using hc1) + have hFlim (x : X) : Tendsto (fun n => F n x) atTop (𝓝 (G x)) := by + have hh := (cutoff_tendsto (w x) (hw01 x).1).mul_const (I x-w x) + convert hh using 1 + dsimp [G] + split_ifs with h <;> simp [h] + have hi := tendsto_integral_of_dominated_convergence (μ := μ) (fun _ : X => (1:ℝ)) + (fun n => (hFm n).aestronglyMeasurable) (integrable_const 1) + (fun n => Eventually.of_forall (hFb n)) (Eventually.of_forall hFlim) + have hFzero (n : ℕ) : (∫ x, F n x ∂μ)=0 := by + exact htest ⟨fun t => max 0 (1-(n:ℝ)*t),by fun_prop⟩ + simp only [hFzero] at hi + have hGzero : (∫ x, G x ∂μ)=0 := tendsto_nhds_unique hi tendsto_const_nhds + have hGi : Integrable G μ := (integrable_const (1:ℝ)).mono' hGm.aestronglyMeasurable + (Eventually.of_forall fun x => by rw [Real.norm_eq_abs, abs_of_nonneg (hgb x).1]; exact (hgb x).2) + have hz := (integral_eq_zero_iff_of_nonneg (fun x => (hgb x).1) hGi).mp hGzero + filter_upwards [hz] with x hx h + simpa [G,h] using hx + +section Compact +variable [TopologicalSpace X] [CompactSpace X] [BorelSpace X] + +theorem sampling_tests_weak_limit (μs : ℕ → ProbabilityMeasure X) + (μ : ProbabilityMeasure X) (hμ : Tendsto μs atTop (𝓝 μ)) + (w I : C(X,ℝ)) + (htest : ∀ k (g : C(ℝ,ℝ)), + (∫ x, g (w x)*(I x-w x) ∂(μs k : Measure X))=0) : + ∀ g : C(ℝ,ℝ), (∫ x, g (w x)*(I x-w x) ∂(μ : Measure X))=0 := by + intro g + let F : C(X,ℝ) := ⟨fun x => g (w x)*(I x-w x),by fun_prop⟩ + have ht := (ProbabilityMeasure.continuous_integral_continuousMap F).continuousAt.tendsto.comp hμ + have he (k) : (∫ x, F x ∂(μs k : Measure X))=0 := htest k g + change Tendsto (fun k => ∫ x, F x ∂(μs k : Measure X)) atTop _ at ht + simp only [he] at ht + exact tendsto_nhds_unique ht tendsto_const_nhds + +end Compact +end DirectionalTransience.Sampling + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SamplingRearrangement.lean b/lean/OAI/Probability/Ballisticity/Estimates/SamplingRearrangement.lean new file mode 100644 index 0000000000000000000000000000000000000000..c406534377312ca53b05ef98db8c802652a981f5 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SamplingRearrangement.lean @@ -0,0 +1,62 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal +namespace DirectionalTransience.StoppedWindow + +variable {X A B V F : Type*} [MeasurableSpace X] [MeasurableSpace A] + [MeasurableSpace B] [MeasurableSpace V] [MeasurableSpace F] + +theorem sample_lower_map (μ : Measure X) [IsFiniteMeasure μ] + (π : Measure V) [IsProbabilityMeasure π] + (g : X → A) (hg : Measurable g) + (f : X × V → F) (hf : Measurable f) + (K : Kernel A B) [IsMarkovKernel K] : + (((μ.compProd (K.comap g hg)).prod π).map + (fun p : (X × B) × V => ((g p.1.1,p.1.2),f (p.1.1,p.2)))) = + (((Kernel.id.prod K) ∥ₖ Kernel.id) ∘ₘ + ((μ.prod π).map (fun p => (g p.1,f p)))) := by + have hw : Measurable (fun p : (X × B) × V => ((g p.1.1,p.1.2),f (p.1.1,p.2))) := + ((hg.comp (measurable_fst.comp measurable_fst)).prodMk + (measurable_snd.comp measurable_fst)).prodMk + (hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)) + have hz : Measurable (fun p : X × V => (g p.1,f p)) := (hg.comp measurable_fst).prodMk hf + apply Measure.ext_of_lintegral + intro h hh + have hhw : Measurable (fun p : (X × B) × V => h ((g p.1.1,p.1.2),f (p.1.1,p.2))) := hh.comp hw + have hk : Measurable (fun z : A × F => ∫⁻ y, h y ∂((Kernel.id.prod K) ∥ₖ Kernel.id) z) := + hh.lintegral_kernel + have hkm : Measurable (fun p : X × V => ∫⁻ y, h y ∂((Kernel.id.prod K) ∥ₖ Kernel.id) (g p.1,f p)) := + hk.comp hz + rw [lintegral_map hh hw, lintegral_prod _ hhw.aemeasurable, + Measure.lintegral_compProd hhw.lintegral_prod_right', + Measure.lintegral_bind (Kernel.aemeasurable _) hh.aemeasurable, + lintegral_map hk hz, lintegral_prod _ hkm.aemeasurable] + apply lintegral_congr + intro x + simp only [Kernel.comap_apply] + have hrow : Measurable (fun p : B × V => h ((g x,p.1),f (x,p.2))) := + hh.comp ((measurable_const.prodMk measurable_fst).prodMk + (hf.comp (measurable_const.prodMk measurable_snd))) + rw [← lintegral_prod _ hrow.aemeasurable, lintegral_prod_symm _ hrow.aemeasurable] + apply lintegral_congr + intro v + rw [Kernel.lintegral_parallelComp _ hh] + simp_rw [Kernel.id_apply] + have hi (p : A × B) : (∫⁻ z : F, h (p,z) ∂Measure.dirac (f (x,v))) = h (p,f (x,v)) := + lintegral_dirac' _ (hh.comp measurable_prodMk_left) + simp_rw [hi] + have hs : Measurable (fun p : A × B => h (p,f (x,v))) := hh.comp measurable_prodMk_right + simpa only [id_eq, Kernel.id] using + (Kernel.lintegral_deterministic_prod (f:=id) measurable_id K (g x) hs).symm + +end DirectionalTransience.StoppedWindow + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ScaledMaxMoment.lean b/lean/OAI/Probability/Ballisticity/Estimates/ScaledMaxMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..c61749f06d913355322d8bcdd0cb82ec8bb0c761 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ScaledMaxMoment.lean @@ -0,0 +1,155 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.FullCapTransfer + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma sq_min_nonneg {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) : + (min a b)^2 = min (a^2) (b^2) := by + rcases le_total a b with h | h + · rw [min_eq_left h,min_eq_left (pow_le_pow_left₀ ha h 2)] + · rw [min_eq_right h,min_eq_right (pow_le_pow_left₀ hb h 2)] + +lemma cappedMoment_scaled_eq {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : Ω → ℝ) (hX : ∀ x, 0 ≤ X x) + {r b : ℝ} (hr : 0 < r) (hb : 0 ≤ b) : + cappedMoment μ (fun x => X x/r) b = truncatedVariance μ X (b*r)/r^2 := by + unfold cappedMoment truncatedVariance + rw [← integral_div] + congr 1 + funext x + nth_rw 1 [show b = (b*r)/r from (mul_div_cancel_right₀ b (ne_of_gt hr)).symm] + rw [min_div_div_right hr.le,div_pow,sq_min_nonneg (hX x) (mul_nonneg hb hr.le)] + +lemma iid_scaled_max_moment_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {r b : ℝ} (hr : 0 < r) (hb : 0 ≤ b) (n : ℕ) : + cappedMoment μ (fun ω => partialSumMax (fun k => X k ω) n/r) b ≤ + 5*(n:ℝ)*truncatedVariance μ (X 0) (b*r)/r^2 := by + rw [cappedMoment_scaled_eq μ _ (fun ω => partialSumMax_nonneg _ _) hr hb] + exact div_le_div_of_nonneg_right + (integral_partialSumMax_capped_le μ X hX hind hident hsym (mul_nonneg hb hr.le) n) (sq_nonneg r) + +lemma scaled_max_moment_ratio_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hne : 0 < μ {ω | X 0 ω ≠ 0}) + {r b t : ℝ} (hr : 0 < r) (hb : 0 ≤ b) (n : ℕ) + (hn : (n:ℝ) ≤ t*fluctuationScale μ (X 0) r) : + cappedMoment μ (fun ω => partialSumMax (fun k => X k ω) n/r) b ≤ + 5*t*(truncatedVariance μ (X 0) (b*r)/truncatedVariance μ (X 0) r) := by + have hm : 0 < truncatedVariance μ (X 0) r := truncatedVariance_pos μ (X 0) (hX 0) hne hr + have hm0 := truncatedVariance_nonneg μ (X 0) (b*r) + have hmul : (n:ℝ)*truncatedVariance μ (X 0) r ≤ t*r^2 := by + rw [fluctuationScale,← mul_div_assoc] at hn + exact (le_div_iff₀ hm).mp hn + apply (iid_scaled_max_moment_le μ X hX hind hident hsym hr hb n).trans + rw [div_le_iff₀ (sq_pos_of_pos hr)] + have heq : (5*t*(truncatedVariance μ (X 0) (b*r)/truncatedVariance μ (X 0) r))*r^2 = + (5*truncatedVariance μ (X 0) (b*r))*(t*r^2)/truncatedVariance μ (X 0) r := by ring + rw [heq,le_div_iff₀ hm] + nlinarith [mul_le_mul_of_nonneg_left hmul (mul_nonneg (by norm_num : (0:ℝ) ≤ 5) hm0)] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma successful_small_variance_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : ∀ n, 0 < r n) (hrinf : Tendsto r atTop atTop) + (H : ℕ → ℕ) (hH : Tendsto H atTop atTop) {b t F : ℝ} (hb : 0 < b) + (hHt : ∀ᶠ n in atTop, (H n:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r n)) + (hF : Tendsto (fun n => truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (b*r n) / + truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r n)) atTop (𝓝 F)) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + limsup (fun n => cappedMoment (successfulAverage ν ℓ (H n)) + (fun X => medianDeviation ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) (H n) X/r n) b) atTop ≤ + (40000/p^2)*t*F := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + let μ := independentConditionedPairLaw ν ℓ + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + let X := commonIncrementProcess ℓ f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hM := successfulMedian_moment_transfer ν hue e f htrans H hH r hr hrinf + (A := b/2) (L := b) (by positivity) (by linarith) + have hlim : Tendsto (fun n => 5*t*(truncatedVariance μ (X 0) (b*r n)/truncatedVariance μ (X 0) (r n))) + atTop (𝓝 (5*t*F)) := tendsto_const_nhds.mul hF + have hbound : limsup (fun n => cappedMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/r n) b) atTop ≤ 5*t*F := by + rw [← hlim.limsup_eq] + have hev : ∀ᶠ n in atTop, cappedMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/r n) b ≤ + 5*t*(truncatedVariance μ (X 0) (b*r n)/truncatedVariance μ (X 0) (r n)) := by + filter_upwards [hHt] with n hn + exact scaled_max_moment_ratio_bound μ X (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) hne (hr n) hb.le (H n) hn + have h0 : ∀ n, (0:ℝ) ≤ cappedMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/r n) b := + fun n => integral_nonneg fun P => sq_nonneg _ + exact limsup_le_limsup hev (isCoboundedUnder_le_of_le atTop h0) hlim.isBoundedUnder_le + have hC : 0 ≤ 8000/p^2 := by positivity + calc + _ ≤ (8000/p^2)*limsup (fun n => cappedMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/r n) b) atTop := hM.1 + _ ≤ (8000/p^2)*(5*t*F) := mul_le_mul_of_nonneg_left hbound hC + _ = _ := by ring + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience +lemma exists_block_count {T t : ℝ} (hT : 0 < T) (ht : 0 < t) (ht1 : t ≤ 1) : + ∃ J : ℕ, T < (J:ℝ)*t ∧ (J:ℝ)*t ≤ 2*T+1 := by + refine ⟨⌈2*T/t⌉₊,?_,?_⟩ + · have hh := Nat.le_ceil (2*T/t) + have hh := mul_le_mul_of_nonneg_right hh ht.le + rw [div_mul_cancel₀ _ ht.ne'] at hh + linarith + · have hh := Nat.ceil_lt_add_one (by positivity : 0 ≤ 2*T/t) + have hh := mul_lt_mul_of_pos_right hh ht + rw [add_mul,div_mul_cancel₀ _ ht.ne',one_mul] at hh + linarith + +lemma eventually_ceil_horizon_covered (n : ℕ → ℝ) (hn : Tendsto n atTop atTop) + {T δ : ℝ} (hT : 0 < T) (hδ : 0 < δ) (M : ℕ) (hM : T < (M:ℝ)*δ) : + ∀ᶠ i in atTop, 0 < ⌊δ*n i⌋₊ ∧ 0 < ⌈T*n i⌉₊ ∧ ⌈T*n i⌉₊ ≤ M*⌊δ*n i⌋₊ := by + filter_upwards [eventually_floor_horizon_covered n hn hT.le hδ M hM, + hn.eventually (eventually_gt_atTop (0:ℝ))] with i hi hni + refine ⟨hi.1,?_,?_⟩ + · exact Nat.ceil_pos.mpr (mul_pos hT hni) + · exact (Nat.ceil_le_floor_add_one _).trans (by omega) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ScaledMaxTail.lean b/lean/OAI/Probability/Ballisticity/Estimates/ScaledMaxTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..76158ca277c6afa4455b619247d29883968686f0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ScaledMaxTail.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ScaledMaxMoment +import OAI.Probability.Ballisticity.Estimates.MaxTailDecomposition + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma cappedTailMoment_scaled_eq {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (X : Ω → ℝ) (hX : ∀ x, 0 ≤ X x) + {z A L : ℝ} (hz : 0 < z) (hL : 0 ≤ L) : + cappedTailMoment μ (fun x => X x/z) A L = + (∫ x, (if A*z < X x then min ((X x)^2) ((L*z)^2) else 0) ∂μ)/z^2 := by + unfold cappedTailMoment + rw [← integral_div] + congr 1 + funext x + simp only [lt_div_iff₀ hz] + split_ifs + · nth_rw 1 [show L = (L*z)/z from (mul_div_cancel_right₀ L (ne_of_gt hz)).symm] + rw [min_div_div_right hz.le,div_pow,sq_min_nonneg (hX x) (mul_nonneg hL hz.le)] + · simp + +lemma iid_scaled_max_tail_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hne : 0 < μ {ω | X 0 ω ≠ 0}) {z A L : ℝ} (hz : 0 < z) (hA : 0 < A) (hL : 1 ≤ L) + (n : ℕ) (hn : (n:ℝ) ≤ fluctuationScale μ (X 0) z) : + cappedTailMoment μ (fun ω => partialSumMax (fun k => X k ω) n/z) A L ≤ + 2048/A^2+16*((truncatedVariance μ (X 0) (L*z)-truncatedVariance μ (X 0) z)/ + truncatedVariance μ (X 0) z)+16*fluctuationScale μ (X 0) z*μ.real {ω | z < |X 0 ω|} := by + let m := truncatedVariance μ (X 0) z + let D := truncatedVariance μ (X 0) (L*z)-m + let p := μ.real {ω | z < |X 0 ω|} + have hm : 0 < m := truncatedVariance_pos μ (X 0) (hX 0) hne hz + have hD : 0 ≤ D := sub_nonneg.mpr (truncatedVariance_mono μ (X 0) (hX 0) hz.le (by nlinarith)) + have hp : 0 ≤ p := measureReal_nonneg + have hn0 : 0 ≤ (n:ℝ) := by positivity + have hnM : (n:ℝ)*m ≤ z^2 := (le_div_iff₀ hm).mp hn + have hnSq : (n:ℝ)^2*m^2 ≤ z^4 := by + have hh := pow_le_pow_left₀ (mul_nonneg hn0 hm.le) hnM 2 + nlinarith [hh] + have hfour : 32*(n:ℝ)*z^2*m+96*(n:ℝ)^2*m^2 ≤ 128*z^4 := by + nlinarith [mul_le_mul_of_nonneg_left hnM (sq_nonneg z)] + have hz2 := sq_pos_of_pos hz + have hA2 := sq_pos_of_pos hA + have hAz2 := sq_pos_of_pos (mul_pos hA hz) + have hfirst : ((16/(A*z)^2)*(32*(n:ℝ)*z^2*m+96*(n:ℝ)^2*m^2))/z^2 ≤ 2048/A^2 := by + calc + _ ≤ ((16/(A*z)^2)*(128*z^4))/z^2 := div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left hfour (by positivity)) hz2.le + _ = _ := by field_simp; ring + have hsecond : (16*(n:ℝ)*(D+z^2*p))/z^2 ≤ 16*(D/m)+16*(z^2/m)*p := by + rw [div_le_iff₀ hz2] + have hh := mul_le_mul_of_nonneg_right hnM (add_nonneg hD (mul_nonneg hz2.le hp)) + apply (mul_le_mul_iff_of_pos_right hm).mp + field_simp + nlinarith [hh] + rw [cappedTailMoment_scaled_eq μ _ (fun ω => partialSumMax_nonneg _ _) hz (by linarith)] + apply (div_le_div_of_nonneg_right (integral_iid_max_tail_le μ X hX hind hident hsym + hz.le (by nlinarith) (mul_pos hA hz) n) hz2.le).trans + rw [add_div] + simpa only [add_assoc,fluctuationScale,m,D,p] using add_le_add hfirst hsecond + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma iid_scaled_max_tail_variance_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hne : 0 < μ {ω | X 0 ω ≠ 0}) {z A L : ℝ} (hz : 0 < z) (hA : 0 < A) (hL : 1 ≤ L) + (n : ℕ) (hn : (n:ℝ) ≤ fluctuationScale μ (X 0) z) : + cappedTailMoment μ (fun ω => partialSumMax (fun k => X k ω) n/z) A L ≤ + 2048/A^2+16*((truncatedVariance μ (X 0) (L*z)-truncatedVariance μ (X 0) z)/ + truncatedVariance μ (X 0) z)+(64/3)*((truncatedVariance μ (X 0) z-truncatedVariance μ (X 0) (z/2))/ + truncatedVariance μ (X 0) z) := by + have hh := fluctuation_tail_difference μ (X 0) (hX 0) hne hz (show (0:ℝ)<1 by norm_num) + simp only [one_mul,one_pow,mul_one] at hh + have hb := iid_scaled_max_tail_le μ X hX hind hident hsym hne hz hA hL n hn + nlinarith [hh] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma successful_tail_profile_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (z : ℕ → ℝ) (hz : ∀ n, 0 < z n) (hzinf : Tendsto z atTop atTop) + (H : ℕ → ℕ) (hH : Tendsto H atTop atTop) {A L R G : ℝ} (hA : 0 < A) (hAL : A < L) (hL : 1 ≤ L) + (hHt : ∀ᶠ n in atTop, (H n:ℝ) ≤ fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (z n)) + (hR : Tendsto (fun n => truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (L*z n)/ + truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (z n)) atTop (𝓝 R)) + (hG : Tendsto (fun n => truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (z n/2)/ + truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (z n)) atTop (𝓝 G)) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + limsup (fun n => cappedTailMoment (successfulAverage ν ℓ (H n)) + (fun X => medianDeviation ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) (H n) X/z n) A L) atTop ≤ + (16000/p^2)*(2048/(A/40)^2+16*(R-1)+(64/3)*(1-G)) := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + let μ := independentConditionedPairLaw ν ℓ + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + let X := commonIncrementProcess ℓ f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hm (n) : truncatedVariance μ (X 0) (z n) ≠ 0 := + ne_of_gt (truncatedVariance_pos μ (X 0) (measurable_commonIncrementProcess ℓ f 0) hne (hz n)) + have hlim : Tendsto (fun n => 2048/(A/40)^2+ + 16*((truncatedVariance μ (X 0) (L*z n)-truncatedVariance μ (X 0) (z n))/truncatedVariance μ (X 0) (z n))+ + (64/3)*((truncatedVariance μ (X 0) (z n)-truncatedVariance μ (X 0) (z n/2))/truncatedVariance μ (X 0) (z n))) + atTop (𝓝 (2048/(A/40)^2+16*(R-1)+(64/3)*(1-G))) := by + simp only [sub_div,div_self (hm _)] + exact (tendsto_const_nhds.add (tendsto_const_nhds.mul (hR.sub tendsto_const_nhds))).add + (tendsto_const_nhds.mul (tendsto_const_nhds.sub hG)) + have hbound : limsup (fun n => cappedTailMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/z n) (A/40) L) atTop ≤ + 2048/(A/40)^2+16*(R-1)+(64/3)*(1-G) := by + rw [← hlim.limsup_eq] + have hev : ∀ᶠ n in atTop, cappedTailMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/z n) (A/40) L ≤ + 2048/(A/40)^2+ + 16*((truncatedVariance μ (X 0) (L*z n)-truncatedVariance μ (X 0) (z n))/truncatedVariance μ (X 0) (z n))+ + (64/3)*((truncatedVariance μ (X 0) (z n)-truncatedVariance μ (X 0) (z n/2))/truncatedVariance μ (X 0) (z n)) := by + filter_upwards [hHt] with n hn + exact iid_scaled_max_tail_variance_le μ X (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) hne (hz n) (by positivity) hL (H n) hn + have h0 : ∀ n, (0:ℝ) ≤ cappedTailMoment μ (fun P => partialSumMax (fun k => X k P) (H n)/z n) (A/40) L := + fun n => integral_nonneg fun P => by split_ifs <;> positivity + exact limsup_le_limsup hev (isCoboundedUnder_le_of_le atTop h0) hlim.isBoundedUnder_le + have hh := (successfulMedian_moment_transfer ν hue e f htrans H hH z hz hzinf hA hAL).2 + exact hh.trans (mul_le_mul_of_nonneg_left hbound (by positivity)) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ScheduledCellSuccess.lean b/lean/OAI/Probability/Ballisticity/Estimates/ScheduledCellSuccess.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee5be0b451a442593697e7f5b5a5f7323283e98d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ScheduledCellSuccess.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.WordPrefixes +import OAI.Probability.Ballisticity.Estimates.CellExhaustion + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +noncomputable def scheduledCellSuccess {d k : ℕ} (ν : Measure (Row d)) + (e f : Direction d) (hef : e.1 ≠ f.1) (a C c g₀ g₁ A : ℝ) (hc : 0 < c) + (π : Environment d → LayerTupleProfile (k:=k) e a) (v w m s i : ℕ) : Set (Environment d) := + if i < m then + cellAttemptSuccess + (cellSeedMass e f (a+cellOpportunity v w m i) (c*cellRadius ν e f C w m i) + (cellWidth w m i) (cellRestart e a π v w m i)) + (cellEarlyMass e f hef (a+cellOpportunity v w m i) (c*cellRadius ν e f C w m i) + (cellWidth w m i) (cellEarlyHeight v w m i s) (cellRestart e a π v w m i)) + (cellLateMass e f hef (a+cellOpportunity v w m i) c (cellRadius ν e f C w m i) + hc (cellRadius_pos ν e f C w m i) (cellWidth w m i) (cellEarlyHeight v w m i s) s + (cellLateHeight v w m i s) (cellRestart e a π v w m i)) g₀ g₁ (A*k) s (m-i) + else ∅ + +lemma scheduledCellSuccess_or_failure {d k : ℕ} (ν : Measure (Row d)) + (e f : Direction d) (hef : e.1 ≠ f.1) (a C c g₀ g₁ A : ℝ) (hc : 0 < c) + (π : Environment d → LayerTupleProfile (k:=k) e a) (v w m s : ℕ) (hs : 0 < s) + (i : ℕ) (hi : i < m) (ω : Environment d) : + ω ∈ scheduledCellSuccess ν e f hef a C c g₀ g₁ A hc π v w m s i ∨ + ∃ n, 0 < n ∧ n ≤ m-i ∧ ω ∈ scheduledCellFailure ν e f hef a C c g₀ g₁ A hc π v w m s i n := by + have hh := cell_failure_or_success + (cellSeedMass e f (a+cellOpportunity v w m i) (c*cellRadius ν e f C w m i) + (cellWidth w m i) (cellRestart e a π v w m i)) + (cellEarlyMass e f hef (a+cellOpportunity v w m i) (c*cellRadius ν e f C w m i) + (cellWidth w m i) (cellEarlyHeight v w m i s) (cellRestart e a π v w m i)) + (cellLateMass e f hef (a+cellOpportunity v w m i) c (cellRadius ν e f C w m i) + hc (cellRadius_pos ν e f C w m i) (cellWidth w m i) (cellEarlyHeight v w m i s) s + (cellLateHeight v w m i s) (cellRestart e a π v w m i)) g₀ g₁ (A*k) s (m-i) hs (by omega) ω + rcases hh with hh|⟨n,hn,hnm,hf⟩ + · exact Or.inl (by simpa only [scheduledCellSuccess,ite_eq_left hi] using hh) + · exact Or.inr ⟨n,hn,hnm,by simpa only [scheduledCellFailure,ite_eq_left (show i < m ∧ 0 < n ∧ n ≤ m-i from ⟨hi,hn,hnm⟩)] using hf⟩ + +lemma no_cell_success_subset_exhaustion {d k : ℕ} (ν : Measure (Row d)) + (e f : Direction d) (hef : e.1 ≠ f.1) (a C c g₀ g₁ A : ℝ) (hc : 0 < c) + (π : Environment d → LayerTupleProfile (k:=k) e a) (v w m s : ℕ) (hs : 0 < s) : + (⋃ i, scheduledCellSuccess ν e f hef a C c g₀ g₁ A hc π v w m s i)ᶜ ⊆ + ⋃ p : Composition m, failedOpportunityBlocks + (scheduledCellFailure ν e f hef a C c g₀ g₁ A hc π v w m s) 0 p.blocks := by + intro ω hω + apply Set.mem_iUnion.mpr + apply failed_blocks_of_no_success _ + (scheduledCellSuccess ν e f hef a C c g₀ g₁ A hc π v w m s) m + (scheduledCellSuccess_or_failure ν e f hef a C c g₀ g₁ A hc π v w m s hs) ω + intro i hi hS + exact hω (Set.mem_iUnion.mpr ⟨i,hS⟩) + +theorem actual_cell_no_success {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℝ, 1 ≤ A ∧ ∀ k : ℕ, 2 ≤ k → + ∃ C c g₀ g₁ : ℝ, 0 < C ∧ ∃ hc : 0 < c, c ≤ 1 ∧ 0 < g₀ ∧ 0 < g₁ ∧ + ∃ s : ℕ, 0 < s ∧ ∀ Bstar : ℝ, 0 < Bstar → ∃ w₀ : ℕ, 0 < w₀ ∧ + ∀ w ≥ w₀, ∀ m : ℕ, (2*A*k)*(m:ℝ) ≤ Bstar → + ∀ v : ℕ, 2*cellWidth w m 0 ≤ v → + ∀ (a : ℝ) (π : Environment d → LayerTupleProfile (k:=k) e a), + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π → + environmentLaw ν (⋃ i, scheduledCellSuccess ν e f hef a C c g₀ g₁ A hc π v w m s i)ᶜ ≤ + (2:ℝ≥0∞)^(m-1)*ENNReal.ofReal (Real.exp (-2*k*m)) := by + obtain ⟨A,hA,hk⟩ := actual_cell_exhaustion ν hue e f hef htrans + refine ⟨A,hA,fun k hk₂ => ?_⟩ + obtain ⟨C,c,g₀,g₁,hC,hc,hc1,hg₀,hg₁,s,hs,hb⟩ := hk k hk₂ + refine ⟨C,c,g₀,g₁,hC,hc,hc1,hg₀,hg₁,s,hs,fun Bstar hB => ?_⟩ + obtain ⟨w₀,hw₀,hw⟩ := hb Bstar hB + refine ⟨w₀,hw₀,fun w hww m hm v hv a π hπ => ?_⟩ + exact (measure_mono (no_cell_success_subset_exhaustion ν e f hef a C c g₀ g₁ A hc π v w m s hs)).trans + (hw w hww m hm v hv a π hπ) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal BigOperators Classical +namespace DirectionalTransience + +lemma budget_profile_prefix_certificate {d k : ℕ} (e f : Direction d) + (a G r : ℝ) (π : BudgetProfile (k:=k) e f a G) (ω : Environment d) + (h H : ℕ) (hh : h≤H) : + relativeBudgetMassENN e f H r π.val ω ≤ + rawTupleMixture (realPosition (step e)) h π.val ω {y | TupleSeparated f (G-r) y} := by + rw [relativeBudgetMassENN,rawTupleMixture_apply] + apply lintegral_mono_ae + filter_upwards [π.property.2] with x hx + exact budget_prefix_certificate e f ω x h H hh G r hx.2 + +theorem protection_prefix_certificate {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i,0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) + (n h : ℕ) (hh : h≤H n) (ω : Environment d) : + (∏ i∈Finset.range (n+1),ENNReal.ofReal (protectionMass e f base G H r hr π i ω)) ≤ + rawTupleMixture (realPosition (step e)) ((∑ i∈Finset.range n,H i)+h) (π ω).val ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := by + let c := ∏ i∈Finset.range n,ENNReal.ofReal (protectionMass e f base G H r hr π i ω) + let p := protectionProfile e f base G H r hr π n ω + have hi := budget_profile_prefix_certificate e f _ _ (r n) p ω h (H n) hh + have hp := protection_retained_le_raw e f base G H r hr π n ω + rw [Finset.prod_range_succ,protectionMass_ennreal] + change c*relativeBudgetMassENN e f (H n) (r n) p.val ω ≤ _ + calc + _ ≤ c*rawTupleMixture (realPosition (step e)) h p.val ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := mul_le_mul_right hi c + _ = rawTupleMixture (realPosition (step e)) h (c•p.val) ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := by + rw [rawTupleMixture_smul,Measure.smul_apply,smul_eq_mul] + _ ≤ rawTupleMixture (realPosition (step e)) h + (rawTupleMixture (realPosition (step e)) (∑ i∈Finset.range n,H i) (π ω).val ω) ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := (rawTupleMixture_mono _ _ _ hp) _ + _ ≤ _ := rawTupleMixture_comp_le e (∑ i∈Finset.range n,H i) h (π ω).val ω _ + +theorem protection_prefix_after_retention {d k : ℕ} (e f : Direction d) (base G : ℝ) + (H : ℕ → ℕ) (r : ℕ → ℝ) (hr : ∀ i,0≤r i) + (π : Environment d → BudgetProfile (k:=k) e f base G) + (n h : ℕ) (hh : h≤H n) (ω : Environment d) + (μ : Measure (Fin k → Lattice d)) (t : ℕ) (c : ℝ≥0∞) + (hc : c•(π ω).val ≤ rawTupleMixture (realPosition (step e)) t μ ω) : + c*(∏ i∈Finset.range (n+1),ENNReal.ofReal (protectionMass e f base G H r hr π i ω)) ≤ + rawTupleMixture (realPosition (step e)) (t+(∑ i∈Finset.range n,H i)+h) μ ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := by + have hp := protection_prefix_certificate e f base G H r hr π n h hh ω + calc + _ ≤ c*rawTupleMixture (realPosition (step e)) ((∑ i∈Finset.range n,H i)+h) (π ω).val ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := mul_le_mul_right hp c + _ = rawTupleMixture (realPosition (step e)) ((∑ i∈Finset.range n,H i)+h) (c•(π ω).val) ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := by + rw [rawTupleMixture_smul,Measure.smul_apply,smul_eq_mul] + _ ≤ rawTupleMixture (realPosition (step e)) ((∑ i∈Finset.range n,H i)+h) + (rawTupleMixture (realPosition (step e)) t μ ω) ω + {y | TupleSeparated f (protectionGap G r n-r n) y} := (rawTupleMixture_mono _ _ _ hc) _ + _ ≤ _ := by + simpa only [Nat.add_assoc] using rawTupleMixture_comp_le e t ((∑ i∈Finset.range n,H i)+h) μ ω + {y | TupleSeparated f (protectionGap G r n-r n) y} + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SecondMomentConcentration.lean b/lean/OAI/Probability/Ballisticity/Estimates/SecondMomentConcentration.lean new file mode 100644 index 0000000000000000000000000000000000000000..1069fb5e7464d63087e28832bd21004a2e07e8f4 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SecondMomentConcentration.lean @@ -0,0 +1,74 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma integral_squared_error {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (M : Ω → ℝ) (hM : Measurable M) + (C : ℝ) (hbound : ∀ ω, ‖M ω‖ ≤ C) (b : ℝ) : + (∫ ω, (M ω-b)^2 ∂μ) = (∫ ω, (M ω)^2 ∂μ)-2*b*(∫ ω, M ω ∂μ)+b^2 := by + have hi : Integrable M μ := Integrable.of_bound hM.aestronglyMeasurable C (ae_of_all _ hbound) + have his : Integrable (fun ω => (M ω)^2) μ := + Integrable.of_bound (hM.pow_const 2).aestronglyMeasurable (C^2) (ae_of_all _ (fun ω => by + simpa only [norm_pow] using pow_le_pow_left₀ (norm_nonneg _) (hbound ω) 2)) + have hh : (fun ω => (M ω-b)^2) = (fun ω => (M ω)^2-2*b*M ω+b^2) := by funext ω; ring + have hid : Integrable (fun ω => (M ω)^2-2*b*M ω) μ := his.sub (hi.const_mul (2*b)) + rw [hh,integral_add hid (integrable_const (b^2)), + integral_sub his (hi.const_mul (2*b)),integral_const_mul] + simp + +lemma squared_error_tendsto_of_moments {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (M : ℕ → Ω → ℝ) + (hM : ∀ i, Measurable (M i)) (C : ℝ) (hbound : ∀ i ω, ‖M i ω‖ ≤ C) + (b : ℝ) (hfirst : Tendsto (fun i => ∫ ω, M i ω ∂μ) atTop (𝓝 b)) + (hsecond : Tendsto (fun i => ∫ ω, (M i ω)^2 ∂μ) atTop (𝓝 (b^2))) : + Tendsto (fun i => ∫ ω, (M i ω-b)^2 ∂μ) atTop (𝓝 0) := by + have hh := (hsecond.sub (hfirst.const_mul (2*b))).add_const (b^2) + have hb : b^2-2*b*b+b^2 = 0 := by ring + simpa only [integral_squared_error μ _ (hM _) C (hbound _) b,hb] using hh + +lemma tendstoInMeasure_of_squared_error {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (M : ℕ → Ω → ℝ) (b : ℝ) + (hi : ∀ i, Integrable (fun ω => (M i ω-b)^2) μ) + (hl : Tendsto (fun i => ∫ ω, (M i ω-b)^2 ∂μ) atTop (𝓝 0)) : + TendstoInMeasure μ M atTop (fun _ => b) := by + rw [tendstoInMeasure_iff_measureReal_norm] + intro ε hε + have hb (i : ℕ) : μ.real {ω | ε ≤ ‖M i ω-b‖} ≤ (∫ ω, (M i ω-b)^2 ∂μ)/(ε^2) := by + apply (le_div_iff₀ (sq_pos_of_pos hε)).mpr + have hm := mul_meas_ge_le_integral_of_nonneg (ae_of_all μ (fun ω => sq_nonneg (M i ω-b))) (hi i) (ε^2) + have hs : {ω | ε ≤ ‖M i ω-b‖} = {ω | ε^2 ≤ (M i ω-b)^2} := by + ext ω + change ε ≤ ‖M i ω-b‖ ↔ ε^2 ≤ (M i ω-b)^2 + simpa only [Real.norm_eq_abs,sq_abs] using (sq_le_sq₀ hε.le (abs_nonneg (M i ω-b))).symm + rw [hs,mul_comm] + exact hm + apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds + (show Tendsto (fun i => (∫ ω, (M i ω-b)^2 ∂μ)/(ε^2)) atTop (𝓝 0) from by simpa using hl.div_const (ε^2)) + (fun _ => measureReal_nonneg) hb + +lemma tendstoInMeasure_of_absolutelyContinuous {Ω : Type*} [MeasurableSpace Ω] + (μ ν : Measure Ω) [IsFiniteMeasure μ] (hac : μ ≪ ν) + (M : ℕ → Ω → ℝ) (hM : ∀ i, Measurable (M i)) (b : ℝ) + (hl : TendstoInMeasure ν M atTop (fun _ => b)) : + TendstoInMeasure μ M atTop (fun _ => b) := by + apply (exists_seq_tendstoInMeasure_atTop_iff (fun i => (hM i).aestronglyMeasurable)).mpr + intro ns hns + obtain ⟨ns',hns',hh⟩ := (hl.comp hns.tendsto_atTop).exists_seq_tendsto_ae + exact ⟨ns',hns',hac.ae_le hh⟩ + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SelectedBoundaryRestart.lean b/lean/OAI/Probability/Ballisticity/Estimates/SelectedBoundaryRestart.lean new file mode 100644 index 0000000000000000000000000000000000000000..87dd83ecac83928780b9fdb94be74921da61d64b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SelectedBoundaryRestart.lean @@ -0,0 +1,392 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.JointPastRestart + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +def selectedBoundaryAt {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + (n m : ℕ) : Prop := + 0 < n ∧ 0 < m ∧ CommonTrueRecord ℓ P n m ∧ + B (P.1 n,P.2 m) ∧ + ∀ j k, 0 < j → j < n → 0 < k → k < m → + B (P.1 j,P.2 k) → ¬ CommonTrueRecord ℓ P j k + +def selectedAdmissibleBoundaryPrefix {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (x y : Lattice d) + (f g : Path d) (n m : ℕ) : Prop := + 0 < n ∧ 0 < m ∧ + dot (realPosition (f n)) ℓ = dot (realPosition (g m)) ℓ ∧ + StrictRecord ℓ f n ∧ StrictRecord ℓ g m ∧ + (∀ j ≤ n, dot (realPosition x) ℓ ≤ dot (realPosition (f j)) ℓ) ∧ + (∀ k ≤ m, dot (realPosition y) ℓ ≤ dot (realPosition (g k)) ℓ) ∧ + B (f n,g m) ∧ + ∀ j k, 0 < j → j < n → 0 < k → k < m → + B (f j,g k) → StrictRecord ℓ f j → StrictRecord ℓ g k → + dot (realPosition (f j)) ℓ = dot (realPosition (g k)) ℓ → + (∃ a, j < a ∧ a < n ∧ dot (realPosition (f a)) ℓ < dot (realPosition (f j)) ℓ) ∨ + (∃ b, k < b ∧ b < m ∧ dot (realPosition (g b)) ℓ < dot (realPosition (g k)) ℓ) + +lemma selectedBoundaryPrefix_characterization {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) + (x y : Lattice d) (f g : Path d) (n m : ℕ) (P : Path d × Path d) + (hf : P.1 ∈ pathCylinder f n) (hg : P.2 ∈ pathCylinder g m) : + (P.1 ∈ NoDrop ℓ x ∧ P.2 ∈ NoDrop ℓ y ∧ selectedBoundaryAt ℓ B P n m) ↔ + (selectedAdmissibleBoundaryPrefix ℓ B x y f g n m ∧ + P.1 ∈ FutureNoDrop ℓ n ∧ P.2 ∈ FutureNoDrop ℓ m) := by + have hr1 j (hj : j ≤ n) : StrictRecord ℓ P.1 j ↔ StrictRecord ℓ f j := + strictRecord_congr_prefix ℓ hj hf + have hr2 k (hk : k ≤ m) : StrictRecord ℓ P.2 k ↔ StrictRecord ℓ g k := + strictRecord_congr_prefix ℓ hk hg + constructor + · rintro ⟨hD1,hD2,hn,hm,⟨ht1,ht2,he⟩,hH,hfirst⟩ + refine ⟨⟨hn,hm,?_,(hr1 _ le_rfl).mp ht1.1,(hr2 _ le_rfl).mp ht2.1, + ?_,?_,?_,?_⟩,ht1.2,ht2.2⟩ + · simpa only [hf _ le_rfl,hg _ le_rfl] using he + · intro j hj + simpa only [hf j hj] using hD1 j + · intro k hk + simpa only [hg k hk] using hD2 k + · simpa only [hf _ le_rfl,hg _ le_rfl] using hH + · intro j k hj hjn hk hkm hjH hrj hrk heq + have hj' := (hr1 j hjn.le).mpr hrj + have hk' := (hr2 k hkm.le).mpr hrk + have he' : dot (realPosition (P.1 j)) ℓ = dot (realPosition (P.2 k)) ℓ := by + simpa only [hf j hjn.le,hg k hkm.le] using heq + have hnot := hfirst j k hj hjn hk hkm (by simpa only [hf j hjn.le,hg k hkm.le] using hjH) + have hdis : ¬ TrueRecord ℓ P.1 j ∨ ¬ TrueRecord ℓ P.2 k := by + by_cases h1 : TrueRecord ℓ P.1 j + · exact Or.inr fun h2 => hnot ⟨h1,h2,he'⟩ + · exact Or.inl h1 + rcases hdis with h1 | h2 + · obtain ⟨a,hja,han,ha⟩ := (not_trueRecord_before_true_iff ℓ P.1 hjn hj' ht1).mp h1 + exact Or.inl ⟨a,hja,han,by simpa only [hf a han.le,hf j hjn.le] using ha⟩ + · obtain ⟨b,hkb,hbm,hb⟩ := (not_trueRecord_before_true_iff ℓ P.2 hkm hk' ht2).mp h2 + exact Or.inr ⟨b,hkb,hbm,by simpa only [hg b hbm.le,hg k hkm.le] using hb⟩ + · rintro ⟨⟨hn,hm,he,hrf,hrg,hD1,hD2,hH,hfail⟩,hF1,hF2⟩ + have ht1 : TrueRecord ℓ P.1 n := ⟨(hr1 _ le_rfl).mpr hrf,hF1⟩ + have ht2 : TrueRecord ℓ P.2 m := ⟨(hr2 _ le_rfl).mpr hrg,hF2⟩ + refine ⟨(noDrop_iff_prefix_and_future ℓ x P.1 _ hF1).mpr ?_, + (noDrop_iff_prefix_and_future ℓ y P.2 _ hF2).mpr ?_, + hn,hm,⟨ht1,ht2,?_⟩,?_,?_⟩ + · intro j hj + simpa only [hf j hj] using hD1 j hj + · intro k hk + simpa only [hg k hk] using hD2 k hk + · simpa only [hf _ le_rfl,hg _ le_rfl] using he + · simpa only [hf _ le_rfl,hg _ le_rfl] using hH + · intro j k hj hjn hk hkm hjH htrue + have hdis := hfail j k hj hjn hk hkm (by simpa only [hf j hjn.le,hg k hkm.le] using hjH) + ((hr1 _ hjn.le).mp htrue.1.1) ((hr2 _ hkm.le).mp htrue.2.1.1) + (by simpa only [hf j hjn.le,hg k hkm.le] using htrue.2.2) + rcases hdis with ⟨a,hja,han,ha⟩ | ⟨b,hkb,hbm,hb⟩ + · exact (not_trueRecord_before_true_iff ℓ P.1 hjn htrue.1.1 ht1).mpr + ⟨a,hja,han,by simpa only [hf a han.le,hf j hjn.le] using ha⟩ htrue.1 + · exact (not_trueRecord_before_true_iff ℓ P.2 hkm htrue.2.1.1 ht2).mpr + ⟨b,hkb,hbm,by simpa only [hg b hbm.le,hg k hkm.le] using hb⟩ htrue.2.1 + +lemma selectedBoundaryAt_unique {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + {n m j k : ℕ} (hn : selectedBoundaryAt ℓ B P n m) (hj : selectedBoundaryAt ℓ B P j k) : + n = j ∧ m = k := by + have hnj : n = j := by + rcases lt_trichotomy n j with h | h | h + · exact False.elim (hj.2.2.2.2 n m hn.1 h hn.2.1 + ((commonTrueRecord_time_order ℓ P hn.2.2.1 hj.2.2.1).mp h) hn.2.2.2.1 hn.2.2.1) + · exact h + · exact False.elim (hn.2.2.2.2 j k hj.1 h hj.2.1 + ((commonTrueRecord_time_order ℓ P hj.2.2.1 hn.2.2.1).mp h) hj.2.2.2.1 hj.2.2.1) + refine ⟨hnj,?_⟩ + apply Nat.le_antisymm + · by_contra h + have := (commonTrueRecord_time_order ℓ P hj.2.2.1 hn.2.2.1).mpr (by omega : k < m) + omega + · by_contra h + have := (commonTrueRecord_time_order ℓ P hn.2.2.1 hj.2.2.1).mpr (by omega : m < k) + omega + +lemma selectedBoundaryAt_exists {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + (h : ∃ n m, 0 < n ∧ 0 < m ∧ CommonTrueRecord ℓ P n m ∧ + B (P.1 n,P.2 m)) : ∃ n m, selectedBoundaryAt ℓ B P n m := by + obtain ⟨m,hn,hm,hr,hH⟩ := Nat.find_spec h + exact ⟨Nat.find h,m,hn,hm,hr,hH,fun j k hj hjn hk _ hjH hc => + Nat.find_min h hjn ⟨k,hj,hk,hc,hjH⟩⟩ + +lemma selectedMeasurableSet_boundaryAt {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (n m : ℕ) : + MeasurableSet {P : Path d × Path d | selectedBoundaryAt ℓ B P n m} := by + have hheight (j k : ℕ) : MeasurableSet {P : Path d × Path d | B (P.1 j,P.2 k)} := + ((Set.to_countable {z | B z}).measurableSet).preimage + (((measurable_pi_apply j).comp measurable_fst).prodMk + ((measurable_pi_apply k).comp measurable_snd)) + simp only [selectedBoundaryAt,Set.ofPred_and,Set.ofPred_forall] + refine (MeasurableSet.const _).inter ((MeasurableSet.const _).inter + ((measurableSet_commonTrueRecord ℓ n m).inter ((hheight n m).inter ?_))) + refine MeasurableSet.iInter fun j => MeasurableSet.iInter fun k => + MeasurableSet.iInter fun _ => MeasurableSet.iInter fun _ => + MeasurableSet.iInter fun _ => MeasurableSet.iInter fun _ => ?_ + convert (hheight j k).compl.union (measurableSet_commonTrueRecord ℓ j k).compl using 1 + ext P + simp only [Set.mem_union,Set.mem_compl_iff,Set.mem_ofPred_eq,imp_iff_not_or] + +lemma selectedBoundaryCode_exists {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) : + ∃ a : ℕ, selectedBoundaryAt ℓ B P (Nat.unpair a).1 (Nat.unpair a).2 ∨ + ¬ ∃ n m, selectedBoundaryAt ℓ B P n m := by + by_cases h : ∃ n m, selectedBoundaryAt ℓ B P n m + · obtain ⟨n,m,hnm⟩ := h + exact ⟨Nat.pair n m,Or.inl (by simpa only [Nat.unpair_pair] using hnm)⟩ + · exact ⟨0,Or.inr h⟩ + +noncomputable def selectedBoundaryCode {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) : ℕ := + Nat.find (selectedBoundaryCode_exists ℓ B P) + +noncomputable def selectedBoundaryTimes {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) : ℕ × ℕ := + Nat.unpair (selectedBoundaryCode ℓ B P) + +lemma measurable_selectedBoundaryCode {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) : + Measurable (selectedBoundaryCode ℓ B) := by + apply measurable_find + intro a + apply (selectedMeasurableSet_boundaryAt ℓ B _ _).union + change MeasurableSet ({P : Path d × Path d | ∃ n m, selectedBoundaryAt ℓ B P n m}ᶜ) + simp only [Set.ofPred_exists] + exact (MeasurableSet.iUnion fun n => MeasurableSet.iUnion fun m => + selectedMeasurableSet_boundaryAt ℓ B n m).compl + +lemma measurable_selectedBoundaryTimes {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) : + Measurable (selectedBoundaryTimes ℓ B) := (measurable_of_countable _).comp (measurable_selectedBoundaryCode ℓ B) + +lemma selectedBoundaryTimes_spec {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + (h : ∃ n m, selectedBoundaryAt ℓ B P n m) : + selectedBoundaryAt ℓ B P (selectedBoundaryTimes ℓ B P).1 (selectedBoundaryTimes ℓ B P).2 := + (Nat.find_spec (selectedBoundaryCode_exists ℓ B P)).resolve_right (not_not.mpr h) + +lemma selectedBoundaryTimes_eq {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + {n m : ℕ} (h : selectedBoundaryAt ℓ B P n m) : selectedBoundaryTimes ℓ B P = (n,m) := by + exact Prod.ext (selectedBoundaryAt_unique ℓ B P (selectedBoundaryTimes_spec ℓ B P ⟨n,m,h⟩) h).1 + (selectedBoundaryAt_unique ℓ B P (selectedBoundaryTimes_spec ℓ B P ⟨n,m,h⟩) h).2 + +def selectedBoundaryAtom {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (x y : Lattice d) + (f g : Path d) (n m : ℕ) : Set (Path d × Path d) := + (pathCylinder f n ×ˢ pathCylinder g m) ∩ + ((NoDrop ℓ x ×ˢ NoDrop ℓ y) ∩ {P | selectedBoundaryAt ℓ B P n m}) + +lemma selectedMeasurableSet_selectedBoundaryAtom {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (x y : Lattice d) + (f g : Path d) (n m : ℕ) : MeasurableSet (selectedBoundaryAtom ℓ B x y f g n m) := + ((measurableSet_pathCylinder f n).prod (measurableSet_pathCylinder g m)).inter + (((measurableSet_noDrop ℓ x).prod (measurableSet_noDrop ℓ y)).inter + (selectedMeasurableSet_boundaryAt ℓ B n m)) + +lemma selectedBoundaryAtom_eq {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (x y : Lattice d) + (f g : Path d) (n m : ℕ) : selectedBoundaryAtom ℓ B x y f g n m = + if selectedAdmissibleBoundaryPrefix ℓ B x y f g n m then truePairCylinder ℓ f g n m else ∅ := by + by_cases ha : selectedAdmissibleBoundaryPrefix ℓ B x y f g n m + · rw [ite_eq_left ha] + ext P + constructor + · rintro ⟨⟨hf,hg⟩,⟨hD,hE⟩,hB⟩ + have := (selectedBoundaryPrefix_characterization ℓ B x y f g n m P hf hg).mp ⟨hD,hE,hB⟩ + exact ⟨⟨hf,hg⟩,this.2⟩ + · rintro ⟨⟨hf,hg⟩,hD,hE⟩ + have := (selectedBoundaryPrefix_characterization ℓ B x y f g n m P hf hg).mpr ⟨ha,hD,hE⟩ + exact ⟨⟨hf,hg⟩,⟨this.1,this.2.1⟩,this.2.2⟩ + · rw [ite_eq_right ha] + apply Set.eq_empty_iff_forall_notMem.mpr + rintro P ⟨⟨hf,hg⟩,⟨hD,hE⟩,hB⟩ + exact ha ((selectedBoundaryPrefix_characterization ℓ B x y f g n m P hf hg).mp ⟨hD,hE,hB⟩).1 + +lemma shared_selectedBoundaryAtom_map {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (B : Lattice d × Lattice d → Prop) (x y : Lattice d) + (f g : Path d) (n m : ℕ) : + ((sharedConditionedPairLaw ν ℓ x y).restrict (selectedBoundaryAtom ℓ B x y f g n m)).map + (commonPairSuffix n m) = + sharedConditionedPairLaw ν ℓ x y (selectedBoundaryAtom ℓ B x y f g n m) • + sharedConditionedPairLaw ν ℓ (f n) (g m) := by + rw [selectedBoundaryAtom_eq] + split_ifs with ha + · exact shared_truePairCylinder_map ν ℓ x y f g n m ha.1 ha.2.1 + ha.2.2.2.1 ha.2.2.2.2.1 ha.2.2.1 ha.2.2.2.2.2.1 ha.2.2.2.2.2.2.1 + (ne_of_gt (sharedNoDropMass_positive ν hue ℓ hℓ htrans _ _)) + · simp + +noncomputable def selectedBoundaryData {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) : + BoundaryData d := ⟨selectedBoundaryTimes ℓ B P, + pairPrefix (selectedBoundaryTimes ℓ B P).1 (selectedBoundaryTimes ℓ B P).2 P⟩ + +lemma selectedBoundaryData_fiber {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (F : BoundaryData d) : + selectedBoundaryData ℓ B ⁻¹' {F} = + (selectedBoundaryTimes ℓ B ⁻¹' {F.1}) ∩ (pairPrefix F.1.1 F.1.2 ⁻¹' {F.2}) := by + ext P + simp only [Set.mem_preimage,Set.mem_singleton_iff,Set.mem_inter_iff] + constructor + · intro he + have ht : selectedBoundaryTimes ℓ B P = F.1 := congrArg Sigma.fst he + refine ⟨ht,?_⟩ + cases F with + | mk q f => + dsimp only at ht ⊢ + unfold selectedBoundaryData at he + cases ht + exact Sigma.mk.inj_iff.mp he |>.2 |> eq_of_heq + · rintro ⟨ht,hf⟩ + cases F with + | mk q f => + dsimp only at ht hf ⊢ + unfold selectedBoundaryData + cases ht + exact congrArg (Sigma.mk _) hf + +lemma measurable_selectedBoundaryData {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) : + Measurable (selectedBoundaryData ℓ B) := by + apply measurable_to_countable' + intro F + rw [selectedBoundaryData_fiber] + exact ((measurable_selectedBoundaryTimes ℓ B) (measurableSet_singleton _)).inter + ((measurable_pairPrefix _ _) (measurableSet_singleton _)) + +noncomputable def selectedBoundarySuffix {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) : + Path d × Path d := commonPairSuffix (selectedBoundaryTimes ℓ B P).1 (selectedBoundaryTimes ℓ B P).2 P + +lemma measurable_selectedBoundarySuffix {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) : + Measurable (selectedBoundarySuffix ℓ B) := by + have hm : Measurable (fun Z : (Path d × Path d) × (ℕ × ℕ) => + commonPairSuffix Z.2.1 Z.2.2 Z.1) := + measurable_from_prod_countable_left fun q => measurable_commonPairSuffix q.1 q.2 + exact hm.comp (measurable_id.prodMk (measurable_selectedBoundaryTimes ℓ B)) + +lemma selectedBoundaryData_times {d : ℕ} (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (P : Path d × Path d) + (F : BoundaryData d) (hF : selectedBoundaryData ℓ B P = F) : + selectedBoundaryTimes ℓ B P = F.1 := congrArg Sigma.fst hF + +lemma selectedBoundaryAtom_fiber_ae {d : ℕ} (μ : Measure (Path d × Path d)) + (ℓ : Vector d) (B : Lattice d × Lattice d → Prop) (x y : Lattice d) + (hD : ∀ᵐ P ∂μ, P.1 ∈ NoDrop ℓ x ∧ P.2 ∈ NoDrop ℓ y) + (hS : ∀ᵐ P ∂μ, selectedBoundaryAt ℓ B P (selectedBoundaryTimes ℓ B P).1 (selectedBoundaryTimes ℓ B P).2) + (F : BoundaryData d) : + (selectedBoundaryData ℓ B ⁻¹' {F}) =ᵐ[μ] + selectedBoundaryAtom ℓ B x y (extendPrefix F.1.1 F.2.1) (extendPrefix F.1.2 F.2.2) F.1.1 F.1.2 := by + filter_upwards [hD,hS] with P hDP hSP + rw [selectedBoundaryData_fiber,pairPrefix_fiber] + apply propext + change (selectedBoundaryTimes ℓ B P = F.1 ∧ _) ↔ _ + constructor + · rintro ⟨ht,hpre⟩ + refine ⟨hpre,hDP,?_⟩ + change selectedBoundaryAt ℓ B P F.1.1 F.1.2 + simpa only [ht] using hSP + · rintro ⟨hpre,hno,hB⟩ + exact ⟨selectedBoundaryTimes_eq ℓ B P hB,hpre⟩ + +lemma selectedBoundaryAt_exists_above {d : ℕ} (ℓ : Vector d) + (B : Lattice d × Lattice d → Prop) (H : ℝ) + (hB : ∀ z w, H ≤ dot (realPosition z) ℓ → B (z,w)) + (P : Path d × Path d) (h : ∃ n m, BoundaryAt ℓ H P n m) : + ∃ n m, selectedBoundaryAt ℓ B P n m := by + obtain ⟨n,m,hn⟩ := h + exact selectedBoundaryAt_exists ℓ B P ⟨n,m,hn.1,hn.2.1,hn.2.2.1,hB _ _ hn.2.2.2.1⟩ + +lemma shared_selectedBoundaryTimes_spec {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) + (x y : Lattice d) (hxy : height x = height y) (H : ℕ) (hH : 0 < H) + (B : Lattice d × Lattice d → Prop) + (hB : ∀ z w, height x+H ≤ height z → B (z,w)) : + ∀ᵐ P ∂sharedConditionedPairLaw ν ℓ x y, + selectedBoundaryAt ℓ B P (selectedBoundaryTimes ℓ B P).1 (selectedBoundaryTimes ℓ B P).2 := by + filter_upwards [shared_boundaryTimes_spec ν hue ℓ hℓ htrans height hproj hstep x y hxy H hH] + with P hP + apply selectedBoundaryTimes_spec + apply selectedBoundaryAt_exists_above ℓ B ((height x+H : ℤ) : ℝ) _ P + ⟨_,_,hP⟩ + intro z w hz + rw [hproj] at hz + exact hB z w (by exact_mod_cast hz) + +def BoundaryData.endpoints {d : ℕ} (F : BoundaryData d) : Lattice d × Lattice d := + (extendPrefix F.1.1 F.2.1 F.1.1,extendPrefix F.1.2 F.2.2 F.1.2) + +lemma shared_selectedBoundaryData_map {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) + (B : Lattice d × Lattice d → Prop) + (hS : ∀ᵐ P ∂sharedConditionedPairLaw ν ℓ x y, + selectedBoundaryAt ℓ B P (selectedBoundaryTimes ℓ B P).1 (selectedBoundaryTimes ℓ B P).2) + (F : BoundaryData d) : + ((sharedConditionedPairLaw ν ℓ x y).restrict + (selectedBoundaryData ℓ B ⁻¹' {F})).map (selectedBoundarySuffix ℓ B) = + sharedConditionedPairLaw ν ℓ x y (selectedBoundaryData ℓ B ⁻¹' {F}) • + sharedConditionedPairLaw ν ℓ F.endpoints.1 F.endpoints.2 := by + let μ := sharedConditionedPairLaw ν ℓ x y + have hae := selectedBoundaryAtom_fiber_ae μ ℓ B x y + (sharedConditionedPairLaw_noDrop ν ℓ x y) hS F + have hmap : (μ.restrict (selectedBoundaryData ℓ B ⁻¹' {F})).map (selectedBoundarySuffix ℓ B) = + (μ.restrict (selectedBoundaryData ℓ B ⁻¹' {F})).map (commonPairSuffix F.1.1 F.1.2) := by + apply Measure.map_congr + filter_upwards [ae_restrict_mem ((measurable_selectedBoundaryData ℓ B) + (measurableSet_singleton F))] with P hP + have ht := selectedBoundaryData_times ℓ B P F hP + simp only [selectedBoundarySuffix,ht] + change (μ.restrict (selectedBoundaryData ℓ B ⁻¹' {F})).map _ = _ + rw [hmap,Measure.restrict_congr_set hae,measure_congr hae] + exact shared_selectedBoundaryAtom_map ν hue ℓ hℓ htrans B x y _ _ _ _ + +lemma lintegral_countable_restart_dependent {Ω I S : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + [MeasurableSpace S] [Countable I] [MeasurableSingletonClass I] + (μ : Measure Ω) (D : Ω → I) (Y : Ω → S) (κ : I → Measure S) + (hD : Measurable D) (hY : Measurable Y) + (hrestart : ∀ i, (μ.restrict (D ⁻¹' {i})).map Y = μ (D ⁻¹' {i}) • κ i) + (g : I → S → ℝ≥0∞) (hg : ∀ i, Measurable (g i)) : + (∫⁻ a, g (D a) (Y a) ∂μ) = ∫⁻ a, (∫⁻ z, g (D a) z ∂κ (D a)) ∂μ := by + rw [lintegral_partition_countable μ D hD,lintegral_partition_countable μ D hD] + apply tsum_congr + intro i + have ha : ∀ᵐ a ∂μ.restrict (D ⁻¹' {i}), D a = i := + ae_restrict_mem (hD (measurableSet_singleton i)) + calc + (∫⁻ a in D ⁻¹' {i}, g (D a) (Y a) ∂μ) = + ∫⁻ a in D ⁻¹' {i}, g i (Y a) ∂μ := + lintegral_congr_ae (ha.mono fun a ha => by dsimp only; rw [ha]) + _ = ∫⁻ z, g i z ∂(μ.restrict (D ⁻¹' {i})).map Y := by + rw [lintegral_map (hg i) hY] + _ = μ (D ⁻¹' {i}) * ∫⁻ z, g i z ∂κ i := by + rw [hrestart i,lintegral_smul_measure,smul_eq_mul] + _ = ∫⁻ a in D ⁻¹' {i}, (∫⁻ z, g i z ∂κ i) ∂μ := by + rw [lintegral_const,Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] + exact mul_comm _ _ + _ = ∫⁻ a in D ⁻¹' {i}, (∫⁻ z, g (D a) z ∂κ (D a)) ∂μ := + lintegral_congr_ae (ha.mono fun a ha => by dsimp only; rw [ha]) + +theorem shared_selected_jointPast_restart {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) + (x y : Lattice d) (hxy : height x = height y) (H : ℕ) (hH : 0 < H) + (B : Lattice d × Lattice d → Prop) + (hB : ∀ z w, height x+H ≤ height z → B (z,w)) + (g : BoundaryData d → (Path d × Path d) → ℝ≥0∞) + (hg : ∀ F, Measurable (g F)) : + (∫⁻ P, g (selectedBoundaryData ℓ B P) (selectedBoundarySuffix ℓ B P) + ∂sharedConditionedPairLaw ν ℓ x y) = + ∫⁻ P, (∫⁻ Q, g (selectedBoundaryData ℓ B P) Q + ∂sharedConditionedPairLaw ν ℓ (selectedBoundaryData ℓ B P).endpoints.1 + (selectedBoundaryData ℓ B P).endpoints.2) + ∂sharedConditionedPairLaw ν ℓ x y := by + exact lintegral_countable_restart_dependent _ _ _ _ (measurable_selectedBoundaryData ℓ B) + (measurable_selectedBoundarySuffix ℓ B) + (shared_selectedBoundaryData_map ν hue ℓ hℓ htrans x y B + (shared_selectedBoundaryTimes_spec ν hue ℓ hℓ htrans height hproj hstep x y hxy H hH B hB)) g hg + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SelectedEndpointMoment.lean b/lean/OAI/Probability/Ballisticity/Estimates/SelectedEndpointMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d51d4c8b8d0483c13acfc601447dab932e209c3 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SelectedEndpointMoment.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CurveEndpointLaw + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +noncomputable def selectedEndpointLaw {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (N E : Set Ω) (Y : Ω → ℝ) (b : ℝ) (failure strict : Prop) + [Decidable failure] [Decidable strict] : Measure ℝ := + if failure then Measure.dirac b else (μ[|if strict then E else N]).map Y + +lemma capped_selection_moment {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (W Y : Ω → ℝ) + (hW : Measurable W) (hY : Measurable Y) {b A B : ℝ} + (hA : 0 ≤ A) (hAB : A < B) (hW0 : ∀ x, 0 ≤ W x) + (hYW : ∀ x, |Y x-b| ≤ W x) (hN : μ {x | W x ≤ B} ≠ 0) : + (∫ x, (Y x-b)^2 ∂μ[|{x | W x ≤ B}]) ≤ A^2+ + 2*∫ x, if A < W x then (min (W x) B)^2 else 0 ∂μ := by + let N := {x | W x ≤ B} + let F := fun x => (Y x-b)^2 + let G := fun x => if A < W x then (min (W x) B)^2 else 0 + have hB : 0 ≤ B := hA.trans hAB.le + apply conditional_selection_moment μ N (measurableSet_le hW measurable_const) hN F G + (by fun_prop) (by exact Measurable.ite (measurableSet_lt measurable_const hW) (by fun_prop) measurable_const) + (sq_nonneg A) (sq_nonneg B) + · intro x; exact sq_nonneg _ + · intro x hx + have hh := (hYW x).trans hx + nlinarith [sq_abs (Y x-b),sq_nonneg (B-|Y x-b|),abs_nonneg (Y x-b)] + · intro x; dsimp [G]; split_ifs <;> positivity + · intro x + dsimp [G] + split_ifs + · have hm0 : 0 ≤ min (W x) B := le_min (hW0 x) hB + have hmB : min (W x) B ≤ B := min_le_right _ _ + nlinarith + · positivity + · intro x hx + have hx' : B < W x := lt_of_not_ge hx + simp [G,hAB.trans hx',min_eq_right hx'.le] + · intro x hx + dsimp [F,G] + by_cases hax : A < W x + · rw [ite_eq_left hax,min_eq_left hx] + have hh := hYW x + nlinarith [sq_abs (Y x-b),sq_nonneg (W x-|Y x-b|),abs_nonneg (Y x-b),sq_nonneg A] + · rw [ite_eq_right hax] + have hh := (hYW x).trans (le_of_not_gt hax) + nlinarith [sq_abs (Y x-b),sq_nonneg (A-|Y x-b|),abs_nonneg (Y x-b)] + +lemma conditional_bounded_square {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (E : Set Ω) (hE : MeasurableSet E) (hμE : μ E ≠ 0) + (hμEtop : μ E ≠ ∞) (Y : Ω → ℝ) (hY : Measurable Y) {b ρ : ℝ} + (hρ : 0 ≤ ρ) (hbound : ∀ x ∈ E, |Y x-b| ≤ ρ) : + (∫ x, (Y x-b)^2 ∂μ[|E]) ≤ ρ^2 := by + let : IsProbabilityMeasure μ[|E] := ⟨by simp [ProbabilityTheory.cond,Measure.smul_apply, + ENNReal.inv_mul_cancel hμE hμEtop]⟩ + have hb : ∀ᵐ x ∂μ[|E], (Y x-b)^2 ≤ ρ^2 := by + filter_upwards [ae_cond_mem hE] with x hx + have hh := hbound x hx + nlinarith [sq_abs (Y x-b),sq_nonneg (ρ-|Y x-b|),abs_nonneg (Y x-b)] + have hi : Integrable (fun x => (Y x-b)^2) μ[|E] := + Integrable.of_bound (by fun_prop) (ρ^2) (hb.mono fun x hx => by simpa using hx) + simpa using integral_mono_ae hi (integrable_const (ρ^2)) hb + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma selectedEndpointLaw_probability {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (N E : Set Ω) (Y : Ω → ℝ) (hY : Measurable Y) + (b : ℝ) (failure strict : Prop) [Decidable failure] [Decidable strict] + (hN : μ N ≠ 0) (hNt : μ N ≠ ∞) (hE : strict → μ E ≠ 0) + (hEt : μ E ≠ ∞) : IsProbabilityMeasure (selectedEndpointLaw μ N E Y b failure strict) := by + by_cases hf : failure + · simp only [selectedEndpointLaw,ite_eq_left hf] + infer_instance + simp only [selectedEndpointLaw,ite_eq_right hf] + have hn : μ (if strict then E else N) ≠ 0 := by + by_cases hs : strict + · simpa only [ite_eq_left hs] using hE hs + · simpa only [ite_eq_right hs] using hN + have ht : μ (if strict then E else N) ≠ ∞ := by + by_cases hs : strict + · simpa only [ite_eq_left hs] using hEt + · simpa only [ite_eq_right hs] using hNt + let : IsProbabilityMeasure μ[|if strict then E else N] := ⟨by + simpa only [ProbabilityTheory.cond,Measure.smul_apply,Measure.restrict_apply_univ,smul_eq_mul] + using ENNReal.inv_mul_cancel hn ht⟩ + exact (Measure.isProbabilityMeasure_map_iff hY.aemeasurable).2 inferInstance + +lemma selectedEndpointLaw_moment {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (W Y : Ω → ℝ) + (hW : Measurable W) (hY : Measurable Y) (E : Set Ω) (hE : MeasurableSet E) + {b A B ρ : ℝ} (hA : 0 ≤ A) (hAB : A < B) (hρ : 0 ≤ ρ) + (hW0 : ∀ x, 0 ≤ W x) (hYW : ∀ x, |Y x-b| ≤ W x) + (failure strict : Prop) [Decidable failure] [Decidable strict] + (hN : μ {x | W x ≤ B} ≠ 0) (hμE : strict → μ E ≠ 0) + (hbound : ∀ x ∈ E, |Y x-b| ≤ ρ) : + (∫ u, (u-b)^2 ∂selectedEndpointLaw μ {x | W x ≤ B} E Y b failure strict) ≤ + ρ^2+(if strict then 0 else A^2)+ + 2*(∫ x, if A < W x then (min (W x) B)^2 else 0 ∂μ) := by + have htail : 0 ≤ ∫ x, if A < W x then (min (W x) B)^2 else 0 ∂μ := + integral_nonneg fun x => by split_ifs <;> positivity + by_cases hf : failure + · simp only [selectedEndpointLaw,ite_eq_left hf,integral_dirac,sub_self,zero_pow (by decide : 2 ≠ 0)] + split_ifs <;> positivity + simp only [selectedEndpointLaw,ite_eq_right hf] + by_cases hs : strict + · simp only [ite_eq_left hs] + rw [integral_map hY.aemeasurable (by fun_prop)] + have hh := conditional_bounded_square μ E hE (hμE hs) (measure_ne_top _ _) Y hY hρ hbound + linarith + · simp only [ite_eq_right hs] + rw [integral_map hY.aemeasurable (by fun_prop)] + have hh := capped_selection_moment μ W Y hW hY hA hAB hW0 hYW hN + nlinarith [sq_nonneg ρ] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedConditionedContactBound.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedConditionedContactBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..d077b35429671534b54441a4a59d3441e050b290 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedConditionedContactBound.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SurvivingLane + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem shared_conditioned_contact_bound {d : ℕ} (ν : Measure (Row d)) + (ℓ : Vector d) (x y : Lattice d) (hxy : dot (realPosition x) ℓ = dot (realPosition y) ℓ) + (T A B : Set (Lattice d)) (hAB : Disjoint A B) : + let U := {z | dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ} + sharedConditionedPairLaw ν ℓ x y (PrefixContact (U \ T)) ≤ + 2 * (sharedConditionedPairLaw ν ℓ x y (Prod.fst ⁻¹' (SurvivingLane U T A)ᶜ) + + sharedConditionedPairLaw ν ℓ x y (Prod.snd ⁻¹' (SurvivingLane U T B)ᶜ)) := by + let U := {z | dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ} + have hx : NoDrop ℓ x = Stay U := rfl + have hy : NoDrop ℓ y = Stay U := by unfold NoDrop Stay U; rw [← hxy]; rfl + have hA := measurableSet_survivingLane U T A + have hB := measurableSet_survivingLane U T B + change _ ≤ 2*(_+_) + rw [sharedConditionedPairLaw,Measure.smul_apply,Measure.restrict_apply (measurableSet_prefixContact _)] + rw [Measure.smul_apply,Measure.restrict_apply (hA.compl.preimage measurable_fst), + Measure.smul_apply,Measure.restrict_apply (hB.compl.preimage measurable_snd),hx,hy] + have heA : Prod.fst ⁻¹' (SurvivingLane U T A)ᶜ ∩ (Stay U ×ˢ Stay U) = + (Stay U \ SurvivingLane U T A) ×ˢ Stay U := by ext Z; change (¬_ ∧ _ ∧ _) ↔ ((_ ∧ ¬_) ∧ _); tauto + have heB : Prod.snd ⁻¹' (SurvivingLane U T B)ᶜ ∩ (Stay U ×ˢ Stay U) = + Stay U ×ˢ (Stay U \ SurvivingLane U T B) := by ext Z; change (¬_ ∧ _ ∧ _) ↔ (_ ∧ _ ∧ ¬_); tauto + rw [heA,heB] + simp only [smul_eq_mul] + calc + _ ≤ (sharedNoDropMass ν ℓ x y)⁻¹ * (2*(sharedPairLaw ν x y + ((Stay U \ SurvivingLane U T A) ×ˢ Stay U) + sharedPairLaw ν x y + (Stay U ×ˢ (Stay U \ SurvivingLane U T B)))) := + mul_le_mul_right (shared_pair_contact_bound ν x y U T A B hAB) _ + _ = _ := by ring + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedConditionedPairLawFst.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedConditionedPairLawFst.lean new file mode 100644 index 0000000000000000000000000000000000000000..05ced23dbb2783237469057486861af75169604f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedConditionedPairLawFst.lean @@ -0,0 +1,313 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RecordMedianSlope +import OAI.Probability.Ballisticity.Walk.RecordLinearPath + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma sharedConditionedPairLaw_fst {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (y : Lattice d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) : + (sharedConditionedPairLaw ν ℓ 0 y).map Prod.fst = + normalizedMeasure (weightedConditioned ν ℓ (noDropQuenched ℓ y)) := by + ext A hA + rw [Measure.map_apply measurable_fst hA,sharedConditionedPairLaw,Measure.smul_apply, + Measure.restrict_apply (hA.preimage measurable_fst)] + have he : Prod.fst ⁻¹' A ∩ (NoDrop ℓ 0 ×ˢ NoDrop ℓ y) = + (A ∩ NoDrop ℓ 0) ×ˢ NoDrop ℓ y := by ext Z; exact and_assoc.symm + rw [he,sharedPairLaw_rectangle ν 0 y _ _ (hA.inter (measurableSet_noDrop ℓ 0)) + (measurableSet_noDrop ℓ y),normalizedMeasure,Measure.smul_apply, + weightedConditioned_noDrop_mass,weightedConditioned_apply ν ℓ _ (measurable_noDropQuenched ℓ y) A hA] + simp only [smul_eq_mul] + have hc : (((annealedLaw ν (NoDrop ℓ 0))⁻¹ * sharedNoDropMass ν ℓ 0 y)⁻¹ * + (annealedLaw ν (NoDrop ℓ 0))⁻¹) = (sharedNoDropMass ν ℓ 0 y)⁻¹ := by + rw [ENNReal.mul_inv (Or.inl (ENNReal.inv_ne_zero.mpr (measure_ne_top _ _))) + (Or.inl (ENNReal.inv_ne_top.mpr hp)),inv_inv,mul_right_comm, + ENNReal.mul_inv_cancel hp (measure_ne_top _ _),one_mul] + rw [← mul_assoc,hc] + congr 1 + apply lintegral_congr + intro ω + exact mul_comm _ _ + +lemma sharedPairLaw_swap {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x y : Lattice d) : (sharedPairLaw ν x y).map Prod.swap = sharedPairLaw ν y x := by + apply Measure.ext_prod + intro A B hA hB + rw [Measure.map_apply measurable_swap (hA.prod hB)] + have he : Prod.swap ⁻¹' (A ×ˢ B) = B ×ˢ A := by ext Z; exact and_comm + rw [he,sharedPairLaw_rectangle ν x y B A hB hA,sharedPairLaw_rectangle ν y x A B hA hB] + apply lintegral_congr + intro ω + exact mul_comm _ _ + +lemma sharedNoDropMass_swap {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (x y : Lattice d) : sharedNoDropMass ν ℓ x y = sharedNoDropMass ν ℓ y x := by + unfold sharedNoDropMass + apply lintegral_congr + intro ω + exact mul_comm _ _ + +lemma sharedConditionedPairLaw_swap {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) : + (sharedConditionedPairLaw ν ℓ x y).map Prod.swap = sharedConditionedPairLaw ν ℓ y x := by + have he : Prod.swap ⁻¹' (NoDrop ℓ y ×ˢ NoDrop ℓ x) = NoDrop ℓ x ×ˢ NoDrop ℓ y := by + ext Z; exact and_comm + rw [sharedConditionedPairLaw,Measure.map_smul _ measurable_swap.aemeasurable,← he,← Measure.restrict_map measurable_swap + ((measurableSet_noDrop ℓ y).prod (measurableSet_noDrop ℓ x)),sharedPairLaw_swap, + sharedNoDropMass_swap] + rfl + +lemma sharedPairLaw_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (z x y : Lattice d) : + (sharedPairLaw ν (z+x) (z+y)).map + (fun Z : Path d × Path d => ((fun j => Z.1 j-z),(fun j => Z.2 j-z))) = sharedPairLaw ν x y := by + have hm : Measurable (fun X : Path d => fun j => X j-z) := by fun_prop + have hpair : Measurable (fun Z : Path d × Path d => ((fun j => Z.1 j-z),(fun j => Z.2 j-z))) := by fun_prop + apply Measure.ext_prod + intro A B hA hB + rw [Measure.map_apply hpair (hA.prod hB)] + have he : (fun Z : Path d × Path d => ((fun j => Z.1 j-z),(fun j => Z.2 j-z))) ⁻¹' (A ×ˢ B) = + ((fun X : Path d => fun j => X j-z) ⁻¹' A) ×ˢ ((fun X : Path d => fun j => X j-z) ⁻¹' B) := rfl + rw [he,sharedPairLaw_rectangle ν (z+x) (z+y) _ _ (hA.preimage hm) (hB.preimage hm), + sharedPairLaw_rectangle ν x y A B hA hB] + have ht (ω : Environment d) (a : Lattice d) (C : Set (Path d)) (hC : MeasurableSet C) : + quenchedKernel (ω,z+a) ((fun X : Path d => fun j => X j-z) ⁻¹' C) = + quenchedKernel ((fun b => ω (z+b)),a) C := by + rw [← Measure.map_apply hm hC,quenched_translation] + simp_rw [ht _ x A hA,ht _ y B hB] + have henv : Measurable (fun ω : Environment d => fun b => ω (z+b)) := by fun_prop + have hprod : Measurable (fun ω : Environment d => quenchedKernel (ω,x) A * quenchedKernel (ω,y) B) := + ((Kernel.measurable_coe _ hA).comp (measurable_id.prodMk measurable_const)).mul + ((Kernel.measurable_coe _ hB).comp (measurable_id.prodMk measurable_const)) + rw [← lintegral_map hprod henv,environment_translation] + +lemma sharedNoDropMass_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (z x y : Lattice d) : + sharedNoDropMass ν ℓ (z+x) (z+y) = sharedNoDropMass ν ℓ x y := by + rw [sharedNoDropMass_eq,sharedNoDropMass_eq,← sharedPairLaw_translation ν z x y, + Measure.map_apply (by fun_prop) ((measurableSet_noDrop ℓ x).prod (measurableSet_noDrop ℓ y))] + congr 1 + change NoDrop ℓ (z+x) ×ˢ NoDrop ℓ (z+y) = + ((fun X : Path d => fun j => X j-z) ⁻¹' NoDrop ℓ x) ×ˢ + ((fun X : Path d => fun j => X j-z) ⁻¹' NoDrop ℓ y) + rw [noDrop_translation,noDrop_translation] + +lemma sharedConditionedPairLaw_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (z x y : Lattice d) : + (sharedConditionedPairLaw ν ℓ (z+x) (z+y)).map + (fun Z : Path d × Path d => ((fun j => Z.1 j-z),(fun j => Z.2 j-z))) = + sharedConditionedPairLaw ν ℓ x y := by + have hm : Measurable (fun Z : Path d × Path d => ((fun j => Z.1 j-z),(fun j => Z.2 j-z))) := by fun_prop + have he : (fun Z : Path d × Path d => ((fun j => Z.1 j-z),(fun j => Z.2 j-z))) ⁻¹' + (NoDrop ℓ x ×ˢ NoDrop ℓ y) = NoDrop ℓ (z+x) ×ˢ NoDrop ℓ (z+y) := by + change ((fun X : Path d => fun j => X j-z) ⁻¹' NoDrop ℓ x) ×ˢ + ((fun X : Path d => fun j => X j-z) ⁻¹' NoDrop ℓ y) = _ + rw [noDrop_translation,noDrop_translation] + rw [sharedConditionedPairLaw,Measure.map_smul _ hm.aemeasurable,← he,← Measure.restrict_map hm + ((measurableSet_noDrop ℓ x).prod (measurableSet_noDrop ℓ y)),sharedPairLaw_translation, + sharedNoDropMass_translation] + rfl + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma tendstoInDistribution_pullback {Ω Ω' E E' : Type*} [MeasurableSpace Ω] + [MeasurableSpace Ω'] [MeasurableSpace E'] [MeasurableSpace E] [TopologicalSpace E] + [OpensMeasurableSpace E] (μ : ℕ → Measure Ω) (η : ℕ → Measure Ω') + [∀ i, IsProbabilityMeasure (μ i)] [∀ i, IsProbabilityMeasure (η i)] + (S : ℕ → Ω → Ω') (hS : ∀ i, Measurable (S i)) (hm : ∀ i, (μ i).map (S i) = η i) + (F : ℕ → Ω' → E) (hF : ∀ i, Measurable (F i)) (G : E' → E) + (W : Measure E') [IsProbabilityMeasure W] + (hlim : TendstoInDistribution F atTop G η W) : + TendstoInDistribution (fun i => F i ∘ S i) atTop G μ W := by + refine ⟨fun i => ((hF i).comp (hS i)).aemeasurable,hlim.aemeasurable_limit,?_⟩ + apply hlim.tendsto.congr' + apply Eventually.of_forall + intro i + apply Subtype.ext + change (η i).map (F i) = (μ i).map (F i ∘ S i) + rw [← Measure.map_map (hF i) (hS i),hm] + +lemma sharedNoDropMass_pos {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) : + 0 < sharedNoDropMass ν ℓ x y := by + obtain ⟨c,hc,hm⟩ := sharedNoDropMass_uniform_positive ν hue ℓ hℓ htrans + exact hc.trans_le (hm x y) + +lemma distribution_sequence_tight {Ω E Ω' : Type*} [MeasurableSpace Ω] [MeasurableSpace Ω'] + [MetricSpace E] [CompleteSpace E] [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (X : ℕ → Ω → E) (G : Ω' → E) (W : Measure Ω') [IsProbabilityMeasure W] + (h : TendstoInDistribution X atTop G μ W) : + IsTightMeasureSet (Set.range (fun i => (μ i).map (X i))) := by + let A : ℕ → ProbabilityMeasure E := fun i => ⟨(μ i).map (X i), inferInstance⟩ + let B : ProbabilityMeasure E := ⟨W.map G, inferInstance⟩ + have hh : Tendsto A atTop (𝓝 B) := h.tendsto + have ht := weak_sequence_tight (E := E) (μ := A) (ν := B) hh + exact ht + +theorem shared_first_zero_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + (∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw (T/(2*commonMeanWidth ν ℓ)) I) ∧ + ∀ y : ℕ → Lattice d, (∀ i, signedHeight e (y i) = 0) → + letI : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ 0 (y i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ 0 (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans 0 (y i))) + TendstoInDistribution (fun i Z => recordLinearPath ℓ f + (recordMedianSlope ν ℓ hp f (r i)) (r i) + (fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i)) T Z.1) + atTop id (fun i => sharedConditionedPairLaw ν ℓ 0 (y i)) W := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + let θ i := recordMedianSlope ν ℓ hp f (r i) + let n i := fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + obtain ⟨W,hW,hWf⟩ := transverse_firstHit_linear_path_limit ν hue e f hef htrans r hr hT + obtain ⟨W',hW',_⟩ := transverse_firstHit_linear_path_limit ν hue e f hef htrans r hr (show 0 ≤ T+1 by linarith) + have ht : IsTightMeasureSet (Set.range (fun i => (conditionedLaw ν ℓ).map + (recordLinearPath ℓ f (θ i) (r i) (n i) (T+1)))) := by + have hh := distribution_sequence_tight _ _ _ _ hW' + change IsTightMeasureSet (Set.range (fun i => (conditionedLaw ν ℓ).map + (fun X => heightPolygon (fun h => signedCoordinate f (recordIndexPosition ℓ h X)- + (h:ℝ)*θ i) (r i) (n i) (T+1)))) + exact hh + refine ⟨W,hWf,?_⟩ + intro y hy + let : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ 0 (y i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ 0 (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans 0 (y i))) + obtain ⟨c₀,hc₀,hc₀m⟩ := sharedNoDropMass_uniform_positive ν hue ℓ (signed_direction_unit e) htrans + let c := (annealedLaw ν (NoDrop ℓ 0))⁻¹*c₀ + have hc : 0 < c := ENNReal.mul_pos (ENNReal.inv_ne_zero.mpr (measure_ne_top _ _)) hc₀.ne' + have hcmass (i : ℕ) : c ≤ weightedConditioned ν ℓ (noDropQuenched ℓ (y i)) Set.univ := by + rw [weightedConditioned_noDrop_mass] + exact mul_le_mul_right (hc₀m 0 (y i)) _ + let μ i := normalizedMeasure (weightedConditioned ν ℓ (noDropQuenched ℓ (y i))) + let : ∀ i, IsFiniteMeasure (weightedConditioned ν ℓ (noDropQuenched ℓ (y i))) := fun i => + weightedConditioned_finite ν ℓ _ (measurable_noDropQuenched ℓ (y i)) (fun _ => prob_le_one) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => normalizedMeasure_probability _ + (ne_of_gt (hc.trans_le (hcmass i))) + have hlim := noDropWeighted_recordLinearPath_limit ν e f htrans θ r n hr.1 + (recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1) + (recordMedianSlope_small ν hue e f hef htrans r hr) hT ht W hW y hy c hc hcmass + exact tendstoInDistribution_pullback (fun i => sharedConditionedPairLaw ν ℓ 0 (y i)) μ + (fun _ => Prod.fst) (fun _ => measurable_fst) (fun i => sharedConditionedPairLaw_fst ν ℓ (y i) hp) + (fun i => recordLinearPath ℓ f (θ i) (r i) (n i) T) + (fun i => measurable_recordLinearPath _ _ _ _ _ _) id W hlim + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedEndpointOverlapRight.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedEndpointOverlapRight.lean new file mode 100644 index 0000000000000000000000000000000000000000..fda23b266e6b01c236cd30f10d1db482d4cb2973 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedEndpointOverlapRight.lean @@ -0,0 +1,390 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MeasureAdd +import OAI.Probability.Ballisticity.Estimates.EndpointPrefixConditionedReal + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma shared_endpoint_overlap_right {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) (H : ℕ) (A B : Set (Lattice d)) + {δ α β : ℝ} (hδ : 0 ≤ δ) + (hmean : α ≤ (annealedFrom ν y).real (EndpointPrefix ℓ y H B)) + (hbad : (environmentLaw ν).real {ω | (quenchedKernel (ω,x)).real (EndpointPrefix ℓ x H A) < δ} ≤ β) : + δ*(α-β) ≤ (sharedPairLaw ν x y).real + (EndpointPrefix ℓ x H A ×ˢ EndpointPrefix ℓ y H B) := by + have hh := shared_endpoint_overlap ν ℓ y x H B A hδ hmean hbad + rw [sharedPairLaw_real_rectangle ν y x _ _ (measurableSet_endpointPrefix ℓ y H B) + (measurableSet_endpointPrefix ℓ x H A)] at hh + rw [sharedPairLaw_real_rectangle ν x y _ _ (measurableSet_endpointPrefix ℓ x H A) + (measurableSet_endpointPrefix ℓ y H B)] + simpa only [mul_comm] using hh + +theorem bad_radius_raw_gap_growth {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) {l ε : ℝ} + (hl : 0 < l) (hl1 : l ≤ 1) (hε : 0 < ε) + (hbad : ∀ᶠ i in atTop, + ε ≤ fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)* + (independentConditionedPairLaw ν (realPosition (step e))).real + {P | l*r i < |commonIncrementProcess (realPosition (step e)) f 0 P|}) : + ∃ t q : ℝ, 0 < t ∧ 0 < q ∧ ∀ᶠ i in atTop, + let ℓ := realPosition (step e) + let H := ⌊t*fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ f 0) (r i)⌋₊ + 0 < H ∧ ∀ x y : Lattice d, signedHeight e x=signedHeight e y → + q ≤ (sharedPairLaw ν x y).real (layerPairEvent ℓ (signedHeight e) x y + (signedHeight e x+H) {uv | |signedCoordinate f x-signedCoordinate f y|+l*r i/16 < + |signedCoordinate f uv.1-signedCoordinate f uv.2|}) := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let n := fun i => fluctuationScale μ S (r i) + let c := commonMeanWidth ν ℓ + have hc : 0 < c := zero_lt_one.trans_le (commonMeanWidth_ge_one ν ℓ htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν).real (NoDrop ℓ 0) + have hp0 : 0 < p := ENNReal.toReal_pos hp (measure_ne_top _ _) + let μ₁ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ₁ := conditionedLaw_probability ν ℓ hp + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + let b := fun j => (recordMedian ν ℓ hp f j:ℝ) + let a := p*ε/(64*c) + have ha : 0 < a := by positivity + obtain ⟨C,hC,t₀,ht₀,hsurv⟩ := short_block_survival ν hue e f hef htrans (show 0 < l/24 by positivity) + let t := min t₀ (min (c*l^2/4) (a/(2*C))) + have ht : 0 < t := lt_min ht₀ (lt_min (by positivity) (by positivity)) + have htt : t ≤ t₀ := min_le_left _ _ + have htc : t ≤ c*l^2/4 := (min_le_right _ _).trans (min_le_left _ _) + have hta : t ≤ a/(2*C) := (min_le_right _ _).trans (min_le_right _ _) + have hCt : C*t ≤ a/2 := by + have hh := (le_div_iff₀ (show 0 < 2*C by positivity)).mp hta + nlinarith + obtain ⟨δ,hδ,R,hR,hsurv⟩ := hsurv t ht htt + let q := δ*(a*t/2) + have hq : 0 < q := by positivity + refine ⟨t,q,ht,hq,?_⟩ + have hspread := transverse_bad_radius_spread ν hue e f hef htrans r hr hl hl1 hε ht htc hbad + have hI := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn := (fluctuationScale_tendsto μ S (measurable_commonIncrementProcess ℓ f 0) hI hne).comp hr + filter_upwards [hspread,hr.eventually (eventually_ge_atTop R), + hn.eventually (eventually_ge_atTop (2/t))] with i hspread hri hni + let H := ⌊t*n i⌋₊ + have hscale : (H:ℝ) ≤ t*n i := Nat.floor_le (mul_nonneg ht.le (fluctuationScale_nonneg μ S (r i))) + change 2/t ≤ n i at hni + have htn : 2 ≤ t*n i := by + have hh := (div_le_iff₀ ht).mp hni + nlinarith + have hH : 0 < H := by + have hh := Nat.lt_floor_add_one (t*n i) + change t*n i < (H:ℝ)+1 at hh + have : (0:ℝ) < H := by linarith + exact_mod_cast this + have hri0 : 0 < r i := hR.trans_le hri + have hspread' : t*ε/(16*c) ≤ (μ₁.prod μ₁).real + {P | 2*(l*r i/8) < |signedCoordinate f (recordIndexPosition ℓ H P.1)- + signedCoordinate f (recordIndexPosition ℓ H P.2)|} := by + have he : 2*(l*r i/8)=l*r i/4 := by ring + simpa only [he,firstHitPairGap,independentConditionedPairLaw,μ₁,ℓ,H,n,μ,c,S] using hspread + obtain ⟨s,hs,hdev⟩ := scalar_pair_tail_one_side μ₁ + (fun X => signedCoordinate f (recordIndexPosition ℓ H X)) (b H) (l*r i/8) + (t*ε/(16*c)) hspread' + have hmean (x : Lattice d) : a*t ≤ (annealedFrom ν x).real + (EndpointPrefix ℓ x H {z | l*r i/8 < s*(signedCoordinate f (z-x)-b H)}) := by + have hh := endpointPrefix_conditioned_real ν e htrans x hH + {z | l*r i/8 < s*(signedCoordinate f z-b H)} + have hh' := mul_le_mul_of_nonneg_left hdev hp0.le + have he : p*(t*ε/(16*c)/4)=a*t := by dsimp [a]; ring + rw [he] at hh' + exact hh'.trans hh + have hbadsite (x : Lattice d) : (environmentLaw ν).real + {ω | (quenchedKernel (ω,x)).real (EndpointPrefix ℓ x H + {z | |signedCoordinate f (z-x)-b H| ≤ l*r i/24}) < δ} ≤ C*t^2 := by + have htube := hsurv (r i) hri H hH hscale (signedHeight e x) (Measure.dirac x) + inferInstance (by simp) + have hle := endpointPrefix_bad_le_tube_bad ν e f b hH (l*r i/24) δ x + have he : l/24*r i=l*r i/24 := by ring + rw [he] at htube + exact hle.trans htube + refine ⟨hH,?_⟩ + intro x y hxy + let D := fun x : Lattice d => {z | l*r i/8 < s*(signedCoordinate f (z-x)-b H)} + let G := fun x : Lattice d => {z | |signedCoordinate f (z-x)-b H| ≤ l*r i/24} + let E := {uv : Lattice d × Lattice d | + |signedCoordinate f x-signedCoordinate f y|+l*r i/16 < |signedCoordinate f uv.1-signedCoordinate f uv.2|} + have hqle : q ≤ δ*(a*t-C*t^2) := by + dsimp [q] + have hh := mul_le_mul_of_nonneg_right hCt ht.le + nlinarith [mul_nonneg hδ.le (show 0 ≤ a*t-C*t^2-a*t/2 by nlinarith)] + by_cases horder : 0 ≤ s*(signedCoordinate f x-signedCoordinate f y) + · have hover := shared_endpoint_overlap ν ℓ x y H (D x) (G y) hδ.le (hmean x) (hbadsite y) + have hAB : D x ×ˢ G y ⊆ E := by + rintro ⟨u,v⟩ ⟨hu,hv⟩ + have hv' : |signedCoordinate f (v-y)-b H| ≤ (l*r i/8)/3 := by dsimp [G] at hv; convert hv using 1; ring + have hh := favorable_endpoint_gap f x y u v (b H) (l*r i/8) hs horder hu hv' + dsimp [E] + convert hh using 1; ring + exact (hqle.trans hover).trans (ENNReal.toReal_mono (measure_ne_top _ _) + (endpoint_rectangle_le_layerPair ν e htrans x y hxy hH (D x) (G y) E hAB)) + · have horder' : 0 ≤ s*(signedCoordinate f y-signedCoordinate f x) := by nlinarith + have hover := shared_endpoint_overlap_right ν ℓ x y H (G x) (D y) hδ.le (hmean y) (hbadsite x) + have hAB : G x ×ˢ D y ⊆ E := by + rintro ⟨u,v⟩ ⟨hu,hv⟩ + have hu' : |signedCoordinate f (u-x)-b H| ≤ (l*r i/8)/3 := by dsimp [G] at hu; convert hu using 1; ring + have hh := favorable_endpoint_gap f y x v u (b H) (l*r i/8) hs horder' hv hu' + rw [abs_sub_comm (signedCoordinate f y),abs_sub_comm (signedCoordinate f v)] at hh + dsimp [E] + convert hh using 1; ring + exact (hqle.trans hover).trans (ENNReal.toReal_mono (measure_ne_top _ _) + (endpoint_rectangle_le_layerPair ν e htrans x y hxy hH (G x) (D y) E hAB)) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedEndpointTests.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedEndpointTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..c48cbb0cfd245e288a5ffc3206045179e10cc86a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedEndpointTests.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BoundaryDecorrelation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +noncomputable def centeredFirstHit {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ r : ℝ) (k : ℕ) (x : Lattice d) (X : Path d) : ℝ := + (signedCoordinate f (recordIndexPosition ℓ k (fun j => X j-x))-(k:ℝ)*θ)/r + +lemma measurable_centeredFirstHit {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ r : ℝ) (k : ℕ) (x : Lattice d) : Measurable (centeredFirstHit ℓ f θ r k x) := by + apply Measurable.div_const + apply Measurable.sub_const + exact ((measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ k)).comp (by fun_prop) + +theorem shared_endpoint_tests_uniform {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (hn : ∀ i, 0 < fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (T : ℝ) (hT : 0 < T) (k : ℕ → ℕ) + (hk : ∀ i, (k i:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (t : ℝ) (hkt : Tendsto (fun i => (k i:ℝ)/fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) atTop (𝓝 t)) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let Z := fun i => centeredFirstHit ℓ f (recordMedianSlope ν ℓ hp f (r i)) (r i) (k i) + ∀ G : ℝ →ᵇ ℝ, ∀ ε > 0, ∀ᶠ i in atTop, + ∀ x y : Lattice d, signedHeight e x = signedHeight e y → + |(∫ P, G (Z i x P.1) ∂sharedConditionedPairLaw ν ℓ x y)- + (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))| < ε ∧ + |(∫ P, G (Z i y P.2) ∂sharedConditionedPairLaw ν ℓ x y)- + (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))| < ε := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let V := 1/(2*commonMeanWidth ν ℓ) + obtain ⟨W,hW,hlim⟩ := shared_path_marginal_limits ν hue e f hef htrans r hr hT.le + have hw (I : Finset unitInterval) : (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (T*V) I := by + simpa only [V,mul_one_div] using hW I + intro G ε hε + let A := {p : Lattice d × Lattice d // signedHeight e p.1 = signedHeight e p.2} + let : Nonempty A := ⟨⟨(0,0),rfl⟩⟩ + have hh : ∀ᶠ i in atTop, ∀ p : A, + |(∫ P, G (centeredFirstHit ℓ f (θ i) (r i) (k i) p.val.1 P.1) + ∂sharedConditionedPairLaw ν ℓ p.val.1 p.val.2)- + (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))| < ε ∧ + |(∫ P, G (centeredFirstHit ℓ f (θ i) (r i) (k i) p.val.2 P.2) + ∂sharedConditionedPairLaw ν ℓ p.val.1 p.val.2)- + (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))| < ε := by + apply uniform_eventually_of_all_sequences + intro p + let μ := fun i => sharedConditionedPairLaw ν ℓ (p i).val.1 (p i).val.2 + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => sharedConditionedPairLaw_probability ν ℓ _ _ + (ne_of_gt (sharedNoDropMass_positive ν hue ℓ (signed_direction_unit e) htrans _ _)) + obtain ⟨h1,h2⟩ := hlim (fun i => (p i).val.1) (fun i => (p i).val.2) (fun i => (p i).property) + have he1 := varying_height_path_gaussian_eval μ + (fun i j P => signedCoordinate f (recordIndexPosition ℓ j (fun a => P.1 a-(p i).val.1))-(j:ℝ)*θ i) + (fun i j => (((measurable_of_countable (signedCoordinate f)).comp + (measurable_recordIndexPosition ℓ j)).comp (by fun_prop)).sub_const _) + r n hn T hT V W h1 hw k hk hkt + have he2 := varying_height_path_gaussian_eval μ + (fun i j P => signedCoordinate f (recordIndexPosition ℓ j (fun a => P.2 a-(p i).val.2))-(j:ℝ)*θ i) + (fun i j => (((measurable_of_countable (signedCoordinate f)).comp + (measurable_recordIndexPosition ℓ j)).comp (by fun_prop)).sub_const _) + r n hn T hT V W h2 hw k hk hkt + let M : ProbabilityMeasure ℝ := ⟨gaussianReal 0 (Real.toNNReal (V*t)),inferInstance⟩ + have ht1 := integral_bounded_test_tendsto μ _ M he1 G + have ht2 := integral_bounded_test_tendsto μ _ M he2 G + have hv : V*t = t/(2*commonMeanWidth ν ℓ) := by dsimp [V]; ring + filter_upwards [(Metric.tendsto_nhds.mp ht1) ε hε,(Metric.tendsto_nhds.mp ht2) ε hε] with i hi hj + simpa only [M,ProbabilityMeasure.coe_mk,Real.dist_eq,hv,centeredFirstHit] using And.intro hi hj + filter_upwards [hh] with i hi x y hxy + exact hi ⟨(x,y),hxy⟩ + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma bounded_normal_test_mean {v : ℝ≥0} (G : ℝ →ᵇ ℝ) : + ‖∫ z, G z ∂gaussianReal 0 v‖ ≤ ‖G‖ := by + simpa using norm_integral_le_of_norm_le_const (μ := gaussianReal 0 v) + (f := fun z => G z) (Filter.Eventually.of_forall (fun z => G.norm_coe_le_norm z)) + +lemma shared_boundary_endpoint_decorrelation {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (hn : ∀ i, 0 < fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (T : ℝ) (hT : 0 < T) (k : ℕ → ℕ) + (hk : ∀ i, (k i:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (t : ℝ) (hkt : Tendsto (fun i => (k i:ℝ)/fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) atTop (𝓝 t)) + (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) + (H : ℕ → ℕ) (hH : ∀ i, 0 < H i) + (F : ℕ → BoundaryData d → ℝ) (C : ℝ) (hC : 0 ≤ C) (hF : ∀ i j, ‖F i j‖ ≤ C) + (G : ℝ →ᵇ ℝ) (b : Bool) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let D := fun i => boundaryData ℓ ((signedHeight e (x i)+H i : ℤ) : ℝ) + let Y := fun i => boundarySuffix ℓ ((signedHeight e (x i)+H i : ℤ) : ℝ) + Tendsto (fun i => ∫ P, F i (D i P) * + (G (centeredFirstHit ℓ f (recordMedianSlope ν ℓ hp f (r i)) (r i) (k i) + (pairSide b (boundaryTerminal (D i P))) (pairSide b (Y i P)))- + (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))) + ∂sharedConditionedPairLaw ν ℓ (x i) (y i)) atTop (𝓝 0) := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + let m := ∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))) + let Z := fun i a c (Q : Path d × Path d) => + G (centeredFirstHit ℓ f (θ i) (r i) (k i) (pairSide b (a,c)) (pairSide b Q)) + have hZ (i : ℕ) (a c : Lattice d) : Measurable (Z i a c) := + G.continuous.measurable.comp ((measurable_centeredFirstHit ℓ f (θ i) (r i) (k i) _).comp + (measurable_pairSide b)) + have hm : ‖m‖ ≤ ‖G‖ := bounded_normal_test_mean G + have hZb (i : ℕ) (a c : Lattice d) (Q : Path d × Path d) : ‖Z i a c Q‖ ≤ ‖G‖ := + G.norm_coe_le_norm _ + apply shared_boundary_test_decorrelation ν hue e htrans x y hxy H hH F C hC hF + (fun i a c Q => Z i a c Q-m) (fun i a c => (hZ i a c).sub_const m) (2*‖G‖) + (fun i a c Q => (norm_sub_le _ _).trans (by linarith [hZb i a c Q])) + intro ε hε + filter_upwards [shared_endpoint_tests_uniform ν hue e f hef htrans r hr hn T hT k hk t hkt G ε hε] + with i hi a c hac + let : IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ a c) := + sharedConditionedPairLaw_probability ν ℓ a c + (ne_of_gt (sharedNoDropMass_positive ν hue ℓ (signed_direction_unit e) htrans a c)) + have hzi : Integrable (Z i a c) (sharedConditionedPairLaw ν ℓ a c) := + Integrable.of_bound (hZ i a c).aestronglyMeasurable ‖G‖ (Filter.Eventually.of_forall (hZb i a c)) + rw [integral_sub hzi (integrable_const m),integral_const] + simp only [probReal_univ,one_smul] + have hh := hi a c hac + cases b + · exact hh.1 + · exact hh.2 + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitNormalPast.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitNormalPast.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4e8682ca374a492f167d07fd39e276e0aaec5cb --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitNormalPast.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.JointPastMoments + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma shared_limit_normalJointPast {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (T : ℝ) (hT : 0 < T) (x : ℕ → Lattice d) + (μ : ℕ → ProbabilityMeasure RealPathPair) (V : ProbabilityMeasure RealPathPair) + (hweak : Tendsto μ atTop (𝓝 V)) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + (∀ i, (μ i : Measure RealPathPair)=(sharedConditionedPairLaw ν ℓ (x i) (x i)).map + (sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (x i))) → + NormalJointPast (V : Measure RealPathPair) (Real.toNNReal (T/(2*commonMeanWidth ν ℓ))) := by + dsimp only + intro hμ + apply normal_past_of_uc_tests + intro q v s t hv hst ht b F G hG + have hh := shared_limit_interior_past_identity ν hue e f hef htrans r hr T hT x μ V hweak + v s t hv hst ht F G hG b hμ + have hc := commonMeanWidth_ge_one ν (realPosition (step e)) htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) + have he : Real.toNNReal (T*((t:ℝ)-s)/(2*commonMeanWidth ν (realPosition (step e)))) = + Real.toNNReal (T/(2*commonMeanWidth ν (realPosition (step e)))) * Real.toNNReal ((t:ℝ)-s) := by + rw [← Real.toNNReal_mul (by positivity : 0 ≤ T/(2*commonMeanWidth ν (realPosition (step e))))] + congr 1 + ring + simpa only [he] using hh + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def gridOccupationMass (μ : Measure RealPathPair) (a ρ : ℝ) : ℝ := + (∑ j ∈ Finset.range (⌊a⌋₊+1), μ.real {P | |layerGap P (layerGridPoint a j)| ≤ ρ})/a + +lemma gap_open_measure_le_grid (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + {a ρ δ : ℝ} (ha : 0 < a) (hδ : 1/a ≤ δ) : + (μ.prod volume) {z : RealPathPair × unitInterval | |layerGap z.1 z.2| < ρ/2} ≤ + ENNReal.ofReal (gridOccupationMass μ a ρ) + + μ {P | P.1 ∈ ContinuousOscillation (ρ/4) δ ∨ P.2 ∈ ContinuousOscillation (ρ/4) δ} := by + let E := fun j => {P : RealPathPair | |layerGap P (layerGridPoint a j)| ≤ ρ} + let C := fun j => {t : unitInterval | ⌊a*(t:ℝ)⌋₊ = j} + let B := {P : RealPathPair | P.1 ∈ ContinuousOscillation (ρ/4) δ ∨ P.2 ∈ ContinuousOscillation (ρ/4) δ} + have hsub : {z : RealPathPair × unitInterval | |layerGap z.1 z.2| < ρ/2} ⊆ + (⋃ j ∈ Finset.range (⌊a⌋₊+1), E j ×ˢ C j) ∪ (B ×ˢ Set.univ) := by + rintro ⟨P,t⟩ ht + change |layerGap P t| < ρ/2 at ht + by_cases hB : P ∈ B + · exact Or.inr ⟨hB,Set.mem_univ _⟩ + · have h1 : P.1 ∉ ContinuousOscillation (ρ/4) δ := fun h => hB (Or.inl h) + have h2 : P.2 ∉ ContinuousOscillation (ρ/4) δ := fun h => hB (Or.inr h) + have hc := gap_grid_close ha hδ P t h1 h2 + have hj : ⌊a*(t:ℝ)⌋₊ ∈ Finset.range (⌊a⌋₊+1) := + Finset.mem_range.mpr (Nat.lt_succ_of_le (Nat.floor_mono (mul_le_of_le_one_right ha.le t.2.2))) + apply Or.inl + apply Set.mem_iUnion.mpr + refine ⟨⌊a*(t:ℝ)⌋₊,Set.mem_iUnion.mpr ⟨hj,?_,rfl⟩⟩ + have hab := abs_sub_le (layerGap P (layerGridPoint a ⌊a*(t:ℝ)⌋₊)) (layerGap P t) 0 + rw [sub_zero,sub_zero,abs_sub_comm] at hab + change |layerGap P (layerGridPoint a ⌊a*(t:ℝ)⌋₊)| ≤ ρ + linarith only [hab,hc,ht] + have hsum : (∑ j ∈ Finset.range (⌊a⌋₊+1), μ (E j))*ENNReal.ofReal (1/a) = + ENNReal.ofReal (gridOccupationMass μ a ρ) := by + rw [show gridOccupationMass μ a ρ = + (∑ j ∈ Finset.range (⌊a⌋₊+1), μ.real (E j))*(1/a) by dsimp [gridOccupationMass,E]; ring] + rw [ENNReal.ofReal_mul (Finset.sum_nonneg (fun j hj => measureReal_nonneg)), + ENNReal.ofReal_sum_of_nonneg (fun j hj => measureReal_nonneg)] + congr 1 + apply Finset.sum_congr rfl + intro j hj + exact (ENNReal.ofReal_toReal (measure_ne_top μ _)).symm + calc + _ ≤ (μ.prod volume) ((⋃ j ∈ Finset.range (⌊a⌋₊+1), E j ×ˢ C j) ∪ (B ×ˢ Set.univ)) := measure_mono hsub + _ ≤ (μ.prod volume) (⋃ j ∈ Finset.range (⌊a⌋₊+1), E j ×ˢ C j) + (μ.prod volume) (B ×ˢ Set.univ) := + measure_union_le _ _ + _ ≤ (∑ j ∈ Finset.range (⌊a⌋₊+1), μ (E j)*ENNReal.ofReal (1/a))+μ B := by + apply add_le_add + · apply (measure_biUnion_finset_le _ _).trans + apply Finset.sum_le_sum + intro j hj + rw [Measure.prod_prod] + exact mul_le_mul le_rfl (volume_layer_cell_le ha j) (by positivity) (by positivity) + · simp only [Measure.prod_prod,measure_univ,mul_one,le_refl] + _ = _ := by rw [← Finset.sum_mul,hsum] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem joint_limit_diagonal_time_zero (μ : ℕ → ProbabilityMeasure RealPathPair) + (V : ProbabilityMeasure RealPathPair) (hweak : Tendsto μ atTop (𝓝 V)) + (ht : IsTightMeasureSet (Set.range (fun i => (μ i : Measure RealPathPair)))) + (a : ℕ → ℝ) (ha : Tendsto a atTop atTop) + (hocc : ∀ ε : ℝ, 0 < ε → ∃ ρ : ℝ, 0 < ρ ∧ + ∀ᶠ i in atTop, gridOccupationMass (μ i) (a i) ρ ≤ ε) : + ((V : Measure RealPathPair).prod volume) {z : RealPathPair × unitInterval | layerGap z.1 z.2 = 0} = 0 := by + have ht1 : IsTightMeasureSet (Set.range (fun i => (μ i : Measure RealPathPair).map Prod.fst)) := by + convert ht.map (f := Prod.fst) continuous_fst using 1 + ext η + simp + have ht2 : IsTightMeasureSet (Set.range (fun i => (μ i : Measure RealPathPair).map Prod.snd)) := by + convert ht.map (f := Prod.snd) continuous_snd using 1 + ext η + simp + let U : ProbabilityMeasure unitInterval := ⟨volume,inferInstance⟩ + have hprod : Tendsto (fun i => (μ i).prod U) atTop (𝓝 (V.prod U)) := + ProbabilityMeasure.continuous_prod.tendsto (V,U) |>.comp (hweak.prodMk_nhds tendsto_const_nhds) + apply le_antisymm _ (by positivity) + apply ENNReal.le_of_forall_pos_le_add + intro ε hε _ + simp only [zero_add] + have he : 0 < (ε:ℝ)/3 := by exact div_pos hε (by norm_num) + obtain ⟨ρ,hρ,hocc⟩ := hocc ((ε:ℝ)/3) he + obtain ⟨δ1,hd1,hm1⟩ := tight_path_modulus _ ht1 (by positivity : 0 < ρ/4) he + obtain ⟨δ2,hd2,hm2⟩ := tight_path_modulus _ ht2 (by positivity : 0 < ρ/4) he + let δ := min δ1 δ2 + have hd : 0 < δ := lt_min hd1 hd2 + have hb (i : ℕ) : (μ i : Measure RealPathPair) + {P | P.1 ∈ ContinuousOscillation (ρ/4) δ ∨ P.2 ∈ ContinuousOscillation (ρ/4) δ} ≤ + ENNReal.ofReal ((ε:ℝ)/3)+ENNReal.ofReal ((ε:ℝ)/3) := by + apply (measure_union_le _ _).trans + apply add_le_add + · have hs : {P : RealPathPair | P.1 ∈ ContinuousOscillation (ρ/4) δ} ⊆ + Prod.fst ⁻¹' ContinuousOscillation (ρ/4) δ1 := fun P h => + continuousOscillation_mono (min_le_left _ _) h + apply (measure_mono hs).trans + rw [← Measure.map_apply measurable_fst (isOpen_continuousOscillation _ _).measurableSet] + exact hm1 i + · have hs : {P : RealPathPair | P.2 ∈ ContinuousOscillation (ρ/4) δ} ⊆ + Prod.snd ⁻¹' ContinuousOscillation (ρ/4) δ2 := fun P h => + continuousOscillation_mono (min_le_right _ _) h + apply (measure_mono hs).trans + rw [← Measure.map_apply measurable_snd (isOpen_continuousOscillation _ _).measurableSet] + exact hm2 i + have hinv : Tendsto (fun i => 1/a i) atTop (𝓝 (0:ℝ)) := + tendsto_const_nhds.div_atTop ha + have hevent : ∀ᶠ i in atTop, + ((↑((μ i).prod U)) : Measure (RealPathPair × unitInterval)) + {z | |layerGap z.1 z.2| < ρ/2} ≤ (ε:ℝ≥0∞) := by + filter_upwards [hocc,ha.eventually_gt_atTop 0,hinv.eventually_lt_const hd] with i hi hai hdi + have hg := gap_open_measure_le_grid (ρ := ρ) (μ i) hai hdi.le + have hc := hg.trans (add_le_add (ENNReal.ofReal_le_ofReal hi) (hb i)) + have heq : ENNReal.ofReal ((ε:ℝ)/3)+(ENNReal.ofReal ((ε:ℝ)/3)+ENNReal.ofReal ((ε:ℝ)/3)) = ε := by + rw [← ENNReal.ofReal_add he.le,← ENNReal.ofReal_add he.le] + have heq : (ε:ℝ)/3+((ε:ℝ)/3+(ε:ℝ)/3) = ε := by ring + rw [heq,ENNReal.ofReal_coe_nnreal] + all_goals positivity + exact hc.trans_eq heq + have hopen : IsOpen {z : RealPathPair × unitInterval | |layerGap z.1 z.2| < ρ/2} := + isOpen_lt continuous_layerGap.abs continuous_const + have hport := ProbabilityMeasure.le_liminf_measure_open_of_tendsto hprod hopen + have hlim : liminf (fun i => ((↑((μ i).prod U)) : Measure (RealPathPair × unitInterval)) + {z | |layerGap z.1 z.2| < ρ/2}) atTop ≤ (ε:ℝ≥0∞) := + (liminf_le_limsup (by isBoundedDefault) (by isBoundedDefault)).trans (limsup_le_of_le (by isBoundedDefault) hevent) + apply (measure_mono (show {z : RealPathPair × unitInterval | layerGap z.1 z.2 = 0} ⊆ + {z | |layerGap z.1 z.2| < ρ/2} from ?_)).trans (hport.trans hlim) + intro z hz + simp only [Set.mem_ofPred_eq] at hz ⊢ + rw [hz,abs_zero] + positivity + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitOccupation.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitOccupation.lean new file mode 100644 index 0000000000000000000000000000000000000000..81fcbbd5283441febe3fcf01ea9def5efff89cd7 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitOccupation.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.JointPathIndependence +import OAI.Probability.Ballisticity.Crossings.SharedInteriorCross +import OAI.Probability.Ballisticity.Estimates.SharedLimitNormalPast +import OAI.Probability.Ballisticity.Estimates.OccupationLimit + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma shared_gap_at_grid {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ r n T : ℝ) (h : 0 < T*n) (x : Lattice d) (P : Path d × Path d) + (j : ℕ) (hj : (j:ℝ) ≤ T*n) : + layerGap (sharedLinearPairPath ℓ f θ r n T x x P) (layerGridPoint (T*n) j) = + -(physicalFirstHitGap ℓ f x x j P)/r := by + have ht : T*n*(layerGridPoint (T*n) j : ℝ) = j := by + rw [layerGridPoint_coe h hj] + rw [← mul_div_assoc] + exact mul_div_cancel_left₀ _ h.ne' + dsimp only [layerGap,sharedLinearPairPath] + rw [recordLinearPath_grid ℓ f θ r n T h.le x P.1 j _ ht, + recordLinearPath_grid ℓ f θ r n T h.le x P.2 j _ ht] + have hz : signedCoordinate f (0 : Lattice d) = 0 := by simp [signedCoordinate] + simp only [centeredFirstHit,physicalFirstHitGap,firstHitPairGap,sub_self,hz,zero_add] + simp only [sub_eq_add_neg,add_comm] + ring + +lemma shared_gridOccupation_eq {d : ℕ} (ν : Measure (Row d)) (e f : Direction d) + (θ r n T ρ : ℝ) (hr : 0 < r) (h : 0 < T*n) (x : Lattice d) : + gridOccupationMass ((sharedConditionedPairLaw ν (realPosition (step e)) x x).map + (sharedLinearPairPath (realPosition (step e)) f θ r n T x x)) (T*n) ρ = + firstHitOccupationMean ν e f x x (ρ*r) (⌊T*n⌋₊+1)/(T*n) := by + unfold gridOccupationMass firstHitOccupationMean + congr 1 + apply Finset.sum_congr rfl + intro j hj + have hjn : (j:ℝ) ≤ T*n := (Nat.cast_le.mpr (Nat.le_of_lt_succ (Finset.mem_range.mp hj))).trans (Nat.floor_le h.le) + have hs : MeasurableSet {P : RealPathPair | |layerGap P (layerGridPoint (T*n) j)| ≤ ρ} := + (isClosed_le (show Continuous (fun P : RealPathPair => |layerGap P (layerGridPoint (T*n) j)|) from + (continuous_layerGap.comp (continuous_id.prodMk continuous_const)).abs) continuous_const).measurableSet + rw [Measure.real,Measure.map_apply (measurable_sharedLinearPairPath _ _ _ _ _ _ _ _) hs] + congr 2 + ext P + change |layerGap (sharedLinearPairPath _ _ _ _ _ _ _ _ P) (layerGridPoint (T*n) j)| ≤ ρ ↔ _ + rw [shared_gap_at_grid _ _ _ _ _ _ h _ _ j hjn,abs_div,abs_neg,abs_of_pos hr] + exact div_le_iff₀ hr + +theorem shared_limit_diagonal_time_zero {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x : ℕ → Lattice d) {T : ℝ} (hT : 0 < T) + (μ : ℕ → ProbabilityMeasure RealPathPair) (V : ProbabilityMeasure RealPathPair) + (hweak : Tendsto μ atTop (𝓝 V)) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + (∀ i, (μ i : Measure RealPathPair) = (sharedConditionedPairLaw ν ℓ (x i) (x i)).map + (sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (x i))) → + ((V : Measure RealPathPair).prod volume) {z : RealPathPair × unitInterval | layerGap z.1 z.2 = 0} = 0 := by + dsimp only + intro hμ + let ℓ := realPosition (step e) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + have hn : Tendsto n atTop atTop := recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1 + apply joint_limit_diagonal_time_zero μ V hweak (weak_sequence_tight hweak) (fun i => T*n i) (hn.const_mul_atTop hT) + intro ε hε + obtain ⟨ρ,hρ,ho⟩ := shared_first_hit_occupation_vanishes ν hue e f hef htrans r hr x hT (mul_pos hε hT) + refine ⟨ρ,hρ,?_⟩ + filter_upwards [ho,hr.1.eventually_gt_atTop 0,hn.eventually_gt_atTop 0] with i hi hri hni + rw [hμ i,shared_gridOccupation_eq ν e f _ _ _ _ ρ hri (mul_pos hT hni)] + calc + _ = (firstHitOccupationMean ν e f (x i) (x i) (ρ*r i) (⌊T*n i⌋₊+1)/n i)/T := by + rw [div_div,mul_comm T] + _ ≤ ε := (div_le_iff₀ hT).mpr hi + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma shared_limit_product {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (T : ℝ) (hT : 0 < T) (x : ℕ → Lattice d) + (μ : ℕ → ProbabilityMeasure RealPathPair) (V : ProbabilityMeasure RealPathPair) + (hweak : Tendsto μ atTop (𝓝 V)) + (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hW : ∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g)= + gaussianPathFiniteLaw (T/(2*commonMeanWidth ν (realPosition (step e)))) I) + (hf : (V : Measure RealPathPair).map Prod.fst=W) + (hg : (V : Measure RealPathPair).map Prod.snd=W) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + (∀ i, (μ i : Measure RealPathPair)=(sharedConditionedPairLaw ν ℓ (x i) (x i)).map + (sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (x i))) → + (V : Measure RealPathPair)=(W : Measure C(unitInterval,ℝ)).prod W := by + dsimp only + intro hμ + let ℓ := realPosition (step e) + let c := Real.toNNReal (T/(2*commonMeanWidth ν ℓ)) + have hc := commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) + have h := shared_limit_normalJointPast ν hue e f hef htrans r hr T hT x μ V hweak hμ + have hz := shared_limit_diagonal_time_zero ν hue e f hef htrans r hr x hT μ V hweak hμ + have hcross : SeparatedCrossBound (V : Measure RealPathPair) + (commonMeanWidth ν ℓ/(9*T)) (16*‖symmetricClip 1‖^2) := by + intro q v s t hv hst ht F g hg hgb ρ hρ hgzero + have hh := shared_limit_interior_cross_bound ν hue e f hef htrans r hr T hT x μ V hweak + v s t hv hst ht F g hg hgb hρ hgzero 1 hμ + have hexp : -(commonMeanWidth ν ℓ/(9*T))*ρ^2/((t:ℝ)-s) = + -commonMeanWidth ν ℓ*ρ^2/(9*(T*((t:ℝ)-s))) := by + field_simp + rw [hexp] + simpa only [jointCrossPastTest_apply,pairPastCoordinates,pairPathIncrement, + ContinuousMap.coe_mk,Bool.false_eq_true,ite_false,ite_true,mul_assoc] using hh + have hW0 := wiener_path_initial_zero W _ hW + have h0f : ∀ᵐ P ∂(V : Measure RealPathPair),P.1 0=0 := by + have hh : ∀ᵐ P ∂(V : Measure RealPathPair).map Prod.fst,P 0=0 := by rw [hf]; exact hW0 + exact (ae_map_iff measurable_fst.aemeasurable ((isClosed_eq (continuous_eval_const 0) continuous_const).measurableSet)).mp hh + have h0g : ∀ᵐ P ∂(V : Measure RealPathPair),P.2 0=0 := by + have hh : ∀ᵐ P ∂(V : Measure RealPathPair).map Prod.snd,P 0=0 := by rw [hg]; exact hW0 + exact (ae_map_iff measurable_snd.aemeasurable ((isClosed_eq (continuous_eval_const 0) continuous_const).measurableSet)).mp hh + have he := normalJointPast_product_identification (V : Measure RealPathPair) c h + (by positivity : 0 < commonMeanWidth ν ℓ/(9*T)) (by positivity : 0 ≤ 16*‖symmetricClip 1‖^2) + hcross (by + have hs : {z : RealPathPair × unitInterval | z.1.1 z.2-z.1.2 z.2=0} = + {z : RealPathPair × unitInterval | layerGap z.1 z.2=0} := by + ext z + change z.1.1 z.2-z.1.2 z.2=0 ↔ z.1.2 z.2-z.1.1 z.2=0 + rw [sub_eq_zero,sub_eq_zero,eq_comm] + rw [hs] + exact hz) (h0f.and h0g) + simpa only [hf,hg] using he + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitPastIdentity.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitPastIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8a6a1ca9b8133b6ded437d1035371ec472a6c7c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedLimitPastIdentity.lean @@ -0,0 +1,76 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.FinitePastDecorrelation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +theorem shared_limit_finite_past_identity {d q : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (hn : ∀ i, 0 < fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (T : ℝ) (hT : 0 < T) (k : ℕ → ℕ) + (hk : ∀ i, (k i:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (t : ℝ) (hkt : Tendsto (fun i => (k i:ℝ)/fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) atTop (𝓝 t)) + (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) + (H : ℕ → ℕ) (hH : ∀ i, 0 < H i) (j : ℕ → Fin q → ℕ) (hj : ∀ i z, j i z ≤ H i) + (a : ℕ → JointPastTimes q) (a₀ : JointPastTimes q) (ha : Tendsto a atTop (𝓝 a₀)) + (μ : ℕ → ProbabilityMeasure RealPathPair) (V : ProbabilityMeasure RealPathPair) + (hweak : Tendsto μ atTop (𝓝 V)) + (F : (Fin q → ℝ × ℝ) →ᵇ ℝ) (G : ℝ →ᵇ ℝ) (hG : UniformContinuous G) (b : Bool) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + (∀ i z, T*n i*(a i |>.1 z : ℝ) = j i z) → + (∀ i, T*n i*(a i |>.2.1 : ℝ) = H i) → + (∀ i, T*n i*(a i |>.2.2 : ℝ) = H i+k i) → + (∀ i, (μ i : Measure RealPathPair) = (sharedConditionedPairLaw ν ℓ (x i) (y i)).map + (sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (y i))) → + (∫ P, jointPastProductTest F G (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ)))) + (jointPastIncrementMap b (P,a₀)) ∂(V : Measure RealPathPair)) = 0 := by + dsimp only + intro haj haH hak hμ + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + let c := ∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))) + have hd := shared_finite_past_increment_decorrelation ν hue e f hef htrans r hr hn T hT k hk t hkt + x y hxy H hH j hj (fun _ => F) ‖F‖ (norm_nonneg _) (fun _ z => F.norm_coe_le_norm z) G hG b + apply joint_past_identity_of_prelimit μ V hweak a a₀ ha b F G c + apply hd.congr' + filter_upwards [] with i + rw [hμ i] + have htest : Continuous (fun P : RealPathPair => jointPastProductTest F G c (jointPastIncrementMap b (P,a i))) := + (jointPastProductTest F G c).continuous.comp ((jointPastIncrementMap b).continuous.comp + (continuous_id.prodMk continuous_const)) + rw [integral_map (measurable_sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (y i)).aemeasurable + htest.aestronglyMeasurable] + apply integral_congr_ae + apply ae_of_all + intro P + dsimp only + rw [jointPastIncrementMap_grid ℓ f (θ i) (r i) (n i) T (mul_nonneg hT.le (hn i).le) + (x i) (y i) P (j i) (H i) (k i) (a i) (haj i) (haH i) (hak i) b] + rfl + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedShrinking.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedShrinking.lean new file mode 100644 index 0000000000000000000000000000000000000000..711f5d7891288c40e82caf9d00d92364ed513547 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedShrinking.lean @@ -0,0 +1,178 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.GaussianBadCutoff +import OAI.Probability.Ballisticity.Walk.WienerPathMaximal + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma physical_shrinking_subset_path_norm {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x y : Lattice d) (θ r n T : ℝ) (hr : 0 < r) (hn : 0 < n) (hT : 0 < T) + (hgap : |signedCoordinate f (x-y)| = r) : + {P : Path d × Path d | ∃ h ≤ ⌊T*n⌋₊, |physicalFirstHitGap ℓ f x y h P| ≤ r/2} ⊆ + {P | 1/4 ≤ ‖recordLinearPath ℓ f θ r n T (fun j => P.1 j-x)‖} ∪ + {P | 1/4 ≤ ‖recordLinearPath ℓ f θ r n T (fun j => P.2 j-y)‖} := by + rintro P ⟨h,hh,hsmall⟩ + by_contra hno + simp only [Set.mem_union, Set.mem_ofPred_eq, not_or, not_le] at hno + have hTn : 0 < T*n := mul_pos hT hn + have hhh : (h:ℝ) ≤ T*n := (show (h:ℝ) ≤ (⌊T*n⌋₊:ℝ) by exact_mod_cast hh).trans (Nat.floor_le hTn.le) + let s : unitInterval := ⟨(h:ℝ)/(T*n), div_nonneg (Nat.cast_nonneg _) hTn.le, + (div_le_one hTn).mpr hhh⟩ + have hs : T*n*(s:ℝ) = h := by dsimp [s]; field_simp + let A := recordLinearPath ℓ f θ r n T (fun j => P.1 j-x) + let B := recordLinearPath ℓ f θ r n T (fun j => P.2 j-y) + have hA : |A s| < 1/4 := by + exact (A.norm_coe_le_norm s).trans_lt hno.1 + have hB : |B s| < 1/4 := by + exact (B.norm_coe_le_norm s).trans_lt hno.2 + have hAe : A s = (signedCoordinate f (recordIndexPosition ℓ h (fun j => P.1 j-x))-(h:ℝ)*θ)/r := + heightPolygon_grid _ r n T hTn.le h s hs + have hBe : B s = (signedCoordinate f (recordIndexPosition ℓ h (fun j => P.2 j-y))-(h:ℝ)*θ)/r := + heightPolygon_grid _ r n T hTn.le h s hs + have he : physicalFirstHitGap ℓ f x y h P = signedCoordinate f (x-y)+r*(A s-B s) := by + rw [hAe,hBe] + dsimp only [physicalFirstHitGap, firstHitPairGap] + field_simp + ring + have hab : |A s-B s| < 1/2 := (abs_sub _ _).trans_lt (by linarith) + have hg : r ≤ |physicalFirstHitGap ℓ f x y h P| + r*|A s-B s| := by + rw [← hgap] + have ht := abs_sub (physicalFirstHitGap ℓ f x y h P) (r*(A s-B s)) + rw [he,add_sub_cancel_right,abs_mul,abs_of_pos hr] at ht + rw [hgap] at ht ⊢ + simpa only [he] using ht + nlinarith + +theorem shared_shrinking_gaussian {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hrpos : ∀ i, 0 < r i) + (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) + (hgap : ∀ i, |signedCoordinate f (x i-y i)| = r i) + {t : ℝ} (ht : 0 < t) : + let ℓ := realPosition (step e) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ f 0) (r i) + ∀ᶠ i in atTop, + (sharedConditionedPairLaw ν ℓ (x i) (y i)).real + {P | ∃ h ≤ ⌊t*n i⌋₊, |physicalFirstHitGap ℓ f (x i) (y i) h P| ≤ r i/2} ≤ + 8*Real.exp (-commonMeanWidth ν ℓ/(16*t)) := by + let ℓ := realPosition (step e) + let m := commonMeanWidth ν ℓ + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + let μ := fun i => sharedConditionedPairLaw ν ℓ (x i) (y i) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + let F := fun i (P : Path d × Path d) => recordLinearPath ℓ f (θ i) (r i) (n i) t (fun j => P.1 j-x i) + let G := fun i (P : Path d × Path d) => recordLinearPath ℓ f (θ i) (r i) (n i) t (fun j => P.2 j-y i) + have hFm (i : ℕ) : Measurable (F i) := (measurable_recordLinearPath _ _ _ _ _ _).comp (by fun_prop) + have hGm (i : ℕ) : Measurable (G i) := (measurable_recordLinearPath _ _ _ _ _ _).comp (by fun_prop) + have hm : 0 < m := zero_lt_one.trans_le (commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e)) + obtain ⟨W,hW,hlim⟩ := shared_path_marginal_limits ν hue e f hef htrans r hr ht.le + have hV : 0 < t/(2*m) := by positivity + have hF := distribution_path_norm_limsup μ F hFm W (hlim x y hxy).1 + (t/(2*m)) hV hW (1/4) (by norm_num) + have hG := distribution_path_norm_limsup μ G hGm W (hlim x y hxy).2 + (t/(2*m)) hV hW (1/4) (by norm_num) + have he : -(1/4:ℝ)^2/(2*(t/(2*m))) = -m/(16*t) := by field_simp; ring + rw [he] at hF hG + let c := Real.exp (-m/(16*t)) + have hc : 0 < c := Real.exp_pos _ + have hFb : IsBoundedUnder (· ≤ ·) atTop (fun i => (μ i).real {P | 1/4 ≤ ‖F i P‖}) := + isBoundedUnder_of_eventually_le (Eventually.of_forall fun i => + (show (μ i).real {P | 1/4 ≤ ‖F i P‖} ≤ 1 from measureReal_le_one)) + have hGb : IsBoundedUnder (· ≤ ·) atTop (fun i => (μ i).real {P | 1/4 ≤ ‖G i P‖}) := + isBoundedUnder_of_eventually_le (Eventually.of_forall fun i => + (show (μ i).real {P | 1/4 ≤ ‖G i P‖} ≤ 1 from measureReal_le_one)) + have hFe := eventually_lt_of_limsup_lt (hF.trans_lt (show 2*c < 3*c by linarith)) hFb + have hGe := eventually_lt_of_limsup_lt (hG.trans_lt (show 2*c < 3*c by linarith)) hGb + filter_upwards [hFe,hGe] with i hi hj + have hni : 0 < n i := recordFluctuationScale_pos ν hue e f hef htrans (hrpos i) + have hs := physical_shrinking_subset_path_norm ℓ f (x i) (y i) (θ i) (r i) (n i) t + (hrpos i) hni ht (hgap i) + exact (measureReal_mono hs).trans ((measureReal_union_le _ _).trans (by + change (μ i).real {P | 1/4 ≤ ‖F i P‖} + (μ i).real {P | 1/4 ≤ ‖G i P‖} ≤ 8*c + linarith)) + +theorem shared_uniform_good_shrinking {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {t : ℝ} (ht : 0 < t) : + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let n := fluctuationScale μ (commonIncrementProcess ℓ f 0) + ∃ l ε R : ℝ, 0 < l ∧ l < 1 ∧ 0 < ε ∧ 0 < R ∧ + ∀ u : ℝ, R ≤ u → n u * μ.real {P | l*u < |commonIncrementProcess ℓ f 0 P|} ≤ ε → + ∀ x y : Lattice d, signedHeight e x = signedHeight e y → |signedCoordinate f (x-y)| = u → + (sharedConditionedPairLaw ν ℓ x y).real + {P | ∃ h ≤ ⌊t*n u⌋₊, |physicalFirstHitGap ℓ f x y h P| ≤ u/2} ≤ + 8*Real.exp (-commonMeanWidth ν ℓ/(16*t)) := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let S := commonIncrementProcess ℓ f 0 + let n := fluctuationScale μ S + let P := fun u (x y : Lattice d) => + (sharedConditionedPairLaw ν ℓ x y).real + {Q | ∃ h ≤ ⌊t*n u⌋₊, |physicalFirstHitGap ℓ f x y h Q| ≤ u/2} ≤ + 8*Real.exp (-commonMeanWidth ν ℓ/(16*t)) + change ∃ l ε R : ℝ, 0 1/((i:ℝ)+2) + have ha (i : ℕ) : 0 + mul_nonneg (fluctuationScale_nonneg μ S _) measureReal_nonneg) _ ha0 + filter_upwards [ha0.eventually_lt_const hδ] with i hi + have htail' : μ.real {Q | δ*r i< |S Q|} ≤ μ.real {Q | a i*r i< |S Q|} := by + apply measureReal_mono _ (measure_ne_top _ _) + intro Q hQ + exact lt_of_le_of_lt (mul_le_mul_of_nonneg_right hi.le (hrpos i).le) hQ + exact (mul_le_mul_of_nonneg_left htail' (fluctuationScale_nonneg μ S _)).trans (htail i) + obtain ⟨i,hi⟩ := (shared_shrinking_gaussian ν hue e f hef htrans r hrpos hgauss x y hxy hgap ht).exists + exact hbad i hi + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SharedWordCylinderLower.lean b/lean/OAI/Probability/Ballisticity/Estimates/SharedWordCylinderLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..a385bb50fb69478285e6c9ee896c4c06197954ed --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SharedWordCylinderLower.lean @@ -0,0 +1,365 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.PrefixVariationNonneg +import OAI.Probability.Ballisticity.Estimates.DirectBridge + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma shared_wordCylinder_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (κ : ℝ≥0) (hκ : ∀ᵐ ω ∂environmentLaw ν, ∀ x e, κ ≤ (ω x).1 e) + (x y : Lattice d) (w v : List (Direction d)) : + (κ:ℝ≥0∞)^(w.length+v.length) ≤ sharedPairLaw ν x y (wordCylinder x w ×ˢ wordCylinder y v) := by + rw [sharedPairLaw_rectangle ν x y _ _ (measurableSet_wordCylinder _ _) (measurableSet_wordCylinder _ _)] + simp_rw [quenched_wordCylinder] + have hconst : (κ:ℝ≥0∞)^(w.length+v.length) = + ∫⁻ _ : Environment d, (κ:ℝ≥0∞)^(w.length+v.length) ∂environmentLaw ν := by simp + rw [hconst] + apply lintegral_mono_ae + filter_upwards [hκ] with ω hω + have hw := ENNReal.ofReal_le_ofReal (wordWeight_lower ω hω x w) + have hv := ENNReal.ofReal_le_ofReal (wordWeight_lower ω hω y v) + simp only [ENNReal.ofReal_pow κ.coe_nonneg,ENNReal.ofReal_coe_nnreal] at hw hv + rw [pow_add] + exact mul_le_mul' hw hv + +lemma signedHeight_add_step_other {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) (x : Lattice d) : + signedHeight e (x+step f)=signedHeight e x := by + simp [signedHeight,Pi.add_apply,step,hef] + +lemma transverse_two_step_hit {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (x : Lattice d) (X : Path d) (hX : X ∈ wordCylinder x [f,e]) : + X ∈ FirstLayerHit (signedHeight e) (signedHeight e x+1) 2 ∧ + X ∈ StayUntil {z | dot (realPosition x) (realPosition (step e)) ≤ + dot (realPosition z) (realPosition (step e))} 2 ∧ X 2=x+step f+step e := by + have h0 : X 0=x := by simpa only [wordPath_zero] using hX 0 (by simp) + have h1 : X 1=x+step f := by simpa only [wordPath] using hX 1 (by simp) + have h2 : X 2=x+step f+step e := by simpa only [wordPath] using hX 2 (by simp) + have hheight1 : signedHeight e (X 1)=signedHeight e x := by rw [h1,signedHeight_add_step_other e f hef] + have hheight2 : signedHeight e (X 2)=signedHeight e x+1 := by + rw [h2,signedHeight_add_step_self,signedHeight_add_step_other e f hef] + refine ⟨⟨hheight2,?_⟩,?_,h2⟩ + · intro j hj + have hj' : j=0 ∨ j=1 := by omega + rcases hj' with rfl | rfl <;> simp only [h0,hheight1] <;> omega + · intro j hj + change dot (realPosition x) (realPosition (step e)) ≤ dot (realPosition (X j)) (realPosition (step e)) + rw [signedHeight_projection,signedHeight_projection] + have hj' : j=0 ∨ j=1 ∨ j=2 := by omega + rcases hj' with rfl | rfl | rfl + all_goals simp only [h0,hheight1,hheight2] + all_goals norm_cast + all_goals omega + +lemma direction_one_step_hit {d : ℕ} (e : Direction d) (x : Lattice d) (X : Path d) + (hX : X ∈ wordCylinder x [e]) : + X ∈ FirstLayerHit (signedHeight e) (signedHeight e x+1) 1 ∧ + X ∈ StayUntil {z | dot (realPosition x) (realPosition (step e)) ≤ + dot (realPosition z) (realPosition (step e))} 1 ∧ X 1=x+step e := by + have h0 : X 0=x := by simpa only [wordPath_zero] using hX 0 (by simp) + have h1 : X 1=x+step e := by simpa only [wordPath] using hX 1 (by simp) + have hheight1 : signedHeight e (X 1)=signedHeight e x+1 := by rw [h1,signedHeight_add_step_self] + refine ⟨⟨hheight1,?_⟩,?_,h1⟩ + · intro j hj + have hj' : j=0 := by omega + subst j; rw [h0]; omega + · intro j hj + change dot (realPosition x) (realPosition (step e)) ≤ dot (realPosition (X j)) (realPosition (step e)) + rw [signedHeight_projection,signedHeight_projection] + have hj' : j=0 ∨ j=1 := by omega + rcases hj' with rfl | rfl + all_goals simp only [h0,hheight1] + all_goals norm_cast + all_goals omega + +lemma elliptic_raw_gap_growth {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) : + ∃ q : ℝ≥0∞, 0 < q ∧ ∀ x y : Lattice d, signedHeight e x=signedHeight e y → + q ≤ sharedPairLaw ν x y (layerPairEvent (realPosition (step e)) (signedHeight e) x y + (signedHeight e x+1) {uv | |signedCoordinate f x-signedCoordinate f y|+1/2 < + |signedCoordinate f uv.1-signedCoordinate f uv.2|}) := by + obtain ⟨κ,hκ,hrows⟩ := environment_uniform_elliptic ν hue + refine ⟨(κ:ℝ≥0∞)^3,ENNReal.pow_pos (by exact_mod_cast hκ) _,?_⟩ + intro x y hxy + by_cases horder : signedCoordinate f y ≤ signedCoordinate f x + · have hh := shared_wordCylinder_lower ν κ hrows x y [f,e] [e] + simp only [List.length_cons,List.length_nil] at hh + apply hh.trans (measure_mono _) + intro P hP + have h1 := transverse_two_step_hit e f hef x P.1 hP.1 + have h2 := direction_one_step_hit e y P.2 hP.2 + refine Set.mem_iUnion.mpr ⟨(1,0),⟨⟨⟨h1.1,by simpa only [hxy] using h2.1⟩,?_⟩,h1.2.1,h2.2.1⟩⟩ + change |signedCoordinate f x-signedCoordinate f y|+1/2 < |signedCoordinate f (P.1 2)-signedCoordinate f (P.2 1)| + rw [h1.2.2,h2.2.2] + simp only [signedCoordinate_add,signedCoordinate_step_self,signedCoordinate_step_other f e (Ne.symm hef),add_zero] + rw [abs_of_nonneg (sub_nonneg.mpr horder),abs_of_nonneg (by linarith)] + linarith + · have hyx : signedCoordinate f x ≤ signedCoordinate f y := le_of_not_ge horder + have hh := shared_wordCylinder_lower ν κ hrows x y [e] [f,e] + simp only [List.length_cons,List.length_nil] at hh + apply hh.trans (measure_mono _) + intro P hP + have h1 := direction_one_step_hit e x P.1 hP.1 + have h2 := transverse_two_step_hit e f hef y P.2 hP.2 + refine Set.mem_iUnion.mpr ⟨(0,1),⟨⟨⟨h1.1,by simpa only [hxy] using h2.1⟩,?_⟩,h1.2.1,h2.2.1⟩⟩ + change |signedCoordinate f x-signedCoordinate f y|+1/2 < |signedCoordinate f (P.1 1)-signedCoordinate f (P.2 2)| + rw [h1.2.2,h2.2.2] + simp only [signedCoordinate_add,signedCoordinate_step_self,signedCoordinate_step_other f e (Ne.symm hef),add_zero] + rw [abs_of_nonpos (sub_nonpos.mpr hyx),abs_of_nonpos (by linarith)] + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/ShiftedCurveConcatenation.lean b/lean/OAI/Probability/Ballisticity/Estimates/ShiftedCurveConcatenation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bb2783c0c2f9aabac067cdc2992cb72a2945d20 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/ShiftedCurveConcatenation.lean @@ -0,0 +1,75 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RecordOrPrefixAdd +import OAI.Probability.Ballisticity.Estimates.CurveWordDisjoint + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma shiftedCurvePrefixAt_concatenate {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ a z : ℝ) {s : ℕ} (hs : 0 < s) (n k m : ℕ) (X : Path d) (h0 : X 0=x) + (hnn : ∀ j, ∃ g, X (j+1)=X j+step g) + (hpre : X ∈ CurvePrefixAt (realPosition (step e)) f x (fun j => (j:ℝ)*θ-a) z s n) + (hpost : (fun j => X (n+j)) ∈ CurvePrefixAt (realPosition (step e)) f (X n) + (fun j => (j:ℝ)*θ-(a+signedCoordinate f (X n-x)-(s:ℝ)*θ)) z k m) : + X ∈ CurvePrefixAt (realPosition (step e)) f x (fun j => (j:ℝ)*θ-a) z (s+k) (n+m) := by + let ℓ := realPosition (step e) + have hheight : dot (realPosition (X n)) ℓ = dot (realPosition x) ℓ+(s:ℝ) := by + have hh := coordinate_hitAt_exact e x X h0 hnn s n hpre.1 + simp only [ℓ,signedHeight_projection,hh,Int.cast_add,Int.cast_natCast] + have hrec : (fun j => X j-x) ∈ RecordOrZeroPrefix ℓ s n := by + simpa only [RecordOrZeroPrefix,ite_eq_right (Nat.ne_of_gt hs)] using + coordinate_hitAt_recordPrefix e x X h0 hnn hs hpre.1 + refine ⟨⟨?_,?_⟩,?_⟩ + · have hh := hpost.1.1 + change dot (realPosition (X n)) ℓ+(k:ℝ) ≤ dot (realPosition (X (n+m))) ℓ at hh + change dot (realPosition x) ℓ+((s+k:ℕ):ℝ) ≤ dot (realPosition (X (n+m))) ℓ + rw [hheight,Nat.cast_add] at * + linarith + · intro j hj + change dot (realPosition x) ℓ ≤ dot (realPosition (X j)) ℓ ∧ + dot (realPosition (X j)) ℓ < dot (realPosition x) ℓ+((s+k:ℕ):ℝ) + rw [Nat.cast_add] + by_cases hjn : j X b-x) (by rw [h0,sub_self]) s n (j-s) a hrec + (by convert hra using 1; ext b; dsimp; abel) + simpa only [Nat.add_sub_of_le (show s ≤ j by omega)] using hh + · have he : X (n+a)-x = (X n-x)+(X (n+a)-X n) := by abel + have hadd (u v : Lattice d) : signedCoordinate f (u+v)=signedCoordinate f u+signedCoordinate f v := by + simp only [signedCoordinate,Pi.add_apply,Int.cast_add] + split_ifs <;> ring + have hcast : (j:ℝ)=(s:ℝ)+((j-s:ℕ):ℝ) := by exact_mod_cast (Nat.add_sub_of_le (show s ≤ j by omega)).symm + dsimp only at hga ⊢ + rw [he,hadd,hcast] + convert hga using 1 + congr 1 + ring + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SignedPrefixComparison.lean b/lean/OAI/Probability/Ballisticity/Estimates/SignedPrefixComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..314a251ac5799fb7e055ccd81aeca6ba2a8df93a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SignedPrefixComparison.lean @@ -0,0 +1,203 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ClippedAbsThreeHalves +import OAI.Probability.Ballisticity.Estimates.IidListProcess +import OAI.Probability.Ballisticity.Estimates.SharedEndpointTests + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma prefixVariation_signed_integral_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) + (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) + (hxy : dot (realPosition x) ℓ=dot (realPosition y) ℓ) (H : ℝ) + (F : Path d × Path d → ℝ) (hF : Measurable F) {M : ℝ} (hM : 0≤M) + (hFb : ∀ P, |F P|≤M) + (W : HitWord x (Strip ℓ x H) (Upper ℓ x H) × HitWord y (Strip ℓ x H) (Upper ℓ x H) → ℝ) + (hW : ∀ w P, P.1 ∈ RegularPath ℓ x → P.2 ∈ RegularPath ℓ y → + P ∈ wordCylinder x w.1.val ×ˢ wordCylinder y w.2.val → F P=W w) : + |(∫ P, F P ∂sharedConditionedPairLaw ν ℓ x y)- + (∫ P, F P ∂(conditionedFrom ν ℓ x).prod (conditionedFrom ν ℓ y))|≤ + (2*M)*prefixVariation ν ℓ x y H := by + let μ := sharedConditionedPairLaw ν ℓ x y + let η := (conditionedFrom ν ℓ x).prod (conditionedFrom ν ℓ y) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure μ := sharedConditionedPairLaw_probability ν ℓ x y + (ne_of_gt (sharedNoDropMass_positive ν hue ℓ hℓ htrans x y)) + let : IsProbabilityMeasure (conditionedFrom ν ℓ x) := conditionedFrom_probability ν ℓ x hp + let : IsProbabilityMeasure (conditionedFrom ν ℓ y) := conditionedFrom_probability ν ℓ y hp + have hi (σ : Measure (Path d × Path d)) [IsProbabilityMeasure σ] : Integrable F σ := + Integrable.mono' (integrable_const M) hF.aestronglyMeasurable (ae_of_all _ fun P => by + simpa only [Real.norm_eq_abs] using hFb P) + have hb := prefixVariation_integral_bound ν hue ℓ hℓ htrans x y hxy H (fun P => F P+M) + (hF.add_const M) (show 0≤2*M by positivity) + (fun P => by linarith [(abs_le.mp (hFb P)).1]) + (fun P => by linarith [(abs_le.mp (hFb P)).2]) (fun w => W w+M) + (fun w P hx hy hw => by rw [hW w P hx hy hw]) + change |(∫ P, F P+M ∂μ)-(∫ P, F P+M ∂η)|≤_ at hb + rw [integral_add (hi μ) (integrable_const _),integral_add (hi η) (integrable_const _)] at hb + simpa only [integral_const,probReal_univ,one_smul,add_sub_add_right_eq_sub] using hb + +lemma centeredFirstHit_on_hitWord {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ r : ℝ) {H : ℕ} (hH : 0 G₁ (centeredFirstHit ℓ f θ r H x P.1)*G₂ (centeredFirstHit ℓ f θ r H y P.2)) + (((G₁.continuous.measurable.comp (measurable_centeredFirstHit _ _ _ _ _ _)).comp measurable_fst).mul + ((G₂.continuous.measurable.comp (measurable_centeredFirstHit _ _ _ _ _ _)).comp measurable_snd)) + (mul_nonneg (norm_nonneg _) (norm_nonneg _)) + (fun P => by rw [abs_mul]; exact mul_le_mul (G₁.norm_coe_le_norm _) (G₂.norm_coe_le_norm _) (abs_nonneg _) (norm_nonneg _)) + (fun w => G₁ ((signedCoordinate f (wordPath x w.1.val w.1.val.length-x)-(H:ℝ)*θ)/r)* + G₂ ((signedCoordinate f (wordPath y w.2.val w.2.val.length-y)-(H:ℝ)*θ)/r)) + intro w P hx hy hw + rw [centeredFirstHit_on_hitWord e f x θ r hH w.1 P.1 hx hw.1] + let w₂ : HitWord y (Strip ℓ y H) (Upper ℓ y H) := ⟨w.2.val,by simpa only [← hs,← ht] using w.2.property⟩ + rw [centeredFirstHit_on_hitWord e f y θ r hH w₂ P.2 hy hw.2] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma centeredFirstHit_integral_recenter {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (f : Direction d) + (θ r : ℝ) (H : ℕ) (x : Lattice d) (G : ℝ →ᵇ ℝ) : + (∫ X, G (centeredFirstHit ℓ f θ r H x X) ∂conditionedFrom ν ℓ x) = + ∫ X, G (centeredFirstHit ℓ f θ r H 0 X) ∂conditionedLaw ν ℓ := by + let : IsProbabilityMeasure (conditionedFrom ν ℓ x) := + conditionedFrom_probability ν ℓ x + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + have hm : Measurable (fun X : Path d => fun n => X n-x) := by fun_prop + have he : (conditionedFrom ν ℓ x).map (fun X : Path d => fun n => X n-x)=conditionedLaw ν ℓ := by + ext A hA + rw [Measure.map_apply hm hA] + exact conditionedFrom_recenter ν ℓ x A hA + rw [← he,integral_map hm.aemeasurable + (show AEStronglyMeasurable (fun X : Path d => G (centeredFirstHit ℓ f θ r H 0 X)) + ((conditionedFrom ν ℓ x).map (fun X : Path d => fun n => X n-x)) from + (Integrable.of_bound + (G.continuous.measurable.comp (measurable_centeredFirstHit ℓ f θ r H 0)).aestronglyMeasurable + ‖G‖ (ae_of_all _ fun path => G.norm_coe_le_norm _)).aestronglyMeasurable)] + congr 1 + funext X + simp only [centeredFirstHit,sub_zero] + +lemma independent_centered_test_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hrpos : ∀ i, 0 < r i) + (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + {t : ℝ} (ht : 0 < t) (G : ℝ →ᵇ ℝ) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + Tendsto (fun i => ∫ X, G (centeredFirstHit ℓ f (θ i) (r i) ⌊t*n i⌋₊ 0 X) ∂conditionedLaw ν ℓ) + atTop (𝓝 (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))) := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ hp + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + obtain ⟨W,hW,hWf⟩ := transverse_firstHit_linear_path_limit ν hue e f hef htrans r hr ht.le + have hnpos : ∀ i, 0 < n i := fun i => recordFluctuationScale_pos ν hue e f hef htrans (hrpos i) + have hn := recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1 + have hf : ∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw (t*(1/(2*commonMeanWidth ν ℓ))) I := by + intro I + simpa only [div_eq_mul_inv,one_mul] using hWf I + have hh := varying_height_path_gaussian_eval (fun _ => μ) + (fun i h X => signedCoordinate f (recordIndexPosition ℓ h X)-(h:ℝ)*θ i) + (fun i h => ((measurable_of_countable (signedCoordinate f)).comp + (measurable_recordIndexPosition ℓ h)).sub_const _) r n hnpos t ht + (1/(2*commonMeanWidth ν ℓ)) W hW hf (fun i => ⌊t*n i⌋₊) + (fun i => Nat.floor_le (mul_pos ht (hnpos i)).le) + ((tendsto_nat_floor_mul_div_atTop ht.le).comp hn) + have hi := integral_bounded_test_tendsto (fun _ => μ) _ + (⟨gaussianReal 0 (Real.toNNReal ((1/(2*commonMeanWidth ν ℓ))*t)),inferInstance⟩ : ProbabilityMeasure ℝ) hh G + simpa only [centeredFirstHit,sub_zero,ProbabilityMeasure.coe_mk,div_eq_mul_inv,one_mul, + mul_comm ((2*commonMeanWidth ν ℓ)⁻¹)] using hi + +lemma independent_centered_clip_product_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hrpos : ∀ i, 0 < r i) + (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x y : ℕ → Lattice d) {t : ℝ} (ht : 0 < t) (w : ℝ≥0) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + Tendsto (fun i => ∫ P, symmetricClip w (centeredFirstHit ℓ f (θ i) (r i) ⌊t*n i⌋₊ (x i) P.1)* + symmetricClip w (centeredFirstHit ℓ f (θ i) (r i) ⌊t*n i⌋₊ (y i) P.2) + ∂(conditionedFrom ν ℓ (x i)).prod (conditionedFrom ν ℓ (y i))) atTop (𝓝 0) := by + dsimp only + have hi := independent_centered_test_limit ν hue e f hef htrans r hrpos hr ht (symmetricClip w) + dsimp only at hi + rw [symmetricClip_gaussian_integral] at hi + have hh := hi.mul hi + simp only [mul_zero] at hh + apply hh.congr + intro i + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans) + let : IsProbabilityMeasure (conditionedFrom ν (realPosition (step e)) (x i)) := conditionedFrom_probability ν _ _ hp + let : IsProbabilityMeasure (conditionedFrom ν (realPosition (step e)) (y i)) := conditionedFrom_probability ν _ _ hp + let ℓ := realPosition (step e) + let θ := recordMedianSlope ν ℓ hp f (r i) + let H := ⌊t*fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i)⌋₊ + have he := integral_prod_mul (μ := conditionedFrom ν ℓ (x i)) (ν := conditionedFrom ν ℓ (y i)) + (fun X : Path d => symmetricClip w (centeredFirstHit ℓ f θ (r i) H (x i) X)) + (fun X : Path d => symmetricClip w (centeredFirstHit ℓ f θ (r i) H (y i) X)) + rw [centeredFirstHit_integral_recenter ν _ htrans,centeredFirstHit_integral_recenter ν _ htrans] at he + exact he.symm + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SingleAdjacentRadiusBound.lean b/lean/OAI/Probability/Ballisticity/Estimates/SingleAdjacentRadiusBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..997fd43a8485a09c56cbf9ab3f2e4c7b75360024 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SingleAdjacentRadiusBound.lean @@ -0,0 +1,242 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SingleCoverWord + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma single_adjacent_radius_bound {d : ℕ} (ℓ : Vector d) (e : Direction d) (X : Path d) + (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (hs : ∀ h, 0 < h → X ∈ RecordIndexPrefix ℓ h (recordIndexTime ℓ h X)) (h : ℕ) : + |signedCoordinate e (recordIndexPosition ℓ (h+1) X)-signedCoordinate e (recordIndexPosition ℓ h X)| ≤ + 2*wordRadius (singleCoverWord ℓ h X) := by + let k := renewalCount (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) h + let j := regenerationTimes ℓ X k + let t := regenerationTimes ℓ X (k+1) + have ht := regenerationTimes_true ℓ X h0 hX + have hl := renewalCount_lower (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) h + have hu := renewalCount_upper (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) + (single_width_positive ℓ X hX) h + have hc (n : ℕ) : recordCount ℓ X (regenerationTimes ℓ X n) = + renewalSum (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) n := + recordCount_regenerationTimes ℓ X h0 hX n + have hlow : recordCount ℓ X j ≤ h := by rw [hc]; exact hl + have hupp : h < recordCount ℓ X t := by rw [hc]; exact hu + have hbound0 : j ≤ recordIndexTime ℓ h X ∧ recordIndexTime ℓ h X ≤ t := by + by_cases hh : h = 0 + · subst h + simp only [k,renewalCount_zero,j,regenerationTimes_zero,recordIndexTime_zero,Nat.le_refl,Nat.zero_le,and_self] + · exact (recordTime_between ℓ X (ht k).1 (hs h (Nat.pos_of_ne_zero hh)) hlow hupp).imp_right le_of_lt + have hbound1 : j ≤ recordIndexTime ℓ (h+1) X ∧ recordIndexTime ℓ (h+1) X ≤ t := by + have hn := hs (h+1) (Nat.succ_pos h) + constructor + · by_contra! hh + have hlt := recordCount_lt_of_strictRecord ℓ X hh (ht k).1 + rw [hn.2.2.1] at hlt + omega + · by_contra! hh + have hlt := recordCount_lt_of_strictRecord ℓ X hh hn.2.1 + rw [hn.2.2.1] at hlt + omega + have hw : ∀ a ≤ (regenerationWords ℓ X k).length, X (j+a)-X j = wordPath 0 (regenerationWords ℓ X k) a := by + intro a ha + rw [← iterate_renewSuffix_eq ℓ X h0 k a] + exact (hX k).2.1 a ha + have ht' : t = j+(regenerationWords ℓ X k).length := regenerationTimes_succ ℓ X k + have h1 := coordinate_prefix_bound e X (regenerationWords ℓ X k) hw hbound0.1 (ht' ▸ hbound0.2) + have h2 := coordinate_prefix_bound e X (regenerationWords ℓ X k) hw hbound1.1 (ht' ▸ hbound1.2) + change |_ - _| ≤ 2*wordRadius (regenerationWords ℓ X k) + calc + _ = |(signedCoordinate e (X (recordIndexTime ℓ (h+1) X))-signedCoordinate e (X j))- + (signedCoordinate e (X (recordIndexTime ℓ h X))-signedCoordinate e (X j))| := by + dsimp only [recordIndexPosition]; congr 1; ring + _ ≤ _ := (abs_sub _ _).trans (by linarith) + +lemma conditioned_adjacent_radius_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (e : Direction d) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ X ∂conditionedLaw ν ℓ, ∀ h : ℕ, + |signedCoordinate e (recordIndexPosition ℓ (h+1) X)-signedCoordinate e (recordIndexPosition ℓ h X)| ≤ + 2*wordRadius (singleCoverWord ℓ h X) := by + have hs : ∀ᵐ X ∂conditionedLaw ν ℓ, ∀ h, 0 < h → X ∈ RecordIndexPrefix ℓ h (recordIndexTime ℓ h X) := by + apply ae_all_iff.mpr + intro h + by_cases hh : 0 < h + · exact (conditioned_recordIndexTime_spec ν ℓ htrans hh).mono (fun _ hX _ => hX) + · exact Eventually.of_forall fun _ hh' => (hh hh').elim + filter_upwards [conditioned_all_firstWords ν ℓ htrans, + (conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_initial ν),hs] with X hX h0 hs h + exact single_adjacent_radius_bound ℓ e X h0 hX hs h + +theorem conditioned_adjacent_increment_small {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (e : Direction d) (htrans : DirectionallyTransient ν ℓ) + (h : ℕ → ℕ) (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) : + Tendsto (fun i => (conditionedLaw ν ℓ).real {X | + r i ≤ |signedCoordinate e (recordIndexPosition ℓ (h i+1) X)- + signedCoordinate e (recordIndexPosition ℓ (h i) X)|}) atTop (𝓝 0) := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + apply squeeze_zero (fun _ => measureReal_nonneg) (fun i => + ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae ?_)) + (single_cover_tail_small ν ℓ htrans wordRadius h (fun i => r i/2) (hr.atTop_div_const (by norm_num))) + filter_upwards [conditioned_adjacent_radius_bound ν ℓ e htrans] with X hX hi + change r i ≤ |signedCoordinate e (recordIndexPosition ℓ (h i+1) X)- + signedCoordinate e (recordIndexPosition ℓ (h i) X)| at hi + rw [abs_of_nonneg (wordRadius_nonneg _)] + exact (div_le_iff₀ (by norm_num : (0:ℝ)<2)).mpr (by linarith [hX (h i)]) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SingleCoverWord.lean b/lean/OAI/Probability/Ballisticity/Estimates/SingleCoverWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ce83c294229858d5f5e7ac31025be22ed304681 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SingleCoverWord.lean @@ -0,0 +1,362 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SharedConditionedPairLawFst + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def singleCoverWord {d : ℕ} (ℓ : Vector d) (h : ℕ) (X : Path d) : + List (Direction d) := + regenerationWords ℓ X (renewalCount (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) h) + +lemma measurable_countable_select {Ω α : Type*} [MeasurableSpace Ω] [MeasurableSpace α] + (F : ℕ → Ω → α) (hF : ∀ j, Measurable (F j)) (k : Ω → ℕ) (hk : Measurable k) : + Measurable (fun X => F (k X) X) := + (measurable_from_prod_countable_left (f := fun p : Ω × ℕ => F p.2 p.1) hF).comp + (measurable_id.prodMk hk) + +lemma measurable_singleCoverWord {d : ℕ} (ℓ : Vector d) (h : ℕ) : + Measurable (singleCoverWord ℓ h) := by + unfold singleCoverWord + exact measurable_countable_select (fun j X => regenerationWords ℓ X j) + (measurable_regenerationWord ℓ) + (fun X => renewalCount (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) h) + (measurable_renewalCount (fun j X => wordRecordCount ℓ (regenerationWords ℓ X j)) + (fun j => (measurable_of_countable (wordRecordCount ℓ)).comp (measurable_regenerationWord ℓ j)) h) + +lemma single_width_positive {d : ℕ} (ℓ : Vector d) (X : Path d) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) (n : ℕ) : + 0 < wordRecordCount ℓ (regenerationWords ℓ X n) := + wordRecordCount_positive ℓ _ + (((firstTrueWord_characterization ℓ _ _ (hX n).2.1).mp ⟨(hX n).1,(hX n).2.2⟩).1) + +theorem single_cover_event_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (A : Set (List (Direction d))) (hA : MeasurableSet A) (h : ℕ) : + (conditionedLaw ν ℓ).real {X | singleCoverWord ℓ h X ∈ A} ≤ + ∫ X, if firstWord ℓ X ∈ A then (wordRecordCount ℓ (firstWord ℓ X) : ℝ) else 0 + ∂conditionedLaw ν ℓ := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + apply renewal_selected_event_bound _ (fun j X => regenerationWords ℓ X j) + (measurable_regenerationWord ℓ) (regenerationWords_independent ν ℓ htrans) + (regenerationWords_identDistrib ν ℓ htrans) (wordRecordCount ℓ) (measurable_of_countable _) _ + (conditioned_wordRecordCount_integrable ν ℓ htrans).1 A hA h + filter_upwards [conditioned_all_firstWords ν ℓ htrans] with X hX n + exact single_width_positive ℓ X hX n + +lemma single_cover_tail_small {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (R : List (Direction d) → ℝ) (h : ℕ → ℕ) (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) : + Tendsto (fun i => (conditionedLaw ν ℓ).real {X | r i ≤ |R (singleCoverWord ℓ (h i) X)|}) + atTop (𝓝 0) := by + apply squeeze_zero (fun _ => measureReal_nonneg) (fun i => + single_cover_event_bound ν ℓ htrans {w | r i ≤ |R w|} (Set.to_countable _).measurableSet (h i)) + exact width_mark_tail_tendsto _ _ + ((measurable_of_countable (wordRecordCount ℓ)).comp (measurable_firstWord ℓ)) + (conditioned_wordRecordCount_integrable ν ℓ htrans).1 _ + ((measurable_of_countable R).comp (measurable_firstWord ℓ)) r hr + +lemma late_failure_cover_width {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (height : Lattice d → ℤ) (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ n, height (X (n+1)) ≤ height (X n)+1) + (h B c b : ℕ) (hc : X ∈ FirstLayerHit height (h+B) c) (hcb : c ≤ b) + (hb : height (X b) < h) : + B < wordRecordCount ℓ (singleCoverWord ℓ h X) := by + let k := renewalCount (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) h + let t := regenerationTimes ℓ X (k+1) + have ht := regenerationTimes_true ℓ X h0 hX (k+1) + have hzero : height (X 0) = 0 := by + have hh := hproj 0 + simp only [realPosition,dot,Pi.zero_apply,Int.cast_zero,zero_mul,Finset.sum_const_zero] at hh + rw [h0] + exact_mod_cast hh.symm + have he : height (X t) = (renewalSum (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) (k+1) : ℤ) := by + rw [recordCount_eq_height_at_record ℓ height hproj X hstep ht.1,hzero,zero_add, + recordCount_regenerationTimes ℓ X h0 hX] + rfl + have hl := renewalCount_lower (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) h + have hu := renewalCount_upper (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) + (single_width_positive ℓ X hX) h + change renewalSum _ k ≤ h at hl + change h < renewalSum _ (k+1) at hu + by_contra! hn + change wordRecordCount ℓ (regenerationWords ℓ X k) ≤ B at hn + have htH : height (X t) ≤ (h+B : ℕ) := by + rw [he,renewalSum_succ] + exact_mod_cast (Nat.add_le_add hl hn) + have htc : t ≤ c := by + by_contra! hh + have hs := ht.1 c hh + rw [hproj,hproj,hc.1] at hs + exact (not_lt_of_ge (by exact_mod_cast htH)) hs + have hh := ht.2 (b-t) + rw [Nat.add_sub_of_le (htc.trans hcb),hproj,hproj] at hh + have hh' : height (X t) ≤ height (X b) := by exact_mod_cast hh + rw [he] at hh' + have hu' : (h : ℤ) < (renewalSum (fun j => wordRecordCount ℓ (regenerationWords ℓ X j)) (k+1) : ℤ) := by + exact_mod_cast hu + omega + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma conditionedFrom_recenter {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x : Lattice d) (A : Set (Path d)) (hA : MeasurableSet A) : + conditionedFrom ν ℓ x ((fun X : Path d => fun n => X n-x) ⁻¹' A) = conditionedLaw ν ℓ A := by + have hm : Measurable (fun X : Path d => fun n => X n-x) := by fun_prop + rw [conditionedFrom,Measure.smul_apply,Measure.restrict_apply (hA.preimage hm),conditionedLaw, + Measure.smul_apply,Measure.restrict_apply hA] + congr 1 + have he : NoDrop ℓ x = (fun X : Path d => fun n => X n-x) ⁻¹' NoDrop ℓ 0 := by + rw [noDrop_translation,add_zero] + rw [he,← Set.preimage_inter,annealedFrom_apply ν x _ ((hA.inter (measurableSet_noDrop ℓ 0)).preimage hm), + annealed_event_translation ν x _ (hA.inter (measurableSet_noDrop ℓ 0))] + +lemma shared_recenter_marginal_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) + (c : ℝ) (hc : 0 < c) (hlo : ENNReal.ofReal c ≤ sharedNoDropMass ν ℓ x y) + (A : Set (Path d)) (hA : MeasurableSet A) : + (sharedConditionedPairLaw ν ℓ x y).real {P | (fun n => P.1 n-x) ∈ A} ≤ + c⁻¹ * (conditionedLaw ν ℓ).real A := by + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hm : Measurable (fun X : Path d => fun n => X n-x) := by fun_prop + have hh := sharedConditionedPairLaw_fst_le ν ℓ x y _ (hA.preimage hm) hp + rw [conditionedFrom_recenter ν ℓ x A hA] at hh + have hq : sharedNoDropMass ν ℓ x y ≠ 0 := ne_of_gt ((ENNReal.ofReal_pos.mpr hc).trans_le hlo) + have hfin : (sharedNoDropMass ν ℓ x y)⁻¹ * annealedLaw ν (NoDrop ℓ 0) * conditionedLaw ν ℓ A ≠ ⊤ := by + exact ENNReal.mul_ne_top (ENNReal.mul_ne_top (ENNReal.inv_ne_top.mpr hq) (measure_ne_top _ _)) + (by let _ := conditionedLaw_probability ν ℓ hp; exact measure_ne_top _ _) + have hh' := ENNReal.toReal_mono hfin hh + rw [ENNReal.toReal_mul,ENNReal.toReal_mul,ENNReal.toReal_inv] at hh' + apply hh'.trans + apply mul_le_mul_of_nonneg_right _ measureReal_nonneg + calc + _ ≤ (sharedNoDropMass ν ℓ x y).toReal⁻¹ := + mul_le_of_le_one_right (inv_nonneg.mpr ENNReal.toReal_nonneg) (by exact measureReal_le_one) + _ ≤ c⁻¹ := by + apply inv_anti₀ hc + have h := ENNReal.toReal_mono (ne_top_of_le_ne_top ENNReal.one_ne_top (sharedNoDropMass_le_one ν ℓ x y)) hlo + rwa [ENNReal.toReal_ofReal hc.le] at h + +lemma shared_recenter_marginal_bound_snd {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) + (c : ℝ) (hc : 0 < c) (hlo : ENNReal.ofReal c ≤ sharedNoDropMass ν ℓ x y) + (A : Set (Path d)) (hA : MeasurableSet A) : + (sharedConditionedPairLaw ν ℓ x y).real {P | (fun n => P.2 n-y) ∈ A} ≤ + c⁻¹ * (conditionedLaw ν ℓ).real A := by + have hh := shared_recenter_marginal_bound ν ℓ htrans y x c hc + (by rwa [sharedNoDropMass_swap]) A hA + rw [← sharedConditionedPairLaw_swap ν ℓ x y,measureReal_def,Measure.map_apply measurable_swap + (show MeasurableSet {P : Path d × Path d | (fun n => P.1 n-y) ∈ A} from hA.preimage (by fun_prop))] at hh + exact hh + +lemma height_sub {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) (x y : Lattice d) : + height (x-y) = height x-height y := by + have hh := dot_realPosition_sub x y ℓ + rw [hproj,hproj,hproj] at hh + exact_mod_cast hh + +def LateFailure {d : ℕ} (height : Lattice d → ℤ) (h B : ℤ) : Set (Path d) := + {X | ∃ c b, X ∈ FirstLayerHit height (h+B) c ∧ c ≤ b ∧ height (X b) < h} + +lemma measurableSet_lateFailure {d : ℕ} (height : Lattice d → ℤ) (h B : ℤ) : + MeasurableSet (LateFailure height h B) := by + simp only [LateFailure,Set.ofPred_exists,Set.ofPred_and] + exact MeasurableSet.iUnion fun c => MeasurableSet.iUnion fun b => + (measurableSet_firstLayerHit height (h+B) c).inter + ((MeasurableSet.const (c ≤ b)).inter (measurableSet_lt + ((measurable_of_countable height).comp (measurable_pi_apply b)) measurable_const)) + +lemma lateFailure_recenter {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (x : Lattice d) (h B : ℤ) (X : Path d) : + X ∈ LateFailure height (height x+h) B ↔ + (fun n => X n-x) ∈ LateFailure height h B := by + simp only [LateFailure,FirstLayerHit,Set.mem_ofPred_eq,height_sub ℓ height hproj] + apply exists_congr + intro c + apply exists_congr + intro b + constructor <;> rintro ⟨⟨he,hlt⟩,hcb,hb⟩ + · exact ⟨⟨by omega,fun j hj => by have := hlt j hj; omega⟩,hcb,by omega⟩ + · exact ⟨⟨by omega,fun j hj => by have := hlt j hj; omega⟩,hcb,by omega⟩ + +lemma conditioned_late_failure_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) (h B : ℕ) : + (conditionedLaw ν ℓ).real (LateFailure height h B) ≤ + ∫ X, if B < wordRecordCount ℓ (firstWord ℓ X) then + (wordRecordCount ℓ (firstWord ℓ X) : ℝ) else 0 ∂conditionedLaw ν ℓ := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + have hbnd := single_cover_event_bound ν ℓ htrans {w | B < wordRecordCount ℓ w} + (Set.to_countable _).measurableSet h + simp only [Set.mem_ofPred_eq] at hbnd + refine le_trans (b := (conditionedLaw ν ℓ).real {X | B < wordRecordCount ℓ (singleCoverWord ℓ h X)}) ?_ ?_ + swap + · convert hbnd using 1; try rfl + apply integral_congr_ae + filter_upwards [] with X + congr 1 + apply ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae ?_) + have hac := conditionedLaw_absolutelyContinuous ν ℓ + filter_upwards [conditioned_all_firstWords ν ℓ htrans,hac.ae_le (annealed_initial ν), + hac.ae_le (annealed_nearest_neighbor ν)] with X hX h0 hnn hlate + obtain ⟨c,b,hc,hcb,hb⟩ := hlate + exact late_failure_cover_width ℓ X h0 hX height hproj (fun n => by + obtain ⟨u,hu⟩ := hnn n; rw [hu]; exact hstep _ _) h B c b (by simpa only [Nat.cast_add] using hc) hcb hb + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SingleThreat.lean b/lean/OAI/Probability/Ballisticity/Estimates/SingleThreat.lean new file mode 100644 index 0000000000000000000000000000000000000000..781f7c209c0c9954af5390b829ec4b935fc9c730 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SingleThreat.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BudgetThreat + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma noDropMass_le_budget_bad {d k : ℕ} (e f : Direction d) (ω : Environment d) + (hreg : ∀ x, ∀ᵐ X ∂quenchedKernel (ω,x), X ∈ RegularPath (realPosition (step e)) x) + (H h : ℕ) (hh : h ≤ H) (b : ℕ → ℝ) (z : ℝ) + (π : Measure (Fin k → Lattice d)) [IsFiniteMeasure π] : + (∫ x, noDropProduct (realPosition (step e)) x ω ∂π) ≤ + relativeBudgetMass e f h (2*z) π ω + + tupleBadMass (realPosition (step e)) (MedianTubeFailure (realPosition (step e)) f b H z) π ω := by + let A := MedianTubeFailure (realPosition (step e)) f b H z + have hI (F : (Fin k → Lattice d) → ℝ) (B : ℝ) (hF : ∀ x, 0 ≤ F x ∧ F x ≤ B) : Integrable F π := by + apply (integrable_const B).mono' (measurable_of_countable _).aestronglyMeasurable + exact ae_of_all _ fun x => by rw [Real.norm_eq_abs,abs_of_nonneg (hF x).1]; exact (hF x).2 + have hq := hI (fun x => noDropProduct (realPosition (step e)) x ω) 1 + (fun x => noDropProduct_bounds _ x ω) + have hm := hI (fun x => (relativeBudgetWordLaw e f h (2*z) ω x).real Set.univ) 1 + (fun x => ⟨measureReal_nonneg,by + exact (ENNReal.toReal_mono ENNReal.one_ne_top (relativeBudgetWordLaw_le_one e f h (2*z) ω x)).trans_eq ENNReal.toReal_one⟩) + have hb := hI (fun x => ∑ j, relativeBadMass (realPosition (step e)) A ω (x j)) k + (fun x => sum_relativeBadMass_bounds _ A ω x) + change _ ≤ (∫ x, (relativeBudgetWordLaw e f h (2*z) ω x).real Set.univ ∂π) + + ∫ x, ∑ j, relativeBadMass (realPosition (step e)) A ω (x j) ∂π + rw [← integral_add hm hb] + apply integral_mono hq (hm.add hb) + intro x + exact (product_noDrop_le_good_bad _ A (measurableSet_medianTubeFailure _ f b H z) ω x).trans + (add_le_add (tupleGood_le_relativeBudget e f ω hreg H h hh b z x) le_rfl) + +def budgetThreatEvent {d k : ℕ} (e f : Direction d) (H : ℕ) (r : ℝ) + (π : Measure (Fin k → Lattice d)) (s : ℝ) : Set (Environment d) := + {ω | ∃ h ≤ H, relativeBudgetMass e f h r π ω < s} + +lemma budgetThreatEvent_subset_ae {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (H : ℕ) (b : ℕ → ℝ) (z s : ℝ) (π : Measure (Fin k → Lattice d)) [IsFiniteMeasure π] : + budgetThreatEvent e f H (2*z) π s ≤ᵐ[environmentLaw ν] + (({ω | (∫ x, noDropProduct (realPosition (step e)) x ω ∂π) < 2*s} ∪ + {ω | s < tupleBadMass (realPosition (step e)) (MedianTubeFailure (realPosition (step e)) f b H z) π ω}) : Set (Environment d)) := by + filter_upwards [quenched_regularPath_ae ν _ htrans] with ω hω + rintro ⟨h,hh,hbad⟩ + by_cases hq : (∫ x, noDropProduct (realPosition (step e)) x ω ∂π) < 2*s + · exact Or.inl hq + · right + have hm := noDropMass_le_budget_bad e f ω hω H h hh b z π + change s < _ + linarith + +lemma single_budget_threat_bound {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (H : ℕ) (b : ℕ → ℝ) (z : ℝ) {s : ℝ} (hs : 0 < s) + (π : Measure (Fin k → Lattice d)) [IsProbabilityMeasure π] : + (environmentLaw ν).real (budgetThreatEvent e f H (2*z) π s) ≤ + (environmentLaw ν).real {ω | (∫ x, noDropProduct (realPosition (step e)) x ω ∂π) < 2*s} + + (k:ℝ)*(annealedLaw ν).real (MedianTubeFailure (realPosition (step e)) f b H z ∩ NoDrop (realPosition (step e)) 0)/s := by + let A := MedianTubeFailure (realPosition (step e)) f b H z + have hA := measurableSet_medianTubeFailure (realPosition (step e)) f b H z + have hm := ENNReal.toReal_mono (measure_ne_top _ _) + (measure_mono_ae (budgetThreatEvent_subset_ae ν e f htrans H b z s π)) + have hu := measureReal_union_le (μ := environmentLaw ν) + {ω | (∫ x, noDropProduct (realPosition (step e)) x ω ∂π) < 2*s} + {ω | s < tupleBadMass (realPosition (step e)) A π ω} + apply hm.trans (hu.trans (add_le_add le_rfl ?_)) + have hb := mul_meas_ge_le_integral_of_nonneg + (ae_of_all (environmentLaw ν) fun ω => tupleBadMass_nonneg (realPosition (step e)) A π ω) + (integrable_sum_relativeBadMass ν (realPosition (step e)) A hA π).integral_prod_left s + rw [tupleBadMass_mean ν (realPosition (step e)) A hA π] at hb + apply (le_div_iff₀ hs).mpr + rw [mul_comm] + exact (mul_le_mul_of_nonneg_left (measureReal_mono (show {ω | s < tupleBadMass (realPosition (step e)) A π ω} ⊆ {ω | s ≤ tupleBadMass (realPosition (step e)) A π ω} from fun ω h => show s ≤ tupleBadMass (realPosition (step e)) A π ω from (show s < tupleBadMass (realPosition (step e)) A π ω from h).le)) hs.le).trans hb + +lemma annealed_noDrop_event_le_conditioned {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (A : Set (Path d)) (hA : MeasurableSet A) : + (annealedLaw ν).real (A ∩ NoDrop ℓ 0) ≤ (conditionedLaw ν ℓ).real A := by + have he : annealedLaw ν (NoDrop ℓ 0)*conditionedLaw ν ℓ A = annealedLaw ν (A ∩ NoDrop ℓ 0) := by + rw [conditionedLaw,Measure.smul_apply,Measure.restrict_apply hA,smul_eq_mul, + ← mul_assoc,ENNReal.mul_inv_cancel hp (measure_ne_top _ _),one_mul] + have he' := congrArg ENNReal.toReal he + simp only [ENNReal.toReal_mul] at he' + change ((annealedLaw ν) (A ∩ NoDrop ℓ 0)).toReal ≤ _ + rw [← he'] + exact mul_le_of_le_one_left ENNReal.toReal_nonneg (by exact measureReal_le_one) + +lemma annealed_median_failure_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (H : ℕ) {z : ℝ} (hz : 0 < z) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν).real (NoDrop ℓ 0) + (annealedLaw ν).real (MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H z ∩ NoDrop ℓ 0) ≤ + (10/p^2)*(H:ℝ)/fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) z := by + dsimp only + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hp0 : 0 < (annealedLaw ν).real (NoDrop ℓ 0) := ENNReal.toReal_pos hp (measure_ne_top _ _) + let A := MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H z + have hA := measurableSet_medianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H z + have ha := annealed_noDrop_event_le_conditioned ν ℓ hp A hA + have hb := conditioned_median_tube_bound ν e f htrans H hz + dsimp only at hb + have hc : ((annealedLaw ν).real (NoDrop ℓ 0))^2/2*(annealedLaw ν).real (A ∩ NoDrop ℓ 0) ≤ + 5*(H:ℝ)/fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) z := + (mul_le_mul_of_nonneg_left ha (by positivity)).trans hb + have hi : (annealedLaw ν).real (A ∩ NoDrop ℓ 0) ≤ + (5*(H:ℝ)/fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) z) / + (((annealedLaw ν).real (NoDrop ℓ 0))^2/2) := by + apply (le_div_iff₀ (show 0 < ((annealedLaw ν).real (NoDrop ℓ 0))^2/2 by positivity)).mpr + nlinarith only [hc] + convert hi using 1; dsimp [A,ℓ] + ring + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SmallScaleGaussianMass.lean b/lean/OAI/Probability/Ballisticity/Estimates/SmallScaleGaussianMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..b84745c8ddf8eb77c62a4b16fe69c535ce5ae749 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SmallScaleGaussianMass.lean @@ -0,0 +1,160 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.VarianceTailDifference +import OAI.Probability.Ballisticity.Coupling.GaussianQuenchedMass + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma dyadic_inv_tendsto : Tendsto (fun j => (dyadicCut j)⁻¹) atTop atTop := + tendsto_inv_nhdsGT_zero.comp (tendsto_nhdsWithin_iff.mpr + ⟨dyadicCut_tendsto,Eventually.of_forall dyadicCut_pos⟩) + +theorem small_scale_gaussian_mass {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) {ρ : ℝ} (hρ : 0 < ρ) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + ∃ c : ℝ, 0 < c ∧ ∀ (r : ℕ → ℝ), (∀ n, 0 < r n) → Tendsto r atTop atTop → + ∀ (F : ℕ → ℝ) (F₀ : ℝ), 0 < F₀ → (∀ j, F₀ ≤ F j) → Tendsto F atTop (𝓝 F₀) → + (∀ j, Tendsto (fun n => truncatedVariance μ S (dyadicCut j*r n)/truncatedVariance μ S (r n)) atTop (𝓝 (F j))) → + ∀ b : ℝ, 0 < b → ∀ x : Lattice d, ∀ δ : ℝ, 0 < δ → + ∀ᶠ j in atTop, ∀ᶠ n in atTop, + (environmentLaw ν).real {ω | + (successQuenchedKernel ℓ x (⌊fluctuationScale μ S (dyadicCut j*r n)⌋₊:ℕ) ω).real + (medianTubeEndpoint ν ℓ hp f x ⌊fluctuationScale μ S (dyadicCut j*r n)⌋₊ + (b*r n) (ρ*(dyadicCut j*r n))) < c} < δ := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + obtain ⟨c,hc,hGaussian⟩ := gaussian_quenched_mass ν hue e f hef htrans hρ + refine ⟨c,hc,?_⟩ + intro r hr hrinf F F₀ hF₀ hFle hFlim hF b hb x δ hδ + let z := fun j n => dyadicCut j*r n + let bad := fun j n => (environmentLaw ν).real {ω | + (successQuenchedKernel ℓ x (⌊fluctuationScale μ S (z j n)⌋₊:ℕ) ω).real + (medianTubeEndpoint ν ℓ hp f x ⌊fluctuationScale μ S (z j n)⌋₊ (b*r n) (ρ*z j n)) < c} + change ∀ᶠ j in atTop, ∀ᶠ n in atTop, bad j n < δ + by_contra hbad + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have htail := dyadic_profile_gaussian_tail μ S (measurable_commonIncrementProcess ℓ f 0) hne r hr F hF₀ hFle hF hFlim + obtain ⟨j,n,hj,hGauss,hbadn⟩ := double_gaussian_selection μ S z + (fun j => hrinf.const_mul_atTop (dyadicCut_pos j)) (fun k δ hδ => htail k hδ) bad hbad + have hbStar : Tendsto (fun i => b/dyadicCut (j i)) atTop atTop := by + simpa only [div_eq_mul_inv,Function.comp_apply] using (dyadic_inv_tendsto.comp hj).const_mul_atTop hb + have hconc := hGaussian (fun i => z (j i) (n i)) hGauss (fun i => b/dyadicCut (j i)) hbStar x + have heq (i) : (b/dyadicCut (j i))*z (j i) (n i) = b*r (n i) := by + dsimp [z] + field_simp [ne_of_gt (dyadicCut_pos (j i))] + simp only [heq] at hconc + have hconc' : Tendsto (fun i => bad (j i) (n i)) atTop (𝓝 0) := hconc + obtain ⟨i,hi⟩ := (hconc'.eventually (gt_mem_nhds hδ)).exists + exact (not_lt_of_ge (hbadn i)) hi + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +noncomputable def bandTruncate (z R x : ℝ) : ℝ := symmetricTruncate R x-symmetricTruncate z x +lemma measurable_bandTruncate (z R : ℝ) : Measurable (bandTruncate z R) := + (measurable_symmetricTruncate R).sub (measurable_symmetricTruncate z) +lemma bandTruncate_bound {z R : ℝ} (hz : 0 ≤ z) (hzR : z ≤ R) (x : ℝ) : |bandTruncate z R x| ≤ R := by + unfold bandTruncate symmetricTruncate + by_cases hxz : |x| ≤ z + · simp only [ite_eq_left hxz,ite_eq_left (hxz.trans hzR),sub_self,abs_zero] + exact hz.trans hzR + · simp only [ite_eq_right hxz,sub_zero] + split_ifs with hxR + · exact hxR + · simpa using hz.trans hzR +lemma bandTruncate_neg (z R x : ℝ) : bandTruncate z R (-x) = -bandTruncate z R x := by + simp only [bandTruncate,symmetricTruncate_neg]; ring + +lemma bandTruncate_cost_identity {z R : ℝ} (hz : 0 ≤ z) (hzR : z ≤ R) (x : ℝ) : + (bandTruncate z R x)^2+truncatedTailCost R x = + min (x^2) (R^2)-min (x^2) (z^2)+truncatedTailCost z x := by + have hs := sq_abs x + have hx := abs_nonneg x + unfold bandTruncate symmetricTruncate truncatedTailCost + by_cases hxz : |x| ≤ z + · have hxR := hxz.trans hzR + simp only [ite_eq_left hxz,ite_eq_left hxR,ite_eq_right (not_lt.mpr hxz),ite_eq_right (not_lt.mpr hxR),sub_self,zero_pow (by norm_num : 2 ≠ 0),add_zero] + rw [min_eq_left (by nlinarith : x^2 ≤ R^2),min_eq_left (by nlinarith : x^2 ≤ z^2),sub_self] + · have hzx : z < |x| := lt_of_not_ge hxz + by_cases hxR : |x| ≤ R + · simp only [ite_eq_left hxR,ite_eq_right hxz,ite_eq_right (not_lt.mpr hxR),ite_eq_left hzx,sub_zero,add_zero] + rw [min_eq_left (by nlinarith : x^2 ≤ R^2),min_eq_right (by nlinarith : z^2 ≤ x^2)] + ring + · have hRx : R < |x| := lt_of_not_ge hxR + simp only [ite_eq_right hxz,ite_eq_right hxR,ite_eq_left hzx,ite_eq_left hRx,sub_self,zero_pow (by norm_num : 2 ≠ 0),zero_add] + rw [min_eq_right (by nlinarith : R^2 ≤ x^2),min_eq_right (by nlinarith : z^2 ≤ x^2)] + ring + +lemma integral_truncatedTailCost {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (hS : Measurable S) (z : ℝ) : + (∫ x, truncatedTailCost z (S x) ∂μ) = z^2*μ.real {x | z < |S x|} := by + change (∫ x, ({x | z < |S x|}).indicator (fun _ => z^2) x ∂μ) = _ + rw [integral_indicator (measurableSet_lt measurable_const hS.abs)] + simp only [integral_const,Measure.real,Measure.restrict_apply_univ,smul_eq_mul,mul_comm] + +lemma integrable_bandTruncate {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + {z R : ℝ} (hz : 0 ≤ z) (hzR : z ≤ R) : Integrable (fun x => bandTruncate z R (S x)) μ := + integrable_of_abs_bound μ _ ((measurable_bandTruncate z R).comp hS) R + (fun sample => bandTruncate_bound hz hzR (S sample)) + +lemma integral_bandTruncate_zero {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (S : Ω → ℝ) (z R : ℝ) + (hsym : IdentDistrib S (fun x => -S x) μ μ) : + ∫ x, bandTruncate z R (S x) ∂μ = 0 := by + have hh := (hsym.comp (measurable_bandTruncate z R)).integral_eq + change (∫ x, bandTruncate z R (S x) ∂μ) = (∫ x, bandTruncate z R (-S x) ∂μ) at hh + simp only [bandTruncate_neg,integral_neg] at hh + linarith + +lemma integral_bandTruncate_cost {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + {z R : ℝ} (hz : 0 ≤ z) (hzR : z ≤ R) : + (∫ x, (bandTruncate z R (S x))^2 ∂μ)+R^2*μ.real {x | R < |S x|} = + truncatedVariance μ S R-truncatedVariance μ S z+z^2*μ.real {x | z < |S x|} := by + have hB : Integrable (fun x => (bandTruncate z R (S x))^2) μ := + integrable_of_abs_bound μ _ (((measurable_bandTruncate z R).comp hS).pow_const 2) (R^2) + (fun x => by rw [abs_pow]; exact pow_le_pow_left₀ (abs_nonneg _) (bandTruncate_bound hz hzR _) 2) + have hT (a : ℝ) : Integrable (fun x => truncatedTailCost a (S x)) μ := by + apply integrable_of_abs_bound μ _ ((measurable_truncatedTailCost a).comp hS) (a^2) + intro x + change |truncatedTailCost a (S x)| ≤ a^2 + unfold truncatedTailCost + split_ifs <;> simp [abs_of_nonneg (sq_nonneg a),sq_nonneg a] + rw [← integral_truncatedTailCost μ S hS R,← integral_add hB (hT R)] + simp only [bandTruncate_cost_identity hz hzR] + change (∫ a, ((fun x => min (S x^2) (R^2)) - (fun x => min (S x^2) (z^2))) a + truncatedTailCost z (S a) ∂μ) = _ + rw [integral_add ((integrable_truncated_square μ S hS R).sub (integrable_truncated_square μ S hS z)) (hT z)] + simp only [Pi.sub_apply] + rw [integral_sub (integrable_truncated_square μ S hS R) (integrable_truncated_square μ S hS z),integral_truncatedTailCost μ S hS z] + rfl + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SmallScaleTailMoment.lean b/lean/OAI/Probability/Ballisticity/Estimates/SmallScaleTailMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..37c14abd0b820a739bee356dcea3b1d051a07f9f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SmallScaleTailMoment.lean @@ -0,0 +1,157 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ScaledMaxTail + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +theorem small_scale_tail_moment {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : ∀ n, 0 < r n) (hrinf : Tendsto r atTop atTop) + (F : ℕ → ℝ) {F₀ : ℝ} (hF₀ : 0 < F₀) (hFle : ∀ j, F₀ ≤ F j) + (hFlim : Tendsto F atTop (𝓝 F₀)) + (hF : ∀ j, Tendsto (fun n => truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (dyadicCut j*r n)/ + truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r n)) atTop (𝓝 (F j))) + {A : ℝ} (hA : 0 < A) (B : ℕ) {δ : ℝ} (hδ : 0 < δ) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + ∀ᶠ j in atTop, + limsup (fun n => cappedTailMoment (successfulAverage ν ℓ ⌊fluctuationScale μ S (dyadicCut j*r n)⌋₊) + (fun X => medianDeviation ℓ f (fun h => (recordMedian ν ℓ hp f h:ℝ)) + ⌊fluctuationScale μ S (dyadicCut j*r n)⌋₊ X/(dyadicCut j*r n)) A (dyadicCut B/dyadicCut j)) atTop ≤ + (16000/p^2)*(2048/(A/40)^2+16*(F B/F₀-1))+δ := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hm (n) : truncatedVariance μ S (r n) ≠ 0 := + ne_of_gt (truncatedVariance_pos μ S (measurable_commonIncrementProcess ℓ f 0) hne (hr n)) + have hlim : Tendsto (fun j => (16000/p^2)*(2048/(A/40)^2+16*(F B/F j-1)+(64/3)*(1-F (j+1)/F j))) + atTop (𝓝 ((16000/p^2)*(2048/(A/40)^2+16*(F B/F₀-1)))) := by + have hsucc : Tendsto (fun j => F (j+1)) atTop (𝓝 F₀) := hFlim.comp (tendsto_add_atTop_nat 1) + have hRlim := (tendsto_const_nhds (x := F B)).div hFlim (ne_of_gt hF₀) + have hGlim := hsucc.div hFlim (ne_of_gt hF₀) + have hh := (((tendsto_const_nhds (x := 2048/(A/40)^2)).add + ((hRlim.sub_const 1).const_mul 16)).add + (((tendsto_const_nhds (x := (1:ℝ))).sub hGlim).const_mul (64/3))).const_mul (16000/p^2) + simpa only [Pi.div_apply,div_self (ne_of_gt hF₀),sub_self,mul_zero,add_zero] using hh + have hsmall := dyadicCut_tendsto.eventually (gt_mem_nhds (div_pos (dyadicCut_pos B) hA)) + filter_upwards [hlim.eventually (gt_mem_nhds (lt_add_of_pos_right _ hδ)),hsmall,eventually_ge_atTop B] + with j hj hsj hBj + have hj0 := dyadicCut_pos j + have hAL : A < dyadicCut B/dyadicCut j := by + rw [lt_div_iff₀ hj0] + have := (lt_div_iff₀ hA).mp hsj + nlinarith + have hL : 1 ≤ dyadicCut B/dyadicCut j := (one_le_div hj0).mpr (dyadicCut_antitone hBj) + have hFj : F j ≠ 0 := ne_of_gt (hF₀.trans_le (hFle j)) + let z := fun n => dyadicCut j*r n + have hz : ∀ n, 0 < z n := fun n => mul_pos hj0 (hr n) + have hzinf : Tendsto z atTop atTop := hrinf.const_mul_atTop hj0 + have hR : Tendsto (fun n => truncatedVariance μ S ((dyadicCut B/dyadicCut j)*z n)/ + truncatedVariance μ S (z n)) atTop (𝓝 (F B/F j)) := by + convert (hF B).div (hF j) hFj using 1 + funext n + have heq : (dyadicCut B/dyadicCut j)*z n = dyadicCut B*r n := by + dsimp [z]; field_simp + rw [heq] + simp only [Pi.div_apply] + change _ = (truncatedVariance μ S _/truncatedVariance μ S (r n))/(truncatedVariance μ S (z n)/truncatedVariance μ S (r n)) + field_simp [hm n] + have hG : Tendsto (fun n => truncatedVariance μ S (z n/2)/truncatedVariance μ S (z n)) + atTop (𝓝 (F (j+1)/F j)) := by + convert (hF (j+1)).div (hF j) hFj using 1 + funext n + rw [dyadicCut_succ] + have heq : z n/2 = (dyadicCut j/2)*r n := by dsimp [z]; ring + rw [heq] + simp only [Pi.div_apply] + change _ = (truncatedVariance μ S _/truncatedVariance μ S (r n))/(truncatedVariance μ S (z n)/truncatedVariance μ S (r n)) + field_simp [hm n] + have hH : Tendsto (fun n => ⌊fluctuationScale μ S (z n)⌋₊) atTop atTop := + tendsto_nat_floor_atTop.comp (recordFluctuationScale_tendsto ν hue e f hef htrans z hzinf) + have hbound := successful_tail_profile_bound ν hue e f hef htrans z hz hzinf _ hH hA hAL hL + (Eventually.of_forall fun n => Nat.floor_le (fluctuationScale_nonneg μ S (z n))) hR hG + exact hbound.trans hj.le + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma success_medianTube_curveIncrement {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (hp : annealedLaw ν (NoDrop (realPosition (step e)) 0) ≠ 0) + (x : Lattice d) {H : ℕ} (hH : 0 < H) (B R : ℝ) (ω : Environment d) : + successQuenchedKernel (realPosition (step e)) x H ω + (medianTubeEndpoint ν (realPosition (step e)) hp f x H B R) = + (crossingQuenched (realPosition (step e)) x H ω)⁻¹* + curveIncrement (realPosition (step e)) f x + (fun j => (recordMedian ν (realPosition (step e)) hp f j:ℝ)) B H ω + {u | |signedCoordinate f u-(recordMedian ν (realPosition (step e)) hp f H:ℝ)| ≤ R} := by + let ℓ := realPosition (step e) + let b := fun j => (recordMedian ν ℓ hp f j:ℝ) + let Z := fun X : Path d => recordIndexPosition ℓ H (fun j => X j-x) + have hZ : Measurable Z := (measurable_recordIndexPosition ℓ H).comp (by fun_prop) + rw [successQuenchedKernel_apply _ _ _ _ _ (measurableSet_medianTubeEndpoint ν ℓ hp f x H B R), + curveIncrement_eq_success_map e f x b B hH ω,Measure.map_apply hZ (Set.to_countable _).measurableSet, + Measure.restrict_apply (hZ (Set.to_countable _).measurableSet)] + congr 2 + ext X + simp only [Set.mem_inter_iff,Set.mem_ofPred_eq,Set.mem_preimage, + medianTubeEndpoint,heightTubeEndpointEvent,medianDeviation_le_iff] + tauto + +lemma curveGaussian_failure_le {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (hp : annealedLaw ν (NoDrop (realPosition (step e)) 0) ≠ 0) + {H : ℕ} (hH : 0 < H) (B R : ℝ) {α c : ℝ} (hα : 0 < α) (hαc : α ≤ c) : + (environmentLaw ν).real {ω | ¬ ENNReal.ofReal α*crossingQuenched (realPosition (step e)) 0 H ω ≤ + curveIncrement (realPosition (step e)) f 0 + (fun j => (recordMedian ν (realPosition (step e)) hp f j:ℝ)) B H ω + {u | |signedCoordinate f u-(recordMedian ν (realPosition (step e)) hp f H:ℝ)| ≤ R}} ≤ + (environmentLaw ν).real {ω | (successQuenchedKernel (realPosition (step e)) 0 H ω).real + (medianTubeEndpoint ν (realPosition (step e)) hp f 0 H B R) < c} := by + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [crossingQuenched_positive_ae ν hue (realPosition (step e)) (signed_direction_unit e) htrans] + with ω hω + intro hbad + have hh : successQuenchedKernel (realPosition (step e)) 0 H ω + (medianTubeEndpoint ν (realPosition (step e)) hp f 0 H B R) < ENNReal.ofReal α := by + rw [success_medianTube_curveIncrement ν e f hp 0 hH B R ω] + apply lt_of_not_ge + intro hh + have hh := (ENNReal.mul_le_iff_le_inv (hω 0 H) (measure_ne_top _ _)).mpr hh + exact hbad (by simpa only [mul_comm] using hh) + have hh' := (ENNReal.toReal_lt_toReal (measure_ne_top _ _) ENNReal.ofReal_ne_top).mpr hh + rw [ENNReal.toReal_ofReal hα.le] at hh' + exact hh'.trans_le hαc +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SmallTimeExponentialError.lean b/lean/OAI/Probability/Ballisticity/Estimates/SmallTimeExponentialError.lean new file mode 100644 index 0000000000000000000000000000000000000000..8034c04c42cd53444a334d26038267c103c7e976 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SmallTimeExponentialError.lean @@ -0,0 +1,421 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.IndependentRecenterMap + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma small_time_exponential_error {m t : ℝ} (hm1 : 1 ≤ m) (ht : 0 fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ f 0) (r i) + let H := fun i => ⌊t*n i⌋₊ + ∀ᶠ i in atTop, + 1+t/(128*commonMeanWidth ν ℓ) ≤ + ∫ P, min (|physicalFirstHitGap ℓ f (x i) (y i) + (H i+commonOffset ℓ (signedHeight e) (signedHeight e (x i)+H i) P) P/r i|^((3:ℝ)/2)) + ((2:ℝ)^((3:ℝ)/2)) ∂sharedConditionedPairLaw ν ℓ (x i) (y i) := by + have hm := commonMeanWidth_ge_one ν (realPosition (step e)) htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) + exact shared_observed_clipped_drift_gaussian ν hue e f hef htrans r hrpos hr x y hxy hgap ht + (by linarith) (small_time_exponential_error hm ht htmax) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +theorem shared_uniform_good_clipped_drift {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1≠f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {t : ℝ} (ht : 0 + 1≤⌊t*n u⌋₊ ∧ 1+t/(128*commonMeanWidth ν ℓ) ≤ + ∫ Q, min (|physicalFirstHitGap ℓ f x y + (⌊t*n u⌋₊+commonOffset ℓ (signedHeight e) (signedHeight e x+⌊t*n u⌋₊) Q) Q/u|^((3:ℝ)/2)) + ((2:ℝ)^((3:ℝ)/2)) ∂sharedConditionedPairLaw ν ℓ x y + change ∃ l ε R : ℝ, 0 1/((i:ℝ)+2) + have ha (i : ℕ) : 0 + mul_nonneg (fluctuationScale_nonneg μ S _) measureReal_nonneg) _ ha0 + filter_upwards [ha0.eventually_lt_const hδ] with i hi + have htail' : μ.real {Q | δ*r i< |S Q|} ≤ μ.real {Q | a i*r i< |S Q|} := by + apply measureReal_mono _ (measure_ne_top _ _) + intro Q hQ + exact lt_of_le_of_lt (mul_le_mul_of_nonneg_right hi.le (hrpos i).le) hQ + exact (mul_le_mul_of_nonneg_left htail' (fluctuationScale_nonneg μ S _)).trans (htail i) + have hdrift := shared_observed_clipped_drift_small_time ν hue e f hef htrans r hrpos hgauss + x y hxy hgap ht htmax + have hnlarge := recordFluctuationScale_tendsto ν hue e f hef htrans r hgauss.1 + have hH : ∀ᶠ i in atTop, 1≤⌊t*n (r i)⌋₊ := by + filter_upwards [(hnlarge.const_mul_atTop ht).eventually_ge_atTop 1] with i hi + exact Nat.floor_pos.mpr hi + obtain ⟨i,hi,hHi⟩ := (hdrift.and hH).exists + exact hbad i ⟨hHi,hi⟩ + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StageClassification.lean b/lean/OAI/Probability/Ballisticity/Estimates/StageClassification.lean new file mode 100644 index 0000000000000000000000000000000000000000..29f79fbeee3b297b482eb5b3d5d274dcf30d15b4 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StageClassification.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeRetention + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +noncomputable def episodeStageFails {d k : ℕ} (e f : Direction d) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) : Prop := + stageTestMass e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (episodeStageLength e f r fexp g χ b N q ω) ω < + ENNReal.ofReal (Real.exp (-((k:ℝ)*b))) + +lemma episodeStage_grows_iff {d k : ℕ} (e f : Direction d) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) : + episodeStageGrows e f r fexp g χ b N q ω ↔ + episodeStageLength e f r fexp g χ b N q ω=episodeStageH χ b q.scale ∧ + ¬episodeStageFails e f r fexp g χ b N q ω := by + simp only [episodeStageGrows,episodeStageFails,not_lt,neg_mul] + +lemma episodeStage_not_fail_length {d k : ℕ} (e f : Direction d) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hf : ¬episodeStageFails e f r fexp g χ b N q ω) : + episodeStageLength e f r fexp g χ b N q ω = min (episodeStageH χ b q.scale) (N-q.height) := by + have hu : episodeStageLength e f r fexp g χ b N q ω ≤ min (episodeStageH χ b q.scale) (N-q.height) := + hittingBtwn_le ω + apply le_antisymm hu + by_contra hn + have hl := lt_of_not_ge hn + exact hf (hittingBtwn_mem_set_of_hittingBtwn_lt hl) + +lemma episodeStage_incomplete_terminal {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hq : q.height ≤ N) (hf : ¬episodeStageFails e f r fexp g χ b N q ω) + (hg : ¬episodeStageGrows e f r fexp g χ b N q ω) : + (episodeStageNext e f hef r fexp g χ b N q ω).height=N := by + have hl := episodeStage_not_fail_length e f r fexp g χ b N q ω hf + have hn : episodeStageLength e f r fexp g χ b N q ω ≠ episodeStageH χ b q.scale := by + intro he + exact hg ((episodeStage_grows_iff e f r fexp g χ b N q ω).mpr ⟨he,hf⟩) + rw [episodeStageNext_height] + omega + +noncomputable def episodeCount {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (test : EpisodeState (k:=k) e f r → Environment d → Prop) : ℕ → ℕ + | 0 => 0 + | n+1 => episodeCount e f hef r fexp g χ b sfloor N q ω test n + + if EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ∧ + test (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω then 1 else 0 + +lemma episodeSteps_le_height {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) (n : ℕ) : + q.height+episodeSteps e f hef r fexp g χ b sfloor N q ω n ≤ + (episodeRun e f hef r fexp g χ b sfloor N q ω n).height := by + induction n with + | zero => simp only [episodeRun,episodeSteps,add_zero,le_refl] + | succ n ih => + rw [episodeSteps,episodeRun] + by_cases hp : EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) + · rw [ite_eq_left hp,ite_eq_left hp] + have hh := episodeStageNext_gt e f hef r fexp g χ b sfloor N _ ω hH hp + omega + · simpa only [ite_eq_right hp,add_zero] using ih + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StageExponentialScales.lean b/lean/OAI/Probability/Ballisticity/Estimates/StageExponentialScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc616407265397a2e35e1a8ba1112abe8d598684 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StageExponentialScales.lean @@ -0,0 +1,290 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CellRadiusComparison +import OAI.Probability.Ballisticity.Estimates.StageParameters + +namespace OAI + +section + +open Filter +open scoped Topology +namespace DirectionalTransience + +lemma eventually_stage_scale_ratios (j g D : ℝ) (hj : 0 < j) (hg : 0 < g) (hD : 0 < D) : + ∀ᶠ b : ℝ in atTop, 0 < b ∧ + Real.exp (-(2+Real.log 16*j)*b) ≤ 1/4 ∧ + 16*(16:ℝ)^⌊j*b⌋₊*Real.exp (-(2+Real.log 16*j)*b) ≤ D*Real.exp (-b) ∧ + 16*(16:ℝ)^⌊j*b⌋₊*Real.exp (g*b) ≤ D*Real.exp ((g+1+Real.log 16*j)*b) ∧ + 16*(16:ℝ)^⌊j*b⌋₊*Real.exp (((g+1+Real.log 16*j)+1)*b)+2 ≤ Real.exp (((g+1+Real.log 16*j)+2+Real.log 16*j)*b) := by + let f := 2+Real.log 16*j + let χ := g+1+Real.log 16*j + let E := χ+1+Real.log 16*j + have hf : 0 < f := by dsimp [f]; positivity + have hE : 0 < E+1 := by dsimp [E,χ]; positivity + filter_upwards [eventually_ge_atTop (1:ℝ), eventually_ge_atTop (Real.log 4/f), + eventually_ge_atTop (-Real.log (D/16)), + eventually_exp_affine_le (Real.log 16) (-E) (-(E+1)) (by linarith), + eventually_mul_exp_le 2 0 (-(E+1)) (by linarith)] with b hb hsmall hDsmall hc₁ hc₂ + have hb0 : 0 < b := by linarith + have hp := radix_floor_bound j b (mul_nonneg hj.le hb0.le) + have hDb : 16*Real.exp (-b) ≤ D := by + have hh : Real.exp (-b) ≤ D/16 := by + rw [← Real.exp_log (by positivity : 0 < D/16)] + exact Real.exp_le_exp.mpr (by linarith only [hDsmall]) + linarith only [hh] + refine ⟨hb0,?_,?_,?_,?_⟩ + · have hh := (div_le_iff₀ hf).mp hsmall + have he : Real.exp (-(2+Real.log 16*j)*b) ≤ Real.exp (-Real.log 4) := + Real.exp_le_exp.mpr (by dsimp [f] at hh; nlinarith only [hh]) + simpa only [Real.exp_neg,Real.exp_log (by norm_num : (0:ℝ) < 4),one_div] using he + · calc + _ ≤ 16*Real.exp (Real.log 16*j*b)*Real.exp (-(2+Real.log 16*j)*b) := by gcongr + _ = (16*Real.exp (-b))*Real.exp (-b) := by + simp only [mul_assoc,← Real.exp_add]; congr 2; ring + _ ≤ _ := mul_le_mul_of_nonneg_right hDb (Real.exp_pos _).le + · calc + _ ≤ 16*Real.exp (Real.log 16*j*b)*Real.exp (g*b) := by gcongr + _ = (16*Real.exp (-b))*Real.exp ((g+1+Real.log 16*j)*b) := by + simp only [mul_assoc,← Real.exp_add]; congr 2; ring + _ ≤ _ := mul_le_mul_of_nonneg_right hDb (Real.exp_pos _).le + · have h₁ : 16*(16:ℝ)^⌊j*b⌋₊*Real.exp ((χ+1)*b) ≤ Real.exp ((E+1)*b)/2 := by + calc + _ ≤ 16*Real.exp (Real.log 16*j*b)*Real.exp ((χ+1)*b) := by gcongr + _ = Real.exp (Real.log 16-(-E)*b) := by + rw [show Real.log 16-(-E)*b=Real.log 16+(Real.log 16*j*b+(χ+1)*b) by dsimp [E]; ring, + Real.exp_add,Real.exp_log (by norm_num : (0:ℝ) < 16),Real.exp_add]; ring + _ ≤ _ := by convert hc₁ using 1; congr 2; ring + have h₂ : (2:ℝ) ≤ Real.exp ((E+1)*b)/2 := by simpa using hc₂ + have hh : 16*(16:ℝ)^⌊j*b⌋₊*Real.exp ((χ+1)*b)+2 ≤ Real.exp ((E+1)*b) := by linarith only [h₁,h₂] + convert hh using 1; dsimp [E,χ]; congr 2; ring + +lemma width_target_of_exp_ratio (s D P x y w : ℝ) (hs : 0 ≤ s) (hP : 0 < P) + (hD : 0 ≤ D) (hw : s*y/P ≤ w) (hr : P*x ≤ D*y) : s*x ≤ D*w := by + have hh := mul_le_mul_of_nonneg_left hw hD + have hh' := mul_le_mul_of_nonneg_left hr hs + apply le_trans _ hh + rw [← mul_div_assoc] + apply (le_div_iff₀ hP).mpr + nlinarith only [hh'] + +end DirectionalTransience + +end + +section + +open Filter MeasureTheory +open scoped Topology +namespace DirectionalTransience + +lemma eventually_inverse_stage_tools {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hI : Integrable S μ) (hne : 0 < μ {x | S x ≠ 0}) + (L : ℕ) (hL : 1 ≤ L) (N T ρ σ : ℝ) (hρ : 0 < ρ) (hρquarter : ρ ≤ 1/4) (hσ : 0 < σ) : + ∀ᶠ s : ℝ in atTop, 0 < s ∧ 0 < fluctuationRadius μ S s ∧ N ≤ fluctuationRadius μ S s ∧ + T ≤ s*ρ ∧ T ≤ s*σ ∧ fluctuationRadius μ S (s*ρ) ≤ fluctuationRadius μ S s/2 ∧ + s/(16*(L:ℝ)^2) ≤ fluctuationScale μ S (fluctuationRadius μ S s/(4*L)) := by + obtain ⟨R,hR,hcomp⟩ := fluctuationRadius_scaling_compare μ S hS hI hne + have hLp : (0:ℝ) < L := by exact_mod_cast (by omega : 0 < L) + filter_upwards [eventually_gt_atTop (0:ℝ), + (fluctuationRadius_tendsto μ S hS hI hne).eventually (eventually_ge_atTop N), + eventually_gt_atTop (fluctuationScale μ S R), + eventually_gt_atTop ((max T (fluctuationScale μ S R+1))/ρ), + eventually_ge_atTop (T/σ)] with s hs hN hsR hρT hσT + obtain ⟨hr,heq⟩ := fluctuationRadius_spec μ S hS hI hne hR hsR + have hρB : max T (fluctuationScale μ S R+1) < s*ρ := (div_lt_iff₀ hρ).mp hρT + have ht : fluctuationScale μ S R < s*ρ := by linarith [le_max_right T (fluctuationScale μ S R+1)] + have hrad := hcomp s (s*ρ) (1/2) ht (by nlinarith only [mul_le_mul_of_nonneg_left hρquarter hs.le]) (by norm_num) (by norm_num) + refine ⟨hs,hR.trans hr,hN,(le_max_left _ _).trans hρB.le,(div_le_iff₀ hσ).mp hσT,?_,?_⟩ + · simpa only [div_eq_mul_inv,mul_comm,one_mul] using hrad + · have hc : 0 < (1:ℝ)/(4*L) := by positivity + have hc1 : (1:ℝ)/(4*L) ≤ 1 := by + apply (div_le_iff₀ (by positivity : 0 < (4:ℝ)*L)).mpr + have hh : (1:ℝ) ≤ L := by exact_mod_cast hL + linarith + have hh := fluctuationScale_scaling μ S hS hne (hR.trans hr) hc hc1 + rw [heq] at hh + convert hh using 1 <;> ring_nf + +lemma short_stage_scale_ratio (s b : ℝ) (L H : ℕ) (n : ℝ) + (hs : 0 < s) (hL : 0 < L) (hH : (H:ℝ) ≤ s*Real.exp (-b)) + (hn : s/(16*(L:ℝ)^2) ≤ n) : (H:ℝ)/n ≤ 16*(L:ℝ)^2*Real.exp (-b) := by + have hLp : (0:ℝ) < L := by exact_mod_cast hL + have hn0 : 0 < n := (div_pos hs (by positivity)).trans_le hn + apply (div_le_iff₀ hn0).mpr + have hh := mul_le_mul_of_nonneg_left hn (show 0 ≤ 16*(L:ℝ)^2*Real.exp (-b) by positivity) + have heq : (16*(L:ℝ)^2*Real.exp (-b))*(s/(16*(L:ℝ)^2)) = s*Real.exp (-b) := by field_simp + rw [heq] at hh + exact hH.trans hh + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BigOperators Classical +namespace DirectionalTransience + +theorem separated_stages_with_gap {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (D₀ : ℝ) (hD₀ : 0 ≤ D₀) : + ∃ fexp g χ K : ℝ, 0 < fexp ∧ 0 < g ∧ g < χ ∧ 0 < K ∧ + 1/g < (1/2:ℝ)/64 ∧ (1+fexp/g)*D₀/K < (1/2:ℝ)/64 ∧ + ∃ k : ℕ, 2 ≤ k ∧ ∀ᶠ b : ℝ in atTop, 0 < b ∧ ∃ sfloor : ℝ, 0 < sfloor ∧ + ∀ s : ℝ, sfloor ≤ s → ∀ a : ℝ, + let μ := independentConditionedPairLaw ν (realPosition (step e)) + let S := commonIncrementProcess (realPosition (step e)) f 0 + ∀ π : BudgetProfile (k:=k) e f a (fluctuationRadius μ S s), + environmentLaw ν (stageBadEvent e f ⌊s*Real.exp (χ*b)⌋₊ + (fluctuationRadius μ S (s*Real.exp (-fexp*b))) + (fluctuationRadius μ S (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-(k:ℝ)*b)))) ≤ ENNReal.ofReal (Real.exp (-2*K*b)) := by + obtain ⟨κ,lam,Cr,lamq,Cq,A,hκ,hrows,hlam,hlam1,hCr,hlamq,hlamq1,hCq,hA,hstage⟩ := + actual_finite_stage_estimate ν hue e f hef htrans + let j : ℝ := 1/(8*A) + let fexp := 2+Real.log 16*j + have hA0 : 0 < A := by linarith + have hj : 0 < j := by dsimp [j]; positivity + have hfexp : 0 < fexp := by dsimp [fexp]; positivity + obtain ⟨g,K,hg,hK,hgsmall,hKsmall,k,L,hk,hL,hkr,hkq,hkc,hLk⟩ := + stage_parameter_hierarchy A lam lamq D₀ hA hlam hlamq hD₀ + let χ := g+1+Real.log 16*j + let D := χ+2+Real.log 16*j + have hχ : 0 < χ := by dsimp [χ]; positivity + have hgχ : g < χ := by + dsimp [χ] + have hh : 0 ≤ Real.log 16*j := by positivity + linarith + obtain ⟨C,c,g₀,g₁,hC,hc,hc1,hg₀,hg₁,tseed,htseed,hcb⟩ := hstage k hk + obtain ⟨T,hT,hTbound⟩ := cell_radius_comparison ν hue e f hef htrans C c hC hc hc1 + let μ := independentConditionedPairLaw ν (realPosition (step e)) + let S := commonIncrementProcess (realPosition (step e)) f 0 + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν _ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + have hS : Measurable S := measurable_commonIncrementProcess _ _ _ + have hI : Integrable S μ := independent_commonWordIncrement_integrable ν hue _ + (signed_direction_unit e) htrans (signedHeight e) (signedHeight_projection e) + (signedHeight_step_le e) f + have hne : 0 < μ {x | S x ≠ 0} := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hL0 : 0 < L := by omega + have hk0 : (0:ℝ) < k := by exact_mod_cast (by omega : 0 < k) + have hnumeric := eventually_stage_probability_sum lam lamq Cr Cq j D K k L hk hL0 hCr.le + (by nlinarith only [hkr,mul_pos hlam hk0]) (by linarith only [hLk]) + (by linarith only [hkq]) (by exact lt_trans (by linarith) hkc) + refine ⟨fexp,g,χ,K,hfexp,hg,hgχ,hK,hgsmall,hKsmall,k,hk,?_⟩ + filter_upwards [hnumeric,stage_budget_parameters A g₀ g₁ κ K k L hA hg₀ hg₁ hk, + eventually_stage_scale_ratios j g (c^2/(4*C)) hj hg (by positivity)] with b hnum hbgeom hscales + obtain ⟨hb,hell,hmb,hcoef⟩ := hbgeom + obtain ⟨_,hquarter,hminus,hplus,hcountExp⟩ := hscales + have hBstar : 0 < 2*(k:ℝ)*b := by positivity + obtain ⟨W,N,hW,hbound⟩ := hcb (2*k*b) hBstar + let m := ⌊j*b⌋₊ + have hm : j*b-1 ≤ (m:ℝ) := by have hh := Nat.lt_floor_add_one (j*b); dsimp [m]; linarith only [hh] + have hevent : ∀ᶠ s : ℝ in atTop, 0 < s ∧ ∀ a : ℝ, + ∀ π : BudgetProfile (k:=k) e f a (fluctuationRadius μ S s), + environmentLaw ν (stageBadEvent e f ⌊s*Real.exp (χ*b)⌋₊ + (fluctuationRadius μ S (s*Real.exp (-fexp*b))) + (fluctuationRadius μ S (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-(k:ℝ)*b)))) ≤ ENNReal.ofReal (Real.exp (-2*K*b)) := by + filter_upwards [eventually_finest_width (Real.exp (-b)) (Real.exp_pos _) m W, + eventually_finest_width (Real.exp (χ*b)) (Real.exp_pos _) m W, + eventually_inverse_stage_tools μ S hS hI hne L hL N T + (Real.exp (-fexp*b)) (Real.exp (g*b)) (Real.exp_pos _) hquarter (Real.exp_pos _)] + with s hearly hgrowth hinverse + obtain ⟨hs,hwidth,hlow⟩ := hearly + obtain ⟨_,hwidthp,hlowp⟩ := hgrowth + obtain ⟨_,hrpos,hrN,htminus,htplus,hrhalf,hnscale⟩ := hinverse + refine ⟨hs,fun a π => ?_⟩ + let He := ⌊s*Real.exp (-b)⌋₊ + let H := ⌊s*Real.exp (χ*b)⌋₊ + let w := finestCellWidth He m + let wp := finestCellWidth H m + let n := ((H-He)/w+1)+1 + let v := stageCellStarts He H w + let ws := stageCellWidths He H w wp + let Gminus := fluctuationRadius μ S (s*Real.exp (-fexp*b)) + let Gplus := fluctuationRadius μ S (s*Real.exp (g*b)) + let gs := stageCellGaps He H w Gminus Gplus + obtain ⟨hws,hv,hcover,hgrowth⟩ := stage_cells_geometry He H m W hwidth hwidthp hW Gminus Gplus + have hgm : ∀ i, i < m → Gminus ≤ c*cellRadius ν e f C w m i/2 := by + intro i hi + apply hTbound w m i _ htminus + exact width_target_of_exp_ratio s _ _ _ _ _ hs.le (by positivity) (by positivity) hlow hminus + have hgp : ∀ i, i < m → Gplus ≤ c*cellRadius ν e f C wp m i/2 := by + intro i hi + apply hTbound wp m i _ htplus + exact width_target_of_exp_ratio s _ _ _ _ _ hs.le (by positivity) (by positivity) hlowp hplus + have hgs := stage_cells_gap_bounds ν e f C c Gminus Gplus He H m hgm hgp + have hqe : Real.exp (-(2*(k:ℝ)*b)) ≤ Real.exp (-(k:ℝ)*b/4) := + Real.exp_le_exp.mpr (by nlinarith only [mul_pos hk0 hb]) + have hcoefENN : ENNReal.ofReal (Real.exp (-(k:ℝ)*b)) ≤ + ENNReal.ofReal (Real.exp (-(k:ℝ)*b/4))*(ENNReal.ofReal g₀*ENNReal.ofReal g₁* + ENNReal.ofReal (Real.exp (-A*k*m))) := by + have hh := ENNReal.ofReal_le_ofReal hcoef + rw [ENNReal.ofReal_mul (Real.exp_pos _).le,ENNReal.ofReal_mul (mul_pos hg₀ hg₁).le, + ENNReal.ofReal_mul hg₀.le] at hh + exact hh + have hp := hbound n L He H m a (fluctuationRadius μ S s) (k*b) + (Real.exp (-(k:ℝ)*b/4)) Gminus Gplus v ws gs hL hrpos hrN + (mul_pos hk0 hb) (by nlinarith only [mul_pos hk0 hb]) hell hqe hmb + hws hv hgs hcover hgrowth hrhalf (by simpa only [neg_mul] using hcoefENN) π + change environmentLaw ν (stageBadEvent e f H Gminus Gplus π.val + (ENNReal.ofReal (Real.exp (-(k:ℝ)*b)))) ≤ _ + have hn : (n:ℝ) ≤ Real.exp (D*b) := + (stage_cell_count_bound b χ s m hs hlow).trans hcountExp + have hsum := hnum m hm n (Nat.cast_nonneg _) hn + have hH : (He:ℝ) ≤ s*Real.exp (-b) := Nat.floor_le (by positivity) + have hrat := short_stage_scale_ratio s b L He _ hs hL0 hH hnscale + have hshort : (Real.exp (Cr*k-lam*(k*b/2)/L)+Cr*k*Real.exp ((k*b/2)/L)*He / + fluctuationScale μ S (fluctuationRadius μ S s/(4*L)))^L ≤ + (Real.exp (Cr*k-lam*(k*b/2)/L)+(16*Cr*k*L^2)*Real.exp ((k*b/2)/L-b))^L := by + have hnnonneg := fluctuationScale_nonneg μ S (fluctuationRadius μ S s/(4*L)) + apply pow_le_pow_left₀ (by positivity) _ L + apply add_le_add le_rfl + calc + _ = (Cr*k*Real.exp ((k*b/2)/L))*((He:ℝ)/fluctuationScale μ S (fluctuationRadius μ S s/(4*L))) := by ring + _ ≤ (Cr*k*Real.exp ((k*b/2)/L))*(16*(L:ℝ)^2*Real.exp (-b)) := + mul_le_mul_of_nonneg_left hrat (by positivity) + _ = _ := by rw [Real.exp_sub]; rw [Real.exp_neg]; ring + have hsumENN := ENNReal.ofReal_le_ofReal hsum + rw [ENNReal.ofReal_add (by positivity : 0 ≤ + (Real.exp (Cr*k-lam*(k*b/2)/L)+(16*Cr*k*L^2)*Real.exp ((k*b/2)/L-b))^L + + Real.exp (Cq*k)*(Real.exp (-(k:ℝ)*b/4))^lamq) (by positivity), + ENNReal.ofReal_add (by positivity) (by positivity), + ENNReal.ofReal_mul (by positivity : 0 ≤ (n:ℝ)*2^(m-1)), + ENNReal.ofReal_mul (Nat.cast_nonneg n),ENNReal.ofReal_pow (by norm_num : (0:ℝ) ≤ 2)] at hsumENN + simp only [ENNReal.ofReal_natCast,ENNReal.ofReal_ofNat] at hsumENN + have hp' := hp.trans (add_le_add (add_le_add (ENNReal.ofReal_le_ofReal hshort) le_rfl) le_rfl) + simp only [mul_assoc,neg_mul] at hp' hsumENN ⊢ + exact hp'.trans hsumENN + obtain ⟨s₀,hs₀⟩ := eventually_atTop.mp hevent + refine ⟨hb,max s₀ 1,lt_of_lt_of_le (by norm_num) (le_max_right _ _),fun s hs a => ?_⟩ + exact (hs₀ s ((le_max_left _ _).trans hs)).2 a + +theorem separated_stages {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (D₀ : ℝ) (hD₀ : 0 ≤ D₀) : + ∃ fexp g χ K : ℝ, 0 < fexp ∧ 0 < g ∧ 0 < χ ∧ 0 < K ∧ + 1/g < (1/2:ℝ)/64 ∧ (1+fexp/g)*D₀/K < (1/2:ℝ)/64 ∧ + ∃ k : ℕ, 2 ≤ k ∧ ∀ᶠ b : ℝ in atTop, 0 < b ∧ ∃ sfloor : ℝ, 0 < sfloor ∧ + ∀ s : ℝ, sfloor ≤ s → ∀ a : ℝ, + let μ := independentConditionedPairLaw ν (realPosition (step e)) + let S := commonIncrementProcess (realPosition (step e)) f 0 + ∀ π : BudgetProfile (k:=k) e f a (fluctuationRadius μ S s), + environmentLaw ν (stageBadEvent e f ⌊s*Real.exp (χ*b)⌋₊ + (fluctuationRadius μ S (s*Real.exp (-fexp*b))) + (fluctuationRadius μ S (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-(k:ℝ)*b)))) ≤ ENNReal.ofReal (Real.exp (-2*K*b)) := by + obtain ⟨fexp,g,χ,K,hf,hg,hχ,hK,hgs,hKs,k,hk,hb⟩ := + separated_stages_with_gap ν hue e f hef htrans D₀ hD₀ + exact ⟨fexp,g,χ,K,hf,hg,hg.trans hχ,hK,hgs,hKs,k,hk,hb⟩ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StageInjection.lean b/lean/OAI/Probability/Ballisticity/Estimates/StageInjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a62d6a74add668d03f5cc63959174b9aab84421 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StageInjection.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferRestorationScript +import OAI.Probability.Ballisticity.Coupling.SeedOrder + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +def injectionKey {d k : ℕ} (f : Direction d) (x : Fin k → Lattice d) (j : Fin k) : Lex (ℤ × Fin k) := + toLex (signedHeight f (x j),j) + +lemma injectionKey_injective {d k : ℕ} (f : Direction d) (x : Fin k → Lattice d) : + Function.Injective (injectionKey f x) := by + intro i j h + exact congrArg Prod.snd (toLex.injective h) + +noncomputable def injectionRank {d k : ℕ} (f : Direction d) (x : Fin k → Lattice d) (j : Fin k) : ℕ := + (Finset.univ.filter (fun i => injectionKey f x i < injectionKey f x j)).card + +lemma injectionRank_lt {d k : ℕ} (f : Direction d) (x : Fin k → Lattice d) (j : Fin k) : + injectionRank f x j < k := by + have hs : Finset.univ.filter (fun i => injectionKey f x i < injectionKey f x j) ⊂ Finset.univ := + Finset.filter_ssubset.mpr ⟨j,Finset.mem_univ _,lt_irrefl _⟩ + simpa only [injectionRank,Finset.card_univ,Fintype.card_fin] using Finset.card_lt_card hs + +lemma injectionRank_strict {d k : ℕ} (f : Direction d) (x : Fin k → Lattice d) (i j : Fin k) + (hij : injectionKey f x i < injectionKey f x j) : injectionRank f x i < injectionRank f x j := by + apply Finset.card_lt_card + apply Finset.ssubset_iff_subset_ne.mpr + constructor + · intro l hl + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp hl).2.trans hij⟩ + · intro he + have hi : i∈Finset.univ.filter (fun l => injectionKey f x l < injectionKey f x j) := + Finset.mem_filter.mpr ⟨Finset.mem_univ _,hij⟩ + rw [←he] at hi + exact (lt_irrefl _ (Finset.mem_filter.mp hi).2) + +noncomputable def injectionOffset {d k : ℕ} (f : Direction d) (M : ℕ) + (x : Fin k → Lattice d) (j : Fin k) : ℕ := (injectionRank f x j+1)*M + +noncomputable def injectTuple {d k : ℕ} (e f : Direction d) (M : ℕ) (x : Fin k → Lattice d) : Fin k → Lattice d := + fun j => x j + injectionOffset f M x j • step f + step e + +lemma injectionOffset_le {d k : ℕ} (f : Direction d) (M : ℕ) (x : Fin k → Lattice d) (j : Fin k) : + injectionOffset f M x j ≤ k*M := + Nat.mul_le_mul_right M (injectionRank_lt f x j) + +lemma injectTuple_height {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (M : ℕ) (x : Fin k → Lattice d) (a : ℝ) (hx : x∈TupleAtHeight (realPosition (step e)) a) : + injectTuple e f M x ∈ TupleAtHeight (realPosition (step e)) (a+1) := by + intro j + change dot (realPosition (x j + injectionOffset f M x j • step f + step e)) (realPosition (step e))=a+1 + rw [signedHeight_projection,signedHeight_add_step_self,signedHeight_add_nsmul_other e f hef, + Int.cast_add,Int.cast_one,←signedHeight_projection,hx j] + +lemma injectTuple_separated {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (M : ℕ) (x : Fin k → Lattice d) : TupleSeparated f (M:ℝ) (injectTuple e f M x) := by + have hg {i j : Fin k} (hij : injectionKey f x i < injectionKey f x j) : + (M:ℤ) ≤ signedHeight f (injectTuple e f M x j)-signedHeight f (injectTuple e f M x i) := by + have hc : signedHeight f (x i) ≤ signedHeight f (x j) := by + rcases Prod.Lex.toLex_lt_toLex.mp hij with h|h + · exact h.le + · exact h.1.le + have hr : (injectionRank f x i : ℤ)+1 ≤ injectionRank f x j := by + exact_mod_cast injectionRank_strict f x i j hij + simp only [injectTuple,signedHeight_add_step_other f e hef.symm,signedHeight_add_nsmul_step, + injectionOffset,Nat.cast_mul,Nat.cast_add,Nat.cast_one] + nlinarith [Int.natCast_nonneg M] + intro i j hij + rw [←signedHeight_cast_coordinate,←signedHeight_cast_coordinate,←Int.cast_sub,←Int.cast_abs] + apply Int.cast_le.mpr + rcases lt_or_gt_of_ne ((injectionKey_injective f x).ne hij) with h|h + · exact le_trans (hg h) (by rw [abs_sub_comm]; exact le_abs_self _) + · exact le_trans (hg h) (le_abs_self _) + +lemma injectTuple_atom {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (M : ℕ) (ω : Environment d) (x : Fin k → Lattice d) (κ : ℝ≥0) + (hκ : ∀ y u, κ ≤ (ω y).val u) : + (κ : ℝ≥0∞)^(k*(k*M+1)) ≤ rawTupleEndpointLaw (realPosition (step e)) 1 ω x {injectTuple e f M x} := by + have hk1 : (κ : ℝ≥0∞) ≤ 1 := (ENNReal.coe_le_coe.mpr (hκ 0 e)).trans (by exact_mod_cast row_entry_le_one (ω 0) e) + rw [rawTupleEndpointLaw_singleton,mul_comm k (k*M+1),pow_mul] + calc + ((κ : ℝ≥0∞)^(k*M+1))^k = ∏ _j : Fin k, (κ : ℝ≥0∞)^(k*M+1) := by simp + _ ≤ _ := by + apply Finset.prod_le_prod + intro j _ + have h := elliptic_lateral_script ω e f hef (x j) (injectionOffset f M x j) hκ {injectTuple e f M x j} + have hp : (κ : ℝ≥0∞)^(k*M+1) ≤ (κ : ℝ≥0∞)^(injectionOffset f M x j+1) := + pow_le_pow_right_of_le_one' hk1 (Nat.add_le_add_right (injectionOffset_le f M x j) 1) + apply hp.trans + simpa only [injectTuple,Measure.smul_apply,smul_eq_mul,Measure.dirac_apply_of_mem (Set.mem_singleton _),mul_one, + variableHitKernel,Kernel.coe_mk,Nat.cast_one] using h + +lemma injectTuple_endpoint_le {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (M : ℕ) (ω : Environment d) (x : Fin k → Lattice d) (κ : ℝ≥0) + (hκ : ∀ y u, κ ≤ (ω y).val u) : + (κ : ℝ≥0∞)^(k*(k*M+1)) • Measure.dirac (injectTuple e f M x) ≤ + rawTupleEndpointLaw (realPosition (step e)) 1 ω x := by + have h : (κ : ℝ≥0∞)^(k*(k*M+1)) • Measure.dirac (injectTuple e f M x) ≤ + rawTupleEndpointLaw (realPosition (step e)) 1 ω x {injectTuple e f M x} • + Measure.dirac (injectTuple e f M x) := by + intro U + simp only [Measure.smul_apply,smul_eq_mul] + exact mul_le_mul_left (injectTuple_atom e f hef M ω x κ hκ) _ + rw [←Measure.restrict_singleton] at h + exact h.trans Measure.restrict_le_self + +noncomputable def injectionLaw {d k : ℕ} (e f : Direction d) (M : ℕ) (κ : ℝ≥0) + (π : Measure (Fin k → Lattice d)) : Measure (Fin k → Lattice d) := + (κ : ℝ≥0∞)^(k*(k*M+1)) • π.map (injectTuple e f M) + +lemma injectionLaw_le {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (M : ℕ) (ω : Environment d) (π : Measure (Fin k → Lattice d)) (κ : ℝ≥0) + (hκ : ∀ y u, κ ≤ (ω y).val u) : + injectionLaw e f M κ π ≤ rawTupleMixture (realPosition (step e)) 1 π ω := by + rw [injectionLaw,←Measure.bind_dirac_eq_map π (measurable_of_countable _), + ←Measure.bind_smul _ _ (measurable_of_countable _).aemeasurable] + apply Measure.le_iff.mpr + intro U hU + rw [Measure.bind_apply hU (measurable_of_countable _).aemeasurable,rawTupleMixture_apply, + lintegral_smul_measure,smul_eq_mul] + rw [←lintegral_const_mul _ (measurable_of_countable _)] + apply lintegral_mono + intro x + exact injectTuple_endpoint_le e f hef M ω x κ hκ U + +lemma injectionLaw_mass {d k : ℕ} (e f : Direction d) (M : ℕ) (κ : ℝ≥0) + (π : Measure (Fin k → Lattice d)) [IsProbabilityMeasure π] : + injectionLaw e f M κ π Set.univ = (κ : ℝ≥0∞)^(k*(k*M+1)) := by + simp only [injectionLaw,Measure.smul_apply,smul_eq_mul,Measure.map_apply + (measurable_of_countable _) MeasurableSet.univ,Set.preimage_univ,measure_univ,mul_one] + +lemma injectionProfile_support {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (M : ℕ) (π : Measure (Fin k → Lattice d)) (a : ℝ) + (hπ : ∀ᵐ x ∂π,x∈TupleAtHeight (realPosition (step e)) a) : + ∀ᵐ y ∂π.map (injectTuple e f M), + y∈TupleAtHeight (realPosition (step e)) (a+1) ∧ TupleSeparated f (M:ℝ) y := by + rw [ae_map_iff (measurable_of_countable _).aemeasurable (Set.to_countable _).measurableSet] + filter_upwards [hπ] with x hx + exact ⟨injectTuple_height e f hef M x a hx,injectTuple_separated e f hef M x⟩ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StageParameters.lean b/lean/OAI/Probability/Ballisticity/Estimates/StageParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..0eba521bc4d79ce09b0a85693ad0de55b6a98890 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StageParameters.lean @@ -0,0 +1,170 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.FiniteStage + +namespace OAI + +section + +open Filter +open scoped Topology +namespace DirectionalTransience + +lemma stage_parameter_hierarchy (A lam lamq D₀ : ℝ) (hA : 1 ≤ A) + (hlam : 0 < lam) (hlamq : 0 < lamq) (hD₀ : 0 ≤ D₀) : + let j := 1/(8*A) + let f := 2+Real.log 16*j + ∃ g K : ℝ, 0 < g ∧ 0 < K ∧ 1/g < (1/2:ℝ)/64 ∧ (1+f/g)*D₀/K < (1/2:ℝ)/64 ∧ + ∃ k L : ℕ, 2 ≤ k ∧ 1 ≤ L ∧ + 2*K+4 < lam*k/4 ∧ 2*K+4 < lamq*k/4 ∧ + 2*K+4 < (2*k-Real.log 2)*j-((g+1+Real.log 16*j)+2+Real.log 16*j) ∧ + 2*K+4 < (L:ℝ)-k/2 := by + let j := 1/(8*A) + let f := 2+Real.log 16*j + have hA0 : 0 < A := by linarith + have hj : 0 < j := by dsimp [j]; positivity + have hf : 0 < f := by dsimp [f]; positivity + let g : ℝ := 256 + let K := 256*(1+f/g)*(D₀+1) + have hg : 0 < g := by norm_num [g] + have hK : 0 < K := by dsimp [K]; positivity + refine ⟨g,K,hg,hK,by norm_num [g],?_,?_⟩ + · apply (div_lt_iff₀ hK).mpr + dsimp [K] + have hh : 0 < 1+f/g := by positivity + nlinarith only [mul_pos hh (show 0 < D₀+2 by linarith)] + · let D := (g+1+Real.log 16*j)+2+Real.log 16*j + let lam₀ := min lam lamq + have hlam₀ : 0 < lam₀ := lt_min hlam hlamq + obtain ⟨k,hk⟩ := exists_nat_gt (max 2 (max (4*(2*K+4)/lam₀) + ((D+2*K+4)/j/2+Real.log 2/2))) + have hk2 : (2:ℝ) < k := (le_max_left _ _).trans_lt hk + have hkn : 2 ≤ k := by exact_mod_cast hk2.le + have hkr := (le_max_right _ _).trans_lt hk + have hkLam : 2*K+4 < lam₀*k/4 := by + have hh := (div_lt_iff₀ hlam₀).mp ((le_max_left _ _).trans_lt hkr) + nlinarith only [hh] + have hkcell : 2*K+4 < (2*k-Real.log 2)*j-D := by + have hh := (le_max_right _ _).trans_lt hkr + have hmul := mul_lt_mul_of_pos_right hh hj + have hjn : j ≠ 0 := ne_of_gt hj + field_simp at hmul + nlinarith only [hmul] + obtain ⟨L,hL⟩ := exists_nat_gt (max 1 ((k:ℝ)/2+2*K+4)) + have hL1 : 1 ≤ L := by exact_mod_cast ((le_max_left _ _).trans_lt hL).le + refine ⟨k,L,hkn,hL1,?_,?_,hkcell,?_⟩ + · have hh := mul_le_mul_of_nonneg_right (min_le_left lam lamq) (Nat.cast_nonneg k) + exact hkLam.trans_le (by dsimp [lam₀] at *; linarith) + · have hh := mul_le_mul_of_nonneg_right (min_le_right lam lamq) (Nat.cast_nonneg k) + exact hkLam.trans_le (by dsimp [lam₀] at *; linarith) + · have hh := (le_max_right _ _).trans_lt hL + linarith only [hh] + +lemma stage_budget_parameters (A g₀ g₁ κ _K : ℝ) (k L : ℕ) (hA : 1 ≤ A) + (hg₀ : 0 < g₀) (hg₁ : 0 < g₁) (hk : 2 ≤ k) : + ∀ᶠ b : ℝ in atTop, 0 < b ∧ + (k:ℝ)*L*Real.log (1/κ) ≤ k*b/2 ∧ + (2*A*k)*(⌊(1/(8*A))*b⌋₊:ℝ) ≤ 2*k*b ∧ + Real.exp (-(k:ℝ)*b) ≤ Real.exp (-(k:ℝ)*b/4)* + (g₀*g₁*Real.exp (-A*k*(⌊(1/(8*A))*b⌋₊:ℝ))) := by + have hk0 : (0:ℝ) < k := by exact_mod_cast (by omega : 0 < k) + have hA0 : 0 < A := by linarith + let j := 1/(8*A) + have hj : 0 < j := by dsimp [j]; positivity + filter_upwards [eventually_ge_atTop (1:ℝ), + eventually_ge_atTop (2*L*Real.log (1/κ)), + eventually_ge_atTop (-8*Real.log (g₀*g₁)/(5*k))] with b hb hell hc + have hb0 : 0 < b := by linarith + have hm : (⌊j*b⌋₊:ℝ) ≤ j*b := Nat.floor_le (by positivity) + have hym : A*k*(⌊j*b⌋₊:ℝ) ≤ k*b/8 := by + have hh := mul_le_mul_of_nonneg_left hm (show 0 ≤ A*k by positivity) + have heq : A*k*(j*b) = k*b/8 := by dsimp [j]; field_simp + rwa [heq] at hh + refine ⟨hb0,?_,?_,?_⟩ + · have hh := mul_le_mul_of_nonneg_left hell hk0.le + nlinarith only [hh] + · change 2*A*k*(⌊j*b⌋₊:ℝ) ≤ 2*k*b + nlinarith only [hym,mul_pos hk0 hb0] + · have hh := (div_le_iff₀ (show 0 < 5*(k:ℝ) by positivity)).mp hc + calc + _ ≤ Real.exp (-k*b/4+(Real.log (g₀*g₁)-A*k*(⌊j*b⌋₊:ℝ))) := by + apply Real.exp_le_exp.mpr + nlinarith only [hh,hym] + _ = _ := by rw [Real.exp_add,Real.exp_sub,Real.exp_log (mul_pos hg₀ hg₁)]; + rw [show -A*(k:ℝ)*(⌊j*b⌋₊:ℝ)= -(A*k*(⌊j*b⌋₊:ℝ)) by ring,Real.exp_neg]; ring + +end DirectionalTransience + +end + +section + +open Filter +open scoped Topology +namespace DirectionalTransience + +lemma eventually_finest_width (c : ℝ) (hc : 0 h.1) (fun h => False.elim (not_lt_of_gt hc h.2)) + have hrem := Nat.lt_floor_add_one (s*c) + have hhalf : s*c/2 ≤ (⌊s*c⌋₊:ℝ) := by linarith + have hM : 16*(16:ℝ)^m*(W+1) ≤ s*c := (le_max_right _ _).trans hx + have hpow : 0<(16:ℝ)^m := by positivity + have hH : 8*16^m ≤ ⌊s*c⌋₊ := by + have hW0 : (0:ℝ)≤W := Nat.cast_nonneg W + have hreal : 8*(16:ℝ)^m ≤ (⌊s*c⌋₊:ℝ) := by nlinarith [mul_nonneg hpow.le hW0] + exact_mod_cast hreal + have hlow : (⌊s*c⌋₊:ℝ) ≤ 8*(16:ℝ)^m*(finestCellWidth ⌊s*c⌋₊ m:ℝ) := by + exact_mod_cast finestCellWidth_lower hH + have hw : (W:ℝ) ≤ (finestCellWidth ⌊s*c⌋₊ m:ℝ) := by nlinarith + refine ⟨hs0,by exact_mod_cast hw,?_⟩ + apply (div_le_iff₀ (by positivity : 0<16*(16:ℝ)^m)).mpr + nlinarith only [hhalf,hlow] + +lemma stage_cell_count_bound (b χ s : ℝ) (m : ℕ) (hs : 0 (seedSeparatedProfile e f hef a G + (stageStop e f a Gminus Gplus B π H R ω) (π ω) ω).val) (ite_eq_left h) + · rename_i h + exact congrArg (fun G => (seedSeparatedProfile e f hef a G + (stageStop e f a Gminus Gplus B π H R ω) (π ω) ω).val) (ite_eq_right h) + +lemma stageStop_event {d k : ℕ} (e f : Direction d) (a Gminus Gplus B : ℝ) + (π : Environment d → LayerTupleProfile (k:=k) e a) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) + (H R h : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) (a+h))] + {ω | stageStop e f a Gminus Gplus B π H R ω=h} := by + have ht := (stageStop_stopping e f a Gminus Gplus B π hπ H R).measurableSet_eq_of_countable h + change MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) (a+h))] _ at ht + simpa only [WithTop.coe_inj, Nat.cast_withTop] using ht + +lemma stageOutput_stopped_rows {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (a Gminus Gplus B : ℝ) (π : Environment d → LayerTupleProfile (k:=k) e a) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) + (H R : ℕ) (U : Set (Measure (Fin k → Lattice d))) (hU : MeasurableSet U) : + StoppedRowsEvent (fun h => BelowHeight (realPosition (step e)) (a+h)) + (stageStop e f a Gminus Gplus B π H R) + {ω | (stageOutput e f hef a Gminus Gplus B π H R ω).val ∈ U} := by + intro h + have he : {ω | (stageOutput e f hef a Gminus Gplus B π H R ω).val ∈ U} ∩ + {ω | stageStop e f a Gminus Gplus B π H R ω=h} = + (stageOutputAt e f hef a Gminus Gplus B π H h ⁻¹' U) ∩ + {ω | stageStop e f a Gminus Gplus B π H R ω=h} := by + ext ω + simp only [Set.mem_inter_iff,Set.mem_ofPred_eq,Set.mem_preimage] + constructor <;> rintro ⟨h₁,h₂⟩ <;> refine ⟨?_,h₂⟩ + · rwa [stageOutput_eq_at,h₂] at h₁ + · rwa [stageOutput_eq_at,h₂] + rw [he] + exact ((stageOutputAt_adapted e f hef a Gminus Gplus B π hπ H h) hU).inter + (stageStop_event e f a Gminus Gplus B π hπ H R h) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StageStopping.lean b/lean/OAI/Probability/Ballisticity/Estimates/StageStopping.lean new file mode 100644 index 0000000000000000000000000000000000000000..25834d96d4ab4f33dd3c5acaf179a3b2449c171f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StageStopping.lean @@ -0,0 +1,166 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BudgetMeasurable + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal Classical +namespace DirectionalTransience + +noncomputable def stageEndpointMass {d k : ℕ} (e f : Direction d) (a G : ℝ) + (π : Environment d → LayerTupleProfile (k:=k) e a) (h : ℕ) (ω : Environment d) : ℝ≥0∞ := + rawTupleMixture (realPosition (step e)) h (π ω).val ω {y | TupleSeparated f G y} + +lemma stageEndpointMass_adapted {d k : ℕ} (e f : Direction d) (a G : ℝ) + (π : Environment d → LayerTupleProfile (k:=k) e a) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) : + Adapted (rowHeightFiltration (realPosition (step e)) a) (stageEndpointMass e f a G π) := by + intro h + have hle : rowSigma (BelowHeight (realPosition (step e)) a) ≤ + rowSigma (BelowHeight (realPosition (step e)) (a+h)) := by + apply rowSigma_mono + intro y hy + change dot (realPosition y) (realPosition (step e)) < a+h + change dot (realPosition y) (realPosition (step e)) < a at hy + linarith [Nat.cast_nonneg (α:=ℝ) h] + have hp := ((LayerTupleProfile.measurable_toSupported e a).comp hπ).mono hle le_rfl + have hm := (rawTupleMixture_joint_rows (realPosition (step e)) h + (TupleAtHeight (k:=k) (realPosition (step e)) a) + (BelowHeight (realPosition (step e)) (a+h)) (by + intro x hx j y hy + change dot (realPosition y) (realPosition (step e)) stageTestMass e f a Gminus Gplus π H h ω) + by_cases hh : h=0 + · simp only [stageTestMass,hh]; exact measurable_const + · simp only [stageTestMass,ite_eq_right hh] + by_cases hH : h=H + · simp only [ite_eq_left hH] + exact (stageEndpointMass_adapted e f a Gminus π hπ h).min + (stageEndpointMass_adapted e f a Gplus π hπ h) + · simp only [ite_eq_right hH] + exact stageEndpointMass_adapted e f a Gminus π hπ h + +noncomputable def stageStop {d k : ℕ} (e f : Direction d) (a Gminus Gplus B : ℝ) + (π : Environment d → LayerTupleProfile (k:=k) e a) (H R : ℕ) : Environment d → ℕ := + hittingBtwn (stageTestMass e f a Gminus Gplus π H) + (Set.Iio (ENNReal.ofReal (Real.exp (-B)))) 1 (min H R) + +lemma stageStop_stopping {d k : ℕ} (e f : Direction d) (a Gminus Gplus B : ℝ) + (π : Environment d → LayerTupleProfile (k:=k) e a) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) (H R : ℕ) : + IsStoppingTime (rowHeightFiltration (realPosition (step e)) a) + (fun ω => (stageStop e f a Gminus Gplus B π H R ω : WithTop ℕ)) := + (stageTestMass_adapted e f a Gminus Gplus π hπ H).isStoppingTime_hittingBtwn measurableSet_Iio + +lemma before_stageStop_pass {d k : ℕ} (e f : Direction d) (a Gminus Gplus B : ℝ) + (π : Environment d → LayerTupleProfile (k:=k) e a) (H R : ℕ) (ω : Environment d) + {h : ℕ} (hh : 0 hp.2⟩ + · simp only [ite_eq_right hH] at hp + exact ⟨hp,fun he => (hH he).elim⟩ + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal BigOperators +namespace DirectionalTransience + +lemma adapted_product_moment {Ω : Type*} [m : MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (ℱ : Filtration ℕ m) + (X : ℕ → Ω → ℝ≥0∞) (hX : ∀ n, Measurable[ℱ (n+1)] (X n)) + (c : ℝ≥0∞) + (hstep : ∀ n (w : Ω → ℝ≥0∞), Measurable[ℱ n] w → + (∫⁻ ω, w ω*X n ω ∂μ) ≤ c*(∫⁻ ω, w ω ∂μ)) : + ∀ n, (∫⁻ ω, ∏ i∈Finset.range n, X i ω ∂μ) ≤ c^n := by + have hm (n : ℕ) : Measurable[ℱ n] (fun ω => ∏ i∈Finset.range n, X i ω) := by + apply Finset.measurable_fun_prod + intro i hi + exact (hX i).mono (ℱ.mono (by simpa using hi)) le_rfl + intro n + induction n with + | zero => simp + | succ n ih => + simp_rw [Finset.prod_range_succ] + exact (hstep n _ (hm n)).trans (by simpa [pow_succ,mul_comm] using mul_le_mul_left ih c) + +lemma adapted_exp_sum_tail {Ω : Type*} [m : MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (ℱ : Filtration ℕ m) + (X : ℕ → Ω → ℝ) (hX : ∀ n, Measurable[ℱ (n+1)] (X n)) + (t C : ℝ) (ht : 0 ENNReal.ofReal (Real.exp (t*X i ω)) + have hY (i : ℕ) : Measurable[ℱ (i+1)] (Y i) := ((hX i).const_mul t).exp.ennreal_ofReal + have hprod := adapted_product_moment μ ℱ Y hY (ENNReal.ofReal (Real.exp C)) hstep n + have hsum : Measurable (fun ω => ∑ i∈Finset.range n, X i ω) := + Finset.measurable_fun_sum _ (fun i _ => (hX i).mono (ℱ.le _) le_rfl) + have hid (ω : Ω) : (∏ i∈Finset.range n, Y i ω)= + ENNReal.ofReal (Real.exp (t*∑ i∈Finset.range n, X i ω)) := by + simp only [Y,← ENNReal.ofReal_prod_of_nonneg (fun i _ => (Real.exp_pos (t*X i ω)).le), + ← Real.exp_sum,Finset.mul_sum] + simp_rw [hid] at hprod + have hmeas : Measurable (fun ω => ENNReal.ofReal (Real.exp (t*∑ i∈Finset.range n, X i ω))) := + (hsum.const_mul t).exp.ennreal_ofReal + have he : {ω | v≤∑ i∈Finset.range n, X i ω} = + {ω | ENNReal.ofReal (Real.exp (t*v))≤ENNReal.ofReal (Real.exp (t*∑ i∈Finset.range n, X i ω))} := by + ext ω + simp only [Set.mem_ofPred_eq,ENNReal.ofReal_le_ofReal_iff (Real.exp_pos _).le, + Real.exp_le_exp,mul_le_mul_iff_right₀ ht] + rw [he] + apply (meas_ge_le_lintegral_div hmeas.aemeasurable + (ne_of_gt (ENNReal.ofReal_pos.mpr (Real.exp_pos _))) ENNReal.ofReal_ne_top).trans + calc + _ ≤ ENNReal.ofReal (Real.exp C)^n/ENNReal.ofReal (Real.exp (t*v)) := + ENNReal.div_le_div_right hprod _ + _ = ENNReal.ofReal (Real.exp (C*n-t*v)) := by + rw [← ENNReal.ofReal_pow (Real.exp_pos C).le,← ENNReal.ofReal_div_of_pos (Real.exp_pos _), + ← Real.exp_nat_mul,← Real.exp_sub] + congr 2 + ring + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StayUntil.lean b/lean/OAI/Probability/Ballisticity/Estimates/StayUntil.lean new file mode 100644 index 0000000000000000000000000000000000000000..4dfb14ca1e5f77f3a12da22f3f817cdd67cc6ba5 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StayUntil.lean @@ -0,0 +1,433 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.WordDepartures + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +def StayUntil {d : ℕ} (S : Set (Lattice d)) (n : ℕ) : Set (Path d) := + {X | ∀ i ≤ n, X i ∈ S} + +def Stay {d : ℕ} (S : Set (Lattice d)) : Set (Path d) := + {X | ∀ i, X i ∈ S} + +lemma measurableSet_stayUntil {d : ℕ} (S : Set (Lattice d)) (n : ℕ) : + MeasurableSet (StayUntil S n) := by + simp only [StayUntil, Set.ofPred_forall] + exact MeasurableSet.iInter fun i => MeasurableSet.iInter fun _ => + (measurable_pi_apply i) S.to_countable.measurableSet + +lemma measurableSet_stay {d : ℕ} (S : Set (Lattice d)) : + MeasurableSet (Stay S) := by + simp only [Stay, Set.ofPred_forall] + exact MeasurableSet.iInter fun i => + (measurable_pi_apply i) S.to_countable.measurableSet + +lemma restrict_prefix_fiber {d : ℕ} (n : ℕ) + (f : (i : Finset.Iic n) → Lattice d) : + (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' {f} = + pathCylinder (extendPrefix n f) n := by + ext X + simp only [Set.mem_preimage, Set.mem_singleton_iff, pathCylinder, Set.mem_ofPred_eq] + constructor + · intro hh i hi + simpa [extendPrefix, hi] using congrFun hh ⟨i, Finset.mem_Iic.mpr hi⟩ + · intro hh + funext i + simpa [extendPrefix, Finset.mem_Iic.mp i.2] using hh i (Finset.mem_Iic.mp i.2) + +lemma quenched_stayUntil_congr {d : ℕ} (S : Set (Lattice d)) + (ω η : Environment d) (hωη : Set.EqOn ω η S) (x : Lattice d) (n : ℕ) : + quenchedKernel (ω, x) (StayUntil S n) = quenchedKernel (η, x) (StayUntil S n) := by + let A : Set ((i : Finset.Iic n) → Lattice d) := {f | ∀ i, f i ∈ S} + have hA : (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' A = StayUntil S n := by + ext X + constructor + · intro h i hi + exact h ⟨i, Finset.mem_Iic.mpr hi⟩ + · intro h i + exact h i (Finset.mem_Iic.mp i.2) + have hm (f : (i : Finset.Iic n) → Lattice d) (_ : f ∈ A) : + MeasurableSet ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' {f}) := + (Preorder.measurable_frestrictLe n) (measurableSet_singleton f) + rw [← hA, ← tsum_measure_preimage_singleton A.to_countable hm, + ← tsum_measure_preimage_singleton A.to_countable hm] + apply tsum_congr + intro f + rw [restrict_prefix_fiber] + by_cases hf : extendPrefix n f.val 0 = x + · rw [quenched_pathCylinder _ _ _ hf, quenched_pathCylinder _ _ _ hf] + apply Finset.prod_congr rfl + intro i hi + have hie : i ≤ n := Nat.le_of_lt (Finset.mem_range.mp hi) + have hiS : extendPrefix n f.val i ∈ S := by + rw [extendPrefix_apply _ _ _ hie] + exact f.property _ + simp only [edgeWeight, hωη hiS] + · rw [quenched_pathCylinder_zero _ _ _ hf, quenched_pathCylinder_zero _ _ _ hf] + +lemma quenched_stay_congr {d : ℕ} (S : Set (Lattice d)) + (ω η : Environment d) (hωη : Set.EqOn ω η S) (x : Lattice d) : + quenchedKernel (ω, x) (Stay S) = quenchedKernel (η, x) (Stay S) := by + have hS : Stay S = ⋂ n, StayUntil S n := by + ext X + simp only [Stay, StayUntil, Set.mem_ofPred_eq, Set.mem_iInter] + exact ⟨fun h _ i _ => h i, fun h i => h i i le_rfl⟩ + have hm : Antitone (StayUntil S) := fun m n hmn X hX i hi => hX i (hi.trans hmn) + rw [hS, hm.measure_iInter (fun n => (measurableSet_stayUntil S n).nullMeasurableSet) + ⟨0, measure_ne_top _ _⟩, + hm.measure_iInter (fun n => (measurableSet_stayUntil S n).nullMeasurableSet) + ⟨0, measure_ne_top _ _⟩] + congr 1 + funext n + exact quenched_stayUntil_congr S ω η hωη x n + +lemma measurable_stay_rows {d : ℕ} (S : Set (Lattice d)) (x : Lattice d) (hx : x ∈ S) : + @Measurable _ _ (rowSigma S) _ (fun ω : Environment d => quenchedKernel (ω, x) (Stay S)) := by + classical + let patch : Environment d → Environment d := fun ω y => if y ∈ S then ω y else ω x + have hp : @Measurable _ _ (rowSigma S) _ patch := by + refine @Measurable.of_eval _ _ _ (rowSigma S) _ _ ?_ + intro y + by_cases hy : y ∈ S + · simpa only [patch, ite_eq_left hy] using measurable_row_on hy + · simpa only [patch, ite_eq_right hy] using measurable_row_on hx + have hm : Measurable (fun η : Environment d => quenchedKernel (η, x) (Stay S)) := + (Kernel.measurable_coe _ (measurableSet_stay S)).comp + (measurable_id.prodMk measurable_const) + have he : (fun ω : Environment d => quenchedKernel (ω, x) (Stay S)) = + (fun η : Environment d => quenchedKernel (η, x) (Stay S)) ∘ patch := by + funext ω + exact quenched_stay_congr S ω (patch ω) (fun y hy => by simp [patch, hy]) x + rw [he] + exact hm.comp hp + +lemma measurable_noDropQuenched_rows {d : ℕ} (ℓ : Vector d) (x : Lattice d) : + @Measurable _ _ (rowSigma {y | dot (realPosition x) ℓ ≤ dot (realPosition y) ℓ}) _ + (noDropQuenched ℓ x) := + measurable_stay_rows {y | dot (realPosition x) ℓ ≤ dot (realPosition y) ℓ} x + (show dot (realPosition x) ℓ ≤ dot (realPosition x) ℓ from le_rfl) + +lemma noDropQuenched_lower_step {d : ℕ} (ℓ : Vector d) (ω : Environment d) + (x : Lattice d) (e : Direction d) (he : 0 ≤ dot (realPosition (step e)) ℓ) : + ((ω x).1 e : ℝ≥0∞) * noDropQuenched ℓ (x + step e) ω ≤ noDropQuenched ℓ x ω := by + let f := wordPath x [e] + have hm := quenched_prefix_future ω x f (by simp [f]) 1 + (measurableSet_noDrop ℓ (x + step e)) + have hf1 : f 1 = x + step e := by simp [f, wordPath] + rw [hf1] at hm + have hcy : pathCylinder f 1 = wordCylinder x [e] := rfl + rw [hcy, quenched_wordCylinder] at hm + have hw : ENNReal.ofReal (wordWeight ω x [e]) = ((ω x).1 e : ℝ≥0∞) := by + simp [wordWeight] + rw [hw] at hm + unfold noDropQuenched + rw [← hm] + apply measure_mono + intro X hX n + rcases n with _ | n + · simpa only [show X 0 = x from hX.2 0 (by simp)] using + (le_refl (dot (realPosition x) ℓ)) + · have ht := hX.1 n + change dot (realPosition (x + step e)) ℓ ≤ dot (realPosition (X (1 + n))) ℓ at ht + rw [dot_realPosition_add] at ht + simpa only [Nat.add_comm 1 n] using (le_trans (le_add_of_nonneg_right he) ht) + +lemma dot_realPosition_nsmul {d : ℕ} (n : ℕ) (x : Lattice d) (ℓ : Vector d) : + dot (realPosition (n • x)) ℓ = (n : ℝ) * dot (realPosition x) ℓ := by + induction n with + | zero => simp [dot, realPosition] + | succ n ih => + rw [succ_nsmul, dot_realPosition_add, ih, Nat.cast_add, Nat.cast_one] + ring + +lemma noDrop_positive_limsup {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (e : Direction d) (he : 0 < dot (realPosition (step e)) ℓ) + (hp : 0 < annealedLaw ν (NoDrop ℓ 0)) : + ∀ᵐ ω ∂environmentLaw ν, + ω ∈ limsup (fun n : ℕ => {ω | 0 < noDropQuenched ℓ (n • step e) ω}) atTop := by + let A : ℕ → Set (Environment d) := fun n => {ω | 0 < noDropQuenched ℓ (n • step e) ω} + have hAm (n : ℕ) : MeasurableSet (A n) := + measurableSet_lt measurable_const (measurable_noDropQuenched ℓ _) + have hsame (n : ℕ) : environmentLaw ν (A n) = environmentLaw ν (A 0) := by + have hA : A n = (fun ω : Environment d => fun a => ω (n • step e + a)) ⁻¹' A 0 := by + ext ω + simp only [A, Set.mem_ofPred_eq, Set.mem_preimage, zero_nsmul] + rw [noDropQuenched_translation] + rw [hA, ← Measure.map_apply (by fun_prop) (hAm 0), environment_translation] + have hpos : 0 < environmentLaw ν (A 0) := by + by_contra hn + have hz : environmentLaw ν (A 0) = 0 := le_antisymm (not_lt.mp hn) zero_le + have hq : noDropQuenched ℓ 0 =ᵐ[environmentLaw ν] 0 := by + apply ae_iff.mpr + simpa only [A, zero_nsmul, pos_iff_ne_zero, Pi.zero_apply] using hz + have hi := (lintegral_eq_zero_iff (measurable_noDropQuenched ℓ 0)).mpr hq + rw [annealed_noDrop_translation] at hi + exact (ne_of_gt hp) hi + have htail : ∀ S ∈ (cofinite : Filter (Lattice d)), + MeasurableSet[rowSigma S] (limsup A atTop) := by + intro S hS + have hfin : Sᶜ.Finite := mem_cofinite.mp hS + obtain ⟨B, hB⟩ := (hfin.image (fun y => dot (realPosition y) ℓ)).bddAbove + have ht : Tendsto (fun n : ℕ => dot (realPosition (n • step e)) ℓ) atTop atTop := by + simp_rw [dot_realPosition_nsmul] + exact tendsto_natCast_atTop_atTop.atTop_mul_const he + obtain ⟨k, hk⟩ := eventually_atTop.mp (ht.eventually (eventually_gt_atTop B)) + rw [← limsup_nat_add A k] + apply @MeasurableSet.measurableSet_limsup _ (rowSigma S) + intro n + apply measurableSet_lt measurable_const + apply (measurable_noDropQuenched_rows ℓ ((n + k) • step e)).mono _ le_rfl + apply rowSigma_mono + intro y hy + by_contra hyS + have hBy : dot (realPosition y) ℓ ≤ B := hB ⟨y, hyS, rfl⟩ + exact (not_le_of_gt (hk (n + k) (Nat.le_add_left k n))) (le_trans hy hBy) + have hEpos : 0 < environmentLaw ν (limsup A atTop) := by + apply lt_of_lt_of_le hpos + rw [limsup_eq_iInf_iSup_of_nat] + change environmentLaw ν (A 0) ≤ environmentLaw ν (⋂ n, ⋃ i ≥ n, A i) + have ha : Antitone (fun n => ⋃ i ≥ n, A i) := by + intro n m hnm ω hω + simp only [Set.mem_iUnion] at hω ⊢ + obtain ⟨i, hi, hω⟩ := hω + exact ⟨i, le_trans hnm hi, hω⟩ + rw [ha.measure_iInter (fun n => (MeasurableSet.iUnion fun i => + MeasurableSet.iUnion fun _ => hAm i).nullMeasurableSet) ⟨0, measure_ne_top _ _⟩] + apply le_iInf + intro n + rw [← hsame n] + exact measure_mono (Set.subset_iUnion_of_subset n (Set.subset_iUnion_of_subset le_rfl le_rfl)) + have hEone := (environment_tail_zero_one ν htail).resolve_left (ne_of_gt hEpos) + exact ae_iff.mpr ((prob_compl_eq_zero_iff (MeasurableSet.measurableSet_limsup hAm)).mpr hEone) + +lemma noDropQuenched_positive_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (e : Direction d) + (he : 0 < dot (realPosition (step e)) ℓ) + (hp : 0 < annealedLaw ν (NoDrop ℓ 0)) : + ∀ᵐ ω ∂environmentLaw ν, ∀ x, 0 < noDropQuenched ℓ x ω := by + have h0 : ∀ᵐ ω ∂environmentLaw ν, 0 < noDropQuenched ℓ 0 ω := by + obtain ⟨κ, hκ, hκae⟩ := environment_uniform_elliptic ν hue + filter_upwards [hκae, noDrop_positive_limsup ν ℓ e he hp] with ω hω hE + obtain ⟨n, hn⟩ := (mem_limsup_iff_frequently_mem.mp hE).exists + have htransfer : ∀ n : ℕ, 0 < noDropQuenched ℓ (n • step e) ω → + 0 < noDropQuenched ℓ 0 ω := by + intro n + induction n with + | zero => simp + | succ n ih => + intro hn + apply ih + apply lt_of_lt_of_le _ (noDropQuenched_lower_step ℓ ω (n • step e) e he.le) + apply ENNReal.mul_pos + · apply ne_of_gt + exact_mod_cast (lt_of_lt_of_le hκ (hω (n • step e) e)) + · simpa only [succ_nsmul] using ne_of_gt hn + exact htransfer n hn + apply ae_all_iff.mpr + intro x + have ht : Measurable (fun ω : Environment d => fun a => ω (x + a)) := by fun_prop + have hm := environment_translation ν x + have hmap : ∀ᵐ ω ∂(environmentLaw ν).map (fun η : Environment d => fun a => η (x + a)), + 0 < noDropQuenched ℓ 0 ω := by rwa [hm] + have ha := (ae_map_iff ht.aemeasurable ((measurable_noDropQuenched ℓ 0) measurableSet_Ioi)).mp hmap + filter_upwards [ha] with ω hω + simpa only [noDropQuenched_translation ℓ ω x, Set.mem_Ioi] using hω + +lemma annealed_record_noDrop {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (w : List (Direction d)) + (hrecord : ∀ y ∈ wordDepartures 0 w, + dot (realPosition y) ℓ < dot (realPosition (wordPath 0 w w.length)) ℓ) : + annealedLaw ν ((fun X : Path d => fun i => X (w.length + i)) ⁻¹' + NoDrop ℓ (wordPath 0 w w.length) ∩ wordCylinder 0 w) = + annealedLaw ν (wordCylinder 0 w) * annealedLaw ν (NoDrop ℓ 0) := by + let y := wordPath 0 w w.length + let S : Set (Lattice d) := ↑(wordDepartures 0 w) + let T : Set (Lattice d) := {z | dot (realPosition y) ℓ ≤ dot (realPosition z) ℓ} + have hST : Disjoint S T := by + apply Set.disjoint_left.mpr + intro z hz hz' + exact (not_le_of_gt (hrecord z hz)) hz' + have hw (ω : Environment d) : quenchedKernel (ω, 0) + ((fun X : Path d => fun i => X (w.length + i)) ⁻¹' NoDrop ℓ y ∩ wordCylinder 0 w) = + ENNReal.ofReal (wordWeight ω 0 w) * noDropQuenched ℓ y ω := by + have hh := quenched_prefix_future ω 0 (wordPath 0 w) (by simp) w.length + (measurableSet_noDrop ℓ y) + change quenchedKernel (ω, 0) (_ ∩ wordCylinder 0 w) = + quenchedKernel (ω, 0) (wordCylinder 0 w) * noDropQuenched ℓ y ω at hh + rwa [quenched_wordCylinder] at hh + rw [annealed_apply ν (((by fun_prop : Measurable (fun X : Path d => fun i => X (w.length + i)))) + (measurableSet_noDrop ℓ y) |>.inter (measurableSet_wordCylinder 0 w))] + simp_rw [hw] + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hST) + ((measurable_wordWeight_on 0 w (fun _ hz => hz)).ennreal_ofReal) + (measurable_noDropQuenched_rows ℓ y)] + rw [← annealed_wordCylinder, annealed_noDrop_translation] + +lemma quenched_futureNoDrop_zero {d : ℕ} (ℓ : Vector d) (ω : Environment d) + (x : Lattice d) (hzero : ∀ y, noDropQuenched ℓ y ω = 0) (n : ℕ) : + quenchedKernel (ω, x) (FutureNoDrop ℓ n) = 0 := by + let E := fun f : (i : Finset.Iic n) → Lattice d => + (fun X : Path d => fun j => X (n + j)) ⁻¹' NoDrop ℓ (extendPrefix n f n) ∩ + pathCylinder (extendPrefix n f) n + have hE (f : (i : Finset.Iic n) → Lattice d) : quenchedKernel (ω, x) (E f) = 0 := by + by_cases hf : extendPrefix n f 0 = x + · change quenchedKernel (ω, x) (_ ∩ _) = 0 + rw [quenched_prefix_future ω x _ hf n (measurableSet_noDrop _ _)] + change _ * noDropQuenched ℓ _ ω = 0 + rw [hzero, mul_zero] + · apply measure_mono_null Set.inter_subset_right + exact quenched_pathCylinder_zero ω x _ hf n + apply measure_mono_null (t := ⋃ f, E f) _ (measure_iUnion_null hE) + intro X hX + apply Set.mem_iUnion.mpr + refine ⟨fun i => X i, ?_⟩ + constructor + · change ∀ j, dot (realPosition (extendPrefix n (fun i => X i) n)) ℓ ≤ + dot (realPosition (X (n + j))) ℓ + simpa [extendPrefix, FutureNoDrop] using hX + · intro i hi + simp [extendPrefix, hi] + +lemma noDrop_positive_of_directionallyTransient {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + 0 < annealedLaw ν (NoDrop ℓ 0) := by + by_contra hn + have hzero : annealedLaw ν (NoDrop ℓ 0) = 0 := le_antisymm (le_of_not_gt hn) bot_le + have hq : ∀ᵐ ω ∂environmentLaw ν, ∀ x, noDropQuenched ℓ x ω = 0 := by + apply ae_all_iff.mpr + intro x + apply (lintegral_eq_zero_iff (measurable_noDropQuenched ℓ x)).mp + rw [annealed_noDrop_translation ν ℓ x, hzero] + have hnzero (n : ℕ) : annealedLaw ν (FutureNoDrop ℓ n) = 0 := by + rw [annealed_apply ν (measurableSet_futureNoDrop ℓ n)] + apply lintegral_eq_zero_of_ae_eq_zero + filter_upwards [hq] with ω hω + exact quenched_futureNoDrop_zero ℓ ω 0 hω n + have hnone : ∀ᵐ X ∂annealedLaw ν, ∀ n, X ∉ FutureNoDrop ℓ n := by + apply ae_all_iff.mpr + intro n + apply ae_iff.mpr + simpa only [not_not, Set.ofPred_mem_eq] using hnzero n + have hfalse : ∀ᵐ X ∂annealedLaw ν, False := by + filter_upwards [htrans, hnone] with X ht hh + obtain ⟨n, hn⟩ := tendsto_atTop_has_minimum _ ht + exact hh n (fun i => hn (n + i)) + obtain ⟨X, hX⟩ := hfalse.exists + exact hX + +lemma measure_partition_prefix {d : ℕ} (μ : Measure (Path d)) (A : Set (Path d)) (n : ℕ) : + μ A = ∑' f : (i : Finset.Iic n) → Lattice d, μ (A ∩ pathCylinder (extendPrefix n f) n) := by + have h := tsum_measure_preimage_singleton (μ := μ.restrict A) + (s := Set.univ) (Set.to_countable _) (f := fun X : Path d => Preorder.frestrictLe n X) + (fun f _ => (Preorder.measurable_frestrictLe n) (measurableSet_singleton f)) + simp only [Set.preimage_univ, Measure.restrict_apply + MeasurableSet.univ, Set.univ_inter] at h + rw [tsum_subtype Set.univ (fun f => (μ.restrict A) + ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' {f})), Set.indicator_univ] at h + rw [← h] + apply tsum_congr + intro f + rw [Measure.restrict_apply ((Preorder.measurable_frestrictLe n) (measurableSet_singleton f)), + restrict_prefix_fiber, Set.inter_comm] + +lemma lintegral_partition_prefix {d : ℕ} (μ : Measure (Path d)) (A : Set (Path d)) + (n : ℕ) (g : ((i : Finset.Iic n) → Lattice d) → ℝ≥0∞) : + (∫⁻ X in A, g (Preorder.frestrictLe n X) ∂μ) = + ∑' f : (i : Finset.Iic n) → Lattice d, + g f * μ (A ∩ pathCylinder (extendPrefix n f) n) := by + rw [← lintegral_map (measurable_of_countable g) (Preorder.measurable_frestrictLe n), + lintegral_countable'] + apply tsum_congr + intro f + rw [Measure.map_apply (Preorder.measurable_frestrictLe n) (measurableSet_singleton f), + Measure.restrict_apply ((Preorder.measurable_frestrictLe n) (measurableSet_singleton f)), + restrict_prefix_fiber, Set.inter_comm] + +def FutureEvent {d : ℕ} (B : Lattice d → Set (Path d)) (n : ℕ) : Set (Path d) := + {X | (fun j => X (n + j)) ∈ B (X n)} + +lemma measurableSet_futureEvent {d : ℕ} (B : Lattice d → Set (Path d)) + (hB : ∀ y, MeasurableSet (B y)) (n : ℕ) : MeasurableSet (FutureEvent B n) := by + have he : FutureEvent B n = ⋃ y, {X : Path d | X n = y} ∩ + (fun X : Path d => fun j => X (n + j)) ⁻¹' B y := by + ext X + simp only [FutureEvent, Set.mem_ofPred_eq, Set.mem_iUnion, Set.mem_inter_iff, Set.mem_preimage] + constructor + · intro h + exact ⟨X n, rfl, h⟩ + · rintro ⟨y, rfl, h⟩ + exact h + rw [he] + apply MeasurableSet.iUnion + intro y + exact (measurableSet_eq_fun (measurable_pi_apply n) measurable_const).inter + ((by fun_prop : Measurable (fun X : Path d => fun j => X (n + j))) (hB y)) + +lemma quenched_past_future {d : ℕ} (ω : Environment d) (x : Lattice d) (n : ℕ) + (C : Set ((i : Finset.Iic n) → Lattice d)) (B : Lattice d → Set (Path d)) + (hB : ∀ y, MeasurableSet (B y)) : + quenchedKernel (ω, x) ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' C ∩ FutureEvent B n) = + ∫⁻ X in (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' C, + quenchedKernel (ω, X n) (B (X n)) ∂quenchedKernel (ω, x) := by + classical + let Q := fun X : Path d => Preorder.frestrictLe n X + let g := fun f : (i : Finset.Iic n) → Lattice d => + quenchedKernel (ω, extendPrefix n f n) (B (extendPrefix n f n)) + have hr : (∫⁻ X in Q ⁻¹' C, quenchedKernel (ω, X n) (B (X n)) ∂quenchedKernel (ω, x)) = + ∑' f : (i : Finset.Iic n) → Lattice d, + g f * quenchedKernel (ω, x) (Q ⁻¹' C ∩ pathCylinder (extendPrefix n f) n) := by + convert lintegral_partition_prefix (quenchedKernel (ω, x)) (Q ⁻¹' C) n g using 1 + apply lintegral_congr + intro X + simp [g, extendPrefix] + rw [hr, measure_partition_prefix _ _ n] + apply tsum_congr + intro f + have hcf (X : Path d) (hX : X ∈ pathCylinder (extendPrefix n f) n) : Q X = f := by + rw [← restrict_prefix_fiber] at hX + exact hX + by_cases hC : f ∈ C + · have hpc : Q ⁻¹' C ∩ pathCylinder (extendPrefix n f) n = pathCylinder (extendPrefix n f) n := by + apply Set.inter_eq_right.mpr + intro X hX + change Q X ∈ C + simpa only [hcf X hX] using hC + have hfc : (Q ⁻¹' C ∩ FutureEvent B n) ∩ pathCylinder (extendPrefix n f) n = + (fun X : Path d => fun j => X (n + j)) ⁻¹' B (extendPrefix n f n) ∩ + pathCylinder (extendPrefix n f) n := by + ext X + constructor + · rintro ⟨⟨_, hF⟩, hX⟩ + exact ⟨by simpa only [FutureEvent, Set.mem_ofPred_eq, Set.mem_preimage, ← hX n le_rfl] using hF, hX⟩ + · rintro ⟨hF, hX⟩ + refine ⟨⟨by change Q X ∈ C; simpa only [hcf X hX] using hC, ?_⟩, hX⟩ + change (fun j => X (n + j)) ∈ B (X n) + simpa only [Set.mem_preimage, hX n le_rfl] using hF + change quenchedKernel (ω, x) ((Q ⁻¹' C ∩ FutureEvent B n) ∩ _) = _ + rw [hpc, hfc] + by_cases hf : extendPrefix n f 0 = x + · rw [quenched_prefix_future ω x _ hf n (hB _)] + exact mul_comm _ _ + · rw [quenched_pathCylinder_zero ω x _ hf, mul_zero] + exact measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero ω x _ hf n) + · have hz : Q ⁻¹' C ∩ pathCylinder (extendPrefix n f) n = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro X ⟨hX, hcy⟩ + exact hC (by simpa only [Set.mem_preimage, hcf X hcy] using hX) + change quenchedKernel (ω, x) ((Q ⁻¹' C ∩ FutureEvent B n) ∩ _) = _ + rw [hz, measure_empty, mul_zero] + apply measure_mono_null (t := Q ⁻¹' C ∩ pathCylinder (extendPrefix n f) n) + (by intro X hX; exact ⟨hX.1.1, hX.2⟩) + rw [hz, measure_empty] + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StoppedSplice.lean b/lean/OAI/Probability/Ballisticity/Estimates/StoppedSplice.lean new file mode 100644 index 0000000000000000000000000000000000000000..943c5ee7af69b2923555acf3d285b6b9c0155466 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StoppedSplice.lean @@ -0,0 +1,247 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.IndependentRandomTestBound + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma independent_diagonal_lintegral {Ω A B : Type*} [MeasurableSpace Ω] + [MeasurableSpace A] [MeasurableSpace B] (μ : Measure Ω) [IsProbabilityMeasure μ] + (U : Ω → A) (V : Ω → B) (hU : Measurable U) (hV : Measurable V) + (hind : IndepFun U V μ) (F : A × B → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ ω, F (U ω,V ω) ∂μ) = ∫⁻ η, ∫⁻ ξ, F (U η,V ξ) ∂μ ∂μ := by + rw [←lintegral_map hF (hU.prodMk hV), + hind.map_prod_eq_prod_map_map hU.aemeasurable hV.aemeasurable, + lintegral_prod _ hF.aemeasurable] + have hm : Measurable (fun a => ∫⁻ b, F (a,b) ∂μ.map V) := + Measurable.lintegral_prod_right (f:=fun a b => F (a,b)) hF + rw [lintegral_map hm hU] + apply lintegral_congr + intro η + exact lintegral_map (hF.comp measurable_prodMk_left) hV + +lemma fresh_rows_diagonal_lintegral {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {S T : Set (Lattice d)} (hST : Disjoint S T) + (F : Environment d × Environment d → ℝ≥0∞) + (hF : @Measurable _ _ (MeasurableSpace.prod (rowSigma S) (rowSigma T)) _ F) : + (∫⁻ ω, F (ω,ω) ∂environmentLaw ν)= + ∫⁻ η, ∫⁻ ξ, F (η,ξ) ∂environmentLaw ν ∂environmentLaw ν := by + have hU : @Measurable (Environment d) (Environment d) inferInstance (rowSigma S) id := + measurable_id.mono le_rfl (rowSigma_le S) + have hV : @Measurable (Environment d) (Environment d) inferInstance (rowSigma T) id := + measurable_id.mono le_rfl (rowSigma_le T) + exact @independent_diagonal_lintegral (Environment d) (Environment d) (Environment d) + inferInstance (rowSigma S) (rowSigma T) (environmentLaw ν) inferInstance id id hU hV + (@indepFun_of_disjoint_rows d (Environment d) (Environment d) (rowSigma S) (rowSigma T) + ν _ S T hST id id measurable_id measurable_id) F hF + +noncomputable def rowGraft {d : ℕ} (S : Set (Lattice d)) + (η ξ : Environment d) : Environment d := fun x => if x∈S then η x else ξ x + +lemma rowGraft_diagonal {d : ℕ} (S : Set (Lattice d)) (ω : Environment d) : + rowGraft S ω ω=ω := by ext x; simp [rowGraft] + +lemma rowGraft_measurable_rows {d : ℕ} (S : Set (Lattice d)) : + @Measurable (Environment d×Environment d) (Environment d) + (MeasurableSpace.prod (rowSigma S) (rowSigma Sᶜ)) inferInstance + (fun p => rowGraft S p.1 p.2) := by + apply @Measurable.of_eval (Environment d×Environment d) (Lattice d) (fun _ => Row d) + (MeasurableSpace.prod (rowSigma S) (rowSigma Sᶜ)) (fun _ => inferInstance) + intro x + by_cases hx : x∈S + · simp only [rowGraft,ite_eq_left hx] + exact (measurable_row_on hx).comp measurable_fst + · simp only [rowGraft,ite_eq_right hx] + exact (measurable_row_on hx).comp measurable_snd + +lemma rowGraft_measurable {d : ℕ} (S : Set (Lattice d)) : + Measurable (fun p : Environment d×Environment d => rowGraft S p.1 p.2) := by + apply Measurable.of_eval + intro x + by_cases hx : x∈S + · simp only [rowGraft,ite_eq_left hx] + exact (measurable_pi_apply x).comp measurable_fst + · simp only [rowGraft,ite_eq_right hx] + exact (measurable_pi_apply x).comp measurable_snd + +lemma rowGraft_event_lintegral {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (S : Set (Lattice d)) (A : Set (Environment d)) + (hA : MeasurableSet[rowSigma S] A) + (f : Environment d → ℝ≥0∞) (hf : Measurable f) : + (∫⁻ η, ∫⁻ ξ, A.indicator (fun ω => f (rowGraft S ω ξ)) η + ∂environmentLaw ν ∂environmentLaw ν)= + ∫⁻ ω, A.indicator f ω ∂environmentLaw ν := by + have hF : @Measurable _ _ (MeasurableSpace.prod (rowSigma S) (rowSigma Sᶜ)) _ + (fun p : Environment d×Environment d => A.indicator + (fun ω => f (rowGraft S ω p.2)) p.1) := by + change @Measurable _ _ (MeasurableSpace.prod (rowSigma S) (rowSigma Sᶜ)) _ + ((Prod.fst ⁻¹' A).indicator (fun p => f (rowGraft S p.1 p.2))) + exact (hf.comp (rowGraft_measurable_rows S)).indicator (hA.preimage measurable_fst) + rw [←fresh_rows_diagonal_lintegral ν disjoint_compl_right _ hF] + apply lintegral_congr + intro ω + by_cases hω : ω∈A + · simp [hω,rowGraft_diagonal] + · simp [hω] + +noncomputable def stoppedRowGraft {d : ℕ} (S : ℕ → Set (Lattice d)) + (τ : Environment d → ℕ) (η ξ : Environment d) : Environment d := + rowGraft (S (τ η)) η ξ + +lemma stoppedRowGraft_measurable {d : ℕ} (S : ℕ → Set (Lattice d)) + (τ : Environment d → ℕ) (hτ : Measurable τ) : + Measurable (fun p : Environment d×Environment d => stoppedRowGraft S τ p.1 p.2) := by + have hm : Measurable (fun p : (Environment d×Environment d)×ℕ => + rowGraft (S p.2) p.1.1 p.1.2) := + measurable_from_prod_countable_left (fun n => rowGraft_measurable (S n)) + exact hm.comp (measurable_id.prodMk (hτ.comp measurable_fst)) + +theorem stoppedRowGraft_lintegral {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (f : Environment d → ℝ≥0∞) (hf : Measurable f) : + (∫⁻ η, ∫⁻ ξ, f (stoppedRowGraft S τ η ξ) ∂environmentLaw ν ∂environmentLaw ν)= + ∫⁻ ω, f ω ∂environmentLaw ν := by + let G (n : ℕ) (η ξ : Environment d) := {ω | τ ω=n}.indicator + (fun ω => f (rowGraft (S n) ω ξ)) η + have hG (n : ℕ) : Measurable (Function.uncurry (G n)) := by + change Measurable ((Prod.fst ⁻¹' {ω | τ ω=n}).indicator + (fun p : Environment d×Environment d => f (rowGraft (S n) p.1 p.2))) + exact (hf.comp (rowGraft_measurable (S n))).indicator + (((rowSigma_le _) _ (hτ n)).preimage measurable_fst) + have he (η ξ : Environment d) : f (stoppedRowGraft S τ η ξ)=∑' n, G n η ξ := by + rw [tsum_eq_single (τ η)] + · simp [G,stoppedRowGraft] + · intro n hn + simp [G,Ne.symm hn] + simp_rw [he] + have hin (η : Environment d) : + (∫⁻ ξ, ∑' n, G n η ξ ∂environmentLaw ν)= + ∑' n, ∫⁻ ξ, G n η ξ ∂environmentLaw ν := + lintegral_tsum (fun n => ((hG n).comp (measurable_const.prodMk measurable_id)).aemeasurable) + simp_rw [hin] + rw [lintegral_tsum (fun n => (hG n).lintegral_prod_right.aemeasurable)] + simp_rw [show ∀ n, (∫⁻ η, ∫⁻ ξ, G n η ξ ∂environmentLaw ν ∂environmentLaw ν)= + ∫⁻ ω, {ω | τ ω=n}.indicator f ω ∂environmentLaw ν from + fun n => rowGraft_event_lintegral ν (S n) _ (hτ n) f hf] + rw [←lintegral_tsum (fun n => (hf.indicator ((rowSigma_le _) _ (hτ n))).aemeasurable)] + apply lintegral_congr + intro ω + rw [tsum_eq_single (τ ω)] + · simp + · intro n hn + simp [Ne.symm hn] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma rowSigma_eq_comap {d : ℕ} (S : Set (Lattice d)) : + rowSigma S=MeasurableSpace.comap (fun ω : Environment d => S.domRestrict ω) inferInstance := by + apply le_antisymm + · apply iSup_le + intro x + apply iSup_le + intro hx + have hr : @Measurable (Environment d) (S → Row d) + (MeasurableSpace.comap (fun ω : Environment d => S.domRestrict ω) inferInstance) inferInstance + (fun ω => S.domRestrict ω) := Measurable.of_comap_le le_rfl + exact ((measurable_pi_apply (⟨x,hx⟩ : S)).comp hr).comap_le + · apply Measurable.comap_le + exact @Measurable.of_eval (Environment d) S (fun _ => Row d) (rowSigma S) + (fun _ => inferInstance) (fun ω => S.domRestrict ω) (fun x => measurable_row_on x.property) + +lemma rowSigma_event_congr {d : ℕ} (S : Set (Lattice d)) (A : Set (Environment d)) + (hA : MeasurableSet[rowSigma S] A) {η ξ : Environment d} + (hrows : ∀ x∈S, η x=ξ x) : η∈A ↔ ξ∈A := by + rw [rowSigma_eq_comap] at hA + obtain ⟨B,_,rfl⟩ := MeasurableSpace.measurableSet_comap.mp hA + have he : S.domRestrict η=S.domRestrict ξ := funext fun x => hrows x.val x.property + change S.domRestrict η∈B ↔ S.domRestrict ξ∈B + rw [he] + +lemma rowGraft_rows {d : ℕ} (S : Set (Lattice d)) (η ξ : Environment d) : + ∀ x∈S, rowGraft S η ξ x=η x := by intro x hx; simp [rowGraft,hx] + +lemma stoppedRowGraft_stop {d : ℕ} (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) (η ξ : Environment d) : + τ (stoppedRowGraft S τ η ξ)=τ η := by + exact (rowSigma_event_congr (S (τ η)) _ (hτ (τ η)) + (rowGraft_rows (S (τ η)) η ξ)).mpr rfl + +def StoppedRowsEvent {d : ℕ} (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (A : Set (Environment d)) : Prop := + ∀ n, MeasurableSet[rowSigma (S n)] (A∩{ω | τ ω=n}) + +lemma stoppedRowGraft_event {d : ℕ} (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (A : Set (Environment d)) (hA : StoppedRowsEvent S τ A) (η ξ : Environment d) : + stoppedRowGraft S τ η ξ∈A ↔ η∈A := by + have hh := rowSigma_event_congr (S (τ η)) _ (hA (τ η)) + (rowGraft_rows (S (τ η)) η ξ) + change (stoppedRowGraft S τ η ξ∈A ∧ τ (stoppedRowGraft S τ η ξ)=τ η) ↔ + (η∈A ∧ τ η=τ η) at hh + simpa only [stoppedRowGraft_stop S τ hτ η ξ,and_true] using hh + +lemma stoppedRowGraft_observable {d : ℕ} {D : Type*} [MeasurableSpace D] + [MeasurableSingletonClass D] (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (U : Environment d → D) + (hU : ∀ B, MeasurableSet B → StoppedRowsEvent S τ (U ⁻¹' B)) (η ξ : Environment d) : + U (stoppedRowGraft S τ η ξ)=U η := by + exact (stoppedRowGraft_event S τ hτ _ (hU {U η} (measurableSet_singleton _)) η ξ).mpr rfl + +lemma measurable_of_stop_events {d : ℕ} (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) : Measurable τ := by + apply measurable_to_countable + intro ω + exact (rowSigma_le _) _ (hτ (τ ω)) + +theorem stoppedRowGraft_map {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) : + ((environmentLaw ν).prod (environmentLaw ν)).map + (fun p => stoppedRowGraft S τ p.1 p.2)=environmentLaw ν := by + apply Measure.ext_of_lintegral + intro f hf + rw [lintegral_map hf (stoppedRowGraft_measurable S τ (measurable_of_stop_events S τ hτ))] + have hm : Measurable (fun p : Environment d×Environment d => f (stoppedRowGraft S τ p.1 p.2)) := + hf.comp (stoppedRowGraft_measurable S τ (measurable_of_stop_events S τ hτ)) + exact (lintegral_prod _ hm.aemeasurable).trans (stoppedRowGraft_lintegral ν S τ hτ f hf) + +theorem stoppedRowGraft_joint_map {d : ℕ} {D : Type*} [MeasurableSpace D] + [MeasurableSingletonClass D] (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (U : Environment d → D) (hUm : Measurable U) + (hU : ∀ B, MeasurableSet B → StoppedRowsEvent S τ (U ⁻¹' B)) : + ((environmentLaw ν).prod (environmentLaw ν)).map + (fun p => (U p.1,stoppedRowGraft S τ p.1 p.2))= + (environmentLaw ν).map (fun ω => (U ω,ω)) := by + calc + _ = ((environmentLaw ν).prod (environmentLaw ν)).map + ((fun ω => (U ω,ω)) ∘ fun p => stoppedRowGraft S τ p.1 p.2) := by + congr 1 + funext p + simp only [Function.comp_apply,stoppedRowGraft_observable S τ hτ U hU] + _ = (((environmentLaw ν).prod (environmentLaw ν)).map + (fun p => stoppedRowGraft S τ p.1 p.2)).map (fun ω => (U ω,ω)) := + (Measure.map_map (hUm.prodMk measurable_id) + (stoppedRowGraft_measurable S τ (measurable_of_stop_events S τ hτ))).symm + _ = _ := by rw [stoppedRowGraft_map ν S τ hτ] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/StrictRecord.lean b/lean/OAI/Probability/Ballisticity/Estimates/StrictRecord.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc79799d0cd546ece8334e1840afce9f2f7d092c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/StrictRecord.lean @@ -0,0 +1,432 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightSlab + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +def StrictRecord {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : Prop := + ∀ j < n, dot (realPosition (X j)) ℓ < dot (realPosition (X n)) ℓ + +def TrueRecord {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : Prop := + StrictRecord ℓ X n ∧ X ∈ FutureNoDrop ℓ n + +def FirstTrueRecord {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : Prop := + 0 < n ∧ TrueRecord ℓ X n ∧ ∀ j, 0 < j → j < n → ¬ TrueRecord ℓ X j + +lemma measurableSet_strictRecord {d : ℕ} (ℓ : Vector d) (n : ℕ) : + MeasurableSet {X : Path d | StrictRecord ℓ X n} := by + simp only [StrictRecord, Set.ofPred_forall] + exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + measurableSet_lt + ((measurable_of_countable (f := fun y : Lattice d => dot (realPosition y) ℓ)).comp + (measurable_pi_apply j)) + ((measurable_of_countable (f := fun y : Lattice d => dot (realPosition y) ℓ)).comp + (measurable_pi_apply n)) + +lemma measurableSet_trueRecord {d : ℕ} (ℓ : Vector d) (n : ℕ) : + MeasurableSet {X : Path d | TrueRecord ℓ X n} := + (measurableSet_strictRecord ℓ n).inter (measurableSet_futureNoDrop ℓ n) + +lemma measurableSet_firstTrueRecord {d : ℕ} (ℓ : Vector d) (n : ℕ) : + MeasurableSet {X : Path d | FirstTrueRecord ℓ X n} := by + simp only [FirstTrueRecord, Set.ofPred_and, Set.ofPred_forall] + exact (MeasurableSet.const _).inter ((measurableSet_trueRecord ℓ n).inter + (MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + MeasurableSet.iInter fun _ => (measurableSet_trueRecord ℓ j).compl)) + +lemma wordDepartures_mem_iff {d : ℕ} (x y : Lattice d) (w : List (Direction d)) : + y ∈ wordDepartures x w ↔ ∃ j < w.length, y = wordPath x w j := by + induction w generalizing x with + | nil => simp [wordDepartures] + | cons e w ih => + rw [wordDepartures, Finset.mem_insert, ih] + constructor + · rintro (rfl | ⟨j, hj, rfl⟩) + · exact ⟨0, by simp, by simp⟩ + · exact ⟨j + 1, by simpa using hj, rfl⟩ + · rintro ⟨j, hj, he⟩ + cases j with + | zero => exact Or.inl (by simpa using he) + | succ j => exact Or.inr ⟨j, by simpa using hj, he⟩ + +lemma strictRecord_congr_prefix {d : ℕ} (ℓ : Vector d) {X Y : Path d} {n m : ℕ} + (hn : n ≤ m) (hXY : ∀ j ≤ m, X j = Y j) : + StrictRecord ℓ X n ↔ StrictRecord ℓ Y n := by + simp only [StrictRecord] + constructor <;> intro h j hj + · simpa only [hXY j (hj.le.trans hn), hXY n hn] using h j hj + · simpa only [hXY j (hj.le.trans hn), hXY n hn] using h j hj + +def AdmissibleTrueWord {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) : Prop := + 0 < w.length ∧ + (∀ j < w.length, 0 ≤ dot (realPosition (wordPath 0 w j)) ℓ ∧ + dot (realPosition (wordPath 0 w j)) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ) ∧ + ∀ j, 0 < j → j < w.length → StrictRecord ℓ (wordPath 0 w) j → + ∃ k, j < k ∧ k < w.length ∧ dot (realPosition (wordPath 0 w k)) ℓ < + dot (realPosition (wordPath 0 w j)) ℓ + +lemma admissibleTrueWord_record {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) + (hw : AdmissibleTrueWord ℓ w) : + ∀ y ∈ wordDepartures 0 w, + dot (realPosition y) ℓ < dot (realPosition (wordPath 0 w w.length)) ℓ := by + intro y hy + obtain ⟨j, hj, rfl⟩ := (wordDepartures_mem_iff 0 y w).mp hy + exact (hw.2.1 j hj).2 + +lemma suffix_noDrop_iff {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : + (fun j => X (n + j) - X n) ∈ NoDrop ℓ 0 ↔ X ∈ FutureNoDrop ℓ n := by + change (∀ j, dot (realPosition 0) ℓ ≤ dot (realPosition (X (n + j) - X n)) ℓ) ↔ _ + simp only [dot_realPosition_sub, FutureNoDrop, Set.mem_ofPred_eq] + have hzero : dot (realPosition (0 : Lattice d)) ℓ = 0 := by simp [dot, realPosition] + rw [hzero] + exact forall_congr' fun j => sub_nonneg + +lemma firstTrueWord_characterization {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) + (X : Path d) (hX : X ∈ wordCylinder 0 w) : + (X ∈ NoDrop ℓ 0 ∧ FirstTrueRecord ℓ X w.length) ↔ + AdmissibleTrueWord ℓ w ∧ + (fun j => X (w.length + j) - wordPath 0 w w.length) ∈ NoDrop ℓ 0 := by + have hx0 : X 0 = 0 := by simpa only [wordPath_zero] using hX 0 (Nat.zero_le _) + have hzero : dot (realPosition (0 : Lattice d)) ℓ = 0 := by simp [dot, realPosition] + have hrec (j : ℕ) (hj : j ≤ w.length) : + StrictRecord ℓ X j ↔ StrictRecord ℓ (wordPath 0 w) j := + strictRecord_congr_prefix ℓ hj hX + have hsuf : (fun j => X (w.length + j) - wordPath 0 w w.length) ∈ NoDrop ℓ 0 ↔ + X ∈ FutureNoDrop ℓ w.length := by + rw [← hX w.length le_rfl] + exact suffix_noDrop_iff ℓ X w.length + rw [hsuf] + constructor + · rintro ⟨hD, hn, ⟨hr, hs⟩, hfirst⟩ + refine ⟨⟨hn, ?_, ?_⟩, hs⟩ + · intro j hj + constructor + · simpa only [← hX j hj.le, hzero] using hD j + · simpa only [← hX j hj.le, ← hX w.length le_rfl] using hr j hj + · intro j hj hjn hrj + have hnot := hfirst j hj hjn + have hnotD : X ∉ FutureNoDrop ℓ j := fun h => hnot ⟨(hrec j hjn.le).mpr hrj, h⟩ + change ¬ ∀ k, dot (realPosition (X j)) ℓ ≤ dot (realPosition (X (j + k))) ℓ at hnotD + push Not at hnotD + obtain ⟨k, hk⟩ := hnotD + have hjk : j < j + k := by + by_contra hh + have he : j + k = j := by omega + rw [he] at hk + exact (lt_irrefl _) hk + have hklen : j + k < w.length := by + by_contra hh + have hle : w.length ≤ j + k := by omega + have hs' := hs (j + k - w.length) + change dot (realPosition (X w.length)) ℓ ≤ + dot (realPosition (X (w.length + (j + k - w.length)))) ℓ at hs' + rw [Nat.add_sub_of_le hle] at hs' + exact (not_lt_of_ge ((hr j hjn).le.trans hs')) hk + exact ⟨j + k, hjk, hklen, by + simpa only [← hX (j + k) hklen.le, ← hX j hjn.le] using hk⟩ + · rintro ⟨⟨hn, hpre, hbad⟩, hs⟩ + have hr : StrictRecord ℓ X w.length := (hrec _ le_rfl).mpr fun j hj => (hpre j hj).2 + refine ⟨?_, hn, ⟨hr, hs⟩, ?_⟩ + · intro j + by_cases hj : j < w.length + · simpa only [hX j hj.le, hzero] using (hpre j hj).1 + · have hle : w.length ≤ j := by omega + have ht := hs (j - w.length) + change dot (realPosition (X w.length)) ℓ ≤ + dot (realPosition (X (w.length + (j - w.length)))) ℓ at ht + rw [Nat.add_sub_of_le hle] at ht + exact (le_of_eq (congrArg (fun x : Lattice d => dot (realPosition x) ℓ) hx0.symm)).trans + ((hr 0 hn).le.trans ht) + · intro j hj hjn ⟨hrj, hsj⟩ + obtain ⟨k, hjk, hk, hdrop⟩ := hbad j hj hjn ((hrec j hjn.le).mp hrj) + have ht := hsj (k - j) + change dot (realPosition (X j)) ℓ ≤ dot (realPosition (X (j + (k - j)))) ℓ at ht + rw [Nat.add_sub_of_le hjk.le, hX j hjn.le, hX k hk.le] at ht + exact (not_lt_of_ge ht) hdrop + +lemma firstTrueRecord_unique {d : ℕ} (ℓ : Vector d) (X : Path d) {m n : ℕ} + (hm : FirstTrueRecord ℓ X m) (hn : FirstTrueRecord ℓ X n) : m = n := by + rcases lt_trichotomy m n with h | h | h + · exact False.elim (hn.2.2 m hm.1 h hm.2.1) + · exact h + · exact False.elim (hm.2.2 n hn.1 h hn.2.1) + +noncomputable def conditionedLaw {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) : + Measure (Path d) := + (annealedLaw ν (NoDrop ℓ 0))⁻¹ • (annealedLaw ν).restrict (NoDrop ℓ 0) + +lemma conditionedLaw_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) : + IsProbabilityMeasure (conditionedLaw ν ℓ) := by + constructor + simp only [conditionedLaw, Measure.smul_apply, Measure.restrict_apply MeasurableSet.univ, + Set.univ_inter, smul_eq_mul] + exact ENNReal.inv_mul_cancel hp (measure_ne_top _ _) + +lemma conditionedLaw_apply_of_subset {d : ℕ} (ν : Measure (Row d)) + (ℓ : Vector d) (A : Set (Path d)) (hA : MeasurableSet A) (hAD : A ⊆ NoDrop ℓ 0) : + conditionedLaw ν ℓ A = (annealedLaw ν (NoDrop ℓ 0))⁻¹ * annealedLaw ν A := by + rw [conditionedLaw, Measure.smul_apply, Measure.restrict_apply hA, + Set.inter_eq_left.mpr hAD, smul_eq_mul] + +lemma conditioned_true_word_factor {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (w : List (Direction d)) (hw : AdmissibleTrueWord ℓ w) + (A : Set (Path d)) (hA : MeasurableSet A) (hAD : A ⊆ NoDrop ℓ 0) : + conditionedLaw ν ℓ ((fun X : Path d => fun j => X (w.length + j) - + wordPath 0 w w.length) ⁻¹' A ∩ wordCylinder 0 w) = + annealedLaw ν (wordCylinder 0 w) * conditionedLaw ν ℓ A := by + have hE : MeasurableSet ((fun X : Path d => fun j => X (w.length + j) - + wordPath 0 w w.length) ⁻¹' A ∩ wordCylinder 0 w) := + (hA.preimage (by fun_prop)).inter (measurableSet_wordCylinder _ _) + have hED : ((fun X : Path d => fun j => X (w.length + j) - + wordPath 0 w w.length) ⁻¹' A ∩ wordCylinder 0 w) ⊆ NoDrop ℓ 0 := by + rintro X ⟨hXA, hX⟩ + exact ((firstTrueWord_characterization ℓ w X hX).mpr ⟨hw, hAD hXA⟩).1 + rw [conditionedLaw_apply_of_subset ν ℓ _ hE hED, + annealed_record_suffix ν ℓ w (admissibleTrueWord_record ℓ w hw) A hA hAD, + conditionedLaw_apply_of_subset ν ℓ A hA hAD] + ac_rfl + +lemma piLE_iSup_eq {d : ℕ} : + (⨆ n : ℕ, Filtration.piLE (X := fun _ : ℕ => Lattice d) n) = + (inferInstance : MeasurableSpace (Path d)) := by + apply le_antisymm (iSup_le fun n => Filtration.piLE.le n) + change (⨆ n : ℕ, MeasurableSpace.comap (fun X : Path d => X n) inferInstance) ≤ _ + apply iSup_le + intro n + apply le_trans _ (le_iSup _ n) + rw [Filtration.piLE_eq_comap_frestrictLe] + have hm : @Measurable (Path d) (Lattice d) + (MeasurableSpace.comap (Preorder.frestrictLe n) inferInstance) _ + (fun X => X n) := by + have hc : Measurable (fun f : (i : Finset.Iic n) → Lattice d => + f ⟨n, Finset.mem_Iic.mpr le_rfl⟩) := measurable_pi_apply _ + exact hc.comp (Measurable.of_comap_le le_rfl) + exact hm.comap_le + +lemma prefix_probability_lower {d : ℕ} (μ : Measure (Path d)) + (E : Set (Path d)) (p : ℝ≥0∞) (n : ℕ) + (h : ∀ f : Path d, p * μ (pathCylinder f n) ≤ μ (E ∩ pathCylinder f n)) + (S : Set (Path d)) (hS : MeasurableSet[Filtration.piLE (X := fun _ : ℕ => Lattice d) n] S) : + p * μ S ≤ μ (E ∩ S) := by + classical + rw [Filtration.piLE_eq_comap_frestrictLe] at hS + obtain ⟨B, _, rfl⟩ := MeasurableSpace.measurableSet_comap.mp hS + rw [measure_partition_prefix μ _ n, measure_partition_prefix μ (E ∩ _) n, + ← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro f + have hc : Preorder.frestrictLe n ⁻¹' B ∩ pathCylinder (extendPrefix n f) n = + if f ∈ B then pathCylinder (extendPrefix n f) n else ∅ := by + split_ifs with hf + · apply Set.inter_eq_right.mpr + intro X hX + change Preorder.frestrictLe n X ∈ B + have he : Preorder.frestrictLe n X = f := by + funext j + change X j = f j + simpa only [extendPrefix_apply n f j (Finset.mem_Iic.mp j.2)] + using hX j (Finset.mem_Iic.mp j.2) + rwa [he] + · apply Set.eq_empty_iff_forall_notMem.mpr + rintro X ⟨hB, hX⟩ + have he : Preorder.frestrictLe n X = f := by + funext j + change X j = f j + simpa only [extendPrefix_apply n f j (Finset.mem_Iic.mp j.2)] + using hX j (Finset.mem_Iic.mp j.2) + exact hf (by simpa only [Set.mem_preimage, he] using hB) + rw [Set.inter_assoc, hc] + split_ifs + · exact h _ + · simp + +lemma ae_of_prefix_probability_lower {d : ℕ} (μ : Measure (Path d)) [IsFiniteMeasure μ] + (E : Set (Path d)) (hE : MeasurableSet E) (p : ℝ≥0∞) (hp : 0 < p) (hpt : p ≠ ∞) + (h : ∀ (n : ℕ) (f : Path d), + p * μ (pathCylinder f n) ≤ μ (E ∩ pathCylinder f n)) : ∀ᵐ X ∂μ, X ∈ E := by + let g : Path d → ℝ := E.indicator (fun _ => 1) + have hg : Integrable g μ := (integrable_const (1 : ℝ)).indicator hE + let ℱ : Filtration ℕ (inferInstance : MeasurableSpace (Path d)) := Filtration.piLE + have hlo (n : ℕ) : ∀ᵐ X ∂μ, p.toReal ≤ μ[g | ℱ n] X := by + apply ae_of_ae_trim (ℱ.le n) + apply ae_le_of_forall_setIntegral_le (integrable_const p.toReal) + (integrable_condExp.trim (ℱ.le n) stronglyMeasurable_condExp) + intro S hS _ + rw [← setIntegral_trim (ℱ.le n) stronglyMeasurable_const hS, + ← setIntegral_trim (ℱ.le n) stronglyMeasurable_condExp hS, + setIntegral_condExp (ℱ.le n) hg hS] + have hh := prefix_probability_lower μ E p n (h n) S hS + have hreal := ENNReal.toReal_mono (measure_ne_top μ _) hh + rw [ENNReal.toReal_mul] at hreal + simpa only [g, setIntegral_indicator hE, setIntegral_const, smul_eq_mul, + mul_one, one_mul, Measure.real, Set.inter_comm E S, mul_comm] using hreal + have hgmeas : StronglyMeasurable[⨆ n, ℱ n] g := by + change StronglyMeasurable[⨆ n, Filtration.piLE (X := fun _ : ℕ => Lattice d) n] g + rw [piLE_iSup_eq] + exact stronglyMeasurable_const.indicator hE + have hlim := hg.tendsto_ae_condExp (ℱ := ℱ) hgmeas + filter_upwards [ae_all_iff.mpr hlo, hlim] with X hX hlimX + have hge : p.toReal ≤ g X := ge_of_tendsto hlimX (Eventually.of_forall hX) + by_contra hnot + have hzero : g X = 0 := Set.indicator_of_notMem hnot _ + rw [hzero] at hge + exact (not_le_of_gt (ENNReal.toReal_pos hp.ne' hpt)) hge + +lemma annealed_record_cylinder_noDrop {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Path d) (n : ℕ) (hn : 0 < n) (hr : StrictRecord ℓ f n) : + annealedLaw ν ((fun X : Path d => fun j => X (n + j)) ⁻¹' NoDrop ℓ (f n) ∩ + pathCylinder f n) = + annealedLaw ν (pathCylinder f n) * annealedLaw ν (NoDrop ℓ 0) := by + by_cases hf : f 0 = 0 + · let S : Set (Lattice d) := {y | ∃ j < n, y = f j} + let T : Set (Lattice d) := {y | dot (realPosition (f n)) ℓ ≤ dot (realPosition y) ℓ} + have hST : Disjoint S T := by + apply Set.disjoint_left.mpr + rintro y ⟨j, hj, rfl⟩ hy + exact (not_le_of_gt (hr j hj)) hy + have hS0 : (0 : Lattice d) ∈ S := ⟨0, hn, hf.symm⟩ + have hm : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => quenchedKernel (ω, 0) (pathCylinder f n)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_pathCylinder f n)).comp + (measurable_id.prodMk measurable_const)) S 0 hS0 + intro ω η hωη + exact pathCylinder_weight_locality S ω η hωη 0 f n (fun j hj => ⟨j, hj, rfl⟩) + rw [annealed_apply ν ((measurableSet_noDrop ℓ (f n)).preimage + (by fun_prop) |>.inter (measurableSet_pathCylinder f n))] + simp_rw [quenched_prefix_future _ _ _ hf n (measurableSet_noDrop ℓ (f n))] + change (∫⁻ ω, quenchedKernel (ω, 0) (pathCylinder f n) * noDropQuenched ℓ (f n) ω + ∂environmentLaw ν) = _ + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hST) hm + (measurable_noDropQuenched_rows ℓ (f n)), + annealed_noDrop_translation, ← annealed_apply ν (measurableSet_pathCylinder f n)] + · have hzero : annealedLaw ν (pathCylinder f n) = 0 := by + rw [annealed_apply ν (measurableSet_pathCylinder f n)] + simp_rw [quenched_pathCylinder_zero _ _ _ hf n] + simp + rw [measure_mono_null Set.inter_subset_right hzero, hzero, zero_mul] + +def PrefixDetermined {d : ℕ} (n : ℕ) (A : Set (Path d)) : Prop := + ∀ X Y, (∀ j ≤ n, X j = Y j) → (X ∈ A ↔ Y ∈ A) + +lemma prefixDetermined_mono {d : ℕ} {n m : ℕ} (hm : n ≤ m) + {A : Set (Path d)} (hA : PrefixDetermined n A) : PrefixDetermined m A := + fun X Y hXY => hA X Y (fun j hj => hXY j (hj.trans hm)) + +lemma prefixDetermined_inter {d : ℕ} {n : ℕ} {A B : Set (Path d)} + (hA : PrefixDetermined n A) (hB : PrefixDetermined n B) : PrefixDetermined n (A ∩ B) := + fun X Y hXY => and_congr (hA X Y hXY) (hB X Y hXY) + +lemma prefixDetermined_cylinder {d : ℕ} (f : Path d) (n : ℕ) : + PrefixDetermined n (pathCylinder f n) := by + intro X Y hXY + exact forall_congr' fun j => forall_congr' fun hj => by rw [hXY j hj] + +open scoped Classical in +lemma prefixDetermined_inter_cylinder {d : ℕ} (A : Set (Path d)) (n : ℕ) + (hA : PrefixDetermined n A) (f : Path d) : + A ∩ pathCylinder f n = if f ∈ A then pathCylinder f n else ∅ := by + classical + split_ifs with hf + · exact Set.inter_eq_right.mpr fun X hX => (hA X f hX).mpr hf + · apply Set.eq_empty_iff_forall_notMem.mpr + rintro X ⟨hXA, hX⟩ + exact hf ((hA X f hX).mp hXA) + +lemma annealed_record_event_noDrop {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (n : ℕ) (hn : 0 < n) (A : Set (Path d)) (hA : PrefixDetermined n A) + (hr : ∀ X ∈ A, StrictRecord ℓ X n) : + annealedLaw ν (A ∩ FutureNoDrop ℓ n) = + annealedLaw ν A * annealedLaw ν (NoDrop ℓ 0) := by + classical + rw [measure_partition_prefix (annealedLaw ν) (A ∩ _) n, + measure_partition_prefix (annealedLaw ν) A n, ← ENNReal.tsum_mul_right] + apply tsum_congr + intro f + let g := extendPrefix n f + by_cases hg : g ∈ A + · have he : (A ∩ FutureNoDrop ℓ n) ∩ pathCylinder g n = + (fun X : Path d => fun j => X (n + j)) ⁻¹' NoDrop ℓ (g n) ∩ pathCylinder g n := by + ext X + constructor + · rintro ⟨⟨_, hD⟩, hX⟩ + refine ⟨?_, hX⟩ + change ∀ j, dot (realPosition (g n)) ℓ ≤ dot (realPosition (X (n + j))) ℓ + change ∀ j, dot (realPosition (X n)) ℓ ≤ dot (realPosition (X (n + j))) ℓ at hD + simpa only [← hX n le_rfl] using hD + · rintro ⟨hD, hX⟩ + refine ⟨⟨(hA X g hX).mpr hg, ?_⟩, hX⟩ + change ∀ j, dot (realPosition (X n)) ℓ ≤ dot (realPosition (X (n + j))) ℓ + change ∀ j, dot (realPosition (g n)) ℓ ≤ dot (realPosition (X (n + j))) ℓ at hD + simpa only [hX n le_rfl] using hD + have hAc : A ∩ pathCylinder g n = pathCylinder g n := by + rw [prefixDetermined_inter_cylinder A n hA g, ite_eq_left hg] + rw [he, hAc] + exact annealed_record_cylinder_noDrop ν ℓ g n hn (hr g hg) + · have hzero : A ∩ pathCylinder g n = ∅ := by + rw [prefixDetermined_inter_cylinder A n hA g, ite_eq_right hg] + have he : (A ∩ FutureNoDrop ℓ n) ∩ pathCylinder g n = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro X ⟨⟨hXA, _⟩, hX⟩ + exact (Set.eq_empty_iff_forall_notMem.mp hzero) X ⟨hXA, hX⟩ + rw [he, hzero, measure_empty, zero_mul] + +def NextRecordAfter {d : ℕ} (ℓ : Vector d) (N n : ℕ) : Set (Path d) := + {X | N < n ∧ StrictRecord ℓ X n ∧ ∀ j, N < j → j < n → ¬ StrictRecord ℓ X j} + +lemma nextRecordAfter_prefix {d : ℕ} (ℓ : Vector d) (N n : ℕ) : + PrefixDetermined n (NextRecordAfter ℓ N n) := by + intro X Y hXY + simp only [NextRecordAfter, Set.mem_ofPred_eq] + apply and_congr Iff.rfl + apply and_congr (strictRecord_congr_prefix ℓ le_rfl hXY) + exact forall_congr' fun j => forall_congr' fun _ => forall_congr' fun hj => + not_congr (strictRecord_congr_prefix ℓ hj.le hXY) + +lemma measurableSet_nextRecordAfter {d : ℕ} (ℓ : Vector d) (N n : ℕ) : + MeasurableSet (NextRecordAfter ℓ N n) := by + simp only [NextRecordAfter, Set.ofPred_and, Set.ofPred_forall] + exact (MeasurableSet.const _).inter ((measurableSet_strictRecord ℓ n).inter + (MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + MeasurableSet.iInter fun _ => (measurableSet_strictRecord ℓ j).compl)) + +lemma nextRecordAfter_disjoint {d : ℕ} (ℓ : Vector d) (N : ℕ) : + Pairwise (fun m n => Disjoint (NextRecordAfter ℓ N m) (NextRecordAfter ℓ N n)) := by + intro m n hmn + apply Set.disjoint_left.mpr + intro X hXm hXn + rcases lt_or_gt_of_ne hmn with h | h + · exact hXn.2.2 m hXm.1 h hXm.2.1 + · exact hXm.2.2 n hXn.1 h hXn.2.1 + +lemma exists_strictRecord_gt {d : ℕ} (ℓ : Vector d) (X : Path d) + (ht : Tendsto (fun n => dot (realPosition (X n)) ℓ) atTop atTop) (N : ℕ) : + ∃ n, N < n ∧ StrictRecord ℓ X n := by + classical + let b := ∑ j ∈ Finset.range (N + 1), |dot (realPosition (X j)) ℓ| + have hb (j : ℕ) (hj : j ≤ N) : dot (realPosition (X j)) ℓ ≤ b := by + apply (le_abs_self _).trans + exact Finset.single_le_sum (f := fun j => |dot (realPosition (X j)) ℓ|) + (fun k _ => abs_nonneg _) (Finset.mem_range.mpr (Nat.lt_succ_of_le hj)) + have he : ∃ n, b < dot (realPosition (X n)) ℓ := + Filter.Eventually.exists (show ∀ᶠ n : ℕ in atTop, b < dot (realPosition (X n)) ℓ from + ht (eventually_gt_atTop b)) + refine ⟨Nat.find he, ?_, ?_⟩ + · by_contra hh + exact (not_lt_of_ge (hb (Nat.find he) (by omega))) (Nat.find_spec he) + · intro j hj + exact (le_of_not_gt (Nat.find_min he hj)).trans_lt (Nat.find_spec he) + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulAverage.lean b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6fde2aa78fa3aac868ad24137cc5b9a2fe3b583 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulAverage.lean @@ -0,0 +1,307 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.FiniteConditionalDensityTubeTransfer + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma measurable_crossingQuenched {d : ℕ} (ℓ : Vector d) (x : Lattice d) (H : ℝ) : + Measurable (crossingQuenched ℓ x H) := + (Kernel.measurable_coe quenchedKernel (measurableSet_cross ℓ x H)).comp + (measurable_id.prodMk measurable_const) + +lemma quenched_noDrop_subset_cross_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ ω ∂environmentLaw ν, ∀ x H, + NoDrop ℓ x ≤ᵐ[quenchedKernel (ω,x)] Cross ℓ x H := by + filter_upwards [quenched_directionallyTransient_ae ν ℓ htrans] with ω hω x H + filter_upwards [hω x] with X hX + exact fun hD => noDrop_subset_cross_of_tendsto ℓ x X hX hD H + +noncomputable def successfulAverage {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) (H : ℝ) : + Measure (Path d) := + (weightedAnnealed ν (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹)).restrict (Cross ℓ 0 H) + +lemma successfulAverage_apply {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) (H : ℝ) + (A : Set (Path d)) (hA : MeasurableSet A) : + successfulAverage ν ℓ H A = ∫⁻ ω, (crossingQuenched ℓ 0 H ω)⁻¹ * + quenchedKernel (ω,0) (A ∩ Cross ℓ 0 H) ∂environmentLaw ν := by + rw [successfulAverage,Measure.restrict_apply hA, + weightedAnnealed_apply ν (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) + (show Measurable (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) from (measurable_crossingQuenched ℓ 0 H).inv) _ + (hA.inter (measurableSet_cross ℓ 0 H))] + +lemma successfulAverage_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (H : ℝ) : + IsProbabilityMeasure (successfulAverage ν ℓ H) := by + constructor + rw [successfulAverage_apply ν ℓ H Set.univ MeasurableSet.univ] + have he : (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹ * + quenchedKernel (ω,0) (Set.univ ∩ Cross ℓ 0 H)) =ᵐ[environmentLaw ν] fun _ => 1 := by + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans, + quenched_noDrop_subset_cross_ae ν ℓ htrans] with ω hp hsub + have ha : crossingQuenched ℓ 0 H ω ≠ 0 := ne_of_gt + ((hp 0).trans_le (measure_mono_ae (hsub 0 H))) + simp only [Set.univ_inter] + exact ENNReal.inv_mul_cancel ha (measure_ne_top _ _) + rw [lintegral_congr_ae he] + simp + +lemma raw_crossingDensity_le_successful {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (H : ℝ) : + rawConditionedWeight ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) ≤ successfulAverage ν ℓ H := by + apply Measure.le_iff.mpr + intro A hA + rw [rawConditionedWeight_apply ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) + (show Measurable (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) from (measurable_crossingQuenched ℓ 0 H).inv) A hA, + successfulAverage_apply ν ℓ H A hA] + apply lintegral_mono_ae + filter_upwards [quenched_noDrop_subset_cross_ae ν ℓ htrans] with ω hω + apply mul_le_mul' le_rfl + apply measure_mono_ae + filter_upwards [hω 0 H] with X hX + exact fun h => ⟨h.1,hX h.2⟩ + +lemma raw_crossingDensity_le_conditioned {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (H : ℝ) : + rawConditionedWeight ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) ≤ quenchedConditionedAverage ν ℓ := by + apply Measure.le_iff.mpr + intro A hA + rw [rawConditionedWeight_apply ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) + (show Measurable (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) from (measurable_crossingQuenched ℓ 0 H).inv) A hA, + quenchedConditionedAverage_apply ν ℓ A hA] + apply lintegral_mono_ae + filter_upwards [quenched_noDrop_subset_cross_ae ν ℓ htrans] with ω hω + exact mul_le_mul' (ENNReal.inv_le_inv.mpr (measure_mono_ae (hω 0 H))) le_rfl + +lemma raw_crossingDensity_mass_tendsto {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : + Tendsto (fun H : ℕ => (rawConditionedWeight ν ℓ + (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹)) Set.univ) atTop (𝓝 1) := by + have hdom (H : ℕ) : ∀ᵐ ω ∂environmentLaw ν, + (crossingQuenched ℓ 0 H ω)⁻¹*noDropQuenched ℓ 0 ω ≤ 1 := by + filter_upwards [quenched_noDrop_subset_cross_ae ν ℓ htrans] with ω hω + exact (mul_le_mul' le_rfl (measure_mono_ae (hω 0 H))).trans (ENNReal.inv_mul_le_one _) + have hlim : ∀ᵐ ω ∂environmentLaw ν, Tendsto + (fun H : ℕ => (crossingQuenched ℓ 0 H ω)⁻¹*noDropQuenched ℓ 0 ω) atTop (𝓝 1) := by + filter_upwards [crossingQuenched_tendsto_ae ν ℓ htrans, + quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans] with ω hω hp + have hh := ENNReal.Tendsto.mul_const (tendsto_inv_iff.mpr (hω 0)) + (Or.inr (show noDropQuenched ℓ 0 ω ≠ ∞ from measure_ne_top _ _)) + rwa [ENNReal.inv_mul_cancel (ne_of_gt (hp 0)) (measure_ne_top _ _)] at hh + have hh := tendsto_lintegral_of_dominated_convergence (μ := environmentLaw ν) + (f := fun _ => (1:ℝ≥0∞)) (fun _ => (1:ℝ≥0∞)) + (fun H => (measurable_crossingQuenched ℓ 0 H).inv.mul (measurable_noDropQuenched ℓ 0)) hdom (by simp) hlim + simp only [lintegral_one,measure_univ] at hh + convert hh using 1 + funext H + rw [rawConditionedWeight_apply ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) + (show Measurable (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) from (measurable_crossingQuenched ℓ 0 H).inv) Set.univ MeasurableSet.univ] + simp only [Pi.mul_apply,Pi.inv_apply,Set.univ_inter,noDropQuenched] + +theorem successfulAverage_comparison {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (H : ℝ) + (A : Set (Path d)) (hA : MeasurableSet A) : + (successfulAverage ν ℓ H).real A ≤ (quenchedConditionedAverage ν ℓ).real A+1- + (rawConditionedWeight ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹)).real Set.univ := by + let μ := successfulAverage ν ℓ H + let η := rawConditionedWeight ν ℓ (fun ω => (crossingQuenched ℓ 0 H ω)⁻¹) + let : IsProbabilityMeasure μ := successfulAverage_probability ν hue ℓ hℓ htrans H + let : IsProbabilityMeasure (quenchedConditionedAverage ν ℓ) := + quenchedConditionedAverage_probability ν hue ℓ hℓ htrans + have hη : η ≤ μ := raw_crossingDensity_le_successful ν ℓ htrans H + let : IsFiniteMeasure η := ⟨lt_of_le_of_lt (hη Set.univ) (measure_lt_top _ _)⟩ + have hh := measureReal_le_add_mass_defect μ η hη A hA + have hg : η.real A ≤ (quenchedConditionedAverage ν ℓ).real A := + ENNReal.toReal_mono (measure_ne_top _ _) (raw_crossingDensity_le_conditioned ν ℓ htrans H A) + change μ.real A ≤ (quenchedConditionedAverage ν ℓ).real A+1-η.real Set.univ + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulAverageBind.lean b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulAverageBind.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9c7e5312b2176eefbc8e8b2f0f7c451a8d6efd9 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulAverageBind.lean @@ -0,0 +1,46 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BindIntegral +import OAI.Probability.Ballisticity.Coupling.QuenchedSuccessComparison + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma successfulAverage_eq_bind {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) (H : ℝ) : + successfulAverage ν ℓ H = (environmentLaw ν).bind (successQuenchedKernel ℓ 0 H) := by + apply Measure.ext + intro A hA + rw [successfulAverage_apply ν ℓ H A hA,Measure.bind_apply hA (Kernel.measurable _).aemeasurable] + apply lintegral_congr + intro ω + exact (successQuenchedKernel_apply ℓ 0 H ω A hA).symm + +lemma successfulAverage_integral {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) (H : ℝ) + (F : Path d → ℝ) (hF : Measurable F) (h0 : ∀ X, 0 ≤ F X) + (hi : ∀ ω, Integrable F (successQuenchedKernel ℓ 0 H ω)) : + (∫ X, F X ∂successfulAverage ν ℓ H) = + ∫ ω, ∫ X, F X ∂successQuenchedKernel ℓ 0 H ω ∂environmentLaw ν := by + rw [successfulAverage_eq_bind] + exact integral_bind_nonneg_of_integrable _ _ (Kernel.measurable _) F hF h0 hi + +lemma crossingQuenched_positive_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ ω ∂environmentLaw ν, ∀ x H, crossingQuenched ℓ x H ω ≠ 0 := by + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans, + quenched_noDrop_subset_cross_ae ν ℓ htrans] with ω hp hs x H + exact ne_of_gt ((hp x).trans_le (measure_mono_ae (hs x H))) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulScaledTail.lean b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulScaledTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4d84692130298d754f609830b4edc42ead13f3a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulScaledTail.lean @@ -0,0 +1,168 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CappedMomentTransfer + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma successfulMedian_scaled_tail_comparison {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (H : ℕ → ℕ) (hH : Tendsto H atTop atTop) + (z : ℕ → ℝ) (hz0 : ∀ n, 0 < z n) (hz : Tendsto z atTop atTop) + {u : ℝ} (hu : 0 < u) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + limsup (fun n => (successfulAverage ν ℓ (H n)).real + {X | u < medianDeviation ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) (H n) X / z n}) atTop ≤ + (20/p^2) * limsup (fun n => (independentConditionedPairLaw ν ℓ).real + {P | u/10 < partialSumMax (fun k => commonIncrementProcess ℓ f k P) (H n) / z n}) atTop := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + let b : ℕ → ℝ := fun j => (recordMedian ν ℓ hp f j:ℝ) + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := independentConditionedPairLaw_probability ν ℓ hp + have hp0 : 0 < p := ENNReal.toReal_pos hp (measure_ne_top _ _) + have h1 := successfulAverage_tube_transfer ν hue e f htrans b H hH (fun n => u*z n) (hz.const_mul_atTop hu) + have h2 := limsup_le_mul_of_bounded_nonneg + (fun n => (conditionedLaw ν ℓ).real (MedianTubeFailure ℓ f b (H n) (u*z n/10))) + (fun n => (independentConditionedPairLaw ν ℓ).real {P | u*z n/10 < partialSumMax (fun k => commonIncrementProcess ℓ f k P) (H n)}) + (C := 2/p^2) (B := 1) (by positivity) + (fun _ => measureReal_nonneg) (fun _ => measureReal_nonneg) (fun _ => measureReal_le_one) (by + intro n + rw [← medianDeviation_tail] + exact medianDeviation_conditioned_tail ν e f htrans (H n) (div_pos (mul_pos hu (hz0 n)) (by norm_num))) + have h3 := h1.trans (mul_le_mul_of_nonneg_left h2 (by norm_num : (0:ℝ) ≤ 10)) + have hleft (n) : {X | u < medianDeviation ℓ f b (H n) X / z n} = MedianTubeFailure ℓ f b (H n) (u*z n) := by + rw [← medianDeviation_tail] + ext X + exact (lt_div_iff₀ (hz0 n)) + have hright (n) : {P | u/10 < partialSumMax (fun k => commonIncrementProcess ℓ f k P) (H n) / z n} = + {P | u*z n/10 < partialSumMax (fun k => commonIncrementProcess ℓ f k P) (H n)} := by + ext P + rw [Set.mem_ofPred_eq,Set.mem_ofPred_eq,lt_div_iff₀ (hz0 n),div_mul_eq_mul_div₀] + change limsup (fun n => (successfulAverage ν ℓ (H n)).real {X | u < medianDeviation ℓ f b (H n) X/z n}) atTop ≤ + (20/p^2) * limsup (fun n => (independentConditionedPairLaw ν ℓ).real + {P | u/10 < partialSumMax (fun k => commonIncrementProcess ℓ f k P) (H n) / z n}) atTop + simp only [hleft,hright] + calc + _ ≤ 10 * ((2/p^2) * limsup (fun n => (independentConditionedPairLaw ν ℓ).real + {P | u*z n/10 < partialSumMax (fun k => commonIncrementProcess ℓ f k P) (H n)}) atTop) := h3 + _ = _ := by ring + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +noncomputable def unitCap (x : ℝ) : unitInterval := + ⟨min (max x 0) 1,le_min (le_max_right _ _) zero_le_one,min_le_right _ _⟩ + +lemma continuous_unitCap : Continuous unitCap := by + apply Continuous.subtype_mk + exact (continuous_id.max continuous_const).min continuous_const + +lemma unitCap_tail {u : ℝ} (hu : 0 < u) (hu1 : u < 1) (x : ℝ) : + u < (unitCap x : ℝ) ↔ u < x := by + change u < min (max x 0) 1 ↔ _ + rw [lt_min_iff,lt_max_iff] + simp only [not_lt.mpr hu.le,or_false,hu1,and_true] + +lemma unitCap_coe_of_nonneg {x : ℝ} (hx : 0 ≤ x) : + (unitCap x : ℝ) = min x 1 := by simp [unitCap,max_eq_left hx] + +noncomputable def unitCapLaw {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) (hX : Measurable X) : + ProbabilityMeasure unitInterval := + ⟨μ.map (unitCap ∘ X),⟨by + rw [Measure.map_apply (continuous_unitCap.measurable.comp hX) MeasurableSet.univ, + Set.preimage_univ,measure_univ]⟩⟩ + +lemma unitCapLaw_tail {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) (hX : Measurable X) + {u : ℝ} (hu : 0 < u) (hu1 : u < 1) : + (unitCapLaw μ X hX : Measure unitInterval).real {x | u < (x:ℝ)} = μ.real {x | u < X x} := by + change (μ.map (unitCap ∘ X)).real _ = _ + unfold Measure.real + rw [Measure.map_apply (continuous_unitCap.measurable.comp hX) + (measurableSet_lt measurable_const measurable_subtype_coe)] + have he : (unitCap ∘ X) ⁻¹' {x | u < (x:ℝ)} = {x | u < X x} := by + ext x + exact unitCap_tail hu hu1 (X x) + rw [he] + +lemma unitCapLaw_tail_upper {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) (hX : Measurable X) + {u : ℝ} (hu : 0 < u) : + (unitCapLaw μ X hX : Measure unitInterval).real {x | u < (x:ℝ)} ≤ μ.real {x | u < X x} := by + by_cases hu1 : u < 1 + · exact le_of_eq (unitCapLaw_tail μ X hX hu hu1) + · have hh : {x : unitInterval | u < (x:ℝ)} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro x hx + exact (not_lt.mpr (x.2.2.trans (le_of_not_gt hu1))) hx + simp only [hh,measureReal_empty] + exact measureReal_nonneg + +lemma unitCapLaw_integral_tail_square {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : Ω → ℝ) (hX : Measurable X) + (hX0 : ∀ x, 0 ≤ X x) {A : ℝ} (hA : 0 < A) (hA1 : A < 1) : + (∫ x, unitTailSquare A x ∂(unitCapLaw μ X hX : Measure unitInterval)) = + ∫ x, (if A < X x then (min (X x) 1)^2 else 0) ∂μ := by + rw [show (unitCapLaw μ X hX : Measure unitInterval) = μ.map (unitCap ∘ X) from rfl, + integral_map (continuous_unitCap.measurable.comp hX).aemeasurable + (unitTailSquare_measurable A).aestronglyMeasurable] + congr 1 + funext x + simp only [Function.comp_apply,unitTailSquare] + simp only [unitCap_tail hA hA1] + rw [unitCap_coe_of_nonneg (hX0 x)] + +lemma raw_capped_tail_moment_transfer {Ω Ξ : Type*} [MeasurableSpace Ω] [MeasurableSpace Ξ] + (μ : ℕ → Measure Ω) (ν : ℕ → Measure Ξ) + [∀ n, IsProbabilityMeasure (μ n)] [∀ n, IsProbabilityMeasure (ν n)] + (X : ℕ → Ω → ℝ) (Y : ℕ → Ξ → ℝ) + (hX : ∀ n, Measurable (X n)) (hY : ∀ n, Measurable (Y n)) + (hX0 : ∀ n x, 0 ≤ X n x) (hY0 : ∀ n y, 0 ≤ Y n y) + {C D : ℝ} (hC : 0 ≤ C) (hD : 1 ≤ D) + (ht : ∀ ns : ℕ → ℕ, Tendsto ns atTop atTop → ∀ u > 0, + limsup (fun n => (μ (ns n)).real {x | u < X (ns n) x}) atTop ≤ + C * limsup (fun n => (ν (ns n)).real {y | u/D < Y (ns n) y}) atTop) + {A : ℝ} (hA : 0 < A) (hA1 : A < 1) : + limsup (fun n => ∫ x, (if A < X n x then (min (X n x) 1)^2 else 0) ∂μ n) atTop ≤ + (8*C*D^2) * limsup (fun n => ∫ y, (if A/(4*D) < Y n y then (min (Y n y) 1)^2 else 0) ∂ν n) atTop := by + have hD0 : 0 < D := zero_lt_one.trans_le hD + let μs := fun n => unitCapLaw (μ n) (X n) (hX n) + let νs := fun n => unitCapLaw (ν n) (Y n) (hY n) + have hh := compact_tail_square_moment_transfer μs νs hC hD0 (by + intro ns hns u hu hu1 + have hh := ht ns hns u hu + have hud : u/D < 1 := (div_lt_one hD0).mpr (hu1.trans_le hD) + simpa only [μs,νs,unitCapLaw_tail _ _ _ hu hu1, + unitCapLaw_tail _ _ _ (div_pos hu hD0) hud] using hh) hA hA1.le + have had0 : 0 < A/(4*D) := by positivity + have had1 : A/(4*D) < 1 := (div_lt_one (by positivity)).mpr (by nlinarith) + simpa only [μs,νs,unitCapLaw_integral_tail_square _ _ _ (hX0 _) hA hA1, + unitCapLaw_integral_tail_square _ _ _ (hY0 _) had0 had1] using hh + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulWords.lean b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb4c33cc7b0a4426a09336b88c44058e3686ebcf --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SuccessfulWords.lean @@ -0,0 +1,228 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.TupleEndpoint + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def hitWordEvent {d : ℕ} (x : Lattice d) (S T : Set (Lattice d)) + (E : Set (HitWord x S T)) : Set (Path d) := + ⋃ w : E, wordCylinder x w.val.val + +lemma measurableSet_hitWordEvent {d : ℕ} (x : Lattice d) (S T : Set (Lattice d)) + (E : Set (HitWord x S T)) : MeasurableSet (hitWordEvent x S T E) := by + exact MeasurableSet.iUnion fun w => measurableSet_wordCylinder x w.val.val + +lemma hitWordEvent_mass {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) (E : Set (HitWord x S T)) : + quenchedKernel (ω,x) (hitWordEvent x S T E) = + ∑' w : E, ENNReal.ofReal (wordWeight ω x w.val.val) := by + rw [hitWordEvent,measure_iUnion] + · congr 1; funext w; exact quenched_wordCylinder ω x w.val.val + · intro u v huv + exact hitWord_cylinders_disjoint x S T hST (fun h => huv (Subtype.ext h)) + · exact fun w => measurableSet_wordCylinder x w.val.val + +lemma hitWordEvent_univ_ae {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) : + hitWordEvent x S T Set.univ =ᵐ[quenchedKernel (ω,x)] Hit S T := by + filter_upwards [quenched_initial_ae (ω,x), quenched_nearest_neighbor (ω,x)] with X h0 hnn + apply propext + rw [hitWord_cover x S T X h0 hnn] + simp only [hitWordEvent,Set.mem_iUnion,Subtype.exists,Set.mem_univ,exists_true_left] + +noncomputable def successfulWordLaw {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) : Measure (HitWord x S T) := + Measure.sum (fun w => ENNReal.ofReal (wordWeight ω x w.val) • Measure.dirac w) + +lemma successfulWordLaw_apply {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (E : Set (HitWord x S T)) : + successfulWordLaw ω x S T E = ∑' w : E, ENNReal.ofReal (wordWeight ω x w.val.val) := by + rw [successfulWordLaw,Measure.sum_apply_of_countable] + simp only [Measure.smul_apply,smul_eq_mul,Measure.dirac_apply' _ (Set.to_countable E).measurableSet] + calc + _ = ∑' w, E.indicator (fun w => ENNReal.ofReal (wordWeight ω x w.val)) w := by + congr 1 + funext w + by_cases hw : w ∈ E <;> simp [hw] + _ = _ := (tsum_subtype E (fun w => ENNReal.ofReal (wordWeight ω x w.val))).symm + +lemma successfulWordLaw_event {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) (E : Set (HitWord x S T)) : + successfulWordLaw ω x S T E = quenchedKernel (ω,x) (hitWordEvent x S T E) := by + rw [successfulWordLaw_apply,hitWordEvent_mass ω x S T hST] + +lemma successfulWordLaw_univ {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) : + successfulWordLaw ω x S T Set.univ = quenchedKernel (ω,x) (Hit S T) := by + rw [successfulWordLaw_event ω x S T hST] + exact measure_congr (hitWordEvent_univ_ae ω x S T) + +lemma successfulWordLaw_le_one {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) : + successfulWordLaw ω x S T Set.univ ≤ 1 := by + rw [successfulWordLaw_univ ω x S T hST] + exact prob_le_one + +lemma successfulWordLaw_finite {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) : + IsFiniteMeasure (successfulWordLaw ω x S T) := + ⟨lt_of_le_of_lt (successfulWordLaw_le_one ω x S T hST) ENNReal.one_lt_top⟩ + +lemma successfulWordLaw_endpoint {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) : + (successfulWordLaw ω x S T).map (fun w => wordPath x w.val w.val.length) = + hitKernel S T (ω,x) := by + apply Measure.ext + intro A hA + rw [Measure.map_apply (measurable_of_countable _) hA, + successfulWordLaw_event ω x S T hST,hitKernel_apply_eq_hit hST] + apply measure_congr + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + apply propext + constructor + · intro hx + obtain ⟨w,hw⟩ := Set.mem_iUnion.mp hx + have hp := hitWord_prefix x S T w.val hw + exact Set.mem_iUnion.mpr ⟨w.val.val.length,⟨⟨hp.1,by + rw [hw _ le_rfl] + exact w.property⟩,hp.2⟩⟩ + · intro hx + have hhit : X ∈ Hit S T := by + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hx + exact Set.mem_iUnion.mpr ⟨n,hn.1.1,hn.2⟩ + obtain ⟨w,hw⟩ := (hitWord_cover x S T X h0 hnn).mp hhit + have hp := hitWord_prefix x S T w hw + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hx + have hn' : X ∈ HitAt S T n := ⟨hn.1.1,hn.2⟩ + have he : n = w.val.length := by + by_contra hne + exact Set.disjoint_left.mp (hitAt_pairwise_disjoint hST hne) hn' hp + have hwA : wordPath x w.val w.val.length ∈ A := by + simpa only [he,hw _ le_rfl] using hn.1.2 + exact Set.mem_iUnion.mpr ⟨⟨w,hwA⟩,hw⟩ + +lemma successfulWordLaw_singleton {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (w : HitWord x S T) : + successfulWordLaw ω x S T {w} = ENNReal.ofReal (wordWeight ω x w.val) := by + rw [successfulWordLaw_apply,tsum_subtype {w} (fun v => ENNReal.ofReal (wordWeight ω x v.val))] + simp + +noncomputable def rawWordLaw {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d) : Measure (List (Direction d)) := + (successfulWordLaw ω x (Strip ℓ x H) (Upper ℓ x H)).map Subtype.val + +instance rawWordLaw_finite {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d) : IsFiniteMeasure (rawWordLaw ℓ H ω x) := by + let := successfulWordLaw_finite ω x (Strip ℓ x H) (Upper ℓ x H) (disjoint_strip_upper _ _ _) + exact Measure.isFiniteMeasure_map _ _ + +lemma rawWordLaw_singleton {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d) (w : List (Direction d)) : + rawWordLaw ℓ H ω x {w} = + if wordPath x w ∈ HitAt (Strip ℓ x H) (Upper ℓ x H) w.length + then ENNReal.ofReal (wordWeight ω x w) else 0 := by + rw [rawWordLaw,Measure.map_apply measurable_subtype_coe (measurableSet_singleton _)] + split_ifs with hw + · have he : Subtype.val ⁻¹' {w} = ({⟨w,hw⟩} : Set (HitWord x (Strip ℓ x H) (Upper ℓ x H))) := by + ext v + simp only [Set.mem_preimage,Set.mem_singleton_iff,Subtype.ext_iff] + rw [he,successfulWordLaw_singleton] + · have he : Subtype.val ⁻¹' {w} = (∅ : Set (HitWord x (Strip ℓ x H) (Upper ℓ x H))) := by + ext v + simp only [Set.mem_preimage,Set.mem_singleton_iff,Set.mem_empty_iff_false,iff_false] + intro hv + exact hw (hv ▸ v.property) + rw [he,measure_empty] + +lemma rawWordLaw_univ {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d) : + rawWordLaw ℓ H ω x Set.univ = variableHitKernel ℓ H (ω,x) Set.univ := by + rw [rawWordLaw,Measure.map_apply measurable_subtype_coe MeasurableSet.univ, + Set.preimage_univ,successfulWordLaw_univ ω x _ _ (disjoint_strip_upper _ _ _)] + change _ = hitKernel (Strip ℓ x H) (Upper ℓ x H) (ω,x) Set.univ + rw [hitKernel_apply_eq_hit (disjoint_strip_upper _ _ _),Set.inter_univ] + +lemma rawWordLaw_endpoint {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d) : + (rawWordLaw ℓ H ω x).map (fun w => wordPath x w w.length) = variableHitKernel ℓ H (ω,x) := by + rw [rawWordLaw,Measure.map_map (measurable_of_countable _) measurable_subtype_coe] + exact successfulWordLaw_endpoint ω x _ _ (disjoint_strip_upper _ _ _) + +lemma measurable_rawWordLaw_rows {d : ℕ} (ℓ : Vector d) (H : ℕ) (x : Lattice d) : + @Measurable _ _ (rowSigma (Strip ℓ x H)) _ (rawWordLaw ℓ H · x) := by + let : MeasurableSpace (Environment d) := rowSigma (Strip ℓ x H) + apply TupleKernel.measurable_countable_measure + intro w + simp_rw [rawWordLaw_singleton] + by_cases hw : wordPath x w ∈ HitAt (Strip ℓ x H) (Upper ℓ x H) w.length + · simp only [ite_eq_left hw] + apply Measurable.ennreal_ofReal + exact measurable_wordWeight_on x w fun y hy => by + obtain ⟨n,hn,he⟩ := (wordDepartures_mem_iff x y w).mp hy + rw [he] + exact hw.2 n hn + · simp only [ite_eq_right hw] + exact measurable_const + +lemma measurable_rawWordLaw {d : ℕ} (ℓ : Vector d) (H : ℕ) : + Measurable (fun p : Environment d × Lattice d => rawWordLaw ℓ H p.1 p.2) := by + apply measurable_from_prod_countable_left + intro x + exact (measurable_rawWordLaw_rows ℓ H x).mono (rowSigma_le _) le_rfl + +noncomputable def rawTupleWordLaw {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : Measure (Fin k → List (Direction d)) := + Measure.pi (fun j => rawWordLaw ℓ H ω (x j)) + +instance rawTupleWordLaw_finite {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : IsFiniteMeasure (rawTupleWordLaw ℓ H ω x) := by + unfold rawTupleWordLaw + infer_instance + +lemma rawTupleWordLaw_endpoint {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : + (rawTupleWordLaw ℓ H ω x).map (fun w j => wordPath (x j) (w j) (w j).length) = + rawTupleEndpointLaw ℓ H ω x := by + have he := Measure.pi_map_pi (μ := fun j : Fin k => rawWordLaw ℓ H ω (x j)) + (f := fun j w => wordPath (x j) w w.length) + (fun _ => (measurable_of_countable _).aemeasurable) + rw [rawTupleWordLaw,he] + simp only [rawWordLaw_endpoint,rawTupleEndpointLaw] + +lemma rawTupleWordLaw_singleton {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) (w : Fin k → List (Direction d)) : + rawTupleWordLaw ℓ H ω x {w} = ∏ j, rawWordLaw ℓ H ω (x j) {w j} := by + exact Measure.pi_singleton _ _ + +lemma measurable_rawWordLaw_tuple_component {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (j : Fin k) : + Measurable (fun p : Environment d × (Fin k → Lattice d) => rawWordLaw ℓ H p.1 (p.2 j)) := by + have hg : Measurable (fun p : Environment d × (Fin k → Lattice d) => (p.1,p.2 j)) := + measurable_fst.prodMk ((measurable_pi_apply j).comp measurable_snd) + have hc := (measurable_rawWordLaw ℓ H).comp hg + simpa only [Function.comp_def] using hc + +lemma measurable_rawTupleWordLaw_singleton {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (w : Fin k → List (Direction d)) : + Measurable (fun p : Environment d × (Fin k → Lattice d) => rawTupleWordLaw ℓ H p.1 p.2 {w}) := by + simp only [rawTupleWordLaw_singleton] + apply Finset.measurable_prod + intro j _ + have hc := (Measure.measurable_coe (measurableSet_singleton (w j))).comp + (measurable_rawWordLaw_tuple_component ℓ H j) + simpa only [Function.comp_def] using hc + +lemma measurable_rawTupleWordLaw {d k : ℕ} (ℓ : Vector d) (H : ℕ) : + Measurable (fun p : Environment d × (Fin k → Lattice d) => rawTupleWordLaw ℓ H p.1 p.2) := by + exact TupleKernel.measurable_countable_measure _ (measurable_rawTupleWordLaw_singleton ℓ H) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SurvivalConditional.lean b/lean/OAI/Probability/Ballisticity/Estimates/SurvivalConditional.lean new file mode 100644 index 0000000000000000000000000000000000000000..f43b55ef2f174adf6e4fcf811bbf29a6386063be --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SurvivalConditional.lean @@ -0,0 +1,245 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeGlobalRetention +import OAI.Probability.Ballisticity.Stationary.EpisodeNumber +import OAI.Probability.Ballisticity.Stationary.StationaryWindowEntropy +import OAI.Probability.Ballisticity.Stationary.ArraySurvival + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma conditional_survivalViolation_bound {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (ω : Environment d) (hmono : Monotone (t ω)) + (hpos : ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k ω≠0) + (A : EpisodeAuxiliary e) (i : ℤ) (m n : ℕ) (hn : 0 (localSurvival e ω (t ω i) (t ω (i+m)-t ω i) z).toReal + let μ := globalEpisodeAnchors e t ht ω + have hm : Measurable v := measurable_of_countable _ + have hle (z : HorizontalSpace e) : |v z|≤1 := by + rw [abs_of_nonneg ENNReal.toReal_nonneg] + exact (ENNReal.toReal_mono ENNReal.one_ne_top (localSurvival_le_one _ _ _ _ _)).trans_eq ENNReal.toReal_one + have hi : iIndepFun (fun a (E : EpisodeAnchors e) => v (E (i,a))) μ := by + have h := iIndepFun_infinitePi (P:=fun p : ℤ×ℕ => episodeProfile e t ω p.1) + (X:=fun (_p : ℤ×ℕ) z => v z) (fun _ => hm) + exact h.precomp (fun a b hab => Prod.mk.inj hab |>.2) + have hmean (a : ℕ) : (∫ E, v (E (i,a)) ∂μ) ≤ + (crossingQuenched (realPosition (step e)) 0 (t ω (i+m)) ω / + crossingQuenched (realPosition (step e)) 0 (t ω i) ω).toReal := by + have hmp := measurePreserving_eval_infinitePi (fun p : ℤ×ℕ => episodeProfile e t ω p.1) (i,a) + have he : (∫ E, v (E (i,a)) ∂μ)=∫ z, v z ∂episodeProfile e t ω i := by + rw [←hmp.map_eq,integral_map hmp.measurable.aemeasurable hm.aestronglyMeasurable] + rfl + rw [he] + have hh := localSurvival_mean e ω (t ω i) (t ω (i+m)-t ω i) (hpos _) + have hadd : t ω i+(t ω (i+m)-t ω i)=t ω (i+m) := + Nat.add_sub_of_le (hmono (by omega)) + simpa only [hadd,episodeProfile,v] using hh + have he : {E : EpisodeAnchors e | actualArrayMap e t J ((ω,E),A)∈survivalViolation e i m n ε}= + {E | (crossingQuenched (realPosition (step e)) 0 (t ω (i+m)) ω / + crossingQuenched (realPosition (step e)) 0 (t ω i) ω).toReal+ε < + sampleAverage (fun a E => v (E (i,a))) n E} := by + ext E + exact actual_survivalViolation_iff e t J ((ω,E),A) hmono hpos i m n hn ε hε + rw [he] + exact sampleAverage_upper_tail μ _ (fun a => hm.comp (measurable_pi_apply _)) + (fun a E => hle (E (i,a))) hi n hn _ ε hmean hε + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma arrayContinuation_shift {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayContinuation e Y) : ArrayContinuation e (StationaryCompact.shift Y) := by + intro i m a H z hH + have he : arrayWindowHeight e i m (StationaryCompact.shift Y)=arrayWindowHeight e (i+1) m Y := by + simp only [arrayWindowHeight,StationaryCompact.shift,add_right_comm i _ 1] + rw [he] at hH + have hh := h (i+1) m a H z hH + convert hh using 1 + · rfl + · simp only [arrayDiscountedProfile,arrayWindowCost,arrayProfileMass,StationaryCompact.shift, + add_right_comm i _ 1] + +lemma actualArrayMap_continuation_ae {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hmono : ∀ ω, Monotone (t ω)) (κ : ℝ≥0) (hκ : 0<κ) + (hQ : ∀ᵐ ω ∂Q, ∀ y u, κ ≤ (ω y).1 u) : + ∀ᵐ X ∂episodeInputLaw e ν Q t ht, ArrayContinuation e (actualArrayMap e t J X) := by + have hm : MeasurableSet {ω : Environment d | ∀ y u, κ ≤ (ω y).1 u} := by + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter fun y => MeasurableSet.iInter fun u => + measurableSet_le measurable_const ((measurable_pi_apply u).comp + (measurable_subtype_coe.comp (measurable_pi_apply y))) + have hb := Measure.ae_compProd_of_ae_fst (globalEpisodeAnchors e t ht) hm hQ + have ha := (Measure.quasiMeasurePreserving_fst + (μ:=Q.compProd (globalEpisodeAnchors e t ht)) (ν:=episodeAuxiliaryLaw e ν)).ae hb + filter_upwards [ha] with X hX + apply actual_arrayContinuation e t J X (hmono _) + intro k + exact ne_of_gt ((pos_iff_ne_zero.mpr (pow_ne_zero k (show (κ:ℝ≥0∞)≠0 by exact_mod_cast hκ.ne'))).trans_le + (coordinate_survival_lower e X.1.1 κ (fun y => hX y e) k)) + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} + {e f : Direction d} {D : ℝ} + +lemma paddedTimes_int_mono [IsProbabilityMeasure ν] + (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (ω : Environment d) : Monotone (C.paddedTimes hef N ω) := by + intro i j hij + exact episodeBoundary_mono (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω (Int.toNat_le_toNat hij) + +variable [IsProbabilityMeasure ν] + +lemma bad_limit_continuation (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (Ns : ℕ → ℕ) (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) : + ∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ArrayContinuation e Y := by + apply closed_support_weak_limit _ ρ hlim _ (arrayContinuation_closed e) + intro n + apply actualOccupation_ae_of_ae_invariant e ν _ + (C.paddedTimes hef (Ns n)) (C.paddedStages hef (Ns n)) + (C.paddedTimes_measurable hef (Ns n)) (C.paddedStages_measurable hef (Ns n)) (Ns n) + (C.activeCount hef (Ns n)) (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n)) _ + (arrayContinuation_closed e).measurableSet + · exact actualArrayMap_continuation_ae e ν _ _ _ (C.paddedTimes_measurable hef (Ns n)) + (C.paddedTimes_int_mono hef (Ns n)) C.κ C.hκ0 + ((cond_absolutelyContinuous (μ:=environmentLaw ν) + (s:=badCrossingEvent e (Ns n) (1/2))).ae_le C.rows) + · exact arrayContinuation_shift e + +end OperationalConstants +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma survivalViolation_shift {d : ℕ} (e : Direction d) (i : ℤ) (m n : ℕ) (ε : ℝ) + (Y : ActualEpisodeArray e) : + StationaryCompact.shift Y∈survivalViolation e i m n ε ↔ Y∈survivalViolation e (i+1) m n ε := by + simp only [survivalViolation,Set.mem_ofPred_eq,arrayWindowHeight,arraySurvivalThreshold, + arrayWindowCost,arraySurvivalSum,StationaryCompact.shift,add_right_comm i _ 1] + rfl + +lemma survivalViolation_iterate {d : ℕ} (e : Direction d) (i : ℤ) (m n : ℕ) (ε : ℝ) + (Y : ActualEpisodeArray e) (j : ℕ) : + StationaryCompact.shift^[j] Y∈survivalViolation e i m n ε ↔ Y∈survivalViolation e (i+j) m n ε := by + induction j generalizing i with + | zero => simp + | succ j ih => + rw [Function.iterate_succ_apply',survivalViolation_shift,ih] + rw [show i+1+(j:ℤ)=i+(j+1:ℕ) by omega] + +lemma input_survivalViolation_bound {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) + (hgood : ∀ᵐ ω ∂Q, Monotone (t ω) ∧ ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k ω≠0) + (i : ℤ) (m n : ℕ) (hn : 0 t ω i) : + episodeInputLaw e ν Q t ht Set.univ=Q Set.univ := by + rw [episodeInputLaw,←Set.univ_prod_univ,Measure.prod_prod] + simp only [measure_univ,mul_one,Measure.compProd_apply_univ] + +lemma actualOccupation_survivalViolation_bound {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (hgood : ∀ᵐ ω ∂Q, Monotone (t ω) ∧ ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k ω≠0) + (i : ℤ) (m n : ℕ) (hn : 0 StationaryCompact.shift^[j] (actualArrayMap e t J x)) at hmap + rw [Measure.map_apply hmap hs,Measure.map_apply hmap MeasurableSet.univ,Set.preimage_univ] + have hr := episodeInputLaw_restrict e ν Q t ht {ω | j M X.1.1) x} = _ at hr + rw [hr,input_env_mass] + have he : (fun X : EpisodeInput e => StationaryCompact.shift^[j] (actualArrayMap e t J X)) ⁻¹' s= + {X | actualArrayMap e t J X∈survivalViolation e (i+j) m n ε} := by + ext X + exact survivalViolation_iterate e i m n ε (actualArrayMap e t J X) j + rw [he] + exact input_survivalViolation_bound e ν (Q.restrict {ω | j.1 + have hρ : ρ≠0 := by + intro hz + exact hmass (by rw [hz]; rfl) + change (ρ.normalize : Measure (ActualEpisodeArray e)) s ≤ c + rw [ρ.toMeasure_normalize_eq_of_nonzero hρ,Measure.smul_apply] + rw [ENNReal.smul_def,ENNReal.coe_inv (ρ.mass_nonzero_iff.mpr hρ)] + have he : (ρ.mass : ℝ≥0∞)=(ρ : Measure (ActualEpisodeArray e)) Set.univ := by simp + rw [he,smul_eq_mul] + calc + _ ≤ ((ρ : Measure (ActualEpisodeArray e)) Set.univ)⁻¹ * + (c * (ρ : Measure (ActualEpisodeArray e)) Set.univ) := mul_le_mul + le_rfl hraw (by positivity) (by positivity) + _ = c := by rw [mul_left_comm,ENNReal.inv_mul_cancel hmass (measure_ne_top _ _),mul_one] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SurvivalLimit.lean b/lean/OAI/Probability/Ballisticity/Estimates/SurvivalLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..24fcde033157cc5e57071d58f5092babbdd8c81a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SurvivalLimit.lean @@ -0,0 +1,107 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SurvivalConditional + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma survivalViolation_weak_bound {d : ℕ} (e : Direction d) + (μ : ℕ → ProbabilityMeasure (ActualEpisodeArray e)) (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto μ atTop (𝓝 ρ)) (i : ℤ) (m n : ℕ) (ε : ℝ) (c : ℝ≥0∞) + (hμ : ∀ k, (μ k : Measure (ActualEpisodeArray e)) (survivalViolation e i m n ε)≤c) : + (ρ : Measure (ActualEpisodeArray e)) (survivalViolation e i m n ε)≤c := by + apply (ProbabilityMeasure.le_liminf_measure_open_of_tendsto hlim (survivalViolation_open e i m n ε)).trans + exact (liminf_le_limsup).trans (limsup_le_of_le (by isBoundedDefault) (Eventually.of_forall hμ)) + +noncomputable def arraySurvivalAverage {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) + (Y : ActualEpisodeArray e) : ℝ := (n:ℝ)⁻¹*(arraySurvivalSum e i m H n Y).toReal + +lemma arraySurvivalAverage_nonneg {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) + (Y : ActualEpisodeArray e) : 0≤arraySurvivalAverage e i m H n Y := by + unfold arraySurvivalAverage + positivity + +lemma arraySurvivalAverage_le_of_notMem {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) + (hn : 0 arraySurvivalAverage e i m H (2^r) Y) atTop ≤ + (expNeg (arrayWindowCost e i m Y)).toReal + +lemma arrayAveragedSurvival_of_bounds {d : ℕ} (e : Direction d) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hb : ∀ (i : ℤ) (m n : ℕ), 0 ((2^r:ℕ):ℝ)⁻¹/(1/(k+1:ℝ))^2) := by + simpa only [Nat.cast_pow,Nat.cast_ofNat,←inv_pow] using + (summable_geometric_of_norm_lt_one (show ‖(2:ℝ)⁻¹‖<1 by norm_num)).div_const ((1/(k+1:ℝ))^2) + exact ne_top_of_le_ne_top hs.tsum_ofReal_lt_top.ne + (ENNReal.tsum_le_tsum (fun r => hb i m (2^r) (by positivity) _ (by positivity))) + have hall : ∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ∀ (i : ℤ) (m k : ℕ), + ∀ᶠ r : ℕ in atTop, Y∉survivalViolation e i m (2^r) (1/(k+1:ℝ)) := + ae_all_iff.mpr fun i => ae_all_iff.mpr fun m => ae_all_iff.mpr fun k => hbc i m k + filter_upwards [hall] with Y hY + intro i m H hH + apply le_of_forall_pos_le_add + intro ε hε + obtain ⟨k,hk⟩ := exists_nat_one_div_lt hε + apply limsup_le_of_le (isCoboundedUnder_le_of_le atTop (fun r => arraySurvivalAverage_nonneg e i m H (2^r) Y)) + filter_upwards [hY i m k] with r hr + exact (arraySurvivalAverage_le_of_notMem e i m H (2^r) (by positivity) _ (by positivity) Y hH hr).trans + (add_le_add_right hk.le _) + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma bad_limit_averaged_survival (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (Ns : ℕ → ℕ) (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) : + ∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ArrayAveragedSurvival e Y := by + apply arrayAveragedSurvival_of_bounds e ρ + intro i m n hn ε hε + apply survivalViolation_weak_bound e _ ρ hlim i m n ε _ + intro k + apply actualOccupation_survivalViolation_bound e ν _ + (C.paddedTimes hef (Ns k)) (C.paddedStages hef (Ns k)) + (C.paddedTimes_measurable hef (Ns k)) (C.paddedStages_measurable hef (Ns k)) (Ns k) + (C.activeCount hef (Ns k)) (C.activeCount_measurable hef (Ns k)) + (C.bad_raw_mass_pos hef (Ns k) (hN k) (hmass k)) _ i m n hn ε hε + have hQ := (cond_absolutelyContinuous (μ:=environmentLaw ν) + (s:=badCrossingEvent e (Ns k) (1/2))).ae_le C.rows + filter_upwards [hQ] with ω hω + refine ⟨C.paddedTimes_int_mono hef (Ns k) ω,?_⟩ + intro H + exact ne_of_gt ((ENNReal.pow_pos (show (0:ℝ≥0∞) hω y e) H)) + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SurvivingLane.lean b/lean/OAI/Probability/Ballisticity/Estimates/SurvivingLane.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad5dc78794edf84f39cdd7616d1edebf275fe8da --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SurvivingLane.lean @@ -0,0 +1,342 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.FixedQuenchedKernel + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def SurvivingLane {d : ℕ} (U T A : Set (Lattice d)) : Set (Path d) := + Stay U ∩ Hit (U \ T) (T ∩ A) + +lemma measurableSet_survivingLane {d : ℕ} (U T A : Set (Lattice d)) : + MeasurableSet (SurvivingLane U T A) := + (measurableSet_stay U).inter (measurableSet_hit _ _) + +lemma future_stay_iff {d : ℕ} {U : Set (Lattice d)} {X : Path d} {n : ℕ} + (hpre : ∀ j < n, X j ∈ U) : + (fun j => X (n+j)) ∈ Stay U ↔ X ∈ Stay U := by + constructor + · intro h j + by_cases hj : j < n + · exact hpre j hj + · have hh := h (j-n) + simpa only [Nat.add_sub_of_le (by omega : n ≤ j)] using hh + · intro h j + exact h (n+j) + +lemma future_hit_iff {d : ℕ} {S T A : Set (Lattice d)} (hST : Disjoint S T) + {X : Path d} {n : ℕ} (hpre : ∀ j < n, X j ∈ S) : + (fun j => X (n+j)) ∈ Hit S (T ∩ A) ↔ X ∈ Hit S (T ∩ A) := by + constructor + · intro h + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp h + refine Set.mem_iUnion.mpr ⟨n+m,hm.1,?_⟩ + intro j hj + by_cases hjn : j < n + · exact hpre j hjn + · have hh := hm.2 (j-n) (by omega) + simpa only [Nat.add_sub_of_le (by omega : n ≤ j)] using hh + · intro h + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp h + have hnm : n ≤ m := by + by_contra! h + exact Set.disjoint_left.mp hST (hpre m h) hm.1.1 + refine Set.mem_iUnion.mpr ⟨m-n,?_,?_⟩ + · simpa only [Nat.add_sub_of_le hnm] using hm.1 + · intro j hj + exact hm.2 (n+j) (by omega) + +lemma hit_survival_factorization {d : ℕ} (ω : Environment d) (x : Lattice d) + (U S V : Set (Lattice d)) (hS : S ⊆ U) : + quenchedKernel (ω,x) (Hit (S \ V) V ∩ Stay U) = + ∫⁻ z, quenchedKernel (ω,z) (Stay U) ∂hitKernel (S \ V) V (ω,x) := by + rw [hitKernel_future ω x Set.disjoint_sdiff_left (fun _ => Stay U) + (fun _ => measurableSet_stay U)] + congr 1 + ext X + simp only [Hit,Set.mem_inter_iff,Set.mem_iUnion] + constructor + · rintro ⟨⟨n,hn⟩,hD⟩ + exact ⟨n,hn,fun j => hD (n+j)⟩ + · rintro ⟨n,hn,hD⟩ + exact ⟨⟨n,hn⟩,(future_stay_iff (fun j hj => hS (hn.2 j hj).1)).mp hD⟩ + +lemma hit_laneError_factorization {d : ℕ} (ω : Environment d) (x : Lattice d) + (U T A V : Set (Lattice d)) : + quenchedKernel (ω,x) (Hit ((U \ T) \ V) V ∩ (Stay U \ SurvivingLane U T A)) = + ∫⁻ z, quenchedKernel (ω,z) (Stay U \ SurvivingLane U T A) + ∂hitKernel ((U \ T) \ V) V (ω,x) := by + rw [hitKernel_future ω x Set.disjoint_sdiff_left (fun _ => Stay U \ SurvivingLane U T A) + (fun _ => (measurableSet_stay U).diff (measurableSet_survivingLane U T A))] + congr 1 + ext X + have hh (n : ℕ) (hn : X ∈ HitAt ((U \ T) \ V) V n) : + (fun j => X (n+j)) ∈ Stay U \ SurvivingLane U T A ↔ X ∈ Stay U \ SurvivingLane U T A := by + have hd := future_stay_iff (fun j hj => (hn.2 j hj).1.1) + have he := future_hit_iff (A := A) Set.disjoint_sdiff_left (fun j hj => (hn.2 j hj).1) + change (_ ∧ ¬(_ ∧ _)) ↔ (_ ∧ ¬(_ ∧ _)) + rw [hd,he] + simp only [Hit,Set.mem_inter_iff,Set.mem_iUnion] + constructor + · rintro ⟨⟨n,hn⟩,hD⟩ + exact ⟨n,hn,(hh n hn).mpr hD⟩ + · rintro ⟨n,hn,hD⟩ + exact ⟨⟨n,hn⟩,(hh n hn).mp hD⟩ + +lemma hitKernel_ae_target {d : ℕ} (S V : Set (Lattice d)) (z : State d) : + ∀ᵐ y ∂hitKernel S V z, y ∈ V := by + apply ae_iff.mpr + rw [hitKernel_apply] + have he : V ∩ {a | a ∉ V} = ∅ := by ext a; simp + rw [he] + simp only [HitAt,Set.mem_empty_iff_false,false_and,Set.ofPred_false,measure_empty,tsum_zero] + +lemma quenched_lowLane_visit_bound {d : ℕ} (ω : Environment d) (x : Lattice d) + (U T A V : Set (Lattice d)) + (hlow : ∀ z ∈ V, quenchedKernel (ω,z) (Stay U) ≤ + 2 * quenchedKernel (ω,z) (Stay U \ SurvivingLane U T A)) : + quenchedKernel (ω,x) (Hit ((U \ T) \ V) V ∩ Stay U) ≤ + 2 * quenchedKernel (ω,x) (Stay U \ SurvivingLane U T A) := by + rw [hit_survival_factorization ω x U (U \ T) V Set.sdiff_subset] + calc + _ ≤ ∫⁻ z, 2 * quenchedKernel (ω,z) (Stay U \ SurvivingLane U T A) + ∂hitKernel ((U \ T) \ V) V (ω,x) := by + apply lintegral_mono_ae + filter_upwards [hitKernel_ae_target ((U \ T) \ V) V (ω,x)] with z hz + exact hlow z hz + _ = 2 * quenchedKernel (ω,x) + (Hit ((U \ T) \ V) V ∩ (Stay U \ SurvivingLane U T A)) := by + rw [lintegral_const_mul _ (measurable_of_countable _),hit_laneError_factorization] + _ ≤ _ := mul_le_mul_right (measure_mono Set.inter_subset_right) 2 + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma survivingLane_disjoint {d : ℕ} (U T A B : Set (Lattice d)) (hAB : Disjoint A B) : + Disjoint (SurvivingLane U T A) (SurvivingLane U T B) := by + apply Set.disjoint_left.mpr + intro X hA hB + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hA.2 + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp hB.2 + have he : n = m := by + by_contra h + exact Set.disjoint_left.mp (hitAt_pairwise_disjoint (S := U \ T) (T := T) + Set.disjoint_sdiff_left h) ⟨hn.1.1,hn.2⟩ ⟨hm.1.1,hm.2⟩ + subst m + exact Set.disjoint_left.mp hAB hn.1.2 hm.1.2 + +lemma measure_low_complement_or {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (D A B : Set Ω) (hAB : Disjoint A B) : + μ D ≤ 2*μ (D \ A) ∨ μ D ≤ 2*μ (D \ B) := by + have hh : μ D ≤ μ (D \ A)+μ (D \ B) := by + apply (measure_mono (s := D) (t := (D \ A) ∪ (D \ B)) ?_).trans (measure_union_le _ _) + intro x hx + by_cases ha : x ∈ A + · exact Or.inr ⟨hx,fun hb => Set.disjoint_left.mp hAB ha hb⟩ + · exact Or.inl ⟨hx,ha⟩ + rcases le_total (μ (D \ A)) (μ (D \ B)) with h | h + · right + exact (hh.trans (add_le_add h le_rfl)).trans_eq (two_mul _).symm + · left + exact (hh.trans (add_le_add le_rfl h)).trans_eq (two_mul _).symm + +def PrefixContact {d : ℕ} (S : Set (Lattice d)) : Set (Path d × Path d) := + {Z | ∃ n m, Z.1 n = Z.2 m ∧ (∀ j < n, Z.1 j ∈ S) ∧ (∀ j < m, Z.2 j ∈ S)} + +lemma measurableSet_prefixContact {d : ℕ} (S : Set (Lattice d)) : + MeasurableSet (PrefixContact S) := by + simp only [PrefixContact,Set.ofPred_exists,Set.ofPred_and,Set.ofPred_forall] + apply MeasurableSet.iUnion + intro n + apply MeasurableSet.iUnion + intro m + refine (measurableSet_eq_fun (by fun_prop) (by fun_prop)).inter ?_ + apply MeasurableSet.inter + · exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + ((measurable_pi_apply j).comp measurable_fst) S.to_countable.measurableSet + · exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + ((measurable_pi_apply j).comp measurable_snd) S.to_countable.measurableSet + +lemma prefix_visit_first {d : ℕ} (S V : Set (Lattice d)) (X : Path d) + {n : ℕ} (hn : X n ∈ V) (hpre : ∀ j < n, X j ∈ S) : + X ∈ Hit (S \ V) V := by + classical + let h : ∃ j, X j ∈ V := ⟨n,hn⟩ + let m := Nat.find h + have hm : m ≤ n := Nat.find_min' h hn + refine Set.mem_iUnion.mpr ⟨m,Nat.find_spec h,?_⟩ + intro j hj + exact ⟨hpre j (hj.trans_le hm),Nat.find_min h hj⟩ + +lemma quenched_pair_contact_bound {d : ℕ} (ω : Environment d) (x y : Lattice d) + (U T A B : Set (Lattice d)) (hAB : Disjoint A B) : + ((quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))) + (PrefixContact (U \ T) ∩ (Stay U ×ˢ Stay U)) ≤ + 2 * (quenchedKernel (ω,x) (Stay U \ SurvivingLane U T A) * quenchedKernel (ω,y) (Stay U) + + quenchedKernel (ω,x) (Stay U) * quenchedKernel (ω,y) (Stay U \ SurvivingLane U T B)) := by + let V := fun C : Set (Lattice d) => {z | quenchedKernel (ω,z) (Stay U) ≤ + 2*quenchedKernel (ω,z) (Stay U \ SurvivingLane U T C)} + let E := fun C : Set (Lattice d) => Hit ((U \ T) \ V C) (V C) ∩ Stay U + have hlow : ∀ z, z ∈ V A ∨ z ∈ V B := fun z => + measure_low_complement_or _ _ _ _ (survivingLane_disjoint U T A B hAB) + have hsub : PrefixContact (U \ T) ∩ (Stay U ×ˢ Stay U) ⊆ + (E A ×ˢ Stay U) ∪ (Stay U ×ˢ E B) := by + intro Z hZ + obtain ⟨n,m,he,hpre,hpre'⟩ := hZ.1 + rcases hlow (Z.1 n) with h | h + · exact Or.inl ⟨⟨prefix_visit_first _ _ _ h hpre,hZ.2.1⟩,hZ.2.2⟩ + · rw [he] at h + exact Or.inr ⟨hZ.2.1,⟨prefix_visit_first _ _ _ h hpre',hZ.2.2⟩⟩ + have hE (C : Set (Lattice d)) : MeasurableSet (E C) := + (measurableSet_hit _ _).inter (measurableSet_stay U) + calc + _ ≤ ((quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))) (E A ×ˢ Stay U) + + ((quenchedKernel (ω,x)).prod (quenchedKernel (ω,y))) (Stay U ×ˢ E B) := + (measure_mono hsub).trans (measure_union_le _ _) + _ = quenchedKernel (ω,x) (E A)*quenchedKernel (ω,y) (Stay U) + + quenchedKernel (ω,x) (Stay U)*quenchedKernel (ω,y) (E B) := by + rw [Measure.prod_prod,Measure.prod_prod] + _ ≤ (2*quenchedKernel (ω,x) (Stay U \ SurvivingLane U T A))*quenchedKernel (ω,y) (Stay U) + + quenchedKernel (ω,x) (Stay U)*(2*quenchedKernel (ω,y) (Stay U \ SurvivingLane U T B)) := by + apply add_le_add + · exact mul_le_mul_left (quenched_lowLane_visit_bound ω x U T A (V A) (fun _ hz => hz)) _ + · exact mul_le_mul_right (quenched_lowLane_visit_bound ω y U T B (V B) (fun _ hz => hz)) _ + _ = _ := by ring + +lemma shared_pair_contact_bound {d : ℕ} (ν : Measure (Row d)) (x y : Lattice d) + (U T A B : Set (Lattice d)) (hAB : Disjoint A B) : + sharedPairLaw ν x y (PrefixContact (U \ T) ∩ (Stay U ×ˢ Stay U)) ≤ + 2 * (sharedPairLaw ν x y ((Stay U \ SurvivingLane U T A) ×ˢ Stay U) + + sharedPairLaw ν x y (Stay U ×ˢ (Stay U \ SurvivingLane U T B))) := by + have hD := measurableSet_stay U + have hA := hD.diff (measurableSet_survivingLane U T A) + have hB := hD.diff (measurableSet_survivingLane U T B) + conv_lhs => rw [sharedPairLaw,Measure.bind_apply ((measurableSet_prefixContact _).inter (hD.prod hD)) (Kernel.aemeasurable _)] + rw [sharedPairLaw_rectangle ν x y _ _ hA hD,sharedPairLaw_rectangle ν x y _ _ hD hB] + have hm (C D : Set (Path d)) (hC : MeasurableSet C) (hD : MeasurableSet D) : + Measurable (fun ω : Environment d => quenchedKernel (ω,x) C * quenchedKernel (ω,y) D) := + ((Kernel.measurable_coe _ hC).comp (measurable_id.prodMk measurable_const)).mul + ((Kernel.measurable_coe _ hD).comp (measurable_id.prodMk measurable_const)) + rw [← lintegral_add_left (hm _ _ hA hD)] + rw [← lintegral_const_mul _ (show Measurable (fun ω : Environment d => + quenchedKernel (ω,x) (Stay U \ SurvivingLane U T A)*quenchedKernel (ω,y) (Stay U) + + quenchedKernel (ω,x) (Stay U)*quenchedKernel (ω,y) (Stay U \ SurvivingLane U T B)) from + (hm _ _ hA hD).add (hm _ _ hD hB))] + apply lintegral_mono + intro ω + dsimp only + rw [sharedPairKernel,Kernel.prod_apply] + exact quenched_pair_contact_bound ω x y U T A B hAB + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SymmetricPrefixTail.lean b/lean/OAI/Probability/Ballisticity/Estimates/SymmetricPrefixTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..c67e0d37803f563c8b8bff8635a76a1663d0b5ec --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SymmetricPrefixTail.lean @@ -0,0 +1,152 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MeasureAdd + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma symmetric_iid_partialSum {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ j, Measurable (X j)) (hind : iIndepFun X μ) + (hsym : ∀ j, IdentDistrib (X j) (fun ω => -X j ω) μ μ) (n : ℕ) : + IdentDistrib (fun ω => realPartialSum (fun j => X j ω) n) + (fun ω => -realPartialSum (fun j => X j ω) n) μ μ := by + induction n with + | zero => simp only [realPartialSum,Finset.range_zero,Finset.sum_empty,neg_zero]; exact IdentDistrib.refl measurable_const.aemeasurable + | succ n ih => + have hi : IndepFun (fun ω => realPartialSum (fun j => X j ω) n) (X n) μ := by + have he : (∑ j ∈ Finset.range n, X j) = (fun ω => realPartialSum (fun j => X j ω) n) := by + funext ω + simp only [realPartialSum,Finset.sum_apply] + rw [←he] + exact hind.indepFun_finsetSum_of_notMem hX (show n ∉ Finset.range n by simp) + have hin := hi.comp measurable_neg measurable_neg + have hh := (ih.prodMk (hsym n) hi hin).comp measurable_add + simpa only [Function.comp_def,realPartialSum,Finset.sum_range_succ,neg_add] using hh + +lemma independent_prefix_remainder {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ j, Measurable (X j)) (hind : iIndepFun X μ) (m n : ℕ) : + IndepFun (fun ω => realPartialSum (fun j => X j ω) m) + (fun ω => ∑ j ∈ Finset.Ico m n, X j ω) μ := by + have hd : Disjoint (Finset.range m) (Finset.Ico m n) := by + rw [Finset.disjoint_left] + intro j hj hk + simp only [Finset.mem_range,Finset.mem_Ico] at hj hk + omega + have hi := hind.indepFun_finset (Finset.range m) (Finset.Ico m n) hd hX + have hh := hi.comp (show Measurable (fun z : Finset.range m → ℝ => ∑ j, z j) by fun_prop) + (show Measurable (fun z : Finset.Ico m n → ℝ => ∑ j, z j) by fun_prop) + change IndepFun (fun ω => ∑ j : Finset.range m, X j.1 ω) + (fun ω => ∑ j : Finset.Ico m n, X j.1 ω) μ at hh + have he (ω : Ω) : (∑ j : Finset.range m, X j.1 ω) = realPartialSum (fun j => X j ω) m := by + exact Finset.sum_coe_sort (Finset.range m) (fun j => X j ω) + have hf (ω : Ω) : (∑ j : Finset.Ico m n, X j.1 ω) = ∑ j ∈ Finset.Ico m n, X j ω := by + exact Finset.sum_coe_sort (Finset.Ico m n) (fun j => X j ω) + simpa only [he,hf] using hh + +lemma symmetric_prefix_tail {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ j, Measurable (X j)) (hind : iIndepFun X μ) + (hsym : ∀ j, IdentDistrib (X j) (fun ω => -X j ω) μ μ) + {m n : ℕ} (hmn : m ≤ n) (a : ℝ) : + (1/2:ℝ)*μ.real {ω | a < |realPartialSum (fun j => X j ω) m|} ≤ + μ.real {ω | a < |realPartialSum (fun j => X j ω) n|} := by + have hh := symmetric_summand_tail μ + (fun ω => realPartialSum (fun j => X j ω) m) (fun ω => ∑ j ∈ Finset.Ico m n, X j ω) + (by unfold realPartialSum; fun_prop) (by fun_prop) (symmetric_iid_partialSum μ X hX hind hsym m) + (independent_prefix_remainder μ X hX hind m n) a + have he (ω) : realPartialSum (fun j => X j ω) m + ∑ j ∈ Finset.Ico m n, X j ω = + realPartialSum (fun j => X j ω) n := Finset.sum_range_add_sum_Ico _ hmn + simp only [he] at hh + exact hh.trans (measureReal_mono fun _ h => h.2) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma gaussian_sequence_of_collapsed_sums {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ j, Measurable (X j)) (hind : iIndepFun X μ) + (hid : ∀ j, IdentDistrib (X j) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) (k : ℕ → ℕ) + {τ : ℝ} (hτ : 0 < τ) + (hk : Tendsto (fun i => (k i:ℝ)/fluctuationScale μ (X 0) (r i)) atTop (𝓝 τ)) + (hcollapse : ∀ a : ℝ, 0 < a → Tendsto + (fun i => μ.real {ω | a*r i < |realPartialSum (fun j => X j ω) (k i)|}) atTop (𝓝 0)) : + IsGaussianSequence μ (X 0) r := by + let n := fun i => fluctuationScale μ (X 0) (r i) + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto μ (X 0) (hX 0) hI hne).comp hr + have hsymj (j) : IdentDistrib (X j) (fun ω => -X j ω) μ μ := + (hid j).trans (hsym.trans ((hid j).symm.comp measurable_neg)) + refine ⟨hr,fun a ha => ?_⟩ + let l := min a 1 + have hl : 0 < l := lt_min ha zero_lt_one + have hl1 : l ≤ 1 := min_le_right _ _ + have hla : l ≤ a := min_le_left _ _ + let t := min (τ/4) (l^2/4) + have ht : 0 < t := lt_min (by positivity) (by positivity) + have htτ : t ≤ τ/4 := min_le_left _ _ + have htl : t ≤ l^2/4 := min_le_right _ _ + let m := fun i => ⌊t*n i⌋₊ + let p := fun i => μ.real {ω | l*r i < |X 0 ω|} + have hbd : ∀ᶠ i in atTop, n i*μ.real {ω | a*r i < |X 0 ω|} ≤ + (16/t)*μ.real {ω | l*r i < |realPartialSum (fun j => X j ω) (k i)|} := by + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ)), + hn.eventually (eventually_ge_atTop (2/t)),hk.eventually (lt_mem_nhds (show τ/2 < τ by linarith))] with i hri hni hki + have hn0 : 0 < n i := (div_pos (by norm_num : (0:ℝ)<2) ht).trans_le hni + have hnp : n i*p i ≤ 1/l^2 := fluctuation_tail_bound μ (X 0) (hX 0) hne hri hl hl1 + have hp0 : 0 ≤ p i := measureReal_nonneg + have hmhi : (m i:ℝ) ≤ t*n i := Nat.floor_le (mul_nonneg ht.le hn0.le) + have hmlo : t*n i/2 ≤ (m i:ℝ) := by + have hh := Nat.lt_floor_add_one (t*n i) + have hni' := (div_le_iff₀ ht).mp hni + dsimp [m] + nlinarith + have hmk : m i ≤ k i := by + have hki' : τ/2*n i < (k i:ℝ) := (lt_div_iff₀ hn0).mp hki + exact_mod_cast (show (m i:ℝ) ≤ (k i:ℝ) by nlinarith) + have hu0 : 0 ≤ (m i:ℝ)*p i := mul_nonneg (Nat.cast_nonneg _) hp0 + have hu1 : (m i:ℝ)*p i ≤ 1/4 := by + have hh := mul_le_mul_of_nonneg_left hnp ht.le + rw [mul_one_div] at hh + have hh' := mul_le_mul_of_nonneg_right hmhi hp0 + have hfrac : t/l^2 ≤ 1/4 := (div_le_iff₀ (sq_pos_of_pos hl)).mpr (by nlinarith only [htl]) + nlinarith + have hra := iid_symmetric_sum_spread μ X hX hind hid hsym (l*r i) (m i) + have hpre := symmetric_prefix_tail μ X hX hind hsymj hmk (l*r i) + change (1/2:ℝ)*((m i:ℝ)*p i)-((m i:ℝ)*p i)^2/2 ≤ + μ.real {ω | l*r i < |realPartialSum (fun j => X j ω) (m i)|} at hra + have hu : ((m i:ℝ)*p i)/4 ≤ + μ.real {ω | l*r i < |realPartialSum (fun j => X j ω) (m i)|} := by + nlinarith only [hra,hu0,hu1,mul_nonneg hu0 (show 0 ≤ 1/2-(m i:ℝ)*p i by linarith)] + have hpa : μ.real {ω | a*r i < |X 0 ω|} ≤ p i := + measureReal_mono (fun ω hω => (mul_le_mul_of_nonneg_right hla hri.le).trans_lt hω) + have hscale := mul_le_mul_of_nonneg_right hmlo hp0 + have hfinal : t*(n i*p i) ≤ 16*μ.real {ω | l*r i < |realPartialSum (fun j => X j ω) (k i)|} := by + nlinarith only [hu,hpre,hscale] + have hh : n i*p i ≤ (16/t)*μ.real {ω | l*r i < |realPartialSum (fun j => X j ω) (k i)|} := by + rw [div_mul_eq_mul_div] + exact (le_div_iff₀ ht).2 (by nlinarith only [hfinal]) + exact (mul_le_mul_of_nonneg_left hpa hn0.le).trans hh + apply squeeze_zero' (Eventually.of_forall fun i => mul_nonneg (fluctuationScale_nonneg _ _ _) measureReal_nonneg) hbd + simpa using (hcollapse l hl).const_mul (16/t) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SymmetricTruncate.lean b/lean/OAI/Probability/Ballisticity/Estimates/SymmetricTruncate.lean new file mode 100644 index 0000000000000000000000000000000000000000..456c6377620f745cb0086f6c21a38ba08dcde50b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SymmetricTruncate.lean @@ -0,0 +1,434 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CommonWordIncrement + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma abs_supporting (t x : ℝ) : absSlope t*x ≤ |t+x|-|t| := by + by_cases ht : 0 ≤ t + · rw [absSlope,ite_eq_left ht,one_mul,abs_of_nonneg ht] + linarith [le_abs_self (t+x)] + · rw [absSlope,ite_eq_right ht,neg_one_mul,abs_of_neg (lt_of_not_ge ht)] + linarith [neg_le_abs (t+x)] + +lemma max_square_increment {m a : ℝ} : (max m |a|)^2-m^2 ≤ 2*|a| * (max m |a|-m) := by + by_cases h : |a| ≤ m + · rw [max_eq_left h]; ring_nf; rfl + · rw [max_eq_right (le_of_not_ge h)] + nlinarith [sq_nonneg (|a|-m)] + +lemma partialSumMax_pathwise (X : ℕ → ℝ) (n : ℕ) : + (partialSumMax X n)^2 ≤ 2*partialSumMax X n*|realPartialSum X n|- + 2*∑ k ∈ Finset.range n, partialSumMax X k*absSlope (realPartialSum X k)*X k := by + induction n with + | zero => simp [partialSumMax] + | succ n ih => + have hincr := max_square_increment (m := partialSumMax X n) (a := realPartialSum X (n+1)) + have hs := mul_le_mul_of_nonneg_left (abs_supporting (realPartialSum X n) (X n)) + (partialSumMax_nonneg X n) + rw [← realPartialSum_succ] at hs + rw [Finset.sum_range_succ] + change (max (partialSumMax X n) |realPartialSum X (n+1)|)^2 ≤ _ + change _ ≤ 2*max (partialSumMax X n) |realPartialSum X (n+1)| * |realPartialSum X (n+1)|-_ + nlinarith + +lemma partialSumMax_square_pathwise (X : ℕ → ℝ) (n : ℕ) : + (partialSumMax X n)^2 ≤ 4*(realPartialSum X n)^2- + 4*∑ k ∈ Finset.range n, partialSumMax X k*absSlope (realPartialSum X k)*X k := by + have h := partialSumMax_pathwise X n + nlinarith [sq_nonneg (partialSumMax X n-2*|realPartialSum X n|),sq_abs (realPartialSum X n)] + +lemma measurable_realPartialSum {Ω : Type*} [MeasurableSpace Ω] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (n : ℕ) : Measurable (fun ω => realPartialSum (fun k => X k ω) n) := by + unfold realPartialSum + fun_prop + +lemma measurable_partialSumMax {Ω : Type*} [MeasurableSpace Ω] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (n : ℕ) : Measurable (fun ω => partialSumMax (fun k => X k ω) n) := by + induction n with + | zero => exact measurable_const + | succ n ih => exact ih.max (measurable_realPartialSum X hX (n+1)).abs + +lemma measurable_absSlope : Measurable absSlope := + Measurable.ite (measurableSet_le measurable_const measurable_id) measurable_const measurable_const + +lemma integrable_of_abs_bound {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (f : Ω → ℝ) (hf : Measurable f) (C : ℝ) (hC : ∀ ω, |f ω| ≤ C) : Integrable f μ := + (integrable_const C).mono' hf.aestronglyMeasurable (Eventually.of_forall fun ω => by + simpa only [Real.norm_eq_abs] using hC ω) + +lemma realPartialSum_congr {X Y : ℕ → ℝ} (n : ℕ) (hXY : ∀ k < n, X k = Y k) : + realPartialSum X n = realPartialSum Y n := by + exact Finset.sum_congr rfl fun k hk => hXY k (Finset.mem_range.mp hk) + +lemma partialSumMax_congr {X Y : ℕ → ℝ} (n : ℕ) (hXY : ∀ k < n, X k = Y k) : + partialSumMax X n = partialSumMax Y n := by + induction n with + | zero => rfl + | succ n ih => + rw [partialSumMax,partialSumMax,ih (fun k hk => hXY k (hk.trans (Nat.lt_succ_self _))), + realPartialSum_congr (n+1) hXY] + +lemma independent_max_transform {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) (n : ℕ) : + IndepFun (fun ω => partialSumMax (fun k => X k ω) n*absSlope (realPartialSum (fun k => X k ω) n)) + (X n) μ := by + let Y (v : Fin n → ℝ) (k : ℕ) := if h : k < n then v ⟨k,h⟩ else 0 + have hY : ∀ k, Measurable (fun v => Y v k) := by + intro k + by_cases h : k < n <;> simp only [Y,h,↓reduceDIte] <;> fun_prop + have hm : Measurable (fun v => partialSumMax (Y v) n*absSlope (realPartialSum (Y v) n)) := + (measurable_partialSumMax (fun k v => Y v k) hY n).mul + (measurable_absSlope.comp (measurable_realPartialSum (fun k v => Y v k) hY n)) + have hh := (independent_past_current μ X hX hind n).comp hm measurable_id + convert hh using 1 + · funext ω + have heq : ∀ k < n, X k ω = Y (fun j : Fin n => X j ω) k := fun k hk => by simp [Y,hk] + rw [partialSumMax_congr n heq,realPartialSum_congr n heq] + rfl + · rfl + +lemma integrable_partialSumMax_square {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + Integrable (fun ω => (partialSumMax (fun k => X k ω) n)^2) μ := by + apply integrable_of_abs_bound μ _ ((measurable_partialSumMax X hX n).pow_const 2) ((n*z)^2) + intro ω + rw [abs_of_nonneg (sq_nonneg _)] + exact pow_le_pow_left₀ (partialSumMax_nonneg _ _) (partialSumMax_bound _ hz (fun k => hbound k ω) n) 2 + +lemma integrable_realPartialSum_square {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + Integrable (fun ω => (realPartialSum (fun k => X k ω) n)^2) μ := by + apply (integrable_partialSumMax_square μ X hX hz hbound n).mono' + ((measurable_realPartialSum X hX n).pow_const 2).aestronglyMeasurable + exact Eventually.of_forall fun ω => by + rw [Real.norm_of_nonneg (sq_nonneg _)] + have := abs_partialSum_le_max (fun k => X k ω) n + rw [← sq_abs (realPartialSum (fun k => X k ω) n)] + exact pow_le_pow_left₀ (abs_nonneg _) this 2 + +lemma integral_partialSumMax_square_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hmean : ∀ k, ∫ ω, X k ω ∂μ = 0) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + (∫ ω, (partialSumMax (fun k => X k ω) n)^2 ∂μ) ≤ + 4*∫ ω, (realPartialSum (fun k => X k ω) n)^2 ∂μ := by + let C (k : ℕ) (ω : Ω) := partialSumMax (fun j => X j ω) k*absSlope (realPartialSum (fun j => X j ω) k) + have hC (k : ℕ) : Measurable (C k) := (measurable_partialSumMax X hX k).mul + (measurable_absSlope.comp (measurable_realPartialSum X hX k)) + have hCI (k : ℕ) : Integrable (fun ω => C k ω*X k ω) μ := by + apply integrable_of_abs_bound μ _ ((hC k).mul (hX k)) (k*z*z) + intro ω + dsimp [C] + rw [abs_mul,abs_mul,abs_absSlope,mul_one,abs_of_nonneg (partialSumMax_nonneg _ _)] + exact mul_le_mul (partialSumMax_bound _ hz (fun j => hbound j ω) k) (hbound k ω) + (abs_nonneg _) (mul_nonneg (Nat.cast_nonneg _) hz) + have hzero (k : ℕ) : ∫ ω, C k ω*X k ω ∂μ = 0 := by + rw [(independent_max_transform μ X hX hind k).integral_fun_mul_eq_mul_integral + (hC k).aestronglyMeasurable (hX k).aestronglyMeasurable,hmean,mul_zero] + have hm := integral_mono (integrable_partialSumMax_square μ X hX hz hbound n) + (((integrable_realPartialSum_square μ X hX hz hbound n).const_mul 4).sub + ((integrable_finsetSum (Finset.range n) (fun k _ => hCI k)).const_mul 4)) + (fun ω => partialSumMax_square_pathwise (fun k => X k ω) n) + simp only [Pi.sub_apply] at hm + rw [integral_sub ((integrable_realPartialSum_square μ X hX hz hbound n).const_mul 4) + ((integrable_finsetSum (Finset.range n) (fun k _ => hCI k)).const_mul 4), + integral_const_mul,integral_const_mul,integral_finsetSum _ (fun k _ => hCI k)] at hm + simpa only [hzero,Finset.sum_const_zero,mul_zero,sub_zero] using hm + +lemma integral_partialSum_square_eq_sum {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hmean : ∀ k, ∫ ω, X k ω ∂μ = 0) + {z : ℝ} (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + (∫ ω, (realPartialSum (fun k => X k ω) n)^2 ∂μ) = + ∑ k ∈ Finset.range n, ∫ ω, (X k ω)^2 ∂μ := by + have hLp (k : ℕ) : MemLp (X k) 2 μ := MemLp.of_bound (hX k).aestronglyMeasurable z + (Eventually.of_forall fun ω => by simpa only [Real.norm_eq_abs] using hbound k ω) + have hI (k : ℕ) : Integrable (X k) μ := (hLp k).integrable (by norm_num) + have hsum : ∫ ω, realPartialSum (fun k => X k ω) n ∂μ = 0 := by + rw [show (fun ω => realPartialSum (fun k => X k ω) n) = + (fun ω => ∑ k ∈ Finset.range n, X k ω) from rfl, + integral_finsetSum _ (fun k _ => hI k)] + simp only [hmean,Finset.sum_const_zero] + have hv := IndepFun.variance_sum (s := Finset.range n) (fun k _ => hLp k) + (fun i _ j _ hij => hind.indepFun hij) + have heq : (∑ k ∈ Finset.range n, X k) = (fun ω => realPartialSum (fun k => X k ω) n) := by + ext ω + simp only [realPartialSum,Finset.sum_apply] + rw [heq,variance_eq_integral (measurable_realPartialSum X hX n).aemeasurable,hsum] at hv + simpa only [variance_eq_integral (hX _).aemeasurable,hmean,sub_zero] using hv + +lemma integral_partialSumMax_square_le_sum {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hmean : ∀ k, ∫ ω, X k ω ∂μ = 0) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + (∫ ω, (partialSumMax (fun k => X k ω) n)^2 ∂μ) ≤ + 4*∑ k ∈ Finset.range n, ∫ ω, (X k ω)^2 ∂μ := by + rw [← integral_partialSum_square_eq_sum μ X hX hind hmean hbound n] + exact integral_partialSumMax_square_le μ X hX hind hmean hz hbound n + +noncomputable def symmetricTruncate (z x : ℝ) : ℝ := if |x| ≤ z then x else 0 +noncomputable def truncatedTailCost (z x : ℝ) : ℝ := if z < |x| then z^2 else 0 + +lemma measurable_symmetricTruncate (z : ℝ) : Measurable (symmetricTruncate z) := + Measurable.ite (measurableSet_le measurable_abs measurable_const) measurable_id measurable_const + +lemma measurable_truncatedTailCost (z : ℝ) : Measurable (truncatedTailCost z) := + Measurable.ite (measurableSet_lt measurable_const measurable_abs) measurable_const measurable_const + +lemma symmetricTruncate_bound {z : ℝ} (hz : 0 ≤ z) (x : ℝ) : |symmetricTruncate z x| ≤ z := by + unfold symmetricTruncate + split_ifs with h + · exact h + · simpa using hz + +lemma symmetricTruncate_neg (z x : ℝ) : symmetricTruncate z (-x) = -symmetricTruncate z x := by + simp only [symmetricTruncate,abs_neg] + split_ifs <;> simp + +lemma symmetricTruncate_sq_le (z x : ℝ) : (symmetricTruncate z x)^2 ≤ min (x^2) (z^2) := by + unfold symmetricTruncate + split_ifs with h + · exact le_min le_rfl (by nlinarith [abs_nonneg x,sq_abs x]) + · simpa only [zero_pow (by norm_num : 2 ≠ 0)] using le_min (sq_nonneg x) (sq_nonneg z) + +lemma truncatedTailCost_nonneg (z x : ℝ) : 0 ≤ truncatedTailCost z x := by + unfold truncatedTailCost + split_ifs <;> positivity + +lemma truncatedTailCost_le {z : ℝ} (hz : 0 ≤ z) (x : ℝ) : + truncatedTailCost z x ≤ min (x^2) (z^2) := by + unfold truncatedTailCost + split_ifs with h + · exact le_min (by nlinarith [sq_abs x]) le_rfl + · exact le_min (sq_nonneg x) (sq_nonneg z) + +lemma integral_symmetricTruncate_zero {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (S : Ω → ℝ) (z : ℝ) + (hsym : IdentDistrib S (fun ω => -S ω) μ μ) : + (∫ ω, symmetricTruncate z (S ω) ∂μ) = 0 := by + have he := (hsym.comp (measurable_symmetricTruncate z)).integral_eq + simp only [Function.comp_apply,symmetricTruncate_neg,integral_neg] at he + linarith + +lemma capped_partialSumMax_le_truncated (X : ℕ → ℝ) (n : ℕ) (z : ℝ) : + min ((partialSumMax X n)^2) (z^2) ≤ + (partialSumMax (fun k => symmetricTruncate z (X k)) n)^2 + + ∑ k ∈ Finset.range n, truncatedTailCost z (X k) := by + classical + by_cases h : ∀ k < n, |X k| ≤ z + · have he : partialSumMax X n = partialSumMax (fun k => symmetricTruncate z (X k)) n := by + apply partialSumMax_congr + intro k hk + simp only [symmetricTruncate,ite_eq_left (h k hk)] + rw [he] + exact (min_le_left _ _).trans (le_add_of_nonneg_right + (Finset.sum_nonneg fun k _ => truncatedTailCost_nonneg z (X k))) + · push Not at h + obtain ⟨k,hkn,hk⟩ := h + have hs := Finset.single_le_sum (f := fun k => truncatedTailCost z (X k)) + (fun j _ => truncatedTailCost_nonneg z (X j)) (Finset.mem_range.mpr hkn) + rw [truncatedTailCost,ite_eq_left hk] at hs + exact (min_le_right _ _).trans (hs.trans (le_add_of_nonneg_left (sq_nonneg _))) + +lemma integral_partialSumMax_capped_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {z : ℝ} (hz : 0 ≤ z) (n : ℕ) : + (∫ ω, min ((partialSumMax (fun k => X k ω) n)^2) (z^2) ∂μ) ≤ + 5*(n : ℝ)*truncatedVariance μ (X 0) z := by + let Y (k : ℕ) (ω : Ω) := symmetricTruncate z (X k ω) + have hY (k : ℕ) : Measurable (Y k) := (measurable_symmetricTruncate z).comp (hX k) + have hYb (k : ℕ) (ω : Ω) : |Y k ω| ≤ z := symmetricTruncate_bound hz _ + have hYi : iIndepFun Y μ := hind.comp (fun _ => symmetricTruncate z) (fun _ => measurable_symmetricTruncate z) + have hYm (k : ℕ) : (∫ ω, Y k ω ∂μ) = 0 := by + rw [show (∫ ω, Y k ω ∂μ) = ∫ ω, Y 0 ω ∂μ from + ((hident k).comp (measurable_symmetricTruncate z)).integral_eq] + exact integral_symmetricTruncate_zero μ (X 0) z hsym + have htI (k : ℕ) : Integrable (fun ω => truncatedTailCost z (X k ω)) μ := by + apply (integrable_truncated_square μ (X k) (hX k) z).mono' + (((measurable_truncatedTailCost z).comp (hX k)).aestronglyMeasurable) + exact Eventually.of_forall fun ω => by + simp only [Function.comp_apply] + rw [Real.norm_of_nonneg (truncatedTailCost_nonneg _ _)] + exact truncatedTailCost_le hz _ + have hsqI (k : ℕ) : Integrable (fun ω => (Y k ω)^2) μ := by + apply (integrable_truncated_square μ (X k) (hX k) z).mono' + ((hY k).pow_const 2).aestronglyMeasurable + exact Eventually.of_forall fun ω => by + rw [Real.norm_of_nonneg (sq_nonneg _)] + exact symmetricTruncate_sq_le _ _ + have heq (k : ℕ) : truncatedVariance μ (X k) z = truncatedVariance μ (X 0) z := + ((hident k).comp ((measurable_id.pow_const 2).min measurable_const)).integral_eq + have hsq (k : ℕ) : (∫ ω, (Y k ω)^2 ∂μ) ≤ truncatedVariance μ (X 0) z := by + rw [← heq k] + exact integral_mono (hsqI k) (integrable_truncated_square μ (X k) (hX k) z) + (fun ω => symmetricTruncate_sq_le _ _) + have ht (k : ℕ) : (∫ ω, truncatedTailCost z (X k ω) ∂μ) ≤ truncatedVariance μ (X 0) z := by + rw [← heq k] + exact integral_mono (htI k) (integrable_truncated_square μ (X k) (hX k) z) + (fun ω => truncatedTailCost_le hz _) + have hm := integral_mono (integrable_truncated_square μ _ (measurable_partialSumMax X hX n) z) + ((integrable_partialSumMax_square μ Y hY hz hYb n).add + (integrable_finsetSum (Finset.range n) (fun k _ => htI k))) + (fun ω => capped_partialSumMax_le_truncated (fun k => X k ω) n z) + simp only [Pi.add_apply] at hm + rw [integral_add (integrable_partialSumMax_square μ Y hY hz hYb n) + (integrable_finsetSum (Finset.range n) (fun k _ => htI k)), + integral_finsetSum _ (fun k _ => htI k)] at hm + have hmax := integral_partialSumMax_square_le_sum μ Y hY hYi hYm hz hYb n + have hsum1 := Finset.sum_le_sum (s := Finset.range n) (fun k _ => hsq k) + have hsum2 := Finset.sum_le_sum (s := Finset.range n) (fun k _ => ht k) + simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul] at hsum1 hsum2 + linarith + +lemma measureReal_partialSumMax_gt_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {z : ℝ} (hz : 0 < z) (n : ℕ) : + μ.real {ω | z < partialSumMax (fun k => X k ω) n} ≤ + 5*(n : ℝ)*truncatedVariance μ (X 0) z / z^2 := by + have hb := mul_meas_ge_le_integral_of_nonneg + (Eventually.of_forall (fun ω => le_min + (sq_nonneg (partialSumMax (fun k => X k ω) n)) (sq_nonneg z))) + (integrable_truncated_square μ _ (measurable_partialSumMax X hX n) z) (z^2) + have hmono : μ.real {ω | z < partialSumMax (fun k => X k ω) n} ≤ + μ.real {ω | z^2 ≤ min ((partialSumMax (fun k => X k ω) n)^2) (z^2)} := by + apply measureReal_mono _ (measure_ne_top _ _) + intro ω hω + change z < partialSumMax (fun k => X k ω) n at hω + change z^2 ≤ min ((partialSumMax (fun k => X k ω) n)^2) (z^2) + apply le_min + · nlinarith only [mul_self_le_mul_self hz.le hω.le] + · exact le_rfl + apply (le_div_iff₀ (sq_pos_of_pos hz)).mpr + calc + μ.real {ω | z < partialSumMax (fun k => X k ω) n} * z^2 ≤ + z^2 * μ.real {ω | z^2 ≤ min ((partialSumMax (fun k => X k ω) n)^2) (z^2)} := by + simpa only [mul_comm] using mul_le_mul_of_nonneg_left hmono (sq_nonneg z) + _ ≤ ∫ ω, min ((partialSumMax (fun k => X k ω) n)^2) (z^2) ∂μ := hb + _ ≤ _ := integral_partialSumMax_capped_le μ X hX hind hident hsym hz.le n + +noncomputable def commonIncrementProcess {d : ℕ} (ℓ : Vector d) (e : Direction d) + (n : ℕ) (P : Path d × Path d) : ℝ := + commonWordIncrement e (commonWords ℓ P n) + +lemma measurable_commonIncrementProcess {d : ℕ} (ℓ : Vector d) (e : Direction d) (n : ℕ) : + Measurable (commonIncrementProcess ℓ e n) := + (measurable_of_countable (commonWordIncrement e)).comp + ((measurable_firstPairWord ℓ).comp ((measurable_renewPairSuffix ℓ).iterate n)) + +lemma commonIncrements_independent {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) : + iIndepFun (commonIncrementProcess ℓ e) (independentConditionedPairLaw ν ℓ) := + (common_words_independent ν ℓ htrans height hproj hstep).comp + (fun _ => commonWordIncrement e) (fun _ => measurable_of_countable _) + +lemma commonIncrements_identDistrib {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) (n : ℕ) : + IdentDistrib (commonIncrementProcess ℓ e n) (commonIncrementProcess ℓ e 0) + (independentConditionedPairLaw ν ℓ) (independentConditionedPairLaw ν ℓ) := + (common_words_identDistrib ν ℓ htrans height hproj hstep n).comp (measurable_of_countable _) + +lemma independent_common_maximal_capped {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) + {r : ℝ} (hr : 0 ≤ r) (n : ℕ) : + (∫ P, min ((partialSumMax (fun k => commonIncrementProcess ℓ e k P) n)^2) (r^2) + ∂independentConditionedPairLaw ν ℓ) ≤ + 5*(n : ℝ)*truncatedVariance (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ e 0) r := by + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + exact integral_partialSumMax_capped_le _ _ (measurable_commonIncrementProcess ℓ e) + (commonIncrements_independent ν ℓ htrans height hproj hstep e) + (commonIncrements_identDistrib ν ℓ htrans height hproj hstep e) + (independent_commonWordIncrement_symmetric ν ℓ htrans e) hr n + +lemma independent_common_maximal_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ x, dot (realPosition x) ℓ = (height x : ℝ)) + (hstep : ∀ x e, height (x+step e) ≤ height x+1) (e : Direction d) + {r : ℝ} (hr : 0 < r) (n : ℕ) : + (independentConditionedPairLaw ν ℓ).real + {P | r < partialSumMax (fun k => commonIncrementProcess ℓ e k P) n} ≤ + 5*(n : ℝ)/fluctuationScale (independentConditionedPairLaw ν ℓ) + (commonIncrementProcess ℓ e 0) r := by + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + rw [fluctuationScale,div_div_eq_mul_div] + exact measureReal_partialSumMax_gt_le _ _ (measurable_commonIncrementProcess ℓ e) + (commonIncrements_independent ν ℓ htrans height hproj hstep e) + (commonIncrements_identDistrib ν ℓ htrans height hproj hstep e) + (independent_commonWordIncrement_symmetric ν ℓ htrans e) hr n + +lemma signedCoordinate_sub {d : ℕ} (e : Direction d) (x y : Lattice d) : + signedCoordinate e (x-y) = signedCoordinate e x - signedCoordinate e y := by + simp only [signedCoordinate, Pi.sub_apply, Int.cast_sub] + split <;> ring + +lemma commonTimes_span {d : ℕ} (ℓ : Vector d) (P : Path d × Path d) + (h0 : P.1 0 = 0) (h0' : P.2 0 = 0) + (hP : ∀ n, ((renewPairSuffix ℓ)^[n] P) ∈ FirstPairWordEvent ℓ (commonWords ℓ P n)) + (n : ℕ) : + P.1 (commonTimes ℓ P (n+1)).1 = + P.1 (commonTimes ℓ P n).1 + wordPath 0 (commonWords ℓ P n).1 (commonWords ℓ P n).1.length ∧ + P.2 (commonTimes ℓ P (n+1)).2 = + P.2 (commonTimes ℓ P n).2 + wordPath 0 (commonWords ℓ P n).2 (commonWords ℓ P n).2.length := by + have he := iterate_renewPairSuffix_eq ℓ P h0 h0' n + have h1 := (hP n).2.1.1 _ le_rfl + have h2 := (hP n).2.1.2 _ le_rfl + rw [he] at h1 h2 + rw [commonTimes_succ] + constructor + · exact (sub_eq_iff_eq_add.mp h1).trans (add_comm _ _) + · exact (sub_eq_iff_eq_add.mp h2).trans (add_comm _ _) + +lemma common_coordinate_sum {d : ℕ} (ℓ : Vector d) (e : Direction d) (P : Path d × Path d) + (h0 : P.1 0 = 0) (h0' : P.2 0 = 0) + (hP : ∀ n, ((renewPairSuffix ℓ)^[n] P) ∈ FirstPairWordEvent ℓ (commonWords ℓ P n)) + (n : ℕ) : + signedCoordinate e (P.1 (commonTimes ℓ P n).1) - + signedCoordinate e (P.2 (commonTimes ℓ P n).2) = + realPartialSum (fun k => commonIncrementProcess ℓ e k P) n := by + induction n with + | zero => simp [commonTimes_zero,h0,h0',signedCoordinate,realPartialSum] + | succ n ih => + obtain ⟨h1,h2⟩ := commonTimes_span ℓ P h0 h0' hP n + rw [h1,h2,signedCoordinate_add,signedCoordinate_add,realPartialSum_succ,← ih] + simp only [commonIncrementProcess,commonWordIncrement,wordCoordinate] + ring + +lemma commonIndex_le_recordCount {d : ℕ} (ℓ : Vector d) (P : Path d × Path d) + (h0 : P.1 0 = 0) (h0' : P.2 0 = 0) + (hP : ∀ n, ((renewPairSuffix ℓ)^[n] P) ∈ FirstPairWordEvent ℓ (commonWords ℓ P n)) + (n : ℕ) : n ≤ recordCount ℓ P.1 (commonTimes ℓ P n).1 := by + rw [recordCount_commonTimes ℓ P h0 h0' hP n] + calc + n = ∑ i ∈ Finset.range n, 1 := by simp + _ ≤ ∑ i ∈ Finset.range n, wordRecordCount ℓ (commonWords ℓ P i).1 := + Finset.sum_le_sum fun i _ => commonWordWidth_positive ℓ _ _ (hP i) + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/SymmetrizedMgf.lean b/lean/OAI/Probability/Ballisticity/Estimates/SymmetrizedMgf.lean new file mode 100644 index 0000000000000000000000000000000000000000..1815b75a76516e6d5e3a4637cbf5dfe8b3f749e4 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/SymmetrizedMgf.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.DifferentiableExp + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma symmetrized_mgf (μ : Measure ℝ) [IsProbabilityMeasure μ] (t : ℝ) : + mgf (fun p : ℝ × ℝ => p.1-p.2) (μ.prod μ) t = mgf id μ t*mgf id μ (-t) := by + simp only [mgf,mul_sub,Real.exp_sub,Real.exp_neg,neg_mul,id_eq,div_eq_mul_inv] + exact integral_prod_mul (fun x : ℝ => Real.exp (t*x)) (fun y : ℝ => (Real.exp (t*y))⁻¹) + +lemma symmetrized_complexMGF (μ : Measure ℝ) [IsProbabilityMeasure μ] (z : ℂ) : + complexMGF (fun p : ℝ × ℝ => p.1-p.2) (μ.prod μ) z = + complexMGF id μ z*complexMGF id μ (-z) := by + simp only [complexMGF,Complex.ofReal_sub,mul_sub,Complex.exp_sub,Complex.exp_neg,neg_mul, + id_eq,div_eq_mul_inv] + exact integral_prod_mul (fun x : ℝ => Complex.exp (z*x)) (fun y : ℝ => (Complex.exp (z*y))⁻¹) + +lemma iid_difference_gaussian_mgf_product (μ : Measure ℝ) [IsProbabilityMeasure μ] + (v : ℝ≥0) (hv : (μ.prod μ).map (fun p : ℝ × ℝ => p.1-p.2) = gaussianReal 0 v) (t : ℝ) : + mgf id μ t*mgf id μ (-t) = Real.exp (v*t^2/2) := by + rw [← symmetrized_mgf,mgf_gaussianReal ⟨by fun_prop, hv⟩] + simp + +lemma iid_difference_gaussian_integrableExpSet (μ : Measure ℝ) [IsProbabilityMeasure μ] + (v : ℝ≥0) (hv : (μ.prod μ).map (fun p : ℝ × ℝ => p.1-p.2) = gaussianReal 0 v) : + integrableExpSet id μ = Set.univ := by + ext t + simp only [Set.mem_univ,iff_true,integrableExpSet,Set.mem_ofPred_eq] + apply mgf_pos_iff.mp + have h := iid_difference_gaussian_mgf_product μ v hv t + have hh : 0 < mgf id μ t*mgf id μ (-t) := by rw [h]; exact Real.exp_pos _ + exact pos_of_mul_pos_left hh mgf_nonneg + +lemma exp_mean_le_mgf (μ : Measure ℝ) [IsProbabilityMeasure μ] + (hμ : integrableExpSet id μ = Set.univ) (t : ℝ) : + Real.exp (t*∫ x, x ∂μ) ≤ mgf id μ t := by + have hi : Integrable id μ := integrable_of_mem_interior_integrableExpSet (by simp [hμ]) + have he : Integrable (fun x : ℝ => Real.exp (t*x)) μ := by + have h : t ∈ integrableExpSet id μ := by rw [hμ]; trivial + exact h + have h := convexOn_exp.map_integral_le Real.continuous_exp.continuousOn isClosed_univ + (Eventually.of_forall fun x : ℝ => Set.mem_univ (t*x)) (hi.const_mul t) he + convert! h using 1 + congr 1 + exact (integral_const_mul t (id : ℝ → ℝ)).symm + +lemma iid_difference_gaussian_mgf_bound (μ : Measure ℝ) [IsProbabilityMeasure μ] + (v : ℝ≥0) (hv : (μ.prod μ).map (fun p : ℝ × ℝ => p.1-p.2) = gaussianReal 0 v) + (t : ℝ) : mgf id μ t ≤ Real.exp (t*(∫ x, x ∂μ)+v*t^2/2) := by + have h := exp_mean_le_mgf μ (iid_difference_gaussian_integrableExpSet μ v hv) (-t) + have hp := iid_difference_gaussian_mgf_product μ v hv t + have hb := mul_le_mul_of_nonneg_left h (mgf_nonneg (X := id) (μ := μ) (t := t)) + rw [hp] at hb + have he : Real.exp (t*(∫ x,x ∂μ)+v*t^2/2)*Real.exp (-t*(∫ x,x ∂μ)) = + Real.exp (v*t^2/2) := by rw [← Real.exp_add]; congr 1; ring + rw [← he] at hb + exact (mul_le_mul_iff_left₀ (Real.exp_pos _)).mp hb + +theorem iid_difference_gaussian (μ : Measure ℝ) [IsProbabilityMeasure μ] + (v : ℝ≥0) (hv : (μ.prod μ).map (fun p : ℝ × ℝ => p.1-p.2) = gaussianReal 0 v) : + μ = gaussianReal (∫ x, x ∂μ) (v/2) := by + have hset := iid_difference_gaussian_integrableExpSet μ v hv + have hz (z : ℂ) : z.re ∈ interior (integrableExpSet id μ) := by simp [hset] + have hf : Differentiable ℂ (complexMGF id μ) := + fun z => (hasDerivAt_complexMGF (hz z)).differentiableAt + have h0 : complexMGF id μ 0 = 1 := by simp [complexMGF] + have hp (z : ℂ) : complexMGF id μ z*complexMGF id μ (-z) = + Complex.exp ((v:ℂ)/2*z^2) := by + rw [← symmetrized_complexMGF,complexMGF_gaussianReal ⟨by fun_prop, hv⟩] + congr 1 + simp only [Complex.ofReal_zero,mul_zero,zero_add] + ring + let m := ∫ x, x ∂μ + let C := |m|+(v:ℝ)+1 + have hC : 0 < C := by dsimp [C]; positivity + have hb (z : ℂ) : ‖complexMGF id μ z‖ ≤ Real.exp (C*(1+‖z‖^2)) := by + refine norm_complexMGF_le_mgf.trans ((iid_difference_gaussian_mgf_bound μ v hv z.re).trans ?_) + apply Real.exp_le_exp.mpr + have hm : z.re*m ≤ |m| *‖z‖ := by + calc z.re*m ≤ |z.re*m| := le_abs_self _ + _ = |m| *|z.re| := by rw [abs_mul]; ring + _ ≤ |m| *‖z‖ := mul_le_mul_of_nonneg_left (Complex.abs_re_le_norm z) (abs_nonneg m) + have hs : z.re^2 ≤ ‖z‖^2 := by + simpa only [sq_abs] using pow_le_pow_left₀ (abs_nonneg z.re) (Complex.abs_re_le_norm z) 2 + have ht : ‖z‖ ≤ 1+‖z‖^2 := by nlinarith [sq_nonneg (‖z‖-1)] + have hmv := mul_le_mul_of_nonneg_left ht (abs_nonneg m) + have hvz := mul_le_mul_of_nonneg_left hs v.2 + have hv0 := mul_nonneg v.2 (sq_nonneg ‖z‖) + dsimp [C,m] at * + nlinarith [norm_nonneg z,abs_nonneg (∫ x,x ∂μ)] + have hfac := entire_gaussian_factor hf h0 ((v:ℂ)/2) hp hC hb + have hd : deriv (complexMGF id μ) 0 = (∫ x, x ∂μ : ℝ) := by + calc + _ = ∫ x : ℝ, (x : ℂ) ∂μ := by + simpa only [id_eq,zero_mul,Complex.exp_zero,mul_one] using + (hasDerivAt_complexMGF (hz 0)).deriv + _ = _ := integral_complex_ofReal + apply Measure.ext_of_complexMGF_id_eq + funext z + rw [hfac z,complexMGF_id_gaussianReal,hd] + congr 1 + push_cast + ring + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma map_iid_difference_linear {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [MeasurableSpace F] [BorelSpace F] + [SecondCountableTopology F] + (μ : Measure E) [IsProbabilityMeasure μ] (L : E →L[ℝ] F) : + ((μ.map L).prod (μ.map L)).map (fun p : F × F => p.1-p.2) = + ((μ.prod μ).map (fun p : E × E => p.1-p.2)).map L := by + rw [Measure.map_prod_map μ μ L.measurable L.measurable, + Measure.map_map (show Measurable (fun p : F × F => p.1-p.2) by fun_prop) + (L.measurable.prodMap L.measurable), + Measure.map_map L.measurable (show Measurable (fun p : E × E => p.1-p.2) by fun_prop)] + congr 1 + funext p + exact (L.map_sub p.1 p.2).symm + +theorem iid_difference_isGaussian {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] [CompleteSpace E] + (μ ν : Measure E) [IsProbabilityMeasure μ] [IsGaussian ν] + (hmean : ∫ x, x ∂ν = 0) + (hv : (μ.prod μ).map (fun p : E × E => p.1-p.2) = ν) : IsGaussian μ := by + apply isGaussian_of_map_eq_gaussianReal + intro L + have hn : ν.map L = gaussianReal 0 (Var[L; ν]).toNNReal := by + rw [IsGaussian.map_eq_gaussianReal,IsGaussian.integral_dual,hmean,map_zero] + have hd : ((μ.map L).prod (μ.map L)).map (fun p : ℝ × ℝ => p.1-p.2) = + gaussianReal 0 (Var[L; ν]).toNNReal := by + rw [map_iid_difference_linear,hv,hn] + exact ⟨∫ x, x ∂μ.map L,(Var[L; ν]).toNNReal/2,iid_difference_gaussian _ _ hd⟩ + +lemma iid_difference_gaussian_centered_linear {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + [CompleteSpace E] (μ ν : Measure E) [IsProbabilityMeasure μ] [IsGaussian ν] + (hmean : ∫ x, x ∂ν = 0) + (hv : (μ.prod μ).map (fun p : E × E => p.1-p.2) = ν) (L : E →L[ℝ] ℝ) : + μ.map (fun x => L (x-∫ y, y ∂μ)) = gaussianReal 0 ((Var[L; ν]).toNNReal/2) := by + have : IsGaussian μ := iid_difference_isGaussian μ ν hmean hv + have hn : ν.map L = gaussianReal 0 (Var[L; ν]).toNNReal := by + rw [IsGaussian.map_eq_gaussianReal,IsGaussian.integral_dual,hmean,map_zero] + have hd : ((μ.map L).prod (μ.map L)).map (fun p : ℝ × ℝ => p.1-p.2) = + gaussianReal 0 (Var[L; ν]).toNNReal := by rw [map_iid_difference_linear,hv,hn] + have hg := iid_difference_gaussian (μ.map L) _ hd + have hi : (∫ x, x ∂μ.map L) = L (∫ x, x ∂μ) := by + rw [integral_map L.measurable.aemeasurable + (show AEStronglyMeasurable (fun x : ℝ => x) (μ.map L) from measurable_id.aestronglyMeasurable)] + exact IsGaussian.integral_dual L + have he : (fun x => L (x-∫ y, y ∂μ)) = (fun x : ℝ => x-L (∫ y, y ∂μ)) ∘ L := by + funext x; simp + rw [he,← Measure.map_map (by fun_prop) L.measurable,hg,hi] + simpa only [sub_self] using (gaussianReal_map_sub_const (μ := L (∫ y, y ∂μ)) + (v := (Var[L; ν]).toNNReal/2) (L (∫ y, y ∂μ))) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TailProfile.lean b/lean/OAI/Probability/Ballisticity/Estimates/TailProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c580954f3be93a5acc28e28258e7fd2e87821c0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TailProfile.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.ProfileGrowth2 + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace TailSampling + +variable {D X : Type*} [MeasurableSpace D] [MeasurableSpace X] + [MeasurableSingletonClass X] + +theorem measurable_profile_cuts (w : Kernel D X) [IsFiniteKernel w] + (ξ : X → ℤ) (hξ : Measurable ξ) (hsurj : Function.Surjective ξ) + (hfull : ∀ d x, 0 < (w d).real {x}) : + ∃ j : ℕ → D → ℤ, (∀ r, Measurable (j r)) ∧ + (∀ d (r : ℕ) (k : ℤ), TailCuts.score (TailCuts.lower ((w d).map ξ)) + (TailCuts.upper ((w d).map ξ)) (r : ℤ) k ≤ + TailCuts.score (TailCuts.lower ((w d).map ξ)) + (TailCuts.upper ((w d).map ξ)) (r : ℤ) (j r d)) ∧ + (∀ d, Tendsto (fun r => j r d) atTop atBot ∧ + Tendsto (fun r => j r d + (r : ℤ)) atTop atTop) := by + have hpos : ∀ d z, 0 < ((w d).map ξ).real {z} := + fun d => coordinate_atom_pos (w d) ξ hξ hsurj (hfull d) + have hL : ∀ n, Measurable (fun d => TailCuts.lower ((w d).map ξ) n) := by + intro n + have hh := ((w.map ξ).measurable_coe (s := Set.Iic n) measurableSet_Iic).ennreal_toReal + simpa only [TailCuts.lower, Measure.real, Kernel.map_apply _ hξ] using hh + have hU : ∀ n, Measurable (fun d => TailCuts.upper ((w d).map ξ) n) := by + intro n + have hh := ((w.map ξ).measurable_coe (s := Set.Ici n) measurableSet_Ici).ennreal_toReal + simpa only [TailCuts.upper, Measure.real, Kernel.map_apply _ hξ] using hh + have hex : ∀ r : ℕ, ∃ j : D → ℤ, Measurable j ∧ + ∀ d k, TailCuts.score (TailCuts.lower ((w d).map ξ)) + (TailCuts.upper ((w d).map ξ)) (r : ℤ) k ≤ + TailCuts.score (TailCuts.lower ((w d).map ξ)) + (TailCuts.upper ((w d).map ξ)) (r : ℤ) (j d) := by + intro r + exact TailCuts.measurable_maximizing_cut _ _ (r : ℤ) hL hU + (fun d => (TailCuts.finite_profile_cuts_escape ((w d).map ξ) (hpos d)).1 _) + choose j hj hmax using hex + refine ⟨j,hj,fun d r => hmax r d,fun d => ?_⟩ + exact (TailCuts.finite_profile_cuts_escape ((w d).map ξ) (hpos d)).2 + (fun r => j r d) (fun r k => hmax r d k) + +noncomputable def lowerKernel (w : Kernel D X) (ξ : X → ℤ) (hξ : Measurable ξ) + (j : D → ℤ) (hj : Measurable j) : Kernel D X := + cutKernel w (fun n => ξ ⁻¹' Set.Iic n) (fun _ => hξ measurableSet_Iic) j hj + +noncomputable def upperKernel (w : Kernel D X) (ξ : X → ℤ) (hξ : Measurable ξ) + (j : D → ℤ) (hj : Measurable j) : Kernel D X := + cutKernel w (fun n => ξ ⁻¹' Set.Ici n) (fun _ => hξ measurableSet_Ici) j hj + +lemma lowerKernel_markov (w : Kernel D X) [IsFiniteKernel w] + (ξ : X → ℤ) (hξ : Measurable ξ) (hsurj : Function.Surjective ξ) + (hfull : ∀ d x, 0 < (w d).real {x}) (j : D → ℤ) (hj : Measurable j) : + IsMarkovKernel (lowerKernel w ξ hξ j hj) := by + apply cutKernel_markov + · intro d + have ht := TailCuts.lower_pos ((w d).map ξ) + (coordinate_atom_pos (w d) ξ hξ hsurj (hfull d)) (j d) + rw [TailCuts.lower, Measure.real, Measure.map_apply hξ measurableSet_Iic] at ht + exact (ENNReal.toReal_pos_iff.mp ht).1.ne' + · exact fun d => measure_ne_top _ _ + +lemma upperKernel_markov (w : Kernel D X) [IsFiniteKernel w] + (ξ : X → ℤ) (hξ : Measurable ξ) (hsurj : Function.Surjective ξ) + (hfull : ∀ d x, 0 < (w d).real {x}) (j : D → ℤ) (hj : Measurable j) : + IsMarkovKernel (upperKernel w ξ hξ j hj) := by + apply cutKernel_markov + · intro d + have ht := TailCuts.upper_pos ((w d).map ξ) + (coordinate_atom_pos (w d) ξ hξ hsurj (hfull d)) (j d) + rw [TailCuts.upper, Measure.real, Measure.map_apply hξ measurableSet_Ici] at ht + exact (ENNReal.toReal_pos_iff.mp ht).1.ne' + · exact fun d => measure_ne_top _ _ + +omit [MeasurableSingletonClass X] in +lemma lowerKernel_supported [MeasurableSingletonClass X] + (w : Kernel D X) (ξ : X → ℤ) (hξ : Measurable ξ) + (j : D → ℤ) (hj : Measurable j) (d : D) : + ∀ᵐ x ∂lowerKernel w ξ hξ j hj d, ξ x ≤ j d := + cutKernel_supported _ _ _ _ _ _ + +omit [MeasurableSingletonClass X] in +lemma upperKernel_supported [MeasurableSingletonClass X] + (w : Kernel D X) (ξ : X → ℤ) (hξ : Measurable ξ) + (j : D → ℤ) (hj : Measurable j) (d : D) : + ∀ᵐ x ∂upperKernel w ξ hξ j hj d, j d ≤ ξ x := + cutKernel_supported _ _ _ _ _ _ + +end TailSampling + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +abbrev ZeroHeightPair {d : ℕ} (e : Direction d) := + {p : Lattice d × Lattice d // p ∈ PairAtHeight (realPosition (step e)) 0} + +def horizontalPair {d : ℕ} (e : Direction d) + (p : HorizontalLayer e × HorizontalLayer e) : ZeroHeightPair e := + ⟨(p.1.1,p.2.1), by + simp only [PairAtHeight, Set.mem_ofPred, dot_signed_direction, signedCoordinate, + p.1.2, p.2.2, Int.cast_zero, neg_zero, ite_self, and_self]⟩ + +noncomputable def profilePairKernel {d : ℕ} (e : Direction d) (f : Fin d) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) + (R : ℤ) (j : D → ℤ) (hj : Measurable j) : Kernel D (ZeroHeightPair e) := + ((TailSampling.lowerKernel w (fun x => x.1 f) (measurable_of_countable _) j hj).prod + (TailSampling.upperKernel w (fun x => x.1 f) (measurable_of_countable _) + (fun z => j z+R) (hj.add_const R))).map (horizontalPair e) + +lemma profilePairKernel_markov {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1 ≠ f) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] + (hfull : ∀ z x, 0 < (w z).real {x}) (R : ℤ) (j : D → ℤ) (hj : Measurable j) : + IsMarkovKernel (profilePairKernel e f w R j hj) := by + have := TailSampling.lowerKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull j hj + have := TailSampling.upperKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull (fun z => j z+R) (hj.add_const R) + unfold profilePairKernel + exact Kernel.IsMarkovKernel.map _ (measurable_of_countable _) + +lemma profilePairKernel_supported {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1 ≠ f) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] + (hfull : ∀ z x, 0 < (w z).real {x}) (R : ℤ) (j : D → ℤ) (hj : Measurable j) (z : D) : + ∀ᵐ p ∂profilePairKernel e f w R j hj z, + p.1.1 f ≤ j z ∧ j z+R ≤ p.1.2 f := by + have := TailSampling.lowerKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull j hj + have := TailSampling.upperKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull (fun z => j z+R) (hj.add_const R) + rw [profilePairKernel, Kernel.map_apply _ (measurable_of_countable _), Kernel.prod_apply] + apply (ae_map_iff (measurable_of_countable _).aemeasurable + ((Set.to_countable _).measurableSet)).mpr + apply (Measure.ae_prod_iff_ae_ae ((Set.to_countable _).measurableSet)).mpr + filter_upwards [TailSampling.lowerKernel_supported w (fun x => x.1 f) + (measurable_of_countable _) j hj z] with x hx + filter_upwards [TailSampling.upperKernel_supported w (fun x => x.1 f) + (measurable_of_countable _) (fun z => j z+R) (hj.add_const R) z] with y hy + exact ⟨hx,hy⟩ + +lemma profilePairKernel_integral {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1 ≠ f) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] + (hfull : ∀ z x, 0 < (w z).real {x}) (R : ℤ) (j : D → ℤ) (hj : Measurable j) (z : D) (F : ZeroHeightPair e → ℝ) : + (∫ p, F p ∂profilePairKernel e f w R j hj z) = + ∫ p : HorizontalLayer e × HorizontalLayer e, F (horizontalPair e p) + ∂((TailGrowth.normalizedRestriction (w z) {x | x.1 f ≤ j z}).prod + (TailGrowth.normalizedRestriction (w z) {x | j z+R ≤ x.1 f})) := by + have := TailSampling.lowerKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull j hj + have := TailSampling.upperKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull (fun z => j z+R) (hj.add_const R) + rw [profilePairKernel, Kernel.map_apply _ (measurable_of_countable _), + integral_map (measurable_of_countable _).aemeasurable (measurable_of_countable _).aestronglyMeasurable, + Kernel.prod_apply] + rfl + +lemma profilePairKernel_integrable {d : ℕ} (e : Direction d) (f : Fin d) (hef : e.1 ≠ f) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] + (hfull : ∀ z x, 0 < (w z).real {x}) (R : ℤ) (j : D → ℤ) (hj : Measurable j) (z : D) + (F : ZeroHeightPair e → ℝ) : + Integrable F (profilePairKernel e f w R j hj z) ↔ + Integrable (fun p : HorizontalLayer e × HorizontalLayer e => F (horizontalPair e p)) + ((TailGrowth.normalizedRestriction (w z) {x | x.1 f ≤ j z}).prod + (TailGrowth.normalizedRestriction (w z) {x | j z+R ≤ x.1 f})) := by + have := TailSampling.lowerKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull j hj + have := TailSampling.upperKernel_markov w (fun x => x.1 f) (measurable_of_countable _) + (horizontal_coordinate_surjective e f hef) hfull (fun z => j z+R) (hj.add_const R) + rw [profilePairKernel, Kernel.map_apply _ (measurable_of_countable _), Kernel.prod_apply] + exact integrable_map_measure (measurable_of_countable _).aestronglyMeasurable + (measurable_of_countable _).aemeasurable + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TailSampling.lean b/lean/OAI/Probability/Ballisticity/Estimates/TailSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ef0984aa1022007e7d04118bd4636556495d04e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TailSampling.lean @@ -0,0 +1,217 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.TailGrowth + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology + +namespace TailSampling + +variable {D X : Type*} [MeasurableSpace D] [MeasurableSpace X] + +noncomputable def cutKernel (w : Kernel D X) (S : ℤ → Set X) + (hS : ∀ j, MeasurableSet (S j)) (j : D → ℤ) (hj : Measurable j) : Kernel D X where + toFun d := (w d (S (j d)))⁻¹ • (w d).restrict (S (j d)) + measurable' := by + apply Measure.measurable_of_measurable_coe + intro A hA + have h₁ : Measurable (fun p : D × ℤ => w p.1 (S p.2)) := + measurable_from_prod_countable_left fun n => w.measurable_coe (hS n) + have h₂ : Measurable (fun p : D × ℤ => w p.1 (A ∩ S p.2)) := + measurable_from_prod_countable_left fun n => w.measurable_coe (hA.inter (hS n)) + simp only [Measure.smul_apply, smul_eq_mul, Measure.restrict_apply hA] + exact (h₁.comp (measurable_id.prodMk hj)).inv.mul + (h₂.comp (measurable_id.prodMk hj)) + +lemma cutKernel_apply (w : Kernel D X) (S : ℤ → Set X) + (hS : ∀ j, MeasurableSet (S j)) (j : D → ℤ) (hj : Measurable j) (d : D) : + cutKernel w S hS j hj d = (w d (S (j d)))⁻¹ • (w d).restrict (S (j d)) := rfl + +lemma cutKernel_markov (w : Kernel D X) (S : ℤ → Set X) + (hS : ∀ j, MeasurableSet (S j)) (j : D → ℤ) (hj : Measurable j) + (hpos : ∀ d, w d (S (j d)) ≠ 0) (hfin : ∀ d, w d (S (j d)) ≠ ∞) : + IsMarkovKernel (cutKernel w S hS j hj) := by + constructor + intro d + constructor + simp only [cutKernel_apply, Measure.smul_apply, smul_eq_mul, + Measure.restrict_apply MeasurableSet.univ, Set.univ_inter] + exact ENNReal.inv_mul_cancel (hpos d) (hfin d) + +lemma cutKernel_supported (w : Kernel D X) (S : ℤ → Set X) + (hS : ∀ j, MeasurableSet (S j)) (j : D → ℤ) (hj : Measurable j) (d : D) : + ∀ᵐ x ∂cutKernel w S hS j hj d, x ∈ S (j d) := by + exact Measure.ae_smul_measure (ae_restrict_mem (hS (j d))) _ + +lemma cutKernel_mass_mul (w : Kernel D X) (S : ℤ → Set X) + (hS : ∀ j, MeasurableSet (S j)) (j : D → ℤ) (hj : Measurable j) + (d : D) (hpos : w d (S (j d)) ≠ 0) (hfin : w d (S (j d)) ≠ ∞) : + w d (S (j d)) • cutKernel w S hS j hj d = (w d).restrict (S (j d)) := by + rw [cutKernel_apply, smul_smul, ENNReal.mul_inv_cancel hpos hfin, one_smul] + +lemma coordinate_atom_pos (μ : Measure X) [IsFiniteMeasure μ] + [MeasurableSingletonClass X] (ξ : X → ℤ) (hξ : Measurable ξ) + (hsurj : Function.Surjective ξ) (hμ : ∀ x, 0 < μ.real {x}) (z : ℤ) : + 0 < (μ.map ξ).real {z} := by + obtain ⟨x,hx⟩ := hsurj z + rw [Measure.real, Measure.map_apply hξ (measurableSet_singleton z)] + apply lt_of_lt_of_le (hμ x) + apply measureReal_mono _ (measure_ne_top _ _) + intro y hy + simp only [Set.mem_singleton_iff] at hy + subst y + exact hx + +end TailSampling + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Topology + +namespace TailGrowth + +lemma log_integral_lower_of_exp {X : Type*} [MeasurableSpace X] + (μ : Measure X) [IsProbabilityMeasure μ] (Z p : X → ℝ) (a : ℝ) + (hZ : Integrable Z μ) (hZ0 : ∀ᵐ x ∂μ, 0 ≤ Z x) + (hp : Integrable p μ) (hlower : ∀ᵐ x ∂μ, Real.exp (-a - Z x) ≤ p x) : + 0 < ∫ x, p x ∂μ ∧ + -a - (∫ x, Z x ∂μ) ≤ Real.log (∫ x, p x ∂μ) := by + have hF : Integrable (fun x => -a - Z x) μ := (integrable_const (-a)).sub hZ + have hE : Integrable (fun x => Real.exp (-a - Z x)) μ := by + apply (integrable_const (Real.exp (-a))).mono' (Real.continuous_exp.comp_aestronglyMeasurable hF.aestronglyMeasurable) + filter_upwards [hZ0] with x hx + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] + exact Real.exp_le_exp.mpr (by linarith) + have hj := convexOn_exp.map_integral_le Real.continuous_exp.continuousOn + isClosed_univ (Filter.Eventually.of_forall fun _ => Set.mem_univ _) + hF hE + have hi : (∫ x, -a - Z x ∂μ) = -a - ∫ x, Z x ∂μ := by + rw [integral_sub (integrable_const _) hZ, integral_const] + simp + rw [hi] at hj + have hb := hj.trans (integral_mono_ae hE hp hlower) + have hp0 := (Real.exp_pos _).trans_le hb + refine ⟨hp0, ?_⟩ + calc + -a - (∫ x, Z x ∂μ) = Real.log (Real.exp (-a - ∫ x, Z x ∂μ)) := + (Real.log_exp _).symm + _ ≤ Real.log (∫ x, p x ∂μ) := Real.log_le_log (Real.exp_pos _) hb + +lemma log_integral_lower {X : Type*} [MeasurableSpace X] + (μ : Measure X) [IsProbabilityMeasure μ] (Z p : X → ℝ) (a : ℝ) + (hZ : Integrable Z μ) (hZ0 : ∀ᵐ x ∂μ, 0 ≤ Z x) + (hp : Integrable p μ) (hp0 : ∀ᵐ x ∂μ, 0 < p x) + (hlower : ∀ᵐ x ∂μ, -a - Z x ≤ Real.log (p x)) : + 0 < ∫ x, p x ∂μ ∧ + -a - (∫ x, Z x ∂μ) ≤ Real.log (∫ x, p x ∂μ) := by + apply log_integral_lower_of_exp μ Z p a hZ hZ0 hp + filter_upwards [hp0,hlower] with x hx h + simpa only [Real.exp_log hx] using Real.exp_le_exp.mpr h + +end TailGrowth + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology + +namespace TailGrowth + +lemma measurable_statistic {D : Type*} [MeasurableSpace D] (w : Kernel D ℤ) (R : ℤ) : + Measurable (fun d => statistic (w d) R) := by + apply Measurable.iSup + intro j + exact ((w.measurable_coe (s := Set.Iic j) measurableSet_Iic).ennreal_toReal).min + ((w.measurable_coe (s := Set.Ici (j+R)) measurableSet_Ici).ennreal_toReal) + +lemma statistic_translate (μ : Measure ℤ) (R z : ℤ) : + statistic (μ.map (fun x => x+z)) R = statistic μ R := by + unfold statistic + have he (j : ℤ) : TailCuts.score (TailCuts.lower (μ.map (fun x => x+z))) + (TailCuts.upper (μ.map (fun x => x+z))) R j = + TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R (j-z) := by + unfold TailCuts.score TailCuts.lower TailCuts.upper Measure.real + rw [Measure.map_apply (show Measurable (fun x : ℤ => x+z) from measurable_of_countable _) measurableSet_Iic, + Measure.map_apply (show Measurable (fun x : ℤ => x+z) from measurable_of_countable _) measurableSet_Ici] + congr 3 + · ext x + simp only [Set.mem_preimage, Set.mem_Iic] + omega + · ext x + simp only [Set.mem_preimage, Set.mem_Ici] + omega + simp_rw [he] + exact (show Function.Surjective (fun j : ℤ => j-z) from + fun j => ⟨j+z,by dsimp; omega⟩).iSup_comp _ + +lemma comp_mono_left {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + (κ : Kernel X Y) {μ ν : Measure X} (h : μ ≤ ν) : + κ ∘ₘ μ ≤ κ ∘ₘ ν := by + apply Measure.le_iff.mpr + intro s hs + rw [Measure.bind_apply hs κ.measurable.aemeasurable, + Measure.bind_apply hs κ.measurable.aemeasurable] + exact lintegral_mono' h le_rfl + +lemma smul_mono_scalar {X : Type*} [MeasurableSpace X] + (μ : Measure X) {a b : ℝ≥0∞} (h : a ≤ b) : a • μ ≤ b • μ := by + apply Measure.le_iff.mpr + intro s _ + simp only [Measure.smul_apply,smul_eq_mul] + exact mul_le_mul h le_rfl zero_le zero_le + +lemma normalized_tail_dominated {X : Type*} [MeasurableSpace X] + (μ : Measure X) [IsFiniteMeasure μ] (s : Set X) + (hpos : μ s ≠ 0) {t : ℝ} (ht : t ≤ μ.real s) : + ENNReal.ofReal t • ((μ s)⁻¹ • μ.restrict s) ≤ μ := by + have hh : ENNReal.ofReal t ≤ μ s := + (ENNReal.ofReal_le_iff_le_toReal (measure_ne_top _ _)).mpr ht + calc + ENNReal.ofReal t • ((μ s)⁻¹ • μ.restrict s) ≤ + μ s • ((μ s)⁻¹ • μ.restrict s) := smul_mono_scalar _ hh + _ = μ.restrict s := by + rw [smul_smul, ENNReal.mul_inv_cancel hpos (measure_ne_top _ _), one_smul] + _ ≤ μ := Measure.restrict_le_self + +lemma continued_tail_dominated {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + (κ : Kernel X Y) (w : Measure X) [IsFiniteMeasure w] (w' : Measure Y) + (s : Set X) (hpos : w s ≠ 0) {C t : ℝ} (ht : t ≤ w.real s) + (hupdate : ENNReal.ofReal (Real.exp C) • (κ ∘ₘ w) ≤ w') : + ENNReal.ofReal (Real.exp C * t) • + (κ ∘ₘ ((w s)⁻¹ • w.restrict s)) ≤ w' := by + have hh := comp_mono_left κ (normalized_tail_dominated w s hpos ht) + rw [Measure.comp_smul] at hh + have hh' := smul_le_smul_left (ENNReal.ofReal (Real.exp C)) hh + rw [smul_smul, ← ENNReal.ofReal_mul (Real.exp_pos C).le] at hh' + exact hh'.trans hupdate + +lemma stream_real_lower {X : Type*} [MeasurableSpace X] + (μ w' : Measure X) [IsFiniteMeasure w'] {t : ℝ} (ht : 0 ≤ t) + (h : ENNReal.ofReal t • μ ≤ w') (s : Set X) : t * μ.real s ≤ w'.real s := by + have hh := ENNReal.toReal_mono (measure_ne_top w' s) (h s) + simpa only [Measure.real,Measure.smul_apply,smul_eq_mul,ENNReal.toReal_mul, + ENNReal.toReal_ofReal ht] using hh + +lemma prod_comp {X X' Y Y' : Type*} + [MeasurableSpace X] [MeasurableSpace X'] [MeasurableSpace Y] [MeasurableSpace Y'] + (κ : Kernel X Y) (η : Kernel X' Y') [IsSFiniteKernel κ] [IsSFiniteKernel η] + (μ : Measure X) (ν : Measure X') [SFinite μ] [SFinite ν] : + (κ ∘ₘ μ).prod (η ∘ₘ ν) = (κ ∥ₖ η) ∘ₘ (μ.prod ν) := by + have hh := congrArg (fun K : Kernel (Unit × Unit) (Y × Y') => K ((),())) + (Kernel.parallelComp_comp_parallelComp + (κ := Kernel.const Unit μ) (κ' := Kernel.const Unit ν) (η := κ) (η' := η)) + simpa only [Kernel.comp_apply,Kernel.parallelComp_apply,Kernel.const_apply] using hh.symm + +end TailGrowth + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TightIidDifferenceTranslations.lean b/lean/OAI/Probability/Ballisticity/Estimates/TightIidDifferenceTranslations.lean new file mode 100644 index 0000000000000000000000000000000000000000..9add087a48e82d5527e7b57c1f1dbe46da193690 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TightIidDifferenceTranslations.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +namespace DirectionalTransience + +theorem tight_iid_difference_translations {E ι : Type*} [NormedAddCommGroup E] + [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + (μ : ι → Measure E) [∀ i, IsProbabilityMeasure (μ i)] + (ht : IsTightMeasureSet (Set.range fun i => + ((μ i).prod (μ i)).map (fun p : E × E => p.1-p.2))) : + ∃ c : ι → E, IsTightMeasureSet (Set.range fun i => (μ i).map (fun x => x-c i)) := by + obtain ⟨C,hC,hbound⟩ := isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mp ht + (1/4) (by norm_num) + have hdiff : Measurable (fun p : E × E => p.1-p.2) := measurable_fst.sub measurable_snd + have hex (i : ι) : ∃ c : E, (μ i) {x | x-c ∉ C} ≤ 1/2 := by + have h := hbound _ ⟨i,rfl⟩ + rw [Measure.map_apply hdiff hC.measurableSet.compl, + Measure.prod_apply_symm (hdiff hC.measurableSet.compl)] at h + by_contra hn + push Not at hn + have hh : (1/2 : ℝ≥0∞) ≤ ∫⁻ y, (μ i) {x | x-y ∉ C} ∂μ i := by + calc _ = ∫⁻ y : E, (1/2 : ℝ≥0∞) ∂μ i := by simp + _ ≤ _ := lintegral_mono fun y => (hn y).le + have : (1/2 : ℝ≥0∞) ≤ 1/4 := hh.trans h + norm_num at this + choose c hc using hex + refine ⟨c,isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mpr ?_⟩ + intro ε hε + obtain ⟨K,hK,hKb⟩ := isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mp ht + (ε/2) (ENNReal.div_pos hε.ne' (by norm_num)) + refine ⟨K+C,hK.add hC,?_⟩ + rintro _ ⟨i,rfl⟩ + let A := {x : E | x-c i ∉ K+C} + let B := {y : E | y-c i ∈ C} + have hb : (1/2 : ℝ≥0∞) ≤ μ i B := by + have hc' : μ i Bᶜ ≤ 1/2 := hc i + have hBm : MeasurableSet B := hC.measurableSet.preimage (measurable_id.sub_const _) + rw [measure_compl hBm (measure_ne_top _ _),measure_univ] at hc' + have hh := (tsub_le_iff_right.mp hc') + apply ENNReal.le_of_add_le_add_left (by norm_num : (1/2 : ℝ≥0∞) ≠ ∞) + convert hh using 1 + exact ENNReal.add_halves 1 + have hAB : A ×ˢ B ⊆ (fun p : E × E => p.1-p.2) ⁻¹' Kᶜ := by + rintro ⟨x,y⟩ ⟨hx,hy⟩ hxy + apply hx + have he : x-c i = (x-y)+(y-c i) := by abel + rw [he] + exact Set.add_mem_add hxy hy + have hp : μ i A * μ i B ≤ ε/2 := by + calc _ = (μ i).prod (μ i) (A ×ˢ B) := (Measure.prod_prod _ _).symm + _ ≤ (μ i).prod (μ i) ((fun p : E × E => p.1-p.2) ⁻¹' Kᶜ) := measure_mono hAB + _ = ((μ i).prod (μ i)).map (fun p : E × E => p.1-p.2) Kᶜ := + (Measure.map_apply hdiff hK.measurableSet.compl).symm + _ ≤ ε/2 := hKb _ ⟨i,rfl⟩ + change ((μ i).map (fun x => x-c i)) (K+C)ᶜ ≤ ε + rw [Measure.map_apply (show Measurable (fun x : E => x-c i) by fun_prop) (hK.add hC).measurableSet.compl] + change μ i A ≤ ε + have hhalf : μ i A / 2 ≤ ε/2 := by + calc _ = μ i A * (1/2) := by simp [div_eq_mul_inv] + _ ≤ μ i A * μ i B := by gcongr + _ ≤ ε/2 := hp + calc _ = (μ i A / 2)*2 := (ENNReal.div_mul_cancel (by norm_num) (by norm_num)).symm + _ ≤ (ε/2)*2 := by gcongr + _ = ε := ENNReal.div_mul_cancel (by norm_num) (by norm_num) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +namespace DirectionalTransience + +theorem tight_iid_difference_translations_support {E ι : Type*} [NormedAddCommGroup E] + [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + (μ : ι → Measure E) [∀ i, IsProbabilityMeasure (μ i)] + (S : ι → Set E) (hS : ∀ i, ∀ᵐ x ∂μ i, x ∈ S i) + (ht : IsTightMeasureSet (Set.range fun i => + ((μ i).prod (μ i)).map (fun p : E × E => p.1-p.2))) : + ∃ c : ι → E, (∀ i, c i ∈ S i) ∧ IsTightMeasureSet (Set.range fun i => (μ i).map (fun x => x-c i)) := by + obtain ⟨C,hC,hbound⟩ := isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mp ht + (1/4) (by norm_num) + have hdiff : Measurable (fun p : E × E => p.1-p.2) := measurable_fst.sub measurable_snd + have hex (i : ι) : ∃ c : E, c ∈ S i ∧ (μ i) {x | x-c ∉ C} ≤ 1/2 := by + have h := hbound _ ⟨i,rfl⟩ + rw [Measure.map_apply hdiff hC.measurableSet.compl, + Measure.prod_apply_symm (hdiff hC.measurableSet.compl)] at h + by_contra hn + push Not at hn + have hh : (1/2 : ℝ≥0∞) ≤ ∫⁻ y, (μ i) {x | x-y ∉ C} ∂μ i := by + calc _ = ∫⁻ y : E, (1/2 : ℝ≥0∞) ∂μ i := by simp + _ ≤ _ := lintegral_mono_ae ((hS i).mono fun y hy => (hn y hy).le) + have : (1/2 : ℝ≥0∞) ≤ 1/4 := hh.trans h + norm_num at this + choose c hcs hc using hex + refine ⟨c,hcs,isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mpr ?_⟩ + intro ε hε + obtain ⟨K,hK,hKb⟩ := isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mp ht + (ε/2) (ENNReal.div_pos hε.ne' (by norm_num)) + refine ⟨K+C,hK.add hC,?_⟩ + rintro _ ⟨i,rfl⟩ + let A := {x : E | x-c i ∉ K+C} + let B := {y : E | y-c i ∈ C} + have hb : (1/2 : ℝ≥0∞) ≤ μ i B := by + have hc' : μ i Bᶜ ≤ 1/2 := hc i + have hBm : MeasurableSet B := hC.measurableSet.preimage (measurable_id.sub_const _) + rw [measure_compl hBm (measure_ne_top _ _),measure_univ] at hc' + have hh := (tsub_le_iff_right.mp hc') + apply ENNReal.le_of_add_le_add_left (by norm_num : (1/2 : ℝ≥0∞) ≠ ∞) + convert hh using 1 + exact ENNReal.add_halves 1 + have hAB : A ×ˢ B ⊆ (fun p : E × E => p.1-p.2) ⁻¹' Kᶜ := by + rintro ⟨x,y⟩ ⟨hx,hy⟩ hxy + apply hx + have he : x-c i = (x-y)+(y-c i) := by abel + rw [he] + exact Set.add_mem_add hxy hy + have hp : μ i A * μ i B ≤ ε/2 := by + calc _ = (μ i).prod (μ i) (A ×ˢ B) := (Measure.prod_prod _ _).symm + _ ≤ (μ i).prod (μ i) ((fun p : E × E => p.1-p.2) ⁻¹' Kᶜ) := measure_mono hAB + _ = ((μ i).prod (μ i)).map (fun p : E × E => p.1-p.2) Kᶜ := + (Measure.map_apply hdiff hK.measurableSet.compl).symm + _ ≤ ε/2 := hKb _ ⟨i,rfl⟩ + change ((μ i).map (fun x => x-c i)) (K+C)ᶜ ≤ ε + rw [Measure.map_apply (show Measurable (fun x : E => x-c i) by fun_prop) (hK.add hC).measurableSet.compl] + change μ i A ≤ ε + have hhalf : μ i A / 2 ≤ ε/2 := by + calc _ = μ i A * (1/2) := by simp [div_eq_mul_inv] + _ ≤ μ i A * μ i B := by gcongr + _ ≤ ε/2 := hp + calc _ = (μ i A / 2)*2 := (ENNReal.div_mul_cancel (by norm_num) (by norm_num)).symm + _ ≤ (ε/2)*2 := by gcongr + _ = ε := ENNReal.div_mul_cancel (by norm_num) (by norm_num) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TripleTestPerturbation.lean b/lean/OAI/Probability/Ballisticity/Estimates/TripleTestPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..05e432f1e8c3ce86a6c09a35360d6652bc70af50 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TripleTestPerturbation.lean @@ -0,0 +1,111 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BoundaryGapReplacement + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma weighted_three_test_perturbation {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (X Y : Fin 3 → ℕ → Ω → ℝ) + (hX : ∀ j i, Measurable (X j i)) (hY : ∀ j i, Measurable (Y j i)) + (F : ℕ → Ω → ℝ) (hF : ∀ i, Measurable (F i)) (C : ℝ) (hC : 0≤C) + (hFb : ∀ i ω, ‖F i ω‖≤C) (f : Fin 3 → ℝ →ᵇ ℝ) (hf : ∀ j, UniformContinuous (f j)) + (hc : ∀ j ε, 0<ε → Tendsto (fun i => (μ i).real {ω | ε≤|X j i ω-Y j i ω|}) atTop (𝓝 0)) : + Tendsto (fun i => ∫ ω, F i ω*(f 0 (X 0 i ω)*f 1 (X 1 i ω)*f 2 (X 2 i ω)- + f 0 (Y 0 i ω)*f 1 (Y 1 i ω)*f 2 (Y 2 i ω)) ∂μ i) atTop (𝓝 0) := by + have h1 := weighted_product_test_perturbation μ (X 0) (Y 0) (X 1) (Y 1) + (hX 0) (hY 0) (hX 1) (hY 1) (fun i ω => F i ω*f 2 (X 2 i ω)) + (fun i => (hF i).mul ((f 2).continuous.measurable.comp (hX 2 i))) + (C*‖f 2‖) (by positivity) (fun i ω => by + rw [norm_mul] + exact mul_le_mul (hFb i ω) ((f 2).norm_coe_le_norm _) (norm_nonneg _) hC) + (f 0) (f 1) (hf 0) (hf 1) (hc 0) (hc 1) + have h2 := weighted_test_perturbation μ (X 2) (Y 2) (hX 2) (hY 2) + (fun i ω => F i ω*(f 0 (Y 0 i ω)*f 1 (Y 1 i ω))) + (fun i => (hF i).mul (((f 0).continuous.measurable.comp (hY 0 i)).mul + ((f 1).continuous.measurable.comp (hY 1 i)))) + (C*(‖f 0‖*‖f 1‖)) (by positivity) (fun i ω => by + simp only [norm_mul] + exact mul_le_mul (hFb i ω) (mul_le_mul ((f 0).norm_coe_le_norm _) + ((f 1).norm_coe_le_norm _) (norm_nonneg _) (norm_nonneg _)) (by positivity) hC) + (f 2) (hf 2) (hc 2) + have hA (i) : Integrable (fun ω => F i ω*f 2 (X 2 i ω)* + (f 0 (X 0 i ω)*f 1 (X 1 i ω)-f 0 (Y 0 i ω)*f 1 (Y 1 i ω))) (μ i) := by + apply Integrable.of_bound (((hF i).mul ((f 2).continuous.measurable.comp (hX 2 i))).mul + ((((f 0).continuous.measurable.comp (hX 0 i)).mul ((f 1).continuous.measurable.comp (hX 1 i))).sub + (((f 0).continuous.measurable.comp (hY 0 i)).mul ((f 1).continuous.measurable.comp (hY 1 i))))).aestronglyMeasurable + ((C*‖f 2‖)*(2*(‖f 0‖*‖f 1‖))) + apply ae_of_all + intro ω + change ‖F i ω*f 2 (X 2 i ω)*(f 0 (X 0 i ω)*f 1 (X 1 i ω)-f 0 (Y 0 i ω)*f 1 (Y 1 i ω))‖ ≤ _ + rw [norm_mul] + apply mul_le_mul _ _ (norm_nonneg _) (by positivity) + · rw [norm_mul]; exact mul_le_mul (hFb i ω) ((f 2).norm_coe_le_norm _) (norm_nonneg _) hC + · apply (norm_sub_le _ _).trans + simp only [norm_mul] + have hb (Z : Fin 3 → ℕ → Ω → ℝ) := mul_le_mul ((f 0).norm_coe_le_norm (Z 0 i ω)) + ((f 1).norm_coe_le_norm (Z 1 i ω)) (norm_nonneg _) (norm_nonneg _) + linarith [hb X,hb Y] + have hB (i) : Integrable (fun ω => F i ω*(f 0 (Y 0 i ω)*f 1 (Y 1 i ω))* + (f 2 (X 2 i ω)-f 2 (Y 2 i ω))) (μ i) := by + apply Integrable.of_bound (((hF i).mul (((f 0).continuous.measurable.comp (hY 0 i)).mul + ((f 1).continuous.measurable.comp (hY 1 i)))).mul + (((f 2).continuous.measurable.comp (hX 2 i)).sub ((f 2).continuous.measurable.comp (hY 2 i)))).aestronglyMeasurable + ((C*(‖f 0‖*‖f 1‖))*(2*‖f 2‖)) + apply ae_of_all + intro ω + change ‖F i ω*(f 0 (Y 0 i ω)*f 1 (Y 1 i ω))*(f 2 (X 2 i ω)-f 2 (Y 2 i ω))‖ ≤ _ + rw [norm_mul] + apply mul_le_mul _ _ (norm_nonneg _) (by positivity) + · simp only [norm_mul] + exact mul_le_mul (hFb i ω) (mul_le_mul ((f 0).norm_coe_le_norm _) + ((f 1).norm_coe_le_norm _) (norm_nonneg _) (norm_nonneg _)) (by positivity) hC + · exact (norm_sub_le _ _).trans (by + linarith [(f 2).norm_coe_le_norm (X 2 i ω), (f 2).norm_coe_le_norm (Y 2 i ω)]) + have hs := h1.add h2 + simp only [add_zero] at hs + apply hs.congr + intro i + rw [← integral_add (hA i) (hB i)] + congr 1 + funext ω + ring + +end DirectionalTransience + +end + +section + +open MeasureTheory Filter +namespace DirectionalTransience + +lemma integrable_bounded_mul {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F G : Ω → ℝ) (hF : Measurable F) (hG : Measurable G) + (C D : ℝ) (hC : 0≤C) (hFb : ∀ ω, ‖F ω‖≤C) (hGb : ∀ ω, ‖G ω‖≤D) : + Integrable (fun ω => F ω*G ω) μ := + Integrable.of_bound (hF.mul hG).aestronglyMeasurable (C*D) (ae_of_all _ fun ω => by + rw [norm_mul]; exact mul_le_mul (hFb ω) (hGb ω) (norm_nonneg _) hC) + +lemma integral_weighted_sub_bounded {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F G K : Ω → ℝ) (hF : Measurable F) (hG : Measurable G) (hK : Measurable K) + (C D : ℝ) (hC : 0≤C) (hFb : ∀ ω, ‖F ω‖≤C) (hGb : ∀ ω, ‖G ω‖≤D) (hKb : ∀ ω, ‖K ω‖≤D) : + (∫ ω, F ω*(G ω-K ω) ∂μ) = (∫ ω, F ω*G ω ∂μ)-(∫ ω, F ω*K ω ∂μ) := by + simp_rw [mul_sub] + exact integral_sub (integrable_bounded_mul μ F G hF hG C D hC hFb hGb) + (integrable_bounded_mul μ F K hF hK C D hC hFb hKb) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TruncatedVarianceDouble.lean b/lean/OAI/Probability/Ballisticity/Estimates/TruncatedVarianceDouble.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a78ad33f0aa102ae3e31b44f53a19a956766b84 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TruncatedVarianceDouble.lean @@ -0,0 +1,416 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OrderedTimes + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma truncatedVariance_double_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + {u : ℝ} (hu : 0 ≤ u) : + truncatedVariance μ S (2*u) ≤ truncatedVariance μ S u+4*u^2*μ.real {x | u < |S x|} := by + let A := {x | u < |S x|} + have hA : MeasurableSet A := measurableSet_lt measurable_const hS.abs + have hI := (integrable_const (4*u^2)).indicator hA (μ := μ) + have hh : (∫ x, min ((S x)^2) ((2*u)^2) ∂μ) ≤ + ∫ x, min ((S x)^2) (u^2)+A.indicator (fun _ => 4*u^2) x ∂μ := by + apply integral_mono (integrable_truncated_square μ S hS (2*u)) + ((integrable_truncated_square μ S hS u).add hI) + intro x + simp only [Pi.add_apply] + by_cases hx : x∈A + · rw [Set.indicator_of_mem hx] + have h1 : min ((S x)^2) ((2*u)^2) ≤ (2*u)^2 := min_le_right _ _ + have h2 : 0 ≤ min ((S x)^2) (u^2) := le_min (sq_nonneg _) (sq_nonneg _) + nlinarith + · rw [Set.indicator_of_notMem hx,add_zero] + have ha : |S x| ≤ u := le_of_not_gt hx + have hs : (S x)^2 ≤ u^2 := by nlinarith [sq_abs (S x), abs_nonneg (S x)] + rw [min_eq_left hs,min_eq_left (by nlinarith : (S x)^2 ≤ (2*u)^2)] + rw [integral_add (integrable_truncated_square μ S hS u) hI, + integral_indicator_const _ hA] at hh + simpa only [truncatedVariance,A,smul_eq_mul,mul_comm] using hh + +lemma good_scale_doubling {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {u ε γ : ℝ} (hu : 0 < u) (hε : 0 ≤ ε) + (hg : fluctuationScale μ S u*μ.real {x | u < |S x|} ≤ ε) + (hγ : (2:ℝ)^γ ≤ 4/(1+4*ε)) : + (2:ℝ)^γ*fluctuationScale μ S u ≤ fluctuationScale μ S (2*u) := by + have hm := truncatedVariance_pos μ S hS hne hu + have hm2 := truncatedVariance_pos μ S hS hne (show 0 < 2*u by positivity) + have hden : 0 < 1+4*ε := by positivity + have htail : u^2*μ.real {x | u < |S x|} ≤ ε*truncatedVariance μ S u := by + apply (div_le_iff₀ hm).mp + simpa only [fluctuationScale,div_mul_eq_mul_div] using hg + have hvar : truncatedVariance μ S (2*u) ≤ (1+4*ε)*truncatedVariance μ S u := by + have hh := truncatedVariance_double_le μ S hS hu.le + nlinarith + have hbase : 4/(1+4*ε)*fluctuationScale μ S u ≤ fluctuationScale μ S (2*u) := by + rw [fluctuationScale,fluctuationScale] + have he : 4/(1+4*ε)*(u^2/truncatedVariance μ S u) = + (2*u)^2/((1+4*ε)*truncatedVariance μ S u) := by field_simp; ring + rw [he] + exact div_le_div_of_nonneg_left (sq_nonneg _) hm2 hvar + exact (mul_le_mul_of_nonneg_right hγ (fluctuationScale_nonneg μ S u)).trans hbase + +lemma good_scale_dyadic {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {u r ε γ : ℝ} (hu : 0 < u) (hε : 0 ≤ ε) + (hγ : (2:ℝ)^γ ≤ 4/(1+4*ε)) + (hg : ∀ v, u ≤ v → v ≤ r → fluctuationScale μ S v*μ.real {x | v < |S x|} ≤ ε) : + ∀ k : ℕ, (2:ℝ)^k*u ≤ r → + ((2:ℝ)^γ)^k*fluctuationScale μ S u ≤ fluctuationScale μ S ((2:ℝ)^k*u) := by + intro k + induction k with + | zero => intro _; simp + | succ k ih => + intro hk + have hpow : (2:ℝ)^k ≤ 2^(k+1) := pow_le_pow_right₀ (by norm_num) (by omega) + have hkr : (2:ℝ)^k*u ≤ r := (mul_le_mul_of_nonneg_right hpow hu.le).trans hk + have huk : u ≤ (2:ℝ)^k*u := le_mul_of_one_le_left hu.le (one_le_pow₀ (by norm_num)) + have hkd := good_scale_doubling μ S hS hne (show 0 < (2:ℝ)^k*u by positivity) + hε (hg _ huk hkr) hγ + have hh := (mul_le_mul_of_nonneg_left (ih hkr) (Real.rpow_pos_of_pos (by norm_num) γ).le).trans hkd + simpa only [pow_succ',mul_assoc] using hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma good_scale_power_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {u r ε γ : ℝ} (hu : 0 < u) (hur : u ≤ r) + (hε : 0 ≤ ε) (hγ0 : 0 ≤ γ) (hγ : (2:ℝ)^γ ≤ 4/(1+4*ε)) + (hg : ∀ v, u ≤ v → v ≤ r → fluctuationScale μ S v*μ.real {x | v < |S x|} ≤ ε) : + fluctuationScale μ S u/fluctuationScale μ S r ≤ (2:ℝ)^γ*(u/r)^γ := by + have hr : 0 < r := hu.trans_le hur + have hnr : 0 < fluctuationScale μ S r := div_pos (sq_pos_of_pos hr) (truncatedVariance_pos μ S hS hne hr) + have hnu : 0 ≤ fluctuationScale μ S u := fluctuationScale_nonneg μ S u + obtain ⟨k,hk1,hk2⟩ := exists_nat_pow_near (x := r/u) ((one_le_div hu).mpr hur) (by norm_num : (1:ℝ)<2) + have hkr : (2:ℝ)^k*u ≤ r := (le_div_iff₀ hu).mp hk1 + have hd := (good_scale_dyadic μ S hS hne hu hε hγ hg k hkr).trans + (fluctuationScale_mono μ S hS hne (by positivity) hkr) + have hpow : (r/u)^γ ≤ ((2:ℝ)^γ)^(k+1) := by + have hh := Real.rpow_le_rpow (div_nonneg hr.le hu.le) hk2.le hγ0 + rw [← Real.rpow_natCast_mul (by norm_num : (0:ℝ)≤2), mul_comm, + Real.rpow_mul (by norm_num : (0:ℝ)≤2), Real.rpow_natCast] at hh + exact hh + have hall : (r/u)^γ*fluctuationScale μ S u ≤ (2:ℝ)^γ*fluctuationScale μ S r := by + calc + _ ≤ ((2:ℝ)^γ)^(k+1)*fluctuationScale μ S u := mul_le_mul_of_nonneg_right hpow hnu + _ = (2:ℝ)^γ*(((2:ℝ)^γ)^k*fluctuationScale μ S u) := by rw [pow_succ']; ring + _ ≤ _ := mul_le_mul_of_nonneg_left hd (Real.rpow_pos_of_pos (by norm_num) γ).le + have hpU : 0 < u^γ := Real.rpow_pos_of_pos hu γ + have hpR : 0 < r^γ := Real.rpow_pos_of_pos hr γ + rw [Real.div_rpow hr.le hu.le] at hall + have hall' : r^γ*fluctuationScale μ S u ≤ ((2:ℝ)^γ*fluctuationScale μ S r)*u^γ := by + apply (div_le_iff₀ hpU).mp + simpa only [div_mul_eq_mul_div] using hall + apply (div_le_iff₀ hnr).mpr + rw [Real.div_rpow hu.le hr.le] + have hh : fluctuationScale μ S u ≤ ((2:ℝ)^γ*fluctuationScale μ S r)*u^γ/r^γ := + (le_div_iff₀ hpR).mpr ((_root_.mul_comm _ _).trans_le hall') + exact hh.trans_eq (by ring) + +lemma fluctuationScale_upper_ratio {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {r u : ℝ} (hr : 0 < r) (hru : r ≤ u) : + fluctuationScale μ S u/fluctuationScale μ S r ≤ (u/r)^2 := by + have hu := hr.trans_le hru + have hmR := truncatedVariance_pos μ S hS hne hr + have hmU := truncatedVariance_pos μ S hS hne hu + have hm := truncatedVariance_mono μ S hS hr.le hru + have hnr : 0 < fluctuationScale μ S r := div_pos (sq_pos_of_pos hr) hmR + apply (div_le_iff₀ hnr).mpr + change u^2/truncatedVariance μ S u ≤ (u/r)^2*(r^2/truncatedVariance μ S r) + have hright : (u/r)^2*(r^2/truncatedVariance μ S r)=u^2/truncatedVariance μ S r := by field_simp + rw [hright] + exact div_le_div_of_nonneg_left (sq_nonneg _) hmR hm + +theorem good_scale_comparison {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {b r A ε γ : ℝ} (hb : 0 < b) (hbr : b ≤ r) + (_hA : 1 ≤ A) (hε : 0 ≤ ε) (hγ0 : 0 ≤ γ) (hγ : (2:ℝ)^γ ≤ 4/(1+4*ε)) + (hg : ∀ v, b ≤ v → v ≤ r → fluctuationScale μ S v*μ.real {x | v < |S x|} ≤ ε) : + ∀ u, b ≤ u → u ≤ A*r → fluctuationScale μ S u/fluctuationScale μ S r ≤ + max ((2:ℝ)^γ) (A^2)*(u/r)^γ := by + intro u hbu hur + have hu : 0 < u := hb.trans_le hbu + have hr : 0 < r := hb.trans_le hbr + have hratio : 0 ≤ (u/r)^γ := (Real.rpow_pos_of_pos (div_pos hu hr) γ).le + by_cases hsmall : u ≤ r + · exact (good_scale_power_bound μ S hS hne hu hsmall hε hγ0 hγ + (fun v huv hvr => hg v (hbu.trans huv) hvr)).trans + (mul_le_mul_of_nonneg_right (le_max_left _ _) hratio) + · have hru : r ≤ u := le_of_not_ge hsmall + have hrat1 : 1 ≤ u/r := (one_le_div hr).mpr hru + have hratA : u/r ≤ A := (div_le_iff₀ hr).mpr hur + have hratpow : 1 ≤ (u/r)^γ := Real.one_le_rpow hrat1 hγ0 + calc + fluctuationScale μ S u/fluctuationScale μ S r ≤ (u/r)^2 := fluctuationScale_upper_ratio μ S hS hne hr hru + _ ≤ A^2 := pow_le_pow_left₀ (div_nonneg hu.le hr.le) hratA 2 + _ ≤ max ((2:ℝ)^γ) (A^2) := le_max_right _ _ + _ ≤ max ((2:ℝ)^γ) (A^2)*(u/r)^γ := le_mul_of_one_le_right (le_trans (sq_nonneg A) (le_max_right _ _)) hratpow + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TupleClipping.lean b/lean/OAI/Probability/Ballisticity/Estimates/TupleClipping.lean new file mode 100644 index 0000000000000000000000000000000000000000..067585d49b6f33882ee8ff13ae0a4bdaf0c5ce20 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TupleClipping.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.UniformLowerMass + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma product_small_mass_probability {Ω I : Type*} [MeasurableSpace Ω] [MeasurableSpace I] + (μ : Measure Ω) (π : Measure I) [IsProbabilityMeasure μ] [IsProbabilityMeasure π] + (k : ℕ) (F : Ω → I → Fin k → ℝ) + (hF : ∀ j, Measurable (fun p : Ω × I => F p.1 p.2 j)) + (hF0 : ∀ ω x j, 0 ≤ F ω x j) (hF1 : ∀ ω x j, F ω x j ≤ 1) + {c α : ℝ} (hc : 0 < c) + (hbad : ∀ x j, μ.real {ω | F ω x j < c} ≤ α) : + μ.real {ω | (∫ x, ∏ j, F ω x j ∂π) < c^k/2} ≤ 2*k*α := by + have hb (x : I) : μ.real {ω | (∏ j, F ω x j) < 2*(c^k/2)} ≤ k*α := by + have hs : {ω | (∏ j, F ω x j) < 2*(c^k/2)} ⊆ ⋃ j, {ω | F ω x j < c} := by + intro ω hω + change (∏ j, F ω x j) < 2*(c^k/2) at hω + by_contra hn + simp only [Set.mem_iUnion,Set.mem_ofPred_eq,not_exists,not_lt] at hn + have hh := Finset.prod_le_prod₀ (s := Finset.univ) (f := fun _ : Fin k => c) + (g := fun j => F ω x j) (fun _ _ => hc.le) (fun j _ => hn j) + simpa using (show c^k ≤ ∏ j, F ω x j by simpa using hh).not_gt (by linarith) + have hh := (measureReal_mono (μ := μ) hs).trans (measureReal_iUnion_fintype_le _) + have hh' := Finset.sum_le_sum (s := Finset.univ) (fun j _ => hbad x j) + simpa using hh.trans hh' + have hh := mixture_small_mass_probability μ π (fun ω x => ∏ j, F ω x j) + (Finset.measurable_prod _ fun j _ => hF j) + (fun ω x => Finset.prod_nonneg fun j _ => hF0 ω x j) + (fun ω x => Finset.prod_le_one₀ (fun j _ => hF0 ω x j) (fun j _ => hF1 ω x j)) + (show 0 < c^k/2 by positivity) hb + simpa only [mul_assoc] using hh + +noncomputable def tupleTubeMass {d k : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (H : ℕ) (π : Measure (Fin k → Lattice d)) (ω : Environment d) : ℝ := + ∫ x, ∏ j, (quenchedKernel (ω,x j)).real (TubePrefix ℓ f (x j) θ z H) ∂π + +lemma measurable_tupleTube_integrand {d k : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (H : ℕ) (j : Fin k) : + Measurable (fun p : Environment d × (Fin k → Lattice d) => + (quenchedKernel (p.1,p.2 j)).real (TubePrefix ℓ f (p.2 j) θ z H)) := by + apply Measurable.ennreal_toReal + apply measurable_from_prod_countable_left + intro x + exact (Kernel.measurable_coe _ (measurableSet_tubePrefix ℓ f (x j) θ z H)).comp + (measurable_id.prodMk measurable_const) + +theorem initial_tuple_clipping {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (k : ℕ) {T η ε : ℝ} (hT : 0 < T) (hη : 0 < η) (hε : 0 < ε) : + ∃ c : ℝ, 0 < c ∧ ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → ∃ θ : ℝ, + ∀ (H : ℕ) (π : Measure (Fin k → Lattice d)), IsProbabilityMeasure π → + (H:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + (environmentLaw ν).real {ω | tupleTubeMass (realPosition (step e)) f θ (η*r) H π ω < c} < ε := by + let α := ε/(4*((k:ℝ)+1)) + have hα : 0 < α := by dsimp [α]; positivity + obtain ⟨c,hc,hc1,R,hR,hh⟩ := clipping_uniform ν hue e f hef htrans hT hη hα + have hcfin : c ≠ ∞ := ne_top_of_le_ne_top (by simp) hc1 + have hcr : 0 < c.toReal := ENNReal.toReal_pos (ne_of_gt hc) hcfin + refine ⟨c.toReal^k/2,by positivity,R,hR,fun r hr => ?_⟩ + obtain ⟨θ,hθ⟩ := hh r hr + refine ⟨θ,fun H π hπ hH => ?_⟩ + let := hπ + have hb (x : Fin k → Lattice d) (j : Fin k) : + (environmentLaw ν).real {ω | (quenchedKernel (ω,x j)).real + (TubePrefix (realPosition (step e)) f (x j) θ (η*r) H) < c.toReal} ≤ α := by + have he : {ω | (quenchedKernel (ω,x j)).real + (TubePrefix (realPosition (step e)) f (x j) θ (η*r) H) < c.toReal} = + {ω | quenchedKernel (ω,x j) (TubePrefix (realPosition (step e)) f (x j) θ (η*r) H) < c} := by + ext ω + exact ENNReal.toReal_lt_toReal (measure_ne_top _ _) hcfin + rw [he] + exact (hθ (x j) H hH).le + have he := product_small_mass_probability (environmentLaw ν) π k + (fun ω x j => (quenchedKernel (ω,x j)).real (TubePrefix (realPosition (step e)) f (x j) θ (η*r) H)) + (measurable_tupleTube_integrand _ _ _ _ _) + (fun _ _ _ => ENNReal.toReal_nonneg) (fun _ _ _ => by exact ENNReal.toReal_mono (by simp) (show _ ≤ (1:ℝ≥0∞) from prob_le_one)) hcr hb + change (environmentLaw ν).real {ω | tupleTubeMass _ _ θ (η*r) H π ω < c.toReal^k/2} ≤ 2*k*α at he + apply lt_of_le_of_lt he + have hk : 0 ≤ (k:ℝ) := Nat.cast_nonneg _ + dsimp [α] + rw [←mul_div_assoc,div_lt_iff₀ (by positivity)] + nlinarith +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TupleEndpoint.lean b/lean/OAI/Probability/Ballisticity/Estimates/TupleEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcbd6920ddf57125c413e0b856783945ba7fcd6f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TupleEndpoint.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RawPairLocality +import OAI.Probability.Ballisticity.Walk.CoordinateKernelComp + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience.TupleKernel + +lemma fin_tsum_product {A : Type*} (n : ℕ) (f : Fin n → A → ℝ≥0∞) : + (∑' x : Fin n → A, ∏ j, f j (x j)) = ∏ j, ∑' x : A, f j x := by + induction n with + | zero => simp + | succ n ih => + rw [← (Fin.consEquiv (fun _ : Fin (n+1) => A)).tsum_eq] + simp only [Fin.consEquiv_apply, Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ] + rw [ENNReal.tsum_prod'] + simp_rw [ENNReal.tsum_mul_left] + rw [ENNReal.tsum_mul_right, ih] + +lemma measurable_countable_measure {A Ω : Type*} [MeasurableSpace A] + [MeasurableSpace Ω] [Countable A] [MeasurableSingletonClass A] + (μ : Ω → Measure A) (h : ∀ x, Measurable (fun ω => μ ω {x})) : Measurable μ := by + have he (ω) : μ ω = Measure.sum (fun x => μ ω {x} • Measure.dirac x) := + (Measure.sum_smul_dirac _).symm + apply Measure.measurable_of_measurable_coe + intro s hs + have hf : (fun ω => μ ω s) = (fun ω => ∑' x, μ ω {x} * Measure.dirac x s) := by + funext ω + conv_lhs => rw [he ω] + simp only [Measure.sum_apply _ hs, Measure.smul_apply, smul_eq_mul] + rw [hf] + exact Measurable.tsum fun x => (h x).mul_const _ + +lemma measure_le_of_singletons {A : Type*} [MeasurableSpace A] + [Countable A] [MeasurableSingletonClass A] (μ ν : Measure A) + (h : ∀ x, μ {x} ≤ ν {x}) : μ ≤ ν := by + intro s + conv_lhs => rw [← Measure.sum_smul_dirac μ] + conv_rhs => rw [← Measure.sum_smul_dirac ν] + simp only [Measure.sum_apply_of_countable, Measure.smul_apply, smul_eq_mul] + exact ENNReal.tsum_le_tsum fun x => mul_le_mul_left (h x) _ + +lemma countable_pi_mono {A : Type*} [MeasurableSpace A] [Countable A] + [MeasurableSingletonClass A] (n : ℕ) (μ ν : Fin n → Measure A) + [∀ j, SigmaFinite (μ j)] [∀ j, SigmaFinite (ν j)] + (h : ∀ j, μ j ≤ ν j) : Measure.pi μ ≤ Measure.pi ν := by + apply measure_le_of_singletons + intro x + simp only [Measure.pi_singleton] + exact Finset.prod_le_prod fun j _ => h j {x j} + +lemma countable_pi_bind {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable A] [Countable B] [MeasurableSingletonClass A] [MeasurableSingletonClass B] + (n : ℕ) (μ : Fin n → Measure A) (K : Fin n → A → Measure B) + [∀ j, SigmaFinite (μ j)] [∀ j x, SigmaFinite (K j x)] + [∀ j, SigmaFinite ((μ j).bind (K j))] : + (Measure.pi μ).bind (fun x => Measure.pi (fun j => K j (x j))) = + Measure.pi (fun j => (μ j).bind (K j)) := by + apply Measure.ext_of_singleton + intro y + rw [Measure.bind_apply (measurableSet_singleton _) (measurable_of_countable _).aemeasurable] + simp_rw [Measure.pi_singleton,Measure.bind_apply (measurableSet_singleton _) (measurable_of_countable _).aemeasurable, + lintegral_countable',Measure.pi_singleton,← Finset.prod_mul_distrib] + exact fin_tsum_product n (fun j a => K j a {y j} * μ j {a}) + +end TupleKernel + +noncomputable def rawTupleEndpointLaw {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : Measure (Fin k → Lattice d) := + Measure.pi (fun j => variableHitKernel ℓ H (ω,x j)) + +lemma rawTupleEndpointLaw_singleton {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x y : Fin k → Lattice d) : + rawTupleEndpointLaw ℓ H ω x {y} = ∏ j, variableHitKernel ℓ H (ω,x j) {y j} := by + exact Measure.pi_singleton _ _ + +lemma rawTupleEndpointLaw_le_one {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : + rawTupleEndpointLaw ℓ H ω x Set.univ ≤ 1 := by + rw [rawTupleEndpointLaw,Measure.pi_univ] + exact Finset.prod_le_one fun j _ => + hitKernel_total_le_one (disjoint_strip_upper ℓ (x j) H) (ω,x j) + +instance rawTupleEndpointLaw_finite {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : + IsFiniteMeasure (rawTupleEndpointLaw ℓ H ω x) := by + unfold rawTupleEndpointLaw + infer_instance + +lemma measurable_rawTupleEndpointLaw {d k : ℕ} (ℓ : Vector d) (H : ℕ) : + Measurable (fun p : Environment d × (Fin k → Lattice d) => rawTupleEndpointLaw ℓ H p.1 p.2) := by + apply TupleKernel.measurable_countable_measure + intro y + simp_rw [rawTupleEndpointLaw_singleton] + apply Finset.measurable_prod + intro j _ + exact (Kernel.measurable_coe (variableHitKernel ℓ H) (measurableSet_singleton _)).comp + (measurable_fst.prodMk ((measurable_pi_apply j).comp measurable_snd)) + +noncomputable def rawTupleMixture {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (π : Measure (Fin k → Lattice d)) (ω : Environment d) : Measure (Fin k → Lattice d) := + π.bind (rawTupleEndpointLaw ℓ H ω) + +lemma rawTupleMixture_apply {d k : ℕ} (ℓ : Vector d) (H : ℕ) + (π : Measure (Fin k → Lattice d)) (ω : Environment d) (A : Set (Fin k → Lattice d)) : + rawTupleMixture ℓ H π ω A = ∫⁻ x, rawTupleEndpointLaw ℓ H ω x A ∂π := by + exact Measure.bind_apply (Set.to_countable _).measurableSet (measurable_of_countable _).aemeasurable + +lemma rawTupleEndpointLaw_comp_le {d k : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Fin k → Lattice d) : + rawTupleMixture (realPosition (step e)) m + (rawTupleEndpointLaw (realPosition (step e)) h ω x) ω ≤ + rawTupleEndpointLaw (realPosition (step e)) (h+m) ω x := by + let ℓ := realPosition (step e) + let K := fun (n : ℕ) (y : Lattice d) => variableHitKernel ℓ n (ω,y) + have hcomp (y : Lattice d) : (K h y).bind (K m) ≤ K (h+m) y := by + intro U + rw [Measure.bind_apply (Set.to_countable _).measurableSet (measurable_of_countable _).aemeasurable] + change (∫⁻ a, hitKernel (Strip ℓ a (m : ℝ)) (Upper ℓ a (m : ℝ)) (ω,a) U + ∂hitKernel (Strip ℓ y (h : ℝ)) (Upper ℓ y (h : ℝ)) (ω,y)) ≤ + hitKernel (Strip ℓ y ((h+m : ℕ) : ℝ)) (Upper ℓ y ((h+m : ℕ) : ℝ)) (ω,y) U + simpa only [ℓ, Nat.cast_add] using coordinate_raw_kernel_comp_le e h m ω y U + let : ∀ y, IsFiniteMeasure ((K h y).bind (K m)) := fun y => + ⟨lt_of_le_of_lt (hcomp y Set.univ) (measure_lt_top _ _)⟩ + change (Measure.pi (fun j => K h (x j))).bind (fun y => Measure.pi (fun j => K m (y j))) ≤ + Measure.pi (fun j => K (h+m) (x j)) + rw [TupleKernel.countable_pi_bind] + exact TupleKernel.countable_pi_mono k _ _ (fun j => hcomp (x j)) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/TwoStopSplice.lean b/lean/OAI/Probability/Ballisticity/Estimates/TwoStopSplice.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cb4438718fdd81f6d2cc7b7c523a1960136eb2d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/TwoStopSplice.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Probability.Ballisticity.Coupling.StoppedFreshField + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma stop_observable {d : ℕ} (S : ℕ → Set (Lattice d)) (τ : Environment d → ℕ) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (B : Set ℕ) : StoppedRowsEvent S τ (τ ⁻¹' B) := by + intro n + by_cases hn : n∈B + · have he : (τ ⁻¹' B)∩{ω | τ ω=n}={ω | τ ω=n} := by + ext ω; simp only [Set.mem_inter_iff,Set.mem_preimage,Set.mem_ofPred_eq] + exact ⟨And.right,fun h => ⟨h ▸ hn,h⟩⟩ + rw [he]; exact hτ n + · have he : (τ ⁻¹' B)∩{ω | τ ω=n}=∅ := by + ext ω; simp only [Set.mem_inter_iff,Set.mem_preimage,Set.mem_ofPred_eq,Set.mem_empty_iff_false,iff_false] + rintro ⟨hb,h⟩; exact hn (h ▸ hb) + rw [he]; exact @MeasurableSet.empty _ (rowSigma (S n)) + +lemma upperField_joint_measurable {d : ℕ} (e : Direction d) : + Measurable (fun p : Environment d×ℕ => upperField e p.2 p.1) := by + apply measurable_from_prod_countable_left + intro n + exact (upperField_measurable_rows e n).mono (rowSigma_le _) le_rfl + +lemma belowHeight_mono {d : ℕ} (e : Direction d) : + Monotone (fun n : ℕ => BelowHeight (realPosition (step e)) n) := by + intro n m h x hx + change dot (realPosition x) (realPosition (step e))<(n:ℝ) at hx + change dot (realPosition x) (realPosition (step e))<(m:ℝ) + exact lt_of_lt_of_le hx (by exact_mod_cast h) + +theorem twoStopSplice_fresh {d : ℕ} {D : Type*} [MeasurableSpace D] + [MeasurableSingletonClass D] (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω≤σ ω) + (hτ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | τ ω=n}) + (hσ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | σ ω=n}) + (U : Environment d → D) (hUm : Measurable U) + (hU : ∀ B, MeasurableSet B → + StoppedRowsEvent (fun n => BelowHeight (realPosition (step e)) n) τ (U ⁻¹' B)) : + ((environmentLaw ν).prod (environmentLaw ν)).map + (fun p => (U p.1,upperField e (τ p.1) + (stoppedRowGraft (fun n => BelowHeight (realPosition (step e)) n) σ p.1 p.2))) = + ((environmentLaw ν).map U).prod (Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)) := by + let S : ℕ → Set (Lattice d) := fun n => BelowHeight (realPosition (step e)) n + let G : Environment d×Environment d → Environment d := fun p => stoppedRowGraft S σ p.1 p.2 + have hUσ : ∀ B, MeasurableSet B → StoppedRowsEvent S σ (U ⁻¹' B) := by + intro B hB + exact stoppedRowsEvent_mono S (belowHeight_mono e) τ σ hτσ hσ _ (hU B hB) + have hτσobs : ∀ B, MeasurableSet B → StoppedRowsEvent S σ (τ ⁻¹' B) := by + intro B _ + exact stoppedRowsEvent_mono S (belowHeight_mono e) τ σ hτσ hσ _ (stop_observable S τ hτ B) + have hUG (p : Environment d×Environment d) : U (G p)=U p.1 := + stoppedRowGraft_observable S σ hσ U hUσ p.1 p.2 + have hτG (p : Environment d×Environment d) : τ (G p)=τ p.1 := + stoppedRowGraft_observable S σ hσ τ hτσobs p.1 p.2 + have hFm : Measurable (fun ω => (U ω,upperField e (τ ω) ω)) := + hUm.prodMk ((upperField_joint_measurable e).comp + (measurable_id.prodMk (measurable_of_stop_events S τ hτ))) + have hGm : Measurable G := stoppedRowGraft_measurable S σ (measurable_of_stop_events S σ hσ) + calc + _ = ((environmentLaw ν).prod (environmentLaw ν)).map + ((fun ω => (U ω,upperField e (τ ω) ω)) ∘ G) := by + congr 1 + funext p + simp only [Function.comp_apply,hUG,hτG] + rfl + _ = (((environmentLaw ν).prod (environmentLaw ν)).map G).map + (fun ω => (U ω,upperField e (τ ω) ω)) := (Measure.map_map hFm hGm).symm + _ = (environmentLaw ν).map (fun ω => (U ω,upperField e (τ ω) ω)) := by + rw [show ((environmentLaw ν).prod (environmentLaw ν)).map G=environmentLaw ν from + stoppedRowGraft_map ν S σ hσ] + _ = _ := stopped_fresh_joint_map ν S τ hτ U hUm hU (upperField e) + (upperField_measurable_rows e) _ (upperField_map e ν) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience + +instance row_standardBorel (d : ℕ) : StandardBorelSpace (Row d) := + (show MeasurableSet {p : Direction d → ℝ≥0 | ∑ e, p e = 1} from + (isClosed_eq (by fun_prop) continuous_const).measurableSet).standardBorel + +noncomputable def stoppedObservation {d : ℕ} (S : ℕ → Set (Lattice d)) + (τ : Environment d → ℕ) (filler : Environment d) : Environment d → Environment d := + fun ω => stoppedRowGraft S τ ω filler + +lemma stoppedObservation_measurable {d : ℕ} (S : ℕ → Set (Lattice d)) + (τ : Environment d → ℕ) (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (filler : Environment d) : Measurable (stoppedObservation S τ filler) := + (stoppedRowGraft_measurable S τ (measurable_of_stop_events S τ hτ)).comp + (measurable_id.prodMk measurable_const) + +lemma rowGraft_fixed_measurable_rows {d : ℕ} (S : Set (Lattice d)) + (filler : Environment d) : + @Measurable (Environment d) (Environment d) (rowSigma S) inferInstance + (fun ω => rowGraft S ω filler) := + (rowGraft_measurable_rows S).comp (measurable_id.prodMk measurable_const) + +lemma stoppedObservation_observable {d : ℕ} (S : ℕ → Set (Lattice d)) + (τ : Environment d → ℕ) (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (filler : Environment d) (B : Set (Environment d)) (hB : MeasurableSet B) : + StoppedRowsEvent S τ (stoppedObservation S τ filler ⁻¹' B) := by + intro n + have he : (stoppedObservation S τ filler ⁻¹' B) ∩ {ω | τ ω=n} = + ((fun ω => rowGraft (S n) ω filler) ⁻¹' B) ∩ {ω | τ ω=n} := by + ext ω + simp only [Set.mem_inter_iff, Set.mem_preimage, Set.mem_ofPred_eq] + constructor <;> rintro ⟨hb, hn⟩ <;> refine ⟨?_, hn⟩ + · simpa only [stoppedObservation, stoppedRowGraft, hn] using hb + · simpa only [stoppedObservation, stoppedRowGraft, hn] using hb + rw [he] + exact (hB.preimage (rowGraft_fixed_measurable_rows (S n) filler)).inter (hτ n) + +lemma stoppedObservation_nested {d : ℕ} (S : ℕ → Set (Lattice d)) (hS : Monotone S) + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω≤σ ω) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (hσ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | σ ω=n}) + (filler η ξ : Environment d) : + stoppedObservation S τ filler (stoppedRowGraft S σ η ξ) = + stoppedObservation S τ filler η := by + apply stoppedRowGraft_observable S σ hσ + intro B hB + exact stoppedRowsEvent_mono S hS τ σ hτσ hσ _ + (stoppedObservation_observable S τ hτ filler B hB) + +lemma stoppedObservation_nested_stop {d : ℕ} (S : ℕ → Set (Lattice d)) (hS : Monotone S) + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω≤σ ω) + (hτ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | τ ω=n}) + (hσ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | σ ω=n}) + (filler η : Environment d) : τ (stoppedObservation S σ filler η)=τ η := by + apply stoppedRowGraft_observable S σ hσ + intro B _ + exact stoppedRowsEvent_mono S hS τ σ hτσ hσ _ (stop_observable S τ hτ B) + +lemma stoppedObservation_regraft {d : ℕ} (S : ℕ → Set (Lattice d)) + (σ : Environment d → ℕ) (hσ : ∀ n, MeasurableSet[rowSigma (S n)] {ω | σ ω=n}) + (filler η ξ : Environment d) : + stoppedRowGraft S σ (stoppedObservation S σ filler η) ξ = stoppedRowGraft S σ η ξ := by + have ht : σ (stoppedObservation S σ filler η)=σ η := + stoppedRowGraft_stop S σ hσ η filler + change rowGraft (S (σ (stoppedObservation S σ filler η))) + (stoppedObservation S σ filler η) ξ = rowGraft (S (σ η)) η ξ + rw [ht] + funext x + by_cases hx : x ∈ S (σ η) <;> simp [rowGraft, hx, stoppedObservation, stoppedRowGraft] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/UniformLowerMass.lean b/lean/OAI/Probability/Ballisticity/Estimates/UniformLowerMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..e26459c0dc65a19a5f841e081260903a0a9cc7ce --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/UniformLowerMass.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Probability.Ballisticity.Renewal.CurvePositiveScale + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience +lemma uniform_lower_mass_from_sequences (P : ℝ → ℝ≥0∞ → Prop) + (hmono : ∀ r c c', c' ≤ c → P r c → P r c') + (hseq : ∀ r : ℕ → ℝ, (∀ n, 0 < r n) → Tendsto r atTop atTop → + ∃ (ns : ℕ → ℕ) (c : ℝ≥0∞), StrictMono ns ∧ 0 < c ∧ c ≤ 1 ∧ ∀ᶠ n in atTop, P (r (ns n)) c) : + ∃ c : ℝ≥0∞, 0 < c ∧ c ≤ 1 ∧ ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → P r c := by + by_contra hn + push Not at hn + have hx (n : ℕ) : ∃ r : ℝ, (n:ℝ)+1 ≤ r ∧ ¬ P r (ENNReal.ofReal (dyadicCut n)) := + hn _ (ENNReal.ofReal_pos.mpr (dyadicCut_pos n)) (ENNReal.ofReal_le_one.mpr (dyadicCut_le_one n)) + ((n:ℝ)+1) (by positivity) + choose r hre hrP using hx + have hr : ∀ n, 0 < r n := fun n => lt_of_lt_of_le (by positivity) (hre n) + have hrinf : Tendsto r atTop atTop := tendsto_atTop_mono hre + ((tendsto_natCast_atTop_atTop : Tendsto (fun n : ℕ => (n:ℝ)) atTop atTop).atTop_add tendsto_const_nhds) + obtain ⟨ns,c,hns,hc,hc1,hgood⟩ := hseq r hr hrinf + have hcn : Tendsto (fun n => ENNReal.ofReal (dyadicCut (ns n))) atTop (𝓝 0) := by + simpa only [ENNReal.ofReal_zero, Function.comp_def] using ENNReal.continuous_ofReal.continuousAt.tendsto.comp + (dyadicCut_tendsto.comp hns.tendsto_atTop) + obtain ⟨n,hn,hsmall⟩ := (hgood.and (hcn.eventually (gt_mem_nhds hc))).exists + exact hrP (ns n) (hmono _ _ _ hsmall.le hn) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +theorem clipping_uniform_origin {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {T η ε : ℝ} (hT : 0 < T) (hη : 0 < η) (hε : 0 < ε) : + ∃ c : ℝ≥0∞, 0 < c ∧ c ≤ 1 ∧ ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → ∃ θ : ℝ, + (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix (realPosition (step e)) f 0 θ (η*r) + ⌈T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r⌉₊) < c} < ε := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + let P := fun r c => ∃ θ : ℝ, (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix ℓ f 0 θ (η*r) ⌈T*fluctuationScale μ S r⌉₊) < c} < ε + apply uniform_lower_mass_from_sequences P + · intro r c c' hcc' hP + obtain ⟨θ,hθ⟩ := hP + refine ⟨θ,lt_of_le_of_lt ?_ hθ⟩ + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono + intro ω hω + exact hω.trans_le hcc' + · intro r hr hrinf + obtain ⟨ns,F,F₀,hns,hF,hFb,hF1,hFa,hF₀,hFlim,hFle⟩ := exists_dyadic_variance_profile μ S + (measurable_commonIncrementProcess ℓ f 0) (independent_commonWordIncrement_nonzero ν hue e f hef htrans) r hr + have hri : Tendsto (fun n => r (ns n)) atTop atTop := hrinf.comp hns.tendsto_atTop + by_cases hzero : F₀=0 + · have hFlim0 : Tendsto F atTop (𝓝 0) := hzero ▸ hFlim + obtain ⟨c,hc,hc1,hh⟩ := clipping_zero_profile ν hue e f hef htrans + (fun n => r (ns n)) (fun n => hr (ns n)) hri F hFlim0 hF hT hη hε + exact ⟨ns,c,hns,hc,hc1,hh⟩ + · have hpos : 0 < F₀ := lt_of_le_of_ne hF₀.1 (Ne.symm hzero) + obtain ⟨c,hc,hc1,hh⟩ := clipping_positive_profile ν hue e f hef htrans + (fun n => r (ns n)) (fun n => hr (ns n)) hri F hpos hF₀.2 hFle hFlim hF hT hη hε + exact ⟨ns,c,hns,hc,hc1,hh⟩ +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience +lemma quenchedTube_translation {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (θ z : ℝ) (H : ℕ) (ω : Environment d) : + quenchedKernel (ω,x) (TubePrefix ℓ f x θ z H) = + quenchedKernel ((fun y => ω (x+y)),0) (TubePrefix ℓ f 0 θ z H) := by + have hm : Measurable (fun X : Path d => fun n => X n-x) := by fun_prop + rw [←tubePrefix_translation,←Measure.map_apply hm (measurableSet_tubePrefix ℓ f 0 θ z H)] + simpa only [add_zero] using congrArg (fun μ : Measure (Path d) => μ (TubePrefix ℓ f 0 θ z H)) + (quenched_translation ω x 0) +lemma quenchedTube_probability_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (x : Lattice d) (θ z : ℝ) (H : ℕ) (c : ℝ≥0∞) : + (environmentLaw ν).real {ω | quenchedKernel (ω,x) (TubePrefix ℓ f x θ z H) < c} = + (environmentLaw ν).real {ω | quenchedKernel (ω,0) (TubePrefix ℓ f 0 θ z H) < c} := by + have hm : Measurable (fun ω : Environment d => quenchedKernel (ω,0) (TubePrefix ℓ f 0 θ z H)) := + (Kernel.measurable_coe _ (measurableSet_tubePrefix ℓ f 0 θ z H)).comp (measurable_id.prodMk measurable_const) + have he := congrArg (fun μ : Measure (Environment d) => μ {ω | quenchedKernel (ω,0) (TubePrefix ℓ f 0 θ z H) < c}) + (environment_translation ν x) + rw [Measure.map_apply (by fun_prop) (measurableSet_lt hm measurable_const)] at he + apply congrArg ENNReal.toReal + convert he using 1 + congr 1 + ext ω + exact Iff.of_eq (congrArg (fun y : ℝ≥0∞ => y < c) (quenchedTube_translation ℓ f x θ z H ω)) +lemma quenchedTube_zero {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ : ℝ) {z : ℝ} (hz : 0 ≤ z) (ω : Environment d) : + quenchedKernel (ω,x) (TubePrefix ℓ f x θ z 0)=1 := by + apply (measure_congr ?_).trans measure_univ + filter_upwards [quenched_initial_ae (ω,x)] with X hX + exact propext (iff_of_true (tubePrefix_zero_of_initial ℓ f x θ z hz X hX) (Set.mem_univ X)) + +theorem clipping_uniform {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {T η ε : ℝ} (hT : 0 < T) (hη : 0 < η) (hε : 0 < ε) : + ∃ c : ℝ≥0∞, 0 < c ∧ c ≤ 1 ∧ ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → ∃ θ : ℝ, + ∀ (x : Lattice d) (H : ℕ), (H:ℝ) ≤ T*fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + (environmentLaw ν).real {ω | quenchedKernel (ω,x) + (TubePrefix (realPosition (step e)) f x θ (η*r) H) < c} < ε := by + obtain ⟨c,hc,hc1,R,hR,hh⟩ := clipping_uniform_origin ν hue e f hef htrans hT hη hε + refine ⟨c,hc,hc1,R,hR,fun r hr => ?_⟩ + obtain ⟨θ,hθ⟩ := hh r hr + refine ⟨θ,fun x H hH => ?_⟩ + rw [quenchedTube_probability_translation] + by_cases hH0 : H=0 + · subst H + have hz : 0 ≤ η*r := mul_nonneg hη.le (hR.le.trans hr) + simp only [quenchedTube_zero _ _ _ _ hz,not_lt.mpr hc1,Set.ofPred_false,measureReal_empty] + exact hε + · apply lt_of_le_of_lt _ hθ + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono + intro ω hω + exact (quenchedTube_mono_height e f 0 θ (η*r) (Nat.pos_of_ne_zero hH0) + (by exact_mod_cast hH.trans (Nat.le_ceil _)) ω).trans_lt hω +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/UniformRiemannMesh.lean b/lean/OAI/Probability/Ballisticity/Estimates/UniformRiemannMesh.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8bc1613600fbb566937d8ea289ee03846b28db0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/UniformRiemannMesh.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory Filter +open scoped BigOperators Topology +namespace DirectionalTransience + +noncomputable def realMesh (s t : ℝ) (n j : ℕ) : ℝ := s+(j:ℝ)*(t-s)/n + +lemma realMesh_zero (s t : ℝ) (n : ℕ) : realMesh s t n 0=s := by simp [realMesh] +lemma realMesh_last (s t : ℝ) {n : ℕ} (hn : 0 < n) : realMesh s t n n=t := by + have hn0 : (n:ℝ) ≠ 0 := by exact_mod_cast hn.ne' + simp only [realMesh,mul_div_cancel_left₀ _ hn0] + ring +lemma realMesh_sub (s t : ℝ) (n j : ℕ) : realMesh s t n (j+1)-realMesh s t n j=(t-s)/n := by + simp only [realMesh,Nat.cast_add,Nat.cast_one] + ring +lemma realMesh_mono {s t : ℝ} (hst : s ≤ t) (n : ℕ) : Monotone (realMesh s t n) := by + intro i j hij + simpa only [realMesh, add_comm] using add_le_add_left (div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right + (Nat.cast_le.mpr hij) (sub_nonneg.mpr hst)) (Nat.cast_nonneg n)) s + +lemma riemann_error_le (f : ℝ → ℝ) (hf : Continuous f) {s t ε δ : ℝ} + (hst : s ≤ t) (hε : 0 ≤ ε) (hmod : ∀ x y, dist x y < δ → dist (f x) (f y) ≤ ε) + {n : ℕ} (hn : 0 < n) (hδ : (t-s)/n < δ) : + |(∑ j ∈ Finset.range n, (t-s)/n*f (realMesh s t n j))-(∫ u in s..t, f u)| ≤ ε*(t-s) := by + have hmono := realMesh_mono hst n + have hi : ∀ k < n, IntervalIntegrable f volume (realMesh s t n k) (realMesh s t n (k+1)) := + fun _ _ => hf.intervalIntegrable _ _ + have hsum := intervalIntegral.sum_integral_adjacent_intervals hi + rw [realMesh_zero,realMesh_last s t hn] at hsum + rw [← hsum,← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j ∈ Finset.range n, |(t-s)/n*f (realMesh s t n j)- + (∫ u in realMesh s t n j..realMesh s t n (j+1), f u)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j ∈ Finset.range n, ε*((t-s)/n) := by + apply Finset.sum_le_sum + intro j hj + have he : (t-s)/n*f (realMesh s t n j) = + ∫ _u in realMesh s t n j..realMesh s t n (j+1), f (realMesh s t n j) := by + rw [intervalIntegral.integral_const,realMesh_sub,smul_eq_mul] + rw [he,← intervalIntegral.integral_sub intervalIntegrable_const (hf.intervalIntegrable _ _)] + have hb := intervalIntegral.norm_integral_le_of_norm_le_const (a := realMesh s t n j) + (b := realMesh s t n (j+1)) (C := |ε|) (f := fun u => f (realMesh s t n j)-f u) (fun u hu => by + rw [Set.uIoc_of_le (hmono (Nat.le_succ j))] at hu + have hd : dist (realMesh s t n j) u < δ := by + rw [Real.dist_eq,abs_of_nonpos (by linarith [hu.1] : realMesh s t n j-u ≤ 0)] + have hw := realMesh_sub s t n j + linarith [hu.2] + simpa only [Real.norm_eq_abs,Real.dist_eq,abs_of_nonneg hε] using hmod _ _ hd) + simpa only [Real.norm_eq_abs,realMesh_sub,abs_of_nonneg hε,abs_of_nonneg (div_nonneg (sub_nonneg.mpr hst) (Nat.cast_nonneg n))] using hb + _ = ε*(t-s) := by + simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul] + have hn0 : (n:ℝ) ≠ 0 := by exact_mod_cast hn.ne' + field_simp + +lemma tendsto_riemann_mesh (f : ℝ → ℝ) (hf : UniformContinuous f) {s t : ℝ} (hst : s < t) : + Tendsto (fun n => ∑ j ∈ Finset.range n, (t-s)/n*f (realMesh s t n j)) atTop + (𝓝 (∫ u in s..t, f u)) := by + apply Metric.tendsto_atTop.mpr + intro ε hε + have he : 0 < ε/(2*(t-s)) := div_pos hε (mul_pos (by norm_num) (sub_pos.mpr hst)) + obtain ⟨δ,hδ,hmod⟩ := Metric.uniformContinuous_iff.mp hf (ε/(2*(t-s))) he + have hh : Tendsto (fun n : ℕ => (t-s)/(n:ℝ)) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop + obtain ⟨N,hN⟩ := eventually_atTop.mp ((hh.eventually_lt_const hδ).and (eventually_gt_atTop 0)) + refine ⟨N,fun n hn => ?_⟩ + have hb := riemann_error_le f hf.continuous hst.le he.le + (fun x y hxy => (hmod hxy).le) (hN n hn).2 (hN n hn).1 + rw [Real.dist_eq] + have heq : ε/(2*(t-s))*(t-s)=ε/2 := by field_simp [ne_of_gt (sub_pos.mpr hst)] + rw [heq] at hb + exact hb.trans_lt (by linarith) + +end DirectionalTransience + +end + +section + +open MeasureTheory Filter +open scoped BigOperators Topology +namespace DirectionalTransience + +noncomputable def unitMesh (s t : unitInterval) (n j : ℕ) : unitInterval := + Set.projIcc 0 1 zero_le_one (realMesh s t n j) + +lemma realMesh_between {s t : ℝ} (hst : s ≤ t) {n j : ℕ} (hn : 0 < n) (hj : j ≤ n) : + s ≤ realMesh s t n j ∧ realMesh s t n j ≤ t := by + constructor + · simpa only [realMesh_zero] using (realMesh_mono hst n (Nat.zero_le j)) + · simpa only [realMesh_last s t hn] using (realMesh_mono hst n hj) + +lemma unitMesh_coe (s t : unitInterval) (hst : s ≤ t) {n j : ℕ} (hn : 0 < n) (hj : j ≤ n) : + (unitMesh s t n j:ℝ)=realMesh s t n j := by + have hb := realMesh_between hst hn hj + have hm : realMesh (s:ℝ) t n j ∈ unitInterval := ⟨s.property.1.trans hb.1,hb.2.trans t.property.2⟩ + simp only [unitMesh,Set.projIcc_of_mem zero_le_one hm] + +lemma unitMesh_between (s t : unitInterval) (hst : s ≤ t) {n j : ℕ} (hn : 0 < n) (hj : j ≤ n) : + s ≤ unitMesh s t n j ∧ unitMesh s t n j ≤ t := by + change (s:ℝ) ≤ (unitMesh s t n j:ℝ) ∧ (unitMesh s t n j:ℝ) ≤ t + rw [unitMesh_coe s t hst hn hj] + exact realMesh_between hst hn hj + +lemma unitMesh_zero (s t : unitInterval) (n : ℕ) : unitMesh s t n 0=s := by + simp only [unitMesh,realMesh_zero,Set.projIcc_of_mem zero_le_one s.property] + +lemma unitMesh_last (s t : unitInterval) {n : ℕ} (hn : 0 < n) : unitMesh s t n n=t := by + simp only [unitMesh,realMesh_last (s:ℝ) t hn,Set.projIcc_of_mem zero_le_one t.property] + +lemma unitMesh_sub (s t : unitInterval) (hst : s ≤ t) {n j : ℕ} (hn : 0 < n) (hj : j < n) : + (unitMesh s t n (j+1):ℝ)-(unitMesh s t n j:ℝ)=((t:ℝ)-s)/n := by + rw [unitMesh_coe s t hst hn (Nat.succ_le_of_lt hj),unitMesh_coe s t hst hn hj.le,realMesh_sub] + +lemma unitMesh_step_lt (s t : unitInterval) (hst : s < t) {n j : ℕ} (hn : 0 < n) (hj : j < n) : + unitMesh s t n j < unitMesh s t n (j+1) := by + have hh := unitMesh_sub s t hst.le hn hj + have hp : 0 < ((t:ℝ)-s)/(n:ℝ) := div_pos (sub_pos.mpr (show (s:ℝ) < t from hst)) + (Nat.cast_pos.mpr hn) + change (unitMesh s t n j:ℝ) < (unitMesh s t n (j+1):ℝ) + linarith + +end DirectionalTransience + +end + +section + +open Filter +open scoped BigOperators Topology +namespace DirectionalTransience + +lemma contraction_recurrence_error (z : ℕ → ℂ) (r : ℂ) (e : ℕ → ℝ) (n : ℕ) + (hr : ‖r‖ ≤ 1) (he : ∀ j < n, ‖z (j+1)-r*z j‖ ≤ e j) : + ‖z n-r^n*z 0‖ ≤ ∑ j ∈ Finset.range n, e j := by + induction n with + | zero => simp + | succ n ihn => + have hn := ihn (fun j hj => he j (Nat.lt_succ_of_lt hj)) + have heq : z (n+1)-r^(n+1)*z 0=(z (n+1)-r*z n)+r*(z n-r^n*z 0) := by + rw [pow_succ]; ring + rw [heq,Finset.sum_range_succ] + calc + _ ≤ ‖z (n+1)-r*z n‖+‖r‖*‖z n-r^n*z 0‖ := by + simpa only [norm_mul] using norm_add_le (z (n+1)-r*z n) (r*(z n-r^n*z 0)) + _ ≤ e n+‖z n-r^n*z 0‖ := add_le_add (he n (Nat.lt_succ_self n)) + ((mul_le_mul_of_nonneg_right hr (norm_nonneg _)).trans_eq (one_mul _)) + _ ≤ _ := by linarith + +lemma realEulerCoefficient_norm {lam δ : ℝ} (hlam : 0 ≤ lam) (hδ : 0 ≤ δ) (h : lam*δ ≤ 1) : + ‖(1-((lam*δ:ℝ):ℂ))‖ ≤ 1 := by + rw [← Complex.ofReal_one,← Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg (sub_nonneg.mpr h)] + nlinarith + +lemma scaled_exp_tendsto_zero {A L : ℝ} (hA : 0 < A) (hL : 0 < L) : + Tendsto (fun n : ℕ => (n:ℝ)*Real.exp (-A/(L/n))) atTop (𝓝 0) := by + have hat : Tendsto (fun n : ℕ => (A/L)*(n:ℝ)) atTop atTop := + tendsto_natCast_atTop_atTop.const_mul_atTop (div_pos hA hL) + have hh := ((Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero 1).comp hat).const_mul (L/A) + simp only [pow_one,mul_zero] at hh + apply hh.congr' + filter_upwards [eventually_gt_atTop 0] with n hn + have hn0 : (n:ℝ) ≠ 0 := by exact_mod_cast hn.ne' + have hid : -A/(L/(n:ℝ))= -(A/L*(n:ℝ)) := by field_simp + rw [hid] + simp only [Function.comp_apply] + field_simp + +lemma scaled_sqrt_cube_tendsto_zero {c L : ℝ} (hc : 0 ≤ c) (hL : 0 ≤ L) : + Tendsto (fun n : ℕ => (n:ℝ)*(Real.sqrt (c*(L/n)))^3) atTop (𝓝 0) := by + have hh : Tendsto (fun n : ℕ => c*(L/n)) atTop (𝓝 0) := by + simpa using (tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop : + Tendsto (fun n : ℕ => L/(n:ℝ)) atTop (𝓝 0)).const_mul c + have hs := (Real.continuous_sqrt.tendsto 0).comp hh + simp only [Real.sqrt_zero] at hs + have hj := hs.const_mul (c*L) + simp only [mul_zero] at hj + apply hj.congr' + filter_upwards [eventually_gt_atTop 0] with n hn + have hn0 : (n:ℝ) ≠ 0 := by exact_mod_cast hn.ne' + have hp : 0 ≤ c*(L/(n:ℝ)) := mul_nonneg hc (div_nonneg hL (Nat.cast_nonneg n)) + calc + c*L*Real.sqrt (c*(L/(n:ℝ))) = (n:ℝ)*(c*(L/(n:ℝ)))*Real.sqrt (c*(L/(n:ℝ))) := by field_simp + _ = _ := by + have hcube : (Real.sqrt (c*(L/(n:ℝ))))^3=c*(L/(n:ℝ))*Real.sqrt (c*(L/(n:ℝ))) := by + calc + _ = (Real.sqrt (c*(L/(n:ℝ))))^2*Real.sqrt (c*(L/(n:ℝ))) := by ring + _ = _ := by rw [Real.sq_sqrt hp] + rw [hcube] + ring + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/UniformSpreadSequences.lean b/lean/OAI/Probability/Ballisticity/Estimates/UniformSpreadSequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9e25adff846387d253714b82a7fee3b51441911 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/UniformSpreadSequences.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.EndpointPrefixConditionedReal +import OAI.Probability.Ballisticity.Estimates.NonCollapsedSums + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma uniform_spread_of_no_collapse {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F : ℝ → Ω → ℝ) + (hnot : ∀ (r : ℕ → ℝ), Tendsto r atTop atTop → + ¬ TendstoInMeasure μ (fun i ω => F (r i) ω/r i) atTop 0) : + ∃ c : ℝ, 0 < c ∧ ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → + c ≤ μ.real {ω | c*r < |F r ω|} := by + by_contra hn + push Not at hn + have hx (i : ℕ) : ∃ r : ℝ, (i:ℝ)+1 ≤ r ∧ μ.real {ω | dyadicCut i*r < |F r ω|} < dyadicCut i := + hn (dyadicCut i) (dyadicCut_pos i) ((i:ℝ)+1) (by positivity) + choose r hr hb using hx + have hrpos (i) : 0 < r i := lt_of_lt_of_le (by positivity) (hr i) + have hrinf : Tendsto r atTop atTop := tendsto_atTop_mono hr + ((tendsto_natCast_atTop_atTop : Tendsto (fun n : ℕ => (n:ℝ)) atTop atTop).atTop_add tendsto_const_nhds) + apply hnot r hrinf + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ dyadicCut_tendsto + filter_upwards [dyadicCut_tendsto.eventually (gt_mem_nhds hε)] with i hi + apply le_trans (measureReal_mono (μ := μ) ?_ (measure_ne_top _ _)) (hb i).le + intro ω hω + change ε ≤ |F (r i) ω/r i| at hω + change dyadicCut i*r i < |F (r i) ω| + rw [abs_div,abs_of_pos (hrpos i),le_div_iff₀ (hrpos i)] at hω + exact (mul_lt_mul_of_pos_right hi (hrpos i)).trans_le hω +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem transverse_uniform_spread {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ c : ℝ, 0 < c ∧ ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → + c ≤ (independentConditionedPairLaw ν (realPosition (step e))).real + {P | c*r < |firstHitPairGap (realPosition (step e)) f + ⌊fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r⌋₊ P|} := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let X := commonIncrementProcess ℓ f + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + apply uniform_spread_of_no_collapse μ + intro r hr hcollapse + let n := fun i => fluctuationScale μ (X 0) (r i) + have hI := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn : Tendsto n atTop atTop := + (fluctuationScale_tendsto μ (X 0) (measurable_commonIncrementProcess ℓ f 0) hI hne).comp hr + have hc := zero_lt_one.trans_le (commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)) + have hk := double_floor_ratio n hn hc + have herr := transverse_firstHit_fixed_sum_error ν hue e f hef htrans r hr + (fun i => ⌊n i⌋₊) (show (0:ℝ)≤1 by norm_num) (Eventually.of_forall fun i => by + change (⌊n i⌋₊:ℝ) ≤ 1*n i + rw [one_mul] + exact Nat.floor_le (fluctuationScale_nonneg _ _ _)) + have hs := inMeasure_sub_zero μ _ _ hcollapse herr + have hs' : TendstoInMeasure μ (fun i P => realPartialSum (fun j => X j P) + ⌊(⌊n i⌋₊:ℝ)/commonMeanWidth ν ℓ⌋₊/r i) atTop 0 := by + apply hs.congr_left + intro i + filter_upwards [] with P + dsimp only [X,ℓ,μ,n] + ring + exact iid_fluctuation_not_collapse μ X (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) hI hne r hr _ + (by positivity) hk hs' +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma bounded_mean_probability_lower {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Ω → ℝ) (hF : Measurable F) + (hF0 : ∀ ω, 0 ≤ F ω) (hF1 : ∀ ω, F ω ≤ 1) {q : ℝ} (hq : 0 ≤ q) + (hmean : q ≤ ∫ ω, F ω ∂μ) : + q/2 ≤ μ.real {ω | q/2 ≤ F ω} := by + let A := {ω | q/2 ≤ F ω} + have hA : MeasurableSet A := measurableSet_le measurable_const hF + have hFi : Integrable F μ := (integrable_const (1:ℝ)).mono' hF.aestronglyMeasurable + (ae_of_all _ fun ω => by rw [Real.norm_eq_abs,abs_of_nonneg (hF0 ω)]; exact hF1 ω) + have hAi : Integrable (A.indicator (fun _ => (1:ℝ))) μ := (integrable_const _).indicator hA + have hb := integral_mono hFi ((integrable_const (q/2)).add hAi) (fun ω => ?_) + · change (∫ ω, F ω ∂μ) ≤ ∫ ω, q/2+A.indicator (fun _ => (1:ℝ)) ω ∂μ at hb + rw [integral_add (integrable_const _) hAi,integral_indicator hA] at hb + simp only [integral_const,smul_eq_mul,one_mul,mul_one, + Measure.real,Measure.restrict_apply_univ,measure_univ, ENNReal.toReal_one] at hb + change q/2 ≤ μ.real A + change (∫ ω, F ω ∂μ) ≤ q/2+μ.real A at hb + linarith + · change F ω ≤ q/2+A.indicator (fun _ => (1:ℝ)) ω + by_cases hω : ω ∈ A + · rw [Set.indicator_of_mem hω] + linarith [hF1 ω] + · rw [Set.indicator_of_notMem hω,add_zero] + exact le_of_not_ge hω +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem uniform_raw_jump {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ a j R : ℝ, 0 < a ∧ 0 < j ∧ 0 < R ∧ ∀ r : ℝ, R ≤ r → + let H := ⌊fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r⌋₊ + 0 < H ∧ ∀ b : ℝ, ∃ s : ℝ, (s=1 ∨ s= -1) ∧ ∀ x : Lattice d, + j ≤ (environmentLaw ν).real {ω | j ≤ (quenchedKernel (ω,x)).real + (EndpointPrefix (realPosition (step e)) x H + {z | a*r < s*(signedCoordinate f (z-x)-b)})} := by + let ℓ := realPosition (step e) + let μ₁ := conditionedLaw ν ℓ + let n := fun r => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) r + have hp := noDrop_positive_of_directionallyTransient ν ℓ htrans + let : IsProbabilityMeasure μ₁ := conditionedLaw_probability ν ℓ (ne_of_gt hp) + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := independentConditionedPairLaw_probability ν ℓ (ne_of_gt hp) + let p := (annealedLaw ν).real (NoDrop ℓ 0) + have hp0 : 0 < p := ENNReal.toReal_pos (ne_of_gt hp) (measure_ne_top _ _) + obtain ⟨c,hc,R,hR,hspread⟩ := transverse_uniform_spread ν hue e f hef htrans + have hn : Tendsto n atTop atTop := fluctuationScale_tendsto _ _ + (measurable_commonIncrementProcess ℓ f 0) + (independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_nonzero ν hue e f hef htrans) + obtain ⟨R₁,hR₁⟩ := Filter.eventually_atTop.1 (hn.eventually (eventually_ge_atTop (1:ℝ))) + refine ⟨c/2,p*c/8,max R R₁,by positivity,by positivity,hR.trans_le (le_max_left _ _),fun r hr => ?_⟩ + have hrR := (le_max_left R R₁).trans hr + have hn1 := hR₁ r ((le_max_right R R₁).trans hr) + let H := ⌊n r⌋₊ + have hH : 0 < H := Nat.floor_pos.mpr hn1 + refine ⟨hH,fun b => ?_⟩ + have hsp : c ≤ (μ₁.prod μ₁).real + {P | 2*(c/2*r) < |signedCoordinate f (recordIndexPosition ℓ H P.1)-signedCoordinate f (recordIndexPosition ℓ H P.2)|} := by + have he : 2*(c/2*r)=c*r := by ring + simpa only [he,firstHitPairGap,independentConditionedPairLaw,μ₁,ℓ,H,n] using hspread r hrR + obtain ⟨s,hs,hdev⟩ := scalar_pair_tail_one_side μ₁ + (fun X => signedCoordinate f (recordIndexPosition ℓ H X)) b (c/2*r) c hsp + refine ⟨s,hs,fun x => ?_⟩ + let A := EndpointPrefix ℓ x H {z | c/2*r < s*(signedCoordinate f (z-x)-b)} + have hmean : p*c/4 ≤ (annealedFrom ν x).real A := by + have hh := endpointPrefix_conditioned_real ν e htrans x hH + {z | c/2*r < s*(signedCoordinate f z-b)} + have hm := mul_le_mul_of_nonneg_left hdev hp0.le + have hm' : p*c/4 ≤ p*μ₁.real {X | c/2*r < s*(signedCoordinate f (recordIndexPosition ℓ H X)-b)} := by + simpa only [mul_div_assoc] using hm + exact hm'.trans hh + let F := fun ω : Environment d => (quenchedKernel (ω,x)).real A + have hF : Measurable F := ((Kernel.measurable_coe _ (measurableSet_endpointPrefix ℓ x H _)).comp + (measurable_id.prodMk measurable_const)).ennreal_toReal + have hm : p*c/4 ≤ ∫ ω, F ω ∂environmentLaw ν := by + simpa only [F,annealedFrom_real_integral ν x A (measurableSet_endpointPrefix ℓ x H _)] using hmean + have hh := bounded_mean_probability_lower (environmentLaw ν) F hF + (fun _ => measureReal_nonneg) (fun _ => measureReal_le_one) (by positivity : 0 ≤ p*c/4) hm + have he : (p*c/4)/2=p*c/8 := by ring + simpa only [he,F,A] using hh +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/UpperPairPatch.lean b/lean/OAI/Probability/Ballisticity/Estimates/UpperPairPatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..cef1faabc36be5fd54553ab13f895ac3fbc9dd91 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/UpperPairPatch.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ProductTruncationError +import OAI.Probability.Ballisticity.Walk.OutwardKernelElementary + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def upperPairNeighborhood {d : ℕ} (e : Direction d) (a : ℝ) + (x : Lattice d × Lattice d) (N : ℕ) : Set (Lattice d) := + (LatticeBall x.1 N ∪ LatticeBall x.2 N) ∩ {y | a ≤ dot (realPosition y) (realPosition (step e))} + +lemma upperPairNeighborhood_finite {d : ℕ} (e : Direction d) (a : ℝ) + (x : Lattice d × Lattice d) (N : ℕ) : (upperPairNeighborhood e a x N).Finite := + ((latticeBall_finite x.1 N).union (latticeBall_finite x.2 N)).subset Set.inter_subset_left + +noncomputable def upperPairPatch {d : ℕ} (e : Direction d) (a : ℝ) + (x : Lattice d × Lattice d) (N : ℕ) (ω : Environment d) : Environment d := + fun y => if y ∈ upperPairNeighborhood e a x N then ω y else ω x.1 + +lemma upperPairPatch_measurable {d : ℕ} (e : Direction d) (a : ℝ) + (x : Lattice d × Lattice d) (hx : x ∈ PairAtHeight (realPosition (step e)) a) (N : ℕ) : + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x N)) _ (upperPairPatch e a x N) := by + have hx₁ : x.1 ∈ upperPairNeighborhood e a x N := by + refine ⟨Or.inl ?_,?_⟩ + · simp [LatticeBall] + · exact le_of_eq hx.1.symm + refine @Measurable.of_eval _ _ _ (rowSigma (upperPairNeighborhood e a x N)) _ _ ?_ + intro y + by_cases hy : y ∈ upperPairNeighborhood e a x N + · simpa only [upperPairPatch,ite_eq_left hy] using measurable_row_on hy + · simpa only [upperPairPatch,ite_eq_right hy] using measurable_row_on hx₁ + +lemma upperPairPatch_elliptic {d : ℕ} (e : Direction d) (a : ℝ) + (x : Lattice d × Lattice d) (N : ℕ) (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y g, κ ≤ (ω y).1 g) : + ∀ y g, κ ≤ ((upperPairPatch e a x N ω) y).1 g := by + intro y g + by_cases hy : y ∈ upperPairNeighborhood e a x N <;> + simp only [upperPairPatch,hy,ite_true,ite_false] <;> apply hκ + +lemma rawPairEndpointLaw_upper_patch_locality {d : ℕ} {κ : ℝ≥0} (hκ : 0 < κ) + (e : Direction d) {H : ℕ} (hH : 0 < H) {ε : ℝ≥0∞} (hε : 0 < ε) : + ∃ N : ℕ, ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∀ (ω : Environment d), (∀ y g, κ ≤ (ω y).1 g) → + ∀ S : Set (Lattice d × Lattice d), + rawPairEndpointLaw (realPosition (step e)) H ω x S ≤ + rawPairEndpointLaw (realPosition (step e)) H (upperPairPatch e a x N ω) x S+ε ∧ + rawPairEndpointLaw (realPosition (step e)) H (upperPairPatch e a x N ω) x S ≤ + rawPairEndpointLaw (realPosition (step e)) H ω x S+ε := by + obtain ⟨N,hN⟩ := rawPairEndpointLaw_uniform_locality hκ e hH hε + refine ⟨N,?_⟩ + intro a x hx ω hω S + let η : Environment d := fun y => if a ≤ dot (realPosition y) (realPosition (step e)) then ω y else ω x.1 + have hη : ∀ y g, κ ≤ (η y).1 g := by + intro y g + dsimp [η] + split_ifs <;> apply hω + have he : Set.EqOn η (upperPairPatch e a x N ω) (LatticeBall x.1 N ∪ LatticeBall x.2 N) := by + intro y hy + by_cases ha : a ≤ dot (realPosition y) (realPosition (step e)) + · simp [η,upperPairPatch,upperPairNeighborhood,hy,ha] + · simp [η,upperPairPatch,upperPairNeighborhood,ha] + have hsame : rawPairEndpointLaw (realPosition (step e)) H ω x = rawPairEndpointLaw (realPosition (step e)) H η x := by + apply rawPairEndpointLaw_upper_congr e H a x hx + intro y hy + change a ≤ dot (realPosition y) (realPosition (step e)) at hy + simp only [η,ite_eq_left hy] + rw [hsame] + exact hN η (upperPairPatch e a x N ω) hη (upperPairPatch_elliptic e a x N ω hω) x he S +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/VarianceTailDifference.lean b/lean/OAI/Probability/Ballisticity/Estimates/VarianceTailDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddcd7a1a160ebf1eb6b8c87e29b4445c03fac73c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/VarianceTailDifference.lean @@ -0,0 +1,179 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.NonCollapsedSums + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma truncated_variance_tail_difference {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (hS : Measurable S) {z : ℝ} (hz : 0 ≤ z) : + (3/4:ℝ)*z^2*μ.real {x | z < |S x|} ≤ + truncatedVariance μ S z-truncatedVariance μ S (z/2) := by + have hi (a : ℝ) := integrable_truncated_square μ S hS a + let E := {x | z < |S x|} + have hE : MeasurableSet E := measurableSet_lt measurable_const hS.abs + have hI : Integrable (E.indicator (fun _ => (3/4:ℝ)*z^2)) μ := (integrable_const _).indicator hE + have heq : (∫ x, E.indicator (fun _ => (3/4:ℝ)*z^2) x ∂μ) = (3/4:ℝ)*z^2*μ.real E := by + rw [integral_indicator hE] + simp only [integral_const,Measure.real,Measure.restrict_apply_univ,smul_eq_mul,mul_comm] + unfold truncatedVariance + rw [← heq,← integral_sub (hi z) (hi (z/2))] + apply integral_mono hI ((hi z).sub (hi (z/2))) + intro x + change E.indicator (fun _ => (3/4:ℝ)*z^2) x ≤ min ((S x)^2) (z^2)-min ((S x)^2) ((z/2)^2) + by_cases hx : x ∈ E + · rw [Set.indicator_of_mem hx] + have hh : z < |S x| := hx + rw [min_eq_right (by nlinarith [sq_abs (S x)] : z^2 ≤ (S x)^2), + min_eq_right (by nlinarith [sq_abs (S x)] : (z/2)^2 ≤ (S x)^2)] + ring_nf + rfl + · rw [Set.indicator_of_notMem hx] + exact sub_nonneg.mpr (min_le_min_left _ (by nlinarith : (z/2)^2 ≤ z^2)) + +lemma fluctuation_tail_difference {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) {r a : ℝ} (hr : 0 < r) (ha : 0 < a) : + fluctuationScale μ S r*μ.real {x | a*r < |S x|} ≤ + (4/(3*a^2))*((truncatedVariance μ S (a*r)-truncatedVariance μ S (a*r/2))/truncatedVariance μ S r) := by + have hh := truncated_variance_tail_difference μ S hS (mul_nonneg ha.le hr.le) + have hm := truncatedVariance_pos μ S hS hne hr + have ha2 : 0 < a^2 := sq_pos_of_pos ha + unfold fluctuationScale + rw [div_mul_eq_mul_div,div_le_iff₀ hm] + rw [mul_assoc,div_mul_cancel₀ _ (ne_of_gt hm)] + rw [div_mul_eq_mul_div,le_div_iff₀ (mul_pos (by norm_num : (0:ℝ)<3) ha2)] + nlinarith [hh] + +lemma dyadicCut_add (j k : ℕ) : dyadicCut (j+k) = dyadicCut j*dyadicCut k := by + exact pow_add _ _ _ +lemma dyadicCut_succ (j : ℕ) : dyadicCut (j+1) = dyadicCut j/2 := by + simp only [dyadicCut,pow_succ] + ring + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma dyadic_profile_gaussian_tail {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hne : 0 < μ {x | S x ≠ 0}) (r : ℕ → ℝ) (hr : ∀ n, 0 < r n) + (F : ℕ → ℝ) {F₀ : ℝ} (hF₀ : 0 < F₀) (hFle : ∀ j, F₀ ≤ F j) + (hF : ∀ j, Tendsto (fun n => truncatedVariance μ S (dyadicCut j*r n)/truncatedVariance μ S (r n)) atTop (𝓝 (F j))) + (hFlim : Tendsto F atTop (𝓝 F₀)) (k : ℕ) {δ : ℝ} (hδ : 0 < δ) : + ∀ᶠ j in atTop, ∀ᶠ n in atTop, + fluctuationScale μ S (dyadicCut j*r n)*μ.real {x | dyadicCut k*(dyadicCut j*r n) < |S x|} < δ := by + let B := fun j => (4/(3*(dyadicCut k)^2))*((F (j+k)-F (j+k+1))/F j) + have hB : Tendsto B atTop (𝓝 0) := by + have h1 : Tendsto (fun j => F (j+k)) atTop (𝓝 F₀) := hFlim.comp (tendsto_add_atTop_nat k) + have h2 : Tendsto (fun j => F (j+k+1)) atTop (𝓝 F₀) := hFlim.comp ((tendsto_add_atTop_nat 1).comp (tendsto_add_atTop_nat k)) + simpa only [B,Pi.div_apply,sub_self,zero_div,mul_zero] using tendsto_const_nhds.mul ((h1.sub h2).div hFlim (ne_of_gt hF₀)) + filter_upwards [hB.eventually (gt_mem_nhds hδ)] with j hj + have hm (n) : truncatedVariance μ S (r n) ≠ 0 := ne_of_gt (truncatedVariance_pos μ S hS hne (hr n)) + have hFj : F j ≠ 0 := ne_of_gt (hF₀.trans_le (hFle j)) + have hlim : Tendsto (fun n => (4/(3*(dyadicCut k)^2))* + ((truncatedVariance μ S (dyadicCut k*(dyadicCut j*r n))- + truncatedVariance μ S (dyadicCut k*(dyadicCut j*r n)/2))/ + truncatedVariance μ S (dyadicCut j*r n))) atTop (𝓝 (B j)) := by + have hh := ((((hF (j+k)).sub (hF (j+k+1))).div (hF j) hFj).const_mul (4/(3*(dyadicCut k)^2))) + convert hh using 1 + funext n + rw [dyadicCut_succ (j+k),dyadicCut_add] + congr 1 + have heq₁ : dyadicCut k*(dyadicCut j*r n) = dyadicCut j*dyadicCut k*r n := by ring + have heq₂ : dyadicCut k*(dyadicCut j*r n)/2 = (dyadicCut j*dyadicCut k/2)*r n := by ring + rw [heq₂,heq₁] + simp only [Pi.div_apply] + field_simp [hm n] + filter_upwards [hlim.eventually (gt_mem_nhds hj)] with n hn + exact (fluctuation_tail_difference μ S hS hne (mul_pos (dyadicCut_pos j) (hr n)) (dyadicCut_pos k)).trans_lt hn + +lemma isGaussianSequence_of_dyadic {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) + (hr0 : ∀ᶠ n in atTop, 0 ≤ r n) + (hGauss : ∀ k, Tendsto (fun n => fluctuationScale μ S (r n)*μ.real {x | dyadicCut k*r n < |S x|}) atTop (𝓝 0)) : + IsGaussianSequence μ S r := by + refine ⟨hr,?_⟩ + intro a ha + obtain ⟨k,hk⟩ := (dyadicCut_tendsto.eventually (gt_mem_nhds ha)).exists + apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds (hGauss k) + (Eventually.of_forall fun n => mul_nonneg (fluctuationScale_nonneg μ S _) measureReal_nonneg) + filter_upwards [hr0] with n hn + apply mul_le_mul_of_nonneg_left _ (fluctuationScale_nonneg μ S _) + apply measureReal_mono _ (measure_ne_top _ _) + intro x hx + exact (mul_le_mul_of_nonneg_right hk.le hn).trans_lt hx + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma double_gaussian_selection {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Ω → ℝ) + (z : ℕ → ℕ → ℝ) (hz : ∀ j, Tendsto (z j) atTop atTop) + (htail : ∀ k, ∀ δ : ℝ, 0 < δ → ∀ᶠ j in atTop, ∀ᶠ n in atTop, + fluctuationScale μ S (z j n)*μ.real {x | dyadicCut k*z j n < |S x|} < δ) + (bad : ℕ → ℕ → ℝ) {δ : ℝ} + (hbad : ¬ ∀ᶠ j in atTop, ∀ᶠ n in atTop, bad j n < δ) : + ∃ j n : ℕ → ℕ, Tendsto j atTop atTop ∧ + IsGaussianSequence μ S (fun i => z (j i) (n i)) ∧ + (∀ i, δ ≤ bad (j i) (n i)) := by + classical + have hbad' : ∀ J, ∃ j, J ≤ j ∧ ∀ N, ∃ n, N ≤ n ∧ δ ≤ bad j n := by + simpa only [eventually_atTop,not_exists,not_forall,Classical.not_imp,not_lt,exists_prop] using hbad + have hex (i : ℕ) : ∃ j n, i ≤ j ∧ (i:ℝ)+1 ≤ z j n ∧ δ ≤ bad j n ∧ + ∀ k ≤ i, fluctuationScale μ S (z j n)*μ.real {x | dyadicCut k*z j n < |S x|} < 1/((i:ℝ)+1) := by + have ht : ∀ᶠ j in atTop, ∀ k : Fin (i+1), ∀ᶠ n in atTop, + fluctuationScale μ S (z j n)*μ.real {x | dyadicCut (k:ℕ)*z j n < |S x|} < 1/((i:ℝ)+1) := + eventually_all.mpr (fun k => htail k _ (by positivity)) + obtain ⟨J,hJ⟩ := eventually_atTop.mp ht + obtain ⟨j,hji,hbadj⟩ := hbad' (max i J) + have hev : ∀ᶠ n in atTop, (i:ℝ)+1 ≤ z j n ∧ ∀ k : Fin (i+1), + fluctuationScale μ S (z j n)*μ.real {x | dyadicCut (k:ℕ)*z j n < |S x|} < 1/((i:ℝ)+1) := + ((hz j).eventually_ge_atTop _).and (eventually_all.mpr (hJ j ((le_max_right ..).trans hji))) + obtain ⟨N,hN⟩ := eventually_atTop.mp hev + obtain ⟨n,hn,hbn⟩ := hbadj N + refine ⟨j,n,(le_max_left ..).trans hji,(hN n hn).1,hbn,?_⟩ + intro k hk + exact (hN n hn).2 ⟨k,by omega⟩ + choose j n hj hz0 hbadn htailn using hex + have hjtop : Tendsto j atTop atTop := tendsto_atTop_mono hj tendsto_id + have hztop : Tendsto (fun i => z (j i) (n i)) atTop atTop := by + apply tendsto_atTop_mono (fun i : ℕ => (by linarith [hz0 i] : (i:ℝ) ≤ z (j i) (n i))) + exact tendsto_natCast_atTop_atTop + refine ⟨j,n,hjtop,?_,hbadn⟩ + apply isGaussianSequence_of_dyadic μ S _ hztop + (Eventually.of_forall fun i => by have := hz0 i; linarith) + intro k + have hlim : Tendsto (fun i : ℕ => 1/((i:ℝ)+1)) atTop (𝓝 (0:ℝ)) := by + apply tendsto_one_div_add_atTop_nhds_zero_nat + apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hlim + (Eventually.of_forall fun i => mul_nonneg (fluctuationScale_nonneg μ S _) measureReal_nonneg) + filter_upwards [eventually_ge_atTop k] with i hi + exact (htailn i k hi).le + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/VisibleFailure.lean b/lean/OAI/Probability/Ballisticity/Estimates/VisibleFailure.lean new file mode 100644 index 0000000000000000000000000000000000000000..57b0dc37c7fe30222be6c7163925d6fd705f2453 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/VisibleFailure.lean @@ -0,0 +1,326 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.RegularPath + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def VisibleFailure {d : ℕ} (height : Lattice d → ℤ) (h B : ℤ) : Set (Path d) := + {X | ∃ a b c, X ∈ FirstLayerHit height h a ∧ + X ∈ FirstLayerHit height (h+B) c ∧ a ≤ b ∧ b < c ∧ height (X b) < h} + +lemma measurableSet_visibleFailure {d : ℕ} (height : Lattice d → ℤ) (h B : ℤ) : + MeasurableSet (VisibleFailure height h B) := by + simp only [VisibleFailure,Set.ofPred_exists,Set.ofPred_and] + refine MeasurableSet.iUnion fun a => MeasurableSet.iUnion fun b => MeasurableSet.iUnion fun c => ?_ + exact (measurableSet_firstLayerHit height h a).inter + ((measurableSet_firstLayerHit height (h+B) c).inter + ((MeasurableSet.const (a ≤ b)).inter ((MeasurableSet.const (b < c)).inter + (measurableSet_lt ((measurable_of_countable height).comp (measurable_pi_apply b)) measurable_const)))) + +lemma visibleFailure_prefix {d : ℕ} (height : Lattice d → ℤ) (h B H : ℤ) + (hH : h+B ≤ H) (n : ℕ) (X Y : Path d) + (hx : X ∈ FirstLayerHit height H n) (hy : Y ∈ FirstLayerHit height H n) + (hxy : ∀ j ≤ n, X j = Y j) : + X ∈ VisibleFailure height h B ↔ Y ∈ VisibleFailure height h B := by + have aux (X Y : Path d) (hx : X ∈ FirstLayerHit height H n) + (hxy : ∀ j ≤ n, X j = Y j) (hX : X ∈ VisibleFailure height h B) : + Y ∈ VisibleFailure height h B := by + obtain ⟨a,b,c,ha,hc,hab,hbc,hb⟩ := hX + have hcn : c ≤ n := by + by_contra hn + have hh := hc.2 n (by omega) + rw [hx.1] at hh + omega + have han : a ≤ n := by omega + refine ⟨a,b,c,(firstLayerHit_prefix height h a X Y (fun j hj => hxy j (hj.trans han))).mp ha, + (firstLayerHit_prefix height (h+B) c X Y (fun j hj => hxy j (hj.trans hcn))).mp hc,hab,hbc,?_⟩ + simpa only [← hxy b (by omega)] using hb + exact ⟨aux X Y hx hxy,aux Y X hy (fun j hj => (hxy j hj).symm)⟩ + +lemma future_truth_not_visible {d : ℕ} (ℓ : Vector d) (height : Lattice d → ℤ) + (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) (h B : ℤ) + (n : ℕ) (X : Path d) (hx : X ∈ FirstLayerHit height h n) + (ht : X ∈ FutureNoDrop ℓ n) : X ∉ VisibleFailure height h B := by + rintro ⟨a,b,c,ha,_,hab,_,hb⟩ + have he : a = n := by + by_contra he + exact Set.disjoint_left.mp (firstLayerHit_disjoint height h he) ha hx + subst a + have hh := ht (b-n) + rw [Nat.add_sub_of_le hab,hproj,hproj,hx.1] at hh + exact (not_le_of_gt hb) (by exact_mod_cast hh) + +def VisibleHistory {d : ℕ} (height : Lattice d → ℤ) (H B : ℤ) (m : ℕ) : Set (Path d × Path d) := + {P | ∀ j < m, P.1 ∈ VisibleFailure height (H+j*B) B ∨ P.2 ∈ VisibleFailure height (H+j*B) B} + +lemma measurableSet_visibleHistory {d : ℕ} (height : Lattice d → ℤ) (H B : ℤ) (m : ℕ) : + MeasurableSet (VisibleHistory height H B m) := by + simp only [VisibleHistory,Set.ofPred_forall,Set.ofPred_or] + exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + ((measurableSet_visibleFailure height (H+j*B) B).preimage measurable_fst).union + ((measurableSet_visibleFailure height (H+j*B) B).preimage measurable_snd) + +lemma visibleHistory_at_height_prefix {d : ℕ} (height : Lattice d → ℤ) (H B : ℤ) + (hB : 0 ≤ B) (m : ℕ) (q : ℕ × ℕ) : + PairPrefixDetermined q.1 q.2 (VisibleHistory height H B m ∩ + (FirstLayerHit height (H+m*B) q.1 ×ˢ FirstLayerHit height (H+m*B) q.2)) := by + intro P Q h1 h2 + have he1 := firstLayerHit_prefix height (H+m*B) q.1 P.1 Q.1 h1 + have he2 := firstLayerHit_prefix height (H+m*B) q.2 P.2 Q.2 h2 + constructor + · rintro ⟨hP,hP1,hP2⟩ + refine ⟨?_,he1.mp hP1,he2.mp hP2⟩ + intro j hj + have hle : H+(j:ℤ)*B+B ≤ H+(m:ℤ)*B := by + have hcast : (j:ℤ)+1 ≤ m := by exact_mod_cast hj + nlinarith + exact ((visibleFailure_prefix height (H+j*B) B (H+m*B) hle q.1 P.1 Q.1 hP1 (he1.mp hP1) h1).or + (visibleFailure_prefix height (H+j*B) B (H+m*B) hle q.2 P.2 Q.2 hP2 (he2.mp hP2) h2)).mp (hP j hj) + · rintro ⟨hQ,hQ1,hQ2⟩ + refine ⟨?_,he1.mpr hQ1,he2.mpr hQ2⟩ + intro j hj + have hle : H+(j:ℤ)*B+B ≤ H+(m:ℤ)*B := by + have hcast : (j:ℤ)+1 ≤ m := by exact_mod_cast hj + nlinarith + exact ((visibleFailure_prefix height (H+j*B) B (H+m*B) hle q.1 P.1 Q.1 (he1.mpr hQ1) hQ1 h1).or + (visibleFailure_prefix height (H+j*B) B (H+m*B) hle q.2 P.2 Q.2 (he2.mpr hQ2) hQ2 h2)).mpr (hQ j hj) + +theorem shared_visible_history_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (height : Lattice d → ℤ) (hproj : ∀ z, dot (realPosition z) ℓ = (height z : ℝ)) + (hstep : ∀ z e, height (z+step e) ≤ height z+1) + (x y : Lattice d) (H B : ℤ) (hx : height x < H) (hy : height y < H) (hB : 0 ≤ B) + (c : ℝ) (hc : 0 ≤ c) (hc1 : c ≤ 1) + (htruth : ∀ u v, ENNReal.ofReal c ≤ sharedNoDropMass ν ℓ u v) (m : ℕ) : + (sharedPairLaw ν x y).real (VisibleHistory height H B m) ≤ (1-c)^m := by + let μ := sharedPairLaw ν x y + have hrec (k : ℕ) : μ.real (VisibleHistory height H B (k+1)) ≤ + (1-c) * μ.real (VisibleHistory height H B k) := by + let T := H+(k:ℤ)*B + let A := fun q : ℕ × ℕ => VisibleHistory height H B k ∩ + (FirstLayerHit height T q.1 ×ˢ FirstLayerHit height T q.2) + let F := fun q : ℕ × ℕ => A q ∩ (FutureNoDrop ℓ q.1 ×ˢ FutureNoDrop ℓ q.2) + have hAm q : MeasurableSet (A q) := (measurableSet_visibleHistory height H B k).inter + ((measurableSet_firstLayerHit height T q.1).prod (measurableSet_firstLayerHit height T q.2)) + have hFm q : MeasurableSet (F q) := (hAm q).inter + ((measurableSet_futureNoDrop ℓ q.1).prod (measurableSet_futureNoDrop ℓ q.2)) + have hdisA : Pairwise (fun q r => Disjoint (A q) (A r)) := fun _ _ h => + (firstLayerHit_pair_disjoint height T h).mono Set.inter_subset_right Set.inter_subset_right + have hdisF : Pairwise (fun q r => Disjoint (F q) (F r)) := fun _ _ h => + (hdisA h).mono Set.inter_subset_left Set.inter_subset_left + have hxT : height x < T := by dsimp [T]; nlinarith [Int.natCast_nonneg k] + have hyT : height y < T := by dsimp [T]; nlinarith [Int.natCast_nonneg k] + have hcover : μ (⋃ q, A q) = μ (VisibleHistory height H B k) := by + apply measure_congr + filter_upwards [shared_pair_layer_hits ν ℓ htrans height hproj hstep x y T hxT hyT] with P hP + apply propext + constructor + · intro hh + obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hh + exact hq.1 + · intro hh + obtain ⟨n,hn⟩ := hP.1 + obtain ⟨l,hl⟩ := hP.2 + exact Set.mem_iUnion.mpr ⟨(n,l),hh,hn,hl⟩ + have hlow : ENNReal.ofReal c * μ (VisibleHistory height H B k) ≤ μ (⋃ q, F q) := by + rw [← hcover,measure_iUnion hdisA hAm,measure_iUnion hdisF hFm,← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro q + by_cases hq : 0 < q.1 ∧ 0 < q.2 + · apply shared_pair_record_event_noDrop_lower ν ℓ x y (ENNReal.ofReal c) htruth _ _ hq.1 hq.2 + (A q) (visibleHistory_at_height_prefix height H B hB k q) + intro P hP + exact ⟨firstLayerHit_record ℓ height hproj T _ _ hP.2.1, + firstLayerHit_record ℓ height hproj T _ _ hP.2.2, + by rw [hproj,hproj,hP.2.1.1,hP.2.2.1]⟩ + · have hz : μ (A q) = 0 := by + apply measure_eq_zero_iff_ae_notMem.mpr + filter_upwards [shared_pair_ae ν x y (RegularPath ℓ x) (RegularPath ℓ y) + (measurableSet_regularPath ℓ x) (measurableSet_regularPath ℓ y) + (annealedFrom_regularPath ν ℓ htrans x) (annealedFrom_regularPath ν ℓ htrans y)] with P hP hh + have h1 := hh.2.1.1 + have h2 := hh.2.2.1 + have hn : q.1 = 0 ∨ q.2 = 0 := by omega + rcases hn with hn | hn + · rw [hn,hP.1.1] at h1; omega + · rw [hn,hP.2.1] at h2; omega + rw [hz,mul_zero]; exact zero_le + have hdis : Disjoint (VisibleHistory height H B (k+1)) (⋃ q, F q) := by + apply Set.disjoint_left.mpr + intro P hp hf + obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hf + rcases hp k (by omega) with hh | hh + · exact future_truth_not_visible ℓ height hproj T B q.1 P.1 hq.1.2.1 hq.2.1 hh + · exact future_truth_not_visible ℓ height hproj T B q.2 P.2 hq.1.2.2 hq.2.2 hh + have hsub : VisibleHistory height H B (k+1) ∪ (⋃ q, F q) ⊆ VisibleHistory height H B k := by + intro P hp + rcases hp with hp | hp + · intro j hj; exact hp j (by omega) + · obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hp; exact hq.1.1 + have hsum : μ (VisibleHistory height H B (k+1)) + ENNReal.ofReal c * μ (VisibleHistory height H B k) ≤ + μ (VisibleHistory height H B k) := by + calc + _ ≤ μ (VisibleHistory height H B (k+1)) + μ (⋃ q, F q) := by gcongr + _ = μ (VisibleHistory height H B (k+1) ∪ (⋃ q, F q)) := + (measure_union hdis (MeasurableSet.iUnion hFm)).symm + _ ≤ _ := measure_mono hsub + have hr := ENNReal.toReal_mono (measure_ne_top _ _) hsum + rw [ENNReal.toReal_add (measure_ne_top _ _) + (ENNReal.mul_ne_top ENNReal.ofReal_ne_top (measure_ne_top _ _)), + ENNReal.toReal_mul,ENNReal.toReal_ofReal hc] at hr + change μ.real (VisibleHistory height H B (k+1)) + c * μ.real (VisibleHistory height H B k) ≤ μ.real (VisibleHistory height H B k) at hr + linarith + induction m with + | zero => simp [VisibleHistory,Measure.real] + | succ m ih => + calc + _ ≤ (1-c) * μ.real (VisibleHistory height H B m) := hrec m + _ ≤ (1-c) * (1-c)^m := mul_le_mul_of_nonneg_left ih (by linarith) + _ = (1-c)^(m+1) := by ring + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/VisitTrials.lean b/lean/OAI/Probability/Ballisticity/Estimates/VisitTrials.lean new file mode 100644 index 0000000000000000000000000000000000000000..55dcc78a2bdca78e2d92bade14cfcdea8d4313d2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/VisitTrials.lean @@ -0,0 +1,171 @@ +import Mathlib +import OAI.Probability.Ballisticity.Renewal.Regeneration + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def visitCount {d : ℕ} (X : Path d) (y : Lattice d) (n : ℕ) : ℕ := + ∑ j ∈ Finset.range n, if X j=y then 1 else 0 + +lemma visitCount_succ {d : ℕ} (X : Path d) (y : Lattice d) (n : ℕ) : + visitCount X y (n+1)=visitCount X y n+(if X n=y then 1 else 0) := by + exact Finset.sum_range_succ _ n + +lemma visitCount_mono {d : ℕ} (X : Path d) (y : Lattice d) : Monotone (visitCount X y) := by + apply monotone_nat_of_le_succ + intro n + rw [visitCount_succ] + omega + +lemma visitCount_exists {d : ℕ} (X : Path d) (y : Lattice d) (n k : ℕ) + (hk : k < visitCount X y n) : ∃ j < n, X j=y ∧ visitCount X y j=k := by + induction n with + | zero => simp [visitCount] at hk + | succ n ih => + by_cases hh : k < visitCount X y n + · obtain ⟨j,hj,hX,hc⟩ := ih hh + exact ⟨j,by omega,hX,hc⟩ + · rw [visitCount_succ] at hk + split_ifs at hk with hX + · exact ⟨n,by omega,hX,by omega⟩ + · omega + +lemma measurable_visitCount {d : ℕ} (y : Lattice d) (n : ℕ) : + Measurable (fun X : Path d => visitCount X y n) := by + unfold visitCount + exact Finset.measurable_sum _ fun j _ => measurable_const.ite + (measurableSet_eq_fun (measurable_pi_apply j) measurable_const) measurable_const + +lemma visitCount_prefix {d : ℕ} (X Y : Path d) (y : Lattice d) (n : ℕ) + (h : ∀ j < n, X j=Y j) : visitCount X y n=visitCount Y y n := by + apply Finset.sum_congr rfl + intro j hj + rw [h j (Finset.mem_range.mp hj)] + +def VisitPrefix {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k n : ℕ) : + Set (Path d) := {X | X 0=x ∧ X n=y ∧ (∀ j ≤ n, X j∈S) ∧ visitCount X y n=k} + +def VisitReached {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k : ℕ) : + Set (Path d) := ⋃ n, VisitPrefix x S y k n + +lemma measurableSet_visitPrefix {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k n : ℕ) : + MeasurableSet (VisitPrefix x S y k n) := by + unfold VisitPrefix + simp only [Set.ofPred_and,Set.ofPred_forall] + exact (measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter + ((measurableSet_eq_fun (measurable_pi_apply n) measurable_const).inter + ((MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => (measurable_pi_apply j) ((Set.to_countable S).measurableSet)).inter + (measurableSet_eq_fun (measurable_visitCount y n) measurable_const))) + +lemma visitPrefix_prefix {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k n : ℕ) : + PrefixDetermined n (VisitPrefix x S y k n) := by + intro X Y hXY + have hc := visitCount_prefix X Y y n (fun j hj => hXY j hj.le) + simp only [VisitPrefix,Set.mem_ofPred_eq,hXY 0 (Nat.zero_le n),hXY n le_rfl,hc] + have hh : (∀ j ≤ n, X j∈S) ↔ ∀ j ≤ n, Y j∈S := by + apply forall_congr'; intro j + apply forall_congr'; intro hj + rw [hXY j hj] + rw [hh] + +lemma measurableSet_visitReached {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k : ℕ) : + MeasurableSet (VisitReached x S y k) := MeasurableSet.iUnion (measurableSet_visitPrefix x S y k) + +lemma visitPrefix_disjoint {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k : ℕ) : + Pairwise (fun n m => Disjoint (VisitPrefix x S y k n) (VisitPrefix x S y k m)) := by + have hh (n m : ℕ) (hnm : n < m) (X : Path d) (hn : X ∈ VisitPrefix x S y k n) + (hm : X ∈ VisitPrefix x S y k m) : False := by + have hc := visitCount_mono X y (show n+1 ≤ m by omega) + rw [visitCount_succ,hn.2.1,ite_eq_left rfl,hn.2.2.2,hm.2.2.2] at hc + omega + intro n m hnm + apply Set.disjoint_left.mpr + intro X hn hm + rcases lt_or_gt_of_ne hnm with hlt | hgt + · exact hh n m hlt X hn hm + · exact hh m n hgt X hm hn + +lemma visitReached_succ_subset {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) (k : ℕ) : + VisitReached x S y (k+1) ⊆ VisitReached x S y k := by + intro X hX + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp hX + obtain ⟨n,hn,hny,hc⟩ := visitCount_exists X y m k (by rw [hm.2.2.2]; omega) + exact Set.mem_iUnion.mpr ⟨n,hm.1,hny,fun j hj => hm.2.2.1 j (hj.trans hn.le),hc⟩ + +def ReturnIn {d : ℕ} (S : Set (Lattice d)) (y : Lattice d) : Set (Path d) := + {X | ∃ n, 0 < n ∧ X n=y ∧ ∀ j ≤ n, X j∈S} + +lemma measurableSet_returnIn {d : ℕ} (S : Set (Lattice d)) (y : Lattice d) : + MeasurableSet (ReturnIn S y) := by + unfold ReturnIn + simp only [Set.ofPred_exists,Set.ofPred_and,Set.ofPred_forall] + exact MeasurableSet.iUnion fun n => (MeasurableSet.const _).inter + ((measurableSet_eq_fun (measurable_pi_apply n) measurable_const).inter + (MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + (measurable_pi_apply j) ((Set.to_countable S).measurableSet))) + +lemma visitReached_succ_return {d : ℕ} (x : Lattice d) (S : Set (Lattice d)) (y : Lattice d) + (k n : ℕ) (X : Path d) (hn : X ∈ VisitPrefix x S y k n) + (hnext : X ∈ VisitReached x S y (k+1)) : + (fun j => X (n+j)) ∈ ReturnIn S y := by + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp hnext + have hnm : n < m := by + by_contra hh + have hc := visitCount_mono X y (by omega : m ≤ n) + rw [hn.2.2.2,hm.2.2.2] at hc + omega + refine ⟨m-n,by omega,by simpa only [Nat.add_sub_of_le hnm.le] using hm.2.1,?_⟩ + intro j hj + exact hm.2.2.1 (n+j) (by omega) + +lemma visitReached_contraction {d : ℕ} (ω : Environment d) (x : Lattice d) + (S : Set (Lattice d)) (y : Lattice d) (k : ℕ) (A : Set (Path d)) + (hA : MeasurableSet A) (hdis : Disjoint A (ReturnIn S y)) : + (quenchedKernel (ω,x)).real (VisitReached x S y (k+1)) ≤ + (1-(quenchedKernel (ω,y)).real A)*(quenchedKernel (ω,x)).real (VisitReached x S y k) := by + let μ := quenchedKernel (ω,x) + have hg := stopping_prefix_favourable_gain μ (VisitPrefix x S y k) (VisitReached x S y (k+1)) + (quenchedKernel (ω,y) A) (visitPrefix_prefix x S y k) (measurableSet_visitPrefix x S y k) + (visitPrefix_disjoint x S y k) (measurableSet_visitReached x S y (k+1)) + (visitReached_succ_subset x S y k) (by + intro n f hf + let F := (fun X : Path d => fun i => X (n+i)) ⁻¹' A ∩ pathCylinder f n + refine ⟨F,(hA.preimage (by fun_prop)).inter (measurableSet_pathCylinder f n),Set.inter_subset_right,?_,?_⟩ + · apply Set.disjoint_left.mpr + intro X hnext hF + have hpre := (visitPrefix_prefix x S y k n X f hF.2).mpr hf + exact Set.disjoint_left.mp hdis hF.1 (visitReached_succ_return x S y k n X hpre hnext) + · simpa only [hf.2.1] using quenched_prefix_future ω x f hf.1 n hA) + have hr := ENNReal.toReal_mono (measure_ne_top μ _) hg + rw [ENNReal.toReal_add (measure_ne_top μ _) + (ENNReal.mul_ne_top (measure_ne_top μ _) (measure_ne_top (quenchedKernel (ω,y)) _)),ENNReal.toReal_mul] at hr + change μ.real (VisitReached x S y (k+1))+μ.real (VisitReached x S y k)*(quenchedKernel (ω,y)).real A ≤ + μ.real (VisitReached x S y k) at hr + change μ.real _ ≤ (1-(quenchedKernel (ω,y)).real A)*μ.real _ + nlinarith + +lemma visitReached_geometric {d : ℕ} (ω : Environment d) (x : Lattice d) + (S : Set (Lattice d)) (y : Lattice d) (k : ℕ) (A : Set (Path d)) + (hA : MeasurableSet A) (hdis : Disjoint A (ReturnIn S y)) (δ : ℝ) + (hδ : δ ≤ (quenchedKernel (ω,y)).real A) : + (quenchedKernel (ω,x)).real (VisitReached x S y k) ≤ (1-δ)^k := by + have hp : (quenchedKernel (ω,y)).real A ≤ 1 := measureReal_le_one + induction k with + | zero => simp + | succ k ih => + calc + _ ≤ (1-(quenchedKernel (ω,y)).real A)*(quenchedKernel (ω,x)).real (VisitReached x S y k) := + visitReached_contraction ω x S y k A hA hdis + _ ≤ (1-δ)*(1-δ)^k := mul_le_mul (by linarith) ih measureReal_nonneg (by linarith) + _ = _ := by rw [pow_succ]; ring + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WeakAddTendsto.lean b/lean/OAI/Probability/Ballisticity/Estimates/WeakAddTendsto.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee0009c6f2bac57fd744fb9b3aa7263091d49e2a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WeakAddTendsto.lean @@ -0,0 +1,161 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.DominatedTranslationBounded +import OAI.Probability.Ballisticity.Walk.GaussianPathFiniteLawSingleton + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma weak_add_tendsto {μ ν : ℕ → ProbabilityMeasure ℝ} {M N : ProbabilityMeasure ℝ} + (hμ : Tendsto μ atTop (𝓝 M)) (hν : Tendsto ν atTop (𝓝 N)) : + Tendsto (fun i => ((μ i).prod (ν i)).map + (fun pair => pair.1 + pair.2)) atTop + (𝓝 ((M.prod N).map (fun pair => pair.1 + pair.2))) := by + exact (ProbabilityMeasure.continuous_map (continuous_fst.add continuous_snd)).tendsto + (M.prod N) |>.comp + (ProbabilityMeasure.continuous_prod.tendsto (M,N) |>.comp (hμ.prodMk_nhds hν)) + +lemma gaussian_prod_add (v w : ℝ≥0) : + ((gaussianReal 0 v).prod (gaussianReal 0 w)).map (fun p : ℝ × ℝ => p.1+p.2) = + gaussianReal 0 (v+w) := by + simpa only [Measure.conv,zero_add] using (gaussianReal_conv_gaussianReal (m₁ := 0) (m₂ := 0) (v₁ := v) (v₂ := w)) + +lemma centered_height_additive_sequence {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : ℕ → Ω → ℝ) + (hF : ∀ h, Measurable (F h)) (b : ℕ → ℝ) (r n : ℕ → ℝ) + (hn : ∀ i, 0 < n i) (T V : ℝ) (hT : 0 < T) (hV : 0 ≤ V) + (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : TendstoInDistribution (fun i x => heightPolygon (fun h => F h x-b h) (r i) (n i) T) + atTop id (fun _ => μ) W) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (T*V) I) + (p : ℝ) (hp : 0 < p) + (hd : ∀ k j : ℕ, 0 < k → 0 < j → + ENNReal.ofReal p • (μ.prod μ).map (fun P => F k P.1+F j P.2) ≤ μ.map (F (k+j))) + (k j : ℕ → ℕ) (hk : ∀ i, 0 < k i) (hj : ∀ i, 0 < j i) + (hkn : ∀ i, ((k i+j i : ℕ) : ℝ) ≤ T*n i) + {s t : ℝ} (hs : Tendsto (fun i => (k i:ℝ)/n i) atTop (𝓝 s)) + (ht : Tendsto (fun i => (j i:ℝ)/n i) atTop (𝓝 t)) : + Tendsto (fun i => (b (k i+j i)-b (k i)-b (j i))/r i) atTop (𝓝 0) := by + let G := fun h x => F h x-b h + have hG (h : ℕ) : Measurable (G h) := (hF h).sub_const _ + have hs0 : 0 ≤ s := le_of_tendsto_of_tendsto tendsto_const_nhds hs + (Eventually.of_forall fun i => div_nonneg (Nat.cast_nonneg _) (hn i).le) + have ht0 : 0 ≤ t := le_of_tendsto_of_tendsto tendsto_const_nhds ht + (Eventually.of_forall fun i => div_nonneg (Nat.cast_nonneg _) (hn i).le) + have hkbound (i : ℕ) : (k i:ℝ) ≤ T*n i := le_trans (by exact_mod_cast Nat.le_add_right (k i) (j i)) (hkn i) + have hjbound (i : ℕ) : (j i:ℝ) ≤ T*n i := le_trans (by exact_mod_cast Nat.le_add_left (j i) (k i)) (hkn i) + have hks := height_path_gaussian_eval μ G hG r n hn T hT V W hlim hW k hkbound hs + have hjs := height_path_gaussian_eval μ G hG r n hn T hT V W hlim hW j hjbound ht + have hksj := height_path_gaussian_eval μ G hG r n hn T hT V W hlim hW + (fun i => k i+j i) hkn (show Tendsto (fun i => ((k i+j i:ℕ):ℝ)/n i) atTop (𝓝 (s+t)) by + simpa only [Nat.cast_add,add_div] using hs.add ht) + let A : ℕ → ProbabilityMeasure ℝ := fun i => ⟨μ.map (fun x => G (k i) x/r i), + inferInstance⟩ + let B : ℕ → ProbabilityMeasure ℝ := fun i => ⟨μ.map (fun x => G (j i) x/r i), + inferInstance⟩ + let C : ℕ → ProbabilityMeasure ℝ := fun i => ⟨μ.map (fun x => G (k i+j i) x/r i), + inferInstance⟩ + have hA : Tendsto A atTop (𝓝 ⟨gaussianReal 0 (Real.toNNReal (V*s)),inferInstance⟩) := by + simpa only [Measure.map_id] using hks.tendsto + have hB : Tendsto B atTop (𝓝 ⟨gaussianReal 0 (Real.toNNReal (V*t)),inferInstance⟩) := by + simpa only [Measure.map_id] using hjs.tendsto + have hC : Tendsto C atTop (𝓝 ⟨gaussianReal 0 (Real.toNNReal (V*(s+t))),inferInstance⟩) := by + simpa only [Measure.map_id] using hksj.tendsto + let D : ℕ → ProbabilityMeasure ℝ := fun i => ((A i).prod (B i)).map + (fun pair => pair.1 + pair.2) + have hvar : Real.toNNReal (V*s)+Real.toNNReal (V*t) = Real.toNNReal (V*(s+t)) := by + rw [← Real.toNNReal_add (mul_nonneg hV hs0) (mul_nonneg hV ht0),mul_add] + have hD : Tendsto D atTop (𝓝 ⟨gaussianReal 0 (Real.toNNReal (V*(s+t))),inferInstance⟩) := by + have hh := weak_add_tendsto hA hB + have he : ProbabilityMeasure.map (ProbabilityMeasure.prod + (⟨gaussianReal 0 (Real.toNNReal (V*s)),inferInstance⟩ : ProbabilityMeasure ℝ) + (⟨gaussianReal 0 (Real.toNNReal (V*t)),inferInstance⟩ : ProbabilityMeasure ℝ)) + (fun pair => pair.1 + pair.2) = + (⟨gaussianReal 0 (Real.toNNReal (V*(s+t))),inferInstance⟩ : ProbabilityMeasure ℝ) := by + apply Subtype.ext + exact (gaussian_prod_add _ _).trans (congrArg (gaussianReal 0) hvar) + rw [he] at hh + exact hh + apply weak_gaussian_domination_center _ hD hC hp + intro i + let a := fun x : ℝ => (x-b (k i+j i))/r i + have ha : Measurable a := by fun_prop + have hh := Measure.map_mono (hd (k i) (j i) (hk i) (hj i)) ha + have hsum : Measurable (fun P : Ω × Ω => F (k i) P.1+F (j i) P.2) := + ((hF (k i)).comp measurable_fst).add ((hF (j i)).comp measurable_snd) + rw [Measure.map_smul _ ha.aemeasurable,Measure.map_map ha hsum, + Measure.map_map ha (hF (k i+j i))] at hh + have he : (D i : Measure ℝ).map (fun x => x-(b (k i+j i)-b (k i)-b (j i))/r i) = + (μ.prod μ).map (a ∘ (fun P => F (k i) P.1+F (j i) P.2)) := by + change (((μ.map _).prod (μ.map _)).map _).map _ = _ + rw [Measure.map_prod_map _ _ ((hG _).div_const _) ((hG _).div_const _), + Measure.map_map (by fun_prop) (by fun_prop),Measure.map_map (by fun_prop) (by fun_prop)] + congr 1 + funext P + dsimp [G,a] + ring + rw [he] + exact hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WeakTailTransfer.lean b/lean/OAI/Probability/Ballisticity/Estimates/WeakTailTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e6322f729480c28ffb9936d096559f42160bdaa --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WeakTailTransfer.lean @@ -0,0 +1,93 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma weak_probability_open_le_limsup {X : Type*} [MeasurableSpace X] + [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] + (μs : ℕ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (hμ : Tendsto μs atTop (𝓝 μ)) (G : Set X) (hG : IsOpen G) : + (μ : Measure X).real G ≤ limsup (fun n => (μs n : Measure X).real G) atTop := by + have hh := ProbabilityMeasure.le_liminf_measure_open_of_tendsto hμ hG + have he : liminf (fun n => (μs n : Measure X).real G) atTop = + (liminf (fun n => (μs n : Measure X) G) atTop).toReal := + ENNReal.liminf_toReal_eq (by norm_num : (1:ℝ≥0∞) ≠ ∞) + (Eventually.of_forall fun n => (prob_le_one : (μs n : Measure X) G ≤ 1)) + have hb : IsBoundedUnder (· ≤ ·) atTop (fun n => (μs n : Measure X).real G) := + isBoundedUnder_of ⟨1,fun n => measureReal_le_one⟩ + have hc : IsBoundedUnder (· ≥ ·) atTop (fun n => (μs n : Measure X).real G) := + isBoundedUnder_of ⟨0,fun n => measureReal_nonneg⟩ + have hfin : (liminf (fun n => (μs n : Measure X) G) atTop) ≠ ∞ := by + apply ne_top_of_le_ne_top (by norm_num : (1:ℝ≥0∞)≠∞) + exact (liminf_le_limsup).trans (limsup_le_of_le (h := Eventually.of_forall fun n => (prob_le_one : (μs n : Measure X) G ≤ 1))) + have hi : (μ : Measure X).real G ≤ liminf (fun n => (μs n : Measure X).real G) atTop := by + rw [he] + exact ENNReal.toReal_mono hfin hh + exact hi.trans (liminf_le_limsup hb hc) + +lemma weak_probability_limsup_closed_le {X : Type*} [MeasurableSpace X] + [TopologicalSpace X] [OpensMeasurableSpace X] [HasOuterApproxClosed X] + (μs : ℕ → ProbabilityMeasure X) (μ : ProbabilityMeasure X) + (hμ : Tendsto μs atTop (𝓝 μ)) (G : Set X) (hG : IsClosed G) : + limsup (fun n => (μs n : Measure X).real G) atTop ≤ (μ : Measure X).real G := by + have hh := ProbabilityMeasure.limsup_measure_closed_le_of_tendsto hμ hG + change limsup (fun n => ((μs n : Measure X) G).toReal) atTop ≤ _ + rw [ENNReal.limsup_toReal_eq (f := atTop) (by norm_num : (1:ℝ≥0∞)≠∞) + (Eventually.of_forall fun n => (prob_le_one : (μs n : Measure X) G ≤ 1))] + exact ENNReal.toReal_mono (measure_ne_top _ _) hh + +lemma weak_tail_comparison + (μs νs : ℕ → ProbabilityMeasure unitInterval) (μ ν : ProbabilityMeasure unitInterval) + (hμ : Tendsto μs atTop (𝓝 μ)) (hν : Tendsto νs atTop (𝓝 ν)) + {C D : ℝ} (hC : 0 ≤ C) (hD : 0 < D) + (ht : ∀ u > 0, u < 1 → + limsup (fun n => (μs n : Measure unitInterval).real {x | u < (x:ℝ)}) atTop ≤ + C * limsup (fun n => (νs n : Measure unitInterval).real {y | u/D < (y:ℝ)}) atTop) : + ∀ u > 0, (μ : Measure unitInterval) {x | u < (x:ℝ)} ≤ + ENNReal.ofReal C * (ν : Measure unitInterval) {y | u/(2*D) < (y:ℝ)} := by + intro u hu + by_cases hu1 : u < 1 + · have hop : IsOpen {x : unitInterval | u < (x:ℝ)} := isOpen_lt continuous_const continuous_subtype_val + have hcl : IsClosed {x : unitInterval | u/D ≤ (x:ℝ)} := isClosed_le continuous_const continuous_subtype_val + have hsub : ∀ n, (νs n : Measure unitInterval).real {y | u/D < (y:ℝ)} ≤ + (νs n : Measure unitInterval).real {y | u/D ≤ (y:ℝ)} := + fun n => measureReal_mono (by intro y hy; exact (show u/D < (y:ℝ) from hy).le) (measure_ne_top _ _) + have hs := limsup_le_limsup (Eventually.of_forall hsub) + (isBoundedUnder_of (r := (· ≥ ·)) ⟨0,fun n => measureReal_nonneg⟩).isCoboundedUnder_le + (show IsBoundedUnder (· ≤ ·) atTop (fun n => (νs n : Measure unitInterval).real {y | u/D ≤ (y:ℝ)}) from + isBoundedUnder_of ⟨1,fun n => measureReal_le_one⟩) + have hre : (μ : Measure unitInterval).real {x | u < (x:ℝ)} ≤ + C * (ν : Measure unitInterval).real {y | u/(2*D) < (y:ℝ)} := by + refine (weak_probability_open_le_limsup μs μ hμ _ hop).trans ((ht u hu hu1).trans ?_) + apply mul_le_mul_of_nonneg_left _ hC + refine hs.trans ((weak_probability_limsup_closed_le νs ν hν _ hcl).trans ?_) + apply measureReal_mono (h₂ := measure_ne_top _ _) + intro y hy + have hh : u/(2*D) < u/D := by + apply (div_lt_div_iff₀ (by positivity) hD).mpr + nlinarith + exact hh.trans_le hy + have hh := ENNReal.ofReal_le_ofReal hre + simpa only [ENNReal.ofReal_mul hC,ofReal_measureReal (measure_ne_top _ _)] using hh + · have he : {x : unitInterval | u < (x:ℝ)} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro x hx + exact (not_lt.mpr (x.2.2.trans (le_of_not_gt hu1))) hx + rw [he,measure_empty] + exact bot_le + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WeakVaryingParameter.lean b/lean/OAI/Probability/Ballisticity/Estimates/WeakVaryingParameter.lean new file mode 100644 index 0000000000000000000000000000000000000000..83bcbe6eb3f52cf25b4bb2b772e87c20b4419e6d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WeakVaryingParameter.lean @@ -0,0 +1,44 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma weak_map_varying_parameter {E A B : Type*} + [MetricSpace E] [MeasurableSpace E] [BorelSpace E] + [MetricSpace A] [MeasurableSpace A] [BorelSpace A] + [TopologicalSpace B] [MeasurableSpace B] [BorelSpace B] + [SecondCountableTopology E] [SecondCountableTopology A] + (μ : ℕ → ProbabilityMeasure E) (ν : ProbabilityMeasure E) (hμ : Tendsto μ atTop (𝓝 ν)) + (a : ℕ → A) (a₀ : A) (ha : Tendsto a atTop (𝓝 a₀)) + (f : E × A → B) (hf : Continuous f) : + Tendsto (fun i => (μ i).map (fun point => f (point, a i))) + atTop (𝓝 (ν.map (fun point => f (point, a₀)))) := by + have hh := (ProbabilityMeasure.continuous_map hf).tendsto (ν.prod (diracProba a₀)) |>.comp + (ProbabilityMeasure.continuous_prod.tendsto (ν,diracProba a₀) |>.comp + (hμ.prodMk_nhds (continuous_diracProba.tendsto a₀ |>.comp ha))) + have hid (V : ProbabilityMeasure E) (u : A) : + (V.prod (diracProba u)).map f = + V.map (fun point => f (point, u)) := by + apply Subtype.ext + change ((V : Measure E).prod (Measure.dirac u)).map f = _ + rw [Measure.prod_dirac,Measure.map_map hf.measurable (by fun_prop)] + rfl + change Tendsto (fun i => ((μ i).prod (diracProba (a i))).map f) + atTop (𝓝 ((ν.prod (diracProba a₀)).map f)) at hh + simpa only [hid] using hh + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WeightedConditioned.lean b/lean/OAI/Probability/Ballisticity/Estimates/WeightedConditioned.lean new file mode 100644 index 0000000000000000000000000000000000000000..66227a66c81096eed4e0e27a09a140c0384ee77f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WeightedConditioned.lean @@ -0,0 +1,242 @@ +import Mathlib +import OAI.Probability.Ballisticity.Coupling.WeightedAnnealed +import OAI.Probability.Ballisticity.Estimates.FirstHighRecord + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def weightedConditioned {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) : Measure (Path d) := + (annealedLaw ν (NoDrop ℓ 0))⁻¹ • (weightedAnnealed ν g).restrict (NoDrop ℓ 0) + +lemma weightedConditioned_le {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) (hg : Measurable g) (hgle : ∀ ω, g ω ≤ 1) : + weightedConditioned ν ℓ g ≤ conditionedLaw ν ℓ := by + intro A + change (annealedLaw ν (NoDrop ℓ 0))⁻¹ * (weightedAnnealed ν g).restrict (NoDrop ℓ 0) A ≤ + (annealedLaw ν (NoDrop ℓ 0))⁻¹ * (annealedLaw ν).restrict (NoDrop ℓ 0) A + apply mul_le_mul_right + exact (Measure.restrict_mono le_rfl (weightedAnnealed_le ν g hg hgle)) A + +lemma weightedConditioned_apply_subset {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (g : Environment d → ℝ≥0∞) (A : Set (Path d)) (hA : MeasurableSet A) + (hAD : A ⊆ NoDrop ℓ 0) : + weightedConditioned ν ℓ g A = (annealedLaw ν (NoDrop ℓ 0))⁻¹ * weightedAnnealed ν g A := by + simp only [weightedConditioned,Measure.smul_apply,Measure.restrict_apply hA, + Set.inter_eq_left.mpr hAD,smul_eq_mul] + +lemma weightedConditioned_highWord_factor {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (J : ℝ) (hJ : 0 ≤ J) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (g : Environment d → ℝ≥0∞) + (hg : @Measurable _ _ (rowSigma {z | dot (realPosition z) ℓ ≤ J}) _ g) + (w : List (Direction d)) (A : Set (Path d)) (hA : MeasurableSet A) : + weightedConditioned ν ℓ g (HighWordEvent ℓ J w ∩ highSuffix ℓ J ⁻¹' A) = + weightedConditioned ν ℓ g (HighWordEvent ℓ J w) * conditionedLaw ν ℓ A := by + have hg' : Measurable g := hg.mono (rowSigma_le _) le_rfl + by_cases hw : AdmissibleHighWord ℓ J w + · let F := fun X : Path d => fun j => X (w.length+j)-wordPath 0 w w.length + have hF : Measurable F := by fun_prop + have hFD : ∀ B : Set (Path d), B ⊆ NoDrop ℓ 0 → + F ⁻¹' B ∩ wordCylinder 0 w ⊆ NoDrop ℓ 0 := by + intro B hBD X hX + exact ((highWord_characterization ℓ J w X hX.2).mpr ⟨hw,hBD hX.1⟩).1 + have hrec : ∀ y ∈ wordDepartures 0 w, + dot (realPosition y) ℓ < dot (realPosition (wordPath 0 w w.length)) ℓ := by + intro y hy + obtain ⟨j,hj,rfl⟩ := (wordDepartures_mem_iff 0 y w).mp hy + exact hw.1 j hj + have hf (B : Set (Path d)) (hB : MeasurableSet B) (hBD : B ⊆ NoDrop ℓ 0) : + weightedConditioned ν ℓ g (F ⁻¹' B ∩ wordCylinder 0 w) = + (∫⁻ ω, g ω * ENNReal.ofReal (wordWeight ω 0 w) ∂environmentLaw ν) * + conditionedLaw ν ℓ B := by + rw [weightedConditioned_apply_subset ν ℓ g _ ((hB.preimage hF).inter + (measurableSet_wordCylinder 0 w)) (hFD B hBD), + weightedAnnealed_apply ν g hg' _ ((hB.preimage hF).inter (measurableSet_wordCylinder 0 w)), + weighted_record_suffix ν ℓ w J hrec hw.2.1 g hg B hB hBD, + conditionedLaw_apply_of_subset ν ℓ B hB hBD] + ac_rfl + have he : HighWordEvent ℓ J w ∩ highSuffix ℓ J ⁻¹' A = + F ⁻¹' (A ∩ NoDrop ℓ 0) ∩ wordCylinder 0 w := by + ext X + constructor + · rintro ⟨hX,hXA⟩ + have hXD := (Set.ext_iff.mp (highWordEvent_eq ℓ J w hw) X).mp hX + exact ⟨⟨by simpa only [Set.mem_preimage,highSuffix_on_highWordEvent ℓ J hJ w X hX] using hXA,hXD.1⟩,hXD.2⟩ + · rintro ⟨⟨hXA,hXD⟩,hc⟩ + have hX := (Set.ext_iff.mp (highWordEvent_eq ℓ J w hw) X).mpr ⟨hXD,hc⟩ + exact ⟨hX,by simpa only [Set.mem_preimage,highSuffix_on_highWordEvent ℓ J hJ w X hX] using hXA⟩ + have hmass : weightedConditioned ν ℓ g (HighWordEvent ℓ J w) = + ∫⁻ ω, g ω * ENNReal.ofReal (wordWeight ω 0 w) ∂environmentLaw ν := by + rw [highWordEvent_eq ℓ J w hw,hf _ (measurableSet_noDrop ℓ 0) Set.Subset.rfl] + have hD : conditionedLaw ν ℓ (NoDrop ℓ 0) = 1 := by + rw [conditionedLaw_apply_of_subset ν ℓ _ (measurableSet_noDrop ℓ 0) Set.Subset.rfl] + exact ENNReal.inv_mul_cancel hp (measure_ne_top _ _) + rw [hD,mul_one] + rw [he,hf _ (hA.inter (measurableSet_noDrop ℓ 0)) Set.inter_subset_right, + conditionedLaw_inter_noDrop ν ℓ A hA,hmass] + · simp [highWordEvent_empty ℓ J w hw] + +lemma weightedConditioned_highSuffix {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (J : ℝ) (hJ : 0 ≤ J) + (g : Environment d → ℝ≥0∞) + (hg : @Measurable _ _ (rowSigma {z | dot (realPosition z) ℓ ≤ J}) _ g) + (hgle : ∀ ω, g ω ≤ 1) : + (weightedConditioned ν ℓ g).map (highSuffix ℓ J) = + weightedConditioned ν ℓ g Set.univ • conditionedLaw ν ℓ := by + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hle := weightedConditioned_le ν ℓ g (hg.mono (rowSigma_le _) le_rfl) hgle + have he : ∀ᵐ X ∂weightedConditioned ν ℓ g, ∃ w, X ∈ HighWordEvent ℓ J w := + (Measure.absolutelyContinuous_of_le hle).ae_le (conditioned_highWord_exists ν ℓ htrans J) + have hpart (B : Set (Path d)) (hB : MeasurableSet B) : + weightedConditioned ν ℓ g B = + ∑' w : List (Direction d), weightedConditioned ν ℓ g (HighWordEvent ℓ J w ∩ B) := by + rw [← measure_iUnion (fun u v huv => (highWordEvent_disjoint ℓ J huv).mono + Set.inter_subset_left Set.inter_subset_left) + (fun w => (measurableSet_highWordEvent ℓ J w).inter hB)] + apply measure_congr + filter_upwards [he] with X ⟨w,hw⟩ + apply propext + exact ⟨fun hX => Set.mem_iUnion.mpr ⟨w,hw,hX⟩, + fun hX => (Set.mem_iUnion.mp hX).choose_spec.2⟩ + apply Measure.ext + intro A hA + rw [Measure.map_apply (measurable_highSuffix ℓ J hJ) hA, + hpart _ (hA.preimage (measurable_highSuffix ℓ J hJ))] + simp_rw [weightedConditioned_highWord_factor ν ℓ J hJ hp g hg _ A hA] + rw [ENNReal.tsum_mul_right,Measure.smul_apply,smul_eq_mul] + have hm := hpart Set.univ MeasurableSet.univ + simp only [Set.inter_univ] at hm + rw [← hm] + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma levyProkhorov_map_distance_le {Ω E : Type*} [MeasurableSpace Ω] + [MetricSpace E] [MeasurableSpace E] [BorelSpace E] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F G : Ω → E) + (hF : Measurable F) (hG : Measurable G) {δ : ℝ} (hδ : 0 ≤ δ) + (hbad : μ {ω | δ ≤ dist (F ω) (G ω)} ≤ ENNReal.ofReal δ) : + levyProkhorovDist (μ.map F) (μ.map G) ≤ δ := by + apply levyProkhorovDist_le_of_forall_le _ _ hδ + intro ε B hε hB + rw [Measure.map_apply hF hB,Measure.map_apply hG Metric.isOpen_thickening.measurableSet] + have hs : F ⁻¹' B ⊆ G ⁻¹' Metric.thickening ε B ∪ {ω | δ ≤ dist (F ω) (G ω)} := by + intro ω hω + by_cases hh : δ ≤ dist (F ω) (G ω) + · exact Or.inr hh + · exact Or.inl (Metric.mem_thickening_iff.mpr ⟨F ω,hω,by + rw [dist_comm]; exact (lt_of_not_ge hh).trans hε⟩) + exact (measure_mono hs).trans ((measure_union_le _ _).trans + (add_le_add le_rfl (hbad.trans (ENNReal.ofReal_le_ofReal hε.le)))) + +lemma weak_map_of_varying_close {Ω E : Type*} [MeasurableSpace Ω] + [MetricSpace E] [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (F G : ℕ → Ω → E) (hF : ∀ i, Measurable (F i)) (hG : ∀ i, Measurable (G i)) + (ν : ProbabilityMeasure E) + (hlim : Tendsto (fun i => ProbabilityMeasure.map (⟨μ i, inferInstance⟩ : ProbabilityMeasure Ω) (F i)) + atTop (𝓝 ν)) + (hclose : ∀ ε, 0 < ε → Tendsto (fun i => (μ i).real + {ω | ε ≤ dist (F i ω) (G i ω)}) atTop (𝓝 0)) : + Tendsto (fun i => ProbabilityMeasure.map (⟨μ i, inferInstance⟩ : ProbabilityMeasure Ω) (G i)) + atTop (𝓝 ν) := by + let A i := ProbabilityMeasure.map (⟨μ i, inferInstance⟩ : ProbabilityMeasure Ω) (F i) + let B i := ProbabilityMeasure.map (⟨μ i, inferInstance⟩ : ProbabilityMeasure Ω) (G i) + have hd : Tendsto (fun i => dist (LevyProkhorov.ofMeasure (A i)) + (LevyProkhorov.ofMeasure (B i))) atTop (𝓝 0) := by + apply Metric.tendsto_nhds.2 + intro ε hε + filter_upwards [(hclose (ε/2) (by positivity)).eventually_lt_const + (by positivity : 0 < ε/2)] with i hi + have hb : μ i {ω | ε/2 ≤ dist (F i ω) (G i ω)} ≤ ENNReal.ofReal (ε/2) := by + have hh := ENNReal.ofReal_le_ofReal hi.le + simpa only [Measure.real,ENNReal.ofReal_toReal (measure_ne_top _ _)] using hh + have h := levyProkhorov_map_distance_le (μ i) (F i) (G i) (hF i) (hG i) (by positivity) hb + rw [Real.dist_eq,sub_zero,abs_of_nonneg dist_nonneg] + exact h.trans_lt (half_lt_self hε) + have hA := LevyProkhorov.continuous_ofMeasure_probabilityMeasure.tendsto ν |>.comp hlim + have hB := hA.congr_dist hd + exact LevyProkhorov.continuous_toMeasure_probabilityMeasure.tendsto + (LevyProkhorov.ofMeasure ν) |>.comp hB + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WeightedTestPerturbation.lean b/lean/OAI/Probability/Ballisticity/Estimates/WeightedTestPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..81c779e6a8bd64882de432965fe27d8dec911a0d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WeightedTestPerturbation.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BoundarySuffixIdentity + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma weighted_test_perturbation {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (X Y : ℕ → Ω → ℝ) (hX : ∀ i, Measurable (X i)) (hY : ∀ i, Measurable (Y i)) + (F : ℕ → Ω → ℝ) (hF : ∀ i, Measurable (F i)) (C : ℝ) (hC : 0 ≤ C) + (hFb : ∀ i ω, ‖F i ω‖ ≤ C) + (f : ℝ →ᵇ ℝ) (hf : UniformContinuous f) + (hclose : ∀ ε : ℝ, 0 < ε → Tendsto (fun i => (μ i).real {ω | ε ≤ |X i ω-Y i ω|}) atTop (𝓝 0)) : + Tendsto (fun i => ∫ ω, F i ω*(f (X i ω)-f (Y i ω)) ∂μ i) atTop (𝓝 0) := by + apply Metric.tendsto_nhds.mpr + intro η hη + let a := η/(2*(C+1)) + have ha : 0 < a := by dsimp [a]; positivity + obtain ⟨δ,hδ,hδf⟩ := Metric.uniformContinuous_iff.mp hf a ha + have hh : Tendsto (fun i => C*(2*‖f‖)*(μ i).real {ω | δ ≤ |X i ω-Y i ω|}) atTop (𝓝 0) := by + simpa using (hclose δ hδ).const_mul (C*(2*‖f‖)) + filter_upwards [hh.eventually_lt_const (show (0:ℝ)<η/2 by positivity)] with i hi + let A := {ω | δ ≤ |X i ω-Y i ω|} + have hA : MeasurableSet A := measurableSet_le measurable_const ((hX i).sub (hY i)).abs + have hg : Integrable (fun ω => C*a+A.indicator (fun _ => C*(2*‖f‖)) ω) (μ i) := + (integrable_const _).add ((integrable_const _).indicator hA) + have hbound : ∀ᵐ ω ∂μ i, ‖F i ω*(f (X i ω)-f (Y i ω))‖ ≤ + C*a+A.indicator (fun _ => C*(2*‖f‖)) ω := by + exact Eventually.of_forall fun ω => by + rw [norm_mul] + by_cases h : ω ∈ A + · rw [Set.indicator_of_mem h] + have hb := (norm_sub_le (f (X i ω)) (f (Y i ω))).trans + (add_le_add (f.norm_coe_le_norm _) (f.norm_coe_le_norm _)) + have hb' := mul_le_mul (hFb i ω) hb (norm_nonneg _) hC + nlinarith + · rw [Set.indicator_of_notMem h,add_zero] + have hdist : dist (X i ω) (Y i ω) < δ := by + simpa only [A,Set.mem_ofPred_eq,not_le,Real.dist_eq] using h + have hb : ‖f (X i ω)-f (Y i ω)‖ ≤ a := by + simpa only [Real.norm_eq_abs,Real.dist_eq] using (hδf hdist).le + exact mul_le_mul (hFb i ω) hb (norm_nonneg _) hC + have hIntegrable := hg.mono' ((hF i).mul ((f.continuous.measurable.comp (hX i)).sub + (f.continuous.measurable.comp (hY i)))).aestronglyMeasurable hbound + have hnorm := (norm_integral_le_integral_norm + (fun sample => F i sample*(f (X i sample)-f (Y i sample)))).trans + (integral_mono_ae hIntegrable.norm hg hbound) + rw [integral_add (integrable_const _) ((integrable_const _).indicator hA), + integral_const,integral_indicator_const _ hA] at hnorm + simp only [probReal_univ,smul_eq_mul,one_mul] at hnorm + rw [Real.dist_eq,sub_zero] + have hac : C*a < η/2 := by + dsimp [a] + have hden : 0 < 2*(C+1) := by positivity + rw [← mul_div_assoc,div_lt_iff₀ hden] + nlinarith + change C*(2*‖f‖)*(μ i).real A < η/2 at hi + rw [Real.norm_eq_abs] at hnorm + nlinarith + +lemma weighted_centered_test_transfer {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (X Y : ℕ → Ω → ℝ) (hX : ∀ i, Measurable (X i)) (hY : ∀ i, Measurable (Y i)) + (F : ℕ → Ω → ℝ) (hF : ∀ i, Measurable (F i)) (C : ℝ) (hC : 0 ≤ C) + (hFb : ∀ i ω, ‖F i ω‖ ≤ C) (f : ℝ →ᵇ ℝ) (hf : UniformContinuous f) (m : ℝ) + (hclose : ∀ ε : ℝ, 0 < ε → Tendsto (fun i => (μ i).real {ω | ε ≤ |X i ω-Y i ω|}) atTop (𝓝 0)) + (hlim : Tendsto (fun i => ∫ ω, F i ω*(f (Y i ω)-m) ∂μ i) atTop (𝓝 0)) : + Tendsto (fun i => ∫ ω, F i ω*(f (X i ω)-m) ∂μ i) atTop (𝓝 0) := by + have hi (Z : ℕ → Ω → ℝ) (hZ : ∀ i, Measurable (Z i)) (i : ℕ) : + Integrable (fun ω => F i ω*(f (Z i ω)-m)) (μ i) := by + apply Integrable.of_bound ((hF i).mul ((f.continuous.measurable.comp (hZ i)).sub_const m)).aestronglyMeasurable + (C*(‖f‖+‖m‖)) + exact Eventually.of_forall fun ω => by + change ‖F i ω*(f (Z i ω)-m)‖ ≤ _ + rw [norm_mul] + exact mul_le_mul (hFb i ω) ((norm_sub_le _ _).trans + (add_le_add (f.norm_coe_le_norm _) le_rfl)) (norm_nonneg _) hC + have hp := weighted_test_perturbation μ X Y hX hY F hF C hC hFb f hf hclose + have he (i : ℕ) : (∫ ω, F i ω*(f (X i ω)-m) ∂μ i) = + (∫ ω, F i ω*(f (Y i ω)-m) ∂μ i)+(∫ ω, F i ω*(f (X i ω)-f (Y i ω)) ∂μ i) := by + have heq : (fun ω => F i ω*(f (X i ω)-f (Y i ω))) = + (fun ω => F i ω*(f (X i ω)-m)-F i ω*(f (Y i ω)-m)) := by funext ω; ring + rw [heq,integral_sub (hi X hX i) (hi Y hY i)] + ring + simp_rw [he] + simpa using hlim.add hp + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +namespace DirectionalTransience + +lemma measurable_centeredFirstHit_variable_start {d : ℕ} (ℓ : Vector d) + (f : Direction d) (θ r : ℝ) (k : ℕ) : + Measurable (fun q : Path d × Lattice d => centeredFirstHit ℓ f θ r k q.2 q.1) := by + apply measurable_from_prod_countable_left + intro z + exact measurable_centeredFirstHit ℓ f θ r k z + +lemma measurable_boundary_terminal_side {d : ℕ} (ℓ : Vector d) (L : ℝ) (b : Bool) : + Measurable (fun P : Path d × Path d => pairSide b (boundaryTerminal (boundaryData ℓ L P))) := + (measurable_of_countable (fun z : BoundaryData d => pairSide b (boundaryTerminal z))).comp + (measurable_boundaryData ℓ L) + +lemma measurable_boundary_centeredFirstHit {d : ℕ} (ℓ : Vector d) + (f : Direction d) (θ r : ℝ) (k : ℕ) (L : ℝ) (b : Bool) : + Measurable (fun P : Path d × Path d => centeredFirstHit ℓ f θ r k + (pairSide b (boundaryTerminal (boundaryData ℓ L P))) + (pairSide b (boundarySuffix ℓ L P))) := by + apply Measurable.div_const + apply Measurable.sub_const + apply (measurable_of_countable (signedCoordinate f)).comp + apply (measurable_recordIndexPosition ℓ k).comp + apply Measurable.of_eval + intro j + exact ((measurable_pi_apply j).comp ((measurable_pairSide b).comp + (measurable_boundarySuffix ℓ L))).sub (measurable_boundary_terminal_side ℓ L b) + +theorem shared_deterministic_increment_decorrelation {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (hn : ∀ i, 0 < fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (T : ℝ) (hT : 0 < T) (k : ℕ → ℕ) + (hk : ∀ i, (k i:ℝ) ≤ T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) + (t : ℝ) (hkt : Tendsto (fun i => (k i:ℝ)/fluctuationScale + (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) atTop (𝓝 t)) + (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) + (H : ℕ → ℕ) (hH : ∀ i, 0 < H i) + (F : ℕ → BoundaryData d → ℝ) (C : ℝ) (hC : 0 ≤ C) (hF : ∀ i j, ‖F i j‖ ≤ C) + (G : ℝ →ᵇ ℝ) (hG : UniformContinuous G) (b : Bool) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let D := fun i => boundaryData ℓ ((signedHeight e (x i)+H i : ℤ) : ℝ) + Tendsto (fun i => ∫ P, F i (D i P) * + (G (centeredHitIncrement ℓ f (recordMedianSlope ν ℓ hp f (r i)) (r i) (H i) (k i) + (pairSide b (x i,y i)) (pairSide b P))- + (∫ z, G z ∂gaussianReal 0 (Real.toNNReal (t/(2*commonMeanWidth ν ℓ))))) + ∂sharedConditionedPairLaw ν ℓ (x i) (y i)) atTop (𝓝 0) := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + let μ := fun i => sharedConditionedPairLaw ν ℓ (x i) (y i) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => sharedConditionedPairLaw_probability ν ℓ _ _ + (ne_of_gt (sharedNoDropMass_positive ν hue ℓ (signed_direction_unit e) htrans _ _)) + let D := fun i => boundaryData ℓ ((signedHeight e (x i)+H i : ℤ) : ℝ) + let S := fun i => boundarySuffix ℓ ((signedHeight e (x i)+H i : ℤ) : ℝ) + let X := fun i P => centeredHitIncrement ℓ f (θ i) (r i) (H i) (k i) + (pairSide b (x i,y i)) (pairSide b P) + let Y := fun i P => centeredFirstHit ℓ f (θ i) (r i) (k i) + (pairSide b (boundaryTerminal (D i P))) (pairSide b (S i P)) + have hX (i : ℕ) : Measurable (X i) := + (measurable_centeredHitIncrement ℓ f (θ i) (r i) (H i) (k i) _).comp (measurable_pairSide b) + have hY (i : ℕ) : Measurable (Y i) := + measurable_boundary_centeredFirstHit ℓ f (θ i) (r i) (k i) _ b + exact weighted_centered_test_transfer μ X Y hX hY (fun i P => F i (D i P)) + (fun i => (measurable_of_countable (F i)).comp (measurable_boundaryData _ _)) C hC + (fun i P => hF i (D i P)) G hG _ + (fun ε hε => shared_boundary_increment_replacement ν hue e f htrans x y hxy H k hH θ r hr.1 b ε hε) + (shared_boundary_endpoint_decorrelation ν hue e f hef htrans r hr hn T hT k hk t hkt + x y hxy H hH F C hC hF G b) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WidthGridTail.lean b/lean/OAI/Probability/Ballisticity/Estimates/WidthGridTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..102c1be2f1a6d81569aee32021d5ec8b05ddf3da --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WidthGridTail.lean @@ -0,0 +1,193 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GridTrials +import OAI.Probability.Ballisticity.Crossings.CrossingSurplus + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +def LateGridFailure {d : ℕ} (e : Direction d) (B j : ℕ) : Set (Path d) := + ⋃ n, (({X : Path d | X 0=0} ∩ FirstLayerHit (signedHeight e) (j*B:ℕ) n) ∩ + FutureEvent (fun x => Cross (realPosition (step e)) x B) n) \ FutureNoDrop (realPosition (step e)) n + +lemma measurableSet_lateGridFailure {d : ℕ} (e : Direction d) (B j : ℕ) : + MeasurableSet (LateGridFailure e B j) := by + apply MeasurableSet.iUnion + intro n + exact (((measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter + (measurableSet_firstLayerHit _ _ _)).inter + (measurableSet_futureEvent _ (fun x => measurableSet_cross _ _ _) _)).diff + (measurableSet_futureNoDrop _ _) + +lemma measureReal_iUnion_disjoint {α : Type*} [MeasurableSpace α] (μ : Measure α) + [IsFiniteMeasure μ] (A : ℕ → Set α) (hm : ∀ n, MeasurableSet (A n)) + (hd : Pairwise (fun n m => Disjoint (A n) (A m))) : + μ.real (⋃ n,A n)=∑' n,μ.real (A n) := by + rw [measureReal_def,measure_iUnion hd hm] + exact ENNReal.tsum_toReal_eq (fun n => measure_ne_top μ (A n)) + +lemma lateGridFailure_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (B j : ℕ) (hB : 0 < B) (hj : 0 < j) : + (annealedLaw ν).real (LateGridFailure e B j) ≤ + (annealedLaw ν).real (Cross (realPosition (step e)) 0 B \ NoDrop (realPosition (step e)) 0) := by + let ℓ := realPosition (step e) + let μ := annealedLaw ν + let A := fun n => {X : Path d | X 0=0} ∩ FirstLayerHit (signedHeight e) (j*B:ℕ) n + let F := fun n => (A n ∩ FutureEvent (fun x => Cross ℓ x B) n) \ FutureNoDrop ℓ n + have hAm (n : ℕ) : MeasurableSet (A n) := + (measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter (measurableSet_firstLayerHit _ _ _) + have hFm (n : ℕ) : MeasurableSet (F n) := + ((hAm n).inter (measurableSet_futureEvent _ (fun _ => measurableSet_cross _ _ _) _)).diff + (measurableSet_futureNoDrop _ _) + have hAd : Pairwise (fun n m => Disjoint (A n) (A m)) := + fun n m hnm => (firstLayerHit_disjoint (signedHeight e) (j*B:ℕ) hnm).mono + Set.inter_subset_right Set.inter_subset_right + have hFd : Pairwise (fun n m => Disjoint (F n) (F m)) := + fun n m hnm => (hAd hnm).mono (Set.Subset.trans Set.sdiff_subset Set.inter_subset_left) + (Set.Subset.trans Set.sdiff_subset Set.inter_subset_left) + have hf (n : ℕ) : μ.real (F n)=μ.real (A n)*μ.real (Cross ℓ 0 B \ NoDrop ℓ 0) := by + by_cases hn : 0 < n + · apply annealed_record_event_cross_failure ν ℓ htrans n hn (A n) (hAm n) + · apply prefixDetermined_inter + · intro X Y hXY + simp only [Set.mem_ofPred_eq,hXY 0 (Nat.zero_le n)] + · exact firstLayerHit_prefix _ _ _ + · exact fun X hX => firstLayerHit_record _ _ (signedHeight_projection e) _ _ X hX.2 + · exact_mod_cast hB + · have hz : n=0 := by omega + have hAe : A n=∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro X hX + have hh := hX.2.1 + rw [hz,hX.1,signedHeight_zero] at hh + have hpos : 0 < j*B := Nat.mul_pos hj hB + exact (Nat.ne_of_gt hpos) (by exact_mod_cast hh.symm) + have hFe : F n=∅ := by simp [F,hAe] + simp only [hAe,hFe,measureReal_empty,zero_mul] + change μ.real (⋃ n,F n) ≤ _ + rw [measureReal_iUnion_disjoint μ F hFm hFd] + simp_rw [hf] + rw [tsum_mul_right,← measureReal_iUnion_disjoint μ A hAm hAd] + exact mul_le_of_le_one_left measureReal_nonneg measureReal_le_one + +def NoTruePastHeight {d : ℕ} (e : Direction d) (H : ℕ) : Set (Path d) := + {X | X 0=0 ∧ ∃ n, X ∈ FirstLayerHit (signedHeight e) H n ∧ + ∀ t, 0 < t → t ≤ n → ¬TrueRecord (realPosition (step e)) X t} + +lemma measurableSet_noTruePastHeight {d : ℕ} (e : Direction d) (H : ℕ) : + MeasurableSet (NoTruePastHeight e H) := by + simp only [NoTruePastHeight,Set.ofPred_and,Set.ofPred_exists,Set.ofPred_forall] + exact (measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter + (MeasurableSet.iUnion fun n => (measurableSet_firstLayerHit _ _ _).inter + (MeasurableSet.iInter fun t => MeasurableSet.iInter fun _ => MeasurableSet.iInter fun _ => + (measurableSet_trueRecord _ _).compl)) + +lemma firstLayerHit_time_lt {d : ℕ} (h : Lattice d → ℤ) (H K : ℤ) (hHK : H < K) + (X : Path d) (n m : ℕ) (hn : X ∈ FirstLayerHit h H n) (hm : X ∈ FirstLayerHit h K m) : n < m := by + by_contra hh + rcases lt_or_eq_of_le (Nat.le_of_not_lt hh) with hlt | rfl + · have hk := hn.2 m hlt + rw [hm.1] at hk + omega + · have hh := hm.1 + rw [hn.1] at hh + exact (ne_of_lt hHK) hh + +lemma noTruePastHeight_grid_cover {d : ℕ} (e : Direction d) (B k : ℕ) (hB : 0 < B) + (X : Path d) (hNN : ∀ n, ∃ f, X (n+1)=X n+step f) + (ht : X ∈ TransientPaths (realPosition (step e))) + (hX : X ∈ NoTruePastHeight e ((k+1)*B)) : + X ∈ GridReached e B k ∪ ⋃ j ∈ Finset.range k, LateGridFailure e B (j+1) := by + induction k with + | zero => + obtain ⟨h0,n,hn,_⟩ := hX + exact Or.inl (Set.mem_iUnion.mpr ⟨n,h0,by simpa using hn⟩) + | succ k ih => + obtain ⟨h0,m,hm,hnot⟩ := hX + obtain ⟨n,hn⟩ := noDrop_firstLayerHit_exists e X h0 hNN ht + (show 0 < (k+1)*B by positivity) + have hnm : n < m := firstLayerHit_time_lt _ _ _ (by exact_mod_cast + (show (k+1)*B < (k+1+1)*B by nlinarith)) X n m hn hm + have hprev : X ∈ NoTruePastHeight e ((k+1)*B) := + ⟨h0,n,hn,fun t ht htn => hnot t ht (htn.trans hnm.le)⟩ + rcases ih hprev with hg | hbad + · obtain ⟨q,hq⟩ := Set.mem_iUnion.mp hg + have hqn : q=n := by + by_contra hh + exact Set.disjoint_left.mp (firstLayerHit_disjoint (signedHeight e) ((k+1)*B:ℕ) hh) + (gridPrefix_hit e B k q hq).2 hn + subst q + by_cases hdrop : X ∈ DropBetween (realPosition (step e)) n m + · exact Or.inl (Set.mem_iUnion.mpr ⟨m,⟨h0,by simpa [Nat.add_assoc] using hm⟩, + Set.mem_iUnion.mpr ⟨n,Set.mem_iUnion.mpr ⟨hnm,hq,hdrop⟩⟩⟩) + · apply Or.inr + refine Set.mem_iUnion.mpr ⟨k,Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr (Nat.lt_succ_self k),?_⟩⟩ + apply Set.mem_iUnion.mpr + refine ⟨n,⟨⟨h0,hn⟩,?_⟩,?_⟩ + · refine ⟨m-n,?_,?_⟩ + · change dot (realPosition (X n)) (realPosition (step e))+B ≤ dot (realPosition (X (n+(m-n)))) (realPosition (step e)) + rw [Nat.add_sub_of_le hnm.le,signedHeight_projection,signedHeight_projection,hn.1,hm.1] + push_cast + ring_nf + exact le_rfl + · intro i hi + rw [signedHeight_projection,signedHeight_projection] + by_contra hh + apply hdrop + exact ⟨n+i,by omega,by omega,by simpa only [signedHeight_projection] using lt_of_not_ge hh⟩ + · have hr := gridPrefix_record e B k n hB X hq + exact fun hD => hnot n hr.1 hnm.le ⟨hr.2,hD⟩ + · apply Or.inr + obtain ⟨j,hj⟩ := Set.mem_iUnion.mp hbad + obtain ⟨hj,hbad⟩ := Set.mem_iUnion.mp hj + exact Set.mem_iUnion.mpr ⟨j,Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr + ((Finset.mem_range.mp hj).trans (Nat.lt_succ_self k)),hbad⟩⟩ + +lemma noTruePastHeight_grid_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (B k : ℕ) (hB : 0 < B) : + (annealedLaw ν).real (NoTruePastHeight e ((k+1)*B)) ≤ + (1-(annealedLaw ν).real (NoDrop (realPosition (step e)) 0))^k + + k*(annealedLaw ν).real (Cross (realPosition (step e)) 0 B \ NoDrop (realPosition (step e)) 0) := by + calc + _ ≤ (annealedLaw ν).real (GridReached e B k ∪ ⋃ j ∈ Finset.range k, LateGridFailure e B (j+1)) := by + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [annealed_nearest_neighbor ν,htrans] with X hNN ht + exact noTruePastHeight_grid_cover e B k hB X hNN ht + _ ≤ (annealedLaw ν).real (GridReached e B k)+ + ∑ j ∈ Finset.range k, (annealedLaw ν).real (LateGridFailure e B (j+1)) := + (measureReal_union_le _ _).trans (add_le_add le_rfl + (measureReal_biUnion_finset_le (μ := annealedLaw ν) (Finset.range k) (fun j => LateGridFailure e B (j+1)))) + _ ≤ _ := add_le_add (gridReached_geometric ν e B k hB) (by + simpa using Finset.sum_le_sum (s := Finset.range k) (fun j _ => lateGridFailure_bound ν e htrans B (j+1) hB (by omega))) + +lemma noTruePastSquare_rapidDecay {d : ℕ} (hd : 2 ≤ d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + RapidDecay (fun N => (annealedLaw ν).real (NoTruePastHeight e ((N+1)^2))) := by + have hp := noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans + have hp' : 0 < (annealedLaw ν).real (NoDrop (realPosition (step e)) 0) := + ENNReal.toReal_pos hp.ne' (measure_ne_top _ _) + have hgeom := rapidDecay_geometric (1-(annealedLaw ν).real (NoDrop (realPosition (step e)) 0)) + (sub_nonneg.mpr measureReal_le_one) (by linarith) + have hbad := ((crossing_failure_rapidDecay hd ν hue e htrans).shift + (fun _ => measureReal_nonneg) 1).pow_mul 1 + apply (hgeom.add hbad).of_le (fun _ => measureReal_nonneg) + apply Eventually.of_forall + intro N + have hh := noTruePastHeight_grid_bound ν e htrans (N+1) N (by omega) + simp only [pow_two,pow_one] at hh ⊢ + exact hh.trans (add_le_add le_rfl (mul_le_mul_of_nonneg_right (by linarith : (N:ℝ) ≤ N+1) + measureReal_nonneg)) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WordConcatenation.lean b/lean/OAI/Probability/Ballisticity/Estimates/WordConcatenation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f164a873007e74bdf1b4cc47b8e8a6c81eb4e15 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WordConcatenation.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.FiniteWordGeometry +import OAI.Probability.Ballisticity.Estimates.SuccessfulWords + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience + +abbrev CoordinateWord {d : ℕ} (e : Direction d) (x : Lattice d) (H : ℕ) := + HitWord x (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) + +def ValidWordSplit {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) + (p : List (Direction d) × List (Direction d)) : Prop := + wordPath x p.1 ∈ HitAt (Strip (realPosition (step e)) x h) + (Upper (realPosition (step e)) x h) p.1.length ∧ + wordPath (wordPath x p.1 p.1.length) p.2 ∈ HitAt + (Strip (realPosition (step e)) (wordPath x p.1 p.1.length) m) + (Upper (realPosition (step e)) (wordPath x p.1 p.1.length) m) p.2.length + +abbrev CoordinateSplit {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) := + {p : List (Direction d) × List (Direction d) // ValidWordSplit e x h m p} + +def coordinateSplitFirst {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) + (p : CoordinateSplit e x h m) : CoordinateWord e x h := ⟨p.val.1,p.property.1⟩ + +def coordinateSplitSecond {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) + (p : CoordinateSplit e x h m) : CoordinateWord e (wordPath x p.val.1 p.val.1.length) m := + ⟨p.val.2,p.property.2⟩ + +def coordinateWordConcat {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) + (p : CoordinateSplit e x h m) : CoordinateWord e x (h+m) := + ⟨p.val.1++p.val.2,wordPath_hit_append e x h m (coordinateSplitFirst e x h m p) + (coordinateSplitSecond e x h m p)⟩ + +lemma coordinateWordConcat_injective {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) : + Function.Injective (coordinateWordConcat e x h m) := by + intro u v huv + have he : u.val.1++u.val.2 = v.val.1++v.val.2 := Subtype.ext_iff.mp huv + have hlen (p : CoordinateSplit e x h m) : + wordFirstHitTime e x h (p.val.1++p.val.2) = p.val.1.length := by + have hf := wordFirstHitTime_append_prefix e x h h le_rfl (coordinateSplitFirst e x h m p) p.val.2 + have hg := wordFirstHitTime_endpoint e x h (coordinateSplitFirst e x h m p) + exact hf.trans hg + have hl : u.val.1.length = v.val.1.length := by rw [← hlen u,he,hlen v] + have hp := List.append_inj he hl + exact Subtype.ext (Prod.ext hp.1 hp.2) + +namespace TupleKernel + +lemma atomic_injection_sum_le {A B : Type*} [MeasurableSpace B] [Countable A] [Countable B] + (f : A → B) (hf : Function.Injective f) (w : B → ℝ≥0∞) : + (Measure.sum (fun a => w (f a) • Measure.dirac (f a))) ≤ + Measure.sum (fun b => w b • Measure.dirac b) := by + intro U + simp only [Measure.sum_apply_of_countable,Measure.smul_apply,smul_eq_mul] + exact ENNReal.tsum_comp_le_tsum_of_injective hf (fun b => w b * Measure.dirac b U) + +lemma countable_map_apply {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable A] [Countable B] [MeasurableSingletonClass A] [MeasurableSingletonClass B] + (μ : Measure A) (f : A → B) (b : B) : + μ.map f {b} = ∑' a, if f a = b then μ {a} else 0 := by + rw [← Measure.sum_smul_dirac μ,Measure.map_sum (measurable_of_countable _).aemeasurable, + Measure.sum_apply_of_countable] + congr 1 + funext a + rw [Measure.map_smul _ (measurable_of_countable f).aemeasurable, + Measure.map_dirac' (measurable_of_countable _),Measure.smul_apply] + by_cases ha : f a = b <;> simp [ha] + +lemma countable_restricted_map_le {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable A] [Countable B] [MeasurableSingletonClass A] [MeasurableSingletonClass B] + (μ : Measure A) (ν : Measure B) (S : Set A) (f : A → B) + (hf : Set.InjOn f S) (hzero : ∀ a ∉ S, μ {a} = 0) + (hatom : ∀ a ∈ S, μ {a} ≤ ν {f a}) : μ.map f ≤ ν := by + apply measure_le_of_singletons + intro b + rw [countable_map_apply] + by_cases hex : ∃ a ∈ S, f a = b + · obtain ⟨a,ha,hab⟩ := hex + rw [tsum_eq_single a] + · simpa [hab] using hatom a ha + · intro c hca + by_cases hc : c ∈ S + · have hne : f c ≠ b := fun he => hca (hf hc ha (he.trans hab.symm)) + simp only [ite_eq_right hne] + · simp only [hzero c hc,ite_self] + · have hz : ∀ a, (if f a = b then μ {a} else 0) = 0 := by + intro a + by_cases he : f a = b + · rw [ite_eq_left he] + exact hzero a (fun ha => hex ⟨a,ha,he⟩) + · exact ite_eq_right he + simp only [hz,tsum_zero,zero_le] + +end TupleKernel + +noncomputable def rawWordPairLaw {d : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Lattice d) : Measure (List (Direction d) × List (Direction d)) := + (rawWordLaw (realPosition (step e)) h ω x).bind (fun u => + (rawWordLaw (realPosition (step e)) m ω (wordPath x u u.length)).map (fun v => (u,v))) + +lemma rawWordPairLaw_singleton {d : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Lattice d) (u v : List (Direction d)) : + rawWordPairLaw e h m ω x {(u,v)} = + rawWordLaw (realPosition (step e)) h ω x {u} * + rawWordLaw (realPosition (step e)) m ω (wordPath x u u.length) {v} := by + rw [rawWordPairLaw,Measure.bind_apply (measurableSet_singleton _) (measurable_of_countable _).aemeasurable, + lintegral_countable'] + have he (a : List (Direction d)) : + ((rawWordLaw (realPosition (step e)) m ω (wordPath x a a.length)).map (fun v => (a,v))) {(u,v)} = + if a=u then rawWordLaw (realPosition (step e)) m ω (wordPath x a a.length) {v} else 0 := by + rw [Measure.map_apply (measurable_of_countable _) (measurableSet_singleton _)] + by_cases ha : a=u + · subst a + rw [ite_eq_left rfl] + congr 1 + ext b + simp + · rw [ite_eq_right ha] + have hset : (fun b => (a,b)) ⁻¹' {(u,v)} = (∅ : Set (List (Direction d))) := by + ext b + simp [ha] + rw [hset,measure_empty] + simp_rw [he] + rw [tsum_eq_single u] + · simp [mul_comm] + · intro a ha + simp [ha] + +lemma rawWordPairLaw_invalid {d : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Lattice d) (p : List (Direction d) × List (Direction d)) + (hp : ¬ ValidWordSplit e x h m p) : rawWordPairLaw e h m ω x {p} = 0 := by + rw [← Prod.eta p,rawWordPairLaw_singleton] + simp only [rawWordLaw_singleton] + unfold ValidWordSplit at hp + by_cases h1 : wordPath x p.1 ∈ HitAt (Strip (realPosition (step e)) x h) + (Upper (realPosition (step e)) x h) p.1.length + · have h2 : ¬ wordPath (wordPath x p.1 p.1.length) p.2 ∈ HitAt + (Strip (realPosition (step e)) (wordPath x p.1 p.1.length) m) + (Upper (realPosition (step e)) (wordPath x p.1 p.1.length) m) p.2.length := fun h2 => hp ⟨h1,h2⟩ + simp only [ite_eq_left h1,ite_eq_right h2,mul_zero] + · simp only [ite_eq_right h1,zero_mul] + +lemma rawWordPairLaw_valid {d : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Lattice d) (p : CoordinateSplit e x h m) : + rawWordPairLaw e h m ω x {p.val} = + rawWordLaw (realPosition (step e)) (h+m) ω x {p.val.1++p.val.2} := by + rw [← Prod.eta p.val,rawWordPairLaw_singleton] + simp only [rawWordLaw_singleton,ite_eq_left p.property.1,ite_eq_left p.property.2] + have hc := (coordinateWordConcat e x h m p).property + change wordPath x (p.val.1++p.val.2) ∈ HitAt (Strip (realPosition (step e)) x (h+m : ℕ)) + (Upper (realPosition (step e)) x (h+m : ℕ)) (p.val.1++p.val.2).length at hc + rw [ite_eq_left hc,wordWeight_append,ENNReal.ofReal_mul (wordWeight_nonneg ω x p.val.1)] + +lemma rawWordLaw_comp_le {d : ℕ} (e : Direction d) (h m : ℕ) + (ω : Environment d) (x : Lattice d) : + (rawWordPairLaw e h m ω x).map (fun p => p.1++p.2) ≤ + rawWordLaw (realPosition (step e)) (h+m) ω x := by + apply TupleKernel.countable_restricted_map_le _ _ {p | ValidWordSplit e x h m p} + · intro u hu v hv he + have he' : coordinateWordConcat e x h m ⟨u,hu⟩ = coordinateWordConcat e x h m ⟨v,hv⟩ := + Subtype.ext he + exact congrArg Subtype.val (coordinateWordConcat_injective e x h m he') + · exact fun p hp => rawWordPairLaw_invalid e h m ω x p hp + · intro p hp + exact (rawWordPairLaw_valid e h m ω x ⟨p,hp⟩).le + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WordDepartures.lean b/lean/OAI/Probability/Ballisticity/Estimates/WordDepartures.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccc81c52ad54f2eefd5eba335ec0a40515639037 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WordDepartures.lean @@ -0,0 +1,428 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.StateTrajectory + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma fresh_rows_factor {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {S T : Set (Lattice d)} (hST : Disjoint S T) + {f g : Environment d → ℝ} + (hf : @Measurable _ _ (rowSigma S) _ f) + (hg : @Measurable _ _ (rowSigma T) _ g) : + (∫ ω, f ω * g ω ∂environmentLaw ν) = + (∫ ω, f ω ∂environmentLaw ν) * (∫ ω, g ω ∂environmentLaw ν) := by + have hi : IndepFun f g (environmentLaw ν) := by + rw [indepFun_iff_measure_inter_preimage_eq_mul] + intro s t hs ht + exact (Indep_iff _ _ _).mp (environment_indep_rows ν hST) _ _ (hf hs) (hg ht) + exact hi.integral_fun_mul_eq_mul_integral + (hf.mono (rowSigma_le S) le_rfl).aestronglyMeasurable + (hg.mono (rowSigma_le T) le_rfl).aestronglyMeasurable + +def wordDepartures {d : ℕ} (x : Lattice d) : List (Direction d) → Finset (Lattice d) + | [] => ∅ + | e :: w => insert x (wordDepartures (x + step e) w) + +noncomputable def wordWeight {d : ℕ} (ω : Environment d) (x : Lattice d) : + List (Direction d) → ℝ + | [] => 1 + | e :: w => ((ω x).1 e : ℝ) * wordWeight ω (x + step e) w + +lemma wordWeight_nonneg {d : ℕ} (ω : Environment d) (x : Lattice d) + (w : List (Direction d)) : 0 ≤ wordWeight ω x w := by + induction w generalizing x with + | nil => simp [wordWeight] + | cons e w ih => exact mul_nonneg (NNReal.coe_nonneg _) (ih _) + +lemma wordWeight_le_one {d : ℕ} (ω : Environment d) (x : Lattice d) + (w : List (Direction d)) : wordWeight ω x w ≤ 1 := by + induction w generalizing x with + | nil => simp [wordWeight] + | cons e w ih => + exact (mul_le_of_le_one_left (wordWeight_nonneg ω _ w) + (by exact_mod_cast row_entry_le_one (ω x) e)).trans (ih _) + +lemma measurable_wordWeight_on {d : ℕ} {S : Set (Lattice d)} (x : Lattice d) + (w : List (Direction d)) (hS : ∀ y ∈ wordDepartures x w, y ∈ S) : + @Measurable _ _ (rowSigma S) _ (fun ω => wordWeight ω x w) := by + induction w generalizing x with + | nil => exact measurable_const + | cons e w ih => + have hx : x ∈ S := hS x (Finset.mem_insert_self _ _) + have he : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => ((ω x).1 e : ℝ)) := + ((measurable_pi_apply e).comp + (measurable_subtype_coe.comp (measurable_row_on hx))).coe_nnreal_real + exact he.mul (ih _ (fun y hy => hS y (Finset.mem_insert_of_mem hy))) + +lemma measurable_wordWeight {d : ℕ} (x : Lattice d) (w : List (Direction d)) : + Measurable (fun ω : Environment d => wordWeight ω x w) := + (measurable_wordWeight_on (S := Set.univ) x w (by simp)).mono + (rowSigma_le _) le_rfl + +lemma integrable_wordWeight {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x : Lattice d) (w : List (Direction d)) : + Integrable (fun ω => wordWeight ω x w) (environmentLaw ν) := by + apply (integrable_const (1 : ℝ)).mono' (measurable_wordWeight x w).aestronglyMeasurable + exact ae_of_all _ fun ω => by + rw [Real.norm_eq_abs, abs_of_nonneg (wordWeight_nonneg ω x w)] + exact wordWeight_le_one ω x w + +lemma wordWeight_fresh_factor {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x : Lattice d) (w : List (Direction d)) {g : Environment d → ℝ} + (hg : @Measurable _ _ (rowSigma (wordDepartures x w : Set (Lattice d))ᶜ) _ g) : + (∫ ω, wordWeight ω x w * g ω ∂environmentLaw ν) = + (∫ ω, wordWeight ω x w ∂environmentLaw ν) * (∫ ω, g ω ∂environmentLaw ν) := by + exact fresh_rows_factor ν disjoint_compl_right + (measurable_wordWeight_on x w (by simp)) hg + +def wordPath {d : ℕ} (x : Lattice d) : List (Direction d) → Path d + | [], _ => x + | _ :: _, 0 => x + | e :: w, n + 1 => wordPath (x + step e) w n + +@[simp] lemma wordPath_zero {d : ℕ} (x : Lattice d) (w : List (Direction d)) : + wordPath x w 0 = x := by cases w <;> rfl + +def wordCylinder {d : ℕ} (x : Lattice d) (w : List (Direction d)) : Set (Path d) := + {X | ∀ i ≤ w.length, X i = wordPath x w i} + +lemma measurableSet_wordCylinder {d : ℕ} (x : Lattice d) (w : List (Direction d)) : + MeasurableSet (wordCylinder x w) := by + simp only [wordCylinder, Set.ofPred_forall] + exact MeasurableSet.iInter fun i => MeasurableSet.iInter fun _ => + measurableSet_eq_fun (measurable_pi_apply i : Measurable (fun X : Path d => X i)) + measurable_const + +lemma wordPath_transition_product {d : ℕ} (ω : Environment d) (x : Lattice d) + (w : List (Direction d)) : + (∏ i ∈ Finset.range w.length, + transition (ω, wordPath x w i) {(ω, wordPath x w (i + 1))}) = + ENNReal.ofReal (wordWeight ω x w) := by + induction w generalizing x with + | nil => simp [wordWeight] + | cons e w ih => + rw [List.length_cons, Finset.prod_range_succ'] + simp only [wordPath, wordPath_zero] + rw [ih, transition_singleton_step, wordWeight, ENNReal.ofReal_mul (NNReal.coe_nonneg _)] + simp [mul_comm] + +lemma quenched_wordCylinder {d : ℕ} (ω : Environment d) (x : Lattice d) + (w : List (Direction d)) : + quenchedKernel (ω, x) (wordCylinder x w) = ENNReal.ofReal (wordWeight ω x w) := by + have hm : Measurable (fun z : ℕ → State d => fun n => (z n).2) := by fun_prop + rw [quenchedKernel, Kernel.map_apply _ hm, Measure.map_apply hm (measurableSet_wordCylinder x w)] + have he : (fun z : ℕ → State d => fun n => (z n).2) ⁻¹' wordCylinder x w + =ᵐ[stateTrajectory (ω, x)] stateCylinder (fun n => (ω, wordPath x w n)) w.length := by + filter_upwards [stateTrajectory_environment (ω, x)] with X hX + apply propext + change (∀ i ≤ w.length, (X i).2 = wordPath x w i) ↔ + (∀ i ≤ w.length, X i = (ω, wordPath x w i)) + constructor + · intro hh n hn + exact Prod.ext (hX n) (hh n hn) + · intro hh n hn + exact congrArg Prod.snd (hh n hn) + rw [measure_congr he, stateTrajectory_cylinder _ _ (by simp), wordPath_transition_product] + +lemma annealed_wordCylinder {d : ℕ} (ν : Measure (Row d)) (w : List (Direction d)) : + annealedLaw ν (wordCylinder 0 w) = + ∫⁻ ω, ENNReal.ofReal (wordWeight ω 0 w) ∂environmentLaw ν := by + rw [annealed_apply ν (measurableSet_wordCylinder 0 w)] + congr 1 + funext ω + exact quenched_wordCylinder ω 0 w + +def pathCylinder {d : ℕ} (f : Path d) (n : ℕ) : Set (Path d) := + {X | ∀ i ≤ n, X i = f i} + +lemma measurableSet_pathCylinder {d : ℕ} (f : Path d) (n : ℕ) : + MeasurableSet (pathCylinder f n) := by + simp only [pathCylinder, Set.ofPred_forall] + exact MeasurableSet.iInter fun i => MeasurableSet.iInter fun _ => + measurableSet_eq_fun (measurable_pi_apply i : Measurable (fun X : Path d => X i)) + measurable_const + +lemma pathMeasure_ext {d : ℕ} (μ ν : Measure (Path d)) [IsFiniteMeasure μ] + (h : ∀ f n, μ (pathCylinder f n) = ν (pathCylinder f n)) : μ = ν := by + let P : (I : Finset ℕ) → Measure ((i : I) → Lattice d) := + fun I => μ.map I.restrict + have hp : IsProjectiveMeasureFamily (α := fun _ : ℕ => Lattice d) P := by + exact isProjectiveMeasureFamily_map_restrict (P := μ) (X := fun n (X : Path d) => X n) + (fun n => (measurable_pi_apply n).aemeasurable) + have hμ : IsProjectiveLimit (α := fun _ : ℕ => Lattice d) μ P := by + intro I + rfl + apply hμ.unique + apply (isProjectiveLimit_nat_iff hp ν).mpr + intro n + apply Measure.ext_of_singleton + intro f + have hf : MeasurableSet ({f} : Set ((i : Finset.Iic n) → Lattice d)) := + measurableSet_singleton _ + rw [Measure.map_apply (Preorder.measurable_frestrictLe n) hf] + change _ = μ.map (Preorder.frestrictLe n) {f} + rw [Measure.map_apply (Preorder.measurable_frestrictLe n) hf] + let g : Path d := fun i => if hi : i ≤ n then f ⟨i, Finset.mem_Iic.mpr hi⟩ else 0 + have he : (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' {f} = pathCylinder g n := by + ext X + simp only [Set.mem_preimage, Set.mem_singleton_iff, pathCylinder, Set.mem_ofPred_eq] + constructor + · intro hh i hi + simpa [g, hi] using congrFun hh ⟨i, Finset.mem_Iic.mpr hi⟩ + · intro hh + funext i + simpa [g, Finset.mem_Iic.mp i.2] using hh i (Finset.mem_Iic.mp i.2) + rw [he, h] + +noncomputable def edgeWeight {d : ℕ} (ω : Environment d) (x y : Lattice d) : ℝ≥0∞ := + ∑ e : Direction d, if y = x + step e then ((ω x).1 e : ℝ≥0∞) else 0 + +lemma transition_singleton {d : ℕ} (ω : Environment d) (x y : Lattice d) : + transition (ω, x) {(ω, y)} = edgeWeight ω x y := by + classical + change (∑ e : Direction d, ((ω x).1 e : ℝ≥0∞) • + Measure.dirac (ω, x + step e)) {(ω, y)} = _ + simp only [Measure.finsetSum_apply, Measure.smul_apply, smul_eq_mul, edgeWeight] + apply Finset.sum_congr rfl + intro e _ + by_cases he : y = x + step e + · simp [he] + · simp [he, Ne.symm he] + +lemma quenched_pathCylinder {d : ℕ} (ω : Environment d) (x : Lattice d) + (f : Path d) (hf : f 0 = x) (n : ℕ) : + quenchedKernel (ω, x) (pathCylinder f n) = + ∏ i ∈ Finset.range n, edgeWeight ω (f i) (f (i + 1)) := by + have hm : Measurable (fun z : ℕ → State d => fun n => (z n).2) := by fun_prop + rw [quenchedKernel, Kernel.map_apply _ hm, Measure.map_apply hm (measurableSet_pathCylinder f n)] + have he : (fun z : ℕ → State d => fun n => (z n).2) ⁻¹' pathCylinder f n + =ᵐ[stateTrajectory (ω, x)] stateCylinder (fun i => (ω, f i)) n := by + filter_upwards [stateTrajectory_environment (ω, x)] with X hX + apply propext + change (∀ i ≤ n, (X i).2 = f i) ↔ (∀ i ≤ n, X i = (ω, f i)) + constructor + · intro hh i hi + exact Prod.ext (hX i) (hh i hi) + · intro hh i hi + exact congrArg Prod.snd (hh i hi) + rw [measure_congr he, stateTrajectory_cylinder _ _ (by simp [hf])] + simp only [transition_singleton] + +lemma quenched_pathCylinder_zero {d : ℕ} (ω : Environment d) (x : Lattice d) + (f : Path d) (hf : f 0 ≠ x) (n : ℕ) : + quenchedKernel (ω, x) (pathCylinder f n) = 0 := by + have hsub : pathCylinder f n ⊆ {X | X 0 ≠ x} := by + intro X hX + change X 0 ≠ x + rw [hX 0 (Nat.zero_le n)] + exact hf + exact measure_mono_null hsub ((ae_iff).mp (quenched_initial_ae (ω, x))) + +lemma edgeWeight_translation {d : ℕ} (ω : Environment d) (z x y : Lattice d) : + edgeWeight (fun a => ω (z + a)) x y = edgeWeight ω (z + x) (z + y) := by + classical + simp only [edgeWeight] + apply Finset.sum_congr rfl + intro e _ + congr 1 + simp only [add_assoc, add_right_inj] + +lemma quenched_translation {d : ℕ} (ω : Environment d) (z x : Lattice d) : + (quenchedKernel (ω, z + x)).map (fun X n => X n - z) = + quenchedKernel ((fun a => ω (z + a)), x) := by + have hm : Measurable (fun X : Path d => fun n => X n - z) := by fun_prop + apply pathMeasure_ext + intro f n + rw [Measure.map_apply hm (measurableSet_pathCylinder f n)] + have he : (fun X : Path d => fun i => X i - z) ⁻¹' pathCylinder f n = + pathCylinder (fun i => z + f i) n := by + ext X + simp only [pathCylinder, Set.mem_preimage, Set.mem_ofPred_eq, sub_eq_iff_eq_add, add_comm] + rw [he] + by_cases hf : f 0 = x + · rw [quenched_pathCylinder _ _ _ (by simp [hf]), quenched_pathCylinder _ _ _ hf] + simp only [edgeWeight_translation] + · rw [quenched_pathCylinder_zero _ _ _ (by simpa using hf), + quenched_pathCylinder_zero _ _ _ hf] + +def splicePath {d : ℕ} (f g : Path d) (n : ℕ) : Path d := + fun i => if i < n then f i else g (i - n) + +lemma splicePath_left {d : ℕ} (f g : Path d) {n i : ℕ} + (hg : g 0 = f n) (hi : i ≤ n) : splicePath f g n i = f i := by + rcases lt_or_eq_of_le hi with hi | rfl + · simp [splicePath, hi] + · simp [splicePath, hg] + +lemma splicePath_right {d : ℕ} (f g : Path d) (n i : ℕ) : + splicePath f g n (n + i) = g i := by + simp [splicePath] + +lemma pathCylinder_splice {d : ℕ} (f g : Path d) (n k : ℕ) (hg : g 0 = f n) : + (fun X : Path d => fun i => X (n + i)) ⁻¹' pathCylinder g k ∩ pathCylinder f n = + pathCylinder (splicePath f g n) (n + k) := by + ext X + simp only [Set.mem_inter_iff, Set.mem_preimage, pathCylinder, Set.mem_ofPred_eq] + constructor + · rintro ⟨h₁, h₂⟩ i hi + by_cases hin : i ≤ n + · rw [splicePath_left f g hg hin] + exact h₂ i hin + · have hn : n ≤ i := by omega + obtain ⟨j, rfl⟩ := Nat.exists_eq_add_of_le hn + rw [splicePath_right] + exact h₁ j (by omega) + · intro hX + constructor + · intro i hi + simpa only [splicePath_right] using hX (n + i) (by omega) + · intro i hi + simpa only [splicePath_left f g hg hi] using hX i (by omega) + +lemma splicePath_weight {d : ℕ} (ω : Environment d) (f g : Path d) (n k : ℕ) + (hg : g 0 = f n) : + (∏ i ∈ Finset.range (n + k), + edgeWeight ω (splicePath f g n i) (splicePath f g n (i + 1))) = + (∏ i ∈ Finset.range n, edgeWeight ω (f i) (f (i + 1))) * + ∏ i ∈ Finset.range k, edgeWeight ω (g i) (g (i + 1)) := by + rw [Finset.prod_range_add] + congr 1 + · apply Finset.prod_congr rfl + intro i hi + have hin := Finset.mem_range.mp hi + rw [splicePath_left f g hg (by omega), splicePath_left f g hg (by omega)] + · apply Finset.prod_congr rfl + intro i _ + rw [splicePath_right, show n + i + 1 = n + (i + 1) by omega, splicePath_right] + +lemma quenched_prefix_markov {d : ℕ} (ω : Environment d) (x : Lattice d) + (f : Path d) (hf : f 0 = x) (n : ℕ) : + ((quenchedKernel (ω, x)).restrict (pathCylinder f n)).map + (fun X i => X (n + i)) = + (quenchedKernel (ω, x) (pathCylinder f n)) • quenchedKernel (ω, f n) := by + have hm : Measurable (fun X : Path d => fun i => X (n + i)) := by fun_prop + apply pathMeasure_ext + intro g k + rw [Measure.map_apply hm (measurableSet_pathCylinder g k), + Measure.restrict_apply (hm (measurableSet_pathCylinder g k)), Measure.smul_apply, smul_eq_mul] + by_cases hg : g 0 = f n + · rw [pathCylinder_splice f g n k hg, + quenched_pathCylinder _ _ _ ((splicePath_left f g hg (Nat.zero_le n)).trans hf), + quenched_pathCylinder _ _ _ hf, quenched_pathCylinder _ _ _ hg, + splicePath_weight ω f g n k hg] + · rw [quenched_pathCylinder_zero _ _ _ hg, mul_zero] + have he : (fun X : Path d => fun i => X (n + i)) ⁻¹' pathCylinder g k ∩ + pathCylinder f n = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro X ⟨h₁, h₂⟩ + have h₁' := h₁ 0 (Nat.zero_le k) + have h₂' := h₂ n le_rfl + apply hg + simpa using h₁'.symm.trans (by simpa using h₂') + rw [he, measure_empty] + +lemma quenched_prefix_future {d : ℕ} (ω : Environment d) (x : Lattice d) + (f : Path d) (hf : f 0 = x) (n : ℕ) {A : Set (Path d)} (hA : MeasurableSet A) : + quenchedKernel (ω, x) + ((fun X : Path d => fun i => X (n + i)) ⁻¹' A ∩ pathCylinder f n) = + quenchedKernel (ω, x) (pathCylinder f n) * quenchedKernel (ω, f n) A := by + have h := congrArg (fun μ : Measure (Path d) => μ A) (quenched_prefix_markov ω x f hf n) + rw [Measure.map_apply (by fun_prop) hA, Measure.restrict_apply ((by fun_prop : Measurable (fun X : Path d => fun i => X (n + i))) hA), + Measure.smul_apply, smul_eq_mul] at h + exact h + +def NoDrop {d : ℕ} (ℓ : Vector d) (x : Lattice d) : Set (Path d) := + {X | ∀ n, dot (realPosition x) ℓ ≤ dot (realPosition (X n)) ℓ} + +lemma measurableSet_noDrop {d : ℕ} (ℓ : Vector d) (x : Lattice d) : + MeasurableSet (NoDrop ℓ x) := by + simp only [NoDrop, Set.ofPred_forall] + apply MeasurableSet.iInter + intro n + exact measurableSet_le measurable_const + ((measurable_of_countable (f := fun y : Lattice d => dot (realPosition y) ℓ)).comp + (measurable_pi_apply n)) + +lemma dot_realPosition_add {d : ℕ} (x y : Lattice d) (ℓ : Vector d) : + dot (realPosition (x + y)) ℓ = dot (realPosition x) ℓ + dot (realPosition y) ℓ := by + simp [dot, realPosition, add_mul, Finset.sum_add_distrib] + +lemma dot_realPosition_sub {d : ℕ} (x y : Lattice d) (ℓ : Vector d) : + dot (realPosition (x - y)) ℓ = dot (realPosition x) ℓ - dot (realPosition y) ℓ := by + simp [dot, realPosition, sub_mul, Finset.sum_sub_distrib] + +lemma noDrop_translation {d : ℕ} (ℓ : Vector d) (z x : Lattice d) : + (fun X : Path d => fun n => X n - z) ⁻¹' NoDrop ℓ x = NoDrop ℓ (z + x) := by + ext X + simp only [NoDrop, Set.mem_preimage, Set.mem_ofPred_eq, dot_realPosition_add, + dot_realPosition_sub] + apply forall_congr' + intro n + constructor <;> intro h <;> linarith + +noncomputable def noDropQuenched {d : ℕ} (ℓ : Vector d) (x : Lattice d) + (ω : Environment d) : ℝ≥0∞ := quenchedKernel (ω, x) (NoDrop ℓ x) + +lemma measurable_noDropQuenched {d : ℕ} (ℓ : Vector d) (x : Lattice d) : + Measurable (noDropQuenched ℓ x) := + (Kernel.measurable_coe _ (measurableSet_noDrop ℓ x)).comp + (measurable_id.prodMk measurable_const) + +lemma noDropQuenched_translation {d : ℕ} (ℓ : Vector d) (ω : Environment d) (x : Lattice d) : + noDropQuenched ℓ x ω = noDropQuenched ℓ 0 (fun a => ω (x + a)) := by + have h := congrArg (fun μ : Measure (Path d) => μ (NoDrop ℓ 0)) + (quenched_translation ω x 0) + rw [Measure.map_apply (by fun_prop) (measurableSet_noDrop ℓ 0), noDrop_translation] at h + simpa [noDropQuenched] using h + +lemma annealed_noDrop_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x : Lattice d) : + (∫⁻ ω, noDropQuenched ℓ x ω ∂environmentLaw ν) = annealedLaw ν (NoDrop ℓ 0) := by + simp_rw [noDropQuenched_translation ℓ _ x] + rw [← lintegral_map (measurable_noDropQuenched ℓ 0) (by fun_prop), + environment_translation, annealed_apply ν (measurableSet_noDrop ℓ 0)] + rfl + +def FutureNoDrop {d : ℕ} (ℓ : Vector d) (n : ℕ) : Set (Path d) := + {X | ∀ i, dot (realPosition (X n)) ℓ ≤ dot (realPosition (X (n + i))) ℓ} + +lemma measurableSet_futureNoDrop {d : ℕ} (ℓ : Vector d) (n : ℕ) : + MeasurableSet (FutureNoDrop ℓ n) := by + simp only [FutureNoDrop, Set.ofPred_forall] + apply MeasurableSet.iInter + intro i + exact measurableSet_le + ((measurable_of_countable (fun y : Lattice d => dot (realPosition y) ℓ)).comp + (measurable_pi_apply n)) + ((measurable_of_countable (fun y : Lattice d => dot (realPosition y) ℓ)).comp + (measurable_pi_apply (n + i))) + +lemma tendsto_atTop_has_minimum (a : ℕ → ℝ) (ha : Tendsto a atTop atTop) : + ∃ n, ∀ j, a n ≤ a j := by + obtain ⟨N, hN⟩ := eventually_atTop.mp (ha.eventually (eventually_ge_atTop (a 0))) + obtain ⟨n, hn, hmin⟩ := Finset.exists_min_image (Finset.range (N + 1)) a + ⟨0, by simp⟩ + refine ⟨n, fun j => ?_⟩ + by_cases hj : N ≤ j + · exact (hmin 0 (by simp)).trans (hN j hj) + · exact hmin j (Finset.mem_range.mpr (by omega)) + +def extendPrefix {d : ℕ} (n : ℕ) (f : (i : Finset.Iic n) → Lattice d) : Path d := + fun i => if hi : i ≤ n then f ⟨i, Finset.mem_Iic.mpr hi⟩ else 0 + +lemma extendPrefix_apply {d : ℕ} (n : ℕ) (f : (i : Finset.Iic n) → Lattice d) + (i : ℕ) (hi : i ≤ n) : + extendPrefix n f i = f ⟨i, Finset.mem_Iic.mpr hi⟩ := by + simp [extendPrefix, hi] + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WordPrefixes.lean b/lean/OAI/Probability/Ballisticity/Estimates/WordPrefixes.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6d45caa6e29417b288b66962b63d9d8ca98000a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WordPrefixes.lean @@ -0,0 +1,202 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RelativeBudget + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma wordPath_take {d : ℕ} (x : Lattice d) (w : List (Direction d)) (n i : ℕ) + (hi : i≤n) : wordPath x (w.take n) i=wordPath x w i := by + by_cases hn : n≤w.length + · have hp := wordPath_append_prefix x (w.take n) (w.drop n) + (n:=i) (by simpa only [List.length_take,Nat.min_eq_left hn] using hi) + simpa only [List.take_append_drop] using hp.symm + · rw [List.take_of_length_le (by omega)] + +noncomputable def wordPrefix {d : ℕ} (e : Direction d) (x : Lattice d) (h : ℕ) + (w : List (Direction d)) := w.take (wordFirstHitTime e x h w) + +lemma wordFirstHitTime_le_end {d : ℕ} (e : Direction d) (x : Lattice d) (h H : ℕ) + (hh : h≤H) (w : CoordinateWord e x H) : wordFirstHitTime e x h w.val≤w.val.length := by + apply wordFirstHitTime_le + rw [wordPath_hit_exact] + omega + +lemma wordPrefix_length {d : ℕ} (e : Direction d) (x : Lattice d) (h H : ℕ) + (hh : h≤H) (w : CoordinateWord e x H) : (wordPrefix e x h w.val).length=wordFirstHitTime e x h w.val := by + simp only [wordPrefix,List.length_take,Nat.min_eq_left (wordFirstHitTime_le_end e x h H hh w)] + +lemma wordPrefix_hit {d : ℕ} (e : Direction d) (x : Lattice d) (h H : ℕ) + (hh : h≤H) (w : CoordinateWord e x H) : + wordPath x (wordPrefix e x h w.val)∈HitAt (Strip (realPosition (step e)) x h) + (Upper (realPosition (step e)) x h) (wordPrefix e x h w.val).length := by + rw [wordPrefix_length e x h H hh w] + constructor + · rw [coordinate_mem_upper_iff] + unfold wordPrefix + rw [wordPath_take x w.val _ _ le_rfl] + exact wordFirstHitTime_spec e x h w.val ⟨w.val.length,by + rw [wordPath_hit_exact]; omega⟩ + · intro i hi + rw [coordinate_mem_strip_iff] + unfold wordPrefix + rw [wordPath_take x w.val _ i hi.le] + refine ⟨?_,wordFirstHitTime_min e x h w.val hi⟩ + have h := (coordinate_mem_strip_iff e x _ H).mp + (w.property.2 i (hi.trans_le (wordFirstHitTime_le_end e x h H hh w))) + exact h.1 + +noncomputable def coordinateWordPrefix {d : ℕ} (e : Direction d) (x : Lattice d) + (h H : ℕ) (hh : h≤H) (w : CoordinateWord e x H) : CoordinateWord e x h := + ⟨wordPrefix e x h w.val,wordPrefix_hit e x h H hh w⟩ + +lemma wordCylinder_prefix {d : ℕ} (e : Direction d) (x : Lattice d) (h : ℕ) + (w : List (Direction d)) : wordCylinder x w ⊆ wordCylinder x (wordPrefix e x h w) := by + intro X hX i hi + have hlen : (wordPrefix e x h w).length≤w.length := by + simp only [wordPrefix,List.length_take]; exact min_le_right _ _ + have hin : i≤wordFirstHitTime e x h w := by + exact hi.trans (by simp only [wordPrefix,List.length_take]; exact min_le_left _ _) + exact (hX i (hi.trans hlen)).trans (wordPath_take x w _ i hin).symm + +lemma successfulWordLaw_prefix_le {d : ℕ} (e : Direction d) (ω : Environment d) + (x : Lattice d) (h H : ℕ) (hh : h≤H) : + (successfulWordLaw ω x (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H)).map + (coordinateWordPrefix e x h H hh) ≤ + successfulWordLaw ω x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h) := by + apply Measure.le_iff.mpr + intro E hE + rw [Measure.map_apply (measurable_of_countable _) hE, + successfulWordLaw_event _ _ _ _ (disjoint_strip_upper _ _ _), + successfulWordLaw_event _ _ _ _ (disjoint_strip_upper _ _ _)] + apply measure_mono + intro X hX + obtain ⟨w,hw⟩ := Set.mem_iUnion.mp hX + exact Set.mem_iUnion.mpr ⟨⟨coordinateWordPrefix e x h H hh w.val,w.property⟩, + wordCylinder_prefix e x h w.val.val hw⟩ + +lemma rawWordLaw_prefix_le {d : ℕ} (e : Direction d) (ω : Environment d) + (x : Lattice d) (h H : ℕ) (hh : h≤H) : + (rawWordLaw (realPosition (step e)) H ω x).map (wordPrefix e x h)≤ + rawWordLaw (realPosition (step e)) h ω x := by + let μ : Measure (CoordinateWord e x H) := successfulWordLaw ω x + (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) + let μ' : Measure (CoordinateWord e x h) := successfulWordLaw ω x + (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h) + have hf : (μ.map (coordinateWordPrefix e x h H hh)).map Subtype.val≤μ'.map Subtype.val := + Measure.map_mono (successfulWordLaw_prefix_le e ω x h H hh) measurable_subtype_coe + rw [Measure.map_map measurable_subtype_coe (measurable_of_countable _)] at hf + change (μ.map Subtype.val).map (wordPrefix e x h)≤μ'.map Subtype.val + rw [Measure.map_map (measurable_of_countable _) measurable_subtype_coe] + exact hf + +noncomputable def tupleWordPrefix {d k : ℕ} (e : Direction d) (x : Fin k → Lattice d) (h : ℕ) + (w : Fin k → List (Direction d)) : Fin k → List (Direction d) := fun j => wordPrefix e (x j) h (w j) + +lemma rawTupleWordLaw_prefix_le {d k : ℕ} (e : Direction d) (ω : Environment d) + (x : Fin k → Lattice d) (h H : ℕ) (hh : h≤H) : + (rawTupleWordLaw (realPosition (step e)) H ω x).map (tupleWordPrefix e x h)≤ + rawTupleWordLaw (realPosition (step e)) h ω x := by + change (Measure.pi (fun j => rawWordLaw (realPosition (step e)) H ω (x j))).map + (fun w j => wordPrefix e (x j) h (w j))≤_ + rw [Measure.pi_map_pi (fun _ => (measurable_of_countable _).aemeasurable)] + exact TupleKernel.countable_pi_mono k _ _ fun j => rawWordLaw_prefix_le e ω (x j) h H hh + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma relativeWordDisplacement_prefix {d : ℕ} (e f : Direction d) (x : Lattice d) + (h H : ℕ) (hh : h≤H) (s : ℕ) (hs : s≤h) (w : CoordinateWord e x H) : + relativeWordDisplacement e f x s (wordPrefix e x h w.val)=relativeWordDisplacement e f x s w.val := by + have he := relativeWordDisplacement_append_prefix e f x h s hs + (coordinateWordPrefix e x h H hh w) (w.val.drop (wordFirstHitTime e x h w.val)) + change relativeWordDisplacement e f x s (w.val.take (wordFirstHitTime e x h w.val)++ + w.val.drop (wordFirstHitTime e x h w.val))=_ at he + rw [List.take_append_drop] at he + exact he.symm + +lemma tupleRelativeBudget_prefix {d k : ℕ} (e f : Direction d) (x : Fin k → Lattice d) + (h H : ℕ) (hh : h≤H) (r : ℝ) (w : ∀ j, CoordinateWord e (x j) H) + (hw : TupleRelativeBudget e f x H r (fun j => (w j).val)) : + TupleRelativeBudget e f x h r (tupleWordPrefix e x h (fun j => (w j).val)) := by + intro s hs i j + change |relativeWordDisplacement e f (x i) s (wordPrefix e (x i) h (w i).val)- + relativeWordDisplacement e f (x j) s (wordPrefix e (x j) h (w j).val)|≤r + rw [relativeWordDisplacement_prefix e f (x i) h H hh s hs (w i), + relativeWordDisplacement_prefix e f (x j) h H hh s hs (w j)] + exact hw s (hs.trans hh) i j + +lemma tupleRelativeBudget_prefix_separation {d k : ℕ} (e f : Direction d) + (x : Fin k → Lattice d) (h H : ℕ) (hh : h≤H) (G r : ℝ) + (w : ∀ j, CoordinateWord e (x j) H) (hG : TupleSeparated f G x) + (hw : TupleRelativeBudget e f x H r (fun j => (w j).val)) : + TupleSeparated f (G-r) (tupleWordEndpoint x (tupleWordPrefix e x h (fun j => (w j).val))) := + tupleRelativeBudget_separation e f x h G r (fun j => coordinateWordPrefix e (x j) h H hh (w j)) + hG (tupleRelativeBudget_prefix e f x h H hh r w hw) + +lemma rawTupleWordLaw_valid_ae {d k : ℕ} (e : Direction d) (ω : Environment d) + (x : Fin k → Lattice d) (H : ℕ) : + ∀ᵐ w ∂rawTupleWordLaw (realPosition (step e)) H ω x, ∀ j, + wordPath (x j) (w j)∈HitAt (Strip (realPosition (step e)) (x j) H) + (Upper (realPosition (step e)) (x j) H) (w j).length := by + apply ae_iff_of_countable.mpr + intro w hw j + by_contra hj + apply hw + rw [rawTupleWordLaw_singleton] + apply Finset.prod_eq_zero (Finset.mem_univ j) + rw [rawWordLaw_singleton,ite_eq_right hj] + +lemma relativeBudgetWordLaw_prefix_separation_ae {d k : ℕ} (e f : Direction d) + (ω : Environment d) (x : Fin k → Lattice d) (h H : ℕ) (hh : h≤H) (G r : ℝ) + (hG : TupleSeparated f G x) : + ∀ᵐ w ∂relativeBudgetWordLaw e f H r ω x, + TupleSeparated f (G-r) (tupleWordEndpoint x (tupleWordPrefix e x h w)) := by + have hv := (rawTupleWordLaw_valid_ae e ω x H).filter_mono + (ae_mono (show relativeBudgetWordLaw e f H r ω x≤rawTupleWordLaw (realPosition (step e)) H ω x from + Measure.restrict_le_self)) + have hb : ∀ᵐ w ∂relativeBudgetWordLaw e f H r ω x,TupleRelativeBudget e f x H r w := + ae_restrict_mem (Set.to_countable _).measurableSet + filter_upwards [hv,hb] with w hw hb + exact tupleRelativeBudget_prefix_separation e f x h H hh G r (fun j => ⟨w j,hw j⟩) hG hb + +theorem budget_prefix_certificate {d k : ℕ} (e f : Direction d) (ω : Environment d) + (x : Fin k → Lattice d) (h H : ℕ) (hh : h≤H) (G r : ℝ) + (hG : TupleSeparated f G x) : + relativeBudgetWordLaw e f H r ω x Set.univ ≤ + rawTupleEndpointLaw (realPosition (step e)) h ω x {y | TupleSeparated f (G-r) y} := by + let P := fun w : Fin k → List (Direction d) => tupleWordEndpoint x (tupleWordPrefix e x h w) + have hle : (relativeBudgetWordLaw e f H r ω x).map P≤rawTupleEndpointLaw (realPosition (step e)) h ω x := by + rw [←rawTupleWordLaw_endpoint (realPosition (step e)) h ω x] + have hp := (Measure.map_mono (show relativeBudgetWordLaw e f H r ω x≤ + rawTupleWordLaw (realPosition (step e)) H ω x from Measure.restrict_le_self) + (measurable_of_countable (tupleWordPrefix e x h))).trans (rawTupleWordLaw_prefix_le e ω x h H hh) + have he := Measure.map_mono hp (measurable_of_countable (tupleWordEndpoint x)) + rw [Measure.map_map (measurable_of_countable _) (measurable_of_countable _)] at he + exact he + have he : (relativeBudgetWordLaw e f H r ω x).map P {y | TupleSeparated f (G-r) y}= + relativeBudgetWordLaw e f H r ω x Set.univ := by + rw [Measure.map_apply (measurable_of_countable _) (Set.to_countable _).measurableSet] + apply measure_congr + filter_upwards [relativeBudgetWordLaw_prefix_separation_ae e f ω x h H hh G r hG] with w hw + apply propext + exact iff_true_intro hw + rw [←he] + exact hle _ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Estimates/WordTemplate.lean b/lean/OAI/Probability/Ballisticity/Estimates/WordTemplate.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bce1a138bb43239b0c2ae1f795fe6ce52bebbb0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Estimates/WordTemplate.lean @@ -0,0 +1,452 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.LatticeVector + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma independent_past_current {Ω β : Type*} [MeasurableSpace Ω] [MeasurableSpace β] + (μ : Measure Ω) (W : ℕ → Ω → β) (hW : ∀ i, Measurable (W i)) + (hInd : iIndepFun W μ) (i : ℕ) : + IndepFun (fun x => fun j : Fin i => W j x) (W i) μ := by + have hd : Disjoint (Finset.range i) {i} := by simp + have hh := hInd.indepFun_finset (Finset.range i) {i} hd hW + have hc := hh.comp + (show Measurable (fun f : (j : ↑(Finset.range i)) → β => + fun j : Fin i => f ⟨j, Finset.mem_range.mpr j.2⟩) by fun_prop) + (show Measurable (fun f : (j : ↑({i} : Finset ℕ)) → β => + f ⟨i, Finset.mem_singleton.mpr rfl⟩) by fun_prop) + exact hc + +lemma independent_past_event {Ω β : Type*} [MeasurableSpace Ω] [MeasurableSpace β] + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : ℕ → Ω → β) + (hW : ∀ i, Measurable (W i)) (hInd : iIndepFun W μ) (i : ℕ) + (A : Set β) (G : Set (Fin i → β)) (hA : MeasurableSet A) (hG : MeasurableSet G) : + μ.real {x | W i x ∈ A ∧ (fun j : Fin i => W j x) ∈ G} = + μ.real (W i ⁻¹' A) * μ.real {x | (fun j : Fin i => W j x) ∈ G} := by + have hh := (independent_past_current μ W hW hInd i).symm.measure_inter_preimage_eq_mul + A G hA hG + exact congrArg ENNReal.toReal hh |>.trans ENNReal.toReal_mul + +lemma regeneration_span {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (n j : ℕ) (hj : j ≤ (regenerationWords ℓ X n).length) : + X (regenerationTimes ℓ X n + j) = X (regenerationTimes ℓ X n) + + wordPath 0 (regenerationWords ℓ X n) j := by + have hh := (hX n).2.1 j hj + rw [iterate_renewSuffix_eq ℓ X h0] at hh + exact (sub_eq_iff_eq_add.mp hh).trans (add_comm _ _) + +lemma regeneration_height_sum {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (n : ℕ) : dot (realPosition (X (regenerationTimes ℓ X n))) ℓ = + ∑ i ∈ Finset.range n, wordHeightGain ℓ (regenerationWords ℓ X i) := by + induction n with + | zero => simp [h0, dot, realPosition] + | succ n ih => + rw [regenerationTimes_succ, regeneration_span ℓ X h0 hX n _ (by rfl), + dot_realPosition_add, ih, Finset.sum_range_succ, wordHeightGain] + +lemma regeneration_radius_sum {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (n : ℕ) : ‖latticeVector (X (regenerationTimes ℓ X n))‖ ≤ + ∑ i ∈ Finset.range n, wordRadius (regenerationWords ℓ X i) := by + induction n with + | zero => simp [h0] + | succ n ih => + rw [regenerationTimes_succ, regeneration_span ℓ X h0 hX n _ (by rfl), + latticeVector_add, Finset.sum_range_succ] + exact (norm_add_le _ _).trans (add_le_add ih (wordRadius_bound _ (by rfl))) + +lemma regeneration_word_admissible {d : ℕ} (ℓ : Vector d) (X : Path d) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (n : ℕ) : AdmissibleTrueWord ℓ (regenerationWords ℓ X n) := + ((firstTrueWord_characterization ℓ _ _ (hX n).2.1).mp ⟨(hX n).1, (hX n).2.2⟩).1 + +lemma regeneration_span_bounds {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (n j : ℕ) (hj : j ≤ (regenerationWords ℓ X n).length) : + (dot (realPosition (X (regenerationTimes ℓ X n))) ℓ ≤ + dot (realPosition (X (regenerationTimes ℓ X n + j))) ℓ ∧ + dot (realPosition (X (regenerationTimes ℓ X n + j))) ℓ ≤ + dot (realPosition (X (regenerationTimes ℓ X (n+1)))) ℓ) ∧ + ‖latticeVector (X (regenerationTimes ℓ X n + j))‖ ≤ + (∑ i ∈ Finset.range n, wordRadius (regenerationWords ℓ X i)) + + wordRadius (regenerationWords ℓ X n) := by + have hw := regeneration_word_admissible ℓ X hX n + have hlo : 0 ≤ dot (realPosition (wordPath 0 (regenerationWords ℓ X n) j)) ℓ := by + rcases lt_or_eq_of_le hj with hj' | rfl + · exact (hw.2.1 j hj').1 + · exact (wordHeightGain_positive ℓ _ hw).le + have hhi : dot (realPosition (wordPath 0 (regenerationWords ℓ X n) j)) ℓ ≤ + wordHeightGain ℓ (regenerationWords ℓ X n) := by + rcases lt_or_eq_of_le hj with hj' | rfl + · exact (hw.2.1 j hj').2.le + · rfl + rw [regeneration_span ℓ X h0 hX n j hj, dot_realPosition_add, latticeVector_add] + constructor + · rw [regenerationTimes_succ, regeneration_span ℓ X h0 hX n _ (by rfl), dot_realPosition_add] + exact ⟨le_add_of_nonneg_right hlo, add_le_add (le_refl _) hhi⟩ + · exact (norm_add_le _ _).trans + (add_le_add (regeneration_radius_sum ℓ X h0 hX n) (wordRadius_bound _ hj)) + +lemma increasing_cuts_cover (T : ℕ → ℕ) (hT : StrictMono T) (h0 : T 0 = 0) (j : ℕ) : + ∃ n, T n ≤ j ∧ j < T (n+1) := by + have hex : ∃ n, j < T n := ⟨j+1, lt_of_lt_of_le (by omega) hT.le_apply⟩ + let n := Nat.find hex + have hn : j < T n := Nat.find_spec hex + have hn0 : 0 < n := by + by_contra h + have : n = 0 := by omega + simp [this, h0] at hn + refine ⟨n-1, ?_, ?_⟩ + · exact le_of_not_gt (Nat.find_min hex (by dsimp only [n] at hn0 ⊢; omega)) + · simpa only [Nat.sub_add_cancel hn0] using hn + +lemma regeneration_prefix_radius {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + {K j : ℕ} (hj : j ≤ regenerationTimes ℓ X K) : + ‖latticeVector (X j)‖ ≤ ∑ i ∈ Finset.range K, wordRadius (regenerationWords ℓ X i) := by + rcases lt_or_eq_of_le hj with hj' | rfl + · obtain ⟨n, hn, hn'⟩ := increasing_cuts_cover (regenerationTimes ℓ X) + (regenerationTimes_strictMono ℓ X hX) (regenerationTimes_zero ℓ X) j + have hnK : n < K := (regenerationTimes_strictMono ℓ X hX).lt_iff_lt.mp (hn.trans_lt hj') + have hh := (regeneration_span_bounds ℓ X h0 hX n (j-regenerationTimes ℓ X n) + (by rw [regenerationTimes_succ] at hn'; omega)).2 + rw [Nat.add_sub_of_le hn, ← Finset.sum_range_succ] at hh + exact hh.trans (Finset.sum_le_sum_of_subset_of_nonneg + (Finset.range_mono (by omega : n+1 ≤ K)) (fun _ _ _ => wordRadius_nonneg _)) + · exact regeneration_radius_sum ℓ X h0 hX K + +lemma regeneration_prefix_height {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + {K j : ℕ} (hj : j ≤ regenerationTimes ℓ X K) : + 0 ≤ dot (realPosition (X j)) ℓ ∧ + dot (realPosition (X j)) ℓ ≤ ∑ i ∈ Finset.range K, + wordHeightGain ℓ (regenerationWords ℓ X i) := by + have ht := regenerationTimes_true ℓ X h0 hX K + have hnd := (hX 0).1 j + have hzero : dot (realPosition (0 : Lattice d)) ℓ = 0 := by simp [dot, realPosition] + change dot (realPosition (0 : Lattice d)) ℓ ≤ dot (realPosition (X j)) ℓ at hnd + rw [hzero] at hnd + refine ⟨hnd, ?_⟩ + rw [← regeneration_height_sum ℓ X h0 hX K] + rcases lt_or_eq_of_le hj with hj' | rfl + · exact (ht.1 j hj').le + · rfl + +lemma truncatedMean_increment_bounds {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) {s t : ℝ} (hs : 0 ≤ s) (hst : s ≤ t) : + (t-s) * μ.real {x | t < f x} ≤ truncatedMean μ f t - truncatedMean μ f s ∧ + truncatedMean μ f t - truncatedMean μ f s ≤ (t-s) * μ.real {x | s < f x} := by + have hms : MeasurableSet {x | s < f x} := measurableSet_lt measurable_const hf + have hmt : MeasurableSet {x | t < f x} := measurableSet_lt measurable_const hf + have his := integrable_min_nonneg μ f hf hfn s hs + have hit := integrable_min_nonneg μ f hf hfn t (hs.trans hst) + have he : truncatedMean μ f t - truncatedMean μ f s = + ∫ x, min (f x) t - min (f x) s ∂μ := by + rw [integral_sub hit his]; rfl + rw [he] + constructor + · have hb := integral_mono ((integrable_const (t-s)).indicator hmt) (hit.sub his) + (show ∀ x, Set.indicator {x | t < f x} (fun _ => t-s) x ≤ + min (f x) t - min (f x) s from by + intro x + by_cases hx : t < f x + · simp only [Set.indicator_of_mem (show x ∈ {x | t < f x} from hx), min_eq_right hx.le, + min_eq_right (hst.trans hx.le), le_refl] + · rw [Set.indicator_of_notMem (show x ∉ {x | t < f x} from hx)] + exact sub_nonneg.mpr (min_le_min le_rfl hst)) + simpa only [integral_indicator_const (t-s) hmt, smul_eq_mul, mul_comm, Pi.sub_apply] using hb + · have hb := integral_mono (hit.sub his) ((integrable_const (t-s)).indicator hms) + (show ∀ x, min (f x) t - min (f x) s ≤ + Set.indicator {x | s < f x} (fun _ => t-s) x from by + intro x + by_cases hx : s < f x + · rw [Set.indicator_of_mem (show x ∈ {x | s < f x} from hx), min_eq_right hx.le] + exact sub_le_sub_right (min_le_right _ _) _ + · rw [Set.indicator_of_notMem (show x ∉ {x | s < f x} from hx), min_eq_left (le_of_not_gt hx), + min_eq_left ((le_of_not_gt hx).trans hst), sub_self]) + simpa only [integral_indicator_const (t-s) hms, smul_eq_mul, mul_comm, Pi.sub_apply] using hb + +lemma scaled_tail_sum_lower {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) {a : ℝ} (ha : 0 ≤ a) {m n : ℕ} (hmn : m ≤ n) : + truncatedMean μ f (a*n) - truncatedMean μ f (a*m) ≤ + a * ∑ i ∈ Finset.Ico m n, μ.real {x | a*i < f x} := by + have hb : ∀ i : ℕ, truncatedMean μ f (a*(i+1)) - truncatedMean μ f (a*i) ≤ + a * μ.real {x | a*i < f x} := by + intro i + have hh := (truncatedMean_increment_bounds μ f hf hfn + (mul_nonneg ha (Nat.cast_nonneg i)) (by nlinarith : a*i ≤ a*(i+1))).2 + convert hh using 1; ring + have hh := Finset.sum_le_sum (fun i (_ : i ∈ Finset.Ico m n) => hb i) + have he := Finset.sum_Ico_sub (fun i : ℕ => truncatedMean μ f (a*i)) hmn + simp only [Nat.cast_add, Nat.cast_one] at he + rw [he, ← Finset.mul_sum] at hh + exact hh + +lemma scaled_tail_sum_upper {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) {a : ℝ} (ha : 0 ≤ a) (n : ℕ) : + a * ∑ i ∈ Finset.range n, μ.real {x | a*(i+1) < f x} ≤ + truncatedMean μ f (a*n) := by + have hb : ∀ i : ℕ, a * μ.real {x | a*(i+1) < f x} ≤ + truncatedMean μ f (a*(i+1)) - truncatedMean μ f (a*i) := by + intro i + have hh := (truncatedMean_increment_bounds μ f hf hfn + (mul_nonneg ha (Nat.cast_nonneg i)) (by nlinarith : a*i ≤ a*(i+1))).1 + convert hh using 1; ring + have hh := Finset.sum_le_sum (fun i (_ : i ∈ Finset.range n) => hb i) + have he := Finset.sum_range_sub (fun i : ℕ => truncatedMean μ f (a*i)) n + simp only [Nat.cast_add, Nat.cast_one, Nat.cast_zero, mul_zero] at he + rw [← Finset.mul_sum, he] at hh + have hz : truncatedMean μ f 0 = 0 := by + simp only [truncatedMean, min_eq_right (hfn _), integral_zero] + rwa [hz, sub_zero] at hh + +lemma summable_positive_tail {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (hint : Integrable f μ) : + Summable (fun i : ℕ => μ.real {x | (i : ℝ) < f x}) := by + apply (summable_nat_add_iff 1).mp + apply summable_of_sum_range_le (fun _ => measureReal_nonneg) + intro n + have hb := scaled_tail_sum_upper μ f hf hfn (show (0:ℝ) ≤ 1 by norm_num) n + have hu : truncatedMean μ f (1*n) ≤ ∫ x, f x ∂μ := + integral_mono (integrable_min_nonneg μ f hf hfn _ (by positivity)) hint + (fun x => min_le_left _ _) + simpa only [one_mul, Nat.cast_add, Nat.cast_one] using hb.trans hu + +lemma positive_tail_sums_eventually_small {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (hint : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ m : ℕ in atTop, ∀ n, (∑ i ∈ Finset.Ico m n, + μ.real {x | (i : ℝ) < f x}) < ε := by + have hs := summable_positive_tail μ f hf hfn hint + have ht := (tendsto_sum_nat_add (fun i : ℕ => μ.real {x | (i : ℝ) < f x})).eventually + (Iio_mem_nhds hε) + filter_upwards [ht] with m hm n + rw [Finset.sum_Ico_eq_sum_range] + have hh := ((summable_nat_add_iff m).mpr hs).sum_le_tsum (Finset.range (n-m)) + (fun _ _ => measureReal_nonneg) + have he : (∑ i ∈ Finset.range (n-m), μ.real {x | ((m+i : ℕ) : ℝ) < f x}) = + ∑ i ∈ Finset.range (n-m), μ.real {x | ((i+m : ℕ) : ℝ) < f x} := by + apply Finset.sum_congr rfl; intro i _; rw [Nat.add_comm] + rw [he] + exact hh.trans_lt hm + +lemma restricted_large_word_intensity {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (R L : Ω → ℝ) (hR : Measurable R) + (hRn : ∀ x, 0 ≤ R x) {a B η : ℝ} (ha : 0 < a) (hB : 1 ≤ B) + {m N : ℕ} (hm : 1 ≤ m) (hmN : m ≤ N+1) + (hlo : η*a ≤ truncatedMean μ R (a*N)) + (hhi : truncatedMean μ R (a*N) < 2*η*a) + (hbase : truncatedMean μ R (B*a*m) < η*a/4) + (hwidth : (∑ i ∈ Finset.Ico m (N+1), μ.real {x | (i:ℝ) < L x}) < η/(4*B)) : + η/(2*B) ≤ (∑ i ∈ Finset.Ico m (N+1), + μ.real {x | B*a*i < R x ∧ L x ≤ (i:ℝ)}) ∧ + (∑ i ∈ Finset.Ico m (N+1), + μ.real {x | B*a*i < R x ∧ L x ≤ (i:ℝ)}) < 2*η := by + have hBpos : 0 < B := lt_of_lt_of_le zero_lt_one hB + have hBa : 0 < B*a := mul_pos hBpos ha + let S := Finset.Ico m (N+1) + let lam := ∑ i ∈ S, μ.real {x | B*a*i < R x ∧ L x ≤ (i:ℝ)} + have hlose : (∑ i ∈ S, μ.real {x | B*a*i < R x}) ≤ + lam + ∑ i ∈ S, μ.real {x | (i:ℝ) < L x} := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro i _ + calc + _ ≤ μ.real ({x | B*a*i < R x ∧ L x ≤ (i:ℝ)} ∪ {x | (i:ℝ) < L x}) := by + apply measureReal_mono (μ := μ) + intro x hx + by_cases hl : L x ≤ (i:ℝ) + · exact Or.inl ⟨hx,hl⟩ + · exact Or.inr (lt_of_not_ge hl) + _ ≤ _ := measureReal_union_le _ _ + have hlow := scaled_tail_sum_lower μ R hR hRn hBa.le hmN + have hmon : truncatedMean μ R (a*N) ≤ truncatedMean μ R (B*a*(N+1)) := by + apply truncatedMean_mono μ R hR hRn (by positivity) + have he : a*N ≤ B*(a*N) := le_mul_of_one_le_left (by positivity) hB + nlinarith + have hupper0 : (∑ i ∈ S, μ.real {x | B*a*i < R x ∧ L x ≤ (i:ℝ)}) ≤ + ∑ i ∈ Finset.Ico 1 (N+1), μ.real {x | B*a*i < R x} := by + calc + _ ≤ ∑ i ∈ S, μ.real {x | B*a*i < R x} := + Finset.sum_le_sum (fun _ _ => measureReal_mono (μ := μ) (fun _ hx => hx.1)) + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg + (fun i hi => Finset.mem_Ico.mpr ⟨hm.trans (Finset.mem_Ico.mp hi).1,(Finset.mem_Ico.mp hi).2⟩) + (fun _ _ _ => measureReal_nonneg) + have he : (∑ i ∈ Finset.Ico 1 (N+1), μ.real {x | B*a*i < R x}) = + ∑ i ∈ Finset.range N, μ.real {x | B*a*(i+1) < R x} := by + rw [Finset.sum_Ico_eq_sum_range] + simp only [Nat.add_sub_cancel, Nat.cast_add, Nat.cast_one] + apply Finset.sum_congr rfl + intro i _ + rw [add_comm (1:ℝ)] + rw [he] at hupper0 + have hupper1 := scaled_tail_sum_upper μ R hR hRn hBa.le N + have hupper2 := truncatedMean_mul_le μ R hR hRn + (show 0 ≤ a*N by positivity) hB + rw [← mul_assoc] at hupper2 + constructor + · apply (div_le_iff₀ (by positivity : 0 < 2*B)).mpr + have hw := (lt_div_iff₀ (by positivity : 0 < 4*B)).mp hwidth + have hmnow := mul_le_mul_of_nonneg_left hlose hBa.le + change (B*a)*(∑ i ∈ S, μ.real {x | B*a*i < R x}) ≤ (B*a)*(lam+_) at hmnow + have haN : B*a*(N+1 : ℕ) = B*a*(N+1) := by push_cast; rfl + rw [haN] at hlow + dsimp only [S] at hmnow + nlinarith + · have hh := mul_le_mul_of_nonneg_left hupper0 hBa.le + have hhh := mul_lt_mul_of_pos_left hhi hBpos + nlinarith + +lemma independent_rare_word_past {Ω β : Type*} [MeasurableSpace Ω] [MeasurableSpace β] + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : ℕ → Ω → β) + (hW : ∀ i, Measurable (W i)) (hInd : iIndepFun W μ) + (S : Finset ℕ) (A : ℕ → Set β) (G : (i : ℕ) → Set (Fin i → β)) + (hA : ∀ i, MeasurableSet (A i)) (hG : ∀ i, MeasurableSet (G i)) + (q : ℝ) (hprev : ∀ i ∈ S, q ≤ μ.real {x | (fun j : Fin i => W j x) ∈ G i}) : + q * (∑ i ∈ S, μ.real (W i ⁻¹' A i)) - + (∑ i ∈ S, μ.real (W i ⁻¹' A i))^2 / 2 ≤ + μ.real {x | ∃ i ∈ S, W i x ∈ A i ∧ (fun j : Fin i => W j x) ∈ G i} := by + apply independent_rare_words_lower_bound μ S + (fun i => W i ⁻¹' A i) (fun i => (fun x j => W (j : Fin i) x) ⁻¹' G i) + (fun i => (hA i).preimage (hW i)) (fun i => (hG i).preimage (by fun_prop)) + q + · intro i hi + rw [show (W i ⁻¹' A i) ∩ ((fun x j => W (j : Fin i) x) ⁻¹' G i) = + {x | W i x ∈ A i ∧ (fun j : Fin i => W j x) ∈ G i} from rfl, + independent_past_event μ W hW hInd i (A i) (G i) (hA i) (hG i), mul_comm] + exact mul_le_mul_of_nonneg_left (hprev i hi) measureReal_nonneg + · intro i _ j _ hij + have hh := (hInd.indepFun hij).measure_inter_preimage_eq_mul (A i) (A j) (hA i) (hA j) + exact congrArg ENNReal.toReal hh |>.trans ENNReal.toReal_mul + +lemma polynomial_lower_from_small_intensity {B η lam p : ℝ} + (hB : 0 < B) (hη : 0 < η) (hηsmall : η ≤ 1/10) + (hlow : η/(2*B) ≤ lam) (hupper : lam ≤ 2*η) + (hp : (4/5)*lam - lam^2/2 ≤ p) : η/(4*B) ≤ p := by + have hlam : 0 ≤ lam := (div_pos hη (by positivity)).le.trans hlow + have hsmall : lam ≤ 1/5 := by linarith + have hprod := mul_le_mul_of_nonneg_left hsmall hlam + have he : η/(4*B) = (η/(2*B))/2 := by field_simp; ring + rw [he] + nlinarith + +def WordTemplate {d : ℕ} (ℓ : Vector d) (c C C0 a : ℝ) (K : ℕ) : Set (Path d) := + {X | ∀ k ≤ K, + (c*k-C0 ≤ ∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) ∧ + ((∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) ≤ C*k+C0) ∧ + ((∑ j ∈ Finset.range k, wordRadius (regenerationWords ℓ X j)) ≤ a*k)} + +lemma measurableSet_wordTemplate {d : ℕ} (ℓ : Vector d) (c C C0 a : ℝ) (K : ℕ) : + MeasurableSet (WordTemplate ℓ c C C0 a K) := by + simp only [WordTemplate, Set.ofPred_forall] + apply MeasurableSet.iInter + intro k + apply MeasurableSet.iInter + intro _ + have hL : Measurable (fun X => ∑ j ∈ Finset.range k, + wordHeightGain ℓ (regenerationWords ℓ X j)) := + Finset.measurable_fun_sum _ fun j _ => + (measurable_of_countable (wordHeightGain ℓ)).comp (measurable_regenerationWord ℓ j) + have hR : Measurable (fun X => ∑ j ∈ Finset.range k, + wordRadius (regenerationWords ℓ X j)) := + Finset.measurable_fun_sum _ fun j _ => measurable_wordRadius.comp (measurable_regenerationWord ℓ j) + exact (measurableSet_le measurable_const hL).inter + ((measurableSet_le hL measurable_const).inter (measurableSet_le hR measurable_const)) + +lemma wordTemplate_antitone {d : ℕ} (ℓ : Vector d) (c C C0 a : ℝ) {K M : ℕ} (hKM : K ≤ M) : + WordTemplate ℓ c C C0 a M ⊆ WordTemplate ℓ c C C0 a K := + fun _ hX k hk => hX k (hk.trans hKM) + +lemma controlled_template_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (c C C0 η a : ℝ) (ha : 0 < a) (C1 N : ℕ) (hC1 : 1 ≤ C1) + (hheight : (19/20 : ℝ) < (conditionedLaw ν ℓ).real {X | ∀ k : ℕ, + c*k-C0 ≤ ∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j) ∧ + (∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) ≤ C*k+C0}) + (hsmall : 4*C1*η < 1/10) + (hI : truncatedMean (conditionedLaw ν ℓ) (fun X => wordRadius (firstWord ℓ X)) (a*N) < 2*η*a) : + (4/5 : ℝ) < (conditionedLaw ν ℓ).real (WordTemplate ℓ c C C0 a (C1*N)) := by + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let E : Set (Path d) := {X | ∀ k : ℕ, + c*k-C0 ≤ ∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j) ∧ + (∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) ≤ C*k+C0} + let F : Set (Path d) := {X | ∃ k, 0 < k ∧ k ≤ C1*N ∧ + a*k < ∑ j ∈ Finset.range k, wordRadius (regenerationWords ℓ X j)} + have hf : μ.real F < 4*C1*η := truncated_template_failure_bound μ _ + (renewSuffix_preserves_conditioned ν ℓ htrans) _ + (measurable_wordRadius.comp (measurable_firstWord ℓ)) (fun _ => wordRadius_nonneg _) + η a ha C1 N hC1 hI + have hsub : E ⊆ WordTemplate ℓ c C C0 a (C1*N) ∪ F := by + intro X hX + by_cases hF : X ∈ F + · exact Or.inr hF + · left + intro k hk + refine ⟨(hX k).1,(hX k).2, ?_⟩ + by_contra h + have hk0 : 0 < k := by + by_contra hk0 + have he : k = 0 := by omega + simp [he] at h + exact hF ⟨k,hk0,hk,lt_of_not_ge h⟩ + have hu := (measureReal_mono (μ := μ) hsub).trans (measureReal_union_le _ _) + change 19/20 < μ.real E at hheight + change 4/5 < μ.real (WordTemplate ℓ c C C0 a (C1*N)) + linarith + +lemma wordTemplate_congr {d : ℕ} (ℓ : Vector d) (c C C0 a : ℝ) (K : ℕ) + {X Y : Path d} (h : ∀ j < K, regenerationWords ℓ X j = regenerationWords ℓ Y j) : + X ∈ WordTemplate ℓ c C C0 a K ↔ Y ∈ WordTemplate ℓ c C C0 a K := by + have he (k : ℕ) (hk : k ≤ K) (f : List (Direction d) → ℝ) : + (∑ j ∈ Finset.range k, f (regenerationWords ℓ X j)) = + ∑ j ∈ Finset.range k, f (regenerationWords ℓ Y j) := by + apply Finset.sum_congr rfl + intro j hj + rw [h j ((Finset.mem_range.mp hj).trans_le hk)] + simp only [WordTemplate, Set.mem_ofPred_eq] + constructor <;> intro hh k hk + · simpa only [← he k hk (wordHeightGain ℓ), ← he k hk wordRadius] using hh k hk + · simpa only [he k hk (wordHeightGain ℓ), he k hk wordRadius] using hh k hk + +lemma current_word_template_independent {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (c C C0 a : ℝ) (i : ℕ) (A : Set (List (Direction d))) : + (conditionedLaw ν ℓ).real ({X | regenerationWords ℓ X i ∈ A} ∩ + WordTemplate ℓ c C C0 a i) = + (conditionedLaw ν ℓ).real {X | regenerationWords ℓ X i ∈ A} * + (conditionedLaw ν ℓ).real (WordTemplate ℓ c C C0 a i) := by + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let G : Set (Fin i → List (Direction d)) := {v | ∃ X ∈ WordTemplate ℓ c C C0 a i, + ∀ j : Fin i, v j = regenerationWords ℓ X j} + have he (X : Path d) : (fun j : Fin i => regenerationWords ℓ X j) ∈ G ↔ + X ∈ WordTemplate ℓ c C C0 a i := by + constructor + · rintro ⟨Y,hY,hXY⟩ + exact (wordTemplate_congr ℓ c C C0 a i (fun j hj => hXY ⟨j,hj⟩)).mpr hY + · intro hX + exact ⟨X,hX,fun _ => rfl⟩ + have hh := independent_past_event μ (fun j X => regenerationWords ℓ X j) + (measurable_regenerationWord ℓ) (regenerationWords_independent ν ℓ htrans) i A G + (Set.to_countable _).measurableSet (Set.to_countable _).measurableSet + simpa only [he, Set.ofPred_mem_eq, Set.inter_def, Set.mem_ofPred_eq, Set.preimage, μ] using hh + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/AlignedSlabs.lean b/lean/OAI/Probability/Ballisticity/Geometry/AlignedSlabs.lean new file mode 100644 index 0000000000000000000000000000000000000000..33c8ef0d6d5822b0b590a065f64353c0cad98a36 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/AlignedSlabs.lean @@ -0,0 +1,68 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.SignedHeight + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma signedHeight_add {d : ℕ} (e : Direction d) (x y : Lattice d) : + signedHeight e (x+y) = signedHeight e x+signedHeight e y := by + simp only [signedHeight,Pi.add_apply] + split <;> omega + +lemma signedHeight_zsmul_step {d : ℕ} (e : Direction d) (a : ℤ) : + signedHeight e (a • step e) = a := by + simp only [signedHeight,Pi.smul_apply,smul_eq_mul,step,ite_true] + split <;> simp_all + +noncomputable def alignHeight {d : ℕ} (e : Direction d) (a : ℤ) (x : Lattice d) : Lattice d := + x+(a-signedHeight e x) • step e + +lemma signedHeight_align {d : ℕ} (e : Direction d) (a : ℤ) (x : Lattice d) : + signedHeight e (alignHeight e a x) = a := by + rw [alignHeight,signedHeight_add,signedHeight_zsmul_step] + omega + +lemma alignHeight_eq_self {d : ℕ} (e : Direction d) (a : ℤ) (x : Lattice d) + (hx : signedHeight e x = a) : alignHeight e a x = x := by + simp [alignHeight,hx] + +def blockRows {d : ℕ} (e : Direction d) (H i : ℕ) : Set (Lattice d) := + {x | (i:ℤ)*H ≤ signedHeight e x ∧ signedHeight e x < (i:ℤ)*H+H} + +lemma blockRows_pairwise {d : ℕ} (e : Direction d) (H : ℕ) : + Pairwise (fun i j => Disjoint (blockRows e H i) (blockRows e H j)) := by + intro i j hij + apply Set.disjoint_left.mpr + intro x hx hy + change (i:ℤ)*H ≤ signedHeight e x ∧ signedHeight e x < (i:ℤ)*H+H at hx + change (j:ℤ)*H ≤ signedHeight e x ∧ signedHeight e x < (j:ℤ)*H+H at hy + rcases lt_or_gt_of_ne hij with h | h + · have hh : (i:ℤ)+1 ≤ j := by exact_mod_cast h + nlinarith [Int.natCast_nonneg H] + · have hh : (j:ℤ)+1 ≤ i := by exact_mod_cast h + nlinarith [Int.natCast_nonneg H] + +lemma strip_align_blockRows {d : ℕ} (e : Direction d) (H i : ℕ) (x : Lattice d) : + Strip (realPosition (step e)) (alignHeight e ((i:ℤ)*H) x) H = blockRows e H i := by + ext y + simp only [Strip,Set.mem_ofPred_eq,signedHeight_projection,signedHeight_align,blockRows] + constructor + · rintro ⟨h₁,h₂⟩ + exact ⟨by exact_mod_cast h₁,by exact_mod_cast h₂⟩ + · rintro ⟨h₁,h₂⟩ + exact ⟨by exact_mod_cast h₁,by exact_mod_cast h₂⟩ + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/BufferAllHeightRetention.lean b/lean/OAI/Probability/Ballisticity/Geometry/BufferAllHeightRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..dabacb9c4f4134cd1a582e18a757b99d21cecff9 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/BufferAllHeightRetention.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferRootRetention +import OAI.Probability.Ballisticity.Walk.BufferHistoryBracket +import OAI.Probability.Ballisticity.Estimates.RawPairMassComposition + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma buffer_all_height_retention {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + {R : ℝ} (hR : 0 ≤ R) (a ε α g : ℝ) {κ : ℝ≥0} + (hκpos : 0 < κ) (hκ1 : κ ≤ 1) (hg : 0 < g) (hg1 : g ≤ 1) + (hε : 0 ≤ ε) (hε1 : ε ≤ 1) (hα : 0 ≤ α) + (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (x : Lattice d × Lattice d) (hx : x ∈ PairAtHeight (realPosition (step e)) a) + (ω : Environment d) (hκ : ∀ y u, κ ≤ (ω y).1 u) (t : ℕ) : + ∃ n : ℕ, let l := (bufferHistory e f hef R (signedCoordinate f (x.2-x.1)) ε α g κ H hH + (bufferRootNode e f hef R a x hx) ω n); + bufferWordHeight l ≤ t ∧ + ((κ:ℝ≥0∞)^(⌈R⌉₊+2)*(bufferRetentionCost R g κ)^n)*((κ:ℝ≥0∞)^2*ENNReal.ofReal g) ≤ + rawPairEndpointLaw (realPosition (step e)) (t+1) ω x + {y | signedCoordinate f (x.2-x.1) ≤ signedCoordinate f (y.2-y.1)} := by + let z := signedCoordinate f (x.2-x.1) + let root := bufferRootNode e f hef R a x hx + obtain ⟨n,hnt,hnt'⟩ := bufferHistory_bracket e f hef R z ε α g κ H hH root ω t + let l := bufferHistory e f hef R z ε α g κ H hH root ω n + change bufferWordHeight l ≤ t at hnt + let N := bufferNodeAt e f hef R z ε α g κ H hH root l + have ha : ω ∈ N.active := by + rw [bufferNodeAt_active_iff_history,bufferHistory_length] + exact ⟨Set.mem_univ _,rfl⟩ + have hv := bufferNodeAt_valid e f hef hR z ε α g hκpos hκ1 hg hg1 hε H hH root le_rfl + (bufferRootNode_valid e f hef R a x hx κ) l + obtain ⟨hp,hgap⟩ := hv ω hκ ha + have := hp + have hnR : 0 ≤ N.radius := hR.trans (bufferNodeAt_radius e f hef R z ε α g κ H hH root le_rfl l) + have hret := bufferNodeAt_root_retained e f hef hR a ε α g hκpos hκ1 hg hg1 hε hε1 hα + H hH x hx l ω hκ ha + have hj : t-bufferWordHeight l ≤ bufferFirstFailure (realPosition (step e)) f N.level + (z+(1-ε)*N.radius) g N.law (H N.radius) ω := by + change t < _ at hnt' + simp only [bufferHistory,bufferWordHeight] at hnt' + change t < (bufferNodeDecision e f z ε α g H N ω).1+1+bufferWordHeight l at hnt' + change t < bufferFirstFailure (realPosition (step e)) f N.level (z+(1-ε)*N.radius) g N.law (H N.radius) ω+1+bufferWordHeight l at hnt' + omega + have hm := bufferPartialStage_mass e f N.level z N.radius ε α g N.law (hH N.radius) ω + (fun y => hκ y e) hκ1 hg1 hnR hε hε1 hα hgap (t-bufferWordHeight l) hj + have hb := rawPair_gap_mass_composition e f (1+bufferWordHeight l) (t-bufferWordHeight l) ω x (N.law ω).val + ((κ:ℝ≥0∞)^(⌈R⌉₊+2)*(bufferRetentionCost R g κ)^l.length) ((κ:ℝ≥0∞)^2*ENNReal.ofReal g) z hret hm + have hh : 1+bufferWordHeight l+(t-bufferWordHeight l)=t+1 := by omega + have hlen : l.length=n := bufferHistory_length e f hef R z ε α g κ H hH root ω n + refine ⟨n,hnt,?_⟩ + simpa only [hh,hlen] using hb +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/BufferElapsedHeight.lean b/lean/OAI/Probability/Ballisticity/Geometry/BufferElapsedHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..51f24c4cf2d754cfab4a5b137c343bf0f888e05a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/BufferElapsedHeight.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferTree + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def bufferWordHeight : List (ℕ × Bool) → ℕ + | [] => 0 + | p::l => p.1+1+bufferWordHeight l + +lemma bufferNodeAt_level {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R₀ z₀ ε α g : ℝ) (κ : ℝ≥0) (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (root : AdaptedBufferNode e) (l : List (ℕ × Bool)) : + (bufferNodeAt e f hef R₀ z₀ ε α g κ H hH root l).level = root.level+bufferWordHeight l := by + induction l with + | nil => simp [bufferNodeAt,bufferWordHeight] + | cons p l ih => + change (bufferNodeAt e f hef R₀ z₀ ε α g κ H hH root l).level+p.1+1 = _ + rw [ih,bufferWordHeight,Nat.cast_add,Nat.cast_add,Nat.cast_one] + ring + +lemma bufferNodeAt_radius_elapsed {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + {R₀ ε α M C : ℝ} (hR₀ : 0 < R₀) (hε : 0 ≤ ε) (hα : 0 ≤ α) (_ : 0 < M) + (hC0 : R₀ ≤ C) (hC : (1+α)*M ≤ C) + (z₀ g : ℝ) (κ : ℝ≥0) (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (hplan : ∀ r : ℝ, R₀ ≤ r → r ≤ M*(H r+1)) + (root : AdaptedBufferNode e) (hr : root.radius=R₀) (ω : Environment d) + (l : List (ℕ × Bool)) + (ha : ω ∈ (bufferNodeAt e f hef R₀ z₀ ε α g κ H hH root l).active) : + (bufferNodeAt e f hef R₀ z₀ ε α g κ H hH root l).radius ≤ C*(bufferWordHeight l+1) := by + have hCpos : 0 < C := hR₀.trans_le hC0 + induction l with + | nil => simpa [bufferNodeAt,bufferWordHeight,hr] using hC0 + | cons p l ih => + let N := bufferNodeAt e f hef R₀ z₀ ε α g κ H hH root l + have hpa : ω ∈ N.active := ha.1 + have hb : BufferStageEvent (realPosition (step e)) f (H N.radius) z₀ N.radius ε α g (N.law ω).val ω ↔ p.2=true := ha.2.2 + have hk : bufferFirstFailure (realPosition (step e)) f N.level (z₀+(1-ε)*N.radius) g N.law (H N.radius) ω=p.1 := ha.2.1 + have hNr : R₀ ≤ N.radius := bufferNodeAt_radius e f hef R₀ z₀ ε α g κ H hH root hr.ge l + have hn : 0 ≤ N.radius := hR₀.le.trans hNr + have ih' := ih hpa + change bufferNextRadius R₀ N.radius ε α p.2 ≤ C*((bufferWordHeight (p::l):ℕ)+1) + unfold bufferNextRadius + apply max_le + · apply hC0.trans + have hh : (1:ℝ) ≤ (bufferWordHeight (p::l):ℝ)+1 := by + have := Nat.cast_nonneg (α := ℝ) (bufferWordHeight (p::l)); linarith + simpa only [mul_one] using mul_le_mul_of_nonneg_left hh hCpos.le + · cases hp : p.2 + · simp only [Bool.false_eq_true,↓reduceIte] + have hdec : (1-ε)*N.radius ≤ N.radius := by nlinarith + apply hdec.trans (ih'.trans _) + apply mul_le_mul_of_nonneg_left _ hCpos.le + simp only [bufferWordHeight,Nat.cast_add,Nat.cast_one] + have ht := Nat.cast_nonneg (α := ℝ) (bufferWordHeight l) + have hk := Nat.cast_nonneg (α := ℝ) p.1 + linarith + · simp only [↓reduceIte] + have hE := hb.mpr hp + have htop := (bufferStageEvent_iff_last_tests (realPosition (step e)) f N.level z₀ + N.radius ε α g N.law (hH N.radius) ω).mp hE |>.1 + have hj := bufferFirstFailure_eq_top_of_pass (realPosition (step e)) f N.level + (z₀+(1-ε)*N.radius) g N.law (hH N.radius) ω htop + have hkH : p.1=H N.radius := hk.symm.trans hj + have hh := mul_le_mul_of_nonneg_left (hplan N.radius hNr) (show 0 ≤ 1+α by linarith) + rw [←mul_assoc] at hh + apply hh.trans + rw [←hkH] + have hmul := mul_le_mul_of_nonneg_right hC (show 0 ≤ (p.1:ℝ)+1 by positivity) + apply hmul.trans + apply mul_le_mul_of_nonneg_left _ hCpos.le + simp only [bufferWordHeight,Nat.cast_add,Nat.cast_one] + have ht := Nat.cast_nonneg (α := ℝ) (bufferWordHeight l) + have hk := Nat.cast_nonneg (α := ℝ) p.1 + linarith +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/BufferStructuralHeight.lean b/lean/OAI/Probability/Ballisticity/Geometry/BufferStructuralHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc58be132c03941928fbbd3f51db646a0a55f3bb --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/BufferStructuralHeight.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferStagePacket +import OAI.Probability.Ballisticity.Walk.BufferNormalizedRows + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma bufferStageRetainedLaw_height_unconditional {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + {H : ℕ} (hH : 0 < H) (ω : Environment d) (κ : ℝ≥0) : + ∀ᵐ y ∂bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ, + y ∈ PairAtHeight (realPosition (step e)) + (a+bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω) := by + let ℓ := realPosition (step e) + let z := z₀+(1-ε)*r + let j := bufferFirstFailure ℓ f a z g π H ω + have hπ : ∀ᵐ x ∂(π ω).val, x ∈ PairAtHeight ℓ a := ae_iff.mpr (π ω).property + have hj : 1 ≤ j := (bufferFirstFailure_bounds ℓ f a z g π hH ω).1 + unfold bufferStageRetainedLaw + dsimp only + split + · have he : j-1+1=j := by omega + simpa only [he] using upwardRetainedLaw_height e f (j-1) z ω (π ω).val κ a hπ + · rename_i hp + have hjH : j=H := bufferFirstFailure_eq_top_of_pass ℓ f a z g π hH ω (le_of_not_gt hp) + change ∀ᵐ y ∂(if _ then _ else _), y ∈ PairAtHeight ℓ (a+j) + rw [hjH] + split <;> exact retainedPairLaw_height e f H _ ω (π ω).val a hπ + +noncomputable def bufferStageStoppedProbability {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (H : ℕ) (hH : 0 < H) (κ : ℝ≥0) (k : ℕ) (ω : Environment d) : + SupportedPairMeasures (PairAtHeight (realPosition (step e)) (a+k)) := + ⟨if bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω = k + then normalizedMeasure (bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ) else 0, by + split + · rename_i hk + apply ae_iff.mp + apply Measure.ae_smul_measure + simpa only [hk] using bufferStageRetainedLaw_height_unconditional e f a z₀ r ε α g π hH ω κ + · simp⟩ + +lemma bufferStageStoppedProbability_rows {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) + (H : ℕ) (hH : 0 < H) (κ : ℝ≥0) (k : ℕ) : + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) (a+k))) _ + (bufferStageStoppedProbability e f a z₀ r ε α g π H hH κ k) := by + exact (bufferStage_normalized_stopped_rows e f a z₀ r ε α g π hπ hH κ k).subtype_mk + +lemma bufferStageStoppedProbability_gap {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (H : ℕ) (hH : 0 < H) (κ : ℝ≥0) (k : ℕ) (ω : Environment d) : + ∀ᵐ y ∂(bufferStageStoppedProbability e f a z₀ r ε α g π H hH κ k ω).val, + z₀+(if BufferStageEvent (realPosition (step e)) f H z₀ r ε α g (π ω).val ω + then (1+α)*r else (1-ε)*r) ≤ signedCoordinate f (y.2-y.1) := by + by_cases hk : bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω = k + · simp only [bufferStageStoppedProbability,ite_eq_left hk] + apply Measure.ae_smul_measure + by_cases hE : BufferStageEvent (realPosition (step e)) f H z₀ r ε α g (π ω).val ω + · rw [ite_eq_left hE,bufferStageRetainedLaw_success e f a z₀ r ε α g π hH ω κ hE] + exact retainedPairLaw_support _ _ _ _ _ _ + · rw [ite_eq_right hE] + exact bufferStageRetainedLaw_failure_support e f a z₀ r ε α g π hH ω κ hE + · simp [bufferStageStoppedProbability,ite_eq_right hk] +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/CenteredHeightAdditiveUniform.lean b/lean/OAI/Probability/Ballisticity/Geometry/CenteredHeightAdditiveUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1c900c68faeebcc9ae777fe44061740469b939e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/CenteredHeightAdditiveUniform.lean @@ -0,0 +1,137 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.WeakAddTendsto + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem centered_height_additive_uniform {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : ℕ → Ω → ℝ) + (hF : ∀ h, Measurable (F h)) (b : ℕ → ℝ) (hb0 : b 0 = 0) (r n : ℕ → ℝ) + (hn : Tendsto n atTop atTop) (V : ℝ) (hV : 0 ≤ V) + (hlim : ∀ T : ℝ, 0 < T → ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i x => heightPolygon (fun h => F h x-b h) (r i) (n i) T) + atTop id (fun _ => μ) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (T*V) I) + (p : ℝ) (hp : 0 < p) + (hd : ∀ k j : ℕ, 0 < k → 0 < j → + ENNReal.ofReal p • (μ.prod μ).map (fun P => F k P.1+F j P.2) ≤ μ.map (F (k+j))) + (T : ℝ) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ i in atTop, ∀ k j : ℕ, ((k+j:ℕ):ℝ) ≤ T*n i → + |(b (k+j)-b k-b j)/r i| < ε := by + let S := max T 1 + have hS : 0 < S := lt_of_lt_of_le zero_lt_one (le_max_right _ _) + obtain ⟨N,hN⟩ := eventually_atTop.mp (hn.eventually (eventually_gt_atTop (0:ℝ))) + by_contra hf + simp only [eventually_atTop,not_exists,not_forall] at hf + have hex (l : ℕ) : ∃ i ≥ max l N, ∃ k j : ℕ, + ((k+j:ℕ):ℝ) ≤ T*n i ∧ ε ≤ |(b (k+j)-b k-b j)/r i| := by + obtain ⟨i,hi,hbreak⟩ := hf (max l N) + push Not at hbreak + obtain ⟨k,j,hkj,hbad⟩ := hbreak + exact ⟨i,hi,k,j,hkj,hbad⟩ + choose a ha k j hkj hbad using hex + have halim : Tendsto a atTop atTop := tendsto_atTop_mono (fun l => le_trans (le_max_left _ _) (ha l)) tendsto_id + have hna (l : ℕ) : 0 < n (a l) := hN _ (le_trans (le_max_right _ _) (ha l)) + have hbounds (l : ℕ) : ((k l+j l:ℕ):ℝ) ≤ S*n (a l) := + (hkj l).trans (mul_le_mul_of_nonneg_right (le_max_left _ _) (hna l).le) + have hkpos (l : ℕ) : 0 < k l := by + by_contra hh + have hz : k l = 0 := by omega + have hb := hbad l + simp [hz,hb0] at hb + linarith + have hjpos (l : ℕ) : 0 < j l := by + by_contra hh + have hz : j l = 0 := by omega + have hb := hbad l + simp [hz,hb0] at hb + linarith + have hx (l : ℕ) : (k l:ℝ)/n (a l) ∈ Set.Icc 0 S := by + refine ⟨div_nonneg (Nat.cast_nonneg _) (hna l).le,(div_le_iff₀ (hna l)).mpr ?_⟩ + exact le_trans (by exact_mod_cast Nat.le_add_right (k l) (j l)) (hbounds l) + have hy (l : ℕ) : (j l:ℝ)/n (a l) ∈ Set.Icc 0 S := by + refine ⟨div_nonneg (Nat.cast_nonneg _) (hna l).le,(div_le_iff₀ (hna l)).mpr ?_⟩ + exact le_trans (by exact_mod_cast Nat.le_add_left (j l) (k l)) (hbounds l) + obtain ⟨s,_,q,hq,hqs⟩ := isCompact_Icc.tendsto_subseq hx + obtain ⟨t,_,u,hu,hut⟩ := isCompact_Icc.tendsto_subseq (fun i => hy (q i)) + let v := fun i => a (q (u i)) + have hv : Tendsto v atTop atTop := halim.comp (hq.tendsto_atTop.comp hu.tendsto_atTop) + obtain ⟨W,hW,hWf⟩ := hlim S hS + have hsub : TendstoInDistribution + (fun i x => heightPolygon (fun h => F h x-b h) (r (v i)) (n (v i)) S) + atTop id (fun _ => μ) W := + ⟨fun i => hW.forall_aemeasurable (v i),hW.aemeasurable_limit,hW.tendsto.comp hv⟩ + have hadd := centered_height_additive_sequence μ F hF b (r ∘ v) (n ∘ v) + (fun i => hna (q (u i))) S V hS hV W hsub hWf p hp hd + (fun i => k (q (u i))) (fun i => j (q (u i))) + (fun i => hkpos _) (fun i => hjpos _) (fun i => hbounds _) + (hqs.comp hu.tendsto_atTop) hut + have he := hadd.abs.eventually (gt_mem_nhds (show |(0:ℝ)| < ε by simpa using hε)) + obtain ⟨i,hi⟩ := he.exists + exact not_lt_of_ge (hbad (q (u i))) hi + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/CoordinateLanesDisjoint.lean b/lean/OAI/Probability/Ballisticity/Geometry/CoordinateLanesDisjoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..7238de4c06f7d3b39f13236ccecd40576336e8aa --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/CoordinateLanesDisjoint.lean @@ -0,0 +1,292 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SharedConditionedContactBound +import OAI.Probability.Ballisticity.Walk.RegularPath + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma coordinate_lanes_disjoint {d : ℕ} (f : Direction d) (x y : Lattice d) + (c R : ℝ) (hR : 0 < R) (hxy : R ≤ |signedCoordinate f (y-x)|) : + Disjoint {z | |signedCoordinate f z-(signedCoordinate f x+c)| < R/3} + {z | |signedCoordinate f z-(signedCoordinate f y+c)| < R/3} := by + apply Set.disjoint_left.mpr + intro z hx hy + change |signedCoordinate f z-(signedCoordinate f x+c)| < R/3 at hx + change |signedCoordinate f z-(signedCoordinate f y+c)| < R/3 at hy + have he : signedCoordinate f (y-x) = + (signedCoordinate f z-(signedCoordinate f x+c))-(signedCoordinate f z-(signedCoordinate f y+c)) := by + rw [signedCoordinate_sub] + ring + have hh := abs_sub (signedCoordinate f z-(signedCoordinate f x+c)) + (signedCoordinate f z-(signedCoordinate f y+c)) + rw [← he] at hh + have hlt := add_lt_add hx hy + have h := hxy.trans hh + linarith + +lemma shared_contact_endpoint_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (x y : Lattice d) (hxy : signedHeight e x = signedHeight e y) + {k : ℕ} (hk : 0 < k) (θ : ℝ) {r a : ℝ} (hr : 0 < r) (ha : 0 < a) + (hsep : a*r ≤ |signedCoordinate f (y-x)|) : + let ℓ := realPosition (step e) + let μ := sharedConditionedPairLaw ν ℓ x y + μ.real (PrefixContact (Strip ℓ x k)) ≤ 2*( + μ.real {Z | a/3 ≤ |scaledRecordEndpoint ℓ f θ r k x Z.1|}+ + μ.real {Z | a/3 ≤ |scaledRecordEndpoint ℓ f θ r k y Z.2|}) := by + let ℓ := realPosition (step e) + let μ := sharedConditionedPairLaw ν ℓ x y + let : IsProbabilityMeasure μ := sharedConditionedPairLaw_probability ν ℓ x y + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans x y)) + let U := {z | dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ} + let T := Upper ℓ x k + let A := {z | |signedCoordinate f z-(signedCoordinate f x+(k:ℝ)*θ)| < (a/3)*r} + let B := {z | |signedCoordinate f z-(signedCoordinate f y+(k:ℝ)*θ)| < (a/3)*r} + have hp : dot (realPosition x) ℓ = dot (realPosition y) ℓ := by + simp only [ℓ,signedHeight_projection,hxy] + have hAB : Disjoint A B := by + have hh := coordinate_lanes_disjoint f x y ((k:ℝ)*θ) (a*r) (mul_pos ha hr) hsep + have he : a / 3 * r = a * r / 3 := by ring + simpa only [A,B,he] using hh + have hS : U \ T = Strip ℓ x k := by + ext z + change (dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ ∧ + ¬ dot (realPosition x) ℓ + (k:ℝ) ≤ dot (realPosition z) ℓ) ↔ + (dot (realPosition x) ℓ ≤ dot (realPosition z) ℓ ∧ + dot (realPosition z) ℓ < dot (realPosition x) ℓ + (k:ℝ)) + exact and_congr_right fun _ => not_le + have he₁ : μ (Prod.fst ⁻¹' (SurvivingLane U T A)ᶜ) = + μ {Z | a/3 ≤ |scaledRecordEndpoint ℓ f θ r k x Z.1|} := by + apply measure_congr + filter_upwards [sharedConditioned_regularPath ν ℓ htrans x y] with Z hZ + apply propext + exact not_congr (open_lane_record_iff e f x Z.1 hZ.1.1 hZ.1.2 hk θ r (a/3) hr) |>.trans not_lt + have he₂ : μ (Prod.snd ⁻¹' (SurvivingLane U T B)ᶜ) = + μ {Z | a/3 ≤ |scaledRecordEndpoint ℓ f θ r k y Z.2|} := by + apply measure_congr + filter_upwards [sharedConditioned_regularPath ν ℓ htrans x y] with Z hZ + have hU : U = {z | dot (realPosition y) ℓ ≤ dot (realPosition z) ℓ} := by unfold U; rw [hp] + have hT : T = Upper ℓ y k := by unfold T Upper; rw [hp] + apply propext + change (Z.2 ∉ SurvivingLane U T B) ↔ _ + rw [hU,hT] + exact not_congr (open_lane_record_iff e f y Z.2 hZ.2.1 hZ.2.2 hk θ r (a/3) hr) |>.trans not_lt + have hb := shared_conditioned_contact_bound ν ℓ x y hp T A B hAB + change μ (PrefixContact (U \ T)) ≤ 2*(_+_) at hb + rw [hS,he₁,he₂] at hb + have hh := ENNReal.toReal_mono (show 2*(μ _+μ _) ≠ ∞ by finiteness) hb + simpa only [Measure.real,ENNReal.toReal_mul,ENNReal.toReal_ofNat, + ENNReal.toReal_add (measure_ne_top _ _) (measure_ne_top _ _)] using hh + +theorem shared_contact_limsup {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hrpos : ∀ i, 0 < r i) + (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) + {a t : ℝ} (ha : 0 < a) (ht : 0 < t) + (hsep : ∀ i, a*r i ≤ |signedCoordinate f (y i-x i)|) : + let ℓ := realPosition (step e) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + limsup (fun i => (sharedConditionedPairLaw ν ℓ (x i) (y i)).real + (PrefixContact (Strip ℓ (x i) (⌊t*n i⌋₊ : ℝ)))) atTop ≤ + 8*Real.exp (-commonMeanWidth ν ℓ*a^2/(9*t)) := by + let ℓ := realPosition (step e) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) f (r i) + let μ := fun i => sharedConditionedPairLaw ν ℓ (x i) (y i) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + let F := fun i (Z : Path d × Path d) => scaledRecordEndpoint ℓ f (θ i) (r i) ⌊t*n i⌋₊ (x i) Z.1 + let G := fun i (Z : Path d × Path d) => scaledRecordEndpoint ℓ f (θ i) (r i) ⌊t*n i⌋₊ (y i) Z.2 + have hF (i : ℕ) : Measurable (F i) := (measurable_scaledRecordEndpoint _ _ _ _ _ _).comp measurable_fst + have hG (i : ℕ) : Measurable (G i) := (measurable_scaledRecordEndpoint _ _ _ _ _ _).comp measurable_snd + let p := fun i => (μ i).real {Z | a/3 ≤ |F i Z|} + let q := fun i => (μ i).real {Z | a/3 ≤ |G i Z|} + let c := fun i => (μ i).real (PrefixContact (Strip ℓ (x i) (⌊t*n i⌋₊ : ℝ))) + have hM : 0 < commonMeanWidth ν ℓ := lt_of_lt_of_le (by norm_num : (0:ℝ)<1) + (commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)) + have hv : 0 < t/(2*commonMeanWidth ν ℓ) := div_pos ht (mul_pos (by norm_num) hM) + have hh := shared_endpoint_limits ν hue e f hef htrans r hrpos hr x y hxy ht + have hcoe : ((t/(2*commonMeanWidth ν (realPosition (step e)))).toNNReal : ℝ) = + t/(2*commonMeanWidth ν ℓ) := Real.coe_toNNReal _ hv.le + let R := 2*Real.exp (-(a/3)^2/(2*(t/(2*commonMeanWidth ν ℓ)))) + have hp : limsup p atTop ≤ R := by + have hh' := distribution_abs_limsup μ F hF _ (by simpa only [hcoe] using hv) + hh.1 (a/3) (by positivity) + simpa only [hcoe] using hh' + have hq : limsup q atTop ≤ R := by + have hh' := distribution_abs_limsup μ G hG _ (by simpa only [hcoe] using hv) + hh.2 (a/3) (by positivity) + simpa only [hcoe] using hh' + have hn := recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1 + have hk : ∀ᶠ i in atTop, 0 < ⌊t*n i⌋₊ := by + have hn' : Tendsto (fun i => t*n i) atTop atTop := hn.const_mul_atTop ht + filter_upwards [hn'.eventually_ge_atTop 1] with i hi + exact Nat.floor_pos.mpr hi + have hb : ∀ᶠ i in atTop, c i ≤ 2*(p i+q i) := hk.mono fun i hi => + shared_contact_endpoint_bound ν hue e f htrans (x i) (y i) (hxy i) hi (θ i) (hrpos i) ha (hsep i) + have hb₁ : IsBoundedUnder (· ≤ ·) atTop p := by + refine ⟨1, ?_⟩ + change ∀ᶠ i in atTop, _ ≤ (1:ℝ) + exact Eventually.of_forall fun i => measureReal_le_one + have hb₂ : IsBoundedUnder (· ≤ ·) atTop q := by + refine ⟨1, ?_⟩ + change ∀ᶠ i in atTop, _ ≤ (1:ℝ) + exact Eventually.of_forall fun i => measureReal_le_one + have hc₁ : IsCoboundedUnder (· ≤ ·) atTop c := + (show IsBoundedUnder (· ≥ ·) atTop c from ⟨0, + (show ∀ᶠ i in atTop, 0 ≤ c i from Eventually.of_forall fun i => measureReal_nonneg)⟩).isCoboundedUnder_le + have hc₂ : IsBoundedUnder (· ≤ ·) atTop c := by + refine ⟨1, ?_⟩ + change ∀ᶠ i in atTop, _ ≤ (1:ℝ) + exact Eventually.of_forall fun i => measureReal_le_one + have hc : limsup c atTop ≤ 4*R := (limsup_le_iff hc₁ hc₂).mpr (by + intro b hb' + have hp' := eventually_lt_of_limsup_lt (hp.trans_lt (show R < R+(b-4*R)/8 by linarith)) hb₁ + have hq' := eventually_lt_of_limsup_lt (hq.trans_lt (show R < R+(b-4*R)/8 by linarith)) hb₂ + filter_upwards [hb,hp',hq'] with i hi hp' hq' + linarith) + have he : -(a/3)^2/(2*(t/(2*commonMeanWidth ν ℓ))) = -commonMeanWidth ν ℓ*a^2/(9*t) := by + field_simp + ring + simpa only [R,he,← mul_assoc,show (4:ℝ)*2=8 by norm_num] using hc + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/CoordinateStrip.lean b/lean/OAI/Probability/Ballisticity/Geometry/CoordinateStrip.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2c5f6c19d22be72e5ba7a44617e43e06bd86938 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/CoordinateStrip.lean @@ -0,0 +1,420 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.LowerClip + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma integrable_log_sum + {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + {h : ℕ → α → ℝ} (hh : ∀ᵐ a ∂μ, ∀ j, 0 ≤ h j a) + (hm : ∀ j, AEMeasurable (h j) μ) + (hint : ∀ j, Integrable (fun a => Real.log (1 + h j a)) μ) (n : ℕ) : + Integrable (fun a => Real.log (1 + ∑ j ∈ Finset.range n, h j a)) μ := by + by_cases hn : n = 0 + · subst n + simp + have hn0 : 0 < n := Nat.pos_of_ne_zero hn + let Z : ℕ → α → ℝ := fun j a => Real.log (1 + h j a) + have hup : Integrable (fun a => Real.log n + prefixMax (fun j => Z j a) n) μ := + (integrable_const _).add (integrable_prefixMax μ hint n) + apply hup.mono' + (Real.measurable_log.comp_aemeasurable + (aemeasurable_const.add (Finset.aemeasurable_fun_sum _ fun j _ => hm j))).aestronglyMeasurable + filter_upwards [hh] with a ha + simp only [Function.comp_apply, Pi.add_apply] + rw [Real.norm_eq_abs, abs_of_nonneg (Real.log_nonneg (by + have := Finset.sum_nonneg (s := Finset.range n) (fun j _ => ha j) + linarith))] + exact log_sum_le_log_add_prefixMax _ ha hn0 + +lemma stationary_tail_growth_obstruction + {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + {c h : ℕ → α → ℝ} {X : ℕ → ℕ → α → ℝ} {Z : ℕ → ℕ → α → ℝ} + (hcint : Integrable (c 0) μ) + (hcid : ∀ j, IdentDistrib (c j) (c 0) μ μ) + (hh : ∀ᵐ a ∂μ, ∀ j, 0 ≤ h j a) + (hhid : ∀ j, IdentDistrib (h j) (h 0) μ μ) + (hhint : Integrable (fun a => Real.log (1 + h 0 a)) μ) + (hXid : ∀ n R, IdentDistrib (X 0 R) (X n R) μ μ) + (hXnonpos : ∀ n R, ∀ᵐ a ∂μ, X n R a ≤ 0) + (hZint : ∀ n R, Integrable (Z n R) μ) + (A C : ℝ) + (hZmean : ∀ n, ∀ᶠ R : ℕ in atTop, (∫ a, Z n R a ∂μ) ≤ C) + (hgrowth : ∀ n R, ∀ᵐ a ∂μ, + (∑ j ∈ Finset.range n, c j a) - + A * Real.log (1 + ∑ j ∈ Finset.range n, h j a) - Z n R a - Real.log 2 ≤ + X n R a - X 0 R a) : + (∫ a, c 0 a ∂μ) ≤ 0 := by + have hcj (j : ℕ) : Integrable (c j) μ := (hcid j).integrable_iff.mpr hcint + have hhj (j : ℕ) : Integrable (fun a => Real.log (1 + h j a)) μ := + ((hhid j).comp (Real.measurable_log.comp (measurable_const.add measurable_id))).integrable_iff.mpr hhint + have hsumint (n : ℕ) : Integrable (fun a => Real.log (1 + ∑ j ∈ Finset.range n, h j a)) μ := + integrable_log_sum μ hh (fun j => (hhid j).aemeasurable_fst) hhj n + have hbound (n : ℕ) : (n : ℝ) * (∫ a, c 0 a ∂μ) ≤ + A * (∫ a, Real.log (1 + ∑ j ∈ Finset.range n, h j a) ∂μ) + C + Real.log 2 := by + obtain ⟨R, hR⟩ := (hZmean n).exists + have hcs : Integrable (fun a => ∑ j ∈ Finset.range n, c j a) μ := + integrable_finsetSum _ (fun j _ => hcj j) + have h1 : Integrable (fun a => (∑ j ∈ Finset.range n, c j a) - + A * Real.log (1 + ∑ j ∈ Finset.range n, h j a)) μ := + hcs.sub ((hsumint n).const_mul A) + have h2 : Integrable (fun a => (∑ j ∈ Finset.range n, c j a) - + A * Real.log (1 + ∑ j ∈ Finset.range n, h j a) - Z n R a) μ := + h1.sub (hZint n R) + have h3 : Integrable (fun a => A * Real.log (1 + ∑ j ∈ Finset.range n, h j a)) μ := + (hsumint n).const_mul A + have hG := h2.sub (integrable_const (Real.log 2)) + have hle := integral_le_zero_of_identDistrib_lower_bound μ (hXid n R) + (hXnonpos 0 R) (hXnonpos n R) hG (hgrowth n R) + simp only [Pi.sub_apply] at hle + rw [integral_sub h2 (integrable_const (Real.log 2)), + integral_sub h1 (hZint n R), integral_sub hcs h3, integral_const_mul, + integral_finsetSum _ (fun j _ => hcj j)] at hle + simp only [(hcid _).integral_eq, integral_const, probReal_univ, smul_eq_mul, + one_mul, Finset.sum_const, Finset.card_range, nsmul_eq_mul] at hle + linarith + have hlim := + ((integral_log_sum_div_tendsto_zero μ hh hhid hhint).const_mul A).add + (tendsto_const_div_atTop_nhds_zero_nat (C + Real.log 2)) + simp only [mul_zero, add_zero] at hlim + apply ge_of_tendsto hlim + filter_upwards [eventually_ge_atTop 1] with n hn + have hnpos : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) + rw [← mul_div_assoc, ← add_div] + apply (le_div_iff₀ hnpos).mpr + nlinarith [hbound n] + +lemma wordWeight_lower {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (x : Lattice d) (w : List (Direction d)) : + (κ : ℝ) ^ w.length ≤ wordWeight ω x w := by + induction w generalizing x with + | nil => simp [wordWeight] + | cons e w ih => + simp only [List.length_cons, pow_succ', wordWeight] + exact mul_le_mul (by exact_mod_cast hκ x e) (ih _) + (pow_nonneg κ.coe_nonneg _) (NNReal.coe_nonneg _) + +lemma wordPath_replicate {d : ℕ} (x : Lattice d) (e : Direction d) (N : ℕ) : + wordPath x (List.replicate N e) N = x + N • step e := by + induction N generalizing x with + | zero => simp + | succ N ih => + simp only [List.replicate_succ, wordPath, ih, succ_nsmul] + abel + +lemma stayUntil_split {d : ℕ} (S : Set (Lattice d)) (n m : ℕ) : + StayUntil S (n + m) = StayUntil S n ∩ FutureEvent (fun _ => StayUntil S m) n := by + ext X + constructor + · intro h + exact ⟨fun i hi => h i (by omega), fun j hj => h (n + j) (by omega)⟩ + · rintro ⟨h, h'⟩ i hi + by_cases hin : i ≤ n + · exact h i hin + · have he : n + (i - n) = i := by omega + simpa only [he] using h' (i - n) (by omega) + +lemma quenched_stayUntil_add {d : ℕ} (ω : Environment d) (x : Lattice d) + (S : Set (Lattice d)) (n m : ℕ) : + quenchedKernel (ω, x) (StayUntil S (n + m)) = + ∫⁻ X in StayUntil S n, quenchedKernel (ω, X n) (StayUntil S m) + ∂quenchedKernel (ω, x) := by + let A : Set ((i : Finset.Iic n) → Lattice d) := {f | ∀ i, f i ∈ S} + have hA : (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' A = StayUntil S n := by + ext X + constructor + · intro h i hi + exact h ⟨i, Finset.mem_Iic.mpr hi⟩ + · intro h i + exact h i (Finset.mem_Iic.mp i.2) + rw [stayUntil_split, ← hA] + exact quenched_past_future ω x n A (fun _ => StayUntil S m) + (fun _ => measurableSet_stayUntil S m) + +lemma quenched_stayUntil_block_bound {d : ℕ} (ω : Environment d) + (S : Set (Lattice d)) (N : ℕ) (c : ℝ≥0∞) + (hc : ∀ y, quenchedKernel (ω, y) (StayUntil S N) ≤ c) + (x : Lattice d) (k : ℕ) : + quenchedKernel (ω, x) (StayUntil S (k * N)) ≤ c ^ k := by + induction k with + | zero => simpa using (prob_le_one (μ := quenchedKernel (ω, x)) (s := StayUntil S 0)) + | succ k ih => + rw [Nat.succ_mul, quenched_stayUntil_add] + calc + _ ≤ ∫⁻ _ in StayUntil S (k * N), c ∂quenchedKernel (ω, x) := + lintegral_mono fun X => hc (X (k * N)) + _ = c * quenchedKernel (ω, x) (StayUntil S (k * N)) := by simp + _ ≤ c * c ^ k := mul_le_mul' le_rfl ih + _ = c ^ (k + 1) := (pow_succ' c k).symm + +def CoordinateStrip {d : ℕ} (i : Fin d) (b : ℤ) (H : ℕ) : Set (Lattice d) := + {x | b ≤ x i ∧ x i < b + (H : ℤ)} + +lemma wordCylinder_up_disjoint_stay {d : ℕ} (i : Fin d) (b : ℤ) (H : ℕ) + (x : Lattice d) : + Disjoint (wordCylinder x (List.replicate H (i, true))) + (StayUntil (CoordinateStrip i b H) H) := by + apply Set.disjoint_left.mpr + intro X hw hS + have hx : b ≤ x i := by + have h := (hS 0 (Nat.zero_le H)).1 + simpa only [hw 0 (by simp), wordPath_zero] using h + have hend := (hS H le_rfl).2 + have hp := hw H (by simp) + rw [wordPath_replicate] at hp + rw [hp] at hend + simp [step] at hend + omega + +lemma quenched_strip_block {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (i : Fin d) (b : ℤ) (H : ℕ) (x : Lattice d) : + quenchedKernel (ω, x) (StayUntil (CoordinateStrip i b H) H) ≤ + 1 - (κ : ℝ≥0∞) ^ H := by + have hsub : StayUntil (CoordinateStrip i b H) H ⊆ + (wordCylinder x (List.replicate H (i, true)))ᶜ := + (wordCylinder_up_disjoint_stay i b H x).subset_compl_left + calc + _ ≤ quenchedKernel (ω, x) (wordCylinder x (List.replicate H (i, true)))ᶜ := + measure_mono hsub + _ = 1 - ENNReal.ofReal (wordWeight ω x (List.replicate H (i, true))) := by + rw [measure_compl (measurableSet_wordCylinder _ _) (measure_ne_top _ _), + measure_univ, quenched_wordCylinder] + _ ≤ 1 - (κ : ℝ≥0∞) ^ H := by + apply tsub_le_tsub_left + have hs := ENNReal.ofReal_le_ofReal (wordWeight_lower ω hκ x + (List.replicate H (i, true))) + simpa only [List.length_replicate, ENNReal.ofReal_pow κ.coe_nonneg, + ENNReal.ofReal_coe_nnreal] using hs + +lemma quenched_strip_geometric {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (i : Fin d) (b : ℤ) (H k : ℕ) (x : Lattice d) : + quenchedKernel (ω, x) (StayUntil (CoordinateStrip i b H) (k * H)) ≤ + (1 - (κ : ℝ≥0∞) ^ H) ^ k := + quenched_stayUntil_block_bound ω (CoordinateStrip i b H) H _ + (quenched_strip_block ω hκ i b H) x k + +def HitThrough {d : ℕ} (S T : Set (Lattice d)) (n : ℕ) : Set (Path d) := + ⋃ k ≤ n, HitAt S T k + +lemma measurableSet_hitThrough {d : ℕ} (S T : Set (Lattice d)) (n : ℕ) : + MeasurableSet (HitThrough S T n) := + MeasurableSet.iUnion fun k => MeasurableSet.iUnion fun _ => measurableSet_hitAt S T k + +lemma hitThrough_subset_hit {d : ℕ} (S T : Set (Lattice d)) (n : ℕ) : + HitThrough S T n ⊆ Hit S T := by + intro X h + obtain ⟨k, _, hk⟩ := Set.mem_iUnion₂.mp h + exact Set.mem_iUnion.mpr ⟨k, hk⟩ + +lemma hit_subset_hitThrough_union_stayUntil {d : ℕ} (S T : Set (Lattice d)) (n : ℕ) : + Hit S T ⊆ HitThrough S T n ∪ StayUntil S n := by + intro X h + obtain ⟨k, hk⟩ := Set.mem_iUnion.mp h + by_cases hkn : k ≤ n + · exact Or.inl (Set.mem_iUnion₂.mpr ⟨k, hkn, hk⟩) + · exact Or.inr (fun j hj => hk.2 j (by omega)) + +lemma quenched_hit_truncation {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (n : ℕ) : + quenchedKernel (ω, x) (Hit S T) ≤ + quenchedKernel (ω, x) (HitThrough S T n) + + quenchedKernel (ω, x) (StayUntil S n) := + (measure_mono (hit_subset_hitThrough_union_stayUntil S T n)).trans (measure_union_le _ _) + +lemma quenched_strip_hit_truncation {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (i : Fin d) (b : ℤ) (H k : ℕ) + (x : Lattice d) (T : Set (Lattice d)) : + quenchedKernel (ω, x) (Hit (CoordinateStrip i b H) T) ≤ + quenchedKernel (ω, x) (HitThrough (CoordinateStrip i b H) T (k * H)) + + (1 - (κ : ℝ≥0∞) ^ H) ^ k := + (quenched_hit_truncation ω x _ _ _).trans + (add_le_add le_rfl (quenched_strip_geometric ω hκ i b H k x)) + +def LatticeBall {d : ℕ} (x : Lattice d) (n : ℕ) : Set (Lattice d) := + {y | ∀ i, |y i - x i| ≤ (n : ℤ)} + +lemma latticeBall_finite {d : ℕ} (x : Lattice d) (n : ℕ) : + (LatticeBall x n).Finite := by + have he : LatticeBall x n = Set.Icc (x - fun _ => (n : ℤ)) (x + fun _ => (n : ℤ)) := by + ext y + simp only [LatticeBall, Set.mem_ofPred_eq, Set.mem_Icc, Pi.le_def, + Pi.sub_apply, Pi.add_apply] + constructor + · intro h + exact ⟨fun i => by have := (abs_le.mp (h i)).1; omega, + fun i => by have := (abs_le.mp (h i)).2; omega⟩ + · rintro ⟨h, h'⟩ i + exact abs_le.mpr ⟨by have := h i; omega, by have := h' i; omega⟩ + rw [he] + exact Set.finite_Icc _ _ + +lemma abs_step_le_one {d : ℕ} (e : Direction d) (i : Fin d) : + |step e i| ≤ (1 : ℤ) := by + simp only [step] + split_ifs <;> norm_num + +def NearestNeighborPrefix {d : ℕ} (f : Path d) (n : ℕ) : Prop := + ∀ k < n, ∃ e : Direction d, f (k + 1) = f k + step e + +lemma nearestNeighborPrefix_bound {d : ℕ} (f : Path d) (n : ℕ) + (hf : NearestNeighborPrefix f n) {k : ℕ} (hk : k ≤ n) : + f k ∈ LatticeBall (f 0) k := by + induction k with + | zero => simp [LatticeBall] + | succ k ih => + obtain ⟨e, he⟩ := hf k (by omega) + intro i + rw [he] + have hb := ih (by omega) i + change |f k i + step e i - f 0 i| ≤ ((k + 1 : ℕ) : ℤ) + calc + _ = |(f k i - f 0 i) + step e i| := by congr 1; ring + _ ≤ |f k i - f 0 i| + |step e i| := abs_add_le _ _ + _ ≤ (k : ℤ) + 1 := add_le_add hb (abs_step_le_one e i) + _ = _ := by norm_cast + +lemma edgeWeight_eq_zero_of_not_neighbor {d : ℕ} (ω : Environment d) (x y : Lattice d) + (h : ¬ ∃ e : Direction d, y = x + step e) : edgeWeight ω x y = 0 := by + classical + apply Finset.sum_eq_zero + intro e _ + exact ite_eq_right (fun he => h ⟨e, he⟩) + +lemma quenched_pathCylinder_locality {d : ℕ} (ω η : Environment d) (x : Lattice d) + (n : ℕ) (hωη : Set.EqOn ω η (LatticeBall x n)) (f : Path d) : + quenchedKernel (ω, x) (pathCylinder f n) = + quenchedKernel (η, x) (pathCylinder f n) := by + classical + by_cases hstart : f 0 = x + · rw [quenched_pathCylinder _ _ _ hstart, quenched_pathCylinder _ _ _ hstart] + by_cases hpath : NearestNeighborPrefix f n + · apply Finset.prod_congr rfl + intro k hk + have hn := (Finset.mem_range.mp hk).le + have hb := nearestNeighborPrefix_bound f n hpath hn + have hmem : f k ∈ LatticeBall x n := by + intro i + have h := hb i + rw [hstart] at h + exact h.trans (by exact_mod_cast hn) + simp only [edgeWeight, hωη hmem] + · unfold NearestNeighborPrefix at hpath + push Not at hpath + obtain ⟨k, hk, hbad⟩ := hpath + have hbad' : ¬ ∃ e : Direction d, f (k + 1) = f k + step e := by + simpa using hbad + rw [Finset.prod_eq_zero (Finset.mem_range.mpr hk) + (edgeWeight_eq_zero_of_not_neighbor ω _ _ hbad'), + Finset.prod_eq_zero (Finset.mem_range.mpr hk) + (edgeWeight_eq_zero_of_not_neighbor η _ _ hbad')] + · rw [quenched_pathCylinder_zero _ _ _ hstart, quenched_pathCylinder_zero _ _ _ hstart] + +lemma quenched_prefix_locality {d : ℕ} (ω η : Environment d) (x : Lattice d) + (n : ℕ) (hωη : Set.EqOn ω η (LatticeBall x n)) + (C : Set ((i : Finset.Iic n) → Lattice d)) : + quenchedKernel (ω, x) ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' C) = + quenchedKernel (η, x) ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' C) := by + have hm (f : (i : Finset.Iic n) → Lattice d) (_ : f ∈ C) : + MeasurableSet ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' {f}) := + (Preorder.measurable_frestrictLe n) (measurableSet_singleton f) + rw [← tsum_measure_preimage_singleton C.to_countable hm, + ← tsum_measure_preimage_singleton C.to_countable hm] + apply tsum_congr + intro f + rw [restrict_prefix_fiber] + exact quenched_pathCylinder_locality ω η x n hωη _ + +lemma quenched_hitThrough_locality {d : ℕ} (ω η : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (n : ℕ) (hωη : Set.EqOn ω η (LatticeBall x n)) : + quenchedKernel (ω, x) (HitThrough S T n) = + quenchedKernel (η, x) (HitThrough S T n) := by + let C : Set ((i : Finset.Iic n) → Lattice d) := + {f | ∃ (k : ℕ) (hk : k ≤ n), f ⟨k, Finset.mem_Iic.mpr hk⟩ ∈ T ∧ + ∀ (j : ℕ) (hj : j < k), f ⟨j, Finset.mem_Iic.mpr (hj.le.trans hk)⟩ ∈ S} + have hC : (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' C = HitThrough S T n := by + ext X + constructor + · rintro ⟨k, hk, hT, hS⟩ + exact Set.mem_iUnion₂.mpr ⟨k, hk, hT, hS⟩ + · intro h + obtain ⟨k, hk, hT, hS⟩ := Set.mem_iUnion₂.mp h + exact ⟨k, hk, hT, hS⟩ + rw [← hC] + exact quenched_prefix_locality ω η x n hωη C + +lemma quenched_strip_compare {d : ℕ} (ω η : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (i : Fin d) (b : ℤ) (H k : ℕ) + (x : Lattice d) (T : Set (Lattice d)) + (hωη : Set.EqOn ω η (LatticeBall x (k * H))) : + quenchedKernel (ω, x) (Hit (CoordinateStrip i b H) T) ≤ + quenchedKernel (η, x) (Hit (CoordinateStrip i b H) T) + + (1 - (κ : ℝ≥0∞) ^ H) ^ k := by + have ht := quenched_strip_hit_truncation ω hκ i b H k x T + rw [quenched_hitThrough_locality ω η x _ _ _ hωη] at ht + exact ht.trans (add_le_add (measure_mono (hitThrough_subset_hit _ _ _)) le_rfl) + +lemma quenched_strip_uniform_locality {d : ℕ} {κ : ℝ≥0} (hκ : 0 < κ) + (H : ℕ) {ε : ℝ≥0∞} (hε : 0 < ε) : + ∃ n : ℕ, ∀ (ω η : Environment d), + (∀ y e, κ ≤ (ω y).1 e) → (∀ y e, κ ≤ (η y).1 e) → + ∀ (x : Lattice d) (i : Fin d) (b : ℤ) (T : Set (Lattice d)), + Set.EqOn ω η (LatticeBall x n) → + quenchedKernel (ω, x) (Hit (CoordinateStrip i b H) T) ≤ + quenchedKernel (η, x) (Hit (CoordinateStrip i b H) T) + ε ∧ + quenchedKernel (η, x) (Hit (CoordinateStrip i b H) T) ≤ + quenchedKernel (ω, x) (Hit (CoordinateStrip i b H) T) + ε := by + have hc : 1 - (κ : ℝ≥0∞) ^ H < 1 := + ENNReal.sub_lt_self ENNReal.one_ne_top one_ne_zero (pow_ne_zero _ (by exact_mod_cast hκ.ne')) + obtain ⟨k, hk⟩ := ((ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one hc).eventually_lt_const hε).exists + refine ⟨k * H, fun ω η hω hη x i b T he => ?_⟩ + exact ⟨(quenched_strip_compare ω η hω i b H k x T he).trans (add_le_add le_rfl hk.le), + (quenched_strip_compare η ω hη i b H k x T he.symm).trans (add_le_add le_rfl hk.le)⟩ + +lemma measurable_of_row_locality {d : ℕ} {α : Type*} [MeasurableSpace α] + (f : Environment d → α) (hf : Measurable f) (S : Set (Lattice d)) + (x : Lattice d) (hx : x ∈ S) + (hloc : ∀ ω η, Set.EqOn ω η S → f ω = f η) : + @Measurable _ _ (rowSigma S) _ f := by + classical + let patch : Environment d → Environment d := fun ω y => if y ∈ S then ω y else ω x + have hp : @Measurable _ _ (rowSigma S) _ patch := by + refine @Measurable.of_eval _ _ _ (rowSigma S) _ _ ?_ + intro y + by_cases hy : y ∈ S + · simpa only [patch, ite_eq_left hy] using measurable_row_on hy + · simpa only [patch, ite_eq_right hy] using measurable_row_on hx + have he : f = f ∘ patch := by + funext ω + exact hloc ω (patch ω) (fun y hy => by simp [patch, hy]) + rw [he] + exact hf.comp hp + +lemma measurable_hitThrough_ball {d : ℕ} (x : Lattice d) (S T : Set (Lattice d)) (n : ℕ) : + @Measurable _ _ (rowSigma (LatticeBall x n)) _ + (fun ω : Environment d => quenchedKernel (ω, x) (HitThrough S T n)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_hitThrough S T n)).comp + (measurable_id.prodMk measurable_const)) _ x + (by simp [LatticeBall]) + intro ω η h + exact quenched_hitThrough_locality ω η x S T n h + +noncomputable def noDropFinite {d : ℕ} (ℓ : Vector d) (x : Lattice d) (n : ℕ) + (ω : Environment d) : ℝ≥0∞ := + quenchedKernel (ω, x) (StayUntil {y | dot (realPosition x) ℓ ≤ dot (realPosition y) ℓ} n) + +lemma noDropFinite_measurable {d : ℕ} (ℓ : Vector d) (x : Lattice d) (n : ℕ) : + Measurable (noDropFinite ℓ x n) := + (Kernel.measurable_coe _ (measurableSet_stayUntil _ n)).comp + (measurable_id.prodMk measurable_const) + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/CurvePolicyTubeMass.lean b/lean/OAI/Probability/Ballisticity/Geometry/CurvePolicyTubeMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2895134890e0dc4efee9b00988b06699c649d26 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/CurvePolicyTubeMass.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.PolicyGoodMass +import OAI.Probability.Ballisticity.Estimates.FinitePolicyFailure +import OAI.Probability.Ballisticity.Geometry.CurveWordTube +import OAI.Probability.Ballisticity.Estimates.ListPrefixSum + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +local instance CurvePolicyTubeMassMs {d : ℕ} : MeasurableSpace (List (Lattice d)) := ⊤ +local instance CurvePolicyTubeMassSingleton {d : ℕ} : MeasurableSingletonClass (List (Lattice d)) := ⟨fun _ => trivial⟩ + +lemma curvePolicy_tube_density {d : ℕ} (e f : Direction d) + (b : ℕ → ℝ) {B D : ℝ} (hB : 0 ≤ B) (hD : 0 ≤ D) {H : ℕ} (hH : 0 < H) + (θ r : ℝ) (hb : ∀ j ≤ H, |b j-(j:ℝ)*θ| ≤ D) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (hα1 : α ≤ 1) + (dummy : Lattice d) (ω : Environment d) (i : ℕ) (x : Lattice d) (n : ℕ) : + (finitePolicyPMF (fun _ ω x => curvePolicyPMF (realPosition (step e)) f x b B H E hδ hα dummy ω) + ω i x n).toMeasure {w | w.length=n ∧ + policySafe (fun y => δ ≤ curveIncrement (realPosition (step e)) f y b B H ω Set.univ) x w ∧ + listCenteredMax (signedCoordinate f) ((H:ℝ)*θ) w ≤ r} ≤ + ((α*δ)⁻¹)^n * quenchedKernel (ω,x) + (TubePrefix (realPosition (step e)) f x θ (r+B+D) (n*H)) := by + let S : Set (List (Lattice d)) := {w | w.length=n ∧ + policySafe (fun y => δ ≤ curveIncrement (realPosition (step e)) f y b B H ω Set.univ) x w ∧ + listCenteredMax (signedCoordinate f) ((H:ℝ)*θ) w ≤ r} + have hd := curvePolicy_event_density (realPosition (step e)) f b B H E hδ hα hα1 dummy ω i x n S + (fun _ h => h.1) (fun _ h => h.2.1) + apply hd.trans + apply mul_le_mul_right + apply measure_mono_ae + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + intro hX + obtain ⟨w,hX⟩ := Set.mem_iUnion.mp hX + obtain ⟨hw,hX⟩ := Set.mem_iUnion.mp hX + have hmax := hw.2.2 + have hp : ∀ k ≤ w.length, |(0:ℝ)+signedCoordinate f (w.take k).sum-(k:ℝ)*(H:ℝ)*θ| ≤ r := by + intro k hk + simpa only [zero_add,mul_assoc] using (listCenteredMax_prefix f ((H:ℝ)*θ) w hk).trans hmax + obtain ⟨m,hm⟩ := curveWordEvent_shifted_tube e f x b hB hD hH θ 0 r hb w hp X h0 hnn hX + apply Set.mem_iUnion.mpr + refine ⟨m,?_⟩ + simpa only [hw.1,sub_zero,CurvePrefixAt,TubePrefixAt] using hm + +lemma curvePolicy_tube_mass {d : ℕ} (e f : Direction d) + (b : ℕ → ℝ) {B D : ℝ} (hB : 0 ≤ B) (hD : 0 ≤ D) {H : ℕ} (hH : 0 < H) + (θ r : ℝ) (hb : ∀ j ≤ H, |b j-(j:ℝ)*θ| ≤ D) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) + (hδ1 : δ ≤ 1) (hα1 : α ≤ 1) + (dummy : Lattice d) (ω : Environment d) (i : ℕ) (x : Lattice d) (n : ℕ) : + (α*δ)^n * + (finitePolicyPMF (fun _ ω x => curvePolicyPMF (realPosition (step e)) f x b B H E hδ hα dummy ω) + ω i x n).toMeasure {w | w.length=n ∧ + policySafe (fun y => δ ≤ curveIncrement (realPosition (step e)) f y b B H ω Set.univ) x w ∧ + listCenteredMax (signedCoordinate f) ((H:ℝ)*θ) w ≤ r} ≤ + quenchedKernel (ω,x) (TubePrefix (realPosition (step e)) f x θ (r+B+D) (n*H)) := by + have hd := mul_le_mul_right (curvePolicy_tube_density e f b hB hD hH θ r hb E hδ hα hα1 dummy ω i x n) ((α*δ)^n) + have hne : α*δ ≠ 0 := mul_ne_zero hα.ne' hδ.ne' + have ht : α*δ ≠ ⊤ := ne_of_lt (lt_of_le_of_lt (by simpa using mul_le_mul' hα1 hδ1) ENNReal.one_lt_top) + simpa only [← mul_assoc,← mul_pow,ENNReal.mul_inv_cancel hne ht,one_pow,one_mul] using hd + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +local instance CurvePolicyTubeProbabilityMs {d : ℕ} : MeasurableSpace (List (Lattice d)) := ⊤ +local instance CurvePolicyTubeProbabilitySingleton {d : ℕ} : MeasurableSingletonClass (List (Lattice d)) := ⟨fun _ => trivial⟩ + +lemma curvePolicy_tube_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (b : ℕ → ℝ) {B D : ℝ} (hB : 0 ≤ B) (hD : 0 ≤ D) + {H : ℕ} (hH : 0 < H) (θ : ℝ) {r : ℝ} (hr : 0 < r) + (hb : ∀ j ≤ H, |b j-(j:ℝ)*θ| ≤ D) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) + (hδ1 : δ ≤ 1) (hα1 : α ≤ 1) + (dummy : Lattice d) (hd : signedHeight e dummy=H) (hdb : signedCoordinate f dummy=b H) + (i n : ℕ) (x : Lattice d) (hx : signedHeight e x=(i:ℤ)*H) + (hc : (H:ℝ)*θ = ∫ u, signedCoordinate f u + ∂(curvePolicy_average ν (realPosition (step e)) f b B hH E hδ hα dummy).toMeasure) : + environmentLaw ν {ω | quenchedKernel (ω,x) + (TubePrefix (realPosition (step e)) f x θ (r+B+D) (n*H)) < (α*δ)^n/2} ≤ + 2*((n:ℝ≥0∞)*environmentLaw ν {ω | curveIncrement (realPosition (step e)) f 0 b B H ω Set.univ < δ} + + ENNReal.ofReal ((4*(n:ℝ)*(∫ u, (signedCoordinate f u-b H)^2 + ∂(curvePolicy_average ν (realPosition (step e)) f b B hH E hδ hα dummy).toMeasure))/r^2)) := by + let Q := fun (_ : ℕ) ω x => curvePolicyPMF (realPosition (step e)) f x b B H E hδ hα dummy ω + let F := fun ω => (finitePolicyPMF Q ω i x n).toMeasure + {w | ¬policySafe (fun y => δ ≤ curveIncrement (realPosition (step e)) f y b B H ω Set.univ) x w} + let M := fun ω => (finitePolicyPMF Q ω i x n).toMeasure + {w | r ≤ listCenteredMax (signedCoordinate f) ((H:ℝ)*θ) w} + have hF : Measurable F := curvePolicy_failure_measurable e f b B hH E hδ hα dummy i x n + have hM : Measurable M := curvePolicy_fixed_event_measurable e f b B hH E hδ hα dummy i x n _ + have hlow := low_mass_probability (environmentLaw ν) (fun ω => F ω+M ω) + (fun ω => quenchedKernel (ω,x) (TubePrefix (realPosition (step e)) f x θ (r+B+D) (n*H))) + (hF.add hM).aemeasurable ((α*δ)^n/2) (by + intro ω hcost + have hp := policy_good_mass Q ω i x n + (fun y => δ ≤ curveIncrement (realPosition (step e)) f y b B H ω Set.univ) + (listCenteredMax (signedCoordinate f) ((H:ℝ)*θ)) r hcost + have ht := curvePolicy_tube_mass e f b hB hD hH θ r hb E hδ hα hδ1 hα1 dummy ω i x n + have hs := (mul_le_mul_right hp ((α*δ)^n)).trans ht + simpa only [div_eq_mul_inv,one_mul] using hs) + apply hlow.trans + apply mul_le_mul_right + rw [lintegral_add_left hF] + apply add_le_add (curvePolicy_actual_failure ν e f b B hH E hδ hα dummy hd i n x hx) + have hMt : (∫⁻ ω, M ω ∂environmentLaw ν) ≠ ⊤ := by + have hbnd : (∫⁻ ω, M ω ∂environmentLaw ν) ≤ 1 := by + calc + _ ≤ ∫⁻ ω, (1:ℝ≥0∞) ∂environmentLaw ν := lintegral_mono (fun ω => prob_le_one) + _ = 1 := by simp + exact ne_of_lt (hbnd.trans_lt ENNReal.one_lt_top) + rw [← ENNReal.ofReal_toReal hMt] + apply ENNReal.ofReal_le_ofReal + simpa only [M,Q,hc] using curvePolicy_maximal_tail ν e f b hB hH E hδ hα dummy hd hdb i x hx n hr + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/CurveWordTube.lean b/lean/OAI/Probability/Ballisticity/Geometry/CurveWordTube.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b3e596b97f18dafcc81e58322ac67366f22989e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/CurveWordTube.lean @@ -0,0 +1,91 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ShiftedCurveConcatenation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma curvePrefixAt_center_comparison {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (b c : ℕ → ℝ) (B D : ℝ) (H n : ℕ) (X : Path d) + (hc : ∀ j ≤ H, |b j-c j| ≤ D) (hX : X ∈ CurvePrefixAt ℓ f x b B H n) : + X ∈ CurvePrefixAt ℓ f x c (B+D) H n := by + refine ⟨hX.1,?_⟩ + intro j hj + obtain ⟨a,ha,hr,hg⟩ := hX.2 j hj + refine ⟨a,ha,hr,?_⟩ + calc + _ = |(signedCoordinate f (X a-x)-b j)+(b j-c j)| := by congr 1; ring + _ ≤ |signedCoordinate f (X a-x)-b j|+|b j-c j| := abs_add_le _ _ + _ ≤ B+D := add_le_add hg (hc j hj) + +lemma curvePrefixAt_radius_mono {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (b : ℕ → ℝ) {B C : ℝ} (hBC : B ≤ C) (H n : ℕ) (X : Path d) + (hX : X ∈ CurvePrefixAt ℓ f x b B H n) : X ∈ CurvePrefixAt ℓ f x b C H n := by + refine ⟨hX.1,?_⟩ + intro j hj + obtain ⟨a,ha,hr,hg⟩ := hX.2 j hj + exact ⟨a,ha,hr,hg.trans hBC⟩ + +lemma curveWordEvent_shifted_tube {d : ℕ} (e f : Direction d) (x : Lattice d) + (b : ℕ → ℝ) {B D : ℝ} (hB : 0 ≤ B) (hD : 0 ≤ D) {H : ℕ} (hH : 0 < H) + (θ a r : ℝ) (hb : ∀ j ≤ H, |b j-(j:ℝ)*θ| ≤ D) + (w : List (Lattice d)) + (hp : ∀ k ≤ w.length, |a+signedCoordinate f (w.take k).sum-(k:ℝ)*(H:ℝ)*θ| ≤ r) + (X : Path d) (h0 : X 0=x) (hnn : ∀ j, ∃ g, X (j+1)=X j+step g) + (hX : X ∈ curveWordEvent (realPosition (step e)) f b B H x w) : + ∃ n, X ∈ CurvePrefixAt (realPosition (step e)) f x + (fun j => (j:ℝ)*θ-a) (r+B+D) (w.length*H) n := by + induction w generalizing x X a with + | nil => + have ha : |a| ≤ r := by simpa [signedCoordinate] using hp 0 le_rfl + refine ⟨0,⟨?_,?_⟩,?_⟩ + · simp [Upper,h0] + · intro j hj; omega + · intro j hj + have hj0 : j=0 := by simpa using hj + subst j + refine ⟨0,le_rfl,?_,?_⟩ + · simp [RecordOrZeroPrefix] + · simpa [h0,signedCoordinate] using ha.trans (by linarith : r ≤ r+B+D) + | cons u w ih => + obtain ⟨n,hn,hnu,hnt⟩ := (curveWordEvent_cons_mem _ f b B H x u w X).mp hX + let a' := a+signedCoordinate f u-(H:ℝ)*θ + have hp' : ∀ k ≤ w.length, |a'+signedCoordinate f (w.take k).sum-(k:ℝ)*(H:ℝ)*θ| ≤ r := by + intro k hk + have hh := hp (k+1) (by simp only [List.length_cons]; omega) + simp only [List.take_succ_cons,List.sum_cons,signedCoordinate_add,Nat.cast_add,Nat.cast_one] at hh + dsimp [a'] + convert hh using 1; congr 1; ring + have hnt' : (fun j => X (n+j)) ∈ curveWordEvent (realPosition (step e)) f b B H (X n) w := by simpa only [hnu] using hnt + obtain ⟨m,hm⟩ := ih (X n) a' hp' (fun j => X (n+j)) (by simp) + (fun j => by simpa only [Nat.add_assoc] using hnn (n+j)) hnt' + have ha : |a| ≤ r := by simpa [signedCoordinate] using hp 0 (Nat.zero_le _) + have hc : ∀ j ≤ H, |b j-((j:ℝ)*θ-a)| ≤ D+r := by + intro j hj + calc + _ = |(b j-(j:ℝ)*θ)+a| := by congr 1; ring + _ ≤ |b j-(j:ℝ)*θ|+|a| := abs_add_le _ _ + _ ≤ D+r := add_le_add (hb j hj) ha + have hn' := curvePrefixAt_center_comparison _ f x b (fun j => (j:ℝ)*θ-a) B (D+r) H n X hc hn + have hn'' : X ∈ CurvePrefixAt (realPosition (step e)) f x (fun j => (j:ℝ)*θ-a) (r+B+D) H n := by + simpa only [add_comm,add_left_comm,add_assoc] using hn' + have ha' : a'=a+signedCoordinate f (X n-x)-(H:ℝ)*θ := by + simp only [a',hnu,add_sub_cancel_left] + rw [ha'] at hm + have hh := shiftedCurvePrefixAt_concatenate e f x θ a (r+B+D) hH n (w.length*H) m X h0 hnn hn'' hm + refine ⟨n+m,?_⟩ + simpa only [List.length_cons,Nat.add_mul,one_mul,Nat.add_comm] using hh + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/FiniteConditionalDensityTubeTransfer.lean b/lean/OAI/Probability/Ballisticity/Geometry/FiniteConditionalDensityTubeTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..0894d7b8e9efcb77dd2d478ecce1e499d2805647 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/FiniteConditionalDensityTubeTransfer.lean @@ -0,0 +1,286 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.WeightedConditionedTubeTransfer +import OAI.Probability.Ballisticity.Estimates.RawConditionedWeight + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma finiteConditionalDensity_tube_transfer {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (b : ℕ → ℝ) (H : ℕ → ℕ) (z : ℕ → ℝ) (hz : Tendsto z atTop atTop) + (hsmall : ∀ᶠ i in atTop, (conditionedLaw ν (realPosition (step e))).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i/10)) ≤ 3/10) + (N : ℕ) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ i in atTop, (rawConditionedWeight ν (realPosition (step e)) + (finiteConditionalDensity (realPosition (step e)) N)).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i)) ≤ + (rawConditionedWeight ν (realPosition (step e)) (finiteConditionalDensity (realPosition (step e)) N)).real + Set.univ * (conditionedLaw ν (realPosition (step e))).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i/10))+ε := by + let ℓ := realPosition (step e) + let p := annealedLaw ν (NoDrop ℓ 0) + have hp : p ≠ 0 := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hpfin : p ≠ ∞ := measure_ne_top _ _ + let C : ℝ≥0∞ := (N+1:ℕ) + have hC : C ≠ 0 := by simp [C] + have hCfin : C ≠ ∞ := by simp [C] + let g := fun ω => C⁻¹ * finiteConditionalDensity ℓ N ω + have hg : @Measurable _ _ (rowSigma {x | dot (realPosition x) ℓ ≤ (N:ℝ)}) _ g := + measurable_const.mul (finiteConditionalDensity_lower_rows e N) + have hgle : ∀ ω, g ω ≤ 1 := by + intro ω + exact (mul_le_mul' (le_refl C⁻¹) (finiteConditionalDensity_le ℓ N ω)).trans (ENNReal.inv_mul_le_one C) + let η := weightedConditioned ν ℓ g + let ρ := rawConditionedWeight ν ℓ (finiteConditionalDensity ℓ N) + have heq : ρ = (C*p) • η := by + have he : finiteConditionalDensity ℓ N = fun ω => C*g ω := by + funext ω + dsimp only [g] + rw [← mul_assoc,ENNReal.mul_inv_cancel hC hCfin,one_mul] + dsimp only [ρ] + rw [he,rawConditionedWeight_smul ν ℓ g (hg.mono (rowSigma_le _) le_rfl) C, + rawConditionedWeight_eq_smul ν ℓ hp g,smul_smul] + have hM : 0 < (C*p).toReal := ENNReal.toReal_pos (mul_ne_zero hC hp) (ENNReal.mul_ne_top hCfin hpfin) + have hh := weightedConditioned_tube_transfer ν ℓ f htrans b H z hz hsmall + (N:ℝ) (Nat.cast_nonneg N) g hg hgle (div_pos hε hM) + filter_upwards [hh] with i hi + have hm (A : Set (Path d)) : ρ.real A = (C*p).toReal*η.real A := by + rw [heq,Measure.real,Measure.smul_apply,smul_eq_mul,ENNReal.toReal_mul] + rfl + change ρ.real (MedianTubeFailure ℓ f b (H i) (z i)) ≤ + ρ.real Set.univ*(conditionedLaw ν ℓ).real (MedianTubeFailure ℓ f b (H i) (z i/10))+ε + rw [hm,hm] + have hi' := mul_le_mul_of_nonneg_left hi hM.le + have hc : (C*p).toReal*(ε/(C*p).toReal) = ε := by field_simp + rw [mul_add,hc] at hi' + simpa only [mul_assoc,η] using hi' + +lemma measureReal_le_add_mass_defect {Ω : Type*} [MeasurableSpace Ω] + (μ η : Measure Ω) [IsProbabilityMeasure μ] [IsFiniteMeasure η] (hη : η ≤ μ) + (A : Set Ω) (hA : MeasurableSet A) : μ.real A ≤ η.real A+1-η.real Set.univ := by + have hc : η.real Aᶜ ≤ μ.real Aᶜ := ENNReal.toReal_mono (measure_ne_top _ _) (hη Aᶜ) + rw [measureReal_compl hA,measureReal_compl hA,show μ.real Set.univ = 1 from probReal_univ] at hc + linarith + +theorem quenchedConditioned_tube_transfer_small {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (b : ℕ → ℝ) (H : ℕ → ℕ) (z : ℕ → ℝ) (hz : Tendsto z atTop atTop) + (hsmall : ∀ᶠ i in atTop, (conditionedLaw ν (realPosition (step e))).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i/10)) ≤ 3/10) + {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ i in atTop, (quenchedConditionedAverage ν (realPosition (step e))).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i)) ≤ + (conditionedLaw ν (realPosition (step e))).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i/10))+ε := by + let ℓ := realPosition (step e) + let μ := quenchedConditionedAverage ν ℓ + let : IsProbabilityMeasure μ := quenchedConditionedAverage_probability ν hue ℓ (signed_direction_unit e) htrans + let ρ := fun N => rawConditionedWeight ν ℓ (finiteConditionalDensity ℓ N) + have hdom (N : ℕ) : ρ N ≤ μ := rawConditionedWeight_mono ν ℓ _ _ + (finiteConditionalDensity_measurable ℓ N) (measurable_noDropQuenched ℓ 0).inv + (finiteConditionalDensity_le_inverse ℓ N) + let : ∀ N, IsFiniteMeasure (ρ N) := fun N => + ⟨lt_of_le_of_lt (hdom N Set.univ) (measure_lt_top _ _)⟩ + have ht : Tendsto (fun N => (ρ N).real Set.univ) atTop (𝓝 1) := by + have hh := (ENNReal.continuousAt_toReal (by simp : (1:ℝ≥0∞) ≠ ∞)).tendsto.comp + (finiteConditionalDensity_mass_tendsto ν hue ℓ (signed_direction_unit e) htrans) + simpa only [Function.comp_def,ENNReal.toReal_one,Measure.real,ρ] using hh + obtain ⟨N,hN⟩ := (ht.eventually (lt_mem_nhds (show 1-ε/2 < (1:ℝ) by linarith))).exists + have hh := finiteConditionalDensity_tube_transfer ν e f htrans b H z hz hsmall N + (show 0 < ε/2 by positivity) + filter_upwards [hh] with i hi + let A := MedianTubeFailure ℓ f b (H i) (z i) + let B := MedianTubeFailure ℓ f b (H i) (z i/10) + have ha := measureReal_le_add_mass_defect μ (ρ N) (hdom N) A + (measurableSet_medianTubeFailure ℓ f b (H i) (z i)) + have hmass : (ρ N).real Set.univ ≤ 1 := by + have h := ENNReal.toReal_mono (measure_ne_top _ _) (hdom N Set.univ) + simpa only [Measure.real,measure_univ,ENNReal.toReal_one] using h + have hp := mul_le_mul_of_nonneg_right hmass (show 0 ≤ (conditionedLaw ν ℓ).real B from measureReal_nonneg) + change (ρ N).real A ≤ (ρ N).real Set.univ*(conditionedLaw ν ℓ).real B+ε/2 at hi + change μ.real A ≤ (conditionedLaw ν ℓ).real B+ε + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/FiniteCoordinateApproximation.lean b/lean/OAI/Probability/Ballisticity/Geometry/FiniteCoordinateApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2570f7f83d92b8fcd3207f1911a39c5c8319b3c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/FiniteCoordinateApproximation.lean @@ -0,0 +1,61 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open Filter UniformSpace +open scoped Uniformity Topology +namespace DirectionalTransience.Entropy + +lemma finite_coordinates_of_entourage {I R : Type*} [UniformSpace R] + {V : Set ((I → R) × (I → R))} (hV : V ∈ 𝓤 (I → R)) : + ∃ S : Finset I, ∀ x y : I → R, (∀ i ∈ S, x i=y i) → (x,y)∈V := by + classical + rw [Pi.uniformity] at hV + refine Filter.iInf_sets_induct hV ?_ ?_ + · exact ⟨∅,fun _ _ _ => Set.mem_univ _⟩ + · intro i V W hV hW + obtain ⟨S,hS⟩ := hW + obtain ⟨U,hU,hUV⟩ := Filter.mem_comap.mp hV + refine ⟨insert i S,fun x y hxy => ⟨?_,hS x y (fun j hj => hxy j (Finset.mem_insert_of_mem hj))⟩⟩ + apply hUV + change (x i,y i)∈U + rw [hxy i (Finset.mem_insert_self _ _)] + exact refl_mem_uniformity hU + +lemma finite_coordinates_of_uniformContinuous {I R : Type*} [UniformSpace R] + (f : (I → R) → ℝ) (hf : UniformContinuous f) {ε : ℝ} (hε : 0<ε) : + ∃ S : Finset I, ∀ x y : I → R, (∀ i ∈ S, x i=y i) → |f x-f y|<ε := by + have h := hf (Metric.dist_mem_uniformity hε) + obtain ⟨S,hS⟩ := finite_coordinates_of_entourage h + exact ⟨S,fun x y hxy => by simpa only [Set.mem_preimage,Set.mem_ofPred_eq,Real.dist_eq] using hS x y hxy⟩ + +noncomputable def finiteFiller {I R : Type*} (r : I → R) (S : Finset I) (x : S → R) : I → R := by + classical + exact fun i => if h : i∈S then x ⟨i,h⟩ else r i + +lemma finiteFiller_continuous {I R : Type*} [TopologicalSpace R] (r : I → R) (S : Finset I) : + Continuous (finiteFiller r S) := by + classical + apply continuous_pi + intro i + by_cases hi : i∈S + · simpa only [finiteFiller, dite_eq_left hi] using (continuous_apply (⟨i,hi⟩ : S) : Continuous (fun x : S → R => x ⟨i,hi⟩)) + · simp only [finiteFiller, dite_eq_right hi] + exact continuous_const + +lemma finiteFiller_approx {I R : Type*} [UniformSpace R] [CompactSpace R] + (f : C((I → R),ℝ)) (r : I → R) {ε : ℝ} (hε : 0<ε) : + ∃ S : Finset I, ∀ x, |f x-f (finiteFiller r S (fun i => x i))|<ε := by + obtain ⟨S,hS⟩ := finite_coordinates_of_uniformContinuous f (CompactSpace.uniformContinuous_of_continuous f.continuous) hε + refine ⟨S,fun x => hS x _ ?_⟩ + intro i hi + simp [finiteFiller,hi] + +end DirectionalTransience.Entropy + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/FinitePastCoordinates.lean b/lean/OAI/Probability/Ballisticity/Geometry/FinitePastCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..304a4c3337cf6f13c63ff655c91137f52f603da7 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/FinitePastCoordinates.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.BoundaryPathCoordinates +import OAI.Probability.Ballisticity.Estimates.SharedEndpointTests + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def boundaryPrefixPair {d : ℕ} (D : BoundaryData d) : Path d × Path d := + (extendPrefix D.1.1 D.2.1, extendPrefix D.1.2 D.2.2) + +noncomputable def centeredPastCoordinates {d q : ℕ} (ℓ : Vector d) (f : Direction d) + (θ r : ℝ) (j : Fin q → ℕ) (x y : Lattice d) (P : Path d × Path d) : Fin q → ℝ × ℝ := + fun a => (centeredFirstHit ℓ f θ r (j a) x P.1, centeredFirstHit ℓ f θ r (j a) y P.2) + +lemma measurable_centeredPastCoordinates {d q : ℕ} (ℓ : Vector d) (f : Direction d) + (θ r : ℝ) (j : Fin q → ℕ) (x y : Lattice d) : + Measurable (centeredPastCoordinates ℓ f θ r j x y) := by + apply Measurable.of_eval + intro a + exact ((measurable_centeredFirstHit ℓ f θ r (j a) x).comp measurable_fst).prodMk + ((measurable_centeredFirstHit ℓ f θ r (j a) y).comp measurable_snd) + +lemma shared_centeredPastCoordinates_boundary {d q : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (x y : Lattice d) (hxy : signedHeight e x = signedHeight e y) + (H : ℕ) (hH : 0 < H) (j : Fin q → ℕ) (hj : ∀ a, j a ≤ H) (θ r : ℝ) : + let ℓ := realPosition (step e) + ∀ᵐ P ∂sharedConditionedPairLaw ν ℓ x y, + centeredPastCoordinates ℓ f θ r j x y P = + centeredPastCoordinates ℓ f θ r j x y + (boundaryPrefixPair (boundaryData ℓ ((signedHeight e x+H : ℤ) : ℝ) P)) := by + dsimp only + let ℓ := realPosition (step e) + filter_upwards [sharedConditioned_regularPath ν ℓ htrans x y, + shared_boundaryTimes_spec ν hue ℓ (signed_direction_unit e) htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) x y hxy H hH] + with P hP hb + funext a + obtain ⟨h1,h2⟩ := boundaryData_firstHit_prefix e x y hxy H P + hP.1.1 hP.2.1 hP.1.2 hP.2.2 hb (j a) (hj a) + simp only [centeredPastCoordinates,centeredFirstHit,boundaryPrefixPair] + rw [h1,h2] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/FiniteWordGeometry.lean b/lean/OAI/Probability/Ballisticity/Geometry/FiniteWordGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..22a81c5866cf59d0ee601c8a4c5f2c192de8f1ec --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/FiniteWordGeometry.lean @@ -0,0 +1,249 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.SignedHeight +import OAI.Probability.Ballisticity.Crossings.HitWord + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma wordPath_append_prefix {d : ℕ} (x : Lattice d) (u v : List (Direction d)) + {n : ℕ} (hn : n ≤ u.length) : wordPath x (u ++ v) n = wordPath x u n := by + induction u generalizing x n with + | nil => + have : n = 0 := by simpa using hn + simp [this] + | cons e u ih => + cases n with + | zero => simp + | succ n => + simpa only [List.cons_append,wordPath] using ih (x+step e) (Nat.le_of_succ_le_succ hn) + +lemma wordPath_append_suffix {d : ℕ} (x : Lattice d) (u v : List (Direction d)) + (n : ℕ) : wordPath x (u ++ v) (u.length+n) = wordPath (wordPath x u u.length) v n := by + induction u generalizing x with + | nil => simp [wordPath] + | cons e u ih => + simpa only [List.cons_append,List.length_cons,Nat.succ_add,wordPath] using ih (x+step e) + +lemma wordPath_after_end {d : ℕ} (x : Lattice d) (u : List (Direction d)) + {n : ℕ} (hn : u.length ≤ n) : wordPath x u n = wordPath x u u.length := by + induction u generalizing x n with + | nil => rfl + | cons e u ih => + cases n with + | zero => simp at hn + | succ n => + simpa only [List.length_cons,wordPath] using ih (x+step e) (Nat.le_of_succ_le_succ hn) + +lemma wordWeight_append {d : ℕ} (ω : Environment d) (x : Lattice d) + (u v : List (Direction d)) : + wordWeight ω x (u ++ v) = wordWeight ω x u * wordWeight ω (wordPath x u u.length) v := by + induction u generalizing x with + | nil => simp [wordWeight,wordPath] + | cons e u ih => simp only [List.cons_append,wordWeight,List.length_cons,wordPath,ih,mul_assoc] + +lemma wordPath_height_step {d : ℕ} (e : Direction d) (x : Lattice d) + (w : List (Direction d)) (n : ℕ) : + signedHeight e (wordPath x w (n+1)) ≤ signedHeight e (wordPath x w n)+1 := by + rcases wordPath_step_or_stay x w n with h | ⟨g,h⟩ + · rw [h]; omega + · rw [h]; exact signedHeight_step_le e _ g + +lemma wordPath_hit_exact {d : ℕ} (e : Direction d) (x : Lattice d) (H : ℕ) + (w : HitWord x (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H)) : + signedHeight e (wordPath x w.val w.val.length) = signedHeight e x + H := by + have htop : signedHeight e x + H ≤ signedHeight e (wordPath x w.val w.val.length) := by + have h := w.property.1 + change dot (realPosition x) (realPosition (step e))+(H:ℝ) ≤ + dot (realPosition (wordPath x w.val w.val.length)) (realPosition (step e)) at h + rw [signedHeight_projection,signedHeight_projection] at h + exact_mod_cast h + apply le_antisymm _ htop + cases hlen : w.val.length with + | zero => simpa only [hlen,wordPath_zero] using (show signedHeight e x ≤ signedHeight e x+H by omega) + | succ n => + have h := (w.property.2 n (by omega)).2 + change dot (realPosition (wordPath x w.val n)) (realPosition (step e)) < + dot (realPosition x) (realPosition (step e))+(H:ℝ) at h + rw [signedHeight_projection,signedHeight_projection] at h + have hn : signedHeight e (wordPath x w.val n) < signedHeight e x+H := by exact_mod_cast h + have hs := wordPath_height_step e x w.val n + omega + +noncomputable def wordFirstHitTime {d : ℕ} (e : Direction d) (x : Lattice d) + (s : ℕ) (w : List (Direction d)) : ℕ := + if h : ∃ n, signedHeight e x+s ≤ signedHeight e (wordPath x w n) then Nat.find h else 0 + +noncomputable def wordFirstHitPosition {d : ℕ} (e : Direction d) (x : Lattice d) + (s : ℕ) (w : List (Direction d)) : Lattice d := + wordPath x w (wordFirstHitTime e x s w) + +lemma wordFirstHitTime_spec {d : ℕ} (e : Direction d) (x : Lattice d) + (s : ℕ) (w : List (Direction d)) + (h : ∃ n, signedHeight e x+s ≤ signedHeight e (wordPath x w n)) : + signedHeight e x+s ≤ signedHeight e (wordFirstHitPosition e x s w) := by + simp only [wordFirstHitPosition,wordFirstHitTime,dite_eq_left h] + exact Nat.find_spec h + +lemma wordFirstHitTime_le {d : ℕ} (e : Direction d) (x : Lattice d) + (s : ℕ) (w : List (Direction d)) {n : ℕ} + (h : signedHeight e x+s ≤ signedHeight e (wordPath x w n)) : + wordFirstHitTime e x s w ≤ n := by + simp only [wordFirstHitTime,dite_eq_left (show ∃ n, signedHeight e x+s ≤ signedHeight e (wordPath x w n) from ⟨n,h⟩)] + exact Nat.find_min' _ h + +lemma wordFirstHitTime_min {d : ℕ} (e : Direction d) (x : Lattice d) + (s : ℕ) (w : List (Direction d)) {n : ℕ} (hn : n < wordFirstHitTime e x s w) : + signedHeight e (wordPath x w n) < signedHeight e x+s := by + by_contra h + exact (wordFirstHitTime_le e x s w (le_of_not_gt h)).not_gt hn + +lemma wordFirstHitTime_zero {d : ℕ} (e : Direction d) (x : Lattice d) + (w : List (Direction d)) : wordFirstHitTime e x 0 w = 0 := by + apply Nat.eq_zero_of_le_zero + apply wordFirstHitTime_le + simp + +lemma wordFirstHitTime_endpoint {d : ℕ} (e : Direction d) (x : Lattice d) (H : ℕ) + (w : HitWord x (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H)) : + wordFirstHitTime e x H w.val = w.val.length := by + have hh : signedHeight e x+(H:ℤ) ≤ signedHeight e (wordPath x w.val w.val.length) := + (wordPath_hit_exact e x H w).ge + apply le_antisymm (wordFirstHitTime_le e x H w.val hh) + by_contra h + have hn : wordFirstHitTime e x H w.val < w.val.length := by omega + have hp := (w.property.2 _ hn).2 + change dot (realPosition (wordFirstHitPosition e x H w.val)) (realPosition (step e)) < + dot (realPosition x) (realPosition (step e))+(H:ℝ) at hp + rw [signedHeight_projection,signedHeight_projection] at hp + have hp' : signedHeight e (wordFirstHitPosition e x H w.val) < signedHeight e x+H := by exact_mod_cast hp + exact hp'.not_ge (wordFirstHitTime_spec e x H w.val ⟨w.val.length,hh⟩) + +lemma coordinate_mem_strip_iff {d : ℕ} (e : Direction d) (x y : Lattice d) (H : ℕ) : + y ∈ Strip (realPosition (step e)) x H ↔ + signedHeight e x ≤ signedHeight e y ∧ signedHeight e y < signedHeight e x+H := by + simp only [Strip,Set.mem_ofPred_eq,signedHeight_projection] + constructor + · rintro ⟨h1,h2⟩ + constructor + · exact_mod_cast h1 + · exact_mod_cast h2 + · rintro ⟨h1,h2⟩ + constructor + · exact_mod_cast h1 + · exact_mod_cast h2 + +lemma coordinate_mem_upper_iff {d : ℕ} (e : Direction d) (x y : Lattice d) (H : ℕ) : + y ∈ Upper (realPosition (step e)) x H ↔ signedHeight e x+H ≤ signedHeight e y := by + simp only [Upper,Set.mem_ofPred_eq,signedHeight_projection] + constructor <;> intro h <;> exact_mod_cast h + +lemma wordPath_hit_append {d : ℕ} (e : Direction d) (x : Lattice d) (h m : ℕ) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : HitWord (wordPath x u.val u.val.length) + (Strip (realPosition (step e)) (wordPath x u.val u.val.length) m) + (Upper (realPosition (step e)) (wordPath x u.val u.val.length) m)) : + wordPath x (u.val++v.val) ∈ HitAt (Strip (realPosition (step e)) x ((h+m : ℕ) : ℝ)) + (Upper (realPosition (step e)) x ((h+m : ℕ) : ℝ)) (u.val++v.val).length := by + have hy := wordPath_hit_exact e x h u + constructor + · rw [List.length_append,wordPath_append_suffix,coordinate_mem_upper_iff, + wordPath_hit_exact e _ m v,hy,Nat.cast_add] + omega + · intro n hn + rw [coordinate_mem_strip_iff] + by_cases hu : n < u.val.length + · rw [wordPath_append_prefix x u.val v.val hu.le] + have hp := (coordinate_mem_strip_iff e x (wordPath x u.val n) h).mp (u.property.2 n hu) + constructor + · exact hp.1 + · push_cast; omega + · have he : n = u.val.length+(n-u.val.length) := by omega + rw [he,wordPath_append_suffix] + have hv : n-u.val.length < v.val.length := by simp only [List.length_append] at hn; omega + have hp := (coordinate_mem_strip_iff e _ _ m).mp (v.property.2 _ hv) + rw [hy] at hp + constructor <;> push_cast <;> omega + +lemma wordFirstHitTime_eq {d : ℕ} (e : Direction d) (x : Lattice d) (s : ℕ) + (w : List (Direction d)) (n : ℕ) + (hn : signedHeight e x+s ≤ signedHeight e (wordPath x w n)) + (hmin : ∀ i < n, signedHeight e (wordPath x w i) < signedHeight e x+s) : + wordFirstHitTime e x s w = n := by + apply le_antisymm (wordFirstHitTime_le e x s w hn) + by_contra hc + have hi : wordFirstHitTime e x s w < n := by omega + exact (hmin _ hi).not_ge (wordFirstHitTime_spec e x s w ⟨n,hn⟩) + +lemma wordFirstHitTime_append_prefix {d : ℕ} (e : Direction d) (x : Lattice d) + (h s : ℕ) (hs : s ≤ h) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : List (Direction d)) : + wordFirstHitTime e x s (u.val++v) = wordFirstHitTime e x s u.val := by + have hend : signedHeight e x+s ≤ signedHeight e (wordPath x u.val u.val.length) := by + rw [wordPath_hit_exact e x h u]; omega + have hn := wordFirstHitTime_le e x s u.val hend + apply wordFirstHitTime_eq + · rw [wordPath_append_prefix x u.val v hn] + exact wordFirstHitTime_spec e x s u.val ⟨u.val.length,hend⟩ + · intro i hi + rw [wordPath_append_prefix x u.val v (hi.le.trans hn)] + exact wordFirstHitTime_min e x s u.val hi + +lemma wordFirstHitPosition_append_prefix {d : ℕ} (e : Direction d) (x : Lattice d) + (h s : ℕ) (hs : s ≤ h) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : List (Direction d)) : + wordFirstHitPosition e x s (u.val++v) = wordFirstHitPosition e x s u.val := by + rw [wordFirstHitPosition,wordFirstHitTime_append_prefix e x h s hs u v] + apply wordPath_append_prefix + apply wordFirstHitTime_le + rw [wordPath_hit_exact e x h u] + omega + +lemma wordFirstHitTime_append_suffix {d : ℕ} (e : Direction d) (x : Lattice d) + (h m t : ℕ) (ht : t ≤ m) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : HitWord (wordPath x u.val u.val.length) + (Strip (realPosition (step e)) (wordPath x u.val u.val.length) m) + (Upper (realPosition (step e)) (wordPath x u.val u.val.length) m)) : + wordFirstHitTime e x (h+t) (u.val++v.val) = + u.val.length+wordFirstHitTime e (wordPath x u.val u.val.length) t v.val := by + have hy := wordPath_hit_exact e x h u + have hend : signedHeight e (wordPath x u.val u.val.length)+t ≤ + signedHeight e (wordPath (wordPath x u.val u.val.length) v.val v.val.length) := by + rw [wordPath_hit_exact e _ m v]; omega + apply wordFirstHitTime_eq + · rw [wordPath_append_suffix,Nat.cast_add,← add_assoc,← hy] + exact wordFirstHitTime_spec e _ t v.val ⟨v.val.length,hend⟩ + · intro i hi + by_cases hui : i < u.val.length + · rw [wordPath_append_prefix x u.val v.val hui.le] + have hp := ((coordinate_mem_strip_iff e x _ h).mp (u.property.2 _ hui)).2 + push_cast; omega + · have he : i = u.val.length+(i-u.val.length) := by omega + rw [he,wordPath_append_suffix,Nat.cast_add,← add_assoc,← hy] + apply wordFirstHitTime_min + omega + +lemma wordFirstHitPosition_append_suffix {d : ℕ} (e : Direction d) (x : Lattice d) + (h m t : ℕ) (ht : t ≤ m) + (u : HitWord x (Strip (realPosition (step e)) x h) (Upper (realPosition (step e)) x h)) + (v : HitWord (wordPath x u.val u.val.length) + (Strip (realPosition (step e)) (wordPath x u.val u.val.length) m) + (Upper (realPosition (step e)) (wordPath x u.val u.val.length) m)) : + wordFirstHitPosition e x (h+t) (u.val++v.val) = + wordFirstHitPosition e (wordPath x u.val u.val.length) t v.val := by + rw [wordFirstHitPosition,wordFirstHitTime_append_suffix e x h m t ht u v, + wordPath_append_suffix] + rfl + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/HeightIncrement.lean b/lean/OAI/Probability/Ballisticity/Geometry/HeightIncrement.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7efedb7189b152a5993ed690f3bc3c5d6e09490 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/HeightIncrement.lean @@ -0,0 +1,405 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.AlignedRecordPrefix + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma block_transfer_bound {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F B : ℕ → Ω → ℝ) {q : ℝ} (hq : 0 ≤ q) {H b M : ℕ} (hM : H/b ≤ M) + {a : ℝ} + (htransfer : q*μ.real (HeightOscillation F (HeightBlockRelation H b) (2*a)) ≤ + μ.real {ω | ∃ s h, (s,h) ∈ HeightBlockRelation H b ∧ + 2*a < |B h ω-B s ω|+|F s ω-B s ω|}) : + q*μ.real (HeightGapEvent F B H (6*a)) ≤ + (q+1)*(μ.real (HeightOscillation B (HeightBlockRelation H b) a)+ + μ.real (BlockDecoration F B M b a)) := by + have hs : {ω | ∃ s h, (s,h) ∈ HeightBlockRelation H b ∧ + 2*a < |B h ω-B s ω|+|F s ω-B s ω|} ⊆ + HeightOscillation B (HeightBlockRelation H b) a ∪ BlockDecoration F B M b a := by + rintro ω ⟨s,h,hsj,hbig⟩ + by_cases hb : a < |B h ω-B s ω| + · exact Or.inl ⟨s,h,hsj,hb⟩ + · apply Or.inr + refine ⟨h/b,(Nat.div_le_div_right hsj.1).trans hM,?_⟩ + rw [← hsj.2] + have := le_of_not_gt hb + linarith + have ht := htransfer.trans ((measureReal_mono hs (measure_ne_top _ _)).trans + (measureReal_union_le (μ := μ) _ _)) + have hg := (measureReal_mono (heightGap_subset F B hM (a := a)) (measure_ne_top _ _)).trans + ((measureReal_union_le (μ := μ) _ _).trans + (add_le_add (measureReal_union_le (μ := μ) _ _) le_rfl)) + have hmul := mul_le_mul_of_nonneg_left hg hq + nlinarith + +lemma blockDecoration_finite_union {Ω : Type*} (F B : ℕ → Ω → ℝ) (M b : ℕ) (z : ℝ) : + BlockDecoration F B M b z = ⋃ j ∈ Finset.range (M+1), {ω | z < |F (j*b) ω-B (j*b) ω|} := by + ext ω + simp only [BlockDecoration,Set.mem_ofPred_eq,Set.mem_iUnion,Finset.mem_range,Nat.lt_succ_iff,exists_prop] + +lemma blockDecoration_small {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F B : ℕ → Ω → ℝ) (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) + (hdec : ∀ h : ℕ → ℕ, TendstoInMeasure μ (fun i ω => (F (h i) ω-B (h i) ω)/r i) atTop 0) + (M : ℕ) (b : ℕ → ℕ) {a : ℝ} (ha : 0 < a) : + Tendsto (fun i => μ.real (BlockDecoration F B M (b i) (a*r i))) atTop (𝓝 0) := by + have hj (j : ℕ) : Tendsto (fun i => μ.real {ω | a*r i < |F (j*b i) ω-B (j*b i) ω|}) atTop (𝓝 0) := by + have ht := tendstoInMeasure_iff_measureReal_norm.mp (hdec (fun i => j*b i)) a ha + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at ht + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ ht + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ))] with i hri + apply measureReal_mono _ (measure_ne_top _ _) + intro ω hω + simp only [Set.mem_ofPred_eq,abs_div,abs_of_pos hri] + exact ((lt_div_iff₀ hri).2 hω).le + have ht := tendsto_finsetSum (Finset.range (M+1)) (fun j _ => hj j) + simp only [Finset.sum_const_zero] at ht + apply squeeze_zero (fun _ => measureReal_nonneg) _ ht + intro i + rw [blockDecoration_finite_union] + exact measureReal_biUnion_finset_le _ _ + +lemma renewal_height_block_subset {Ω : Type*} (X : ℕ → Ω → ℝ) (L : ℕ → Ω → ℕ) + {n T c δ z : ℝ} (hn : 1 ≤ n) (hT : 0 ≤ T) (hc : 1 ≤ c) (hδ : 0 ≤ δ) (hδn : 4 ≤ δ*n) : + HeightOscillation (fun h ω => realPartialSum (fun k => X k ω) + (renewalCount (fun k => L k ω) h)) (HeightBlockRelation (⌊T*n⌋₊+1) ⌊(δ/4)*n⌋₊) z ⊆ + {ω | ∃ h : ℕ, (h:ℝ) ≤ (T+1)*n ∧ + δ/8 < |(renewalCount (fun j => L j ω) h : ℝ)/n-(h:ℝ)/(c*n)|} ∪ + GridOscillation X ⌊(T+1)*n⌋₊ ⌊δ*n⌋₊ z := by + rintro ω ⟨s,h,hsj,hbad⟩ + by_cases hclock : ω ∈ {ω | ∃ h : ℕ, (h:ℝ) ≤ (T+1)*n ∧ + δ/8 < |(renewalCount (fun j => L j ω) h : ℝ)/n-(h:ℝ)/(c*n)|} + · exact Or.inl hclock + apply Or.inr + let C := renewalCount (fun k => L k ω) + have hn0 : 0 < n := by linarith + have hc0 : 0 < c := by linarith + have hs : s ≤ h := heightBlockRelation_order _ _ _ hsj + have hH : (h:ℝ) ≤ (T+1)*n := by + have := (show (h:ℝ) ≤ (⌊T*n⌋₊:ℝ)+1 by exact_mod_cast hsj.1) + have hf := Nat.floor_le (mul_nonneg hT hn0.le) + nlinarith + have hsH := (Nat.cast_le.mpr hs).trans hH + have hb : (h:ℝ)-(s:ℝ) ≤ (δ/4)*n := by + have hrem : h-s = h % ⌊(δ/4)*n⌋₊ := by + have he : s = h / ⌊(δ/4)*n⌋₊ * ⌊(δ/4)*n⌋₊ := hsj.2 + have heq : h % ⌊(δ/4)*n⌋₊ + h / ⌊(δ/4)*n⌋₊ * ⌊(δ/4)*n⌋₊ = h := by + simpa only [Nat.mul_comm] using Nat.mod_add_div h ⌊(δ/4)*n⌋₊ + omega + have hb0 : 0 < ⌊(δ/4)*n⌋₊ := by + apply Nat.succ_le_iff.mp + apply Nat.le_floor + norm_num + linarith + have hh : h-s ≤ ⌊(δ/4)*n⌋₊ := by rw [hrem]; exact (Nat.mod_lt _ hb0).le + have hh' : (h:ℝ)-(s:ℝ) ≤ (⌊(δ/4)*n⌋₊:ℝ) := by + rw [← Nat.cast_sub hs] + exact_mod_cast hh + exact hh'.trans (Nat.floor_le (mul_nonneg (by positivity) hn0.le)) + have hclock' (j : ℕ) (hj : (j:ℝ) ≤ (T+1)*n) : |(C j:ℝ)-(j:ℝ)/c| ≤ δ*n/8 := by + have he : |(C j:ℝ)/n-(j:ℝ)/(c*n)| ≤ δ/8 := + le_of_not_gt (fun hh => hclock ⟨j,hj,hh⟩) + have heq : ((C j:ℝ)/n-(j:ℝ)/(c*n))*n = (C j:ℝ)-(j:ℝ)/c := by field_simp + have he' := mul_le_mul_of_nonneg_right he hn0.le + have he'' : |((C j:ℝ)/n-(j:ℝ)/(c*n))*n| ≤ δ/8*n := by + simpa only [abs_mul,abs_of_pos hn0] using he' + rw [heq] at he'' + convert he'' using 1; ring + have hch := (abs_le.mp (hclock' h hH)).2 + have hcs := (abs_le.mp (hclock' s hsH)).1 + have hdiv : ((h:ℝ)-(s:ℝ))/c ≤ (h:ℝ)-(s:ℝ) := div_le_self (sub_nonneg.mpr (Nat.cast_le.mpr hs)) hc + have hd : (C h:ℝ)-(C s:ℝ) ≤ δ*n := by + have he : (h:ℝ)/c-(s:ℝ)/c = ((h:ℝ)-(s:ℝ))/c := (sub_div _ _ _).symm + have hδn := mul_nonneg hδ hn0.le + linarith + have hC := renewalCount_monotone (fun k => L k ω) hs + have hdiff : C h-C s ≤ ⌊δ*n⌋₊ := by + apply Nat.le_floor + rw [Nat.cast_sub hC] + exact hd + refine ⟨C s,?_,C h,?_,hC,by omega,hbad⟩ + · exact (renewalCount_le _ _).trans (Nat.le_floor hsH) + · exact (renewalCount_le _ _).trans (Nat.le_floor hH) + +lemma gaussian_renewal_block_modulus {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (L : ℕ → Ω → ℕ) (hL : ∀ k, Measurable (L k)) + (hpos : ∀ᵐ ω ∂μ, ∀ k, 0 < L k ω) {c : ℝ} (hc : 1 ≤ c) + (hmean : ∀ᵐ ω ∂μ, Tendsto (fun k : ℕ => (renewalSum (fun j => L j ω) k : ℝ)/k) + atTop (𝓝 c)) (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T a β : ℝ} (hT : 0 ≤ T) (ha : 0 < a) (hβ : 0 < β) : + ∃ δ : ℝ, 0 < δ ∧ ∀ᶠ i in atTop, + μ.real (HeightOscillation (fun h ω => realPartialSum (fun k => X k ω) + (renewalCount (fun k => L k ω) h)) + (HeightBlockRelation (⌊T*fluctuationScale μ (X 0) (r i)⌋₊+1) + ⌊δ*fluctuationScale μ (X 0) (r i)⌋₊) (a*r i)) ≤ β := by + let n := fun i => fluctuationScale μ (X 0) (r i) + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto μ (X 0) (hX 0) hI hne).comp hr.1 + obtain ⟨δ,hδ,hgrid⟩ := gaussian_grid_modulus μ X hX hind hident hsym hI hne r hr + (by linarith : 0 ≤ T+1) ha (by linarith : 0 < β/2) + let A := fun i => {ω | ∃ h : ℕ, (h:ℝ) ≤ (T+1)*n i ∧ + δ/8 < |(renewalCount (fun j => L j ω) h : ℝ)/n i-(h:ℝ)/(c*n i)|} + have hclock : Tendsto (fun i => μ (A i)) atTop (𝓝 0) := + renewalCount_uniform_in_probability μ L hL hpos (by linarith) hmean n hn + (by linarith) (by positivity) + have hclockR : Tendsto (fun i => μ.real (A i)) atTop (𝓝 0) := by + simpa only [ENNReal.toReal_zero,Function.comp_def,Measure.real] using (ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp hclock + have hevent := (tendsto_order.mp hclockR).2 (β/2) (by linarith) + refine ⟨δ/4,by positivity,?_⟩ + filter_upwards [hgrid,hevent,hn.eventually (eventually_ge_atTop (1:ℝ)), + (hn.const_mul_atTop hδ).eventually (eventually_ge_atTop (4:ℝ))] with i hg ha hni hdni + have hs := renewal_height_block_subset X L hni hT hc hδ.le hdni (z := a*r i) + have hh := (measureReal_mono hs (measure_ne_top _ _)).trans (measureReal_union_le (μ := μ) _ _) + change μ.real (A i) < β/2 at ha + change μ.real (GridOscillation X ⌊(T+1)*n i⌋₊ ⌊δ*n i⌋₊ (a*r i)) ≤ β/2 at hg + exact hh.trans (by linarith) + +theorem heightGap_small_of_transfer {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F B : ℕ → Ω → ℝ) + (r n : ℕ → ℝ) (hr : Tendsto r atTop atTop) (hn : Tendsto n atTop atTop) + {q T : ℝ} (hq : 0 < q) (hT : 0 ≤ T) + (htransfer : ∀ J : Set (ℕ × ℕ), (∀ sr ∈ J, sr.1 ≤ sr.2) → ∀ z, 0 ≤ z → + q*μ.real (HeightOscillation F J z) ≤ + μ.real {ω | ∃ s h, (s,h) ∈ J ∧ z < |B h ω-B s ω|+|F s ω-B s ω|}) + (hdec : ∀ h : ℕ → ℕ, TendstoInMeasure μ (fun i ω => (F (h i) ω-B (h i) ω)/r i) atTop 0) + (hmod : ∀ a β : ℝ, 0 < a → 0 < β → ∃ δ : ℝ, 0 < δ ∧ ∀ᶠ i in atTop, + μ.real (HeightOscillation B (HeightBlockRelation (⌊T*n i⌋₊+1) ⌊δ*n i⌋₊) (a*r i)) ≤ β) + {ε : ℝ} (hε : 0 < ε) : + Tendsto (fun i => μ.real (HeightGapEvent F B (⌊T*n i⌋₊+1) (ε*r i))) atTop (𝓝 0) := by + apply tendsto_order.2 + constructor + · intro a ha + exact Eventually.of_forall fun _ => ha.trans_le measureReal_nonneg + · intro β hβ + let a := ε/6 + let b := β*q/(4*(q+1)) + have ha : 0 < a := by dsimp [a]; positivity + have hb : 0 < b := by dsimp [b]; positivity + obtain ⟨δ,hδ,hm⟩ := hmod a b ha hb + obtain ⟨M,hM⟩ := exists_nat_gt ((T+1)/δ) + have hM' : T+1 < (M:ℝ)*δ := (div_lt_iff₀ hδ).mp hM + have hcovered := eventually_floor_horizon_covered n hn (by linarith : 0 ≤ T+1) hδ M hM' + have hd := blockDecoration_small μ F B r hr hdec M (fun i => ⌊δ*n i⌋₊) ha + have hdevent := (tendsto_order.mp hd).2 b hb + filter_upwards [hm,hcovered,hdevent,hr.eventually (eventually_gt_atTop (0:ℝ)), + hn.eventually (eventually_ge_atTop (1:ℝ))] with i hmi hci hdi hri hni + have hH : ⌊T*n i⌋₊+1 ≤ ⌊(T+1)*n i⌋₊ := by + apply Nat.le_floor + push_cast + have hf := Nat.floor_le (mul_nonneg hT (by linarith : 0 ≤ n i)) + nlinarith + have hdiv : (⌊T*n i⌋₊+1)/⌊δ*n i⌋₊ ≤ M := by + exact ((Nat.div_lt_iff_lt_mul hci.1).mpr (hH.trans_lt hci.2)).le + have hz : 0 ≤ 2*(a*r i) := by positivity + have ht := block_transfer_bound μ F B hq.le hdiv + (htransfer _ (heightBlockRelation_order _ _) (2*(a*r i)) hz) + have he : 6*(a*r i) = ε*r i := by dsimp [a]; ring + rw [he] at ht + have hfin : q*μ.real (HeightGapEvent F B (⌊T*n i⌋₊+1) (ε*r i)) < q*β := by + have hbq : (q+1)*(2*b) = q*β/2 := by dsimp [b]; field_simp; ring + have := mul_lt_mul_of_pos_left (add_lt_add_of_le_of_lt hmi hdi) (by linarith : 0 < q+1) + rw [← two_mul,hbq] at this + nlinarith + exact (mul_lt_mul_iff_of_pos_left hq).mp hfin + +theorem transverse_firstHit_uniform_error {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T ε : ℝ} (hT : 0 ≤ T) (hε : 0 < ε) : + Tendsto (fun i => (independentConditionedPairLaw ν (realPosition (step e))).real + (HeightGapEvent (firstHitPairGap (realPosition (step e)) f) + (commonBoundaryGap (realPosition (step e)) f) + (⌊T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)⌋₊+1) (ε*r i))) atTop (𝓝 0) := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + have hp := noDrop_positive_of_directionallyTransient ν ℓ htrans + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ (ne_of_gt hp) + have hi := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn := (fluctuationScale_tendsto μ (commonIncrementProcess ℓ f 0) + (measurable_commonIncrementProcess ℓ f 0) hi hne).comp hr.1 + apply heightGap_small_of_transfer μ (firstHitPairGap ℓ f) (commonBoundaryGap ℓ f) + r _ hr.1 hn (q := (annealedLaw ν (NoDrop ℓ 0)).toReal^2) + (sq_pos_of_pos (ENNReal.toReal_pos (ne_of_gt hp) (measure_ne_top _ _))) hT _ _ _ hε + · intro J hJ z hz + have hh := independent_firstHit_gap_transfer ν ℓ f htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) J hJ hz + have hh' := ENNReal.toReal_mono (measure_ne_top _ _) hh + simpa only [HeightOscillation,Measure.real,ENNReal.toReal_mul,ENNReal.toReal_pow,μ] using hh' + · intro h + exact independent_firstHit_decoration_small ν ℓ f htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) r hr.1 h + · intro a β ha hβ + apply gaussian_renewal_block_modulus μ (commonIncrementProcess ℓ f) + (measurable_commonIncrementProcess ℓ f) + (commonIncrements_independent ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) f) + (commonIncrements_identDistrib ν ℓ htrans (signedHeight e) + (signedHeight_projection e) (signedHeight_step_le e) f) + (independent_commonWordIncrement_symmetric ν ℓ htrans f) hi hne + (commonWidthProcess ℓ) (measurable_commonWidthProcess ℓ) _ + (commonMeanWidth_ge_one ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)) + (commonWidth_strongLaw ν ℓ htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)) + r hr hT ha hβ + filter_upwards [independent_conditioned_all_firstPairWords ν ℓ htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e)] with P hP k + exact commonWordWidth_positive ℓ _ _ (hP k) + +def heightIncrement (F : ℕ → ℝ) (k : ℕ) : ℝ := F (k+1)-F k + +lemma realPartialSum_heightIncrement (F : ℕ → ℝ) (h : ℕ) : + realPartialSum (heightIncrement F) h = F h-F 0 := by + induction h with + | zero => simp [realPartialSum] + | succ h ih => rw [realPartialSum_succ,ih,heightIncrement]; ring + +lemma measurable_heightIncrement {Ω : Type*} [MeasurableSpace Ω] + (F : ℕ → Ω → ℝ) (hF : ∀ k, Measurable (F k)) (j : ℕ) : + Measurable (fun ω => heightIncrement (fun k => F k ω) j) := (hF (j+1)).sub (hF j) + +lemma height_polygon_difference_le (F B : ℕ → ℝ) (h0 : F 0 = B 0) + {r n T a : ℝ} (hr : 0 < r) (hn : 0 ≤ n) (hT : 0 ≤ T) + (hgap : ∀ h ≤ ⌊T*n⌋₊+1, |F h-B h| ≤ a*r) : + ‖scaledPolygon (heightIncrement F) r n T-scaledPolygon (heightIncrement B) r n T‖ ≤ a := by + apply (ContinuousMap.norm_le_of_nonempty _).mpr + intro t + let u := T*n*(t:ℝ) + let j := ⌊u⌋₊ + have hu : 0 ≤ u := mul_nonneg (mul_nonneg hT hn) t.2.1 + have huT : u ≤ T*n := mul_le_of_le_one_right (mul_nonneg hT hn) t.2.2 + have hj : j < ⌊T*n⌋₊+1 := Nat.lt_succ_of_le (Nat.floor_mono huT) + have hj0 : (j:ℝ) ≤ u := Nat.floor_le hu + have hj1 : u < (j:ℝ)+1 := Nat.lt_floor_add_one u + have hdet := abs_convex_sub_le (q := u-j) (by linarith) (by linarith) + (z := (0:ℝ)) (by simpa only [sub_zero] using hgap j hj.le) + (by simpa only [sub_zero] using hgap (j+1) hj) + have he : linearPolygon (heightIncrement F) (⌊T*n⌋₊+1) u- + linearPolygon (heightIncrement B) (⌊T*n⌋₊+1) u = + (1-(u-j))*(F j-B j)+(u-j)*(F (j+1)-B (j+1)) := by + rw [linearPolygon_formula _ _ hu hj,linearPolygon_formula _ _ hu hj, + realPartialSum_heightIncrement,realPartialSum_heightIncrement] + simp only [heightIncrement,h0] + dsimp only [j] + ring + rw [sub_zero,← he] at hdet + simp only [ContinuousMap.sub_apply,Real.norm_eq_abs,scaledPolygon_apply] + rw [← sub_div,abs_div,abs_of_pos hr] + exact (div_le_iff₀ hr).2 hdet + +lemma height_polygon_difference_small {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F B : ℕ → Ω → ℝ) + (h0 : ∀ᵐ ω ∂μ, F 0 ω = B 0 ω) (r n : ℕ → ℝ) + (hr : Tendsto r atTop atTop) (hn : Tendsto n atTop atTop) {T : ℝ} (hT : 0 ≤ T) + (hgap : ∀ ε, 0 < ε → Tendsto (fun i => μ.real + (HeightGapEvent F B (⌊T*n i⌋₊+1) (ε*r i))) atTop (𝓝 0)) : + TendstoInMeasure μ (fun i ω => scaledPolygon (heightIncrement (fun h => F h ω)) (r i) (n i) T- + scaledPolygon (heightIncrement (fun h => B h ω)) (r i) (n i) T) atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + simp only [Pi.zero_apply,sub_zero] + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ (hgap (ε/2) (by linarith)) + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ)), + hn.eventually (eventually_ge_atTop (0:ℝ))] with i hri hni + apply ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae _) + filter_upwards [h0] with ω h0 hbig + by_contra hnot + have hb (h : ℕ) (hh : h ≤ ⌊T*n i⌋₊+1) : |F h ω-B h ω| ≤ ε/2*r i := + le_of_not_gt (fun hbad => hnot ⟨h,hh,hbad⟩) + have hh := height_polygon_difference_le (fun h => F h ω) (fun h => B h ω) h0 hri hni hT hb + change ε ≤ ‖scaledPolygon (heightIncrement (fun h => F h ω)) (r i) (n i) T- + scaledPolygon (heightIncrement (fun h => B h ω)) (r i) (n i) T‖ at hbig + linarith + +lemma commonBoundary_heightIncrement {d : ℕ} (ℓ : Vector d) (e : Direction d) (P : Path d × Path d) : + heightIncrement (fun h => commonBoundaryGap ℓ e h P) = + renewalRewardIncrement (fun k => commonIncrementProcess ℓ e k P) + (fun k => commonWidthProcess ℓ k P) := rfl + +theorem transverse_firstHit_path_error {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + TendstoInMeasure (independentConditionedPairLaw ν (realPosition (step e))) (fun i P => + scaledPolygon (heightIncrement (fun h => firstHitPairGap (realPosition (step e)) f h P)) + (r i) (fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) T- + scaledPolygon (renewalRewardIncrement (fun k => commonIncrementProcess (realPosition (step e)) f k P) + (fun k => commonWidthProcess (realPosition (step e)) k P)) + (r i) (fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) T) atTop 0 := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + have hp := noDrop_positive_of_directionallyTransient ν ℓ htrans + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ (ne_of_gt hp) + have hi := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn := (fluctuationScale_tendsto μ (commonIncrementProcess ℓ f 0) + (measurable_commonIncrementProcess ℓ f 0) hi hne).comp hr.1 + apply height_polygon_difference_small μ (firstHitPairGap ℓ f) (commonBoundaryGap ℓ f) _ r _ hr.1 hn hT + · exact fun ε hε => transverse_firstHit_uniform_error ν hue e f hef htrans r hr hT hε + + · let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ (ne_of_gt hp) + have hac := conditionedLaw_absolutelyContinuous ν ℓ + have h0 := (Measure.quasiMeasurePreserving_fst.ae (hac.ae_le (annealed_initial ν))).and + (Measure.quasiMeasurePreserving_snd.ae (hac.ae_le (annealed_initial ν))) + filter_upwards [h0] with P hP + simp only [firstHitPairGap,recordIndexPosition,recordIndexTime_zero,hP.1,hP.2,sub_self, + commonBoundaryGap,renewalCount_zero,realPartialSum_zero] + +theorem transverse_firstHit_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + letI : IsProbabilityMeasure (independentConditionedPairLaw ν (realPosition (step e))) := + independentConditionedPairLaw_probability ν _ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i P => scaledPolygon + (heightIncrement (fun h => firstHitPairGap (realPosition (step e)) f h P)) (r i) + (fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) T) + atTop id (fun _ => independentConditionedPairLaw ν (realPosition (step e))) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun f : C(unitInterval,ℝ) => I.restrict f) = + gaussianPathFiniteLaw (T/commonMeanWidth ν (realPosition (step e))) I := by + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + obtain ⟨W,hW,hf⟩ := transverse_common_boundary_path_limit ν hue e f hef htrans r hr hT + refine ⟨W,?_,hf⟩ + apply tendstoInDistribution_of_tendstoInMeasure_sub _ id hW + · exact transverse_firstHit_path_error ν hue e f hef htrans r hr hT + · intro i + exact (measurable_scaledPolygon _ + (measurable_heightIncrement (firstHitPairGap ℓ f) (measurable_firstHitPairGap ℓ f)) _ _ _).aemeasurable + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygon.lean b/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygon.lean new file mode 100644 index 0000000000000000000000000000000000000000..fff1a2f74f9d991f791522cf0e7ab33373c98ebe --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygon.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightIncrement +import OAI.Probability.Ballisticity.Estimates.GridLinear + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def heightPolygon (F : ℕ → ℝ) (r n T : ℝ) : C(unitInterval,ℝ) := + ContinuousMap.const _ (F 0/r) + scaledPolygon (heightIncrement F) r n T + +lemma measurable_heightPolygon {Ω : Type*} [MeasurableSpace Ω] + (F : ℕ → Ω → ℝ) (hF : ∀ k, Measurable (F k)) (r n T : ℝ) : + Measurable (fun ω => heightPolygon (fun k => F k ω) r n T) := by + exact (ContinuousMap.continuous_const'.measurable.comp ((hF 0).div_const _)).add + (measurable_scaledPolygon _ (measurable_heightIncrement F hF) _ _ _) + +lemma heightPolygon_formula (F : ℕ → ℝ) (r n T : ℝ) (h : 0 ≤ T*n) (t : unitInterval) : + heightPolygon F r n T t = + (F ⌊T*n*(t:ℝ)⌋₊ + (T*n*(t:ℝ)-⌊T*n*(t:ℝ)⌋₊)* + (F (⌊T*n*(t:ℝ)⌋₊+1)-F ⌊T*n*(t:ℝ)⌋₊))/r := by + have ht : 0 ≤ T*n*(t:ℝ) := mul_nonneg h t.2.1 + have hN : ⌊T*n*(t:ℝ)⌋₊ < ⌊T*n⌋₊+1 := + Nat.lt_succ_of_le (Nat.floor_mono (mul_le_of_le_one_right h t.2.2)) + simp only [heightPolygon,ContinuousMap.add_apply,ContinuousMap.const_apply,scaledPolygon_apply, + linearPolygon_formula _ _ ht hN,realPartialSum_heightIncrement,heightIncrement] + ring + +lemma heightPolygon_grid (F : ℕ → ℝ) (r n T : ℝ) (h : 0 ≤ T*n) + (j : ℕ) (t : unitInterval) (ht : T*n*(t:ℝ) = j) : + heightPolygon F r n T t = F j/r := by + rw [heightPolygon_formula F r n T h,ht] + simp + +lemma realPartialSum_sub (x y : ℕ → ℝ) (j : ℕ) : + realPartialSum (fun k => x k-y k) j = realPartialSum x j-realPartialSum y j := by + simp [realPartialSum,Finset.sum_sub_distrib] + +lemma scaledPolygon_sub (x y : ℕ → ℝ) (r n T : ℝ) : + scaledPolygon (fun k => x k-y k) r n T = scaledPolygon x r n T-scaledPolygon y r n T := by + ext t + simp only [scaledPolygon_apply,ContinuousMap.sub_apply,linearPolygon,mul_sub,Finset.sum_sub_distrib,sub_div] + +lemma heightPolygon_sub (F G : ℕ → ℝ) (r n T : ℝ) : + heightPolygon (fun k => F k-G k) r n T = heightPolygon F r n T-heightPolygon G r n T := by + have he : heightIncrement (fun k => F k-G k) = fun k => heightIncrement F k-heightIncrement G k := by + funext k + simp only [heightIncrement] + ring + ext t + simp only [heightPolygon,he,scaledPolygon_sub,sub_div,ContinuousMap.add_apply, + ContinuousMap.sub_apply,ContinuousMap.const_apply] + ring + +lemma heightPolygon_segment (F : ℕ → ℝ) (r n T : ℝ) (h : 0 ≤ T*n) + (j : ℕ) (t : unitInterval) (hjt : (j:ℝ) ≤ T*n*(t:ℝ)) (htj : T*n*(t:ℝ) ≤ (j:ℝ)+1) : + heightPolygon F r n T t = + (F j+(T*n*(t:ℝ)-j)*(F (j+1)-F j))/r := by + by_cases he : T*n*(t:ℝ) = (j:ℝ)+1 + · rw [heightPolygon_grid F r n T h (j+1) t (by simpa using he),he] + congr 1 + ring + · have hj : ⌊T*n*(t:ℝ)⌋₊ = j := Nat.floor_eq_iff (mul_nonneg h t.2.1) |>.mpr ⟨hjt,lt_of_le_of_ne htj he⟩ + rw [heightPolygon_formula F r n T h,hj] + +lemma heightPolygon_gridLinear (F : ℕ → ℝ) (r n T : ℝ) (h : 0 ≤ T*n) : + GridLinear (T*n) (heightPolygon F r n T) := by + intro j u v t hu hv htu htv + have hjt : (j:ℝ) ≤ T*n*(t:ℝ) := hu ▸ mul_le_mul_of_nonneg_left htu h + have htj : T*n*(t:ℝ) ≤ (j:ℝ)+1 := hv ▸ mul_le_mul_of_nonneg_left htv h + rw [heightPolygon_segment F r n T h j t hjt htj, + heightPolygon_grid F r n T h j u hu, + heightPolygon_grid F r n T h (j+1) v (by simpa using hv)] + ring + +lemma heightPolygon_restrict (F : ℕ → ℝ) (r n T S : ℝ) (hn : 0 ≤ n) + (hT : 0 ≤ T) (hS : 0 ≤ S) (a : unitInterval) (ha : S*(a:ℝ) = T) : + pathRestrictScale a (heightPolygon F r n S) = heightPolygon F r n T := by + ext t + rw [pathRestrictScale_apply,heightPolygon_formula F r n S (mul_nonneg hS hn), + heightPolygon_formula F r n T (mul_nonneg hT hn)] + have he : S*n*((a*t:unitInterval):ℝ) = T*n*(t:ℝ) := by + change S*n*((a:ℝ)*(t:ℝ)) = T*n*(t:ℝ) + rw [← ha] + ring + rw [he] + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygonRandomShiftSmall.lean b/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygonRandomShiftSmall.lean new file mode 100644 index 0000000000000000000000000000000000000000..9640e456cc622924f828e2f7dd33350484c7fd23 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygonRandomShiftSmall.lean @@ -0,0 +1,162 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightPolygonTranslateApply +import OAI.Probability.Ballisticity.Walk.CompactPathModulus + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma heightPolygon_random_shift_small {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : ℕ → ℕ → Ω → ℝ) + (hF : ∀ i k, Measurable (F i k)) (r n : ℕ → ℝ) (hn : Tendsto n atTop atTop) + (H : Ω → ℕ) (hH : Measurable H) (c : ℕ → Ω → ℝ) + (hc : TendstoInMeasure μ (fun i ω => c i ω/r i) atTop 0) + {T : ℝ} (hT : 0 ≤ T) + (ht : IsTightMeasureSet (Set.range (fun i => μ.map + (fun ω => heightPolygon (fun k => F i k ω) (r i) (n i) (T+1))))) : + TendstoInMeasure μ (fun i ω => + heightPolygon (fun k => F i (k+H ω) ω+c i ω) (r i) (n i) T- + heightPolygon (fun k => F i k ω) (r i) (n i) T) atTop 0 := by + have hhn : TendstoInMeasure μ (fun i ω => (H ω:ℝ)/n i) atTop 0 := by + apply tendstoInMeasure_of_tendsto_ae + (fun i => (((measurable_of_countable (fun k : ℕ => (k : ℝ))).comp hH).div_const _).aestronglyMeasurable) + exact ae_of_all _ (fun _ => tendsto_const_nhds.div_atTop hn) + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + simp only [Pi.zero_apply,sub_zero] + apply Metric.tendsto_nhds.2 + intro β hβ + obtain ⟨δ,hδ,hmod⟩ := tight_path_modulus _ ht (by positivity : 0 < ε/4) + (by positivity : 0 < β/4) + have hht := (tendstoInMeasure_iff_measureReal_norm.1 hhn) (min δ 1) (by positivity) + have hct := (tendstoInMeasure_iff_measureReal_norm.1 hc) (ε/4) (by positivity) + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at hht hct + filter_upwards [hn.eventually (eventually_gt_atTop (0:ℝ)), + hht.eventually_lt_const (by positivity : 0 < β/4), + hct.eventually_lt_const (by positivity : 0 < β/4)] with i hni hhi hci + let A := {ω | min δ 1 ≤ |(H ω:ℝ)/n i|} + let B := {ω | heightPolygon (fun k => F i k ω) (r i) (n i) (T+1) ∈ ContinuousOscillation (ε/4) δ} + let C := {ω | ε/4 ≤ |c i ω/r i|} + have hb : μ.real B ≤ β/4 := by + have hm := hmod i + rw [Measure.map_apply (measurable_heightPolygon _ (hF i) _ _ _) + (isOpen_continuousOscillation _ _).measurableSet] at hm + exact ENNReal.toReal_le_of_le_ofReal (by positivity) hm + have hs : {ω | ε ≤ ‖heightPolygon (fun k => F i (k+H ω) ω+c i ω) (r i) (n i) T- + heightPolygon (fun k => F i k ω) (r i) (n i) T‖} ⊆ A ∪ B ∪ C := by + intro ω hω + by_contra hh + have ha : ω ∉ A := fun h => hh (Or.inl (Or.inl h)) + have hb' : ω ∉ B := fun h => hh (Or.inl (Or.inr h)) + have hc' : ω ∉ C := fun h => hh (Or.inr h) + have ha' : (H ω:ℝ)/n i < min δ 1 := by + simpa only [A,Set.mem_ofPred_eq,not_le,abs_of_nonneg + (div_nonneg (Nat.cast_nonneg _) hni.le)] using ha + have hHi : (H ω:ℝ) ≤ n i := ((div_lt_one hni).mp (ha'.trans_le (min_le_right _ _))).le + have hnorm := heightPolygon_translate_norm_le (fun k => F i k ω) (r i) (n i) T + hni hT (H ω) hHi (c i ω) (ε/4) δ (ha'.le.trans (min_le_left _ _)) hb' + have hcc : |c i ω/r i| < ε/4 := lt_of_not_ge hc' + simp only [Set.mem_ofPred_eq] at hω + linarith + have hm := (measureReal_mono (μ := μ) hs (measure_ne_top _ _)).trans + ((measureReal_union_le (μ := μ) (s₁ := A ∪ B) (s₂ := C)).trans + (add_le_add (measureReal_union_le (μ := μ) (s₁ := A) (s₂ := B)) le_rfl)) + rw [Real.dist_eq,sub_zero,abs_of_nonneg measureReal_nonneg] + dsimp only [A,C] at hm + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygonTranslateApply.lean b/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygonTranslateApply.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf84a58fb94e6ac6215f6eebb36792dbed057950 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/HeightPolygonTranslateApply.lean @@ -0,0 +1,148 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightPolygon + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma heightPolygon_translate_apply (F : ℕ → ℝ) (r n T : ℝ) (hn : 0 ≤ n) (hT : 0 ≤ T) + (H : ℕ) (c : ℝ) (t u : unitInterval) + (hu : (T+1)*n*(u:ℝ) = T*n*(t:ℝ)+(H:ℝ)) : + heightPolygon (fun k => F (k+H)+c) r n T t = + heightPolygon F r n (T+1) u+c/r := by + let j := ⌊T*n*(t:ℝ)⌋₊ + have h0 : 0 ≤ T*n*(t:ℝ) := mul_nonneg (mul_nonneg hT hn) t.2.1 + have hj0 : (j:ℝ) ≤ T*n*(t:ℝ) := Nat.floor_le h0 + have hj1 : T*n*(t:ℝ) ≤ (j:ℝ)+1 := (Nat.lt_floor_add_one _).le + rw [heightPolygon_formula _ _ _ _ (mul_nonneg hT hn), + heightPolygon_segment F r n (T+1) (mul_nonneg (by linarith) hn) (j+H) u + (by rw [hu]; push_cast; linarith) + (by rw [hu]; push_cast; linarith),hu] + simp only [Nat.cast_add,Nat.add_assoc,Nat.add_comm 1 H] + dsimp only [j] + ring + +lemma heightPolygon_translate_norm_le (F : ℕ → ℝ) (r n T : ℝ) + (hn : 0 < n) (hT : 0 ≤ T) (H : ℕ) (hH : (H:ℝ) ≤ n) (c ε δ : ℝ) + (hδ : (H:ℝ)/n ≤ δ) + (hmod : heightPolygon F r n (T+1) ∉ ContinuousOscillation ε δ) : + ‖heightPolygon (fun k => F (k+H)+c) r n T-heightPolygon F r n T‖ ≤ ε+|c/r| := by + have hL : 0 < T+1 := by linarith + have hLn : 0 < (T+1)*n := mul_pos hL hn + apply (ContinuousMap.norm_le_of_nonempty _).mpr + intro t + let s : unitInterval := ⟨T/(T+1)*(t:ℝ),mul_nonneg (div_nonneg hT hL.le) t.2.1, + (mul_le_of_le_one_right (div_nonneg hT hL.le) t.2.2).trans + ((div_le_one hL).mpr (by linarith))⟩ + let u : unitInterval := ⟨(T*n*(t:ℝ)+(H:ℝ))/((T+1)*n), + div_nonneg (add_nonneg (mul_nonneg (mul_nonneg hT hn.le) t.2.1) (Nat.cast_nonneg _)) hLn.le, + (div_le_one hLn).mpr (by nlinarith [mul_le_of_le_one_right (mul_nonneg hT hn.le) t.2.2])⟩ + have hs : (T+1)*n*(s:ℝ) = T*n*(t:ℝ) := by dsimp [s]; field_simp + have hu : (T+1)*n*(u:ℝ) = T*n*(t:ℝ)+(H:ℝ) := by dsimp [u]; field_simp + have hdist : dist u s ≤ δ := by + have he : (u:ℝ)-(s:ℝ) = (H:ℝ)/((T+1)*n) := by dsimp [u,s]; field_simp; ring + rw [Subtype.dist_eq,Real.dist_eq,he,abs_of_nonneg (div_nonneg (Nat.cast_nonneg _) hLn.le)] + exact (div_le_div_of_nonneg_left (Nat.cast_nonneg H) hn (by nlinarith)).trans hδ + have hm : |heightPolygon F r n (T+1) u-heightPolygon F r n (T+1) s| ≤ ε := + le_of_not_gt (fun h => hmod ⟨u,s,hdist,h⟩) + have hsval := heightPolygon_translate_apply F r n T hn.le hT 0 0 t s (by simpa using hs) + simp only [add_zero,zero_div] at hsval + simp only [ContinuousMap.sub_apply,Real.norm_eq_abs] + rw [heightPolygon_translate_apply F r n T hn.le hT H c t u hu,hsval] + calc + |heightPolygon F r n (T+1) u+c/r-heightPolygon F r n (T+1) s| + = |(heightPolygon F r n (T+1) u-heightPolygon F r n (T+1) s)+c/r| := by ring_nf + _ ≤ |heightPolygon F r n (T+1) u-heightPolygon F r n (T+1) s|+|c/r| := abs_add_le _ _ + _ ≤ ε+|c/r| := by gcongr + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/HeightSlab.lean b/lean/OAI/Probability/Ballisticity/Geometry/HeightSlab.lean new file mode 100644 index 0000000000000000000000000000000000000000..07114cfe3b934371c8cca69f1b7a39a7c918df90 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/HeightSlab.lean @@ -0,0 +1,418 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ClippedInverse + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma convexOn_rpow_nonpos_Ici {δ p : ℝ} (hδ : 0 < δ) (hp : p ≤ 0) : + ConvexOn ℝ (Set.Ici δ) (fun x : ℝ => x ^ p) := by + refine ⟨convex_Ici δ, ?_⟩ + intro x hx y hy a b ha hb hab + have hx0 := hδ.trans_le hx + have hy0 := hδ.trans_le hy + have hz : 0 < a • x + b • y := + hδ.trans_le ((convex_Ici δ) hx hy ha hb hab) + have hl := (StrictConcaveOn.concaveOn strictConcaveOn_log_Ioi).2 hx0 hy0 ha hb hab + have he := convexOn_exp.2 (Set.mem_univ (p * Real.log x)) + (Set.mem_univ (p * Real.log y)) ha hb hab + simp only [smul_eq_mul] at hl he hz ⊢ + rw [Real.rpow_def_of_pos hz, Real.rpow_def_of_pos hx0, Real.rpow_def_of_pos hy0] + calc + Real.exp (Real.log (a * x + b * y) * p) ≤ + Real.exp (a * (p * Real.log x) + b * (p * Real.log y)) := by + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonpos_right hl hp] + _ ≤ a * Real.exp (Real.log x * p) + b * Real.exp (Real.log y * p) := by + simpa only [mul_comm p] using he + +lemma inverse_jensen_bounded {α : Type*} [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] {f : α → ℝ} (hf : Measurable f) + {δ B lam : ℝ} (hδ : 0 < δ) (hlam : 0 ≤ lam) (hb : ∀ x, δ ≤ f x ∧ f x ≤ B) : + (∫ x, f x ∂μ) ^ (-lam) ≤ ∫ x, (f x) ^ (-lam) ∂μ := by + have hi : Integrable f μ := + (MemLp.of_bound (p := 1) hf.aestronglyMeasurable B + (Filter.Eventually.of_forall fun x => by + simpa only [Real.norm_eq_abs, abs_of_nonneg (hδ.le.trans (hb x).1)] using + (hb x).2)).integrable le_rfl + have hj : Integrable (fun x => (f x) ^ (-lam)) μ := + (MemLp.of_bound (p := 1) (hf.pow_const _).aestronglyMeasurable (δ ^ (-lam)) + (Filter.Eventually.of_forall fun x => by + rw [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg (hδ.le.trans (hb x).1) _)] + exact Real.rpow_le_rpow_of_nonpos hδ (hb x).1 (neg_nonpos.mpr hlam))).integrable le_rfl + exact (convexOn_rpow_nonpos_Ici hδ (neg_nonpos.mpr hlam)).map_integral_le + (continuousOn_id.rpow_const (fun x hx => Or.inl (ne_of_gt (hδ.trans_le hx)))) + isClosed_Ici (Filter.Eventually.of_forall fun x => (hb x).1) hi hj + +lemma inverse_mixture_markov {Ω A : Type*} [MeasurableSpace Ω] [MeasurableSpace A] + (μ : Measure Ω) (π : Measure A) [IsProbabilityMeasure μ] [IsProbabilityMeasure π] + (F : Ω → A → ℝ) (hF : Measurable (Function.uncurry F)) (Q : Ω → ℝ) + {δ₀ δ lam s K : ℝ} (hδ₀ : 0 < δ₀) (hlam : 0 ≤ lam) (hs : 0 < s) (hδs : δ ≤ s) + (hb : ∀ ω a, δ₀ ≤ F ω a ∧ F ω a ≤ 1) + (hQ : ∀ ω, (∫ a, F ω a ∂π) ≤ Q ω + δ) + (hE : (∫ ω, ∫ a, (F ω a) ^ (-lam) ∂π ∂μ) ≤ K) : + μ {ω | Q ω < 2 * s} ≤ ENNReal.ofReal ((3 * s) ^ lam * K) := by + have hGi : Integrable (fun z : Ω × A => F z.1 z.2 ^ (-lam)) (μ.prod π) := + (MemLp.of_bound (p := 1) (hF.pow_const _).aestronglyMeasurable (δ₀ ^ (-lam)) + (Filter.Eventually.of_forall fun z => by + change ‖F z.1 z.2 ^ (-lam)‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg (hδ₀.le.trans (hb z.1 z.2).1) _)] + exact Real.rpow_le_rpow_of_nonpos hδ₀ (hb z.1 z.2).1 + (neg_nonpos.mpr hlam))).integrable le_rfl + have hJi ω : Integrable (F ω) π := + (MemLp.of_bound (p := 1) (hF.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable 1 + (Filter.Eventually.of_forall fun a => by + change ‖F ω a‖ ≤ 1 + rw [Real.norm_eq_abs, abs_of_nonneg (hδ₀.le.trans (hb ω a).1)] + exact (hb ω a).2)).integrable le_rfl + have hJpos ω : 0 < ∫ a, F ω a ∂π := by + have hl := integral_mono (integrable_const δ₀) (hJi ω) (fun a => (hb ω a).1) + have hl' : δ₀ ≤ ∫ a, F ω a ∂π := by simpa using hl + exact hδ₀.trans_le hl' + have hp : 0 < 3 * s := mul_pos (by norm_num) hs + have hMeas := (hGi.integral_prod_left.const_mul ((3 * s) ^ lam)).measure_le_integral + (Filter.Eventually.of_forall fun ω => mul_nonneg (Real.rpow_nonneg hp.le _) + (integral_nonneg (fun a => Real.rpow_nonneg (hδ₀.le.trans (hb ω a).1) _))) + (s := {ω | Q ω < 2 * s}) (fun ω hω => by + have hJle : (∫ a, F ω a ∂π) ≤ 3 * s := by + change Q ω < 2 * s at hω + linarith [hQ ω] + have hj := inverse_jensen_bounded π + (hF.comp (measurable_const.prodMk measurable_id)) hδ₀ hlam (hb ω) + have hr := Real.rpow_le_rpow_of_nonpos (hJpos ω) hJle (neg_nonpos.mpr hlam) + calc + 1 = (3 * s) ^ lam * (3 * s) ^ (-lam) := by + rw [← Real.rpow_add hp, add_neg_cancel, Real.rpow_zero] + _ ≤ (3 * s) ^ lam * ∫ a, F ω a ^ (-lam) ∂π := + mul_le_mul_of_nonneg_left (hr.trans hj) (Real.rpow_nonneg hp.le _)) + rw [integral_const_mul] at hMeas + exact hMeas.trans (ENNReal.ofReal_le_ofReal + (mul_le_mul_of_nonneg_left hE (Real.rpow_nonneg hp.le _))) + +theorem separated_initial_inverse_moment {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (ℓ : Vector d) + (hℓ : dot ℓ ℓ = 1) (htrans : DirectionallyTransient ν ℓ) (e : Fin d) : + ∃ lam C : ℝ, 0 < lam ∧ lam ≤ 1 ∧ 0 < C ∧ + ∀ Bstar : ℝ, 0 < Bstar → ∀ k : ℕ, 1 ≤ k → ∃ G : ℕ, + ∀ (π : Measure (Fin k → Lattice d)) [IsProbabilityMeasure π], + (∀ᵐ x ∂π, Pairwise fun i j => (G : ℤ) ≤ |x i e - x j e|) → + ∀ s : ℝ, Real.exp (-Bstar) ≤ s → + (environmentLaw ν) {ω | (∫ x, noDropProduct ℓ x ω ∂π) < 2 * s} ≤ + ENNReal.ofReal (Real.exp (C * k) * s ^ lam) := by + classical + obtain ⟨lam, hlam, hlam1, hmom⟩ := noDrop_real_inverse_moment ν hue ℓ hℓ htrans + let M := max 1 (∫ ω, (noDropQuenched ℓ 0 ω).toReal ^ (-lam) ∂environmentLaw ν) + have hM : 1 ≤ M := le_max_left _ _ + have hM0 : 0 ≤ M := zero_le_one.trans hM + let C := Real.log (6 * M) + have hC : 0 < C := Real.log_pos (by linarith) + refine ⟨lam, C, hlam, hlam1, hC, ?_⟩ + intro Bstar hBstar k hk + let δ := Real.exp (-Bstar) + have hδ : 0 < δ := Real.exp_pos _ + have hδ1 : δ ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr hBstar.le) + have hpos : ∀ᵐ ω ∂environmentLaw ν, 0 < noDropQuenched ℓ 0 ω := by + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans] with ω hω + exact hω 0 + obtain ⟨n, hn⟩ := separated_noDropProduct_inverse_bound ν ℓ hδ hlam.le hpos hmom k + refine ⟨2 * n + 1, ?_⟩ + intro π hπ hsep s hs + have hs0 : 0 < s := hδ.trans_le hs + let F : Environment d → (Fin k → Lattice d) → ℝ := fun ω x => clippedNoDropProduct ℓ δ x ω + have hF : Measurable (Function.uncurry F) := clippedNoDropProduct_measurable ℓ δ + have hb ω x : δ ^ k ≤ F ω x ∧ F ω x ≤ 1 := + clippedNoDropProduct_bounds ℓ hδ.le hδ1 x ω + have hGi : Integrable (fun z : Environment d × (Fin k → Lattice d) => + F z.1 z.2 ^ (-lam)) ((environmentLaw ν).prod π) := by + apply integrable_of_nonneg_bound _ (hF.pow_const _) + intro z + exact ⟨Real.rpow_nonneg ((pow_pos hδ k).le.trans (hb z.1 z.2).1) _, + Real.rpow_le_rpow_of_nonpos (pow_pos hδ k) (hb z.1 z.2).1 (neg_nonpos.mpr hlam.le)⟩ + have hE : (∫ ω, ∫ x, F ω x ^ (-lam) ∂π ∂environmentLaw ν) ≤ 2 * M ^ k := by + rw [integral_integral_swap hGi] + have hh := integral_mono_ae hGi.integral_prod_right (integrable_const (2 * M ^ k)) + (hsep.mono fun x hx => hn x (fun i j hij => latticeBall_disjoint_of_coordinate_gap e + (by have h := hx hij; omega))) + simpa using hh + have hQ ω : (∫ x, F ω x ∂π) ≤ (∫ x, noDropProduct ℓ x ω ∂π) + δ := by + have hI : Integrable (noDropProduct ℓ · ω) π := + integrable_of_nonneg_bound π (measurable_of_countable _) (fun x => noDropProduct_bounds ℓ x ω) + have hJ : Integrable (F ω) π := + integrable_of_nonneg_bound π (measurable_of_countable _) (fun x => + ⟨(pow_pos hδ k).le.trans (hb ω x).1, (hb ω x).2⟩) + calc + (∫ x, F ω x ∂π) ≤ ∫ x, noDropProduct ℓ x ω + δ ∂π := + integral_mono hJ (hI.add (integrable_const δ)) (clippedNoDropProduct_error ℓ hδ.le hδ1 · ω) + _ = (∫ x, noDropProduct ℓ x ω ∂π) + δ := by simp [integral_add hI (integrable_const δ)] + have hmark := inverse_mixture_markov (environmentLaw ν) π F hF + (fun ω => ∫ x, noDropProduct ℓ x ω ∂π) (pow_pos hδ k) hlam.le hs0 hs hb hQ hE + apply hmark.trans (ENNReal.ofReal_le_ofReal ?_) + have h3 : (3 : ℝ) ^ lam ≤ 3 := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 3 by norm_num) hlam1 + have h6 : (6 : ℝ) ≤ 6 ^ k := by + have h := pow_le_pow_right₀ (show (1 : ℝ) ≤ 6 by norm_num) hk + simpa only [pow_one] using h + have hexp : Real.exp (C * k) = (6 * M) ^ k := by + rw [mul_comm, Real.exp_nat_mul, Real.exp_log (by positivity : 0 < 6 * M)] + rw [hexp, Real.mul_rpow (by norm_num : (0 : ℝ) ≤ 3) hs0.le, mul_pow] + have hsp : 0 ≤ s ^ lam := Real.rpow_nonneg hs0.le _ + calc + 3 ^ lam * s ^ lam * (2 * M ^ k) ≤ 6 * M ^ k * s ^ lam := by + nlinarith [mul_le_mul_of_nonneg_right h3 (mul_nonneg hsp (pow_nonneg hM0 k))] + _ ≤ 6 ^ k * M ^ k * s ^ lam := by gcongr + +lemma hitKernel_apply_eq_hit {d : ℕ} {S T : Set (Lattice d)} + (hST : Disjoint S T) (U : Set (Lattice d)) (z : State d) : + hitKernel S T z U = quenchedKernel z (Hit S (T ∩ U)) := by + rw [hitKernel_apply] + exact (measure_iUnion (hitAt_pairwise_disjoint (hST.mono_right Set.inter_subset_left)) + (measurableSet_hitAt S (T ∩ U))).symm + +lemma hit_concatenation {d : ℕ} {S₁ T₁ S₂ T₂ S : Set (Lattice d)} + (h₁ : S₁ ⊆ S) (h₂ : S₂ ⊆ S) : + (⋃ n, HitAt S₁ T₁ n ∩ FutureEvent (fun _ => Hit S₂ T₂) n) ⊆ Hit S T₂ := by + rintro X hX + obtain ⟨n, hn, hfuture⟩ := Set.mem_iUnion.mp hX + obtain ⟨m, hm⟩ := Set.mem_iUnion.mp hfuture + apply Set.mem_iUnion.mpr + refine ⟨n + m, hm.1, ?_⟩ + intro j hj + by_cases hjn : j < n + · exact h₁ (hn.2 j hjn) + · have hn : n ≤ j := by omega + have hsub : j - n < m := by omega + have := h₂ (hm.2 (j - n) hsub) + simpa only [Nat.add_sub_of_le hn] using this + +lemma hitKernel_comp_le {d : ℕ} (ω : Environment d) (x : Lattice d) + {S₁ T₁ S₂ T₂ S : Set (Lattice d)} + (hST₁ : Disjoint S₁ T₁) (hST₂ : Disjoint S₂ T₂) (hST : Disjoint S T₂) + (h₁ : S₁ ⊆ S) (h₂ : S₂ ⊆ S) (U : Set (Lattice d)) : + (∫⁻ y, hitKernel S₂ T₂ (ω, y) U ∂hitKernel S₁ T₁ (ω, x)) ≤ + hitKernel S T₂ (ω, x) U := by + simp_rw [hitKernel_apply_eq_hit hST₂ U] + rw [hitKernel_future ω x hST₁ (fun _ => Hit S₂ (T₂ ∩ U)) + (fun _ => measurableSet_hit _ _), hitKernel_apply_eq_hit hST U] + exact measure_mono (hit_concatenation h₁ h₂) + +def HeightSlab {d : ℕ} (i : Fin d) (a b : ℤ) : Set (Lattice d) := + {x | a ≤ x i ∧ x i < b} + +def HeightLayer {d : ℕ} (i : Fin d) (b : ℤ) : Set (Lattice d) := + {x | x i = b} + +lemma heightSlab_disjoint_layer {d : ℕ} (i : Fin d) (a b : ℤ) : + Disjoint (HeightSlab i a b) (HeightLayer i b) := by + apply Set.disjoint_left.mpr + intro x hx hy + exact (ne_of_lt hx.2) hy + +noncomputable def heightKernel {d : ℕ} (i : Fin d) (a b : ℤ) : + Kernel (State d) (Lattice d) := + hitKernel (HeightSlab i a b) (HeightLayer i b) + +lemma heightKernel_total_le_one {d : ℕ} (i : Fin d) (a b : ℤ) (z : State d) : + heightKernel i a b z Set.univ ≤ 1 := + hitKernel_total_le_one (heightSlab_disjoint_layer i a b) z + +instance heightKernel_finite {d : ℕ} (i : Fin d) (a b : ℤ) : + IsFiniteKernel (heightKernel i a b) where + exists_univ_le := ⟨1, ENNReal.one_lt_top, heightKernel_total_le_one i a b⟩ + +lemma heightKernel_supported {d : ℕ} (i : Fin d) (a b : ℤ) (z : State d) : + ∀ᵐ y ∂heightKernel i a b z, y i = b := by + rw [ae_iff] + change hitKernel (HeightSlab i a b) (HeightLayer i b) z (HeightLayer i b)ᶜ = 0 + rw [hitKernel_apply_eq_hit (heightSlab_disjoint_layer i a b), Set.inter_compl_self] + have he : Hit (HeightSlab i a b) ∅ = ∅ := by + ext X + simp [Hit, HitAt] + rw [he, measure_empty] + +lemma heightKernel_rows {d : ℕ} (i : Fin d) {a b : ℤ} (hab : a < b) + (x : Lattice d) (hx : x i = a) : + @Measurable _ _ (rowSigma (HeightSlab i a b)) _ + (fun ω : Environment d => heightKernel i a b (ω, x)) := by + exact measurable_hitKernel_rows _ _ x ⟨by simpa only [hx] using (le_refl a), by simpa only [hx]⟩ + +lemma heightKernel_comp_le {d : ℕ} (i : Fin d) {a b c : ℤ} + (hab : a ≤ b) (hbc : b ≤ c) (ω : Environment d) (x : Lattice d) + (U : Set (Lattice d)) : + (∫⁻ y, heightKernel i b c (ω, y) U ∂heightKernel i a b (ω, x)) ≤ + heightKernel i a c (ω, x) U := by + exact hitKernel_comp_le ω x (heightSlab_disjoint_layer i a b) + (heightSlab_disjoint_layer i b c) (heightSlab_disjoint_layer i a c) + (fun _ h => ⟨h.1, h.2.trans_le hbc⟩) + (fun _ h => ⟨hab.trans h.1, h.2⟩) U + +noncomputable def normalizedMeasure {α : Type*} [MeasurableSpace α] + (μ : Measure α) : Measure α := (μ Set.univ)⁻¹ • μ + +lemma normalizedMeasure_probability {α : Type*} [MeasurableSpace α] + (μ : Measure α) [IsFiniteMeasure μ] (hμ : μ Set.univ ≠ 0) : + IsProbabilityMeasure (normalizedMeasure μ) := by + constructor + simp only [normalizedMeasure, Measure.smul_apply, smul_eq_mul] + exact ENNReal.inv_mul_cancel hμ (measure_ne_top μ Set.univ) + +lemma mass_smul_normalizedMeasure {α : Type*} [MeasurableSpace α] + (μ : Measure α) [IsFiniteMeasure μ] : + μ Set.univ • normalizedMeasure μ = μ := by + by_cases hμ : μ Set.univ = 0 + · have hzero : μ = 0 := Measure.measure_univ_eq_zero.mp hμ + simp [hzero, normalizedMeasure] + · rw [normalizedMeasure, smul_smul, + ENNReal.mul_inv_cancel hμ (measure_ne_top μ Set.univ), one_smul] + +lemma integral_normalized_comp {α : Type*} [MeasurableSpace α] + (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) : + μ Set.univ * (∫⁻ x, f x ∂normalizedMeasure μ) = ∫⁻ x, f x ∂μ := by + change μ Set.univ • (∫⁻ x, f x ∂normalizedMeasure μ) = _ + rw [← lintegral_smul_measure, mass_smul_normalizedMeasure] + +lemma retained_kernel_comp_le {d : ℕ} (i : Fin d) {a b c : ℤ} + (hab : a ≤ b) (hbc : b ≤ c) (ω : Environment d) (x : Lattice d) + (ρ : Measure (Lattice d)) (hρ : ρ ≤ heightKernel i a b (ω, x)) + (U : Set (Lattice d)) : + ρ Set.univ * (∫⁻ y, heightKernel i b c (ω, y) U ∂normalizedMeasure ρ) ≤ + heightKernel i a c (ω, x) U := by + have : IsFiniteMeasure ρ := ⟨lt_of_le_of_lt (hρ Set.univ) + (measure_lt_top (heightKernel i a b (ω, x)) Set.univ)⟩ + rw [integral_normalized_comp] + exact (lintegral_mono' hρ le_rfl).trans (heightKernel_comp_le i hab hbc ω x U) + +lemma pathCylinder_weight_locality {d : ℕ} (S : Set (Lattice d)) + (ω η : Environment d) (hωη : Set.EqOn ω η S) (x : Lattice d) + (f : Path d) (n : ℕ) (hf : ∀ j < n, f j ∈ S) : + quenchedKernel (ω, x) (pathCylinder f n) = + quenchedKernel (η, x) (pathCylinder f n) := by + by_cases hfx : f 0 = x + · rw [quenched_pathCylinder ω x f hfx, quenched_pathCylinder η x f hfx] + exact Finset.prod_congr rfl fun j hj => by + simp only [edgeWeight, hωη (hf j (Finset.mem_range.mp hj))] + · rw [quenched_pathCylinder_zero ω x f hfx, quenched_pathCylinder_zero η x f hfx] + +lemma quenched_restrict_stay_congr {d : ℕ} (S : Set (Lattice d)) + (ω η : Environment d) (hωη : Set.EqOn ω η S) (x : Lattice d) : + (quenchedKernel (ω, x)).restrict (Stay S) = + (quenchedKernel (η, x)).restrict (Stay S) := by + apply pathMeasure_ext + intro f n + rw [Measure.restrict_apply (measurableSet_pathCylinder f n), + Measure.restrict_apply (measurableSet_pathCylinder f n)] + by_cases hf : ∀ j ≤ n, f j ∈ S + · have he : pathCylinder f n ∩ Stay S = + (fun X : Path d => fun j => X (n + j)) ⁻¹' Stay S ∩ pathCylinder f n := by + ext X + constructor + · rintro ⟨hX, hS⟩ + exact ⟨fun j => hS (n + j), hX⟩ + · rintro ⟨hS, hX⟩ + refine ⟨hX, fun j => ?_⟩ + by_cases hj : j ≤ n + · simpa only [hX j hj] using hf j hj + · have hnj : n ≤ j := by omega + simpa only [Nat.add_sub_of_le hnj] using hS (j - n) + rw [he] + by_cases hfx : f 0 = x + · rw [quenched_prefix_future ω x f hfx n (measurableSet_stay S), + quenched_prefix_future η x f hfx n (measurableSet_stay S), + pathCylinder_weight_locality S ω η hωη x f n (fun j hj => hf j hj.le), + quenched_stay_congr S ω η hωη (f n)] + · rw [measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero ω x f hfx n), + measure_mono_null Set.inter_subset_right (quenched_pathCylinder_zero η x f hfx n)] + · have he : pathCylinder f n ∩ Stay S = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro X ⟨hX, hS⟩ + exact hf fun j hj => by simpa only [← hX j hj] using hS j + rw [he] + simp + +lemma quenched_stay_event_congr {d : ℕ} (A : Set (Path d)) + (T : Set (Lattice d)) (hA : MeasurableSet A) (hAT : A ⊆ Stay T) + (ω η : Environment d) (hωη : Set.EqOn ω η T) (x : Lattice d) : + quenchedKernel (ω, x) A = quenchedKernel (η, x) A := by + have := congrArg (fun μ : Measure (Path d) => μ A) + (quenched_restrict_stay_congr T ω η hωη x) + simpa only [Measure.restrict_apply hA, Set.inter_eq_left.mpr hAT] using this + +lemma measurable_quenched_stay_event_rows {d : ℕ} (T : Set (Lattice d)) + (x : Lattice d) (hx : x ∈ T) (A : Set (Path d)) + (hA : MeasurableSet A) (hAT : A ⊆ Stay T) : + @Measurable _ _ (rowSigma T) _ (fun ω : Environment d => quenchedKernel (ω, x) A) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ hA).comp (measurable_id.prodMk measurable_const)) T x hx + intro ω η h + exact quenched_stay_event_congr A T hA hAT ω η h x + +lemma annealed_event_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x : Lattice d) (A : Set (Path d)) (hA : MeasurableSet A) : + (∫⁻ ω, quenchedKernel (ω, x) ((fun X : Path d => fun n => X n - x) ⁻¹' A) + ∂environmentLaw ν) = annealedLaw ν A := by + have ht : Measurable (fun X : Path d => fun n => X n - x) := by fun_prop + have he (ω : Environment d) : + quenchedKernel (ω, x) ((fun X : Path d => fun n => X n - x) ⁻¹' A) = + quenchedKernel ((fun a => ω (x + a)), 0) A := by + have := congrArg (fun μ : Measure (Path d) => μ A) (quenched_translation ω x 0) + rw [Measure.map_apply ht hA] at this + simpa only [add_zero] using this + simp_rw [he] + have hm : Measurable (fun ω : Environment d => quenchedKernel (ω, 0) A) := + (Kernel.measurable_coe _ hA).comp (measurable_id.prodMk measurable_const) + rw [← lintegral_map hm (show Measurable (fun ω : Environment d => fun a => ω (x + a)) by + fun_prop), environment_translation, ← annealed_apply ν hA] + +lemma annealed_record_suffix {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (w : List (Direction d)) + (hrecord : ∀ y ∈ wordDepartures 0 w, + dot (realPosition y) ℓ < dot (realPosition (wordPath 0 w w.length)) ℓ) + (A : Set (Path d)) (hA : MeasurableSet A) (hAD : A ⊆ NoDrop ℓ 0) : + annealedLaw ν ((fun X : Path d => fun j => X (w.length + j) - + wordPath 0 w w.length) ⁻¹' A ∩ wordCylinder 0 w) = + annealedLaw ν (wordCylinder 0 w) * annealedLaw ν A := by + let y := wordPath 0 w w.length + let S : Set (Lattice d) := ↑(wordDepartures 0 w) + let T : Set (Lattice d) := {z | dot (realPosition y) ℓ ≤ dot (realPosition z) ℓ} + let B : Set (Path d) := (fun X : Path d => fun j => X j - y) ⁻¹' A + have hB : MeasurableSet B := hA.preimage (by fun_prop) + have hBT : B ⊆ Stay T := by + intro X hX j + have h := hAD hX j + change dot (realPosition y) ℓ ≤ dot (realPosition (X j)) ℓ + change dot (realPosition 0) ℓ ≤ dot (realPosition (X j - y)) ℓ at h + rw [dot_realPosition_sub] at h + have hzero : dot (realPosition (0 : Lattice d)) ℓ = 0 := by simp [dot, realPosition] + rw [hzero] at h + linarith + have hST : Disjoint S T := by + apply Set.disjoint_left.mpr + intro z hz hz' + exact (not_le_of_gt (hrecord z hz)) hz' + have hw (ω : Environment d) : quenchedKernel (ω, 0) + ((fun X : Path d => fun j => X (w.length + j) - y) ⁻¹' A ∩ wordCylinder 0 w) = + ENNReal.ofReal (wordWeight ω 0 w) * quenchedKernel (ω, y) B := by + have hh := quenched_prefix_future ω 0 (wordPath 0 w) (by simp) w.length hB + change quenchedKernel (ω, 0) (_ ∩ wordCylinder 0 w) = + quenchedKernel (ω, 0) (wordCylinder 0 w) * quenchedKernel (ω, y) B at hh + rwa [quenched_wordCylinder] at hh + rw [annealed_apply ν ((hA.preimage (by fun_prop)).inter (measurableSet_wordCylinder 0 w))] + change (∫⁻ ω, quenchedKernel (ω, 0) + ((fun X : Path d => fun j => X (w.length + j) - y) ⁻¹' A ∩ wordCylinder 0 w) + ∂environmentLaw ν) = _ + simp_rw [hw] + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hST) + ((measurable_wordWeight_on 0 w (fun _ hz => hz)).ennreal_ofReal) + (measurable_quenched_stay_event_rows T y + (show dot (realPosition y) ℓ ≤ dot (realPosition y) ℓ from le_rfl) B hB hBT)] + rw [← annealed_wordCylinder, annealed_event_translation ν y A hA] + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/HeightTubeWindow.lean b/lean/OAI/Probability/Ballisticity/Geometry/HeightTubeWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3d7faf68eed0bb96f07a18075f1222fa2a3b0cd --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/HeightTubeWindow.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GridOccupation + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BoundedContinuousFunction +namespace DirectionalTransience + +def heightTubeEndpointEvent (Y : ℕ → ℝ) (H : ℕ) (L R : ℝ) : Prop := + (∀ j ≤ H, |Y j| ≤ L) ∧ |Y H| ≤ R + +lemma measurableSet_heightTubeEndpointEvent {Ω : Type*} [MeasurableSpace Ω] + (Y : ℕ → Ω → ℝ) (hY : ∀ j, Measurable (Y j)) (H : ℕ) (L R : ℝ) : + MeasurableSet {x | heightTubeEndpointEvent (fun j => Y j x) H L R} := by + change MeasurableSet ({x | ∀ j ≤ H, |Y j x| ≤ L} ∩ {x | |Y H x| ≤ R}) + apply MeasurableSet.inter + · simp only [Set.ofPred_forall] + exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + measurableSet_le (hY j).abs measurable_const + · exact measurableSet_le (hY H).abs measurable_const + +lemma heightPolygon_window_implies_tube (Y : ℕ → ℝ) (r n : ℝ) (hr : 0 < r) (hn : 0 < n) + (B L ρ δ : ℝ) (hBL : B ≤ L) (τ : unitInterval) + (hg : ‖heightPolygon Y r n 2‖ < B) + (he : ∀ t : unitInterval, dist t τ ≤ δ → |heightPolygon Y r n 2 t| < ρ) + (ht : dist (layerGridPoint (2*n) ⌊n⌋₊) τ ≤ δ) : + heightTubeEndpointEvent Y ⌊n⌋₊ (L*r) (ρ*r) := by + have h2n : 0 < 2*n := by positivity + have hj (j : ℕ) (h : j ≤ ⌊n⌋₊) : (j:ℝ) ≤ 2*n := by + have h' := (Nat.cast_le (α := ℝ)).mpr h + have hfloor := Nat.floor_le hn.le + linarith + have heval (j : ℕ) (h : j ≤ ⌊n⌋₊) : heightPolygon Y r n 2 (layerGridPoint (2*n) j)=Y j/r := by + apply heightPolygon_grid _ _ _ _ h2n.le + rw [layerGridPoint_coe h2n (hj j h),mul_div_cancel₀ _ h2n.ne'] + constructor + · intro j h + have hh := (heightPolygon Y r n 2).norm_coe_le_norm (layerGridPoint (2*n) j) + rw [heval j h,Real.norm_eq_abs,abs_div,abs_of_pos hr] at hh + exact ((div_le_iff₀ hr).mp (hh.trans (hg.le.trans hBL))) + · have hh := he _ ht + rw [heval ⌊n⌋₊ le_rfl,abs_div,abs_of_pos hr] at hh + exact ((div_lt_iff₀ hr).mp hh).le + +lemma half_layer_grid_tendsto (n : ℕ → ℝ) (hn : Tendsto n atTop atTop) : + Tendsto (fun i => layerGridPoint (2*n i) ⌊n i⌋₊) atTop + (𝓝 (⟨(1:ℝ)/2,by norm_num,by norm_num⟩ : unitInterval)) := by + apply layerGridPoint_tendsto + have hh := ((tendsto_nat_floor_mul_div_atTop (by norm_num : (0:ℝ)≤1)).comp hn).div_const 2 + convert hh using 1 + simp only [one_mul,Function.comp_def] + funext i + ring + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/JointTubeSuccess.lean b/lean/OAI/Probability/Ballisticity/Geometry/JointTubeSuccess.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4367ab4ed66e4a415287a3d37c8e7bd7a7b99e2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/JointTubeSuccess.lean @@ -0,0 +1,345 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.TubePrefixMonoRadius + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def JointTubeSuccess {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (b : ℕ → ℝ) (H : ℕ) (z : ℝ) : Set (Path d) := + Hit (Strip ℓ x H) (Upper ℓ x H) ∩ + {X | (fun n => X n-x) ∉ MedianTubeFailure ℓ f b H z ∧ + (fun n => X n-x) ∉ MedianTubeFailure ℓ f (fun j => (j:ℝ)*b H/H) H z} + +noncomputable def jointTubeMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (H : ℕ) (z : ℝ) (π : Measure (Lattice d)) (ω : Environment d) : ℝ≥0∞ := + ∫⁻ x, (quenchedKernel (ω,x)) (JointTubeSuccess ℓ f x b H z) ∂π + +lemma jointTubeMass_ne_top {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (H : ℕ) (z : ℝ) (π : Measure (Lattice d)) [IsFiniteMeasure π] (ω : Environment d) : + jointTubeMass ℓ f b H z π ω ≠ ⊤ := by + apply ne_top_of_le_ne_top (measure_ne_top π Set.univ) + calc + _ ≤ ∫⁻ _x, (1:ℝ≥0∞) ∂π := lintegral_mono fun _ => prob_le_one + _ = π Set.univ := by simp + +lemma tubePrefix_subset_jointTubeSuccess {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (b : ℕ → ℝ) (H : ℕ) (z a R : ℝ) + (hdet : ∀ j ≤ H, |b j-(j:ℝ)*b H/H| ≤ a) (hz : z ≤ R) (hza : z+a ≤ R) : + TubePrefix ℓ f x (b H/H) z H ⊆ JointTubeSuccess ℓ f x b H R := by + rintro X hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + refine ⟨Set.mem_iUnion.mpr ⟨n,hn.1⟩,?_,?_⟩ + · rintro ⟨j,hj,hbad⟩ + obtain ⟨k,hk,hr,hgood⟩ := hn.2 j hj + have he : recordIndexPosition ℓ j (fun m => X m-x) = X k-x := by + simp only [recordIndexPosition,recordOrZeroPrefix_time ℓ hr] + rw [he] at hbad + have hh : |signedCoordinate f (X k-x)-b j| ≤ R := by + calc + _ ≤ |signedCoordinate f (X k-x)-(j:ℝ)*b H/H|+|(j:ℝ)*b H/H-b j| := abs_sub_le _ _ _ + _ ≤ z+a := add_le_add (by simpa only [mul_div_assoc] using hgood) + (by simpa only [abs_sub_comm] using hdet j hj) + _ ≤ R := hza + exact (not_lt_of_ge hh) hbad + · rintro ⟨j,hj,hbad⟩ + obtain ⟨k,hk,hr,hgood⟩ := hn.2 j hj + have he : recordIndexPosition ℓ j (fun m => X m-x) = X k-x := by + simp only [recordIndexPosition,recordOrZeroPrefix_time ℓ hr] + rw [he] at hbad + have hh : |signedCoordinate f (X k-x)-(j:ℝ)*b H/H| ≤ R := + (by simpa only [mul_div_assoc] using hgood.trans hz) + exact (not_lt_of_ge hh) hbad + +theorem short_block_survival {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {v : ℝ} (hv : 0 < v) : + ∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℝ, 0 < t₀ ∧ ∀ t : ℝ, 0 < t → t ≤ t₀ → + ∃ δ : ℝ, 0 < δ ∧ ∃ R : ℝ, 0 < R ∧ + ∀ r : ℝ, R ≤ r → ∀ H : ℕ, 0 < H → + (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + ∀ (a : ℤ) (π : Measure (Lattice d)), IsProbabilityMeasure π → + (∀ᵐ x ∂π, signedHeight e x = a) → + (environmentLaw ν).real {ω | (jointTubeMass ℓ f + (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (v*r) π ω).toReal < δ} ≤ C*t^2 := by + let w := min (v/8) 1 + have hw : 0 < w := lt_min (by positivity) zero_lt_one + have hw20 : w ≤ 20 := (min_le_right _ _).trans (by norm_num) + obtain ⟨C,hC,t₁,ht₁,hsurv⟩ := short_block_slope_survival ν hue e f hef htrans hw hw20 + obtain ⟨D,hD,t₂,ht₂,hmedian⟩ := recordMedian_shortBlock ν hue e f hef htrans + let t₀ := min t₁ (min t₂ ((w/(2*D))^2)) + have ht₀ : 0 < t₀ := lt_min ht₁ (lt_min ht₂ (sq_pos_of_pos (by positivity))) + refine ⟨C,hC,t₀,ht₀,?_⟩ + intro t ht htt + obtain ⟨δ,hδ,R,hR,hsurv⟩ := hsurv t ht (htt.trans (min_le_left _ _)) + refine ⟨δ,hδ,R,hR,?_⟩ + intro r hr H hH hscale + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let b := fun j => (recordMedian ν ℓ hp f j:ℝ) + have hr0 : 0 < r := hR.trans_le hr + have hmid := hmedian t ht ((htt.trans (min_le_right _ _)).trans (min_le_left _ _)) r hr0 H hH hscale + have hroot : Real.sqrt t ≤ w/(2*D) := (Real.sqrt_le_iff).mpr + ⟨by positivity,(htt.trans (min_le_right _ _)).trans (min_le_right _ _)⟩ + have hcoef : D*Real.sqrt t ≤ w/2 := by + have hh := mul_le_mul_of_nonneg_left hroot hD.le + have he : D*(w/(2*D))=w/2 := by field_simp + linarith + have hdet (j : ℕ) (hj : j ≤ H) : |b j-(j:ℝ)*b H/H| ≤ w*r/2 := by + exact (hmid j hj).trans (by nlinarith [mul_le_mul_of_nonneg_right hcoef hr0.le]) + have hwv : 8*w ≤ v := by have := min_le_left (v/8) 1; dsimp [w]; linarith + have hz : 3*(w*r) ≤ v*r := by nlinarith + have hza : 3*(w*r)+w*r/2 ≤ v*r := by nlinarith + dsimp only + intro a π hπ hsupp + let := hπ + have hb := hsurv r hr H hH hscale a π hπ hsupp + have hle : environmentLaw ν {ω | (jointTubeMass ℓ f b H (v*r) π ω).toReal < δ} ≤ + environmentLaw ν {ω | (tubePrefixMass ℓ f (b H/H) (3*(w*r)) H π ω).toReal < δ} := by + apply measure_mono + intro ω hω + have hh : tubePrefixMass ℓ f (b H/H) (3*(w*r)) H π ω ≤ jointTubeMass ℓ f b H (v*r) π ω := by + apply lintegral_mono; intro x + exact measure_mono (tubePrefix_subset_jointTubeSuccess ℓ f x b H (3*(w*r)) (w*r/2) (v*r) hdet hz hza) + exact (ENNReal.toReal_mono (jointTubeMass_ne_top ℓ f b H (v*r) π ω) hh).trans_lt hω + exact (ENNReal.toReal_mono (measure_ne_top _ _) hle).trans hb + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/LatticeVector.lean b/lean/OAI/Probability/Ballisticity/Geometry/LatticeVector.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8e13fa0efbb578e14be5f989a5a7056f9b15a7e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/LatticeVector.lean @@ -0,0 +1,428 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.WordHeightGain + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma stationary_initial_average_truncated_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (T : Ω → Ω) (hT : MeasurePreserving T μ μ) + (f : Ω → ℝ) (hf : Measurable f) (hfn : ∀ x, 0 ≤ f x) + (K : ℕ) (a : ℝ) (ha : 0 < a) : + a * μ.real {x | ∃ k, 0 < k ∧ k ≤ K ∧ + a * (k : ℝ) < ∑ j ∈ Finset.range k, f (T^[j] x)} ≤ + 2 * truncatedMean μ f (a*K) := by + let g : Ω → ℝ := fun x => min (f x) (a*K) + have hg : Measurable g := hf.min measurable_const + have hgn (x : Ω) : 0 ≤ g x := le_min (hfn x) (mul_nonneg ha.le (Nat.cast_nonneg _)) + have hgi : Integrable g μ := integrable_min_nonneg μ f hf hfn _ + (mul_nonneg ha.le (Nat.cast_nonneg _)) + have hsub : {x | ∃ k, 0 < k ∧ k ≤ K ∧ + a * (k : ℝ) < ∑ j ∈ Finset.range k, f (T^[j] x)} ⊆ + {x | ∃ k, 0 < k ∧ k ≤ K ∧ + (a/2) * (k : ℝ) < ∑ j ∈ Finset.range k, g (T^[j] x)} := by + intro x hx + obtain ⟨k,hk,hkK,hs⟩ := hx + refine ⟨k,hk,hkK,?_⟩ + have hkpos : (0 : ℝ) < k := Nat.cast_pos.mpr hk + by_cases ht : ∀ j ∈ Finset.range k, f (T^[j] x) ≤ a*K + · have he : (∑ j ∈ Finset.range k, g (T^[j] x)) = + ∑ j ∈ Finset.range k, f (T^[j] x) := by + apply Finset.sum_congr rfl + intro j hj + exact min_eq_left (ht j hj) + rw [he] + nlinarith + · obtain ⟨j,hj,hjt⟩ : ∃ j ∈ Finset.range k, a*K < f (T^[j] x) := by + simpa only [not_forall, not_le, exists_prop] using ht + have hle : a*(k : ℝ) ≤ ∑ j ∈ Finset.range k, g (T^[j] x) := by + calc + _ ≤ a*K := mul_le_mul_of_nonneg_left (Nat.cast_le.mpr hkK) ha.le + _ = g (T^[j] x) := (min_eq_right hjt.le).symm + _ ≤ _ := Finset.single_le_sum (fun i (_ : i ∈ Finset.range k) => hgn (T^[i] x)) hj + nlinarith + have hme := measureReal_mono (μ := μ) hsub + have hb := stationary_initial_average_bound μ T hT g hg hgi hgn K (a/2) (by linarith) + change (a/2) * _ ≤ truncatedMean μ f (a*K) at hb + have hm := mul_le_mul_of_nonneg_left hme (show 0 ≤ a/2 by linarith) + linarith + +lemma truncatedMean_ratio_tendsto_zero {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (c : ℝ) (hc : 0 ≤ c) : + Tendsto (fun n : ℕ => truncatedMean μ f (c*(n+1)) / (n+1)) atTop (𝓝 0) := by + have hpt (x : Ω) : Tendsto (fun n : ℕ => min (f x) (c*(n+1)) / (n+1)) atTop (𝓝 0) := by + have hz : Tendsto (fun n : ℕ => f x / (n+1)) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop (tendsto_atTop_mono (fun n : ℕ => show (n : ℝ) ≤ (n : ℝ)+1 by linarith) + tendsto_natCast_atTop_atTop) + apply squeeze_zero (fun n => div_nonneg (le_min (hfn x) (mul_nonneg hc (by positivity))) + (by positivity)) (fun n => div_le_div_of_nonneg_right (min_le_left _ _) (by positivity)) hz + have hdom := tendsto_integral_of_dominated_convergence (μ := μ) + (F := fun n : ℕ => fun x : Ω => min (f x) (c*(n+1)) / (n+1)) + (f := fun _ : Ω => (0 : ℝ)) (fun _ : Ω => c) + (fun n => ((hf.min measurable_const).div_const _).aestronglyMeasurable) + (integrable_const c) (fun n => Filter.Eventually.of_forall fun x => by + rw [Real.norm_eq_abs, abs_of_nonneg (div_nonneg + (le_min (hfn x) (mul_nonneg hc (by positivity))) (by positivity))] + exact (div_le_iff₀ (show (0 : ℝ) < n+1 by positivity)).mpr (min_le_right _ _)) + (Filter.Eventually.of_forall hpt) + simpa only [integral_div, integral_zero, truncatedMean] using hdom + +lemma real_integrable_of_scaled_truncation_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) {c B : ℝ} (hc : 0 < c) + (hB : ∀ K : ℕ, truncatedMean μ f (c*K) ≤ B) : Integrable f μ := by + have hbound : (∫⁻ x, ENNReal.ofReal (f x) ∂μ) ≤ ENNReal.ofReal B := by + have he (x : Ω) : ENNReal.ofReal (f x) = + ⨆ K : ℕ, ENNReal.ofReal (min (f x) (c*K)) := by + apply le_antisymm + · obtain ⟨K,hK⟩ := exists_nat_ge (f x / c) + have hle : f x ≤ c*K := by + have := (div_le_iff₀ hc).mp hK + linarith + exact le_iSup_of_le K (by rw [min_eq_left hle]) + · exact iSup_le fun K => ENNReal.ofReal_le_ofReal (min_le_left _ _) + simp_rw [he] + rw [lintegral_iSup (f := fun K x => ENNReal.ofReal (min (f x) (c*K))) + (fun K => (hf.min measurable_const).ennreal_ofReal) + (fun i j hij x => ENNReal.ofReal_le_ofReal + (min_le_min_left _ (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr hij) hc.le)))] + apply iSup_le + intro K + have hi := integrable_min_nonneg μ f hf hfn (c*K) (mul_nonneg hc.le (Nat.cast_nonneg _)) + rw [← ofReal_integral_eq_lintegral_ofReal hi + (Filter.Eventually.of_forall fun x => le_min (hfn x) (mul_nonneg hc.le (Nat.cast_nonneg _)))] + exact ENNReal.ofReal_le_ofReal (hB K) + refine ⟨hf.aestronglyMeasurable, ?_⟩ + rw [hasFiniteIntegral_iff_ofReal (Filter.Eventually.of_forall hfn)] + exact hbound.trans_lt ENNReal.ofReal_lt_top + +lemma exists_minimal_truncation_scale {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (hinf : ¬ Integrable f μ) + (η a : ℝ) (hη : 0 < η) (ha : 0 < a) : + ∃ N : ℕ, 0 < N ∧ η*a ≤ truncatedMean μ f (a*N) ∧ + ∀ k < N, truncatedMean μ f (a*k) < η*a := by + have hex : ∃ N : ℕ, η*a ≤ truncatedMean μ f (a*N) := by + by_contra h + have hb : ∀ N : ℕ, truncatedMean μ f (a*N) ≤ η*a := by + intro N + have := not_exists.mp h N + exact le_of_lt (lt_of_not_ge this) + exact hinf (real_integrable_of_scaled_truncation_bound μ f hf hfn ha hb) + refine ⟨Nat.find hex, ?_, Nat.find_spec hex, ?_⟩ + · by_contra h + have he : Nat.find hex = 0 := by omega + have hh := Nat.find_spec hex + rw [he, Nat.cast_zero, mul_zero, truncatedMean] at hh + have he' : (fun x => min (f x) 0) = fun _ => (0 : ℝ) := + funext fun x => min_eq_right (hfn x) + rw [he', integral_zero] at hh + exact (not_le_of_gt (mul_pos hη ha)) hh + · intro k hk + exact lt_of_not_ge (Nat.find_min hex hk) + +lemma minimal_truncation_scale_upper {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (η a : ℝ) (ha : 0 ≤ a) {N : ℕ} (hN : 2 ≤ N) + (hmin : ∀ k < N, truncatedMean μ f (a*k) < η*a) : + truncatedMean μ f (a*N) < 2*η*a := by + have hlt := hmin (N-1) (by omega) + calc + _ ≤ truncatedMean μ f (2*(a*(N-1 : ℕ))) := + truncatedMean_mono μ f hf hfn (mul_nonneg ha (Nat.cast_nonneg _)) + (by have hn : (N : ℝ) ≤ 2*(N-1 : ℕ) := by exact_mod_cast (show N ≤ 2*(N-1) by omega) + nlinarith) + _ ≤ 2*truncatedMean μ f (a*(N-1 : ℕ)) := + truncatedMean_mul_le μ f hf hfn (mul_nonneg ha (Nat.cast_nonneg _)) (by norm_num) + _ < 2*η*a := by linarith + +noncomputable def latticeVector {d : ℕ} (x : Lattice d) : EuclideanSpace ℝ (Fin d) := + WithLp.toLp 2 (realPosition x) + +@[simp] lemma latticeVector_zero {d : ℕ} : latticeVector (0 : Lattice d) = 0 := by + ext i + simp [latticeVector, realPosition] + +lemma latticeVector_add {d : ℕ} (x y : Lattice d) : + latticeVector (x+y) = latticeVector x + latticeVector y := by + ext i + simp [latticeVector, realPosition] + +lemma latticeVector_sub {d : ℕ} (x y : Lattice d) : + latticeVector (x-y) = latticeVector x - latticeVector y := by + ext i + simp [latticeVector, realPosition] + +lemma latticeVector_step_norm {d : ℕ} (e : Direction d) : ‖latticeVector (step e)‖ = 1 := by + have hs : ‖latticeVector (step e)‖ ^ 2 = 1 := by + rw [EuclideanSpace.real_norm_sq_eq] + simp only [latticeVector, realPosition, step, + Int.cast_ite, Int.cast_one, Int.cast_neg, Int.cast_zero, ite_pow, zero_pow (by norm_num : 2 ≠ 0)] + simp + nlinarith [norm_nonneg (latticeVector (step e))] + +noncomputable def wordRadius {d : ℕ} (w : List (Direction d)) : ℝ := by + classical + exact (Finset.range (w.length+1)).sup' (Finset.nonempty_range_iff.mpr (by omega)) + (fun j => ‖latticeVector (wordPath 0 w j)‖) + +lemma wordRadius_bound {d : ℕ} (w : List (Direction d)) {j : ℕ} (hj : j ≤ w.length) : + ‖latticeVector (wordPath 0 w j)‖ ≤ wordRadius w := by + classical + exact Finset.le_sup' (fun j => ‖latticeVector (wordPath 0 w j)‖) + (Finset.mem_range.mpr (by omega)) + +lemma wordRadius_nonneg {d : ℕ} (w : List (Direction d)) : 0 ≤ wordRadius w := by + have hh := wordRadius_bound w (j := 0) (by omega) + simpa only [wordPath_zero, latticeVector_zero, norm_zero] using hh + +lemma wordRadius_attained {d : ℕ} (w : List (Direction d)) : + ∃ j ≤ w.length, wordRadius w = ‖latticeVector (wordPath 0 w j)‖ := by + classical + obtain ⟨j,hj,he⟩ := Finset.exists_mem_eq_sup' (Finset.nonempty_range_iff.mpr + (show w.length+1 ≠ 0 by omega)) (fun j => ‖latticeVector (wordPath 0 w j)‖) + exact ⟨j, by have := Finset.mem_range.mp hj; omega, he⟩ + +lemma wordRadius_le_length {d : ℕ} (w : List (Direction d)) : wordRadius w ≤ w.length := by + classical + have hb (j : ℕ) : ‖latticeVector (wordPath 0 w j)‖ ≤ j := by + induction j with + | zero => simp + | succ j ih => + rcases wordPath_step_or_stay 0 w j with he | ⟨e,he⟩ + · rw [he, Nat.cast_add, Nat.cast_one]; linarith + · rw [he, latticeVector_add, Nat.cast_add, Nat.cast_one] + exact (norm_add_le _ _).trans (by rw [latticeVector_step_norm]; linarith) + apply Finset.sup'_le + intro j hj + exact (hb j).trans (Nat.cast_le.mpr (by have := Finset.mem_range.mp hj; omega)) + +lemma measurable_wordRadius {d : ℕ} : Measurable (wordRadius (d := d)) := measurable_of_countable _ + +lemma conditioned_radius_initial_average_bound {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (K : ℕ) (a : ℝ) (ha : 0 < a) : + a * (conditionedLaw ν ℓ).real {X | ∃ k, 0 < k ∧ k ≤ K ∧ + a * (k : ℝ) < ∑ j ∈ Finset.range k, wordRadius (regenerationWords ℓ X j)} ≤ + 2 * truncatedMean (conditionedLaw ν ℓ) + (fun X => wordRadius (firstWord ℓ X)) (a*K) := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + exact stationary_initial_average_truncated_bound _ _ + (renewSuffix_preserves_conditioned ν ℓ htrans) _ + (measurable_wordRadius.comp (measurable_firstWord ℓ)) (fun X => wordRadius_nonneg _) K a ha + +lemma affine_envelope_of_average_limit (H : ℕ → ℝ) (L : ℝ) (hL : 0 < L) + (hlim : Tendsto (fun n : ℕ => H n / n) atTop (𝓝 L)) : + ∃ C0 : ℕ, ∀ n : ℕ, (L/2)*n-C0 ≤ H n ∧ H n ≤ (2*L)*n+C0 := by + have hevent : ∀ᶠ n : ℕ in atTop, L/2 < H n / n ∧ H n / n < 2*L := + hlim.eventually (Ioo_mem_nhds (by linarith) (by linarith)) + obtain ⟨N,hN⟩ := (eventually_atTop.1 hevent) + let M := max N 1 + let B : ℝ := (∑ j ∈ Finset.range M, |H j|) + 2*L*M + obtain ⟨C0,hC0⟩ := exists_nat_ge B + refine ⟨C0, fun n => ?_⟩ + by_cases hn : M ≤ n + · have hn0 : (0 : ℝ) < n := Nat.cast_pos.mpr (by dsimp [M] at hn; omega) + obtain ⟨hl,hu⟩ := hN n (by dsimp [M] at hn; omega) + have hl' := (lt_div_iff₀ hn0).mp hl + have hu' := (div_lt_iff₀ hn0).mp hu + constructor <;> nlinarith [Nat.cast_nonneg (α := ℝ) C0] + · have hn' : n ∈ Finset.range M := Finset.mem_range.mpr (by omega) + have hnM : (n : ℝ) ≤ M := Nat.cast_le.mpr (by omega) + have hs : |H n| ≤ ∑ j ∈ Finset.range M, |H j| := + Finset.single_le_sum (fun j _ => abs_nonneg (H j)) hn' + have hs0 : 0 ≤ ∑ j ∈ Finset.range M, |H j| := + Finset.sum_nonneg fun j _ => abs_nonneg (H j) + dsimp only [B] at hC0 + constructor <;> nlinarith [le_abs_self (H n), neg_abs_le (H n), + Nat.cast_nonneg (α := ℝ) n, Nat.cast_nonneg (α := ℝ) M] + +lemma uniform_affine_envelope_probability {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (H : ℕ → Ω → ℝ) (L : ℝ) (hL : 0 < L) + (hlim : ∀ᵐ x ∂μ, Tendsto (fun n : ℕ => H n x / n) atTop (𝓝 L)) + (ε : ℝ) (hε : 0 < ε) : + ∃ C0 : ℕ, 1-ε < μ.real {x | ∀ n : ℕ, (L/2)*n-C0 ≤ H n x ∧ + H n x ≤ (2*L)*n+C0} := by + let E : ℕ → Set Ω := fun C0 => {x | ∀ n : ℕ, (L/2)*n-C0 ≤ H n x ∧ + H n x ≤ (2*L)*n+C0} + have hmono : Monotone E := by + intro i j hij x hx n + have hi := hx n + have hij' : (i : ℝ) ≤ j := Nat.cast_le.mpr hij + constructor <;> linarith + have hae : ∀ᵐ x ∂μ, x ∈ ⋃ C0, E C0 := by + filter_upwards [hlim] with x hx + obtain ⟨C0,hC0⟩ := affine_envelope_of_average_limit (fun n => H n x) L hL hx + exact Set.mem_iUnion.mpr ⟨C0,hC0⟩ + have hme : μ (⋃ C0, E C0) = 1 := by + rw [← measure_univ (μ := μ)] + apply measure_congr + filter_upwards [hae] with x hx + exact propext (iff_true_intro hx) + have ht := (ENNReal.tendsto_toReal (measure_ne_top μ (⋃ C0, E C0))).comp + (tendsto_measure_iUnion_atTop (μ := μ) hmono) + rw [hme, ENNReal.toReal_one] at ht + have he := ht.eventually (Ioi_mem_nhds (show 1-ε < 1 by linarith)) + obtain ⟨C0,hC0⟩ := he.exists + exact ⟨C0,hC0⟩ + +lemma conditioned_height_template {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hℓ : ∀ i, |ℓ i| ≤ 1) (htrans : DirectionallyTransient ν ℓ) + (ε : ℝ) (hε : 0 < ε) : + ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∃ C0 : ℕ, + 1-ε < (conditionedLaw ν ℓ).real {X | ∀ k : ℕ, + c*k-C0 ≤ ∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j) ∧ + (∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) ≤ C*k+C0} := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + obtain ⟨hint,hpositive,_⟩ := conditioned_wordHeightGain_moments ν ℓ hℓ htrans + let L := ∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂conditionedLaw ν ℓ + have hmeas : Measurable (wordHeightGain ℓ) := measurable_of_countable _ + have hlim : ∀ᵐ X ∂conditionedLaw ν ℓ, Tendsto + (fun k : ℕ => (∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) / k) + atTop (𝓝 L) := by + exact strong_law_ae_real _ hint + (fun i j hij => ((regenerationWords_independent ν ℓ htrans).indepFun hij).comp hmeas hmeas) + (fun i => (regenerationWords_identDistrib ν ℓ htrans i).comp hmeas) + obtain ⟨C0,hC0⟩ := uniform_affine_envelope_probability (conditionedLaw ν ℓ) + (fun k X => ∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) + L hpositive hlim ε hε + exact ⟨L/2,2*L,by linarith,by linarith,C0,hC0⟩ + +lemma truncation_threshold_eventually_large {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (η : ℝ) (hη : 0 < η) (M : ℕ) : + ∀ᶠ a : ℕ in atTop, ∀ N : ℕ, + η*(a+1) ≤ truncatedMean μ f ((a+1)*N) → M < N := by + have ht := truncatedMean_ratio_tendsto_zero μ f hf hfn (M : ℝ) (Nat.cast_nonneg _) + have he := ht.eventually (Iio_mem_nhds hη) + filter_upwards [he] with a ha N hN + by_contra hNM + have hNM' : (N : ℝ) ≤ M := Nat.cast_le.mpr (by omega) + have hb := truncatedMean_mono μ f hf hfn + (show 0 ≤ ((a : ℝ)+1)*N by positivity) + (mul_le_mul_of_nonneg_left hNM' (by positivity : 0 ≤ (a : ℝ)+1)) + have ha' := (div_lt_iff₀ (show 0 < (a : ℝ)+1 by positivity)).mp ha + rw [mul_comm ((a : ℝ)+1) (M : ℝ)] at hb + linarith + +lemma truncated_template_failure_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (T : Ω → Ω) + (hT : MeasurePreserving T μ μ) (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (η a : ℝ) (ha : 0 < a) (C1 N : ℕ) (hC1 : 1 ≤ C1) + (hI : truncatedMean μ f (a*N) < 2*η*a) : + μ.real {x | ∃ k, 0 < k ∧ k ≤ C1*N ∧ + a*(k : ℝ) < ∑ j ∈ Finset.range k, f (T^[j] x)} < 4*C1*η := by + have hb := stationary_initial_average_truncated_bound μ T hT f hf hfn (C1*N) a ha + have hc : (1 : ℝ) ≤ C1 := by exact_mod_cast hC1 + have hs := truncatedMean_mul_le μ f hf hfn + (mul_nonneg ha.le (Nat.cast_nonneg N)) hc + have he : a*(C1*N : ℕ) = (C1 : ℝ)*(a*N) := by push_cast; ring + rw [he] at hb + have hC1pos : (0 : ℝ) < C1 := lt_of_lt_of_le zero_lt_one hc + have hmul := mul_lt_mul_of_pos_left hI hC1pos + have hh : a * μ.real {x | ∃ k, 0 < k ∧ k ≤ C1*N ∧ + a*(k : ℝ) < ∑ j ∈ Finset.range k, f (T^[j] x)} < a*(4*C1*η) := by + nlinarith + exact (mul_lt_mul_iff_right₀ ha).mp hh + +lemma restricted_union_lower_bound {Ω ι : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (S : Finset ι) (E : ι → Set Ω) + (hE : ∀ i, MeasurableSet (E i)) (p : ι → ℝ) (q : ℝ) + (hfirst : ∀ i ∈ S, q*p i ≤ μ.real (E i)) + (hpair : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → μ.real (E i ∩ E j) ≤ p i * p j) : + q * (∑ i ∈ S, p i) - (∑ i ∈ S, p i)^2 / 2 ≤ μ.real (⋃ i ∈ S, E i) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert a S ha ih => + have hfirstS : ∀ i ∈ S, q*p i ≤ μ.real (E i) := fun i hi => hfirst i (by simp [hi]) + have hpairS : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → μ.real (E i ∩ E j) ≤ p i * p j := + fun i hi j hj hij => hpair i (by simp [hi]) j (by simp [hj]) hij + have hold := ih hfirstS hpairS + have hnew := hfirst a (Finset.mem_insert_self a S) + have hcross : μ.real (E a ∩ ⋃ i ∈ S, E i) ≤ p a * (∑ i ∈ S, p i) := by + rw [Set.inter_iUnion] + simp_rw [Set.inter_iUnion] + calc + _ ≤ ∑ i ∈ S, μ.real (E a ∩ E i) := measureReal_biUnion_finset_le S _ + _ ≤ ∑ i ∈ S, p a * p i := by + apply Finset.sum_le_sum + intro i hi + exact hpair a (by simp) i (by simp [hi]) (by intro he; subst i; contradiction) + _ = _ := by rw [Finset.mul_sum] + have hidentity := measureReal_union_add_inter₀' (μ := μ) (hE a).nullMeasurableSet + (s := E a) (t := ⋃ i ∈ S, E i) (h₂ := measure_ne_top μ _) + simp only [Finset.sum_insert ha, Finset.set_biUnion_insert] + nlinarith [sq_nonneg (p a)] + +lemma independent_rare_words_lower_bound {Ω ι : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Finset ι) (A G : ι → Set Ω) + (hA : ∀ i, MeasurableSet (A i)) (hG : ∀ i, MeasurableSet (G i)) (q : ℝ) + (hprev : ∀ i ∈ S, q*μ.real (A i) ≤ μ.real (A i ∩ G i)) + (hpair : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → + μ.real (A i ∩ A j) = μ.real (A i) * μ.real (A j)) : + q * (∑ i ∈ S, μ.real (A i)) - (∑ i ∈ S, μ.real (A i))^2 / 2 ≤ + μ.real {x | ∃ i ∈ S, x ∈ A i ∧ x ∈ G i} := by + have hh := restricted_union_lower_bound μ S (fun i => A i ∩ G i) + (fun i => (hA i).inter (hG i)) (fun i => μ.real (A i)) q hprev (by + intro i hi j hj hij + calc + μ.real ((A i ∩ G i) ∩ (A j ∩ G j)) ≤ μ.real (A i ∩ A j) := + measureReal_mono (μ := μ) (fun _ hx => ⟨hx.1.1,hx.2.1⟩) + _ = _ := hpair i hi j hj hij) + have he : (⋃ i ∈ S, A i ∩ G i) = {x | ∃ i ∈ S, x ∈ A i ∧ x ∈ G i} := by + ext x + simp only [Set.mem_iUnion, Set.mem_inter_iff, Set.mem_ofPred_eq] + aesop + rwa [he] at hh + +lemma annealed_avoiding_suffix {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (w : List (Direction d)) + (hnew : wordPath 0 w w.length ∉ wordDepartures 0 w) + (A : Set (Path d)) (hA : MeasurableSet A) + (havoid : ∀ X ∈ A, ∀ j, wordPath 0 w w.length + X j ∉ wordDepartures 0 w) : + annealedLaw ν ((fun X : Path d => fun j => X (w.length + j) - + wordPath 0 w w.length) ⁻¹' A ∩ wordCylinder 0 w) = + annealedLaw ν (wordCylinder 0 w) * annealedLaw ν A := by + let y := wordPath 0 w w.length + let S : Set (Lattice d) := ↑(wordDepartures 0 w) + let T : Set (Lattice d) := Sᶜ + let B : Set (Path d) := (fun X : Path d => fun j => X j - y) ⁻¹' A + have hB : MeasurableSet B := hA.preimage (by fun_prop) + have hBT : B ⊆ Stay T := by + intro X hX j + have h := havoid (fun k => X k-y) hX j + have he : wordPath 0 w w.length + (X j-y) = X j := by dsimp only [y]; abel + rw [he] at h + exact h + have hST : Disjoint S T := disjoint_compl_right + have hw (ω : Environment d) : quenchedKernel (ω, 0) + ((fun X : Path d => fun j => X (w.length + j) - y) ⁻¹' A ∩ wordCylinder 0 w) = + ENNReal.ofReal (wordWeight ω 0 w) * quenchedKernel (ω, y) B := by + have hh := quenched_prefix_future ω 0 (wordPath 0 w) (by simp) w.length hB + change quenchedKernel (ω, 0) (_ ∩ wordCylinder 0 w) = + quenchedKernel (ω, 0) (wordCylinder 0 w) * quenchedKernel (ω, y) B at hh + rwa [quenched_wordCylinder] at hh + rw [annealed_apply ν ((hA.preimage (by fun_prop)).inter (measurableSet_wordCylinder 0 w))] + change (∫⁻ ω, quenchedKernel (ω, 0) + ((fun X : Path d => fun j => X (w.length + j) - y) ⁻¹' A ∩ wordCylinder 0 w) + ∂environmentLaw ν) = _ + simp_rw [hw] + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hST) + ((measurable_wordWeight_on 0 w (fun _ hz => hz)).ennreal_ofReal) + (measurable_quenched_stay_event_rows T y hnew B hB hBT)] + rw [← annealed_wordCylinder, annealed_event_translation ν y A hA] + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/MedianTubeFailure.lean b/lean/OAI/Probability/Ballisticity/Geometry/MedianTubeFailure.lean new file mode 100644 index 0000000000000000000000000000000000000000..79f8b402722e91e4123d66e6ddf10fddbd944df4 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/MedianTubeFailure.lean @@ -0,0 +1,270 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.FiniteHitOscillation + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def MedianTubeFailure {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (H : ℕ) (z : ℝ) : Set (Path d) := + {X | ∃ j ≤ H, z < |signedCoordinate f (recordIndexPosition ℓ j X)-b j|} + +lemma measurableSet_medianTubeFailure {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b : ℕ → ℝ) (H : ℕ) (z : ℝ) : MeasurableSet (MedianTubeFailure ℓ f b H z) := by + simp only [MedianTubeFailure,Set.ofPred_exists,Set.ofPred_and] + exact MeasurableSet.iUnion fun j => (MeasurableSet.const (j ≤ H)).inter + (measurableSet_lt measurable_const ((((measurable_of_countable (signedCoordinate f)).comp + (measurable_recordIndexPosition ℓ j)).sub_const (b j)).abs)) + +lemma two_centers_close_of_tails {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F G : Ω → ℝ) + (hF : Measurable F) (hG : Measurable G) (a b z : ℝ) + (hf : μ.real {x | z < |F x-a|} ≤ 3/10) + (hg : μ.real {x | z < |G x-b|} ≤ 3/10) + (hfg : μ.real {x | z ≤ |G x-F x|} < 1/10) : |b-a| ≤ 3*z := by + by_contra! hfar + let A := {x | z < |F x-a|} + let B := {x | z < |G x-b|} + let E := {x | z ≤ |G x-F x|} + have hm : MeasurableSet (A ∪ B ∪ E) := + ((measurableSet_lt measurable_const (hF.sub_const a).abs).union + (measurableSet_lt measurable_const (hG.sub_const b).abs)).union + (measurableSet_le measurable_const (hG.sub hF).abs) + have hcover : Set.univ ⊆ A ∪ B ∪ E := by + intro x _ + by_contra hn + have ha : |F x-a| ≤ z := by + by_contra! ha + exact hn (Or.inl (Or.inl ha)) + have hb : |G x-b| ≤ z := by + by_contra! hb + exact hn (Or.inl (Or.inr hb)) + have he : |G x-F x| < z := by + by_contra! he + exact hn (Or.inr he) + have h₁ := abs_sub_le b (G x) (F x) + have h₂ := abs_sub_le b (F x) a + rw [abs_sub_comm b (G x)] at h₁ + linarith + have hmono := measureReal_mono (μ := μ) hcover + rw [probReal_univ] at hmono + have hu := measureReal_union_le (μ := μ) (A ∪ B) E + have hu' := measureReal_union_le (μ := μ) A B + change μ.real A ≤ 3/10 at hf + change μ.real B ≤ 3/10 at hg + change μ.real E < 1/10 at hfg + linarith + +theorem median_shift_eventually {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (htrans : DirectionallyTransient ν ℓ) + (b : ℕ → ℝ) (H : ℕ → ℕ) (z : ℕ → ℝ) (hz : Tendsto z atTop atTop) + (hsmall : ∀ᶠ i in atTop, (conditionedLaw ν ℓ).real + (MedianTubeFailure ℓ f b (H i) (z i/10)) ≤ 3/10) (R : ℕ) : + ∀ᶠ i in atTop, ∀ h s : ℕ, s ≤ R → h+s ≤ H i → |b (h+s)-b h| ≤ 3*z i/10 := by + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let bad (i : ℕ) := ∃ h s : ℕ, s ≤ R ∧ h+s ≤ H i ∧ ¬ |b (h+s)-b h| ≤ 3*z i/10 + let a (i : ℕ) : ℕ := if hi : bad i then hi.choose else 0 + have ht := conditioned_finite_increment_small ν ℓ f htrans R a + (fun i => z i/10) (hz.atTop_div_const (by norm_num)) + have he := (tendsto_order.mp ht).2 (1/10) (by norm_num) + filter_upwards [hsmall,he] with i hi hei + by_contra hn + have hbad : bad i := by + push Not at hn + obtain ⟨h,s,hs,hH,hfar⟩ := hn + exact ⟨h,s,hs,hH,not_le.mpr hfar⟩ + have ha : a i = hbad.choose := dite_eq_left hbad + obtain ⟨s,hs,hH,hfar⟩ := hbad.choose_spec + have hbound (j : ℕ) (hj : j ≤ H i) : + μ.real {X | z i/10 < |signedCoordinate f (recordIndexPosition ℓ j X)-b j|} ≤ 3/10 := + (measureReal_mono (μ := μ) (s₂ := MedianTubeFailure ℓ f b (H i) (z i/10)) + (fun X hX => ⟨j,hj,hX⟩)).trans hi + have hinc : μ.real {X | z i/10 ≤ |signedCoordinate f (recordIndexPosition ℓ (a i+s) X)- + signedCoordinate f (recordIndexPosition ℓ (a i) X)|} < 1/10 := + (measureReal_mono (fun X hX => (show X ∈ FiniteHitOscillation ℓ f (a i) R (z i/10) from + ⟨s,hs,hX⟩))).trans_lt hei + have hh := two_centers_close_of_tails μ + (fun X => signedCoordinate f (recordIndexPosition ℓ (a i) X)) + (fun X => signedCoordinate f (recordIndexPosition ℓ (a i+s) X)) + ((measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ (a i))) + ((measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ (a i+s))) + (b (a i)) (b (a i+s)) (z i/10) + (hbound _ (by rw [ha]; omega)) (hbound _ (by rwa [ha])) hinc + rw [ha] at hh + exact hfar (by linarith) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/NormHeightPolygon.lean b/lean/OAI/Probability/Ballisticity/Geometry/NormHeightPolygon.lean new file mode 100644 index 0000000000000000000000000000000000000000..ebd5b6aeb17783f78af23e2fab91f722aefe33b0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/NormHeightPolygon.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightPolygon + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma norm_heightPolygon_le (F : ℕ → ℝ) (r n T : ℝ) (hq : 0 ≤ T*n) + {E : ℝ} (hE : 0 ≤ E) (hb : ∀ j ≤ ⌊T*n⌋₊+1, |F j/r| ≤ E) : + ‖heightPolygon F r n T‖ ≤ E := by + apply (ContinuousMap.norm_le _ hE).mpr + intro t + rw [Real.norm_eq_abs,heightPolygon_formula F r n T hq t] + let u := T*n*(t:ℝ) + let j := ⌊u⌋₊ + have hu : 0 ≤ u := mul_nonneg hq t.2.1 + have hv0 : 0 ≤ u-(j:ℝ) := sub_nonneg.mpr (Nat.floor_le hu) + have hv1 : u-(j:ℝ) ≤ 1 := by have := Nat.lt_floor_add_one u; change u < (j:ℝ)+1 at this; linarith + have hj : j ≤ ⌊T*n⌋₊ := Nat.floor_mono (mul_le_of_le_one_right hq t.2.2) + have he : (F j+(u-j)*(F (j+1)-F j))/r = (1-(u-j))*(F j/r)+(u-j)*(F (j+1)/r) := by ring + change |(F j+(u-j)*(F (j+1)-F j))/r| ≤ E + rw [he] + calc + _ ≤ |(1-(u-j))*(F j/r)|+|(u-j)*(F (j+1)/r)| := abs_add_le _ _ + _ = (1-(u-j))*|F j/r|+(u-j)*|F (j+1)/r| := by + rw [abs_mul,abs_mul,abs_of_nonneg (sub_nonneg.mpr hv1),abs_of_nonneg hv0] + _ ≤ (1-(u-j))*E+(u-j)*E := by + gcongr + · exact hb j (by omega) + · exact hb (j+1) (by omega) + _ = E := by ring + +lemma heightPolygon_tendsto_zero_of_grid (F : ℕ → ℕ → ℝ) (r n : ℕ → ℝ) + (hn : Tendsto n atTop atTop) (T : ℝ) (hT : 0 ≤ T) + (hb : ∀ ε > 0, ∀ᶠ i in atTop, ∀ j : ℕ, (j:ℝ) ≤ (T+1)*n i → |F i j/r i| < ε) : + Tendsto (fun i => heightPolygon (F i) (r i) (n i) T) atTop (𝓝 0) := by + apply Metric.tendsto_nhds.mpr + intro ε hε + filter_upwards [hb (ε/2) (half_pos hε),hn.eventually (eventually_ge_atTop (1:ℝ))] with i hi hni + rw [dist_zero_right] + apply lt_of_le_of_lt (norm_heightPolygon_le _ _ _ _ (mul_nonneg hT (by positivity)) (half_pos hε).le _) (half_lt_self hε) + intro j hj + have hjr : (j:ℝ) ≤ (⌊T*n i⌋₊:ℝ)+1 := by exact_mod_cast hj + have hfl := Nat.floor_le (mul_nonneg hT (show 0 ≤ n i by positivity)) + exact (hi j (by nlinarith)).le + +lemma heightPolygon_change_center (F b c : ℕ → ℝ) (r n T : ℝ) : + heightPolygon (fun h => F h-c h) r n T-heightPolygon (fun h => F h-b h) r n T = + heightPolygon (fun h => b h-c h) r n T := by + rw [← heightPolygon_sub] + congr 1 + funext h + ring + +theorem height_path_change_center {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : ℕ → Ω → ℝ) (hF : ∀ h, Measurable (F h)) + (b : ℕ → ℝ) (c : ℕ → ℕ → ℝ) (r n : ℕ → ℝ) (hn : Tendsto n atTop atTop) + (T : ℝ) (hT : 0 ≤ T) + (hb : ∀ ε > 0, ∀ᶠ i in atTop, ∀ j : ℕ, (j:ℝ) ≤ (T+1)*n i → |(b j-c i j)/r i| < ε) + (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : TendstoInDistribution (fun i x => heightPolygon (fun h => F h x-b h) (r i) (n i) T) + atTop id (fun _ => μ) W) : + TendstoInDistribution (fun i x => heightPolygon (fun h => F h x-c i h) (r i) (n i) T) + atTop id (fun _ => μ) W := by + apply tendstoInDistribution_of_tendstoInMeasure_sub _ id hlim + · have hh := heightPolygon_tendsto_zero_of_grid (fun i j => b j-c i j) r n hn T hT hb + apply tendstoInMeasure_of_tendsto_ae + · intro i + have he : (fun x => heightPolygon (fun h => F h x-c i h) (r i) (n i) T) - + (fun x => heightPolygon (fun h => F h x-b h) (r i) (n i) T) = + (fun _ => heightPolygon (fun h => b h-c i h) (r i) (n i) T) := by + funext x + exact heightPolygon_change_center _ _ _ _ _ _ + change AEStronglyMeasurable ((fun x => heightPolygon (fun h => F h x-c i h) (r i) (n i) T) - + (fun x => heightPolygon (fun h => F h x-b h) (r i) (n i) T)) μ + rw [he] + exact aestronglyMeasurable_const + · exact Eventually.of_forall (fun x => by simpa only [Pi.sub_apply,heightPolygon_change_center,Pi.zero_apply] using hh) + · intro i + exact (measurable_heightPolygon _ (fun h => (hF h).sub_const _) _ _ _).aemeasurable + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/OccupationWindow.lean b/lean/OAI/Probability/Ballisticity/Geometry/OccupationWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..c75be22d742db02e9af7811557a6d135ca71ba16 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/OccupationWindow.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.RestrictedWindow +import OAI.Probability.Ballisticity.Stationary.ArrayClosed + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical BigOperators +namespace DirectionalTransience + +lemma typedCurrentArrayWindow_iterate_actual {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (j : ℤ) (m i : ℕ) (X : EpisodeInput e) : + typedCurrentArrayWindow e j m (StationaryCompact.shift^[i] (actualArrayMap e t J X)) = + actualCurrentWindow e t (j+i) m X := by + have hc : ReferenceClasses.Consistent + (currentOffsets e j (StationaryCompact.shift^[i] (actualArrayMap e t J X))) := by + have h := congrArg (fun W : AmbientCurrentWindow e => W.1.1) + (currentArrayWindow_iterate e j m i (actualArrayMap e t J X)) + change currentOffsets e j (StationaryCompact.shift^[i] (actualArrayMap e t J X)) = + currentOffsets e (j+i) (actualArrayMap e t J X) at h + rw [h] + exact actual_currentOffsets e t J X (j+i) + apply currentWindowInclude_injective e + rw [currentWindowInclude_typed e j m _ hc,currentArrayWindow_iterate,currentArrayWindow_actual] + +lemma rawCurrentOccupation_actual {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (hst : ∀ (i : ℤ) (n : ℕ), MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | t ω i=n}) + (filler : Environment d) (N m : ℕ) (M : Environment d → ℕ) + (hact : ∀ (i : ℕ) ω, t ω i t ω i) (fun i => ht i) filler N m).map + (rawCurrentProjection e) = + (actualOccupationRaw e ν Q t J ht N M).map (typedCurrentArrayWindow e 0 m) := by + rw [rawCurrentOccupation_projected e ν Q t ht hst filler N m] + unfold actualOccupationRaw StationaryCompact.episodeOccupationRaw + rw [Measure.map_finset_sum (typedCurrentArrayWindow_measurable e 0 m).aemeasurable] + apply Finset.sum_congr rfl + intro i _ + have hA : {X : EpisodeInput e | t X.1.1 i StationaryCompact.shift^[i] (actualArrayMap e t J X)) := + (StationaryCompact.shift_continuous.measurable.iterate i).comp (actualArrayMap_measurable e t J ht hJ) + rw [hA,Measure.map_map (typedCurrentArrayWindow_measurable e 0 m) hm] + congr 1 + funext X + exact ((typedCurrentArrayWindow_iterate_actual e t J 0 m i X).trans (by simp)).symm + +namespace Entropy +lemma normalize_map_measure {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + [Nonempty X] [Nonempty Y] (μ : FiniteMeasure X) (f : X → Y) (hf : Measurable f) + (hμ : μ≠0) : + let ν : FiniteMeasure Y := ⟨(μ : Measure X).map f,inferInstance⟩ + (ν.normalize : Measure Y) = (μ.normalize : Measure X).map f := by + let ν : FiniteMeasure Y := ⟨(μ : Measure X).map f,inferInstance⟩ + have hm : ν.mass=μ.mass := by + change ((μ : Measure X).map f Set.univ).toNNReal = _ + rw [Measure.map_apply hf MeasurableSet.univ,Set.preimage_univ] + rfl + have hν : ν≠0 := by + rw [← ν.mass_nonzero_iff,hm] + exact μ.mass_nonzero_iff.mpr hμ + change (ν.normalize : Measure Y)=_ + rw [ν.toMeasure_normalize_eq_of_nonzero hν,μ.toMeasure_normalize_eq_of_nonzero hμ,hm, + Measure.map_smul _ hf.aemeasurable] + rfl + +lemma normalize_maps_equal {X Y Z : Type*} [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z] + [Nonempty X] [Nonempty Y] [Nonempty Z] + (μ : FiniteMeasure X) (ν : FiniteMeasure Y) (f : X → Z) (g : Y → Z) + (hf : Measurable f) (hg : Measurable g) (hμ : μ≠0) (hν : ν≠0) + (h : (μ : Measure X).map f = (ν : Measure Y).map g) : + (μ.normalize : Measure X).map f = (ν.normalize : Measure Y).map g := by + rw [←normalize_map_measure μ f hf hμ,←normalize_map_measure ν g hg hν] + have he : (⟨(μ : Measure X).map f,inferInstance⟩ : FiniteMeasure Z) = + ⟨(ν : Measure Y).map g,inferInstance⟩ := Subtype.ext h + rw [he] + +lemma real_mass_eq_of_maps_equal {X Y Z : Type*} + [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z] + (μ : Measure X) (ν : Measure Y) (f : X → Z) (g : Y → Z) + (hf : Measurable f) (hg : Measurable g) (h : μ.map f=ν.map g) : + μ.real Set.univ=ν.real Set.univ := by + have hh := congrArg (fun ρ : Measure Z => ρ.real Set.univ) h + simpa only [Measure.real,Measure.map_apply hf MeasurableSet.univ, + Measure.map_apply hg MeasurableSet.univ,Set.preimage_univ] using hh +end Entropy + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/PairHeight.lean b/lean/OAI/Probability/Ballisticity/Geometry/PairHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca33c0f2c7467d738d46d8ec1f6b6bf10024b273 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/PairHeight.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferFirstFailure +import OAI.Probability.Ballisticity.Estimates.PairUpwardRetention + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma rawPairEndpointLaw_height {d : ℕ} (e : Direction d) (H : ℕ) + (ω : Environment d) (x : Lattice d × Lattice d) (a : ℝ) + (hx : x ∈ PairAtHeight (realPosition (step e)) a) : + ∀ᵐ y ∂rawPairEndpointLaw (realPosition (step e)) H ω x, + y ∈ PairAtHeight (realPosition (step e)) (a+H) := by + have hfinite (z : Lattice d) : IsFiniteMeasure + (hitKernel (Strip (realPosition (step e)) z H) (Upper (realPosition (step e)) z H) (ω,z)) := + ⟨lt_of_le_of_lt (hitKernel_total_le_one (disjoint_strip_upper _ _ _) _) ENNReal.one_lt_top⟩ + let := hfinite x.2 + rw [rawPairEndpointLaw,Measure.ae_prod_iff_ae_ae (Set.to_countable _ |>.measurableSet)] + filter_upwards [coordinate_hitKernel_supported e x.1 H ω] with y hy + filter_upwards [coordinate_hitKernel_supported e x.2 H ω] with z hz + constructor + · change dot (realPosition y) (realPosition (step e)) = a+H + rw [signedHeight_projection] + have h := hx.1 + rw [signedHeight_projection] at h + rw [←h] + exact_mod_cast hy + · change dot (realPosition z) (realPosition (step e)) = a+H + rw [signedHeight_projection] + have h := hx.2 + rw [signedHeight_projection] at h + rw [←h] + exact_mod_cast hz + +lemma rawPairMixture_height {d : ℕ} (e : Direction d) (H : ℕ) + (ω : Environment d) (π : Measure (Lattice d × Lattice d)) (a : ℝ) + (hπ : ∀ᵐ x ∂π, x ∈ PairAtHeight (realPosition (step e)) a) : + ∀ᵐ y ∂rawPairMixture (realPosition (step e)) H π ω, + y ∈ PairAtHeight (realPosition (step e)) (a+H) := by + rw [ae_iff,rawPairMixture_apply] + apply (lintegral_eq_zero_iff (measurable_of_countable _)).mpr + filter_upwards [hπ] with x hx + exact (ae_iff.mp (rawPairEndpointLaw_height e H ω x a hx)) + +lemma retainedPairLaw_height {d : ℕ} (e f : Direction d) (H : ℕ) (z : ℝ) + (ω : Environment d) (π : Measure (Lattice d × Lattice d)) (a : ℝ) + (hπ : ∀ᵐ x ∂π, x ∈ PairAtHeight (realPosition (step e)) a) : + ∀ᵐ y ∂retainedPairLaw (realPosition (step e)) f H z π ω, + y ∈ PairAtHeight (realPosition (step e)) (a+H) := + (Measure.absolutelyContinuous_of_le (retainedPairLaw_le _ _ _ _ _ _)).ae_le + (rawPairMixture_height e H ω π a hπ) + +lemma pairUp_height {d : ℕ} (e : Direction d) (x : Lattice d × Lattice d) (a : ℝ) + (hx : x ∈ PairAtHeight (realPosition (step e)) a) : + pairUp e x ∈ PairAtHeight (realPosition (step e)) (a+1) := by + constructor <;> simp only [pairUp,dot_realPosition_add,signed_direction_unit] + · rw [hx.1] + · rw [hx.2] + +lemma upwardRetainedLaw_height {d : ℕ} (e f : Direction d) (H : ℕ) (z : ℝ) + (ω : Environment d) (π : Measure (Lattice d × Lattice d)) (κ : ℝ≥0) (a : ℝ) + (hπ : ∀ᵐ x ∂π, x ∈ PairAtHeight (realPosition (step e)) a) : + ∀ᵐ y ∂upwardRetainedLaw e f H z π ω κ, + y ∈ PairAtHeight (realPosition (step e)) (a+(H+1:ℕ)) := by + unfold upwardRetainedLaw + apply Measure.ae_smul_measure + rw [ae_map_iff (measurable_of_countable _).aemeasurable (Set.to_countable _ |>.measurableSet)] + filter_upwards [retainedPairLaw_height e f H z ω π a hπ] with x hx + have := pairUp_height e x (a+H) hx + simpa only [Nat.cast_add,Nat.cast_one,add_assoc] using this +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/RawMedianTubeSingleSite.lean b/lean/OAI/Probability/Ballisticity/Geometry/RawMedianTubeSingleSite.lean new file mode 100644 index 0000000000000000000000000000000000000000..a67fb646271dc66144cc0381a37c286bc494cff5 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/RawMedianTubeSingleSite.lean @@ -0,0 +1,234 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.SuccessfulAverageTubeTransfer +import OAI.Probability.Ballisticity.Coupling.QuenchedConditionalProbability + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem raw_median_tube_single_site {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {w : ℝ} (hw : 0 < w) (hw1 : w ≤ 10) : + ∃ C : ℝ, 0 < C ∧ ∀ t : ℝ, 0 < t → ∃ δ : ℝ, 0 < δ ∧ δ < 1/4 ∧ + ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → + ∀ H : ℕ, (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let A := MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (w*r) + (environmentLaw ν).real {ω | (quenchedKernel (ω,0)).real (Aᶜ ∩ NoDrop ℓ 0) < 2*δ} ≤ C*t := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + obtain ⟨C,hC,hbound⟩ := quenched_median_tube_short_uniform ν hue e f hef htrans hw hw1 + refine ⟨1+2*C,by positivity,?_⟩ + intro t ht + have hpos : ∀ᵐ ω ∂environmentLaw ν, 0 < (noDropQuenched ℓ 0 ω).toReal := by + filter_upwards [quenched_noDrop_positive_of_directionallyTransient ν hue ℓ (signed_direction_unit e) htrans] with ω hq + exact ENNReal.toReal_pos (ne_of_gt (hq 0)) (measure_ne_top _ _) + obtain ⟨δ,hδ,hδ1,hquant⟩ := positive_lower_quantile (environmentLaw ν) + (fun ω => (noDropQuenched ℓ 0 ω).toReal) (measurable_noDropQuenched ℓ 0).ennreal_toReal hpos ht + obtain ⟨R,hR,hRbound⟩ := hbound t ht + refine ⟨δ,hδ,hδ1,R,hR,?_⟩ + intro r hr H hH + let A := MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (w*r) + have hb := quenched_good_mass_bad_probability ν hue ℓ (signed_direction_unit e) htrans A + (measurableSet_medianTubeFailure ℓ f _ H _) hδ + have htu := hRbound r hr H hH + change (quenchedConditionedAverage ν ℓ).real A ≤ C*t at htu + change (environmentLaw ν).real {ω | (quenchedKernel (ω,0)).real (Aᶜ ∩ NoDrop ℓ 0) < 2*δ} ≤ (1+2*C)*t + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/RawWindow.lean b/lean/OAI/Probability/Ballisticity/Geometry/RawWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6dbaeaf780a43a450493d8e6fd7d79e92cf9683 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/RawWindow.lean @@ -0,0 +1,126 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.LocalStoppedSplice +import OAI.Probability.Ballisticity.Entropy.WindowProjectionEntropy +import OAI.Probability.Ballisticity.Entropy.AnchorEntropy +import OAI.Probability.Ballisticity.Estimates.SamplingRearrangement +import OAI.Probability.Ballisticity.Entropy.StoppedEntropySum + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +abbrev RawCurrentData {d : ℕ} (e : Direction d) := + ℕ × (Environment d × (ℕ → HorizontalSpace e)) + +noncomputable def rawCurrentWindow {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) (Q : Measure (Environment d)) + (τ σ : Environment d → ℕ) (hτ : Measurable τ) (filler : Environment d) : + Measure (RawCurrentData e × LocalUpperField e) := + (((Q.compProd (currentAnchorKernel e τ hτ)).prod + (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν))).map + (fun p => ((τ p.1.1, + (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) τ filler p.1.1,p.1.2)), + localStoppedField e τ σ (p.1.1,p.2)))) + +lemma sampled_stoppedWindow_law {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω ≤ σ ω) + (hτ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | τ ω=n}) + (hσ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | σ ω=n}) + (filler : Environment d) : + let G := stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) τ filler + let K := currentAnchorKernel e τ (measurable_of_stop_events _ τ hτ) + (((Q.compProd K).prod (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν))).map + (fun p => ((G p.1.1,p.1.2),localStoppedField e τ σ (p.1.1,p.2)))) = + (((Kernel.id.prod K) ∥ₖ Kernel.id) ∘ₘ stoppedWindowLaw e ν Q τ σ filler) := by + let S : ℕ → Set (Lattice d) := fun n => BelowHeight (realPosition (step e)) n + let G := stoppedObservation S τ filler + let K := currentAnchorKernel e τ (measurable_of_stop_events S τ hτ) + have hG := stoppedObservation_measurable S τ hτ filler + have hK : K.comap G hG = K := by + ext ω : 1 + exact currentAnchorKernel_observation e τ hτ filler ω + have h := StoppedWindow.sample_lower_map Q + (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν)) G hG + (localStoppedField e τ σ) + (localStoppedField_measurable e τ σ (measurable_of_stop_events S τ hτ) + (measurable_of_stop_events S σ hσ)) K + rw [hK, localStoppedField_law e ν Q τ σ hτσ hτ hσ filler] at h + exact h + +lemma rawCurrentWindow_measurable {d : ℕ} (e : Direction d) + (τ σ : Environment d → ℕ) + (hτ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | τ ω=n}) + (hσ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | σ ω=n}) + (filler : Environment d) : + Measurable (fun p : (Environment d × (ℕ → HorizontalSpace e)) × LocalUpperField e => + ((τ p.1.1,(stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) + τ filler p.1.1,p.1.2)),localStoppedField e τ σ (p.1.1,p.2))) := by + let S : ℕ → Set (Lattice d) := fun n => BelowHeight (realPosition (step e)) n + have hw : Measurable (fun p : (Environment d × (ℕ → HorizontalSpace e)) × LocalUpperField e => p.1.1) := + measurable_fst.comp measurable_fst + exact ((measurable_of_stop_events S τ hτ).comp hw).prodMk + (((stoppedObservation_measurable S τ hτ filler).comp hw).prodMk + (measurable_snd.comp measurable_fst)) |>.prodMk + ((localStoppedField_measurable e τ σ (measurable_of_stop_events S τ hτ) + (measurable_of_stop_events S σ hσ)).comp (hw.prodMk measurable_snd)) + +theorem rawCurrentWindow_kl_le {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsProbabilityMeasure Q] + (τ σ : Environment d → ℕ) (hτσ : ∀ ω, τ ω ≤ σ ω) + (hτ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | τ ω=n}) + (hσ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | σ ω=n}) + (filler : Environment d) : + let μ := rawCurrentWindow e ν Q τ σ (measurable_of_stop_events _ τ hτ) filler + klDiv μ (μ.fst.prod (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν))) ≤ + ownedWindowEntropy e ν Q τ σ filler := by + let S : ℕ → Set (Lattice d) := fun n => BelowHeight (realPosition (step e)) n + let G := stoppedObservation S τ filler + let K := currentAnchorKernel e τ (measurable_of_stop_events S τ hτ) + let π := Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν) + let μ := stoppedWindowLaw e ν Q τ σ filler + let μ' : Measure ((Environment d × (ℕ → HorizontalSpace e)) × LocalUpperField e) := + (((Kernel.id.prod K) ∥ₖ (Kernel.id : Kernel (LocalUpperField e) (LocalUpperField e))) ∘ₘ μ) + have : IsFiniteMeasure μ := by unfold μ stoppedWindowLaw; infer_instance + have : IsFiniteMeasure μ' := by unfold μ'; infer_instance + let dat : Environment d × (ℕ → HorizontalSpace e) → RawCurrentData e := fun p => (τ p.1,p) + have hdat : Measurable dat := ((measurable_of_stop_events S τ hτ).comp measurable_fst).prodMk measurable_id + have hproj := klDiv_map_le μ' (μ'.fst.prod π) (hdat.prodMap measurable_id) + have hfst := StoppedWindow.map_data_field_fst μ' dat hdat + (fun (_ : Environment d × (ℕ → HorizontalSpace e)) (ξ : LocalUpperField e) => ξ) measurable_snd + change (μ'.map (Prod.map dat id)).fst = μ'.fst.map dat at hfst + have hout : μ'.map (Prod.map dat id) = + rawCurrentWindow e ν Q τ σ (measurable_of_stop_events S τ hτ) filler := by + dsimp only [μ', μ, K] + rw [← sampled_stoppedWindow_law e ν Q τ σ hτσ hτ hσ filler] + rw [Measure.map_map (hdat.prodMap measurable_id)] + · congr 1 + funext p + have ht : τ (G p.1.1) = τ p.1.1 := stoppedRowGraft_stop S τ hτ p.1.1 filler + exact Prod.ext (Prod.ext ht rfl) rfl + · exact (((stoppedObservation_measurable S τ hτ filler).comp + (measurable_fst.comp measurable_fst)).prodMk (measurable_snd.comp measurable_fst)).prodMk + ((localStoppedField_measurable e τ σ (measurable_of_stop_events S τ hτ) + (measurable_of_stop_events S σ hσ)).comp + ((measurable_fst.comp measurable_fst).prodMk measurable_snd)) + have href : (μ'.fst.prod π).map (Prod.map dat id) = + (μ'.map (Prod.map dat id)).fst.prod π := by + rw [← Measure.map_prod_map _ _ hdat measurable_id, Measure.map_id] + rw [hfst] + rw [href, hout] at hproj + refine hproj.trans ?_ + have h := StoppedWindow.parallel_lower_kl_le μ π (Kernel.id.prod K) + rw [stoppedWindowLaw_fst e ν Q τ σ hτ hσ filler] at h + exact h + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/RecordIndexPrefixHeight.lean b/lean/OAI/Probability/Ballisticity/Geometry/RecordIndexPrefixHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..96c3b5a905e3a8292924e51a821e8818a0ae62a1 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/RecordIndexPrefixHeight.lean @@ -0,0 +1,450 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.StoppedTubeEndpoint + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma recordIndexPrefix_height {d : ℕ} (e : Direction d) (X : Path d) (h0 : X 0=0) + (hnn : ∀ n, ∃ g, X (n+1)=X n+step g) (s n : ℕ) + (hX : X ∈ RecordIndexPrefix (realPosition (step e)) s n) : + signedHeight e (X n) = (s:ℤ) := by + have hs (j : ℕ) : signedHeight e (X (j+1)) ≤ signedHeight e (X j)+1 := by + obtain ⟨g,hg⟩ := hnn j + rw [hg] + exact signedHeight_step_le e _ g + have hh := recordCount_eq_height_at_record (realPosition (step e)) (signedHeight e) + (signedHeight_projection e) X hs hX.2.1 + rw [hX.2.2.1,h0,show signedHeight e (0:Lattice d)=0 by simp [signedHeight],zero_add] at hh + exact hh + +lemma tubePrefixAt_top_witness {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z : ℝ) (s n : ℕ) (X : Path d) (h0 : X 0=x) + (hnn : ∀ n, ∃ g, X (n+1)=X n+step g) + (hX : X ∈ TubePrefixAt (realPosition (step e)) f x θ z s n) : + (fun k => X k-x) ∈ RecordOrZeroPrefix (realPosition (step e)) s n ∧ + |signedCoordinate f (X n-x)-(s:ℝ)*θ| ≤ z := by + obtain ⟨a,ha,hrec,hgood⟩ := hX.2 s le_rfl + have he : a=n := by + by_cases hs : s=0 + · have ha0 : a=0 := by simpa [RecordOrZeroPrefix,hs] using hrec + have hn0 : n=0 := by + by_contra hn + have hh := hX.1.2 0 (Nat.pos_of_ne_zero hn) + change dot (realPosition x) (realPosition (step e)) ≤ dot (realPosition (X 0)) (realPosition (step e)) ∧ + dot (realPosition (X 0)) (realPosition (step e)) < dot (realPosition x) (realPosition (step e))+(s:ℝ) at hh + rw [hs,Nat.cast_zero,add_zero] at hh + exact (not_lt_of_ge hh.1) hh.2 + exact ha0.trans hn0.symm + · have hrec' : (fun k => X k-x) ∈ RecordIndexPrefix (realPosition (step e)) s a := by + simpa only [RecordOrZeroPrefix,ite_eq_right hs] using hrec + have hha := recordIndexPrefix_height e (fun k => X k-x) (by rw [h0,sub_self]) + (fun k => by obtain ⟨g,hg⟩ := hnn k; exact ⟨g,by rw [hg]; abel⟩) s a hrec' + have hhreal : dot (realPosition (X a)) (realPosition (step e)) = + dot (realPosition x) (realPosition (step e))+(s:ℝ) := by + have hh : dot (realPosition (X a-x)) (realPosition (step e))=(s:ℝ) := by + rw [signedHeight_projection,hha]; norm_cast + rw [dot_realPosition_sub] at hh + linarith + by_contra han + have hh := (hX.1.2 a (lt_of_le_of_ne ha han)).2 + change dot (realPosition (X a)) (realPosition (step e)) < + dot (realPosition x) (realPosition (step e))+(s:ℝ) at hh + rw [hhreal] at hh + exact lt_irrefl _ hh + exact ⟨by simpa only [he] using hrec,by simpa only [he] using hgood⟩ + +lemma tubePrefixAt_top_deviation {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z : ℝ) (s n : ℕ) (X : Path d) (h0 : X 0=x) + (hnn : ∀ n, ∃ g, X (n+1)=X n+step g) + (hX : X ∈ TubePrefixAt (realPosition (step e)) f x θ z s n) : + |signedCoordinate f (X n-x)-(s:ℝ)*θ| ≤ z := + (tubePrefixAt_top_witness e f x θ z s n X h0 hnn hX).2 + +lemma tubeEndpoint_deviation {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) (ω : Environment d) : + ∀ᵐ y ∂tubeEndpoint (realPosition (step e)) f x θ z s ω, + |signedCoordinate f (y-x)-(s:ℝ)*θ| ≤ z := by + rw [ae_iff,tubeEndpoint_apply] + apply ENNReal.tsum_eq_zero.mpr; intro n + apply measure_eq_zero_iff_ae_notMem.mpr + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + rintro ⟨hbad,hTube⟩ + exact hbad (tubePrefixAt_top_deviation e f x θ z s n X h0 hnn hTube) + +lemma signedCoordinate_add_distinct_step {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (x : Lattice d) : signedCoordinate f (x+step e) = signedCoordinate f x := by + simp only [signedCoordinate,Pi.add_apply,step] + have hfe : f.1 ≠ e.1 := Ne.symm hef + simp only [ite_eq_right hfe,add_zero] + +lemma directBridge_deviation {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (x : Lattice d) (θ z : ℝ) (s : ℕ) (ω : Environment d) : + ∀ᵐ y ∂directBridge e (tubeEndpoint (realPosition (step e)) f x θ z s ω) ω, + |signedCoordinate f (y-x)-((s:ℝ)+1)*θ| ≤ z+|θ| := by + rw [ae_iff,directBridge,Measure.sum_apply _ (Set.to_countable _ |>.measurableSet)] + apply ENNReal.tsum_eq_zero.mpr; intro y + by_cases hy : |signedCoordinate f (y-x)-(s:ℝ)*θ| ≤ z + · have he : |signedCoordinate f (y+step e-x)-((s:ℝ)+1)*θ| ≤ z+|θ| := by + have he : y+step e-x = (y-x)+step e := by abel + rw [he,signedCoordinate_add_distinct_step e f hef] + calc + _ = |(signedCoordinate f (y-x)-(s:ℝ)*θ)-θ| := by congr 1; ring + _ ≤ |signedCoordinate f (y-x)-(s:ℝ)*θ|+|θ| := abs_sub _ _ + _ ≤ z+|θ| := by linarith + simp only [Measure.smul_apply,smul_eq_mul] + rw [Measure.dirac_apply,Set.indicator_of_notMem (show y+step e ∉ + {v | ¬ |signedCoordinate f (v-x)-((s:ℝ)+1)*θ| ≤ z+|θ|} from fun hh => hh he),mul_zero] + · have hz : tubeEndpoint (realPosition (step e)) f x θ z s ω {y}=0 := + measure_mono_null (show {y} ⊆ {v | ¬ |signedCoordinate f (v-x)-(s:ℝ)*θ| ≤ z} from + fun v hv => by simpa only [Set.mem_singleton_iff.mp hv,Set.mem_ofPred_eq] using hy) + (ae_iff.mp (tubeEndpoint_deviation e f x θ z s ω)) + simp only [hz,mul_zero,zero_smul] + rfl + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma tubePrefix_zero_of_initial {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (θ z : ℝ) (hz : 0 ≤ z) (X : Path d) (h0 : X 0=x) : + X ∈ TubePrefix ℓ f x θ z 0 := by + apply Set.mem_iUnion.mpr + refine ⟨0,⟨⟨?_,fun i hi => by omega⟩,?_⟩⟩ + · simpa only [Upper,Set.mem_ofPred_eq,Nat.cast_zero,add_zero,h0] using le_rfl + · intro j hj + have hj0 : j=0 := by omega + subst j + refine ⟨0,le_rfl,by simp [RecordOrZeroPrefix],?_⟩ + simpa [h0,signedCoordinate] using hz + +lemma tubePrefixMass_zero {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (hz : 0 ≤ z) (π : Measure (Lattice d)) (ω : Environment d) : + tubePrefixMass ℓ f θ z 0 π ω = π Set.univ := by + have he (x : Lattice d) : quenchedKernel (ω,x) (TubePrefix ℓ f x θ z 0)=1 := by + calc + _ = quenchedKernel (ω,x) Set.univ := by + apply measure_congr + filter_upwards [quenched_initial_ae (ω,x)] with X hX + exact propext (iff_of_true (tubePrefix_zero_of_initial ℓ f x θ z hz X hX) (Set.mem_univ X)) + _ = 1 := measure_univ + simp only [tubePrefixMass,he,lintegral_const,one_mul] + +lemma stoppedTubeEndpoint_total {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (hz : 0 ≤ z) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + stoppedTubeEndpoint ℓ f θ z s π ω Set.univ = tubePrefixMass ℓ f θ z s π ω := by + unfold stoppedTubeEndpoint + split_ifs with hs + · subst s + exact (tubePrefixMass_zero ℓ f θ z hz π ω).symm + · exact tubeEndpointMixture_total ℓ f θ z s π ω + +lemma firstThreat_previous_mass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a θ z δ : ℝ) (hδ : δ ≤ 1) (s : ℕ) (π : Measure (Lattice d)) [IsProbabilityMeasure π] + (hπ : ∀ᵐ x ∂π, dot (realPosition x) ℓ = a) (ω : Environment d) + (hthreat : ω ∈ FirstTubeThreat ℓ f a θ z δ s π) : + ENNReal.ofReal δ ≤ stoppedTubeEndpoint ℓ f θ z (s-1) π ω Set.univ := by + by_cases hs : s-1=0 + · simp only [stoppedTubeEndpoint,hs,ite_eq_left,measure_univ] + exact ENNReal.ofReal_le_one.mpr hδ + · have hh := hthreat.2.2 (s-1) (Nat.pos_of_ne_zero hs) (Nat.sub_lt hthreat.1 (by decide)) + rw [tubeLayerMass_eq ℓ f a θ z (s-1) π hπ ω] at hh + simp only [stoppedTubeEndpoint,hs] + rw [← tubeEndpointMixture_total] at hh + have h := ENNReal.ofReal_le_ofReal hh + rwa [ENNReal.ofReal_toReal (measure_ne_top _ _)] at h + +lemma firstThreat_bridge_mass {d : ℕ} (e f : Direction d) + (a θ z δ : ℝ) (hδ : δ ≤ 1) (s : ℕ) (π : Measure (Lattice d)) [IsProbabilityMeasure π] + (hπ : ∀ᵐ x ∂π, dot (realPosition x) (realPosition (step e)) = a) + (ω : Environment d) (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).1 e) + (hthreat : ω ∈ FirstTubeThreat (realPosition (step e)) f a θ z δ s π) : + (κ:ℝ≥0∞)*ENNReal.ofReal δ ≤ + directBridge e (stoppedTubeEndpoint (realPosition (step e)) f θ z (s-1) π ω) ω Set.univ := by + exact (mul_le_mul' le_rfl (firstThreat_previous_mass _ f a θ z δ hδ s π hπ ω hthreat)).trans + (directBridge_total_lower e _ ω κ (ae_of_all _ hκ)) + +lemma noThreat_mass_lower {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a θ z δ : ℝ) (hz : 0 ≤ z) (hδ : δ ≤ 1) (H : ℕ) (π : Measure (Lattice d)) [IsProbabilityMeasure π] + (hπ : ∀ᵐ x ∂π, dot (realPosition x) ℓ = a) (ω : Environment d) + (hthreat : (π,ω) ∉ TubeThreat ℓ f a θ z δ H) {s : ℕ} (hs : s ≤ H) : + ENNReal.ofReal δ ≤ tubePrefixMass ℓ f θ z s π ω := by + by_cases hs0 : s=0 + · subst s + rw [tubePrefixMass_zero ℓ f θ z hz π ω,measure_univ] + exact ENNReal.ofReal_le_one.mpr hδ + · have hh : δ ≤ (tubeLayerMass ℓ f a θ z s π ω).toReal := + not_lt.mp fun hh => hthreat ⟨s,Nat.pos_of_ne_zero hs0,hs,hh⟩ + rw [tubeLayerMass_eq ℓ f a θ z s π hπ ω,← tubeEndpointMixture_total] at hh + have h := ENNReal.ofReal_le_ofReal hh + rw [ENNReal.ofReal_toReal (measure_ne_top _ _),tubeEndpointMixture_total] at h + exact h + +lemma normalized_tubePrefixMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (μ : Measure (Lattice d)) [IsFiniteMeasure μ] + (x₀ : Lattice d) (ω : Environment d) : + tubePrefixMass ℓ f θ z s μ ω = + μ Set.univ * tubePrefixMass ℓ f θ z s (probabilityNormalize μ x₀) ω := by + have hh := probabilityNormalize_mass μ x₀ + nth_rw 1 [← hh] + exact lintegral_smul_measure _ _ + +lemma firstThreat_noSecond_retained_mass {d : ℕ} (e f : Direction d) + (a : ℤ) (x₀ : Lattice d) (hx₀ : signedHeight e x₀=a) + (θ z δ : ℝ) (hz : 0 ≤ z) (hδ : δ ≤ 1) (H s : ℕ) (_hs : s ≤ H) + (π : Measure (Lattice d)) [IsProbabilityMeasure π] + (hπ : ∀ᵐ x ∂π, signedHeight e x=a) (ω : Environment d) + (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).1 e) + (hfirst : ω ∈ FirstTubeThreat (realPosition (step e)) f a θ z δ s π) + (hsecond : (bridgedRestart e f x₀ θ z π s ω,ω) ∉ + TubeThreat (realPosition (step e)) f ((a:ℝ)+s) θ z δ H) : + (κ:ℝ≥0∞)*ENNReal.ofReal δ*ENNReal.ofReal δ ≤ + tubePrefixMass (realPosition (step e)) f θ z (H-s) + (directBridge e (stoppedTubeEndpoint (realPosition (step e)) f θ z (s-1) π ω) ω) ω := by + let ℓ := realPosition (step e) + let μ := directBridge e (stoppedTubeEndpoint ℓ f θ z (s-1) π ω) ω + have hs0 : s ≠ 0 := Nat.ne_of_gt hfirst.1 + have hπ' : ∀ᵐ x ∂π, dot (realPosition x) ℓ = (a:ℝ) := + hπ.mono fun x hx => by rw [signedHeight_projection,hx] + have hρP := bridgedRestart_probability e f x₀ θ z π s ω + let := hρP + have hρsupp : ∀ᵐ x ∂bridgedRestart e f x₀ θ z π s ω, + dot (realPosition x) ℓ = (a:ℝ)+s := by + filter_upwards [bridgedRestart_supported e f x₀ a hx₀ θ z π hπ s ω] with y hy + rw [signedHeight_projection,hy,Int.cast_add,Int.cast_natCast] + have hlower := noThreat_mass_lower ℓ f ((a:ℝ)+s) θ z δ hz hδ H + (bridgedRestart e f x₀ θ z π s ω) hρsupp ω hsecond (Nat.sub_le H s) + have hμ := firstThreat_bridge_mass e f a θ z δ hδ s π hπ' ω κ hκ hfirst + rw [normalized_tubePrefixMass ℓ f θ z (H-s) μ (x₀+s • step e) ω] + have he : bridgedRestart e f x₀ θ z π s ω = probabilityNormalize μ (x₀+s • step e) := by + simp only [bridgedRestart,hs0,μ,ℓ,ite_false] + rw [he] at hlower + exact mul_le_mul' hμ hlower + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/RestrictedWindow.lean b/lean/OAI/Probability/Ballisticity/Geometry/RestrictedWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..feaa05a7cb337ff4f0945c2b3f1e2facbf40c4c2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/RestrictedWindow.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.OccupationEntropy2 + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical BigOperators +namespace DirectionalTransience + +lemma actualCurrentWindow_restricted_law {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (i : ℤ) (m N : ℕ) + (hi : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | t ω i=n}) + (him : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | t ω (i+m)=n}) + (filler : Environment d) : + ((rawCurrentWindow e ν Q (fun ω => t ω i) (fun ω => t ω (i+m)) (ht i) filler).restrict + {p | p.1.1 t ω i) + (hst : ∀ (i : ℤ) (n : ℕ), MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | t ω i=n}) + (filler : Environment d) (N m : ℕ) : + (rawCurrentOccupation e ν Q (fun i ω => t ω i) (fun i => ht i) filler N m).map + (rawCurrentProjection e) = + ∑ i ∈ Finset.range N, ((episodeInputLaw e ν Q t ht).restrict {X | t X.1.1 i + {w | B*a*i < wordRadius w ∧ wordHeightGain ℓ w ≤ i} + have he (i : ℕ) : μ.real {X | regenerationWords ℓ X (i-1) ∈ A i} = + μ.real {X | firstWord ℓ X ∈ A i} := by + exact congrArg ENNReal.toReal ((regenerationWords_identDistrib ν ℓ htrans (i-1)).measure_mem_eq + (Set.to_countable (A i)).measurableSet) + have hb := independent_rare_words_lower_bound μ S + (fun i => {X | regenerationWords ℓ X (i-1) ∈ A i}) (fun i => WordTemplate ℓ c C C0 a (i-1)) + (fun i => (Set.to_countable (A i)).measurableSet.preimage (measurable_regenerationWord ℓ (i-1))) + (fun i => measurableSet_wordTemplate ℓ c C C0 a (i-1)) (4/5) + (by + intro i hi + have hiN : i-1 ≤ N := by have := Finset.mem_Ico.mp hi; omega + have hgp := hg.trans (measureReal_mono (μ := μ) (wordTemplate_antitone ℓ c C C0 a hiN)) + rw [current_word_template_independent ν ℓ htrans c C C0 a (i-1) (A i), mul_comm] + exact mul_le_mul_of_nonneg_left hgp measureReal_nonneg) + (by + intro i hi j hj hij + have hh := ((regenerationWords_independent ν ℓ htrans).indepFun + (show i-1 ≠ j-1 by have := Finset.mem_Ico.mp hi; have := Finset.mem_Ico.mp hj; omega)).measure_inter_preimage_eq_mul + (A i) (A j) (Set.to_countable _).measurableSet (Set.to_countable _).measurableSet + exact congrArg ENNReal.toReal hh |>.trans ENNReal.toReal_mul) + simp_rw [he] at hb + apply polynomial_lower_from_small_intensity hB hη hηsmall hlow hupper + simpa only [A, S, μ, Set.mem_ofPred_eq, and_assoc] using hb + +lemma large_regeneration_word_excursion {d : ℕ} (ℓ : Vector d) (X : Path d) + (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (c C C0 a B : ℝ) (ha : 0 ≤ a) (i : ℕ) (hi : 1 ≤ i) + (hlarge : B*a*i < wordRadius (regenerationWords ℓ X (i-1))) + (hL : wordHeightGain ℓ (regenerationWords ℓ X (i-1)) ≤ i) + (hT : X ∈ WordTemplate ℓ c C C0 a (i-1)) + (hC0 : C*(i-1)+C0+i ≤ (C+2)*i) : + ∃ n, (B-1)*a*i < ‖latticeVector (X n)‖ ∧ + ∀ j ≤ n, 0 ≤ dot (realPosition (X j)) ℓ ∧ + dot (realPosition (X j)) ℓ ≤ (C+2)*i := by + obtain ⟨j,hj,he⟩ := wordRadius_attained (regenerationWords ℓ X (i-1)) + let n := regenerationTimes ℓ X (i-1) + j + have hi' : i-1+1 = i := by omega + have hcast : ((i-1 : ℕ) : ℝ) = i-1 := by rw [Nat.cast_sub hi]; norm_num + have hsum := hT (i-1) le_rfl + have hcut : ‖latticeVector (X (regenerationTimes ℓ X (i-1)))‖ ≤ a*(i-1) := by + exact (regeneration_radius_sum ℓ X h0 hX (i-1)).trans (by simpa only [hcast] using hsum.2.2) + have htriangle : wordRadius (regenerationWords ℓ X (i-1)) ≤ + ‖latticeVector (X n)‖ + ‖latticeVector (X (regenerationTimes ℓ X (i-1)))‖ := by + have he' := regeneration_span ℓ X h0 hX (i-1) j hj + have he'' : wordPath 0 (regenerationWords ℓ X (i-1)) j = + X n-X (regenerationTimes ℓ X (i-1)) := by dsimp only [n]; rw [he']; abel + rw [he, he'', latticeVector_sub] + exact norm_sub_le _ _ + have hn : n ≤ regenerationTimes ℓ X i := by + rw [← hi', regenerationTimes_succ] + exact Nat.add_le_add_left hj _ + refine ⟨n, ?_, ?_⟩ + · nlinarith + · intro k hk + obtain ⟨hlo,hhi⟩ := regeneration_prefix_height ℓ X h0 hX (hk.trans hn) + refine ⟨hlo,hhi.trans ?_⟩ + rw [← hi', Finset.sum_range_succ, hi'] + have hs : (∑ j ∈ Finset.range (i-1), wordHeightGain ℓ (regenerationWords ℓ X j)) ≤ + C*(i-1)+C0 := by simpa only [hcast] using hsum.2.1 + linarith + +def signedCoordinate {d : ℕ} (e : Direction d) (x : Lattice d) : ℝ := + if e.2 then (x e.1 : ℝ) else -(x e.1 : ℝ) + +lemma signedCoordinate_add {d : ℕ} (e : Direction d) (x y : Lattice d) : + signedCoordinate e (x+y) = signedCoordinate e x + signedCoordinate e y := by + simp only [signedCoordinate, Pi.add_apply, Int.cast_add] + split <;> ring + +lemma signedCoordinate_abs_le_norm {d : ℕ} (e : Direction d) (x : Lattice d) : + |signedCoordinate e x| ≤ ‖latticeVector x‖ := by + have hh := PiLp.norm_apply_le (p := (2 : ℝ≥0∞)) (latticeVector x) e.1 + simpa only [signedCoordinate, apply_ite abs, abs_neg, ite_self, Real.norm_eq_abs, + latticeVector, realPosition] using hh + +lemma latticeVector_norm_le_sum_abs {d : ℕ} (x : Lattice d) : + ‖latticeVector x‖ ≤ ∑ i, |(x i : ℝ)| := by + have he : latticeVector x = ∑ i : Fin d, PiLp.single 2 i (x i : ℝ) := by + ext j + simp [latticeVector, realPosition] + rw [he] + simpa only [PiLp.norm_single, Real.norm_eq_abs] using + norm_sum_le (Finset.univ : Finset (Fin d)) (fun i => PiLp.single 2 i (x i : ℝ)) + +lemma exists_large_signedCoordinate {d : ℕ} (x : Lattice d) (r : ℝ) + (hlarge : (d : ℝ)*r < ‖latticeVector x‖) : ∃ e : Direction d, r < signedCoordinate e x := by + have hex : ∃ i : Fin d, r < |(x i : ℝ)| := by + by_contra! h + have hh := (latticeVector_norm_le_sum_abs x).trans (Finset.sum_le_sum (fun i _ => h i)) + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at hh + linarith + obtain ⟨i,hi⟩ := hex + by_cases hx : 0 ≤ (x i : ℝ) + · exact ⟨(i,true), by simpa [signedCoordinate, abs_of_nonneg hx] using hi⟩ + · exact ⟨(i,false), by simpa [signedCoordinate, abs_of_neg (lt_of_not_ge hx)] using hi⟩ + +lemma prefixMax_mono (z : ℕ → ℝ) : Monotone (prefixMax z) := by + apply monotone_nat_of_le_succ + intro n + exact le_max_left _ _ + +lemma prefixMax_le_iff (z : ℕ → ℝ) (n : ℕ) (r : ℝ) : + prefixMax z n ≤ r ↔ 0 ≤ r ∧ ∀ j < n, z j ≤ r := by + induction n with + | zero => simp [prefixMax] + | succ n ih => + simp only [prefixMax, max_le_iff, ih] + constructor + · rintro ⟨⟨hr,h⟩,hn⟩ + refine ⟨hr,fun j hj => ?_⟩ + rcases lt_or_eq_of_le (Nat.le_of_lt_succ hj) with hj' | rfl + · exact h j hj' + · exact hn + · rintro ⟨hr,h⟩ + exact ⟨⟨hr,fun j hj => h j (by omega)⟩,h n (by omega)⟩ + +lemma prefixMax_congr (z w : ℕ → ℝ) (n : ℕ) (h : ∀ j < n, z j = w j) : + prefixMax z n = prefixMax w n := by + induction n with + | zero => rfl + | succ n ih => rw [prefixMax, prefixMax, ih (fun j hj => h j (by omega)), h n (by omega)] + +noncomputable def runningHeight {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : ℝ := + prefixMax (fun j => dot (realPosition (X j)) ℓ) (n+1) + +lemma runningHeight_nonneg {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : + 0 ≤ runningHeight ℓ X n := prefixMax_nonneg _ _ + +lemma height_le_runningHeight {d : ℕ} (ℓ : Vector d) (X : Path d) {j n : ℕ} (hj : j ≤ n) : + dot (realPosition (X j)) ℓ ≤ runningHeight ℓ X n := le_prefixMax (j := j) (n := n+1) (fun k => dot (realPosition (X k)) ℓ) (by omega) + +lemma runningHeight_mono {d : ℕ} (ℓ : Vector d) (X : Path d) : Monotone (runningHeight ℓ X) := + fun _ _ h => prefixMax_mono _ (Nat.add_le_add_right h 1) + +lemma runningHeight_le {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) (r : ℝ) (hr : 0 ≤ r) + (h : ∀ j ≤ n, dot (realPosition (X j)) ℓ ≤ r) : runningHeight ℓ X n ≤ r := + (prefixMax_le_iff _ _ _).mpr ⟨hr,fun j hj => h j (Nat.le_of_lt_succ hj)⟩ + +lemma runningHeight_congr {d : ℕ} (ℓ : Vector d) {X Y : Path d} (n : ℕ) + (h : ∀ j ≤ n, X j = Y j) : runningHeight ℓ X n = runningHeight ℓ Y n := by + apply prefixMax_congr + intro j hj + rw [h j (Nat.le_of_lt_succ hj)] + +lemma measurable_runningHeight {d : ℕ} (ℓ : Vector d) (n : ℕ) : + Measurable (fun X : Path d => runningHeight ℓ X n) := by + have hh (k : ℕ) : Measurable (fun X : Path d => prefixMax + (fun j => dot (realPosition (X j)) ℓ) k) := by + induction k with + | zero => exact measurable_const + | succ k ih => exact ih.max (by unfold dot realPosition; fun_prop) + exact hh (n+1) + +noncomputable def tiltedCoordinate {d : ℕ} (ℓ : Vector d) (u : Direction d) + (b a : ℝ) (x : Lattice d) : ℝ := signedCoordinate u x + b*a*dot (realPosition x) ℓ + +noncomputable def heightRatio {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a : ℝ) + (X : Path d) (n : ℕ) : ℝ := tiltedCoordinate ℓ u b a (X n) / (a*(1+runningHeight ℓ X n)) + +lemma tiltedCoordinate_add {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a : ℝ) (x y : Lattice d) : + tiltedCoordinate ℓ u b a (x+y) = tiltedCoordinate ℓ u b a x + tiltedCoordinate ℓ u b a y := by + simp only [tiltedCoordinate, signedCoordinate_add, dot_realPosition_add] + ring + +lemma tiltedCoordinate_zero {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a : ℝ) : + tiltedCoordinate ℓ u b a 0 = 0 := by simp [tiltedCoordinate, signedCoordinate, dot, realPosition] + +lemma measurable_heightRatio {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a : ℝ) (n : ℕ) : + Measurable (fun X : Path d => heightRatio ℓ u b a X n) := by + unfold heightRatio + apply Measurable.div + · exact (measurable_of_countable (tiltedCoordinate ℓ u b a)).comp (measurable_pi_apply n) + · exact measurable_const.mul (measurable_const.add (measurable_runningHeight ℓ n)) + +def AdmissiblePrefix {d : ℕ} (n : ℕ) : Set (Path d) := + {X | X 0 = 0 ∧ ∀ j < n, ∃ e : Direction d, X (j+1) = X j+step e} + +def BoundedHeightPrefix {d : ℕ} (ℓ : Vector d) (H : ℝ) (n : ℕ) : Set (Path d) := + {X | ∀ j ≤ n, 0 ≤ dot (realPosition (X j)) ℓ ∧ dot (realPosition (X j)) ℓ ≤ H} + +def RatioExceed {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) (n : ℕ) : Set (Path d) := + AdmissiblePrefix n ∩ BoundedHeightPrefix ℓ H n ∩ {X | t < heightRatio ℓ u b a X n} + +def RatioHit {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) : Set (Path d) := + ⋃ n, RatioExceed ℓ u b a H t n + +def FirstRatioExceed {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) (n : ℕ) : Set (Path d) := + RatioExceed ℓ u b a H t n ∩ {X | ∀ j < n, heightRatio ℓ u b a X j ≤ t} + +lemma measurableSet_admissiblePrefix {d : ℕ} (n : ℕ) : MeasurableSet (AdmissiblePrefix (d := d) n) := by + simp only [AdmissiblePrefix, Set.ofPred_and, Set.ofPred_forall, Set.ofPred_exists] + refine (measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter ?_ + exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => MeasurableSet.iUnion fun e => by + exact measurableSet_eq_fun (measurable_pi_apply (j+1)) ((show Measurable (fun X : Path d => X j) from measurable_pi_apply j).add_const (step e)) + +lemma measurableSet_boundedHeightPrefix {d : ℕ} (ℓ : Vector d) (H : ℝ) (n : ℕ) : + MeasurableSet (BoundedHeightPrefix ℓ H n) := by + simp only [BoundedHeightPrefix, Set.ofPred_forall, Set.ofPred_and] + refine MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => ?_ + have hh : Measurable (fun X : Path d => dot (realPosition (X j)) ℓ) := by unfold dot realPosition; fun_prop + exact (measurableSet_le measurable_const hh).inter (measurableSet_le hh measurable_const) + +lemma measurableSet_ratioExceed {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) (n : ℕ) : + MeasurableSet (RatioExceed ℓ u b a H t n) := + ((measurableSet_admissiblePrefix n).inter (measurableSet_boundedHeightPrefix ℓ H n)).inter + (measurableSet_lt measurable_const (measurable_heightRatio ℓ u b a n)) + +lemma measurableSet_ratioHit {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) : + MeasurableSet (RatioHit ℓ u b a H t) := + MeasurableSet.iUnion fun n => measurableSet_ratioExceed ℓ u b a H t n + +lemma measurableSet_firstRatioExceed {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) (n : ℕ) : + MeasurableSet (FirstRatioExceed ℓ u b a H t n) := by + apply (measurableSet_ratioExceed ℓ u b a H t n).inter + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + measurableSet_le (measurable_heightRatio ℓ u b a j) measurable_const + +lemma admissiblePrefix_mono {d : ℕ} {m n : ℕ} (hmn : m ≤ n) : + AdmissiblePrefix (d := d) n ⊆ AdmissiblePrefix m := + fun _ h => ⟨h.1,fun j hj => h.2 j (hj.trans_le hmn)⟩ + +lemma boundedHeightPrefix_mono {d : ℕ} (ℓ : Vector d) (H : ℝ) {m n : ℕ} (hmn : m ≤ n) : + BoundedHeightPrefix ℓ H n ⊆ BoundedHeightPrefix ℓ H m := + fun _ h j hj => h j (hj.trans hmn) + +lemma ratioHit_eq_first {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) : + RatioHit ℓ u b a H t = ⋃ n, FirstRatioExceed ℓ u b a H t n := by + ext X + constructor + · intro hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + have hex : ∃ n, t < heightRatio ℓ u b a X n := ⟨n,hn.2⟩ + let k := Nat.find hex + have hk : k ≤ n := Nat.find_min' hex hn.2 + refine Set.mem_iUnion.mpr ⟨k,⟨⟨admissiblePrefix_mono hk hn.1.1, + boundedHeightPrefix_mono ℓ H hk hn.1.2⟩,Nat.find_spec hex⟩,?_⟩ + intro j hj + exact le_of_not_gt (Nat.find_min hex hj) + · intro hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + exact Set.mem_iUnion.mpr ⟨n,hn.1⟩ + +lemma firstRatioExceed_disjoint {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) : + Pairwise (fun n m => Disjoint (FirstRatioExceed ℓ u b a H t n) (FirstRatioExceed ℓ u b a H t m)) := by + intro n m hnm + apply Set.disjoint_left.mpr + rintro X ⟨hn,hprevn⟩ ⟨hm,hprevm⟩ + rcases lt_or_gt_of_ne hnm with h | h + · exact (not_le_of_gt hn.2) (hprevm n h) + · exact (not_le_of_gt hm.2) (hprevn m h) + +lemma ratioHit_antitone {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H : ℝ) {s t : ℝ} (hst : s ≤ t) : + RatioHit ℓ u b a H t ⊆ RatioHit ℓ u b a H s := by + intro X hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + exact Set.mem_iUnion.mpr ⟨n,hn.1,hst.trans_lt hn.2⟩ + +lemma firstRatioExceed_record {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a H t : ℝ) + (ha : 0 < a) (ht : 0 < t) (X : Path d) (n : ℕ) + (hX : X ∈ FirstRatioExceed ℓ u b a H t n) : + 0 < n ∧ ∀ j < n, tiltedCoordinate ℓ u b a (X j) < tiltedCoordinate ℓ u b a (X n) := by + have hd (j : ℕ) : 0 < a*(1+runningHeight ℓ X j) := mul_pos ha (by linarith [runningHeight_nonneg ℓ X j]) + have hn0 : 0 < n := by + by_contra h + have hn : n = 0 := by omega + have hz : heightRatio ℓ u b a X n = 0 := by + simp only [heightRatio, hn, hX.1.1.1.1, tiltedCoordinate_zero, zero_div] + have hh : t < heightRatio ℓ u b a X n := hX.1.2 + rw [hz] at hh + linarith + refine ⟨hn0,fun j hj => ?_⟩ + have hlo := (div_le_iff₀ (hd j)).mp (hX.2 j hj) + have hhi := (lt_div_iff₀ (hd n)).mp hX.1.2 + have hM := runningHeight_mono ℓ X hj.le + have hm := mul_le_mul_of_nonneg_left hM (mul_nonneg ht.le ha.le) + nlinarith + +lemma prefixDetermined_admissiblePrefix {d : ℕ} (n : ℕ) : + PrefixDetermined n (AdmissiblePrefix (d := d) n) := by + intro X Y hXY + simp only [AdmissiblePrefix, Set.mem_ofPred_eq] + rw [hXY 0 (by omega)] + apply and_congr Iff.rfl + apply forall_congr' + intro j + apply forall_congr' + intro hj + rw [hXY j (by omega), hXY (j+1) (by omega)] + +lemma prefixDetermined_boundedHeightPrefix {d : ℕ} (ℓ : Vector d) (H : ℝ) (n : ℕ) : + PrefixDetermined n (BoundedHeightPrefix ℓ H n) := by + intro X Y hXY + simp only [BoundedHeightPrefix, Set.mem_ofPred_eq] + exact forall_congr' fun j => forall_congr' fun hj => by rw [hXY j hj] + +lemma heightRatio_congr {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a : ℝ) {X Y : Path d} + (n : ℕ) (hXY : ∀ j ≤ n, X j = Y j) : heightRatio ℓ u b a X n = heightRatio ℓ u b a Y n := by + rw [heightRatio, heightRatio, hXY n le_rfl, runningHeight_congr ℓ n hXY] + +lemma prefixDetermined_firstRatioExceed {d : ℕ} (ℓ : Vector d) (u : Direction d) + (b a H t : ℝ) (n : ℕ) : PrefixDetermined n (FirstRatioExceed ℓ u b a H t n) := by + apply prefixDetermined_inter + · apply prefixDetermined_inter + · exact prefixDetermined_inter (prefixDetermined_admissiblePrefix n) + (prefixDetermined_boundedHeightPrefix ℓ H n) + · intro X Y hXY + simp only [Set.mem_ofPred_eq, heightRatio_congr ℓ u b a n hXY] + · intro X Y hXY + simp only [Set.mem_ofPred_eq] + exact forall_congr' fun j => forall_congr' fun hj => by + rw [heightRatio_congr ℓ u b a j (fun k hk => hXY k (by omega))] + +lemma firstRatioExceed_overshoot {d : ℕ} (ℓ : Vector d) (u : Direction d) + (hℓ : ∀ i, |ℓ i| ≤ 1) (b a H t : ℝ) (hb : 0 ≤ b) (ha : 1 ≤ a) (ht : 0 < t) + (X : Path d) (n : ℕ) (hX : X ∈ FirstRatioExceed ℓ u b a H t n) : + heightRatio ℓ u b a X n ≤ t+b+1 := by + have ha0 : 0 < a := by linarith + have hn := (firstRatioExceed_record ℓ u b a H t ha0 ht X n hX).1 + obtain ⟨e,he⟩ := hX.1.1.1.2 (n-1) (by omega) + have hn' : n-1+1 = n := by omega + rw [hn'] at he + have hs : signedCoordinate u (step e) ≤ 1 := + (le_abs_self _).trans ((signedCoordinate_abs_le_norm _ _).trans_eq (latticeVector_step_norm _)) + have hl : dot (realPosition (step e)) ℓ ≤ 1 := by + rw [dot_step] + split + · exact (le_abs_self _).trans (hℓ _) + · exact (neg_le_abs _).trans (hℓ _) + have hstep : tiltedCoordinate ℓ u b a (step e) ≤ 1+b*a := by + have hh := mul_le_mul_of_nonneg_left hl (mul_nonneg hb ha0.le) + dsimp only [tiltedCoordinate] + linarith + have hd (j : ℕ) : 0 < a*(1+runningHeight ℓ X j) := + mul_pos ha0 (by linarith [runningHeight_nonneg ℓ X j]) + have hprev := (div_le_iff₀ (hd (n-1))).mp (hX.2 (n-1) (by omega)) + have hm := mul_le_mul_of_nonneg_left (runningHeight_mono ℓ X (Nat.sub_le n 1)) + (mul_nonneg ht.le ha0.le) + have hend : tiltedCoordinate ℓ u b a (X n) ≤ + t*(a*(1+runningHeight ℓ X n)) + 1+b*a := by + rw [he, tiltedCoordinate_add] + nlinarith + apply (div_le_iff₀ (hd n)).mpr + have hm0 := runningHeight_nonneg ℓ X n + have hba := mul_nonneg hb ha0.le + have hprod := mul_nonneg (show 0 ≤ b*a+a by positivity) hm0 + nlinarith + +lemma annealed_prefix_avoiding_suffix {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (f : Path d) (n : ℕ) (hn : 0 < n) + (A : Set (Path d)) (hA : MeasurableSet A) + (hfresh : ∀ j < n, f j ≠ f n) + (havoid : ∀ X ∈ A, ∀ k, ∀ j < n, f n + X k ≠ f j) : + annealedLaw ν ((fun X : Path d => fun k => X (n+k)-f n) ⁻¹' A ∩ pathCylinder f n) = + annealedLaw ν (pathCylinder f n) * annealedLaw ν A := by + by_cases hf : f 0 = 0 + · let S : Set (Lattice d) := {y | ∃ j < n, y = f j} + let T : Set (Lattice d) := Sᶜ + let B : Set (Path d) := (fun X : Path d => fun k => X k-f n) ⁻¹' A + have hB : MeasurableSet B := hA.preimage (by fun_prop) + have hBT : B ⊆ Stay T := by + intro X hX k + rintro ⟨j,hj,hjk⟩ + have hh := havoid (fun k => X k-f n) hX k j hj + have he : f n + (X k-f n) = X k := by abel + rw [he, hjk] at hh + exact hh rfl + have hnT : f n ∈ T := by + rintro ⟨j,hj,hjn⟩ + exact hfresh j hj hjn.symm + have hS0 : (0 : Lattice d) ∈ S := ⟨0,hn,hf.symm⟩ + have hm : @Measurable _ _ (rowSigma S) _ + (fun ω : Environment d => quenchedKernel (ω,0) (pathCylinder f n)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_pathCylinder f n)).comp + (measurable_id.prodMk measurable_const)) S 0 hS0 + intro ω η hωη + exact pathCylinder_weight_locality S ω η hωη 0 f n (fun j hj => ⟨j,hj,rfl⟩) + rw [annealed_apply ν ((hA.preimage (by fun_prop)).inter (measurableSet_pathCylinder f n))] + have hh (ω : Environment d) : quenchedKernel (ω,0) + ((fun X : Path d => fun k => X (n+k)-f n) ⁻¹' A ∩ pathCylinder f n) = + quenchedKernel (ω,0) (pathCylinder f n) * quenchedKernel (ω,f n) B := + quenched_prefix_future ω 0 f hf n hB + simp_rw [hh] + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν disjoint_compl_right) hm + (measurable_quenched_stay_event_rows T (f n) hnT B hB hBT), + annealed_event_translation ν (f n) A hA, + ← annealed_apply ν (measurableSet_pathCylinder f n)] + · have hz : annealedLaw ν (pathCylinder f n) = 0 := by + rw [annealed_apply ν (measurableSet_pathCylinder f n)] + simp_rw [quenched_pathCylinder_zero _ _ _ hf n] + simp + rw [measure_mono_null Set.inter_subset_right hz, hz, zero_mul] + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/SignedHeight.lean b/lean/OAI/Probability/Ballisticity/Geometry/SignedHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3d86dc7e8c800dc1712de313873abea15d3e499 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/SignedHeight.lean @@ -0,0 +1,438 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.IntegerMedian + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +def signedHeight {d : ℕ} (e : Direction d) (x : Lattice d) : ℤ := + if e.2 then x e.1 else -x e.1 + +lemma signedHeight_projection {d : ℕ} (e : Direction d) (x : Lattice d) : + dot (realPosition x) (realPosition (step e)) = (signedHeight e x : ℝ) := by + rw [dot_signed_direction] + simp only [signedCoordinate,signedHeight,Int.cast_ite,Int.cast_neg] + +lemma signedHeight_step_le {d : ℕ} (e : Direction d) (x : Lattice d) (f : Direction d) : + signedHeight e (x+step f) ≤ signedHeight e x+1 := by + simp only [signedHeight,Pi.add_apply,step] + split <;> split <;> (try split) <;> omega + +theorem transverse_common_gaussian_marginal {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) (τ : ℝ≥0) : + letI : IsProbabilityMeasure (independentConditionedPairLaw ν (realPosition (step e))) := + independentConditionedPairLaw_probability ν _ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + TendstoInDistribution + (fun i P => realPartialSum (fun k => commonIncrementProcess (realPosition (step e)) f k P) + (⌊(τ:ℝ)*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)⌋₊) / r i) + atTop id (fun _ => independentConditionedPairLaw ν (realPosition (step e))) (gaussianReal 0 τ) := + independent_common_gaussian_marginal ν hue _ (signed_direction_unit e) htrans + (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + (independent_commonWordIncrement_nonzero ν hue e f hef htrans) r hr τ + +lemma max_fourth_increment {m a : ℝ} : + (max m |a|)^4-m^4 ≤ 2*|a| *((max m |a|)^3-m^3) := by + by_cases h : |a| ≤ m + · rw [max_eq_left h]; ring_nf; rfl + · rw [max_eq_right (le_of_not_ge h)] + have hp := mul_nonneg (mul_nonneg (abs_nonneg a) (sq_nonneg m)) + (sub_nonneg.mpr (le_of_not_ge h)) + nlinarith [sq_nonneg (|a|^2-m^2)] + +lemma partialSumMax_fourth_pathwise (X : ℕ → ℝ) (n : ℕ) : + (partialSumMax X n)^4 ≤ 2*(partialSumMax X n)^3*|realPartialSum X n|- + 2*∑ k ∈ Finset.range n, (partialSumMax X k)^3*absSlope (realPartialSum X k)*X k := by + induction n with + | zero => simp [partialSumMax] + | succ n ih => + have hincr := max_fourth_increment (m := partialSumMax X n) + (a := realPartialSum X (n+1)) + have hs := mul_le_mul_of_nonneg_left (abs_supporting (realPartialSum X n) (X n)) + (pow_nonneg (partialSumMax_nonneg X n) 3) + rw [← realPartialSum_succ] at hs + rw [Finset.sum_range_succ] + change (max (partialSumMax X n) |realPartialSum X (n+1)|)^4 ≤ _ + change _ ≤ 2*(max (partialSumMax X n) |realPartialSum X (n+1)|)^3 * |realPartialSum X (n+1)|-_ + nlinarith + +lemma partialSumMax_fourth_pathwise_bound (X : ℕ → ℝ) (n : ℕ) : + (partialSumMax X n)^4 ≤ 32*(realPartialSum X n)^4- + 4*∑ k ∈ Finset.range n, (partialSumMax X k)^3*absSlope (realPartialSum X k)*X k := by + have h := partialSumMax_fourth_pathwise X n + have hy : 2*(partialSumMax X n)^3*|realPartialSum X n| ≤ + (partialSumMax X n)^4/2+16*(realPartialSum X n)^4 := by + nlinarith [sq_nonneg ((partialSumMax X n)^2-4*partialSumMax X n*|realPartialSum X n|), + sq_nonneg ((partialSumMax X n)^2-8*(realPartialSum X n)^2), + sq_abs (realPartialSum X n)] + linarith + +lemma integrable_partialSumMax_pow {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n p : ℕ) : + Integrable (fun ω => (partialSumMax (fun k => X k ω) n)^p) μ := by + apply integrable_of_abs_bound μ _ ((measurable_partialSumMax X hX n).pow_const p) ((n*z)^p) + intro ω + rw [abs_of_nonneg (pow_nonneg (partialSumMax_nonneg _ _) _)] + exact pow_le_pow_left₀ (partialSumMax_nonneg _ _) (partialSumMax_bound _ hz (fun k => hbound k ω) n) p + +lemma integrable_realPartialSum_pow {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n p : ℕ) : + Integrable (fun ω => (realPartialSum (fun k => X k ω) n)^p) μ := by + apply integrable_of_abs_bound μ _ ((measurable_realPartialSum X hX n).pow_const p) ((n*z)^p) + intro ω + rw [abs_pow] + exact pow_le_pow_left₀ (abs_nonneg _) ((abs_partialSum_le_max _ _).trans + (partialSumMax_bound _ hz (fun k => hbound k ω) n)) p + +lemma absSlope_cube (t : ℝ) : (absSlope t)^3 = absSlope t := by + unfold absSlope + split <;> norm_num + +lemma independent_max_cube_transform {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) (n : ℕ) : + IndepFun (fun ω => (partialSumMax (fun k => X k ω) n)^3*absSlope (realPartialSum (fun k => X k ω) n)) + (X n) μ := by + have hh := (independent_max_transform μ X hX hind n).comp + (show Measurable (fun x : ℝ => x^3) by fun_prop) measurable_id + simpa only [Function.comp_def,mul_pow,absSlope_cube,id_eq] using hh + +lemma integral_partialSumMax_fourth_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hmean : ∀ k, ∫ ω, X k ω ∂μ = 0) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + (∫ ω, (partialSumMax (fun k => X k ω) n)^4 ∂μ) ≤ + 32*∫ ω, (realPartialSum (fun k => X k ω) n)^4 ∂μ := by + let C (k : ℕ) (ω : Ω) := (partialSumMax (fun j => X j ω) k)^3*absSlope (realPartialSum (fun j => X j ω) k) + have hC (k : ℕ) : Measurable (C k) := ((measurable_partialSumMax X hX k).pow_const 3).mul + (measurable_absSlope.comp (measurable_realPartialSum X hX k)) + have hCI (k : ℕ) : Integrable (fun ω => C k ω*X k ω) μ := by + apply integrable_of_abs_bound μ _ ((hC k).mul (hX k)) ((k*z)^3*z) + intro ω + dsimp [C] + rw [abs_mul,abs_mul,abs_absSlope,mul_one,abs_of_nonneg (pow_nonneg (partialSumMax_nonneg _ _) _)] + exact mul_le_mul (pow_le_pow_left₀ (partialSumMax_nonneg _ _) + (partialSumMax_bound _ hz (fun j => hbound j ω) k) 3) (hbound k ω) + (abs_nonneg _) (pow_nonneg (mul_nonneg (Nat.cast_nonneg _) hz) 3) + have hzero (k : ℕ) : ∫ ω, C k ω*X k ω ∂μ = 0 := by + rw [(independent_max_cube_transform μ X hX hind k).integral_fun_mul_eq_mul_integral + (hC k).aestronglyMeasurable (hX k).aestronglyMeasurable,hmean,mul_zero] + have hm := integral_mono (integrable_partialSumMax_pow μ X hX hz hbound n 4) + (((integrable_realPartialSum_pow μ X hX hz hbound n 4).const_mul 32).sub + ((integrable_finsetSum (Finset.range n) (fun k _ => hCI k)).const_mul 4)) + (fun ω => partialSumMax_fourth_pathwise_bound (fun k => X k ω) n) + simp only [Pi.sub_apply] at hm + rw [integral_sub ((integrable_realPartialSum_pow μ X hX hz hbound n 4).const_mul 32) + ((integrable_finsetSum (Finset.range n) (fun k _ => hCI k)).const_mul 4), + integral_const_mul,integral_const_mul,integral_finsetSum _ (fun k _ => hCI k)] at hm + simpa only [hzero,Finset.sum_const_zero,mul_zero,sub_zero] using hm + +lemma independent_partialSum_current {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) (n : ℕ) : + IndepFun (fun ω => realPartialSum (fun k => X k ω) n) (X n) μ := by + have hh := (independent_past_current μ X hX hind n).comp + (show Measurable (fun v : Fin n → ℝ => ∑ k, v k) by fun_prop) measurable_id + convert hh using 1 + · funext ω + exact (Fin.sum_univ_eq_sum_range (fun k => X k ω) n).symm + · rfl + +lemma integrable_pow_mul_of_abs_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F G : Ω → ℝ) + (hF : Measurable F) (hG : Measurable G) {a b : ℝ} + (ha : ∀ ω, |F ω| ≤ a) (hb : ∀ ω, |G ω| ≤ b) (p q : ℕ) : + Integrable (fun ω => F ω^p*G ω^q) μ := by + apply integrable_of_abs_bound μ _ (by fun_prop) (a^p*b^q) + intro ω + rw [abs_mul,abs_pow,abs_pow] + exact mul_le_mul (pow_le_pow_left₀ (abs_nonneg _) (ha ω) p) + (pow_le_pow_left₀ (abs_nonneg _) (hb ω) q) (pow_nonneg (abs_nonneg _) _) + (pow_nonneg ((abs_nonneg (F ω)).trans (ha ω)) _) + +lemma integral_independent_add_fourth {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F G : Ω → ℝ) + (hF : Measurable F) (hG : Measurable G) (hind : IndepFun F G μ) + (hmF : ∫ ω, F ω ∂μ = 0) (hmG : ∫ ω, G ω ∂μ = 0) + {a b : ℝ} (ha : ∀ ω, |F ω| ≤ a) (hb : ∀ ω, |G ω| ≤ b) : + (∫ ω, (F ω+G ω)^4 ∂μ) = + (∫ ω, F ω^4 ∂μ)+6*(∫ ω, F ω^2 ∂μ)*(∫ ω, G ω^2 ∂μ)+(∫ ω, G ω^4 ∂μ) := by + have hI := integrable_pow_mul_of_abs_bound μ F G hF hG ha hb + have hF4 : Integrable (fun ω => F ω^4) μ := by simpa using hI 4 0 + have hG4 : Integrable (fun ω => G ω^4) μ := by simpa using hI 0 4 + have h31 : Integrable (fun ω => 4*(F ω^3*G ω^1)) μ := (hI 3 1).const_mul 4 + have h22 : Integrable (fun ω => 6*(F ω^2*G ω^2)) μ := (hI 2 2).const_mul 6 + have h13 : Integrable (fun ω => 4*(F ω^1*G ω^3)) μ := (hI 1 3).const_mul 4 + have hfactor (p q : ℕ) : (∫ ω, F ω^p*G ω^q ∂μ) = + (∫ ω, F ω^p ∂μ)*(∫ ω, G ω^q ∂μ) := + (hind.comp (by fun_prop : Measurable (fun x : ℝ => x^p)) + (by fun_prop : Measurable (fun x : ℝ => x^q))).integral_fun_mul_eq_mul_integral + (hF.pow_const p).aestronglyMeasurable (hG.pow_const q).aestronglyMeasurable + have heq : (fun ω => (F ω+G ω)^4) = + (fun ω => F ω^4+4*(F ω^3*G ω^1)+6*(F ω^2*G ω^2)+4*(F ω^1*G ω^3)+G ω^4) := by + ext ω; ring + have h12 : Integrable (fun ω => F ω^4+4*(F ω^3*G ω^1)) μ := hF4.add h31 + have h123 : Integrable (fun ω => F ω^4+4*(F ω^3*G ω^1)+6*(F ω^2*G ω^2)) μ := h12.add h22 + have h1234 : Integrable (fun ω => F ω^4+4*(F ω^3*G ω^1)+6*(F ω^2*G ω^2)+4*(F ω^1*G ω^3)) μ := h123.add h13 + rw [heq,integral_add h1234 hG4,integral_add h123 h13,integral_add h12 h22, + integral_add hF4 h31] + simp only [integral_const_mul] + rw [hfactor 3 1,hfactor 2 2,hfactor 1 3] + simp only [pow_one,hmF,hmG,mul_zero,zero_mul,add_zero] + ring + +lemma integral_iid_partialSum_fourth_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hmean : ∫ ω, X 0 ω ∂μ = 0) + {z : ℝ} (hz : 0 ≤ z) (hbound : ∀ k ω, |X k ω| ≤ z) (n : ℕ) : + (∫ ω, (realPartialSum (fun k => X k ω) n)^4 ∂μ) ≤ + n*(∫ ω, (X 0 ω)^4 ∂μ)+3*(n:ℝ)^2*(∫ ω, (X 0 ω)^2 ∂μ)^2 := by + have hmeans (k : ℕ) : ∫ ω, X k ω ∂μ = 0 := (hident k).integral_eq.trans hmean + have hpows (k p : ℕ) : (∫ ω, (X k ω)^p ∂μ) = (∫ ω, (X 0 ω)^p ∂μ) := + ((hident k).comp (u := fun x : ℝ => x^p) (by fun_prop)).integral_eq + have hsq (n : ℕ) : (∫ ω, (realPartialSum (fun k => X k ω) n)^2 ∂μ) = + n*(∫ ω, (X 0 ω)^2 ∂μ) := by + rw [integral_partialSum_square_eq_sum μ X hX hind hmeans hbound] + simp only [hpows,Finset.sum_const,Finset.card_range,nsmul_eq_mul] + have hsummean (n : ℕ) : ∫ ω, realPartialSum (fun k => X k ω) n ∂μ = 0 := by + rw [show (fun ω => realPartialSum (fun k => X k ω) n) = + (fun ω => ∑ k ∈ Finset.range n, X k ω) from rfl, + integral_finsetSum _ (fun k _ => integrable_of_abs_bound μ _ (hX k) z (hbound k))] + simp only [hmeans,Finset.sum_const_zero] + induction n with + | zero => simp [realPartialSum] + | succ n ih => + simp only [realPartialSum_succ] + rw [integral_independent_add_fourth μ _ _ (measurable_realPartialSum X hX n) (hX n) + (independent_partialSum_current μ X hX hind n) (hsummean n) (hmeans n) + (fun ω => (abs_partialSum_le_max _ _).trans (partialSumMax_bound _ hz (fun k => hbound k ω) n)) + (hbound n),hsq] + simp only [hpows] + push_cast + nlinarith [sq_nonneg (∫ ω, (X 0 ω)^2 ∂μ)] + +lemma integral_iid_truncated_max_fourth_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {z r : ℝ} (hz : 0 ≤ z) (hzr : z ≤ r) (n : ℕ) : + (∫ ω, (partialSumMax (fun k => symmetricTruncate z (X k ω)) n)^4 ∂μ) ≤ + 32*(n:ℝ)*z^2*truncatedVariance μ (X 0) r+ + 96*(n:ℝ)^2*(truncatedVariance μ (X 0) r)^2 := by + let Y := fun k ω => symmetricTruncate z (X k ω) + have hY (k : ℕ) : Measurable (Y k) := (measurable_symmetricTruncate z).comp (hX k) + have hYb := fun k ω => symmetricTruncate_bound hz (X k ω) + have hYi : iIndepFun Y μ := hind.comp (fun _ => symmetricTruncate z) (fun _ => measurable_symmetricTruncate z) + have hYid (k : ℕ) : IdentDistrib (Y k) (Y 0) μ μ := (hident k).comp (measurable_symmetricTruncate z) + have hYm : ∫ ω, Y 0 ω ∂μ = 0 := integral_symmetricTruncate_zero μ (X 0) z hsym + have hYmeans (k : ℕ) : ∫ ω, Y k ω ∂μ = 0 := (hYid k).integral_eq.trans hYm + have hI (p : ℕ) : Integrable (fun ω => (Y 0 ω)^p) μ := by + apply integrable_of_abs_bound μ _ ((hY 0).pow_const p) (z^p) + intro ω + rw [abs_pow] + exact pow_le_pow_left₀ (abs_nonneg _) (hYb 0 ω) p + have hvar : (∫ ω, (Y 0 ω)^2 ∂μ) ≤ truncatedVariance μ (X 0) r := by + apply integral_mono (hI 2) (integrable_truncated_square μ (X 0) (hX 0) r) + intro ω + exact (symmetricTruncate_sq_le z _).trans + (min_le_min le_rfl (pow_le_pow_left₀ hz hzr 2)) + have hfour : (∫ ω, (Y 0 ω)^4 ∂μ) ≤ z^2*(∫ ω, (Y 0 ω)^2 ∂μ) := by + rw [← integral_const_mul] + apply integral_mono (hI 4) ((hI 2).const_mul (z^2)) + intro ω + have hs : (Y 0 ω)^2 ≤ z^2 := by + nlinarith [sq_abs (Y 0 ω),hYb 0 ω,abs_nonneg (Y 0 ω)] + nlinarith [mul_le_mul_of_nonneg_right hs (sq_nonneg (Y 0 ω))] + have hv0 : 0 ≤ ∫ ω, (Y 0 ω)^2 ∂μ := integral_nonneg fun _ => sq_nonneg _ + calc + _ ≤ 32*(∫ ω, (realPartialSum (fun k => Y k ω) n)^4 ∂μ) := + integral_partialSumMax_fourth_le μ Y hY hYi hYmeans hz hYb n + _ ≤ 32*(n*(∫ ω, (Y 0 ω)^4 ∂μ)+3*(n:ℝ)^2*(∫ ω, (Y 0 ω)^2 ∂μ)^2) := + mul_le_mul_of_nonneg_left (integral_iid_partialSum_fourth_le μ Y hY hYi hYid hYm hz hYb n) (by norm_num) + _ ≤ 32*(n*(z^2*truncatedVariance μ (X 0) r)+3*(n:ℝ)^2*(truncatedVariance μ (X 0) r)^2) := by + gcongr + · exact hfour.trans (mul_le_mul_of_nonneg_left hvar (sq_nonneg z)) + _ = _ := by ring + +lemma measureReal_truncated_max_gt_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {z r a : ℝ} (hz : 0 ≤ z) (hzr : z ≤ r) (ha : 0 < a) (n : ℕ) : + μ.real {ω | a < partialSumMax (fun k => symmetricTruncate z (X k ω)) n} ≤ + (32*(n:ℝ)*z^2*truncatedVariance μ (X 0) r+ + 96*(n:ℝ)^2*(truncatedVariance μ (X 0) r)^2) / a^4 := by + let Y := fun k ω => symmetricTruncate z (X k ω) + have hY (k : ℕ) : Measurable (Y k) := (measurable_symmetricTruncate z).comp (hX k) + have hYb := fun k ω => symmetricTruncate_bound hz (X k ω) + have hb := mul_meas_ge_le_integral_of_nonneg + (Eventually.of_forall (fun ω => pow_nonneg (partialSumMax_nonneg (fun k => Y k ω) n) 4)) + (integrable_partialSumMax_pow μ Y hY hz hYb n 4) (a^4) + have hmono : μ.real {ω | a < partialSumMax (fun k => Y k ω) n} ≤ + μ.real {ω | a^4 ≤ (partialSumMax (fun k => Y k ω) n)^4} := by + apply measureReal_mono _ (measure_ne_top _ _) + intro ω hω + exact pow_le_pow_left₀ ha.le hω.le 4 + apply (le_div_iff₀ (pow_pos ha 4)).mpr + calc + _ ≤ a^4*μ.real {ω | a^4 ≤ (partialSumMax (fun k => Y k ω) n)^4} := by + simpa only [mul_comm] using mul_le_mul_of_nonneg_left hmono (pow_nonneg ha.le 4) + _ ≤ (∫ ω, (partialSumMax (fun k => Y k ω) n)^4 ∂μ) := hb + _ ≤ _ := integral_iid_truncated_max_fourth_le μ X hX hind hident hsym hz hzr n + +lemma measureReal_iid_max_gt_fourth_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) (hX : ∀ k, Measurable (X k)) + (hind : iIndepFun X μ) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + {z r a : ℝ} (hz : 0 ≤ z) (hzr : z ≤ r) (ha : 0 < a) (n : ℕ) : + μ.real {ω | a < partialSumMax (fun k => X k ω) n} ≤ + n*μ.real {ω | z < |X 0 ω|}+ + (32*(n:ℝ)*z^2*truncatedVariance μ (X 0) r+ + 96*(n:ℝ)^2*(truncatedVariance μ (X 0) r)^2) / a^4 := by + let A : ℕ → Set Ω := fun k => {ω | z < |X k ω|} + let B : Set Ω := {ω | a < partialSumMax (fun k => symmetricTruncate z (X k ω)) n} + have hsub : {ω | a < partialSumMax (fun k => X k ω) n} ⊆ + (⋃ k ∈ Finset.range n, A k) ∪ B := by + intro ω hω + by_cases ht : ω ∈ ⋃ k ∈ Finset.range n, A k + · exact Or.inl ht + · right + have hc : ∀ k < n, X k ω = symmetricTruncate z (X k ω) := by + intro k hk + have hnot : ¬ z < |X k ω| := fun h => ht (Set.mem_iUnion.mpr + ⟨k,Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr hk,h⟩⟩) + simp only [symmetricTruncate,ite_eq_left (le_of_not_gt hnot)] + change a < partialSumMax (fun k => symmetricTruncate z (X k ω)) n + rwa [← partialSumMax_congr n hc] + have htail (k : ℕ) : μ.real (A k) = μ.real (A 0) := by + exact congrArg ENNReal.toReal ((hident k).measure_mem_eq + (show MeasurableSet {x : ℝ | z < |x|} from measurableSet_lt measurable_const measurable_id.abs)) + calc + _ ≤ μ.real ((⋃ k ∈ Finset.range n, A k) ∪ B) := measureReal_mono hsub (measure_ne_top _ _) + _ ≤ μ.real (⋃ k ∈ Finset.range n, A k)+μ.real B := measureReal_union_le _ _ + _ ≤ (∑ k ∈ Finset.range n, μ.real (A k))+μ.real B := + add_le_add (measureReal_biUnion_finset_le _ _) le_rfl + _ = n*μ.real {ω | z < |X 0 ω|}+μ.real B := by + simp only [htail,Finset.sum_const,Finset.card_range,nsmul_eq_mul,A] + _ ≤ _ := add_le_add le_rfl (measureReal_truncated_max_gt_le μ X hX hind hident hsym hz hzr ha n) + +lemma gaussian_charFun_power_limit_count {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Ω → ℝ) (hS : Measurable S) + (hI : Integrable S μ) (hne : 0 < μ {x | S x ≠ 0}) + (hsym : IdentDistrib S (fun x => -S x) μ μ) (r : ℕ → ℝ) + (hr : IsGaussianSequence μ S r) (k : ℕ → ℕ) {τ : ℝ} + (hk : Tendsto (fun i => (k i : ℝ)/fluctuationScale μ S (r i)) atTop (𝓝 τ)) (t : ℝ) : + Tendsto (fun i => (charFun (μ.map S) (t/r i))^(k i)) + atTop (𝓝 (Complex.exp (-(τ*t^2/2 : ℝ)))) := by + have hn : Tendsto (fun i => fluctuationScale μ S (r i)) atTop atTop := + (fluctuationScale_tendsto μ S hS hI hne).comp hr.1 + have hd := gaussian_cosine_drift μ S hS hne r hr t + have hzero : Tendsto (fun i => (∫ x, Real.cos (t*(S x/r i)) ∂μ)-1) atTop (𝓝 0) := by + have hz := hd.mul (tendsto_inv_atTop_zero.comp hn) + simp only [mul_zero] at hz + apply hz.congr' + filter_upwards [hn.eventually (eventually_gt_atTop (0:ℝ))] with i hi + dsimp only [Function.comp_def] + field_simp + have ha : Tendsto (fun i => ∫ x, Real.cos (t*(S x/r i)) ∂μ) atTop (𝓝 1) := by + simpa using hzero.add_const 1 + have hdk : Tendsto (fun i => (k i : ℝ)* + ((∫ x, Real.cos (t*(S x/r i)) ∂μ)-1)) atTop (𝓝 (-(τ*t^2/2))) := by + have hc := hk.mul hd + have he : τ * (-(t^2/2)) = -(τ*t^2/2) := by ring + rw [he] at hc + apply hc.congr' + filter_upwards [hn.eventually (eventually_gt_atTop (0:ℝ))] with i hi + field_simp + convert (tendsto_pow_variable_of_drift ha hdk).ofReal using 1 + · ext i + rw [symmetric_charFun_cosine μ S hS hsym, ← Complex.ofReal_pow] + congr 2 + apply integral_congr_ae + filter_upwards [] with x + congr 1 + ring + · simp + +lemma charFun_independent_finite_blocks {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (k : ι → ℕ) (g : (j : ι) → Fin (k j) → ℕ) + (hg : Function.Injective (fun p : (j : ι) × Fin (k j) => g p.1 p.2)) (r : ℝ) + (t : EuclideanSpace ℝ ι) : + charFun (μ.map (fun ω => WithLp.toLp 2 (fun j => (∑ l, X (g j l) ω)/r))) t = + ∏ j, (charFun (μ.map (X 0)) (t j/r))^(k j) := by + classical + let Y (p : (j : ι) × Fin (k j)) (ω : Ω) := (t p.1/r)*X (g p.1 p.2) ω + have hY p : Measurable (Y p) := (hX _).const_mul _ + have hiY : iIndepFun Y μ := (hind.precomp hg).comp + (fun p x => (t p.1/r)*x) (fun _ => by fun_prop) + have heq : charFun (μ.map (fun ω => WithLp.toLp 2 (fun j => (∑ l, X (g j l) ω)/r))) t = + charFun (μ.map (fun ω => ∑ p, Y p ω)) 1 := by + rw [charFun, charFun, integral_map (by fun_prop) (by fun_prop), + integral_map (by fun_prop) (by fun_prop)] + apply integral_congr_ae + filter_upwards [] with ω + congr 2 + simp only [PiLp.inner_apply, RCLike.inner_apply, conj_trivial, + one_mul, Fintype.sum_sigma, Y] + congr 1 + apply Finset.sum_congr rfl + intro j _ + rw [← Finset.mul_sum] + ring + rw [heq,hiY.charFun_map_fun_sum_eq_prod (fun p => (hY p).aemeasurable)] + simp only [Finset.prod_apply] + rw [Fintype.prod_sigma] + apply Finset.prod_congr rfl + intro j _ + have hterm (l : Fin (k j)) : charFun (μ.map (Y ⟨j,l⟩)) 1 = + charFun (μ.map (X 0)) (t j/r) := by + dsimp [Y] + rw [charFun_map_mul_comp (hX _).aemeasurable,mul_one,(hident _).map_eq] + simp only [hterm,Finset.prod_const,Finset.card_univ,Fintype.card_fin] + +theorem gaussian_iid_finite_block_limit {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {x | X 0 x ≠ 0}) + (hsym : IdentDistrib (X 0) (fun x => -X 0 x) μ μ) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + (k : ℕ → ι → ℕ) (g : (i : ℕ) → (j : ι) → Fin (k i j) → ℕ) + (hg : ∀ i, Function.Injective (fun p : (j : ι) × Fin (k i j) => g i p.1 p.2)) + (τ : ι → ℝ≥0) + (hk : ∀ j, Tendsto (fun i => (k i j : ℝ)/fluctuationScale μ (X 0) (r i)) atTop (𝓝 (τ j : ℝ))) : + TendstoInDistribution + (fun i ω => WithLp.toLp 2 (fun j => (∑ l, X (g i j l) ω)/r i)) atTop + (WithLp.toLp 2 : (ι → ℝ) → EuclideanSpace ℝ ι) (fun _ => μ) + (Measure.pi (fun j => gaussianReal 0 (τ j))) where + forall_aemeasurable _ := by fun_prop + aemeasurable_limit := by fun_prop + tendsto := by + refine ProbabilityMeasure.tendsto_iff_tendsto_charFun.2 fun t => ?_ + change Tendsto (fun i => charFun (μ.map (fun ω => WithLp.toLp 2 (fun j => (∑ l, X (g i j l) ω)/r i))) t) + atTop (𝓝 (charFun ((Measure.pi (fun j => gaussianReal 0 (τ j))).map (WithLp.toLp 2)) t)) + simp only [charFun_independent_finite_blocks μ X hX hind hident _ _ (hg _) _,charFun_pi] + apply tendsto_finsetProd _ + intro j _ + simpa only [charFun_gaussianReal,Complex.ofReal_zero,mul_zero,zero_mul,zero_sub, + Complex.ofReal_neg,Complex.ofReal_div,Complex.ofReal_mul,Complex.ofReal_pow, + Complex.ofReal_ofNat] using + gaussian_charFun_power_limit_count μ (X 0) (hX 0) hI hne hsym r hr (fun i => k i j) (hk j) (t j) + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/SignedHeightSub.lean b/lean/OAI/Probability/Ballisticity/Geometry/SignedHeightSub.lean new file mode 100644 index 0000000000000000000000000000000000000000..9079109888a4de199761328d4d8dcaacc8574b21 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/SignedHeightSub.lean @@ -0,0 +1,198 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SharedConditionedPairLawFst + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma signedHeight_sub {d : ℕ} (e : Direction d) (x y : Lattice d) : + signedHeight e (x-y) = signedHeight e x-signedHeight e y := by + simp only [signedHeight,Pi.sub_apply] + split <;> omega + +theorem shared_path_marginal_limits {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let F := fun i => recordLinearPath ℓ f (recordMedianSlope ν ℓ hp f (r i)) (r i) + (fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i)) T + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + (∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw (T/(2*commonMeanWidth ν ℓ)) I) ∧ + ∀ x y : ℕ → Lattice d, (∀ i, signedHeight e (x i) = signedHeight e (y i)) → + letI : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ (x i) (y i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + TendstoInDistribution (fun i Z => F i (fun j => Z.1 j-x i)) + atTop id (fun i => sharedConditionedPairLaw ν ℓ (x i) (y i)) W ∧ + TendstoInDistribution (fun i Z => F i (fun j => Z.2 j-y i)) + atTop id (fun i => sharedConditionedPairLaw ν ℓ (x i) (y i)) W := by + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let F := fun i => recordLinearPath ℓ f (recordMedianSlope ν ℓ hp f (r i)) (r i) + (fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i)) T + have hF (i : ℕ) : Measurable (F i) := measurable_recordLinearPath _ _ _ _ _ _ + obtain ⟨W,hW,hlim⟩ := shared_first_zero_path_limit ν hue e f hef htrans r hr hT + have hfirst (x y : ℕ → Lattice d) (hxy : ∀ i, signedHeight e (x i) = signedHeight e (y i)) : + letI : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ (x i) (y i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + TendstoInDistribution (fun i Z => F i (fun j => Z.1 j-x i)) + atTop id (fun i => sharedConditionedPairLaw ν ℓ (x i) (y i)) W := by + let : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ (x i) (y i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + let : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ 0 (y i-x i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ 0 (y i-x i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans 0 (y i-x i))) + have hy : ∀ i, signedHeight e (y i-x i) = 0 := fun i => by rw [signedHeight_sub,← hxy i,sub_self] + have hm (i : ℕ) : (sharedConditionedPairLaw ν ℓ (x i) (y i)).map + (fun Z : Path d × Path d => ((fun j => Z.1 j-x i),(fun j => Z.2 j-x i))) = + sharedConditionedPairLaw ν ℓ 0 (y i-x i) := by + simpa only [add_zero,add_sub_cancel] using sharedConditionedPairLaw_translation ν ℓ (x i) 0 (y i-x i) + exact tendstoInDistribution_pullback _ _ _ (fun _ => by fun_prop) hm + (fun i Z => F i Z.1) (fun i => (hF i).comp measurable_fst) id W (hlim _ hy) + refine ⟨W,hW,fun x y hxy => ?_⟩ + let : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ (x i) (y i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ (x i) (y i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (x i) (y i))) + let : ∀ i, IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ (y i) (x i)) := fun i => + sharedConditionedPairLaw_probability ν ℓ (y i) (x i) + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans (y i) (x i))) + refine ⟨hfirst x y hxy,?_⟩ + exact tendstoInDistribution_pullback _ _ (fun _ => Prod.swap) (fun _ => measurable_swap) + (fun i => sharedConditionedPairLaw_swap ν ℓ (x i) (y i)) + (fun i Z => F i (fun j => Z.1 j-y i)) (fun i => (hF i).comp (by fun_prop)) id W + (hfirst y x (fun i => (hxy i).symm)) + +lemma joint_tight_of_marginal_limits {Ω Ω' E F : Type*} [MeasurableSpace Ω] [MeasurableSpace Ω'] + [MetricSpace E] [CompleteSpace E] [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] + [MetricSpace F] [CompleteSpace F] [MeasurableSpace F] [BorelSpace F] [SecondCountableTopology F] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (X : ℕ → Ω → E) (Y : ℕ → Ω → F) (hX : ∀ i, Measurable (X i)) (hY : ∀ i, Measurable (Y i)) + (G : Ω' → E) (H : Ω' → F) (W : Measure Ω') [IsProbabilityMeasure W] + (h₁ : TendstoInDistribution X atTop G μ W) (h₂ : TendstoInDistribution Y atTop H μ W) : + IsTightMeasureSet (Set.range (fun i => (μ i).map (fun ω => (X i ω,Y i ω)))) := by + have hx := distribution_sequence_tight μ X G W h₁ + have hy := distribution_sequence_tight μ Y H W h₂ + apply IsTightMeasureSet.prodMk + · convert hx using 1 + ext η + simp only [Set.mem_image,Set.mem_range,exists_exists_eq_and] + simp only [Measure.fst,Measure.map_map measurable_fst ((hX _).prodMk (hY _)),Function.comp_def] + · convert hy using 1 + ext η + simp only [Set.mem_image,Set.mem_range,exists_exists_eq_and] + simp only [Measure.snd,Measure.map_map measurable_snd ((hX _).prodMk (hY _)),Function.comp_def] + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/SignedStripTruncation.lean b/lean/OAI/Probability/Ballisticity/Geometry/SignedStripTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..02ce2f20e3356cbbf6b0807c0ad85eb81a75202a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/SignedStripTruncation.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OutwardCanonical + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma wordCylinder_signed_up_disjoint_stay {d : ℕ} (e : Direction d) + (x y : Lattice d) (H : ℕ) : + Disjoint (wordCylinder y (List.replicate H e)) + (StayUntil (Strip (realPosition (step e)) x H) H) := by + apply Set.disjoint_left.mpr + intro X hw hS + have hb := (hS 0 (Nat.zero_le H)).1 + have ht := (hS H le_rfl).2 + have hzero := hw 0 (by simp) + have hend := hw H (by simp) + rw [wordPath_replicate] at hend + rw [hzero,wordPath_zero] at hb + rw [hend,dot_realPosition_add,dot_realPosition_nsmul,dot_signed_direction e (step e),signedCoordinate_step_self,mul_one] at ht + linarith + +lemma quenched_signed_strip_block {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (e : Direction d) (x y : Lattice d) (H : ℕ) : + quenchedKernel (ω,y) (StayUntil (Strip (realPosition (step e)) x H) H) ≤ + 1-(κ:ℝ≥0∞)^H := by + have hsub := (wordCylinder_signed_up_disjoint_stay e x y H).subset_compl_left + calc + _ ≤ quenchedKernel (ω,y) (wordCylinder y (List.replicate H e))ᶜ := measure_mono hsub + _ = 1-ENNReal.ofReal (wordWeight ω y (List.replicate H e)) := by + rw [measure_compl (measurableSet_wordCylinder _ _) (measure_ne_top _ _),measure_univ,quenched_wordCylinder] + _ ≤ 1-(κ:ℝ≥0∞)^H := by + apply tsub_le_tsub_left + have hs := ENNReal.ofReal_le_ofReal (wordWeight_lower ω hκ y (List.replicate H e)) + simpa only [List.length_replicate,ENNReal.ofReal_pow κ.coe_nonneg,ENNReal.ofReal_coe_nnreal] using hs + +lemma quenched_signed_strip_geometric {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (e : Direction d) (x y : Lattice d) (H k : ℕ) : + quenchedKernel (ω,y) (StayUntil (Strip (realPosition (step e)) x H) (k*H)) ≤ + (1-(κ:ℝ≥0∞)^H)^k := + quenched_stayUntil_block_bound ω _ H _ (fun y => quenched_signed_strip_block ω hκ e x y H) y k + +lemma truncatedEndpointLaw_mass_error {d : ℕ} (ω : Environment d) {κ : ℝ≥0} + (hκ : ∀ y e, κ ≤ (ω y).1 e) (e : Direction d) (x : Lattice d) + {H : ℕ} (hH : 0 < H) (k : ℕ) : + hitKernel (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) (ω,x) Set.univ ≤ + truncatedEndpointLaw e H (k*H) ω x Set.univ+(1-(κ:ℝ≥0∞)^H)^k := by + rw [truncatedEndpointLaw_apply e hH,Set.inter_univ,hitKernel_total (disjoint_strip_upper _ _ _)] + exact (quenched_hit_truncation ω x _ _ _).trans + (add_le_add le_rfl (quenched_signed_strip_geometric ω hκ e x x H k)) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/SpatialConfinement.lean b/lean/OAI/Probability/Ballisticity/Geometry/SpatialConfinement.lean new file mode 100644 index 0000000000000000000000000000000000000000..081958c13e8c7538b3a13f7f38e9911b838d0f40 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/SpatialConfinement.lean @@ -0,0 +1,69 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ConfinementTemplates + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +def StripExcursion {d : ℕ} (ℓ : Vector d) (H R : ℝ) : Set (Path d) := + {X | ∃ n, X ∈ BoundedHeightPrefix ℓ H n ∧ ∃ u : Direction d, R < signedCoordinate u (X n)} + +lemma measurableSet_stripExcursion {d : ℕ} (ℓ : Vector d) (H R : ℝ) : + MeasurableSet (StripExcursion ℓ H R) := by + simp only [StripExcursion, Set.ofPred_exists, Set.ofPred_and] + apply MeasurableSet.iUnion + intro n + refine (measurableSet_boundedHeightPrefix ℓ H n).inter (MeasurableSet.iUnion fun u => ?_) + exact measurableSet_lt measurable_const ((measurable_of_countable (signedCoordinate u)).comp (measurable_pi_apply n)) + +lemma stripExcursion_subset_ratio {d : ℕ} (ℓ : Vector d) (X : Path d) + (h0 : X 0 = 0) (hNN : ∀ n, ∃ e : Direction d, X (n+1) = X n+step e) + (b a D : ℝ) (hb : 0 ≤ b) (ha : 1 ≤ a) (hD : 0 ≤ D) (N : ℕ) : + X ∈ StripExcursion ℓ N (a*(2*b+2+D)*(N+1)^2) → + X ∈ ⋃ u : Direction d, RatioHit ℓ u b a N (1+N*(2*b+1+D)) := by + rintro ⟨n,hn,u,hu⟩ + refine Set.mem_iUnion.mpr ⟨u,Set.mem_iUnion.mpr ⟨n,⟨⟨h0,fun j _ => hNN j⟩,hn⟩,?_⟩⟩ + have hm := runningHeight_le ℓ X n N (Nat.cast_nonneg _) (fun j hj => (hn j hj).2) + have hm0 := runningHeight_nonneg ℓ X n + have ht : 0 ≤ 1+(N:ℝ)*(2*b+1+D) := by positivity + have hfactor : 1+(N:ℝ)*(2*b+1+D) ≤ (2*b+2+D)*(N+1) := by nlinarith + have hbnd : (1+(N:ℝ)*(2*b+1+D))*(a*(1+runningHeight ℓ X n)) ≤ + a*(2*b+2+D)*(N+1)^2 := by + calc + _ ≤ (1+(N:ℝ)*(2*b+1+D))*(a*(1+N)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left (by linarith) (by linarith)) ht + _ ≤ ((2*b+2+D)*(N+1))*(a*(1+N)) := + mul_le_mul_of_nonneg_right hfactor (by positivity) + _ = _ := by ring + change _ < tiltedCoordinate ℓ u b a (X n)/(a*(1+runningHeight ℓ X n)) + apply (lt_div_iff₀ (mul_pos (by linarith) (by linarith))).mpr + have hz := mul_nonneg (mul_nonneg hb (show 0 ≤ a by linarith)) (hn n le_rfl).1 + dsimp only [tiltedCoordinate] + linarith + +theorem spatial_confinement {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ C ε : ℝ, 0 < C ∧ 0 < ε ∧ ε ≤ 1 ∧ ∀ N : ℕ, + (annealedLaw ν).real (StripExcursion (realPosition (step e)) N (C*(N+1)^2)) ≤ + (2*d : ℕ)*(1-ε)^N := by + obtain ⟨b,a,D,ε,hb,ha,hD,hε,hε1,hA⟩ := strip_templates ν hue e htrans + refine ⟨a*(2*b+2+D),ε,mul_pos (by linarith) (by linarith),hε,hε1,?_⟩ + intro N + obtain ⟨A,hAm,hAp,hAc⟩ := hA N + apply le_trans ?_ (ratio_hit_union_bound ν (realPosition (step e)) + (unit_direction_coordinate_bound _ (signed_direction_unit e)) b a D N ε hb ha hD hε.le hε1 A hAm hAp hAc N) + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [annealed_initial ν,annealed_nearest_neighbor ν] with X h0 hNN + exact stripExcursion_subset_ratio _ X h0 hNN b a D hb ha hD N + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/StoppedTubeEndpoint.lean b/lean/OAI/Probability/Ballisticity/Geometry/StoppedTubeEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6c87e0ff0a8053ee61014e8e04cb07119b4ca95 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/StoppedTubeEndpoint.lean @@ -0,0 +1,388 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.QuenchedRegularPathAe +import OAI.Probability.Ballisticity.Crossings.CoordinateHitExact + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def stoppedTubeEndpoint {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : Measure (Lattice d) := + if s=0 then π else tubeEndpointMixture ℓ f θ z s π ω + +instance stoppedTubeEndpoint_finite {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) [IsFiniteMeasure π] (ω : Environment d) : + IsFiniteMeasure (stoppedTubeEndpoint ℓ f θ z s π ω) := by + unfold stoppedTubeEndpoint + split_ifs <;> infer_instance + +lemma stoppedTubeEndpoint_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) + (hπ : ∀ᵐ x ∂π, dot (realPosition x) ℓ = a) : + @Measurable _ _ (rowSigma {y | dot (realPosition y) ℓ < a+s}) _ (stoppedTubeEndpoint ℓ f θ z s π) := by + change @Measurable _ _ (rowSigma {y | dot (realPosition y) ℓ < a+s}) _ + (fun ω => stoppedTubeEndpoint ℓ f θ z s π ω) + by_cases hs : s=0 + · simp only [stoppedTubeEndpoint,hs,ite_eq_left] + apply @measurable_const + · simp only [stoppedTubeEndpoint,hs] + exact tubeEndpointMixture_lower_rows ℓ f a θ z (Nat.pos_of_ne_zero hs) π hπ + +lemma stoppedTubeEndpoint_supported {d : ℕ} (e f : Direction d) (a : ℤ) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) + (hπ : ∀ᵐ x ∂π, signedHeight e x = a) (ω : Environment d) : + ∀ᵐ y ∂stoppedTubeEndpoint (realPosition (step e)) f θ z s π ω, + signedHeight e y = a+s := by + by_cases hs : s=0 + · simpa only [stoppedTubeEndpoint,hs,ite_eq_left,Nat.cast_zero,add_zero] using hπ + · simp only [stoppedTubeEndpoint,hs] + exact tubeEndpointMixture_supported e f a θ z s π hπ ω + +lemma signedHeight_add_nsmul_step {d : ℕ} (e : Direction d) (x : Lattice d) (s : ℕ) : + signedHeight e (x+s • step e) = signedHeight e x+s := by + induction s with + | zero => simp + | succ s ih => + rw [succ_nsmul,← add_assoc,signedHeight_add_step_self,ih] + simp only [Nat.cast_add,Nat.cast_one,add_assoc] + +noncomputable def bridgedRestart {d : ℕ} (e f : Direction d) (x₀ : Lattice d) + (θ z : ℝ) (π : Measure (Lattice d)) (s : ℕ) (ω : Environment d) : Measure (Lattice d) := + if s=0 then π else probabilityNormalize + (directBridge e (stoppedTubeEndpoint (realPosition (step e)) f θ z (s-1) π ω) ω) + (x₀+s • step e) + +lemma bridgedRestart_probability {d : ℕ} (e f : Direction d) (x₀ : Lattice d) + (θ z : ℝ) (π : Measure (Lattice d)) [IsProbabilityMeasure π] (s : ℕ) (ω : Environment d) : + IsProbabilityMeasure (bridgedRestart e f x₀ θ z π s ω) := by + unfold bridgedRestart + split_ifs + · infer_instance + · exact probabilityNormalize_probability _ _ + +lemma bridgedRestart_supported {d : ℕ} (e f : Direction d) (x₀ : Lattice d) (a : ℤ) + (hx₀ : signedHeight e x₀ = a) (θ z : ℝ) (π : Measure (Lattice d)) + (hπ : ∀ᵐ x ∂π, signedHeight e x = a) (s : ℕ) (ω : Environment d) : + ∀ᵐ y ∂bridgedRestart e f x₀ θ z π s ω, signedHeight e y = a+s := by + by_cases hs : s=0 + · simpa only [bridgedRestart,hs,ite_eq_left,Nat.cast_zero,add_zero] using hπ + · rw [bridgedRestart,ite_eq_right hs] + apply probabilityNormalize_supported + · rw [signedHeight_add_nsmul_step,hx₀] + · have hh := directBridge_supported e (a+(s-1:ℕ)) _ ω + (stoppedTubeEndpoint_supported e f a θ z (s-1) π hπ ω) + have he : a+((s-1:ℕ):ℤ)+1=a+s := by omega + rwa [he] at hh + +lemma bridgedRestart_rows {d : ℕ} (e f : Direction d) (x₀ : Lattice d) (a : ℤ) + (θ z : ℝ) (π : Measure (Lattice d)) + (hπ : ∀ᵐ x ∂π, signedHeight e x = a) (s : ℕ) : + @Measurable _ _ (rowSigma {y | dot (realPosition y) (realPosition (step e)) < (a:ℝ)+s}) _ + (bridgedRestart e f x₀ θ z π s) := by + let ℓ := realPosition (step e) + let S : Set (Lattice d) := {y | dot (realPosition y) ℓ < (a:ℝ)+s} + let : MeasurableSpace (Environment d) := rowSigma S + change Measurable (fun ω => bridgedRestart e f x₀ θ z π s ω) + by_cases hs : s=0 + · simp only [bridgedRestart,hs,ite_eq_left] + exact measurable_const + · simp only [bridgedRestart,hs] + apply measurable_probabilityNormalize + apply directBridge_rows e S + · have hp : ∀ᵐ x ∂π, dot (realPosition x) ℓ = (a:ℝ) := hπ.mono fun x hx => by + rw [signedHeight_projection,hx] + apply (stoppedTubeEndpoint_rows ℓ f a θ z (s-1) π hp).mono _ le_rfl + apply rowSigma_mono + intro y hy + have hc : ((s-1:ℕ):ℝ) ≤ s := by exact_mod_cast Nat.sub_le s 1 + change dot (realPosition y) ℓ < (a:ℝ)+s + change dot (realPosition y) ℓ < (a:ℝ)+(s-1:ℕ) at hy + linarith + · intro ω + filter_upwards [stoppedTubeEndpoint_supported e f a θ z (s-1) π hπ ω] with y hy + change dot (realPosition y) ℓ < (a:ℝ)+s + rw [signedHeight_projection,hy,Int.cast_add,Int.cast_natCast] + have hc : ((s-1:ℕ):ℝ) < s := by exact_mod_cast Nat.sub_lt (Nat.pos_of_ne_zero hs) (by decide : 0<1) + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem canonical_two_tube_threat {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {w : ℝ} (hw : 0 < w) (hw1 : w ≤ 20) : + ∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℝ, 0 < t₀ ∧ ∀ t : ℝ, 0 < t → t ≤ t₀ → + ∃ δ : ℝ, 0 < δ ∧ δ < 1/4 ∧ ∃ R : ℝ, 0 < R ∧ + ∀ r : ℝ, R ≤ r → ∀ H : ℕ, 0 < H → + (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := (recordMedian ν ℓ hp f H:ℝ)/H + |θ| ≤ w*r ∧ ∀ (a : ℤ) (x₀ : Lattice d), signedHeight e x₀ = a → + ∀ π : Measure (Lattice d), IsProbabilityMeasure π → + (∀ᵐ x ∂π, signedHeight e x = a) → + (environmentLaw ν).real (⋃ s ∈ Finset.range (H+1), + {ω | ω ∈ FirstTubeThreat ℓ f a θ (w*r) δ s π ∧ + (bridgedRestart e f x₀ θ (w*r) π s ω,ω) ∈ TubeThreat ℓ f ((a:ℝ)+s) θ (w*r) δ H}) ≤ C*t^2 := by + obtain ⟨D,hD,t₀,ht₀,hb⟩ := slope_tube_single_threat ν hue e f hef htrans hw hw1 + refine ⟨D^2,sq_pos_of_pos hD,t₀,ht₀,?_⟩ + intro t ht htt + obtain ⟨δ,hδ,hδ1,R,hR,hb⟩ := hb t ht htt + refine ⟨δ,hδ,hδ1,R,hR,?_⟩ + intro r hr H hH hscale + obtain ⟨hθ,hb⟩ := hb r hr H hH hscale + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := (recordMedian ν ℓ hp f H:ℝ)/H + refine ⟨hθ,?_⟩ + intro a x₀ hx₀ π hπ hsupp + let := hπ + have hsection (b : ℤ) (η : Measure (Lattice d)) (hη : IsProbabilityMeasure η) + (hηsupp : ∀ᵐ x ∂η, signedHeight e x = b) : + environmentLaw ν {ω | (η,ω) ∈ TubeThreat ℓ f b θ (w*r) δ H} ≤ ENNReal.ofReal (D*t) := by + have hsupp' : ∀ᵐ x ∂η, dot (realPosition x) ℓ = (b:ℝ) := + hηsupp.mono fun x hx => by rw [signedHeight_projection,hx] + have hh := (tubeThreat_probability_le ν ℓ f b θ (w*r) δ H η hsupp').trans (hb η hη) + have h := ENNReal.ofReal_le_ofReal hh + rwa [Measure.real,ENNReal.ofReal_toReal (measure_ne_top _ _)] at h + have hh := two_tube_threat_bound ν ℓ f a θ (w*r) δ H π + (bridgedRestart e f x₀ θ (w*r) π) + (fun s => bridgedRestart_rows e f x₀ a θ (w*r) π hsupp s) (ENNReal.ofReal (D*t)) + (hsection a π hπ hsupp) (by + intro s hs η hη + have h := hsection (a+s) (bridgedRestart e f x₀ θ (w*r) π s η) + (bridgedRestart_probability e f x₀ θ (w*r) π s η) + (bridgedRestart_supported e f x₀ a hx₀ θ (w*r) π hsupp s η) + simpa only [Int.cast_add,Int.cast_natCast] using h) + have hh' := ENNReal.toReal_mono (ENNReal.mul_ne_top ENNReal.ofReal_ne_top ENNReal.ofReal_ne_top) hh + rw [ENNReal.toReal_mul,ENNReal.toReal_ofReal (mul_nonneg hD.le ht.le)] at hh' + calc + _ ≤ D*t*(D*t) := hh' + _ = D^2*t^2 := by ring + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/StripTimeTail.lean b/lean/OAI/Probability/Ballisticity/Geometry/StripTimeTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a32079a2ddedee2340a2271a715cc4f3a35cae6 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/StripTimeTail.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.StripExitBound +import OAI.Probability.Ballisticity.Crossings.CrossingGapDecay + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma strip_box_card_bound {d : ℕ} (m H : ℕ) (hH : 0 < H) : + (latticeBox (d := d) (m*H^2)).card ≤ (2*m+1)^d*H^(2*d) := by + rw [card_latticeBox] + calc + _ ≤ ((2*m+1)*H^2)^d := Nat.pow_le_pow_left (by nlinarith [sq_pos_of_pos hH]) _ + _ = _ := by rw [mul_pow,← pow_mul] + +lemma upward_probability_bound (N : ℕ) (κ : ℝ) (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) : + (1-κ*((N+1:ℕ):ℝ)^(-(1/2:ℝ)))^(N+1) ≤ + Real.exp (-κ*((N+1:ℕ):ℝ)^(1/2:ℝ)) := by + have hn : (0:ℝ) < (N+1:ℕ) := by positivity + have h1 : (1:ℝ) ≤ (N+1:ℕ) := by exact_mod_cast Nat.succ_le_succ (Nat.zero_le N) + have ha := Real.rpow_le_one_of_one_le_of_nonpos h1 (by norm_num : -(1/2:ℝ) ≤ 0) + have hb : κ*((N+1:ℕ):ℝ)^(-(1/2:ℝ)) ≤ 1 := + (mul_le_of_le_one_left (by positivity) hκ1).trans ha + calc + _ ≤ (Real.exp (- (κ*((N+1:ℕ):ℝ)^(-(1/2:ℝ)))))^(N+1) := + pow_le_pow_left₀ (by linarith) (Real.one_sub_le_exp_neg _) _ + _ = _ := by + rw [← Real.exp_nat_mul] + congr 1 + have hh : ((N+1:ℕ):ℝ)*((N+1:ℕ):ℝ)^(-(1/2:ℝ)) = ((N+1:ℕ):ℝ)^(1/2:ℝ) := by + calc + _ = ((N+1:ℕ):ℝ)^(1:ℝ)*((N+1:ℕ):ℝ)^(-(1/2:ℝ)) := by rw [Real.rpow_one] + _ = _ := by rw [← Real.rpow_add hn]; norm_num + nlinarith + +lemma stripTime_rapidDecay {d : ℕ} (hd : 2 ≤ d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℕ, 0 < A ∧ RapidDecay (fun N => + (annealedLaw ν).real (StripUntil e (N+1) (A*(N+1)^(2*d+1)))) := by + obtain ⟨C,ε,hC,hε,hε1,hconf⟩ := spatial_confinement ν hue e htrans + obtain ⟨κ,hκ,hωκ⟩ := environment_uniform_elliptic ν hue + have hκ1 : κ ≤ 1 := by + obtain ⟨ω,hω⟩ := hωκ.exists + exact (hω 0 e).trans (row_entry_le_one (ω 0) e) + let m : ℕ := ⌈4*C⌉₊ + let A : ℕ := (2*m+1)^d + have hA : 0 < A := by dsimp [A]; positivity + have hm : 4*C ≤ (m:ℝ) := Nat.le_ceil _ + have hgeom := ((rapidDecay_geometric (1-ε) (by linarith) (by linarith)).shift + (fun _ => by positivity) 1).const_mul (2*d:ℕ) + have hbad := (((bad_crossing_rapidDecay hd ν hue e htrans).shift + (fun _ => measureReal_nonneg) 1).pow_mul (2*d)).const_mul A + have hexp := ((rapidDecay_stretchedExp (1/2) κ (by norm_num) (by exact_mod_cast hκ)).pow_mul (2*d)).const_mul A + refine ⟨A,hA,((hgeom.add hbad).add hexp).of_le (fun _ => measureReal_nonneg) ?_⟩ + apply Eventually.of_forall + intro N + let H := N+1 + have hH : 0 < H := by dsimp [H]; omega + have hH' : (1:ℝ) ≤ H := by exact_mod_cast hH + have hM : C*((H:ℝ)+1)^2 ≤ (m*H^2:ℕ) := by + push_cast + have hs : ((H:ℝ)+1)^2 ≤ 4*(H:ℝ)^2 := by nlinarith + have hh := mul_le_mul_of_nonneg_left hs hC.le + nlinarith [sq_nonneg (H:ℝ)] + have hcard := strip_box_card_bound (d := d) m H hH + have hT : (latticeBox (d := d) (m*H^2)).card*H ≤ A*H^(2*d+1) := by + simpa only [pow_succ,mul_assoc] using Nat.mul_le_mul_right H hcard + have hh := annealed_stripUntil_bound ν e H (A*H^(2*d+1)) H (m*H^2) hH + (C*((H:ℝ)+1)^2) hM hT κ hκ1 hωκ + have hc := hconf H + have hb := mul_le_mul_of_nonneg_right (show ((latticeBox (d := d) (m*H^2)).card:ℝ) ≤ (A*H^(2*d):ℕ) by exact_mod_cast hcard) + (show 0 ≤ (environmentLaw ν).real (badCrossingEvent e H (1/2)) from measureReal_nonneg) + have he := upward_probability_bound N κ (by positivity) (by exact_mod_cast hκ1) + have he' : ((latticeBox (d := d) (m*H^2)).card:ℝ)*(1-(κ:ℝ)*(H:ℝ)^(-(1/2:ℝ)))^H ≤ + (A*H^(2*d):ℕ)*Real.exp (-(κ:ℝ)*(H:ℝ)^(1/2:ℝ)) := + mul_le_mul (by exact_mod_cast hcard) he (by + apply pow_nonneg + have ha := Real.rpow_le_one_of_one_le_of_nonpos hH' (by norm_num : -(1/2:ℝ) ≤ 0) + have hh := (mul_le_of_le_one_left (by positivity : 0 ≤ (H:ℝ)^(-(1/2:ℝ))) + (show (κ:ℝ) ≤ 1 by exact_mod_cast hκ1)).trans ha + linarith) (by positivity) + have hbnd := hh.trans (add_le_add (add_le_add hc hb) he') + simpa only [H,Nat.cast_add,Nat.cast_one,Nat.cast_mul,Nat.cast_pow,mul_assoc] using hbnd + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/SuccessfulAverageTubeTransfer.lean b/lean/OAI/Probability/Ballisticity/Geometry/SuccessfulAverageTubeTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee345a2000839631431bfae58013618c3087ef74 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/SuccessfulAverageTubeTransfer.lean @@ -0,0 +1,365 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ConvolutionCentersClose +import OAI.Probability.Ballisticity.Coupling.QuenchedConditionedTubeTransfer +import OAI.Probability.Ballisticity.Estimates.SuccessfulAverage + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem successfulAverage_tube_transfer {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (b : ℕ → ℝ) (H : ℕ → ℕ) (hH : Tendsto H atTop atTop) + (z : ℕ → ℝ) (hz : Tendsto z atTop atTop) : + limsup (fun i => (successfulAverage ν (realPosition (step e)) (H i)).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i))) atTop ≤ + 10*limsup (fun i => (conditionedLaw ν (realPosition (step e))).real + (MedianTubeFailure (realPosition (step e)) f b (H i) (z i/10))) atTop := by + let ℓ := realPosition (step e) + let μ := fun i => successfulAverage ν ℓ (H i) + let η := fun i => rawConditionedWeight ν ℓ (fun ω => (crossingQuenched ℓ 0 (H i) ω)⁻¹) + let : ∀ i, IsProbabilityMeasure (μ i) := fun i => successfulAverage_probability ν hue ℓ (signed_direction_unit e) htrans (H i) + let : IsProbabilityMeasure (quenchedConditionedAverage ν ℓ) := + quenchedConditionedAverage_probability ν hue ℓ (signed_direction_unit e) htrans + let a := fun i => (μ i).real (MedianTubeFailure ℓ f b (H i) (z i)) + let q := fun i => (quenchedConditionedAverage ν ℓ).real (MedianTubeFailure ℓ f b (H i) (z i)) + have hab : IsBoundedUnder (· ≤ ·) atTop a := ⟨1, + (show ∀ᶠ i in atTop, a i ≤ 1 from Eventually.of_forall fun _ => measureReal_le_one)⟩ + have hqb : IsBoundedUnder (· ≤ ·) atTop q := ⟨1, + (show ∀ᶠ i in atTop, q i ≤ 1 from Eventually.of_forall fun _ => measureReal_le_one)⟩ + have hac : IsCoboundedUnder (· ≤ ·) atTop a := + (show IsBoundedUnder (· ≥ ·) atTop a from ⟨0, + (show ∀ᶠ i in atTop, 0 ≤ a i from Eventually.of_forall fun _ => measureReal_nonneg)⟩).isCoboundedUnder_le + have hm : Tendsto (fun i => (η i).real Set.univ) atTop (𝓝 1) := by + have hh := (ENNReal.continuousAt_toReal (by simp : (1:ℝ≥0∞) ≠ ∞)).tendsto.comp + ((raw_crossingDensity_mass_tendsto ν hue ℓ (signed_direction_unit e) htrans).comp hH) + simpa only [Function.comp_def,Measure.real,ENNReal.toReal_one,η] using hh + have hmain : limsup a atTop ≤ limsup q atTop := by + apply (limsup_le_iff hac hab).mpr + intro u hu + have hqt := eventually_lt_of_limsup_lt + (show limsup q atTop < limsup q atTop+(u-limsup q atTop)/3 by linarith) hqb + have hmt := hm.eventually (lt_mem_nhds (show 1-(u-limsup q atTop)/3 < (1:ℝ) by linarith)) + filter_upwards [hqt,hmt] with i hi hi' + have hb := successfulAverage_comparison ν hue ℓ (signed_direction_unit e) htrans (H i) + (MedianTubeFailure ℓ f b (H i) (z i)) (measurableSet_medianTubeFailure ℓ f b (H i) (z i)) + change a i ≤ q i+1-(η i).real Set.univ at hb + linarith + exact hmain.trans (quenchedConditioned_tube_transfer ν hue e f htrans b H z hz) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma conditioned_median_tube_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (H : ℕ) {z : ℝ} (hz : 0 < z) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + p^2/2 * (conditionedLaw ν ℓ).real + (MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H z) ≤ + 5*(H:ℝ)/fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) z := by + dsimp only + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have he : MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H z =ᵐ[conditionedLaw ν ℓ] + {X | ∃ j, 0 < j ∧ j ≤ H ∧ z < |signedCoordinate f (recordIndexPosition ℓ j X)-(recordMedian ν ℓ hp f j:ℝ)|} := by + filter_upwards [(conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_initial ν)] with X hX + apply propext + constructor + · rintro ⟨j,hj,hbad⟩ + have hj0 : 0 < j := by + by_contra hn + have hjz : j = 0 := by omega + simp [hjz,recordIndexPosition,recordIndexTime_zero,hX,recordMedian_zero,signedCoordinate] at hbad + linarith + exact ⟨j,hj0,hj,hbad⟩ + · rintro ⟨j,_,hj,hbad⟩ + exact ⟨j,hj,hbad⟩ + rw [measureReal_congr he] + exact conditioned_median_max_bound ν ℓ htrans (signedHeight e) (signedHeight_projection e) + (signedHeight_step_le e) f H hz + +lemma conditioned_median_tube_short_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {r c t : ℝ} (hr : 0 < r) (hc : 0 < c) (hc1 : c ≤ 1) (ht : 0 ≤ t) + (H : ℕ) (hH : (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + (conditionedLaw ν ℓ).real (MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (c*r)) ≤ + 10*t/(p^2*c^2) := by + dsimp only + let ℓ := realPosition (step e) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hp0 : 0 < p := ENNReal.toReal_pos hp (measure_ne_top _ _) + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + have hs := measurable_commonIncrementProcess ℓ f 0 + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hnr : 0 < fluctuationScale μ S r := div_pos (sq_pos_of_pos hr) (truncatedVariance_pos μ S hs hne hr) + have hnc : 0 < fluctuationScale μ S (c*r) := div_pos (sq_pos_of_pos (mul_pos hc hr)) + (truncatedVariance_pos μ S hs hne (mul_pos hc hr)) + have hsc := fluctuationScale_scaling μ S hs hne hr hc hc1 + have hb := conditioned_median_tube_bound ν e f htrans H (mul_pos hc hr) + have hfrac : 5*(H:ℝ)/fluctuationScale μ S (c*r) ≤ 5*t/c^2 := by + apply (div_le_iff₀ hnc).mpr + have hh := mul_le_mul_of_nonneg_left hsc (show 0 ≤ 5*t/c^2 by positivity) + have heq : (5*t/c^2)*(c^2*fluctuationScale μ S r) = 5*t*fluctuationScale μ S r := by field_simp + rw [heq] at hh + nlinarith + have hh := hb.trans hfrac + have hd : 0 < p^2/2 := by positivity + have heq : 5*t/c^2 = (p^2/2)*(10*t/(p^2*c^2)) := by field_simp; ring + rw [heq] at hh + exact (mul_le_mul_iff_right₀ hd).mp hh + +theorem quenched_median_tube_short_uniform {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {w : ℝ} (hw : 0 < w) (hw1 : w ≤ 10) : + ∃ C : ℝ, 0 < C ∧ ∀ t : ℝ, 0 < t → ∃ R : ℝ, 0 < R ∧ ∀ r : ℝ, R ≤ r → + ∀ H : ℕ, (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + (quenchedConditionedAverage ν ℓ).real + (MedianTubeFailure ℓ f (fun j => (recordMedian ν ℓ hp f j:ℝ)) H (w*r)) ≤ C*t := by + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + have hp0 : 0 < p := ENNReal.toReal_pos hp (measure_ne_top _ _) + let C := 100/(p^2*(w/10)^2) + have hC : 0 < C := by dsimp [C]; positivity + let μ := quenchedConditionedAverage ν ℓ + let : IsProbabilityMeasure μ := quenchedConditionedAverage_probability ν hue ℓ (signed_direction_unit e) htrans + let n := fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) + let b := fun j => (recordMedian ν ℓ hp f j:ℝ) + refine ⟨2*C,by positivity,?_⟩ + intro t ht + by_contra hn + push Not at hn + have hbad (i : ℕ) : ∃ r : ℝ, (max (i:ℝ) 1) ≤ r ∧ ∃ H : ℕ, (H:ℝ) ≤ t*n r ∧ + 2*C*t < μ.real (MedianTubeFailure ℓ f b H (w*r)) := by + obtain ⟨r,hr,H,hH,hbad⟩ := hn (max (i:ℝ) 1) (lt_of_lt_of_le zero_lt_one (le_max_right _ _)) + exact ⟨r,hr,H,hH,lt_of_not_ge hbad⟩ + choose r hr H hH hbad using hbad + have hrpos (i : ℕ) : 0 < r i := lt_of_lt_of_le zero_lt_one ((le_max_right _ _).trans (hr i)) + have hrinf : Tendsto r atTop atTop := tendsto_atTop_mono (fun i => (le_max_left _ _).trans (hr i)) tendsto_natCast_atTop_atTop + let q := fun i => (conditionedLaw ν ℓ).real (MedianTubeFailure ℓ f b (H i) ((w*r i)/10)) + let a := fun i => μ.real (MedianTubeFailure ℓ f b (H i) (w*r i)) + have hqb : ∀ i, q i ≤ 10*t/(p^2*(w/10)^2) := by + intro i + have hh := conditioned_median_tube_short_bound ν hue e f hef htrans (hrpos i) + (show 0 < w/10 by positivity) (show w/10 ≤ 1 by linarith) ht.le (H i) (hH i) + simpa only [show w/10*r i = w*r i/10 by ring] using hh + have hqc : IsCoboundedUnder (· ≤ ·) atTop q := + (show IsBoundedUnder (· ≥ ·) atTop q from ⟨0, + (show ∀ᶠ i in atTop, 0 ≤ q i from Eventually.of_forall fun _ => measureReal_nonneg)⟩).isCoboundedUnder_le + have hlimq := limsup_le_of_le hqc (Eventually.of_forall hqb) + have htransfer := quenchedConditioned_tube_transfer ν hue e f htrans b H (fun i => w*r i) (hrinf.const_mul_atTop hw) + have hlim : limsup a atTop ≤ C*t := by + have hh := htransfer.trans (mul_le_mul_of_nonneg_left hlimq (by norm_num : (0:ℝ) ≤ 10)) + have heq : 10*(10*t/(p^2*(w/10)^2)) = C*t := by dsimp [C]; ring + rwa [heq] at hh + have hab : IsBoundedUnder (· ≤ ·) atTop a := ⟨1, + (show ∀ᶠ i in atTop, a i ≤ 1 from Eventually.of_forall fun _ => measureReal_le_one)⟩ + have hlo : 2*C*t ≤ limsup a atTop := le_limsup_of_frequently_le + (Frequently.of_forall fun i => (hbad i).le) hab + nlinarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/SumWindowDifference.lean b/lean/OAI/Probability/Ballisticity/Geometry/SumWindowDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..e98d01d8c3fdaa18c9b52494f7265fb4b69ea5cf --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/SumWindowDifference.lean @@ -0,0 +1,274 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GridOscillation + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma sum_window_difference (x : ℕ → ℝ) (k j m : ℕ) + (hj : j ≤ k+m) (hk : k ≤ j+m) : + |realPartialSum x j-realPartialSum x k| ≤ + 2*partialSumMax (fun l => x (k-m+l)) (2*m) := by + let s := k-m + have hs : s ≤ j := by dsimp [s]; omega + have hs' : s ≤ k := Nat.sub_le _ _ + have hjm : j-s ≤ 2*m := by dsimp [s]; omega + have hkm : k-s ≤ 2*m := by dsimp [s]; omega + have he (a : ℕ) (ha : s ≤ a) : + realPartialSum x a = realPartialSum x s+realPartialSum (fun l => x (s+l)) (a-s) := by + rw [← realPartialSum_add,Nat.add_sub_of_le ha] + rw [he j hs,he k hs'] + have hb1 := (abs_partialSum_le_max (fun l => x (s+l)) (j-s)).trans + (partialSumMax_mono _ hjm) + have hb2 := (abs_partialSum_le_max (fun l => x (s+l)) (k-s)).trans + (partialSumMax_mono _ hkm) + have h := abs_sub (realPartialSum (fun l => x (s+l)) (j-s)) + (realPartialSum (fun l => x (s+l)) (k-s)) + rw [add_sub_add_left_eq_sub] + dsimp [s] at hb1 hb2 h + linarith + +theorem iid_random_clock_error {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ j, Measurable (X j)) (hind : iIndepFun X μ) + (hid : ∀ j, IdentDistrib (X j) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) (K : ℕ → ℕ) (C : ℕ → Ω → ℕ) + (hclock : TendstoInMeasure μ (fun i ω => ((C i ω : ℝ)-K i)/fluctuationScale μ (X 0) (r i)) atTop 0) : + TendstoInMeasure μ (fun i ω => (realPartialSum (fun j => X j ω) (C i ω)- + realPartialSum (fun j => X j ω) (K i))/r i) atTop 0 := by + let n := fun i => fluctuationScale μ (X 0) (r i) + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto μ (X 0) (hX 0) hI hne).comp hr + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] + apply tendsto_order.mpr + constructor + · intro a ha + exact Eventually.of_forall (fun _ => ha.trans_le measureReal_nonneg) + · intro η hη + let ρ := min (ε/4) 1 + have hρ : 0 < ρ := lt_min (by positivity) zero_lt_one + have hρ1 : ρ ≤ 1 := min_le_right _ _ + have hρε : ρ ≤ ε/4 := min_le_left _ _ + let δ := η*ρ^2/40 + have hδ : 0 < δ := by dsimp [δ]; positivity + let A := fun i => {ω | δ ≤ |((C i ω : ℝ)-K i)/n i|} + have ht : Tendsto (fun i => μ.real (A i)) atTop (𝓝 0) := by + simpa only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] using + (tendstoInMeasure_iff_measureReal_norm.mp hclock δ hδ) + have hinv : Tendsto (fun i => 1/n i) atTop (𝓝 0) := by + simpa only [one_div,Function.comp_def] using tendsto_inv_atTop_zero.comp hn + have hb : Tendsto (fun i => μ.real (A i)+10*(δ+1/n i)/ρ^2) atTop (𝓝 (η/4)) := by + have hh := ht.add ((((tendsto_const_nhds (x := δ)).add hinv).const_mul 10).div_const (ρ^2)) + have he : 0+10*(δ+0)/ρ^2 = η/4 := by + dsimp [δ] + field_simp [ne_of_gt hρ]; ring + rwa [he] at hh + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ)), + hb.eventually (gt_mem_nhds (show η/4 < η by linarith))] with i hri hbi + have hni : 0 < n i := div_pos (sq_pos_of_pos hri) (truncatedVariance_pos μ (X 0) (hX 0) hne hri) + let m := ⌈δ*n i⌉₊ + have hm : δ*n i ≤ (m:ℝ) := Nat.le_ceil _ + have hm' : (m:ℝ) ≤ δ*n i+1 := (Nat.ceil_lt_add_one (mul_nonneg hδ.le hni.le)).le + let B := {ω | ρ*r i < partialSumMax (fun j => X (K i-m+j) ω) (2*m)} + have hsub : {ω | ε ≤ |(realPartialSum (fun j => X j ω) (C i ω)- + realPartialSum (fun j => X j ω) (K i))/r i|} ⊆ A i ∪ B := by + intro ω hω + change ε ≤ |(realPartialSum (fun j => X j ω) (C i ω)- + realPartialSum (fun j => X j ω) (K i))/r i| at hω + by_cases ha : ω ∈ A i + · exact Or.inl ha + · apply Or.inr + have ha' : |(C i ω : ℝ)-K i| < δ*n i := by + change ¬δ ≤ |((C i ω : ℝ)-K i)/n i| at ha + rwa [abs_div,abs_of_pos hni,not_le,div_lt_iff₀ hni] at ha + have hle := abs_le.mp (ha'.le.trans hm) + have hj : C i ω ≤ K i+m := by exact_mod_cast (show (C i ω : ℝ) ≤ K i+m by linarith) + have hk : K i ≤ C i ω+m := by exact_mod_cast (show (K i : ℝ) ≤ C i ω+m by linarith) + have hw := sum_window_difference (fun j => X j ω) (K i) (C i ω) m hj hk + rw [abs_div,abs_of_pos hri,le_div_iff₀ hri] at hω + change ρ*r i < partialSumMax (fun j => X (K i-m+j) ω) (2*m) + nlinarith + have hp : μ.real B ≤ 10*(δ+1/n i)/ρ^2 := by + dsimp only [B] + rw [measureReal_shifted_max μ X hind hid] + have hh := measureReal_partialSumMax_gt_le μ X hX hind hid hsym (mul_pos hρ hri) (2*m) + have hs := fluctuationScale_scaling μ (X 0) (hX 0) hne hri hρ hρ1 + have hbound : 5*(2*m:ℕ)/fluctuationScale μ (X 0) (ρ*r i) ≤ 10*(δ+1/n i)/ρ^2 := by + calc + _ ≤ 5*(2*m:ℕ)/(ρ^2*n i) := div_le_div_of_nonneg_left (by positivity) (by positivity) hs + _ ≤ 10*(δ*n i+1)/(ρ^2*n i) := by + apply div_le_div_of_nonneg_right _ (by positivity) + push_cast + nlinarith + _ = _ := by field_simp + rw [← div_div_eq_mul_div] at hh + exact hh.trans hbound + exact ((measureReal_mono (μ := μ) hsub).trans (measureReal_union_le _ _)).trans_lt + (lt_of_le_of_lt (add_le_add le_rfl hp) hbi) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/TubeEndpoint.lean b/lean/OAI/Probability/Ballisticity/Geometry/TubeEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bc5601fce2fa65f6ac1b87eb5c11ed6d1b41c7e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/TubeEndpoint.lean @@ -0,0 +1,340 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.TubePrefixMass + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def tubeEndpoint {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) (ω : Environment d) : Measure (Lattice d) := + Measure.sum fun n => ((quenchedKernel (ω,x)).restrict (TubePrefixAt ℓ f x θ z s n)).map (fun X => X n) + +lemma tubeEndpoint_apply {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) (ω : Environment d) (U : Set (Lattice d)) : + tubeEndpoint ℓ f x θ z s ω U = ∑' n, quenchedKernel (ω,x) + ((fun X => X n) ⁻¹' U ∩ TubePrefixAt ℓ f x θ z s n) := by + rw [tubeEndpoint,Measure.sum_apply _ U.to_countable.measurableSet] + apply tsum_congr; intro n + rw [Measure.map_apply (measurable_pi_apply n) U.to_countable.measurableSet, + Measure.restrict_apply ((measurable_pi_apply n) U.to_countable.measurableSet)] + +lemma tubeEndpoint_total {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) (ω : Environment d) : + tubeEndpoint ℓ f x θ z s ω Set.univ = quenchedKernel (ω,x) (TubePrefix ℓ f x θ z s) := by + rw [tubeEndpoint_apply,TubePrefix,measure_iUnion (tubePrefixAt_disjoint ℓ f x θ z s) + (measurableSet_tubePrefixAt ℓ f x θ z s)] + simp only [Set.preimage_univ,Set.univ_inter] + +instance tubeEndpoint_finite {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) (ω : Environment d) : IsFiniteMeasure (tubeEndpoint ℓ f x θ z s ω) := + ⟨by rw [tubeEndpoint_total]; exact measure_lt_top _ _⟩ + +lemma tubeEndpoint_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) {s : ℕ} (hs : 0 < s) : + @Measurable _ _ (rowSigma (Strip ℓ x s)) _ (tubeEndpoint ℓ f x θ z s) := by + let : MeasurableSpace (Environment d) := rowSigma (Strip ℓ x s) + apply Measure.measurable_of_measurable_coe + intro U _ + simp_rw [tubeEndpoint_apply] + apply Measurable.tsum; intro n + apply measurable_quenched_prefix_event_rows (Strip ℓ x s) x + (show x ∈ Strip ℓ x s from ⟨le_rfl,lt_add_of_pos_right _ (by exact_mod_cast hs)⟩) n + · exact ((measurable_pi_apply n) U.to_countable.measurableSet).inter (measurableSet_tubePrefixAt ℓ f x θ z s n) + · intro X Y hXY + exact and_congr (by rw [Set.mem_preimage,Set.mem_preimage,hXY n le_rfl]) + (tubePrefixAt_prefix ℓ f x θ z s n X Y hXY) + · exact fun _ hX => hX.2.1.2 + +noncomputable def tubeEndpointMixture {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : Measure (Lattice d) := + Measure.sum fun x => π {x} • tubeEndpoint ℓ f x θ z s ω + +lemma tubeEndpointMixture_total {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + tubeEndpointMixture ℓ f θ z s π ω Set.univ = tubePrefixMass ℓ f θ z s π ω := by + rw [tubeEndpointMixture,Measure.sum_apply _ MeasurableSet.univ,tubePrefixMass,lintegral_countable'] + apply tsum_congr; intro x + rw [Measure.smul_apply,smul_eq_mul,tubeEndpoint_total,mul_comm] + +lemma tubeEndpointMixture_total_le {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + tubeEndpointMixture ℓ f θ z s π ω Set.univ ≤ π Set.univ := by + rw [tubeEndpointMixture_total,tubePrefixMass] + calc + _ ≤ ∫⁻ _, (1:ℝ≥0∞) ∂π := lintegral_mono (fun _ => prob_le_one) + _ = _ := by simp + +instance tubeEndpointMixture_finite {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) [IsFiniteMeasure π] (ω : Environment d) : + IsFiniteMeasure (tubeEndpointMixture ℓ f θ z s π ω) := + ⟨(tubeEndpointMixture_total_le ℓ f θ z s π ω).trans_lt (measure_lt_top _ _)⟩ + +lemma tubeEndpointMixture_lower_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a θ z : ℝ) {s : ℕ} (hs : 0 < s) (π : Measure (Lattice d)) + (hπ : ∀ᵐ x ∂π, dot (realPosition x) ℓ = a) : + @Measurable _ _ (rowSigma {y | dot (realPosition y) ℓ < a+s}) _ + (tubeEndpointMixture ℓ f θ z s π) := by + let : MeasurableSpace (Environment d) := rowSigma {y | dot (realPosition y) ℓ < a+s} + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [tubeEndpointMixture,Measure.sum_apply _ hU,Measure.smul_apply,smul_eq_mul] + apply Measurable.tsum; intro x + by_cases hx : dot (realPosition x) ℓ = a + · have hm := (tubeEndpoint_rows ℓ f x θ z hs).mono (rowSigma_mono (show Strip ℓ x s ⊆ + {y | dot (realPosition y) ℓ < a+s} from fun _ hy => by simpa only [hx,Set.mem_ofPred_eq] using hy.2)) le_rfl + exact measurable_const.mul ((Measure.measurable_coe hU).comp hm) + · have hh : π {x} = 0 := measure_mono_null (show {x} ⊆ {y | dot (realPosition y) ℓ ≠ a} from + fun y hy => by simpa only [Set.mem_singleton_iff.mp hy,Set.mem_ofPred_eq] using hx) (ae_iff.mp hπ) + simp only [hh,zero_mul] + exact measurable_const + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma two_tube_threat_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) (H : ℕ) + (π : Measure (Lattice d)) (ρ : ℕ → Environment d → Measure (Lattice d)) + (hρ : ∀ s : ℕ, @Measurable _ _ (rowSigma {y | dot (realPosition y) ℓ < a+s}) _ (ρ s)) + (c : ℝ≥0∞) + (hfirst : environmentLaw ν {ω | (π,ω) ∈ TubeThreat ℓ f a θ z δ H} ≤ c) + (hsecond : ∀ s ≤ H, ∀ η ∈ FirstTubeThreat ℓ f a θ z δ s π, + environmentLaw ν {ω | (ρ s η,ω) ∈ TubeThreat ℓ f (a+s) θ z δ H} ≤ c) : + environmentLaw ν (⋃ s ∈ Finset.range (H+1), + {ω | ω ∈ FirstTubeThreat ℓ f a θ z δ s π ∧ + (ρ s ω,ω) ∈ TubeThreat ℓ f (a+s) θ z δ H}) ≤ c*c := by + let A := fun s => FirstTubeThreat ℓ f a θ z δ s π + have hA (s : ℕ) : MeasurableSet (A s) := + rowSigma_le _ _ (firstTubeThreat_lower_rows ℓ f a θ z δ s π) + have hdisj : (↑(Finset.range (H+1)) : Set ℕ).PairwiseDisjoint A := + fun _ _ _ _ h => firstTubeThreat_disjoint ℓ f a θ z δ π h + have he : (⋃ s ∈ Finset.range (H+1), A s) = {ω | (π,ω) ∈ TubeThreat ℓ f a θ z δ H} := by + simpa only [Finset.mem_range,Nat.lt_succ_iff] using firstTubeThreat_iUnion ℓ f a θ z δ π H + calc + _ ≤ ∑ s ∈ Finset.range (H+1), environmentLaw ν + {ω | ω ∈ A s ∧ (ρ s ω,ω) ∈ TubeThreat ℓ f (a+s) θ z δ H} := measure_biUnion_finset_le _ _ + _ ≤ ∑ s ∈ Finset.range (H+1), c*environmentLaw ν (A s) := by + apply Finset.sum_le_sum + intro s hs + apply fresh_random_tube_threat ν ℓ f (a+s) θ z δ H + {y | dot (realPosition y) ℓ < a+s} + (Set.disjoint_left.mpr (fun _ hy hz => (not_lt_of_ge (show a+(s:ℝ) ≤ _ from hz)) hy)) (ρ s) (hρ s) (A s) + (firstTubeThreat_lower_rows ℓ f a θ z δ s π) c + exact hsecond s (Nat.lt_succ_iff.mp (Finset.mem_range.mp hs)) + _ = c*environmentLaw ν (⋃ s ∈ Finset.range (H+1), A s) := by + rw [← Finset.mul_sum,measure_biUnion_finset hdisj (fun s _ => hA s)] + _ ≤ c*c := by rw [he]; exact mul_le_mul_right hfirst c + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/TubeHeightMono.lean b/lean/OAI/Probability/Ballisticity/Geometry/TubeHeightMono.lean new file mode 100644 index 0000000000000000000000000000000000000000..25243f84aa6ed8da940850fa20988f7882df595f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/TubeHeightMono.lean @@ -0,0 +1,108 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.CurvePolicyTubeMass +import OAI.Probability.Ballisticity.Estimates.CurveCenter + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma tubePrefix_eq_curvePrefix {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (θ z : ℝ) (H : ℕ) : + TubePrefix ℓ f x θ z H = CurvePrefix ℓ f x (fun j => (j:ℝ)*θ) z H := rfl + +lemma tubePrefix_mono_height_ae {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z : ℝ) {H K : ℕ} (hH : 0 < H) (hHK : H ≤ K) (ω : Environment d) : + TubePrefix (realPosition (step e)) f x θ z K ≤ᵐ[quenchedKernel (ω,x)] + TubePrefix (realPosition (step e)) f x θ z H := by + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + intro hX + rw [tubePrefix_eq_curvePrefix] at hX ⊢ + have hX := (curvePrefix_iff e f x _ z (hH.trans_le hHK) X h0 hnn).mp hX + apply (curvePrefix_iff e f x _ z hH X h0 hnn).mpr + refine ⟨?_,fun j hj => hX.2 j (hj.trans hHK)⟩ + have hh := hX.1 + rw [←cross_eq_hit] at hh ⊢ + exact cross_antitone _ x (by exact_mod_cast hHK) hh + +lemma quenchedTube_mono_height {d : ℕ} (e f : Direction d) (x : Lattice d) + (θ z : ℝ) {H K : ℕ} (hH : 0 < H) (hHK : H ≤ K) (ω : Environment d) : + quenchedKernel (ω,x) (TubePrefix (realPosition (step e)) f x θ z K) ≤ + quenchedKernel (ω,x) (TubePrefix (realPosition (step e)) f x θ z H) := + measure_mono_ae (tubePrefix_mono_height_ae e f x θ z hH hHK ω) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma tubePrefix_mono_width {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ : ℝ) {z w : ℝ} (hzw : z ≤ w) (H : ℕ) : + TubePrefix ℓ f x θ z H ⊆ TubePrefix ℓ f x θ w H := by + intro X hX + obtain ⟨a,ha⟩ := Set.mem_iUnion.mp hX + refine Set.mem_iUnion.mpr ⟨a,ha.1,?_⟩ + intro j hj + obtain ⟨k,hk,hr,hb⟩ := ha.2 j hj + exact ⟨k,hk,hr,hb.trans hzw⟩ + +lemma curvePolicy_real_tube_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (b : ℕ → ℝ) {B D : ℝ} (hB : 0 ≤ B) (hD : 0 ≤ D) + {H : ℕ} (hH : 0 < H) {r : ℝ} (hr : 0 < r) + (hb : ∀ j ≤ H, |b j-(j:ℝ)*b H/H| ≤ D) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) + (hδ1 : δ ≤ 1) (hα1 : α ≤ 1) + (dummy : Lattice d) (hd : signedHeight e dummy=H) (hdb : signedCoordinate f dummy=b H) + (n : ℕ) {K : ℕ} (hK : 0 < K) (hKn : K ≤ n*H) : + let μ := curvePolicy_average ν (realPosition (step e)) f b B hH E hδ hα dummy + let θ := (∫ u, signedCoordinate f u ∂μ.toMeasure)/(H:ℝ) + (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix (realPosition (step e)) f 0 θ (r+2*B+D) K) < (α*δ)^n/2} ≤ + 2*((n:ℝ)*(environmentLaw ν).real {ω | curveIncrement (realPosition (step e)) f 0 b B H ω Set.univ < δ} + + (4*(n:ℝ)*(∫ u, (signedCoordinate f u-b H)^2 ∂μ.toMeasure))/r^2) := by + dsimp only + let μ := curvePolicy_average ν (realPosition (step e)) f b B hH E hδ hα dummy + let m := ∫ u, signedCoordinate f u ∂μ.toMeasure + have hm : |m-b H| ≤ B := curvePolicy_mean_bound ν e f b hB hH E hδ hα dummy hdb + have hθ : (H:ℝ)*(m/(H:ℝ))=m := by field_simp + have hh := curvePolicy_tube_probability ν e f b hB (add_nonneg hD hB) hH (m/H) hr + (median_line_mean_bound b hH hB hm hb) E hδ hα hδ1 hα1 dummy hd hdb 0 n 0 + (by simp [signedHeight]) hθ + have hl : environmentLaw ν {ω | quenchedKernel (ω,0) + (TubePrefix (realPosition (step e)) f 0 (m/H) (r+2*B+D) K) < (α*δ)^n/2} ≤ + environmentLaw ν {ω | quenchedKernel (ω,0) + (TubePrefix (realPosition (step e)) f 0 (m/H) (r+B+(D+B)) (n*H)) < (α*δ)^n/2} := by + apply measure_mono + intro ω hω + have he : r+B+(D+B)=r+2*B+D := by ring + rw [he] + exact (quenchedTube_mono_height e f 0 (m/H) _ hK hKn ω).trans_lt hω + have hV : 0 ≤ 4*(n:ℝ)*(∫ u, (signedCoordinate f u-b H)^2 ∂μ.toMeasure)/r^2 := by + apply div_nonneg _ (sq_nonneg _) + exact mul_nonneg (by positivity) (integral_nonneg fun _ => sq_nonneg _) + have hrhs : 2*((n:ℝ≥0∞)*environmentLaw ν {ω | curveIncrement (realPosition (step e)) f 0 b B H ω Set.univ < δ}+ + ENNReal.ofReal (4*(n:ℝ)*(∫ u, (signedCoordinate f u-b H)^2 ∂μ.toMeasure)/r^2)) ≠ ⊤ := by + finiteness + have hh := ENNReal.toReal_mono hrhs (hl.trans hh) + rw [ENNReal.toReal_mul,ENNReal.toReal_ofNat, + ENNReal.toReal_add (by finiteness) ENNReal.ofReal_ne_top, + ENNReal.toReal_mul,ENNReal.toReal_natCast,ENNReal.toReal_ofReal hV] at hh + exact hh + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/TubePrefix.lean b/lean/OAI/Probability/Ballisticity/Geometry/TubePrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f2b042698d2a730913af631ae0c6bd5409da5f8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/TubePrefix.lean @@ -0,0 +1,307 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.AlignedRecordPrefix + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma quenched_prefix_event_congr {d : ℕ} (S : Set (Lattice d)) + (ω η : Environment d) (hωη : Set.EqOn ω η S) (x : Lattice d) (n : ℕ) + (A : Set (Path d)) (hA : PrefixDetermined n A) + (hAS : ∀ X ∈ A, ∀ j < n, X j ∈ S) : + quenchedKernel (ω,x) A = quenchedKernel (η,x) A := by + let C : Set ((i : Finset.Iic n) → Lattice d) := {f | extendPrefix n f ∈ A} + have he : (fun X : Path d => Preorder.frestrictLe n X) ⁻¹' C = A := by + ext X + exact hA (extendPrefix n (Preorder.frestrictLe n X)) X + (fun j hj => by rw [extendPrefix_apply _ _ _ hj]; rfl) + have hm (f : (i : Finset.Iic n) → Lattice d) (_ : f ∈ C) : + MeasurableSet ((fun X : Path d => Preorder.frestrictLe n X) ⁻¹' {f}) := + (Preorder.measurable_frestrictLe n) (measurableSet_singleton f) + rw [← he,← tsum_measure_preimage_singleton C.to_countable hm, + ← tsum_measure_preimage_singleton C.to_countable hm] + apply tsum_congr + intro f + rw [restrict_prefix_fiber] + exact pathCylinder_weight_locality S ω η hωη x (extendPrefix n f.val) n (hAS _ f.property) + +lemma measurable_quenched_prefix_event_rows {d : ℕ} (S : Set (Lattice d)) + (x : Lattice d) (hx : x ∈ S) (n : ℕ) (A : Set (Path d)) + (hA : MeasurableSet A) (hprefix : PrefixDetermined n A) + (hAS : ∀ X ∈ A, ∀ j < n, X j ∈ S) : + @Measurable _ _ (rowSigma S) _ (fun ω : Environment d => quenchedKernel (ω,x) A) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ hA).comp (measurable_id.prodMk measurable_const)) S x hx + intro ω η h + exact quenched_prefix_event_congr S ω η h x n A hprefix hAS + +def TubePrefixAt {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s n : ℕ) : Set (Path d) := + HitAt (Strip ℓ x s) (Upper ℓ x s) n ∩ + {X | ∀ j ≤ s, ∃ a ≤ n, + (fun k => X k-x) ∈ RecordOrZeroPrefix ℓ j a ∧ + |signedCoordinate f (X a-x)-(j:ℝ)*θ| ≤ z} + +lemma measurableSet_tubePrefixAt {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s n : ℕ) : MeasurableSet (TubePrefixAt ℓ f x θ z s n) := by + apply (measurableSet_hitAt _ _ n).inter + simp only [Set.ofPred_forall,Set.ofPred_exists,Set.ofPred_and] + apply MeasurableSet.iInter; intro j + apply MeasurableSet.iInter; intro _ + apply MeasurableSet.iUnion; intro a + refine (MeasurableSet.const (a ≤ n)).inter ?_ + have hm : Measurable (fun X : Path d => fun k => X k-x) := by fun_prop + have hc : Measurable (fun X : Path d => signedCoordinate f (X a-x)) := + (measurable_of_countable (signedCoordinate f)).comp + ((measurable_pi_apply a : Measurable (fun X : Path d => X a)).sub_const x) + exact ((measurableSet_recordOrZeroPrefix ℓ j a).preimage hm).inter + (measurableSet_le ((hc.sub_const ((j:ℝ)*θ)).abs) measurable_const) + +lemma tubePrefixAt_prefix {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s n : ℕ) : PrefixDetermined n (TubePrefixAt ℓ f x θ z s n) := by + have hdir (X Y : Path d) (hXY : ∀ j ≤ n, X j=Y j) + (hX : X ∈ TubePrefixAt ℓ f x θ z s n) : Y ∈ TubePrefixAt ℓ f x θ z s n := by + refine ⟨⟨by simpa only [← hXY n le_rfl] using hX.1.1, + fun j hj => by simpa only [← hXY j hj.le] using hX.1.2 j hj⟩,?_⟩ + intro j hj + obtain ⟨a,ha,hrec,hgood⟩ := hX.2 j hj + refine ⟨a,ha,(recordOrZeroPrefix_prefix ℓ j a _ _ + (fun k hk => by rw [hXY k (hk.trans ha)])).mp hrec,?_⟩ + simpa only [← hXY a ha] using hgood + intro X Y h + exact ⟨hdir X Y h,hdir Y X (fun j hj => (h j hj).symm)⟩ + +def TubePrefix {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) : Set (Path d) := ⋃ n, TubePrefixAt ℓ f x θ z s n + +lemma measurableSet_tubePrefix {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) : MeasurableSet (TubePrefix ℓ f x θ z s) := + MeasurableSet.iUnion (measurableSet_tubePrefixAt ℓ f x θ z s) + +lemma tubePrefixAt_disjoint {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) : Pairwise (fun n m => + Disjoint (TubePrefixAt ℓ f x θ z s n) (TubePrefixAt ℓ f x θ z s m)) := by + intro n m hnm + exact (hitAt_pairwise_disjoint (disjoint_strip_upper ℓ x s) hnm).mono + Set.inter_subset_left Set.inter_subset_left + +lemma quenched_tubePrefix_congr {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z : ℝ) (s : ℕ) (ω η : Environment d) (hωη : Set.EqOn ω η (Strip ℓ x s)) : + quenchedKernel (ω,x) (TubePrefix ℓ f x θ z s) = + quenchedKernel (η,x) (TubePrefix ℓ f x θ z s) := by + rw [TubePrefix,measure_iUnion (tubePrefixAt_disjoint ℓ f x θ z s) + (measurableSet_tubePrefixAt ℓ f x θ z s),measure_iUnion (tubePrefixAt_disjoint ℓ f x θ z s) + (measurableSet_tubePrefixAt ℓ f x θ z s)] + exact tsum_congr fun n => quenched_prefix_event_congr (Strip ℓ x s) ω η hωη x n _ + (tubePrefixAt_prefix ℓ f x θ z s n) (fun _ hX => hX.1.2) + +lemma measurable_quenched_tubePrefix_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (θ z : ℝ) {s : ℕ} (hs : 0 < s) : + @Measurable _ _ (rowSigma (Strip ℓ x s)) _ + (fun ω : Environment d => quenchedKernel (ω,x) (TubePrefix ℓ f x θ z s)) := by + apply measurable_of_row_locality _ + ((Kernel.measurable_coe _ (measurableSet_tubePrefix ℓ f x θ z s)).comp + (measurable_id.prodMk measurable_const)) (Strip ℓ x s) x + (show x ∈ Strip ℓ x s from ⟨le_rfl,by exact lt_add_of_pos_right _ (by exact_mod_cast hs)⟩) + intro ω η h + exact quenched_tubePrefix_congr ℓ f x θ z s ω η h + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/TubePrefixMass.lean b/lean/OAI/Probability/Ballisticity/Geometry/TubePrefixMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..4167da848ba32f82d44ee368a0eddfbb310721d7 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/TubePrefixMass.lean @@ -0,0 +1,418 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.TubePrefix +import OAI.Probability.Ballisticity.Estimates.IndependentRandomTestBound + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def tubePrefixMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : ℝ≥0∞ := + ∫⁻ x, quenchedKernel (ω,x) (TubePrefix ℓ f x θ z s) ∂π + +lemma tubePrefixMass_toReal {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + (tubePrefixMass ℓ f θ z s π ω).toReal = + ∫ x, (quenchedKernel (ω,x)).real (TubePrefix ℓ f x θ z s) ∂π := by + exact (integral_toReal (measurable_of_countable _).aemeasurable + (ae_of_all _ fun x => measure_lt_top _ _)).symm + +lemma measurable_tubePrefixMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) : Measurable (Function.uncurry (tubePrefixMass ℓ f θ z s)) := by + change Measurable (fun p : Measure (Lattice d) × Environment d => + ∫⁻ x, quenchedKernel (p.2,x) (TubePrefix ℓ f x θ z s) ∂p.1) + simp_rw [lintegral_countable'] + apply Measurable.tsum + intro x + have hm : Measurable (fun ω : Environment d => quenchedKernel (ω,x) (TubePrefix ℓ f x θ z s)) := + (Kernel.measurable_coe _ (measurableSet_tubePrefix ℓ f x θ z s)).comp + (measurable_id.prodMk measurable_const) + exact (hm.comp measurable_snd).mul ((Measure.measurable_coe (measurableSet_singleton x)).comp measurable_fst) + +noncomputable def tubeLayerMass {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z : ℝ) + (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : ℝ≥0∞ := + ∑' x, if dot (realPosition x) ℓ = a then + quenchedKernel (ω,x) (TubePrefix ℓ f x θ z s)*π {x} else 0 + +lemma tubeLayerMass_eq {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z : ℝ) + (s : ℕ) (π : Measure (Lattice d)) + (hπ : ∀ᵐ x ∂π, dot (realPosition x) ℓ = a) (ω : Environment d) : + tubeLayerMass ℓ f a θ z s π ω = tubePrefixMass ℓ f θ z s π ω := by + rw [tubeLayerMass,tubePrefixMass,lintegral_countable'] + apply tsum_congr + intro x + by_cases hx : dot (realPosition x) ℓ = a + · simp only [hx,ite_eq_left] + · have hh : π {x} = 0 := (measure_mono_null (show {x} ⊆ {y | dot (realPosition y) ℓ ≠ a} from + fun y hy => by simpa only [Set.mem_singleton_iff.mp hy,Set.mem_ofPred_eq] using hx) + (ae_iff.mp hπ)) + simp only [hx,ite_false,hh,mul_zero] + +lemma tubeLayerMass_joint_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z : ℝ) + {s : ℕ} (hs : 0 < s) (S : Set (Lattice d)) + (hS : ∀ x, dot (realPosition x) ℓ = a → Strip ℓ x s ⊆ S) : + @Measurable (Measure (Lattice d) × Environment d) ℝ≥0∞ + (MeasurableSpace.prod inferInstance (rowSigma S)) _ + (Function.uncurry (tubeLayerMass ℓ f a θ z s)) := by + let : MeasurableSpace (Measure (Lattice d) × Environment d) := + MeasurableSpace.prod inferInstance (rowSigma S) + change Measurable (fun p : Measure (Lattice d) × Environment d => ∑' x, + if dot (realPosition x) ℓ = a then + quenchedKernel (p.2,x) (TubePrefix ℓ f x θ z s)*p.1 {x} else 0) + apply Measurable.tsum + intro x + by_cases hx : dot (realPosition x) ℓ = a + · simp only [hx,ite_eq_left] + have hm := (measurable_quenched_tubePrefix_rows ℓ f x θ z hs).mono (rowSigma_mono (hS x hx)) le_rfl + exact (hm.comp measurable_snd).mul ((Measure.measurable_coe (measurableSet_singleton x)).comp measurable_fst) + · simp only [hx] + exact measurable_const + +lemma tubeLayerMass_lower_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z : ℝ) + {s : ℕ} (hs : 0 < s) : + @Measurable (Measure (Lattice d) × Environment d) ℝ≥0∞ + (MeasurableSpace.prod inferInstance (rowSigma {y | dot (realPosition y) ℓ < a+s})) _ + (Function.uncurry (tubeLayerMass ℓ f a θ z s)) := + tubeLayerMass_joint_rows ℓ f a θ z hs _ (fun x hx _ hy => by simpa only [← hx,Set.mem_ofPred_eq] using hy.2) + +lemma tubeLayerMass_upper_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z : ℝ) + {s : ℕ} (hs : 0 < s) : + @Measurable (Measure (Lattice d) × Environment d) ℝ≥0∞ + (MeasurableSpace.prod inferInstance (rowSigma {y | a ≤ dot (realPosition y) ℓ})) _ + (Function.uncurry (tubeLayerMass ℓ f a θ z s)) := + tubeLayerMass_joint_rows ℓ f a θ z hs _ (fun x hx _ hy => by simpa only [← hx,Set.mem_ofPred_eq] using hy.1) + +def TubeThreat {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) + (H : ℕ) : Set (Measure (Lattice d) × Environment d) := + {p | ∃ s, 0 < s ∧ s ≤ H ∧ (tubeLayerMass ℓ f a θ z s p.1 p.2).toReal < δ} + +lemma measurableSet_tubeThreat_upper {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a θ z δ : ℝ) (H : ℕ) : + @MeasurableSet (Measure (Lattice d) × Environment d) + (MeasurableSpace.prod inferInstance (rowSigma {y | a ≤ dot (realPosition y) ℓ})) + (TubeThreat ℓ f a θ z δ H) := by + simp only [TubeThreat,Set.ofPred_exists] + apply MeasurableSet.iUnion + intro s + by_cases hs : 0 < s + · simp only [hs,true_and,Set.ofPred_and] + exact (MeasurableSet.const (s ≤ H)).inter + (measurableSet_lt (tubeLayerMass_upper_rows ℓ f a θ z hs).ennreal_toReal measurable_const) + · simp only [hs,false_and,Set.ofPred_false] + exact @MeasurableSet.empty _ (MeasurableSpace.prod inferInstance (rowSigma {y | a ≤ dot (realPosition y) ℓ})) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def FirstTubeThreat {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) + (s : ℕ) (π : Measure (Lattice d)) : Set (Environment d) := + {ω | 0 < s ∧ (tubeLayerMass ℓ f a θ z s π ω).toReal < δ ∧ + ∀ j, 0 < j → j < s → δ ≤ (tubeLayerMass ℓ f a θ z j π ω).toReal} + +lemma firstTubeThreat_disjoint {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) + (π : Measure (Lattice d)) : Pairwise (fun s t => + Disjoint (FirstTubeThreat ℓ f a θ z δ s π) (FirstTubeThreat ℓ f a θ z δ t π)) := by + intro s t hst + apply Set.disjoint_left.mpr + intro ω hs ht + rcases lt_or_gt_of_ne hst with h | h + · exact (not_lt_of_ge (ht.2.2 s hs.1 h)) hs.2.1 + · exact (not_lt_of_ge (hs.2.2 t ht.1 h)) ht.2.1 + +lemma firstTubeThreat_iUnion {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) + (π : Measure (Lattice d)) (H : ℕ) : + (⋃ s ≤ H, FirstTubeThreat ℓ f a θ z δ s π) = + {ω | (π,ω) ∈ TubeThreat ℓ f a θ z δ H} := by + ext ω + constructor + · intro h + obtain ⟨s,hs⟩ := Set.mem_iUnion.mp h + obtain ⟨hsH,hs⟩ := Set.mem_iUnion.mp hs + exact ⟨s,hs.1,hsH,hs.2.1⟩ + · rintro ⟨s,hs,hsH,hbad⟩ + have hex : ∃ j : ℕ, 0 < j ∧ (tubeLayerMass ℓ f a θ z j π ω).toReal < δ := ⟨s,hs,hbad⟩ + let j := Nat.find hex + have hj := Nat.find_spec hex + apply Set.mem_iUnion.mpr + refine ⟨j,Set.mem_iUnion.mpr ⟨(Nat.find_min' hex ⟨hs,hbad⟩).trans hsH,hj.1,hj.2,?_⟩⟩ + intro k hk hkj + by_contra! hh + exact Nat.find_min hex hkj ⟨hk,hh⟩ + +lemma firstTubeThreat_lower_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) + (s : ℕ) (π : Measure (Lattice d)) : + MeasurableSet[rowSigma {y | dot (realPosition y) ℓ < a+s}] + (FirstTubeThreat ℓ f a θ z δ s π) := by + let S : Set (Lattice d) := {y | dot (realPosition y) ℓ < a+s} + let : MeasurableSpace (Environment d) := rowSigma S + have hm (j : ℕ) (hj : 0 < j) (hjs : j ≤ s) : + @Measurable _ _ (rowSigma S) _ (fun ω => (tubeLayerMass ℓ f a θ z j π ω).toReal) := by + have hh := tubeLayerMass_joint_rows ℓ f a θ z hj S (fun x hx y hy => by + change dot (realPosition y) ℓ < a+s + have hcast : (j:ℝ) ≤ s := by exact_mod_cast hjs + have hh' := hy.2 + change dot (realPosition y) ℓ < dot (realPosition x) ℓ+j at hh' + rw [hx] at hh' + linarith) + have hp : @Measurable (Environment d) (Measure (Lattice d) × Environment d) + (rowSigma S) (MeasurableSpace.prod inferInstance (rowSigma S)) + (fun ω => (π,ω)) := measurable_const.prodMk measurable_id + have hc := hh.comp hp + exact hc.ennreal_toReal + by_cases hs : 0 < s + · simp only [FirstTubeThreat,hs,true_and,Set.ofPred_and] + apply (measurableSet_lt (hm s hs le_rfl) measurable_const).inter + simp only [Set.ofPred_forall] + apply MeasurableSet.iInter; intro j + apply MeasurableSet.iInter; intro hj + apply MeasurableSet.iInter; intro hjs + exact measurableSet_le measurable_const (hm j hj hjs.le) + · have he : FirstTubeThreat ℓ f a θ z δ s π = ∅ := by ext ω; simp [FirstTubeThreat,hs] + rw [he] + exact @MeasurableSet.empty _ (rowSigma S) + +lemma tubeThreat_probability_le {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) (H : ℕ) + (π : Measure (Lattice d)) (hπ : ∀ᵐ x ∂π, dot (realPosition x) ℓ = a) : + (environmentLaw ν).real {ω | (π,ω) ∈ TubeThreat ℓ f a θ z δ H} ≤ + (environmentLaw ν).real {ω | ∃ s ≤ H, + (∫ x, (quenchedKernel (ω,x)).real (TubePrefix ℓ f x θ z s) ∂π) < δ} := by + apply measureReal_mono (h₂ := measure_ne_top _ _) + rintro ω ⟨s,_,hsH,hh⟩ + exact ⟨s,hsH,by rwa [tubeLayerMass_eq ℓ f a θ z s π hπ ω,tubePrefixMass_toReal] at hh⟩ + +lemma fresh_random_tube_threat {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (a θ z δ : ℝ) (H : ℕ) + (S : Set (Lattice d)) (hST : Disjoint S {y | a ≤ dot (realPosition y) ℓ}) + (π : Environment d → Measure (Lattice d)) + (hπ : @Measurable _ _ (rowSigma S) _ π) (A : Set (Environment d)) + (hA : MeasurableSet[rowSigma S] A) (c : ℝ≥0∞) + (hbound : ∀ η ∈ A, environmentLaw ν {ω | (π η,ω) ∈ TubeThreat ℓ f a θ z δ H} ≤ c) : + environmentLaw ν {ω | ω ∈ A ∧ (π ω,ω) ∈ TubeThreat ℓ f a θ z δ H} ≤ c*environmentLaw ν A := by + let T : Set (Lattice d) := {y | a ≤ dot (realPosition y) ℓ} + let G : Set (Environment d × Environment d) := {p | (π p.1,p.2) ∈ TubeThreat ℓ f a θ z δ H} + have hG : @MeasurableSet (Environment d × Environment d) + (MeasurableSpace.prod (rowSigma S) (rowSigma T)) G := + (measurableSet_tubeThreat_upper ℓ f a θ z δ H).preimage + ((hπ.comp measurable_fst).prodMk measurable_snd) + have hV : @Measurable (Environment d) (Environment d) inferInstance (rowSigma T) id := + measurable_id.mono le_rfl (rowSigma_le T) + have hb (η : Environment d) (hη : η ∈ A) : + (@Measure.map (Environment d) (Environment d) inferInstance (rowSigma T) id (environmentLaw ν)) + {ω | (η,ω) ∈ G} ≤ c := by + have he : {ω | (η,ω) ∈ G} = Prod.mk η ⁻¹' G := rfl + rw [he,Measure.map_apply hV (hG.preimage measurable_prodMk_left)] + exact hbound η hη + exact @fresh_rows_random_test_bound d (Environment d) (Environment d) (rowSigma S) (rowSigma T) + ν _ S T hST id id measurable_id measurable_id A hA G hG c hb + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/TubePrefixMonoRadius.lean b/lean/OAI/Probability/Ballisticity/Geometry/TubePrefixMonoRadius.lean new file mode 100644 index 0000000000000000000000000000000000000000..45fcb8b1ac77a07c210824ba177f74590b50f68b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/TubePrefixMonoRadius.lean @@ -0,0 +1,451 @@ +import Mathlib +import OAI.Probability.Ballisticity.Coupling.QuenchedPrefixDeterminedFuture +import OAI.Probability.Ballisticity.Estimates.RecordOrPrefixAdd + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma tubePrefix_mono_radius {d : ℕ} (ℓ : Vector d) (f : Direction d) (x : Lattice d) + (θ z z' : ℝ) (hzz : z ≤ z') (s : ℕ) : TubePrefix ℓ f x θ z s ⊆ TubePrefix ℓ f x θ z' s := by + rintro X hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + apply Set.mem_iUnion.mpr + refine ⟨n,hn.1,?_⟩ + intro j hj + obtain ⟨a,ha,hr,hg⟩ := hn.2 j hj + exact ⟨a,ha,hr,hg.trans hzz⟩ + +lemma tubePrefixMass_mono_radius {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z z' : ℝ) (hzz : z ≤ z') (s : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + tubePrefixMass ℓ f θ z s π ω ≤ tubePrefixMass ℓ f θ z' s π ω := + lintegral_mono fun x => measure_mono (tubePrefix_mono_radius ℓ f x θ z z' hzz s) + +lemma tubePrefixMass_comp_le {d : ℕ} (e f : Direction d) + (θ z₁ z₂ : ℝ) (hz₂ : 0 ≤ z₂) (s k : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + tubePrefixMass (realPosition (step e)) f θ z₂ k + (tubeEndpointMixture (realPosition (step e)) f θ z₁ s π ω) ω ≤ + tubePrefixMass (realPosition (step e)) f θ (z₁+z₂) (s+k) π ω := by + let ℓ := realPosition (step e) + rw [tubePrefixMass,tubeEndpointMixture_future ℓ f θ z₁ s π ω + (fun y => TubePrefix ℓ f y θ z₂ k) (fun y => measurableSet_tubePrefix ℓ f y θ z₂ k)] + apply lintegral_mono; intro x + apply measure_mono_ae + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + intro hX + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp hX + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp hn.2 + exact Set.mem_iUnion.mpr ⟨n+m,tubePrefixAt_concatenate e f x θ z₁ z₂ hz₂ s n k m X h0 hnn hn.1 hm⟩ + +lemma directBridge_lintegral {d : ℕ} (e : Direction d) (π : Measure (Lattice d)) + (ω : Environment d) (G : Lattice d → ℝ≥0∞) : + (∫⁻ y, G y ∂directBridge e π ω) = ∫⁻ x, ((ω x).1 e : ℝ≥0∞)*G (x+step e) ∂π := by + rw [directBridge,lintegral_sum_measure,lintegral_countable'] + apply tsum_congr; intro x + rw [lintegral_smul_measure,lintegral_dirac',smul_eq_mul] + · ring + · exact measurable_of_countable G + +lemma single_step_tubePrefixAt {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (x : Lattice d) (θ : ℝ) (X : Path d) (h0 : X 0=x) (h1 : X 1=x+step e) : + X ∈ TubePrefixAt (realPosition (step e)) f x θ |θ| 1 1 := by + let ℓ := realPosition (step e) + have hheight : dot (realPosition (X 1)) ℓ = dot (realPosition x) ℓ+1 := by + rw [h1,signedHeight_projection,signedHeight_add_step_self,Int.cast_add,Int.cast_one,signedHeight_projection] + have hzero : dot (realPosition (0:Lattice d)) ℓ=0 := by simp [dot,realPosition] + have hstrict : StrictRecord ℓ (fun k => X k-x) 1 := by + intro j hj + have hj0 : j=0 := by omega + simp only [hj0,h0,sub_self,hzero] + rw [dot_realPosition_sub,hheight] + linarith + refine ⟨⟨?_,?_⟩,?_⟩ + · simpa only [Upper,Set.mem_ofPred_eq,Nat.cast_one] using le_of_eq hheight.symm + · intro j hj + have hj0 : j=0 := by omega + simp only [Strip,Set.mem_ofPred_eq,Nat.cast_one,hj0,h0] + exact ⟨le_rfl,lt_add_one _⟩ + · intro j hj + rcases show j=0 ∨ j=1 by omega with rfl | rfl + · refine ⟨0,by omega,by simp [RecordOrZeroPrefix],?_⟩ + simp [h0,signedCoordinate] + · refine ⟨1,le_rfl,?_,?_⟩ + · rw [RecordOrZeroPrefix,ite_eq_right (by decide : (1:ℕ) ≠ 0)] + refine ⟨by decide,hstrict,?_,?_⟩ + · rw [show (1:ℕ)=0+1 from rfl,recordCount_succ,recordCount_zero,ite_eq_left hstrict] + · intro j hj + rcases show j=0 ∨ j=1 by omega with rfl | rfl + · change dot (realPosition (0:Lattice d)) ℓ ≤ dot (realPosition (X 0-x)) ℓ + rw [h0,sub_self] + · change dot (realPosition (0:Lattice d)) ℓ ≤ dot (realPosition (X 1-x)) ℓ + rw [dot_realPosition_sub,hheight,hzero]; linarith + · have he : X 1-x = step e := by rw [h1]; abel + have hz : signedCoordinate f (step e)=0 := by + have hh := signedCoordinate_add_distinct_step e f hef (0:Lattice d) + simpa [signedCoordinate] using hh + simp only [he,hz,Nat.cast_one,one_mul,zero_sub,abs_neg,le_refl] + +lemma directBridge_tubeMass_le {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (θ z : ℝ) (hz : 0 ≤ z) (k : ℕ) (π : Measure (Lattice d)) (ω : Environment d) : + tubePrefixMass (realPosition (step e)) f θ z k (directBridge e π ω) ω ≤ + tubePrefixMass (realPosition (step e)) f θ (|θ|+z) (1+k) π ω := by + let ℓ := realPosition (step e) + rw [tubePrefixMass,directBridge_lintegral] + apply lintegral_mono; intro x + let v := wordPath x [e] + have hm := quenched_prefix_future ω x v (by simp [v]) 1 + (measurableSet_tubePrefix ℓ f (x+step e) θ z k) + have hv1 : v 1=x+step e := by simp [v,wordPath] + rw [hv1,show pathCylinder v 1=wordCylinder x [e] from rfl,quenched_wordCylinder] at hm + have hw : ENNReal.ofReal (wordWeight ω x [e])=((ω x).1 e:ℝ≥0∞) := by simp [wordWeight] + rw [hw] at hm + change ((ω x).1 e:ℝ≥0∞)*(quenchedKernel (ω,x+step e)) (TubePrefix ℓ f (x+step e) θ z k) ≤ _ + rw [← hm] + apply measure_mono_ae + filter_upwards [quenched_nearest_neighbor (ω,x)] with X hnn + rintro ⟨hfut,hcy⟩ + have h0 : X 0=x := by simpa [v] using hcy 0 (by omega) + have h1 : X 1=x+step e := by simpa [wordPath] using hcy 1 le_rfl + obtain ⟨m,hm⟩ := Set.mem_iUnion.mp hfut + apply Set.mem_iUnion.mpr + exact ⟨1+m,tubePrefixAt_concatenate e f x θ |θ| z hz 1 1 k m X h0 hnn + (single_step_tubePrefixAt e f hef x θ X h0 h1) (by simpa only [h1] using hm)⟩ + +lemma bridged_continuation_le_tube {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (θ z : ℝ) (hz : 0 ≤ z) (hθ : |θ| ≤ z) (H s : ℕ) (hs0 : 0 < s) (hsH : s ≤ H) + (π : Measure (Lattice d)) (ω : Environment d) : + tubePrefixMass (realPosition (step e)) f θ z (H-s) + (directBridge e (stoppedTubeEndpoint (realPosition (step e)) f θ z (s-1) π ω) ω) ω ≤ + tubePrefixMass (realPosition (step e)) f θ (3*z) H π ω := by + let ℓ := realPosition (step e) + have hb := directBridge_tubeMass_le e f hef θ z hz (H-s) + (stoppedTubeEndpoint ℓ f θ z (s-1) π ω) ω + by_cases hs : s-1=0 + · have hs1 : s=1 := by omega + have he : 1+(H-s)=H := by omega + simp only [stoppedTubeEndpoint,hs,ite_eq_left,he] at hb + simpa only [stoppedTubeEndpoint,hs,ite_eq_left] using hb.trans (tubePrefixMass_mono_radius ℓ f θ (|θ|+z) (3*z) (by linarith) H π ω) + · simp only [stoppedTubeEndpoint,hs] at hb + have hc := tubePrefixMass_comp_le e f θ z (|θ|+z) (by positivity) (s-1) (1+(H-s)) π ω + have he : (s-1)+(1+(H-s))=H := by omega + rw [he] at hc + simpa only [stoppedTubeEndpoint,hs,ite_false] using (hb.trans hc).trans (tubePrefixMass_mono_radius ℓ f θ (z+(|θ|+z)) (3*z) (by linarith) H π ω) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma tubePrefixMass_ne_top {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (s : ℕ) (π : Measure (Lattice d)) [IsFiniteMeasure π] (ω : Environment d) : + tubePrefixMass ℓ f θ z s π ω ≠ ⊤ := by + rw [← tubeEndpointMixture_total] + exact measure_ne_top _ _ + +theorem short_block_slope_survival {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {w : ℝ} (hw : 0 < w) (hw1 : w ≤ 20) : + ∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℝ, 0 < t₀ ∧ ∀ t : ℝ, 0 < t → t ≤ t₀ → + ∃ δ : ℝ, 0 < δ ∧ ∃ R : ℝ, 0 < R ∧ + ∀ r : ℝ, R ≤ r → ∀ H : ℕ, 0 < H → + (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := (recordMedian ν ℓ hp f H:ℝ)/H + ∀ (a : ℤ) (π : Measure (Lattice d)), IsProbabilityMeasure π → + (∀ᵐ x ∂π, signedHeight e x = a) → + (environmentLaw ν).real {ω | (tubePrefixMass ℓ f θ (3*(w*r)) H π ω).toReal < δ} ≤ C*t^2 := by + obtain ⟨C,hC,t₀,ht₀,hb⟩ := canonical_two_tube_threat ν hue e f hef htrans hw hw1 + obtain ⟨κ,hκ,hUE⟩ := environment_uniform_elliptic ν hue + refine ⟨C,hC,t₀,ht₀,?_⟩ + intro t ht htt + obtain ⟨δ₀,hδ₀,hδ₀1,R,hR,hb⟩ := hb t ht htt + let δ := min δ₀ ((κ:ℝ)*δ₀^2) + have hκreal : (0:ℝ) < κ := by exact_mod_cast hκ + have hδ : 0 < δ := lt_min hδ₀ (by positivity) + refine ⟨δ,hδ,R,hR,?_⟩ + intro r hr H hH hscale + obtain ⟨hθ,hb⟩ := hb r hr H hH hscale + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := (recordMedian ν ℓ hp f H:ℝ)/H + dsimp only + intro a π hπ hsupp + let := hπ + obtain ⟨x₀,hx₀⟩ := hsupp.exists + have hb' := hb a x₀ hx₀ π hπ hsupp + have hz : 0 ≤ w*r := mul_nonneg hw.le (hR.trans_le hr).le + have hδ1 : δ₀ ≤ 1 := by linarith + have hπ' : ∀ᵐ x ∂π, dot (realPosition x) ℓ = (a:ℝ) := + hsupp.mono fun x hx => by rw [signedHeight_projection,hx] + have hδEN : ENNReal.ofReal δ ≤ (κ:ℝ≥0∞)*ENNReal.ofReal δ₀*ENNReal.ofReal δ₀ := by + have he : ENNReal.ofReal ((κ:ℝ)*δ₀^2) = (κ:ℝ≥0∞)*ENNReal.ofReal δ₀*ENNReal.ofReal δ₀ := by + rw [pow_two,← mul_assoc,ENNReal.ofReal_mul (mul_nonneg hκreal.le hδ₀.le), + ENNReal.ofReal_mul hκreal.le,ENNReal.ofReal_coe_nnreal] + rw [← he] + exact ENNReal.ofReal_le_ofReal (min_le_right _ _) + have hle : environmentLaw ν {ω | (tubePrefixMass ℓ f θ (3*(w*r)) H π ω).toReal < δ} ≤ + environmentLaw ν (⋃ s ∈ Finset.range (H+1), + {ω | ω ∈ FirstTubeThreat ℓ f a θ (w*r) δ₀ s π ∧ + (bridgedRestart e f x₀ θ (w*r) π s ω,ω) ∈ TubeThreat ℓ f ((a:ℝ)+s) θ (w*r) δ₀ H}) := by + apply measure_mono_ae + filter_upwards [hUE] with ω hω + intro hbad + have hcontra (h : ENNReal.ofReal δ ≤ tubePrefixMass ℓ f θ (3*(w*r)) H π ω) : False := by + have hh := ENNReal.toReal_mono (tubePrefixMass_ne_top ℓ f θ (3*(w*r)) H π ω) h + rw [ENNReal.toReal_ofReal hδ.le] at hh + exact (not_lt_of_ge hh) hbad + by_cases hfirst : (π,ω) ∈ TubeThreat ℓ f a θ (w*r) δ₀ H + · have hh : ω ∈ ⋃ s ≤ H, FirstTubeThreat ℓ f a θ (w*r) δ₀ s π := by + rw [firstTubeThreat_iUnion] + exact hfirst + obtain ⟨s,hs⟩ := Set.mem_iUnion.mp hh + obtain ⟨hsH,hs⟩ := Set.mem_iUnion.mp hs + by_cases hsecond : (bridgedRestart e f x₀ θ (w*r) π s ω,ω) ∈ TubeThreat ℓ f ((a:ℝ)+s) θ (w*r) δ₀ H + · exact Set.mem_iUnion.mpr ⟨s,Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr (Nat.lt_succ_of_le hsH),hs,hsecond⟩⟩ + · exfalso + apply hcontra + exact (hδEN.trans (firstThreat_noSecond_retained_mass e f a x₀ hx₀ θ (w*r) δ₀ hz hδ1 H s hsH π hsupp ω + κ (fun y => hω y e) hs hsecond)).trans + (bridged_continuation_le_tube e f hef θ (w*r) hz hθ H s hs.1 hsH π ω) + · exfalso + apply hcontra + exact ((ENNReal.ofReal_le_ofReal (min_le_left _ _)).trans + (noThreat_mass_lower ℓ f a θ (w*r) δ₀ hz hδ1 H π hπ' ω hfirst le_rfl)).trans + (tubePrefixMass_mono_radius ℓ f θ (w*r) (3*(w*r)) (by linarith) H π ω) + exact (ENNReal.toReal_mono (measure_ne_top _ _) hle).trans hb' + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/WeightedConditionedTubeTransfer.lean b/lean/OAI/Probability/Ballisticity/Geometry/WeightedConditionedTubeTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..02103cf7fa76795ee7a6e20e38a4ebc69d281cbd --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/WeightedConditionedTubeTransfer.lean @@ -0,0 +1,238 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RecordPrefixControl + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem weightedConditioned_tube_transfer {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (htrans : DirectionallyTransient ν ℓ) + (b : ℕ → ℝ) (H : ℕ → ℕ) (z : ℕ → ℝ) (hz : Tendsto z atTop atTop) + (hsmall : ∀ᶠ i in atTop, (conditionedLaw ν ℓ).real + (MedianTubeFailure ℓ f b (H i) (z i/10)) ≤ 3/10) + (J : ℝ) (hJ : 0 ≤ J) (g : Environment d → ℝ≥0∞) + (hg : @Measurable _ _ (rowSigma {x | dot (realPosition x) ℓ ≤ J}) _ g) + (hgle : ∀ ω, g ω ≤ 1) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ i in atTop, (weightedConditioned ν ℓ g).real (MedianTubeFailure ℓ f b (H i) (z i)) ≤ + (weightedConditioned ν ℓ g).real Set.univ * + (conditionedLaw ν ℓ).real (MedianTubeFailure ℓ f b (H i) (z i/10))+ε := by + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let η := weightedConditioned ν ℓ g + let : IsFiniteMeasure η := weightedConditioned_finite ν ℓ g (hg.mono (rowSigma_le _) le_rfl) hgle + have hac : η ≪ μ := Measure.absolutelyContinuous_of_le + (weightedConditioned_le ν ℓ g (hg.mono (rowSigma_le _) le_rfl) hgle) + have hcnt : Measurable (fun X => (highRecordCount ℓ J X:ℝ)) := + (measurable_of_countable (fun k : ℕ => (k:ℝ))).comp (measurable_highRecordCount ℓ J hJ) + have hc := fixed_real_tail_small η _ hcnt (fun n : ℕ => (n:ℝ)) tendsto_natCast_atTop_atTop + obtain ⟨R,hR⟩ := (hc.eventually (gt_mem_nhds (show (0:ℝ) < ε/2 by positivity))).exists + have hR' : η.real {X | R < highRecordCount ℓ J X} < ε/2 := by + apply lt_of_le_of_lt (measureReal_mono (μ := η) ?_) hR + intro X hX + change (R:ℝ) ≤ |(highRecordCount ℓ J X:ℝ)| + rw [abs_of_nonneg (Nat.cast_nonneg _)] + exact_mod_cast hX.le + have hp := fixed_real_tail_small η _ (measurable_recordPrefixControl ℓ f b J hJ) + (fun i => z i/10) (hz.atTop_div_const (by norm_num)) + have hpe := hp.eventually (gt_mem_nhds (show (0:ℝ) < ε/2 by positivity)) + have hmed := median_shift_eventually ν ℓ f htrans b H z hz hsmall R + filter_upwards [hpe,hmed,hz.eventually_gt_atTop 0] with i hi hmi hzi + let A := MedianTubeFailure ℓ f b (H i) (z i/10) + let B := highSuffix ℓ J ⁻¹' A + let C := {X | R < highRecordCount ℓ J X} + let E := {X | z i/10 ≤ |recordPrefixControl ℓ f b J X|} + have hs := hac.ae_le (medianTube_suffix_subset_ae ν ℓ f htrans b J hJ (H i) R hzi hmi) + have hb : η.real (MedianTubeFailure ℓ f b (H i) (z i)) ≤ η.real (B ∪ C ∪ E) := + ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hs) + have hmap := weightedConditioned_highSuffix ν ℓ htrans J hJ g hg hgle + have hB : η.real B = η.real Set.univ * μ.real A := by + have hh := congrArg (fun ρ : Measure (Path d) => ρ A) hmap + rw [Measure.map_apply (measurable_highSuffix ℓ J hJ) + (measurableSet_medianTubeFailure ℓ f b (H i) (z i/10)),Measure.smul_apply] at hh + have hhr := congrArg ENNReal.toReal hh + simpa only [smul_eq_mul,ENNReal.toReal_mul,Measure.real,η,μ,B] using hhr + have hu := measureReal_union_le (μ := η) (B ∪ C) E + have hu' := measureReal_union_le (μ := η) B C + change η.real E < ε/2 at hi + change η.real C < ε/2 at hR' + change η.real (MedianTubeFailure ℓ f b (H i) (z i)) ≤ η.real Set.univ*μ.real A+ε + linarith + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/WindowProjection.lean b/lean/OAI/Probability/Ballisticity/Geometry/WindowProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..b62e257f7b7c2c7dec106d2ac2a63c051f37aa9c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/WindowProjection.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.AnchorFrameReference +import OAI.Probability.Ballisticity.Geometry.RawWindow +import OAI.Probability.Ballisticity.Estimates.InputMarginal + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +abbrev CurrentProfiles {d : ℕ} (e : Direction d) := + (ℕ × HorizontalSpace e) → Set.Icc (0 : ℝ) 1 + +abbrev CurrentWindow {d : ℕ} (e : Direction d) := + (ReferenceClasses.Data (HorizontalSpace e) × CurrentProfiles e) × + ReferenceClasses.AllFields (HorizontalSpace e) (Row d) + +noncomputable def rawCurrentProfiles {d : ℕ} (e : Direction d) + (z : RawCurrentData e) : CurrentProfiles e := + fun p => globalHorizontalCoordinate e z.1 z.2.1 (z.2.2 p.1 + p.2) + +lemma rawCurrentProfileCoordinate_measurable {d : ℕ} (e : Direction d) + (a : ℕ) (z : HorizontalSpace e) : + Measurable (fun p : RawCurrentData e => globalHorizontalCoordinate e p.1 p.2.1 (p.2.2 a+z)) := by + have hw : Measurable (fun p : RawCurrentData e => p.2.1) := measurable_fst.comp measurable_snd + have hn : Measurable (fun p : RawCurrentData e => p.1) := measurable_fst + have hu : Measurable (fun p : RawCurrentData e => p.2.2 a) := + (measurable_pi_apply a).comp (measurable_snd.comp measurable_snd) + have ha : Measurable (fun p : RawCurrentData e => ((p.2.1,p.1),p.2.2 a+z)) := + (hw.prodMk hn).prodMk (hu.add_const z) + have hm := (globalHorizontalCoordinate_joint_measurable e).comp ha + simpa only [Function.comp_def] using hm + +lemma rawCurrentProfiles_measurable {d : ℕ} (e : Direction d) : + Measurable (rawCurrentProfiles e) := + Measurable.of_eval fun p => rawCurrentProfileCoordinate_measurable e p.1 p.2 + +noncomputable def rawCurrentProjection {d : ℕ} (e : Direction d) + (p : RawCurrentData e × LocalUpperField e) : CurrentWindow e := + ((ReferenceClasses.anchorOffsets p.1.2.2,rawCurrentProfiles e p.1), + ReferenceClasses.anchorFields p.1.2.2 p.2) + +lemma rawCurrentProjection_measurable {d : ℕ} (e : Direction d) : + Measurable (rawCurrentProjection e) := by + have hU : Measurable (fun p : RawCurrentData e × LocalUpperField e => p.1.2.2) := + measurable_snd.comp (measurable_snd.comp measurable_fst) + exact ((ReferenceClasses.anchorOffsets_measurable.comp hU).prodMk + ((rawCurrentProfiles_measurable e).comp measurable_fst)).prodMk + (ReferenceClasses.anchorFields_measurable.comp (hU.prodMk measurable_snd)) + +noncomputable def currentWindowReference {d : ℕ} (e : Direction d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] : + Kernel (ReferenceClasses.Data (HorizontalSpace e) × CurrentProfiles e) + (ReferenceClasses.AllFields (HorizontalSpace e) (Row d)) := + (ReferenceClasses.reference ν).comap Prod.fst measurable_fst + +instance currentWindowReference_markov {d : ℕ} (e : Direction d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] : IsMarkovKernel (currentWindowReference e ν) := by + unfold currentWindowReference + infer_instance + +lemma rawCurrentProjection_kl_le {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (μ : Measure (RawCurrentData e × LocalUpperField e)) [IsFiniteMeasure μ] : + let out := μ.map (rawCurrentProjection e) + klDiv out (out.fst.compProd (currentWindowReference e ν)) ≤ + klDiv μ (μ.fst.prod (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν))) := by + exact ReferenceClasses.anchorFrame_kl_le μ ν (fun z => z.2.2) + (measurable_snd.comp measurable_snd) (rawCurrentProfiles e) (rawCurrentProfiles_measurable e) + +noncomputable def actualCurrentWindow {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (i : ℤ) (m : ℕ) (X : EpisodeInput e) : CurrentWindow e := + ((ReferenceClasses.anchorOffsets (fun a => X.1.2 (i,a)), + fun p => globalHorizontalCoordinate e (t X.1.1 i) X.1.1 (X.1.2 (i,p.1)+p.2)), + fun p => episodeSplicedRow e t X i m p.1 p.2.1 p.2.2) + +lemma actualCurrentWindow_measurable {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (i : ℤ) (m : ℕ) : Measurable (actualCurrentWindow e t i m) := by + have hu : Measurable (fun X : EpisodeInput e => fun a => X.1.2 (i,a)) := + Measurable.of_eval fun a => (measurable_pi_apply (i,a)).comp + (measurable_snd.comp measurable_fst) + have ho := ReferenceClasses.anchorOffsets_measurable.comp hu + have hp : Measurable (fun X : EpisodeInput e => fun p : ℕ × HorizontalSpace e => + globalHorizontalCoordinate e (t X.1.1 i) X.1.1 (X.1.2 (i,p.1)+p.2)) := + Measurable.of_eval fun p => actualArrayCoordinate_measurable e t ht i (i,p.1) p.2 + have hf : Measurable (fun X : EpisodeInput e => fun p : ReferenceClasses.Site (HorizontalSpace e) => + episodeSplicedRow e t X i m p.1 p.2.1 p.2.2) := + Measurable.of_eval fun p => episodeSplicedRow_measurable e t ht i m p.1 p.2.1 p.2.2 + exact (ho.prodMk hp).prodMk hf + +lemma globalHorizontalCoordinate_stoppedObservation {d : ℕ} (e : Direction d) + (τ : Environment d → ℕ) + (hτ : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | τ ω=n}) + (filler ω : Environment d) (z : HorizontalSpace e) : + globalHorizontalCoordinate e (τ ω) + (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) τ filler ω) z = + globalHorizontalCoordinate e (τ ω) ω z := by + have h := currentStoppedProfile_observation e τ hτ filler ω + have hn : τ (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) τ filler ω) = τ ω := + stoppedRowGraft_stop (fun n => BelowHeight (realPosition (step e)) n) τ hτ ω filler + dsimp only [currentStoppedProfile] at h + rw [hn] at h + apply Subtype.ext + exact congrArg (fun μ : Measure (HorizontalSpace e) => (μ {z}).toReal) h + +lemma actualCurrentWindow_raw {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (i : ℤ) (m : ℕ) + (ht : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] + {ω | t ω i=n}) (filler : Environment d) (X : EpisodeInput e) : + rawCurrentProjection e ((t X.1.1 i, + (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) + (fun ω => t ω i) filler X.1.1,fun a => X.1.2 (i,a))), + localStoppedField e (fun ω => t ω i) (fun ω => t ω (i+m)) (X.1.1,X.2 (i,m))) = + actualCurrentWindow e t i m X := by + dsimp only [rawCurrentProjection,actualCurrentWindow,rawCurrentProfiles] + refine Prod.ext (Prod.ext rfl ?_) ?_ + · funext p + exact globalHorizontalCoordinate_stoppedObservation e (fun ω => t ω i) ht filler X.1.1 _ + · funext p + dsimp only [ReferenceClasses.anchorFields,localStoppedField,episodeSplicedRow] + +theorem actualCurrentWindow_law {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (i : ℤ) (m : ℕ) + (hi : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | t ω i=n}) + (him : ∀ n : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {ω | t ω (i+m)=n}) + (filler : Environment d) : + (rawCurrentWindow e ν Q (fun ω => t ω i) (fun ω => t ω (i+m)) (ht i) filler).map + (rawCurrentProjection e) = + (episodeInputLaw e ν Q t ht).map (actualCurrentWindow e t i m) := by + unfold rawCurrentWindow + rw [← episodeInputLaw_current e ν Q t ht i m] + rw [Measure.map_map (rawCurrentWindow_measurable e _ _ hi him filler) + (currentInput_measurable e i m)] + rw [Measure.map_map (rawCurrentProjection_measurable e)] + · congr 1 + funext X + exact actualCurrentWindow_raw e t i m hi filler X + · exact (rawCurrentWindow_measurable e _ _ hi him filler).comp (currentInput_measurable e i m) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/WindowWeak.lean b/lean/OAI/Probability/Ballisticity/Geometry/WindowWeak.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a934af860da095b34f7c232e97d0089ff812f90 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/WindowWeak.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.WindowEntropy +import OAI.Probability.Ballisticity.Estimates.ClosedEmbeddingWeak +import OAI.Probability.Ballisticity.Estimates.ReferenceFeller +import OAI.Probability.Ballisticity.Entropy.EntropyContinuousTests + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory TopologicalSpace Filter +open scoped ENNReal Classical Topology +namespace DirectionalTransience + +instance currentDataProfiles_secondCountable {d : ℕ} (e : Direction d) : + SecondCountableTopology (ReferenceClasses.Data (HorizontalSpace e) × CurrentProfiles e) := inferInstance +instance currentDataProfiles_compact {d : ℕ} (e : Direction d) : + CompactSpace (ReferenceClasses.Data (HorizontalSpace e) × CurrentProfiles e) := inferInstance +instance currentFields_compact {d : ℕ} (e : Direction d) : + CompactSpace (ReferenceClasses.AllFields (HorizontalSpace e) (Row d)) := inferInstance +instance currentWindow_compact {d : ℕ} (e : Direction d) : CompactSpace (CurrentWindow e) := inferInstance +instance currentWindow_secondCountable {d : ℕ} (e : Direction d) : SecondCountableTopology (CurrentWindow e) := inferInstance + +instance currentWindow_opens {d : ℕ} (e : Direction d) : OpensMeasurableSpace (CurrentWindow e) := inferInstance +instance currentDataProfiles_borel {d : ℕ} (e : Direction d) : + BorelSpace (ReferenceClasses.Data (HorizontalSpace e) × CurrentProfiles e) := inferInstance +instance currentDataProfiles_opens {d : ℕ} (e : Direction d) : + OpensMeasurableSpace (ReferenceClasses.Data (HorizontalSpace e) × CurrentProfiles e) := inferInstance + +lemma actualCurrentLaw_include {d : ℕ} (e : Direction d) (m : ℕ) + (L : ProbabilityMeasure (ActualEpisodeArray e)) + (hc : ∀ᵐ Y ∂(L : Measure (ActualEpisodeArray e)), ReferenceClasses.Consistent (currentOffsets e 0 Y)) : + (actualCurrentLaw e m L).map (currentWindowInclude e) = + L.map (currentArrayWindow e 0 m) := by + apply Subtype.ext + change ((L : Measure _).map (typedCurrentArrayWindow e 0 m)).map (currentWindowInclude e) = _ + rw [Measure.map_map (currentWindowInclude_continuous e).measurable (typedCurrentArrayWindow_measurable e 0 m)] + apply Measure.map_congr + filter_upwards [hc] with Y hY + exact currentWindowInclude_typed e 0 m Y hY + +lemma actualCurrentLaw_tendsto {d : ℕ} (e : Direction d) (m : ℕ) + (Ls : ℕ → ProbabilityMeasure (ActualEpisodeArray e)) (L : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto Ls atTop (𝓝 L)) + (hc : ∀ n, ∀ᵐ Y ∂(Ls n : Measure (ActualEpisodeArray e)), ∀ j, ReferenceClasses.Consistent (currentOffsets e j Y)) : + Tendsto (fun n => actualCurrentLaw e m (Ls n)) atTop (𝓝 (actualCurrentLaw e m L)) := by + have hL := closed_support_weak_limit Ls L hlim _ (currentOffsets_closed e) hc + apply Entropy.tendsto_of_map_closedEmbedding (currentWindowInclude e) + ((currentWindowInclude_continuous e).isClosedEmbedding (currentWindowInclude_injective e)) + have hi (n : ℕ) := actualCurrentLaw_include e m (Ls n) ((hc n).mono fun _ h => h 0) + simp_rw [hi,actualCurrentLaw_include e m L (hL.mono fun _ h => h 0)] + exact ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous Ls L hlim + (currentArrayWindow_continuous e 0 m) + +noncomputable def currentReferenceLaw {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (W : ProbabilityMeasure (CurrentWindow e)) : + ProbabilityMeasure (CurrentWindow e) := + Entropy.compProdProb (W.map Prod.fst) (currentWindowReference e ν) + +lemma currentReferenceLaw_tendsto {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {I : Type*} {l : Filter I} {Ws : I → ProbabilityMeasure (CurrentWindow e)} {W : ProbabilityMeasure (CurrentWindow e)} + (h : Tendsto Ws l (𝓝 W)) : + Tendsto (fun n => currentReferenceLaw e ν (Ws n)) l (𝓝 (currentReferenceLaw e ν W)) := by + have hK : Continuous (Entropy.kernelProb (currentWindowReference e ν)) := + (ReferenceClasses.referenceProb_continuous ν).comp continuous_fst + exact Entropy.compProdProb_tendsto (currentWindowReference e ν) hK + (ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous Ws W h continuous_fst) + +theorem actualCurrentLaw_kl_weak_limit {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (m : ℕ) + (Ls : ℕ → ProbabilityMeasure (ActualEpisodeArray e)) (L : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto Ls atTop (𝓝 L)) + (hc : ∀ n, ∀ᵐ Y ∂(Ls n : Measure (ActualEpisodeArray e)), ∀ j, ReferenceClasses.Consistent (currentOffsets e j Y)) + (C : ℝ) (hC : 0≤C) + (hb : ∀ n, klDiv (actualCurrentLaw e m (Ls n) : Measure (CurrentWindow e)) + (currentReferenceLaw e ν (actualCurrentLaw e m (Ls n)) : Measure (CurrentWindow e)) ≤ ENNReal.ofReal C) : + klDiv (actualCurrentLaw e m L : Measure (CurrentWindow e)) + (currentReferenceLaw e ν (actualCurrentLaw e m L) : Measure (CurrentWindow e)) ≤ ENNReal.ofReal C := by + have ht := actualCurrentLaw_tendsto e m Ls L hlim hc + exact Entropy.kl_le_of_weak_limit _ _ _ _ ht (currentReferenceLaw_tendsto e ν ht) hC (Filter.Eventually.of_forall hb) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/WordCoordinate.lean b/lean/OAI/Probability/Ballisticity/Geometry/WordCoordinate.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c26d7320cd83ee9762bbf85616377ed6ff502bf --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/WordCoordinate.lean @@ -0,0 +1,446 @@ +import Mathlib +import OAI.Probability.Ballisticity.Renewal.Regeneration + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma ratio_hit_geometric {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (u : Direction d) (hℓ : ∀ i, |ℓ i| ≤ 1) + (b a D H ε : ℝ) (hb : 0 ≤ b) (ha : 1 ≤ a) (hD : 0 ≤ D) + (_hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (A : Set (Path d)) (hA : MeasurableSet A) (hp : ε ≤ (annealedLaw ν).real A) + (hcontrol : ∀ Z ∈ A, ∀ k, (0 ≤ tiltedCoordinate ℓ u b a (Z k) ∧ + signedCoordinate u (Z k) ≤ a*D*(1+dot (realPosition (Z k)) ℓ)) ∨ + H < dot (realPosition (Z k)) ℓ) (j : ℕ) : + (annealedLaw ν).real (RatioHit ℓ u b a H (1+j*(2*b+1+D))) ≤ (1-ε)^j := by + induction j with + | zero => simp [measureReal_le_one] + | succ j ih => + have ht : 0 < 1+(j : ℝ)*(2*b+1+D) := by positivity + have hc := ratio_threshold_contraction ν ℓ u hℓ b a D H _ hb ha hD ht A hA hcontrol + have hcoef : 0 ≤ 1-(annealedLaw ν).real A := sub_nonneg.mpr measureReal_le_one + have hmul := mul_le_mul_of_nonneg_left ih hcoef + have hpow := mul_le_mul_of_nonneg_right (show 1-(annealedLaw ν).real A ≤ 1-ε by linarith) + (pow_nonneg (by linarith : 0 ≤ 1-ε) j) + have he : 1+(j+1 : ℕ)*(2*b+1+D) = (1+(j : ℝ)*(2*b+1+D))+(2*b+1+D) := by + push_cast; ring + rw [he,pow_succ] + nlinarith + +lemma forwardTemplate_probability_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (e : Direction d) + (he : 0 < dot (realPosition (step e)) ℓ) (c C C0 a : ℝ) (K M : ℕ) + (κ : ℝ≥0) (hκ : ∀ᵐ ω ∂environmentLaw ν, ∀ x e, κ ≤ (ω x).1 e) + (hg : (4/5 : ℝ) ≤ (conditionedLaw ν ℓ).real (WordTemplate ℓ c C C0 a K)) : + (κ : ℝ)^M*(annealedLaw ν).real (NoDrop ℓ 0)*(4/5) ≤ + (annealedLaw ν).real (ForwardTemplate ℓ e c C C0 a K M) := by + have heq := congrArg ENNReal.toReal (forwardTemplate_probability ν ℓ htrans e he c C C0 a K M) + simp only [ENNReal.toReal_mul] at heq + change _ ≤ (annealedLaw ν (ForwardTemplate ℓ e c C C0 a K M)).toReal + rw [heq] + have hlo := ENNReal.toReal_mono (measure_ne_top _ _) + (annealed_wordCylinder_lower ν κ hκ (List.replicate M e)) + simp only [List.length_replicate, ENNReal.toReal_pow, ENNReal.coe_toReal] at hlo + exact mul_le_mul + (mul_le_mul_of_nonneg_right hlo measureReal_nonneg) hg (by norm_num) + (mul_nonneg measureReal_nonneg measureReal_nonneg) + +lemma ratio_hit_union_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hℓ : ∀ i, |ℓ i| ≤ 1) (b a D H ε : ℝ) + (hb : 0 ≤ b) (ha : 1 ≤ a) (hD : 0 ≤ D) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (A : Set (Path d)) (hA : MeasurableSet A) (hp : ε ≤ (annealedLaw ν).real A) + (hcontrol : ∀ u Z, Z ∈ A → ∀ k, (0 ≤ tiltedCoordinate ℓ u b a (Z k) ∧ + signedCoordinate u (Z k) ≤ a*D*(1+dot (realPosition (Z k)) ℓ)) ∨ + H < dot (realPosition (Z k)) ℓ) (j : ℕ) : + (annealedLaw ν).real (⋃ u : Direction d, RatioHit ℓ u b a H (1+j*(2*b+1+D))) ≤ + (2*d : ℕ)*(1-ε)^j := by + classical + have h := measureReal_iUnion_fintype_le (μ := annealedLaw ν) + (fun u : Direction d => RatioHit ℓ u b a H (1+j*(2*b+1+D))) + refine h.trans ?_ + have hs := Finset.sum_le_sum (s := Finset.univ) (fun u _ => + ratio_hit_geometric ν ℓ u hℓ b a D H ε hb ha hD hε hε1 A hA hp (hcontrol u) j) + simpa [Direction, Fintype.card_prod, mul_comm] using hs + +lemma annealed_ge_noDrop_mul_conditioned {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (A : Set (Path d)) (hA : MeasurableSet A) : + (annealedLaw ν).real (NoDrop ℓ 0)*(conditionedLaw ν ℓ).real A ≤ (annealedLaw ν).real A := by + have hh : annealedLaw ν (NoDrop ℓ 0)*conditionedLaw ν ℓ A = annealedLaw ν (A ∩ NoDrop ℓ 0) := by + rw [conditionedLaw,Measure.smul_apply,Measure.restrict_apply hA,smul_eq_mul, + ← mul_assoc,ENNReal.mul_inv_cancel hp (measure_ne_top _ _),one_mul] + have he : (annealedLaw ν).real (NoDrop ℓ 0)*(conditionedLaw ν ℓ).real A = + (annealedLaw ν).real (A ∩ NoDrop ℓ 0) := by + simpa only [measureReal_def,ENNReal.toReal_mul] using congrArg ENNReal.toReal hh + rw [he] + exact measureReal_mono Set.inter_subset_left + +lemma large_excursion_ratio {d : ℕ} (ℓ : Vector d) (X : Path d) + (h0 : X 0 = 0) (hNN : ∀ n, ∃ e : Direction d, X (n+1) = X n+step e) + (b a C B t : ℝ) (hb : 0 ≤ b) (ha : 0 < a) (hC : 0 ≤ C) (ht : 0 ≤ t) + (hB : (d : ℝ)*t*(C+3) ≤ B-1) (i N n : ℕ) (hi : 1 ≤ i) (hiN : i ≤ N) + (hn : (B-1)*a*i < ‖latticeVector (X n)‖) + (hh : ∀ j ≤ n, 0 ≤ dot (realPosition (X j)) ℓ ∧ dot (realPosition (X j)) ℓ ≤ (C+2)*i) : + X ∈ ⋃ u : Direction d, RatioHit ℓ u b a ((C+2)*N) t := by + have hi' : (1 : ℝ) ≤ i := by exact_mod_cast hi + have hM := runningHeight_le ℓ X n ((C+2)*i) (by positivity) (fun j hj => (hh j hj).2) + have hden : 1+runningHeight ℓ X n ≤ (C+3)*i := by nlinarith + have hbound : (d : ℝ)*(t*(a*(1+runningHeight ℓ X n))) ≤ (B-1)*a*i := by + calc + _ = ((d : ℝ)*t*a)*(1+runningHeight ℓ X n) := by ring + _ ≤ ((d : ℝ)*t*a)*((C+3)*i) := mul_le_mul_of_nonneg_left hden (by positivity) + _ = ((d : ℝ)*t*(C+3))*(a*i) := by ring + _ ≤ (B-1)*(a*i) := mul_le_mul_of_nonneg_right hB (by positivity) + _ = _ := by ring + obtain ⟨u,hu⟩ := exists_large_signedCoordinate (X n) _ (hbound.trans_lt hn) + apply Set.mem_iUnion.mpr + refine ⟨u,Set.mem_iUnion.mpr ⟨n,?_,?_⟩⟩ + · exact ⟨⟨h0,fun j _ => hNN j⟩,fun j hj => ⟨(hh j hj).1, + (hh j hj).2.trans (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr hiN) (by linarith))⟩⟩ + · change t < tiltedCoordinate ℓ u b a (X n)/(a*(1+runningHeight ℓ X n)) + apply (lt_div_iff₀ (mul_pos ha (by linarith [runningHeight_nonneg ℓ X n]))).mpr + have hz := mul_nonneg (mul_nonneg hb ha.le) (hh n le_rfl).1 + dsimp only [tiltedCoordinate] + linarith + +lemma conditioned_polynomial_ratio_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (c C C0 a B η b t : ℝ) (ha : 0 < a) (hC : 0 ≤ C) (hB : 0 < B) + (hη : 0 < η) (hηsmall : η ≤ 1/10) (hb : 0 ≤ b) (ht : 0 ≤ t) + (hthreshold : (d : ℝ)*t*(C+3) ≤ B-1) + (m N : ℕ) (hm : 1 ≤ m) + (hC0 : ∀ i ∈ Finset.Ico m (N+1), C*(i-1)+C0+i ≤ (C+2)*i) + (hg : (4/5 : ℝ) ≤ (conditionedLaw ν ℓ).real (WordTemplate ℓ c C C0 a N)) + (hlow : η/(2*B) ≤ ∑ i ∈ Finset.Ico m (N+1), + (conditionedLaw ν ℓ).real {X | B*a*i < wordRadius (firstWord ℓ X) ∧ + wordHeightGain ℓ (firstWord ℓ X) ≤ i}) + (hupper : (∑ i ∈ Finset.Ico m (N+1), + (conditionedLaw ν ℓ).real {X | B*a*i < wordRadius (firstWord ℓ X) ∧ + wordHeightGain ℓ (firstWord ℓ X) ≤ i}) ≤ 2*η) : + (annealedLaw ν).real (NoDrop ℓ 0)*η/(4*B) ≤ + (annealedLaw ν).real (⋃ u : Direction d, RatioHit ℓ u b a ((C+2)*N) t) := by + let T := ⋃ u : Direction d, RatioHit ℓ u b a ((C+2)*N) t + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + have hlo := conditioned_rare_word_template_lower ν ℓ htrans c C C0 a B η hB hη hηsmall + m N hm hg hlow hupper + have hmono : μ.real {X | ∃ i ∈ Finset.Ico m (N+1), + B*a*i < wordRadius (regenerationWords ℓ X (i-1)) ∧ + wordHeightGain ℓ (regenerationWords ℓ X (i-1)) ≤ i ∧ + X ∈ WordTemplate ℓ c C C0 a (i-1)} ≤ μ.real T := by + apply ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae ?_) + filter_upwards [conditioned_regenerationSupport ν ℓ htrans, + (conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_nearest_neighbor ν)] with X hX hNN + rintro ⟨i,hi,hR,hL,hT⟩ + have him : m ≤ i := (Finset.mem_Ico.mp hi).1 + obtain ⟨n,hn,hh⟩ := large_regeneration_word_excursion ℓ X hX.1 hX.2 c C C0 a B ha.le + i (hm.trans him) hR hL hT (hC0 i hi) + exact large_excursion_ratio ℓ X hX.1 hNN b a C B t hb ha hC ht hthreshold i N n + (hm.trans him) (by have := (Finset.mem_Ico.mp hi).2; omega) hn hh + have hh := annealed_ge_noDrop_mul_conditioned ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) T + (MeasurableSet.iUnion fun u => measurableSet_ratioHit ℓ u b a ((C+2)*N) t) + have hmul := mul_le_mul_of_nonneg_left (hlo.trans hmono) + (measureReal_nonneg (μ := annealedLaw ν) (s := NoDrop ℓ 0)) + dsimp only [T,μ] at hh hmul + calc + _ = (annealedLaw ν).real (NoDrop ℓ 0)*(η/(4*B)) := by ring + _ ≤ _ := hmul.trans hh + +lemma firstWord_height_nonneg {d : ℕ} (ℓ : Vector d) (X : Path d) : + 0 ≤ wordHeightGain ℓ (firstWord ℓ X) := by + by_cases h : firstWord ℓ X = [] + · simp [h,wordHeightGain,dot,realPosition] + · have hm := (firstWord_eq_iff ℓ X _ h).mp rfl + exact (wordHeightGain_positive ℓ _ + ((firstTrueWord_characterization ℓ _ X hm.2.1).mp ⟨hm.1,hm.2.2⟩).1).le + +lemma geometric_beats_affine (q k L M r : ℝ) (hq : 0 ≤ q) (hq1 : q < 1) (hr : 0 < r) : + ∃ j : ℕ, k*(L+M*j)*q^j < r := by + have hp := tendsto_pow_atTop_nhds_zero_of_lt_one hq hq1 + have hnp := tendsto_pow_const_mul_const_pow_of_lt_one 1 hq hq1 + have ht : Tendsto (fun j : ℕ => k*(L+M*j)*q^j) atTop (𝓝 0) := by + convert (hp.const_mul (k*L)).add (hnp.const_mul (k*M)) using 1 + · ext j + simp only [pow_one] + ring + · ring_nf + exact (ht.eventually (Iio_mem_nhds hr)).exists + +lemma nonintegrable_radius_scale {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (R L : Ω → ℝ) + (hR : Measurable R) (hRn : ∀ x, 0 ≤ R x) (hinf : ¬ Integrable R μ) + (hL : Measurable L) (hLn : ∀ x, 0 ≤ L x) (hLint : Integrable L μ) + (B η Amin : ℝ) (hB : 1 ≤ B) (hη : 0 < η) (C0 : ℕ) : + ∃ (A : ℝ) (m N : ℕ), 1 ≤ A ∧ Amin ≤ A ∧ 1 ≤ m ∧ C0 ≤ m ∧ m ≤ N ∧ 2 ≤ N ∧ + truncatedMean μ R (A*N) < 2*η*A ∧ + η/(2*B) ≤ (∑ i ∈ Finset.Ico m (N+1), μ.real {x | B*A*i < R x ∧ L x ≤ (i:ℝ)}) ∧ + (∑ i ∈ Finset.Ico m (N+1), μ.real {x | B*A*i < R x ∧ L x ≤ (i:ℝ)}) < 2*η := by + have hBpos : 0 < B := lt_of_lt_of_le zero_lt_one hB + have htail := positive_tail_sums_eventually_small μ L hL hLn hLint + (show 0 < η/(4*B) by positivity) + obtain ⟨m,hmTail,hmBig⟩ := (htail.and (eventually_ge_atTop (max 1 C0))).exists + have hm : 1 ≤ m := (le_max_left _ _).trans hmBig + have hmC0 : C0 ≤ m := (le_max_right _ _).trans hmBig + have hbase := (truncatedMean_ratio_tendsto_zero μ R hR hRn (B*m) (by positivity)).eventually + (Iio_mem_nhds (show 0 < η/4 by positivity)) + have hNlarge := truncation_threshold_eventually_large μ R hR hRn η hη (max m 2) + obtain ⟨a0,ha0⟩ := exists_nat_ge Amin + obtain ⟨a,haBase,haN,haBound⟩ := (hbase.and (hNlarge.and (eventually_ge_atTop a0))).exists + let A : ℝ := (a : ℝ)+1 + have hA : 0 < A := by dsimp only [A]; positivity + have hA1 : 1 ≤ A := by dsimp only [A]; linarith only [Nat.cast_nonneg a (α := ℝ)] + have hAmin : Amin ≤ A := ha0.trans ((Nat.cast_le.mpr haBound).trans (by dsimp only [A]; linarith)) + obtain ⟨N,hN,hI,hmin⟩ := exists_minimal_truncation_scale μ R hR hRn hinf η A hη hA + have hNmax : max m 2 < N := haN N hI + have hmN : m ≤ N := le_of_lt ((le_max_left _ _).trans_lt hNmax) + have hN2 : 2 ≤ N := le_of_lt ((le_max_right _ _).trans_lt hNmax) + have hIhi := minimal_truncation_scale_upper μ R hR hRn η A hA.le hN2 hmin + have hIbase : truncatedMean μ R (B*A*m) < η*A/4 := by + have hb' := (div_lt_iff₀ hA).mp haBase + change truncatedMean μ R ((B*m)*A) < (η/4)*A at hb' + rwa [show B*A*(m:ℝ) = (B*m)*A by ring, show η*A/4 = (η/4)*A by ring] + obtain ⟨hintenlo,hintenhi⟩ := restricted_large_word_intensity μ R L hR hRn hA hB hm + (by omega : m ≤ N+1) hI hIhi hIbase (hmTail (N+1)) + exact ⟨A,m,N,hA1,hAmin,hm,hmC0,hmN,hN2,hIhi,hintenlo,hintenhi⟩ + +lemma radius_integrable_of_template_constants {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (ℓ : Vector d) + (htrans : DirectionallyTransient ν ℓ) (hℓ : ∀ i, |ℓ i| ≤ 1) + (e : Direction d) (he : 0 < dot (realPosition (step e)) ℓ) + (κ : ℝ≥0) (hκ : 0 < κ) + (hκenv : ∀ᵐ ω ∂environmentLaw ν, ∀ x e, κ ≤ (ω x).1 e) + (c C : ℝ) (_hc : 0 < c) (hC : 0 < C) (C0 : ℕ) + (hheight : (19/20 : ℝ) < (conditionedLaw ν ℓ).real {X | ∀ k : ℕ, + c*k-C0 ≤ ∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j) ∧ + (∑ j ∈ Finset.range k, wordHeightGain ℓ (regenerationWords ℓ X j)) ≤ C*k+C0}) + (C1 : ℕ) (hC1 : 1 ≤ C1) (hC1large : C+2 < c*C1) + (b : ℝ) (hb : 0 < b) (hbc : 1 ≤ b*c) (M : ℕ) + (hM : 0 ≤ (M : ℝ)*dot (realPosition (step e)) ℓ-C0) + (hconst : 0 < b*((M : ℝ)*dot (realPosition (step e)) ℓ)-b*C0-1) + (D : ℝ) (hD : (M : ℝ)+1 ≤ D) (hDc : 1 ≤ D*c) + (η : ℝ) (hη : 0 < η) (hηsmall : η ≤ 1/10) (hsmall : 4*C1*η < 1/10) : + Integrable (fun X => wordRadius (firstWord ℓ X)) (conditionedLaw ν ℓ) := by + by_contra hinf + let μ := conditionedLaw ν ℓ + have hp0 := noDrop_positive_of_directionallyTransient ν ℓ htrans + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ (ne_of_gt hp0) + let R := fun X : Path d => wordRadius (firstWord ℓ X) + let L := fun X : Path d => wordHeightGain ℓ (firstWord ℓ X) + have hR : Measurable R := measurable_wordRadius.comp (measurable_firstWord ℓ) + have hRn : ∀ X, 0 ≤ R X := fun X => wordRadius_nonneg _ + have hL : Measurable L := (measurable_of_countable (wordHeightGain ℓ)).comp (measurable_firstWord ℓ) + have hLn : ∀ X, 0 ≤ L X := firstWord_height_nonneg ℓ + have hLint : Integrable L μ := (conditioned_wordHeightGain_moments ν ℓ hℓ htrans).1 + let p : ℝ := (annealedLaw ν).real (NoDrop ℓ 0) + have hp : 0 < p := ENNReal.toReal_pos (ne_of_gt hp0) (measure_ne_top _ _) + have hp1 : p ≤ 1 := measureReal_le_one + have hκ1 : (κ : ℝ) ≤ 1 := by + obtain ⟨ω,hω⟩ := hκenv.exists + exact_mod_cast (hω 0 e).trans (row_entry_le_one _ e) + have hκ0 : (0 : ℝ) < κ := hκ + let ε : ℝ := (κ : ℝ)^M*p*(4/5) + have hε : 0 < ε := by dsimp only [ε]; positivity + have hε1 : ε ≤ 1 := by + have hpow : (κ : ℝ)^M ≤ 1 := pow_le_one₀ κ.coe_nonneg hκ1 + have hkp : (κ : ℝ)^M*p ≤ 1 := calc + (κ : ℝ)^M*p ≤ 1*p := mul_le_mul_of_nonneg_right hpow hp.le + _ ≤ 1 := by simpa only [one_mul] using hp1 + dsimp only [ε] + nlinarith only [hkp, mul_nonneg (pow_nonneg κ.coe_nonneg M) hp.le] + let K := 2*b+1+D + have hD0 : 0 ≤ D := by linarith [Nat.cast_nonneg M (α := ℝ)] + have hK : 0 < K := by dsimp only [K]; positivity + obtain ⟨j,hj⟩ := geometric_beats_affine (1-ε) (2*d : ℕ) + (2+(d : ℝ)*(C+3)) ((d : ℝ)*(C+3)*K) (p*η/4) + (by linarith) (by linarith) (by positivity) + let t : ℝ := 1+j*K + have ht : 0 < t := by dsimp only [t]; positivity + let B : ℝ := 2+(d : ℝ)*(C+3)*t + have hB1 : 1 ≤ B := by + have hn : 0 ≤ (d : ℝ)*(C+3)*t := by positivity + dsimp only [B]; linarith only [hn] + have hB : 0 < B := lt_of_lt_of_le zero_lt_one hB1 + have hthreshold : (d : ℝ)*t*(C+3) ≤ B-1 := by dsimp only [B]; nlinarith only [] + have hjB : (2*d : ℕ)*B*(1-ε)^j < p*η/4 := by + convert hj using 1; dsimp only [B,t]; ring + let Q := b*((M : ℝ)*dot (realPosition (step e)) ℓ)-b*C0-1 + have hQ : 0 < Q := hconst + obtain ⟨A,m,N,hA1,hAmin,hm,hmC0,hmN,hN2,hIhi,hintenlo,hintenhi⟩ := + nonintegrable_radius_scale μ R L hR hRn hinf hL hLn hLint B η + (max ((M : ℝ)/Q) (1/(b*dot (realPosition (step e)) ℓ))) hB1 hη C0 + have hA : 0 < A := lt_of_lt_of_le zero_lt_one hA1 + have hAM : (M : ℝ) ≤ A*Q := (div_le_iff₀ hQ).mp ((le_max_left _ _).trans hAmin) + have hAdelta : 1 ≤ b*A*dot (realPosition (step e)) ℓ := by + have hh := (div_le_iff₀ (mul_pos hb he)).mp ((le_max_right _ _).trans hAmin) + nlinarith only [hh] + have htemplate := controlled_template_probability ν ℓ htrans c C C0 η A hA C1 N hC1 + hheight hsmall hIhi + have htemplateN : (4/5 : ℝ) ≤ μ.real (WordTemplate ℓ c C C0 A N) := + htemplate.le.trans (measureReal_mono (wordTemplate_antitone ℓ c C C0 A + (show N ≤ C1*N by simpa only [one_mul] using Nat.mul_le_mul_right N hC1))) + have hlo := conditioned_polynomial_ratio_lower ν ℓ htrans c C C0 A B η b t hA hC.le hB + hη hηsmall hb.le ht.le hthreshold m N hm (by + intro i hi + have hmi := (Finset.mem_Ico.mp hi).1 + have hci : (C0 : ℝ) ≤ i := Nat.cast_le.mpr (hmC0.trans hmi) + linarith only [hci, hC]) htemplateN hintenlo hintenhi.le + let F := ForwardTemplate ℓ e c C C0 A (C1*N) M + have hF : MeasurableSet F := measurableSet_forwardTemplate ℓ e c C C0 A (C1*N) M + have hprob : ε ≤ (annealedLaw ν).real F := + forwardTemplate_probability_lower ν ℓ htrans e he c C C0 A (C1*N) M κ hκenv htemplate.le + have hgeom : ∀ u Z, Z ∈ F → ∀ k, (0 ≤ tiltedCoordinate ℓ u b A (Z k) ∧ + signedCoordinate u (Z k) ≤ A*D*(1+dot (realPosition (Z k)) ℓ)) ∨ + (C+2)*N < dot (realPosition (Z k)) ℓ := by + intro u Z hZ k + apply (forwardTemplate_control ℓ u e c C C0 A b D ((C+2)*N) (C1*N) M hA1 hb.le he.le + hbc hM hAM ?_ hD hDc ?_ hZ k).2 + · have hstep := signedCoordinate_abs_le_norm u (step e) + rw [latticeVector_step_norm] at hstep + have hlow := neg_le_of_abs_le hstep + dsimp only [tiltedCoordinate] + have hh := hAdelta + change 1 ≤ b*A*dot (realPosition (step e)) ℓ at hh + linarith only [hlow, hh] + · have hNpos : (0 : ℝ) < N := Nat.cast_pos.mpr (by omega) + have hh := mul_lt_mul_of_pos_right hC1large hNpos + push_cast + nlinarith only [hh, hM] + have hup := ratio_hit_union_bound ν ℓ hℓ b A D ((C+2)*N) ε hb.le hA1 hD0 hε.le hε1 + F hF hprob hgeom j + change p*η/(4*B) ≤ (annealedLaw ν).real (⋃ u : Direction d, + RatioHit ℓ u b A ((C+2)*N) (1+j*(2*b+1+D))) at hlo + have hbnd := hlo.trans hup + have hprod := (div_le_iff₀ (show 0 < 4*B by positivity)).mp hbnd + nlinarith only [hprod, hjB] + +lemma unit_direction_coordinate_bound {d : ℕ} (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) : + ∀ i, |ℓ i| ≤ 1 := by + intro i + have hh : ℓ i*ℓ i ≤ ∑ j : Fin d, ℓ j*ℓ j := + Finset.single_le_sum (fun j _ => mul_self_nonneg (ℓ j)) (Finset.mem_univ i) + change ℓ i*ℓ i ≤ dot ℓ ℓ at hh + rw [hℓ] at hh + nlinarith [sq_abs (ℓ i),abs_nonneg (ℓ i)] + +lemma conditioned_wordRadius_integrable {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : + Integrable (fun X => wordRadius (firstWord ℓ X)) (conditionedLaw ν ℓ) := by + have hcoord := unit_direction_coordinate_bound ℓ hℓ + obtain ⟨e,he⟩ := exists_positive_step ℓ hℓ + obtain ⟨κ,hκ,hκenv⟩ := environment_uniform_elliptic ν hue + obtain ⟨c,C,hc,hC,C0,hheight⟩ := conditioned_height_template ν ℓ hcoord htrans (1/20) (by norm_num) + norm_num only at hheight + obtain ⟨C1,hC1'⟩ := exists_nat_gt (max 1 ((C+2)/c)) + have hC1r : (1 : ℝ) < C1 := (le_max_left _ _).trans_lt hC1' + have hC1 : 1 ≤ C1 := by exact_mod_cast hC1r.le + have hC1large : C+2 < c*C1 := by + have hh := (div_lt_iff₀ hc).mp ((le_max_right _ _).trans_lt hC1') + linarith + let b : ℝ := 2/c + have hb : 0 < b := by dsimp only [b]; positivity + have hbc : b*c = 2 := by dsimp only [b]; field_simp + obtain ⟨M,hM'⟩ := exists_nat_gt (((C0 : ℝ)+2/b)/dot (realPosition (step e)) ℓ) + have hMdelta : (C0 : ℝ)+2/b < (M : ℝ)*dot (realPosition (step e)) ℓ := + (div_lt_iff₀ he).mp hM' + have hM : 0 ≤ (M : ℝ)*dot (realPosition (step e)) ℓ-C0 := by + linarith [div_pos (show (0 : ℝ) < 2 by norm_num) hb] + have hconst : 0 < b*((M : ℝ)*dot (realPosition (step e)) ℓ)-b*C0-1 := by + have hh := mul_lt_mul_of_pos_left hMdelta hb + have heq : b*(2/b) = 2 := by field_simp + nlinarith + let D : ℝ := (M : ℝ)+1+1/c + have hD : (M : ℝ)+1 ≤ D := by dsimp only [D]; linarith only [one_div_pos.mpr hc] + have hDc : 1 ≤ D*c := by + have heq : D*c = ((M : ℝ)+1)*c+1 := by dsimp only [D]; field_simp + rw [heq] + linarith only [mul_nonneg (show (0:ℝ) ≤ (M:ℝ)+1 by positivity) hc.le] + let η : ℝ := 1/(100*(C1 : ℝ)) + have hη : 0 < η := by dsimp only [η]; positivity + have hηsmall : η ≤ 1/10 := by + dsimp only [η] + apply (div_le_iff₀ (show 0 < 100*(C1 : ℝ) by positivity)).mpr + nlinarith + have hsmall : 4*C1*η < 1/10 := by + have heq : (C1 : ℝ)*η = 1/100 := by dsimp only [η]; field_simp + nlinarith + exact radius_integrable_of_template_constants ν ℓ htrans hcoord e he κ hκ hκenv + c C hc hC C0 hheight C1 hC1 hC1large b hb (by linarith) M hM hconst D hD hDc + η hη hηsmall hsmall + +lemma increment_sublinear_of_average (f : ℕ → ℝ) (m : ℝ) + (h : Tendsto (fun n : ℕ => (∑ i ∈ Finset.range n, f i) / n) atTop (𝓝 m)) : + Tendsto (fun n : ℕ => f n / n) atTop (𝓝 0) := by + have hr : Tendsto (fun n : ℕ => ((n : ℝ)+1)/n) atTop (𝓝 1) := by + have hh := (tendsto_natCast_div_add_atTop (𝕜 := ℝ) 1).inv₀ (by norm_num : (1 : ℝ) ≠ 0) + simpa only [inv_one, inv_div] using hh + have hh := ((h.comp (tendsto_add_atTop_nat 1)).mul hr).sub h + simp only [mul_one, sub_self] at hh + apply hh.congr' + filter_upwards [eventually_gt_atTop (0 : ℕ)] with n hn + have hn' : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (ne_of_gt hn) + have hnp : (n : ℝ)+1 ≠ 0 := by positivity + simp only [Function.comp_apply, Finset.sum_range_succ, Nat.cast_add, Nat.cast_one] + field_simp + ring + +noncomputable def wordCoordinate {d : ℕ} (e : Direction d) (w : List (Direction d)) : ℝ := + signedCoordinate e (wordPath 0 w w.length) + +lemma wordCoordinate_abs_le_radius {d : ℕ} (e : Direction d) (w : List (Direction d)) : + |wordCoordinate e w| ≤ wordRadius w := + (signedCoordinate_abs_le_norm _ _).trans (wordRadius_bound _ (by rfl)) + +lemma conditioned_wordCoordinate_integrable {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (e : Direction d) : + Integrable (fun X => wordCoordinate e (firstWord ℓ X)) (conditionedLaw ν ℓ) := by + apply (conditioned_wordRadius_integrable ν hue ℓ hℓ htrans).mono' + (((measurable_of_countable (wordCoordinate e)).comp (measurable_firstWord ℓ)).aestronglyMeasurable) + exact Filter.Eventually.of_forall fun X => by + simpa only [Real.norm_eq_abs, Function.comp_apply] using wordCoordinate_abs_le_radius e (firstWord ℓ X) + +lemma conditioned_coordinate_positive_mean {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : ∃ e : Direction d, + 0 < ∫ X, wordCoordinate e (firstWord ℓ X) ∂conditionedLaw ν ℓ := by + let μ := conditionedLaw ν ℓ + have hint (i : Fin d) : Integrable (fun X => + wordCoordinate (i,true) (firstWord ℓ X) * ℓ i) μ := + (conditioned_wordCoordinate_integrable ν hue ℓ hℓ htrans (i,true)).mul_const _ + have hid : (∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂μ) = + ∑ i : Fin d, (∫ X, wordCoordinate (i,true) (firstWord ℓ X) ∂μ) * ℓ i := by + change (∫ X, ∑ i : Fin d, wordCoordinate (i,true) (firstWord ℓ X) * ℓ i ∂μ) = _ + rw [integral_finsetSum _ (fun i _ => hint i)] + apply Finset.sum_congr rfl + intro i _ + exact integral_mul_const _ _ + have hpos := (conditioned_wordHeightGain_moments ν ℓ + (unit_direction_coordinate_bound ℓ hℓ) htrans).2.1 + change 0 < ∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂μ at hpos + rw [hid] at hpos + have hex : ∃ i : Fin d, (∫ X, wordCoordinate (i,true) (firstWord ℓ X) ∂μ) ≠ 0 := by + by_contra! hn + simp only [hn, zero_mul, Finset.sum_const_zero, lt_self_iff_false] at hpos + obtain ⟨i,hi⟩ := hex + rcases lt_or_gt_of_ne hi with hi | hi + · refine ⟨(i,false), ?_⟩ + have he : (fun X => wordCoordinate (i,false) (firstWord ℓ X)) = + fun X => -wordCoordinate (i,true) (firstWord ℓ X) := by + ext X; simp [wordCoordinate, signedCoordinate] + rw [he, integral_neg] + exact neg_pos.mpr hi + · exact ⟨(i,true), hi⟩ + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Geometry/WordHeightGain.lean b/lean/OAI/Probability/Ballisticity/Geometry/WordHeightGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..51b8bdee580f0b717acbd6ae3ba2404a2d52f469 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Geometry/WordHeightGain.lean @@ -0,0 +1,435 @@ +import Mathlib +import OAI.Probability.Ballisticity.Renewal.RegenerationWords + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma renewal_occupation_lower {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + (T : ℕ → α → ℕ) (hT : ∀ i, Measurable (T i)) + (hbig : ∀ᵐ x ∂μ, ∀ i, i ≤ T i x) {p : ℝ} + (hlow : ∀ r, 0 < r → p ≤ μ.real {x | ∃ i, T i x = r}) (H : ℕ) : + (H : ℝ) * p ≤ ∑ i ∈ Finset.range (H+1), μ.real {x | T i x ≤ H} := by + classical + have hlow' (r : ℕ) (hr : r ∈ Finset.Icc 1 H) : + p ≤ ∑ i ∈ Finset.range (H+1), μ.real {x | T i x = r} := by + have hsub : {x | ∃ i, T i x = r} ≤ᵐ[μ] + ⋃ i ∈ Finset.range (H+1), {x | T i x = r} := by + filter_upwards [hbig] with x hx hi + obtain ⟨i, hi⟩ := hi + refine Set.mem_iUnion.mpr ⟨i, Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr ?_, hi⟩⟩ + have hh := hx i + have hrH := (Finset.mem_Icc.mp hr).2 + omega + exact (hlow r (by have := (Finset.mem_Icc.mp hr).1; omega)).trans + ((ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hsub)).trans + (measureReal_biUnion_finset_le _ _)) + calc + (H : ℝ) * p = ∑ r ∈ Finset.Icc 1 H, p := by simp + _ ≤ ∑ r ∈ Finset.Icc 1 H, ∑ i ∈ Finset.range (H+1), μ.real {x | T i x = r} := + Finset.sum_le_sum hlow' + _ = ∑ i ∈ Finset.range (H+1), ∑ r ∈ Finset.Icc 1 H, μ.real {x | T i x = r} := + Finset.sum_comm + _ ≤ _ := by + apply Finset.sum_le_sum + intro i _ + have he := sum_measureReal_preimage_singleton (μ := μ) (Finset.Icc 1 H) + (fun r _ => (hT i) (measurableSet_singleton r)) + change (∑ r ∈ Finset.Icc 1 H, μ.real (T i ⁻¹' {r})) ≤ _ + rw [he] + exact measureReal_mono (fun x hx => show T i x ≤ H from (Finset.mem_Icc.mp hx).2) + +lemma nat_integrable_of_truncated_mean_bound {α : Type*} [MeasurableSpace α] + (μ : Measure α) [IsProbabilityMeasure μ] (S : α → ℕ) (hS : Measurable S) {B : ℝ} + (hB : ∀ K : ℕ, (∫ x, ((min (S x) K : ℕ) : ℝ) ∂μ) ≤ B) : + Integrable (fun x => (S x : ℝ)) μ ∧ (∫ x, (S x : ℝ) ∂μ) ≤ B := by + have hKint (K : ℕ) : Integrable (fun x => ((min (S x) K : ℕ) : ℝ)) μ := + integrable_of_nonneg_bound μ ((measurable_of_countable (f := fun n : ℕ => (n : ℝ))).comp (hS.min measurable_const)) (B := K) + fun x => ⟨Nat.cast_nonneg _, by exact_mod_cast min_le_right (S x) K⟩ + have hB0 : 0 ≤ B := by simpa only [Nat.min_zero, Nat.cast_zero, integral_zero] using hB 0 + have hbound : (∫⁻ x, (S x : ℝ≥0∞) ∂μ) ≤ ENNReal.ofReal B := by + have he (x : α) : (S x : ℝ≥0∞) = ⨆ K : ℕ, ((min (S x) K : ℕ) : ℝ≥0∞) := by + apply le_antisymm + · exact le_iSup_of_le (S x) (by simp) + · exact iSup_le fun K => by exact_mod_cast min_le_left (S x) K + simp_rw [he] + rw [lintegral_iSup (f := fun K x => ((min (S x) K : ℕ) : ℝ≥0∞)) (fun K => (measurable_of_countable (f := fun n : ℕ => + ((min n K : ℕ) : ℝ≥0∞))).comp hS) (fun i j hij x => by + dsimp only + exact_mod_cast min_le_min_left (S x) hij)] + apply iSup_le + intro K + have hh := ofReal_integral_eq_lintegral_ofReal (hKint K) + (Filter.Eventually.of_forall fun x => Nat.cast_nonneg (min (S x) K)) + simp only [ENNReal.ofReal_natCast] at hh + rw [← hh] + exact ENNReal.ofReal_le_ofReal (hB K) + have hint : Integrable (fun x => (S x : ℝ)) μ := by + refine ⟨((measurable_of_countable (f := fun n : ℕ => (n : ℝ))).comp hS).aestronglyMeasurable, ?_⟩ + rw [hasFiniteIntegral_iff_ofReal (Filter.Eventually.of_forall fun x => Nat.cast_nonneg (S x))] + simp only [ENNReal.ofReal_natCast] + exact hbound.trans_lt ENNReal.ofReal_lt_top + refine ⟨hint, ?_⟩ + have he := ofReal_integral_eq_lintegral_ofReal hint + (Filter.Eventually.of_forall fun x => Nat.cast_nonneg (S x)) + simp only [ENNReal.ofReal_natCast] at he + rw [← he] at hbound + exact (ENNReal.ofReal_le_ofReal_iff hB0).mp hbound + +lemma renewal_mean_bound {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + (S : ℕ → α → ℕ) (hS : ∀ i, Measurable (S i)) (hind : iIndepFun S μ) + (hident : ∀ i, IdentDistrib (S i) (S 0) μ μ) + (hpos : ∀ᵐ x ∂μ, ∀ i, 0 < S i x) {p : ℝ} (hp : 0 < p) + (hlow : ∀ r, 0 < r → p ≤ μ.real {x | ∃ i, (∑ j ∈ Finset.range i, S j x) = r}) : + Integrable (fun x => (S 0 x : ℝ)) μ ∧ (∫ x, (S 0 x : ℝ) ∂μ) ≤ 1 / p := by + apply nat_integrable_of_truncated_mean_bound μ (S 0) (hS 0) + intro K + let E := ∫ x, ((min (S 0 x) K : ℕ) : ℝ) ∂μ + have hE : 0 ≤ E := integral_nonneg fun x => Nat.cast_nonneg _ + have hbig : ∀ᵐ x ∂μ, ∀ i, i ≤ ∑ j ∈ Finset.range i, S j x := by + filter_upwards [hpos] with x hx i + calc + i = ∑ _j ∈ Finset.range i, 1 := by simp + _ ≤ _ := Finset.sum_le_sum fun j _ => hx j + have hbound (H : ℕ) : (H : ℝ) * p * E ≤ (H : ℝ) + K := + (mul_le_mul_of_nonneg_right (renewal_occupation_lower μ _ + (fun i => Finset.measurable_fun_sum _ (fun j _ => hS j)) hbig hlow H) hE).trans + (renewal_wald_bound μ S hS hind hident H K) + have hpE : p * E ≤ 1 := by + by_contra h + have hpos' : 0 < p * E - 1 := by linarith + obtain ⟨H, hH⟩ := exists_nat_gt ((K : ℝ) / (p * E - 1)) + have hH' := (div_lt_iff₀ hpos').mp hH + have hh := hbound H + nlinarith + exact (le_div_iff₀ hp).mpr (by simpa only [mul_comm] using hpE) + +lemma trueRecord_eq_regenerationTime {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + {j : ℕ} (hj : TrueRecord ℓ X j) : ∃ n, regenerationTimes ℓ X n = j := by + have hmono := regenerationTimes_strictMono ℓ X hX + have hbig (n : ℕ) : n ≤ regenerationTimes ℓ X n := by + induction n with + | zero => exact Nat.zero_le _ + | succ n ih => exact Nat.succ_le_of_lt (ih.trans_lt (hmono (Nat.lt_succ_self n))) + have hex : ∃ n, j < regenerationTimes ℓ X n := ⟨j+1, (Nat.lt_succ_self j).trans_le (hbig _)⟩ + let n := Nat.find hex + have hn : j < regenerationTimes ℓ X n := Nat.find_spec hex + have hn0 : 0 < n := by + by_contra h + have he : n = 0 := by omega + simp only [he, regenerationTimes_zero, not_lt_zero] at hn + have hn' : n - 1 + 1 = n := by omega + have hbefore : regenerationTimes ℓ X (n-1) ≤ j := + le_of_not_gt (Nat.find_min hex (show n-1 < Nat.find hex by change n-1 < n; omega)) + by_cases he : regenerationTimes ℓ X (n-1) = j + · exact ⟨n-1, he⟩ + · exact False.elim (regenerationTimes_no_true_between ℓ X h0 hX (n-1) j + (lt_of_le_of_ne hbefore he) (by simpa only [hn'] using hn) hj) + +lemma conditioned_wordRecordCount_integrable {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + Integrable (fun X => (wordRecordCount ℓ (firstWord ℓ X) : ℝ)) (conditionedLaw ν ℓ) ∧ + (∫ X, (wordRecordCount ℓ (firstWord ℓ X) : ℝ) ∂conditionedLaw ν ℓ) ≤ + 1 / (annealedLaw ν).real (NoDrop ℓ 0) := by + have hp := noDrop_positive_of_directionallyTransient ν ℓ htrans + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ (ne_of_gt hp) + let S : ℕ → Path d → ℕ := fun n X => wordRecordCount ℓ (regenerationWords ℓ X n) + have hS (n : ℕ) : Measurable (S n) := + (measurable_of_countable (wordRecordCount ℓ)).comp (measurable_regenerationWord ℓ n) + have hind : iIndepFun S (conditionedLaw ν ℓ) := + (regenerationWords_independent ν ℓ htrans).comp (fun _ => wordRecordCount ℓ) + (fun _ => measurable_of_countable _) + have hident (n : ℕ) : IdentDistrib (S n) (S 0) (conditionedLaw ν ℓ) (conditionedLaw ν ℓ) := + (regenerationWords_identDistrib ν ℓ htrans n).comp (measurable_of_countable (wordRecordCount ℓ)) + have hall := conditioned_all_firstWords ν ℓ htrans + have hpos : ∀ᵐ X ∂conditionedLaw ν ℓ, ∀ n, 0 < S n X := by + filter_upwards [hall] with X hX n + exact wordRecordCount_positive ℓ _ + (((firstTrueWord_characterization ℓ _ _ (hX n).2.1).mp ⟨(hX n).1, (hX n).2.2⟩).1) + have hp' : 0 < (annealedLaw ν).real (NoDrop ℓ 0) := + ENNReal.toReal_pos (ne_of_gt hp) (measure_ne_top _ _) + have hlow (r : ℕ) (hr : 0 < r) : (annealedLaw ν).real (NoDrop ℓ 0) ≤ + (conditionedLaw ν ℓ).real {X | ∃ n, (∑ j ∈ Finset.range n, S j X) = r} := by + apply (ENNReal.toReal_mono (measure_ne_top _ _) (conditioned_true_at_index_lower ν ℓ htrans hr)).trans + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [hall, (conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_initial ν)] + with X hX h0 hR + obtain ⟨j, _, hj, hcount⟩ := hR + obtain ⟨n, hn⟩ := trueRecord_eq_regenerationTime ℓ X h0 hX hj + exact ⟨n, (recordCount_regenerationTimes ℓ X h0 hX n).symm.trans (hn ▸ hcount)⟩ + exact renewal_mean_bound (conditionedLaw ν ℓ) S hS hind hident hpos hp' hlow + +lemma height_le_recordCount {d : ℕ} (ℓ : Vector d) (X : Path d) + (hstep : ∀ n, dot (realPosition (X (n+1))) ℓ ≤ dot (realPosition (X n)) ℓ + 1) + (n : ℕ) : dot (realPosition (X n)) ℓ - dot (realPosition (X 0)) ℓ ≤ + (recordCount ℓ X n : ℝ) := by + classical + induction n using Nat.strong_induction_on with + | h n ih => + cases n with + | zero => simp + | succ n => + by_cases hr : StrictRecord ℓ X (n+1) + · rw [recordCount_succ, ite_eq_left hr, Nat.cast_add, Nat.cast_one] + have := ih n (by omega) + linarith [hstep n] + · obtain ⟨j, hj, hjh⟩ : ∃ j < n+1, + dot (realPosition (X (n+1))) ℓ ≤ dot (realPosition (X j)) ℓ := by + simpa only [StrictRecord, not_forall, exists_prop, not_lt] using hr + have hle : (recordCount ℓ X j : ℝ) ≤ (recordCount ℓ X (n+1) : ℝ) := + Nat.cast_le.mpr (recordCount_mono ℓ X hj.le) + linarith [ih j hj] + +lemma wordPath_step_or_stay {d : ℕ} (x : Lattice d) (w : List (Direction d)) (n : ℕ) : + wordPath x w (n+1) = wordPath x w n ∨ + ∃ e : Direction d, wordPath x w (n+1) = wordPath x w n + step e := by + induction w generalizing x n with + | nil => exact Or.inl rfl + | cons e w ih => + cases n with + | zero => exact Or.inr ⟨e, by simp only [wordPath, wordPath_zero]⟩ + | succ n => exact ih (x + step e) n + +lemma dot_step {d : ℕ} (ℓ : Vector d) (e : Direction d) : + dot (realPosition (step e)) ℓ = if e.2 then ℓ e.1 else -ℓ e.1 := by + classical + simp only [dot, realPosition, step, Int.cast_ite, Int.cast_one, Int.cast_neg, + Int.cast_zero, ite_mul, zero_mul] + rw [Finset.sum_ite_eq'] + simp only [Finset.mem_univ, ite_true] + split <;> simp_all + +noncomputable def wordHeightGain {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) : ℝ := + dot (realPosition (wordPath 0 w w.length)) ℓ + +lemma wordHeightGain_le_recordCount {d : ℕ} (ℓ : Vector d) + (hℓ : ∀ i, |ℓ i| ≤ 1) (w : List (Direction d)) : + wordHeightGain ℓ w ≤ (wordRecordCount ℓ w : ℝ) := by + have hs (n : ℕ) : dot (realPosition (wordPath 0 w (n+1))) ℓ ≤ + dot (realPosition (wordPath 0 w n)) ℓ + 1 := by + rcases wordPath_step_or_stay 0 w n with he | ⟨e, he⟩ + · rw [he]; linarith + · rw [he, dot_realPosition_add, dot_step] + have hl := (abs_le.mp (hℓ e.1)) + split <;> linarith + simpa only [wordHeightGain, wordRecordCount, wordPath_zero, dot, realPosition, + Pi.zero_apply, Int.cast_zero, zero_mul, Finset.sum_const_zero, sub_zero] using + height_le_recordCount ℓ (wordPath 0 w) hs w.length + +lemma wordHeightGain_positive {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) + (hw : AdmissibleTrueWord ℓ w) : 0 < wordHeightGain ℓ w := by + simpa only [wordPath_zero, dot, realPosition, Pi.zero_apply, Int.cast_zero, + zero_mul, Finset.sum_const_zero, wordHeightGain] using (hw.2.1 0 hw.1).2 + +lemma conditioned_wordHeightGain_moments {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hℓ : ∀ i, |ℓ i| ≤ 1) (htrans : DirectionallyTransient ν ℓ) : + Integrable (fun X => wordHeightGain ℓ (firstWord ℓ X)) (conditionedLaw ν ℓ) ∧ + 0 < (∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂conditionedLaw ν ℓ) ∧ + (∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂conditionedLaw ν ℓ) ≤ + 1 / (annealedLaw ν).real (NoDrop ℓ 0) := by + have hp := noDrop_positive_of_directionallyTransient ν ℓ htrans + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ (ne_of_gt hp) + have hm : Measurable (fun X => wordHeightGain ℓ (firstWord ℓ X)) := + (measurable_of_countable (wordHeightGain ℓ)).comp (measurable_firstWord ℓ) + have hpos : ∀ᵐ X ∂conditionedLaw ν ℓ, 0 < wordHeightGain ℓ (firstWord ℓ X) := by + filter_upwards [conditioned_all_firstWords ν ℓ htrans] with X hX + have he := hX 0 + simp only [Function.iterate_zero, id_eq, regenerationWords] at he + exact wordHeightGain_positive ℓ _ + ((firstTrueWord_characterization ℓ _ X he.2.1).mp ⟨he.1, he.2.2⟩).1 + obtain ⟨hcount, hbound⟩ := conditioned_wordRecordCount_integrable ν ℓ htrans + have hint : Integrable (fun X => wordHeightGain ℓ (firstWord ℓ X)) (conditionedLaw ν ℓ) := by + apply hcount.mono' hm.aestronglyMeasurable + filter_upwards [hpos] with X hX + rw [Real.norm_eq_abs, abs_of_pos hX] + exact wordHeightGain_le_recordCount ℓ hℓ _ + refine ⟨hint, ?_, (integral_mono_ae hint hcount + (Filter.Eventually.of_forall fun X => wordHeightGain_le_recordCount ℓ hℓ _)).trans hbound⟩ + rw [integral_pos_iff_support_of_nonneg_ae (hpos.mono fun _ h => h.le) hint] + have he : Function.support (fun X => wordHeightGain ℓ (firstWord ℓ X)) =ᵐ[conditionedLaw ν ℓ] + Set.univ := by + filter_upwards [hpos] with X hX + apply propext + change (wordHeightGain ℓ (firstWord ℓ X) ≠ 0) ↔ True + exact iff_true_intro (ne_of_gt hX) + rw [measure_congr he, measure_univ] + exact zero_lt_one + +lemma nonnegative_interval_count (a : ℝ) (ha : 0 ≤ a) (K : ℕ) + (u b : ℕ → ℝ) (hu : ∀ i, 0 ≤ u i) (hb : ∀ i, 0 ≤ b i ∧ b i ≤ 1) + (hw : ∀ i, b i ≠ 0 → ∃ k, 0 < k ∧ k ≤ K ∧ + a * (k : ℝ) ≤ ∑ j ∈ Finset.range k, u (i+j)) + (M : ℕ) : a * (∑ i ∈ Finset.range M, b i) ≤ + ∑ i ∈ Finset.range (M+K), u i := by + induction M using Nat.strong_induction_on generalizing u b with + | h M ih => + by_cases hM : M = 0 + · subst M + simp only [Finset.range_zero, Finset.sum_empty, mul_zero, Nat.zero_add] + exact Finset.sum_nonneg fun i _ => hu i + by_cases hb0 : b 0 = 0 + · have hrec := ih (M-1) (by omega) (fun i => u (1+i)) (fun i => b (1+i)) + (fun i => hu _) (fun i => hb _) (by + intro i hi + obtain ⟨k,hk,hkK,hku⟩ := hw (1+i) hi + exact ⟨k,hk,hkK,by simpa only [Nat.add_assoc] using hku⟩) + have hfirst : (∑ i ∈ Finset.range M, b i) = ∑ i ∈ Finset.range (M-1), b (1+i) := by + conv_lhs => rw [show M = 1+(M-1) by omega, Finset.sum_range_add, Finset.sum_range_one, + hb0, zero_add] + rw [hfirst] + calc + _ ≤ ∑ i ∈ Finset.range (M-1+K), u (1+i) := hrec + _ ≤ u 0 + ∑ i ∈ Finset.range (M-1+K), u (1+i) := le_add_of_nonneg_left (hu 0) + _ = _ := by + conv_rhs => rw [show M+K = 1+(M-1+K) by omega, Finset.sum_range_add, + Finset.sum_range_one] + · obtain ⟨k,hk,hkK,hkw⟩ := hw 0 hb0 + simp only [Nat.zero_add] at hkw + by_cases hkM : k ≤ M + · have hrec := ih (M-k) (by omega) (fun i => u (k+i)) (fun i => b (k+i)) + (fun i => hu _) (fun i => hb _) (by + intro i hi + obtain ⟨l,hl,hlK,hlu⟩ := hw (k+i) hi + exact ⟨l,hl,hlK,by simpa only [Nat.add_assoc] using hlu⟩) + have hbfirst : (∑ i ∈ Finset.range k, b i) ≤ (k : ℝ) := by + calc + _ ≤ ∑ i ∈ Finset.range k, (1 : ℝ) := Finset.sum_le_sum fun i _ => (hb i).2 + _ = _ := by simp + calc + _ = a * (∑ i ∈ Finset.range k, b i) + + a * (∑ i ∈ Finset.range (M-k), b (k+i)) := by + conv_lhs => arg 2; rw [show M = k+(M-k) by omega, Finset.sum_range_add] + rw [mul_add] + _ ≤ (∑ i ∈ Finset.range k, u i) + + (∑ i ∈ Finset.range (M-k+K), u (k+i)) := + add_le_add ((mul_le_mul_of_nonneg_left hbfirst ha).trans hkw) hrec + _ = _ := by + conv_rhs => rw [show M+K = k+(M-k+K) by omega, Finset.sum_range_add] + · have hbfirst : (∑ i ∈ Finset.range M, b i) ≤ (k : ℝ) := by + calc + _ ≤ ∑ i ∈ Finset.range M, (1 : ℝ) := Finset.sum_le_sum fun i _ => (hb i).2 + _ = (M : ℝ) := by simp + _ ≤ k := Nat.cast_le.mpr (by omega) + exact ((mul_le_mul_of_nonneg_left hbfirst ha).trans hkw).trans + (Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono (by omega)) + (fun i _ _ => hu i)) + +lemma stationary_initial_average_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (T : Ω → Ω) (hT : MeasurePreserving T μ μ) + (f : Ω → ℝ) (hf : Measurable f) (hfi : Integrable f μ) (hfn : ∀ x, 0 ≤ f x) + (K : ℕ) (a : ℝ) (ha : 0 < a) : + a * μ.real {x | ∃ k, 0 < k ∧ k ≤ K ∧ + a * (k : ℝ) < ∑ j ∈ Finset.range k, f (T^[j] x)} ≤ ∫ x, f x ∂μ := by + classical + let B : Set Ω := {x | ∃ k, 0 < k ∧ k ≤ K ∧ + a * (k : ℝ) < ∑ j ∈ Finset.range k, f (T^[j] x)} + have hB : MeasurableSet B := by + simp only [B, Set.ofPred_exists] + apply MeasurableSet.iUnion + intro k + have hs : Measurable (fun x => ∑ j ∈ Finset.range k, f (T^[j] x)) := + Finset.measurable_fun_sum _ (fun j _ => hf.comp (hT.iterate j).measurable) + by_cases h0 : 0 < k + · by_cases hk : k ≤ K + · simpa only [h0, hk, true_and] using measurableSet_lt measurable_const hs + · simp only [hk, false_and, and_false, Set.ofPred_false]; exact MeasurableSet.empty + · simp only [h0, false_and, Set.ofPred_false]; exact MeasurableSet.empty + let b : Ω → ℝ := B.indicator (fun _ => (1 : ℝ)) + have hbi : Integrable b μ := integrable_const _ |>.indicator hB + have hb (x : Ω) : 0 ≤ b x ∧ b x ≤ 1 := by + simp only [b, Set.indicator]; split <;> norm_num + have hcomp (g : Ω → ℝ) (hg : Integrable g μ) (n : ℕ) : + Integrable (fun x => g (T^[n] x)) μ ∧ (∫ x, g (T^[n] x) ∂μ) = ∫ x, g x ∂μ := by + refine ⟨(hT.iterate n).integrable_comp_of_integrable hg, ?_⟩ + have hgm : AEStronglyMeasurable g (μ.map (T^[n])) := by + rw [(hT.iterate n).map_eq] + exact hg.aestronglyMeasurable + rw [← integral_map (hT.iterate n).measurable.aemeasurable hgm, (hT.iterate n).map_eq] + have hbi' : (∫ x, b x ∂μ) = μ.real B := by + exact integral_indicator_one hB + have hbme (M : ℕ) : (∫ x, ∑ i ∈ Finset.range M, b (T^[i] x) ∂μ) = M * μ.real B := by + rw [integral_finsetSum _ (fun i _ => (hcomp b hbi i).1)] + simp_rw [(hcomp b hbi _).2, hbi'] + simp + have hfme (M : ℕ) : (∫ x, ∑ i ∈ Finset.range M, f (T^[i] x) ∂μ) = M * ∫ x, f x ∂μ := by + rw [integral_finsetSum _ (fun i _ => (hcomp f hfi i).1)] + simp_rw [(hcomp f hfi _).2] + simp + have hbound (M : ℕ) : a * ((M : ℝ) * μ.real B) ≤ ((M+K : ℕ) : ℝ) * ∫ x, f x ∂μ := by + have hpt (x : Ω) : a * (∑ i ∈ Finset.range M, b (T^[i] x)) ≤ + ∑ i ∈ Finset.range (M+K), f (T^[i] x) := by + apply nonnegative_interval_count a ha.le K _ _ (fun i => hfn _) (fun i => hb _) + intro i hi + have hmem : T^[i] x ∈ B := by + by_contra h + exact hi (Set.indicator_of_notMem h _) + obtain ⟨k, hk, hkK, hkg⟩ := hmem + refine ⟨k, hk, hkK, ?_⟩ + simpa only [← Function.iterate_add_apply, Nat.add_comm] using hkg.le + have hintb : Integrable (fun x => a * ∑ i ∈ Finset.range M, b (T^[i] x)) μ := + (integrable_finsetSum _ (fun i _ => (hcomp b hbi i).1)).const_mul a + have hintf : Integrable (fun x => ∑ i ∈ Finset.range (M+K), f (T^[i] x)) μ := + integrable_finsetSum _ (fun i _ => (hcomp f hfi i).1) + have h := integral_mono hintb hintf hpt + simpa only [integral_const_mul, hbme, hfme] using h + change a * μ.real B ≤ ∫ x, f x ∂μ + by_contra h + have hδ : 0 < a * μ.real B - ∫ x, f x ∂μ := sub_pos.mpr (lt_of_not_ge h) + obtain ⟨M, hM⟩ := exists_nat_gt ((K : ℝ) * (∫ x, f x ∂μ) / + (a * μ.real B - ∫ x, f x ∂μ)) + have hgt := (div_lt_iff₀ hδ).mp hM + have hle := hbound M + push_cast at hle + nlinarith + +lemma integrable_min_nonneg {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) (s : ℝ) (hs : 0 ≤ s) : + Integrable (fun x => min (f x) s) μ := by + apply (integrable_const s).mono' (hf.min measurable_const).aestronglyMeasurable + exact Filter.Eventually.of_forall fun x => by + rw [Real.norm_eq_abs, abs_of_nonneg (le_min (hfn x) hs)] + exact min_le_right _ _ + +noncomputable def truncatedMean {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (f : Ω → ℝ) (s : ℝ) : ℝ := ∫ x, min (f x) s ∂μ + +lemma truncatedMean_nonneg {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (f : Ω → ℝ) (hfn : ∀ x, 0 ≤ f x) + {s : ℝ} (hs : 0 ≤ s) : 0 ≤ truncatedMean μ f s := + integral_nonneg fun x => le_min (hfn x) hs + +lemma truncatedMean_mono {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) {s t : ℝ} (hs : 0 ≤ s) (hst : s ≤ t) : + truncatedMean μ f s ≤ truncatedMean μ f t := + integral_mono (integrable_min_nonneg μ f hf hfn s hs) + (integrable_min_nonneg μ f hf hfn t (hs.trans hst)) + (fun _ => min_le_min le_rfl hst) + +lemma truncatedMean_mul_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (f : Ω → ℝ) (hf : Measurable f) + (hfn : ∀ x, 0 ≤ f x) {s c : ℝ} (hs : 0 ≤ s) (hc : 1 ≤ c) : + truncatedMean μ f (c*s) ≤ c * truncatedMean μ f s := by + rw [truncatedMean, truncatedMean, ← integral_const_mul] + apply integral_mono (integrable_min_nonneg μ f hf hfn _ (mul_nonneg (by linarith) hs)) + ((integrable_min_nonneg μ f hf hfn s hs).const_mul c) + intro x + dsimp only + by_cases h : f x ≤ s + · rw [min_eq_left h] + exact (min_le_left _ _).trans (le_mul_of_one_le_left (hfn x) hc) + · rw [min_eq_right (le_of_not_ge h)] + exact min_le_right _ _ + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Main.lean b/lean/OAI/Probability/Ballisticity/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..e63468abd024d61ed7abd20c0412572d6a53d966 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Main.lean @@ -0,0 +1,33 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.PreBrownianGridMartingale +import OAI.Probability.Ballisticity.Walk.RowProductIntegral +import OAI.Probability.Ballisticity.Stationary.EpisodeFresh +import OAI.Probability.Ballisticity.Stationary.BadArraySampling +import OAI.Probability.Ballisticity.Entropy.BadWindowEntropy +import OAI.Probability.Ballisticity.Stationary.BadArrayElliptic +import OAI.Probability.Ballisticity.Estimates.BadStageMoment +import OAI.Probability.Ballisticity.Estimates.BadDropMoment +import OAI.Probability.Ballisticity.Renewal.PositiveLengthMark +import OAI.Probability.Ballisticity.Stationary.BadFiniteArray +import OAI.Probability.Ballisticity.Stationary.ArrayClassProbability +import OAI.Probability.Ballisticity.Stationary.StationaryProfile2 +import OAI.Probability.Ballisticity.Estimates.RapidDecayTail +import OAI.Probability.Ballisticity.Renewal.VelocityWords + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +theorem directional_transience_implies_ballisticity : MainStatement := by + intro d hd ν hν hue ℓ hℓ htrans + exact directional_transience_implies_ballisticity_unit hd ν hue ℓ hℓ htrans + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Model.lean b/lean/OAI/Probability/Ballisticity/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..fad143ac34d79a3c8d1263f13d61a91c8c2dd0e3 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Model.lean @@ -0,0 +1,97 @@ +import Mathlib + +namespace OAI + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +namespace DirectionalTransience + +abbrev Lattice (d : ℕ) := Fin d → ℤ +abbrev Direction (d : ℕ) := Fin d × Bool +abbrev Vector (d : ℕ) := Fin d → ℝ +abbrev Row (d : ℕ) := {p : Direction d → ℝ≥0 // ∑ e, p e = 1} +abbrev Environment (d : ℕ) := Lattice d → Row d +abbrev State (d : ℕ) := Environment d × Lattice d +abbrev Path (d : ℕ) := ℕ → Lattice d + +def step {d : ℕ} (e : Direction d) : Lattice d := + fun i => if i = e.1 then (if e.2 then 1 else -1) else 0 + +noncomputable def environmentLaw {d : ℕ} (ν : Measure (Row d)) : + Measure (Environment d) := Measure.infinitePi (fun _ => ν) + +def UniformElliptic {d : ℕ} (ν : Measure (Row d)) : Prop := + ∃ κ : ℝ≥0, 0 < κ ∧ ∀ᵐ p ∂ν, ∀ e, κ ≤ p.1 e + +lemma measurable_current_row {d : ℕ} : + Measurable (fun z : State d => z.1 z.2) := by + apply measurable_from_prod_countable_left + intro x + exact measurable_pi_apply x + +noncomputable def transition {d : ℕ} : Kernel (State d) (State d) where + toFun z := ∑ e : Direction d, + ((z.1 z.2).1 e : ℝ≥0∞) • Measure.dirac (z.1, z.2 + step e) + measurable' := by + apply Measure.measurable_of_measurable_coe + intro s hs + simp only [Measure.finsetSum_apply, Measure.smul_apply, smul_eq_mul] + apply Finset.measurable_fun_sum + intro e _ + apply Measurable.mul + · exact (measurable_pi_apply e |>.comp + (measurable_subtype_coe.comp measurable_current_row)).coe_nnreal_ennreal + · exact (Measure.measurable_coe hs).comp + (Measure.measurable_dirac.comp (measurable_fst.prodMk + (measurable_snd.add_const (step e)))) + +instance transition_markov {d : ℕ} : IsMarkovKernel (transition (d := d)) where + isProbabilityMeasure z := by + constructor + change (∑ e : Direction d, + ((z.1 z.2).1 e : ℝ≥0∞) • Measure.dirac (z.1, z.2 + step e)) Set.univ = 1 + simp only [Measure.finsetSum_apply, Measure.smul_apply, Measure.dirac_apply_of_mem + (Set.mem_univ _), smul_eq_mul, mul_one] + rw [← ENNReal.ofNNReal_finsetSum, (z.1 z.2).2] + rfl + +noncomputable def historyTransition {d : ℕ} (n : ℕ) : + Kernel ((i : Finset.Iic n) → State d) (State d) where + toFun z := transition (z ⟨n, Finset.mem_Iic.mpr le_rfl⟩) + measurable' := transition.measurable.comp (measurable_pi_apply _) + +instance historyTransition_markov {d : ℕ} (n : ℕ) : + IsMarkovKernel (historyTransition (d := d) n) where + isProbabilityMeasure _ := transition_markov.isProbabilityMeasure _ + +noncomputable def initialLaw {d : ℕ} (ν : Measure (Row d)) : Measure (State d) := + (environmentLaw ν).map (fun ω => (ω, (0 : Lattice d))) + +noncomputable def annealedLaw {d : ℕ} (ν : Measure (Row d)) : Measure (Path d) := + (@Kernel.trajMeasure (fun _ => State d) _ (initialLaw ν) (historyTransition (d := d)) _).map + (fun z n => (z n).2) + +def dot {d : ℕ} (v ℓ : Vector d) : ℝ := ∑ i, v i * ℓ i + +def realPosition {d : ℕ} (x : Lattice d) : Vector d := fun i => (x i : ℝ) + +def DirectionallyTransient {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) : Prop := + ∀ᵐ X ∂annealedLaw ν, + Tendsto (fun n => dot (realPosition (X n)) ℓ) atTop atTop + +def HasVelocity {d : ℕ} (ν : Measure (Row d)) (v : Vector d) : Prop := + ∀ᵐ X ∂annealedLaw ν, + Tendsto (fun n : ℕ => (fun i => (X n i : ℝ) / (n : ℝ))) atTop (𝓝 v) + +open scoped ENNReal NNReal Classical Topology BigOperators + +def MainStatement : Prop := + ∀ (d : ℕ), 2 ≤ d → ∀ (ν : Measure (Row d)), IsProbabilityMeasure ν → + UniformElliptic ν → ∀ (ℓ : Vector d), dot ℓ ℓ = 1 → + DirectionallyTransient ν ℓ → + ∃ v : Vector d, 0 < dot v ℓ ∧ HasVelocity ν v + +end DirectionalTransience + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/PositiveEscape.lean b/lean/OAI/Probability/Ballisticity/PositiveEscape.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba8dc890531e54cf96ce030da5f08dcbcbbe6764 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/PositiveEscape.lean @@ -0,0 +1,80 @@ +import OAI.Probability.Ballisticity.RowBridge + +namespace OAI + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +namespace DirectionalTransience + +lemma uniformElliptic_directional_zero_one {d : ℕ} (hd : 3 ≤ d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (ℓ : Vector d) (hℓ : ℓ ≠ 0) : + annealedLaw ν (TransientPaths ℓ) = 0 ∨ annealedLaw ν (TransientPaths ℓ) = 1 := by + have h := DirectionalZeroOne.directional_zero_one d hd (RowBridge.rowLaw ν) + (RowBridge.strictEllipticity ν hue) ℓ hℓ + change DirectionalZeroOne.annealed (RowBridge.rowLaw ν) 0 (TransientPaths ℓ) = 0 ∨ + DirectionalZeroOne.annealed (RowBridge.rowLaw ν) 0 (TransientPaths ℓ) = 1 at h + rwa [← RowBridge.annealedLaw_eq ν] at h + +lemma dot_div_right {d : ℕ} (v ℓ : Vector d) (r : ℝ) : + dot v (fun i => ℓ i / r) = dot v ℓ / r := by + simp only [dot, mul_div_assoc, Finset.sum_div] + +lemma dot_self_pos_of_ne_zero {d : ℕ} (ℓ : Vector d) (hℓ : ℓ ≠ 0) : + 0 < dot ℓ ℓ := by + obtain ⟨i, hi⟩ := Function.ne_iff.mp hℓ + change ℓ i ≠ 0 at hi + exact (mul_self_pos.mpr hi).trans_le + (Finset.single_le_sum (fun j _ => mul_self_nonneg (ℓ j)) (Finset.mem_univ i)) + +lemma transientPaths_div_pos {d : ℕ} (ℓ : Vector d) {r : ℝ} (hr : 0 < r) : + TransientPaths (fun i => ℓ i / r) = TransientPaths ℓ := by + ext X + simp only [TransientPaths, Set.mem_ofPred_eq, dot_div_right] + exact tendsto_div_const_atTop_of_pos hr + +lemma velocity_of_positive_escape {d : ℕ} (hd : 3 ≤ d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (ℓ : Vector d) (hℓ : ℓ ≠ 0) (hpos : 0 < annealedLaw ν (TransientPaths ℓ)) : + ∃ v : Vector d, 0 < dot v ℓ ∧ HasVelocity ν v := by + have hprob : annealedLaw ν (TransientPaths ℓ) = 1 := + (uniformElliptic_directional_zero_one hd ν hue ℓ hℓ).resolve_left hpos.ne' + have hs : 0 < dot ℓ ℓ := dot_self_pos_of_ne_zero ℓ hℓ + let r : ℝ := Real.sqrt (dot ℓ ℓ) + have hr : 0 < r := Real.sqrt_pos.mpr hs + let u : Vector d := fun i => ℓ i / r + have hu : dot u u = 1 := by + have he : dot u u = dot ℓ ℓ / (r * r) := by + simp only [u, dot, div_mul_div_comm, Finset.sum_div] + rw [he, show r * r = dot ℓ ℓ from Real.mul_self_sqrt hs.le, div_self hs.ne'] + have htrans : DirectionallyTransient ν u := by + apply (mem_ae_iff_prob_eq_one (measurableSet_transientPaths u)).mpr + rw [transientPaths_div_pos ℓ hr] + exact hprob + obtain ⟨v, hvu, hv⟩ := directional_transience_implies_ballisticity_unit + (by omega : 2 ≤ d) ν hue u hu htrans + refine ⟨v, ?_, hv⟩ + have hp : 0 < dot v ℓ / r := by simpa only [u, dot_div_right] using hvu + exact (div_pos_iff_of_pos_right hr).mp hp + +lemma escape_probability_one_of_velocity {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (v u : Vector d) (hv : HasVelocity ν v) + (hvu : 0 < dot v u) : annealedLaw ν (TransientPaths u) = 1 := by + apply (mem_ae_iff_prob_eq_one (measurableSet_transientPaths u)).mp + filter_upwards [hv] with X hX + have hproj := velocityPaths_projection v u X hX + have hprod := hproj.pos_mul_atTop hvu + (tendsto_natCast_atTop_atTop : Tendsto (fun n : ℕ => (n : ℝ)) atTop atTop) + apply hprod.congr' + filter_upwards [eventually_gt_atTop (0 : ℕ)] with n hn + exact div_mul_cancel₀ _ (by exact_mod_cast hn.ne') + +lemma unit_direction_ne_zero {d : ℕ} (u : Vector d) (hu : dot u u = 1) : u ≠ 0 := by + intro h + subst u + simp [dot] at hu + +end DirectionalTransience + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/ClippingPositiveNumbers.lean b/lean/OAI/Probability/Ballisticity/Renewal/ClippingPositiveNumbers.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dbbfefe4f9910f0eba4ed81fcaa45dfb0c93f6a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/ClippingPositiveNumbers.lean @@ -0,0 +1,46 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CommonWordIncrement + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience +lemma exists_large_tail_cut {K ζ : ℝ} (hK : 0 < K) (hζ : 0 < ζ) : + ∃ A : ℝ, 0 < A ∧ K*(2048/(A/40)^2) < ζ/8 := by + let A := 40*(Real.sqrt (16384*K/ζ)+1) + have hA : 0 < A := by dsimp [A]; positivity + refine ⟨A,hA,?_⟩ + have hs := Real.sq_sqrt (show 0 ≤ 16384*K/ζ by positivity) + have hs0 := Real.sqrt_nonneg (16384*K/ζ) + have hss : 16384*K < ζ*(A/40)^2 := by + have he : A/40=Real.sqrt (16384*K/ζ)+1 := by dsimp [A]; ring + rw [he] + have hd : ζ*(16384*K/ζ)=16384*K := by field_simp + nlinarith + have hAp : 0 < (A/40)^2 := by positivity + rw [←mul_div_assoc,div_lt_iff₀ hAp] + nlinarith + +lemma profile_scale_ratio {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (S : Ω → ℝ) (hS : Measurable S) (hzero : 0 < μ {x | S x ≠ 0}) + (r : ℕ → ℝ) (hr : ∀ n, 0 < r n) {b F : ℝ} (hb : 0 < b) (hF : 0 < F) + (hlim : Tendsto (fun n => truncatedVariance μ S (b*r n)/truncatedVariance μ S (r n)) atTop (𝓝 F)) : + Tendsto (fun n => fluctuationScale μ S (b*r n)/fluctuationScale μ S (r n)) atTop (𝓝 (b^2/F)) := by + convert tendsto_const_nhds.div hlim hF.ne' using 1 + funext n + have hv := ne_of_gt (truncatedVariance_pos μ S hS hzero (hr n)) + have hvb := ne_of_gt (truncatedVariance_pos μ S hS hzero (mul_pos hb (hr n))) + dsimp [fluctuationScale] + field_simp [(hr n).ne',hv,hvb] +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/CurvePositiveScale.lean b/lean/OAI/Probability/Ballisticity/Renewal/CurvePositiveScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a826f830e2b18ba45f4c89e36abd7a67bb18d22 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/CurvePositiveScale.lean @@ -0,0 +1,253 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.ClippingTime +import OAI.Probability.Ballisticity.Renewal.ClippingPositiveNumbers +import OAI.Probability.Ballisticity.Estimates.SmallScaleTailMoment + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience +lemma positive_scale_moment_arithmetic {V z r s ρ A bad tail ζ t : ℝ} + (hr : 0 < r) (hz : 0 < z) (hζ : 0 < ζ) (hA : 0 < A) + (hρ : ρ^2 ≤ ζ) (hbad : bad < ζ/A^2) (htail : tail < ζ) + (hV : V ≤ (ρ*z)^2+(A*z)^2*bad+2*(z^2*tail)) + (hs : s^2 ≤ t) (hsz : z=s*r) : V/r^2 ≤ 4*ζ*t := by + have hba := (lt_div_iff₀ (sq_pos_of_pos hA)).mp hbad + have ht' := mul_lt_mul_of_pos_left htail (sq_pos_of_pos hz) + have hρ' := mul_le_mul_of_nonneg_left hρ (sq_nonneg z) + have hba' := mul_lt_mul_of_pos_left hba (sq_pos_of_pos hz) + have hVz : V ≤ z^2*(4*ζ) := by nlinarith only [hV,ht',hρ',hba'] + apply (div_le_iff₀ (sq_pos_of_pos hr)).mpr + have hh := mul_le_mul_of_nonneg_right hs (show 0 ≤ r^2*(4*ζ) by positivity) + rw [hsz] at hVz + nlinarith only [hVz,hh] + +lemma curve_positive_scale {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (hp : annealedLaw ν (NoDrop (realPosition (step e)) 0) ≠ 0) + {r s b A ρ t C D M η ε : ℝ} (hr : 0 < r) (hs : 0 < s) (hb : 0 < b) + (hA : 0 < A) (hρ : 0 < ρ) (ht : 0 < t) (hC : 0 < C) (hD : 0 < D) + (hM : 0 < M) (hη : 0 < η) (hε : 0 < ε) + (hbη : b < η/8) (hAs : A*s < b) (hst : s^2 ≤ t) + (hρsq : ρ^2 ≤ ε*η^2/(1024*M)) (hCs : C*Real.sqrt t ≤ η/8) + (hDt : 2*D*M*t ≤ ε/16) + {H K J : ℕ} (hH : 0 < H) (hK : 0 < K) (hKJ : K ≤ J*H) (hJt : (J:ℝ)*t ≤ M) + {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (hδ1 : δ ≤ 1) (hα1 : α ≤ 1) + (hline : ∀ j ≤ H, |(recordMedian ν (realPosition (step e)) hp f j:ℝ)- + (j:ℝ)*(recordMedian ν (realPosition (step e)) hp f H:ℝ)/H| ≤ C*Real.sqrt t*r) + (hfail : (environmentLaw ν).real {ω | curveIncrement (realPosition (step e)) f 0 + (fun j => (recordMedian ν (realPosition (step e)) hp f j:ℝ)) (b*r) H ω Set.univ < δ} ≤ D*t^2) + (hbad : (environmentLaw ν).real {ω | ¬ α*crossingQuenched (realPosition (step e)) 0 H ω ≤ + curveIncrement (realPosition (step e)) f 0 (fun j => (recordMedian ν (realPosition (step e)) hp f j:ℝ)) + (b*r) H ω {u | |signedCoordinate f u-(recordMedian ν (realPosition (step e)) hp f H:ℝ)| ≤ ρ*(s*r)}} < + (ε*η^2/(1024*M))/A^2) + (htail : cappedTailMoment (successfulAverage ν (realPosition (step e)) H) + (fun X => medianDeviation (realPosition (step e)) f + (fun j => (recordMedian ν (realPosition (step e)) hp f j:ℝ)) H X/(s*r)) A (b/s) < ε*η^2/(1024*M)) : + ∃ θ : ℝ, (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix (realPosition (step e)) f 0 θ (η*r) K) < (α*δ)^J/2} < ε := by + let ℓ := realPosition (step e) + let med := fun a => (recordMedian ν ℓ hp f a:ℝ) + let dum := medianDummy e f H (recordMedian ν ℓ hp f H) + have hdh : signedHeight e dum=H := medianDummy_height e f hef _ _ + have hdb : signedCoordinate f dum=med H := medianDummy_coordinate e f hef _ _ + let E := {u : Lattice d | |signedCoordinate f u-med H| ≤ ρ*(s*r)} + let υ := curvePolicy_average ν ℓ f med (b*r) hH E hδ hα dum + let θ := (∫ u, signedCoordinate f u ∂υ.toMeasure)/(H:ℝ) + refine ⟨θ,?_⟩ + have hprob := curvePolicy_real_tube_probability ν e f med (mul_nonneg hb.le hr.le) + (by positivity : 0 ≤ C*Real.sqrt t*r) hH (by positivity : 0 < η*r/2) + hline E hδ hα hδ1 hα1 dum hdh hdb J hK hKJ + have hwidth : η*r/2+2*(b*r)+C*Real.sqrt t*r ≤ η*r := by + have hh := mul_le_mul_of_nonneg_right hCs hr.le + have hb' := mul_lt_mul_of_pos_right hbη hr + nlinarith only [hh,hb',mul_pos hη hr] + have hlow : (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix ℓ f 0 θ (η*r) K) < (α*δ)^J/2} ≤ + (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix ℓ f 0 θ (η*r/2+2*(b*r)+C*Real.sqrt t*r) K) < (α*δ)^J/2} := by + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono + intro ω hω + exact (measure_mono (tubePrefix_mono_width ℓ f 0 θ hwidth _)).trans_lt hω + have hzn : 0 < s*r := mul_pos hs hr + have hAB : A*(s*r) < b*r := by nlinarith only [mul_lt_mul_of_pos_right hAs hr] + have hm := curvePolicy_average_moment ν hue e f htrans med (mul_nonneg hA.le hzn.le) hAB + (mul_nonneg hρ.le hzn.le) hH hδ hα dum hdb + have hdsc := cappedTailMoment_descaled (successfulAverage ν ℓ H) + (fun X => medianDeviation ℓ f med H X) (r:=s*r) (A:=A) (B:=b/s) hzn + have hbz : (b/s)*(s*r)=b*r := by field_simp + rw [hbz] at hdsc + dsimp only at hm + rw [hdsc] at hm + have hV := positive_scale_moment_arithmetic hr hzn (show 0 < ε*η^2/(1024*M) by positivity) + hA hρsq hbad htail hm hst rfl + exact (hlow.trans hprob).trans_lt (clipping_error_bound (show (0:ℝ)≤J by positivity) + hD.le hM ht hr hη hε hJt hfail hDt hV) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +theorem clipping_positive_profile {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : ∀ n, 0 < r n) (hrinf : Tendsto r atTop atTop) + (F : ℕ → ℝ) {F₀ : ℝ} (hF₀ : 0 < F₀) (hF₀1 : F₀ ≤ 1) + (hFle : ∀ j, F₀ ≤ F j) (hFlim : Tendsto F atTop (𝓝 F₀)) + (hF : ∀ j, Tendsto (fun n => truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (dyadicCut j*r n)/ + truncatedVariance (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r n)) atTop (𝓝 (F j))) + {T η ε : ℝ} (hT : 0 < T) (hη : 0 < η) (hε : 0 < ε) : + ∃ c : ℝ≥0∞, 0 < c ∧ c ≤ 1 ∧ ∀ᶠ n in atTop, ∃ θ : ℝ, + (environmentLaw ν).real {ω | quenchedKernel (ω,0) + (TubePrefix (realPosition (step e)) f 0 θ (η*r n) + ⌈T*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r n)⌉₊) < c} < ε := by + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let p := (annealedLaw ν (NoDrop ℓ 0)).toReal + have hp0 : 0 < p := ENNReal.toReal_pos hp (measure_ne_top _ _) + let μ := independentConditionedPairLaw ν ℓ + let S := commonIncrementProcess ℓ f 0 + let : IsProbabilityMeasure μ := independentConditionedPairLaw_probability ν ℓ hp + let K := 16000/p^2 + have hK : 0 < K := by dsimp [K]; positivity + let M := 8*T+1 + have hM : 0 < M := by dsimp [M]; linarith + let ζ := ε*η^2/(1024*M) + have hζ : 0 < ζ := by dsimp [ζ]; positivity + let ρ := Real.sqrt ζ/2 + have hρ : 0 < ρ := by dsimp [ρ]; positivity + have hρsq : ρ^2 ≤ ζ := by + have hh := Real.sq_sqrt hζ.le + dsimp [ρ] + nlinarith only [hh,hζ.le] + obtain ⟨A,hA,hAK⟩ := exists_large_tail_cut hK hζ + obtain ⟨B,hBF,hBb⟩ := (((hFlim.div_const F₀).sub_const 1).eventually + (gt_mem_nhds (show F₀/F₀-1 < ζ/(128*K) by rw [div_self hF₀.ne',sub_self]; positivity))).and + (dyadicCut_tendsto.eventually (gt_mem_nhds (by positivity : 0 < η/8))) |>.exists + let b := dyadicCut B + have hb : 0 < b := dyadicCut_pos B + have hbη : b < η/8 := hBb + have hBK : K*(16*(F B/F₀-1)) < ζ/8 := by + have hh := (lt_div_iff₀ (show 0 < 128*K by positivity)).mp hBF + nlinarith only [hh] + obtain ⟨C,hC,t₁,ht₁,hmed⟩ := recordMedian_shortBlock ν hue e f hef htrans + obtain ⟨D,hD,t₀,ht₀,hfail⟩ := curveIncrement_short_block ν hue e f hef htrans hb + obtain ⟨τ,hτ,hτ₀,hτ₁,hτ1,hCs,hDt⟩ := exists_clipping_time ht₀ ht₁ hC hD hM hη hε + obtain ⟨cα,hcα,hGaussian⟩ := small_scale_gaussian_mass ν hue e f hef htrans hρ + let α := min cα 1 + have hα : 0 < α := lt_min hcα zero_lt_one + have hα1 : α ≤ 1 := min_le_right _ _ + have hαc : α ≤ cα := min_le_left _ _ + have htail := small_scale_tail_moment ν hue e f hef htrans r hr hrinf F hF₀ hFle hFlim hF + hA B (show 0 < ζ/4 by positivity) + have hgauss := hGaussian r hr hrinf F F₀ hF₀ hFle hFlim hF b hb 0 (ζ/A^2) (by positivity) + have htlim : Tendsto (fun j => 2*(dyadicCut j)^2/F₀) atTop (𝓝 0) := by + simpa only [zero_pow (by omega : 2 ≠ 0),mul_zero,zero_div] using ((dyadicCut_tendsto.pow 2).const_mul 2).div_const F₀ + obtain ⟨j,hjtail,hjgauss,hjt,hjF,hjA⟩ := (htail.and (hgauss.and + ((htlim.eventually (gt_mem_nhds hτ)).and ((hFlim.eventually (gt_mem_nhds (by linarith : F₀ < 2*F₀))).and + (dyadicCut_tendsto.eventually (gt_mem_nhds (div_pos hb hA))))))).exists + let s := dyadicCut j + have hs : 0 < s := dyadicCut_pos j + let t := 2*s^2/F₀ + have ht : 0 < t := by dsimp [t]; positivity + have htt : t ≤ τ := le_of_lt hjt + have htt₀ : t ≤ t₀ := htt.trans hτ₀ + have htt₁ : t ≤ t₁ := htt.trans hτ₁ + have ht1 : t ≤ 1 := htt.trans hτ1 + have hCs' : C*Real.sqrt t ≤ η/8 := (mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt htt) hC.le).trans hCs + have hDt' : 2*D*M*t ≤ ε/16 := (mul_le_mul_of_nonneg_left htt (by positivity)).trans hDt + have hAs : A*s < b := by + have hh := (lt_div_iff₀ hA).mp hjA + simpa only [mul_comm] using hh + obtain ⟨J,hJT,hJM⟩ := exists_block_count (show 0 < 4*T by positivity) ht ht1 + have hJt : (J:ℝ)*t ≤ M := by dsimp [M]; linarith + obtain ⟨δ,hδ,hδ1,R,hR,hfail⟩ := hfail t ht htt₀ + let δe := ENNReal.ofReal δ + let αe := ENNReal.ofReal α + have hδe : 0 < δe := ENNReal.ofReal_pos.mpr hδ + have hαe : 0 < αe := ENNReal.ofReal_pos.mpr hα + have hδe1 : δe ≤ 1 := ENNReal.ofReal_le_one.mpr hδ1 + have hαe1 : αe ≤ 1 := ENNReal.ofReal_le_one.mpr hα1 + let c := (αe*δe)^J/2 + have hc : 0 < c := ENNReal.div_pos (pow_ne_zero _ (mul_ne_zero hαe.ne' hδe.ne')) (by norm_num) + have hc1 : c ≤ 1 := by + apply (ENNReal.div_le_iff (by norm_num : (2:ℝ≥0∞) ≠ 0) (by norm_num)).mpr + exact (pow_le_one₀ (zero_le : (0:ℝ≥0∞) ≤ αe*δe) + ((mul_le_of_le_one_left (zero_le : (0:ℝ≥0∞) ≤ δe) hαe1).trans hδe1)).trans (by norm_num) + let N := fun n => fluctuationScale μ S (r n) + let z := fun n => s*r n + let Nz := fun n => fluctuationScale μ S (z n) + let H := fun n => ⌊Nz n⌋₊ + have hN : Tendsto N atTop atTop := recordFluctuationScale_tendsto ν hue e f hef htrans r hrinf + have hz : ∀ n, 0 < z n := fun n => mul_pos hs (hr n) + have hNz : Tendsto Nz atTop atTop := recordFluctuationScale_tendsto ν hue e f hef htrans z (hrinf.const_mul_atTop hs) + have hH : Tendsto H atTop atTop := tendsto_nat_floor_atTop.comp hNz + have hratio := profile_scale_ratio μ S (measurable_commonIncrementProcess ℓ f 0) + (independent_commonWordIncrement_nonzero ν hue e f hef htrans) r hr hs (hF₀.trans_le (hFle j)) (hF j) + have hrt : s^2/F j < t := calc + _ ≤ s^2/F₀ := div_le_div_of_nonneg_left (sq_nonneg s) hF₀ (hFle j) + _ < 2*(s^2/F₀) := by linarith only [show 0 < s^2/F₀ by positivity] + _ = t := by dsimp [t]; ring + have hlr : t/4 < s^2/F j := by + have hh := div_lt_div_of_pos_left (sq_pos_of_pos hs) (hF₀.trans_le (hFle j)) hjF + have he : t/4=s^2/(2*F₀) := by dsimp [t]; ring + rw [he] + exact hh + have hbounds : ∀ᶠ n in atTop, 0 < H n ∧ (H n:ℝ) ≤ t*N n ∧ ⌈T*N n⌉₊ ≤ J*H n ∧ 0 < ⌈T*N n⌉₊ := by + filter_upwards [hN.eventually (eventually_gt_atTop (0:ℝ)), hratio.eventually (Ioo_mem_nhds hlr hrt), + eventually_ceil_horizon_covered N hN hT (show 0 < t/4 by positivity) J (by linarith)] with n hNn hn hc + have hupper : Nz n ≤ t*N n := ((div_lt_iff₀ hNn).mp hn.2).le + have hlower : t/4*N n ≤ Nz n := ((lt_div_iff₀ hNn).mp hn.1).le + have hfloor : ⌊t/4*N n⌋₊ ≤ H n := Nat.floor_mono hlower + exact ⟨hc.1.trans_le hfloor,(Nat.floor_le (fluctuationScale_nonneg μ S (z n))).trans hupper, + hc.2.2.trans (Nat.mul_le_mul_left J hfloor),hc.2.1⟩ + let med := fun a => (recordMedian ν ℓ hp f a:ℝ) + let Q := fun n => successfulAverage ν ℓ (H n) + let W := fun n X => medianDeviation ℓ f med (H n) X + let tail := fun n => cappedTailMoment (Q n) (fun X => W n X/z n) A (b/s) + have htailBound : IsBoundedUnder (· ≤ ·) atTop tail := by + apply isBoundedUnder_of + refine ⟨(b/s)^2,fun n => ?_⟩ + let := successfulAverage_probability ν hue ℓ (signed_direction_unit e) htrans (H n) + exact (cappedTailMoment_bounds (Q n) _ ((measurable_medianDeviation ℓ f med (H n)).div_const (z n)) + (fun X => div_nonneg (medianDeviation_nonneg ℓ f med (H n) X) (hz n).le) A (div_pos hb hs)).2 + have htailSmall : limsup tail atTop < ζ := by + have hh : limsup tail atTop ≤ K*(2048/(A/40)^2+16*(F B/F₀-1))+ζ/4 := hjtail + nlinarith only [hh,hAK,hBK,hζ] + have htailEv := eventually_lt_of_limsup_lt htailSmall htailBound + refine ⟨c,hc,hc1,?_⟩ + filter_upwards [htailEv,hjgauss,hbounds,hrinf.eventually (eventually_ge_atTop R)] with n htn hgn hbds hrR + have hrn := hr n + have hzn := hz n + have hHn : 0 < H n := hbds.1 + have hline := hmed t ht htt₁ (r n) hrn (H n) hHn hbds.2.1 + have hbad := (curveGaussian_failure_le ν hue e f htrans hp hHn (b*r n) (ρ*z n) hα hαc).trans_lt hgn + have hs2 : s^2 ≤ t := by + dsimp [t] + apply (le_div_iff₀ hF₀).mpr + nlinarith only [mul_le_mul_of_nonneg_left hF₀1 (sq_nonneg s),sq_nonneg s] + exact curve_positive_scale ν hue e f hef htrans hp hrn hs hb hA hρ ht hC hD hM hη hε + hbη hAs hs2 hρsq hCs' hDt' hHn hbds.2.2.2 hbds.2.2.1 hJt hδe hαe hδe1 hαe1 + hline (hfail (r n) hrR (H n) hHn hbds.2.1) hbad htn +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/DurationMoment.lean b/lean/OAI/Probability/Ballisticity/Renewal/DurationMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ff74bec7a7efd2844a61c3297a9442a2bbade21 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/DurationMoment.lean @@ -0,0 +1,210 @@ +import Mathlib +import OAI.Probability.Ballisticity.Renewal.DurationTail +import OAI.Probability.Ballisticity.Estimates.NaturalTailIntegrable + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma conditioned_wordDuration_integrable {d : ℕ} (hd : 2 ≤ d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + Integrable (fun X => ((firstWord (realPosition (step e)) X).length:ℝ)) + (conditionedLaw ν (realPosition (step e))) := by + let : IsProbabilityMeasure (conditionedLaw ν (realPosition (step e))) := + conditionedLaw_probability ν _ (noDrop_positive_of_directionallyTransient ν _ htrans).ne' + obtain ⟨A,hA,ht⟩ := duration_polynomial_rapidDecay hd ν hue e htrans + exact natural_integrable_of_polynomial_rapid_tail _ _ + ((measurable_of_countable List.length).comp (measurable_firstWord _)) A (4*d+2) hA (by omega) ht + +lemma conditioned_wordDuration_mean_positive {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (hint : Integrable (fun X => ((firstWord ℓ X).length:ℝ)) (conditionedLaw ν ℓ)) : + 0 < ∫ X, ((firstWord ℓ X).length:ℝ) ∂conditionedLaw ν ℓ := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := + conditionedLaw_probability ν _ (noDrop_positive_of_directionallyTransient ν _ htrans).ne' + have hge : (1:ℝ) ≤ ∫ X, ((firstWord ℓ X).length:ℝ) ∂conditionedLaw ν ℓ := by + calc + (1:ℝ) = ∫ X, (1:ℝ) ∂conditionedLaw ν ℓ := by simp + _ ≤ _ := integral_mono_ae (integrable_const _) hint (by + filter_upwards [conditioned_firstWord_exists ν ℓ htrans] with X hX + have hh := (firstWordEvent_self ℓ X hX).2.2.1 + exact_mod_cast hh) + linarith + +lemma conditioned_word_temporal_strong_law {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) + (hint : Integrable (fun X => ((firstWord ℓ X).length:ℝ)) (conditionedLaw ν ℓ)) : + ∀ᵐ X ∂conditionedLaw ν ℓ, Tendsto + (fun n : ℕ => (regenerationTimes ℓ X n:ℝ)/n) atTop + (𝓝 (∫ Y, ((firstWord ℓ Y).length:ℝ) ∂conditionedLaw ν ℓ)) := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := + conditionedLaw_probability ν _ (noDrop_positive_of_directionallyTransient ν _ htrans).ne' + have hm : Measurable (fun w : List (Direction d) => (w.length:ℝ)) := measurable_of_countable _ + have ht := strong_law_ae_real (fun n X => ((regenerationWords ℓ X n).length:ℝ)) hint + (fun i j hij => ((regenerationWords_independent ν ℓ htrans).indepFun hij).comp hm hm) + (fun i => (regenerationWords_identDistrib ν ℓ htrans i).comp hm) + simpa only [regenerationTimes,Nat.cast_sum,regenerationWords,Function.iterate_zero,id_eq] using ht + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma scalar_cut_speed (T : ℕ → ℕ) (hT : StrictMono T) (hT0 : T 0=0) + (Y R : ℕ → ℝ) (m t : ℝ) (ht : 0 < t) + (hTime : Tendsto (fun n : ℕ => (T n:ℝ)/n) atTop (𝓝 t)) + (hSpace : Tendsto (fun n : ℕ => Y (T n)/n) atTop (𝓝 m)) + (hR : Tendsto (fun n : ℕ => R n/n) atTop (𝓝 0)) + (herr : ∀ k n, T k ≤ n → n < T (k+1) → |Y n-Y (T k)| ≤ R k) : + Tendsto (fun n : ℕ => Y n/n) atTop (𝓝 (m/t)) := by + choose K hK using increasing_cuts_cover T hT hT0 + have hKt := increasing_cuts_index_tendsto T K hT hK + have hr : Tendsto (fun n : ℕ => ((n:ℝ)+1)/n) atTop (𝓝 1) := by + have hh := (tendsto_natCast_div_add_atTop (𝕜 := ℝ) 1).inv₀ (by norm_num : (1:ℝ) ≠ 0) + simpa only [inv_one,inv_div] using hh + have hsucc : Tendsto (fun n : ℕ => (T (n+1):ℝ)/n) atTop (𝓝 t) := by + have hh := (hTime.comp (tendsto_add_atTop_nat 1)).mul hr + simp only [mul_one] at hh + apply hh.congr' + filter_upwards [eventually_gt_atTop (0:ℕ)] with n hn + have hn' : (n:ℝ) ≠ 0 := by exact_mod_cast hn.ne' + have hn1 : (n:ℝ)+1 ≠ 0 := by positivity + simp only [Function.comp_def,Nat.cast_add,Nat.cast_one] + field_simp + have hden : Tendsto (fun n : ℕ => (n:ℝ)/K n) atTop (𝓝 t) := by + apply tendsto_of_tendsto_of_tendsto_of_le_of_le (hTime.comp hKt) (hsucc.comp hKt) + · intro n + change (T (K n):ℝ)/(K n:ℝ) ≤ (n:ℝ)/(K n:ℝ) + exact div_le_div_of_nonneg_right (Nat.cast_le.mpr (hK n).1) (Nat.cast_nonneg _) + · intro n + change (n:ℝ)/(K n:ℝ) ≤ (T (K n+1):ℝ)/(K n:ℝ) + exact div_le_div_of_nonneg_right (Nat.cast_le.mpr (hK n).2.le) (Nat.cast_nonneg _) + have hnum : Tendsto (fun n : ℕ => Y n/K n) atTop (𝓝 m) := by + have hlo := (hSpace.sub hR).comp hKt + have hhi := (hSpace.add hR).comp hKt + simp only [sub_zero,add_zero] at hlo hhi + apply tendsto_of_tendsto_of_tendsto_of_le_of_le hlo hhi + · intro n + have hh := (abs_le.mp (herr (K n) n (hK n).1 (hK n).2)).1 + have hb : Y (T (K n))-R (K n) ≤ Y n := by linarith + simpa only [sub_div,Function.comp_def] using div_le_div_of_nonneg_right hb (Nat.cast_nonneg (K n)) + · intro n + have hh := (abs_le.mp (herr (K n) n (hK n).1 (hK n).2)).2 + have hb : Y n ≤ Y (T (K n))+R (K n) := by linarith + simpa only [add_div,Function.comp_def] using div_le_div_of_nonneg_right hb (Nat.cast_nonneg (K n)) + apply (hnum.div hden ht.ne').congr' + filter_upwards [hKt.eventually (eventually_gt_atTop (0:ℕ)),eventually_gt_atTop (0:ℕ)] with n hn hn' + have hk : (K n:ℝ) ≠ 0 := by exact_mod_cast hn.ne' + have hn0 : (n:ℝ) ≠ 0 := by exact_mod_cast hn'.ne' + change (Y n/(K n:ℝ))/((n:ℝ)/(K n:ℝ)) = Y n/(n:ℝ) + field_simp + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +def VelocityPaths {d : ℕ} (v : Vector d) : Set (Path d) := + {X | Tendsto (fun n : ℕ => fun i => (X n i:ℝ)/(n:ℝ)) atTop (𝓝 v)} + +lemma measurableSet_velocityPaths {d : ℕ} (v : Vector d) : MeasurableSet (VelocityPaths v) := by + apply measurableSet_tendsto + intro n + exact (measurable_of_countable (fun y : Lattice d => fun i => (y i:ℝ)/(n:ℝ))).comp + (measurable_pi_apply n) + +lemma velocityPaths_of_suffix {d : ℕ} (v : Vector d) (X : Path d) (n : ℕ) + (ht : (fun j => X (n+j)-X n) ∈ VelocityPaths v) : X ∈ VelocityPaths v := by + apply tendsto_pi_nhds.mpr + intro i + have hh := tendsto_pi_nhds.mp ht i + have hz : Tendsto (fun j : ℕ => (X n i:ℝ)/j) atTop (𝓝 0) := by + simpa only [div_eq_mul_inv,mul_zero] using + (tendsto_const_nhds.mul (tendsto_inv_atTop_nhds_zero_nat (𝕜 := ℝ)) : + Tendsto (fun j : ℕ => (X n i:ℝ)*(j:ℝ)⁻¹) atTop (𝓝 ((X n i:ℝ)*0))) + have hs : Tendsto (fun j : ℕ => (X (n+j) i:ℝ)/j) atTop (𝓝 (v i)) := by + convert hh.add hz using 1 <;> simp [Pi.sub_apply,Int.cast_sub,sub_div] + have hp := hs.mul (tendsto_natCast_div_add_atTop (𝕜 := ℝ) (n:ℝ)) + simp only [mul_one] at hp + apply (tendsto_add_atTop_iff_nat n).mp + apply hp.congr' + filter_upwards [eventually_gt_atTop (0:ℕ)] with j hj + have hj' : (j:ℝ) ≠ 0 := by exact_mod_cast hj.ne' + change (X (n+j) i:ℝ)/(j:ℝ) * ((j:ℝ)/((j:ℝ)+(n:ℝ))) = + (X (j+n) i:ℝ)/(j+n:ℕ) + rw [Nat.add_comm j n] + simp only [Nat.cast_add] + field_simp + ring + +lemma conditioned_to_annealed_velocity {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (v : Vector d) + (hv : ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ VelocityPaths v) : HasVelocity ν v := by + let B := NoDrop ℓ 0 ∩ (VelocityPaths v)ᶜ + have hB : MeasurableSet B := (measurableSet_noDrop ℓ 0).inter (measurableSet_velocityPaths v).compl + have hBD : B ⊆ NoDrop ℓ 0 := Set.inter_subset_left + have hcB : conditionedLaw ν ℓ B=0 := measure_mono_null Set.inter_subset_right (ae_iff.mp hv) + have haB : annealedLaw ν B=0 := by + rw [conditionedLaw_apply_of_subset ν ℓ B hB hBD] at hcB + exact (mul_eq_zero.mp hcB).resolve_left (ENNReal.inv_ne_zero.mpr (measure_ne_top _ _)) + have hwords : ∀ᵐ X ∂annealedLaw ν, ∀ w : List (Direction d), + (∀ y ∈ wordDepartures 0 w, dot (realPosition y) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ) → + X ∈ wordCylinder 0 w → + (fun j => X (w.length+j)-wordPath 0 w w.length) ∉ B := by + apply ae_all_iff.mpr + intro w + by_cases hw : ∀ y ∈ wordDepartures 0 w, dot (realPosition y) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ + · have hz := annealed_record_suffix ν ℓ w hw B hB hBD + rw [haB,mul_zero] at hz + filter_upwards [measure_eq_zero_iff_ae_notMem.mp hz] with X hX _ hcy + exact fun hh => hX ⟨hh,hcy⟩ + · exact Eventually.of_forall fun _ h _ => (hw h).elim + filter_upwards [annealed_initial ν,annealed_nearest_neighbor ν, + annealed_trueRecords_unbounded ν ℓ htrans,hwords] with X h0 hNN hrec hwords + obtain ⟨n,_,hn⟩ := hrec 0 + obtain ⟨w,hw,hcy⟩ := exists_word_prefix X hNN n + rw [h0] at hcy + have hwend : wordPath 0 w w.length=X n := by rw [← hw]; exact (hcy _ le_rfl).symm + have hwrec : ∀ y ∈ wordDepartures 0 w, dot (realPosition y) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ := by + intro y hy + obtain ⟨j,hj,rfl⟩ := (wordDepartures_mem_iff 0 y w).mp hy + rw [← hcy j hj.le,hwend] + exact hn.1 j (by omega) + have hnot := hwords w hwrec hcy + have hD : (fun j => X (w.length+j)-wordPath 0 w w.length) ∈ NoDrop ℓ 0 := by + intro j + rw [hwend,hw,dot_realPosition_sub] + have hh := hn.2 j + simpa only [dot,realPosition,Pi.zero_apply,Int.cast_zero,zero_mul,Finset.sum_const_zero, + sub_nonneg] using hh + apply velocityPaths_of_suffix v X n + by_contra hh + apply hnot + refine ⟨hD,?_⟩ + change (fun j => X (w.length+j)-wordPath 0 w w.length) ∉ VelocityPaths v + rw [hwend,hw] + exact hh + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/DurationTail.lean b/lean/OAI/Probability/Ballisticity/Renewal/DurationTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..57c0f5ee69d1a30c3479356052540a918514c990 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/DurationTail.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.StripTimeTail +import OAI.Probability.Ballisticity.Estimates.WidthGridTail +import OAI.Probability.Ballisticity.Estimates.RapidDecaySubsequence + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma firstWordEvent_of_length_pos {d : ℕ} (ℓ : Vector d) (X : Path d) + (hpos : 0 < (firstWord ℓ X).length) : X ∈ FirstWordEvent ℓ (firstWord ℓ X) := by + apply firstWordEvent_self + by_contra hh + simp only [firstWord,dite_eq_right hh,List.length_nil] at hpos + omega + +lemma duration_tail_cover {d : ℕ} (e : Direction d) (H T : ℕ) (hH : 0 < H) + (X : Path d) (hNN : ∀ n, ∃ f, X (n+1)=X n+step f) + (ht : X ∈ TransientPaths (realPosition (step e))) + (hτ : T < (firstWord (realPosition (step e)) X).length) : + X ∈ NoTruePastHeight e H ∪ StripUntil e H T := by + have hw := firstWordEvent_of_length_pos (realPosition (step e)) X (by omega) + have h0 : X 0=0 := by simpa using hw.2.1 0 (Nat.zero_le _) + obtain ⟨n,hn⟩ := noDrop_firstLayerHit_exists e X h0 hNN ht hH + by_cases hnT : n ≤ T + · exact Or.inl ⟨h0,n,hn,fun t ht htn => hw.2.2.2.2 t ht (by omega)⟩ + · apply Or.inr + refine ⟨h0,fun j hj => ⟨?_,hn.2 j (by omega)⟩⟩ + have hh := hw.1 j + simp only [signedHeight_projection,signedHeight_zero,Int.cast_zero] at hh + exact_mod_cast hh + +lemma raw_duration_tail_bound {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (H T : ℕ) (hH : 0 < H) : + (annealedLaw ν).real {X | T < (firstWord (realPosition (step e)) X).length} ≤ + (annealedLaw ν).real (NoTruePastHeight e H)+(annealedLaw ν).real (StripUntil e H T) := by + apply le_trans ?_ (measureReal_union_le _ _) + apply ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae ?_) + filter_upwards [annealed_nearest_neighbor ν,htrans] with X hNN ht + exact duration_tail_cover e H T hH X hNN ht + +lemma duration_polynomial_rapidDecay {d : ℕ} (hd : 2 ≤ d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℕ, 0 < A ∧ RapidDecay (fun N => + (conditionedLaw ν (realPosition (step e))).real + {X | A*(N+1)^(4*d+2) < (firstWord (realPosition (step e)) X).length}) := by + obtain ⟨A,hA,htime⟩ := stripTime_rapidDecay hd ν hue e htrans + have ht := htime.comp_strictMono (fun _ => measureReal_nonneg) _ square_pred_strictMono + have ht' : RapidDecay (fun N => (annealedLaw ν).real + (StripUntil e ((N+1)^2) (A*(N+1)^(4*d+2)))) := by + convert ht using 1 + ext N + have hsq : 1 ≤ (N+1)^2 := Nat.one_le_pow _ _ (by omega) + rw [Nat.sub_add_cancel hsq,← pow_mul,show 2*(2*d+1)=4*d+2 by omega] + have hw := noTruePastSquare_rapidDecay hd ν hue e htrans + have hraw : RapidDecay (fun N => (annealedLaw ν).real + {X | A*(N+1)^(4*d+2) < (firstWord (realPosition (step e)) X).length}) := by + apply (hw.add ht').of_le (fun _ => measureReal_nonneg) + exact Eventually.of_forall (fun N => raw_duration_tail_bound ν e htrans ((N+1)^2) _ (by positivity)) + have hp := noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans + have hp' : 0 < (annealedLaw ν).real (NoDrop (realPosition (step e)) 0) := + ENNReal.toReal_pos hp.ne' (measure_ne_top _ _) + refine ⟨A,hA,(hraw.const_mul (((annealedLaw ν).real (NoDrop (realPosition (step e)) 0))⁻¹)).of_le + (fun _ => measureReal_nonneg) ?_⟩ + apply Eventually.of_forall + intro N + have hh := annealed_ge_noDrop_mul_conditioned ν (realPosition (step e)) hp.ne' + {X | A*(N+1)^(4*d+2) < (firstWord (realPosition (step e)) X).length} + (measurableSet_lt measurable_const ((measurable_of_countable List.length).comp (measurable_firstWord _))) + exact (le_inv_mul_iff₀ hp').mpr hh + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/PositiveLengthMark.lean b/lean/OAI/Probability/Ballisticity/Renewal/PositiveLengthMark.lean new file mode 100644 index 0000000000000000000000000000000000000000..65b65b6dc59dea48c6e26809f7ab7e45ac0103d9 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/PositiveLengthMark.lean @@ -0,0 +1,106 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OperationalLengthMarks +import OAI.Probability.Ballisticity.Stationary.ArrayMarkTests +import OAI.Probability.Ballisticity.Stationary.BadArraySampling + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +noncomputable def lengthUnitTest {d : ℕ} (e : Direction d) : C(ActualEpisodeArray e,ℝ) := + (cutENNReal 1).comp ⟨fun Y => ((Y.1 0).1).toENNReal, + ENat.continuous_toENNReal.comp (by fun_prop)⟩ + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma raw_lengthUnit (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (Q : Measure (Environment d)) [IsFiniteMeasure Q] : + (∫ Y, lengthUnitTest e Y ∂actualOccupationRaw e ν Q + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) N (C.activeCount hef N)) = + (actualOccupationRaw e ν Q (C.paddedTimes hef N) (C.paddedStages hef N) + (C.paddedTimes_measurable hef N) N (C.activeCount hef N)).real Set.univ := by + let T := episodeBoundary (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N + have hm (i : ℕ) : Measurable (fun ω => (min (T ω (i+1)-T ω i) 1:ℕ)) := + ((episodeBoundary_measurable (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N (i+1)).sub + (episodeBoundary_measurable (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N i)).min measurable_const + rw [actualOccupationRaw_env_test e ν Q _ _ _ (C.paddedStages_measurable hef N) N _ + (C.activeCount_measurable hef N) (lengthUnitTest e) + (fun i ω => (min (T ω (i+1)-T ω i) 1:ℕ)) + (fun i => (measurable_of_countable (fun n:ℕ => (n:ℝ))).comp (hm i)) + (fun i X => by + change (min (((StationaryCompact.shift^[i] (actualArrayMap e (C.paddedTimes hef N) + (C.paddedStages hef N) X)).1 0).1).toENNReal (1:ℝ≥0∞)).toReal = _ + rw [C.actual_lengthMark] + change (min ((T X.1.1 (i+1)-T X.1.1 i:ℕ):ℝ≥0∞) 1).toReal = _ + generalize T X.1.1 (i+1)-T X.1.1 i = n + simp only [ENNReal.toReal_min (ENNReal.natCast_ne_top _) ENNReal.one_ne_top, + ENNReal.toReal_natCast,ENNReal.toReal_one,Nat.cast_min,Nat.cast_one]), + actualOccupationRaw_mass e ν Q _ _ _ (C.paddedStages_measurable hef N) N _ (C.activeCount_measurable hef N)] + apply Finset.sum_congr rfl + intro i _ + calc + (∫ ω in {ω | i C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) : + ∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), 0<(Y.1 0).1 := by + have he (n : ℕ) : (∫ Y, lengthUnitTest e Y ∂(C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)]):Measure (ActualEpisodeArray e)))=1 := by + change (∫ Y, lengthUnitTest e Y ∂(actualOccupation e ν _ _ _ _ _ _:Measure _))=1 + rw [actualOccupation_integral e ν _ _ _ _ _ _ (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n)),C.raw_lengthUnit] + exact inv_mul_cancel₀ (ne_of_gt (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n))) + have hconv := (ProbabilityMeasure.continuous_integral_continuousMap (lengthUnitTest e)).continuousAt.tendsto.comp hlim + have hl : Tendsto (fun n => ∫ Y, lengthUnitTest e Y ∂(C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)]):Measure (ActualEpisodeArray e))) atTop (𝓝 (1:ℝ)) := by + simp_rw [he] + exact tendsto_const_nhds + have hi : (∫ Y, lengthUnitTest e Y ∂(ρ:Measure (ActualEpisodeArray e)))=1 := + tendsto_nhds_unique hconv hl + have hz : (∫ Y, 1-lengthUnitTest e Y ∂(ρ:Measure (ActualEpisodeArray e)))=0 := by + rw [integral_sub (integrable_const _) + ((lengthUnitTest e).continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)), + integral_const,probReal_univ,one_smul,hi,sub_self] + have hnon (Y : ActualEpisodeArray e) : 0≤1-lengthUnitTest e Y := by + exact sub_nonneg.mpr (cutENNReal_le 1 _) + have hae := (integral_eq_zero_iff_of_nonneg hnon + ((1-lengthUnitTest e).continuous.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _))).mp hz + filter_upwards [hae] with Y hY + by_contra hh + have hh : (Y.1 0).1=0 := le_antisymm (le_of_not_gt hh) bot_le + have htest : lengthUnitTest e Y=0 := by simp [lengthUnitTest,cutENNReal,hh] + rw [htest] at hY + norm_num at hY + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/PositiveOpenTest.lean b/lean/OAI/Probability/Ballisticity/Renewal/PositiveOpenTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..505269bcaa7254c6e793cabe83eba8baaa0cec6e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/PositiveOpenTest.lean @@ -0,0 +1,48 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma positive_bounded_test_of_open {E : Type*} [MetricSpace E] [MeasurableSpace E] [BorelSpace E] + (μ : Measure E) [IsFiniteMeasure μ] (O : Set E) (hO : IsOpen O) + (hc : Oᶜ.Nonempty) (hpos : 0 < μ O) : + ∃ F : E →ᵇ ℝ, (∀ x, 0 ≤ F x ∧ F x ≤ 1) ∧ + (∀ x, F x ≠ 0 → x ∈ O) ∧ 0 < ∫ x, F x ∂μ := by + let f : E → ℝ := fun x => min 1 (Metric.infDist x Oᶜ) + have hf : Continuous f := continuous_const.min (Metric.continuous_infDist_pt Oᶜ) + have hb (x : E) : 0 ≤ f x ∧ f x ≤ 1 := + ⟨le_min (by norm_num) Metric.infDist_nonneg, min_le_left _ _⟩ + let F : E →ᵇ ℝ := BoundedContinuousFunction.mkOfBound ⟨f,hf⟩ 1 (fun x y => by + change |f x-f y| ≤ 1 + rw [abs_le] + constructor <;> linarith [(hb x).1,(hb x).2,(hb y).1,(hb y).2]) + have hs : Function.support F = O := by + ext x + change f x ≠ 0 ↔ x ∈ O + have he : 0 < Metric.infDist x Oᶜ ↔ x ∈ O := by + simpa only [Set.notMem_compl_iff] using (hO.isClosed_compl.notMem_iff_infDist_pos hc).symm + rw [← (hb x).1.lt_iff_ne'] + exact (lt_min_iff.trans (and_iff_right (by norm_num))).trans he + refine ⟨F,hb,?_,?_⟩ + · intro x hx + exact hs ▸ hx + · apply (integral_pos_iff_support_of_nonneg (fun x => (hb x).1) + (BoundedContinuousFunction.integrable μ F)).mpr + change 0 < μ (Function.support F) + rwa [hs] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/PositiveQuenchedEvent.lean b/lean/OAI/Probability/Ballisticity/Renewal/PositiveQuenchedEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..572d23d0467310e04568aaa2f8fe76d9f69027d3 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/PositiveQuenchedEvent.lean @@ -0,0 +1,52 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma integral_lower_test_le_event {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F : Ω → ℝ) (hF : Measurable F) + (hFb : ∀ x, 0 ≤ F x ∧ F x ≤ 1) (A : Set Ω) (hA : MeasurableSet A) + (hs : ∀ x, F x ≠ 0 → x ∈ A) : (∫ x, F x ∂μ) ≤ μ.real A := by + rw [← integral_indicator_one hA] + apply integral_mono_ae + · exact Integrable.of_bound hF.aestronglyMeasurable 1 + (ae_of_all _ (fun x => by simpa [Real.norm_eq_abs,abs_of_nonneg (hFb x).1] using (hFb x).2)) + · exact (integrable_const (1:ℝ)).indicator hA + · exact ae_of_all _ (fun x => by + by_cases hx : x ∈ A + · simpa [hx] using (hFb x).2 + · have hz : F x=0 := by contrapose! hx; exact hs x hx + simp [hx,hz]) + +lemma event_lower_mass_of_test_concentration {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (M p : ℕ → Ω → ℝ) (b : ℝ) (hb : 0 < b) + (hlim : TendstoInMeasure μ M atTop (fun _ => b)) + (hbound : ∀ᶠ i in atTop, ∀ᵐ x ∂μ, M i x ≤ p i x) : + Tendsto (fun i => μ.real {x | p i x < b/2}) atTop (𝓝 0) := by + have hh := (tendstoInMeasure_iff_measureReal_norm.mp hlim) (b/2) (half_pos hb) + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ hh + filter_upwards [hbound] with i hi + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [hi] with x hx + intro hp + change p i x < b/2 at hp + change b/2 ≤ ‖M i x-b‖ + rw [Real.norm_eq_abs,abs_of_nonpos (by linarith : M i x-b ≤ 0)] + linarith + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/Regeneration.lean b/lean/OAI/Probability/Ballisticity/Renewal/Regeneration.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdadd0491e0fbc853f2f73772ffead549f7c0207 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/Regeneration.lean @@ -0,0 +1,447 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.SignedCoordinate + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +def RegenerationSupport {d : ℕ} (ℓ : Vector d) : Set (Path d) := + {X | X 0 = 0 ∧ ∀ n, ((renewSuffix ℓ)^[n] X) ∈ + FirstWordEvent ℓ (regenerationWords ℓ X n)} + +lemma measurableSet_regenerationSupport {d : ℕ} (ℓ : Vector d) : + MeasurableSet (RegenerationSupport ℓ) := by + have hm (n : ℕ) : MeasurableSet {X : Path d | ((renewSuffix ℓ)^[n] X) ∈ + FirstWordEvent ℓ (regenerationWords ℓ X n)} := by + have he : {X : Path d | ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)} = + ⋃ w : List (Direction d), {X | regenerationWords ℓ X n = w} ∩ + ((renewSuffix ℓ)^[n]) ⁻¹' FirstWordEvent ℓ w := by + ext X + simp only [Set.mem_ofPred_eq, Set.mem_iUnion, Set.mem_inter_iff, Set.mem_preimage] + exact ⟨fun h => ⟨_,rfl,h⟩,fun ⟨w,hw,h⟩ => hw ▸ h⟩ + rw [he] + exact MeasurableSet.iUnion fun w => + ((measurable_regenerationWord ℓ n) (measurableSet_singleton w)).inter + ((measurableSet_firstWordEvent ℓ w).preimage ((measurable_renewSuffix ℓ).iterate n)) + unfold RegenerationSupport + rw [Set.ofPred_and, Set.ofPred_forall] + exact (measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter + (MeasurableSet.iInter hm) + +lemma conditioned_regenerationSupport {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ RegenerationSupport ℓ := by + filter_upwards [(conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_initial ν), + conditioned_all_firstWords ν ℓ htrans] with X h0 hX + exact ⟨h0,hX⟩ + +lemma regenerationSupport_noDrop {d : ℕ} (ℓ : Vector d) : RegenerationSupport ℓ ⊆ NoDrop ℓ 0 := + fun _ h => (h.2 0).1 + +lemma template_span_estimates {d : ℕ} (ℓ : Vector d) (c C C0 a : ℝ) (K : ℕ) (X : Path d) + (hX : X ∈ RegenerationSupport ℓ) (ht : X ∈ WordTemplate ℓ c C C0 a K) + {k j : ℕ} (hk : k < K) (hj : j ≤ (regenerationWords ℓ X k).length) : + c*k-C0 ≤ dot (realPosition (X (regenerationTimes ℓ X k+j))) ℓ ∧ + dot (realPosition (X (regenerationTimes ℓ X k+j))) ℓ ≤ C*(k+1)+C0 ∧ + ‖latticeVector (X (regenerationTimes ℓ X k+j))‖ ≤ a*(k+1) := by + obtain ⟨⟨hlo,hhi⟩,hR⟩ := regeneration_span_bounds ℓ X hX.1 hX.2 k j hj + rw [regeneration_height_sum ℓ X hX.1 hX.2 k] at hlo + rw [regeneration_height_sum ℓ X hX.1 hX.2 (k+1)] at hhi + rw [← Finset.sum_range_succ] at hR + refine ⟨(ht k hk.le).1.trans hlo,?_,?_⟩ + · exact hhi.trans (by simpa only [Nat.cast_add, Nat.cast_one] using (ht (k+1) hk).2.1) + · exact hR.trans (by simpa only [Nat.cast_add, Nat.cast_one] using (ht (k+1) hk).2.2) + +lemma signedCoordinate_nsmul {d : ℕ} (u : Direction d) (x : Lattice d) (n : ℕ) : + signedCoordinate u (n • x) = n * signedCoordinate u x := by + induction n with + | zero => simp [signedCoordinate] + | succ n ih => rw [succ_nsmul, signedCoordinate_add, ih, Nat.cast_add, Nat.cast_one]; ring + +lemma tiltedCoordinate_nsmul {d : ℕ} (ℓ : Vector d) (u : Direction d) (b a : ℝ) + (x : Lattice d) (n : ℕ) : + tiltedCoordinate ℓ u b a (n • x) = n * tiltedCoordinate ℓ u b a x := by + rw [tiltedCoordinate, signedCoordinate_nsmul, dot_realPosition_nsmul, tiltedCoordinate] + ring + +lemma template_tilted_lower {d : ℕ} (ℓ : Vector d) (u e : Direction d) + (c C C0 a b : ℝ) (hb : 0 ≤ b) (ha : 0 ≤ a) (K M : ℕ) (X : Path d) + (hX : X ∈ RegenerationSupport ℓ) (ht : X ∈ WordTemplate ℓ c C C0 a K) + {k j : ℕ} (hk : k < K) (hj : j ≤ (regenerationWords ℓ X k).length) : + a*((b*c-1)*k + (b*((M : ℝ)*dot (realPosition (step e)) ℓ)-b*C0-1)) - M ≤ + tiltedCoordinate ℓ u b a (M • step e + X (regenerationTimes ℓ X k+j)) := by + obtain ⟨hlo,_,hR⟩ := template_span_estimates ℓ c C C0 a K X hX ht hk hj + have hcoord : -a*(k+1) ≤ signedCoordinate u (X (regenerationTimes ℓ X k+j)) := + by + have habs := signedCoordinate_abs_le_norm u (X (regenerationTimes ℓ X k+j)) + have hneg := neg_abs_le (signedCoordinate u (X (regenerationTimes ℓ X k+j))) + linarith + have hscript : -(1 : ℝ) ≤ signedCoordinate u (step e) := by + have hh := signedCoordinate_abs_le_norm u (step e) + rw [latticeVector_step_norm] at hh + exact (neg_le_neg hh).trans (neg_abs_le _) + have hM := mul_le_mul_of_nonneg_left hscript (Nat.cast_nonneg M : (0 : ℝ) ≤ M) + have hh := mul_le_mul_of_nonneg_left hlo (mul_nonneg hb ha) + rw [tiltedCoordinate_add, tiltedCoordinate_nsmul] + dsimp only [tiltedCoordinate] + nlinarith + +lemma wordPath_replicate_prefix {d : ℕ} (x : Lattice d) (e : Direction d) (M j : ℕ) + (hj : j ≤ M) : wordPath x (List.replicate M e) j = x + j • step e := by + induction M generalizing x j with + | zero => + have : j = 0 := by omega + subst j + simp + | succ M ih => + cases j with + | zero => simp + | succ j => + simp only [List.replicate_succ, wordPath] + rw [ih (x+step e) j (by omega), succ_nsmul] + abel + +def ForwardTemplate {d : ℕ} (ℓ : Vector d) (e : Direction d) (c C C0 a : ℝ) + (K M : ℕ) : Set (Path d) := + ((fun X : Path d => fun j => X (M+j) - M • step e) ⁻¹' + (RegenerationSupport ℓ ∩ WordTemplate ℓ c C C0 a K)) ∩ + wordCylinder 0 (List.replicate M e) + +lemma measurableSet_forwardTemplate {d : ℕ} (ℓ : Vector d) (e : Direction d) + (c C C0 a : ℝ) (K M : ℕ) : MeasurableSet (ForwardTemplate ℓ e c C C0 a K M) := + (((measurableSet_regenerationSupport ℓ).inter + (measurableSet_wordTemplate ℓ c C C0 a K)).preimage (by fun_prop)).inter + (measurableSet_wordCylinder 0 (List.replicate M e)) + +lemma forwardTemplate_script {d : ℕ} (ℓ : Vector d) (e : Direction d) + (c C C0 a : ℝ) (K M : ℕ) {X : Path d} + (hX : X ∈ ForwardTemplate ℓ e c C C0 a K M) {j : ℕ} (hj : j ≤ M) : + X j = j • step e := by + have hh := hX.2 j (by simpa only [List.length_replicate] using hj) + rw [wordPath_replicate_prefix _ _ _ _ hj, zero_add] at hh + exact hh + +lemma forwardTemplate_noDrop {d : ℕ} (ℓ : Vector d) (e : Direction d) + (c C C0 a : ℝ) (K M : ℕ) (he : 0 ≤ dot (realPosition (step e)) ℓ) : + ForwardTemplate ℓ e c C C0 a K M ⊆ NoDrop ℓ 0 := by + intro X hX j + have hz : dot (realPosition (0 : Lattice d)) ℓ = 0 := by simp [dot, realPosition] + rw [hz] + by_cases hj : j ≤ M + · rw [forwardTemplate_script ℓ e c C C0 a K M hX hj, dot_realPosition_nsmul] + exact mul_nonneg (Nat.cast_nonneg _) he + · have hs := regenerationSupport_noDrop ℓ hX.1.1 (j-M) + change dot (realPosition 0) ℓ ≤ dot (realPosition (X (M+(j-M))-M • step e)) ℓ at hs + rw [Nat.add_sub_of_le (by omega), dot_realPosition_sub, dot_realPosition_nsmul, hz] at hs + exact (mul_nonneg (Nat.cast_nonneg M) he).trans (sub_nonneg.mp hs) + +lemma forwardTemplate_control {d : ℕ} (ℓ : Vector d) (u e : Direction d) + (c C C0 a b D H : ℝ) (K M : ℕ) + (ha : 1 ≤ a) (hb : 0 ≤ b) (he : 0 ≤ dot (realPosition (step e)) ℓ) + (hbc : 1 ≤ b*c) (hM : 0 ≤ (M : ℝ)*dot (realPosition (step e)) ℓ-C0) + (hconst : (M : ℝ) ≤ a*(b*((M : ℝ)*dot (realPosition (step e)) ℓ)-b*C0-1)) + (hstep : 0 ≤ tiltedCoordinate ℓ u b a (step e)) + (hD : (M : ℝ)+1 ≤ D) (hDc : 1 ≤ D*c) + (hH : H < (M : ℝ)*dot (realPosition (step e)) ℓ+c*K-C0) + {X : Path d} (hX : X ∈ ForwardTemplate ℓ e c C C0 a K M) (n : ℕ) : + 0 ≤ dot (realPosition (X n)) ℓ ∧ + ((0 ≤ tiltedCoordinate ℓ u b a (X n) ∧ + signedCoordinate u (X n) ≤ a*D*(1+dot (realPosition (X n)) ℓ)) ∨ + H < dot (realPosition (X n)) ℓ) := by + have ha0 : 0 ≤ a := by linarith + have hD0 : 0 ≤ D := by linarith [Nat.cast_nonneg M (α := ℝ)] + have hnonneg : 0 ≤ dot (realPosition (X n)) ℓ := by + simpa [dot, realPosition] using + forwardTemplate_noDrop ℓ e c C C0 a K M he hX n + refine ⟨hnonneg,?_⟩ + by_cases hn : n < M + · left + rw [forwardTemplate_script ℓ e c C C0 a K M hX hn.le, tiltedCoordinate_nsmul, + signedCoordinate_nsmul] + refine ⟨mul_nonneg (Nat.cast_nonneg n) hstep,?_⟩ + have hcoord : signedCoordinate u (step e) ≤ 1 := by + have hh := signedCoordinate_abs_le_norm u (step e) + rw [latticeVector_step_norm] at hh + exact (le_abs_self _).trans hh + have hnM : (n : ℝ) ≤ M := by exact_mod_cast hn.le + have hu := mul_le_mul_of_nonneg_left hcoord (Nat.cast_nonneg n : (0 : ℝ) ≤ n) + have hbase : (M : ℝ) ≤ a*D := by nlinarith [Nat.cast_nonneg M (α := ℝ)] + have hg := mul_nonneg (mul_nonneg ha0 hD0) hnonneg + have hx := forwardTemplate_script ℓ e c C C0 a K M hX hn.le + rw [hx] at hnonneg hg + nlinarith + · let Y : Path d := fun j => X (M+j)-M • step e + have hY : Y ∈ RegenerationSupport ℓ := hX.1.1 + have ht : Y ∈ WordTemplate ℓ c C C0 a K := hX.1.2 + have hx (j : ℕ) : X (M+j) = M • step e + Y j := by dsimp only [Y]; abel + have hnM : M ≤ n := by omega + have hnm : M+(n-M) = n := Nat.add_sub_of_le hnM + by_cases hcut : n-M < regenerationTimes ℓ Y K + · obtain ⟨k,hk,hk'⟩ := increasing_cuts_cover (regenerationTimes ℓ Y) + (regenerationTimes_strictMono ℓ Y hY.2) (regenerationTimes_zero ℓ Y) (n-M) + have hkK : k < K := (regenerationTimes_strictMono ℓ Y hY.2).lt_iff_lt.mp (hk.trans_lt hcut) + have hj : n-M-regenerationTimes ℓ Y k ≤ (regenerationWords ℓ Y k).length := by + rw [regenerationTimes_succ] at hk' + omega + have heq : regenerationTimes ℓ Y k+(n-M-regenerationTimes ℓ Y k) = n-M := + Nat.add_sub_of_le hk + have hlow := template_tilted_lower ℓ u e c C C0 a b hb ha0 K M Y hY ht hkK hj + rw [heq] at hlow + obtain ⟨hh,_,hr⟩ := template_span_estimates ℓ c C C0 a K Y hY ht hkK hj + rw [heq] at hh hr + left + rw [← hnm, hx] + refine ⟨?_,?_⟩ + · have hprod : 0 ≤ a*((b*c-1)*k) := mul_nonneg ha0 (mul_nonneg (by linarith) (Nat.cast_nonneg k)) + nlinarith + · have hcoord : signedCoordinate u (M • step e + Y (n-M)) ≤ M+a*(k+1) := by + rw [signedCoordinate_add, signedCoordinate_nsmul] + have hu := (le_abs_self (signedCoordinate u (step e))).trans (signedCoordinate_abs_le_norm u (step e)) + rw [latticeVector_step_norm] at hu + have hv := (le_abs_self (signedCoordinate u (Y (n-M)))).trans (signedCoordinate_abs_le_norm u (Y (n-M))) + have hmul := mul_le_mul_of_nonneg_left hu (Nat.cast_nonneg M : (0 : ℝ) ≤ M) + linarith + have hheight : (M : ℝ)*dot (realPosition (step e)) ℓ+c*k-C0 ≤ + dot (realPosition (M • step e + Y (n-M))) ℓ := by + rw [dot_realPosition_add, dot_realPosition_nsmul] + linarith + have hscaled := mul_le_mul_of_nonneg_left hheight (mul_nonneg ha0 hD0) + have hDk := mul_le_mul_of_nonneg_right hDc (Nat.cast_nonneg k : (0 : ℝ) ≤ k) + have hDM := mul_nonneg hD0 hM + have hbase : (M : ℝ) ≤ a*(D-1) := by nlinarith [Nat.cast_nonneg M (α := ℝ)] + have hka := mul_le_mul_of_nonneg_left hDk ha0 + have hMa := mul_nonneg ha0 hDM + nlinarith + · right + have hh := (regenerationTimes_true ℓ Y hY.1 hY.2 K).2 (n-M-regenerationTimes ℓ Y K) + change dot (realPosition (Y (regenerationTimes ℓ Y K))) ℓ ≤ + dot (realPosition (Y (regenerationTimes ℓ Y K+(n-M-regenerationTimes ℓ Y K)))) ℓ at hh + rw [Nat.add_sub_of_le (le_of_not_gt hcut)] at hh + have hlo := (ht K le_rfl).1 + rw [← regeneration_height_sum ℓ Y hY.1 hY.2 K] at hlo + rw [← hnm, hx, dot_realPosition_add, dot_realPosition_nsmul] + linarith + +lemma annealed_wordCylinder_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (κ : ℝ≥0) (hκ : ∀ᵐ ω ∂environmentLaw ν, ∀ x e, κ ≤ (ω x).1 e) + (w : List (Direction d)) : (κ : ℝ≥0∞)^w.length ≤ annealedLaw ν (wordCylinder 0 w) := by + rw [annealed_wordCylinder] + have hconst : (κ : ℝ≥0∞)^w.length = ∫⁻ _ : Environment d, (κ : ℝ≥0∞)^w.length + ∂environmentLaw ν := by simp + rw [hconst] + apply lintegral_mono_ae + filter_upwards [hκ] with ω hω + have hh := ENNReal.ofReal_le_ofReal (wordWeight_lower ω hω 0 w) + simpa only [ENNReal.ofReal_pow κ.coe_nonneg, ENNReal.ofReal_coe_nnreal] using hh + +lemma annealed_eq_noDrop_mul_conditioned {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) + (A : Set (Path d)) (hA : MeasurableSet A) (hAD : A ⊆ NoDrop ℓ 0) : + annealedLaw ν A = annealedLaw ν (NoDrop ℓ 0) * conditionedLaw ν ℓ A := by + rw [conditionedLaw_apply_of_subset ν ℓ A hA hAD, ← mul_assoc, + ENNReal.mul_inv_cancel hp (measure_ne_top _ _), one_mul] + +lemma forwardTemplate_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (e : Direction d) + (he : 0 < dot (realPosition (step e)) ℓ) (c C C0 a : ℝ) (K M : ℕ) : + annealedLaw ν (ForwardTemplate ℓ e c C C0 a K M) = + annealedLaw ν (wordCylinder 0 (List.replicate M e)) * + annealedLaw ν (NoDrop ℓ 0) * conditionedLaw ν ℓ (WordTemplate ℓ c C C0 a K) := by + let A := RegenerationSupport ℓ ∩ WordTemplate ℓ c C C0 a K + have hA : MeasurableSet A := (measurableSet_regenerationSupport ℓ).inter + (measurableSet_wordTemplate ℓ c C C0 a K) + have hAD : A ⊆ NoDrop ℓ 0 := fun _ h => regenerationSupport_noDrop ℓ h.1 + have hrecord : ∀ y ∈ wordDepartures 0 (List.replicate M e), + dot (realPosition y) ℓ < dot (realPosition (wordPath 0 (List.replicate M e) (List.replicate M e).length)) ℓ := by + intro y hy + obtain ⟨j,hj,rfl⟩ := (wordDepartures_mem_iff 0 y (List.replicate M e)).mp hy + simp only [List.length_replicate] at hj ⊢ + rw [wordPath_replicate_prefix _ _ _ _ hj.le, wordPath_replicate, + zero_add, zero_add, dot_realPosition_nsmul, dot_realPosition_nsmul] + exact mul_lt_mul_of_pos_right (by exact_mod_cast hj) he + have hf := annealed_record_suffix ν ℓ (List.replicate M e) hrecord A hA hAD + simp only [List.length_replicate, wordPath_replicate, zero_add] at hf + change annealedLaw ν (ForwardTemplate ℓ e c C C0 a K M) = + annealedLaw ν (wordCylinder 0 (List.replicate M e)) * annealedLaw ν A at hf + rw [hf, annealed_eq_noDrop_mul_conditioned ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) A hA hAD, ← mul_assoc] + congr 1 + apply measure_congr + filter_upwards [conditioned_regenerationSupport ν ℓ htrans] with X hX + apply propext + change (X ∈ RegenerationSupport ℓ ∧ X ∈ WordTemplate ℓ c C C0 a K) ↔ X ∈ WordTemplate ℓ c C C0 a K + simp only [hX,true_and] + +lemma tilted_height_avoids_prefix {d : ℕ} (ℓ : Vector d) (u : Direction d) + (b a H : ℝ) (f Z : Path d) (n : ℕ) + (hrecord : ∀ j < n, tiltedCoordinate ℓ u b a (f j) < tiltedCoordinate ℓ u b a (f n)) + (hf : f ∈ BoundedHeightPrefix ℓ H n) + (hZ : ∀ k, 0 ≤ tiltedCoordinate ℓ u b a (Z k) ∨ H < dot (realPosition (Z k)) ℓ) : + ∀ k j, j < n → f n+Z k ≠ f j := by + intro k j hj heq + rcases hZ k with htilt | hheight + · have h := hrecord j hj + rw [← heq, tiltedCoordinate_add] at h + linarith + · have hlo := (hf n le_rfl).1 + have hhi := (hf j hj.le).2 + rw [← heq, dot_realPosition_add] at hhi + linarith + +lemma controlled_suffix_caps_ratio {d : ℕ} (ℓ : Vector d) (u : Direction d) + (hℓ : ∀ i, |ℓ i| ≤ 1) (b a D H t : ℝ) + (hb : 0 ≤ b) (ha : 1 ≤ a) (hD : 0 ≤ D) (ht : 0 < t) + (f X : Path d) (n : ℕ) (hf : f ∈ FirstRatioExceed ℓ u b a H t n) + (hX : X ∈ pathCylinder f n) + (hcontrol : ∀ k, (signedCoordinate u (X (n+k)-f n) ≤ + a*D*(1+dot (realPosition (X (n+k)-f n)) ℓ)) ∨ + H < dot (realPosition (X (n+k)-f n)) ℓ) : + X ∉ RatioHit ℓ u b a H (t+(2*b+1+D)) := by + intro hhit + obtain ⟨k,hk⟩ := Set.mem_iUnion.mp hhit + have ha0 : 0 < a := by linarith + have hscale : 0 ≤ a*D := mul_nonneg ha0.le hD + by_cases hkn : k < n + · have he := heightRatio_congr ℓ u b a k (fun j hj => hX j (by omega)) + have hlo := hf.2 k hkn + have hkbound : t+(2*b+1+D) < heightRatio ℓ u b a X k := hk.2 + rw [he] at hkbound + linarith [show 0 ≤ 2*b+1+D by linarith] + · have hnk : n ≤ k := by omega + have hkm : n+(k-n) = k := Nat.add_sub_of_le hnk + have hz := hcontrol (k-n) + rw [hkm, dot_realPosition_sub] at hz + have hlaunch := (hf.1.1.2 n le_rfl).1 + have htop := (hk.1.2 k le_rfl).2 + rcases hz with hcoord | hhigh + · have hs : signedCoordinate u (X k) = signedCoordinate u (f n) + + signedCoordinate u (X k-f n) := by + rw [← signedCoordinate_add] + congr 1 + abel + have hratio := firstRatioExceed_overshoot ℓ u hℓ b a H t hb ha ht f n hf + have denom (j : ℕ) : 0 < a*(1+runningHeight ℓ X j) := + mul_pos ha0 (by linarith [runningHeight_nonneg ℓ X j]) + have hne : runningHeight ℓ f n = runningHeight ℓ X n := + runningHeight_congr ℓ n (fun j hj => (hX j hj).symm) + have hm := runningHeight_mono ℓ X hnk + have hheight := height_le_runningHeight ℓ X (show k ≤ k from le_rfl) + have hprev : signedCoordinate u (f n) ≤ (t+b+1)*(a*(1+runningHeight ℓ X n)) := by + have hfden : 0 < a*(1+runningHeight ℓ f n) := by rw [hne]; exact denom n + have hh := (div_le_iff₀ hfden).mp hratio + dsimp only [heightRatio, tiltedCoordinate] at hh + rw [hne] at hh + have hpos := mul_nonneg (mul_nonneg hb ha0.le) hlaunch + linarith + have hlaunchscale := mul_le_mul_of_nonneg_left hm + (show 0 ≤ (t+b+1)*a by positivity) + have hrelscale := mul_le_mul_of_nonneg_left (show 1+dot (realPosition (X k)) ℓ - + dot (realPosition (f n)) ℓ ≤ 1+runningHeight ℓ X k by linarith) hscale + have hheightscale := mul_le_mul_of_nonneg_left hheight (mul_nonneg hb ha0.le) + have hbound : heightRatio ℓ u b a X k ≤ t+(2*b+1+D) := by + apply (div_le_iff₀ (denom k)).mpr + dsimp only [tiltedCoordinate] + nlinarith + exact (not_le_of_gt hk.2) hbound + · linarith + +lemma prefix_favourable_gain {d : ℕ} (μ : Measure (Path d)) + (E B : Set (Path d)) (n : ℕ) (p : ℝ≥0∞) + (hE : PrefixDetermined n E) + (hfav : ∀ f ∈ E, ∃ A : Set (Path d), MeasurableSet A ∧ A ⊆ pathCylinder f n ∧ + Disjoint B A ∧ μ A = μ (pathCylinder f n)*p) : + μ (B∩E)+μ E*p ≤ μ E := by + classical + rw [measure_partition_prefix μ (B∩E) n, measure_partition_prefix μ E n, + ← ENNReal.tsum_mul_right, ← ENNReal.tsum_add] + apply ENNReal.tsum_le_tsum + intro f + let g := extendPrefix n f + by_cases hg : g ∈ E + · obtain ⟨A,hA,hAC,hBA,hm⟩ := hfav g hg + have hc : E ∩ pathCylinder g n = pathCylinder g n := by + rw [prefixDetermined_inter_cylinder E n hE g, ite_eq_left hg] + have he : (B∩E)∩pathCylinder g n = B∩pathCylinder g n := by rw [Set.inter_assoc, hc] + change μ ((B∩E)∩pathCylinder g n)+μ (E∩pathCylinder g n)*p ≤ μ (E∩pathCylinder g n) + rw [he,hc,← hm] + have hd : Disjoint (B∩pathCylinder g n) A := hBA.mono_left Set.inter_subset_left + rw [← measure_union hd hA] + exact measure_mono (Set.union_subset Set.inter_subset_right hAC) + · have hc : E∩pathCylinder g n = ∅ := by + rw [prefixDetermined_inter_cylinder E n hE g, ite_eq_right hg] + have he : (B∩E)∩pathCylinder g n = ∅ := by rw [Set.inter_assoc,hc,Set.inter_empty] + change μ ((B∩E)∩pathCylinder g n)+μ (E∩pathCylinder g n)*p ≤ μ (E∩pathCylinder g n) + rw [he,hc,measure_empty,zero_mul,zero_add] + +lemma stopping_prefix_favourable_gain {d : ℕ} (μ : Measure (Path d)) + (E : ℕ → Set (Path d)) (B : Set (Path d)) (p : ℝ≥0∞) + (hE : ∀ n, PrefixDetermined n (E n)) (hm : ∀ n, MeasurableSet (E n)) + (hd : Pairwise (fun n m => Disjoint (E n) (E m))) (hB : MeasurableSet B) + (hsub : B ⊆ ⋃ n,E n) + (hfav : ∀ n f, f ∈ E n → ∃ A : Set (Path d), MeasurableSet A ∧ A ⊆ pathCylinder f n ∧ + Disjoint B A ∧ μ A = μ (pathCylinder f n)*p) : + μ B+μ (⋃ n,E n)*p ≤ μ (⋃ n,E n) := by + have hBu : B = ⋃ n,B∩E n := by + ext X + simp only [Set.mem_iUnion,Set.mem_inter_iff] + exact ⟨fun h => by obtain ⟨n,hn⟩ := Set.mem_iUnion.mp (hsub h); exact ⟨n,h,hn⟩, + fun ⟨_,h,_⟩ => h⟩ + have hdb : Pairwise (fun n m => Disjoint (B∩E n) (B∩E m)) := + fun n m hnm => (hd hnm).mono Set.inter_subset_right Set.inter_subset_right + rw [hBu,measure_iUnion hdb (fun n => hB.inter (hm n)), + measure_iUnion hd hm,← ENNReal.tsum_mul_right,← ENNReal.tsum_add] + exact ENNReal.tsum_le_tsum fun n => prefix_favourable_gain μ (E n) B n p (hE n) (hfav n) + +lemma ratio_threshold_contraction {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (u : Direction d) (hℓ : ∀ i, |ℓ i| ≤ 1) + (b a D H t : ℝ) (hb : 0 ≤ b) (ha : 1 ≤ a) (hD : 0 ≤ D) (ht : 0 < t) + (A : Set (Path d)) (hA : MeasurableSet A) + (hcontrol : ∀ Z ∈ A, ∀ k, (0 ≤ tiltedCoordinate ℓ u b a (Z k) ∧ + signedCoordinate u (Z k) ≤ a*D*(1+dot (realPosition (Z k)) ℓ)) ∨ + H < dot (realPosition (Z k)) ℓ) : + (annealedLaw ν).real (RatioHit ℓ u b a H (t+(2*b+1+D))) ≤ + (1-(annealedLaw ν).real A)*(annealedLaw ν).real (RatioHit ℓ u b a H t) := by + let μ := annealedLaw ν + let B := RatioHit ℓ u b a H (t+(2*b+1+D)) + have hsub : B ⊆ ⋃ n, FirstRatioExceed ℓ u b a H t n := by + rw [← ratioHit_eq_first] + exact ratioHit_antitone ℓ u b a H (by linarith) + have hg := stopping_prefix_favourable_gain μ (FirstRatioExceed ℓ u b a H t) B (μ A) + (prefixDetermined_firstRatioExceed ℓ u b a H t) + (measurableSet_firstRatioExceed ℓ u b a H t) + (firstRatioExceed_disjoint ℓ u b a H t) + (measurableSet_ratioHit ℓ u b a H _) hsub (by + intro n f hf + let F := (fun X : Path d => fun k => X (n+k)-f n) ⁻¹' A ∩ pathCylinder f n + have hF : MeasurableSet F := (hA.preimage (by fun_prop)).inter (measurableSet_pathCylinder f n) + obtain ⟨hn,hrecord⟩ := firstRatioExceed_record ℓ u b a H t (by linarith) ht f n hf + refine ⟨F,hF,Set.inter_subset_right,?_,?_⟩ + · apply Set.disjoint_left.mpr + intro X hB hF + apply controlled_suffix_caps_ratio ℓ u hℓ b a D H t hb ha hD ht f X n hf hF.2 + · intro k + rcases hcontrol _ hF.1 k with h | h + · exact Or.inl h.2 + · exact Or.inr h + · exact hB + · exact annealed_prefix_avoiding_suffix ν f n hn A hA + (fun j hj he => by have hh := hrecord j hj; rw [he] at hh; exact (lt_irrefl _) hh) + (fun Z hZ => tilted_height_avoids_prefix ℓ u b a H f Z n hrecord hf.1.1.2 + (fun k => (hcontrol Z hZ k).imp And.left id))) + rw [← ratioHit_eq_first] at hg + have hpne : μ (RatioHit ℓ u b a H t)*μ A ≠ ∞ := + ENNReal.mul_ne_top (measure_ne_top _ _) (measure_ne_top _ _) + have hr := ENNReal.toReal_mono (measure_ne_top _ _) hg + rw [ENNReal.toReal_add (measure_ne_top _ _) hpne,ENNReal.toReal_mul] at hr + change (μ B).toReal ≤ (1-(μ A).toReal)*(μ (RatioHit ℓ u b a H t)).toReal + nlinarith + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/RegenerationWords.lean b/lean/OAI/Probability/Ballisticity/Renewal/RegenerationWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b6cbc2e73f7f833b0c9df58b86a43a6029cd943 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/RegenerationWords.lean @@ -0,0 +1,436 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.FirstWordEvent + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma identDistrib_iterated_symbol {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] + (μ : Measure α) (F : α → β) (T : α → α) + (hF : Measurable F) (hT : MeasurePreserving T μ μ) (n : ℕ) : + IdentDistrib (fun x => F (T^[n] x)) F μ μ := by + refine ⟨(hF.comp (hT.iterate n).measurable).aemeasurable, hF.aemeasurable, ?_⟩ + change μ.map (F ∘ T^[n]) = μ.map F + rw [← Measure.map_map hF (hT.iterate n).measurable, (hT.iterate n).map_eq] + +noncomputable def regenerationWords {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : + List (Direction d) := firstWord ℓ ((renewSuffix ℓ)^[n] X) + +lemma measurable_regenerationWord {d : ℕ} (ℓ : Vector d) (n : ℕ) : + Measurable (fun X : Path d => regenerationWords ℓ X n) := + (measurable_firstWord ℓ).comp ((measurable_renewSuffix ℓ).iterate n) + +lemma regenerationWords_independent {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + iIndepFun (fun n X => regenerationWords ℓ X n) (conditionedLaw ν ℓ) := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + exact independent_iterated_symbols _ _ _ (measurable_firstWord ℓ) + (renewSuffix_preserves_conditioned ν ℓ htrans) (firstWord_indep_renewSuffix ν ℓ htrans) + +lemma regenerationWords_identDistrib {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (n : ℕ) : + IdentDistrib (fun X => regenerationWords ℓ X n) (firstWord ℓ) + (conditionedLaw ν ℓ) (conditionedLaw ν ℓ) := + identDistrib_iterated_symbol _ _ _ (measurable_firstWord ℓ) + (renewSuffix_preserves_conditioned ν ℓ htrans) n + +lemma firstWordEvent_self {d : ℕ} (ℓ : Vector d) (X : Path d) + (hX : ∃ w, X ∈ FirstWordEvent ℓ w) : X ∈ FirstWordEvent ℓ (firstWord ℓ X) := by + classical + simpa only [firstWord, dite_eq_left hX] using hX.choose_spec + +noncomputable def regenerationTimes {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : ℕ := + ∑ i ∈ Finset.range n, (regenerationWords ℓ X i).length + +@[simp] lemma regenerationTimes_zero {d : ℕ} (ℓ : Vector d) (X : Path d) : + regenerationTimes ℓ X 0 = 0 := by simp [regenerationTimes] + +lemma regenerationTimes_succ {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : + regenerationTimes ℓ X (n + 1) = regenerationTimes ℓ X n + + (regenerationWords ℓ X n).length := by simp [regenerationTimes, Finset.sum_range_succ] + +lemma measurable_regenerationTime {d : ℕ} (ℓ : Vector d) (n : ℕ) : + Measurable (fun X : Path d => regenerationTimes ℓ X n) := by + exact Finset.measurable_fun_sum _ fun i _ => + (measurable_of_countable List.length).comp (measurable_regenerationWord ℓ i) + +lemma iterate_renewSuffix_eq {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) (n j : ℕ) : + ((renewSuffix ℓ)^[n] X) j = X (regenerationTimes ℓ X n + j) - + X (regenerationTimes ℓ X n) := by + induction n generalizing j with + | zero => simp [h0] + | succ n ih => + rw [Function.iterate_succ_apply', renewSuffix, ih, ih, regenerationTimes_succ] + change X (regenerationTimes ℓ X n + ((regenerationWords ℓ X n).length + j)) - + X (regenerationTimes ℓ X n) - (X (regenerationTimes ℓ X n + + (regenerationWords ℓ X n).length) - X (regenerationTimes ℓ X n)) = _ + rw [Nat.add_assoc] + abel + +lemma strictRecord_suffix_iff {d : ℕ} (ℓ : Vector d) (X : Path d) {n j : ℕ} + (hn : StrictRecord ℓ X n) (hj : 0 < j) : + StrictRecord ℓ (fun k => X (n + k) - X n) j ↔ StrictRecord ℓ X (n + j) := by + simp only [StrictRecord, dot_realPosition_sub, sub_lt_sub_iff_right] + constructor + · intro h k hk + by_cases hkn : k < n + · exact (hn k hkn).trans (by simpa using h 0 hj) + · have hle : n ≤ k := by omega + simpa only [Nat.add_sub_of_le hle] using h (k - n) (by omega) + · intro h k hk + exact h (n + k) (by omega) + +lemma trueRecord_suffix_iff {d : ℕ} (ℓ : Vector d) (X : Path d) {n j : ℕ} + (hn : StrictRecord ℓ X n) (hj : 0 < j) : + TrueRecord ℓ (fun k => X (n + k) - X n) j ↔ TrueRecord ℓ X (n + j) := by + simp only [TrueRecord, strictRecord_suffix_iff ℓ X hn hj, FutureNoDrop, + Set.mem_ofPred_eq, dot_realPosition_sub, sub_le_sub_iff_right, Nat.add_assoc] + +lemma conditioned_all_firstWords {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ X ∂conditionedLaw ν ℓ, ∀ n, ((renewSuffix ℓ)^[n] X) ∈ + FirstWordEvent ℓ (regenerationWords ℓ X n) := by + apply ae_all_iff.mpr + intro n + have h := ((renewSuffix_preserves_conditioned ν ℓ htrans).iterate n).quasiMeasurePreserving.ae + (conditioned_firstWord_exists ν ℓ htrans) + filter_upwards [h] with X hX + exact firstWordEvent_self ℓ _ hX + +lemma regenerationTimes_strictMono {d : ℕ} (ℓ : Vector d) (X : Path d) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) : + StrictMono (regenerationTimes ℓ X) := by + apply strictMono_nat_of_lt_succ + intro n + rw [regenerationTimes_succ] + exact Nat.lt_add_of_pos_right (hX n).2.2.1 + +lemma regenerationTimes_true {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) : + ∀ n, TrueRecord ℓ X (regenerationTimes ℓ X n) := by + intro n + induction n with + | zero => + refine ⟨fun j hj => by simp at hj, ?_⟩ + have hD := (hX 0).1 + change X ∈ NoDrop ℓ 0 at hD + change ∀ j, dot (realPosition (X 0)) ℓ ≤ dot (realPosition (X (0 + j))) ℓ + simpa only [Nat.zero_add, h0, NoDrop, Set.mem_ofPred_eq] using hD + | succ n ih => + have ht := (hX n).2.2.2.1 + have hj := (hX n).2.2.1 + rw [show (renewSuffix ℓ)^[n] X = _ from funext (iterate_renewSuffix_eq ℓ X h0 n)] at ht + rw [regenerationTimes_succ] + exact (trueRecord_suffix_iff ℓ X ih.1 hj).mp ht + +lemma regenerationTimes_no_true_between {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) + (n j : ℕ) (hj : regenerationTimes ℓ X n < j) (hj' : j < regenerationTimes ℓ X (n+1)) : + ¬ TrueRecord ℓ X j := by + intro ht + have hn := regenerationTimes_true ℓ X h0 hX n + have hs := (trueRecord_suffix_iff ℓ X hn.1 (show 0 < j - regenerationTimes ℓ X n by omega)).mpr + (show TrueRecord ℓ X (regenerationTimes ℓ X n + (j - regenerationTimes ℓ X n)) by + simpa only [Nat.add_sub_of_le hj.le] using ht) + have he : (fun k => X (regenerationTimes ℓ X n + k) - X (regenerationTimes ℓ X n)) = + (renewSuffix ℓ)^[n] X := funext fun k => (iterate_renewSuffix_eq ℓ X h0 n k).symm + rw [he] at hs + exact (hX n).2.2.2.2 _ (by omega) + (by rw [regenerationTimes_succ] at hj'; omega) hs + +open scoped Classical in +noncomputable def recordCount {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : ℕ := + ∑ j ∈ Finset.range n, if StrictRecord ℓ X (j + 1) then 1 else 0 + +noncomputable def wordRecordCount {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) : ℕ := + recordCount ℓ (wordPath 0 w) w.length + +lemma recordCount_congr_prefix {d : ℕ} (ℓ : Vector d) {X Y : Path d} {n : ℕ} + (hXY : ∀ j ≤ n, X j = Y j) : recordCount ℓ X n = recordCount ℓ Y n := by + classical + apply Finset.sum_congr rfl + intro j hj + rw [strictRecord_congr_prefix ℓ (by simpa using Finset.mem_range.mp hj) hXY] + +lemma recordCount_add {d : ℕ} (ℓ : Vector d) (X : Path d) {n : ℕ} + (hn : StrictRecord ℓ X n) (m : ℕ) : + recordCount ℓ X (n + m) = recordCount ℓ X n + + recordCount ℓ (fun j => X (n + j) - X n) m := by + classical + rw [recordCount, Finset.sum_range_add] + congr 1 + apply Finset.sum_congr rfl + intro j _ + simp only [Nat.add_assoc, strictRecord_suffix_iff ℓ X hn (Nat.succ_pos j)] + +lemma recordCount_regenerationTimes {d : ℕ} (ℓ : Vector d) (X : Path d) (h0 : X 0 = 0) + (hX : ∀ n, ((renewSuffix ℓ)^[n] X) ∈ FirstWordEvent ℓ (regenerationWords ℓ X n)) (n : ℕ) : + recordCount ℓ X (regenerationTimes ℓ X n) = + ∑ j ∈ Finset.range n, wordRecordCount ℓ (regenerationWords ℓ X j) := by + induction n with + | zero => simp [recordCount] + | succ n ih => + rw [regenerationTimes_succ, recordCount_add ℓ X + (regenerationTimes_true ℓ X h0 hX n).1, ih, Finset.sum_range_succ] + congr 1 + have he := recordCount_congr_prefix ℓ (hX n).2.1 + rw [show (renewSuffix ℓ)^[n] X = _ from funext (iterate_renewSuffix_eq ℓ X h0 n)] at he + exact he + +lemma wordRecordCount_positive {d : ℕ} (ℓ : Vector d) (w : List (Direction d)) + (hw : AdmissibleTrueWord ℓ w) : 0 < wordRecordCount ℓ w := by + classical + have hn := hw.1 + have hr : StrictRecord ℓ (wordPath 0 w) w.length := fun j hj => (hw.2.1 j hj).2 + have he : w.length - 1 + 1 = w.length := by omega + have hterm : (if StrictRecord ℓ (wordPath 0 w) (w.length - 1 + 1) then 1 else 0 : ℕ) = 1 := by + rw [he, ite_eq_left hr] + have hle := Finset.single_le_sum (f := fun j => + (if StrictRecord ℓ (wordPath 0 w) (j+1) then 1 else 0 : ℕ)) + (fun j _ => Nat.zero_le _) (Finset.mem_range.mpr (show w.length - 1 < w.length by omega)) + rw [hterm] at hle + exact hle + +@[simp] lemma recordCount_zero {d : ℕ} (ℓ : Vector d) (X : Path d) : + recordCount ℓ X 0 = 0 := by simp [recordCount] + +open scoped Classical in +lemma recordCount_succ {d : ℕ} (ℓ : Vector d) (X : Path d) (n : ℕ) : + recordCount ℓ X (n + 1) = recordCount ℓ X n + + if StrictRecord ℓ X (n + 1) then 1 else 0 := by + classical + exact Finset.sum_range_succ (fun j => if StrictRecord ℓ X (j + 1) then 1 else 0) n + +lemma recordCount_mono {d : ℕ} (ℓ : Vector d) (X : Path d) : + Monotone (recordCount ℓ X) := by + apply monotone_nat_of_le_succ + intro n + rw [recordCount_succ] + exact Nat.le_add_right _ _ + +lemma recordCount_lt_of_strictRecord {d : ℕ} (ℓ : Vector d) (X : Path d) {m n : ℕ} + (hmn : m < n) (hn : StrictRecord ℓ X n) : recordCount ℓ X m < recordCount ℓ X n := by + classical + obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (show n ≠ 0 by omega) + rw [recordCount_succ, ite_eq_left hn] + exact Nat.lt_succ_of_le (recordCount_mono ℓ X (by omega)) + +lemma recordCount_unbounded {d : ℕ} (ℓ : Vector d) (X : Path d) + (hX : Tendsto (fun n => dot (realPosition (X n)) ℓ) atTop atTop) : + ∀ r, ∃ n, r ≤ recordCount ℓ X n := by + intro r + induction r with + | zero => exact ⟨0, Nat.zero_le _⟩ + | succ r ih => + obtain ⟨n, hn⟩ := ih + obtain ⟨m, hnm, hm⟩ := exists_strictRecord_gt ℓ X hX n + exact ⟨m, Nat.succ_le_of_lt (hn.trans_lt (recordCount_lt_of_strictRecord ℓ X hnm hm))⟩ + +lemma exists_record_at_index {d : ℕ} (ℓ : Vector d) (X : Path d) + (hX : Tendsto (fun n => dot (realPosition (X n)) ℓ) atTop atTop) {r : ℕ} (hr : 0 < r) : + ∃ n, 0 < n ∧ StrictRecord ℓ X n ∧ recordCount ℓ X n = r := by + classical + let n := Nat.find (recordCount_unbounded ℓ X hX r) + have hn : r ≤ recordCount ℓ X n := Nat.find_spec (recordCount_unbounded ℓ X hX r) + have hn0 : 0 < n := by + by_contra h + have he : n = 0 := by omega + simp only [he, recordCount_zero] at hn + omega + obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hn0) + have hklt : recordCount ℓ X k < r := Nat.lt_of_not_ge + (Nat.find_min (recordCount_unbounded ℓ X hX r) (by omega)) + have hrec : StrictRecord ℓ X n := by + by_contra hrec + rw [hk, recordCount_succ, ite_eq_right (by simpa only [hk, Nat.succ_eq_add_one] using hrec), Nat.add_zero] at hn + omega + refine ⟨n, hn0, hrec, ?_⟩ + rw [hk, recordCount_succ, ite_eq_left (by simpa only [hk, Nat.succ_eq_add_one] using hrec)] + rw [hk, recordCount_succ, ite_eq_left (by simpa only [hk, Nat.succ_eq_add_one] using hrec)] at hn + omega + +lemma measurable_recordCount {d : ℕ} (ℓ : Vector d) (n : ℕ) : + Measurable (fun X : Path d => recordCount ℓ X n) := by + classical + apply Finset.measurable_fun_sum + intro j _ + exact Measurable.ite (measurableSet_strictRecord ℓ (j+1)) measurable_const measurable_const + +def RecordIndexPrefix {d : ℕ} (ℓ : Vector d) (r n : ℕ) : Set (Path d) := + {X | 0 < n ∧ StrictRecord ℓ X n ∧ recordCount ℓ X n = r ∧ + ∀ j ≤ n, dot (realPosition (0 : Lattice d)) ℓ ≤ dot (realPosition (X j)) ℓ} + +lemma recordIndexPrefix_prefix {d : ℕ} (ℓ : Vector d) (r n : ℕ) : + PrefixDetermined n (RecordIndexPrefix ℓ r n) := by + intro X Y hXY + have hr := strictRecord_congr_prefix ℓ (le_refl n) hXY + have hc := recordCount_congr_prefix ℓ hXY + simp only [RecordIndexPrefix, Set.mem_ofPred_eq, hr, hc] + have hh : (∀ j ≤ n, dot (realPosition (0 : Lattice d)) ℓ ≤ dot (realPosition (X j)) ℓ) ↔ + (∀ j ≤ n, dot (realPosition (0 : Lattice d)) ℓ ≤ dot (realPosition (Y j)) ℓ) := + forall_congr' fun j => forall_congr' fun hj => by rw [hXY j hj] + rw [hh] + +lemma measurableSet_recordIndexPrefix {d : ℕ} (ℓ : Vector d) (r n : ℕ) : + MeasurableSet (RecordIndexPrefix ℓ r n) := by + simp only [RecordIndexPrefix, Set.ofPred_and, Set.ofPred_forall] + exact (MeasurableSet.const _).inter ((measurableSet_strictRecord ℓ n).inter + ((measurableSet_eq_fun (measurable_recordCount ℓ n) measurable_const).inter + (MeasurableSet.iInter fun j => MeasurableSet.iInter fun _ => + measurableSet_le measurable_const + ((measurable_of_countable (f := fun x : Lattice d => dot (realPosition x) ℓ)).comp + (measurable_pi_apply j))))) + +lemma recordIndexPrefix_disjoint {d : ℕ} (ℓ : Vector d) (r : ℕ) : + Pairwise (fun m n => Disjoint (RecordIndexPrefix ℓ r m) (RecordIndexPrefix ℓ r n)) := by + intro m n hmn + apply Set.disjoint_left.mpr + intro X hm hn + rcases lt_or_gt_of_ne hmn with h | h + · have := recordCount_lt_of_strictRecord ℓ X h hn.2.1 + rw [hm.2.2.1, hn.2.2.1] at this + exact (lt_irrefl _) this + · have := recordCount_lt_of_strictRecord ℓ X h hm.2.1 + rw [hm.2.2.1, hn.2.2.1] at this + exact (lt_irrefl _) this + +lemma recordIndexPrefix_noDrop {d : ℕ} (ℓ : Vector d) (r n : ℕ) : + RecordIndexPrefix ℓ r n ∩ FutureNoDrop ℓ n ⊆ NoDrop ℓ 0 := by + intro X ⟨hX, hD⟩ j + by_cases hj : j ≤ n + · exact hX.2.2.2 j hj + · have hnj : n ≤ j := by omega + have h := hD (j - n) + change dot (realPosition (X n)) ℓ ≤ dot (realPosition (X (n + (j-n)))) ℓ at h + rw [Nat.add_sub_of_le hnj] at h + exact (hX.2.2.2 n le_rfl).trans h + +lemma conditioned_recordIndexPrefix_true {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (r n : ℕ) : + conditionedLaw ν ℓ (RecordIndexPrefix ℓ r n ∩ FutureNoDrop ℓ n) = + annealedLaw ν (RecordIndexPrefix ℓ r n) := by + by_cases hn : 0 < n + · rw [conditionedLaw, Measure.smul_apply, smul_eq_mul, + Measure.restrict_apply ((measurableSet_recordIndexPrefix ℓ r n).inter + (measurableSet_futureNoDrop ℓ n)), + Set.inter_eq_left.mpr (recordIndexPrefix_noDrop ℓ r n), + annealed_record_event_noDrop ν ℓ n hn _ (recordIndexPrefix_prefix ℓ r n) + (fun X hX => hX.2.1), mul_comm _ (annealedLaw ν _ * _), + mul_assoc, ENNReal.mul_inv_cancel hp (measure_ne_top _ _), mul_one] + · have he : RecordIndexPrefix ℓ r n = ∅ := Set.eq_empty_iff_forall_notMem.mpr + (fun X hX => hn hX.1) + simp only [he, Set.empty_inter, measure_empty] + +lemma conditioned_true_at_index_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) {r : ℕ} (hr : 0 < r) : + annealedLaw ν (NoDrop ℓ 0) ≤ conditionedLaw ν ℓ + {X | ∃ n, 0 < n ∧ TrueRecord ℓ X n ∧ recordCount ℓ X n = r} := by + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + have hsub : NoDrop ℓ 0 ≤ᵐ[annealedLaw ν] ⋃ n, RecordIndexPrefix ℓ r n := by + filter_upwards [htrans] with X hX hD + obtain ⟨n, hn, hrec, hcount⟩ := exists_record_at_index ℓ X hX hr + exact Set.mem_iUnion.mpr ⟨n, hn, hrec, hcount, fun j _ => hD j⟩ + calc + annealedLaw ν (NoDrop ℓ 0) ≤ annealedLaw ν (⋃ n, RecordIndexPrefix ℓ r n) := measure_mono_ae hsub + _ = ∑' n, annealedLaw ν (RecordIndexPrefix ℓ r n) := + measure_iUnion (recordIndexPrefix_disjoint ℓ r) (measurableSet_recordIndexPrefix ℓ r) + _ = ∑' n, conditionedLaw ν ℓ (RecordIndexPrefix ℓ r n ∩ FutureNoDrop ℓ n) := by + simp_rw [conditioned_recordIndexPrefix_true ν ℓ hp] + _ = conditionedLaw ν ℓ (⋃ n, RecordIndexPrefix ℓ r n ∩ FutureNoDrop ℓ n) := by + symm + exact measure_iUnion (fun m n hmn => (recordIndexPrefix_disjoint ℓ r hmn).mono + Set.inter_subset_left Set.inter_subset_left) (fun n => + (measurableSet_recordIndexPrefix ℓ r n).inter (measurableSet_futureNoDrop ℓ n)) + _ ≤ _ := measure_mono (by + rintro X ⟨s, ⟨n, rfl⟩, hX, hD⟩ + exact ⟨n, hX.1, ⟨hX.2.1, hD⟩, hX.2.2.1⟩) + +lemma renewal_truncated_sum_le (s : ℕ → ℕ) (H K n : ℕ) : + (∑ i ∈ Finset.range n, if (∑ j ∈ Finset.range i, s j) ≤ H then min (s i) K else 0) ≤ H + K := by + induction n with + | zero => simp + | succ n ih => + rw [Finset.sum_range_succ] + by_cases hn : (∑ j ∈ Finset.range n, s j) ≤ H + · rw [ite_eq_left hn] + apply (Nat.add_le_add ?_ (min_le_right _ _)).trans (Nat.add_le_add_right hn K) + apply Finset.sum_le_sum + intro i _ + split_ifs + · exact min_le_left _ _ + · exact Nat.zero_le _ + · simpa only [ite_eq_right hn, Nat.add_zero] using ih + +lemma renewal_wald_bound {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsProbabilityMeasure μ] + (S : ℕ → α → ℕ) (hS : ∀ i, Measurable (S i)) (hind : iIndepFun S μ) + (hident : ∀ i, IdentDistrib (S i) (S 0) μ μ) (H K : ℕ) : + (∑ i ∈ Finset.range (H+1), μ.real {x | (∑ j ∈ Finset.range i, S j x) ≤ H}) * + (∫ x, ((min (S 0 x) K : ℕ) : ℝ) ∂μ) ≤ (H : ℝ) + K := by + classical + let F : ℕ → α → ℝ := fun i x => if (∑ j ∈ Finset.range i, S j x) ≤ H then + ((min (S i x) K : ℕ) : ℝ) else 0 + have hFmeas (i : ℕ) : Measurable (F i) := + Measurable.ite (measurableSet_le (Finset.measurable_fun_sum _ (fun j _ => hS j)) measurable_const) + ((measurable_of_countable (f := fun n : ℕ => (n : ℝ))).comp ((hS i).min measurable_const)) measurable_const + have hFint (i : ℕ) : Integrable (F i) μ := + integrable_of_nonneg_bound μ (hFmeas i) (B := K) fun x => by + dsimp [F] + split_ifs + · exact ⟨Nat.cast_nonneg _, by exact_mod_cast min_le_right (S i x) K⟩ + · exact ⟨le_rfl, Nat.cast_nonneg _⟩ + have hbound : (∫ x, ∑ i ∈ Finset.range (H+1), F i x ∂μ) ≤ (H : ℝ) + K := by + calc + _ ≤ ∫ _ : α, (H : ℝ) + K ∂μ := integral_mono + (integrable_finsetSum _ (fun i _ => hFint i)) (integrable_const _) fun x => by + have hh := renewal_truncated_sum_le (fun i => S i x) H K (H+1) + have he : (∑ i ∈ Finset.range (H+1), F i x) = + ((∑ i ∈ Finset.range (H+1), if (∑ j ∈ Finset.range i, S j x) ≤ H + then min (S i x) K else 0 : ℕ) : ℝ) := by + simp only [Nat.cast_sum, Nat.cast_ite, Nat.cast_zero, F, Nat.cast_min] + rw [he] + simpa only [Nat.cast_add] using (Nat.cast_le (α := ℝ)).mpr hh + _ = _ := by simp + have hfactor (i : ℕ) : (∫ x, F i x ∂μ) = + μ.real {x | (∑ j ∈ Finset.range i, S j x) ≤ H} * + ∫ x, ((min (S 0 x) K : ℕ) : ℝ) ∂μ := by + let A : ℕ → ℝ := fun t => if t ≤ H then 1 else 0 + let B : ℕ → ℝ := fun t => ((min t K : ℕ) : ℝ) + have hsummeas : Measurable (fun x => ∑ j ∈ Finset.range i, S j x) := + Finset.measurable_fun_sum _ (fun j _ => hS j) + have hi := (hind.indepFun_finsetSum_of_notMem hS (Finset.notMem_range_self (n := i))).comp + (measurable_of_countable A) (measurable_of_countable B) + have hi' : IndepFun (fun x => A (∑ j ∈ Finset.range i, S j x)) (fun x => B (S i x)) μ := by + have heq : (∑ j ∈ Finset.range i, S j) = (fun x => ∑ j ∈ Finset.range i, S j x) := by + funext x + simp only [Finset.sum_apply] + rw [heq] at hi + exact hi + have he : F i = fun x => A (∑ j ∈ Finset.range i, S j x) * B (S i x) := by + funext x + simp only [F, A, B] + split_ifs <;> simp + rw [he, hi'.integral_fun_mul_eq_mul_integral + ((measurable_of_countable A).comp hsummeas).aestronglyMeasurable + ((measurable_of_countable B).comp (hS i)).aestronglyMeasurable] + have hA : (fun x => A (∑ j ∈ Finset.range i, S j x)) = + {x | (∑ j ∈ Finset.range i, S j x) ≤ H}.indicator (fun _ => (1 : ℝ)) := by + funext x + simp only [A, Set.indicator_apply, Set.mem_ofPred_eq] + rw [hA, integral_indicator_const (1 : ℝ) (measurableSet_le hsummeas measurable_const)] + simp only [smul_eq_mul, mul_one] + exact congrArg (fun y => μ.real {x | (∑ j ∈ Finset.range i, S j x) ≤ H} * y) + ((hident i).comp (measurable_of_countable B)).integral_eq + rw [integral_finsetSum _ (fun i _ => hFint i)] at hbound + simp_rw [hfactor] at hbound + simpa only [Finset.sum_mul] using hbound + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/RenewalCountBounds.lean b/lean/OAI/Probability/Ballisticity/Renewal/RenewalCountBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1354bfce531d0c579e326610d3081baad48e4fa --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/RenewalCountBounds.lean @@ -0,0 +1,225 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OrderedTimes + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma renewalCount_eq_of_bounds (L : ℕ → ℕ) (hL : ∀ k, 0 < L k) + {h k : ℕ} (hl : renewalSum L k ≤ h) (hu : h < renewalSum L (k+1)) : + renewalCount L h = k := by + have hm := renewalSum_strictMono L hL + have hl' := renewalCount_lower L h + have hu' := renewalCount_upper L hL h + apply le_antisymm + · by_contra! hh + have := hm.monotone (show k+1 ≤ renewalCount L h by omega) + omega + · by_contra! hh + have := hm.monotone (show renewalCount L h+1 ≤ k by omega) + omega + +lemma renewalCount_at_sum (L : ℕ → ℕ) (hL : ∀ k, 0 < L k) (k : ℕ) : + renewalCount L (renewalSum L k) = k := + renewalCount_eq_of_bounds L hL le_rfl ((renewalSum_strictMono L hL) (Nat.lt_succ_self k)) + +lemma measurable_renewalSum {Ω : Type*} [MeasurableSpace Ω] + (L : ℕ → Ω → ℕ) (hL : ∀ k, Measurable (L k)) (n : ℕ) : + Measurable (fun ω => renewalSum (fun k => L k ω) n) := + Finset.measurable_fun_sum _ (fun k _ => hL k) + +lemma integral_nat_event_indicator {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (A : Set Ω) [DecidablePred (· ∈ A)] (hA : MeasurableSet A) : + (∫ ω, if ω ∈ A then (1:ℝ) else 0 ∂μ) = μ.real A := by + simpa only [Set.indicator_apply,smul_eq_mul,mul_one] using integral_indicator_const (1:ℝ) hA + +lemma renewal_occupation_upper {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (L : ℕ → Ω → ℕ) + (hL : ∀ k, Measurable (L k)) (hpos : ∀ᵐ ω ∂μ, ∀ k, 0 < L k ω) (s H : ℕ) : + (∑ k ∈ Finset.range H, μ.real {ω | renewalSum (fun j => L j ω) k = s}) ≤ 1 := by + classical + let A := fun k => {ω | renewalSum (fun j => L j ω) k = s} + have hA (k : ℕ) : MeasurableSet (A k) := + measurableSet_eq_fun (measurable_renewalSum L hL k) measurable_const + have hi (k : ℕ) : Integrable (fun ω => if ω ∈ A k then (1:ℝ) else 0) μ := + by + apply ((integrable_const (μ := μ) (1:ℝ)).indicator (hA k)).congr + filter_upwards [] with ω + simp only [Set.indicator_apply] + have he : (∑ k ∈ Finset.range H, μ.real (A k)) = + ∫ ω, ∑ k ∈ Finset.range H, if ω ∈ A k then (1:ℝ) else 0 ∂μ := by + rw [integral_finsetSum _ (fun k _ => hi k)] + exact Finset.sum_congr rfl (fun k _ => (integral_nat_event_indicator μ (A k) (hA k)).symm) + rw [he] + calc + _ ≤ ∫ _ : Ω, (1:ℝ) ∂μ := by + apply integral_mono_ae (integrable_finsetSum _ (fun k _ => hi k)) (integrable_const _) + filter_upwards [hpos] with ω hω + calc + _ ≤ ∑ k ∈ Finset.range H, if k = renewalCount (fun j => L j ω) s then (1:ℝ) else 0 := by + apply Finset.sum_le_sum + intro k _ + by_cases hk : ω ∈ A k + · have he := renewalCount_at_sum (fun j => L j ω) hω k + change renewalSum (fun j => L j ω) k = s at hk + rw [hk] at he + simp [show ω ∈ A k from hk,he] + · simp only [ite_eq_right hk] + split_ifs <;> norm_num + _ ≤ 1 := by simp only [Finset.sum_ite_eq']; split_ifs <;> norm_num + _ = 1 := by simp + +lemma renewal_selected_event_bound {Ω α : Type*} [MeasurableSpace Ω] [MeasurableSpace α] + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : ℕ → Ω → α) + (hW : ∀ k, Measurable (W k)) (hind : iIndepFun W μ) + (hident : ∀ k, IdentDistrib (W k) (W 0) μ μ) + (L : α → ℕ) (hL : Measurable L) (hpos : ∀ᵐ ω ∂μ, ∀ k, 0 < L (W k ω)) + (hI : Integrable (fun ω => (L (W 0 ω) : ℝ)) μ) + (A : Set α) (hA : MeasurableSet A) (h : ℕ) : + μ.real {ω | W (renewalCount (fun j => L (W j ω)) h) ω ∈ A} ≤ + ∫ ω, if W 0 ω ∈ A then (L (W 0 ω) : ℝ) else 0 ∂μ := by + classical + let S := fun k ω => renewalSum (fun j => L (W j ω)) k + let B := fun s => {a | a ∈ A ∧ h-s < L a} + let E := fun k s => {ω | S k ω = s ∧ W k ω ∈ B s} + have hB (s : ℕ) : MeasurableSet (B s) := hA.inter (measurableSet_lt measurable_const hL) + have hSm (k : ℕ) : Measurable (S k) := measurable_renewalSum _ (fun j => hL.comp (hW j)) k + have hE (k s : ℕ) : MeasurableSet (E k s) := + (measurableSet_eq_fun (hSm k) measurable_const).inter ((hW k) (hB s)) + have hsub : {ω | W (renewalCount (fun j => L (W j ω)) h) ω ∈ A} ≤ᵐ[μ] + ⋃ k ∈ Finset.range (h+1), ⋃ s ∈ Finset.range (h+1), E k s := by + filter_upwards [hpos] with ω hω ha + let k := renewalCount (fun j => L (W j ω)) h + have hk := renewalCount_le (fun j => L (W j ω)) h + have hs := renewalCount_lower (fun j => L (W j ω)) h + have hs' := renewalCount_upper (fun j => L (W j ω)) hω h + rw [renewalSum_succ] at hs' + refine Set.mem_iUnion.mpr ⟨k,Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr (by omega), + Set.mem_iUnion.mpr ⟨S k ω,Set.mem_iUnion.mpr ⟨Finset.mem_range.mpr (by dsimp [S,k]; omega), + rfl,ha,?_⟩⟩⟩⟩ + dsimp [S,k] + omega + have hfactor (k s : ℕ) : μ.real (E k s) = + μ.real {ω | S k ω = s} * μ.real (W 0 ⁻¹' B s) := by + let F := fun w : Fin k → α => ∑ j : Fin k, L (w j) + have hF : Measurable F := Finset.measurable_fun_sum _ (fun j _ => hL.comp (measurable_pi_apply j)) + have hind' := (independent_past_current μ W hW hind k).comp hF measurable_id + have he : (fun ω => F (fun j : Fin k => W j ω)) = S k := by + funext ω + dsimp [F,S,renewalSum] + exact Fin.sum_univ_eq_sum_range (fun j => L (W j ω)) k + change IndepFun (fun ω => F (fun j : Fin k => W j ω)) (W k) μ at hind' + rw [he] at hind' + have hh := hind'.measure_inter_preimage_eq_mul {s} (B s) (measurableSet_singleton s) (hB s) + have hid := (hident k).measure_mem_eq (hB s) + change μ (E k s) = μ {ω | S k ω = s} * μ (W k ⁻¹' B s) at hh + rw [hid] at hh + exact congrArg ENNReal.toReal hh |>.trans ENNReal.toReal_mul + calc + _ ≤ μ.real (⋃ k ∈ Finset.range (h+1), ⋃ s ∈ Finset.range (h+1), E k s) := + ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono_ae hsub) + _ ≤ ∑ k ∈ Finset.range (h+1), ∑ s ∈ Finset.range (h+1), μ.real (E k s) := by + exact (measureReal_biUnion_finset_le _ _).trans + (Finset.sum_le_sum (fun k _ => measureReal_biUnion_finset_le _ _)) + _ = ∑ s ∈ Finset.range (h+1), + (∑ k ∈ Finset.range (h+1), μ.real {ω | S k ω = s}) * μ.real (W 0 ⁻¹' B s) := by + simp_rw [hfactor] + rw [Finset.sum_comm] + simp_rw [Finset.sum_mul] + _ ≤ ∑ s ∈ Finset.range (h+1), μ.real (W 0 ⁻¹' B s) := by + apply Finset.sum_le_sum + intro s _ + exact mul_le_of_le_one_left measureReal_nonneg + (renewal_occupation_upper μ _ (fun k => hL.comp (hW k)) hpos s (h+1)) + _ = ∑ s ∈ Finset.range (h+1), μ.real {ω | W 0 ω ∈ A ∧ s < L (W 0 ω)} := by + simpa only [Nat.add_sub_cancel,B,Set.preimage_ofPred_eq] using + Finset.sum_range_reflect (fun s => μ.real {ω | W 0 ω ∈ A ∧ s < L (W 0 ω)}) (h+1) + _ ≤ _ := by + let C := fun s => {ω | W 0 ω ∈ A ∧ s < L (W 0 ω)} + have hC (s : ℕ) : MeasurableSet (C s) := ((hW 0) hA).inter + (measurableSet_lt measurable_const (hL.comp (hW 0))) + have hCi (s : ℕ) : Integrable (fun ω => if ω ∈ C s then (1:ℝ) else 0) μ := + by + apply ((integrable_const (μ := μ) (1:ℝ)).indicator (hC s)).congr + filter_upwards [] with ω + simp only [Set.indicator_apply] + calc + _ = ∫ ω, ∑ s ∈ Finset.range (h+1), if ω ∈ C s then (1:ℝ) else 0 ∂μ := by + rw [integral_finsetSum _ (fun s _ => hCi s)] + exact Finset.sum_congr rfl (fun s _ => (integral_nat_event_indicator μ (C s) (hC s)).symm) + _ ≤ _ := by + apply integral_mono (integrable_finsetSum _ (fun s _ => hCi s)) (by + apply (hI.indicator ((hW 0) hA)).congr + filter_upwards [] with ω + simp only [Set.indicator_apply,Set.mem_preimage]) + intro ω + by_cases hω : W 0 ω ∈ A + · simp only [C,Set.mem_ofPred_eq,hω,true_and,ite_eq_left] + calc + _ ≤ ∑ s ∈ Finset.range (L (W 0 ω)), (1:ℝ) := by + rw [← Finset.sum_filter] + exact Finset.sum_le_sum_of_subset_of_nonneg + (fun s hs => Finset.mem_range.mpr (Finset.mem_filter.mp hs).2) + (fun _ _ _ => zero_le_one) + _ = _ := by simp + · simp [C,hω] + +lemma width_mark_tail_tendsto {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (L : Ω → ℕ) (hL : Measurable L) + (hI : Integrable (fun ω => (L ω : ℝ)) μ) (R : Ω → ℝ) (hR : Measurable R) + (b : ℕ → ℝ) (hb : Tendsto b atTop atTop) : + Tendsto (fun i => ∫ ω, if b i ≤ |R ω| then (L ω : ℝ) else 0 ∂μ) atTop (𝓝 0) := by + have hm (i : ℕ) : Measurable (fun ω => if b i ≤ |R ω| then (L ω : ℝ) else 0) := + Measurable.ite (measurableSet_le measurable_const hR.abs) + ((measurable_of_countable (fun j : ℕ => (j:ℝ))).comp hL) measurable_const + have ht := tendsto_integral_of_dominated_convergence (μ := μ) + (F := fun i ω => if b i ≤ |R ω| then (L ω : ℝ) else 0) (f := fun _ => (0:ℝ)) + (fun ω => (L ω : ℝ)) (fun i => (hm i).aestronglyMeasurable) hI + (fun i => Eventually.of_forall fun ω => by + split_ifs <;> simp [Nat.cast_nonneg]) + (Eventually.of_forall fun ω => by + apply tendsto_const_nhds.congr' + filter_upwards [hb.eventually (eventually_gt_atTop |R ω|)] with i hi + simp only [ite_eq_right (not_le_of_gt hi)]) + simpa only [integral_zero] using ht + +theorem renewal_selected_mark_small {Ω α : Type*} [MeasurableSpace Ω] [MeasurableSpace α] + (μ : Measure Ω) [IsProbabilityMeasure μ] (W : ℕ → Ω → α) + (hW : ∀ k, Measurable (W k)) (hind : iIndepFun W μ) + (hident : ∀ k, IdentDistrib (W k) (W 0) μ μ) + (L : α → ℕ) (hL : Measurable L) (hpos : ∀ᵐ ω ∂μ, ∀ k, 0 < L (W k ω)) + (hI : Integrable (fun ω => (L (W 0 ω) : ℝ)) μ) + (R : α → ℝ) (hR : Measurable R) (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) + (h : ℕ → ℕ) : + TendstoInMeasure μ (fun i ω => R (W (renewalCount (fun j => L (W j ω)) (h i)) ω)/r i) + atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] + have ht := width_mark_tail_tendsto μ (fun ω => L (W 0 ω)) (hL.comp (hW 0)) hI + (fun ω => R (W 0 ω)) (hR.comp (hW 0)) (fun i => ε*r i) (hr.const_mul_atTop hε) + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ ht + filter_upwards [hr.eventually (eventually_gt_atTop (0:ℝ))] with i hri + have he : {ω | ε ≤ |R (W (renewalCount (fun j => L (W j ω)) (h i)) ω)/r i|} = + {ω | W (renewalCount (fun j => L (W j ω)) (h i)) ω ∈ {a | ε*r i ≤ |R a|}} := by + ext ω + simp only [Set.mem_ofPred_eq,abs_div,abs_of_pos hri,le_div_iff₀ hri] + rw [he] + exact renewal_selected_event_bound μ W hW hind hident L hL hpos hI + {a | ε*r i ≤ |R a|} (measurableSet_le measurable_const hR.abs) (h i) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Renewal/VelocityWords.lean b/lean/OAI/Probability/Ballisticity/Renewal/VelocityWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..5baa1b44938f55d6f396b35e5d73724e358a8112 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Renewal/VelocityWords.lean @@ -0,0 +1,168 @@ +import Mathlib +import OAI.Probability.Ballisticity.Renewal.DurationMoment + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def renewalVelocity {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) : Vector d := + fun i => (∫ X, wordCoordinate (i,true) (firstWord ℓ X) ∂conditionedLaw ν ℓ) / + (∫ X, ((firstWord ℓ X).length:ℝ) ∂conditionedLaw ν ℓ) + +lemma conditioned_velocity_from_duration {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) + (htrans : DirectionallyTransient ν ℓ) + (hint : Integrable (fun X => ((firstWord ℓ X).length:ℝ)) (conditionedLaw ν ℓ)) : + ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ VelocityPaths (renewalVelocity ν ℓ) := by + have ht := conditioned_wordDuration_mean_positive ν ℓ htrans hint + filter_upwards [conditioned_regenerationSupport ν ℓ htrans, + conditioned_word_temporal_strong_law ν ℓ htrans hint, + ae_all_iff.mpr (fun i : Fin d => conditioned_word_spatial_strong_laws ν hue ℓ hℓ htrans (i,true))] + with X hX hTime hSpace + apply tendsto_pi_nhds.mpr + intro i + change Tendsto (fun n : ℕ => signedCoordinate (i,true) (X n)/n) atTop (𝓝 _) + apply scalar_cut_speed (regenerationTimes ℓ X) (regenerationTimes_strictMono ℓ X hX.2) + (regenerationTimes_zero ℓ X) (fun n => signedCoordinate (i,true) (X n)) + (fun n => wordRadius (regenerationWords ℓ X n)) _ _ ht hTime + · simpa only [regeneration_coordinate_sum ℓ (i,true) X hX] using (hSpace i).1 + · exact (hSpace i).2 + · intro k n hlo hhi + have hnk : n=regenerationTimes ℓ X k+(n-regenerationTimes ℓ X k) := by omega + have hlen : n-regenerationTimes ℓ X k ≤ (regenerationWords ℓ X k).length := by + rw [regenerationTimes_succ] at hhi + omega + have hh := regeneration_span ℓ X hX.1 hX.2 k _ hlen + rw [← hnk] at hh + rw [hh,signedCoordinate_add,add_sub_cancel_left] + exact (signedCoordinate_abs_le_norm _ _).trans (wordRadius_bound _ hlen) + +lemma renewalVelocity_projection {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) + (htrans : DirectionallyTransient ν ℓ) : + dot (renewalVelocity ν ℓ) ℓ = + (∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂conditionedLaw ν ℓ) / + (∫ X, ((firstWord ℓ X).length:ℝ) ∂conditionedLaw ν ℓ) := by + have hint (i : Fin d) : Integrable (fun X => wordCoordinate (i,true) (firstWord ℓ X)*ℓ i) + (conditionedLaw ν ℓ) := (conditioned_wordCoordinate_integrable ν hue ℓ hℓ htrans (i,true)).mul_const _ + have hid : (∫ X, wordHeightGain ℓ (firstWord ℓ X) ∂conditionedLaw ν ℓ) = + ∑ i : Fin d, (∫ X, wordCoordinate (i,true) (firstWord ℓ X) ∂conditionedLaw ν ℓ)*ℓ i := by + change (∫ X, ∑ i : Fin d, wordCoordinate (i,true) (firstWord ℓ X)*ℓ i ∂conditionedLaw ν ℓ)=_ + rw [integral_finsetSum _ (fun i _ => hint i)] + exact Finset.sum_congr rfl (fun i _ => integral_mul_const _ _) + rw [hid,Finset.sum_div] + apply Finset.sum_congr rfl + intro i _ + change (_ / _)*_=(_*_)/_ + ring + +lemma velocity_from_integrable_words {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) + (htrans : DirectionallyTransient ν ℓ) + (hint : Integrable (fun X => ((firstWord ℓ X).length:ℝ)) (conditionedLaw ν ℓ)) : + 0 < dot (renewalVelocity ν ℓ) ℓ ∧ HasVelocity ν (renewalVelocity ν ℓ) := by + constructor + · rw [renewalVelocity_projection ν hue ℓ hℓ htrans] + exact div_pos (conditioned_wordHeightGain_moments ν ℓ (unit_direction_coordinate_bound ℓ hℓ) htrans).2.1 + (conditioned_wordDuration_mean_positive ν ℓ htrans hint) + · exact conditioned_to_annealed_velocity ν ℓ htrans _ + (conditioned_velocity_from_duration ν hue ℓ hℓ htrans hint) + +lemma signed_coordinate_ballisticity {d : ℕ} (hd : 2 ≤ d) (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e : Direction d) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ v : Vector d, 0 < dot v (realPosition (step e)) ∧ HasVelocity ν v := by + exact ⟨renewalVelocity ν (realPosition (step e)),velocity_from_integrable_words ν hue _ + (signed_direction_unit e) htrans (conditioned_wordDuration_integrable hd ν hue e htrans)⟩ + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma velocityPaths_projection {d : ℕ} (v ℓ : Vector d) (X : Path d) + (hX : X ∈ VelocityPaths v) : + Tendsto (fun n : ℕ => dot (realPosition (X n)) ℓ/(n:ℝ)) atTop (𝓝 (dot v ℓ)) := by + have hh := tendsto_finsetSum Finset.univ (fun i _ => + (tendsto_pi_nhds.mp hX i).mul_const (ℓ i)) + simpa only [dot,realPosition,Finset.sum_div,div_mul_eq_mul_div] using hh + +lemma conditioned_word_height_strong_law {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ X ∂conditionedLaw ν ℓ, Tendsto + (fun n : ℕ => dot (realPosition (X (regenerationTimes ℓ X n))) ℓ/n) atTop + (𝓝 (∫ Y, wordHeightGain ℓ (firstWord ℓ Y) ∂conditionedLaw ν ℓ)) := by + have hm : Measurable (wordHeightGain ℓ) := measurable_of_countable _ + have ht := strong_law_ae_real (fun n X => wordHeightGain ℓ (regenerationWords ℓ X n)) + (conditioned_wordHeightGain_moments ν ℓ (unit_direction_coordinate_bound ℓ hℓ) htrans).1 + (fun i j hij => ((regenerationWords_independent ν ℓ htrans).indepFun hij).comp hm hm) + (fun i => (regenerationWords_identDistrib ν ℓ htrans i).comp hm) + filter_upwards [conditioned_regenerationSupport ν ℓ htrans,ht] with X hX ht + simpa only [regeneration_height_sum ℓ X hX.1 hX.2,regenerationWords,Function.iterate_zero,id_eq] using ht + +lemma velocity_positive_original_direction {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) + (htrans : DirectionallyTransient ν ℓ) (e : Direction d) + (he : 0 < ∫ X, wordCoordinate e (firstWord ℓ X) ∂conditionedLaw ν ℓ) + (v : Vector d) (hv : HasVelocity ν v) (hve : 0 < dot v (realPosition (step e))) : + 0 < dot v ℓ := by + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := + conditionedLaw_probability ν _ (noDrop_positive_of_directionallyTransient ν _ htrans).ne' + have hvc : ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ VelocityPaths v := + (conditionedLaw_absolutelyContinuous ν ℓ).ae_le hv + have hfull := (conditioned_regenerationSupport ν ℓ htrans).and + ((conditioned_word_height_strong_law ν ℓ hℓ htrans).and + ((conditioned_word_spatial_strong_laws ν hue ℓ hℓ htrans e).and hvc)) + obtain ⟨X,hX,hH,hC,hvX⟩ := hfull.exists + have hT := (regenerationTimes_strictMono ℓ X hX.2).tendsto_atTop + have hvH := (velocityPaths_projection v ℓ X hvX).comp hT + have hvC := (velocityPaths_projection v (realPosition (step e)) X hvX).comp hT + simp only [Function.comp_def,dot_signed_direction] at hvC + have hC' : Tendsto (fun n : ℕ => signedCoordinate e (X (regenerationTimes ℓ X n))/n) + atTop (𝓝 (∫ Y, wordCoordinate e (firstWord ℓ Y) ∂conditionedLaw ν ℓ)) := by + simpa only [regeneration_coordinate_sum ℓ e X hX] using hC.1 + have hp := hH.mul hvC + have hq := hC'.mul hvH + have hid : (fun n : ℕ => + (dot (realPosition (X (regenerationTimes ℓ X n))) ℓ/(n:ℝ)) * + (signedCoordinate e (X (regenerationTimes ℓ X n))/(regenerationTimes ℓ X n:ℝ))) = + (fun n : ℕ => (signedCoordinate e (X (regenerationTimes ℓ X n))/(n:ℝ)) * + (dot (realPosition (X (regenerationTimes ℓ X n))) ℓ/(regenerationTimes ℓ X n:ℝ))) := by + funext n + ring + simp only [Function.comp_def] at hp hq + rw [hid] at hp + have hlim := tendsto_nhds_unique hp hq + have hh := (conditioned_wordHeightGain_moments ν ℓ + (unit_direction_coordinate_bound ℓ hℓ) htrans).2.1 + have hm : 0 < (∫ X, wordCoordinate e (firstWord ℓ X) ∂conditionedLaw ν ℓ)*dot v ℓ := by + rw [← hlim] + exact mul_pos hh hve + exact (mul_pos_iff.mp hm).resolve_right (fun h => (not_lt_of_ge he.le h.1)) |>.2 + +theorem directional_transience_implies_ballisticity_unit {d : ℕ} (hd : 2 ≤ d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (ℓ : Vector d) (hℓ : dot ℓ ℓ=1) (htrans : DirectionallyTransient ν ℓ) : + ∃ v : Vector d, 0 < dot v ℓ ∧ HasVelocity ν v := by + obtain ⟨e,he⟩ := conditioned_coordinate_positive_mean ν hue ℓ hℓ htrans + have hte : DirectionallyTransient ν (realPosition (step e)) := by + apply conditioned_to_annealed_transience ν ℓ _ htrans + simpa only [TransientPaths,Set.mem_ofPred_eq,dot_signed_direction] using + conditioned_coordinate_transience ν hue ℓ hℓ htrans e he + obtain ⟨v,hve,hv⟩ := signed_coordinate_ballisticity hd ν hue e hte + exact ⟨v,velocity_positive_original_direction ν hue ℓ hℓ htrans e he v hv hve,hv⟩ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/RowBridge.lean b/lean/OAI/Probability/Ballisticity/RowBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e3b665d99795479d00a4250cadf28772183b7cb --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/RowBridge.lean @@ -0,0 +1,89 @@ +import OAI.Probability.Ballisticity.Main +import OAI.Probability.DirectionalWalk.Main + +namespace OAI + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +namespace DirectionalTransience + +namespace RowBridge + +def toReal {d : ℕ} (p : Row d) : DirectionalZeroOne.Row d := + ⟨fun e => (p.1 e : ℝ), by + constructor + · intro e + exact ⟨(p.1 e).coe_nonneg, by exact_mod_cast row_entry_le_one p e⟩ + · change ∑ e : Direction d, (p.1 e : ℝ) = 1 + rw [← NNReal.coe_sum, p.2] + rfl⟩ + +lemma measurable_toReal {d : ℕ} : Measurable (toReal (d := d)) := by + apply Measurable.subtype_mk + exact Measurable.of_eval fun e => + ((measurable_pi_apply e).comp measurable_subtype_coe).coe_nnreal_real + +noncomputable def rowLaw {d : ℕ} (ν : Measure (Row d)) : + Measure (DirectionalZeroOne.Row d) := ν.map toReal + +instance rowLaw_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] : + IsProbabilityMeasure (rowLaw ν) := + (Measure.isProbabilityMeasure_map_iff measurable_toReal.aemeasurable).2 inferInstance + +def environment {d : ℕ} (ω : Environment d) : DirectionalZeroOne.Environment d := + fun x => toReal (ω x) + +lemma measurable_environment {d : ℕ} : Measurable (environment (d := d)) := + Measurable.of_eval fun x => measurable_toReal.comp (measurable_pi_apply x) + +lemma environmentLaw_map {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] : + (environmentLaw ν).map environment = DirectionalZeroOne.environmentLaw (rowLaw ν) := by + exact Measure.infinitePi_map_pi (fun _ : Lattice d => ν) (fun _ => measurable_toReal) + +lemma strictEllipticity {d : ℕ} (ν : Measure (Row d)) (hue : UniformElliptic ν) : + DirectionalZeroOne.StrictEllipticity (rowLaw ν) := by + obtain ⟨κ, hκ, hrows⟩ := hue + have hm : MeasurableSet {p : DirectionalZeroOne.Row d | ∀ e, 0 < p.1 e} := by + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter fun e => measurableSet_lt measurable_const + ((measurable_pi_apply e).comp (measurable_subtype_coe : + Measurable (fun p : DirectionalZeroOne.Row d => p.1))) + apply (ae_map_iff measurable_toReal.aemeasurable hm).mpr + filter_upwards [hrows] with p hp e + change (0 : ℝ) < (p.1 e : ℝ) + exact_mod_cast lt_of_lt_of_le hκ (hp e) + +lemma entryWeight {d : ℕ} (ω : Environment d) (x y : Lattice d) : + DirectionalZeroOne.entryWeight (environment ω) x y = edgeWeight ω x y := by + classical + simp only [DirectionalZeroOne.entryWeight, edgeWeight, + environment, toReal, ENNReal.ofReal_coe_nnreal] + apply Finset.sum_congr rfl + intro e _ + change (if x + step e = y then ((ω x).1 e : ℝ≥0∞) else 0) = _ + simp only [eq_comm] + +lemma annealedLaw_eq {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] : + annealedLaw ν = DirectionalZeroOne.annealed (rowLaw ν) 0 := by + apply pathMeasure_ext + intro γ n + rw [annealed_apply ν (measurableSet_pathCylinder γ n)] + change (∫⁻ ω, quenchedKernel (ω, 0) (pathCylinder γ n) ∂environmentLaw ν) = + DirectionalZeroOne.annealed (rowLaw ν) 0 (DirectionalZeroOne.pathCylinder n γ) + rw [DirectionalZeroOne.annealed_cylinder] + by_cases h0 : γ 0 = 0 + · rw [ite_eq_left h0.symm, ← environmentLaw_map ν, + lintegral_map (DirectionalZeroOne.measurable_pathWeight n γ) measurable_environment] + apply lintegral_congr + intro ω + rw [quenched_pathCylinder ω 0 γ h0 n] + simp only [DirectionalZeroOne.pathWeight, entryWeight] + · rw [ite_eq_right (Ne.symm h0)] + simp only [quenched_pathCylinder_zero _ _ _ h0, lintegral_zero] + +end RowBridge + +end DirectionalTransience + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/Array.lean b/lean/OAI/Probability/Ballisticity/Stationary/Array.lean new file mode 100644 index 0000000000000000000000000000000000000000..4af6978e930a82f67390230562b04a3660b6c571 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/Array.lean @@ -0,0 +1,45 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayTopology + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped NNReal ENNReal BigOperators Classical +namespace DirectionalTransience + +instance row_compact (d : ℕ) : CompactSpace (Row d) := by + apply isCompact_iff_compactSpace.mp + have hbox : IsCompact {p : Direction d → ℝ≥0 | ∀ e, p e∈Set.Icc 0 1} := + isCompact_pi_infinite (fun _ => isCompact_Icc) + apply hbox.of_isClosed_subset (isClosed_eq (by fun_prop) continuous_const) + intro p hp e + exact ⟨bot_le, (Finset.single_le_sum (fun j _ => bot_le) (Finset.mem_univ e)).trans_eq hp⟩ + +def horizontalSubgroup {d : ℕ} (e : Direction d) : AddSubgroup (Lattice d) where + carrier := {x | x e.1=0} + zero_mem' := rfl + add_mem' {x y} hx hy := by + change x e.1=0 at hx + change y e.1=0 at hy + change x e.1+y e.1=0 + simp only [hx,hy,add_zero] + neg_mem' {x} hx := by + change x e.1=0 at hx + change -x e.1=0 + simp only [hx,neg_zero] + +abbrev HorizontalSpace {d : ℕ} (e : Direction d) := horizontalSubgroup e + +abbrev ActualEpisodeArray {d : ℕ} (e : Direction d) := + StationaryCompact.EpisodeArray (HorizontalSpace e) (Row d) + +instance actualArray_compact {d : ℕ} (e : Direction d) : CompactSpace (ActualEpisodeArray e) := inferInstance +instance actualArray_metrizable {d : ℕ} (e : Direction d) : MetrizableSpace (ActualEpisodeArray e) := inferInstance + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayClassProbability.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayClassProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8c4c86d770b9d8f890649e4a349cc5d44597b9d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayClassProbability.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.ArrayGrowthEvent +import OAI.Probability.Ballisticity.Entropy.EntropyEvent +import OAI.Probability.Ballisticity.Stationary.ArrayMassSurvival +import OAI.Probability.Ballisticity.Estimates.EventRate + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma class_selection_probability (L : StationaryArrayLaw ν e) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) + {lam : ℝ} (hlam : 0 ν))<⊤) (n : ℕ) (hn : 0 ν))^n + have hM : M≠⊤ := ENNReal.pow_ne_top hmean.ne + let B : ℕ → Set (ActualEpisodeArray e) := fun k => {Y | + ENNReal.ofReal (Real.exp (a*(G.sequence k:ℝ)))≤ selectedClassProduct e n r lam + (typedCurrentArrayWindow e 0 (G.sequence k) Y)} + have hB (k : ℕ) : MeasurableSet (B k) := measurableSet_le measurable_const + ((selectedClassProduct_measurable e n r lam).comp (typedCurrentArrayWindow_measurable e 0 _)) + have hbound (k : ℕ) : μ.real (B k)*(a*(G.sequence k:ℝ))≤ + max L.entropyConstant 0*(G.sequence k:ℝ)+M.toReal := by + let F := typedCurrentArrayWindow e 0 (G.sequence k) + let W := μ.map F + have hmF : Measurable F := typedCurrentArrayWindow_measurable e 0 _ + have : IsProbabilityMeasure W := + (Measure.isProbabilityMeasure_map_iff hmF.aemeasurable).mpr inferInstance + have he : klDiv W (W.fst.compProd (currentWindowReference e ν))≤ + ENNReal.ofReal (max L.entropyConstant 0*(G.sequence k:ℝ)) := by + apply (L.entropy 0 (G.sequence k)).trans + apply ENNReal.ofReal_le_ofReal + nlinarith [le_max_left L.entropyConstant 0,show (0:ℝ)≤(G.sequence k:ℝ) from Nat.cast_nonneg _] + have hh := Entropy.event_moment_budget W (W.fst.compProd (currentWindowReference e ν)) + (mul_nonneg (le_max_right _ _) (Nat.cast_nonneg _)) he _ (selectedClassProduct_measurable e n r lam) hM + (selectedClassProduct_lintegral e ν W.fst n r lam) (a*(G.sequence k:ℝ)) + change ((μ.map F) {w | ENNReal.ofReal (Real.exp (a*(G.sequence k:ℝ)))≤ selectedClassProduct e n r lam w}).toReal * _ ≤ _ at hh + rw [Measure.map_apply hmF (measurableSet_le measurable_const + (selectedClassProduct_measurable e n r lam))] at hh + exact hh + apply event_rate μ _ (G.measurable_event.inter + ((current_selection_event_measurable e n r).preimage (arrayCurrentData_measurable e 0))) B hB + G.sequence G.strictMono.tendsto_atTop ha (le_max_right _ _) hbound + have hq := array_dust_reference_facts e ν htrans μ L.consistent L.zero_sampling L.entropy_finite + have hexp : ∀ᶠ k in atTop, Real.exp (-(G.ζ*(G.sequence k:ℝ)/2))≤r := by + have ht : Tendsto (fun k => G.ζ*(G.sequence k:ℝ)/2) atTop atTop := by + have hh := (tendsto_natCast_atTop_atTop.comp G.strictMono.tendsto_atTop).const_mul_atTop G.positive_ζ + exact Tendsto.atTop_div_const (by norm_num) hh + exact (Real.tendsto_exp_neg_atTop_nhds_zero.comp ht).eventually (ge_mem_nhds hr) + filter_upwards [L.consistent,L.continuation,L.finite_marks,hq,G.growth] with Y hP hc hf hq hg hY + filter_upwards [hg hY.1,hexp] with k hk hkr + have hHfin : arrayWindowHeight e 0 (G.sequence k) Y≠⊤ := + ENat.sum_ne_top.mpr fun j _ => (hf (0+j)).2.1.ne + have hcfin : arrayWindowCost e 0 (G.sequence k) Y≠⊤ := + ENNReal.sum_ne_top.mpr fun j _ => (hf (0+j)).2.2.2.ne + have hh := array_selectedProduct_lower e Y hP.2 hc 0 (G.sequence k) + (arrayWindowHeight e 0 (G.sequence k) Y).toNat n (ENat.natCast_toNat hHfin).symm hcfin + (fun a => (hq 0 (G.sequence k)).2 a _) hr hlam.le (by linarith) hkr hY.2 + change ENNReal.ofReal (Real.exp (a*(G.sequence k:ℝ)))≤_ + convert hh using 1 + congr 2 + unfold a + ring + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayClosed.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayClosed.lean new file mode 100644 index 0000000000000000000000000000000000000000..2535e36b5af60dd691984a04b306a5c0db08cf3c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayClosed.lean @@ -0,0 +1,214 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.WindowProjection +import OAI.Probability.Ballisticity.Estimates.OccupationSampling + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma closed_support_weak_limit {X : Type*} [MeasurableSpace X] [TopologicalSpace X] + [BorelSpace X] [HasOuterApproxClosed X] + (μ : ℕ → ProbabilityMeasure X) (ρ : ProbabilityMeasure X) + (hlim : Tendsto μ atTop (𝓝 ρ)) (s : Set X) (hs : IsClosed s) + (hμ : ∀ n, ∀ᵐ x ∂(μ n : Measure X), x∈s) : + ∀ᵐ x ∂(ρ : Measure X), x∈s := by + have he (n : ℕ) : (μ n : Measure X) s=1 := + (mem_ae_iff_prob_eq_one hs.measurableSet).mp (hμ n) + have hle := ProbabilityMeasure.limsup_measure_closed_le_of_tendsto hlim hs + simp only [he,limsup_const] at hle + exact (mem_ae_iff_prob_eq_one hs.measurableSet).mpr + (le_antisymm prob_le_one hle) + +lemma actualOccupation_ae_of_invariant {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (s : Set (ActualEpisodeArray e)) (hs : MeasurableSet s) + (ha : ∀ X, actualArrayMap e t J X∈s) + (hshift : ∀ Y∈s, StationaryCompact.shift Y∈s) : + ∀ᵐ Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)), Y∈s := by + have hiter (i : ℕ) (X : EpisodeInput e) : + StationaryCompact.shift^[i] (actualArrayMap e t J X)∈s := by + induction i with + | zero => exact ha X + | succ i hi => + rw [Function.iterate_succ_apply'] + exact hshift _ hi + have hraw : ∀ᵐ Y ∂actualOccupationRaw e ν Q t J ht N M, Y∈s := by + unfold actualOccupationRaw StationaryCompact.episodeOccupationRaw + rw [ae_finsetSum_measure_iff] + intro i _ + apply (ae_map_iff ((StationaryCompact.shift_continuous.measurable.iterate i).comp + (actualArrayMap_measurable e t J ht hJ)).aemeasurable hs).mpr + exact Filter.Eventually.of_forall (hiter i) + have : Nonempty (Row d) := nonempty_of_isProbabilityMeasure ν + let ρ : FiniteMeasure (ActualEpisodeArray e) := ⟨actualOccupationRaw e ν Q t J ht N M,inferInstance⟩ + have hn : ρ≠0 := by + intro hz + have hh : (actualOccupationRaw e ν Q t J ht N M).real Set.univ=0 := by + change (ρ : Measure (ActualEpisodeArray e)).real Set.univ=0 + rw [hz] + simp + linarith + change ∀ᵐ Y ∂(ρ.normalize : Measure (ActualEpisodeArray e)), Y∈s + rw [ρ.toMeasure_normalize_eq_of_nonzero hn] + exact Measure.ae_smul_measure hraw _ + +noncomputable def currentOffsets {d : ℕ} (e : Direction d) (j : ℤ) + (Y : ActualEpisodeArray e) : ReferenceClasses.Offsets (HorizontalSpace e) := + fun p => Y.2.1 ((j,p.1),(j,p.2)) + +lemma currentOffsets_continuous {d : ℕ} (e : Direction d) (j : ℤ) : + Continuous (currentOffsets e j) := by + unfold currentOffsets + fun_prop + +lemma currentOffsets_closed {d : ℕ} (e : Direction d) : + IsClosed {Y : ActualEpisodeArray e | ∀ j, ReferenceClasses.Consistent (currentOffsets e j Y)} := by + simp only [Set.ofPred_forall] + exact isClosed_iInter fun j => ReferenceClasses.consistent_closed.preimage + (currentOffsets_continuous e j) + +lemma actual_currentOffsets {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (X : EpisodeInput e) (j : ℤ) : + ReferenceClasses.Consistent (currentOffsets e j (actualArrayMap e t J X)) := by + constructor + · intro a + simp [currentOffsets,actualArrayMap] + · intro a b z h + have he : X.1.2 (j,b)-X.1.2 (j,a)=z := OnePoint.coe_injective h + change ((X.1.2 (j,a)-X.1.2 (j,b) : HorizontalSpace e):OnePoint (HorizontalSpace e))=((-z : HorizontalSpace e):OnePoint (HorizontalSpace e)) + rw [←he,neg_sub] + · intro a b c z w h₁ h₂ + have h₁ : X.1.2 (j,b)-X.1.2 (j,a)=z := OnePoint.coe_injective h₁ + have h₂ : X.1.2 (j,c)-X.1.2 (j,b)=w := OnePoint.coe_injective h₂ + change ((X.1.2 (j,c)-X.1.2 (j,a) : HorizontalSpace e):OnePoint (HorizontalSpace e))=((z+w : HorizontalSpace e):OnePoint (HorizontalSpace e)) + rw [←h₁,←h₂] + congr 1 + abel + +lemma actualOccupation_currentOffsets {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) : + ∀ᵐ Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)), + ∀ j, ReferenceClasses.Consistent (currentOffsets e j Y) := by + apply actualOccupation_ae_of_invariant e ν Q t J ht hJ N M hpos _ + (currentOffsets_closed e).measurableSet (actual_currentOffsets e t J) + intro Y hY j + exact hY (j+1) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped ENNReal Classical +namespace DirectionalTransience + +abbrev AmbientCurrentWindow {d : ℕ} (e : Direction d) := + (ReferenceClasses.Offsets (HorizontalSpace e) × CurrentProfiles e) × + ReferenceClasses.AllFields (HorizontalSpace e) (Row d) + +instance currentOffsets_secondCountable {d : ℕ} (e : Direction d) : + SecondCountableTopology (ReferenceClasses.Offsets (HorizontalSpace e)) := inferInstance +instance currentData_secondCountable {d : ℕ} (e : Direction d) : + SecondCountableTopology (ReferenceClasses.Data (HorizontalSpace e)) := + Subtype.secondCountableTopology {O : ReferenceClasses.Offsets (HorizontalSpace e) | ReferenceClasses.Consistent O} +instance currentProfiles_secondCountable {d : ℕ} (e : Direction d) : + SecondCountableTopology (CurrentProfiles e) := inferInstance +instance currentFields_secondCountable {d : ℕ} (e : Direction d) : + SecondCountableTopology (ReferenceClasses.AllFields (HorizontalSpace e) (Row d)) := inferInstance +instance ambientCurrentWindow_borel {d : ℕ} (e : Direction d) : + BorelSpace (AmbientCurrentWindow e) := inferInstance +instance currentWindow_borel {d : ℕ} (e : Direction d) : + BorelSpace (CurrentWindow e) := inferInstance + +def currentWindowInclude {d : ℕ} (e : Direction d) (W : CurrentWindow e) : AmbientCurrentWindow e := + ((W.1.1.1,W.1.2),W.2) + +lemma currentWindowInclude_continuous {d : ℕ} (e : Direction d) : + Continuous (currentWindowInclude e) := by unfold currentWindowInclude; fun_prop + +lemma currentWindowInclude_injective {d : ℕ} (e : Direction d) : + Function.Injective (currentWindowInclude e) := by + intro W W' h + have h1 : W.1.1.1=W'.1.1.1 := congrArg (fun p => p.1.1) h + have h2 : W.1.2=W'.1.2 := congrArg (fun p => p.1.2) h + have h3 : W.2=W'.2 := congrArg (fun p => p.2) h + exact Prod.ext (Prod.ext (Subtype.ext h1) h2) h3 + +noncomputable def currentArrayWindow {d : ℕ} (e : Direction d) (j : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) : AmbientCurrentWindow e := + ((currentOffsets e j Y,fun p => Y.2.2.1 (j,(j,p.1),p.2)), + fun p => Y.2.2.2 (j,m,p.1,p.2.1,p.2.2)) + +lemma currentArrayWindow_continuous {d : ℕ} (e : Direction d) (j : ℤ) (m : ℕ) : + Continuous (currentArrayWindow e j m) := by + unfold currentArrayWindow currentOffsets + fun_prop + +lemma currentArrayWindow_actual {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (j : ℤ) (m : ℕ) (X : EpisodeInput e) : + currentArrayWindow e j m (actualArrayMap e t J X) = + currentWindowInclude e (actualCurrentWindow e t j m X) := rfl + +lemma currentArrayWindow_shift {d : ℕ} (e : Direction d) (j : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) : + currentArrayWindow e j m (StationaryCompact.shift Y) = currentArrayWindow e (j+1) m Y := rfl + +lemma currentArrayWindow_iterate {d : ℕ} (e : Direction d) (j : ℤ) (m i : ℕ) + (Y : ActualEpisodeArray e) : + currentArrayWindow e j m (StationaryCompact.shift^[i] Y) = currentArrayWindow e (j+i) m Y := by + induction i generalizing Y with + | zero => simp + | succ i hi => + rw [Function.iterate_succ_apply,hi,currentArrayWindow_shift] + simp only [Nat.cast_add,Nat.cast_one,add_assoc] + +noncomputable def typedCurrentArrayWindow {d : ℕ} (e : Direction d) (j : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) : CurrentWindow e := + ((if h : ReferenceClasses.Consistent (currentOffsets e j Y) then + ⟨currentOffsets e j Y,h⟩ else ReferenceClasses.anchorOffsets (fun _ => 0), + (currentArrayWindow e j m Y).1.2),(currentArrayWindow e j m Y).2) + +lemma typedCurrentArrayWindow_measurable {d : ℕ} (e : Direction d) (j : ℤ) (m : ℕ) : + Measurable (typedCurrentArrayWindow e j m) := by + have hs : MeasurableSet {Y : ActualEpisodeArray e | ReferenceClasses.Consistent (currentOffsets e j Y)} := + (ReferenceClasses.consistent_closed.preimage (currentOffsets_continuous e j)).measurableSet + have ho : Measurable (fun Y : ActualEpisodeArray e => + if h : ReferenceClasses.Consistent (currentOffsets e j Y) then + (⟨currentOffsets e j Y,h⟩ : ReferenceClasses.Data (HorizontalSpace e)) + else ReferenceClasses.anchorOffsets (fun _ => 0)) := by + apply (MeasurableEmbedding.subtype_coe ReferenceClasses.consistent_closed.measurableSet).measurable_comp_iff.mp + simp only [Function.comp_def,apply_dite] + change Measurable (fun Y => if ReferenceClasses.Consistent (currentOffsets e j Y) then + currentOffsets e j Y else (ReferenceClasses.anchorOffsets (fun _ : ℕ => (0 : HorizontalSpace e))).1) + exact Measurable.ite hs (currentOffsets_continuous e j).measurable measurable_const + exact (ho.prodMk ((currentArrayWindow_continuous e j m).measurable.fst.snd)).prodMk + (currentArrayWindow_continuous e j m).measurable.snd + +lemma currentWindowInclude_typed {d : ℕ} (e : Direction d) (j : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) (h : ReferenceClasses.Consistent (currentOffsets e j Y)) : + currentWindowInclude e (typedCurrentArrayWindow e j m Y) = currentArrayWindow e j m Y := by + simp only [typedCurrentArrayWindow,dite_eq_left h,currentWindowInclude,currentArrayWindow] + +lemma typedCurrentArrayWindow_actual {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (j : ℤ) (m : ℕ) (X : EpisodeInput e) : + typedCurrentArrayWindow e j m (actualArrayMap e t J X) = actualCurrentWindow e t j m X := by + apply currentWindowInclude_injective e + rw [currentWindowInclude_typed e j m _ (actual_currentOffsets e t J X j),currentArrayWindow_actual] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayDust.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayDust.lean new file mode 100644 index 0000000000000000000000000000000000000000..02d4951393cdea9a058e0a7aa27c5108f59cf747 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayDust.lean @@ -0,0 +1,209 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayProfileConsistency +import OAI.Probability.Ballisticity.Estimates.SurvivalLimit +import OAI.Probability.Ballisticity.Stationary.ArrayPermutation +import OAI.Probability.Ballisticity.Estimates.Dust + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +def arrayDust {d : ℕ} (e : Direction d) (i : ℤ) (a : ℕ) (Y : ActualEpisodeArray e) : Prop := + (Y.2.2.1 (i,(i,a),0):ℝ)=0 + +lemma arrayDust_measurable {d : ℕ} (e : Direction d) (i : ℤ) (a : ℕ) : + MeasurableSet {Y : ActualEpisodeArray e | arrayDust e i a Y} := by + exact (show Measurable (fun Y : ActualEpisodeArray e => (Y.2.2.1 (i,(i,a),0):ℝ)) from by fun_prop) + (measurableSet_singleton 0) + +noncomputable def arrayDustFrequency {d : ℕ} (e : Direction d) (i : ℤ) (n : ℕ) + (Y : ActualEpisodeArray e) : ℝ := ReferenceClasses.dustFrequency (fun a => arrayDust e i a Y) n + +lemma currentDust_array {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) (Y : ActualEpisodeArray e) (a : ℕ) : + currentDust e (typedCurrentArrayWindow e i m Y).1 a ↔ arrayDust e i a Y := Iff.rfl + +lemma currentDustFrequency_array {d : ℕ} (e : Direction d) (i : ℤ) (m n : ℕ) (Y : ActualEpisodeArray e) : + currentDustFrequency e n (typedCurrentArrayWindow e i m Y).1 = arrayDustFrequency e i n Y := rfl + +lemma arrayDustFrequency_nonneg {d : ℕ} (e : Direction d) (i : ℤ) (n : ℕ) (Y : ActualEpisodeArray e) : + 0≤arrayDustFrequency e i n Y := by + unfold arrayDustFrequency ReferenceClasses.dustFrequency + positivity + +lemma arrayDust_current_isolated {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) (Y : ActualEpisodeArray e) + (hO : ArrayOffsetsConsistent e Y) (hP : ArrayProfilesConsistent e Y) + (hzero : ∀ p q z, p≠q → arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0) : + ∀ a, currentDust e (typedCurrentArrayWindow e i m Y).1 a → ∀ b, + ReferenceClasses.related (typedCurrentArrayWindow e i m Y).1.1 a b → a=b := by + intro a ha b hr + by_contra hab + obtain ⟨z,hz⟩ := hr + have ho : ReferenceClasses.Consistent (currentOffsets e i Y) := hO (fun a => (i,a)) + have hz' : Y.2.1 ((i,a),(i,b))=(z:OnePoint (HorizontalSpace e)) := by + simpa only [typedCurrentArrayWindow,dite_eq_left ho,currentOffsets] using hz + exact dust_isolated e Y hO hP hzero (i,a) (i,b) (by simpa using hab) ha z hz' + +lemma arraySurvivalAverage_le_one {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) + (hn : 0 hk a)] + calc + _ ≤ (n:ℝ)⁻¹*∑ _a∈Finset.range n, (1:ℝ) := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum fun a _ => by + simpa only [ENNReal.toReal_one] using ENNReal.toReal_mono ENNReal.one_ne_top + (upperHorizontalKernel_mass_le_one e H (arrayUpperRows e i m a Y) 0)) (by positivity) + _ = 1 := by simp [hn.ne'] + +lemma arrayDustWeight_le_survival {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) + (Y : ActualEpisodeArray e) + (h : ∀ a, upperNoDrop e (arrayUpperRows e i m a Y)≤ + upperHorizontalKernel e H (arrayUpperRows e i m a Y) 0 Set.univ) : + currentDustWeight e n (typedCurrentArrayWindow e i m Y)≤arraySurvivalAverage e i m H n Y := by + have hk (a : ℕ) : upperHorizontalKernel e H (arrayUpperRows e i m a Y) 0 Set.univ≠⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top (upperHorizontalKernel_mass_le_one e H _ 0) + rw [arraySurvivalAverage,arraySurvivalSum,ENNReal.toReal_sum (fun a _ => hk a)] + unfold currentDustWeight ReferenceClasses.dustWeight sampleAverage + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Finset.sum_le_sum + intro a _ + dsimp only + split_ifs + · exact ENNReal.toReal_mono (hk a) (h a) + · exact ENNReal.toReal_nonneg + +lemma array_dust_reference_facts {d : ℕ} (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (htrans : DirectionallyTransient ν (realPosition (step e))) + (μ : Measure (ActualEpisodeArray e)) [IsProbabilityMeasure μ] + (hconsistent : ∀ᵐ Y ∂μ, ArrayOffsetsConsistent e Y ∧ ArrayProfilesConsistent e Y) + (hzero : ∀ᵐ Y ∂μ, ∀ p q z, p≠q → arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0) + (hentropy : ∀ i m, let W:=μ.map (typedCurrentArrayWindow e i m) + klDiv W (W.fst.compProd (currentWindowReference e ν))≠⊤) : + ∀ᵐ Y ∂μ, ∀ (i : ℤ) (m : ℕ), + Tendsto (fun r : ℕ => currentDustWeight e (2^r) (typedCurrentArrayWindow e i m Y)- + upperNoDropMean e ν*arrayDustFrequency e i (2^r) Y) atTop (𝓝 0) ∧ + ∀ a H : ℕ, upperNoDrop e (arrayUpperRows e i m a Y)≤ + upperHorizontalKernel e H (arrayUpperRows e i m a Y) 0 Set.univ := by + apply ae_all_iff.mpr + intro i + apply ae_all_iff.mpr + intro m + let F := typedCurrentArrayWindow e i m + let W := μ.map F + have hm : Measurable F := typedCurrentArrayWindow_measurable e i m + have : IsProbabilityMeasure W := (Measure.isProbabilityMeasure_map_iff hm.aemeasurable).mpr inferInstance + have hi : ∀ᵐ A ∂W.fst, ∀ a, currentDust e A a → ∀ b, ReferenceClasses.related A.1 a b → a=b := by + change ∀ᵐ A ∂(μ.map F).map Prod.fst, _ + rw [Measure.map_map measurable_fst hm] + apply (ae_map_iff ((measurable_fst.comp hm).aemeasurable) _).mpr + · filter_upwards [hconsistent,hzero] with Y hY hz + exact arrayDust_current_isolated e i m Y hY.1 hY.2 hz + · simp only [Set.ofPred_forall] + refine MeasurableSet.iInter fun a => (currentDust_measurable e a).imp ?_ + simp only [Set.ofPred_forall] + refine MeasurableSet.iInter fun b => ((ReferenceClasses.measurable_related a b).preimage measurable_fst).imp ?_ + by_cases hab : a=b <;> simp [hab] + have hc := current_reference_dust_law e ν W hi (hentropy i m) + have hq := current_reference_nodrop_le e ν htrans W (hentropy i m) + have hv := ae_of_ae_map hm.aemeasurable (hc.and hq) + exact hv + +lemma array_dust_frequency_zero {d : ℕ} (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (htrans : DirectionallyTransient ν (realPosition (step e))) + (Y : ActualEpisodeArray e) (i : ℤ) + (href : ∀ m, Tendsto (fun r : ℕ => currentDustWeight e (2^r) (typedCurrentArrayWindow e i m Y)- + upperNoDropMean e ν*arrayDustFrequency e i (2^r) Y) atTop (𝓝 0) ∧ + ∀ a H : ℕ, upperNoDrop e (arrayUpperRows e i m a Y)≤ + upperHorizontalKernel e H (arrayUpperRows e i m a Y) 0 Set.univ) + (hmarks : ∀ j, (Y.1 j).1<⊤) (hsurv : ArrayAveragedSurvival e Y) + (hcost : ∀ ε : ℝ, 0<ε → ∃ m, (expNeg (arrayWindowCost e i m Y)).toReal<ε) : + Tendsto (fun r : ℕ => arrayDustFrequency e i (2^r) Y) atTop (𝓝 0) := by + have hfin (m : ℕ) : arrayWindowHeight e i m Y≠⊤ := by + unfold arrayWindowHeight + exact (ENat.sum_ne_top).mpr fun j hj => (hmarks (i+j)).ne + let H := fun m => (arrayWindowHeight e i m Y).toNat + have hH (m : ℕ) : arrayWindowHeight e i m Y=(H m:ℕ∞) := (ENat.natCast_toNat (hfin m)).symm + apply average_zero_of_survival (upperNoDropMean e ν) (upperNoDropMean_pos e ν hue htrans) + _ (fun r => arrayDustFrequency_nonneg e i _ Y) + (fun m r => arraySurvivalAverage e i m (H m) (2^r) Y) + (fun m r => currentDustWeight e (2^r) (typedCurrentArrayWindow e i m Y)) + (fun m => (expNeg (arrayWindowCost e i m Y)).toReal) + · intro m + exact isBoundedUnder_of_eventually_le (Eventually.of_forall fun r => arraySurvivalAverage_le_one e i m (H m) (2^r) (by positivity) Y) + · exact fun m r => arrayDustWeight_le_survival e i m (H m) _ Y (fun a => (href m).2 a (H m)) + · exact fun m => (href m).1 + · exact fun m => hsurv i m (H m) (hH m) + · exact hcost + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma arrayDust_perm {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) (i : ℤ) (a : ℕ) + (Y : ActualEpisodeArray e) : arrayDust e i a (arrayPerm e σ Y) ↔ arrayDust e i (σ a) Y := Iff.rfl + +lemma array_no_dust_on_frequency_zero {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (i : ℤ) (E : Set (ActualEpisodeArray e)) (hE : MeasurableSet E) + (hperm : ∀ σ, MeasurePreserving (arrayPerm e σ) μ μ) + (hEinv : ∀ σ, ∀ᵐ Y ∂μ, arrayPerm e σ Y∈E ↔ Y∈E) + (hfreq : ∀ᵐ Y ∂μ, Y∈E → Tendsto (fun r : ℕ => arrayDustFrequency e i (2^r) Y) atTop (𝓝 0)) : + ∀ᵐ Y ∂μ, Y∈E → ∀ a, ¬arrayDust e i a Y := by + let I : ℕ → ActualEpisodeArray e → ℝ := fun a Y => if Y∈E ∧ arrayDust e i a Y then 1 else 0 + have hm (a : ℕ) : Measurable (I a) := Measurable.ite (hE.inter (arrayDust_measurable e i a)) measurable_const measurable_const + have hb (a : ℕ) (Y : ActualEpisodeArray e) : I a Y∈Set.Icc 0 1 := by dsimp [I]; split_ifs <;> norm_num + have hmean (a : ℕ) : (∫ Y, I a Y ∂μ)=∫ Y, I 0 Y ∂μ := by + let σ := Equiv.swap 0 a + have he : (fun Y => I 0 (arrayPerm e σ Y))=ᵐ[μ] I a := by + filter_upwards [hEinv σ] with Y hY + dsimp only [I] + rw [hY,arrayDust_perm,Equiv.swap_apply_left] + calc + _ = ∫ Y, I 0 (arrayPerm e σ Y) ∂μ := (integral_congr_ae he).symm + _ = ∫ Y, I 0 Y ∂μ := by + rw [←integral_map (hperm σ).measurable.aemeasurable (hm 0).aestronglyMeasurable,(hperm σ).map_eq] + have hav : ∀ᵐ Y ∂μ, Tendsto (fun r : ℕ => ((2^r:ℕ):ℝ)⁻¹*∑ a∈Finset.range (2^r), I a Y) atTop (𝓝 0) := by + filter_upwards [hfreq] with Y hY + by_cases hy : Y∈E + · simpa only [I,hy,true_and,arrayDustFrequency,ReferenceClasses.dustFrequency] using hY hy + · simp only [I,hy,false_and,ite_false,Finset.sum_const_zero,mul_zero] + exact tendsto_const_nhds + have hz := symmetric_indicator_zero_of_average μ I hm hb hmean (fun r => 2^r) (fun r => by positivity) hav + filter_upwards [hz] with Y hY hy a ha + have hh := hY a + simp only [I,hy,ha,and_self,ite_true] at hh + norm_num at hh + +lemma array_no_dust_on_cost_decay {d : ℕ} (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (htrans : DirectionallyTransient ν (realPosition (step e))) + (μ : Measure (ActualEpisodeArray e)) [IsProbabilityMeasure μ] + (hconsistent : ∀ᵐ Y ∂μ, ArrayOffsetsConsistent e Y ∧ ArrayProfilesConsistent e Y) + (hzero : ∀ᵐ Y ∂μ, ∀ p q z, p≠q → arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0) + (hentropy : ∀ i m, let W:=μ.map (typedCurrentArrayWindow e i m) + InformationTheory.klDiv W (W.fst.compProd (currentWindowReference e ν))≠⊤) + (hmarks : ∀ᵐ Y ∂μ, ∀ j, (Y.1 j).1<⊤) + (hsurv : ∀ᵐ Y ∂μ, ArrayAveragedSurvival e Y) + (hperm : ∀ σ, MeasurePreserving (arrayPerm e σ) μ μ) + (i : ℤ) (E : Set (ActualEpisodeArray e)) (hE : MeasurableSet E) + (hEinv : ∀ σ, ∀ᵐ Y ∂μ, arrayPerm e σ Y∈E ↔ Y∈E) + (hcost : ∀ᵐ Y ∂μ, Y∈E → ∀ ε : ℝ, 0<ε → ∃ m, (expNeg (arrayWindowCost e i m Y)).toReal<ε) : + ∀ᵐ Y ∂μ, Y∈E → ∀ a, ¬arrayDust e i a Y := by + apply array_no_dust_on_frequency_zero e μ i E hE hperm hEinv + have href := array_dust_reference_facts e ν htrans μ hconsistent hzero hentropy + filter_upwards [href,hmarks,hsurv,hcost] with Y hr hm hs hc hY + exact array_dust_frequency_zero e ν hue htrans Y i (hr i) hm hs (hc hY) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayFiniteClasses.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayFiniteClasses.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5e5f760f0e87db29ba7dde3d915d4f606e781ba --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayFiniteClasses.lean @@ -0,0 +1,183 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.ArrayGrowthEvent +import OAI.Probability.Ballisticity.Stationary.ArrayClassProbability +import OAI.Probability.Ballisticity.Stationary.ArrayMassSurvival +import OAI.Probability.Ballisticity.Estimates.EventRate +import OAI.Probability.Ballisticity.Estimates.FiniteClasses + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma finite_current_classes (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → CurrentFiniteClasses e (arrayCurrentData e 0 Y) := by + let μ := (L.law : Measure (ActualEpisodeArray e)) + let A := G.event ∩ {Y | ¬CurrentFiniteClasses e (arrayCurrentData e 0 Y)} + have hA : MeasurableSet A := G.measurable_event.inter + (((currentFiniteClasses_measurable e).preimage (arrayCurrentData_measurable e 0)).compl) + obtain ⟨lam,hlam,hmean⟩ := upperNoDrop_inverse_moment e ν hue htrans + have hprob (n : ℕ) (hn : 0 G.event ∩ + {Y | ∃ a, CurrentClassSelection e n (1/((k:ℝ)+1)) (arrayCurrentData e 0 Y) a} + have hB (k : ℕ) : MeasurableSet (B k) := G.measurable_event.inter + ((current_selection_event_measurable e n _).preimage (arrayCurrentData_measurable e 0)) + have he : ∀ᵐ Y ∂μ, Y∈A → ∀ᶠ k in atTop, Y∈B k := by + filter_upwards [G.no_dust] with Y hY hy + have hp (a : ℕ) : 0<((arrayCurrentData e 0 Y).2 (a,0):ℝ) := by + have hn : ((arrayCurrentData e 0 Y).2 (a,0):ℝ)≠0 := hY hy.1 0 a + exact lt_of_le_of_ne ((arrayCurrentData e 0 Y).2 (a,0)).property.1 hn.symm + have hh := infinite_current_selection_eventually e (arrayCurrentData e 0 Y) hy.2 hp n + filter_upwards [hh] with k hk + exact ⟨hy.1,hk⟩ + have hb (k : ℕ) : μ (B k)≤ENNReal.ofReal (max L.entropyConstant 0 / ((n:ℝ)*lam*G.ζ/2)) := by + rw [←ENNReal.ofReal_toReal (measure_ne_top μ (B k))] + exact ENNReal.ofReal_le_ofReal (L.class_selection_probability htrans G hlam hmean n hn _ (by positivity)) + have hh := (measure_le_liminf_of_ae_eventually μ A hA B hB he).trans + (liminf_le_liminf (Eventually.of_forall hb)) + rw [liminf_const] at hh + exact ENNReal.toReal_le_of_le_ofReal (div_nonneg (le_max_right _ _) + (div_nonneg (mul_nonneg (mul_nonneg (Nat.cast_nonneg _) hlam.le) G.positive_ζ.le) (by norm_num))) hh + have ht : Tendsto (fun n : ℕ => max L.entropyConstant 0 / ((n:ℝ)*lam*G.ζ/2)) atTop (𝓝 (0:ℝ)) := by + have hi : Tendsto (fun n : ℕ => (n:ℝ)*lam*G.ζ/2) atTop atTop := + Tendsto.atTop_div_const (by norm_num) (((tendsto_natCast_atTop_atTop).atTop_mul_const hlam).atTop_mul_const G.positive_ζ) + exact hi.const_div_atTop _ + have hz : μ.real A=0 := le_antisymm (le_of_tendsto_of_tendsto tendsto_const_nhds ht + ((eventually_gt_atTop 0).mono fun n hn => hprob n hn)) measureReal_nonneg + have hmzero : μ A=0 := ((ENNReal.toReal_eq_zero_iff (μ A)).mp hz).resolve_right (measure_ne_top μ A) + have hnot : ∀ᵐ Y ∂μ, Y∉A := ae_iff.mpr (by simpa using hmzero) + exact hnot.mono (by intro Y hY hE; by_contra hf; exact hY ⟨hE,hf⟩) + +lemma finite_classes_all_times (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → + ∀ i, CurrentFiniteClasses e (arrayCurrentData e i Y) := by + have hh := stationary_ae_integer_family (L.law : Measure (ActualEpisodeArray e)) L.preserving + (fun i Y => Y∈G.event → CurrentFiniteClasses e (arrayCurrentData e i Y)) + (fun i => G.measurable_event.imp ((currentFiniteClasses_measurable e).preimage + (arrayCurrentData_measurable e i))) + (fun i => G.invariant.mono fun Y hY => by rw [hY]; rfl) + (L.finite_current_classes hue htrans G) + filter_upwards [hh] with Y hY hy i + exact hY i hy + +end StationaryArrayLaw +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical BigOperators Topology +namespace DirectionalTransience + +def ArrayRelated {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (p q : StationaryCompact.Label) : Prop := ∃ z : HorizontalSpace e, + Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e)) + +lemma arrayRelated_measurable {d : ℕ} (e : Direction d) (p q : StationaryCompact.Label) : + MeasurableSet {Y : ActualEpisodeArray e | ArrayRelated e Y p q} := by + simp only [ArrayRelated,Set.ofPred_exists] + exact MeasurableSet.iUnion fun z => measurableSet_eq_fun (by fun_prop) measurable_const + +lemma array_offset_self {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) (p : StationaryCompact.Label) : + Y.2.1 (p,p)=(0:HorizontalSpace e) := by + exact (h (fun _ => p)).self 0 + +lemma array_offset_add {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) (p q r : StationaryCompact.Label) + (z w : HorizontalSpace e) (hz : Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e))) + (hw : Y.2.1 (q,r)=(w:OnePoint (HorizontalSpace e))) : + Y.2.1 (p,r)=((z+w:HorizontalSpace e):OnePoint (HorizontalSpace e)) := by + let E := Denumerable.eqv StationaryCompact.Label + have hs := (h E.symm).add (E p) (E q) (E r) z w + simpa only [selectedOffsets,Equiv.symm_apply_apply] using hs + (by simpa [selectedOffsets] using hz) (by simpa [selectedOffsets] using hw) + +lemma arrayRelated_refl {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) (p : StationaryCompact.Label) : ArrayRelated e Y p p := + ⟨0,array_offset_self e Y h p⟩ +lemma arrayRelated_symm {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) {p q : StationaryCompact.Label} + (hpq : ArrayRelated e Y p q) : ArrayRelated e Y q p := by + obtain ⟨z,hz⟩ := hpq + exact ⟨-z,array_offset_symm e Y h p q z hz⟩ +lemma arrayRelated_trans {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) {p q r : StationaryCompact.Label} + (hpq : ArrayRelated e Y p q) (hqr : ArrayRelated e Y q r) : ArrayRelated e Y p r := by + obtain ⟨z,hz⟩ := hpq + obtain ⟨w,hw⟩ := hqr + exact ⟨z+w,array_offset_add e Y h p q r z w hz hw⟩ + +lemma arrayRelated_current {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) (i : ℤ) (a b : ℕ) : + ReferenceClasses.related (arrayCurrentData e i Y).1 a b ↔ ArrayRelated e Y (i,a) (i,b) := by + have ho : ReferenceClasses.Consistent (currentOffsets e i Y) := h (fun a => (i,a)) + simp only [arrayCurrentData,typedCurrentArrayWindow,dite_eq_left ho,ReferenceClasses.related, + ArrayRelated,currentOffsets] + +lemma array_positive_coordinate_represented {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hs : ∀ p j z, Tendsto (fun n => arraySamplingError e p j z (2^n) Y) atTop (𝓝 0)) + (p : StationaryCompact.Label) (j : ℤ) (z : HorizontalSpace e) + (hp : 0<(Y.2.2.1 (j,p,z):ℝ)) : + ∃ b, Y.2.1 (p,(j,b))=(z:OnePoint (HorizontalSpace e)) := by + by_contra h + have hn : ∀ b, Y.2.1 (p,(j,b))≠(z:OnePoint (HorizontalSpace e)) := by simpa using h + have he (n : ℕ) : arraySamplingError e p j z (2^n) Y=-(Y.2.2.1 (j,p,z):ℝ) := by + simp [arraySamplingError,arrayOffsetTest,arrayProfileTest,finiteOffsetTest,hn] + have hlim := hs p j z + simp_rw [he] at hlim + have hz := tendsto_nhds_unique hlim tendsto_const_nhds + linarith + +lemma array_next_full {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (κ : ℝ≥0) (hκ : 0<κ) (he : ArrayElliptic e κ Y) (hc : ArrayContinuation e Y) + (hm : ∀ i, 0<(Y.1 i).1 ∧ (Y.1 i).1<⊤) + (i : ℤ) (a : ℕ) (ha : 0<(Y.2.2.1 (i,(i,a),0):ℝ)) (z : HorizontalSpace e) : + 0<(Y.2.2.1 (i+1,(i,a),z):ℝ) := by + let H := (Y.1 i).1.toNat + have hH : arrayWindowHeight e i 1 Y=(H:ℕ∞) := by + simp only [arrayWindowHeight,Finset.sum_range_one,Nat.cast_zero,add_zero] + exact (ENat.natCast_toNat (hm i).2.ne).symm + have hpH : 0 hκ.trans_le (he i 1 a p.1 p.2 u)) 0 z + have hL : 0 arrayProfileMass e i (i,a) offset Y * + upperHorizontalKernel e H (arrayUpperRows e i 1 a Y) offset {z}) 0) + have hR := hL.trans_le (hc i 1 a H z hH) + have : arrayProfileMass e (i+1) (i,a) z Y≠0 := by + intro hz + simp only [arrayDiscountedProfile,Nat.cast_one,hz,mul_zero,lt_self_iff_false] at hR + exact ENNReal.ofReal_pos.mp (pos_iff_ne_zero.mpr this) + +lemma array_forward_survives {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hs : ∀ p j z, Tendsto (fun n => arraySamplingError e p j z (2^n) Y) atTop (𝓝 0)) + (κ : ℝ≥0) (hκ : 0<κ) (he : ArrayElliptic e κ Y) (hc : ArrayContinuation e Y) + (hm : ∀ i, 0<(Y.1 i).1 ∧ (Y.1 i).1<⊤) + (hd : ∀ i a, ¬arrayDust e i a Y) (i : ℤ) (a : ℕ) : + ∃ b, ArrayRelated e Y (i,a) (i+1,b) := by + have ha : 0<(Y.2.2.1 (i,(i,a),0):ℝ) := + lt_of_le_of_ne (Y.2.2.1 (i,(i,a),0)).property.1 (show (Y.2.2.1 (i,(i,a),0):ℝ)≠0 from hd i a).symm + obtain ⟨b,hb⟩ := array_positive_coordinate_represented e Y hs (i,a) (i+1) 0 + (array_next_full e Y κ hκ he hc hm i a ha 0) + exact ⟨b,0,hb⟩ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayFull.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayFull.lean new file mode 100644 index 0000000000000000000000000000000000000000..dece741ec57349e5467b7dcefe67703486b085a1 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayFull.lean @@ -0,0 +1,64 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.StationaryMonotone + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma arrayTransport_image {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) + (ho : ArrayOffsetsConsistent e Y) (hf : ∀ i, CurrentFiniteClasses e (arrayCurrentData e i Y)) + (hs : ∀ a, ∃ b, ArrayRelated e Y (i,a) (i+1,b)) + (hcard : (arrayClassFinset e (i+1) Y).card=(arrayClassFinset e i Y).card) : + (arrayClassFinset e i Y).image (arrayTransport e i Y)=arrayClassFinset e (i+1) Y := by + apply Finset.eq_of_subset_of_card_le + · intro b hb + obtain ⟨a,ha,rfl⟩ := Finset.mem_image.mp hb + exact arrayTransport_mem e i Y (hf (i+1)) a + · rw [Finset.card_image_iff.mpr (arrayTransport_injOn e i Y ho (hf i) hs),hcard] + +lemma array_backward_survives {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) + (ho : ArrayOffsetsConsistent e Y) (hf : ∀ i, CurrentFiniteClasses e (arrayCurrentData e i Y)) + (hs : ∀ a, ∃ b, ArrayRelated e Y (i,a) (i+1,b)) + (hcard : (arrayClassFinset e (i+1) Y).card=(arrayClassFinset e i Y).card) (b : ℕ) : + ∃ a, ArrayRelated e Y (i,a) (i+1,b) := by + have hm : ReferenceClasses.representative (arrayCurrentData e (i+1) Y).1 b ∈ + arrayClassFinset e (i+1) Y := currentClassFinset_rep_mem e _ (hf (i+1)) b + rw [←arrayTransport_image e i Y ho hf hs hcard] at hm + obtain ⟨a,ha,heq⟩ := Finset.mem_image.mp hm + refine ⟨a,arrayRelated_trans e Y ho (arrayTransport_related e i Y ho a (hs a)) ?_⟩ + rw [heq] + exact (arrayRelated_current e Y ho (i+1) _ _).mp (ReferenceClasses.representative_related _ b) + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma full_profiles (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → ∀ i a z, + 0<(Y.2.2.1 (i,(i,a),z):ℝ) := by + filter_upwards [L.consistent,L.sampling,L.elliptic,L.continuation,L.finite_marks, + G.no_dust,L.finite_classes_all_times hue htrans G,L.class_card_constant hue htrans G] + with Y hO hs he hc hm hd hf hcard hY i b z + have hsurv (j : ℤ) := array_forward_survives e Y hs L.κ L.κ_pos he hc + (fun j => ⟨(hm j).1,(hm j).2.1⟩) (hd hY) j + obtain ⟨a,w,hw⟩ := array_backward_survives e (i-1) Y hO.1 (hf hY) (hsurv (i-1)) (hcard hY (i-1)) b + have ha : 0<(Y.2.2.1 (i-1,(i-1,a),0):ℝ) := + lt_of_le_of_ne (Y.2.2.1 (i-1,(i-1,a),0)).property.1 + (show (Y.2.2.1 (i-1,(i-1,a),0):ℝ)≠0 from hd hY (i-1) a).symm + have hp := array_next_full e Y L.κ L.κ_pos he hc + (fun j => ⟨(hm j).1,(hm j).2.1⟩) (i-1) a ha (w+z) + have hc' := hO.2.1 i (i-1,a) (i-1+1,b) w z hw + simp only [sub_add_cancel] at hp hc' + rwa [hc'] at hp + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayMap.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..1855fe28859c122b97c990458fb790ad2990b378 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMap.lean @@ -0,0 +1,161 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GlobalProfile + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience + +instance enat_borel : BorelSpace ℕ∞ := ⟨borel_eq_top_of_countable.symm⟩ +instance horizontalOnePoint_measurable {d : ℕ} (e : Direction d) : + MeasurableSpace (OnePoint (HorizontalSpace e)) := borel _ +instance horizontalOnePoint_borel {d : ℕ} (e : Direction d) : + BorelSpace (OnePoint (HorizontalSpace e)) := ⟨rfl⟩ + +noncomputable def episodeProfile {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ω : Environment d) (i : ℤ) := + globalHorizontalProfile e (t ω i) ω + +instance episodeProfile_probability {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ω : Environment d) (i : ℤ) : + IsProbabilityMeasure (episodeProfile e t ω i) := by + unfold episodeProfile + infer_instance + +lemma globalHorizontalProfile_joint_measurable {d : ℕ} (e : Direction d) : + Measurable (fun p : Environment d×ℕ => globalHorizontalProfile e p.2 p.1) := by + apply measurable_from_prod_countable_left + intro n + exact globalHorizontalProfile_measurable e n + +lemma globalHorizontalCoordinate_joint_measurable {d : ℕ} (e : Direction d) : + Measurable (fun p : (Environment d×ℕ)×HorizontalSpace e => + globalHorizontalCoordinate e p.1.2 p.1.1 p.2) := by + apply measurable_from_prod_countable_left + intro z + apply Measurable.subtype_mk + exact (((Measure.measurable_coe (measurableSet_singleton z)).comp + (globalHorizontalProfile_joint_measurable e)).ennreal_toReal) + +abbrev EpisodeAnchors {d : ℕ} (e : Direction d) := (ℤ×ℕ) → HorizontalSpace e +abbrev EpisodeAuxiliary {d : ℕ} (e : Direction d) := (ℤ×ℕ) → (ℕ×HorizontalSpace e) → Row d +abbrev EpisodeInput {d : ℕ} (e : Direction d) := (Environment d×EpisodeAnchors e)×EpisodeAuxiliary e + +lemma episodeProfile_measurable {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) (i : ℤ) : + Measurable (fun ω => episodeProfile e t ω i) := by + have hn : Measurable (fun ω : Environment d => (ω,t ω i)) := measurable_id.prodMk (ht i) + have hm := (globalHorizontalProfile_joint_measurable e).comp hn + simpa only [Function.comp_def,episodeProfile] using hm + +noncomputable def globalEpisodeAnchors {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) : + Kernel (Environment d) (EpisodeAnchors e) := + AnchorSampling.anchorKernel (episodeProfile e t) + (episodeProfile_measurable e t ht) + +instance globalEpisodeAnchors_markov {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) : + IsMarkovKernel (globalEpisodeAnchors e t ht) := by unfold globalEpisodeAnchors; infer_instance + +noncomputable def episodeAuxiliaryLaw {d : ℕ} (e : Direction d) (ν : Measure (Row d)) : + Measure (EpisodeAuxiliary e) := + Measure.infinitePi (fun _ : ℤ×ℕ => Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)) + +instance episodeAuxiliaryLaw_probability {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] : + IsProbabilityMeasure (episodeAuxiliaryLaw e ν) := by unfold episodeAuxiliaryLaw; infer_instance + +noncomputable def episodeInputLaw {d : ℕ} (e : Direction d) (ν : Measure (Row d)) + (Q : Measure (Environment d)) (t : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) : Measure (EpisodeInput e) := + (Q.compProd (globalEpisodeAnchors e t ht)).prod (episodeAuxiliaryLaw e ν) + +instance episodeInputLaw_probability {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsProbabilityMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) : + IsProbabilityMeasure (episodeInputLaw e ν Q t ht) := by unfold episodeInputLaw; infer_instance + +noncomputable def episodeCost {d : ℕ} (e : Direction d) (t : Environment d → ℤ → ℕ) + (ω : Environment d) (i : ℤ) : ℝ≥0∞ := + ENNReal.ofReal (Real.log (crossingQuenched (realPosition (step e)) 0 (t ω i) ω).toReal- + Real.log (crossingQuenched (realPosition (step e)) 0 (t ω (i+1)) ω).toReal) + +lemma episodeCost_measurable {d : ℕ} (e : Direction d) (t : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (i : ℤ) : Measurable (fun ω => episodeCost e t ω i) := by + have hm : Measurable (fun p : Environment d×ℕ => crossingQuenched (realPosition (step e)) 0 p.2 p.1) := by + apply measurable_from_prod_countable_left + intro n + change Measurable (crossingQuenched (realPosition (step e)) 0 (n : ℝ)) + exact measurable_crossingQuenched _ _ _ + exact (((hm.comp (measurable_id.prodMk (ht i))).ennreal_toReal.log).sub + ((hm.comp (measurable_id.prodMk (ht (i+1)))).ennreal_toReal.log)).ennreal_ofReal + +noncomputable def episodeSplicedRow {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (X : EpisodeInput e) + (i : ℤ) (m a l : ℕ) (z : HorizontalSpace e) : Row d := + if l ((t X.1.1 (i+1)-t X.1.1 i : ℕ),(J X.1.1 i : ℕ),episodeCost e t X.1.1 i)), + (fun p => ((X.1.2 p.2-X.1.2 p.1 : HorizontalSpace e) : OnePoint (HorizontalSpace e))), + (fun p => globalHorizontalCoordinate e (t X.1.1 p.1) X.1.1 (X.1.2 p.2.1+p.2.2)), + (fun p => episodeSplicedRow e t X p.1 p.2.1 p.2.2.1 p.2.2.2.1 p.2.2.2.2)⟩ + +lemma episodeSplicedRow_measurable {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (i : ℤ) (m a l : ℕ) (z : HorizontalSpace e) : + Measurable (fun X : EpisodeInput e => episodeSplicedRow e t X i m a l z) := by + have hw : Measurable (fun X : EpisodeInput e => X.1.1) := measurable_fst.comp measurable_fst + have hU : Measurable (fun X : EpisodeInput e => X.1.2 (i,a)) := + (measurable_pi_apply (i,a)).comp (measurable_snd.comp measurable_fst) + have hx : Measurable (fun X : EpisodeInput e => horizontalLift e (t X.1.1 i+l) (X.1.2 (i,a)+z)) := + (measurable_of_countable (fun p : ℕ×HorizontalSpace e => horizontalLift e (p.1+l) (p.2+z))).comp + (((ht i).comp hw).prodMk hU) + unfold episodeSplicedRow + apply Measurable.ite (measurableSet_lt measurable_const (((ht (i+m)).comp hw).sub ((ht i).comp hw))) + · exact measurable_current_row.comp (hw.prodMk hx) + · have hev : Measurable (fun p : (((ℕ×HorizontalSpace e) → Row d)×(ℕ×HorizontalSpace e)) => p.1 p.2) := + measurable_from_prod_countable_left (fun q => measurable_pi_apply q) + exact hev.comp ((((measurable_pi_apply (i,m)).comp measurable_snd).prodMk + (measurable_const.prodMk (hU.add_const z)))) + +lemma actualArrayCoordinate_measurable {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (j : ℤ) (p : ℤ×ℕ) (z : HorizontalSpace e) : + Measurable (fun X : EpisodeInput e => globalHorizontalCoordinate e (t X.1.1 j) X.1.1 (X.1.2 p+z)) := by + have hw : Measurable (fun X : EpisodeInput e => X.1.1) := measurable_fst.comp measurable_fst + have hU : Measurable (fun X : EpisodeInput e => X.1.2 p) := + (measurable_pi_apply p).comp (measurable_snd.comp measurable_fst) + have ha : Measurable (fun X : EpisodeInput e => ((X.1.1,t X.1.1 j),X.1.2 p+z)) := + (hw.prodMk ((ht j).comp hw)).prodMk (hU.add_const z) + have hm := (globalHorizontalCoordinate_joint_measurable e).comp ha + simpa only [Function.comp_def] using hm + +lemma actualArrayMap_measurable {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) : Measurable (actualArrayMap e t J) := by + have hw : Measurable (fun X : EpisodeInput e => X.1.1) := measurable_fst.comp measurable_fst + have hU (p : ℤ×ℕ) : Measurable (fun X : EpisodeInput e => X.1.2 p) := + (measurable_pi_apply p).comp (measurable_snd.comp measurable_fst) + refine Measurable.prodMk (Measurable.of_eval fun i => ?_) + (Measurable.prodMk (Measurable.of_eval fun p => ?_) + (Measurable.prodMk (Measurable.of_eval fun p => ?_) (Measurable.of_eval fun p => ?_))) + · have hc : Measurable (fun n : ℕ => (n : ℕ∞)) := measurable_of_countable _ + exact (hc.comp (((ht (i+1)).comp hw).sub ((ht i).comp hw))).prodMk + ((hc.comp ((hJ i).comp hw)).prodMk ((episodeCost_measurable e t ht i).comp hw)) + · exact OnePoint.continuous_coe.measurable.comp ((hU p.2).sub (hU p.1)) + · exact actualArrayCoordinate_measurable e t ht _ _ _ + · exact episodeSplicedRow_measurable e t ht _ _ _ _ _ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayMarkTests.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMarkTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..5272fd650cfe757a391ac408cb07dff47e9d5785 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMarkTests.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.BadCrossingEpisodes + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma arrayMark_iterate {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (r : ℕ) (i : ℤ) : (StationaryCompact.shift^[r] Y).1 i = Y.1 (i+r) := by + induction r generalizing i with + | zero => simp + | succ r ih => + rw [Function.iterate_succ_apply'] + change (StationaryCompact.shift^[r] Y).1 (i+1)=_ + rw [ih] + simp only [Nat.cast_add,Nat.cast_one,add_assoc,add_comm (1:ℤ)] + +noncomputable def cutENNReal (B : ℝ≥0) : C(ℝ≥0∞,ℝ) := + ⟨fun x => (min x (B:ℝ≥0∞)).toReal, by + apply continuous_iff_continuousAt.mpr + intro x + have hf : min x (B:ℝ≥0∞) ≠ ∞ := ne_top_of_le_ne_top ENNReal.coe_ne_top (min_le_right _ _) + exact (ENNReal.continuousAt_toReal hf).comp (f:=fun y : ℝ≥0∞ => min y (B:ℝ≥0∞)) + (show ContinuousAt (fun y : ℝ≥0∞ => min y (B:ℝ≥0∞)) x from + (continuous_id.min continuous_const).continuousAt)⟩ + +lemma cutENNReal_nonneg (B : ℝ≥0) (x : ℝ≥0∞) : 0 ≤ cutENNReal B x := ENNReal.toReal_nonneg +lemma cutENNReal_le (B : ℝ≥0) (x : ℝ≥0∞) : cutENNReal B x ≤ B := by + change (min x (B:ℝ≥0∞)).toReal ≤ (B:ℝ≥0∞).toReal + exact ENNReal.toReal_mono ENNReal.coe_ne_top (min_le_right _ _) + +noncomputable def stageMarkCut {d : ℕ} (e : Direction d) (B : ℝ≥0) + (i : ℤ) : C(ActualEpisodeArray e,ℝ) := + (cutENNReal B).comp ⟨fun Y => ((Y.1 i).2.1).toENNReal, + ENat.continuous_toENNReal.comp (by fun_prop)⟩ + +noncomputable def dropMarkCut {d : ℕ} (e : Direction d) (B : ℝ≥0) + (i : ℤ) : C(ActualEpisodeArray e,ℝ) := + (cutENNReal B).comp ⟨fun Y => (Y.1 i).2.2,by fun_prop⟩ + +lemma actualOccupationRaw_env_test {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) + (ht : ∀ i, Measurable fun ω => t ω i) (hJ : ∀ i, Measurable fun ω => J ω i) + (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (F : C(ActualEpisodeArray e,ℝ)) (G : ℕ → Environment d → ℝ) + (hG : ∀ i, Measurable (G i)) + (hFG : ∀ i X, F (StationaryCompact.shift^[i] (actualArrayMap e t J X))=G i X.1.1) : + (∫ Y, F Y ∂actualOccupationRaw e ν Q t J ht N M)= + ∑ i∈Finset.range N, ∫ ω in {ω | i p.2 (p.1,z) +lemma selectUpperField_measurable {d : ℕ} (e : Direction d) : Measurable (selectUpperField e) := by + apply Measurable.of_eval + intro z + have hm : Measurable (fun p : ReferenceClasses.AllFields (HorizontalSpace e) (Row d) × ℕ => p.1 (p.2,z)) := + measurable_from_prod_countable_left (fun a => measurable_pi_apply (a,z)) + exact hm.comp measurable_swap + +noncomputable def markedUpper {d : ℕ} (e : Direction d) (n : ℕ) (p : MarkedArray e) : UpperRows e := + arrayUpperRows e 0 n p.2 p.1 +lemma markedUpper_measurable {d : ℕ} (e : Direction d) (n : ℕ) : Measurable (markedUpper e n) := + measurable_from_prod_countable_left (fun a => (arrayUpperRows_continuous e 0 n a).measurable) + +lemma marked_window_law {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (E : Set (ActualEpisodeArray e)) (n : ℕ) : + (markedArrayLaw e μ E).map (fun p => (markedData e p,markedUpper e n p)) = + StoppedWindow.selectedKernel (currentClassKernel e) (selectUpperField e) (selectUpperField_measurable e) ∘ₘ + (μ[|E].map (typedCurrentArrayWindow e 0 n)) := by + have hf := (typedCurrentArrayWindow_measurable e 0 n).snd + have hp : Measurable (fun p : (CurrentData e × ℕ) × ReferenceClasses.AllFields (HorizontalSpace e) (Row d) => + (p.1,selectUpperField e (p.1.2,p.2))) := + measurable_fst.prodMk ((selectUpperField_measurable e).comp + ((measurable_snd.comp measurable_fst).prodMk measurable_snd)) + have h := congrArg (fun M => M.map (fun p : (CurrentData e × ℕ) × ReferenceClasses.AllFields (HorizontalSpace e) (Row d) => + (p.1,selectUpperField e (p.1.2,p.2)))) + (StoppedWindow.sample_data_map μ[|E] (arrayCurrentData e 0) (arrayCurrentData_measurable e 0) + (fun Y => (typedCurrentArrayWindow e 0 n Y).2) hf (currentClassKernel e)) + have hw : Measurable (fun p : ActualEpisodeArray e × ℕ => + ((arrayCurrentData e 0 p.1,p.2),(typedCurrentArrayWindow e 0 n p.1).2)) := + (((arrayCurrentData_measurable e 0).comp measurable_fst).prodMk measurable_snd).prodMk + (hf.comp measurable_fst) + rw [Measure.map_map hp hw,Measure.map_comp _ _ hp] at h + exact h + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma marked_upper_entropy (L : StationaryArrayLaw ν e) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) (n : ℕ) : + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + let W := μ.map (fun p => (markedData e p,markedUpper e n p)) + klDiv W (W.fst.prod (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν)))≠∞ := by + have : Nonempty (Row d) := nonempty_of_isProbabilityMeasure ν + let μ := (L.law : Measure (ActualEpisodeArray e)) + have : IsProbabilityMeasure μ[|G.event] := cond_isProbabilityMeasure G.positive_event.ne' + let W := μ.map (typedCurrentArrayWindow e 0 n) + let Q := μ[|G.event].map (typedCurrentArrayWindow e 0 n) + have : IsProbabilityMeasure W := inferInstance + have : IsProbabilityMeasure Q := inferInstance + have hdom : Q≤ENNReal.ofReal ((μ G.event)⁻¹).toReal • W := by + rw [ENNReal.ofReal_toReal (ENNReal.inv_ne_top.mpr G.positive_event.ne')] + have h : μ[|G.event]≤(μ G.event)⁻¹ • μ := smul_le_smul_left _ Measure.restrict_le_self + simpa only [Measure.map_smul _ (typedCurrentArrayWindow_measurable e 0 n).aemeasurable] using + Measure.map_mono h (typedCurrentArrayWindow_measurable e 0 n) + have hk := Entropy.finite_kl_of_domination Q W (W.fst.compProd (currentWindowReference e ν)) + (L.entropy_finite 0 n) _ ENNReal.toReal_nonneg hdom + have h := StoppedWindow.selected_kl_finite Q W.fst (currentWindowReference e ν) (currentClassKernel e) + (Measure.infinitePi (fun _ : ℕ × HorizontalSpace e => ν)) (selectUpperField e) + (selectUpperField_measurable e) (fun A a => ReferenceClasses.reference_single_field ν A.1 a) hk + rw [←marked_window_law e μ G.event n] at h + exact h + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayMarkedIterate.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMarkedIterate.lean new file mode 100644 index 0000000000000000000000000000000000000000..d80d1a4bef3cb161e8e90070588e947d92cdee55 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMarkedIterate.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.StationaryMarking + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma markedShift_iterate_fst {d : ℕ} (e : Direction d) (p : MarkedArray e) (n : ℕ) : + ((markedShift e)^[n] p).1=StationaryCompact.shift^[n] p.1 := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply',Function.iterate_succ_apply'] + change StationaryCompact.shift ((markedShift e)^[n] p).1=_ + rw [ih] + +lemma arrayOffset_iterate {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (n : ℕ) (p q : StationaryCompact.Label) : + (StationaryCompact.shift^[n] Y).2.1 (p,q)=Y.2.1 ((p.1+n,p.2),(q.1+n,q.2)) := by + induction n generalizing p q with + | zero => simp + | succ n ih => + rw [Function.iterate_succ_apply'] + change (StationaryCompact.shift^[n] Y).2.1 ((p.1+1,p.2),(q.1+1,q.2))=_ + rw [ih] + simp only [Nat.cast_add,Nat.cast_one,add_left_comm,add_comm] + +lemma arrayProfile_iterate {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (n : ℕ) (j : ℤ) (p : StationaryCompact.Label) (z : HorizontalSpace e) : + (StationaryCompact.shift^[n] Y).2.2.1 (j,p,z)=Y.2.2.1 (j+n,(p.1+n,p.2),z) := by + induction n generalizing j p with + | zero => simp + | succ n ih => + rw [Function.iterate_succ_apply'] + change (StationaryCompact.shift^[n] Y).2.2.1 (j+1,(p.1+1,p.2),z)=_ + rw [ih] + simp only [Nat.cast_add,Nat.cast_one,add_left_comm,add_comm] + +lemma marked_related_iterate {d : ℕ} (e : Direction d) (p : MarkedArray e) + (ho : ArrayOffsetsConsistent e p.1) + (hs : ∀ n, ArrayRelated e ((markedShift e)^[n] p).1 (0,((markedShift e)^[n] p).2) + (1,((markedShift e)^[n+1] p).2)) (n : ℕ) : + ArrayRelated e p.1 (0,p.2) (n,((markedShift e)^[n] p).2) := by + induction n with + | zero => exact arrayRelated_refl e p.1 ho _ + | succ n ih => + apply arrayRelated_trans e p.1 ho ih + obtain ⟨z,hz⟩ := hs n + rw [markedShift_iterate_fst,arrayOffset_iterate] at hz + refine ⟨z,?_⟩ + simpa only [zero_add,add_zero,Nat.cast_add,Nat.cast_one,add_comm] using hz + +noncomputable def markedDisplacement {d : ℕ} (e : Direction d) (n : ℕ) (p : MarkedArray e) : HorizontalSpace e := + if h : ArrayRelated e p.1 (0,p.2) (n,((markedShift e)^[n] p).2) then Classical.choose h else 0 + +lemma markedDisplacement_spec {d : ℕ} (e : Direction d) (n : ℕ) (p : MarkedArray e) + (h : ArrayRelated e p.1 (0,p.2) (n,((markedShift e)^[n] p).2)) : + p.1.2.1 ((0,p.2),(n,((markedShift e)^[n] p).2))=(markedDisplacement e n p : OnePoint (HorizontalSpace e)) := by + rw [markedDisplacement,dite_eq_left h] + exact Classical.choose_spec h + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma marked_related (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + ∀ᵐ p ∂markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event, + ∀ n : ℕ, ArrayRelated e p.1 (0,p.2) (n,((markedShift e)^[n] p).2) := by + have h0 := markedArrayLaw_ae e (L.law : Measure (ActualEpisodeArray e)) G.event G.measurable_event + (show ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → + ArrayOffsetsConsistent e Y ∧ ∀ a, ArrayRelated e Y (0,a) (1,arrayTransport e 0 Y a) from by + filter_upwards [L.consistent,L.sampling,L.elliptic,L.continuation,L.finite_marks,G.no_dust] + with Y hO hs he hc hm hd hY + refine ⟨hO.1,fun a => arrayTransport_related e 0 Y hO.1 a ?_⟩ + exact array_forward_survives e Y hs L.κ L.κ_pos he hc + (fun i => ⟨(hm i).1,(hm i).2.1⟩) (hd hY) 0 a) + have hall := ae_all_iff.mpr fun n => + ((L.marked_preserving hue htrans G).iterate n).quasiMeasurePreserving.ae h0 + filter_upwards [h0,hall] with p hp hh n + apply marked_related_iterate e p hp.1 _ n + intro k + simpa only [Function.iterate_succ_apply',markedShift] using (hh k).2 ((markedShift e)^[k] p).2 + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayMassSurvival.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMassSurvival.lean new file mode 100644 index 0000000000000000000000000000000000000000..16a0cae644995f44c6cd592bbd6184f084967ce0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayMassSurvival.lean @@ -0,0 +1,128 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayProfileConsistency +import OAI.Probability.Ballisticity.Walk.ArrayCostGrowth +import OAI.Probability.Ballisticity.Estimates.ClassMoment + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma arrayProfileMass_total_le_one {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hP : ArrayProfilesConsistent e Y) (i : ℤ) (p : StationaryCompact.Label) : + (∑' z, arrayProfileMass e i p z Y)≤1 := by + apply ENNReal.summable.tsum_le_of_sum_le + intro s + dsimp only [arrayProfileMass] + rw [←ENNReal.ofReal_sum_of_nonneg (fun z _ => (Y.2.2.1 (i,p,z)).property.1)] + exact ENNReal.ofReal_le_one.mpr (hP.2 i p s) + +lemma upperHorizontalKernel_mass_sum {d : ℕ} (e : Direction d) (H : ℕ) + (ξ : UpperRows e) (x : HorizontalSpace e) : + (∑' z, upperHorizontalKernel e H ξ x {z})=upperHorizontalKernel e H ξ x Set.univ := by + simpa only [Set.indicator_univ] using + (upperHorizontalKernel e H ξ x).tsum_indicator_apply_singleton Set.univ MeasurableSet.univ + +lemma arrayKernelImage_total_le_discount {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hP : ArrayProfilesConsistent e Y) (hc : ArrayContinuation e Y) + (i : ℤ) (m a H : ℕ) (hH : arrayWindowHeight e i m Y=H) : + arrayKernelImage e i m a H Set.univ Y≤expNeg (arrayWindowCost e i m Y) := by + calc + _ = ∑' z, arrayKernelImage e i m a H {z} Y := by + unfold arrayKernelImage + calc + _ = ∑' x, ∑' z, arrayProfileMass e i (i,a) x Y * + upperHorizontalKernel e H (arrayUpperRows e i m a Y) x {z} := by + congr 1 + funext x + rw [ENNReal.tsum_mul_left,upperHorizontalKernel_mass_sum] + _ = _ := ENNReal.tsum_comm + _ ≤ ∑' z, arrayDiscountedProfile e i m a z Y := ENNReal.tsum_le_tsum (fun z => hc i m a H z hH) + _ = expNeg (arrayWindowCost e i m Y)*(∑' z, arrayProfileMass e (i+m) (i,a) z Y) := by + simp only [arrayDiscountedProfile,ENNReal.tsum_mul_left] + _ ≤ expNeg (arrayWindowCost e i m Y)*1 := mul_le_mul_right (arrayProfileMass_total_le_one e Y hP _ _) _ + _ = _ := mul_one _ + +lemma arraySelfMass_mul_q_le_discount {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hP : ArrayProfilesConsistent e Y) (hc : ArrayContinuation e Y) + (i : ℤ) (m a H : ℕ) (hH : arrayWindowHeight e i m Y=H) + (hq : upperNoDrop e (arrayUpperRows e i m a Y)≤upperHorizontalKernel e H (arrayUpperRows e i m a Y) 0 Set.univ) : + arrayProfileMass e i (i,a) 0 Y * upperNoDrop e (arrayUpperRows e i m a Y)≤ + expNeg (arrayWindowCost e i m Y) := by + apply le_trans (mul_le_mul_right hq _) + exact (ENNReal.le_tsum 0).trans (arrayKernelImage_total_le_discount e Y hP hc i m a H hH) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def arrayCurrentData {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) : CurrentData e := + (typedCurrentArrayWindow e i 0 Y).1 +lemma arrayCurrentData_measurable {d : ℕ} (e : Direction d) (i : ℤ) : Measurable (arrayCurrentData e i) := + (typedCurrentArrayWindow_measurable e i 0).fst +lemma typedCurrentArrayWindow_data {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) (Y : ActualEpisodeArray e) : + (typedCurrentArrayWindow e i m Y).1=arrayCurrentData e i Y := rfl + +lemma ennreal_negative_power_exp_lower {q : ℝ≥0∞} {lam t : ℝ} (hlam : 0≤lam) + (hq : q≤ENNReal.ofReal (Real.exp (-t))) : + ENNReal.ofReal (Real.exp (lam*t))≤q^(-lam) := by + have h := ENNReal.inv_le_inv.mpr (ENNReal.rpow_le_rpow hq hlam) + rw [←ENNReal.rpow_neg,←ENNReal.rpow_neg] at h + rw [ENNReal.ofReal_rpow_of_pos (Real.exp_pos _),Real.rpow_def_of_pos (Real.exp_pos _)] at h + simpa only [Real.log_exp,neg_mul_neg,mul_comm] using h + +lemma selfmass_nodrop_bound {mass q c : ℝ≥0∞} {r t : ℝ} + (hr : 0 Y.2.1 (labelPerm σ p.1,labelPerm σ p.2)), + (fun p => Y.2.2.1 (p.1,labelPerm σ p.2.1,p.2.2)), + (fun p => Y.2.2.2 (p.1,p.2.1,σ p.2.2.1,p.2.2.2))) + +lemma arrayPerm_continuous {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) : + Continuous (arrayPerm e σ) := by unfold arrayPerm; fun_prop + +lemma arrayPerm_shift {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (Y : ActualEpisodeArray e) : + arrayPerm e σ (StationaryCompact.shift Y) = StationaryCompact.shift (arrayPerm e σ Y) := rfl + +lemma arrayPerm_iterate {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (j : ℕ) (Y : ActualEpisodeArray e) : + arrayPerm e σ (StationaryCompact.shift^[j] Y) = StationaryCompact.shift^[j] (arrayPerm e σ Y) := by + induction j with + | zero => rfl + | succ j ih => rw [Function.iterate_succ_apply',arrayPerm_shift,ih,Function.iterate_succ_apply'] + +def anchorsPerm {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (E : EpisodeAnchors e) : EpisodeAnchors e := E ∘ labelPerm σ +lemma anchorsPerm_measurable {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) : + Measurable (anchorsPerm e σ) := by unfold anchorsPerm; fun_prop + +def inputPerm {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (X : EpisodeInput e) : EpisodeInput e := ((X.1.1,anchorsPerm e σ X.1.2),X.2) +lemma inputPerm_measurable {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) : + Measurable (inputPerm e σ) := + ((measurable_fst.comp measurable_fst).prodMk + ((anchorsPerm_measurable e σ).comp (measurable_snd.comp measurable_fst))).prodMk measurable_snd + +lemma arrayPerm_actual {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (t J : Environment d → ℤ → ℕ) (X : EpisodeInput e) : + arrayPerm e σ (actualArrayMap e t J X) = actualArrayMap e t J (inputPerm e σ X) := rfl + +lemma anchorLaw_perm {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) (ω : Environment d) : + (globalEpisodeAnchors e t ht ω).map (anchorsPerm e σ) = globalEpisodeAnchors e t ht ω := by + have hh := Measure.infinitePi_map_piCongrLeft + (fun p : StationaryCompact.Label => episodeProfile e t ω p.1) (labelPerm σ).symm + convert hh using 1 + · congr 1 + funext E p + simp [anchorsPerm,MeasurableEquiv.piCongrLeft,Equiv.piCongrLeft,labelPerm] + · rfl + +lemma inputLaw_perm {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [SFinite Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) : + (episodeInputLaw e ν Q t ht).map (inputPerm e σ) = episodeInputLaw e ν Q t ht := by + have hk : (globalEpisodeAnchors e t ht).map (anchorsPerm e σ)=globalEpisodeAnchors e t ht := by + ext ω + rw [Kernel.map_apply _ (anchorsPerm_measurable e σ),anchorLaw_perm] + have hmap : (Q.compProd (globalEpisodeAnchors e t ht)).map (Prod.map id (anchorsPerm e σ)) = + Q.compProd (globalEpisodeAnchors e t ht) := by + rw [←Measure.compProd_map (anchorsPerm_measurable e σ),hk] + unfold episodeInputLaw + change ((Q.compProd (globalEpisodeAnchors e t ht)).prod (episodeAuxiliaryLaw e ν)).map + (Prod.map (Prod.map id (anchorsPerm e σ)) id)=_ + rw [←Measure.map_prod_map _ _ (measurable_id.prodMap (anchorsPerm_measurable e σ)) measurable_id, + hmap,Measure.map_id] + +lemma occupation_perm_integral {d : ℕ} (e : Direction d) (σ : Equiv.Perm ℕ) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) (hM : Measurable M) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (F : ActualEpisodeArray e →ᵇ ℝ) : + (∫ Y, F (arrayPerm e σ Y) ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)))= + ∫ Y, F Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)) := by + rw [actualOccupation_integral e ν Q t J ht N M hpos, + actualOccupation_integral e ν Q t J ht N M hpos] + congr 1 + have h₁ := actualOccupationRaw_integral e ν Q t J ht hJ N M hM + (F.toContinuousMap.comp ⟨arrayPerm e σ,arrayPerm_continuous e σ⟩) + have h₂ := actualOccupationRaw_integral e ν Q t J ht hJ N M hM F.toContinuousMap + simp only [ContinuousMap.comp_apply,BoundedContinuousFunction.coe_toContinuousMap, + ContinuousMap.coe_mk] at h₁ h₂ + rw [h₁,h₂] + apply Finset.sum_congr rfl + intro j hj + simp only [arrayPerm_iterate,arrayPerm_actual] + have hf : Measurable (fun X : EpisodeInput e => F (StationaryCompact.shift^[j] (actualArrayMap e t J X))) := + F.continuous.measurable.comp ((StationaryCompact.shift_continuous.measurable.iterate j).comp + (actualArrayMap_measurable e t J ht hJ)) + rw [←integral_map (inputPerm_measurable e σ).aemeasurable hf.aestronglyMeasurable, + inputLaw_perm] + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma bad_limit_perm (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (Ns : ℕ → ℕ) (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) (σ : Equiv.Perm ℕ) : + MeasurePreserving (arrayPerm e σ) (ρ : Measure (ActualEpisodeArray e)) (ρ : Measure (ActualEpisodeArray e)) := by + apply StationaryCompact.invariant_of_weak_limit (arrayPerm e σ) (arrayPerm_continuous e σ) _ ρ hlim + intro F + have hz (n : ℕ) : (∫ Y, F (arrayPerm e σ Y) ∂(C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)]) : Measure (ActualEpisodeArray e)))= + ∫ Y, F Y ∂(C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)]) : Measure (ActualEpisodeArray e)) := + occupation_perm_integral e σ ν _ _ _ (C.paddedTimes_measurable hef (Ns n)) + (C.paddedStages_measurable hef (Ns n)) (Ns n) _ (C.activeCount_measurable hef (Ns n)) + (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n)) F + simpa only [hz,sub_self] using (tendsto_const_nhds : Tendsto (fun _ : ℕ => (0:ℝ)) atTop (𝓝 0)) + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayProfileConsistency.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayProfileConsistency.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd01a2187ff4464714c7a079c456046799577383 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayProfileConsistency.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.LocalRadiusOrder +import OAI.Probability.Ballisticity.Crossings.BadCrossingLaw +import OAI.Probability.Ballisticity.Estimates.AllOffsetConsistency +import OAI.Probability.Ballisticity.Stationary.BadArraySampling + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma finite_translated_atoms_le_one {H : Type*} [AddCommGroup H] + [MeasurableSpace H] [MeasurableSingletonClass H] + (μ : Measure H) [IsProbabilityMeasure μ] (v : H) (s : Finset H) : + ∑ z∈s, (μ {v+z}).toReal ≤ 1 := by + rw [←ENNReal.toReal_sum (fun z _ => measure_ne_top μ _)] + have he : ∑ z∈s, μ {v+z}=μ (↑(s.image (fun z => v+z)):Set H) := by + rw [←sum_measure_singleton] + have hi : ∀ a∈s, ∀ b∈s, v+a=v+b → a=b := fun a _ b _ h => add_left_cancel h + exact (Finset.sum_image (f := fun z => μ {z}) hi).symm + rw [he] + exact measureReal_le_one + +def ArrayProfilesConsistent {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) : Prop := + (∀ (j : ℤ) (p q : StationaryCompact.Label) (z w : HorizontalSpace e), + Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e)) → + Y.2.2.1 (j,p,z+w)=Y.2.2.1 (j,q,w)) ∧ + (∀ (j : ℤ) (p : StationaryCompact.Label) (s : Finset (HorizontalSpace e)), + ∑ z∈s, (Y.2.2.1 (j,p,z):ℝ) ≤ 1) + +lemma arrayProfilesConsistent_closed {d : ℕ} (e : Direction d) : + IsClosed {Y : ActualEpisodeArray e | ArrayProfilesConsistent e Y} := by + have ht : IsClosed {Y : ActualEpisodeArray e | + ∀ (j : ℤ) (p q : StationaryCompact.Label) (z w : HorizontalSpace e), + Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e)) → + Y.2.2.1 (j,p,z+w)=Y.2.2.1 (j,q,w)} := by + simp only [Set.ofPred_forall] + refine isClosed_iInter fun j => isClosed_iInter fun p => isClosed_iInter fun q => + isClosed_iInter fun z => isClosed_iInter fun w => ?_ + have heq : {Y : ActualEpisodeArray e | Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e)) → + Y.2.2.1 (j,p,z+w)=Y.2.2.1 (j,q,w)} = + {Y | Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e))}ᶜ ∪ + {Y | Y.2.2.1 (j,p,z+w)=Y.2.2.1 (j,q,w)} := by + ext; simp [imp_iff_not_or] + rw [heq] + exact ((ReferenceClasses.finite_value_clopen z).preimage (by fun_prop)).2.isClosed_compl.union + (isClosed_eq (by fun_prop) (by fun_prop)) + have hm : IsClosed {Y : ActualEpisodeArray e | + ∀ (j : ℤ) (p : StationaryCompact.Label) (s : Finset (HorizontalSpace e)), + ∑ z∈s, (Y.2.2.1 (j,p,z):ℝ) ≤ 1} := by + simp only [Set.ofPred_forall] + refine isClosed_iInter fun j => isClosed_iInter fun p => isClosed_iInter fun s => ?_ + exact isClosed_le (by fun_prop) continuous_const + exact ht.inter hm + +lemma actual_arrayProfilesConsistent {d : ℕ} (e : Direction d) + (t J : Environment d → ℤ → ℕ) (X : EpisodeInput e) : + ArrayProfilesConsistent e (actualArrayMap e t J X) := by + constructor + · intro j p q z w h + have he : X.1.2 q-X.1.2 p=z := OnePoint.coe_injective h + change globalHorizontalCoordinate e (t X.1.1 j) X.1.1 (X.1.2 p+(z+w)) = + globalHorizontalCoordinate e (t X.1.1 j) X.1.1 (X.1.2 q+w) + congr 1 + rw [←he] + abel + · intro j p s + exact finite_translated_atoms_le_one (globalHorizontalProfile e (t X.1.1 j) X.1.1) (X.1.2 p) s + +lemma arrayProfilesConsistent_shift {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayProfilesConsistent e Y) : ArrayProfilesConsistent e (StationaryCompact.shift Y) := by + constructor + · intro j p q z w ho + exact h.1 (j+1) (p.1+1,p.2) (q.1+1,q.2) z w ho + · intro j p s + exact h.2 (j+1) (p.1+1,p.2) s + +lemma actualOccupation_profilesConsistent {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) : + ∀ᵐ Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)), + ArrayProfilesConsistent e Y := + actualOccupation_ae_of_invariant e ν Q t J ht hJ N M hpos _ + (arrayProfilesConsistent_closed e).measurableSet (actual_arrayProfilesConsistent e t J) + (arrayProfilesConsistent_shift e) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma array_offset_symm {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (h : ArrayOffsetsConsistent e Y) (p q : StationaryCompact.Label) + (z : HorizontalSpace e) (ho : Y.2.1 (p,q)=(z:OnePoint (HorizontalSpace e))) : + Y.2.1 (q,p)=((-z:HorizontalSpace e):OnePoint (HorizontalSpace e)) := by + let E := Denumerable.eqv StationaryCompact.Label + have hs := (h E.symm).symm (E p) (E q) z + simpa only [selectedOffsets,Equiv.symm_apply_apply] using hs (by simpa [selectedOffsets] using ho) + +lemma dust_isolated {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hO : ArrayOffsetsConsistent e Y) (hP : ArrayProfilesConsistent e Y) + (hzero : ∀ p q z, p≠q → arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0) + (p q : StationaryCompact.Label) (hpq : p≠q) + (hdust : arrayProfileTest e p.1 p 0 Y=0) (z : HorizontalSpace e) : + Y.2.1 (p,q)≠(z:OnePoint (HorizontalSpace e)) := by + intro ho + have hrev := array_offset_symm e Y hO p q z ho + have hp := congrArg Subtype.val (hP.1 p.1 p q z (-z) ho) + have hprofile : arrayProfileTest e p.1 q (-z) Y=0 := by + change (Y.2.2.1 (p.1,q,-z)).val=0 + simp only [add_neg_cancel] at hp + exact hp.symm.trans hdust + have htest := hzero q p (-z) hpq.symm hprofile + simp [arrayOffsetTest,finiteOffsetTest,hrev] at htest + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma bad_limit_consistent (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (Ns : ℕ → ℕ) (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) : + ∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), + ArrayOffsetsConsistent e Y ∧ ArrayProfilesConsistent e Y := by + have ho := closed_support_weak_limit _ ρ hlim _ (arrayOffsetsConsistent_closed e) (fun n => + actualOccupation_offsetsConsistent e ν _ (C.paddedTimes hef (Ns n)) (C.paddedStages hef (Ns n)) + (C.paddedTimes_measurable hef (Ns n)) (C.paddedStages_measurable hef (Ns n)) (Ns n) + (C.activeCount hef (Ns n)) (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n))) + have hp := closed_support_weak_limit _ ρ hlim _ (arrayProfilesConsistent_closed e) (fun n => + actualOccupation_profilesConsistent e ν _ (C.paddedTimes hef (Ns n)) (C.paddedStages hef (Ns n)) + (C.paddedTimes_measurable hef (Ns n)) (C.paddedStages_measurable hef (Ns n)) (Ns n) + (C.activeCount hef (Ns n)) (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n))) + filter_upwards [ho,hp] with Y hO hP + exact ⟨hO,hP⟩ + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArraySurvival.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArraySurvival.lean new file mode 100644 index 0000000000000000000000000000000000000000..3eea24d804e90f6f369171bb127e567f076eaf3f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArraySurvival.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayWindowMarks +import OAI.Probability.Ballisticity.Estimates.BoundedAnchorAverage + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def arraySurvivalSum {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) + (Y : ActualEpisodeArray e) : ℝ≥0∞ := + ∑ a∈Finset.range n, upperHorizontalKernel e H (arrayUpperRows e i m a Y) 0 Set.univ + +lemma arraySurvivalSum_lowerSemicontinuous {d : ℕ} (e : Direction d) (i : ℤ) (m H n : ℕ) : + LowerSemicontinuous (arraySurvivalSum e i m H n) := by + apply lowerSemicontinuous_sum + intro a ha + exact (upperHorizontalKernel_lowerSemicontinuous e H 0 Set.univ).comp + (arrayUpperRows_continuous e i m a) + +noncomputable def arraySurvivalThreshold {d : ℕ} (e : Direction d) (i : ℤ) (m n : ℕ) + (ε : ℝ) (Y : ActualEpisodeArray e) : ℝ≥0∞ := + ENNReal.ofReal ((n:ℝ)*((expNeg (arrayWindowCost e i m Y)).toReal+ε)) + +lemma arraySurvivalThreshold_continuous {d : ℕ} (e : Direction d) (i : ℤ) (m n : ℕ) (ε : ℝ) : + Continuous (arraySurvivalThreshold e i m n ε) := + ENNReal.continuous_ofReal.comp (continuous_const.mul + ((expNeg_toReal_continuous.comp (arrayWindowCost_continuous e i m)).add continuous_const)) + +def survivalViolation {d : ℕ} (e : Direction d) (i : ℤ) (m n : ℕ) (ε : ℝ) : + Set (ActualEpisodeArray e) := + {Y | ∃ H : ℕ, arrayWindowHeight e i m Y=H ∧ + arraySurvivalThreshold e i m n ε Y ENNReal.toReal_nonneg)] + apply Finset.sum_congr rfl + intro a ha + rw [ENNReal.ofReal_toReal (localSurvival_ne_top _ _ _ _ _)] + change upperHorizontalKernel e _ (fun p => episodeSplicedRow e t X i m a p.1 p.2) 0 Set.univ=_ + rw [episodeSpliced_kernel] + simp only [Set.mem_univ,Set.ofPred_true,add_zero,localSurvival] + +lemma localSurvival_mean {d : ℕ} (e : Direction d) (ω : Environment d) (k H : ℕ) + (hk : crossingQuenched (realPosition (step e)) 0 k ω≠0) : + (∫ z, (localSurvival e ω k H z).toReal ∂globalHorizontalProfile e k ω) ≤ + (crossingQuenched (realPosition (step e)) 0 ((k+H:ℕ):ℝ) ω / + crossingQuenched (realPosition (step e)) 0 k ω).toReal := by + rw [integral_toReal (measurable_of_countable _).aemeasurable + (Eventually.of_forall (fun z => lt_top_iff_ne_top.mpr (localSurvival_ne_top _ _ _ _ z)))] + apply ENNReal.toReal_mono (ENNReal.div_ne_top (crossingQuenched_ne_top _ _ _ _) hk) + have hh := globalHorizontalProfile_continuation e k H ω hk Set.univ + simpa only [localSurvival,Set.preimage_univ,measure_univ,mul_one,Nat.cast_add] using hh + +lemma actual_survivalViolation_iff {d : ℕ} (e : Direction d) (t J : Environment d → ℤ → ℕ) + (X : EpisodeInput e) (hmono : Monotone (t X.1.1)) + (hpos : ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k X.1.1≠0) + (i : ℤ) (m n : ℕ) (hn : 0 (localSurvival e X.1.1 (t X.1.1 i) + (t X.1.1 (i+m)-t X.1.1 i) (E (i,a))).toReal) n X.1.2 := by + have hik := hmono (show i ≤ i+(m:ℤ) by omega) + simp only [survivalViolation,Set.mem_ofPred_eq,arrayWindowHeight_actual e t J X hmono, + Nat.cast_inj,exists_eq_left',actual_arraySurvivalSum] + unfold arraySurvivalThreshold + rw [arrayWindowCost_actual e t J X hmono hpos,expNeg_log_ratio _ _ (hpos _) + (crossingQuenched_ne_top _ _ _ _) (hpos _) (crossingQuenched_ne_top _ _ _ _) + (crossingQuenched_antitone _ _ _ (by exact_mod_cast hik)), + ENNReal.ofReal_lt_ofReal_iff_of_nonneg (by positivity)] + unfold sampleAverage + rw [show (n:ℝ)⁻¹*∑ a∈Finset.range n, _ = (∑ a∈Finset.range n, _)/(n:ℝ) by ring, + lt_div_iff₀ (by exact_mod_cast hn)] + rw [mul_comm] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayTopology.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayTopology.lean new file mode 100644 index 0000000000000000000000000000000000000000..2629c0a544f812959090b71ea8887f4aca2f3760 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayTopology.lean @@ -0,0 +1,70 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace Filter +open scoped ENNReal Topology +namespace DirectionalTransience.StationaryCompact + +instance discreteOnePoint_countable (H : Type*) [Countable H] : Countable (OnePoint H) := by + unfold OnePoint + infer_instance + +instance discreteOnePoint_firstCountable (H : Type*) [TopologicalSpace H] + [DiscreteTopology H] [Countable H] : FirstCountableTopology (OnePoint H) := by + constructor + intro x + induction x using OnePoint.rec with + | coe x => + rw [OnePoint.nhds_coe_eq, nhds_discrete] + infer_instance + | infty => + rw [OnePoint.nhds_infty_eq, coclosedCompact_eq_cocompact, cocompact_eq_cofinite] + have : (cofinite : Filter H).IsCountablyGenerated := + (show (cofinite : Filter H).HasCountableBasis Set.Finite (fun s => sᶜ) from + ⟨Filter.hasBasis_cofinite, Set.Countable.ofPred_finite⟩).isCountablyGenerated + infer_instance + +instance discreteOnePoint_secondCountable (H : Type*) [TopologicalSpace H] + [DiscreteTopology H] [Countable H] : SecondCountableTopology (OnePoint H) := inferInstance + +abbrev Label := ℤ × ℕ +abbrev MarkSpace := ℕ∞ × ℕ∞ × ℝ≥0∞ +abbrev EpisodeArray (H R : Type*) := + (ℤ → MarkSpace) × ((Label × Label) → OnePoint H) × + ((ℤ × Label × H) → Set.Icc (0:ℝ) 1) × + ((ℤ × ℕ × ℕ × ℕ × H) → R) + +variable {H R : Type*} + [TopologicalSpace H] [DiscreteTopology H] [Countable H] + [TopologicalSpace R] [CompactSpace R] [T2Space R] [SecondCountableTopology R] + +instance array_compact : CompactSpace (EpisodeArray H R) := inferInstance +instance array_secondCountable : SecondCountableTopology (EpisodeArray H R) := inferInstance +instance array_t2 : T2Space (EpisodeArray H R) := by + have : T2Space (OnePoint H) := inferInstance + have : T2Space MarkSpace := inferInstance + unfold EpisodeArray + infer_instance +instance array_metrizable : MetrizableSpace (EpisodeArray H R) := inferInstance + +def shift (a : EpisodeArray H R) : EpisodeArray H R := + ⟨fun i => a.1 (i+1), + (fun p => a.2.1 ((p.1.1+1,p.1.2),(p.2.1+1,p.2.2))), + (fun p => a.2.2.1 (p.1+1,(p.2.1.1+1,p.2.1.2),p.2.2)), + (fun p => a.2.2.2 (p.1+1,p.2.1,p.2.2.1,p.2.2.2.1,p.2.2.2.2))⟩ + +omit [DiscreteTopology H] [Countable H] [CompactSpace R] [T2Space R] + [SecondCountableTopology R] in +lemma shift_continuous : Continuous (shift : EpisodeArray H R → EpisodeArray H R) := by + unfold shift + fun_prop + +end DirectionalTransience.StationaryCompact + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/ArrayWindowMarks.lean b/lean/OAI/Probability/Ballisticity/Stationary/ArrayWindowMarks.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c0f3d76b0287ce09de19a81b798182e371dc3a1 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/ArrayWindowMarks.lean @@ -0,0 +1,232 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GlobalContinuation +import OAI.Probability.Ballisticity.Walk.KernelTranslation + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped ENNReal NNReal Classical BigOperators +namespace DirectionalTransience + +noncomputable def arrayWindowHeight {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) : ℕ∞ := ∑ r∈Finset.range m, (Y.1 (i+r)).1 +noncomputable def arrayWindowCost {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) : ℝ≥0∞ := ∑ r∈Finset.range m, (Y.1 (i+r)).2.2 + +lemma arrayWindowHeight_continuous {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) : + Continuous (arrayWindowHeight e i m) := by unfold arrayWindowHeight; fun_prop +lemma arrayWindowCost_continuous {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) : + Continuous (arrayWindowCost e i m) := by unfold arrayWindowCost; fun_prop + +noncomputable def expNeg (C : ℝ≥0∞) : ℝ≥0∞ := EReal.exp (-(C:EReal)) +lemma expNeg_le_one (C : ℝ≥0∞) : expNeg C≤1 := by + rw [←EReal.exp_zero] + change EReal.exp (-(C:EReal)) ≤ EReal.exp 0 + simpa only [EReal.expOrderIso_apply] using + EReal.expOrderIso.monotone (show -(C:EReal) ≤ 0 from (EReal.neg_le_zero.mpr (EReal.coe_ennreal_nonneg C))) +lemma expNeg_ne_top (C : ℝ≥0∞) : expNeg C≠⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top (expNeg_le_one C) +lemma expNeg_continuous : Continuous expNeg := + ENNReal.continuous_exp.comp (continuous_coe_ennreal_ereal.neg) +lemma expNeg_toReal_continuous : Continuous (fun C => (expNeg C).toReal) := by + apply continuous_iff_continuousAt.mpr + intro C + exact (ENNReal.continuousAt_toReal (expNeg_ne_top C)).comp expNeg_continuous.continuousAt + +lemma arrayWindowHeight_actual {d : ℕ} (e : Direction d) (t J : Environment d → ℤ → ℕ) + (X : EpisodeInput e) (hmono : Monotone (t X.1.1)) (i : ℤ) (m : ℕ) : + arrayWindowHeight e i m (actualArrayMap e t J X)=(t X.1.1 (i+m)-t X.1.1 i:ℕ) := by + have hs : (∑ r∈Finset.range m, (t X.1.1 (i+r+1)-t X.1.1 (i+r)))= + t X.1.1 (i+m)-t X.1.1 i := by + induction m with + | zero => simp + | succ m ih => + rw [Finset.sum_range_succ,ih] + have h₁ := hmono (show i ≤ i+(m:ℤ) by omega) + have h₂ := hmono (show i+(m:ℤ) ≤ i+m+1 by omega) + have hx : i+(m+1:ℕ)=i+(m:ℤ)+1 := by omega + rw [hx] + omega + simpa only [arrayWindowHeight,actualArrayMap,Nat.cast_sum] using congrArg (fun n : ℕ => (n:ℕ∞)) hs + +lemma episodeCost_nonneg_real {d : ℕ} (e : Direction d) (t : Environment d → ℤ → ℕ) + (ω : Environment d) (hmono : Monotone (t ω)) + (hpos : ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k ω≠0) (i : ℤ) : + 0≤Real.log (crossingQuenched (realPosition (step e)) 0 (t ω i) ω).toReal- + Real.log (crossingQuenched (realPosition (step e)) 0 (t ω (i+1)) ω).toReal := by + apply sub_nonneg.mpr + apply Real.log_le_log (ENNReal.toReal_pos (hpos _) (crossingQuenched_ne_top _ _ _ _)) + apply ENNReal.toReal_mono (crossingQuenched_ne_top _ _ _ _) + exact crossingQuenched_antitone _ _ _ (by exact_mod_cast hmono (show i ≤ i+1 by omega)) + +lemma arrayWindowCost_actual {d : ℕ} (e : Direction d) (t J : Environment d → ℤ → ℕ) + (X : EpisodeInput e) (hmono : Monotone (t X.1.1)) + (hpos : ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k X.1.1≠0) (i : ℤ) (m : ℕ) : + arrayWindowCost e i m (actualArrayMap e t J X)=ENNReal.ofReal + (Real.log (crossingQuenched (realPosition (step e)) 0 (t X.1.1 i) X.1.1).toReal- + Real.log (crossingQuenched (realPosition (step e)) 0 (t X.1.1 (i+m)) X.1.1).toReal) := by + unfold arrayWindowCost + simp only [actualArrayMap,episodeCost] + rw [←ENNReal.ofReal_sum_of_nonneg (fun (r : ℕ) _ => episodeCost_nonneg_real e t X.1.1 hmono hpos (i+(r:ℤ)))] + congr 1 + induction m with + | zero => simp + | succ m ih => + rw [Finset.sum_range_succ,ih] + have hx : i+(m+1:ℕ)=i+(m:ℤ)+1 := by omega + rw [hx] + ring + +lemma expNeg_log_ratio (a b : ℝ≥0∞) (ha : a≠0) (hat : a≠⊤) + (hb : b≠0) (hbt : b≠⊤) (hba : b≤a) : + expNeg (ENNReal.ofReal (Real.log a.toReal-Real.log b.toReal))=b/a := by + have hnonneg : 0≤Real.log a.toReal-Real.log b.toReal := sub_nonneg.mpr + (Real.log_le_log (ENNReal.toReal_pos hb hbt) (ENNReal.toReal_mono hat hba)) + unfold expNeg + rw [EReal.coe_ennreal_ofReal, max_eq_left hnonneg] + simp only [←EReal.coe_neg,EReal.exp_coe] + rw [neg_sub,Real.exp_sub,Real.exp_log (ENNReal.toReal_pos hb hbt),Real.exp_log (ENNReal.toReal_pos ha hat)] + rw [ENNReal.ofReal_div_of_pos (ENNReal.toReal_pos ha hat),ENNReal.ofReal_toReal hbt,ENNReal.ofReal_toReal hat] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def arrayProfileMass {d : ℕ} (e : Direction d) (j : ℤ) + (p : StationaryCompact.Label) (z : HorizontalSpace e) (Y : ActualEpisodeArray e) : ℝ≥0∞ := + ENNReal.ofReal (Y.2.2.1 (j,p,z):ℝ) + +lemma arrayProfileMass_continuous {d : ℕ} (e : Direction d) (j : ℤ) + (p : StationaryCompact.Label) (z : HorizontalSpace e) : Continuous (arrayProfileMass e j p z) := by + exact ENNReal.continuous_ofReal.comp (by fun_prop) + +noncomputable def arrayUpperRows {d : ℕ} (e : Direction d) (i : ℤ) (m a : ℕ) + (Y : ActualEpisodeArray e) : UpperRows e := fun p => Y.2.2.2 (i,m,a,p.1,p.2) +lemma arrayUpperRows_continuous {d : ℕ} (e : Direction d) (i : ℤ) (m a : ℕ) : + Continuous (arrayUpperRows e i m a) := by unfold arrayUpperRows; fun_prop + +noncomputable def arrayKernelImage {d : ℕ} (e : Direction d) (i : ℤ) (m a H : ℕ) + (A : Set (HorizontalSpace e)) (Y : ActualEpisodeArray e) : ℝ≥0∞ := + ∑' z, arrayProfileMass e i (i,a) z Y * upperHorizontalKernel e H (arrayUpperRows e i m a Y) z A + +lemma arrayKernelImage_lowerSemicontinuous {d : ℕ} (e : Direction d) (i : ℤ) (m a H : ℕ) + (A : Set (HorizontalSpace e)) : LowerSemicontinuous (arrayKernelImage e i m a H A) := by + unfold arrayKernelImage + apply lowerSemicontinuous_tsum + intro z + simp_rw [upperHorizontalKernel_apply, hitKernel_eq_tsum_words _ _ _ _ (disjoint_strip_upper _ _ _) _, + ←ENNReal.tsum_mul_left] + apply lowerSemicontinuous_tsum + intro w + have hp : Continuous (fun Y : ActualEpisodeArray e => (Y.2.2.1 (i,(i,a),z):ℝ)) := by fun_prop + have hw : Continuous (fun Y : ActualEpisodeArray e => + wordWeight (upperEnvironment e (arrayUpperRows e i m a Y)) (horizontalLift e 0 z) w.val.val) := + (continuous_wordWeight _ _).comp ((upperEnvironment_continuous e).comp (arrayUpperRows_continuous e i m a)) + have he : (fun Y : ActualEpisodeArray e => arrayProfileMass e i (i,a) z Y * + ENNReal.ofReal (wordWeight (upperEnvironment e (arrayUpperRows e i m a Y)) + (horizontalLift e 0 z) w.val.val)) = + (fun Y => ENNReal.ofReal ((Y.2.2.1 (i,(i,a),z):ℝ)* + wordWeight (upperEnvironment e (arrayUpperRows e i m a Y)) (horizontalLift e 0 z) w.val.val)) := by + funext Y + exact (ENNReal.ofReal_mul (Y.2.2.1 (i,(i,a),z)).property.1).symm + rw [he] + exact (ENNReal.continuous_ofReal.comp (hp.mul hw)).lowerSemicontinuous + +noncomputable def arrayDiscountedProfile {d : ℕ} (e : Direction d) (i : ℤ) (m a : ℕ) + (z : HorizontalSpace e) (Y : ActualEpisodeArray e) : ℝ≥0∞ := + expNeg (arrayWindowCost e i m Y)*arrayProfileMass e (i+m) (i,a) z Y + +lemma arrayDiscountedProfile_continuous {d : ℕ} (e : Direction d) (i : ℤ) (m a : ℕ) + (z : HorizontalSpace e) : Continuous (arrayDiscountedProfile e i m a z) := by + have he : arrayDiscountedProfile e i m a z = fun Y => ENNReal.ofReal + ((expNeg (arrayWindowCost e i m Y)).toReal*(Y.2.2.1 (i+m,(i,a),z):ℝ)) := by + funext Y + rw [ENNReal.ofReal_mul ENNReal.toReal_nonneg,ENNReal.ofReal_toReal (expNeg_ne_top _)] + rfl + rw [he] + exact ENNReal.continuous_ofReal.comp ((expNeg_toReal_continuous.comp + (arrayWindowCost_continuous e i m)).mul (by fun_prop)) + +def ArrayContinuation {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) : Prop := + ∀ (i : ℤ) (m a H : ℕ) (z : HorizontalSpace e), arrayWindowHeight e i m Y=H → + arrayKernelImage e i m a H {z} Y ≤ arrayDiscountedProfile e i m a z Y + +lemma arrayContinuation_closed {d : ℕ} (e : Direction d) : + IsClosed {Y : ActualEpisodeArray e | ArrayContinuation e Y} := by + simp only [ArrayContinuation,Set.ofPred_forall] + refine isClosed_iInter fun i => isClosed_iInter fun m => isClosed_iInter fun a => + isClosed_iInter fun H => isClosed_iInter fun z => ?_ + have hg : IsClosed {Y : ActualEpisodeArray e | arrayKernelImage e i m a H {z} Y ≤ + arrayDiscountedProfile e i m a z Y} := + (arrayKernelImage_lowerSemicontinuous e i m a H {z}).isClosed_epigraph.preimage + (continuous_id.prodMk (arrayDiscountedProfile_continuous e i m a z)) + have ho : IsOpen {Y : ActualEpisodeArray e | arrayWindowHeight e i m Y=(H:ℕ∞)} := + (ENat.isOpen_singleton (by simp)).preimage (arrayWindowHeight_continuous e i m) + convert ho.isClosed_compl.union hg using 1 + ext Y + simp [imp_iff_not_or] + +lemma actual_arrayProfileMass {d : ℕ} (e : Direction d) (t J : Environment d → ℤ → ℕ) + (X : EpisodeInput e) (j : ℤ) (p : StationaryCompact.Label) (z : HorizontalSpace e) : + arrayProfileMass e j p z (actualArrayMap e t J X)= + globalHorizontalProfile e (t X.1.1 j) X.1.1 {X.1.2 p+z} := by + exact ENNReal.ofReal_toReal (measure_ne_top _ _) + +lemma actual_arrayKernelImage {d : ℕ} (e : Direction d) (t J : Environment d → ℤ → ℕ) + (X : EpisodeInput e) (i : ℤ) (m a : ℕ) (A : Set (HorizontalSpace e)) : + arrayKernelImage e i m a (t X.1.1 (i+m)-t X.1.1 i) A (actualArrayMap e t J X)= + ∫⁻ z, variableHitKernel (realPosition (step e)) (t X.1.1 (i+m)-t X.1.1 i) + (X.1.1,horizontalLift e (t X.1.1 i) z) + {y | horizontalProjection e y-X.1.2 (i,a)∈A} + ∂globalHorizontalProfile e (t X.1.1 i) X.1.1 := by + unfold arrayKernelImage + simp_rw [actual_arrayProfileMass] + have he : arrayUpperRows e i m a (actualArrayMap e t J X)= + fun p => episodeSplicedRow e t X i m a p.1 p.2 := rfl + simp_rw [he,episodeSpliced_kernel] + rw [lintegral_countable'] + simp_rw [mul_comm] + exact (Equiv.addLeft (X.1.2 (i,a))).tsum_eq (fun z : HorizontalSpace e => + globalHorizontalProfile e (t X.1.1 i) X.1.1 {z} * + variableHitKernel (realPosition (step e)) (t X.1.1 (i+m)-t X.1.1 i) + (X.1.1,horizontalLift e (t X.1.1 i) z) + {y | horizontalProjection e y-X.1.2 (i,a)∈A}) + +lemma actual_arrayContinuation {d : ℕ} (e : Direction d) (t J : Environment d → ℤ → ℕ) + (X : EpisodeInput e) (hmono : Monotone (t X.1.1)) + (hpos : ∀ k : ℕ, crossingQuenched (realPosition (step e)) 0 k X.1.1≠0) : + ArrayContinuation e (actualArrayMap e t J X) := by + intro i m a H z hH + rw [arrayWindowHeight_actual e t J X hmono] at hH + have hH' : t X.1.1 (i+m)-t X.1.1 i=H := by exact_mod_cast hH + subst H + rw [actual_arrayKernelImage] + have hik : t X.1.1 i ≤ t X.1.1 (i+m) := hmono (by omega) + have hadd : t X.1.1 i+(t X.1.1 (i+m)-t X.1.1 i)=t X.1.1 (i+m) := Nat.add_sub_of_le hik + have hh := globalHorizontalProfile_continuation e (t X.1.1 i) + (t X.1.1 (i+m)-t X.1.1 i) X.1.1 (hpos _) {w | w-X.1.2 (i,a)∈({z}:Set (HorizontalSpace e))} + simp only [←Nat.cast_add,hadd] at hh + have hs : {w : HorizontalSpace e | w-X.1.2 (i,a)∈({z}:Set (HorizontalSpace e))}={X.1.2 (i,a)+z} := by + ext w + simp only [Set.mem_ofPred,Set.mem_singleton_iff] + rw [sub_eq_iff_eq_add,add_comm z] + convert hh using 1 + · rfl + · unfold arrayDiscountedProfile + rw [arrayWindowCost_actual e t J X hmono hpos,expNeg_log_ratio _ _ (hpos _) + (crossingQuenched_ne_top _ _ _ _) (hpos _) (crossingQuenched_ne_top _ _ _ _) + (crossingQuenched_antitone _ _ _ (by exact_mod_cast hik)),actual_arrayProfileMass,hs] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/BadArrayElliptic.lean b/lean/OAI/Probability/Ballisticity/Stationary/BadArrayElliptic.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ad11012a44e5b2bd014610ff68c7a213bd87ebc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/BadArrayElliptic.lean @@ -0,0 +1,49 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.StationaryWindowEntropy + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma row_law_lower_bound (C : OperationalConstants ν e f D) : + ∀ᵐ r ∂ν, ∀ u, C.κ ≤ r.1 u := by + have hp : ∀ᵐ ω ∂environmentLaw ν, ∀ u, C.κ ≤ (ω 0).1 u := + C.rows.mono fun ω hω => hω 0 + have hm : MeasurableSet {r : Row d | ∀ u, C.κ ≤ r.1 u} := by + simp only [Set.ofPred_forall] + exact MeasurableSet.iInter fun u => measurableSet_le measurable_const + ((measurable_pi_apply u).comp measurable_subtype_coe) + have hmp := measurePreserving_eval_infinitePi (fun _ : Lattice d => ν) 0 + have hh := (ae_map_iff hmp.measurable.aemeasurable hm).mpr hp + simpa only [environmentLaw,hmp.map_eq] using hh + +lemma bad_limit_elliptic (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (Ns : ℕ → ℕ) (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) : + ∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ArrayElliptic e C.κ Y := by + apply closed_support_weak_limit _ ρ hlim _ (arrayElliptic_closed e C.κ) + intro n + exact actualOccupation_elliptic e ν _ + (C.paddedTimes hef (Ns n)) (C.paddedStages hef (Ns n)) + (C.paddedTimes_measurable hef (Ns n)) (C.paddedStages_measurable hef (Ns n)) (Ns n) + (C.activeCount hef (Ns n)) (C.bad_raw_mass_pos hef (Ns n) (hN n) (hmass n)) + C.κ C.row_law_lower_bound + ((cond_absolutelyContinuous (μ:=environmentLaw ν) + (s:=badCrossingEvent e (Ns n) (1/2))).ae_le C.rows) + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/BadArraySampling.lean b/lean/OAI/Probability/Ballisticity/Stationary/BadArraySampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..e05e6382806e814d20b69431fbec2bb34743d51f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/BadArraySampling.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.BadCrossingEpisodes +import OAI.Probability.Ballisticity.Estimates.BadOccupationLimit + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +lemma bad_raw_mass_pos (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (hN : C.sfloor ≤ (N:ℝ)) + (hmass : (N:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e N (1/2))) : + 0<(actualOccupationRaw e ν ((environmentLaw ν)[|badCrossingEvent e N (1/2)]) + (C.paddedTimes hef N) (C.paddedStages hef N) (C.paddedTimes_measurable hef N) + N (C.activeCount hef N)).real Set.univ := by + have hN0 : 0 C.occupation hef (Ns (φ n)) + ((environmentLaw ν)[|badCrossingEvent e (Ns (φ n)) (1/2)])) atTop (𝓝 ρ) ∧ + MeasurePreserving StationaryCompact.shift (ρ : Measure (ActualEpisodeArray e)) + (ρ : Measure (ActualEpisodeArray e)) ∧ + (∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ∀ p j z, + Tendsto (fun n => arraySamplingError e p j z (2^n) Y) atTop (𝓝 0)) ∧ + (∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ∀ p q z, p≠q → + arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0) := by + obtain ⟨ρ,φ,hφ,hlim,hstat⟩ := C.bad_occupation_stationary_limit hef hD Ns hNs hN hlarge hmass + refine ⟨ρ,φ,hφ,hlim,hstat,?_,?_⟩ + · apply ae_all_iff.mpr + intro p + apply ae_all_iff.mpr + intro j + apply ae_all_iff.mpr + intro z + exact actualOccupation_limit_sampling e ν + (fun n => (environmentLaw ν)[|badCrossingEvent e (Ns (φ n)) (1/2)]) + (fun n => C.paddedTimes hef (Ns (φ n))) (fun n => C.paddedStages hef (Ns (φ n))) + (fun n => C.paddedTimes_measurable hef (Ns (φ n))) + (fun n => C.paddedStages_measurable hef (Ns (φ n))) + (fun n => Ns (φ n)) (fun n => C.activeCount hef (Ns (φ n))) + (fun n => C.activeCount_measurable hef (Ns (φ n))) + (fun n => C.bad_raw_mass_pos hef (Ns (φ n)) (hN (φ n)) (hmass (φ n))) ρ hlim p j z + · apply ae_all_iff.mpr + intro p + apply ae_all_iff.mpr + intro q + apply ae_all_iff.mpr + intro z + by_cases hpq : p=q + · exact Filter.Eventually.of_forall (fun _ h => (h hpq).elim) + · exact (actualOccupation_limit_zero e ν + (fun n => (environmentLaw ν)[|badCrossingEvent e (Ns (φ n)) (1/2)]) + (fun n => C.paddedTimes hef (Ns (φ n))) (fun n => C.paddedStages hef (Ns (φ n))) + (fun n => C.paddedTimes_measurable hef (Ns (φ n))) + (fun n => C.paddedStages_measurable hef (Ns (φ n))) + (fun n => Ns (φ n)) (fun n => C.activeCount hef (Ns (φ n))) + (fun n => C.activeCount_measurable hef (Ns (φ n))) + (fun n => C.bad_raw_mass_pos hef (Ns (φ n)) (hN (φ n)) (hmass (φ n))) ρ hlim p q hpq z).mono + (fun _ h _ => h) + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/BadCrossingEpisodes.lean b/lean/OAI/Probability/Ballisticity/Stationary/BadCrossingEpisodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..256722db565efddc2787b9029831f76386cc682d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/BadCrossingEpisodes.lean @@ -0,0 +1,207 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OccupationSampling +import OAI.Probability.Ballisticity.Estimates.LocalRadiusOrder +import OAI.Probability.Ballisticity.Stationary.EpisodePotentialIteration +import OAI.Probability.Ballisticity.Stationary.EpisodeMeanDrop +import OAI.Probability.Ballisticity.Crossings.BadCrossingLaw + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} {e f : Direction d} {D : ℝ} + +lemma radius_nonneg (C : OperationalConstants ν e f D) : + 0 ≤ episodeScaleRadius ν e f C.sfloor := + (fluctuationRadius_pos _ _ _).le + +noncomputable def activeCount (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (ω : Environment d) : ℕ := + EpisodeChainLedger.number (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω N + +noncomputable def stagesAt (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (ω : Environment d) (i : ℕ) : ℕ := + EpisodeChainLedger.stepMark (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω i + +noncomputable def dropAt (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (N : ℕ) (ω : Environment d) (i : ℕ) : ℝ := + EpisodeChainLedger.dropMark (k:=C.k) e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N ω i + +noncomputable def injectionCost (C : OperationalConstants ν e f D) : ℝ := + ((BoundedInjection.injectionMultiplier (episodeScaleRadius ν e f C.sfloor)*C.k+1:ℕ)*(-Real.log C.κ)) + +lemma height_pos (C : OperationalConstants ν e f D) : + ∀ s, C.sfloor ≤ s → 0 < episodeStageH C.χ C.b s := by + intro s hs + have hpos : 0 hω y e) N)) + · exact crossingQuenched_ne_top _ _ _ _ + have hkl := badCrossing_cond_entropy e N (1/2) D (environmentLaw ν) hN0 hmass + have hj := actual_expected_stages (k:=C.k) ν e f hef (episodeScaleRadius ν e f) + C.fexp C.g C.χ C.b C.sfloor C.K D (1/2) C.radius_nonneg N C.hs hN + C.hf.le C.hg C.hb C.hK hD C.height C.stages Q hkl C.coeff C.small hlarge + have hh := EpisodeChainLedger.mean_episode_drops_local (k:=C.k) e f hef + (episodeScaleRadius ν e f) C.fexp C.g C.χ C.b C.sfloor C.radius_nonneg N + C.order C.hf.le C.hb (lt_of_lt_of_le zero_lt_one C.hs) C.height_pos + C.κ C.hκ0 C.hκ1 (lt_of_lt_of_le (by norm_num) C.hk) C.hbκ Q hκQ (1/2) + (badCrossing_cond_drop e N (1/2) (environmentLaw ν) hN0 hpositive) hj L hL hcharge + dsimp only [activeCount,injectionCost,stagesAt,dropAt] + dsimp only [Q] at hh + refine ⟨?_,?_,?_⟩ + · convert hh.1 using 1 + ring + · convert hh.2.1 using 1 + ring + · have hn : (1/2:ℝ)/2 = 1/4 := by norm_num + rw [hn] at hh + exact hh.2.2 + +end OperationalConstants +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma episodeInputLaw_environment {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) : + (episodeInputLaw e ν Q t ht).map (fun X => X.1.1)=Q := by + change Measure.map (Prod.fst ∘ Prod.fst) _=Q + rw [←Measure.map_map measurable_fst measurable_fst] + unfold episodeInputLaw + rw [Measure.map_fst_prod,measure_univ,one_smul] + exact Measure.fst_compProd Q (globalEpisodeAnchors e t ht) + +lemma episodeInputLaw_env_integral {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (F : Environment d → ℝ) (hF : Measurable F) : + (∫ X, F X.1.1 ∂episodeInputLaw e ν Q t ht)=(∫ ω, F ω ∂Q) := by + have hh := integral_map ((measurable_fst.comp measurable_fst).aemeasurable) + hF.aestronglyMeasurable (μ:=episodeInputLaw e ν Q t ht) + change (∫ y, F y ∂Measure.map (fun X => X.1.1) (episodeInputLaw e ν Q t ht)) = _ at hh + rw [episodeInputLaw_environment] at hh + exact hh.symm + +namespace EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "T" => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "M" => number (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "j" => stepMark (k:=k) e f hef r fexp g χ b sfloor hR N + +noncomputable def arrayTime (ω : Environment d) (i : ℤ) := T ω i.toNat +noncomputable def arrayStages (ω : Environment d) (i : ℤ) := + if i<0 then 0 else j ω i.toNat +local notation "t" => arrayTime (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "s" => arrayStages (k:=k) e f hef r fexp g χ b sfloor hR N + +lemma arrayTime_measurable (i : ℤ) : Measurable (fun ω => t ω i) := + episodeBoundary_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i.toNat +lemma arrayStages_measurable (i : ℤ) : Measurable (fun ω => s ω i) := by + unfold arrayStages + split + · exact measurable_const + · exact stepMark_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i.toNat + +lemma arrayTime_neg (ω : Environment d) (i : ℤ) (hi : i≤0) : t ω i=0 := by + simp only [arrayTime,Int.toNat_eq_zero.mpr hi,episodeBoundary] + +lemma arrayTime_nat (ω : Environment d) (i : ℕ) : t ω i=T ω i := by + simp only [arrayTime,Int.toNat_natCast] + +lemma arrayTime_terminal (ω : Environment d) (i : ℕ) (hi : M ω N ≤ i) : t ω i = N := by + rw [arrayTime_nat] + have hn : ¬ T ω i < N := by + rw [active_iff_lt_number (k:=k) e f hef r fexp g χ b sfloor hR N ω i] + exact not_lt.mpr hi + exact le_antisymm (episodeBoundary_le (k:=k) e f hef r fexp g χ b sfloor hR N ω i) (Nat.le_of_not_lt hn) + +lemma arrayStages_nat (ω : Environment d) (i : ℕ) : s ω i=j ω i := by + simp only [arrayStages,Int.natCast_nonneg,not_lt.mpr,ite_false,Int.toNat_natCast] + +lemma arrayStages_terminal (ω : Environment d) (i : ℕ) (hi : M ω N ≤ i) : s ω i = 0 := by + rw [arrayStages_nat] + have hn : ¬ T ω i < N := by + rw [active_iff_lt_number (k:=k) e f hef r fexp g χ b sfloor hR N ω i] + exact not_lt.mpr hi + simp only [stepMark,ite_eq_right hn] + +lemma operational_raw_mass (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (Q : Measure (Environment d)) [IsFiniteMeasure Q] : + (actualOccupationRaw e ν Q t s (arrayTime_measurable (k:=k) e f hef r fexp g χ b sfloor hR N) N (fun ω => M ω N)).real Set.univ= + ∫ ω, (M ω N:ℝ) ∂Q := by + unfold actualOccupationRaw + have hM : Measurable (fun X : EpisodeInput e => M X.1.1 N) := + (number_measurable (k:=k) e f hef r fexp g χ b sfloor hR N N).comp (measurable_fst.comp measurable_fst) + rw [StationaryCompact.episodeOccupationRaw_mass N _ _ + (actualArrayMap_measurable e t s (arrayTime_measurable (k:=k) e f hef r fexp g χ b sfloor hR N) + (arrayStages_measurable (k:=k) e f hef r fexp g χ b sfloor hR N)) _ + hM + (fun X => number_le (k:=k) e f hef r fexp g χ b sfloor hR N X.1.1 N) _ StationaryCompact.shift_continuous.measurable] + exact episodeInputLaw_env_integral e ν Q t _ _ + ((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp (number_measurable (k:=k) e f hef r fexp g χ b sfloor hR N N)) + +lemma operational_mass_positive (Q : Measure (Environment d)) [IsProbabilityMeasure Q] (hN : 0 by + change (1:ℝ) ≤ (M ω N:ℝ) + exact_mod_cast Nat.one_le_iff_ne_zero.mpr (Nat.ne_of_gt (number_positive (k:=k) e f hef r fexp g χ b sfloor hR N ω hN))) + simp only [integral_const,probReal_univ,one_smul] at hh + exact lt_of_lt_of_le zero_lt_one hh + +end EpisodeChainLedger +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/BadFiniteArray.lean b/lean/OAI/Probability/Ballisticity/Stationary/BadFiniteArray.lean new file mode 100644 index 0000000000000000000000000000000000000000..91bfbd58c0f0e6880726054961ecc81643a339a4 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/BadFiniteArray.lean @@ -0,0 +1,70 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BadDropMoment +import OAI.Probability.Ballisticity.Estimates.OperationalLengthMarks +import OAI.Probability.Ballisticity.Renewal.PositiveLengthMark + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma logLengthMark_real {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hf : (Y.1 0).1<⊤) : + (logLengthMark e Y).toReal = Real.log (1+((Y.1 0).1.toNat:ℝ)) := by + have he := ENat.natCast_toNat hf.ne + change (ENNReal.log (1+(Y.1 0).1.toENNReal)).toENNReal.toReal=_ + generalize (Y.1 0).1.toNat=n at he ⊢ + rw [←he,ENat.toENNReal_coe] + rw [ENNReal.log_pos_real (by positivity) (by finiteness),EReal.real_coe_toENNReal, + ENNReal.toReal_add ENNReal.one_ne_top (ENNReal.natCast_ne_top n)] + simp only [ENNReal.toReal_one,ENNReal.toReal_natCast] + rw [ENNReal.toReal_ofReal (Real.log_nonneg (le_add_of_nonneg_right (Nat.cast_nonneg n)))] + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +theorem bad_array_finite_marks (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (hD : 0≤D) (Ns : ℕ → ℕ) (hNs : Tendsto Ns atTop atTop) + (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hlarge : ∀ n, 32*C.b ≤ (1/2:ℝ)*Real.log (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) : + ∃ ρ : ProbabilityMeasure (ActualEpisodeArray e), ∃ φ : ℕ → ℕ, + StrictMono φ ∧ + Tendsto (fun n => C.occupation hef (Ns (φ n)) + ((environmentLaw ν)[|badCrossingEvent e (Ns (φ n)) (1/2)])) atTop (𝓝 ρ) ∧ + MeasurePreserving StationaryCompact.shift (ρ : Measure (ActualEpisodeArray e)) + (ρ : Measure (ActualEpisodeArray e)) ∧ + (∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ∀ p j z, + Tendsto (fun n => arraySamplingError e p j z (2^n) Y) atTop (𝓝 0)) ∧ + (∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), ∀ p q z, p≠q → + arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0) ∧ + (∀ᵐ Y ∂(ρ : Measure (ActualEpisodeArray e)), + 0<(Y.1 0).1 ∧ (Y.1 0).1<⊤ ∧ (Y.1 0).2.1<⊤ ∧ (Y.1 0).2.2<∞) ∧ + Integrable (fun Y => ((Y.1 0).2.1).toENNReal.toReal) (ρ : Measure (ActualEpisodeArray e)) ∧ + Integrable (fun Y => Real.log (1+((Y.1 0).1.toNat:ℝ))) (ρ : Measure (ActualEpisodeArray e)) ∧ + Integrable (fun Y => (Y.1 0).2.2.toReal) (ρ : Measure (ActualEpisodeArray e)) ∧ + C.b ≤ ∫ Y, (Y.1 0).2.2.toReal ∂(ρ : Measure (ActualEpisodeArray e)) := by + obtain ⟨ρ,φ,hφ,hlim,hstat,hsample,hzero⟩ := C.bad_array_sampling_limit hef hD Ns hNs hN hlarge hmass + have hJ := C.bad_limit_finite_stages hef hD (fun n => Ns (φ n)) (fun n => hN (φ n)) + (fun n => hlarge (φ n)) (fun n => hmass (φ n)) ρ hlim + have hc := C.bad_limit_drop_moment hef hD (fun n => Ns (φ n)) (fun n => hN (φ n)) + (fun n => hlarge (φ n)) (fun n => hmass (φ n)) ρ hlim + have hh := C.bad_limit_length_moment hef hD (fun n => Ns (φ n)) (fun n => hN (φ n)) + (fun n => hlarge (φ n)) (fun n => hmass (φ n)) ρ hlim + have hpos := C.bad_limit_positive_length hef (fun n => Ns (φ n)) (fun n => hN (φ n)) + (fun n => hmass (φ n)) ρ hlim + refine ⟨ρ,φ,hφ,hlim,hstat,hsample,hzero,?_,hJ.2,?_,hc.2.1,hc.2.2⟩ + · filter_upwards [hpos,hh.1,hJ.1,hc.1] with Y ha hb hj hk + exact ⟨ha,hb,hj,hk⟩ + · exact hh.2.congr (hh.1.mono (fun Y hY => logLengthMark_real e Y hY)) + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/CompactCapTransfer.lean b/lean/OAI/Probability/Ballisticity/Stationary/CompactCapTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..95d64aefdd5da0f918f8a57354d566335c6a101b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/CompactCapTransfer.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.FavorablePairFraction +import OAI.Probability.Ballisticity.Estimates.WeakTailTransfer + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma capExcessTest_le_one (a : ℝ) {D : ℝ} (hD : 0 ≤ D) (x : unitInterval) : + capExcessTest a D x ≤ 1 := by + have hh0 : 0 ≤ min (D*(x:ℝ)) 1 := le_min (mul_nonneg hD x.2.1) zero_le_one + have hh1 := min_le_right (D*(x:ℝ)) 1 + change max ((min (D*(x:ℝ)) 1)^2-a^2) 0 ≤ 1 + apply max_le <;> nlinarith [sq_nonneg a] + +lemma capExcess_integrable (a D : ℝ) (μ : ProbabilityMeasure unitInterval) : + Integrable (capExcessTest a D) (μ : Measure unitInterval) := + (capExcessTest a D).continuous.integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +lemma capExcess_integral_bounds (a : ℝ) {D : ℝ} (hD : 0 ≤ D) + (μ : ProbabilityMeasure unitInterval) : + 0 ≤ (∫ x, capExcessTest a D x ∂(μ : Measure unitInterval)) ∧ + (∫ x, capExcessTest a D x ∂(μ : Measure unitInterval)) ≤ 1 := by + constructor + · exact integral_nonneg (capExcessTest_nonneg _ _) + · calc + _ ≤ ∫ x : unitInterval, (1:ℝ) ∂(μ : Measure unitInterval) := + integral_mono (capExcess_integrable _ _ _) (integrable_const _) + (capExcessTest_le_one a hD) + _ = 1 := by simp + +lemma compact_capped_moment_transfer + (μs νs : ℕ → ProbabilityMeasure unitInterval) + {C D : ℝ} (hC : 0 ≤ C) (hD : 0 < D) + (ht : ∀ ns : ℕ → ℕ, Tendsto ns atTop atTop → ∀ u > 0, u < 1 → + limsup (fun n => (μs (ns n) : Measure unitInterval).real {x | u < (x:ℝ)}) atTop ≤ + C * limsup (fun n => (νs (ns n) : Measure unitInterval).real {y | u/D < (y:ℝ)}) atTop) + (a : ℝ) (ha : 0 ≤ a) : + limsup (fun n => ∫ x, capExcessTest a 1 x ∂(μs n : Measure unitInterval)) atTop ≤ + C * limsup (fun n => ∫ y, capExcessTest a (2*D) y ∂(νs n : Measure unitInterval)) atTop := by + let F : ℕ → ℝ := fun n => ∫ x, capExcessTest a 1 x ∂(μs n : Measure unitInterval) + let G : ℕ → ℝ := fun n => ∫ y, capExcessTest a (2*D) y ∂(νs n : Measure unitInterval) + have hF0 (n) : 0 ≤ F n := (capExcess_integral_bounds a (by norm_num) _).1 + have hF1 (n) : F n ≤ 1 := (capExcess_integral_bounds a (by norm_num) _).2 + have hG0 (n) : 0 ≤ G n := (capExcess_integral_bounds a (by positivity) _).1 + have hG1 (n) : G n ≤ 1 := (capExcess_integral_bounds a (by positivity) _).2 + have hFb : IsBoundedUnder (· ≤ ·) atTop F := isBoundedUnder_of ⟨1,hF1⟩ + have hFc : IsCoboundedUnder (· ≤ ·) atTop F := isCoboundedUnder_le_of_le atTop hF0 + have hGb : IsBoundedUnder (· ≤ ·) atTop G := isBoundedUnder_of ⟨1,hG1⟩ + apply (limsup_le_iff hFc hFb).mpr + intro b hb + by_contra hbad + have hfreq : ∃ᶠ n in atTop, b ≤ F n := by simpa only [not_eventually,not_lt] using hbad + obtain ⟨ns,hns,hnsb⟩ := exists_seq_forall_of_frequently hfreq + obtain ⟨p,hp,ks,hks,hpk⟩ := isCompact_univ.tendsto_subseq + (x := fun n => (μs (ns n),νs (ns n))) (fun _ => Set.mem_univ _) + have hμ : Tendsto (fun n => μs (ns (ks n))) atTop (𝓝 p.1) := + (continuous_fst.tendsto p).comp hpk + have hν : Tendsto (fun n => νs (ns (ks n))) atTop (𝓝 p.2) := + (continuous_snd.tendsto p).comp hpk + have htail := weak_tail_comparison _ _ _ _ hμ hν hC hD + (ht (ns ∘ ks) (hns.comp hks.tendsto_atTop)) + have hcomp := capExcess_integral_comparison p.1 p.2 hC (by positivity : 0 < 2*D) htail a ha + have hlimF : Tendsto (F ∘ (ns ∘ ks)) atTop + (𝓝 (∫ x, capExcessTest a 1 x ∂(p.1 : Measure unitInterval))) := + (ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mp hμ) + (BoundedContinuousFunction.mkOfCompact (capExcessTest a 1)) + have hlimG : Tendsto (G ∘ (ns ∘ ks)) atTop + (𝓝 (∫ y, capExcessTest a (2*D) y ∂(p.2 : Measure unitInterval))) := + (ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mp hν) + (BoundedContinuousFunction.mkOfCompact (capExcessTest a (2*D))) + have hhF := ge_of_tendsto hlimF (Eventually.of_forall fun n => hnsb (ks n)) + have hhG : (∫ y, capExcessTest a (2*D) y ∂(p.2 : Measure unitInterval)) ≤ limsup G atTop := by + rw [← hlimG.limsup_eq] + exact (hns.comp hks.tendsto_atTop).limsup_comp_le_limsup + (isCoboundedUnder_le_of_le atTop (fun n => hG0 (ns (ks n)))) hGb + exact (not_le_of_gt hb) (hhF.trans (hcomp.trans (mul_le_mul_of_nonneg_left hhG hC))) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeAdapted.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeAdapted.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf969a24c6c6d8bbee00cc2aac5d358b914e8f67 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeAdapted.lean @@ -0,0 +1,179 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeInjection +import OAI.Probability.Ballisticity.Stationary.EpisodeCharts + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +noncomputable def episodeInitialChart {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) (t : ℕ) : EpisodeChart (k:=k) e f r where + height := t+1 + scale := sfloor + profile := fun ω => (episodeInitial (k:=k) e f hef r sfloor hR t ω).profile + measurable_profile := by + apply Measurable.subtype_mk + have hm := measurable_subtype_coe.comp + ((BoundedInjection.injectionProfile_measurable (k:=k) e f hef (r sfloor) hR t).comp + (globalTupleProfile_measurable_below (k:=k) e t)) + exact hm.mono (rowSigma_mono (by + intro x hx + change dot (realPosition x) (realPosition (step e)) < ((t+1:ℕ):ℝ) + exact hx.trans_le (by exact_mod_cast Nat.le_add_right t 1))) le_rfl + event := Set.univ + measurable_event := MeasurableSet.univ + +noncomputable def episodeInitialAtlas {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) (t : ℕ) : + EpisodeAtlas (episodeInitial (k:=k) e f hef r sfloor hR t) where + Label := Unit + countable := inferInstance + chart := fun _ => episodeInitialChart e f hef r sfloor hR t + cover := fun _ => ⟨(),Set.mem_univ _⟩ + correct := fun _ _ _ => rfl + +noncomputable def episodeFinalAtlas {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) : + EpisodeAtlas (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t) := + (episodeInitialAtlas (k:=k) e f hef r sfloor hR t).run hef fexp g χ b sfloor N N + +lemma episodeFinal_height_event {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t m : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] + {ω | (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height=m} := + (episodeFinalAtlas (k:=k) e f hef r fexp g χ b sfloor hR N t).height_event m + +lemma episodeBoundary_height_event {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N i m : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] + {ω | episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i=m} := by + induction i generalizing m with + | zero => + change MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] {_ω : Environment d | (0:ℕ)=m} + exact MeasurableSet.const _ + | succ i ih => + let T := fun ω => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i + let U := fun t ω => (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height + have he : {ω | episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω (i+1)=m} = + ({ω | T ω=m} ∩ {ω | N ≤ m}) ∪ + ⋃ t : {t : ℕ // t < N ∧ t < m}, {ω | T ω=t} ∩ {ω | U t ω=m} := by + ext ω + simp only [Set.mem_ofPred_eq,Set.mem_union,Set.mem_inter_iff,Set.mem_iUnion] + constructor + · intro hh + change (if T ω + cases m with + | none => rfl + | some m => exact False.elim (hl.2 ⟨hm.2.1,hm.2.2.1⟩) + | some l => + cases m with + | none => exact False.elim (hm.2 ⟨hl.2.1,hl.2.2.1⟩) + | some m => + have hj : l.1=m.1 := hl.2.2.2.1.symm.trans hm.2.2.2.1 + have hg := hl.2.2.2.2 + rw [hj] at hg + have hb : (l.2=true) ↔ (m.2=true) := hg.symm.trans hm.2.2.2.2 + have hbool : l.2=m.2 := by + cases h₁ : l.2 <;> cases h₂ : m.2 <;> simp_all only [Bool.false_eq_true,iff_false, + iff_true,not_true_eq_false,iff_self] + exact congrArg some (Prod.ext hj hbool) + +end EpisodeChart +namespace EpisodeAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} + +def IsPartition (A : EpisodeAtlas q) : Prop := + ∀ l m ω, ω∈(A.chart l).event → ω∈(A.chart m).event → l=m + +lemma advance_partition (A : EpisodeAtlas q) (hA : A.IsPartition) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) : + (A.advance hef fexp g χ b sfloor N).IsPartition := by + rintro ⟨l,j⟩ ⟨m,h⟩ ω hl hm + have hl₀ := ((A.chart l).branch_state hef fexp g χ b sfloor N ω j hl).1 + have hm₀ := ((A.chart m).branch_state hef fexp g χ b sfloor N ω h hm).1 + have he := hA l m ω hl₀ hm₀ + subst m + exact Prod.ext rfl ((A.chart l).branch_unique hef fexp g χ b sfloor N ω j h hl hm) + +lemma run_partition (A : EpisodeAtlas q) (hA : A.IsPartition) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N n : ℕ) : + (A.run hef fexp g χ b sfloor N n).IsPartition := by + induction n with + | zero => exact hA + | succ n ih => exact advance_partition _ ih hef fexp g χ b sfloor N + +lemma chart_disjoint (A : EpisodeAtlas q) (hA : A.IsPartition) : + Pairwise (fun l m => Disjoint (A.chart l).event (A.chart m).event) := by + intro l m hne + exact Set.disjoint_left.mpr (fun ω hl hm => hne (hA l m ω hl hm)) + +end EpisodeAtlas + +lemma episodeInitialAtlas_partition {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) (t : ℕ) : + (episodeInitialAtlas (k:=k) e f hef r sfloor hR t).IsPartition := + by + intro l m _ _ _ + change Unit at l m + exact Subsingleton.elim l m + +lemma episodeFinalAtlas_partition {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) : + (episodeFinalAtlas (k:=k) e f hef r fexp g χ b sfloor hR N t).IsPartition := + (episodeInitialAtlas (k:=k) e f hef r sfloor hR t).run_partition + (episodeInitialAtlas_partition e f hef r sfloor hR t) hef fexp g χ b sfloor N N + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCharts.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5cc60f4b69dfb09889794505fc7dc50eab4f4a3 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCharts.lean @@ -0,0 +1,319 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.OperationalEpisode + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma EpisodeState.ext_raw {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {p q : EpisodeState (k:=k) e f r} (hh : p.height=q.height) (hs : p.scale=q.scale) + (hm : p.profile.val=q.profile.val) : p=q := by + cases p with | mk hp sp pp => + cases q with | mk hq sq pq => + dsimp only at hh hs hm + subst hq + subst sq + have he : pp=pq := Subtype.ext hm + subst pq + rfl + +structure EpisodeChart {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) where + height : ℕ + scale : ℝ + profile : Environment d → BudgetProfile (k:=k) e f height (r scale) + measurable_profile : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) height)) _ profile + event : Set (Environment d) + measurable_event : MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) height)] event + +namespace EpisodeChart +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + +noncomputable def state (c : EpisodeChart (k:=k) e f r) (ω : Environment d) : EpisodeState (k:=k) e f r := + ⟨c.height,c.scale,c.profile ω⟩ + +noncomputable def layerProfile (c : EpisodeChart (k:=k) e f r) : Environment d → LayerTupleProfile (k:=k) e c.height := + fun ω => (c.profile ω).toLayerProfile + +lemma measurable_layerProfile (c : EpisodeChart (k:=k) e f r) : + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) c.height)) _ c.layerProfile := + (measurable_subtype_coe.comp c.measurable_profile).subtype_mk + +noncomputable def stop (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (N : ℕ) : Environment d → ℕ := + stageStop e f c.height (r (c.scale*Real.exp (-fexp*b))) (r (c.scale*Real.exp (g*b))) + ((k:ℝ)*b) c.layerProfile (episodeStageH χ b c.scale) (N-c.height) + +noncomputable def growsAt (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (j : ℕ) (ω : Environment d) : Prop := + j=episodeStageH χ b c.scale ∧ ENNReal.ofReal (Real.exp (-((k:ℝ)*b))) ≤ + stageTestMass e f c.height (r (c.scale*Real.exp (-fexp*b))) (r (c.scale*Real.exp (g*b))) + c.layerProfile (episodeStageH χ b c.scale) j ω + +lemma measurableSet_growsAt (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (j : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) ((c.height+j:ℕ):ℝ))] + {ω | c.growsAt fexp g χ b j ω} := by + have hm := (MeasurableSet.const (j=episodeStageH χ b c.scale)).inter + (measurableSet_le (f:=fun _ : Environment d => ENNReal.ofReal (Real.exp (-((k:ℝ)*b)))) measurable_const + (stageTestMass_adapted e f c.height (r (c.scale*Real.exp (-fexp*b))) + (r (c.scale*Real.exp (g*b))) c.layerProfile c.measurable_layerProfile + (episodeStageH χ b c.scale) j)) + convert hm using 1 <;> first | rfl | (rw [Nat.cast_add]; rfl) + +lemma stop_eq (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (N : ℕ) (ω : Environment d) : + c.stop fexp g χ b N ω=episodeStageLength e f r fexp g χ b N (c.state ω) ω := rfl + +lemma growsAt_eq (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (N : ℕ) (ω : Environment d) : + c.growsAt fexp g χ b (c.stop fexp g χ b N ω) ω ↔ + episodeStageGrows e f r fexp g χ b N (c.state ω) ω := by + simp only [growsAt,episodeStageGrows,neg_mul] + rfl + +noncomputable def nextScale (c : EpisodeChart (k:=k) e f r) (fexp g b : ℝ) (grow : Bool) : ℝ := + if grow then c.scale*Real.exp (g*b) else c.scale*Real.exp (-fexp*b) + +noncomputable def nextProfile (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g b : ℝ) (j : ℕ) (grow : Bool) (ω : Environment d) : + BudgetProfile (k:=k) e f ((c.height+j:ℕ):ℝ) (r (c.nextScale fexp g b grow)) := by + let p := seedSeparatedProfile e f hef c.height (r (c.nextScale fexp g b grow)) j (c.layerProfile ω) ω + refine ⟨p.val,p.property.1,?_⟩ + simpa only [Nat.cast_add] using p.property.2 + +lemma measurable_nextProfile (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g b : ℝ) (j : ℕ) (grow : Bool) : + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) ((c.height+j:ℕ):ℝ))) _ + (c.nextProfile hef fexp g b j grow) := by + apply Measurable.subtype_mk + have hm := measurable_subtype_coe.comp + (seedSeparatedProfile_measurable e f hef c.height (r (c.nextScale fexp g b grow)) j + c.layerProfile c.measurable_layerProfile) + convert hm using 1 <;> first | rfl | rw [Nat.cast_add] + +noncomputable def nextEvent (c : EpisodeChart (k:=k) e f r) + (fexp g χ b sfloor : ℝ) (N j : ℕ) (grow : Bool) : Set (Environment d) := + {ω | ω∈c.event ∧ c.height q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω) _ _ ω).val = _ + rw [episodeStageGap] + rfl + +namespace EpisodeChart +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + +lemma next_state (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N j : ℕ) (grow : Bool) (ω : Environment d) + (hω : ω∈(c.next hef fexp g χ b sfloor N j grow).event) : + (c.next hef fexp g χ b sfloor N j grow).state ω = + episodeStageNext e f hef r fexp g χ b N (c.state ω) ω := by + have hj : c.stop fexp g χ b N ω=j := hω.2.2.2.1 + have hg : episodeStageGrows e f r fexp g χ b N (c.state ω) ω ↔ grow=true := by + rw [←c.growsAt_eq fexp g χ b N ω,hj] + exact hω.2.2.2.2 + have hscale : c.nextScale fexp g b grow=episodeStageScale e f r fexp g χ b N (c.state ω) ω := by + cases grow with + | false => + have hn : ¬episodeStageGrows e f r fexp g χ b N (c.state ω) ω := by + intro hh + exact Bool.false_ne_true (hg.mp hh) + simp only [nextScale,Bool.false_eq_true,ite_false,episodeStageScale,ite_eq_right hn] + rfl + | true => + have hp : episodeStageGrows e f r fexp g χ b N (c.state ω) ω := hg.mpr rfl + simp only [nextScale,ite_true,episodeStageScale,ite_eq_left hp] + rfl + apply EpisodeState.ext_raw + · change c.height+j=c.height+episodeStageLength e f r fexp g χ b N (c.state ω) ω + rw [←c.stop_eq,hj] + · exact hscale + · rw [episodeStageNext_profile,←c.stop_eq,hj] + change (seedSeparatedProfile e f hef c.height (r (c.nextScale fexp g b grow)) j (c.layerProfile ω) ω).val=_ + rw [hscale] + rfl + +noncomputable def frozen (c : EpisodeChart (k:=k) e f r) (sfloor : ℝ) (N : ℕ) : EpisodeChart (k:=k) e f r where + height := c.height + scale := c.scale + profile := c.profile + measurable_profile := c.measurable_profile + event := c.event ∩ {_ω | ¬(c.height c.frozen sfloor N + | some (j,grow) => c.next hef fexp g χ b sfloor N j grow + +lemma branch_covers (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) (ω : Environment d) (hω : ω∈c.event) : + ∃ l, ω∈(c.branch hef fexp g χ b sfloor N l).event := by + by_cases hr : c.height + refine ⟨hω.1,?_⟩ + rw [ite_eq_right (show ¬EpisodeReady e f r sfloor N (c.state ω) from hω.2)] + rfl + | some l => + have hr : EpisodeReady e f r sfloor N (c.state ω) := ⟨hω.2.1,hω.2.2.1⟩ + exact ⟨hω.1,by rw [ite_eq_left hr]; exact c.next_state hef fexp g χ b sfloor N l.1 l.2 ω hω⟩ + +end EpisodeChart + +structure EpisodeAtlas {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + (q : Environment d → EpisodeState (k:=k) e f r) where + Label : Type + countable : Countable Label + chart : Label → EpisodeChart (k:=k) e f r + cover : ∀ ω, ∃ l, ω∈(chart l).event + correct : ∀ l ω, ω∈(chart l).event → q ω=(chart l).state ω + +namespace EpisodeAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} + +noncomputable def advance (A : EpisodeAtlas q) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) : + EpisodeAtlas (fun ω => if EpisodeReady e f r sfloor N (q ω) + then episodeStageNext e f hef r fexp g χ b N (q ω) ω else q ω) := by + let := A.countable + refine ⟨A.Label×Option (ℕ×Bool),inferInstance, + fun l => (A.chart l.1).branch hef fexp g χ b sfloor N l.2,?_,?_⟩ + · intro ω + obtain ⟨l,hl⟩ := A.cover ω + obtain ⟨j,hj⟩ := (A.chart l).branch_covers hef fexp g χ b sfloor N ω hl + exact ⟨(l,j),hj⟩ + · intro l ω hω + obtain ⟨hl,hnext⟩ := (A.chart l.1).branch_state hef fexp g χ b sfloor N ω l.2 hω + rw [A.correct l.1 ω hl] + exact hnext.symm + +noncomputable def run (A : EpisodeAtlas q) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) (n : ℕ) : + EpisodeAtlas (fun ω => episodeRun e f hef r fexp g χ b sfloor N (q ω) ω n) := by + induction n with + | zero => exact A + | succ n ih => exact ih.advance hef fexp g χ b sfloor N + +lemma height_event (A : EpisodeAtlas q) (m : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] {ω | (q ω).height=m} := by + let := A.countable + have he : {ω | (q ω).height=m} = ⋃ l : {l : A.Label // (A.chart l).height=m}, (A.chart l.val).event := by + ext ω + change (q ω).height=m ↔ _ + constructor + · intro hω + obtain ⟨l,hl⟩ := A.cover ω + have hh : (A.chart l).height=m := by rw [A.correct l ω hl] at hω; exact hω + exact Set.mem_iUnion.mpr ⟨⟨l,hh⟩,hl⟩ + · intro hω + obtain ⟨l,hl⟩ := Set.mem_iUnion.mp hω + rw [A.correct l.val ω hl] + exact l.property + rw [he] + apply MeasurableSet.iUnion + intro l + have hm := (A.chart l.val).measurable_event + rwa [l.property] at hm + +lemma profile_event (A : EpisodeAtlas q) (m : ℕ) (U : Set (Measure (Fin k → Lattice d))) + (hU : MeasurableSet U) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] + ({ω | (q ω).profile.val∈U} ∩ {ω | (q ω).height=m}) := by + let := A.countable + have he : {ω | (q ω).profile.val∈U} ∩ {ω | (q ω).height=m} = + ⋃ l : {l : A.Label // (A.chart l).height=m}, + (A.chart l.val).event ∩ {ω | ((A.chart l.val).profile ω).val∈U} := by + ext ω + change ((q ω).profile.val∈U ∧ (q ω).height=m) ↔ _ + constructor + · rintro ⟨hUω,hmω⟩ + obtain ⟨l,hl⟩ := A.cover ω + have hh : (A.chart l).height=m := by rw [A.correct l ω hl] at hmω; exact hmω + exact Set.mem_iUnion.mpr ⟨⟨l,hh⟩,hl,by rw [A.correct l ω hl] at hUω; exact hUω⟩ + · intro hω + obtain ⟨l,hl,hV⟩ := Set.mem_iUnion.mp hω + rw [A.correct l.val ω hl] + exact ⟨hV,l.property⟩ + rw [he] + apply MeasurableSet.iUnion + intro l + have hm := (A.chart l.val).measurable_event.inter + ((measurable_subtype_coe.comp (A.chart l.val).measurable_profile) hU) + have hle : rowSigma (BelowHeight (realPosition (step e)) ((A.chart l.val).height:ℝ)) ≤ + rowSigma (BelowHeight (realPosition (step e)) (m:ℝ)) := by rw [l.property] + exact hle _ hm + +end EpisodeAtlas +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCountLedger.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCountLedger.lean new file mode 100644 index 0000000000000000000000000000000000000000..79e243e46c22e4b12153d593fd492d24483d68a3 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCountLedger.lean @@ -0,0 +1,220 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeInjection +import OAI.Probability.Ballisticity.Stationary.EpisodeLength + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +noncomputable def episodeStageIncomplete {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) : Prop := + ¬episodeStageGrows e f r fexp g χ b N q ω ∧ ¬episodeStageFails e f r fexp g χ b N q ω + +namespace EpisodeLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) +local notation "R" => episodeRun e f hef r fexp g χ b sfloor N q ω +local notation "Grow" => episodeStageGrows e f r fexp g χ b N +local notation "Fail" => episodeStageFails e f r fexp g χ b N +local notation "Inc" => episodeStageIncomplete e f r fexp g χ b N +local notation "Ready" => EpisodeReady e f r sfloor N +local notation "Count" => episodeCount e f hef r fexp g χ b sfloor N q ω +local notation "J" => episodeSteps e f hef r fexp g χ b sfloor N q ω + +lemma counts_partition (n : ℕ) : J n=Count Grow n+Count Fail n+Count Inc n := by + induction n with + | zero => rfl + | succ n ih => + rw [episodeSteps,episodeCount,episodeCount,episodeCount] + by_cases hr : Ready (R n) + · by_cases hg : Grow (R n) ω + · have hf := ((episodeStage_grows_iff e f r fexp g χ b N (R n) ω).mp hg).2 + simp only [episodeStageIncomplete,hr,hg,hf,not_true_eq_false,false_and,and_self, + true_and,ite_true,ite_false,add_zero] + omega + · by_cases hf : Fail (R n) ω + · simp only [episodeStageIncomplete,hr,hg,hf,not_true_eq_false,not_false_eq_true, + true_and,and_false,ite_true,ite_false,add_zero] + omega + · simp only [episodeStageIncomplete,hr,hg,hf,not_false_eq_true,true_and, + and_true,ite_true,ite_false,add_zero] + omega + · simp only [hr,false_and,ite_false,add_zero] + exact ih + +lemma incomplete_count (n : ℕ) : Count Inc n ≤ 1 ∧ ((R n).height < N → Count Inc n=0) := by + induction n with + | zero => exact ⟨by simp only [episodeCount]; omega,fun _ => rfl⟩ + | succ n ih => + rw [episodeCount,episodeRun] + by_cases hr : Ready (R n) + · rw [ite_eq_left hr] + by_cases hi : Inc (R n) ω + · rw [ite_eq_left ⟨hr,hi⟩,ih.2 hr.1] + refine ⟨by omega,?_⟩ + have ht := episodeStage_incomplete_terminal e f hef r fexp g χ b N (R n) ω hr.1.le hi.2 hi.1 + intro hn + omega + · rw [ite_eq_right (fun hh => hi hh.2),add_zero] + exact ⟨ih.1,fun _ => ih.2 hr.1⟩ + · rw [ite_eq_right hr,ite_eq_right (fun hh => hr hh.1),add_zero] + exact ih + +lemma counts_le (n : ℕ) : + J n ≤ Count Grow n+Count Fail n+1 ∧ + ((R n).height < N → J n=Count Grow n+Count Fail n) := by + have hp := counts_partition e f hef r fexp g χ b sfloor N q ω n + have hi := incomplete_count e f hef r fexp g χ b sfloor N q ω n + constructor + · omega + · intro hn + have hz := hi.2 hn + omega + +lemma nonterminal_ledger (hq : 0 < q.scale) (hqN : q.height ≤ N) + (hqfloor : q.scale=sfloor) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hn : (R N).height < N) : + g*b*(Count Grow N : ℝ) ≤ fexp*b*(Count Fail N : ℝ) := by + have ht := episodeRun_terminates e f hef r fexp g χ b sfloor N q ω hqN hH + have hs : (R N).scale < sfloor := lt_of_not_ge (fun hh => ht ⟨hn,hh⟩) + have ha := scale_agrees e f hef r fexp g χ b sfloor N q ω N hn + have hl := log_scale e f hef r fexp g χ b sfloor N q ω hq N + have hp := scale_pos e f hef r fexp g χ b sfloor N q ω hq N + have hlog : Real.log (scale e f hef r fexp g χ b sfloor N q ω N) ≤ Real.log q.scale := + Real.log_le_log hp (by rw [ha,hqfloor]; exact hs.le) + linarith only [hl,hlog] + +lemma terminal_ledger (hq : 0 < q.scale) (hqfloor : q.scale=sfloor) + (hqN : q.height ≤ N) (hN : sfloor ≤ (N:ℝ)) (hf : 0 ≤ fexp) (hb : 0 ≤ b) + (hH : ∀ s, sfloor ≤ s → s*Real.exp (g*b) ≤ (episodeStageH χ b s : ℝ)) : + g*b*(Count Grow N : ℝ)-fexp*b*(Count Fail N : ℝ) ≤ Real.log (N:ℝ)-Real.log sfloor := by + have ha := scale_le e f hef r fexp g χ b sfloor N q ω hq + (by rw [hqfloor]; exact le_max_left _ _) hqN hf hb hH N + rw [max_eq_right hN] at ha + have hlog := Real.log_le_log (scale_pos e f hef r fexp g χ b sfloor N q ω hq N) ha + have hl := log_scale e f hef r fexp g χ b sfloor N q ω hq N + rw [hqfloor] at hl + linarith only [hl,hlog] + +end EpisodeLedger +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (ω : Environment d) + +local notation "T" => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω +local notation "Q" => episodeInitial (k:=k) e f hef r sfloor hR +local notation "Run" => episodeRun e f hef r fexp g χ b sfloor N +local notation "Grow" => episodeStageGrows (k:=k) e f r fexp g χ b N +local notation "Fail" => episodeStageFails (k:=k) e f r fexp g χ b N +local notation "Inc" => episodeStageIncomplete (k:=k) e f r fexp g χ b N +local notation "LocalCount" => episodeCount e f hef r fexp g χ b sfloor N + +noncomputable def count (test : EpisodeState (k:=k) e f r → Environment d → Prop) : ℕ → ℕ + | 0 => 0 + | i+1 => count test i + if T i < N then LocalCount (Q (T i) ω) ω test N else 0 + +noncomputable def steps : ℕ → ℕ + | 0 => 0 + | i+1 => steps i + if T i < N then episodeSteps e f hef r fexp g χ b sfloor N (Q (T i) ω) ω N else 0 + +local notation "C" => count e f hef r fexp g χ b sfloor hR N ω +local notation "J" => steps (k:=k) e f hef r fexp g χ b sfloor hR N ω + +lemma partition (i : ℕ) : J i=C Grow i+C Fail i+C Inc i := by + induction i with + | zero => rfl + | succ i ih => + rw [steps,count,count,count] + by_cases ht : T i < N + · simp only [ite_eq_left ht] + have hp := EpisodeLedger.counts_partition (k:=k) e f hef r fexp g χ b sfloor N (Q (T i) ω) ω N + omega + · simpa only [ite_eq_right ht,add_zero] using ih + +lemma incomplete (i : ℕ) : C Inc i ≤ 1 ∧ (T i < N → C Inc i=0) := by + induction i with + | zero => exact ⟨by simp only [count]; omega,fun _ => rfl⟩ + | succ i ih => + rw [count,episodeBoundary] + by_cases ht : T i < N + · simp only [ite_eq_left ht] + have hz := ih.2 ht + rw [hz,zero_add] + exact EpisodeLedger.incomplete_count e f hef r fexp g χ b sfloor N (Q (T i) ω) ω N + · simpa only [ite_eq_right ht,add_zero] using ih + +lemma counts_le (i : ℕ) : J i ≤ C Grow i+C Fail i+1 := by + have hp := partition (k:=k) e f hef r fexp g χ b sfloor hR N ω i + have hi := (incomplete (k:=k) e f hef r fexp g χ b sfloor hR N ω i).1 + omega + +lemma balance (hs : 0 < sfloor) (hN : sfloor ≤ (N:ℝ)) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) + (hH : ∀ s, sfloor ≤ s → s*Real.exp (g*b) ≤ (episodeStageH χ b s : ℝ)) (i : ℕ) : + g*b*(C Grow i : ℝ)-fexp*b*(C Fail i : ℝ) ≤ Real.log (N:ℝ)-Real.log sfloor ∧ + (T i < N → g*b*(C Grow i : ℝ)-fexp*b*(C Fail i : ℝ) ≤ 0) := by + have hH0 : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s := by + intro s h + exact_mod_cast (mul_pos (hs.trans_le h) (Real.exp_pos (g*b))).trans_le (hH s h) + have hL : 0 ≤ Real.log (N:ℝ)-Real.log sfloor := sub_nonneg.mpr (Real.log_le_log hs hN) + induction i with + | zero => simpa only [count,Nat.cast_zero,mul_zero,sub_self] using ⟨hL,fun _ => le_refl 0⟩ + | succ i ih => + rw [count,count,episodeBoundary] + by_cases ht : T i < N + · simp only [ite_eq_left ht,Nat.cast_add] + have hqN : (Q (T i) ω).height ≤ N := Nat.succ_le_of_lt ht + have hqpos : 0 < (Q (T i) ω).scale := hs + have hqeq : (Q (T i) ω).scale=sfloor := rfl + have hp := ih.2 ht + have hu := EpisodeLedger.terminal_ledger e f hef r fexp g χ b sfloor N + (Q (T i) ω) ω hqpos hqeq hqN hN hf hb hH + constructor + · nlinarith only [hp,hu] + · intro hn + have hh := EpisodeLedger.nonterminal_ledger e f hef r fexp g χ b sfloor N + (Q (T i) ω) ω hqpos hqN hqeq hH0 hn + nlinarith only [hp,hh] + · simpa only [ite_eq_right ht,add_zero] using ih + +theorem stage_count_bound (hs : 1 ≤ sfloor) (hN : sfloor ≤ (N:ℝ)) + (hf : 0 ≤ fexp) (hg : 0 < g) (hb : 0 < b) + (hH : ∀ s, sfloor ≤ s → s*Real.exp (g*b) ≤ (episodeStageH χ b s : ℝ)) : + (J N : ℝ) ≤ Real.log (N:ℝ)/(g*b)+(1+fexp/g)*(C Fail N : ℝ)+1 := by + have hbal := (balance (k:=k) e f hef r fexp g χ b sfloor hR N ω + (lt_of_lt_of_le (by norm_num : (0:ℝ)<1) hs) hN hf hb.le hH N).1 + have hlog : 0 ≤ Real.log sfloor := Real.log_nonneg hs + have hcnt : (J N : ℝ) ≤ (C Grow N : ℝ)+(C Fail N : ℝ)+1 := by + exact_mod_cast counts_le (k:=k) e f hef r fexp g χ b sfloor hR N ω N + have hgb : 0 < g*b := mul_pos hg hb + apply (mul_le_mul_iff_right₀ hgb).mp + have he : (g*b)*(Real.log (N:ℝ)/(g*b)+(1+fexp/g)*(C Fail N : ℝ)+1) = + Real.log (N:ℝ)+(g*b)*(C Fail N : ℝ)+(fexp*b)*(C Fail N : ℝ)+g*b := by + field_simp + ring + rw [he] + have hh := mul_le_mul_of_nonneg_right hcnt hgb.le + nlinarith only [hh,hbal,hlog] + +end EpisodeChainLedger +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCounterChain.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCounterChain.lean new file mode 100644 index 0000000000000000000000000000000000000000..650861762a2e5a68f3a54e1841e4742a2fff9ee7 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeCounterChain.lean @@ -0,0 +1,183 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.EntropyVariational +import OAI.Probability.Ballisticity.Stationary.EpisodeRecordedAtlas +import OAI.Probability.Ballisticity.Stationary.EpisodeCountLedger + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +structure EpisodeCounter {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) where + state : EpisodeState (k:=k) e f r + stages : ℕ + failures : ℕ + +noncomputable def episodeCounterChain {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (ω : Environment d) : ℕ → EpisodeCounter (k:=k) e f r + | 0 => ⟨episodeInitial e f hef r sfloor hR 0 ω,0,0⟩ + | i+1 => let p := episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i + let q := episodeRun e f hef r fexp g χ b sfloor N p.state ω N + ⟨episodeInitial e f hef r sfloor hR q.height ω, + p.stages+episodeSteps e f hef r fexp g χ b sfloor N p.state ω N, + p.failures+episodeCount e f hef r fexp g χ b sfloor N p.state ω + (episodeStageFails e f r fexp g χ b N) N⟩ + +noncomputable def episodeCounterAtlas {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N i : ℕ) : + EpisodeRecordedAtlas (fun ω => (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).state) + (fun ω => (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).stages) + (fun ω => (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).failures) := by + induction i with + | zero => exact EpisodeRecordedAtlas.zero (episodeInitialAtlas e f hef r sfloor hR 0) + | succ i ih => exact (ih.runFrom hef fexp g χ b sfloor N N).reinject hef sfloor hR + +lemma episodeCounterAtlas_partition {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N i : ℕ) : + (episodeCounterAtlas (k:=k) e f hef r fexp g χ b sfloor hR N i).toEpisodeAtlas.IsPartition := by + induction i with + | zero => exact episodeInitialAtlas_partition e f hef r sfloor hR 0 + | succ i ih => exact EpisodeRecordedAtlas.runFrom_partition _ ih hef fexp g χ b sfloor N N + +lemma episodeRun_stopped {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) (hq : N ≤ q.height) (n : ℕ) : + episodeRun e f hef r fexp g χ b sfloor N q ω n=q ∧ + episodeSteps e f hef r fexp g χ b sfloor N q ω n=0 ∧ + episodeCount e f hef r fexp g χ b sfloor N q ω (episodeStageFails e f r fexp g χ b N) n=0 := by + have hnr : ¬EpisodeReady e f r sfloor N q := fun h => (Nat.not_lt_of_ge hq) h.1 + induction n with + | zero => exact ⟨rfl,rfl,rfl⟩ + | succ n ih => + simp only [episodeRun,episodeSteps,episodeCount,ih.1,ih.2.1,ih.2.2,hnr,ite_false,false_and,add_zero,and_self] + +lemma episodeCounterChain_actual {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (ω : Environment d) (i : ℕ) : + let T := episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i + let p := episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i + (T exact ⟨fun _ => rfl,fun h => h.trans (Nat.zero_le _),rfl,rfl⟩ + | succ i ih => + let T := episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i + let p := episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i + by_cases ht : T dsimp only [T] at ht + · have he := ih.1 ht + simp only [episodeBoundary,episodeCounterChain,EpisodeChainLedger.steps,EpisodeChainLedger.count,he,ite_eq_left ht] + refine ⟨fun _ => rfl,?_,?_,?_⟩ + · intro hh + exact hh.trans (Nat.le_add_right _ 1) + · rw [ih.2.2.1] + · rw [ih.2.2.2] + · have hp := ih.2.1 (Nat.le_of_not_lt ht) + have hz := episodeRun_stopped e f hef r fexp g χ b sfloor N p.state ω hp N + dsimp only [p] at hz + simp only [episodeBoundary,episodeCounterChain,EpisodeChainLedger.steps,EpisodeChainLedger.count,ite_eq_right ht, + hz.1,hz.2.1,hz.2.2,add_zero] + refine ⟨fun h => False.elim (ht h),?_,ih.2.2.1,ih.2.2.2⟩ + intro _ + exact hp.trans (Nat.le_add_right _ 1) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeRecordedAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} {J F : Environment d → ℕ} + +lemma measurable_counts (A : EpisodeRecordedAtlas q J F) : Measurable (fun ω => (J ω,F ω)) := by + apply measurable_to_countable' + intro z + have he : (fun ω => (J ω,F ω)) ⁻¹' {z} = + ⋃ m : ℕ, {ω | (q ω).height=m ∧ J ω=z.1 ∧ F ω=z.2} := by + ext ω + constructor + · intro h + have hh : J ω=z.1 ∧ F ω=z.2 := Prod.mk.inj h + exact Set.mem_iUnion.mpr ⟨(q ω).height,rfl,hh⟩ + · intro h + obtain ⟨m,hm,hj,hf⟩ := Set.mem_iUnion.mp h + exact Prod.ext hj hf + rw [he] + exact MeasurableSet.iUnion fun m => (rowSigma_le _) _ (A.count_event m z.1 z.2) + +end EpisodeRecordedAtlas + +lemma episode_counts_le_loops {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) + (ω : Environment d) (test : EpisodeState (k:=k) e f r → Environment d → Prop) (n : ℕ) : + episodeSteps e f hef r fexp g χ b sfloor N q ω n ≤ n ∧ + episodeCount e f hef r fexp g χ b sfloor N q ω test n ≤ n := by + induction n with + | zero => exact ⟨le_refl _,le_refl _⟩ + | succ n ih => + rw [episodeSteps,episodeCount] + constructor <;> split <;> omega + +namespace EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "Fail" => episodeStageFails (k:=k) e f r fexp g χ b N +local notation "J" => fun ω i => steps (k:=k) e f hef r fexp g χ b sfloor hR N ω i +local notation "C" => fun ω i => count (k:=k) e f hef r fexp g χ b sfloor hR N ω Fail i + +lemma measurable_counts (i : ℕ) : Measurable (fun ω => (J ω i,C ω i)) := by + have he : (fun ω => ((episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).stages, + (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).failures)) = + (fun ω => (J ω i,C ω i)) := by + funext ω + have hh := episodeCounterChain_actual (k:=k) e f hef r fexp g χ b sfloor hR N ω i + exact Prod.ext hh.2.2.1 hh.2.2.2 + rw [←he] + exact (episodeCounterAtlas (k:=k) e f hef r fexp g χ b sfloor hR N i).measurable_counts + +lemma counts_bounded (ω : Environment d) (i : ℕ) : J ω i ≤ i*N ∧ C ω i ≤ i*N := by + induction i with + | zero => simp only [steps,count,Nat.zero_mul,le_refl,and_self] + | succ i ih => + have hh := episode_counts_le_loops e f hef r fexp g χ b sfloor N + (episodeInitial (k:=k) e f hef r sfloor hR + (episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i) ω) ω Fail N + dsimp only at ih ⊢ + rw [steps,count,Nat.succ_mul] + constructor <;> split <;> omega + +lemma counts_integrable (Q : Measure (Environment d)) [IsFiniteMeasure Q] (i : ℕ) : + Integrable (fun ω => (J ω i:ℝ)) Q ∧ Integrable (fun ω => (C ω i:ℝ)) Q := by + have hm := measurable_counts (k:=k) e f hef r fexp g χ b sfloor hR N i + have hcast : Measurable (fun n : ℕ => (n:ℝ)) := measurable_of_countable _ + constructor + · apply Entropy.integrable_of_bounded (hcast.comp hm.fst) + refine ⟨(i*N:ℕ),fun ω => ?_⟩ + rw [abs_of_nonneg (Nat.cast_nonneg _)] + dsimp only [Function.comp_def] + exact_mod_cast (counts_bounded (k:=k) e f hef r fexp g χ b sfloor hR N ω i).1 + · apply Entropy.integrable_of_bounded (hcast.comp hm.snd) + refine ⟨(i*N:ℕ),fun ω => ?_⟩ + rw [abs_of_nonneg (Nat.cast_nonneg _)] + dsimp only [Function.comp_def] + exact_mod_cast (counts_bounded (k:=k) e f hef r fexp g χ b sfloor hR N ω i).2 + +end EpisodeChainLedger +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeDropLedger.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeDropLedger.lean new file mode 100644 index 0000000000000000000000000000000000000000..013d327a33feef8aaa4f3c12b0b2052d73568309 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeDropLedger.lean @@ -0,0 +1,182 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeGlobalRetention +import OAI.Probability.Ballisticity.Stationary.EpisodeCounterChain +import OAI.Probability.Ballisticity.Stationary.EpisodeNumber + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience.EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "T" => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "J" => steps (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "M" => number (k:=k) e f hef r fexp g χ b sfloor hR N + +noncomputable def stepMark (ω : Environment d) (i : ℕ) : ℕ := + if T ω i stepMark (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "c" => dropMark (k:=k) e f hef r fexp g χ b sfloor hR N + +lemma stepMark_sub (ω : Environment d) (i : ℕ) : j ω i=J ω (i+1)-J ω i := by + rw [steps,Nat.add_sub_cancel_left] + rfl + +lemma stepMark_measurable (i : ℕ) : Measurable (fun ω => j ω i) := by + have hi := (measurable_counts (k:=k) e f hef r fexp g χ b sfloor hR N i).fst + have hj := (measurable_counts (k:=k) e f hef r fexp g χ b sfloor hR N (i+1)).fst + have h : Measurable (fun ω => J ω (i+1)-J ω i) := hj.sub hi + convert h using 1 + exact funext (fun ω => stepMark_sub (k:=k) e f hef r fexp g χ b sfloor hR N ω i) + +lemma dropMark_measurable (i : ℕ) : Measurable (fun ω => c ω i) := by + have hm : Measurable (fun p : Environment d×ℕ => crossingQuenched (realPosition (step e)) 0 p.2 p.1) := by + apply measurable_from_prod_countable_left + intro n + simpa only [Prod.fst,Prod.snd] using (measurable_crossingQuenched (realPosition (step e)) 0 (n:ℝ)) + exact (((hm.comp (measurable_id.prodMk (episodeBoundary_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i))).ennreal_toReal.log).sub + ((hm.comp (measurable_id.prodMk (episodeBoundary_measurable (k:=k) e f hef r fexp g χ b sfloor hR N (i+1)))).ennreal_toReal.log)) + +lemma stepMark_sum (ω : Environment d) (n : ℕ) : ∑ i ∈ Finset.range n, j ω i=J ω n := by + induction n with + | zero => simp only [Finset.range_zero,Finset.sum_empty,steps] + | succ n ih => rw [Finset.sum_range_succ,ih,steps]; rfl + +lemma dropMark_sum (ω : Environment d) (n : ℕ) : + ∑ i ∈ Finset.range n, c ω i = -Real.log (crossingQuenched (realPosition (step e)) 0 (T ω n) ω).toReal := by + induction n with + | zero => simp only [Finset.range_zero,Finset.sum_empty,episodeBoundary,Nat.cast_zero, + crossingQuenched_zero,ENNReal.toReal_one,Real.log_one,neg_zero] + | succ n ih => rw [Finset.sum_range_succ,ih,dropMark]; ring + +lemma dropMark_total (ω : Environment d) : + ∑ i ∈ Finset.range N, c ω i = -Real.log (crossingQuenched (realPosition (step e)) 0 N ω).toReal := by + rw [dropMark_sum,episodeBoundary_complete] + +lemma dropMark_bounds (hr : Monotone r) (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hs : 0 < sfloor) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hk : 0 < k) (hbκ : -Real.log κ ≤ b) + (ω : Environment d) (hκ : ∀ y u, κ ≤ (ω y).1 u) (i : ℕ) : + 0 ≤ c ω i ∧ c ω i ≤ + ((BoundedInjection.injectionMultiplier (r sfloor)*k+1:ℕ)*(-Real.log κ))* + (if T ω i + (dropMark_bounds (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb hs hH κ hκ0 hκ1 hk hbκ ω hκ i).2) + rw [Finset.sum_add_distrib,←Finset.mul_sum,←Finset.mul_sum] at hh + have hm : (∑ i ∈ Finset.range N, if T ω i episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "J" => steps (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "M" => number (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "j" => stepMark (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "c" => dropMark (k:=k) e f hef r fexp g χ b sfloor hR N + +lemma stepMark_le (ω : Environment d) (i : ℕ) : j ω i ≤ N := by + unfold stepMark + split + · exact (episode_counts_le_loops e f hef r fexp g χ b sfloor N _ ω + (episodeStageFails e f r fexp g χ b N) N).1 + · exact Nat.zero_le _ + +lemma dropMark_inactive (ω : Environment d) (i : ℕ) (hi : M ω N ≤ i) : c ω i=0 := by + have ha : ¬T ω i simp_all only [mul_one,mul_zero,le_refl] + change c ω i ≤ A*(if T ω i hpoint i) + rw [←Finset.mul_sum] at h + have hj : (∑ i ∈ Finset.range N, (j ω i:ℝ))=(J ω N:ℝ) := by + exact_mod_cast stepMark_sum (k:=k) e f hef r fexp g χ b sfloor hR N ω N + rw [hj] at h + exact h + +lemma dropMark_integrable (hr : Monotone r) (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hs : 0 < sfloor) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hk : 0 < k) (hbκ : -Real.log κ ≤ b) + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (hκ : ∀ᵐ ω ∂Q, ∀ y u, κ ≤ (ω y).1 u) (i : ℕ) : Integrable (fun ω => c ω i) Q := by + let A : ℝ := ((BoundedInjection.injectionMultiplier (r sfloor)*k+1:ℕ)*(-Real.log κ)) + apply Integrable.of_bound (dropMark_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i).aestronglyMeasurable (A+2*b*N) + filter_upwards [hκ] with ω hω + have hc := dropMark_bounds (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb hs hH κ hκ0 hκ1 hk hbκ ω hω i + rw [Real.norm_eq_abs,abs_of_nonneg hc.1] + have hA : 0 ≤ A := injection_cost_nonneg (k:=k) r sfloor κ hκ0 hκ1 + have hj : (j ω i:ℝ) ≤ N := by exact_mod_cast stepMark_le (k:=k) e f hef r fexp g χ b sfloor hR N ω i + have hai : A*(if T ω i simp_all only [mul_one,mul_zero,le_refl] + have hc' : c ω i ≤ A*(if T ω i (1:ℝ≥0∞)) ω ∂P ≤ P (E∩D) := by + have h := lintegral_indicator_const_le (μ:=P.restrict E) D (1:ℝ≥0∞) + simpa only [one_mul,Measure.restrict_apply' hE,Set.inter_comm] using h + calc + _ ≤ ∫⁻ ω in E, w*a*(1+c*D.indicator (fun _ => (1:ℝ≥0∞)) ω) ∂P := by + apply lintegral_mono + intro ω + simpa only [Set.indicator_apply,Pi.one_apply] using stagePotential_succ_le t j f (ω∈D) + _ = w*a*(P E+c*(∫⁻ ω in E, D.indicator (fun _ => (1:ℝ≥0∞)) ω ∂P)) := by + rw [lintegral_const_mul' (w*a) _ (ENNReal.mul_ne_top (by simp [w,stagePotential]) (by simp [a])), + lintegral_add_left measurable_const,lintegral_const_mul' c _ (by simp [c])] + simp only [lintegral_const,Measure.restrict_apply_univ,one_mul] + _ ≤ w*a*(P E+c*(ENNReal.ofReal (Real.exp (-2*t))*P E)) := + by gcongr; exact hd.trans hD + _ = w*(a*(1+c*ENNReal.ofReal (Real.exp (-2*t))))*P E := by ring + _ ≤ w*1*P E := by gcongr; exact stage_exponential_factor t + _ = _ := by rw [mul_one] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeRecordedAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} {J F : Environment d → ℕ} + +lemma integral_partition (A : EpisodeRecordedAtlas q J F) (hA : A.toEpisodeAtlas.IsPartition) + (P : Measure (Environment d)) (W : Environment d → ℝ≥0∞) : + ∫⁻ ω, W ω ∂P = ∑' l : A.Label, ∫⁻ ω in (A.chart l).event, W ω ∂P := by + let := A.countable + have hu : (⋃ l : A.Label, (A.chart l).event)=Set.univ := + Set.eq_univ_of_forall (fun ω => Set.mem_iUnion.mpr (A.cover ω)) + have hd : Pairwise (fun l m : A.Label => Disjoint (A.chart l).event (A.chart m).event) := by + intro l m hne + exact Set.disjoint_left.mpr (fun ω hl hm => hne (hA l m ω hl hm)) + simpa only [hu,Measure.restrict_univ] using + lintegral_iUnion (μ:=P) (fun l => (rowSigma_le _) _ (A.chart l).measurable_event) hd W + +lemma potential_advance (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (A : EpisodeRecordedAtlas q J F) (hA : A.toEpisodeAtlas.IsPartition) + (fexp g χ b sfloor K : ℝ) (N : ℕ) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hbound : ∀ s, sfloor ≤ s → ∀ a : ℝ, ∀ π : BudgetProfile (k:=k) e f a (r s), + environmentLaw ν (stageBadEvent e f (episodeStageH χ b s) + (r (s*Real.exp (-fexp*b))) (r (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) ≤ ENNReal.ofReal (Real.exp (-2*(K*b)))) : + ∫⁻ ω, stagePotential (K*b) + (J ω+if EpisodeReady e f r sfloor N (q ω) then 1 else 0) + (F ω+if EpisodeReady e f r sfloor N (q ω) ∧ episodeStageFails e f r fexp g χ b N (q ω) ω then 1 else 0) + ∂environmentLaw ν ≤ + ∫⁻ ω, stagePotential (K*b) (J ω) (F ω) ∂environmentLaw ν := by + rw [A.integral_partition hA,A.integral_partition hA] + apply ENNReal.tsum_le_tsum + intro l + let c := A.chart l + have hc : MeasurableSet c.event := (rowSigma_le _) _ c.measurable_event + have hold : (∫⁻ ω in c.event, stagePotential (K*b) (J ω) (F ω) ∂environmentLaw ν) = + stagePotential (K*b) (A.stages l) (A.failures l)*environmentLaw ν c.event := by + rw [setLIntegral_congr_fun hc (fun ω hω => by rw [A.stages_correct l ω hω,A.failures_correct l ω hω])] + simp only [lintegral_const,Measure.restrict_apply_univ] + rw [hold] + by_cases hr : c.height hbound (c.profile η)) A hA + apply le_trans (measure_mono ?_) hb + intro ω hω + refine ⟨hω.1,?_⟩ + have hs := stopped_stage_failure_subset e f c.height + (r (c.scale*Real.exp (-fexp*b))) (r (c.scale*Real.exp (g*b))) ((k:ℝ)*b) + c.layerProfile (episodeStageH χ b c.scale) (N-c.height) hH (by omega) + apply hs + exact hω.2 + +end EpisodeChart +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} + +lemma past_inter_chart (A : EpisodeAtlas q) (B : Set (Environment d)) + (hB : ∀ m : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] + (B ∩ {ω | (q ω).height=m})) (l : A.Label) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) (A.chart l).height)] + (B ∩ (A.chart l).event) := by + have he : B ∩ (A.chart l).event = + (B ∩ {ω | (q ω).height=(A.chart l).height}) ∩ (A.chart l).event := by + ext ω + constructor + · rintro ⟨hω,hl⟩ + refine ⟨⟨hω,?_⟩,hl⟩ + change (q ω).height=(A.chart l).height + rw [A.correct l ω hl] + rfl + · rintro ⟨⟨hω,_⟩,hl⟩ + exact ⟨hω,hl⟩ + rw [he] + exact (hB _).inter (A.chart l).measurable_event + +lemma actual_failure_bound (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (A : EpisodeAtlas q) (hpart : A.IsPartition) (fexp g χ b sfloor : ℝ) (N : ℕ) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) (δ : ℝ≥0∞) + (hbound : ∀ s, sfloor ≤ s → ∀ a : ℝ, ∀ π : BudgetProfile (k:=k) e f a (r s), + environmentLaw ν (stageBadEvent e f (episodeStageH χ b s) + (r (s*Real.exp (-fexp*b))) (r (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) ≤ δ) + (B : Set (Environment d)) + (hB : ∀ m : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] + (B ∩ {ω | (q ω).height=m})) : + environmentLaw ν (B ∩ {ω | EpisodeReady e f r sfloor N (q ω) ∧ + episodeStageFails e f r fexp g χ b N (q ω) ω}) ≤ + δ*environmentLaw ν (B ∩ {ω | EpisodeReady e f r sfloor N (q ω)}) := by + let := A.countable + let L := {l : A.Label // (A.chart l).height < N ∧ sfloor ≤ (A.chart l).scale} + let D : L → Set (Environment d) := fun l => B ∩ (A.chart l.val).event + let E : L → Set (Environment d) := fun l => D l ∩ + {ω | episodeStageFails e f r fexp g χ b N ((A.chart l.val).state ω) ω} + have hD (l : L) : MeasurableSet (D l) := + (rowSigma_le _) _ (A.past_inter_chart B hB l.val) + have hDj : Pairwise (fun l m : L => Disjoint (D l) (D m)) := by + intro l m hne + apply Set.disjoint_left.mpr + intro ω hl hm + exact hne (Subtype.ext (hpart l.val m.val ω hl.2 hm.2)) + have hUB : (⋃ l : L, D l) = B ∩ {ω | EpisodeReady e f r sfloor N (q ω)} := by + ext ω + constructor + · intro hh + obtain ⟨l,hl⟩ := Set.mem_iUnion.mp hh + refine ⟨hl.1,?_⟩ + change EpisodeReady e f r sfloor N (q ω) + rw [A.correct l.val ω hl.2] + exact l.property + · rintro ⟨hω,hr⟩ + obtain ⟨l,hl⟩ := A.cover ω + have hlr : (A.chart l).height < N ∧ sfloor ≤ (A.chart l).scale := by + change EpisodeReady e f r sfloor N ((A.chart l).state ω) + rw [←A.correct l ω hl] + exact hr + exact Set.mem_iUnion.mpr ⟨⟨l,hlr⟩,hω,hl⟩ + have hUE : (⋃ l : L, E l) = B ∩ {ω | EpisodeReady e f r sfloor N (q ω) ∧ + episodeStageFails e f r fexp g χ b N (q ω) ω} := by + ext ω + constructor + · intro hh + obtain ⟨l,hl,hf⟩ := Set.mem_iUnion.mp hh + refine ⟨hl.1,?_⟩ + change EpisodeReady e f r sfloor N (q ω) ∧ episodeStageFails e f r fexp g χ b N (q ω) ω + rw [A.correct l.val ω hl.2] + exact ⟨l.property,hf⟩ + · rintro ⟨hω,hr,hf⟩ + have hmem : ω∈⋃ l : L, D l := by rw [hUB]; exact ⟨hω,hr⟩ + obtain ⟨l,hl⟩ := Set.mem_iUnion.mp hmem + refine Set.mem_iUnion.mpr ⟨l,hl,?_⟩ + change episodeStageFails e f r fexp g χ b N ((A.chart l.val).state ω) ω + rw [←A.correct l.val ω hl.2] + exact hf + calc + _ = environmentLaw ν (⋃ l : L, E l) := congrArg _ hUE.symm + _ ≤ ∑' l : L, environmentLaw ν (E l) := measure_iUnion_le _ + _ ≤ ∑' l : L, δ*environmentLaw ν (D l) := ENNReal.tsum_le_tsum (fun l => + (A.chart l.val).actual_failure_bound ν fexp g χ b N l.property.1 + (hH _ l.property.2) δ (hbound _ l.property.2 _) (D l) (A.past_inter_chart B hB l.val)) + _ = δ*(∑' l : L, environmentLaw ν (D l)) := ENNReal.tsum_mul_left + _ = δ*environmentLaw ν (⋃ l : L, D l) := congrArg (δ* ·) (measure_iUnion hDj hD).symm + _ = _ := congrArg (fun Z => δ*environmentLaw ν Z) hUB + +end EpisodeAtlas +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeGlobalRetention.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeGlobalRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..70f805edd00261629284df43b74aca5d56117131 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeGlobalRetention.lean @@ -0,0 +1,201 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeInjection + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience + +noncomputable def episodeStageCount {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (ω : Environment d) : ℕ := + episodeSteps e f hef r fexp g χ b sfloor N (episodeInitial (k:=k) e f hef r sfloor hR t ω) ω N + +theorem episodeFinal_global_retained {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (hr : Monotone r) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (ω : Environment d) (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + ((crossingQuenched (realPosition (step e)) 0 t ω)^k * + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) * + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω)) • + episodeMeasure (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω) ≤ + rawTupleEndpointLaw (realPosition (step e)) + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω (fun _ : Fin k => 0) := by + let q := episodeInitial (k:=k) e f hef r sfloor hR t ω + let p := episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω + let c := (crossingQuenched (realPosition (step e)) 0 t ω)^k * + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) + have hi : c • episodeMeasure q ≤ rawTupleEndpointLaw (realPosition (step e)) (t+1) ω (fun _ : Fin k => 0) := by + rw [mul_smul] + exact episodeInitial_retained e f hef r sfloor hR t ω κ hκ1 hκ + have hs := episodeRun_retained e f hef r hr fexp g χ b sfloor N hf hb hsfloor q ω hH κ (fun y => hκ y e) N + have hs := smul_le_smul_left c hs + rw [←rawTupleMixture_smul] at hs + have hm := rawTupleMixture_mono (realPosition (step e)) (p.height-q.height) ω hi + have hc := rawTupleEndpointLaw_comp_le e (t+1) (p.height-q.height) ω (fun _ : Fin k => 0) + have ht : t+1 ≤ p.height := episodeRun_height_mono e f hef r fexp g χ b sfloor N q ω N + have hh : (t+1)+(p.height-q.height)=p.height := by change (t+1)+(p.height-(t+1))=p.height; omega + rw [hh] at hc + simpa only [c,p,q,episodeStageCount,episodeFinal,episodeMeasure,mul_smul] using hs.trans (hm.trans hc) + +lemma rawTupleEndpointLaw_origin_mass {d k : ℕ} (e : Direction d) (H : ℕ) (ω : Environment d) : + rawTupleEndpointLaw (realPosition (step e)) H ω (fun _ : Fin k => 0) Set.univ = + (crossingQuenched (realPosition (step e)) 0 H ω)^k := by + have hh := congrArg (fun μ : Measure (Fin k → Lattice d) => μ Set.univ) + (globalTupleProfile_mass (k:=k) e H ω) + simpa only [Measure.smul_apply,smul_eq_mul,measure_univ,mul_one] using hh.symm + +lemma episode_survival_lower {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (hr : Monotone r) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (ω : Environment d) (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + (crossingQuenched (realPosition (step e)) 0 t ω)^k * + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) * + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω) ≤ + (crossingQuenched (realPosition (step e)) 0 + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω)^k := by + have hh := episodeFinal_global_retained (k:=k) e f hef r hr fexp g χ b sfloor hR N t hf hb hsfloor ω hH κ hκ1 hκ Set.univ + simpa only [Measure.smul_apply,smul_eq_mul,episodeMeasure,measure_univ,mul_one, + rawTupleEndpointLaw_origin_mass] using hh + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience +theorem episodeFinal_global_retained_local {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hr : StageRadiusOrder r fexp b sfloor) (hR : 0 ≤ r sfloor) (N t : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (ω : Environment d) (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + ((crossingQuenched (realPosition (step e)) 0 t ω)^k * + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) * + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω)) • + episodeMeasure (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω) ≤ + rawTupleEndpointLaw (realPosition (step e)) + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω (fun _ : Fin k => 0) := by + let q := episodeInitial (k:=k) e f hef r sfloor hR t ω + let p := episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω + let c := (crossingQuenched (realPosition (step e)) 0 t ω)^k * + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) + have hi : c • episodeMeasure q ≤ rawTupleEndpointLaw (realPosition (step e)) (t+1) ω (fun _ : Fin k => 0) := by + rw [mul_smul] + exact episodeInitial_retained e f hef r sfloor hR t ω κ hκ1 hκ + have hs := episodeRun_retained_local e f hef r fexp g χ b sfloor hr N hf hb hsfloor q ω hH κ (fun y => hκ y e) N + have hs := smul_le_smul_left c hs + rw [←rawTupleMixture_smul] at hs + have hm := rawTupleMixture_mono (realPosition (step e)) (p.height-q.height) ω hi + have hc := rawTupleEndpointLaw_comp_le e (t+1) (p.height-q.height) ω (fun _ : Fin k => 0) + have ht : t+1 ≤ p.height := episodeRun_height_mono e f hef r fexp g χ b sfloor N q ω N + have hh : (t+1)+(p.height-q.height)=p.height := by change (t+1)+(p.height-(t+1))=p.height; omega + rw [hh] at hc + simpa only [c,p,q,episodeStageCount,episodeFinal,episodeMeasure,mul_smul] using hs.trans (hm.trans hc) + +lemma episode_survival_lower_local {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hr : StageRadiusOrder r fexp b sfloor) (hR : 0 ≤ r sfloor) (N t : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (ω : Environment d) (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + (crossingQuenched (realPosition (step e)) 0 t ω)^k * + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) * + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω) ≤ + (crossingQuenched (realPosition (step e)) 0 + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω)^k := by + have hh := episodeFinal_global_retained_local (k:=k) e f hef r fexp g χ b sfloor hr hR N t hf hb hsfloor ω hH κ hκ1 hκ Set.univ + simpa only [Measure.smul_apply,smul_eq_mul,episodeMeasure,measure_univ,mul_one, + rawTupleEndpointLaw_origin_mass] using hh + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +lemma coordinate_survival_lower {d : ℕ} (e : Direction d) (ω : Environment d) + (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).1 e) (H : ℕ) : + (κ : ℝ≥0∞)^H ≤ crossingQuenched (realPosition (step e)) 0 H ω := by + induction H with + | zero => simp [crossingQuenched_zero] + | succ H ih => + have hh := crossingQuenched_lower_step (realPosition (step e)) ω 0 e hκ (H:=H) (by positivity) + rw [signed_direction_unit] at hh + simpa only [Nat.cast_add,Nat.cast_one,pow_succ',Nat.succ_eq_add_one] using + (mul_le_mul_right ih (κ : ℝ≥0∞)).trans hh + +lemma episode_log_algebra {A C : ℝ≥0∞} (hA : A ≠ ⊤) (hC : C ≠ ⊤) + (hA0 : A ≠ 0) (hC0 : C ≠ 0) (κ : ℝ≥0) (hκ : 0 < κ) + (b : ℝ) (k L J : ℕ) (hk : 0 < k) + (h : A^k*(κ:ℝ≥0∞)^(k*L)* + ((κ:ℝ≥0∞)^k*ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^J ≤ C^k) : + Real.log A.toReal-Real.log C.toReal ≤ + (L:ℝ)*(-Real.log κ)+(b-Real.log κ)*(J:ℝ) := by + have hAf : 0 < A.toReal := ENNReal.toReal_pos hA0 hA + have hCf : 0 < C.toReal := ENNReal.toReal_pos hC0 hC + have hκf : 0 < (κ:ℝ) := hκ + have ht := ENNReal.toReal_mono (ENNReal.pow_ne_top hC) h + simp only [ENNReal.toReal_mul,ENNReal.toReal_pow,ENNReal.coe_toReal, + ENNReal.toReal_ofReal (Real.exp_pos _).le] at ht + have hl := Real.log_le_log (by positivity : 0 < A.toReal^k*(κ:ℝ)^(k*L)* + ((κ:ℝ)^k*Real.exp (-((k:ℝ)*b)))^J) ht + rw [Real.log_mul (by positivity) (by positivity), + Real.log_mul (by positivity) (by positivity),Real.log_pow,Real.log_pow,Real.log_pow, + Real.log_mul (by positivity) (Real.exp_ne_zero _),Real.log_pow,Real.log_exp,Real.log_pow] at hl + have hkf : 0 < (k:ℝ) := Nat.cast_pos.mpr hk + push_cast at hl + nlinarith + +theorem episode_log_bound {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (hr : Monotone r) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (ω : Environment d) (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) + (hk : 0 < k) (hbκ : -Real.log κ ≤ b) : + 0 ≤ Real.log (crossingQuenched (realPosition (step e)) 0 t ω).toReal - + Real.log (crossingQuenched (realPosition (step e)) 0 + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω).toReal ∧ + Real.log (crossingQuenched (realPosition (step e)) 0 t ω).toReal - + Real.log (crossingQuenched (realPosition (step e)) 0 + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω).toReal ≤ + (BoundedInjection.injectionMultiplier (r sfloor)*k+1:ℕ)*(-Real.log κ)+ + 2*b*(episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω) := by + let T := (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height + have hpos (h : ℕ) : crossingQuenched (realPosition (step e)) 0 h ω ≠ 0 := + ne_of_gt ((ENNReal.pow_pos (ENNReal.coe_pos.mpr hκ0) h).trans_le + (coordinate_survival_lower e ω κ (fun y => hκ y e) h)) + have hfinite (h : ℕ) := crossingQuenched_ne_top (realPosition (step e)) 0 h ω + have hl := episode_log_algebra (hfinite t) (hfinite T) (hpos t) (hpos T) κ hκ0 b k + (BoundedInjection.injectionMultiplier (r sfloor)*k+1) + (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω) hk + (episode_survival_lower e f hef r hr fexp g χ b sfloor hR N t hf hb hsfloor ω hH κ hκ1 hκ) + constructor + · have hm := crossingQuenched_antitone (realPosition (step e)) 0 ω + (a:= (t:ℝ)) (b:= (T:ℝ)) (by exact_mod_cast (episodeFinal_gt (k:=k) e f hef r fexp g χ b sfloor hR N t ω).le) + exact sub_nonneg.mpr (Real.log_le_log (ENNReal.toReal_pos (hpos T) (hfinite T)) + (ENNReal.toReal_mono (hfinite t) hm)) + · have hj : 0 ≤ (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω : ℝ) := by positivity + dsimp only [T] at hl + push_cast at hl ⊢ + nlinarith + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeInjection.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeInjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..77208778094d49831a0d5bf842e1ab9ab3766aa9 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeInjection.lean @@ -0,0 +1,217 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.StageInjection +import OAI.Probability.Ballisticity.Stationary.EpisodeRetention +import OAI.Probability.Ballisticity.Estimates.GlobalTuple + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal BigOperators Classical +namespace DirectionalTransience.BoundedInjection + +noncomputable def injectionMultiplier (R : ℝ) : ℕ := ⌈2*R⌉₊+1 + +lemma injectionMultiplier_lt (R : ℝ) : 2*R < (injectionMultiplier R : ℝ) := by + have h := Nat.le_ceil (2*R) + dsimp [injectionMultiplier] + push_cast + linarith + +noncomputable def injectionChoice {d k : ℕ} (f : Direction d) (R : ℝ) (hR : 0 ≤ R) + (x : Fin k → Lattice d) : Fin k → Fin k := + (finite_injection_choice k R (injectionMultiplier R) hR (injectionMultiplier_lt R) + (fun j => signedCoordinate f (x j))).choose + +noncomputable def injectionOffset {d k : ℕ} (f : Direction d) (R : ℝ) (hR : 0 ≤ R) + (x : Fin k → Lattice d) (j : Fin k) : ℕ := + injectionMultiplier R * ((injectionChoice f R hR x j : ℕ)+1) + +noncomputable def injectTuple {d k : ℕ} (e f : Direction d) (R : ℝ) (hR : 0 ≤ R) + (x : Fin k → Lattice d) : Fin k → Lattice d := + fun j => x j+injectionOffset f R hR x j • step f+step e + +lemma injectionOffset_le {d k : ℕ} (f : Direction d) (R : ℝ) (hR : 0 ≤ R) + (x : Fin k → Lattice d) (j : Fin k) : injectionOffset f R hR x j ≤ injectionMultiplier R*k := by + exact Nat.mul_le_mul_left _ (injectionChoice f R hR x j).isLt + +lemma injectTuple_separated {d k : ℕ} (e f : Direction d) (R : ℝ) (hR : 0 ≤ R) + (x : Fin k → Lattice d) : TupleSeparated f R (injectTuple e f R hR x) := by + intro i j hij + have h := (finite_injection_choice k R (injectionMultiplier R) hR (injectionMultiplier_lt R) + (fun j => signedCoordinate f (x j))).choose_spec i j hij + simpa only [injectTuple,injectionOffset,signedCoordinate_add,signedCoordinate_nsmul, + signedCoordinate_step_self,mul_one,Nat.cast_mul,Nat.cast_add,Nat.cast_one, + add_sub_add_right_eq_sub,injectionChoice] using h + +lemma injectTuple_height {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R : ℝ) (hR : 0 ≤ R) (a : ℝ) (x : Fin k → Lattice d) + (hx : x ∈ TupleAtHeight (realPosition (step e)) a) : + injectTuple e f R hR x ∈ TupleAtHeight (realPosition (step e)) (a+1) := by + intro j + have hh := hx j + simp only [signedHeight_projection] at hh + change dot (realPosition (x j+injectionOffset f R hR x j • step f+step e)) (realPosition (step e))=a+1 + simp only [signedHeight_projection,signedHeight_add_step_self, + signedHeight_add_nsmul_other e f hef,Int.cast_add,Int.cast_one,hh] + +lemma injectTuple_kernel_le {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R : ℝ) (hR : 0 ≤ R) (ω : Environment d) (x : Fin k → Lattice d) + (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + (κ : ℝ≥0∞)^(k*(injectionMultiplier R*k+1)) • Measure.dirac (injectTuple e f R hR x) ≤ + rawTupleEndpointLaw (realPosition (step e)) 1 ω x := by + apply TupleKernel.measure_le_of_singletons + intro y + by_cases hy : y=injectTuple e f R hR x + · subst y + simp only [Measure.smul_apply,smul_eq_mul,Measure.dirac_apply_of_mem (Set.mem_singleton _),mul_one, + rawTupleEndpointLaw_singleton] + have hc : (κ : ℝ≥0∞) ≤ 1 := by exact_mod_cast hκ1 + calc + _ = ∏ _j : Fin k, (κ : ℝ≥0∞)^(injectionMultiplier R*k+1) := by + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,←pow_mul,Nat.mul_comm] + _ ≤ ∏ j, variableHitKernel (realPosition (step e)) 1 (ω,x j) {injectTuple e f R hR x j} := by + apply Finset.prod_le_prod + intro j _ + have hp := elliptic_lateral_script ω e f hef (x j) (injectionOffset f R hR x j) hκ + have hb : (κ : ℝ≥0∞)^(injectionMultiplier R*k+1) ≤ + (κ : ℝ≥0∞)^(injectionOffset f R hR x j+1) := + pow_le_pow_of_le_one bot_le hc (Nat.add_le_add_right (injectionOffset_le f R hR x j) 1) + apply hb.trans + simp only [variableHitKernel, Kernel.coe_mk, Nat.cast_one] + change (κ : ℝ≥0∞)^(injectionOffset f R hR x j+1) ≤ + hitKernel (Strip (realPosition (step e)) (x j) 1) (Upper (realPosition (step e)) (x j) 1) (ω,x j) {injectTuple e f R hR x j} + simpa only [Measure.smul_apply,smul_eq_mul,injectTuple, + Measure.dirac_apply_of_mem (Set.mem_singleton _),mul_one] using hp {injectTuple e f R hR x j} + · simp only [Measure.smul_apply,smul_eq_mul,Measure.dirac_apply',measurableSet_singleton, + Set.indicator_apply,Set.mem_singleton_iff] + simp [Ne.symm hy] + +noncomputable def injectionProfile {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R : ℝ) (hR : 0 ≤ R) (a : ℝ) (π : LayerTupleProfile (k:=k) e a) : + BudgetProfile (k:=k) e f (a+1) R := by + let ρ := π.val.map (injectTuple e f R hR) + refine ⟨ρ,inferInstance,?_⟩ + rw [ae_map_iff (measurable_of_countable _).aemeasurable (Set.to_countable _).measurableSet] + exact π.property.2.mono fun x hx => ⟨injectTuple_height e f hef R hR a x hx, + injectTuple_separated e f R hR x⟩ + +lemma injectionProfile_measurable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R : ℝ) (hR : 0 ≤ R) (a : ℝ) : Measurable (injectionProfile (k:=k) e f hef R hR a) := by + exact ((Measure.measurable_map _ (measurable_of_countable _)).comp measurable_subtype_coe).subtype_mk + +lemma injectionProfile_retained {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R : ℝ) (hR : 0 ≤ R) (a : ℝ) (π : LayerTupleProfile (k:=k) e a) + (ω : Environment d) (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + (κ : ℝ≥0∞)^(k*(injectionMultiplier R*k+1)) • (injectionProfile e f hef R hR a π).val ≤ + rawTupleMixture (realPosition (step e)) 1 π.val ω := by + intro U + have hU := (Set.to_countable U).measurableSet + change (κ : ℝ≥0∞)^(k*(injectionMultiplier R*k+1))*(π.val.map (injectTuple e f R hR)) U ≤ _ + rw [Measure.map_apply (measurable_of_countable _) hU,rawTupleMixture_apply] + calc + _ = ∫⁻ x, ((κ : ℝ≥0∞)^(k*(injectionMultiplier R*k+1)) • Measure.dirac (injectTuple e f R hR x)) U ∂π.val := by + simp only [Measure.smul_apply,smul_eq_mul,Measure.dirac_apply' _ hU] + rw [lintegral_const_mul _ (measurable_of_countable _)] + congr 1 + rw [←lintegral_indicator_one ((measurable_of_countable _) hU)] + apply lintegral_congr + intro x + by_cases hx : injectTuple e f R hR x ∈ U <;> simp [hx] + _ ≤ _ := lintegral_mono fun x => (injectTuple_kernel_le e f hef R hR ω x κ hκ1 hκ) U + +end DirectionalTransience.BoundedInjection + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +noncomputable def episodeInitial {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) (t : ℕ) (ω : Environment d) : + EpisodeState (k:=k) e f r := by + let p := BoundedInjection.injectionProfile e f hef (r sfloor) hR t + (globalTupleProfile (k:=k) e t ω) + refine ⟨t+1,sfloor,p.val,p.property.1,?_⟩ + simpa only [Nat.cast_add,Nat.cast_one] using p.property.2 + +lemma episodeInitial_retained {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) (t : ℕ) (ω : Environment d) + (κ : ℝ≥0) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) : + (crossingQuenched (realPosition (step e)) 0 t ω)^k • + (κ : ℝ≥0∞)^(k*(BoundedInjection.injectionMultiplier (r sfloor)*k+1)) • + episodeMeasure (episodeInitial (k:=k) e f hef r sfloor hR t ω) ≤ + rawTupleEndpointLaw (realPosition (step e)) (t+1) ω (fun _ : Fin k => 0) := by + have hi := BoundedInjection.injectionProfile_retained e f hef (r sfloor) hR t + (globalTupleProfile (k:=k) e t ω) ω κ hκ1 hκ + have hi := smul_le_smul_left ((crossingQuenched (realPosition (step e)) 0 t ω)^k) hi + rw [←rawTupleMixture_smul,globalTupleProfile_mass] at hi + exact hi.trans (rawTupleEndpointLaw_comp_le e t 1 ω (fun _ : Fin k => 0)) + +noncomputable def episodeFinal {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (ω : Environment d) : EpisodeState (k:=k) e f r := + episodeRun e f hef r fexp g χ b sfloor N + (episodeInitial e f hef r sfloor hR t ω) ω N + +lemma episodeFinal_gt {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (ω : Environment d) : t < (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height := by + have hh := episodeRun_height_mono e f hef r fexp g χ b sfloor N + (episodeInitial (k:=k) e f hef r sfloor hR t ω) ω N + exact Nat.lt_of_lt_of_le (Nat.lt_succ_self t) hh + +lemma episodeFinal_le {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (ω : Environment d) (ht : t 0 + | i+1 => let t := episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i + if t exact Nat.zero_le _ + | succ i ih => + rw [episodeBoundary] + split + · exact episodeFinal_le e f hef r fexp g χ b sfloor hR N _ ω ‹_› + · exact ih + +lemma episodeBoundary_progress {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (ω : Environment d) (i : ℕ) : + min i N ≤ episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i := by + induction i with + | zero => exact Nat.zero_le _ + | succ i ih => + rw [episodeBoundary] + split + · have hh := episodeFinal_gt (k:=k) e f hef r fexp g χ b sfloor hR N + (episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i) ω + omega + · omega + +theorem episodeBoundary_complete {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (ω : Environment d) : episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω N=N := by + have hu := episodeBoundary_le (k:=k) e f hef r fexp g χ b sfloor hR N ω N + have hl := episodeBoundary_progress (k:=k) e f hef r fexp g χ b sfloor hR N ω N + omega + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeLength.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeLength.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad7730fd262a2d2df1afda1c76795e03743cecc6 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeLength.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.StageClassification + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma episodeStageScale_pos {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) (hs : 0 < q.scale) : + 0 < episodeStageScale e f r fexp g χ b N q ω := by + unfold episodeStageScale + split <;> positivity + +lemma episodeStageScale_le {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hf : 0 ≤ fexp) (hg : 0 ≤ g) (hb : 0 ≤ b) (hs : 0 ≤ q.scale) : + episodeStageScale e f r fexp g χ b N q ω ≤ q.scale*Real.exp (g*b) := by + unfold episodeStageScale + split + · exact le_rfl + · exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by nlinarith)) hs + +lemma episodeStageLength_le {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) (hs : 0 ≤ q.scale) : + (episodeStageLength e f r fexp g χ b N q ω : ℝ) ≤ q.scale*Real.exp (χ*b) := by + have hh := (stageStop_le e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω).trans (min_le_left _ _) + exact (show (episodeStageLength e f r fexp g χ b N q ω : ℝ) ≤ (episodeStageH χ b q.scale : ℝ) by exact_mod_cast hh).trans + (Nat.floor_le (mul_nonneg hs (Real.exp_pos _).le)) + +lemma episodeRun_length_scale {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hf : 0 ≤ fexp) (hg : 0 ≤ g) (hb : 0 ≤ b) (hq : 0 < q.scale) (n : ℕ) : + let p := episodeRun e f hef r fexp g χ b sfloor N q ω n + let J := episodeSteps e f hef r fexp g χ b sfloor N q ω n + 0 < p.scale ∧ p.scale ≤ q.scale*Real.exp (g*b)^J ∧ + (p.height:ℝ) ≤ (q.height:ℝ)+(J:ℝ)*q.scale*Real.exp (g*b)^J*Real.exp (χ*b) := by + induction n with + | zero => simpa only [episodeRun,episodeSteps,pow_zero,mul_one,Nat.cast_zero,zero_mul,add_zero] using ⟨hq,le_rfl,le_rfl⟩ + | succ n ih => + dsimp only at ih ⊢ + rw [episodeRun,episodeSteps] + by_cases hr : EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) + · rw [ite_eq_left hr,ite_eq_left hr] + let p := episodeRun e f hef r fexp g χ b sfloor N q ω n + let J := episodeSteps e f hef r fexp g χ b sfloor N q ω n + have hE : 1 ≤ Real.exp (g*b) := Real.one_le_exp_iff.mpr (mul_nonneg hg hb) + have hpow : Real.exp (g*b)^J ≤ Real.exp (g*b)^(J+1) := by + rw [pow_succ] + exact le_mul_of_one_le_right (by positivity) hE + refine ⟨episodeStageScale_pos e f r fexp g χ b N p ω ih.1,?_,?_⟩ + · change episodeStageScale e f r fexp g χ b N p ω ≤ _ + calc + _ ≤ p.scale*Real.exp (g*b) := episodeStageScale_le e f r fexp g χ b N p ω hf hg hb ih.1.le + _ ≤ (q.scale*Real.exp (g*b)^J)*Real.exp (g*b) := mul_le_mul_of_nonneg_right ih.2.1 (Real.exp_pos _).le + _ = q.scale*Real.exp (g*b)^(J+1) := by rw [pow_succ,mul_assoc] + · rw [episodeStageNext_height,Nat.cast_add] + have hl := episodeStageLength_le e f r fexp g χ b N p ω ih.1.le + have hlq := mul_le_mul_of_nonneg_right ih.2.1 (Real.exp_pos (χ*b)).le + have hunit : (p.height:ℝ)+(episodeStageLength e f r fexp g χ b N p ω : ℝ) ≤ + (q.height:ℝ)+((J:ℝ)+1)*q.scale*Real.exp (g*b)^J*Real.exp (χ*b) := by + dsimp only [p,J] at hl hlq ⊢ + nlinarith [ih.2.2] + apply hunit.trans + rw [Nat.cast_add,Nat.cast_one] + exact add_le_add_right (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hpow (by positivity : 0 ≤ ((J:ℝ)+1)*q.scale)) + (Real.exp_pos _).le) _ + · simpa only [ite_eq_right hr,add_zero] using ih + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + +noncomputable def scale : ℕ → ℝ + | 0 => q.scale + | n+1 => + let p := episodeRun e f hef r fexp g χ b sfloor N q ω n + if EpisodeReady e f r sfloor N p then + if episodeStageGrows e f r fexp g χ b N p ω then + scale n * Real.exp (g*b) + else if episodeStageFails e f r fexp g χ b N p ω then + scale n * Real.exp (-fexp*b) + else scale n + else scale n + +local notation "R" => episodeRun e f hef r fexp g χ b sfloor N q ω +local notation "A" => scale e f hef r fexp g χ b sfloor N q ω +local notation "Grow" => episodeStageGrows e f r fexp g χ b N +local notation "Fail" => episodeStageFails e f r fexp g χ b N +local notation "Ready" => EpisodeReady e f r sfloor N + +lemma scale_pos (hq : 0 < q.scale) (n : ℕ) : 0 < A n := by + induction n with + | zero => exact hq + | succ n ih => dsimp only [scale]; split; split; positivity; split <;> positivity; exact ih + +lemma scale_agrees (n : ℕ) (hn : (R n).height < N) : A n=(R n).scale := by + induction n with + | zero => rfl + | succ n ih => + rw [episodeRun] at hn ⊢ + rw [scale] + by_cases hr : Ready (R n) + · simp only [ite_eq_left hr] at hn ⊢ + rw [ih hr.1] + change (if Grow (R n) ω then (R n).scale*Real.exp (g*b) else + if Fail (R n) ω then (R n).scale*Real.exp (-fexp*b) else (R n).scale) = + episodeStageScale e f r fexp g χ b N (R n) ω + unfold episodeStageScale + by_cases hg : Grow (R n) ω + · simp only [ite_eq_left hg] + · rw [ite_eq_right hg,ite_eq_right hg] + by_cases hf : Fail (R n) ω + · rw [ite_eq_left hf] + · have ht := episodeStage_incomplete_terminal e f hef r fexp g χ b N (R n) ω hr.1.le hf hg + omega + · simp only [ite_eq_right hr] at hn ⊢ + exact ih hn + +lemma scale_le (hq : 0 < q.scale) (hqcap : q.scale ≤ max sfloor (N:ℝ)) + (hqN : q.height ≤ N) (hf : 0 ≤ fexp) (hb : 0 ≤ b) + (hH : ∀ s, sfloor ≤ s → s*Real.exp (g*b) ≤ (episodeStageH χ b s : ℝ)) (n : ℕ) : + A n ≤ max sfloor (N:ℝ) := by + induction n with + | zero => exact hqcap + | succ n ih => + rw [scale] + by_cases hr : Ready (R n) + · rw [ite_eq_left hr] + by_cases hg : Grow (R n) ω + · rw [ite_eq_left hg,scale_agrees e f hef r fexp g χ b sfloor N q ω n hr.1] + have hl : episodeStageLength e f r fexp g χ b N (R n) ω ≤ N := by + have hn := episodeStageNext_le e f hef r fexp g χ b N (R n) ω + (episodeRun_le e f hef r fexp g χ b sfloor N q ω hqN n) + rw [episodeStageNext_height] at hn + omega + apply (hH _ hr.2).trans + have he := (episodeStage_grows_iff e f r fexp g χ b N (R n) ω).mp hg + rw [←he.1] + exact (show (episodeStageLength e f r fexp g χ b N (R n) ω : ℝ) ≤ (N:ℝ) by exact_mod_cast hl).trans + (le_max_right _ _) + · rw [ite_eq_right hg] + split + · apply le_trans _ ih + exact mul_le_of_le_one_right (scale_pos e f hef r fexp g χ b sfloor N q ω hq n).le + (Real.exp_le_one_iff.mpr (by nlinarith)) + · exact ih + · rw [ite_eq_right hr] + exact ih + +lemma log_scale (hq : 0 < q.scale) (n : ℕ) : + Real.log (A n)-Real.log q.scale = + g*b*(episodeCount e f hef r fexp g χ b sfloor N q ω Grow n : ℝ) - + fexp*b*(episodeCount e f hef r fexp g χ b sfloor N q ω Fail n : ℝ) := by + induction n with + | zero => simp only [scale,episodeCount,Nat.cast_zero,mul_zero,sub_self] + | succ n ih => + rw [scale,episodeCount,episodeCount] + by_cases hr : Ready (R n) + · by_cases hg : Grow (R n) ω + · have hf := ((episodeStage_grows_iff e f r fexp g χ b N (R n) ω).mp hg).2 + simp only [hr,hg,hf,and_self,and_false,ite_true,ite_false, + Nat.cast_add,Nat.cast_one,add_zero] + rw [Real.log_mul (ne_of_gt (scale_pos e f hef r fexp g χ b sfloor N q ω hq n)) (Real.exp_ne_zero _),Real.log_exp] + linarith + · by_cases hf : Fail (R n) ω + · simp only [hr,hg,hf,and_self,and_false,ite_true,ite_false, + Nat.cast_add,Nat.cast_one,add_zero] + rw [Real.log_mul (ne_of_gt (scale_pos e f hef r fexp g χ b sfloor N q ω hq n)) (Real.exp_ne_zero _),Real.log_exp] + linarith + · simpa only [hr,hg,hf,and_false,ite_true,ite_false,add_zero] using ih + · simpa only [hr,false_and,ite_false,add_zero] using ih + +end EpisodeLedger +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeLogLength.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeLogLength.lean new file mode 100644 index 0000000000000000000000000000000000000000..820e48abb548b70629a8abaf9a1e38564ceca7cc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeLogLength.lean @@ -0,0 +1,93 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeGlobalRetention +import OAI.Probability.Ballisticity.Stationary.EpisodeLength + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +private lemma episode_log_geometric_bound (A B h : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hB : 0 ≤ B) (hh : 0 ≤ h) + (hbound : h ≤ (J:ℝ)*A*Real.exp B^J) : + Real.log (1+h) ≤ (Real.log (1+A)+1+B)*(1+(J:ℝ)) := by + have hJ : (J:ℝ) ≤ Real.exp (J:ℝ) := by linarith [Real.add_one_le_exp (J:ℝ)] + have hE : 1 ≤ Real.exp ((1+B)*(J:ℝ)) := Real.one_le_exp_iff.mpr (by positivity) + have hprod : Real.exp (J:ℝ)*Real.exp B^J = Real.exp ((1+B)*(J:ℝ)) := by + rw [←Real.exp_nat_mul,←Real.exp_add] + congr 1 + ring + have hmul := mul_le_mul_of_nonneg_right hJ (mul_nonneg hA (by positivity : 0 ≤ Real.exp B^J)) + have hl : 1+h ≤ (1+A)*Real.exp ((1+B)*(J:ℝ)) := by + have he : Real.exp (J:ℝ)*(A*Real.exp B^J) = A*Real.exp ((1+B)*(J:ℝ)) := by + rw [←hprod] + ring + rw [he] at hmul + nlinarith + have hlog := Real.log_le_log (by positivity : 0 < 1+h) hl + rw [Real.log_mul (by positivity) (Real.exp_pos _).ne',Real.log_exp] at hlog + have hlogA : 0 ≤ Real.log (1+A) := Real.log_nonneg (by linarith) + have hjA := mul_nonneg hlogA (Nat.cast_nonneg J : (0:ℝ) ≤ J) + nlinarith + +lemma episodeRun_logLength {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hf : 0 ≤ fexp) (hg : 0 ≤ g) (hb : 0 ≤ b) (hq : 0 < q.scale) (n : ℕ) : + let p := episodeRun e f hef r fexp g χ b sfloor N q ω n + let J := episodeSteps e f hef r fexp g χ b sfloor N q ω n + Real.log (1+(p.height-q.height:ℕ)) ≤ + (Real.log (1+q.scale*Real.exp (χ*b))+1+g*b)*(1+(J:ℝ)) := by + dsimp only + have hlen := (episodeRun_length_scale e f hef r fexp g χ b sfloor N q ω hf hg hb hq n).2.2 + have hmono := episodeRun_height_mono e f hef r fexp g χ b sfloor N q ω n + apply episode_log_geometric_bound (q.scale*Real.exp (χ*b)) (g*b) _ _ + (by positivity) (mul_nonneg hg hb) (Nat.cast_nonneg _) + rw [Nat.cast_sub hmono] + nlinarith [hlen] + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +theorem episode_log_length_bound {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N t : ℕ) + (ω : Environment d) (hf : 0 ≤ fexp) (hg : 0 ≤ g) (hb : 0 ≤ b) (hs : 0 < sfloor) : + Real.log (1+((episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height-t:ℕ)) ≤ + (Real.log 2+Real.log (1+sfloor*Real.exp (χ*b))+1+g*b)* + (1+(episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω : ℝ)) := by + let q := episodeInitial (k:=k) e f hef r sfloor hR t ω + let p := episodeRun e f hef r fexp g χ b sfloor N q ω N + let J := episodeSteps e f hef r fexp g χ b sfloor N q ω N + have h := episodeRun_logLength e f hef r fexp g χ b sfloor N q ω hf hg hb hs N + have hm := episodeRun_height_mono e f hef r fexp g χ b sfloor N q ω N + have hqt : q.height=t+1 := rfl + have he : p.height-t=(p.height-q.height)+1 := by dsimp only [p] at ⊢; omega + change Real.log (1+(p.height-t:ℕ)) ≤ _ + rw [he,Nat.cast_add,Nat.cast_one] + have hl := Real.log_le_log (by positivity : 0 < 1+((p.height-q.height:ℕ):ℝ)+1) + (show 1+((p.height-q.height:ℕ):ℝ)+1 ≤ 2*(1+((p.height-q.height:ℕ):ℝ)) by nlinarith [(show (0:ℝ) ≤ (p.height-q.height:ℕ) from Nat.cast_nonneg _)]) + rw [Real.log_mul (by norm_num) (by positivity)] at hl + have htwo : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + have hjtwo := mul_nonneg htwo (Nat.cast_nonneg J : (0:ℝ) ≤ J) + change Real.log (1+((p.height-q.height:ℕ):ℝ)) ≤ + (Real.log (1+sfloor*Real.exp (χ*b))+1+g*b)*(1+(J:ℝ)) at h + change Real.log (1+(((p.height-q.height:ℕ):ℝ)+1)) ≤ + (Real.log 2+Real.log (1+sfloor*Real.exp (χ*b))+1+g*b)*(1+(J:ℝ)) + rw [add_assoc] at hl + nlinarith + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeMeanDrop.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeMeanDrop.lean new file mode 100644 index 0000000000000000000000000000000000000000..5434ed279009e33f4d8a852a2798f733f9f4c927 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeMeanDrop.lean @@ -0,0 +1,283 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.LocalEpisodeLog +import OAI.Probability.Ballisticity.Stationary.EpisodeDropLedger + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience.EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "J" => steps (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "M" => number (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "j" => stepMark (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "c" => dropMark (k:=k) e f hef r fexp g χ b sfloor hR N + +theorem mean_episode_drops (hr : Monotone r) (hf : 0 ≤ fexp) (hb : 0 < b) (hs : 0 < sfloor) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hk : 0 < k) (hbκ : -Real.log κ ≤ b) + (Q : Measure (Environment d)) [IsProbabilityMeasure Q] + (hκ : ∀ᵐ ω ∂Q, ∀ y u, κ ≤ (ω y).1 u) + (β : ℝ) (hbad : ∀ᵐ ω ∂Q, β*Real.log (N:ℝ) ≤ -Real.log (crossingQuenched (realPosition (step e)) 0 N ω).toReal) + (hstages : 2*b*(∫ ω, (J ω N:ℝ) ∂Q) ≤ β/4*Real.log (N:ℝ)) + (L : ℕ) (hL : 0 ∑ i ∈ Finset.range N, if j ω i≤L then c ω i else 0 + let B : Environment d → ℝ := fun ω => ∑ i ∈ Finset.range N, if L -Real.log (crossingQuenched (realPosition (step e)) 0 N ω).toReal + have hc (i : ℕ) := dropMark_integrable (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb.le hs hH κ hκ0 hκ1 hk hbκ Q hκ i + have hsum : Integrable D Q := by + have hh := integrable_finsetSum (s:=Finset.range N) (fun i _ => hc i) + simpa only [dropMark_total] using hh + have hS : Integrable S Q := by + apply integrable_finsetSum + intro i _ + convert (hc i).indicator (s:={ω | j ω i≤L}) (measurableSet_le (stepMark_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i) measurable_const) using 1 + funext ω + simp only [Set.indicator_apply,Set.mem_ofPred_eq] + have hB : Integrable B Q := by + apply integrable_finsetSum + intro i _ + convert (hc i).indicator (s:={ω | L total_drop_bound (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb.le hs hH κ hκ0 hκ1 hk hbκ ω hω)) + change (∫ ω, D ω ∂Q) ≤ (∫ ω, A*(M ω N:ℝ)+2*b*(J ω N:ℝ) ∂Q) at hh + rw [integral_add (f:=fun ω => A*(M ω N:ℝ)) (g:=fun ω => 2*b*(J ω N:ℝ)) (hM.const_mul _) (hJ.const_mul _), + integral_const_mul,integral_const_mul] at hh + exact hh + have hlower : 3*β/4*Real.log (N:ℝ) ≤ A*(∫ ω, (M ω N:ℝ) ∂Q) := by linarith + have hupper : (∫ ω, (M ω N:ℝ) ∂Q) ≤ β*Real.log (N:ℝ)/(8*b)+1 := by + have hcount := integral_mono hM (hJ.add (integrable_const 1)) (fun ω => by + change (M ω N:ℝ) ≤ (J ω N:ℝ)+1 + exact_mod_cast (number_stage_bound (k:=k) e f hef r fexp g χ b sfloor hR N ω N).1) + change (∫ ω, (M ω N:ℝ) ∂Q) ≤ (∫ ω, (J ω N:ℝ)+1 ∂Q) at hcount + rw [integral_add (f:=fun ω => (J ω N:ℝ)) (g:=fun _ => (1:ℝ)) hJ (integrable_const _)] at hcount + simp only [integral_const,probReal_univ,one_smul] at hcount + have hjle : (∫ ω, (J ω N:ℝ) ∂Q) ≤ β*Real.log (N:ℝ)/(8*b) := by + apply (le_div_iff₀ (show 0<8*b by positivity)).mpr + nlinarith only [hstages] + linarith + have hlong : (∫ ω, B ω ∂Q) ≤ β/2*Real.log (N:ℝ) := by + have hl : (∫ ω, B ω ∂Q) ≤ (A/(L:ℝ)+2*b)*(∫ ω, (J ω N:ℝ) ∂Q) := by + have hh := integral_mono_ae hB (hJ.const_mul (A/(L:ℝ)+2*b)) + (hκ.mono (fun ω hω => long_drop_bound (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb.le hs hH κ hκ0 hκ1 hk hbκ ω hω L hL)) + rw [integral_const_mul] at hh + exact hh + have hcoeff : A/(L:ℝ) ≤ 2*b := (div_le_iff₀ (Nat.cast_pos.mpr hL)).mpr hcharge + have hnon : 0 ≤ ∫ ω, (J ω N:ℝ) ∂Q := integral_nonneg (fun _ => Nat.cast_nonneg _) + have hm := mul_le_mul_of_nonneg_right hcoeff hnon + nlinarith only [hl,hm,hstages] + have hsplit : (∫ ω, S ω ∂Q)+(∫ ω, B ω ∂Q)=(∫ ω, D ω ∂Q) := by + rw [←integral_add hS hB] + apply integral_congr_ae + filter_upwards [] with ω + change S ω+B ω=D ω + dsimp only [S,B,D] + rw [←Finset.sum_add_distrib,←dropMark_total (k:=k) e f hef r fexp g χ b sfloor hR N ω] + apply Finset.sum_congr rfl + intro i _ + by_cases hh : j ω i≤L + · simp only [ite_eq_left hh,ite_eq_right (not_lt.mpr hh),add_zero] + · simp only [ite_eq_right hh,ite_eq_left (Nat.lt_of_not_ge hh),zero_add] + exact ⟨hlower,hupper,by change β/2*Real.log (N:ℝ) ≤ ∫ ω, S ω ∂Q; linarith⟩ + +end DirectionalTransience.EpisodeChainLedger + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience +namespace EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "T" => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "J" => steps (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "M" => number (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "j" => stepMark (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "c" => dropMark (k:=k) e f hef r fexp g χ b sfloor hR N + +lemma dropMark_bounds_local (hr : StageRadiusOrder r fexp b sfloor) (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hs : 0 < sfloor) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hk : 0 < k) (hbκ : -Real.log κ ≤ b) + (ω : Environment d) (hκ : ∀ y u, κ ≤ (ω y).1 u) (i : ℕ) : + 0 ≤ c ω i ∧ c ω i ≤ + ((BoundedInjection.injectionMultiplier (r sfloor)*k+1:ℕ)*(-Real.log κ))* + (if T ω i + (dropMark_bounds_local (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb hs hH κ hκ0 hκ1 hk hbκ ω hκ i).2) + rw [Finset.sum_add_distrib,←Finset.mul_sum,←Finset.mul_sum] at hh + have hm : (∑ i ∈ Finset.range N, if T ω i simp_all only [mul_one,mul_zero,le_refl] + change c ω i ≤ A*(if T ω i hpoint i) + rw [←Finset.mul_sum] at h + have hj : (∑ i ∈ Finset.range N, (j ω i:ℝ))=(J ω N:ℝ) := by + exact_mod_cast stepMark_sum (k:=k) e f hef r fexp g χ b sfloor hR N ω N + rw [hj] at h + exact h + +lemma dropMark_integrable_local (hr : StageRadiusOrder r fexp b sfloor) (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hs : 0 < sfloor) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hk : 0 < k) (hbκ : -Real.log κ ≤ b) + (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (hκ : ∀ᵐ ω ∂Q, ∀ y u, κ ≤ (ω y).1 u) (i : ℕ) : Integrable (fun ω => c ω i) Q := by + let A : ℝ := ((BoundedInjection.injectionMultiplier (r sfloor)*k+1:ℕ)*(-Real.log κ)) + apply Integrable.of_bound (dropMark_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i).aestronglyMeasurable (A+2*b*N) + filter_upwards [hκ] with ω hω + have hc := dropMark_bounds_local (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb hs hH κ hκ0 hκ1 hk hbκ ω hω i + rw [Real.norm_eq_abs,abs_of_nonneg hc.1] + have hA : 0 ≤ A := injection_cost_nonneg (k:=k) r sfloor κ hκ0 hκ1 + have hj : (j ω i:ℝ) ≤ N := by exact_mod_cast stepMark_le (k:=k) e f hef r fexp g χ b sfloor hR N ω i + have hai : A*(if T ω i simp_all only [mul_one,mul_zero,le_refl] + have hc' : c ω i ≤ A*(if T ω i ∑ i ∈ Finset.range N, if j ω i≤L then c ω i else 0 + let B : Environment d → ℝ := fun ω => ∑ i ∈ Finset.range N, if L -Real.log (crossingQuenched (realPosition (step e)) 0 N ω).toReal + have hc (i : ℕ) := dropMark_integrable_local (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb.le hs hH κ hκ0 hκ1 hk hbκ Q hκ i + have hsum : Integrable D Q := by + have hh := integrable_finsetSum (s:=Finset.range N) (fun i _ => hc i) + simpa only [dropMark_total] using hh + have hS : Integrable S Q := by + apply integrable_finsetSum + intro i _ + convert (hc i).indicator (s:={ω | j ω i≤L}) (measurableSet_le (stepMark_measurable (k:=k) e f hef r fexp g χ b sfloor hR N i) measurable_const) using 1 + funext ω + simp only [Set.indicator_apply,Set.mem_ofPred_eq] + have hB : Integrable B Q := by + apply integrable_finsetSum + intro i _ + convert (hc i).indicator (s:={ω | L total_drop_bound_local (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb.le hs hH κ hκ0 hκ1 hk hbκ ω hω)) + change (∫ ω, D ω ∂Q) ≤ (∫ ω, A*(M ω N:ℝ)+2*b*(J ω N:ℝ) ∂Q) at hh + rw [integral_add (f:=fun ω => A*(M ω N:ℝ)) (g:=fun ω => 2*b*(J ω N:ℝ)) (hM.const_mul _) (hJ.const_mul _), + integral_const_mul,integral_const_mul] at hh + exact hh + have hlower : 3*β/4*Real.log (N:ℝ) ≤ A*(∫ ω, (M ω N:ℝ) ∂Q) := by linarith + have hupper : (∫ ω, (M ω N:ℝ) ∂Q) ≤ β*Real.log (N:ℝ)/(8*b)+1 := by + have hcount := integral_mono hM (hJ.add (integrable_const 1)) (fun ω => by + change (M ω N:ℝ) ≤ (J ω N:ℝ)+1 + exact_mod_cast (number_stage_bound (k:=k) e f hef r fexp g χ b sfloor hR N ω N).1) + change (∫ ω, (M ω N:ℝ) ∂Q) ≤ (∫ ω, (J ω N:ℝ)+1 ∂Q) at hcount + rw [integral_add (f:=fun ω => (J ω N:ℝ)) (g:=fun _ => (1:ℝ)) hJ (integrable_const _)] at hcount + simp only [integral_const,probReal_univ,one_smul] at hcount + have hjle : (∫ ω, (J ω N:ℝ) ∂Q) ≤ β*Real.log (N:ℝ)/(8*b) := by + apply (le_div_iff₀ (show 0<8*b by positivity)).mpr + nlinarith only [hstages] + linarith + have hlong : (∫ ω, B ω ∂Q) ≤ β/2*Real.log (N:ℝ) := by + have hl : (∫ ω, B ω ∂Q) ≤ (A/(L:ℝ)+2*b)*(∫ ω, (J ω N:ℝ) ∂Q) := by + have hh := integral_mono_ae hB (hJ.const_mul (A/(L:ℝ)+2*b)) + (hκ.mono (fun ω hω => long_drop_bound_local (k:=k) e f hef r fexp g χ b sfloor hR N hr hf hb.le hs hH κ hκ0 hκ1 hk hbκ ω hω L hL)) + rw [integral_const_mul] at hh + exact hh + have hcoeff : A/(L:ℝ) ≤ 2*b := (div_le_iff₀ (Nat.cast_pos.mpr hL)).mpr hcharge + have hnon : 0 ≤ ∫ ω, (J ω N:ℝ) ∂Q := integral_nonneg (fun _ => Nat.cast_nonneg _) + have hm := mul_le_mul_of_nonneg_right hcoeff hnon + nlinarith only [hl,hm,hstages] + have hsplit : (∫ ω, S ω ∂Q)+(∫ ω, B ω ∂Q)=(∫ ω, D ω ∂Q) := by + rw [←integral_add hS hB] + apply integral_congr_ae + filter_upwards [] with ω + change S ω+B ω=D ω + dsimp only [S,B,D] + rw [←Finset.sum_add_distrib,←dropMark_total (k:=k) e f hef r fexp g χ b sfloor hR N ω] + apply Finset.sum_congr rfl + intro i _ + by_cases hh : j ω i≤L + · simp only [ite_eq_left hh,ite_eq_right (not_lt.mpr hh),add_zero] + · simp only [ite_eq_right hh,ite_eq_left (Nat.lt_of_not_ge hh),zero_add] + exact ⟨hlower,hupper,by change β/2*Real.log (N:ℝ) ≤ ∫ ω, S ω ∂Q; linarith⟩ + +end EpisodeChainLedger +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeNumber.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeNumber.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fab42fc15a78c2355a4215f550f1b5f6b559717 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeNumber.lean @@ -0,0 +1,173 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.EntropyVariational +import OAI.Probability.Ballisticity.Stationary.EpisodeAdapted +import OAI.Probability.Ballisticity.Stationary.EpisodeCountLedger + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma episodeSteps_mono {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) : + Monotone (episodeSteps e f hef r fexp g χ b sfloor N q ω) := by + apply monotone_nat_of_le_succ + intro n + rw [episodeSteps] + exact Nat.le_add_right _ _ + +lemma episodeSteps_pos_of_ready {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hq : EpisodeReady e f r sfloor N q) (n : ℕ) (hn : 0 < n) : + 0 < episodeSteps e f hef r fexp g χ b sfloor N q ω n := by + have hm := episodeSteps_mono e f hef r fexp g χ b sfloor N q ω (Nat.succ_le_of_lt hn) + have he : episodeSteps e f hef r fexp g χ b sfloor N q ω 1=1 := by + simp only [episodeSteps,episodeRun,hq,ite_true,zero_add] + rw [he] at hm + omega + +lemma episodeBoundary_mono {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) (ω : Environment d) : + Monotone (episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω) := by + apply monotone_nat_of_le_succ + intro i + rw [episodeBoundary] + split + · exact (episodeFinal_gt (k:=k) e f hef r fexp g χ b sfloor hR N _ ω).le + · exact le_refl _ + +lemma episodeBoundary_measurable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N i : ℕ) : + Measurable (fun ω => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i) := by + apply measurable_to_countable' + intro m + exact (rowSigma_le _) _ (episodeBoundary_height_event (k:=k) e f hef r fexp g χ b sfloor hR N i m) + +namespace EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "T" => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "J" => steps (k:=k) e f hef r fexp g χ b sfloor hR N + +noncomputable def number (ω : Environment d) : ℕ → ℕ + | 0 => 0 + | i+1 => number ω i+if T ω i number (k:=k) e f hef r fexp g χ b sfloor hR N + +lemma number_sum (ω : Environment d) (n : ℕ) : + M ω n=∑ i ∈ Finset.range n, if T ω i simp only [number,Finset.range_zero,Finset.sum_empty] + | succ n ih => rw [number,Finset.sum_range_succ,ih] + +lemma number_le (ω : Environment d) (n : ℕ) : M ω n ≤ n := by + induction n with + | zero => exact le_refl _ + | succ n ih => rw [number]; split <;> omega + +lemma number_measurable (n : ℕ) : Measurable (fun ω => M ω n) := by + induction n with + | zero => exact measurable_const + | succ n ih => + exact ih.add (Measurable.ite (measurableSet_lt + (episodeBoundary_measurable (k:=k) e f hef r fexp g χ b sfloor hR N n) measurable_const) + measurable_const measurable_const) + +lemma number_stage_bound (ω : Environment d) (n : ℕ) : M ω n ≤ J ω n+1 ∧ + (T ω n exact ⟨by simp only [number,steps]; omega,fun _ => le_refl _⟩ + | succ n ih => + rw [number,steps,episodeBoundary] + by_cases ht : T ω n False.elim (ht h)⟩ + +lemma number_integrable (Q : Measure (Environment d)) [IsFiniteMeasure Q] (n : ℕ) : + Integrable (fun ω => (M ω n:ℝ)) Q := by + apply Entropy.integrable_of_bounded ((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp + (number_measurable (k:=k) e f hef r fexp g χ b sfloor hR N n)) + refine ⟨n,fun ω => ?_⟩ + dsimp only [Function.comp_def] + rw [abs_of_nonneg (Nat.cast_nonneg _)] + exact_mod_cast number_le (k:=k) e f hef r fexp g χ b sfloor hR N ω n + +end EpisodeChainLedger +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience.EpisodeChainLedger +variable {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) +local notation "T" => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N +local notation "M" => number (k:=k) e f hef r fexp g χ b sfloor hR N + +lemma number_mono (ω : Environment d) : Monotone (M ω) := by + apply monotone_nat_of_le_succ + intro n + rw [number] + exact Nat.le_add_right _ _ + +lemma number_active (ω : Environment d) (i : ℕ) (ha : T ω i rfl + | succ i ih => + have hprev : T ω i rfl + | succ j ih => + have hn : ¬T ω (i+j) exact le_refl _ + | succ n ih => + have hh := (A.runFrom hef fexp g χ b sfloor N n).potential_advance ν + (A.runFrom_partition hA hef fexp g χ b sfloor N n) fexp g χ b sfloor K N hH hbound + apply le_trans _ ih + simpa only [episodeSteps,episodeCount,Nat.add_assoc] using hh + +end EpisodeRecordedAtlas + +theorem actual_stage_exponential {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (hef : e.1 ≠ f.1) (r : ℝ → ℝ) + (fexp g χ b sfloor K : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hbound : ∀ s, sfloor ≤ s → ∀ a : ℝ, ∀ π : BudgetProfile (k:=k) e f a (r s), + environmentLaw ν (stageBadEvent e f (episodeStageH χ b s) + (r (s*Real.exp (-fexp*b))) (r (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) ≤ ENNReal.ofReal (Real.exp (-2*(K*b)))) (i : ℕ) : + ∫⁻ ω, stagePotential (K*b) + (EpisodeChainLedger.steps (k:=k) e f hef r fexp g χ b sfloor hR N ω i) + (EpisodeChainLedger.count (k:=k) e f hef r fexp g χ b sfloor hR N ω + (episodeStageFails e f r fexp g χ b N) i) ∂environmentLaw ν ≤ 1 := by + have hc : ∀ i : ℕ, ∫⁻ ω, stagePotential (K*b) + (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).stages + (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).failures ∂environmentLaw ν ≤ 1 := by + intro i + induction i with + | zero => simp only [episodeCounterChain,stagePotential,Nat.cast_zero,mul_zero,sub_self,Real.exp_zero, + ENNReal.ofReal_one,lintegral_one,measure_univ,le_refl] + | succ i ih => + apply le_trans _ ih + exact (episodeCounterAtlas (k:=k) e f hef r fexp g χ b sfloor hR N i).potential_runFrom ν + (episodeCounterAtlas_partition (k:=k) e f hef r fexp g χ b sfloor hR N i) + hef fexp g χ b sfloor K N hH hbound N + have he : (fun ω => stagePotential (K*b) + (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).stages + (episodeCounterChain (k:=k) e f hef r fexp g χ b sfloor hR N ω i).failures) = + (fun ω => stagePotential (K*b) + (EpisodeChainLedger.steps (k:=k) e f hef r fexp g χ b sfloor hR N ω i) + (EpisodeChainLedger.count (k:=k) e f hef r fexp g χ b sfloor hR N ω + (episodeStageFails e f r fexp g χ b N) i)) := by + funext ω + have hh := episodeCounterChain_actual (k:=k) e f hef r fexp g χ b sfloor hR N ω i + rw [hh.2.2.1,hh.2.2.2] + simpa only [he] using hc i + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +theorem actual_stage_entropy {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (hef : e.1 ≠ f.1) (r : ℝ → ℝ) + (fexp g χ b sfloor K : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hbound : ∀ s, sfloor ≤ s → ∀ a : ℝ, ∀ π : BudgetProfile (k:=k) e f a (r s), + environmentLaw ν (stageBadEvent e f (episodeStageH χ b s) + (r (s*Real.exp (-fexp*b))) (r (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) ≤ ENNReal.ofReal (Real.exp (-2*(K*b)))) + (Q : Measure (Environment d)) [IsProbabilityMeasure Q] (C : ℝ) (hC : 0 ≤ C) + (hkl : klDiv Q (environmentLaw ν) ≤ ENNReal.ofReal C) (i : ℕ) : + K*b*(∫ ω, (EpisodeChainLedger.count (k:=k) e f hef r fexp g χ b sfloor hR N ω + (episodeStageFails e f r fexp g χ b N) i:ℝ) ∂Q) ≤ C+Real.exp (-(K*b))* + (∫ ω, (EpisodeChainLedger.steps (k:=k) e f hef r fexp g χ b sfloor hR N ω i:ℝ) ∂Q) := by + let J := fun ω => (EpisodeChainLedger.steps (k:=k) e f hef r fexp g χ b sfloor hR N ω i:ℝ) + let F := fun ω => (EpisodeChainLedger.count (k:=k) e f hef r fexp g χ b sfloor hR N ω + (episodeStageFails e f r fexp g χ b N) i:ℝ) + let Z := fun ω => K*b*F ω-Real.exp (-(K*b))*J ω + have hm := EpisodeChainLedger.measurable_counts (k:=k) e f hef r fexp g χ b sfloor hR N i + have hcast : Measurable (fun n : ℕ => (n:ℝ)) := measurable_of_countable _ + have hJ : Measurable J := hcast.comp hm.fst + have hF : Measurable F := hcast.comp hm.snd + have hZ : Measurable Z := (hF.const_mul _).sub (hJ.const_mul _) + have hB : ∃ B : ℝ, ∀ ω, |Z ω| ≤ B := by + refine ⟨(|K*b|+Real.exp (-(K*b)))*(i*N:ℕ),fun ω => ?_⟩ + have hh := EpisodeChainLedger.counts_bounded (k:=k) e f hef r fexp g χ b sfloor hR N ω i + have hj : |J ω| ≤ (i*N:ℕ) := by + rw [abs_of_nonneg (Nat.cast_nonneg _)] + dsimp only [J] + exact_mod_cast hh.1 + have hf : |F ω| ≤ (i*N:ℕ) := by + rw [abs_of_nonneg (Nat.cast_nonneg _)] + dsimp only [F] + exact_mod_cast hh.2 + calc + |Z ω| ≤ |K*b*F ω|+|Real.exp (-(K*b))*J ω| := by + simpa only [Z,sub_eq_add_neg,abs_neg] using abs_add_le (K*b*F ω) (-(Real.exp (-(K*b))*J ω)) + _ = |K*b| *|F ω|+Real.exp (-(K*b))*|J ω| := by + simp only [abs_mul,abs_of_pos (Real.exp_pos _)] + _ ≤ |K*b| *(i*N:ℕ)+Real.exp (-(K*b))*(i*N:ℕ) := by gcongr + _ = _ := by ring + have he := Entropy.exp_integrable_of_bounded (μ:=environmentLaw ν) hZ hB + have hmgf := actual_stage_exponential ν e f hef r fexp g χ b sfloor K hR N hH hbound i + have hint : (∫ ω, Real.exp (Z ω) ∂environmentLaw ν) ≤ 1 := by + apply (ENNReal.ofReal_le_ofReal_iff (by norm_num : (0:ℝ)≤1)).mp + rw [ofReal_integral_eq_lintegral_ofReal he (ae_of_all _ fun ω => (Real.exp_pos _).le)] + simpa only [stagePotential,Z,J,F,ENNReal.ofReal_one] using hmgf + have hE := Entropy.expBudget_of_kl_le Q (environmentLaw ν) hC hkl Z hZ hB + have hi := EpisodeChainLedger.counts_integrable (k:=k) e f hef r fexp g χ b sfloor hR N Q i + have hze : (∫ ω, Z ω ∂Q) = K*b*(∫ ω, F ω ∂Q)-Real.exp (-(K*b))*(∫ ω, J ω ∂Q) := by + rw [integral_sub (hi.2.const_mul _) (hi.1.const_mul _),integral_const_mul,integral_const_mul] + rw [hze] at hE + change K*b*(∫ ω, F ω ∂Q) ≤ C+Real.exp (-(K*b))*(∫ ω, J ω ∂Q) + linarith + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory InformationTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +lemma episode_count_absorption (j z L b g f K D β : ℝ) + (hj : 0 ≤ j) (hL : 0 ≤ L) (hb : 0 < b) (hg : 0 < g) (hf : 0 ≤ f) (hK : 0 < K) + (hc : 1/g+(1+f/g)*D/K ≤ β/32) + (hs : (1+f/g)*Real.exp (-(K*b))/(K*b) ≤ 1/2) + (hlarge : 32*b ≤ β*L) + (hcount : j ≤ L/(g*b)+(1+f/g)*z+1) + (hent : K*b*z ≤ D*L+Real.exp (-(K*b))*j) : + 2*b*j ≤ β/4*L := by + have hkb : 0 < K*b := mul_pos hK hb + have hcf : 0 ≤ 1+f/g := by positivity + have hz : z ≤ (D*L+Real.exp (-(K*b))*j)/(K*b) := (le_div_iff₀ hkb).mpr (by nlinarith only [hent]) + have he : L/(g*b)+(1+f/g)*((D*L+Real.exp (-(K*b))*j)/(K*b))+1 = + (L/b)*(1/g+(1+f/g)*D/K)+((1+f/g)*Real.exp (-(K*b))/(K*b))*j+1 := by + field_simp + ring + have hh : j ≤ L/(g*b)+(1+f/g)*((D*L+Real.exp (-(K*b))*j)/(K*b))+1 := by + have hx := mul_le_mul_of_nonneg_left hz hcf + linarith only [hcount,hx] + rw [he] at hh + have ht := mul_le_mul_of_nonneg_left hc (div_nonneg hL hb.le) + have hu := mul_le_mul_of_nonneg_right hs hj + have hh' : j/2 ≤ (L/b)*(β/32)+1 := by linarith + have hv := mul_le_mul_of_nonneg_left hh' hb.le + have hEq : b*((L/b)*(β/32)+1)=β*L/32+b := by field_simp + rw [hEq] at hv + nlinarith only [hv,hlarge] + +theorem actual_expected_stages {d k : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (hef : e.1 ≠ f.1) (r : ℝ → ℝ) + (fexp g χ b sfloor K D β : ℝ) (hR : 0 ≤ r sfloor) (N : ℕ) + (hs : 1 ≤ sfloor) (hN : sfloor ≤ (N:ℝ)) + (hf : 0 ≤ fexp) (hg : 0 < g) (hb : 0 < b) (hK : 0 < K) (hD : 0 ≤ D) + (hH : ∀ s, sfloor ≤ s → s*Real.exp (g*b) ≤ (episodeStageH χ b s:ℝ)) + (hbound : ∀ s, sfloor ≤ s → ∀ a : ℝ, ∀ π : BudgetProfile (k:=k) e f a (r s), + environmentLaw ν (stageBadEvent e f (episodeStageH χ b s) + (r (s*Real.exp (-fexp*b))) (r (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) ≤ ENNReal.ofReal (Real.exp (-2*(K*b)))) + (Q : Measure (Environment d)) [IsProbabilityMeasure Q] + (hkl : klDiv Q (environmentLaw ν) ≤ ENNReal.ofReal (D*Real.log (N:ℝ))) + (hc : 1/g+(1+fexp/g)*D/K ≤ β/32) + (hsmall : (1+fexp/g)*Real.exp (-(K*b))/(K*b) ≤ 1/2) + (hlarge : 32*b ≤ β*Real.log (N:ℝ)) : + 2*b*(∫ ω, (EpisodeChainLedger.steps (k:=k) e f hef r fexp g χ b sfloor hR N ω N:ℝ) ∂Q) ≤ + β/4*Real.log (N:ℝ) := by + let J := fun ω => (EpisodeChainLedger.steps (k:=k) e f hef r fexp g χ b sfloor hR N ω N:ℝ) + let F := fun ω => (EpisodeChainLedger.count (k:=k) e f hef r fexp g χ b sfloor hR N ω + (episodeStageFails e f r fexp g χ b N) N:ℝ) + have hi := EpisodeChainLedger.counts_integrable (k:=k) e f hef r fexp g χ b sfloor hR N Q N + have hlog : 0 ≤ Real.log (N:ℝ) := Real.log_nonneg (hs.trans hN) + have hH0 : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s := by + intro s h + have hp : 0 < s := lt_of_lt_of_le (by norm_num : (0:ℝ)<1) (hs.trans h) + exact_mod_cast (mul_pos hp (Real.exp_pos _)).trans_le (hH s h) + have he := actual_stage_entropy ν e f hef r fexp g χ b sfloor K hR N hH0 hbound Q + (D*Real.log (N:ℝ)) (mul_nonneg hD hlog) hkl N + have hcount : (∫ ω, J ω ∂Q) ≤ Real.log (N:ℝ)/(g*b)+(1+fexp/g)*(∫ ω, F ω ∂Q)+1 := by + have hh := integral_mono hi.1 + (((integrable_const (Real.log (N:ℝ)/(g*b))).add (hi.2.const_mul (1+fexp/g))).add (integrable_const 1)) + (fun ω => EpisodeChainLedger.stage_count_bound (k:=k) e f hef r fexp g χ b sfloor hR N ω hs hN hf hg hb hH) + change (∫ ω, J ω ∂Q) ≤ (∫ ω, Real.log (N:ℝ)/(g*b)+(1+fexp/g)*F ω+1 ∂Q) at hh + have hfi : Integrable F Q := hi.2 + rw [integral_add (f:=fun ω => Real.log (N:ℝ)/(g*b)+(1+fexp/g)*F ω) (g:=fun _ => (1:ℝ)) + ((integrable_const _).add (hfi.const_mul _)) (integrable_const _), + integral_add (f:=fun _ => Real.log (N:ℝ)/(g*b)) (g:=fun ω => (1+fexp/g)*F ω) + (integrable_const _) (hfi.const_mul _),integral_const_mul] at hh + simpa only [integral_const,probReal_univ,one_smul] using hh + exact episode_count_absorption _ _ _ _ _ _ _ _ _ + (integral_nonneg (fun ω => Nat.cast_nonneg _)) hlog hb hg hf hK hc hsmall hlarge hcount he + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRandomStart.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRandomStart.lean new file mode 100644 index 0000000000000000000000000000000000000000..3908a827b805e361d070f0e7df34ba58afa0bc4b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRandomStart.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.StageExponentialScales +import OAI.Probability.Ballisticity.Stationary.EpisodeAdapted + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +noncomputable def randomEpisodeInitialAtlas {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) + (T : Environment d → ℕ) + (hT : ∀ t : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) t)] {ω | T ω=t}) : + EpisodeAtlas (fun ω => episodeInitial (k:=k) e f hef r sfloor hR (T ω) ω) where + Label := ℕ + countable := inferInstance + chart := fun t => { episodeInitialChart e f hef r sfloor hR t with + event := {ω | T ω=t} + measurable_event := (rowSigma_mono (by + intro x hx + change dot (realPosition x) (realPosition (step e)) < ((t+1:ℕ):ℝ) + change dot (realPosition x) (realPosition (step e)) < (t:ℝ) at hx + exact hx.trans_le (by exact_mod_cast Nat.le_add_right t 1))) _ (hT t) } + cover := fun ω => ⟨T ω,rfl⟩ + correct := by + intro t ω hω + change T ω=t at hω + change episodeInitial (k:=k) e f hef r sfloor hR (T ω) ω = episodeInitial e f hef r sfloor hR t ω + rw [hω] + +lemma randomEpisodeInitialAtlas_partition {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (sfloor : ℝ) (hR : 0 ≤ r sfloor) + (T : Environment d → ℕ) + (hT : ∀ t : ℕ, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) t)] {ω | T ω=t}) : + (randomEpisodeInitialAtlas (k:=k) e f hef r sfloor hR T hT).IsPartition := by + intro l m ω hl hm + change T ω=l at hl + change T ω=m at hm + exact hl.symm.trans hm + +noncomputable def actualEpisodeStageAtlas {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N i n : ℕ) : + EpisodeAtlas (fun ω => episodeRun e f hef r fexp g χ b sfloor N + (episodeInitial (k:=k) e f hef r sfloor hR + (episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i) ω) ω n) := + (randomEpisodeInitialAtlas (k:=k) e f hef r sfloor hR + (fun ω => episodeBoundary (k:=k) e f hef r fexp g χ b sfloor hR N ω i) + (fun t => episodeBoundary_height_event (k:=k) e f hef r fexp g χ b sfloor hR N i t)).run + hef fexp g χ b sfloor N n + +lemma actualEpisodeStageAtlas_partition {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hR : 0 ≤ r sfloor) (N i n : ℕ) : + (actualEpisodeStageAtlas (k:=k) e f hef r fexp g χ b sfloor hR N i n).IsPartition := + EpisodeAtlas.run_partition _ (randomEpisodeInitialAtlas_partition (k:=k) e f hef r sfloor hR _ _) + hef fexp g χ b sfloor N n + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal Classical Topology +namespace DirectionalTransience + +lemma stage_height_dominates_growth (g χ b s : ℝ) (hg : g < χ) (hb : 0 < b) + (hs : 1 / (Real.exp (χ*b)-Real.exp (g*b)) ≤ s) : + s*Real.exp (g*b) ≤ (episodeStageH χ b s : ℝ) := by + have hsub : 0 < Real.exp (χ*b)-Real.exp (g*b) := + sub_pos.mpr (Real.exp_lt_exp.mpr (mul_lt_mul_of_pos_right hg hb)) + have hm := (div_le_iff₀ hsub).mp hs + have hf := Nat.lt_floor_add_one (s*Real.exp (χ*b)) + change s*Real.exp (g*b) ≤ (⌊s*Real.exp (χ*b)⌋₊:ℝ) + nlinarith only [hm,hf] + +theorem operational_stage_parameters {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (D₀ : ℝ) (hD₀ : 0 ≤ D₀) : + let μ := independentConditionedPairLaw ν (realPosition (step e)) + let S := commonIncrementProcess (realPosition (step e)) f 0 + let r := fluctuationRadius μ S + ∃ fexp g χ K : ℝ, 0 < fexp ∧ 0 < g ∧ g < χ ∧ 0 < K ∧ + 1/g < (1/2:ℝ)/64 ∧ (1+fexp/g)*D₀/K < (1/2:ℝ)/64 ∧ + ∃ k : ℕ, 2 ≤ k ∧ ∀ᶠ b : ℝ in atTop, 0 < b ∧ ∃ sfloor : ℝ, 1 ≤ sfloor ∧ + (∀ s, sfloor ≤ s → 0 < episodeStageH χ b s ∧ + s*Real.exp (g*b) ≤ (episodeStageH χ b s : ℝ)) ∧ + ∀ s, sfloor ≤ s → ∀ a : ℝ, ∀ π : BudgetProfile (k:=k) e f a (r s), + environmentLaw ν (stageBadEvent e f (episodeStageH χ b s) + (r (s*Real.exp (-fexp*b))) (r (s*Real.exp (g*b))) π.val + (ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) ≤ ENNReal.ofReal (Real.exp (-2*K*b)) := by + dsimp only + obtain ⟨fexp,g,χ,K,hf,hg,hχ,hK,hgs,hKs,k,hk,hb⟩ := + separated_stages_with_gap ν hue e f hef htrans D₀ hD₀ + refine ⟨fexp,g,χ,K,hf,hg,hχ,hK,hgs,hKs,k,hk,?_⟩ + filter_upwards [hb] with b hb + obtain ⟨hb,oldfloor,hold,hbound⟩ := hb + let sfloor := max oldfloor (max 1 (1/(Real.exp (χ*b)-Real.exp (g*b)))) + have hfloor : 1 ≤ sfloor := (le_max_left _ _).trans (le_max_right _ _) + refine ⟨hb,sfloor,hfloor,?_,?_⟩ + · intro s hs + have hh := stage_height_dominates_growth g χ b s hχ hb + ((le_max_right _ _).trans ((le_max_right _ _).trans hs)) + refine ⟨?_,hh⟩ + have hs0 : 0 < s := lt_of_lt_of_le (by norm_num : (0:ℝ)<1) (hfloor.trans hs) + exact_mod_cast (mul_pos hs0 (Real.exp_pos _)).trans_le hh + · intro s hs a π + simpa only [episodeStageH,neg_mul] using hbound s ((le_max_left _ _).trans hs) a π + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRecordedAtlas.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRecordedAtlas.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bde5515f58b01e2a753ba555b5c0745aa8141aa --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRecordedAtlas.lean @@ -0,0 +1,198 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeAdapted +import OAI.Probability.Ballisticity.Stationary.LocalEpisodeLog +import OAI.Probability.Ballisticity.Estimates.StageClassification + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +structure EpisodeRecordedAtlas {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + (q : Environment d → EpisodeState (k:=k) e f r) (J F : Environment d → ℕ) + extends EpisodeAtlas q where + stages : Label → ℕ + failures : Label → ℕ + stages_correct : ∀ l ω, ω∈(chart l).event → J ω=stages l + failures_correct : ∀ l ω, ω∈(chart l).event → F ω=failures l + +namespace EpisodeRecordedAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} {J F : Environment d → ℕ} + +noncomputable def zero (A : EpisodeAtlas q) : EpisodeRecordedAtlas q (fun _ => 0) (fun _ => 0) where + toEpisodeAtlas := A + stages := fun _ => 0 + failures := fun _ => 0 + stages_correct := fun _ _ _ => rfl + failures_correct := fun _ _ _ => rfl + +noncomputable def advance (A : EpisodeRecordedAtlas q J F) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) : + EpisodeRecordedAtlas + (fun ω => if EpisodeReady e f r sfloor N (q ω) then episodeStageNext e f hef r fexp g χ b N (q ω) ω else q ω) + (fun ω => J ω+if EpisodeReady e f r sfloor N (q ω) then 1 else 0) + (fun ω => F ω+if EpisodeReady e f r sfloor N (q ω) ∧ episodeStageFails e f r fexp g χ b N (q ω) ω then 1 else 0) := by + have := A.countable + refine { Label := A.Label×Option (ℕ×Bool×Bool) + countable := inferInstance + chart := fun l => (A.chart l.1).countedBranch hef fexp g χ b sfloor N l.2 + cover := ?_ + correct := ?_ + stages := fun l => A.stages l.1+if l.2.isSome then 1 else 0 + failures := fun l => A.failures l.1+if (l.2.map (fun z => z.2.2)).getD false then 1 else 0 + stages_correct := ?_ + failures_correct := ?_ } + · intro ω + obtain ⟨l,hl⟩ := A.cover ω + obtain ⟨j,hj⟩ := (A.chart l).countedBranch_covers hef fexp g χ b sfloor N ω hl + exact ⟨(l,j),hj⟩ + · intro l ω hω + obtain ⟨hl,hnext⟩ := (A.chart l.1).countedBranch_state hef fexp g χ b sfloor N ω l.2 hω + rw [A.correct l.1 ω hl] + exact hnext.symm + · intro l ω hω + have hl := ((A.chart l.1).countedBranch_state hef fexp g χ b sfloor N ω l.2 hω).1 + rw [A.stages_correct l.1 ω hl,A.correct l.1 ω hl] + exact congrArg (A.stages l.1+ ·) (((A.chart l.1).countedBranch_record hef fexp g χ b sfloor N ω l.2 hω).1) + · intro l ω hω + have hl := ((A.chart l.1).countedBranch_state hef fexp g χ b sfloor N ω l.2 hω).1 + rw [A.failures_correct l.1 ω hl,A.correct l.1 ω hl] + exact congrArg (A.failures l.1+ ·) (((A.chart l.1).countedBranch_record hef fexp g χ b sfloor N ω l.2 hω).2) + +lemma advance_partition (A : EpisodeRecordedAtlas q J F) (hA : A.toEpisodeAtlas.IsPartition) + (hef : e.1 ≠ f.1) (fexp g χ b sfloor : ℝ) (N : ℕ) : + (A.advance hef fexp g χ b sfloor N).toEpisodeAtlas.IsPartition := by + rintro ⟨l,j⟩ ⟨m,h⟩ ω hl hm + have hl₀ := ((A.chart l).countedBranch_state hef fexp g χ b sfloor N ω j hl).1 + have hm₀ := ((A.chart m).countedBranch_state hef fexp g χ b sfloor N ω h hm).1 + have he := hA l m ω hl₀ hm₀ + subst m + exact Prod.ext rfl ((A.chart l).countedBranch_unique hef fexp g χ b sfloor N ω j h hl hm) + +lemma count_event (A : EpisodeRecordedAtlas q J F) (m j h : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) m)] + {ω | (q ω).height=m ∧ J ω=j ∧ F ω=h} := by + have := A.countable + have he : {ω | (q ω).height=m ∧ J ω=j ∧ F ω=h} = + ⋃ l : {l : A.Label // (A.chart l).height=m ∧ A.stages l=j ∧ A.failures l=h}, (A.chart l.val).event := by + ext ω + constructor + · rintro ⟨hm,hj,hf⟩ + obtain ⟨l,hl⟩ := A.cover ω + refine Set.mem_iUnion.mpr ⟨⟨l,?_,?_,?_⟩,hl⟩ + · rw [A.correct l ω hl] at hm + exact hm + · exact (A.stages_correct l ω hl).symm.trans hj + · exact (A.failures_correct l ω hl).symm.trans hf + · intro hh + obtain ⟨l,hl⟩ := Set.mem_iUnion.mp hh + change (q ω).height=m ∧ J ω=j ∧ F ω=h + rw [A.correct l ω hl,A.stages_correct l ω hl,A.failures_correct l ω hl] + exact l.property + rw [he] + apply MeasurableSet.iUnion + intro l + have hm := (A.chart l.val).measurable_event + rwa [l.property.1] at hm + +noncomputable def run (A : EpisodeAtlas q) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N n : ℕ) : + EpisodeRecordedAtlas + (fun ω => episodeRun e f hef r fexp g χ b sfloor N (q ω) ω n) + (fun ω => episodeSteps e f hef r fexp g χ b sfloor N (q ω) ω n) + (fun ω => episodeCount e f hef r fexp g χ b sfloor N (q ω) ω + (episodeStageFails e f r fexp g χ b N) n) := by + induction n with + | zero => exact zero A + | succ n ih => exact ih.advance hef fexp g χ b sfloor N + +lemma run_partition (A : EpisodeAtlas q) (hA : A.IsPartition) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N n : ℕ) : + (run A hef fexp g χ b sfloor N n).toEpisodeAtlas.IsPartition := by + induction n with + | zero => exact hA + | succ n ih => exact advance_partition _ ih hef fexp g χ b sfloor N + +end EpisodeRecordedAtlas +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeRecordedAtlas +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + {q : Environment d → EpisodeState (k:=k) e f r} {J F : Environment d → ℕ} + +noncomputable def reinject (A : EpisodeRecordedAtlas q J F) (hef : e.1 ≠ f.1) + (sfloor : ℝ) (hR : 0 ≤ r sfloor) : + EpisodeRecordedAtlas (fun ω => episodeInitial (k:=k) e f hef r sfloor hR (q ω).height ω) J F where + Label := A.Label + countable := A.countable + chart := fun l => { episodeInitialChart e f hef r sfloor hR (A.chart l).height with + event := (A.chart l).event + measurable_event := (rowSigma_mono (by + intro x hx + change dot (realPosition x) (realPosition (step e)) < (((A.chart l).height+1:ℕ):ℝ) + change dot (realPosition x) (realPosition (step e)) < ((A.chart l).height:ℝ) at hx + exact hx.trans_le (by exact_mod_cast Nat.le_add_right (A.chart l).height 1))) _ (A.chart l).measurable_event } + cover := A.cover + correct := by + intro l ω hω + change episodeInitial e f hef r sfloor hR (q ω).height ω = + episodeInitial e f hef r sfloor hR (A.chart l).height ω + rw [A.correct l ω hω] + rfl + stages := A.stages + failures := A.failures + stages_correct := A.stages_correct + failures_correct := A.failures_correct + +lemma reinject_partition (A : EpisodeRecordedAtlas q J F) (hA : A.toEpisodeAtlas.IsPartition) + (hef : e.1 ≠ f.1) (sfloor : ℝ) (hR : 0 ≤ r sfloor) : + (A.reinject hef sfloor hR).toEpisodeAtlas.IsPartition := hA + +noncomputable def runFrom (A : EpisodeRecordedAtlas q J F) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N n : ℕ) : + EpisodeRecordedAtlas + (fun ω => episodeRun e f hef r fexp g χ b sfloor N (q ω) ω n) + (fun ω => J ω+episodeSteps e f hef r fexp g χ b sfloor N (q ω) ω n) + (fun ω => F ω+episodeCount e f hef r fexp g χ b sfloor N (q ω) ω + (episodeStageFails e f r fexp g χ b N) n) := by + induction n with + | zero => exact A + | succ n ih => + let B := ih.advance hef fexp g χ b sfloor N + refine { toEpisodeAtlas := B.toEpisodeAtlas + stages := B.stages + failures := B.failures + stages_correct := ?_ + failures_correct := ?_ } + · intro l ω hω + rw [episodeSteps,←Nat.add_assoc] + exact B.stages_correct l ω hω + · intro l ω hω + rw [episodeCount,←Nat.add_assoc] + exact B.failures_correct l ω hω + +lemma runFrom_partition (A : EpisodeRecordedAtlas q J F) (hA : A.toEpisodeAtlas.IsPartition) + (hef : e.1 ≠ f.1) (fexp g χ b sfloor : ℝ) (N n : ℕ) : + (A.runFrom hef fexp g χ b sfloor N n).toEpisodeAtlas.IsPartition := by + induction n with + | zero => exact hA + | succ n ih => + exact advance_partition _ ih hef fexp g χ b sfloor N + +end EpisodeRecordedAtlas +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRetention.lean b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a700344225e08bf7027bc0caa0886ec2fe715ac --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/EpisodeRetention.lean @@ -0,0 +1,209 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.OperationalEpisode + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +lemma episodeStageNext_retained {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (hr : Monotone r) (fexp g χ b sfloor : ℝ) (N : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hq : EpisodeReady e f r sfloor N q) + (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).val e) : + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b)))) • + (episodeStageNext e f hef r fexp g χ b N q ω).profile.val ≤ + rawTupleMixture (realPosition (step e)) (episodeStageLength e f r fexp g χ b N q ω) + q.profile.val ω := by + have hs : 0 ≤ q.scale := hsfloor.le.trans hq.2 + have he : Real.exp (-fexp*b) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith) + have hg : r (q.scale*Real.exp (-fexp*b)) ≤ r q.scale := + hr (by simpa only [mul_one] using mul_le_mul_of_nonneg_left he hs) + have hp : ∀ᵐ x ∂q.profile.val,TupleSeparated f (r (q.scale*Real.exp (-fexp*b))) x := + q.profile.property.2.mono fun x hx => tupleSeparated_mono f hg x hx.2 + have hm := stageRetainedMass_lower e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) (hH _ hq.2) (Nat.sub_pos_of_lt hq.1) + (mul_nonneg (Nat.cast_nonneg _) hb) ω hp κ hκ + have ho := stageOutput_retained_le e f hef q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω + have hi : ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b)))) • + (episodeStageNext e f hef r fexp g χ b N q ω).profile.val ≤ + stageRetainedMass e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω • + (episodeStageNext e f hef r fexp g χ b N q ω).profile.val := by + intro U + simpa only [Measure.smul_apply,smul_eq_mul,mul_comm] using + mul_le_mul_right hm ((episodeStageNext e f hef r fexp g χ b N q ω).profile.val U) + exact hi.trans ho + +noncomputable def episodeSteps {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) : ℕ → ℕ + | 0 => 0 + | n+1 => episodeSteps e f hef r fexp g χ b sfloor N q ω n + + if EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) then 1 else 0 + +lemma episodeRun_height_mono {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) (n : ℕ) : + q.height ≤ (episodeRun e f hef r fexp g χ b sfloor N q ω n).height := by + induction n with + | zero => exact le_rfl + | succ n ih => + rw [episodeRun] + split + · rw [episodeStageNext_height] + exact ih.trans (Nat.le_add_right _ _) + · exact ih + +def episodeMeasure {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + (q : EpisodeState (k:=k) e f r) : Measure (Fin k → Lattice d) := q.profile.val + +theorem episodeRun_retained {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (hr : Monotone r) (fexp g χ b sfloor : ℝ) (N : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).val e) (n : ℕ) : + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeSteps e f hef r fexp g χ b sfloor N q ω n) • + (episodeRun e f hef r fexp g χ b sfloor N q ω n).profile.val ≤ + rawTupleMixture (realPosition (step e)) + ((episodeRun e f hef r fexp g χ b sfloor N q ω n).height-q.height) + q.profile.val ω := by + change ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeSteps e f hef r fexp g χ b sfloor N q ω n) • + episodeMeasure (episodeRun e f hef r fexp g χ b sfloor N q ω n) ≤ _ + induction n with + | zero => simp only [episodeMeasure,episodeSteps,episodeRun,pow_zero,one_smul,Nat.sub_self,rawTupleMixture_zero,le_refl] + | succ n ih => + rw [episodeSteps,episodeRun] + by_cases hp : EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) + · rw [ite_eq_left hp,ite_eq_left hp,pow_succ,mul_smul] + have ht := episodeRun_height_mono e f hef r fexp g χ b sfloor N q ω n + have hs := smul_le_smul_left + (((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeSteps e f hef r fexp g χ b sfloor N q ω n)) + (episodeStageNext_retained e f hef r hr fexp g χ b sfloor N hf hb hsfloor _ ω hH hp κ hκ) + rw [←rawTupleMixture_smul] at hs + have hm := rawTupleMixture_mono (realPosition (step e)) + (episodeStageLength e f r fexp g χ b N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω) ω ih + have hc := rawTupleMixture_comp_le e + ((episodeRun e f hef r fexp g χ b sfloor N q ω n).height-q.height) + (episodeStageLength e f r fexp g χ b N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω) + q.profile.val ω + have he : (episodeStageNext e f hef r fexp g χ b N + (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω).height-q.height = + (episodeRun e f hef r fexp g χ b sfloor N q ω n).height-q.height + + episodeStageLength e f r fexp g χ b N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω := by + rw [episodeStageNext_height] + omega + convert hs.trans (hm.trans hc) using 1 + · rfl + · exact congrArg (fun h => rawTupleMixture (realPosition (step e)) h q.profile.val ω) he + · simp only [ite_eq_right hp,add_zero] + exact ih + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +def StageRadiusOrder (r : ℝ → ℝ) (f b sfloor : ℝ) : Prop := + ∀ s, sfloor ≤ s → r (s*Real.exp (-f*b)) ≤ r s + +lemma episodeStageNext_retained_local {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hr : StageRadiusOrder r fexp b sfloor) (N : ℕ) + (_ : 0 ≤ fexp) (hb : 0 ≤ b) (_ : 0 < sfloor) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hq : EpisodeReady e f r sfloor N q) + (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).val e) : + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b)))) • + (episodeStageNext e f hef r fexp g χ b N q ω).profile.val ≤ + rawTupleMixture (realPosition (step e)) (episodeStageLength e f r fexp g χ b N q ω) + q.profile.val ω := by + have hg : r (q.scale*Real.exp (-fexp*b)) ≤ r q.scale := hr q.scale hq.2 + have hp : ∀ᵐ x ∂q.profile.val,TupleSeparated f (r (q.scale*Real.exp (-fexp*b))) x := + q.profile.property.2.mono fun x hx => tupleSeparated_mono f hg x hx.2 + have hm := stageRetainedMass_lower e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) (hH _ hq.2) (Nat.sub_pos_of_lt hq.1) + (mul_nonneg (Nat.cast_nonneg _) hb) ω hp κ hκ + have ho := stageOutput_retained_le e f hef q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω + have hi : ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b)))) • + (episodeStageNext e f hef r fexp g χ b N q ω).profile.val ≤ + stageRetainedMass e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω • + (episodeStageNext e f hef r fexp g χ b N q ω).profile.val := by + intro U + simpa only [Measure.smul_apply,smul_eq_mul,mul_comm] using + mul_le_mul_right hm ((episodeStageNext e f hef r fexp g χ b N q ω).profile.val U) + exact hi.trans ho + +theorem episodeRun_retained_local {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hr : StageRadiusOrder r fexp b sfloor) (N : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ : ∀ y, κ ≤ (ω y).val e) (n : ℕ) : + ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeSteps e f hef r fexp g χ b sfloor N q ω n) • + (episodeRun e f hef r fexp g χ b sfloor N q ω n).profile.val ≤ + rawTupleMixture (realPosition (step e)) + ((episodeRun e f hef r fexp g χ b sfloor N q ω n).height-q.height) + q.profile.val ω := by + change ((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeSteps e f hef r fexp g χ b sfloor N q ω n) • + episodeMeasure (episodeRun e f hef r fexp g χ b sfloor N q ω n) ≤ _ + induction n with + | zero => simp only [episodeMeasure,episodeSteps,episodeRun,pow_zero,one_smul,Nat.sub_self,rawTupleMixture_zero,le_refl] + | succ n ih => + rw [episodeSteps,episodeRun] + by_cases hp : EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) + · rw [ite_eq_left hp,ite_eq_left hp,pow_succ,mul_smul] + have ht := episodeRun_height_mono e f hef r fexp g χ b sfloor N q ω n + have hs := smul_le_smul_left + (((κ:ℝ≥0∞)^k * ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))^ + (episodeSteps e f hef r fexp g χ b sfloor N q ω n)) + (episodeStageNext_retained_local e f hef r fexp g χ b sfloor hr N hf hb hsfloor _ ω hH hp κ hκ) + rw [←rawTupleMixture_smul] at hs + have hm := rawTupleMixture_mono (realPosition (step e)) + (episodeStageLength e f r fexp g χ b N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω) ω ih + have hc := rawTupleMixture_comp_le e + ((episodeRun e f hef r fexp g χ b sfloor N q ω n).height-q.height) + (episodeStageLength e f r fexp g χ b N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω) + q.profile.val ω + have he : (episodeStageNext e f hef r fexp g χ b N + (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω).height-q.height = + (episodeRun e f hef r fexp g χ b sfloor N q ω n).height-q.height + + episodeStageLength e f r fexp g χ b N (episodeRun e f hef r fexp g χ b sfloor N q ω n) ω := by + rw [episodeStageNext_height] + omega + convert hs.trans (hm.trans hc) using 1 + · rfl + · exact congrArg (fun h => rawTupleMixture (realPosition (step e)) h q.profile.val ω) he + · simp only [ite_eq_right hp,add_zero] + exact ih + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/LocalEpisodeLog.lean b/lean/OAI/Probability/Ballisticity/Stationary/LocalEpisodeLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf209326507929cbe50fd90162b4272e73b9d1b8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/LocalEpisodeLog.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.EpisodeCharts +import OAI.Probability.Ballisticity.Stationary.EpisodeAdapted +import OAI.Probability.Ballisticity.Estimates.StageClassification +import OAI.Probability.Ballisticity.Stationary.EpisodeGlobalRetention + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience +theorem episode_log_bound_local {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (hr : StageRadiusOrder r fexp b sfloor) (hR : 0 ≤ r sfloor) (N t : ℕ) + (hf : 0 ≤ fexp) (hb : 0 ≤ b) (hsfloor : 0 < sfloor) + (ω : Environment d) (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (κ : ℝ≥0) (hκ0 : 0 < κ) (hκ1 : κ ≤ 1) (hκ : ∀ y u, κ ≤ (ω y).1 u) + (hk : 0 < k) (hbκ : -Real.log κ ≤ b) : + 0 ≤ Real.log (crossingQuenched (realPosition (step e)) 0 t ω).toReal - + Real.log (crossingQuenched (realPosition (step e)) 0 + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω).toReal ∧ + Real.log (crossingQuenched (realPosition (step e)) 0 t ω).toReal - + Real.log (crossingQuenched (realPosition (step e)) 0 + (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height ω).toReal ≤ + (BoundedInjection.injectionMultiplier (r sfloor)*k+1:ℕ)*(-Real.log κ)+ + 2*b*(episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω) := by + let T := (episodeFinal (k:=k) e f hef r fexp g χ b sfloor hR N t ω).height + have hpos (h : ℕ) : crossingQuenched (realPosition (step e)) 0 h ω ≠ 0 := + ne_of_gt ((ENNReal.pow_pos (ENNReal.coe_pos.mpr hκ0) h).trans_le + (coordinate_survival_lower e ω κ (fun y => hκ y e) h)) + have hfinite (h : ℕ) := crossingQuenched_ne_top (realPosition (step e)) 0 h ω + have hl := episode_log_algebra (hfinite t) (hfinite T) (hpos t) (hpos T) κ hκ0 b k + (BoundedInjection.injectionMultiplier (r sfloor)*k+1) + (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω) hk + (episode_survival_lower_local e f hef r fexp g χ b sfloor hr hR N t hf hb hsfloor ω hH κ hκ1 hκ) + constructor + · have hm := crossingQuenched_antitone (realPosition (step e)) 0 ω + (a:= (t:ℝ)) (b:= (T:ℝ)) (by exact_mod_cast (episodeFinal_gt (k:=k) e f hef r fexp g χ b sfloor hR N t ω).le) + exact sub_nonneg.mpr (Real.log_le_log (ENNReal.toReal_pos (hpos T) (hfinite T)) + (ENNReal.toReal_mono (hfinite t) hm)) + · have hj : 0 ≤ (episodeStageCount (k:=k) e f hef r fexp g χ b sfloor hR N t ω : ℝ) := by positivity + dsimp only [T] at hl + push_cast at hl ⊢ + nlinarith + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience +namespace EpisodeChart +variable {d k : ℕ} {e f : Direction d} {r : ℝ → ℝ} + +noncomputable def failsAt (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (j : ℕ) (ω : Environment d) : Prop := + stageTestMass e f c.height (r (c.scale*Real.exp (-fexp*b))) (r (c.scale*Real.exp (g*b))) + c.layerProfile (episodeStageH χ b c.scale) j ω < ENNReal.ofReal (Real.exp (-((k:ℝ)*b))) + +lemma measurableSet_failsAt (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (j : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) ((c.height+j:ℕ):ℝ))] + {ω | c.failsAt fexp g χ b j ω} := by + have hm := measurableSet_lt + (stageTestMass_adapted e f c.height (r (c.scale*Real.exp (-fexp*b))) + (r (c.scale*Real.exp (g*b))) c.layerProfile c.measurable_layerProfile + (episodeStageH χ b c.scale) j) + (measurable_const (a:=ENNReal.ofReal (Real.exp (-((k:ℝ)*b))))) + convert hm using 1 <;> first | rfl | (rw [Nat.cast_add]; rfl) + +lemma failsAt_eq (c : EpisodeChart (k:=k) e f r) (fexp g χ b : ℝ) (N : ℕ) (ω : Environment d) : + c.failsAt fexp g χ b (c.stop fexp g χ b N ω) ω ↔ + episodeStageFails e f r fexp g χ b N (c.state ω) ω := Iff.rfl + +noncomputable def countedNext (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N j : ℕ) (grow failed : Bool) : EpisodeChart (k:=k) e f r := + { c.next hef fexp g χ b sfloor N j grow with + event := (c.next hef fexp g χ b sfloor N j grow).event ∩ + {ω | c.failsAt fexp g χ b j ω ↔ failed=true} + measurable_event := (c.measurable_nextEvent fexp g χ b sfloor N j grow).inter (by + cases failed + · simpa only [Bool.false_eq_true,iff_false,Set.compl_ofPred] using (c.measurableSet_failsAt fexp g χ b j).compl + · simpa only [iff_true] using c.measurableSet_failsAt fexp g χ b j) } + +noncomputable def countedBranch (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) : Option (ℕ×Bool×Bool) → EpisodeChart (k:=k) e f r + | none => c.frozen sfloor N + | some (j,grow,failed) => c.countedNext hef fexp g χ b sfloor N j grow failed + +lemma countedBranch_covers (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) (ω : Environment d) (hω : ω∈c.event) : + ∃ l, ω∈(c.countedBranch hef fexp g χ b sfloor N l).event := by + obtain ⟨l,hl⟩ := c.branch_covers hef fexp g χ b sfloor N ω hω + cases l with + | none => exact ⟨none,hl⟩ + | some l => + by_cases hf : c.failsAt fexp g χ b l.1 ω + · exact ⟨some (l.1,l.2,true),hl,by simpa only [Set.mem_ofPred_eq,iff_true] using hf⟩ + · exact ⟨some (l.1,l.2,false),hl,by simpa only [Set.mem_ofPred_eq,Bool.false_eq_true,iff_false] using hf⟩ + +lemma countedBranch_state (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) (ω : Environment d) (l : Option (ℕ×Bool×Bool)) + (hω : ω∈(c.countedBranch hef fexp g χ b sfloor N l).event) : + ω∈c.event ∧ (c.countedBranch hef fexp g χ b sfloor N l).state ω = + if EpisodeReady e f r sfloor N (c.state ω) + then episodeStageNext e f hef r fexp g χ b N (c.state ω) ω else c.state ω := by + cases l with + | none => exact c.branch_state hef fexp g χ b sfloor N ω none hω + | some l => exact c.branch_state hef fexp g χ b sfloor N ω (some (l.1,l.2.1)) hω.1 + +lemma countedBranch_record (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) (ω : Environment d) (l : Option (ℕ×Bool×Bool)) + (hω : ω∈(c.countedBranch hef fexp g χ b sfloor N l).event) : + (if EpisodeReady e f r sfloor N (c.state ω) then 1 else 0 : ℕ) = (if l.isSome then 1 else 0) ∧ + (if EpisodeReady e f r sfloor N (c.state ω) ∧ episodeStageFails e f r fexp g χ b N (c.state ω) ω + then 1 else 0 : ℕ) = (if (l.map (fun z => z.2.2)).getD false then 1 else 0) := by + cases l with + | none => + have hn : ¬EpisodeReady e f r sfloor N (c.state ω) := hω.2 + simp only [hn,false_and,ite_false,Option.isSome_none,Option.map_none,Option.getD_none,Bool.false_eq_true,and_self] + | some l => + have hr : EpisodeReady e f r sfloor N (c.state ω) := ⟨hω.1.2.1,hω.1.2.2.1⟩ + have hfail : episodeStageFails e f r fexp g χ b N (c.state ω) ω ↔ l.2.2=true := by + rw [←c.failsAt_eq fexp g χ b N ω,hω.1.2.2.2.1] + exact hω.2 + simp only [hr,true_and,ite_true,Option.isSome_some,Option.map_some,Option.getD_some,hfail] + +lemma countedBranch_unique (c : EpisodeChart (k:=k) e f r) (hef : e.1 ≠ f.1) + (fexp g χ b sfloor : ℝ) (N : ℕ) (ω : Environment d) (l m : Option (ℕ×Bool×Bool)) + (hl : ω∈(c.countedBranch hef fexp g χ b sfloor N l).event) + (hm : ω∈(c.countedBranch hef fexp g χ b sfloor N m).event) : l=m := by + cases l with + | none => + cases m with + | none => rfl + | some m => exact False.elim (hl.2 ⟨hm.1.2.1,hm.1.2.2.1⟩) + | some l => + cases m with + | none => exact False.elim (hm.2 ⟨hl.1.2.1,hl.1.2.2.1⟩) + | some m => + have hp := c.branch_unique hef fexp g χ b sfloor N ω (some (l.1,l.2.1)) (some (m.1,m.2.1)) hl.1 hm.1 + have hj : l.1=m.1 := congrArg (fun z : ℕ×Bool => z.1) (Option.some.inj hp) + have hg : l.2.1=m.2.1 := congrArg (fun z : ℕ×Bool => z.2) (Option.some.inj hp) + have hh := hl.2 + rw [hj] at hh + have hb : (l.2.2=true) ↔ (m.2.2=true) := hh.symm.trans hm.2 + have hf : l.2.2=m.2.2 := by + cases h₁ : l.2.2 <;> cases h₂ : m.2.2 <;> simp_all only [Bool.false_eq_true,iff_false, + iff_true,not_true_eq_false,iff_self] + exact congrArg some (Prod.ext hj (Prod.ext hg hf)) + +end EpisodeChart +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/OperationalEpisode.lean b/lean/OAI/Probability/Ballisticity/Stationary/OperationalEpisode.lean new file mode 100644 index 0000000000000000000000000000000000000000..04bb2e6fb1da2bd60102aa4a365634ce0893a8c8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/OperationalEpisode.lean @@ -0,0 +1,146 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.StageRetention + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical +namespace DirectionalTransience + +structure EpisodeState {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) where + height : ℕ + scale : ℝ + profile : BudgetProfile (k:=k) e f height (r scale) + +noncomputable def episodeStageH (χ b s : ℝ) : ℕ := ⌊s*Real.exp (χ*b)⌋₊ + +noncomputable def episodeStageLength {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) : ℕ := + stageStop e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω + +def EpisodeReady {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (sfloor : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) : Prop := + q.height q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (episodeStageLength e f r fexp g χ b N q ω) ω + +noncomputable def episodeStageScale {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) : ℝ := + if episodeStageGrows e f r fexp g χ b N q ω + then q.scale*Real.exp (g*b) else q.scale*Real.exp (-fexp*b) + +lemma episodeStageGap {d k : ℕ} (e f : Direction d) (r : ℝ → ℝ) + (fexp g χ b : ℝ) (N : ℕ) (q : EpisodeState (k:=k) e f r) (ω : Environment d) : + stageRetainedGap e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω= + r (episodeStageScale e f r fexp g χ b N q ω) := by + unfold stageRetainedGap episodeStageScale episodeStageGrows episodeStageLength + dsimp only + simp only [neg_mul] + split <;> rfl + +noncomputable def episodeStageNext {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) : EpisodeState (k:=k) e f r := by + let out := stageOutput e f hef q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω + refine ⟨q.height+episodeStageLength e f r fexp g χ b N q ω, + episodeStageScale e f r fexp g χ b N q ω, out.val, out.property.1, ?_⟩ + filter_upwards [out.property.2] with x hx + constructor + · simpa only [Nat.cast_add,episodeStageLength] using hx.1 + · have hh := hx.2 + rwa [episodeStageGap] at hh + +lemma episodeStageNext_height {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) : + (episodeStageNext e f hef r fexp g χ b N q ω).height= + q.height+episodeStageLength e f r fexp g χ b N q ω := rfl + +lemma episodeStageNext_le {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) (hq : q.height ≤ N) : + (episodeStageNext e f hef r fexp g χ b N q ω).height ≤ N := by + have hs := stageStop_le e f q.height (r (q.scale*Real.exp (-fexp*b))) + (r (q.scale*Real.exp (g*b))) ((k:ℝ)*b) (fun _ => q.profile.toLayerProfile) + (episodeStageH χ b q.scale) (N-q.height) ω + change episodeStageLength e f r fexp g χ b N q ω ≤ _ at hs + rw [episodeStageNext_height] + omega + +lemma episodeStageNext_gt {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) + (hq : EpisodeReady e f r sfloor N q) : + q.height<(episodeStageNext e f hef r fexp g χ b N q ω).height := by + rw [episodeStageNext_height] + exact Nat.lt_add_of_pos_right (stageStop_pos e f q.height _ _ _ _ _ _ + (hH q.scale hq.2) (Nat.sub_pos_of_lt hq.1) ω) + +noncomputable def episodeRun {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) : ℕ → EpisodeState (k:=k) e f r + | 0 => q + | n+1 => let p := episodeRun e f hef r fexp g χ b sfloor N q ω n + if EpisodeReady e f r sfloor N p then episodeStageNext e f hef r fexp g χ b N p ω else p + +lemma episodeRun_le {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) (hq : q.height ≤ N) (n : ℕ) : + (episodeRun e f hef r fexp g χ b sfloor N q ω n).height ≤ N := by + induction n with + | zero => exact hq + | succ n ih => + rw [episodeRun] + split + · exact episodeStageNext_le e f hef r fexp g χ b N _ ω ih + · exact ih + +lemma episodeRun_progress {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) (n : ℕ) + (hready : EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n)) : + q.height+n ≤ (episodeRun e f hef r fexp g χ b sfloor N q ω n).height := by + induction n with + | zero => exact le_rfl + | succ n ih => + simp only [episodeRun] at hready ⊢ + by_cases hp : EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω n) + · rw [ite_eq_left hp] at hready ⊢ + have ht := episodeStageNext_gt e f hef r fexp g χ b sfloor N _ ω hH hp + have hi := ih hp + omega + · rw [ite_eq_right hp] at hready + exact False.elim (hp hready) + +theorem episodeRun_terminates {d k : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (r : ℝ → ℝ) (fexp g χ b sfloor : ℝ) (N : ℕ) + (q : EpisodeState (k:=k) e f r) (ω : Environment d) (hq : q.height ≤ N) + (hH : ∀ s, sfloor ≤ s → 0 < episodeStageH χ b s) : + ¬EpisodeReady e f r sfloor N (episodeRun e f hef r fexp g χ b sfloor N q ω N) := by + intro hr + have hp := episodeRun_progress e f hef r fexp g χ b sfloor N q ω hH N hr + have hu := episodeRun_le e f hef r fexp g χ b sfloor N q ω hq N + have hn := hr.1 + omega + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryArrayLaw.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryArrayLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fb091729dbd01e02a85ee837bdf2b5b9a99259a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryArrayLaw.lean @@ -0,0 +1,86 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayProfileConsistency +import OAI.Probability.Ballisticity.Estimates.SurvivalLimit +import OAI.Probability.Ballisticity.Walk.ArrayCostGrowth +import OAI.Probability.Ballisticity.Estimates.AllIndexMarks +import OAI.Probability.Ballisticity.Stationary.BadFiniteArray +import OAI.Probability.Ballisticity.Stationary.BadArrayElliptic + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +structure StationaryArrayLaw {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] (e : Direction d) where + law : ProbabilityMeasure (ActualEpisodeArray e) + preserving : MeasurePreserving StationaryCompact.shift (law : Measure (ActualEpisodeArray e)) (law : Measure (ActualEpisodeArray e)) + symmetric : ∀ σ, MeasurePreserving (arrayPerm e σ) (law : Measure (ActualEpisodeArray e)) (law : Measure (ActualEpisodeArray e)) + consistent : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ArrayOffsetsConsistent e Y ∧ ArrayProfilesConsistent e Y + sampling : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ∀ p j z, + Tendsto (fun n => arraySamplingError e p j z (2^n) Y) atTop (𝓝 0) + zero_sampling : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ∀ p q z, p≠q → + arrayProfileTest e q.1 p z Y=0 → arrayOffsetTest e p q z Y=0 + finite_marks : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ∀ i, + 0<(Y.1 i).1 ∧ (Y.1 i).1<⊤ ∧ (Y.1 i).2.1<⊤ ∧ (Y.1 i).2.2<⊤ + integrable_cost : Integrable (arrayRealCost e) (law : Measure (ActualEpisodeArray e)) + positive_cost : 0<∫ Y, arrayRealCost e Y ∂(law : Measure (ActualEpisodeArray e)) + integrable_logheight : Integrable (fun Y => Real.log (1+((Y.1 0).1.toNat:ℝ))) (law : Measure (ActualEpisodeArray e)) + continuation : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ArrayContinuation e Y + survival : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ArrayAveragedSurvival e Y + κ : ℝ≥0 + κ_pos : 0<κ + elliptic : ∀ᵐ Y ∂(law : Measure (ActualEpisodeArray e)), ArrayElliptic e κ Y + entropyConstant : ℝ + entropy : ∀ i m, let W:=(law : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e i m) + klDiv W (W.fst.compProd (currentWindowReference e ν))≤ENNReal.ofReal ((m:ℝ)*entropyConstant) + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} +lemma entropy_finite (L : StationaryArrayLaw ν e) (i : ℤ) (m : ℕ) : + let W:=(L.law : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e i m) + klDiv W (W.fst.compProd (currentWindowReference e ν))≠⊤ := + ne_top_of_le_ne_top ENNReal.ofReal_ne_top (L.entropy i m) +end StationaryArrayLaw + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e f : Direction d} {D : ℝ} + +theorem bad_stationary_array_law (C : OperationalConstants ν e f D) (hef : e.1≠f.1) + (hD : 0≤D) (Ns : ℕ → ℕ) (hNs : Tendsto Ns atTop atTop) + (hN : ∀ n, C.sfloor≤(Ns n:ℝ)) (hlarge : ∀ n, 32*C.b≤(1/2:ℝ)*Real.log (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D)≤(environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) : + Nonempty (StationaryArrayLaw ν e) := by + obtain ⟨ρ,φ,hφ,hlim,hstat,hsample,hzero,hmarks,hJ,hh,hc,hcp⟩ := C.bad_array_finite_marks hef hD Ns hNs hN hlarge hmass + let Ns' := fun n => Ns (φ n) + have hN' := fun n => hN (φ n) + have hlarge' := fun n => hlarge (φ n) + have hmass' := fun n => hmass (φ n) + exact ⟨{ + law := ρ + preserving := hstat + symmetric := C.bad_limit_perm hef Ns' hN' hmass' ρ hlim + consistent := C.bad_limit_consistent hef Ns' hN' hmass' ρ hlim + sampling := hsample + zero_sampling := hzero + finite_marks := stationary_finite_marks_all e _ hstat hmarks + integrable_cost := hc + positive_cost := C.hb.trans_le hcp + integrable_logheight := hh + continuation := C.bad_limit_continuation hef Ns' hN' hmass' ρ hlim + survival := C.bad_limit_averaged_survival hef Ns' hN' hmass' ρ hlim + κ := C.κ + κ_pos := C.hκ0 + elliptic := C.bad_limit_elliptic hef Ns' hN' hmass' ρ hlim + entropyConstant := C.windowEntropyConstant + entropy := C.stationary_window_entropy hef hD Ns' hN' hlarge' hmass' ρ hlim hstat + }⟩ + +end OperationalConstants +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryCompact.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryCompact.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c2d194b00440a5ffaad573f393415d62a841115 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryCompact.lean @@ -0,0 +1,243 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace BoundedContinuousFunction +open scoped Topology +namespace DirectionalTransience.StationaryCompact + +variable {Ω : Type*} [TopologicalSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω] + [CompactSpace Ω] [T2Space Ω] [MetrizableSpace Ω] [SecondCountableTopology Ω] + +omit [CompactSpace Ω] [T2Space Ω] [SecondCountableTopology Ω] in +theorem invariant_of_weak_limit (T : Ω → Ω) (hT : Continuous T) + (μs : ℕ → ProbabilityMeasure Ω) (μ : ProbabilityMeasure Ω) + (hlim : Tendsto μs atTop (𝓝 μ)) + (hdefect : ∀ F : Ω →ᵇ ℝ, + Tendsto (fun n => (∫ x, F (T x) ∂(μs n : Measure Ω)) - + ∫ x, F x ∂(μs n : Measure Ω)) atTop (𝓝 0)) : + MeasurePreserving T (μ : Measure Ω) (μ : Measure Ω) := by + refine ⟨hT.measurable, ?_⟩ + let ν := μ.map T + have heq : ν.toFiniteMeasure = μ.toFiniteMeasure := by + apply FiniteMeasure.ext_of_forall_integral_eq + intro F + have h₁ := (ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mp + (ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous μs μ hlim hT)) F + have h₂ := (ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mp hlim) F + have h₃ : Tendsto (fun n => + (∫ x, F (T x) ∂(μs n : Measure Ω)) - ∫ x, F x ∂(μs n : Measure Ω)) + atTop (𝓝 ((∫ x, F x ∂(ν : Measure Ω)) - ∫ x, F x ∂(μ : Measure Ω))) := by + convert h₁.sub h₂ using 1 + ext n + rw [ProbabilityMeasure.toMeasure_map, + integral_map hT.measurable.aemeasurable F.continuous.aestronglyMeasurable] + have hz := tendsto_nhds_unique h₃ (hdefect F) + exact sub_eq_zero.mp hz + exact congrArg FiniteMeasure.toMeasure heq + +theorem exists_invariant_subsequence (T : Ω → Ω) (hT : Continuous T) + (μs : ℕ → ProbabilityMeasure Ω) + (hdefect : ∀ F : Ω →ᵇ ℝ, + Tendsto (fun n => (∫ x, F (T x) ∂(μs n : Measure Ω)) - + ∫ x, F x ∂(μs n : Measure Ω)) atTop (𝓝 0)) : + ∃ μ : ProbabilityMeasure Ω, ∃ φ : ℕ → ℕ, + StrictMono φ ∧ Tendsto (μs ∘ φ) atTop (𝓝 μ) ∧ + MeasurePreserving T (μ : Measure Ω) (μ : Measure Ω) := by + obtain ⟨μ, -, φ, hφ, hlim⟩ := + (isCompact_univ : IsCompact (Set.univ : Set (ProbabilityMeasure Ω))).tendsto_subseq + (fun n => Set.mem_univ (μs n)) + exact ⟨μ, φ, hφ, hlim, invariant_of_weak_limit T hT (μs ∘ φ) μ hlim + (fun F => (hdefect F).comp hφ.tendsto_atTop)⟩ + +omit [TopologicalSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω] [CompactSpace Ω] + [T2Space Ω] [MetrizableSpace Ω] [SecondCountableTopology Ω] in +lemma episode_telescope (T : Ω → Ω) (F : Ω → ℝ) (x : Ω) (M : ℕ) : + (∑ i ∈ Finset.range M, (F (T (T^[i] x)) - F (T^[i] x))) = + F (T^[M] x) - F x := by + simpa only [Function.iterate_succ_apply', Function.iterate_zero, id_eq] using + Finset.sum_range_sub (fun i => F (T^[i] x)) M + +omit [MeasurableSpace Ω] [BorelSpace Ω] [CompactSpace Ω] [T2Space Ω] + [MetrizableSpace Ω] [SecondCountableTopology Ω] in +lemma episode_boundary_bound (T : Ω → Ω) (F : Ω →ᵇ ℝ) (x : Ω) (M : ℕ) : + |∑ i ∈ Finset.range M, (F (T (T^[i] x)) - F (T^[i] x))| ≤ 2*‖F‖ := by + rw [episode_telescope] + exact (abs_sub _ _).trans (by + have h₁ := F.norm_coe_le_norm (T^[M] x) + have h₂ := F.norm_coe_le_norm x + change |F (T^[M] x)| ≤ ‖F‖ at h₁ + change |F x| ≤ ‖F‖ at h₂ + linarith) + +end DirectionalTransience.StationaryCompact + +end + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace BoundedContinuousFunction +open scoped ENNReal Topology +namespace DirectionalTransience.StationaryCompact + +variable {X Y : Type*} [MeasurableSpace X] + [TopologicalSpace Y] [MeasurableSpace Y] [BorelSpace Y] + +noncomputable def episodeOccupationRaw (N : ℕ) (μ : Measure X) + (A : X → Y) (M : X → ℕ) (T : Y → Y) : Measure Y := + ∑ i ∈ Finset.range N, (μ.restrict {x | i < M x}).map (fun x => T^[i] (A x)) + +instance episodeOccupationRaw_finite (N : ℕ) (μ : Measure X) [IsFiniteMeasure μ] + (A : X → Y) (M : X → ℕ) (T : Y → Y) : + IsFiniteMeasure (episodeOccupationRaw N μ A M T) := by + unfold episodeOccupationRaw + infer_instance + +lemma sum_indicator_range (N M : ℕ) (hM : M ≤ N) (G : ℕ → ℝ) : + (∑ i ∈ Finset.range N, (if i < M then G i else 0)) = ∑ i ∈ Finset.range M, G i := by + have he : (Finset.range N).filter (fun i => i < M) = Finset.range M := by + ext i + simp only [Finset.mem_filter, Finset.mem_range] + omega + rw [←Finset.sum_filter, he] + +lemma episodeOccupationRaw_integral (N : ℕ) (μ : Measure X) [IsFiniteMeasure μ] + (A : X → Y) (hA : Measurable A) (M : X → ℕ) (hM : Measurable M) + (hMN : ∀ x, M x ≤ N) (T : Y → Y) (hT : Measurable T) + (F : Y →ᵇ ℝ) : + (∫ y, F y ∂episodeOccupationRaw N μ A M T) = + ∫ x, ∑ i ∈ Finset.range (M x), F (T^[i] (A x)) ∂μ := by + have hi (i : ℕ) : Integrable (fun x => F (T^[i] (A x))) μ := by + apply (integrable_const ‖F‖).mono' ((F.continuous.measurable.comp + ((hT.iterate i).comp hA)).aestronglyMeasurable) + exact Eventually.of_forall fun x => F.norm_coe_le_norm _ + have hm (i : ℕ) : MeasurableSet {x | i < M x} := measurableSet_lt measurable_const hM + rw [episodeOccupationRaw] + rw [integral_finsetSum_measure (fun i _ => + BoundedContinuousFunction.integrable ((μ.restrict {x | i < M x}).map + (fun x => T^[i] (A x))) F)] + calc (∑ i ∈ Finset.range N, ∫ y, F y ∂(μ.restrict {x | i < M x}).map + (fun x => T^[i] (A x))) + = ∑ i ∈ Finset.range N, ∫ x, + Set.indicator {x | i < M x} (fun x => F (T^[i] (A x))) x ∂μ := by + apply Finset.sum_congr rfl + intro i _ + rw [integral_indicator (hm i)] + exact integral_map ((hT.iterate i).comp hA).aemeasurable + F.continuous.aestronglyMeasurable + _ = ∫ x, ∑ i ∈ Finset.range N, + Set.indicator {x | i < M x} (fun x => F (T^[i] (A x))) x ∂μ := + (integral_finsetSum _ (fun i _ => (hi i).indicator (hm i))).symm + _ = _ := by + apply integral_congr_ae + exact Eventually.of_forall fun x => by + simp only [Set.indicator_apply,Set.mem_ofPred_eq] + exact sum_indicator_range N (M x) (hMN x) _ + +lemma episodeOccupationRaw_mass (N : ℕ) (μ : Measure X) [IsFiniteMeasure μ] + (A : X → Y) (hA : Measurable A) (M : X → ℕ) (hM : Measurable M) + (hMN : ∀ x, M x ≤ N) (T : Y → Y) (hT : Measurable T) : + (episodeOccupationRaw N μ A M T).real Set.univ = ∫ x, (M x : ℝ) ∂μ := by + simpa using episodeOccupationRaw_integral N μ A hA M hM hMN T hT + (BoundedContinuousFunction.const Y (1:ℝ)) + +noncomputable def episodeOccupation [Nonempty Y] (N : ℕ) (μ : Measure X) [IsFiniteMeasure μ] + (A : X → Y) (M : X → ℕ) (T : Y → Y) : ProbabilityMeasure Y := + FiniteMeasure.normalize (⟨episodeOccupationRaw N μ A M T, inferInstance⟩ : FiniteMeasure Y) + +lemma episodeOccupation_integral [Nonempty Y] (N : ℕ) (μ : Measure X) [IsFiniteMeasure μ] + (A : X → Y) (hA : Measurable A) (M : X → ℕ) (hM : Measurable M) + (hMN : ∀ x, M x ≤ N) (hpos : 0 < ∫ x, (M x:ℝ) ∂μ) + (T : Y → Y) (hT : Measurable T) (F : Y →ᵇ ℝ) : + (∫ y, F y ∂(episodeOccupation N μ A M T : Measure Y)) = + (∫ x, (M x:ℝ) ∂μ)⁻¹ * ∫ x, ∑ i ∈ Finset.range (M x), F (T^[i] (A x)) ∂μ := by + let ρ : FiniteMeasure Y := ⟨episodeOccupationRaw N μ A M T,inferInstance⟩ + have hn : ρ ≠ 0 := by + intro hz + have hh : (episodeOccupationRaw N μ A M T).real Set.univ = 0 := by + change (ρ : Measure Y).real Set.univ = 0 + rw [hz] + simp + rw [episodeOccupationRaw_mass N μ A hA M hM hMN T hT] at hh + linarith + change (∫ y, F y ∂(ρ.normalize : Measure Y)) = _ + rw [←ρ.average_eq_integral_normalize hn,average,integral_smul_measure] + change ((episodeOccupationRaw N μ A M T) Set.univ)⁻¹.toReal * + (∫ y, F y ∂episodeOccupationRaw N μ A M T) = _ + rw [ENNReal.toReal_inv,←Measure.real, + episodeOccupationRaw_mass N μ A hA M hM hMN T hT, + episodeOccupationRaw_integral N μ A hA M hM hMN T hT] + +lemma episode_sum_integrable (N : ℕ) (μ : Measure X) [IsFiniteMeasure μ] + (A : X → Y) (hA : Measurable A) (M : X → ℕ) (hM : Measurable M) + (hMN : ∀ x, M x ≤ N) (T : Y → Y) (hT : Measurable T) + (F : Y →ᵇ ℝ) : + Integrable (fun x => ∑ i ∈ Finset.range (M x), F (T^[i] (A x))) μ := by + have hi (i : ℕ) : Integrable (fun x => F (T^[i] (A x))) μ := by + apply (integrable_const ‖F‖).mono' ((F.continuous.measurable.comp + ((hT.iterate i).comp hA)).aestronglyMeasurable) + exact Eventually.of_forall fun x => F.norm_coe_le_norm _ + have hm (i : ℕ) : MeasurableSet {x | i < M x} := measurableSet_lt measurable_const hM + have hh := integrable_finsetSum (Finset.range N) (fun i _ => (hi i).indicator (hm i)) + apply hh.congr + exact Eventually.of_forall fun x => by + change (∑ i ∈ Finset.range N, Set.indicator {x | i < M x} + (fun x => F (T^[i] (A x))) x) = _ + simp only [Set.indicator_apply,Set.mem_ofPred_eq] + exact sum_indicator_range N (M x) (hMN x) _ + +lemma episodeOccupation_defect [Nonempty Y] [CompactSpace Y] [T2Space Y] + [MetrizableSpace Y] (N : ℕ) (μ : Measure X) [IsProbabilityMeasure μ] + (A : X → Y) (hA : Measurable A) (M : X → ℕ) (hM : Measurable M) + (hMN : ∀ x, M x ≤ N) (hpos : 0 < ∫ x, (M x:ℝ) ∂μ) + (T : Y → Y) (hT : Continuous T) (F : Y →ᵇ ℝ) : + |(∫ y, F (T y) ∂(episodeOccupation N μ A M T : Measure Y)) - + ∫ y, F y ∂(episodeOccupation N μ A M T : Measure Y)| ≤ + 2*‖F‖ / (∫ x, (M x:ℝ) ∂μ) := by + let G : Y →ᵇ ℝ := F.compContinuous ⟨T,hT⟩ + change |(∫ y, G y ∂(episodeOccupation N μ A M T : Measure Y)) - + ∫ y, F y ∂(episodeOccupation N μ A M T : Measure Y)| ≤ _ + rw [episodeOccupation_integral N μ A hA M hM hMN hpos T hT.measurable G, + episodeOccupation_integral N μ A hA M hM hMN hpos T hT.measurable F, + ←mul_sub,←integral_sub (episode_sum_integrable N μ A hA M hM hMN T hT.measurable G) + (episode_sum_integrable N μ A hA M hM hMN T hT.measurable F)] + rw [abs_mul,abs_of_nonneg (inv_nonneg.mpr hpos.le),div_eq_inv_mul] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr hpos.le) + have hh := norm_integral_le_of_norm_le_const (μ := μ) + (f := fun x => (∑ i ∈ Finset.range (M x), G (T^[i] (A x))) - + ∑ i ∈ Finset.range (M x), F (T^[i] (A x))) + (C := 2*‖F‖) (Eventually.of_forall fun x => by + rw [←Finset.sum_sub_distrib] + exact episode_boundary_bound T F (A x) (M x)) + simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using hh + +theorem episodeOccupation_stationary_limit [SecondCountableTopology Y] + [Nonempty Y] [CompactSpace Y] [T2Space Y] + [MetrizableSpace Y] (Ns : ℕ → ℕ) (μs : ℕ → Measure X) + [∀ n, IsProbabilityMeasure (μs n)] + (As : ℕ → X → Y) (hAs : ∀ n, Measurable (As n)) + (Ms : ℕ → X → ℕ) (hMs : ∀ n, Measurable (Ms n)) + (hMN : ∀ n x, Ms n x ≤ Ns n) + (hpos : ∀ n, 0 < ∫ x, (Ms n x:ℝ) ∂μs n) + (hcount : Tendsto (fun n => ∫ x, (Ms n x:ℝ) ∂μs n) atTop atTop) + (T : Y → Y) (hT : Continuous T) : + ∃ μ : ProbabilityMeasure Y, ∃ φ : ℕ → ℕ, + StrictMono φ ∧ + Tendsto (fun n => episodeOccupation (Ns (φ n)) (μs (φ n)) (As (φ n)) (Ms (φ n)) T) + atTop (𝓝 μ) ∧ MeasurePreserving T (μ : Measure Y) (μ : Measure Y) := by + apply exists_invariant_subsequence T hT + (fun n => episodeOccupation (Ns n) (μs n) (As n) (Ms n) T) + intro F + apply squeeze_zero_norm (fun n => + episodeOccupation_defect (Ns n) (μs n) (As n) (hAs n) (Ms n) (hMs n) + (hMN n) (hpos n) T hT F) + exact tendsto_const_nhds.div_atTop hcount + +end DirectionalTransience.StationaryCompact + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryMarking.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryMarking.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8b04574623f205ff5699c1e91cda792e77485cf --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryMarking.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayFull +import OAI.Probability.Ballisticity.Walk.UniformFinsetKernel + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal +namespace DirectionalTransience + +lemma preserving_cond {A : Type*} [MeasurableSpace A] (μ : Measure A) + {T : A → A} (hT : MeasurePreserving T μ μ) (E : Set A) (hE : MeasurableSet E) + (hi : ∀ᵐ a ∂μ, T a∈E ↔ a∈E) : MeasurePreserving T μ[|E] μ[|E] := by + have he : μ.restrict (T ⁻¹' E)=μ.restrict E := Measure.restrict_congr_set (hi.mono fun a ha => propext ha) + have h := hT.restrict_preimage hE + rw [he] at h + exact h.smul_measure (μ E)⁻¹ + +lemma preserving_marking {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + (μ : Measure A) [SFinite μ] {T : A → A} (hT : MeasurePreserving T μ μ) + (K : Kernel A B) [IsSFiniteKernel K] (f : A × B → B) (hf : Measurable f) + (he : ∀ᵐ a ∂μ, (K a).map (fun b => f (a,b))=K (T a)) : + MeasurePreserving (fun p : A × B => (T p.1,f p)) (μ.compProd K) (μ.compProd K) := by + have hm : Measurable (fun p : A × B => (T p.1,f p)) := (hT.measurable.comp measurable_fst).prodMk hf + refine ⟨hm,?_⟩ + ext s hs + rw [Measure.map_apply hm hs,Measure.compProd_apply (hs.preimage hm),Measure.compProd_apply hs] + calc + (∫⁻ a, K a (Prod.mk a ⁻¹' ((fun p : A × B => (T p.1,f p)) ⁻¹' s)) ∂μ) = + ∫⁻ a, K (T a) (Prod.mk (T a) ⁻¹' s) ∂μ := by + apply lintegral_congr_ae + filter_upwards [he] with a ha + rw [←ha,Measure.map_apply (show Measurable (fun b => f (a,b)) from hf.comp measurable_prodMk_left) (hs.preimage measurable_prodMk_left)] + rfl + _ = _ := hT.lintegral_comp (Kernel.measurable_kernel_prodMk_left hs) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +noncomputable def currentClassKernel {d : ℕ} (e : Direction d) : Kernel (CurrentData e) ℕ := + uniformFinsetKernel (currentClassFinset e) (currentClassFinset_measurable e) (currentClassFinset_nonempty e) +instance currentClassKernel_markov {d : ℕ} (e : Direction d) : IsMarkovKernel (currentClassKernel e) := by + unfold currentClassKernel; infer_instance + +noncomputable def arrayClassKernel {d : ℕ} (e : Direction d) (i : ℤ) : Kernel (ActualEpisodeArray e) ℕ := + (currentClassKernel e).comap (arrayCurrentData e i) (arrayCurrentData_measurable e i) +instance arrayClassKernel_markov {d : ℕ} (e : Direction d) (i : ℤ) : IsMarkovKernel (arrayClassKernel e i) := by + unfold arrayClassKernel; infer_instance + +abbrev MarkedArray {d : ℕ} (e : Direction d) := ActualEpisodeArray e × ℕ +noncomputable def markedShift {d : ℕ} (e : Direction d) (p : MarkedArray e) : MarkedArray e := + (StationaryCompact.shift p.1,arrayTransport e 0 p.1 p.2) +lemma markedShift_measurable {d : ℕ} (e : Direction d) : Measurable (markedShift e) := by + exact ((StationaryCompact.shift_continuous).measurable.comp measurable_fst).prodMk + (measurable_from_prod_countable_left (arrayTransport_measurable e 0)) + +noncomputable def markedArrayLaw {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + (E : Set (ActualEpisodeArray e)) : Measure (MarkedArray e) := μ[|E].compProd (arrayClassKernel e 0) + +lemma markedArrayLaw_probability {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (E : Set (ActualEpisodeArray e)) (hE : μ E≠0) : + IsProbabilityMeasure (markedArrayLaw e μ E) := by + have := cond_isProbabilityMeasure hE + unfold markedArrayLaw + infer_instance + +lemma markedArrayLaw_fst {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (E : Set (ActualEpisodeArray e)) : + (markedArrayLaw e μ E).fst=μ[|E] := Measure.fst_compProd _ _ + +lemma markedArrayLaw_ae {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (E : Set (ActualEpisodeArray e)) (hE : MeasurableSet E) + {P : ActualEpisodeArray e → Prop} (hP : ∀ᵐ Y ∂μ, Y∈E → P Y) : + ∀ᵐ p ∂markedArrayLaw e μ E, P p.1 := by + have h : ∀ᵐ Y ∂μ[|E], P Y := by + filter_upwards [(show μ[|E]≪μ from cond_absolutelyContinuous).ae_le hP,ae_cond_mem hE] with Y hY hy + exact hY hy + have hp : MeasurePreserving Prod.fst (markedArrayLaw e μ E) μ[|E] := + ⟨measurable_fst,markedArrayLaw_fst e μ E⟩ + exact hp.quasiMeasurePreserving.ae h + +lemma markedArrayLaw_supported {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + [IsProbabilityMeasure μ] (E : Set (ActualEpisodeArray e)) : + ∀ᵐ p ∂markedArrayLaw e μ E, p.2∈arrayClassFinset e 0 p.1 := by + apply (Measure.ae_compProd_iff ?_).mpr + · exact ae_of_all _ fun Y => uniformFinsetKernel_supported (currentClassFinset e) + (currentClassFinset_measurable e) (currentClassFinset_nonempty e) (arrayCurrentData e 0 Y) + · exact measurableSet_setOfPred.mpr (by + apply measurable_from_prod_countable_left + intro a + exact (measurable_finset_iff.mp (arrayClassFinset_measurable e 0)) a) + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma marked_preserving (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + MeasurePreserving (markedShift e) (markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event) + (markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event) := by + apply preserving_marking _ (preserving_cond _ L.preserving G.event G.measurable_event G.invariant) + (arrayClassKernel e 0) (fun p => arrayTransport e 0 p.1 p.2) + (measurable_from_prod_countable_left (arrayTransport_measurable e 0)) + have h : ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → + ((arrayClassKernel e 0) Y).map (arrayTransport e 0 Y)= + (arrayClassKernel e 0) (StationaryCompact.shift Y) := by + filter_upwards [L.consistent,L.sampling,L.elliptic,L.continuation,L.finite_marks, + G.no_dust,L.finite_classes_all_times hue htrans G,L.class_card_constant hue htrans G] + with Y hO hs he hc hm hd hf hcard hY + have hsurv := array_forward_survives e Y hs L.κ L.κ_pos he hc + (fun j => ⟨(hm j).1,(hm j).2.1⟩) (hd hY) 0 + exact uniformFinset_map (arrayClassFinset e 0 Y) (arrayClassFinset e 1 Y) + (currentClassFinset_nonempty e _) (currentClassFinset_nonempty e _) + (arrayTransport e 0 Y) (arrayTransport_injOn e 0 Y hO.1 (hf hY 0) hsurv) + (by + apply Finset.coe_injective + simpa only [Finset.coe_image, zero_add] using congrArg (fun s : Finset ℕ => (s : Set ℕ)) + (arrayTransport_image e 0 Y hO.1 (hf hY) hsurv (hcard hY 0))) + filter_upwards [(show (L.law : Measure (ActualEpisodeArray e))[|G.event]≪(L.law : Measure (ActualEpisodeArray e)) from cond_absolutelyContinuous).ae_le h,ae_cond_mem G.measurable_event] with Y hY hy + exact hY hy + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryMonotone.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryMonotone.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bc17b8d64ceffae2d45496c0cd3cae236cc16e0 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryMonotone.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayFiniteClasses +import OAI.Probability.Ballisticity.Estimates.ClassFinset + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal +namespace DirectionalTransience +lemma stationary_nat_monotone {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] {T : Ω → Ω} (hT : MeasurePreserving T μ μ) + (N : Ω → ℕ) (hm : Measurable N) (hle : ∀ᵐ ω ∂μ, N ω≤N (T ω)) : + ∀ᵐ ω ∂μ, N (T ω)=N ω := by + let f := fun ω => (1:ℝ)/((N ω:ℝ)+1) + have hfm : Measurable f := measurable_const.div (((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp hm).add_const 1) + have hfi : Integrable f μ := by + apply Integrable.mono' (integrable_const (1:ℝ)) hfm.aestronglyMeasurable + filter_upwards [] with ω + rw [Real.norm_eq_abs,abs_of_nonneg (by dsimp [f]; positivity)] + exact (div_le_one (by positivity)).mpr (by have := Nat.cast_nonneg (N ω) (α:=ℝ); linarith) + have hcomp : Integrable (fun ω => f (T ω)) μ := (hT.integrable_comp hfm.aestronglyMeasurable).mpr hfi + have hfl : ∀ᵐ ω ∂μ, f (T ω)≤f ω := by + filter_upwards [hle] with ω hω + exact one_div_le_one_div_of_le (by positivity) (by exact_mod_cast Nat.add_le_add_right hω 1) + have hF : (fun ω => f (T ω))=ᵐ[μ] f := + (integral_eq_iff_of_ae_le hcomp hfi hfl).mp (by rw [←integral_map hT.measurable.aemeasurable hfm.aestronglyMeasurable,hT.map_eq]) + filter_upwards [hF] with ω hω + have hh : (N (T ω):ℝ)+1=(N ω:ℝ)+1 := inv_inj.mp (by simpa only [f,one_div] using hω) + exact_mod_cast (add_right_cancel hh : (N (T ω):ℝ)=(N ω:ℝ)) +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def arrayClassFinset {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) : Finset ℕ := + currentClassFinset e (arrayCurrentData e i Y) +lemma arrayClassFinset_measurable {d : ℕ} (e : Direction d) (i : ℤ) : Measurable (arrayClassFinset e i) := + (currentClassFinset_measurable e).comp (arrayCurrentData_measurable e i) +lemma arrayClassFinset_shift {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) : + arrayClassFinset e i (StationaryCompact.shift Y)=arrayClassFinset e (i+1) Y := rfl + +noncomputable def arrayLink {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) (a : ℕ) : ℕ := + if h : ∃ b, ArrayRelated e Y (i,a) (i+1,b) then Nat.find h else 0 + +lemma arrayLink_measurable {d : ℕ} (e : Direction d) (i : ℤ) (a : ℕ) : + Measurable (fun Y => arrayLink e i Y a) := by + have hm : MeasurableSet {Y | ∃ b, ArrayRelated e Y (i,a) (i+1,b)} := by + simpa only [Set.ofPred_exists] using MeasurableSet.iUnion fun b => arrayRelated_measurable e (i,a) (i+1,b) + unfold arrayLink + apply Measurable.dite (s := {Y | ∃ b, ArrayRelated e Y (i,a) (i+1,b)}) + (f := fun Y => Nat.find Y.property) (g := fun _ => 0) + · exact measurable_find (fun Y : {Y | ∃ b, ArrayRelated e Y (i,a) (i+1,b)} => Y.property) + (fun b => (arrayRelated_measurable e (i,a) (i+1,b)).preimage measurable_subtype_coe) + · exact measurable_const + · exact hm + +lemma arrayLink_related {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) (a : ℕ) + (h : ∃ b, ArrayRelated e Y (i,a) (i+1,b)) : + ArrayRelated e Y (i,a) (i+1,arrayLink e i Y a) := by + rw [arrayLink,dite_eq_left h] + exact Nat.find_spec h + +noncomputable def arrayTransport {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) (a : ℕ) : ℕ := + ReferenceClasses.representative (arrayCurrentData e (i+1) Y).1 (arrayLink e i Y a) + +lemma arrayTransport_measurable {d : ℕ} (e : Direction d) (i : ℤ) (a : ℕ) : + Measurable (fun Y => arrayTransport e i Y a) := by + exact (measurable_from_prod_countable_left (f := fun p : ActualEpisodeArray e × ℕ => + ReferenceClasses.representative (arrayCurrentData e (i+1) p.1).1 p.2) + (fun b => (ReferenceClasses.measurable_representative b).comp + (arrayCurrentData_measurable e (i+1)).fst)).comp + (measurable_id.prodMk (arrayLink_measurable e i a)) + +lemma arrayTransport_related {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) + (ho : ArrayOffsetsConsistent e Y) (a : ℕ) (h : ∃ b, ArrayRelated e Y (i,a) (i+1,b)) : + ArrayRelated e Y (i,a) (i+1,arrayTransport e i Y a) := by + apply arrayRelated_trans e Y ho (arrayLink_related e i Y a h) + apply (arrayRelated_current e Y ho (i+1) _ _).mp + exact ReferenceClasses.related_symm (ReferenceClasses.representative_related _ _) + +lemma arrayTransport_mem {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) + (hf : CurrentFiniteClasses e (arrayCurrentData e (i+1) Y)) (a : ℕ) : + arrayTransport e i Y a∈arrayClassFinset e (i+1) Y := + currentClassFinset_rep_mem e _ hf _ + +lemma arrayTransport_injOn {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) + (ho : ArrayOffsetsConsistent e Y) (hf : CurrentFiniteClasses e (arrayCurrentData e i Y)) + (hs : ∀ a, ∃ b, ArrayRelated e Y (i,a) (i+1,b)) : + Set.InjOn (arrayTransport e i Y) (arrayClassFinset e i Y) := by + intro a ha b hb hab + have ha' := arrayTransport_related e i Y ho a (hs a) + rw [hab] at ha' + have hr := arrayRelated_trans e Y ho ha' + (arrayRelated_symm e Y ho (arrayTransport_related e i Y ho b (hs b))) + have hh : ReferenceClasses.related (arrayCurrentData e i Y).1 a b := + (arrayRelated_current e Y ho i a b).mpr (by simpa only [hab] using hr) + have he := (ReferenceClasses.representative_eq_iff _ a b).mpr hh + rw [(currentClassFinset_mem e _ hf a).mp ha,(currentClassFinset_mem e _ hf b).mp hb] at he + exact he + +lemma arrayClassFinset_card_le {d : ℕ} (e : Direction d) (i : ℤ) (Y : ActualEpisodeArray e) + (ho : ArrayOffsetsConsistent e Y) (hf : ∀ i, CurrentFiniteClasses e (arrayCurrentData e i Y)) + (hs : ∀ a, ∃ b, ArrayRelated e Y (i,a) (i+1,b)) : + (arrayClassFinset e i Y).card≤(arrayClassFinset e (i+1) Y).card := by + calc + _ = ((arrayClassFinset e i Y).image (arrayTransport e i Y)).card := + (Finset.card_image_iff.mpr (arrayTransport_injOn e i Y ho (hf i) hs)).symm + _ ≤ _ := Finset.card_le_card (by + intro b hb + obtain ⟨a,ha,rfl⟩ := Finset.mem_image.mp hb + exact arrayTransport_mem e i Y (hf (i+1)) a) + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +lemma class_card_constant (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) : + ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → ∀ i, + (arrayClassFinset e (i+1) Y).card=(arrayClassFinset e i Y).card := by + let N := fun Y => if Y∈G.event then (arrayClassFinset e 0 Y).card else 0 + have hm : Measurable N := Measurable.ite G.measurable_event + ((measurable_of_countable Finset.card).comp (arrayClassFinset_measurable e 0)) measurable_const + have hf := L.finite_classes_all_times hue htrans G + have hle : ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), N Y≤N (StationaryCompact.shift Y) := by + filter_upwards [L.consistent,L.sampling,L.elliptic,L.continuation,L.finite_marks,G.no_dust,hf,G.invariant] + with Y hO hs he hc hm hd hf hi + by_cases hY : Y∈G.event + · simp only [N,ite_eq_left hY,ite_eq_left (hi.mpr hY),arrayClassFinset_shift] + exact arrayClassFinset_card_le e 0 Y hO.1 (hf hY) + (array_forward_survives e Y hs L.κ L.κ_pos he hc (fun i => ⟨(hm i).1,(hm i).2.1⟩) (hd hY) 0) + · simp only [N,ite_eq_right hY,ite_eq_right (mt hi.mp hY),le_refl] + have heq := stationary_nat_monotone _ L.preserving N hm hle + have h0 : ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → + (arrayClassFinset e (0+1) Y).card=(arrayClassFinset e 0 Y).card := by + filter_upwards [heq,G.invariant] with Y hY hi hy + simpa only [N,ite_eq_left hy,ite_eq_left (hi.mpr hy),arrayClassFinset_shift] using hY + have hall := stationary_ae_integer_family _ L.preserving + (fun i Y => Y∈G.event → (arrayClassFinset e (i+1) Y).card=(arrayClassFinset e i Y).card) + (fun i => G.measurable_event.imp (measurableSet_eq_fun + ((measurable_of_countable Finset.card).comp (arrayClassFinset_measurable e (i+1))) + ((measurable_of_countable Finset.card).comp (arrayClassFinset_measurable e i)))) + (fun i => G.invariant.mono fun Y hi => by rw [hi]; rfl) h0 + filter_upwards [hall] with Y hY hy i + exact hY i hy + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryProfile.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..63a833ba4c5c0e7950392be73f3e22575901c37c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryProfile.lean @@ -0,0 +1,197 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.DensityTransfer + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +noncomputable def coordinateProfile {d : ℕ} (e : Direction d) (f : Fin d) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) : Kernel D ℤ := + w.map (fun x => x.1 f) + +instance coordinateProfile_finite {d : ℕ} (e : Direction d) (f : Fin d) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] : + IsFiniteKernel (coordinateProfile e f w) := by + unfold coordinateProfile + infer_instance + +lemma coordinateProfile_apply {d : ℕ} (e : Direction d) (f : Fin d) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) (z : D) : + coordinateProfile e f w z = (w z).map (fun x => x.1 f) := + Kernel.map_apply _ (measurable_of_countable _) _ + +lemma profile_statistic_nonpos {d : ℕ} (e : Direction d) (f : Fin d) + {D : Type*} [MeasurableSpace D] (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] + (htotal : ∀ z, w z Set.univ ≤ 1) (z : D) (R : ℤ) : + Real.log (TailGrowth.statistic (coordinateProfile e f w z) R) ≤ 0 := by + have hnon : 0 ≤ TailGrowth.statistic (coordinateProfile e f w z) R := by + apply le_trans _ (TailGrowth.score_le_statistic _ R 0) + exact le_min (measureReal_nonneg) (measureReal_nonneg) + apply Real.log_nonpos hnon + apply (TailGrowth.statistic_le_mass _ _).trans + rw [coordinateProfile_apply,Measure.real, + Measure.map_apply (measurable_of_countable _) MeasurableSet.univ] + exact ENNReal.toReal_le_of_le_ofReal (by norm_num) (by simpa using htotal z) + +lemma iterate_identDistrib {Ω Y : Type*} [MeasurableSpace Ω] [MeasurableSpace Y] + (μ : Measure Ω) {T : Ω → Ω} (hT : MeasurePreserving T μ μ) + {F : Ω → Y} (hF : Measurable F) (n : ℕ) : + IdentDistrib (fun ω => F (T^[n] ω)) F μ μ := by + refine ⟨(hF.comp (hT.iterate n).measurable).aemeasurable,hF.aemeasurable,?_⟩ + change Measure.map (F ∘ T^[n]) μ = _ + rw [←Measure.map_map hF (hT.iterate n).measurable, (hT.iterate n).map_eq] + +structure StationaryProfileSystem {d : ℕ} (ν : Measure (Row d)) + (e : Direction d) (f : Fin d) + (Ω D : Type) [MeasurableSpace Ω] [MeasurableSpace D] + (μ : Measure Ω) (w : Kernel D (HorizontalLayer e)) where + T : Ω → Ω + preserving : MeasurePreserving T μ μ + data : Ω → D + measurable_data : Measurable data + full : ∀ z x, 0 < (w z).real {x} + total : ∀ z, w z Set.univ ≤ 1 + c : Ω → ℝ + measurable_c : Measurable c + nonneg_c : ∀ᵐ ω ∂μ, 0 ≤ c ω + integrable_c : Integrable c μ + h : Ω → ℕ + measurable_h : Measurable h + positive_h : ∀ᵐ ω ∂μ, 1 ≤ h ω + integrable_log_h : Integrable (fun ω => Real.log (1+(h ω:ℝ))) μ + field : ℕ → Ω → Environment d + measurable_field : ∀ n, Measurable (field n) + finite_entropy : ∀ n : ℕ, 0 < n → + ∃ g : D × Environment d → ℝ, + Measurable g ∧ (∀ z, 0 ≤ g z) ∧ + Integrable g ((μ.map data).prod (environmentLaw ν)) ∧ + (∫ z, g z ∂(μ.map data).prod (environmentLaw ν)) = 1 ∧ + Integrable (fun z => TailDecorrelation.entropyPlus (g z)) + ((μ.map data).prod (environmentLaw ν)) ∧ + μ.map (fun ω => (data ω,field n ω)) = + ((μ.map data).prod (environmentLaw ν)).withDensity (fun z => ENNReal.ofReal (g z)) + offset : ℕ → Ω → ℤ + update : ∀ n : ℕ, 0 < n → ∀ᵐ ω ∂μ, + ENNReal.ofReal (Real.exp (∑ i ∈ Finset.range n, c (T^[i] ω))) • + (horizontalCoordinateKernel e f (∑ i ∈ Finset.range n, h (T^[i] ω)) (field n ω) ∘ₘ + w (data ω)) ≤ + (coordinateProfile e f w (data (T^[n] ω))).map (fun x => x+offset n ω) + +theorem stationary_profile_mean_nonpos {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e : Direction d) (f : Fin d) (hef : e.1 ≠ f) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (Ω D : Type) [MeasurableSpace Ω] [MeasurableSpace D] + (μ : Measure Ω) [IsProbabilityMeasure μ] + (w : Kernel D (HorizontalLayer e)) [IsFiniteKernel w] + (S : StationaryProfileSystem ν e f Ω D μ w) : + (∫ ω, S.c ω ∂μ) ≤ 0 := by + classical + obtain ⟨A,hA,hpoint,M,hM,hdec⟩ := actual_profile_tail_decorrelation ν hue e f hef htrans + let δ := μ.map S.data + let : IsProbabilityMeasure δ := + (Measure.isProbabilityMeasure_map_iff S.measurable_data.aemeasurable).2 inferInstance + let X : ℕ → ℕ → Ω → ℝ := fun n R ω => + Real.log (TailGrowth.statistic (coordinateProfile e f w (S.data (S.T^[n] ω))) (R:ℤ)) + have hXa (R : ℕ) : Measurable (fun ω => X 0 R ω) := by + exact Real.measurable_log.comp ((TailGrowth.measurable_statistic + (coordinateProfile e f w) (R:ℤ)).comp S.measurable_data) + have hXid (n R : ℕ) : IdentDistrib (X 0 R) (X n R) μ μ := by + exact (iterate_identDistrib μ S.preserving (hXa R) n).symm + have hXnon (n R : ℕ) : ∀ᵐ ω ∂μ, X n R ω ≤ 0 := + Eventually.of_forall fun ω => profile_statistic_nonpos e f w S.total _ _ + have hpos : ∀ᵐ ω ∂μ, ∀ i, 1 ≤ S.h (S.T^[i] ω) := + ae_all_iff.mpr fun i => (S.preserving.iterate i).quasiMeasurePreserving.ae S.positive_h + have hwindow (n : ℕ) (hn : 0 < n) : ∃ Z : ℕ → Ω → ℝ, + (∀ R, Integrable (Z R) μ) ∧ + (∀ᶠ R in atTop, (∫ ω, Z R ω ∂μ) ≤ M+1) ∧ + (∀ R, ∀ᵐ ω ∂μ, + (∑ i ∈ Finset.range n, S.c (S.T^[i] ω)) - + (2*A)*Real.log (1+∑ i ∈ Finset.range n, (S.h (S.T^[i] ω):ℝ)) - + Z R ω - Real.log 2 ≤ X n R ω-X 0 R ω) := by + obtain ⟨g,hgm,hg0,hgi,hg1,hgH,hLaw⟩ := S.finite_entropy n hn + obtain ⟨j,hj,hmax,hsect,hint,hmean,hlim⟩ := hdec D δ w S.full g hgm hg0 hgi hg1 hgH + let κ := fun R : ℕ => profilePairKernel e f w (R:ℤ) (j R) (hj R) + let F : ℕ → D × Environment d → ℝ := fun R z => + ∫ p : ZeroHeightPair e, outwardCanonicalExcess e (f,true) A p.1 z.2 ∂κ R z.1 + let V : Ω → D × Environment d := fun ω => (S.data ω,S.field n ω) + have hVm : Measurable V := S.measurable_data.prodMk (S.measurable_field n) + have hFi (R : ℕ) := TailDecorrelation.controlled_integral μ + (δ.prod (environmentLaw ν)) hVm hgm hg0 hLaw (hint R) + refine ⟨fun R ω => F R (V ω),fun R => (hFi R).1,?_,?_⟩ + · filter_upwards [hmean 1 (by norm_num)] with R hR + exact ((hFi R).2).trans_le hR + · intro R + have hs := TailDecorrelation.controlled_ae μ (δ.prod (environmentLaw ν)) + hVm hgm hLaw (hsect R) + have hp : ∀ᵐ ω ∂μ, + ∀ x : Lattice d × Lattice d, + dot (realPosition x.1) (realPosition (step e)) = + dot (realPosition x.2) (realPosition (step e)) → + ∀ t : ℕ, 0 < outwardKernelMass e (f,true) (t+1) x (S.field n ω) ∧ + -Real.log (outwardKernelMass e (f,true) (t+1) x (S.field n ω)) ≤ + 2*A*Real.log ((t:ℝ)+2)+outwardCanonicalExcess e (f,true) A x (S.field n ω) := by + have hpref := (Measure.quasiMeasurePreserving_snd (μ := δ) (ν := environmentLaw ν)).ae hpoint + exact TailDecorrelation.controlled_ae μ (δ.prod (environmentLaw ν)) hVm hgm hLaw + (hpref.mono fun _ hz _ => hz) + filter_upwards [S.update n hn,hs,hp,hpos] with ω hupdate hsec hpω hhω + have hH : 0 < ∑ i ∈ Finset.range n, S.h (S.T^[i] ω) := by + exact lt_of_lt_of_le (Nat.succ_le_iff.mp (hhω 0)) + (Finset.single_le_sum (s := Finset.range n) (f := fun i => S.h (S.T^[i] ω)) + (fun i _ => Nat.zero_le _) (Finset.mem_range.mpr hn)) + have hsec' := (profilePairKernel_integrable e f hef w S.full (R:ℤ) + (j R) (hj R) (S.data ω) + (fun p : ZeroHeightPair e => outwardCanonicalExcess e (f,true) A p.1 (S.field n ω))).mp hsec + have hgrowth := actual_profile_tail_growth e f hef A (S.field n ω) hpω + (∑ i ∈ Finset.range n, S.h (S.T^[i] ω)) hH (w (S.data ω)) (S.full _) + ((coordinateProfile e f w (S.data (S.T^[n] ω))).map (fun x => x+S.offset n ω)) + (R:ℤ) (j R (S.data ω)) (hmax (S.data ω) R) + (∑ i ∈ Finset.range n, S.c (S.T^[i] ω)) hupdate hsec' + rw [TailGrowth.statistic_translate] at hgrowth + have heq := profilePairKernel_integral e f hef w S.full (R:ℤ) + (j R) (hj R) (S.data ω) + (fun p : ZeroHeightPair e => outwardCanonicalExcess e (f,true) A p.1 (S.field n ω)) + dsimp only [horizontalPair] at heq + rw [←heq] at hgrowth + simpa only [Nat.cast_sum, X, Function.iterate_zero, id_eq, coordinateProfile_apply, + F,V,κ] using hgrowth + choose W hWi hWmean hWgrowth using fun n => hwindow (n+1) (Nat.succ_pos n) + let Z : ℕ → ℕ → Ω → ℝ := fun n => match n with + | 0 => fun _ _ => 0 + | k+1 => W k + have hZint (n R : ℕ) : Integrable (Z n R) μ := by + cases n with + | zero => exact integrable_const 0 + | succ k => exact hWi k R + have hZmean (n : ℕ) : ∀ᶠ R in atTop, (∫ ω, Z n R ω ∂μ) ≤ M+1 := by + cases n with + | zero => exact Eventually.of_forall fun R => by simp only [Z,integral_zero]; linarith + | succ k => exact hWmean k + have hgrowth (n R : ℕ) : ∀ᵐ ω ∂μ, + (∑ i ∈ Finset.range n, S.c (S.T^[i] ω)) - + (2*A)*Real.log (1+∑ i ∈ Finset.range n, (S.h (S.T^[i] ω):ℝ)) - + Z n R ω-Real.log 2 ≤ X n R ω-X 0 R ω := by + cases n with + | zero => + apply Eventually.of_forall + intro ω + simp only [Finset.range_zero,Finset.sum_empty,add_zero,Real.log_one,mul_zero, + Z,zero_sub,sub_self] + exact neg_nonpos.mpr (Real.log_nonneg (by norm_num)) + | succ k => exact hWgrowth k R + apply stationary_tail_growth_obstruction μ (c := fun i ω => S.c (S.T^[i] ω)) + (h := fun i ω => (S.h (S.T^[i] ω):ℝ)) (X := X) (Z := Z) + S.integrable_c (fun i => iterate_identDistrib μ S.preserving S.measurable_c i) + (Eventually.of_forall fun ω i => Nat.cast_nonneg _) (fun i => ?_) + S.integrable_log_h hXid hXnon hZint (2*A) (M+1) hZmean hgrowth + exact iterate_identDistrib μ S.preserving ((measurable_of_countable (fun k : ℕ => (k : ℝ))).comp S.measurable_h) i + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryProfile2.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryProfile2.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6e6ca902a3f8bc8febcf916cf627fa630f13edf --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryProfile2.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MarkedObservables + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +abbrev FullMarkedArray {d : ℕ} (e : Direction d) := MarkedArray e × Environment d +noncomputable def fullMarkedShift {d : ℕ} (e : Direction d) : FullMarkedArray e → FullMarkedArray e := + Prod.map (markedShift e) id + +lemma fullMarkedShift_iterate_fst {d : ℕ} (e : Direction d) (p : FullMarkedArray e) (n : ℕ) : + ((fullMarkedShift e)^[n] p).1=(markedShift e)^[n] p.1 := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply',Function.iterate_succ_apply'] + change markedShift e (((fullMarkedShift e)^[n] p).1)=_ + rw [ih] + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +noncomputable def actualProfileSystem (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (G : ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) + (w₀ : ProperProfile e) (f : Fin d) (hef : e.1≠f) : + StationaryProfileSystem ν e f (FullMarkedArray e) (ProperProfile e) + ((markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event).prod (environmentLaw ν)) + (properProfileKernel e) := by + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + haveI := markedArrayLaw_probability e (L.law : Measure (ActualEpisodeArray e)) G.event G.positive_event.ne' + have hT := L.marked_preserving hue htrans G + have hF := Measure.quasiMeasurePreserving_fst (μ := μ) (ν := environmentLaw ν) + have hmarks := markedArrayLaw_ae e (L.law : Measure (ActualEpisodeArray e)) G.event G.measurable_event + (L.finite_marks.mono fun Y h _ => h) + have hp := L.marked_profile_proper hue htrans G + refine { + T := fullMarkedShift e + preserving := hT.prod (MeasurePreserving.id (environmentLaw ν)) + data := fun p => properData e w₀ (markedData e p.1) + measurable_data := (properData_measurable e w₀).comp ((markedData_measurable e).comp measurable_fst) + full := properProfileKernel_full e + total := properProfileKernel_total e + c := fun p => arrayRealCost e p.1.1 + measurable_c := (arrayRealCost_measurable e).comp measurable_fst.fst + nonneg_c := ae_of_all _ fun p => arrayRealCost_nonneg e p.1.1 + integrable_c := (markedArrayLaw_integrable e _ G.event G.positive_event.ne' _ + (arrayRealCost_measurable e) L.integrable_cost).comp_fst (environmentLaw ν) + h := fun p => arrayNatHeight e p.1.1 + measurable_h := (arrayNatHeight_measurable e).comp measurable_fst.fst + positive_h := ?_ + integrable_log_h := ?_ + field := fun n p => fillUpper e (markedUpper e n p.1,p.2) + measurable_field := fun n => (fillUpper_measurable e).comp + (((markedUpper_measurable e n).comp measurable_fst).prodMk measurable_snd) + finite_entropy := fun n _ => L.marked_full_entropy G w₀ n + offset := fun n p => (markedDisplacement e n p.1).val f + update := ?_ + } + · filter_upwards [hF.ae hmarks] with p hm + exact arrayNatHeight_positive e p.1.1 (hm 0).1 (hm 0).2.1 + · have hm : Measurable (fun Y : ActualEpisodeArray e => Real.log (1+(arrayNatHeight e Y:ℝ))) := + Real.measurable_log.comp (measurable_const.add ((measurable_of_countable (fun n : ℕ => (n:ℝ))).comp + (arrayNatHeight_measurable e))) + exact (markedArrayLaw_integrable e _ G.event G.positive_event.ne' _ hm + L.integrable_logheight).comp_fst (environmentLaw ν) + · intro n hn + have hcont := markedArrayLaw_ae e (L.law : Measure (ActualEpisodeArray e)) G.event G.measurable_event + (show ∀ᵐ Y ∂(L.law : Measure (ActualEpisodeArray e)), Y∈G.event → + ArrayProfilesConsistent e Y ∧ ArrayContinuation e Y from by + filter_upwards [L.consistent,L.continuation] with Y ho hc _ + exact ⟨ho.2,hc⟩) + have hrel := L.marked_related hue htrans G + have hpn := (hT.iterate n).quasiMeasurePreserving.ae hp + filter_upwards [hF.ae hcont,hF.ae hmarks,hF.ae hrel,hF.ae hp,hF.ae hpn] with p hco hm hr hp0 hpn0 + simp only [fullMarkedShift_iterate_fst] + exact markedProfile_update e f hef w₀ p.1 p.2 n hco.1 hco.2 + (fun j => (hm j).2.1) (fun j => (hm j).2.2.2.ne) (hr n) hp0 hpn0 + +end StationaryArrayLaw +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +theorem impossible (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (f : Fin d) (hef : e.1≠f) : False := by + obtain ⟨G⟩ := L.growth_sector hue htrans + obtain ⟨w₀⟩ := L.properProfile_nonempty hue htrans G + let μ := markedArrayLaw e (L.law : Measure (ActualEpisodeArray e)) G.event + have : IsProbabilityMeasure μ := markedArrayLaw_probability e _ G.event G.positive_event.ne' + let η := μ.prod (environmentLaw ν) + let S := L.actualProfileSystem hue htrans G w₀ f hef + have hn := stationary_profile_mean_nonpos ν hue e f hef htrans (FullMarkedArray e) + (ProperProfile e) η (properProfileKernel e) S + have hz : S.c =ᵐ[η] 0 := (integral_eq_zero_iff_of_nonneg_ae S.nonneg_c S.integrable_c).mp + (le_antisymm hn (integral_nonneg_of_ae S.nonneg_c)) + have hzero : ∀ᵐ p ∂η, ∀ i : ℕ, S.c (S.T^[i] p)=0 := + ae_all_iff.mpr fun i => (S.preserving.iterate i).quasiMeasurePreserving.ae hz + have hgrowth := markedArrayLaw_ae e (L.law : Measure (ActualEpisodeArray e)) G.event + G.measurable_event G.growth + have hmarks := markedArrayLaw_ae e (L.law : Measure (ActualEpisodeArray e)) G.event + G.measurable_event (L.finite_marks.mono fun Y h _ => h) + have hF := Measure.quasiMeasurePreserving_fst (μ := μ) (ν := environmentLaw ν) + obtain ⟨p,hp0,hpg,hpm⟩ := (hzero.and ((hF.ae hgrowth).and (hF.ae hmarks))).exists + have hwin (n : ℕ) : (arrayWindowCost e 0 n p.1.1).toReal=0 := by + rw [arrayWindowCost_toReal e p.1.1 (fun j => (hpm j).2.2.2.ne)] + apply Finset.sum_eq_zero + intro i hi + have h := hp0 i + change arrayRealCost e (((fullMarkedShift e)^[i] p).1.1)=0 at h + simpa only [fullMarkedShift_iterate_fst,markedShift_iterate_fst] using h + obtain ⟨k,hk⟩ := hpg.exists + rw [hwin] at hk + exact (not_lt_of_ge (mul_nonneg G.positive_ζ.le (Nat.cast_nonneg _))) hk + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Stationary/StationaryWindowEntropy.lean b/lean/OAI/Probability/Ballisticity/Stationary/StationaryWindowEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..73c59c42549ef963c3db1d33865472d14281c22c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Stationary/StationaryWindowEntropy.lean @@ -0,0 +1,184 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.WindowEntropy +import OAI.Probability.Ballisticity.Entropy.BadWindowEntropy +import OAI.Probability.Ballisticity.Estimates.LocalRadiusOrder +import OAI.Probability.Ballisticity.Crossings.BadCrossingLaw + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory InformationTheory Filter +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma typedCurrentArrayWindow_shift {d : ℕ} (e : Direction d) (i : ℤ) (m : ℕ) + (Y : ActualEpisodeArray e) : + typedCurrentArrayWindow e i m (StationaryCompact.shift Y)=typedCurrentArrayWindow e (i+1) m Y := rfl + +lemma stationary_currentWindow_law {d : ℕ} (e : Direction d) (m : ℕ) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hstat : MeasurePreserving StationaryCompact.shift (ρ : Measure (ActualEpisodeArray e)) + (ρ : Measure (ActualEpisodeArray e))) (i : ℤ) : + (ρ : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e i m) = + (actualCurrentLaw e m ρ : Measure (CurrentWindow e)) := by + have hs' (j : ℤ) : (ρ : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e (j+1) m)= + (ρ : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e j m) := by + calc + _ = (ρ : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e j m ∘ StationaryCompact.shift) := rfl + _ = ((ρ : Measure (ActualEpisodeArray e)).map StationaryCompact.shift).map (typedCurrentArrayWindow e j m) := + (Measure.map_map (typedCurrentArrayWindow_measurable e j m) hstat.measurable).symm + _ = _ := by rw [hstat.map_eq] + induction i using Int.induction_on with + | zero => rfl + | succ i hi => exact (hs' i).trans hi + | pred i hi => + have hh := hs' (-(i:ℤ)-1) + simp only [sub_add_cancel] at hh + exact hh.symm.trans hi + +namespace OperationalConstants +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] + {e f : Direction d} {D : ℝ} + +theorem stationary_window_entropy (C : OperationalConstants ν e f D) (hef : e.1≠f.1) (hD : 0≤D) + (Ns : ℕ → ℕ) + (hN : ∀ n, C.sfloor ≤ (Ns n:ℝ)) + (hlarge : ∀ n, 32*C.b ≤ (1/2:ℝ)*Real.log (Ns n:ℝ)) + (hmass : ∀ n, (Ns n:ℝ)^(-D) ≤ (environmentLaw ν).real (badCrossingEvent e (Ns n) (1/2))) + (ρ : ProbabilityMeasure (ActualEpisodeArray e)) + (hlim : Tendsto (fun n => C.occupation hef (Ns n) + ((environmentLaw ν)[|badCrossingEvent e (Ns n) (1/2)])) atTop (𝓝 ρ)) + (hstat : MeasurePreserving StationaryCompact.shift (ρ : Measure (ActualEpisodeArray e)) + (ρ : Measure (ActualEpisodeArray e))) (i : ℤ) (m : ℕ) : + let W := (ρ : Measure (ActualEpisodeArray e)).map (typedCurrentArrayWindow e i m) + klDiv W (W.fst.compProd (currentWindowReference e ν)) ≤ + ENNReal.ofReal ((m:ℝ)*C.windowEntropyConstant) := by + dsimp only + rw [stationary_currentWindow_law e m ρ hstat i] + exact C.bad_limit_window_entropy hef hD Ns hN hlarge hmass ρ hlim m + +end OperationalConstants +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter TopologicalSpace +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +lemma actualOccupation_ae_of_ae_invariant {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (s : Set (ActualEpisodeArray e)) (hs : MeasurableSet s) + (ha : ∀ᵐ X ∂episodeInputLaw e ν Q t ht, actualArrayMap e t J X∈s) + (hshift : ∀ Y∈s, StationaryCompact.shift Y∈s) : + ∀ᵐ Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)), Y∈s := by + have hiter (i : ℕ) : ∀ᵐ X ∂episodeInputLaw e ν Q t ht, + StationaryCompact.shift^[i] (actualArrayMap e t J X)∈s := by + filter_upwards [ha] with X hX + induction i with + | zero => exact hX + | succ i hi => + rw [Function.iterate_succ_apply'] + exact hshift _ hi + have hraw : ∀ᵐ Y ∂actualOccupationRaw e ν Q t J ht N M, Y∈s := by + unfold actualOccupationRaw StationaryCompact.episodeOccupationRaw + rw [ae_finsetSum_measure_iff] + intro i _ + apply (ae_map_iff ((StationaryCompact.shift_continuous.measurable.iterate i).comp + (actualArrayMap_measurable e t J ht hJ)).aemeasurable hs).mpr + exact ae_restrict_of_ae (hiter i) + have : Nonempty (Row d) := nonempty_of_isProbabilityMeasure ν + let ρ : FiniteMeasure (ActualEpisodeArray e) := ⟨actualOccupationRaw e ν Q t J ht N M,inferInstance⟩ + have hn : ρ≠0 := by + intro hz + have hh : (actualOccupationRaw e ν Q t J ht N M).real Set.univ=0 := by + change (ρ : Measure (ActualEpisodeArray e)).real Set.univ=0 + rw [hz] + simp + linarith + change ∀ᵐ Y ∂(ρ.normalize : Measure (ActualEpisodeArray e)), Y∈s + rw [ρ.toMeasure_normalize_eq_of_nonzero hn] + exact Measure.ae_smul_measure hraw _ + +def ArrayElliptic {d : ℕ} (e : Direction d) (κ : ℝ≥0) (Y : ActualEpisodeArray e) : Prop := + ∀ i m a l z u, κ ≤ (Y.2.2.2 (i,m,a,l,z)).1 u + +lemma arrayElliptic_closed {d : ℕ} (e : Direction d) (κ : ℝ≥0) : + IsClosed {Y : ActualEpisodeArray e | ArrayElliptic e κ Y} := by + unfold ArrayElliptic + simp only [Set.ofPred_forall] + refine isClosed_iInter fun i => isClosed_iInter fun m => isClosed_iInter fun a => + isClosed_iInter fun l => isClosed_iInter fun z => isClosed_iInter fun u => ?_ + exact isClosed_le continuous_const ((continuous_apply u).comp + (continuous_subtype_val.comp (by fun_prop))) + +lemma arrayElliptic_shift {d : ℕ} (e : Direction d) (κ : ℝ≥0) + (Y : ActualEpisodeArray e) (h : ArrayElliptic e κ Y) : + ArrayElliptic e κ (StationaryCompact.shift Y) := by + intro i m a l z u + exact h (i+1) m a l z u + +lemma auxiliary_rows {d : ℕ} (e : Direction d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (κ : ℝ≥0) (hν : ∀ᵐ r ∂ν, ∀ u, κ ≤ r.1 u) : + ∀ᵐ A ∂episodeAuxiliaryLaw e ν, ∀ p q u, κ ≤ (A p q).1 u := by + have hinner : ∀ᵐ A ∂Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν), + ∀ q u, κ ≤ (A q).1 u := by + apply ae_all_iff.mpr + intro q + exact (measurePreserving_eval_infinitePi (fun _ : ℕ×HorizontalSpace e => ν) q).quasiMeasurePreserving.ae hν + apply ae_all_iff.mpr + intro p + exact (measurePreserving_eval_infinitePi + (fun _ : ℤ×ℕ => Measure.infinitePi (fun _ : ℕ×HorizontalSpace e => ν)) p).quasiMeasurePreserving.ae hinner + +lemma actualArrayMap_elliptic_ae {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (κ : ℝ≥0) (hν : ∀ᵐ r ∂ν, ∀ u, κ ≤ r.1 u) + (hQ : ∀ᵐ ω ∂Q, ∀ y u, κ ≤ (ω y).1 u) : + ∀ᵐ X ∂episodeInputLaw e ν Q t ht, ArrayElliptic e κ (actualArrayMap e t J X) := by + have hm : MeasurableSet {ω : Environment d | ∀ y u, κ ≤ (ω y).1 u} := by + simp only [Set.ofPred_forall] + apply MeasurableSet.iInter + intro y + apply MeasurableSet.iInter + intro u + exact measurableSet_le measurable_const ((measurable_pi_apply u).comp + (measurable_subtype_coe.comp (measurable_pi_apply y))) + have hbase := Measure.ae_compProd_of_ae_fst (globalEpisodeAnchors e t ht) hm hQ + have hfirst := (Measure.quasiMeasurePreserving_fst + (μ:=Q.compProd (globalEpisodeAnchors e t ht)) (ν:=episodeAuxiliaryLaw e ν)).ae hbase + have hsecond := (Measure.quasiMeasurePreserving_snd + (μ:=Q.compProd (globalEpisodeAnchors e t ht)) (ν:=episodeAuxiliaryLaw e ν)).ae + (auxiliary_rows e ν κ hν) + filter_upwards [hfirst,hsecond] with X hX hA + intro i m a l z u + change κ ≤ (episodeSplicedRow e t X i m a l z).1 u + unfold episodeSplicedRow + split + · exact hX _ u + · exact hA _ _ u + +lemma actualOccupation_elliptic {d : ℕ} (e : Direction d) + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (Q : Measure (Environment d)) [IsFiniteMeasure Q] + (t J : Environment d → ℤ → ℕ) (ht : ∀ i, Measurable fun ω => t ω i) + (hJ : ∀ i, Measurable fun ω => J ω i) (N : ℕ) (M : Environment d → ℕ) + (hpos : 0<(actualOccupationRaw e ν Q t J ht N M).real Set.univ) + (κ : ℝ≥0) (hν : ∀ᵐ r ∂ν, ∀ u, κ ≤ r.1 u) + (hQ : ∀ᵐ ω ∂Q, ∀ y u, κ ≤ (ω y).1 u) : + ∀ᵐ Y ∂(actualOccupation e ν Q t J ht N M : Measure (ActualEpisodeArray e)), ArrayElliptic e κ Y := + actualOccupation_ae_of_ae_invariant e ν Q t J ht hJ N M hpos _ + (arrayElliptic_closed e κ).measurableSet (actualArrayMap_elliptic_ae e ν Q t J ht κ hν hQ) + (arrayElliptic_shift e κ) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/VelocityHemisphere.lean b/lean/OAI/Probability/Ballisticity/VelocityHemisphere.lean new file mode 100644 index 0000000000000000000000000000000000000000..74656c2f22cebdf6c67aac03afb2dca4bbe42130 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/VelocityHemisphere.lean @@ -0,0 +1,64 @@ +import OAI.Probability.Ballisticity.PositiveEscape + +namespace OAI + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +namespace DirectionalTransience + +theorem positive_probability_transience_velocity_hemisphere + {d : ℕ} (hd : 3 ≤ d) (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : ℓ ≠ 0) + (hpos : 0 < annealedLaw ν (TransientPaths ℓ)) : + ∃ v : Vector d, + v ≠ 0 ∧ 0 < dot v ℓ ∧ annealedLaw ν (VelocityPaths v) = 1 ∧ + (∀ w : Vector d, annealedLaw ν (VelocityPaths w) = 1 → w = v) ∧ + {u : Vector d | dot u u = 1 ∧ annealedLaw ν (TransientPaths u) = 1} = + {u : Vector d | dot u u = 1 ∧ 0 < annealedLaw ν (TransientPaths u)} ∧ + {u : Vector d | dot u u = 1 ∧ 0 < annealedLaw ν (TransientPaths u)} = + {u : Vector d | dot u u = 1 ∧ 0 < dot v u} ∧ + (∀ u : Vector d, dot u u = 1 → dot v u ≤ 0 → + annealedLaw ν (TransientPaths u) = 0) := by + obtain ⟨v, hvℓ, hv⟩ := velocity_of_positive_escape hd ν hue ℓ hℓ hpos + have hv0 : v ≠ 0 := by + intro h + subst v + simp only [dot, Pi.zero_apply, zero_mul, Finset.sum_const_zero, lt_self_iff_false] at hvℓ + have hvprob : annealedLaw ν (VelocityPaths v) = 1 := + (mem_ae_iff_prob_eq_one (measurableSet_velocityPaths v)).mp hv + have hunique : ∀ w : Vector d, annealedLaw ν (VelocityPaths w) = 1 → w = v := by + intro w hw + apply hasVelocity_unique ν _ hv + exact (mem_ae_iff_prob_eq_one (measurableSet_velocityPaths w)).mpr hw + have hpositive (u : Vector d) (hu : dot u u = 1) : + 0 < annealedLaw ν (TransientPaths u) ↔ 0 < dot v u := by + constructor + · intro hp + obtain ⟨w, hwu, hw⟩ := velocity_of_positive_escape hd ν hue u + (unit_direction_ne_zero u hu) hp + have hwv : w = v := hasVelocity_unique ν hw hv + simpa only [hwv] using hwu + · intro hp + rw [escape_probability_one_of_velocity ν v u hv hp] + exact zero_lt_one + have hone (u : Vector d) (hu : dot u u = 1) : + annealedLaw ν (TransientPaths u) = 1 ↔ 0 < annealedLaw ν (TransientPaths u) := by + constructor + · intro h + rw [h] + exact zero_lt_one + · intro h + exact escape_probability_one_of_velocity ν v u hv ((hpositive u hu).mp h) + refine ⟨v, hv0, hvℓ, hvprob, hunique, ?_, ?_, ?_⟩ + · ext u + exact and_congr_right (hone u) + · ext u + exact and_congr_right (hpositive u) + · intro u hu hnonpos + apply le_antisymm _ bot_le + exact le_of_not_gt (fun hp => (not_lt_of_ge hnonpos) ((hpositive u hu).mp hp)) + +end DirectionalTransience + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/ArrayCostGrowth.lean b/lean/OAI/Probability/Ballisticity/Walk/ArrayCostGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..69ee044c9a98976b7cc60cfbc83e054b08f40993 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/ArrayCostGrowth.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayWindowMarks +import OAI.Probability.Ballisticity.Stationary.ArrayPermutation +import OAI.Probability.Ballisticity.Walk.StationaryGrowth +import OAI.Probability.Ballisticity.Stationary.ArrayMarkTests + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +noncomputable def arrayRealCost {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) : ℝ := (Y.1 0).2.2.toReal +lemma arrayRealCost_measurable {d : ℕ} (e : Direction d) : Measurable (arrayRealCost e) := by + exact (show Measurable (fun Y : ActualEpisodeArray e => (Y.1 0).2.2) from by fun_prop).ennreal_toReal +lemma arrayRealCost_nonneg {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) : 0≤arrayRealCost e Y := ENNReal.toReal_nonneg + +lemma arrayWindowCost_toReal {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hc : ∀ j, (Y.1 j).2.2≠⊤) (m : ℕ) : + (arrayWindowCost e 0 m Y).toReal=∑ j∈Finset.range m, arrayRealCost e (StationaryCompact.shift^[j] Y) := by + rw [arrayWindowCost,ENNReal.toReal_sum (fun (j : ℕ) _ => hc (0+(j:ℤ)))] + apply Finset.sum_congr rfl + intro j _ + simp only [arrayRealCost,arrayMark_iterate] + +lemma expNeg_toReal_of_ne_top (C : ℝ≥0∞) (hc : C≠⊤) : (expNeg C).toReal=Real.exp (-C.toReal) := by + rw [←ENNReal.ofReal_toReal hc] + unfold expNeg + rw [EReal.coe_ennreal_ofReal,max_eq_left ENNReal.toReal_nonneg,←EReal.coe_neg,EReal.exp_coe, + ENNReal.toReal_ofReal (Real.exp_nonneg _)] + rw [ENNReal.toReal_ofReal ENNReal.toReal_nonneg] + +lemma array_cost_decay_of_growth {d : ℕ} (e : Direction d) (Y : ActualEpisodeArray e) + (hc : ∀ j, (Y.1 j).2.2≠⊤) (ζ : ℝ) (hζ : 0<ζ) (ns : ℕ → ℕ) (hns : StrictMono ns) + (hg : ∀ᶠ k in atTop, ζ*(ns k:ℝ)<∑ j∈Finset.range (ns k), arrayRealCost e (StationaryCompact.shift^[j] Y)) : + ∀ ε : ℝ, 0<ε → ∃ m, (expNeg (arrayWindowCost e 0 m Y)).toReal<ε := by + have ht : Tendsto (fun k => ζ*(ns k:ℝ)) atTop atTop := + (tendsto_natCast_atTop_atTop.comp hns.tendsto_atTop).const_mul_atTop hζ + have he := Real.tendsto_exp_neg_atTop_nhds_zero.comp ht + intro ε hε + obtain ⟨k,hk,hk'⟩ := (hg.and (he.eventually (gt_mem_nhds hε))).exists + refine ⟨ns k,?_⟩ + have hf : arrayWindowCost e 0 (ns k) Y≠⊤ := by + unfold arrayWindowCost + exact ENNReal.sum_ne_top.mpr fun j _ => hc (0+j) + rw [expNeg_toReal_of_ne_top _ hf,arrayWindowCost_toReal e Y hc] + exact (Real.exp_lt_exp.mpr (neg_lt_neg hk)).trans hk' + +lemma array_growth_symmetry {d : ℕ} (e : Direction d) (μ : Measure (ActualEpisodeArray e)) + (g : ActualEpisodeArray e → ℝ) (ns : ℕ → ℕ) + (hlim : ∀ᵐ Y ∂μ, Tendsto (fun k => orbitAverage StationaryCompact.shift + (fun Y => min (arrayRealCost e Y) 1) (ns k) Y) atTop (𝓝 (g Y))) + (hperm : ∀ σ, MeasurePreserving (arrayPerm e σ) μ μ) (σ : Equiv.Perm ℕ) : + ∀ᵐ Y ∂μ, g (arrayPerm e σ Y)=g Y := by + exact growth_limit_respects_symmetry μ ns hlim (hperm σ) (fun Y => rfl) (fun Y => rfl) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/ArrayGrowthEvent.lean b/lean/OAI/Probability/Ballisticity/Walk/ArrayGrowthEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac4503078661a396b47ead38bb7f239046b08c9f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/ArrayGrowthEvent.lean @@ -0,0 +1,91 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.StationaryArrayLaw +import OAI.Probability.Ballisticity.Stationary.ArrayDust + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Classical Topology BigOperators +namespace DirectionalTransience + +lemma stationary_ae_integer_family {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) {T : Ω → Ω} (hT : MeasurePreserving T μ μ) + (P : ℤ → Ω → Prop) (hp : ∀ i, MeasurableSet {ω | P i ω}) + (hs : ∀ i, ∀ᵐ ω ∂μ, P i (T ω) ↔ P (i+1) ω) + (h0 : ∀ᵐ ω ∂μ, P 0 ω) : ∀ᵐ ω ∂μ, ∀ i, P i ω := by + apply ae_all_iff.mpr + have hb (i : ℤ) : (∀ᵐ ω ∂μ, P i ω) ↔ ∀ᵐ ω ∂μ, P (i+1) ω := by + have he : (∀ᵐ ω ∂μ, P i (T ω)) ↔ ∀ᵐ ω ∂μ, P (i+1) ω := eventually_congr (hs i) + rw [←ae_map_iff hT.measurable.aemeasurable (hp i),hT.map_eq] at he + exact he + intro i + induction i using Int.induction_on with + | zero => exact h0 + | succ n ih => exact (hb n).mp ih + | pred n ih => + apply (hb (-(n:ℤ)-1)).mpr + simpa only [sub_add_cancel] using ih + +structure ArrayGrowthSector {d : ℕ} (e : Direction d) + (μ : Measure (ActualEpisodeArray e)) where + event : Set (ActualEpisodeArray e) + measurable_event : MeasurableSet event + positive_event : 0<μ event + invariant : ∀ᵐ Y ∂μ, StationaryCompact.shift Y∈event ↔ Y∈event + symmetric : ∀ σ, ∀ᵐ Y ∂μ, arrayPerm e σ Y∈event ↔ Y∈event + ζ : ℝ + positive_ζ : 0<ζ + sequence : ℕ → ℕ + strictMono : StrictMono sequence + growth : ∀ᵐ Y ∂μ, Y∈event → ∀ᶠ k in atTop, + ζ*(sequence k:ℝ)<(arrayWindowCost e 0 (sequence k) Y).toReal + no_dust : ∀ᵐ Y ∂μ, Y∈event → ∀ i a, ¬arrayDust e i a Y + +namespace StationaryArrayLaw +variable {d : ℕ} {ν : Measure (Row d)} [IsProbabilityMeasure ν] {e : Direction d} + +theorem growth_sector (L : StationaryArrayLaw ν e) (hue : UniformElliptic ν) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + Nonempty (ArrayGrowthSector e (L.law : Measure (ActualEpisodeArray e))) := by + let μ := (L.law : Measure (ActualEpisodeArray e)) + obtain ⟨g,hgm,hgb,hgT,ζ,hζ,hE,ns,hns,hlim,hgrowth⟩ := stationary_positive_growth μ + L.preserving (arrayRealCost e) (arrayRealCost_measurable e) (arrayRealCost_nonneg e) + L.integrable_cost L.positive_cost + let E := {Y | ζ (hY j).2.2.2.ne + have hd : ∀ᵐ Y ∂μ, Y∈E → ∀ ε : ℝ, 0<ε → ∃ m, + (expNeg (arrayWindowCost e 0 m Y)).toReal<ε := by + filter_upwards [hc,hgrowth] with Y hY hg hy + exact array_cost_decay_of_growth e Y hY ζ hζ ns hns (hg hy) + have hn0 := array_no_dust_on_cost_decay e ν hue htrans μ L.consistent L.zero_sampling + L.entropy_finite (L.finite_marks.mono fun Y hY j => (hY j).2.1) L.survival L.symmetric 0 E hmE heP hd + have hnd : ∀ᵐ Y ∂μ, Y∈E → ∀ i a, ¬arrayDust e i a Y := by + have hh := stationary_ae_integer_family μ L.preserving (fun i Y => Y∈E → ∀ a, ¬arrayDust e i a Y) + (fun i => hmE.imp (by + simpa only [Set.ofPred_forall, Set.compl_ofPred] using MeasurableSet.iInter fun a => (arrayDust_measurable e i a).compl)) + (fun i => heT.mono fun Y hY => by + rw [hY] + rfl) hn0 + filter_upwards [hh] with Y hY hy i + exact hY i hy + refine ⟨⟨E,hmE,hE,heT,heP,ζ,hζ,ns,hns,?_,hnd⟩⟩ + filter_upwards [hc,hgrowth] with Y hY hg hy + simpa only [arrayWindowCost_toReal e Y hY] using hg hy + +end StationaryArrayLaw +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/BoundaryPathCoordinates.lean b/lean/OAI/Probability/Ballisticity/Walk/BoundaryPathCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..87f95092d553704e0adbbb6e591475e36d5c6adc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/BoundaryPathCoordinates.lean @@ -0,0 +1,152 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.FirstLayerHitRecordPrefix +import OAI.Probability.Ballisticity.Estimates.JointPastRestart + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma recordIndexPosition_prefix_coord {d : ℕ} (e : Direction d) (X Y : Path d) + (h0 : X 0 = 0) (hD : X ∈ NoDrop (realPosition (step e)) 0) + (hnn : ∀ n, ∃ f, X (n+1) = X n+step f) + (ht : X ∈ TransientPaths (realPosition (step e))) (n k : ℕ) + (hk : (k : ℤ) ≤ signedHeight e (X n)) (hXY : ∀ j ≤ n, X j = Y j) : + recordIndexPosition (realPosition (step e)) k X = + recordIndexPosition (realPosition (step e)) k Y := by + by_cases hz : k = 0 + · subst k + simp only [recordIndexPosition,recordIndexTime_zero] + exact hXY 0 (Nat.zero_le n) + obtain ⟨m,hm⟩ := noDrop_firstLayerHit_exists e X h0 hnn ht (Nat.pos_of_ne_zero hz) + have hmn : m ≤ n := by + by_contra hh + have hc := hm.2 n (by omega) + omega + have hr := firstLayerHit_recordPrefix e X h0 hD hnn (Nat.pos_of_ne_zero hz) hm + have hr' := (recordIndexPrefix_prefix (realPosition (step e)) k m X Y + (fun j hj => hXY j (hj.trans hmn))).mp hr + simp only [recordIndexPosition,recordIndexTime_eq _ _ _ _ hr,recordIndexTime_eq _ _ _ _ hr'] + exact hXY m hmn + +lemma regularPath_recenter {d : ℕ} (ℓ : Vector d) (x : Lattice d) (X : Path d) + (hX : X ∈ RegularPath ℓ x) : (fun j => X j-x) ∈ RegularPath ℓ 0 := by + refine ⟨by simp only [hX.1,sub_self],?_,?_⟩ + · intro n + obtain ⟨f,hf⟩ := hX.2.1 n + exact ⟨f,by dsimp only; rw [hf]; abel⟩ + · change X ∈ (fun Z : Path d => fun j => Z j-x) ⁻¹' TransientPaths ℓ + rw [transientPaths_translation] + exact hX.2.2 + +lemma noDrop_recenter {d : ℕ} (ℓ : Vector d) (x : Lattice d) (X : Path d) + (hX : X ∈ NoDrop ℓ x) : (fun j => X j-x) ∈ NoDrop ℓ 0 := by + change X ∈ (fun Z : Path d => fun j => Z j-x) ⁻¹' NoDrop ℓ 0 + rw [noDrop_translation] + simpa only [add_zero] using hX + +lemma trueRecord_recenter {d : ℕ} (ℓ : Vector d) (x : Lattice d) (X : Path d) + (n : ℕ) (hn : TrueRecord ℓ X n) : TrueRecord ℓ (fun j => X j-x) n := by + constructor + · intro j hj + dsimp only + simp only [dot_realPosition_sub] + exact sub_lt_sub_right (hn.1 j hj) _ + · intro j + dsimp only + simp only [dot_realPosition_sub] + exact sub_le_sub_right (hn.2 j) _ + +lemma translated_recordIndexPosition_suffix {d : ℕ} (e : Direction d) + (x : Lattice d) (X : Path d) + (hX : X ∈ RegularPath (realPosition (step e)) x) + (hD : X ∈ NoDrop (realPosition (step e)) x) + (n H : ℕ) (hn : 0 < n) (htrue : TrueRecord (realPosition (step e)) X n) + (hH : signedHeight e (X n) = signedHeight e x+H) (j : ℕ) : + recordIndexPosition (realPosition (step e)) (j+H) (fun k => X k-x) = + recordIndexPosition (realPosition (step e)) j (fun k => X (n+k)-X n)+(X n-x) := by + let ℓ := realPosition (step e) + let Z : Path d := fun k => X k-x + have hZ : Z ∈ RegularPath ℓ 0 := regularPath_recenter ℓ x X hX + have hZD := noDrop_recenter ℓ x X hD + have hZT := trueRecord_recenter ℓ x X n htrue + have hs (k : ℕ) : signedHeight e (Z (k+1)) ≤ signedHeight e (Z k)+1 := by + obtain ⟨f,hf⟩ := hZ.2.1 k + rw [hf] + exact signedHeight_step_le e _ f + have hc := recordCount_eq_height_at_record ℓ (signedHeight e) (signedHeight_projection e) Z hs hZT.1 + have hc' : recordCount ℓ Z n = H := by + have h0 : signedHeight e (Z 0) = 0 := by rw [hZ.1]; simp [signedHeight] + have hh : signedHeight e (Z n) = H := by dsimp [Z]; rw [signedHeight_sub,hH]; omega + rw [h0,hh,zero_add] at hc + exact_mod_cast hc.symm + have hh := recordIndexPosition_suffix ℓ Z hZD hZ.2.2 hn hZT j + rw [hc'] at hh + convert hh using 2 + congr 1 + funext k + dsimp [Z] + abel + +lemma boundaryData_firstHit_prefix {d : ℕ} (e : Direction d) (x y : Lattice d) + (hxy : signedHeight e x = signedHeight e y) (H : ℕ) (P : Path d × Path d) + (hX : P.1 ∈ RegularPath (realPosition (step e)) x) + (hY : P.2 ∈ RegularPath (realPosition (step e)) y) + (hD : P.1 ∈ NoDrop (realPosition (step e)) x) + (hE : P.2 ∈ NoDrop (realPosition (step e)) y) + (hb : BoundaryAt (realPosition (step e)) ((signedHeight e x+H : ℤ) : ℝ) P + (boundaryTimes (realPosition (step e)) ((signedHeight e x+H : ℤ) : ℝ) P).1 + (boundaryTimes (realPosition (step e)) ((signedHeight e x+H : ℤ) : ℝ) P).2) + (j : ℕ) (hj : j ≤ H) : + let F := boundaryData (realPosition (step e)) ((signedHeight e x+H : ℤ) : ℝ) P + recordIndexPosition (realPosition (step e)) j (fun k => P.1 k-x) = + recordIndexPosition (realPosition (step e)) j (fun k => extendPrefix F.1.1 F.2.1 k-x) ∧ + recordIndexPosition (realPosition (step e)) j (fun k => P.2 k-y) = + recordIndexPosition (realPosition (step e)) j (fun k => extendPrefix F.1.2 F.2.2 k-y) := by + dsimp only + let ℓ := realPosition (step e) + let L := ((signedHeight e x+H : ℤ) : ℝ) + let q := boundaryTimes ℓ L P + have hh : signedHeight e x+H ≤ signedHeight e (P.1 q.1) := by + have hh := hb.2.2.2.1 + rw [signedHeight_projection e] at hh + exact_mod_cast hh + have he : signedHeight e (P.1 q.1) = signedHeight e (P.2 q.2) := by + have he := hb.2.2.1.2.2 + rw [signedHeight_projection e,signedHeight_projection e] at he + exact_mod_cast he + have hxr := regularPath_recenter ℓ x P.1 hX + have hyr := regularPath_recenter ℓ y P.2 hY + constructor + · apply recordIndexPosition_prefix_coord e _ _ hxr.1 (noDrop_recenter ℓ x P.1 hD) + hxr.2.1 hxr.2.2 q.1 j + · simp only [signedHeight_sub] + omega + · intro k hk + change k ≤ (boundaryTimes (realPosition (step e)) ((signedHeight e x+H : ℤ) : ℝ) P).1 at hk + change P.1 k-x = extendPrefix q.1 (Preorder.frestrictLe q.1 P.1) k-x + rw [extendPrefix_apply _ _ _ hk] + rfl + · apply recordIndexPosition_prefix_coord e _ _ hyr.1 (noDrop_recenter ℓ y P.2 hE) + hyr.2.1 hyr.2.2 q.2 j + · simp only [signedHeight_sub] + omega + · intro k hk + change k ≤ (boundaryTimes (realPosition (step e)) ((signedHeight e x+H : ℤ) : ℝ) P).2 at hk + change P.2 k-y = extendPrefix q.2 (Preorder.frestrictLe q.2 P.2) k-y + rw [extendPrefix_apply _ _ _ hk] + rfl + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/BufferGrowthArithmetic.lean b/lean/OAI/Probability/Ballisticity/Walk/BufferGrowthArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..a97eeabcec9b0d264b52c7073b9b899d7d7b13c7 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/BufferGrowthArithmetic.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.BufferTree + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma buffer_log_recurrence {Ω : Type*} (B : ℕ → Set Ω) (ω : Ω) + (R : ℕ → ℝ) (hR : ∀ n, 0 < R n) (A D : ℝ) + (hstep : ∀ n, R n * Real.exp (if ω ∈ B n then A else -D) ≤ R (n+1)) (n : ℕ) : + Real.log (R n)+(if ω ∈ B n then A else -D) ≤ Real.log (R (n+1)) := by + have hp : 0 < R n * Real.exp (if ω ∈ B n then A else -D) := mul_pos (hR n) (Real.exp_pos _) + have hh := Real.log_le_log hp (hstep n) + rwa [Real.log_mul (hR n).ne' (Real.exp_pos _).ne',Real.log_exp] at hh + +lemma buffer_log_sum {Ω : Type*} (B : ℕ → Set Ω) (ω : Ω) + (R : ℕ → ℝ) (hR : ∀ n, 0 < R n) (A D : ℝ) + (hstep : ∀ n, R n * Real.exp (if ω ∈ B n then A else -D) ≤ R (n+1)) (n : ℕ) : + Real.log (R 0) + successes B n ω*(A+D) - (n:ℝ)*D ≤ Real.log (R n) := by + induction n with + | zero => simp [successes] + | succ n ih => + have hh := buffer_log_recurrence B ω R hR A D hstep n + rw [successes_succ,Nat.cast_add,Nat.cast_one] + by_cases hb : ω ∈ B n + · simp only [ite_eq_left hb] at hh ⊢ + nlinarith + · simp only [ite_eq_right hb] at hh ⊢ + nlinarith + +lemma buffer_log_growth {Ω : Type*} (B : ℕ → Set Ω) (ω : Ω) + (R : ℕ → ℝ) (hR : ∀ n, 0 < R n) {A s W : ℝ} (hA : 0 ≤ A) (hs : 0 ≤ s) + (hstep : ∀ n, R n * Real.exp (if ω ∈ B n then A else -(s*A/8)) ≤ R (n+1)) + (hexcess : ∀ n : ℕ, s/4*(n:ℝ)-successes B n ω ≤ W) (n : ℕ) : + Real.log (R 0) + (s*A/8)*(n:ℝ) - W*(A+s*A/8) ≤ Real.log (R n) := by + have hh := buffer_log_sum B ω R hR A (s*A/8) hstep n + have hAD : 0 ≤ A+s*A/8 := by positivity + have hc := mul_le_mul_of_nonneg_right (hexcess n) hAD + have hn : 0 ≤ s*s*A*(n:ℝ) := by positivity + nlinarith + +lemma buffer_stage_count {Ω : Type*} (B : ℕ → Set Ω) (ω : Ω) + (R : ℕ → ℝ) (hR : ∀ n, 0 < R n) {A s W C : ℝ} (hA : 0 ≤ A) (hs : 0 ≤ s) + (hstep : ∀ n, R n * Real.exp (if ω ∈ B n then A else -(s*A/8)) ≤ R (n+1)) + (hexcess : ∀ n : ℕ, s/4*(n:ℝ)-successes B n ω ≤ W) + (hR0 : 1 ≤ R 0) (hC : 0 < C) (n H : ℕ) (hheight : R n ≤ C*(H+1)) : + (s*A/8)*(n:ℝ) ≤ Real.log C + Real.log ((H:ℝ)+1) + W*(A+s*A/8) := by + have hl := buffer_log_growth B ω R hR hA hs hstep hexcess n + have hu := Real.log_le_log (hR n) hheight + have hH : 0 < (H:ℝ)+1 := by positivity + rw [Real.log_mul hC.ne' hH.ne'] at hu + have h0 := Real.log_nonneg hR0 + linarith + +lemma buffer_contraction_choice {α s : ℝ} (hα : 0 < α) (hs : 0 < s) : + let ε := 1-Real.exp (-(s*Real.log (1+α)/8)) + 0 < ε ∧ ε < 1 ∧ Real.exp (Real.log (1+α))=1+α ∧ + Real.exp (-(s*Real.log (1+α)/8))=1-ε := by + have hA : 0 < Real.log (1+α) := Real.log_pos (by linarith) + have hd : 0 < s*Real.log (1+α)/8 := by positivity + have he := Real.exp_lt_one_iff.mpr (show -(s*Real.log (1+α)/8)<0 by linarith) + have hep := Real.exp_pos (-(s*Real.log (1+α)/8)) + dsimp only + refine ⟨by linarith,by linarith,Real.exp_log (by linarith),by ring⟩ +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def bufferCurrentNode {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R₀ z₀ ε α g : ℝ) (κ : ℝ≥0) (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (root : AdaptedBufferNode e) (ω : Environment d) (n : ℕ) : AdaptedBufferNode e := + bufferNodeAt e f hef R₀ z₀ ε α g κ H hH root (bufferHistory e f hef R₀ z₀ ε α g κ H hH root ω n) + +lemma bufferCurrentNode_succ {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R₀ z₀ ε α g : ℝ) (κ : ℝ≥0) (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (root : AdaptedBufferNode e) (ω : Environment d) (n : ℕ) : + let N := bufferCurrentNode e f hef R₀ z₀ ε α g κ H hH root ω n + let p := bufferNodeDecision e f z₀ ε α g H N ω + bufferCurrentNode e f hef R₀ z₀ ε α g κ H hH root ω (n+1) = + bufferChildNode e f hef R₀ z₀ ε α g κ N (H N.radius) (hH N.radius) p.1 p.2 := rfl + +lemma bufferNextRadius_exponential_step (R₀ r ε α A D : ℝ) + (hα : Real.exp A=1+α) (hε : Real.exp (-D)=1-ε) (b : Bool) : + r*Real.exp (if b then A else -D) ≤ bufferNextRadius R₀ r ε α b := by + cases b <;> simp only [Bool.false_eq_true,↓reduceIte,bufferNextRadius,hα,hε] + · simpa only [mul_comm] using (le_max_right R₀ ((1-ε)*r)) + · simpa only [mul_comm] using (le_max_right R₀ ((1+α)*r)) + +lemma bufferCurrentNode_exponential_step {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + (R₀ z₀ ε α g A D : ℝ) (hα : Real.exp A=1+α) (hε : Real.exp (-D)=1-ε) + (κ : ℝ≥0) (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (root : AdaptedBufferNode e) (ω : Environment d) (hr : ω ∈ root.active) (n : ℕ) : + (bufferCurrentNode e f hef R₀ z₀ ε α g κ H hH root ω n).radius * + Real.exp (if ω ∈ bufferTreeSuccess e f hef R₀ z₀ ε α g κ H hH root n then A else -D) ≤ + (bufferCurrentNode e f hef R₀ z₀ ε α g κ H hH root ω (n+1)).radius := by + rw [bufferCurrentNode_succ] + have hb := bufferTreeSuccess_iff_decision e f hef R₀ z₀ ε α g κ H hH root ω hr n + rw [hb] + let N := bufferCurrentNode e f hef R₀ z₀ ε α g κ H hH root ω n + have he := bufferNextRadius_exponential_step R₀ N.radius ε α A D hα hε + (bufferNodeDecision e f z₀ ε α g H N ω).2 + convert he using 1 + · congr 2 + exact congrArg (fun h : Decidable ((bufferNodeDecision e f z₀ ε α g H N ω).2=true) => + @ite ℝ _ h A (-D)) (Subsingleton.elim _ _) + · rfl + +lemma bufferCurrentNode_log_growth {d : ℕ} (e f : Direction d) (hef : e.1 ≠ f.1) + {R₀ α s : ℝ} (hR₀ : 0 < R₀) (hα : 0 < α) (hs : 0 < s) + (z₀ g : ℝ) (κ : ℝ≥0) (H : ℝ → ℕ) (hH : ∀ r, 0 < H r) + (root : AdaptedBufferNode e) (hroot : root.radius=R₀) (ω : Environment d) (hr : ω ∈ root.active) + (W : ℝ) + (hexcess : ∀ n : ℕ, s/4*(n:ℝ)-successes + (bufferTreeSuccess e f hef R₀ z₀ (1-Real.exp (-(s*Real.log (1+α)/8))) α g κ H hH root) n ω ≤ W) + (n : ℕ) : + Real.log R₀+(s*Real.log (1+α)/8)*(n:ℝ)-W*(Real.log (1+α)+s*Real.log (1+α)/8) ≤ + Real.log (bufferCurrentNode e f hef R₀ z₀ (1-Real.exp (-(s*Real.log (1+α)/8))) α g κ H hH root ω n).radius := by + let ε := 1-Real.exp (-(s*Real.log (1+α)/8)) + let R := fun n => (bufferCurrentNode e f hef R₀ z₀ ε α g κ H hH root ω n).radius + have hp (n : ℕ) : 0 < R n := hR₀.trans_le + (bufferNodeAt_radius e f hef R₀ z₀ ε α g κ H hH root hroot.ge _) + have hc := buffer_contraction_choice hα hs + have he := bufferCurrentNode_exponential_step e f hef R₀ z₀ ε α g + (Real.log (1+α)) (s*Real.log (1+α)/8) hc.2.2.1 hc.2.2.2 κ H hH root ω hr + have hA : 0 ≤ Real.log (1+α) := (Real.log_pos (by linarith)).le + have hh := buffer_log_growth + (bufferTreeSuccess e f hef R₀ z₀ ε α g κ H hH root) ω R hp hA hs.le he hexcess n + have hr0 : R 0=R₀ := hroot + rw [hr0] at hh + exact hh +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/BufferHistoryBracket.lean b/lean/OAI/Probability/Ballisticity/Walk/BufferHistoryBracket.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b77b9b642714eac8415c2d485346cecf5127dfa --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/BufferHistoryBracket.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.BufferElapsedHeight + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma bufferWordHeight_length (l : List (ℕ × Bool)) : l.length ≤ bufferWordHeight l := by + induction l with + | nil => rfl + | cons p l ih => simp only [List.length_cons,bufferWordHeight]; omega + +lemma nat_increasing_bracket (b : ℕ → ℕ) (h0 : b 0=0) (h : ∀ n, b n < b (n+1)) (t : ℕ) : + ∃ n, b n ≤ t ∧ t < b (n+1) := by + have hbn : ∀ n, n ≤ b n := by + intro n + induction n with + | zero => exact Nat.zero_le _ + | succ n ih => have hh := h n; omega + have hex : ∃ n, t < b n := ⟨t+1,lt_of_lt_of_le (Nat.lt_succ_self t) (hbn (t+1))⟩ + let k := Nat.find hex + have hk : t < b k := Nat.find_spec hex + have hk0 : 0 < k := by + by_contra hn + have he : k=0 := by omega + rw [he,h0] at hk + omega + refine ⟨k-1,?_,?_⟩ + · have hh := Nat.find_min hex (show k-1 if bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω = k + then normalizedMeasure (bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ) else 0) := by + have hm := measurable_normalizedMeasure.comp + (bufferStageRetainedLaw_stopped_rows e f a z₀ r ε α g π hπ hH κ k) + convert hm using 1 + funext ω + dsimp only [Function.comp_def] + split <;> simp_all only [normalizedMeasure_zero] + +lemma bufferStage_success_stopped_rows {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) + {H : ℕ} (hH : 0 < H) (k : ℕ) : + MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) (a+k))] + {ω | bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω = k ∧ + BufferStageEvent (realPosition (step e)) f H z₀ r ε α g (π ω).val ω} := by + let ℓ := realPosition (step e) + by_cases h : k=H + · subst k + have heq := bufferFirstFailure_eq_measurable ℓ f a (z₀+(1-ε)*r) g π hπ H H + have hp : @Measurable _ _ (rowSigma (BelowHeight ℓ (a+H))) _ π := + hπ.mono (rowSigma_below_height_mono ℓ a H) le_rfl + have hm := (measurableSet_bufferStageEvent_rows ℓ f hH z₀ r ε α g (PairAtHeight ℓ a) + (BelowHeight ℓ (a+H)) (fun x hx => strip_subset_below_height ℓ a x hx le_rfl)).preimage + (hp.prodMk measurable_id) + exact heq.inter hm + · have he : {ω | bufferFirstFailure ℓ f a (z₀+(1-ε)*r) g π H ω = k ∧ + BufferStageEvent ℓ f H z₀ r ε α g (π ω).val ω} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro ω ⟨hk,hE⟩ + have hlast := bufferFirstFailure_eq_top_of_pass ℓ f a (z₀+(1-ε)*r) g π hH ω + ((bufferStageEvent_iff_last_tests ℓ f a z₀ r ε α g π hH ω).mp hE).1 + exact h (hk.symm.trans hlast) + change MeasurableSet[rowSigma (BelowHeight ℓ (a+k))] _ + rw [he] + exact @MeasurableSet.empty _ (rowSigma (BelowHeight ℓ (a+k))) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/ClippedPairGrowth.lean b/lean/OAI/Probability/Ballisticity/Walk/ClippedPairGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..462ea685d6cad44244d87d23729da8f3552894f8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/ClippedPairGrowth.lean @@ -0,0 +1,129 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.UniformLowerMass + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +noncomputable def centralPrefixMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (H : ℕ) (ω : Environment d) (x : Lattice d) : ℝ := + (quenchedKernel (ω,x)).real (TubePrefix ℓ f x θ z H) +noncomputable def jumpPrefixMass {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b a s : ℝ) (H : ℕ) (ω : Environment d) (x : Lattice d) : ℝ := + (quenchedKernel (ω,x)).real (EndpointPrefix ℓ x H {z | a < s*(signedCoordinate f (z-x)-b)}) +lemma centralPrefixMass_measurable {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ z : ℝ) (H : ℕ) : Measurable (fun p : Environment d × Lattice d => + centralPrefixMass ℓ f θ z H p.1 p.2) := by + apply Measurable.ennreal_toReal + apply measurable_from_prod_countable_left + intro x + exact (Kernel.measurable_coe _ (measurableSet_tubePrefix ℓ f x θ z H)).comp + (measurable_id.prodMk measurable_const) +lemma jumpPrefixMass_measurable {d : ℕ} (ℓ : Vector d) (f : Direction d) + (b a s : ℝ) (H : ℕ) : Measurable (fun p : Environment d × Lattice d => + jumpPrefixMass ℓ f b a s H p.1 p.2) := by + apply measurable_from_prod_countable_left + intro x + let E := EndpointPrefix ℓ x H {z | a < s*(signedCoordinate f (z-x)-b)} + have hE : MeasurableSet E := measurableSet_endpointPrefix ℓ x H _ + have hh : Measurable (fun ω : Environment d => quenchedKernel (ω,x) E) := + (Kernel.measurable_coe quenchedKernel hE).comp (measurable_id.prodMk measurable_const) + exact hh.ennreal_toReal + +theorem clipped_pair_favorable_fraction {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ a j c : ℝ, 0 < a ∧ 0 < j ∧ 0 < c ∧ ∀ δ : ℝ, 0 < δ → + ∃ d₀ R : ℝ, 0 < d₀ ∧ 0 < R ∧ ∀ r : ℝ, R ≤ r → + let H := ⌊fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r⌋₊ + 0 < H ∧ ∃ θ s : ℝ, (s=1 ∨ s= -1) ∧ + ∀ π : Measure (Lattice d × Lattice d), IsProbabilityMeasure π → + c ≤ (environmentLaw ν).real {ω | c ≤ ∫ x, + if j ≤ jumpPrefixMass (realPosition (step e)) f ((H:ℝ)*θ) (a*r) s H ω + (if s=1 then x.2 else x.1) ∧ + d₀ ≤ centralPrefixMass (realPosition (step e)) f θ (δ*r) H ω x.1 ∧ + d₀ ≤ centralPrefixMass (realPosition (step e)) f θ (δ*r) H ω x.2 + then (1:ℝ) else 0 ∂π} := by + let ℓ := realPosition (step e) + let n := fun r => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) r + obtain ⟨a,j,R,hapos,hjpos,hR,hjump⟩ := uniform_raw_jump ν hue e f hef htrans + refine ⟨a,j,j/4,hapos,hjpos,by positivity,fun δ hδ => ?_⟩ + obtain ⟨d₀,hd₀,hd₁,R₁,hR₁,hclip⟩ := clipping_uniform ν hue e f hef htrans + (by norm_num : 0 < (1:ℝ)) hδ (by positivity : 0 < j/4) + have hdfin : d₀ ≠ ∞ := ne_top_of_le_ne_top (by simp) hd₁ + have hd : 0 < d₀.toReal := ENNReal.toReal_pos (ne_of_gt hd₀) hdfin + refine ⟨d₀.toReal,max R R₁,hd,hR.trans_le (le_max_left _ _),fun r hr => ?_⟩ + obtain ⟨hH,hj⟩ := hjump r ((le_max_left R R₁).trans hr) + obtain ⟨θ,hθ⟩ := hclip r ((le_max_right R R₁).trans hr) + let H := ⌊n r⌋₊ + obtain ⟨s,hs,hjs⟩ := hj ((H:ℝ)*θ) + refine ⟨hH,θ,s,hs,fun π hπ => ?_⟩ + let := hπ + let A := fun (ω : Environment d) (x : Lattice d × Lattice d) => + j ≤ jumpPrefixMass ℓ f ((H:ℝ)*θ) (a*r) s H ω (if s=1 then x.2 else x.1) ∧ + d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x.1 ∧ + d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x.2 + have hm : MeasurableSet {p : Environment d × (Lattice d × Lattice d) | A p.1 p.2} := by + have h₁ := (jumpPrefixMass_measurable ℓ f ((H:ℝ)*θ) (a*r) s H).comp + (measurable_fst.prodMk ((measurable_of_countable (fun x : Lattice d × Lattice d => if s=1 then x.2 else x.1)).comp measurable_snd)) + have h₂ : Measurable (fun p : Environment d × (Lattice d × Lattice d) => centralPrefixMass ℓ f θ (δ*r) H p.1 p.2.1) := (centralPrefixMass_measurable ℓ f θ (δ*r) H).comp + (measurable_fst.prodMk measurable_snd.fst) + have h₃ : Measurable (fun p : Environment d × (Lattice d × Lattice d) => centralPrefixMass ℓ f θ (δ*r) H p.1 p.2.2) := (centralPrefixMass_measurable ℓ f θ (δ*r) H).comp + (measurable_fst.prodMk measurable_snd.snd) + exact (measurableSet_le measurable_const h₁).inter + ((measurableSet_le measurable_const h₂).inter (measurableSet_le measurable_const h₃)) + have hb (x : Lattice d) : (environmentLaw ν).real + {ω | ¬d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x} ≤ j/4 := by + have hnn : 0 ≤ n r := (Nat.floor_pos.mp hH).trans' (by norm_num) + have hHn : (H:ℝ) ≤ 1*n r := by simpa [H] using Nat.floor_le hnn + have hh := hθ x H hHn + have he : {ω | ¬d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x} = + {ω | quenchedKernel (ω,x) (TubePrefix ℓ f x θ (δ*r) H) < d₀} := by + ext ω + simp only [not_le,centralPrefixMass,Measure.real] + exact ENNReal.toReal_lt_toReal (measure_ne_top _ _) hdfin + simpa only [he] using hh.le + have hx (x : Lattice d × Lattice d) : j/2 ≤ (environmentLaw ν).real {ω | A ω x} := by + have hh := favorable_pair_probability (environmentLaw ν) + {ω | j ≤ jumpPrefixMass ℓ f ((H:ℝ)*θ) (a*r) s H ω (if s=1 then x.2 else x.1)} + {ω | d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x.1} + {ω | d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x.2} + (measurableSet_le measurable_const ((jumpPrefixMass_measurable ℓ f _ _ _ _).comp + (measurable_id.prodMk measurable_const))) + (measurableSet_le measurable_const ((centralPrefixMass_measurable ℓ f _ _ _).comp + (measurable_id.prodMk measurable_const))) + (measurableSet_le measurable_const ((centralPrefixMass_measurable ℓ f _ _ _).comp + (measurable_id.prodMk measurable_const))) + (hjs (if s=1 then x.2 else x.1)) (hb x.1) (hb x.2) + have he : j-2*(j/4)=j/2 := by ring + have hsA : ({ω | j ≤ jumpPrefixMass ℓ f ((H:ℝ)*θ) (a*r) s H ω (if s=1 then x.2 else x.1)} ∩ + {ω | d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x.1} ∩ + {ω | d₀.toReal ≤ centralPrefixMass ℓ f θ (δ*r) H ω x.2}) = {ω | A ω x} := by + ext ω; simp only [Set.mem_inter_iff,Set.mem_ofPred_eq,A,and_assoc] + simpa only [he,hsA] using hh + have hh := favorable_fraction_probability (environmentLaw ν) π A hm (by positivity : 0 ≤ j/2) hx + have he : (j/2)/2=j/4 := by ring + rw [he] at hh + convert hh using 1 + congr 1 + ext ω + simp only [Set.mem_ofPred_eq] + apply Iff.of_eq + congr 1 + apply integral_congr_ae + filter_upwards [] with x + dsimp [A,H,n,ℓ] + split_ifs <;> rfl +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/CompactPathModulus.lean b/lean/OAI/Probability/Ballisticity/Walk/CompactPathModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7dd4621d251db254fa5717b9fca68b155a92b76 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/CompactPathModulus.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GridOscillation + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma compact_path_modulus (K : Set C(unitInterval,ℝ)) (hK : IsCompact K) + {ε : ℝ} (hε : 0 < ε) : + ∃ δ, 0 < δ ∧ Disjoint K (ContinuousOscillation ε δ) := by + let : CompactSpace K := isCompact_iff_compactSpace.mp hK + have hc : Continuous (fun p : K × unitInterval => p.1.1 p.2) := + continuous_eval.comp ((continuous_subtype_val.comp continuous_fst).prodMk continuous_snd) + obtain ⟨δ,hδ,hm⟩ := Metric.uniformContinuous_iff.mp + (CompactSpace.uniformContinuous_of_continuous hc) ε hε + refine ⟨δ/2,by positivity,Set.disjoint_left.mpr ?_⟩ + rintro f hf ⟨s,t,hst,hbig⟩ + have hd : dist ((⟨f,hf⟩ : K),s) ((⟨f,hf⟩ : K),t) < δ := by + simpa only [Prod.dist_eq,dist_self,max_eq_right dist_nonneg] using hst.trans_lt (half_lt_self hδ) + have hh := hm hd + exact (not_lt_of_ge hbig.le) (by simpa only [Real.dist_eq] using hh) + +lemma tight_path_modulus (μ : ℕ → Measure C(unitInterval,ℝ)) + (ht : IsTightMeasureSet (Set.range μ)) {ε β : ℝ} (hε : 0 < ε) (hβ : 0 < β) : + ∃ δ, 0 < δ ∧ ∀ i, μ i (ContinuousOscillation ε δ) ≤ ENNReal.ofReal β := by + obtain ⟨K,hK,hKm⟩ := isTightMeasureSet_iff_exists_isCompact_measure_compl_le.mp ht (ENNReal.ofReal β) (ENNReal.ofReal_pos.mpr hβ) + obtain ⟨δ,hδ,hd⟩ := compact_path_modulus K hK hε + have hsub : ContinuousOscillation ε δ ⊆ Kᶜ := by + intro f hf hfK + exact Set.disjoint_left.mp hd hfK hf + exact ⟨δ,hδ,fun i => (measure_mono hsub).trans (hKm _ (Set.mem_range_self i))⟩ + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/CoordinateKernelComp.lean b/lean/OAI/Probability/Ballisticity/Walk/CoordinateKernelComp.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecc216c195336560d845c91636ce97e5dd0abeae --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/CoordinateKernelComp.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.FirstHitUpward + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma coordinate_raw_kernel_comp_le {d : ℕ} (e : Direction d) (k m : ℕ) + (ω : Environment d) (x : Lattice d) (U : Set (Lattice d)) : + (∫⁻ y, hitKernel (Strip (realPosition (step e)) y m) (Upper (realPosition (step e)) y m) (ω,y) U + ∂hitKernel (Strip (realPosition (step e)) x k) (Upper (realPosition (step e)) x k) (ω,x)) ≤ + hitKernel (Strip (realPosition (step e)) x (k+m)) (Upper (realPosition (step e)) x (k+m)) (ω,x) U := by + let ℓ := realPosition (step e) + let b := dot (realPosition x) ℓ+(k:ℝ) + let c := dot (realPosition x) ℓ+((k+m:ℕ):ℝ) + let S₂ : Set (Lattice d) := {y | b ≤ dot (realPosition y) ℓ ∧ dot (realPosition y) ℓ < c} + let T₂ : Set (Lattice d) := {y | c ≤ dot (realPosition y) ℓ} + have he : (∫⁻ y, hitKernel (Strip ℓ y m) (Upper ℓ y m) (ω,y) U + ∂hitKernel (Strip ℓ x k) (Upper ℓ x k) (ω,x)) = + ∫⁻ y, hitKernel S₂ T₂ (ω,y) U ∂hitKernel (Strip ℓ x k) (Upper ℓ x k) (ω,x) := by + apply lintegral_congr_ae + filter_upwards [coordinate_hitKernel_supported e x k ω] with y hy + have hproj : dot (realPosition y) ℓ=b := by + dsimp [ℓ,b] + rw [signedHeight_projection,signedHeight_projection] + exact_mod_cast hy + have hS : Strip ℓ y m=S₂ := by + ext z + simp only [Strip,Set.mem_ofPred_eq,S₂,hproj,b,c,Nat.cast_add,add_assoc] + have hT : Upper ℓ y m=T₂ := by + ext z + simp only [Upper,Set.mem_ofPred_eq,T₂,hproj,b,c,Nat.cast_add,add_assoc] + rw [hS,hT] + rw [he] + have hd : Disjoint S₂ T₂ := Set.disjoint_left.mpr (fun y hy hz => (not_lt_of_ge hz) hy.2) + have hT : T₂=Upper ℓ x (k+m) := by + simp only [T₂,Upper,c,Nat.cast_add] + have hk : Strip ℓ x k ⊆ Strip ℓ x (k+m) := by + intro y hy + refine ⟨hy.1,?_⟩ + dsimp [Strip] at hy ⊢ + have := Nat.cast_nonneg (α := ℝ) m + linarith [hy.2] + have hm : S₂ ⊆ Strip ℓ x (k+m) := by + intro y hy + refine ⟨?_,by simpa only [c,Nat.cast_add] using hy.2⟩ + dsimp [S₂,b,Strip] at hy ⊢ + have := Nat.cast_nonneg (α := ℝ) k + linarith [hy.1] + have hh := hitKernel_comp_le ω x (disjoint_strip_upper ℓ x k) hd + (hT ▸ disjoint_strip_upper ℓ x (k+m)) hk hm U + simpa only [hT] using hh +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/CurvePolicyKernel.lean b/lean/OAI/Probability/Ballisticity/Walk/CurvePolicyKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..71eeb0596ca22d6069f2fc68edc38cce664f947c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/CurvePolicyKernel.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.CurvePolicyPMF +import OAI.Probability.Ballisticity.Estimates.CurvePolicyLateral +import OAI.Probability.Ballisticity.Estimates.BindIntegral + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +noncomputable def curvePolicyKernel {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (b : ℕ → ℝ) (B : ℝ) {H : ℕ} (hH : 0 < H) + (E : Set (Lattice d)) (δ α : ℝ≥0∞) (dummy : Lattice d) : + Kernel (Environment d) (Lattice d) where + toFun := curvePolicy ℓ f x b B H E δ α dummy + measurable' := (curvePolicy_rows ℓ f x b B hH E δ α dummy).mono (rowSigma_le _) le_rfl + +lemma curvePolicyKernel_markov {d : ℕ} (ℓ : Vector d) (f : Direction d) + (x : Lattice d) (b : ℕ → ℝ) (B : ℝ) {H : ℕ} (hH : 0 < H) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (dummy : Lattice d) : + IsMarkovKernel (curvePolicyKernel ℓ f x b B hH E δ α dummy) := + ⟨curvePolicy_probability ℓ f x b B H E hδ hα dummy⟩ + +lemma curvePolicy_average_toMeasure {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) (b : ℕ → ℝ) (B : ℝ) {H : ℕ} (hH : 0 < H) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) (dummy : Lattice d) : + (curvePolicy_average ν ℓ f b B hH E hδ hα dummy).toMeasure = + (environmentLaw ν).bind (curvePolicy ℓ f 0 b B H E δ α dummy) := by + have := curvePolicy_average_probability ν ℓ f b B hH E hδ hα dummy + exact Measure.toPMF_toMeasure _ + +lemma curvePolicy_average_square {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (b : ℕ → ℝ) {B : ℝ} (hB : 0 ≤ B) {H : ℕ} (hH : 0 < H) + (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) + (dummy : Lattice d) (hd : signedCoordinate f dummy = b H) : + (∫ u, (signedCoordinate f u-b H)^2 ∂(curvePolicy_average ν (realPosition (step e)) f b B hH E hδ hα dummy).toMeasure) = + ∫ ω, ∫ u, (signedCoordinate f u-b H)^2 ∂curvePolicy (realPosition (step e)) f 0 b B H E δ α dummy ω ∂environmentLaw ν := by + rw [curvePolicy_average_toMeasure] + exact integral_bind_nonneg_of_integrable _ _ + ((curvePolicy_rows _ f 0 b B hH E δ α dummy).mono (rowSigma_le _) le_rfl) + _ (measurable_of_countable _) (fun u => sq_nonneg _) (curvePolicy_square_integrable e f 0 b hB hH E hδ hα dummy hd) + +lemma curvePolicy_square_outer_integrable {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (x : Lattice d) (b : ℕ → ℝ) {B : ℝ} (hB : 0 ≤ B) + {H : ℕ} (hH : 0 < H) (E : Set (Lattice d)) {δ α : ℝ≥0∞} (hδ : 0 < δ) (hα : 0 < α) + (dummy : Lattice d) (hd : signedCoordinate f dummy = b H) : + Integrable (fun ω => ∫ u, (signedCoordinate f u-b H)^2 ∂curvePolicy (realPosition (step e)) f x b B H E δ α dummy ω) + (environmentLaw ν) := by + let Q := curvePolicyKernel (realPosition (step e)) f x b B hH E δ α dummy + have hm : Measurable (fun ω => ∫ u, (signedCoordinate f u-b H)^2 ∂Q ω) := + (measurable_of_countable _).stronglyMeasurable.integral_kernel.measurable + apply Integrable.of_bound hm.aestronglyMeasurable (B^2) + apply Eventually.of_forall + intro ω + have := curvePolicy_probability (realPosition (step e)) f x b B H E hδ hα dummy ω + have hi := curvePolicy_square_integrable e f x b hB hH E hδ hα dummy hd ω + have hh : (∫ u, (signedCoordinate f u-b H)^2 ∂curvePolicy (realPosition (step e)) f x b B H E δ α dummy ω) ≤ B^2 := by + have hb : ∀ᵐ u ∂curvePolicy (realPosition (step e)) f x b B H E δ α dummy ω, + (signedCoordinate f u-b H)^2 ≤ B^2 := by + filter_upwards [curvePolicy_lateral_bound e f x b hB hH E δ α dummy hd ω] with u hu + nlinarith [sq_abs (signedCoordinate f u-b H),sq_nonneg (B-|signedCoordinate f u-b H|),abs_nonneg (signedCoordinate f u-b H)] + simpa using integral_mono_ae hi (integrable_const (B^2)) hb + have h0 : 0 ≤ ∫ u, (signedCoordinate f u-b H)^2 ∂Q ω := integral_nonneg (fun u => sq_nonneg (signedCoordinate f u-b H)) + rw [Real.norm_eq_abs,abs_of_nonneg h0] + exact hh + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/FiniteOutwardRowApproximation.lean b/lean/OAI/Probability/Ballisticity/Walk/FiniteOutwardRowApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c5a8f99470108dc72c9246abee1b56bcd68c827 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/FiniteOutwardRowApproximation.lean @@ -0,0 +1,74 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.FiniteLogStability + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma upperPairNeighborhood_mono {d : ℕ} (e : Direction d) (a : ℝ) + (x : Lattice d × Lattice d) {N R : ℕ} (hNR : N ≤ R) : + upperPairNeighborhood e a x N ⊆ upperPairNeighborhood e a x R := by + intro y hy + refine ⟨?_,hy.2⟩ + have hball (z : Lattice d) : LatticeBall z N ⊆ LatticeBall z R := by + intro w hw i + exact (hw i).trans (by exact_mod_cast hNR) + exact hy.1.elim (fun h => Or.inl (hball _ h)) (fun h => Or.inr (hball _ h)) + +lemma finite_outward_upper_row_approximation {d : ℕ} {κ : ℝ≥0} (hκ : 0 < κ) + (e f : Direction d) (A : ℝ) (N : ℕ) {ε B : ℝ} (hε : 0 < ε) (hB : 0 ≤ B) : + ∃ R : ℕ, ∀ (a : ℝ) (x : Lattice d × Lattice d), x ∈ PairAtHeight (realPosition (step e)) a → + ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ B) ∧ + (∀ ω, (∀ y g, κ ≤ (ω y).1 g) → + |min (finiteLogExcess A (fun n => outwardKernelMass e f (n+1) x) N ω) B-F ω| ≤ ε) := by + have hloc (n : ℕ) := outwardLog_fixed_height_locality hκ e f (Nat.succ_pos n) hε + choose r hr using hloc + obtain ⟨R,hR⟩ := ((Finset.range (N+1)).image r).exists_le + refine ⟨R,?_⟩ + intro a x hx + let q : ℕ → Environment d → ℝ := fun n ω => outwardKernelMass e f (n+1) x (upperPairPatch e a x (r n) ω) + let F : Environment d → ℝ := fun ω => min (finiteLogExcess A q N ω) B + refine ⟨F,?_,?_,?_⟩ + · have hm : @Measurable _ _ (rowSigma (upperPairNeighborhood e a x R)) _ (finiteLogExcess A q N) := by + unfold finiteLogExcess + apply Measurable.ennreal_toReal + apply Measurable.iSup + intro n + have hnr : r n ≤ R := hR (r n) (Finset.mem_image.mpr ⟨n,Finset.mem_range.mpr n.isLt,rfl⟩) + have hp := (upperPairPatch_measurable e a x hx (r n)).mono + (rowSigma_mono (upperPairNeighborhood_mono e a x hnr)) le_rfl + have hq := (measurable_outwardKernelMass e f (n+1) x).comp hp + exact (hq.log.neg.sub_const _).ennreal_ofReal + exact hm.min measurable_const + · intro ω + exact ⟨le_min ENNReal.toReal_nonneg hB,min_le_right _ _⟩ + · intro ω hω + have hd := finiteLogExcess_stability A (fun n => outwardKernelMass e f (n+1) x) q N ω hε.le + (fun n hn => (hr n a x hx ω hω).le) + have h₁ := (abs_le.mp hd).1 + have h₂ := (abs_le.mp hd).2 + apply abs_le.mpr + constructor + · have hh : min (finiteLogExcess A q N ω) B ≤ min (finiteLogExcess A (fun n => outwardKernelMass e f (n+1) x) N ω) B+ε := by + have ht := min_le_min (show finiteLogExcess A q N ω ≤ finiteLogExcess A (fun n => outwardKernelMass e f (n+1) x) N ω+ε by linarith) (show B ≤ B+ε by linarith) + simpa only [min_add_add_right] using ht + exact by dsimp [F]; linarith + · have hh : min (finiteLogExcess A (fun n => outwardKernelMass e f (n+1) x) N ω) B ≤ min (finiteLogExcess A q N ω) B+ε := by + have ht := min_le_min (show finiteLogExcess A (fun n => outwardKernelMass e f (n+1) x) N ω ≤ finiteLogExcess A q N ω+ε by linarith) (show B ≤ B+ε by linarith) + simpa only [min_add_add_right] using ht + exact by dsimp [F]; linarith +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/FixedQuenchedKernel.lean b/lean/OAI/Probability/Ballisticity/Walk/FixedQuenchedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a62725e3ef9327c9d0c50c0293b551134876250 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/FixedQuenchedKernel.lean @@ -0,0 +1,423 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.WordCoordinate + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma conditioned_word_spatial_strong_laws {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (e : Direction d) : + ∀ᵐ X ∂conditionedLaw ν ℓ, + Tendsto (fun n : ℕ => (∑ i ∈ Finset.range n, wordCoordinate e (regenerationWords ℓ X i))/n) + atTop (𝓝 (∫ Y, wordCoordinate e (firstWord ℓ Y) ∂conditionedLaw ν ℓ)) ∧ + Tendsto (fun n : ℕ => wordRadius (regenerationWords ℓ X n)/n) atTop (𝓝 0) := by + have hi := regenerationWords_independent ν ℓ htrans + have hd := regenerationWords_identDistrib ν ℓ htrans + have hmc : Measurable (wordCoordinate e) := measurable_of_countable _ + have hc := strong_law_ae_real (fun n X => wordCoordinate e (regenerationWords ℓ X n)) + (conditioned_wordCoordinate_integrable ν hue ℓ hℓ htrans e) + (fun i j hij => (hi.indepFun hij).comp hmc hmc) (fun i => (hd i).comp hmc) + have hr := strong_law_ae_real (fun n X => wordRadius (regenerationWords ℓ X n)) + (conditioned_wordRadius_integrable ν hue ℓ hℓ htrans) + (fun i j hij => (hi.indepFun hij).comp measurable_wordRadius measurable_wordRadius) + (fun i => (hd i).comp measurable_wordRadius) + filter_upwards [hc,hr] with X hX hR + exact ⟨hX, increment_sublinear_of_average _ _ hR⟩ + +lemma increasing_cuts_index_tendsto (T K : ℕ → ℕ) (hT : StrictMono T) + (hK : ∀ n, T (K n) ≤ n ∧ n < T (K n+1)) : Tendsto K atTop atTop := by + apply tendsto_atTop.mpr + intro M + filter_upwards [eventually_ge_atTop (T M)] with n hn + by_contra hm + have hh := hT.monotone (show K n+1 ≤ M by omega) + exact (not_lt_of_ge (hh.trans hn)) (hK n).2 + +lemma scalar_cut_interpolation (T : ℕ → ℕ) (hT : StrictMono T) (hT0 : T 0 = 0) + (Y f R : ℕ → ℝ) (m : ℝ) (hm : 0 < m) + (hY : ∀ n, Y (T n) = ∑ i ∈ Finset.range n, f i) + (herr : ∀ k n, T k ≤ n → n < T (k+1) → |Y n-Y (T k)| ≤ R k) + (hf : Tendsto (fun n : ℕ => (∑ i ∈ Finset.range n, f i)/n) atTop (𝓝 m)) + (hR : Tendsto (fun n : ℕ => R n/n) atTop (𝓝 0)) : Tendsto Y atTop atTop := by + choose K hK using increasing_cuts_cover T hT hT0 + have hKt := increasing_cuts_index_tendsto T K hT hK + have hh := (hf.sub hR).comp hKt + simp only [sub_zero] at hh + have hmul := hh.pos_mul_atTop hm (tendsto_natCast_atTop_atTop.comp hKt) + apply tendsto_atTop_mono' _ _ hmul + filter_upwards [hKt.eventually (eventually_gt_atTop (0 : ℕ))] with n hn + have hk : (K n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (ne_of_gt hn) + have he := neg_le_of_abs_le (herr (K n) n (hK n).1 (hK n).2) + simp only [Function.comp_apply, sub_mul, div_mul_cancel₀ _ hk] + rw [← hY] + linarith only [he] + +lemma regeneration_coordinate_sum {d : ℕ} (ℓ : Vector d) (e : Direction d) + (X : Path d) (hX : X ∈ RegenerationSupport ℓ) (n : ℕ) : + signedCoordinate e (X (regenerationTimes ℓ X n)) = + ∑ i ∈ Finset.range n, wordCoordinate e (regenerationWords ℓ X i) := by + induction n with + | zero => simp [hX.1, signedCoordinate] + | succ n ih => + rw [regenerationTimes_succ, regeneration_span ℓ X hX.1 hX.2 n _ (by rfl), + signedCoordinate_add, ih, Finset.sum_range_succ, wordCoordinate] + +lemma conditioned_coordinate_transience {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) (e : Direction d) + (he : 0 < ∫ X, wordCoordinate e (firstWord ℓ X) ∂conditionedLaw ν ℓ) : + ∀ᵐ X ∂conditionedLaw ν ℓ, Tendsto (fun n => signedCoordinate e (X n)) atTop atTop := by + filter_upwards [conditioned_regenerationSupport ν ℓ htrans, + conditioned_word_spatial_strong_laws ν hue ℓ hℓ htrans e] with X hX hlim + apply scalar_cut_interpolation (regenerationTimes ℓ X) + (regenerationTimes_strictMono ℓ X hX.2) (regenerationTimes_zero ℓ X) + (fun n => signedCoordinate e (X n)) (fun n => wordCoordinate e (regenerationWords ℓ X n)) + (fun n => wordRadius (regenerationWords ℓ X n)) _ he + (regeneration_coordinate_sum ℓ e X hX) _ hlim.1 hlim.2 + intro k n hlo hhi + have hnk : n = regenerationTimes ℓ X k+(n-regenerationTimes ℓ X k) := by omega + have hlen : n-regenerationTimes ℓ X k ≤ (regenerationWords ℓ X k).length := by + rw [regenerationTimes_succ] at hhi + omega + have hh := regeneration_span ℓ X hX.1 hX.2 k _ hlen + rw [← hnk] at hh + rw [hh, signedCoordinate_add, add_sub_cancel_left] + exact (signedCoordinate_abs_le_norm _ _).trans (wordRadius_bound _ hlen) + +lemma conditioned_to_annealed_transience {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ u : Vector d) (htrans : DirectionallyTransient ν ℓ) + (hu : ∀ᵐ X ∂conditionedLaw ν ℓ, X ∈ TransientPaths u) : DirectionallyTransient ν u := by + let B := NoDrop ℓ 0 ∩ (TransientPaths u)ᶜ + have hB : MeasurableSet B := (measurableSet_noDrop ℓ 0).inter (measurableSet_transientPaths u).compl + have hBD : B ⊆ NoDrop ℓ 0 := Set.inter_subset_left + have hcB : conditionedLaw ν ℓ B = 0 := + measure_mono_null Set.inter_subset_right (ae_iff.mp hu) + have haB : annealedLaw ν B = 0 := by + rw [conditionedLaw_apply_of_subset ν ℓ B hB hBD] at hcB + exact (mul_eq_zero.mp hcB).resolve_left (ENNReal.inv_ne_zero.mpr (measure_ne_top _ _)) + have hwords : ∀ᵐ X ∂annealedLaw ν, ∀ w : List (Direction d), + (∀ y ∈ wordDepartures 0 w, dot (realPosition y) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ) → + X ∈ wordCylinder 0 w → + (fun j => X (w.length+j)-wordPath 0 w w.length) ∉ B := by + apply ae_all_iff.mpr + intro w + by_cases hw : ∀ y ∈ wordDepartures 0 w, dot (realPosition y) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ + · have hz := annealed_record_suffix ν ℓ w hw B hB hBD + rw [haB, mul_zero] at hz + filter_upwards [measure_eq_zero_iff_ae_notMem.mp hz] with X hX _ hcy + exact fun hh => hX ⟨hh,hcy⟩ + · exact Filter.Eventually.of_forall fun _ h _ => (hw h).elim + filter_upwards [annealed_initial ν, annealed_nearest_neighbor ν, + annealed_trueRecords_unbounded ν ℓ htrans, hwords] with X h0 hnn hrec hwords + obtain ⟨n,_,hn⟩ := hrec 0 + obtain ⟨w,hw,hcy⟩ := exists_word_prefix X hnn n + rw [h0] at hcy + have hwend : wordPath 0 w w.length = X n := by rw [← hw]; exact (hcy _ le_rfl).symm + have hwrec : ∀ y ∈ wordDepartures 0 w, dot (realPosition y) ℓ < + dot (realPosition (wordPath 0 w w.length)) ℓ := by + intro y hy + obtain ⟨j,hj,rfl⟩ := (wordDepartures_mem_iff 0 y w).mp hy + rw [← hcy j hj.le, hwend] + exact hn.1 j (by omega) + have hnot := hwords w hwrec hcy + have hD : (fun j => X (w.length+j)-wordPath 0 w w.length) ∈ NoDrop ℓ 0 := by + intro j + rw [hwend, hw, dot_realPosition_sub] + have hh := hn.2 j + simpa only [dot, realPosition, Pi.zero_apply, Int.cast_zero, zero_mul, Finset.sum_const_zero, + sub_nonneg] using hh + have ht : (fun j => X (n+j)-X n) ∈ TransientPaths u := by + by_contra hh + apply hnot + refine ⟨hD, ?_⟩ + change (fun j => X (w.length+j)-wordPath 0 w w.length) ∉ TransientPaths u + rw [hwend, hw] + exact hh + have hraw : (fun j => X (n+j)) ∈ TransientPaths u := by + change (fun j => X (n+j)) ∈ (fun Z : Path d => fun j => Z j-X n) ⁻¹' TransientPaths u at ht + rwa [transientPaths_translation] at ht + change Tendsto (fun j => dot (realPosition (X j)) u) atTop atTop + change Tendsto (fun j => dot (realPosition (X (n+j))) u) atTop atTop at hraw + exact (tendsto_add_atTop_iff_nat n).mp (by simpa only [Nat.add_comm] using hraw) + +lemma dot_comm {d : ℕ} (v w : Vector d) : dot v w = dot w v := by + simp only [dot, mul_comm] + +lemma dot_signed_direction {d : ℕ} (e : Direction d) (x : Lattice d) : + dot (realPosition x) (realPosition (step e)) = signedCoordinate e x := by + rw [dot_comm, dot_step] + rfl + +lemma signed_direction_unit {d : ℕ} (e : Direction d) : + dot (realPosition (step e)) (realPosition (step e)) = 1 := by + rw [dot_step] + simp only [realPosition,step,ite_true,Int.cast_ite,Int.cast_one,Int.cast_neg] + cases e.2 <;> norm_num + +lemma exists_transient_signed_coordinate {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : ∃ e : Direction d, + DirectionallyTransient ν (realPosition (step e)) := by + obtain ⟨e,he⟩ := conditioned_coordinate_positive_mean ν hue ℓ hℓ htrans + refine ⟨e, conditioned_to_annealed_transience ν ℓ (realPosition (step e)) htrans ?_⟩ + have hh := conditioned_coordinate_transience ν hue ℓ hℓ htrans e he + simpa only [TransientPaths, Set.mem_ofPred_eq, dot_signed_direction] using hh + +noncomputable def fixedQuenchedKernel {d : ℕ} (x : Lattice d) : + Kernel (Environment d) (Path d) := + quenchedKernel.comap (fun ω => (ω,x)) (measurable_id.prodMk measurable_const) + +instance fixedQuenchedKernel_markov {d : ℕ} (x : Lattice d) : + IsMarkovKernel (fixedQuenchedKernel x) := by unfold fixedQuenchedKernel; infer_instance + +noncomputable def sharedPairKernel {d : ℕ} (x y : Lattice d) : + Kernel (Environment d) (Path d × Path d) := + (fixedQuenchedKernel x).prod (fixedQuenchedKernel y) + +instance sharedPairKernel_markov {d : ℕ} (x y : Lattice d) : + IsMarkovKernel (sharedPairKernel x y) := by unfold sharedPairKernel; infer_instance + +noncomputable def sharedPairLaw {d : ℕ} (ν : Measure (Row d)) (x y : Lattice d) : + Measure (Path d × Path d) := sharedPairKernel x y ∘ₘ environmentLaw ν + +instance sharedPairLaw_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x y : Lattice d) : IsProbabilityMeasure (sharedPairLaw ν x y) := by + unfold sharedPairLaw + infer_instance + +noncomputable def sharedNoDropMass {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (x y : Lattice d) : ℝ≥0∞ := + ∫⁻ ω, noDropQuenched ℓ x ω * noDropQuenched ℓ y ω ∂environmentLaw ν + +lemma sharedPairLaw_rectangle {d : ℕ} (ν : Measure (Row d)) (x y : Lattice d) + (A B : Set (Path d)) (hA : MeasurableSet A) (hB : MeasurableSet B) : + sharedPairLaw ν x y (A ×ˢ B) = + ∫⁻ ω, quenchedKernel (ω,x) A * quenchedKernel (ω,y) B ∂environmentLaw ν := by + rw [sharedPairLaw, Measure.bind_apply (hA.prod hB) (Kernel.aemeasurable _)] + apply lintegral_congr + intro ω + rw [sharedPairKernel, Kernel.prod_apply, Measure.prod_prod] + rfl + +lemma sharedNoDropMass_eq {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) (x y : Lattice d) : + sharedNoDropMass ν ℓ x y = sharedPairLaw ν x y (NoDrop ℓ x ×ˢ NoDrop ℓ y) := + (sharedPairLaw_rectangle ν x y _ _ (measurableSet_noDrop ℓ x) (measurableSet_noDrop ℓ y)).symm + +lemma sharedNoDropMass_le_one {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) : sharedNoDropMass ν ℓ x y ≤ 1 := by + rw [sharedNoDropMass_eq] + exact prob_le_one + +lemma sharedNoDropMass_uniform_positive {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (ℓ : Vector d) (hℓ : dot ℓ ℓ = 1) + (htrans : DirectionallyTransient ν ℓ) : + ∃ c : ℝ≥0∞, 0 < c ∧ ∀ x y : Lattice d, c ≤ sharedNoDropMass ν ℓ x y := by + obtain ⟨s,hs,_,hsmall⟩ := positive_random_small_set (environmentLaw ν) (noDropQuenched ℓ 0) + (measurable_noDropQuenched ℓ 0) + ((quenched_noDrop_positive_of_directionallyTransient ν hue ℓ hℓ htrans).mono fun _ h => h 0) + refine ⟨(s : ℝ≥0∞)^2 / 2, ENNReal.div_pos (pow_ne_zero _ (by exact_mod_cast hs.ne')) (by norm_num), ?_⟩ + intro x y + let μ := environmentLaw ν + let A := {ω | noDropQuenched ℓ x ω ≤ 2*(s : ℝ≥0∞)} + let B := {ω | noDropQuenched ℓ y ω ≤ 2*(s : ℝ≥0∞)} + have hA : MeasurableSet A := measurableSet_le (measurable_noDropQuenched ℓ x) measurable_const + have hB : MeasurableSet B := measurableSet_le (measurable_noDropQuenched ℓ y) measurable_const + have hsa : μ A < 1/4 := by + rw [show μ A = environmentLaw ν {ω | noDropQuenched ℓ 0 ω ≤ 2*(s : ℝ≥0∞)} from + noDropQuenched_small_translation ν ℓ x _] + exact hsmall + have hsb : μ B < 1/4 := by + rw [show μ B = environmentLaw ν {ω | noDropQuenched ℓ 0 ω ≤ 2*(s : ℝ≥0∞)} from + noDropQuenched_small_translation ν ℓ y _] + exact hsmall + have hsa' : μ.real A < 1/4 := by + have hh := (ENNReal.toReal_lt_toReal (measure_ne_top μ A) (by norm_num)).mpr hsa + norm_num at hh + exact hh + have hsb' : μ.real B < 1/4 := by + have hh := (ENNReal.toReal_lt_toReal (measure_ne_top μ B) (by norm_num)).mpr hsb + norm_num at hh + exact hh + have hgood : (1 : ℝ≥0∞)/2 ≤ μ (A ∪ B)ᶜ := by + apply (ENNReal.toReal_le_toReal (by norm_num) (measure_ne_top μ _)).mp + change ((1 : ℝ≥0∞)/2).toReal ≤ μ.real (A ∪ B)ᶜ + rw [probReal_compl_eq_one_sub (hA.union hB)] + norm_num only [ENNReal.toReal_div, ENNReal.toReal_one, ENNReal.toReal_ofNat] + linarith only [measureReal_union_le (μ := μ) A B, hsa', hsb'] + have hsub : (A ∪ B)ᶜ ⊆ {ω | (s : ℝ≥0∞)^2 ≤ + noDropQuenched ℓ x ω * noDropQuenched ℓ y ω} := by + intro ω hω + have hx : ¬noDropQuenched ℓ x ω ≤ 2*(s : ℝ≥0∞) := fun h => hω (Or.inl h) + have hy : ¬noDropQuenched ℓ y ω ≤ 2*(s : ℝ≥0∞) := fun h => hω (Or.inr h) + have hs2 : (s : ℝ≥0∞) ≤ 2*(s : ℝ≥0∞) := by + simpa only [one_mul] using mul_le_mul_left (by norm_num : (1 : ℝ≥0∞) ≤ 2) (s : ℝ≥0∞) + rw [pow_two] + exact mul_le_mul' (hs2.trans (le_of_not_ge hx)) (hs2.trans (le_of_not_ge hy)) + calc + (s : ℝ≥0∞)^2/2 = (s : ℝ≥0∞)^2 * (1/2) := by rw [div_eq_mul_inv, one_div] + _ ≤ (s : ℝ≥0∞)^2 * μ {ω | (s : ℝ≥0∞)^2 ≤ + noDropQuenched ℓ x ω * noDropQuenched ℓ y ω} := + mul_le_mul_right (hgood.trans (measure_mono hsub)) _ + _ ≤ sharedNoDropMass ν ℓ x y := + mul_meas_ge_le_lintegral₀ + ((measurable_noDropQuenched ℓ x).mul (measurable_noDropQuenched ℓ y)).aemeasurable _ + +noncomputable def sharedConditionedPairLaw {d : ℕ} (ν : Measure (Row d)) + (ℓ : Vector d) (x y : Lattice d) : Measure (Path d × Path d) := + (sharedNoDropMass ν ℓ x y)⁻¹ • + (sharedPairLaw ν x y).restrict (NoDrop ℓ x ×ˢ NoDrop ℓ y) + +lemma sharedConditionedPairLaw_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) (hp : sharedNoDropMass ν ℓ x y ≠ 0) : + IsProbabilityMeasure (sharedConditionedPairLaw ν ℓ x y) := by + constructor + simp only [sharedConditionedPairLaw, Measure.smul_apply, Measure.restrict_apply MeasurableSet.univ, + Set.univ_inter, smul_eq_mul, ← sharedNoDropMass_eq] + exact ENNReal.inv_mul_cancel hp (ne_of_lt ((sharedNoDropMass_le_one ν ℓ x y).trans_lt (by simp))) + +noncomputable def annealedFrom {d : ℕ} (ν : Measure (Row d)) (x : Lattice d) : + Measure (Path d) := fixedQuenchedKernel x ∘ₘ environmentLaw ν + +instance annealedFrom_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x : Lattice d) : IsProbabilityMeasure (annealedFrom ν x) := by + unfold annealedFrom + infer_instance + +lemma annealedFrom_apply {d : ℕ} (ν : Measure (Row d)) (x : Lattice d) + (A : Set (Path d)) (hA : MeasurableSet A) : + annealedFrom ν x A = ∫⁻ ω, quenchedKernel (ω,x) A ∂environmentLaw ν := by + rw [annealedFrom, Measure.bind_apply hA (Kernel.aemeasurable _)] + rfl + +lemma annealedFrom_noDrop {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x : Lattice d) : + annealedFrom ν x (NoDrop ℓ x) = annealedLaw ν (NoDrop ℓ 0) := by + rw [annealedFrom_apply ν x _ (measurableSet_noDrop ℓ x)] + exact annealed_noDrop_translation ν ℓ x + +noncomputable def conditionedFrom {d : ℕ} (ν : Measure (Row d)) (ℓ : Vector d) + (x : Lattice d) : Measure (Path d) := + (annealedLaw ν (NoDrop ℓ 0))⁻¹ • (annealedFrom ν x).restrict (NoDrop ℓ x) + +lemma conditionedFrom_probability {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x : Lattice d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) : + IsProbabilityMeasure (conditionedFrom ν ℓ x) := by + constructor + simp only [conditionedFrom, Measure.smul_apply, Measure.restrict_apply MeasurableSet.univ, + Set.univ_inter, smul_eq_mul, annealedFrom_noDrop] + exact ENNReal.inv_mul_cancel hp (measure_ne_top _ _) + +lemma sharedConditionedPairLaw_fst_le {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) (A : Set (Path d)) (hA : MeasurableSet A) + (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) : + sharedConditionedPairLaw ν ℓ x y (Prod.fst ⁻¹' A) ≤ + (sharedNoDropMass ν ℓ x y)⁻¹ * annealedLaw ν (NoDrop ℓ 0) * + conditionedFrom ν ℓ x A := by + rw [sharedConditionedPairLaw, Measure.smul_apply, + Measure.restrict_apply (hA.preimage measurable_fst)] + have he : Prod.fst ⁻¹' A ∩ (NoDrop ℓ x ×ˢ NoDrop ℓ y) = + (A ∩ NoDrop ℓ x) ×ˢ NoDrop ℓ y := by + ext z + exact and_assoc.symm + rw [he, sharedPairLaw_rectangle ν x y _ _ (hA.inter (measurableSet_noDrop ℓ x)) + (measurableSet_noDrop ℓ y)] + simp only [smul_eq_mul, conditionedFrom, Measure.smul_apply, + Measure.restrict_apply hA] + rw [← mul_assoc, mul_assoc _ (annealedLaw ν (NoDrop ℓ 0)), + ENNReal.mul_inv_cancel hp (measure_ne_top _ _), mul_one] + apply mul_le_mul_right + rw [annealedFrom_apply ν x _ (hA.inter (measurableSet_noDrop ℓ x))] + exact lintegral_mono fun ω => mul_le_of_le_one_right' prob_le_one + +lemma sharedConditionedPairLaw_snd_le {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (x y : Lattice d) (A : Set (Path d)) (hA : MeasurableSet A) + (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) : + sharedConditionedPairLaw ν ℓ x y (Prod.snd ⁻¹' A) ≤ + (sharedNoDropMass ν ℓ x y)⁻¹ * annealedLaw ν (NoDrop ℓ 0) * + conditionedFrom ν ℓ y A := by + rw [sharedConditionedPairLaw, Measure.smul_apply, + Measure.restrict_apply (hA.preimage measurable_snd)] + have he : Prod.snd ⁻¹' A ∩ (NoDrop ℓ x ×ˢ NoDrop ℓ y) = + NoDrop ℓ x ×ˢ (A ∩ NoDrop ℓ y) := by + ext z + simp only [Set.mem_inter_iff, Set.mem_preimage, Set.mem_prod] + tauto + rw [he, sharedPairLaw_rectangle ν x y _ _ (measurableSet_noDrop ℓ x) + (hA.inter (measurableSet_noDrop ℓ y))] + simp only [smul_eq_mul, conditionedFrom, Measure.smul_apply, + Measure.restrict_apply hA] + rw [← mul_assoc, mul_assoc _ (annealedLaw ν (NoDrop ℓ 0)), + ENNReal.mul_inv_cancel hp (measure_ne_top _ _), mul_one] + apply mul_le_mul_right + rw [annealedFrom_apply ν y _ (hA.inter (measurableSet_noDrop ℓ y))] + exact lintegral_mono fun ω => mul_le_of_le_one_left' prob_le_one + +lemma shared_pair_word_suffix {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (x y : Lattice d) (w v : List (Direction d)) (T : Set (Lattice d)) + (hx : wordPath x w w.length ∈ T) (hy : wordPath y v v.length ∈ T) + (hdis : Disjoint ((wordDepartures x w : Set (Lattice d)) ∪ wordDepartures y v) T) + (A B : Set (Path d)) (hA : MeasurableSet A) (hB : MeasurableSet B) + (hAT : A ⊆ Stay T) (hBT : B ⊆ Stay T) : + sharedPairLaw ν x y + (((fun X : Path d => fun j => X (w.length+j)) ⁻¹' A ∩ wordCylinder x w) ×ˢ + ((fun X : Path d => fun j => X (v.length+j)) ⁻¹' B ∩ wordCylinder y v)) = + sharedPairLaw ν x y (wordCylinder x w ×ˢ wordCylinder y v) * + sharedPairLaw ν (wordPath x w w.length) (wordPath y v v.length) (A ×ˢ B) := by + let S : Set (Lattice d) := (wordDepartures x w : Set (Lattice d)) ∪ wordDepartures y v + have hmA : MeasurableSet ((fun X : Path d => fun j => X (w.length+j)) ⁻¹' A ∩ + wordCylinder x w) := (hA.preimage (by fun_prop)).inter (measurableSet_wordCylinder x w) + have hmB : MeasurableSet ((fun X : Path d => fun j => X (v.length+j)) ⁻¹' B ∩ + wordCylinder y v) := (hB.preimage (by fun_prop)).inter (measurableSet_wordCylinder y v) + have hw (ω : Environment d) : quenchedKernel (ω,x) + ((fun X : Path d => fun j => X (w.length+j)) ⁻¹' A ∩ wordCylinder x w) = + ENNReal.ofReal (wordWeight ω x w) * quenchedKernel (ω, wordPath x w w.length) A := by + rw [show wordCylinder x w = pathCylinder (wordPath x w) w.length from rfl, + quenched_prefix_future ω x (wordPath x w) (wordPath_zero x w) w.length hA] + rw [show pathCylinder (wordPath x w) w.length = wordCylinder x w from rfl, + quenched_wordCylinder] + have hv (ω : Environment d) : quenchedKernel (ω,y) + ((fun X : Path d => fun j => X (v.length+j)) ⁻¹' B ∩ wordCylinder y v) = + ENNReal.ofReal (wordWeight ω y v) * quenchedKernel (ω, wordPath y v v.length) B := by + rw [show wordCylinder y v = pathCylinder (wordPath y v) v.length from rfl, + quenched_prefix_future ω y (wordPath y v) (wordPath_zero y v) v.length hB] + rw [show pathCylinder (wordPath y v) v.length = wordCylinder y v from rfl, + quenched_wordCylinder] + rw [sharedPairLaw_rectangle ν x y _ _ hmA hmB] + simp_rw [hw,hv, mul_mul_mul_comm] + have hind := lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (rowSigma_le S) (rowSigma_le T) (environment_indep_rows ν hdis) + (((measurable_wordWeight_on x w (fun _ hz => Or.inl hz)).ennreal_ofReal).mul + ((measurable_wordWeight_on y v (fun _ hz => Or.inr hz)).ennreal_ofReal)) + ((measurable_quenched_stay_event_rows T _ hx A hA hAT).mul + (measurable_quenched_stay_event_rows T _ hy B hB hBT)) + simp only [Pi.mul_apply] at hind + rw [hind] + rw [sharedPairLaw_rectangle ν x y _ _ (measurableSet_wordCylinder x w) + (measurableSet_wordCylinder y v), + sharedPairLaw_rectangle ν (wordPath x w w.length) (wordPath y v v.length) _ _ hA hB] + simp only [quenched_wordCylinder] + +lemma noDrop_real_integral_translation {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (ℓ : Vector d) (x : Lattice d) : + (∫ ω, (noDropQuenched ℓ x ω).toReal ∂environmentLaw ν) = + ∫ ω, (noDropQuenched ℓ 0 ω).toReal ∂environmentLaw ν := by + conv_lhs => enter [2, ω]; rw [noDropQuenched_translation ℓ ω x] + have h := integral_map (μ := environmentLaw ν) + (show AEMeasurable (fun ω : Environment d => fun a => ω (x + a)) (environmentLaw ν) from + (by fun_prop : Measurable (fun ω : Environment d => fun a => ω (x + a))).aemeasurable) + ((measurable_noDropQuenched ℓ 0).ennreal_toReal.aestronglyMeasurable) + rw [environment_translation] at h + exact h.symm + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/FreshRowWeights.lean b/lean/OAI/Probability/Ballisticity/Walk/FreshRowWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..792e5745022e432a02af9eebe4ba82dbd2c35a14 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/FreshRowWeights.lean @@ -0,0 +1,68 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RawPairRetention +import OAI.Probability.Ballisticity.Coupling.FreshWeightedTest + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma fresh_rows_weighted_test_lower {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {S T : Set (Lattice d)} (hST : Disjoint S T) + (G : Set (Environment d × Environment d)) + (hG : @MeasurableSet (Environment d × Environment d) + (MeasurableSpace.prod (rowSigma S) (rowSigma T)) G) + (A : Set (Environment d)) (hA : MeasurableSet[rowSigma S] A) + (w : Environment d → ℝ≥0∞) (hw : @Measurable _ _ (rowSigma S) _ w) + (c : ℝ≥0∞) (hbound : ∀ η ∈ A, c ≤ environmentLaw ν {ω | (η,ω) ∈ G}) : + c*(∫⁻ ω in A, w ω ∂environmentLaw ν) ≤ + ∫⁻ ω in {ω | ω ∈ A ∧ (ω,ω) ∈ G}, w ω ∂environmentLaw ν := by + have hU : @Measurable (Environment d) (Environment d) inferInstance (rowSigma S) id := + measurable_id.mono le_rfl (rowSigma_le S) + have hV : @Measurable (Environment d) (Environment d) inferInstance (rowSigma T) id := + measurable_id.mono le_rfl (rowSigma_le T) + have hb (η : Environment d) (hη : η ∈ A) : + c ≤ (@Measure.map (Environment d) (Environment d) inferInstance (rowSigma T) id (environmentLaw ν)) + {ω | (η,ω) ∈ G} := by + have he : {ω | (η,ω) ∈ G} = Prod.mk η ⁻¹' G := rfl + rw [he,Measure.map_apply hV (hG.preimage measurable_prodMk_left)] + exact hbound η hη + exact @independent_random_test_weighted_lower (Environment d) (Environment d) (Environment d) + inferInstance (rowSigma S) (rowSigma T) (environmentLaw ν) inferInstance + id id hU hV + (@indepFun_of_disjoint_rows d (Environment d) (Environment d) (rowSigma S) (rowSigma T) + ν _ S T hST id id measurable_id measurable_id) A hA G hG w hw c hb + +lemma fresh_buffer_weighted_test {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (f : Direction d) {H : ℕ} (hH : 0 < H) (z₀ r ε a g : ℝ) + (C : Set (Lattice d × Lattice d)) {S T : Set (Lattice d)} (hST : Disjoint S T) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ T ∧ Strip ℓ x.2 H ⊆ T) + (π : Environment d → SupportedPairMeasures C) + (hπ : @Measurable _ _ (rowSigma S) _ π) + (A : Set (Environment d)) (hA : MeasurableSet[rowSigma S] A) + (w : Environment d → ℝ≥0∞) (hw : @Measurable _ _ (rowSigma S) _ w) + (c : ℝ≥0∞) + (hbound : ∀ η ∈ A, c ≤ environmentLaw ν + {ω | BufferStageEvent ℓ f H z₀ r ε a g (π η).val ω}) : + c*(∫⁻ ω in A, w ω ∂environmentLaw ν) ≤ + ∫⁻ ω in {ω | ω ∈ A ∧ BufferStageEvent ℓ f H z₀ r ε a g (π ω).val ω}, + w ω ∂environmentLaw ν := by + let G : Set (Environment d × Environment d) := + {p | BufferStageEvent ℓ f H z₀ r ε a g (π p.1).val p.2} + have hG : @MeasurableSet (Environment d × Environment d) + (MeasurableSpace.prod (rowSigma S) (rowSigma T)) G := + (measurableSet_bufferStageEvent_rows ℓ f hH z₀ r ε a g C T hC).preimage + ((hπ.comp measurable_fst).prodMk measurable_snd) + exact fresh_rows_weighted_test_lower ν hST G hG A hA w hw c hbound +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/GaussianPathFiniteLawSingleton.lean b/lean/OAI/Probability/Ballisticity/Walk/GaussianPathFiniteLawSingleton.lean new file mode 100644 index 0000000000000000000000000000000000000000..24bf5152e2a0662fb58af4ed753e60d247e3d439 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/GaussianPathFiniteLawSingleton.lean @@ -0,0 +1,160 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightPolygon + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma gaussianPathFiniteLaw_singleton (T : ℝ) (t : unitInterval) : + (gaussianPathFiniteLaw T {t}).map (fun x => x ⟨t,by simp⟩) = + gaussianReal 0 (Real.toNNReal (T*(t:ℝ))) := by + let I : Finset unitInterval := {t} + let z : Fin I.card := ⟨0,by simp [I]⟩ + have hj (j : Fin I.card) : j = z := by apply Fin.ext; have := j.isLt; simp [I] at this; omega + have htimes0 (j : Fin I.card) : orderedTimes I j.castSucc = 0 := by + rw [hj j] + simp [orderedTimes,z] + have htimes1 (j : Fin I.card) : orderedTimes I j.succ = t := by + rw [orderedTimes_succ] + exact Finset.mem_singleton.mp (Finset.orderEmbOfFin_mem I rfl j) + have hc (x : Fin I.card → ℝ) : incrementCumsum I x ⟨t,by simp [I]⟩ = x z := by + simp only [incrementCumsum,ContinuousLinearMap.coe_mk',LinearMap.coe_mk,AddHom.coe_mk] + rw [show Finset.Iic ((I.orderIsoOfFin rfl).symm ⟨t,by simp [I]⟩) = {z} by + ext j; simp only [Finset.mem_Iic,Finset.mem_singleton]; rw [hj j,hj ((I.orderIsoOfFin rfl).symm _)]; simp] + simp + change (gaussianPathFiniteLaw T I).map _ = _ + unfold gaussianPathFiniteLaw + rw [Measure.map_map (by fun_prop) (by fun_prop)] + have he : (fun x : I → ℝ => x ⟨t,by simp [I]⟩) ∘ incrementCumsum I = + (fun x : Fin I.card → ℝ => x z) := funext hc + rw [he] + have hm := (measurePreserving_eval (fun j : Fin I.card => gaussianReal 0 + (Real.toNNReal (T*((orderedTimes I j.succ:ℝ)-orderedTimes I j.castSucc)))) z).map_eq + rw [hm,htimes0,htimes1] + simp + +lemma wiener_path_eval (W : ProbabilityMeasure C(unitInterval,ℝ)) (T : ℝ) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw T I) + (t : unitInterval) : + (W : Measure C(unitInterval,ℝ)).map (fun g => g t) = gaussianReal 0 (Real.toNNReal (T*(t:ℝ))) := by + rw [← gaussianPathFiniteLaw_singleton T t,← hW {t},Measure.map_map (by fun_prop) (continuous_path_restrict {t}).measurable] + rfl + +lemma height_path_gaussian_eval {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : ℕ → Ω → ℝ) + (hF : ∀ h, Measurable (F h)) (r n : ℕ → ℝ) (hn : ∀ i, 0 < n i) + (T : ℝ) (hT : 0 < T) (V : ℝ) (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : TendstoInDistribution (fun i x => heightPolygon (fun h => F h x) (r i) (n i) T) + atTop id (fun _ => μ) W) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (T*V) I) + (k : ℕ → ℕ) (hkn : ∀ i, (k i : ℝ) ≤ T*n i) {s : ℝ} + (hs : Tendsto (fun i => (k i : ℝ)/n i) atTop (𝓝 s)) : + TendstoInDistribution (fun i x => F (k i) x/r i) atTop id (fun _ => μ) + (gaussianReal 0 (Real.toNNReal (V*s))) := by + have hs0 : 0 ≤ s := le_of_tendsto_of_tendsto tendsto_const_nhds hs + (Eventually.of_forall fun i => div_nonneg (Nat.cast_nonneg _) (hn i).le) + have hsT : s ≤ T := le_of_tendsto_of_tendsto hs tendsto_const_nhds + (Eventually.of_forall fun i => (div_le_iff₀ (hn i)).mpr (hkn i)) + let t : ℕ → unitInterval := fun i => ⟨(k i:ℝ)/(T*n i), + div_nonneg (Nat.cast_nonneg _) (mul_pos hT (hn i)).le, + (div_le_one (mul_pos hT (hn i))).mpr (hkn i)⟩ + let u : unitInterval := ⟨s/T,div_nonneg hs0 hT.le,(div_le_one hT).mpr hsT⟩ + have ht : Tendsto t atTop (𝓝 u) := by + apply tendsto_subtype_rng.mpr + change Tendsto (fun i => (k i:ℝ)/(T*n i)) atTop (𝓝 (s/T)) + convert hs.div_const T using 1 + funext i + ring + let P : ℕ → ProbabilityMeasure C(unitInterval,ℝ) := fun i => + ⟨μ.map (fun x => heightPolygon (fun h => F h x) (r i) (n i) T), + inferInstance⟩ + have hP : Tendsto P atTop (𝓝 W) := by + have hh := hlim.tendsto + have hid : (⟨(W : Measure C(unitInterval,ℝ)).map id, + inferInstance⟩ : ProbabilityMeasure C(unitInterval,ℝ)) = W := + Subtype.ext Measure.map_id + rw [hid] at hh + exact hh + have hev := weak_path_eval_tendsto hP ht + have hwm : W.map (fun path => path u) = + (⟨gaussianReal 0 (Real.toNNReal (V*s)),inferInstance⟩ : ProbabilityMeasure ℝ) := by + apply Subtype.ext + change (W : Measure C(unitInterval,ℝ)).map (fun g => g u) = _ + rw [wiener_path_eval W (T*V) hW] + congr 2 + change (T*V)*(s/T) = V*s + field_simp + rw [hwm] at hev + refine ⟨fun i => ((hF (k i)).div_const _).aemeasurable,measurable_id.aemeasurable,?_⟩ + have he (i : ℕ) : (P i).map (fun path => path (t i)) = + (⟨μ.map (fun x => F (k i) x/r i),inferInstance⟩ : ProbabilityMeasure ℝ) := by + apply Subtype.ext + change (μ.map (fun x => heightPolygon (fun h => F h x) (r i) (n i) T)).map (fun g => g (t i)) = _ + rw [Measure.map_map (continuous_eval_const (t i)).measurable (measurable_heightPolygon F hF _ _ _)] + congr 1 + funext x + exact heightPolygon_grid _ _ _ _ (mul_pos hT (hn i)).le (k i) (t i) + (by change T*n i*((k i:ℝ)/(T*n i)) = _; field_simp [hT.ne',(hn i).ne']) + simpa only [he,Measure.map_id] using hev + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/GaussianPathFiniteLawSmul.lean b/lean/OAI/Probability/Ballisticity/Walk/GaussianPathFiniteLawSmul.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb944f1880b98e23c75fb9a3c8276e934f4a794a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/GaussianPathFiniteLawSmul.lean @@ -0,0 +1,235 @@ +import Mathlib +import OAI.Probability.Ballisticity.Geometry.HeightPolygon + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma gaussianPathFiniteLaw_smul (T a : ℝ) (I : Finset unitInterval) : + (gaussianPathFiniteLaw T I).map (fun x => a • x) = gaussianPathFiniteLaw (a^2*T) I := by + unfold gaussianPathFiniteLaw + let v := fun j : Fin I.card => Real.toNNReal (T*((orderedTimes I j.succ:ℝ)-orderedTimes I j.castSucc)) + have he (j : Fin I.card) : (gaussianReal 0 (v j)).map (fun x : ℝ => a*x) = + gaussianReal 0 (Real.toNNReal ((a^2*T)*((orderedTimes I j.succ:ℝ)-orderedTimes I j.castSucc))) := by + rw [gaussianReal_map_const_mul,mul_zero] + congr 1 + have hsq : NNReal.mk (a^2) (sq_nonneg a) = Real.toNNReal (a^2) := by + apply NNReal.eq + simp only [NNReal.coe_mk,Real.coe_toNNReal'] + exact (max_eq_left (sq_nonneg a)).symm + rw [hsq,← Real.toNNReal_mul (sq_nonneg a)] + congr 1 + ring + have hpi := Measure.pi_map_pi (μ := fun j : Fin I.card => gaussianReal 0 (v j)) + (f := fun _ (x : ℝ) => a*x) (fun _ => by fun_prop) + rw [Measure.map_map (by fun_prop) (by fun_prop)] + rw [show (fun x => a • x) ∘ incrementCumsum I = incrementCumsum I ∘ (fun x => a • x) by ext x; simp] + rw [← Measure.map_map (by fun_prop) (by fun_prop)] + congr 1 + change (Measure.pi (fun j => gaussianReal 0 (v j))).map (fun x i => a*x i) = _ + rw [hpi] + congr 1 + funext j + exact he j + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma median_div {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (F : Ω → ℝ) (hF : Measurable F) (b r : ℝ) + (hb : (1/2 : ℝ≥0∞) ≤ μ {x | F x ≤ b} ∧ (1/2 : ℝ≥0∞) ≤ μ {x | b ≤ F x}) : + (1/2 : ℝ≥0∞) ≤ (μ.map (fun x => F x/r)) (Set.Iic (b/r)) ∧ + (1/2 : ℝ≥0∞) ≤ (μ.map (fun x => F x/r)) (Set.Ici (b/r)) := by + rw [Measure.map_apply (hF.div_const r) measurableSet_Iic, + Measure.map_apply (hF.div_const r) measurableSet_Ici] + rcases lt_trichotomy r 0 with hr|hr|hr + · simpa only [Set.preimage,Set.mem_Iic,Set.mem_Ici,div_le_div_right_of_neg hr] using hb.symm + · subst r + simp + · simpa only [Set.preimage,Set.mem_Iic,Set.mem_Ici,div_le_div_iff_of_pos_right hr] using hb + +noncomputable def heightPathLaw {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (F : ℕ → Ω → ℝ) (hF : ∀ k, Measurable (F k)) (r n T : ℝ) : ProbabilityMeasure C(unitInterval,ℝ) := + ⟨μ.map (fun x => heightPolygon (fun k => F k x) r n T), + (Measure.isProbabilityMeasure_map_iff + (measurable_heightPolygon F hF r n T).aemeasurable).2 inferInstance⟩ + +lemma heightPathLaw_iid_difference {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (F : ℕ → Ω → ℝ) (hF : ∀ k, Measurable (F k)) (r n T : ℝ) : + (((heightPathLaw μ F hF r n T : Measure C(unitInterval,ℝ)).prod + (heightPathLaw μ F hF r n T)).map (fun p : C(unitInterval,ℝ) × C(unitInterval,ℝ) => p.1-p.2)) = + (μ.prod μ).map (fun p => heightPolygon (fun k => F k p.1-F k p.2) r n T) := by + change ((μ.map _).prod (μ.map _)).map _ = _ + rw [Measure.map_prod_map _ _ (measurable_heightPolygon F hF _ _ _) (measurable_heightPolygon F hF _ _ _), + Measure.map_map (by fun_prop) ((measurable_heightPolygon F hF _ _ _).prodMap (measurable_heightPolygon F hF _ _ _))] + congr 1 + ext p t + exact congrArg (fun g : C(unitInterval,ℝ) => g t) (heightPolygon_sub _ _ _ _ _).symm + +lemma heightPathLaw_restrict {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (F : ℕ → Ω → ℝ) (hF : ∀ k, Measurable (F k)) (r n T S : ℝ) + (hn : 0 ≤ n) (hT : 0 ≤ T) (hS : 0 ≤ S) (a : unitInterval) (ha : S*(a:ℝ) = T) : + (heightPathLaw μ F hF r n S).map (pathRestrictScale a) = + heightPathLaw μ F hF r n T := by + apply Subtype.ext + change (μ.map _).map _ = _ + rw [Measure.map_map (pathRestrictScale a).measurable (measurable_heightPolygon F hF _ _ _)] + congr 1 + funext x + exact heightPolygon_restrict _ _ _ _ _ hn hT hS a ha + +theorem height_median_path_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : ℕ → Ω → ℝ) + (hF : ∀ k, Measurable (F k)) (b : ℕ → ℝ) + (hb : ∀ k, (1/2 : ℝ≥0∞) ≤ μ {x | F k x ≤ b k} ∧ (1/2 : ℝ≥0∞) ≤ μ {x | b k ≤ F k x}) + (r n : ℕ → ℝ) (hn : ∀ i, 0 ≤ n i) (hnlim : Tendsto n atTop atTop) (c : ℝ) + (hd : ∀ S : ℝ, 0 ≤ S → ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + Tendsto (fun i => ((heightPathLaw μ F hF (r i) (n i) S).prod + (heightPathLaw μ F hF (r i) (n i) S)).map + (fun pair => pair.1-pair.2)) atTop (𝓝 W) ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (S/c) I) + {T : ℝ} (hT : 0 ≤ T) : + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i x => heightPolygon (fun k => F k x-b k) (r i) (n i) T) + atTop id (fun _ => μ) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (T/(2*c)) I := by + let S := T+1 + have hS : 0 < S := by dsimp [S]; linarith + let a : unitInterval := ⟨T/S,div_nonneg hT hS.le,(div_le_one hS).2 (by dsimp [S]; linarith)⟩ + have ha : (a:ℝ) < 1 := (div_lt_one hS).2 (by dsimp [S]; linarith) + have haS : S*(a:ℝ) = T := by dsimp [a]; field_simp + obtain ⟨WS,hWS,hWSf⟩ := hd S hS.le + obtain ⟨WT,hWT,hWTf⟩ := hd T hT + have hrestrict : WS.map (pathRestrictScale a) = WT := by + have h := (ProbabilityMeasure.continuous_map (pathRestrictScale a).continuous).tendsto WS |>.comp hWS + have he (i : ℕ) : (((heightPathLaw μ F hF (r i) (n i) S).prod + (heightPathLaw μ F hF (r i) (n i) S)).map + (fun pair => pair.1-pair.2)).map + (pathRestrictScale a) = + ((heightPathLaw μ F hF (r i) (n i) T).prod + (heightPathLaw μ F hF (r i) (n i) T)).map + (fun pair => pair.1-pair.2) := by + apply Subtype.ext + change (((heightPathLaw μ F hF (r i) (n i) S : Measure C(unitInterval,ℝ)).prod + (heightPathLaw μ F hF (r i) (n i) S : Measure C(unitInterval,ℝ))).map + (fun p : C(unitInterval,ℝ) × C(unitInterval,ℝ) => p.1-p.2)).map (pathRestrictScale a) = + ((heightPathLaw μ F hF (r i) (n i) T : Measure C(unitInterval,ℝ)).prod + (heightPathLaw μ F hF (r i) (n i) T : Measure C(unitInterval,ℝ))).map + (fun p : C(unitInterval,ℝ) × C(unitInterval,ℝ) => p.1-p.2) + rw [heightPathLaw_iid_difference,Measure.map_map (pathRestrictScale a).measurable (measurable_heightPolygon (fun k (p : Ω × Ω) => F k p.1-F k p.2) (fun k => ((hF k).comp measurable_fst).sub ((hF k).comp measurable_snd)) (r i) (n i) S), + heightPathLaw_iid_difference] + congr 1 + funext p + exact heightPolygon_restrict _ _ _ _ _ (hn i) hT hS.le a haS + exact tendsto_nhds_unique (by simpa only [Function.comp_def,he] using h) hWT + let Q := fun i => heightPathLaw μ F hF (r i) (n i) S + let B := fun i => heightPolygon b (r i) (n i) S + let s := Real.sqrt (1/2) + have hs : s^2 = 1/2 := Real.sq_sqrt (by norm_num) + have hlim := path_grid_median_limit_from_iid_difference Q WS (S/c) hWSf hWS + (fun i => S*n i) (hnlim.const_mul_atTop hS) + (fun i => ?_) B (fun i => heightPolygon_gridLinear b _ _ _ (mul_nonneg hS.le (hn i))) + (fun i j t ht => ?_) s hs a ha + · let W := WT.map (fun path : C(unitInterval,ℝ) => s • path) + refine ⟨W,⟨fun i => (measurable_heightPolygon (fun k x => F k x-b k) + (fun k => (hF k).sub_const _) _ _ _).aemeasurable,measurable_id.aemeasurable,?_⟩,?_⟩ + · have he (i : ℕ) : (Q i).map (fun path => pathRestrictScale a (path-B i)) = + (⟨μ.map (fun x => heightPolygon (fun k => F k x-b k) (r i) (n i) T), + (Measure.isProbabilityMeasure_map_iff + (measurable_heightPolygon _ (fun k => (hF k).sub_const _) _ _ _).aemeasurable).2 inferInstance⟩ : + ProbabilityMeasure C(unitInterval,ℝ)) := by + apply Subtype.ext + change (μ.map _).map _ = _ + rw [Measure.map_map (by fun_prop) (measurable_heightPolygon F hF _ _ _)] + congr 1 + funext x + change pathRestrictScale a (heightPolygon (fun k => F k x) (r i) (n i) S-B i) = _ + rw [← heightPolygon_sub] + exact heightPolygon_restrict _ _ _ _ _ (hn i) hT hS.le a haS + have heW : WS.map (fun path => s • pathRestrictScale a path) = W := by + rw [show W = (WS.map (pathRestrictScale a)).map + (fun path : C(unitInterval,ℝ) => s • path) by rw [hrestrict]] + apply Subtype.ext + exact (Measure.map_map (by fun_prop) (pathRestrictScale a).measurable).symm + change Tendsto _ atTop (𝓝 (W.map id)) + have hid : W.map id = W := by apply Subtype.ext; exact Measure.map_id + rw [hid] + simpa only [he,heW] using hlim + · intro I + change ((WT : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => s • g)).map _ = _ + rw [Measure.map_map (continuous_path_restrict I).measurable (by fun_prop)] + have he : (fun g : C(unitInterval,ℝ) => I.restrict (s • g)) = + (fun x : I → ℝ => s • x) ∘ (fun g : C(unitInterval,ℝ) => I.restrict g) := rfl + change (WT : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict (s • g)) = _ + rw [he,← Measure.map_map (by fun_prop) (continuous_path_restrict I).measurable,hWTf, + gaussianPathFiniteLaw_smul,hs] + congr 1 + ring + · change ∀ᵐ f ∂μ.map (fun x => heightPolygon (fun k => F k x) (r i) (n i) S), GridLinear (S*n i) f + rw [ae_map_iff (measurable_heightPolygon F hF _ _ _).aemeasurable + (isClosed_gridLinear _).measurableSet] + exact ae_of_all _ (fun x => heightPolygon_gridLinear _ _ _ _ (mul_nonneg hS.le (hn i))) + · change (1/2 : ℝ≥0∞) ≤ ((μ.map (fun x => heightPolygon (fun k => F k x) (r i) (n i) S)).map + (fun g => g t)) (Set.Iic (B i t)) ∧ + (1/2 : ℝ≥0∞) ≤ ((μ.map (fun x => heightPolygon (fun k => F k x) (r i) (n i) S)).map + (fun g => g t)) (Set.Ici (B i t)) + rw [Measure.map_map (continuous_eval_const t).measurable (measurable_heightPolygon F hF _ _ _)] + have he : (fun g : C(unitInterval,ℝ) => g t) ∘ (fun x => heightPolygon (fun k => F k x) (r i) (n i) S) = + fun x => F j x/r i := by + funext x + exact heightPolygon_grid _ _ _ _ (mul_nonneg hS.le (hn i)) j t ht + rw [he,show B i t = b j/r i from heightPolygon_grid _ _ _ _ (mul_nonneg hS.le (hn i)) j t ht] + exact median_div μ (F j) (hF j) (b j) (r i) (hb j) + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/JointPathIndependence.lean b/lean/OAI/Probability/Ballisticity/Walk/JointPathIndependence.lean new file mode 100644 index 0000000000000000000000000000000000000000..908816ac97161fa6066388833313af8a85ef440e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/JointPathIndependence.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.InteriorPairMeasureExt + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma probability_prod_initial_zero (μ ν : Measure C(unitInterval,ℝ)) + (hμ : ∀ᵐ P ∂μ,P 0=0) (hν : ∀ᵐ P ∂ν,P 0=0) [SFinite ν] : + ∀ᵐ P : RealPathPair ∂μ.prod ν,P.1 0=0 ∧ P.2 0=0 := by + apply (Measure.ae_prod_iff_ae_ae (by measurability)).mpr + filter_upwards [hμ] with P hP + filter_upwards [hν] with Q hQ + exact ⟨hP,hQ⟩ + +lemma normalJointPast_product_identification (μ : Measure RealPathPair) [IsProbabilityMeasure μ] + (c : ℝ≥0) (h : NormalJointPast μ c) {A K : ℝ} (hA : 0 < A) (hK : 0 ≤ K) + (hcross : SeparatedCrossBound μ A K) + (hz : (μ.prod volume) {z : RealPathPair × unitInterval | z.1.1 z.2-z.1.2 z.2=0}=0) + (hzero : ∀ᵐ P ∂μ,P.1 0=0 ∧ P.2 0=0) : + μ=(μ.map Prod.fst).prod (μ.map Prod.snd) := by + let : IsProbabilityMeasure (μ.map Prod.fst) := inferInstance + let : IsProbabilityMeasure (μ.map Prod.snd) := inferInstance + have hf : NormalSinglePast (μ.map Prod.fst) c := normalJointPast_single μ c h false + have hg : NormalSinglePast (μ.map Prod.snd) c := normalJointPast_single μ c h true + have h0f : ∀ᵐ P ∂μ.map Prod.fst,P 0=0 := by + rw [ae_map_iff measurable_fst.aemeasurable ((isClosed_eq (continuous_eval_const 0) continuous_const).measurableSet)] + exact hzero.mono fun P hP => hP.1 + have h0g : ∀ᵐ P ∂μ.map Prod.snd,P 0=0 := by + rw [ae_map_iff measurable_snd.aemeasurable ((isClosed_eq (continuous_eval_const 0) continuous_const).measurableSet)] + exact hzero.mono fun P hP => hP.2 + have hfull := fullNormalJointPast_of_cross μ c h hA hK hcross hz + have hprod := normalSinglePast_prod (μ.map Prod.fst) (μ.map Prod.snd) c hf hg + apply interior_pair_measure_ext + intro I hI + exact fullNormalJointPast_finite_uniqueness μ _ c hfull hprod hzero + (probability_prod_initial_zero _ _ h0f h0g) I hI + +lemma wiener_path_initial_zero (W : ProbabilityMeasure C(unitInterval,ℝ)) (T : ℝ) + (hW : ∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g)=gaussianPathFiniteLaw T I) : + ∀ᵐ P ∂(W : Measure C(unitInterval,ℝ)),P 0=0 := by + have he := wiener_path_eval W T hW 0 + have he0 : ((0:unitInterval):ℝ)=0 := rfl + simp only [he0,mul_zero,Real.toNNReal_zero,gaussianReal_zero_var] at he + have hh : ∀ᵐ x ∂(W : Measure C(unitInterval,ℝ)).map (fun P => P 0),x=0 := by + rw [he] + simp + exact (ae_map_iff (continuous_eval_const 0).measurable.aemeasurable (by measurability)).mp hh + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/Kernel.lean b/lean/OAI/Probability/Ballisticity/Walk/Kernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fadd8025870b7f1d14995061a5140e497b2115f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/Kernel.lean @@ -0,0 +1,253 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MeasurableCountableSample + +namespace OAI + +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BigOperators + +namespace TailDecorrelation + +section Randomization +variable {D I A J E : Type*} [MeasurableSpace D] [MeasurableSpace A] +variable [MeasurableSpace E] [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J] +variable (δ : Measure D) (σ : Measure E) (ν : Measure A) +variable [IsProbabilityMeasure δ] [IsProbabilityMeasure σ] [IsProbabilityMeasure ν] + +lemma randomization_projection_preserving : + MeasurePreserving (fun x : (D × E) × (I → A) => (x.1.1, x.2)) + ((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) + (δ.prod (Measure.infinitePi (fun _ : I => ν))) := by + exact measurePreserving_fst.prod (MeasurePreserving.id _) + +lemma randomized_density {f : D × (I → A) → ℝ} + (hf : Measurable f) (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν)))) : + Integrable (fun x : (D × E) × (I → A) => f (x.1.1, x.2)) + ((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) ∧ + Integrable (fun x : (D × E) × (I → A) => entropyPlus (f (x.1.1, x.2))) + ((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) ∧ + (∫ x : (D × E) × (I → A), f (x.1.1, x.2) + ∂(δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) = + (∫ x, f x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) := by + have hp := randomization_projection_preserving δ σ ν (I := I) + refine ⟨(hp.integrable_comp hf.aestronglyMeasurable).mpr hfi, + (hp.integrable_comp (measurable_entropyPlus.comp hf).aestronglyMeasurable).mpr hH, ?_⟩ + have hh : AEStronglyMeasurable f + (((δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))).map + (fun x : (D × E) × (I → A) => (x.1.1, x.2))) := by + rw [hp.map_eq] + exact hf.aestronglyMeasurable + have he := integral_map hp.measurable.aemeasurable hh + rw [hp.map_eq] at he + exact he.symm + +end Randomization +end TailDecorrelation + +namespace TailDecorrelation + +lemma measurableSet_eventually_nat {X : Type*} [MeasurableSpace X] + {p : ℕ → X → Prop} (hp : ∀ n, MeasurableSet {x | p n x}) : + MeasurableSet {x | ∀ᶠ n in atTop, p n x} := by + simp only [eventually_atTop, Set.ofPred_exists, Set.ofPred_forall] + exact MeasurableSet.iUnion fun n => MeasurableSet.iInter fun m => + MeasurableSet.iInter fun _ => hp m + +section KernelTransfer +variable {D E W J : Type*} [MeasurableSpace D] [MeasurableSpace E] +variable [MeasurableSpace W] [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J] +variable (δ : Measure D) (σ : Measure E) (P : Measure W) +variable [IsProbabilityMeasure δ] [IsProbabilityMeasure σ] [IsProbabilityMeasure P] + +lemma integral_comp_preserving {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + {μ : Measure X} {ρ : Measure Y} {T : X → Y} (hT : MeasurePreserving T μ ρ) + {g : Y → ℝ} (hg : Measurable g) : + (∫ x, g (T x) ∂μ) = ∫ y, g y ∂ρ := by + have hm : AEStronglyMeasurable g (μ.map T) := by + rw [hT.map_eq] + exact hg.aestronglyMeasurable + have he := integral_map hT.measurable.aemeasurable hm + rw [hT.map_eq] at he + exact he.symm + +lemma swap_seed_preserving : + MeasurePreserving (fun x : (D × W) × E => ((x.1.1,x.2),x.1.2)) + ((δ.prod P).prod σ) ((δ.prod σ).prod P) := by + exact ((measurePreserving_prodAssoc δ σ P).symm MeasurableEquiv.prodAssoc).comp + (((MeasurePreserving.id δ).prod Measure.measurePreserving_swap).comp + (measurePreserving_prodAssoc δ P σ)) + +lemma sampled_kernel_integral (κ : Kernel D J) (s : D → E → J) + (hs : Measurable (Function.uncurry s)) (hmap : ∀ d, σ.map (s d) = κ d) + {f : D × W → ℝ} (hf : Measurable f) {Z : J → W → ℝ} + (hZ : ∀ a, Measurable (Z a)) + (hi : Integrable (fun x : (D × E) × W => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2) + ((δ.prod σ).prod P)) : + (∫ x : (D × E) × W, f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2 ∂(δ.prod σ).prod P) = + (∫ x : D × W, f x * (∫ a, Z a x.2 ∂κ x.1) ∂δ.prod P) := by + have hz : Measurable (Function.uncurry Z) := measurable_from_prod_countable_right hZ + let G : (D × E) × W → ℝ := fun x => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2 + have hG : Measurable G := + (hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)).mul + (hz.comp ((hs.comp measurable_fst).prodMk measurable_snd)) + have hp := swap_seed_preserving δ σ P + have hj : Integrable (fun x : (D × W) × E => f x.1 * Z (s x.1.1 x.2) x.1.2) + ((δ.prod P).prod σ) := (hp.integrable_comp hG.aestronglyMeasurable).mpr hi + rw [← integral_comp_preserving hp hG] + change (∫ x : (D × W) × E, f x.1 * Z (s x.1.1 x.2) x.1.2 ∂(δ.prod P).prod σ) = _ + rw [integral_prod _ hj] + apply integral_congr_ae + apply Eventually.of_forall + intro x + change (∫ u, f x * Z (s x.1 u) x.2 ∂σ) = f x * (∫ a, Z a x.2 ∂κ x.1) + rw [integral_const_mul] + congr 1 + have he := integral_map ((hs.comp measurable_prodMk_left).aemeasurable) + (show AEStronglyMeasurable (fun a => Z a x.2) (σ.map (s x.1)) from + Measurable.of_discrete.aestronglyMeasurable) + change (∫ a, Z a x.2 ∂σ.map (s x.1)) = (∫ u, Z (s x.1 u) x.2 ∂σ) at he + rw [hmap] at he + exact he.symm + +lemma sampled_kernel_integrable (κ : Kernel D J) (s : D → E → J) + (hs : Measurable (Function.uncurry s)) (hmap : ∀ d, σ.map (s d) = κ d) + {f : D × W → ℝ} (hf : Measurable f) {Z : J → W → ℝ} + (hZ : ∀ a, Measurable (Z a)) + (hi : Integrable (fun x : (D × E) × W => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2) + ((δ.prod σ).prod P)) : + Integrable (fun x : D × W => f x * (∫ a, Z a x.2 ∂κ x.1)) (δ.prod P) := by + have hz : Measurable (Function.uncurry Z) := measurable_from_prod_countable_right hZ + let G : (D × E) × W → ℝ := fun x => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2 + have hG : Measurable G := + (hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)).mul + (hz.comp ((hs.comp measurable_fst).prodMk measurable_snd)) + have hp := swap_seed_preserving δ σ P + have hj : Integrable (fun x : (D × W) × E => f x.1 * Z (s x.1.1 x.2) x.1.2) + ((δ.prod P).prod σ) := (hp.integrable_comp hG.aestronglyMeasurable).mpr hi + apply hj.integral_prod_left.congr + apply Eventually.of_forall + intro x + change (∫ u, f x * Z (s x.1 u) x.2 ∂σ) = f x * (∫ a, Z a x.2 ∂κ x.1) + rw [integral_const_mul] + congr 1 + have he := integral_map ((hs.comp measurable_prodMk_left).aemeasurable) + (show AEStronglyMeasurable (fun a => Z a x.2) (σ.map (s x.1)) from + Measurable.of_discrete.aestronglyMeasurable) + change (∫ a, Z a x.2 ∂σ.map (s x.1)) = (∫ u, Z (s x.1 u) x.2 ∂σ) at he + rw [hmap] at he + exact he.symm + +omit [IsProbabilityMeasure δ] in +lemma kernel_escape_sampled (κ : ℕ → Kernel D J) (s : ℕ → D → E → J) + (hs : ∀ r, Measurable (Function.uncurry (s r))) + (hmap : ∀ r d, σ.map (s r d) = κ r d) + (good : ℕ → J → Prop) + (hesc : ∀ᵐ d ∂δ, ∀ᶠ r in atTop, ∀ᵐ a ∂κ r d, good r a) : + ∀ᵐ x ∂δ.prod σ, ∀ᶠ r in atTop, good r (s r x.1 x.2) := by + have hm : ∀ r, MeasurableSet {x : D × E | good r (s r x.1 x.2)} := fun r => + (hs r) (Set.to_countable _).measurableSet + apply (Measure.ae_prod_iff_ae_ae (measurableSet_eventually_nat hm)).mpr + filter_upwards [hesc] with d hd + obtain ⟨N,hN⟩ := eventually_atTop.mp hd + have hforall : ∀ r : ℕ, ∀ᵐ u ∂σ, N ≤ r → good r (s r d u) := by + intro r + by_cases hr : N ≤ r + · have hh := hN r hr + rw [← hmap r d] at hh + have htrans := (ae_map_iff (hs r |>.comp measurable_prodMk_left |>.aemeasurable) + (Set.to_countable _).measurableSet).mp hh + exact htrans.mono fun u hu _ => hu + · exact Eventually.of_forall fun _ h => (hr h).elim + filter_upwards [ae_all_iff.mpr hforall] with u hu + exact eventually_atTop.mpr ⟨N,hu⟩ + +end KernelTransfer +end TailDecorrelation + +namespace TailDecorrelation +section KernelCompletion +variable {D I A J : Type*} [MeasurableSpace D] [MeasurableSpace A] [Encodable I] +variable [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J] +variable [Nonempty J] [StandardBorelSpace J] +variable (δ : Measure D) (ν : Measure A) [IsProbabilityMeasure δ] [IsProbabilityMeasure ν] + +omit [Encodable I] in +lemma kernel_density_integrable {f : D × (I → A) → ℝ} {Z : J → (I → A) → ℝ} + {c Q : ℝ} (hc : 0 < c) + (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) + (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hZ : ∀ a, Measurable (Z a)) (hZ0 : ∀ a ω, 0 ≤ Z a ω) + (he : ∀ a, Integrable (fun ω => Real.exp (c * Z a ω)) (Measure.infinitePi (fun _ : I => ν))) + (heQ : ∀ a, (∫ ω, Real.exp (c * Z a ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q) + (κ : Kernel D J) [IsMarkovKernel κ] : + Integrable (fun x : D × (I → A) => f x * (∫ a, Z a x.2 ∂κ x.1)) + (δ.prod (Measure.infinitePi (fun _ : I => ν))) := by + obtain ⟨s,hs,hmap⟩ := Kernel.exists_measurable_map_eq_unitInterval κ + let σ : Measure unitInterval := volume + let g : (D × unitInterval) × (I → A) → ℝ := fun x => f (x.1.1,x.2) + have hg : Measurable g := hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd) + obtain ⟨_,hgH,_⟩ := randomized_density δ σ ν hf hfi hH + have hi := integrable_density_mul_of_entropy hc hg + (measurable_countable_sample hZ hs) (fun x => hf0 _) (fun x => hZ0 _ _) hgH + (sampled_exponential_integrable (δ.prod σ) ν hZ he heQ hs).1 + exact sampled_kernel_integrable δ σ (Measure.infinitePi (fun _ : I => ν)) + κ s hs hmap hf hZ hi + +lemma kernel_entropy_decorrelation {f : D × (I → A) → ℝ} {Z : J → (I → A) → ℝ} + {c Q C : ℝ} (hc : 0 < c) (hC : 0 ≤ C) + (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) + (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hf1 : (∫ x, f x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) = 1) + (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hZ : ∀ a, Measurable (Z a)) (hZ0 : ∀ a ω, 0 ≤ Z a ω) + (he : ∀ a, Integrable (fun ω => Real.exp ((2 * c) * Z a ω)) (Measure.infinitePi (fun _ : I => ν))) + (heQ : ∀ a, (∫ ω, Real.exp ((2 * c) * Z a ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q) + (hZi : ∀ a, Integrable (Z a) (Measure.infinitePi (fun _ : I => ν))) + (hZC : ∀ a, (∫ ω, Z a ω ∂Measure.infinitePi (fun _ : I => ν)) ≤ C) + (N : ℕ → J → Set I) (κ : ℕ → Kernel D J) [∀ r, IsMarkovKernel (κ r)] + (hloc : ∀ K η : ℝ, 0 < K → 0 < η → ∃ n : ℕ, ∃ F : J → (I → A) → ℝ, + (∀ a, @Measurable _ _ (rows (N n a)) _ (F a)) ∧ + (∀ a ω, 0 ≤ F a ω ∧ F a ω ≤ K) ∧ + (∀ a, (∫ ω, |min K (Z a ω) - F a ω| ∂Measure.infinitePi (fun _ : I => ν)) ≤ η)) + (hescape : ∀ n (S : Set I), S.Finite → ∀ᵐ d ∂δ, + ∀ᶠ r in atTop, ∀ᵐ a ∂κ r d, Disjoint S (N n a)) : + ∀ ε > 0, ∀ᶠ r in atTop, + (∫ x : D × (I → A), f x * (∫ a, Z a x.2 ∂κ r x.1) + ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) ≤ C + ε := by + classical + let σ : Measure unitInterval := volume + choose s hs hmap using fun r => Kernel.exists_measurable_map_eq_unitInterval (κ r) + let g : (D × unitInterval) × (I → A) → ℝ := fun x => f (x.1.1,x.2) + have hg : Measurable g := hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd) + obtain ⟨hgi,hgH,hg1⟩ := randomized_density δ σ ν hf hfi hH + have hesc : ∀ n (S : Set I), S.Finite → ∀ᵐ d ∂δ.prod σ, + ∀ᶠ r in atTop, Disjoint S (N n (s r d.1 d.2)) := by + intro n S hS + exact kernel_escape_sampled δ σ κ s hs hmap (fun _ a => Disjoint S (N n a)) (hescape n S hS) + have hbound := sampled_entropy_decorrelation (δ.prod σ) ν hc hC hg + (fun x => hf0 _) hgi (hg1.trans hf1) hgH hZ hZ0 he heQ hZi hZC N + (fun r => Function.uncurry (s r)) hs hloc hesc + have heq : ∀ r, (∫ x : (D × unitInterval) × (I → A), + g x * Z (s r x.1.1 x.1.2) x.2 ∂(δ.prod σ).prod (Measure.infinitePi (fun _ : I => ν))) = + (∫ x : D × (I → A), f x * (∫ a, Z a x.2 ∂κ r x.1) + ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) := by + intro r + have hi := integrable_density_mul_of_entropy (by linarith : 0 < 2*c) hg + (measurable_countable_sample hZ (hs r)) (fun x => hf0 _) (fun x => hZ0 _ _) hgH + (sampled_exponential_integrable (δ.prod σ) ν hZ he heQ (hs r)).1 + exact sampled_kernel_integral δ σ (Measure.infinitePi (fun _ : I => ν)) + (κ r) (s r) (hs r) (hmap r) hf hZ hi + intro ε hε + filter_upwards [hbound ε hε] with r hr + rw [← heq r] + exact hr + +end KernelCompletion +end TailDecorrelation + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/KernelBoundedExpectation.lean b/lean/OAI/Probability/Ballisticity/Walk/KernelBoundedExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ee4d0e8de7ec0bb920d5cf06d1fd9b9251cc30d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/KernelBoundedExpectation.lean @@ -0,0 +1,47 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma kernel_bounded_integral {Ω G : Type*} [MeasurableSpace Ω] [MeasurableSpace G] + (Q : Kernel Ω G) [IsFiniteKernel Q] (F : G → ℝ) (hF : Measurable F) + {B : ℝ} (hB : 0 ≤ B) (h0 : ∀ u, 0 ≤ F u) (hbound : ∀ u, F u ≤ B) + (hQ : ∀ ω, Q ω Set.univ ≤ 1) : + ∀ ω, 0 ≤ (∫ u, F u ∂Q ω) ∧ (∫ u, F u ∂Q ω) ≤ B := by + intro ω + have hi : Integrable F (Q ω) := Integrable.of_bound hF.aestronglyMeasurable B + (Eventually.of_forall fun u => by simpa only [Real.norm_eq_abs,abs_of_nonneg (h0 u)] using hbound u) + refine ⟨integral_nonneg h0,?_⟩ + have hh := integral_mono hi (integrable_const B) (fun u => hbound u) + rw [integral_const,smul_eq_mul] at hh + apply hh.trans + have hm : (Q ω).real Set.univ ≤ 1 := by + simpa only [measureReal_def,ENNReal.toReal_one] using ENNReal.toReal_mono (by simp : (1:ℝ≥0∞) ≠ ∞) (hQ ω) + exact mul_le_of_le_one_left hB hm + +lemma integrable_kernel_bounded_integral {Ω G : Type*} [MeasurableSpace Ω] [MeasurableSpace G] + (μ : Measure Ω) [IsFiniteMeasure μ] (Q : Kernel Ω G) [IsFiniteKernel Q] + (F : G → ℝ) (hF : Measurable F) {B : ℝ} (hB : 0 ≤ B) + (h0 : ∀ u, 0 ≤ F u) (hbound : ∀ u, F u ≤ B) + (hQ : ∀ ω, Q ω Set.univ ≤ 1) : + Integrable (fun ω => ∫ u, F u ∂Q ω) μ := by + apply Integrable.of_bound hF.stronglyMeasurable.integral_kernel.aestronglyMeasurable B + exact Eventually.of_forall fun ω => by + obtain ⟨h0',hB'⟩ := kernel_bounded_integral Q F hF hB h0 hbound hQ ω + simpa only [Real.norm_eq_abs,abs_of_nonneg h0'] using hB' + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/KernelSections.lean b/lean/OAI/Probability/Ballisticity/Walk/KernelSections.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7e726d774dfe22cf4b1373b4a009d2940a8619e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/KernelSections.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.Kernel + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace TailDecorrelation + +lemma sampled_kernel_sections {D E J W : Type*} + [MeasurableSpace D] [MeasurableSpace E] [MeasurableSpace J] [MeasurableSpace W] + [Countable J] [MeasurableSingletonClass J] + (δ : Measure D) (σ : Measure E) (P : Measure W) + [IsProbabilityMeasure δ] [IsProbabilityMeasure σ] [IsProbabilityMeasure P] + (κ : Kernel D J) (s : D → E → J) + (hs : Measurable (Function.uncurry s)) (hmap : ∀ d, σ.map (s d) = κ d) + {f : D × W → ℝ} (hf : Measurable f) {Z : J → W → ℝ} + (hZ : ∀ a, Measurable (Z a)) + (hi : Integrable (fun x : (D × E) × W => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2) + ((δ.prod σ).prod P)) : + ∀ᵐ x ∂δ.prod P, f x ≠ 0 → Integrable (fun a => Z a x.2) (κ x.1) := by + have hz : Measurable (Function.uncurry Z) := measurable_from_prod_countable_right hZ + let G : (D × E) × W → ℝ := fun x => f (x.1.1,x.2) * Z (s x.1.1 x.1.2) x.2 + have hG : Measurable G := + (hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)).mul + (hz.comp ((hs.comp measurable_fst).prodMk measurable_snd)) + have hp := swap_seed_preserving δ σ P + have hj : Integrable (fun x : (D × W) × E => f x.1 * Z (s x.1.1 x.2) x.1.2) + ((δ.prod P).prod σ) := (hp.integrable_comp hG.aestronglyMeasurable).mpr hi + filter_upwards [hj.prod_right_ae] with x hx + intro hfx + have hzx : Integrable (fun u => Z (s x.1 u) x.2) σ := by + have hh := hx.const_mul (f x)⁻¹ + simpa only [←mul_assoc, inv_mul_cancel₀ hfx, one_mul] using hh + rw [←hmap] + exact (integrable_map_measure (measurable_of_countable _).aestronglyMeasurable + (hs.comp measurable_prodMk_left).aemeasurable).mpr hzx + +lemma kernel_density_sections {D I A J : Type*} [MeasurableSpace D] [MeasurableSpace A] [Encodable I] + [MeasurableSpace J] [Countable J] [MeasurableSingletonClass J] + [Nonempty J] [StandardBorelSpace J] + (δ : Measure D) (ν : Measure A) [IsProbabilityMeasure δ] [IsProbabilityMeasure ν] + {f : D × (I → A) → ℝ} {Z : J → (I → A) → ℝ} + {c Q : ℝ} (hc : 0 < c) + (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) + (hfi : Integrable f (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hH : Integrable (fun x => entropyPlus (f x)) (δ.prod (Measure.infinitePi (fun _ : I => ν)))) + (hZ : ∀ a, Measurable (Z a)) (hZ0 : ∀ a ω, 0 ≤ Z a ω) + (he : ∀ a, Integrable (fun ω => Real.exp (c * Z a ω)) (Measure.infinitePi (fun _ : I => ν))) + (heQ : ∀ a, (∫ ω, Real.exp (c * Z a ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ Q) + (κ : Kernel D J) [IsMarkovKernel κ] : + ∀ᵐ x ∂δ.prod (Measure.infinitePi (fun _ : I => ν)), + f x ≠ 0 → Integrable (fun a => Z a x.2) (κ x.1) := by + obtain ⟨s,hs,hmap⟩ := Kernel.exists_measurable_map_eq_unitInterval κ + let σ : Measure unitInterval := volume + let g : (D × unitInterval) × (I → A) → ℝ := fun x => f (x.1.1,x.2) + have hg : Measurable g := hf.comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd) + obtain ⟨_,hgH,_⟩ := randomized_density δ σ ν hf hfi hH + have hi := integrable_density_mul_of_entropy hc hg + (measurable_countable_sample hZ hs) (fun x => hf0 _) (fun x => hZ0 _ _) hgH + (sampled_exponential_integrable (δ.prod σ) ν hZ he heQ hs).1 + exact sampled_kernel_sections δ σ (Measure.infinitePi (fun _ : I => ν)) + κ s hs hmap hf hZ hi + +end TailDecorrelation + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +lemma cut_neighborhoods_escape {d : ℕ} (e : Direction d) (a : ℝ) + (k : Fin d) (L U : ℕ → ℤ) + (hL : Tendsto L atTop atBot) (hU : Tendsto U atTop atTop) + (N : ℕ) (S : Set (Lattice d)) (hS : S.Finite) : + ∀ᶠ r in atTop, ∀ p : Lattice d × Lattice d, + p.1 k ≤ L r → U r ≤ p.2 k → Disjoint S (upperPairNeighborhood e a p N) := by + have hz : ∀ z ∈ S, ∀ᶠ r in atTop, ∀ p : Lattice d × Lattice d, + p.1 k ≤ L r → U r ≤ p.2 k → z ∉ LatticeBall p.1 N ∪ LatticeBall p.2 N := by + intro z _ + filter_upwards [(tendsto_atBot.mp hL) (z k - (N : ℤ) - 1), + (tendsto_atTop.mp hU) (z k + (N : ℤ) + 1)] with r hrx hry + intro p hp hq hz + rcases hz with hz | hz + · have hh := (abs_le.mp (hz k)).2 + omega + · have hh := (abs_le.mp (hz k)).1 + omega + filter_upwards [hS.eventually_all.mpr hz] with r hr + intro p hp hq + exact Set.disjoint_left.mpr fun z hz hz' => hr z hz p hp hq hz'.1 + +theorem actual_kernel_tail_decorrelation {d : ℕ} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] (hue : UniformElliptic ν) + (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) : + ∃ A : ℝ, 0 < A ∧ + (∀ᵐ ω ∂environmentLaw ν, ∀ x : Lattice d × Lattice d, + dot (realPosition x.1) (realPosition (step e)) = + dot (realPosition x.2) (realPosition (step e)) → + ∀ t : ℕ, 0 < outwardKernelMass e f (t+1) x ω ∧ + -Real.log (outwardKernelMass e f (t+1) x ω) ≤ + 2*A*Real.log ((t:ℝ)+2)+outwardCanonicalExcess e f A x ω) ∧ + let J := {p : Lattice d × Lattice d // p ∈ PairAtHeight (realPosition (step e)) 0} + let Z : J → Environment d → ℝ := fun p => outwardCanonicalExcess e f A p.1 + BddAbove (Set.range (fun p => ∫ ω, Z p ω ∂environmentLaw ν)) ∧ + ∀ (D : Type) [MeasurableSpace D] (δ : Measure D) [IsProbabilityMeasure δ] + (g : D × Environment d → ℝ), + Measurable g → (∀ x, 0 ≤ g x) → Integrable g (δ.prod (environmentLaw ν)) → + (∫ x, g x ∂δ.prod (environmentLaw ν)) = 1 → + Integrable (fun x => TailDecorrelation.entropyPlus (g x)) (δ.prod (environmentLaw ν)) → + ∀ (κ : ℕ → Kernel D J) [∀ r, IsMarkovKernel (κ r)] (L U : ℕ → D → ℤ), + (∀ᵐ z ∂δ, Tendsto (fun r => L r z) atTop atBot ∧ Tendsto (fun r => U r z) atTop atTop) → + (∀ r, ∀ᵐ z ∂δ, ∀ᵐ p ∂κ r z, p.1.1 f.1 ≤ L r z ∧ U r z ≤ p.1.2 f.1) → + (∀ r, ∀ᵐ z ∂δ.prod (environmentLaw ν), g z ≠ 0 → + Integrable (fun p => Z p z.2) (κ r z.1)) ∧ + (∀ r, Integrable (fun z => g z * (∫ p, Z p z.2 ∂κ r z.1)) (δ.prod (environmentLaw ν))) ∧ + (∀ ε : ℝ, 0 < ε → ∀ᶠ r in atTop, + (∫ z, g z * (∫ p, Z p z.2 ∂κ r z.1) ∂δ.prod (environmentLaw ν)) ≤ + (⨆ p, ∫ ω, Z p ω ∂environmentLaw ν) + ε) ∧ + Filter.limsup (fun r => ∫ z, g z * (∫ p, Z p z.2 ∂κ r z.1) + ∂δ.prod (environmentLaw ν)) atTop ≤ ⨆ p, ∫ ω, Z p ω ∂environmentLaw ν := by + classical + obtain ⟨A,c,B,hA,hc,hB,hbound,hloc⟩ := actual_outward_order ν hue e f hef htrans + let J := {p : Lattice d × Lattice d // p ∈ PairAtHeight (realPosition (step e)) 0} + let Z : J → Environment d → ℝ := fun p => outwardCanonicalExcess e f A p.1 + have hZm : ∀ p : J, Measurable (Z p) := fun p => + ((hbound 0 p.1 p.2).2.1).mono (rowSigma_le _) le_rfl + have hZ0 : ∀ p : J, ∀ ω, 0 ≤ Z p ω := fun p => (hbound 0 p.1 p.2).1 + have he : ∀ p : J, Integrable (fun ω => Real.exp (c * Z p ω)) (environmentLaw ν) := + fun p => (hbound 0 p.1 p.2).2.2.1 + have heB : ∀ p : J, (∫ ω, Real.exp (c * Z p ω) ∂environmentLaw ν) ≤ B := + fun p => (hbound 0 p.1 p.2).2.2.2.1 + have hZi : ∀ p : J, Integrable (Z p) (environmentLaw ν) := fun p => + (integrable_and_mean_le_of_exp (environmentLaw ν) hc (hZm p) (hZ0 p) (he p) (heB p)).1 + have hZB : ∀ p : J, (∫ ω, Z p ω ∂environmentLaw ν) ≤ B / c := fun p => + (integrable_and_mean_le_of_exp (environmentLaw ν) hc (hZm p) (hZ0 p) (he p) (heB p)).2 + have hba : BddAbove (Set.range (fun p : J => ∫ ω, Z p ω ∂environmentLaw ν)) := + ⟨B/c, by rintro _ ⟨p,rfl⟩; exact hZB p⟩ + let p0 : J := ⟨(0,0), by simp [PairAtHeight, dot, realPosition]⟩ + let : Nonempty J := ⟨p0⟩ + have hC : 0 ≤ ⨆ p : J, ∫ ω, Z p ω ∂environmentLaw ν := + (integral_nonneg fun ω => hZ0 p0 ω).trans (le_ciSup hba p0) + refine ⟨A,hA,outward_order_countable_event ν e f A (fun a x hx => (hbound a x hx).2.2.2.2),hba,?_⟩ + intro D mD δ hδ g hgm hg0 hgi hg1 hgH κ hκ L U hcuts htail + have hcap : ∀ K η : ℝ, 0 < K → 0 < η → ∃ N : ℕ, + ∃ F : J → Environment d → ℝ, + (∀ p, @Measurable _ _ (TailDecorrelation.rows (upperPairNeighborhood e 0 p.1 N)) _ (F p)) ∧ + (∀ p ω, 0 ≤ F p ω ∧ F p ω ≤ K) ∧ + (∀ p, (∫ ω, |min K (Z p ω) - F p ω| ∂environmentLaw ν) ≤ η) := by + intro K η hK hη + obtain ⟨N,hN⟩ := outward_cap_locality_L1 ν e f A hloc hK hη + have hh : ∀ p : J, ∃ F : Environment d → ℝ, + @Measurable _ _ (rowSigma (upperPairNeighborhood e 0 p.1 N)) _ F ∧ + (∀ ω, 0 ≤ F ω ∧ F ω ≤ K) ∧ + (∫ ω, |min (Z p ω) K - F ω| ∂environmentLaw ν) < η := + fun p => hN 0 p.1 p.2 + choose F hFm hFb hFe using hh + refine ⟨N,F,?_,hFb,?_⟩ + · intro p + rw [analytic_rows_eq] + exact hFm p + · intro p + simpa only [min_comm] using (hFe p).le + have hesc : ∀ N (S : Set (Lattice d)), S.Finite → ∀ᵐ z ∂δ, + ∀ᶠ r in atTop, ∀ᵐ p ∂κ r z, Disjoint S (upperPairNeighborhood e 0 p.1 N) := by + intro N S hS + filter_upwards [hcuts, ae_all_iff.mpr htail] with z hz ht + filter_upwards [cut_neighborhoods_escape e 0 f.1 (fun r => L r z) (fun r => U r z) + hz.1 hz.2 N S hS] with r hr + filter_upwards [ht r] with p hp + exact hr p.1 hp.1 hp.2 + have he' : ∀ p : J, Integrable (fun ω => Real.exp ((2*(c/2)) * Z p ω)) (environmentLaw ν) := by + simpa only [mul_div_cancel₀ _ (by norm_num : (2:ℝ) ≠ 0)] using he + have heB' : ∀ p : J, (∫ ω, Real.exp ((2*(c/2)) * Z p ω) ∂environmentLaw ν) ≤ B := by + simpa only [show 2*(c/2) = c by ring] using heB + refine ⟨fun r => TailDecorrelation.kernel_density_sections δ ν hc hgm hg0 hgi hgH + hZm hZ0 he heB (κ r), ?_⟩ + refine ⟨fun r => TailDecorrelation.kernel_density_integrable δ ν hc hgm hg0 hgi hgH + hZm hZ0 he heB (κ r), ?_⟩ + have hE := TailDecorrelation.kernel_entropy_decorrelation δ ν (by linarith : 0 < c/2) hC + hgm hg0 hgi hg1 hgH hZm hZ0 he' heB' hZi (fun p => le_ciSup hba p) + (fun N p => upperPairNeighborhood e 0 p.1 N) κ hcap hesc + exact ⟨hE, TailDecorrelation.limsup_le_of_nonneg_eventual + (fun r => integral_nonneg fun z => mul_nonneg (hg0 z) (integral_nonneg fun p => hZ0 _ _)) hE⟩ + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/KernelTranslation.lean b/lean/OAI/Probability/Ballisticity/Walk/KernelTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..82f2cbf6b26394d7fc65f81babb3ad810b540b70 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/KernelTranslation.lean @@ -0,0 +1,119 @@ +import Mathlib +import OAI.Probability.Ballisticity.Stationary.ArrayMap +import OAI.Probability.Ballisticity.Walk.UpperKernel + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical +namespace DirectionalTransience + +lemma hitKernel_translation {d : ℕ} (ω : Environment d) (z x : Lattice d) + (S T U : Set (Lattice d)) : + hitKernel ((fun y => z+y) ⁻¹' S) ((fun y => z+y) ⁻¹' T) ((fun y => ω (z+y)),x) U = + hitKernel S T (ω,z+x) ((fun y => y-z) ⁻¹' U) := by + simp only [hitKernel_apply] + apply tsum_congr + intro n + rw [←quenched_translation ω z x, + Measure.map_apply (by fun_prop) (measurableSet_hitAt _ _ _)] + congr 1 + ext X + simp only [Set.mem_preimage,HitAt,Set.mem_ofPred_eq,Set.mem_inter_iff] + simp only [add_sub_cancel] + +lemma strip_translation {d : ℕ} (ℓ : Vector d) (z x : Lattice d) (H : ℝ) : + (fun y => z+y) ⁻¹' Strip ℓ (z+x) H=Strip ℓ x H := by + ext y + simp only [Set.mem_preimage,Strip,Set.mem_ofPred_eq,dot_realPosition_add] + constructor <;> rintro ⟨h₁,h₂⟩ <;> constructor <;> linarith + +lemma upper_translation {d : ℕ} (ℓ : Vector d) (z x : Lattice d) (H : ℝ) : + (fun y => z+y) ⁻¹' Upper ℓ (z+x) H=Upper ℓ x H := by + ext y + simp only [Set.mem_preimage,Upper,Set.mem_ofPred_eq,dot_realPosition_add] + constructor <;> intro h <;> linarith + +lemma variableHitKernel_translation {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (z x : Lattice d) (U : Set (Lattice d)) : + variableHitKernel ℓ H ((fun y => ω (z+y)),x) U = + variableHitKernel ℓ H (ω,z+x) ((fun y => y-z) ⁻¹' U) := by + simpa only [variableHitKernel,Kernel.coe_mk,strip_translation,upper_translation] using + hitKernel_translation ω z x (Strip ℓ (z+x) H) (Upper ℓ (z+x) H) U + +lemma horizontalProjection_add {d : ℕ} (e : Direction d) (x y : Lattice d) : + horizontalProjection e (x+y)=horizontalProjection e x+horizontalProjection e y := by + apply Subtype.ext + funext j + by_cases hj : j=e.1 + · subst j + simp [horizontalProjection] + · simp [horizontalProjection,Function.update_of_ne hj] + +lemma horizontalProjection_sub {d : ℕ} (e : Direction d) (x y : Lattice d) : + horizontalProjection e (x-y)=horizontalProjection e x-horizontalProjection e y := by + apply Subtype.ext + funext j + by_cases hj : j=e.1 + · subst j + simp [horizontalProjection] + · simp [horizontalProjection,Function.update_of_ne hj] + +lemma horizontalLift_add {d : ℕ} (e : Direction d) (a b : ℤ) (x y : HorizontalSpace e) : + horizontalLift e a x+horizontalLift e b y=horizontalLift e (a+b) (x+y) := by + simp only [horizontalLift,AddSubgroup.coe_add,add_zsmul] + abel + +lemma episodeSpliced_kernel {d : ℕ} (e : Direction d) + (t : Environment d → ℤ → ℕ) (X : EpisodeInput e) (i : ℤ) (m a : ℕ) + (z : HorizontalSpace e) (A : Set (HorizontalSpace e)) : + upperHorizontalKernel e (t X.1.1 (i+m)-t X.1.1 i) + (fun p => episodeSplicedRow e t X i m a p.1 p.2) z A = + variableHitKernel (realPosition (step e)) (t X.1.1 (i+m)-t X.1.1 i) + (X.1.1,horizontalLift e (t X.1.1 i) (X.1.2 (i,a)+z)) + {y | horizontalProjection e y-X.1.2 (i,a)∈A} := by + let b := horizontalLift e (t X.1.1 i) (X.1.2 (i,a)) + let H := t X.1.1 (i+m)-t X.1.1 i + have he : hitKernel (Strip (realPosition (step e)) (horizontalLift e 0 z) H) + (Upper (realPosition (step e)) (horizontalLift e 0 z) H) + (upperEnvironment e (fun p => episodeSplicedRow e t X i m a p.1 p.2),horizontalLift e 0 z)= + hitKernel (Strip (realPosition (step e)) (horizontalLift e 0 z) H) + (Upper (realPosition (step e)) (horizontalLift e 0 z) H) + ((fun y => X.1.1 (b+y)),horizontalLift e 0 z) := by + apply hitKernel_congr + intro y hy + have hy0 : 0 ≤ signedHeight e y := by + have := hy.1 + simp only [signedHeight_projection,signedHeight_horizontalLift,Int.cast_zero] at this + exact_mod_cast this + have hyH : (signedHeight e y).toNat X.1.1 (b+y)),horizontalLift e 0 z) + (horizontalProjection e ⁻¹' A)=_ + rw [variableHitKernel_translation] + dsimp only [b] + rw [horizontalLift_add,add_zero] + congr 1 + ext y + simp only [Set.mem_preimage,Set.mem_ofPred_eq,horizontalProjection_sub,horizontalProjection_lift] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/OutwardCanonicalRows.lean b/lean/OAI/Probability/Ballisticity/Walk/OutwardCanonicalRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..26ebf4c373f0c9a8f009cccc7a6e1315096f80d8 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/OutwardCanonicalRows.lean @@ -0,0 +1,60 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.BufferCostBounds +import OAI.Probability.Ballisticity.Entropy.CanonicalLogExcess + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma outwardKernelMass_upper_rows {d : ℕ} (e f : Direction d) (H : ℕ) (hH : 0 < H) + (a : ℝ) (x : Lattice d × Lattice d) (hx : x ∈ PairAtHeight (realPosition (step e)) a) : + @Measurable _ _ (rowSigma {y | a ≤ dot (realPosition y) (realPosition (step e))}) _ + (outwardKernelMass e f H x) := by + have h₁ : Strip (realPosition (step e)) x.1 H ⊆ {y | a ≤ dot (realPosition y) (realPosition (step e))} := by + intro y hy + change a ≤ dot (realPosition y) (realPosition (step e)) + simpa only [hx.1] using hy.1 + have h₂ : Strip (realPosition (step e)) x.2 H ⊆ {y | a ≤ dot (realPosition y) (realPosition (step e))} := by + intro y hy + change a ≤ dot (realPosition y) (realPosition (step e)) + simpa only [hx.2] using hy.1 + exact ((Measure.measurable_coe (Set.to_countable _).measurableSet).comp + (rawPairEndpointLaw_rows (realPosition (step e)) x hH h₁ h₂)).ennreal_toReal + +lemma measurable_outwardKernelMass {d : ℕ} (e f : Direction d) (H : ℕ) + (x : Lattice d × Lattice d) : Measurable (outwardKernelMass e f H x) := by + have h := ((variablePairHitKernel (realPosition (step e)) H).measurable_coe (Set.to_countable + {y : Lattice d × Lattice d | signedCoordinate f (x.2-x.1) ≤ signedCoordinate f (y.2-y.1)}).measurableSet).comp + (measurable_id.prodMk (measurable_const (a:=x))) + change Measurable (fun ω => outwardKernelMass e f H x ω) + simpa only [Function.comp_def,id_eq,variablePairHitKernel_apply,outwardKernelMass] using h.ennreal_toReal + +noncomputable def outwardCanonicalExcess {d : ℕ} (e f : Direction d) (A : ℝ) + (x : Lattice d × Lattice d) : Environment d → ℝ := + canonicalLogExcess A (fun n => outwardKernelMass e f (n+1) x) + +lemma outwardCanonicalExcess_upper_rows {d : ℕ} (e f : Direction d) (A a : ℝ) + (x : Lattice d × Lattice d) (hx : x ∈ PairAtHeight (realPosition (step e)) a) : + @Measurable _ _ (rowSigma {y | a ≤ dot (realPosition y) (realPosition (step e))}) _ + (outwardCanonicalExcess e f A x) := by + let : MeasurableSpace (Environment d) := rowSigma {y | a ≤ dot (realPosition y) (realPosition (step e))} + apply measurable_canonicalLogExcess + intro n + exact outwardKernelMass_upper_rows e f (n+1) (Nat.succ_pos n) a x hx + +lemma measurable_outwardCanonicalExcess {d : ℕ} (e f : Direction d) (A : ℝ) + (x : Lattice d × Lattice d) : Measurable (outwardCanonicalExcess e f A x) := + measurable_canonicalLogExcess A _ (fun n => measurable_outwardKernelMass e f (n+1) x) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/OutwardKernelElementary.lean b/lean/OAI/Probability/Ballisticity/Walk/OutwardKernelElementary.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4002d8217620813cdba47da2092a531c677278c --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/OutwardKernelElementary.lean @@ -0,0 +1,59 @@ +import Mathlib +import OAI.Probability.Ballisticity.Entropy.BufferCostBounds + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter Function +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma outwardKernelMass_lower {d : ℕ} (e f : Direction d) (H : ℕ) + (ω : Environment d) (x : Lattice d × Lattice d) {κ : ℝ≥0} + (hκ : ∀ y, κ ≤ (ω y).1 e) : + (κ:ℝ)^(2*H) ≤ outwardKernelMass e f H x ω := by + let S := {y : Lattice d × Lattice d | signedCoordinate f (x.2-x.1) ≤ signedCoordinate f (y.2-y.1)} + have hlow : ((κ:ℝ≥0∞)^2)^H ≤ rawPairEndpointLaw (realPosition (step e)) H ω x S := by + induction H with + | zero => simp [rawPairEndpointLaw_zero,S] + | succ H ih => + have hh := rawPairEndpointLaw_upward e H ω x hκ S + rw [Measure.smul_apply,smul_eq_mul,Measure.map_apply (measurable_of_countable _) (Set.to_countable _).measurableSet] at hh + have hpre : pairUp e ⁻¹' S=S := by + ext y + simp only [S,Set.mem_preimage,Set.mem_ofPred,pairUp_preserves_gap] + rw [hpre] at hh + apply le_trans _ hh + rw [pow_succ'] + exact mul_le_mul_right ih _ + have hfinite : rawPairEndpointLaw (realPosition (step e)) H ω x S ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top ((measure_mono (Set.subset_univ _)).trans (rawPairEndpointLaw_total_le_one _ _ _ _)) + have hh := ENNReal.toReal_mono hfinite hlow + simpa only [ENNReal.toReal_pow,ENNReal.coe_toReal,←pow_mul,outwardKernelMass,S] using hh + +lemma rawPairEndpointLaw_upper_congr {d : ℕ} (e : Direction d) (H : ℕ) + (a : ℝ) (x : Lattice d × Lattice d) (hx : x ∈ PairAtHeight (realPosition (step e)) a) + (ω η : Environment d) (he : Set.EqOn ω η {y | a ≤ dot (realPosition y) (realPosition (step e))}) : + rawPairEndpointLaw (realPosition (step e)) H ω x = rawPairEndpointLaw (realPosition (step e)) H η x := by + have h₁ : Set.EqOn ω η (Strip (realPosition (step e)) x.1 H) := by + intro y hy + apply he + change a ≤ dot (realPosition y) (realPosition (step e)) + simpa only [hx.1] using hy.1 + have h₂ : Set.EqOn ω η (Strip (realPosition (step e)) x.2 H) := by + intro y hy + apply he + change a ≤ dot (realPosition y) (realPosition (step e)) + simpa only [hx.2] using hy.1 + unfold rawPairEndpointLaw + rw [hitKernel_congr _ _ ω η h₁,hitKernel_congr _ _ ω η h₂] +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/PathCompact.lean b/lean/OAI/Probability/Ballisticity/Walk/PathCompact.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ad6417200994a487a7c6149bbb2eb0fa82fdcc4 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/PathCompact.lean @@ -0,0 +1,433 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GridOscillation + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +namespace DirectionalTransience + +lemma floor_scaled_close {s t u : ℝ} (hs : 0 ≤ s) (_ht : 0 ≤ t) + (hu : 4 ≤ u) (hst : |s-t| ≤ u/2) : ⌊s⌋₊ ≤ ⌊t⌋₊+⌊u⌋₊ := by + have h1 := Nat.floor_le hs + have h2 := Nat.lt_floor_add_one t + have h3 := Nat.lt_floor_add_one u + have hb := (abs_le.mp hst).2 + have he : (⌊s⌋₊:ℝ) ≤ (⌊t⌋₊:ℝ)+(⌊u⌋₊:ℝ) := by linarith + exact_mod_cast he + +lemma scaledPolygon_oscillation_subset {Ω : Type*} (X : ℕ → Ω → ℝ) + {r n T ε δ : ℝ} (hr : 0 < r) (hn : 2 ≤ n) (hT : 0 ≤ T) + (_hδ : 0 < δ) (hδn : 4 ≤ δ*n) : + {ω | scaledPolygon (fun k => X k ω) r n T ∈ ContinuousOscillation (3*ε) + (δ/(2*(T+1)))} ⊆ GridOscillation X ⌊(T+1)*n⌋₊ ⌊δ*n⌋₊ (ε*r) := by + intro ω hω + by_contra hg + rcases hω with ⟨s,t,hst,hbig⟩ + have hn0 : 0 ≤ n := by linarith + have hTn : 0 ≤ T*n := mul_nonneg hT hn0 + have hs : 0 ≤ T*n*(s:ℝ) := mul_nonneg hTn s.2.1 + have ht : 0 ≤ T*n*(t:ℝ) := mul_nonneg hTn t.2.1 + have hsle : T*n*(s:ℝ) ≤ T*n := mul_le_of_le_one_right hTn s.2.2 + have htle : T*n*(t:ℝ) ≤ T*n := mul_le_of_le_one_right hTn t.2.2 + have hsP : ⌊T*n*(s:ℝ)⌋₊ < ⌊T*n⌋₊+1 := Nat.lt_succ_of_le (Nat.floor_mono hsle) + have htP : ⌊T*n*(t:ℝ)⌋₊ < ⌊T*n⌋₊+1 := Nat.lt_succ_of_le (Nat.floor_mono htle) + have hP : ⌊T*n⌋₊+1 ≤ ⌊(T+1)*n⌋₊ := by + apply Nat.le_floor + have hf := Nat.floor_le hTn + push_cast + nlinarith + have hH : 1 ≤ ⌊δ*n⌋₊ := by apply Nat.le_floor; norm_num; linarith + have hst' : |(s:ℝ)-(t:ℝ)| ≤ δ/(2*(T+1)) := hst + have hclose : |T*n*(s:ℝ)-T*n*(t:ℝ)| ≤ (δ*n)/2 := by + rw [← mul_sub,abs_mul,abs_of_nonneg hTn] + have h1 := mul_le_mul_of_nonneg_left hst' hTn + have hden : 0 < 2*(T+1) := by positivity + have he : T*n*(δ/(2*(T+1))) ≤ δ*n/2 := by + rw [← mul_div_assoc] + apply (div_le_iff₀ hden).2 + nlinarith [mul_nonneg _hδ.le hn0] + exact h1.trans he + have hb := linearPolygon_oscillation_le X hg hH hP hs ht hsP htP + (floor_scaled_close hs ht hδn hclose) + (floor_scaled_close ht hs hδn (by simpa [abs_sub_comm] using hclose)) + simp only [scaledPolygon_apply] at hbig + rw [← sub_div,abs_div,abs_of_pos hr] at hbig + have hlarge := (lt_div_iff₀ hr).mp hbig + rw [abs_sub_comm] at hb + nlinarith + +theorem gaussian_continuous_modulus {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T ε β : ℝ} (hT : 0 ≤ T) (hε : 0 < ε) (hβ : 0 < β) : + ∃ δ : ℝ, 0 < δ ∧ ∀ᶠ i in atTop, + μ.real {ω | scaledPolygon (fun k => X k ω) (r i) + (fluctuationScale μ (X 0) (r i)) T ∈ ContinuousOscillation ε δ} ≤ β := by + let n := fun i => fluctuationScale μ (X 0) (r i) + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto μ (X 0) (hX 0) hI hne).comp hr.1 + obtain ⟨δ,hδ,hb⟩ := gaussian_grid_modulus μ X hX hind hident hsym hI hne r hr + (T := T+1) (ε := ε/3) (by linarith) (by positivity) hβ + refine ⟨δ/(2*(T+1)),by positivity,?_⟩ + have hδn : Tendsto (fun i => δ*n i) atTop atTop := hn.const_mul_atTop hδ + filter_upwards [hb,hr.1.eventually (eventually_gt_atTop (0:ℝ)), + hn.eventually (eventually_ge_atTop (2:ℝ)),hδn.eventually (eventually_ge_atTop (4:ℝ))] + with i hi hri hni hdni + have hs := scaledPolygon_oscillation_subset X hri hni hT hδ hdni (ε := ε/3) + have he : 3*(ε/3)=ε := by ring + rw [he] at hs + exact (measureReal_mono hs (measure_ne_top _ _)).trans hi + +lemma linearPolygon_abs_le_max (x : ℕ → ℝ) {N : ℕ} {t : ℝ} + (ht : 0 ≤ t) (hN : ⌊t⌋₊ < N) : |linearPolygon x N t| ≤ partialSumMax x N := by + let j := ⌊t⌋₊ + have hj : (j:ℝ) ≤ t := Nat.floor_le ht + have hj1 : t < j+1 := Nat.lt_floor_add_one t + have h1 := (abs_partialSum_le_max x j).trans (partialSumMax_mono x hN.le) + have h2 := (abs_partialSum_le_max x (j+1)).trans (partialSumMax_mono x hN) + rw [linearPolygon_formula x N ht hN] + have he : realPartialSum x j+(t-j)*x j = + (1-(t-j))*realPartialSum x j+(t-j)*realPartialSum x (j+1) := by + rw [realPartialSum_succ] + ring + change |realPartialSum x j+(t-j)*x j| ≤ _ + rw [he] + calc + _ ≤ |(1-(t-j))*realPartialSum x j|+|(t-j)*realPartialSum x (j+1)| := abs_add_le _ _ + _ = (1-(t-j))*|realPartialSum x j|+(t-j)*|realPartialSum x (j+1)| := by + rw [abs_mul,abs_mul,abs_of_nonneg (show 0 ≤ 1-(t-j) by linarith), + abs_of_nonneg (show 0 ≤ t-j by linarith)] + _ ≤ (1-(t-j))*partialSumMax x N+(t-j)*partialSumMax x N := by gcongr; linarith + _ = _ := by ring + +lemma norm_scaledPolygon_le_max (x : ℕ → ℝ) {r n T : ℝ} + (hr : 0 < r) (hn : 0 ≤ n) (hT : 0 ≤ T) : + ‖scaledPolygon x r n T‖ ≤ partialSumMax x (⌊T*n⌋₊+1)/r := by + apply (ContinuousMap.norm_le_of_nonempty _).mpr + intro t + rw [Real.norm_eq_abs,scaledPolygon_apply,abs_div,abs_of_pos hr] + apply (div_le_div_iff_of_pos_right hr).2 + apply linearPolygon_abs_le_max + · exact mul_nonneg (mul_nonneg hT hn) t.2.1 + · exact Nat.lt_succ_of_le (Nat.floor_mono (mul_le_of_le_one_right (mul_nonneg hT hn) t.2.2)) + +lemma gaussian_max_horizon_eventually {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hne : 0 < μ {ω | X 0 ω ≠ 0}) (r : ℕ → ℝ) + (hr : IsGaussianSequence μ (X 0) r) {α ε β : ℝ} + (hα : 0 ≤ α) (hε : 0 < ε) (hβ : 0 < β) + (H : ℕ → ℕ) (hH : ∀ᶠ i in atTop, (H i : ℝ) ≤ α*fluctuationScale μ (X 0) (r i)) : + ∀ᶠ i in atTop, μ.real {ω | ε*r i < partialSumMax (fun k => X k ω) (H i)} ≤ + (32*α+96*α^2)/ε^4+β := by + have he := (hr.2 1 zero_lt_one).const_mul α + have hb := (tendsto_order.mp he).2 β (by simpa using hβ) + filter_upwards [hb,hH,hr.1.eventually (eventually_gt_atTop (0:ℝ))] with i hi hHi hri + have h := measureReal_max_scaled_fourth_le μ X hX hind hident hsym hne hri + (η := 1) zero_le_one le_rfl hε hα (H i) 0 hHi + simp only [Nat.zero_add,one_mul,one_pow,mul_one] at h hi + linarith + +lemma gaussian_continuous_norm_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T β : ℝ} (hT : 0 ≤ T) (hβ : 0 < β) : + ∃ R : ℝ, 0 < R ∧ ∀ᶠ i in atTop, + μ.real {ω | R < ‖scaledPolygon (fun k => X k ω) (r i) + (fluctuationScale μ (X 0) (r i)) T‖} ≤ β := by + let n := fun i => fluctuationScale μ (X 0) (r i) + let C := 32*(T+1)+96*(T+1)^2 + have hC : 0 < C := by dsimp [C]; positivity + let R := max 1 (2*C/β) + have hR1 : 1 ≤ R := le_max_left _ _ + have hR : 0 < R := zero_lt_one.trans_le hR1 + have hRβ : 2*C ≤ R*β := (div_le_iff₀ hβ).mp (le_max_right _ _) + have hR4 : R ≤ R^4 := by nlinarith [sq_nonneg (R-1),sq_nonneg (R^2-1)] + have hsmall : C/R^4 ≤ β/2 := by + rw [div_le_iff₀ (pow_pos hR 4)] + nlinarith + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto μ (X 0) (hX 0) hI hne).comp hr.1 + have hH : ∀ᶠ i in atTop, (⌊T*n i⌋₊+1 : ℝ) ≤ (T+1)*n i := by + filter_upwards [hn.eventually (eventually_ge_atTop (1:ℝ))] with i hi + have hf := Nat.floor_le (mul_nonneg hT (by linarith : 0 ≤ n i)) + nlinarith + have hH' : ∀ᶠ i in atTop, ((⌊T*n i⌋₊+1:ℕ):ℝ) ≤ (T+1)*n i := by simpa using hH + have hb := gaussian_max_horizon_eventually μ X hX hind hident hsym hne r hr + (by linarith : 0 ≤ T+1) hR (by linarith : 0 < β/2) (fun i => ⌊T*n i⌋₊+1) hH' + refine ⟨R,hR,?_⟩ + filter_upwards [hb,hn.eventually (eventually_ge_atTop (0:ℝ)), + hr.1.eventually (eventually_gt_atTop (0:ℝ))] with i hi hni hri + have hs : {ω | R < ‖scaledPolygon (fun k => X k ω) (r i) (n i) T‖} ⊆ + {ω | R*r i < partialSumMax (fun k => X k ω) (⌊T*n i⌋₊+1)} := by + intro ω hω + exact (lt_div_iff₀ hri).mp (hω.trans_le (norm_scaledPolygon_le_max _ hri hni hT)) + exact ((measureReal_mono hs (measure_ne_top _ _)).trans hi).trans (by linarith) + +lemma continuousOscillation_mono {ε δ δ' : ℝ} (hδ : δ ≤ δ') : + ContinuousOscillation ε δ ⊆ ContinuousOscillation ε δ' := by + rintro f ⟨s,t,hst,h⟩ + exact ⟨s,t,hst.trans hδ,h⟩ + +lemma continuousOscillation_iInter_empty {ε : ℝ} (hε : 0 < ε) : + (⋂ m : ℕ, ContinuousOscillation ε (1/(m+1))) = ∅ := by + apply Set.eq_empty_iff_forall_notMem.2 + intro f hf + obtain ⟨δ,hδ,hfδ⟩ := Metric.uniformContinuous_iff.mp (CompactSpace.uniformContinuous_of_continuous f.continuous) ε hε + have hm := (tendsto_order.mp (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ))).2 δ hδ + obtain ⟨m,hm⟩ := hm.exists + rcases Set.mem_iInter.mp hf m with ⟨s,t,hst,hbig⟩ + have hc := hfδ (hst.trans_lt hm) + exact (not_lt_of_ge hbig.le) (by simpa [Real.dist_eq] using hc) + +lemma tendsto_measure_continuousOscillation (μ : Measure C(unitInterval,ℝ)) + [IsFiniteMeasure μ] {ε : ℝ} (hε : 0 < ε) : + Tendsto (fun m : ℕ => μ (ContinuousOscillation ε (1/(m+1)))) atTop (𝓝 0) := by + have ha : Antitone (fun m : ℕ => ContinuousOscillation ε (1/(m+1))) := by + intro j k hjk + apply continuousOscillation_mono + gcongr + have h := tendsto_measure_iInter_atTop (μ := μ) + (fun m : ℕ => (isOpen_continuousOscillation ε (1/(m+1))).measurableSet.nullMeasurableSet) + ha ⟨0,measure_ne_top _ _⟩ + rw [continuousOscillation_iInter_empty hε,measure_empty] at h + exact h + +lemma continuous_modulus_uniform_of_eventual + (μ : ℕ → Measure C(unitInterval,ℝ)) [∀ i, IsFiniteMeasure (μ i)] + (h : ∀ ε β : ℝ, 0 < ε → 0 < β → ∃ δ : ℝ, 0 < δ ∧ + ∀ᶠ i in atTop, μ i (ContinuousOscillation ε δ) ≤ ENNReal.ofReal β) : + ∀ ε β : ℝ, 0 < ε → 0 < β → ∃ δ : ℝ, 0 < δ ∧ + ∀ i, μ i (ContinuousOscillation ε δ) ≤ ENNReal.ofReal β := by + intro ε β hε hβ + obtain ⟨δ,hδ,hb⟩ := h ε β hε hβ + obtain ⟨N,hN⟩ := eventually_atTop.1 hb + have he : ∀ᶠ m : ℕ in atTop, ∀ j : Fin N, + μ j (ContinuousOscillation ε (1/(m+1))) ≤ ENNReal.ofReal β := by + apply eventually_all.2 + intro j + exact ((tendsto_order.mp (tendsto_measure_continuousOscillation (μ j) hε)).2 + _ (ENNReal.ofReal_pos.mpr hβ)).mono (fun _ hm => hm.le) + obtain ⟨m,hm⟩ := he.exists + refine ⟨min δ (1/(m+1)),lt_min hδ (by positivity),?_⟩ + intro i + by_cases hi : N ≤ i + · exact (measure_mono (continuousOscillation_mono (min_le_left _ _))).trans (hN i hi) + · exact (measure_mono (continuousOscillation_mono (min_le_right _ _))).trans + (hm ⟨i,by omega⟩) + +lemma continuous_norm_uniform_of_eventual + (μ : ℕ → Measure C(unitInterval,ℝ)) [∀ i, IsFiniteMeasure (μ i)] + (h : ∀ β : ℝ, 0 < β → ∃ R : ℝ, 0 < R ∧ + ∀ᶠ i in atTop, μ i {f | R < ‖f‖} ≤ ENNReal.ofReal β) : + ∀ β : ℝ, 0 < β → ∃ R : ℝ, 0 < R ∧ + ∀ i, μ i {f | R < ‖f‖} ≤ ENNReal.ofReal β := by + intro β hβ + obtain ⟨R,hR,hb⟩ := h β hβ + obtain ⟨N,hN⟩ := eventually_atTop.1 hb + have he : ∀ᶠ r : ℝ in atTop, ∀ j : Fin N, + μ j {f | r < ‖f‖} ≤ ENNReal.ofReal β := by + apply eventually_all.2 + intro j + have ht := tendsto_measure_norm_gt_of_isTightMeasureSet + (isTightMeasureSet_singleton (μ := μ j)) + simp only [Set.mem_singleton_iff,iSup_iSup_eq_left] at ht + exact ((tendsto_order.mp ht).2 _ (ENNReal.ofReal_pos.mpr hβ)).mono (fun _ hm => hm.le) + obtain ⟨r,hr⟩ := he.exists + refine ⟨max R r, hR.trans_le (le_max_left _ _),?_⟩ + intro i + by_cases hi : N ≤ i + · exact (measure_mono (μ := μ i) (show {f : C(unitInterval,ℝ) | max R r < ‖f‖} ⊆ {f | R < ‖f‖} from fun _ hf => (le_max_left R r).trans_lt hf)).trans (hN i hi) + · exact (measure_mono (μ := μ i) (show {f : C(unitInterval,ℝ) | max R r < ‖f‖} ⊆ {f | r < ‖f‖} from fun _ hf => (le_max_right R r).trans_lt hf)).trans + (hr ⟨i,by omega⟩) + +noncomputable def pathCompact (R : ℝ) (δ : ℕ → ℝ) : Set C(unitInterval,ℝ) := + {f | ‖f‖ ≤ R} ∩ ⋂ m : ℕ, (ContinuousOscillation (1/(m+1)) (δ m))ᶜ + +lemma isClosed_pathCompact (R : ℝ) (δ : ℕ → ℝ) : IsClosed (pathCompact R δ) := by + exact (isClosed_le continuous_norm continuous_const).inter + (isClosed_iInter (fun m => (isOpen_continuousOscillation _ _).isClosed_compl)) + +lemma isCompact_pathCompact (R : ℝ) (δ : ℕ → ℝ) (hδ : ∀ m, 0 < δ m) : + IsCompact (pathCompact R δ) := by + let e := ContinuousMap.isometryEquivBoundedOfCompact unitInterval ℝ + have hc : IsCompact (e.symm ⁻¹' pathCompact R δ) := by + apply BoundedContinuousFunction.arzela_ascoli₂ (Set.Icc (-R) R) isCompact_Icc + (e.symm ⁻¹' pathCompact R δ) ((isClosed_pathCompact R δ).preimage e.symm.continuous) + · intro f t hf + have hnorm : ‖e.symm f‖ ≤ R := hf.1 + have hval := ContinuousMap.norm_coe_le_norm (e.symm f) t + have habs : |f t| ≤ R := hval.trans hnorm + exact abs_le.mp habs + · intro t + apply Metric.equicontinuousAt_iff.2 + intro ε hε + have hm := (tendsto_order.mp (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ))).2 ε hε + obtain ⟨m,hm⟩ := hm.exists + refine ⟨δ m,hδ m,?_⟩ + intro s hst f + have hf := Set.mem_iInter.mp f.2.2 m + have hb : |f.1 t-f.1 s| ≤ 1/(m+1) := by + by_contra! hb + exact hf ⟨t,s,by simpa [dist_comm] using hst.le,hb⟩ + simpa [Real.dist_eq] using hb.trans_lt hm + have he : e.symm '' (e.symm ⁻¹' pathCompact R δ) = pathCompact R δ := + Set.image_preimage_eq _ e.symm.surjective + rw [← he] + exact hc.image e.symm.continuous + +lemma isTightMeasureSet_of_continuous_modulus + (μ : ℕ → Measure C(unitInterval,ℝ)) [∀ i, IsFiniteMeasure (μ i)] + (hnorm : ∀ β : ℝ, 0 < β → ∃ R : ℝ, 0 < R ∧ + ∀ᶠ i in atTop, μ i {f | R < ‖f‖} ≤ ENNReal.ofReal β) + (hmod : ∀ ε β : ℝ, 0 < ε → 0 < β → ∃ δ : ℝ, 0 < δ ∧ + ∀ᶠ i in atTop, μ i (ContinuousOscillation ε δ) ≤ ENNReal.ofReal β) : + IsTightMeasureSet (Set.range μ) := by + have hn := continuous_norm_uniform_of_eventual μ hnorm + have hm := continuous_modulus_uniform_of_eventual μ hmod + apply isTightMeasureSet_iff_exists_isCompact_measure_compl_le.2 + intro ε hε + obtain ⟨b,hb,hbs⟩ := ENNReal.exists_pos_sum_of_countable hε.ne' ℕ + obtain ⟨R,hR,hRb⟩ := hn (b 0) (by exact_mod_cast hb 0) + have hd : ∀ m : ℕ, ∃ δ : ℝ, 0 < δ ∧ ∀ i, + μ i (ContinuousOscillation (1/(m+1)) δ) ≤ (b (m+1) : ℝ≥0∞) := by + intro m + simpa only [ENNReal.ofReal_coe_nnreal] using + hm (1/(m+1)) (b (m+1)) (by positivity) (by exact_mod_cast hb (m+1)) + choose δ hδ hd using hd + refine ⟨pathCompact R δ,isCompact_pathCompact R δ hδ,?_⟩ + rintro _ ⟨i,rfl⟩ + have he : (pathCompact R δ)ᶜ = {f | R < ‖f‖} ∪ + ⋃ m : ℕ, ContinuousOscillation (1/(m+1)) (δ m) := by + ext f + simp [pathCompact,imp_iff_not_or] + rw [he] + calc + _ ≤ μ i {f | R < ‖f‖}+μ i (⋃ m : ℕ, ContinuousOscillation (1/(m+1)) (δ m)) := measure_union_le _ _ + _ ≤ (b 0 : ℝ≥0∞) + ∑' m : ℕ, (b (m+1) : ℝ≥0∞) := by + gcongr + · simpa only [ENNReal.ofReal_coe_nnreal] using hRb i + · exact (measure_iUnion_le _).trans (ENNReal.tsum_le_tsum (fun m => hd m i)) + _ = ∑' m : ℕ, (b m : ℝ≥0∞) := (tsum_eq_zero_add' (f := fun m : ℕ => (b m : ℝ≥0∞)) ENNReal.summable).symm + _ ≤ ε := hbs.le + +theorem gaussian_iid_path_tight {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hX : ∀ k, Measurable (X k)) (hind : iIndepFun X μ) + (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (hsym : IdentDistrib (X 0) (fun ω => -X 0 ω) μ μ) + (hI : Integrable (X 0) μ) (hne : 0 < μ {ω | X 0 ω ≠ 0}) + (r : ℕ → ℝ) (hr : IsGaussianSequence μ (X 0) r) + {T : ℝ} (hT : 0 ≤ T) : + IsTightMeasureSet (Set.range (fun i => μ.map (fun ω => + scaledPolygon (fun k => X k ω) (r i) (fluctuationScale μ (X 0) (r i)) T))) := by + let P := fun i ω => scaledPolygon (fun k => X k ω) (r i) + (fluctuationScale μ (X 0) (r i)) T + have hP : ∀ i, Measurable (P i) := fun i => measurable_scaledPolygon X hX _ _ _ + have : ∀ i, IsProbabilityMeasure (μ.map (P i)) := fun i => + (Measure.isProbabilityMeasure_map_iff (hP i).aemeasurable).mpr inferInstance + apply isTightMeasureSet_of_continuous_modulus + · intro β hβ + obtain ⟨R,hR,hb⟩ := gaussian_continuous_norm_bound μ X hX hind hident hsym hI hne r hr hT hβ + refine ⟨R,hR,hb.mono (fun i hi => ?_)⟩ + rw [Measure.map_apply (hP i) (isOpen_lt continuous_const continuous_norm).measurableSet] + exact (ENNReal.le_ofReal_iff_toReal_le (measure_ne_top _ _) hβ.le).2 hi + · intro ε β hε hβ + obtain ⟨δ,hδ,hb⟩ := gaussian_continuous_modulus μ X hX hind hident hsym hI hne r hr hT hε hβ + refine ⟨δ,hδ,hb.mono (fun i hi => ?_)⟩ + rw [Measure.map_apply (hP i) (isOpen_continuousOscillation ε δ).measurableSet] + exact (ENNReal.le_ofReal_iff_toReal_le (measure_ne_top _ _) hβ.le).2 hi + +lemma tendstoInMeasure_pi {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] + (μ : Measure Ω) [IsFiniteMeasure μ] (F : ℕ → Ω → ι → ℝ) + (h : ∀ j, TendstoInMeasure μ (fun n ω => F n ω j) atTop 0) : + TendstoInMeasure μ F atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + have ht : Tendsto (fun n => ∑ j, μ.real {ω | ε ≤ |F n ω j|}) atTop (𝓝 0) := by + convert tendsto_finsetSum Finset.univ (fun j _ => + (tendstoInMeasure_iff_measureReal_norm.1 (h j)) ε hε) using 1 <;> + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs,Finset.sum_const_zero] + apply squeeze_zero (fun _ => measureReal_nonneg) _ ht + intro n + have hs : {ω | ε ≤ ‖F n ω-(0 : Ω → ι → ℝ) ω‖} ⊆ ⋃ j, {ω | ε ≤ |F n ω j|} := by + intro ω hω + by_contra! hc + have hl : ‖F n ω‖ < ε := (pi_norm_lt_iff hε).2 (by simpa [Real.norm_eq_abs] using hc) + exact (not_lt_of_ge (show ε ≤ ‖F n ω‖ by simpa using hω)) hl + exact (measureReal_mono hs (measure_ne_top _ _)).trans (measureReal_iUnion_fintype_le _) + +lemma tendstoInMeasure_of_abs_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (F G : ℕ → Ω → ℝ) + (hG : TendstoInMeasure μ G atTop 0) + (hb : ∀ᶠ n in atTop, ∀ ω, |F n ω| ≤ |G n ω|) : + TendstoInMeasure μ F atTop 0 := by + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + have hg := (tendstoInMeasure_iff_measureReal_norm.1 hG) ε hε + simp only [Pi.zero_apply,sub_zero,Real.norm_eq_abs] at hg ⊢ + apply squeeze_zero' (Eventually.of_forall fun _ => measureReal_nonneg) _ hg + filter_upwards [hb] with n hn + exact measureReal_mono (fun ω hω => hω.trans (hn ω)) (measure_ne_top _ _) + +lemma selected_iid_div_tendstoInMeasure {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (X : ℕ → Ω → ℝ) + (hX : Measurable (X 0)) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (r : ℕ → ℝ) (hr : Tendsto r atTop atTop) (k : ℕ → ℕ) : + TendstoInMeasure μ (fun n ω => X (k n) ω/r n) atTop 0 := by + have h0 : TendstoInMeasure μ (fun n ω => X 0 ω/r n) atTop 0 := by + apply tendstoInMeasure_of_tendsto_ae (fun n => (hX.div_const _).aestronglyMeasurable) + filter_upwards [] with ω + exact tendsto_const_nhds.div_atTop hr + apply tendstoInMeasure_iff_measureReal_norm.2 + intro ε hε + have he n : μ.real {ω | ε ≤ ‖X (k n) ω/r n-(0 : Ω → ℝ) ω‖} = + μ.real {ω | ε ≤ ‖X 0 ω/r n-(0 : Ω → ℝ) ω‖} := by + simp only [Pi.zero_apply,sub_zero] + unfold Measure.real + apply congrArg ENNReal.toReal + exact ((hident (k n)).comp (show Measurable (fun x : ℝ => x/r n) by fun_prop)).measure_mem_eq + (s := {x : ℝ | ε ≤ ‖x‖}) (isClosed_le continuous_const continuous_norm).measurableSet + simp_rw [he] + exact (tendstoInMeasure_iff_measureReal_norm.1 h0) ε hε + +lemma polygon_eval_error_tendstoInMeasure {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (X : ℕ → Ω → ℝ) + (hX : Measurable (X 0)) (hident : ∀ k, IdentDistrib (X k) (X 0) μ μ) + (r n : ℕ → ℝ) (hr : Tendsto r atTop atTop) (hn : ∀ᶠ i in atTop, 0 ≤ n i) + {T : ℝ} (hT : 0 ≤ T) (s : unitInterval) : + TendstoInMeasure μ (fun i ω => scaledPolygon (fun k => X k ω) (r i) (n i) T s - + realPartialSum (fun k => X k ω) ⌊(T*s)*n i⌋₊/r i) atTop 0 := by + have hsel := selected_iid_div_tendstoInMeasure μ X hX hident r hr (fun i => ⌊(T*s)*n i⌋₊) + apply tendstoInMeasure_of_abs_le μ _ _ hsel + filter_upwards [hn,hr.eventually (eventually_gt_atTop (0:ℝ))] with i hni hri + intro ω + rw [scaledPolygon_apply] + have he : T*n i*s = (T*s)*n i := by ring + rw [he,← sub_div,abs_div,abs_div] + apply div_le_div_of_nonneg_right _ (abs_nonneg _) + apply linearPolygon_near_partialSum + · exact mul_nonneg (mul_nonneg hT s.2.1) hni + · apply Nat.lt_succ_of_le + apply Nat.floor_mono + calc + (T*s)*n i = (T*n i)*s := by ring + _ ≤ T*n i := mul_le_of_le_one_right (mul_nonneg hT hni) s.2.2 + · exact le_rfl + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/PathPointMean.lean b/lean/OAI/Probability/Ballisticity/Walk/PathPointMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d1c575373de9ecaed57bf0c13526e215bd86a68 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/PathPointMean.lean @@ -0,0 +1,123 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.WeakPathEvalTendsto +import OAI.Probability.Ballisticity.Estimates.GaussianPiReal + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def pathPointMean (G : Measure C(unitInterval,ℝ)) (t : unitInterval) : ℝ := + ∫ g, g t ∂G + +lemma path_finite_gaussian_marginal (G : ProbabilityMeasure C(unitInterval,ℝ)) + (hG : ∀ I : Finset unitInterval, + IsGaussian ((G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g))) + (t : unitInterval) : IsGaussian ((G : Measure C(unitInterval,ℝ)).map (fun g => g t)) := by + let I : Finset unitInterval := {t} + let μ := (G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) + have : IsGaussian μ := hG I + let L : (I → ℝ) →L[ℝ] ℝ := .proj ⟨t,by simp [I]⟩ + have he : μ.map L = (G : Measure C(unitInterval,ℝ)).map (fun g => g t) := by + rw [Measure.map_map L.measurable (continuous_path_restrict I).measurable] + rfl + rw [← he] + infer_instance + +lemma path_marginal_eq_gaussian (G : ProbabilityMeasure C(unitInterval,ℝ)) + (hG : ∀ I : Finset unitInterval, + IsGaussian ((G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g))) + (t : unitInterval) : + (G : Measure C(unitInterval,ℝ)).map (fun g => g t) = + gaussianReal (pathPointMean G t) (Var[fun g : C(unitInterval,ℝ) => g t; G]).toNNReal := by + have : IsGaussian ((G : Measure C(unitInterval,ℝ)).map (fun g => g t)) := path_finite_gaussian_marginal G hG t + rw [IsGaussian.eq_gaussianReal ((G : Measure C(unitInterval,ℝ)).map (fun g => g t)) inferInstance] + congr 1 + · exact integral_map (continuous_eval_const t).measurable.aemeasurable measurable_id.aestronglyMeasurable + · rw [variance_map measurable_id.aemeasurable (continuous_eval_const t).measurable.aemeasurable]; rfl + +lemma continuous_pathPointMean (G : ProbabilityMeasure C(unitInterval,ℝ)) + (hG : ∀ I : Finset unitInterval, + IsGaussian ((G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g))) : + Continuous (pathPointMean G) := + continuous_gaussian_path_mean G (pathPointMean G) _ (path_marginal_eq_gaussian G hG) + +lemma path_finite_mean (G : ProbabilityMeasure C(unitInterval,ℝ)) (I : Finset unitInterval) + (hG : IsGaussian ((G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g))) : + (∫ x, x ∂(G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g)) = + I.restrict (pathPointMean G) := by + have := hG + ext t + change (ContinuousLinearMap.proj t : (I → ℝ) →L[ℝ] ℝ) (∫ x, x ∂(G : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g)) = pathPointMean G t + rw [← IsGaussian.integral_dual (μ := (G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g)) (.proj t),integral_map + (continuous_path_restrict I).measurable.aemeasurable (by fun_prop)] + rfl + +theorem path_iid_difference_centered (G W : ProbabilityMeasure C(unitInterval,ℝ)) (T : ℝ) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw T I) + (hG : ((G : Measure C(unitInterval,ℝ)).prod G).map + (fun p : C(unitInterval,ℝ) × C(unitInterval,ℝ) => p.1-p.2) = W) + (a : ℝ) (ha : a^2 = 1/2) : + ∃ m : C(unitInterval,ℝ), (∀ t, m t = pathPointMean G t) ∧ + (G : Measure C(unitInterval,ℝ)).map (fun g => g-m) = + (W : Measure C(unitInterval,ℝ)).map (fun g => a • g) := by + have hg := path_of_iid_difference_gaussian G W T hW hG + let m : C(unitInterval,ℝ) := ⟨pathPointMean G,continuous_pathPointMean G hg⟩ + refine ⟨m,fun _ => rfl,?_⟩ + apply continuous_path_measure_ext + intro I + let V := (G : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) + have hd : (V.prod V).map (fun p : (I → ℝ) × (I → ℝ) => p.1-p.2) = gaussianPathFiniteLaw T I := by + rw [path_restrict_iid_diff,hG,hW] + have hh := iid_difference_centered_eq_half V (gaussianPathFiniteLaw T I) + (gaussianPathFiniteLaw_mean T I) hd a ha + rw [path_finite_mean G I (hg I)] at hh + rw [← hW I] at hh + rw [Measure.map_map (show Measurable (fun x : I → ℝ => x-I.restrict (pathPointMean G)) by fun_prop) + (continuous_path_restrict I).measurable, + Measure.map_map (show Measurable (fun x : I → ℝ => a • x) by fun_prop) + (continuous_path_restrict I).measurable] at hh + rw [Measure.map_map (continuous_path_restrict I).measurable (show Measurable (fun g : C(unitInterval,ℝ) => g-m) by fun_prop), + Measure.map_map (continuous_path_restrict I).measurable (show Measurable (fun g : C(unitInterval,ℝ) => a • g) by fun_prop)] + exact hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/PathWindowTest.lean b/lean/OAI/Probability/Ballisticity/Walk/PathWindowTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea84395ec9f33151939acf799054bd835d9d6e94 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/PathWindowTest.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.GaussianPathFiniteLawSingleton +import OAI.Probability.Ballisticity.Renewal.PositiveOpenTest + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BoundedContinuousFunction +namespace DirectionalTransience + +def pathWindowEvent (τ : unitInterval) (δ ρ B : ℝ) : Set C(unitInterval,ℝ) := + {g | Set.MapsTo g (Metric.closedBall τ δ) (Set.Ioo (-ρ) ρ) ∧ ‖g‖ < B} + +lemma isOpen_pathWindowEvent (τ : unitInterval) (δ ρ B : ℝ) : + IsOpen (pathWindowEvent τ δ ρ B) := + (ContinuousMap.isOpen_setOfPred_mapsTo (isCompact_closedBall τ δ) isOpen_Ioo).inter + (isOpen_lt continuous_norm continuous_const) + +lemma pathWindowEvent_compl_nonempty (τ : unitInterval) (δ ρ B : ℝ) (hδ : 0 ≤ δ) : + (pathWindowEvent τ δ ρ B)ᶜ.Nonempty := by + refine ⟨ContinuousMap.const _ (ρ+1),?_⟩ + intro h + have hh := h.1 (Metric.mem_closedBall_self hδ) + change -ρ < ρ+1 ∧ ρ+1 < ρ at hh + linarith [hh.2] + +lemma endpoint_window_covered (τ : unitInterval) (ρ : ℝ) : + {g : C(unitInterval,ℝ) | |g τ| < ρ} ⊆ + ⋃ n : ℕ, pathWindowEvent τ (1/((n:ℝ)+1)) ρ ((n:ℝ)+1) := by + intro g hg + have he : 0 < ρ-|g τ| := sub_pos.mpr hg + obtain ⟨δ,hδ,hgδ⟩ := Metric.continuousAt_iff.mp g.continuous.continuousAt (ρ-|g τ|) he + have hn : ∀ᶠ n : ℕ in atTop, 1/((n:ℝ)+1) < δ := + tendsto_one_div_add_atTop_nhds_zero_nat.eventually_lt_const hδ + have hn' : ∀ᶠ n : ℕ in atTop, ‖g‖ < (n:ℝ)+1 := by + have hh := (tendsto_natCast_atTop_atTop (R := ℝ)).eventually (eventually_gt_atTop ‖g‖) + filter_upwards [hh] with n hn + linarith + obtain ⟨n,hn,hbn⟩ := (hn.and hn').exists + refine Set.mem_iUnion.mpr ⟨n,?_,hbn⟩ + intro t ht + have hd := hgδ (lt_of_le_of_lt ht hn) + have hgt : |g t| < ρ := by + rw [Real.dist_eq] at hd + have ha := abs_add_le (g t-g τ) (g τ) + rw [sub_add_cancel] at ha + linarith + exact abs_lt.mp hgt + +theorem positive_path_window_test (μ : Measure C(unitInterval,ℝ)) [IsFiniteMeasure μ] + (τ : unitInterval) (ρ : ℝ) (hpos : 0 < μ {g | |g τ| < ρ}) : + ∃ δ B : ℝ, 0 < δ ∧ 0 < B ∧ ∃ F : C(unitInterval,ℝ) →ᵇ ℝ, + (∀ g, 0 ≤ F g ∧ F g ≤ 1) ∧ + (∀ g, F g ≠ 0 → ‖g‖ < B ∧ ∀ t : unitInterval, dist t τ ≤ δ → |g t| < ρ) ∧ + 0 < ∫ g, F g ∂μ := by + have hc := endpoint_window_covered τ ρ + have hn : ∃ n : ℕ, 0 < μ (pathWindowEvent τ (1/((n:ℝ)+1)) ρ ((n:ℝ)+1)) := by + by_contra! h + have hz : ∀ n : ℕ, μ (pathWindowEvent τ (1/((n:ℝ)+1)) ρ ((n:ℝ)+1)) = 0 := + fun n => le_antisymm (h n) zero_le + have hu := measure_iUnion_null hz + exact (ne_of_gt hpos) (measure_mono_null hc hu) + obtain ⟨n,hn⟩ := hn + have hB : 0 < (n:ℝ)+1 := by positivity + have hδ : 0 < 1/((n:ℝ)+1) := by positivity + obtain ⟨F,hF,hFs,hFp⟩ := positive_bounded_test_of_open μ + (pathWindowEvent τ (1/((n:ℝ)+1)) ρ ((n:ℝ)+1)) (isOpen_pathWindowEvent _ _ _ _) + (pathWindowEvent_compl_nonempty _ _ _ _ hδ.le) hn + refine ⟨_,_,hδ,hB,F,hF,?_,hFp⟩ + intro g hg + have hh := hFs g hg + refine ⟨hh.2,fun t ht => ?_⟩ + exact abs_lt.mpr (hh.1 ht) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma gaussianReal_centered_window_pos (v : ℝ≥0) {ρ : ℝ} (hρ : 0 < ρ) : + 0 < gaussianReal 0 v {z : ℝ | |z| < ρ} := by + by_cases hv : v = 0 + · rw [hv,gaussianReal_zero_var] + simp [hρ] + · apply pos_iff_ne_zero.mpr + intro hz + have hh := gaussianReal_absolutelyContinuous' 0 hv hz + have hs : {z : ℝ | |z| < ρ} = Set.Ioo (-ρ) ρ := by + ext z + change |z| < ρ ↔ -ρ < z ∧ z < ρ + exact abs_lt + rw [hs,Real.volume_Ioo,ENNReal.ofReal_eq_zero] at hh + linarith + +theorem brownian_positive_common_time_window (W : ProbabilityMeasure C(unitInterval,ℝ)) (T : ℝ) + (hW : ∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw T I) + (τ : unitInterval) {ρ : ℝ} (hρ : 0 < ρ) : + ∃ δ B : ℝ, 0 < δ ∧ 0 < B ∧ ∃ F : C(unitInterval,ℝ) →ᵇ ℝ, + (∀ g, 0 ≤ F g ∧ F g ≤ 1) ∧ + (∀ g, F g ≠ 0 → ‖g‖ < B ∧ ∀ t : unitInterval, dist t τ ≤ δ → |g t| < ρ) ∧ + 0 < ∫ g, F g ∂(W : Measure C(unitInterval,ℝ)) := by + apply positive_path_window_test + have hp := gaussianReal_centered_window_pos (Real.toNNReal (T*(τ:ℝ))) hρ + rw [← wiener_path_eval W T hW τ] at hp + simpa only [Measure.map_apply (continuous_eval_const τ).measurable + (isOpen_lt (continuous_abs) continuous_const).measurableSet,Set.preimage_ofPred_eq] using hp + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/PreBrownianGridMartingale.lean b/lean/OAI/Probability/Ballisticity/Walk/PreBrownianGridMartingale.lean new file mode 100644 index 0000000000000000000000000000000000000000..4bad95c6ecb772dd0e8d67f63efa10be6f67935d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/PreBrownianGridMartingale.lean @@ -0,0 +1,462 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MartingaleExponentialSubmartingale + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma preBrownian_grid_martingale {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (B : ℝ≥0 → Ω → ℝ) + (hB : IsPreBrownianReal B μ) (hBm : ∀ t, Measurable (B t)) + (t : ℕ → ℝ≥0) (ht : Monotone t) : + Martingale (fun n => B (t n)) + (Filtration.natural (fun n => B (t n)) (fun n => (hBm (t n)).stronglyMeasurable)) μ := by + let X := fun n => B (t n) + let F := Filtration.natural X (fun n => (hBm (t n)).stronglyMeasurable) + apply martingale_of_condExp_sub_eq_zero_nat (Filtration.stronglyAdapted_natural _) + (fun i => hB.integrable_eval (t i)) + intro n + have hn : t n≤t (n+1) := ht (Nat.le_succ n) + have hind := (hB.indepFun_shift (t n)).comp + (show Measurable (fun z : ℝ≥0 → ℝ => z (t (n+1)-t n)) by fun_prop) + (show Measurable (fun z : Set.Iic (t n) → ℝ => + fun j : Set.Iic n => z ⟨t j,ht j.2⟩) by fun_prop) + have he : t n+(t (n+1)-t n) = t (n+1) := add_tsub_cancel_of_le hn + simp only [Function.comp_def, he] at hind + have hD : Measurable (B (t (n+1))-B (t n)) := (hBm _).sub (hBm _) + have hind' : Indep (MeasurableSpace.comap (X (n+1)-X n) inferInstance) (F n) μ := by + rw [Filtration.natural_eq_comap] + exact hind + have hx := condExp_indep_eq hD.comap_le (F.le n) + (comap_measurable (X (n+1)-X n)).stronglyMeasurable hind' + have hzero : (∫ ω, (X (n+1)-X n) ω ∂μ) = 0 := by + change (∫ ω, B (t (n+1)) ω - B (t n) ω ∂μ) = 0 + rw [integral_sub (hB.integrable_eval _) (hB.integrable_eval _), hB.integral_eval,hB.integral_eval,sub_self] + simpa only [hzero, Pi.zero_def] using hx + +lemma preBrownian_grid_abs_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (B : ℝ≥0 → Ω → ℝ) + (hB : IsPreBrownianReal B μ) (hBm : ∀ t, Measurable (B t)) + (t : ℕ → ℝ≥0) (ht : Monotone t) (n : ℕ) (hn : 0<(t n:ℝ)) (a : ℝ) (ha : 0 (hB.hasLaw_eval (t n)).map_eq) n hn a ha + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma preBrownian_finite_abs_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (B : ℝ≥0 → Ω → ℝ) + (hB : IsPreBrownianReal B μ) (hBm : ∀ t, Measurable (B t)) + (T : ℝ≥0) (hT : 0<(T:ℝ)) (I : Finset ℝ≥0) (hI : ∀ z∈I, z≤T) + (a : ℝ) (ha : 0 if hk : k {ω | ∃ k∈Finset.range n, a≤|B (t k) ω|} + have hm : Monotone E := by + intro i j hij ω + rintro ⟨k,hk,hka⟩ + exact ⟨k,Finset.mem_range.mpr ((Finset.mem_range.mp hk).trans_le hij),hka⟩ + have hu : {ω | ∃ k, a≤|B (t k) ω|} = ⋃ n, E n := by + ext ω + simp only [Set.mem_ofPred_eq,Set.mem_iUnion,E] + constructor + · rintro ⟨k,hk⟩; exact ⟨k+1,k,Finset.mem_range.mpr (Nat.lt_succ_self k),hk⟩ + · rintro ⟨n,k,_,hk⟩; exact ⟨k,hk⟩ + have hb n : μ (E n) ≤ ENNReal.ofReal (2*Real.exp (-a^2/(2*T))) := by + have hh := preBrownian_finite_abs_maximal μ B hB hBm T hT + ((Finset.range n).image t) (fun z hz => by + rcases Finset.mem_image.mp hz with ⟨k,_,rfl⟩; exact ht k) a ha + have he : {ω | ∃ z∈(Finset.range n).image t, a≤|B z ω|} = E n := by + ext ω + simp only [Set.mem_ofPred_eq,Finset.mem_image,E] + aesop + rw [he] at hh + rw [← ofReal_measureReal] + exact ENNReal.ofReal_le_ofReal hh + have hbound : μ {ω | ∃ k, a≤|B (t k) ω|} ≤ + ENNReal.ofReal (2*Real.exp (-a^2/(2*T))) := by + rw [hu,hm.measure_iUnion] + exact iSup_le hb + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top hbound + simpa only [measureReal_def,ENNReal.toReal_ofReal (by positivity : 0 ≤ 2*Real.exp (-a^2/(2*T)))] using hh + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma preBrownian_continuous_abs_gt_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (B : ℝ≥0 → Ω → ℝ) + (hB : IsPreBrownianReal B μ) (hBm : ∀ t, Measurable (B t)) + (hBc : ∀ ω, Continuous (fun t => B t ω)) (T : ℝ≥0) (hT : 0<(T:ℝ)) + (a : ℝ) (ha : 0 (u n:ℝ≥0)) (fun n => (u n).2) a ha + refine (measureReal_mono (show {ω | ∃ t≤T, a < |B t ω|} ⊆ + {ω | ∃ k, a≤|B (u k) ω|} from ?_)).trans hh + rintro ω ⟨t,ht,hat⟩ + have hc : Continuous (fun z : Set.Iic T => |B z ω|) := + (hBc ω).abs.comp continuous_subtype_val + obtain ⟨k,hk⟩ := hu.exists_mem_open (isOpen_lt continuous_const hc) ⟨⟨t,ht⟩,hat⟩ + exact ⟨k,hk.le⟩ + +lemma preBrownian_continuous_abs_maximal {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (B : ℝ≥0 → Ω → ℝ) + (hB : IsPreBrownianReal B μ) (hBm : ∀ t, Measurable (B t)) + (hBc : ∀ ω, Continuous (fun t => B t ω)) (T : ℝ≥0) (hT : 0<(T:ℝ)) + (a : ℝ) (ha : 0 a-a/((n:ℝ)+2) + have hbpos n : 0 2*Real.exp (-(b n)^2/(2*T))) atTop + (𝓝 (2*Real.exp (-a^2/(2*T)))) := by + exact tendsto_const_nhds.mul (Real.continuous_exp.tendsto _ |>.comp ((hb.pow 2).neg.div_const (2*T))) + apply ge_of_tendsto hlim + filter_upwards [] with n + have hh := preBrownian_continuous_abs_gt_maximal μ B hB hBm hBc T hT (b n) (hbpos n) + refine (measureReal_mono (show {ω | ∃ t≤T, a≤|B t ω|} ⊆ + {ω | ∃ t≤T, b n < |B t ω|} from ?_)).trans hh + rintro ω ⟨t,ht,hat⟩ + exact ⟨t,ht,(hblt n).trans_le hat⟩ + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/ProfileGrowth.lean b/lean/OAI/Probability/Ballisticity/Walk/ProfileGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e1c8d0fb5e72251d581196466d05d66dcb84f70 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/ProfileGrowth.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.TailSampling + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace TailGrowth + +noncomputable def normalizedRestriction {X : Type*} [MeasurableSpace X] + (μ : Measure X) (s : Set X) : Measure X := (μ s)⁻¹ • μ.restrict s + +lemma normalizedRestriction_probability {X : Type*} [MeasurableSpace X] + (μ : Measure X) [IsFiniteMeasure μ] (s : Set X) (hpos : μ s ≠ 0) : + IsProbabilityMeasure (normalizedRestriction μ s) := by + constructor + simp only [normalizedRestriction, Measure.smul_apply,smul_eq_mul, + Measure.restrict_apply MeasurableSet.univ,Set.univ_inter] + exact ENNReal.inv_mul_cancel hpos (measure_ne_top _ _) + +lemma normalizedRestriction_supported {X : Type*} [MeasurableSpace X] + (μ : Measure X) (s : Set X) (hs : MeasurableSet s) : + ∀ᵐ x ∂normalizedRestriction μ s, x ∈ s := + Measure.ae_smul_measure (ae_restrict_mem hs) _ + +lemma comp_total_le_one {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y] + (κ : Kernel X Y) (hκ : ∀ x, κ x Set.univ ≤ 1) + (μ : Measure X) [IsProbabilityMeasure μ] : (κ ∘ₘ μ) Set.univ ≤ 1 := by + rw [Measure.bind_apply MeasurableSet.univ κ.measurable.aemeasurable] + calc + (∫⁻ x, κ x Set.univ ∂μ) ≤ ∫⁻ _, (1 : ℝ≥0∞) ∂μ := lintegral_mono hκ + _ = 1 := by simp + +lemma real_le_one_of_total_le_one {X : Type*} [MeasurableSpace X] + (μ : Measure X) (hμ : μ Set.univ ≤ 1) (s : Set X) : μ.real s ≤ 1 := by + exact (ENNReal.toReal_mono (by simp) ((measure_mono (Set.subset_univ s)).trans hμ)).trans_eq (by simp) + +noncomputable def outwardMass {X : Type*} [MeasurableSpace X] + (κ : Kernel X ℤ) (ξ : X → ℤ) (p : X × X) : ℝ := + ((κ p.1).prod (κ p.2)).real {y | ξ p.2 - ξ p.1 ≤ y.2-y.1} + +lemma ordered_stream_mass_lower {X : Type*} [MeasurableSpace X] + [Countable X] [MeasurableSingletonClass X] + (κ : Kernel X ℤ) [IsFiniteKernel κ] (hκ : ∀ x, κ x Set.univ ≤ 1) + (ξ : X → ℤ) (α β : Measure X) [IsProbabilityMeasure α] [IsProbabilityMeasure β] + (R : ℤ) (hgap : ∀ᵐ p ∂α.prod β, R ≤ ξ p.2 - ξ p.1) : + (∫ p, outwardMass κ ξ p ∂α.prod β) ≤ + ((κ ∘ₘ α).prod (κ ∘ₘ β)).real {y | y.1+R ≤ y.2} := by + have hset : MeasurableSet {y : ℤ × ℤ | y.1+R ≤ y.2} := (Set.to_countable _).measurableSet + have hfin : ∀ p : X × X, (κ p.1).prod (κ p.2) Set.univ ≤ 1 := by + intro p + rw [←Set.univ_prod_univ,Measure.prod_prod] + exact (mul_le_of_le_one_left (by positivity) (hκ _)).trans (hκ _) + have hm : Measurable (fun p : X × X => + (κ p.1).prod (κ p.2) {y | ξ p.2 - ξ p.1 ≤ y.2-y.1}) := measurable_of_countable _ + rw [Measure.real,prod_comp, + Measure.bind_apply hset (κ ∥ₖ κ).measurable.aemeasurable] + unfold outwardMass Measure.real + rw [integral_toReal hm.aemeasurable (Eventually.of_forall fun p => + ((measure_mono (Set.subset_univ _)).trans (hfin p)).trans_lt (by simp))] + apply ENNReal.toReal_mono + · have hb : (∫⁻ p, (κ ∥ₖ κ) p {y | y.1+R ≤ y.2} ∂α.prod β) ≤ 1 := by + calc + _ ≤ ∫⁻ _, (1 : ℝ≥0∞) ∂α.prod β := by + apply lintegral_mono + intro p + dsimp only + rw [Kernel.parallelComp_apply] + exact (measure_mono (Set.subset_univ _)).trans (hfin p) + _ = 1 := by simp + exact ne_of_lt (hb.trans_lt (by simp)) + · apply lintegral_mono_ae + filter_upwards [hgap] with p hp + rw [Kernel.parallelComp_apply] + apply measure_mono + intro y hy + simp only [Set.mem_ofPred_eq] at hy ⊢ + omega + +theorem profile_tail_growth {X : Type*} [MeasurableSpace X] [Countable X] + [MeasurableSingletonClass X] + (w : Measure X) [IsFiniteMeasure w] (w' : Measure ℤ) [IsFiniteMeasure w'] + (ξ : X → ℤ) (hsurj : Function.Surjective ξ) (hfull : ∀ x, 0 < w.real {x}) + (κ : Kernel X ℤ) [IsFiniteKernel κ] (hκ : ∀ x, κ x Set.univ ≤ 1) + (R j : ℤ) (hj : ∀ k, TailCuts.score (TailCuts.lower (w.map ξ)) + (TailCuts.upper (w.map ξ)) R k ≤ + TailCuts.score (TailCuts.lower (w.map ξ)) (TailCuts.upper (w.map ξ)) R j) + (C a : ℝ) (hupdate : ENNReal.ofReal (Real.exp C) • (κ ∘ₘ w) ≤ w') + (Z : X × X → ℝ) + (hZi : Integrable Z ((normalizedRestriction w (ξ ⁻¹' Set.Iic j)).prod + (normalizedRestriction w (ξ ⁻¹' Set.Ici (j+R))))) + (hZ0 : ∀ p, 0 ≤ Z p) + (hp0 : ∀ᵐ p ∂((normalizedRestriction w (ξ ⁻¹' Set.Iic j)).prod + (normalizedRestriction w (ξ ⁻¹' Set.Ici (j+R)))), 0 < outwardMass κ ξ p) + (hp : ∀ᵐ p ∂((normalizedRestriction w (ξ ⁻¹' Set.Iic j)).prod + (normalizedRestriction w (ξ ⁻¹' Set.Ici (j+R)))), + -a-Z p ≤ Real.log (outwardMass κ ξ p)) : + C-a-(∫ p, Z p ∂((normalizedRestriction w (ξ ⁻¹' Set.Iic j)).prod + (normalizedRestriction w (ξ ⁻¹' Set.Ici (j+R)))))-Real.log 2 ≤ + Real.log (statistic w' R) - Real.log (statistic (w.map ξ) R) := by + have hξ : Measurable ξ := measurable_of_countable _ + have hwfull := TailSampling.coordinate_atom_pos w ξ hξ hsurj hfull + have hLp := TailCuts.lower_pos (w.map ξ) hwfull j + have hUp := TailCuts.upper_pos (w.map ξ) hwfull (j+R) + rw [TailCuts.lower,Measure.real,Measure.map_apply hξ measurableSet_Iic] at hLp + rw [TailCuts.upper,Measure.real,Measure.map_apply hξ measurableSet_Ici] at hUp + have hL : w (ξ ⁻¹' Set.Iic j) ≠ 0 := (ENNReal.toReal_pos_iff.mp hLp).1.ne' + have hU : w (ξ ⁻¹' Set.Ici (j+R)) ≠ 0 := (ENNReal.toReal_pos_iff.mp hUp).1.ne' + let α := normalizedRestriction w (ξ ⁻¹' Set.Iic j) + let β := normalizedRestriction w (ξ ⁻¹' Set.Ici (j+R)) + let : IsProbabilityMeasure α := normalizedRestriction_probability w _ hL + let : IsProbabilityMeasure β := normalizedRestriction_probability w _ hU + have hT := statistic_pos (w.map ξ) hwfull R + have hTls : statistic (w.map ξ) R ≤ w.real (ξ ⁻¹' Set.Iic j) := by + rw [statistic_eq_max _ R j hj] + exact (min_le_left _ _).trans_eq (by + simp only [TailCuts.lower,Measure.real,Measure.map_apply hξ measurableSet_Iic]) + have hTus : statistic (w.map ξ) R ≤ w.real (ξ ⁻¹' Set.Ici (j+R)) := by + rw [statistic_eq_max _ R j hj] + exact (min_le_right _ _).trans_eq (by + simp only [TailCuts.upper,Measure.real,Measure.map_apply hξ measurableSet_Ici]) + have hdl := continued_tail_dominated κ w w' _ hL hTls hupdate + have hdu := continued_tail_dominated κ w w' _ hU hTus hupdate + have hgap : ∀ᵐ p ∂α.prod β, R ≤ ξ p.2 - ξ p.1 := by + apply (Measure.ae_prod_iff_ae_ae ((Set.to_countable _).measurableSet)).mpr + filter_upwards [normalizedRestriction_supported w _ (hξ measurableSet_Iic)] with x hx + filter_upwards [normalizedRestriction_supported w _ (hξ measurableSet_Ici)] with y hy + simp only [Set.mem_preimage,Set.mem_Iic,Set.mem_Ici] at hx hy + omega + have hPi : Integrable (outwardMass κ ξ) (α.prod β) := by + apply (integrable_const (1 : ℝ)).mono' (measurable_of_countable _).aestronglyMeasurable + exact Eventually.of_forall fun p => by + rw [Real.norm_eq_abs] + unfold outwardMass + rw [abs_of_nonneg measureReal_nonneg] + apply real_le_one_of_total_le_one + rw [←Set.univ_prod_univ,Measure.prod_prod] + exact (mul_le_of_le_one_left (by positivity) (hκ _)).trans (hκ _) + obtain ⟨hQ,hlog⟩ := log_integral_lower (α.prod β) Z (outwardMass κ ξ) a + hZi (Eventually.of_forall hZ0) hPi hp0 hp + exact log_statistic_grows (κ ∘ₘ α) (κ ∘ₘ β) (w.map ξ) w' + (real_le_one_of_total_le_one _ (comp_total_le_one κ hκ α) _) + (real_le_one_of_total_le_one _ (comp_total_le_one κ hκ β) _) + R hT hQ (ordered_stream_mass_lower κ hκ ξ α β R hgap) hlog + (fun j => stream_real_lower _ w' (mul_pos (Real.exp_pos C) hT).le hdl (Set.Iic j)) + (fun j => stream_real_lower _ w' (mul_pos (Real.exp_pos C) hT).le hdu (Set.Ici j)) + +end TailGrowth + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/ProfileGrowth2.lean b/lean/OAI/Probability/Ballisticity/Walk/ProfileGrowth2.lean new file mode 100644 index 0000000000000000000000000000000000000000..13dd50c3f56b8a95b726e1473f6125e7fe758724 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/ProfileGrowth2.lean @@ -0,0 +1,128 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.OutwardCanonicalRows +import OAI.Probability.Ballisticity.Walk.ProfileGrowth + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace DirectionalTransience + +def HorizontalLayer {d : ℕ} (e : Direction d) := {x : Lattice d // x e.1 = 0} + +instance {d : ℕ} (e : Direction d) : Countable (HorizontalLayer e) := inferInstanceAs (Countable {x : Lattice d // x e.1 = 0}) +instance {d : ℕ} (e : Direction d) : MeasurableSpace (HorizontalLayer e) := inferInstanceAs (MeasurableSpace {x : Lattice d // x e.1 = 0}) +instance {d : ℕ} (e : Direction d) : MeasurableSingletonClass (HorizontalLayer e) := inferInstanceAs (MeasurableSingletonClass {x : Lattice d // x e.1 = 0}) + +lemma horizontal_coordinate_surjective {d : ℕ} (e : Direction d) (f : Fin d) + (hef : e.1 ≠ f) : Function.Surjective (fun x : HorizontalLayer e => x.1 f) := by + intro z + refine ⟨⟨Pi.single f z, ?_⟩, ?_⟩ + · simp [Ne.symm hef] + · simp + +noncomputable def horizontalCoordinateKernel {d : ℕ} (e : Direction d) (f : Fin d) + (H : ℕ) (ω : Environment d) : Kernel (HorizontalLayer e) ℤ := + ((variableHitKernel (realPosition (step e)) H).comap + (fun x : HorizontalLayer e => (ω,x.1)) (measurable_of_countable _)).map (fun x => x f) + +instance horizontalCoordinateKernel_finite {d : ℕ} (e : Direction d) (f : Fin d) + (H : ℕ) (ω : Environment d) : IsFiniteKernel (horizontalCoordinateKernel e f H ω) := by + unfold horizontalCoordinateKernel + infer_instance + +lemma horizontalCoordinateKernel_apply {d : ℕ} (e : Direction d) (f : Fin d) + (H : ℕ) (ω : Environment d) (x : HorizontalLayer e) : + horizontalCoordinateKernel e f H ω x = + (hitKernel (Strip (realPosition (step e)) x.1 H) + (Upper (realPosition (step e)) x.1 H) (ω,x.1)).map (fun y => y f) := by + rw [horizontalCoordinateKernel, Kernel.map_apply _ (measurable_of_countable _), Kernel.comap_apply] + rfl + +lemma horizontalCoordinateKernel_total {d : ℕ} (e : Direction d) (f : Fin d) + (H : ℕ) (ω : Environment d) (x : HorizontalLayer e) : + horizontalCoordinateKernel e f H ω x Set.univ ≤ 1 := by + rw [horizontalCoordinateKernel_apply, Measure.map_apply (measurable_of_countable _) MeasurableSet.univ] + exact hitKernel_total_le_one (disjoint_strip_upper _ _ _) _ + +lemma coordinate_outwardMass {d : ℕ} (e : Direction d) (f : Fin d) + (H : ℕ) (ω : Environment d) (p : HorizontalLayer e × HorizontalLayer e) : + TailGrowth.outwardMass (horizontalCoordinateKernel e f H ω) (fun x => x.1 f) p = + outwardKernelMass e (f,true) H (p.1.1,p.2.1) ω := by + unfold TailGrowth.outwardMass Measure.real + rw [horizontalCoordinateKernel_apply, horizontalCoordinateKernel_apply, + Measure.map_prod_map _ _ (measurable_of_countable _) (measurable_of_countable _), + Measure.map_apply (measurable_of_countable _) ((Set.to_countable _).measurableSet)] + unfold outwardKernelMass rawPairEndpointLaw + congr 2 + ext y + simp only [Set.mem_preimage, Set.mem_ofPred_eq, + signedCoordinate, reduceIte, Pi.sub_apply, Int.cast_sub] + exact_mod_cast Iff.rfl + +lemma horizontal_pair_height {d : ℕ} (e : Direction d) + (p : HorizontalLayer e × HorizontalLayer e) : + dot (realPosition p.1.1) (realPosition (step e)) = + dot (realPosition p.2.1) (realPosition (step e)) := by + rw [dot_signed_direction, dot_signed_direction] + simp only [signedCoordinate, p.1.2, p.2.2, Int.cast_zero, neg_zero, ite_self] + +theorem actual_profile_tail_growth {d : ℕ} (e : Direction d) (f : Fin d) + (hef : e.1 ≠ f) (A : ℝ) (ω : Environment d) + (hω : ∀ x : Lattice d × Lattice d, + dot (realPosition x.1) (realPosition (step e)) = + dot (realPosition x.2) (realPosition (step e)) → + ∀ t : ℕ, 0 < outwardKernelMass e (f,true) (t+1) x ω ∧ + -Real.log (outwardKernelMass e (f,true) (t+1) x ω) ≤ + 2*A*Real.log ((t:ℝ)+2)+outwardCanonicalExcess e (f,true) A x ω) + (H : ℕ) (hH : 0 < H) + (w : Measure (HorizontalLayer e)) [IsFiniteMeasure w] + (hfull : ∀ x, 0 < w.real {x}) (w' : Measure ℤ) [IsFiniteMeasure w'] + (R j : ℤ) (hj : ∀ k, TailCuts.score (TailCuts.lower (w.map (fun x => x.1 f))) + (TailCuts.upper (w.map (fun x => x.1 f))) R k ≤ + TailCuts.score (TailCuts.lower (w.map (fun x => x.1 f))) + (TailCuts.upper (w.map (fun x => x.1 f))) R j) + (C : ℝ) (hupdate : ENNReal.ofReal (Real.exp C) • + (horizontalCoordinateKernel e f H ω ∘ₘ w) ≤ w') + (hZi : Integrable (fun p : HorizontalLayer e × HorizontalLayer e => + outwardCanonicalExcess e (f,true) A (p.1.1,p.2.1) ω) + ((TailGrowth.normalizedRestriction w {x | x.1 f ≤ j}).prod + (TailGrowth.normalizedRestriction w {x | j+R ≤ x.1 f}))) : + C-2*A*Real.log (1+(H:ℝ))- + (∫ p : HorizontalLayer e × HorizontalLayer e, + outwardCanonicalExcess e (f,true) A (p.1.1,p.2.1) ω + ∂((TailGrowth.normalizedRestriction w {x | x.1 f ≤ j}).prod + (TailGrowth.normalizedRestriction w {x | j+R ≤ x.1 f}))) - Real.log 2 ≤ + Real.log (TailGrowth.statistic w' R) - + Real.log (TailGrowth.statistic (w.map (fun x => x.1 f)) R) := by + have hpoint (p : HorizontalLayer e × HorizontalLayer e) : + 0 < outwardKernelMass e (f,true) H (p.1.1,p.2.1) ω ∧ + -Real.log (outwardKernelMass e (f,true) H (p.1.1,p.2.1) ω) ≤ + 2*A*Real.log (1+(H:ℝ))+outwardCanonicalExcess e (f,true) A (p.1.1,p.2.1) ω := by + have hh := hω (p.1.1,p.2.1) (horizontal_pair_height e p) (H-1) + have hn : H-1+1=H := by omega + have hnR : ((H-1:ℕ):ℝ)+2 = 1+(H:ℝ) := by + have heq := congrArg (fun n : ℕ => (n:ℝ)) hn + push_cast at heq + linarith + simpa only [hn,hnR] using hh + apply TailGrowth.profile_tail_growth w w' (fun x => x.1 f) + (horizontal_coordinate_surjective e f hef) hfull + (horizontalCoordinateKernel e f H ω) (horizontalCoordinateKernel_total e f H ω) + R j hj C (2*A*Real.log (1+(H:ℝ))) hupdate + (fun p => outwardCanonicalExcess e (f,true) A (p.1.1,p.2.1) ω) hZi + · intro p + exact canonicalLogExcess_nonneg _ _ ω + · exact Eventually.of_forall fun p => (coordinate_outwardMass e f H ω p) ▸ (hpoint p).1 + · apply Eventually.of_forall + intro p + rw [coordinate_outwardMass] + linarith [(hpoint p).2] + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/QuenchedRegularPathAe.lean b/lean/OAI/Probability/Ballisticity/Walk/QuenchedRegularPathAe.lean new file mode 100644 index 0000000000000000000000000000000000000000..46e9543a3a578902e0d4d5ecc15e870f15bd9d4e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/QuenchedRegularPathAe.lean @@ -0,0 +1,320 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.MixtureSmallMassProbability +import OAI.Probability.Ballisticity.Crossings.FirstLayerHitRecordPrefix + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma quenched_regularPath_ae {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) : + ∀ᵐ ω ∂environmentLaw ν, ∀ x, ∀ᵐ X ∂quenchedKernel (ω,x), X ∈ RegularPath ℓ x := by + filter_upwards [quenched_directionallyTransient_ae ν ℓ htrans] with ω hω + intro x + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x),hω x] with X h0 hn ht + exact ⟨h0,hn,ht⟩ + +lemma relativeGoodMass_le_tubePrefix {d : ℕ} (e f : Direction d) (ω : Environment d) + (x : Lattice d) (hreg : ∀ᵐ X ∂quenchedKernel (ω,x), X ∈ RegularPath (realPosition (step e)) x) + (b : ℕ → ℝ) (H : ℕ) (θ a z : ℝ) (hdet : ∀ j ≤ H, |b j-(j:ℝ)*θ| ≤ z-a) + {s : ℕ} (hs : s ≤ H) : + relativeGoodMass (realPosition (step e)) (MedianTubeFailure (realPosition (step e)) f b H a) ω x ≤ + (quenchedKernel (ω,x)).real (TubePrefix (realPosition (step e)) f x θ z s) := by + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono_ae + filter_upwards [hreg] with X hX + intro hgood + apply regular_noDrop_tubePrefix e f x hX hgood.2 θ z s + intro j hj + have hmedian : |signedCoordinate f (recordIndexPosition (realPosition (step e)) j (fun k => X k-x))-b j| ≤ a := by + by_contra! hh + exact hgood.1 ⟨j,hj.trans hs,hh⟩ + calc + _ ≤ |signedCoordinate f (recordIndexPosition (realPosition (step e)) j (fun k => X k-x))-b j| + + |b j-(j:ℝ)*θ| := abs_sub_le _ _ _ + _ ≤ a+(z-a) := add_le_add hmedian (hdet j (hj.trans hs)) + _ = z := by ring + +lemma integral_tubePrefix_lower_bound {d : ℕ} (e f : Direction d) (ω : Environment d) + (hreg : ∀ x, ∀ᵐ X ∂quenchedKernel (ω,x), X ∈ RegularPath (realPosition (step e)) x) + (π : Measure (Lattice d)) [IsProbabilityMeasure π] (b : ℕ → ℝ) (H : ℕ) + (θ a z : ℝ) (hdet : ∀ j ≤ H, |b j-(j:ℝ)*θ| ≤ z-a) {s : ℕ} (hs : s ≤ H) : + (∫ x, relativeGoodMass (realPosition (step e)) (MedianTubeFailure (realPosition (step e)) f b H a) ω x ∂π) ≤ + ∫ x, (quenchedKernel (ω,x)).real (TubePrefix (realPosition (step e)) f x θ z s) ∂π := by + have hI (F : Lattice d → ℝ) (hF0 : ∀ x, 0 ≤ F x) (hF1 : ∀ x, F x ≤ 1) : Integrable F π := + (integrable_const (1:ℝ)).mono' (measurable_of_countable F).aestronglyMeasurable + (ae_of_all _ fun x => by rw [Real.norm_eq_abs,abs_of_nonneg (hF0 x)]; exact hF1 x) + apply integral_mono (hI _ (fun _ => measureReal_nonneg) (fun _ => measureReal_le_one)) + (hI _ (fun _ => measureReal_nonneg) (fun _ => measureReal_le_one)) + exact fun x => relativeGoodMass_le_tubePrefix e f ω x (hreg x) b H θ a z hdet hs + +theorem slope_tube_single_threat {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + {w : ℝ} (hw : 0 < w) (hw1 : w ≤ 20) : + ∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℝ, 0 < t₀ ∧ ∀ t : ℝ, 0 < t → t ≤ t₀ → + ∃ δ : ℝ, 0 < δ ∧ δ < 1/4 ∧ ∃ R : ℝ, 0 < R ∧ + ∀ r : ℝ, R ≤ r → ∀ H : ℕ, 0 < H → + (H:ℝ) ≤ t*fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r → + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let θ := (recordMedian ν ℓ hp f H:ℝ)/H + |θ| ≤ w*r ∧ ∀ π : Measure (Lattice d), IsProbabilityMeasure π → + (environmentLaw ν).real {ω | ∃ s ≤ H, + (∫ x, (quenchedKernel (ω,x)).real (TubePrefix ℓ f x θ (w*r) s) ∂π) < δ} ≤ C*t := by + obtain ⟨C,hC,hbound⟩ := raw_median_tube_single_threat ν hue e f hef htrans + (show 0 < w/2 by positivity) (show w/2 ≤ 10 by linarith) + obtain ⟨D,hD,t₁,ht₁,hmedian⟩ := recordMedian_shortBlock ν hue e f hef htrans + let t₀ := min t₁ ((w/(2*D))^2) + have ht₀ : 0 < t₀ := lt_min ht₁ (sq_pos_of_pos (by positivity)) + refine ⟨C,hC,t₀,ht₀,?_⟩ + intro t ht htt + obtain ⟨δ,hδ,hδ1,R,hR,hraw⟩ := hbound t ht + let ℓ := realPosition (step e) + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let b := fun j => (recordMedian ν ℓ hp f j:ℝ) + let R' := max R (2*|b 1|/w) + have hR' : 0 < R' := hR.trans_le (le_max_left _ _) + refine ⟨δ,hδ,hδ1,R',hR',?_⟩ + intro r hr H hH hscale + have hr0 : 0 < r := hR'.trans_le hr + have hb := hmedian t ht (htt.trans (min_le_left _ _)) r hr0 H hH hscale + let θ := b H/H + have hroot : Real.sqrt t ≤ w/(2*D) := by + apply (Real.sqrt_le_iff).mpr + exact ⟨by positivity,htt.trans (min_le_right _ _)⟩ + have hcoef : D*Real.sqrt t ≤ w/2 := by + have hh := mul_le_mul_of_nonneg_left hroot hD.le + have he : D*(w/(2*D)) = w/2 := by field_simp + linarith + have hdet (j : ℕ) (hj : j ≤ H) : |b j-(j:ℝ)*θ| ≤ w*r/2 := by + have hh := (hb j hj).trans (mul_le_mul_of_nonneg_right hcoef hr0.le) + simpa only [θ,mul_div_assoc,div_mul_eq_mul_div] using hh + have htheta : |θ| ≤ w*r := by + have hh := hdet 1 hH + simp only [Nat.cast_one,one_mul] at hh + have hb1 : |b 1| ≤ w*r/2 := by + have hh' := (le_max_right R (2*|b 1|/w)).trans hr + have hh'' := (div_le_iff₀ hw).mp hh' + nlinarith + have hh' := abs_sub_le θ (b 1) 0 + rw [sub_zero,sub_zero,abs_sub_comm θ] at hh' + linarith + refine ⟨htheta,?_⟩ + intro π hπ + let := hπ + have hraw' := hraw r ((le_max_left _ _).trans hr) H hscale π hπ + have hle : (environmentLaw ν) {ω | ∃ s ≤ H, + (∫ x, (quenchedKernel (ω,x)).real (TubePrefix ℓ f x θ (w*r) s) ∂π) < δ} ≤ + (environmentLaw ν) {ω | (∫ x, relativeGoodMass ℓ (MedianTubeFailure ℓ f b H (w/2*r)) ω x ∂π) < δ} := by + apply measure_mono_ae + filter_upwards [quenched_regularPath_ae ν ℓ htrans] with ω hω + rintro ⟨s,hs,hh⟩ + exact (integral_tubePrefix_lower_bound e f ω hω π b H θ (w/2*r) (w*r) + (fun j hj => by convert hdet j hj using 1; ring) hs).trans_lt hh + exact (ENNReal.toReal_mono (measure_ne_top _ _) hle).trans hraw' + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/RawPairKernel.lean b/lean/OAI/Probability/Ballisticity/Walk/RawPairKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f04206dc0e4a83feebc7f5f68dda09581cc17398 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/RawPairKernel.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RawPairEndpoint + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma hit_prefixEndpoint_iff {d : ℕ} (e : Direction d) (x : Lattice d) + {H : ℕ} (hH : 0 < H) (A : Set (Lattice d)) (X : Path d) + (h0 : X 0=x) (hnn : ∀ n, ∃ g, X (n+1)=X n+step g) : + X ∈ Hit (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H ∩ A) ↔ + X ∈ Hit (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) ∧ + prefixEndpoint (realPosition (step e)) x H X ∈ A := by + constructor + · intro h + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp h + have hh : X ∈ HitAt (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) n := ⟨hn.1.1,hn.2⟩ + refine ⟨Set.mem_iUnion.mpr ⟨n,hh⟩,?_⟩ + dsimp [prefixEndpoint] + rw [coordinate_hitAt_record e x X h0 hnn hH hh] + simpa only [add_sub_cancel] using hn.1.2 + · rintro ⟨h,hA⟩ + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp h + dsimp [prefixEndpoint] at hA + rw [coordinate_hitAt_record e x X h0 hnn hH hn] at hA + exact Set.mem_iUnion.mpr ⟨n,⟨hn.1,by simpa only [add_sub_cancel] using hA⟩,hn.2⟩ + +lemma hitKernel_eq_map_prefixEndpoint {d : ℕ} (e : Direction d) (x : Lattice d) + {H : ℕ} (hH : 0 < H) (ω : Environment d) : + hitKernel (Strip (realPosition (step e)) x H) (Upper (realPosition (step e)) x H) (ω,x) = + ((quenchedKernel (ω,x)).restrict (Hit (Strip (realPosition (step e)) x H) + (Upper (realPosition (step e)) x H))).map (prefixEndpoint (realPosition (step e)) x H) := by + apply Measure.ext + intro A hA + rw [hitKernel_apply_eq_hit (disjoint_strip_upper _ _ _),Measure.map_apply + (measurable_prefixEndpoint _ _ _) hA,Measure.restrict_apply ((measurable_prefixEndpoint _ _ _) hA)] + apply measure_congr + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x)] with X h0 hnn + have := hit_prefixEndpoint_iff e x hH A X h0 hnn + apply propext + exact this.trans and_comm + +noncomputable def rawPairEndpointLaw {d : ℕ} (ℓ : Vector d) (H : ℕ) + (ω : Environment d) (x : Lattice d × Lattice d) : Measure (Lattice d × Lattice d) := + (hitKernel (Strip ℓ x.1 H) (Upper ℓ x.1 H) (ω,x.1)).prod + (hitKernel (Strip ℓ x.2 H) (Upper ℓ x.2 H) (ω,x.2)) + +lemma rawPairEndpointLaw_eq {d : ℕ} (e f : Direction d) (x : Lattice d × Lattice d) + {H : ℕ} (hH : 0 < H) (z : ℝ) (ω : Environment d) : + rawPairEndpointLaw (realPosition (step e)) H ω x {y | z ≤ signedCoordinate f (y.2-y.1)} = + ((quenchedKernel (ω,x.1)).prod (quenchedKernel (ω,x.2))) + (PairEndpointEvent (realPosition (step e)) f x.1 x.2 H z) := by + have hgap : MeasurableSet {y : Lattice d × Lattice d | z ≤ signedCoordinate f (y.2-y.1)} := Set.to_countable _ |>.measurableSet + have hm := (measurable_prefixEndpoint (realPosition (step e)) x.1 H).prodMap + (measurable_prefixEndpoint (realPosition (step e)) x.2 H) + unfold rawPairEndpointLaw + rw [hitKernel_eq_map_prefixEndpoint e x.1 hH,hitKernel_eq_map_prefixEndpoint e x.2 hH, + Measure.map_prod_map _ _ (measurable_prefixEndpoint _ _ _) (measurable_prefixEndpoint _ _ _), + Measure.prod_restrict,Measure.map_apply hm hgap, + Measure.restrict_apply (hm hgap)] + congr 1 + ext p + simp only [PairEndpointEvent,Set.mem_inter_iff,Set.mem_preimage, + Set.mem_ofPred_eq,Set.mem_prod] + tauto +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/RecordLinearPath.lean b/lean/OAI/Probability/Ballisticity/Walk/RecordLinearPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..24ea38d7554173362c651c5213220821df47b6dc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/RecordLinearPath.lean @@ -0,0 +1,309 @@ +import Mathlib +import OAI.Probability.Ballisticity.Coupling.WeakLimitBoundedFreshMap +import OAI.Probability.Ballisticity.Estimates.NoDropApproxError +import OAI.Probability.Ballisticity.Estimates.HighRecordCount +import OAI.Probability.Ballisticity.Geometry.HeightPolygonRandomShiftSmall + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +noncomputable def recordLinearPath {d : ℕ} (ℓ : Vector d) (f : Direction d) + (θ r n T : ℝ) (X : Path d) : C(unitInterval,ℝ) := + heightPolygon (fun h => signedCoordinate f (recordIndexPosition ℓ h X)-(h:ℝ)*θ) r n T + +lemma measurable_recordLinearPath {d : ℕ} (ℓ : Vector d) (f : Direction d) (θ r n T : ℝ) : + Measurable (recordLinearPath ℓ f θ r n T) := + measurable_heightPolygon _ (fun h => + ((measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ h)).sub_const ((h:ℝ)*θ)) _ _ _ + +lemma recordLinearPath_suffix_small {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (f : Direction d) + (θ r n : ℕ → ℝ) (hr : Tendsto r atTop atTop) (hn : Tendsto n atTop atTop) + (hθ : Tendsto (fun i => θ i/r i) atTop (𝓝 0)) + (J : ℝ) (hJ : 0 ≤ J) {T : ℝ} (hT : 0 ≤ T) + (ht : IsTightMeasureSet (Set.range (fun i => (conditionedLaw ν ℓ).map + (recordLinearPath ℓ f (θ i) (r i) (n i) (T+1))))) : + TendstoInMeasure (conditionedLaw ν ℓ) (fun i X => + recordLinearPath ℓ f (θ i) (r i) (n i) T (highSuffix ℓ J X)- + recordLinearPath ℓ f (θ i) (r i) (n i) T X) atTop 0 := by + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let H := highRecordCount ℓ J + let D := fun X => signedCoordinate f (highRecordPosition ℓ J X) + have hH : Measurable H := measurable_highRecordCount ℓ J hJ + have hD : Measurable D := (measurable_of_countable (signedCoordinate f)).comp (measurable_highRecordPosition ℓ J hJ) + let F := fun i h X => signedCoordinate f (recordIndexPosition ℓ h X)-(h:ℝ)*θ i + have hF : ∀ i h, Measurable (F i h) := fun i h => + ((measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ h)).sub_const ((h:ℝ)*θ i) + let c := fun i X => (H X:ℝ)*θ i-D X + have hc : TendstoInMeasure μ (fun i X => c i X/r i) atTop 0 := by + apply tendstoInMeasure_of_tendsto_ae + · intro i + exact (((((measurable_of_countable (fun k : ℕ => (k:ℝ))).comp hH).mul_const _).sub hD).div_const _).aestronglyMeasurable + · apply ae_of_all + intro X + have hh := (hθ.const_mul (H X:ℝ)).sub (tendsto_const_nhds.div_atTop hr : + Tendsto (fun i => D X/r i) atTop (𝓝 0)) + simpa only [mul_zero,sub_zero,Pi.zero_apply,c,sub_div,mul_div_assoc] using hh + have hs := heightPolygon_random_shift_small μ F hF r n hn H hH c hc hT ht + apply hs.congr _ (Filter.EventuallyEq.rfl) + intro i + filter_upwards [conditioned_highSuffix_recordPosition ν ℓ htrans J hJ] with X hX + congr 1 + congr 1 + funext h + dsimp only [recordLinearPath,F,c,H,D] + rw [hX h,signedCoordinate_sub,Nat.cast_add] + ring + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma weighted_recordLinearPath_limit {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (f : Direction d) + (θ r n : ℕ → ℝ) (hr : Tendsto r atTop atTop) (hn : Tendsto n atTop atTop) + (hθ : Tendsto (fun i => θ i/r i) atTop (𝓝 0)) + {T : ℝ} (hT : 0 ≤ T) + (ht : IsTightMeasureSet (Set.range (fun i => (conditionedLaw ν ℓ).map + (recordLinearPath ℓ f (θ i) (r i) (n i) (T+1))))) + (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : + letI : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + TendstoInDistribution (fun i => recordLinearPath ℓ f (θ i) (r i) (n i) T) + atTop id (fun _ => conditionedLaw ν ℓ) W) + (J : ℝ) (hJ : 0 ≤ J) (g : ℕ → Environment d → ℝ≥0∞) + (hg : ∀ i, @Measurable _ _ (rowSigma {z | dot (realPosition z) ℓ ≤ J}) _ (g i)) + (hgle : ∀ i ω, g i ω ≤ 1) (c : ℝ≥0∞) (hc : 0 < c) + (hcmass : ∀ i, c ≤ weightedConditioned ν ℓ (g i) Set.univ) : + letI : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + letI : ∀ i, IsFiniteMeasure (weightedConditioned ν ℓ (g i)) := fun i => + weightedConditioned_finite ν ℓ (g i) ((hg i).mono (rowSigma_le _) le_rfl) (hgle i) + letI : ∀ i, IsProbabilityMeasure (normalizedMeasure (weightedConditioned ν ℓ (g i))) := fun i => + normalizedMeasure_probability (weightedConditioned ν ℓ (g i)) + (ne_of_gt (hc.trans_le (hcmass i))) + TendstoInDistribution (fun i => recordLinearPath ℓ f (θ i) (r i) (n i) T) + atTop id (fun i => normalizedMeasure (weightedConditioned ν ℓ (g i))) W := by + let μ := conditionedLaw ν ℓ + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ + (ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans)) + let : ∀ i, IsFiniteMeasure (weightedConditioned ν ℓ (g i)) := fun i => + weightedConditioned_finite ν ℓ (g i) ((hg i).mono (rowSigma_le _) le_rfl) (hgle i) + let η := fun i => normalizedMeasure (weightedConditioned ν ℓ (g i)) + let : ∀ i, IsProbabilityMeasure (η i) := fun i => normalizedMeasure_probability _ + (ne_of_gt (hc.trans_le (hcmass i))) + let F := fun i => recordLinearPath ℓ f (θ i) (r i) (n i) T + have hF : ∀ i, Measurable (F i) := fun i => measurable_recordLinearPath _ _ _ _ _ _ + have hl : Tendsto (fun i => ProbabilityMeasure.map (⟨μ,inferInstance⟩ : ProbabilityMeasure (Path d)) + (F i)) atTop (𝓝 W) := by + have hh := hlim.tendsto + change Tendsto (fun i => ProbabilityMeasure.map (⟨μ,inferInstance⟩ : ProbabilityMeasure (Path d)) + (F i)) atTop (𝓝 (W.map id)) at hh + have he : W.map id = W := Subtype.ext Measure.map_id + rw [he] at hh + exact hh + have hs := recordLinearPath_suffix_small ν ℓ htrans f θ r n hr hn hθ J hJ hT ht + have hclose : ∀ ε, 0 < ε → Tendsto (fun i => μ.real + {X | ε ≤ dist (F i (highSuffix ℓ J X)) (F i X)}) atTop (𝓝 0) := by + intro ε hε + simpa only [Pi.zero_apply,sub_zero,dist_eq_norm,F] using + (tendstoInMeasure_iff_measureReal_norm.mp hs ε hε) + refine ⟨fun i => (hF i).aemeasurable,measurable_id.aemeasurable,?_⟩ + have hout := weak_limit_of_bounded_fresh_map μ η (highSuffix ℓ J) + (measurable_highSuffix ℓ J hJ) + (fun i => normalized_weightedConditioned_highSuffix ν ℓ htrans J hJ (g i) (hg i) + (hgle i) (ne_of_gt (hc.trans_le (hcmass i)))) c⁻¹ (ENNReal.inv_ne_top.mpr hc.ne') + (fun i => normalized_weightedConditioned_le ν ℓ (g i) ((hg i).mono (rowSigma_le _) le_rfl) + (hgle i) c (hcmass i)) F hF W hl hclose + change Tendsto (fun i => ProbabilityMeasure.map (⟨η i,inferInstance⟩ : ProbabilityMeasure (Path d)) + (F i)) atTop (𝓝 (W.map id)) + have he : W.map id = W := Subtype.ext Measure.map_id + rw [he] + exact hout + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma noDropWeighted_recordLinearPath_limit {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (e f : Direction d) (htrans : DirectionallyTransient ν (realPosition (step e))) + (θ r n : ℕ → ℝ) (hr : Tendsto r atTop atTop) (hn : Tendsto n atTop atTop) + (hθ : Tendsto (fun i => θ i/r i) atTop (𝓝 0)) + {T : ℝ} (hT : 0 ≤ T) + (ht : IsTightMeasureSet (Set.range (fun i => (conditionedLaw ν (realPosition (step e))).map + (recordLinearPath (realPosition (step e)) f (θ i) (r i) (n i) (T+1))))) + (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : + letI : IsProbabilityMeasure (conditionedLaw ν (realPosition (step e))) := + conditionedLaw_probability ν _ (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + TendstoInDistribution (fun i => recordLinearPath (realPosition (step e)) f (θ i) (r i) (n i) T) + atTop id (fun _ => conditionedLaw ν (realPosition (step e))) W) + (y : ℕ → Lattice d) (hy : ∀ i, signedHeight e (y i) = 0) + (c : ℝ≥0∞) (hc : 0 < c) + (hcmass : ∀ i, c ≤ weightedConditioned ν (realPosition (step e)) + (noDropQuenched (realPosition (step e)) (y i)) Set.univ) : + letI : IsProbabilityMeasure (conditionedLaw ν (realPosition (step e))) := + conditionedLaw_probability ν _ (ne_of_gt (noDrop_positive_of_directionallyTransient ν _ htrans)) + letI : ∀ i, IsFiniteMeasure (weightedConditioned ν (realPosition (step e)) + (noDropQuenched (realPosition (step e)) (y i))) := fun _i => + weightedConditioned_finite ν _ _ (measurable_noDropQuenched _ _) (fun _ => prob_le_one) + letI : ∀ i, IsProbabilityMeasure (normalizedMeasure (weightedConditioned ν (realPosition (step e)) + (noDropQuenched (realPosition (step e)) (y i)))) := fun i => + normalizedMeasure_probability _ (ne_of_gt (hc.trans_le (hcmass i))) + TendstoInDistribution (fun i => recordLinearPath (realPosition (step e)) f (θ i) (r i) (n i) T) + atTop id (fun i => normalizedMeasure (weightedConditioned ν (realPosition (step e)) + (noDropQuenched (realPosition (step e)) (y i)))) W := by + let ℓ := realPosition (step e) + let p := annealedLaw ν (NoDrop ℓ 0) + have hp : p ≠ 0 := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure (conditionedLaw ν ℓ) := conditionedLaw_probability ν ℓ hp + let μ i := weightedConditioned ν ℓ (noDropQuenched ℓ (y i)) + let η J i := weightedConditioned ν ℓ (noDropFinite ℓ (y i) J) + let : ∀ i, IsFiniteMeasure (μ i) := fun i => weightedConditioned_finite ν ℓ _ + (measurable_noDropQuenched ℓ (y i)) (fun _ => prob_le_one) + let : ∀ J i, IsFiniteMeasure (η J i) := fun J i => weightedConditioned_finite ν ℓ _ + (noDropFinite_measurable ℓ (y i) J) (fun _ => prob_le_one) + let : ∀ i, IsProbabilityMeasure (normalizedMeasure (μ i)) := fun i => + normalizedMeasure_probability _ (ne_of_gt (hc.trans_le (hcmass i))) + have hmono (J i : ℕ) : μ i ≤ η J i := weightedConditioned_mono ν ℓ _ _ + (measurable_noDropQuenched ℓ (y i)) (noDropFinite_measurable ℓ (y i) J) + (fun ω => noDropQuenched_le_finite ℓ (y i) ω J) + have heta (J i : ℕ) : c ≤ η J i Set.univ := (hcmass i).trans (hmono J i Set.univ) + let : ∀ J i, IsProbabilityMeasure (normalizedMeasure (η J i)) := fun J i => + normalizedMeasure_probability _ (ne_of_gt (hc.trans_le (heta J i))) + let F i := recordLinearPath ℓ f (θ i) (r i) (n i) T + have hF : ∀ i, Measurable (F i) := fun i => measurable_recordLinearPath _ _ _ _ _ _ + let A i : ProbabilityMeasure C(unitInterval,ℝ) := + ProbabilityMeasure.map (⟨normalizedMeasure (μ i),inferInstance⟩ : ProbabilityMeasure (Path d)) (F i) + let B J i : ProbabilityMeasure C(unitInterval,ℝ) := + ProbabilityMeasure.map (⟨normalizedMeasure (η J i),inferInstance⟩ : ProbabilityMeasure (Path d)) (F i) + have heW : W.map id = W := Subtype.ext Measure.map_id + have hB (J : ℕ) : Tendsto (B J) atTop (𝓝 W) := by + have h := weighted_recordLinearPath_limit ν ℓ htrans f θ r n hr hn hθ hT ht W hlim + (J:ℝ) (Nat.cast_nonneg J) (fun i => noDropFinite ℓ (y i) J) + (fun i => noDropFinite_lower_rows e (y i) (hy i) J) (fun _ _ => prob_le_one) c hc (heta J) + have hh := h.tendsto + change Tendsto (B J) atTop (𝓝 (W.map id)) at hh + rwa [heW] at hh + have hd : Tendsto (fun J => (c⁻¹*(p⁻¹*noDropApproxError ν ℓ J)).toReal) atTop (𝓝 0) := by + have h := ((ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp + (noDropApproxError_tendsto ν ℓ)).const_mul ((c⁻¹).toReal*(p⁻¹).toReal) + simpa only [ENNReal.toReal_mul,ENNReal.toReal_zero,mul_zero,Function.comp_def,mul_assoc] using h + have hclose (J i : ℕ) : levyProkhorovDist (A i : Measure C(unitInterval,ℝ)) (B J i : Measure C(unitInterval,ℝ)) ≤ + (c⁻¹*(p⁻¹*noDropApproxError ν ℓ J)).toReal := by + rw [levyProkhorovDist_comm] + exact levyProkhorov_normalized_map_le (μ i) (η J i) (hmono J i) + (p⁻¹*noDropApproxError ν ℓ J) c hc + (ENNReal.mul_ne_top (ENNReal.inv_ne_top.mpr hp) + (ne_of_lt ((noDropApproxError_le_one ν ℓ J).trans_lt (by simp)))) + (hcmass i) (fun A hA => weightedConditioned_noDrop_approx ν ℓ (y i) J A hA) (F i) (hF i) + refine ⟨fun i => (hF i).aemeasurable,measurable_id.aemeasurable,?_⟩ + change Tendsto A atTop (𝓝 (W.map id)) + rw [heW] + exact weak_limit_of_uniform_approximation A B W _ hd hB hclose + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/RegularPath.lean b/lean/OAI/Probability/Ballisticity/Walk/RegularPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..49364d9a028b8e8520f3c5dcf09863e41584055b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/RegularPath.lean @@ -0,0 +1,201 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.FirstLayerHitRecordIndexTime +import OAI.Probability.Ballisticity.Estimates.GaussianAbsTail + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +def RegularPath {d : ℕ} (ℓ : Vector d) (x : Lattice d) : Set (Path d) := + {X | X 0 = x ∧ (∀ n, ∃ f, X (n+1) = X n+step f) ∧ X ∈ TransientPaths ℓ} + +lemma measurableSet_regularPath {d : ℕ} (ℓ : Vector d) (x : Lattice d) : + MeasurableSet (RegularPath ℓ x) := by + apply (measurableSet_eq_fun (measurable_pi_apply 0) measurable_const).inter + apply MeasurableSet.inter _ (measurableSet_transientPaths ℓ) + change MeasurableSet {X : Path d | ∀ n, ∃ f, X (n+1) = X n+step f} + simp only [Set.ofPred_forall,Set.ofPred_exists] + exact MeasurableSet.iInter fun n => MeasurableSet.iUnion fun f => + measurableSet_eq_fun (by fun_prop : Measurable (fun X : Path d => X (n+1))) + (by fun_prop : Measurable (fun X : Path d => X n+step f)) + +lemma annealedFrom_regularPath {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (x : Lattice d) : + ∀ᵐ X ∂annealedFrom ν x, X ∈ RegularPath ℓ x := by + apply annealedFrom_ae_of_quenched ν x _ (measurableSet_regularPath ℓ x) + filter_upwards [quenched_directionallyTransient_ae ν ℓ htrans] with ω hω + filter_upwards [quenched_initial_ae (ω,x),quenched_nearest_neighbor (ω,x),hω x] with X h0 hnn ht + exact ⟨h0,hnn,ht⟩ + +lemma sharedConditioned_regularPath {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (x y : Lattice d) : + ∀ᵐ Z ∂sharedConditionedPairLaw ν ℓ x y, + (Z.1 ∈ RegularPath ℓ x ∧ Z.1 ∈ NoDrop ℓ x) ∧ + (Z.2 ∈ RegularPath ℓ y ∧ Z.2 ∈ NoDrop ℓ y) := by + have hh := shared_pair_ae ν x y _ _ (measurableSet_regularPath ℓ x) (measurableSet_regularPath ℓ y) + (annealedFrom_regularPath ν ℓ htrans x) (annealedFrom_regularPath ν ℓ htrans y) + filter_upwards [(sharedConditionedPairLaw_absolutelyContinuous ν ℓ x y).ae_le hh, + sharedConditionedPairLaw_noDrop ν ℓ x y] with Z hZ hD + exact ⟨⟨hZ.1,hD.1⟩,hZ.2,hD.2⟩ + +lemma conditionedFrom_regularPath {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (htrans : DirectionallyTransient ν ℓ) (x : Lattice d) : + ∀ᵐ X ∂conditionedFrom ν ℓ x, X ∈ RegularPath ℓ x ∧ X ∈ NoDrop ℓ x := by + have hac : conditionedFrom ν ℓ x ≪ annealedFrom ν x := + Measure.smul_absolutelyContinuous.trans Measure.absolutelyContinuous_restrict + have hD : ∀ᵐ X ∂conditionedFrom ν ℓ x, X ∈ NoDrop ℓ x := by + exact Measure.smul_absolutelyContinuous.ae_le (ae_restrict_mem (measurableSet_noDrop ℓ x)) + have hR : ∀ᵐ X ∂conditionedFrom ν ℓ x, X ∈ RegularPath ℓ x := + hac.ae_le (annealedFrom_regularPath ν ℓ htrans x) + exact hR.and hD + +lemma open_lane_record_iff {d : ℕ} (e f : Direction d) (x : Lattice d) (X : Path d) + (hX : X ∈ RegularPath (realPosition (step e)) x) + (hD : X ∈ NoDrop (realPosition (step e)) x) {k : ℕ} (hk : 0 < k) + (θ r a : ℝ) (hr : 0 < r) : + X ∈ SurvivingLane {z | dot (realPosition x) (realPosition (step e)) ≤ dot (realPosition z) (realPosition (step e))} + (Upper (realPosition (step e)) x k) + {z | |signedCoordinate f z-(signedCoordinate f x+(k:ℝ)*θ)| < a*r} ↔ + |scaledRecordEndpoint (realPosition (step e)) f θ r k x X| < a := by + rw [survivingLane_record_iff e x X hX.1 hD hX.2.1 hX.2.2 hk] + change |signedCoordinate f (_+x)-(signedCoordinate f x+(k:ℝ)*θ)| < a*r ↔ _ + rw [signedCoordinate_add] + have he (z : Lattice d) : signedCoordinate f z+signedCoordinate f x-(signedCoordinate f x+(k:ℝ)*θ) = + signedCoordinate f z-(k:ℝ)*θ := by ring + rw [he] + simp only [scaledRecordEndpoint,abs_div,abs_of_pos hr] + exact (div_lt_iff₀ hr).symm + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/RetentionRowsAllHeights.lean b/lean/OAI/Probability/Ballisticity/Walk/RetentionRowsAllHeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..274b3f19586a1059fe7f81d66a5385b7632bced2 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/RetentionRowsAllHeights.lean @@ -0,0 +1,203 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.RawPair + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience +lemma retainedPairLaw_zero {d : ℕ} (ℓ : Vector d) (f : Direction d) (z : ℝ) + (π : Measure (Lattice d × Lattice d)) (ω : Environment d) : + retainedPairLaw ℓ f 0 z π ω = π.restrict {y | z ≤ signedCoordinate f (y.2-y.1)} := by + simp only [retainedPairLaw,rawPairMixture_zero] + +lemma retainedPairLaw_joint_rows_all {d : ℕ} (ℓ : Vector d) (f : Direction d) + (H : ℕ) (z : ℝ) (C : Set (Lattice d × Lattice d)) (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip ℓ x.1 H ⊆ S ∧ Strip ℓ x.2 H ⊆ S) : + @Measurable (SupportedPairMeasures C × Environment d) (Measure (Lattice d × Lattice d)) + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) _ + (fun p => retainedPairLaw ℓ f H z p.1.val p.2) := by + by_cases hH : H=0 + · subst H + simp only [retainedPairLaw_zero] + let : MeasurableSpace (Environment d) := rowSigma S + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [Measure.restrict_apply hU] + exact (Measure.measurable_coe (hU.inter (Set.to_countable _).measurableSet)).comp + (measurable_subtype_coe.comp measurable_fst) + · exact retainedPairLaw_joint_rows ℓ f (Nat.pos_of_ne_zero hH) z C S hC + +lemma upwardRetainedLaw_joint_rows {d : ℕ} (e f : Direction d) + (H : ℕ) (z : ℝ) (κ : ℝ≥0) (C : Set (Lattice d × Lattice d)) (S : Set (Lattice d)) + (hC : ∀ x ∈ C, Strip (realPosition (step e)) x.1 H ⊆ S ∧ + Strip (realPosition (step e)) x.2 H ⊆ S) : + @Measurable (SupportedPairMeasures C × Environment d) (Measure (Lattice d × Lattice d)) + (@Prod.instMeasurableSpace _ _ inferInstance (rowSigma S)) _ + (fun p => upwardRetainedLaw e f H z p.1.val p.2 κ) := by + let : MeasurableSpace (Environment d) := rowSigma S + have hm := (Measure.measurable_map (pairUp e) (measurable_of_countable _)).comp + (retainedPairLaw_joint_rows_all (realPosition (step e)) f H z C S hC) + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [upwardRetainedLaw,Measure.smul_apply,smul_eq_mul] + exact measurable_const.mul ((Measure.measurable_coe hU).comp hm) + +lemma strip_subset_below_height {d : ℕ} (ℓ : Vector d) (a : ℝ) + (x : Lattice d × Lattice d) (hx : x ∈ PairAtHeight ℓ a) + {h k : ℕ} (hhk : h ≤ k) : + Strip ℓ x.1 h ⊆ BelowHeight ℓ (a+k) ∧ Strip ℓ x.2 h ⊆ BelowHeight ℓ (a+k) := by + have hhkR : (h:ℝ) ≤ k := by exact_mod_cast hhk + constructor + · intro y hy + change dot (realPosition y) ℓ < a+k + have ht := hy.2 + rw [hx.1] at ht + linarith + · intro y hy + change dot (realPosition y) ℓ < a+k + have ht := hy.2 + rw [hx.2] at ht + linarith + +lemma rowSigma_below_height_mono {d : ℕ} (ℓ : Vector d) (a : ℝ) (k : ℕ) : + rowSigma (BelowHeight ℓ a) ≤ rowSigma (BelowHeight ℓ (a+k)) := by + apply rowSigma_mono + intro y hy + dsimp [BelowHeight] at hy ⊢ + have : (0:ℝ) ≤ k := Nat.cast_nonneg k + linarith + +lemma retainedPairLaw_at_height_rows {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a z : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight ℓ a)) + (hπ : @Measurable _ _ (rowSigma (BelowHeight ℓ a)) _ π) + {h k : ℕ} (hhk : h ≤ k) : + @Measurable _ _ (rowSigma (BelowHeight ℓ (a+k))) _ + (fun ω => retainedPairLaw ℓ f h z (π ω).val ω) := by + let : MeasurableSpace (Environment d) := rowSigma (BelowHeight ℓ (a+k)) + have hp : @Measurable _ _ (rowSigma (BelowHeight ℓ (a+k))) _ π := + hπ.mono (rowSigma_below_height_mono ℓ a k) le_rfl + have hm := (retainedPairLaw_joint_rows_all ℓ f h z (PairAtHeight ℓ a) (BelowHeight ℓ (a+k)) + (fun x hx => strip_subset_below_height ℓ a x hx hhk)).comp (hp.prodMk measurable_id) + exact hm + +lemma upwardRetainedLaw_at_height_rows {d : ℕ} (e f : Direction d) + (a z : ℝ) (κ : ℝ≥0) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) + {h k : ℕ} (hhk : h ≤ k) : + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) (a+k))) _ + (fun ω => upwardRetainedLaw e f h z (π ω).val ω κ) := by + let : MeasurableSpace (Environment d) := rowSigma (BelowHeight (realPosition (step e)) (a+k)) + have hp : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) (a+k))) _ π := + hπ.mono (rowSigma_below_height_mono (realPosition (step e)) a k) le_rfl + have hm := (upwardRetainedLaw_joint_rows e f h z κ (PairAtHeight (realPosition (step e)) a) + (BelowHeight (realPosition (step e)) (a+k)) + (fun x hx => strip_subset_below_height (realPosition (step e)) a x hx hhk)).comp + (hp.prodMk measurable_id) + exact hm +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma bufferFirstFailure_eq_measurable {d : ℕ} (ℓ : Vector d) (f : Direction d) + (a z g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight ℓ a)) + (hπ : @Measurable _ _ (rowSigma (BelowHeight ℓ a)) _ π) (H k : ℕ) : + MeasurableSet[rowSigma (BelowHeight ℓ (a+k))] {ω | bufferFirstFailure ℓ f a z g π H ω = k} := by + have hm := (bufferFirstFailure_stopping ℓ f a z g π hπ H).measurableSet_eq_of_countable k + have heq : {ω | bufferFirstFailure ℓ f a z g π H ω = k} = + {ω | (bufferFirstFailure ℓ f a z g π H ω : WithTop ℕ) = (k : WithTop ℕ)} := by + ext ω + change _ = _ ↔ _ = _ + norm_cast + rw [heq] + exact hm + +lemma bufferStageRetainedLaw_at_stop_lt {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + {H : ℕ} (hH : 0 < H) (ω : Environment d) (κ : ℝ≥0) {k : ℕ} (hkH : k < H) + (hk : bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω = k) : + bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ = + upwardRetainedLaw e f (k-1) (z₀+(1-ε)*r) (π ω).val ω κ := by + have hf := bufferFirstFailure_fails_of_lt (realPosition (step e)) f a (z₀+(1-ε)*r) g π hH ω + (by simpa only [hk] using hkH) + rw [hk] at hf + simp only [bufferStageRetainedLaw,hk,ite_eq_left hf] + +lemma bufferStageRetainedLaw_stopped_rows {d : ℕ} (e f : Direction d) + (a z₀ r ε α g : ℝ) (π : Environment d → SupportedPairMeasures (PairAtHeight (realPosition (step e)) a)) + (hπ : @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) a)) _ π) + {H : ℕ} (hH : 0 < H) (κ : ℝ≥0) (k : ℕ) : + @Measurable _ _ (rowSigma (BelowHeight (realPosition (step e)) (a+k))) _ + (fun ω => if bufferFirstFailure (realPosition (step e)) f a (z₀+(1-ε)*r) g π H ω = k + then bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ else 0) := by + let ℓ := realPosition (step e) + let z := z₀+(1-ε)*r + have heq := bufferFirstFailure_eq_measurable ℓ f a z g π hπ H k + by_cases hk : k ≤ H + · rcases lt_or_eq_of_le hk with hklt|he + · have hf : (fun ω => if bufferFirstFailure ℓ f a z g π H ω = k + then bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ else 0) = + (fun ω => if bufferFirstFailure ℓ f a z g π H ω = k + then upwardRetainedLaw e f (k-1) z (π ω).val ω κ else 0) := by + funext ω + by_cases hj : bufferFirstFailure ℓ f a z g π H ω = k + · simp only [ite_eq_left hj] + exact bufferStageRetainedLaw_at_stop_lt e f a z₀ r ε α g π hH ω κ hklt hj + · simp only [ite_eq_right hj] + change @Measurable _ _ (rowSigma (BelowHeight ℓ (a+k))) _ _ + rw [hf] + exact (upwardRetainedLaw_at_height_rows e f a z κ π hπ (Nat.sub_le k 1)).ite heq measurable_const + · subst k + have hp : @Measurable _ _ (rowSigma (BelowHeight ℓ (a+H))) _ π := + hπ.mono (rowSigma_below_height_mono ℓ a H) le_rfl + have hmass (b : ℝ) : @Measurable _ _ (rowSigma (BelowHeight ℓ (a+H))) _ + (fun ω => pairKernelMass ℓ f H b (π ω).val ω) := by + have hm := (pairKernelMass_joint_rows ℓ f hH b (PairAtHeight ℓ a) (BelowHeight ℓ (a+H)) + (fun x hx => strip_subset_below_height ℓ a x hx le_rfl)).comp (hp.prodMk measurable_id) + exact hm + have hu := upwardRetainedLaw_at_height_rows e f a z κ π hπ (Nat.sub_le H 1) + have hc := retainedPairLaw_at_height_rows ℓ f a z π hπ (le_refl H) + have hg := retainedPairLaw_at_height_rows ℓ f a (z₀+(1+α)*r) π hπ (le_refl H) + have hf : (fun ω => if bufferFirstFailure ℓ f a z g π H ω = H + then bufferStageRetainedLaw e f a z₀ r ε α g π H ω κ else 0) = + (fun ω => if bufferFirstFailure ℓ f a z g π H ω = H then + (if pairKernelMass ℓ f H z (π ω).val ω < ENNReal.ofReal g then + upwardRetainedLaw e f (H-1) z (π ω).val ω κ + else if ENNReal.ofReal g ≤ pairKernelMass ℓ f H (z₀+(1+α)*r) (π ω).val ω then + retainedPairLaw ℓ f H (z₀+(1+α)*r) (π ω).val ω + else retainedPairLaw ℓ f H z (π ω).val ω) else 0) := by + funext ω + by_cases hj : bufferFirstFailure ℓ f a z g π H ω = H + · simp only [ite_eq_left hj,bufferStageRetainedLaw] + change (if pairKernelMass ℓ f (bufferFirstFailure ℓ f a z g π H ω) z (π ω).val ω < _ + then upwardRetainedLaw e f (bufferFirstFailure ℓ f a z g π H ω-1) z (π ω).val ω κ else _) = _ + rw [hj] + · simp only [ite_eq_right hj] + change @Measurable _ _ (rowSigma (BelowHeight ℓ (a+H))) _ _ + rw [hf] + exact (hu.ite (measurableSet_lt (hmass z) measurable_const) + (hg.ite (measurableSet_le measurable_const (hmass (z₀+(1+α)*r))) hc)).ite heq measurable_const + · have hn (ω : Environment d) : bufferFirstFailure ℓ f a z g π H ω ≠ k := by + have := (bufferFirstFailure_bounds ℓ f a z g π hH ω).2 + omega + convert (measurable_const : @Measurable _ _ (rowSigma (BelowHeight ℓ (a+k))) _ + (fun _ : Environment d => (0 : Measure (Lattice d × Lattice d)))) using 1 + funext ω + exact ite_eq_right (hn ω) +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/RowProductIntegral.lean b/lean/OAI/Probability/Ballisticity/Walk/RowProductIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..2de6b90ab6d2191be9aaec8ffad912bd4e9395cc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/RowProductIntegral.lean @@ -0,0 +1,46 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.IndependentRandomTestBound + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma lintegral_prod_disjoint_rows {d : ℕ} {ι : Type*} + (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (S : ι → Set (Lattice d)) (hS : Pairwise (fun i j => Disjoint (S i) (S j))) + (F : ι → Environment d → ℝ≥0∞) + (hF : ∀ i, @Measurable _ _ (rowSigma (S i)) _ (F i)) (I : Finset ι) : + (∫⁻ ω, ∏ i ∈ I, F i ω ∂environmentLaw ν) = + ∏ i ∈ I, ∫⁻ ω, F i ω ∂environmentLaw ν := by + induction I using Finset.cons_induction with + | empty => simp + | cons a I ha ih => + simp only [Finset.prod_cons] + let T := ⋃ i ∈ (I : Set ι), S i + have hST : Disjoint (S a) T := by + simp only [T,Set.disjoint_iUnion_right] + intro i hi + exact hS (by intro he; subst i; exact ha hi) + have hp : @Measurable _ _ (rowSigma T) _ (fun ω => ∏ i ∈ I, F i ω) := by + apply Finset.measurable_prod + intro i hi + exact (hF i).mono (rowSigma_mono (by + intro x hx; exact Set.mem_iUnion.mpr ⟨i,Set.mem_iUnion.mpr ⟨hi,hx⟩⟩)) le_rfl + have hind := indepFun_of_disjoint_rows ν hST (F a) _ (hF a) hp + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_indepFun'' + ((hF a).mono (rowSigma_le _) le_rfl).aemeasurable + (hp.mono (rowSigma_le _) le_rfl).aemeasurable hind,ih] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/Rows.lean b/lean/OAI/Probability/Ballisticity/Walk/Rows.lean new file mode 100644 index 0000000000000000000000000000000000000000..2813be2faebc0b9aeffe9f1c94b6a673a0e13b48 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/Rows.lean @@ -0,0 +1,424 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BigOperators + +namespace TailDecorrelation + +variable {I A D : Type*} [MeasurableSpace A] [MeasurableSpace D] + +@[instance_reducible] def rows (S : Set I) : MeasurableSpace (I → A) := + ⨆ i : S, (inferInstance : MeasurableSpace A).comap (fun ω => ω i.1) + +lemma rows_mono {S T : Set I} (h : S ⊆ T) : + rows (A := A) S ≤ rows T := by + apply iSup_le + intro i + exact le_iSup_of_le ⟨i.1, h i.2⟩ le_rfl + +lemma rows_le (S : Set I) : rows (A := A) S ≤ (inferInstance : MeasurableSpace (I → A)) := by + apply iSup_le + intro i + exact (show Measurable (fun ω : I → A => ω i.1) from + measurable_pi_apply i.1).comap_le + +lemma rows_univ : rows (A := A) (Set.univ : Set I) = (inferInstance : MeasurableSpace (I → A)) := by + apply le_antisymm (rows_le Set.univ) + change (⨆ i : I, _) ≤ _ + exact iSup_le fun i => le_iSup_of_le ⟨i, Set.mem_univ i⟩ le_rfl + +@[instance_reducible] def dataRows (S : Set I) : MeasurableSpace (D × (I → A)) := + (inferInstance : MeasurableSpace D).comap Prod.fst ⊔ + (rows S).comap Prod.snd + +lemma dataRows_mono {S T : Set I} (h : S ⊆ T) : + dataRows (D := D) (A := A) S ≤ dataRows T := by + exact sup_le_sup le_rfl (MeasurableSpace.comap_mono (rows_mono h)) + +lemma dataRows_le (S : Set I) : dataRows (D := D) (A := A) S ≤ (inferInstance : MeasurableSpace (D × (I → A))) := by + exact sup_le_sup le_rfl (MeasurableSpace.comap_mono (rows_le S)) + +lemma dataRows_univ : + dataRows (D := D) (A := A) (Set.univ : Set I) = (inferInstance : MeasurableSpace (D × (I → A))) := by + simp only [dataRows, rows_univ] + rfl + +lemma rows_eq_iSup_two (S : Set I) : + rows (A := A) S = + ⨆ i ∈ S, (inferInstance : MeasurableSpace A).comap (fun ω : I → A => ω i) := by + simp only [rows, iSup_subtype] + +lemma independent_rows (ν : Measure A) [IsProbabilityMeasure ν] + {S T : Set I} (hST : Disjoint S T) : + Indep (rows S) (rows T) (Measure.infinitePi (fun _ : I => ν)) := by + rw [rows_eq_iSup_two, rows_eq_iSup_two] + exact indep_iSup_of_disjoint (fun i => + (show Measurable (fun ω : I → A => ω i) from measurable_pi_apply i).comap_le) + (iIndepFun_infinitePi (P := fun _ : I => ν) + (X := fun _ a => a) (fun _ => measurable_id)).iIndep hST + +lemma independent_row_functions (ν : Measure A) [IsProbabilityMeasure ν] + {S T : Set I} (hST : Disjoint S T) + {f g : (I → A) → ℝ} + (hf : @Measurable _ _ (rows S) _ f) + (hg : @Measurable _ _ (rows T) _ g) : + IndepFun f g (Measure.infinitePi (fun _ : I => ν)) := by + rw [indepFun_iff_measure_inter_preimage_eq_mul] + intro s t hs ht + exact (Indep_iff _ _ _).mp (independent_rows ν hST) _ _ (hf hs) (hg ht) + +lemma row_function_integral_mul (ν : Measure A) [IsProbabilityMeasure ν] + {S T : Set I} (hST : Disjoint S T) + {f g : (I → A) → ℝ} + (hf : @Measurable _ _ (rows S) _ f) + (hg : @Measurable _ _ (rows T) _ g) : + (∫ ω, f ω * g ω ∂Measure.infinitePi (fun _ : I => ν)) = + (∫ ω, f ω ∂Measure.infinitePi (fun _ : I => ν)) * + ∫ ω, g ω ∂Measure.infinitePi (fun _ : I => ν) := by + exact (independent_row_functions ν hST hf hg).integral_mul_eq_mul_integral + ((hf.mono (rows_le S) le_rfl).aestronglyMeasurable) + ((hg.mono (rows_le T) le_rfl).aestronglyMeasurable) + +lemma dataRows_section {S : Set I} {f : D × (I → A) → ℝ} + (hf : @Measurable _ _ (dataRows S) _ f) (d : D) : + @Measurable _ _ (rows S) _ (fun ω => f (d, ω)) := by + apply hf.comp + let : MeasurableSpace (I → A) := rows S + exact measurable_const.prodMk measurable_id + +variable [Encodable I] + +def prefixRows (n : ℕ) : Set I := {i | Encodable.encode i < n} + +lemma prefixRows_finite (n : ℕ) : (prefixRows (I := I) n).Finite := by + exact (Set.finite_Iio n).preimage Encodable.encode_injective.injOn + +lemma prefixRows_mono : Monotone (prefixRows (I := I)) := by + intro n m h i hi + exact lt_of_lt_of_le hi h + +lemma iUnion_prefixRows : (⋃ n, prefixRows (I := I) n) = Set.univ := by + ext i + simp only [Set.mem_iUnion, Set.mem_univ, iff_true] + exact ⟨Encodable.encode i + 1, Nat.lt_succ_self _⟩ + +noncomputable def dataFiltration : Filtration ℕ (inferInstance : MeasurableSpace (D × (I → A))) where + seq n := dataRows (prefixRows n) + mono' := fun _ _ h => dataRows_mono (prefixRows_mono h) + le' n := dataRows_le (prefixRows n) + +lemma iSup_dataFiltration : + (⨆ n, dataFiltration (D := D) (A := A) (I := I) n) = (inferInstance : MeasurableSpace (D × (I → A))) := by + apply le_antisymm (iSup_le fun n => (dataFiltration (D := D) (A := A) (I := I)).le n) + change (inferInstance : MeasurableSpace D).comap Prod.fst ⊔ + (inferInstance : MeasurableSpace (I → A)).comap Prod.snd ≤ _ + apply sup_le + · exact le_iSup_of_le 0 le_sup_left + · change (⨆ i : I, (inferInstance : MeasurableSpace A).comap (fun ω => ω i)).comap + (Prod.snd : D × (I → A) → I → A) ≤ _ + rw [MeasurableSpace.comap_iSup] + apply iSup_le + intro i + apply le_iSup_of_le (Encodable.encode i + 1) + apply le_trans _ le_sup_right + exact MeasurableSpace.comap_mono (le_iSup_of_le + (⟨i, Nat.lt_succ_self _⟩ : prefixRows (Encodable.encode i + 1)) le_rfl) + +section LikelihoodApproximation + +variable {μ : Measure (D × (I → A))} [IsFiniteMeasure μ] + +lemma likelihood_approximation {f : D × (I → A) → ℝ} + (hf : Integrable f μ) (hm : StronglyMeasurable f) : + Tendsto (fun n => eLpNorm + (μ[f | dataFiltration (D := D) (A := A) (I := I) n] - f) 1 μ) + atTop (𝓝 0) := by + apply hf.tendsto_eLpNorm_condExp (ℱ := dataFiltration (D := D) (A := A) (I := I)) + rw [iSup_dataFiltration] + exact hm + +lemma bounded_likelihood_approximation {f : D × (I → A) → ℝ} {B : ℝ} + (hB : 0 ≤ B) (hf : StronglyMeasurable f) + (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) : + ∃ g : ℕ → D × (I → A) → ℝ, + (∀ n, @Measurable _ _ (dataRows (prefixRows n)) _ (g n)) ∧ + (∀ n x, 0 ≤ g n x ∧ g n x ≤ B) ∧ + (∀ n, (∫ x, g n x ∂μ) = ∫ x, f x ∂μ) ∧ + Tendsto (fun n => ∫ x, |g n x - f x| ∂μ) atTop (𝓝 0) := by + let F := dataFiltration (D := D) (A := A) (I := I) + let u : ℕ → D × (I → A) → ℝ := fun n => μ[f | F n] + let g : ℕ → D × (I → A) → ℝ := fun n x => max 0 (min B (u n x)) + have hu (n : ℕ) : @Measurable _ _ (dataRows (prefixRows n)) _ (u n) := + stronglyMeasurable_condExp.measurable + have hg (n : ℕ) : @Measurable _ _ (dataRows (prefixRows n)) _ (g n) := + measurable_const.max (measurable_const.min (hu n)) + have hgf (n : ℕ) : g n =ᵐ[μ] u n := by + have h0 : 0 ≤ᵐ[μ] u n := condExp_nonneg (Eventually.of_forall hf0) + have h1 : ∀ᵐ x ∂μ, u n x ≤ B := + condExp_le_nonneg_const hB (Eventually.of_forall hfB) + filter_upwards [h0, h1] with x hx0 hx1 + change 0 ≤ u n x at hx0 + simp only [g, min_eq_right hx1, max_eq_right hx0] + have hfi : Integrable f μ := (integrable_const B).mono' hf.aestronglyMeasurable + (Eventually.of_forall fun x => by simpa [Real.norm_eq_abs, abs_of_nonneg (hf0 x)] using hfB x) + refine ⟨g, hg, ?_, ?_, ?_⟩ + · intro n x + exact ⟨le_max_left _ _, max_le hB (min_le_left _ _)⟩ + · intro n + rw [integral_congr_ae (hgf n)] + exact integral_condExp (F.le n) + · have ht := ENNReal.tendsto_toReal ENNReal.zero_ne_top |>.comp + (likelihood_approximation (μ := μ) hfi hf) + simp only [ENNReal.toReal_zero] at ht + apply ht.congr + intro n + change (eLpNorm (u n - f) 1 μ).toReal = _ + rw [eLpNorm_one_eq_lintegral_enorm (integrable_condExp.sub hfi).aestronglyMeasurable, + ← integral_norm_eq_lintegral_enorm (integrable_condExp.sub hfi).aestronglyMeasurable] + apply integral_congr_ae + filter_upwards [hgf n] with x hx + simp only [Pi.sub_apply, Real.norm_eq_abs, hx] + rfl + +end LikelihoodApproximation + +section BoundedEscape + +variable {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsFiniteMeasure μ] + +lemma integrable_bounded_nonneg {f : Ω → ℝ} {B : ℝ} + (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) : + Integrable f μ := by + exact (integrable_const B).mono' hf.aestronglyMeasurable + (Eventually.of_forall fun x => by simpa [Real.norm_eq_abs, abs_of_nonneg (hf0 x)] using hfB x) + +lemma eventually_integral_le_of_pointwise_eventually + {F : ℕ → Ω → ℝ} {G : Ω → ℝ} {K : ℝ} + (hF : ∀ n, Measurable (F n)) (hG : Integrable G μ) + (hF0 : ∀ n x, 0 ≤ F n x) (hFK : ∀ n x, F n x ≤ K) + (hG0 : ∀ x, 0 ≤ G x) + (hevent : ∀ᵐ x ∂μ, ∀ᶠ n in atTop, F n x ≤ G x) : + ∀ ε > 0, ∀ᶠ n in atTop, (∫ x, F n x ∂μ) ≤ (∫ x, G x ∂μ) + ε := by + let E : ℕ → Ω → ℝ := fun n x => max 0 (F n x - G x) + have hEmeas (n : ℕ) : AEStronglyMeasurable (E n) μ := + (aemeasurable_const.max ((hF n).aemeasurable.sub hG.aestronglyMeasurable.aemeasurable)).aestronglyMeasurable + have hEbound (n : ℕ) (x : Ω) : ‖E n x‖ ≤ K := by + rw [Real.norm_eq_abs, abs_of_nonneg (le_max_left _ _)] + exact max_le (le_trans (hF0 n x) (hFK n x)) (by linarith [hFK n x, hG0 x]) + have hEi (n : ℕ) : Integrable (E n) μ := + (integrable_const K).mono' (hEmeas n) (Eventually.of_forall (hEbound n)) + have hlim : ∀ᵐ x ∂μ, Tendsto (fun n => E n x) atTop (𝓝 0) := by + filter_upwards [hevent] with x hx + apply tendsto_const_nhds.congr' + filter_upwards [hx] with n hn + exact (max_eq_left (sub_nonpos.mpr hn)).symm + have ht : Tendsto (fun n => ∫ x, E n x ∂μ) atTop (𝓝 0) := by + simpa only [integral_zero] using tendsto_integral_of_dominated_convergence + (fun _ => K) hEmeas (integrable_const K) + (fun n => Eventually.of_forall (hEbound n)) hlim + intro ε hε + filter_upwards [ht.eventually_lt_const hε] with n hn + calc + (∫ x, F n x ∂μ) ≤ ∫ x, G x + E n x ∂μ := by + apply integral_mono (integrable_bounded_nonneg (hF n) (hF0 n) (hFK n)) (hG.add (hEi n)) + intro x + have := le_max_right 0 (F n x - G x) + dsimp [E] + linarith + _ = (∫ x, G x ∂μ) + ∫ x, E n x ∂μ := integral_add hG (hEi n) + _ ≤ _ := by linarith + +end BoundedEscape + +section BoundedIndependence + +variable (δ : Measure D) (ν : Measure A) [IsProbabilityMeasure δ] [IsProbabilityMeasure ν] + +omit [Encodable I] in +lemma bounded_escape_product + {S : Set I} {g : D × (I → A) → ℝ} {B K C : ℝ} + (hB : 0 ≤ B) (_ : 0 ≤ K) (hC : 0 ≤ C) + (hg : @Measurable _ _ (dataRows S) _ g) + (hg0 : ∀ x, 0 ≤ g x) (hgB : ∀ x, g x ≤ B) + (W : ℕ → D × (I → A) → ℝ) (T : ℕ → D → Set I) + (hW : ∀ n, Measurable (W n)) + (hW0 : ∀ n x, 0 ≤ W n x) (hWK : ∀ n x, W n x ≤ K) + (hWr : ∀ n d, @Measurable _ _ (rows (T n d)) _ (fun ω => W n (d, ω))) + (hWC : ∀ n d, (∫ ω, W n (d, ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ C) + (hescape : ∀ᵐ d ∂δ, ∀ᶠ n in atTop, Disjoint S (T n d)) : + ∀ ε > 0, ∀ᶠ n in atTop, + (∫ x, g x * W n x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) ≤ + C * (∫ x, g x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) + ε := by + let P := Measure.infinitePi (fun _ : I => ν) + have hgm : Measurable g := hg.mono (dataRows_le S) le_rfl + have hgi : Integrable g (δ.prod P) := integrable_bounded_nonneg hgm hg0 hgB + have hprod0 (n : ℕ) (x : D × (I → A)) : 0 ≤ g x * W n x := + mul_nonneg (hg0 x) (hW0 n x) + have hprodK (n : ℕ) (x : D × (I → A)) : g x * W n x ≤ B * K := + mul_le_mul (hgB x) (hWK n x) (hW0 n x) hB + have hprod (n : ℕ) : Integrable (fun x => g x * W n x) (δ.prod P) := + integrable_bounded_nonneg (hgm.mul (hW n)) (hprod0 n) (hprodK n) + let F : ℕ → D → ℝ := fun n d => ∫ ω, g (d, ω) * W n (d, ω) ∂P + let G : D → ℝ := fun d => C * ∫ ω, g (d, ω) ∂P + have hFm (n : ℕ) : Measurable (F n) := + (hgm.mul (hW n)).stronglyMeasurable.integral_prod_right.measurable + have hGi : Integrable G δ := hgi.integral_prod_left.const_mul C + have hG0 (d : D) : 0 ≤ G d := + mul_nonneg hC (integral_nonneg fun ω => hg0 (d, ω)) + have hF0 (n : ℕ) (d : D) : 0 ≤ F n d := integral_nonneg fun ω => hprod0 n (d, ω) + have hFK (n : ℕ) (d : D) : F n d ≤ B * K := by + calc + F n d ≤ ∫ _ : I → A, B * K ∂P := by + exact integral_mono + (integrable_bounded_nonneg (μ := P) + ((hgm.mul (hW n)).comp (measurable_const.prodMk measurable_id)) + (fun ω => hprod0 n (d, ω)) (fun ω => hprodK n (d, ω))) + (integrable_const _) (fun ω => hprodK n (d, ω)) + _ = B * K := by simp [P] + have hevent : ∀ᵐ d ∂δ, ∀ᶠ n in atTop, F n d ≤ G d := by + filter_upwards [hescape] with d hd + filter_upwards [hd] with n hn + change (∫ ω, g (d, ω) * W n (d, ω) ∂P) ≤ _ + rw [row_function_integral_mul ν hn (dataRows_section hg d) (hWr n d)] + change (∫ ω, g (d, ω) ∂P) * (∫ ω, W n (d, ω) ∂P) ≤ + C * (∫ ω, g (d, ω) ∂P) + exact (mul_le_mul_of_nonneg_left (hWC n d) (integral_nonneg fun ω => hg0 (d, ω))).trans_eq + (mul_comm _ _) + intro ε hε + filter_upwards [eventually_integral_le_of_pointwise_eventually hFm hGi hF0 hFK hG0 hevent ε hε] with n hn + rw [integral_prod _ (hprod n)] + rw [show (∫ d, G d ∂δ) = C * ∫ x, g x ∂δ.prod P by + dsimp [G] + rw [integral_const_mul, ← integral_prod _ hgi]] at hn + exact hn + +def EscapingLocalApproximation (Z : ℕ → D × (I → A) → ℝ) (K : ℝ) : Prop := + ∀ η > 0, ∃ (W : ℕ → D × (I → A) → ℝ) (T : ℕ → D → Set I), + (∀ n, Measurable (W n)) ∧ + (∀ n x, 0 ≤ W n x ∧ W n x ≤ K) ∧ + (∀ n d, @Measurable _ _ (rows (T n d)) _ (fun ω => W n (d, ω))) ∧ + (∀ n d, (∫ ω, |Z n (d, ω) - W n (d, ω)| ∂Measure.infinitePi (fun _ : I => ν)) ≤ η) ∧ + (∀ S : Set I, S.Finite → ∀ᵐ d ∂δ, ∀ᶠ n in atTop, Disjoint S (T n d)) + +lemma bounded_product_approximation_pointwise {f g z w B K : ℝ} + (hg0 : 0 ≤ g) (hgB : g ≤ B) (hz0 : 0 ≤ z) (hzK : z ≤ K) : + f * z ≤ g * w + K * |f - g| + B * |z - w| := by + have h1 := mul_le_mul_of_nonneg_right (le_abs_self (f - g)) hz0 + have h2 := mul_le_mul_of_nonneg_left hzK (abs_nonneg (f - g)) + have h3 := mul_le_mul_of_nonneg_left (le_abs_self (z - w)) hg0 + have h4 := mul_le_mul_of_nonneg_right hgB (abs_nonneg (z - w)) + nlinarith + +lemma bounded_decorrelation + {f : D × (I → A) → ℝ} {Z : ℕ → D × (I → A) → ℝ} {B K C : ℝ} + (hB : 0 ≤ B) (hK : 0 ≤ K) (hC : 0 ≤ C) + (hf : Measurable f) (hf0 : ∀ x, 0 ≤ f x) (hfB : ∀ x, f x ≤ B) + (hZ : ∀ n, Measurable (Z n)) + (hZ0 : ∀ n x, 0 ≤ Z n x) (hZK : ∀ n x, Z n x ≤ K) + (hZC : ∀ n d, (∫ ω, Z n (d, ω) ∂Measure.infinitePi (fun _ : I => ν)) ≤ C) + (hloc : EscapingLocalApproximation δ ν Z K) : + ∀ ε > 0, ∀ᶠ n in atTop, + (∫ x, f x * Z n x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) ≤ + C * (∫ x, f x ∂δ.prod (Measure.infinitePi (fun _ : I => ν))) + ε := by + let P := Measure.infinitePi (fun _ : I => ν) + let μ := δ.prod P + have hfi : Integrable f μ := integrable_bounded_nonneg hf hf0 hfB + have hfintB : (∫ x, f x ∂μ) ≤ B := by + calc + (∫ x, f x ∂μ) ≤ ∫ _ : D × (I → A), B ∂μ := integral_mono hfi (integrable_const B) hfB + _ = B := by simp [μ, P] + obtain ⟨g, hgr, hgb, hgint, hgconv⟩ := + bounded_likelihood_approximation (μ := μ) hB hf.stronglyMeasurable hf0 hfB + intro ε hε + let η := ε / (2 * (K + 2 * B + 1)) + have hη : 0 < η := by dsimp [η]; positivity + obtain ⟨W, T, hWm, hWb, hWr, hWerr, hWesc⟩ := hloc η hη + obtain ⟨j, hj⟩ := (hgconv.eventually_lt_const hη).exists + let g₀ := g j + have hg₀m : Measurable g₀ := (hgr j).mono (dataRows_le _) le_rfl + have hg₀i : Integrable g₀ μ := + integrable_bounded_nonneg hg₀m (fun x => (hgb j x).1) (fun x => (hgb j x).2) + have hW0 (n : ℕ) (x : D × (I → A)) : 0 ≤ W n x := (hWb n x).1 + have hWK (n : ℕ) (x : D × (I → A)) : W n x ≤ K := (hWb n x).2 + have hZi (n : ℕ) : Integrable (Z n) μ := integrable_bounded_nonneg (hZ n) (hZ0 n) (hZK n) + have hWi (n : ℕ) : Integrable (W n) μ := integrable_bounded_nonneg (hWm n) (hW0 n) (hWK n) + have hZsi (n : ℕ) (d : D) : Integrable (fun ω => Z n (d, ω)) P := + integrable_bounded_nonneg ((hZ n).comp (measurable_const.prodMk measurable_id)) + (fun ω => hZ0 n (d, ω)) (fun ω => hZK n (d, ω)) + have hWsi (n : ℕ) (d : D) : Integrable (fun ω => W n (d, ω)) P := + integrable_bounded_nonneg ((hWm n).comp (measurable_const.prodMk measurable_id)) + (fun ω => hW0 n (d, ω)) (fun ω => hWK n (d, ω)) + have hWmean (n : ℕ) (d : D) : (∫ ω, W n (d, ω) ∂P) ≤ C + η := by + calc + (∫ ω, W n (d, ω) ∂P) ≤ ∫ ω, Z n (d, ω) + |Z n (d, ω) - W n (d, ω)| ∂P := by + apply integral_mono (hWsi n d) ((hZsi n d).add ((hZsi n d).sub (hWsi n d)).abs) + intro ω + have := neg_abs_le (Z n (d, ω) - W n (d, ω)) + change W n (d, ω) ≤ Z n (d, ω) + |Z n (d, ω) - W n (d, ω)| + linarith + _ = (∫ ω, Z n (d, ω) ∂P) + ∫ ω, |Z n (d, ω) - W n (d, ω)| ∂P := + integral_add (hZsi n d) ((hZsi n d).sub (hWsi n d)).abs + _ ≤ C + η := add_le_add (hZC n d) (hWerr n d) + have herri (n : ℕ) : Integrable (fun x => |Z n x - W n x|) μ := + ((hZi n).sub (hWi n)).abs + have hWerrμ (n : ℕ) : (∫ x, |Z n x - W n x| ∂μ) ≤ η := by + change (∫ x, |Z n x - W n x| ∂δ.prod P) ≤ η + rw [integral_prod _ (herri n)] + calc + (∫ d, ∫ ω, |Z n (d, ω) - W n (d, ω)| ∂P ∂δ) ≤ ∫ _ : D, η ∂δ := + integral_mono ((hZi n).sub (hWi n)).abs.integral_prod_left (integrable_const η) (hWerr n) + _ = η := by simp + have hprod (n : ℕ) : Integrable (fun x => f x * Z n x) μ := + integrable_bounded_nonneg (hf.mul (hZ n)) (fun x => mul_nonneg (hf0 x) (hZ0 n x)) + (fun x => mul_le_mul (hfB x) (hZK n x) (hZ0 n x) hB) + have hgprod (n : ℕ) : Integrable (fun x => g₀ x * W n x) μ := + integrable_bounded_nonneg (hg₀m.mul (hWm n)) (fun x => mul_nonneg (hgb j x).1 (hW0 n x)) + (fun x => mul_le_mul (hgb j x).2 (hWK n x) (hW0 n x) hB) + have hgf : (∫ x, |f x - g₀ x| ∂μ) < η := by + simpa only [abs_sub_comm] using hj + have hevent := bounded_escape_product δ ν hB hK (add_nonneg hC hη.le) + (hgr j) (fun x => (hgb j x).1) (fun x => (hgb j x).2) + W T hWm hW0 hWK hWr hWmean (hWesc _ (prefixRows_finite j)) η hη + filter_upwards [hevent] with n hn + have hfgi : Integrable (fun x => |f x - g₀ x|) μ := (hfi.sub hg₀i).abs + have hsum : Integrable (fun x => g₀ x * W n x + K * |f x - g₀ x|) μ := + (hgprod n).add (hfgi.const_mul K) + have hi : (∫ x, f x * Z n x ∂μ) ≤ + (∫ x, g₀ x * W n x ∂μ) + K * (∫ x, |f x - g₀ x| ∂μ) + + B * (∫ x, |Z n x - W n x| ∂μ) := by + have ht := integral_mono (hprod n) (hsum.add ((herri n).const_mul B)) + (fun x => bounded_product_approximation_pointwise (hgb j x).1 (hgb j x).2 (hZ0 n x) (hZK n x)) + change (∫ x, f x * Z n x ∂μ) ≤ + ∫ x, (g₀ x * W n x + K * |f x - g₀ x|) + B * |Z n x - W n x| ∂μ at ht + rwa [integral_add hsum ((herri n).const_mul B), + integral_add (hgprod n) (hfgi.const_mul K), + integral_const_mul, integral_const_mul] at ht + have hn' : (∫ x, g₀ x * W n x ∂μ) ≤ (C + η) * (∫ x, f x ∂μ) + η := by + change (∫ x, g j x * W n x ∂μ) ≤ (C + η) * (∫ x, g j x ∂μ) + η at hn + rw [hgint j] at hn + exact hn + have heq : (K + 2 * B + 1) * η = ε / 2 := by + dsimp [η] + have hden : K + 2 * B + 1 ≠ 0 := by positivity + field_simp + have h1 := mul_le_mul_of_nonneg_left hgf.le hK + have h2 := mul_le_mul_of_nonneg_left (hWerrμ n) hB + have h3 := mul_le_mul_of_nonneg_left hfintB hη.le + change (∫ x, f x * Z n x ∂μ) ≤ C * (∫ x, f x ∂μ) + ε + nlinarith + +end BoundedIndependence + +end TailDecorrelation + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/SelectedFiniteKernel.lean b/lean/OAI/Probability/Ballisticity/Walk/SelectedFiniteKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3aece4a6dc9a11cd26bbe293b2b0101baae2d0d --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/SelectedFiniteKernel.lean @@ -0,0 +1,97 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +noncomputable def normalizeFinite {α : Type*} [MeasurableSpace α] (μ : Measure α) : Measure α := + (μ Set.univ)⁻¹ • μ + +lemma normalizeFinite_probability {α : Type*} [MeasurableSpace α] (μ : Measure α) + (h0 : μ Set.univ ≠ 0) (ht : μ Set.univ ≠ ∞) : IsProbabilityMeasure (normalizeFinite μ) := by + refine ⟨?_⟩ + simpa [normalizeFinite,Measure.smul_apply] using ENNReal.inv_mul_cancel h0 ht + +lemma normalizeFinite_domination {α : Type*} [MeasurableSpace α] (μ : Measure α) + {δ : ℝ≥0∞} (_ : δ ≠ 0) (hm : δ ≤ μ Set.univ) : + normalizeFinite μ ≤ δ⁻¹ • μ := by + apply Measure.le_iff.mpr + intro U hU + simp only [normalizeFinite,Measure.smul_apply,smul_eq_mul] + gcongr + +lemma measurable_normalizeFinite {Ω α : Type*} [MeasurableSpace Ω] [MeasurableSpace α] + (μ : Ω → Measure α) (hμ : Measurable μ) : Measurable (fun ω => normalizeFinite (μ ω)) := by + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [normalizeFinite,Measure.smul_apply,smul_eq_mul] + exact (((Measure.measurable_coe MeasurableSet.univ).comp hμ).inv).mul + ((Measure.measurable_coe hU).comp hμ) + +noncomputable def selectedFiniteKernel {α : Type*} [MeasurableSpace α] + (D : Measure α) (E : Set α) (dummy : α) (failure strict : Prop) + [Decidable failure] [Decidable strict] : Measure α := + if failure then Measure.dirac dummy else normalizeFinite (if strict then D.restrict E else D) + +lemma selectedFiniteKernel_probability {α : Type*} [MeasurableSpace α] + (D : Measure α) [IsFiniteMeasure D] (E : Set α) (dummy : α) (failure strict : Prop) + [Decidable failure] [Decidable strict] + (hD : ¬failure → D Set.univ ≠ 0) (hE : ¬failure → strict → D E ≠ 0) : + IsProbabilityMeasure (selectedFiniteKernel D E dummy failure strict) := by + by_cases hf : failure + · simp only [selectedFiniteKernel,ite_eq_left hf]; infer_instance + simp only [selectedFiniteKernel,ite_eq_right hf] + by_cases hs : strict + · simp only [ite_eq_left hs] + apply normalizeFinite_probability + · simpa using hE hf hs + · exact measure_ne_top _ _ + · simp only [ite_eq_right hs] + exact normalizeFinite_probability D (hD hf) (measure_ne_top _ _) + +lemma selectedFiniteKernel_domination {α : Type*} [MeasurableSpace α] + (D : Measure α) (E : Set α) (dummy : α) (failure strict : Prop) + [Decidable failure] [Decidable strict] {δ : ℝ≥0∞} (hδ : δ ≠ 0) + (hf : ¬failure) (hD : δ ≤ D Set.univ) (hE : strict → δ ≤ D E) : + selectedFiniteKernel D E dummy failure strict ≤ δ⁻¹ • D := by + simp only [selectedFiniteKernel,ite_eq_right hf] + by_cases hs : strict + · simp only [ite_eq_left hs] + exact (normalizeFinite_domination _ hδ (by simpa using hE hs)).trans + (by + apply Measure.le_iff.mpr + intro U hU + simp only [Measure.smul_apply,smul_eq_mul] + gcongr + exact Measure.restrict_le_self) + · simp only [ite_eq_right hs] + exact normalizeFinite_domination D hδ hD + +lemma selectedFiniteKernel_measurable {Ω α : Type*} [MeasurableSpace Ω] [MeasurableSpace α] + (D : Ω → Measure α) (hD : Measurable D) (E : Set α) (hE : MeasurableSet E) + (dummy : α) (failure strict : Ω → Prop) [DecidablePred failure] [DecidablePred strict] + (hf : MeasurableSet {ω | failure ω}) (hs : MeasurableSet {ω | strict ω}) : + Measurable (fun ω => selectedFiniteKernel (D ω) E dummy (failure ω) (strict ω)) := by + unfold selectedFiniteKernel + apply Measurable.ite hf measurable_const + apply measurable_normalizeFinite + apply Measurable.ite hs _ hD + apply Measure.measurable_of_measurable_coe + intro U hU + simp only [Measure.restrict_apply hU] + exact (Measure.measurable_coe (hU.inter hE)).comp hD + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/SelectedKernelMap.lean b/lean/OAI/Probability/Ballisticity/Walk/SelectedKernelMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..147c1c508048f4eb197e44ff1736cfe14b766c45 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/SelectedKernelMap.lean @@ -0,0 +1,60 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.SelectedEndpointMoment +import OAI.Probability.Ballisticity.Walk.SelectedFiniteKernel + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology Classical +namespace DirectionalTransience + +lemma normalizeFinite_map {Ω A : Type*} [MeasurableSpace Ω] [MeasurableSpace A] + (μ : Measure Ω) (Y : Ω → A) (hY : Measurable Y) : + normalizeFinite (μ.map Y) = (normalizeFinite μ).map Y := by + simp only [normalizeFinite,Measure.map_apply hY MeasurableSet.univ,Set.preimage_univ, + Measure.map_smul _ hY.aemeasurable] + +lemma normalizeFinite_restrict {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (N : Set Ω) : normalizeFinite (μ.restrict N) = μ[|N] := by + simp only [normalizeFinite,Measure.restrict_apply_univ,ProbabilityTheory.cond] + +lemma selectedFiniteKernel_map_eq {Ω A : Type*} [MeasurableSpace Ω] [MeasurableSpace A] + [MeasurableSingletonClass A] (μ : Measure Ω) (N : Set Ω) (Z : Ω → A) (hZ : Measurable Z) + (E : Set A) (hE : MeasurableSet E) (Y : A → ℝ) (hY : Measurable Y) + (dummy : A) (failure strict : Prop) [Decidable failure] [Decidable strict] : + (selectedFiniteKernel ((μ.restrict N).map Z) E dummy failure strict).map Y = + selectedEndpointLaw μ N (N ∩ Z ⁻¹' E) (Y ∘ Z) (Y dummy) failure strict := by + by_cases hf : failure + · simp only [selectedFiniteKernel,selectedEndpointLaw,ite_eq_left hf,Measure.map_dirac' hY] + simp only [selectedFiniteKernel,selectedEndpointLaw,ite_eq_right hf] + by_cases hs : strict + · simp only [ite_eq_left hs] + rw [Measure.restrict_map hZ hE,Measure.restrict_restrict (hZ hE)] + rw [Set.inter_comm (Z ⁻¹' E) N,normalizeFinite_map _ Z hZ, + normalizeFinite_restrict,Measure.map_map hY hZ] + · simp only [ite_eq_right hs] + rw [normalizeFinite_map _ Z hZ,normalizeFinite_restrict,Measure.map_map hY hZ] + +lemma selectedEndpointLaw_cond {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsFiniteMeasure μ] (C N E : Set Ω) + (hC : MeasurableSet C) (hN : MeasurableSet N) (hE : MeasurableSet E) + (Y : Ω → ℝ) (b : ℝ) (failure strict : Prop) [Decidable failure] [Decidable strict] : + selectedEndpointLaw μ[|C] N E Y b failure strict = + selectedEndpointLaw μ (C ∩ N) (C ∩ E) Y b failure strict := by + unfold selectedEndpointLaw + split_ifs with hf hs + · rfl + · rw [cond_cond_eq_cond_inter hC hE] + · rw [cond_cond_eq_cond_inter hC hN] + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/SharedPairPathLimit.lean b/lean/OAI/Probability/Ballisticity/Walk/SharedPairPathLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..08f51a6ddf4f41c8a1eafb8b09ca6d857e30282a --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/SharedPairPathLimit.lean @@ -0,0 +1,204 @@ +import Mathlib +import OAI.Probability.Ballisticity.Coupling.QuenchedMoments +import OAI.Probability.Ballisticity.Estimates.SharedLimitOccupation +import OAI.Probability.Ballisticity.Estimates.PairWeakUniqueness + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma probability_law_tendsto {Ω E : Type*} [MeasurableSpace Ω] + [TopologicalSpace E] [MeasurableSpace E] [BorelSpace E] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] (X : ℕ → Ω → E) + (hX : ∀ i, AEMeasurable (X i) (μ i)) (W : ProbabilityMeasure E) + (h : TendstoInDistribution X atTop id μ W) : + Tendsto (β := ProbabilityMeasure E) (fun i => (⟨(μ i).map (X i), + (Measure.isProbabilityMeasure_map_iff (hX i)).mpr inferInstance⟩ : ProbabilityMeasure E)) + atTop (𝓝 W) := by + have hh := h.tendsto + have he : (⟨(W : Measure E).map id, + (Measure.isProbabilityMeasure_map_iff h.aemeasurable_limit).mpr inferInstance⟩ : ProbabilityMeasure E)=W := by + apply Subtype.ext + exact Measure.map_id + simpa only [he] using hh + +theorem shared_pair_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) + (T : ℝ) (hT : 0 < T) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + (∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g)=gaussianPathFiniteLaw (T/(2*commonMeanWidth ν ℓ)) I) ∧ + ∀ x : ℕ → Lattice d, + ∀ μ : ℕ → ProbabilityMeasure RealPathPair, + (∀ i, (μ i : Measure RealPathPair)=(sharedConditionedPairLaw ν ℓ (x i) (x i)).map + (sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (x i))) → + Tendsto μ atTop (𝓝 (W.prod W)) := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + obtain ⟨W,hW,hlim⟩ := shared_path_marginal_limits ν hue e f hef htrans r hr hT.le + refine ⟨W,hW,?_⟩ + intro x μ hμ + let η := fun i => sharedConditionedPairLaw ν ℓ (x i) (x i) + have : ∀ i, IsProbabilityMeasure (η i) := fun i => sharedConditionedPairLaw_probability ν ℓ _ _ + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans _ _)) + let X := fun i (P : Path d × Path d) => recordLinearPath ℓ f (θ i) (r i) (n i) T (fun j => P.1 j-x i) + let Y := fun i (P : Path d × Path d) => recordLinearPath ℓ f (θ i) (r i) (n i) T (fun j => P.2 j-x i) + have hX (i : ℕ) : Measurable (X i) := (measurable_recordLinearPath _ _ _ _ _ _).comp (by fun_prop) + have hY (i : ℕ) : Measurable (Y i) := (measurable_recordLinearPath _ _ _ _ _ _).comp (by fun_prop) + obtain ⟨hf,hg⟩ := hlim x x (fun _ => rfl) + have hMf : Tendsto (fun i => (μ i).map Prod.fst) atTop (𝓝 W) := by + have hh := probability_law_tendsto η X (fun i => (hX i).aemeasurable) W hf + apply hh.congr' + filter_upwards [] with i + symm + apply Subtype.ext + change (μ i : Measure RealPathPair).map Prod.fst=_ + rw [hμ i,Measure.map_map measurable_fst (measurable_sharedLinearPairPath _ _ _ _ _ _ _ _)] + rfl + have hMg : Tendsto (fun i => (μ i).map Prod.snd) atTop (𝓝 W) := by + have hh := probability_law_tendsto η Y (fun i => (hY i).aemeasurable) W hg + apply hh.congr' + filter_upwards [] with i + symm + apply Subtype.ext + change (μ i : Measure RealPathPair).map Prod.snd=_ + rw [hμ i,Measure.map_map measurable_snd (measurable_sharedLinearPairPath _ _ _ _ _ _ _ _)] + rfl + apply weak_limit_of_tight_identification μ (W.prod W) (pair_weak_tight μ W W hMf hMg) + intro j hj V hV + have hVf : (V : Measure RealPathPair).map Prod.fst=W := by + have he := tendsto_nhds_unique + ((ProbabilityMeasure.continuous_map continuous_fst).tendsto V |>.comp hV) (hMf.comp hj) + exact congrArg (fun M : ProbabilityMeasure C(unitInterval,ℝ) => (M : Measure C(unitInterval,ℝ))) he + have hVg : (V : Measure RealPathPair).map Prod.snd=W := by + have he := tendsto_nhds_unique + ((ProbabilityMeasure.continuous_map continuous_snd).tendsto V |>.comp hV) (hMg.comp hj) + exact congrArg (fun M : ProbabilityMeasure C(unitInterval,ℝ) => (M : Measure C(unitInterval,ℝ))) he + apply Subtype.ext + exact shared_limit_product ν hue e f hef htrans (r ∘ j) (hr.comp hj) T hT (x ∘ j) + (μ ∘ j) V hV W hW hVf hVg (fun i => hμ (j i)) + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology BoundedContinuousFunction +namespace DirectionalTransience + +lemma medianFirstHitPath_sub_linear {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (f : Direction d) + (x : Lattice d) (θ r n T : ℝ) (X : Path d) : + medianFirstHitPath ν ℓ hp f x r n T X- + recordLinearPath ℓ f θ r n T (fun j => X j-x) = + heightPolygon (fun h => (h:ℝ)*θ-(recordMedian ν ℓ hp f h:ℝ)) r n T := by + exact heightPolygon_change_center _ _ _ _ _ _ + +lemma linear_add_median_error {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (ℓ : Vector d) (hp : annealedLaw ν (NoDrop ℓ 0) ≠ 0) (f : Direction d) + (x : Lattice d) (θ r n T : ℝ) (X : Path d) : + recordLinearPath ℓ f θ r n T (fun j => X j-x)+ + heightPolygon (fun h => (h:ℝ)*θ-(recordMedian ν ℓ hp f h:ℝ)) r n T = + medianFirstHitPath ν ℓ hp f x r n T X := by + rw [← medianFirstHitPath_sub_linear ν ℓ hp f x θ r n T X] + abel + +lemma median_center_error_tendsto {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + Tendsto (fun i => heightPolygon (fun h => (h:ℝ)*θ i-(recordMedian ν ℓ hp f h:ℝ)) + (r i) (n i) T) atTop (𝓝 0) := by + dsimp only + apply heightPolygon_tendsto_zero_of_grid _ _ _ + (recordFluctuationScale_tendsto ν hue e f hef htrans r hr.1) T hT + intro ε hε + filter_upwards [recordMedian_linearization ν hue e f hef htrans r hr (T+1) hε] with i hi + intro j hj + simpa only [abs_div,abs_sub_comm] using hi j hj + +theorem shared_median_pair_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) (T : ℝ) (hT : 0 < T) : + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + (∀ I : Finset unitInterval, (W : Measure C(unitInterval,ℝ)).map + (fun g : C(unitInterval,ℝ) => I.restrict g)=gaussianPathFiniteLaw (T/(2*commonMeanWidth ν ℓ)) I) ∧ + ∀ x : ℕ → Lattice d, + ∀ μ : ℕ → ProbabilityMeasure RealPathPair, + (∀ i, (μ i : Measure RealPathPair)=(sharedConditionedPairLaw ν ℓ (x i) (x i)).map + (fun P : Path d × Path d => (medianFirstHitPath ν ℓ hp f (x i) (r i) (n i) T P.1, + medianFirstHitPath ν ℓ hp f (x i) (r i) (n i) T P.2))) → + Tendsto μ atTop (𝓝 (W.prod W)) := by + dsimp only + let ℓ := realPosition (step e) + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + let θ := fun i => recordMedianSlope ν ℓ hp f (r i) + obtain ⟨W,hW,hlim⟩ := shared_pair_path_limit ν hue e f hef htrans r hr T hT + refine ⟨W,hW,?_⟩ + intro x μ hμ + let η := fun i => sharedConditionedPairLaw ν ℓ (x i) (x i) + have : ∀ i, IsProbabilityMeasure (η i) := fun i => sharedConditionedPairLaw_probability ν ℓ _ _ + (ne_of_gt (sharedNoDropMass_pos ν hue ℓ (signed_direction_unit e) htrans _ _)) + let L := fun i => sharedLinearPairPath ℓ f (θ i) (r i) (n i) T (x i) (x i) + have hL (i : ℕ) : Measurable (L i) := measurable_sharedLinearPairPath _ _ _ _ _ _ _ _ + let V : ℕ → ProbabilityMeasure RealPathPair := fun i => ⟨(η i).map (L i), + (Measure.isProbabilityMeasure_map_iff (hL i).aemeasurable).mpr inferInstance⟩ + have hV : Tendsto V atTop (𝓝 (W.prod W)) := hlim x V (fun i => rfl) + let a := fun i => heightPolygon (fun h => (h:ℝ)*θ i-(recordMedian ν ℓ hp f h:ℝ)) (r i) (n i) T + have ha : Tendsto a atTop (𝓝 0) := median_center_error_tendsto ν hue e f hef htrans r hr hT.le + let addPair : RealPathPair × C(unitInterval,ℝ) → RealPathPair := fun z => (z.1.1+z.2,z.1.2+z.2) + have hadd : Continuous addPair := by fun_prop + have hh := weak_map_varying_parameter V (W.prod W) hV a 0 ha addPair hadd + have he0 : (W.prod W).map (fun pair => addPair (pair,0))=W.prod W := by + apply Subtype.ext + change (↑(W.prod W) : Measure RealPathPair).map (fun P => addPair (P,0))=_ + simp only [addPair,add_zero,Prod.eta] + exact Measure.map_id + rw [he0] at hh + apply hh.congr' + filter_upwards [] with i + apply Subtype.ext + change ((η i).map (L i)).map (fun P => addPair (P,a i))=(μ i : Measure RealPathPair) + rw [Measure.map_map (by fun_prop) (hL i),hμ i] + congr 1 + funext P + apply Prod.ext + · exact linear_add_median_error ν ℓ hp f (x i) (θ i) (r i) (n i) T P.1 + · exact linear_add_median_error ν ℓ hp f (x i) (θ i) (r i) (n i) T P.2 + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/StateTrajectory.lean b/lean/OAI/Probability/Ballisticity/Walk/StateTrajectory.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cbee715d8b832e4bcd8cccffd1c5fdf3c4d00f3 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/StateTrajectory.lean @@ -0,0 +1,352 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology + +namespace DirectionalTransience + +instance environmentLaw_probability {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] : IsProbabilityMeasure (environmentLaw ν) := by + unfold environmentLaw + infer_instance + +instance initialLaw_probability {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] : IsProbabilityMeasure (initialLaw ν) := by + unfold initialLaw + infer_instance + +instance annealedLaw_probability {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] : IsProbabilityMeasure (annealedLaw ν) := by + unfold annealedLaw + infer_instance + +lemma environment_site_law {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (x : Lattice d) : + (environmentLaw ν).map (fun ω => ω x) = ν := by + exact (measurePreserving_eval_infinitePi (fun _ : Lattice d => ν) x).map_eq + +lemma environment_uniform_elliptic {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) : + ∃ κ : ℝ≥0, 0 < κ ∧ ∀ᵐ ω ∂environmentLaw ν, ∀ x e, κ ≤ (ω x).1 e := by + obtain ⟨κ, hκ, hrows⟩ := hue + refine ⟨κ, hκ, ae_all_iff.mpr fun x => ?_⟩ + exact (measurePreserving_eval_infinitePi (fun _ : Lattice d => ν) x).quasiMeasurePreserving.ae hrows + +lemma row_entry_le_one {d : ℕ} (p : Row d) (e : Direction d) : p.1 e ≤ 1 := by + calc + p.1 e ≤ ∑ i, p.1 i := Finset.single_le_sum (fun _ _ => zero_le) (Finset.mem_univ e) + _ = 1 := p.2 + +lemma hasVelocity_unique {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {v w : Vector d} (hv : HasVelocity ν v) (hw : HasVelocity ν w) : v = w := by + obtain ⟨X, hXv, hXw⟩ := (hv.and hw).exists + exact tendsto_nhds_unique hXv hXw + +noncomputable def stateTrajectory {d : ℕ} : Kernel (State d) (ℕ → State d) := + (Kernel.traj (historyTransition (d := d)) 0).comap + (fun z _ => z) (Measurable.of_eval fun _ => measurable_id) + +instance stateTrajectory_markov {d : ℕ} : IsMarkovKernel (stateTrajectory (d := d)) := by + unfold stateTrajectory + infer_instance + +noncomputable def quenchedKernel {d : ℕ} : Kernel (State d) (Path d) := + stateTrajectory.map (fun z n => (z n).2) + +instance quenchedKernel_markov {d : ℕ} : IsMarkovKernel (quenchedKernel (d := d)) := by + apply Kernel.IsMarkovKernel.map + exact Measurable.of_eval fun n => measurable_snd.comp (measurable_pi_apply n) + +lemma stateTrajectory_eq {d : ℕ} (μ : Measure (State d)) : + stateTrajectory ∘ₘ μ = Kernel.trajMeasure μ (historyTransition (d := d)) := by + unfold Kernel.trajMeasure stateTrajectory + rw [← Kernel.comp_deterministic_eq_comap, ← Measure.comp_assoc, + Measure.deterministic_comp_eq_map] + rfl + +lemma annealed_eq_quenched_mixture {d : ℕ} (ν : Measure (Row d)) : + annealedLaw ν = quenchedKernel ∘ₘ initialLaw ν := by + unfold annealedLaw quenchedKernel + rw [← stateTrajectory_eq, Measure.map_comp] + exact Measurable.of_eval fun n => measurable_snd.comp (measurable_pi_apply n) + +lemma annealed_apply {d : ℕ} (ν : Measure (Row d)) {A : Set (Path d)} + (hA : MeasurableSet A) : + annealedLaw ν A = ∫⁻ ω, quenchedKernel (ω, (0 : Lattice d)) A ∂environmentLaw ν := by + rw [annealed_eq_quenched_mixture, Measure.bind_apply hA (Kernel.aemeasurable _), + initialLaw, lintegral_map] + · exact Kernel.measurable_coe _ hA + · exact measurable_id.prodMk measurable_const + +lemma environment_translation {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + (z : Lattice d) : + (environmentLaw ν).map (fun ω x => ω (z + x)) = environmentLaw ν := by + apply Measure.map_infinitePi_infinitePi_of_inj + exact add_right_injective z + +lemma stateTrajectory_initial {d : ℕ} (z : State d) : + (stateTrajectory z).map (fun X => X 0) = Measure.dirac z := by + rw [stateTrajectory, Kernel.comap_apply] + have h := Kernel.traj_map_frestrictLe_apply (X := fun _ => State d) + (κ := historyTransition (d := d)) + 0 0 (fun _ => z) + rw [Kernel.partialTraj_self, Kernel.id_apply] at h + have hm : Measurable (fun X : (i : Finset.Iic 0) → State d => + X ⟨0, Finset.mem_Iic.mpr le_rfl⟩) := measurable_pi_apply _ + have := congrArg (fun μ => μ.map + (fun X : (i : Finset.Iic 0) → State d => X ⟨0, Finset.mem_Iic.mpr le_rfl⟩)) h + rw [Measure.map_map hm (Preorder.measurable_frestrictLe 0), Measure.map_dirac' hm] at this + exact this + +lemma quenched_initial {d : ℕ} (z : State d) : + (quenchedKernel z).map (fun X => X 0) = Measure.dirac z.2 := by + have hm : Measurable (fun z : ℕ → State d => fun n => (z n).2) := by fun_prop + rw [quenchedKernel, Kernel.map_apply _ hm, Measure.map_map (measurable_pi_apply 0) hm] + have h := congrArg (fun μ => μ.map Prod.snd) (stateTrajectory_initial z) + rw [Measure.map_map measurable_snd (measurable_pi_apply 0), + Measure.map_dirac' measurable_snd] at h + exact h + +lemma quenched_initial_ae {d : ℕ} (z : State d) : + ∀ᵐ X ∂quenchedKernel z, X 0 = z.2 := by + have h : ∀ᵐ x ∂(quenchedKernel z).map (fun X => X 0), x = z.2 := by + rw [quenched_initial] + exact ae_dirac_iff (measurableSet_singleton _ ) |>.mpr rfl + exact (ae_map_iff (measurable_pi_apply 0).aemeasurable + (measurableSet_singleton _)).mp h + +instance state_measurableEq {d : ℕ} : MeasurableEq (State d) where + measurableSet_diagonal := by + change MeasurableSet {zz : State d × State d | zz.1 = zz.2} + simp only [Prod.ext_iff, Set.ofPred_and] + exact (measurableSet_eq_fun (measurable_fst.comp measurable_fst) + (measurable_fst.comp measurable_snd)).inter + (measurableSet_eq_fun (measurable_snd.comp measurable_fst) + (measurable_snd.comp measurable_snd)) + +instance state_measurableSingleton {d : ℕ} : MeasurableSingletonClass (State d) := by + infer_instance + +def AdmissibleStep {d : ℕ} (z z' : State d) : Prop := + ∃ e : Direction d, z' = (z.1, z.2 + step e) + +lemma measurableSet_admissibleStep {d : ℕ} : + MeasurableSet {zz : State d × State d | AdmissibleStep zz.1 zz.2} := by + simp only [AdmissibleStep, Prod.ext_iff, Set.ofPred_exists, Set.ofPred_and] + apply MeasurableSet.iUnion + intro e + exact (measurableSet_eq_fun (measurable_fst.comp measurable_snd) + (measurable_fst.comp measurable_fst)).inter + (measurableSet_eq_fun (measurable_snd.comp measurable_snd) + ((measurable_snd.comp measurable_fst).add_const (step e))) + +lemma transition_admissible {d : ℕ} (z : State d) : + ∀ᵐ z' ∂transition z, AdmissibleStep z z' := by + change ∀ᵐ z' ∂∑ e : Direction d, + ((z.1 z.2).1 e : ℝ≥0∞) • Measure.dirac (z.1, z.2 + step e), AdmissibleStep z z' + apply ae_finsetSum_measure_iff.mpr + intro e _ + apply Measure.ae_smul_measure + apply (ae_dirac_iff _).mpr + · exact ⟨e, rfl⟩ + · exact measurableSet_admissibleStep.preimage (measurable_const.prodMk measurable_id) + +lemma stateTrajectory_admissible {d : ℕ} (z : State d) : + ∀ᵐ X ∂stateTrajectory z, ∀ n, AdmissibleStep (X n) (X (n + 1)) := by + rw [stateTrajectory, Kernel.comap_apply] + apply ae_all_iff.mpr + intro n + let p := fun zz : ((i : Finset.Iic n) → State d) × State d => + AdmissibleStep (zz.1 ⟨n, Finset.mem_Iic.mpr le_rfl⟩) zz.2 + have hm : Measurable (fun zz : ((i : Finset.Iic n) → State d) × State d => + (zz.1 ⟨n, Finset.mem_Iic.mpr le_rfl⟩, zz.2)) := by fun_prop + have hp : MeasurableSet {zz | p zz} := + measurableSet_admissibleStep.preimage hm + have h : ∀ᵐ zz ∂(Kernel.partialTraj (X := fun _ => State d) (historyTransition (d := d)) 0 n (fun _ => z)) + ⊗ₘ historyTransition (d := d) n, p zz := by + apply Measure.ae_compProd_of_ae_ae hp + exact ae_of_all _ fun x => transition_admissible _ + rw [Kernel.partialTraj_compProd_eq_map_traj (Nat.zero_le n)] at h + exact (ae_map_iff (by fun_prop) hp).mp h + +lemma stateTrajectory_environment {d : ℕ} (z : State d) : + ∀ᵐ X ∂stateTrajectory z, ∀ n, (X n).1 = z.1 := by + have h0 : ∀ᵐ X ∂stateTrajectory z, X 0 = z := by + have h : ∀ᵐ y ∂(stateTrajectory z).map (fun X => X 0), y = z := by + rw [stateTrajectory_initial] + exact (ae_dirac_iff (measurableSet_singleton _)).mpr rfl + exact (ae_map_iff (measurable_pi_apply 0).aemeasurable + (measurableSet_singleton _)).mp h + filter_upwards [h0, stateTrajectory_admissible z] with X hX hstep n + induction n with + | zero => rw [hX] + | succ n ih => + obtain ⟨e, he⟩ := hstep n + rw [he] + exact ih + +lemma quenched_nearest_neighbor {d : ℕ} (z : State d) : + ∀ᵐ X ∂quenchedKernel z, ∀ n, ∃ e : Direction d, X (n + 1) = X n + step e := by + have hm : Measurable (fun z : ℕ → State d => fun n => (z n).2) := by fun_prop + rw [quenchedKernel, Kernel.map_apply _ hm] + apply (ae_map_iff hm.aemeasurable _).mpr + · filter_upwards [stateTrajectory_admissible z] with X hX n + obtain ⟨e, he⟩ := hX n + exact ⟨e, congrArg Prod.snd he⟩ + · simp only [Set.ofPred_forall, Set.ofPred_exists] + apply MeasurableSet.iInter + intro n + apply MeasurableSet.iUnion + intro e + exact measurableSet_eq_fun (measurable_pi_apply _) ((measurable_pi_apply _).add_const _) + +lemma step_injective {d : ℕ} : Function.Injective (step (d := d)) := by + rintro ⟨i, b⟩ ⟨j, c⟩ he + have hij : i = j := by + by_contra hne + have hi := congrFun he i + cases b <;> simp [step, hne] at hi + subst j + have hi := congrFun he i + cases b <;> cases c <;> simp_all [step] + +lemma transition_singleton_step {d : ℕ} (z : State d) (e : Direction d) : + transition z {(z.1, z.2 + step e)} = ((z.1 z.2).1 e : ℝ≥0∞) := by + change (∑ f : Direction d, + ((z.1 z.2).1 f : ℝ≥0∞) • Measure.dirac (z.1, z.2 + step f)) + {(z.1, z.2 + step e)} = _ + simp only [Measure.finsetSum_apply, Measure.smul_apply, smul_eq_mul] + rw [Finset.sum_eq_single e] + · simp + · intro f _ hne + have hh : (z.1, z.2 + step f) ∉ ({(z.1, z.2 + step e)} : Set (State d)) := by + intro he + apply hne + exact step_injective (add_left_cancel (congrArg Prod.snd (Set.mem_singleton_iff.mp he))) + simp [Measure.dirac_apply' _ (measurableSet_singleton _), hh] + · simp + +def stateCylinder {d : ℕ} (f : ℕ → State d) (n : ℕ) : Set (ℕ → State d) := + {X | ∀ i ≤ n, X i = f i} + +lemma measurableSet_stateCylinder {d : ℕ} (f : ℕ → State d) (n : ℕ) : + MeasurableSet (stateCylinder f n) := by + simp only [stateCylinder, Set.ofPred_forall] + exact MeasurableSet.iInter fun i => MeasurableSet.iInter fun _ => + measurableSet_eq_fun (measurable_pi_apply i : Measurable (fun X : ℕ → State d => X i)) + measurable_const + +lemma stateCylinder_eq_preimage {d : ℕ} (f : ℕ → State d) (n : ℕ) : + stateCylinder f n = (fun X : ℕ → State d => Preorder.frestrictLe n X) ⁻¹' {fun i : Finset.Iic n => f i} := by + ext X + simp only [stateCylinder, Set.mem_ofPred_eq, Set.mem_preimage, Set.mem_singleton_iff] + constructor + · intro h + funext i + exact h i (Finset.mem_Iic.mp i.2) + · intro h i hi + exact congrFun h ⟨i, Finset.mem_Iic.mpr hi⟩ + +lemma stateTrajectory_cylinder_succ {d : ℕ} (z : State d) (f : ℕ → State d) (n : ℕ) : + stateTrajectory z (stateCylinder f (n + 1)) = + transition (f n) {f (n + 1)} * stateTrajectory z (stateCylinder f n) := by + rw [stateTrajectory, Kernel.comap_apply] + have h := Kernel.partialTraj_compProd_eq_map_traj (X := fun _ => State d) + (κ := historyTransition (d := d)) (x₀ := fun _ => z) (Nat.zero_le n) + have hm : Measurable (fun X : ℕ → State d => (Preorder.frestrictLe n X, X (n + 1))) := by + fun_prop + have he : (fun X : ℕ → State d => (Preorder.frestrictLe n X, X (n + 1))) ⁻¹' + ({fun i : Finset.Iic n => f i} ×ˢ {f (n + 1)}) = stateCylinder f (n + 1) := by + ext X + simp only [Set.mem_preimage, Set.mem_prod, Set.mem_singleton_iff, + stateCylinder, Set.mem_ofPred_eq] + constructor + · rintro ⟨h₁, h₂⟩ i hi + obtain hi | rfl := Nat.lt_or_eq_of_le hi + · exact congrFun h₁ ⟨i, Finset.mem_Iic.mpr (by omega)⟩ + · exact h₂ + · intro hX + exact ⟨funext fun i => hX i (by have := Finset.mem_Iic.mp i.2; omega), hX _ le_rfl⟩ + have hs := congrArg (fun μ : Measure (((i : Finset.Iic n) → State d) × State d) => + μ ({fun i : Finset.Iic n => f i} ×ˢ {f (n + 1)})) h + rw [Measure.compProd_apply_prod (measurableSet_singleton _) (measurableSet_singleton _), + lintegral_singleton, Measure.map_apply hm + ((measurableSet_singleton _).prod (measurableSet_singleton _)), he] at hs + rw [← hs] + congr 1 + rw [stateCylinder_eq_preimage, ← Measure.map_apply (Preorder.measurable_frestrictLe n) + (measurableSet_singleton _), Kernel.traj_map_frestrictLe_apply] + +lemma stateTrajectory_cylinder {d : ℕ} (z : State d) (f : ℕ → State d) + (hf : f 0 = z) (n : ℕ) : + stateTrajectory z (stateCylinder f n) = + ∏ i ∈ Finset.range n, transition (f i) {f (i + 1)} := by + induction n with + | zero => + have he : stateCylinder f 0 = (fun X : ℕ → State d => X 0) ⁻¹' {z} := by + ext X + simp [stateCylinder, hf] + rw [he, ← Measure.map_apply (measurable_pi_apply 0) (measurableSet_singleton _), + stateTrajectory_initial] + simp + | succ n ih => + rw [stateTrajectory_cylinder_succ, ih, Finset.prod_range_succ, mul_comm] + +abbrev rowSigma {d : ℕ} (S : Set (Lattice d)) : MeasurableSpace (Environment d) := + ⨆ x ∈ S, MeasurableSpace.comap (fun ω : Environment d => ω x) inferInstance + +lemma rowSigma_le {d : ℕ} (S : Set (Lattice d)) : rowSigma S ≤ (inferInstance : MeasurableSpace (Environment d)) := by + exact iSup_le fun x => iSup_le fun _ => (measurable_pi_apply x).comap_le + +lemma measurable_row_on {d : ℕ} {S : Set (Lattice d)} {x : Lattice d} (hx : x ∈ S) : + @Measurable _ _ (rowSigma S) _ (fun ω : Environment d => ω x) := by + apply Measurable.of_comap_le + exact le_iSup_of_le x (le_iSup_of_le hx le_rfl) + +lemma environment_indep_rows {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {S T : Set (Lattice d)} (hST : Disjoint S T) : + Indep (rowSigma S) (rowSigma T) (environmentLaw ν) := by + exact indep_iSup_of_disjoint (fun x => (measurable_pi_apply x).comap_le) + (iIndepFun_infinitePi (P := fun _ : Lattice d => ν) + (X := fun _ p => p) (fun _ => measurable_id)).iIndep hST + +lemma rowSigma_mono {d : ℕ} {S T : Set (Lattice d)} (hST : S ⊆ T) : + rowSigma S ≤ rowSigma T := + iSup₂_le fun x hx => le_iSup_of_le x (le_iSup_of_le (hST hx) le_rfl) + +lemma environment_tail_zero_one {d : ℕ} (ν : Measure (Row d)) [IsProbabilityMeasure ν] + {E : Set (Environment d)} + (hE : ∀ S ∈ (cofinite : Filter (Lattice d)), MeasurableSet[rowSigma S] E) : + environmentLaw ν E = 0 ∨ environmentLaw ν E = 1 := by + let s : Lattice d → MeasurableSpace (Environment d) := fun x => + MeasurableSpace.comap (fun ω : Environment d => ω x) inferInstance + have hind : iIndep s (environmentLaw ν) := + (iIndepFun_infinitePi (P := fun _ : Lattice d => ν) + (X := fun _ p => p) (fun _ => measurable_id)).iIndep + have ht : MeasurableSet[limsup s cofinite] E := by + rw [limsup_eq_iInf_iSup] + apply MeasurableSpace.measurableSet_iInf.mpr + intro S + apply MeasurableSpace.measurableSet_iInf.mpr + exact hE S + apply measure_zero_or_one_of_measurableSet_limsup + (s := s) (p := Set.Finite) (ns := fun F : Finset (Lattice d) => (F : Set (Lattice d))) + (fun x => (measurable_pi_apply x).comap_le) hind + (fun S hS => by simpa only [mem_cofinite, compl_compl] using hS) _ + (fun F => F.finite_toSet) (fun x => ⟨{x}, by simp⟩) ht + intro F G + exact ⟨F ∪ G, Finset.coe_subset.mpr Finset.subset_union_left, + Finset.coe_subset.mpr Finset.subset_union_right⟩ + +end DirectionalTransience +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/StationaryGrowth.lean b/lean/OAI/Probability/Ballisticity/Walk/StationaryGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0f93764996d015c41ee6d18e3b5836f920bd8da --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/StationaryGrowth.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology BigOperators +namespace DirectionalTransience + +noncomputable def orbitAverage {Ω : Type*} (T : Ω → Ω) (f : Ω → ℝ) (n : ℕ) (ω : Ω) : ℝ := + (n:ℝ)⁻¹ * ∑ i∈Finset.range n, f (T^[i] ω) + +lemma orbitAverage_measurable {Ω : Type*} [MeasurableSpace Ω] (T : Ω → Ω) (hT : Measurable T) + (f : Ω → ℝ) (hf : Measurable f) (n : ℕ) : Measurable (orbitAverage T f n) := by + unfold orbitAverage + fun_prop + +lemma orbitAverage_bounds {Ω : Type*} (T : Ω → Ω) (f : Ω → ℝ) + (hf : ∀ ω, f ω∈Set.Icc 0 1) (n : ℕ) (ω : Ω) : orbitAverage T f n ω∈Set.Icc 0 1 := by + refine ⟨mul_nonneg (inv_nonneg.mpr (Nat.cast_nonneg n)) (Finset.sum_nonneg fun i _ => (hf _).1),?_⟩ + by_cases hn : n=0 + · simp [orbitAverage,hn] + calc orbitAverage T f n ω ≤ (n:ℝ)⁻¹*∑ _i∈Finset.range n, (1:ℝ) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun i _ => (hf _).2) (by positivity) + _ = 1 := by simp [hn] + +lemma orbitAverage_integral {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + {T : Ω → Ω} (hT : MeasurePreserving T μ μ) {f : Ω → ℝ} (hf : Integrable f μ) + (n : ℕ) (hn : n≠0) : (∫ ω, orbitAverage T f n ω ∂μ)=∫ ω, f ω ∂μ := by + simp only [orbitAverage] + rw [integral_const_mul,integral_finsetSum (Finset.range n) (fun i _ => (show Integrable (fun ω => f (T^[i] ω)) μ from (hT.iterate i).integrable_comp_of_integrable hf))] + have hi (i : ℕ) : (∫ ω, f (T^[i] ω) ∂μ)=∫ ω, f ω ∂μ := by + have hh := integral_map (hT.iterate i).measurable.aemeasurable + (show AEStronglyMeasurable f (μ.map (T^[i])) from by rw [(hT.iterate i).map_eq]; exact hf.aestronglyMeasurable) + rw [(hT.iterate i).map_eq] at hh + exact hh.symm + simp only [hi] + simp [hn] + +lemma lp_orbitAverage {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + {T : Ω → Ω} (hT : MeasurePreserving T μ μ) (x : Lp ℝ 2 μ) (n : ℕ) : + (birkhoffAverage ℝ (Lp.compMeasurePreservingₗᵢ (E:=ℝ) (p:=2) ℝ T hT).toContinuousLinearMap id n x : Lp ℝ 2 μ) + =ᵐ[μ] orbitAverage T x n := by + let L := (Lp.compMeasurePreservingₗᵢ (E:=ℝ) (p:=2) ℝ T hT).toContinuousLinearMap + have hi (i : ℕ) : (L^[i] x : Lp ℝ 2 μ)=ᵐ[μ] (fun ω => x (T^[i] ω)) := by + change ((Lp.compMeasurePreserving T hT)^[i] x : Lp ℝ 2 μ)=ᵐ[μ] _ + rw [Lp.compMeasurePreserving_iterate] + exact Lp.coeFn_compMeasurePreserving x (hT.iterate i) + have hs := Lp.coeFn_fun_finsetSum (Finset.range n) (fun i => L^[i] x) + have hm := Lp.coeFn_smul ((n:ℝ)⁻¹) (∑ i∈Finset.range n, L^[i] x) + have hall := ae_all_iff.mpr hi + filter_upwards [hs,hm,hall] with ω hs hm hh + change (((n:ℝ)⁻¹ • ∑ i∈Finset.range n, L^[i] x : Lp ℝ 2 μ) : Ω → ℝ) ω=_ + rw [hm] + change (n:ℝ)⁻¹ * _ = _ + rw [hs] + simp only [orbitAverage,hh] + +lemma stationary_bounded_growth_limit {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] {T : Ω → Ω} (hT : MeasurePreserving T μ μ) + (f : Ω → ℝ) (hf : Measurable f) (hb : ∀ ω, f ω∈Set.Icc 0 1) : + ∃ g : Ω → ℝ, Measurable g ∧ (∀ᵐ ω ∂μ, g ω∈Set.Icc 0 1) ∧ + (∀ᵐ ω ∂μ, g (T ω)=g ω) ∧ (∫ ω, g ω ∂μ)=∫ ω, f ω ∂μ ∧ + ∃ ns : ℕ → ℕ, StrictMono ns ∧ + ∀ᵐ ω ∂μ, Tendsto (fun k => orbitAverage T f (ns k) ω) atTop (𝓝 (g ω)) := by + let hfLp : MemLp f 2 μ := memLp_of_bounded (Eventually.of_forall hb) hf.aestronglyMeasurable 2 + let x := hfLp.toLp f + let L := (Lp.compMeasurePreservingₗᵢ (E:=ℝ) (p:=2) ℝ T hT).toContinuousLinearMap + let y := (L.eqLocus (1 : Lp ℝ 2 μ →L[ℝ] Lp ℝ 2 μ)).orthogonalProjectionOnto x + have hy : L (y : Lp ℝ 2 μ)=(y : Lp ℝ 2 μ) := y.property + have hlim := L.tendsto_birkhoffAverage_orthogonalProjection + (Lp.compMeasurePreservingₗᵢ (E:=ℝ) (p:=2) ℝ T hT).norm_toContinuousLinearMap_le x + obtain ⟨ns,hns,hnsLim⟩ := (tendstoInMeasure_of_tendsto_Lp hlim).exists_seq_tendsto_ae + let g := (Lp.aestronglyMeasurable (y : Lp ℝ 2 μ)).mk (y : Lp ℝ 2 μ) + have hgm : Measurable g := (Lp.aestronglyMeasurable (y : Lp ℝ 2 μ)).measurable_mk + have hg : (y : Lp ℝ 2 μ)=ᵐ[μ] g := (Lp.aestronglyMeasurable (y : Lp ℝ 2 μ)).ae_eq_mk + have hall : ∀ᵐ ω ∂μ, ∀ i : ℕ, x (T^[i] ω)=f (T^[i] ω) := + ae_all_iff.mpr fun i => (hT.iterate i).quasiMeasurePreserving.ae hfLp.coeFn_toLp + have hco : ∀ᵐ ω ∂μ, ∀ n : ℕ, + (birkhoffAverage ℝ L id n x : Lp ℝ 2 μ) ω=orbitAverage T f n ω := by + have ha := ae_all_iff.mpr (lp_orbitAverage μ hT x) + filter_upwards [ha,hall] with ω ha hh n + rw [ha n] + simp only [orbitAverage,hh] + have hgLim : ∀ᵐ ω ∂μ, Tendsto (fun k => orbitAverage T f (ns k) ω) atTop (𝓝 (g ω)) := by + filter_upwards [hnsLim,hco,hg] with ω hh hc hg + change Tendsto (fun k => (birkhoffAverage ℝ L id (ns k) x : Lp ℝ 2 μ) ω) atTop (𝓝 ((y : Lp ℝ 2 μ) ω)) at hh + simpa only [hc,hg] using hh + have hgb : ∀ᵐ ω ∂μ, g ω∈Set.Icc 0 1 := hgLim.mono fun ω hh => + isClosed_Icc.mem_of_tendsto hh (Eventually.of_forall fun k => orbitAverage_bounds T f hb _ ω) + have hinv : ∀ᵐ ω ∂μ, g (T ω)=g ω := by + have he := Lp.coeFn_compMeasurePreserving (y : Lp ℝ 2 μ) hT + change ((L (y : Lp ℝ 2 μ) : Lp ℝ 2 μ) : Ω → ℝ)=ᵐ[μ] _ at he + rw [hy] at he + filter_upwards [he,hg,hT.quasiMeasurePreserving.ae hg] with ω he hg hgt + exact hgt.symm.trans (he.symm.trans hg) + have hfi : Integrable f μ := (memLp_of_bounded (Eventually.of_forall hb) hf.aestronglyMeasurable 1).integrable (by rfl) + have hint := tendsto_integral_of_dominated_convergence (fun _ : Ω => (1:ℝ)) + (fun k => (orbitAverage_measurable T hT.measurable f hf (ns k)).aestronglyMeasurable) + (integrable_const 1) (fun k => Eventually.of_forall fun ω => by + rw [Real.norm_eq_abs,abs_of_nonneg (orbitAverage_bounds T f hb (ns k) ω).1] + exact (orbitAverage_bounds T f hb (ns k) ω).2) hgLim + have hevent : ∀ᶠ k in atTop, (∫ ω, orbitAverage T f (ns k) ω ∂μ)=∫ ω, f ω ∂μ := by + filter_upwards [hns.tendsto_atTop.eventually (eventually_ge_atTop 1)] with k hk + exact orbitAverage_integral μ hT hfi _ (by omega) + refine ⟨g,hgm,hgb,hinv,?_,ns,hns,hgLim⟩ + exact tendsto_nhds_unique hint (tendsto_const_nhds.congr' (hevent.mono fun _ h => h.symm)) + +lemma growth_limit_respects_symmetry {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) {T : Ω → Ω} {f g : Ω → ℝ} (ns : ℕ → ℕ) + (hg : ∀ᵐ ω ∂μ, Tendsto (fun k => orbitAverage T f (ns k) ω) atTop (𝓝 (g ω))) + {S : Ω → Ω} (hS : MeasurePreserving S μ μ) + (hcomm : Function.Commute T S) (hfS : ∀ ω, f (S ω)=f ω) : + ∀ᵐ ω ∂μ, g (S ω)=g ω := by + filter_upwards [hg,hS.quasiMeasurePreserving.ae hg] with ω hω hSω + have he (k : ℕ) : orbitAverage T f (ns k) (S ω)=orbitAverage T f (ns k) ω := by + simp only [orbitAverage, (hcomm.iterate_left _).eq, hfS] + exact tendsto_nhds_unique (hSω.congr fun k => he k) hω + +lemma stationary_positive_growth {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] {T : Ω → Ω} (hT : MeasurePreserving T μ μ) + (c : Ω → ℝ) (hc : Measurable c) (hc0 : ∀ ω, 0≤c ω) + (hci : Integrable c μ) (hcp : 0<∫ ω, c ω ∂μ) : + ∃ g : Ω → ℝ, Measurable g ∧ (∀ᵐ ω ∂μ, g ω∈Set.Icc 0 1) ∧ + (∀ᵐ ω ∂μ, g (T ω)=g ω) ∧ ∃ ζ : ℝ, 0<ζ ∧ 0<μ {ω | ζ orbitAverage T (fun ω => min (c ω) 1) (ns k) ω) atTop (𝓝 (g ω))) ∧ + ∀ᵐ ω ∂μ, ζ min (c ω) 1 + have hfm : Measurable f := hc.min measurable_const + have hfb : ∀ ω, f ω∈Set.Icc 0 1 := fun ω => ⟨le_min (hc0 ω) (by norm_num),min_le_right _ _⟩ + have hfi : Integrable f μ := (memLp_of_bounded (Eventually.of_forall hfb) hfm.aestronglyMeasurable 1).integrable (by rfl) + have hfp : 0<∫ ω, f ω ∂μ := by + by_contra hh + have hz := (integral_eq_zero_iff_of_nonneg_ae (Eventually.of_forall fun ω => (hfb ω).1) hfi).mp + (le_antisymm (le_of_not_gt hh) (integral_nonneg fun ω => (hfb ω).1)) + have hcz : c=ᵐ[μ] 0 := hz.mono fun ω hh => by + change min (c ω) 1=0 at hh + change c ω=0 + rcases min_cases (c ω) 1 with h|h + · rw [h.1] at hh; exact hh + · rw [h.1] at hh; norm_num at hh + have hi0 : (∫ ω, c ω ∂μ)=0 := + (integral_eq_zero_iff_of_nonneg_ae (Eventually.of_forall hc0) hci).mpr hcz + linarith + obtain ⟨g,hgm,hgb,hgT,hgi,ns,hns,hlim⟩ := stationary_bounded_growth_limit μ hT f hfm hfb + have hgp : 0<∫ ω, g ω ∂μ := by rw [hgi]; exact hfp + have hex : ∃ ζ : ℝ, 0<ζ ∧ 0<μ {ω | ζ min_le_left _ _) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/TailGrowth.lean b/lean/OAI/Probability/Ballisticity/Walk/TailGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..e279eaeeb08b048a43f4538be16b4fc04517071f --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/TailGrowth.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Probability.Ballisticity.Crossings.TailCuts + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal Topology +namespace TailGrowth + +lemma first_tail_threshold (μ : Measure ℤ) [IsFiniteMeasure μ] {q : ℝ} + (hq : 0 < q) (hqμ : q < μ.real Set.univ) : + ∃ j : ℤ, q ≤ μ.real (Set.Iic j) ∧ μ.real (Set.Iio j) < q := by + have htop : Tendsto (fun j : ℤ => μ.real (Set.Iic j)) atTop (𝓝 (μ.real Set.univ)) := + (ENNReal.tendsto_toReal (measure_ne_top _ _)).comp (tendsto_measure_Iic_atTop μ) + have hbot := TailCuts.lower_tendsto μ + obtain ⟨b,hb⟩ := eventually_atBot.mp (hbot.eventually (gt_mem_nhds hq)) + have hbound : ∃ b : ℤ, ∀ z, q ≤ μ.real (Set.Iic z) → b ≤ z := by + refine ⟨b,fun z hz => ?_⟩ + by_contra h + exact (not_lt_of_ge hz) (hb z (le_of_lt (lt_of_not_ge h))) + have hex : ∃ j : ℤ, q ≤ μ.real (Set.Iic j) := + ((htop.eventually (lt_mem_nhds hqμ)).exists).imp fun j hj => hj.le + obtain ⟨j,hj,hmin⟩ := Int.exists_least_of_bdd hbound hex + refine ⟨j,hj,?_⟩ + have he : Set.Iio j = Set.Iic (j-1) := by ext z; simp only [Set.mem_Iio,Set.mem_Iic]; omega + rw [he] + by_contra h + have := hmin (j-1) (le_of_not_gt h) + omega + +lemma ordered_pair_common_cut (μ ν : Measure ℤ) [IsFiniteMeasure μ] [IsFiniteMeasure ν] + (hμ : μ.real Set.univ ≤ 1) (hν : ν.real Set.univ ≤ 1) + (R : ℤ) {q : ℝ} (hq : 0 < q) + (hpair : q ≤ (μ.prod ν).real {p | p.1 + R ≤ p.2}) : + ∃ j : ℤ, q / 2 ≤ μ.real (Set.Iic j) ∧ q / 2 ≤ ν.real (Set.Ici (j+R)) := by + have hqμ : q ≤ μ.real Set.univ := by + calc + q ≤ (μ.prod ν).real {p | p.1 + R ≤ p.2} := hpair + _ ≤ (μ.prod ν).real (Set.univ ×ˢ Set.univ) := + measureReal_mono (by intro p hp; exact ⟨Set.mem_univ _,Set.mem_univ _⟩) (measure_ne_top _ _) + _ = μ.real Set.univ * ν.real Set.univ := measureReal_prod_prod _ _ + _ ≤ μ.real Set.univ * 1 := mul_le_mul_of_nonneg_left hν (measureReal_nonneg) + _ = μ.real Set.univ := mul_one _ + obtain ⟨j,hj,hprev⟩ := first_tail_threshold μ (by linarith : 0 < q/2) (by linarith : q/2 < μ.real Set.univ) + refine ⟨j,hj,?_⟩ + by_contra hh + have hh' : ν.real (Set.Ici (j+R)) < q/2 := lt_of_not_ge hh + have hsub : {p : ℤ × ℤ | p.1 + R ≤ p.2} ⊆ + (Set.Iio j ×ˢ Set.univ) ∪ (Set.univ ×ˢ Set.Ici (j+R)) := by + intro p hp + by_cases hx : p.1 < j + · exact Or.inl ⟨hx,Set.mem_univ _⟩ + · exact Or.inr ⟨Set.mem_univ _,by change j+R ≤ p.2; dsimp at hp; omega⟩ + have hle : q ≤ μ.real (Set.Iio j) + ν.real (Set.Ici (j+R)) := by + calc + q ≤ (μ.prod ν).real {p | p.1+R ≤ p.2} := hpair + _ ≤ (μ.prod ν).real ((Set.Iio j ×ˢ Set.univ) ∪ (Set.univ ×ˢ Set.Ici (j+R))) := + measureReal_mono hsub (measure_ne_top _ _) + _ ≤ (μ.prod ν).real (Set.Iio j ×ˢ Set.univ) + + (μ.prod ν).real (Set.univ ×ˢ Set.Ici (j+R)) := measureReal_union_le _ _ + _ = μ.real (Set.Iio j) * ν.real Set.univ + μ.real Set.univ * ν.real (Set.Ici (j+R)) := by + rw [measureReal_prod_prod,measureReal_prod_prod] + _ ≤ μ.real (Set.Iio j) * 1 + 1 * ν.real (Set.Ici (j+R)) := + add_le_add (mul_le_mul_of_nonneg_left hν measureReal_nonneg) + (mul_le_mul_of_nonneg_right hμ measureReal_nonneg) + _ = μ.real (Set.Iio j) + ν.real (Set.Ici (j+R)) := by ring + linarith + +noncomputable def statistic (μ : Measure ℤ) (R : ℤ) : ℝ := + ⨆ j : ℤ, TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R j + +lemma score_bddAbove (μ : Measure ℤ) [IsFiniteMeasure μ] (R : ℤ) : + BddAbove (Set.range (TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R)) := by + refine ⟨μ.real Set.univ,?_⟩ + rintro _ ⟨j,rfl⟩ + exact (min_le_left _ _).trans (measureReal_mono (Set.subset_univ _) (measure_ne_top _ _)) + +lemma score_le_statistic (μ : Measure ℤ) [IsFiniteMeasure μ] (R j : ℤ) : + TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R j ≤ statistic μ R := + le_ciSup (score_bddAbove μ R) j + +lemma statistic_le_mass (μ : Measure ℤ) [IsFiniteMeasure μ] (R : ℤ) : + statistic μ R ≤ μ.real Set.univ := by + apply ciSup_le + intro j + exact (min_le_left _ _).trans (measureReal_mono (Set.subset_univ _) (measure_ne_top _ _)) + +lemma statistic_pos (μ : Measure ℤ) [IsFiniteMeasure μ] + (hfull : ∀ j, 0 < μ.real {j}) (R : ℤ) : 0 < statistic μ R := by + apply lt_of_lt_of_le _ (score_le_statistic μ R 0) + exact lt_min (TailCuts.lower_pos μ hfull _) (TailCuts.upper_pos μ hfull _) + +lemma statistic_eq_max (μ : Measure ℤ) [IsFiniteMeasure μ] (R j : ℤ) + (hj : ∀ k, TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R k ≤ + TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R j) : + statistic μ R = TailCuts.score (TailCuts.lower μ) (TailCuts.upper μ) R j := by + exact le_antisymm (ciSup_le hj) (score_le_statistic μ R j) + +lemma statistic_grows (μ ν w' : Measure ℤ) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] [IsFiniteMeasure w'] + (hμ : μ.real Set.univ ≤ 1) (hν : ν.real Set.univ ≤ 1) + (R : ℤ) {q t : ℝ} (hq : 0 < q) (ht : 0 ≤ t) + (hpair : q ≤ (μ.prod ν).real {p | p.1+R ≤ p.2}) + (hleft : ∀ j, t * μ.real (Set.Iic j) ≤ w'.real (Set.Iic j)) + (hright : ∀ j, t * ν.real (Set.Ici j) ≤ w'.real (Set.Ici j)) : + t * q / 2 ≤ statistic w' R := by + obtain ⟨j,hj,hj'⟩ := ordered_pair_common_cut μ ν hμ hν R hq hpair + apply le_trans _ (score_le_statistic w' R j) + change t*q/2 ≤ min _ _ + exact le_min (by simpa [mul_div_assoc, TailCuts.lower, TailCuts.upper] using (mul_le_mul_of_nonneg_left hj ht).trans (hleft j)) + (by simpa [mul_div_assoc, TailCuts.lower, TailCuts.upper] using (mul_le_mul_of_nonneg_left hj' ht).trans (hright (j+R))) + +lemma log_statistic_grows (μ ν w w' : Measure ℤ) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] [IsFiniteMeasure w] [IsFiniteMeasure w'] + (hμ : μ.real Set.univ ≤ 1) (hν : ν.real Set.univ ≤ 1) + (R : ℤ) {Q C a Z : ℝ} (hw : 0 < statistic w R) (hQ : 0 < Q) + (hpair : Q ≤ (μ.prod ν).real {p | p.1+R ≤ p.2}) + (hlog : -a-Z ≤ Real.log Q) + (hleft : ∀ j, (Real.exp C * statistic w R) * μ.real (Set.Iic j) ≤ w'.real (Set.Iic j)) + (hright : ∀ j, (Real.exp C * statistic w R) * ν.real (Set.Ici j) ≤ w'.real (Set.Ici j)) : + C-a-Z-Real.log 2 ≤ Real.log (statistic w' R) - Real.log (statistic w R) := by + have ht := mul_pos (Real.exp_pos C) hw + have hg := statistic_grows μ ν w' hμ hν R hQ ht.le hpair hleft hright + have hp : 0 < Real.exp C * statistic w R * Q / 2 := + div_pos (mul_pos ht hQ) (by norm_num) + have hh := Real.log_le_log hp hg + rw [Real.log_div (ne_of_gt (mul_pos ht hQ)) (by norm_num : (2 : ℝ) ≠ 0), + Real.log_mul (ne_of_gt ht) (ne_of_gt hQ), + Real.log_mul (ne_of_gt (Real.exp_pos C)) (ne_of_gt hw), Real.log_exp] at hh + linarith + +end TailGrowth + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/TransverseFirstHitSinglePathLimit.lean b/lean/OAI/Probability/Ballisticity/Walk/TransverseFirstHitSinglePathLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..78fa4ed6a04ebc46b85ba2d5a112af3b44291731 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/TransverseFirstHitSinglePathLimit.lean @@ -0,0 +1,125 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.GaussianPathFiniteLawSmul + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +theorem transverse_firstHit_single_path_limit {d : ℕ} (ν : Measure (Row d)) + [IsProbabilityMeasure ν] (hue : UniformElliptic ν) (e f : Direction d) (hef : e.1 ≠ f.1) + (htrans : DirectionallyTransient ν (realPosition (step e))) + (r : ℕ → ℝ) (hr : IsGaussianSequence (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) r) {T : ℝ} (hT : 0 ≤ T) : + let hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν (realPosition (step e)) htrans) + letI : IsProbabilityMeasure (conditionedLaw ν (realPosition (step e))) := + conditionedLaw_probability ν _ hp + ∃ W : ProbabilityMeasure C(unitInterval,ℝ), + TendstoInDistribution (fun i X => heightPolygon + (fun h => signedCoordinate f (recordIndexPosition (realPosition (step e)) h X)- + (recordMedian ν (realPosition (step e)) hp f h : ℝ)) (r i) + (fluctuationScale (independentConditionedPairLaw ν (realPosition (step e))) + (commonIncrementProcess (realPosition (step e)) f 0) (r i)) T) + atTop id (fun _ => conditionedLaw ν (realPosition (step e))) W ∧ + ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw (T/(2*commonMeanWidth ν (realPosition (step e)))) I := by + let ℓ := realPosition (step e) + let μ := conditionedLaw ν ℓ + have hp := ne_of_gt (noDrop_positive_of_directionallyTransient ν ℓ htrans) + let : IsProbabilityMeasure μ := conditionedLaw_probability ν ℓ hp + let : IsProbabilityMeasure (independentConditionedPairLaw ν ℓ) := + independentConditionedPairLaw_probability ν ℓ hp + let F := fun h X => signedCoordinate f (recordIndexPosition ℓ h X) + have hF (h : ℕ) : Measurable (F h) := + (measurable_of_countable (signedCoordinate f)).comp (measurable_recordIndexPosition ℓ h) + let n := fun i => fluctuationScale (independentConditionedPairLaw ν ℓ) (commonIncrementProcess ℓ f 0) (r i) + have hi := independent_commonWordIncrement_integrable ν hue ℓ (signed_direction_unit e) + htrans (signedHeight e) (signedHeight_projection e) (signedHeight_step_le e) f + have hne := independent_commonWordIncrement_nonzero ν hue e f hef htrans + have hn : Tendsto n atTop atTop := (fluctuationScale_tendsto _ _ + (measurable_commonIncrementProcess ℓ f 0) hi hne).comp hr.1 + apply height_median_path_limit μ F hF (fun h => (recordMedian ν ℓ hp f h : ℝ)) + (recordMedian_spec ν ℓ hp f) r n (fun _ => fluctuationScale_nonneg _ _ _) + hn (commonMeanWidth ν ℓ) _ hT + intro S hS + obtain ⟨W,hW,hWf⟩ := transverse_firstHit_path_limit ν hue e f hef htrans r hr hS + refine ⟨W,?_,hWf⟩ + have h0 : ∀ᵐ P ∂independentConditionedPairLaw ν ℓ, firstHitPairGap ℓ f 0 P = 0 := by + have hx := (conditionedLaw_absolutelyContinuous ν ℓ).ae_le (annealed_initial ν) + filter_upwards [Measure.quasiMeasurePreserving_fst.ae hx, + Measure.quasiMeasurePreserving_snd.ae hx] with P hP1 hP2 + simp [firstHitPairGap,recordIndexPosition,recordIndexTime_zero,hP1,hP2] + have he (i : ℕ) : ((heightPathLaw μ F hF (r i) (n i) S).prod + (heightPathLaw μ F hF (r i) (n i) S)).map + (fun paths => paths.1 - paths.2) = + (⟨(independentConditionedPairLaw ν ℓ).map (fun P => scaledPolygon + (heightIncrement (fun h => firstHitPairGap ℓ f h P)) (r i) (n i) S), + inferInstance⟩ : ProbabilityMeasure C(unitInterval,ℝ)) := by + apply Subtype.ext + change ((heightPathLaw μ F hF (r i) (n i) S : Measure C(unitInterval,ℝ)).prod + (heightPathLaw μ F hF (r i) (n i) S : Measure C(unitInterval,ℝ))).map + (fun p => p.1-p.2) = _ + rw [heightPathLaw_iid_difference] + apply Measure.map_congr + filter_upwards [h0] with P hP + change heightPolygon (fun h => firstHitPairGap ℓ f h P) (r i) (n i) S = _ + simp [heightPolygon,hP] + have hId : (⟨(W : Measure C(unitInterval,ℝ)).map id, + inferInstance⟩ : ProbabilityMeasure C(unitInterval,ℝ)) = W := by + apply Subtype.ext + exact Measure.map_id + have h := hW.tendsto + rw [hId] at h + simpa only [he] using h + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/UniformFinsetKernel.lean b/lean/OAI/Probability/Ballisticity/Walk/UniformFinsetKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec1c7bbf44a973737f6b6b5a039086f7ba9093ae --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/UniformFinsetKernel.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Probability.Ballisticity.Model + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal Classical BigOperators +namespace DirectionalTransience + +lemma uniformFinset_eq {B : Type*} [MeasurableSpace B] [Countable B] + [MeasurableSingletonClass B] (s : Finset B) (hs : s.Nonempty) : + (PMF.uniformOfFinset s hs).toMeasure = (s.card:ℝ≥0∞)⁻¹ • ∑ b∈s, Measure.dirac b := by + apply Measure.ext_of_singleton + intro b + rw [PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton b),PMF.uniformOfFinset_apply, + Measure.smul_apply,Measure.finsetSum_apply] + simp only [Measure.dirac_apply' _ (measurableSet_singleton b),smul_eq_mul] + by_cases hb : b∈s + · simp [hb] + · simp [hb] + +lemma uniformFinset_map {B C : Type*} [MeasurableSpace B] [MeasurableSpace C] + [Countable B] [Countable C] [MeasurableSingletonClass B] [MeasurableSingletonClass C] + (s : Finset B) (t : Finset C) (hs : s.Nonempty) (ht : t.Nonempty) (f : B → C) + (hi : Set.InjOn f s) (he : s.image f=t) : + ((PMF.uniformOfFinset s hs).toMeasure).map f=(PMF.uniformOfFinset t ht).toMeasure := by + have hc : s.card=t.card := by rw [←he,Finset.card_image_iff.mpr hi] + rw [uniformFinset_eq s hs,uniformFinset_eq t ht, + Measure.map_smul _ (measurable_of_countable f).aemeasurable, + Measure.map_finset_sum (measurable_of_countable f).aemeasurable,hc] + simp only [Measure.map_dirac] + congr 1 + rw [←he,Finset.sum_image hi] + +noncomputable def nonemptyFinsetKernel {B : Type*} [MeasurableSpace B] + [Countable B] [MeasurableSingletonClass B] : Kernel {t : Finset B | t.Nonempty} B := + Kernel.ofFunOfCountable (fun t => (PMF.uniformOfFinset t.1 t.2).toMeasure) + +noncomputable def uniformFinsetKernel {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable B] [MeasurableSingletonClass B] (s : A → Finset B) + (hm : Measurable s) (hs : ∀ a, (s a).Nonempty) : Kernel A B := + nonemptyFinsetKernel.comap (fun a => ⟨s a,hs a⟩) (hm.subtype_mk (h := hs)) + +instance uniformFinsetKernel_markov {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable B] [MeasurableSingletonClass B] (s : A → Finset B) + (hm : Measurable s) (hs : ∀ a, (s a).Nonempty) : + IsMarkovKernel (uniformFinsetKernel s hm hs) where + isProbabilityMeasure a := by change IsProbabilityMeasure (PMF.uniformOfFinset (s a) (hs a)).toMeasure; infer_instance + +lemma uniformFinsetKernel_supported {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] + [Countable B] [MeasurableSingletonClass B] (s : A → Finset B) + (hm : Measurable s) (hs : ∀ a, (s a).Nonempty) (a : A) : + ∀ᵐ b ∂uniformFinsetKernel s hm hs a, b∈s a := by + rw [ae_iff] + change (PMF.uniformOfFinset (s a) (hs a)).toMeasure {b | b∉s a}=0 + rw [PMF.toMeasure_uniformOfFinset_apply (hs a) _ (Set.to_countable _).measurableSet] + simp + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/UpperKernel.lean b/lean/OAI/Probability/Ballisticity/Walk/UpperKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..3646d31855c1d5078aac4cd648da447f7e281a5b --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/UpperKernel.lean @@ -0,0 +1,225 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.GlobalProfile + +namespace OAI + +section + +open MeasureTheory ProbabilityTheory TopologicalSpace +open scoped ENNReal NNReal Classical Topology +namespace DirectionalTransience + +abbrev UpperRows {d : ℕ} (e : Direction d) := (ℕ×HorizontalSpace e) → Row d + +noncomputable def upperEnvironment {d : ℕ} (e : Direction d) (ξ : UpperRows e) : Environment d := + fun x => ξ ((signedHeight e x).toNat,horizontalProjection e x) + +lemma upperEnvironment_continuous {d : ℕ} (e : Direction d) : Continuous (upperEnvironment e) := by + unfold upperEnvironment + fun_prop + +lemma upperEnvironment_lift {d : ℕ} (e : Direction d) (ξ : UpperRows e) + (l : ℕ) (z : HorizontalSpace e) : + upperEnvironment e ξ (horizontalLift e l z)=ξ (l,z) := by + simp only [upperEnvironment,signedHeight_horizontalLift,horizontalProjection_lift,Int.toNat_natCast] + +lemma continuous_wordWeight {d : ℕ} (x : Lattice d) (w : List (Direction d)) : + Continuous (fun ω : Environment d => wordWeight ω x w) := by + induction w generalizing x with + | nil => exact continuous_const + | cons u w ih => + change Continuous (fun ω : Environment d => ((ω x).1 u:ℝ)*wordWeight ω (x+step u) w) + exact (NNReal.continuous_coe.comp ((continuous_apply u).comp (continuous_subtype_val.comp (continuous_apply x)))).mul (ih _) + +lemma hitKernel_eq_tsum_words {d : ℕ} (ω : Environment d) (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) (A : Set (Lattice d)) : + hitKernel S T (ω,x) A = + ∑' w : {w : HitWord x S T // wordPath x w.val w.val.length∈A}, + ENNReal.ofReal (wordWeight ω x w.val.val) := by + rw [←successfulWordLaw_endpoint ω x S T hST, + Measure.map_apply (measurable_of_countable _) (Set.to_countable A).measurableSet, + successfulWordLaw_apply] + rfl + +lemma hitKernel_lowerSemicontinuous {d : ℕ} (x : Lattice d) + (S T : Set (Lattice d)) (hST : Disjoint S T) (A : Set (Lattice d)) : + LowerSemicontinuous (fun ω : Environment d => hitKernel S T (ω,x) A) := by + simp_rw [hitKernel_eq_tsum_words _ x S T hST A] + exact lowerSemicontinuous_tsum fun w => + (ENNReal.continuous_ofReal.comp (continuous_wordWeight x w.val.val)).lowerSemicontinuous + +noncomputable def upperHorizontalKernel {d : ℕ} (e : Direction d) (H : ℕ) (ξ : UpperRows e) : + Kernel (HorizontalSpace e) (HorizontalSpace e) := + Kernel.mk (fun z => (variableHitKernel (realPosition (step e)) H (upperEnvironment e ξ,horizontalLift e 0 z)).map + (horizontalProjection e)) (measurable_of_countable _) + +lemma upperHorizontalKernel_apply {d : ℕ} (e : Direction d) (H : ℕ) (ξ : UpperRows e) + (z : HorizontalSpace e) (A : Set (HorizontalSpace e)) : + upperHorizontalKernel e H ξ z A = + hitKernel (Strip (realPosition (step e)) (horizontalLift e 0 z) H) + (Upper (realPosition (step e)) (horizontalLift e 0 z) H) + (upperEnvironment e ξ,horizontalLift e 0 z) (horizontalProjection e ⁻¹' A) := by + rw [upperHorizontalKernel,Kernel.coe_mk,Measure.map_apply (measurable_of_countable _) (Set.to_countable A).measurableSet] + rfl + +lemma upperHorizontalKernel_lowerSemicontinuous {d : ℕ} (e : Direction d) (H : ℕ) + (z : HorizontalSpace e) (A : Set (HorizontalSpace e)) : + LowerSemicontinuous (fun ξ : UpperRows e => upperHorizontalKernel e H ξ z A) := by + simp_rw [upperHorizontalKernel_apply] + exact (hitKernel_lowerSemicontinuous _ _ _ (disjoint_strip_upper _ _ _) _).comp + (upperEnvironment_continuous e) + +lemma upperHorizontalKernel_mass_le_one {d : ℕ} (e : Direction d) (H : ℕ) (ξ : UpperRows e) + (z : HorizontalSpace e) : upperHorizontalKernel e H ξ z Set.univ ≤ 1 := by + rw [upperHorizontalKernel_apply,Set.preimage_univ] + exact hitKernel_total_le_one (disjoint_strip_upper _ _ _) _ + +end DirectionalTransience + +end + +section + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal Classical BigOperators +namespace DirectionalTransience + +lemma wordPath_endpoint_sum {d : ℕ} (x : Lattice d) (w : List (Direction d)) : + wordPath x w w.length=x+(w.map step).sum := by + induction w generalizing x with + | nil => simp [wordPath] + | cons u w ih => simp [wordPath,ih,add_assoc] + +lemma wordPath_replicate_min {d : ℕ} (x : Lattice d) (u : Direction d) (k n : ℕ) : + wordPath x (List.replicate k u) n=x+(min n k:ℕ) • step u := by + induction k generalizing x n with + | zero => simp [wordPath] + | succ k ih => + cases n with + | zero => simp + | succ n => + rw [List.replicate_succ,wordPath,ih,min_add_add_right,succ_nsmul] + abel + +lemma exists_horizontal_word {d : ℕ} (e : Direction d) (z : HorizontalSpace e) : + ∃ w : List (Direction d), (w.map step).sum=z.val ∧ ∀ u∈w, u.1≠e.1 := by + have hsingle (i : Fin d) : ∃ w : List (Direction d), + (w.map step).sum=Pi.single i (z.val i) ∧ ∀ u∈w, u.1≠e.1 := by + by_cases hi : i=e.1 + · subst i + refine ⟨[],?_,by simp⟩ + have hz : z.val e.1=0 := z.property + simp [hz] + · cases hz : z.val i with + | ofNat n => + refine ⟨List.replicate n (i,true),?_,?_⟩ + · simp only [List.map_replicate,List.sum_replicate] + funext j + by_cases hj : j=i + · subst j; simp [step] + · simp [step,hj] + · intro u hu + have he := List.eq_of_mem_replicate hu + simpa only [he] using hi + | negSucc n => + refine ⟨List.replicate (n+1) (i,false),?_,?_⟩ + · simp only [List.map_replicate,List.sum_replicate] + funext j + by_cases hj : j=i + · subst j; simp [step]; omega + · simp [step,hj] + · intro u hu + have he := List.eq_of_mem_replicate hu + simpa only [he] using hi + have hf (s : Finset (Fin d)) : ∃ w : List (Direction d), + (w.map step).sum=∑ i∈s, Pi.single i (z.val i) ∧ ∀ u∈w, u.1≠e.1 := by + induction s using Finset.induction_on with + | empty => exact ⟨[],by simp,by simp⟩ + | @insert i s hi ih => + obtain ⟨v,hv,hve⟩ := hsingle i + obtain ⟨w,hw,hwe⟩ := ih + refine ⟨v++w,by simp [hv,hw,hi],?_⟩ + intro u hu + rcases List.mem_append.mp hu with hu|hu + · exact hve u hu + · exact hwe u hu + obtain ⟨w,hw,hwe⟩ := hf Finset.univ + refine ⟨w,hw.trans ?_,hwe⟩ + funext j + simp + +lemma wordPath_horizontal {d : ℕ} (e : Direction d) (x : Lattice d) + (w : List (Direction d)) (hw : ∀ u∈w, u.1≠e.1) (n : ℕ) : + signedHeight e (wordPath x w n)=signedHeight e x := by + induction w generalizing x n with + | nil => rfl + | cons u w ih => + cases n with + | zero => rfl + | succ n => + rw [wordPath,ih (x+step u) (fun g hg => hw g (by simp [hg]))] + have hu := hw u (by simp) + rw [signedHeight_add] + simp [signedHeight, step,Ne.symm hu] + +lemma positive_wordWeight {d : ℕ} (ω : Environment d) + (hω : ∀ x u, 0<(ω x).val u) (x : Lattice d) (w : List (Direction d)) : + 0 norm_num [wordWeight] + | cons u w ih => + exact mul_pos (NNReal.coe_pos.mpr (hω x u)) (ih _) + +lemma upperHorizontalKernel_pos {d : ℕ} (e : Direction d) (H : ℕ) (hH : 0 hξ _ u) (horizontalLift e 0 x) w)) + (ENNReal.le_tsum (f := fun term => ENNReal.ofReal + (wordWeight (upperEnvironment e ξ) (horizontalLift e 0 x) term.val.val)) a) + +end DirectionalTransience + +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/VaryingHeightPathGaussianEval.lean b/lean/OAI/Probability/Ballisticity/Walk/VaryingHeightPathGaussianEval.lean new file mode 100644 index 0000000000000000000000000000000000000000..235d74c00cb53653b1f9ea8ff9af29c7ab42fcfc --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/VaryingHeightPathGaussianEval.lean @@ -0,0 +1,190 @@ +import Mathlib +import OAI.Probability.Ballisticity.Walk.GaussianPathFiniteLawSingleton + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical BoundedContinuousFunction +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma varying_height_path_gaussian_eval {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] (F : ℕ → ℕ → Ω → ℝ) + (hF : ∀ i h, Measurable (F i h)) (r n : ℕ → ℝ) (hn : ∀ i, 0 < n i) + (T : ℝ) (hT : 0 < T) (V : ℝ) (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : TendstoInDistribution (fun i x => heightPolygon (fun h => F i h x) (r i) (n i) T) + atTop id μ W) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = gaussianPathFiniteLaw (T*V) I) + (k : ℕ → ℕ) (hkn : ∀ i, (k i : ℝ) ≤ T*n i) {s : ℝ} + (hs : Tendsto (fun i => (k i : ℝ)/n i) atTop (𝓝 s)) : + TendstoInDistribution (fun i x => F i (k i) x/r i) atTop id μ + (gaussianReal 0 (Real.toNNReal (V*s))) := by + have hs0 : 0 ≤ s := le_of_tendsto_of_tendsto tendsto_const_nhds hs + (Eventually.of_forall fun i => div_nonneg (Nat.cast_nonneg _) (hn i).le) + have hsT : s ≤ T := le_of_tendsto_of_tendsto hs tendsto_const_nhds + (Eventually.of_forall fun i => (div_le_iff₀ (hn i)).mpr (hkn i)) + let t : ℕ → unitInterval := fun i => ⟨(k i:ℝ)/(T*n i), + div_nonneg (Nat.cast_nonneg _) (mul_pos hT (hn i)).le, + (div_le_one (mul_pos hT (hn i))).mpr (hkn i)⟩ + let u : unitInterval := ⟨s/T,div_nonneg hs0 hT.le,(div_le_one hT).mpr hsT⟩ + have ht : Tendsto t atTop (𝓝 u) := by + apply tendsto_subtype_rng.mpr + change Tendsto (fun i => (k i:ℝ)/(T*n i)) atTop (𝓝 (s/T)) + convert hs.div_const T using 1 + funext i + ring + let P : ℕ → ProbabilityMeasure C(unitInterval,ℝ) := fun i => + ⟨(μ i).map (fun x => heightPolygon (fun h => F i h x) (r i) (n i) T), + inferInstance⟩ + have hP : Tendsto P atTop (𝓝 W) := by + have hh := hlim.tendsto + have hid : (⟨(W : Measure C(unitInterval,ℝ)).map id, + inferInstance⟩ : ProbabilityMeasure C(unitInterval,ℝ)) = W := + Subtype.ext Measure.map_id + rw [hid] at hh + exact hh + have hev := weak_path_eval_tendsto hP ht + have hwm : W.map (fun path => path u) = + (⟨gaussianReal 0 (Real.toNNReal (V*s)),inferInstance⟩ : ProbabilityMeasure ℝ) := by + apply Subtype.ext + change (W : Measure C(unitInterval,ℝ)).map (fun g => g u) = _ + rw [wiener_path_eval W (T*V) hW] + congr 2 + change (T*V)*(s/T) = V*s + field_simp + rw [hwm] at hev + refine ⟨fun i => ((hF i (k i)).div_const _).aemeasurable,measurable_id.aemeasurable,?_⟩ + have he (i : ℕ) : (P i).map (fun path => path (t i)) = + (⟨(μ i).map (fun x => F i (k i) x/r i),inferInstance⟩ : ProbabilityMeasure ℝ) := by + apply Subtype.ext + change ((μ i).map (fun x => heightPolygon (fun h => F i h x) (r i) (n i) T)).map (fun g => g (t i)) = _ + rw [Measure.map_map (continuous_eval_const (t i)).measurable (measurable_heightPolygon (F i) (hF i) _ _ _)] + congr 1 + funext x + exact heightPolygon_grid _ _ _ _ (mul_pos hT (hn i)).le (k i) (t i) + (by change T*n i*((k i:ℝ)/(T*n i)) = _; field_simp [hT.ne',(hn i).ne']) + simpa only [he,Measure.map_id] using hev + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/WeakPathEvalTendsto.lean b/lean/OAI/Probability/Ballisticity/Walk/WeakPathEvalTendsto.lean new file mode 100644 index 0000000000000000000000000000000000000000..39c8de8c3f053b4041841228b6ad48d72d925f48 --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/WeakPathEvalTendsto.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.IidDifferenceCenteredHalf + +namespace OAI + +section +section +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Pointwise Classical +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical +namespace DirectionalTransience + +lemma weak_path_eval_tendsto {μ : ℕ → ProbabilityMeasure C(unitInterval,ℝ)} + {ν : ProbabilityMeasure C(unitInterval,ℝ)} (hμ : Tendsto μ atTop (𝓝 ν)) + {t : ℕ → unitInterval} {s : unitInterval} (ht : Tendsto t atTop (𝓝 s)) : + Tendsto (fun n => (μ n).map (fun path => path (t n))) + atTop (𝓝 (ν.map (fun path => path s))) := by + have he : Continuous (fun p : C(unitInterval,ℝ) × unitInterval => p.1 p.2) := continuous_eval + have hh := (ProbabilityMeasure.continuous_map he).tendsto + (ν.prod (diracProba s)) |>.comp + (ProbabilityMeasure.continuous_prod.tendsto (ν,diracProba s) |>.comp + (hμ.prodMk_nhds (continuous_diracProba.tendsto s |>.comp ht))) + have hid (V : ProbabilityMeasure C(unitInterval,ℝ)) (u : unitInterval) : + (V.prod (diracProba u)).map (fun pair => pair.1 pair.2) = + V.map (fun path => path u) := by + apply Subtype.ext + change ((V : Measure C(unitInterval,ℝ)).prod (Measure.dirac u)).map _ = _ + rw [Measure.prod_dirac,Measure.map_map he.measurable (by fun_prop)] + rfl + change Tendsto (fun n => ((μ n).prod (diracProba (t n))).map (fun pair => pair.1 pair.2)) + atTop (𝓝 ((ν.prod (diracProba s)).map (fun pair => pair.1 pair.2))) at hh + simpa only [hid] using hh + +lemma gaussian_median_nonstrict (m : ℝ) (v : ℝ≥0) : + (1/2 : ℝ≥0∞) ≤ gaussianReal m v (Set.Iic m) ∧ + (1/2 : ℝ≥0∞) ≤ gaussianReal m v (Set.Ici m) := by + by_cases hv : v = 0 + · subst v; simp [gaussianReal_zero_var] + · exact ⟨(gaussian_median_half m v hv).1.ge,(gaussian_median_half m v hv).2.ge⟩ + +lemma continuous_gaussian_path_mean (G : ProbabilityMeasure C(unitInterval,ℝ)) + (m : unitInterval → ℝ) (v : unitInterval → ℝ≥0) + (hg : ∀ t, (G : Measure C(unitInterval,ℝ)).map (fun g => g t) = gaussianReal (m t) (v t)) : + Continuous m := by + apply continuous_iff_seqContinuous.mpr + intro t s ht + apply median_tendsto_of_weak (weak_path_eval_tendsto tendsto_const_nhds ht) + · intro n + change (1/2 : ℝ≥0∞) ≤ ((G : Measure C(unitInterval,ℝ)).map (fun g => g (t n))) (Set.Iic (m (t n))) ∧ + (1/2 : ℝ≥0∞) ≤ ((G : Measure C(unitInterval,ℝ)).map (fun g => g (t n))) (Set.Ici (m (t n))) + rw [hg] + exact gaussian_median_nonstrict _ _ + · intro ε hε + change (1/2 : ℝ≥0∞) < ((G : Measure C(unitInterval,ℝ)).map (fun g => g s)) (Set.Iio (m s+ε)) ∧ + (1/2 : ℝ≥0∞) < ((G : Measure C(unitInterval,ℝ)).map (fun g => g s)) (Set.Ioi (m s-ε)) + rw [hg] + exact gaussian_median_strict _ _ hε + +lemma weak_path_grid_medians_uniform {μ : ℕ → ProbabilityMeasure C(unitInterval,ℝ)} + {G : ProbabilityMeasure C(unitInterval,ℝ)} (hμ : Tendsto μ atTop (𝓝 G)) + (m : unitInterval → ℝ) (v : unitInterval → ℝ≥0) + (hg : ∀ t, (G : Measure C(unitInterval,ℝ)).map (fun g => g t) = gaussianReal (m t) (v t)) + (grid : ℕ → Set unitInterval) (b : ℕ → unitInterval → ℝ) + (hb : ∀ n t, t ∈ grid n → + (1/2 : ℝ≥0∞) ≤ ((μ n : Measure C(unitInterval,ℝ)).map (fun g => g t)) (Set.Iic (b n t)) ∧ + (1/2 : ℝ≥0∞) ≤ ((μ n : Measure C(unitInterval,ℝ)).map (fun g => g t)) (Set.Ici (b n t))) + {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ n in atTop, ∀ t ∈ grid n, |b n t-m t| < ε := by + by_contra hn + simp only [eventually_atTop,not_exists,not_forall] at hn + have hex : ∀ N : ℕ, ∃ n ≥ N, ∃ t ∈ grid n, ε ≤ |b n t-m t| := by + intro N + obtain ⟨n,hn⟩ := hn N + push Not at hn + obtain ⟨t,ht,hb⟩ := hn.2 + exact ⟨n,hn.1,t,ht,hb⟩ + choose n hn t htg hbad using hex + have hnlim : Tendsto n atTop atTop := tendsto_atTop_mono hn tendsto_id + obtain ⟨s,_,k,hk,ht⟩ := isCompact_univ.tendsto_subseq (fun n => Set.mem_univ (t n)) + have hm := continuous_gaussian_path_mean G m v hg |>.tendsto s |>.comp ht + have hl := weak_path_eval_tendsto (hμ.comp (hnlim.comp hk.tendsto_atTop)) ht + have hb' : Tendsto (fun i => b (n (k i)) (t (k i))) atTop (𝓝 (m s)) := by + apply median_tendsto_of_weak hl + · intro i; exact hb _ _ (htg _) + · intro δ hδ + change (1/2 : ℝ≥0∞) < ((G : Measure C(unitInterval,ℝ)).map (fun g => g s)) (Set.Iio (m s+δ)) ∧ + (1/2 : ℝ≥0∞) < ((G : Measure C(unitInterval,ℝ)).map (fun g => g s)) (Set.Ioi (m s-δ)) + rw [hg] + exact gaussian_median_strict _ _ hδ + have hz := (hb'.sub hm).abs + have he := hz.eventually (gt_mem_nhds (show |m s-m s| < ε by simpa using hε)) + obtain ⟨i,hi⟩ := he.exists + exact not_lt_of_ge (hbad (k i)) hi + +end DirectionalTransience + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +end +end + +end OAI diff --git a/lean/OAI/Probability/Ballisticity/Walk/WienerPathMaximal.lean b/lean/OAI/Probability/Ballisticity/Walk/WienerPathMaximal.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2f2d27165b2223b5e7f2142cbf3b158c08a419e --- /dev/null +++ b/lean/OAI/Probability/Ballisticity/Walk/WienerPathMaximal.lean @@ -0,0 +1,342 @@ +import Mathlib +import OAI.Probability.Ballisticity.Estimates.OrderedTimes +import OAI.Probability.Ballisticity.Estimates.MartingaleExponentialSubmartingale + +namespace OAI + +section + +section + +open MeasureTheory ProbabilityTheory Filter +open scoped ENNReal NNReal BigOperators Topology Classical + +namespace DirectionalTransience + +lemma gaussian_independent_sum_range_law {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ) + (hXm : ∀ n, Measurable (X n)) (hind : iIndepFun X μ) + (v : ℕ → ℝ≥0) (hLaw : ∀ n, μ.map (X n) = gaussianReal 0 (v n)) (n : ℕ) : + μ.map (fun ω => ∑ j ∈ Finset.range n, X j ω) = + gaussianReal 0 (∑ j ∈ Finset.range n, v j) := by + induction n with + | zero => simp [gaussianReal_zero_var] + | succ n ih => + have he : (∑ j ∈ Finset.range n, X j) = (fun ω => ∑ j ∈ Finset.range n, X j ω) := by + funext ω + simp + have hi' : μ.map (∑ j ∈ Finset.range n, X j) = + gaussianReal 0 (∑ j ∈ Finset.range n, v j) := by rw [he]; exact ih + have hh := gaussianReal_add_gaussianReal_of_indepFun + (hind.indepFun_finsetSum_of_notMem hXm (Finset.notMem_range_self (n := n))) + ⟨by rw [he]; fun_prop, hi'⟩ ⟨(hXm n).aemeasurable, hLaw n⟩ + rw [he] at hh + convert hh using 1 + · congr 1 + funext ω + simp [Finset.sum_range_succ] + · simp only [zero_add, Finset.sum_range_succ] + +lemma gaussian_martingale_maximal_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Filtration ℕ ‹MeasurableSpace Ω›) + (X : ℕ → Ω → ℝ) (hX : Martingale X F μ) (v : ℕ → ℝ≥0) + (hLaw : ∀ n, μ.map (X n) = gaussianReal 0 (v n)) + (n : ℕ) (V : ℝ) (hV : 0 < V) (hv : (v n : ℝ) ≤ V) (a : ℝ) (ha : 0 < a) : + μ.real {ω | ∃ k ≤ n, a ≤ X k ω} ≤ Real.exp (-a^2/(2*V)) := by + let c := a/V + have hc : 0 < c := div_pos ha hV + have hXm (j : ℕ) : Measurable (X j) := (hX.stronglyMeasurable j).measurable.mono (F.le j) le_rfl + have hi (j : ℕ) : Integrable (fun ω => Real.exp (c*X j ω)) μ := by + have hh : Integrable (fun z : ℝ => Real.exp (c*z)) (μ.map (X j)) := by + rw [hLaw j] + exact integrable_exp_mul_gaussianReal c + exact (integrable_map_measure (by fun_prop) (hXm j).aemeasurable).mp hh + have hh := martingale_exponential_maximal μ F (c • X) (hX.smul c) hi n (c*a) + have hs : {ω | ∃ k ≤ n, c*a ≤ (c • X) k ω} = {ω | ∃ k ≤ n, a ≤ X k ω} := by + ext ω + simp only [Set.mem_ofPred_eq, Pi.smul_apply, smul_eq_mul, mul_le_mul_iff_right₀ hc] + rw [hs] at hh + have he : (∫ ω, Real.exp ((c • X) n ω) ∂μ) = Real.exp ((v n:ℝ)*c^2/2) := by + simpa only [mgf, Pi.smul_apply, smul_eq_mul, zero_mul, zero_add] using + mgf_gaussianReal ⟨(hXm n).aemeasurable, hLaw n⟩ c + rw [he, ← Real.exp_add] at hh + refine hh.trans (Real.exp_le_exp.mpr ?_) + calc + -(c*a) + (v n:ℝ)*c^2/2 ≤ -(c*a) + V*c^2/2 := by gcongr + _ = -a^2/(2*V) := by dsimp [c]; field_simp; ring + +lemma gaussian_martingale_abs_maximal_le {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Filtration ℕ ‹MeasurableSpace Ω›) + (X : ℕ → Ω → ℝ) (hX : Martingale X F μ) (v : ℕ → ℝ≥0) + (hLaw : ∀ n, μ.map (X n) = gaussianReal 0 (v n)) + (n : ℕ) (V : ℝ) (hV : 0 < V) (hv : (v n : ℝ) ≤ V) (a : ℝ) (ha : 0 < a) : + μ.real {ω | ∃ k ≤ n, a ≤ |X k ω|} ≤ 2*Real.exp (-a^2/(2*V)) := by + have hneg (j : ℕ) : μ.map ((-X) j) = gaussianReal 0 (v j) := by + have hm : AEMeasurable (X j) μ := + ((hX.stronglyMeasurable j).measurable.mono (F.le j) le_rfl).aemeasurable + simpa only [neg_zero, Pi.neg_apply] using + (gaussianReal_neg (show HasLaw (X j) (gaussianReal 0 (v j)) μ from ⟨hm,hLaw j⟩)).map_eq + have hp := gaussian_martingale_maximal_le μ F X hX v hLaw n V hV hv a ha + have hn := gaussian_martingale_maximal_le μ F (-X) hX.neg v hneg n V hV hv a ha + have hs : {ω | ∃ k ≤ n, a ≤ |X k ω|} = + {ω | ∃ k ≤ n, a ≤ X k ω} ∪ {ω | ∃ k ≤ n, a ≤ (-X) k ω} := by + ext ω + simp only [Set.mem_ofPred_eq, Set.mem_union, le_abs, Pi.neg_apply] + aesop + rw [hs] + exact (measureReal_union_le _ _).trans (by simpa only [two_mul] using add_le_add hp hn) + +lemma fin_sum_Iic_eq_range {M : Type*} [AddCommMonoid M] {n : ℕ} + (x : ℕ → M) (k : Fin n) : + (∑ j ≤ k, x j) = ∑ j ∈ Finset.range (k+1), x j := by + apply Finset.sum_bij (fun j _ => j.val) + · intro j hj + simp only [Finset.mem_Iic] at hj + exact Finset.mem_range.mpr (Nat.lt_succ_of_le hj) + · intro j hj j' hj' he + exact Fin.ext he + · intro j hj + have hjk : j ≤ k.val := Nat.lt_succ_iff.mp (Finset.mem_range.mp hj) + exact ⟨⟨j, hjk.trans_lt k.isLt⟩, Finset.mem_Iic.mpr hjk, rfl⟩ + · intros; rfl + +lemma gaussian_pi_prefix_maximal {n : ℕ} (v : Fin n → ℝ≥0) + (V : ℝ) (hV : 0 < V) (hv : (∑ j, (v j : ℝ)) ≤ V) (a : ℝ) (ha : 0 < a) : + (Measure.pi (fun j => gaussianReal 0 (v j))).real + {x | ∃ k : Fin n, a ≤ |∑ j ≤ k, x j|} ≤ 2*Real.exp (-a^2/(2*V)) := by + let w : ℕ → ℝ≥0 := fun j => if hj : j < n then v ⟨j,hj⟩ else 0 + let μ := Measure.infinitePi (fun j => gaussianReal 0 (w j)) + let X : ℕ → (ℕ → ℝ) → ℝ := fun j x => x j + have hXm (j : ℕ) : Measurable (X j) := measurable_pi_apply j + have hLaw (j : ℕ) : μ.map (X j) = gaussianReal 0 (w j) := + Measure.infinitePi_map_eval _ j + have hHasLaw (j : ℕ) : HasLaw (X j) (gaussianReal 0 (w j)) μ := + ⟨(hXm j).aemeasurable, hLaw j⟩ + have hi (j : ℕ) : Integrable (X j) μ := (hHasLaw j).hasGaussianLaw.integrable + have hmean (j : ℕ) : ∫ x, X j x ∂μ = 0 := by + rw [(hHasLaw j).integral_eq] + exact integral_id_gaussianReal + have hind : iIndepFun X μ := iIndepFun_infinitePi (X := fun _ x => x) (by fun_prop) + have hM := independent_centered_sum_martingale μ X hXm hi hind hmean + have hsum (j : ℕ) := gaussian_independent_sum_range_law μ X hXm hind w hLaw (j+1) + have htotal : ((∑ j ∈ Finset.range (n+1), w j : ℝ≥0) : ℝ) ≤ V := by + rw [Finset.sum_range_succ] + have hw : w n = 0 := by simp [w] + rw [hw, add_zero] + have hs : ∑ j ∈ Finset.range n, w j = ∑ j, v j := by + symm + exact Finset.sum_fin_eq_sum_range _ + rw [hs] + simpa only [NNReal.coe_sum] using hv + have hh := gaussian_martingale_abs_maximal_le μ _ _ hM + (fun j => ∑ k ∈ Finset.range (j+1), w k) hsum n V hV htotal a ha + let π : (ℕ → ℝ) → (Fin n → ℝ) := fun x j => x j + have hm : μ.map π = Measure.pi (fun j => gaussianReal 0 (v j)) := by + have hh := Measure.map_infinitePi_infinitePi_of_inj + (P := fun j => gaussianReal 0 (w j)) (f := fun j : Fin n => j.val) Fin.val_injective + rw [Measure.infinitePi_eq_pi (fun j : Fin n => gaussianReal 0 (w j))] at hh + simpa only [w, dite_eq_left (Fin.isLt _)] using hh + rw [← hm, measureReal_def, Measure.map_apply (by fun_prop) + (by measurability)] + apply le_trans (measureReal_mono (show π ⁻¹' {x | ∃ k : Fin n, a ≤ |∑ j ≤ k, x j|} ⊆ + {x | ∃ k ≤ n, a ≤ |∑ j ∈ Finset.range (k+1), X j x|} from ?_)) hh + rintro x ⟨k,hk⟩ + refine ⟨k,k.isLt.le,?_⟩ + simpa only [π, X, fin_sum_Iic_eq_range] using hk + +lemma gaussianPathFiniteLaw_abs_maximal (V : ℝ) (hV : 0 < V) + (I : Finset unitInterval) (a : ℝ) (ha : 0 < a) : + (gaussianPathFiniteLaw V I).real {x | ∃ i : I, a ≤ |x i|} ≤ + 2*Real.exp (-a^2/(2*V)) := by + let v : Fin I.card → ℝ≥0 := fun j => + Real.toNNReal (V*((orderedTimes I j.succ : ℝ)-orderedTimes I j.castSucc)) + have hv : (∑ j, (v j : ℝ)) ≤ V := by + have hn (j : Fin I.card) : 0 ≤ V*((orderedTimes I j.succ : ℝ)-orderedTimes I j.castSucc) := + mul_nonneg hV.le (sub_nonneg.mpr (orderedTimes_monotone I (Fin.castSucc_le_succ j))) + simp only [v, Real.coe_toNNReal _ (hn _)] + by_cases hI : I.card = 0 + · have he : I = ∅ := Finset.card_eq_zero.mp hI + subst I + have : IsEmpty (Fin ((∅ : Finset unitInterval).card)) := by + change IsEmpty (Fin 0) + infer_instance + rw [Finset.univ_eq_empty, Finset.sum_empty] + exact hV.le + · let k : Fin I.card := ⟨I.card-1, by omega⟩ + have hk : Finset.Iic k = Finset.univ := by + ext j + simp only [Finset.mem_Iic, Finset.mem_univ, iff_true] + change j.val ≤ I.card-1 + have := j.isLt + omega + rw [← Finset.mul_sum, ← hk, Fin.sum_Iic_sub k (fun j => (orderedTimes I j : ℝ))] + have hz : (orderedTimes I 0 : ℝ) = 0 := by simp [orderedTimes] + rw [hz, sub_zero] + exact (mul_le_mul_of_nonneg_left (orderedTimes I k.succ).2.2 hV.le).trans_eq (mul_one V) + have hh := gaussian_pi_prefix_maximal v V hV hv a ha + unfold gaussianPathFiniteLaw + rw [measureReal_def, Measure.map_apply (by fun_prop) + (show MeasurableSet {x : I → ℝ | ∃ i : I, a ≤ |x i|} from by + simp only [Set.ofPred_exists] + exact MeasurableSet.iUnion fun i => measurableSet_le measurable_const (measurable_pi_apply i).abs)] + apply le_trans (measureReal_mono (show (incrementCumsum I) ⁻¹' {x | ∃ i : I, a ≤ |x i|} ⊆ + {x | ∃ k : Fin I.card, a ≤ |∑ j ≤ k, x j|} from ?_)) hh + rintro x ⟨i,hi⟩ + exact ⟨(I.orderIsoOfFin rfl).symm i, hi⟩ + +lemma wiener_path_finite_abs_maximal (W : ProbabilityMeasure C(unitInterval,ℝ)) + (V : ℝ) (hV : 0 < V) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw V I) + (I : Finset unitInterval) (a : ℝ) (ha : 0 < a) : + (W : Measure C(unitInterval,ℝ)).real {g | ∃ t ∈ I, a ≤ |g t|} ≤ + 2*Real.exp (-a^2/(2*V)) := by + have hh := gaussianPathFiniteLaw_abs_maximal V hV I a ha + rw [← hW I, measureReal_def, Measure.map_apply (continuous_path_restrict I).measurable + (show MeasurableSet {x : I → ℝ | ∃ i : I, a ≤ |x i|} from by + simp only [Set.ofPred_exists] + exact MeasurableSet.iUnion fun i => measurableSet_le measurable_const (measurable_pi_apply i).abs)] at hh + have hs : (fun g : C(unitInterval,ℝ) => I.restrict g) ⁻¹' {x | ∃ i : I, a ≤ |x i|} = + {g | ∃ t ∈ I, a ≤ |g t|} := by + ext g + constructor + · rintro ⟨⟨t,ht⟩,hg⟩ + exact ⟨t,ht,hg⟩ + · rintro ⟨t,ht,hg⟩ + exact ⟨⟨t,ht⟩,hg⟩ + rw [hs] at hh + exact hh + +lemma wiener_path_countable_abs_maximal (W : ProbabilityMeasure C(unitInterval,ℝ)) + (V : ℝ) (hV : 0 < V) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw V I) + (t : ℕ → unitInterval) (a : ℝ) (ha : 0 < a) : + (W : Measure C(unitInterval,ℝ)).real {g | ∃ k, a ≤ |g (t k)|} ≤ + 2*Real.exp (-a^2/(2*V)) := by + let E := fun n => {g : C(unitInterval,ℝ) | ∃ k ∈ Finset.range n, a ≤ |g (t k)|} + have hm : Monotone E := by + intro i j hij g + rintro ⟨k,hk,hka⟩ + exact ⟨k,Finset.mem_range.mpr ((Finset.mem_range.mp hk).trans_le hij),hka⟩ + have hu : {g : C(unitInterval,ℝ) | ∃ k, a ≤ |g (t k)|} = ⋃ n, E n := by + ext g + simp only [Set.mem_ofPred_eq,Set.mem_iUnion,E] + constructor + · rintro ⟨k,hk⟩; exact ⟨k+1,k,Finset.mem_range.mpr (Nat.lt_succ_self k),hk⟩ + · rintro ⟨n,k,_,hk⟩; exact ⟨k,hk⟩ + have hb n : (W : Measure C(unitInterval,ℝ)) (E n) ≤ + ENNReal.ofReal (2*Real.exp (-a^2/(2*V))) := by + have hh := wiener_path_finite_abs_maximal W V hV hW ((Finset.range n).image t) a ha + have he : {g : C(unitInterval,ℝ) | ∃ z ∈ (Finset.range n).image t, a ≤ |g z|} = E n := by + ext g + simp only [Set.mem_ofPred_eq,Finset.mem_image,E] + aesop + rw [he] at hh + rw [← ofReal_measureReal] + exact ENNReal.ofReal_le_ofReal hh + have hbound : (W : Measure C(unitInterval,ℝ)) {g | ∃ k, a ≤ |g (t k)|} ≤ + ENNReal.ofReal (2*Real.exp (-a^2/(2*V))) := by + rw [hu,hm.measure_iUnion] + exact iSup_le hb + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top hbound + simpa only [measureReal_def,ENNReal.toReal_ofReal + (by positivity : 0 ≤ 2*Real.exp (-a^2/(2*V)))] using hh + +lemma wiener_path_abs_gt_maximal (W : ProbabilityMeasure C(unitInterval,ℝ)) + (V : ℝ) (hV : 0 < V) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw V I) + (a : ℝ) (ha : 0 < a) : + (W : Measure C(unitInterval,ℝ)).real {g | ∃ t, a < |g t|} ≤ + 2*Real.exp (-a^2/(2*V)) := by + let u := TopologicalSpace.denseSeq unitInterval + have hu : DenseRange u := TopologicalSpace.denseRange_denseSeq _ + have hh := wiener_path_countable_abs_maximal W V hV hW u a ha + refine (measureReal_mono (show {g : C(unitInterval,ℝ) | ∃ t, a < |g t|} ⊆ + {g | ∃ k, a ≤ |g (u k)|} from ?_)).trans hh + rintro g ⟨t,hat⟩ + obtain ⟨k,hk⟩ := hu.exists_mem_open (isOpen_lt continuous_const g.continuous.abs) ⟨t,hat⟩ + exact ⟨k,hk.le⟩ + +lemma wiener_path_abs_maximal (W : ProbabilityMeasure C(unitInterval,ℝ)) + (V : ℝ) (hV : 0 < V) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw V I) + (a : ℝ) (ha : 0 < a) : + (W : Measure C(unitInterval,ℝ)).real {g | ∃ t, a ≤ |g t|} ≤ + 2*Real.exp (-a^2/(2*V)) := by + let b : ℕ → ℝ := fun n => a-a/((n:ℝ)+2) + have hbpos n : 0 < b n := by + have hd : a/((n:ℝ)+2) < a := (div_lt_iff₀ (by positivity)).2 (by nlinarith [Nat.cast_nonneg (α:=ℝ) n]) + dsimp [b]; linarith + have hblt n : b n < a := by dsimp [b]; exact sub_lt_self a (div_pos ha (by positivity)) + have hb : Tendsto b atTop (𝓝 a) := by + have hd := (tendsto_const_div_atTop_nhds_zero_nat a).comp (tendsto_add_atTop_nat 2) + simpa only [Function.comp_def,Nat.cast_add,Nat.cast_ofNat,sub_zero] using tendsto_const_nhds.sub hd + have hlim : Tendsto (fun n => 2*Real.exp (-(b n)^2/(2*V))) atTop + (𝓝 (2*Real.exp (-a^2/(2*V)))) := by + exact tendsto_const_nhds.mul (Real.continuous_exp.tendsto _ |>.comp ((hb.pow 2).neg.div_const (2*V))) + apply ge_of_tendsto hlim + filter_upwards [] with n + have hh := wiener_path_abs_gt_maximal W V hV hW (b n) (hbpos n) + refine (measureReal_mono (show {g : C(unitInterval,ℝ) | ∃ t, a ≤ |g t|} ⊆ + {g | ∃ t, b n < |g t|} from ?_)).trans hh + rintro g ⟨t,hat⟩ + exact ⟨t,(hblt n).trans_le hat⟩ + +lemma wiener_path_norm_maximal (W : ProbabilityMeasure C(unitInterval,ℝ)) + (V : ℝ) (hV : 0 < V) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw V I) + (a : ℝ) (ha : 0 < a) : + (W : Measure C(unitInterval,ℝ)).real {g | a ≤ ‖g‖} ≤ + 2*Real.exp (-a^2/(2*V)) := by + have hs : {g : C(unitInterval,ℝ) | a ≤ ‖g‖} = {g | ∃ t, a ≤ |g t|} := by + ext g + simp only [Set.mem_ofPred_eq, ← not_lt, g.norm_lt_iff ha, Real.norm_eq_abs, not_forall] + rw [hs] + exact wiener_path_abs_maximal W V hV hW a ha + +lemma distribution_path_norm_limsup {Ω : Type*} [MeasurableSpace Ω] + (μ : ℕ → Measure Ω) [∀ i, IsProbabilityMeasure (μ i)] + (F : ℕ → Ω → C(unitInterval,ℝ)) (hF : ∀ i, Measurable (F i)) + (W : ProbabilityMeasure C(unitInterval,ℝ)) + (hlim : TendstoInDistribution F atTop id μ W) + (V : ℝ) (hV : 0 < V) + (hW : ∀ I : Finset unitInterval, + (W : Measure C(unitInterval,ℝ)).map (fun g : C(unitInterval,ℝ) => I.restrict g) = + gaussianPathFiniteLaw V I) + (a : ℝ) (ha : 0 < a) : + limsup (fun i => (μ i).real {ω | a ≤ ‖F i ω‖}) atTop ≤ + 2*Real.exp (-a^2/(2*V)) := by + let P : ℕ → ProbabilityMeasure C(unitInterval,ℝ) := fun i => + ⟨(μ i).map (F i),inferInstance⟩ + have hp : Tendsto P atTop (𝓝 (⟨(W : Measure C(unitInterval,ℝ)),inferInstance⟩ : ProbabilityMeasure C(unitInterval,ℝ))) := by + simpa only [Measure.map_id] using hlim.tendsto + have hA : IsClosed {g : C(unitInterval,ℝ) | a ≤ ‖g‖} := + isClosed_le continuous_const continuous_norm + have hh := ProbabilityMeasure.limsup_measure_closed_le_of_tendsto hp hA + change limsup (fun i => ((μ i).map (F i)) {g | a ≤ ‖g‖}) atTop ≤ + (W : Measure C(unitInterval,ℝ)) {g | a ≤ ‖g‖} at hh + simp only [Measure.map_apply (hF _) hA.measurableSet] at hh + have he : limsup (fun i => (μ i).real {ω | a ≤ ‖F i ω‖}) atTop = + (limsup (fun i => μ i {ω | a ≤ ‖F i ω‖}) atTop).toReal := by + exact ENNReal.limsup_toReal_eq (by norm_num : (1 : ℝ≥0∞) ≠ ∞) + (Eventually.of_forall fun i => prob_le_one) + rw [he] + exact (ENNReal.toReal_mono (measure_ne_top _ _) hh).trans + (wiener_path_norm_maximal W V hV hW a ha) + +end DirectionalTransience + +end + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm.lean b/lean/OAI/Probability/BenjaminiSchramm.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4bf282caa742fe30c45c124f6e0eddb49e76a5c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm.lean @@ -0,0 +1,186 @@ +import OAI.Probability.BenjaminiSchramm.InputReduction +import OAI.Probability.BenjaminiSchramm.MeanFieldReduction +import OAI.Probability.BenjaminiSchramm.VolumeEntropy +import OAI.Probability.BenjaminiSchramm.OpenTriangle +import OAI.Probability.BenjaminiSchramm.KernelDeletionOperator +import OAI.Probability.BenjaminiSchramm.BoundaryMultiplicity +import OAI.Probability.BenjaminiSchramm.FourArmGeometry +import OAI.Probability.BenjaminiSchramm.ProbabilityLower +import OAI.Probability.BenjaminiSchramm.ModularSchur +import OAI.Probability.BenjaminiSchramm.PeakFirstMoment +import OAI.Probability.BenjaminiSchramm.PeakLayerTransport +import OAI.Probability.BenjaminiSchramm.PeakComparison +import OAI.Probability.BenjaminiSchramm.RootTiltedGhost +import OAI.Probability.BenjaminiSchramm.GhostTiltedTransport +import OAI.Probability.BenjaminiSchramm.TiltedMomentBridge +import OAI.Probability.BenjaminiSchramm.TiltedHit +import OAI.Probability.BenjaminiSchramm.TwoGhost +import OAI.Probability.BenjaminiSchramm.GhostField +import OAI.Probability.BenjaminiSchramm.GhostBondBK +import OAI.Probability.BenjaminiSchramm.GhostFanBK +import OAI.Probability.BenjaminiSchramm.GhostCluster +import OAI.Probability.BenjaminiSchramm.BlockExposure +import OAI.Probability.BenjaminiSchramm.ClusterExposure +import OAI.Probability.BenjaminiSchramm.EdgeClosing +import OAI.Probability.BenjaminiSchramm.PivotalExposure +import OAI.Probability.BenjaminiSchramm.GhostAvoidance +import OAI.Probability.BenjaminiSchramm.GhostPivotalBound +import OAI.Probability.BenjaminiSchramm.GhostMomentBound +import OAI.Probability.BenjaminiSchramm.WeightedGhostIncidence +import OAI.Probability.BenjaminiSchramm.GhostDerivative + +import OAI.Probability.BenjaminiSchramm.OperatorMeanFieldReduction +import OAI.Probability.BenjaminiSchramm.GhostPivotalGeometry +import OAI.Probability.BenjaminiSchramm.RootGhostSums +import OAI.Probability.BenjaminiSchramm.GhostPivotalProbability +import OAI.Probability.BenjaminiSchramm.GhostPivotalWeight +import OAI.Probability.BenjaminiSchramm.GhostPivotalIncidence +import OAI.Probability.BenjaminiSchramm.GhostPivotalUnion +import OAI.Probability.BenjaminiSchramm.GhostDoubleConnection +import OAI.Probability.BenjaminiSchramm.FiniteClusterSums +import OAI.Probability.BenjaminiSchramm.CriticalUpwardDecay + +import OAI.Probability.BenjaminiSchramm.IntrinsicRadiusLower +import OAI.Probability.BenjaminiSchramm.SubcriticalUpward +import OAI.Probability.BenjaminiSchramm.ModularSlabs +import OAI.Probability.BenjaminiSchramm.EventLeftContinuity +import OAI.Probability.BenjaminiSchramm.SlabCrossing +import OAI.Probability.BenjaminiSchramm.SlabHit +import OAI.Probability.BenjaminiSchramm.LayerFreshSelection + +import OAI.Probability.BenjaminiSchramm.ThinSphereRecurrence +import OAI.Probability.BenjaminiSchramm.FreshSlabCrossing +import OAI.Probability.BenjaminiSchramm.FreshSlabConcatenation +import OAI.Probability.BenjaminiSchramm.SelectedLayerVertex + +import OAI.Probability.BenjaminiSchramm.IntrinsicRadiusUpper +import OAI.Probability.BenjaminiSchramm.IntrinsicConnectionAverage +import OAI.Probability.BenjaminiSchramm.HalfspaceConcatenation +import OAI.Probability.BenjaminiSchramm.ModularCrossingRate +import OAI.Probability.BenjaminiSchramm.OrbitHeightComparison +import OAI.Probability.BenjaminiSchramm.FiniteOrbitStationary +import OAI.Probability.BenjaminiSchramm.OrbitNeighborChain + +import OAI.Probability.BenjaminiSchramm.RadiusInputReduction +import OAI.Probability.BenjaminiSchramm.OrbitTransport + +import OAI.Probability.BenjaminiSchramm.HalfspaceRootComparison + +import OAI.Probability.BenjaminiSchramm.NonunimodularMomentReduction +import OAI.Probability.BenjaminiSchramm.CriticalHalfspaceDecay +import OAI.Probability.BenjaminiSchramm.CrossingExponentContinuity +import OAI.Probability.BenjaminiSchramm.NormalizedExponentComparison +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry +import OAI.Probability.BenjaminiSchramm.PrefixMaximumBootstrap +import OAI.Probability.BenjaminiSchramm.SlabFractionalRecurrence +import OAI.Probability.BenjaminiSchramm.CeilingBandTransport +import OAI.Probability.BenjaminiSchramm.NormalizedLayerTransport +import OAI.Probability.BenjaminiSchramm.IntegerLayerFirstVisit +import OAI.Probability.BenjaminiSchramm.LayerFirstMoments +import OAI.Probability.BenjaminiSchramm.SlabSecondMoment + +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerConvolution +import OAI.Probability.BenjaminiSchramm.DownLayerReciprocity +import OAI.Probability.BenjaminiSchramm.LayerFirstMomentRate + +import OAI.Probability.BenjaminiSchramm.LayerMaximumDecomposition +import OAI.Probability.BenjaminiSchramm.LayerSecondMomentDecomposition +import OAI.Probability.BenjaminiSchramm.MinimumHeightHit +import OAI.Probability.BenjaminiSchramm.UpperLayerSecondMoment +import OAI.Probability.BenjaminiSchramm.BandMomentSummability +import OAI.Probability.BenjaminiSchramm.NegativeMomentConvolution +import OAI.Probability.BenjaminiSchramm.SignedUpperConvolution +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerPrefactor +import OAI.Probability.BenjaminiSchramm.SubcriticalFullLayerProfile +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerSecondMoment +import OAI.Probability.BenjaminiSchramm.PeakSurgeryGeometry +import OAI.Probability.BenjaminiSchramm.PeakFiniteEnergy +import OAI.Probability.BenjaminiSchramm.FractionalBandEstimate +import OAI.Probability.BenjaminiSchramm.PeakCorrelationAveraging +import OAI.Probability.BenjaminiSchramm.PeakCountComparison +import OAI.Probability.BenjaminiSchramm.PeakComparisonAveraging +import OAI.Probability.BenjaminiSchramm.CriticalPeakBand +import OAI.Probability.BenjaminiSchramm.PeakSurgeryProbability +import OAI.Probability.BenjaminiSchramm.PeakExtension +import OAI.Probability.BenjaminiSchramm.PeakFrontierTruncation +import OAI.Probability.BenjaminiSchramm.PeakSurgeryAverage +import OAI.Probability.BenjaminiSchramm.SubcriticalUpperSecondMoment +import OAI.Probability.BenjaminiSchramm.IntegerFrontierCrossing +import OAI.Probability.BenjaminiSchramm.UpwardFrontierProbability +import OAI.Probability.BenjaminiSchramm.NormalizedPeakSurgery +import OAI.Probability.BenjaminiSchramm.MixedRootSurgery +import OAI.Probability.BenjaminiSchramm.PeakExposureGeometry + +import OAI.Probability.BenjaminiSchramm.SubcriticalPeakSurvival +import OAI.Probability.BenjaminiSchramm.CriticalPeakComparison +import OAI.Probability.BenjaminiSchramm.PeakSprinklingCost +import OAI.Probability.BenjaminiSchramm.RestrictedMomentHolder + +import OAI.Probability.BenjaminiSchramm.PeakConditionalLayers +import OAI.Probability.BenjaminiSchramm.SprinklingPeakGeometry +import OAI.Probability.BenjaminiSchramm.AvoidanceProduct +import OAI.Probability.BenjaminiSchramm.PairedSprinkling +import OAI.Probability.BenjaminiSchramm.SubcriticalPeakConditional +import OAI.Probability.BenjaminiSchramm.PeakRateCancellation +import OAI.Probability.BenjaminiSchramm.TruncatedFractionalSummation +import OAI.Probability.BenjaminiSchramm.TruncatedSlabMoment +import OAI.Probability.BenjaminiSchramm.PeakSurvivalRealHeight +import OAI.Probability.BenjaminiSchramm.HeightMaximumSlices +import OAI.Probability.BenjaminiSchramm.FractionalSlabFromTruncation + +import OAI.Probability.BenjaminiSchramm.CriticalFractionalSlab +import OAI.Probability.BenjaminiSchramm.WeightedCostRetention +import OAI.Probability.BenjaminiSchramm.FiniteEnergyObservable +import OAI.Probability.BenjaminiSchramm.FractionalSlabGeometry +import OAI.Probability.BenjaminiSchramm.FractionalSlabTransport +import OAI.Probability.BenjaminiSchramm.FractionalSlabEstimate +import OAI.Probability.BenjaminiSchramm.FirstHeightPeakWalk +import OAI.Probability.BenjaminiSchramm.FreshWhiteExposure +import OAI.Probability.BenjaminiSchramm.ExteriorEscape +import OAI.Probability.BenjaminiSchramm.CriticalHeightHit +import OAI.Probability.BenjaminiSchramm.AvoidanceCostProfile +import OAI.Probability.BenjaminiSchramm.NormalizedEscapeRisk +import OAI.Probability.BenjaminiSchramm.PeakSprinklingCell + +import OAI.Probability.BenjaminiSchramm.SlabRootShift +import OAI.Probability.BenjaminiSchramm.AntitoneSurvivalHeight +import OAI.Probability.BenjaminiSchramm.SlabCountBasic +import OAI.Probability.BenjaminiSchramm.SlabFractionalProfileShift +import OAI.Probability.BenjaminiSchramm.UpwardFractionalSlabProfile +import OAI.Probability.BenjaminiSchramm.PeakLayerCost +import OAI.Probability.BenjaminiSchramm.PeakCostBound +import OAI.Probability.BenjaminiSchramm.SprinklingAvoidanceProfile +import OAI.Probability.BenjaminiSchramm.SprinklingParameter +import OAI.Probability.BenjaminiSchramm.PeakSprinklingAverage +import OAI.Probability.BenjaminiSchramm.PeakSprinklingSurvival +import OAI.Probability.BenjaminiSchramm.CriticalPeakSurvival +import OAI.Probability.BenjaminiSchramm.NormalizedQuarterMoment +import OAI.Probability.BenjaminiSchramm.LayerMonotoneLimit +import OAI.Probability.BenjaminiSchramm.GeometricIncrement +import OAI.Probability.BenjaminiSchramm.CriticalSlabProfiles +import OAI.Probability.BenjaminiSchramm.SlabExtensionGeometry +import OAI.Probability.BenjaminiSchramm.CeilingZeroBand +import OAI.Probability.BenjaminiSchramm.NeighborDegreeBound +import OAI.Probability.BenjaminiSchramm.CriticalCeilingProfile +import OAI.Probability.BenjaminiSchramm.UpwardHalfspaceFromContinuation +import OAI.Probability.BenjaminiSchramm.DownwardHalfspaceFromContinuation +import OAI.Probability.BenjaminiSchramm.FractionalInterpolation +import OAI.Probability.BenjaminiSchramm.FractionalExponentBootstrap +import OAI.Probability.BenjaminiSchramm.CeilingDownCrudeProfile +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShift +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShiftProfile +import OAI.Probability.BenjaminiSchramm.HalfspaceFractionalRecurrence + +import OAI.Probability.BenjaminiSchramm.HalfspaceProfileBootstrap + +import OAI.Probability.BenjaminiSchramm.HalfspaceUniformShift +import OAI.Probability.BenjaminiSchramm.UpwardCeilingProfile +import OAI.Probability.BenjaminiSchramm.FloorDownProfile +import OAI.Probability.BenjaminiSchramm.CriticalHalfspaceProfiles +import OAI.Probability.BenjaminiSchramm.CriticalEndpointProfiles +import OAI.Probability.BenjaminiSchramm.FullspaceFractionalRecurrence +import OAI.Probability.BenjaminiSchramm.CriticalFullspaceProfiles +import OAI.Probability.BenjaminiSchramm.CriticalQuarterMoment + +import OAI.Probability.BenjaminiSchramm.CombinatorialUnimodularOperator +import OAI.Probability.BenjaminiSchramm.Main diff --git a/lean/OAI/Probability/BenjaminiSchramm/AntitoneSurvivalHeight.lean b/lean/OAI/Probability/BenjaminiSchramm/AntitoneSurvivalHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..550ed86925584bec35bb2c4f99de6cb0c7e15456 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/AntitoneSurvivalHeight.lean @@ -0,0 +1,53 @@ +import OAI.Probability.BenjaminiSchramm.PeakSurvivalRealHeight + +namespace OAI + +noncomputable section +open Filter +open scoped ENNReal Topology + +namespace Percolation.BenjaminiSchramm + +theorem antitone_survival_real_lower (Q : ℝ → ℝ≥0∞) (hQ : Antitone Q) + (R b : ℝ) (hR : 0 < R) (hb : 0 ≤ b) + (hdisc : ∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ + ∀ᶠ n : ℕ in atTop, ENNReal.ofReal (c*Real.exp (-(R*b+ε)*n)) ≤ Q (R*n)) : + ∀ δ : ℝ, 0 < δ → ∃ c : ℝ, 0 < c ∧ ∀ ell : ℝ, 0 < ell → + ENNReal.ofReal (c*Real.exp (-(b+δ)*ell)) ≤ Q ell := by + intro δ hδ + obtain ⟨c,hc,hcbd⟩ := hdisc (R*δ) (mul_pos hR hδ) + obtain ⟨N,hN⟩ := eventually_atTop.mp hcbd + let A := R*b+R*δ + have hA : 0 ≤ A := add_nonneg (mul_nonneg hR.le hb) (mul_nonneg hR.le hδ.le) + refine ⟨c*Real.exp (-A*((N : ℝ)+1)),mul_pos hc (Real.exp_pos _),fun ell hell => ?_⟩ + let n := max N ⌈ell/R⌉₊ + have hNn : N ≤ n := le_max_left _ _ + have helln : ell ≤ R*(n : ℝ) := by + have hh : ell/R ≤ (n : ℝ) := (Nat.le_ceil (ell/R)).trans (Nat.cast_le.mpr (le_max_right _ _)) + have hh' := (div_le_iff₀ hR).mp hh + nlinarith + have hnn : (n : ℝ) ≤ ell/R+(N : ℝ)+1 := by + have hh := (Nat.ceil_lt_add_one (div_nonneg hell.le hR.le)).le + have hh' : (n : ℝ) ≤ (N : ℝ)+(⌈ell/R⌉₊ : ℝ) := by + exact_mod_cast (show n ≤ N+⌈ell/R⌉₊ from + Nat.max_le.mpr ⟨Nat.le_add_right _ _,Nat.le_add_left _ _⟩) + linarith + have hreal : (c*Real.exp (-A*((N : ℝ)+1)))*Real.exp (-(b+δ)*ell) ≤ + c*Real.exp (-(R*b+R*δ)*(n : ℝ)) := by + rw [mul_assoc,←Real.exp_add] + apply mul_le_mul_of_nonneg_left _ hc.le + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left hnn hA + have hcancel : A*(ell/R)=(b+δ)*ell := by + dsimp [A] + field_simp + rw [mul_add,mul_add,hcancel] at hh + dsimp [A] at hh ⊢ + nlinarith + exact (ENNReal.ofReal_le_ofReal hreal).trans ((hN n hNn).trans (hQ helln)) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/Application.lean b/lean/OAI/Probability/BenjaminiSchramm/Application.lean new file mode 100644 index 0000000000000000000000000000000000000000..d97eab03c131bb732902cf0e92631ddd1ec1ed0c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/Application.lean @@ -0,0 +1,100 @@ +import OAI.Probability.BenjaminiSchramm.CayleyTheorem + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +open MeasureTheory + +universe u v +variable {V : Type u} {E : Type v} + +def OperatorConclusions (G : BondGraph V E) : Prop := + MainConclusion G ∧ + (∀ x, triangleDiagram G (pc G) x ≤ operatorNorm G (pc G) ^ 3 ∧ + triangleDiagram G (pc G) x < ⊤) ∧ + (pc G < ptwo G ∧ ptwo G ≤ pexp G) ∧ + ∀ p : unitInterval, p < ptwo G → ExponentialDecay G p + +theorem operatorConclusions_of_main [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hm : MainConclusion G) : OperatorConclusions G := by + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + exact ⟨hm, critical_triangle_of_mainConclusion G hm, + ⟨hm.2.2.1, ptwo_le_pexp G hconn hloc⟩, + exponentialDecay_of_lt_ptwo G hconn hloc⟩ + +theorem operator_conclusions_conditional [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) : OperatorConclusions G := + operatorConclusions_of_main G hconn hloc (main_conditional G hconn hloc hqt hh hutchcroft2019) + +theorem operator_conclusions_unimodular [Infinite V] + (G : BondGraph V E) (hG : Function.Injective G) + (hconn : Connected G) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hh : 0 < hV G) (huni : AutUnimodular G hG hconn hloc) : OperatorConclusions G := + operatorConclusions_of_main G hconn hloc (mainConclusion_of_critical_bounded G hconn hloc hqt + (critical_bounded_of_unimodular G hG hconn hloc hqt hh huni)) + +theorem critical_laws_of_main [Infinite V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) (hm : MainConclusion G) + (hfirst : HutchcroftFirstMomentInput G) + (htheta : TrianglePercolationProbabilityInput G) + (hvolume : HutchcroftCriticalVolumeInput G) + (hradii : HutchcroftCriticalRadiiInput G) : CriticalLawsConclusion G := by + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + have hb := (operatorNorm_lt_top_iff G (pc G)).mp hm.2.1 + have hθ := percolationProbabilityLaw_of_publishedInput G hgraph htheta hb + have hp1 : pc G < 1 := hm.2.2.1.trans_le (ptwo G).2.2 + have hfin := critical_finite_of_probabilityLaw G hp1 hθ + exact ⟨critical_triangle_of_mainConclusion G hm, + susceptibilityLaw_of_publishedInput G hgraph hfirst hm.2.2.1, hθ, + criticalTailLaws_of_publishedInputs G hgraph hvolume hradii hm.2.2.1 hfin, + ⟨hm.2.2.1,ptwo_le_pexp G hgraph.connected hgraph.locallyFinite⟩, + exponentialDecay_of_lt_ptwo G hgraph.connected hgraph.locallyFinite⟩ + +theorem full_application_conditional [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) + (hfirst : HutchcroftFirstMomentInput (subdivision G)) + (htheta : TrianglePercolationProbabilityInput (subdivision G)) + (hvolume : HutchcroftCriticalVolumeInput (subdivision G)) + (hradii : HutchcroftCriticalRadiiInput (subdivision G)) : + MainConclusion G ∧ CriticalLawsConclusion G := by + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + have hm := main_conditional G hconn hloc hqt hh hutchcroft2019 + have hmH := mainConclusion_of_critical_bounded (subdivision G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) + (subdivision_quasiTransitive G hloc hqt) + (critical_subdivision_bounded_conditional G hconn hloc hqt hh hutchcroft2019) + have hH := critical_laws_of_main (subdivision G) + (publishedSimpleGraph_subdivision G hconn hloc hqt) hmH hfirst htheta hvolume hradii + exact ⟨hm,critical_triangle_of_mainConclusion G hm, + susceptibilityLaw_of_subdivision G hloc hqt hH.2.1, + probabilityLaw_of_subdivision G hloc hqt hH.2.2.1, + criticalTailLaws_of_subdivision G hloc hqt hH.2.2.2.1, + ⟨hm.2.2.1,ptwo_le_pexp G hconn hloc⟩, + exponentialDecay_of_lt_ptwo G hconn hloc⟩ + +theorem cayley_operator_conclusions + {Λ : Type*} [Group Λ] (S : Finset Λ) (hsym : ∀ s ∈ S, s⁻¹ ∈ S) + (hone : 1 ∉ S) (hgen : Subgroup.closure (S : Set Λ) = ⊤) + (hna : ¬ FolnerAmenable Λ) : OperatorConclusions (cayleyBond S) := by + let : Infinite Λ := infinite_of_not_folnerAmenable hna + exact operatorConclusions_of_main (cayleyBond S) (cayleyBond_connected S hgen) + (cayleyBond_locallyFinite S hsym) (cayley_main S hsym hone hgen hna).2.1 + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/AvoidanceCostProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/AvoidanceCostProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f59670383d7bfd98682fbf7391cb181dfa142e1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/AvoidanceCostProfile.lean @@ -0,0 +1,56 @@ +import OAI.Probability.BenjaminiSchramm.CriticalHeightHit + +namespace OAI + +noncomputable section +open Filter +open scoped Topology + +namespace Percolation.BenjaminiSchramm + +lemma exp_neg_two_le_one_sub (r : ℝ) (hr : 0 ≤ r) (hrhalf : r ≤ 1/2) : + Real.exp (-2*r) ≤ 1-r := by + have hp : 0 < 1-r := by linarith + have hlog := Real.one_sub_inv_le_log_of_pos hp + have hi : (1-r)⁻¹ ≤ 1+2*r := by + rw [inv_eq_one_div] + apply (div_le_iff₀ hp).mpr + nlinarith + have he := Real.exp_le_exp.mpr (show -2*r ≤ Real.log (1-r) by linarith) + rwa [Real.exp_log hp] at he + +theorem exists_vanishing_avoidance_cost (h : ℕ → ℝ) + (hh : ∀ l, 0 ≤ h l) (M : ℝ) (hM : ∀ l, h l ≤ M) + (hlim : Tendsto h atTop (𝓝 0)) (κ : ℝ) (hκ : 0 < κ) (hκone : κ ≤ 1) : + ∃ g : ℕ → ℝ, (∀ l, 0 ≤ g l) ∧ + (∃ C : ℝ, ∀ l, g l ≤ C) ∧ Tendsto g atTop (𝓝 0) ∧ + ∀ n : ℕ, ∀ z : ℝ, κ ≤ z → 1-h n ≤ z → Real.exp (-g n) ≤ z := by + obtain ⟨N,hN⟩ := eventually_atTop.mp (hlim.eventually (gt_mem_nhds (by norm_num : (0 : ℝ)<1/2))) + let g : ℕ → ℝ := fun n => if N ≤ n then 2*h n else -Real.log κ + have hlog : 0 ≤ -Real.log κ := neg_nonneg.mpr (Real.log_nonpos hκ.le hκone) + refine ⟨g,fun n => ?_,⟨max (2*M) (-Real.log κ),fun n => ?_⟩,?_,?_⟩ + · dsimp [g] + split_ifs + · exact mul_nonneg (by norm_num) (hh n) + · exact hlog + · dsimp [g] + split_ifs + · exact (mul_le_mul_of_nonneg_left (hM n) (by norm_num)).trans (le_max_left _ _) + · exact le_max_right _ _ + · apply Tendsto.congr' (f₁ := fun n => 2*h n) + · filter_upwards [eventually_ge_atTop N] with n hn + exact (ite_eq_left hn).symm + · simpa only [mul_zero] using tendsto_const_nhds.mul hlim + · intro n z hκz hhz + dsimp [g] + by_cases hn : N ≤ n + · rw [ite_eq_left hn] + simpa only [neg_mul] using (exp_neg_two_le_one_sub (h n) (hh n) (hN n hn).le).trans hhz + · rw [ite_eq_right hn,neg_neg,Real.exp_log hκ] + exact hκz + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/AvoidanceProduct.lean b/lean/OAI/Probability/BenjaminiSchramm/AvoidanceProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..6dbbb02b5221c017f5b8ef811288bbc418cfa8d8 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/AvoidanceProduct.lean @@ -0,0 +1,80 @@ +import OAI.Probability.BenjaminiSchramm.PeakFiniteEnergy +import OAI.Probability.CriticalPercolation.ProductMeasure.MonotoneIndicatorUpper +import OAI.Probability.CriticalPercolation.ProductMeasure.MeasurableSetRestrict + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BernoulliProduct +variable {E ι : Type*} [Countable E] + +lemma harris_finiteWitness_compl (q : E → unitInterval) (A B : Set (Set E)) + (hA : IsUpperSet A) (hB : IsUpperSet B) + (hwA : HasFiniteOpenWitness A) (hwB : HasFiniteOpenWitness B) : + (law q).real Aᶜ*(law q).real Bᶜ ≤ (law q).real (Aᶜ ∩ Bᶜ) := by + have hmA := measurableSet_finiteWitness A hA hwA + have hmB := measurableSet_finiteWitness B hB hwB + have hh := harris_finiteWitness q A B hA hB hwA hwB + have hu := measureReal_union_add_inter (μ := law q) (s := A) hmB + (measure_ne_top _ _) (measure_ne_top _ _) + rw [measureReal_compl hmA,measureReal_compl hmB,←Set.compl_union, + measureReal_compl (hmA.union hmB),probReal_univ] + nlinarith + +def finiteBadUnion (F : Finset ι) (A : ι → Set (Set E)) : Set (Set E) := + {ω | ∃ i ∈ F, ω ∈ A i} + +omit [Countable E] in +lemma finiteBadUnion_upper (F : Finset ι) (A : ι → Set (Set E)) + (hA : ∀ i ∈ F, IsUpperSet (A i)) : IsUpperSet (finiteBadUnion F A) := by + rintro ω η hωη ⟨i,hi,hω⟩ + exact ⟨i,hi,hA i hi hωη hω⟩ + +omit [Countable E] in +lemma finiteBadUnion_finiteWitness (F : Finset ι) (A : ι → Set (Set E)) + (hw : ∀ i ∈ F, HasFiniteOpenWitness (A i)) : HasFiniteOpenWitness (finiteBadUnion F A) := by + rintro ω ⟨i,hi,hω⟩ + obtain ⟨S,hS,hSω,hSA⟩ := hw i hi ω hω + exact ⟨S,hS,hSω,i,hi,hSA⟩ + +theorem finite_avoidance_product (q : E → unitInterval) (F : Finset ι) + (A : ι → Set (Set E)) (hA : ∀ i ∈ F, IsUpperSet (A i)) + (hw : ∀ i ∈ F, HasFiniteOpenWitness (A i)) : + (∏ i ∈ F, (law q).real (A i)ᶜ) ≤ (law q).real (finiteBadUnion F A)ᶜ := by + induction F using Finset.induction_on with + | empty => + have he : finiteBadUnion (∅ : Finset ι) A=∅ := by ext ω; simp [finiteBadUnion] + simp only [Finset.prod_empty,he,Set.compl_empty,probReal_univ,le_refl] + | @insert i F hi ih => + have hAF : ∀ j ∈ F, IsUpperSet (A j) := fun j hj => hA j (Finset.mem_insert_of_mem hj) + have hwF : ∀ j ∈ F, HasFiniteOpenWitness (A j) := fun j hj => hw j (Finset.mem_insert_of_mem hj) + have hh := harris_finiteWitness_compl q (A i) (finiteBadUnion F A) + (hA i (Finset.mem_insert_self _ _)) (finiteBadUnion_upper F A hAF) + (hw i (Finset.mem_insert_self _ _)) (finiteBadUnion_finiteWitness F A hwF) + have he : finiteBadUnion (insert i F) A=A i ∪ finiteBadUnion F A := by + ext ω + simp only [finiteBadUnion,Set.mem_ofPred_eq,Finset.mem_insert,Set.mem_union] + aesop + rw [Finset.prod_insert hi,he,Set.compl_union] + exact (mul_le_mul_of_nonneg_left (ih hAF hwF) measureReal_nonneg).trans hh + +theorem exponential_finite_avoidance (q : E → unitInterval) (F : Finset ι) + (A : ι → Set (Set E)) (hA : ∀ i ∈ F, IsUpperSet (A i)) + (hw : ∀ i ∈ F, HasFiniteOpenWitness (A i)) (g : ι → ℝ) + (hbound : ∀ i ∈ F, Real.exp (-g i) ≤ (law q).real (A i)ᶜ) : + ENNReal.ofReal (Real.exp (-(∑ i ∈ F, g i))) ≤ law q (finiteBadUnion F A)ᶜ := by + apply ENNReal.ofReal_le_of_le_toReal + calc + _ = ∏ i ∈ F, Real.exp (-g i) := by rw [←Real.exp_sum,Finset.sum_neg_distrib] + _ ≤ ∏ i ∈ F, (law q).real (A i)ᶜ := + Finset.prod_le_prod₀ (fun i _ => (Real.exp_pos (-g i)).le) hbound + _ ≤ _ := finite_avoidance_product q F A hA hw + +end CriticalPercolation.BernoulliProduct + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/BallSnapshot.lean b/lean/OAI/Probability/BenjaminiSchramm/BallSnapshot.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2c67a0748bd516f81584286add7b16042adda0a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/BallSnapshot.lean @@ -0,0 +1,87 @@ +import OAI.Probability.BenjaminiSchramm.ThinSphereProbability + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +def ballSnapshotCell (G : BondGraph V E) (x : V) (j : ℕ) (U W : Finset V) : Set (Set E) := + {ω | intrinsicBall G ω x (j-1) = U ∧ intrinsicBall G ω x j = W} + +theorem ballSnapshotCell_dependsOn (G : BondGraph V E) (x : V) + (j : ℕ) (U W : Finset V) : + DependsOn (fun ω => ω ∈ ballSnapshotCell G x j U W) (ballIncidentEdges G U) := by + intro ω η hagree + apply propext + have hforward (ω η : Set E) + (hωη : ∀ e ∈ ballIncidentEdges G U, e ∈ ω ↔ e ∈ η) + (hω : ω ∈ ballSnapshotCell G x j U W) : η ∈ ballSnapshotCell G x j U W := by + have hballs := intrinsicBall_history_eq_of_incident_agreement G ω η x j (by + intro e he + rw [hω.1] at he + exact hωη e he) + exact ⟨(hballs (j-1) (Nat.sub_le j 1)).symm.trans hω.1,(hballs j le_rfl).symm.trans hω.2⟩ + exact ⟨hforward ω η (fun e he => (hagree e he).to_iff), + hforward η ω (fun e he => (hagree e he).symm.to_iff)⟩ + +theorem measurableSet_ballSnapshotCell [Countable V] (G : BondGraph V E) + (hloc : LocallyFinite G) (x : V) (j : ℕ) (U W : Finset V) : + MeasurableSet (ballSnapshotCell G x j U W) := by + have hU := measurableSet_intrinsicBall_eq G hloc Set.univ x (j-1) U + have hW := measurableSet_intrinsicBall_eq G hloc Set.univ x j W + simpa only [ballSnapshotCell, Set.inter_univ, Set.ofPred_and] using hU.inter hW + +theorem ballSnapshotCell_pairwise (G : BondGraph V E) (x : V) (j : ℕ) : + Pairwise (fun a b : Finset V × Finset V => + Disjoint (ballSnapshotCell G x j a.1 a.2) (ballSnapshotCell G x j b.1 b.2)) := by + intro a b hab + apply Set.disjoint_left.mpr + rintro ω ha hb + apply hab + exact Prod.ext (Finset.coe_injective (ha.1.symm.trans hb.1)) + (Finset.coe_injective (ha.2.symm.trans hb.2)) + +theorem exists_ballSnapshotCell (G : BondGraph V E) (hloc : LocallyFinite G) + (ω : Set E) (x : V) (j : ℕ) : + ∃ a : Finset V × Finset V, ω ∈ ballSnapshotCell G x j a.1 a.2 := by + let hU := (finite_reachBall hloc x (j-1)).subset (intrinsicBall_subset_reachBall G ω x (j-1)) + let hW := (finite_reachBall hloc x j).subset (intrinsicBall_subset_reachBall G ω x j) + exact ⟨(hU.toFinset,hW.toFinset),hU.coe_toFinset.symm,hW.coe_toFinset.symm⟩ + +theorem ballSnapshotCell_fresh_connection_factor [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (x y z : V) (j : ℕ) (U W : Finset V) : + law p (ballSnapshotCell G x j U W ∩ + {ω | Conn G (ω \ ballIncidentEdges G U) z y}) = + law p (ballSnapshotCell G x j U W) * + law p {ω | Conn G (ω \ ballIncidentEdges G U) z y} := by + have hm : Measurable (fun ω : Set E => ω \ ballIncidentEdges G U) := + measurable_set_iff.mpr (fun e => (measurable_set_mem e).and measurable_const) + unfold law + rw [←CriticalPercolation.BernoulliProduct.law_const] + apply CriticalPercolation.BernoulliProduct.measure_inter_of_separate_blocks + (fun _ => p) (ballIncidentEdges G U) _ _ + (measurableSet_ballSnapshotCell G hloc x j U W) + ((measurableSet_conn G z y).preimage hm) + (ballSnapshotCell_dependsOn G x j U W) + intro ω η hagree + have he : Set.diff ω (ballIncidentEdges G U) = Set.diff η (ballIncidentEdges G U) := by + apply Set.ext + intro e + change (ω e ∧ e ∉ ballIncidentEdges G U) ↔ (η e ∧ e ∉ ballIncidentEdges G U) + by_cases hi : e ∈ ballIncidentEdges G U + · simp only [hi,not_true_eq_false,and_false] + · simp only [hi,not_false_eq_true,and_true] + exact (hagree e hi).to_iff + change (Conn G (Set.diff ω (ballIncidentEdges G U)) z y) = + (Conn G (Set.diff η (ballIncidentEdges G U)) z y) + rw [he] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/BandMomentSummability.lean b/lean/OAI/Probability/BenjaminiSchramm/BandMomentSummability.lean new file mode 100644 index 0000000000000000000000000000000000000000..70b4464aed769f3809b40b14e6b05856d3b14088 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/BandMomentSummability.lean @@ -0,0 +1,240 @@ +import OAI.Probability.BenjaminiSchramm.CeilingBandUniform +import OAI.Probability.BenjaminiSchramm.LayerFirstMomentRate + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma adjustedBandCount_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (l u : ℝ) + (φ : G.Aut) (ω : Set E) (x : V) : + G.adjustedBandCount a l u (φ.edge '' ω) (φ.vertex x) = + G.adjustedBandCount a l u ω x := by + unfold adjustedBandCount + rw [←φ.vertex.tsum_eq] + simp only [G.adjustedBandTransport_aut a ha l u] + +lemma upLayerCount_le_bandCount (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (n : ℕ) (x : V) (u : ℝ) (ω : Set E) : + restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v ≤ (n : ℤ)}) + {v | G.adjustedLayerIndex a R u x v=(n : ℤ)} ω x ≤ + G.adjustedBandCount a (R*((n : ℝ)-1)) (R*((n : ℝ)+1)) ω x := by + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : G.adjustedLayerIndex a R u x y=(n : ℤ) ∧ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | G.adjustedLayerIndex a R u x v ≤ (n : ℤ)}) x y + · have hh := G.adjustedLayerIndex_height_bounds a R u hR x y + rw [hy.1] at hh + simp only [Int.cast_natCast] at hh + have hc : y ∈ G.cluster ω x := by + change y ∈ (criticalModel G.ends).cluster ω x + rw [criticalModel_cluster] + exact Percolation.conn_mono G.ends Set.inter_subset_left hy.2 + have ht : y ∈ G.cluster ω x ∧ R*((n : ℝ)-1) ≤ G.orbitAdjustedHeight a x y ∧ + G.orbitAdjustedHeight a x y ≤ R*((n : ℝ)+1) := ⟨hc,hh.1.le,hh.2.le⟩ + simp only [Set.mem_ofPred_eq,ite_eq_left hy,adjustedBandTransport,ite_eq_left ht,le_refl] + · simp only [Set.mem_ofPred_eq,ite_eq_right hy] + exact bot_le + +lemma spaced_down_bands_sum_le_cluster (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (s : Finset ℕ) (ω : Set E) (x : V) : + (∑ n ∈ s, G.adjustedBandCount a (-R*(3*(n : ℝ)+1)) (-R*(3*(n : ℝ)-1)) ω x) ≤ + ∑' y, if y ∈ G.cluster ω x then (1 : ℝ≥0∞) else 0 := by + unfold adjustedBandCount + rw [←Summable.tsum_finsetSum (fun _ _ => ENNReal.summable)] + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : y ∈ G.cluster ω x + · simp only [adjustedBandTransport,hy,true_and,ite_true] + rw [Finset.sum_boole] + have hcard : (s.filter fun (n : ℕ) => -R*(3*(n : ℝ)+1) ≤ G.orbitAdjustedHeight a x y ∧ + G.orbitAdjustedHeight a x y ≤ -R*(3*(n : ℝ)-1)).card ≤ 1 := by + apply Finset.card_le_one.mpr + intro n hn m hm + have hn' := (Finset.mem_filter.mp hn).2 + have hm' := (Finset.mem_filter.mp hm).2 + rcases lt_trichotomy n m with hnm | hnm | hmn + · have hh : (n : ℝ)+1 ≤ m := by exact_mod_cast (Nat.succ_le_iff.mpr hnm) + nlinarith + · exact hnm + · have hh : (m : ℝ)+1 ≤ n := by exact_mod_cast (Nat.succ_le_iff.mpr hmn) + nlinarith + simpa only [Nat.cast_one] using (Nat.cast_le (α := ℝ≥0∞)).mpr hcard + · simp [adjustedBandTransport,hy] + +variable [Countable V] [Countable E] + +lemma measurable_adjustedBandCount (a : V → ℝ) (l u : ℝ) (x : V) : + Measurable (fun ω => G.adjustedBandCount a l u ω x) := + Measurable.tsum fun y => G.measurable_adjustedBandTransport a l u x y + +lemma expected_adjustedBandCount_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (l u : ℝ) + (φ : G.Aut) (p : unitInterval) (x : V) : + (∫⁻ ω, G.adjustedBandCount a l u ω (φ.vertex x) ∂G.law p) = + ∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p := by + conv_lhs => rw [←G.law_map_aut p φ] + rw [lintegral_map (G.measurable_adjustedBandCount a l u _) + (BernoulliProduct.measurable_image_equiv φ.edge)] + simp only [G.adjustedBandCount_aut a ha l u] + +lemma expected_band_le_weighted_roots (O : G.OrbitRepresentatives) + (a : V → ℝ) (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (p : unitInterval) (l u : ℝ) (x : V) : + (∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p) ≤ + (ENNReal.ofReal m)⁻¹ * ∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedBandCount a l u ω r ∂G.law p) := by + have hh : ENNReal.ofReal m*(∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p) ≤ + ∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedBandCount a l u ω r ∂G.law p) := by + obtain ⟨r,hr,φ,rfl⟩ := O.cover x + rw [G.expected_adjustedBandCount_aut a ha l u φ p r] + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (ham r)) le_rfl).trans + (Finset.single_le_sum (f := fun r => ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedBandCount a l u ω r ∂G.law p)) (fun _ _ => bot_le) hr) + calc + _ = (ENNReal.ofReal m)⁻¹*(ENNReal.ofReal m* + (∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p)) := by + rw [←mul_assoc,ENNReal.inv_mul_cancel (ne_of_gt (ENNReal.ofReal_pos.mpr hm)) + ENNReal.ofReal_ne_top,one_mul] + _ ≤ _ := mul_le_mul' le_rfl hh + +lemma spaced_down_band_moments_sum_le_row (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (s : Finset ℕ) (x : V) : + (∑ n ∈ s, ∫⁻ ω, G.adjustedBandCount a (-R*(3*(n : ℝ)+1)) + (-R*(3*(n : ℝ)-1)) ω x ∂G.law p) ≤ C := by + rw [←lintegral_finsetSum s (fun n _ => G.measurable_adjustedBandCount a _ _ x)] + have hall (ω : Set E) : (∑' y, if y ∈ G.cluster ω x then (1 : ℝ≥0∞) else 0) = + restrictedLayerCount G.ends Set.univ Set.univ ω x := by + apply tsum_congr + intro y + have hc : y ∈ G.cluster ω x ↔ Percolation.Conn G.ends ω x y := by + change y ∈ (criticalModel G.ends).cluster ω x ↔ _ + rw [criticalModel_cluster] + rfl + simp [hc] + exact (lintegral_mono (fun ω => (G.spaced_down_bands_sum_le_cluster a R hR s ω x).trans_eq + (hall ω))).trans (restrictedLayerCount_expectation_le_row_bound G.ends p C hrow _ _ x) + +theorem spaced_up_layer_moments_sum_bound + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (R : ℝ) (hR : 0 < R) (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (s : Finset ℕ) : + (∑ n ∈ s, ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))* + G.supAdjustedUpLayerMoment a R p (3*n)) ≤ + (ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp R)* + ((∑ r ∈ O.roots, ENNReal.ofReal (a r))*C) := by + let D (n : ℕ) := ∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedBandCount a (-R*(3*(n : ℝ)+1)) (-R*(3*(n : ℝ)-1)) ω r ∂G.law p) + have hu (n : ℕ) : G.supAdjustedUpLayerMoment a R p (3*n) ≤ + (ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-R*(3*(n : ℝ)-1)))*D n := by + apply iSup_le + intro x + apply iSup_le + intro u + have hh := ((lintegral_mono (G.upLayerCount_le_bandCount a R hR (3*n) x u)).trans + (G.expected_band_le_weighted_roots O a ha m hm ham p _ _ x)).trans + (mul_le_mul' le_rfl (G.expected_adjustedBandCount_reciprocity O hc hl a hapos ha p + (R*((3*n : ℕ)-1 : ℝ)) (R*((3*n : ℕ)+1 : ℝ))).2) + simpa only [adjustedUpLayerMoment,D,Nat.cast_mul,Nat.cast_ofNat,mul_assoc,neg_mul] using hh + have hp (n : ℕ) : ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))* + G.supAdjustedUpLayerMoment a R p (3*n) ≤ + ((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp R))*D n := by + apply (mul_le_mul' le_rfl (hu n)).trans_eq + calc + _ = (ENNReal.ofReal m)⁻¹*(ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))* + ENNReal.ofReal (Real.exp (-R*(3*(n : ℝ)-1))))*D n := by ring + _ = _ := by rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add, + show R*(3*(n : ℝ)) + -R*(3*(n : ℝ)-1)=R by ring] + calc + _ ≤ ∑ n ∈ s, ((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp R))*D n := + Finset.sum_le_sum fun n _ => hp n + _ = ((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp R))*(∑ n ∈ s, D n) := + (Finset.mul_sum _ _ _).symm + _ ≤ _ := by + apply mul_le_mul' le_rfl + dsimp only [D] + rw [Finset.sum_comm,Finset.sum_mul] + apply Finset.sum_le_sum + intro r hr + rw [←Finset.mul_sum] + exact mul_le_mul' le_rfl (G.spaced_down_band_moments_sum_le_row a R hR p C hrow s r) + +end CriticalPercolation.BondGraph +namespace Percolation.BenjaminiSchramm + +lemma exponential_rate_strict_of_spaced_sum + (S : ℕ → ℝ≥0∞) (R β : ℝ) + (hlower : ∀ n : ℕ, ENNReal.ofReal (Real.exp (-β*n)) ≤ S n) + (K : ℝ≥0∞) (hK : K < ⊤) + (hsum : ∀ s : Finset ℕ, + (∑ n ∈ s, ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))*S (3*n)) ≤ K) : + R < β := by + by_contra hβ + have hβR : β ≤ R := le_of_not_gt hβ + have hterm (n : ℕ) : (1 : ℝ≥0∞) ≤ + ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))*S (3*n) := by + calc + _ ≤ ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))* + ENNReal.ofReal (Real.exp (-β*(3*n : ℕ))) := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add,←ENNReal.ofReal_one] + apply ENNReal.ofReal_le_ofReal + apply Real.one_le_exp_iff.mpr + simp only [Nat.cast_mul,Nat.cast_ofNat] + nlinarith [(Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + _ ≤ _ := mul_le_mul' le_rfl (hlower (3*n)) + obtain ⟨N,hN⟩ := exists_nat_gt K.toReal + have hh : (N : ℝ≥0∞) ≤ K := by + calc + _ = ∑ n ∈ Finset.range N, (1 : ℝ≥0∞) := by simp + _ ≤ ∑ n ∈ Finset.range N, ENNReal.ofReal (Real.exp (R*(3*(n : ℝ))))*S (3*n) := + Finset.sum_le_sum fun n _ => hterm n + _ ≤ _ := hsum _ + have hh' := ENNReal.toReal_mono hK.ne hh + simp only [ENNReal.toReal_natCast] at hh' + exact (not_lt_of_ge hh') hN + +end Percolation.BenjaminiSchramm +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem normalized_layer_rate_strict_of_lower + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (R : ℝ) (hR : 0 < R) (p : unitInterval) (C : ℝ≥0∞) (hC : C < ⊤) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (β : ℝ) (hlower : ∀ n : ℕ, ENNReal.ofReal (Real.exp (-β*n)) ≤ + G.supAdjustedUpLayerMoment a R p n) : R < β := by + apply exponential_rate_strict_of_spaced_sum _ R β hlower + ((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp R)* + ((∑ r ∈ O.roots, ENNReal.ofReal (a r))*C)) + · apply ENNReal.mul_lt_top + · exact ENNReal.mul_lt_top + (lt_top_iff_ne_top.mpr (ENNReal.inv_ne_top.mpr (ENNReal.ofReal_pos.mpr hm).ne')) + ENNReal.ofReal_lt_top + · exact ENNReal.mul_lt_top (ENNReal.sum_lt_top.mpr fun r _ => ENNReal.ofReal_lt_top) hC + · exact G.spaced_up_layer_moments_sum_bound O hc hl a hapos ha m hm ham R hR p C hrow + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/BlockExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/BlockExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..b83afa7d17ae13a082fe954ed6c201788e8bf488 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/BlockExposure.lean @@ -0,0 +1,76 @@ +import OAI.Probability.CriticalPercolation.ProductMeasure.ProductConditioning + +namespace OAI + +noncomputable section +open Set MeasureTheory ProbabilityTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BernoulliProduct +variable {E B : Type*} + +lemma measurable_block_of_dependsOn {A : Type*} [MeasurableSpace A] + {f : Set E → A} (hf : Measurable f) (S : Set E) (hdep : DependsOn f S) : + @Measurable (Set E) A (blockSigma S) inferInstance f := by + have hm := hf.comp (measurable_forceOn_block Sᶜ (∅ : Set E)) + rw [compl_compl] at hm + convert hm using 1 + funext ω + apply hdep + intro e he + simp only [forceOn, Set.mem_compl_iff, ite_eq_right (not_not.mpr he), + Set.mem_empty_iff_false] + rfl + +lemma lintegral_indicator_fresh (q : E → unitInterval) (S : Set E) + (A : Set (Set E)) (hA : MeasurableSet A) (hdep : DependsOn (fun ω => ω ∈ A) S) + (g : Set E → ℝ≥0∞) (hg : Measurable g) (hgdep : DependsOn g Sᶜ) : + (∫⁻ ω, A.indicator g ω ∂law q) = law q A * ∫⁻ ω, g ω ∂law q := by + have hAb : MeasurableSet[blockSigma S] A := by + have hm := hA.preimage (measurable_forceOn_block Sᶜ (∅ : Set E)) + rw [compl_compl] at hm + convert hm using 1 + ext ω + apply Iff.of_eq + apply hdep + intro e he + simp only [forceOn, Set.mem_compl_iff, ite_eq_right (not_not.mpr he)] + rfl + have hgb := measurable_block_of_dependsOn hg Sᶜ hgdep + have hi := lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace + (blockSigma_le S) (blockSigma_le Sᶜ) + (independent_blocks q S) + ((measurable_const : @Measurable (Set E) ℝ≥0∞ (blockSigma S) inferInstance + (fun _ => 1)).indicator hAb) hgb + have heq : (fun ω => A.indicator (fun _ => (1 : ℝ≥0∞)) ω * g ω) = A.indicator g := by + funext ω + by_cases hω : ω ∈ A <;> simp [Set.indicator, hω] + have hone := lintegral_indicator_const (μ := law q) hA (1 : ℝ≥0∞) + simp only [one_mul] at hone + rw [heq, hone] at hi + exact hi + +theorem lintegral_countable_exposure [Countable B] [MeasurableSpace B] + [MeasurableSingletonClass B] (q : E → unitInterval) (exposed : Set E → B) + (hm : Measurable exposed) (block : B → Set E) + (hd : ∀ b, DependsOn (fun ω => exposed ω = b) (block b)) + (g : B → Set E → ℝ≥0∞) (hg : ∀ b, Measurable (g b)) + (hgd : ∀ b, DependsOn (g b) (block b)ᶜ) : + (∫⁻ ω, g (exposed ω) ω ∂law q) = + ∑' b, law q {ω | exposed ω = b} * ∫⁻ η, g b η ∂law q := by + have hA (b : B) : MeasurableSet {ω | exposed ω = b} := + hm (MeasurableSet.singleton b) + have heq (ω : Set E) : g (exposed ω) ω = + ∑' b, ({ω | exposed ω = b} : Set (Set E)).indicator (g b) ω := by + simp [Set.indicator, eq_comm] + simp_rw [heq] + rw [lintegral_tsum (fun b => ((hg b).indicator (hA b)).aemeasurable)] + apply tsum_congr + intro b + exact lintegral_indicator_fresh q (block b) _ (hA b) (hd b) (g b) (hg b) (hgd b) + +end CriticalPercolation.BernoulliProduct + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/BoundaryMultiplicity.lean b/lean/OAI/Probability/BenjaminiSchramm/BoundaryMultiplicity.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfab24bf5c78720ab0295d708f9c24275be9049b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/BoundaryMultiplicity.lean @@ -0,0 +1,94 @@ +import OAI.Probability.UnimodularPercolation.Escape.CollisionTails +import OAI.Probability.UnimodularPercolation.Clusters.KernelMoments + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem mem_reachBall_symm (G : BondGraph V E) (x y : V) (M : ℕ) + (hy : y ∈ reachBall G x M) : x ∈ reachBall G y M := by + obtain ⟨q,hq⟩ := reachBall_exists_short_walk G x M hy + obtain ⟨l,hl,he,_⟩ := walk_lift_bonds G Set.univ q.reverse + have hlen : l.length ≤ M := by + have hh := congrArg List.length he + have hh' : l.length = q.length := by + simpa only [List.length_map,SimpleGraph.Walk.length_edges, + SimpleGraph.Walk.length_reverse] using hh + exact hh'.le.trans hq + exact reachBall_mono G y hlen hl.mem_reachBall + +theorem ball_multiplicity_bound (G : BondGraph V E) (hloc : LocallyFinite G) + (d : ℕ) (hd : ∀ x, degree G x ≤ d) (M : ℕ) (W : Finset V) + (f : V → ℝ) (hf : ∀ x, 0 ≤ f x) : + (∑ a ∈ W, ∑ c ∈ W, if c ∈ reachBall G a M then f c else 0) ≤ + ((d+1)^M : ℕ) * ∑ c ∈ W, f c := by + rw [Finset.sum_comm,Finset.mul_sum] + apply Finset.sum_le_sum + intro c _ + have hs : W.filter (fun a => c ∈ reachBall G a M) ⊆ + (finite_reachBall hloc c M).toFinset := by + intro a ha + exact (finite_reachBall hloc c M).mem_toFinset.mpr + (mem_reachBall_symm G a c M (Finset.mem_filter.mp ha).2) + have hn : (W.filter (fun a => c ∈ reachBall G a M)).card ≤ (d+1)^M := by + apply (Finset.card_le_card hs).trans + simpa only [←Set.ncard_eq_toFinset_card] using + reachBall_ncard_le_pow G hloc d hd c M + calc + _ = ((W.filter (fun a => c ∈ reachBall G a M)).card : ℝ) * f c := by + rw [←Finset.sum_filter] + simp + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hn) (hf c) + +theorem deletedBoundaryPotential_sum_bound (G : BondGraph V E) + (hloc : LocallyFinite G) (d : ℕ) (hd : ∀ x, degree G x ≤ d) + (M : ℕ) (W : Finset V) (p : unitInterval) : + (∑ a ∈ W, deletedBoundaryPotential G hloc (W : Set V)ᶜ p a M) ≤ + ((d+1)^M : ℕ) * + ∑ c ∈ W, ∑ b ∈ neighbors G hloc c, + inducedSusceptibility G (W : Set V)ᶜ p b := by + let f (c : V) := ∑ b ∈ neighbors G hloc c, + inducedSusceptibility G (W : Set V)ᶜ p b + have he (a : V) : + deletedBoundaryPotential G hloc (W : Set V)ᶜ p a M = + ∑ c ∈ W, if c ∈ reachBall G a M then f c else 0 := by + unfold deletedBoundaryPotential + simp only [Set.mem_compl_iff,Finset.mem_coe,not_not] + have hs : (finite_reachBall hloc a M).toFinset.filter (· ∈ W) = + W.filter (fun c => c ∈ reachBall G a M) := by + ext c + simp only [Finset.mem_filter,Set.Finite.mem_toFinset] + exact and_comm + rw [hs,Finset.sum_filter] + simp_rw [he] + exact ball_multiplicity_bound G hloc d hd M W f + (fun c => Finset.sum_nonneg (fun b _ => inducedSusceptibility_nonneg G _ p b)) + +theorem inducedSusceptibility_ball_bound [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (D : Set V) + (p : unitInterval) (hp : 0 < (p : ℝ)) (a b : V) (M : ℕ) + (ha : a ∉ D) (hb : b ∈ reachBall G a M) + (hfin : ∀ c, Summable (fun z => (law p).real + {η | Conn G (η ∩ internalEdges G D) c z})) : + inducedSusceptibility G D p b ≤ + (p : ℝ)^(-(M : ℤ)) * deletedBoundaryPotential G hloc D p a M := by + obtain ⟨q,hq⟩ := reachBall_exists_short_walk G a M hb + obtain ⟨l,hl,he,ho⟩ := walk_lift_bonds G Set.univ q + have hlen : l.length ≤ M := by + have hh : l.length = q.length := by + simpa only [List.length_map,SimpleGraph.Walk.length_edges] using congrArg List.length he + exact hh.le.trans hq + have hh := short_path_deleted_potential_bound G hloc D p hp Set.univ a b M + l hl hlen ho hfin + simpa only [deletedLocalPotential,ite_eq_right ha,zero_add] using hh + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/BoundedLayerShift.lean b/lean/OAI/Probability/BenjaminiSchramm/BoundedLayerShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f59947dcb421793f383c624f44abf66cc0a0114 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/BoundedLayerShift.lean @@ -0,0 +1,113 @@ +import OAI.Probability.BenjaminiSchramm.CeilingBandTransport +import OAI.Probability.BenjaminiSchramm.LayerFirstMoments +import OAI.Probability.BenjaminiSchramm.IntegerLayerFirstVisit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma restrictedLayerCount_expectation_le_row_bound (p : unitInterval) + (C : ℝ≥0∞) (hrow : ∀ z, (∑' y, law p {ω | Conn G ω z y}) ≤ C) + (I : Set E) (A : Set V) (x : V) : + (∫⁻ ω, restrictedLayerCount G I A ω x ∂law p) ≤ C := by + rw [lintegral_restrictedLayerCount] + apply le_trans _ (hrow x) + apply ENNReal.tsum_le_tsum + intro y + split_ifs + · exact measure_mono fun ω hω => conn_mono G Set.inter_subset_left hω + · exact bot_le + +theorem first_layer_moment_bound_with_row (p : unitInterval) + (C : ℝ≥0∞) (hrow : ∀ z, (∑' y, law p {ω | Conn G ω z y}) ≤ C) + (f : V → ℤ) (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + f w ≤ f v+1 ∧ f v ≤ f w+1) + (I : Set E) (A : Set V) (x : V) (n : ℤ) + (hx : f x < n) (hA : ∀ y ∈ A, n ≤ f y) : + (∫⁻ ω, restrictedLayerCount G I A ω x ∂law p) ≤ + (∫⁻ ω, restrictedLayerCount G (internalEdges G {v | f v ≤ n}) + {v | f v=n} ω x ∂law p)*C := by + have hfirst := integer_first_layer_moment_bound G f hjump I A p x n hx hA + have hprefix (z : V) : + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ n})) x z} ≤ + law p {ω | Conn G (ω ∩ internalEdges G {v | f v ≤ n}) x z} := + measure_mono (fun ω hω => conn_mono G + (Set.inter_subset_inter_right _ Set.inter_subset_right) hω) + calc + _ ≤ ∑' z, (if f z=n then + law p {ω | Conn G (ω ∩ internalEdges G {v | f v ≤ n}) x z} else 0)*C := by + apply hfirst.trans + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z=n + · simp only [ite_eq_left hz] + exact mul_le_mul' (hprefix z) + (restrictedLayerCount_expectation_le_row_bound G p C hrow I A z) + · simp only [ite_eq_right hz,zero_mul,le_refl] + _ = _ := by + rw [ENNReal.tsum_mul_right] + congr 1 + rw [lintegral_restrictedLayerCount] + apply tsum_congr + intro z + by_cases hz : f z=n <;> simp [hz] + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma adjustedCeilingBandCount_eq_restrictedLayerCount + (a : V → ℝ) (c l u : ℝ) (ω : Set E) (x : V) : + G.adjustedCeilingBandCount a c l u ω x = restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ c}) + {v | l ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ u} ω x := by + apply tsum_congr + intro y + by_cases hc : Percolation.Conn G.ends + (ω ∩ Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ c}) x y + <;> by_cases hl : l ≤ G.orbitAdjustedHeight a x y + <;> by_cases hu : G.orbitAdjustedHeight a x y ≤ u + <;> simp [adjustedCeilingBandTransport,hc,hl,hu] + +theorem expected_ceilingBandCount_le_intermediate_upLayerMoment [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (n : ℕ) (hn : 0 < n) (x : V) (c l u : ℝ) (hlower : R*n ≤ l) : + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p) ≤ + G.adjustedUpLayerMoment a R p n x 0*C := by + simp_rw [G.adjustedCeilingBandCount_eq_restrictedLayerCount a c l u] + let f := G.adjustedLayerIndex a R 0 x + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → f w ≤ f v+1 ∧ f v ≤ f w+1 := by + intro e v w hv hw + have hh := G.adjustedLayerIndex_edge_jump hc hl a R 0 hR hjump x v w e hv hw + dsimp only [f] + exact ⟨hh.2,by omega⟩ + have hx : f x < (n : ℤ) := by + simp only [f,G.adjustedLayerIndex_self] + exact_mod_cast hn + have hA : ∀ y ∈ {v | l ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ u}, + (n : ℤ) ≤ f y := by + intro y hy + simp only [f,adjustedLayerIndex,add_zero,Int.floor_zero,sub_zero] + apply Int.le_floor.mpr + apply (le_div_iff₀ hR).mpr + have hlow : (n : ℝ)*R ≤ l := by nlinarith [hlower] + exact hlow.trans hy.1 + exact first_layer_moment_bound_with_row G.ends p C hrow f hj _ _ x n hx hA + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/BoundedOrbitDescent.lean b/lean/OAI/Probability/BenjaminiSchramm/BoundedOrbitDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecef5d9f98cd6dc33d4bb13d3242735108f57d5c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/BoundedOrbitDescent.lean @@ -0,0 +1,81 @@ +import OAI.Probability.BenjaminiSchramm.UniformHeightDescent + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma walk_height_support_bound {V : Type*} {H : SimpleGraph V} + (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hj : ∀ {v w}, H.Adj v w → |f w-f v| ≤ R) + {x y : V} (p : H.Walk x y) : + ∀ v ∈ p.support, |f v-f x| ≤ (p.length : ℝ)*R := by + induction p with + | @nil u => + intro v hv + have he : v=u := List.mem_singleton.mp hv + simp only [he,sub_self,abs_zero,SimpleGraph.Walk.length_nil,Nat.cast_zero,zero_mul,le_refl] + | @cons x z y hxy p ih => + intro v hv + rcases List.mem_cons.mp hv with rfl | hv + · simp only [sub_self,abs_zero,SimpleGraph.Walk.length_cons,Nat.cast_add,Nat.cast_one] + positivity + · calc + _ = |(f v-f z)+(f z-f x)| := by congr 1; ring + _ ≤ |f v-f z|+|f z-f x| := abs_add_le _ _ + _ ≤ (p.length : ℝ)*R+R := add_le_add (ih v hv) (hj hxy) + _ = _ := by rw [SimpleGraph.Walk.length_cons,Nat.cast_add,Nat.cast_one]; ring + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_bounded_orbit_below [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) : + ∃ N : ℕ, ∃ M : ℝ, 0 < M ∧ ∀ x (j : G.VertexOrbit), ∃ y, + ∃ w : G.fullGraph.Walk x y, G.vertexOrbit y=j ∧ w.length ≤ N ∧ + (∀ v ∈ w.support, -M ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0) ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ≤ -R := by + obtain ⟨A,B,hA,hB,hpath⟩ := G.stationaryOrbitHeight_orbit_below hc hl hq μ hμ hstat hu + let N : ℕ := ⌈A*R+B⌉₊ + let M : ℝ := (N : ℝ)*R+R + refine ⟨N,M,by dsimp [M]; positivity,fun x j => ?_⟩ + obtain ⟨y,w,hy,hlen,hw,hend⟩ := hpath R hR.le x j + have hlenN : w.length ≤ N := by + exact_mod_cast hlen.trans (Nat.le_ceil (A*R+B)) + let a := G.stationaryOrbitWeight μ + let f := G.orbitAdjustedHeight a x + have hj {v v' : V} (hv : G.fullGraph.Adj v v') : |f v'-f v| ≤ R := by + obtain ⟨⟨e,_he,heq⟩,_hne⟩ := (SimpleGraph.fromEdgeSet_adj _).mp hv + have hh := hjump e v v' (by rw [heq]; simp) (by rw [heq]; simp) + have he : f v'-f v=G.orbitAdjustedHeight a v v' := by + dsimp [f] + rw [G.orbitAdjustedHeight_change_base hc hl _ x v v',add_sub_cancel_left] + rwa [he] + refine ⟨y,w,hy,hlenN,fun v hv => ⟨?_,hw v hv⟩,hend⟩ + have hh := walk_height_support_bound f R hR.le hj w v hv + have hf : f x=0 := G.orbitAdjustedHeight_self a x + rw [hf,sub_zero] at hh + have hN : (w.length : ℝ)*R ≤ (N : ℝ)*R := + mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hlenN) hR.le + have hv' := (abs_le.mp hh).1 + change -M ≤ f v + dsimp [M] + linarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/Cayley.lean b/lean/OAI/Probability/BenjaminiSchramm/Cayley.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3a1e557c584daa6c4b05280a939275bfbbd496a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/Cayley.lean @@ -0,0 +1,138 @@ +import OAI.Probability.BenjaminiSchramm.FullConclusion +import Mathlib.Combinatorics.SimpleGraph.Cayley + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u +variable {Λ : Type u} [Group Λ] +attribute [local instance] Classical.decEq + +abbrev CayleyEdge (S : Finset Λ) := (SimpleGraph.mulCayley (S : Set Λ)).edgeSet + +def cayleyBond (S : Finset Λ) : BondGraph Λ (CayleyEdge S) := Subtype.val + +theorem cayleyBond_adj (S : Finset Λ) (x y : Λ) : + Adj (cayleyBond S) x y ↔ (SimpleGraph.mulCayley (S : Set Λ)).Adj x y := + (SimpleGraph.adj_iff_exists_edge_coe).symm + +def cayleyLeftIso (S : Finset Λ) (a : Λ) : + SimpleGraph.mulCayley (S : Set Λ) ≃g SimpleGraph.mulCayley (S : Set Λ) where + toEquiv := Equiv.mulLeft a + map_rel_iff' := SimpleGraph.mulCayley_adj_mul_iff_right + +theorem cayleyLeft_isAut (S : Finset Λ) (a : Λ) : + IsAut (cayleyBond S) (Equiv.mulLeft a) (cayleyLeftIso S a).mapEdgeSet := by + intro e + rfl + +theorem cayleyBond_quasiTransitive (S : Finset Λ) : QuasiTransitive (cayleyBond S) := by + classical + refine ⟨{1}, ?_⟩ + intro x + exact ⟨1, by simp, Equiv.mulLeft x, (cayleyLeftIso S x).mapEdgeSet, + cayleyLeft_isAut S x, mul_one x⟩ + +theorem cayleyBond_locallyFinite (S : Finset Λ) + (hsym : ∀ s ∈ S, s⁻¹ ∈ S) : LocallyFinite (cayleyBond S) := by + classical + let H := SimpleGraph.mulCayley (S : Set Λ) + intro x + have hn : (H.neighborSet x).Finite := by + apply (S.finite_toSet.image (fun s => x * s)).subset + intro y hy + obtain ⟨_, s, hs, h | h⟩ := (SimpleGraph.mulCayley_adj' (S : Set Λ) x y).mp hy + · exact ⟨s, hs, h⟩ + · exact ⟨s⁻¹, hsym s hs, by simp only [h, mul_inv_cancel_right]⟩ + have hi : (H.incidenceSet x).Finite := by + apply (hn.image (fun y => s(x, y))).subset + intro e he + exact ⟨H.otherVertexOfIncident he, H.incidence_other_prop he, + Sym2.other_spec' he.2⟩ + apply Set.Finite.of_finite_image (f := fun e : CayleyEdge S => e.val) + · apply hi.subset + rintro e ⟨f, hf, rfl⟩ + exact ⟨f.property, hf⟩ + · exact Subtype.val_injective.injOn + +theorem cayleyBond_connected (S : Finset Λ) + (hgen : Subgroup.closure (S : Set Λ) = ⊤) : Connected (cayleyBond S) := by + have htranslate (a : Λ) {x y : Λ} + (h : Relation.ReflTransGen (Adj (cayleyBond S)) x y) : + Relation.ReflTransGen (Adj (cayleyBond S)) (a * x) (a * y) := by + induction h with + | refl => exact .refl + | tail _ h ih => exact ih.tail (adj_aut _ (cayleyLeft_isAut S a) h) + have hreverse {x y : Λ} (h : Relation.ReflTransGen (Adj (cayleyBond S)) x y) : + Relation.ReflTransGen (Adj (cayleyBond S)) y x := by + induction h with + | refl => exact .refl + | tail _ h ih => exact (Relation.ReflTransGen.single (adj_symm _ h)).trans ih + have hroot (y : Λ) : Relation.ReflTransGen (Adj (cayleyBond S)) 1 y := by + have hy : y ∈ Subgroup.closure (S : Set Λ) := by rw [hgen]; trivial + induction hy using Subgroup.closure_induction with + | mem s hs => + by_cases h : (1 : Λ) = s + · simpa only [← h] using (Relation.ReflTransGen.refl (a := (1 : Λ))) + · exact .single ((cayleyBond_adj S 1 s).mpr + ((SimpleGraph.mulCayley_adj' (S : Set Λ) 1 s).mpr + ⟨h, s, hs, Or.inl (one_mul s)⟩)) + | one => exact .refl + | mul a b _ _ ha hb => exact ha.trans (by simpa using htranslate a hb) + | inv a _ ha => simpa using htranslate a⁻¹ (hreverse ha) + intro x y + simpa using htranslate x (hroot (x⁻¹ * y)) + +def FolnerAmenable (Λ : Type u) [Group Λ] : Prop := + ∀ K : Finset Λ, ∀ ε : ℝ, 0 < ε → ∃ A : Finset Λ, A.Nonempty ∧ + ∀ k ∈ K, (((A.image (fun x => x * k)) \ A).card : ℝ) < ε * A.card + +theorem folnerAmenable_of_finite [Finite Λ] : FolnerAmenable Λ := by + classical + let : Fintype Λ := Fintype.ofFinite Λ + intro K ε hε + refine ⟨Finset.univ, Finset.univ_nonempty, ?_⟩ + intro k _hk + simpa using + mul_pos hε (Nat.cast_pos.mpr (Fintype.card_pos : 0 < Fintype.card Λ)) + +theorem infinite_of_not_folnerAmenable (hna : ¬ FolnerAmenable Λ) : Infinite Λ := by + by_contra h + let : Finite Λ := not_infinite_iff_finite.mp h + exact hna folnerAmenable_of_finite + +def CayleyFolnerInput (Λ : Type u) [Group Λ] : Prop := + ¬ FolnerAmenable Λ → ∀ S : Finset Λ, (∀ s ∈ S, s⁻¹ ∈ S) → + Subgroup.closure (S : Set Λ) = ⊤ → 0 < hV (cayleyBond S) + +def PublishedPhaseInput {V E : Type*} (G : BondGraph V E) : Prop := + ∀ p : unitInterval, pc G < p → p < pu G → + ∀ᵐ ω ∂law p, (infiniteClusters G ω).Infinite + +theorem cayley_conditional + (S : Finset Λ) (hsym : ∀ s ∈ S, s⁻¹ ∈ S) (_hone : 1 ∉ S) + (hgen : Subgroup.closure (S : Set Λ) = ⊤) (hna : ¬ FolnerAmenable Λ) + (hfolner : CayleyFolnerInput Λ) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision (cayleyBond S)) + (subdivision_injective (cayleyBond S)) + (subdivision_connected (cayleyBond S) (cayleyBond_connected S hgen)) + (subdivision_locallyFinite (cayleyBond S) (cayleyBond_locallyFinite S hsym)) → + pc (subdivision (cayleyBond S)) < ptwo (subdivision (cayleyBond S))) + (hphase : PublishedPhaseInput (cayleyBond S)) : + OperatorBounded (cayleyBond S) (pc (cayleyBond S)) ∧ + MainConclusion (cayleyBond S) ∧ + ∀ p : unitInterval, pc (cayleyBond S) < p → p < pu (cayleyBond S) → + ∀ᵐ ω ∂law p, (infiniteClusters (cayleyBond S) ω).Infinite := by + let : Infinite Λ := infinite_of_not_folnerAmenable hna + have hm := main_conditional (cayleyBond S) (cayleyBond_connected S hgen) + (cayleyBond_locallyFinite S hsym) (cayleyBond_quasiTransitive S) + (hfolner hna S hsym hgen) hutchcroft2019 + exact ⟨(operatorNorm_lt_top_iff _ _).mp hm.2.1, hm, hphase⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CayleyCritical.lean b/lean/OAI/Probability/BenjaminiSchramm/CayleyCritical.lean new file mode 100644 index 0000000000000000000000000000000000000000..34a18b07c36f4a4ca63dbb566a24c4f0a7f866c8 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CayleyCritical.lean @@ -0,0 +1,58 @@ +import OAI.Probability.BenjaminiSchramm.CayleyInputs + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u +variable {Λ : Type u} [Group Λ] + +theorem cayleyRootTransport (S : Finset Λ) : + RootTransport (fun _ : Unit => (1 : Λ)) (fun _ => (1 : ℝ)) + (vertexAut (cayleyBond S)) := by + intro m hm _hrow _hcol + simp only [Complex.ofReal_one, one_mul, Finset.univ_unique, Finset.sum_singleton] + calc + ∑' y, m 1 y = ∑' y, m y⁻¹ 1 := by + apply tsum_congr + intro y + have h := hm (Equiv.mulLeft y⁻¹) + ⟨(cayleyLeftIso S y⁻¹).mapEdgeSet, cayleyLeft_isAut S y⁻¹⟩ 1 y + simpa using h.symm + _ = ∑' x, m x 1 := (Equiv.inv Λ).tsum_eq (fun x => m x 1) + +theorem cayleyRootCover (S : Finset Λ) : + ∀ x : Λ, ∃ _i : Unit, ∃ a ∈ vertexAut (cayleyBond S), a 1 = x := by + intro x + exact ⟨(), Equiv.mulLeft x, + ⟨(cayleyLeftIso S x).mapEdgeSet, cayleyLeft_isAut S x⟩, mul_one x⟩ + +theorem cayley_critical_bounded + (S : Finset Λ) (hsym : ∀ s ∈ S, s⁻¹ ∈ S) (_hone : 1 ∉ S) + (hgen : Subgroup.closure (S : Set Λ) = ⊤) (hna : ¬ FolnerAmenable Λ) : + OperatorBounded (cayleyBond S) (pc (cayleyBond S)) := by + classical + let : Infinite Λ := infinite_of_not_folnerAmenable hna + have hconn := cayleyBond_connected S hgen + have hloc := cayleyBond_locallyFinite S hsym + have hqt := cayleyBond_quasiTransitive S + have hh := cayleyFolnerInput_proved hna S hsym hgen + let : Countable Λ := countable_vertices hloc hconn + let : Countable (CayleyEdge S) := countable_edges hloc + have htr := cayleyRootTransport S + have hcov := cayleyRootCover S + have hw : ∀ _ : Unit, (0 : ℝ) < 1 := fun _ => zero_lt_one + have hw1 : ∑ _ : Unit, (1 : ℝ) = 1 := by simp + have hf := critical_finite_of_transport (cayleyBond S) hconn hloc hqt hh + (fun _ : Unit => (1 : Λ)) (fun _ => (1 : ℝ)) + (vertexAut (cayleyBond S)) (Set.Subset.refl _) htr hcov hw hw1 + have hb := critical_bounded_of_transport_finiteness (cayleyBond S) + Subtype.val_injective hconn hloc hqt hh + (fun _ : Unit => (1 : Λ)) (fun _ => (1 : ℝ)) htr hcov hw hw1 (fun _ => hf 1) + exact hb + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CayleyInputs.lean b/lean/OAI/Probability/BenjaminiSchramm/CayleyInputs.lean new file mode 100644 index 0000000000000000000000000000000000000000..b525953eb5fd49cc28a4442d91375160b64a02cd --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CayleyInputs.lean @@ -0,0 +1,112 @@ +import OAI.Probability.BenjaminiSchramm.Cayley + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u +variable {Λ : Type u} [Group Λ] +attribute [local instance] Classical.decEq + +noncomputable def rightDefect (A : Finset Λ) (g : Λ) : ℕ := + ((A.image (fun x => x * g)) \ A).card + +theorem rightDefect_mul (A : Finset Λ) (a b : Λ) : + rightDefect A (a * b) ≤ rightDefect A a + rightDefect A b := by + have hsub : A.image (fun x => x * (a * b)) \ A ⊆ + ((A.image (fun x => x * a) \ A).image (fun x => x * b)) ∪ + (A.image (fun x => x * b) \ A) := by + intro x hx + obtain ⟨hx, hnot⟩ := Finset.mem_sdiff.mp hx + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hx + by_cases hya : y * a ∈ A + · exact Finset.mem_union_right _ (Finset.mem_sdiff.mpr + ⟨Finset.mem_image.mpr ⟨y * a, hya, mul_assoc y a b⟩, hnot⟩) + · exact Finset.mem_union_left _ (Finset.mem_image.mpr + ⟨y * a, Finset.mem_sdiff.mpr ⟨Finset.mem_image.mpr ⟨y, hy, rfl⟩, hya⟩, + mul_assoc y a b⟩) + exact (Finset.card_le_card hsub).trans + ((Finset.card_union_le _ _).trans + (Nat.add_le_add (Finset.card_image_le) le_rfl)) + +theorem rightDefect_inv (A : Finset Λ) (a : Λ) : rightDefect A a⁻¹ = rightDefect A a := by + have hinj : Function.Injective (fun x : Λ => x * a) := mul_left_injective a + have himage : (A.image (fun x => x * a⁻¹) \ A).image (fun x => x * a) = + A \ A.image (fun x => x * a) := by + rw [Finset.image_sdiff _ _ hinj, Finset.image_image] + simp only [Function.comp_def, inv_mul_cancel_right, Finset.image_id'] + calc + rightDefect A a⁻¹ = ((A.image (fun x => x * a⁻¹) \ A).image (fun x => x * a)).card := + (Finset.card_image_of_injective _ hinj).symm + _ = (A \ A.image (fun x => x * a)).card := congrArg Finset.card himage + _ = rightDefect A a := Finset.card_sdiff_comm + (Finset.card_image_of_injective A hinj).symm + +theorem rightDefect_generator (S A : Finset Λ) (s : Λ) (hs : s ∈ S) + (hsym : ∀ s ∈ S, s⁻¹ ∈ S) : + rightDefect A s ≤ (vertexBoundary (cayleyBond S) A).ncard := by + have hf := finite_vertexBoundary (cayleyBond S) (cayleyBond_locallyFinite S hsym) A + change (A.image (fun x => x * s) \ A).card ≤ _ + rw [← Set.ncard_coe_finset] + apply Set.ncard_le_ncard _ hf + intro y hy + obtain ⟨hy, hnot⟩ := Finset.mem_sdiff.mp hy + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hy + refine ⟨hnot, x, hx, (cayleyBond_adj S x (x * s)).mpr ?_⟩ + apply (SimpleGraph.mulCayley_adj' (S : Set Λ) x (x * s)).mpr + exact ⟨fun h => hnot (h ▸ hx), s, hs, Or.inl rfl⟩ + +theorem rightDefect_word_bound (S : Finset Λ) (hsym : ∀ s ∈ S, s⁻¹ ∈ S) + (hgen : Subgroup.closure (S : Set Λ) = ⊤) (g : Λ) : + ∃ L : ℕ, ∀ A : Finset Λ, + rightDefect A g ≤ L * (vertexBoundary (cayleyBond S) A).ncard := by + have hg : g ∈ Subgroup.closure (S : Set Λ) := by rw [hgen]; trivial + induction hg using Subgroup.closure_induction with + | mem s hs => exact ⟨1, fun A => by simpa using rightDefect_generator S A s hs hsym⟩ + | one => exact ⟨0, fun A => by simp [rightDefect]⟩ + | mul a b _ _ ha hb => + obtain ⟨La, ha⟩ := ha + obtain ⟨Lb, hb⟩ := hb + exact ⟨La + Lb, fun A => (rightDefect_mul A a b).trans + (by simpa only [Nat.add_mul] using Nat.add_le_add (ha A) (hb A))⟩ + | inv a _ ha => + obtain ⟨L, ha⟩ := ha + exact ⟨L, fun A => by rw [rightDefect_inv]; exact ha A⟩ + +theorem folnerAmenable_of_cayley_hV_nonpos (S : Finset Λ) + (hsym : ∀ s ∈ S, s⁻¹ ∈ S) (hgen : Subgroup.closure (S : Set Λ) = ⊤) + (hh : hV (cayleyBond S) ≤ 0) : FolnerAmenable Λ := by + intro K ε hε + choose L hL using rightDefect_word_bound S hsym hgen + let M : ℕ := (∑ k ∈ K, L k) + 1 + have hM : (0 : ℝ) < M := by dsimp [M]; positivity + have hset : {r : ℝ | ∃ A : Finset Λ, A.Nonempty ∧ + r = (vertexBoundary (cayleyBond S) A).ncard / (A.card : ℝ)}.Nonempty := + ⟨_, {1}, by simp, rfl⟩ + obtain ⟨r, ⟨A, hA, rfl⟩, hr⟩ := exists_lt_of_csInf_lt hset + (hh.trans_lt (div_pos hε hM)) + have hcard : (0 : ℝ) < A.card := Nat.cast_pos.mpr hA.card_pos + have hbound : (M : ℝ) * (vertexBoundary (cayleyBond S) A).ncard < ε * A.card := by + have ht := (div_lt_iff₀ hcard).mp hr + have hh' : ((vertexBoundary (cayleyBond S) A).ncard : ℝ) * M < ε * A.card := + (lt_div_iff₀ hM).mp (by simpa only [div_mul_eq_mul_div] using ht) + calc + (M : ℝ) * (vertexBoundary (cayleyBond S) A).ncard = + (vertexBoundary (cayleyBond S) A).ncard * (M : ℝ) := mul_comm _ _ + _ < ε * A.card := hh' + refine ⟨A, hA, ?_⟩ + intro k hk + have hkM : L k ≤ M := (Finset.single_le_sum (fun _ _ => Nat.zero_le _) hk).trans + (Nat.le_add_right _ 1) + have hd : rightDefect A k ≤ M * (vertexBoundary (cayleyBond S) A).ncard := + (hL k A).trans (Nat.mul_le_mul_right _ hkM) + exact lt_of_le_of_lt (by exact_mod_cast hd) hbound + +theorem cayleyFolnerInput_proved : CayleyFolnerInput Λ := by + intro hna S hsym hgen + by_contra hh + exact hna (folnerAmenable_of_cayley_hV_nonpos S hsym hgen (le_of_not_gt hh)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CayleyTheorem.lean b/lean/OAI/Probability/BenjaminiSchramm/CayleyTheorem.lean new file mode 100644 index 0000000000000000000000000000000000000000..aeb9a21baec9aa0c59610c15c120eb35e5a6bde1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CayleyTheorem.lean @@ -0,0 +1,31 @@ +import OAI.Probability.BenjaminiSchramm.CayleyCritical +import OAI.Probability.BenjaminiSchramm.PhaseInput +import OAI.Probability.BenjaminiSchramm.ExponentialDecay + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u +variable {Λ : Type u} [Group Λ] + +theorem cayley_main + (S : Finset Λ) (hsym : ∀ s ∈ S, s⁻¹ ∈ S) (_hone : 1 ∉ S) + (hgen : Subgroup.closure (S : Set Λ) = ⊤) (hna : ¬ FolnerAmenable Λ) : + OperatorBounded (cayleyBond S) (pc (cayleyBond S)) ∧ + MainConclusion (cayleyBond S) ∧ + ∀ p : unitInterval, pc (cayleyBond S) < p → p < pu (cayleyBond S) → + ∀ᵐ ω ∂law p, (infiniteClusters (cayleyBond S) ω).Infinite := by + let : Infinite Λ := infinite_of_not_folnerAmenable hna + have hconn := cayleyBond_connected S hgen + have hloc := cayleyBond_locallyFinite S hsym + have hqt := cayleyBond_quasiTransitive S + have hb := cayley_critical_bounded S hsym _hone hgen hna + exact ⟨hb, mainConclusion_of_critical_bounded (cayleyBond S) hconn hloc hqt hb, + publishedPhaseInput_proved (cayleyBond S) hconn hloc hqt⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CeilingBandTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/CeilingBandTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc699da2fc8536e3ad094adb051ffe49afa6445e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CeilingBandTransport.lean @@ -0,0 +1,163 @@ +import OAI.Probability.BenjaminiSchramm.NormalizedLayerTransport +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def adjustedCeilingBandTransport (a : V → ℝ) (c l u : ℝ) + (ω : Set E) (x y : V) : ℝ≥0∞ := + if Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u then 1 else 0 + +def adjustedCeilingBandCount (a : V → ℝ) (c l u : ℝ) + (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, G.adjustedCeilingBandTransport a c l u ω x y + +lemma measurable_adjustedCeilingBandTransport [Countable V] [Countable E] + (a : V → ℝ) (c l u : ℝ) (x y : V) : + Measurable (fun ω => G.adjustedCeilingBandTransport a c l u ω x y) := by + have hm : Measurable (fun ω : Set E => ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c}) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact Measurable.ite (((Percolation.measurableSet_conn G.ends x y).mem.comp hm).and + measurable_const).setOf measurable_const measurable_const + +lemma adjustedCeilingBandTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (c l u : ℝ) + (φ : G.Aut) (ω : Set E) (x y : V) : + G.adjustedCeilingBandTransport a c l u (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.adjustedCeilingBandTransport a c l u ω x y := by + have hD : φ.vertex ⁻¹' {z | G.orbitAdjustedHeight a (φ.vertex x) z ≤ c} = + {z | G.orbitAdjustedHeight a x z ≤ c} := by + ext z + simp only [Set.mem_preimage,Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] + have hmask : φ.edge ⁻¹' (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a (φ.vertex x) z ≤ c}) = + ω ∩ Percolation.internalEdges G.ends {z | G.orbitAdjustedHeight a x z ≤ c} := by + rw [Set.preimage_inter,Set.preimage_image_eq _ φ.edge.injective, + ←Percolation.internalEdges_aut_preimage G.ends φ.preserves,hD] + unfold adjustedCeilingBandTransport + rw [←Percolation.conn_aut_iff G.ends φ.preserves,hmask, + G.orbitAdjustedHeight_aut a ha] + +lemma adjusted_ceiling_connection_change_root + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (ω : Set E) (x y v w : V) (c d : ℝ) + (hcd : c ≤ d+G.orbitAdjustedHeight a x y) + (hconn : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c}) v w) : + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a y z ≤ d}) v w := by + apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hconn + intro z hz + change G.orbitAdjustedHeight a x z ≤ c at hz + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + change G.orbitAdjustedHeight a y z ≤ d + linarith + +lemma adjustedCeilingBandTransport_weight_bounds + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (c l u : ℝ) (ω : Set E) (x y : V) : + ENNReal.ofReal (Real.exp (-u))*G.adjustedCeilingBandTransport a (c-u) (-u) (-l) ω y x ≤ + G.adjustedCeilingBandTransport a c l u ω x y* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) ∧ + G.adjustedCeilingBandTransport a c l u ω x y* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) ≤ + ENNReal.ofReal (Real.exp (-l))*G.adjustedCeilingBandTransport a (c-l) (-u) (-l) ω y x := by + have hrev := G.orbitAdjustedHeight_reverse hc hl a x y + constructor + · by_cases ht : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a y z ≤ c-u}) y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l + · have hs : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u := by + refine ⟨G.adjusted_ceiling_connection_change_root hc hl a ω y x x y (c-u) c + (by linarith [ht.2.1]) (Percolation.conn_symm G.ends _ ht.1), + by linarith [ht.2.2],by linarith [ht.2.1]⟩ + simp only [adjustedCeilingBandTransport,ite_eq_left ht,ite_eq_left hs,mul_one,one_mul] + exact ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr ht.2.1) + · simp only [adjustedCeilingBandTransport,ite_eq_right ht,mul_zero] + exact bot_le + · by_cases hs : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u + · have ht : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a y z ≤ c-l}) y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l := by + refine ⟨G.adjusted_ceiling_connection_change_root hc hl a ω x y y x c (c-l) + (by linarith [hs.2.1]) (Percolation.conn_symm G.ends _ hs.1), + by linarith [hs.2.2],by linarith [hs.2.1]⟩ + simp only [adjustedCeilingBandTransport,ite_eq_left ht,ite_eq_left hs,mul_one,one_mul] + exact ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr ht.2.2) + · simp only [adjustedCeilingBandTransport,ite_eq_right hs,zero_mul] + exact bot_le + +theorem expected_adjustedCeilingBandCount_reciprocity [Countable V] [Countable E] + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (p : unitInterval) (c l u : ℝ) : + ENNReal.ofReal (Real.exp (-u))* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω x ∂G.law p)) ≤ + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p)) ∧ + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p)) ≤ + ENNReal.ofReal (Real.exp (-l))* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω x ∂G.law p)) := by + have he := OrbitRepresentatives.random_normalized_tilted_transport G O hc hl a hapos ha p + (G.adjustedCeilingBandTransport a c l u) (G.measurable_adjustedCeilingBandTransport a c l u) + (G.adjustedCeilingBandTransport_aut a ha c l u) + change (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p)) = _ at he + rw [he] + constructor + · rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro y _ + have hb (ω : Set E) : ENNReal.ofReal (Real.exp (-u))* + G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω y ≤ + ∑' x, G.adjustedCeilingBandTransport a c l u ω x y* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) := by + rw [adjustedCeilingBandCount,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum fun x => + (G.adjustedCeilingBandTransport_weight_bounds hc hl a c l u ω x y).1 + calc + _ = ENNReal.ofReal (a y)*(∫⁻ ω, ENNReal.ofReal (Real.exp (-u))* + G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω y ∂G.law p) := by + rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] + ring + _ ≤ _ := mul_le_mul' le_rfl (lintegral_mono hb) + · rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro y _ + have hb (ω : Set E) : + (∑' x, G.adjustedCeilingBandTransport a c l u ω x y* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x))) ≤ + ENNReal.ofReal (Real.exp (-l))* + G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω y := by + rw [adjustedCeilingBandCount,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum fun x => + (G.adjustedCeilingBandTransport_weight_bounds hc hl a c l u ω x y).2 + calc + _ ≤ ENNReal.ofReal (a y)*(∫⁻ ω, ENNReal.ofReal (Real.exp (-l))* + G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω y ∂G.law p) := + mul_le_mul' le_rfl (lintegral_mono hb) + _ = _ := by rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top]; ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CeilingBandUniform.lean b/lean/OAI/Probability/BenjaminiSchramm/CeilingBandUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..e98010f79f8369e1903d6acbf3daf96faec21ed3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CeilingBandUniform.lean @@ -0,0 +1,77 @@ +import OAI.Probability.BenjaminiSchramm.BoundedLayerShift + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma measurable_adjustedCeilingBandCount (a : V → ℝ) (c l u : ℝ) (x : V) : + Measurable (fun ω => G.adjustedCeilingBandCount a c l u ω x) := + Measurable.tsum fun y => G.measurable_adjustedCeilingBandTransport a c l u x y + +omit [Countable V] [Countable E] in +lemma adjustedCeilingBandCount_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (c l u : ℝ) + (φ : G.Aut) (ω : Set E) (x : V) : + G.adjustedCeilingBandCount a c l u (φ.edge '' ω) (φ.vertex x) = + G.adjustedCeilingBandCount a c l u ω x := by + unfold adjustedCeilingBandCount + rw [←φ.vertex.tsum_eq] + simp only [G.adjustedCeilingBandTransport_aut a ha c l u] + +lemma expected_adjustedCeilingBandCount_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (c l u : ℝ) + (φ : G.Aut) (p : unitInterval) (x : V) : + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω (φ.vertex x) ∂G.law p) = + ∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p := by + conv_lhs => rw [←G.law_map_aut p φ] + rw [lintegral_map (G.measurable_adjustedCeilingBandCount a c l u _) + (BernoulliProduct.measurable_image_equiv φ.edge)] + simp only [G.adjustedCeilingBandCount_aut a ha c l u] + +theorem expected_ceilingBandCount_uniform_bound + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (p : unitInterval) (c l u : ℝ) (x : V) : + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p) ≤ + ((ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r)))* + ENNReal.ofReal (Real.exp (-l))* + (⨆ y, ∫⁻ ω, G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω y ∂G.law p) := by + have hroot : ENNReal.ofReal m* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p) ≤ + ∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω r ∂G.law p) := by + obtain ⟨r,hr,φ,rfl⟩ := O.cover x + rw [G.expected_adjustedCeilingBandCount_aut a ha c l u φ p r] + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (ham r)) le_rfl).trans + (Finset.single_le_sum (f := fun r => ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω r ∂G.law p)) + (fun _ _ => bot_le) hr) + have hsum : (∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω r ∂G.law p)) ≤ + (∑ r ∈ O.roots, ENNReal.ofReal (a r))* + (⨆ y, ∫⁻ ω, G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω y ∂G.law p) := by + rw [Finset.sum_mul] + exact Finset.sum_le_sum fun r _ => mul_le_mul' le_rfl + (le_iSup (fun y => ∫⁻ ω, G.adjustedCeilingBandCount a (c-l) (-u) (-l) ω y ∂G.law p) r) + have hh := hroot.trans ((G.expected_adjustedCeilingBandCount_reciprocity + O hc hl a hapos ha p c l u).2.trans (mul_le_mul' le_rfl hsum)) + calc + _ = (ENNReal.ofReal m)⁻¹*(ENNReal.ofReal m* + (∫⁻ ω, G.adjustedCeilingBandCount a c l u ω x ∂G.law p)) := by + rw [←mul_assoc,ENNReal.inv_mul_cancel (ne_of_gt (ENNReal.ofReal_pos.mpr hm)) + ENNReal.ofReal_ne_top,one_mul] + _ ≤ _ := (mul_le_mul' le_rfl hh).trans_eq (by ring) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CeilingDownCrudeProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/CeilingDownCrudeProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..1050914d79f4dd4872bf7337fdd29bb35732cb07 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CeilingDownCrudeProfile.lean @@ -0,0 +1,161 @@ +import OAI.Probability.BenjaminiSchramm.UniformHeightDescent +import OAI.Probability.BenjaminiSchramm.FirstHeightPeakWalk +import OAI.Probability.BenjaminiSchramm.SlabFractionalProfileShift + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_bounded_descent_to_level + [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ k : ℝ, 0 ≤ k → ∀ x, + ∃ y, ∃ w : G.fullGraph.Walk x y, (w.length : ℝ) ≤ A*k+B ∧ + -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ≤ -k ∧ + ∀ v ∈ w.support, G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ≤ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0 := by + obtain ⟨ε,hε,L,hstep⟩ := G.stationaryOrbitHeight_uniform_descent hc hl hq μ hμ hstat hu + let a := G.stationaryOrbitWeight μ + refine ⟨(L : ℝ)/ε+1,L,by positivity,Nat.cast_nonneg _,fun k hk x => ?_⟩ + let n := ⌈k/ε⌉₊ + have hn : k ≤ (n : ℝ)*ε := (div_le_iff₀ hε).mp (Nat.le_ceil (k/ε)) + have hn' : (n : ℝ) ≤ k/ε+1 := (Nat.ceil_lt_add_one (div_nonneg hk hε.le)).le + obtain ⟨y,w,hwlen,hw,hwy⟩ := G.height_descent_iterate hc hl a ε hε.le L hstep n x + let f := fun v => -G.orbitAdjustedHeight a x v + have hj : ∀ {u v}, G.fullGraph.Adj u v → |f v-f u| ≤ R := by + intro u v huv + have huv' : (Percolation.openSimpleGraph G.ends Set.univ).Adj u v := by + rw [←criticalModel_openGraph G.ends Set.univ] + exact huv + obtain ⟨e,_he,he⟩ := huv'.2 + have hv := hjump e u v (by rw [he]; simp) (by rw [he]; simp) + have hh : |G.orbitAdjustedHeight a x v-G.orbitAdjustedHeight a x u| ≤ R := by + rw [G.orbitAdjustedHeight_change_base hc hl a x u v] + simpa only [add_sub_cancel_left] using hv + simpa only [f,neg_sub_neg,abs_sub_comm] using hh + obtain ⟨z,q,hqlen,hz,hzR,hbound⟩ := first_height_peak_walk f R hR hj w 0 k + (by simp [f]) (by simpa [f] using hk) (by dsimp [f]; linarith) + (fun v hv => by dsimp [f]; exact neg_nonneg.mpr (hw v hv)) + refine ⟨z,q,?_,by dsimp [f] at hzR; linarith,by dsimp [f] at hz; linarith,?_⟩ + · have hqn : q.length ≤ n*L := hqlen.trans hwlen + have hqn' : (q.length : ℝ) ≤ (n : ℝ)*L := by exact_mod_cast hqn + have hm := mul_le_mul_of_nonneg_right hn' (Nat.cast_nonneg L : (0 : ℝ) ≤ L) + calc + _ ≤ (n : ℝ)*L := hqn' + _ ≤ (k/ε+1)*L := hm + _ = ((L : ℝ)/ε+1)*k+L-k := by ring + _ ≤ ((L : ℝ)/ε+1)*k+L := by linarith + · intro v hv + have hh := hbound v hv + dsimp [f] at hh + exact ⟨by linarith [hh.2],by linarith [hh.1]⟩ + +variable [Countable V] [Countable E] + +theorem ceiling_down_crude_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (Vcoef : ℝ) (hV : 0 < Vcoef) + (hzero : ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ c}) + {v | -2*R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 2*R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (Vcoef*c))) : + ∃ T : ℝ, 0 < T ∧ ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (T*k)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpaths⟩ := G.stationaryOrbitHeight_bounded_descent_to_level + hc hl hq μ hμ hstat hu R hR.le hjump + let δ := min (p : ℝ) (1-p) + have hδ : 0 < δ := lt_min hp0 (sub_pos.mpr hp1) + have hδ1 : δ ≤ 1 := (min_le_left _ _).trans p.2.2 + let s := -Real.log δ + have hs : 0 ≤ s := neg_nonneg.mpr (Real.log_nonpos hδ.le hδ1) + let T := s*A+Vcoef+1 + refine ⟨T,by dsimp [T]; positivity,fun q hq0 hq1 => ?_⟩ + obtain ⟨D,hD,hbound⟩ := hzero q hq0 hq1 + refine ⟨D*ENNReal.ofReal (Real.exp (s*B+Vcoef*R)), + ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top,fun k hk x => ?_⟩ + obtain ⟨y,w,hlen,hylo,hyhi,hw⟩ := hpaths k hk x + let h := G.orbitAdjustedHeight a x y + let I := Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ 0} + let J := Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a y v ≤ -h} + let W : Set V := {v | -k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+R} + let Z : Set V := {v | -2*R ≤ G.orbitAdjustedHeight a y v ∧ G.orbitAdjustedHeight a y v ≤ 2*R} + have hIJ : I ⊆ J := Percolation.internalEdges_mono G.ends (by + intro v hv + change G.orbitAdjustedHeight a x v ≤ 0 at hv + change G.orbitAdjustedHeight a y v ≤ -h + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + dsimp [h] + linarith) + have hWZ : W ⊆ Z := by + intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + change -k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+R at hv + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + let f : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by rw [←criticalModel_openGraph G.ends Set.univ]; exact h⟩ + obtain ⟨F,hF,hconn⟩ := walk_finite_open_restriction G.ends (w.reverse.map f) + {v | G.orbitAdjustedHeight a y v ≤ -h} (by + intro v hv + have hv' : v ∈ w.support := by + rw [SimpleGraph.Walk.support_map] at hv + change v ∈ w.reverse.support.map id at hv + simpa only [List.map_id_fun,id_eq,SimpleGraph.Walk.support_reverse,List.mem_reverse] using hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + dsimp [h] + linarith [(hw v hv').2]) + have hcard : F.card ≤ w.length := by + simpa only [SimpleGraph.Walk.length_map,SimpleGraph.Walk.length_reverse] using hF + have hcost : ENNReal.ofReal (δ^w.length) ≤ ENNReal.ofReal (δ^F.card) := + ENNReal.ofReal_le_ofReal (pow_le_pow_of_le_one hδ.le hδ1 hcard) + have hXY := (mul_le_mul' hcost le_rfl).trans + (forced_path_fractional_layer_comparison G.ends p F I J W Z hIJ hWZ y x hconn hq0.le) + have hcancel := finite_energy_cancel_length _ _ δ A B k w.length hδ hδ1 hlen hXY + have hceil : 0 ≤ -h := by dsimp [h]; linarith + have hmoment := hbound (-h) hceil y + apply hcancel.trans ((mul_le_mul' le_rfl hmoment).trans ?_) + have he : -Real.log δ*(A*k+B)+Vcoef*(-h) ≤ (s*B+Vcoef*R)+T*k := by + have hh : -h ≤ k+R := by dsimp [h]; linarith + have hh' := mul_le_mul_of_nonneg_left hh hV.le + dsimp [s,T] + nlinarith + calc + _ = D*ENNReal.ofReal (Real.exp (-Real.log δ*(A*k+B)+Vcoef*(-h))) := by + rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ D*ENNReal.ofReal (Real.exp ((s*B+Vcoef*R)+T*k)) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CeilingZeroBand.lean b/lean/OAI/Probability/BenjaminiSchramm/CeilingZeroBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a61f80a48f536e55ccf20ef3ee4485a08997003 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CeilingZeroBand.lean @@ -0,0 +1,155 @@ +import OAI.Probability.BenjaminiSchramm.SlabExtensionGeometry +import OAI.Probability.BenjaminiSchramm.GeometricIncrement + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem ceiling_zero_band_from_profiles + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (d : ℕ) (hd : ∀ u, (Percolation.finite_neighbors hl u).toFinset.card ≤ d) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → |G.orbitAdjustedHeight a u v| ≤ R) + (p : unitInterval) (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (T U : ℝ) (hT : 0 < T) (hU : 0 < U) + (hdown : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → ζ ≤ 1 → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount a (-k) c (-k-R) (-k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k+T*c))) + (hup : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount a (-r) (k+r) (k-R) (k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k+U*r))) : + ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ c}) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((T+U+1)*c)) := by + intro q hq0 hq1 + let b := (q+1)/2 + have hb : 0 < b := by dsimp [b]; positivity + have hb1 : b < 1 := by dsimp [b]; linarith + have hqb : q ≤ b*b := by dsimp [b]; nlinarith [sq_nonneg (q-1)] + obtain ⟨D,hD,hdb⟩ := hdown b hb hb1 (b/4) (by positivity) (by linarith) + obtain ⟨A,hA,hab⟩ := hup b hb hb1 (1/2) (by norm_num) + obtain ⟨B,hB,hbb⟩ := hup (b*b) (mul_pos hb hb) (by nlinarith) (1/2) (by norm_num) + let A' := A*ENNReal.ofReal (Real.exp (U*R)) + have hA' : A' < ⊤ := ENNReal.mul_lt_top hA ENNReal.ofReal_lt_top + let K := (d : ℝ≥0∞)^b*D*(A')^b + have hK : K < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.rpow_lt_top_of_nonneg hb.le (ENNReal.natCast_ne_top d)) hD) + (ENNReal.rpow_lt_top_of_nonneg hb.le hA'.ne) + let s := b*R/4 + have hs : 0 < s := by dsimp [s]; positivity + let S : ℝ≥0∞ := ∑' n : ℕ, ENNReal.ofReal (Real.exp (-s*n)) + have hS : S < ⊤ := by + apply Summable.tsum_ofReal_lt_top + simpa only [mul_comm] using Real.summable_exp_nat_mul_iff.mpr (neg_neg_of_pos hs) + refine ⟨B+K*S,ENNReal.add_lt_top.mpr ⟨hB,ENNReal.mul_lt_top hK hS⟩,fun c hc0 x => ?_⟩ + let F (n : ℕ) := ∫⁻ ω, (G.adjustedSlabBandCount a (-(n : ℝ)*R) c (-R) R ω x)^(b*b) ∂G.law p + let W := ENNReal.ofReal (Real.exp ((T+U+1)*c)) + have h0 : F 0 ≤ B*W := by + simp only [F,Nat.cast_zero,neg_zero,zero_mul] + have hh := hbb 0 (by norm_num) c hc0 x + simp only [zero_sub,zero_add,mul_zero] at hh + apply le_trans _ (hh.trans ?_) + · apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ (mul_nonneg hb.le hb.le) + simp only [G.adjustedSlabBandCount_eq_restricted] + apply restrictedLayerCount_mono_edges G.ends + apply Percolation.internalEdges_mono G.ends + intro v hv + exact ⟨by linarith [hv.1],hv.2⟩ + · exact mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr (by + have hh := mul_nonneg (by linarith : 0 ≤ T+1) hc0 + nlinarith))) + have hstep (n : ℕ) : F (n+1) ≤ F n+K*W*ENNReal.ofReal (Real.exp (-s*n)) := by + let L := A'*ENNReal.ofReal (Real.exp (-(n : ℝ)*R/2+U*c)) + have hL (z : V) (hzlo : -((n : ℝ)+1)*R ≤ G.orbitAdjustedHeight a x z) + (hzhi : G.orbitAdjustedHeight a x z < -(n : ℝ)*R) : + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -((n : ℝ)+1)*R ≤ G.orbitAdjustedHeight a x v ∧ + G.orbitAdjustedHeight a x v ≤ c}) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} ω z)^b ∂G.law p) ≤ L := by + have hnn : (0 : ℝ) ≤ (n : ℝ)*R := mul_nonneg (Nat.cast_nonneg _) hR.le + have hh := hab (-G.orbitAdjustedHeight a x z) (by linarith) (c+R) (by positivity) z + apply le_trans _ (hh.trans ?_) + · apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ hb.le + apply G.lower_extension_frontier_count_bound hc hl a R c hc0 n x z + · simpa only [Nat.cast_add,Nat.cast_one] using hzlo + · exact hzhi + · dsimp [L,A'] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + linarith + have hh := G.lower_extension_fractional_recurrence hc hl a d hd R c hR.le hc0 hjump + p hfin n x hb hb1.le hb hb1.le L hL + have hdownn := hdb ((n : ℝ)*R) (by positivity) c hc0 x + simp only [←neg_mul] at hdownn + have hcast : ((n+1 : ℕ) : ℝ)=(n : ℝ)+1 := by norm_cast + simp only [F,hcast] + apply hh.trans + apply add_le_add le_rfl + apply (mul_le_mul' (mul_le_mul' le_rfl hdownn) le_rfl).trans + have hprod := fractional_two_profile_product D A' (b/4) T (-1/2) U + ((n : ℝ)*R) c 1 b (by norm_num) hb.le + simp only [ENNReal.rpow_one] at hprod + calc + _ = (d : ℝ≥0∞)^b*((D*ENNReal.ofReal (Real.exp (b/4*((n : ℝ)*R)+T*c)))*L^b) := by ac_rfl + _ = K*ENNReal.ofReal (Real.exp ((b/4+b*(-1/2))*((n : ℝ)*R)+(T+b*U)*c)) := by + dsimp [L,K] + rw [show -(n : ℝ)*R/2+U*c=(-1/2)*((n : ℝ)*R)+U*c by ring,hprod] + ac_rfl + _ ≤ K*ENNReal.ofReal (Real.exp ((T+U+1)*c+(-s*(n : ℝ)))) := by + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_right (mul_le_of_le_one_left hU.le hb1.le) hc0 + dsimp [s] + nlinarith + _ = _ := by + dsimp [W,K] + rw [Real.exp_add ((T+U+1)*c) (-s*(n : ℝ)),ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + ac_rfl + have hF := geometric_increment_factored F B K W s h0 hstep + have hlimit : (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ c}) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} ω x)^(b*b) ∂G.law p) ≤ + (B+K*S)*W := by + have hh := restrictedLayerMoment_iUnion G.ends + (fun n : ℕ => Percolation.internalEdges G.ends + {v | -(n : ℝ)*R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ c}) + (internalEdges_lowerSlabs_monotone G.ends _ R c hR.le) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} x p (mul_pos hb hb) + rw [internalEdges_lowerSlabs_iUnion G.ends _ R c hR] at hh + simp only [CriticalPercolation.BondGraph.law,Percolation.law] at hh ⊢ + rw [hh] + apply iSup_le + intro n + simpa only [F,G.adjustedSlabBandCount_eq_restricted,CriticalPercolation.BondGraph.law,Percolation.law] using hF n + apply le_trans _ hlimit + apply lintegral_mono + intro ω + dsimp only + rcases restrictedLayerCount_zero_or_one_le G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ c}) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} ω x with hz | ho + · rw [hz,ENNReal.zero_rpow_of_pos hq0,ENNReal.zero_rpow_of_pos (mul_pos hb hb)] + · exact ENNReal.rpow_le_rpow_of_exponent_le ho hqb + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ClusterExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/ClusterExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..7faad4f7a307c06ee6b5881e6da785c2bb66f440 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ClusterExposure.lean @@ -0,0 +1,70 @@ +import OAI.Probability.BenjaminiSchramm.BlockExposure +import OAI.Probability.CriticalPercolation.Clusters.ClusterObject +import OAI.Probability.CriticalPercolation.Clusters.ComponentSelf + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma exactCluster_dependsOn (x : V) (S : Set V) : + DependsOn (fun ω : Set E => G.cluster ω x = S) (G.incidentEdges S) := by + intro ω η hω + apply propext + have hforward (ω η : Set E) (hωη : ∀ e ∈ G.incidentEdges S, e ∈ ω ↔ e ∈ η) + (hS : G.cluster ω x = S) : G.cluster η x = S := by + have hr : ClusterDeletion.roots (G.openGraph ω) {x} = S := by + simpa only [ClusterDeletion.roots_singleton, ClusterDeletion.component, cluster] using hS + have hr' := G.roots_eq_of_incident hr hωη + simpa only [ClusterDeletion.roots_singleton, ClusterDeletion.component, cluster] using hr' + exact ⟨hforward ω η (fun e he => (hω e he).to_iff), + hforward η ω (fun e he => (hω e he).symm.to_iff)⟩ + +lemma measurable_eraseVertices (S : Set V) : Measurable (fun ω => G.eraseVertices ω S) := by + refine (@measurable_pi_iff (Set E) E (fun _ => Prop) + inferInstance (fun _ => inferInstance) _).mpr ?_ + intro e + exact (measurable_set_mem e).and measurable_const + +lemma measurableSet_exactCluster [Countable V] [Countable E] (x : V) (S : Set V) : + MeasurableSet {ω | G.cluster ω x = S} := by + have heq : {ω | G.cluster ω x = S} = + ⋂ y : V, {ω | (G.openGraph ω).Reachable x y ↔ y ∈ S} := by + ext ω + simp only [Set.mem_ofPred_eq, Set.mem_iInter] + exact Set.ext_iff + rw [heq] + exact MeasurableSet.iInter fun y => ((G.measurable_reachable x y).iff measurable_const).setOf + +theorem exactCluster_exterior_factor [Countable V] [Countable E] + (p : unitInterval) (x : V) (S : Set V) (F : Set E → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ ω, ({ω | G.cluster ω x = S} : Set (Set E)).indicator + (fun ω => F (G.eraseVertices ω S)) ω ∂G.law p) = + G.law p {ω | G.cluster ω x = S} * + ∫⁻ η, F (G.eraseVertices η S) ∂G.law p := by + unfold law + rw [← BernoulliProduct.law_const] + apply BernoulliProduct.lintegral_indicator_fresh (fun _ => p) (G.incidentEdges S) + _ (G.measurableSet_exactCluster x S) (G.exactCluster_dependsOn x S) + _ (hF.comp (G.measurable_eraseVertices S)) + intro ω η hωη + exact congrArg F (G.eraseVertices_dependsOn S hωη) + +lemma exactCluster_exterior_le [Countable V] [Countable E] + (p : unitInterval) (x : V) (S : Set V) (F : Set E → ℝ≥0∞) (hF : Measurable F) + (B : ℝ≥0∞) (hB : (∫⁻ η, F (G.eraseVertices η S) ∂G.law p) ≤ B) : + (∫⁻ ω, ({ω | G.cluster ω x = S} : Set (Set E)).indicator + (fun ω => F (G.eraseVertices ω S)) ω ∂G.law p) ≤ + G.law p {ω | G.cluster ω x = S} * B := by + rw [G.exactCluster_exterior_factor p x S F hF] + exact mul_le_mul' le_rfl hB + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CombinatorialUnimodularOperator.lean b/lean/OAI/Probability/BenjaminiSchramm/CombinatorialUnimodularOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3cb687c17d4e354f789568b99eb193c6c85e61c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CombinatorialUnimodularOperator.lean @@ -0,0 +1,131 @@ +import OAI.Probability.BenjaminiSchramm.GeneralCriticalFiniteness +import OAI.Probability.UnimodularPercolation.Criticality.Operator +import OAI.Probability.CriticalPercolation.Modular.UnimodularGeometric + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical BigOperators Topology + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma tendsto_vertexBall_tsum (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (f : V → ℝ) (hf : Summable f) (x : V) : + Tendsto (fun n : ℕ => ∑' y, if y ∈ G.vertexBall x n then f y else 0) + atTop (𝓝 (∑' y, f y)) := by + let S (n : ℕ) := (G.vertexBall_finite hl x n).toFinset + have hmono : Monotone S := by + intro n m hnm y hy + exact (G.vertexBall_finite hl x m).mem_toFinset.mpr + (G.vertexBall_mono x hnm ((G.vertexBall_finite hl x n).mem_toFinset.mp hy)) + have hcover : ∀ y, ∃ n, y ∈ S n := by + intro y + obtain ⟨n,hn⟩ := G.reachable_mem_vertexBall (hc x y) + exact ⟨n,(G.vertexBall_finite hl x n).mem_toFinset.mpr hn⟩ + have ht := hf.hasSum.comp (hmono.tendsto_atTop_finset hcover) + have he (n : ℕ) : (∑' y, if y ∈ G.vertexBall x n then f y else 0)=∑ y ∈ S n, f y := by + rw [tsum_eq_sum (s := S n) (fun y hy => + ite_eq_right (fun h => hy ((G.vertexBall_finite hl x n).mem_toFinset.mpr h)))] + exact Finset.sum_congr rfl (fun y hy => ite_eq_left ((G.vertexBall_finite hl x n).mem_toFinset.mp hy)) + simpa only [he,Function.comp_def] using ht + +lemma UnimodularRoot.balance_summable (R : G.UnimodularRoot) + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (F : V → V → ℝ) + (hF : ∀ (φ : G.Aut) u v, F (φ.vertex u) (φ.vertex v)=F u v) + (hrow : ∀ u, Summable (F u)) (hcol : ∀ v, Summable (fun u => F u v)) : + (∑ u ∈ R.roots, R.weight u*∑' v, F u v)= + ∑ v ∈ R.roots, R.weight v*∑' u, F u v := by + let Fn (n : ℕ) (u v : V) := if v ∈ G.vertexBall u n then F u v else 0 + have hFn (n : ℕ) (φ : G.Aut) (u v : V) : Fn n (φ.vertex u) (φ.vertex v)=Fn n u v := by + simp only [Fn,Aut.vertexBall_mem,hF] + have hrowfin (n : ℕ) (u : V) : (Function.support (Fn n u)).Finite := by + apply (G.vertexBall_finite hl u n).subset + intro v hv + by_contra hn + exact hv (by simp only [Fn,ite_eq_right hn]) + have hcolfin (n : ℕ) (v : V) : (Function.support (fun u => Fn n u v)).Finite := by + apply (G.vertexBall_finite hl v n).subset + intro u hu + by_contra hn + have hnu : v ∉ G.vertexBall u n := fun h => hn (G.vertexBall_comm.mp h) + exact hu (by simp only [Fn,ite_eq_right hnu]) + have hbal (n : ℕ) := R.balance (Fn n) (hFn n) (hrowfin n) (hcolfin n) + have htrow (u : V) : Tendsto (fun n : ℕ => ∑' v, Fn n u v) atTop (𝓝 (∑' v, F u v)) := + G.tendsto_vertexBall_tsum hc hl (F u) (hrow u) u + have htcol (v : V) : Tendsto (fun n : ℕ => ∑' u, Fn n u v) atTop (𝓝 (∑' u, F u v)) := by + have he (n : ℕ) : (∑' u, Fn n u v)=∑' u, if u ∈ G.vertexBall v n then F u v else 0 := by + apply tsum_congr + intro u + dsimp [Fn] + rw [G.vertexBall_comm] + simpa only [he] using G.tendsto_vertexBall_tsum hc hl (fun u => F u v) (hcol v) v + have htout : Tendsto (fun n => ∑ u ∈ R.roots, R.weight u*∑' v, Fn n u v) + atTop (𝓝 (∑ u ∈ R.roots, R.weight u*∑' v, F u v)) := + tendsto_finsetSum _ (fun u _ => tendsto_const_nhds.mul (htrow u)) + have htin : Tendsto (fun n => ∑ v ∈ R.roots, R.weight v*∑' u, Fn n u v) + atTop (𝓝 (∑ v ∈ R.roots, R.weight v*∑' u, F u v)) := + tendsto_finsetSum _ (fun v _ => tendsto_const_nhds.mul (htcol v)) + exact tendsto_nhds_unique htout (by simpa only [hbal] using htin) + +end CriticalPercolation.BondGraph + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma criticalModel_unimodularRoot_transport [Nonempty V] + (hc : Connected G) (hl : LocallyFinite G) + (R : (criticalModel G).UnimodularRoot) : + RootTransport (fun r : {x // x ∈ R.roots} => (r : V)) + (fun r => R.weight r) (vertexAut G) := by + intro m hm hrow hcol + have hHc := criticalModel_connected G hc + have hma (φ : (criticalModel G).Aut) (x y : V) : + m (φ.vertex x) (φ.vertex y)=m x y := hm φ.vertex ⟨φ.edge,φ.preserves⟩ x y + have hre := R.balance_summable (criticalModel G) hHc hl + (fun x y => (m x y).re) (fun φ x y => congrArg Complex.re (hma φ x y)) + (fun x => Complex.reCLM.summable (hrow x)) (fun y => Complex.reCLM.summable (hcol y)) + have him := R.balance_summable (criticalModel G) hHc hl + (fun x y => (m x y).im) (fun φ x y => congrArg Complex.im (hma φ x y)) + (fun x => Complex.imCLM.summable (hrow x)) (fun y => Complex.imCLM.summable (hcol y)) + dsimp only + rw [Finset.sum_coe_sort R.roots (fun x => (R.weight x : ℂ)*∑' y, m x y), + Finset.sum_coe_sort R.roots (fun y => (R.weight y : ℂ)*∑' x, m x y)] + have hsumre (s : Finset V) (f : V → ℂ) : (∑ v ∈ s, f v).re=∑ v ∈ s, (f v).re := by + simpa only [Complex.reCLM_apply] using map_sum Complex.reCLM f s + have hsumim (s : Finset V) (f : V → ℂ) : (∑ v ∈ s, f v).im=∑ v ∈ s, (f v).im := by + simpa only [Complex.imCLM_apply] using map_sum Complex.imCLM f s + apply Complex.ext + · simpa only [hsumre,Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero, + Complex.re_tsum (hrow _),Complex.re_tsum (hcol _)] using hre + · simpa only [hsumim,Complex.mul_im,Complex.ofReal_re,Complex.ofReal_im,zero_mul,add_zero, + Complex.im_tsum (hrow _),Complex.im_tsum (hcol _)] using him + +theorem critical_bounded_of_combinatorial_unimodular [Infinite V] + (hG : Function.Injective G) (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hh : 0 < hV G) + (hu : (criticalModel G).CombinatoriallyUnimodular) : + OperatorBounded G (pc G) := by + let H := criticalModel G + let R := CriticalPercolation.BondGraph.CombinatoriallyUnimodular.unimodularRoot H hu + (criticalModel_connected G hc) hl (criticalModel_quasiTransitive G hq) (Classical.arbitrary V) + have htr := criticalModel_unimodularRoot_transport G hc hl R + have hcov : ∀ x, ∃ r : {x // x ∈ R.roots}, ∃ g ∈ vertexAut G, g (r : V)=x := by + intro x + obtain ⟨r,hr,φ,hφ⟩ := R.cover x + exact ⟨⟨r,hr⟩,φ.vertex,⟨φ.edge,φ.preserves⟩,hφ⟩ + have hw : ∀ r : {x // x ∈ R.roots}, 0 < R.weight r := fun r => R.positive r r.property + have hw1 : (∑ r : {x // x ∈ R.roots}, R.weight r)=1 := by + rw [Finset.sum_coe_sort] + exact R.normalized + exact critical_bounded_of_transport_finiteness G hG hc hl hq hh + (fun r : {x // x ∈ R.roots} => (r : V)) (fun r => R.weight r) htr hcov hw hw1 + (fun r => critical_finite_general G hc hl hq (pc_lt_one_of_nonamenable G hc hl hq hh) r) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/Consequences.lean b/lean/OAI/Probability/BenjaminiSchramm/Consequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ba9c4b6373954db3ea16dc93ad1c30f545a4ff3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/Consequences.lean @@ -0,0 +1,98 @@ +import OAI.Probability.BenjaminiSchramm.OperatorGap +import OAI.Probability.BenjaminiSchramm.PublishedConsequences + +namespace OAI + +open MeasureTheory Filter +open scoped Topology + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem percolationProbability_mono [Countable V] [Countable E] + (G : BondGraph V E) (x : V) : Monotone (fun p => percolationProbability G p x) := by + have heq (p : unitInterval) : law p {ω | (cluster G ω x).Infinite} = + labelLaw {labels : E → unitInterval | (cluster G (openEdges labels p) x).Infinite} := by + rw [← map_openEdges p, Measure.map_apply (measurable_openEdges p) + (measurableSet_infinite_cluster G x)] + rfl + intro p q hpq + change ((law p) {ω | (cluster G ω x).Infinite}).toReal ≤ + ((law q) {ω | (cluster G ω x).Infinite}).toReal + rw [heq p, heq q] + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono + intro labels h + exact h.mono (fun y hy => conn_mono G (openEdges_mono labels hpq) hy) + +theorem critical_finite_of_probabilityLaw [Countable V] [Countable E] + (G : BondGraph V E) (hpc : pc G < 1) (htheta : PercolationProbabilityLaw G) : + ∀ x, ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite := by + intro x + obtain ⟨c, C, δ, _hc, _hC, hδ, hb⟩ := htheta x + obtain ⟨p, _hp, hmem, hlim⟩ := exists_seq_strictAnti_tendsto' hpc + have hreal : Tendsto (fun n => (p n : ℝ) - (pc G : ℝ)) atTop (𝓝 0) := by + simpa using (continuous_subtype_val.tendsto (pc G) |>.comp hlim).sub_const (pc G : ℝ) + have hnear : ∀ᶠ n in atTop, (p n : ℝ) - (pc G : ℝ) < δ := + (tendsto_order.mp hreal).2 δ hδ + have hzero : percolationProbability G (pc G) x ≤ 0 := by + have hlim' : Tendsto (fun n => C * ((p n : ℝ) - (pc G : ℝ))) atTop (𝓝 0) := by + simpa using hreal.const_mul C + apply ge_of_tendsto hlim' + filter_upwards [hnear] with n hn + exact (percolationProbability_mono G x (hmem n).1.le).trans (hb (p n) (hmem n).1 hn).2 + have hmeasure : law (pc G) {ω | (cluster G ω x).Infinite} = 0 := by + apply (measureReal_eq_zero_iff).mp + exact le_antisymm hzero measureReal_nonneg + rw [ae_iff] + exact hmeasure + +def CriticalLawsConclusion (G : BondGraph V E) : Prop := + (∀ x, triangleDiagram G (pc G) x ≤ operatorNorm G (pc G) ^ 3 ∧ + triangleDiagram G (pc G) x < ⊤) ∧ + SusceptibilityLaw G ∧ PercolationProbabilityLaw G ∧ CriticalTailLaws G ∧ + (pc G < ptwo G ∧ ptwo G ≤ pexp G) ∧ + ∀ p : unitInterval, p < ptwo G → ExponentialDecay G p + +theorem critical_laws_of_mainConclusion [Infinite V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) (hm : MainConclusion G) + (hfirst : HutchcroftFirstMomentInput G) + (htheta : TrianglePercolationProbabilityInput G) + (hvolume : HutchcroftCriticalVolumeInput G) + (hradii : HutchcroftCriticalRadiiInput G) + (hexp : HutchcroftExponentialInput G) : + CriticalLawsConclusion G := by + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + have hb := (operatorNorm_lt_top_iff G (pc G)).mp hm.2.1 + have hθ := percolationProbabilityLaw_of_publishedInput G hgraph htheta hb + have hp1 : pc G < 1 := hm.2.2.1.trans_le (ptwo G).2.2 + have hfin := critical_finite_of_probabilityLaw G hp1 hθ + refine ⟨critical_triangle_of_mainConclusion G hm, + susceptibilityLaw_of_publishedInput G hgraph hfirst hm.2.2.1, hθ, + criticalTailLaws_of_publishedInputs G hgraph hvolume hradii hm.2.2.1 hfin, + exponential_threshold_of_mainConclusion G hgraph hexp hm, ?_⟩ + exact exponentialDecay_of_publishedInput G hgraph hexp + +theorem critical_laws_conditional [Infinite V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hgraph.connected) + (subdivision_locallyFinite G hgraph.locallyFinite) → + pc (subdivision G) < ptwo (subdivision G)) + (hfirst : HutchcroftFirstMomentInput G) + (htheta : TrianglePercolationProbabilityInput G) + (hvolume : HutchcroftCriticalVolumeInput G) + (hradii : HutchcroftCriticalRadiiInput G) + (hexp : HutchcroftExponentialInput G) : + CriticalLawsConclusion G := by + exact critical_laws_of_mainConclusion G hgraph + (main_conditional G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hh hutchcroft2019) hfirst htheta hvolume hradii hexp + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ConsistentLayers.lean b/lean/OAI/Probability/BenjaminiSchramm/ConsistentLayers.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ce3800ff80bef873d508ac2a14b6b69d5ea9bf7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ConsistentLayers.lean @@ -0,0 +1,97 @@ +import OAI.Probability.BenjaminiSchramm.NormalizedLayerTransport + +namespace OAI + +noncomputable section +open Set +open scoped Classical + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +def adjustedLayerIndex (a : V → ℝ) (R u : ℝ) (x y : V) : ℤ := + ⌊G.orbitAdjustedHeight a x y/R+u⌋-⌊u⌋ + +@[simp] lemma adjustedLayerIndex_self (a : V → ℝ) (R u : ℝ) (x : V) : + G.adjustedLayerIndex a R u x x=0 := by simp [adjustedLayerIndex] + +lemma adjustedLayerIndex_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (R u : ℝ) + (φ : G.Aut) (x y : V) : + G.adjustedLayerIndex a R u (φ.vertex x) (φ.vertex y)=G.adjustedLayerIndex a R u x y := by + simp only [adjustedLayerIndex,G.orbitAdjustedHeight_aut a ha] + +lemma adjustedLayerIndex_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R u : ℝ) (x y z : V) : + G.adjustedLayerIndex a R u x z = G.adjustedLayerIndex a R u x y+ + G.adjustedLayerIndex a R (G.orbitAdjustedHeight a x y/R+u) y z := by + unfold adjustedLayerIndex + rw [G.orbitAdjustedHeight_change_base hc hl a x y z] + have he : (G.orbitAdjustedHeight a x y+G.orbitAdjustedHeight a y z)/R+u = + G.orbitAdjustedHeight a y z/R+(G.orbitAdjustedHeight a x y/R+u) := by ring + rw [he] + ring + +lemma adjustedLayerIndex_periodic (a : V → ℝ) (R u : ℝ) (n : ℤ) (x y : V) : + G.adjustedLayerIndex a R (u+n) x y=G.adjustedLayerIndex a R u x y := by + unfold adjustedLayerIndex + rw [←add_assoc,Int.floor_add_intCast,Int.floor_add_intCast] + ring + +lemma adjustedLayerIndex_height_bounds (a : V → ℝ) (R u : ℝ) (hR : 0 < R) (x y : V) : + R*((G.adjustedLayerIndex a R u x y : ℝ)-1) < G.orbitAdjustedHeight a x y ∧ + G.orbitAdjustedHeight a x y < R*((G.adjustedLayerIndex a R u x y : ℝ)+1) := by + have h₁ := Int.floor_le (G.orbitAdjustedHeight a x y/R+u) + have h₂ := Int.lt_floor_add_one (G.orbitAdjustedHeight a x y/R+u) + have h₃ := Int.floor_le u + have h₄ := Int.lt_floor_add_one u + have he : (G.adjustedLayerIndex a R u x y : ℝ) = + (⌊G.orbitAdjustedHeight a x y/R+u⌋ : ℝ)-(⌊u⌋ : ℝ) := by + simp only [adjustedLayerIndex,Int.cast_sub] + rw [he] + constructor + · have hh : (⌊G.orbitAdjustedHeight a x y/R+u⌋ : ℝ)-(⌊u⌋ : ℝ)-1 < + G.orbitAdjustedHeight a x y/R := by linarith + have hm := (lt_div_iff₀ hR).mp hh + nlinarith + · have hh : G.orbitAdjustedHeight a x y/R < + (⌊G.orbitAdjustedHeight a x y/R+u⌋ : ℝ)-(⌊u⌋ : ℝ)+1 := by linarith + have hm := (div_lt_iff₀ hR).mp hh + nlinarith + +lemma adjustedLayerIndex_edge_jump (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R u : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight a v w| ≤ R) + (x v w : V) (e : E) (hv : v ∈ G.ends e) (hw : w ∈ G.ends e) : + G.adjustedLayerIndex a R u x v-1 ≤ G.adjustedLayerIndex a R u x w ∧ + G.adjustedLayerIndex a R u x w ≤ G.adjustedLayerIndex a R u x v+1 := by + have hh := abs_le.mp (hjump e v w hv hw) + have hcoc := G.orbitAdjustedHeight_change_base hc hl a x v w + have hdiv : G.orbitAdjustedHeight a x v/R-1 ≤ G.orbitAdjustedHeight a x w/R ∧ + G.orbitAdjustedHeight a x w/R ≤ G.orbitAdjustedHeight a x v/R+1 := by + constructor + · apply (le_div_iff₀ hR).mpr + have he : (G.orbitAdjustedHeight a x v/R-1)*R = G.orbitAdjustedHeight a x v-R := by + field_simp + rw [he] + linarith + · apply (div_le_iff₀ hR).mpr + have he : (G.orbitAdjustedHeight a x v/R+1)*R = G.orbitAdjustedHeight a x v+R := by + field_simp + rw [he] + linarith + have hlo := Int.floor_mono (add_le_add hdiv.1 (le_refl u)) + have hhi := Int.floor_mono (add_le_add hdiv.2 (le_refl u)) + have helo : G.orbitAdjustedHeight a x v/R-1+u = G.orbitAdjustedHeight a x v/R+u-1 := by ring + have hehi : G.orbitAdjustedHeight a x v/R+1+u = G.orbitAdjustedHeight a x v/R+u+1 := by ring + rw [helo,Int.floor_sub_one] at hlo + rw [hehi,Int.floor_add_one] at hhi + unfold adjustedLayerIndex + omega + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalCeilingProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalCeilingProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f4b79bcb751d4e7b472e11e17cadb09017f2c36 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalCeilingProfile.lean @@ -0,0 +1,64 @@ +import OAI.Probability.BenjaminiSchramm.CriticalSlabProfiles +import OAI.Probability.BenjaminiSchramm.CeilingZeroBand +import OAI.Probability.BenjaminiSchramm.NeighborDegreeBound + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_ceiling_zero_band_profile + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∃ A : ℝ, 0 < A ∧ ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G + (internalEdges G {v | (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ c}) + {v | -R ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ R} ω x)^q ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp (A*c)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have hp0 : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + have hp1 : (pc G : ℝ) < 1 := by exact_mod_cast hpc1 + have hfin (x : V) : ∀ᵐ ω ∂H.law (pc G), (Percolation.cluster H.ends ω x).Finite := by + simpa only [H,criticalModel,CriticalPercolation.BondGraph.law,law] using + critical_finite_general G hc hl hq hpc1 x + obtain ⟨L₁,_hL₁,hprof₁⟩ := critical_lower_slab_fractional_profile G hc hl hq hpc1 hu μ hμ hstat R hR hjump + have hjump₂ : ∀ e v w, v ∈ G e → w ∈ G e → |H.orbitAdjustedHeight a v w| ≤ 2*R := by + intro e v w hv hw + exact (hjump e v w hv hw).trans (by linarith) + obtain ⟨L₂,_hL₂,hprof₂⟩ := critical_lower_slab_fractional_profile G hc hl hq hpc1 hu μ hμ hstat + (2*R) (by positivity) hjump₂ + obtain ⟨T,hT,hshift⟩ := H.finite_ceiling_fractional_profile hHc hl hHq μ hμ hstat hu R hR hjump + (pc G) hp0 hp1 L₁ hprof₁ + obtain ⟨U,hU,hup⟩ := H.upward_fractional_slab_profile hHc hl hHq μ hμ hstat hu R hR hjump + (pc G) hp0 hp1 hfin L₁ L₂ hprof₁ hprof₂ + obtain ⟨d,hd⟩ := exists_neighbor_card_bound G hl hq + have hh := H.ceiling_zero_band_from_profiles hHc hl a d hd R hR hjump (pc G) hfin T U hT hU + (fun q hq0 hq1 ζ hζ hζ1 => by + obtain ⟨C,hC,hb⟩ := hshift q hq0 hq1 ζ hζ hζ1 + refine ⟨C,hC,fun k hk c hc0 x => ?_⟩ + simpa only [sub_zero,mul_zero,add_zero] using hb k hk 0 (by norm_num) c hc0 x) hup + refine ⟨T+U+1,by positivity,fun q hq0 hq1 => ?_⟩ + obtain ⟨C,hC,hb⟩ := hh q hq0 hq1 + refine ⟨C,hC,fun c hc0 x => ?_⟩ + simpa only [a,H,criticalModel,CriticalPercolation.BondGraph.law,law] using hb c hc0 x + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalEndpointProfiles.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalEndpointProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb7801f908a9299d84f763c414bb5dc73e3d446c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalEndpointProfiles.lean @@ -0,0 +1,71 @@ +import OAI.Probability.BenjaminiSchramm.CriticalHalfspaceProfiles +import OAI.Probability.BenjaminiSchramm.UpwardCeilingProfile +import OAI.Probability.BenjaminiSchramm.FloorDownProfile + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_endpoint_fractional_profiles + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + (∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G + (internalEdges G {v | (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ k}) + {v | k-R ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k))) ∧ + (∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G + (internalEdges G {v | -k ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v}) + {v | -k-R ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k))) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have hp0 : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + have hp1 : (pc G : ℝ) < 1 := by exact_mod_cast hpc1 + have hfin (x : V) : ∀ᵐ ω ∂H.law (pc G), (Percolation.cluster H.ends ω x).Finite := by + simpa only [H,criticalModel,CriticalPercolation.BondGraph.law,law] using + critical_finite_general G hc hl hq hpc1 x + have hjump₂ : ∀ e v w, v ∈ G e → w ∈ G e → |H.orbitAdjustedHeight a v w| ≤ 2*R := by + intro e v w hv hw + exact (hjump e v w hv hw).trans (by linarith) + have hb := critical_halfspace_fractional_profiles G hc hl hq hpc1 hu μ hμ hstat R hR hjump + have hb₂ := critical_halfspace_fractional_profiles G hc hl hq hpc1 hu μ hμ hstat (2*R) (by positivity) hjump₂ + obtain ⟨A,hA,hzero⟩ := critical_ceiling_zero_band_profile G hc hl hq hpc1 hu μ hμ hstat + (2*R) (by positivity) hjump₂ + have hzero' : ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount H.ends + (internalEdges H.ends {v | H.orbitAdjustedHeight a x v ≤ c}) + {v | -(2*R) ≤ H.orbitAdjustedHeight a x v ∧ H.orbitAdjustedHeight a x v ≤ 2*R} ω x)^q ∂H.law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp (A*c)) := by + simpa only [a,H,criticalModel,CriticalPercolation.BondGraph.law,law] using hzero + have hup := H.upward_ceiling_profile hHc hl hHq μ hμ hstat hu R hR hjump + (pc G) hp0 hp1 hfin A hA (fun q hq0 hq1 => (hb q hq0 hq1).1) hzero' + have hdown := H.floor_down_profile hHc hl hHq μ hμ hstat hu R hR hjump + (pc G) hp0 hp1 hfin (fun q hq0 hq1 => (hb q hq0 hq1).2) + (fun q hq0 hq1 => (hb₂ q hq0 hq1).2) + simpa only [a,H,criticalModel,CriticalPercolation.BondGraph.law,law] using And.intro hup hdown + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalFiniteness.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalFiniteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b35f22f7ddc32bd4b8823fdd1eae46bf0f9aa22 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalFiniteness.lean @@ -0,0 +1,46 @@ +import OAI.Probability.BenjaminiSchramm.PhaseInput +import OAI.Probability.CriticalPercolation.Criticality.LayerContradiction + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem criticalModel_percolates (G : BondGraph V E) : + (criticalModel G).percolates = {ω | (infiniteClusters G ω).Nonempty} := by + ext ω + simp only [CriticalPercolation.BondGraph.percolates, Set.mem_ofPred_eq, + criticalModel_cluster, Set.Nonempty, infiniteClusters] + constructor + · rintro ⟨x,hx⟩ + exact ⟨cluster G ω x,hx,x,rfl⟩ + · rintro ⟨C,hC,x,hx⟩ + exact ⟨x,hx ▸ hC⟩ + +theorem criticalModel_pc (G : BondGraph V E) : + (criticalModel G).criticalProbability = pc G := by + simp only [CriticalPercolation.BondGraph.criticalProbability, criticalModel_percolates, + CriticalPercolation.BondGraph.law, pc, law] + +theorem critical_finite_of_combinatorial_nonunimodular [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hpc : pc G < 1) + (hu : ¬ (criticalModel G).CombinatoriallyUnimodular) (x : V) : + ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite := by + have hz := (criticalModel G).nonunimodular_no_percolation_at_criticality + (criticalModel_connected G hconn) hloc (criticalModel_quasiTransitive G hqt) hu + (by simpa only [criticalModel_pc] using hpc) + rw [criticalModel_pc, criticalModel_percolates] at hz + change law (pc G) {ω | (infiniteClusters G ω).Nonempty} = 0 at hz + rw [ae_iff] + apply measure_mono_null _ hz + intro ω hω + exact ⟨cluster G ω x,hω,x,rfl⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalFractionalSlab.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalFractionalSlab.lean new file mode 100644 index 0000000000000000000000000000000000000000..458a832778fbcfe7d118ace390319b0a0c81b24d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalFractionalSlab.lean @@ -0,0 +1,159 @@ +import OAI.Probability.BenjaminiSchramm.FractionalSlabFromTruncation +import OAI.Probability.BenjaminiSchramm.PeakRateCancellation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma fractional_exponential_product (A B Z : ℝ≥0∞) (t u k r a δ : ℝ) + (ha : 0 ≤ a) (hδ : 0 ≤ δ) : + (A*ENNReal.ofReal (Real.exp (t*r)))^a* + (B*ENNReal.ofReal (Real.exp (u*(k+r))))^δ*Z = + (A^a*B^δ*Z)*ENNReal.ofReal (Real.exp (δ*u*k+(a*t+δ*u)*r)) := by + rw [ENNReal.mul_rpow_of_nonneg _ _ ha,ENNReal.mul_rpow_of_nonneg _ _ hδ, + ennreal_exp_rpow _ _ ha,ennreal_exp_rpow _ _ hδ] + calc + _ = (A^a*B^δ*Z)*(ENNReal.ofReal (Real.exp (t*r*a))* + ENNReal.ofReal (Real.exp (u*(k+r)*δ))) := by ac_rfl + _ = _ := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show t*r*a+u*(k+r)*δ=δ*u*k+(a*t+δ*u)*r by ring] + +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_slab_fractional_of_peak_survival + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (α : ℝ) (hα : 1 ≤ α) (hcross : ∀ t : ℝ, 0 ≤ t → + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) t).toReal ≤ Real.exp (-α*t)) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (hsurv : ∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ ell : ℝ, 0 < ell → + ENNReal.ofReal (c*Real.exp (-((α-1)+ε)*ell)) ≤ + (criticalModel G).fullPeakDownProbability + ((criticalModel G).orbitRepresentatives (criticalModel_quasiTransitive G hq)) + ((criticalModel G).stationaryOrbitWeight μ) (pc G) ell) : + ∃ L : ℝ, 0 < L ∧ ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G + (internalEdges G {z | -k-r ≤ (criticalModel G).orbitAdjustedHeight + ((criticalModel G).stationaryOrbitWeight μ) x z ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x z ≤ 0}) + {z | -k-R ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x z ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x z ≤ -k+R} + ω x)^q ∂law (pc G)) ≤ C*ENNReal.ofReal (Real.exp (ζ*k+L*r)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + let O := H.orbitRepresentatives (criticalModel_quasiTransitive G hq) + obtain ⟨M,hM,K,hK,L₁,hL₁,hcmp⟩ := critical_peak_comparison_at_rate G hc hl hq hpc1 hu + μ hμ hstat α hcross R hR hjump + obtain ⟨C₀,L₀,hC₀,hL₀,hup⟩ := critical_normalized_halfspace_exp_bound G hc hl hq hu μ hμ hstat + refine ⟨L₁+L₀,by positivity,fun q hq0 hq1 ζ hζ => ?_⟩ + let δ := min ((1-q)/2) (ζ/(L₀+1)) + have hδpos : 0 < δ := lt_min (by positivity) (div_pos hζ (by positivity)) + have hδq : δ ≤ 1-q := (min_le_left _ _).trans (by linarith) + have hδ1 : δ ≤ 1 := by linarith + have hδL : δ*L₀ ≤ ζ := by + have hle : δ ≤ ζ/(L₀+1) := min_le_right _ _ + have hm := (le_div_iff₀ (show 0 < L₀+1 by positivity)).mp hle + nlinarith + let ε := δ/(2*q) + have hε : 0 < ε := div_pos hδpos (by positivity) + have heq : ε*q=δ/2 := by dsimp [ε]; field_simp + obtain ⟨c,hcpos,hden⟩ := hsurv ε hε + let A := ENNReal.ofReal c⁻¹*K*ENNReal.ofReal (Real.exp ε) + let B := ENNReal.ofReal (C₀*Real.exp (L₀*(2*M+2*R))) + let Z := ∑' n : ℕ, ENNReal.ofReal (Real.exp ((ε*q-δ)*n)) + have hA : A < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top ENNReal.ofReal_lt_top hK) ENNReal.ofReal_lt_top + have hB : B < ⊤ := ENNReal.ofReal_lt_top + have hZ : Z < ⊤ := by + simpa only [one_mul] using fractional_height_geometric_sum_lt_top (t := ε) (s := 1) + (a := q) (δ := δ) (by rw [heq]; linarith) + let C := A^q*B^δ*Z + have hC : C < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.rpow_lt_top_of_nonneg hq0.le hA.ne) + (ENNReal.rpow_lt_top_of_nonneg hδpos.le hB.ne)) hZ + refine ⟨C,hC,fun k hk r hr x => ?_⟩ + let f := fun z => H.orbitAdjustedHeight a x z + let D := internalEdges G {z | -k-r-2*M-2*R ≤ f z} + let I := internalEdges G {z | -k-r ≤ f z ∧ f z ≤ 0} + let W : Set V := {z | -k-R ≤ f z ∧ f z ≤ -k+R} + have htrunc (n : ℕ) : (∫⁻ ω, + (restrictedHit G D x {z | 1*((n : ℝ)+1) ≤ f z})ᶜ.indicator + (fun ω => restrictedLayerCount G I W ω x) ω ∂law (pc G)) ≤ + (A*ENNReal.ofReal (Real.exp (L₁*r)))*ENNReal.ofReal (Real.exp (ε*n)) := by + have hn : (0 : ℝ) < (n : ℝ)+1 := by positivity + have hh := peak_rate_cancellation + (H.fullPeakDownProbability O a (pc G) ((n : ℝ)+1)) + (H.mixedHeightLayerMoment a (pc G) (-k-r) 0 (-k-R) (-k+R) + (-k-r-2*M-2*R) ((n : ℝ)+1) x) K c (α-1) ε ((n : ℝ)+1) k L₁ r hcpos + (hden _ hn) (hcmp k hk r hr _ hn x) + rw [H.mixedHeightLayerMoment_eq_lintegral] at hh + change (∫⁻ ω, + (restrictedHit G D x {z | (n : ℝ)+1 ≤ f z})ᶜ.indicator + (fun ω => restrictedLayerCount G I W ω x) ω ∂law (pc G)) ≤ _ at hh + simp only [one_mul] + apply hh.trans + have he : L₁*r+ε*((n : ℝ)+1)-(α-1)*k ≤ ε+L₁*r+ε*n := by + nlinarith [mul_nonneg (sub_nonneg.mpr hα) hk] + calc + _ ≤ ENNReal.ofReal c⁻¹*K*ENNReal.ofReal (Real.exp (ε+L₁*r+ε*n)) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by + dsimp [A] + rw [Real.exp_add,Real.exp_add, + ENNReal.ofReal_mul (by positivity : 0 ≤ Real.exp ε*Real.exp (L₁*r)),ENNReal.ofReal_mul (Real.exp_nonneg ε)] + ac_rfl + have hhit (n : ℕ) : law (pc G) (restrictedHit G D x {z | 1*n ≤ f z}) ≤ + (B*ENNReal.ofReal (Real.exp (L₀*(k+r))))*ENNReal.ofReal (Real.exp (-1*n)) := by + have hh := hup (k+r+2*M+2*R) (by positivity) x n (Nat.cast_nonneg n) + have he : -(k+r+2*M+2*R)= -k-r-2*M-2*R := by ring + change law (pc G) (H.adjustedHalfspaceHit a x _ _) ≤ _ at hh + unfold CriticalPercolation.BondGraph.adjustedHalfspaceHit at hh + rw [he] at hh + change law (pc G) (restrictedHit G D x {z | (n : ℝ) ≤ f z}) ≤ _ at hh + simp only [one_mul,neg_mul,one_mul] + apply hh.trans_eq + have he : C₀*Real.exp (L₀*(k+r+2*M+2*R)-(n : ℝ)) = + (C₀*Real.exp (L₀*(2*M+2*R)))*Real.exp (L₀*(k+r))*Real.exp (-(n : ℝ)) := by + rw [mul_assoc,mul_assoc,←Real.exp_add,←Real.exp_add] + congr 2 + ring + rw [he,ENNReal.ofReal_mul (by positivity : 0 ≤ C₀*Real.exp (L₀*(2*M+2*R))*Real.exp (L₀*(k+r))), + ENNReal.ofReal_mul (by positivity : 0 ≤ C₀*Real.exp (L₀*(2*M+2*R)))] + have hfin : ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite := + critical_finite_general G hc hl hq hpc1 x + have hh := layer_fractional_of_truncated_moments G (pc G) D I W f 1 zero_lt_one x + (by exact H.orbitAdjustedHeight_self a x) hfin + (A*ENNReal.ofReal (Real.exp (L₁*r))) (B*ENNReal.ofReal (Real.exp (L₀*(k+r)))) + ε htrunc hhit hq0 hq1 hδpos.le hδq + change (∫⁻ ω, (restrictedLayerCount G I W ω x)^q ∂law (pc G)) ≤ _ + apply hh.trans + simp only [one_mul] at hh ⊢ + change (A*ENNReal.ofReal (Real.exp (L₁*r)))^q* + (B*ENNReal.ofReal (Real.exp (L₀*(k+r))))^δ*Z ≤ _ + rw [fractional_exponential_product A B Z L₁ L₀ k r q δ hq0.le hδpos.le] + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hqL : q*L₁ ≤ L₁ := mul_le_of_le_one_left hL₁.le hq1.le + have hδL₀ : δ*L₀ ≤ L₀ := mul_le_of_le_one_left hL₀.le hδ1 + have hkk := mul_le_mul_of_nonneg_right hδL hk + have hrr := mul_le_mul_of_nonneg_right (add_le_add hqL hδL₀) hr + linarith + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalFullspaceProfiles.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalFullspaceProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..dddcab1d22acc5ff1ad13d13e051a4ddf581f726 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalFullspaceProfiles.lean @@ -0,0 +1,153 @@ +import OAI.Probability.BenjaminiSchramm.CriticalEndpointProfiles +import OAI.Probability.BenjaminiSchramm.FullspaceFractionalRecurrence + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_fullspace_threeQuarter_profiles + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∃ C : ℝ≥0∞, C < ⊤ ∧ + (∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G Set.univ + {v | k-R ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ k+R} ω x)^(3/4 : ℝ) ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp (-k/2))) ∧ + (∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G Set.univ + {v | -k-R ≤ (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^(3/4 : ℝ) ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp (k/16))) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + let h := H.orbitAdjustedHeight a + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have hp0 : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + have hp1 : (pc G : ℝ) < 1 := by exact_mod_cast hpc1 + have hfin := critical_finite_general G hc hl hq hpc1 + obtain ⟨d,hd⟩ := exists_neighbor_card_bound G hl hq + obtain ⟨hendup,henddown⟩ := critical_endpoint_fractional_profiles G hc hl hq hpc1 hu μ hμ hstat R hR hjump + have hhalf := critical_halfspace_fractional_profiles G hc hl hq hpc1 hu μ hμ hstat R hR hjump + have hbase (x z v : V) : h x v=h x z+h z v := H.orbitAdjustedHeight_change_base hHc hl a x z v + have hself (x : V) : h x x=0 := H.orbitAdjustedHeight_self a x + have hj (x : V) := H.height_difference_jump hHc hl a R hjump x + obtain ⟨T₁,_hT₁,hshift₁⟩ := H.halfspace_ceiling_shift_profile_fixed hHc hl hHq μ hμ hstat hu R hR.le hjump + (pc G) hp0 hp1 (1/4) + obtain ⟨D₁,hD₁,hb₁⟩ := hshift₁ (7/8) (by norm_num) ((hhalf (7/8) (by norm_num) (by norm_num)).1 (1/4) (by norm_num)) + let D₁' := D₁*ENNReal.ofReal (Real.exp (T₁*R)) + have hD₁' : D₁' < ⊤ := ENNReal.mul_lt_top hD₁ ENNReal.ofReal_lt_top + have hcont₁ (s : ℝ) (hs : 0 ≤ s) (z : V) : + (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | h z v ≤ R}) + {v | -s-R ≤ h z v ∧ h z v ≤ -s+R} ω z)^(7/8 : ℝ) ∂law (pc G)) ≤ + D₁'*ENNReal.ofReal (Real.exp ((1/4)*s)) := by + apply le_trans _ ((hb₁ s hs R hR.le z).trans_eq ?_) + · rfl + · dsimp [D₁'] + rw [Real.exp_add ((1/4)*s) (T₁*R),ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + have htop₁ : ∀ u ∈ ({(7/8 : ℝ),(7/8 : ℝ)*(7/8 : ℝ)} : Set ℝ), ∀ ε : ℝ, 0 < ε → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | h x v ≤ k}) + {v | k-R ≤ h x v ∧ h x v ≤ k+R} ω x)^u ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ε)*k)) := by + intro u hu ε hε + have hu0 : 0 < u := by + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hu + rcases hu with rfl | rfl <;> norm_num + have hu1 : u < 1 := by + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hu + rcases hu with rfl | rfl <;> norm_num + exact hendup u hu0 hu1 ε hε + obtain ⟨C₁,hC₁,hfull₁⟩ := fullspace_fractional_from_ceiling_profiles G hl d hd h hself hbase R hR + hj (pc G) hfin (7/8) (7/8) (-1) (1/4) (by norm_num) (by norm_num) (by norm_num) (by norm_num) + (by norm_num) htop₁ D₁' hD₁' hcont₁ (1/2) (by norm_num) + obtain ⟨T₂,_hT₂,hshift₂⟩ := H.halfspace_floor_shift_profile_fixed hHc hl hHq μ hμ hstat hu R hR.le hjump + (pc G) hp0 hp1 (-1+(1/2 : ℝ)) + obtain ⟨D₂,hD₂,hb₂⟩ := hshift₂ (7/8) (by norm_num) ((hhalf (7/8) (by norm_num) (by norm_num)).2 (1/2) (by norm_num)) + let D₂' := D₂*ENNReal.ofReal (Real.exp (T₂*R)) + have hD₂' : D₂' < ⊤ := ENNReal.mul_lt_top hD₂ ENNReal.ofReal_lt_top + have hnegceil (x : V) (k : ℝ) : {v | -h x v ≤ k}={v | -k ≤ h x v} := by + ext v + change (-h x v ≤ k) ↔ -k ≤ h x v + constructor <;> intro hv <;> linarith + have hnegband (x : V) (k : ℝ) : {v | k-R ≤ -h x v ∧ -h x v ≤ k+R}= + {v | -k-R ≤ h x v ∧ h x v ≤ -k+R} := by + ext v + constructor <;> intro hv <;> constructor <;> linarith [hv.1,hv.2] + have hnegcont (x : V) (k : ℝ) : {v | -k-R ≤ -h x v ∧ -h x v ≤ -k+R}= + {v | k-R ≤ h x v ∧ h x v ≤ k+R} := by + ext v + constructor <;> intro hv <;> constructor <;> linarith [hv.1,hv.2] + have hcont₂ (s : ℝ) (hs : 0 ≤ s) (z : V) : + (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | -h z v ≤ R}) + {v | -s-R ≤ -h z v ∧ -h z v ≤ -s+R} ω z)^(7/8 : ℝ) ∂law (pc G)) ≤ + D₂'*ENNReal.ofReal (Real.exp ((-1/2)*s)) := by + rw [hnegceil,hnegcont] + apply le_trans _ ((hb₂ s hs R hR.le z).trans_eq ?_) + · rfl + · dsimp [D₂'] + rw [Real.exp_add ((-1+(1/2 : ℝ))*s) (T₂*R),ENNReal.ofReal_mul (Real.exp_nonneg _)] + rw [show (-1+(1/2 : ℝ))*s=(-1/2)*s by ring] + ac_rfl + have htop₂ : ∀ u ∈ ({(7/8 : ℝ),(7/8 : ℝ)*(7/8 : ℝ)} : Set ℝ), ∀ ε : ℝ, 0 < ε → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | -h x v ≤ k}) + {v | k-R ≤ -h x v ∧ -h x v ≤ k+R} ω x)^u ∂law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp ((0+ε)*k)) := by + intro u hu ε hε + have hu0 : 0 < u := by + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hu + rcases hu with rfl | rfl <;> norm_num + have hu1 : u < 1 := by + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hu + rcases hu with rfl | rfl <;> norm_num + obtain ⟨C,hC,hb⟩ := henddown u hu0 hu1 ε hε + refine ⟨C,hC,fun k hk x => ?_⟩ + simpa only [hnegceil,hnegband,zero_add] using hb k hk x + obtain ⟨C₂,hC₂,hfull₂⟩ := fullspace_fractional_from_ceiling_profiles G hl d hd + (fun x v => -h x v) (fun x => by simp only [hself,neg_zero]) + (fun x z v => by rw [hbase]; ring) R hR + (fun x e u v hu hv => by simpa only [neg_sub_neg,abs_sub_comm] using hj x e u v hu hv) + (pc G) hfin (7/8) (7/8) 0 (-1/2) (by norm_num) (by norm_num) (by norm_num) (by norm_num) + (by norm_num) htop₂ D₂' hD₂' hcont₂ (1/16) (by norm_num) + have hmono (W : Set V) (x : V) : + (∫⁻ ω, (restrictedLayerCount G Set.univ W ω x)^(3/4 : ℝ) ∂law (pc G)) ≤ + (∫⁻ ω, (restrictedLayerCount G Set.univ W ω x)^((7/8 : ℝ)*(7/8 : ℝ)) ∂law (pc G)) := by + apply lintegral_mono + intro ω + rcases restrictedLayerCount_zero_or_one_le G Set.univ W ω x with hz | ho + · simp only [hz,ENNReal.zero_rpow_of_pos (by norm_num : (0 : ℝ) < 3/4), + ENNReal.zero_rpow_of_pos (by norm_num : (0 : ℝ) < (7/8)*(7/8)),le_refl] + · exact ENNReal.rpow_le_rpow_of_exponent_le ho (by norm_num) + refine ⟨C₁+C₂,ENNReal.add_lt_top.mpr ⟨hC₁,hC₂⟩,?_,?_⟩ + · intro k hk x + apply (hmono _ x).trans ((hfull₁ k hk x).trans ?_) + have he : (-1+(1/2 : ℝ))*k= -k/2 := by ring + rw [he] + exact mul_le_mul' le_self_add le_rfl + · intro k hk x + have hh := hfull₂ k hk x + simp only [hnegband,zero_add] at hh + apply (hmono _ x).trans (hh.trans ?_) + have he : (1/16 : ℝ)*k=k/16 := by ring + rw [he] + exact mul_le_mul' le_add_self le_rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalHalfspaceDecay.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalHalfspaceDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..d59f6015f1302a7d3c42f33d2ad82510226eca7f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalHalfspaceDecay.lean @@ -0,0 +1,79 @@ +import OAI.Probability.BenjaminiSchramm.CriticalNormalizedCrossing + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] (G : BondGraph V E) + +theorem critical_raw_halfspace_decay (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hu : ¬ (criticalModel G).CombinatoriallyUnimodular) : + ∃ C L : ℝ, 0 < C ∧ 0 < L ∧ ∀ r : ℝ, 0 ≤ r → ∀ (x : V) (t : ℝ), 0 ≤ t → + (law (pc G)).real (restrictedHit G + (internalEdges G {v | -r ≤ modularHeight G x v}) x {v | t ≤ modularHeight G x v}) ≤ + C*Real.exp (L*r-t) := by + let H := criticalModel G + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + let : Finite H.VertexOrbit := H.finite_vertexOrbits hHq + let : Fintype H.VertexOrbit := Fintype.ofFinite _ + obtain ⟨μ,hμ,_hmass,hstat⟩ := H.exists_positive_orbit_stationary hHc hl + let a := H.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hnorm⟩ := critical_normalized_halfspace_uniform G hc hl hq hu μ hμ hstat + obtain ⟨D,hD,hdiff⟩ := H.stationaryOrbitHeight_uniform_comparison hHc hl μ hμ + have hp : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + let ell := -Real.log (pc G : ℝ) + have hell : 0 ≤ ell := neg_nonneg.mpr (Real.log_nonpos hp.le (pc G).2.2) + let C := Real.exp (ell*A*D+ell*B+D) + let L := ell*A+1 + have hL : 0 < L := by dsimp [L]; positivity + refine ⟨C,L,Real.exp_pos _,hL,fun r hr x t ht => ?_⟩ + by_cases hDt : D ≤ t + · have hsub : restrictedHit G (internalEdges G {v | -r ≤ modularHeight G x v}) x + {v | t ≤ modularHeight G x v} ⊆ H.adjustedHalfspaceHit a x (-(r+D)) (t-D) := by + rintro ω ⟨y,hy,hxy⟩ + refine ⟨y,?_,conn_mono G (Set.inter_subset_inter_right _ (internalEdges_mono G ?_)) hxy⟩ + · have hd := (abs_le.mp (hdiff x y)).1 + change t ≤ H.modularLogHeight x y at hy + change t-D ≤ H.orbitAdjustedHeight a x y + linarith + · intro v hv + have hd := (abs_le.mp (hdiff x v)).1 + change -r ≤ H.modularLogHeight x v at hv + change -(r+D) ≤ H.orbitAdjustedHeight a x v + linarith + have hh := (measureReal_mono hsub).trans (hnorm (r+D) (add_nonneg hr hD) x (t-D) + (sub_nonneg.mpr hDt)) + have he : (pc G : ℝ)^(-(A*(r+D)+B))*Real.exp (-(t-D)) = + C*Real.exp (ell*A*r-t) := by + rw [Real.rpow_def_of_pos hp,← Real.exp_add] + change Real.exp _ = Real.exp (ell*A*D+ell*B+D)*Real.exp (ell*A*r-t) + rw [← Real.exp_add] + congr 1 + dsimp [ell] + ring + rw [he] at hh + apply hh.trans + apply mul_le_mul_of_nonneg_left _ (Real.exp_pos _).le + apply Real.exp_le_exp.mpr + dsimp [L] + nlinarith + · have hlo : 1 ≤ C*Real.exp (L*r-t) := by + change 1 ≤ Real.exp (ell*A*D+ell*B+D)*Real.exp (L*r-t) + rw [← Real.exp_add] + apply Real.one_le_exp_iff.mpr + have hellA := mul_nonneg hell hA.le + have hellAD := mul_nonneg hellA hD + have hellB := mul_nonneg hell hB + have hLr := mul_nonneg hL.le hr + linarith + exact (show (law (pc G)).real _ ≤ 1 by simp).trans hlo + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalHalfspaceProfiles.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalHalfspaceProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..8105bad59e6ea45c1dd768dbfa6e772507be526d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalHalfspaceProfiles.lean @@ -0,0 +1,64 @@ +import OAI.Probability.BenjaminiSchramm.CriticalCeilingProfile +import OAI.Probability.BenjaminiSchramm.CeilingDownCrudeProfile +import OAI.Probability.BenjaminiSchramm.HalfspaceProfileBootstrap + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_halfspace_fractional_profiles + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∀ q : ℝ, 0 < q → q < 1 → + (criticalModel G).downwardHalfspaceFractionalProfile + ((criticalModel G).stationaryOrbitWeight μ) (pc G) R q ∧ + (criticalModel G).upwardHalfspaceFractionalProfile + ((criticalModel G).stationaryOrbitWeight μ) (pc G) R q := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have hp0 : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + have hp1 : (pc G : ℝ) < 1 := by exact_mod_cast hpc1 + have hfin (x : V) : ∀ᵐ ω ∂H.law (pc G), (Percolation.cluster H.ends ω x).Finite := by + simpa only [H,criticalModel,CriticalPercolation.BondGraph.law,law] using + critical_finite_general G hc hl hq hpc1 x + obtain ⟨L₁,_hL₁,hprof₁⟩ := critical_lower_slab_fractional_profile G hc hl hq hpc1 hu μ hμ hstat R hR hjump + have hjump₂ : ∀ e v w, v ∈ G e → w ∈ G e → |H.orbitAdjustedHeight a v w| ≤ 2*R := by + intro e v w hv hw + exact (hjump e v w hv hw).trans (by linarith) + obtain ⟨L₂,_hL₂,hprof₂⟩ := critical_lower_slab_fractional_profile G hc hl hq hpc1 hu μ hμ hstat + (2*R) (by positivity) hjump₂ + obtain ⟨U,_hU,hup⟩ := H.upward_fractional_slab_profile hHc hl hHq μ hμ hstat hu R hR hjump + (pc G) hp0 hp1 hfin L₁ L₂ hprof₁ hprof₂ + obtain ⟨A,hA,hzero⟩ := critical_ceiling_zero_band_profile G hc hl hq hpc1 hu μ hμ hstat + (2*R) (by positivity) hjump₂ + have hzero' : ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount H.ends + (internalEdges H.ends {v | H.orbitAdjustedHeight a x v ≤ c}) + {v | -2*R ≤ H.orbitAdjustedHeight a x v ∧ H.orbitAdjustedHeight a x v ≤ 2*R} ω x)^q ∂H.law (pc G)) ≤ + C*ENNReal.ofReal (Real.exp (A*c)) := by + simpa only [a,H,criticalModel,CriticalPercolation.BondGraph.law,law,←neg_mul] using hzero + obtain ⟨B,hB,hcrude⟩ := H.ceiling_down_crude_profile hHc hl hHq μ hμ hstat hu R hR hjump + (pc G) hp0 hp1 A hA hzero' + obtain ⟨d,hd⟩ := exists_neighbor_card_bound G hl hq + exact H.halfspace_fractional_profile_bootstrap hHc hl hHq μ hμ hstat hu d hd R hR hjump + (pc G) hp0 hp1 hfin L₁ U B hB hprof₁ hup hcrude + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalHeightHit.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalHeightHit.lean new file mode 100644 index 0000000000000000000000000000000000000000..56cfc9a4f79a71b986219dc586a97f4bae383856 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalHeightHit.lean @@ -0,0 +1,110 @@ +import OAI.Probability.BenjaminiSchramm.GeneralCriticalFiniteness +import OAI.Probability.BenjaminiSchramm.NormalizedHalfspace + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def adjustedFullHit (a : V → ℝ) (x : V) (t : ℝ) : Set (Set E) := + {ω | ∃ y, t ≤ G.orbitAdjustedHeight a x y ∧ y ∈ G.cluster ω x} + +lemma measurableSet_adjustedFullHit [Countable V] [Countable E] + (a : V → ℝ) (x : V) (t : ℝ) : MeasurableSet (G.adjustedFullHit a x t) := + (Measurable.exists fun y => measurable_const.and (G.measurable_reachable x y)).setOf + +lemma adjustedFullHit_antitone (a : V → ℝ) (x : V) : + Antitone (G.adjustedFullHit a x) := by + rintro s t hst ω ⟨y,hy,hxy⟩ + exact ⟨y,hst.trans hy,hxy⟩ + +lemma Aut.adjustedFullHit_preimage (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (φ : G.Aut) (x : V) (t : ℝ) : + (fun ω : Set E => φ.edge '' ω) ⁻¹' G.adjustedFullHit a (φ.vertex x) t= + G.adjustedFullHit a x t := by + ext ω + constructor + · rintro ⟨y,hy,hxy⟩ + obtain ⟨z,rfl⟩ := φ.vertex.surjective y + exact ⟨z,by simpa only [G.orbitAdjustedHeight_aut a ha] using hy, + (SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω)).mp hxy⟩ + · rintro ⟨y,hy,hxy⟩ + exact ⟨φ.vertex y,by simpa only [G.orbitAdjustedHeight_aut a ha] using hy, + (SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω)).mpr hxy⟩ + +lemma Aut.adjustedFullHit_real [Countable V] [Countable E] + (a : V → ℝ) (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (φ : G.Aut) (p : unitInterval) (x : V) (t : ℝ) : + (G.law p).real (G.adjustedFullHit a (φ.vertex x) t)= + (G.law p).real (G.adjustedFullHit a x t) := by + simp only [measureReal_def] + congr 1 + conv_lhs => rw [←G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + (G.measurableSet_adjustedFullHit _ _ _),Aut.adjustedFullHit_preimage G a ha φ] + +theorem adjustedFullHit_tendsto_zero [Countable V] [Countable E] + (a : V → ℝ) (p : unitInterval) (x : V) (R : ℝ) (hR : 0 < R) + (hfin : ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) : + Tendsto (fun n : ℕ => (G.law p).real (G.adjustedFullHit a x (R*n))) atTop (𝓝 0) := by + have hempty (ω : Set E) (hω : (G.cluster ω x).Finite) : + ω ∉ ⋂ n : ℕ, G.adjustedFullHit a x (R*n) := by + obtain ⟨B,hB⟩ := (hω.image (G.orbitAdjustedHeight a x)).bddAbove + obtain ⟨n,hn⟩ := exists_nat_gt (B/R) + intro hh + obtain ⟨y,hy,hxy⟩ := Set.mem_iInter.mp hh n + have hBy := hB ⟨y,hxy,rfl⟩ + have hBn := (div_lt_iff₀ hR).mp hn + nlinarith + have hz : G.law p (⋂ n : ℕ, G.adjustedFullHit a x (R*n))=0 := by + simpa only [not_not,Set.ofPred_mem_eq] using (ae_iff.mp (hfin.mono hempty)) + have h := tendsto_measure_iInter_atTop (μ := G.law p) + (fun n : ℕ => (G.measurableSet_adjustedFullHit a x (R*n)).nullMeasurableSet) + (fun n m hnm => G.adjustedFullHit_antitone a x (by gcongr)) ⟨0,measure_ne_top _ _⟩ + rw [hz] at h + simpa only [Function.comp_def,measureReal_def,ENNReal.toReal_zero] using + (ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp h + +def rootHeightHitProfile (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ := + ∑ x ∈ O.roots, (G.law p).real (G.adjustedFullHit a x (R*n)) + +lemma rootHeightHitProfile_nonneg (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (n : ℕ) : 0 ≤ G.rootHeightHitProfile O a R p n := + Finset.sum_nonneg fun _ _ => measureReal_nonneg + +lemma adjustedFullHit_le_rootProfile [Countable V] [Countable E] + (O : G.OrbitRepresentatives) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (R : ℝ) (p : unitInterval) (n : ℕ) (x : V) : + (G.law p).real (G.adjustedFullHit a x (R*n)) ≤ G.rootHeightHitProfile O a R p n := by + obtain ⟨y,hy,φ,rfl⟩ := O.cover x + rw [Aut.adjustedFullHit_real G a ha φ] + exact Finset.single_le_sum (f := fun z => (G.law p).real (G.adjustedFullHit a z (R*n))) + (fun _ _ => measureReal_nonneg) hy + +lemma rootHeightHitProfile_le_card (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (n : ℕ) : + G.rootHeightHitProfile O a R p n ≤ O.roots.card := by + calc + _ ≤ ∑ _x ∈ O.roots, (1 : ℝ) := Finset.sum_le_sum fun _ _ => measureReal_le_one + _ = _ := by simp + +theorem rootHeightHitProfile_tendsto_zero [Countable V] [Countable E] + (O : G.OrbitRepresentatives) (a : V → ℝ) (p : unitInterval) + (R : ℝ) (hR : 0 < R) (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) : + Tendsto (G.rootHeightHitProfile O a R p) atTop (𝓝 0) := by + change Tendsto (fun n : ℕ => ∑ x ∈ O.roots, (G.law p).real (G.adjustedFullHit a x (R*n))) atTop (𝓝 0) + have hh := tendsto_finsetSum O.roots (fun x _ => G.adjustedFullHit_tendsto_zero a p x R hR (hfin x)) + simpa only [Finset.sum_const_zero] using hh + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalNormalizedCrossing.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalNormalizedCrossing.lean new file mode 100644 index 0000000000000000000000000000000000000000..bec04768a8d859a4365bb6fe528b5920916196e7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalNormalizedCrossing.lean @@ -0,0 +1,73 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceRootComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_normalized_halfspace_uniform (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hu : ¬ (criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ = μ) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ r : ℝ, 0 ≤ r → ∀ (x : V) (t : ℝ), 0 ≤ t → + (law (pc G)).real ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t) ≤ + (pc G : ℝ)^(-(A*r+B)) * Real.exp (-t) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨A,B,hA,hB,hpath⟩ := H.stationaryOrbitHeight_orbit_above hHc hl hHq μ hμ hstat hu + obtain ⟨m,M,hm,hbounds⟩ := H.stationaryOrbitWeight_uniform_bounds hHc hl μ hμ + have hauto := H.stationaryOrbitWeight_aut μ + have hp : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + refine ⟨A,B,hA,hB,fun r hr x t ht => ?_⟩ + let α : ℝ := (pc G : ℝ)^(A*r+B) + have hα : 0 < α := Real.rpow_pos_of_pos hp _ + have hroot (u : V) : + α*(law (pc G)).real (H.adjustedHalfspaceHit a x (-r) t) ≤ + (law (pc G)).real (H.adjustedHalfspaceHit a u 0 t) := by + obtain ⟨y,w,horb,hlen,hw,hy⟩ := hpath r hr u (H.vertexOrbit x) + obtain ⟨φ,hφ⟩ := MulAction.mem_orbit_iff.mp (Quotient.exact horb) + change φ.vertex x = y at hφ + have hcomp := H.adjustedHalfspaceHit_path_comparison hHc hl a (pc G) w r t hr hw hy + have he := CriticalPercolation.BondGraph.Aut.adjustedHalfspaceHit_measure H a hauto φ (pc G) x (-r) t + rw [hφ] at he + have her := congrArg ENNReal.toReal he + change (H.law (pc G)).real (H.adjustedHalfspaceHit a y (-r) t) = + (H.law (pc G)).real (H.adjustedHalfspaceHit a x (-r) t) at her + rw [her] at hcomp + have hcoeff : α ≤ (pc G : ℝ)^w.length := by + simpa only [Real.rpow_natCast] using + Real.rpow_le_rpow_of_exponent_ge hp (pc G).2.2 hlen + exact (mul_le_mul_of_nonneg_right hcoeff ENNReal.toReal_nonneg).trans hcomp + have hmin : α*(law (pc G)).real (H.adjustedHalfspaceHit a x (-r) t) ≤ + (H.infimalAdjustedCrossing a (pc G) t).toReal := by + have he : ENNReal.ofReal (α*(law (pc G)).real (H.adjustedHalfspaceHit a x (-r) t)) ≤ + H.infimalAdjustedCrossing a (pc G) t := by + apply le_iInf + intro u + exact ENNReal.ofReal_le_of_le_toReal (hroot u) + have hf := ENNReal.toReal_mono + (ne_top_of_le_ne_top ENNReal.one_ne_top (H.infimalAdjustedCrossing_le_one a (pc G) t)) he + have hnonneg : 0 ≤ α*(law (pc G)).real (H.adjustedHalfspaceHit a x (-r) t) := + mul_nonneg hα.le measureReal_nonneg + rwa [ENNReal.toReal_ofReal hnonneg] at hf + have hh := hmin.trans (critical_infimal_adjusted_crossing_bound G hc hl hq a hauto + m M hm hbounds t ht) + have hh' := mul_le_mul_of_nonneg_left hh (inv_nonneg.mpr hα.le) + rw [← mul_assoc,inv_mul_cancel₀ hα.ne',one_mul] at hh' + have he : α⁻¹ = (pc G : ℝ)^(-(A*r+B)) := by + exact (Real.rpow_neg (pc G).2.1 _).symm + rwa [he] at hh' + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakBand.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb3d12753e520ee9d89546a20545c3d3dad9e290 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakBand.lean @@ -0,0 +1,188 @@ +import OAI.Probability.BenjaminiSchramm.PeakHalfspaceTransport +import OAI.Probability.BenjaminiSchramm.CriticalNormalizedCrossing +import OAI.Probability.BenjaminiSchramm.NormalizedExponentComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +lemma critical_normalized_halfspace_exp_bound (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) : + ∃ C L : ℝ, 0 < C ∧ 0 < L ∧ ∀ r, 0 ≤ r → ∀ x t, 0 ≤ t → + law (pc G) ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t) ≤ + ENNReal.ofReal (C*Real.exp (L*r-t)) := by + obtain ⟨A,B,hA,hB,hh⟩ := critical_normalized_halfspace_uniform G hc hl hq hu μ hμ hstat + have hp : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + let ell := -Real.log (pc G : ℝ) + have hell : 0 ≤ ell := neg_nonneg.mpr (Real.log_nonpos hp.le (pc G).2.2) + let C := Real.exp (ell*B) + let L := ell*A+1 + have hL : 0 < L := by dsimp [L]; positivity + refine ⟨C,L,Real.exp_pos _,hL,fun r hr x t ht => ?_⟩ + have hreal : (law (pc G)).real ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t) ≤ C*Real.exp (L*r-t) := by + apply (hh r hr x t ht).trans + rw [Real.rpow_def_of_pos hp,←Real.exp_add] + change Real.exp _ ≤ Real.exp (ell*B)*Real.exp (L*r-t) + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + dsimp [ell,L] + nlinarith + calc + _ = ENNReal.ofReal ((law (pc G)).real ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t)) := + (ENNReal.ofReal_toReal (measure_ne_top _ _)).symm + _ ≤ _ := ENNReal.ofReal_le_ofReal hreal + +theorem critical_peak_band_bound (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) : + ∃ C L : ℝ, 0 < C ∧ 0 < L ∧ ∀ r, 0 ≤ r → ∀ l u, u ≤ 0 → + (∑ x ∈ ((criticalModel G).orbitRepresentatives + (criticalModel_quasiTransitive G hq)).roots, + ENNReal.ofReal ((criticalModel G).stationaryOrbitWeight μ x)* + (∫⁻ ω, (criticalModel G).strictPeakSlabBandCount + ((criticalModel G).stationaryOrbitWeight μ) r l u ω x ∂law (pc G))) ≤ + (∑ x ∈ ((criticalModel G).orbitRepresentatives + (criticalModel_quasiTransitive G hq)).roots, + ENNReal.ofReal ((criticalModel G).stationaryOrbitWeight μ x))* + ENNReal.ofReal (C*Real.exp (L*r+u-l)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + let O := H.orbitRepresentatives (criticalModel_quasiTransitive G hq) + have hHc := criticalModel_connected G hc + obtain ⟨C,L,hC,hL,hup⟩ := critical_normalized_halfspace_exp_bound G hc hl hq hu μ hμ hstat + refine ⟨C,L,hC,hL,fun r hr l u hu0 => ?_⟩ + have hb := H.expected_strictPeakSlabBandCount_bound O hHc hl a + (H.stationaryOrbitWeight_pos hHc hl μ hμ) (H.stationaryOrbitWeight_aut μ) (pc G) r l u + have hs : (∑ y ∈ O.roots, ENNReal.ofReal (a y)*H.law (pc G) + (restrictedHit G (internalEdges G {z | -r ≤ H.orbitAdjustedHeight a y z}) y + {z | -u ≤ H.orbitAdjustedHeight a y z})) ≤ + (∑ y ∈ O.roots, ENNReal.ofReal (a y))*ENNReal.ofReal (C*Real.exp (L*r+u)) := by + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro y _ + apply mul_le_mul' le_rfl + change law (pc G) (H.adjustedHalfspaceHit a y (-r) (-u)) ≤ _ + simpa only [sub_neg_eq_add] using hup r hr y (-u) (neg_nonneg.mpr hu0) + have he : ENNReal.ofReal (Real.exp (-l))*ENNReal.ofReal (Real.exp l)=1 := by + rw [←ENNReal.ofReal_mul (Real.exp_pos _).le,←Real.exp_add] + simp only [neg_add_cancel,Real.exp_zero,ENNReal.ofReal_one] + calc + _ = ENNReal.ofReal (Real.exp (-l))*(ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, H.strictPeakSlabBandCount a r l u ω x ∂law (pc G)))) := by + rw [←mul_assoc,he,one_mul] + _ ≤ ENNReal.ofReal (Real.exp (-l))* + ((∑ y ∈ O.roots, ENNReal.ofReal (a y))*ENNReal.ofReal (C*Real.exp (L*r+u))) := + mul_le_mul' le_rfl (hb.trans hs) + _ = _ := by + rw [mul_left_comm,←ENNReal.ofReal_mul (Real.exp_pos _).le] + congr 2 + rw [mul_left_comm,←Real.exp_add] + congr 2 + ring + +lemma critical_normalized_halfspace_exp_bound_at_rate (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (α : ℝ) (hcross : ∀ t : ℝ, 0 ≤ t → + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) t).toReal ≤ Real.exp (-α*t)) : + ∃ C L : ℝ, 0 < C ∧ 0 < L ∧ ∀ r, 0 ≤ r → ∀ x t, 0 ≤ t → + law (pc G) ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t) ≤ + ENNReal.ofReal (C*Real.exp (L*r-α*t)) := by + have hp : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + obtain ⟨A,B,hA,hB,hh⟩ := normalized_halfspace_uniform_of_infimal_bound G hc hl hq hu + μ hμ hstat (pc G) hp α hcross + let ell := -Real.log (pc G : ℝ) + have hell : 0 ≤ ell := neg_nonneg.mpr (Real.log_nonpos hp.le (pc G).2.2) + let C := Real.exp (ell*B) + let L := ell*A+1 + have hL : 0 < L := by dsimp [L]; positivity + refine ⟨C,L,Real.exp_pos _,hL,fun r hr x t ht => ?_⟩ + have hreal : (law (pc G)).real ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t) ≤ C*Real.exp (L*r-α*t) := by + apply (hh r hr x t ht).trans + rw [Real.rpow_def_of_pos hp,←Real.exp_add] + change Real.exp _ ≤ Real.exp (ell*B)*Real.exp (L*r-α*t) + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + dsimp [ell,L] + nlinarith + calc + _ = ENNReal.ofReal ((law (pc G)).real ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t)) := + (ENNReal.ofReal_toReal (measure_ne_top _ _)).symm + _ ≤ _ := ENNReal.ofReal_le_ofReal hreal + +theorem critical_peak_band_bound_at_rate (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (α : ℝ) (hcross : ∀ t : ℝ, 0 ≤ t → + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) t).toReal ≤ Real.exp (-α*t)) : + ∃ C L : ℝ, 0 < C ∧ 0 < L ∧ ∀ r, 0 ≤ r → ∀ l u, u ≤ 0 → + (∑ x ∈ ((criticalModel G).orbitRepresentatives + (criticalModel_quasiTransitive G hq)).roots, + ENNReal.ofReal ((criticalModel G).stationaryOrbitWeight μ x)* + (∫⁻ ω, (criticalModel G).strictPeakSlabBandCount + ((criticalModel G).stationaryOrbitWeight μ) r l u ω x ∂law (pc G))) ≤ + (∑ x ∈ ((criticalModel G).orbitRepresentatives + (criticalModel_quasiTransitive G hq)).roots, + ENNReal.ofReal ((criticalModel G).stationaryOrbitWeight μ x))* + ENNReal.ofReal (C*Real.exp (L*r+α*u-l)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + let O := H.orbitRepresentatives (criticalModel_quasiTransitive G hq) + have hHc := criticalModel_connected G hc + obtain ⟨C,L,hC,hL,hup⟩ := critical_normalized_halfspace_exp_bound_at_rate G hc hl hq hu μ hμ hstat α hcross + refine ⟨C,L,hC,hL,fun r hr l u hu0 => ?_⟩ + have hb := H.expected_strictPeakSlabBandCount_bound O hHc hl a + (H.stationaryOrbitWeight_pos hHc hl μ hμ) (H.stationaryOrbitWeight_aut μ) (pc G) r l u + have hs : (∑ y ∈ O.roots, ENNReal.ofReal (a y)*H.law (pc G) + (restrictedHit G (internalEdges G {z | -r ≤ H.orbitAdjustedHeight a y z}) y + {z | -u ≤ H.orbitAdjustedHeight a y z})) ≤ + (∑ y ∈ O.roots, ENNReal.ofReal (a y))*ENNReal.ofReal (C*Real.exp (L*r+α*u)) := by + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro y _ + apply mul_le_mul' le_rfl + change law (pc G) (H.adjustedHalfspaceHit a y (-r) (-u)) ≤ _ + simpa only [mul_neg,sub_neg_eq_add] using hup r hr y (-u) (neg_nonneg.mpr hu0) + have he : ENNReal.ofReal (Real.exp (-l))*ENNReal.ofReal (Real.exp l)=1 := by + rw [←ENNReal.ofReal_mul (Real.exp_pos _).le,←Real.exp_add] + simp only [neg_add_cancel,Real.exp_zero,ENNReal.ofReal_one] + calc + _ = ENNReal.ofReal (Real.exp (-l))*(ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, H.strictPeakSlabBandCount a r l u ω x ∂law (pc G)))) := by + rw [←mul_assoc,he,one_mul] + _ ≤ ENNReal.ofReal (Real.exp (-l))* + ((∑ y ∈ O.roots, ENNReal.ofReal (a y))*ENNReal.ofReal (C*Real.exp (L*r+α*u))) := + mul_le_mul' le_rfl (hb.trans hs) + _ = _ := by + rw [mul_left_comm,←ENNReal.ofReal_mul (Real.exp_pos _).le] + congr 2 + rw [mul_left_comm,←Real.exp_add] + congr 2 + ring + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..d527eabb43439896204c6c7cb1bac794641e6c2a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakComparison.lean @@ -0,0 +1,149 @@ +import OAI.Probability.BenjaminiSchramm.WeightedPeakSlabComparison +import OAI.Probability.BenjaminiSchramm.GeneralCriticalFiniteness + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_peak_comparison + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∃ M : ℝ, 0 < M ∧ ∃ K : ℝ≥0∞, K < ⊤ ∧ ∃ L : ℝ, 0 < L ∧ + ∀ k, 0 ≤ k → ∀ r, 0 ≤ r → ∀ ell, 0 < ell → ∀ v₀, + (criticalModel G).fullPeakDownProbability + ((criticalModel G).orbitRepresentatives (criticalModel_quasiTransitive G hq)) + ((criticalModel G).stationaryOrbitWeight μ) (pc G) ell* + (criticalModel G).mixedHeightLayerMoment ((criticalModel G).stationaryOrbitWeight μ) + (pc G) (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ ≤ + K*ENNReal.ofReal (Real.exp (L*r)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + let O := H.orbitRepresentatives (criticalModel_quasiTransitive G hq) + have hHc := criticalModel_connected G hc + obtain ⟨N,M,hM,hpaths⟩ := H.stationaryOrbitHeight_bounded_orbit_below hHc hl + (criticalModel_quasiTransitive G hq) μ hμ hstat hu R hR hjump + obtain ⟨d,_hdpos,hd⟩ := exists_degree_bound G hq + obtain ⟨C,L,hC,hL,hband⟩ := critical_peak_band_bound G hc hl hq hu μ hμ hstat + let cost := ENNReal.ofReal ((min (pc G : ℝ) (1-pc G))^(d*(N+1))) + have hp0 : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + have hp1 : (pc G : ℝ) < 1 := by exact_mod_cast hpc1 + have hcost0 : cost ≠ 0 := by + apply ne_of_gt + apply ENNReal.ofReal_pos.mpr + exact pow_pos (lt_min hp0 (sub_pos.mpr hp1)) _ + have hcosttop : cost ≠ ⊤ := ENNReal.ofReal_ne_top + let W := ∑ x ∈ O.roots, ENNReal.ofReal (a x) + let K := cost⁻¹*W*ENNReal.ofReal (C*Real.exp (L*(R+M)+M+2*R)) + have hW : W < ⊤ := ENNReal.sum_lt_top.mpr fun _ _ => ENNReal.ofReal_lt_top + have hK : K < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.inv_lt_top.mpr (bot_lt_iff_ne_bot.mpr hcost0)) hW) ENNReal.ofReal_lt_top + refine ⟨M,hM,K,hK,L,hL,fun k hk r hr ell hell v₀ => ?_⟩ + have hcmp := H.weighted_full_peak_lower_slab_comparison O hHc hl a + (H.stationaryOrbitWeight_aut μ) d N hd (pc G) R M k r ell hR.le hM.le hk hr hell + hjump hpaths (critical_finite_general G hc hl hq hpc1) v₀ + have hbound := hband (r+R+M) (by positivity) (-ell-k-M-2*R) (-ell-k) (by linarith) + have hcancel : cost⁻¹*cost=1 := ENNReal.inv_mul_cancel hcost0 hcosttop + calc + _ = cost⁻¹*((H.fullPeakDownProbability O a (pc G) ell*cost)* + H.mixedHeightLayerMoment a (pc G) (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀) := by + let P := H.fullPeakDownProbability O a (pc G) ell + let X := H.mixedHeightLayerMoment a (pc G) (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ + change P*X=cost⁻¹*((P*cost)*X) + calc + _ = (cost⁻¹*cost)*(P*X) := by rw [hcancel,one_mul] + _ = _ := by ac_rfl + _ ≤ cost⁻¹*(W*ENNReal.ofReal (C*Real.exp (L*(r+R+M)+(-ell-k)-(-ell-k-M-2*R)))) := + mul_le_mul' le_rfl (hcmp.trans hbound) + _ = K*ENNReal.ofReal (Real.exp (L*r)) := by + have he : C*Real.exp (L*(r+R+M)+(-ell-k)-(-ell-k-M-2*R)) = + (C*Real.exp (L*(R+M)+M+2*R))*Real.exp (L*r) := by + rw [mul_assoc,←Real.exp_add] + congr 2 + ring + rw [he,ENNReal.ofReal_mul (by positivity : 0 ≤ C*Real.exp (L*(R+M)+M+2*R))] + dsimp [K] + ac_rfl + +theorem critical_peak_comparison_at_rate + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (α : ℝ) (hcross : ∀ t : ℝ, 0 ≤ t → + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) t).toReal ≤ Real.exp (-α*t)) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∃ M : ℝ, 0 < M ∧ ∃ K : ℝ≥0∞, K < ⊤ ∧ ∃ L : ℝ, 0 < L ∧ + ∀ k, 0 ≤ k → ∀ r, 0 ≤ r → ∀ ell, 0 < ell → ∀ v₀, + (criticalModel G).fullPeakDownProbability + ((criticalModel G).orbitRepresentatives (criticalModel_quasiTransitive G hq)) + ((criticalModel G).stationaryOrbitWeight μ) (pc G) ell* + (criticalModel G).mixedHeightLayerMoment ((criticalModel G).stationaryOrbitWeight μ) + (pc G) (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ ≤ + K*ENNReal.ofReal (Real.exp (L*r-(α-1)*(ell+k))) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + let O := H.orbitRepresentatives (criticalModel_quasiTransitive G hq) + have hHc := criticalModel_connected G hc + obtain ⟨N,M,hM,hpaths⟩ := H.stationaryOrbitHeight_bounded_orbit_below hHc hl + (criticalModel_quasiTransitive G hq) μ hμ hstat hu R hR hjump + obtain ⟨d,_hdpos,hd⟩ := exists_degree_bound G hq + obtain ⟨C,L,hC,hL,hband⟩ := critical_peak_band_bound_at_rate G hc hl hq hu μ hμ hstat α hcross + let cost := ENNReal.ofReal ((min (pc G : ℝ) (1-pc G))^(d*(N+1))) + have hp0 : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + have hp1 : (pc G : ℝ) < 1 := by exact_mod_cast hpc1 + have hcost0 : cost ≠ 0 := by + apply ne_of_gt + apply ENNReal.ofReal_pos.mpr + exact pow_pos (lt_min hp0 (sub_pos.mpr hp1)) _ + have hcosttop : cost ≠ ⊤ := ENNReal.ofReal_ne_top + let W := ∑ x ∈ O.roots, ENNReal.ofReal (a x) + let K := cost⁻¹*W*ENNReal.ofReal (C*Real.exp (L*(R+M)+M+2*R)) + have hW : W < ⊤ := ENNReal.sum_lt_top.mpr fun _ _ => ENNReal.ofReal_lt_top + have hK : K < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.inv_lt_top.mpr (bot_lt_iff_ne_bot.mpr hcost0)) hW) ENNReal.ofReal_lt_top + refine ⟨M,hM,K,hK,L,hL,fun k hk r hr ell hell v₀ => ?_⟩ + have hcmp := H.weighted_full_peak_lower_slab_comparison O hHc hl a + (H.stationaryOrbitWeight_aut μ) d N hd (pc G) R M k r ell hR.le hM.le hk hr hell + hjump hpaths (critical_finite_general G hc hl hq hpc1) v₀ + have hbound := hband (r+R+M) (by positivity) (-ell-k-M-2*R) (-ell-k) (by linarith) + have hcancel : cost⁻¹*cost=1 := ENNReal.inv_mul_cancel hcost0 hcosttop + calc + _ = cost⁻¹*((H.fullPeakDownProbability O a (pc G) ell*cost)* + H.mixedHeightLayerMoment a (pc G) (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀) := by + let P := H.fullPeakDownProbability O a (pc G) ell + let X := H.mixedHeightLayerMoment a (pc G) (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ + change P*X=cost⁻¹*((P*cost)*X) + calc + _ = (cost⁻¹*cost)*(P*X) := by rw [hcancel,one_mul] + _ = _ := by ac_rfl + _ ≤ cost⁻¹*(W*ENNReal.ofReal (C*Real.exp (L*(r+R+M)+α*(-ell-k)-(-ell-k-M-2*R)))) := + mul_le_mul' le_rfl (hcmp.trans hbound) + _ = K*ENNReal.ofReal (Real.exp (L*r-(α-1)*(ell+k))) := by + have he : C*Real.exp (L*(r+R+M)+α*(-ell-k)-(-ell-k-M-2*R)) = + (C*Real.exp (L*(R+M)+M+2*R))*Real.exp (L*r-(α-1)*(ell+k)) := by + rw [mul_assoc,←Real.exp_add] + congr 2 + ring + rw [he,ENNReal.ofReal_mul (by positivity : 0 ≤ C*Real.exp (L*(R+M)+M+2*R))] + dsimp [K] + ac_rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakSurvival.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakSurvival.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8f9f819f81ee5cf7eba9b39b603f35e16f5c080 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalPeakSurvival.lean @@ -0,0 +1,150 @@ +import OAI.Probability.BenjaminiSchramm.PeakSprinklingSurvival +import OAI.Probability.BenjaminiSchramm.SprinklingAvoidanceProfile +import OAI.Probability.BenjaminiSchramm.SprinklingParameter +import OAI.Probability.BenjaminiSchramm.SubcriticalPeakConditional +import OAI.Probability.BenjaminiSchramm.CrossingExponentContinuity +import OAI.Probability.BenjaminiSchramm.LayerCrossingComparison +import OAI.Probability.BenjaminiSchramm.GeneralCriticalFiniteness +import OAI.Probability.BenjaminiSchramm.NormalizedExponentComparison +import OAI.Probability.BenjaminiSchramm.AntitoneSurvivalHeight + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma fullPeakDownProbability_antitone (O : G.OrbitRepresentatives) (a : V → ℝ) + (p : unitInterval) : Antitone (G.fullPeakDownProbability O a p) := by + intro ell ell' hle + apply Finset.sum_le_sum + intro x _ + apply mul_le_mul' le_rfl + apply measure_mono + rintro ω ⟨hpeak,y,hy,hxy⟩ + change G.orbitAdjustedHeight a x y ≤ -ell' at hy + exact ⟨hpeak,y,show G.orbitAdjustedHeight a x y ≤ -ell by linarith,hxy⟩ + +end CriticalPercolation.BondGraph + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_peak_survival_eventual + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (α : ℝ) + (hlim : Tendsto (fun n : ℕ => -Real.log + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) n).toReal/n) atTop (𝓝 α)) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (O : (criticalModel G).OrbitRepresentatives) (ε : ℝ) (hε : 0 < ε) : + ∃ c : ℝ, 0 < c ∧ ∀ᶠ n : ℕ in atTop, + ENNReal.ofReal (c*Real.exp (-(R*(α-1)+ε)*n)) ≤ + (criticalModel G).fullPeakDownProbability O + ((criticalModel G).stationaryOrbitWeight μ) (pc G) (R*n) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have ha := H.stationaryOrbitWeight_aut μ + have hp : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + obtain ⟨q,hqhalf,hqpc,γ,hγ,hγα,_hγupper,hγlower⟩ := + H.normalized_crossing_exponent_approximation hHc hl hHq μ hμ hstat hu + (pc G) hp α hlim (ε/(2*R)) (div_pos hε (by positivity)) + have hqpos : (0 : ℝ) < q := (half_pos hp).trans_le hqhalf + obtain ⟨β,hβR,K,hK,hup,c,hcpos,C,hC,hprofile⟩ := + subcritical_weighted_peak_conditional_layers G hc hl hq μ hμ hstat hu R hR hjump + q hqpos hqpc O + obtain ⟨χ,hχ,hrow⟩ := subcritical_ennreal_row_bound G hl hq q hqpc + have hβγ : β ≤ γ*R := by + apply H.crossing_rate_ge_layer_rate hHc hl a R hR hjump q + (ENNReal.ofReal χ) ENNReal.ofReal_lt_top hrow γ β hγ hγlower + intro δ hδ + refine ⟨K,hK,fun n => (hup n).trans ?_⟩ + apply ENNReal.ofReal_le_ofReal + apply mul_le_mul_of_nonneg_left _ hK.le + apply Real.exp_le_exp.mpr + nlinarith [Nat.cast_nonneg (α := ℝ) n] + obtain ⟨b,hb0,hb1,hparam⟩ := exists_sprinkling_parameter q (pc G) hqpc hpc1 + have hfincrit (x : V) : ∀ᵐ ω ∂H.law (pc G), (H.cluster ω x).Finite := by + simpa only [H,criticalModel_cluster,CriticalPercolation.BondGraph.law,law] using + critical_finite_general G hc hl hq hpc1 x + have hfinq (x : V) : ∀ᵐ ω ∂H.law q, (H.cluster ω x).Finite := by + simpa only [H,criticalModel_cluster,CriticalPercolation.BondGraph.law,law] using + subcritical_cluster_finite_ae G q hqpc x + obtain ⟨d,_hdpos,hd⟩ := exists_degree_bound G hq + obtain ⟨g,hg,⟨C₀,hgb⟩,hglim,havoid⟩ := H.sprinkling_avoidance_cost_profile + hHc hl O a ha (pc G) q b hparam hb0 hb1 R hR d hd hfincrit + have hC₀ : 0 ≤ C₀ := (hg 0).trans (hgb 0) + have hsurv := H.peak_sprinkling_eventual_survival hHc hl O (pc G) q b hparam + a R hR hfinq g hg C₀ hC₀ hgb hglim havoid c (β-R) (β-R) C + (sub_pos.mpr hβR) hC.le (fun n hn => (hprofile n hn).1) + (fun n hn => (hprofile n hn).2) (ε/2) (half_pos hε) + have hrate : β-R+ε/2 ≤ R*(α-1)+ε := by + have hh := (lt_div_iff₀ (show 0 < 2*R by positivity)).mp + (show γ-α < ε/(2*R) by linarith) + nlinarith + refine ⟨c/2,half_pos hcpos,?_⟩ + filter_upwards [hsurv] with n hn + apply le_trans _ hn + apply ENNReal.ofReal_le_ofReal + apply mul_le_mul_of_nonneg_left _ (half_pos hcpos).le + apply Real.exp_le_exp.mpr + nlinarith [Nat.cast_nonneg (α := ℝ) n] + +theorem critical_peak_survival_real + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (α : ℝ) (hα : 1 ≤ α) + (hlim : Tendsto (fun n : ℕ => -Real.log + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) n).toReal/n) atTop (𝓝 α)) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (O : (criticalModel G).OrbitRepresentatives) : + ∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ ell : ℝ, 0 < ell → + ENNReal.ofReal (c*Real.exp (-((α-1)+ε)*ell)) ≤ + (criticalModel G).fullPeakDownProbability O + ((criticalModel G).stationaryOrbitWeight μ) (pc G) ell := by + apply antitone_survival_real_lower _ + ((criticalModel G).fullPeakDownProbability_antitone O _ _) R (α-1) hR (by linarith) + exact critical_peak_survival_eventual G hc hl hq hpc1 hu μ hμ hstat α hlim R hR hjump O + +theorem critical_crossing_and_peak_survival + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (O : (criticalModel G).OrbitRepresentatives) : + ∃ α : ℝ, 1 ≤ α ∧ + (∀ t : ℝ, 0 ≤ t → ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) t).toReal ≤ Real.exp (-α*t)) ∧ + (∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ ell : ℝ, 0 < ell → + ENNReal.ofReal (c*Real.exp (-((α-1)+ε)*ell)) ≤ + (criticalModel G).fullPeakDownProbability O + ((criticalModel G).stationaryOrbitWeight μ) (pc G) ell) := by + obtain ⟨α,hα,hupper,_hlower,hlim⟩ := + critical_normalized_exact_exponent G hc hl hq hu μ hμ hstat + exact ⟨α,hα,hupper,critical_peak_survival_real G hc hl hq hpc1 hu μ hμ hstat + α hα hlim R hR hjump O⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalQuarterMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalQuarterMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..73248ffe74427dd881a28c9aae958b6626b911ac --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalQuarterMoment.lean @@ -0,0 +1,50 @@ +import OAI.Probability.BenjaminiSchramm.CriticalFullspaceProfiles +import OAI.Probability.BenjaminiSchramm.NormalizedQuarterMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] [Infinite V] (G : BondGraph V E) + +theorem critical_quarter_moment_finite + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) (o : V) : + (criticalModel G).quarterThreeQuarterMoment (pc G) o < ⊤ := by + let : Encodable V := Encodable.ofCountable V + let H := criticalModel G + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + let : Finite H.VertexOrbit := H.finite_vertexOrbits hHq + let : Fintype H.VertexOrbit := Fintype.ofFinite _ + obtain ⟨μ,hμ,_hmass,hstat⟩ := H.exists_positive_orbit_stationary hHc hl + let a := H.stationaryOrbitWeight μ + obtain ⟨m,M,hm,ha⟩ := H.stationaryOrbitWeight_uniform_bounds hHc hl μ hμ + obtain ⟨K,hK⟩ := H.uniform_ball_bound hHq 1 + let D := Real.log M-Real.log m + have hD : 0 ≤ D := sub_nonneg.mpr (Real.log_le_log hm ((ha o).1.trans (ha o).2)) + let R := D+max 0 (Real.log (K : ℝ))+1 + have hR1 : 1 ≤ R := by dsimp [R]; linarith [le_max_left (0 : ℝ) (Real.log (K : ℝ))] + have hR : 0 < R := lt_of_lt_of_le (by norm_num) hR1 + have hjump : ∀ e v w, v ∈ G e → w ∈ G e → |H.orbitAdjustedHeight a v w| ≤ R := by + intro e v w hv hw + have hr := H.modularLogHeight_edge_jump hHc hl K hK v v w e hv hw + rw [H.modularLogHeight_self,sub_zero] at hr + have ht := abs_add_le (H.orbitAdjustedHeight a v w-H.modularLogHeight v w) (H.modularLogHeight v w) + rw [sub_add_cancel] at ht + apply (ht.trans (add_le_add (H.orbitAdjustedHeight_sub_bound a m M hm ha v w) + (hr.trans (le_max_right _ _)))).trans + dsimp [R,D] + linarith + obtain ⟨C,hC,hpos,hneg⟩ := critical_fullspace_threeQuarter_profiles G hc hl hq hpc1 hu μ hμ hstat R hR hjump + exact raw_quarterMoment_lt_top_of_normalized_bands G hc hl a m M hm ha R hR1 + (pc G) o C hC (fun k hk => hpos k hk o) (fun k hk => hneg k hk o) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalSlabProfiles.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalSlabProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee0ab1d1bddf42a9aa8b51ac255a384687366398 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalSlabProfiles.lean @@ -0,0 +1,39 @@ +import OAI.Probability.BenjaminiSchramm.CriticalPeakSurvival +import OAI.Probability.BenjaminiSchramm.UpwardFractionalSlabProfile + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Infinite V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem critical_lower_slab_fractional_profile + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hpc1 : pc G < 1) (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∃ L : ℝ, 0 < L ∧ (criticalModel G).lowerSlabFractionalProfile + ((criticalModel G).stationaryOrbitWeight μ) (pc G) R L := by + let O := (criticalModel G).orbitRepresentatives (criticalModel_quasiTransitive G hq) + obtain ⟨α,hα,hcross,hsurv⟩ := critical_crossing_and_peak_survival G hc hl hq hpc1 hu + μ hμ hstat R hR hjump O + obtain ⟨L,hL,hbound⟩ := critical_slab_fractional_of_peak_survival G hc hl hq hpc1 hu + μ hμ hstat α hα hcross R hR hjump hsurv + refine ⟨L,hL,fun q hq0 hq1 ζ hζ => ?_⟩ + obtain ⟨C,hC,hb⟩ := hbound q hq0 hq1 ζ hζ + refine ⟨C,hC,fun k hk r hr x => ?_⟩ + simpa only [CriticalPercolation.BondGraph.adjustedSlabBandCount_eq_restricted, + criticalModel,CriticalPercolation.BondGraph.law,law] using hb k hk r hr x + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalSusceptibility.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalSusceptibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa1f1b89ce46e364c38aa723ccb21336fdfc8837 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalSusceptibility.lean @@ -0,0 +1,101 @@ +import OAI.Probability.BenjaminiSchramm.GhostCritical + +namespace OAI + +open MeasureTheory Filter +open scoped Topology ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem volume_threshold_le_clusterMass (G : BondGraph V E) (ω : Set E) + (x : V) (n : ℕ) (hn : ω ∈ volumeEvent G x n) : + (n : ℝ≥0∞) ≤ clusterMass G ω x := by + rw [volumeEvent_eq_clusterLarge] at hn + obtain ⟨F,hF,hsub⟩ := hn + have he : (∑ y ∈ F, if Conn G ω x y then (1 : ℝ≥0∞) else 0) = F.card := by + calc + _ = ∑ _y ∈ F, (1 : ℝ≥0∞) := + Finset.sum_congr rfl (fun y hy => ite_eq_left (hsub y hy)) + _ = _ := by simp + calc + (n : ℝ≥0∞) ≤ F.card := by exact_mod_cast hF + _ = ∑ y ∈ F, if Conn G ω x y then (1 : ℝ≥0∞) else 0 := he.symm + _ ≤ clusterMass G ω x := ENNReal.sum_le_tsum F + +theorem volume_probability_times_threshold_le_mass [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (x : V) (n : ℕ) : + (n : ℝ≥0∞) * law p (volumeEvent G x n) ≤ + ∑' y, law p {ω | Conn G ω x y} := by + rw [←lintegral_clusterMass] + rw [←lintegral_indicator_const (measurableSet_volumeEvent G x n) (n : ℝ≥0∞)] + apply lintegral_mono + intro ω + by_cases hn : ω ∈ volumeEvent G x n + · rw [Set.indicator_of_mem hn] + exact volume_threshold_le_clusterMass G ω x n hn + · rw [Set.indicator_of_notMem hn] + exact bot_le + +theorem critical_mass_expectation_top_of_volume_lower [Countable V] [Countable E] + (G : BondGraph V E) (x : V) + (hvol : PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + (∑' y, law (pc G) {ω | Conn G ω x y}) = ⊤ := by + obtain ⟨c,C,hc,_hC,hb⟩ := hvol + by_contra htop + let R := (∑' y, law (pc G) {ω | Conn G ω x y}).toReal + obtain ⟨m,hm⟩ := exists_nat_gt (max 0 (R / c)) + have hmR : 0 < (m : ℝ) := (le_max_left _ _).trans_lt hm + have hm0 : 0 < m := by exact_mod_cast hmR + have hcm : R < c * m := by + have hh := (le_max_right 0 (R / c)).trans_lt hm + exact (div_lt_iff₀ hc).mp hh |>.trans_eq (mul_comm _ _) + have hlower := (hb (m ^ 2) (pow_pos hm0 _)).1 + rw [Real.rpow_neg (Nat.cast_nonneg _),←Real.sqrt_eq_rpow,Nat.cast_pow, + Real.sqrt_sq hmR.le] at hlower + have hupp := ENNReal.toReal_mono htop + (volume_probability_times_threshold_le_mass G (pc G) x (m ^ 2)) + rw [ENNReal.toReal_mul,ENNReal.toReal_natCast] at hupp + have htail : criticalTail G (volumeEvent G) x (m ^ 2) = + (law (pc G) (volumeEvent G x (m ^ 2))).toReal := rfl + rw [←htail,Nat.cast_pow] at hupp + have hl := mul_le_mul_of_nonneg_left hlower (sq_nonneg (m : ℝ)) + have hid : (m : ℝ) ^ 2 * (c * (m : ℝ)⁻¹) = c * m := by + field_simp + rw [hid] at hl + exact (not_lt_of_ge (hl.trans hupp)) hcm + +theorem susceptibility_unbounded_below_critical [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hpc0 : 0 < pc G) (x : V) + (hvol : PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) + (a : unitInterval) (ha : a < pc G) (B : ℝ) : + ∃ p : unitInterval, a ≤ p ∧ p < pc G ∧ B < susceptibility G p x := by + by_contra! hbound + obtain ⟨p,hp,hpcrit,hlim⟩ := exists_seq_strictMono_tendsto' hpc0 + have hpa : ∀ᶠ n in atTop, a ≤ p n := + (tendsto_order.mp hlim).1 a ha |>.mono (fun _ h => h.le) + have hrow (F : Finset V) : ∑ y ∈ F, twoPoint G (pc G) x y ≤ B := by + apply le_of_tendsto (tendsto_finsetSum F (fun y _ => + twoPoint_tendsto_of_monotone G p hp.monotone (pc G) + (fun n => (hpcrit n).2.le) hlim x y)) + filter_upwards [hpa] with n hn + exact ((summable_twoPoint_subcritical G hloc hqt (p n) (hpcrit n).2 x).sum_le_tsum F + (fun y _ => twoPoint_nonneg G (p n) x y)).trans + (hbound (p n) hn (hpcrit n).2) + have hs := summable_of_sum_le (twoPoint_nonneg G (pc G) x) hrow + have he : ENNReal.ofReal (susceptibility G (pc G) x) = + ∑' y, law (pc G) {ω | Conn G ω x y} := by + rw [susceptibility,ENNReal.ofReal_tsum_of_nonneg (twoPoint_nonneg G (pc G) x) hs] + apply tsum_congr + intro y + exact ENNReal.ofReal_toReal (measure_ne_top _ _) + rw [critical_mass_expectation_top_of_volume_lower G x hvol] at he + exact ENNReal.ofReal_ne_top he + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CriticalUpwardDecay.lean b/lean/OAI/Probability/BenjaminiSchramm/CriticalUpwardDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecd33bfb3731808fb02c4fa10e93f73b04b6ed91 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CriticalUpwardDecay.lean @@ -0,0 +1,96 @@ +import OAI.Probability.BenjaminiSchramm.TiltedHit +import OAI.Probability.CriticalPercolation.Modular.LightTwoPointDecay + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma weightHit_antitone (x : V) : Antitone (fun a : ℝ≥0∞ => G.weightHit a x) := by + rintro a b hab ω ⟨y,hxy,hy⟩ + exact ⟨y,hxy,hab.trans hy⟩ + +lemma weightHit_le_modularMass {a : ℝ≥0∞} {x : V} {ω : Set E} + (h : ω ∈ G.weightHit a x) : a ≤ G.modularMass x (G.cluster ω x) := by + obtain ⟨y,hxy,hy⟩ := h + apply hy.trans + change G.stabilizerWeight x y ≤ + ∑' z, if z ∈ G.cluster ω x then G.stabilizerWeight x z else 0 + have hxy' : y ∈ G.cluster ω x := hxy + simpa only [ite_eq_left hxy'] using + (ENNReal.le_tsum (f := fun z => if z ∈ G.cluster ω x then G.stabilizerWeight x z else 0) y) + +lemma not_iInter_weightHit_nat_of_mass_ne_top {ω : Set E} {x : V} + (hm : G.modularMass x (G.cluster ω x) ≠ ⊤) : + ω ∉ ⋂ n : ℕ, G.weightHit n x := by + obtain ⟨n,hn⟩ := ENNReal.exists_nat_gt hm + intro h + exact hn.not_ge (G.weightHit_le_modularMass (Set.mem_iInter.mp h n)) + +theorem tendsto_weightHit_nat_zero [Countable V] [Countable E] + (p : unitInterval) (x : V) + (hm : ∀ᵐ ω ∂G.law p, G.modularMass x (G.cluster ω x) ≠ ⊤) : + Tendsto (fun n : ℕ => (G.law p).real (G.weightHit n x)) atTop (𝓝 0) := by + have hz : G.law p (⋂ n : ℕ, G.weightHit n x) = 0 := by + simpa only [not_not,Set.ofPred_mem_eq] using + (ae_iff.mp (hm.mono fun _ h => G.not_iInter_weightHit_nat_of_mass_ne_top h)) + have h := tendsto_measure_iInter_atTop (μ := G.law p) + (fun n : ℕ => (G.measurableSet_weightHit (n : ℝ≥0∞) x).nullMeasurableSet) + (fun (n m : ℕ) hnm => G.weightHit_antitone x (by exact_mod_cast hnm)) ⟨0,measure_ne_top _ _⟩ + rw [hz] at h + simpa only [Function.comp_def,measureReal_def,ENNReal.toReal_zero] using + (ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp h + +lemma Aut.weightHit_preimage (φ : G.Aut) (a : ℝ≥0∞) (x : V) : + (fun ω : Set E => φ.edge '' ω) ⁻¹' G.weightHit a (φ.vertex x) = G.weightHit a x := by + ext ω + constructor + · rintro ⟨y,hxy,hy⟩ + obtain ⟨z,rfl⟩ := φ.vertex.surjective y + exact ⟨z,(SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω)).mp hxy, + by simpa only [Aut.stabilizerWeight] using hy⟩ + · rintro ⟨y,hxy,hy⟩ + exact ⟨φ.vertex y,(SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω)).mpr hxy, + by simpa only [Aut.stabilizerWeight] using hy⟩ + +lemma Aut.weightHit_real [Countable V] [Countable E] + (φ : G.Aut) (p : unitInterval) (a : ℝ≥0∞) (x : V) : + (G.law p).real (G.weightHit a (φ.vertex x)) = (G.law p).real (G.weightHit a x) := by + simp only [measureReal_def] + congr 1 + conv_lhs => rw [← G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + (G.measurableSet_weightHit _ _),φ.weightHit_preimage] + +theorem uniform_weightHit_nat_small [Countable V] [Countable E] + (hq : G.QuasiTransitive) (p : unitInterval) + (hm : ∀ x, ∀ᵐ ω ∂G.law p, G.modularMass x (G.cluster ω x) ≠ ⊤) + (ε : ℝ) (hε : 0 < ε) : + ∃ n : ℕ, ∀ x, (G.law p).real (G.weightHit n x) < ε := by + obtain ⟨S,hS,hcover⟩ := hq + have he (s : V) : ∀ᶠ n : ℕ in atTop, (G.law p).real (G.weightHit n s) < ε := + (G.tendsto_weightHit_nat_zero p s (hm s)).eventually (gt_mem_nhds hε) + obtain ⟨n,hn⟩ := (hS.toFinset.eventually_all.mpr fun s _ => he s).exists + refine ⟨n,fun x => ?_⟩ + obtain ⟨s,hs,φ,rfl⟩ := hcover x + rw [φ.weightHit_real] + exact hn s (hS.mem_toFinset.mpr hs) + +theorem nonunimodular_critical_upward_decay [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (hpc : G.criticalProbability < 1) (hu : ¬G.CombinatoriallyUnimodular) + (ε : ℝ) (hε : 0 < ε) : + ∃ n : ℕ, ∀ x, (G.law G.criticalProbability).real (G.weightHit n x) < ε := by + apply G.uniform_weightHit_nat_small hq G.criticalProbability _ ε hε + intro x + exact (G.nonunimodular_critical_mass_finite_ae hc hl hq hpc hu x).mono fun _ h => (h x).ne + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CrossingExponent.lean b/lean/OAI/Probability/BenjaminiSchramm/CrossingExponent.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd66798bd4002e9d86a3d29e50ccaff9f0dcf467 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CrossingExponent.lean @@ -0,0 +1,70 @@ +import OAI.Probability.BenjaminiSchramm.CriticalHalfspaceDecay +import Mathlib.Analysis.Subadditive + +namespace OAI + +noncomputable section +open Set Filter +open scoped Classical Topology BigOperators + +namespace Percolation.BenjaminiSchramm + +theorem positive_crossing_exponent (P : ℕ → ℝ) (hP : ∀ n, 0 < P n) + (hP1 : ∀ n, P n ≤ 1) (hP0 : P 0 = 1) + (hmul : ∀ m n, P m*P n ≤ P (m+n)) : + ∃ α : ℝ, 0 ≤ α ∧ + (∀ n : ℕ, P n ≤ Real.exp (-α*n)) ∧ + (∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + c*Real.exp (-(α+ε)*n) ≤ P n) ∧ + Tendsto (fun n : ℕ => -Real.log (P n)/n) atTop (𝓝 α) := by + let u : ℕ → ℝ := fun n => -Real.log (P n) + have hu : Subadditive u := by + intro m n + have h := Real.log_le_log (mul_pos (hP m) (hP n)) (hmul m n) + rw [Real.log_mul (hP m).ne' (hP n).ne'] at h + dsimp [u] + linarith + have hun (n : ℕ) : 0 ≤ u n := neg_nonneg.mpr (Real.log_nonpos (hP n).le (hP1 n)) + have hbdd : BddBelow (Set.range fun n : ℕ => u n/n) := + ⟨0,by rintro _ ⟨n,rfl⟩; exact div_nonneg (hun n) (Nat.cast_nonneg n)⟩ + let α := hu.lim + have hlim : Tendsto (fun n : ℕ => u n/n) atTop (𝓝 α) := hu.tendsto_lim hbdd + have hα : 0 ≤ α := ge_of_tendsto hlim (Filter.Eventually.of_forall + (fun n => div_nonneg (hun n) (Nat.cast_nonneg n))) + refine ⟨α,hα,?_,?_,hlim⟩ + · intro n + by_cases hn : n = 0 + · simp only [hn,hP0,Nat.cast_zero,mul_zero,Real.exp_zero,le_refl] + have hr := (le_div_iff₀ (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn) : (0 : ℝ) < n)).mp + (hu.lim_le_div hbdd hn) + have he := Real.exp_le_exp.mpr (show Real.log (P n) ≤ -α*n by dsimp [u] at hr; nlinarith) + rwa [Real.exp_log (hP n)] at he + · intro ε hε + obtain ⟨N,hN⟩ := eventually_atTop.mp (hlim.eventually (gt_mem_nhds (lt_add_of_pos_right α hε))) + let f : ℕ → ℝ := fun n => P n*Real.exp ((α+ε)*n) + obtain ⟨i,hi,himin⟩ := Finset.exists_min_image (Finset.range (N+1)) f + ⟨0,Finset.mem_range.mpr (Nat.succ_pos N)⟩ + let c := min 1 (f i) + have hc : 0 < c := lt_min (by norm_num) (mul_pos (hP i) (Real.exp_pos _)) + refine ⟨c,hc,fun n => ?_⟩ + by_cases hn : n < N+1 + · have hcf : c ≤ f n := (min_le_right _ _).trans (himin n (Finset.mem_range.mpr hn)) + have hh := mul_le_mul_of_nonneg_right hcf (Real.exp_pos (-(α+ε)*n)).le + have he : Real.exp ((α+ε)*n)*Real.exp (-(α+ε)*n) = 1 := by + rw [← Real.exp_add] + ring_nf + exact Real.exp_zero + dsimp [f] at hh + rwa [mul_assoc,he,mul_one] at hh + · have hnpos : (0 : ℝ) < n := Nat.cast_pos.mpr (by omega) + have hr := (div_lt_iff₀ hnpos).mp (hN n (by omega)) + have hh : -(α+ε)*(n : ℝ) ≤ Real.log (P n) := by dsimp [u] at hr; linarith + have he := Real.exp_le_exp.mpr hh + rw [Real.exp_log (hP n)] at he + exact (mul_le_of_le_one_left (Real.exp_nonneg _) (min_le_left _ _)).trans he + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CrossingExponentContinuity.lean b/lean/OAI/Probability/BenjaminiSchramm/CrossingExponentContinuity.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa6b49b8d3c14486bb7cd26a59d67615dd65a17a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CrossingExponentContinuity.lean @@ -0,0 +1,81 @@ +import OAI.Probability.BenjaminiSchramm.CrossingPositivity + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma infimalAdjustedCrossing_lower_parameter [Countable E] [Nonempty V] + (hq : G.QuasiTransitive) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) + (p : unitInterval) (hp : 0 < p) (t c : ℝ) (hc : 0 ≤ c) + (hlt : c < (G.infimalAdjustedCrossing a p t).toReal) : + ∃ q : unitInterval, (p : ℝ)/2 ≤ q ∧ q < p ∧ c < (G.infimalAdjustedCrossing a q t).toReal := by + let d := (c+(G.infimalAdjustedCrossing a p t).toReal)/2 + have hcd : c < d := by dsimp [d]; linarith + have hdp : d < (G.infimalAdjustedCrossing a p t).toReal := by dsimp [d]; linarith + obtain ⟨S,hS,hcover⟩ := hq + let : Finite S := hS.to_subtype + have hroot (x : V) : d < (G.law p).real (G.adjustedHalfspaceHit a x 0 t) := + hdp.trans_le (ENNReal.toReal_mono (measure_ne_top _ _) + (iInf_le (fun y => G.law p (G.adjustedHalfspaceHit a y 0 t)) x)) + obtain ⟨q,hhalf,hqp,hqroot⟩ := BernoulliProduct.exists_lower_parameter + (fun x : S => G.adjustedHalfspaceHit a x 0 t) (fun x => G.adjustedHalfspaceHit_upper a x 0 t) + (fun x => G.adjustedHalfspaceHit_hasFiniteOpenWitness a x 0 t) p hp (fun _ => d) + (fun x => by simpa only [BernoulliProduct.law_const,law] using hroot x) + refine ⟨q,hhalf,hqp,hcd.trans_le ?_⟩ + have he : ENNReal.ofReal d ≤ G.infimalAdjustedCrossing a q t := by + apply le_iInf + intro x + obtain ⟨o,ho,φ,rfl⟩ := hcover x + rw [Aut.adjustedHalfspaceHit_measure G a ha φ] + have hr := hqroot ⟨o,ho⟩ + rw [BernoulliProduct.law_const] at hr + exact ENNReal.ofReal_le_of_le_toReal hr.le + have hf := ENNReal.toReal_mono + (ne_top_of_le_ne_top ENNReal.one_ne_top (G.infimalAdjustedCrossing_le_one a q t)) he + rwa [ENNReal.toReal_ofReal (hc.trans hcd.le)] at hf + +theorem normalized_crossing_exponent_approximation [Fintype G.VertexOrbit] [Nontrivial V] + [Encodable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ = μ) (hu : ¬ G.CombinatoriallyUnimodular) + (p : unitInterval) (hp : 0 < p) (α : ℝ) + (hlim : Tendsto (fun n : ℕ => -Real.log + (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) p n).toReal/n) atTop (𝓝 α)) + (ε : ℝ) (hε : 0 < ε) : + ∃ q : unitInterval, (p : ℝ)/2 ≤ q ∧ q < p ∧ ∃ β : ℝ, 0 ≤ β ∧ β < α+ε ∧ + (∀ n : ℕ, (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) q n).toReal ≤ Real.exp (-β*n)) ∧ + (∀ δ : ℝ, 0 < δ → ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + c*Real.exp (-(β+δ)*n) ≤ (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) q n).toReal) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,_hA,_hB,hpos⟩ := G.infimalAdjustedCrossing_finite_energy hc hl hq μ hμ hstat hu p hp + obtain ⟨n,hn,hsl⟩ := ((eventually_ge_atTop (1 : ℕ)).and + (hlim.eventually (gt_mem_nhds (lt_add_of_pos_right α hε)))).exists + have hnpos : (0 : ℝ) < n := Nat.cast_pos.mpr (by omega) + have hPn : 0 < (G.infimalAdjustedCrossing a p n).toReal := + (Real.rpow_pos_of_pos hp _).trans_le (hpos n (Nat.cast_nonneg n)) + have hlog : -(α+ε)*(n : ℝ) < Real.log (G.infimalAdjustedCrossing a p n).toReal := by + have hh := (div_lt_iff₀ hnpos).mp hsl + linarith + have he := Real.exp_lt_exp.mpr hlog + rw [Real.exp_log hPn] at he + obtain ⟨q,hhalf,hqp,hqprob⟩ := G.infimalAdjustedCrossing_lower_parameter hq a + (G.stationaryOrbitWeight_aut μ) p hp n (Real.exp (-(α+ε)*n)) (Real.exp_pos _).le he + have hqpos : (0 : ℝ) < q := (half_pos (show (0 : ℝ) < p from hp)).trans_le hhalf + obtain ⟨β,hβ,hβupper,hβlower,_hβlim⟩ := G.normalized_crossing_exponent hc hl hq μ hμ hstat hu q hqpos + refine ⟨q,hhalf,hqp,β,hβ,?_,hβupper,hβlower⟩ + have hle := Real.exp_lt_exp.mp (hqprob.trans_le (hβupper n)) + nlinarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/CrossingPositivity.lean b/lean/OAI/Probability/BenjaminiSchramm/CrossingPositivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..e41150489df580a49f36b063650696d09ddb9b1d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/CrossingPositivity.lean @@ -0,0 +1,94 @@ +import OAI.Probability.BenjaminiSchramm.CrossingExponent + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem adjustedHalfspaceHit_walk_lower [Countable E] (a : V → ℝ) (p : unitInterval) + {x y : V} (w : G.fullGraph.Walk x y) (t : ℝ) + (hw : ∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight a x v) + (hy : t ≤ G.orbitAdjustedHeight a x y) : + (p : ℝ)^w.length ≤ (G.law p).real (G.adjustedHalfspaceHit a x 0 t) := by + have hg : G.fullGraph = Percolation.openSimpleGraph G.ends Set.univ := + criticalModel_openGraph G.ends Set.univ + let f : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by simpa only [← hg,id_eq] using h⟩ + obtain ⟨s,hs,hconn⟩ := walk_finite_open_restriction G.ends (w.map f) + {v | 0 ≤ G.orbitAdjustedHeight a x v} (by + intro v hv + rw [SimpleGraph.Walk.support_map] at hv + change v ∈ w.support.map id at hv + exact hw v (by simpa only [List.map_id_fun,id_eq] using hv)) + have hslen : s.card ≤ w.length := by simpa only [SimpleGraph.Walk.length_map] using hs + have hsub : {ω : Set E | (s : Set E) ⊆ ω} ⊆ G.adjustedHalfspaceHit a x 0 t := + fun ω hω => ⟨y,hy,hconn ω hω⟩ + calc + _ ≤ (p : ℝ)^s.card := pow_le_pow_of_le_one p.2.1 p.2.2 hslen + _ = (G.law p).real {ω : Set E | (s : Set E) ⊆ ω} := + (Percolation.finite_open_probability p s).symm + _ ≤ _ := measureReal_mono hsub + +theorem infimalAdjustedCrossing_finite_energy [Fintype G.VertexOrbit] [Nontrivial V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ = μ) (hu : ¬ G.CombinatoriallyUnimodular) + (p : unitInterval) (hp : 0 < (p : ℝ)) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ t : ℝ, 0 ≤ t → + (p : ℝ)^(A*t+B) ≤ (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) p t).toReal := by + obtain ⟨A,B,hA,hB,hpath⟩ := G.stationaryOrbitHeight_orbit_above hc hl hq μ hμ hstat hu + refine ⟨A,B,hA,hB,fun t ht => ?_⟩ + have hroot (x : V) : (p : ℝ)^(A*t+B) ≤ + (G.law p).real (G.adjustedHalfspaceHit (G.stationaryOrbitWeight μ) x 0 t) := by + obtain ⟨y,w,_horb,hlen,hw,hy⟩ := hpath t ht x (G.vertexOrbit x) + have hc := G.adjustedHalfspaceHit_walk_lower (G.stationaryOrbitWeight μ) p w t hw hy + have hcoeff : (p : ℝ)^(A*t+B) ≤ (p : ℝ)^w.length := by + simpa only [Real.rpow_natCast] using Real.rpow_le_rpow_of_exponent_ge hp p.2.2 hlen + exact hcoeff.trans hc + have he : ENNReal.ofReal ((p : ℝ)^(A*t+B)) ≤ + G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) p t := + le_iInf fun x => ENNReal.ofReal_le_of_le_toReal (hroot x) + have hf := ENNReal.toReal_mono + (ne_top_of_le_ne_top ENNReal.one_ne_top (G.infimalAdjustedCrossing_le_one _ p t)) he + rwa [ENNReal.toReal_ofReal (Real.rpow_pos_of_pos hp _).le] at hf + +theorem normalized_crossing_exponent [Fintype G.VertexOrbit] [Nontrivial V] + [Encodable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ = μ) (hu : ¬ G.CombinatoriallyUnimodular) + (p : unitInterval) (hp : 0 < (p : ℝ)) : + ∃ α : ℝ, 0 ≤ α ∧ + (∀ n : ℕ, (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) p n).toReal ≤ Real.exp (-α*n)) ∧ + (∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + c*Real.exp (-(α+ε)*n) ≤ (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) p n).toReal) ∧ + Tendsto (fun n : ℕ => -Real.log + (G.infimalAdjustedCrossing (G.stationaryOrbitWeight μ) p n).toReal/n) atTop (𝓝 α) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,_hA,_hB,hbound⟩ := G.infimalAdjustedCrossing_finite_energy hc hl hq μ hμ hstat hu p hp + obtain ⟨m,M,hm,ha⟩ := G.stationaryOrbitWeight_uniform_bounds hc hl μ hμ + have hne (t : ℝ) : G.infimalAdjustedCrossing a p t ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top (G.infimalAdjustedCrossing_le_one a p t) + apply positive_crossing_exponent (fun n : ℕ => (G.infimalAdjustedCrossing a p n).toReal) + · intro n + exact (Real.rpow_pos_of_pos hp _).trans_le (hbound n (Nat.cast_nonneg n)) + · intro n + exact (ENNReal.toReal_mono ENNReal.one_ne_top (G.infimalAdjustedCrossing_le_one a p n)).trans_eq + ENNReal.toReal_one + · simp + · intro n k + have hh := ENNReal.toReal_mono (hne (n+k)) + (G.infimalAdjustedCrossing_supermultiplicative hc hl hq a m M hm ha p + (Nat.cast_nonneg n) (Nat.cast_nonneg k)) + simpa only [ENNReal.toReal_mul,Nat.cast_add] using hh + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/DeletionBound.lean b/lean/OAI/Probability/BenjaminiSchramm/DeletionBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..4794f53138428103312992aa913b343a07a554dd --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/DeletionBound.lean @@ -0,0 +1,102 @@ +import OAI.Probability.BenjaminiSchramm.SusceptibilityDerivative +import OAI.Probability.UnimodularPercolation.Deformation.ClusterProducts + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem connection_or_first_deleted_vertex (G : BondGraph V E) (D : Set V) + (ω : Set E) (x y : V) (hc : Conn G ω x y) : + (x ∈ D ∧ Conn G (ω ∩ internalEdges G D) x y) ∨ + ∃ z ∉ D, ω ∈ DisjointOccurrence {η | Conn G η x z} {η | Conn G η z y} := by + obtain ⟨p₀⟩ := (conn_iff_reachable G ω x y).mp hc + let p := p₀.toPath.val + by_cases h : ∀ z ∈ p.support, z ∈ D + · exact Or.inl ⟨h x p.start_mem_support,walk_conn_restrict_vertices G ω p D h⟩ + · push Not at h + obtain ⟨z,hz,hzD⟩ := h + exact Or.inr ⟨z,hzD,simplePath_disjoint_at G ω p p₀.toPath.property hz⟩ + +theorem first_hit_deletion_probability [Countable V] [Countable E] + (G : BondGraph V E) (D : Set V) (p : unitInterval) (x y : V) : + law p {ω | Conn G ω x y} ≤ + (if x ∈ D then law p {ω | Conn G (ω ∩ internalEdges G D) x y} else 0) + + ∑' z, if z ∈ D then 0 else + law p {ω | Conn G ω x z} * law p {ω | Conn G ω z y} := by + let B : Set (Set E) := {ω | x ∈ D ∧ Conn G (ω ∩ internalEdges G D) x y} + let C (z : V) : Set (Set E) := if z ∈ D then ∅ else + DisjointOccurrence {ω | Conn G ω x z} {ω | Conn G ω z y} + have hc : {ω | Conn G ω x y} ⊆ B ∪ ⋃ z, C z := by + intro ω hω + rcases connection_or_first_deleted_vertex G D ω x y hω with hb | ⟨z,hz,hzω⟩ + · exact Or.inl hb + · exact Or.inr (Set.mem_iUnion.mpr ⟨z,by simpa only [C,ite_eq_right hz] using hzω⟩) + have hB : law p B = if x ∈ D then law p {ω | Conn G (ω ∩ internalEdges G D) x y} else 0 := by + by_cases hx : x ∈ D <;> simp [B,hx] + have hC (z : V) : law p (C z) ≤ if z ∈ D then 0 else + law p {ω | Conn G ω x z} * law p {ω | Conn G ω z y} := by + by_cases hz : z ∈ D + · simp only [C,ite_eq_left hz,measure_empty,le_refl] + · simp only [C,ite_eq_right hz] + exact bk_ennreal p _ _ + (fun _ _ h hconn => conn_mono G h hconn) + (fun _ _ h hconn => conn_mono G h hconn) + (finiteWitness_conn G x z) (finiteWitness_conn G z y) + calc + _ ≤ law p B + law p (⋃ z, C z) := (measure_mono hc).trans (measure_union_le _ _) + _ ≤ law p B + ∑' z, law p (C z) := add_le_add_right (measure_iUnion_le C) _ + _ ≤ _ := by rw [hB]; exact add_le_add_right (ENNReal.tsum_le_tsum hC) _ + +theorem ennreal_inducedSusceptibility [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (D : Set V) (x : V) : + ENNReal.ofReal (inducedSusceptibility G D p x) = + ∑' y, if x ∈ D then law p {ω | Conn G (ω ∩ internalEdges G D) x y} else 0 := by + by_cases hx : x ∈ D + · simp only [inducedSusceptibility,ite_eq_left hx,restrictedSusceptibility] + rw [ENNReal.ofReal_tsum_of_nonneg (fun _ => measureReal_nonneg) + (summable_restrictedTwoPoint G hloc hqt p hp _ x)] + exact tsum_congr (fun _ => ENNReal.ofReal_toReal (measure_ne_top _ _)) + · simp only [inducedSusceptibility,ite_eq_right hx,ENNReal.ofReal_zero,tsum_zero] + +theorem susceptibility_deletion_ennreal [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (D : Set V) (C : ℝ≥0∞) + (hC : ∀ z, ENNReal.ofReal (susceptibility G p z) ≤ C) (x : V) : + ENNReal.ofReal (susceptibility G p x) ≤ + ENNReal.ofReal (inducedSusceptibility G D p x) + + (∑' z, if z ∈ D then 0 else law p {ω | Conn G ω x z}) * C := by + rw [ennreal_susceptibility G hloc hqt p hp x, + ennreal_inducedSusceptibility G hloc hqt p hp D x] + calc + _ ≤ ∑' y, ((if x ∈ D then law p {ω | Conn G (ω ∩ internalEdges G D) x y} else 0) + + ∑' z, if z ∈ D then 0 else law p {ω | Conn G ω x z} * law p {ω | Conn G ω z y}) := + ENNReal.tsum_le_tsum (first_hit_deletion_probability G D p x) + _ = (∑' y, if x ∈ D then law p {ω | Conn G (ω ∩ internalEdges G D) x y} else 0) + + ∑' z, (if z ∈ D then 0 else law p {ω | Conn G ω x z}) * + (∑' y, law p {ω | Conn G ω z y}) := by + rw [ENNReal.tsum_add,ENNReal.tsum_comm] + congr 1 + apply tsum_congr + intro z + by_cases hz : z ∈ D + · simp only [ite_eq_left hz,tsum_zero,zero_mul] + · simp only [ite_eq_right hz,ENNReal.tsum_mul_left] + _ ≤ _ := by + apply add_le_add_right + rw [←ENNReal.tsum_mul_right] + apply ENNReal.tsum_le_tsum + intro z + rw [←ennreal_susceptibility G hloc hqt p hp z] + exact mul_le_mul' le_rfl (hC z) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/DeletionLoss.lean b/lean/OAI/Probability/BenjaminiSchramm/DeletionLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..3294c0b14a41028bcbcbfd0428ebf6f89ebc1287 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/DeletionLoss.lean @@ -0,0 +1,125 @@ +import OAI.Probability.BenjaminiSchramm.DeletionBound + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem connection_measure_symm (G : BondGraph V E) (p : unitInterval) (x y : V) : + law p {ω | Conn G ω x y} = law p {ω | Conn G ω y x} := by + congr 1 + ext ω + exact ⟨conn_symm G ω,conn_symm G ω⟩ + +noncomputable def openTriangle (G : BondGraph V E) (p : unitInterval) (x y : V) : ℝ≥0∞ := + ∑' a, ∑' z, law p {ω | Conn G ω x a} * law p {ω | Conn G ω a z} * + law p {ω | Conn G ω z y} + +theorem lintegral_clusterMass_conn [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (x z : V) : + (∫⁻ ω, (if Conn G ω x z then clusterMass G ω x else 0) ∂law p) = + ∑' u, law p {ω | Conn G ω x u ∧ Conn G ω x z} := by + have he (ω : Set E) : (if Conn G ω x z then clusterMass G ω x else 0) = + ∑' u, if Conn G ω x u ∧ Conn G ω x z then (1 : ℝ≥0∞) else 0 := by + by_cases hz : Conn G ω x z + · simp only [hz,ite_true,and_true,clusterMass] + · simp only [hz,ite_false,and_false,tsum_zero] + have hm (u : V) : Measurable (fun ω : Set E => + if Conn G ω x u ∧ Conn G ω x z then (1 : ℝ≥0∞) else 0) := + Measurable.ite ((measurableSet_conn G x u).inter (measurableSet_conn G x z)) + measurable_const measurable_const + simp_rw [he] + rw [lintegral_tsum (fun u => (hm u).aemeasurable)] + apply tsum_congr + intro u + have hs : MeasurableSet {ω : Set E | Conn G ω x u ∧ Conn G ω x z} := + (measurableSet_conn G x u).inter (measurableSet_conn G x z) + simpa only [Set.indicator,Pi.one_apply,Set.mem_ofPred_eq] using + lintegral_indicator_one (μ := law p) hs + +theorem three_arm_first_moment_bound [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (C : ℝ≥0∞) + (hC : ∀ a, (∑' u, law p {ω | Conn G ω a u}) ≤ C) (x z : V) : + (∑' u, law p {ω | Conn G ω x u ∧ Conn G ω x z}) ≤ + C * ∑' a, law p {ω | Conn G ω x a} * law p {ω | Conn G ω a z} := by + calc + _ ≤ ∑' u, ∑' a, law p {ω | Conn G ω x a} * law p {ω | Conn G ω a u} * + law p {ω | Conn G ω a z} := ENNReal.tsum_le_tsum (fun u => three_arm_bound G p x u z) + _ = ∑' a, law p {ω | Conn G ω x a} * (∑' u, law p {ω | Conn G ω a u}) * + law p {ω | Conn G ω a z} := by + rw [ENNReal.tsum_comm] + simp_rw [ENNReal.tsum_mul_right,ENNReal.tsum_mul_left] + _ ≤ ∑' a, law p {ω | Conn G ω x a} * C * law p {ω | Conn G ω a z} := + ENNReal.tsum_le_tsum (fun a => mul_le_mul' (mul_le_mul' le_rfl (hC a)) le_rfl) + _ = _ := by + rw [←ENNReal.tsum_mul_left] + apply tsum_congr + intro a + ring + +noncomputable def clusterDeletionLoss (G : BondGraph V E) (p : unitInterval) + (x y : V) (ω : Set E) : ℝ≥0∞ := + clusterMass G ω x * ∑' z, if Conn G ω x z then law p {η | Conn G η y z} else 0 + +theorem measurable_clusterDeletionLoss [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (x y : V) : + Measurable (clusterDeletionLoss G p x y) := + (measurable_clusterMass G x).mul (Measurable.tsum (fun z => + Measurable.ite (measurableSet_conn G x z) measurable_const measurable_const)) + +theorem lintegral_clusterDeletionLoss [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (x y : V) : + (∫⁻ ω, clusterDeletionLoss G p x y ω ∂law p) = + ∑' z, law p {ω | Conn G ω y z} * + ∑' u, law p {ω | Conn G ω x u ∧ Conn G ω x z} := by + have hm (z : V) : Measurable (fun ω : Set E => + if Conn G ω x z then clusterMass G ω x else 0) := + Measurable.ite (measurableSet_conn G x z) (measurable_clusterMass G x) measurable_const + have he (ω : Set E) : clusterDeletionLoss G p x y ω = + ∑' z, law p {η | Conn G η y z} * (if Conn G ω x z then clusterMass G ω x else 0) := by + dsimp only [clusterDeletionLoss] + rw [←ENNReal.tsum_mul_left] + apply tsum_congr + intro z + split_ifs <;> ring + have hm' (z : V) : Measurable (fun ω : Set E => + law p {η | Conn G η y z} * (if Conn G ω x z then clusterMass G ω x else 0)) := + measurable_const.mul (hm z) + simp_rw [he] + rw [lintegral_tsum (fun z => (hm' z).aemeasurable)] + apply tsum_congr + intro z + rw [lintegral_const_mul _ (hm z),lintegral_clusterMass_conn] + +theorem clusterDeletionLoss_openTriangle_bound [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (C : ℝ≥0∞) + (hC : ∀ a, (∑' u, law p {ω | Conn G ω a u}) ≤ C) (x y : V) : + (∫⁻ ω, clusterDeletionLoss G p x y ω ∂law p) ≤ C * openTriangle G p x y := by + rw [lintegral_clusterDeletionLoss] + calc + _ ≤ ∑' z, law p {ω | Conn G ω y z} * + (C * ∑' a, law p {ω | Conn G ω x a} * law p {ω | Conn G ω a z}) := + ENNReal.tsum_le_tsum (fun z => + mul_le_mul' le_rfl (three_arm_first_moment_bound G p C hC x z)) + _ = ∑' z, ∑' a, C * (law p {ω | Conn G ω x a} * law p {ω | Conn G ω a z} * + law p {ω | Conn G ω z y}) := by + apply tsum_congr + intro z + rw [←ENNReal.tsum_mul_left,←ENNReal.tsum_mul_left,connection_measure_symm G p y z] + apply tsum_congr + intro a + ring + _ = _ := by + rw [ENNReal.tsum_comm] + simp_rw [ENNReal.tsum_mul_left] + rfl + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/DownLayerReciprocity.lean b/lean/OAI/Probability/BenjaminiSchramm/DownLayerReciprocity.lean new file mode 100644 index 0000000000000000000000000000000000000000..48c73a3c5bf519ab95fe3c77a31d427bc67943e0 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/DownLayerReciprocity.lean @@ -0,0 +1,88 @@ +import OAI.Probability.BenjaminiSchramm.CeilingBandUniform + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma downLayerCount_le_ceilingBandCount + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (n : ℕ) (x : V) (u : ℝ) (ω : Set E) : + restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v ≤ 0}) + {v | G.adjustedLayerIndex a R u x v = -(n : ℤ)} ω x ≤ + G.adjustedCeilingBandCount a R (-(R*((n : ℝ)+1))) (-(R*((n : ℝ)-1))) ω x := by + have hD : {v | G.adjustedLayerIndex a R u x v ≤ 0} ⊆ + {v | G.orbitAdjustedHeight a x v ≤ R} := by + intro v hv + have hh := (G.adjustedLayerIndex_height_bounds a R u hR x v).2 + have hi : (G.adjustedLayerIndex a R u x v : ℝ) ≤ 0 := by exact_mod_cast hv + change G.orbitAdjustedHeight a x v ≤ R + nlinarith + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : G.adjustedLayerIndex a R u x y = -(n : ℤ) ∧ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | G.adjustedLayerIndex a R u x v ≤ 0}) x y + · have hh := G.adjustedLayerIndex_height_bounds a R u hR x y + rw [hy.1] at hh + push_cast at hh + have ht : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | G.orbitAdjustedHeight a x v ≤ R}) x y ∧ + -(R*((n : ℝ)+1)) ≤ G.orbitAdjustedHeight a x y ∧ + G.orbitAdjustedHeight a x y ≤ -(R*((n : ℝ)-1)) := by + exact ⟨Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends hD)) hy.2,by linarith [hh.1],by linarith [hh.2]⟩ + simp only [Set.mem_ofPred_eq,adjustedCeilingBandTransport,ite_eq_left hy,ite_eq_left ht,le_refl] + · simp only [Set.mem_ofPred_eq,ite_eq_right hy] + exact bot_le + +variable [Countable V] [Countable E] + +theorem adjustedDownLayerMoment_le_shifted_up + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (n : ℕ) (hn : 3 ≤ n) (x : V) (u : ℝ) : + G.adjustedDownLayerMoment a R p n x u ≤ + ((ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r)))* + ENNReal.ofReal (Real.exp (R*((n : ℝ)+1)))* + (G.supAdjustedUpLayerMoment a R p (n-2)*C) := by + have hnm : 0 < n-2 := by omega + have hmin : R*(n-2 : ℕ) ≤ -(-(R*((n : ℝ)-1))) := by + rw [Nat.cast_sub (by omega : 2 ≤ n)] + push_cast + nlinarith + have hsup : (⨆ y, ∫⁻ ω, G.adjustedCeilingBandCount a + (R-(-(R*((n : ℝ)+1)))) (-(-(R*((n : ℝ)-1)))) (-(-(R*((n : ℝ)+1)))) ω y ∂G.law p) ≤ + G.supAdjustedUpLayerMoment a R p (n-2)*C := by + apply iSup_le + intro y + exact (G.expected_ceilingBandCount_le_intermediate_upLayerMoment hc hl a R hR hjump + p C hrow (n-2) hnm y _ _ _ hmin).trans + (mul_le_mul' (G.adjustedUpLayerMoment_le_sup a R p (n-2) y 0) le_rfl) + calc + _ ≤ ∫⁻ ω, G.adjustedCeilingBandCount a R + (-(R*((n : ℝ)+1))) (-(R*((n : ℝ)-1))) ω x ∂G.law p := + lintegral_mono (G.downLayerCount_le_ceilingBandCount a R hR n x u) + _ ≤ _ := by + have hh := (G.expected_ceilingBandCount_uniform_bound O hc hl a hapos ha m hm ham + p R (-(R*((n : ℝ)+1))) (-(R*((n : ℝ)-1))) x).trans + (mul_le_mul' le_rfl hsup) + simpa only [neg_neg] using hh + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/DownwardHalfspaceFromContinuation.lean b/lean/OAI/Probability/BenjaminiSchramm/DownwardHalfspaceFromContinuation.lean new file mode 100644 index 0000000000000000000000000000000000000000..0feb7e10c5f5fe4c6ac35aeabe0b772f530cd5a6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/DownwardHalfspaceFromContinuation.lean @@ -0,0 +1,173 @@ +import OAI.Probability.BenjaminiSchramm.CeilingZeroBand + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem downward_halfspace_from_continuation + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (d : ℕ) (hd : ∀ u, (Percolation.finite_neighbors hl u).toFinset.card ≤ d) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → |G.orbitAdjustedHeight a u v| ≤ R) + (p : unitInterval) (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (L : ℝ) (hdown : G.lowerSlabFractionalProfile a p R L) + (q t : ℝ) (hq : 0 < q) (hq1 : q < 1) (ht : 0 < t) (ht1 : t < 1) + (D : ℝ≥0∞) (hD : D < ⊤) + (hup : ∀ s : ℝ, 0 ≤ s → ∀ z : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -R ≤ G.orbitAdjustedHeight a z v}) + {v | s-R ≤ G.orbitAdjustedHeight a z v ∧ G.orbitAdjustedHeight a z v ≤ s+R} ω z)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (-s/2))) : + ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+R} ω x)^(q*t) ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k)) := by + intro ζ hζ + let ε := min ζ (t/4) + have hε : 0 < ε := lt_min hζ (by positivity) + have hεζ : ε ≤ ζ := min_le_left _ _ + have hεt : ε ≤ t/4 := min_le_right _ _ + have hqt : 0 < q*t := mul_pos hq ht + have hqt1 : q*t < 1 := (mul_le_mul_of_nonneg_right hq1.le ht.le).trans_lt (by simpa using ht1) + obtain ⟨A,hA,hab⟩ := hdown t ht ht1 ε hε + obtain ⟨B,hB,hbb⟩ := hdown (q*t) hqt hqt1 ε hε + let K := (d : ℝ≥0∞)^t*A*D^t + have hK : K < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.rpow_lt_top_of_nonneg ht.le (ENNReal.natCast_ne_top d)) hA) + (ENNReal.rpow_lt_top_of_nonneg ht.le hD.ne) + let S : ℝ≥0∞ := ∑' n : ℕ, ENNReal.ofReal (Real.exp (-(t*R/4)*n)) + have hS : S < ⊤ := by + apply Summable.tsum_ofReal_lt_top + simpa only [mul_comm] using Real.summable_exp_nat_mul_iff.mpr + (neg_neg_of_pos (show 0 < t*R/4 by positivity)) + refine ⟨B+K*S,ENNReal.add_lt_top.mpr ⟨hB,ENNReal.mul_lt_top hK hS⟩,fun k hk x => ?_⟩ + let f := fun z => -G.orbitAdjustedHeight a x z + let W := {v | -k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+R} + let F (n : ℕ) := ∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -(k+(n : ℝ)*R) ≤ G.orbitAdjustedHeight a x v ∧ + G.orbitAdjustedHeight a x v ≤ 0}) W ω x)^(q*t) ∂G.law p + let Z := ENNReal.ofReal (Real.exp (ε*k)) + have h0 : F 0 ≤ B*Z := by + have hh := hbb k hk 0 (by norm_num) x + simpa only [F,Nat.cast_zero,zero_mul,add_zero,sub_zero,mul_zero,add_zero, + G.adjustedSlabBandCount_eq_restricted] using hh + have hstep (n : ℕ) : F (n+1) ≤ F n+K*Z*ENNReal.ofReal (Real.exp (-(t*R/4)*n)) := by + let b := k+(n : ℝ)*R + let J := Percolation.internalEdges G.ends + {v | -(k+((n : ℝ)+1)*R) ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ 0} + let M := D*ENNReal.ofReal (Real.exp (-((n : ℝ)*R)/2)) + have hM (z : V) (hzlo : b < f z) (hzhi : f z ≤ b+R) : + (∫⁻ ω, (restrictedLayerCount G.ends J W ω z)^q ∂G.law p) ≤ M := by + let s := -k-G.orbitAdjustedHeight a x z + have hs : 0 ≤ s := by + dsimp [s,f,b] at * + nlinarith [Nat.cast_nonneg (α := ℝ) n] + apply le_trans _ ((hup s hs z).trans ?_) + · apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ hq.le + apply (restrictedLayerCount_mono_edges G.ends ?_ W ω z).trans + · apply restrictedLayerCount_mono_vertices G.ends + intro v hv + have he := G.orbitAdjustedHeight_change_base hc hl a x z v + dsimp [s,W] at hv ⊢ + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + · apply Percolation.internalEdges_mono G.ends + intro v hv + have he := G.orbitAdjustedHeight_change_base hc hl a x z v + dsimp [J,f,b] at hv hzlo hzhi ⊢ + linarith [hv.1] + · apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + dsimp [s,f,b] at * + linarith + have hIeq : Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ b}= + Percolation.internalEdges G.ends {v | -b ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ 0} := by + congr 1 + ext v + dsimp [f] + constructor <;> intro hv <;> constructor <;> linarith [hv.1,hv.2] + have hI : ∀ᵐ ω ∂G.law p, + (Percolation.cluster G.ends (ω ∩ Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ b}) x).Finite := by + filter_upwards [hfin x] with ω hω + exact hω.subset fun v hv => Percolation.conn_mono G.ends inter_subset_left hv + have hj : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → |f v-f u| ≤ R := by + intro e u v hu hv + simpa only [f,neg_sub_neg,abs_sub_comm] using + G.height_difference_jump hc hl a R hjump x e u v hu hv + have hh := lower_slab_fractional_recurrence G.ends hl d hd (fun _ => p) f R 0 b hj J + (Percolation.internalEdges_mono G.ends (fun v hv => by dsimp [f]; linarith [hv.2])) x + (by simp only [f,G.orbitAdjustedHeight_self,neg_zero]; exact ⟨le_rfl,by dsimp [b]; positivity⟩) + (by simpa only [CriticalPercolation.BernoulliProduct.law_const,CriticalPercolation.BondGraph.law] using hI) + W hq hq1.le ht ht1.le M + (fun z hzlo hzhi => by simpa only [CriticalPercolation.BernoulliProduct.law_const, + CriticalPercolation.BondGraph.law] using hM z hzlo hzhi) + simp only [CriticalPercolation.BernoulliProduct.law_const,hIeq] at hh + have htop : (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -b ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ 0}) + {v | b-R ≤ f v ∧ f v ≤ b} ω x)^t ∂G.law p) ≤ A*ENNReal.ofReal (Real.exp (ε*b)) := by + have hb := hab b (by dsimp [b]; positivity) 0 (by norm_num) x + simp only [sub_zero,mul_zero,add_zero] at hb + apply le_trans _ hb + apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ ht.le + rw [G.adjustedSlabBandCount_eq_restricted] + apply restrictedLayerCount_mono_vertices G.ends + intro v hv + dsimp [f] at hv + exact ⟨by linarith [hv.2],by linarith [hv.1]⟩ + have hcast : ((n+1 : ℕ) : ℝ)=(n : ℝ)+1 := by norm_cast + simp only [F,hcast] + apply hh.trans + apply add_le_add le_rfl + apply (mul_le_mul' (mul_le_mul' le_rfl htop) le_rfl).trans + dsimp [M] + rw [ENNReal.mul_rpow_of_nonneg _ _ ht.le,ennreal_exp_rpow _ _ ht.le] + have he : ε*b+(-((n : ℝ)*R)/2)*t ≤ ε*k+(-(t*R/4)*(n : ℝ)) := by + have hh := mul_le_mul_of_nonneg_right hεt (mul_nonneg (Nat.cast_nonneg n) hR.le) + dsimp [b] + nlinarith + calc + _ = K*ENNReal.ofReal (Real.exp (ε*b+(-((n : ℝ)*R)/2)*t)) := by + dsimp [K] + rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ K*ENNReal.ofReal (Real.exp (ε*k+(-(t*R/4)*(n : ℝ)))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by + dsimp [Z,K] + rw [Real.exp_add (ε*k) (-(t*R/4)*(n : ℝ)),ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + ac_rfl + have hF := geometric_increment_factored F B K Z (t*R/4) h0 hstep + have he (n : ℕ) : -k-(n : ℝ)*R= -(k+(n : ℝ)*R) := by ring + have hlim := restrictedLayerMoment_iUnion G.ends + (fun n : ℕ => Percolation.internalEdges G.ends {v | -k-(n : ℝ)*R ≤ G.orbitAdjustedHeight a x v ∧ + G.orbitAdjustedHeight a x v ≤ 0}) + (internalEdges_lowerSlabs_shift_monotone G.ends _ R 0 (-k) hR.le) W x p hqt + rw [internalEdges_lowerSlabs_shift_iUnion G.ends _ R 0 (-k) hR] at hlim + have hh : (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ 0}) W ω x)^(q*t) ∂G.law p) ≤ + (B+K*S)*Z := by + simp only [CriticalPercolation.BondGraph.law,Percolation.law] at hlim ⊢ + rw [hlim] + apply iSup_le + intro n + simpa only [F,he,CriticalPercolation.BondGraph.law] using hF n + apply hh.trans + exact mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right hεζ hk))) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/EdgeClosing.lean b/lean/OAI/Probability/BenjaminiSchramm/EdgeClosing.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b7267145e23e95059f943c4908430afa413fcd2 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/EdgeClosing.lean @@ -0,0 +1,68 @@ +import OAI.Probability.CriticalPercolation.ProductMeasure.BernoulliSingleton + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BernoulliProduct +variable {E : Type*} + +lemma force_closed_after_singleton (e : E) (σ ω : Set E) : + forceOn {e} ∅ (forceOn {e} σ ω) = forceOn {e} ∅ ω := by + ext f + by_cases hf : f = e <;> simp [hf] + +lemma lintegral_singleton_decomposition (q : E → unitInterval) (e : E) + (f : Set E → ℝ≥0∞) (hf : Measurable f) : + (∫⁻ ω, f ω ∂law q) = + bitMeasure (q e) {True} * (∫⁻ ω, f (forceOn {e} Set.univ ω) ∂law q) + + bitMeasure (q e) {False} * (∫⁻ ω, f (forceOn {e} ∅ ω) ∂law q) := by + conv_lhs => rw [law_singleton_decomposition q e] + rw [lintegral_add_measure, lintegral_smul_measure, lintegral_smul_measure, + lintegral_map hf (measurable_forceOn _ _), lintegral_map hf (measurable_forceOn _ _)] + rfl + +lemma lintegral_open_closed_observable (q : E → unitInterval) (e : E) + (F : Set E → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ ω, if e ∈ ω then F (forceOn {e} ∅ ω) else 0 ∂law q) = + bitMeasure (q e) {True} * ∫⁻ ω, F (forceOn {e} ∅ ω) ∂law q := by + have hm : Measurable (fun ω => if e ∈ ω then F (forceOn {e} ∅ ω) else 0) := + (hF.comp (measurable_forceOn _ _)).ite (measurable_set_mem e).setOf measurable_const + rw [lintegral_singleton_decomposition q e _ hm] + simp only [mem_forceOn, Set.mem_singleton, ite_true, Set.mem_univ, + Set.mem_empty_iff_false, ite_false, force_closed_after_singleton, + lintegral_zero, mul_zero, add_zero] + +lemma lintegral_closed_observable (q : E → unitInterval) (e : E) + (F : Set E → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ ω, if e ∉ ω then F ω else 0 ∂law q) = + bitMeasure (q e) {False} * ∫⁻ ω, F (forceOn {e} ∅ ω) ∂law q := by + have hm : Measurable (fun ω => if e ∉ ω then F ω else 0) := + hF.ite (measurable_set_mem e).setOf.compl measurable_const + rw [lintegral_singleton_decomposition q e _ hm] + simp only [mem_forceOn, Set.mem_singleton, ite_true, Set.mem_univ, + Set.mem_empty_iff_false, not_true_eq_false, not_false_eq_true, + ite_false, ite_true, lintegral_zero, mul_zero, zero_add] + +theorem lintegral_edge_closing (q : E → unitInterval) (e : E) + (he : (q e : ℝ) < 1) (F : Set E → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ ω, if e ∈ ω then F (forceOn {e} ∅ ω) else 0 ∂law q) = + (ENNReal.ofReal (q e : ℝ) / ENNReal.ofReal (1 - (q e : ℝ))) * + (∫⁻ ω, if e ∉ ω then F ω else 0 ∂law q) := by + have hbit (b : Prop) : bitMeasure (q e) {b} = ENNReal.ofReal (bitWeight (q e) b) := by + rw [← ENNReal.ofReal_toReal (measure_ne_top _ _)] + congr 1 + exact bitMeasure_real_singleton (q e) b + have hne : ENNReal.ofReal (1 - (q e : ℝ)) ≠ 0 := (ENNReal.ofReal_pos.mpr (sub_pos.mpr he)).ne' + rw [lintegral_open_closed_observable q e F hF, lintegral_closed_observable q e F hF, + hbit True, hbit False] + simp only [bitWeight, ite_true, ite_false] + rw [← mul_assoc, ENNReal.div_mul_cancel hne ENNReal.ofReal_ne_top] + +end CriticalPercolation.BernoulliProduct + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/EntropyEvent.lean b/lean/OAI/Probability/BenjaminiSchramm/EntropyEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..e67106fd8a17de268bcddd682c0f5822585733c0 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/EntropyEvent.lean @@ -0,0 +1,72 @@ +import OAI.Probability.CriticalPercolation.Entropy.Divergence + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +open CriticalPercolation.FiniteEntropy + +theorem exp_neg_one_le_half : Real.exp (-1) ≤ 1 / 2 := by + have hh := mul_le_mul_of_nonneg_right (Real.add_one_le_exp (1 : ℝ)) + (Real.exp_pos (-1)).le + have he : Real.exp (1 : ℝ) * Real.exp (-1) = 1 := by rw [←Real.exp_add]; norm_num + rw [he] at hh + norm_num only [one_add_one_eq_two] at hh + linarith + +theorem event_mass_le_two_add_divergence + {X : Type*} [Fintype X] (P Q : X → ℝ) (A : X → Bool) + (hP : ∀ x, 0 ≤ P x) (hQ : ∀ x, 0 ≤ Q x) + (hPsum : ∑ x, P x = 1) (hQsum : ∑ x, Q x = 1) + (hs : ∀ x, 0 < P x → 0 < Q x) : + (∑ x, if A x then Q x else 0) ≤ + 2 * (∑ x, if A x then P x else 0) + 2 * divergence P Q := by + let g : X → ℝ := fun x => if A x then -1 else 0 + let a : ℝ := ∑ x, if A x then P x else 0 + let b : ℝ := ∑ x, if A x then Q x else 0 + have hb : 0 ≤ b := Finset.sum_nonneg (fun x _ => by split_ifs; exact hQ x; rfl) + have htest : (∑ x, P x * g x) = -a := by + dsimp only [a] + rw [←Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro x _ + dsimp [g] + split_ifs <;> ring + have hZ : (∑ x, Q x * Real.exp (g x)) = 1 - (1 - Real.exp (-1)) * b := by + dsimp only [b] + calc + _ = (∑ x, Q x) - (1 - Real.exp (-1)) * (∑ x, if A x then Q x else 0) := by + rw [Finset.mul_sum,←Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + dsimp [g] + split_ifs + · ring + · rw [Real.exp_zero] + ring + _ = _ := by rw [hQsum] + have hZpos := normalizer_pos P Q hP hQ hPsum hs g + have hlog := Real.log_le_sub_one_of_pos hZpos + have hentropy := entropy_inequality P Q hP hQ hPsum hs g + rw [htest,hZ] at hentropy + rw [hZ] at hlog + have hh := mul_le_mul_of_nonneg_right exp_neg_one_le_half hb + change b ≤ 2 * a + 2 * divergence P Q + linarith + +theorem divergence_mul + {X : Type*} [Fintype X] (P Q : X → ℝ) + (hP : ∀ x, 0 < P x) (hQ : ∀ x, 0 < Q x) (hPsum : ∑ x, P x = 1) + (a b : ℝ) (ha : 0 < a) (hb : 0 < b) : + divergence (fun x => a * P x) (fun x => b * Q x) = + a * divergence P Q + a * Real.log (a / b) := by + have ht (x : X) : (a * P x) * Real.log ((a * P x) / (b * Q x)) = + a * (P x * Real.log (P x / Q x)) + (a * Real.log (a / b)) * P x := by + rw [show (a * P x) / (b * Q x) = (a / b) * (P x / Q x) by ring, + Real.log_mul (div_ne_zero ha.ne' hb.ne') (div_ne_zero (hP x).ne' (hQ x).ne')] + ring + simp only [divergence,ht,Finset.sum_add_distrib,←Finset.mul_sum,hPsum,mul_one] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/EventLeftContinuity.lean b/lean/OAI/Probability/BenjaminiSchramm/EventLeftContinuity.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb139b7d05c6817676b3675ee37701317d7cafdd --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/EventLeftContinuity.lean @@ -0,0 +1,67 @@ +import OAI.Probability.BenjaminiSchramm.PeakComparison +import OAI.Probability.CriticalPercolation.ProductMeasure.MonotoneBernoulli + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace Percolation.BenjaminiSchramm +variable {E : Type*} + +lemma finset_subset_monotone_iUnion (s : Finset E) (W : ℕ → Set E) (hW : Monotone W) + (hs : (s : Set E) ⊆ ⋃ n, W n) : ∃ n, (s : Set E) ⊆ W n := by + induction s using Finset.induction_on with + | empty => exact ⟨0,by simp⟩ + | @insert e s he ih => + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp (hs (Finset.mem_insert_self e s)) + obtain ⟨m,hm⟩ := ih (fun _ h => hs (Finset.mem_insert_of_mem h)) + refine ⟨max n m,?_⟩ + intro f hf + rcases Finset.mem_insert.mp hf with rfl | hf + · exact hW (le_max_left _ _) hn + · exact hW (le_max_right _ _) (hm hf) + +lemma finiteWitness_mem_iUnion_iff (A : Set (Set E)) (hA : IsUpperSet A) (hfA : FiniteWitness A) + (W : ℕ → Set E) (hW : Monotone W) : (⋃ n, W n) ∈ A ↔ ∃ n, W n ∈ A := by + constructor + · intro h + obtain ⟨s,hs,hsa⟩ := hfA _ h + obtain ⟨n,hn⟩ := finset_subset_monotone_iUnion s W hW hs + exact ⟨n,hA hn hsa⟩ + · rintro ⟨n,hn⟩ + exact hA (Set.subset_iUnion W n) hn + +theorem law_finiteWitness_left_tendsto [Countable E] + (A : Set (Set E)) (hA : IsUpperSet A) (hfA : FiniteWitness A) + (p : unitInterval) (q : ℕ → unitInterval) (hmono : Monotone q) + (hqp : ∀ n, q n ≤ p) (hq : Tendsto q atTop (𝓝 p)) : + Tendsto (fun n => law (q n) A) atTop (𝓝 (law p A)) := by + let B := fun n => CriticalPercolation.BernoulliProduct.atParameter (q n) ⁻¹' A + have hmA := measurableSet_finiteWitness A hA hfA + have hB : Monotone B := by + intro n m hnm u hu + exact hA (CriticalPercolation.BernoulliProduct.atParameter_mono u (hmono hnm)) hu + have heq : (⋃ n, B n) = CriticalPercolation.BernoulliProduct.atParameter p ⁻¹' A := by + ext u + simp only [Set.mem_iUnion,Set.mem_preimage] + rw [← CriticalPercolation.BernoulliProduct.atParameter_iUnion p q hqp hq u] + exact (finiteWitness_mem_iUnion_iff A hA hfA _ + (fun n m hnm => CriticalPercolation.BernoulliProduct.atParameter_mono u (hmono hnm))).symm + have hμ (r : unitInterval) : CriticalPercolation.BernoulliProduct.markLaw + (CriticalPercolation.BernoulliProduct.atParameter r ⁻¹' A) = law r A := by + rw [← Measure.map_apply (CriticalPercolation.BernoulliProduct.measurable_atParameter r) hmA, + CriticalPercolation.BernoulliProduct.markLaw_map_atParameter, + CriticalPercolation.BernoulliProduct.law_const] + rfl + have h := tendsto_measure_iUnion_atTop (μ := CriticalPercolation.BernoulliProduct.markLaw) + hB + rw [heq,hμ] at h + simpa only [Function.comp_def,B,hμ] using h + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/EventMeasurability.lean b/lean/OAI/Probability/BenjaminiSchramm/EventMeasurability.lean new file mode 100644 index 0000000000000000000000000000000000000000..97c37cb04019038e9aeb7e08409a527d2d52fce0 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/EventMeasurability.lean @@ -0,0 +1,119 @@ +import OAI.Probability.BenjaminiSchramm.PublishedConsequences + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem volumeEvent_eq_clusterLarge (G : BondGraph V E) (x : V) (n : ℕ) : + volumeEvent G x n = clusterLarge G x n := by + ext ω + constructor + · intro h + by_cases hf : (cluster G ω x).Finite + · have hn : n ≤ (cluster G ω x).ncard := by + change (n : ℕ∞) ≤ (cluster G ω x).encard at h + rw [← hf.cast_ncard_eq] at h + exact_mod_cast h + exact ⟨hf.toFinset, by simpa only [← Set.ncard_eq_toFinset_card _ hf] using hn, + fun y hy => hf.mem_toFinset.mp hy⟩ + · obtain ⟨t, ht, hn⟩ := (Set.not_finite.mp hf).exists_subset_card_eq n + exact ⟨t, hn.ge, ht⟩ + · rintro ⟨t, hn, ht⟩ + change (n : ℕ∞) ≤ (cluster G ω x).encard + have hsub : (t : Set V) ⊆ cluster G ω x := ht + have hcard := Set.encard_le_encard hsub + have hn' : (n : ℕ∞) ≤ (t.card : ℕ∞) := by exact_mod_cast hn + exact hn'.trans (by simpa using hcard) + +theorem measurableSet_volumeEvent [Countable E] (G : BondGraph V E) (x : V) (n : ℕ) : + MeasurableSet (volumeEvent G x n) := by + rw [volumeEvent_eq_clusterLarge] + exact measurableSet_clusterLarge G x n + +theorem measurableSet_extrinsicRadiusEvent [Countable V] [Countable E] + (G : BondGraph V E) (x : V) (n : ℕ) : + MeasurableSet (extrinsicRadiusEvent G x n) := by + exact (Measurable.exists fun y => + (measurableSet_setOfPred.mp (measurableSet_conn G x y)).and measurable_const).setOf + +theorem along_exists_walk_length_le (G : BondGraph V E) (ω : Set E) + {x y : V} {l : List E} (h : Along G x l y) (ho : ∀ e ∈ l, e ∈ ω) : + ∃ w : (openSimpleGraph G ω).Walk x y, w.length ≤ l.length := by + induction h with + | nil => exact ⟨.nil, by simp⟩ + | @cons x z y l e he h ih => + obtain ⟨w, hw⟩ := ih (fun f hf => ho f (by simp [hf])) + by_cases hxz : x = z + · subst z + exact ⟨w, hw.trans (by simp)⟩ + · refine ⟨.cons ⟨hxz, e, ho e (by simp), he⟩ w, ?_⟩ + change w.length + 1 ≤ l.length + 1 + exact Nat.add_le_add_right hw 1 + +theorem intrinsicBall_iff_distance_le (G : BondGraph V E) (ω : Set E) + (x y : V) (M : ℕ) (hc : Conn G ω x y) : + y ∈ intrinsicBall G ω x M ↔ (openSimpleGraph G ω).dist x y ≤ M := by + constructor + · rintro ⟨l, hl, hlen, ho⟩ + obtain ⟨w, hw⟩ := along_exists_walk_length_le G ω hl ho + exact (SimpleGraph.dist_le w).trans (hw.trans hlen) + · intro hd + obtain ⟨w, hw⟩ := ((conn_iff_reachable G ω x y).mp hc).exists_walk_length_eq_dist + obtain ⟨l, hl, he, ho⟩ := walk_lift_bonds G ω w + have hlen : l.length = w.length := by + have he' := congrArg List.length he + simpa only [List.length_map, SimpleGraph.Walk.length_edges] using he' + exact ⟨l, hl, hlen.trans_le (hw.trans_le hd), ho⟩ + +theorem measurableSet_mem_intrinsicBall (G : BondGraph V E) (hloc : LocallyFinite G) + (x y : V) (M : ℕ) : MeasurableSet {ω | y ∈ intrinsicBall G ω x M} := by + let Q := incidentSupport G hloc (finite_reachBall hloc x M).toFinset + have he : {ω | y ∈ intrinsicBall G ω x M} = + {ω | ω ∩ (Q : Set E) ∈ {η | y ∈ intrinsicBall G η x M}} := by + ext ω + change (y ∈ intrinsicBall G ω x M) ↔ (y ∈ intrinsicBall G (ω ∩ (Q : Set E)) x M) + rw [intrinsicBall_restrict G hloc] + rw [he] + exact measurableSet_finite_restriction Q _ + +theorem intrinsicRadiusEvent_eq (G : BondGraph V E) (x : V) {n : ℕ} (hn : 0 < n) : + intrinsicRadiusEvent G x n = + {ω | ∃ y, Conn G ω x y ∧ y ∉ intrinsicBall G ω x (n - 1)} := by + ext ω + constructor + · rintro ⟨y, hy, hd⟩ + refine ⟨y, hy, ?_⟩ + rw [intrinsicBall_iff_distance_le G ω x y (n - 1) hy] + omega + · rintro ⟨y, hy, hd⟩ + refine ⟨y, hy, ?_⟩ + rw [intrinsicBall_iff_distance_le G ω x y (n - 1) hy] at hd + omega + +theorem measurableSet_intrinsicRadiusEvent [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (x : V) (n : ℕ) : + MeasurableSet (intrinsicRadiusEvent G x n) := by + by_cases hn : n = 0 + · subst n + have he : intrinsicRadiusEvent G x 0 = Set.univ := by + apply Set.eq_univ_of_forall + intro ω + exact ⟨x, mem_cluster_self G ω x, Nat.zero_le _⟩ + rw [he] + exact MeasurableSet.univ + · rw [intrinsicRadiusEvent_eq G x (Nat.pos_of_ne_zero hn)] + exact (Measurable.exists fun y => + (measurableSet_setOfPred.mp (measurableSet_conn G x y)).and + (measurableSet_setOfPred.mp + (measurableSet_mem_intrinsicBall G hloc x y (n - 1))).not).setOf + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ExponentialDecay.lean b/lean/OAI/Probability/BenjaminiSchramm/ExponentialDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac28ed933ef249dda22957924e0fc809948523b2 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ExponentialDecay.lean @@ -0,0 +1,248 @@ +import OAI.Probability.BenjaminiSchramm.EventMeasurability +import OAI.Probability.UnimodularPercolation.Deformation.ClusterProducts +import OAI.Probability.UnimodularPercolation.Escape.CollisionTails + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem walk_crosses_sphere (H : SimpleGraph V) {x y : V} (w : H.Walk x y) + (o : V) (n : ℕ) (hlo : H.dist o x ≤ n) (hhi : n ≤ H.dist o y) : + ∃ z ∈ w.support, H.dist o z = n := by + induction w with + | @nil a => exact ⟨a, by simp, by omega⟩ + | @cons x a y ha w ih => + by_cases hx : H.dist o x = n + · exact ⟨x, by simp, hx⟩ + · have had : H.dist o a ≤ n := by + have hh := ha.diff_dist_adj (u := o) + omega + obtain ⟨z, hz, hd⟩ := ih had hhi + exact ⟨z, by simpa only [SimpleGraph.Walk.support_cons, List.mem_cons] using Or.inr hz, hd⟩ + +theorem mem_reachBall_of_graphDistance_le (G : BondGraph V E) (hconn : Connected G) + (x z : V) (m : ℕ) (hd : graphDistance G x z ≤ m) : z ∈ reachBall G x m := by + obtain ⟨w, hw⟩ := ((conn_iff_reachable G Set.univ x z).mp + (conn_univ_of_connected G hconn x z)).exists_walk_length_eq_dist + obtain ⟨l, hl, he, _⟩ := walk_lift_bonds G Set.univ w + have hlen : l.length = w.length := by + have hh := congrArg List.length he + simpa only [List.length_map, SimpleGraph.Walk.length_edges] using hh + exact reachBall_mono G x (hlen.trans_le (hw.trans_le hd)) hl.mem_reachBall + +theorem sphere_split_subset (G : BondGraph V E) (hconn : Connected G) + (hloc : LocallyFinite G) (x y : V) (m r : ℕ) (hrm : r ≤ m) + (hry : r ≤ graphDistance G x y) : + {ω | Conn G ω x y} ⊆ + ⋃ z ∈ ((finite_reachBall hloc x m).toFinset.filter + fun z => graphDistance G x z = r), + DisjointOccurrence {ω | Conn G ω x z} {ω | Conn G ω z y} := by + intro ω hc + obtain ⟨w⟩ := (conn_iff_reachable G ω x y).mp hc + let q := w.bypass + have hle : openSimpleGraph G ω ≤ openSimpleGraph G Set.univ := by + rintro a b ⟨hne, e, _, he⟩ + exact ⟨hne, e, Set.mem_univ _, he⟩ + obtain ⟨z, hz, hzr⟩ := walk_crosses_sphere (openSimpleGraph G Set.univ) + (q.mapLe hle) x r (by simp) hry + have hzq : z ∈ q.support := by + simpa only [SimpleGraph.Walk.support_mapLe_eq_support] using hz + have hzB : z ∈ (finite_reachBall hloc x m).toFinset := by + apply (finite_reachBall hloc x m).mem_toFinset.mpr + exact mem_reachBall_of_graphDistance_le G hconn x z m (hzr.trans_le hrm) + exact Set.mem_iUnion.mpr ⟨z, Set.mem_iUnion.mpr + ⟨Finset.mem_filter.mpr ⟨hzB, hzr⟩, simplePath_disjoint_at G ω q w.bypass_isPath hzq⟩⟩ + +theorem twoPoint_le_sphere_sum [Countable E] (G : BondGraph V E) + (hconn : Connected G) (hloc : LocallyFinite G) (p : unitInterval) + (x y : V) (m r : ℕ) (hrm : r ≤ m) (hry : r ≤ graphDistance G x y) : + twoPoint G p x y ≤ + ∑ z ∈ (finite_reachBall hloc x m).toFinset with graphDistance G x z = r, + twoPoint G p x z * twoPoint G p z y := by + let F := (finite_reachBall hloc x m).toFinset.filter fun z => graphDistance G x z = r + calc + _ ≤ (law p).real (⋃ z ∈ F, + DisjointOccurrence {ω | Conn G ω x z} {ω | Conn G ω z y}) := + measureReal_mono (sphere_split_subset G hconn hloc x y m r hrm hry) (measure_ne_top _ _) + _ ≤ ∑ z ∈ F, (law p).real + (DisjointOccurrence {ω | Conn G ω x z} {ω | Conn G ω z y}) := + measureReal_biUnion_finset_le F _ + _ ≤ _ := by + apply Finset.sum_le_sum + intro z _ + exact bk p _ _ (fun _ _ h hc => conn_mono G h hc) + (fun _ _ h hc => conn_mono G h hc) + (finiteWitness_conn G x z) (finiteWitness_conn G z y) + +theorem connectivity_power_lower [Countable V] [Countable E] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (p : unitInterval) (A : Hilbert V →L[ℂ] Hilbert V) (hA : HasKernel G p A) + (m k : ℕ) (x y : V) (hd : k * m ≤ graphDistance G x y) : + ((m + 1 : ℕ) : ℝ) ^ k * twoPoint G p x y ≤ + (matrixCoeff (A ^ (k + 1)) x y).re := by + have hk (a b : V) : matrixCoeff A a b = (twoPoint G p a b : ℂ) := hA a b + have hpos : PositiveRealMatrix A := by + intro a b + rw [hk] + exact ⟨rfl, twoPoint_nonneg G p a b⟩ + induction k generalizing x y with + | zero => simp only [pow_zero, one_mul, zero_add, pow_one, hk, Complex.ofReal_re, le_refl] + | succ k ih => + rw [Nat.succ_mul] at hd + let B := (finite_reachBall hloc x m).toFinset + let F (z : V) := twoPoint G p x z * (matrixCoeff (A ^ (k + 1)) z y).re + have hF (z : V) : 0 ≤ F z := + mul_nonneg (twoPoint_nonneg G p x z) ((hpos.pow (k + 1)) z y).2 + have hsphere (r : ℕ) (hr : r ∈ Finset.range (m + 1)) : + ((m + 1 : ℕ) : ℝ) ^ k * twoPoint G p x y ≤ + ∑ z ∈ B with graphDistance G x z = r, F z := by + have hrm : r ≤ m := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using hr + calc + _ ≤ ((m + 1 : ℕ) : ℝ) ^ k * + ∑ z ∈ B with graphDistance G x z = r, + twoPoint G p x z * twoPoint G p z y := + mul_le_mul_of_nonneg_left (twoPoint_le_sphere_sum G hconn hloc p x y m r + hrm (by omega)) (by positivity) + _ ≤ _ := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro z hz + have hxz := (Finset.mem_filter.mp hz).2 + have hzy : k * m ≤ graphDistance G z y := by + have ht := ((conn_iff_reachable G Set.univ x z).mp + (conn_univ_of_connected G hconn x z)).dist_triangle_left y + change graphDistance G x y ≤ graphDistance G x z + graphDistance G z y at ht + omega + simpa only [F, mul_left_comm, mul_assoc] using + mul_le_mul_of_nonneg_left (ih z y hzy) (twoPoint_nonneg G p x z) + have havg := Finset.sum_le_sum hsphere + have hfiber : (∑ r ∈ Finset.range (m + 1), + ∑ z ∈ B with graphDistance G x z = r, F z) = ∑ z ∈ B, F z := by + apply Finset.sum_fiberwise_of_maps_to + intro z hz + apply Finset.mem_range.mpr + have hh := dist_le_of_mem_reachBall G x z m ((finite_reachBall hloc x m).mem_toFinset.mp hz) + change graphDistance G x z ≤ m at hh + omega + rw [hfiber] at havg + have hs := hpos.mul_hasSum (A ^ (k + 1)) x y + simp only [hk, Complex.ofReal_re] at hs + calc + _ = ∑ _r ∈ Finset.range (m + 1), + ((m + 1 : ℕ) : ℝ) ^ k * twoPoint G p x y := by + simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul, pow_succ] + ring + _ ≤ ∑ z ∈ B, F z := havg + _ ≤ ∑' z, F z := hs.summable.sum_le_tsum B (fun z _ => hF z) + _ = (matrixCoeff (A ^ (k + 1 + 1)) x y).re := by + rw [hs.tsum_eq] + exact congrArg (fun T => (matrixCoeff T x y).re) (pow_succ' A (k + 1)).symm + +theorem connectivity_block_bound [Countable V] [Countable E] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (p : unitInterval) (A : Hilbert V →L[ℂ] Hilbert V) (hA : HasKernel G p A) + (m k : ℕ) (x y : V) (hd : k * m ≤ graphDistance G x y) : + twoPoint G p x y ≤ ‖A‖ * (‖A‖ / (m + 1 : ℕ)) ^ k := by + have hp := connectivity_power_lower G hconn hloc p A hA m k x y hd + have hcoeff : (matrixCoeff (A ^ (k + 1)) x y).re ≤ ‖A‖ ^ (k + 1) := by + apply (Complex.re_le_norm _).trans + have hc : ‖matrixCoeff (A ^ (k + 1)) x y‖ ≤ ‖A ^ (k + 1)‖ := by + change ‖(A ^ (k + 1)) (lp.single 2 y (1 : ℂ)) x‖ ≤ _ + apply (lp.norm_apply_le_norm (by norm_num : (2 : ENNReal) ≠ 0) + ((A ^ (k + 1)) (lp.single 2 y (1 : ℂ))) x).trans + simpa only [lp.norm_single (by norm_num : 0 < (2 : ENNReal)), norm_one, mul_one] using + (A ^ (k + 1)).le_opNorm (lp.single 2 y (1 : ℂ)) + exact hc.trans (norm_pow_le' A (Nat.zero_lt_succ k)) + have hc : (0 : ℝ) < (m + 1 : ℕ) := by positivity + calc + _ ≤ ‖A‖ ^ (k + 1) / ((m + 1 : ℕ) : ℝ) ^ k := + (le_div_iff₀ (pow_pos hc k)).mpr (by simpa only [mul_comm] using hp.trans hcoeff) + _ = _ := by rw [div_pow, pow_succ]; ring + +theorem connectivity_exponential_bound [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (p : unitInterval) (A : Hilbert V →L[ℂ] Hilbert V) (hA : HasKernel G p A) + (x y : V) : + twoPoint G p x y ≤ 2 * ‖A‖ * + Real.exp (-(Real.log 2 / (3 * ‖A‖)) * graphDistance G x y) := by + have hM : 1 ≤ ‖A‖ := hA.norm_one_le G p A + have hMp : 0 < ‖A‖ := lt_of_lt_of_le zero_lt_one hM + let m : ℕ := ⌈2 * ‖A‖⌉₊ + have hml : 2 * ‖A‖ ≤ (m : ℝ) := Nat.le_ceil _ + have hmu : (m : ℝ) ≤ 3 * ‖A‖ := by + have hh := Nat.ceil_lt_add_one (show 0 ≤ 2 * ‖A‖ by positivity) + dsimp [m] + linarith + have hmp : 0 < m := by + have : (0 : ℝ) < m := lt_of_lt_of_le (by positivity) hml + exact_mod_cast this + let k := graphDistance G x y / m + have hk : k * m ≤ graphDistance G x y := Nat.div_mul_le_self _ _ + have hxy : graphDistance G x y < (k + 1) * m := by + simpa only [k, Nat.mul_comm] using Nat.lt_mul_div_succ (graphDistance G x y) hmp + have hr : ‖A‖ / (m + 1 : ℕ) ≤ (1 / 2 : ℝ) := by + apply (div_le_iff₀ (by positivity : (0 : ℝ) < (m + 1 : ℕ))).mpr + push_cast + linarith + have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ ‖A‖ / (m + 1 : ℕ)) hr k + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hcast : (graphDistance G x y : ℝ) ≤ ((k : ℝ) + 1) * (3 * ‖A‖) := by + have h1 : (graphDistance G x y : ℝ) ≤ ((k : ℝ) + 1) * m := by + exact_mod_cast hxy.le + exact h1.trans (mul_le_mul_of_nonneg_left hmu (by positivity)) + have hexponent : -(Real.log 2) * k ≤ + Real.log 2 - (Real.log 2 / (3 * ‖A‖)) * graphDistance G x y := by + have hdiv : (graphDistance G x y : ℝ) / (3 * ‖A‖) ≤ (k : ℝ) + 1 := + (div_le_iff₀ (by positivity)).mpr hcast + have hh := mul_le_mul_of_nonneg_left hdiv hlog.le + nlinarith [show (Real.log 2 / (3 * ‖A‖)) * graphDistance G x y = + Real.log 2 * ((graphDistance G x y : ℝ) / (3 * ‖A‖)) by ring] + have hhalf : (1 / 2 : ℝ) ^ k = Real.exp (-(Real.log 2) * k) := by + rw [mul_comm, Real.exp_nat_mul, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + simp only [one_div] + calc + _ ≤ ‖A‖ * (‖A‖ / (m + 1 : ℕ)) ^ k := + connectivity_block_bound G hconn hloc p A hA m k x y hk + _ ≤ ‖A‖ * (1 / 2 : ℝ) ^ k := mul_le_mul_of_nonneg_left hpow (norm_nonneg _) + _ = ‖A‖ * Real.exp (-(Real.log 2) * k) := by rw [hhalf] + _ ≤ ‖A‖ * Real.exp (Real.log 2 - + (Real.log 2 / (3 * ‖A‖)) * graphDistance G x y) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexponent) (norm_nonneg _) + _ = _ := by + rw [Real.exp_sub, Real.exp_log (by norm_num : (0 : ℝ) < 2), + neg_mul, Real.exp_neg, div_eq_mul_inv] + ring + +theorem exponentialDecay_of_bounded [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (p : unitInterval) (hb : OperatorBounded G p) : ExponentialDecay G p := by + obtain ⟨A, hA⟩ := hb + have hM : 0 < ‖A‖ := lt_of_lt_of_le zero_lt_one (hA.norm_one_le G p A) + exact ⟨2 * ‖A‖, Real.log 2 / (3 * ‖A‖), by positivity, + div_pos (Real.log_pos (by norm_num)) (by positivity), + connectivity_exponential_bound G hconn hloc p A hA⟩ + +theorem exponentialDecay_of_lt_ptwo [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (p : unitInterval) (hp : p < ptwo G) : ExponentialDecay G p := by + obtain ⟨q, hq, hpq⟩ := lt_sSup_iff.mp hp + exact exponentialDecay_of_bounded G hconn hloc p + (operatorBounded_of_le G hpq.le hq) + +theorem ptwo_le_pexp [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) : + ptwo G ≤ pexp G := by + apply le_of_forall_lt_imp_le_of_dense + intro p hp + exact le_sSup (exponentialDecay_of_lt_ptwo G hconn hloc p hp) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ExteriorConnection.lean b/lean/OAI/Probability/BenjaminiSchramm/ExteriorConnection.lean new file mode 100644 index 0000000000000000000000000000000000000000..b574191fb374ace1b882a45458a06735f63df8af --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ExteriorConnection.lean @@ -0,0 +1,91 @@ +import OAI.Probability.BenjaminiSchramm.KernelDeletionOperator + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +noncomputable def exteriorSusceptibility (G : BondGraph V E) (p : unitInterval) + (x b : V) (ω : Set E) : ℝ := + freshExteriorMoment G p x b ω / (cluster G ω x).ncard + +theorem measurable_exteriorSusceptibility [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) (x b : V) : + Measurable (exteriorSusceptibility G p x b) := + (measurable_freshExteriorMoment G p x b).div + ((measurable_of_countable (fun n : ℕ => (n : ℝ))).comp + (measurable_cluster_ncard G hloc x)) + +theorem exteriorSusceptibility_nonneg (G : BondGraph V E) (p : unitInterval) + (x b : V) (ω : Set E) : 0 ≤ exteriorSusceptibility G p x b ω := + div_nonneg (freshExteriorMoment_nonneg G p x b ω) (Nat.cast_nonneg _) + +theorem exteriorSusceptibility_eq (G : BondGraph V E) (p : unitInterval) + (x b : V) (ω : Set E) (hf : (cluster G ω x).Finite) : + exteriorSusceptibility G p x b ω = inducedSusceptibility G (cluster G ω x)ᶜ p b := by + have hn : ((cluster G ω x).ncard : ℝ) ≠ 0 := by + exact_mod_cast (cluster_ncard_pos G ω x hf).ne' + exact mul_div_cancel_left₀ _ hn + +noncomputable def exteriorConnectionMoment (G : BondGraph V E) (p : unitInterval) + (x a b : V) : ℝ≥0∞ := + ∫⁻ ω, if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) + else 0 ∂law p + +theorem connection_exterior_comparison [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (C : ℝ≥0∞) + (hC : ∀ z, ENNReal.ofReal (susceptibility G p z) ≤ C) (x a b : V) : + law p {ω | Conn G ω x a} * ENNReal.ofReal (susceptibility G p b) ≤ + exteriorConnectionMoment G p x a b + C * + ∑' z, law p {ω | Conn G ω x a ∧ Conn G ω x z} * + law p {ω | Conn G ω b z} := by + let F (ω : Set E) : ℝ≥0∞ := if Conn G ω x a then + ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0 + let H (z : V) (ω : Set E) : ℝ≥0∞ := if Conn G ω x a ∧ Conn G ω x z then + law p {η | Conn G η b z} else 0 + have hF : Measurable F := Measurable.ite (measurableSet_conn G x a) + (ENNReal.measurable_ofReal.comp (measurable_exteriorSusceptibility G hloc p x b)) + measurable_const + have hH (z : V) : Measurable (H z) := Measurable.ite + ((measurableSet_conn G x a).inter (measurableSet_conn G x z)) + measurable_const measurable_const + have hd : (fun ω => if Conn G ω x a then ENNReal.ofReal (susceptibility G p b) else 0) + ≤ᵐ[law p] fun ω => F ω + C * ∑' z, H z ω := by + filter_upwards [subcritical_cluster_finite_ae G p hp x] with ω hf + by_cases ha : Conn G ω x a + · simp only [ite_eq_left ha,F] + rw [exteriorSusceptibility_eq G p x b ω hf] + have hh := susceptibility_deletion_ennreal G hloc hqt p hp (cluster G ω x)ᶜ C hC b + simpa only [Set.mem_compl_iff,cluster,Set.mem_ofPred_eq,ite_not,H, + ha,true_and,mul_comm] using hh + · simp only [ite_eq_right ha,F,H,ha,false_and,ite_false,tsum_zero,mul_zero, + add_zero,le_refl] + have hi := lintegral_mono_ae hd + have hleft : (∫⁻ ω, if Conn G ω x a then ENNReal.ofReal (susceptibility G p b) + else 0 ∂law p) = law p {ω | Conn G ω x a} * ENNReal.ofReal (susceptibility G p b) := by + simpa only [Set.indicator,Set.mem_ofPred_eq,mul_comm] using + lintegral_indicator_const (measurableSet_conn G x a) (ENNReal.ofReal (susceptibility G p b)) + have hr : (∫⁻ ω, F ω + C * ∑' z, H z ω ∂law p) = + exteriorConnectionMoment G p x a b + C * + ∑' z, law p {ω | Conn G ω x a ∧ Conn G ω x z} * law p {ω | Conn G ω b z} := by + rw [lintegral_add_left hF,lintegral_const_mul _ (Measurable.tsum hH), + lintegral_tsum (fun z => (hH z).aemeasurable)] + congr 2 + apply tsum_congr + intro z + have hs : MeasurableSet {ω | Conn G ω x a ∧ Conn G ω x z} := + (measurableSet_conn G x a).inter (measurableSet_conn G x z) + simpa only [H,Set.indicator,Set.mem_ofPred_eq,mul_comm] using + lintegral_indicator_const hs (law p {ω | Conn G ω b z}) + rwa [hleft,hr] at hi + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ExteriorContact.lean b/lean/OAI/Probability/BenjaminiSchramm/ExteriorContact.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e9711d83c325b75f61a22f0cd9461269c528745 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ExteriorContact.lean @@ -0,0 +1,102 @@ +import OAI.Probability.BenjaminiSchramm.ExteriorExposure + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem distinct_exterior_event (G : BondGraph V E) (x a b y : V) : + {ω | (Conn G ω x a ∧ ¬Conn G ω x b) ∧ Conn G ω b y} = + {ω | ¬Conn G ω x y ∧ (Conn G ω x a ∧ Conn G ω y b)} := by + ext ω + constructor + · rintro ⟨⟨ha,hb⟩,hby⟩ + exact ⟨fun hxy => hb (conn_trans G ω hxy (conn_symm G ω hby)), + ha,conn_symm G ω hby⟩ + · rintro ⟨hxy,ha,hyb⟩ + exact ⟨⟨ha,fun hb => hxy (conn_trans G ω hb (conn_symm G ω hyb))⟩, + conn_symm G ω hyb⟩ + +theorem lintegral_distinctClusterPair [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (J : V → V → ℝ≥0∞) (x y : V) : + (∫⁻ ω, if ¬Conn G ω x y then clusterPairKernel G ω J x y else 0 ∂law p) = + ∑' a, ∑' b, J a b * + law p {ω | ¬Conn G ω x y ∧ (Conn G ω x a ∧ Conn G ω y b)} := by + let F (a b : V) (ω : Set E) : ℝ≥0∞ := + if ¬Conn G ω x y ∧ (Conn G ω x a ∧ Conn G ω y b) then J a b else 0 + have hF (a b : V) : Measurable (F a b) := Measurable.ite + ((measurableSet_conn G x y).compl.inter + ((measurableSet_conn G x a).inter (measurableSet_conn G y b))) + measurable_const measurable_const + have he (ω : Set E) : (if ¬Conn G ω x y then clusterPairKernel G ω J x y else 0) = + ∑' a, ∑' b, F a b ω := by + by_cases hxy : Conn G ω x y + · simp only [hxy,not_true_eq_false,ite_false,F,false_and,tsum_zero] + · simp only [hxy,not_false_eq_true,ite_true,F,true_and,clusterPairKernel] + simp_rw [he] + rw [lintegral_tsum (fun a => (Measurable.tsum (hF a)).aemeasurable)] + apply tsum_congr + intro a + rw [lintegral_tsum (fun b => (hF a b).aemeasurable)] + apply tsum_congr + intro b + have hs : MeasurableSet {ω | ¬Conn G ω x y ∧ (Conn G ω x a ∧ Conn G ω y b)} := + (measurableSet_conn G x y).compl.inter + ((measurableSet_conn G x a).inter (measurableSet_conn G y b)) + simpa only [F,Set.indicator,Set.mem_ofPred_eq] using lintegral_indicator_const hs (J a b) + +theorem kernelExteriorPotential_eq_distinctClusterPair [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (J : V → V → ℝ≥0∞) (x : V) : + kernelExteriorPotential G p J x = + ∑' y, ∫⁻ ω, if ¬Conn G ω x y then clusterPairKernel G ω J x y else 0 ∂law p := by + unfold kernelExteriorPotential + simp_rw [exteriorConnectionMoment_eq_tsum G hloc hqt p hp, + distinct_exterior_event G,lintegral_distinctClusterPair G p J x, + ←ENNReal.tsum_mul_left] + calc + _ = ∑' a, ∑' y, ∑' b, J a b * + law p {ω | ¬Conn G ω x y ∧ (Conn G ω x a ∧ Conn G ω y b)} := + tsum_congr (fun _ => ENNReal.tsum_comm) + _ = _ := ENNReal.tsum_comm + +theorem kernelExteriorPotential_edge_eq_contact [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x : V) : + kernelExteriorPotential G p (indexedEdgeKernel G) x = + ∑' y, ENNReal.ofReal (∫ ω, fullLargeContact G x y 0 ω ∂law p) := by + rw [kernelExteriorPotential_eq_distinctClusterPair G hloc hqt p hp] + apply tsum_congr + intro y + rw [ofReal_integral_eq_lintegral_ofReal + (integrable_fullContact_subcritical G hloc hqt p hp x y) + (Filter.Eventually.of_forall (fullLargeContact_nonneg G x y 0)), + fullContact_lintegral_eq_kernel G hloc p x y (subcritical_cluster_finite_ae G p hp x)] + +theorem kernelExteriorPotential_edge_eq_derivative [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) (x : V) : + kernelExteriorPotential G p (indexedEdgeKernel G) x = + ENNReal.ofReal (1 - (p : ℝ)) * ENNReal.ofReal (deriv (realSusceptibility G x) p) := by + rw [kernelExteriorPotential_edge_eq_contact G hloc hqt p hp, + (hasDerivAt_realSusceptibility G hloc hqt p hp0 hp x).deriv, + ENNReal.ofReal_tsum_of_nonneg (fun y => russoSlope_nonneg G x y p p.2.2) + (summable_russoSlope G hloc hqt p hp x),←ENNReal.tsum_mul_left] + apply tsum_congr + intro y + have hp1 : 0 < 1 - (p : ℝ) := sub_pos.mpr ((show (p : ℝ) < (pc G : ℝ) from hp).trans_le (pc G).2.2) + have he : (∫ ω, fullLargeContact G x y 0 ω ∂law p) = + (1 - (p : ℝ)) * russoSlope G x y p := by + rw [russoSlope,realContactExpectation_coe] + field_simp + rw [he,ENNReal.ofReal_mul hp1.le] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ExteriorEscape.lean b/lean/OAI/Probability/BenjaminiSchramm/ExteriorEscape.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dcd3f3aee00c1619daee67c6959fe7439feef17 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ExteriorEscape.lean @@ -0,0 +1,125 @@ +import OAI.Probability.BenjaminiSchramm.FreshWhiteExposure +import OAI.Probability.BenjaminiSchramm.AvoidanceProduct + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def exteriorEscape (S : Set V) (f : V → ℝ) (x u : V) : Set (Set E) := + {η | ∃ y, y ≠ x ∧ f x ≤ f y ∧ y ∉ S ∧ Conn G (η \ internalEdges G S) u y} + +lemma exteriorEscape_upper (S : Set V) (f : V → ℝ) (x u : V) : + IsUpperSet (exteriorEscape G S f x u) := by + rintro ω η hωη ⟨y,hy,hf,hyS,huy⟩ + exact ⟨y,hy,hf,hyS,conn_mono G (Set.sdiff_subset_sdiff_left hωη) huy⟩ + +lemma exteriorEscape_hasFiniteOpenWitness (S : Set V) (f : V → ℝ) (x u : V) : + CriticalPercolation.BernoulliProduct.HasFiniteOpenWitness (exteriorEscape G S f x u) := by + rintro ω ⟨y,hy,hf,hyS,huy⟩ + obtain ⟨F,hF,hconn⟩ := finiteWitness_conn G u y _ huy + refine ⟨F,F.finite_toSet,fun e he => (hF he).1,y,hy,hf,hyS,conn_mono G ?_ hconn⟩ + intro e he + exact ⟨he,(hF he).2⟩ + +lemma measurableSet_exteriorEscape [Countable E] (S : Set V) (f : V → ℝ) (x u : V) : + MeasurableSet (exteriorEscape G S f x u) := + CriticalPercolation.BernoulliProduct.measurableSet_finiteWitness _ + (exteriorEscape_upper G S f x u) (exteriorEscape_hasFiniteOpenWitness G S f x u) + +lemma conn_eq_of_incident_closed (η : Set E) (u y : V) + (hclosed : ∀ e, u ∈ G e → e ∉ η) (hconn : Conn G η u y) : y=u := by + induction hconn with + | refl => rfl + | @tail v w _ hstep ih => + subst v + obtain ⟨e,he,heq⟩ := hstep + exact False.elim (hclosed e (by rw [heq]; simp) he) + +lemma finiteBondPattern_excludes_exteriorEscape (S : Set V) (f : V → ℝ) (x u : V) + (hu : u ∈ S) (F : Finset E) (hF : ∀ e, u ∈ G e → e ∈ F) : + finiteBondPattern F ∅ ⊆ (exteriorEscape G S f x u)ᶜ := by + rintro η hη ⟨y,_hy,_hf,hyS,huy⟩ + have hclosed (e : E) (he : u ∈ G e) : e ∉ η := by + have hh := hη e (hF e he) + simpa only [Set.mem_empty_iff_false,eq_iff_iff,iff_false] using hh + have heq := conn_eq_of_incident_closed G η u y hclosed + (conn_mono G Set.sdiff_subset huy) + exact hyS (heq ▸ hu) + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BernoulliProduct +open Percolation.BenjaminiSchramm +variable {E : Type*} + +lemma finiteBondPattern_law_eq_of_parameters (r : E → unitInterval) + (b : unitInterval) (F : Finset E) (hb : ∀ e ∈ F, r e=b) (σ : Set E) : + law r (finiteBondPattern F σ)=law (fun _ => b) (finiteBondPattern F σ) := by + let T : Set (F : Set E) := Subtype.val ⁻¹' σ + have he : finiteBondPattern F σ= + (fun ω : Set E => (Subtype.val ⁻¹' ω : Set (F : Set E))) ⁻¹' {T} := by + ext ω + change (∀ e ∈ F, (e ∈ ω)=(e ∈ σ)) ↔ Subtype.val ⁻¹' ω=T + constructor + · intro h + ext e + exact Iff.of_eq (h e e.property) + · intro h e he + exact propext (show (⟨e,he⟩ : (F : Set E)) ∈ Subtype.val ⁻¹' ω ↔ + (⟨e,he⟩ : (F : Set E)) ∈ T from by rw [h]) + rw [he,←Measure.map_apply (Percolation.measurable_set_restrict _) (MeasurableSet.singleton T), + ←Measure.map_apply (Percolation.measurable_set_restrict _) (MeasurableSet.singleton T), + law_map_restrict,law_map_restrict] + congr 1 + apply congrArg law + funext e + exact hb e e.property + +lemma finiteBondPattern_inhomogeneous_lower (r : E → unitInterval) + (b : unitInterval) (F : Finset E) (hb : ∀ e ∈ F, r e=b) (σ : Set E) : + ENNReal.ofReal ((min (b : ℝ) (1-b))^F.card) ≤ law r (finiteBondPattern F σ) := by + rw [finiteBondPattern_law_eq_of_parameters r b F hb σ,law_const] + exact finiteBondPattern_probability_lower b F σ + +end CriticalPercolation.BernoulliProduct + +namespace Percolation.BenjaminiSchramm +open CriticalPercolation.BernoulliProduct +variable {V E : Type*} [Countable E] (G : BondGraph V E) + +omit [Countable E] in +theorem exteriorEscape_avoidance_finite_energy (r : E → unitInterval) + (b : unitInterval) (S : Set V) (f : V → ℝ) (x u : V) (hu : u ∈ S) + (F : Finset E) (hF : ∀ e, u ∈ G e → e ∈ F) (hb : ∀ e ∈ F, r e=b) : + (min (b : ℝ) (1-b))^F.card ≤ (CriticalPercolation.BernoulliProduct.law r).real (exteriorEscape G S f x u)ᶜ := by + have hh := (finiteBondPattern_inhomogeneous_lower r b F hb ∅).trans + (measure_mono (finiteBondPattern_excludes_exteriorEscape G S f x u hu F hF)) + have hr := ENNReal.toReal_mono (measure_ne_top _ _) hh + rw [ENNReal.toReal_ofReal (pow_nonneg (le_min b.2.1 (sub_nonneg.mpr b.2.2)) _)] at hr + exact hr + +theorem exteriorEscape_avoidance_product (r : E → unitInterval) + (S : Finset V) (f : V → ℝ) (x : V) (g : V → ℝ) + (hbound : ∀ u ∈ S, Real.exp (-g u) ≤ + (CriticalPercolation.BernoulliProduct.law r).real (exteriorEscape G (S : Set V) f x u)ᶜ) : + ENNReal.ofReal (Real.exp (-(∑ u ∈ S, g u))) ≤ + CriticalPercolation.BernoulliProduct.law r {η | ∀ u ∈ S, η ∉ exteriorEscape G (S : Set V) f x u} := by + have he : (finiteBadUnion S (fun u => exteriorEscape G (S : Set V) f x u))ᶜ= + {η | ∀ u ∈ S, η ∉ exteriorEscape G (S : Set V) f x u} := by + ext η + simp [finiteBadUnion] + rw [←he] + exact exponential_finite_avoidance r S _ + (fun u _ => exteriorEscape_upper G _ f x u) + (fun u _ => exteriorEscape_hasFiniteOpenWitness G _ f x u) g hbound + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ExteriorExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/ExteriorExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..500a515059e6667d2997f9e7cdb57c4e93a394ae --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ExteriorExposure.lean @@ -0,0 +1,152 @@ +import OAI.Probability.BenjaminiSchramm.KernelExterior + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem exteriorSusceptibility_le [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x b : V) (ω : Set E) : + exteriorSusceptibility G p x b ω ≤ susceptibility G p b := by + by_cases hf : (cluster G ω x).Finite + · rw [exteriorSusceptibility_eq G p x b ω hf] + exact inducedSusceptibility_le_susceptibility G hloc hqt p hp _ b + · simp only [exteriorSusceptibility,Set.Infinite.ncard hf,Nat.cast_zero,div_zero] + exact susceptibility_nonneg G p b + +theorem integrable_exteriorSusceptibility [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x b : V) : + Integrable (exteriorSusceptibility G p x b) (law p) := by + apply (integrable_const (susceptibility G p b)).mono' + (measurable_exteriorSusceptibility G hloc p x b).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun ω => by + rw [Real.norm_of_nonneg (exteriorSusceptibility_nonneg G p x b ω)] + exact exteriorSusceptibility_le G hloc hqt p hp x b ω) + +theorem integral_exterior_connection [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x a b : V) : + (∫ ω, (if Conn G ω x a then exteriorSusceptibility G p x b ω else 0) ∂law p) = + ∫ ω, (if Conn G ω x a ∧ ¬Conn G ω x b then + ((cluster G ω b).ncard : ℝ) else 0) ∂law p := by + have hl : Integrable (fun ω => if Conn G ω x a then + exteriorSusceptibility G p x b ω else 0) (law p) := + (integrable_exteriorSusceptibility G hloc hqt p hp x b).indicator + (measurableSet_conn G x a) + have hr : Integrable (fun ω => if Conn G ω x a ∧ ¬Conn G ω x b then + ((cluster G ω b).ncard : ℝ) else 0) (law p) := by + have hs : MeasurableSet {ω | Conn G ω x a ∧ ¬Conn G ω x b} := + (measurableSet_conn G x a).inter (measurableSet_conn G x b).compl + apply ((susceptibility_eq_integral G hloc hqt p hp b).1.indicator hs).congr + exact Filter.Eventually.of_forall (fun ω => by + by_cases h : Conn G ω x a ∧ ¬Conn G ω x b <;> simp [h]) + rw [integral_cluster_finite_partition G p hp x _ hl, + integral_cluster_finite_partition G p hp x _ hr] + apply tsum_congr + intro W + by_cases ha : a ∈ W + · have hleft : (∫ ω, (if cluster G ω x = (W : Set V) then + (if Conn G ω x a then exteriorSusceptibility G p x b ω else 0) else 0) ∂law p) = + inducedSusceptibility G (W : Set V)ᶜ p b * + (law p).real {ω | cluster G ω x = (W : Set V)} := by + rw [←integral_event_indicator p _ (measurableSet_cluster_eq G x W), + ←integral_const_mul] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun ω => by + by_cases hc : cluster G ω x = (W : Set V) + · have hca : Conn G ω x a := by + change a ∈ cluster G ω x + rw [hc] + exact ha + have hf : (cluster G ω x).Finite := by rw [hc]; exact W.finite_toSet + simp only [hc,ite_true,hca,exteriorSusceptibility_eq G p x b ω hf,mul_one, + Set.mem_ofPred_eq] + · simp only [hc,ite_false,Set.mem_ofPred_eq,mul_zero]) + have hright : (∫ ω, (if cluster G ω x = (W : Set V) then + (if Conn G ω x a ∧ ¬Conn G ω x b then ((cluster G ω b).ncard : ℝ) else 0) + else 0) ∂law p) = + (law p).real {ω | cluster G ω x = (W : Set V)} * + inducedSusceptibility G (W : Set V)ᶜ p b := by + rw [←cluster_cell_exterior_susceptibility G hloc hqt p hp W x b] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun ω => by + by_cases hc : cluster G ω x = (W : Set V) + · have hca : Conn G ω x a := by change a ∈ cluster G ω x; rwa [hc] + simp only [hc,ite_true,hca,true_and] + · simp only [hc,ite_false,false_and]) + rw [hleft,hright,mul_comm] + · have hz (ω : Set E) (hc : cluster G ω x = (W : Set V)) : ¬Conn G ω x a := by + intro h + have hh : a ∈ cluster G ω x := h + rw [hc] at hh + exact ha hh + have he : (fun ω => if cluster G ω x = (W : Set V) then + (if Conn G ω x a then exteriorSusceptibility G p x b ω else 0) else 0) = + fun _ => (0 : ℝ) := by + funext ω + by_cases hc : cluster G ω x = (W : Set V) + · simp only [hc,ite_true,ite_eq_right (hz ω hc)] + · exact ite_eq_right hc + rw [he,integral_zero] + symm + apply integral_eq_zero_of_ae + exact Filter.Eventually.of_forall (fun ω => by + change (if cluster G ω x = (W : Set V) then + (if Conn G ω x a ∧ ¬Conn G ω x b then ((cluster G ω b).ncard : ℝ) else 0) + else 0) = 0 + by_cases hc : cluster G ω x = (W : Set V) + · simp only [hc,ite_true,hz ω hc,false_and,ite_false] + · exact ite_eq_right hc) + +theorem exteriorConnectionMoment_eq_tsum [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x a b : V) : + exteriorConnectionMoment G p x a b = + ∑' y, law p {ω | (Conn G ω x a ∧ ¬Conn G ω x b) ∧ Conn G ω b y} := by + have hi : Integrable (fun ω => if Conn G ω x a then + exteriorSusceptibility G p x b ω else 0) (law p) := + (integrable_exteriorSusceptibility G hloc hqt p hp x b).indicator + (measurableSet_conn G x a) + have hn (ω : Set E) : 0 ≤ (if Conn G ω x a then + exteriorSusceptibility G p x b ω else 0) := by + split_ifs + · exact exteriorSusceptibility_nonneg G p x b ω + · rfl + have he : exteriorConnectionMoment G p x a b = ENNReal.ofReal + (∫ ω, (if Conn G ω x a then exteriorSusceptibility G p x b ω else 0) ∂law p) := by + rw [ofReal_integral_eq_lintegral_ofReal hi (Filter.Eventually.of_forall hn)] + apply lintegral_congr + intro ω + split_ifs <;> simp only [ENNReal.ofReal_zero] + have hsEvent : MeasurableSet {ω | Conn G ω x a ∧ ¬Conn G ω x b} := + (measurableSet_conn G x a).inter (measurableSet_conn G x b).compl + have hv := integral_cluster_size_event G hloc hqt p hp b _ hsEvent + have hv' : (∫ ω, (if Conn G ω x a ∧ ¬Conn G ω x b then + ((cluster G ω b).ncard : ℝ) else 0) ∂law p) = + ∑' y, (law p).real {ω | (Conn G ω x a ∧ ¬Conn G ω x b) ∧ Conn G ω b y} := by + convert hv using 1 + · apply integral_congr_ae + exact Filter.Eventually.of_forall (fun ω => by + by_cases h : Conn G ω x a ∧ ¬Conn G ω x b <;> simp [h]) + · rfl + rw [he,integral_exterior_connection G hloc hqt p hp x a b,hv'] + have hs : Summable (fun y => (law p).real + {ω | (Conn G ω x a ∧ ¬Conn G ω x b) ∧ Conn G ω b y}) := by + apply (summable_twoPoint_subcritical G hloc hqt p hp b).of_nonneg_of_le + (fun _ => measureReal_nonneg) + intro y + exact ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (fun _ h => h.2)) + rw [ENNReal.ofReal_tsum_of_nonneg (fun _ => measureReal_nonneg) hs] + exact tsum_congr (fun _ => ENNReal.ofReal_toReal (measure_ne_top _ _)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FiniteClusterSums.lean b/lean/OAI/Probability/BenjaminiSchramm/FiniteClusterSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bc0a25d66c36b00d34c0793aaed0e304b3f9bb1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FiniteClusterSums.lean @@ -0,0 +1,37 @@ +import OAI.Probability.BenjaminiSchramm.ClusterExposure + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem lintegral_eq_sum_finite_clusters (p : unitInterval) (x : V) + (hfin : ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) (F : Set V → ℝ≥0∞) : + (∫⁻ ω, F (G.cluster ω x) ∂G.law p) = + ∑' S : Finset V, G.law p {ω | G.cluster ω x = (S : Set V)} * F (S : Set V) := by + have heq : (fun ω => F (G.cluster ω x)) =ᵐ[G.law p] + (fun ω => ∑' S : Finset V, if G.cluster ω x = (S : Set V) then F (S : Set V) else 0) := by + filter_upwards [hfin] with ω hω + rw [tsum_eq_single hω.toFinset (fun S hS => by + apply ite_eq_right + intro hc + exact hS (Finset.coe_injective (hc.symm.trans hω.coe_toFinset.symm)))] + rw [ite_eq_left hω.coe_toFinset.symm, hω.coe_toFinset] + rw [lintegral_congr_ae heq,lintegral_tsum] + · apply tsum_congr + intro S + simpa only [Set.indicator,Set.mem_ofPred_eq,mul_comm] using + lintegral_indicator_const (G.measurableSet_exactCluster x (S : Set V)) (F (S : Set V)) + · intro S + exact (measurable_const.ite (G.measurableSet_exactCluster x (S : Set V)) + measurable_const).aemeasurable + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FiniteEnergyModification.lean b/lean/OAI/Probability/BenjaminiSchramm/FiniteEnergyModification.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a30ce70910009ed3aa95c64050f1398de046acf --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FiniteEnergyModification.lean @@ -0,0 +1,130 @@ +import OAI.Probability.BenjaminiSchramm.PeakFiniteEnergy +import OAI.Probability.BenjaminiSchramm.LayerFreshSelection + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +open CriticalPercolation.BernoulliProduct +variable {E : Type*} + +def finiteModification (F : Finset E) (B : Set (Set E)) : Set (Set E) := + ⋃ σ : Set (F : Set E), (forceOn (F : Set E) (Subtype.val '' σ)) ⁻¹' B + +lemma forceOn_finitePattern_eq (F : Finset E) (σ : Set (F : Set E)) (ω : Set E) + (hω : ω ∈ finiteBondPattern F (Subtype.val '' σ)) : + forceOn (F : Set E) (Subtype.val '' σ) ω=ω := by + ext e + rw [mem_forceOn] + by_cases he : e ∈ (F : Set E) + · simpa only [he,ite_true] using (Iff.of_eq (hω e he)).symm + · simp only [he,ite_false] + +lemma finiteBondPattern_pairwise (F : Finset E) : + Pairwise (fun σ τ : Set (F : Set E) => Disjoint + (finiteBondPattern F (Subtype.val '' σ)) (finiteBondPattern F (Subtype.val '' τ))) := by + intro σ τ hστ + apply Set.disjoint_left.mpr + intro ω hσ hτ + apply hστ + ext e + have hh := (hσ e e.property).symm.trans (hτ e e.property) + simpa only [Set.mem_image,Subtype.val_injective.eq_iff,exists_eq_right] using Iff.of_eq hh + +lemma iUnion_finiteBondPattern (F : Finset E) : + (⋃ σ : Set (F : Set E), finiteBondPattern F (Subtype.val '' σ))=Set.univ := by + apply Set.eq_univ_of_forall + intro ω + refine Set.mem_iUnion.mpr ⟨Subtype.val ⁻¹' ω,?_⟩ + intro e he + apply propext + simp only [Set.mem_image,Set.mem_preimage] + constructor + · intro heω + exact ⟨⟨e,he⟩,heω,rfl⟩ + · rintro ⟨z,hz,rfl⟩ + exact hz + +lemma forced_event_dependsOn_compl (F : Finset E) (σ : Set E) (B : Set (Set E)) : + DependsOn (fun ω => forceOn (F : Set E) σ ω ∈ B) (F : Set E)ᶜ := by + intro ω η hωη + let ξ : Set E := {e | ω e} + let ζ : Set E := {e | η e} + have hh : forceOn (F : Set E) σ ξ=forceOn (F : Set E) σ ζ := by + ext e + rw [mem_forceOn,mem_forceOn] + by_cases he : e ∈ (F : Set E) + · simp only [he,ite_true] + · simp only [he,ite_false] + exact Iff.of_eq (hωη e he) + exact congrArg (fun ξ : Set E => ξ ∈ B) hh + +variable [Countable E] + +lemma finiteModification_probability (p : unitInterval) (F : Finset E) + (B : Set (Set E)) (hB : MeasurableSet B) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card)*law p (finiteModification F B) ≤ law p B := by + let A (σ : Set (F : Set E)) := (forceOn (F : Set E) (Subtype.val '' σ)) ⁻¹' B + let P (σ : Set (F : Set E)) := finiteBondPattern F (Subtype.val '' σ) + have hmA (σ : Set (F : Set E)) : MeasurableSet (A σ) := + hB.preimage (measurable_forceOn _ _) + have hcell (σ : Set (F : Set E)) : + law p (A σ)*ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) ≤ law p (B ∩ P σ) := by + have he : A σ ∩ P σ=B ∩ P σ := by + ext ω + constructor + · rintro ⟨ha,hp⟩ + exact ⟨forceOn_finitePattern_eq F σ ω hp ▸ ha,hp⟩ + · rintro ⟨hb,hp⟩ + refine ⟨?_,hp⟩ + change forceOn (F : Set E) (Subtype.val '' σ) ω ∈ B + rw [forceOn_finitePattern_eq F σ ω hp] + exact hb + have hh := fresh_finiteBondPattern_cell_lower p (F : Set E)ᶜ (A σ) (hmA σ) + (forced_event_dependsOn_compl F _ B) F (by simp only [compl_compl]; exact Set.Subset.rfl) + (Subtype.val '' σ) + rwa [he] at hh + have hd : Pairwise (fun σ τ : Set (F : Set E) => Disjoint (B ∩ P σ) (B ∩ P τ)) := + fun σ τ hστ => (finiteBondPattern_pairwise F hστ).mono Set.inter_subset_right Set.inter_subset_right + have hp : (⋃ σ : Set (F : Set E), B ∩ P σ)=B := by + rw [←Set.inter_iUnion,iUnion_finiteBondPattern,Set.inter_univ] + calc + _ ≤ ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card)*∑' σ : Set (F : Set E), law p (A σ) := + mul_le_mul' le_rfl (measure_iUnion_le A) + _ = ∑' σ : Set (F : Set E), law p (A σ)*ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) := by + rw [ENNReal.tsum_mul_right,mul_comm] + _ ≤ ∑' σ : Set (F : Set E), law p (B ∩ P σ) := ENNReal.tsum_le_tsum hcell + _ = _ := by rw [←measure_iUnion hd (fun σ => hB.inter (measurableSet_finiteBondPattern F _)),hp] + +theorem finite_energy_modification_bound (p : unitInterval) (F : Finset E) + (A B : Set (Set E)) (hB : MeasurableSet B) + (hmod : ∀ ω ∈ A, ∃ η ∈ B, ∀ e ∉ F, (e ∈ ω)=(e ∈ η)) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card)*law p A ≤ law p B := by + apply (mul_le_mul' le_rfl (measure_mono ?_)).trans (finiteModification_probability p F B hB) + intro ω hω + obtain ⟨η,hη,hagree⟩ := hmod ω hω + let σ : Set (F : Set E) := Subtype.val ⁻¹' η + refine Set.mem_iUnion.mpr ⟨σ,?_⟩ + have hh : forceOn (F : Set E) (Subtype.val '' σ) ω=η := by + ext e + rw [mem_forceOn] + by_cases he : e ∈ (F : Set E) + · simp only [he,ite_true,Set.mem_image] + constructor + · rintro ⟨z,hz,rfl⟩ + exact hz + · intro heη + exact ⟨⟨e,he⟩,heη,rfl⟩ + · simpa only [he,ite_false] using Iff.of_eq (hagree e he) + change forceOn (F : Set E) (Subtype.val '' σ) ω ∈ B + rw [hh] + exact hη + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FiniteEnergyObservable.lean b/lean/OAI/Probability/BenjaminiSchramm/FiniteEnergyObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a3ae10c5505af071fd5c8a7b97d1d373e686ffa --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FiniteEnergyObservable.lean @@ -0,0 +1,82 @@ +import OAI.Probability.BenjaminiSchramm.FiniteEnergyModification +import OAI.Probability.BenjaminiSchramm.HalfspaceRootComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +open CriticalPercolation.BernoulliProduct + +variable {E : Type*} [Countable E] + +lemma finite_forcing_measure_bound (p : unitInterval) (F : Finset E) (σ : Set E) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) • + (law p).map (forceOn (F : Set E) σ) ≤ law p := by + apply Measure.le_iff.mpr + intro B hB + rw [Measure.smul_apply,Measure.map_apply (measurable_forceOn _ _) hB,smul_eq_mul] + apply finite_energy_modification_bound p F _ B hB + intro ω hω + refine ⟨forceOn (F : Set E) σ ω,hω,?_⟩ + intro e he + rw [mem_forceOn] + simp only [Finset.mem_coe,he,ite_false] + +lemma lintegral_finite_forcing_bound (p : unitInterval) (F : Finset E) (σ : Set E) + (X : Set E → ℝ≥0∞) (hX : Measurable X) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card)* + (∫⁻ ω, X (forceOn (F : Set E) σ ω) ∂law p) ≤ ∫⁻ ω, X ω ∂law p := by + have hh := lintegral_mono' (finite_forcing_measure_bound p F σ) (le_refl X) + rwa [lintegral_smul_measure,lintegral_map hX (measurable_forceOn _ _),smul_eq_mul] at hh + +variable {V : Type*} [Countable V] (G : BondGraph V E) + +omit [Countable E] [Countable V] in +lemma rooted_forced_layer_count_le (F : Finset E) (I J : Set E) (W Z : Set V) + (hIJ : I ⊆ J) (hWZ : W ⊆ Z) (x y : V) + (hpath : ∀ η : Set E, (F : Set E) ⊆ η → Conn G (η ∩ J) x y) + (ω : Set E) : + restrictedLayerCount G I W ω y ≤ + restrictedLayerCount G J Z (forceOn (F : Set E) Set.univ ω) x := by + let η := forceOn (F : Set E) Set.univ ω + have hωη : ω ⊆ η := by + intro e he + rw [mem_forceOn] + by_cases heF : e ∈ (F : Set E) + · simp only [heF,ite_true,Set.mem_univ] + · simpa only [heF,ite_false] using he + have hFη : (F : Set E) ⊆ η := by + intro e he + rw [mem_forceOn,ite_eq_left he] + exact Set.mem_univ e + have hxy := hpath η hFη + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : z ∈ W ∧ Conn G (ω ∩ I) y z + · have hconn := hxy.trans (conn_mono G (Set.inter_subset_inter hωη hIJ) hz.2) + have ht : z ∈ Z ∧ Conn G (η ∩ J) x z := ⟨hWZ hz.1,hconn⟩ + rw [ite_eq_left hz,ite_eq_left ht] + · rw [ite_eq_right hz] + exact bot_le + +theorem forced_path_fractional_layer_comparison + (p : unitInterval) (F : Finset E) (I J : Set E) (W Z : Set V) + (hIJ : I ⊆ J) (hWZ : W ⊆ Z) (x y : V) + (hpath : ∀ η : Set E, (F : Set E) ⊆ η → Conn G (η ∩ J) x y) + {q : ℝ} (hq : 0 ≤ q) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card)* + (∫⁻ ω, (restrictedLayerCount G I W ω y)^q ∂law p) ≤ + ∫⁻ ω, (restrictedLayerCount G J Z ω x)^q ∂law p := by + apply (mul_le_mul' le_rfl (lintegral_mono (fun ω => + ENNReal.rpow_le_rpow (rooted_forced_layer_count_le G F I J W Z hIJ hWZ x y hpath ω) hq))).trans + exact lintegral_finite_forcing_bound p F Set.univ _ + ((measurable_restrictedLayerCount G J Z x).pow_const q) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FiniteOrbitStationary.lean b/lean/OAI/Probability/BenjaminiSchramm/FiniteOrbitStationary.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e41cfad79c361bfe3199d0e438a955809db209f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FiniteOrbitStationary.lean @@ -0,0 +1,118 @@ +import Mathlib + +namespace OAI + +noncomputable section +open Set Filter +open scoped Classical Topology BigOperators + +namespace Percolation.BenjaminiSchramm +variable {ι : Type*} [Fintype ι] + +def orbitChainStep (K : ι → ι → ℝ) (μ : ι → ℝ) (y : ι) : ℝ := ∑ x, μ x * K x y + +lemma orbitChainStep_nonneg (K : ι → ι → ℝ) (hK : ∀ x y, 0 ≤ K x y) + (μ : ι → ℝ) (hμ : ∀ x, 0 ≤ μ x) (y : ι) : 0 ≤ orbitChainStep K μ y := + Finset.sum_nonneg fun x _ => mul_nonneg (hμ x) (hK x y) + +lemma orbitChainStep_mass (K : ι → ι → ℝ) (hK : ∀ x, ∑ y, K x y = 1) (μ : ι → ℝ) : + ∑ y, orbitChainStep K μ y = ∑ y, μ y := by + unfold orbitChainStep + rw [Finset.sum_comm] + simp only [← Finset.mul_sum,hK,mul_one] + +theorem finite_orbit_stationary [Nonempty ι] (K : ι → ι → ℝ) (hK : ∀ x y, 0 ≤ K x y) + (hrow : ∀ x, ∑ y, K x y = 1) : + ∃ μ : ι → ℝ, (∀ x, 0 ≤ μ x) ∧ (∑ x, μ x = 1) ∧ orbitChainStep K μ = μ := by + let i₀ := Classical.arbitrary ι + let d₀ : ι → ℝ := fun i => if i = i₀ then 1 else 0 + let d : ℕ → ι → ℝ := fun n => (orbitChainStep K)^[n] d₀ + have hdnext (n : ℕ) : d (n+1) = orbitChainStep K (d n) := + Function.iterate_succ_apply' (orbitChainStep K) n d₀ + have hd (n : ℕ) : (∀ i, 0 ≤ d n i) ∧ ∑ i, d n i = 1 := by + induction n with + | zero => + change (∀ i, 0 ≤ d₀ i) ∧ ∑ i, d₀ i = 1 + constructor + · intro i + dsimp [d₀] + split_ifs <;> norm_num + · simp [d₀] + | succ n ih => + rw [hdnext] + exact ⟨orbitChainStep_nonneg K hK _ ih.1,by rw [orbitChainStep_mass K hrow,ih.2]⟩ + have hdle (n : ℕ) (i : ι) : d n i ≤ 1 := by + rw [← (hd n).2] + exact Finset.single_le_sum (fun j _ => (hd n).1 j) (Finset.mem_univ i) + let av : ℕ → ι → ℝ := fun n i => ((n : ℝ)+1)⁻¹ * ∑ k ∈ Finset.range (n+1), d k i + have havnonneg (n : ℕ) (i : ι) : 0 ≤ av n i := by + exact mul_nonneg (by positivity) (Finset.sum_nonneg fun k _ => (hd k).1 i) + have havmass (n : ℕ) : ∑ i, av n i = 1 := by + simp only [av,← Finset.mul_sum] + rw [Finset.sum_comm] + simp only [(hd _).2,Finset.sum_const,Finset.card_range,nsmul_eq_mul,mul_one,Nat.cast_add,Nat.cast_one] + exact inv_mul_cancel₀ (by positivity) + have havcube (n : ℕ) : av n ∈ Set.Icc (0 : ι → ℝ) 1 := by + refine ⟨havnonneg n,fun i => ?_⟩ + change av n i ≤ (1 : ℝ) + rw [← havmass n] + exact Finset.single_le_sum (fun j _ => havnonneg n j) (Finset.mem_univ i) + obtain ⟨μ,hμcube,φ,hφ,hlim⟩ := (isCompact_Icc : IsCompact (Set.Icc (0 : ι → ℝ) 1)).tendsto_subseq + (x := av) havcube + have hμmass : ∑ i, μ i = 1 := by + have hs := tendsto_finsetSum Finset.univ (fun i _ => (continuous_apply i).tendsto μ |>.comp hlim) + change Tendsto (fun n => ∑ i, av (φ n) i) atTop (𝓝 (∑ i, μ i)) at hs + have he : (fun n => ∑ i, av (φ n) i) = fun _ : ℕ => (1 : ℝ) := by funext n; exact havmass _ + rw [he] at hs + exact tendsto_nhds_unique hs tendsto_const_nhds + refine ⟨μ,hμcube.1,hμmass,?_⟩ + have havstep (n : ℕ) (i : ι) : orbitChainStep K (av n) i - av n i = + ((n : ℝ)+1)⁻¹ * (d (n+1) i-d 0 i) := by + have hsum : ∑ x, (∑ k ∈ Finset.range (n+1), d k x) * K x i = + ∑ k ∈ Finset.range (n+1), d (k+1) i := by + simp_rw [Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro k _ + rw [hdnext] + rfl + simp only [orbitChainStep,av,mul_assoc,← Finset.mul_sum,hsum,← mul_sub] + congr 1 + rw [← Finset.sum_sub_distrib] + exact Finset.sum_range_sub (fun k => d k i) (n+1) + have hsmall : Tendsto (fun n : ℕ => ((n : ℝ)+1)⁻¹) atTop (𝓝 0) := + tendsto_inv_atTop_zero.comp (tendsto_atTop_add_const_right atTop 1 tendsto_natCast_atTop_atTop) + funext i + have hz : Tendsto (fun n => orbitChainStep K (av n) i-av n i) atTop (𝓝 0) := by + apply squeeze_zero_norm (fun n => ?_) hsmall + rw [havstep,Real.norm_eq_abs,abs_mul,abs_of_nonneg (by positivity)] + apply mul_le_of_le_one_right (by positivity) + rw [abs_le] + constructor <;> linarith [(hd (n+1)).1 i,(hd 0).1 i,hdle (n+1) i,hdle 0 i] + have hstep : Continuous (fun v : ι → ℝ => orbitChainStep K v i) := + continuous_finsetSum Finset.univ fun j _ => (continuous_apply j).mul continuous_const + have ht := (hstep.tendsto μ |>.comp hlim).sub ((continuous_apply i).tendsto μ |>.comp hlim) + exact sub_eq_zero.mp (tendsto_nhds_unique ht (hz.comp hφ.tendsto_atTop)) + +theorem finite_orbit_stationary_positive [Nonempty ι] (K : ι → ι → ℝ) (hK : ∀ x y, 0 ≤ K x y) + (hrow : ∀ x, ∑ y, K x y = 1) + (hconn : ∀ x y, Relation.ReflTransGen (fun i j => 0 < K i j) x y) : + ∃ μ : ι → ℝ, (∀ x, 0 < μ x) ∧ (∑ x, μ x = 1) ∧ orbitChainStep K μ = μ := by + obtain ⟨μ,hμ,hmass,hstat⟩ := finite_orbit_stationary K hK hrow + have hpossum : 0 < ∑ x, μ x := by rw [hmass]; norm_num + obtain ⟨x,_,hx⟩ := (Finset.sum_pos_iff_of_nonneg (fun i _ => hμ i)).mp hpossum + refine ⟨μ,fun y => ?_,hmass,hstat⟩ + have hpath := hconn x y + induction hpath with + | refl => exact hx + | @tail z y _ hzy ih => + have hle : μ z * K z y ≤ μ y := by + rw [← congrFun hstat y] + exact Finset.single_le_sum (fun i _ => mul_nonneg (hμ i) (hK i y)) (Finset.mem_univ z) + exact (mul_pos ih hzy).trans_le hle + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FirstHeightPeakWalk.lean b/lean/OAI/Probability/BenjaminiSchramm/FirstHeightPeakWalk.lean new file mode 100644 index 0000000000000000000000000000000000000000..5185d008281128cec34d5efd1b89706bd18cb204 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FirstHeightPeakWalk.lean @@ -0,0 +1,107 @@ +import OAI.Probability.BenjaminiSchramm.SlabCrossing +import OAI.Probability.BenjaminiSchramm.UniformHeightAscent + +namespace OAI + +noncomputable section +open Set +open scoped Classical + +namespace Percolation.BenjaminiSchramm +variable {V : Type*} {H : SimpleGraph V} + +lemma first_height_peak_walk (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ {u v}, H.Adj u v → |f v-f u| ≤ R) + {x y : V} (p : H.Walk x y) (a b : ℝ) + (ha : a ≤ f x) (hb : f x ≤ b) (hend : b ≤ f y) + (hlow : ∀ z ∈ p.support, a ≤ f z) : + ∃ z, ∃ q : H.Walk x z, q.length ≤ p.length ∧ + b ≤ f z ∧ f z ≤ b+R ∧ ∀ v ∈ q.support, a ≤ f v ∧ f v ≤ f z := by + induction p with + | @nil u => + refine ⟨u,.nil,le_rfl,hend,by linarith,?_⟩ + intro v hv + have hv' : v=u := List.mem_singleton.mp hv + subst v + exact ⟨ha,le_rfl⟩ + | @cons x v y huv p ih => + by_cases hx : b ≤ f x + · refine ⟨x,.nil,Nat.zero_le _,hx,by linarith,?_⟩ + intro z hz + have hz' : z=x := List.mem_singleton.mp hz + subst z + exact ⟨ha,le_rfl⟩ + have hav : a ≤ f v := hlow v (by simp) + by_cases hv : b ≤ f v + · have hvu := (abs_le.mp (hjump huv)).2 + refine ⟨v,.cons huv .nil,by simp,hv,by linarith,?_⟩ + intro z hz + simp only [SimpleGraph.Walk.support_cons,SimpleGraph.Walk.support_nil, + List.mem_cons,List.not_mem_nil,or_false] at hz + rcases hz with rfl | rfl + · exact ⟨ha,by linarith⟩ + · exact ⟨hav,le_rfl⟩ + · obtain ⟨z,q,hq,hz,hzR,hbound⟩ := ih hav (le_of_not_ge hv) hend + (fun z hz => hlow z (by simp only [SimpleGraph.Walk.support_cons,List.mem_cons]; exact Or.inr hz)) + refine ⟨z,.cons huv q,Nat.succ_le_succ hq,hz,hzR,?_⟩ + intro w hw + simp only [SimpleGraph.Walk.support_cons,List.mem_cons] at hw + rcases hw with rfl | hw + · exact ⟨ha,by linarith⟩ + · exact hbound w hw + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_bounded_ascent_to_level + [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ c : ℝ, 0 ≤ c → ∀ x, + ∃ y, ∃ w : G.fullGraph.Walk x y, (w.length : ℝ) ≤ A*c+B ∧ + c ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ≤ c+R ∧ + ∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y := by + obtain ⟨ε,hε,L,hstep⟩ := G.stationaryOrbitHeight_uniform_ascent hc hl hq μ hμ hstat hu + let a := G.stationaryOrbitWeight μ + refine ⟨(L : ℝ)/ε+1,L,by positivity,Nat.cast_nonneg _,fun c hc0 x => ?_⟩ + let n := ⌈c/ε⌉₊ + have hn : c ≤ (n : ℝ)*ε := (div_le_iff₀ hε).mp (Nat.le_ceil (c/ε)) + have hn' : (n : ℝ) ≤ c/ε+1 := (Nat.ceil_lt_add_one (div_nonneg hc0 hε.le)).le + obtain ⟨y,w,hwlen,hw,hwy⟩ := G.height_ascent_iterate hc hl a ε hε.le L hstep n x + have hj : ∀ {u v}, G.fullGraph.Adj u v → + |G.orbitAdjustedHeight a x v-G.orbitAdjustedHeight a x u| ≤ R := by + intro u v huv + have huv' : (Percolation.openSimpleGraph G.ends Set.univ).Adj u v := by + rw [←criticalModel_openGraph G.ends Set.univ] + exact huv + obtain ⟨e,_he,he⟩ := huv'.2 + have hv := hjump e u v (by rw [he]; simp) (by rw [he]; simp) + rw [G.orbitAdjustedHeight_change_base hc hl a x u v] + simpa only [add_sub_cancel_left] using hv + obtain ⟨z,q,hq,hz,hzR,hbound⟩ := first_height_peak_walk + (G.orbitAdjustedHeight a x) R hR hj w 0 c (by simp) (by simpa using hc0) (hn.trans hwy) hw + refine ⟨z,q,?_,hz,hzR,hbound⟩ + have hqn : q.length ≤ n*L := hq.trans hwlen + have hqn' : (q.length : ℝ) ≤ (n : ℝ)*L := by exact_mod_cast hqn + have hm := mul_le_mul_of_nonneg_right hn' (Nat.cast_nonneg L : (0 : ℝ) ≤ L) + calc + _ ≤ (n : ℝ)*L := hqn' + _ ≤ (c/ε+1)*L := hm + _ = ((L : ℝ)/ε+1)*c+L-c := by ring + _ ≤ ((L : ℝ)/ε+1)*c+L := by linarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FloorDownProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/FloorDownProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..e81bd666a19ab8010d1d74940ddb77c862c2c125 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FloorDownProfile.lean @@ -0,0 +1,226 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShiftProfile +import OAI.Probability.BenjaminiSchramm.UpwardFractionalSlabProfile +import OAI.Probability.BenjaminiSchramm.LayerMonotoneLimit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] [Countable E] in +lemma adjustedSlabBandCount_le_floor_count (a : V → ℝ) (d c l u : ℝ) + (ω : Set E) (x : V) : + G.adjustedSlabBandCount a d c l u ω x ≤ restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | d ≤ G.orbitAdjustedHeight a x v}) + {v | l ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ u} ω x := by + rw [G.adjustedSlabBandCount_eq_restricted] + apply restrictedLayerCount_mono_edges G.ends + exact Percolation.internalEdges_mono G.ends (fun _ h => h.1) + +theorem floor_down_profile_of_zero_band [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (Vcoef : ℝ) (hV : 0 < Vcoef) + (hup : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp ((-1+ζ)*k))) + (hzero : ∀ q : ℝ, 0 < q → q < 1 → ∃ Z : ℝ≥0∞, Z < ⊤ ∧ + ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -c ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | -(2*R) ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 2*R} ω x)^q ∂G.law p) ≤ + Z*ENNReal.ofReal (Real.exp (Vcoef*c))) : + ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -k ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨m,M,hm,hbounds⟩ := G.stationaryOrbitWeight_uniform_bounds hc hl μ hμ + let O := G.orbitRepresentatives hq + let D := (ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r))*ENNReal.ofReal (Real.exp R) + have hD : D < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.inv_lt_top.mpr (ENNReal.ofReal_pos.mpr hm)) + (ENNReal.sum_lt_top.mpr fun _ _ => ENNReal.ofReal_lt_top)) ENNReal.ofReal_lt_top + intro q hq0 hq1 ζ hζ + let δ := min ((1-q)/2) (ζ/(4*(Vcoef+1))) + have hδ : 0 < δ := lt_min (by positivity) (div_pos hζ (by positivity)) + have hδq : δ ≤ 1-q := (min_le_left _ _).trans (by linarith) + have hδ1 : δ < 1 := by linarith + have hδV : δ*Vcoef ≤ ζ/4 := by + have hh := (le_div_iff₀ (show 0 < 4*(Vcoef+1) by positivity)).mp + (min_le_right ((1-q)/2) (ζ/(4*(Vcoef+1)))) + change δ*(4*(Vcoef+1)) ≤ ζ at hh + nlinarith + let ε := ζ/4 + have hε : 0 < ε := by dsimp [ε]; positivity + obtain ⟨T,hT,hshift⟩ := G.halfspace_floor_shift_profile_fixed hc hl hq μ hμ hstat hu R hR.le hjump p hp0 hp1 (-1+ε) + obtain ⟨C₁,hC₁,hbound₁⟩ := hshift (1-δ) (by linarith) + (hup (1-δ) (by linarith) (by linarith) ε hε) + obtain ⟨C₂,hC₂,hbound₂⟩ := hzero q hq0 hq1 + let Q := C₁*ENNReal.ofReal (Real.exp (T*R)) + let Z := C₂*ENNReal.ofReal (Real.exp (Vcoef*(2*R))) + have hQ : Q < ⊤ := ENNReal.mul_lt_top hC₁ ENNReal.ofReal_lt_top + have hZ : Z < ⊤ := ENNReal.mul_lt_top hC₂ ENNReal.ofReal_lt_top + let A := D*Q + have hA : A < ⊤ := ENNReal.mul_lt_top hD hQ + let C := A^q*Z^δ + have hC : C < ⊤ := ENNReal.mul_lt_top + (ENNReal.rpow_lt_top_of_nonneg hq0.le hA.ne) (ENNReal.rpow_lt_top_of_nonneg hδ.le hZ.ne) + refine ⟨C,hC,fun k hk x => ?_⟩ + have hslab (r : ℝ) (hr : 0 ≤ r) : + (∫⁻ ω, (G.adjustedSlabBandCount a (-k) r (-k-R) (-k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k)) := by + have hzero' : (∫⁻ ω, (G.adjustedSlabBandCount a (-k-2*R) (r+2*R) (-(2*R)) (2*R) ω x)^q ∂G.law p) ≤ + Z*ENNReal.ofReal (Real.exp (Vcoef*k)) := by + have hh := hbound₂ (k+2*R) (by positivity) x + have hmon : (∫⁻ ω, (G.adjustedSlabBandCount a (-k-2*R) (r+2*R) (-(2*R)) (2*R) ω x)^q ∂G.law p) ≤ + ∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -(k+2*R) ≤ G.orbitAdjustedHeight a x v}) + {v | -(2*R) ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ 2*R} ω x)^q ∂G.law p := by + apply lintegral_mono + intro ω + rw [show -(k+2*R)= -k-2*R by ring] + exact ENNReal.rpow_le_rpow (G.adjustedSlabBandCount_le_floor_count a _ _ _ _ ω x) hq0.le + apply (hmon.trans hh).trans_eq + dsimp [Z] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show Vcoef*(k+2*R)=Vcoef*(2*R)+Vcoef*k by ring] + have hup' (y : V) : (∫⁻ ω, (G.adjustedSlabBandCount a (-R) (r+k+R) (k-R) (k+R) ω y)^(1-δ) ∂G.law p) ≤ + Q*ENNReal.ofReal (Real.exp ((-1+ε)*k)) := by + have hh := hbound₁ k hk R hR.le y + apply ((lintegral_mono (μ := G.law p) (fun ω => ENNReal.rpow_le_rpow + (G.adjustedSlabBandCount_le_floor_count a (-R) (r+k+R) (k-R) (k+R) ω y) + (show 0 ≤ 1-δ by linarith))).trans hh).trans_eq + dsimp [Q] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show (-1+ε)*k+T*R=T*R+(-1+ε)*k by ring] + have hZfin : ∀ᵐ ω ∂G.law p, + 1 ≤ G.adjustedSlabBandCount a (-k-2*R) (r+2*R) (-(2*R)) (2*R) ω x ∧ + G.adjustedSlabBandCount a (-k-2*R) (r+2*R) (-(2*R)) (2*R) ω x ≠ ⊤ := by + filter_upwards [hfin x] with ω hω + exact ⟨G.one_le_adjustedSlabZeroBandCount a _ _ _ (by positivity) ω x, + (G.adjustedSlabBandCount_lt_top_of_finite a _ _ _ _ ω x hω).ne⟩ + have hwidth : (-k+R)-(-k-R)=2*R := by ring + have hminus : (-k-R)-(-k+R)= -(2*R) := by ring + have hnegl : -(-k-R)=k+R := by ring + have hnegu : -(-k+R)=k-R := by ring + have hreverseLo : -k-2*R-(-k-R)= -R := by ring + have hreverseHi : r+2*R-(-k+R)=r+k+R := by ring + have hforwardLo : -k-2*R+2*R= -k := by ring + have hforwardHi : r+2*R-2*R=r := by ring + have hh := G.fractional_slab_band_estimate O hc hl a (G.stationaryOrbitWeight_pos hc hl μ hμ) + (G.stationaryOrbitWeight_aut μ) m hm (fun z => (hbounds z).1) p (-k-2*R) (r+2*R) (-k-R) (-k+R) x + hq0 hq1 hδ.le hδq + (by simpa only [hminus,hwidth] using hZfin) + (Z*ENNReal.ofReal (Real.exp (Vcoef*k))) (Q*ENNReal.ofReal (Real.exp ((-1+ε)*k))) + (by simpa only [hminus,hwidth] using hzero') + (fun y _ => by simpa only [hreverseLo,hreverseHi,hnegu,hnegl] using hup' y) + simp only [hwidth,hforwardLo,hforwardHi] at hh + have hfactor : (((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-(-k-R)))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*(Q*ENNReal.ofReal (Real.exp ((-1+ε)*k)))) = + A*ENNReal.ofReal (Real.exp (ε*k)) := by + dsimp [A,D] + have he : Real.exp (-(-k-R))*Real.exp ((-1+ε)*k)=Real.exp R*Real.exp (ε*k) := by + rw [←Real.exp_add,←Real.exp_add] + congr 1 + ring + calc + _ = ((ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r))*Q)* + (ENNReal.ofReal (Real.exp (-(-k-R)))*ENNReal.ofReal (Real.exp ((-1+ε)*k))) := by ac_rfl + _ = _ := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),he,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + rw [hfactor] at hh + have heq : (A*ENNReal.ofReal (Real.exp (ε*k)))^q* + (Z*ENNReal.ofReal (Real.exp (Vcoef*k)))^δ = + C*ENNReal.ofReal (Real.exp ((q*ε+δ*Vcoef)*k)) := by + simpa only [mul_zero,add_zero] using + fractional_two_profile_product A Z ε 0 Vcoef 0 k 0 q δ hq0.le hδ.le + apply hh.trans + rw [heq] + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hqε : q*ε ≤ ε := mul_le_of_le_one_left hε.le hq1.le + have hrate : q*ε+δ*Vcoef ≤ ζ := by dsimp [ε] at hqε ⊢; linarith + exact mul_le_mul_of_nonneg_right hrate hk + have hh := restrictedLayerMoment_iUnion G.ends + (fun n : ℕ => Percolation.internalEdges G.ends + {v | -k ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ 0+(n : ℝ)*R}) + (internalEdges_upperSlabs_monotone G.ends _ R (-k) 0 hR.le) + {v | -k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+R} x p hq0 + rw [internalEdges_upperSlabs_iUnion G.ends _ R (-k) 0 hR] at hh + simp only [CriticalPercolation.BondGraph.law,Percolation.law] at hh ⊢ + rw [hh] + apply iSup_le + intro n + simpa only [G.adjustedSlabBandCount_eq_restricted,zero_add, + CriticalPercolation.BondGraph.law,Percolation.law] using hslab ((n : ℝ)*R) (by positivity) + +theorem floor_down_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (hup : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp ((-1+ζ)*k))) + (hup₂ : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-2*R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+2*R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp ((-1+ζ)*k))) : + ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -k ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k)) := by + let a := G.stationaryOrbitWeight μ + have hjump₂ : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ 2*R := by + intro e v w hv hw + exact (hjump e v w hv hw).trans (by linarith) + obtain ⟨T,hT,hshift⟩ := G.halfspace_floor_shift_profile hc hl hq μ hμ hstat hu (2*R) + (by positivity) hjump₂ p hp0 hp1 (-1+(1/2 : ℝ)) + (fun q hq0 hq1 => hup₂ q hq0 hq1 (1/2) (by norm_num)) + apply G.floor_down_profile_of_zero_band hc hl hq μ hμ hstat hu R hR hjump p hp0 hp1 hfin T hT hup + intro q hq0 hq1 + obtain ⟨C,hC,hbound⟩ := hshift q hq0 hq1 + refine ⟨C,hC,fun c hc0 x => ?_⟩ + simpa only [zero_sub,sub_zero,zero_add,mul_zero,add_zero] using hbound 0 (by norm_num) c hc0 x + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FourArmGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/FourArmGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f597c7dfa5976e719ee311266c855feebbf0ac75 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FourArmGeometry.lean @@ -0,0 +1,125 @@ +import OAI.Probability.BenjaminiSchramm.GhostFan + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +variable {V : Type*} {H : SimpleGraph V} +attribute [local instance] Classical.decEq + +def WalkQuartet (H : SimpleGraph V) (x y z t : V) : Prop := + ∃ u v, ∃ p : H.Walk u x, ∃ q : H.Walk u y, ∃ r : H.Walk u v, + ∃ s : H.Walk v z, ∃ w : H.Walk v t, + [p.edges,q.edges,r.edges,s.edges,w.edges].Pairwise List.Disjoint + +lemma WalkQuartet.swap_left {x y z t : V} (h : WalkQuartet H x y z t) : + WalkQuartet H y x z t := by + obtain ⟨u,v,p,q,r,s,w,h⟩ := h + refine ⟨u,v,q,p,r,s,w,?_⟩ + simp [List.pairwise_cons] at h ⊢ + rcases h with ⟨⟨hpq,hpr,hps,hpw⟩,⟨⟨hqr,hqs,hqw⟩,⟨⟨hrs,hrw⟩,hsw⟩⟩⟩ + exact ⟨⟨hpq.symm,hqr,hqs,hqw⟩,⟨⟨hpr,hps,hpw⟩,⟨⟨hrs,hrw⟩,hsw⟩⟩⟩ + +lemma WalkQuartet.swap_pairs {x y z t : V} (h : WalkQuartet H x y z t) : + WalkQuartet H z t x y := by + obtain ⟨u,v,p,q,r,s,w,h⟩ := h + refine ⟨v,u,s,w,r.reverse,p,q,?_⟩ + simp [List.pairwise_cons] at h ⊢ + rcases h with ⟨⟨hpq,hpr,hps,hpw⟩,⟨⟨hqr,hqs,hqw⟩,⟨⟨hrs,hrw⟩,hsw⟩⟩⟩ + exact ⟨⟨hsw,hrs.symm,hps.symm,hqs.symm⟩, + ⟨⟨hrw.symm,hpw.symm,hqw.symm⟩,⟨⟨hpr.symm,hqr.symm⟩,hpq⟩⟩⟩ + +lemma walk_disjoint_mono {X : Type*} {a b c d : List X} + (h : a.Disjoint b) (hc : c ⊆ a) (hd : d ⊆ b) : c.Disjoint d := by + exact List.disjoint_left.mpr (fun _ he hf => List.disjoint_left.mp h (hc he) (hd hf)) + +lemma quartet_of_split_arm {u x y z t v : V} + (p : H.Walk u x) (q : H.Walk u y) (r : H.Walk u z) + (s : H.Walk t v) (hp : p.IsTrail) (hv : v ∈ p.support) + (hpq : p.edges.Disjoint q.edges) (hpr : p.edges.Disjoint r.edges) + (hqr : q.edges.Disjoint r.edges) (hsp : s.edges.Disjoint p.edges) + (hsq : s.edges.Disjoint q.edges) (hsr : s.edges.Disjoint r.edges) : + WalkQuartet H x t y z := by + refine ⟨v,u,p.dropUntil v hv,s.reverse,(p.takeUntil v hv).reverse,q,r,?_⟩ + have ha := p.edges_takeUntil_subset_edges hv + have hb := p.edges_dropUntil_subset_edges hv + simp [List.pairwise_cons] + exact ⟨⟨(walk_disjoint_mono hsp (fun _ h => h) hb).symm, + (hp.disjoint_edges_takeUntil_dropUntil hv).symm, + walk_disjoint_mono hpq hb (fun _ h => h), + walk_disjoint_mono hpr hb (fun _ h => h)⟩, + ⟨⟨walk_disjoint_mono hsp (fun _ h => h) ha,hsq,hsr⟩, + ⟨⟨walk_disjoint_mono hpq ha (fun _ h => h), + walk_disjoint_mono hpr ha (fun _ h => h)⟩,hqr⟩⟩⟩ + +lemma three_walks_from_reachable {x y z : V} + (hxy : H.Reachable x y) (hxz : H.Reachable x z) : + ∃ u, ∃ p : H.Walk u x, ∃ q : H.Walk u y, ∃ r : H.Walk u z, + p.IsTrail ∧ q.IsTrail ∧ r.IsTrail ∧ + p.edges.Disjoint q.edges ∧ p.edges.Disjoint r.edges ∧ q.edges.Disjoint r.edges := by + classical + obtain ⟨p₀⟩ := hxy + let p : H.Walk x y := p₀.toPath + obtain ⟨r₀⟩ := hxz.symm + let r : H.Walk z x := r₀.toPath + let S := p.support.toFinset + obtain ⟨u,hu,hur,hfirst⟩ := r.exists_mem_support_forall_mem_support_imp_eq S + ⟨x,Finset.mem_filter.mpr ⟨List.mem_toFinset.mpr p.start_mem_support,r.end_mem_support⟩⟩ + have hup : u ∈ p.support := List.mem_toFinset.mp hu + let a := p.takeUntil u hup + let b := p.dropUntil u hup + let c := r.takeUntil u hur + have hcp : c.edges.Disjoint p.edges := by + apply walk_edges_disjoint_of_single_support_intersection c p + intro w hw hpw + exact hfirst w (List.mem_toFinset.mpr hpw) hw + refine ⟨u,a.reverse,b,c.reverse, + (p₀.toPath.property.isTrail.takeUntil hup).reverse, + p₀.toPath.property.isTrail.dropUntil hup, + (r₀.toPath.property.isTrail.takeUntil hur).reverse,?_,?_,?_⟩ + · simpa only [SimpleGraph.Walk.edges_reverse,List.disjoint_reverse_left] using + p₀.toPath.property.isTrail.disjoint_edges_takeUntil_dropUntil hup + · simpa only [SimpleGraph.Walk.edges_reverse,List.disjoint_reverse_left, + List.disjoint_reverse_right] using + (walk_disjoint_mono hcp (fun _ h => h) (p.edges_takeUntil_subset_edges hup)).symm + · simpa only [SimpleGraph.Walk.edges_reverse,List.disjoint_reverse_right] using + (walk_disjoint_mono hcp (fun _ h => h) (p.edges_dropUntil_subset_edges hup)).symm + +theorem walkQuartet_of_reachable {x y z t : V} + (hxy : H.Reachable x y) (hxz : H.Reachable x z) (hxt : H.Reachable x t) : + WalkQuartet H x y z t ∨ WalkQuartet H x z y t ∨ WalkQuartet H x t y z := by + classical + obtain ⟨u,p,q,r,hp,hq,hr,hpq,hpr,hqr⟩ := three_walks_from_reachable hxy hxz + obtain ⟨s⟩ := hxt.symm.trans p.reachable.symm + let S := p.support.toFinset ∪ q.support.toFinset ∪ r.support.toFinset + have hu : u ∈ S := Finset.mem_union_left _ + (Finset.mem_union_left _ (List.mem_toFinset.mpr p.start_mem_support)) + obtain ⟨v,hv,hvs,hfirst⟩ := s.exists_mem_support_forall_mem_support_imp_eq S + ⟨u,Finset.mem_filter.mpr ⟨hu,s.end_mem_support⟩⟩ + let a := s.takeUntil v hvs + have hap : a.edges.Disjoint p.edges := by + apply walk_edges_disjoint_of_single_support_intersection a p + intro w hw hpw + exact hfirst w (Finset.mem_union_left _ (Finset.mem_union_left _ (List.mem_toFinset.mpr hpw))) hw + have haq : a.edges.Disjoint q.edges := by + apply walk_edges_disjoint_of_single_support_intersection a q + intro w hw hqw + exact hfirst w (Finset.mem_union_left _ (Finset.mem_union_right _ (List.mem_toFinset.mpr hqw))) hw + have har : a.edges.Disjoint r.edges := by + apply walk_edges_disjoint_of_single_support_intersection a r + intro w hw hrw + exact hfirst w (Finset.mem_union_right _ (List.mem_toFinset.mpr hrw)) hw + rcases Finset.mem_union.mp hv with hv | hv + · rcases Finset.mem_union.mp hv with hv | hv + · exact Or.inr (Or.inr (quartet_of_split_arm p q r a hp + (List.mem_toFinset.mp hv) hpq hpr hqr hap haq har)) + · have ht := quartet_of_split_arm q p r a hq + (List.mem_toFinset.mp hv) hpq.symm hqr hpr haq hap har + exact Or.inr (Or.inl ht.swap_pairs) + · have ht := quartet_of_split_arm r p q a hr + (List.mem_toFinset.mp hv) hpr.symm hqr.symm hpq har hap haq + exact Or.inl ht.swap_pairs + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalBandEstimate.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalBandEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..49ce55e4f1fc988277ff332b7d7f95a34236cb29 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalBandEstimate.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.FractionalBandTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma expected_band_product_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (c l u δ : ℝ) + (φ : G.Aut) (p : unitInterval) (x : V) : + (∫⁻ ω, G.adjustedCeilingBandCount a (c-(u-l)) l u ω (φ.vertex x) * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω (φ.vertex x))^(-δ) ∂G.law p) = + ∫⁻ ω, G.adjustedCeilingBandCount a (c-(u-l)) l u ω x * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^(-δ) ∂G.law p := by + conv_lhs => rw [←G.law_map_aut p φ] + have hm : Measurable (fun ω : Set E => + G.adjustedCeilingBandCount a (c-(u-l)) l u ω (φ.vertex x) * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω (φ.vertex x))^(-δ)) := + (G.measurable_adjustedCeilingBandCount a _ _ _ _).mul + ((G.measurable_adjustedCeilingBandCount a _ _ _ _).pow_const (-δ)) + rw [lintegral_map hm + (BernoulliProduct.measurable_image_equiv φ.edge)] + simp only [G.adjustedCeilingBandCount_aut a ha] + +theorem fractional_ceiling_band_estimate + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (p : unitInterval) (c l u : ℝ) (x : V) + {α δ : ℝ} (hα : 0 < α) (hα1 : α < 1) (hδ : 0 ≤ δ) (hδα : δ ≤ 1-α) + (hZfin : ∀ᵐ ω ∂G.law p, + 1 ≤ G.adjustedCeilingBandCount a c (l-u) (u-l) ω x ∧ + G.adjustedCeilingBandCount a c (l-u) (u-l) ω x ≠ ⊤) + (L Q : ℝ≥0∞) + (hL : (∫⁻ ω, (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^α ∂G.law p) ≤ L) + (hQ : ∀ r ∈ O.roots, (∫⁻ ω, + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω r)^(1-δ) ∂G.law p) ≤ Q) : + (∫⁻ ω, (G.adjustedCeilingBandCount a (c-(u-l)) l u ω x)^α ∂G.law p) ≤ + (((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-l))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*Q)^α * L^δ := by + let B (ω : Set E) (z : V) := G.adjustedCeilingBandCount a (c-(u-l)) l u ω z * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω z)^(-δ) + have hroot : ENNReal.ofReal m*(∫⁻ ω, B ω x ∂G.law p) ≤ + ∑ r ∈ O.roots, ENNReal.ofReal (a r)*(∫⁻ ω, B ω r ∂G.law p) := by + obtain ⟨r,hr,φ,rfl⟩ := O.cover x + change ENNReal.ofReal m*(∫⁻ ω, + G.adjustedCeilingBandCount a (c-(u-l)) l u ω (φ.vertex r) * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω (φ.vertex r))^(-δ) ∂G.law p) ≤ _ + rw [G.expected_band_product_aut a ha c l u δ φ p r] + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (ham r)) le_rfl).trans + (Finset.single_le_sum (f := fun r => ENNReal.ofReal (a r)*(∫⁻ ω, B ω r ∂G.law p)) + (fun _ _ => bot_le) hr) + have hδ1 : δ < 1 := by linarith + have hprod : (∫⁻ ω, B ω x ∂G.law p) ≤ + ((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-l))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*Q := by + have hqsum : (∑ r ∈ O.roots, ENNReal.ofReal (a r)*(∫⁻ ω, + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω r)^(1-δ) ∂G.law p)) ≤ + (∑ r ∈ O.roots, ENNReal.ofReal (a r))*Q := by + rw [Finset.sum_mul] + exact Finset.sum_le_sum fun r hr => mul_le_mul' le_rfl (hQ r hr) + have hh := hroot.trans ((G.expected_fractional_band_transport O hc hl a hapos ha p c l u hδ hδ1).trans + (mul_le_mul' le_rfl hqsum)) + calc + _ = (ENNReal.ofReal m)⁻¹*(ENNReal.ofReal m*(∫⁻ ω, B ω x ∂G.law p)) := by + rw [←mul_assoc,ENNReal.inv_mul_cancel (ne_of_gt (ENNReal.ofReal_pos.mpr hm)) + ENNReal.ofReal_ne_top,one_mul] + _ ≤ _ := (mul_le_mul' le_rfl hh).trans_eq (by ring) + exact (fractional_holder_with_count (G.law p) + (fun ω => G.adjustedCeilingBandCount a (c-(u-l)) l u ω x) + (fun ω => G.adjustedCeilingBandCount a c (l-u) (u-l) ω x) + (G.measurable_adjustedCeilingBandCount a _ _ _ x) + (G.measurable_adjustedCeilingBandCount a _ _ _ x) hZfin hα hα1 hδ hδα).trans + (mul_le_mul' (ENNReal.rpow_le_rpow hprod hα.le) (ENNReal.rpow_le_rpow hL hδ)) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalBandGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalBandGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd8bf7ff8f610524dda32063adb52677e9924112 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalBandGeometry.lean @@ -0,0 +1,82 @@ +import OAI.Probability.BenjaminiSchramm.CeilingBandUniform +import OAI.Probability.BenjaminiSchramm.FractionalHolder + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma reverse_ceiling_band_count_le_zero_band + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (c l u : ℝ) (ω : Set E) (x y : V) + (hxy : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c-(u-l)}) x y) + (hylo : l ≤ G.orbitAdjustedHeight a x y) (hyhi : G.orbitAdjustedHeight a x y ≤ u) : + G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω y ≤ + G.adjustedCeilingBandCount a c (l-u) (u-l) ω x := by + have hxy' := G.adjusted_ceiling_connection_change_root hc hl a ω x y x y + (c-(u-l)) (c-u) (by linarith) hxy + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | G.orbitAdjustedHeight a y v ≤ c-u}) y z ∧ + -u ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ -l + · have hconn := G.adjusted_ceiling_connection_change_root hc hl a ω y x x z + (c-u) c (by + rw [G.orbitAdjustedHeight_reverse hc hl a x y] + linarith) (hxy'.trans hz.1) + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + have ht : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | G.orbitAdjustedHeight a x v ≤ c}) x z ∧ + l-u ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u-l := + ⟨hconn,by linarith [hz.2.1],by linarith [hz.2.2]⟩ + simp only [adjustedCeilingBandTransport,ite_eq_left hz,ite_eq_left ht,le_refl] + · simp only [adjustedCeilingBandTransport,ite_eq_right hz] + exact bot_le + +def fractionalReverseBandTransport (a : V → ℝ) (c l u δ : ℝ) + (ω : Set E) (y x : V) : ℝ≥0∞ := + G.adjustedCeilingBandTransport a (c-u) (-u) (-l) ω y x * + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω y)^(-δ) + +lemma fractionalReverseBandTransport_incoming_lower + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (c l u : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) + (ω : Set E) (x y : V) : + ENNReal.ofReal (Real.exp l)* + (G.adjustedCeilingBandTransport a (c-(u-l)) l u ω x y * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^(-δ)) ≤ + G.fractionalReverseBandTransport a c l u δ ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) := by + by_cases hxy : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a x z ≤ c-(u-l)}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u + · have hrev : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | G.orbitAdjustedHeight a y z ≤ c-u}) y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l := by + rw [G.orbitAdjustedHeight_reverse hc hl a x y] + exact ⟨Percolation.conn_symm G.ends _ (G.adjusted_ceiling_connection_change_root hc hl + a ω x y x y (c-(u-l)) (c-u) (by linarith [hxy.2.1]) hxy.1), + by linarith [hxy.2.2],by linarith [hxy.2.1]⟩ + simp only [fractionalReverseBandTransport,adjustedCeilingBandTransport, + ite_eq_left hxy,ite_eq_left hrev,one_mul] + have hpow : (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^(-δ) ≤ + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω y)^(-δ) := by + simp only [ENNReal.rpow_neg] + exact ENNReal.inv_le_inv.mpr (ENNReal.rpow_le_rpow + (G.reverse_ceiling_band_count_le_zero_band hc hl a c l u ω x y hxy.1 hxy.2.1 hxy.2.2) hδ) + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr hxy.2.1)) hpow).trans_eq + (mul_comm _ _) + · simp only [adjustedCeilingBandTransport,ite_eq_right hxy,zero_mul,mul_zero] + exact bot_le + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalBandTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalBandTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..eef2c573853d38a0ffb78ef59ef72cb2ad1bf052 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalBandTransport.lean @@ -0,0 +1,119 @@ +import OAI.Probability.BenjaminiSchramm.FractionalBandGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma ennreal_mul_negative_rpow_le (X : ℝ≥0∞) {δ : ℝ} + (hδ : 0 ≤ δ) (hδ1 : δ < 1) : X*X^(-δ) ≤ X^(1-δ) := by + by_cases hzero : X=0 + · simp only [hzero,zero_mul,ENNReal.zero_rpow_of_pos (sub_pos.mpr hδ1),le_refl] + by_cases htop : X=⊤ + · subst X + by_cases hδ0 : δ=0 + · simp [hδ0] + · have hδpos : 0 < δ := lt_of_le_of_ne hδ (Ne.symm hδ0) + rw [ENNReal.top_rpow_of_neg (neg_neg_of_pos hδpos),mul_zero] + exact bot_le + apply le_of_eq + calc + _ = X^(1 : ℝ)*X^(-δ) := congrArg (fun Y => Y*X^(-δ)) (ENNReal.rpow_one X).symm + _ = _ := (ENNReal.rpow_add 1 (-δ) hzero htop).symm + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma fractionalReverseBandTransport_outgoing (a : V → ℝ) (c l u : ℝ) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ < 1) (ω : Set E) (x : V) : + (∑' y, G.fractionalReverseBandTransport a c l u δ ω x y) ≤ + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω x)^(1-δ) := by + unfold fractionalReverseBandTransport + rw [ENNReal.tsum_mul_right] + exact ennreal_mul_negative_rpow_le _ hδ hδ1 + +lemma fractionalReverseBandTransport_incoming_sum + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (c l u : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) + (ω : Set E) (x : V) : + ENNReal.ofReal (Real.exp l)* + (G.adjustedCeilingBandCount a (c-(u-l)) l u ω x * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^(-δ)) ≤ + ∑' y, G.fractionalReverseBandTransport a c l u δ ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) := by + rw [adjustedCeilingBandCount,←ENNReal.tsum_mul_right,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum fun y => + G.fractionalReverseBandTransport_incoming_lower hc hl a c l u hδ ω x y + +variable [Countable V] [Countable E] + +lemma measurable_fractionalReverseBandTransport (a : V → ℝ) (c l u δ : ℝ) (x y : V) : + Measurable (fun ω => G.fractionalReverseBandTransport a c l u δ ω x y) := + (G.measurable_adjustedCeilingBandTransport a _ _ _ x y).mul + ((G.measurable_adjustedCeilingBandCount a _ _ _ x).pow_const (-δ)) + +omit [Countable V] [Countable E] in +lemma fractionalReverseBandTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (c l u δ : ℝ) + (φ : G.Aut) (ω : Set E) (x y : V) : + G.fractionalReverseBandTransport a c l u δ (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.fractionalReverseBandTransport a c l u δ ω x y := by + simp only [fractionalReverseBandTransport,G.adjustedCeilingBandTransport_aut a ha, + G.adjustedCeilingBandCount_aut a ha] + +theorem expected_fractional_band_transport + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (p : unitInterval) (c l u : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ < 1) : + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + G.adjustedCeilingBandCount a (c-(u-l)) l u ω x * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^(-δ) ∂G.law p)) ≤ + ENNReal.ofReal (Real.exp (-l)) * + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω x)^(1-δ) ∂G.law p)) := by + let B (ω : Set E) (x : V) := G.adjustedCeilingBandCount a (c-(u-l)) l u ω x * + (G.adjustedCeilingBandCount a c (l-u) (u-l) ω x)^(-δ) + have he := OrbitRepresentatives.random_normalized_tilted_transport G O hc hl a hapos ha p + (G.fractionalReverseBandTransport a c l u δ) + (G.measurable_fractionalReverseBandTransport a c l u δ) + (G.fractionalReverseBandTransport_aut a ha c l u δ) + have hw : ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, B ω x ∂G.law p)) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + (G.adjustedCeilingBandCount a (c-u) (-u) (-l) ω x)^(1-δ) ∂G.law p) := by + calc + _ ≤ ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + ∑' y, G.fractionalReverseBandTransport a c l u δ ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) ∂G.law p) := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro x hx + calc + _ = ENNReal.ofReal (a x)*(∫⁻ ω, ENNReal.ofReal (Real.exp l)*B ω x ∂G.law p) := by + rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] + ring + _ ≤ _ := mul_le_mul' le_rfl (lintegral_mono + (G.fractionalReverseBandTransport_incoming_sum hc hl a c l u hδ · x)) + _ = ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + ∑' y, G.fractionalReverseBandTransport a c l u δ ω x y ∂G.law p) := he.symm + _ ≤ _ := Finset.sum_le_sum fun x _ => mul_le_mul' le_rfl + (lintegral_mono (G.fractionalReverseBandTransport_outgoing a c l u hδ hδ1 · x)) + calc + _ = ENNReal.ofReal (Real.exp (-l))*(ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, B ω x ∂G.law p))) := by + rw [←mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add, + neg_add_cancel,Real.exp_zero,ENNReal.ofReal_one,one_mul] + _ ≤ _ := mul_le_mul' le_rfl hw + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalExponentBootstrap.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalExponentBootstrap.lean new file mode 100644 index 0000000000000000000000000000000000000000..69bef6cf714bd32d72c0580f3200242a4dda10de --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalExponentBootstrap.lean @@ -0,0 +1,59 @@ +import Mathlib.Analysis.SpecificLimits.Basic + +namespace OAI + +noncomputable section + +namespace Percolation.BenjaminiSchramm + +theorem fractional_exponent_bootstrap (D U : ℝ → Prop) (η : ℝ) + (hη : 0 < η) (hη1 : η < 1) (hD0 : D 0) + (hup : ∀ q : ℝ, 0 ≤ q → q < 1 → D q → ∀ q' : ℝ, + 0 < q' → q' < q+η*(1-q) → U q') + (hdown : ∀ q : ℝ, 0 < q → q < 1 → U q → ∀ q' : ℝ, + 0 ≤ q' → q' < q → D q') : + ∀ q : ℝ, 0 < q → q < 1 → D q ∧ U q := by + have hstep (q q' : ℝ) (hq0 : 0 ≤ q) (hq1 : q < 1) (hDq : D q) + (hq'0 : 0 ≤ q') (hq' : q' < q+η*(1-q)) : D q' := by + let u := (q'+(q+η*(1-q)))/2 + have hupper : q+η*(1-q) < 1 := by + nlinarith [mul_pos (sub_pos.mpr hη1) (sub_pos.mpr hq1)] + have hu0 : 0 < u := by dsimp [u]; linarith + have hu1 : u < 1 := by dsimp [u]; linarith + have hulim : u < q+η*(1-q) := by dsimp [u]; linarith + have hqu : q' < u := by dsimp [u]; linarith + exact hdown u hu0 hu1 (hup q hq0 hq1 hDq u hu0 hulim) q' hq'0 hqu + let r := 1-η/2 + have hr0 : 0 < r := by dsimp [r]; linarith + have hr1 : r < 1 := by dsimp [r]; linarith + let s (n : ℕ) := 1-r^n + have hs0 (n : ℕ) : 0 ≤ s n := sub_nonneg.mpr (pow_le_one₀ hr0.le hr1.le) + have hs1 (n : ℕ) : s n < 1 := by dsimp [s]; linarith [pow_pos hr0 n] + have hDs : ∀ n : ℕ, D (s n) := by + intro n + induction n with + | zero => simpa only [s,pow_zero,sub_self] using hD0 + | succ n ih => + apply hstep (s n) (s (n+1)) (hs0 n) (hs1 n) ih (hs0 (n+1)) + have hpow := pow_pos hr0 n + have hproduct := mul_pos hη hpow + dsimp [s] + rw [pow_succ] + dsimp [r] at hproduct ⊢ + nlinarith + intro q hq0 hq1 + obtain ⟨n,hn⟩ := exists_pow_lt_of_lt_one (sub_pos.mpr hq1) hr1 + have hqs : q < s n := by dsimp [s]; linarith + have hUs : U (s n) := by + have hsn0 : 0 < s n := hq0.trans hqs + exact hup (s n) (hs0 n) (hs1 n) (hDs n) (s n) hsn0 + (lt_add_of_pos_right _ (mul_pos hη (sub_pos.mpr (hs1 n)))) + have hDq : D q := hdown (s n) (hq0.trans hqs) (hs1 n) hUs q hq0.le hqs + exact ⟨hDq,hup q hq0.le hq1 hDq q hq0 + (lt_add_of_pos_right _ (mul_pos hη (sub_pos.mpr hq1)))⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalHolder.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..772ef82c3cb0fe52e851d8b36673022fb27a6019 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalHolder.lean @@ -0,0 +1,59 @@ +import OAI.Probability.BenjaminiSchramm.LayerMomentDecomposition + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma fractional_holder_with_count + {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (A B : Ω → ℝ≥0∞) (hA : Measurable A) (hB : Measurable B) + (hBfin : ∀ᵐ ω ∂μ, 1 ≤ B ω ∧ B ω ≠ ⊤) + {a δ : ℝ} (ha : 0 < a) (ha1 : a < 1) (hδ : 0 ≤ δ) (hδa : δ ≤ 1-a) : + (∫⁻ ω, A ω^a ∂μ) ≤ + (∫⁻ ω, A ω*B ω^(-δ) ∂μ)^a * (∫⁻ ω, B ω^a ∂μ)^δ := by + by_cases hδ0 : δ=0 + · simpa only [hδ0,neg_zero,ENNReal.rpow_zero,mul_one] using + ennreal_lintegral_rpow_le_rpow_lintegral μ A hA ha ha1.le + have hδpos : 0 < δ := lt_of_le_of_ne hδ (Ne.symm hδ0) + have hc : (1/a).HolderConjugate (1/(1-a)) := + Real.holderConjugate_one_div ha (sub_pos.mpr ha1) (by ring) + have hcancel : a*(1/a)=1 := by field_simp + have hinva : 1/(1/a)=a := by field_simp + have hinvb : 1/(1/(1-a))=1-a := by field_simp + have hfactor : (fun ω => A ω^a) =ᵐ[μ] + (fun ω => (A ω*B ω^(-δ))^a * B ω^(a*δ)) := by + filter_upwards [hBfin] with ω hω + have hne : B ω ≠ 0 := ne_of_gt (lt_of_lt_of_le zero_lt_one hω.1) + rw [ENNReal.mul_rpow_of_nonneg _ _ ha.le,←ENNReal.rpow_mul,mul_assoc, + ←ENNReal.rpow_add _ _ hne hω.2, + show -δ*a+a*δ=0 by ring,ENNReal.rpow_zero,mul_one] + have hh := ENNReal.lintegral_mul_le_Lp_mul_Lq μ hc + (((hA.mul (hB.pow_const (-δ))).pow_const a).aemeasurable) + ((hB.pow_const (a*δ)).aemeasurable) + simp only [Pi.mul_apply,←ENNReal.rpow_mul,hcancel,ENNReal.rpow_one,hinva,hinvb] at hh + have hb : 0 < δ/(1-a) := div_pos hδpos (sub_pos.mpr ha1) + have hb1 : δ/(1-a) ≤ 1 := (div_le_one (sub_pos.mpr ha1)).mpr hδa + have hj := ennreal_lintegral_rpow_le_rpow_lintegral μ (fun ω => B ω^a) + (hB.pow_const a) hb hb1 + have he : a*δ*(1/(1-a))=a*(δ/(1-a)) := by ring + have he' : δ/(1-a)*(1-a)=δ := by field_simp [ne_of_gt (sub_pos.mpr ha1)] + calc + _ = ∫⁻ ω, (A ω*B ω^(-δ))^a*B ω^(a*δ) ∂μ := lintegral_congr_ae hfactor + _ ≤ (∫⁻ ω, A ω*B ω^(-δ) ∂μ)^a * + (∫⁻ ω, B ω^(a*δ*(1/(1-a))) ∂μ)^(1-a) := hh + _ ≤ (∫⁻ ω, A ω*B ω^(-δ) ∂μ)^a * + ((∫⁻ ω, B ω^a ∂μ)^(δ/(1-a)))^(1-a) := by + apply mul_le_mul' le_rfl + apply ENNReal.rpow_le_rpow _ (sub_nonneg.mpr ha1.le) + simpa only [←ENNReal.rpow_mul,he] using hj + _ = _ := by rw [←ENNReal.rpow_mul,he'] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalInterpolation.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c5fc20c87d7457b5a41a99c0ca4a5ae9301c9e9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalInterpolation.lean @@ -0,0 +1,48 @@ +import OAI.Probability.BenjaminiSchramm.FractionalHolder + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +theorem lintegral_rpow_interpolation + {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) + (X : Ω → ℝ≥0∞) (hX : Measurable X) + (a b θ : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) : + (∫⁻ ω, X ω^((1-θ)*a+θ*b) ∂μ) ≤ + (∫⁻ ω, X ω^a ∂μ)^(1-θ)*(∫⁻ ω, X ω^b ∂μ)^θ := by + by_cases hθ0 : θ=0 + · simp only [hθ0,sub_zero,one_mul,zero_mul,add_zero,ENNReal.rpow_one, + ENNReal.rpow_zero,mul_one,le_refl] + by_cases hθeq1 : θ=1 + · simp only [hθeq1,sub_self,zero_mul,one_mul,zero_add,ENNReal.rpow_one, + ENNReal.rpow_zero,le_refl] + have hθpos : 0 < θ := lt_of_le_of_ne hθ (Ne.symm hθ0) + have hθlt : θ < 1 := lt_of_le_of_ne hθ1 hθeq1 + have hholder : (1/(1-θ)).HolderConjugate (1/θ) := + Real.holderConjugate_one_div (sub_pos.mpr hθlt) hθpos (by ring) + have hca : ((1-θ)*a)*(1/(1-θ))=a := by + field_simp [ne_of_gt (sub_pos.mpr hθlt)] + have hcb : (θ*b)*(1/θ)=b := by field_simp [hθ0] + have hia : 1/(1/(1-θ))=1-θ := by field_simp + have hib : 1/(1/θ)=θ := by field_simp + have hh := ENNReal.lintegral_mul_le_Lp_mul_Lq μ hholder + ((hX.pow_const ((1-θ)*a)).aemeasurable) + ((hX.pow_const (θ*b)).aemeasurable) + simp only [Pi.mul_apply,←ENNReal.rpow_mul,hca,hcb,hia,hib] at hh + calc + _ = ∫⁻ ω, X ω^((1-θ)*a)*X ω^(θ*b) ∂μ := by + apply lintegral_congr + intro ω + exact ENNReal.rpow_add_of_nonneg _ _ + (mul_nonneg (sub_nonneg.mpr hθ1) ha) (mul_nonneg hθ hb) + _ ≤ _ := hh + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabEstimate.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..6032d2fe85a1c763a9fde143c7462a0ca6cac7b1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabEstimate.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.FractionalSlabTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma expected_slab_band_product_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (d c l u δ : ℝ) + (φ : G.Aut) (p : unitInterval) (x : V) : + (∫⁻ ω, G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω (φ.vertex x) * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω (φ.vertex x))^(-δ) ∂G.law p) = + ∫⁻ ω, G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω x * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^(-δ) ∂G.law p := by + conv_lhs => rw [←G.law_map_aut p φ] + have hm : Measurable (fun ω : Set E => + G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω (φ.vertex x) * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω (φ.vertex x))^(-δ)) := + (G.measurable_adjustedSlabBandCount a _ _ _ _ _).mul + ((G.measurable_adjustedSlabBandCount a _ _ _ _ _).pow_const (-δ)) + rw [lintegral_map hm + (BernoulliProduct.measurable_image_equiv φ.edge)] + simp only [G.adjustedSlabBandCount_aut a ha] + +theorem fractional_slab_band_estimate + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (p : unitInterval) (d c l u : ℝ) (x : V) + {α δ : ℝ} (hα : 0 < α) (hα1 : α < 1) (hδ : 0 ≤ δ) (hδα : δ ≤ 1-α) + (hZfin : ∀ᵐ ω ∂G.law p, + 1 ≤ G.adjustedSlabBandCount a d c (l-u) (u-l) ω x ∧ + G.adjustedSlabBandCount a d c (l-u) (u-l) ω x ≠ ⊤) + (L Q : ℝ≥0∞) + (hL : (∫⁻ ω, (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^α ∂G.law p) ≤ L) + (hQ : ∀ r ∈ O.roots, (∫⁻ ω, + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω r)^(1-δ) ∂G.law p) ≤ Q) : + (∫⁻ ω, (G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω x)^α ∂G.law p) ≤ + (((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-l))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*Q)^α * L^δ := by + let B (ω : Set E) (z : V) := G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω z * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω z)^(-δ) + have hroot : ENNReal.ofReal m*(∫⁻ ω, B ω x ∂G.law p) ≤ + ∑ r ∈ O.roots, ENNReal.ofReal (a r)*(∫⁻ ω, B ω r ∂G.law p) := by + obtain ⟨r,hr,φ,rfl⟩ := O.cover x + change ENNReal.ofReal m*(∫⁻ ω, + G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω (φ.vertex r) * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω (φ.vertex r))^(-δ) ∂G.law p) ≤ _ + rw [G.expected_slab_band_product_aut a ha d c l u δ φ p r] + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (ham r)) le_rfl).trans + (Finset.single_le_sum (f := fun r => ENNReal.ofReal (a r)*(∫⁻ ω, B ω r ∂G.law p)) + (fun _ _ => bot_le) hr) + have hδ1 : δ < 1 := by linarith + have hprod : (∫⁻ ω, B ω x ∂G.law p) ≤ + ((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-l))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*Q := by + have hqsum : (∑ r ∈ O.roots, ENNReal.ofReal (a r)*(∫⁻ ω, + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω r)^(1-δ) ∂G.law p)) ≤ + (∑ r ∈ O.roots, ENNReal.ofReal (a r))*Q := by + rw [Finset.sum_mul] + exact Finset.sum_le_sum fun r hr => mul_le_mul' le_rfl (hQ r hr) + have hh := hroot.trans ((G.expected_fractional_slab_transport O hc hl a hapos ha p d c l u hδ hδ1).trans + (mul_le_mul' le_rfl hqsum)) + calc + _ = (ENNReal.ofReal m)⁻¹*(ENNReal.ofReal m*(∫⁻ ω, B ω x ∂G.law p)) := by + rw [←mul_assoc,ENNReal.inv_mul_cancel (ne_of_gt (ENNReal.ofReal_pos.mpr hm)) + ENNReal.ofReal_ne_top,one_mul] + _ ≤ _ := (mul_le_mul' le_rfl hh).trans_eq (by ring) + exact (fractional_holder_with_count (G.law p) + (fun ω => G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω x) + (fun ω => G.adjustedSlabBandCount a d c (l-u) (u-l) ω x) + (G.measurable_adjustedSlabBandCount a _ _ _ _ x) + (G.measurable_adjustedSlabBandCount a _ _ _ _ x) hZfin hα hα1 hδ hδα).trans + (mul_le_mul' (ENNReal.rpow_le_rpow hprod hα.le) (ENNReal.rpow_le_rpow hL hδ)) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabFromTruncation.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabFromTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f84be1b3d3f497a6bda70041b0567c6e63a75d8 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabFromTruncation.lean @@ -0,0 +1,45 @@ +import OAI.Probability.BenjaminiSchramm.HeightMaximumSlices +import OAI.Probability.BenjaminiSchramm.TruncatedFractionalSummation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem layer_fractional_of_truncated_moments + (p : unitInterval) (D I : Set E) (W : Set V) (f : V → ℝ) (s : ℝ) (hs : 0 < s) + (x : V) (hx : f x=0) (hfin : ∀ᵐ ω ∂law p, (cluster G ω x).Finite) + (C B : ℝ≥0∞) (t : ℝ) + (htrunc : ∀ n : ℕ, (∫⁻ ω, + (restrictedHit G D x {z | s*((n : ℝ)+1) ≤ f z})ᶜ.indicator + (fun ω => restrictedLayerCount G I W ω x) ω ∂law p) ≤ + C*ENNReal.ofReal (Real.exp (t*n))) + (hhit : ∀ n : ℕ, law p (restrictedHit G D x {z | s*n ≤ f z}) ≤ + B*ENNReal.ofReal (Real.exp (-s*n))) + {a δ : ℝ} (ha : 0 < a) (ha1 : a < 1) (hδ : 0 ≤ δ) (hδa : δ ≤ 1-a) : + (∫⁻ ω, (restrictedLayerCount G I W ω x)^a ∂law p) ≤ + C^a*B^δ*(∑' n : ℕ, ENNReal.ofReal (Real.exp ((t*a-s*δ)*n))) := by + let S := fun n => heightMaximumSlice G D f s n x + have hS (n : ℕ) : MeasurableSet (S n) := measurableSet_heightMaximumSlice G D f s n x + have hfirst (n : ℕ) : (∫⁻ ω in S n, restrictedLayerCount G I W ω x ∂law p) ≤ + C*ENNReal.ofReal (Real.exp (t*n)) := by + have hm := (measurableSet_restrictedHit G D x {z | s*((n : ℝ)+1) ≤ f z}).compl + apply le_trans (lintegral_mono_set (fun _ h => h.1)) + rw [←lintegral_indicator hm (fun ω => restrictedLayerCount G I W ω x)] + exact htrunc n + have hprob (n : ℕ) : law p (S n) ≤ B*ENNReal.ofReal (Real.exp (-s*n)) := + (measure_mono (fun _ h => h.2)).trans (hhit n) + exact fractional_moment_of_height_slices (law p) S hS + (ae_height_slices_cover G p D f s hs x hx hfin) + (fun ω => restrictedLayerCount G I W ω x) (measurable_restrictedLayerCount G I W x) + C B t s hfirst hprob ha ha1 hδ hδa + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..d173694a54bd2642029b236dbb62284902b70344 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabGeometry.lean @@ -0,0 +1,160 @@ +import OAI.Probability.BenjaminiSchramm.FractionalBandTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def adjustedSlabBandTransport (a : V → ℝ) (d c l u : ℝ) + (ω : Set E) (x y : V) : ℝ≥0∞ := + if Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u then 1 else 0 + +def adjustedSlabBandCount (a : V → ℝ) (d c l u : ℝ) + (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, G.adjustedSlabBandTransport a d c l u ω x y + +lemma adjustedSlabBandCount_eq_restricted (a : V → ℝ) (d c l u : ℝ) + (ω : Set E) (x : V) : + G.adjustedSlabBandCount a d c l u ω x = restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) + {z | l ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u} ω x := by + apply tsum_congr + intro y + unfold adjustedSlabBandTransport + by_cases hc : Percolation.Conn G.ends + (ω ∩ Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) x y + <;> by_cases hl : l ≤ G.orbitAdjustedHeight a x y + <;> by_cases hu : G.orbitAdjustedHeight a x y ≤ u + <;> simp [hc,hl,hu] + +lemma adjusted_slab_connection_change_root + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (ω : Set E) (x y v w : V) (d c d' c' : ℝ) + (hlo : d'+G.orbitAdjustedHeight a x y ≤ d) + (hhi : c ≤ c'+G.orbitAdjustedHeight a x y) + (hconn : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) v w) : + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d' ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ c'}) v w := by + apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hconn + intro z hz + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + exact ⟨by linarith [hz.1],by linarith [hz.2]⟩ + +lemma reverse_slab_band_count_le_zero_band + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (d c l u : ℝ) (ω : Set E) (x y : V) + (hxy : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d+(u-l) ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c-(u-l)}) x y) + (hylo : l ≤ G.orbitAdjustedHeight a x y) (hyhi : G.orbitAdjustedHeight a x y ≤ u) : + G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω y ≤ + G.adjustedSlabBandCount a d c (l-u) (u-l) ω x := by + have hxy' := G.adjusted_slab_connection_change_root hc hl a ω x y x y + (d+(u-l)) (c-(u-l)) (d-l) (c-u) (by linarith) (by linarith) hxy + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | d-l ≤ G.orbitAdjustedHeight a y v ∧ G.orbitAdjustedHeight a y v ≤ c-u}) y z ∧ + -u ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ -l + · have hconn := G.adjusted_slab_connection_change_root hc hl a ω y x x z + (d-l) (c-u) d c (by rw [G.orbitAdjustedHeight_reverse hc hl a x y]; linarith) + (by rw [G.orbitAdjustedHeight_reverse hc hl a x y]; linarith) (hxy'.trans hz.1) + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + have ht : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | d ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ c}) x z ∧ + l-u ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u-l := + ⟨hconn,by linarith [hz.2.1],by linarith [hz.2.2]⟩ + simp only [adjustedSlabBandTransport,ite_eq_left hz,ite_eq_left ht,le_refl] + · simp only [adjustedSlabBandTransport,ite_eq_right hz] + exact bot_le + +def fractionalReverseSlabTransport (a : V → ℝ) (d c l u δ : ℝ) + (ω : Set E) (y x : V) : ℝ≥0∞ := + G.adjustedSlabBandTransport a (d-l) (c-u) (-u) (-l) ω y x * + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω y)^(-δ) + +lemma fractionalReverseSlabTransport_incoming_lower + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (d c l u : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) + (ω : Set E) (x y : V) : + ENNReal.ofReal (Real.exp l)* + (G.adjustedSlabBandTransport a (d+(u-l)) (c-(u-l)) l u ω x y * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^(-δ)) ≤ + G.fractionalReverseSlabTransport a d c l u δ ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) := by + by_cases hxy : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d+(u-l) ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c-(u-l)}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u + · have hrev : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d-l ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ c-u}) y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l := by + rw [G.orbitAdjustedHeight_reverse hc hl a x y] + exact ⟨Percolation.conn_symm G.ends _ (G.adjusted_slab_connection_change_root hc hl a ω x y x y + (d+(u-l)) (c-(u-l)) (d-l) (c-u) (by linarith [hxy.2.2]) + (by linarith [hxy.2.1]) hxy.1),by linarith [hxy.2.2],by linarith [hxy.2.1]⟩ + simp only [fractionalReverseSlabTransport,adjustedSlabBandTransport, + ite_eq_left hxy,ite_eq_left hrev,one_mul] + have hpow : (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^(-δ) ≤ + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω y)^(-δ) := by + simp only [ENNReal.rpow_neg] + exact ENNReal.inv_le_inv.mpr (ENNReal.rpow_le_rpow + (G.reverse_slab_band_count_le_zero_band hc hl a d c l u ω x y hxy.1 hxy.2.1 hxy.2.2) hδ) + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr hxy.2.1)) hpow).trans_eq + (mul_comm _ _) + · simp only [adjustedSlabBandTransport,ite_eq_right hxy,zero_mul,mul_zero] + exact bot_le + +lemma adjustedSlabBandTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (d c l u : ℝ) + (φ : G.Aut) (ω : Set E) (x y : V) : + G.adjustedSlabBandTransport a d c l u (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.adjustedSlabBandTransport a d c l u ω x y := by + have hD : φ.vertex ⁻¹' {z | d ≤ G.orbitAdjustedHeight a (φ.vertex x) z ∧ + G.orbitAdjustedHeight a (φ.vertex x) z ≤ c} = + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c} := by + ext z + simp only [Set.mem_preimage,Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] + have hmask : φ.edge ⁻¹' (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a (φ.vertex x) z ∧ G.orbitAdjustedHeight a (φ.vertex x) z ≤ c}) = + ω ∩ Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c} := by + rw [Set.preimage_inter,Set.preimage_image_eq _ φ.edge.injective, + ←Percolation.internalEdges_aut_preimage G.ends φ.preserves,hD] + unfold adjustedSlabBandTransport + rw [←Percolation.conn_aut_iff G.ends φ.preserves,hmask,G.orbitAdjustedHeight_aut a ha] + +lemma adjustedSlabBandCount_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (d c l u : ℝ) + (φ : G.Aut) (ω : Set E) (x : V) : + G.adjustedSlabBandCount a d c l u (φ.edge '' ω) (φ.vertex x) = + G.adjustedSlabBandCount a d c l u ω x := by + unfold adjustedSlabBandCount + rw [←φ.vertex.tsum_eq] + simp only [G.adjustedSlabBandTransport_aut a ha] + +variable [Countable V] [Countable E] + +lemma measurable_adjustedSlabBandTransport (a : V → ℝ) (d c l u : ℝ) (x y : V) : + Measurable (fun ω => G.adjustedSlabBandTransport a d c l u ω x y) := by + have hm : Measurable (fun ω : Set E => ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact Measurable.ite (((Percolation.measurableSet_conn G.ends x y).mem.comp hm).and + measurable_const).setOf measurable_const measurable_const + +lemma measurable_adjustedSlabBandCount (a : V → ℝ) (d c l u : ℝ) (x : V) : + Measurable (fun ω => G.adjustedSlabBandCount a d c l u ω x) := + Measurable.tsum fun y => G.measurable_adjustedSlabBandTransport a d c l u x y + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..76cfb750ce5826385761c4d13356a756d705f39c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FractionalSlabTransport.lean @@ -0,0 +1,99 @@ +import OAI.Probability.BenjaminiSchramm.FractionalSlabGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma fractionalReverseSlabTransport_outgoing (a : V → ℝ) (d c l u : ℝ) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ < 1) (ω : Set E) (x : V) : + (∑' y, G.fractionalReverseSlabTransport a d c l u δ ω x y) ≤ + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω x)^(1-δ) := by + unfold fractionalReverseSlabTransport + rw [ENNReal.tsum_mul_right] + exact ennreal_mul_negative_rpow_le _ hδ hδ1 + +lemma fractionalReverseSlabTransport_incoming_sum + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (d c l u : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) + (ω : Set E) (x : V) : + ENNReal.ofReal (Real.exp l)* + (G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω x * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^(-δ)) ≤ + ∑' y, G.fractionalReverseSlabTransport a d c l u δ ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) := by + rw [adjustedSlabBandCount,←ENNReal.tsum_mul_right,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum fun y => + G.fractionalReverseSlabTransport_incoming_lower hc hl a d c l u hδ ω x y + +variable [Countable V] [Countable E] + +lemma measurable_fractionalReverseSlabTransport (a : V → ℝ) (d c l u δ : ℝ) (x y : V) : + Measurable (fun ω => G.fractionalReverseSlabTransport a d c l u δ ω x y) := + (G.measurable_adjustedSlabBandTransport a _ _ _ _ x y).mul + ((G.measurable_adjustedSlabBandCount a _ _ _ _ x).pow_const (-δ)) + +omit [Countable V] [Countable E] in +lemma fractionalReverseSlabTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (d c l u δ : ℝ) + (φ : G.Aut) (ω : Set E) (x y : V) : + G.fractionalReverseSlabTransport a d c l u δ (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.fractionalReverseSlabTransport a d c l u δ ω x y := by + simp only [fractionalReverseSlabTransport,G.adjustedSlabBandTransport_aut a ha, + G.adjustedSlabBandCount_aut a ha] + +theorem expected_fractional_slab_transport + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (p : unitInterval) (d c l u : ℝ) {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ < 1) : + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω x * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^(-δ) ∂G.law p)) ≤ + ENNReal.ofReal (Real.exp (-l)) * + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω x)^(1-δ) ∂G.law p)) := by + let B (ω : Set E) (x : V) := G.adjustedSlabBandCount a (d+(u-l)) (c-(u-l)) l u ω x * + (G.adjustedSlabBandCount a d c (l-u) (u-l) ω x)^(-δ) + have he := OrbitRepresentatives.random_normalized_tilted_transport G O hc hl a hapos ha p + (G.fractionalReverseSlabTransport a d c l u δ) + (G.measurable_fractionalReverseSlabTransport a d c l u δ) + (G.fractionalReverseSlabTransport_aut a ha d c l u δ) + have hw : ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, B ω x ∂G.law p)) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + (G.adjustedSlabBandCount a (d-l) (c-u) (-u) (-l) ω x)^(1-δ) ∂G.law p) := by + calc + _ ≤ ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + ∑' y, G.fractionalReverseSlabTransport a d c l u δ ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) ∂G.law p) := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro x hx + calc + _ = ENNReal.ofReal (a x)*(∫⁻ ω, ENNReal.ofReal (Real.exp l)*B ω x ∂G.law p) := by + rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] + ring + _ ≤ _ := mul_le_mul' le_rfl (lintegral_mono + (G.fractionalReverseSlabTransport_incoming_sum hc hl a d c l u hδ · x)) + _ = ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + ∑' y, G.fractionalReverseSlabTransport a d c l u δ ω x y ∂G.law p) := he.symm + _ ≤ _ := Finset.sum_le_sum fun x _ => mul_le_mul' le_rfl + (lintegral_mono (G.fractionalReverseSlabTransport_outgoing a d c l u hδ hδ1 · x)) + calc + _ = ENNReal.ofReal (Real.exp (-l))*(ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, B ω x ∂G.law p))) := by + rw [←mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add, + neg_add_cancel,Real.exp_zero,ENNReal.ofReal_one,one_mul] + _ ≤ _ := mul_le_mul' le_rfl hw + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FreshSlabConcatenation.lean b/lean/OAI/Probability/BenjaminiSchramm/FreshSlabConcatenation.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc7666953b5debc1fe6fb1fdd61399f64f7e1f55 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FreshSlabConcatenation.lean @@ -0,0 +1,125 @@ +import OAI.Probability.BenjaminiSchramm.FreshSlabCrossing + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def restrictedHit (I : Set E) (x : V) (A : Set V) : Set (Set E) := + {ω | ∃ y ∈ A, Conn G (ω ∩ I) x y} + +lemma measurableSet_restrictedHit [Countable V] [Countable E] + (I : Set E) (x : V) (A : Set V) : MeasurableSet (restrictedHit G I x A) := by + have hm : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact (Measurable.exists fun y => measurable_const.and + ((measurableSet_conn G x y).mem.comp hm)).setOf + +lemma restrictedHit_dependsOn (I : Set E) (x : V) (A : Set V) : + DependsOn (fun ω => ω ∈ restrictedHit G I x A) I := by + intro ω η hωη + have he : Set.inter ω I = Set.inter η I := by + ext e + change (ω e ∧ e ∈ I) ↔ (η e ∧ e ∈ I) + by_cases hi : e ∈ I + · simp only [hi,and_true] + exact Iff.of_eq (hωη e hi) + · simp only [hi,and_false] + change (∃ y ∈ A, Conn G (Set.inter ω I) x y) = + (∃ y ∈ A, Conn G (Set.inter η I) x y) + rw [he] + +theorem restrictedHit_fresh_concatenation [Encodable V] [Countable E] + (q : E → unitInterval) (I J : Set E) (hIJ : Disjoint I J) + (x : V) (A B : Set V) (c : ℝ≥0∞) + (hc : ∀ z ∈ A, c ≤ CriticalPercolation.BernoulliProduct.law q (restrictedHit G J z B)) : + CriticalPercolation.BernoulliProduct.law q (restrictedHit G I x A) * c ≤ + CriticalPercolation.BernoulliProduct.law q (restrictedHit G (I ∪ J) x B) := by + let SA : A → Set (Set E) := fun z => firstLayerHitAt G I x A z + let SB : A → Set (Set E) := fun z => restrictedHit G J z B + have hdisj : Pairwise (fun z w => Disjoint (SA z) (SA w)) := by + intro z w hzw + exact firstLayerHitAt_pairwise G I x A (fun h => hzw (Subtype.ext h)) + have hsub : J ⊆ Iᶜ := Set.disjoint_left.mp hIJ.symm + have hprob := CriticalPercolation.BernoulliProduct.selected_fresh_continuation_lower + q I SA SB (fun z => measurableSet_firstLayerHitAt G I x A z) + (fun z => measurableSet_restrictedHit G J z B) + (fun z => firstLayerHitAt_dependsOn G I x A z) + (fun z => DependsOn.mono hsub (restrictedHit_dependsOn G J z B)) + hdisj c (fun z => hc z z.property) + have hsel : (⋃ z, SA z) = restrictedHit G I x A := by + ext ω + constructor + · intro h + obtain ⟨z,hz⟩ := Set.mem_iUnion.mp h + exact ⟨z,z.property,hz.1⟩ + · intro h + have h' : ω ∈ ⋃ z, firstLayerHitAt G I x A z := by + rw [iUnion_firstLayerHitAt] + exact h + obtain ⟨z,hz⟩ := Set.mem_iUnion.mp h' + exact Set.mem_iUnion.mpr ⟨⟨z,hz.2.1⟩,hz⟩ + rw [hsel] at hprob + refine hprob.trans (measure_mono ?_) + intro ω hω + obtain ⟨z,hz,hcont⟩ := Set.mem_iUnion.mp hω + obtain ⟨y,hy,hzy⟩ := hcont + refine ⟨y,hy,(conn_mono G (Set.inter_subset_inter_right _ Set.subset_union_left) hz.1).trans ?_⟩ + exact conn_mono G (Set.inter_subset_inter_right _ Set.subset_union_right) hzy + +theorem slab_crossing_fresh_product [Encodable V] [Countable E] + (q : E → unitInterval) (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (x : V) (a b d t : ℝ) (hx : a ≤ f x) (hxb : f x < b) (hbd : b+R ≤ d) + (κ : ℝ≥0∞) + (hκ : ∀ z, b ≤ f z → f z ≤ b+R → + κ ≤ CriticalPercolation.BernoulliProduct.law q + (restrictedHit G (internalEdges G {v | b ≤ f v ∧ f v ≤ d}) z {v | t ≤ f v})) : + CriticalPercolation.BernoulliProduct.law q + (restrictedHit G (internalEdges G {v | a ≤ f v ∧ f v ≤ b+R}) x {v | b ≤ f v}) * κ ≤ + CriticalPercolation.BernoulliProduct.law q + (restrictedHit G (internalEdges G {v | a ≤ f v ∧ f v ≤ d}) x {v | t ≤ f v}) := by + let I := lowerCrossingBlock G f a b R + let J := internalEdges G {v | b ≤ f v ∧ f v ≤ d} + let A := {v | b ≤ f v ∧ f v ≤ b+R} + let B := {v | t ≤ f v} + have hIJ : Disjoint I J := by + apply (lowerCrossingBlock_disjoint_upper G f a b R).mono_right + exact internalEdges_mono G (fun _ h => h.1) + have hstart : restrictedHit G (internalEdges G {v | a ≤ f v ∧ f v ≤ b+R}) x + {v | b ≤ f v} ⊆ restrictedHit G I x A := by + intro ω hω + obtain ⟨y,hy,hxy⟩ := hω + have hlo : Conn G (ω ∩ internalEdges G {v | a ≤ f v}) x y := + conn_mono G (Set.inter_subset_inter_right _ (internalEdges_mono G (fun _ h => h.1))) hxy + obtain ⟨z,hz,hzR,hzconn⟩ := + conn_above_lower_first_crossing G f R hR hjump ω x y a b hx hxb hy hlo + exact ⟨z,⟨hz,hzR⟩,hzconn⟩ + have hfinish : I ∪ J ⊆ internalEdges G {v | a ≤ f v ∧ f v ≤ d} := by + intro e he + rcases he with he | he + · apply internalEdges_mono G (show {v | a ≤ f v ∧ f v ≤ b+R} ⊆ + {v | a ≤ f v ∧ f v ≤ d} from fun _ h => ⟨h.1,h.2.trans hbd⟩) he.1 + · apply internalEdges_mono G (show {v | b ≤ f v ∧ f v ≤ d} ⊆ + {v | a ≤ f v ∧ f v ≤ d} from fun _ h => ⟨by linarith [h.1],h.2⟩) he + calc + _ ≤ CriticalPercolation.BernoulliProduct.law q (restrictedHit G I x A) * κ := + mul_le_mul' (measure_mono hstart) le_rfl + _ ≤ CriticalPercolation.BernoulliProduct.law q (restrictedHit G (I ∪ J) x B) := + restrictedHit_fresh_concatenation G q I J hIJ x A B κ + (fun z hz => hκ z hz.1 hz.2) + _ ≤ _ := by + apply measure_mono + intro ω hω + obtain ⟨y,hy,hxy⟩ := hω + exact ⟨y,hy,conn_mono G (Set.inter_subset_inter_right _ hfinish) hxy⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FreshSlabCrossing.lean b/lean/OAI/Probability/BenjaminiSchramm/FreshSlabCrossing.lean new file mode 100644 index 0000000000000000000000000000000000000000..3106eff546994a37e4b4e7fa7b78fa900493e674 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FreshSlabCrossing.lean @@ -0,0 +1,82 @@ +import OAI.Probability.BenjaminiSchramm.SelectedLayerVertex +import OAI.Probability.UnimodularPercolation.Deformation.ClusterProducts + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma conn_internalEdges_end_mem (ω : Set E) (D : Set V) {x y : V} + (hx : x ∈ D) (hconn : Conn G (ω ∩ internalEdges G D) x y) : y ∈ D := by + induction hconn with + | refl => exact hx + | @tail z y _ hy _ => + obtain ⟨e,he,heq⟩ := hy + exact he.2 y (by rw [heq]; simp) + +def lowerCrossingBlock (f : V → ℝ) (a b R : ℝ) : Set E := + internalEdges G {v | a ≤ f v ∧ f v ≤ b+R} ∩ (internalEdges G {v | b ≤ f v})ᶜ + +lemma lowerCrossingBlock_disjoint_upper (f : V → ℝ) (a b R : ℝ) : + Disjoint (lowerCrossingBlock G f a b R) (internalEdges G {v | b ≤ f v}) := by + exact Set.disjoint_left.mpr fun _ h₁ h₂ => h₁.2 h₂ + +lemma first_height_crossing_unexposed (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) {x y : V} (p : (openSimpleGraph G ω).Walk x y) (a b : ℝ) : + a ≤ f x → f x < b → b ≤ f y → (∀ z ∈ p.support, a ≤ f z) → + ∃ z, b ≤ f z ∧ f z ≤ b+R ∧ + Conn G (ω ∩ lowerCrossingBlock G f a b R) x z := by + induction p with + | @nil u => + intro _ hu hv _ + exact (not_lt_of_ge hv hu).elim + | @cons x v y huv p ih => + intro ha hb hend hlow + have hav : a ≤ f v := hlow v (by simp) + obtain ⟨e,he,heq⟩ := huv.2 + have hxe : x ∈ G e := by rw [heq]; simp + have hve : v ∈ G e := by rw [heq]; simp + have hj := (abs_le.mp (hjump e x v hxe hve)).2 + by_cases hv : b ≤ f v + · have hvR : f v ≤ b+R := by linarith + refine ⟨v,hv,hvR,Relation.ReflTransGen.single ⟨e,⟨he,?_,?_⟩,heq⟩⟩ + · rw [mem_internalEdges_of_ends G _ e x v heq] + exact ⟨⟨ha,by linarith⟩,hav,hvR⟩ + · intro he' + exact (not_le_of_gt hb) (he' x hxe) + · obtain ⟨z,hz,hzR,hconn⟩ := ih hav (lt_of_not_ge hv) hend + (fun w hw => hlow w (List.mem_cons_of_mem _ hw)) + refine ⟨z,hz,hzR,(Relation.ReflTransGen.single ⟨e,⟨he,?_,?_⟩,heq⟩).trans hconn⟩ + · rw [mem_internalEdges_of_ends G _ e x v heq] + exact ⟨⟨ha,by linarith⟩,hav,by linarith⟩ + · intro he' + exact (not_le_of_gt hb) (he' x hxe) + +theorem conn_above_lower_first_crossing (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) (x y : V) (a b : ℝ) (hx : a ≤ f x) (hxb : f x < b) + (hy : b ≤ f y) (hc : Conn G (ω ∩ internalEdges G {v | a ≤ f v}) x y) : + ∃ z, b ≤ f z ∧ f z ≤ b+R ∧ + Conn G (ω ∩ lowerCrossingBlock G f a b R) x z := by + obtain ⟨p⟩ := (conn_iff_reachable G _ x y).mp hc + have hlow : ∀ z ∈ p.support, a ≤ f z := by + intro z hz + have hconn : Conn G (ω ∩ internalEdges G {v | a ≤ f v}) x z := + (conn_iff_reachable G _ x z).mpr ⟨p.takeUntil z hz⟩ + exact conn_internalEdges_end_mem G ω _ hx hconn + obtain ⟨z,hz,hzR,hconn⟩ := first_height_crossing_unexposed G f R hR hjump + (ω ∩ internalEdges G {v | a ≤ f v}) p a b hx hxb hy hlow + refine ⟨z,hz,hzR,conn_mono G ?_ hconn⟩ + intro e he + exact ⟨he.1.1,he.2⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FreshWhiteExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/FreshWhiteExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..e61f5e42924134ca4d446b18c0f31ee2b93f92a0 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FreshWhiteExposure.lean @@ -0,0 +1,116 @@ +import OAI.Probability.BenjaminiSchramm.PairedSprinkling +import OAI.Probability.BenjaminiSchramm.BlockExposure +import OAI.Probability.BenjaminiSchramm.ClusterExposure +import OAI.Probability.BenjaminiSchramm.SprinklingPeakGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BernoulliProduct +variable {E : Type*} + +lemma fresh_white_union_inter_factor (q b : E → unitInterval) (Q : Set E) + (A B : Set (Set (E × Bool))) (hA : MeasurableSet A) + (hdep : DependsOn (fun ω => ω ∈ A) (whiteBlock Q)) (hB : MeasurableSet B) : + law (pairedParameters q b) (A ∩ forceOn (whiteBlock Q) ∅ ⁻¹' B)= + law (pairedParameters q b) A * + law (pairedParameters (erasedWhiteParameters q Q) b) B := by + let g := fun ω => B.indicator (fun _ => (1 : ℝ≥0∞)) (forceOn (whiteBlock Q) ∅ ω) + have hg : Measurable g := (measurable_const.indicator hB).comp (measurable_forceOn _ _) + have hgd : DependsOn g (whiteBlock Q)ᶜ := by + intro ω η hωη + have hh : forceOn (whiteBlock Q) ∅ ω=forceOn (whiteBlock Q) ∅ η := by + ext z + change (if z ∈ whiteBlock Q then False else ω z) ↔ + (if z ∈ whiteBlock Q then False else η z) + by_cases hz : z ∈ whiteBlock Q + · simp only [ite_eq_left hz] + · simpa only [ite_eq_right hz] using (hωη z hz).to_iff + exact congrArg (B.indicator (fun _ => (1 : ℝ≥0∞))) hh + have hi := lintegral_indicator_fresh (pairedParameters q b) (whiteBlock Q) A hA hdep g hg hgd + have he : A.indicator g=(A ∩ forceOn (whiteBlock Q) ∅ ⁻¹' B).indicator (fun _ => (1 : ℝ≥0∞)) := by + funext ω + by_cases ha : ω ∈ A <;> by_cases hb : forceOn (whiteBlock Q) ∅ ω ∈ B <;> + simp [Set.indicator,g,ha,hb] + have hmB := hB.preimage (measurable_forceOn (whiteBlock Q) ∅) + rw [he,lintegral_indicator_fun_one (hA.inter hmB)] at hi + have hgint : (∫⁻ ω, g ω ∂law (pairedParameters q b))= + law (pairedParameters (erasedWhiteParameters q Q) b) B := by + change (∫⁻ ω, (forceOn (whiteBlock Q) ∅ ⁻¹' B).indicator + (fun _ => (1 : ℝ≥0∞)) ω ∂law (pairedParameters q b))=_ + rw [lintegral_indicator_fun_one hmB,←Measure.map_apply (measurable_forceOn _ _) hB, + forceOn_map_law,pinned_white_parameters] + rwa [hgint] at hi + +lemma fresh_white_union_event_factor (q b : E → unitInterval) (Q : Set E) + (A : Set (Set (E × Bool))) (hA : MeasurableSet A) + (hdep : DependsOn (fun ω => ω ∈ A) (whiteBlock Q)) + (B : Set (Set E)) (hB : MeasurableSet B) : + law (pairedParameters q b) + (A ∩ (pairedUnion ∘ forceOn (whiteBlock Q) ∅) ⁻¹' B)= + law (pairedParameters q b) A * + law (fun e => Percolation.sprinkleParameter (erasedWhiteParameters q Q e) (b e)) B := by + rw [show (pairedUnion ∘ forceOn (whiteBlock Q) ∅) ⁻¹' B= + forceOn (whiteBlock Q) ∅ ⁻¹' (pairedUnion ⁻¹' B) from rfl] + rw [fresh_white_union_inter_factor q b Q A _ hA hdep (hB.preimage measurable_pairedUnion), + ←Measure.map_apply measurable_pairedUnion hB,paired_union_law] + +lemma erased_pairedUnion (Q : Set E) (ω : Set (E × Bool)) : + pairedUnion (forceOn (whiteBlock Q) ∅ ω)= + (whiteProjection ω \ Q) ∪ blueProjection ω := by + ext e + by_cases he : e ∈ Q <;> + simp [pairedUnion,whiteBlock,whiteProjection,blueProjection, + Bool.exists_bool,he,and_comm,or_comm] + +end CriticalPercolation.BernoulliProduct + +namespace CriticalPercolation.BondGraph +open BernoulliProduct Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma cluster_eq_percolationCluster (ω : Set E) (x : V) : + G.cluster ω x=Percolation.cluster G.ends ω x := criticalModel_cluster G.ends ω x + +lemma paired_exactWhiteCluster_dependsOn (x : V) (S : Set V) : + DependsOn (fun ω : Set (E × Bool) => G.cluster (whiteProjection ω) x=S) + (whiteBlock (G.incidentEdges S)) := by + intro ω η hωη + apply G.exactCluster_dependsOn x S + intro e he + exact hωη (e,true) ⟨he,rfl⟩ + +lemma white_edge_incident_cluster_internal (white : Set E) (x : V) (e : E) + (he : e ∈ white) (hI : e ∈ G.incidentEdges (G.cluster white x)) : + e ∈ Percolation.internalEdges G.ends (G.cluster white x) := by + have hS : G.cluster white x=Percolation.cluster G.ends white x := criticalModel_cluster G.ends white x + rw [hS] at hI ⊢ + obtain ⟨v,hv,hve⟩ := hI + intro w hw + by_cases h : v=w + · simpa only [←h] using hv + · have heq : G.ends e=s(v,w) := (Sym2.mem_and_mem_iff h).mp ⟨hve,hw⟩ + exact hv.trans (Relation.ReflTransGen.single ⟨e,he,heq⟩) + +lemma erasedWhiteCluster_exterior_eq (ω : Set (E × Bool)) (x : V) : + pairedUnion (forceOn (whiteBlock (G.incidentEdges (G.cluster (whiteProjection ω) x))) ∅ ω) \ + Percolation.internalEdges G.ends (G.cluster (whiteProjection ω) x)= + pairedUnion ω \ Percolation.internalEdges G.ends (G.cluster (whiteProjection ω) x) := by + rw [erased_pairedUnion,pairedUnion_eq] + ext e + constructor + · rintro ⟨(⟨hew,_⟩ | heb),heI⟩ + · exact ⟨Or.inl hew,heI⟩ + · exact ⟨Or.inr heb,heI⟩ + · rintro ⟨(hew | heb),heI⟩ + · exact ⟨Or.inl ⟨hew,fun hQ => heI (G.white_edge_incident_cluster_internal _ x e hew hQ)⟩,heI⟩ + · exact ⟨Or.inr heb,heI⟩ + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FullConclusion.lean b/lean/OAI/Probability/BenjaminiSchramm/FullConclusion.lean new file mode 100644 index 0000000000000000000000000000000000000000..459ca476bfbfff404d457b854d40dceb53397869 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FullConclusion.lean @@ -0,0 +1,78 @@ +import OAI.Probability.BenjaminiSchramm.SubdivisionConsequences +import OAI.Probability.BenjaminiSchramm.SubdivisionOperator + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem publishedSimpleGraph_subdivision (G : BondGraph V E) + (hconn : Connected G) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) : + PublishedSimpleGraph (subdivision G) := by + refine ⟨subdivision_injective G, ?_, subdivision_connected G hconn, + subdivision_locallyFinite G hloc, subdivision_quasiTransitive G hloc hqt⟩ + intro e x hx + exact subdivision_loopless G x ⟨e, hx⟩ + +theorem exponentialDecay_of_subdivision [Countable V] [Countable E] + (G : BondGraph V E) (q : unitInterval) + (h : ExponentialDecay (subdivision G) q) : ExponentialDecay G (q ^ 2) := by + obtain ⟨A, a, hA, ha, hb⟩ := h + refine ⟨A, 2 * a, hA, by positivity, ?_⟩ + intro x y + have hh := hb (.inl x) (.inl y) + rw [twoPoint_subdivision, graphDistance_subdivision] at hh + convert hh using 1 + congr 2 + push_cast + ring + +theorem full_conditional [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) + (hfirst : HutchcroftFirstMomentInput (subdivision G)) + (htheta : TrianglePercolationProbabilityInput (subdivision G)) + (hvolume : HutchcroftCriticalVolumeInput (subdivision G)) + (hradii : HutchcroftCriticalRadiiInput (subdivision G)) + (hexp : HutchcroftExponentialInput (subdivision G)) : + MainConclusion G ∧ CriticalLawsConclusion G := by + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + have hHconn := subdivision_connected G hconn + have hHloc := subdivision_locallyFinite G hloc + have hHqt := subdivision_quasiTransitive G hloc hqt + have hmain := main_conditional G hconn hloc hqt hh hutchcroft2019 + have hmainH := mainConclusion_of_critical_bounded (subdivision G) hHconn hHloc hHqt + (critical_subdivision_bounded_conditional G hconn hloc hqt hh hutchcroft2019) + have hlaws := critical_laws_of_mainConclusion (subdivision G) + (publishedSimpleGraph_subdivision G hconn hloc hqt) hmainH + hfirst htheta hvolume hradii hexp + have hdecay (p : unitInterval) (hp : p < ptwo G) : ExponentialDecay G p := by + let q := squareParameter.symm p + have hq2 : q ^ 2 = p := squareParameter.apply_symm_apply p + have hq : q < ptwo (subdivision G) := by + apply squareParameter.lt_iff_lt.mp + change q ^ 2 < ptwo (subdivision G) ^ 2 + rw [ptwo_subdivision_sq G hloc hqt, hq2] + exact hp + simpa only [hq2] using exponentialDecay_of_subdivision G q (hlaws.2.2.2.2.2 q hq) + refine ⟨hmain, critical_triangle_of_mainConclusion G hmain, + susceptibilityLaw_of_subdivision G hloc hqt hlaws.2.1, + probabilityLaw_of_subdivision G hloc hqt hlaws.2.2.1, + criticalTailLaws_of_subdivision G hloc hqt hlaws.2.2.2.1, + ⟨hmain.2.2.1, ?_⟩, hdecay⟩ + apply le_of_forall_lt_imp_le_of_dense + intro p hp + exact le_sSup (hdecay p hp) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FullLayerProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/FullLayerProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e685c7b95140bc9b4e1abf71ca47258d538be88 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FullLayerProfile.lean @@ -0,0 +1,69 @@ +import OAI.Probability.BenjaminiSchramm.LayerMaximumDecomposition +import OAI.Probability.BenjaminiSchramm.BoundedLayerShift + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem supAdjustedFullLayerMoment_le_row_bound + (a : V → ℝ) (R : ℝ) (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) (i : ℤ) : + G.supAdjustedFullLayerMoment a R p i ≤ C := by + apply iSup_le + intro x + apply iSup_le + intro u + exact restrictedLayerCount_expectation_le_row_bound G.ends p C hrow _ _ x + +theorem adjustedFullLayerMoment_up_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (n : ℕ) (x : V) (u : ℝ) : + G.adjustedFullLayerMoment a R p (n : ℤ) x u ≤ G.supAdjustedUpLayerMoment a R p n*C := by + by_cases hn : n=0 + · subst n + have hz : (1 : ℝ≥0∞) ≤ G.supAdjustedUpLayerMoment a R p 0 := + (G.adjustedUpLayerMoment_zero_ge_one a R p x u).trans (G.adjustedUpLayerMoment_le_sup a R p 0 x u) + exact ((G.adjustedFullLayerMoment_le_sup a R p 0 x u).trans + (G.supAdjustedFullLayerMoment_le_row_bound a R p C hrow 0)).trans + ((one_mul C).symm.le.trans (mul_le_mul' hz le_rfl)) + let f := G.adjustedLayerIndex a R u x + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → f w ≤ f v+1 ∧ f v ≤ f w+1 := by + intro e v w hv hw + have hh := G.adjustedLayerIndex_edge_jump hc hl a R u hR hjump x v w e hv hw + change f v-1 ≤ f w ∧ f w ≤ f v+1 at hh + exact ⟨hh.2,by omega⟩ + have hx : f x < (n : ℤ) := by + simp only [f,G.adjustedLayerIndex_self] + exact_mod_cast Nat.pos_of_ne_zero hn + have hA : ∀ y ∈ {v | f v=(n : ℤ)}, (n : ℤ) ≤ f y := fun _ h => h.ge + exact (first_layer_moment_bound_with_row G.ends p C hrow f hj Set.univ _ x n hx hA).trans + (mul_le_mul' (G.adjustedUpLayerMoment_le_sup a R p n x u) le_rfl) + +theorem supAdjustedFullLayerMoment_up_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) (n : ℕ) : + G.supAdjustedFullLayerMoment a R p (n : ℤ) ≤ G.supAdjustedUpLayerMoment a R p n*C := by + apply iSup_le + intro x + apply iSup_le + intro u + exact G.adjustedFullLayerMoment_up_bound hc hl a R hR hjump p C hrow n x u + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FullNegativeLayerProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/FullNegativeLayerProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..f203f81a0a9ebc5ba55a7f4de004ec629c6e6861 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FullNegativeLayerProfile.lean @@ -0,0 +1,135 @@ +import OAI.Probability.BenjaminiSchramm.FullLayerProfile +import OAI.Probability.BenjaminiSchramm.BandMomentSummability + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma fullLayerCount_le_bandCount (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (i : ℤ) (x : V) (u : ℝ) (ω : Set E) : + restrictedLayerCount G.ends Set.univ {y | G.adjustedLayerIndex a R u x y=i} ω x ≤ + G.adjustedBandCount a (R*((i : ℝ)-1)) (R*((i : ℝ)+1)) ω x := by + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : G.adjustedLayerIndex a R u x y=i ∧ Percolation.Conn G.ends (ω ∩ Set.univ) x y + · have hh := G.adjustedLayerIndex_height_bounds a R u hR x y + rw [hy.1] at hh + have hc : y ∈ G.cluster ω x := by + change y ∈ (criticalModel G.ends).cluster ω x + rw [criticalModel_cluster] + exact Percolation.conn_mono G.ends Set.inter_subset_left hy.2 + have ht : y ∈ G.cluster ω x ∧ + R*((i : ℝ)-1) ≤ G.orbitAdjustedHeight a x y ∧ + G.orbitAdjustedHeight a x y ≤ R*((i : ℝ)+1) := + ⟨hc,hh.1.le,hh.2.le⟩ + simp only [Set.mem_ofPred_eq,ite_eq_left hy,adjustedBandTransport,ite_eq_left ht,le_refl] + · simp only [Set.mem_ofPred_eq,ite_eq_right hy] + exact bot_le + +variable [Countable V] [Countable E] + +lemma expected_bandCount_le_intermediate_upLayerMoment + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (n : ℕ) (hn : 0 < n) (x : V) (l u : ℝ) (hlower : R*n ≤ l) : + (∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p) ≤ G.adjustedUpLayerMoment a R p n x 0*C := by + have he (ω : Set E) : G.adjustedBandCount a l u ω x = + restrictedLayerCount G.ends Set.univ + {y | l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u} ω x := by + apply tsum_congr + intro y + have hc : y ∈ G.cluster ω x ↔ Percolation.Conn G.ends ω x y := by + change y ∈ (criticalModel G.ends).cluster ω x ↔ _ + rw [criticalModel_cluster] + rfl + simp only [adjustedBandTransport,Set.inter_univ,Set.mem_ofPred_eq,hc] + congr 1 + apply propext + tauto + simp_rw [he] + let f := G.adjustedLayerIndex a R 0 x + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → f w ≤ f v+1 ∧ f v ≤ f w+1 := by + intro e v w hv hw + have hh := G.adjustedLayerIndex_edge_jump hc hl a R 0 hR hjump x v w e hv hw + change f v-1 ≤ f w ∧ f w ≤ f v+1 at hh + exact ⟨hh.2,by omega⟩ + have hx : f x < (n : ℤ) := by simp only [f,G.adjustedLayerIndex_self]; exact_mod_cast hn + have hA : ∀ y ∈ {v | l ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ u}, + (n : ℤ) ≤ f y := by + intro y hy + simp only [f,adjustedLayerIndex,add_zero,Int.floor_zero,sub_zero] + apply Int.le_floor.mpr + apply (le_div_iff₀ hR).mpr + push_cast + nlinarith [hy.1] + exact first_layer_moment_bound_with_row G.ends p C hrow f hj Set.univ _ x n hx hA + +theorem adjustedFullLayerMoment_negative_bound + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (hm : 0 < m) (ham : ∀ x, m ≤ a x) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (n : ℕ) (hn : 3 ≤ n) (x : V) (u : ℝ) : + G.adjustedFullLayerMoment a R p (-(n : ℤ)) x u ≤ + ((ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r)))* + ENNReal.ofReal (Real.exp (R*((n : ℝ)+1)))*(G.supAdjustedUpLayerMoment a R p (n-2)*C) := by + let l := -(R*((n : ℝ)+1)) + let v := -(R*((n : ℝ)-1)) + have hmin : R*(n-2 : ℕ) ≤ -v := by + dsimp [v] + rw [Nat.cast_sub (by omega : 2 ≤ n)] + push_cast + nlinarith + have hroot (r : V) : (∫⁻ ω, G.adjustedBandCount a (-v) (-l) ω r ∂G.law p) ≤ + G.supAdjustedUpLayerMoment a R p (n-2)*C := + (G.expected_bandCount_le_intermediate_upLayerMoment hc hl a R hR hjump p C hrow + (n-2) (by omega) r (-v) (-l) hmin).trans + (mul_le_mul' (G.adjustedUpLayerMoment_le_sup a R p (n-2) r 0) le_rfl) + have hsum : (∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedBandCount a (-v) (-l) ω r ∂G.law p)) ≤ + (∑ r ∈ O.roots, ENNReal.ofReal (a r))*(G.supAdjustedUpLayerMoment a R p (n-2)*C) := by + rw [Finset.sum_mul] + exact Finset.sum_le_sum fun r _ => mul_le_mul' le_rfl (hroot r) + calc + _ ≤ ∫⁻ ω, G.adjustedBandCount a l v ω x ∂G.law p := by + have hleft : R*(((-(n : ℤ)) : ℝ)-1)=l := by + dsimp [l] + push_cast + ring + have hright : R*(((-(n : ℤ)) : ℝ)+1)=v := by + dsimp [v] + push_cast + ring + unfold adjustedFullLayerMoment + apply lintegral_mono + intro ω + have hh := G.fullLayerCount_le_bandCount a R hR (-(n : ℤ)) x u ω + simp only [Int.cast_neg] at hh + rw [hleft,hright] at hh + exact hh + _ ≤ (ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r)* + (∫⁻ ω, G.adjustedBandCount a l v ω r ∂G.law p)) := + G.expected_band_le_weighted_roots O a ha m hm ham p l v x + _ ≤ (ENNReal.ofReal m)⁻¹*(ENNReal.ofReal (Real.exp (-l))* + ((∑ r ∈ O.roots, ENNReal.ofReal (a r))*(G.supAdjustedUpLayerMoment a R p (n-2)*C))) := + mul_le_mul' le_rfl (((G.expected_adjustedBandCount_reciprocity O hc hl a hapos ha p l v).2).trans + (mul_le_mul' le_rfl hsum)) + _ = _ := by dsimp only [l]; rw [neg_neg]; ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/FullspaceFractionalRecurrence.lean b/lean/OAI/Probability/BenjaminiSchramm/FullspaceFractionalRecurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea802b2364bfce6b4b55d943ace160c5dd54f786 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/FullspaceFractionalRecurrence.lean @@ -0,0 +1,186 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceFractionalRecurrence +import OAI.Probability.BenjaminiSchramm.LayerMonotoneLimit +import OAI.Probability.BenjaminiSchramm.GeometricIncrement + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma internalEdges_ceilings_iUnion (f : V → ℝ) (R b : ℝ) (hR : 0 < R) : + (⋃ n : ℕ, internalEdges G {z | f z ≤ b+(n : ℝ)*R})=Set.univ := by + ext e + simp only [Set.mem_univ,iff_true] + have hp : ∀ s : Sym2 V, ∃ n : ℕ, ∀ z ∈ s, f z ≤ b+(n : ℝ)*R := by + intro s + induction s using Sym2.inductionOn with + | _ u v => + obtain ⟨N,hN⟩ := exists_nat_gt (max ((f u-b)/R) ((f v-b)/R)) + refine ⟨N,fun z hz => ?_⟩ + have hu := (div_lt_iff₀ hR).mp ((le_max_left _ _).trans_lt hN) + have hv := (div_lt_iff₀ hR).mp ((le_max_right _ _).trans_lt hN) + rcases Sym2.mem_iff.mp hz with rfl | rfl <;> linarith + obtain ⟨n,hn⟩ := hp (G e) + exact mem_iUnion.mpr ⟨n,hn⟩ + +lemma internalEdges_ceilings_monotone (f : V → ℝ) (R b : ℝ) (hR : 0 ≤ R) : + Monotone (fun n : ℕ => internalEdges G {z | f z ≤ b+(n : ℝ)*R}) := by + intro n m hnm + apply internalEdges_mono G + intro z hz + have hh := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hnm : (n : ℝ) ≤ m) hR + change f z ≤ b+(n : ℝ)*R at hz + exact hz.trans (by linarith) + +variable [Countable V] [Countable E] + +theorem fullspace_fractional_from_ceiling_profiles + (hl : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hl u).toFinset.card ≤ d) + (h : V → V → ℝ) (hself : ∀ x, h x x=0) + (hbase : ∀ x z v, h x v=h x z+h z v) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ x e u v, u ∈ G e → v ∈ G e → |h x v-h x u| ≤ R) + (p : unitInterval) (hfin : ∀ x, ∀ᵐ ω ∂law p, (cluster G ω x).Finite) + (q t α ρ : ℝ) (hq : 0 < q) (hq1 : q ≤ 1) (ht : 0 < t) (ht1 : t < 1) + (hrate : α+t*ρ < 0) + (htop : ∀ u ∈ ({t,q*t} : Set ℝ), ∀ ε : ℝ, 0 < ε → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | h x v ≤ k}) + {v | k-R ≤ h x v ∧ h x v ≤ k+R} ω x)^u ∂law p) ≤ + C*ENNReal.ofReal (Real.exp ((α+ε)*k))) + (D : ℝ≥0∞) (hD : D < ⊤) + (hcont : ∀ s : ℝ, 0 ≤ s → ∀ z : V, + (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | h z v ≤ R}) + {v | -s-R ≤ h z v ∧ h z v ≤ -s+R} ω z)^q ∂law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*s))) : + ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G Set.univ + {v | k-R ≤ h x v ∧ h x v ≤ k+R} ω x)^(q*t) ∂law p) ≤ + C*ENNReal.ofReal (Real.exp ((α+ζ)*k)) := by + intro ζ hζ + let ε := min ζ (-(α+t*ρ)/2) + have hε : 0 < ε := lt_min hζ (by linarith) + have hεζ : ε ≤ ζ := min_le_left _ _ + have hεrate : ε ≤ -(α+t*ρ)/2 := min_le_right _ _ + have hqt : 0 < q*t := mul_pos hq ht + obtain ⟨A,hA,hab⟩ := htop t (by simp) ε hε + obtain ⟨B,hB,hbb⟩ := htop (q*t) (by simp) ε hε + let K := (d : ℝ≥0∞)^t*A*D^t*ENNReal.ofReal (Real.exp ((max ρ 0*R)*t)) + have hK : K < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.mul_lt_top + (ENNReal.rpow_lt_top_of_nonneg ht.le (ENNReal.natCast_ne_top d)) hA) + (ENNReal.rpow_lt_top_of_nonneg ht.le hD.ne)) ENNReal.ofReal_lt_top + let s := -(α+t*ρ)*R/2 + have hs : 0 < s := by + dsimp [s] + exact div_pos (mul_pos (neg_pos.mpr hrate) hR) (by norm_num) + let S : ℝ≥0∞ := ∑' n : ℕ, ENNReal.ofReal (Real.exp (-s*n)) + have hS : S < ⊤ := by + apply Summable.tsum_ofReal_lt_top + simpa only [mul_comm] using Real.summable_exp_nat_mul_iff.mpr (neg_neg_of_pos hs) + refine ⟨B+K*S,ENNReal.add_lt_top.mpr ⟨hB,ENNReal.mul_lt_top hK hS⟩,fun k hk x => ?_⟩ + let f := h x + let W := {v | k-R ≤ f v ∧ f v ≤ k+R} + let F (n : ℕ) := ∫⁻ ω, (restrictedLayerCount G + (internalEdges G {v | f v ≤ k+(n : ℝ)*R}) W ω x)^(q*t) ∂law p + let Z := ENNReal.ofReal (Real.exp ((α+ε)*k)) + have h0 : F 0 ≤ B*Z := by simpa only [F,Nat.cast_zero,zero_mul,add_zero] using hbb k hk x + have hstep (n : ℕ) : F (n+1) ≤ F n+K*Z*ENNReal.ofReal (Real.exp (-s*n)) := by + let b := k+(n : ℝ)*R + let J := internalEdges G {v | f v ≤ k+((n : ℝ)+1)*R} + let L := D*ENNReal.ofReal (Real.exp (ρ*((n : ℝ)*R)+max ρ 0*R)) + have hL (z : V) (hzlo : b < f z) (hzhi : f z ≤ b+R) : + (∫⁻ ω, (restrictedLayerCount G J W ω z)^q ∂law p) ≤ L := by + let r := f z-k + have hr : 0 ≤ r := by dsimp [r,b] at *; nlinarith [Nat.cast_nonneg (α := ℝ) n] + apply le_trans _ ((hcont r hr z).trans ?_) + · apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ hq.le + apply (restrictedLayerCount_mono_edges G ?_ W ω z).trans + · apply restrictedLayerCount_mono_vertices G + intro v hv + have he := hbase x z v + dsimp [r,f,W] at hv ⊢ + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + · apply internalEdges_mono G + intro v hv + have he := hbase x z v + dsimp [J,f,b] at hv hzlo hzhi ⊢ + linarith + · apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hrlo : (n : ℝ)*R ≤ r := by dsimp [r,b] at *; linarith + have hrhi : r ≤ (n : ℝ)*R+R := by dsimp [r,b] at *; linarith + by_cases hρ : 0 ≤ ρ + · rw [max_eq_left hρ] + nlinarith + · rw [max_eq_right (le_of_not_ge hρ)] + nlinarith + have hI : ∀ᵐ ω ∂law p, (cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x).Finite := by + filter_upwards [hfin x] with ω hω + exact hω.subset fun v hv => conn_mono G inter_subset_left hv + have hh := lower_halfspace_fractional_recurrence G hl d hd (fun _ => p) f R b + (hjump x) J x (by simp only [f,hself]; dsimp [b]; positivity) + (by simpa only [CriticalPercolation.BernoulliProduct.law_const,law] using hI) + W hq hq1 ht ht1.le L + (fun z hzlo hzhi => by simpa only [CriticalPercolation.BernoulliProduct.law_const,law] using hL z hzlo hzhi) + simp only [CriticalPercolation.BernoulliProduct.law_const] at hh + have htop' : (∫⁻ ω, (restrictedLayerCount G (internalEdges G {v | f v ≤ b}) + {v | b-R ≤ f v ∧ f v ≤ b} ω x)^t ∂law p) ≤ + A*ENNReal.ofReal (Real.exp ((α+ε)*b)) := by + apply le_trans _ (hab b (by dsimp [b]; positivity) x) + apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ ht.le + apply restrictedLayerCount_mono_vertices G + intro v hv + exact ⟨hv.1,hv.2.trans (by linarith)⟩ + have hcast : ((n+1 : ℕ) : ℝ)=(n : ℝ)+1 := by norm_cast + simp only [F,hcast] + apply hh.trans + apply add_le_add le_rfl + apply (mul_le_mul' (mul_le_mul' le_rfl htop') le_rfl).trans + dsimp [L] + rw [ENNReal.mul_rpow_of_nonneg _ _ ht.le,ennreal_exp_rpow _ _ ht.le] + have he : (α+ε)*b+(ρ*((n : ℝ)*R)+max ρ 0*R)*t ≤ + (max ρ 0*R)*t+((α+ε)*k+(-s*(n : ℝ))) := by + have hh := mul_le_mul_of_nonneg_right hεrate (mul_nonneg (Nat.cast_nonneg n) hR.le) + dsimp [b,s] + nlinarith + calc + _ = ((d : ℝ≥0∞)^t*A*D^t)*ENNReal.ofReal + (Real.exp ((α+ε)*b+(ρ*((n : ℝ)*R)+max ρ 0*R)*t)) := by + rw [Real.exp_add ((α+ε)*b) ((ρ*((n : ℝ)*R)+max ρ 0*R)*t), + ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ ((d : ℝ≥0∞)^t*A*D^t)*ENNReal.ofReal (Real.exp + ((max ρ 0*R)*t+((α+ε)*k+(-s*(n : ℝ))))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by + dsimp [K,Z] + rw [Real.exp_add ((max ρ 0*R)*t) ((α+ε)*k+(-s*(n : ℝ))), + ENNReal.ofReal_mul (Real.exp_nonneg _),Real.exp_add ((α+ε)*k) (-s*(n : ℝ)), + ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + have hF := geometric_increment_factored F B K Z s h0 hstep + have hlim := restrictedLayerMoment_iUnion G + (fun n : ℕ => internalEdges G {v | f v ≤ k+(n : ℝ)*R}) + (internalEdges_ceilings_monotone G f R k hR.le) W x p hqt + rw [internalEdges_ceilings_iUnion G f R k hR] at hlim + rw [hlim] + apply (iSup_le fun n => hF n).trans + exact mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right (by linarith : α+ε ≤ α+ζ) hk))) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GeneralCriticalFiniteness.lean b/lean/OAI/Probability/BenjaminiSchramm/GeneralCriticalFiniteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..7894d1cfbdc8ac4ae1ddf16ec2a808dfe63f5215 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GeneralCriticalFiniteness.lean @@ -0,0 +1,29 @@ +import OAI.Probability.BenjaminiSchramm.CriticalFiniteness +import OAI.Probability.CriticalPercolation.Main + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem critical_finite_general [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hpc : pc G < 1) (x : V) : + ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite := by + have hz := (criticalModel G).no_percolation_at_criticality + (criticalModel_connected G hconn) hloc (criticalModel_quasiTransitive G hqt) + (by simpa only [criticalModel_pc] using hpc) + rw [criticalModel_pc,criticalModel_percolates] at hz + change law (pc G) {ω | (infiniteClusters G ω).Nonempty} = 0 at hz + rw [ae_iff] + apply measure_mono_null _ hz + intro ω hω + exact ⟨cluster G ω x,hω,x,rfl⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GeometricIncrement.lean b/lean/OAI/Probability/BenjaminiSchramm/GeometricIncrement.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea6821f2442ad5375a7281fbaeecbdafc2841eff --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GeometricIncrement.lean @@ -0,0 +1,54 @@ +import OAI.Probability.BenjaminiSchramm.UpwardFractionalSlabProfile + +namespace OAI + +noncomputable section +open scoped ENNReal BigOperators +namespace Percolation.BenjaminiSchramm + +lemma geometric_increment_factored (F : ℕ → ℝ≥0∞) (B K W : ℝ≥0∞) (s : ℝ) + (h0 : F 0 ≤ B*W) + (hstep : ∀ n, F (n+1) ≤ F n+K*W*ENNReal.ofReal (Real.exp (-s*n))) : + ∀ n, F n ≤ (B+K*(∑' i : ℕ, ENNReal.ofReal (Real.exp (-s*i))))*W := by + have hb : ∀ n, F n ≤ (B+K*∑ i ∈ Finset.range n, ENNReal.ofReal (Real.exp (-s*i)))*W := by + intro n + induction n with + | zero => simpa using h0 + | succ n ih => + calc + _ ≤ F n+K*W*ENNReal.ofReal (Real.exp (-s*n)) := hstep n + _ ≤ (B+K*∑ i ∈ Finset.range n, ENNReal.ofReal (Real.exp (-s*i)))*W+ + K*W*ENNReal.ofReal (Real.exp (-s*n)) := add_le_add ih le_rfl + _ = _ := by + rw [Finset.sum_range_succ] + simp only [mul_add,add_mul] + ac_rfl + intro n + exact (hb n).trans (mul_le_mul' (add_le_add le_rfl + (mul_le_mul' le_rfl (ENNReal.sum_le_tsum _))) le_rfl) + +lemma geometric_increment_uniform (F : ℕ → ℝ≥0∞) (B K : ℝ≥0∞) (s : ℝ) + (hs : 0 < s) (h0 : F 0 ≤ B) + (hstep : ∀ n, F (n+1) ≤ F n+K*ENNReal.ofReal (Real.exp (-s*n))) : + ∃ C : ℝ≥0∞, (B < ⊤ → K < ⊤ → C < ⊤) ∧ ∀ n, F n ≤ C := by + let S : ℝ≥0∞ := ∑' n : ℕ, ENNReal.ofReal (Real.exp (-s*n)) + have hS : S < ⊤ := by + apply Summable.tsum_ofReal_lt_top + simpa only [mul_comm] using Real.summable_exp_nat_mul_iff.mpr (neg_neg_of_pos hs) + have hfinite : ∀ n, F n ≤ B+K*∑ i ∈ Finset.range n, ENNReal.ofReal (Real.exp (-s*i)) := by + intro n + induction n with + | zero => simpa using h0 + | succ n ih => + apply (hstep n).trans + rw [Finset.sum_range_succ,mul_add,←add_assoc] + exact add_le_add ih le_rfl + refine ⟨B+K*S,fun hB hK => ENNReal.add_lt_top.mpr ⟨hB,ENNReal.mul_lt_top hK hS⟩, + fun n => (hfinite n).trans (add_le_add le_rfl (mul_le_mul' le_rfl ?_))⟩ + exact ENNReal.sum_le_tsum _ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostAvoidance.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostAvoidance.lean new file mode 100644 index 0000000000000000000000000000000000000000..9019f66b1e7f3158e42b8922af9cf952f8113d06 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostAvoidance.lean @@ -0,0 +1,116 @@ +import OAI.Probability.BenjaminiSchramm.GhostField +import OAI.Probability.BenjaminiSchramm.BlockExposure + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal + +namespace Percolation.BenjaminiSchramm +variable {V : Type*} + +lemma ghost_avoidance_exterior_factor (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) + (F : Set V → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ m, ({m | Disjoint (S : Set V) m} : Set (Set V)).indicator + (fun m => F (CriticalPercolation.BernoulliProduct.forceOn (S : Set V) ∅ m)) m + ∂ghostFieldLaw h w) = + ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ S, (w v : ℝ))) * + ∫⁻ m, F (CriticalPercolation.BernoulliProduct.forceOn (S : Set V) ∅ m) + ∂ghostFieldLaw h w := by + let A := {m : Set V | Disjoint (S : Set V) m} + have hA : MeasurableSet A := by + rw [show A = ⋂ v ∈ S, {m | v ∉ m} from by ext m; simp [A,Set.disjoint_left]] + exact S.measurableSet_biInter fun v _ => (measurable_set_mem v).setOf.compl + have hd : DependsOn (fun m => m ∈ A) (S : Set V) := by + intro m n hmn + apply propext + simp only [A, Set.disjoint_left] + exact ⟨fun hm v hv hn => hm hv ((hmn v hv).to_iff.mpr hn), + fun hn v hv hm => hn hv ((hmn v hv).to_iff.mp hm)⟩ + have hforce : DependsOn + (fun m => F (CriticalPercolation.BernoulliProduct.forceOn (S : Set V) ∅ m)) + (S : Set V)ᶜ := by + intro m n hmn + apply congrArg F + unfold CriticalPercolation.BernoulliProduct.forceOn + funext v + by_cases hv : v ∈ (S : Set V) + · simp only [ite_eq_left hv] + · simp only [ite_eq_right hv] + exact hmn v hv + have he := CriticalPercolation.BernoulliProduct.lintegral_indicator_fresh + (fun v => ghostRate h (w v)) (S : Set V) A hA hd + (fun m => F (CriticalPercolation.BernoulliProduct.forceOn (S : Set V) ∅ m)) + (hF.comp (CriticalPercolation.BernoulliProduct.measurable_forceOn _ _)) hforce + change _ = ghostFieldLaw h w A * _ at he + rw [ghostFieldLaw_avoid_finset] at he + exact he + +lemma ghost_avoidance_upper (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) + (F : Set V → ℝ≥0∞) (hF : Measurable F) (hmono : Monotone F) : + (∫⁻ m, if Disjoint (S : Set V) m then F m else 0 ∂ghostFieldLaw h w) ≤ + ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ S, (w v : ℝ))) * + ∫⁻ m, F m ∂ghostFieldLaw h w := by + have heq (m : Set V) (hm : Disjoint (S : Set V) m) : + CriticalPercolation.BernoulliProduct.forceOn (S : Set V) ∅ m = m := by + ext v + by_cases hv : v ∈ (S : Set V) + · have hvm : v ∉ m := fun h => Set.disjoint_left.mp hm hv h + simp [CriticalPercolation.BernoulliProduct.mem_forceOn,hv,hvm] + · simp [CriticalPercolation.BernoulliProduct.mem_forceOn,hv] + calc + _ = ∫⁻ m, ({m | Disjoint (S : Set V) m} : Set (Set V)).indicator + (fun m => F (CriticalPercolation.BernoulliProduct.forceOn (S : Set V) ∅ m)) m + ∂ghostFieldLaw h w := by + apply lintegral_congr + intro m + by_cases hm : Disjoint (S : Set V) m <;> simp [Set.indicator,hm,heq m] + _ = _ := ghost_avoidance_exterior_factor h w S F hF + _ ≤ _ := by + apply mul_le_mul' le_rfl + apply lintegral_mono + intro m + apply hmono + intro v hv + by_cases hvS : v ∈ (S : Set V) + · simp [CriticalPercolation.BernoulliProduct.mem_forceOn,hvS] at hv + · simpa [CriticalPercolation.BernoulliProduct.mem_forceOn,hvS] using hv + +theorem two_ghost_avoidance_upper (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) + (F : Set V × Set V → ℝ≥0∞) (hF : Measurable F) + (hmono : ∀ m m', m ⊆ m' → ∀ n n', n ⊆ n' → F (m,n) ≤ F (m',n')) : + (∫⁻ m, ∫⁻ n, if Disjoint (S : Set V) m ∧ Disjoint (S : Set V) n + then F (m,n) else 0 ∂ghostFieldLaw h w ∂ghostFieldLaw h w) ≤ + ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ S, (w v : ℝ))) ^ 2 * + ∫⁻ m, ∫⁻ n, F (m,n) ∂ghostFieldLaw h w ∂ghostFieldLaw h w := by + let c := ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ S, (w v : ℝ))) + let H := fun m => ∫⁻ n, F (m,n) ∂ghostFieldLaw h w + have hH : Measurable H := hF.lintegral_prod_right' + have hHm : Monotone H := by + intro m m' hmm + exact lintegral_mono fun n => hmono m m' hmm n n le_rfl + calc + _ ≤ ∫⁻ m, if Disjoint (S : Set V) m then c * H m else 0 ∂ghostFieldLaw h w := by + apply lintegral_mono + intro m + by_cases hm : Disjoint (S : Set V) m + · simp only [hm, true_and, ite_true] + exact ghost_avoidance_upper h w S (fun n => F (m,n)) + (hF.comp (measurable_const.prodMk measurable_id)) + (fun n n' hnn => hmono m m le_rfl n n' hnn) + · simp only [hm, false_and, ite_false, lintegral_zero, le_refl] + _ = c * ∫⁻ m, if Disjoint (S : Set V) m then H m else 0 ∂ghostFieldLaw h w := by + have heq (m : Set V) : (if Disjoint (S : Set V) m then c * H m else 0) = + c * (if Disjoint (S : Set V) m then H m else 0) := by split_ifs <;> simp + simp_rw [heq] + exact lintegral_const_mul' _ _ ENNReal.ofReal_ne_top + _ ≤ c * (c * ∫⁻ m, H m ∂ghostFieldLaw h w) := + mul_le_mul' le_rfl (ghost_avoidance_upper h w S H hH hHm) + _ = _ := by rw [← mul_assoc, sq] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostBondBK.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostBondBK.lean new file mode 100644 index 0000000000000000000000000000000000000000..a028668edac4548d0f7165d73d9eab1294b05a93 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostBondBK.lean @@ -0,0 +1,114 @@ +import OAI.Probability.BenjaminiSchramm.GhostField +import OAI.Probability.BenjaminiSchramm.PeakComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical + +namespace Percolation.BenjaminiSchramm + +variable {V E T : Type*} (G : BondGraph V E) (x : V) (vertex : T → V) + +def finiteGhostConnection (m : Set T) : Set (Set E) := + {ω | ∃ i ∈ m, Conn G ω x (vertex i)} + +lemma finiteGhostConnection_upper (m : Set T) : IsUpperSet (finiteGhostConnection G x vertex m) := by + rintro ω η hωη ⟨i,hi,hc⟩ + exact ⟨i,hi,conn_mono G hωη hc⟩ + +lemma finiteGhostConnection_finiteWitness (m : Set T) : + FiniteWitness (finiteGhostConnection G x vertex m) := by + rintro ω ⟨i,hi,hc⟩ + obtain ⟨s,hs,hconn⟩ := finiteWitness_conn G x (vertex i) ω hc + exact ⟨s,hs,i,hi,hconn⟩ + +theorem finiteGhostConnection_bk [Countable E] (p : unitInterval) (m n : Set T) : + (law p).real (DisjointOccurrence (finiteGhostConnection G x vertex m) + (finiteGhostConnection G x vertex n)) ≤ + (law p).real (finiteGhostConnection G x vertex m) * + (law p).real (finiteGhostConnection G x vertex n) := + bk p _ _ (finiteGhostConnection_upper G x vertex m) (finiteGhostConnection_upper G x vertex n) + (finiteGhostConnection_finiteWitness G x vertex m) (finiteGhostConnection_finiteWitness G x vertex n) + +theorem averaged_finiteGhostConnection_bk [Fintype T] [Countable E] + (p : unitInterval) (ν : Measure (Set T)) [IsProbabilityMeasure ν] : + (∫ m, ∫ n, (law p).real (DisjointOccurrence (finiteGhostConnection G x vertex m) + (finiteGhostConnection G x vertex n)) ∂ν ∂ν) ≤ + (∫ m, (law p).real (finiteGhostConnection G x vertex m) ∂ν) ^ 2 := by + calc + _ ≤ ∫ m, ∫ n, (law p).real (finiteGhostConnection G x vertex m) * + (law p).real (finiteGhostConnection G x vertex n) ∂ν ∂ν := by + apply integral_mono Integrable.of_finite Integrable.of_finite + intro m + exact integral_mono Integrable.of_finite Integrable.of_finite + (fun n => finiteGhostConnection_bk G x vertex p m n) + _ = _ := by + simp_rw [integral_const_mul] + rw [integral_mul_const, sq] + +lemma measurable_finiteGhostConnection_measure [Countable V] [Countable T] [Countable E] + (p : unitInterval) : Measurable (fun m => law p (finiteGhostConnection G x vertex m)) := by + have hm : MeasurableSet {z : Set T × Set E | ∃ i ∈ z.1, Conn G z.2 x (vertex i)} := by + have heq : {z : Set T × Set E | ∃ i ∈ z.1, Conn G z.2 x (vertex i)} = + ⋃ i : T, {z : Set T × Set E | i ∈ z.1} ∩ {z | Conn G z.2 x (vertex i)} := by + ext z + simp + rw [heq] + exact MeasurableSet.iUnion fun i => + (((measurable_set_mem i).comp measurable_fst).setOf).inter + ((measurableSet_conn G x (vertex i)).preimage measurable_snd) + exact measurable_measure_prodMk_left (ν := law p) hm + +theorem averaged_ghostConnection_bk [Countable V] [Countable T] [Countable E] + (p : unitInterval) (ν : Measure (Set T)) : + (∫⁻ m, ∫⁻ n, law p (DisjointOccurrence (finiteGhostConnection G x vertex m) + (finiteGhostConnection G x vertex n)) ∂ν ∂ν) ≤ + (∫⁻ m, law p (finiteGhostConnection G x vertex m) ∂ν) ^ 2 := by + have hm := measurable_finiteGhostConnection_measure G x vertex p + calc + _ ≤ ∫⁻ m, ∫⁻ n, law p (finiteGhostConnection G x vertex m) * + law p (finiteGhostConnection G x vertex n) ∂ν ∂ν := by + apply lintegral_mono + intro m + apply lintegral_mono + intro n + exact bk_ennreal p _ _ + (finiteGhostConnection_upper G x vertex m) (finiteGhostConnection_upper G x vertex n) + (finiteGhostConnection_finiteWitness G x vertex m) + (finiteGhostConnection_finiteWitness G x vertex n) + _ = _ := by + simp_rw [lintegral_const_mul _ hm] + rw [lintegral_mul_const _ hm, sq] + +lemma measurableSet_ghostDisjointOccurrence [Countable T] [Countable E] : + MeasurableSet {z : (Set T × Set T) × Set E | + z.2 ∈ DisjointOccurrence (finiteGhostConnection G x vertex z.1.1) + (finiteGhostConnection G x vertex z.1.2)} := by + have hsub (s : Finset E) : + Measurable (fun z : (Set T × Set T) × Set E => (s : Set E) ⊆ z.2) := by + exact Measurable.forall fun e => + measurable_const.imp ((measurable_set_mem e).comp measurable_snd) + have hc (s : Finset E) (j : Fin 2) : + Measurable (fun z : (Set T × Set T) × Set E => + ∃ i ∈ (if j = 0 then z.1.1 else z.1.2), Conn G (s : Set E) x (vertex i)) := by + apply Measurable.exists + intro i + by_cases hj : j = 0 + · simpa only [ite_eq_left hj, Function.comp_def] using + (((measurable_set_mem i).comp (measurable_fst.comp measurable_fst)).and + (measurable_const : Measurable (fun _ : (Set T × Set T) × Set E => + Conn G (s : Set E) x (vertex i)))) + · simpa only [ite_eq_right hj, Function.comp_def] using + (((measurable_set_mem i).comp (measurable_snd.comp measurable_fst)).and + (measurable_const : Measurable (fun _ : (Set T × Set T) × Set E => + Conn G (s : Set E) x (vertex i)))) + exact (Measurable.exists fun s : Finset E => Measurable.exists fun t : Finset E => + (hsub s).and ((hsub t).and (measurable_const.and ((hc s 0).and (hc t 1))))).setOf + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostCluster.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostCluster.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f2a36e1d1afcaa7fcc78151f876535e5e129ac7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostCluster.lean @@ -0,0 +1,137 @@ +import OAI.Probability.BenjaminiSchramm.GhostField +import OAI.Probability.BenjaminiSchramm.TiltedGhostSusceptibility + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm + +variable {V E : Type*} (G : BondGraph V E) + +def quarterGhostWeight (x y : V) : ℝ≥0 := + (G.stabilizerWeight x y ^ (1 / 4 : ℝ)).toNNReal + +lemma coe_quarterGhostWeight (x y : V) : + (G.quarterGhostWeight x y : ℝ≥0∞) = G.stabilizerWeight x y ^ (1 / 4 : ℝ) := by + exact ENNReal.coe_toNNReal (ENNReal.rpow_ne_top_of_nonneg (by norm_num) + (G.stabilizerWeight_ne_top x y)) + +lemma quarterGhostWeight_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (x v y : V) : G.quarterGhostWeight x y = + G.quarterGhostWeight x v * G.quarterGhostWeight v y := by + apply ENNReal.coe_injective + rw [ENNReal.coe_mul, G.coe_quarterGhostWeight, G.coe_quarterGhostWeight, + G.coe_quarterGhostWeight, G.stabilizerWeight_change_base hc hl x v y, + ENNReal.mul_rpow_of_nonneg _ _ (by norm_num)] + +lemma quarterGhostField_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (h : ℝ≥0) (x v : V) : + ghostFieldLaw h (G.quarterGhostWeight x) = + ghostFieldLaw (h * G.quarterGhostWeight x v) (G.quarterGhostWeight v) := by + unfold ghostFieldLaw + congr 1 + funext y + apply Subtype.ext + simp only [ghostRate, ghostKernel, NNReal.coe_mul, G.quarterGhostWeight_change_base hc hl x v y] + congr 2 + ring + +lemma quarterTiltedMass_finite_sum {ω : Set E} {x : V} (hfin : (G.cluster ω x).Finite) : + G.quarterTiltedMass ω x = + ∑ y ∈ hfin.toFinset, (G.quarterGhostWeight x y : ℝ≥0∞) := by + unfold quarterTiltedMass + rw [tsum_eq_sum (s := hfin.toFinset)] + · apply Finset.sum_congr rfl + intro y hy + have hr : (G.openGraph ω).Reachable x y := hfin.mem_toFinset.mp hy + rw [ite_eq_left hr, G.coe_quarterGhostWeight] + · intro y hy + exact ite_eq_right (fun hr => hy (hfin.mem_toFinset.mpr hr)) + +lemma quarterTiltedMass_toReal_finite_sum {ω : Set E} {x : V} + (hfin : (G.cluster ω x).Finite) : + (G.quarterTiltedMass ω x).toReal = + ∑ y ∈ hfin.toFinset, (G.quarterGhostWeight x y : ℝ) := by + rw [G.quarterTiltedMass_finite_sum hfin, ENNReal.toReal_sum] + · apply Finset.sum_congr rfl + intro y _ + exact ENNReal.coe_toReal _ + · intro y _ + exact ENNReal.coe_ne_top + +lemma ghost_hit_cluster_joint_measurable [Countable V] [Countable E] (x : V) : + MeasurableSet {z : Set E × Set V | ∃ y, (G.openGraph z.1).Reachable x y ∧ y ∈ z.2} := by + exact (Measurable.exists fun y => + ((G.measurable_reachable x y).comp measurable_fst).and + ((measurable_set_mem y).comp measurable_snd)).setOf + +theorem quarterGhostField_hit_cluster [Countable V] (h : ℝ≥0) {ω : Set E} {x : V} + (hfin : (G.cluster ω x).Finite) : + (ghostFieldLaw h (G.quarterGhostWeight x)).real (ghostHits (G.cluster ω x)) = + ghostKernel h (G.quarterTiltedMass ω x).toReal := by + rw [G.quarterTiltedMass_toReal_finite_sum hfin] + convert ghostFieldLaw_real_hit_finset h (G.quarterGhostWeight x) hfin.toFinset using 1 + rw [hfin.coe_toFinset] + +theorem quarterTwoGhostField_hit_cluster [Countable V] (h : ℝ≥0) {ω : Set E} {x : V} + (hfin : (G.cluster ω x).Finite) : + ((ghostFieldLaw h (G.quarterGhostWeight x)).prod + (ghostFieldLaw h (G.quarterGhostWeight x))).real + (ghostHits (G.cluster ω x) ×ˢ ghostHits (G.cluster ω x)) = + ghostKernel h (G.quarterTiltedMass ω x).toReal ^ 2 := by + rw [G.quarterTiltedMass_toReal_finite_sum hfin] + convert twoGhostFieldLaw_real_hit_finset h (G.quarterGhostWeight x) hfin.toFinset using 1 + rw [hfin.coe_toFinset] + +theorem quarterGhostConnection_average [Countable V] [Countable E] + (p : unitInterval) (x : V) (h : ℝ≥0) + (hfin : ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) : + (∫⁻ m, G.law p {ω | ∃ y ∈ m, (G.openGraph ω).Reachable x y} + ∂ghostFieldLaw h (G.quarterGhostWeight x)) = + ENNReal.ofReal (G.quarterGhostMagnetization p x h) := by + let ν := ghostFieldLaw h (G.quarterGhostWeight x) + let A := {z : Set E × Set V | ∃ y, (G.openGraph z.1).Reachable x y ∧ y ∈ z.2} + have hm : MeasurableSet A := G.ghost_hit_cluster_joint_measurable x + have he := (Measure.prod_apply (μ := G.law p) (ν := ν) hm).symm.trans + (Measure.prod_apply_symm (μ := G.law p) (ν := ν) hm) + have hswap : (∫⁻ m, G.law p {ω | ∃ y ∈ m, (G.openGraph ω).Reachable x y} ∂ν) = + ∫⁻ ω, ν (ghostHits (G.cluster ω x)) ∂G.law p := by + convert he.symm using 1 + · apply lintegral_congr + intro m + congr 1 + ext ω + simp only [A, Set.mem_preimage, Set.mem_ofPred_eq] + exact exists_congr (fun y => and_comm) + · rfl + rw [hswap] + have hprob : (fun ω => ν (ghostHits (G.cluster ω x))) =ᵐ[G.law p] + (fun ω => ENNReal.ofReal (ghostKernel h (G.quarterTiltedMass ω x).toReal)) := by + filter_upwards [hfin] with ω hω + rw [← ENNReal.ofReal_toReal (measure_ne_top _ _)] + exact congrArg ENNReal.ofReal (G.quarterGhostField_hit_cluster h hω) + rw [lintegral_congr_ae hprob] + exact (ofReal_integral_eq_lintegral_ofReal + (integrable_ghostKernel (G.law p) _ (G.measurable_quarterTiltedMass x).ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) h.2) + (ae_of_all _ fun _ => ghostKernel_nonneg h.2 ENNReal.toReal_nonneg)).symm + +theorem quarterGhostConnection_change_base [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (p : unitInterval) (x v : V) (h : ℝ≥0) + (hfin : ∀ᵐ ω ∂G.law p, (G.cluster ω v).Finite) : + (∫⁻ m, G.law p {ω | ∃ y ∈ m, (G.openGraph ω).Reachable v y} + ∂ghostFieldLaw h (G.quarterGhostWeight x)) = + ENNReal.ofReal (G.quarterGhostMagnetization p v (h * G.quarterGhostWeight x v)) := by + rw [G.quarterGhostField_change_base hc hl h x v] + exact G.quarterGhostConnection_average p v _ hfin + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostCritical.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostCritical.lean new file mode 100644 index 0000000000000000000000000000000000000000..73623a78832cd901039486802278e02cbb88504c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostCritical.lean @@ -0,0 +1,77 @@ +import OAI.Probability.BenjaminiSchramm.GhostVolume + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem volume_probability_aut [Countable E] (G : BondGraph V E) (p : unitInterval) + {a : V ≃ V} {b : E ≃ E} (hab : IsAut G a b) (x : V) (n : ℕ) : + law p (volumeEvent G (a x) n) = law p (volumeEvent G x n) := by + have he : volumeEvent G (a x) n = + (fun ω => b ⁻¹' ω) ⁻¹' volumeEvent G x n := by + ext ω + change (n : ℕ∞) ≤ (cluster G ω (a x)).encard ↔ + (n : ℕ∞) ≤ (cluster G (b ⁻¹' ω) x).encard + rw [←cluster_aut G hab,a.injective.encard_image] + rw [he,←Measure.map_apply (measurable_set_preimage b) + (measurableSet_volumeEvent G x n),law_map_preimage_equiv] + +theorem uniform_critical_volume_upper [Countable E] + (G : BondGraph V E) (hqt : QuasiTransitive G) + (hvol : ∀ x, ∃ C : ℝ, 0 < C ∧ ∀ n : ℕ, 0 < n → + criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n) : + ∃ C : ℝ, 0 < C ∧ ∀ x n, 0 < n → + criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n := by + obtain ⟨O,hO⟩ := hqt + choose c hc hb using hvol + let C := 1 + ∑ o ∈ O, c o + have hC : 0 < C := by + have hs := Finset.sum_nonneg (s := O) (fun o _ => (hc o).le) + dsimp [C] + linarith + refine ⟨C,hC,?_⟩ + intro x n hn + obtain ⟨o,ho,a,b,hab,rfl⟩ := hO x + have he : criticalTail G (volumeEvent G) (a o) n = + criticalTail G (volumeEvent G) o n := by + unfold criticalTail + rw [volume_probability_aut G (pc G) hab] + rw [he] + apply (hb o n hn).trans + apply div_le_div_of_nonneg_right _ (Real.sqrt_nonneg _) + have hs := Finset.single_le_sum (s := O) (fun z _ => (hc z).le) ho + dsimp [C] + linarith + +theorem uniform_critical_volume_upper_of_powerTail [Countable E] + (G : BondGraph V E) (hqt : QuasiTransitive G) + (hvol : ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + ∃ C : ℝ, 0 < C ∧ ∀ x n, 0 < n → + criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n := by + apply uniform_critical_volume_upper G hqt + intro x + obtain ⟨c,C,_hc,hC,hb⟩ := hvol x + refine ⟨C,hC,?_⟩ + intro n hn + have hh := (hb n hn).2 + rw [Real.rpow_neg (Nat.cast_nonneg n),←Real.sqrt_eq_rpow] at hh + simpa only [div_eq_mul_inv] using hh + +theorem critical_ghost_bound_at_square_scale [Countable E] + (G : BondGraph V E) (C : ℝ) (hC : 0 ≤ C) + (hvol : ∀ x n, 0 < n → criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n) + (Q : Finset E) (x : V) (p h : unitInterval) (hp : p ≤ pc G) + (m : ℕ) (hm : 0 < m) (hh : (h : ℝ) * (m : ℝ) ^ 2 ≤ 1) : + markedConnectionPolynomial G Q x h p ≤ 3 * C / m := by + exact markedConnection_le_sqrt_scale G Q x p h m hm C hC hh + (fun n hn => (finiteClusterTail_le_criticalTail G Q x n p hp).trans (hvol x n hn)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostDerivative.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe23cd2d6b622aa856e194818c8390c788c91275 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostDerivative.lean @@ -0,0 +1,43 @@ +import OAI.Probability.BenjaminiSchramm.GhostTiltedTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma ghostAvoid_mul_mass (h : ℝ) (m : ℝ≥0∞) : + ghostAvoid h m * m = ENNReal.ofReal (m.toReal * Real.exp (-h * m.toReal)) := by + by_cases hm : m = ⊤ + · simp [ghostAvoid,hm] + · rw [ghostAvoid,ite_eq_right hm,← ENNReal.ofReal_toReal hm, + ← ENNReal.ofReal_mul (Real.exp_pos _).le] + congr 1 + simp only [ENNReal.toReal_ofReal ENNReal.toReal_nonneg] + ring + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma lintegral_ghostAvoid_mass_eq_derivative (p : unitInterval) (x : V) + {h : ℝ} (hh : 0 < h) : + (∫⁻ ω, ghostAvoid h (G.quarterTiltedMass ω x) * G.quarterTiltedMass ω x ∂G.law p) = + ENNReal.ofReal (G.quarterGhostDerivative p x h) := by + unfold quarterGhostDerivative ghostMagnetizationDerivative + have hI := (hasDerivAt_ghostMagnetization (G.law p) + (fun ω => (G.quarterTiltedMass ω x).toReal) + (G.measurable_quarterTiltedMass x).ennreal_toReal (fun _ => ENNReal.toReal_nonneg) hh).1 + rw [ofReal_integral_eq_lintegral_ofReal hI + (ae_of_all _ fun ω => mul_nonneg ENNReal.toReal_nonneg (Real.exp_pos _).le)] + exact lintegral_congr (fun ω => ghostAvoid_mul_mass h (G.quarterTiltedMass ω x)) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostDifferentialAssembly.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostDifferentialAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..44ad6049b3372dd474eeb1977cff0032c44d4a38 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostDifferentialAssembly.lean @@ -0,0 +1,131 @@ +import OAI.Probability.BenjaminiSchramm.GhostPivotalBoundary +import OAI.Probability.BenjaminiSchramm.RootGhostSums + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem quarter_twoGhost_le_square_add_boundary + (hinj : Function.Injective G) + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (K : ℝ) (hbound : ∀ x h, 0 ≤ h → + (criticalModel G).quarterGhostMagnetization p x h ≤ K*h^(3/4 : ℝ)) + (x : V) (h : ℝ≥0) : + ENNReal.ofReal (∫ ω, ghostKernel h ((criticalModel G).quarterTiltedMass ω x).toReal ^ 2 ∂law p) ≤ + ENNReal.ofReal ((criticalModel G).quarterGhostMagnetization p x h)^2 + + (2*(ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ)))* + ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ))) * + ∫⁻ ω, ghostAvoid (2*(h : ℝ)) ((criticalModel G).quarterTiltedMass ω x) * + (∑' e, if e ∈ (criticalModel G).incidentEdges (cluster G ω x) then + (criticalModel G).ghostBondWeight x e else 0) ∂law p := by + let H := criticalModel G + have hf : ∀ᵐ ω ∂H.law p, (H.cluster ω x).Finite := by + change ∀ᵐ ω ∂law p, (H.cluster ω x).Finite + simpa only [H,criticalModel_cluster] using hfin x + have hb := averaged_twoGhost_le_fan_add_pivotal_sum G hinj p x (hfin x) + (ghostFieldLaw h (H.quarterGhostWeight x)) + have htwo := H.quarterTwoGhostConnection_average p x h hf + have hone := H.quarterGhostConnection_average p x h hf + change (∫⁻ m, ∫⁻ n, law p + ({ω | ∃ y ∈ m, (H.openGraph ω).Reachable x y} ∩ + {ω | ∃ y ∈ n, (H.openGraph ω).Reachable x y}) + ∂ghostFieldLaw h (H.quarterGhostWeight x) ∂ghostFieldLaw h (H.quarterGhostWeight x)) = + ENNReal.ofReal (∫ ω, ghostKernel h (H.quarterTiltedMass ω x).toReal^2 ∂law p) at htwo + change (∫⁻ m, law p {ω | ∃ y ∈ m, (H.openGraph ω).Reachable x y} + ∂ghostFieldLaw h (H.quarterGhostWeight x)) = ENNReal.ofReal (H.quarterGhostMagnetization p x h) at hone + simp_rw [criticalModel_finiteGhostConnection G] at hb + rw [htwo,hone] at hb + exact hb.trans (add_le_add le_rfl + (averagedQuarterBridge_sum_le_boundary G hc hl p hp hfin K hbound x h)) + +theorem root_twoGhost_bound + (hinj : Function.Injective G) + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (hq : (criticalModel G).QuasiTransitive) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (K : ℝ) (hbound : ∀ x h, 0 ≤ h → + (criticalModel G).quarterGhostMagnetization p x h ≤ K*h^(3/4 : ℝ)) + (D B : ℕ) (hD : ∀ v, ((criticalModel G).incidentEdges {v}).ncard ≤ D) + (hB : ∀ v, ((criticalModel G).vertexBall v 1).ncard ≤ B) : + ∃ A : ℝ, 0 ≤ A ∧ ∀ h : ℝ≥0, 0 < h → + (∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + ∫ ω, ghostKernel h ((criticalModel G).quarterTiltedMass ω x).toReal ^ 2 ∂law p) ≤ + (∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterGhostMagnetization p x h)^2 + + A*(h : ℝ)^(3/2 : ℝ) * + (∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterGhostDerivative p x (2*h)) := by + let H := criticalModel G + let O := (H.orbitRepresentatives hq).roots + let R := ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ)) + let J : ℝ≥0∞ := (2*R*ENNReal.ofReal (K^2)) * ((D : ℝ≥0∞)*(2*(B : ℝ≥0∞)^(3/8 : ℝ))) * 2 + have hR : R ≠ ⊤ := by + dsimp [R] + apply ENNReal.div_ne_top ENNReal.ofReal_ne_top + exact (ENNReal.ofReal_pos.mpr (sub_pos.mpr hp)).ne' + have hJ : J ≠ ⊤ := by + dsimp [J] + finiteness + refine ⟨J.toReal,ENNReal.toReal_nonneg,?_⟩ + intro h hh + have hh0 : (0 : ℝ) < h := hh + have h2 : (0 : ℝ) < 2*h := by positivity + let M := ∑ x ∈ O, H.quarterGhostMagnetization p x h + let Derv := ∑ x ∈ O, H.quarterGhostDerivative p x (2*h) + have hM (x : V) : 0 ≤ H.quarterGhostMagnetization p x h := + integral_nonneg fun _ => ghostKernel_nonneg h.2 ENNReal.toReal_nonneg + have hDerv (x : V) : 0 ≤ H.quarterGhostDerivative p x (2*h) := + integral_nonneg fun _ => mul_nonneg ENNReal.toReal_nonneg (Real.exp_pos _).le + have hpow : ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ)) = + ENNReal.ofReal (K^2) * ENNReal.ofReal ((h : ℝ)^(3/2 : ℝ)) := + ENNReal.ofReal_mul (sq_nonneg K) + have htransport := H.expected_ghost_boundary_weight_le hc hl hq p (by positivity : (0 : ℝ) ≤ 2*h) + D B hD hB + have hderiv : (∑ x ∈ O, ∫⁻ ω, ghostAvoid (2*(h : ℝ)) (H.quarterTiltedMass ω x)*H.quarterTiltedMass ω x ∂H.law p) = + ENNReal.ofReal Derv := by + simp_rw [H.lintegral_ghostAvoid_mass_eq_derivative p _ h2] + exact (ENNReal.ofReal_sum_of_nonneg (fun x _ => hDerv x)).symm + have hsq : (∑ x ∈ O, ENNReal.ofReal (H.quarterGhostMagnetization p x h)^2) ≤ ENNReal.ofReal (M^2) := by + simp_rw [←ENNReal.ofReal_pow (hM _)] + rw [←ENNReal.ofReal_sum_of_nonneg (fun x _ => sq_nonneg (H.quarterGhostMagnetization p x h))] + exact ENNReal.ofReal_le_ofReal (Finset.sum_sq_le_sq_sum_of_nonneg (fun x _ => hM x)) + have hfinal : (∑ x ∈ O, ENNReal.ofReal (∫ ω, ghostKernel h (H.quarterTiltedMass ω x).toReal^2 ∂law p)) ≤ + ENNReal.ofReal (M^2) + J*ENNReal.ofReal ((h : ℝ)^(3/2 : ℝ))*ENNReal.ofReal Derv := by + calc + _ ≤ (∑ x ∈ O, ENNReal.ofReal (H.quarterGhostMagnetization p x h)^2) + + (2*R*ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ))) * + ∑ x ∈ O, ∫⁻ ω, ghostAvoid (2*(h : ℝ)) (H.quarterTiltedMass ω x)* + (∑' e, if e ∈ H.incidentEdges (cluster G ω x) then H.ghostBondWeight x e else 0) ∂law p := by + rw [Finset.mul_sum,←Finset.sum_add_distrib] + exact Finset.sum_le_sum fun x _ => quarter_twoGhost_le_square_add_boundary G hinj hc hl p hp hfin K hbound x h + _ ≤ ENNReal.ofReal (M^2) + (2*R*ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ))) * + (((D : ℝ≥0∞)*(2*(B : ℝ≥0∞)^(3/8 : ℝ)))*(2*ENNReal.ofReal Derv)) := by + apply add_le_add hsq + apply mul_le_mul' le_rfl + have htrans := htransport + change (∑ x ∈ O, ∫⁻ ω, ghostAvoid (2*(h:ℝ)) (H.quarterTiltedMass ω x)* + (∑' e, if e ∈ H.incidentEdges (H.cluster ω x) then H.ghostBondWeight x e else 0) ∂law p) ≤ _ at htrans + rw [hderiv] at htrans + simpa only [H,criticalModel_cluster] using htrans + _ = _ := by rw [hpow]; dsimp [J]; ac_rfl + have hreal := ENNReal.toReal_mono (by finiteness) hfinal + rw [ENNReal.toReal_sum (fun _ _ => ENNReal.ofReal_ne_top),ENNReal.toReal_add (by finiteness) (by finiteness), + ENNReal.toReal_ofReal (sq_nonneg M),ENNReal.toReal_mul,ENNReal.toReal_mul] at hreal + have hpnonneg : 0 ≤ (h : ℝ)^(3/2 : ℝ) := Real.rpow_nonneg h.2 _ + have hdnonneg : 0 ≤ Derv := Finset.sum_nonneg (fun x _ => hDerv x) + rw [ENNReal.toReal_ofReal hpnonneg,ENNReal.toReal_ofReal hdnonneg] at hreal + simpa only [ENNReal.toReal_ofReal (integral_nonneg (fun _ => sq_nonneg _))] using hreal + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostDoubleConnection.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostDoubleConnection.lean new file mode 100644 index 0000000000000000000000000000000000000000..c64bf4a98bae45f5486c028a7579a11cc9252b3d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostDoubleConnection.lean @@ -0,0 +1,77 @@ +import OAI.Probability.BenjaminiSchramm.GhostCluster + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem quarterTwoGhostConnection_average (p : unitInterval) (x : V) (h : ℝ≥0) + (hfin : ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) : + (∫⁻ m, ∫⁻ n, G.law p {ω | + (∃ y ∈ m, (G.openGraph ω).Reachable x y) ∧ + (∃ y ∈ n, (G.openGraph ω).Reachable x y)} + ∂ghostFieldLaw h (G.quarterGhostWeight x) + ∂ghostFieldLaw h (G.quarterGhostWeight x)) = + ENNReal.ofReal (∫ ω, ghostKernel h (G.quarterTiltedMass ω x).toReal ^ 2 ∂G.law p) := by + let ν := ghostFieldLaw h (G.quarterGhostWeight x) + let A := {z : Set E × (Set V × Set V) | + (∃ y, (G.openGraph z.1).Reachable x y ∧ y ∈ z.2.1) ∧ + (∃ y, (G.openGraph z.1).Reachable x y ∧ y ∈ z.2.2)} + have hm : MeasurableSet A := by + have h₁ : Measurable (fun z : Set E × (Set V × Set V) => + ∃ y, (G.openGraph z.1).Reachable x y ∧ y ∈ z.2.1) := + Measurable.exists fun y => ((G.measurable_reachable x y).comp measurable_fst).and + ((measurable_set_mem y).comp (measurable_fst.comp measurable_snd)) + have h₂ : Measurable (fun z : Set E × (Set V × Set V) => + ∃ y, (G.openGraph z.1).Reachable x y ∧ y ∈ z.2.2) := + Measurable.exists fun y => ((G.measurable_reachable x y).comp measurable_fst).and + ((measurable_set_mem y).comp (measurable_snd.comp measurable_snd)) + exact (h₁.and h₂).setOf + have hswap := (Measure.prod_apply (μ := G.law p) (ν := ν.prod ν) hm).symm.trans + (Measure.prod_apply_symm (μ := G.law p) (ν := ν.prod ν) hm) + have hmeas : Measurable (fun z : Set V × Set V => G.law p ((fun ω : Set E => (ω,z)) ⁻¹' A)) := + measurable_measure_prodMk_right hm + have hmeas' : Measurable (fun z : Set V × Set V => G.law p {ω | + (∃ y ∈ z.1, (G.openGraph ω).Reachable x y) ∧ + (∃ y ∈ z.2, (G.openGraph ω).Reachable x y)}) := by + convert hmeas using 1 + funext z + congr 1 + ext ω + simp only [A, Set.mem_preimage, Set.mem_ofPred_eq] + exact and_congr (exists_congr fun y => and_comm) (exists_congr fun y => and_comm) + have he : (∫⁻ m, ∫⁻ n, G.law p {ω | + (∃ y ∈ m, (G.openGraph ω).Reachable x y) ∧ + (∃ y ∈ n, (G.openGraph ω).Reachable x y)} ∂ν ∂ν) = + ∫⁻ ω, (ν.prod ν) (ghostHits (G.cluster ω x) ×ˢ ghostHits (G.cluster ω x)) ∂G.law p := by + rw [← lintegral_prod _ hmeas'.aemeasurable] + convert hswap.symm using 1 + · apply lintegral_congr + intro z + congr 1 + ext ω + simp only [A, Set.mem_preimage, Set.mem_ofPred_eq] + exact and_congr (exists_congr fun y => and_comm) (exists_congr fun y => and_comm) + · rfl + rw [he] + have hprob : (fun ω => (ν.prod ν) (ghostHits (G.cluster ω x) ×ˢ ghostHits (G.cluster ω x))) + =ᵐ[G.law p] (fun ω => ENNReal.ofReal (ghostKernel h (G.quarterTiltedMass ω x).toReal ^ 2)) := by + filter_upwards [hfin] with ω hω + rw [← ENNReal.ofReal_toReal (measure_ne_top _ _)] + exact congrArg ENNReal.ofReal (G.quarterTwoGhostField_hit_cluster h hω) + rw [lintegral_congr_ae hprob] + exact (ofReal_integral_eq_lintegral_ofReal + (integrable_ghostKernel_sq (G.law p) _ (G.measurable_quarterTiltedMass x).ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) h.2) + (ae_of_all _ fun _ => sq_nonneg _)).symm + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostEntropy.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..d096867ddc513f440d396b6335031439936d6da9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostEntropy.lean @@ -0,0 +1,127 @@ +import OAI.Probability.BenjaminiSchramm.ProbeEntropy +import OAI.Probability.BenjaminiSchramm.ProbabilityLower + +namespace OAI + +open MeasureTheory Filter +open scoped Topology ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem markedConnection_entropy_comparison + (G : BondGraph V E) (Q : Finset E) (x : V) (p q h : unitInterval) + (hp : (p : ℝ) ∈ Set.Ioo 0 1) (hq : (q : ℝ) ∈ Set.Ioo 0 1) + (hh : (h : ℝ) ∈ Set.Ioo 0 1) (d : ℕ) + (hdeg : ∀ v, (Q.filter (fun e => v ∈ G e)).card ≤ d) : + markedConnectionPolynomial G Q x h q ≤ + (2 + 2 * (d : ℝ) * ((p : ℝ) - q) ^ 2 / ((q : ℝ) * (1-q) * h)) * + markedConnectionPolynomial G Q x h p := by + let t := (markedClusterTree G Q x).forget + have ht : ProbeTree.IsMarkSearch t := .mark (clusterSearch_markSearch G _ _ _) + have hcost : ∀ l, ProbeTree.queries t l ≤ d * ProbeTree.marks t l := by + simpa only [ProbeTree.Budget,zero_add] using markedClusterTree_budget G Q x d hdeg + have hb := ProbeEntropy.successMass_transfer p q h hp hq hh t + have hc := ProbeEntropy.totalQueries_le p h ht d hcost hh.1 + have hk := CriticalPercolation.FiniteEntropy.binaryDivergence_upper hq p.2 + have hkn : 0 ≤ CriticalPercolation.FiniteEntropy.binaryDivergence p q := by + have hl := CriticalPercolation.FiniteEntropy.binaryDivergence_lower hq p.2 + nlinarith [sq_nonneg ((p : ℝ) - q)] + have hm := mul_le_mul_of_nonneg_left hc (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) hkn) + have hn : 0 ≤ (d : ℝ) * ProbeTree.successMass p h t / h := by + exact div_nonneg (mul_nonneg (Nat.cast_nonneg _) (ProbeTree.successMass_nonneg p h t)) hh.1.le + have hk' := mul_le_mul_of_nonneg_right hk hn + have hbound := hb.trans (add_le_add_right (hm.trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hk' (by norm_num : (0 : ℝ) ≤ 2))) _) + rw [markedConnectionPolynomial_eq_tree,markedConnectionPolynomial_eq_tree] + apply hbound.trans_eq + field_simp [hh.1.ne',hq.1.ne',(sub_pos.mpr hq.2).ne'] + ring + +theorem finiteClusterTail_eq_restricted_volume [Countable E] + (G : BondGraph V E) (Q : Finset E) (x : V) (n : ℕ) (p : unitInterval) : + finiteClusterTail G Q x n p = + (law p).real {ω | ω ∩ (Q : Set E) ∈ volumeEvent G x n} := by + let f (ω : Set E) : ℝ := if n ≤ (cluster G (ω ∩ (Q : Set E)) x).ncard then 1 else 0 + have hf : ∀ ω, f ω = f (ω ∩ (Q : Set E)) := by + intro ω + simp only [f,Set.inter_assoc,Set.inter_self] + have he : (∫ ω, f ω ∂law p) = finiteClusterTail G Q x n p := by + rw [integral_eq_bernoulliPolynomial Q p f hf] + apply bernoulliPolynomial_congr + intro ω hω + simp only [f,finiteClusterTailIndicator, + Set.inter_eq_left.mpr (show (ω : Set E) ⊆ Q from hω), + ←coe_finiteRootComponent,Set.ncard_coe_finset] + rw [←he] + have hset : MeasurableSet {ω : Set E | ω ∩ (Q : Set E) ∈ volumeEvent G x n} := by + exact (measurableSet_volumeEvent G x n).preimage (measurable_inter_const _) + rw [←integral_event_indicator p _ hset] + apply integral_congr_ae + filter_upwards with ω + have hfinite := cluster_finite_of_finite_edges G + (ω := ω ∩ (Q : Set E)) (Q.finite_toSet.subset Set.inter_subset_right) x + have hiff : ω ∩ (Q : Set E) ∈ volumeEvent G x n ↔ + n ≤ (cluster G (ω ∩ (Q : Set E)) x).ncard := by + change (n : ℕ∞) ≤ (cluster G (ω ∩ (Q : Set E)) x).encard ↔ _ + rw [←hfinite.cast_ncard_eq] + exact_mod_cast Iff.rfl + simp only [f,hiff] + +theorem finiteWitness_restricted_probability_tendsto [Encodable E] + (A : Set (Set E)) (hA : IsUpperSet A) (hf : FiniteWitness A) (p : unitInterval) : + Tendsto (fun k => (law p).real {ω : Set E | + ω ∩ (edgeExhaustion (E := E) k : Set E) ∈ A}) atTop (𝓝 ((law p).real A)) := by + have hmono : Monotone (fun k => {ω : Set E | + ω ∩ (edgeExhaustion (E := E) k : Set E) ∈ A}) := by + intro k l h ω hω + exact hA (Set.inter_subset_inter_right _ (edgeExhaustion_mono h)) hω + have hh := tendsto_measure_iUnion_atTop (μ := law p) hmono + rw [←witness_eq_union A hA hf] at hh + exact (ENNReal.tendsto_toReal (measure_ne_top _ _)).comp hh + +theorem volumeEvent_upper (G : BondGraph V E) (x : V) (n : ℕ) : + IsUpperSet (volumeEvent G x n) := by + rw [volumeEvent_eq_clusterLarge G x n] + exact clusterLarge_upper G x n + +theorem volumeEvent_finiteWitness (G : BondGraph V E) (x : V) (n : ℕ) : + FiniteWitness (volumeEvent G x n) := by + rw [volumeEvent_eq_clusterLarge G x n] + exact finiteWitness_clusterLarge G x n + +theorem volume_probability_le_of_finite_tails [Countable E] + (G : BondGraph V E) (x : V) (n : ℕ) (p : unitInterval) (B : ℝ) + (hB : ∀ Q : Finset E, finiteClusterTail G Q x n p ≤ B) : + (law p).real (volumeEvent G x n) ≤ B := by + let : Encodable E := Encodable.ofCountable E + have hr := finiteWitness_restricted_probability_tendsto (volumeEvent G x n) + (volumeEvent_upper G x n) (volumeEvent_finiteWitness G x n) p + have hseq (k : ℕ) : (law p).real {ω : Set E | + ω ∩ (edgeExhaustion (E := E) k : Set E) ∈ volumeEvent G x n} ≤ B := + (finiteClusterTail_eq_restricted_volume G (edgeExhaustion (E := E) k) x n p).symm.le.trans (hB _) + exact le_of_tendsto hr (Eventually.of_forall hseq) + +theorem percolationProbability_le_of_marked_bounds [Countable E] + (G : BondGraph V E) (x : V) (p h : unitInterval) (hh : 0 < (h : ℝ)) (B : ℝ) + (hB : ∀ Q : Finset E, markedConnectionPolynomial G Q x h p ≤ B) : + percolationProbability G p x ≤ 2 * B := by + obtain ⟨n,hn⟩ := exists_nat_ge (1 / (h : ℝ)) + have hprod : 1 ≤ (h : ℝ) * n := by + have he := (div_le_iff₀ hh).mp hn + linarith + apply (measureReal_mono (μ := law p) (h₂ := measure_ne_top _ _) ?_).trans + (volume_probability_le_of_finite_tails G x n p (2 * B) (fun Q => + (finiteClusterTail_le_markedConnection G Q x n p h hprod).trans + (mul_le_mul_of_nonneg_left (hB Q) (by norm_num : (0 : ℝ) ≤ 2)))) + intro ω hω + change (n : ℕ∞) ≤ (cluster G ω x).encard + rw [Set.encard_eq_top hω] + exact le_top + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostFan.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostFan.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a76aa4fe5c9b05e30d27ea6603063cce4ffb129 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostFan.lean @@ -0,0 +1,236 @@ +import Mathlib + +namespace OAI + +open scoped Classical + +namespace Percolation.BenjaminiSchramm + +variable {V : Type*} {H : SimpleGraph V} + +def GhostFan (H : SimpleGraph V) (A B : Set V) (x : V) : Prop := + ∃ a ∈ A, ∃ b ∈ B, ∃ p : H.Walk x a, ∃ q : H.Walk x b, p.edges.Disjoint q.edges + +lemma GhostFan.symm {A B : Set V} {x : V} (h : GhostFan H A B x) : GhostFan H B A x := by + obtain ⟨a,ha,b,hb,p,q,hpq⟩ := h + exact ⟨b,hb,a,ha,q,p,hpq.symm⟩ + +lemma walk_edges_disjoint_of_single_support_intersection + {u v a b z : V} (p : H.Walk u v) (q : H.Walk a b) + (h : ∀ x ∈ p.support, x ∈ q.support → x = z) : p.edges.Disjoint q.edges := by + apply List.disjoint_left.mpr + intro e hp hq + obtain ⟨⟨c,d⟩,he⟩ := Quot.exists_rep e + rw [← he] at hp hq + have hc := h c (p.fst_mem_support_of_mem_edges hp) (q.fst_mem_support_of_mem_edges hq) + have hd := h d (p.snd_mem_support_of_mem_edges hp) (q.snd_mem_support_of_mem_edges hq) + exact (p.adj_of_mem_edges hp).ne (hc.trans hd.symm) + +lemma ghostFan_of_trail_support {A B : Set V} {a b x : V} + (ha : a ∈ A) (hb : b ∈ B) (p : H.Walk a b) (hp : p.IsTrail) (hx : x ∈ p.support) : + GhostFan H A B x := by + refine ⟨a,ha,b,hb,(p.takeUntil x hx).reverse,p.dropUntil x hx,?_⟩ + simpa only [SimpleGraph.Walk.edges_reverse, List.disjoint_reverse_left] using + hp.disjoint_edges_takeUntil_dropUntil hx + +lemma ghostFan_of_first_arm_support {A B : Set V} {w a b x : V} + (ha : a ∈ A) (hb : b ∈ B) (p : H.Walk w a) (q : H.Walk w b) + (hp : p.IsTrail) (hq : q.IsTrail) (hpq : p.edges.Disjoint q.edges) (hx : x ∈ p.support) : + GhostFan H A B x := by + apply ghostFan_of_trail_support ha hb (p.reverse.append q) + · exact (SimpleGraph.Walk.isTrail_append _ _).mpr + ⟨hp.reverse,hq,by simpa using hpq⟩ + · exact SimpleGraph.Walk.support_subset_support_append_left _ _ (by simpa using hx) + +lemma ghostFan_of_arm_avoiding_prefix {A B : Set V} {u w a b v : V} + (ha : a ∈ A) (hb : b ∈ B) (p : H.Walk w a) (q : H.Walk w b) + (hpq : p.edges.Disjoint q.edges) (huw : H.Adj u w) + (hu : u ∉ p.support) (r : H.Walk u v) (hv : v ∈ p.support) + (hrq : r.edges.Disjoint q.edges) + (hre : s(u,w) ∉ r.edges) : GhostFan H A B u := by + refine ⟨a,ha,b,hb,r.append (p.dropUntil v hv),SimpleGraph.Walk.cons huw q,?_⟩ + rw [SimpleGraph.Walk.edges_append, SimpleGraph.Walk.edges_cons] + apply List.disjoint_left.mpr + intro e he he' + rcases List.mem_append.mp he with her | hep + · rcases List.mem_cons.mp he' with he' | heq + · exact hre (he' ▸ her) + · exact List.disjoint_left.mp hrq her heq + · have hep' := p.edges_dropUntil_subset_edges hv hep + rcases List.mem_cons.mp he' with he' | heq + · exact hu (p.fst_mem_support_of_mem_edges (he' ▸ hep')) + · exact List.disjoint_left.mp hpq hep' heq + +lemma GhostFan.of_alternate_walk {A B : Set V} {u w : V} + (h : GhostFan H A B w) (huw : H.Adj u w) + (r : H.Walk u w) (hre : s(u,w) ∉ r.edges) : GhostFan H A B u := by + classical + obtain ⟨a,ha,b,hb,p₀,q₀,hpq₀⟩ := h + let p : H.Walk w a := p₀.toPath + let q : H.Walk w b := q₀.toPath + have hp : p.IsTrail := p₀.toPath.property.isTrail + have hq : q.IsTrail := q₀.toPath.property.isTrail + have hpq : p.edges.Disjoint q.edges := by + apply List.disjoint_left.mpr + intro e hep heq + exact List.disjoint_left.mp hpq₀ + (p₀.edges_toPath_subset_edges hep) (q₀.edges_toPath_subset_edges heq) + by_cases hu : u ∈ p.support + · exact ghostFan_of_first_arm_support ha hb p q hp hq hpq hu + by_cases hu' : u ∈ q.support + · exact (ghostFan_of_first_arm_support hb ha q p hq hp hpq.symm hu').symm + let S := p.support.toFinset ∪ q.support.toFinset + have hwS : w ∈ S := Finset.mem_union_left _ (List.mem_toFinset.mpr p.start_mem_support) + obtain ⟨v,hv,hvr,hfirst⟩ := r.exists_mem_support_forall_mem_support_imp_eq S + ⟨w,Finset.mem_filter.mpr ⟨hwS,r.end_mem_support⟩⟩ + let r' := r.takeUntil v hvr + have hrp : r'.edges.Disjoint p.edges := by + apply walk_edges_disjoint_of_single_support_intersection r' p + intro x hxr hxp + exact hfirst x (Finset.mem_union_left _ (List.mem_toFinset.mpr hxp)) hxr + have hrq : r'.edges.Disjoint q.edges := by + apply walk_edges_disjoint_of_single_support_intersection r' q + intro x hxr hxq + exact hfirst x (Finset.mem_union_right _ (List.mem_toFinset.mpr hxq)) hxr + have hre' : s(u,w) ∉ r'.edges := fun he => hre (r.edges_takeUntil_subset_edges hvr he) + rcases Finset.mem_union.mp hv with hvp | hvq + · exact ghostFan_of_arm_avoiding_prefix ha hb p q hpq huw hu r' + (List.mem_toFinset.mp hvp) hrq hre' + · exact (ghostFan_of_arm_avoiding_prefix hb ha q p hpq.symm huw hu' r' + (List.mem_toFinset.mp hvq) hrp hre').symm + +lemma GhostFan.of_not_isBridge {A B : Set V} {u w : V} + (h : GhostFan H A B w) (huw : H.Adj u w) (he : ¬H.IsBridge s(u,w)) : + GhostFan H A B u := by + obtain ⟨r,hr⟩ := SimpleGraph.reachable_deleteEdges_iff_exists_walk.mp + (not_not.mp (SimpleGraph.isBridge_iff.not.mp he)) + exact h.of_alternate_walk huw r hr + +lemma exists_bridge_to_ghostFan {A B : Set V} {x w : V} + (r : H.Walk x w) (hw : GhostFan H A B w) (hx : ¬GhostFan H A B x) : + ∃ u v, H.Adj u v ∧ H.IsBridge s(u,v) ∧ + (H.deleteEdges {s(u,v)}).Reachable x u ∧ GhostFan H A B v ∧ ¬GhostFan H A B u := by + induction r with + | nil => exact (hx hw).elim + | @cons x y w hxy r ih => + by_cases hy : GhostFan H A B y + · have he : H.IsBridge s(x,y) := by + by_contra hn + exact hx (hy.of_not_isBridge hxy hn) + exact ⟨x,y,hxy,he,SimpleGraph.Reachable.refl x,hy,hx⟩ + · obtain ⟨u,v,huv,he,hreach,hv,hu⟩ := ih hw hy + have hne : s(x,y) ≠ s(u,v) := by + intro heq + rcases Sym2.eq_iff.mp heq with ⟨hxu,hyv⟩ | ⟨hxv,hyu⟩ + · exact hy (hyv ▸ hv) + · exact hx (hxv ▸ hv) + have hxy' : (H.deleteEdges {s(u,v)}).Adj x y := by + exact SimpleGraph.deleteEdges_adj.mpr ⟨hxy,by simpa using hne⟩ + exact ⟨u,v,huv,he,hxy'.reachable.trans hreach,hv,hu⟩ + +lemma walk_edges_disjoint_of_bridge {u v a b : V} (he : H.IsBridge s(u,v)) + (p : H.Walk u a) (q : H.Walk v b) + (hp : s(u,v) ∉ p.edges) (hq : s(u,v) ∉ q.edges) : p.edges.Disjoint q.edges := by + apply List.disjoint_left.mpr + intro e hep heq + obtain ⟨⟨c,d⟩,he'⟩ := Quot.exists_rep e + rw [← he'] at hep heq + have hc := p.fst_mem_support_of_mem_edges hep + have hc' := q.fst_mem_support_of_mem_edges heq + let r := (p.takeUntil c hc).append (q.takeUntil c hc').reverse + have hr : s(u,v) ∉ r.edges := by + simp only [r, SimpleGraph.Walk.edges_append, SimpleGraph.Walk.edges_reverse, + List.mem_append, List.mem_reverse, not_or] + exact ⟨fun h => hp (p.edges_takeUntil_subset_edges hc h), + fun h => hq (q.edges_takeUntil_subset_edges hc' h)⟩ + exact hr (SimpleGraph.isBridge_iff_forall_walk_mem_edges.mp he r) + +lemma bridge_to_ghostFan_avoids_marks {A B : Set V} {u v : V} + (huv : H.Adj u v) (he : H.IsBridge s(u,v)) + (hv : GhostFan H A B v) (hu : ¬GhostFan H A B u) : + (∀ a ∈ A, ¬(H.deleteEdges {s(u,v)}).Reachable u a) ∧ + (∀ b ∈ B, ¬(H.deleteEdges {s(u,v)}).Reachable u b) := by + classical + suffices h : ∀ (C D : Set V), GhostFan H C D v → ¬GhostFan H C D u → + ∀ a ∈ C, ¬(H.deleteEdges {s(u,v)}).Reachable u a by + exact ⟨h A B hv hu,h B A hv.symm (fun hf => hu hf.symm)⟩ + intro C D hv hu a ha hreach + obtain ⟨a₀,ha₀,b,hb,p₀,q₀,hpq₀⟩ := hv + let p : H.Walk v a₀ := p₀.toPath + let q : H.Walk v b := q₀.toPath + have hpq : p.edges.Disjoint q.edges := by + apply List.disjoint_left.mpr + intro e hep heq + exact List.disjoint_left.mp hpq₀ + (p₀.edges_toPath_subset_edges hep) (q₀.edges_toPath_subset_edges heq) + have huq : u ∉ q.support := by + intro h + exact hu (ghostFan_of_first_arm_support hb ha₀ q p + q₀.toPath.property.isTrail p₀.toPath.property.isTrail hpq.symm h).symm + have hqe : s(u,v) ∉ q.edges := fun h => huq (q.fst_mem_support_of_mem_edges h) + obtain ⟨r,hr⟩ := SimpleGraph.reachable_deleteEdges_iff_exists_walk.mp hreach + have hrq := walk_edges_disjoint_of_bridge he r q hr hqe + apply hu + refine ⟨a,ha,b,hb,r,SimpleGraph.Walk.cons huv q,?_⟩ + rw [SimpleGraph.Walk.edges_cons] + apply List.disjoint_left.mpr + intro e her heq + rcases List.mem_cons.mp heq with heq | heq + · exact hr (heq ▸ her) + · exact List.disjoint_left.mp hrq her heq + +lemma GhostFan.mono {K : SimpleGraph V} {A B : Set V} {x : V} + (h : GhostFan H A B x) (hHK : H ≤ K) : GhostFan K A B x := by + obtain ⟨a,ha,b,hb,p,q,hpq⟩ := h + refine ⟨a,ha,b,hb,p.mapLe hHK,q.mapLe hHK,?_⟩ + simpa using hpq + +lemma ghostFan_delete_bridge {A B : Set V} {u v : V} + (hv : GhostFan H A B v) (hu : ¬GhostFan H A B u) : + GhostFan (H.deleteEdges {s(u,v)}) A B v := by + classical + obtain ⟨a,ha,b,hb,p₀,q₀,hpq₀⟩ := hv + let p : H.Walk v a := p₀.toPath + let q : H.Walk v b := q₀.toPath + have hpq : p.edges.Disjoint q.edges := by + apply List.disjoint_left.mpr + intro e hep heq + exact List.disjoint_left.mp hpq₀ + (p₀.edges_toPath_subset_edges hep) (q₀.edges_toPath_subset_edges heq) + have hup : u ∉ p.support := by + intro h + exact hu (ghostFan_of_first_arm_support ha hb p q + p₀.toPath.property.isTrail q₀.toPath.property.isTrail hpq h) + have huq : u ∉ q.support := by + intro h + exact hu (ghostFan_of_first_arm_support hb ha q p + q₀.toPath.property.isTrail p₀.toPath.property.isTrail hpq.symm h).symm + have hpe : s(u,v) ∉ p.edges := fun h => hup (p.fst_mem_support_of_mem_edges h) + have hqe : s(u,v) ∉ q.edges := fun h => huq (q.fst_mem_support_of_mem_edges h) + refine ⟨a,ha,b,hb,p.toDeleteEdge s(u,v) hpe,q.toDeleteEdge s(u,v) hqe,?_⟩ + simpa using hpq + +lemma two_connections_fan_or_bridge {A B : Set V} {x : V} + (hA : ∃ a ∈ A, H.Reachable x a) (hB : ∃ b ∈ B, H.Reachable x b) : + GhostFan H A B x ∨ ∃ u v, H.Adj u v ∧ H.IsBridge s(u,v) ∧ + (H.deleteEdges {s(u,v)}).Reachable x u ∧ + (∀ a ∈ A, ¬(H.deleteEdges {s(u,v)}).Reachable x a) ∧ + (∀ b ∈ B, ¬(H.deleteEdges {s(u,v)}).Reachable x b) ∧ + GhostFan (H.deleteEdges {s(u,v)}) A B v := by + classical + by_cases hx : GhostFan H A B x + · exact Or.inl hx + right + obtain ⟨a,ha,⟨p⟩⟩ := hA + obtain ⟨b,hb,⟨q⟩⟩ := hB + have haFan : GhostFan H A B a := + ⟨a,ha,b,hb,SimpleGraph.Walk.nil,p.reverse.append q,by simp⟩ + obtain ⟨u,v,huv,he,hxu,hv,hu⟩ := exists_bridge_to_ghostFan p haFan hx + obtain ⟨hA,hB⟩ := bridge_to_ghostFan_avoids_marks huv he hv hu + exact ⟨u,v,huv,he,hxu, + fun a ha hxa => hA a ha (hxu.symm.trans hxa), + fun b hb hxb => hB b hb (hxu.symm.trans hxb),ghostFan_delete_bridge hv hu⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostFanBK.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostFanBK.lean new file mode 100644 index 0000000000000000000000000000000000000000..07664ff2f42e92043ca5c47e106a6641b30c932a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostFanBK.lean @@ -0,0 +1,51 @@ +import OAI.Probability.BenjaminiSchramm.GhostFan +import OAI.Probability.BenjaminiSchramm.GhostBondBK + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical + +namespace Percolation.BenjaminiSchramm + +variable {V E T : Type*} (G : BondGraph V E) (x : V) (vertex : T → V) + +lemma ghostFan_mem_disjointOccurrence {ω : Set E} {m n : Set T} + (h : GhostFan (openSimpleGraph G ω) (vertex '' m) (vertex '' n) x) : + ω ∈ DisjointOccurrence (finiteGhostConnection G x vertex m) + (finiteGhostConnection G x vertex n) := by + obtain ⟨a,⟨i,hi,rfl⟩,b,⟨j,hj,rfl⟩,p,q,hpq⟩ := h + obtain ⟨s,hs,hse,hso⟩ := walk_lift_bonds G ω p + obtain ⟨t,ht,hte,hto⟩ := walk_lift_bonds G ω q + refine ⟨s.toFinset,t.toFinset,?_,?_,?_,?_,?_⟩ + · intro e he + exact hso e (List.mem_toFinset.mp he) + · intro e he + exact hto e (List.mem_toFinset.mp he) + · apply Finset.disjoint_left.mpr + intro e hes het + exact List.disjoint_left.mp hpq + (hse ▸ List.mem_map_of_mem (List.mem_toFinset.mp hes)) + (hte ▸ List.mem_map_of_mem (List.mem_toFinset.mp het)) + · exact ⟨i,hi,hs.conn (fun e he => List.mem_toFinset.mpr he)⟩ + · exact ⟨j,hj,ht.conn (fun e he => List.mem_toFinset.mpr he)⟩ + +lemma ghostFan_measure_le [Countable E] (p : unitInterval) (m n : Set T) : + (law p) {ω | GhostFan (openSimpleGraph G ω) (vertex '' m) (vertex '' n) x} ≤ + (law p) (finiteGhostConnection G x vertex m) * + (law p) (finiteGhostConnection G x vertex n) := by + calc + _ ≤ (law p) (DisjointOccurrence (finiteGhostConnection G x vertex m) + (finiteGhostConnection G x vertex n)) := + measure_mono (fun _ h => ghostFan_mem_disjointOccurrence G x vertex h) + _ ≤ _ := bk_ennreal p _ _ + (finiteGhostConnection_upper G x vertex m) (finiteGhostConnection_upper G x vertex n) + (finiteGhostConnection_finiteWitness G x vertex m) + (finiteGhostConnection_finiteWitness G x vertex n) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostField.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostField.lean new file mode 100644 index 0000000000000000000000000000000000000000..d57c1eee8a88f489833db55892f6102fa0359ced --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostField.lean @@ -0,0 +1,107 @@ +import OAI.Probability.BenjaminiSchramm.TwoGhost +import OAI.Probability.CriticalPercolation.ProductMeasure.TailProduct + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +def ghostRate (h x : ℝ≥0) : unitInterval := + ⟨ghostKernel h x, ghostKernel_nonneg h.2 x.2, ghostKernel_le_one h x⟩ + +def ghostFieldLaw {V : Type*} (h : ℝ≥0) (w : V → ℝ≥0) : Measure (Set V) := + CriticalPercolation.BernoulliProduct.law (fun v => ghostRate h (w v)) + +instance ghostFieldLaw_probability {V : Type*} (h : ℝ≥0) (w : V → ℝ≥0) : + IsProbabilityMeasure (ghostFieldLaw h w) := by + unfold ghostFieldLaw + infer_instance + +lemma ghostRate_closed_probability (h x : ℝ≥0) : + CriticalPercolation.BernoulliProduct.bitMeasure (ghostRate h x) {False} = + ENNReal.ofReal (Real.exp (-(h : ℝ) * x)) := by + rw [← ENNReal.ofReal_toReal (measure_ne_top _ _)] + change ENNReal.ofReal + ((CriticalPercolation.BernoulliProduct.bitMeasure (ghostRate h x)).real {False}) = _ + rw [CriticalPercolation.BernoulliProduct.bitMeasure_real_singleton] + simp [CriticalPercolation.BernoulliProduct.bitWeight, ghostRate, ghostKernel] + +theorem ghostFieldLaw_avoid_finset {V : Type*} (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) : + ghostFieldLaw h w {m | Disjoint (S : Set V) m} = + ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ S, (w v : ℝ))) := by + unfold ghostFieldLaw + have hm : MeasurableSet {m : Set V | Disjoint (S : Set V) m} := by + rw [show {m : Set V | Disjoint (S : Set V) m} = ⋂ v ∈ S, {m | v ∉ m} from by + ext m + simp [Set.disjoint_left]] + exact S.measurableSet_biInter fun v _ => (measurable_set_mem v).setOf.compl + rw [CriticalPercolation.BernoulliProduct.law, + Measure.map_apply MeasurableEquiv.setOfPred.measurable hm] + have he : MeasurableEquiv.setOfPred ⁻¹' {m : Set V | Disjoint (S : Set V) m} = + ((S : Set V).pi (fun _ => {False}) : Set (V → Prop)) := by + ext f + change Disjoint (S : Set V) {v | f v} ↔ ∀ v ∈ (S : Set V), f v = False + constructor + · intro hd v hv + exact propext (iff_false_intro fun hf => Set.disjoint_left.mp hd hv hf) + · intro hd + apply Set.disjoint_left.mpr + intro v hv hf + change f v at hf + rw [hd v hv] at hf + exact hf + rw [he] + erw [Measure.infinitePi_pi + (μ := fun v : V => CriticalPercolation.BernoulliProduct.bitMeasure (ghostRate h (w v))) + (s := S) (t := fun _ : V => ({False} : Set Prop)) (fun _ _ => MeasurableSet.of_discrete)] + simp_rw [ghostRate_closed_probability] + rw [← ENNReal.ofReal_prod_of_nonneg (fun v _ => (Real.exp_pos _).le), ← Real.exp_sum] + congr 2 + exact (Finset.mul_sum S _ _).symm + +theorem ghostFieldLaw_avoid_finite {V : Type*} (h : ℝ≥0) (w : V → ℝ≥0) + (S : Set V) (hS : S.Finite) : + ghostFieldLaw h w {m | Disjoint S m} = + ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ hS.toFinset, (w v : ℝ))) := by + convert ghostFieldLaw_avoid_finset h w hS.toFinset using 1 + rw [hS.coe_toFinset] + +def ghostHits {V : Type*} (S : Set V) : Set (Set V) := {m | ∃ v ∈ S, v ∈ m} + +lemma measurableSet_ghostHits {V : Type*} [Countable V] (S : Set V) : + MeasurableSet (ghostHits S) := + (Measurable.exists fun v => measurable_const.and (measurable_set_mem v)).setOf + +lemma ghostHits_compl {V : Type*} (S : Set V) : (ghostHits S)ᶜ = {m | Disjoint S m} := by + ext m + simp [ghostHits, Set.disjoint_left] + +theorem ghostFieldLaw_real_hit_finset {V : Type*} [Countable V] + (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) : + (ghostFieldLaw h w).real (ghostHits (S : Set V)) = + ghostKernel h (∑ v ∈ S, (w v : ℝ)) := by + have he := probReal_compl_eq_one_sub (μ := ghostFieldLaw h w) + (measurableSet_ghostHits (S : Set V)) + rw [ghostHits_compl, measureReal_def, ghostFieldLaw_avoid_finset, + ENNReal.toReal_ofReal (Real.exp_pos _).le] at he + dsimp [ghostKernel] + linarith + +theorem twoGhostFieldLaw_real_hit_finset {V : Type*} [Countable V] + (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) : + ((ghostFieldLaw h w).prod (ghostFieldLaw h w)).real + (ghostHits (S : Set V) ×ˢ ghostHits (S : Set V)) = + ghostKernel h (∑ v ∈ S, (w v : ℝ)) ^ 2 := by + rw [measureReal_def, Measure.prod_prod, ENNReal.toReal_mul] + change (ghostFieldLaw h w).real (ghostHits (S : Set V)) * + (ghostFieldLaw h w).real (ghostHits (S : Set V)) = _ + rw [ghostFieldLaw_real_hit_finset, sq] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostMomentBound.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostMomentBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c76c53f32320e425f24b0e05cdc01718be35964 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostMomentBound.lean @@ -0,0 +1,105 @@ +import OAI.Probability.BenjaminiSchramm.GhostCluster + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def quarterThreeQuarterMoment (p : unitInterval) (x : V) : ℝ≥0∞ := + ∫⁻ ω, G.quarterTiltedMass ω x ^ (3 / 4 : ℝ) ∂G.law p + +lemma quarterThreeQuarterMoment_aut (p : unitInterval) (φ : G.Aut) (x : V) : + G.quarterThreeQuarterMoment p (φ.vertex x) = G.quarterThreeQuarterMoment p x := by + unfold quarterThreeQuarterMoment + conv_lhs => rw [← G.law_map_aut p φ] + have hm : Measurable (fun ω => G.quarterTiltedMass ω (φ.vertex x) ^ (3 / 4 : ℝ)) := + ENNReal.continuous_rpow_const.measurable.comp (G.measurable_quarterTiltedMass _) + rw [lintegral_map hm (BernoulliProduct.measurable_image_equiv φ.edge)] + simp only [G.quarterTiltedMass_aut] + +theorem uniform_quarterGhost_moment_bound (hq : G.QuasiTransitive) (p : unitInterval) + (hfin : ∀ x ∈ (G.orbitRepresentatives hq).roots, + G.quarterThreeQuarterMoment p x < ⊤) : + ∃ K : ℝ, 0 < K ∧ ∀ x h, 0 ≤ h → + G.quarterGhostMagnetization p x h ≤ K * h ^ (3 / 4 : ℝ) := by + let C := ∑ x ∈ (G.orbitRepresentatives hq).roots, G.quarterThreeQuarterMoment p x + have hC : C < ⊤ := ENNReal.sum_lt_top.mpr hfin + have hxC (x : V) : G.quarterThreeQuarterMoment p x ≤ C := by + obtain ⟨y,hy,φ,rfl⟩ := (G.orbitRepresentatives hq).cover x + rw [G.quarterThreeQuarterMoment_aut] + exact Finset.single_le_sum (fun _ _ => bot_le) hy + refine ⟨C.toReal + 1,by positivity,?_⟩ + intro x h hh + have hxfin := lt_of_le_of_lt (hxC x) hC + have hpow : Measurable (fun ω => G.quarterTiltedMass ω x ^ (3 / 4 : ℝ)) := + ENNReal.continuous_rpow_const.measurable.comp (G.measurable_quarterTiltedMass x) + have hXi : Integrable (fun ω => (G.quarterTiltedMass ω x).toReal ^ (3 / 4 : ℝ)) + (G.law p) := by + simpa only [ENNReal.toReal_rpow] using + integrable_toReal_of_lintegral_ne_top hpow.aemeasurable hxfin.ne + have hI : (∫ ω, (G.quarterTiltedMass ω x).toReal ^ (3 / 4 : ℝ) ∂G.law p) ≤ C.toReal := by + have he := integral_toReal hpow.aemeasurable (ae_lt_top hpow hxfin.ne) + calc + _ = ∫ ω, (G.quarterTiltedMass ω x ^ (3 / 4 : ℝ)).toReal ∂G.law p := + integral_congr_ae (ae_of_all _ fun ω => ENNReal.toReal_rpow _ _) + _ = (G.quarterThreeQuarterMoment p x).toReal := he + _ ≤ C.toReal := ENNReal.toReal_mono hC.ne (hxC x) + calc + _ ≤ ∫ ω, h ^ (3 / 4 : ℝ) * (G.quarterTiltedMass ω x).toReal ^ (3 / 4 : ℝ) + ∂G.law p := by + apply integral_mono + (integrable_ghostKernel (G.law p) _ (G.measurable_quarterTiltedMass x).ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) hh) (hXi.const_mul _) + intro ω + exact (ghostKernel_le_threeQuarter hh ENNReal.toReal_nonneg).trans_eq + (Real.mul_rpow hh ENNReal.toReal_nonneg) + _ = h ^ (3 / 4 : ℝ) * ∫ ω, (G.quarterTiltedMass ω x).toReal ^ (3 / 4 : ℝ) + ∂G.law p := integral_const_mul _ _ + _ ≤ _ := by + have hp : 0 ≤ h ^ (3 / 4 : ℝ) := Real.rpow_nonneg hh _ + nlinarith + +omit [Countable V] [Countable E] in +lemma quarterGhost_square_bound {p : unitInterval} {K : ℝ} + (hbound : ∀ x h, 0 ≤ h → G.quarterGhostMagnetization p x h ≤ K * h ^ (3 / 4 : ℝ)) + (x : V) {h : ℝ} (hh : 0 ≤ h) : + G.quarterGhostMagnetization p x h ^ 2 ≤ K ^ 2 * h ^ (3 / 2 : ℝ) := by + have hnonneg : 0 ≤ G.quarterGhostMagnetization p x h := + integral_nonneg (fun _ => ghostKernel_nonneg hh ENNReal.toReal_nonneg) + have hpow : (h ^ (3 / 4 : ℝ)) ^ 2 = h ^ (3 / 2 : ℝ) := by + rw [← Real.rpow_mul_natCast hh] + norm_num + calc + _ ≤ (K * h ^ (3 / 4 : ℝ)) ^ 2 := + pow_le_pow_left₀ hnonneg (hbound x h hh) 2 + _ = _ := by rw [mul_pow,hpow] + +omit [Countable V] [Countable E] in +lemma quarterGhostWeight_threeHalf (x v : V) : + (G.quarterGhostWeight x v : ℝ) ^ (3 / 2 : ℝ) = + (G.stabilizerWeight x v ^ (3 / 8 : ℝ)).toReal := by + rw [← ENNReal.coe_toReal (G.quarterGhostWeight x v), G.coe_quarterGhostWeight, + ENNReal.toReal_rpow, ← ENNReal.rpow_mul] + norm_num + +omit [Countable V] [Countable E] in +lemma rebased_quarterGhost_square_bound {p : unitInterval} {K : ℝ} + (hbound : ∀ x h, 0 ≤ h → G.quarterGhostMagnetization p x h ≤ K * h ^ (3 / 4 : ℝ)) + (x v : V) {h : ℝ} (hh : 0 ≤ h) : + G.quarterGhostMagnetization p v (h * G.quarterGhostWeight x v) ^ 2 ≤ + K ^ 2 * h ^ (3 / 2 : ℝ) * (G.stabilizerWeight x v ^ (3 / 8 : ℝ)).toReal := by + have hb := G.quarterGhost_square_bound hbound v (mul_nonneg hh (G.quarterGhostWeight x v).2) + rw [Real.mul_rpow hh (G.quarterGhostWeight x v).2] at hb + erw [G.quarterGhostWeight_threeHalf, ← mul_assoc] at hb + exact hb + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostMomentDischarge.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostMomentDischarge.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d72a3bb7e537ed4b3e00eb684dae5ab1b0bc103 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostMomentDischarge.lean @@ -0,0 +1,148 @@ +import OAI.Probability.BenjaminiSchramm.GhostDifferentialAssembly +import OAI.Probability.BenjaminiSchramm.ModularSchur + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma ghostKernel_mono_field {h k x : ℝ} (hhk : h ≤ k) (hx : 0 ≤ x) : + ghostKernel h x ≤ ghostKernel k x := by + unfold ghostKernel + apply sub_le_sub_left + exact Real.exp_le_exp.mpr (by nlinarith) + +lemma ghostMagnetization_le_derivative_add_twoGhost_same + {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (X : Ω → ℝ) (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + {h : ℝ} (hh : 0 < h) : + ghostMagnetization μ X h ≤ h*ghostMagnetizationDerivative μ X h + + 2*∫ ω, ghostKernel h (X ω)^2 ∂μ := by + apply (ghostMagnetization_le_derivative_add_two_ghost μ X hX hX0 hh).trans + apply add_le_add le_rfl + apply mul_le_mul_of_nonneg_left _ (by norm_num : (0 : ℝ) ≤ 2) + apply integral_mono + (integrable_ghostKernel_sq μ X hX hX0 (by positivity : 0 ≤ h/2)) + (integrable_ghostKernel_sq μ X hX hX0 hh.le) + intro ω + exact pow_le_pow_left₀ (ghostKernel_nonneg (by positivity) (hX0 ω)) + (ghostKernel_mono_field (by linarith) (hX0 ω)) 2 + +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem root_quarterGhost_differential + (hinj : Function.Injective G) + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (hq : (criticalModel G).QuasiTransitive) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (hmoment : ∀ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterThreeQuarterMoment p x < ⊤) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ t : ℝ, 0 < t → t ≤ 1 → + (∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterGhostMagnetization p x (t^4)) ≤ + C*(∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterGhostMagnetization p x (t^4))^2 + + t^4*(∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterGhostDerivative p x (t^4)) + + C*t^6*(∑ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterGhostDerivative p x (t^4)) := by + let H := criticalModel G + let O := (H.orbitRepresentatives hq).roots + obtain ⟨K,_,hK⟩ := H.uniform_quarterGhost_moment_bound hq p hmoment + obtain ⟨D,_,hD⟩ := H.uniform_incident_bound hq + obtain ⟨B,hB⟩ := H.uniform_ball_bound hq 1 + obtain ⟨A,hA,hbound⟩ := root_twoGhost_bound G hinj hc hl hq p hp hfin K hK D B hD hB + let C := max 2 (2*A) + have hC2 : 2 ≤ C := le_max_left _ _ + have hCA : 2*A ≤ C := le_max_right _ _ + refine ⟨C,by dsimp [C]; positivity,?_⟩ + intro t ht _ + let h : ℝ≥0 := ⟨t^4,by positivity⟩ + have hh : (0 : ℝ) < h := by change 0 < t^4; exact pow_pos ht 4 + let M := ∑ x ∈ O, H.quarterGhostMagnetization p x (t^4) + let Derv := ∑ x ∈ O, H.quarterGhostDerivative p x (t^4) + have hDnonneg (x : V) : 0 ≤ H.quarterGhostDerivative p x (t^4) := + integral_nonneg fun _ => mul_nonneg ENNReal.toReal_nonneg (Real.exp_pos _).le + have hDerv : 0 ≤ Derv := Finset.sum_nonneg fun x _ => hDnonneg x + have hdouble : (∑ x ∈ O, H.quarterGhostDerivative p x (2*h)) ≤ Derv := by + apply Finset.sum_le_sum + intro x _ + unfold CriticalPercolation.BondGraph.quarterGhostDerivative ghostMagnetizationDerivative + apply integral_mono + (hasDerivAt_ghostMagnetization (H.law p) _ (H.measurable_quarterTiltedMass x).ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) (by positivity : (0 : ℝ) < 2*h)).1 + (hasDerivAt_ghostMagnetization (H.law p) _ (H.measurable_quarterTiltedMass x).ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) (by positivity : (0 : ℝ) < t^4)).1 + intro ω + apply mul_le_mul_of_nonneg_left _ ENNReal.toReal_nonneg + apply Real.exp_le_exp.mpr + change -(2*t^4)*(H.quarterTiltedMass ω x).toReal ≤ -(t^4)*(H.quarterTiltedMass ω x).toReal + exact mul_le_mul_of_nonneg_right (by nlinarith [pow_nonneg ht.le 4]) ENNReal.toReal_nonneg + have hpow : (h : ℝ)^(3/2 : ℝ) = t^6 := by + change (t^4)^(3/2 : ℝ) = t^6 + rw [←Real.rpow_natCast_mul ht.le] + norm_num + have hsq := hbound h hh + rw [hpow] at hsq + have herror := mul_le_mul_of_nonneg_left hdouble (by positivity : 0 ≤ A*t^6) + have hbase : M ≤ t^4*Derv + 2*(∑ x ∈ O, + ∫ ω, ghostKernel h (H.quarterTiltedMass ω x).toReal^2 ∂law p) := by + calc + _ ≤ ∑ x ∈ O, (t^4*H.quarterGhostDerivative p x (t^4) + + 2*∫ ω, ghostKernel h (H.quarterTiltedMass ω x).toReal^2 ∂law p) := by + apply Finset.sum_le_sum + intro x _ + exact ghostMagnetization_le_derivative_add_twoGhost_same (H.law p) + (fun ω => (H.quarterTiltedMass ω x).toReal) (H.measurable_quarterTiltedMass x).ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) (by positivity) + _ = _ := by rw [Finset.sum_add_distrib,←Finset.mul_sum,←Finset.mul_sum] + have h1 : 2*M^2 ≤ C*M^2 := mul_le_mul_of_nonneg_right hC2 (sq_nonneg M) + have h2 : 2*A*t^6*Derv ≤ C*t^6*Derv := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hCA (by positivity)) hDerv + change M ≤ C*M^2+t^4*Derv+C*t^6*Derv + change (∑ x ∈ O, ∫ ω, ghostKernel h (H.quarterTiltedMass ω x).toReal^2 ∂law p) ≤ + M^2+A*t^6*(∑ x ∈ O, H.quarterGhostDerivative p x (2*h)) at hsq + change A*t^6*(∑ x ∈ O, H.quarterGhostDerivative p x (2*h)) ≤ A*t^6*Derv at herror + nlinarith + +theorem finite_quarterSusceptibility_of_moments + (hinj : Function.Injective G) + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (hq : (criticalModel G).QuasiTransitive) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (hmoment : ∀ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).quarterThreeQuarterMoment p x < ⊤) : + ∀ x ∈ ((criticalModel G).orbitRepresentatives hq).roots, + (criticalModel G).tiltedSusceptibility p (1/4) x < ⊤ := by + let H := criticalModel G + let O := (H.orbitRepresentatives hq).roots + let ι := ↥O + let : MeasurableSpace ι := ⊤ + let root : ι → V := fun i => i.1 + obtain ⟨C,hC,hdiff⟩ := root_quarterGhost_differential G hinj hc hl hq p hp hfin hmoment + have hM (h : ℝ) (hh : 0 ≤ h) : H.rootQuarterGhostMagnetization root p h = + ∑ x ∈ O, H.quarterGhostMagnetization p x h := by + rw [H.rootQuarterGhostMagnetization_eq_sum root p hh] + exact Finset.sum_coe_sort O (fun x => H.quarterGhostMagnetization p x h) + have hD (h : ℝ) (hh : 0 < h) : H.rootQuarterGhostDerivative root p h = + ∑ x ∈ O, H.quarterGhostDerivative p x h := by + rw [H.rootQuarterGhostDerivative_eq_sum root p hh] + exact Finset.sum_coe_sort O (fun x => H.quarterGhostDerivative p x h) + have hresult := H.root_quarterTiltedSusceptibility_lt_top_of_moment_and_differential root p + (fun i => hmoment i.1 i.2) C hC (by + intro t ht ht1 + rw [hM _ (by positivity),hD _ (by positivity)] + exact hdiff t ht ht1) + intro x hx + exact hresult ⟨x,hx⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalBound.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a2908b0f31d6dbf1c1edb4ce307664e232f602a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalBound.lean @@ -0,0 +1,42 @@ +import OAI.Probability.BenjaminiSchramm.GhostAvoidance +import OAI.Probability.BenjaminiSchramm.GhostFanBK + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] + +omit [Countable V] [Countable E] in +lemma finiteGhostConnection_mono_marks (G : BondGraph V E) (x : V) + {m n : Set V} (hmn : m ⊆ n) : + finiteGhostConnection G x id m ⊆ finiteGhostConnection G x id n := by + rintro ω ⟨v,hv,hconn⟩ + exact ⟨v,hmn hv,hconn⟩ + +theorem ghost_avoidance_bk (G : BondGraph V E) (p : unitInterval) (x : V) + (h : ℝ≥0) (w : V → ℝ≥0) (S : Finset V) : + (∫⁻ m, ∫⁻ n, if Disjoint (S : Set V) m ∧ Disjoint (S : Set V) n then + law p (DisjointOccurrence (finiteGhostConnection G x id m) + (finiteGhostConnection G x id n)) else 0 ∂ghostFieldLaw h w ∂ghostFieldLaw h w) ≤ + ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ v ∈ S, (w v : ℝ))) ^ 2 * + (∫⁻ m, law p (finiteGhostConnection G x id m) ∂ghostFieldLaw h w) ^ 2 := by + let F := fun z : Set V × Set V => law p + (DisjointOccurrence (finiteGhostConnection G x id z.1) (finiteGhostConnection G x id z.2)) + have hF : Measurable F := measurable_measure_prodMk_left (ν := law p) + (measurableSet_ghostDisjointOccurrence G x id) + have hmono : ∀ m m', m ⊆ m' → ∀ n n', n ⊆ n' → F (m,n) ≤ F (m',n') := by + intro m m' hmm n n' hnn + exact measure_mono (disjointOccurrence_mono + (finiteGhostConnection_mono_marks G x hmm) (finiteGhostConnection_mono_marks G x hnn)) + exact (two_ghost_avoidance_upper h w S F hF hmono).trans + (mul_le_mul' le_rfl (averaged_ghostConnection_bk G x id p (ghostFieldLaw h w))) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalBoundary.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..e425b84c48a846b34930a27c358c2beb2c8be9da --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalBoundary.lean @@ -0,0 +1,182 @@ +import OAI.Probability.BenjaminiSchramm.GhostPivotalSum + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def averagedQuarterBridge (p : unitInterval) (x : V) (h : ℝ≥0) + (e : E) (u v : V) (S : Finset V) : ℝ≥0∞ := + ∫⁻ m, ∫⁻ n, law p {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} + ∂ghostFieldLaw h ((criticalModel G).quarterGhostWeight x) + ∂ghostFieldLaw h ((criticalModel G).quarterGhostWeight x) + +theorem averagedQuarterBridge_oriented_le + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (K : ℝ) (hbound : ∀ x h, 0 ≤ h → + (criticalModel G).quarterGhostMagnetization p x h ≤ K*h^(3/4 : ℝ)) + (S : Finset V) (x : V) (e : E) (u v : V) (h : ℝ≥0) : + averagedQuarterBridge G p x h e u v S ≤ + ((ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ))) * + law p {ω | cluster G ω x = (S : Set V)} * + ghostAvoid (2*(h : ℝ)) (∑ y ∈ S, ((criticalModel G).quarterGhostWeight x y : ℝ≥0∞)) * + ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ))) * + (if G e = s(u,v) ∧ u ∈ (S : Set V) ∧ v ∉ (S : Set V) then + (criticalModel G).stabilizerWeight x v ^ (3/8 : ℝ) else 0) := by + by_cases hor : G e = s(u,v) ∧ u ∈ (S : Set V) ∧ v ∉ (S : Set V) + · rw [ite_eq_left hor] + exact (averaged_ghostBridge_quarter_weight_le G hc hl p hp hfin K hbound S x e u v + hor.1 hor.2.1 hor.2.2 h).trans_eq (by simp only [mul_assoc]) + · rw [ite_eq_right hor,mul_zero] + have hempty (m n : Set V) : {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro ω ⟨hpiv,hcl⟩ + apply hor + refine ⟨hpiv.2.1,?_,?_⟩ + · have hu : u ∈ cluster G (ω \ {e}) x := hpiv.2.2.1 + rw [hcl] at hu + exact hu + · intro hv + have hv' : v ∈ cluster G (ω \ {e}) x := by rw [hcl]; exact hv + exact hpiv.2.2.2.1 hv' + simp only [averagedQuarterBridge,hempty,measure_empty,lintegral_zero,le_refl] + +theorem averagedQuarterBridge_cluster_sum_le + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (K : ℝ) (hbound : ∀ x h, 0 ≤ h → + (criticalModel G).quarterGhostMagnetization p x h ≤ K*h^(3/4 : ℝ)) + (S : Finset V) (x : V) (h : ℝ≥0) : + (∑' e, ∑' u, ∑' v, averagedQuarterBridge G p x h e u v S) ≤ + ((ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ))) * + law p {ω | cluster G ω x = (S : Set V)} * + ghostAvoid (2*(h : ℝ)) (∑ y ∈ S, ((criticalModel G).quarterGhostWeight x y : ℝ≥0∞)) * + ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ))) * + (2 * ∑' e, if e ∈ (criticalModel G).incidentEdges (S : Set V) then + (criticalModel G).ghostBondWeight x e else 0) := by + let C := (ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ))) * + law p {ω | cluster G ω x = (S : Set V)} * + ghostAvoid (2*(h : ℝ)) (∑ y ∈ S, ((criticalModel G).quarterGhostWeight x y : ℝ≥0∞)) * + ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ)) + calc + _ ≤ ∑' e, ∑' u, ∑' v, C * (if G e = s(u,v) ∧ u ∈ (S : Set V) ∧ v ∉ (S : Set V) then + (criticalModel G).stabilizerWeight x v ^ (3/8 : ℝ) else 0) := by + apply ENNReal.tsum_le_tsum + intro e + apply ENNReal.tsum_le_tsum + intro u + exact ENNReal.tsum_le_tsum fun v => + averagedQuarterBridge_oriented_le G hc hl p hp hfin K hbound S x e u v h + _ = C * ∑' e, ∑' u, ∑' v, if G e = s(u,v) ∧ u ∈ (S : Set V) ∧ v ∉ (S : Set V) then + (criticalModel G).stabilizerWeight x v ^ (3/8 : ℝ) else 0 := by + simp_rw [ENNReal.tsum_mul_left] + _ ≤ C * ∑' e, if e ∈ (criticalModel G).incidentEdges (S : Set V) then + 2*(criticalModel G).ghostBondWeight x e else 0 := by + apply mul_le_mul' le_rfl + apply ENNReal.tsum_le_tsum + intro e + have he := oriented_pivotal_weight_le G (S : Set V) e + (fun v => (criticalModel G).stabilizerWeight x v ^ (3/8 : ℝ)) + convert he using 1 + · apply tsum_congr + intro u + apply tsum_congr + intro v + by_cases hor : G e = s(u,v) ∧ u ∈ (S : Set V) ∧ v ∉ (S : Set V) + · simp only [ite_eq_left hor] + · simp only [ite_eq_right hor] + · rfl + _ = _ := by + congr 1 + rw [←ENNReal.tsum_mul_left] + apply tsum_congr + intro e + split_ifs <;> simp + +theorem averagedQuarterBridge_sum_le_boundary + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (K : ℝ) (hbound : ∀ x h, 0 ≤ h → + (criticalModel G).quarterGhostMagnetization p x h ≤ K*h^(3/4 : ℝ)) + (x : V) (h : ℝ≥0) : + (∑' e, ∑' u, ∑' v, ∑' S, averagedQuarterBridge G p x h e u v S) ≤ + (2*(ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ)))* + ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ))) * + ∫⁻ ω, ghostAvoid (2*(h : ℝ)) ((criticalModel G).quarterTiltedMass ω x) * + (∑' e, if e ∈ (criticalModel G).incidentEdges (cluster G ω x) then + (criticalModel G).ghostBondWeight x e else 0) ∂law p := by + let H := criticalModel G + let R := ENNReal.ofReal (p : ℝ)/ENNReal.ofReal (1-(p : ℝ)) + let Q := ENNReal.ofReal (K^2*(h : ℝ)^(3/2 : ℝ)) + let F := fun S : Set V => ghostAvoid (2*(h : ℝ)) + (∑' y, if y ∈ S then (H.quarterGhostWeight x y : ℝ≥0∞) else 0) * + (∑' e, if e ∈ H.incidentEdges S then H.ghostBondWeight x e else 0) + have hF (S : Finset V) : F (S : Set V) = + ghostAvoid (2*(h : ℝ)) (∑ y ∈ S, (H.quarterGhostWeight x y : ℝ≥0∞)) * + (∑' e, if e ∈ H.incidentEdges (S : Set V) then H.ghostBondWeight x e else 0) := by + dsimp only [F] + apply congrArg (fun m => ghostAvoid (2*(h : ℝ)) m * + (∑' e, if e ∈ H.incidentEdges (S : Set V) then H.ghostBondWeight x e else 0)) + calc + _ = ∑' y, if y ∈ S then (H.quarterGhostWeight x y : ℝ≥0∞) else 0 := by + apply tsum_congr + intro y + by_cases hy : y ∈ S + · simp only [Finset.mem_coe,ite_eq_left hy] + · simp only [Finset.mem_coe,ite_eq_right hy] + _ = ∑ y ∈ S, (H.quarterGhostWeight x y : ℝ≥0∞) := by + rw [tsum_eq_sum (s := S) (fun y hy => ite_eq_right hy)] + apply Finset.sum_congr rfl + intro y hy + exact ite_eq_left hy + have hI : (∫⁻ ω, F (cluster G ω x) ∂law p) = + ∫⁻ ω, ghostAvoid (2*(h : ℝ)) (H.quarterTiltedMass ω x) * + (∑' e, if e ∈ H.incidentEdges (cluster G ω x) then H.ghostBondWeight x e else 0) ∂law p := by + apply lintegral_congr + intro ω + dsimp only [F] + congr 2 + unfold CriticalPercolation.BondGraph.quarterTiltedMass + apply tsum_congr + intro y + rw [H.coe_quarterGhostWeight] + congr 1 + rw [show H.openGraph ω = openSimpleGraph G ω from criticalModel_openGraph G ω] + exact propext (conn_iff_reachable G ω x y) + calc + _ = ∑' e, ∑' u, ∑' S, ∑' v, averagedQuarterBridge G p x h e u v S := + tsum_congr fun e => tsum_congr fun u => ENNReal.tsum_comm + _ = ∑' e, ∑' S, ∑' u, ∑' v, averagedQuarterBridge G p x h e u v S := + tsum_congr fun e => ENNReal.tsum_comm + _ = ∑' S, ∑' e, ∑' u, ∑' v, averagedQuarterBridge G p x h e u v S := ENNReal.tsum_comm + _ ≤ ∑' S : Finset V, (2*R*Q) * (law p {ω | cluster G ω x = (S : Set V)} * F (S : Set V)) := by + apply ENNReal.tsum_le_tsum + intro S + exact (averagedQuarterBridge_cluster_sum_le G hc hl p hp hfin K hbound S x h).trans_eq (by rw [hF]; dsimp [R,Q,H]; ac_rfl) + _ = (2*R*Q) * ∫⁻ ω, F (cluster G ω x) ∂law p := by + rw [ENNReal.tsum_mul_left] + congr 1 + have hf : ∀ᵐ ω ∂(criticalModel G).law p, ((criticalModel G).cluster ω x).Finite := by + change ∀ᵐ ω ∂law p, ((criticalModel G).cluster ω x).Finite + simpa only [criticalModel_cluster] using hfin x + have hh := ((criticalModel G).lintegral_eq_sum_finite_clusters p x hf F).symm + change (∑' S : Finset V, law p {ω | (criticalModel G).cluster ω x = (S : Set V)}*F (S : Set V)) = + ∫⁻ ω, F ((criticalModel G).cluster ω x) ∂law p at hh + simpa only [criticalModel_cluster] using hh + _ = _ := by rw [hI] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ac7346b4ec18eb2f0a60af7c6c48a896241ad7b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalGeometry.lean @@ -0,0 +1,130 @@ +import OAI.Probability.BenjaminiSchramm.GhostFanBK + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma openSimpleGraph_delete_singleton (hG : Function.Injective G) (ω : Set E) (e : E) : + openSimpleGraph G (ω \ {e}) = (openSimpleGraph G ω).deleteEdges {G e} := by + ext u v + rw [SimpleGraph.deleteEdges_adj] + change (u ≠ v ∧ ∃ f ∈ ω \ {e}, G f = s(u,v)) ↔ + (u ≠ v ∧ ∃ f ∈ ω, G f = s(u,v)) ∧ s(u,v) ∉ ({G e} : Set (Sym2 V)) + constructor + · rintro ⟨hne,f,⟨hfw,hfe⟩,hf⟩ + exact ⟨⟨hne,f,hfw,hf⟩,fun heq => hfe (hG (hf.trans heq))⟩ + · rintro ⟨⟨hne,f,hfw,hf⟩,hfe⟩ + refine ⟨hne,f,⟨hfw,?_⟩,hf⟩ + intro he + exact hfe (by simpa only [Set.mem_singleton_iff] using (hf.symm.trans (congrArg G he))) + +def GhostBridgePivotal (ω : Set E) (m n : Set V) (x : V) (e : E) (u v : V) : Prop := + e ∈ ω ∧ G e = s(u,v) ∧ Conn G (ω \ {e}) x u ∧ ¬Conn G (ω \ {e}) x v ∧ + Disjoint (cluster G (ω \ {e}) x) m ∧ Disjoint (cluster G (ω \ {e}) x) n ∧ + (ω \ {e}) ∈ DisjointOccurrence (finiteGhostConnection G v id m) + (finiteGhostConnection G v id n) + +lemma two_ghost_connections_or_pivotal (hG : Function.Injective G) (ω : Set E) + (m n : Set V) (x : V) + (hm : ω ∈ finiteGhostConnection G x id m) (hn : ω ∈ finiteGhostConnection G x id n) : + ω ∈ DisjointOccurrence (finiteGhostConnection G x id m) (finiteGhostConnection G x id n) ∨ + ∃ e u v, GhostBridgePivotal G ω m n x e u v := by + obtain ⟨a,ha,hxa⟩ := hm + obtain ⟨b,hb,hxb⟩ := hn + have hm' : ∃ a ∈ m, (openSimpleGraph G ω).Reachable x a := + ⟨a,ha,(conn_iff_reachable G ω x a).mp hxa⟩ + have hn' : ∃ b ∈ n, (openSimpleGraph G ω).Reachable x b := + ⟨b,hb,(conn_iff_reachable G ω x b).mp hxb⟩ + rcases two_connections_fan_or_bridge hm' hn' with hfan | ⟨u,v,huv,he,hxu,hA,hB,hfan⟩ + · exact Or.inl (ghostFan_mem_disjointOccurrence G x id (by simpa using hfan)) + right + obtain ⟨_,e,heω,hGe⟩ := huv + have hdel : (openSimpleGraph G ω).deleteEdges {s(u,v)} = openSimpleGraph G (ω \ {e}) := by + rw [← hGe] + exact (openSimpleGraph_delete_singleton G hG ω e).symm + have hnot : ¬(openSimpleGraph G (ω \ {e})).Reachable x v := by + intro hxv + exact (SimpleGraph.isBridge_iff.mp he) (hxu.symm.trans (hdel.symm ▸ hxv)) + rw [hdel] at hxu hA hB hfan + refine ⟨e,u,v,heω,hGe,(conn_iff_reachable G _ x u).mpr hxu, + fun h => hnot ((conn_iff_reachable G _ x v).mp h),?_,?_,?_⟩ + · apply Set.disjoint_left.mpr + intro y hy hym + exact hA y hym ((conn_iff_reachable G _ x y).mp hy) + · apply Set.disjoint_left.mpr + intro y hy hyn + exact hB y hyn ((conn_iff_reachable G _ x y).mp hy) + · exact ghostFan_mem_disjointOccurrence G v id (by simpa using hfan) + +lemma measurableSet_ghostBridgePivotal [Countable V] [Countable E] + (x : V) (e : E) (u v : V) : + MeasurableSet {z : (Set V × Set V) × Set E | + GhostBridgePivotal G z.2 z.1.1 z.1.2 x e u v} := by + have hdel : Measurable (fun ω : Set E => ω \ {e}) := + measurable_set_iff.mpr fun f => (measurable_set_mem f).and measurable_const + have hc (y : V) : Measurable (fun z : (Set V × Set V) × Set E => + Conn G (z.2 \ {e}) x y) := + (measurableSet_conn G x y).mem.comp (hdel.comp measurable_snd) + have hm : Measurable (fun z : (Set V × Set V) × Set E => + Disjoint (cluster G (z.2 \ {e}) x) z.1.1) := by + have h := Measurable.forall fun y => (hc y).imp + (((measurable_set_mem y).comp (measurable_fst.comp measurable_fst)).not) + simpa only [Set.disjoint_left,cluster,Set.mem_ofPred_eq, Function.comp_def] using h + have hn : Measurable (fun z : (Set V × Set V) × Set E => + Disjoint (cluster G (z.2 \ {e}) x) z.1.2) := by + have h := Measurable.forall fun y => (hc y).imp + (((measurable_set_mem y).comp (measurable_snd.comp measurable_fst)).not) + simpa only [Set.disjoint_left,cluster,Set.mem_ofPred_eq, Function.comp_def] using h + have hdo := (measurableSet_ghostDisjointOccurrence G v id).preimage + (measurable_fst.prodMk (hdel.comp measurable_snd)) + exact (((measurable_set_mem e).comp measurable_snd).and + (measurable_const.and ((hc u).and ((hc v).not.and (hm.and (hn.and hdo.mem)))))).setOf + +lemma conn_exterior_witness {ω s : Set E} (x v y : V) (hs : s ⊆ ω) + (hv : ¬Conn G ω x v) (hvy : Conn G s v y) : + Conn G (s ∩ internalEdges G (cluster G ω x)ᶜ) v y := by + have hout (a : V) (ha : Conn G s v a) : a ∉ cluster G ω x := by + intro hxa + exact hv (hxa.trans (conn_symm G ω (conn_mono G hs ha))) + induction hvy with + | refl => exact conn_refl G _ v + | @tail a b hva hab ih => + obtain ⟨e,he,hGe⟩ := hab + exact ih.tail ⟨e,⟨he,(mem_internalEdges_of_ends G _ e a b hGe).mpr + ⟨hout a hva,hout b (hva.tail ⟨e,he,hGe⟩)⟩⟩,hGe⟩ + +lemma ghostDisjointOccurrence_exterior {ω : Set E} (x v : V) (m n : Set V) + (hv : ¬Conn G ω x v) + (h : ω ∈ DisjointOccurrence (finiteGhostConnection G v id m) + (finiteGhostConnection G v id n)) : + (ω ∩ internalEdges G (cluster G ω x)ᶜ) ∈ + DisjointOccurrence (finiteGhostConnection G v id m) (finiteGhostConnection G v id n) := by + let I := internalEdges G (cluster G ω x)ᶜ + obtain ⟨s,t,hs,ht,hst,⟨a,ha,hva⟩,⟨b,hb,hvb⟩⟩ := h + let s' := s.filter (fun e => e ∈ I) + let t' := t.filter (fun e => e ∈ I) + have hs' : (s' : Set E) = (s : Set E) ∩ I := by ext e; simp [s'] + have ht' : (t' : Set E) = (t : Set E) ∩ I := by ext e; simp [t'] + refine ⟨s',t',?_,?_,?_,?_,?_⟩ + · rw [hs'] + exact Set.inter_subset_inter_left _ hs + · rw [ht'] + exact Set.inter_subset_inter_left _ ht + · exact hst.mono (Finset.filter_subset _ _) (Finset.filter_subset _ _) + · refine ⟨a,ha,?_⟩ + rw [hs'] + exact conn_exterior_witness G x v a hs hv hva + · refine ⟨b,hb,?_⟩ + rw [ht'] + exact conn_exterior_witness G x v b ht hv hvb + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalIncidence.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..04e33c0c9c423bcdebb3ee03fe86abc54c06cac4 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalIncidence.lean @@ -0,0 +1,58 @@ +import OAI.Probability.BenjaminiSchramm.WeightedGhostIncidence +import OAI.Probability.BenjaminiSchramm.GhostPivotalWeight + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma oriented_pivotal_weight_le (S : Set V) (e : E) (w : V → ℝ≥0∞) : + (∑' u : V, ∑' v : V, + if G e = s(u,v) ∧ u ∈ S ∧ v ∉ S then w v else 0) ≤ + if e ∈ (criticalModel G).incidentEdges S then 2 * ∑ v ∈ (G e).toFinset, w v else 0 := by + let B := (G e).toFinset + by_cases he : e ∈ (criticalModel G).incidentEdges S + · rw [ite_eq_left he] + rw [tsum_eq_sum (s := B) (fun u hu => by + apply ENNReal.tsum_eq_zero.mpr + intro v + apply ite_eq_right + intro h + exact hu (Sym2.mem_toFinset.mpr (by rw [h.1]; simp)))] + have hrow (u : V) : + (∑' v : V, if G e = s(u,v) ∧ u ∈ S ∧ v ∉ S then w v else 0) ≤ ∑ v ∈ B, w v := by + rw [tsum_eq_sum (s := B) (fun v hv => by + apply ite_eq_right + intro h + exact hv (Sym2.mem_toFinset.mpr (by rw [h.1]; simp)))] + apply Finset.sum_le_sum + intro v _ + split_ifs <;> simp + calc + _ ≤ ∑ _u ∈ B, ∑ v ∈ B, w v := Finset.sum_le_sum fun u _ => hrow u + _ = (B.card : ℝ≥0∞) * ∑ v ∈ B, w v := by simp only [Finset.sum_const,nsmul_eq_mul] + _ ≤ _ := by + apply mul_le_mul' _ le_rfl + exact_mod_cast (show B.card ≤ 2 by + dsimp [B] + rw [Sym2.card_toFinset] + split_ifs <;> omega) + · rw [ite_eq_right he] + apply le_of_eq + apply ENNReal.tsum_eq_zero.mpr + intro u + apply ENNReal.tsum_eq_zero.mpr + intro v + apply ite_eq_right + intro h + exact he ⟨u,h.2.1,by change u ∈ G e; rw [h.1]; simp⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalProbability.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..41e9ab47f495259428e97c2fc6ae8ea82b52d442 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalProbability.lean @@ -0,0 +1,151 @@ +import OAI.Probability.BenjaminiSchramm.GhostPivotalGeometry +import OAI.Probability.BenjaminiSchramm.GhostPivotalBound +import OAI.Probability.BenjaminiSchramm.PivotalExposure +import OAI.Probability.BenjaminiSchramm.PhaseInput + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] [Countable E] in +lemma criticalModel_eraseVertices (ω : Set E) (S : Set V) : + (criticalModel G).eraseVertices ω S = ω ∩ internalEdges G Sᶜ := by + ext e + simp only [CriticalPercolation.BondGraph.eraseVertices, + CriticalPercolation.BondGraph.incidentEdges, criticalModel, Set.mem_sdiff, + Set.mem_inter_iff, internalEdges, Set.mem_ofPred_eq, Set.mem_compl_iff, + not_exists, not_and] + constructor + · rintro ⟨he,h⟩ + exact ⟨he,fun y hy hS => h y hS hy⟩ + · rintro ⟨he,h⟩ + exact ⟨he,fun y hS hy => h y hy hS⟩ + +omit [Countable V] [Countable E] in +lemma force_closed_eq_sdiff (ω : Set E) (e : E) : + CriticalPercolation.BernoulliProduct.forceOn {e} ∅ ω = ω \ {e} := by + ext f + by_cases hf : f = e <;> simp [hf] + +lemma measurableSet_ghostBridge_fixed_cluster (S : Set V) (x : V) (e : E) (u v : V) + (m n : Set V) : + MeasurableSet {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = S} := by + have hdel : Measurable (fun ω : Set E => ω \ {e}) := + measurable_set_iff.mpr fun f => (measurable_set_mem f).and measurable_const + have hp := (measurableSet_ghostBridgePivotal G x e u v).preimage + (show Measurable (fun ω : Set E => ((m,n),ω)) from + measurable_const.prodMk measurable_id) + have hc := ((criticalModel G).measurableSet_exactCluster x S).preimage hdel + simpa only [Set.preimage_ofPred_eq, Set.mem_ofPred_eq, criticalModel_cluster] using (hp.mem.and hc.mem).setOf + +theorem ghostBridge_fixed_cluster_measure_le (p : unitInterval) (hp : (p : ℝ) < 1) + (S : Set V) (x : V) (e : E) (u v : V) (hends : G e = s(u,v)) + (hu : u ∈ S) (hv : v ∉ S) (m n : Set V) : + law p {ω | GhostBridgePivotal G ω m n x e u v ∧ cluster G (ω \ {e}) x = S} ≤ + (ENNReal.ofReal (p : ℝ) / ENNReal.ofReal (1 - (p : ℝ))) * + law p {ω | cluster G ω x = S} * + (if Disjoint S m ∧ Disjoint S n then + law p (DisjointOccurrence (finiteGhostConnection G v id m) + (finiteGhostConnection G v id n)) else 0) := by + let D := DisjointOccurrence (finiteGhostConnection G v id m) (finiteGhostConnection G v id n) + have hD : MeasurableSet D := (measurableSet_ghostDisjointOccurrence G v id).preimage + (show Measurable (fun ω : Set E => ((m,n),ω)) from + measurable_const.prodMk measurable_id) + let F := D.indicator (fun _ : Set E => (1 : ℝ≥0∞)) + have hF : Measurable F := measurable_const.indicator hD + by_cases havoid : Disjoint S m ∧ Disjoint S n + · rw [ite_eq_left havoid] + have hpoint (ω : Set E) : + ({ω | GhostBridgePivotal G ω m n x e u v ∧ cluster G (ω \ {e}) x = S} : Set (Set E)).indicator + (fun _ => (1 : ℝ≥0∞)) ω ≤ + if e ∈ ω then ({η | (criticalModel G).cluster η x = S} : Set (Set E)).indicator + (fun η => F ((criticalModel G).eraseVertices η S)) + (CriticalPercolation.BernoulliProduct.forceOn {e} ∅ ω) else 0 := by + by_cases hω : GhostBridgePivotal G ω m n x e u v ∧ cluster G (ω \ {e}) x = S + · have horig := hω + obtain ⟨⟨he,_,_,hnot,_,_,hdo⟩,hcl⟩ := hω + have hd := ghostDisjointOccurrence_exterior G x v m n hnot hdo + rw [hcl] at hd + have hcl' : (criticalModel G).cluster + (CriticalPercolation.BernoulliProduct.forceOn {e} ∅ ω) x = S := by + rw [force_closed_eq_sdiff, criticalModel_cluster, hcl] + have hd' : (criticalModel G).eraseVertices + (CriticalPercolation.BernoulliProduct.forceOn {e} ∅ ω) S ∈ D := by + rw [force_closed_eq_sdiff, criticalModel_eraseVertices G] + exact hd + simp only [Set.indicator, Set.mem_ofPred_eq, ite_eq_left horig, ite_eq_left he, + ite_eq_left hcl', F, ite_eq_left hd', le_refl] + · simp only [Set.indicator, Set.mem_ofPred_eq, ite_eq_right hω] + exact bot_le + calc + _ = ∫⁻ ω, ({ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = S} : Set (Set E)).indicator (fun _ => (1 : ℝ≥0∞)) ω ∂law p := by + exact (lintegral_indicator_one (measurableSet_ghostBridge_fixed_cluster G S x e u v m n)).symm + _ ≤ _ := lintegral_mono hpoint + _ = _ := (criticalModel G).closed_cluster_pivotal_factor p hp x S e u v hends hu hv F hF + _ ≤ _ := by + simp only [criticalModel_cluster] + apply mul_le_mul' le_rfl + calc + _ ≤ ∫⁻ η, F η ∂(criticalModel G).law p := by + apply lintegral_mono + intro η + by_cases he : (criticalModel G).eraseVertices η S ∈ D + · have he' : η ∈ D := (disjointOccurrence_upper _ _) + (fun _ h => h.1) he + simp only [F, Set.indicator, ite_eq_left he, ite_eq_left he', le_refl] + · simp only [F, Set.indicator, ite_eq_right he] + exact bot_le + _ = _ := lintegral_indicator_one hD + · have he : {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = S} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro ω ⟨h,hcl⟩ + exact havoid (by simpa only [← hcl] using ⟨h.2.2.2.2.1,h.2.2.2.2.2.1⟩) + simp only [he,measure_empty,ite_eq_right havoid,mul_zero,le_refl] + +theorem averaged_ghostBridge_fixed_cluster_le (p : unitInterval) (hp : (p : ℝ) < 1) + (S : Finset V) (x : V) (e : E) (u v : V) (hends : G e = s(u,v)) + (hu : u ∈ S) (hv : v ∉ S) (h : ℝ≥0) (w : V → ℝ≥0) : + (∫⁻ m, ∫⁻ n, law p {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} ∂ghostFieldLaw h w ∂ghostFieldLaw h w) ≤ + (ENNReal.ofReal (p : ℝ) / ENNReal.ofReal (1 - (p : ℝ))) * + law p {ω | cluster G ω x = (S : Set V)} * + (ENNReal.ofReal (Real.exp (-(h : ℝ) * ∑ y ∈ S, (w y : ℝ)))) ^ 2 * + (∫⁻ m, law p (finiteGhostConnection G v id m) ∂ghostFieldLaw h w) ^ 2 := by + let C := (ENNReal.ofReal (p : ℝ) / ENNReal.ofReal (1 - (p : ℝ))) * + law p {ω | cluster G ω x = (S : Set V)} + have hC : C ≠ ⊤ := by + apply ENNReal.mul_ne_top + · rw [div_eq_mul_inv] + apply ENNReal.mul_ne_top ENNReal.ofReal_ne_top + exact ENNReal.inv_ne_top.mpr (ENNReal.ofReal_pos.mpr (sub_pos.mpr hp)).ne' + · exact measure_ne_top _ _ + calc + _ ≤ ∫⁻ m, ∫⁻ n, C * (if Disjoint (S : Set V) m ∧ Disjoint (S : Set V) n then + law p (DisjointOccurrence (finiteGhostConnection G v id m) + (finiteGhostConnection G v id n)) else 0) ∂ghostFieldLaw h w ∂ghostFieldLaw h w := by + apply lintegral_mono + intro m + apply lintegral_mono + intro n + exact ghostBridge_fixed_cluster_measure_le G p hp S x e u v hends hu hv m n + _ = C * (∫⁻ m, ∫⁻ n, if Disjoint (S : Set V) m ∧ Disjoint (S : Set V) n then + law p (DisjointOccurrence (finiteGhostConnection G v id m) + (finiteGhostConnection G v id n)) else 0 ∂ghostFieldLaw h w ∂ghostFieldLaw h w) := by + simp_rw [lintegral_const_mul' C _ hC] + _ ≤ _ := by + simpa only [C, mul_assoc] using mul_le_mul' (le_refl C) + (ghost_avoidance_bk G p v h w S) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalSum.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..ced3309b1d25988dd28a8b89910a2256e2ac09bc --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalSum.lean @@ -0,0 +1,92 @@ +import OAI.Probability.BenjaminiSchramm.GhostPivotalUnion +import OAI.Probability.BenjaminiSchramm.GhostPivotalIncidence +import OAI.Probability.BenjaminiSchramm.FiniteClusterSums +import OAI.Probability.BenjaminiSchramm.GhostDoubleConnection +import OAI.Probability.BenjaminiSchramm.GhostDerivative + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +theorem lintegral_twice_tsum {A I : Type*} [MeasurableSpace A] [Countable I] + (ν : Measure A) [SFinite ν] (F : I → A × A → ℝ≥0∞) + (hF : ∀ i, Measurable (F i)) : + (∫⁻ m, ∫⁻ n, ∑' i, F i (m,n) ∂ν ∂ν) = + ∑' i, ∫⁻ m, ∫⁻ n, F i (m,n) ∂ν ∂ν := by + calc + _ = ∫⁻ z, ∑' i, F i z ∂ν.prod ν := + (lintegral_prod _ (Measurable.tsum hF).aemeasurable).symm + _ = ∑' i, ∫⁻ z, F i z ∂ν.prod ν := lintegral_tsum (fun i => (hF i).aemeasurable) + _ = _ := tsum_congr fun i => lintegral_prod _ (hF i).aemeasurable + +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma measurable_ghostBridge_cluster_fields (p : unitInterval) (x : V) + (e : E) (u v : V) (S : Finset V) : + Measurable (fun z : Set V × Set V => law p {ω | + GhostBridgePivotal G ω z.1 z.2 x e u v ∧ cluster G (ω \ {e}) x = (S : Set V)}) := by + have hdel : Measurable (fun ω : Set E => ω \ {e}) := + measurable_set_iff.mpr fun f => (measurable_set_mem f).and measurable_const + have hm := (measurableSet_ghostBridgePivotal G x e u v).inter + ((((criticalModel G).measurableSet_exactCluster x (S : Set V)).preimage hdel).preimage measurable_snd) + convert measurable_measure_prodMk_left (ν := law p) hm using 1 + funext z + congr 1 + ext ω + simp only [Set.mem_inter_iff,Set.mem_preimage,Set.mem_ofPred_eq,criticalModel_cluster] + +theorem averaged_twoGhost_le_fan_add_pivotal_sum (hG : Function.Injective G) + (p : unitInterval) (x : V) (hfin : ∀ᵐ ω ∂law p, (cluster G ω x).Finite) + (ν : Measure (Set V)) [SFinite ν] : + (∫⁻ m, ∫⁻ n, law p (finiteGhostConnection G x id m ∩ finiteGhostConnection G x id n) ∂ν ∂ν) ≤ + (∫⁻ m, law p (finiteGhostConnection G x id m) ∂ν)^2 + + ∑' e : E, ∑' u : V, ∑' v : V, ∑' S : Finset V, + ∫⁻ m, ∫⁻ n, law p {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} ∂ν ∂ν := by + let F := fun e u v (S : Finset V) (z : Set V × Set V) => law p {ω | + GhostBridgePivotal G ω z.1 z.2 x e u v ∧ cluster G (ω \ {e}) x = (S : Set V)} + let D := fun z : Set V × Set V => law p + (DisjointOccurrence (finiteGhostConnection G x id z.1) (finiteGhostConnection G x id z.2)) + have hF (e : E) (u v : V) (S : Finset V) : Measurable (F e u v S) := + measurable_ghostBridge_cluster_fields G p x e u v S + have hD : Measurable D := measurable_measure_prodMk_left (ν := law p) + (measurableSet_ghostDisjointOccurrence G x id) + have hsum : (∫⁻ m, ∫⁻ n, ∑' e, ∑' u, ∑' v, ∑' S, F e u v S (m,n) ∂ν ∂ν) = + ∑' e, ∑' u, ∑' v, ∑' S, ∫⁻ m, ∫⁻ n, F e u v S (m,n) ∂ν ∂ν := by + rw [lintegral_twice_tsum ν _ (fun e => Measurable.tsum fun u => Measurable.tsum fun v => Measurable.tsum (hF e u v))] + apply tsum_congr + intro e + rw [lintegral_twice_tsum ν _ (fun u => Measurable.tsum fun v => Measurable.tsum (hF e u v))] + apply tsum_congr + intro u + rw [lintegral_twice_tsum ν _ (fun v => Measurable.tsum (hF e u v))] + apply tsum_congr + intro v + exact lintegral_twice_tsum ν _ (hF e u v) + calc + _ ≤ ∫⁻ m, ∫⁻ n, D (m,n) + ∑' e, ∑' u, ∑' v, ∑' S, F e u v S (m,n) ∂ν ∂ν := by + apply lintegral_mono + intro m + apply lintegral_mono + intro n + exact twoGhostConnection_le_fan_add_pivotal_sum G hG p x m n hfin + _ = (∫⁻ m, ∫⁻ n, D (m,n) ∂ν ∂ν) + + ∫⁻ m, ∫⁻ n, ∑' e, ∑' u, ∑' v, ∑' S, F e u v S (m,n) ∂ν ∂ν := by + have hM : Measurable (fun z => ∑' e, ∑' u, ∑' v, ∑' S, F e u v S z) := + Measurable.tsum fun e => Measurable.tsum fun u => Measurable.tsum fun v => Measurable.tsum (hF e u v) + have hDM : Measurable (fun z => D z + ∑' e, ∑' u, ∑' v, ∑' S, F e u v S z) := hD.add hM + rw [←lintegral_prod _ hDM.aemeasurable,lintegral_add_left hD _, + lintegral_prod _ hD.aemeasurable,lintegral_prod _ hM.aemeasurable] + _ ≤ _ := by + rw [hsum] + exact add_le_add (averaged_ghostConnection_bk G x id p ν) le_rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalUnion.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dabe287394f7adbfc41a53b4f4c534ebbd7370d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalUnion.lean @@ -0,0 +1,52 @@ +import OAI.Probability.BenjaminiSchramm.GhostPivotalGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem twoGhostConnection_le_fan_add_pivotal_sum (hG : Function.Injective G) + (p : unitInterval) (x : V) (m n : Set V) + (hfin : ∀ᵐ ω ∂law p, (cluster G ω x).Finite) : + law p (finiteGhostConnection G x id m ∩ finiteGhostConnection G x id n) ≤ + law p (DisjointOccurrence (finiteGhostConnection G x id m) + (finiteGhostConnection G x id n)) + + ∑' e : E, ∑' u : V, ∑' v : V, ∑' S : Finset V, + law p {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} := by + let D := DisjointOccurrence (finiteGhostConnection G x id m) (finiteGhostConnection G x id n) + let A := fun e u v (S : Finset V) => {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} + have hsub : (finiteGhostConnection G x id m ∩ finiteGhostConnection G x id n) + ≤ᵐ[law p] D ∪ ⋃ e, ⋃ u, ⋃ v, ⋃ S, A e u v S := by + filter_upwards [hfin] with ω hω hm + rcases two_ghost_connections_or_pivotal G hG ω m n x hm.1 hm.2 with hd | ⟨e,u,v,hp⟩ + · exact Or.inl hd + · have hf : (cluster G (ω \ {e}) x).Finite := + hω.subset (fun _ h => conn_mono G Set.sdiff_subset h) + apply Or.inr + exact Set.mem_iUnion.mpr ⟨e,Set.mem_iUnion.mpr ⟨u,Set.mem_iUnion.mpr ⟨v, + Set.mem_iUnion.mpr ⟨hf.toFinset,hp,hf.coe_toFinset.symm⟩⟩⟩⟩ + calc + _ ≤ law p (D ∪ ⋃ e, ⋃ u, ⋃ v, ⋃ S, A e u v S) := measure_mono_ae hsub + _ ≤ law p D + law p (⋃ e, ⋃ u, ⋃ v, ⋃ S, A e u v S) := measure_union_le _ _ + _ ≤ law p D + ∑' e, law p (⋃ u, ⋃ v, ⋃ S, A e u v S) := + add_le_add le_rfl (measure_iUnion_le _) + _ ≤ law p D + ∑' e, ∑' u, law p (⋃ v, ⋃ S, A e u v S) := + add_le_add le_rfl (ENNReal.tsum_le_tsum fun e : E => measure_iUnion_le _) + _ ≤ law p D + ∑' e, ∑' u, ∑' v, law p (⋃ S, A e u v S) := + add_le_add le_rfl (ENNReal.tsum_le_tsum fun e : E => + ENNReal.tsum_le_tsum fun u : V => measure_iUnion_le _) + _ ≤ _ := add_le_add le_rfl (ENNReal.tsum_le_tsum fun e : E => + ENNReal.tsum_le_tsum fun u : V => ENNReal.tsum_le_tsum fun v : V => + measure_iUnion_le (fun S : Finset V => A e u v S)) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalWeight.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..58638f5deaac9a69e78f78b7726d73ace83b9690 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostPivotalWeight.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.GhostPivotalProbability +import OAI.Probability.BenjaminiSchramm.GhostMomentBound +import OAI.Probability.BenjaminiSchramm.GhostTiltedTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal NNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] [Countable E] in +lemma criticalModel_finiteGhostConnection (x : V) (m : Set V) : + finiteGhostConnection G x id m = + {ω | ∃ y ∈ m, ((criticalModel G).openGraph ω).Reachable x y} := by + ext ω + simp only [finiteGhostConnection, Set.mem_ofPred_eq, criticalModel_openGraph] + exact exists_congr fun y => and_congr_right fun _ => conn_iff_reachable G ω x y + +omit [Countable V] [Countable E] in +lemma ghostAvoid_finite_sum (h : ℝ) (w : V → ℝ≥0) (S : Finset V) : + ghostAvoid h (∑ y ∈ S, (w y : ℝ≥0∞)) = + ENNReal.ofReal (Real.exp (-h * ∑ y ∈ S, (w y : ℝ))) := by + have hfin : (∑ y ∈ S, (w y : ℝ≥0∞)) ≠ ⊤ := + (ENNReal.sum_lt_top.mpr fun _ _ => ENNReal.coe_lt_top).ne + rw [ghostAvoid,ite_eq_right hfin,ENNReal.toReal_sum (fun _ _ => ENNReal.coe_ne_top)] + simp only [ENNReal.coe_toReal] + +omit [Countable V] [Countable E] in +lemma exp_avoidance_sq (h : ℝ) (w : V → ℝ≥0) (S : Finset V) : + ENNReal.ofReal (Real.exp (-h * ∑ y ∈ S, (w y : ℝ))) ^ 2 = + ghostAvoid (2*h) (∑ y ∈ S, (w y : ℝ≥0∞)) := by + rw [ghostAvoid_finite_sum, pow_two, ← ENNReal.ofReal_mul (Real.exp_pos _).le, + ← Real.exp_add] + congr 2 + ring + +theorem averaged_ghostBridge_quarter_weight_le + (hc : (criticalModel G).fullGraph.Connected) (hl : LocallyFinite G) + (p : unitInterval) (hp : (p : ℝ) < 1) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G ω v).Finite) + (K : ℝ) (hbound : ∀ x h, 0 ≤ h → + (criticalModel G).quarterGhostMagnetization p x h ≤ K * h ^ (3/4 : ℝ)) + (S : Finset V) (x : V) (e : E) (u v : V) (hends : G e = s(u,v)) + (hu : u ∈ S) (hv : v ∉ S) (h : ℝ≥0) : + (∫⁻ m, ∫⁻ n, law p {ω | GhostBridgePivotal G ω m n x e u v ∧ + cluster G (ω \ {e}) x = (S : Set V)} + ∂ghostFieldLaw h ((criticalModel G).quarterGhostWeight x) + ∂ghostFieldLaw h ((criticalModel G).quarterGhostWeight x)) ≤ + (ENNReal.ofReal (p : ℝ) / ENNReal.ofReal (1 - (p : ℝ))) * + law p {ω | cluster G ω x = (S : Set V)} * + ghostAvoid (2*(h : ℝ)) (∑ y ∈ S, ((criticalModel G).quarterGhostWeight x y : ℝ≥0∞)) * + (ENNReal.ofReal (K^2 * (h : ℝ)^(3/2 : ℝ)) * + (criticalModel G).stabilizerWeight x v ^ (3/8 : ℝ)) := by + let H := criticalModel G + have hf : ∀ᵐ ω ∂H.law p, (H.cluster ω v).Finite := by + rw [show H.law p = (law p : Measure (Set E)) from rfl] + simpa only [H,criticalModel_cluster] using hfin v + have haverage : (∫⁻ m, law p (finiteGhostConnection G v id m) + ∂ghostFieldLaw h (H.quarterGhostWeight x)) = + ENNReal.ofReal (H.quarterGhostMagnetization p v (h * H.quarterGhostWeight x v)) := by + simp_rw [criticalModel_finiteGhostConnection G] + exact H.quarterGhostConnection_change_base hc hl p x v h hf + have hsquare : ENNReal.ofReal (H.quarterGhostMagnetization p v + (h * H.quarterGhostWeight x v)) ^ 2 ≤ + ENNReal.ofReal (K^2 * (h : ℝ)^(3/2 : ℝ)) * H.stabilizerWeight x v ^ (3/8 : ℝ) := by + have hnonneg : 0 ≤ H.quarterGhostMagnetization p v (h * H.quarterGhostWeight x v) := + integral_nonneg fun _ => ghostKernel_nonneg (by positivity) ENNReal.toReal_nonneg + rw [← ENNReal.ofReal_pow hnonneg] + have hb := ENNReal.ofReal_le_ofReal (H.rebased_quarterGhost_square_bound hbound x v h.2) + rw [ENNReal.ofReal_mul (mul_nonneg (sq_nonneg K) (Real.rpow_nonneg h.2 _)), + ENNReal.ofReal_toReal + (ENNReal.rpow_ne_top_of_nonneg (by norm_num) (H.stabilizerWeight_ne_top x v))] at hb + exact hb + have hb := averaged_ghostBridge_fixed_cluster_le G p hp S x e u v hends hu hv h + (H.quarterGhostWeight x) + rw [exp_avoidance_sq, haverage] at hb + exact hb.trans (mul_le_mul' le_rfl hsquare) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostTail.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa35be2b90fe890343ffda1c15231844ea4997a3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostTail.lean @@ -0,0 +1,101 @@ +import OAI.Probability.UnimodularPercolation.Exploration.TailBounds + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem seeded_revealment_of_ghost_bound (G : BondGraph V E) (Q : Finset E) + (x : V) (p h : unitInterval) (B : ℝ) + (hB : ∀ y, markedConnectionPolynomial G Q y h p ≤ B) : + ∀ i ∈ Q, bernoulliPolynomial (insert x (searchVertices G Q)) + (fun m => (seededEdgeSearch G x Q.card Q m).revealment p i) h ≤ 2 * B := by + intro i hi + obtain ⟨⟨a,b⟩,he⟩ := Quot.exists_rep (G i) + have he' : G i = s(a,b) := he.symm + have hFa : insert a (searchVertices G Q) ⊆ insert x (searchVertices G Q) := + Finset.insert_subset_iff.mpr ⟨Finset.mem_insert_of_mem + (mem_searchVertices G hi (by rw [he']; simp)),Finset.subset_insert _ _⟩ + have hFb : insert b (searchVertices G Q) ⊆ insert x (searchVertices G Q) := + Finset.insert_subset_iff.mpr ⟨Finset.mem_insert_of_mem + (mem_searchVertices G hi (by rw [he']; simp)),Finset.subset_insert _ _⟩ + have ha := hB a + have hb := hB b + rw [←finiteSeedProbability_expectation G Q _ a hFa] at ha + rw [←finiteSeedProbability_expectation G Q _ b hFb] at hb + have hr := seededEdgeSearch_mean_revealment_le G x Q + (insert x (searchVertices G Q)) p h i a b he' + linarith + +theorem covariance_of_ghost_bound (G : BondGraph V E) (Q : Finset E) + (x : V) (p h : unitInterval) (B : ℝ) + (hB : ∀ y, markedConnectionPolynomial G Q y h p ≤ B) + (f : Finset E → ℝ) (hf : Monotone f) : + |finiteCovariance Q p f + (fun ω => finiteSeedProbability G (insert x (searchVertices G Q)) ω x h)| ≤ + (2 * B) * ((p : ℝ) * (1 - p)) * deriv (bernoulliPolynomial Q f) p := by + have hc := EdgeQueryTree.randomized_covariance_le_deriv Q + (insert x (searchVertices G Q)) p h f hf + (fun m => seededEdgeSearch G x Q.card Q m) + (fun _ _ => seededEdgeSearch_valid G x Q.card Q _) + (2 * B) (seeded_revealment_of_ghost_bound G Q x p h B hB) + convert hc using 2 + apply finiteCovariance_congr_right + intro ω hω + exact finiteSeedProbability_tree G Q _ x h ω hω + +theorem tail_derivative_of_ghost_bound (G : BondGraph V E) (Q : Finset E) + (x : V) (n : ℕ) (p h : unitInterval) (B : ℝ) + (hn : 1 ≤ (h : ℝ) * n) (hB0 : 0 ≤ B) (hsmall : B ≤ 1 / 4) + (hB : ∀ y, markedConnectionPolynomial G Q y h p ≤ B) : + finiteClusterTail G Q x n p ≤ 8 * B * deriv (finiteClusterTail G Q x n) p := by + have hlow := finiteSeed_covariance_lower G Q x n p h hn B (hB x) + have hupp := covariance_of_ghost_bound G Q x p h B hB + (finiteClusterTailIndicator G x n) (finiteClusterTailIndicator_mono G x n) + have hF := finiteClusterTail_nonneg G Q x n p + have hd := finiteClusterTail_deriv_nonneg G Q x n p + have hp : (p : ℝ) * (1 - p) ≤ 1 := by nlinarith [p.2.1,p.2.2] + have hprod := mul_le_mul_of_nonneg_right hp hd + have hh := mul_le_mul_of_nonneg_left hprod (show 0 ≤ 2 * B by positivity) + have ha := le_abs_self (finiteCovariance Q p (finiteClusterTailIndicator G x n) + (fun ω => finiteSeedProbability G (insert x (searchVertices G Q)) ω x h)) + have hs := mul_le_mul_of_nonneg_right hsmall hF + change |_| ≤ _ * deriv (finiteClusterTail G Q x n) p at hupp + nlinarith + +theorem tail_transfer_of_ghost_bound (G : BondGraph V E) (Q : Finset E) + (x : V) (n : ℕ) (p q h : unitInterval) (B : ℝ) (hpq : p ≤ q) + (hn : 1 ≤ (h : ℝ) * n) (hB0 : 0 < B) (hsmall : B ≤ 1 / 4) + (hB : ∀ r : unitInterval, p ≤ r → r ≤ q → + ∀ y, markedConnectionPolynomial G Q y h r ≤ B) : + finiteClusterTail G Q x n p ≤ + Real.exp (-((q : ℝ) - p) / (8 * B)) * (2 * B) := by + have hden : 0 < 8 * B := by positivity + have hder : ∀ t ∈ Set.Icc (p : ℝ) q, + (1 / (8 * B)) * finiteClusterTail G Q x n t ≤ + deriv (finiteClusterTail G Q x n) t := by + intro t ht + let r : unitInterval := ⟨t,⟨p.2.1.trans ht.1,ht.2.trans q.2.2⟩⟩ + have he := tail_derivative_of_ghost_bound G Q x n r h B hn hB0.le hsmall + (hB r ht.1 ht.2) + rw [one_div,mul_comm,←div_eq_mul_inv] + apply (div_le_iff₀ hden).mpr + simpa only [mul_comm (deriv (finiteClusterTail G Q x n) t)] using he + have he := exponential_transfer_of_deriv_lower (finiteClusterTail G Q x n) p q + (1 / (8 * B)) (fun t => (hasDerivAt_bernoulliPolynomial Q _ t).differentiableAt) + hpq hder + have hb := (finiteClusterTail_le_markedConnection G Q x n q h hn).trans + (mul_le_mul_of_nonneg_left (hB q hpq le_rfl x) (by norm_num : (0 : ℝ) ≤ 2)) + have heq : -(1 / (8 * B)) * ((q : ℝ) - p) = -((q : ℝ) - p) / (8 * B) := by ring + rw [heq] at he + exact he.trans (mul_le_mul_of_nonneg_left hb (Real.exp_pos _).le) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostTiltedTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostTiltedTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfce35718f55d77e03aa889cc491bd5ac2c6fee6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostTiltedTransport.lean @@ -0,0 +1,158 @@ +import OAI.Probability.BenjaminiSchramm.TiltedGhostSusceptibility + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +def ghostAvoid (h : ℝ) (m : ℝ≥0∞) : ℝ≥0∞ := + if m = ⊤ then 0 else ENNReal.ofReal (Real.exp (-h * m.toReal)) + +lemma measurable_ghostAvoid (h : ℝ) : Measurable (ghostAvoid h) := by + exact measurable_const.ite (measurableSet_eq_fun measurable_id measurable_const) + ((measurable_const.mul measurable_id.ennreal_toReal).exp.ennreal_ofReal) + +lemma ghostAvoid_antitone {h : ℝ} (hh : 0 ≤ h) : Antitone (ghostAvoid h) := by + intro m n hmn + by_cases hn : n = ⊤ + · simp [ghostAvoid, hn] + · have hm : m ≠ ⊤ := ne_top_of_le_ne_top hn hmn + rw [ghostAvoid, ite_eq_right hn, ghostAvoid, ite_eq_right hm] + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonpos_left (ENNReal.toReal_mono hn hmn) (neg_nonpos.mpr hh) + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm + +variable {V E : Type*} (G : BondGraph V E) + +def ghostHighTransport (h : ℝ) (ω : Set E) (x y : V) : ℝ≥0∞ := + if (G.openGraph ω).Reachable x y ∧ 1 < G.stabilizerWeight x y then + ghostAvoid h (G.quarterTiltedMass ω x) * G.stabilizerWeight x y ^ (3 / 8 : ℝ) + else 0 + +lemma measurable_ghostHighTransport [Countable V] [Countable E] + (h : ℝ) (x y : V) : Measurable (fun ω => G.ghostHighTransport h ω x y) := by + exact (((measurable_ghostAvoid h).comp (G.measurable_quarterTiltedMass x)).mul_const _).ite + ((G.measurable_reachable x y).and measurable_const).setOf measurable_const + +lemma ghostHighTransport_aut (h : ℝ) (φ : G.Aut) (ω : Set E) (x y : V) : + G.ghostHighTransport h (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.ghostHighTransport h ω x y := by + unfold ghostHighTransport + rw [Aut.stabilizerWeight, G.quarterTiltedMass_aut] + congr 1 + exact propext (and_congr (SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω)) Iff.rfl) + +lemma ghostHighTransport_incoming_le + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + {h : ℝ} (hh : 0 ≤ h) (ω : Set E) (y : V) : + (∑' x, G.ghostHighTransport h ω x y * G.stabilizerWeight y x) ≤ + ghostAvoid h (G.quarterTiltedMass ω y) * G.quarterTiltedMass ω y := by + rw [quarterTiltedMass, ← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro x + unfold ghostHighTransport + by_cases hr : (G.openGraph ω).Reachable x y + · have hr' := hr.symm + simp only [hr, hr', true_and, ↓reduceIte] + by_cases hw : 1 < G.stabilizerWeight x y + · rw [ite_eq_left hw] + have hmass : G.quarterTiltedMass ω y ≤ G.quarterTiltedMass ω x := by + rw [G.quarterTiltedMass_change_base hc hl ω hr'] + calc + _ = 1 * G.quarterTiltedMass ω y := (one_mul _).symm + _ ≤ _ := mul_le_mul' (ENNReal.one_le_rpow hw.le (by norm_num)) le_rfl + have ha := ghostAvoid_antitone hh hmass + have hrev : G.stabilizerWeight y x ≤ 1 := by + rw [← G.stabilizerWeight_inv hc hl x y] + exact ENNReal.inv_le_one.mpr hw.le + have hp : G.stabilizerWeight x y ^ (3 / 8 : ℝ) * G.stabilizerWeight y x ≤ + G.stabilizerWeight y x ^ (1 / 4 : ℝ) := by + rw [← G.stabilizerWeight_inv hc hl y x, ENNReal.inv_rpow, ← ENNReal.rpow_neg] + nth_rw 2 [← ENNReal.rpow_one (G.stabilizerWeight y x)] + rw [← ENNReal.rpow_add _ _ (G.stabilizerWeight_pos hc hl y x).ne' + (G.stabilizerWeight_ne_top y x)] + exact ENNReal.rpow_le_rpow_of_exponent_ge hrev (by norm_num) + calc + _ = ghostAvoid h (G.quarterTiltedMass ω x) * + (G.stabilizerWeight x y ^ (3 / 8 : ℝ) * G.stabilizerWeight y x) := by ac_rfl + _ ≤ _ := mul_le_mul' ha hp + · simp [hw] + · have hr' : ¬ (G.openGraph ω).Reachable y x := fun h => hr h.symm + simp [hr,hr'] + +theorem ghostHighTransport_expected_le [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) {h : ℝ} (hh : 0 ≤ h) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ∑' y, G.ghostHighTransport h ω x y ∂G.law p) ≤ + ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ghostAvoid h (G.quarterTiltedMass ω x) * G.quarterTiltedMass ω x ∂G.law p := by + rw [OrbitRepresentatives.random_tilted_transport G (G.orbitRepresentatives hq) hc hl p + (G.ghostHighTransport h) (G.measurable_ghostHighTransport h) (G.ghostHighTransport_aut h)] + apply Finset.sum_le_sum + intro y _ + exact lintegral_mono fun ω => G.ghostHighTransport_incoming_le hc hl hh ω y + +def ghostWeightedCount (h : ℝ) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, if (G.openGraph ω).Reachable x y then + ghostAvoid h (G.quarterTiltedMass ω x) * G.stabilizerWeight x y ^ (3 / 8 : ℝ) else 0 + +lemma ghostWeightedCount_le (h : ℝ) (ω : Set E) (x : V) : + G.ghostWeightedCount h ω x ≤ + ghostAvoid h (G.quarterTiltedMass ω x) * G.quarterTiltedMass ω x + + ∑' y, G.ghostHighTransport h ω x y := by + rw [quarterTiltedMass, ← ENNReal.tsum_mul_left, ← ENNReal.tsum_add] + apply ENNReal.tsum_le_tsum + intro y + unfold ghostHighTransport + by_cases hr : (G.openGraph ω).Reachable x y + · simp only [hr, true_and, ↓reduceIte] + by_cases hw : 1 < G.stabilizerWeight x y + · rw [ite_eq_left hw] + exact le_add_left le_rfl + · rw [ite_eq_right hw, add_zero] + exact mul_le_mul' le_rfl + (ENNReal.rpow_le_rpow_of_exponent_ge (le_of_not_gt hw) (by norm_num)) + · simp [hr] + +theorem expected_ghostWeightedCount_le [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) {h : ℝ} (hh : 0 ≤ h) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, G.ghostWeightedCount h ω x ∂G.law p) ≤ + 2 * ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ghostAvoid h (G.quarterTiltedMass ω x) * G.quarterTiltedMass ω x ∂G.law p := by + calc + _ ≤ ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ghostAvoid h (G.quarterTiltedMass ω x) * G.quarterTiltedMass ω x + + ∑' y, G.ghostHighTransport h ω x y ∂G.law p := by + apply Finset.sum_le_sum + intro x _ + exact lintegral_mono fun ω => G.ghostWeightedCount_le h ω x + _ = (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ghostAvoid h (G.quarterTiltedMass ω x) * G.quarterTiltedMass ω x ∂G.law p) + + ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ∑' y, G.ghostHighTransport h ω x y ∂G.law p := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + exact lintegral_add_left + (((measurable_ghostAvoid h).comp (G.measurable_quarterTiltedMass x)).mul + (G.measurable_quarterTiltedMass x)) _ + _ ≤ _ := by + rw [two_mul] + exact add_le_add le_rfl (G.ghostHighTransport_expected_le hc hl hq p hh) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/GhostVolume.lean b/lean/OAI/Probability/BenjaminiSchramm/GhostVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..a597c26ddf5cdfe920531904a0db4430a133210f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/GhostVolume.lean @@ -0,0 +1,144 @@ +import OAI.Probability.BenjaminiSchramm.GhostTail +import OAI.Probability.BenjaminiSchramm.EventMeasurability + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +open MeasureTheory + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem markedConnection_le_truncated_tails (G : BondGraph V E) (Q : Finset E) + (x : V) (p h : unitInterval) (N : ℕ) : + markedConnectionPolynomial G Q x h p ≤ + (h : ℝ) * (∑ i ∈ Finset.range N, finiteClusterTail G Q x (i + 1) p) + + finiteClusterTail G Q x N p := by + rw [markedConnection_component_polynomial] + simp only [finiteClusterTail] + rw [←bernoulliPolynomial_sum,←bernoulliPolynomial_const_mul,←bernoulliPolynomial_add] + apply bernoulliPolynomial_mono _ _ _ p p.2 + intro ω _ + let m := (finiteRootComponent G ω x).card + change 1 - (1 - (h : ℝ)) ^ m ≤ + (h : ℝ) * (∑ i ∈ Finset.range N, if i + 1 ≤ m then (1 : ℝ) else 0) + + if N ≤ m then (1 : ℝ) else 0 + by_cases hm : m ≤ N + · rw [←natCast_eq_sum_tail m N hm] + exact (one_sub_pow_one_sub_le h m).trans + (le_add_of_nonneg_right (by split_ifs <;> norm_num)) + · have hNm : N ≤ m := by omega + rw [ite_eq_left hNm] + have hs : 0 ≤ (h : ℝ) * + (∑ i ∈ Finset.range N, if i + 1 ≤ m then (1 : ℝ) else 0) := + mul_nonneg h.2.1 (Finset.sum_nonneg (fun _ _ => by split_ifs <;> norm_num)) + have hp := pow_nonneg (sub_nonneg.mpr h.2.2) m + linarith + +theorem inverse_sqrt_step (n : ℕ) : + 1 / Real.sqrt (n + 1 : ℕ) ≤ + 2 * (Real.sqrt (n + 1 : ℕ) - Real.sqrt n) := by + have ha : 0 < Real.sqrt (n + 1 : ℕ) := Real.sqrt_pos.2 (by positivity) + have hb := Real.sqrt_nonneg (n : ℝ) + have hab : Real.sqrt (n : ℝ) ≤ Real.sqrt (n + 1 : ℕ) := + Real.sqrt_le_sqrt (by exact_mod_cast Nat.le_succ n) + have ha2 := Real.sq_sqrt (show 0 ≤ ((n + 1 : ℕ) : ℝ) by positivity) + have hb2 := Real.sq_sqrt (show 0 ≤ (n : ℝ) by positivity) + apply (div_le_iff₀ ha).mpr + have hdiff := sq_nonneg (Real.sqrt (n + 1 : ℕ) - Real.sqrt (n : ℝ)) + norm_num only [Nat.cast_add,Nat.cast_one] at ha2 + norm_num only [Nat.cast_add,Nat.cast_one] at ha hab hdiff ⊢ + nlinarith + +theorem sum_inverse_sqrt_le (N : ℕ) : + (∑ i ∈ Finset.range N, 1 / Real.sqrt (i + 1 : ℕ)) ≤ 2 * Real.sqrt N := by + induction N with + | zero => simp + | succ N ih => + rw [Finset.sum_range_succ] + have hs := inverse_sqrt_step N + linarith + +theorem markedConnection_le_sqrt_scale (G : BondGraph V E) (Q : Finset E) + (x : V) (p h : unitInterval) (m : ℕ) (hm : 0 < m) (C : ℝ) (hC : 0 ≤ C) + (hh : (h : ℝ) * (m : ℝ) ^ 2 ≤ 1) + (htail : ∀ n : ℕ, 0 < n → + finiteClusterTail G Q x n p ≤ C / Real.sqrt n) : + markedConnectionPolynomial G Q x h p ≤ 3 * C / m := by + have hmR : 0 < (m : ℝ) := by exact_mod_cast hm + have hmsq : 0 < m ^ 2 := pow_pos hm _ + have hs := Finset.sum_le_sum (s := Finset.range (m ^ 2)) + (fun i _ => htail (i + 1) (by omega)) + have hs' : (∑ i ∈ Finset.range (m ^ 2), finiteClusterTail G Q x (i + 1) p) ≤ + 2 * C * m := by + calc + _ ≤ ∑ i ∈ Finset.range (m ^ 2), C / Real.sqrt (i + 1 : ℕ) := hs + _ = C * (∑ i ∈ Finset.range (m ^ 2), 1 / Real.sqrt (i + 1 : ℕ)) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ ≤ C * (2 * Real.sqrt (m ^ 2 : ℕ)) := + mul_le_mul_of_nonneg_left (sum_inverse_sqrt_le (m ^ 2)) hC + _ = 2 * C * m := by + rw [Nat.cast_pow,Real.sqrt_sq (by positivity)] + ring + have ht := htail (m ^ 2) hmsq + rw [Nat.cast_pow,Real.sqrt_sq (by positivity)] at ht + have hmark := (markedConnection_le_truncated_tails G Q x p h (m ^ 2)).trans + (add_le_add (mul_le_mul_of_nonneg_left hs' h.2.1) ht) + apply hmark.trans + apply (le_div_iff₀ hmR).mpr + have hh' := mul_le_mul_of_nonneg_left hh (show 0 ≤ 2 * C by positivity) + have hCdiv : (C / (m : ℝ)) * m = C := div_mul_cancel₀ C hmR.ne' + nlinarith + +theorem finiteClusterTail_le_volume_probability [Countable E] + (G : BondGraph V E) (Q : Finset E) (x : V) (n : ℕ) (p : unitInterval) : + finiteClusterTail G Q x n p ≤ (law p (volumeEvent G x n)).toReal := by + let f (ω : Set E) : ℝ := if n ≤ (cluster G (ω ∩ (Q : Set E)) x).ncard then 1 else 0 + have hf : ∀ ω, f ω = f (ω ∩ (Q : Set E)) := by + intro ω + simp only [f,Set.inter_assoc,Set.inter_self] + have he : (∫ ω, f ω ∂law p) = finiteClusterTail G Q x n p := by + rw [integral_eq_bernoulliPolynomial Q p f hf] + apply bernoulliPolynomial_congr + intro ω hω + simp only [f,finiteClusterTailIndicator, + Set.inter_eq_left.mpr (show (ω : Set E) ⊆ Q from hω), + ←coe_finiteRootComponent,Set.ncard_coe_finset] + rw [←he] + change (∫ ω, f ω ∂law p) ≤ (law p).real (volumeEvent G x n) + rw [←integral_event_indicator p (volumeEvent G x n) + (measurableSet_volumeEvent G x n)] + apply integral_mono (integrable_finite_local Q p f hf) + (by simpa only [Set.indicator,Pi.one_apply] using! + (integrable_const (1 : ℝ)).indicator (measurableSet_volumeEvent G x n)) + intro ω + dsimp [f] + split_ifs with hn hv + · rfl + · exfalso + apply hv + change (n : ℕ∞) ≤ (cluster G ω x).encard + have hn' : (n : ℕ∞) ≤ ((cluster G (ω ∩ (Q : Set E)) x).ncard : ℕ∞) := by + exact_mod_cast hn + exact hn'.trans ((Set.ncard_le_encard _).trans + (Set.encard_le_encard (fun y hy => conn_mono G Set.inter_subset_left hy))) + · norm_num + · rfl + +theorem finiteClusterTail_le_criticalTail [Countable E] + (G : BondGraph V E) (Q : Finset E) (x : V) (n : ℕ) + (p : unitInterval) (hp : p ≤ pc G) : + finiteClusterTail G Q x n p ≤ criticalTail G (volumeEvent G) x n := by + have hmono := bernoulliPolynomial_monotoneOn Q (finiteClusterTailIndicator G x n) + (finiteClusterTailIndicator_mono G x n) + exact (hmono p.2 (pc G).2 hp).trans + (finiteClusterTail_le_volume_probability G Q x n (pc G)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceConcatenation.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceConcatenation.lean new file mode 100644 index 0000000000000000000000000000000000000000..63b3e58d828f7ea9e9a7f99aca4c444dc137f35f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceConcatenation.lean @@ -0,0 +1,140 @@ +import OAI.Probability.BenjaminiSchramm.FreshSlabConcatenation +import OAI.Probability.BenjaminiSchramm.SubcriticalUpward + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem halfspace_crossing_fresh_product [Encodable V] [Countable E] + (q : E → unitInterval) (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (x : V) (a b t : ℝ) (hx : a ≤ f x) (hxb : f x < b) (κ : ℝ≥0∞) + (hκ : ∀ z, b ≤ f z → f z ≤ b+R → + κ ≤ CriticalPercolation.BernoulliProduct.law q + (restrictedHit G (internalEdges G {v | b ≤ f v}) z {v | t ≤ f v})) : + CriticalPercolation.BernoulliProduct.law q + (restrictedHit G (internalEdges G {v | a ≤ f v}) x {v | b ≤ f v}) * κ ≤ + CriticalPercolation.BernoulliProduct.law q + (restrictedHit G (internalEdges G {v | a ≤ f v}) x {v | t ≤ f v}) := by + let I := lowerCrossingBlock G f a b R + let J := internalEdges G {v | b ≤ f v} + let A := {v | b ≤ f v ∧ f v ≤ b+R} + let B := {v | t ≤ f v} + have hstart : restrictedHit G (internalEdges G {v | a ≤ f v}) x {v | b ≤ f v} ⊆ + restrictedHit G I x A := by + intro ω hω + obtain ⟨y,hy,hxy⟩ := hω + obtain ⟨z,hz,hzR,hzconn⟩ := + conn_above_lower_first_crossing G f R hR hjump ω x y a b hx hxb hy hxy + exact ⟨z,⟨hz,hzR⟩,hzconn⟩ + have hfinish : I ∪ J ⊆ internalEdges G {v | a ≤ f v} := by + intro e he + rcases he with he | he + · exact internalEdges_mono G (fun _ h => h.1) he.1 + · exact internalEdges_mono G (show {v | b ≤ f v} ⊆ {v | a ≤ f v} + from fun _ h => (hx.trans hxb.le).trans h) he + calc + _ ≤ CriticalPercolation.BernoulliProduct.law q (restrictedHit G I x A) * κ := + mul_le_mul' (measure_mono hstart) le_rfl + _ ≤ CriticalPercolation.BernoulliProduct.law q (restrictedHit G (I ∪ J) x B) := + restrictedHit_fresh_concatenation G q I J + (lowerCrossingBlock_disjoint_upper G f a b R) x A B κ + (fun z hz => hκ z hz.1 hz.2) + _ ≤ _ := by + apply measure_mono + intro ω hω + obtain ⟨y,hy,hxy⟩ := hω + exact ⟨y,hy,conn_mono G (Set.inter_subset_inter_right _ hfinish) hxy⟩ + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def upwardHalfspaceHit (x : V) (t : ℝ) : Set (Set E) := + restrictedHit G.ends (Percolation.internalEdges G.ends {v | 0 ≤ G.modularLogHeight x v}) x + {v | t ≤ G.modularLogHeight x v} + +def infimalUpwardCrossing (p : unitInterval) (t : ℝ) : ℝ≥0∞ := + ⨅ x, G.law p (G.upwardHalfspaceHit x t) + +lemma upwardHalfspaceHit_zero (x : V) : G.upwardHalfspaceHit x 0 = Set.univ := by + apply Set.eq_univ_of_forall + intro ω + exact ⟨x,by simp,Percolation.conn_refl G.ends _ x⟩ + +@[simp] lemma infimalUpwardCrossing_zero [Nonempty V] (p : unitInterval) : + G.infimalUpwardCrossing p 0 = 1 := by + simp only [infimalUpwardCrossing,G.upwardHalfspaceHit_zero,measure_univ,ciInf_const] + +lemma upwardHalfspaceHit_upper (x : V) (t : ℝ) : IsUpperSet (G.upwardHalfspaceHit x t) := by + rintro ω η hωη ⟨y,hy,hxy⟩ + exact ⟨y,hy,Percolation.conn_mono G.ends (Set.inter_subset_inter_left _ hωη) hxy⟩ + +lemma upwardHalfspaceHit_finiteWitness (x : V) (t : ℝ) : + Percolation.FiniteWitness (G.upwardHalfspaceHit x t) := by + rintro ω ⟨y,hy,hxy⟩ + obtain ⟨s,hs,hconn⟩ := Percolation.finiteWitness_conn G.ends x y _ hxy + refine ⟨s,fun _ he => (hs he).1,y,hy,?_⟩ + exact Percolation.conn_mono G.ends (show (s : Set E) ⊆ (s : Set E) ∩ + Percolation.internalEdges G.ends {v | 0 ≤ G.modularLogHeight x v} + from fun _ he => ⟨he,(hs he).2⟩) hconn + +lemma measurableSet_upwardHalfspaceHit [Countable E] (x : V) (t : ℝ) : + MeasurableSet (G.upwardHalfspaceHit x t) := + Percolation.measurableSet_finiteWitness _ (G.upwardHalfspaceHit_upper x t) + (G.upwardHalfspaceHit_finiteWitness x t) + +theorem infimalUpwardCrossing_supermultiplicative [Encodable V] [Countable E] [Nonempty V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) {s t : ℝ} (hs : 0 ≤ s) (_ht : 0 ≤ t) : + G.infimalUpwardCrossing p s * G.infimalUpwardCrossing p t ≤ + G.infimalUpwardCrossing p (s+t) := by + by_cases hs0 : s = 0 + · simp only [hs0,zero_add,G.infimalUpwardCrossing_zero,one_mul,le_refl] + have hspos : 0 < s := lt_of_le_of_ne hs (Ne.symm hs0) + obtain ⟨K,hK⟩ := G.uniform_ball_bound hq 1 + let R := max 0 (Real.log (K : ℝ)) + have hR : 0 ≤ R := le_max_left _ _ + apply le_iInf + intro x + have hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → + |G.modularLogHeight x v-G.modularLogHeight x u| ≤ R := by + intro e u v hu hv + exact (G.modularLogHeight_edge_jump hc hl K hK x u v e hu hv).trans (le_max_right _ _) + have hcont (z : V) (hz : s ≤ G.modularLogHeight x z) (_hzR : G.modularLogHeight x z ≤ s+R) : + G.infimalUpwardCrossing p t ≤ BernoulliProduct.law (fun _ : E => p) + (restrictedHit G.ends (Percolation.internalEdges G.ends {v | s ≤ G.modularLogHeight x v}) + z {v | s+t ≤ G.modularLogHeight x v}) := by + apply (iInf_le (fun y => G.law p (G.upwardHalfspaceHit y t)) z).trans + rw [BernoulliProduct.law_const] + apply measure_mono + rintro ω ⟨y,hy,hzy⟩ + change t ≤ G.modularLogHeight z y at hy + refine ⟨y,?_,Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hzy⟩ + · change s+t ≤ G.modularLogHeight x y + rw [G.modularLogHeight_change_base hc hl x z y] + linarith + · intro v hv + change 0 ≤ G.modularLogHeight z v at hv + change s ≤ G.modularLogHeight x v + rw [G.modularLogHeight_change_base hc hl x z v] + linarith + have hprod := halfspace_crossing_fresh_product G.ends (fun _ : E => p) + (G.modularLogHeight x) R hR hjump x 0 s (s+t) (by simp) (by simpa using hspos) + (G.infimalUpwardCrossing p t) hcont + simp only [BernoulliProduct.law_const] at hprod + exact (mul_le_mul' (iInf_le (fun y => G.law p (G.upwardHalfspaceHit y s)) x) le_rfl).trans hprod + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFiniteShift.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFiniteShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..980f4ca4d06a0d37cde50b9af1487c38586dc97d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFiniteShift.lean @@ -0,0 +1,104 @@ +import OAI.Probability.BenjaminiSchramm.CeilingDownCrudeProfile + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma walk_fractional_layer_comparison (p : unitInterval) (I : Set E) + (D W Z : Set V) (hI : I ⊆ Percolation.internalEdges G.ends D) (hW : W ⊆ Z) + {x y : V} (w : G.fullGraph.Walk x y) (hw : ∀ v ∈ w.support, v ∈ D) + {q : ℝ} (hq : 0 ≤ q) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^w.length)* + (∫⁻ ω, (restrictedLayerCount G.ends I W ω y)^q ∂G.law p) ≤ + ∫⁻ ω, (restrictedLayerCount G.ends (Percolation.internalEdges G.ends D) Z ω x)^q ∂G.law p := by + let f : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by rw [←criticalModel_openGraph G.ends Set.univ]; exact h⟩ + obtain ⟨F,hF,hconn⟩ := walk_finite_open_restriction G.ends (w.map f) D (by + intro v hv + rw [SimpleGraph.Walk.support_map] at hv + have hv' : v ∈ w.support := by + change v ∈ w.support.map id at hv + simpa only [List.map_id_fun,id_eq] using hv + exact hw v hv') + have hcard : F.card ≤ w.length := by simpa only [SimpleGraph.Walk.length_map] using hF + have hcost : ENNReal.ofReal ((min (p : ℝ) (1-p))^w.length) ≤ + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) := by + apply ENNReal.ofReal_le_ofReal + exact pow_le_pow_of_le_one (le_min p.2.1 (sub_nonneg.mpr p.2.2)) + ((min_le_left _ _).trans p.2.2) hcard + exact (mul_le_mul' hcost le_rfl).trans + (forced_path_fractional_layer_comparison G.ends p F I _ W Z hI hW x y hconn hq) + +theorem fractional_ceiling_root_ascent + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (p : unitInterval) (k c B : ℝ) {x y : V} (w : G.fullGraph.Walk x y) + (hcy : c ≤ G.orbitAdjustedHeight a x y) + (hw : ∀ v ∈ w.support, G.orbitAdjustedHeight a x v ≤ G.orbitAdjustedHeight a x y) + {q : ℝ} (hq : 0 ≤ q) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^w.length)* + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ c}) + {v | -k-B ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+B} ω x)^q ∂G.law p) ≤ + ∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a y v ≤ 0}) + {v | -(k+G.orbitAdjustedHeight a x y)-B ≤ G.orbitAdjustedHeight a y v ∧ + G.orbitAdjustedHeight a y v ≤ -(k+G.orbitAdjustedHeight a x y)+B} ω y)^q ∂G.law p := by + rw [←SimpleGraph.Walk.length_reverse w] + apply G.walk_fractional_layer_comparison p _ _ _ _ _ _ w.reverse _ hq + · apply Percolation.internalEdges_mono G.ends + intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + change G.orbitAdjustedHeight a x v ≤ c at hv + change G.orbitAdjustedHeight a y v ≤ 0 + linarith + · intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + · intro v hv + have hv' : v ∈ w.support := by simpa only [SimpleGraph.Walk.support_reverse,List.mem_reverse] using hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + change G.orbitAdjustedHeight a y v ≤ 0 + linarith [hw v hv'] + +theorem fractional_floor_root_descent + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (p : unitInterval) (k c B : ℝ) {x y : V} (w : G.fullGraph.Walk x y) + (hcy : G.orbitAdjustedHeight a x y ≤ -c) + (hw : ∀ v ∈ w.support, G.orbitAdjustedHeight a x y ≤ G.orbitAdjustedHeight a x v) + {q : ℝ} (hq : 0 ≤ q) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^w.length)* + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -c ≤ G.orbitAdjustedHeight a x v}) + {v | k-B ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ k+B} ω x)^q ∂G.law p) ≤ + ∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight a y v}) + {v | (k-G.orbitAdjustedHeight a x y)-B ≤ G.orbitAdjustedHeight a y v ∧ + G.orbitAdjustedHeight a y v ≤ (k-G.orbitAdjustedHeight a x y)+B} ω y)^q ∂G.law p := by + rw [←SimpleGraph.Walk.length_reverse w] + apply G.walk_fractional_layer_comparison p _ _ _ _ _ _ w.reverse _ hq + · apply Percolation.internalEdges_mono G.ends + intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + change -c ≤ G.orbitAdjustedHeight a x v at hv + change 0 ≤ G.orbitAdjustedHeight a y v + linarith + · intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + · intro v hv + have hv' : v ∈ w.support := by simpa only [SimpleGraph.Walk.support_reverse,List.mem_reverse] using hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + change 0 ≤ G.orbitAdjustedHeight a y v + linarith [hw v hv'] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFiniteShiftProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFiniteShiftProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..755c271ccde20021a96519007e6527b9bdf5f883 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFiniteShiftProfile.lean @@ -0,0 +1,176 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShift + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem halfspace_ceiling_shift_profile_fixed [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) (ρ : ℝ) : + ∃ T : ℝ, 0 < T ∧ ∀ q : ℝ, 0 ≤ q → + (∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*k))) → + ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ c}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*k+T*c)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpaths⟩ := G.stationaryOrbitHeight_bounded_ascent_to_level + hc hl hq μ hμ hstat hu R hR hjump + let δ := min (p : ℝ) (1-p) + have hδ : 0 < δ := lt_min hp0 (sub_pos.mpr hp1) + have hδlt : δ < 1 := (min_le_left _ _).trans_lt hp1 + let s := -Real.log δ + have hs : 0 < s := neg_pos.mpr (Real.log_neg hδ hδlt) + let T := s*A+abs ρ + refine ⟨T,by dsimp [T]; positivity,fun q hq0 hprofile => ?_⟩ + obtain ⟨D,hD,hbound⟩ := hprofile + refine ⟨D*ENNReal.ofReal (Real.exp (s*B+abs ρ*R)), + ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top,fun k hk c hc0 x => ?_⟩ + obtain ⟨y,w,hlen,hylo,hyhi,hw⟩ := hpaths c hc0 x + have hXY := G.fractional_ceiling_root_ascent hc hl a p k c R w hylo (fun v hv => (hw v hv).2) hq0 + have hh := finite_energy_cancel_length _ _ δ A B c w.length hδ hδlt.le hlen hXY + have hshift := hbound (k+G.orbitAdjustedHeight a x y) (by linarith) y + apply hh.trans ((mul_le_mul' le_rfl hshift).trans ?_) + have hheight : 0 ≤ G.orbitAdjustedHeight a x y := hc0.trans hylo + have hr₁ := mul_le_mul_of_nonneg_right (le_abs_self ρ) hheight + have hr₂ := mul_le_mul_of_nonneg_left hyhi (abs_nonneg ρ) + have he : -Real.log δ*(A*c+B)+ρ*(k+G.orbitAdjustedHeight a x y) ≤ + (s*B+abs ρ*R)+(ρ*k+T*c) := by + dsimp [s,T] + nlinarith + calc + _ = D*ENNReal.ofReal (Real.exp (-Real.log δ*(A*c+B)+ρ*(k+G.orbitAdjustedHeight a x y))) := by + rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ D*ENNReal.ofReal (Real.exp ((s*B+abs ρ*R)+(ρ*k+T*c))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + +theorem halfspace_floor_shift_profile_fixed [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) (ρ : ℝ) : + ∃ T : ℝ, 0 < T ∧ ∀ q : ℝ, 0 ≤ q → + (∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*k))) → + ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -c ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*k+T*c)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpaths⟩ := G.stationaryOrbitHeight_bounded_descent_to_level + hc hl hq μ hμ hstat hu R hR hjump + let δ := min (p : ℝ) (1-p) + have hδ : 0 < δ := lt_min hp0 (sub_pos.mpr hp1) + have hδlt : δ < 1 := (min_le_left _ _).trans_lt hp1 + let s := -Real.log δ + have hs : 0 < s := neg_pos.mpr (Real.log_neg hδ hδlt) + let T := s*A+abs ρ + refine ⟨T,by dsimp [T]; positivity,fun q hq0 hprofile => ?_⟩ + obtain ⟨D,hD,hbound⟩ := hprofile + refine ⟨D*ENNReal.ofReal (Real.exp (s*B+abs ρ*R)), + ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top,fun k hk c hc0 x => ?_⟩ + obtain ⟨y,w,hlen,hylo,hyhi,hw⟩ := hpaths c hc0 x + have hXY := G.fractional_floor_root_descent hc hl a p k c R w hyhi (fun v hv => (hw v hv).1) hq0 + have hh := finite_energy_cancel_length _ _ δ A B c w.length hδ hδlt.le hlen hXY + have hshift := hbound (k-G.orbitAdjustedHeight a x y) (by linarith) y + apply hh.trans ((mul_le_mul' le_rfl hshift).trans ?_) + have hheight : 0 ≤ -G.orbitAdjustedHeight a x y := by linarith + have hr₁ := mul_le_mul_of_nonneg_right (le_abs_self ρ) hheight + have hr₂ := mul_le_mul_of_nonneg_left + (show -G.orbitAdjustedHeight a x y ≤ c+R by linarith) (abs_nonneg ρ) + have he : -Real.log δ*(A*c+B)+ρ*(k-G.orbitAdjustedHeight a x y) ≤ + (s*B+abs ρ*R)+(ρ*k+T*c) := by + dsimp [s,T] + nlinarith + calc + _ = D*ENNReal.ofReal (Real.exp (-Real.log δ*(A*c+B)+ρ*(k-G.orbitAdjustedHeight a x y))) := by + rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ D*ENNReal.ofReal (Real.exp ((s*B+abs ρ*R)+(ρ*k+T*c))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + +theorem halfspace_ceiling_shift_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) (ρ : ℝ) + (hprofile : ∀ q : ℝ, 0 < q → q < 1 → ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*k))) : + ∃ T : ℝ, 0 < T ∧ ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ c}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*k+T*c)) := by + obtain ⟨T,hT,hshift⟩ := G.halfspace_ceiling_shift_profile_fixed hc hl hq μ hμ hstat hu R hR hjump p hp0 hp1 ρ + exact ⟨T,hT,fun q hq0 hq1 => hshift q hq0.le (hprofile q hq0 hq1)⟩ + +theorem halfspace_floor_shift_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) (ρ : ℝ) + (hprofile : ∀ q : ℝ, 0 < q → q < 1 → ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*k))) : + ∃ T : ℝ, 0 < T ∧ ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -c ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*k+T*c)) := by + obtain ⟨T,hT,hshift⟩ := G.halfspace_floor_shift_profile_fixed hc hl hq μ hμ hstat hu R hR hjump p hp0 hp1 ρ + exact ⟨T,hT,fun q hq0 hq1 => hshift q hq0.le (hprofile q hq0 hq1)⟩ + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFractionalRecurrence.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFractionalRecurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..6432ed4606558a0859bf0e7081886bd6cd4931da --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceFractionalRecurrence.lean @@ -0,0 +1,101 @@ +import OAI.Probability.BenjaminiSchramm.SlabFractionalRecurrence + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma lower_halfspace_frontier_location (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) (J : Set E) (x : V) (hx : f x ≤ b) + {z : V} (hz : z ∈ openFrontier G (ω ∩ J) + (cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x)) : + b < f z ∧ f z ≤ b+R := by + obtain ⟨hz,u,hu,e,he,heq⟩ := hz + have hub := conn_internalEdges_end_mem G ω {v | f v ≤ b} hx hu + change f u ≤ b at hub + have hzb : ¬f z ≤ b := openFrontier_lowerCluster_outside G ω + {v | f v ≤ b} x hx ⟨hz,u,hu,e,he.1,heq⟩ + have hj := (abs_le.mp (hjump e u z (by rw [heq]; simp) (by rw [heq]; simp))).2 + exact ⟨lt_of_not_ge hzb,by linarith⟩ + +variable [Countable V] [Countable E] + +theorem lower_halfspace_newLayer_fractional_bound + (hloc : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hloc u).toFinset.card ≤ d) + (q : E → unitInterval) (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (J : Set E) (x : V) (hx : f x ≤ b) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x).Finite) + (A : Set V) {a c : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) + (hc : 0 < c) (hc1 : c ≤ 1) (L : ℝ≥0∞) + (hL : ∀ z, b < f z → f z ≤ b+R → + (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, newLayerCount G (internalEdges G {v | f v ≤ b}) J A ω x^(a*c) + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (d : ℝ≥0∞)^c*(∫⁻ ω, + restrictedLayerCount G (internalEdges G {v | f v ≤ b}) + {u | b-R ≤ f u ∧ f u ≤ b} ω x^c + ∂CriticalPercolation.BernoulliProduct.law q)*L^c := by + let I := internalEdges G {v | f v ≤ b} + let B := {u | b-R ≤ f u ∧ f u ≤ b} + have hfront : (∫⁻ ω, frontierCount G I J ω x^c + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (d : ℝ≥0∞)^c*∫⁻ ω, restrictedLayerCount G I B ω x^c + ∂CriticalPercolation.BernoulliProduct.law q := by + calc + _ ≤ ∫⁻ ω, ((d : ℝ≥0∞)*restrictedLayerCount G I B ω x)^c + ∂CriticalPercolation.BernoulliProduct.law q := by + apply lintegral_mono_ae + filter_upwards [hfin] with ω hω + exact ENNReal.rpow_le_rpow + (lower_halfspace_frontierCount_le_top_band G hloc d hd f R b hjump ω J x hx hω) hc.le + _ = _ := by + simp_rw [ENNReal.mul_rpow_of_nonneg _ _ hc.le] + exact lintegral_const_mul _ ((measurable_restrictedLayerCount G I B x).pow_const c) + have hnew := newLayerCount_fractional_bound_on_frontier G hloc q I J x hfin A + ha ha1 hc hc1 L {z | b < f z ∧ f z ≤ b+R} + (fun ω z hz => lower_halfspace_frontier_location G f R b hjump ω J x hx hz) + (fun z hz => hL z hz.1 hz.2) + exact hnew.trans (mul_le_mul' hfront le_rfl) + +theorem lower_halfspace_fractional_recurrence + (hloc : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hloc u).toFinset.card ≤ d) + (q : E → unitInterval) (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (J : Set E) (x : V) (hx : f x ≤ b) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x).Finite) + (A : Set V) {a c : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) + (hc : 0 < c) (hc1 : c ≤ 1) (L : ℝ≥0∞) + (hL : ∀ z, b < f z → f z ≤ b+R → + (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, restrictedLayerCount G J A ω x^(a*c) + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (∫⁻ ω, restrictedLayerCount G (internalEdges G {v | f v ≤ b}) A ω x^(a*c) + ∂CriticalPercolation.BernoulliProduct.law q)+ + (d : ℝ≥0∞)^c*(∫⁻ ω, + restrictedLayerCount G (internalEdges G {v | f v ≤ b}) + {u | b-R ≤ f u ∧ f u ≤ b} ω x^c + ∂CriticalPercolation.BernoulliProduct.law q)*L^c := by + have hac : a*c ≤ 1 := by + calc a*c ≤ a*1 := mul_le_mul_of_nonneg_left hc1 ha.le + _ ≤ 1 := by simpa only [mul_one] using ha1 + exact (restrictedLayerCount_fractional_increment G q _ J A x (mul_pos ha hc) hac).trans + (add_le_add le_rfl (lower_halfspace_newLayer_fractional_bound G hloc d hd q f R b + hjump J x hx hfin A ha ha1 hc hc1 L hL)) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceProfileBootstrap.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceProfileBootstrap.lean new file mode 100644 index 0000000000000000000000000000000000000000..b132dbef9f57a95ae08dc7c9c2f4d24a7e8901c5 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceProfileBootstrap.lean @@ -0,0 +1,174 @@ +import OAI.Probability.BenjaminiSchramm.UpwardHalfspaceFromContinuation +import OAI.Probability.BenjaminiSchramm.DownwardHalfspaceFromContinuation +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShiftProfile +import OAI.Probability.BenjaminiSchramm.FractionalInterpolation +import OAI.Probability.BenjaminiSchramm.FractionalExponentBootstrap + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def downwardHalfspaceFractionalProfile (a : V → ℝ) (p : unitInterval) (R q : ℝ) : Prop := + ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k)) + +def upwardHalfspaceFractionalProfile (a : V → ℝ) (p : unitInterval) (R q : ℝ) : Prop := + ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight a x v}) + {v | k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k)) + +theorem halfspace_fractional_profile_bootstrap [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) + (d : ℕ) (hd : ∀ u, (Percolation.finite_neighbors hl u).toFinset.card ≤ d) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) u v| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (L U B : ℝ) (hB : 0 < B) + (hdown : G.lowerSlabFractionalProfile (G.stationaryOrbitWeight μ) p R L) + (hup : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount (G.stationaryOrbitWeight μ) (-r) (k+r) (k-R) (k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k+U*r))) + (hcrude : ∀ q : ℝ, 0 < q → q < 1 → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (B*k))) : + ∀ q : ℝ, 0 < q → q < 1 → + G.downwardHalfspaceFractionalProfile (G.stationaryOrbitWeight μ) p R q ∧ + G.upwardHalfspaceFractionalProfile (G.stationaryOrbitWeight μ) p R q := by + let a := G.stationaryOrbitWeight μ + obtain ⟨Tlow,_hTlow,hshiftlow⟩ := G.halfspace_ceiling_shift_profile_fixed hc hl hq μ hμ hstat hu + R hR.le hjump p hp0 hp1 (1/8) + obtain ⟨Thigh,_hThigh,hshifthigh⟩ := G.halfspace_ceiling_shift_profile hc hl hq μ hμ hstat hu + R hR.le hjump p hp0 hp1 B hcrude + obtain ⟨Tup,_hTup,hshiftup⟩ := G.halfspace_floor_shift_profile_fixed hc hl hq μ hμ hstat hu + R hR.le hjump p hp0 hp1 (-1/2) + let η := min (1/4) (1/(16*(B+1))) + have hη : 0 < η := lt_min (by norm_num) (div_pos (by norm_num) (by positivity)) + have hη4 : η ≤ 1/4 := min_le_left _ _ + have hη1 : η < 1 := by linarith + have hηB : (2*η)*B ≤ 1/8 := by + have hh := (le_div_iff₀ (show 0 < 16*(B+1) by positivity)).mp + (min_le_right (1/4) (1/(16*(B+1)))) + change η*(16*(B+1)) ≤ 1 at hh + nlinarith + have hD0 : G.downwardHalfspaceFractionalProfile a p R 0 := by + intro ζ hζ + refine ⟨1,by simp,fun k hk x => ?_⟩ + simp only [ENNReal.rpow_zero,lintegral_const,measure_univ,mul_one,one_mul] + exact ENNReal.one_le_ofReal.mpr (Real.one_le_exp_iff.mpr (mul_nonneg hζ.le hk)) + apply fractional_exponent_bootstrap + (G.downwardHalfspaceFractionalProfile a p R) (G.upwardHalfspaceFractionalProfile a p R) + η hη hη1 hD0 + · intro q hq0 hq1 hDq q' hq'0 hq'lim + let b := (q+1)/2 + have hb0 : 0 < b := by dsimp [b]; positivity + have hb1 : b < 1 := by dsimp [b]; linarith + let θ := 2*η + have hθ0 : 0 < θ := by dsimp [θ]; positivity + have hθ1 : θ ≤ 1 := by dsimp [θ]; linarith + let m := q+η*(1-q) + have hm : 0 < m := add_pos_of_nonneg_of_pos hq0 (mul_pos hη (sub_pos.mpr hq1)) + have hm1 : m < 1 := by + have hh := mul_pos (sub_pos.mpr hη1) (sub_pos.mpr hq1) + dsimp [m] + nlinarith + let t := q'/m + have ht : 0 < t := div_pos hq'0 hm + have ht1 : t < 1 := (div_lt_one hm).mpr hq'lim + have hmt : m*t=q' := by dsimp [t]; field_simp + obtain ⟨D,hD,hdb⟩ := hshiftlow q hq0 (hDq (1/8) (by norm_num)) + obtain ⟨A,hA,hab⟩ := hshifthigh b hb0 hb1 + let D' := D*ENNReal.ofReal (Real.exp (Tlow*R)) + let A' := A*ENNReal.ofReal (Real.exp (Thigh*R)) + have hD' : D' < ⊤ := ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top + have hA' : A' < ⊤ := ENNReal.mul_lt_top hA ENNReal.ofReal_lt_top + let C := D'^(1-θ)*A'^θ + have hC : C < ⊤ := ENNReal.mul_lt_top + (ENNReal.rpow_lt_top_of_nonneg (sub_nonneg.mpr hθ1) hD'.ne) + (ENNReal.rpow_lt_top_of_nonneg hθ0.le hA'.ne) + let ρ := (1-θ)*(1/8)+θ*B + have hρ : 0 ≤ ρ := add_nonneg (mul_nonneg (sub_nonneg.mpr hθ1) (by norm_num)) + (mul_nonneg hθ0.le hB.le) + have hρ1 : ρ ≤ 3/4 := by dsimp [ρ,θ]; nlinarith + have hcont (s : ℝ) (hs : 0 ≤ s) (x : V) : + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ R}) + {v | -s-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -s+R} ω x)^m ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*s)) := by + let X := fun ω => restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a x v ≤ R}) + {v | -s-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ -s+R} ω x + have hX : Measurable X := measurable_restrictedLayerCount G.ends _ _ x + have hlo : (∫⁻ ω, X ω^q ∂G.law p) ≤ D'*ENNReal.ofReal (Real.exp ((1/8)*s)) := by + apply (hdb s hs R hR.le x).trans_eq + dsimp [D'] + rw [Real.exp_add ((1/8)*s) (Tlow*R),ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + have hhi : (∫⁻ ω, X ω^b ∂G.law p) ≤ A'*ENNReal.ofReal (Real.exp (B*s)) := by + apply (hab s hs R hR.le x).trans_eq + dsimp [A'] + rw [Real.exp_add (B*s) (Thigh*R),ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + have hexp : (1-θ)*q+θ*b=m := by dsimp [θ,b,m]; ring + have hh := lintegral_rpow_interpolation (G.law p) X hX q b θ hq0 hb0.le hθ0.le hθ1 + rw [hexp] at hh + apply hh.trans ((mul_le_mul' (ENNReal.rpow_le_rpow hlo (sub_nonneg.mpr hθ1)) + (ENNReal.rpow_le_rpow hhi hθ0.le)).trans_eq ?_) + have he := fractional_two_profile_product D' A' (1/8) 0 B 0 s 0 (1-θ) θ + (sub_nonneg.mpr hθ1) hθ0.le + simpa only [mul_zero,add_zero] using he + have hh := G.upward_halfspace_from_continuation hc hl a d hd R hR hjump p hfin U hup + m t ρ hm hm1.le ht ht1 hρ hρ1 C hC hcont + simpa only [hmt,upwardHalfspaceFractionalProfile] using hh + · intro q hq0 hq1 hUq q' hq'0 hq'q + by_cases hq'zero : q'=0 + · simpa only [hq'zero] using hD0 + have hq'pos : 0 < q' := lt_of_le_of_ne hq'0 (Ne.symm hq'zero) + let t := q'/q + have ht : 0 < t := div_pos hq'pos hq0 + have ht1 : t < 1 := (div_lt_one hq0).mpr hq'q + have hqt : q*t=q' := by dsimp [t]; field_simp + have hbase := hUq (1/2) (by norm_num) + have he (k : ℝ) : (-1+(1/2 : ℝ))*k=(-1/2)*k := by ring + simp only [he] at hbase + obtain ⟨D,hD,hdb⟩ := hshiftup q hq0.le hbase + let D' := D*ENNReal.ofReal (Real.exp (Tup*R)) + have hD' : D' < ⊤ := ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top + have hcont (s : ℝ) (hs : 0 ≤ s) (x : V) : + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -R ≤ G.orbitAdjustedHeight a x v}) + {v | s-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ s+R} ω x)^q ∂G.law p) ≤ + D'*ENNReal.ofReal (Real.exp (-s/2)) := by + apply (hdb s hs R hR.le x).trans_eq + dsimp [D'] + rw [Real.exp_add ((-1/2)*s) (Tup*R),ENNReal.ofReal_mul (Real.exp_nonneg _)] + rw [show (-1/2 : ℝ)*s= -s/2 by ring] + ac_rfl + have hh := G.downward_halfspace_from_continuation hc hl a d hd R hR hjump p hfin L hdown + q t hq0 hq1 ht ht1 D' hD' hcont + simpa only [hqt,downwardHalfspaceFractionalProfile] using hh + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceRootComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceRootComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..fed4500ee159b1a1690b16e6c9c971649f0a4888 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceRootComparison.lean @@ -0,0 +1,85 @@ +import OAI.Probability.BenjaminiSchramm.NormalizedCrossingRate + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma walk_finite_open_restriction {x y : V} (w : (openSimpleGraph G Set.univ).Walk x y) + (D : Set V) (hD : ∀ v ∈ w.support, v ∈ D) : + ∃ s : Finset E, s.card ≤ w.length ∧ ∀ ω : Set E, (s : Set E) ⊆ ω → + Conn G (ω ∩ internalEdges G D) x y := by + obtain ⟨l,hl,he,_ho⟩ := walk_lift_bonds G Set.univ w + have hlen : l.length = w.length := by + simpa only [List.length_map,SimpleGraph.Walk.length_edges] using congrArg List.length he + refine ⟨l.toFinset,(List.toFinset_card_le l).trans_eq hlen,fun ω hω => ?_⟩ + apply hl.conn + intro e he' + refine ⟨hω (List.mem_toFinset.mpr he'),?_⟩ + intro v hv + exact hD v (SimpleGraph.Walk.mem_support_of_mem_edges (he ▸ List.mem_map_of_mem he') hv) + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem adjustedHalfspaceHit_path_comparison [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (p : unitInterval) {x y : V} (w : G.fullGraph.Walk x y) (r t : ℝ) (hr : 0 ≤ r) + (hw : ∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight a x v) + (hxy : r ≤ G.orbitAdjustedHeight a x y) : + (p : ℝ)^w.length * (G.law p).real (G.adjustedHalfspaceHit a y (-r) t) ≤ + (G.law p).real (G.adjustedHalfspaceHit a x 0 t) := by + have hg : G.fullGraph = Percolation.openSimpleGraph G.ends Set.univ := + criticalModel_openGraph G.ends Set.univ + let f : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by simpa only [← hg,id_eq] using h⟩ + obtain ⟨s,hs,hconn⟩ := walk_finite_open_restriction G.ends (w.map f) + {v | 0 ≤ G.orbitAdjustedHeight a x v} (by + intro v hv + have hv' : v ∈ w.support := by + rw [SimpleGraph.Walk.support_map] at hv + change v ∈ w.support.map id at hv + simpa only [List.map_id_fun,id_eq] using hv + exact hw v hv') + have hslen : s.card ≤ w.length := by simpa only [SimpleGraph.Walk.length_map] using hs + let F : Set (Set E) := {ω | (s : Set E) ⊆ ω} + let B := G.adjustedHalfspaceHit a y (-r) t + have hF : IsUpperSet F := fun _ _ hωη hω => hω.trans hωη + have hfF : Percolation.FiniteWitness F := fun _ hω => ⟨s,hω,Set.Subset.rfl⟩ + have hsub : F ∩ B ⊆ G.adjustedHalfspaceHit a x 0 t := by + rintro ω ⟨hω,⟨z,hz,hyz⟩⟩ + have hyz' : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | 0 ≤ G.orbitAdjustedHeight a x v}) y z := by + apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hyz + intro v hv + change -r ≤ G.orbitAdjustedHeight a y v at hv + change 0 ≤ G.orbitAdjustedHeight a x v + rw [G.orbitAdjustedHeight_change_base hc hl a x y v] + linarith + refine ⟨z,?_,(hconn ω hω).trans hyz'⟩ + change t ≤ G.orbitAdjustedHeight a x z + change t ≤ G.orbitAdjustedHeight a y z at hz + rw [G.orbitAdjustedHeight_change_base hc hl a x y z] + linarith + have hassoc := Percolation.association_finiteWitness p F B hF + (G.adjustedHalfspaceHit_upper a y (-r) t) hfF + (G.adjustedHalfspaceHit_finiteWitness a y (-r) t) + have hprob : (G.law p).real F = (p : ℝ)^s.card := Percolation.finite_open_probability p s + rw [show Percolation.law p = G.law p from rfl, hprob] at hassoc + apply (le_trans ?_ hassoc).trans (measureReal_mono hsub) + apply mul_le_mul_of_nonneg_right _ ENNReal.toReal_nonneg + exact pow_le_pow_of_le_one p.2.1 p.2.2 hslen + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HalfspaceUniformShift.lean b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceUniformShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc31bd0c496b4b142bd82e48983623f0849d8f3b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HalfspaceUniformShift.lean @@ -0,0 +1,128 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShiftProfile + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem halfspace_ceiling_shift_profile_uniform_rate [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) : + ∃ S : ℝ, 0 < S ∧ ∀ ρ q : ℝ, 0 ≤ q → + (∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*k))) → + ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ c}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*k+(S+abs ρ)*c)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpaths⟩ := G.stationaryOrbitHeight_bounded_ascent_to_level + hc hl hq μ hμ hstat hu R hR hjump + let δ := min (p : ℝ) (1-p) + have hδ : 0 < δ := lt_min hp0 (sub_pos.mpr hp1) + have hδlt : δ < 1 := (min_le_left _ _).trans_lt hp1 + let s := -Real.log δ + have hs : 0 < s := neg_pos.mpr (Real.log_neg hδ hδlt) + let S := s*A + refine ⟨S,by dsimp [S]; positivity,fun ρ q hq0 hprofile => ?_⟩ + obtain ⟨D,hD,hbound⟩ := hprofile + refine ⟨D*ENNReal.ofReal (Real.exp (s*B+abs ρ*R)), + ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top,fun k hk c hc0 x => ?_⟩ + obtain ⟨y,w,hlen,hylo,hyhi,hw⟩ := hpaths c hc0 x + have hXY := G.fractional_ceiling_root_ascent hc hl a p k c R w hylo (fun v hv => (hw v hv).2) hq0 + have hh := finite_energy_cancel_length _ _ δ A B c w.length hδ hδlt.le hlen hXY + have hshift := hbound (k+G.orbitAdjustedHeight a x y) (by linarith) y + apply hh.trans ((mul_le_mul' le_rfl hshift).trans ?_) + have hheight : 0 ≤ G.orbitAdjustedHeight a x y := hc0.trans hylo + have hr₁ := mul_le_mul_of_nonneg_right (le_abs_self ρ) hheight + have hr₂ := mul_le_mul_of_nonneg_left hyhi (abs_nonneg ρ) + have he : -Real.log δ*(A*c+B)+ρ*(k+G.orbitAdjustedHeight a x y) ≤ + (s*B+abs ρ*R)+(ρ*k+(S+abs ρ)*c) := by + dsimp [s,S] + nlinarith + calc + _ = D*ENNReal.ofReal (Real.exp (-Real.log δ*(A*c+B)+ρ*(k+G.orbitAdjustedHeight a x y))) := by + rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ D*ENNReal.ofReal (Real.exp ((s*B+abs ρ*R)+(ρ*k+(S+abs ρ)*c))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + +theorem halfspace_floor_shift_profile_uniform_rate [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) : + ∃ S : ℝ, 0 < S ∧ ∀ ρ q : ℝ, 0 ≤ q → + (∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*k))) → + ∃ C : ℝ≥0∞, C < ⊤ ∧ + ∀ k : ℝ, 0 ≤ k → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -c ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ρ*k+(S+abs ρ)*c)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpaths⟩ := G.stationaryOrbitHeight_bounded_descent_to_level + hc hl hq μ hμ hstat hu R hR hjump + let δ := min (p : ℝ) (1-p) + have hδ : 0 < δ := lt_min hp0 (sub_pos.mpr hp1) + have hδlt : δ < 1 := (min_le_left _ _).trans_lt hp1 + let s := -Real.log δ + have hs : 0 < s := neg_pos.mpr (Real.log_neg hδ hδlt) + let S := s*A + refine ⟨S,by dsimp [S]; positivity,fun ρ q hq0 hprofile => ?_⟩ + obtain ⟨D,hD,hbound⟩ := hprofile + refine ⟨D*ENNReal.ofReal (Real.exp (s*B+abs ρ*R)), + ENNReal.mul_lt_top hD ENNReal.ofReal_lt_top,fun k hk c hc0 x => ?_⟩ + obtain ⟨y,w,hlen,hylo,hyhi,hw⟩ := hpaths c hc0 x + have hXY := G.fractional_floor_root_descent hc hl a p k c R w hyhi (fun v hv => (hw v hv).1) hq0 + have hh := finite_energy_cancel_length _ _ δ A B c w.length hδ hδlt.le hlen hXY + have hshift := hbound (k-G.orbitAdjustedHeight a x y) (by linarith) y + apply hh.trans ((mul_le_mul' le_rfl hshift).trans ?_) + have hheight : 0 ≤ -G.orbitAdjustedHeight a x y := by linarith + have hr₁ := mul_le_mul_of_nonneg_right (le_abs_self ρ) hheight + have hr₂ := mul_le_mul_of_nonneg_left + (show -G.orbitAdjustedHeight a x y ≤ c+R by linarith) (abs_nonneg ρ) + have he : -Real.log δ*(A*c+B)+ρ*(k-G.orbitAdjustedHeight a x y) ≤ + (s*B+abs ρ*R)+(ρ*k+(S+abs ρ)*c) := by + dsimp [s,S] + nlinarith + calc + _ = D*ENNReal.ofReal (Real.exp (-Real.log δ*(A*c+B)+ρ*(k-G.orbitAdjustedHeight a x y))) := by + rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ D*ENNReal.ofReal (Real.exp ((s*B+abs ρ*R)+(ρ*k+(S+abs ρ)*c))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by rw [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _),mul_assoc] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HarmonicHeightAscent.lean b/lean/OAI/Probability/BenjaminiSchramm/HarmonicHeightAscent.lean new file mode 100644 index 0000000000000000000000000000000000000000..77e4043616b51e21aec1da102b6438fc47b6ae88 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HarmonicHeightAscent.lean @@ -0,0 +1,111 @@ +import OAI.Probability.BenjaminiSchramm.OrbitTransport +import OAI.Probability.CriticalPercolation.Modular.ModularCharacter + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma height_harmonic_flat_or_rise (hl : G.LocallyFinite) (f : V → ℝ) + (hf : ∀ x, (∑ y ∈ (G.finite_neighbors hl x).toFinset, Real.exp (f y-f x)) = + G.modularWalkDegree x) (x : V) : + (∃ y, G.fullGraph.Adj x y ∧ f x < f y) ∨ + (∀ y, G.fullGraph.Adj x y → f y = f x) := by + by_cases hu : ∃ y, G.fullGraph.Adj x y ∧ f x < f y + · exact Or.inl hu + right + have hle (y : V) (hy : y ∈ (G.finite_neighbors hl x).toFinset) : + Real.exp (f y-f x) ≤ 1 := by + apply Real.exp_le_one_iff.mpr + exact sub_nonpos.mpr (le_of_not_gt (fun h => hu ⟨y,(G.finite_neighbors hl x).mem_toFinset.mp hy,h⟩)) + have hs : (∑ y ∈ (G.finite_neighbors hl x).toFinset, Real.exp (f y-f x)) = + ∑ _y ∈ (G.finite_neighbors hl x).toFinset, (1 : ℝ) := by + rw [hf,Finset.sum_const,nsmul_eq_mul,mul_one] + simp only [modularWalkDegree,Set.ncard_eq_toFinset_card _ (G.finite_neighbors hl x)] + intro y hxy + have he := (Finset.sum_eq_sum_iff_of_le hle).mp hs y ((G.finite_neighbors hl x).mem_toFinset.mpr hxy) + exact sub_eq_zero.mp (Real.exp_injective (by simpa only [Real.exp_zero] using he)) + +lemma harmonic_ascent_walk (f : V → ℝ) + (hf : ∀ x, (∃ y, G.fullGraph.Adj x y ∧ f x < f y) ∨ + (∀ y, G.fullGraph.Adj x y → f y = f x)) {x y : V} + (w : G.fullGraph.Walk x y) (hxy : f y ≠ f x) : + ∃ z, ∃ q : G.fullGraph.Walk x z, (∀ v ∈ q.support, f x ≤ f v) ∧ f x < f z := by + induction w with + | nil => exact False.elim (hxy rfl) + | @cons x u y hxu w ih => + rcases hf x with ⟨z,hxz,hz⟩ | hflat + · refine ⟨z,.cons hxz .nil,?_,hz⟩ + intro v hv + simp only [SimpleGraph.Walk.support_cons,SimpleGraph.Walk.support_nil,List.mem_cons, + List.not_mem_nil,or_false] at hv + rcases hv with rfl | rfl + · exact le_rfl + · exact hz.le + · have hux := hflat u hxu + obtain ⟨z,q,hq,hz⟩ := ih (by simpa only [hux] using hxy) + refine ⟨z,.cons hxu q,?_,by simpa only [hux] using hz⟩ + intro v hv + simp only [SimpleGraph.Walk.support_cons,List.mem_cons] at hv + rcases hv with rfl | hv + · exact le_rfl + · simpa only [hux] using hq v hv + +lemma orbitAdjustedHeight_nonconstant (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) + (hu : ¬ G.CombinatoriallyUnimodular) (x : V) : + ∃ y, G.orbitAdjustedHeight a x y ≠ 0 := by + by_contra h + push Not at h + apply hu + intro φ y + have hx := h (φ.vertex x) + simp only [orbitAdjustedHeight,ha,add_sub_cancel_right] at hx + have he : G.modularRatio (φ.vertex x) x = 1 := by + rw [← Real.exp_log (G.modularRatio_pos hc hl (φ.vertex x) x)] + rw [show Real.log (G.modularRatio (φ.vertex x) x) = 0 from hx,Real.exp_zero] + have he' : G.modularRatio x (φ.vertex x) = 1 := by + have hcoc := G.modularRatio_cocycle hc hl x (φ.vertex x) x + rw [he,mul_one,G.modularRatio_self] at hcoc + exact hcoc + rw [← G.modularRatio_aut_base hc hl x y φ] at he' + unfold modularRatio at he' + have hcard := (div_eq_one_iff_eq + (Nat.cast_ne_zero.mpr (G.suborbitCard_pos hc hl (φ.vertex y) y).ne')).mp he' + exact_mod_cast hcard + +theorem stationaryOrbitHeight_ascent [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) + (hu : ¬ G.CombinatoriallyUnimodular) (x : V) : + ∃ y, ∃ w : G.fullGraph.Walk x y, + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v) ∧ + 0 < G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y := by + let f := G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x + have hself : f x = 0 := G.orbitAdjustedHeight_self _ x + obtain ⟨y,hy⟩ := G.orbitAdjustedHeight_nonconstant hc hl _ + (G.stationaryOrbitWeight_aut μ) hu x + have hhar (v : V) : (∑ y ∈ (G.finite_neighbors hl v).toFinset, Real.exp (f y-f v)) = + G.modularWalkDegree v := by + have he (y : V) : f y-f v = G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v y := by + dsimp [f] + rw [G.orbitAdjustedHeight_change_base hc hl _ x v y,add_sub_cancel_left] + simp_rw [he] + exact G.stationaryOrbitHeight_harmonic hc hl hq μ hμ hstat v + obtain ⟨z,w,hw,hz⟩ := G.harmonic_ascent_walk f (G.height_harmonic_flat_or_rise hl f hhar) + (hc x y).some (by simpa only [hself] using hy) + refine ⟨z,w,?_,?_⟩ + · intro v hv + simpa only [hself] using hw v hv + · simpa only [hself] using hz + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HarmonicHeightDescent.lean b/lean/OAI/Probability/BenjaminiSchramm/HarmonicHeightDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..a232cd7058ca4da685256eefb10d310188aa8a7e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HarmonicHeightDescent.lean @@ -0,0 +1,74 @@ +import OAI.Probability.BenjaminiSchramm.HarmonicHeightAscent + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma height_harmonic_flat_or_fall (hl : G.LocallyFinite) (f : V → ℝ) + (hf : ∀ x, (∑ y ∈ (G.finite_neighbors hl x).toFinset, Real.exp (f y-f x)) = + G.modularWalkDegree x) (x : V) : + (∃ y, G.fullGraph.Adj x y ∧ f y < f x) ∨ + (∀ y, G.fullGraph.Adj x y → f y=f x) := by + by_cases hd : ∃ y, G.fullGraph.Adj x y ∧ f y < f x + · exact Or.inl hd + right + have hle (y : V) (hy : y ∈ (G.finite_neighbors hl x).toFinset) : + 1 ≤ Real.exp (f y-f x) := by + apply Real.one_le_exp_iff.mpr + exact sub_nonneg.mpr (le_of_not_gt + (fun h => hd ⟨y,(G.finite_neighbors hl x).mem_toFinset.mp hy,h⟩)) + have hs : (∑ _y ∈ (G.finite_neighbors hl x).toFinset, (1 : ℝ)) = + ∑ y ∈ (G.finite_neighbors hl x).toFinset, Real.exp (f y-f x) := by + rw [hf,Finset.sum_const,nsmul_eq_mul,mul_one] + simp only [modularWalkDegree,Set.ncard_eq_toFinset_card _ (G.finite_neighbors hl x)] + intro y hxy + have he := (Finset.sum_eq_sum_iff_of_le hle).mp hs y + ((G.finite_neighbors hl x).mem_toFinset.mpr hxy) + exact sub_eq_zero.mp (Real.exp_injective (by simpa only [Real.exp_zero] using he.symm)) + +theorem stationaryOrbitHeight_descent [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (x : V) : + ∃ y, ∃ w : G.fullGraph.Walk x y, + (∀ v ∈ w.support, G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0) ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y < 0 := by + let f := G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x + have hself : f x=0 := G.orbitAdjustedHeight_self _ x + obtain ⟨y,hy⟩ := G.orbitAdjustedHeight_nonconstant hc hl _ (G.stationaryOrbitWeight_aut μ) hu x + have hhar (v : V) : (∑ y ∈ (G.finite_neighbors hl v).toFinset, Real.exp (f y-f v)) = + G.modularWalkDegree v := by + have he (y : V) : f y-f v=G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v y := by + dsimp [f] + rw [G.orbitAdjustedHeight_change_base hc hl _ x v y,add_sub_cancel_left] + simp_rw [he] + exact G.stationaryOrbitHeight_harmonic hc hl hq μ hμ hstat v + have hfall (v : V) : (∃ z, G.fullGraph.Adj v z ∧ -f v < -f z) ∨ + (∀ z, G.fullGraph.Adj v z → -f z= -f v) := by + rcases G.height_harmonic_flat_or_fall hl f hhar v with ⟨z,hvz,hz⟩ | hflat + · exact Or.inl ⟨z,hvz,by linarith⟩ + · exact Or.inr fun z hz => congrArg Neg.neg (hflat z hz) + have hy' : f y ≠ f x := by simpa only [hself] using hy + obtain ⟨z,w,hw,hz⟩ := G.harmonic_ascent_walk (fun v => -f v) hfall + (hc x y).some (fun he => hy' (neg_injective he)) + refine ⟨z,w,?_,?_⟩ + · intro v hv + have hh := hw v hv + rw [hself] at hh + change f v ≤ 0 + linarith + · rw [hself] at hz + change f z < 0 + linarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HeightMaximumSlices.lean b/lean/OAI/Probability/BenjaminiSchramm/HeightMaximumSlices.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb5162339cafd9c57762e254dcffc38fb8fb552e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HeightMaximumSlices.lean @@ -0,0 +1,59 @@ +import OAI.Probability.BenjaminiSchramm.TruncatedSlabMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def heightMaximumSlice (D : Set E) (f : V → ℝ) (s : ℝ) (n : ℕ) (x : V) : Set (Set E) := + (restrictedHit G D x {z | s*((n : ℝ)+1) ≤ f z})ᶜ ∩ + restrictedHit G D x {z | s*n ≤ f z} + +lemma finite_cluster_height_slices_cover (D : Set E) (f : V → ℝ) (s : ℝ) (hs : 0 < s) + (ω : Set E) (x : V) (hx : f x=0) (hfin : (cluster G (ω ∩ D) x).Finite) : + ∃ n, ω ∈ heightMaximumSlice G D f s n x := by + obtain ⟨b,hb⟩ := (hfin.image f).bddAbove + obtain ⟨N,hN⟩ := exists_nat_gt (b/s) + have hno : ∃ n : ℕ, ω ∉ restrictedHit G D x {z | s*((n : ℝ)+1) ≤ f z} := by + refine ⟨N,?_⟩ + rintro ⟨z,hz,hxz⟩ + have hh : f z ≤ b := hb ⟨z,hxz,rfl⟩ + have hn : b < s*N := by + have hn' := (div_lt_iff₀ hs).mp hN + nlinarith + change s*((N : ℝ)+1) ≤ f z at hz + nlinarith + let n := Nat.find hno + refine ⟨n,Nat.find_spec hno,?_⟩ + by_cases hn : n=0 + · refine ⟨x,?_,conn_refl G _ x⟩ + simp only [hn,Nat.cast_zero,mul_zero,Set.mem_ofPred_eq,hx,le_refl] + · have hmin := Nat.find_min hno (show n-1 < Nat.find hno by dsimp [n]; omega) + have he : ((n-1 : ℕ) : ℝ)+1=(n : ℝ) := by + rw [Nat.cast_sub (show 1 ≤ n by omega),Nat.cast_one] + ring + simpa only [he,not_not] using hmin + +variable [Countable V] [Countable E] + +lemma measurableSet_heightMaximumSlice (D : Set E) (f : V → ℝ) (s : ℝ) (n : ℕ) (x : V) : + MeasurableSet (heightMaximumSlice G D f s n x) := + (measurableSet_restrictedHit G D x _).compl.inter (measurableSet_restrictedHit G D x _) + +omit [Countable V] [Countable E] in +lemma ae_height_slices_cover (p : unitInterval) (D : Set E) (f : V → ℝ) (s : ℝ) (hs : 0 < s) + (x : V) (hx : f x=0) (hfin : ∀ᵐ ω ∂law p, (cluster G ω x).Finite) : + ∀ᵐ ω ∂law p, ∃ n, ω ∈ heightMaximumSlice G D f s n x := by + filter_upwards [hfin] with ω hω + exact finite_cluster_height_slices_cover G D f s hs ω x hx + (hω.subset fun z hz => conn_mono G Set.inter_subset_left hz) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/HeightOrbitConnection.lean b/lean/OAI/Probability/BenjaminiSchramm/HeightOrbitConnection.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd49fdea9fc31360298e89b6c4ff98988bb08abc --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/HeightOrbitConnection.lean @@ -0,0 +1,109 @@ +import OAI.Probability.BenjaminiSchramm.UniformHeightAscent + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +theorem height_uniform_orbit_connection_abs [Fintype G.VertexOrbit] + (hc : G.fullGraph.Connected) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) : + ∃ N : ℕ, ∃ D : ℝ, 0 ≤ D ∧ ∀ x (j : G.VertexOrbit), ∃ y, + ∃ w : G.fullGraph.Walk x y, G.vertexOrbit y = j ∧ w.length ≤ N ∧ + ∀ v ∈ w.support, |G.orbitAdjustedHeight a x v| ≤ D := by + let w : (i j : G.VertexOrbit) → G.fullGraph.Walk i.out j.out := fun i j => (hc i.out j.out).some + let N : ℕ := ∑ i : G.VertexOrbit, ∑ j : G.VertexOrbit, (w i j).length + let b : G.VertexOrbit → G.VertexOrbit → ℝ := fun i j => + ∑ v ∈ (w i j).support.toFinset, |G.orbitAdjustedHeight a i.out v| + let D : ℝ := ∑ i : G.VertexOrbit, ∑ j : G.VertexOrbit, b i j + have hb (i j : G.VertexOrbit) : 0 ≤ b i j := Finset.sum_nonneg fun _ _ => abs_nonneg _ + have hD : 0 ≤ D := Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => hb i j + have hlen (i j : G.VertexOrbit) : (w i j).length ≤ N := + (Finset.single_le_sum (f := fun k => (w i k).length) + (fun _ _ => Nat.zero_le _) (Finset.mem_univ j)).trans + (Finset.single_le_sum (f := fun k => ∑ j, (w k j).length) + (fun _ _ => Nat.zero_le _) (Finset.mem_univ i)) + have hd (i j : G.VertexOrbit) (v : V) (hv : v ∈ (w i j).support) : + |G.orbitAdjustedHeight a i.out v| ≤ D := + (Finset.single_le_sum (fun _ _ => abs_nonneg _) (List.mem_toFinset.mpr hv)).trans + ((Finset.single_le_sum (fun j _ => hb i j) (Finset.mem_univ j)).trans + (Finset.single_le_sum (fun i _ => Finset.sum_nonneg fun j _ => hb i j) (Finset.mem_univ i))) + refine ⟨N,D,hD,fun x j => ?_⟩ + let i := G.vertexOrbit x + obtain ⟨φ,hφ⟩ := G.orbit_out_aut x + let f : G.fullGraph →g G.fullGraph := + ⟨φ.vertex,fun {_ _} h => (Aut.fullGraph_adj G φ _ _).mpr h⟩ + refine ⟨φ.vertex j.out,((w i j).map f).copy hφ rfl,?_,?_,?_⟩ + · rw [G.vertexOrbit_aut] + exact j.out_eq' + · simpa only [SimpleGraph.Walk.length_copy,SimpleGraph.Walk.length_map] using hlen i j + · intro v hv + simp only [SimpleGraph.Walk.support_copy,SimpleGraph.Walk.support_map,List.mem_map] at hv + obtain ⟨z,hz,rfl⟩ := hv + change |G.orbitAdjustedHeight a x (φ.vertex z)| ≤ D + rw [← hφ,G.orbitAdjustedHeight_aut a ha] + exact hd i j z hz + +theorem height_uniform_orbit_connection [Fintype G.VertexOrbit] + (hc : G.fullGraph.Connected) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) : + ∃ N : ℕ, ∃ D : ℝ, 0 ≤ D ∧ ∀ x (j : G.VertexOrbit), ∃ y, + ∃ w : G.fullGraph.Walk x y, G.vertexOrbit y = j ∧ w.length ≤ N ∧ + ∀ v ∈ w.support, -D ≤ G.orbitAdjustedHeight a x v := by + obtain ⟨N,D,hD,h⟩ := G.height_uniform_orbit_connection_abs hc a ha + refine ⟨N,D,hD,fun x j => ?_⟩ + obtain ⟨y,w,hy,hw,hh⟩ := h x j + exact ⟨y,w,hy,hw,fun v hv => (abs_le.mp (hh v hv)).1⟩ + +theorem stationaryOrbitHeight_orbit_above [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) + (hu : ¬ G.CombinatoriallyUnimodular) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ r : ℝ, 0 ≤ r → ∀ x (j : G.VertexOrbit), + ∃ y, ∃ w : G.fullGraph.Walk x y, G.vertexOrbit y = j ∧ + (w.length : ℝ) ≤ A*r+B ∧ + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v) ∧ + r ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y := by + obtain ⟨ε,hε,L,hstep⟩ := G.stationaryOrbitHeight_uniform_ascent hc hl hq μ hμ hstat hu + let a := G.stationaryOrbitWeight μ + obtain ⟨N,D,hD,hconn⟩ := G.height_uniform_orbit_connection hc a (G.stationaryOrbitWeight_aut μ) + let A : ℝ := (L : ℝ)/ε+1 + let B : ℝ := (D/ε+1)*L+N + refine ⟨A,B,by dsimp [A]; positivity,by dsimp [B]; positivity,fun r hr x j => ?_⟩ + let n : ℕ := ⌈(r+D)/ε⌉₊ + have hn : r+D ≤ (n : ℝ)*ε := (div_le_iff₀ hε).mp (Nat.le_ceil ((r+D)/ε)) + have hn' : (n : ℝ) ≤ (r+D)/ε+1 := + (Nat.ceil_lt_add_one (div_nonneg (add_nonneg hr hD) hε.le)).le + obtain ⟨y,w,hwlen,hw,hwy⟩ := G.height_ascent_iterate hc hl a ε hε.le L hstep n x + obtain ⟨z,q,hqorb,hqlen,hq⟩ := hconn y j + refine ⟨z,w.append q,hqorb,?_,?_,?_⟩ + · rw [SimpleGraph.Walk.length_append,Nat.cast_add] + have hwl : (w.length : ℝ) ≤ (n : ℝ)*L := by exact_mod_cast hwlen + have hql : (q.length : ℝ) ≤ N := by exact_mod_cast hqlen + have hm := mul_le_mul_of_nonneg_right hn' (Nat.cast_nonneg L : (0 : ℝ) ≤ L) + have he : (((r+D)/ε+1)*L+(N : ℝ)) = (L:ℝ)/ε*r+B := by dsimp [B]; ring + calc + _ ≤ (n : ℝ)*L+(N : ℝ) := add_le_add hwl hql + _ ≤ ((r+D)/ε+1)*L+(N : ℝ) := add_le_add hm le_rfl + _ = (L : ℝ)/ε*r+B := he + _ ≤ A*r+B := by dsimp [A]; nlinarith + · intro v hv + rcases (SimpleGraph.Walk.mem_support_append_iff _ _).mp hv with hv | hv + · exact hw v hv + · rw [G.orbitAdjustedHeight_change_base hc hl a x y v] + have hv' := hq v hv + linarith + · rw [G.orbitAdjustedHeight_change_base hc hl a x y z] + have hz := hq z q.end_mem_support + linarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/InputReduction.lean b/lean/OAI/Probability/BenjaminiSchramm/InputReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..9165ce48bde466ceb61dbce85da34dd325ba8ef5 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/InputReduction.lean @@ -0,0 +1,56 @@ +import OAI.Probability.BenjaminiSchramm.Application +import OAI.Probability.BenjaminiSchramm.GeneralCriticalFiniteness +import OAI.Probability.BenjaminiSchramm.SusceptibilityLaw + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +open MeasureTheory + +universe u v +variable {V : Type u} {E : Type v} + +theorem susceptibilityLaw_of_publishedVolume [Infinite V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hvolume : HutchcroftCriticalVolumeInput G) (hgap : pc G < ptwo G) : + SusceptibilityLaw G := by + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + have hp1 : pc G < 1 := hgap.trans_le (ptwo G).2.2 + have hfin := critical_finite_general G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hp1 + apply susceptibilityLaw_of_critical_volume G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hp1 + intro x + have hh := hvolume hgraph hgap x + rwa [criticalFiniteTail_eq G (volumeEvent G) x (hfin x)] at hh + +theorem firstMomentInput_of_volume [Infinite V] + (G : BondGraph V E) (hvolume : HutchcroftCriticalVolumeInput G) : + HutchcroftFirstMomentInput G := by + intro hgraph hgap x + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + obtain ⟨c,C,δ,hc,hC,hδ,hb⟩ := susceptibilityLaw_of_publishedVolume G hgraph hvolume hgap x + refine ⟨c,C,δ,hc,hC,hδ,fun p hp hnear => ?_⟩ + rw [←(susceptibility_eq_integral G hgraph.locallyFinite hgraph.quasiTransitive p hp x).2] + exact hb p hp hnear + +theorem full_application_reduced [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) + (htheta : TrianglePercolationProbabilityInput (subdivision G)) + (hvolume : HutchcroftCriticalVolumeInput (subdivision G)) + (hradii : HutchcroftCriticalRadiiInput (subdivision G)) : + MainConclusion G ∧ CriticalLawsConclusion G := + full_application_conditional G hconn hloc hqt hh hutchcroft2019 + (firstMomentInput_of_volume (subdivision G) hvolume) htheta hvolume hradii + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntegerFrontierCrossing.lean b/lean/OAI/Probability/BenjaminiSchramm/IntegerFrontierCrossing.lean new file mode 100644 index 0000000000000000000000000000000000000000..2475c8a741566c4770e19734ebf8a1eecc451fbd --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntegerFrontierCrossing.lean @@ -0,0 +1,69 @@ +import OAI.Probability.BenjaminiSchramm.PeakExtension +import OAI.Probability.BenjaminiSchramm.LayerFrontierExpectation +import OAI.Probability.BenjaminiSchramm.LayerMomentCauchy + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma integer_lower_frontier_level (f : V → ℤ) (n : ℤ) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → f w ≤ f v+1) + (ω : Set E) (x : V) (hx : f x < n) {u : V} + (hu : u ∈ openFrontier G ω (cluster G (ω ∩ internalEdges G {v | f v < n}) x)) : f u=n := by + have hout := openFrontier_lowerCluster_outside G ω {v | f v < n} x hx hu + obtain ⟨_,v,hv,e,_he,heq⟩ := hu + have hvn := conn_internalEdges_end_mem G ω {v | f v < n} hx hv + have hj := hjump e v u (by rw [heq]; simp) (by rw [heq]; simp) + change ¬f u < n at hout + change f v < n at hvn + omega + +lemma integer_frontierCount_le_fullLayerCount [Countable V] [Countable E] + (f : V → ℤ) (n : ℤ) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → f w ≤ f v+1) + (ω : Set E) (x : V) (hx : f x < n) : + frontierCount G (internalEdges G {v | f v < n}) Set.univ ω x ≤ + restrictedLayerCount G Set.univ {v | f v=n} ω x := by + apply ENNReal.tsum_le_tsum + intro u + by_cases hu : u ∈ openFrontier G (ω ∩ Set.univ) + (cluster G (ω ∩ internalEdges G {v | f v < n}) x) + · have hu' : u ∈ openFrontier G ω (cluster G (ω ∩ internalEdges G {v | f v < n}) x) := by + simpa only [Set.inter_univ] using hu + have hn := integer_lower_frontier_level G f n hjump ω x hx hu' + have hc := openFrontier_reachable G ω (internalEdges G {v | f v < n}) x hu' + simp only [Set.mem_ofPred_eq,Set.inter_univ,ite_eq_left hu',ite_eq_left (show f u=n ∧ Conn G ω x u from ⟨hn,hc⟩),le_refl] + · rw [ite_eq_right hu] + exact bot_le + +lemma integer_upper_layer_hit_frontier_probability [Countable V] [Countable E] + (f : V → ℤ) (n : ℤ) (x : V) (hx : f x < n) (p : unitInterval) : + law p (restrictedHit G (internalEdges G {v | f v ≤ n}) x {v | f v=n}) ≤ + law p {ω | 0 < frontierCount G (internalEdges G {v | f v < n}) Set.univ ω x} := by + apply measure_mono + rintro ω ⟨y,hy,hxy⟩ + let S := cluster G (ω ∩ internalEdges G {v | f v < n}) x + have hyS : y ∉ S := by + intro h + have hh := conn_internalEdges_end_mem G ω {v | f v < n} hx h + change f y < n at hh + change f y=n at hy + omega + obtain ⟨u,hu,_huy⟩ := conn_last_exit_frontier G ω S (mem_cluster_self G _ x) hyS + (conn_mono G Set.inter_subset_left hxy) + have hone : (1 : ℝ≥0∞) ≤ frontierCount G (internalEdges G {v | f v < n}) Set.univ ω x := by + apply le_trans _ (ENNReal.le_tsum u) + have hu' : u ∈ openFrontier G (ω ∩ Set.univ) S := by simpa only [Set.inter_univ] using hu + exact (ite_eq_left hu').symm.le + exact zero_lt_one.trans_le hone + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntegerLayerFirstVisit.lean b/lean/OAI/Probability/BenjaminiSchramm/IntegerLayerFirstVisit.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c49ad729ca19478cc2ad82a276640364db0f9bc --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntegerLayerFirstVisit.lean @@ -0,0 +1,70 @@ +import OAI.Probability.BenjaminiSchramm.SlabFirstVisit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma integer_half_band (k m : ℤ) : + ((m : ℝ)-1/2 ≤ (k : ℝ) ∧ (k : ℝ) ≤ (m : ℝ)-1/2+1) ↔ k=m := by + constructor + · rintro ⟨hlo,hhi⟩ + have h₁ : (m : ℝ)-1 < k := by linarith + have h₂ : (k : ℝ) < (m : ℝ)+1 := by linarith + have h₁' : m-1 < k := by exact_mod_cast h₁ + have h₂' : k < m+1 := by exact_mod_cast h₂ + omega + · rintro rfl + constructor <;> linarith + +lemma integer_half_ceiling (k m : ℤ) : + ((k : ℝ) ≤ (m : ℝ)-1/2+1) ↔ k ≤ m := by + constructor + · intro h + have hh : (k : ℝ) < (m : ℝ)+1 := by linarith + have hh' : k < m+1 := by exact_mod_cast hh + omega + · intro h + have hh : (k : ℝ) ≤ (m : ℝ) := by exact_mod_cast h + linarith + +theorem integer_first_layer_moment_bound [Countable V] [Countable E] + (f : V → ℤ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → f v ≤ f u+1 ∧ f u ≤ f v+1) + (I : Set E) (A : Set V) (p : unitInterval) (x : V) (m : ℤ) + (hx : f x < m) (hA : ∀ y ∈ A, m ≤ f y) : + (∫⁻ ω, restrictedLayerCount G I A ω x ∂law p) ≤ + ∑' z, (if f z=m then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ m})) x z} else 0) * + (∫⁻ ω, restrictedLayerCount G I A ω z ∂law p) := by + have hj : ∀ e u v, u ∈ G e → v ∈ G e → |(f v : ℝ)-(f u : ℝ)| ≤ 1 := by + intro e u v hu hv + obtain ⟨h₁,h₂⟩ := hjump e u v hu hv + have h₁' : (f v : ℝ) ≤ (f u : ℝ)+1 := by exact_mod_cast h₁ + have h₂' : (f u : ℝ) ≤ (f v : ℝ)+1 := by exact_mod_cast h₂ + rw [abs_le] + constructor <;> linarith + have hx' : (f x : ℝ) < (m : ℝ)-1/2 := by + have hh : f x ≤ m-1 := by omega + have hh' : (f x : ℝ) ≤ (m : ℝ)-1 := by exact_mod_cast hh + linarith + have hA' : ∀ y ∈ A, (m : ℝ)-1/2 ≤ (f y : ℝ) := by + intro y hy + have hh : (m : ℝ) ≤ (f y : ℝ) := by exact_mod_cast hA y hy + linarith + have hh := first_height_layer_moment_bound G (fun v => (f v : ℝ)) 1 ((m : ℝ)-1/2) + (by norm_num) hj I A p x hx' hA' + have hD : {v : V | (f v : ℝ) ≤ (m : ℝ)-1/2+1} = {v | f v ≤ m} := by + ext v + exact integer_half_ceiling (f v) m + simpa only [hD,integer_half_band] using hh + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d7a29ef3a1b7f797c064ccff1ceda9ec42d4607 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallExposure.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicBallGrowth +import OAI.Probability.BenjaminiSchramm.BlockExposure + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +def ballIncidentEdges (G : BondGraph V E) (B : Set V) : Set E := + {e | ∃ a ∈ B, a ∈ G e} + +theorem intrinsicBall_mono_radius (G : BondGraph V E) (ω : Set E) (x : V) + {m n : ℕ} (hmn : m ≤ n) : intrinsicBall G ω x m ⊆ intrinsicBall G ω x n := by + rintro y ⟨l,hl,hlen,ho⟩ + exact ⟨l,hl,hlen.trans hmn,ho⟩ + +theorem along_open_of_agree_intrinsic_prefix (G : BondGraph V E) + (ω η : Set E) (x y : V) (n : ℕ) (l : List E) (hl : Along G x l y) + (hlen : l.length ≤ n) (ho : ∀ e ∈ l, e ∈ η) + (hagree : ∀ e ∈ ballIncidentEdges G (intrinsicBall G ω x (n-1)), e ∈ ω ↔ e ∈ η) : + ∀ e ∈ l, e ∈ ω := by + rcases hl.first_outside ω with h | ⟨a,b,e,l₁,l₂,heq,h₁,he,_,hprefix,hnot⟩ + · exact h + · exfalso + have hlength : l₁.length ≤ n-1 := by + rw [heq,List.length_append,List.length_cons] at hlen + omega + have ha : a ∈ intrinsicBall G ω x (n-1) := ⟨l₁,h₁,hlength,hprefix⟩ + have hei : e ∈ ballIncidentEdges G (intrinsicBall G ω x (n-1)) := + ⟨a,ha,by simp [he]⟩ + exact hnot ((hagree e hei).mpr (ho e (by rw [heq]; simp))) + +theorem along_bonds_incident_intrinsic_prefix (G : BondGraph V E) + (ω : Set E) (x y : V) (n : ℕ) (l : List E) (hl : Along G x l y) + (hlen : l.length ≤ n) (ho : ∀ e ∈ l, e ∈ ω) : + ∀ e ∈ l, e ∈ ballIncidentEdges G (intrinsicBall G ω x (n-1)) := by + rcases hl.first_outside (ballIncidentEdges G (intrinsicBall G ω x (n-1))) with + h | ⟨a,b,e,l₁,l₂,heq,h₁,he,_,_,hnot⟩ + · exact h + · exfalso + have hlength : l₁.length ≤ n-1 := by + rw [heq,List.length_append,List.length_cons] at hlen + omega + have ha : a ∈ intrinsicBall G ω x (n-1) := ⟨l₁,h₁,hlength,fun f hf => ho f (by rw [heq]; simp [hf])⟩ + exact hnot ⟨a,ha,by simp [he]⟩ + +theorem intrinsicBall_eq_of_incident_agreement (G : BondGraph V E) + (ω η : Set E) (x : V) (n : ℕ) + (hagree : ∀ e ∈ ballIncidentEdges G (intrinsicBall G ω x (n-1)), e ∈ ω ↔ e ∈ η) : + intrinsicBall G ω x n = intrinsicBall G η x n := by + apply Set.Subset.antisymm + · rintro y ⟨l,hl,hlen,ho⟩ + exact ⟨l,hl,hlen,fun e he => (hagree e + (along_bonds_incident_intrinsic_prefix G ω x y n l hl hlen ho e he)).mp (ho e he)⟩ + · rintro y ⟨l,hl,hlen,ho⟩ + exact ⟨l,hl,hlen,along_open_of_agree_intrinsic_prefix G ω η x y n l hl hlen ho hagree⟩ + +theorem intrinsicBall_history_eq_of_incident_agreement (G : BondGraph V E) + (ω η : Set E) (x : V) (n : ℕ) + (hagree : ∀ e ∈ ballIncidentEdges G (intrinsicBall G ω x (n-1)), e ∈ ω ↔ e ∈ η) : + ∀ i ≤ n, intrinsicBall G ω x i = intrinsicBall G η x i := by + intro i hi + apply intrinsicBall_eq_of_incident_agreement G ω η x i + rintro e ⟨a,ha,he⟩ + exact hagree e ⟨a,intrinsicBall_mono_radius G ω x (by omega) ha,he⟩ + +theorem measurableSet_intrinsicBall_eq [Countable V] + (G : BondGraph V E) (hloc : LocallyFinite G) (S : Set E) (x : V) (n : ℕ) (B : Set V) : + MeasurableSet {ω | intrinsicBall G (ω ∩ S) x n = B} := by + have he : {ω | intrinsicBall G (ω ∩ S) x n = B} = + ⋂ y : V, {ω | y ∈ intrinsicBall G (ω ∩ S) x n ↔ y ∈ B} := by + ext ω + simp only [Set.mem_ofPred_eq,Set.mem_iInter] + exact Set.ext_iff + rw [he] + exact MeasurableSet.iInter (fun y => + ((measurableSet_mem_intrinsicBall_domain G hloc S x y n).mem.iff measurable_const).setOf) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallGrowth.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ff4476b4719ac0ab054f95973d719517ae79607 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallGrowth.lean @@ -0,0 +1,200 @@ +import OAI.Probability.BenjaminiSchramm.SmallWitness +import OAI.Probability.BenjaminiSchramm.OperatorSusceptibility +import OAI.Probability.BenjaminiSchramm.EventMeasurability + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem intrinsicBall_small_witness (G : BondGraph V E) (S : Set E) + (x y : V) (r : ℕ) (ω : Finset E) + (hy : y ∈ intrinsicBall G ((ω : Set E) ∩ S) x r) : + ∃ s ⊆ ω, s.card ≤ r ∧ ∀ η : Finset E, s ⊆ η → + y ∈ intrinsicBall G ((η : Set E) ∩ S) x r := by + obtain ⟨l,hl,hlen,ho⟩ := hy + refine ⟨l.toFinset, ?_, l.toFinset_card_le.trans hlen, ?_⟩ + · intro e he + exact (ho e (List.mem_toFinset.mp he)).1 + · intro η hη + exact ⟨l,hl,hlen,fun e he => ⟨hη (List.mem_toFinset.mpr he),(ho e he).2⟩⟩ + +noncomputable def intrinsicBallPolynomial (G : BondGraph V E) + (hloc : LocallyFinite G) (S : Set E) (x y : V) (r : ℕ) : ℝ → ℝ := + bernoulliPolynomial (intrinsicBondSupport G hloc S x r) + (fun ω => if y ∈ intrinsicBall G ((ω : Set E) ∩ S) x r then 1 else 0) + +theorem intrinsicBallPolynomial_eq (G : BondGraph V E) (hloc : LocallyFinite G) + (S : Set E) (x y : V) (r : ℕ) (p : unitInterval) : + intrinsicBallPolynomial G hloc S x y r p = + (law p {ω | y ∈ intrinsicBall G (ω ∩ S) x r}).toReal := by + change finiteEventPolynomial (intrinsicBondSupport G hloc S x r) + {ω | y ∈ intrinsicBall G (ω ∩ S) x r} p = _ + rw [finiteEventPolynomial_restrict] + congr 2 + ext ω + have hsub : (intrinsicBondSupport G hloc S x r : Set E) ⊆ S := by + rw [intrinsicBondSupport_coe]; exact Set.inter_subset_right + change (y ∈ intrinsicBall G ((ω ∩ _) ∩ S) x r) ↔ _ + rw [Set.inter_assoc,Set.inter_eq_left.mpr hsub,intrinsicBall_domain_restrict] + +theorem intrinsicBall_probability_transfer (G : BondGraph V E) + (hloc : LocallyFinite G) (S : Set E) (x y : V) (r : ℕ) + (p q : unitInterval) (hp : 0 < (p : ℝ)) (hpq : p ≤ q) : + intrinsicBallPolynomial G hloc S x y r q ≤ + Real.exp ((r : ℝ) / p * ((q : ℝ) - p)) * + intrinsicBallPolynomial G hloc S x y r p := by + apply small_witness_probability_transfer _ _ _ r _ p q hp hpq + · intro ω η hωη hy + exact intrinsicBall_mono G (Set.inter_subset_inter_left S + (show (ω : Set E) ⊆ η from hωη)) x r hy + · intro ω _ hy + exact intrinsicBall_small_witness G S x y r ω hy + +noncomputable def intrinsicBallMoment (G : BondGraph V E) (hloc : LocallyFinite G) + (S : Set E) (x : V) (r : ℕ) (p : ℝ) : ℝ := + ∑ y ∈ (finite_reachBall hloc x r).toFinset, intrinsicBallPolynomial G hloc S x y r p + +theorem intrinsicBallMoment_le_susceptibility [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (S : Set E) (x : V) (r : ℕ) (p : unitInterval) (hp : p < pc G) : + intrinsicBallMoment G hloc S x r p ≤ susceptibility G p x := by + apply (Finset.sum_le_sum (fun y _ => ?_)).trans + ((summable_twoPoint_subcritical G hloc hqt p hp x).sum_le_tsum _ + (fun y _ => twoPoint_nonneg G p x y)) + rw [intrinsicBallPolynomial_eq] + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono + rintro ω ⟨l,hl,_,ho⟩ + exact hl.conn (fun e he => (ho e he).1) + +theorem intrinsicBallMoment_transfer (G : BondGraph V E) (hloc : LocallyFinite G) + (S : Set E) (x : V) (r : ℕ) (p q : unitInterval) + (hp : 0 < (p : ℝ)) (hpq : p ≤ q) : + intrinsicBallMoment G hloc S x r q ≤ + Real.exp ((r : ℝ) / p * ((q : ℝ) - p)) * + intrinsicBallMoment G hloc S x r p := by + unfold intrinsicBallMoment + rw [Finset.mul_sum] + exact Finset.sum_le_sum (fun y _ => intrinsicBall_probability_transfer G hloc S x y r p q hp hpq) + +theorem intrinsicBall_ncard_eq_sum (G : BondGraph V E) (hloc : LocallyFinite G) + (ω : Set E) (x : V) (r : ℕ) : + ((intrinsicBall G ω x r).ncard : ℝ) = + ∑ y ∈ (finite_reachBall hloc x r).toFinset, + if y ∈ intrinsicBall G ω x r then (1 : ℝ) else 0 := by + let B := (finite_reachBall hloc x r).toFinset.filter (fun y => y ∈ intrinsicBall G ω x r) + have he : (B : Set V) = intrinsicBall G ω x r := by + ext y + simp only [B,Finset.mem_coe,Finset.mem_filter] + exact and_iff_right_of_imp (fun hy => (finite_reachBall hloc x r).mem_toFinset.mpr + (intrinsicBall_subset_reachBall G ω x r hy)) + rw [←he,Set.ncard_coe_finset] + change (B.card : ℝ) = _ + rw [Finset.card_filter,Nat.cast_sum] + simp only [Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + rw [he] + +theorem measurableSet_mem_intrinsicBall_domain (G : BondGraph V E) + (hloc : LocallyFinite G) (S : Set E) (x y : V) (r : ℕ) : + MeasurableSet {ω | y ∈ intrinsicBall G (ω ∩ S) x r} := by + let Q := intrinsicBondSupport G hloc S x r + have he : {ω | y ∈ intrinsicBall G (ω ∩ S) x r} = + {ω | ω ∩ (Q : Set E) ∈ {η | y ∈ intrinsicBall G (η ∩ S) x r}} := by + ext ω + have hsub : (Q : Set E) ⊆ S := by + dsimp [Q]; rw [intrinsicBondSupport_coe]; exact Set.inter_subset_right + change (y ∈ intrinsicBall G (ω ∩ S) x r) ↔ + (y ∈ intrinsicBall G ((ω ∩ (Q : Set E)) ∩ S) x r) + rw [Set.inter_assoc,Set.inter_eq_left.mpr hsub,intrinsicBall_domain_restrict] + rw [he] + exact measurableSet_finite_restriction Q _ + +theorem integral_intrinsicBall_ncard_eq (G : BondGraph V E) (hloc : LocallyFinite G) + (S : Set E) (x : V) (r : ℕ) (p : unitInterval) : + (∫ ω, ((intrinsicBall G (ω ∩ S) x r).ncard : ℝ) ∂law p) = + intrinsicBallMoment G hloc S x r p := by + simp_rw [intrinsicBall_ncard_eq_sum G hloc] + rw [integral_finsetSum] + · unfold intrinsicBallMoment + apply Finset.sum_congr rfl + intro y _ + rw [intrinsicBallPolynomial_eq] + have heq : (fun ω : Set E => if y ∈ intrinsicBall G (ω ∩ S) x r then (1 : ℝ) else 0) = + {ω | y ∈ intrinsicBall G (ω ∩ S) x r}.indicator 1 := by + funext ω + by_cases hy : y ∈ intrinsicBall G (ω ∩ S) x r <;> simp [Set.indicator,hy] + rw [heq,integral_indicator_one (measurableSet_mem_intrinsicBall_domain G hloc S x y r)] + rfl + · intro y _ + have heq : (fun ω : Set E => if y ∈ intrinsicBall G (ω ∩ S) x r then (1 : ℝ) else 0) = + {ω | y ∈ intrinsicBall G (ω ∩ S) x r}.indicator (fun _ => 1) := by + funext ω + by_cases hy : y ∈ intrinsicBall G (ω ∩ S) x r <;> simp [Set.indicator,hy] + rw [heq] + exact (integrable_const (1 : ℝ)).indicator (measurableSet_mem_intrinsicBall_domain G hloc S x y r) + +theorem integrable_intrinsicBall_ncard (G : BondGraph V E) (hloc : LocallyFinite G) + (S : Set E) (x : V) (r : ℕ) (p : unitInterval) : + Integrable (fun ω => ((intrinsicBall G (ω ∩ S) x r).ncard : ℝ)) (law p) := by + simp_rw [intrinsicBall_ncard_eq_sum G hloc] + apply integrable_finsetSum + intro y _ + have heq : (fun ω : Set E => if y ∈ intrinsicBall G (ω ∩ S) x r then (1 : ℝ) else 0) = + {ω | y ∈ intrinsicBall G (ω ∩ S) x r}.indicator (fun _ => 1) := by + funext ω + by_cases hy : y ∈ intrinsicBall G (ω ∩ S) x r <;> simp [Set.indicator,hy] + rw [heq] + exact (integrable_const (1 : ℝ)).indicator (measurableSet_mem_intrinsicBall_domain G hloc S x y r) + +theorem critical_intrinsicBallMoment_linear [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (A : ℝ) (hA : 0 < A) + (hχ : ∀ p : unitInterval, p < pc G → ∀ x, + susceptibility G p x ≤ A / ((pc G : ℝ) - p)) : + ∃ C : ℝ, 0 < C ∧ ∀ (S : Set E) x (r : ℕ), 0 < r → + intrinsicBallMoment G hloc S x r (pc G) ≤ C * r := by + have hpc : 0 < (pc G : ℝ) := pc_pos G hloc hqt + refine ⟨2 * Real.exp 1 * A / (pc G : ℝ),by positivity,fun S x r hr => ?_⟩ + have hrR : 0 < (r : ℝ) := by exact_mod_cast hr + let p : unitInterval := ⟨(pc G : ℝ) * r / (r+1), by + constructor + · positivity + · apply (div_le_iff₀ (by positivity : (0 : ℝ) < r+1)).mpr + have hc := mul_le_mul_of_nonneg_right (pc G).2.2 hrR.le + nlinarith⟩ + have hp0 : 0 < (p : ℝ) := by dsimp [p]; positivity + have hp : p < pc G := by + change (pc G : ℝ) * r / (r+1) < (pc G : ℝ) + apply (div_lt_iff₀ (by positivity : (0 : ℝ) < r+1)).mpr + nlinarith + have hgap : (pc G : ℝ) - p = (pc G : ℝ) / (r+1) := by dsimp [p]; field_simp; ring + have hexp : (r : ℝ) / p * ((pc G : ℝ) - p) = 1 := by + rw [hgap] + dsimp [p] + field_simp + calc + _ ≤ Real.exp ((r : ℝ) / p * ((pc G : ℝ) - p)) * + intrinsicBallMoment G hloc S x r p := intrinsicBallMoment_transfer G hloc S x r p (pc G) hp0 hp.le + _ ≤ Real.exp 1 * (A / ((pc G : ℝ) - p)) := by + rw [hexp] + exact mul_le_mul_of_nonneg_left + ((intrinsicBallMoment_le_susceptibility G hloc hqt S x r p hp).trans (hχ p hp x)) + (Real.exp_pos 1).le + _ = Real.exp 1 * A / (pc G : ℝ) * (r+1) := by rw [hgap]; field_simp + _ ≤ _ := by + have hr1 : (1 : ℝ) ≤ r := by exact_mod_cast hr + have hn : 0 ≤ Real.exp 1 * A / (pc G : ℝ) := by positivity + calc + _ ≤ (Real.exp 1 * A / (pc G : ℝ)) * (2*r) := + mul_le_mul_of_nonneg_left (by linarith) hn + _ = _ := by ring + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallisticity.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallisticity.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d8894cca6caca16ccf840004efb4e13657d88ff --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicBallisticity.lean @@ -0,0 +1,104 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicConnectionAverage +import OAI.Probability.BenjaminiSchramm.ExponentialDecay + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem longConnectionEvent_antitone (G : BondGraph V E) (x y : V) + {m n : ℕ} (hmn : m ≤ n) : longConnectionEvent G x y n ⊆ longConnectionEvent G x y m := by + rintro ω ⟨hc,hd⟩ + exact ⟨hc,hmn.trans hd⟩ + +theorem longConnection_block_bound [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (M k n : ℕ) (hM : 0 < M) (x y : V) (hd : k*M ≤ n) : + (law p).real (longConnectionEvent G x y n) ≤ ‖T‖ * (‖T‖ / M)^k := by + have hpow := longConnection_power_bound G hloc p T hT M k x y + have hreal : (M : ℝ)^k * (law p).real (longConnectionEvent G x y (k*M)) ≤ + (matrixCoeff (T^(k+1)) x y).re := by + change (M : ℝ)^k * (law p (longConnectionEvent G x y (k*M))).toReal ≤ _ + have hh := ENNReal.toReal_mono (by unfold ennMatrixCoeff; exact ENNReal.ofReal_ne_top) hpow + simpa only [ENNReal.toReal_mul,ENNReal.toReal_pow,ENNReal.toReal_natCast, + ennMatrixCoeff,ENNReal.toReal_ofReal ((hT.positiveRealMatrix G p T).pow (k+1) x y).2] using hh + have hcoeff : (matrixCoeff (T ^ (k + 1)) x y).re ≤ ‖T‖ ^ (k + 1) := by + apply (Complex.re_le_norm _).trans + have hc : ‖matrixCoeff (T ^ (k + 1)) x y‖ ≤ ‖T ^ (k + 1)‖ := by + change ‖(T ^ (k + 1)) (lp.single 2 y (1 : ℂ)) x‖ ≤ _ + apply (lp.norm_apply_le_norm (by norm_num : (2 : ENNReal) ≠ 0) + ((T ^ (k + 1)) (lp.single 2 y (1 : ℂ))) x).trans + simpa only [lp.norm_single (by norm_num : 0 < (2 : ENNReal)), norm_one, mul_one] using + (T ^ (k + 1)).le_opNorm (lp.single 2 y (1 : ℂ)) + exact hc.trans (norm_pow_le' T (Nat.zero_lt_succ k)) + have hc : (0 : ℝ) < M := by exact_mod_cast hM + calc + _ ≤ (law p).real (longConnectionEvent G x y (k*M)) := + ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (longConnectionEvent_antitone G x y hd)) + _ ≤ ‖T‖^(k+1) / (M : ℝ)^k := + (le_div_iff₀ (pow_pos hc k)).mpr (by simpa only [mul_comm] using hreal.trans hcoeff) + _ = _ := by rw [div_pow,pow_succ]; ring + +theorem longConnection_exponential_bound [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) + (p : unitInterval) (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (x y : V) (n : ℕ) : + (law p).real (longConnectionEvent G x y n) ≤ 2 * ‖T‖ * + Real.exp (-(Real.log 2 / (3 * ‖T‖)) * n) := by + have hM : 1 ≤ ‖T‖ := hT.norm_one_le G p T + have hMp : 0 < ‖T‖ := lt_of_lt_of_le zero_lt_one hM + let m : ℕ := ⌈2 * ‖T‖⌉₊ + have hml : 2 * ‖T‖ ≤ (m : ℝ) := Nat.le_ceil _ + have hmu : (m : ℝ) ≤ 3 * ‖T‖ := by + have hh := Nat.ceil_lt_add_one (show 0 ≤ 2 * ‖T‖ by positivity) + dsimp [m] + linarith + have hmp : 0 < m := by + have : (0 : ℝ) < m := lt_of_lt_of_le (by positivity) hml + exact_mod_cast this + let k := n / m + have hk : k * m ≤ n := Nat.div_mul_le_self _ _ + have hxy : n < (k + 1) * m := by + simpa only [k, Nat.mul_comm] using Nat.lt_mul_div_succ (n) hmp + have hr : ‖T‖ / m ≤ (1 / 2 : ℝ) := by + apply (div_le_iff₀ (by positivity : (0 : ℝ) < m)).mpr + linarith + have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ ‖T‖ / m) hr k + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hcast : (n : ℝ) ≤ ((k : ℝ) + 1) * (3 * ‖T‖) := by + have h1 : (n : ℝ) ≤ ((k : ℝ) + 1) * m := by + exact_mod_cast hxy.le + exact h1.trans (mul_le_mul_of_nonneg_left hmu (by positivity)) + have hexponent : -(Real.log 2) * k ≤ + Real.log 2 - (Real.log 2 / (3 * ‖T‖)) * n := by + have hdiv : (n : ℝ) / (3 * ‖T‖) ≤ (k : ℝ) + 1 := + (div_le_iff₀ (by positivity)).mpr hcast + have hh := mul_le_mul_of_nonneg_left hdiv hlog.le + nlinarith [show (Real.log 2 / (3 * ‖T‖)) * n = + Real.log 2 * ((n : ℝ) / (3 * ‖T‖)) by ring] + have hhalf : (1 / 2 : ℝ) ^ k = Real.exp (-(Real.log 2) * k) := by + rw [mul_comm, Real.exp_nat_mul, Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + simp only [one_div] + calc + _ ≤ ‖T‖ * (‖T‖ / m) ^ k := + longConnection_block_bound G hloc p T hT m k n hmp x y hk + _ ≤ ‖T‖ * (1 / 2 : ℝ) ^ k := mul_le_mul_of_nonneg_left hpow (norm_nonneg _) + _ = ‖T‖ * Real.exp (-(Real.log 2) * k) := by rw [hhalf] + _ ≤ ‖T‖ * Real.exp (Real.log 2 - + (Real.log 2 / (3 * ‖T‖)) * n) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexponent) (norm_nonneg _) + _ = _ := by + rw [Real.exp_sub, Real.exp_log (by norm_num : (0 : ℝ) < 2), + neg_mul, Real.exp_neg, div_eq_mul_inv] + ring + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicConnection.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicConnection.lean new file mode 100644 index 0000000000000000000000000000000000000000..671f99e12971559e901fddbd43e06d323d969e07 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicConnection.lean @@ -0,0 +1,120 @@ +import OAI.Probability.BenjaminiSchramm.BallSnapshot + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +def longConnectionEvent (G : BondGraph V E) (x y : V) (n : ℕ) : Set (Set E) := + {ω | Conn G ω x y ∧ n ≤ (openSimpleGraph G ω).dist x y} + +def intrinsicSphereEvent (G : BondGraph V E) (x z : V) (j : ℕ) : Set (Set E) := + {ω | z ∈ intrinsicSphere G ω x j} + +theorem measurableSet_intrinsicSphereEvent (G : BondGraph V E) (hloc : LocallyFinite G) + (x z : V) (j : ℕ) (hj : 0 < j) : MeasurableSet (intrinsicSphereEvent G x z j) := by + have he : intrinsicSphereEvent G x z j = + {ω | z ∈ intrinsicBall G ω x j} \ {ω | z ∈ intrinsicBall G ω x (j-1)} := by + ext ω + exact Set.ext_iff.mp (intrinsicSphere_eq_ball_sdiff G ω x j hj) z + rw [he] + exact (measurableSet_mem_intrinsicBall G hloc x z j).diff + (measurableSet_mem_intrinsicBall G hloc x z (j-1)) + +def snapshotFrontierCell (G : BondGraph V E) (x z : V) (j : ℕ) + (a : Finset V × Finset V) : Set (Set E) := + if z ∈ a.2 \ a.1 then ballSnapshotCell G x j a.1 a.2 else ∅ + +theorem snapshotFrontierCell_iUnion (G : BondGraph V E) (hloc : LocallyFinite G) + (x z : V) (j : ℕ) (hj : 0 < j) : + (⋃ a : Finset V × Finset V, snapshotFrontierCell G x z j a) = intrinsicSphereEvent G x z j := by + ext ω + constructor + · intro h + obtain ⟨a,ha⟩ := Set.mem_iUnion.mp h + by_cases hz : z ∈ a.2 \ a.1 + · rw [snapshotFrontierCell,ite_eq_left hz] at ha + change z ∈ intrinsicSphere G ω x j + rw [intrinsicSphere_eq_ball_sdiff G _ x j hj,ha.1,ha.2] + exact_mod_cast hz + · simp only [snapshotFrontierCell,ite_eq_right hz,Set.mem_empty_iff_false] at ha + · intro hz + obtain ⟨a,ha⟩ := exists_ballSnapshotCell G hloc ω x j + have hz' : z ∈ a.2 \ a.1 := by + change z ∈ intrinsicSphere G ω x j at hz + rw [intrinsicSphere_eq_ball_sdiff G _ x j hj,ha.1,ha.2] at hz + exact_mod_cast hz + exact Set.mem_iUnion.mpr ⟨a,by simpa only [snapshotFrontierCell,ite_eq_left hz'] using ha⟩ + +theorem snapshotFrontierCell_pairwise (G : BondGraph V E) (x z : V) (j : ℕ) : + Pairwise (fun a b : Finset V × Finset V => + Disjoint (snapshotFrontierCell G x z j a) (snapshotFrontierCell G x z j b)) := by + intro a b hab + have ha : snapshotFrontierCell G x z j a ⊆ ballSnapshotCell G x j a.1 a.2 := by + unfold snapshotFrontierCell; split <;> simp + have hb : snapshotFrontierCell G x z j b ⊆ ballSnapshotCell G x j b.1 b.2 := by + unfold snapshotFrontierCell; split <;> simp + exact (ballSnapshotCell_pairwise G x j hab).mono ha hb + +theorem measurableSet_snapshotFrontierCell [Countable V] (G : BondGraph V E) + (hloc : LocallyFinite G) (x z : V) (j : ℕ) (a : Finset V × Finset V) : + MeasurableSet (snapshotFrontierCell G x z j a) := by + unfold snapshotFrontierCell + split + · exact measurableSet_ballSnapshotCell G hloc x j a.1 a.2 + · exact MeasurableSet.empty + +theorem longConnection_sphere_bound [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (x y : V) (n j : ℕ) (hj : 0 < j) (hjn : j ≤ n) : + law p (longConnectionEvent G x y n) ≤ + ∑' z, law p (intrinsicSphereEvent G x z j) * law p {ω | Conn G ω z y} := by + let F := fun (a : Finset V × Finset V) (z : V) => + snapshotFrontierCell G x z j a ∩ {ω | Conn G (ω \ ballIncidentEdges G a.1) z y} + have hcover : longConnectionEvent G x y n ⊆ ⋃ a, ⋃ z, F a z := by + rintro ω ⟨hc,hd⟩ + obtain ⟨a,ha⟩ := exists_ballSnapshotCell G hloc ω x j + obtain ⟨z,hz,hfresh,_⟩ := intrinsic_long_connection_fresh G ω x y j 0 hj hc + (by simpa only [Nat.add_zero] using hjn.trans hd) + have hz' : z ∈ a.2 \ a.1 := by + rw [intrinsicSphere_eq_ball_sdiff G _ x j hj,ha.1,ha.2] at hz + exact_mod_cast hz + apply Set.mem_iUnion.mpr + refine ⟨a,Set.mem_iUnion.mpr ⟨z,?_,?_⟩⟩ + · simpa only [snapshotFrontierCell,ite_eq_left hz'] using ha + · rw [ha.1] at hfresh + exact hfresh + have hF (a : Finset V × Finset V) (z : V) : + law p (F a z) ≤ law p (snapshotFrontierCell G x z j a) * law p {ω | Conn G ω z y} := by + by_cases hz : z ∈ a.2 \ a.1 + · dsimp only [F] + rw [snapshotFrontierCell,ite_eq_left hz,ballSnapshotCell_fresh_connection_factor G hloc p x y z j a.1 a.2] + apply mul_le_mul' le_rfl + apply measure_mono + intro ω hω + exact conn_mono G Set.sdiff_subset hω + · simp only [F,snapshotFrontierCell,ite_eq_right hz,Set.empty_inter,measure_empty,zero_mul,le_refl] + calc + _ ≤ law p (⋃ a, ⋃ z, F a z) := measure_mono hcover + _ ≤ ∑' a, ∑' z, law p (F a z) := + (measure_iUnion_le _).trans (ENNReal.tsum_le_tsum (fun a => measure_iUnion_le (F a))) + _ ≤ ∑' a, ∑' z, law p (snapshotFrontierCell G x z j a) * law p {ω | Conn G ω z y} := + ENNReal.tsum_le_tsum (fun a => ENNReal.tsum_le_tsum (hF a)) + _ = ∑' z, (∑' a, law p (snapshotFrontierCell G x z j a)) * law p {ω | Conn G ω z y} := by + rw [ENNReal.tsum_comm] + simp only [ENNReal.tsum_mul_right] + _ = _ := by + apply tsum_congr + intro z + rw [←measure_iUnion (snapshotFrontierCell_pairwise G x z j) + (measurableSet_snapshotFrontierCell G hloc x z j),snapshotFrontierCell_iUnion G hloc x z j hj] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicConnectionAverage.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicConnectionAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9d7f466e60f21b3e065dee6ca713f8fea6d7a35 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicConnectionAverage.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicConnection + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem intrinsic_sphere_interval_sum_le (G : BondGraph V E) (hloc : LocallyFinite G) + (p : unitInterval) (x z : V) (m n : ℕ) : + (∑ j ∈ Finset.Icc (m+1) n, law p (intrinsicSphereEvent G x z j)) ≤ + law p (longConnectionEvent G x z m) := by + have hdisj : (↑(Finset.Icc (m+1) n) : Set ℕ).PairwiseDisjoint (intrinsicSphereEvent G x z) := by + intro i _ j _ hij + apply Set.disjoint_left.mpr + rintro ω ⟨_,hi⟩ ⟨_,hj⟩ + exact hij (hi.symm.trans hj) + rw [←measure_biUnion_finset hdisj (fun j hj => measurableSet_intrinsicSphereEvent G hloc x z j + (by have h := (Finset.mem_Icc.mp hj).1; omega))] + apply measure_mono + intro ω hω + obtain ⟨j,hj⟩ := Set.mem_iUnion.mp hω + obtain ⟨hji,hz⟩ := Set.mem_iUnion.mp hj + exact ⟨hz.1,((Nat.le_succ m).trans (Finset.mem_Icc.mp hji).1).trans_eq hz.2.symm⟩ + +theorem longConnection_interval_bound [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (x y : V) (m n : ℕ) : + (n-m : ℕ) * law p (longConnectionEvent G x y n) ≤ + ∑' z, law p (longConnectionEvent G x z m) * law p {ω | Conn G ω z y} := by + have havg := Finset.sum_le_sum (s := Finset.Icc (m+1) n) (fun j hj => longConnection_sphere_bound G hloc p x y n j + (by have h := (Finset.mem_Icc.mp hj).1; omega) (Finset.mem_Icc.mp hj).2) + have hcard : (Finset.Icc (m+1) n).card = n-m := by rw [Nat.card_Icc]; omega + calc + _ = ∑ j ∈ Finset.Icc (m+1) n, law p (longConnectionEvent G x y n) := by + simp only [Finset.sum_const,nsmul_eq_mul,hcard] + _ ≤ ∑ j ∈ Finset.Icc (m+1) n, + ∑' z, law p (intrinsicSphereEvent G x z j) * law p {ω | Conn G ω z y} := havg + _ = ∑' z, ∑ j ∈ Finset.Icc (m+1) n, + law p (intrinsicSphereEvent G x z j) * law p {ω | Conn G ω z y} := + (Summable.tsum_finsetSum (fun _ _ => ENNReal.summable)).symm + _ = ∑' z, (∑ j ∈ Finset.Icc (m+1) n, law p (intrinsicSphereEvent G x z j)) * + law p {ω | Conn G ω z y} := by simp only [Finset.sum_mul] + _ ≤ _ := ENNReal.tsum_le_tsum (fun z => mul_le_mul' + (intrinsic_sphere_interval_sum_le G hloc p x z m n) le_rfl) + +theorem longConnection_power_bound [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (M k : ℕ) (x y : V) : + (M : ℝ≥0∞)^k * law p (longConnectionEvent G x y (k*M)) ≤ + ennMatrixCoeff (T^(k+1)) x y := by + have hpos := hT.positiveRealMatrix G p T + induction k generalizing x y with + | zero => + rw [pow_zero,one_mul,Nat.zero_mul,pow_one,hT.ennMatrixCoeff G p T] + apply measure_mono + intro ω hω + exact hω.1 + | succ k ih => + have hrec := longConnection_interval_bound G hloc p x y (k*M) ((k+1)*M) + have hsub : (k+1)*M-k*M = M := by rw [Nat.add_mul]; omega + rw [hsub] at hrec + calc + _ = (M : ℝ≥0∞)^k * (M * law p (longConnectionEvent G x y ((k+1)*M))) := by rw [pow_succ,mul_assoc] + _ ≤ (M : ℝ≥0∞)^k * ∑' z, law p (longConnectionEvent G x z (k*M)) * law p {ω | Conn G ω z y} := + mul_le_mul' le_rfl hrec + _ = ∑' z, ((M : ℝ≥0∞)^k * law p (longConnectionEvent G x z (k*M))) * law p {ω | Conn G ω z y} := by + rw [←ENNReal.tsum_mul_left] + simp only [mul_assoc] + _ ≤ ∑' z, ennMatrixCoeff (T^(k+1)) x z * ennMatrixCoeff T z y := by + apply ENNReal.tsum_le_tsum + intro z + rw [hT.ennMatrixCoeff G p T] + exact mul_le_mul' (ih x z) le_rfl + _ = _ := by + rw [←ennMatrixCoeff_mul (hpos.pow (k+1)) hpos,←pow_succ] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicFreshPath.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicFreshPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b6da2e913a432c9257a397d0f5c91f7b89c6446 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicFreshPath.lean @@ -0,0 +1,93 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicSphere + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem shortest_drop_support_distance (G : BondGraph V E) (ω : Set E) + {x y : V} (w : (openSimpleGraph G ω).Walk x y) + (hw : w.length = (openSimpleGraph G ω).dist x y) + (j : ℕ) (hj : j ≤ w.length) (z : V) (hz : z ∈ (w.drop j).support) : + j ≤ (openSimpleGraph G ω).dist x z := by + let k := (w.drop j).support.idxOf z + have hk : k ≤ (w.drop j).length := by + have hh := List.idxOf_lt_length_of_mem hz + rw [SimpleGraph.Walk.length_support] at hh + exact Nat.le_of_lt_succ hh + have hkj : j+k ≤ w.length := by + rw [SimpleGraph.Walk.drop_length] at hk + omega + have hget : w.getVert (j+k) = z := by + rw [←SimpleGraph.Walk.drop_getVert] + exact (w.drop j).getVert_support_idxOf hz + have hshort := SimpleGraph.length_eq_dist_of_subwalk hw (w.isSubwalk_take (j+k)) + rw [SimpleGraph.Walk.take_length,Nat.min_eq_left hkj,hget] at hshort + omega + +theorem intrinsic_long_connection_fresh (G : BondGraph V E) (ω : Set E) + (x y : V) (j r : ℕ) (hj : 0 < j) (hc : Conn G ω x y) + (hlen : j+r ≤ (openSimpleGraph G ω).dist x y) : + ∃ z ∈ intrinsicSphere G ω x j, + Conn G (ω \ ballIncidentEdges G (intrinsicBall G ω x (j-1))) z y ∧ + r ≤ (openSimpleGraph G (ω \ ballIncidentEdges G (intrinsicBall G ω x (j-1)))).dist z y := by + obtain ⟨w,hw⟩ := ((conn_iff_reachable G ω x y).mp hc).exists_walk_length_eq_dist + have hjw : j ≤ w.length := by omega + have hzdist : (openSimpleGraph G ω).dist x (w.getVert j) = j := by + have hh := SimpleGraph.length_eq_dist_of_subwalk hw (w.isSubwalk_take j) + rw [SimpleGraph.Walk.take_length,Nat.min_eq_left hjw] at hh + exact hh.symm + have hz : w.getVert j ∈ intrinsicSphere G ω x j := + ⟨(conn_iff_reachable G ω x _).mpr (w.take j).reachable,hzdist⟩ + let Q := ballIncidentEdges G (intrinsicBall G ω x (j-1)) + have hsupport (z : V) (hz : z ∈ (w.drop j).support) : z ∉ intrinsicBall G ω x (j-1) := by + intro hzB + have hdist := shortest_drop_support_distance G ω w hw j hjw z hz + obtain ⟨l,hl,hlen,ho⟩ := hzB + have hle := (intrinsicBall_iff_distance_le G ω x z (j-1) (hl.conn ho)).mp ⟨l,hl,hlen,ho⟩ + omega + have hedges : ∀ e, e ∈ (w.drop j).edges → e ∈ (openSimpleGraph G (ω \ Q)).edgeSet := by + intro e he + induction e using Sym2.inductionOn with + | hf a b => + have hab : (openSimpleGraph G ω).Adj a b := by + simpa using (w.drop j).edges_subset_edgeSet he + obtain ⟨hne,f,hf,hfab⟩ := hab + have hnot : f ∉ Q := by + rintro ⟨z,hzB,hzf⟩ + rw [hfab] at hzf + rcases (show z = a ∨ z = b from by simpa only [Sym2.mem_iff] using hzf) with hza | hzb + · exact hsupport a ((w.drop j).fst_mem_support_of_mem_edges he) (hza ▸ hzB) + · exact hsupport b ((w.drop j).snd_mem_support_of_mem_edges he) (hzb ▸ hzB) + show (openSimpleGraph G (ω \ Q)).Adj a b + exact ⟨hne,f,⟨hf,hnot⟩,hfab⟩ + let w' := (w.drop j).transfer (openSimpleGraph G (ω \ Q)) hedges + have hc' : Conn G (ω \ Q) (w.getVert j) y := (conn_iff_reachable G _ _ _).mpr w'.reachable + have hle : (openSimpleGraph G ω).dist (w.getVert j) y ≤ + (openSimpleGraph G (ω \ Q)).dist (w.getVert j) y := by + apply SimpleGraph.Reachable.dist_anti (G := openSimpleGraph G (ω \ Q)) + (G' := openSimpleGraph G ω) _ w'.reachable + intro a b hab + obtain ⟨hne,e,he,heq⟩ := hab + exact ⟨hne,e,he.1,heq⟩ + have hdrop := SimpleGraph.length_eq_dist_of_subwalk hw (w.isSubwalk_drop j) + rw [SimpleGraph.Walk.drop_length] at hdrop + refine ⟨w.getVert j,hz,hc',?_⟩ + change r ≤ (openSimpleGraph G (ω \ Q)).dist (w.getVert j) y + omega + +theorem intrinsic_radius_fresh_continuation (G : BondGraph V E) (ω : Set E) + (x : V) (j r : ℕ) (hj : 0 < j) + (hR : ω ∈ intrinsicRadiusEvent G x (j+r)) : + ∃ z ∈ intrinsicSphere G ω x j, + ω \ ballIncidentEdges G (intrinsicBall G ω x (j-1)) ∈ intrinsicRadiusEvent G z r := by + obtain ⟨y,hc,hlen⟩ := hR + obtain ⟨z,hz,hconn,hdist⟩ := intrinsic_long_connection_fresh G ω x y j r hj hc hlen + exact ⟨z,hz,y,hconn,hdist⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicRadiusLower.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicRadiusLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..11386794365a5bea4491f1263d450450f42b81ef --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicRadiusLower.lean @@ -0,0 +1,112 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicBallGrowth +import OAI.Probability.BenjaminiSchramm.VolumeLower + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem cluster_eq_intrinsicBall_of_not_radius (G : BondGraph V E) + (ω : Set E) (x : V) (r : ℕ) (hr : ω ∉ intrinsicRadiusEvent G x r) : + cluster G ω x = intrinsicBall G ω x r := by + apply Set.Subset.antisymm + · intro y hy + apply (intrinsicBall_iff_distance_le G ω x y r hy).mpr + have hn : ¬ r ≤ (openSimpleGraph G ω).dist x y := fun hd => hr ⟨y,hy,hd⟩ + omega + · rintro y ⟨l,hl,_,ho⟩ + exact hl.conn ho + +theorem volume_le_radius_add_intrinsicBallMoment [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (x : V) (r N : ℕ) (hN : 0 < N) : + (law p (volumeEvent G x N)).toReal ≤ + (law p (intrinsicRadiusEvent G x r)).toReal + + intrinsicBallMoment G hloc Set.univ x r p / N := by + let A : Set (Set E) := {ω | (N : ℝ) ≤ (intrinsicBall G ω x r).ncard} + have hsub : volumeEvent G x N ⊆ intrinsicRadiusEvent G x r ∪ A := by + intro ω hω + by_cases hr : ω ∈ intrinsicRadiusEvent G x r + · exact Or.inl hr + · apply Or.inr + have hf := (finite_reachBall hloc x r).subset (intrinsicBall_subset_reachBall G ω x r) + have he := cluster_eq_intrinsicBall_of_not_radius G ω x r hr + change (N : ℕ∞) ≤ (cluster G ω x).encard at hω + rw [he,←hf.cast_ncard_eq] at hω + have hn : N ≤ (intrinsicBall G ω x r).ncard := by exact_mod_cast hω + change (N : ℝ) ≤ (intrinsicBall G ω x r).ncard + exact_mod_cast hn + have hm := mul_meas_ge_le_integral_of_nonneg + (μ := law p) (f := fun ω => ((intrinsicBall G ω x r).ncard : ℝ)) + (Filter.Eventually.of_forall (fun ω => Nat.cast_nonneg _)) + (by simpa only [Set.inter_univ] using integrable_intrinsicBall_ncard G hloc Set.univ x r p) (N : ℝ) + have he : (∫ ω, ((intrinsicBall G ω x r).ncard : ℝ) ∂law p) = + intrinsicBallMoment G hloc Set.univ x r p := by + simpa only [Set.inter_univ] using integral_intrinsicBall_ncard_eq G hloc Set.univ x r p + rw [he] at hm + have hmark : (law p A).toReal ≤ intrinsicBallMoment G hloc Set.univ x r p / N := by + apply (le_div_iff₀ (show (0 : ℝ) < N by exact_mod_cast hN)).mpr + change (N : ℝ) * (law p A).toReal ≤ _ at hm + simpa only [mul_comm] using hm + exact (measureReal_mono hsub).trans ((measureReal_union_le _ _).trans (add_le_add le_rfl hmark)) + +theorem critical_intrinsic_radius_lower_of_volume_and_ball [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (x : V) + (a C : ℝ) (ha : 0 < a) (_hC : 0 < C) + (hvol : ∀ N : ℕ, 0 < N → a / Real.sqrt N ≤ criticalTail G (volumeEvent G) x N) + (hball : ∀ r : ℕ, 0 < r → intrinsicBallMoment G hloc Set.univ x r (pc G) ≤ C * r) : + ∃ c : ℝ, 0 < c ∧ ∀ r : ℕ, 0 < r → + c / r ≤ criticalTail G (intrinsicRadiusEvent G) x r := by + obtain ⟨m,hm⟩ := exists_nat_gt (max 1 (2*C/a)) + have hm1 : 1 < (m : ℝ) := (le_max_left _ _).trans_lt hm + have hm0 : 0 < m := by exact_mod_cast (zero_lt_one.trans hm1) + have hma : 2*C < a*m := by + have hh := (div_lt_iff₀ ha).mp ((le_max_right _ _).trans_lt hm) + nlinarith + refine ⟨a/(2*m),by positivity,fun r hr => ?_⟩ + let N := (m*r)^2 + have hr0 : 0 < (r : ℝ) := by exact_mod_cast hr + have hN : 0 < N := by dsimp [N]; positivity + have hNr : (N : ℝ) = ((m : ℝ)*r)^2 := by dsimp [N]; push_cast; rfl + have hsqrt : Real.sqrt N = (m : ℝ)*r := by + rw [hNr,Real.sqrt_sq (by positivity)] + have hb := volume_le_radius_add_intrinsicBallMoment G hloc (pc G) x r N hN + have hv := hvol N hN + have hballs := hball r hr + change a / Real.sqrt N ≤ (law (pc G) (volumeEvent G x N)).toReal at hv + have hbound : a / ((m : ℝ)*r) ≤ criticalTail G (intrinsicRadiusEvent G) x r + C*r / N := by + rw [hsqrt] at hv + exact hv.trans (hb.trans (add_le_add le_rfl + (div_le_div_of_nonneg_right hballs (Nat.cast_nonneg N)))) + rw [hNr] at hbound + have hmR : 0 < (m : ℝ) := by positivity + have hmult := (div_le_iff₀ (mul_pos hmR hr0)).mp hbound + have hcancel : (criticalTail G (intrinsicRadiusEvent G) x r + C*r / ((m : ℝ)*r)^2) * ((m : ℝ)*r) = + criticalTail G (intrinsicRadiusEvent G) x r * ((m : ℝ)*r) + C/m := by + field_simp + rw [hcancel] at hmult + have hCm : C/m ≤ a/2 := by apply (div_le_iff₀ hmR).mpr; nlinarith + apply (div_le_iff₀ hr0).mpr + apply (div_le_iff₀ (by positivity : (0 : ℝ) < 2*m)).mpr + nlinarith + +theorem critical_intrinsic_radius_lower_of_operator [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (hpc1 : (pc G : ℝ) < 1) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) (x : V) : + ∃ c : ℝ, 0 < c ∧ ∀ r : ℕ, 0 < r → + c / r ≤ criticalTail G (intrinsicRadiusEvent G) x r := by + obtain ⟨A,hA,hχ⟩ := susceptibility_upper_of_critical_operator G hconn hloc hqt hh T hT + obtain ⟨C,hC,hball⟩ := critical_intrinsicBallMoment_linear G hloc hqt A hA hχ + obtain ⟨B,hB,hvol⟩ := critical_volume_upper_of_operator G hconn hloc hqt hh hpc1 T hT + obtain ⟨a,ha,hlo⟩ := critical_volume_lower_of_upper G hconn hloc hqt hpc1 B hB hvol x + exact critical_intrinsic_radius_lower_of_volume_and_ball G hloc x a C ha hC hlo (hball Set.univ x) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicRadiusUpper.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicRadiusUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea5bd247d7207a1cad26c6d52a0d08385add3071 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicRadiusUpper.lean @@ -0,0 +1,120 @@ +import OAI.Probability.BenjaminiSchramm.ThinSphereRecurrence +import OAI.Probability.BenjaminiSchramm.OperatorSusceptibility +import OAI.Probability.BenjaminiSchramm.GeneralCriticalFiniteness + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem thin_sphere_volume_scale (C A : ℝ) (hC : 0 < C) (hA : 0 < A) + (hlarge : 1000*C^2 ≤ A) (r : ℕ) (hr : 0 < r) : + C / Real.sqrt ((r+1)*(Nat.floor ((r : ℝ)/(10*A))+1) : ℕ) ≤ A/(10*r) := by + let k := Nat.floor ((r : ℝ)/(10*A)) + have hr0 : 0 < (r : ℝ) := by exact_mod_cast hr + have hk := (Nat.lt_floor_add_one ((r : ℝ)/(10*A))).le + have hscale : (r : ℝ)^2/(10*A) ≤ ((r+1)*(k+1) : ℕ) := by + push_cast + calc + _ = (r : ℝ) * ((r : ℝ)/(10*A)) := by ring + _ ≤ (r : ℝ) * (k+1) := mul_le_mul_of_nonneg_left hk hr0.le + _ ≤ _ := by nlinarith [show (0 : ℝ) ≤ k from Nat.cast_nonneg k] + have hs : 0 < Real.sqrt (10*A) := Real.sqrt_pos.mpr (by positivity) + have hsN : (r : ℝ) / Real.sqrt (10*A) ≤ Real.sqrt ((r+1)*(k+1) : ℕ) := by + have hh := Real.sqrt_le_sqrt hscale + rw [Real.sqrt_div (sq_nonneg (r : ℝ)) (10*A),Real.sqrt_sq hr0.le] at hh + exact hh + have hcoeff : C * Real.sqrt (10*A) ≤ A/10 := by + have hm := mul_le_mul_of_nonneg_right hlarge hA.le + apply (sq_le_sq₀ (by positivity) (by positivity)).mp + calc + (C * Real.sqrt (10*A))^2 = C^2*(10*A) := by rw [mul_pow,Real.sq_sqrt (by positivity)] + _ ≤ (A/10)^2 := by nlinarith + calc + _ ≤ C / ((r : ℝ)/Real.sqrt (10*A)) := + div_le_div_of_nonneg_left hC.le (div_pos hr0 hs) hsN + _ = (C*Real.sqrt (10*A)) / r := by field_simp + _ ≤ (A/10)/r := div_le_div_of_nonneg_right hcoeff hr0.le + _ = _ := by ring + +theorem intrinsic_radius_upper_of_volume [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (hfin : ∀ x, ∀ᵐ ω ∂law p, (cluster G ω x).Finite) + (C : ℝ) (hC : 0 < C) + (hvol : ∀ (x : V) (N : ℕ), 0 < N → (law p (volumeEvent G x N)).toReal ≤ C/Real.sqrt N) : + ∃ A : ℝ, 0 < A ∧ ∀ (S : Set E) x (n : ℕ), 0 < n → + (law p (domainRadiusEvent G S x n)).toReal ≤ A/n := by + let A := max 2 (1000*C^2) + have hA2 : 2 ≤ A := le_max_left _ _ + have hA : 0 < A := lt_of_lt_of_le (by norm_num) hA2 + have hlarge : 1000*C^2 ≤ A := le_max_right _ _ + refine ⟨A,hA,?_⟩ + suffices H : ∀ n : ℕ, ∀ (S : Set E) x, 0 < n → + (law p (domainRadiusEvent G S x n)).toReal ≤ A/n from fun S x n hn => H n S x hn + intro n + induction n using Nat.strong_induction_on with + | h n ih => + intro S x hn + by_cases hn3 : n < 3 + · apply measureReal_le_one.trans + apply (le_div_iff₀ (show (0 : ℝ) < n by exact_mod_cast hn)).mpr + have hn2 : (n : ℝ) ≤ 2 := by exact_mod_cast (show n ≤ 2 by omega) + simpa only [one_mul] using hn2.trans hA2 + · let r := n/3 + have hr : 0 < r := Nat.div_pos (by omega) (by norm_num) + have hrn : r < n := Nat.div_lt_self hn (by norm_num) + have h3r : 3*r ≤ n := Nat.mul_div_le n 3 + have hn5 : n ≤ 5*r := by have hh := Nat.mod_lt n (by norm_num : 0 < 3); omega + have hr0 : 0 < (r : ℝ) := by exact_mod_cast hr + let k := Nat.floor ((r : ℝ)/(10*A)) + let b : ℝ≥0∞ := ENNReal.ofReal (A/r) + have hb (I : Set E) (z : V) : law p (domainRadiusEvent G I z r) ≤ b := by + rw [←ENNReal.ofReal_toReal (measure_ne_top _ _)] + exact ENNReal.ofReal_le_ofReal (ih r hrn I z hr) + have hrec := radius_thin_sphere_recurrence G hloc p hfin r k hr b hb S x + have hrecR := ENNReal.toReal_mono + (show law p (volumeEvent G x ((r+1)*(k+1))) + k*b^2 ≠ ⊤ by finiteness) hrec + dsimp only [b] at hrecR + rw [ENNReal.toReal_add (measure_ne_top _ _) (by finiteness), ENNReal.toReal_mul, + ENNReal.toReal_natCast,ENNReal.toReal_pow,ENNReal.toReal_ofReal (by positivity)] at hrecR + have hN : 0 < (r+1)*(k+1) := by positivity + have hV : (law p (volumeEvent G x ((r+1)*(k+1)))).toReal ≤ A/(10*r) := + (hvol x _ hN).trans (thin_sphere_volume_scale C A hC hA hlarge r hr) + have hk : (k : ℝ) ≤ (r : ℝ)/(10*A) := Nat.floor_le (by positivity) + have hK : (k : ℝ)*(A/r)^2 ≤ A/(10*r) := by + calc + _ ≤ ((r : ℝ)/(10*A))*(A/r)^2 := mul_le_mul_of_nonneg_right hk (sq_nonneg _) + _ = _ := by field_simp + have hsurv : (law p (domainRadiusEvent G S x (3*r))).toReal ≤ A/(5*r) := by + calc + _ ≤ A/(10*r)+A/(10*r) := hrecR.trans (add_le_add hV hK) + _ = _ := by ring + calc + _ ≤ (law p (domainRadiusEvent G S x (3*r))).toReal := by + apply ENNReal.toReal_mono (measure_ne_top _ _) + apply measure_mono + rintro ω ⟨y,hc,hd⟩ + exact ⟨y,hc,h3r.trans hd⟩ + _ ≤ A/(5*r) := hsurv + _ ≤ A/n := div_le_div_of_nonneg_left hA.le + (show (0 : ℝ) < n by exact_mod_cast hn) (by exact_mod_cast hn5) + +theorem critical_intrinsic_radius_upper_of_operator [Infinite V] [Countable V] [Countable E] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (hpc1 : (pc G : ℝ) < 1) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) : + ∃ A : ℝ, 0 < A ∧ ∀ (S : Set E) x (n : ℕ), 0 < n → + (law (pc G) (domainRadiusEvent G S x n)).toReal ≤ A/n := by + obtain ⟨C,hC,hvol⟩ := critical_volume_upper_of_operator G hconn hloc hqt hh hpc1 T hT + exact intrinsic_radius_upper_of_volume G hloc (pc G) + (critical_finite_general G hconn hloc hqt hpc1) C hC hvol + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/IntrinsicSphere.lean b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicSphere.lean new file mode 100644 index 0000000000000000000000000000000000000000..672939b9411d955ae8b63101cbee0990d43e8050 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/IntrinsicSphere.lean @@ -0,0 +1,85 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicBallExposure + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +def intrinsicSphere (G : BondGraph V E) (ω : Set E) (x : V) (n : ℕ) : Set V := + {y | Conn G ω x y ∧ (openSimpleGraph G ω).dist x y = n} + +theorem exists_intrinsic_distance_eq (G : BondGraph V E) (ω : Set E) + (x y : V) (hc : Conn G ω x y) (n : ℕ) + (hn : n ≤ (openSimpleGraph G ω).dist x y) : + ∃ z, Conn G ω x z ∧ (openSimpleGraph G ω).dist x z = n := by + obtain ⟨w,hw⟩ := ((conn_iff_reachable G ω x y).mp hc).exists_walk_length_eq_dist + have hshort := SimpleGraph.length_eq_dist_of_subwalk hw (w.isSubwalk_take n) + have hlen : (w.take n).length = n := by + rw [SimpleGraph.Walk.take_length,Nat.min_eq_left (by omega)] + exact ⟨w.getVert n,(conn_iff_reachable G ω x _).mpr (w.take n).reachable, + hshort.symm.trans hlen⟩ + +theorem intrinsicRadiusEvent_iff_sphere (G : BondGraph V E) (ω : Set E) + (x : V) (n : ℕ) : + ω ∈ intrinsicRadiusEvent G x n ↔ (intrinsicSphere G ω x n).Nonempty := by + constructor + · rintro ⟨y,hc,hn⟩ + exact exists_intrinsic_distance_eq G ω x y hc n hn + · rintro ⟨y,hc,hn⟩ + exact ⟨y,hc,hn.ge⟩ + +theorem intrinsicSphere_eq_ball_sdiff (G : BondGraph V E) (ω : Set E) + (x : V) (n : ℕ) (hn : 0 < n) : + intrinsicSphere G ω x n = intrinsicBall G ω x n \ intrinsicBall G ω x (n-1) := by + ext y + constructor + · rintro ⟨hc,hd⟩ + refine ⟨(intrinsicBall_iff_distance_le G ω x y n hc).mpr hd.le,?_⟩ + rw [intrinsicBall_iff_distance_le G ω x y (n-1) hc,hd] + omega + · rintro ⟨hy,hnot⟩ + obtain ⟨l,hl,hlen,ho⟩ := hy + have hc := hl.conn ho + have hle := (intrinsicBall_iff_distance_le G ω x y n hc).mp ⟨l,hl,hlen,ho⟩ + rw [intrinsicBall_iff_distance_le G ω x y (n-1) hc] at hnot + exact ⟨hc,by omega⟩ + +theorem intrinsicSphere_finite (G : BondGraph V E) (hloc : LocallyFinite G) + (ω : Set E) (x : V) (n : ℕ) : (intrinsicSphere G ω x n).Finite := by + apply (finite_reachBall hloc x n).subset + rintro y ⟨hc,hd⟩ + exact intrinsicBall_subset_reachBall G ω x n + ((intrinsicBall_iff_distance_le G ω x y n hc).mpr hd.le) + +theorem intrinsicRadiusEvent_local (G : BondGraph V E) (hloc : LocallyFinite G) + (ω : Set E) (x : V) (n : ℕ) : + ω ∩ (incidentSupport G hloc (finite_reachBall hloc x n).toFinset : Set E) ∈ + intrinsicRadiusEvent G x n ↔ ω ∈ intrinsicRadiusEvent G x n := by + by_cases hn : n = 0 + · subst n + constructor <;> intro _ <;> exact ⟨x,mem_cluster_self G _ x,Nat.zero_le _⟩ + · have hn0 : 0 < n := Nat.pos_of_ne_zero hn + rw [intrinsicRadiusEvent_iff_sphere,intrinsicRadiusEvent_iff_sphere, + intrinsicSphere_eq_ball_sdiff G _ x n hn0,intrinsicSphere_eq_ball_sdiff G _ x n hn0, + intrinsicBall_restrict G hloc] + have he : intrinsicBall G + (ω ∩ (incidentSupport G hloc (finite_reachBall hloc x n).toFinset : Set E)) x (n-1) = + intrinsicBall G ω x (n-1) := by + apply Set.Subset.antisymm (intrinsicBall_mono G Set.inter_subset_left x (n-1)) + rintro y ⟨l,hl,hlen,ho⟩ + exact ⟨l,hl,hlen,fun e he => ⟨ho e he, + hl.bonds_in_incidentBall hloc n (hlen.trans (Nat.sub_le n 1)) e he⟩⟩ + rw [he] + +theorem intrinsicSphere_disjoint (G : BondGraph V E) (ω : Set E) (x : V) + {m n : ℕ} (hmn : m ≠ n) : Disjoint (intrinsicSphere G ω x m) (intrinsicSphere G ω x n) := by + apply Set.disjoint_left.mpr + rintro y ⟨_,hm⟩ ⟨_,hn⟩ + exact hmn (hm.symm.trans hn) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/KernelDeletionDiagram.lean b/lean/OAI/Probability/BenjaminiSchramm/KernelDeletionDiagram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b7934fb325c0dc82069c0255f823c9def6a24b3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/KernelDeletionDiagram.lean @@ -0,0 +1,64 @@ +import OAI.Probability.BenjaminiSchramm.OpenTriangle + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +noncomputable def kernelTriangleDiagonal (G : BondGraph V E) (p : unitInterval) + (K : V → V → ℝ≥0∞) (u : V) : ℝ≥0∞ := + ∑' a, ∑' b, ∑' z, law p {ω | Conn G ω u a} * K a b * + law p {ω | Conn G ω b z} * law p {ω | Conn G ω u z} + +noncomputable def kernelDeletionDiagram (G : BondGraph V E) (p : unitInterval) + (K : V → V → ℝ≥0∞) (x : V) : ℝ≥0∞ := + ∑' a, ∑' b, ∑' z, K a b * law p {ω | Conn G ω b z} * + law p {ω | Conn G ω x a ∧ Conn G ω x z} + +theorem kernelDeletionDiagram_bound [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (K : V → V → ℝ≥0∞) + (ε : ℝ≥0∞) (hε : ∀ u, kernelTriangleDiagonal G p K u ≤ ε) (x : V) : + kernelDeletionDiagram G p K x ≤ ε * ∑' u, law p {ω | Conn G ω x u} := by + let f (a b z u : V) : ℝ≥0∞ := K a b * law p {ω | Conn G ω b z} * + (law p {ω | Conn G ω x u} * law p {ω | Conn G ω u a} * law p {ω | Conn G ω u z}) + have hswap : (∑' a, ∑' b, ∑' z, ∑' u, f a b z u) = + ∑' u, ∑' a, ∑' b, ∑' z, f a b z u := by + calc + _ = ∑' a, ∑' b, ∑' u, ∑' z, f a b z u := + tsum_congr (fun _ => tsum_congr (fun _ => ENNReal.tsum_comm)) + _ = ∑' a, ∑' u, ∑' b, ∑' z, f a b z u := + tsum_congr (fun _ => ENNReal.tsum_comm) + _ = _ := ENNReal.tsum_comm + calc + _ ≤ ∑' a, ∑' b, ∑' z, K a b * law p {ω | Conn G ω b z} * + (∑' u, law p {ω | Conn G ω x u} * law p {ω | Conn G ω u a} * + law p {ω | Conn G ω u z}) := + ENNReal.tsum_le_tsum (fun a => ENNReal.tsum_le_tsum (fun b => + ENNReal.tsum_le_tsum (fun z => mul_le_mul' le_rfl (three_arm_bound G p x a z)))) + _ = ∑' a, ∑' b, ∑' z, ∑' u, f a b z u := by + simp only [f,ENNReal.tsum_mul_left] + _ = ∑' u, ∑' a, ∑' b, ∑' z, f a b z u := hswap + _ = ∑' u, law p {ω | Conn G ω x u} * kernelTriangleDiagonal G p K u := by + apply tsum_congr + intro u + simp only [kernelTriangleDiagonal,←ENNReal.tsum_mul_left] + apply tsum_congr + intro a + apply tsum_congr + intro b + apply tsum_congr + intro z + dsimp only [f] + ring + _ ≤ ∑' u, law p {ω | Conn G ω x u} * ε := + ENNReal.tsum_le_tsum (fun u => mul_le_mul' le_rfl (hε u)) + _ = _ := by rw [ENNReal.tsum_mul_right,mul_comm] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/KernelDeletionOperator.lean b/lean/OAI/Probability/BenjaminiSchramm/KernelDeletionOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..33c085692e5832d2891649dc7e1ca1beddb98215 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/KernelDeletionOperator.lean @@ -0,0 +1,91 @@ +import OAI.Probability.BenjaminiSchramm.KernelDeletionDiagram +import OAI.Probability.UnimodularPercolation.Kernel.ContactTrace + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem kernelTriangleDiagonal_eq_matrix [Countable E] + (G : BondGraph V E) (p : unitInterval) + (T K : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (hK : PositiveRealMatrix K) (u : V) : + kernelTriangleDiagonal G p (ennMatrixCoeff K) u = + ennMatrixCoeff (T * (K * (T*T))) u u := by + have ht := hT.positiveRealMatrix G p T + rw [ennMatrixCoeff_mul ht (hK.mul (ht.mul ht))] + apply tsum_congr + intro a + rw [ennMatrixCoeff_mul hK (ht.mul ht),←ENNReal.tsum_mul_left] + apply tsum_congr + intro b + rw [ennMatrixCoeff_mul ht ht,←ENNReal.tsum_mul_left,←ENNReal.tsum_mul_left] + apply tsum_congr + intro z + simp only [hT.ennMatrixCoeff G p T,connection_measure_symm G p u z] + ring + +theorem matrixCoeff_norm_le (A : Hilbert V →L[ℂ] Hilbert V) (x y : V) : + ‖matrixCoeff A x y‖ ≤ ‖A‖ := by + change ‖A (lp.single 2 y (1 : ℂ)) x‖ ≤ ‖A‖ + apply (lp.norm_apply_le_norm (by norm_num : (2 : ENNReal) ≠ 0) + (A (lp.single 2 y (1 : ℂ))) x).trans + simpa only [lp.norm_single (by norm_num : 0 < (2 : ENNReal)),norm_one,mul_one] using + A.le_opNorm (lp.single 2 y (1 : ℂ)) + +theorem kernelTriangleDiagonal_norm_bound [Countable E] + (G : BondGraph V E) (p : unitInterval) + (T K : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (hK : PositiveRealMatrix K) (u : V) : + kernelTriangleDiagonal G p (ennMatrixCoeff K) u ≤ ENNReal.ofReal (‖T‖ ^ 3 * ‖K‖) := by + rw [kernelTriangleDiagonal_eq_matrix G p T K hT hK u] + apply ENNReal.ofReal_le_ofReal + apply (Complex.re_le_norm _).trans ((matrixCoeff_norm_le _ u u).trans _) + calc + ‖T * (K * (T*T))‖ ≤ ‖T‖ * ‖K * (T*T)‖ := norm_mul_le _ _ + _ ≤ ‖T‖ * (‖K‖ * ‖T*T‖) := + mul_le_mul_of_nonneg_left (norm_mul_le _ _) (norm_nonneg _) + _ ≤ ‖T‖ * (‖K‖ * (‖T‖ * ‖T‖)) := + mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (norm_mul_le _ _) (norm_nonneg _)) (norm_nonneg _) + _ = _ := by ring + +theorem connection_measure_mono [Countable V] [Countable E] (G : BondGraph V E) (x y : V) + {p q : unitInterval} (hpq : p ≤ q) : + law p {ω | Conn G ω x y} ≤ law q {ω | Conn G ω x y} := by + apply (ENNReal.toReal_le_toReal (measure_ne_top _ _) (measure_ne_top _ _)).mp + exact twoPoint_mono G x y hpq + +theorem kernelTriangleDiagonal_mono [Countable V] [Countable E] (G : BondGraph V E) + (K : V → V → ℝ≥0∞) (u : V) {p q : unitInterval} (hpq : p ≤ q) : + kernelTriangleDiagonal G p K u ≤ kernelTriangleDiagonal G q K u := by + apply ENNReal.tsum_le_tsum + intro a + apply ENNReal.tsum_le_tsum + intro b + apply ENNReal.tsum_le_tsum + intro z + exact mul_le_mul' (mul_le_mul' + (mul_le_mul' (connection_measure_mono G u a hpq) le_rfl) + (connection_measure_mono G b z hpq)) (connection_measure_mono G u z hpq) + +theorem kernelDeletionDiagram_le_critical_norm [Countable V] [Countable E] + (G : BondGraph V E) (T K : Hilbert V →L[ℂ] Hilbert V) + (hT : HasKernel G (pc G) T) (hK : PositiveRealMatrix K) + (p : unitInterval) (hp : p ≤ pc G) (x : V) : + kernelDeletionDiagram G p (ennMatrixCoeff K) x ≤ + ENNReal.ofReal (‖T‖ ^ 3 * ‖K‖) * ∑' u, law p {ω | Conn G ω x u} := by + apply kernelDeletionDiagram_bound + intro u + exact (kernelTriangleDiagonal_mono G (ennMatrixCoeff K) u hp).trans + (kernelTriangleDiagonal_norm_bound G (pc G) T K hT hK u) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/KernelExterior.lean b/lean/OAI/Probability/BenjaminiSchramm/KernelExterior.lean new file mode 100644 index 0000000000000000000000000000000000000000..d63c4fdc3e3df284aad0f6cfef37acdadd7a8bc6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/KernelExterior.lean @@ -0,0 +1,71 @@ +import OAI.Probability.BenjaminiSchramm.ExteriorConnection + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +noncomputable def kernelExteriorPotential (G : BondGraph V E) (p : unitInterval) + (K : V → V → ℝ≥0∞) (x : V) : ℝ≥0∞ := + ∑' a, ∑' b, K a b * exteriorConnectionMoment G p x a b + +theorem kernelExteriorPotential_lower [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (K : V → V → ℝ≥0∞) + (hK : ∀ a, ∑' b, K a b = 1) (c C : ℝ≥0∞) + (hc : ∀ b, c ≤ ENNReal.ofReal (susceptibility G p b)) + (hC : ∀ b, ENNReal.ofReal (susceptibility G p b) ≤ C) (x : V) : + c * (∑' a, law p {ω | Conn G ω x a}) ≤ + kernelExteriorPotential G p K x + C * kernelDeletionDiagram G p K x := by + calc + _ = ∑' a, ∑' b, K a b * + (law p {ω | Conn G ω x a} * c) := by + simp only [ENNReal.tsum_mul_right,hK,one_mul,mul_comm c] + _ ≤ ∑' a, ∑' b, K a b * + (law p {ω | Conn G ω x a} * ENNReal.ofReal (susceptibility G p b)) := + ENNReal.tsum_le_tsum (fun a => ENNReal.tsum_le_tsum (fun b => + mul_le_mul' le_rfl (mul_le_mul' le_rfl (hc b)))) + _ ≤ ∑' a, ∑' b, K a b * + (exteriorConnectionMoment G p x a b + C * + ∑' z, law p {ω | Conn G ω x a ∧ Conn G ω x z} * law p {ω | Conn G ω b z}) := + ENNReal.tsum_le_tsum (fun a => ENNReal.tsum_le_tsum (fun b => + mul_le_mul' le_rfl (connection_exterior_comparison G hloc hqt p hp C hC x a b))) + _ = _ := by + simp only [mul_add,ENNReal.tsum_add,kernelExteriorPotential,kernelDeletionDiagram] + congr 1 + simp only [←ENNReal.tsum_mul_left] + apply tsum_congr + intro a + apply tsum_congr + intro b + apply tsum_congr + intro z + ring + +theorem kernelExteriorPotential_lower_of_critical [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (T K : Hilbert V →L[ℂ] Hilbert V) + (hT : HasKernel G (pc G) T) (hK : PositiveRealMatrix K) + (hrow : ∀ a, ∑' b, ennMatrixCoeff K a b = 1) (c C : ℝ≥0∞) + (hc : ∀ b, c ≤ ENNReal.ofReal (susceptibility G p b)) + (hC : ∀ b, ENNReal.ofReal (susceptibility G p b) ≤ C) (x : V) : + c * ENNReal.ofReal (susceptibility G p x) ≤ + kernelExteriorPotential G p (ennMatrixCoeff K) x + + C * ENNReal.ofReal (‖T‖^3 * ‖K‖) * ENNReal.ofReal (susceptibility G p x) := by + have hh := kernelExteriorPotential_lower G hloc hqt p hp (ennMatrixCoeff K) hrow c C hc hC x + rw [←ennreal_susceptibility G hloc hqt p hp x] at hh + apply hh.trans + apply add_le_add_right + have he := kernelDeletionDiagram_le_critical_norm G T K hT hK p hp.le x + rw [←ennreal_susceptibility G hloc hqt p hp x] at he + simpa only [mul_assoc] using mul_le_mul' (le_refl C) he + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/KernelExteriorBound.lean b/lean/OAI/Probability/BenjaminiSchramm/KernelExteriorBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..3901cf797e51d7d1760f021f602905ae08027e13 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/KernelExteriorBound.lean @@ -0,0 +1,179 @@ +import OAI.Probability.BenjaminiSchramm.ExteriorContact +import OAI.Probability.BenjaminiSchramm.BoundaryMultiplicity + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem adjacencyKernel_le_indexed (G : BondGraph V E) (a b : V) : + (if Adj G a b then (1 : ℝ≥0∞) else 0) ≤ indexedEdgeKernel G a b := by + by_cases h : Adj G a b + · obtain ⟨e,he⟩ := h + rw [ite_eq_left ⟨e,he⟩] + change (1 : ℝ≥0∞) ≤ ∑' e, if G e = s(a,b) then 1 else 0 + simpa only [ite_eq_left he] using + (ENNReal.le_tsum (f := fun e => if G e = s(a,b) then (1 : ℝ≥0∞) else 0) e) + · simp only [ite_eq_right h,zero_le] + +theorem neighborSusceptibility_le_edge_action (G : BondGraph V E) (hloc : LocallyFinite G) + (D : Set V) (p : unitInterval) (a : V) : + ENNReal.ofReal (∑ b ∈ neighbors G hloc a, inducedSusceptibility G D p b) ≤ + ∑' b, indexedEdgeKernel G a b * ENNReal.ofReal (inducedSusceptibility G D p b) := by + rw [ENNReal.ofReal_sum_of_nonneg (fun b _ => inducedSusceptibility_nonneg G D p b)] + have he : (∑ b ∈ neighbors G hloc a, ENNReal.ofReal (inducedSusceptibility G D p b)) = + ∑' b, (if Adj G a b then (1 : ℝ≥0∞) else 0) * + ENNReal.ofReal (inducedSusceptibility G D p b) := by + rw [tsum_eq_sum (s := neighbors G hloc a) (fun b hb => by + rw [ite_eq_right (fun h => hb ((mem_neighbors G hloc a b).mpr h)),zero_mul])] + apply Finset.sum_congr rfl + intro b hb + rw [ite_eq_left ((mem_neighbors G hloc a b).mp hb),one_mul] + rw [he] + exact ENNReal.tsum_le_tsum (fun b => mul_le_mul' (adjacencyKernel_le_indexed G a b) le_rfl) + +theorem finite_kernel_exterior_bound [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) + (d : ℕ) (hd : ∀ a, degree G a ≤ d) (M : ℕ) (K : V → V → ℝ≥0∞) + (hrow : ∀ a, ∑' b, K a b = 1) + (hsupport : ∀ a b, b ∉ reachBall G a M → K a b = 0) + (W : Finset V) : + (∑ a ∈ W, ∑' b, K a b * ENNReal.ofReal (inducedSusceptibility G (W : Set V)ᶜ p b)) ≤ + ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ((d+1)^M : ℕ) * + ∑ a ∈ W, ∑' b, indexedEdgeKernel G a b * + ENNReal.ofReal (inducedSusceptibility G (W : Set V)ᶜ p b) := by + have hb (a : V) (ha : a ∈ W) : + (∑' b, K a b * ENNReal.ofReal (inducedSusceptibility G (W : Set V)ᶜ p b)) ≤ + ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * + ENNReal.ofReal (deletedBoundaryPotential G hloc (W : Set V)ᶜ p a M) := by + calc + _ ≤ ∑' b, K a b * + (ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * + ENNReal.ofReal (deletedBoundaryPotential G hloc (W : Set V)ᶜ p a M)) := by + apply ENNReal.tsum_le_tsum + intro b + by_cases hball : b ∈ reachBall G a M + · apply mul_le_mul' le_rfl + rw [←ENNReal.ofReal_mul (zpow_nonneg p.2.1 _)] + apply ENNReal.ofReal_le_ofReal + exact inducedSusceptibility_ball_bound G hloc (W : Set V)ᶜ p hp0 a b M + (by simpa only [Set.mem_compl_iff,Finset.mem_coe,not_not] using ha) hball + (fun c => summable_restrictedTwoPoint G hloc hqt p hp _ c) + · rw [hsupport a b hball,zero_mul,zero_mul] + _ = _ := by rw [ENNReal.tsum_mul_right,hrow,one_mul] + calc + _ ≤ ∑ a ∈ W, ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * + ENNReal.ofReal (deletedBoundaryPotential G hloc (W : Set V)ᶜ p a M) := + Finset.sum_le_sum hb + _ = ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ENNReal.ofReal + (∑ a ∈ W, deletedBoundaryPotential G hloc (W : Set V)ᶜ p a M) := by + rw [ENNReal.ofReal_sum_of_nonneg + (fun a _ => deletedBoundaryPotential_nonneg G hloc _ p a M),Finset.mul_sum] + _ ≤ ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ENNReal.ofReal + (((d+1)^M : ℕ) * ∑ a ∈ W, ∑ b ∈ neighbors G hloc a, + inducedSusceptibility G (W : Set V)ᶜ p b) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal + (deletedBoundaryPotential_sum_bound G hloc d hd M W p)) + _ = ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ((d+1)^M : ℕ) * + ∑ a ∈ W, ENNReal.ofReal (∑ b ∈ neighbors G hloc a, + inducedSusceptibility G (W : Set V)ᶜ p b) := by + rw [ENNReal.ofReal_mul (Nat.cast_nonneg _),ENNReal.ofReal_natCast, + ENNReal.ofReal_sum_of_nonneg (fun a _ => Finset.sum_nonneg + (fun b _ => inducedSusceptibility_nonneg G _ p b)),mul_assoc] + _ ≤ _ := mul_le_mul' le_rfl (Finset.sum_le_sum (fun a _ => + neighborSusceptibility_le_edge_action G hloc _ p a)) + +theorem kernelExteriorPotential_eq_lintegral [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (K : V → V → ℝ≥0∞) (x : V) : + kernelExteriorPotential G p K x = + ∫⁻ ω, ∑' a, ∑' b, K a b * + (if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0) ∂law p := by + have hm (a b : V) : Measurable (fun ω => K a b * + (if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0)) := + measurable_const.mul (Measurable.ite (measurableSet_conn G x a) + (ENNReal.measurable_ofReal.comp (measurable_exteriorSusceptibility G hloc p x b)) + measurable_const) + rw [lintegral_tsum (fun a => (Measurable.tsum (hm a)).aemeasurable)] + apply tsum_congr + intro a + rw [lintegral_tsum (fun b => (hm a b).aemeasurable)] + apply tsum_congr + intro b + exact (lintegral_const_mul _ (Measurable.ite (measurableSet_conn G x a) + (ENNReal.measurable_ofReal.comp (measurable_exteriorSusceptibility G hloc p x b)) + measurable_const)).symm + +theorem kernel_exterior_sample_bound [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) + (d : ℕ) (hd : ∀ a, degree G a ≤ d) (M : ℕ) (K : V → V → ℝ≥0∞) + (hrow : ∀ a, ∑' b, K a b = 1) + (hsupport : ∀ a b, b ∉ reachBall G a M → K a b = 0) + (x : V) (ω : Set E) (hf : (cluster G ω x).Finite) : + (∑' a, ∑' b, K a b * + (if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0)) ≤ + ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ((d+1)^M : ℕ) * + ∑' a, ∑' b, indexedEdgeKernel G a b * + (if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0) := by + let W := hf.toFinset + have hW : cluster G ω x = (W : Set V) := hf.coe_toFinset.symm + have hc (a : V) : Conn G ω x a ↔ a ∈ W := by + change a ∈ cluster G ω x ↔ a ∈ W + rw [hW] + rfl + have he (J : V → V → ℝ≥0∞) : + (∑' a, ∑' b, J a b * + (if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0)) = + ∑ a ∈ W, ∑' b, J a b * ENNReal.ofReal (inducedSusceptibility G (W : Set V)ᶜ p b) := by + rw [tsum_eq_sum (s := W) (fun a ha => by + simp only [ite_eq_right (fun h => ha ((hc a).mp h)),mul_zero,tsum_zero])] + apply Finset.sum_congr rfl + intro a ha + simp only [ite_eq_left ((hc a).mpr ha),exteriorSusceptibility_eq G p x _ ω hf,hW] + rw [he K,he (indexedEdgeKernel G)] + exact finite_kernel_exterior_bound G hloc hqt p hp0 hp d hd M K hrow hsupport W + +theorem kernelExteriorPotential_upper [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) + (d : ℕ) (hd : ∀ a, degree G a ≤ d) (M : ℕ) (K : V → V → ℝ≥0∞) + (hrow : ∀ a, ∑' b, K a b = 1) + (hsupport : ∀ a b, b ∉ reachBall G a M → K a b = 0) (x : V) : + kernelExteriorPotential G p K x ≤ + ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ((d+1)^M : ℕ) * + kernelExteriorPotential G p (indexedEdgeKernel G) x := by + rw [kernelExteriorPotential_eq_lintegral G hloc p K x, + kernelExteriorPotential_eq_lintegral G hloc p (indexedEdgeKernel G) x] + have hm (a b : V) : Measurable (fun ω => indexedEdgeKernel G a b * + (if Conn G ω x a then ENNReal.ofReal (exteriorSusceptibility G p x b ω) else 0)) := + measurable_const.mul (Measurable.ite (measurableSet_conn G x a) + (ENNReal.measurable_ofReal.comp (measurable_exteriorSusceptibility G hloc p x b)) + measurable_const) + rw [←lintegral_const_mul _ (Measurable.tsum (fun a => Measurable.tsum (hm a)))] + apply lintegral_mono_ae + filter_upwards [subcritical_cluster_finite_ae G p hp x] with ω hf + exact kernel_exterior_sample_bound G hloc hqt p hp0 hp d hd M K hrow hsupport x ω hf + +theorem kernelExteriorPotential_le_derivative [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) + (d : ℕ) (hd : ∀ a, degree G a ≤ d) (M : ℕ) (K : V → V → ℝ≥0∞) + (hrow : ∀ a, ∑' b, K a b = 1) + (hsupport : ∀ a b, b ∉ reachBall G a M → K a b = 0) (x : V) : + kernelExteriorPotential G p K x ≤ + ENNReal.ofReal ((p : ℝ)^(-(M : ℤ))) * ((d+1)^M : ℕ) * + (ENNReal.ofReal (1 - (p : ℝ)) * ENNReal.ofReal (deriv (realSusceptibility G x) p)) := by + have hh := kernelExteriorPotential_upper G hloc hqt p hp0 hp d hd M K hrow hsupport x + rwa [kernelExteriorPotential_edge_eq_derivative G hloc hqt p hp0 hp x] at hh + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerCrossingComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerCrossingComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..06e0685c7c1e7c4f8937f59d4f3f29a5aa0a12c0 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerCrossingComparison.lean @@ -0,0 +1,140 @@ +import OAI.Probability.BenjaminiSchramm.FullLayerProfile +import OAI.Probability.BenjaminiSchramm.LayerFirstMomentRate +import OAI.Probability.BenjaminiSchramm.NormalizedExponentComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace Percolation.BenjaminiSchramm + +lemma exponential_rate_le_of_bound (a b c C : ℝ) (hc : 0 < c) + (h : ∀ n : ℕ, 0 < n → c*Real.exp (-a*n) ≤ C*Real.exp (-b*n)) : b ≤ a := by + have hC : 0 < C := by + have hh := h 1 (by norm_num) + have hp : 0 < c*Real.exp (-a*(1 : ℕ)) := mul_pos hc (Real.exp_pos _) + exact pos_of_mul_pos_left (hp.trans_le hh) (Real.exp_nonneg _) + by_contra hn + have hab : 0 < b-a := sub_pos.mpr (lt_of_not_ge hn) + obtain ⟨N,hN⟩ := exists_nat_gt ((Real.log C-Real.log c)/(b-a)) + let n := N+1 + have hh := Real.log_le_log (mul_pos hc (Real.exp_pos _)) (h n (Nat.succ_pos N)) + rw [Real.log_mul hc.ne' (Real.exp_pos _).ne',Real.log_mul hC.ne' (Real.exp_pos _).ne', + Real.log_exp,Real.log_exp] at hh + have hnn : (Real.log C-Real.log c)/(b-a) < (n : ℝ) := + hN.trans (by dsimp [n]; push_cast; linarith) + have hn' := (div_lt_iff₀ hab).mp hnn + linarith + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem adjustedHalfspaceHit_le_upLayerMoment + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (n : ℕ) (hn : 0 < n) (x : V) : + G.law p (G.adjustedHalfspaceHit a x 0 (R*n)) ≤ G.supAdjustedUpLayerMoment a R p n*C := by + let f := G.adjustedLayerIndex a R 0 x + let I := Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight a x v} + let A := {v | R*n ≤ G.orbitAdjustedHeight a x v} + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → f w ≤ f v+1 ∧ f v ≤ f w+1 := by + intro e v w hv hw + have hh := G.adjustedLayerIndex_edge_jump hc hl a R 0 hR hjump x v w e hv hw + change f v-1 ≤ f w ∧ f w ≤ f v+1 at hh + exact ⟨hh.2,by omega⟩ + have hx : f x < (n : ℤ) := by + simp only [f,G.adjustedLayerIndex_self] + exact_mod_cast hn + have hA : ∀ y ∈ A, (n : ℤ) ≤ f y := by + intro y hy + change R*n ≤ G.orbitAdjustedHeight a x y at hy + simp only [f,adjustedLayerIndex,add_zero,Int.floor_zero,sub_zero] + apply Int.le_floor.mpr + apply (le_div_iff₀ hR).mpr + push_cast + nlinarith + have hindicator (ω : Set E) : + (G.adjustedHalfspaceHit a x 0 (R*n)).indicator (fun _ => (1 : ℝ≥0∞)) ω ≤ + restrictedLayerCount G.ends I A ω x := by + by_cases hω : ω ∈ G.adjustedHalfspaceHit a x 0 (R*n) + · rw [Set.indicator_of_mem hω] + obtain ⟨y,hy,hxy⟩ := hω + apply le_trans _ (ENNReal.le_tsum y) + exact (ite_eq_left ⟨hy,hxy⟩).symm.le + · rw [Set.indicator_of_notMem hω] + exact bot_le + calc + _ = ∫⁻ ω, (G.adjustedHalfspaceHit a x 0 (R*n)).indicator (fun _ => (1 : ℝ≥0∞)) ω ∂G.law p := + (lintegral_indicator_one (G.measurableSet_adjustedHalfspaceHit _ _ _ _)).symm + _ ≤ ∫⁻ ω, restrictedLayerCount G.ends I A ω x ∂G.law p := lintegral_mono hindicator + _ ≤ _ := (first_layer_moment_bound_with_row G.ends p C hrow f hj I A x n hx hA).trans + (mul_le_mul' (G.adjustedUpLayerMoment_le_sup a R p n x 0) le_rfl) + +theorem crossing_rate_ge_layer_rate [Nonempty V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (C : ℝ≥0∞) (hC : C < ⊤) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (α β : ℝ) (hα : 0 ≤ α) + (hlower : ∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ m : ℕ, + c*Real.exp (-(α+ε)*m) ≤ (G.infimalAdjustedCrossing a p m).toReal) + (hupper : ∀ ε : ℝ, 0 < ε → ∃ K : ℝ, 0 < K ∧ ∀ n : ℕ, + G.supAdjustedUpLayerMoment a R p n ≤ ENNReal.ofReal (K*Real.exp (-(β-ε)*n))) : + β ≤ α*R := by + have hcompare (ε δ : ℝ) (hε : 0 < ε) (hδ : 0 < δ) : β-ε ≤ (α+δ)*R := by + obtain ⟨c,hcpos,hcbd⟩ := hlower δ hδ + obtain ⟨K,hK,hKbd⟩ := hupper ε hε + have hc' : 0 < c*Real.exp (-(α+δ)) := mul_pos hcpos (Real.exp_pos _) + apply exponential_rate_le_of_bound ((α+δ)*R) (β-ε) + (c*Real.exp (-(α+δ))) (C.toReal*K) hc' + intro n hn + let m := ⌈R*(n : ℝ)⌉₊ + have hmlo : R*(n : ℝ) ≤ (m : ℝ) := Nat.le_ceil _ + have hmhi : (m : ℝ) ≤ R*(n : ℝ)+1 := (Nat.ceil_lt_add_one (mul_nonneg hR.le (Nat.cast_nonneg n))).le + have hmin : G.infimalAdjustedCrossing a p m ≤ + G.law p (G.adjustedHalfspaceHit a (Classical.arbitrary V) 0 (R*n)) := by + apply (iInf_le _ (Classical.arbitrary V)).trans + apply measure_mono + rintro ω ⟨y,hy,hxy⟩ + exact ⟨y,hmlo.trans hy,hxy⟩ + have he : ENNReal.ofReal (c*Real.exp (-(α+δ)*m)) ≤ + C*ENNReal.ofReal (K*Real.exp (-(β-ε)*n)) := by + calc + _ ≤ G.infimalAdjustedCrossing a p m := ENNReal.ofReal_le_of_le_toReal (hcbd m) + _ ≤ G.supAdjustedUpLayerMoment a R p n*C := hmin.trans + (G.adjustedHalfspaceHit_le_upLayerMoment hc hl a R hR hjump p C hrow n hn _) + _ ≤ ENNReal.ofReal (K*Real.exp (-(β-ε)*n))*C := mul_le_mul' (hKbd n) le_rfl + _ = _ := mul_comm _ _ + have her := ENNReal.toReal_mono + (ENNReal.mul_ne_top hC.ne ENNReal.ofReal_ne_top) he + rw [ENNReal.toReal_mul,ENNReal.toReal_ofReal (mul_nonneg hK.le (Real.exp_nonneg _)), + ENNReal.toReal_ofReal (mul_nonneg hcpos.le (Real.exp_nonneg _))] at her + have hexp : Real.exp (-((α+δ)*R)*(n : ℝ)-(α+δ)) ≤ Real.exp (-(α+δ)*(m : ℝ)) := by + apply Real.exp_le_exp.mpr + nlinarith + calc + _ = c*Real.exp (-((α+δ)*R)*(n : ℝ)-(α+δ)) := by rw [mul_assoc,←Real.exp_add]; congr 2; ring + _ ≤ c*Real.exp (-(α+δ)*(m : ℝ)) := mul_le_mul_of_nonneg_left hexp hcpos.le + _ ≤ _ := her.trans_eq (by ring) + by_contra hn + have hd : 0 < β-α*R := sub_pos.mpr (lt_of_not_ge hn) + let ε := (β-α*R)/(2*(R+1)) + have hε : 0 < ε := div_pos hd (by positivity) + have hh := hcompare ε ε hε hε + have he : ε*(2*(R+1))=β-α*R := div_mul_cancel₀ _ (by positivity) + nlinarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentPositivity.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentPositivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..06eeb54ab6609c83c21e4633f89c15a62200ef9a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentPositivity.lean @@ -0,0 +1,167 @@ +import OAI.Probability.BenjaminiSchramm.LayerFirstMoments +import OAI.Probability.BenjaminiSchramm.IntegerLayerFirstVisit +import OAI.Probability.BenjaminiSchramm.CrossingPositivity + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma integer_first_layer_walk {V : Type*} {H : SimpleGraph V} + (f : V → ℤ) (hjump : ∀ {v w}, H.Adj v w → f w ≤ f v+1 ∧ f v ≤ f w+1) + {x y : V} (p : H.Walk x y) (m : ℤ) (hx : f x < m) (hy : m ≤ f y) : + ∃ z, f z=m ∧ ∃ q : H.Walk x z, q.length ≤ p.length ∧ + ∀ v ∈ q.support, f v ≤ m := by + let S := p.support.toFinset.filter fun v => m ≤ f v + have hyS : y ∈ S := Finset.mem_filter.mpr ⟨List.mem_toFinset.mpr p.end_mem_support,hy⟩ + obtain ⟨z,hzS,hzp,hfirst⟩ := p.exists_mem_support_forall_mem_support_imp_eq S + ⟨y,Finset.mem_filter.mpr ⟨hyS,p.end_mem_support⟩⟩ + have hz : m ≤ f z := (Finset.mem_filter.mp hzS).2 + have hbelow (v : V) (hv : v ∈ (p.takeUntil z hzp).support) (hvz : v ≠ z) : f v < m := by + by_contra hn + have hvS : v ∈ S := Finset.mem_filter.mpr + ⟨List.mem_toFinset.mpr (p.support_takeUntil_subset_support hzp hv),le_of_not_gt hn⟩ + exact hvz (hfirst v hvS hv) + have hj {v w : V} (hvw : H.Adj v w) : |(f w : ℝ)-(f v : ℝ)| ≤ 1 := by + obtain ⟨h₁,h₂⟩ := hjump hvw + have h₁' : (f w : ℝ) ≤ (f v : ℝ)+1 := by exact_mod_cast h₁ + have h₂' : (f v : ℝ) ≤ (f w : ℝ)+1 := by exact_mod_cast h₂ + rw [abs_le] + constructor <;> linarith + have hx' : (f x : ℝ) < (m : ℝ)-1/2 := by + have hh : f x ≤ m-1 := by omega + have hh' : (f x : ℝ) ≤ (m : ℝ)-1 := by exact_mod_cast hh + linarith + have hbl : ∀ v ∈ (p.takeUntil z hzp).support, v ≠ z → (f v : ℝ) < (m : ℝ)-1/2 := by + intro v hv hvz + have hh : f v ≤ m-1 := by have := hbelow v hv hvz; omega + have hh' : (f v : ℝ) ≤ (m : ℝ)-1 := by exact_mod_cast hh + linarith + have hzhi := walk_endpoint_height_bound (fun v => (f v : ℝ)) 1 ((m : ℝ)-1/2) + (by norm_num) hj (p.takeUntil z hzp) hx' hbl + have hzm : f z=m := by + have hh : f z ≤ m := (integer_half_ceiling _ _).mp hzhi + omega + refine ⟨z,hzm,p.takeUntil z hzp,p.length_takeUntil_le_length hzp,fun v hv => ?_⟩ + by_cases hvz : v=z + · simp only [hvz,hzm,le_refl] + · exact (hbelow v hv hvz).le + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] in +lemma adjustedUpLayerMoment_walk_lower (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R u : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (n : ℕ) (hn : 0 < n) {x y : V} + (w : G.fullGraph.Walk x y) (hy : (n : ℤ) ≤ G.adjustedLayerIndex a R u x y) : + ENNReal.ofReal ((p : ℝ)^w.length) ≤ G.adjustedUpLayerMoment a R p n x u := by + let f := G.adjustedLayerIndex a R u x + have hj {v z : V} (hvz : G.fullGraph.Adj v z) : f z ≤ f v+1 ∧ f v ≤ f z+1 := by + obtain ⟨⟨e,_he,heq⟩,_hne⟩ := (SimpleGraph.fromEdgeSet_adj _).mp hvz + have hh := G.adjustedLayerIndex_edge_jump hc hl a R u hR hjump x v z e + (by rw [heq]; simp) (by rw [heq]; simp) + change f v-1 ≤ f z ∧ f z ≤ f v+1 at hh + exact ⟨hh.2,by omega⟩ + have hx : f x < (n : ℤ) := by simp only [f,G.adjustedLayerIndex_self]; exact_mod_cast hn + obtain ⟨z,hz,q,hqlen,hq⟩ := integer_first_layer_walk f hj w n hx hy + have hg : G.fullGraph = Percolation.openSimpleGraph G.ends Set.univ := + criticalModel_openGraph G.ends Set.univ + let ι : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by simpa only [←hg,id_eq] using h⟩ + obtain ⟨s,hs,hconn⟩ := walk_finite_open_restriction G.ends (q.map ι) + {v | f v ≤ (n : ℤ)} (by + intro v hv + rw [SimpleGraph.Walk.support_map] at hv + change v ∈ q.support.map id at hv + exact hq v (by simpa only [List.map_id_fun,id_eq] using hv)) + have hslen0 : s.card ≤ q.length := by simpa only [SimpleGraph.Walk.length_map] using hs + have hslen : s.card ≤ w.length := hslen0.trans hqlen + let F : Set (Set E) := {ω | (s : Set E) ⊆ ω} + have hF : MeasurableSet F := Percolation.measurableSet_finiteWitness F + (fun _ _ h hs => hs.trans h) (fun _ hs => ⟨s,hs,Set.Subset.rfl⟩) + have hmeasure : G.law p F = ENNReal.ofReal ((p : ℝ)^s.card) := by + rw [←Percolation.finite_open_probability p s] + exact (ENNReal.ofReal_toReal (measure_ne_top _ _)).symm + calc + _ ≤ ENNReal.ofReal ((p : ℝ)^s.card) := ENNReal.ofReal_le_ofReal + (pow_le_pow_of_le_one p.2.1 p.2.2 hslen) + _ = G.law p F := hmeasure.symm + _ = ∫⁻ ω, F.indicator (fun _ => (1 : ℝ≥0∞)) ω ∂G.law p := + (lintegral_indicator_one hF).symm + _ ≤ _ := by + apply lintegral_mono + intro ω + by_cases hω : ω ∈ F + · rw [Set.indicator_of_mem hω] + apply le_trans _ (ENNReal.le_tsum z) + exact (ite_eq_left ⟨hz,hconn ω hω⟩).symm.le + · rw [Set.indicator_of_notMem hω] + exact bot_le + +theorem adjustedUpLayerMoment_finite_energy [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) (hu : ¬G.CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ (n : ℕ) (x : V) (u : ℝ), + ENNReal.ofReal ((p : ℝ)^(A*n+B)) ≤ + G.adjustedUpLayerMoment (G.stationaryOrbitWeight μ) R p n x u := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpath⟩ := G.stationaryOrbitHeight_orbit_above hc hl hq μ hμ hstat hu + refine ⟨A*R,A*R+B,mul_pos hA hR,add_nonneg (mul_pos hA hR).le hB,fun n x u => ?_⟩ + by_cases hn : n=0 + · subst n + have hb : (p : ℝ)^(A*R+B) ≤ 1 := Real.rpow_le_one p.2.1 p.2.2 (add_nonneg (mul_pos hA hR).le hB) + have hz := G.adjustedUpLayerMoment_zero_ge_one a R p x u + rw [←ENNReal.ofReal_one] at hz + simpa only [Nat.cast_zero,mul_zero,zero_add,a] using + (ENNReal.ofReal_le_ofReal hb).trans hz + have hnpos : 0 < n := Nat.pos_of_ne_zero hn + obtain ⟨y,w,_horb,hlen,_hlow,hy⟩ := hpath (((n : ℝ)+1)*R) + (mul_nonneg (by positivity) hR.le) x (G.vertexOrbit x) + have hend : (n : ℤ) ≤ G.adjustedLayerIndex a R u x y := by + have hh := (G.adjustedLayerIndex_height_bounds a R u hR x y).2 + by_contra hf + have hi : G.adjustedLayerIndex a R u x y ≤ (n : ℤ)-1 := by omega + have hir : (G.adjustedLayerIndex a R u x y : ℝ) ≤ (n : ℝ)-1 := by exact_mod_cast hi + nlinarith + have hlen' : (w.length : ℝ) ≤ A*R*(n : ℝ)+(A*R+B) := by nlinarith [hlen] + have hpow := Real.rpow_le_rpow_of_exponent_ge hp p.2.2 hlen' + rw [Real.rpow_natCast] at hpow + exact (ENNReal.ofReal_le_ofReal hpow).trans + (G.adjustedUpLayerMoment_walk_lower hc hl a R u hR hjump p n hnpos w hend) + +omit [Countable V] [Countable E] in +theorem stationaryOrbitHeight_bounded_jumps [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) : + ∃ R : ℝ, 0 < R ∧ ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R := by + obtain ⟨K,hK⟩ := G.uniform_ball_bound hq 1 + obtain ⟨D,hD,hbound⟩ := G.stationaryOrbitHeight_uniform_comparison hc hl μ hμ + refine ⟨D+max 0 (Real.log (K : ℝ))+1,by positivity,fun e v w hv hw => ?_⟩ + have hr := G.modularLogHeight_edge_jump hc hl K hK v v w e hv hw + rw [G.modularLogHeight_self,sub_zero] at hr + have hh := abs_add_le + (G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w-G.modularLogHeight v w) + (G.modularLogHeight v w) + rw [sub_add_cancel] at hh + exact hh.trans ((add_le_add (hbound v w) (hr.trans (le_max_right _ _))).trans + (le_add_of_nonneg_right (by norm_num))) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentRate.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5e6ed26773c1bd49b44db9e48dac888884bd529 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentRate.lean @@ -0,0 +1,76 @@ +import OAI.Probability.BenjaminiSchramm.LayerFirstMomentSubmultiplicative +import OAI.Probability.BenjaminiSchramm.LayerFirstMomentPositivity +import OAI.Probability.BenjaminiSchramm.LayerMomentFekete + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype G.VertexOrbit] + +theorem subcritical_normalized_layer_rate + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (hql : Percolation.QuasiTransitive G.ends) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) (hu : ¬G.CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < Percolation.pc G.ends) : + ∃ β : ℝ, 0 ≤ β ∧ + (∀ n : ℕ, Real.exp (-β*n) ≤ + (G.supAdjustedUpLayerMoment (G.stationaryOrbitWeight μ) R p n).toReal) ∧ + (∀ ε : ℝ, 0 < ε → ∃ K : ℝ, 0 < K ∧ ∀ n : ℕ, + G.supAdjustedUpLayerMoment (G.stationaryOrbitWeight μ) R p n ≤ + ENNReal.ofReal (K*Real.exp (-(β-ε)*n))) ∧ + Tendsto (fun n : ℕ => -Real.log + (G.supAdjustedUpLayerMoment (G.stationaryOrbitWeight μ) R p n).toReal/n) atTop (𝓝 β) := by + let a := G.stationaryOrbitWeight μ + let S := G.supAdjustedUpLayerMoment a R p + let P : ℕ → ℝ := fun n => (S n).toReal + obtain ⟨C,hC,hbound⟩ := G.subcritical_supAdjustedUpLayerMoment_bound hl hql a R p hpc + have hne (n : ℕ) : S n ≠ ⊤ := (lt_of_le_of_lt (hbound n) hC).ne + obtain ⟨A,B,hA,hB,hlower⟩ := G.adjustedUpLayerMoment_finite_energy hc hl hq μ hμ hstat hu R hR hjump p hp + have hlow (n : ℕ) : (p : ℝ)^(A*n+B) ≤ P n := by + have hh := ENNReal.toReal_mono (hne n) + ((hlower n (Classical.arbitrary V) 0).trans (G.adjustedUpLayerMoment_le_sup a R p n _ 0)) + rwa [ENNReal.toReal_ofReal (Real.rpow_pos_of_pos hp _).le] at hh + have hP (n : ℕ) : 0 < P n := (Real.rpow_pos_of_pos hp _).trans_le (hlow n) + have hP0 : 1 ≤ P 0 := by + have hh := ENNReal.toReal_mono (hne 0) + ((G.adjustedUpLayerMoment_zero_ge_one a R p (Classical.arbitrary V) 0).trans + (G.adjustedUpLayerMoment_le_sup a R p 0 _ 0)) + simpa only [ENNReal.toReal_one] using hh + have hmul (m n : ℕ) : P (m+n) ≤ P m*P n := by + have hh := ENNReal.toReal_mono (ENNReal.mul_ne_top (hne m) (hne n)) + (G.supAdjustedUpLayerMoment_submultiplicative hc hl a R hR hjump p m n) + simpa only [ENNReal.toReal_mul] using hh + have hboundr (n : ℕ) : P n ≤ C.toReal := ENNReal.toReal_mono hC.ne (hbound n) + have hlog : Real.log (p : ℝ) ≤ 0 := Real.log_nonpos hp.le p.2.2 + have hexp (n : ℕ) : Real.exp (-(-A*Real.log (p : ℝ))*n-(-B*Real.log (p : ℝ))) ≤ P n := by + have hh := hlow n + rw [Real.rpow_def_of_pos hp] at hh + convert hh using 1 + congr 1 + ring + obtain ⟨β,hβ,hlo,hupp,hlim⟩ := positive_layer_moment_rate P hP hP0 hmul C.toReal hboundr + (-A*Real.log (p : ℝ)) (-B*Real.log (p : ℝ)) + (mul_nonneg_of_nonpos_of_nonpos (neg_nonpos.mpr hA.le) hlog) + (mul_nonneg_of_nonpos_of_nonpos (neg_nonpos.mpr hB) hlog) hexp + refine ⟨β,hβ,hlo,?_,hlim⟩ + intro ε hε + obtain ⟨K,hK,hKbound⟩ := hupp ε hε + refine ⟨K,hK,fun n => ?_⟩ + have hh := ENNReal.ofReal_le_ofReal (hKbound n) + rwa [ENNReal.ofReal_toReal (hne n)] at hh + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentSubmultiplicative.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentSubmultiplicative.lean new file mode 100644 index 0000000000000000000000000000000000000000..f592c8388f865f3ad5b561efafc8f5df097d8d3a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMomentSubmultiplicative.lean @@ -0,0 +1,134 @@ +import OAI.Probability.BenjaminiSchramm.LayerFirstMoments +import OAI.Probability.BenjaminiSchramm.IntegerLayerFirstVisit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma adjustedUpLayerMoment_first_visit (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (m n : ℕ) (hm : 0 < m) (x : V) (u : ℝ) : + G.adjustedUpLayerMoment a R p (m+n) x u ≤ + G.adjustedUpLayerMoment a R p m x u * G.supAdjustedUpLayerMoment a R p n := by + let f := G.adjustedLayerIndex a R u x + let I := Percolation.internalEdges G.ends {v | f v ≤ (m+n : ℕ)} + let A := {v | f v = (m+n : ℕ)} + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → f w ≤ f v+1 ∧ f v ≤ f w+1 := by + intro e v w hv hw + have hh := G.adjustedLayerIndex_edge_jump hc hl a R u hR hjump x v w e hv hw + change f v-1 ≤ f w ∧ f w ≤ f v+1 at hh + exact ⟨hh.2,by omega⟩ + have hx : f x < (m : ℤ) := by simp only [f,G.adjustedLayerIndex_self]; exact_mod_cast hm + have hA : ∀ y ∈ A, (m : ℤ) ≤ f y := by + intro y hy + change f y = (m+n : ℕ) at hy + rw [hy] + exact_mod_cast Nat.le_add_right m n + have hfirst := integer_first_layer_moment_bound G.ends f hj I A p x m hx hA + have hI : I ∩ Percolation.internalEdges G.ends {v | f v ≤ (m : ℤ)} = + Percolation.internalEdges G.ends {v | f v ≤ (m : ℤ)} := by + apply Set.inter_eq_right.mpr + apply Percolation.internalEdges_mono G.ends + intro v hv + change f v ≤ (m : ℤ) at hv + change f v ≤ (m+n : ℕ) + exact hv.trans (by exact_mod_cast Nat.le_add_right m n) + rw [hI] at hfirst + have hcont (z : V) (hz : f z=(m : ℤ)) : + (∫⁻ ω, restrictedLayerCount G.ends I A ω z ∂G.law p) ≤ G.supAdjustedUpLayerMoment a R p n := by + let v := G.orbitAdjustedHeight a x z/R+u + have hidx (y : V) : f y = (m : ℤ)+G.adjustedLayerIndex a R v z y := by + simpa only [f,hz] using G.adjustedLayerIndex_change_base hc hl a R u x z y + have hDom : {y : V | f y ≤ (m+n : ℕ)} = + {y | G.adjustedLayerIndex a R v z y ≤ (n : ℤ)} := by + ext y + change f y ≤ (m+n : ℕ) ↔ G.adjustedLayerIndex a R v z y ≤ (n : ℤ) + rw [hidx] + push_cast + omega + have hTar : A = {y | G.adjustedLayerIndex a R v z y=(n : ℤ)} := by + ext y + change f y = (m+n : ℕ) ↔ G.adjustedLayerIndex a R v z y=(n : ℤ) + rw [hidx] + push_cast + omega + change (∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | f y ≤ (m+n : ℕ)}) A ω z ∂G.law p) ≤ _ + rw [hDom,hTar] + exact G.adjustedUpLayerMoment_le_sup a R p n z v + calc + _ ≤ ∑' z, (if f z=(m : ℤ) then G.law p + {ω | Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends {v | f v ≤ (m : ℤ)}) x z} else 0) * + (∫⁻ ω, restrictedLayerCount G.ends I A ω z ∂G.law p) := hfirst + _ ≤ ∑' z, (if f z=(m : ℤ) then G.law p + {ω | Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends {v | f v ≤ (m : ℤ)}) x z} else 0) * + G.supAdjustedUpLayerMoment a R p n := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z=(m : ℤ) + · exact mul_le_mul' le_rfl (hcont z hz) + · simp only [ite_eq_right hz,zero_mul,le_refl] + _ = _ := by + rw [ENNReal.tsum_mul_right] + congr 1 + rw [adjustedUpLayerMoment] + change _ = ∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | f v ≤ (m : ℤ)}) {v | f v=(m : ℤ)} ω x ∂Percolation.law p + rw [lintegral_restrictedLayerCount] + apply tsum_congr + intro z + by_cases hz : f z=(m : ℤ) <;> + simp only [Set.mem_ofPred_eq,hz,ite_true,ite_false,law,Percolation.law] + +theorem supAdjustedUpLayerMoment_submultiplicative [Nonempty V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (m n : ℕ) : + G.supAdjustedUpLayerMoment a R p (m+n) ≤ + G.supAdjustedUpLayerMoment a R p m*G.supAdjustedUpLayerMoment a R p n := by + have hzero : (1 : ℝ≥0∞) ≤ G.supAdjustedUpLayerMoment a R p 0 := + (G.adjustedUpLayerMoment_zero_ge_one a R p (Classical.arbitrary V) 0).trans + (G.adjustedUpLayerMoment_le_sup a R p 0 _ 0) + by_cases hm : m=0 + · rw [hm,zero_add] + exact (one_mul _).symm.le.trans (mul_le_mul' hzero le_rfl) + · apply iSup_le + intro x + apply iSup_le + intro u + exact (G.adjustedUpLayerMoment_first_visit hc hl a R hR hjump p m n + (Nat.pos_of_ne_zero hm) x u).trans (mul_le_mul' (G.adjustedUpLayerMoment_le_sup a R p m x u) le_rfl) + +theorem subcritical_supAdjustedUpLayerMoment_bound [Nonempty V] + (hl : Percolation.LocallyFinite G.ends) (hq : Percolation.QuasiTransitive G.ends) + (a : V → ℝ) (R : ℝ) (p : unitInterval) (hp : p < Percolation.pc G.ends) : + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ n, G.supAdjustedUpLayerMoment a R p n ≤ C := by + obtain ⟨C,_hC,hrow⟩ := Percolation.subcritical_ennreal_row_bound G.ends hl hq p hp + refine ⟨ENNReal.ofReal C,ENNReal.ofReal_lt_top,fun n => ?_⟩ + apply iSup_le + intro x + apply iSup_le + intro u + apply le_trans _ (hrow x) + rw [adjustedUpLayerMoment] + change (∫⁻ ω, restrictedLayerCount G.ends _ _ ω x ∂Percolation.law p) ≤ _ + rw [lintegral_restrictedLayerCount] + apply ENNReal.tsum_le_tsum + intro y + split_ifs + · exact measure_mono (fun ω hω => Percolation.conn_mono G.ends Set.inter_subset_left hω) + · exact bot_le + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMoments.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..314c505fe686c4411f7d08765035fb1e8d142fa7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFirstMoments.lean @@ -0,0 +1,64 @@ +import OAI.Probability.BenjaminiSchramm.ConsistentLayers +import OAI.Probability.BenjaminiSchramm.SlabLastMaximum + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def adjustedUpLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) + (n : ℕ) (x : V) (u : ℝ) : ℝ≥0∞ := + ∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v ≤ (n : ℤ)}) + {v | G.adjustedLayerIndex a R u x v = (n : ℤ)} ω x ∂G.law p + +def adjustedDownLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) + (n : ℕ) (x : V) (u : ℝ) : ℝ≥0∞ := + ∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v ≤ 0}) + {v | G.adjustedLayerIndex a R u x v = -(n : ℤ)} ω x ∂G.law p + +def supAdjustedUpLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ≥0∞ := + ⨆ x, ⨆ u, G.adjustedUpLayerMoment a R p n x u + +def infAdjustedUpLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ≥0∞ := + ⨅ x, ⨅ u, G.adjustedUpLayerMoment a R p n x u + +def supAdjustedDownLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ≥0∞ := + ⨆ x, ⨆ u, G.adjustedDownLayerMoment a R p n x u + +def infAdjustedDownLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ≥0∞ := + ⨅ x, ⨅ u, G.adjustedDownLayerMoment a R p n x u + +lemma adjustedUpLayerMoment_le_sup (a : V → ℝ) (R : ℝ) (p : unitInterval) + (n : ℕ) (x : V) (u : ℝ) : + G.adjustedUpLayerMoment a R p n x u ≤ G.supAdjustedUpLayerMoment a R p n := + le_iSup_of_le x (le_iSup_of_le u le_rfl) + +lemma adjustedDownLayerMoment_le_sup (a : V → ℝ) (R : ℝ) (p : unitInterval) + (n : ℕ) (x : V) (u : ℝ) : + G.adjustedDownLayerMoment a R p n x u ≤ G.supAdjustedDownLayerMoment a R p n := + le_iSup_of_le x (le_iSup_of_le u le_rfl) + +lemma adjustedUpLayerMoment_zero_ge_one [Countable V] [Countable E] + (a : V → ℝ) (R : ℝ) (p : unitInterval) (x : V) (u : ℝ) : + 1 ≤ G.adjustedUpLayerMoment a R p 0 x u := by + have hh (ω : Set E) : (1 : ℝ≥0∞) ≤ restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v ≤ (0 : ℤ)}) + {v | G.adjustedLayerIndex a R u x v = (0 : ℤ)} ω x := by + apply le_trans _ (ENNReal.le_tsum x) + simp only [G.adjustedLayerIndex_self,Set.mem_ofPred_eq, + Percolation.conn_refl,true_and,ite_true,le_refl] + exact (show (1 : ℝ≥0∞) = ∫⁻ _ω : Set E, (1 : ℝ≥0∞) ∂G.law p by simp).le.trans + (lintegral_mono hh) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFreshSelection.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFreshSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c73ef11d26fa3e2ea2420b75145b74f3a05785f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFreshSelection.lean @@ -0,0 +1,58 @@ +import OAI.Probability.BenjaminiSchramm.BlockExposure + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BernoulliProduct +variable {E ι : Type*} + +lemma measure_inter_of_separate_blocks (q : E → unitInterval) (S : Set E) + (A B : Set (Set E)) (hA : MeasurableSet A) (hB : MeasurableSet B) + (hdA : DependsOn (fun ω => ω ∈ A) S) + (hdB : DependsOn (fun ω => ω ∈ B) Sᶜ) : + law q (A ∩ B) = law q A * law q B := by + have hBg : DependsOn (B.indicator (fun _ : Set E => (1 : ℝ≥0∞))) Sᶜ := by + intro ω η hωη + have h := hdB hωη + change (ω ∈ B) = (η ∈ B) at h + change (if ω ∈ B then (1 : ℝ≥0∞) else 0) = + (if η ∈ B then (1 : ℝ≥0∞) else 0) + exact congrArg (fun p : Prop => if p then (1 : ℝ≥0∞) else 0) h + have h := lintegral_indicator_fresh q S A hA hdA + (B.indicator (fun _ : Set E => (1 : ℝ≥0∞))) (measurable_const.indicator hB) hBg + have heq : A.indicator (B.indicator (fun _ : Set E => (1 : ℝ≥0∞))) = + (A ∩ B).indicator (fun _ : Set E => (1 : ℝ≥0∞)) := by + funext ω + by_cases ha : ω ∈ A <;> by_cases hb : ω ∈ B <;> simp [Set.indicator,ha,hb] + have hAB : (∫⁻ ω, (A ∩ B).indicator (fun _ : Set E => (1 : ℝ≥0∞)) ω ∂law q) = + law q (A ∩ B) := lintegral_indicator_one (hA.inter hB) + have hB' : (∫⁻ ω, B.indicator (fun _ : Set E => (1 : ℝ≥0∞)) ω ∂law q) = + law q B := lintegral_indicator_one hB + rw [heq,hAB,hB'] at h + exact h + +theorem selected_fresh_continuation_lower [Countable ι] + (q : E → unitInterval) (S : Set E) (A B : ι → Set (Set E)) + (hmA : ∀ i, MeasurableSet (A i)) (hmB : ∀ i, MeasurableSet (B i)) + (hdA : ∀ i, DependsOn (fun ω => ω ∈ A i) S) + (hdB : ∀ i, DependsOn (fun ω => ω ∈ B i) Sᶜ) + (hdisj : Pairwise (fun i j => Disjoint (A i) (A j))) (c : ℝ≥0∞) (hc : ∀ i, c ≤ law q (B i)) : + law q (⋃ i, A i) * c ≤ law q (⋃ i, A i ∩ B i) := by + have hdisj' : Pairwise (fun i j => Disjoint (A i ∩ B i) (A j ∩ B j)) := by + intro i j hij + exact (hdisj hij).mono Set.inter_subset_left Set.inter_subset_left + rw [measure_iUnion hdisj hmA,measure_iUnion hdisj' (fun i => (hmA i).inter (hmB i)), + ← ENNReal.tsum_mul_right] + apply ENNReal.tsum_le_tsum + intro i + rw [measure_inter_of_separate_blocks q S _ _ (hmA i) (hmB i) (hdA i) (hdB i)] + exact mul_le_mul' le_rfl (hc i) + +end CriticalPercolation.BernoulliProduct + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierExpectation.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9baa91b174bf27005b295148767c5a92c8a83b37 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierExpectation.lean @@ -0,0 +1,170 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def newLayerCount (I J : Set E) (A : Set V) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, if y ∈ A ∧ ¬Conn G (ω ∩ I) x y ∧ Conn G (ω ∩ J) x y then 1 else 0 + +def frontierCount (I J : Set E) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' z, if z ∈ openFrontier G (ω ∩ J) (cluster G (ω ∩ I) x) then 1 else 0 + +lemma measurable_newLayerCount (I J : Set E) (A : Set V) (x : V) : + Measurable (fun ω => newLayerCount G I J A ω x) := by + have hm (Q : Set E) : Measurable (fun ω : Set E => ω ∩ Q) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact Measurable.tsum fun y => Measurable.ite + (measurable_const.and (((measurableSet_conn G x y).mem.comp (hm I)).not.and + ((measurableSet_conn G x y).mem.comp (hm J)))).setOf + measurable_const measurable_const + +lemma measurable_frontierCount (I J : Set E) (x : V) : + Measurable (fun ω => frontierCount G I J ω x) := by + have hm : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + have hc (y : V) : Measurable (fun ω => Conn G (ω ∩ I) x y) := + (measurableSet_conn G x y).mem.comp hm + exact Measurable.tsum fun z => Measurable.ite + ((hc z).not.and (Measurable.exists fun u => (hc u).and + (Measurable.exists fun e => ((measurable_set_mem e).and measurable_const).and + measurable_const))).setOf measurable_const measurable_const + +omit [Countable V] [Countable E] in +lemma newLayerCount_eq_on_cell (I J : Set E) (x : V) (S F A : Set V) + {ω : Set E} (hω : ω ∈ lowerFrontierCell G I J x S F) : + newLayerCount G I J A ω x = restrictedLayerCount G J (A \ S) ω x := by + apply tsum_congr + intro y + have he : Conn G (ω ∩ I) x y ↔ y ∈ S := by + change y ∈ cluster G (ω ∩ I) x ↔ y ∈ S + rw [hω.1] + simp only [Set.mem_sdiff,he,and_assoc] + +omit [Countable V] [Countable E] in +lemma frontierCount_eq_card_on_cell (I J : Set E) (x : V) (S : Set V) + (F : Finset V) {ω : Set E} + (hω : ω ∈ lowerFrontierCell G I J x S (F : Set V)) : + frontierCount G I J ω x = F.card := by + unfold frontierCount + rw [hω.1,hω.2] + simp only [Finset.mem_coe] + rw [tsum_eq_sum (s := F) (fun z hz => ite_eq_right hz)] + calc + _ = ∑ _z ∈ F, (1 : ℝ≥0∞) := Finset.sum_congr rfl (fun _ hz => ite_eq_left hz) + _ = _ := by simp only [Finset.sum_const,nsmul_eq_mul,mul_one] + +theorem lintegral_lowerFrontier_partition + (hloc : LocallyFinite G) (q : E → unitInterval) (I J : Set E) (x : V) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ I) x).Finite) + (g : Set E → ℝ≥0∞) (hg : Measurable g) : + (∫⁻ ω, g ω ∂CriticalPercolation.BernoulliProduct.law q) = + ∑' B : Finset V × Finset V, ∫⁻ ω, + (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator g ω + ∂CriticalPercolation.BernoulliProduct.law q := by + have heq : g =ᵐ[CriticalPercolation.BernoulliProduct.law q] + (fun ω => ∑' B : Finset V × Finset V, + (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator g ω) := by + filter_upwards [hfin] with ω hω + let S := hω.toFinset + have hF := openFrontier_finite G hloc (ω ∩ J) hω + let F := hF.toFinset + have hS : (S : Set V) = cluster G (ω ∩ I) x := hω.coe_toFinset + have hFF : (F : Set V) = openFrontier G (ω ∩ J) (cluster G (ω ∩ I) x) := + hF.coe_toFinset + have hmem : ω ∈ lowerFrontierCell G I J x (S : Set V) (F : Set V) := by + exact ⟨hS.symm,by rw [hS,hFF]⟩ + have huniq (B : Finset V × Finset V) + (hB : ω ∈ lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)) : B = (S,F) := by + have hs : B.1 = S := Finset.coe_injective (hB.1.symm.trans hS.symm) + have hf : B.2 = F := Finset.coe_injective (by + rw [←hB.2,←hB.1,hFF]) + exact Prod.ext hs hf + rw [tsum_eq_single (S,F) (fun B hB => Set.indicator_of_notMem + (fun hm => hB (huniq B hm)) g)] + exact (Set.indicator_of_mem hmem g).symm + rw [lintegral_congr_ae heq,lintegral_tsum] + intro B + exact (hg.indicator (measurableSet_lowerFrontierCell G I J x _ _)).aemeasurable + +theorem newLayerCount_fractional_bound_on_frontier + (hloc : LocallyFinite G) (q : E → unitInterval) (I J : Set E) (x : V) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ I) x).Finite) + (A : Set V) {a b : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) + (hb : 0 < b) (hb1 : b ≤ 1) (L : ℝ≥0∞) + (Z : Set V) (hZ : ∀ ω, openFrontier G (ω ∩ J) (cluster G (ω ∩ I) x) ⊆ Z) + (hL : ∀ z ∈ Z, (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, newLayerCount G I J A ω x^(a*b) + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (∫⁻ ω, frontierCount G I J ω x^b + ∂CriticalPercolation.BernoulliProduct.law q)*L^b := by + let μ := CriticalPercolation.BernoulliProduct.law q + rw [lintegral_lowerFrontier_partition G hloc q I J x hfin _ + ((measurable_newLayerCount G I J A x).pow_const (a*b))] + have hbound (B : Finset V × Finset V) : + (∫⁻ ω, (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator + (fun ω => newLayerCount G I J A ω x^(a*b)) ω ∂μ) ≤ + μ (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)) * + (B.2.card : ℝ≥0∞)^b*L^b := by + have he : (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator + (fun ω => newLayerCount G I J A ω x^(a*b)) = + (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator + (fun ω => restrictedLayerCount G J (A \ (B.1 : Set V)) ω x^(a*b)) := by + apply Set.indicator_congr + intro ω hω + exact congrArg (fun t : ℝ≥0∞ => t^(a*b)) + (newLayerCount_eq_on_cell G I J x _ _ A hω) + rw [he] + by_cases hcell : (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).Nonempty + · obtain ⟨η,hη⟩ := hcell + exact lowerFrontierCell_fractional_bound G q I J x _ _ A ha ha1 hb hb1 L + (fun z hz => hL z (hZ η (by + rw [hη.1,hη.2] + exact hz))) + · rw [Set.not_nonempty_iff_eq_empty.mp hcell] + simp only [Set.indicator_empty,lintegral_zero,measure_empty,zero_mul,le_refl] + apply (ENNReal.tsum_le_tsum hbound).trans_eq + rw [ENNReal.tsum_mul_right] + congr 1 + rw [lintegral_lowerFrontier_partition G hloc q I J x hfin _ + ((measurable_frontierCount G I J x).pow_const b)] + apply tsum_congr + intro B + have he : (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator + (fun ω => frontierCount G I J ω x^b) = + (lowerFrontierCell G I J x (B.1 : Set V) (B.2 : Set V)).indicator + (fun _ => (B.2.card : ℝ≥0∞)^b) := by + apply Set.indicator_congr + intro ω hω + exact congrArg (fun t : ℝ≥0∞ => t^b) + (frontierCount_eq_card_on_cell G I J x _ _ hω) + rw [he,lintegral_indicator_const (measurableSet_lowerFrontierCell G I J x _ _),mul_comm] + +theorem newLayerCount_fractional_bound + (hloc : LocallyFinite G) (q : E → unitInterval) (I J : Set E) (x : V) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ I) x).Finite) + (A : Set V) {a b : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) + (hb : 0 < b) (hb1 : b ≤ 1) (L : ℝ≥0∞) + (hL : ∀ z, (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, newLayerCount G I J A ω x^(a*b) + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (∫⁻ ω, frontierCount G I J ω x^b + ∂CriticalPercolation.BernoulliProduct.law q)*L^b := + newLayerCount_fractional_bound_on_frontier G hloc q I J x hfin A ha ha1 hb hb1 L + Set.univ (fun _ _ _ => Set.mem_univ _) (fun z _ => hL z) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..21416a774cbf6b0c186e2eb866244b27d53089d9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierGeometry.lean @@ -0,0 +1,250 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicBallExposure +import OAI.Probability.BenjaminiSchramm.FreshSlabCrossing +import OAI.Probability.BenjaminiSchramm.ClusterExposure +import OAI.Probability.BenjaminiSchramm.PhaseInput +import OAI.Probability.BenjaminiSchramm.LayerMomentDecomposition + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def openFrontier (ω : Set E) (S : Set V) : Set V := + {z | z ∉ S ∧ ∃ u ∈ S, ∃ e ∈ ω, G e = s(u,z)} + +lemma openFrontier_dependsOn (S : Set V) : + DependsOn (fun ω => openFrontier G ω S) (ballIncidentEdges G S) := by + intro ω η hωη + ext z + constructor + · rintro ⟨hz,u,hu,e,he,heq⟩ + exact ⟨hz,u,hu,e,(Iff.of_eq (hωη e ⟨u,hu,by rw [heq]; simp⟩)).mp he,heq⟩ + · rintro ⟨hz,u,hu,e,he,heq⟩ + exact ⟨hz,u,hu,e,(Iff.of_eq (hωη e ⟨u,hu,by rw [heq]; simp⟩)).mpr he,heq⟩ + +lemma openFrontier_finite (hloc : LocallyFinite G) (ω : Set E) + {S : Set V} (hS : S.Finite) : (openFrontier G ω S).Finite := by + apply (hS.biUnion (fun u _ => finite_neighbors hloc u)).subset + rintro z ⟨_,u,hu,e,_,heq⟩ + exact Set.mem_iUnion.mpr ⟨u,Set.mem_iUnion.mpr ⟨hu,e,heq⟩⟩ + +lemma measurable_mem_openFrontier [Countable V] [Countable E] (S : Set V) (z : V) : + Measurable (fun ω => z ∈ openFrontier G ω S) := by + exact measurable_const.and (Measurable.exists fun u => measurable_const.and + (Measurable.exists fun e => (measurable_set_mem e).and measurable_const)) + +lemma measurableSet_openFrontier_eq [Countable V] [Countable E] (S F : Set V) : + MeasurableSet {ω | openFrontier G ω S = F} := by + have he : {ω | openFrontier G ω S = F} = + ⋂ z : V, {ω | (z ∈ openFrontier G ω S) ↔ z ∈ F} := by + ext ω + simp only [Set.mem_ofPred_eq,Set.mem_iInter] + exact Set.ext_iff + rw [he] + exact MeasurableSet.iInter fun z => + ((measurable_mem_openFrontier G S z).iff measurable_const).setOf + +lemma restricted_exactCluster_dependsOn (I : Set E) (x : V) (S : Set V) : + DependsOn (fun ω => cluster G (ω ∩ I) x = S) (ballIncidentEdges G S) := by + intro ω η hωη + have ha : ∀ e ∈ (criticalModel G).incidentEdges S, + (e ∈ Set.inter ω I) = (e ∈ Set.inter η I) := by + intro e he + exact congrArg (fun p : Prop => p ∧ e ∈ I) (hωη e he) + have hh := (criticalModel G).exactCluster_dependsOn x S ha + change ((criticalModel G).cluster (Set.inter ω I) x = S) = + ((criticalModel G).cluster (Set.inter η I) x = S) at hh + rw [criticalModel_cluster,criticalModel_cluster] at hh + exact hh + +lemma measurableSet_restricted_exactCluster [Countable V] [Countable E] + (I : Set E) (x : V) (S : Set V) : + MeasurableSet {ω | cluster G (ω ∩ I) x = S} := by + have hm : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + simpa only [criticalModel_cluster,Set.preimage_ofPred_eq] using + ((criticalModel G).measurableSet_exactCluster x S).preimage hm + +def lowerFrontierCell (I J : Set E) (x : V) (S F : Set V) : Set (Set E) := + {ω | cluster G (ω ∩ I) x = S ∧ openFrontier G (ω ∩ J) S = F} + +lemma lowerFrontierCell_dependsOn (I J : Set E) (x : V) (S F : Set V) : + DependsOn (fun ω => ω ∈ lowerFrontierCell G I J x S F) (ballIncidentEdges G S) := by + intro ω η hωη + have hc := restricted_exactCluster_dependsOn G I x S hωη + change (cluster G (Set.inter ω I) x = S) = + (cluster G (Set.inter η I) x = S) at hc + have ha : ∀ e ∈ ballIncidentEdges G S, + (e ∈ Set.inter ω J) = (e ∈ Set.inter η J) := by + intro e he + exact congrArg (fun p : Prop => p ∧ e ∈ J) (hωη e he) + have hf := openFrontier_dependsOn G S ha + change openFrontier G (Set.inter ω J) S = openFrontier G (Set.inter η J) S at hf + change (cluster G (Set.inter ω I) x = S ∧ openFrontier G (Set.inter ω J) S = F) = + (cluster G (Set.inter η I) x = S ∧ openFrontier G (Set.inter η J) S = F) + rw [hc,hf] + +lemma measurableSet_lowerFrontierCell [Countable V] [Countable E] + (I J : Set E) (x : V) (S F : Set V) : + MeasurableSet (lowerFrontierCell G I J x S F) := by + have hm : Measurable (fun ω : Set E => ω ∩ J) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact (measurableSet_restricted_exactCluster G I x S).inter + ((measurableSet_openFrontier_eq G S F).preimage hm) + +theorem conn_last_exit_frontier (ω : Set E) (S : Set V) {x y : V} + (hx : x ∈ S) (hy : y ∉ S) (hc : Conn G ω x y) : + ∃ z ∈ openFrontier G ω S, Conn G (ω \ ballIncidentEdges G S) z y := by + revert hy + induction hc with + | refl => exact fun hy => (hy hx).elim + | @tail a b hxa hab ih => + intro hy + obtain ⟨e,he,heq⟩ := hab + by_cases ha : a ∈ S + · exact ⟨b,⟨hy,a,ha,e,he,heq⟩,conn_refl G _ b⟩ + · obtain ⟨z,hz,hza⟩ := ih ha + refine ⟨z,hz,hza.tail ⟨e,⟨he,?_⟩,heq⟩⟩ + rintro ⟨u,hu,hue⟩ + rw [heq,Sym2.mem_iff] at hue + rcases hue with rfl | rfl + · exact ha hu + · exact hy hu + +lemma openFrontier_lowerCluster_outside (ω : Set E) (D : Set V) (x : V) + (hx : x ∈ D) {z : V} + (hz : z ∈ openFrontier G ω (cluster G (ω ∩ internalEdges G D) x)) : z ∉ D := by + rintro hzD + obtain ⟨hz,u,hu,e,he,heq⟩ := hz + have huD := conn_internalEdges_end_mem G ω D hx hu + apply hz + exact hu.tail ⟨e,⟨he,(mem_internalEdges_of_ends G D e u z heq).mpr ⟨huD,hzD⟩⟩,heq⟩ + +theorem lowerCluster_new_vertex_cover (ω : Set E) (D U : Set V) (x y : V) + (hy : y ∉ cluster G (ω ∩ internalEdges G D) x) + (hc : Conn G (ω ∩ internalEdges G U) x y) : + ∃ z ∈ openFrontier G (ω ∩ internalEdges G U) + (cluster G (ω ∩ internalEdges G D) x), + Conn G ((ω ∩ internalEdges G U) \ + ballIncidentEdges G (cluster G (ω ∩ internalEdges G D) x)) z y := + conn_last_exit_frontier G _ _ (mem_cluster_self G _ x) hy hc + +def restrictedLayerCount (I : Set E) (A : Set V) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, if y ∈ A ∧ Conn G (ω ∩ I) x y then 1 else 0 + +lemma measurable_restrictedLayerCount [Countable V] [Countable E] + (I : Set E) (A : Set V) (x : V) : Measurable (fun ω => restrictedLayerCount G I A ω x) := by + have hm : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact Measurable.tsum fun y => Measurable.ite + (measurable_const.and ((measurableSet_conn G x y).mem.comp hm)).setOf + measurable_const measurable_const + +lemma restrictedLayerCount_dependsOn (I : Set E) (A : Set V) (x : V) : + DependsOn (fun ω => restrictedLayerCount G I A ω x) I := by + intro ω η hωη + have he : Set.inter ω I = Set.inter η I := by + ext e + change (ω e ∧ e ∈ I) ↔ (η e ∧ e ∈ I) + by_cases hi : e ∈ I + · simp only [hi,and_true] + exact Iff.of_eq (hωη e hi) + · simp only [hi,and_false] + change (∑' y, if y ∈ A ∧ Conn G (Set.inter ω I) x y then (1 : ℝ≥0∞) else 0) = + (∑' y, if y ∈ A ∧ Conn G (Set.inter η I) x y then (1 : ℝ≥0∞) else 0) + rw [he] + +lemma restrictedLayerCount_mono_edges {I J : Set E} (hIJ : I ⊆ J) + (A : Set V) (ω : Set E) (x : V) : + restrictedLayerCount G I A ω x ≤ restrictedLayerCount G J A ω x := by + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : y ∈ A ∧ Conn G (ω ∩ I) x y + · rw [ite_eq_left hy,ite_eq_left + ⟨hy.1,conn_mono G (Set.inter_subset_inter_right _ hIJ) hy.2⟩] + · rw [ite_eq_right hy] + exact bot_le + +theorem layerCount_le_frontier_sum (ω : Set E) (I J : Set E) + (x : V) (S : Set V) (F : Finset V) (A : Set V) + (hcell : ω ∈ lowerFrontierCell G I J x S (F : Set V)) : + restrictedLayerCount G J (A \ S) ω x ≤ + ∑ z ∈ F, restrictedLayerCount G (J \ ballIncidentEdges G S) A ω z := by + rw [show (∑ z ∈ F, restrictedLayerCount G (J \ ballIncidentEdges G S) A ω z) = + ∑' y, ∑ z ∈ F, if y ∈ A ∧ + Conn G (ω ∩ (J \ ballIncidentEdges G S)) z y then (1 : ℝ≥0∞) else 0 by + exact (Summable.tsum_finsetSum (fun _ _ => ENNReal.summable)).symm] + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : y ∈ A \ S ∧ Conn G (ω ∩ J) x y + · rw [ite_eq_left hy] + obtain ⟨z,hz,hzy⟩ := conn_last_exit_frontier G (ω ∩ J) S + (hcell.1 ▸ mem_cluster_self G (ω ∩ I) x) hy.1.2 hy.2 + have hzF : z ∈ F := by + change z ∈ (F : Set V) + rwa [←hcell.2] + have he : Set.inter ω (Set.diff J (ballIncidentEdges G S)) = + Set.diff (Set.inter ω J) (ballIncidentEdges G S) := by + ext e + exact and_assoc.symm + have hzterm : (if y ∈ A ∧ Conn G (ω ∩ (J \ ballIncidentEdges G S)) z y + then (1 : ℝ≥0∞) else 0) = 1 := by + have hc' : Conn G (ω ∩ (J \ ballIncidentEdges G S)) z y := by + change Conn G (Set.inter ω (Set.diff J (ballIncidentEdges G S))) z y + rw [he] + exact hzy + rw [ite_eq_left ⟨hy.1.1,hc'⟩] + exact hzterm.symm.le.trans (Finset.single_le_sum + (f := fun z => if y ∈ A ∧ Conn G (ω ∩ (J \ ballIncidentEdges G S)) z y + then (1 : ℝ≥0∞) else 0) (fun _ _ => bot_le) hzF) + · rw [ite_eq_right hy] + exact bot_le + +theorem lowerFrontierCell_fractional_bound [Countable V] [Countable E] + (q : E → unitInterval) (I J : Set E) (x : V) (S : Set V) + (F : Finset V) (A : Set V) {a b : ℝ} + (ha : 0 < a) (ha1 : a ≤ 1) (hb : 0 < b) (hb1 : b ≤ 1) + (L : ℝ≥0∞) (hL : ∀ z ∈ F, + (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, (lowerFrontierCell G I J x S (F : Set V)).indicator + (fun ω => restrictedLayerCount G J (A \ S) ω x^(a*b)) ω + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + CriticalPercolation.BernoulliProduct.law q + (lowerFrontierCell G I J x S (F : Set V)) * (F.card : ℝ≥0∞)^b*L^b := by + let Q := ballIncidentEdges G S + let f : V → Set E → ℝ≥0∞ := fun z ω => restrictedLayerCount G (J \ Q) A ω z + let g : Set E → ℝ≥0∞ := fun ω => ∑ z ∈ F, f z ω + have hf (z : V) : Measurable (f z) := measurable_restrictedLayerCount G _ A z + have hg : Measurable g := Finset.measurable_sum F (fun z _ => hf z) + have hd : DependsOn g Qᶜ := by + intro ω η hωη + apply Finset.sum_congr rfl + intro z _ + exact restrictedLayerCount_dependsOn G (J \ Q) A z (fun e he => hωη e he.2) + have hLf (z : V) (hz : z ∈ F) : + (∫⁻ ω, f z ω^a ∂CriticalPercolation.BernoulliProduct.law q) ≤ L := by + exact le_trans (lintegral_mono fun ω => ENNReal.rpow_le_rpow + (restrictedLayerCount_mono_edges G (I := J \ Q) (J := J) + Set.sdiff_subset A ω z) ha.le) (hL z hz) + have hbound := exposed_frontier_fractional_bound q Q + (lowerFrontierCell G I J x S (F : Set V)) + (measurableSet_lowerFrontierCell G I J x S _) (lowerFrontierCell_dependsOn G I J x S _) + F f (fun z _ => hf z) g hg hd (fun _ => le_rfl) ha ha1 hb hb1 L hLf + apply le_trans (lintegral_mono ?_) hbound + intro ω + by_cases hω : ω ∈ lowerFrontierCell G I J x S (F : Set V) + · simp only [Set.indicator_of_mem hω] + exact ENNReal.rpow_le_rpow (layerCount_le_frontier_sum G ω I J x S F A hω) + (mul_nonneg ha.le hb.le) + · simp only [Set.indicator_of_notMem hω,le_refl] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierLocalization.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierLocalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..0711b44adbf4c5bf14058db815317fc833cb80a6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerFrontierLocalization.lean @@ -0,0 +1,84 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierExpectation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restrictedLayerCount_eq_card (I : Set E) (A : Set V) (ω : Set E) (x : V) + (F : Finset V) (hF : ∀ y, y ∈ F ↔ y ∈ A ∧ Conn G (ω ∩ I) x y) : + restrictedLayerCount G I A ω x = F.card := by + unfold restrictedLayerCount + rw [tsum_eq_sum (s := F) (fun y hy => ite_eq_right (fun hh => hy ((hF y).mpr hh)))] + calc + _ = ∑ _y ∈ F, (1 : ℝ≥0∞) := + Finset.sum_congr rfl (fun y hy => ite_eq_left ((hF y).mp hy)) + _ = _ := by simp only [Finset.sum_const,nsmul_eq_mul,mul_one] + +theorem frontierCount_le_boundary_layer (hloc : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hloc u).toFinset.card ≤ d) + (I J : Set E) (ω : Set E) (x : V) (A : Set V) + (hfin : (cluster G (ω ∩ I) x).Finite) + (hA : ∀ u ∈ cluster G (ω ∩ I) x, ∀ z ∉ cluster G (ω ∩ I) x, + ∀ e ∈ ω ∩ J, G e = s(u,z) → u ∈ A) : + frontierCount G I J ω x ≤ (d : ℝ≥0∞)*restrictedLayerCount G I A ω x := by + let C := cluster G (ω ∩ I) x + have hCA : (C ∩ A).Finite := hfin.inter_of_left A + let S := hCA.toFinset + have hF := openFrontier_finite G hloc (ω ∩ J) hfin + let F := hF.toFinset + have hcover : F ⊆ S.biUnion (fun u => (finite_neighbors hloc u).toFinset) := by + intro z hz + obtain ⟨hz,u,hu,e,he,heq⟩ := hF.mem_toFinset.mp hz + exact Finset.mem_biUnion.mpr ⟨u,hCA.mem_toFinset.mpr ⟨hu,hA u hu z hz e he heq⟩, + (finite_neighbors hloc u).mem_toFinset.mpr ⟨e,heq⟩⟩ + have hcard : F.card ≤ S.card*d := + (Finset.card_le_card hcover).trans (Finset.card_biUnion_le.trans + ((Finset.sum_le_sum (fun u _ => hd u)).trans_eq (by simp))) + have hcount : restrictedLayerCount G I A ω x = S.card := + restrictedLayerCount_eq_card G I A ω x S (fun y => by + rw [hCA.mem_toFinset] + exact and_comm) + have hfcount : frontierCount G I J ω x = F.card := + frontierCount_eq_card_on_cell G I J x C F + ⟨rfl,hF.coe_toFinset.symm⟩ + rw [hfcount,hcount,mul_comm] + exact_mod_cast hcard + +theorem lower_halfspace_frontier_incident_top_band + (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) (J : Set E) (x : V) (hx : f x ≤ b) + {u z : V} (hu : u ∈ cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x) + (hz : z ∉ cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x) + {e : E} (he : e ∈ ω ∩ J) (heq : G e = s(u,z)) : + b-R ≤ f u ∧ f u ≤ b := by + have hub := conn_internalEdges_end_mem G ω {v | f v ≤ b} hx hu + have hzb : ¬f z ≤ b := openFrontier_lowerCluster_outside G ω + {v | f v ≤ b} x hx ⟨hz,u,hu,e,he.1,heq⟩ + have hj := (abs_le.mp (hjump e u z (by rw [heq]; simp) (by rw [heq]; simp))).2 + exact ⟨by linarith,hub⟩ + +theorem lower_halfspace_frontierCount_le_top_band + (hloc : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hloc u).toFinset.card ≤ d) + (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) (J : Set E) (x : V) (hx : f x ≤ b) + (hfin : (cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x).Finite) : + frontierCount G (internalEdges G {v | f v ≤ b}) J ω x ≤ + (d : ℝ≥0∞)*restrictedLayerCount G (internalEdges G {v | f v ≤ b}) + {u | b-R ≤ f u ∧ f u ≤ b} ω x := by + exact frontierCount_le_boundary_layer G hloc d hd _ J ω x _ hfin + (fun _ hu _ hz _ he heq => + lower_halfspace_frontier_incident_top_band G f R b hjump ω J x hx hu hz he heq) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerMaximumDecomposition.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerMaximumDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..48c92a69f3626979147b0c0ff2d530ed8dbbac48 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerMaximumDecomposition.lean @@ -0,0 +1,168 @@ +import OAI.Probability.BenjaminiSchramm.LayerFirstMoments +import OAI.Probability.BenjaminiSchramm.SlabLastMaximum + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem max_height_layer_moment_bound (f : V → ℝ) (I : Set E) + (p : unitInterval) (x : V) (i : ℝ) : + (∫⁻ ω, restrictedLayerCount G I {y | f y=i} ω x ∂law p) ≤ + ∑' z, if f x ≤ f z ∧ i ≤ f z then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ f z})) x z} * + (∫⁻ ω, restrictedLayerCount G (I ∩ internalEdges G {v | f v ≤ f z}) + {y | f y=i} ω z ∂law p) else 0 := by + simp_rw [lintegral_restrictedLayerCount] + calc + _ ≤ ∑' y, ∑' z, if f y=i ∧ f x ≤ f z ∧ i ≤ f z then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ f z})) x z} * + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ f z})) z y} else 0 := by + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : f y=i + · simp only [Set.mem_ofPred_eq,hy,ite_true] + have hh := max_height_connection_bound G f I p x y + refine hh.trans_eq (tsum_congr fun z => ?_) + rw [hy] + by_cases hz : f x ≤ f z ∧ i ≤ f z + · simp only [hz,true_and,ite_true] + · simp only [hz,true_and,ite_false] + · simp only [Set.mem_ofPred_eq,hy,false_and,ite_false,tsum_zero,le_refl] + _ = _ := by + rw [ENNReal.tsum_comm] + apply tsum_congr + intro z + by_cases hz : f x ≤ f z ∧ i ≤ f z + · rw [ite_eq_left hz,←ENNReal.tsum_mul_left] + apply tsum_congr + intro y + by_cases hy : f y=i <;> + simp only [Set.mem_ofPred_eq,hy,hz,true_and,false_and,ite_true,ite_false,mul_zero] + · rw [ite_eq_right hz] + apply ENNReal.tsum_eq_zero.mpr + intro y + exact ite_eq_right (by tauto) + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def adjustedFullLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) + (i : ℤ) (x : V) (u : ℝ) : ℝ≥0∞ := + ∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R u x y=i} ω x ∂G.law p + +def supAdjustedFullLayerMoment (a : V → ℝ) (R : ℝ) (p : unitInterval) (i : ℤ) : ℝ≥0∞ := + ⨆ x, ⨆ u, G.adjustedFullLayerMoment a R p i x u + +omit [Countable V] [Countable E] in +lemma adjustedFullLayerMoment_le_sup (a : V → ℝ) (R : ℝ) (p : unitInterval) + (i : ℤ) (x : V) (u : ℝ) : + G.adjustedFullLayerMoment a R p i x u ≤ G.supAdjustedFullLayerMoment a R p i := + le_iSup_of_le x (le_iSup_of_le u le_rfl) + +theorem adjusted_full_layer_moment_bound (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (p : unitInterval) (x : V) (u : ℝ) (i : ℤ) : + (∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R u x y=i} ω x ∂G.law p) ≤ + ∑' j : ℕ, if i ≤ (j : ℤ) then + G.supAdjustedUpLayerMoment a R p j * + G.supAdjustedDownLayerMoment a R p ((j : ℤ)-i).toNat else 0 := by + let f := G.adjustedLayerIndex a R u x + let J (z : V) := Percolation.internalEdges G.ends {v | f v ≤ f z} + let T (z : V) := G.law p {ω | Percolation.Conn G.ends (ω ∩ J z) x z} + let D (z : V) := ∫⁻ ω, restrictedLayerCount G.ends (J z) {y | f y=i} ω z ∂G.law p + have hbase : (∫⁻ ω, restrictedLayerCount G.ends Set.univ {y | f y=i} ω x ∂G.law p) ≤ + ∑' z, if 0 ≤ f z ∧ i ≤ f z then T z*D z else 0 := by + have hh := max_height_layer_moment_bound G.ends (fun v => (f v : ℝ)) Set.univ p x i + have htar : {y : V | (f y : ℝ)=(i : ℝ)}={y | f y=i} := by ext y; simp + have hdom (z : V) : {v : V | (f v : ℝ) ≤ (f z : ℝ)}={v | f v ≤ f z} := by ext v; simp + simp only [htar,hdom,Set.univ_inter] at hh + change _ ≤ _ + refine hh.trans_eq (tsum_congr fun z => ?_) + have hx : f x=0 := G.adjustedLayerIndex_self a R u x + have he : ((f x : ℝ) ≤ (f z : ℝ) ∧ (i : ℝ) ≤ (f z : ℝ)) ↔ (0 ≤ f z ∧ i ≤ f z) := by + rw [hx] + exact_mod_cast (Iff.rfl : (0 ≤ f z ∧ i ≤ f z) ↔ (0 ≤ f z ∧ i ≤ f z)) + simp only [he,T,D,J,law,Percolation.law] + have hcont (z : V) (j : ℕ) (hz : f z=(j : ℤ)) (hi : i ≤ (j : ℤ)) : + D z ≤ G.supAdjustedDownLayerMoment a R p ((j : ℤ)-i).toNat := by + let v := G.orbitAdjustedHeight a x z/R+u + have hidx (y : V) : f y=(j : ℤ)+G.adjustedLayerIndex a R v z y := by + simpa only [f,hz] using G.adjustedLayerIndex_change_base hc hl a R u x z y + have hdom : {y : V | f y ≤ f z}={y | G.adjustedLayerIndex a R v z y ≤ 0} := by + ext y + change f y ≤ f z ↔ G.adjustedLayerIndex a R v z y ≤ 0 + rw [hz,hidx] + omega + have htar : {y : V | f y=i}= + {y | G.adjustedLayerIndex a R v z y = -(((j : ℤ)-i).toNat : ℤ)} := by + ext y + change f y=i ↔ G.adjustedLayerIndex a R v z y = -(((j : ℤ)-i).toNat : ℤ) + rw [hidx,Int.toNat_of_nonneg (sub_nonneg.mpr hi)] + omega + change (∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | f y ≤ f z}) {y | f y=i} ω z ∂G.law p) ≤ _ + rw [hdom,htar] + exact G.adjustedDownLayerMoment_le_sup a R p _ z v + have hrow (j : ℕ) : (∑' z, if f z=(j : ℤ) then T z else 0) ≤ + G.supAdjustedUpLayerMoment a R p j := by + apply le_trans _ (G.adjustedUpLayerMoment_le_sup a R p j x u) + rw [adjustedUpLayerMoment] + change _ ≤ ∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | f v ≤ (j : ℤ)}) {v | f v=(j : ℤ)} ω x ∂Percolation.law p + rw [lintegral_restrictedLayerCount] + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z=(j : ℤ) + · simp only [Set.mem_ofPred_eq,hz,ite_true,T,J,law,Percolation.law,le_refl] + · simp only [Set.mem_ofPred_eq,hz,ite_false,le_refl] + calc + _ ≤ ∑' z, if 0 ≤ f z ∧ i ≤ f z then T z*D z else 0 := hbase + _ ≤ ∑' z, ∑' j : ℕ, if f z=(j : ℤ) ∧ i ≤ (j : ℤ) then + T z*G.supAdjustedDownLayerMoment a R p ((j : ℤ)-i).toNat else 0 := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : 0 ≤ f z ∧ i ≤ f z + · rw [ite_eq_left hz] + have hj : f z=((f z).toNat : ℤ) := (Int.toNat_of_nonneg hz.1).symm + apply le_trans (mul_le_mul' le_rfl (hcont z _ hj (hz.2.trans_eq hj))) + have hband : f z=((f z).toNat : ℤ) ∧ i ≤ ((f z).toNat : ℤ) := ⟨hj,hz.2.trans_eq hj⟩ + have ht := ENNReal.le_tsum (f := fun j : ℕ => if f z=(j : ℤ) ∧ i ≤ (j : ℤ) then + T z*G.supAdjustedDownLayerMoment a R p ((j : ℤ)-i).toNat else 0) (f z).toNat + rwa [ite_eq_left hband] at ht + · rw [ite_eq_right hz] + exact bot_le + _ = ∑' j : ℕ, if i ≤ (j : ℤ) then + (∑' z, if f z=(j : ℤ) then T z else 0)* + G.supAdjustedDownLayerMoment a R p ((j : ℤ)-i).toNat else 0 := by + rw [ENNReal.tsum_comm] + apply tsum_congr + intro j + by_cases hi : i ≤ (j : ℤ) + · rw [ite_eq_left hi,←ENNReal.tsum_mul_right] + apply tsum_congr + intro z + by_cases hz : f z=(j : ℤ) <;> + simp only [hi,hz,true_and,false_and,ite_true,ite_false,zero_mul] + · simp only [hi,and_false,ite_false,tsum_zero] + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro j + by_cases hi : i ≤ (j : ℤ) + · simp only [hi,ite_true] + exact mul_le_mul' (hrow j) le_rfl + · simp only [hi,ite_false,le_refl] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerMomentCauchy.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerMomentCauchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..02b9309786e2c8acaf759128ee6dabd2eab5f431 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerMomentCauchy.lean @@ -0,0 +1,77 @@ +import OAI.Probability.BenjaminiSchramm.MinimumHeightHit +import OAI.Probability.BenjaminiSchramm.UpperLayerSecondMoment +import Mathlib.MeasureTheory.Integral.MeanInequalities + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma lintegral_support_cauchy {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (f : Ω → ℝ≥0∞) (hf : Measurable f) + (A : Set Ω) (hA : MeasurableSet A) (hzero : ∀ ω, ω ∉ A → f ω=0) : + (∫⁻ ω, f ω ∂μ)^2 ≤ μ A*(∫⁻ ω, (f ω)^2 ∂μ) := by + let g := A.indicator (fun _ => (1 : ℝ≥0∞)) + have hg : Measurable g := measurable_const.indicator hA + have hfg : (fun ω => f ω*g ω)=f := by + funext ω + by_cases hω : ω ∈ A + · simp only [g,Set.indicator_of_mem hω,mul_one] + · simp only [g,Set.indicator_of_notMem hω,mul_zero,hzero ω hω] + have hgg : (fun ω => (g ω)^2)=g := by + funext ω + by_cases hω : ω ∈ A <;> simp [g,hω] + have hgm : (∫⁻ ω, g ω ∂μ)=μ A := lintegral_indicator_one hA + have hh := ENNReal.lintegral_mul_le_Lp_mul_Lq μ Real.HolderConjugate.two_two + hf.aemeasurable hg.aemeasurable + simp only [Pi.mul_apply,hfg,ENNReal.rpow_two,hgg,hgm] at hh + have hsqrt (z : ℝ≥0∞) : (z^((1 : ℝ)/2))^2=z := by + rw [←ENNReal.rpow_two,←ENNReal.rpow_mul] + norm_num + have hh2 := pow_le_pow_left' hh 2 + rw [mul_pow,hsqrt,hsqrt,mul_comm] at hh2 + exact hh2 + +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma restrictedLayerCount_moment_cauchy (I : Set E) (A : Set V) (p : unitInterval) (x : V) : + (∫⁻ ω, restrictedLayerCount G I A ω x ∂law p)^2 ≤ + law p (restrictedHit G I x A) * + (∫⁻ ω, (restrictedLayerCount G I A ω x)^2 ∂law p) := by + apply lintegral_support_cauchy (law p) _ (measurable_restrictedLayerCount G I A x) _ + (measurableSet_finiteWitness _ (restrictedHit_upper G I x A) (restrictedHit_finiteWitness G I x A)) + intro ω hω + apply ENNReal.tsum_eq_zero.mpr + intro y + exact ite_eq_right (fun h => hω ⟨y,h.1,h.2⟩) + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem adjustedUpLayerMoment_cauchy + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (p : unitInterval) (n : ℕ) (x : V) (u : ℝ) : + (G.adjustedUpLayerMoment a R p n x u)^2 ≤ + G.law p (restrictedHit G.ends Set.univ x {y | R*((n : ℝ)-1) ≤ G.orbitAdjustedHeight a x y}) * + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | G.adjustedLayerIndex a R u x y ≤ (n : ℤ)}) + {y | G.adjustedLayerIndex a R u x y=(n : ℤ)} ω x)^2 ∂G.law p) := by + apply (restrictedLayerCount_moment_cauchy G.ends _ _ p x).trans + apply mul_le_mul' (measure_mono ?_) le_rfl + rintro ω ⟨y,hy,hxy⟩ + have hh := (G.adjustedLayerIndex_height_bounds a R u hR x y).1 + rw [hy] at hh + refine ⟨y,?_,Percolation.conn_mono G.ends + (show ω ∩ Percolation.internalEdges G.ends _ ⊆ ω ∩ Set.univ from fun e he => ⟨he.1,Set.mem_univ e⟩) hxy⟩ + exact_mod_cast hh.le + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerMomentDecomposition.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerMomentDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..3aa9f228f5f91ba265154cad04a448437f13d369 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerMomentDecomposition.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.BlockExposure +import Mathlib.MeasureTheory.Integral.MeanInequalities + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma ennreal_lintegral_rpow_le_rpow_lintegral + {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (f : Ω → ℝ≥0∞) (hf : Measurable f) {b : ℝ} (hb : 0 < b) (hb1 : b ≤ 1) : + (∫⁻ ω, f ω ^ b ∂μ) ≤ (∫⁻ ω, f ω ∂μ)^b := by + by_cases he : b = 1 + · simp only [he,ENNReal.rpow_one,le_refl] + have hblt : b < 1 := lt_of_le_of_ne hb1 he + have hc := Real.holderConjugate_one_div hb (sub_pos.mpr hblt) (by ring : b+(1-b)=1) + have hh := ENNReal.lintegral_mul_le_Lp_mul_Lq μ hc + ((hf.pow_const b).aemeasurable) (measurable_const.aemeasurable : AEMeasurable (fun _ : Ω => (1 : ℝ≥0∞)) μ) + have hcancel : b*(1/b)=1 := by field_simp + have hinv : 1/(1/b)=b := by field_simp + simpa only [Pi.mul_apply,mul_one,ENNReal.one_rpow,←ENNReal.rpow_mul,hcancel,ENNReal.rpow_one, + lintegral_const,measure_univ,one_mul,hinv] using hh + +lemma ennreal_fractional_finset_sum {ι : Type*} (F : Finset ι) (f : ι → ℝ≥0∞) + {a : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) : + (∑ z ∈ F, f z)^a ≤ ∑ z ∈ F, f z^a := by + induction F using Finset.induction_on with + | empty => simp only [Finset.sum_empty,ENNReal.zero_rpow_of_pos ha,le_refl] + | @insert z F hz ih => + simp only [Finset.sum_insert hz] + exact (ENNReal.rpow_add_le_add_rpow _ _ ha.le ha1).trans (add_le_add le_rfl ih) + +theorem fractional_frontier_continuations + {Ω ι : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (F : Finset ι) (f : ι → Ω → ℝ≥0∞) (hf : ∀ z ∈ F, Measurable (f z)) + (g : Ω → ℝ≥0∞) (hcover : ∀ ω, g ω ≤ ∑ z ∈ F, f z ω) + {a b : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) (hb : 0 < b) (hb1 : b ≤ 1) + (L : ℝ≥0∞) (hL : ∀ z ∈ F, (∫⁻ ω, f z ω^a ∂μ) ≤ L) : + (∫⁻ ω, g ω^(a*b) ∂μ) ≤ (F.card : ℝ≥0∞)^b*L^b := by + have hm : Measurable (fun ω => ∑ z ∈ F, f z ω^a) := + Finset.measurable_sum F (fun z hz => (hf z hz).pow_const a) + calc + _ ≤ ∫⁻ ω, (∑ z ∈ F, f z ω^a)^b ∂μ := by + apply lintegral_mono + intro ω + change g ω^(a*b) ≤ (∑ z ∈ F, f z ω^a)^b + rw [ENNReal.rpow_mul] + exact ENNReal.rpow_le_rpow + ((ENNReal.rpow_le_rpow (hcover ω) ha.le).trans + (ennreal_fractional_finset_sum F (fun z => f z ω) ha ha1)) hb.le + _ ≤ (∫⁻ ω, ∑ z ∈ F, f z ω^a ∂μ)^b := + ennreal_lintegral_rpow_le_rpow_lintegral μ _ hm hb hb1 + _ = (∑ z ∈ F, ∫⁻ ω, f z ω^a ∂μ)^b := by + rw [lintegral_finsetSum F (fun z hz => (hf z hz).pow_const a)] + _ ≤ ((F.card : ℝ≥0∞)*L)^b := by + apply ENNReal.rpow_le_rpow _ hb.le + calc + _ ≤ ∑ _z ∈ F, L := Finset.sum_le_sum hL + _ = _ := by simp only [Finset.sum_const,nsmul_eq_mul] + _ = _ := ENNReal.mul_rpow_of_nonneg _ _ hb.le + +theorem exposed_frontier_fractional_bound {E ι : Type*} + (q : E → unitInterval) (Q : Set E) (A : Set (Set E)) + (hA : MeasurableSet A) (hAdep : DependsOn (fun ω => ω ∈ A) Q) + (F : Finset ι) (f : ι → Set E → ℝ≥0∞) (hf : ∀ z ∈ F, Measurable (f z)) + (g : Set E → ℝ≥0∞) (hg : Measurable g) (hgdep : DependsOn g Qᶜ) + (hcover : ∀ ω, g ω ≤ ∑ z ∈ F, f z ω) + {a b : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) (hb : 0 < b) (hb1 : b ≤ 1) + (L : ℝ≥0∞) (hL : ∀ z ∈ F, + (∫⁻ ω, f z ω^a ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, A.indicator (fun ω => g ω^(a*b)) ω ∂CriticalPercolation.BernoulliProduct.law q) ≤ + CriticalPercolation.BernoulliProduct.law q A * (F.card : ℝ≥0∞)^b*L^b := by + rw [CriticalPercolation.BernoulliProduct.lintegral_indicator_fresh q Q A hA hAdep _ + (hg.pow_const (a*b)) (fun ω η h => congrArg (fun x : ℝ≥0∞ => x^(a*b)) (hgdep h))] + exact (mul_le_mul' le_rfl (fractional_frontier_continuations + (CriticalPercolation.BernoulliProduct.law q) F f hf g hcover ha ha1 hb hb1 L hL)).trans_eq + (mul_assoc _ _ _).symm + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerMomentFekete.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerMomentFekete.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea1520b80dbc907a78f72812494e58f6c4ad3b6f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerMomentFekete.lean @@ -0,0 +1,88 @@ +import OAI.Probability.BenjaminiSchramm.CrossingExponent + +namespace OAI + +noncomputable section +open Set Filter +open scoped Classical Topology + +namespace Percolation.BenjaminiSchramm + +theorem positive_layer_moment_rate (P : ℕ → ℝ) (hP : ∀ n, 0 < P n) + (hP0 : 1 ≤ P 0) (hmul : ∀ m n, P (m+n) ≤ P m*P n) + (C : ℝ) (hbound : ∀ n, P n ≤ C) + (A B : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) + (hlower : ∀ n : ℕ, Real.exp (-A*n-B) ≤ P n) : + ∃ β : ℝ, 0 ≤ β ∧ + (∀ n : ℕ, Real.exp (-β*n) ≤ P n) ∧ + (∀ ε : ℝ, 0 < ε → ∃ K : ℝ, 0 < K ∧ ∀ n : ℕ, + P n ≤ K*Real.exp (-(β-ε)*n)) ∧ + Tendsto (fun n : ℕ => -Real.log (P n)/n) atTop (𝓝 β) := by + let u : ℕ → ℝ := fun n => Real.log (P n) + have hu : Subadditive u := by + intro m n + have hh := Real.log_le_log (hP (m+n)) (hmul m n) + rw [Real.log_mul (hP m).ne' (hP n).ne'] at hh + exact hh + have hlo (n : ℕ) : -A*n-B ≤ u n := by + have hh := Real.log_le_log (Real.exp_pos _) (hlower n) + rwa [Real.log_exp] at hh + have hbdd : BddBelow (Set.range fun n : ℕ => u n/n) := by + refine ⟨-A-B,?_⟩ + rintro _ ⟨n,rfl⟩ + by_cases hn : n=0 + · simp only [hn,Nat.cast_zero,div_zero] + linarith + · have hnpos : (0 : ℝ) < n := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn) + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hn + apply (le_div_iff₀ hnpos).mpr + nlinarith [hlo n] + let β := -hu.lim + have hlim0 : Tendsto (fun n : ℕ => u n/n) atTop (𝓝 hu.lim) := hu.tendsto_lim hbdd + have hlim : Tendsto (fun n : ℕ => -Real.log (P n)/n) atTop (𝓝 β) := by + simpa only [neg_div,u] using hlim0.neg + have hlog (n : ℕ) : u n ≤ Real.log C := Real.log_le_log (hP n) (hbound n) + have hzero : Tendsto (fun n : ℕ => Real.log C/(n : ℝ)) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop + have hlimle : hu.lim ≤ 0 := by + apply le_of_tendsto_of_tendsto hlim0 hzero + filter_upwards [eventually_ge_atTop (1 : ℕ)] with n hn + exact div_le_div_of_nonneg_right (hlog n) (Nat.cast_nonneg n) + have hβ : 0 ≤ β := neg_nonneg.mpr hlimle + refine ⟨β,hβ,?_,?_,hlim⟩ + · intro n + by_cases hn : n=0 + · simpa only [hn,Nat.cast_zero,mul_zero,Real.exp_zero] using hP0 + have hr := (le_div_iff₀ (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn) : (0 : ℝ) < n)).mp + (hu.lim_le_div hbdd hn) + have hh : -β*(n : ℝ) ≤ Real.log (P n) := by simpa only [β,u,neg_neg] using hr + have he := Real.exp_le_exp.mpr hh + rwa [Real.exp_log (hP n)] at he + · intro ε hε + obtain ⟨N,hN⟩ := eventually_atTop.mp + (hlim.eventually (lt_mem_nhds (sub_lt_self β hε))) + let f : ℕ → ℝ := fun n => P n*Real.exp ((β-ε)*n) + obtain ⟨i,hi,himax⟩ := Finset.exists_max_image (Finset.range (N+1)) f + ⟨0,Finset.mem_range.mpr (Nat.succ_pos N)⟩ + let K := max 1 (f i) + refine ⟨K,lt_of_lt_of_le (by norm_num) (le_max_left _ _),fun n => ?_⟩ + by_cases hn : n < N+1 + · have hK : f n ≤ K := (himax n (Finset.mem_range.mpr hn)).trans (le_max_right _ _) + have hh := mul_le_mul_of_nonneg_right hK (Real.exp_pos (-(β-ε)*n)).le + have he : Real.exp ((β-ε)*n)*Real.exp (-(β-ε)*n)=1 := by + rw [←Real.exp_add] + ring_nf + exact Real.exp_zero + dsimp [f] at hh + rwa [mul_assoc,he,mul_one] at hh + · have hnpos : (0 : ℝ) < n := Nat.cast_pos.mpr (by omega) + have hh := (lt_div_iff₀ hnpos).mp (hN n (by omega)) + have he := Real.exp_le_exp.mpr (show Real.log (P n) ≤ -(β-ε)*(n : ℝ) by linarith) + rw [Real.exp_log (hP n)] at he + exact he.trans (le_mul_of_one_le_left (Real.exp_nonneg _) (le_max_left _ _)) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerMonotoneLimit.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerMonotoneLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..e789ed303ae60ada3c6743d4711a586d6819b1b1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerMonotoneLimit.lean @@ -0,0 +1,161 @@ +import OAI.Probability.BenjaminiSchramm.SlabCountBasic +import Mathlib.MeasureTheory.Integral.Lebesgue.Countable + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restrictedLayerCount_mono_vertices {A B : Set V} (hAB : A ⊆ B) + (I : Set E) (ω : Set E) (x : V) : + restrictedLayerCount G I A ω x ≤ restrictedLayerCount G I B ω x := by + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : y ∈ A ∧ Conn G (ω ∩ I) x y + · rw [ite_eq_left hy,ite_eq_left ⟨hAB hy.1,hy.2⟩] + · rw [ite_eq_right hy] + exact bot_le + +lemma internalEdges_lowerSlabs_iUnion (f : V → ℝ) (R c : ℝ) (hR : 0 < R) : + (⋃ n : ℕ, internalEdges G {z | -(n : ℝ)*R ≤ f z ∧ f z ≤ c})= + internalEdges G {z | f z ≤ c} := by + ext e + constructor + · rintro ⟨_,⟨n,rfl⟩,hn⟩ + exact internalEdges_mono G (fun _ hz => hz.2) hn + · intro he + have hpair : ∀ s : Sym2 V, (∀ z ∈ s, f z ≤ c) → + ∃ n : ℕ, ∀ z ∈ s, -(n : ℝ)*R ≤ f z ∧ f z ≤ c := by + intro s + induction s using Sym2.inductionOn with + | _ u v => + intro hs + obtain ⟨N,hN⟩ := exists_nat_gt (max (-f u/R) (-f v/R)) + refine ⟨N,fun z hz => ?_⟩ + have hNu : -f u < (N : ℝ)*R := + (div_lt_iff₀ hR).mp ((le_max_left _ _).trans_lt hN) + have hNv : -f v < (N : ℝ)*R := + (div_lt_iff₀ hR).mp ((le_max_right _ _).trans_lt hN) + rcases Sym2.mem_iff.mp hz with rfl | rfl + · exact ⟨by linarith,hs z hz⟩ + · exact ⟨by linarith,hs z hz⟩ + obtain ⟨n,hn⟩ := hpair (G e) he + exact mem_iUnion.mpr ⟨n,hn⟩ + +lemma internalEdges_lowerSlabs_monotone (f : V → ℝ) (R c : ℝ) (hR : 0 ≤ R) : + Monotone (fun n : ℕ => internalEdges G {z | -(n : ℝ)*R ≤ f z ∧ f z ≤ c}) := by + intro n m hnm + apply internalEdges_mono G + intro z hz + have hh := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hnm : (n : ℝ) ≤ m) hR + exact ⟨by linarith [hz.1],hz.2⟩ + +lemma internalEdges_lowerSlabs_shift_iUnion (f : V → ℝ) (R c b : ℝ) (hR : 0 < R) : + (⋃ n : ℕ, internalEdges G {z | b-(n : ℝ)*R ≤ f z ∧ f z ≤ c})= + internalEdges G {z | f z ≤ c} := by + have he (n : ℕ) : {z | -(n : ℝ)*R ≤ f z-b ∧ f z-b ≤ c-b}= + {z | b-(n : ℝ)*R ≤ f z ∧ f z ≤ c} := by + ext z + constructor <;> intro hz <;> constructor <;> linarith [hz.1,hz.2] + have hc : {z | f z-b ≤ c-b}={z | f z ≤ c} := by + ext z + change (f z-b ≤ c-b) ↔ f z ≤ c + constructor <;> intro hz <;> linarith + simpa only [he,hc] using internalEdges_lowerSlabs_iUnion G (fun z => f z-b) R (c-b) hR + +lemma internalEdges_lowerSlabs_shift_monotone (f : V → ℝ) (R c b : ℝ) (hR : 0 ≤ R) : + Monotone (fun n : ℕ => internalEdges G {z | b-(n : ℝ)*R ≤ f z ∧ f z ≤ c}) := by + intro n j hnj + apply internalEdges_mono G + intro z hz + have hh := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hnj : (n : ℝ) ≤ j) hR + exact ⟨by linarith [hz.1],hz.2⟩ + +lemma internalEdges_upperSlabs_iUnion (f : V → ℝ) (R m b : ℝ) (hR : 0 < R) : + (⋃ n : ℕ, internalEdges G {z | m ≤ f z ∧ f z ≤ b+(n : ℝ)*R})= + internalEdges G {z | m ≤ f z} := by + have he (n : ℕ) : {z | -(n : ℝ)*R ≤ -f z+b ∧ -f z+b ≤ -m+b}= + {z | m ≤ f z ∧ f z ≤ b+(n : ℝ)*R} := by + ext z + constructor <;> intro hz <;> constructor <;> linarith [hz.1,hz.2] + have hc : {z | -f z+b ≤ -m+b}={z | m ≤ f z} := by + ext z + change (-f z+b ≤ -m+b) ↔ m ≤ f z + constructor <;> intro hz <;> linarith + simpa only [he,hc] using internalEdges_lowerSlabs_iUnion G (fun z => -f z+b) R (-m+b) hR + +lemma internalEdges_upperSlabs_monotone (f : V → ℝ) (R m b : ℝ) (hR : 0 ≤ R) : + Monotone (fun n : ℕ => internalEdges G {z | m ≤ f z ∧ f z ≤ b+(n : ℝ)*R}) := by + intro n j hnj + apply internalEdges_mono G + intro z hz + have hh := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hnj : (n : ℝ) ≤ j) hR + exact ⟨hz.1,by linarith [hz.2]⟩ + +variable [Countable V] [Countable E] + +omit [Countable E] in +lemma restrictedLayerCount_iUnion (I : ℕ → Set E) (hI : Monotone I) + (A : Set V) (ω : Set E) (x : V) : + restrictedLayerCount G (⋃ n, I n) A ω x = ⨆ n, restrictedLayerCount G (I n) A ω x := by + let : MeasurableSpace V := ⊤ + let : MeasurableSingletonClass V := ⟨fun _ => trivial⟩ + let f (n : ℕ) (y : V) : ℝ≥0∞ := if y ∈ A ∧ Conn G (ω ∩ I n) x y then 1 else 0 + have hf : ∀ n, Measurable (f n) := fun _ => measurable_of_countable _ + have hmono : Monotone f := by + intro n m hnm y + by_cases hy : y ∈ A ∧ Conn G (ω ∩ I n) x y + · have hym : y ∈ A ∧ Conn G (ω ∩ I m) x y := + ⟨hy.1,conn_mono G (inter_subset_inter_right ω (hI hnm)) hy.2⟩ + simp only [f,ite_eq_left hy,ite_eq_left hym,le_refl] + · simp only [f,ite_eq_right hy] + exact bot_le + have hpoint (y : V) : (if y ∈ A ∧ Conn G (ω ∩ ⋃ n, I n) x y then (1 : ℝ≥0∞) else 0)= + ⨆ n, f n y := by + by_cases hy : y ∈ A ∧ Conn G (ω ∩ ⋃ n, I n) x y + · rw [ite_eq_left hy] + have he : ω ∩ ⋃ n, I n=⋃ n, ω ∩ I n := inter_iUnion ω I + obtain ⟨n,hn⟩ := (conn_iUnion_iff G (fun n => ω ∩ I n) + (fun _ _ h => inter_subset_inter_right ω (hI h)) x y).mp (he ▸ hy.2) + apply le_antisymm + · exact le_iSup_of_le n (by + dsimp [f] + rw [ite_eq_left (show y ∈ A ∧ Conn G (ω ∩ I n) x y from ⟨hy.1,hn⟩)]) + · exact iSup_le fun n => by dsimp [f]; split_ifs <;> simp + · rw [ite_eq_right hy] + apply le_antisymm bot_le + apply iSup_le + intro n + have hn : ¬(y ∈ A ∧ Conn G (ω ∩ I n) x y) := fun hh => + hy ⟨hh.1,conn_mono G (inter_subset_inter_right ω (subset_iUnion I n)) hh.2⟩ + simp [f,hn] + unfold restrictedLayerCount + simp_rw [hpoint] + rw [←lintegral_count (fun y => ⨆ n, f n y),lintegral_iSup hf hmono] + simp_rw [lintegral_count] + rfl + +theorem restrictedLayerMoment_iUnion (I : ℕ → Set E) (hI : Monotone I) + (A : Set V) (x : V) (p : unitInterval) {q : ℝ} (hq : 0 < q) : + (∫⁻ ω, (restrictedLayerCount G (⋃ n, I n) A ω x)^q ∂law p)= + ⨆ n, ∫⁻ ω, (restrictedLayerCount G (I n) A ω x)^q ∂law p := by + have hp (ω : Set E) : (restrictedLayerCount G (⋃ n, I n) A ω x)^q = + ⨆ n, (restrictedLayerCount G (I n) A ω x)^q := by + rw [restrictedLayerCount_iUnion G I hI A ω x] + exact (ENNReal.orderIsoRpow q hq).map_iSup _ + simp_rw [hp] + apply lintegral_iSup + · intro n + exact (measurable_restrictedLayerCount G (I n) A x).pow_const q + · intro n m hnm ω + exact ENNReal.rpow_le_rpow (restrictedLayerCount_mono_edges G (hI hnm) A ω x) hq.le + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerPrefactorBootstrap.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerPrefactorBootstrap.lean new file mode 100644 index 0000000000000000000000000000000000000000..5174b625c09b863e24d0753f3c274f2057330e7d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerPrefactorBootstrap.lean @@ -0,0 +1,89 @@ +import OAI.Probability.BenjaminiSchramm.LayerMomentCauchy +import OAI.Probability.BenjaminiSchramm.PrefixMaximumBootstrap + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma ennreal_iSup_square_le {ι : Sort*} (f : ι → ℝ≥0∞) (C : ℝ≥0∞) + (h : ∀ i, (f i)^2 ≤ C) : (⨆ i, f i)^2 ≤ C := by + have hsqrt (z : ℝ≥0∞) : (z^((1 : ℝ)/2))^2=z := by + rw [←ENNReal.rpow_two,←ENNReal.rpow_mul] + norm_num + have hroot (i : ι) : f i ≤ C^((1 : ℝ)/2) := by + have hh := ENNReal.rpow_le_rpow (h i) (by norm_num : 0 ≤ (1 : ℝ)/2) + rw [←ENNReal.rpow_two,←ENNReal.rpow_mul] at hh + norm_num at hh + exact hh + exact (pow_le_pow_left' (iSup_le hroot) 2).trans_eq (hsqrt C) + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem adjusted_layer_prefactor_bootstrap + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (p : unitInterval) (β A B : ℝ) + (hA : 0 ≤ A) (hB : 0 ≤ B) + (hne : ∀ n, G.supAdjustedUpLayerMoment a R p n ≠ ⊤) + (hprob : ∀ (n : ℕ) (x : V), + G.law p (restrictedHit G.ends Set.univ x + {y | R*((n : ℝ)-1) ≤ G.orbitAdjustedHeight a x y}) ≤ ENNReal.ofReal (B*Real.exp (-β*n))) + (hsecond : ∀ (n : ℕ) (x : V) (u : ℝ), + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | G.adjustedLayerIndex a R u x y ≤ (n : ℤ)}) + {y | G.adjustedLayerIndex a R u x y=(n : ℤ)} ω x)^2 ∂G.law p) ≤ + ENNReal.ofReal (A*Real.exp (-β*n)*prefixMaximum + (fun j => Real.exp (β*j)*(G.supAdjustedUpLayerMoment a R p j).toReal) n)) : + ∀ n : ℕ, G.supAdjustedUpLayerMoment a R p n ≤ ENNReal.ofReal (A*B*Real.exp (-β*n)) := by + let S := G.supAdjustedUpLayerMoment a R p + let H : ℕ → ℝ := fun j => Real.exp (β*j)*(S j).toReal + have hH (j : ℕ) : 0 ≤ H j := mul_nonneg (Real.exp_pos _).le ENNReal.toReal_nonneg + have hM (n : ℕ) : 0 ≤ prefixMaximum H n := (hH 0).trans (le_prefixMaximum H (Nat.zero_le n)) + have hsq (n : ℕ) : (S n)^2 ≤ ENNReal.ofReal (A*B*(Real.exp (-β*n))^2*prefixMaximum H n) := by + apply ennreal_iSup_square_le + intro x + apply ennreal_iSup_square_le + intro u + have hh := (G.adjustedUpLayerMoment_cauchy a R hR p n x u).trans + (mul_le_mul' (hprob n x) (hsecond n x u)) + rw [←ENNReal.ofReal_mul (mul_nonneg hB (Real.exp_nonneg _))] at hh + convert hh using 1 + congr 1 + dsimp only [H,S] + ring + have hrec (n : ℕ) : (H n)^2 ≤ A*B*prefixMaximum H n := by + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top (hsq n) + have hnneg : 0 ≤ A*B*(Real.exp (-β*n))^2*prefixMaximum H n := + mul_nonneg (mul_nonneg (mul_nonneg hA hB) (sq_nonneg _)) (hM n) + rw [ENNReal.toReal_pow,ENNReal.toReal_ofReal hnneg] at hh + have hc : (Real.exp (β*n))^2*(Real.exp (-β*n))^2=1 := by + rw [←mul_pow,←Real.exp_add,show β*(n : ℝ)+ -β*n=0 by ring,Real.exp_zero,one_pow] + calc + _ = (Real.exp (β*n))^2*((S n).toReal)^2 := mul_pow _ _ _ + _ ≤ (Real.exp (β*n))^2*(A*B*(Real.exp (-β*n))^2*prefixMaximum H n) := + mul_le_mul_of_nonneg_left hh (sq_nonneg _) + _ = A*B*((Real.exp (β*n))^2*(Real.exp (-β*n))^2)*prefixMaximum H n := by ring + _ = _ := by rw [hc,mul_one] + intro n + have hb := prefix_square_bootstrap H (A*B) (mul_nonneg hA hB) hrec n + have hreal : (S n).toReal ≤ A*B*Real.exp (-β*n) := by + have hc : Real.exp (-β*n)*Real.exp (β*n)=1 := by + rw [←Real.exp_add,show -β*(n : ℝ)+β*n=0 by ring,Real.exp_zero] + calc + _ = Real.exp (-β*n)*H n := by dsimp only [H]; rw [←mul_assoc,hc,one_mul] + _ ≤ Real.exp (-β*n)*(A*B) := mul_le_mul_of_nonneg_left hb (Real.exp_nonneg _) + _ = _ := by ring + have he := ENNReal.ofReal_le_ofReal hreal + rwa [ENNReal.ofReal_toReal (hne n)] at he + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerProfileAtRate.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerProfileAtRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddba70b381af9e59798f5956797d5121a2b86f05 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerProfileAtRate.lean @@ -0,0 +1,111 @@ +import OAI.Probability.BenjaminiSchramm.SubcriticalFullLayerProfile +import OAI.Probability.BenjaminiSchramm.LayerSecondMomentDecomposition +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerConvolution + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_full_layer_profile_at_rate + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hpc : p < pc G) (β K : ℝ) (hβ : R < β) (hK : 0 < K) + (hup : ∀ n : ℕ, (criticalModel G).supAdjustedUpLayerMoment + ((criticalModel G).stationaryOrbitWeight μ) R p n ≤ ENNReal.ofReal (K*Real.exp (-β*n))) : + ∃ C : ℝ, 0 < C ∧ ∀ i : ℤ, + (criticalModel G).supAdjustedFullLayerMoment ((criticalModel G).stationaryOrbitWeight μ) R p i ≤ + ENNReal.ofReal (C*Real.exp (-(β-R)*|(i : ℝ)|)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨χ,hχ,hrow⟩ := subcritical_ennreal_row_bound G hl hq p hpc + obtain ⟨m,M,hm,hweights⟩ := H.stationaryOrbitWeight_uniform_bounds hHc hl μ hμ + let O := H.orbitRepresentatives hHq + let D : ℝ≥0∞ := (ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r)) + have hD : D ≠ ⊤ := ENNReal.mul_ne_top + (ENNReal.inv_ne_top.mpr (ENNReal.ofReal_ne_zero_iff.mpr hm)) + (ENNReal.sum_ne_top.mpr fun r _ => ENNReal.ofReal_ne_top) + have hDEq : ENNReal.ofReal D.toReal=D := ENNReal.ofReal_toReal hD + have hbase (i : ℤ) : H.supAdjustedFullLayerMoment a R p i ≤ ENNReal.ofReal χ := + H.supAdjustedFullLayerMoment_le_row_bound a R p _ hrow i + have hpositive (n : ℕ) : H.supAdjustedFullLayerMoment a R p n ≤ + ENNReal.ofReal (K*χ*Real.exp (-β*n)) := by + apply (H.supAdjustedFullLayerMoment_up_bound hHc hl a R hR hjump p _ hrow n).trans + apply (mul_le_mul' (hup n) le_rfl).trans_eq + rw [←ENNReal.ofReal_mul (mul_nonneg hK.le (Real.exp_nonneg _))] + congr 1 + ring + have hnegative (n : ℕ) (hn : 3 ≤ n) : H.supAdjustedFullLayerMoment a R p (-(n : ℤ)) ≤ + ENNReal.ofReal (D.toReal*K*χ*Real.exp (R+2*β)*Real.exp (-(β-R)*n)) := by + have hb : H.supAdjustedFullLayerMoment a R p (-(n : ℤ)) ≤ + D*ENNReal.ofReal (Real.exp (R*((n : ℝ)+1)))* + (H.supAdjustedUpLayerMoment a R p (n-2)*ENNReal.ofReal χ) := by + apply iSup_le + intro x + apply iSup_le + intro u + exact H.adjustedFullLayerMoment_negative_bound O hHc hl a + (H.stationaryOrbitWeight_pos hHc hl μ hμ) (H.stationaryOrbitWeight_aut μ) + m hm (fun x => (hweights x).1) R hR hjump p _ hrow n hn x u + apply hb.trans + apply (mul_le_mul' le_rfl (mul_le_mul' (hup (n-2)) le_rfl)).trans_eq + nth_rw 1 [←hDEq] + rw [←ENNReal.ofReal_mul ENNReal.toReal_nonneg, + ←ENNReal.ofReal_mul (mul_nonneg hK.le (Real.exp_nonneg _)), + ←ENNReal.ofReal_mul (mul_nonneg ENNReal.toReal_nonneg (Real.exp_nonneg _))] + congr 1 + rw [Nat.cast_sub (by omega : 2 ≤ n)] + push_cast + rw [show D.toReal*Real.exp (R*((n : ℝ)+1))*(K*Real.exp (-β*((n : ℝ)-2))*χ) = + D.toReal*K*χ*(Real.exp (R*((n : ℝ)+1))*Real.exp (-β*((n : ℝ)-2))) by ring, + ←Real.exp_add,show R*((n : ℝ)+1)+ -β*((n : ℝ)-2) = R+2*β + (-(β-R)*(n : ℝ)) by ring, + Real.exp_add] + ring + obtain ⟨C,hC,hprof⟩ := symmetric_exponential_profile + (H.supAdjustedFullLayerMoment a R p) χ K D.toReal R β hχ hK.le ENNReal.toReal_nonneg + hR hβ hbase hpositive hnegative + exact ⟨C,hC,hprof⟩ + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem adjusted_downward_layer_second_moment_at_rate + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) (R : ℝ) + (p : unitInterval) (β C : ℝ) (hβ : R < β) (hC : 0 < C) + (hprofile : ∀ i : ℤ, G.supAdjustedFullLayerMoment a R p i ≤ + ENNReal.ofReal (C*Real.exp (-(β-R)*|(i : ℝ)|))) : + ∃ K : ℝ≥0∞, K < ⊤ ∧ ∀ (k l : ℕ) (x : V) (u : ℝ), + (∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R u x y = -(k : ℤ)} ω x * + restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R u x y = -(l : ℤ)} ω x ∂G.law p) ≤ + K*ENNReal.ofReal (Real.exp (-(β-R)*((max k l : ℕ) : ℝ))) := by + have hprof (i : ℤ) : G.supAdjustedFullLayerMoment a R p i ≤ + ENNReal.ofReal C*expAbsLayerKernel (β-R) i := by + simpa only [expAbsLayerKernel,ENNReal.ofReal_mul hC.le] using hprofile i + obtain ⟨K,hK,hconv⟩ := subcritical_three_profile_uniform_bound (sub_pos.mpr hβ) + (ENNReal.ofReal C) ENNReal.ofReal_lt_top + refine ⟨K,hK,fun k l x u => ?_⟩ + exact (G.adjusted_full_layer_second_moment_bound hc hl a R p x u + (-(k : ℤ)) (-(l : ℤ))).trans + (hconv (G.supAdjustedFullLayerMoment a R p) (G.supAdjustedFullLayerMoment a R p) + (G.supAdjustedFullLayerMoment a R p) hprof hprof hprof k l) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/LayerSecondMomentDecomposition.lean b/lean/OAI/Probability/BenjaminiSchramm/LayerSecondMomentDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..c62103a69a7a97906c0a27af8c5a84455e74cfda --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/LayerSecondMomentDecomposition.lean @@ -0,0 +1,84 @@ +import OAI.Probability.BenjaminiSchramm.LayerMaximumDecomposition +import OAI.Probability.BenjaminiSchramm.SlabSecondMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem adjusted_full_layer_second_moment_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (p : unitInterval) (x : V) (u : ℝ) (k l : ℤ) : + (∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R u x y=k} ω x * + restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R u x y=l} ω x ∂G.law p) ≤ + ∑' i : ℤ, G.supAdjustedFullLayerMoment a R p i * + G.supAdjustedFullLayerMoment a R p (k-i) * G.supAdjustedFullLayerMoment a R p (l-i) := by + let f := G.adjustedLayerIndex a R u x + let T (z : V) := G.law p {ω | Percolation.Conn G.ends (ω ∩ Set.univ) x z} + have hcont (z : V) (j : ℤ) : + (∫⁻ ω, restrictedLayerCount G.ends Set.univ {y | f y=j} ω z ∂G.law p) ≤ + G.supAdjustedFullLayerMoment a R p (j-f z) := by + let v := G.orbitAdjustedHeight a x z/R+u + have hidx (y : V) : f y=f z+G.adjustedLayerIndex a R v z y := + G.adjustedLayerIndex_change_base hc hl a R u x z y + have htar : {y : V | f y=j}={y | G.adjustedLayerIndex a R v z y=j-f z} := by + ext y + change f y=j ↔ G.adjustedLayerIndex a R v z y=j-f z + rw [hidx] + omega + rw [htar] + exact G.adjustedFullLayerMoment_le_sup a R p _ z v + have hrow (i : ℤ) : (∑' z, if f z=i then T z else 0) ≤ G.supAdjustedFullLayerMoment a R p i := by + apply le_trans _ (G.adjustedFullLayerMoment_le_sup a R p i x u) + rw [adjustedFullLayerMoment] + change _ ≤ ∫⁻ ω, restrictedLayerCount G.ends Set.univ {y | f y=i} ω x ∂Percolation.law p + rw [lintegral_restrictedLayerCount] + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z=i <;> + simp only [Set.mem_ofPred_eq,hz,ite_true,ite_false,T,law,Percolation.law,le_refl] + calc + _ ≤ ∑' z, T z * + (∫⁻ ω, restrictedLayerCount G.ends Set.univ {y | f y=k} ω z ∂G.law p) * + (∫⁻ ω, restrictedLayerCount G.ends Set.univ {y | f y=l} ω z ∂G.law p) := + restricted_layer_second_moment G.ends Set.univ _ _ p x + _ ≤ ∑' z, T z*G.supAdjustedFullLayerMoment a R p (k-f z)* + G.supAdjustedFullLayerMoment a R p (l-f z) := by + apply ENNReal.tsum_le_tsum + intro z + exact mul_le_mul' (mul_le_mul' le_rfl (hcont z k)) (hcont z l) + _ ≤ ∑' z, ∑' i : ℤ, if f z=i then + T z*G.supAdjustedFullLayerMoment a R p (k-i)*G.supAdjustedFullLayerMoment a R p (l-i) + else 0 := by + apply ENNReal.tsum_le_tsum + intro z + have ht := ENNReal.le_tsum (f := fun i : ℤ => if f z=i then + T z*G.supAdjustedFullLayerMoment a R p (k-i)*G.supAdjustedFullLayerMoment a R p (l-i) + else 0) (f z) + rwa [ite_eq_left (rfl : f z=f z)] at ht + _ = ∑' i : ℤ, (∑' z, if f z=i then T z else 0)* + G.supAdjustedFullLayerMoment a R p (k-i)*G.supAdjustedFullLayerMoment a R p (l-i) := by + rw [ENNReal.tsum_comm] + apply tsum_congr + intro i + rw [←ENNReal.tsum_mul_right,←ENNReal.tsum_mul_right] + apply tsum_congr + intro z + by_cases hz : f z=i <;> simp only [hz,ite_true,ite_false,zero_mul] + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro i + exact mul_le_mul' (mul_le_mul' (hrow i) le_rfl) le_rfl + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/Main.lean b/lean/OAI/Probability/BenjaminiSchramm/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..757d37a3c3ac4958abd38adb2a643faf6189c708 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/Main.lean @@ -0,0 +1,31 @@ +import OAI.Probability.BenjaminiSchramm.UnconditionalInputs + +namespace OAI + +namespace Percolation.BenjaminiSchramm +universe u v +variable {V : Type u} {E : Type v} [Infinite V] + +theorem full_main + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hh : 0 < hV G) : MainConclusion G := + main_conditional G hc hl hq hh (subdivision_gap_input_proved G hc hl hq hh) + +theorem critical_laws + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hh : 0 < hV G) : CriticalLawsConclusion G := + (full_application_gap G hc hl hq hh (subdivision_gap_input_proved G hc hl hq hh)).2 + +theorem full_main_and_critical_laws + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hh : 0 < hV G) : MainConclusion G ∧ CriticalLawsConclusion G := + ⟨full_main G hc hl hq hh,critical_laws G hc hl hq hh⟩ + +theorem critical_bounded_unconditional + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hh : 0 < hV G) : OperatorBounded G (pc G) := + critical_bounded_conditional G hc hl hq hh (subdivision_gap_input_proved G hc hl hq hh) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/MeanFieldReduction.lean b/lean/OAI/Probability/BenjaminiSchramm/MeanFieldReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..05bdb9083413b1f3368d0054e78b75c149feccb3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/MeanFieldReduction.lean @@ -0,0 +1,64 @@ +import OAI.Probability.BenjaminiSchramm.ProbabilityUpper + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem probabilityLaw_of_critical_volume [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hpc1 : (pc G : ℝ) < 1) + (hvol : ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + PercolationProbabilityLaw G := by + obtain ⟨A,η,hA,hη,hupper⟩ := percolationProbability_upper_of_critical_volume + G hloc hqt hpc1 hvol + intro x + obtain ⟨c,hc,hlower⟩ := percolationProbability_linear_lower G hconn hloc hqt x + let δ : ℝ := min η ((1-pc G)/2) + have hδ : 0 < δ := lt_min hη (by positivity) + refine ⟨c,A,δ,hc,hA,hδ,fun p hp hnear => ?_⟩ + have hnearη : (p : ℝ) - pc G < η := hnear.trans_le (min_le_left _ _) + have hp1 : p < 1 := by + have hh := hnear.trans_le (min_le_right η ((1-pc G)/2)) + change (p : ℝ) < 1 + linarith + exact ⟨hlower p hp hp1,hupper p hp hnearη x⟩ + +theorem probabilityLaw_of_publishedVolume [Infinite V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hvolume : HutchcroftCriticalVolumeInput G) (hgap : pc G < ptwo G) : + PercolationProbabilityLaw G := by + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + have hp1 : pc G < 1 := hgap.trans_le (ptwo G).2.2 + have hfin := critical_finite_general G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hp1 + apply probabilityLaw_of_critical_volume G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hp1 + intro x + have hh := hvolume hgraph hgap x + rwa [criticalFiniteTail_eq G (volumeEvent G) x (hfin x)] at hh + +theorem full_application_volume_radii [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) + (hvolume : HutchcroftCriticalVolumeInput (subdivision G)) + (hradii : HutchcroftCriticalRadiiInput (subdivision G)) : + MainConclusion G ∧ CriticalLawsConclusion G := by + have hmH := mainConclusion_of_critical_bounded (subdivision G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) + (subdivision_quasiTransitive G hloc hqt) + (critical_subdivision_bounded_conditional G hconn hloc hqt hh hutchcroft2019) + apply full_application_reduced G hconn hloc hqt hh hutchcroft2019 + (fun hgraph _ => probabilityLaw_of_publishedVolume (subdivision G) hgraph hvolume hmH.2.2.1) + hvolume hradii + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/MinimumHeightHit.lean b/lean/OAI/Probability/BenjaminiSchramm/MinimumHeightHit.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cd93d25400c5694d7d3affbce831c8c382f9e5d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/MinimumHeightHit.lean @@ -0,0 +1,113 @@ +import OAI.Probability.BenjaminiSchramm.SlabLastMaximum +import OAI.Probability.BenjaminiSchramm.NormalizedHalfspace + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restrictedHit_upper (I : Set E) (x : V) (A : Set V) : + IsUpperSet (restrictedHit G I x A) := by + rintro ω η hωη ⟨y,hy,hxy⟩ + exact ⟨y,hy,conn_mono G (Set.inter_subset_inter_left _ hωη) hxy⟩ + +lemma restrictedHit_finiteWitness (I : Set E) (x : V) (A : Set V) : + FiniteWitness (restrictedHit G I x A) := by + rintro ω ⟨y,hy,hxy⟩ + obtain ⟨s,hs,hconn⟩ := finiteWitness_conn G x y _ hxy + refine ⟨s,fun e he => (hs he).1,y,hy,?_⟩ + exact conn_mono G (show (s : Set E) ⊆ (s : Set E) ∩ I from fun e he => ⟨he,(hs he).2⟩) hconn + +lemma unrestricted_hit_minimum_disjoint (f : V → ℝ) (x : V) (A : Set V) + (ω : Set E) (hω : ω ∈ restrictedHit G Set.univ x A) : + ∃ z, f z ≤ f x ∧ ω ∈ DisjointOccurrence {η | Conn G η x z} + (restrictedHit G (internalEdges G {v | f z ≤ f v}) z A) := by + obtain ⟨y,hy,hxy⟩ := hω + obtain ⟨z,hzx,_hzy,s,t,hs,ht,hd,hxs,hyt⟩ := + conn_max_height_disjoint G (fun v => -f v) Set.univ ω x y hxy + have hD : {v : V | -f v ≤ -f z}={v | f z ≤ f v} := by ext v; simp + rw [Set.univ_inter,hD] at hxs hyt + refine ⟨z,neg_le_neg_iff.mp hzx,s,t,hs,ht,hd,conn_mono G Set.inter_subset_left hxs,y,hy,hyt⟩ + +theorem unrestricted_hit_minimum_bound [Countable V] [Countable E] + (f : V → ℝ) (p : unitInterval) (x : V) (A : Set V) : + law p (restrictedHit G Set.univ x A) ≤ + ∑' z, if f z ≤ f x then law p {ω | Conn G ω x z} * + law p (restrictedHit G (internalEdges G {v | f z ≤ f v}) z A) else 0 := by + let B (z : V) := restrictedHit G (internalEdges G {v | f z ≤ f v}) z A + let D (z : V) := if f z ≤ f x then DisjointOccurrence {ω | Conn G ω x z} (B z) else ∅ + have hs : restrictedHit G Set.univ x A ⊆ ⋃ z, D z := by + intro ω hω + obtain ⟨z,hz,hdis⟩ := unrestricted_hit_minimum_disjoint G f x A ω hω + exact Set.mem_iUnion.mpr ⟨z,by simpa only [D,ite_eq_left hz] using hdis⟩ + calc + _ ≤ law p (⋃ z, D z) := measure_mono hs + _ ≤ ∑' z, law p (D z) := measure_iUnion_le _ + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z ≤ f x + · simp only [D,ite_eq_left hz] + exact bk_ennreal p _ _ (fun _ _ h hc => conn_mono G h hc) + (restrictedHit_upper G _ _ _) (finiteWitness_conn G x z) + (restrictedHit_finiteWitness G _ _ _) + · simp only [D,ite_eq_right hz,measure_empty,le_refl] + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem unrestricted_adjusted_upward_hit_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (p : unitInterval) (C κ : ℝ≥0∞) + (hrow : ∀ z, (∑' y, G.law p {ω | Percolation.Conn G.ends ω z y}) ≤ C) + (t : ℝ) (hκ : ∀ z, G.law p (G.adjustedHalfspaceHit a z 0 t) ≤ κ) (x : V) : + G.law p (restrictedHit G.ends Set.univ x {v | t ≤ G.orbitAdjustedHeight a x v}) ≤ C*κ := by + let f := G.orbitAdjustedHeight a x + let A := {v | t ≤ f v} + have hcont (z : V) (hz : f z ≤ f x) : + G.law p (restrictedHit G.ends (Percolation.internalEdges G.ends {v | f z ≤ f v}) z A) ≤ κ := by + apply le_trans (measure_mono ?_) (hκ z) + rintro ω ⟨y,hy,hzy⟩ + have hz0 : f z ≤ 0 := by simpa only [f,G.orbitAdjustedHeight_self] using hz + have hdom : {v : V | f z ≤ f v} ⊆ {v | 0 ≤ G.orbitAdjustedHeight a z v} := by + intro v hv + change 0 ≤ G.orbitAdjustedHeight a z v + have hh := G.orbitAdjustedHeight_change_base hc hl a x z v + change f z ≤ f v at hv + dsimp only [f] at hv + linarith + refine ⟨y,?_,Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends hdom)) hzy⟩ + change t ≤ G.orbitAdjustedHeight a z y + have hh := G.orbitAdjustedHeight_change_base hc hl a x z y + change t ≤ f y at hy + dsimp only [f] at hy hz0 + linarith + calc + _ ≤ ∑' z, if f z ≤ f x then G.law p {ω | Percolation.Conn G.ends ω x z} * + G.law p (restrictedHit G.ends (Percolation.internalEdges G.ends {v | f z ≤ f v}) z A) else 0 := + unrestricted_hit_minimum_bound G.ends f p x A + _ ≤ ∑' z, G.law p {ω | Percolation.Conn G.ends ω x z}*κ := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z ≤ f x + · rw [ite_eq_left hz] + exact mul_le_mul' le_rfl (hcont z hz) + · rw [ite_eq_right hz] + exact bot_le + _ ≤ C*κ := by + rw [ENNReal.tsum_mul_right] + exact mul_le_mul' (hrow x) le_rfl + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/MixedHeightMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/MixedHeightMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bb1a452b0a1f0def5792cb2c14d3a9a95ba7083 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/MixedHeightMoment.lean @@ -0,0 +1,150 @@ +import OAI.Probability.BenjaminiSchramm.MixedRootPathComparison +import OAI.Probability.BenjaminiSchramm.PeakHalfspaceTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] [Countable E] in +lemma connectionAvoidingHit_mono (D D' J J' : Set E) (T T' : Set V) + (hD : D' ⊆ D) (hJ : J ⊆ J') (hT : T' ⊆ T) (x y : V) : + connectionAvoidingHit G D J x y T ⊆ connectionAvoidingHit G D' J' x y T' := by + rintro ω ⟨hxy,havoid⟩ + refine ⟨conn_mono G (Set.inter_subset_inter_right _ hJ) hxy,?_⟩ + rintro ⟨z,hz,hxz⟩ + exact havoid ⟨z,hT hz,conn_mono G (Set.inter_subset_inter_right _ hD) hxz⟩ + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def mixedHeightLayerMoment (a : V → ℝ) (p : unitInterval) + (d c l u ad t : ℝ) (x : V) : ℝ≥0∞ := + ∑' y, if l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u then + G.law p (connectionAvoidingHit G.ends + (Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a x z}) + (Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) + x y {z | t ≤ G.orbitAdjustedHeight a x z}) else 0 + +omit [Countable V] [Countable E] in +lemma mixedHeight_connection_event_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (d c ad t : ℝ) (φ : G.Aut) (ω : Set E) (x y : V) : + φ.edge '' ω ∈ connectionAvoidingHit G.ends + (Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a (φ.vertex x) z}) + (Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a (φ.vertex x) z ∧ + G.orbitAdjustedHeight a (φ.vertex x) z ≤ c}) + (φ.vertex x) (φ.vertex y) {z | t ≤ G.orbitAdjustedHeight a (φ.vertex x) z} ↔ + ω ∈ connectionAvoidingHit G.ends + (Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a x z}) + (Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) + x y {z | t ≤ G.orbitAdjustedHeight a x z} := by + have hmask : φ.edge ⁻¹' (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a (φ.vertex x) z ∧ G.orbitAdjustedHeight a (φ.vertex x) z ≤ c}) = + ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c} := by + have hD : φ.vertex ⁻¹' {z | d ≤ G.orbitAdjustedHeight a (φ.vertex x) z ∧ + G.orbitAdjustedHeight a (φ.vertex x) z ≤ c} = + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c} := by + ext z + simp only [Set.mem_preimage,Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] + rw [Set.preimage_inter,Set.preimage_image_eq _ φ.edge.injective, + ←Percolation.internalEdges_aut_preimage G.ends φ.preserves,hD] + have hconn : Percolation.Conn G.ends (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a (φ.vertex x) z ∧ G.orbitAdjustedHeight a (φ.vertex x) z ≤ c}) + (φ.vertex x) (φ.vertex y) ↔ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) x y := by + rw [←Percolation.conn_aut_iff G.ends φ.preserves,hmask] + have hhit : φ.edge '' ω ∈ restrictedHit G.ends + (Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a (φ.vertex x) z}) + (φ.vertex x) {z | t ≤ G.orbitAdjustedHeight a (φ.vertex x) z} ↔ + ω ∈ restrictedHit G.ends + (Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a x z}) + x {z | t ≤ G.orbitAdjustedHeight a x z} := by + constructor + · rintro ⟨z,hz,hxz⟩ + obtain ⟨w,rfl⟩ := φ.vertex.surjective z + refine ⟨w,?_,(G.adjustedHalfspaceConn_aut a ha ad φ ω x x w).mp hxz⟩ + simpa only [Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] using hz + · rintro ⟨z,hz,hxz⟩ + refine ⟨φ.vertex z,?_,(G.adjustedHalfspaceConn_aut a ha ad φ ω x x z).mpr hxz⟩ + simpa only [Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] using hz + exact and_congr hconn (not_congr hhit) + +lemma mixedHeightLayerMoment_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (p : unitInterval) (d c l u ad t : ℝ) (φ : G.Aut) (x : V) : + G.mixedHeightLayerMoment a p d c l u ad t (φ.vertex x) = + G.mixedHeightLayerMoment a p d c l u ad t x := by + unfold mixedHeightLayerMoment + rw [←φ.vertex.tsum_eq] + apply tsum_congr + intro y + simp only [G.orbitAdjustedHeight_aut a ha] + split_ifs + · conv_lhs => rw [←G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + (measurableSet_connectionAvoidingHit G.ends _ _ _ _ _)] + congr 1 + ext ω + exact G.mixedHeight_connection_event_aut a ha d c ad t φ ω x y + · rfl + +omit [Countable V] [Countable E] in +lemma mixedHeightLayerMoment_le_continuation + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (p : unitInterval) (R M k r ell : ℝ) (hR : 0 ≤ R) (_hM : 0 ≤ M) + (x v : V) + (hlo : -ell-R-M ≤ G.orbitAdjustedHeight a x v) + (hhi : G.orbitAdjustedHeight a x v ≤ -ell-R) : + G.mixedHeightLayerMoment a p (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v ≤ + ∑' w, if -ell-k-M-2*R ≤ G.orbitAdjustedHeight a x w ∧ + G.orbitAdjustedHeight a x w ≤ -ell-k then + G.law p (connectionAvoidingHit G.ends + (Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z}) + (Percolation.internalEdges G.ends {z | -ell-k-r-R-M ≤ G.orbitAdjustedHeight a x z ∧ + G.orbitAdjustedHeight a x z ≤ -ell}) + v w {z | z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z}) else 0 := by + apply ENNReal.tsum_le_tsum + intro w + by_cases hw : -k-R ≤ G.orbitAdjustedHeight a v w ∧ G.orbitAdjustedHeight a v w ≤ -k+R + · have hw' : -ell-k-M-2*R ≤ G.orbitAdjustedHeight a x w ∧ + G.orbitAdjustedHeight a x w ≤ -ell-k := by + rw [G.orbitAdjustedHeight_change_base hc hl a x v w] + constructor <;> linarith [hw.1,hw.2] + simp only [hw,hw'] + apply measure_mono + apply connectionAvoidingHit_mono G.ends + · apply Percolation.internalEdges_mono G.ends + intro z hz + change -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z at hz + change -k-r-2*M-2*R ≤ G.orbitAdjustedHeight a v z + rw [G.orbitAdjustedHeight_change_base hc hl a x v z] at hz + linarith + · apply Percolation.internalEdges_mono G.ends + intro z hz + change -k-r ≤ G.orbitAdjustedHeight a v z ∧ G.orbitAdjustedHeight a v z ≤ 0 at hz + change -ell-k-r-R-M ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ -ell + rw [G.orbitAdjustedHeight_change_base hc hl a x v z] + constructor <;> linarith [hz.1,hz.2] + · intro z hz + change z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z at hz + change ell ≤ G.orbitAdjustedHeight a v z + rw [G.orbitAdjustedHeight_change_base hc hl a x v z] at hz + linarith [hz.2] + · simp only [hw,ite_false] + exact bot_le + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/MixedRootPathComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/MixedRootPathComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c305930c2b970b2f1a386c774d4f014675a81272 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/MixedRootPathComparison.lean @@ -0,0 +1,87 @@ +import OAI.Probability.BenjaminiSchramm.MixedRootSurgery + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] [Countable E] in +lemma walk_internal_restriction {x y : V} (q : (openSimpleGraph G Set.univ).Walk x y) + (P : Set V) (hP : ∀ v ∈ q.support, v ∈ P) : + ∃ q' : (openSimpleGraph G (internalEdges G P)).Walk x y, + q'.length=q.length ∧ q'.support=q.support := by + induction q with + | nil => exact ⟨.nil,rfl,rfl⟩ + | @cons x z y hxy q ih => + have htail : ∀ v ∈ q.support, v ∈ P := + fun v hv => hP v (List.mem_cons_of_mem x hv) + obtain ⟨q',hlen,hsupp⟩ := ih htail + obtain ⟨e,he,heq⟩ := hxy.2 + have heP : e ∈ internalEdges G P := by + intro v hv + rw [heq] at hv + rcases Sym2.mem_iff.mp hv with hv | hv + · subst v + exact hP x (SimpleGraph.Walk.start_mem_support (.cons hxy q)) + · subst v + exact hP z (List.mem_cons_of_mem x q.start_mem_support) + refine ⟨.cons ⟨hxy.1,e,heP,heq⟩ q',?_,?_⟩ + · change q'.length+1=q.length+1 + rw [hlen] + · change x::q'.support=x::q.support + rw [hsupp] + +theorem mixed_root_walk_probability (hl : LocallyFinite G) (d : ℕ) + (hd : ∀ z, degree G z ≤ d) (p : unitInterval) (D J : Set E) (hJD : J ⊆ D) + (T : Set V) (u v w : V) (q : (openSimpleGraph G J).Walk u v) + (hT : ∀ z ∈ q.support, z ∉ T) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(q.length+1)))* + law p (connectionAvoidingHit G D J v w T) ≤ law p (connectionAvoidingHit G D J u w T) := by + let P := q.support.toFinset + obtain ⟨l,hlift,hends,hopen⟩ := walk_lift_bonds G J q + let γ : Set E := (l.toFinset : Set E) + have hγJ : γ ⊆ J := fun e he => hopen e (List.mem_toFinset.mp he) + have hγP : γ ⊆ internalEdges G (P : Set V) := by + intro e he z hze + exact List.mem_toFinset.mpr (SimpleGraph.Walk.mem_support_of_mem_edges + (hends ▸ List.mem_map_of_mem (List.mem_toFinset.mp he)) hze) + have hPT : Disjoint (P : Set V) T := Set.disjoint_left.mpr + fun z hz hzT => hT z (List.mem_toFinset.mp hz) hzT + have hcard : (incidentSupport G hl P).card ≤ d*(q.length+1) := by + calc + _ ≤ P.card*d := incidentSupport_card_le G hl d hd P + _ ≤ (q.length+1)*d := Nat.mul_le_mul_right d + ((List.toFinset_card_le q.support).trans_eq q.length_support) + _ = _ := by ring + have hδ : 0 ≤ min (p : ℝ) (1-p) := le_min p.2.1 (sub_nonneg.mpr p.2.2) + have hδ1 : min (p : ℝ) (1-p) ≤ 1 := (min_le_left _ _).trans p.2.2 + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal + (pow_le_pow_of_le_one hδ hδ1 hcard)) le_rfl).trans + (mixed_root_connection_probability G hl p D J γ P T hJD hγJ hγP hPT u v w + (List.mem_toFinset.mpr q.start_mem_support) (hlift.conn (fun e he => List.mem_toFinset.mpr he))) + +theorem mixed_root_walk_layer_moment (hl : LocallyFinite G) (d : ℕ) + (hd : ∀ z, degree G z ≤ d) (p : unitInterval) (D J : Set E) (hJD : J ⊆ D) + (T W : Set V) (u v : V) (q : (openSimpleGraph G J).Walk u v) + (hT : ∀ z ∈ q.support, z ∉ T) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(q.length+1)))* + (∑' w, if w ∈ W then law p (connectionAvoidingHit G D J v w T) else 0) ≤ + ∑' w, if w ∈ W then law p (connectionAvoidingHit G D J u w T) else 0 := by + rw [←ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro w + by_cases hw : w ∈ W + · simp only [hw,ite_true] + exact mixed_root_walk_probability G hl d hd p D J hJD T u v w q hT + · simp only [hw,ite_false,mul_zero] + exact le_rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/MixedRootSurgery.lean b/lean/OAI/Probability/BenjaminiSchramm/MixedRootSurgery.lean new file mode 100644 index 0000000000000000000000000000000000000000..425cfed9d78bbeff42997a0f1fb5cf6183048f78 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/MixedRootSurgery.lean @@ -0,0 +1,94 @@ +import OAI.Probability.BenjaminiSchramm.FiniteEnergyModification +import OAI.Probability.BenjaminiSchramm.PeakExposureComparison +import OAI.Probability.BenjaminiSchramm.PeakSurgeryGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma mixed_root_surgery (D J γ : Set E) (P T : Set V) + (hJD : J ⊆ D) (hγJ : γ ⊆ J) (hγP : γ ⊆ internalEdges G P) + (hPT : Disjoint P T) (u v w : V) (huP : u ∈ P) (hγuv : Conn G γ u v) + (ω : Set E) (hvw : Conn G (ω ∩ J) v w) + (havoid : ω ∉ restrictedHit G D v T) : + ∃ η : Set E, η ∈ connectionAvoidingHit G D J u w T ∧ + ∀ e ∉ ballIncidentEdges G P, (e ∈ ω)=(e ∈ η) := by + let S := cluster G (ω ∩ D) v + let Q := ballIncidentEdges G (P \ S) + let η := (ω \ Q) ∪ γ + have hvS : v ∈ S := mem_cluster_self G _ v + have hST : Disjoint S T := by + apply Set.disjoint_left.mpr + intro z hz hzT + exact havoid ⟨z,hzT,hz⟩ + have hkeep : (ω ∩ J) ∩ internalEdges G S ⊆ η ∩ J := by + rintro e ⟨⟨he,heJ⟩,heS⟩ + refine ⟨Or.inl ⟨he,?_⟩,heJ⟩ + rintro ⟨z,⟨_,hzS⟩,hze⟩ + exact hzS (heS z hze) + have hvw' : Conn G (η ∩ J) v w := by + have hh := conn_restrict_cluster_of_subset G (ω ∩ D) v + (Set.inter_subset_inter_right _ hJD) (mem_cluster_self G _ v) hvw + exact conn_mono G hkeep hh + have hγsub : γ ⊆ η ∩ J := fun e he => ⟨Or.inr he,hγJ he⟩ + have huv : Conn G (η ∩ J) u v := conn_mono G hγsub hγuv + have hclosed : ∀ e ∈ η ∩ D, ∀ z ∈ G e, z ∈ S ∪ P → ∀ z' ∈ G e, z' ∈ S ∪ P := by + intro e he z hze hz z' hz'e + rcases he.1 with heω | heγ + · rcases hz with hzS | hzP + · by_cases hzz' : z=z' + · exact Or.inl (hzz' ▸ hzS) + · have heq : G e=s(z,z') := (Sym2.mem_and_mem_iff hzz').mp ⟨hze,hz'e⟩ + exact Or.inl ((edge_cluster_sides G (ω ∩ D) v ⟨heω.1,he.2⟩ heq).mp hzS) + · by_cases hzS : z ∈ S + · by_cases hzz' : z=z' + · exact Or.inl (hzz' ▸ hzS) + · have heq : G e=s(z,z') := (Sym2.mem_and_mem_iff hzz').mp ⟨hze,hz'e⟩ + exact Or.inl ((edge_cluster_sides G (ω ∩ D) v ⟨heω.1,he.2⟩ heq).mp hzS) + · exact (heω.2 ⟨z,⟨hzP,hzS⟩,hze⟩).elim + · exact Or.inr (hγP heγ z' hz'e) + have hηavoid : η ∉ restrictedHit G D u T := by + rintro ⟨z,hzT,huz⟩ + have hz := conn_mem_of_open_closed G (η ∩ D) (S ∪ P) u (Or.inr huP) hclosed z huz + rcases hz with hzS | hzP + · exact Set.disjoint_left.mp hST hzS hzT + · exact Set.disjoint_left.mp hPT hzP hzT + refine ⟨η,⟨huv.trans hvw',hηavoid⟩,?_⟩ + intro e heP + have heQ : e ∉ Q := fun ⟨z,hz,hze⟩ => heP ⟨z,hz.1,hze⟩ + have heγ : e ∉ γ := by + intro he + exact heP ⟨(G e).out.1,hγP he _ (Sym2.out_fst_mem _),Sym2.out_fst_mem _⟩ + apply propext + change e ∈ ω ↔ (e ∈ ω ∧ e ∉ Q) ∨ e ∈ γ + constructor + · intro he + exact Or.inl ⟨he,heQ⟩ + · rintro (⟨he,_⟩ | he) + · exact he + · exact (heγ he).elim + +theorem mixed_root_connection_probability [Countable V] [Countable E] + (hl : LocallyFinite G) (p : unitInterval) (D J γ : Set E) (P : Finset V) (T : Set V) + (hJD : J ⊆ D) (hγJ : γ ⊆ J) (hγP : γ ⊆ internalEdges G (P : Set V)) + (hPT : Disjoint (P : Set V) T) (u v w : V) (huP : u ∈ P) (hγuv : Conn G γ u v) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^(incidentSupport G hl P).card)* + law p (connectionAvoidingHit G D J v w T) ≤ law p (connectionAvoidingHit G D J u w T) := by + apply finite_energy_modification_bound p (incidentSupport G hl P) _ _ + (measurableSet_connectionAvoidingHit G D J u w T) + rintro ω ⟨hvw,havoid⟩ + obtain ⟨η,hη,hagree⟩ := mixed_root_surgery G D J γ (P : Set V) T hJD hγJ hγP hPT + u v w huP hγuv ω hvw havoid + refine ⟨η,hη,fun e he => hagree e ?_⟩ + exact fun hh => he ((mem_incidentSupport G hl P e).mpr hh) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ModularCrossingRate.lean b/lean/OAI/Probability/BenjaminiSchramm/ModularCrossingRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..4907b0a43d1c84da86679675c7fe7b626d894f3b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ModularCrossingRate.lean @@ -0,0 +1,169 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceConcatenation +import OAI.Probability.CriticalPercolation.ProductMeasure.FiniteOpenWitness + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace Percolation.BenjaminiSchramm + +lemma supermultiplicative_exp_bound (P : ℝ → ℝ) (hP : ∀ t, 0 ≤ P t) + (hzero : P 0 = 1) (hmul : ∀ s t, 0 ≤ s → 0 ≤ t → P s * P t ≤ P (s+t)) + (C : ℝ) (hbound : ∀ t, 0 ≤ t → P t ≤ C * Real.exp (-t)) + (t : ℝ) (ht : 0 ≤ t) : P t ≤ Real.exp (-t) := by + have hpow (n : ℕ) : P t ^ n ≤ P ((n : ℝ)*t) := by + induction n with + | zero => simp only [pow_zero,Nat.cast_zero,zero_mul,hzero,le_refl] + | succ n ih => + calc + _ = P t ^ n * P t := pow_succ _ _ + _ ≤ P ((n : ℝ)*t) * P t := mul_le_mul_of_nonneg_right ih (hP t) + _ ≤ P ((n : ℝ)*t+t) := hmul _ _ (mul_nonneg (Nat.cast_nonneg n) ht) ht + _ = _ := by congr 1; push_cast; ring + by_contra hfail + have hlt : Real.exp (-t) < P t := lt_of_not_ge hfail + have hone : 1 < P t * Real.exp t := by + have h := mul_lt_mul_of_pos_right hlt (Real.exp_pos t) + simpa only [← Real.exp_add,neg_add_cancel,Real.exp_zero] using h + obtain ⟨n,hn⟩ := ((tendsto_pow_atTop_atTop_of_one_lt hone).eventually + (eventually_gt_atTop C)).exists + have hb := (hpow n).trans (hbound _ (mul_nonneg (Nat.cast_nonneg n) ht)) + have hm := mul_le_mul_of_nonneg_right hb (pow_nonneg (Real.exp_pos t).le n) + have he : Real.exp (-((n : ℝ)*t)) * Real.exp t ^ n = 1 := by + rw [← Real.exp_nat_mul,← Real.exp_add,neg_add_cancel,Real.exp_zero] + rw [← mul_pow,mul_assoc,he,mul_one] at hm + exact hn.not_ge hm + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma infimalUpwardCrossing_le_one [Nonempty V] (p : unitInterval) (t : ℝ) : + G.infimalUpwardCrossing p t ≤ 1 := + (iInf_le (fun x => G.law p (G.upwardHalfspaceHit x t)) (Classical.arbitrary V)).trans + (prob_le_one) + +lemma upwardHalfspaceHit_hasFiniteOpenWitness (x : V) (t : ℝ) : + BernoulliProduct.HasFiniteOpenWitness (G.upwardHalfspaceHit x t) := by + intro ω hω + obtain ⟨s,hs,hsa⟩ := G.upwardHalfspaceHit_finiteWitness x t ω hω + exact ⟨s,s.finite_toSet,hs,hsa⟩ + +lemma Aut.upwardHalfspaceHit_preimage (φ : G.Aut) (x : V) (t : ℝ) : + (fun ω : Set E => φ.edge '' ω) ⁻¹' G.upwardHalfspaceHit (φ.vertex x) t = + G.upwardHalfspaceHit x t := by + have hD : φ.vertex ⁻¹' {v | 0 ≤ G.modularLogHeight (φ.vertex x) v} = + {v | 0 ≤ G.modularLogHeight x v} := by + ext v + simp only [Set.mem_preimage,Set.mem_ofPred_eq,Aut.modularLogHeight] + ext ω + have hmask : φ.edge ⁻¹' (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {v | 0 ≤ G.modularLogHeight (φ.vertex x) v}) = + ω ∩ Percolation.internalEdges G.ends {v | 0 ≤ G.modularLogHeight x v} := by + rw [Set.preimage_inter,Set.preimage_image_eq _ φ.edge.injective, + ← Percolation.internalEdges_aut_preimage G.ends φ.preserves,hD] + have hconn (y : V) : + Percolation.Conn G.ends (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {v | 0 ≤ G.modularLogHeight (φ.vertex x) v}) (φ.vertex x) (φ.vertex y) ↔ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | 0 ≤ G.modularLogHeight x v}) x y := by + rw [← Percolation.conn_aut_iff G.ends φ.preserves,hmask] + constructor + · rintro ⟨y,hy,hxy⟩ + obtain ⟨z,rfl⟩ := φ.vertex.surjective y + exact ⟨z,by simpa only [Set.mem_ofPred_eq,Aut.modularLogHeight] using hy,(hconn z).mp hxy⟩ + · rintro ⟨y,hy,hxy⟩ + exact ⟨φ.vertex y,by simpa only [Set.mem_ofPred_eq,Aut.modularLogHeight] using hy,(hconn y).mpr hxy⟩ + +lemma Aut.upwardHalfspaceHit_measure [Countable E] (φ : G.Aut) (p : unitInterval) + (x : V) (t : ℝ) : + G.law p (G.upwardHalfspaceHit (φ.vertex x) t) = G.law p (G.upwardHalfspaceHit x t) := by + conv_lhs => rw [← G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + (G.measurableSet_upwardHalfspaceHit _ _),φ.upwardHalfspaceHit_preimage] + +theorem infimalUpwardCrossing_bound_at_limit [Countable E] [Nonempty V] + (hq : G.QuasiTransitive) (p : unitInterval) (hp : 0 < p) (t : ℝ) (b : ℝ) + (hb : 0 ≤ b) + (hbelow : ∀ q : unitInterval, q < p → (G.infimalUpwardCrossing q t).toReal ≤ b) : + (G.infimalUpwardCrossing p t).toReal ≤ b := by + by_contra hn + have hbp : b < (G.infimalUpwardCrossing p t).toReal := lt_of_not_ge hn + let c := (b + (G.infimalUpwardCrossing p t).toReal)/2 + have hbc : b < c := by dsimp [c]; linarith + have hcp : c < (G.infimalUpwardCrossing p t).toReal := by dsimp [c]; linarith + obtain ⟨S,hS,hcover⟩ := hq + let : Finite S := hS.to_subtype + have hroot (x : V) : c < (G.law p).real (G.upwardHalfspaceHit x t) := + hcp.trans_le (ENNReal.toReal_mono (measure_ne_top _ _) + (iInf_le (fun y => G.law p (G.upwardHalfspaceHit y t)) x)) + obtain ⟨q,_hhalf,hqp,hqroot⟩ := BernoulliProduct.exists_lower_parameter + (fun x : S => G.upwardHalfspaceHit x t) (fun x => G.upwardHalfspaceHit_upper x t) + (fun x => G.upwardHalfspaceHit_hasFiniteOpenWitness x t) p hp (fun _ => c) + (fun x => by simpa only [BernoulliProduct.law_const,law] using hroot x) + have hcq : ENNReal.ofReal c ≤ G.infimalUpwardCrossing q t := by + apply le_iInf + intro x + obtain ⟨o,ho,φ,rfl⟩ := hcover x + rw [φ.upwardHalfspaceHit_measure] + have hr := hqroot ⟨o,ho⟩ + rw [BernoulliProduct.law_const] at hr + exact ENNReal.ofReal_le_of_le_toReal hr.le + have hcqr := ENNReal.toReal_mono + (lt_of_le_of_lt (G.infimalUpwardCrossing_le_one q t) (by simp)).ne hcq + rw [ENNReal.toReal_ofReal (hb.trans hbc.le)] at hcqr + exact hbc.not_ge (hcqr.trans (hbelow q hqp)) + +end CriticalPercolation.BondGraph + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nonempty V] (G : BondGraph V E) + +theorem subcritical_infimal_upward_crossing_bound (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (p : unitInterval) (hp : p < pc G) (t : ℝ) (ht : 0 ≤ t) : + ((criticalModel G).infimalUpwardCrossing p t).toReal ≤ Real.exp (-t) := by + let H := criticalModel G + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have hne (a : ℝ) : H.infimalUpwardCrossing p a ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top (H.infimalUpwardCrossing_le_one p a) + obtain ⟨C,_hC,hC⟩ := subcritical_uniform_upward_exponential G hc hl hq p hp + apply supermultiplicative_exp_bound (fun a => (H.infimalUpwardCrossing p a).toReal) + (fun _ => ENNReal.toReal_nonneg) (by simp) ?_ C ?_ t ht + · intro a b ha hb + have h := ENNReal.toReal_mono (hne (a+b)) + (H.infimalUpwardCrossing_supermultiplicative hHc hl hHq p ha hb) + rwa [ENNReal.toReal_mul] at h + · intro a _ha + let x := Classical.arbitrary V + have hhit : H.upwardHalfspaceHit x a ⊆ H.weightHit (ENNReal.ofReal (Real.exp a)) x := by + rintro ω ⟨y,hy,hxy⟩ + refine ⟨y,?_,?_⟩ + · rw [criticalModel_openGraph] + exact (conn_iff_reachable G ω x y).mp (conn_mono G Set.inter_subset_left hxy) + · have he := Real.exp_le_exp.mpr hy + rw [CriticalPercolation.BondGraph.modularLogHeight, + Real.exp_log (H.modularRatio_pos hHc hl y x)] at he + exact ENNReal.ofReal_le_ofReal he + have hroot : (H.infimalUpwardCrossing p a).toReal ≤ + (law p).real (H.upwardHalfspaceHit x a) := + ENNReal.toReal_mono (measure_ne_top _ _) + (iInf_le (fun z => H.law p (H.upwardHalfspaceHit z a)) x) + exact hroot.trans ((measureReal_mono hhit).trans (hC x a)) + +theorem critical_infimal_upward_crossing_bound (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (t : ℝ) (ht : 0 ≤ t) : + ((criticalModel G).infimalUpwardCrossing (pc G) t).toReal ≤ Real.exp (-t) := + (criticalModel G).infimalUpwardCrossing_bound_at_limit (criticalModel_quasiTransitive G hq) + (pc G) (pc_pos G hl hq) t (Real.exp (-t)) (Real.exp_pos _).le + (fun p hp => subcritical_infimal_upward_crossing_bound G hc hl hq p hp t ht) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ModularSchur.lean b/lean/OAI/Probability/BenjaminiSchramm/ModularSchur.lean new file mode 100644 index 0000000000000000000000000000000000000000..adf7ab84908e9a9c0f2cbfdfd26ef18ab718bf8b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ModularSchur.lean @@ -0,0 +1,84 @@ +import OAI.Probability.BenjaminiSchramm.CriticalFiniteness +import OAI.Probability.BenjaminiSchramm.TiltedSusceptibility +import OAI.Probability.BenjaminiSchramm.Nonunimodular + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem criticalModel_connectionMeasure (G : BondGraph V E) (p : unitInterval) (x y : V) : + (criticalModel G).connectionMeasure p x y = ENNReal.ofReal (twoPoint G p x y) := by + unfold CriticalPercolation.BondGraph.connectionMeasure + have he : {ω | ((criticalModel G).openGraph ω).Reachable x y} = + {ω | Conn G ω x y} := by + ext ω + change ((criticalModel G).openGraph ω).Reachable x y ↔ Conn G ω x y + rw [criticalModel_openGraph] + exact (conn_iff_reachable G ω x y).symm + rw [he] + exact (ENNReal.ofReal_toReal (measure_ne_top (law p) _)).symm + +theorem modularSqrtWeight_ratio + (G : CriticalPercolation.BondGraph V E) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (o x y : V) : + Real.sqrt (G.modularRatio y o) / Real.sqrt (G.modularRatio x o) = + Real.sqrt (G.modularRatio y x) := by + rw [← G.modularRatio_cocycle hc hl y x o, + Real.sqrt_mul (G.modularRatio_pos hc hl y x).le] + exact mul_div_cancel_right₀ _ (Real.sqrt_pos.mpr (G.modularRatio_pos hc hl x o)).ne' + +theorem modularSqrtWeight_ratio_ofReal + (G : CriticalPercolation.BondGraph V E) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (o x y : V) : + ENNReal.ofReal (Real.sqrt (G.modularRatio y o) / Real.sqrt (G.modularRatio x o)) = + G.stabilizerWeight x y ^ (1 / 2 : ℝ) := by + rw [modularSqrtWeight_ratio G hc hl, CriticalPercolation.BondGraph.stabilizerWeight, + ENNReal.ofReal_rpow_of_pos (G.modularRatio_pos hc hl y x), ← Real.sqrt_eq_rpow] + +theorem operatorBounded_of_finite_halfTiltedSusceptibility [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) (p : unitInterval) + (C : ℝ≥0∞) (hC : C < ∞) + (hb : ∀ x, (criticalModel G).tiltedSusceptibility p (1 / 2) x ≤ C) : + OperatorBounded G p := by + let H := criticalModel G + have hc := criticalModel_connected G hconn + let o : V := Classical.choice inferInstance + let w (x : V) := Real.sqrt (H.modularRatio x o) + have hw (x : V) : 0 < w x := Real.sqrt_pos.mpr (H.modularRatio_pos hc hloc x o) + apply operatorBounded_of_weighted_susceptibility G p w C.toReal hw ENNReal.toReal_nonneg + intro x s + have ht (y : V) : + ENNReal.ofReal (twoPoint G p x y * w y / w x) = + H.connectionMeasure p x y * H.stabilizerWeight x y ^ (1 / 2 : ℝ) := by + rw [mul_div_assoc, ENNReal.ofReal_mul (twoPoint_nonneg G p x y), + ← criticalModel_connectionMeasure, modularSqrtWeight_ratio_ofReal H hc hloc] + have hn (y : V) : 0 ≤ twoPoint G p x y * w y / w x := + div_nonneg (mul_nonneg (twoPoint_nonneg G p x y) (hw y).le) (hw x).le + have hs : ENNReal.ofReal (∑ y ∈ s, twoPoint G p x y * w y / w x) ≤ C := by + rw [ENNReal.ofReal_sum_of_nonneg (fun y _ => hn y)] + simp_rw [ht] + exact (ENNReal.sum_le_tsum s).trans (hb x) + have hr := ENNReal.toReal_mono hC.ne hs + rwa [ENNReal.toReal_ofReal (Finset.sum_nonneg (fun y _ => hn y))] at hr + +theorem operatorBounded_of_finite_quarterTiltedSusceptibility [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (p : unitInterval) + (hfin : ∀ x ∈ ((criticalModel G).orbitRepresentatives (criticalModel_quasiTransitive G hqt)).roots, + (criticalModel G).tiltedSusceptibility p (1 / 4) x < ∞) : + OperatorBounded G p := by + let : Countable V := countable_vertices hloc hconn + obtain ⟨C,hC,hb⟩ := (criticalModel G).uniform_halfTiltedSusceptibility_of_quarter + (criticalModel_connected G hconn) hloc (criticalModel_quasiTransitive G hqt) p hfin + exact operatorBounded_of_finite_halfTiltedSusceptibility G hconn hloc p C hC hb + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ModularSlabs.lean b/lean/OAI/Probability/BenjaminiSchramm/ModularSlabs.lean new file mode 100644 index 0000000000000000000000000000000000000000..51d0502196386a51c2de2d236dde29e6af1161cb --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ModularSlabs.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.TiltedMomentBridge +import OAI.Probability.CriticalPercolation.Modular.ModularIncidence + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +def modularLogHeight (x y : V) : ℝ := Real.log (G.modularRatio y x) + +def modularSlab (x : V) (a b : ℝ) : Set V := + {y | a ≤ G.modularLogHeight x y ∧ G.modularLogHeight x y ≤ b} + +@[simp] lemma modularLogHeight_self (x : V) : G.modularLogHeight x x = 0 := by + simp only [modularLogHeight,G.modularRatio_self,Real.log_one] + +lemma modularLogHeight_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (x v y : V) : G.modularLogHeight x y = G.modularLogHeight x v + G.modularLogHeight v y := by + unfold modularLogHeight + rw [← Real.log_mul (G.modularRatio_pos hc hl v x).ne' (G.modularRatio_pos hc hl y v).ne'] + congr 1 + rw [mul_comm,G.modularRatio_cocycle hc hl] + +lemma modularLogHeight_reverse (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (x y : V) : G.modularLogHeight y x = -G.modularLogHeight x y := by + have h := G.modularLogHeight_change_base hc hl x y x + rw [G.modularLogHeight_self] at h + linarith + +lemma Aut.modularLogHeight (φ : G.Aut) (x y : V) : + G.modularLogHeight (φ.vertex x) (φ.vertex y) = G.modularLogHeight x y := by + simp only [CriticalPercolation.BondGraph.modularLogHeight,Aut.modularRatio] + +lemma modularSlab_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (x v : V) (a b : ℝ) : G.modularSlab x a b = + G.modularSlab v (a - G.modularLogHeight x v) (b - G.modularLogHeight x v) := by + ext y + change (a ≤ G.modularLogHeight x y ∧ G.modularLogHeight x y ≤ b) ↔ _ + rw [G.modularLogHeight_change_base hc hl x v y] + change (a ≤ G.modularLogHeight x v + G.modularLogHeight v y ∧ + G.modularLogHeight x v + G.modularLogHeight v y ≤ b) ↔ + (a - G.modularLogHeight x v ≤ G.modularLogHeight v y ∧ + G.modularLogHeight v y ≤ b - G.modularLogHeight x v) + constructor <;> rintro ⟨h₁,h₂⟩ <;> constructor <;> linarith + +lemma modularSlab_mono (x : V) {a b a' b' : ℝ} (ha : a' ≤ a) (hb : b ≤ b') : + G.modularSlab x a b ⊆ G.modularSlab x a' b' := + fun _ h => ⟨ha.trans h.1,h.2.trans hb⟩ + +lemma modularLogHeight_eq_log_weight (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (x y : V) : G.modularLogHeight x y = Real.log (G.stabilizerWeight x y).toReal := by + rw [stabilizerWeight,ENNReal.toReal_ofReal (G.modularRatio_pos hc hl y x).le] + rfl + +lemma modularLogHeight_le_log_ball_bound (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (K : ℕ) (hK : ∀ v, (G.vertexBall v 1).ncard ≤ K) (x y : V) + (hxy : y ∈ G.vertexBall x 1) (hyx : x ∈ G.vertexBall y 1) : + G.modularLogHeight x y ≤ Real.log (K : ℝ) := by + rw [G.modularLogHeight_eq_log_weight hc hl] + apply Real.log_le_log (ENNReal.toReal_pos (G.stabilizerWeight_pos hc hl x y).ne' + (G.stabilizerWeight_ne_top x y)) + simpa only [ENNReal.toReal_natCast,ENNReal.coe_toReal,NNReal.coe_natCast] using ENNReal.toReal_mono ENNReal.coe_ne_top + (G.stabilizerWeight_le_ball_bound hc hl K hK hxy hyx) + +lemma modularLogHeight_edge_jump (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (K : ℕ) (hK : ∀ v, (G.vertexBall v 1).ncard ≤ K) (o x y : V) (e : E) + (hx : x ∈ G.ends e) (hy : y ∈ G.ends e) : + |G.modularLogHeight o y - G.modularLogHeight o x| ≤ Real.log (K : ℝ) := by + rw [G.modularLogHeight_change_base hc hl o x y,add_sub_cancel_left,abs_le] + constructor + · have h := G.modularLogHeight_le_log_ball_bound hc hl K hK y x + (G.common_bond_ball_one hy hx) (G.common_bond_ball_one hx hy) + rw [G.modularLogHeight_reverse hc hl] at h + linarith + · exact G.modularLogHeight_le_log_ball_bound hc hl K hK x y + (G.common_bond_ball_one hx hy) (G.common_bond_ball_one hy hx) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NegativeMomentConvolution.lean b/lean/OAI/Probability/BenjaminiSchramm/NegativeMomentConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..de4463e75e095e1f7d00116e8fb9622f23b93995 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NegativeMomentConvolution.lean @@ -0,0 +1,67 @@ +import OAI.Probability.BenjaminiSchramm.UpperMomentConvolution + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma normalized_negative_square_convolution_bound (S : ℕ → ℝ) + (hS : ∀ n, 0 ≤ S n) (β K χ : ℝ) (hβ : 0 < β) (hχ : 0 ≤ χ) + (hbound : ∀ n, S n ≤ χ) (hmul : ∀ n j, S (n+j) ≤ S n*S j) + (hdecay : ∀ n : ℕ, S n ≤ K*Real.exp (-(3*β/4)*n)) : + ∃ D : ℝ, 0 < D ∧ ∀ n : ℕ, + Summable (fun j => (S (n+j))^2) ∧ + (∑' j : ℕ, (S (n+j))^2) ≤ + D*Real.exp (-β*n)*prefixMaximum (fun j => Real.exp (β*j)*S j) n := by + have hgeom : Summable (fun j : ℕ => K^2*Real.exp (-(3*β/2)*j)) := by + apply Summable.mul_left + simpa only [mul_comm] using + (Real.summable_exp_nat_mul_iff.mpr (by linarith : -(3*β/2) < 0)) + have hsqbound (j : ℕ) : (S j)^2 ≤ K^2*Real.exp (-(3*β/2)*j) := by + calc + _ ≤ (K*Real.exp (-(3*β/4)*j))^2 := pow_le_pow_left₀ (hS j) (hdecay j) 2 + _ = _ := by + rw [mul_pow,pow_two (Real.exp _),←Real.exp_add] + congr 2 + ring + have hsq : Summable (fun j : ℕ => (S j)^2) := + hgeom.of_nonneg_of_le (fun j => sq_nonneg _) hsqbound + let B : ℝ := ∑' j : ℕ, (S j)^2 + have hB : 0 ≤ B := tsum_nonneg fun _ => sq_nonneg _ + refine ⟨χ*B+1,by positivity,fun n => ?_⟩ + have hpoint (j : ℕ) : (S (n+j))^2 ≤ (S n)^2*(S j)^2 := by + simpa only [mul_pow] using pow_le_pow_left₀ (hS (n+j)) (hmul n j) 2 + have hnsq : Summable (fun j : ℕ => (S (n+j))^2) := + (hsq.mul_left ((S n)^2)).of_nonneg_of_le (fun _ => sq_nonneg _) hpoint + refine ⟨hnsq,?_⟩ + let H : ℕ → ℝ := fun j => Real.exp (β*j)*S j + let M := prefixMaximum H n + have hM : 0 ≤ M := (mul_nonneg (Real.exp_pos _).le (hS 0)).trans + (le_prefixMaximum H (Nat.zero_le n)) + have he : S n=Real.exp (-β*n)*H n := by + dsimp only [H] + rw [←mul_assoc,←Real.exp_add,show -β*(n : ℝ)+β*n=0 by ring,Real.exp_zero,one_mul] + have hSn : (S n)^2 ≤ χ*Real.exp (-β*n)*M := by + calc + _ = S n*(Real.exp (-β*n)*H n) := by rw [←he]; ring + _ ≤ χ*(Real.exp (-β*n)*M) := + mul_le_mul (hbound n) (mul_le_mul_of_nonneg_left + (le_prefixMaximum H le_rfl) (Real.exp_pos _).le) + (mul_nonneg (Real.exp_pos _).le (mul_nonneg (Real.exp_pos _).le (hS n))) hχ + _ = _ := (mul_assoc _ _ _).symm + calc + _ ≤ ∑' j : ℕ, (S n)^2*(S j)^2 := hnsq.tsum_le_tsum hpoint (hsq.mul_left _) + _ = (S n)^2*B := by rw [hsq.tsum_mul_left] + _ ≤ (χ*Real.exp (-β*n)*M)*B := mul_le_mul_of_nonneg_right hSn hB + _ = (χ*B)*Real.exp (-β*n)*M := by ring + _ ≤ (χ*B+1)*Real.exp (-β*n)*M := by + apply mul_le_mul_of_nonneg_right _ hM + exact mul_le_mul_of_nonneg_right (by linarith) (Real.exp_pos _).le + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NeighborDegreeBound.lean b/lean/OAI/Probability/BenjaminiSchramm/NeighborDegreeBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..9370dbe4c48d7cdd7e5ad55f8aea1df31a7ca6ed --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NeighborDegreeBound.lean @@ -0,0 +1,34 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierLocalization + +namespace OAI + +noncomputable section +open Set +open scoped Classical + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma neighbor_card_le_degree (hl : LocallyFinite G) (x : V) : + (finite_neighbors hl x).toFinset.card ≤ degree G x := by + let f : Step G x → {y // Adj G x y} := fun d => ⟨d.1.2,d.1.1,d.2⟩ + have hf : Function.Surjective f := by + rintro ⟨y,e,he⟩ + exact ⟨⟨(e,y),he⟩,rfl⟩ + let : Fintype (Step G x) := (finite_steps G hl x).fintype + have hh := Nat.card_le_card_of_surjective f hf + have hcard : Nat.card {y // Adj G x y}=(finite_neighbors hl x).toFinset.card := + (Nat.card_coe_set_eq _).trans (Set.ncard_eq_toFinset_card _ (finite_neighbors hl x)) + rw [hcard] at hh + exact hh + +lemma exists_neighbor_card_bound (hl : LocallyFinite G) (hq : QuasiTransitive G) : + ∃ d : ℕ, ∀ x, (finite_neighbors hl x).toFinset.card ≤ d := by + obtain ⟨d,_,hd⟩ := exists_degree_bound G hq + exact ⟨d,fun x => (neighbor_card_le_degree G hl x).trans (hd x)⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/Nonunimodular.lean b/lean/OAI/Probability/BenjaminiSchramm/Nonunimodular.lean new file mode 100644 index 0000000000000000000000000000000000000000..12a927387e4f2f96309ed3a747266e743da4a2a2 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/Nonunimodular.lean @@ -0,0 +1,122 @@ +import OAI.Probability.BenjaminiSchramm.ExponentialDecay + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem exists_operator_of_weighted_schur + (U : V → V → ℝ) (w : V → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hw : ∀ x, 0 < w x) (hU : ∀ x y, 0 ≤ U x y) + (hsym : ∀ x y, U x y = U y x) + (hrow : ∀ x (s : Finset V), ∑ y ∈ s, U x y * w y / w x ≤ C) : + ∃ A : Hilbert V →L[ℂ] Hilbert V, ‖A‖ ≤ C ∧ + ∀ x y, A (lp.single 2 y (1 : ℂ)) x = (U x y : ℂ) := by + have hentry (x y : V) : U x y ≤ C * w y / w x := by + have hh := hrow y {x} + simp only [Finset.sum_singleton, ← hsym x y] at hh + exact (le_div_iff₀ (hw x)).mpr ((div_le_iff₀ (hw y)).mp hh) + have hcol (y : V) (s : Finset V) : ∑ x ∈ s, U x y * w x / w y ≤ C := by + simpa only [hsym] using hrow y s + have hcm (y : V) : Memℓp (fun x => (U x y : ℂ)) 2 := by + apply (memℓp_gen_iff'' (by norm_num : 0 < (2 : ENNReal).toReal)).mpr + refine ⟨C ^ 2, sq_nonneg _, fun s => ?_⟩ + simp only [ENNReal.toReal_ofNat, Real.rpow_two, Complex.norm_real, + Real.norm_eq_abs, sq_abs] + have hs (x : V) : U x y ^ 2 ≤ C * (U x y * w x / w y) := by + have hh := mul_le_mul_of_nonneg_right (hentry y x) (hU x y) + rw [hsym y x] at hh + nlinarith [show C * w x / w y * U x y = C * (U x y * w x / w y) by ring] + calc + ∑ x ∈ s, U x y ^ 2 ≤ ∑ x ∈ s, C * (U x y * w x / w y) := + Finset.sum_le_sum (fun x _ => hs x) + _ = C * ∑ x ∈ s, U x y * w x / w y := by rw [Finset.mul_sum] + _ ≤ C * C := mul_le_mul_of_nonneg_left (hcol y s) hC + _ = C ^ 2 := by ring + let col (y : V) : Hilbert V := ⟨fun x => (U x y : ℂ), hcm y⟩ + let L : (V →₀ ℂ) →ₗ[ℂ] Hilbert V := Finsupp.linearCombination ℂ col + have hn (f : V →₀ ℂ) : ‖L f‖ ≤ C * ‖finiteEmbedding f‖ := by + apply lp.norm_le_of_forall_sum_le (by norm_num) (mul_nonneg hC (norm_nonneg _)) + intro s + simp only [ENNReal.toReal_ofNat, Real.rpow_two] + have hpoint (x : V) : ‖L f x‖ ^ 2 ≤ + C * ∑ y ∈ f.support, ‖f y‖ ^ 2 * (U x y * w x / w y) := by + have hn0 : 0 ≤ ∑ y ∈ f.support, ‖f y‖ * U x y := + Finset.sum_nonneg fun y _ => mul_nonneg (norm_nonneg _) (hU x y) + have hn1 : ‖L f x‖ ≤ ∑ y ∈ f.support, ‖f y‖ * U x y := by + simp only [L, Finsupp.linearCombination_apply, Finsupp.sum, lp.coeFn_sum, + Finset.sum_apply, lp.coeFn_smul, Pi.smul_apply, smul_eq_mul] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro y _ + simp [col, abs_of_nonneg (hU x y)] + have hcs := Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul f.support + (f := fun y => U x y * w y / w x) + (g := fun y => ‖f y‖ ^ 2 * (U x y * w x / w y)) + (r := fun y => ‖f y‖ * U x y) + (fun y _ => div_nonneg (mul_nonneg (hU x y) (hw y).le) (hw x).le) + (fun y _ => mul_nonneg (sq_nonneg _) + (div_nonneg (mul_nonneg (hU x y) (hw x).le) (hw y).le)) + (fun y _ => by + apply le_of_eq + field_simp [(hw x).ne', (hw y).ne'] + ) + exact (sq_le_sq₀ (norm_nonneg _) hn0 |>.mpr hn1).trans + (hcs.trans (mul_le_mul_of_nonneg_right (hrow x f.support) + (Finset.sum_nonneg fun y _ => mul_nonneg (sq_nonneg _) + (div_nonneg (mul_nonneg (hU x y) (hw x).le) (hw y).le)))) + calc + ∑ x ∈ s, ‖L f x‖ ^ 2 ≤ + ∑ x ∈ s, C * ∑ y ∈ f.support, ‖f y‖ ^ 2 * (U x y * w x / w y) := + Finset.sum_le_sum fun x _ => hpoint x + _ = C * ∑ y ∈ f.support, ‖f y‖ ^ 2 * ∑ x ∈ s, U x y * w x / w y := by + rw [← Finset.mul_sum, Finset.sum_comm] + simp_rw [← Finset.mul_sum] + _ ≤ C * ∑ y ∈ f.support, ‖f y‖ ^ 2 * C := by + apply mul_le_mul_of_nonneg_left _ hC + apply Finset.sum_le_sum + intro y _ + exact mul_le_mul_of_nonneg_left (hcol y s) (sq_nonneg _) + _ = C ^ 2 * ∑ y ∈ f.support, ‖finiteEmbedding f y‖ ^ 2 := by + simp only [finiteEmbedding_apply, ← Finset.sum_mul] + ring + _ ≤ C ^ 2 * ‖finiteEmbedding f‖ ^ 2 := by + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + simpa only [ENNReal.toReal_ofNat, Real.rpow_two] using + lp.sum_rpow_le_norm_rpow (by norm_num : 0 < (2 : ENNReal).toReal) + (finiteEmbedding f) f.support + _ = (C * ‖finiteEmbedding f‖) ^ 2 := by ring + refine ⟨L.extendOfNorm finiteEmbedding, + LinearMap.opNorm_extendOfNorm_le finiteEmbedding_dense hC hn, ?_⟩ + intro x y + have he := LinearMap.extendOfNorm_eq (f := L) finiteEmbedding_dense ⟨C, hn⟩ + (Finsupp.single y (1 : ℂ)) + rw [finiteEmbedding_single] at he + rw [he] + simp [L, col] + +theorem operatorBounded_of_weighted_susceptibility + (G : BondGraph V E) (p : unitInterval) (w : V → ℝ) (C : ℝ) + (hw : ∀ x, 0 < w x) (hC : 0 ≤ C) + (hrow : ∀ x (s : Finset V), ∑ y ∈ s, twoPoint G p x y * w y / w x ≤ C) : + OperatorBounded G p := by + obtain ⟨A, _, hA⟩ := exists_operator_of_weighted_schur (twoPoint G p) w C hC hw + (twoPoint_nonneg G p) (twoPoint_symm G p) hrow + exact ⟨A, hA⟩ + +theorem pc_lt_ptwo_of_weighted_susceptibility + (G : BondGraph V E) (q : unitInterval) (hq : pc G < q) + (w : V → ℝ) (C : ℝ) (hw : ∀ x, 0 < w x) (hC : 0 ≤ C) + (hrow : ∀ x (s : Finset V), ∑ y ∈ s, twoPoint G q x y * w y / w x ≤ C) : + pc G < ptwo G := + hq.trans_le (le_sSup (operatorBounded_of_weighted_susceptibility G q w C hw hC hrow)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NonunimodularMomentReduction.lean b/lean/OAI/Probability/BenjaminiSchramm/NonunimodularMomentReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..fba67b118d59a37f13d75bb837c7b8f7c1b0fcb1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NonunimodularMomentReduction.lean @@ -0,0 +1,40 @@ +import OAI.Probability.BenjaminiSchramm.GhostMomentDischarge +import OAI.Probability.BenjaminiSchramm.RadiusInputReduction + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem critical_operator_of_quarter_moments [Infinite V] + (G : BondGraph V E) (hinj : Function.Injective G) + (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hmoment : ∀ x ∈ ((criticalModel G).orbitRepresentatives + (criticalModel_quasiTransitive G hqt)).roots, + (criticalModel G).quarterThreeQuarterMoment (pc G) x < ⊤) : + OperatorBounded G (pc G) := by + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + have hpc1 : (pc G : ℝ) < 1 := pc_lt_one_of_nonamenable G hconn hloc hqt hh + exact operatorBounded_of_finite_quarterTiltedSusceptibility G hconn hloc hqt (pc G) + (finite_quarterSusceptibility_of_moments G hinj (criticalModel_connected G hconn) hloc + (criticalModel_quasiTransitive G hqt) (pc G) hpc1 + (critical_finite_general G hconn hloc hqt hpc1) hmoment) + +theorem strict_gap_of_quarter_moments [Infinite V] + (G : BondGraph V E) (hinj : Function.Injective G) + (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hmoment : ∀ x ∈ ((criticalModel G).orbitRepresentatives + (criticalModel_quasiTransitive G hqt)).roots, + (criticalModel G).quarterThreeQuarterMoment (pc G) x < ⊤) : + pc G < ptwo G := by + exact (mainConclusion_of_critical_bounded G hconn hloc hqt + (critical_operator_of_quarter_moments G hinj hconn hloc hqt hh hmoment)).2.2.1 + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedCrossingRate.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedCrossingRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..9dc9bca2d2f1d427f8fd758be730de819ebe69de --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedCrossingRate.lean @@ -0,0 +1,108 @@ +import OAI.Probability.BenjaminiSchramm.NormalizedHalfspace + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem infimalAdjustedCrossing_bound_at_limit [Countable E] [Nonempty V] + (hq : G.QuasiTransitive) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) + (p : unitInterval) (hp : 0 < p) (t : ℝ) (b : ℝ) (hb : 0 ≤ b) + (hbelow : ∀ q : unitInterval, q < p → (G.infimalAdjustedCrossing a q t).toReal ≤ b) : + (G.infimalAdjustedCrossing a p t).toReal ≤ b := by + by_contra hn + have hbp : b < (G.infimalAdjustedCrossing a p t).toReal := lt_of_not_ge hn + let c := (b+(G.infimalAdjustedCrossing a p t).toReal)/2 + have hbc : b < c := by dsimp [c]; linarith + have hcp : c < (G.infimalAdjustedCrossing a p t).toReal := by dsimp [c]; linarith + obtain ⟨S,hS,hcover⟩ := hq + let : Finite S := hS.to_subtype + have hroot (x : V) : c < (G.law p).real (G.adjustedHalfspaceHit a x 0 t) := + hcp.trans_le (ENNReal.toReal_mono (measure_ne_top _ _) + (iInf_le (fun y => G.law p (G.adjustedHalfspaceHit a y 0 t)) x)) + obtain ⟨q,_hhalf,hqp,hqroot⟩ := BernoulliProduct.exists_lower_parameter + (fun x : S => G.adjustedHalfspaceHit a x 0 t) (fun x => G.adjustedHalfspaceHit_upper a x 0 t) + (fun x => G.adjustedHalfspaceHit_hasFiniteOpenWitness a x 0 t) p hp (fun _ => c) + (fun x => by simpa only [BernoulliProduct.law_const,law] using hroot x) + have hcq : ENNReal.ofReal c ≤ G.infimalAdjustedCrossing a q t := by + apply le_iInf + intro x + obtain ⟨o,ho,φ,rfl⟩ := hcover x + rw [Aut.adjustedHalfspaceHit_measure G a ha φ] + have hr := hqroot ⟨o,ho⟩ + rw [BernoulliProduct.law_const] at hr + exact ENNReal.ofReal_le_of_le_toReal hr.le + have hcqr := ENNReal.toReal_mono + (lt_of_le_of_lt (G.infimalAdjustedCrossing_le_one a q t) (by simp)).ne hcq + rw [ENNReal.toReal_ofReal (hb.trans hbc.le)] at hcqr + exact hbc.not_ge (hcqr.trans (hbelow q hqp)) + +end CriticalPercolation.BondGraph + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nonempty V] (G : BondGraph V E) + +theorem subcritical_infimal_adjusted_crossing_bound (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (a : V → ℝ) (m M : ℝ) (hm : 0 < m) + (ha : ∀ x, m ≤ a x ∧ a x ≤ M) (p : unitInterval) (hp : p < pc G) (t : ℝ) (ht : 0 ≤ t) : + ((criticalModel G).infimalAdjustedCrossing a p t).toReal ≤ Real.exp (-t) := by + let H := criticalModel G + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + have hne (s : ℝ) : H.infimalAdjustedCrossing a p s ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top (H.infimalAdjustedCrossing_le_one a p s) + obtain ⟨C,_hC,hC⟩ := subcritical_uniform_upward_exponential G hc hl hq p hp + let D := Real.log M-Real.log m + apply supermultiplicative_exp_bound (fun s => (H.infimalAdjustedCrossing a p s).toReal) + (fun _ => ENNReal.toReal_nonneg) (by simp) ?_ (C*Real.exp D) ?_ t ht + · intro s u hs hu + have h := ENNReal.toReal_mono (hne (s+u)) + (H.infimalAdjustedCrossing_supermultiplicative hHc hl hHq a m M hm ha p hs hu) + rwa [ENNReal.toReal_mul] at h + · intro s _hs + let x := Classical.arbitrary V + have hhit : H.adjustedHalfspaceHit a x 0 s ⊆ + H.weightHit (ENNReal.ofReal (Real.exp (s-D))) x := by + rintro ω ⟨y,hy,hxy⟩ + refine ⟨y,?_,?_⟩ + · rw [criticalModel_openGraph] + exact (conn_iff_reachable G ω x y).mp (conn_mono G Set.inter_subset_left hxy) + · have hd := (abs_le.mp (H.orbitAdjustedHeight_sub_bound a m M hm ha x y)).2 + have hlo : s-D ≤ H.modularLogHeight x y := by + change s ≤ H.orbitAdjustedHeight a x y at hy + linarith + have he := Real.exp_le_exp.mpr hlo + rw [CriticalPercolation.BondGraph.modularLogHeight, + Real.exp_log (H.modularRatio_pos hHc hl y x)] at he + exact ENNReal.ofReal_le_ofReal he + have hroot : (H.infimalAdjustedCrossing a p s).toReal ≤ + (law p).real (H.adjustedHalfspaceHit a x 0 s) := + ENNReal.toReal_mono (measure_ne_top _ _) + (iInf_le (fun z => H.law p (H.adjustedHalfspaceHit a z 0 s)) x) + have hh := hroot.trans ((measureReal_mono hhit).trans (hC x (s-D))) + have he : C*Real.exp (-(s-D)) = (C*Real.exp D)*Real.exp (-s) := by + rw [mul_assoc,← Real.exp_add] + congr 2 + ring + rwa [he] at hh + +theorem critical_infimal_adjusted_crossing_bound (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (a : V → ℝ) + (hauto : ∀ (φ : (criticalModel G).Aut) x, a (φ.vertex x) = a x) + (m M : ℝ) (hm : 0 < m) (ha : ∀ x, m ≤ a x ∧ a x ≤ M) (t : ℝ) (ht : 0 ≤ t) : + ((criticalModel G).infimalAdjustedCrossing a (pc G) t).toReal ≤ Real.exp (-t) := + (criticalModel G).infimalAdjustedCrossing_bound_at_limit (criticalModel_quasiTransitive G hq) + a hauto (pc G) (pc_pos G hl hq) t (Real.exp (-t)) (Real.exp_pos _).le + (fun p hp => subcritical_infimal_adjusted_crossing_bound G hc hl hq a m M hm ha p hp t ht) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedEscapeRisk.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedEscapeRisk.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad4ae8d59b0d3103944bc6889aed050fe74bdc57 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedEscapeRisk.lean @@ -0,0 +1,61 @@ +import OAI.Probability.BenjaminiSchramm.ExteriorEscape +import OAI.Probability.BenjaminiSchramm.CriticalHeightHit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma adjustedFullHit_upper (a : V → ℝ) (x : V) (t : ℝ) : + IsUpperSet (G.adjustedFullHit a x t) := by + rintro ω η hωη ⟨y,hy,hxy⟩ + refine ⟨y,hy,?_⟩ + rw [G.cluster_eq_percolationCluster] at hxy ⊢ + exact Percolation.conn_mono G.ends hωη hxy + +lemma exteriorEscape_subset_adjustedFullHit + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (S : Set V) (x u : V) (t : ℝ) + (ht : t ≤ -G.orbitAdjustedHeight a x u) : + exteriorEscape G.ends S (G.orbitAdjustedHeight a x) x u ⊆ G.adjustedFullHit a u t := by + rintro η ⟨y,_hy,hheight,_hyS,hconn⟩ + refine ⟨y,?_,?_⟩ + · rw [G.orbitAdjustedHeight_self] at hheight + have hadd := G.orbitAdjustedHeight_change_base hc hl a x u y + linarith + · rw [G.cluster_eq_percolationCluster] + exact Percolation.conn_mono G.ends Set.sdiff_subset hconn + +theorem exteriorEscape_avoidance_profile [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (O : G.OrbitRepresentatives) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (r : E → unitInterval) (p : unitInterval) (hr : ∀ e, r e ≤ p) + (R : ℝ) (n : ℕ) (S : Set V) (x u : V) + (ht : R*n ≤ -G.orbitAdjustedHeight a x u) : + 1-G.rootHeightHitProfile O a R p n ≤ + (BernoulliProduct.law r).real (exteriorEscape G.ends S (G.orbitAdjustedHeight a x) x u)ᶜ := by + let A := exteriorEscape G.ends S (G.orbitAdjustedHeight a x) x u + have hA : MeasurableSet A := measurableSet_exteriorEscape G.ends _ _ x u + have hh := BernoulliProduct.law_mono_pointwise r (fun _ => p) hr + (G.adjustedFullHit a u (R*n)) (G.measurableSet_adjustedFullHit _ _ _) + (G.adjustedFullHit_upper _ _ _) + rw [BernoulliProduct.law_const] at hh + have hμ : BernoulliProduct.law r A ≤ G.law p (G.adjustedFullHit a u (R*n)) := + (measure_mono (G.exteriorEscape_subset_adjustedFullHit hc hl a S x u (R*n) ht)).trans hh + have hreal := (ENNReal.toReal_mono (measure_ne_top _ _) hμ).trans + (G.adjustedFullHit_le_rootProfile O a ha R p n u) + change (BernoulliProduct.law r).real A ≤ G.rootHeightHitProfile O a R p n at hreal + rw [measureReal_compl hA,probReal_univ] + linarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedExponentComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedExponentComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..b01dd0947c737e8fc8b02473d359e9c664c5b94a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedExponentComparison.lean @@ -0,0 +1,196 @@ +import OAI.Probability.BenjaminiSchramm.CrossingExponentContinuity + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace Percolation.BenjaminiSchramm + +lemma supermultiplicative_exp_rate_bound (P : ℝ → ℝ) (hP : ∀ t, 0 ≤ P t) + (hzero : P 0 = 1) (hmul : ∀ s t, 0 ≤ s → 0 ≤ t → P s*P t ≤ P (s+t)) + (β C : ℝ) (hbound : ∀ t, 0 ≤ t → P t ≤ C*Real.exp (-β*t)) + (t : ℝ) (ht : 0 ≤ t) : P t ≤ Real.exp (-β*t) := by + have hpow (n : ℕ) : P t^n ≤ P ((n : ℝ)*t) := by + induction n with + | zero => simp only [pow_zero,Nat.cast_zero,zero_mul,hzero,le_refl] + | succ n ih => + calc + _ = P t^n*P t := pow_succ _ _ + _ ≤ P ((n : ℝ)*t)*P t := mul_le_mul_of_nonneg_right ih (hP t) + _ ≤ P ((n : ℝ)*t+t) := hmul _ _ (mul_nonneg (Nat.cast_nonneg n) ht) ht + _ = _ := by congr 1; push_cast; ring + by_contra hn + have hlt : Real.exp (-β*t) < P t := lt_of_not_ge hn + have hone : 1 < P t*Real.exp (β*t) := by + have hh := mul_lt_mul_of_pos_right hlt (Real.exp_pos (β*t)) + have he : Real.exp (-β*t)*Real.exp (β*t)=1 := by + rw [←Real.exp_add] + ring_nf + exact Real.exp_zero + rwa [he] at hh + obtain ⟨n,hn⟩ := ((tendsto_pow_atTop_atTop_of_one_lt hone).eventually + (eventually_gt_atTop C)).exists + have hh := mul_le_mul_of_nonneg_right + ((hpow n).trans (hbound _ (mul_nonneg (Nat.cast_nonneg n) ht))) + (pow_nonneg (Real.exp_pos (β*t)).le n) + have he : Real.exp (-β*((n : ℝ)*t))*Real.exp (β*t)^n=1 := by + rw [←Real.exp_nat_mul,←Real.exp_add] + ring_nf + exact Real.exp_zero + rw [←mul_pow,mul_assoc,he,mul_one] at hh + exact hn.not_ge hh + +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +omit [Encodable V] in +theorem normalized_halfspace_uniform_of_infimal_bound + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hu : ¬ (criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ = μ) + (p : unitInterval) (hp : 0 < (p : ℝ)) (β : ℝ) + (hbound : ∀ t : ℝ, 0 ≤ t → + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) p t).toReal ≤ Real.exp (-β*t)) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ r : ℝ, 0 ≤ r → ∀ (x : V) (t : ℝ), 0 ≤ t → + (law p).real ((criticalModel G).adjustedHalfspaceHit + ((criticalModel G).stationaryOrbitWeight μ) x (-r) t) ≤ + (p : ℝ)^(-(A*r+B)) * Real.exp (-β*t) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨A,B,hA,hB,hpath⟩ := H.stationaryOrbitHeight_orbit_above hHc hl hHq μ hμ hstat hu + have hauto := H.stationaryOrbitWeight_aut μ + refine ⟨A,B,hA,hB,fun r hr x t ht => ?_⟩ + let α : ℝ := (p : ℝ)^(A*r+B) + have hα : 0 < α := Real.rpow_pos_of_pos hp _ + have hroot (u : V) : + α*(law p).real (H.adjustedHalfspaceHit a x (-r) t) ≤ + (law p).real (H.adjustedHalfspaceHit a u 0 t) := by + obtain ⟨y,w,horb,hlen,hw,hy⟩ := hpath r hr u (H.vertexOrbit x) + obtain ⟨φ,hφ⟩ := MulAction.mem_orbit_iff.mp (Quotient.exact horb) + change φ.vertex x = y at hφ + have hcomp := H.adjustedHalfspaceHit_path_comparison hHc hl a p w r t hr hw hy + have he := CriticalPercolation.BondGraph.Aut.adjustedHalfspaceHit_measure H a hauto φ p x (-r) t + rw [hφ] at he + have her := congrArg ENNReal.toReal he + change (H.law p).real (H.adjustedHalfspaceHit a y (-r) t) = + (H.law p).real (H.adjustedHalfspaceHit a x (-r) t) at her + rw [her] at hcomp + have hcoeff : α ≤ (p : ℝ)^w.length := by + simpa only [Real.rpow_natCast] using + Real.rpow_le_rpow_of_exponent_ge hp p.2.2 hlen + exact (mul_le_mul_of_nonneg_right hcoeff ENNReal.toReal_nonneg).trans hcomp + have hmin : α*(law p).real (H.adjustedHalfspaceHit a x (-r) t) ≤ + (H.infimalAdjustedCrossing a p t).toReal := by + have he : ENNReal.ofReal (α*(law p).real (H.adjustedHalfspaceHit a x (-r) t)) ≤ + H.infimalAdjustedCrossing a p t := by + apply le_iInf + intro u + exact ENNReal.ofReal_le_of_le_toReal (hroot u) + have hf := ENNReal.toReal_mono + (ne_top_of_le_ne_top ENNReal.one_ne_top (H.infimalAdjustedCrossing_le_one a p t)) he + have hnonneg : 0 ≤ α*(law p).real (H.adjustedHalfspaceHit a x (-r) t) := + mul_nonneg hα.le measureReal_nonneg + rwa [ENNReal.toReal_ofReal hnonneg] at hf + have hh := hmin.trans (hbound t ht) + have hh' := mul_le_mul_of_nonneg_left hh (inv_nonneg.mpr hα.le) + rw [← mul_assoc,inv_mul_cancel₀ hα.ne',one_mul] at hh' + have he : α⁻¹ = (p : ℝ)^(-(A*r+B)) := by + exact (Real.rpow_neg p.2.1 _).symm + rwa [he] at hh' + +theorem normalized_crossing_real_bound + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (p : unitInterval) (β : ℝ) (hβ : 0 ≤ β) + (hbound : ∀ n : ℕ, + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) p n).toReal ≤ Real.exp (-β*n)) : + ∀ t : ℝ, 0 ≤ t → ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) p t).toReal ≤ Real.exp (-β*t) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + obtain ⟨m,M,hm,hbounds⟩ := H.stationaryOrbitWeight_uniform_bounds + (criticalModel_connected G hc) hl μ hμ + have hne (t : ℝ) : H.infimalAdjustedCrossing a p t ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.one_ne_top (H.infimalAdjustedCrossing_le_one a p t) + have hmul (s t : ℝ) (hs : 0 ≤ s) (ht : 0 ≤ t) : + (H.infimalAdjustedCrossing a p s).toReal*(H.infimalAdjustedCrossing a p t).toReal ≤ + (H.infimalAdjustedCrossing a p (s+t)).toReal := by + simpa only [ENNReal.toReal_mul] using ENNReal.toReal_mono (hne (s+t)) + (H.infimalAdjustedCrossing_supermultiplicative (criticalModel_connected G hc) hl + (criticalModel_quasiTransitive G hq) a m M hm hbounds p hs ht) + apply supermultiplicative_exp_rate_bound _ (fun _ => ENNReal.toReal_nonneg) + (by simp only [H.infimalAdjustedCrossing_zero,ENNReal.toReal_one]) hmul β (Real.exp β) + intro t ht + have hfloor : (⌊t⌋₊ : ℝ) ≤ t := Nat.floor_le ht + have hmono : H.infimalAdjustedCrossing a p t ≤ H.infimalAdjustedCrossing a p ⌊t⌋₊ := by + apply iInf_mono + intro x + apply measure_mono + rintro ω ⟨y,hy,hxy⟩ + exact ⟨y,hfloor.trans hy,hxy⟩ + calc + _ ≤ (H.infimalAdjustedCrossing a p ⌊t⌋₊).toReal := ENNReal.toReal_mono (hne _) hmono + _ ≤ Real.exp (-β*(⌊t⌋₊ : ℝ)) := hbound _ + _ ≤ Real.exp β*Real.exp (-β*t) := by + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + have hh := Nat.lt_floor_add_one t + nlinarith + +theorem critical_normalized_exponent_ge_one + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) (α : ℝ) + (hpos : ∀ n : ℕ, 0 < ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) n).toReal) + (hlim : Tendsto (fun n : ℕ => -Real.log + ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) n).toReal/n) atTop (𝓝 α)) : + 1 ≤ α := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + obtain ⟨m,M,hm,hbounds⟩ := H.stationaryOrbitWeight_uniform_bounds + (criticalModel_connected G hc) hl μ hμ + apply ge_of_tendsto hlim + filter_upwards [eventually_ge_atTop (1 : ℕ)] with n hn + have hbound := critical_infimal_adjusted_crossing_bound G hc hl hq a + (H.stationaryOrbitWeight_aut μ) m M hm hbounds n (Nat.cast_nonneg n) + have hh := Real.log_le_log (hpos n) hbound + rw [Real.log_exp] at hh + have hnpos : (0 : ℝ) < n := Nat.cast_pos.mpr (by omega) + exact (le_div_iff₀ hnpos).mpr (by nlinarith) + +theorem critical_normalized_exact_exponent + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hu : ¬ (criticalModel G).CombinatoriallyUnimodular) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ = μ) : + ∃ α : ℝ, 1 ≤ α ∧ + (∀ t : ℝ, 0 ≤ t → ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) t).toReal ≤ Real.exp (-α*t)) ∧ + (∀ ε : ℝ, 0 < ε → ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, + c*Real.exp (-(α+ε)*n) ≤ ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) n).toReal) ∧ + Tendsto (fun n : ℕ => -Real.log ((criticalModel G).infimalAdjustedCrossing + ((criticalModel G).stationaryOrbitWeight μ) (pc G) n).toReal/n) atTop (𝓝 α) := by + let H := criticalModel G + have hp : (0 : ℝ) < pc G := by exact_mod_cast pc_pos G hl hq + obtain ⟨A,B,_hA,_hB,hpos⟩ := H.infimalAdjustedCrossing_finite_energy + (criticalModel_connected G hc) hl (criticalModel_quasiTransitive G hq) μ hμ hstat hu (pc G) hp + obtain ⟨α,hα,hupp,hlow,hlim⟩ := H.normalized_crossing_exponent + (criticalModel_connected G hc) hl (criticalModel_quasiTransitive G hq) μ hμ hstat hu (pc G) hp + refine ⟨α,critical_normalized_exponent_ge_one G hc hl hq μ hμ α + (fun n => (Real.rpow_pos_of_pos hp _).trans_le (hpos n (Nat.cast_nonneg n))) hlim, + normalized_crossing_real_bound G hc hl hq μ hμ (pc G) α hα hupp,hlow,hlim⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedHalfspace.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedHalfspace.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f9a50d0c5314491060af7f106e5e04e662943ff --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedHalfspace.lean @@ -0,0 +1,153 @@ +import OAI.Probability.BenjaminiSchramm.ModularCrossingRate +import OAI.Probability.BenjaminiSchramm.HeightOrbitConnection + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def adjustedHalfspaceHit (a : V → ℝ) (x : V) (b t : ℝ) : Set (Set E) := + restrictedHit G.ends (Percolation.internalEdges G.ends {v | b ≤ G.orbitAdjustedHeight a x v}) x + {v | t ≤ G.orbitAdjustedHeight a x v} + +def infimalAdjustedCrossing (a : V → ℝ) (p : unitInterval) (t : ℝ) : ℝ≥0∞ := + ⨅ x, G.law p (G.adjustedHalfspaceHit a x 0 t) + +lemma adjustedHalfspaceHit_zero (a : V → ℝ) (x : V) : + G.adjustedHalfspaceHit a x 0 0 = Set.univ := by + apply Set.eq_univ_of_forall + intro ω + exact ⟨x,by simp,Percolation.conn_refl G.ends _ x⟩ + +@[simp] lemma infimalAdjustedCrossing_zero [Nonempty V] (a : V → ℝ) (p : unitInterval) : + G.infimalAdjustedCrossing a p 0 = 1 := by + simp only [infimalAdjustedCrossing,G.adjustedHalfspaceHit_zero,measure_univ,ciInf_const] + +lemma adjustedHalfspaceHit_upper (a : V → ℝ) (x : V) (b t : ℝ) : + IsUpperSet (G.adjustedHalfspaceHit a x b t) := by + rintro ω η hωη ⟨y,hy,hxy⟩ + exact ⟨y,hy,Percolation.conn_mono G.ends (Set.inter_subset_inter_left _ hωη) hxy⟩ + +lemma adjustedHalfspaceHit_finiteWitness (a : V → ℝ) (x : V) (b t : ℝ) : + Percolation.FiniteWitness (G.adjustedHalfspaceHit a x b t) := by + rintro ω ⟨y,hy,hxy⟩ + obtain ⟨s,hs,hconn⟩ := Percolation.finiteWitness_conn G.ends x y _ hxy + refine ⟨s,fun _ he => (hs he).1,y,hy,?_⟩ + exact Percolation.conn_mono G.ends (show (s : Set E) ⊆ (s : Set E) ∩ + Percolation.internalEdges G.ends {v | b ≤ G.orbitAdjustedHeight a x v} + from fun _ he => ⟨he,(hs he).2⟩) hconn + +lemma adjustedHalfspaceHit_hasFiniteOpenWitness (a : V → ℝ) (x : V) (b t : ℝ) : + BernoulliProduct.HasFiniteOpenWitness (G.adjustedHalfspaceHit a x b t) := by + intro ω hω + obtain ⟨s,hs,hsa⟩ := G.adjustedHalfspaceHit_finiteWitness a x b t ω hω + exact ⟨s,s.finite_toSet,hs,hsa⟩ + +lemma measurableSet_adjustedHalfspaceHit [Countable E] (a : V → ℝ) (x : V) (b t : ℝ) : + MeasurableSet (G.adjustedHalfspaceHit a x b t) := + Percolation.measurableSet_finiteWitness _ (G.adjustedHalfspaceHit_upper a x b t) + (G.adjustedHalfspaceHit_finiteWitness a x b t) + +lemma Aut.adjustedHalfspaceHit_preimage (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) (φ : G.Aut) (x : V) (b t : ℝ) : + (fun ω : Set E => φ.edge '' ω) ⁻¹' G.adjustedHalfspaceHit a (φ.vertex x) b t = + G.adjustedHalfspaceHit a x b t := by + have hD : φ.vertex ⁻¹' {v | b ≤ G.orbitAdjustedHeight a (φ.vertex x) v} = + {v | b ≤ G.orbitAdjustedHeight a x v} := by + ext v + simp only [Set.mem_preimage,Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] + ext ω + have hmask : φ.edge ⁻¹' (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {v | b ≤ G.orbitAdjustedHeight a (φ.vertex x) v}) = + ω ∩ Percolation.internalEdges G.ends {v | b ≤ G.orbitAdjustedHeight a x v} := by + rw [Set.preimage_inter,Set.preimage_image_eq _ φ.edge.injective, + ← Percolation.internalEdges_aut_preimage G.ends φ.preserves,hD] + have hconn (y : V) : + Percolation.Conn G.ends (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {v | b ≤ G.orbitAdjustedHeight a (φ.vertex x) v}) (φ.vertex x) (φ.vertex y) ↔ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {v | b ≤ G.orbitAdjustedHeight a x v}) x y := by + rw [← Percolation.conn_aut_iff G.ends φ.preserves,hmask] + constructor + · rintro ⟨y,hy,hxy⟩ + obtain ⟨z,rfl⟩ := φ.vertex.surjective y + exact ⟨z,by simpa only [Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] using hy,(hconn z).mp hxy⟩ + · rintro ⟨y,hy,hxy⟩ + exact ⟨φ.vertex y,by simpa only [Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] using hy, + (hconn y).mpr hxy⟩ + +lemma Aut.adjustedHalfspaceHit_measure [Countable E] (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) (φ : G.Aut) (p : unitInterval) + (x : V) (b t : ℝ) : + G.law p (G.adjustedHalfspaceHit a (φ.vertex x) b t) = G.law p (G.adjustedHalfspaceHit a x b t) := by + conv_lhs => rw [← G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + (G.measurableSet_adjustedHalfspaceHit _ _ _ _),Aut.adjustedHalfspaceHit_preimage G a ha φ] + +lemma infimalAdjustedCrossing_le_one [Nonempty V] (a : V → ℝ) (p : unitInterval) (t : ℝ) : + G.infimalAdjustedCrossing a p t ≤ 1 := + (iInf_le (fun x => G.law p (G.adjustedHalfspaceHit a x 0 t)) (Classical.arbitrary V)).trans prob_le_one + +theorem infimalAdjustedCrossing_supermultiplicative [Encodable V] [Countable E] [Nonempty V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (a : V → ℝ) (m M : ℝ) (hm : 0 < m) (ha : ∀ x, m ≤ a x ∧ a x ≤ M) + (p : unitInterval) {s t : ℝ} (hs : 0 ≤ s) (_ht : 0 ≤ t) : + G.infimalAdjustedCrossing a p s * G.infimalAdjustedCrossing a p t ≤ + G.infimalAdjustedCrossing a p (s+t) := by + by_cases hs0 : s = 0 + · simp only [hs0,zero_add,G.infimalAdjustedCrossing_zero,one_mul,le_refl] + have hspos : 0 < s := lt_of_le_of_ne hs (Ne.symm hs0) + obtain ⟨K,hK⟩ := G.uniform_ball_bound hq 1 + let D := Real.log M-Real.log m + have hD : 0 ≤ D := sub_nonneg.mpr (Real.log_le_log hm + ((ha (Classical.arbitrary V)).1.trans (ha (Classical.arbitrary V)).2)) + let R := D+max 0 (Real.log (K : ℝ)) + have hR : 0 ≤ R := add_nonneg hD (le_max_left _ _) + apply le_iInf + intro x + have hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → + |G.orbitAdjustedHeight a x v-G.orbitAdjustedHeight a x u| ≤ R := by + intro e u v hu hv + rw [G.orbitAdjustedHeight_change_base hc hl a x u v,add_sub_cancel_left] + have hr := G.modularLogHeight_edge_jump hc hl K hK u u v e hu hv + rw [G.modularLogHeight_self,sub_zero] at hr + have ht := abs_add_le (G.orbitAdjustedHeight a u v-G.modularLogHeight u v) (G.modularLogHeight u v) + rw [sub_add_cancel] at ht + exact ht.trans (add_le_add (G.orbitAdjustedHeight_sub_bound a m M hm ha u v) + (hr.trans (le_max_right _ _))) + have hcont (z : V) (hz : s ≤ G.orbitAdjustedHeight a x z) + (_hzR : G.orbitAdjustedHeight a x z ≤ s+R) : + G.infimalAdjustedCrossing a p t ≤ BernoulliProduct.law (fun _ : E => p) + (restrictedHit G.ends (Percolation.internalEdges G.ends {v | s ≤ G.orbitAdjustedHeight a x v}) + z {v | s+t ≤ G.orbitAdjustedHeight a x v}) := by + apply (iInf_le (fun y => G.law p (G.adjustedHalfspaceHit a y 0 t)) z).trans + rw [BernoulliProduct.law_const] + apply measure_mono + rintro ω ⟨y,hy,hzy⟩ + change t ≤ G.orbitAdjustedHeight a z y at hy + refine ⟨y,?_,Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hzy⟩ + · change s+t ≤ G.orbitAdjustedHeight a x y + rw [G.orbitAdjustedHeight_change_base hc hl a x z y] + linarith + · intro v hv + change 0 ≤ G.orbitAdjustedHeight a z v at hv + change s ≤ G.orbitAdjustedHeight a x v + rw [G.orbitAdjustedHeight_change_base hc hl a x z v] + linarith + have hprod := halfspace_crossing_fresh_product G.ends (fun _ : E => p) + (G.orbitAdjustedHeight a x) R hR hjump x 0 s (s+t) (by simp) (by simpa using hspos) + (G.infimalAdjustedCrossing a p t) hcont + simp only [BernoulliProduct.law_const] at hprod + exact (mul_le_mul' (iInf_le (fun y => G.law p (G.adjustedHalfspaceHit a y 0 s)) x) le_rfl).trans hprod + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedLayerTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedLayerTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..a174257a738c7b38435f84e7b699201603a5d5c2 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedLayerTransport.lean @@ -0,0 +1,155 @@ +import OAI.Probability.BenjaminiSchramm.OrbitHeightComparison +import OAI.Probability.CriticalPercolation.Modular.RandomTiltedTransport + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma orbitAdjustedHeight_reverse (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (x y : V) : + G.orbitAdjustedHeight a y x = -G.orbitAdjustedHeight a x y := by + have hh := G.orbitAdjustedHeight_change_base hc hl a x y x + rw [G.orbitAdjustedHeight_self] at hh + linarith + +lemma orbitAdjustedHeight_exp_balance (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (ha : ∀ x, 0 < a x) (x y : V) : + ENNReal.ofReal (a x)*G.stabilizerWeight y x = + ENNReal.ofReal (a y)*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) := by + rw [stabilizerWeight,←ENNReal.ofReal_mul (ha x).le, + ←ENNReal.ofReal_mul (ha y).le] + congr 1 + rw [orbitAdjustedHeight,modularLogHeight,Real.exp_sub,Real.exp_add, + Real.exp_log (G.modularRatio_pos hc hl x y),Real.exp_log (ha x),Real.exp_log (ha y)] + field_simp [(ha y).ne'] + +theorem OrbitRepresentatives.random_normalized_tilted_transport [Countable V] + (R : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (p : unitInterval) + (F : Set E → V → V → ℝ≥0∞) (hm : ∀ x y, Measurable (fun ω => F ω x y)) + (hF : ∀ (φ : G.Aut) ω x y, F (φ.edge '' ω) (φ.vertex x) (φ.vertex y)=F ω x y) : + (∑ x ∈ R.roots, ENNReal.ofReal (a x)*(∫⁻ ω, ∑' y, F ω x y ∂G.law p)) = + ∑ y ∈ R.roots, ENNReal.ofReal (a y)* + (∫⁻ ω, ∑' x, F ω x y*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) ∂G.law p) := by + have hh := OrbitRepresentatives.random_tilted_transport G R hc hl p + (fun ω x y => ENNReal.ofReal (a x)*F ω x y) + (fun x y => measurable_const.mul (hm x y)) + (fun φ ω x y => by rw [ha φ x,hF φ ω x y]) + have hin (ω : Set E) (y : V) : + (∑' x, (ENNReal.ofReal (a x)*F ω x y)*G.stabilizerWeight y x) = + ENNReal.ofReal (a y)*(∑' x, F ω x y* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x))) := by + rw [←ENNReal.tsum_mul_left] + apply tsum_congr + intro x + calc + _ = F ω x y*(ENNReal.ofReal (a x)*G.stabilizerWeight y x) := by ring + _ = F ω x y*(ENNReal.ofReal (a y)* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x))) := by + rw [G.orbitAdjustedHeight_exp_balance hc hl a hapos x y] + _ = _ := by ring + simp_rw [ENNReal.tsum_mul_left,hin, + lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] at hh + exact hh + +def adjustedBandTransport (a : V → ℝ) (l u : ℝ) (ω : Set E) (x y : V) : ℝ≥0∞ := + if y ∈ G.cluster ω x ∧ l ≤ G.orbitAdjustedHeight a x y ∧ + G.orbitAdjustedHeight a x y ≤ u then 1 else 0 + +def adjustedBandCount (a : V → ℝ) (l u : ℝ) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, G.adjustedBandTransport a l u ω x y + +lemma measurable_adjustedBandTransport [Countable V] [Countable E] (a : V → ℝ) (l u : ℝ) (x y : V) : + Measurable (fun ω => G.adjustedBandTransport a l u ω x y) := by + exact Measurable.ite ((G.measurable_reachable x y).and measurable_const).setOf + measurable_const measurable_const + +lemma adjustedBandTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (l u : ℝ) + (φ : G.Aut) (ω : Set E) (x y : V) : + G.adjustedBandTransport a l u (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.adjustedBandTransport a l u ω x y := by + simp only [adjustedBandTransport,G.orbitAdjustedHeight_aut a ha, + ←Aut.cluster_image,Set.mem_image,φ.vertex.injective.eq_iff,exists_eq_right] + +lemma adjustedBandTransport_reverse (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (l u : ℝ) (ω : Set E) (x y : V) : + G.adjustedBandTransport a l u ω x y = G.adjustedBandTransport a (-u) (-l) ω y x := by + unfold adjustedBandTransport + rw [G.orbitAdjustedHeight_reverse hc hl a x y] + congr 1 + apply propext + constructor + · rintro ⟨h,hlo,hhi⟩ + exact ⟨h.symm,by linarith,by linarith⟩ + · rintro ⟨h,hlo,hhi⟩ + exact ⟨h.symm,by linarith,by linarith⟩ + +lemma adjustedBandTransport_weight_bounds (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (l u : ℝ) (ω : Set E) (x y : V) : + ENNReal.ofReal (Real.exp (-u))*G.adjustedBandTransport a (-u) (-l) ω y x ≤ + G.adjustedBandTransport a l u ω x y*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) ∧ + G.adjustedBandTransport a l u ω x y*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) ≤ + ENNReal.ofReal (Real.exp (-l))*G.adjustedBandTransport a (-u) (-l) ω y x := by + rw [G.adjustedBandTransport_reverse hc hl a l u ω x y] + unfold adjustedBandTransport + split_ifs with h + · simp only [mul_one,one_mul] + constructor <;> apply ENNReal.ofReal_le_ofReal <;> apply Real.exp_le_exp.mpr + · exact h.2.1 + · exact h.2.2 + · simp only [mul_zero,zero_mul,le_refl,and_self] + +theorem expected_adjustedBandCount_reciprocity [Countable V] [Countable E] + (R : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (p : unitInterval) (l u : ℝ) : + ENNReal.ofReal (Real.exp (-u))* + (∑ x ∈ R.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.adjustedBandCount a (-u) (-l) ω x ∂G.law p)) ≤ + (∑ x ∈ R.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p)) ∧ + (∑ x ∈ R.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p)) ≤ + ENNReal.ofReal (Real.exp (-l))* + (∑ x ∈ R.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.adjustedBandCount a (-u) (-l) ω x ∂G.law p)) := by + have he := OrbitRepresentatives.random_normalized_tilted_transport G R hc hl a hapos ha p + (G.adjustedBandTransport a l u) (G.measurable_adjustedBandTransport a l u) + (G.adjustedBandTransport_aut a ha l u) + change (∑ x ∈ R.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.adjustedBandCount a l u ω x ∂G.law p)) = _ at he + rw [he] + constructor + · rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro y _hy + have hb (ω : Set E) : ENNReal.ofReal (Real.exp (-u))*G.adjustedBandCount a (-u) (-l) ω y ≤ + ∑' x, G.adjustedBandTransport a l u ω x y*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x)) := by + rw [adjustedBandCount,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum (fun x => (G.adjustedBandTransport_weight_bounds hc hl a l u ω x y).1) + calc + _ = ENNReal.ofReal (a y)*(∫⁻ ω, ENNReal.ofReal (Real.exp (-u))* + G.adjustedBandCount a (-u) (-l) ω y ∂G.law p) := by + rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] + ring + _ ≤ _ := mul_le_mul' le_rfl (lintegral_mono hb) + · rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro y _hy + have hb (ω : Set E) : + (∑' x, G.adjustedBandTransport a l u ω x y*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a y x))) ≤ + ENNReal.ofReal (Real.exp (-l))*G.adjustedBandCount a (-u) (-l) ω y := by + rw [adjustedBandCount,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum (fun x => (G.adjustedBandTransport_weight_bounds hc hl a l u ω x y).2) + calc + _ ≤ ENNReal.ofReal (a y)*(∫⁻ ω, ENNReal.ofReal (Real.exp (-l))* + G.adjustedBandCount a (-u) (-l) ω y ∂G.law p) := mul_le_mul' le_rfl (lintegral_mono hb) + _ = _ := by rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top]; ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedPeakSurgery.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedPeakSurgery.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f14165bbb1fbe6311b2dbd761ed9dc9c68c4911 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedPeakSurgery.lean @@ -0,0 +1,133 @@ +import OAI.Probability.BenjaminiSchramm.PeakSurgeryProbability +import OAI.Probability.BenjaminiSchramm.IntegerFrontierCrossing + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem normalized_peak_surgery + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) : + ∃ L : ℕ, ∀ (p : unitInterval) (d : ℕ), (∀ v, degree G v ≤ d) → + ∀ (n : ℕ), 0 < n → ∀ (x : V) (u : ℝ) (S F : Finset V), + (lowerFrontierCell G + (internalEdges G {v | (criticalModel G).adjustedLayerIndex + ((criticalModel G).stationaryOrbitWeight μ) R u x v < (n : ℤ)}) Set.univ x (S : Set V) (F : Set V)).Nonempty → + F.Nonempty → + law p (lowerFrontierCell G + (internalEdges G {v | (criticalModel G).adjustedLayerIndex + ((criticalModel G).stationaryOrbitWeight μ) R u x v < (n : ℤ)}) Set.univ x (S : Set V) (F : Set V))* + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(F.card+L+1))) ≤ + law p (lowerFrontierCell G + (internalEdges G {v | (criticalModel G).adjustedLayerIndex + ((criticalModel G).stationaryOrbitWeight μ) R u x v < (n : ℤ)}) Set.univ x (S : Set V) (F : Set V) ∩ + {ω | ∃ z, R*((n : ℝ)+1) < (criticalModel G).orbitAdjustedHeight + ((criticalModel G).stationaryOrbitWeight μ) x z ∧ + (criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x z ≤ R*((n : ℝ)+4) ∧ + ω ∈ strictHeightPeakConnection G + ((criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) x) x z}) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨L,hpath⟩ := H.stationaryOrbitHeight_bounded_peak_extension hHc hl hHq μ hμ hstat hu R hR hjump + refine ⟨L,fun p d hd n hn x offset S F hcell hF => ?_⟩ + let f := H.adjustedLayerIndex a R offset x + let h := H.orbitAdjustedHeight a x + have hfx : f x < (n : ℤ) := by + simp only [f,H.adjustedLayerIndex_self] + exact_mod_cast hn + have hfj : ∀ e v w, v ∈ G e → w ∈ G e → f w ≤ f v+1 := by + intro e v w hv hw + exact (H.adjustedLayerIndex_edge_jump hHc hl a R offset hR hjump x v w e hv hw).2 + obtain ⟨η,hη⟩ := hcell + have hSlevel (v : V) (hv : v ∈ S) : f v < (n : ℤ) := by + apply conn_internalEdges_end_mem G η {v | f v < (n : ℤ)} hfx + change v ∈ cluster G (η ∩ internalEdges G {v | f v < (n : ℤ)}) x + rw [hη.1] + exact hv + have hFlevel (v : V) (hv : v ∈ F) : f v=(n : ℤ) := by + apply integer_lower_frontier_level G f (n : ℤ) hfj η x hfx + have hfront : openFrontier G η (cluster G (η ∩ internalEdges G {v | f v < (n : ℤ)}) x)=(F : Set V) := by + rw [hη.1] + simpa only [Set.inter_univ] using hη.2 + rwa [hfront] + obtain ⟨v,hv⟩ := hF + obtain ⟨z,w,hwlen,hwmin,hwheight,hwpeak⟩ := hpath v + have hvheight := H.adjustedLayerIndex_height_bounds a R offset hR x v + change R*((f v : ℝ)-1) < h v ∧ h v < R*((f v : ℝ)+1) at hvheight + rw [hFlevel v hv] at hvheight + simp only [Int.cast_natCast] at hvheight + have hzadd : h z=h v+H.orbitAdjustedHeight a v z := H.orbitAdjustedHeight_change_base hHc hl a x v z + have hzband : R*((n : ℝ)+1) < h z ∧ h z ≤ R*((n : ℝ)+4) := by + change R*((n : ℝ)-1) < h v ∧ h v < R*((n : ℝ)+1) at hvheight + constructor <;> nlinarith [hwheight.1,hwheight.2] + have hbelow : ∀ v' ∈ (S : Set V) ∪ (F : Set V), h v' < h z := by + intro v' hv' + have hh := (H.adjustedLayerIndex_height_bounds a R offset hR x v').2 + change h v' < R*((f v' : ℝ)+1) at hh + rcases hv' with hvS | hvF + · have hi : (f v' : ℝ)+1 ≤ (n : ℝ) := by exact_mod_cast (show f v'+1 ≤ (n : ℤ) by have := hSlevel v' hvS; omega) + nlinarith [hzband.1] + · rw [hFlevel v' hvF] at hh + simp only [Int.cast_natCast] at hh + exact hh.trans hzband.1 + have havoid : ∀ v' ∈ w.support, v' ∉ (S : Set V) := by + intro v' hv' hvS + have hh := hwmin v' hv' + have hheight : h v ≤ h v' := by + have he := H.orbitAdjustedHeight_change_base hHc hl a x v v' + change h v'=h v+H.orbitAdjustedHeight a v v' at he + linarith + have hidx : f v ≤ f v' := by + unfold f CriticalPercolation.BondGraph.adjustedLayerIndex + apply sub_le_sub_right + apply Int.floor_mono + have hh := div_le_div_of_nonneg_right hheight hR.le + change h v/R+offset ≤ h v'/R+offset + linarith + rw [hFlevel v hv] at hidx + have := hSlevel v' hvS + omega + have hpeak : ∀ v' ∈ w.support, v' ≠ z → h v' < h z := by + intro v' hv' hvz + have hh := hwpeak v' hv' hvz + change H.orbitAdjustedHeight a x v' < H.orbitAdjustedHeight a x z + rw [H.orbitAdjustedHeight_change_base hHc hl a x v v', + H.orbitAdjustedHeight_change_base hHc hl a x v z] + change H.orbitAdjustedHeight a v v' < H.orbitAdjustedHeight a v z at hh + linarith + have hg : H.fullGraph=openSimpleGraph G Set.univ := criticalModel_openGraph G Set.univ + let ι : H.fullGraph →g openSimpleGraph G Set.univ := ⟨id,fun {_ _} h => by simpa only [←hg,id_eq] using h⟩ + have hsupport (v' : V) : v' ∈ (w.map ι).support ↔ v' ∈ w.support := by + simp only [SimpleGraph.Walk.support_map] + change v' ∈ w.support.map id ↔ _ + simp only [List.map_id_fun,id_eq] + have hb := lowerFrontierCell_strict_peak_probability G hl d hd p {v | f v < (n : ℤ)} + (S : Set V) F x v z h hv (w.map ι) + (fun v' hv' => havoid v' ((hsupport v').mp hv')) hbelow + (fun v' hv' => hpeak v' ((hsupport v').mp hv')) + have hδ : 0 ≤ min (p : ℝ) (1-p) := le_min p.2.1 (sub_nonneg.mpr p.2.2) + have hδ1 : min (p : ℝ) (1-p) ≤ 1 := (min_le_left _ _).trans p.2.2 + apply le_trans _ (hb.trans (measure_mono ?_)) + · exact mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (pow_le_pow_of_le_one hδ hδ1 + (Nat.mul_le_mul_left d (by simpa only [SimpleGraph.Walk.length_map] using Nat.add_le_add_right (Nat.add_le_add_left hwlen F.card) 1)))) + · rintro ω ⟨hc',hp'⟩ + exact ⟨hc',z,hzband.1,hzband.2,hp'⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/NormalizedQuarterMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/NormalizedQuarterMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a93ab0b2b1e7bce2e46e01794500ab46b43ad6d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/NormalizedQuarterMoment.lean @@ -0,0 +1,89 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry +import OAI.Probability.BenjaminiSchramm.OrbitHeightComparison +import OAI.Probability.BenjaminiSchramm.GhostMomentBound + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma modularLayerCount_le_height_band (h : V → ℝ) (R : ℝ) (hR : 1 ≤ R) + (ω : Set E) (o : V) (k : ℤ) : + modularLayerCount G h ω o k ≤ + restrictedLayerCount G Set.univ {y | (k : ℝ)-R ≤ h y ∧ h y ≤ (k : ℝ)+R} ω o := by + let F (y : V) : ℝ≥0∞ := if ((k : ℝ)-R ≤ h y ∧ h y ≤ (k : ℝ)+R) ∧ Conn G ω o y then 1 else 0 + have hlocal (y : {y : V // ⌊h y⌋=k}) : (if Conn G ω o y then (1 : ℝ≥0∞) else 0) ≤ F y := by + by_cases hy : Conn G ω o y + · have hlo := Int.floor_le (h (y : V)) + have hhi := Int.lt_floor_add_one (h (y : V)) + rw [y.property] at hlo hhi + have hb : (k : ℝ)-R ≤ h (y : V) ∧ h (y : V) ≤ (k : ℝ)+R := by + constructor <;> linarith + have hh : ((k : ℝ)-R ≤ h (y : V) ∧ h (y : V) ≤ (k : ℝ)+R) ∧ Conn G ω o y := ⟨hb,hy⟩ + simp only [F,ite_eq_left hy,ite_eq_left hh,le_refl] + · simp only [ite_eq_right hy] + exact bot_le + calc + _ ≤ ∑' y : {y : V // ⌊h y⌋=k}, F y := ENNReal.tsum_le_tsum hlocal + _ ≤ ∑' y, F y := ENNReal.tsum_comp_le_tsum_of_injective Subtype.coe_injective F + _ = _ := by + unfold restrictedLayerCount + apply tsum_congr + intro y + simp only [F,Set.mem_ofPred_eq,Set.inter_univ] + +variable [Countable V] [Countable E] + +theorem quarterMoment_lt_top_of_height_bands (h : V → ℝ) + (R : ℝ) (hR : 1 ≤ R) (p : unitInterval) (o : V) (C : ℝ≥0∞) (hC : C < ⊤) + (hpos : ∀ k : ℝ, 0 ≤ k → + (∫⁻ ω, (restrictedLayerCount G Set.univ {y | k-R ≤ h y ∧ h y ≤ k+R} ω o)^(3/4 : ℝ) ∂law p) ≤ + C*ENNReal.ofReal (Real.exp (-k/2))) + (hneg : ∀ k : ℝ, 0 ≤ k → + (∫⁻ ω, (restrictedLayerCount G Set.univ {y | -k-R ≤ h y ∧ h y ≤ -k+R} ω o)^(3/4 : ℝ) ∂law p) ≤ + C*ENNReal.ofReal (Real.exp (k/16))) : + (∫⁻ ω, quarterTiltedClusterMass G h ω o^(3/4 : ℝ) ∂law p) < ⊤ := by + apply quarterTilted_moment_lt_top_of_layer_bounds G p h o C.toReal ENNReal.toReal_nonneg + · intro k hk + have hb := hpos k (by exact_mod_cast hk) + have hm := lintegral_mono (μ := law p) fun ω => ENNReal.rpow_le_rpow + (modularLayerCount_le_height_band G h R hR ω o k) (by norm_num : (0 : ℝ) ≤ 3/4) + apply hm.trans + rw [←ENNReal.ofReal_toReal hC.ne] at hb + simpa only [←ENNReal.ofReal_mul ENNReal.toReal_nonneg] using hb + · intro k hk + have hb := hneg (-(k : ℝ)) (by exact_mod_cast neg_nonneg.mpr hk) + have hm := lintegral_mono (μ := law p) fun ω => ENNReal.rpow_le_rpow + (modularLayerCount_le_height_band G h R hR ω o k) (by norm_num : (0 : ℝ) ≤ 3/4) + apply hm.trans + rw [←ENNReal.ofReal_toReal hC.ne] at hb + simpa only [neg_neg,neg_div,←ENNReal.ofReal_mul ENNReal.toReal_nonneg] using hb + +theorem raw_quarterMoment_lt_top_of_normalized_bands [Nonempty V] + (hc : Connected G) (hl : LocallyFinite G) (a : V → ℝ) (m M : ℝ) (hm : 0 < m) + (ha : ∀ x, m ≤ a x ∧ a x ≤ M) (R : ℝ) (hR : 1 ≤ R) + (p : unitInterval) (o : V) (C : ℝ≥0∞) (hC : C < ⊤) + (hpos : ∀ k : ℝ, 0 ≤ k → + (∫⁻ ω, (restrictedLayerCount G Set.univ + {y | k-R ≤ (criticalModel G).orbitAdjustedHeight a o y ∧ + (criticalModel G).orbitAdjustedHeight a o y ≤ k+R} ω o)^(3/4 : ℝ) ∂law p) ≤ + C*ENNReal.ofReal (Real.exp (-k/2))) + (hneg : ∀ k : ℝ, 0 ≤ k → + (∫⁻ ω, (restrictedLayerCount G Set.univ + {y | -k-R ≤ (criticalModel G).orbitAdjustedHeight a o y ∧ + (criticalModel G).orbitAdjustedHeight a o y ≤ -k+R} ω o)^(3/4 : ℝ) ∂law p) ≤ + C*ENNReal.ofReal (Real.exp (k/16))) : + (criticalModel G).quarterThreeQuarterMoment p o < ⊤ := by + exact raw_quarterMoment_lt_top_of_orbit_normalization G hc hl a m M hm ha p o + (quarterMoment_lt_top_of_height_bands G ((criticalModel G).orbitAdjustedHeight a o) + R hR p o C hC hpos hneg) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OpenTriangle.lean b/lean/OAI/Probability/BenjaminiSchramm/OpenTriangle.lean new file mode 100644 index 0000000000000000000000000000000000000000..305a4064c216bd7910e26a5792a1c95cd20dd8e0 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OpenTriangle.lean @@ -0,0 +1,79 @@ +import OAI.Probability.BenjaminiSchramm.DeletionLoss + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem ennreal_distinctClusterMoment_fresh [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x y : V) : + ENNReal.ofReal (distinctClusterMoment G p x y) = + ∫⁻ ω, ENNReal.ofReal (freshExteriorMoment G p x y ω) ∂law p := by + change ENNReal.ofReal (∫ ω, (if ¬Conn G ω x y then + ((cluster G ω x).ncard : ℝ) * ((cluster G ω y).ncard : ℝ) else 0) ∂law p) = _ + rw [←integral_freshExteriorMoment G hloc hqt p hp x y] + exact ofReal_integral_eq_lintegral_ofReal (integrable_freshExteriorMoment G hloc hqt p hp x y) + (Filter.Eventually.of_forall (freshExteriorMoment_nonneg G p x y)) + +theorem freshExteriorMoment_deletion_bound [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (C : ℝ≥0∞) + (hC : ∀ z, ENNReal.ofReal (susceptibility G p z) ≤ C) (x y : V) + (ω : Set E) (hfin : (cluster G ω x).Finite) : + ENNReal.ofReal (susceptibility G p y) * clusterMass G ω x ≤ + ENNReal.ofReal (freshExteriorMoment G p x y ω) + C * clusterDeletionLoss G p x y ω := by + have hd := susceptibility_deletion_ennreal G hloc hqt p hp (cluster G ω x)ᶜ C hC y + have hd' : ENNReal.ofReal (susceptibility G p y) ≤ + ENNReal.ofReal (inducedSusceptibility G (cluster G ω x)ᶜ p y) + + (∑' z, if Conn G ω x z then law p {η | Conn G η y z} else 0) * C := by + simpa only [Set.mem_compl_iff,cluster,Set.mem_ofPred_eq,ite_not] using hd + have hm := mul_le_mul' hd' (le_refl (clusterMass G ω x)) + rw [add_mul] at hm + have hf : ENNReal.ofReal (freshExteriorMoment G p x y ω) = + ENNReal.ofReal (inducedSusceptibility G (cluster G ω x)ᶜ p y) * clusterMass G ω x := by + rw [freshExteriorMoment,ENNReal.ofReal_mul (Nat.cast_nonneg _), + clusterMass_eq_ncard G ω x hfin] + simp only [ENNReal.ofReal_natCast,mul_comm] + rw [hf] + dsimp only [clusterDeletionLoss] + convert hm using 1 + ring + +theorem distinctClusterMoment_openTriangle [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (C : ℝ≥0∞) + (hC : ∀ z, ENNReal.ofReal (susceptibility G p z) ≤ C) (x y : V) : + ENNReal.ofReal (susceptibility G p x) * ENNReal.ofReal (susceptibility G p y) ≤ + ENNReal.ofReal (distinctClusterMoment G p x y) + C ^ 2 * openTriangle G p x y := by + have hpoint : (fun ω => ENNReal.ofReal (susceptibility G p y) * clusterMass G ω x) ≤ᵐ[law p] + (fun ω => ENNReal.ofReal (freshExteriorMoment G p x y ω) + C * clusterDeletionLoss G p x y ω) := by + filter_upwards [subcritical_cluster_finite_ae G p hp x] with ω hω + exact freshExteriorMoment_deletion_bound G hloc hqt p hp C hC x y ω hω + have h := lintegral_mono_ae hpoint + rw [lintegral_const_mul _ (measurable_clusterMass G x),lintegral_clusterMass, + ←ennreal_susceptibility G hloc hqt p hp x] at h + rw [lintegral_add_left (Measurable.ennreal_ofReal (measurable_freshExteriorMoment G p x y)), + ←ennreal_distinctClusterMoment_fresh G hloc hqt p hp x y, + lintegral_const_mul _ (measurable_clusterDeletionLoss G p x y)] at h + have hrow (z : V) : (∑' u, law p {ω | Conn G ω z u}) ≤ C := by + rw [←ennreal_susceptibility G hloc hqt p hp z] + exact hC z + have hb := mul_le_mul' (le_refl C) (clusterDeletionLoss_openTriangle_bound G p C hrow x y) + have he : C * (C * openTriangle G p x y) = C ^ 2 * openTriangle G p x y := by ring + rw [he] at hb + have h' : ENNReal.ofReal (susceptibility G p x) * ENNReal.ofReal (susceptibility G p y) ≤ + ENNReal.ofReal (distinctClusterMoment G p x y) + + C * ∫⁻ ω, clusterDeletionLoss G p x y ω ∂law p := by + simpa only [mul_comm] using h + exact h'.trans (add_le_add_right hb _) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OperatorGap.lean b/lean/OAI/Probability/BenjaminiSchramm/OperatorGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..d357fb20519e3fc419e6660e9874c74df227b0cc --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OperatorGap.lean @@ -0,0 +1,57 @@ +import OAI.Probability.UnimodularPercolation.Main + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} [Infinite V] + +theorem critical_subdivision_bounded_conditional + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) : + OperatorBounded (subdivision G) (pc (subdivision G)) := by + classical + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + by_cases huni : AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) + · exact critical_bounded_of_unimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) + (subdivision_quasiTransitive G hloc hqt) (subdivision_hV_pos G hloc hqt hh) huni + · obtain ⟨q, hq, hpq⟩ := lt_sSup_iff.mp (hutchcroft2019 huni) + exact operatorBounded_of_le (subdivision G) hpq.le hq + +theorem critical_bounded_conditional + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) : + OperatorBounded G (pc G) := by + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + exact critical_bounded_of_subdivision G hloc + (critical_subdivision_bounded_conditional G hconn hloc hqt hh hutchcroft2019) + +theorem main_conditional + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) : + MainConclusion G := + mainConclusion_of_critical_bounded G hconn hloc hqt + (critical_bounded_conditional G hconn hloc hqt hh hutchcroft2019) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OperatorMeanFieldReduction.lean b/lean/OAI/Probability/BenjaminiSchramm/OperatorMeanFieldReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..b87ef4c8f14f2d3007a27b39fecebf18ded330ad --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OperatorMeanFieldReduction.lean @@ -0,0 +1,25 @@ +import OAI.Probability.BenjaminiSchramm.MeanFieldReduction +import OAI.Probability.BenjaminiSchramm.VolumeLower + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem full_application_radii [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) + (hradii : HutchcroftCriticalRadiiInput (subdivision G)) : + MainConclusion G ∧ CriticalLawsConclusion G := by + exact full_application_volume_radii G hconn hloc hqt hh hutchcroft2019 + (criticalVolumeInput_of_nonamenable (subdivision G) (subdivision_hV_pos G hloc hqt hh)) hradii + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OperatorSusceptibility.lean b/lean/OAI/Probability/BenjaminiSchramm/OperatorSusceptibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb6fd8355ff3f2570c9b01eb2ff9106635887e9b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OperatorSusceptibility.lean @@ -0,0 +1,127 @@ +import OAI.Probability.BenjaminiSchramm.SusceptibilityComparison +import OAI.Probability.BenjaminiSchramm.ReciprocalDecay +import OAI.Probability.BenjaminiSchramm.VolumeEntropy + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem exists_uniform_susceptibility_derivative_lower + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) + (p₀ : ℝ) (hp₀ : 0 < p₀) : + ∃ k : ℝ, 0 < k ∧ ∀ (p : unitInterval), p₀ ≤ (p : ℝ) → p < pc G → ∀ x, + k * (susceptibility G p x)^2 ≤ deriv (realSusceptibility G x) p := by + obtain ⟨c,C,hc,hC,hcomp⟩ := exists_susceptibility_comparison G hconn hloc hqt p₀ hp₀ + let ε := c / (2 * (C * ‖T‖^3 + 1)) + have hε : 0 < ε := by dsimp [ε]; positivity + obtain ⟨d,M,K,hdeg,hK,hKn,hrow,hsupport⟩ := exists_small_walk_kernel G hloc hqt hh ε hε + have hsmall : C * (‖T‖^3 * ‖K‖) ≤ c/2 := by + have hd : 0 < 2 * (C * ‖T‖^3 + 1) := by positivity + have hmul := (lt_div_iff₀ hd).mp hKn + nlinarith [norm_nonneg K] + let A : ℝ := p₀^(-(M : ℤ)) * ((d+1)^M : ℕ) + have hA : 0 < A := by dsimp [A]; positivity + refine ⟨(c/2)/A,div_pos (half_pos hc) hA,fun p hpp hp x => ?_⟩ + have hp0 : 0 < (p : ℝ) := hp₀.trans_le hpp + have hlo := susceptibility_derivative_lower_of_kernel G hloc hqt p hp0 hp T K hT hK d M + hdeg hrow hsupport c C hc.le hC.le x + (fun b => (hcomp p hpp hp x b).1) (fun b => (hcomp p hpp hp x b).2) hsmall + have hz : (p : ℝ)^(-(M : ℤ)) ≤ p₀^(-(M : ℤ)) := by + simp only [zpow_neg,zpow_natCast] + exact inv_anti₀ (pow_pos hp₀ M) (pow_le_pow_left₀ hp₀.le hpp M) + have hcoef : (p : ℝ)^(-(M : ℤ)) * ((d+1)^M : ℕ) * (1-(p : ℝ)) ≤ A := by + calc + _ ≤ (p : ℝ)^(-(M : ℤ)) * ((d+1)^M : ℕ) * 1 := + mul_le_mul_of_nonneg_left (by linarith [p.2.1]) (by positivity) + _ ≤ _ := by simpa only [mul_one] using mul_le_mul_of_nonneg_right hz (Nat.cast_nonneg ((d+1)^M)) + have hbound := hlo.trans (mul_le_mul_of_nonneg_right hcoef + (susceptibility_derivative_nonneg G hloc hqt p hp0 hp x)) + rw [div_mul_eq_mul_div] + apply (div_le_iff₀ hA).mpr + simpa only [mul_comm A] using hbound + +theorem susceptibility_upper_of_critical_operator + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) : + ∃ A : ℝ, 0 < A ∧ ∀ (p : unitInterval), p < pc G → ∀ x, + susceptibility G p x ≤ A / ((pc G : ℝ) - p) := by + have hpc0 : 0 < (pc G : ℝ) := pc_pos G hloc hqt + let a : ℝ := (pc G : ℝ)/4 + have ha : 0 < a := by dsimp [a]; positivity + obtain ⟨k,hk,hderiv⟩ := exists_uniform_susceptibility_derivative_lower G hconn hloc hqt hh T hT a ha + have hnear (p : unitInterval) (hap : a < (p : ℝ)) (hp : p < pc G) (x : V) : + susceptibility G p x ≤ 1 / (k * ((pc G : ℝ) - p)) := by + rw [←realSusceptibility_coe G x p] + apply reciprocal_upper_of_derivative_lower (realSusceptibility G x) a (pc G) k hk + (fun t ht => ?_) (fun t ht => ?_) (fun t ht => ?_) p ⟨hap,hp⟩ + · let q : unitInterval := ⟨t,⟨ha.le.trans ht.1.le,ht.2.le.trans (pc G).2.2⟩⟩ + change 0 < realSusceptibility G x q + rw [realSusceptibility_coe G x q] + exact lt_of_lt_of_le zero_lt_one (susceptibility_one_le G hloc hqt q ht.2 x) + · let q : unitInterval := ⟨t,⟨ha.le.trans ht.1.le,ht.2.le.trans (pc G).2.2⟩⟩ + exact (hasDerivAt_realSusceptibility G hloc hqt q (ha.trans ht.1) ht.2 x).differentiableAt + · let q : unitInterval := ⟨t,⟨ha.le.trans ht.1.le,ht.2.le.trans (pc G).2.2⟩⟩ + change k * (realSusceptibility G x q)^2 ≤ deriv (realSusceptibility G x) q + rw [realSusceptibility_coe G x q] + exact hderiv q ht.1.le ht.2 x + refine ⟨2/k,div_pos (by norm_num) hk,fun p hp x => ?_⟩ + have hgap : 0 < (pc G : ℝ) - p := sub_pos.mpr hp + by_cases hap : a < (p : ℝ) + · apply (hnear p hap hp x).trans + have he : 1 / (k * ((pc G : ℝ)-p)) = (1/k) / ((pc G : ℝ)-p) := by + simp only [div_eq_mul_inv,mul_inv_rev,one_mul] + ring + rw [he] + exact div_le_div_of_nonneg_right (div_le_div_of_nonneg_right (by norm_num) hk.le) hgap.le + · let q : unitInterval := ⟨(pc G : ℝ)/2,⟨by positivity,by linarith [(pc G).2.2]⟩⟩ + have hq : q < pc G := by change (pc G : ℝ)/2 < pc G; linarith + have haq : a < (q : ℝ) := by dsimp [a,q]; linarith + have hpq : p ≤ q := by change (p : ℝ) ≤ (pc G : ℝ)/2; dsimp [a] at hap; linarith + have hm : susceptibility G p x ≤ susceptibility G q x := + (summable_twoPoint_subcritical G hloc hqt p hp x).tsum_le_tsum + (fun y => twoPoint_mono G x y hpq) + (summable_twoPoint_subcritical G hloc hqt q hq x) + apply (hm.trans (hnear q haq hq x)).trans + have he : 1 / (k * ((pc G : ℝ)-q)) = (2/k)/(pc G : ℝ) := by + dsimp only [q] + field_simp + ring + rw [he] + exact div_le_div_of_nonneg_left (div_nonneg (by norm_num) hk.le) hgap (by linarith [p.2.1]) + +theorem critical_volume_upper_of_operator + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (hpc1 : (pc G : ℝ) < 1) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) : + ∃ C : ℝ, 0 < C ∧ ∀ x n, 0 < n → + criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n := by + obtain ⟨A,hA,hχ⟩ := susceptibility_upper_of_critical_operator G hconn hloc hqt hh T hT + exact critical_volume_upper_of_susceptibility_upper G hloc hqt hpc1 A hA hχ + +theorem probability_upper_of_operator + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (hpc1 : (pc G : ℝ) < 1) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) : + ∃ A η : ℝ, 0 < A ∧ 0 < η ∧ ∀ p : unitInterval, pc G < p → + (p : ℝ) - pc G < η → ∀ x, + percolationProbability G p x ≤ A * ((p : ℝ) - pc G) := by + obtain ⟨C,hC,hvol⟩ := critical_volume_upper_of_operator G hconn hloc hqt hh hpc1 T hT + exact percolationProbability_upper_of_uniform_critical_volume G hloc hqt hpc1 C hC hvol + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OrbitHeightComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/OrbitHeightComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..e17b0f628d154470de00d2a1ee446f862c51a907 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OrbitHeightComparison.lean @@ -0,0 +1,94 @@ +import OAI.Probability.BenjaminiSchramm.ModularSlabs + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +def orbitAdjustedHeight (a : V → ℝ) (x y : V) : ℝ := + G.modularLogHeight x y + Real.log (a y) - Real.log (a x) + +@[simp] lemma orbitAdjustedHeight_self (a : V → ℝ) (x : V) : + G.orbitAdjustedHeight a x x = 0 := by simp [orbitAdjustedHeight] + +lemma orbitAdjustedHeight_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (x v y : V) : + G.orbitAdjustedHeight a x y = G.orbitAdjustedHeight a x v + G.orbitAdjustedHeight a v y := by + simp only [orbitAdjustedHeight,G.modularLogHeight_change_base hc hl x v y] + ring + +lemma orbitAdjustedHeight_aut (a : V → ℝ) (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) + (φ : G.Aut) (x y : V) : + G.orbitAdjustedHeight a (φ.vertex x) (φ.vertex y) = G.orbitAdjustedHeight a x y := by + simp only [orbitAdjustedHeight,Aut.modularLogHeight,ha] + +lemma orbitAdjustedHeight_sub_bound (a : V → ℝ) (m M : ℝ) (hm : 0 < m) + (ha : ∀ x, m ≤ a x ∧ a x ≤ M) (x y : V) : + |G.orbitAdjustedHeight a x y - G.modularLogHeight x y| ≤ Real.log M - Real.log m := by + have hxlo := Real.log_le_log hm (ha x).1 + have hylo := Real.log_le_log hm (ha y).1 + have hxhi := Real.log_le_log (hm.trans_le (ha x).1) (ha x).2 + have hyhi := Real.log_le_log (hm.trans_le (ha y).1) (ha y).2 + have he : G.orbitAdjustedHeight a x y-G.modularLogHeight x y = Real.log (a y)-Real.log (a x) := by + unfold orbitAdjustedHeight + ring + rw [he,abs_le] + constructor <;> linarith + +end CriticalPercolation.BondGraph + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem quarterTiltedClusterMass_le_of_height_bound (h h' : V → ℝ) (D : ℝ) + (hbound : ∀ x, h x ≤ h' x+D) (ω : Set E) (o : V) : + quarterTiltedClusterMass G h ω o ≤ ENNReal.ofReal (Real.exp (D/4)) * + quarterTiltedClusterMass G h' ω o := by + unfold quarterTiltedClusterMass + rw [← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro x + by_cases hc : Conn G ω o x + · simp only [ite_eq_left hc] + rw [← ENNReal.ofReal_mul (Real.exp_nonneg _),← Real.exp_add] + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + linarith [hbound x] + · simp only [ite_eq_right hc,mul_zero,le_refl] + +theorem quarterMoment_lt_top_of_height_bound (h h' : V → ℝ) (D : ℝ) + (hbound : ∀ x, h x ≤ h' x+D) (μ : Measure (Set E)) (o : V) + (hM : (∫⁻ ω, quarterTiltedClusterMass G h' ω o ^ (3/4 : ℝ) ∂μ) < ⊤) : + (∫⁻ ω, quarterTiltedClusterMass G h ω o ^ (3/4 : ℝ) ∂μ) < ⊤ := by + have hp (ω : Set E) := ENNReal.rpow_le_rpow + (quarterTiltedClusterMass_le_of_height_bound G h h' D hbound ω o) (by norm_num : (0 : ℝ) ≤ 3/4) + simp only [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num : (0 : ℝ) ≤ 3/4)] at hp + apply lt_of_le_of_lt (lintegral_mono hp) + rw [lintegral_const_mul' _ _ + (ENNReal.rpow_lt_top_of_nonneg (by norm_num) ENNReal.ofReal_ne_top).ne] + exact ENNReal.mul_lt_top (ENNReal.rpow_lt_top_of_nonneg (by norm_num) (by simp)) hM + +theorem raw_quarterMoment_lt_top_of_orbit_normalization [Nonempty V] + (hc : Connected G) (hl : LocallyFinite G) (a : V → ℝ) (m M : ℝ) (hm : 0 < m) + (ha : ∀ x, m ≤ a x ∧ a x ≤ M) (p : unitInterval) (o : V) + (hM : (∫⁻ ω, quarterTiltedClusterMass G + ((criticalModel G).orbitAdjustedHeight a o) ω o ^ (3/4 : ℝ) ∂law p) < ⊤) : + (∫⁻ ω, (criticalModel G).quarterTiltedMass ω o ^ (3/4 : ℝ) ∂law p) < ⊤ := by + simp_rw [quarterTiltedMass_eq_logarithmic_mass G hc hl] + apply quarterMoment_lt_top_of_height_bound G (modularHeight G o) + ((criticalModel G).orbitAdjustedHeight a o) (Real.log M-Real.log m) ?_ (law p) o hM + intro x + have h := (abs_le.mp ((criticalModel G).orbitAdjustedHeight_sub_bound a m M hm ha o x)).1 + change -(Real.log M-Real.log m) ≤ (criticalModel G).orbitAdjustedHeight a o x- + modularHeight G o x at h + linarith + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OrbitNeighborChain.lean b/lean/OAI/Probability/BenjaminiSchramm/OrbitNeighborChain.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea28d01b7719dbad9577a1e01956a2d73b359a5f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OrbitNeighborChain.lean @@ -0,0 +1,113 @@ +import OAI.Probability.BenjaminiSchramm.FiniteOrbitStationary +import OAI.Probability.BenjaminiSchramm.OrbitHeightComparison + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +abbrev VertexOrbit := MulAction.orbitRel.Quotient G.Aut V + +def vertexOrbit (x : V) : G.VertexOrbit := Quotient.mk'' x + +@[simp] lemma vertexOrbit_aut (φ : G.Aut) (x : V) : + G.vertexOrbit (φ.vertex x) = G.vertexOrbit x := + Quotient.sound (MulAction.mem_orbit_iff.mpr ⟨φ,rfl⟩) + +lemma orbit_out_aut (x : V) : ∃ φ : G.Aut, φ.vertex (G.vertexOrbit x).out = x := by + have he : (Quotient.mk'' (G.vertexOrbit x).out : G.VertexOrbit) = Quotient.mk'' x := + (G.vertexOrbit x).out_eq' + exact MulAction.mem_orbit_iff.mp (MulAction.mem_orbit_symm.mp (Quotient.exact he)) + +def modularWalkDegree (x : V) : ℕ := (G.fullGraph.neighborSet x).ncard + +lemma modularWalkDegree_pos [Nontrivial V] (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (x : V) : 0 < G.modularWalkDegree x := by + apply (Set.ncard_pos (G.finite_neighbors hl x)).mpr + have h := hc.preconnected.not_isIsolated x + unfold SimpleGraph.IsIsolated at h + push Not at h + exact h + +lemma modularWalkDegree_aut (φ : G.Aut) (x : V) : + G.modularWalkDegree (φ.vertex x) = G.modularWalkDegree x := by + have he : φ.vertex '' G.fullGraph.neighborSet x = G.fullGraph.neighborSet (φ.vertex x) := by + ext y + obtain ⟨z,rfl⟩ := φ.vertex.surjective y + simp only [Set.mem_image,φ.vertex.injective.eq_iff,exists_eq_right,SimpleGraph.mem_neighborSet, + Aut.fullGraph_adj] + unfold modularWalkDegree + rw [← he,Set.ncard_image_of_injective _ φ.vertex.injective] + +def orbitNeighborCount (hl : G.LocallyFinite) (i j : G.VertexOrbit) : ℕ := + (((G.finite_neighbors hl i.out).toFinset).filter fun y => G.vertexOrbit y = j).card + +def orbitWalkKernel (hl : G.LocallyFinite) (i j : G.VertexOrbit) : ℝ := + G.orbitNeighborCount hl i j / (G.modularWalkDegree i.out : ℝ) + +lemma orbitWalkKernel_nonneg (hl : G.LocallyFinite) (i j : G.VertexOrbit) : + 0 ≤ G.orbitWalkKernel hl i j := by + unfold orbitWalkKernel + positivity + +lemma orbitNeighborCount_sum [Fintype G.VertexOrbit] (hl : G.LocallyFinite) (i : G.VertexOrbit) : + ∑ j, G.orbitNeighborCount hl i j = G.modularWalkDegree i.out := by + have he := Finset.card_eq_sum_card_fiberwise + (s := (G.finite_neighbors hl i.out).toFinset) (t := Finset.univ) + (f := G.vertexOrbit) (by intro x _; exact Finset.mem_univ _) + simpa only [orbitNeighborCount,modularWalkDegree, + Set.ncard_eq_toFinset_card _ (G.finite_neighbors hl i.out)] using he.symm + +lemma orbitWalkKernel_row_sum [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (i : G.VertexOrbit) : + ∑ j, G.orbitWalkKernel hl i j = 1 := by + simp only [orbitWalkKernel,← Finset.sum_div,← Nat.cast_sum,G.orbitNeighborCount_sum hl] + exact div_self (Nat.cast_ne_zero.mpr (G.modularWalkDegree_pos hc hl i.out).ne') + +lemma orbitWalkKernel_pos_of_adj [Nontrivial V] (hc : G.fullGraph.Connected) + (hl : G.LocallyFinite) {x y : V} (hxy : G.fullGraph.Adj x y) : + 0 < G.orbitWalkKernel hl (G.vertexOrbit x) (G.vertexOrbit y) := by + obtain ⟨φ,hφ⟩ := G.orbit_out_aut x + have hy : φ.vertex.symm y ∈ G.fullGraph.neighborSet (G.vertexOrbit x).out := by + have h := (Aut.fullGraph_adj G φ (G.vertexOrbit x).out (φ.vertex.symm y)).mp + (by simpa only [hφ,Equiv.apply_symm_apply] using hxy) + exact h + have ho : G.vertexOrbit (φ.vertex.symm y) = G.vertexOrbit y := by + simpa only [Equiv.apply_symm_apply] using (G.vertexOrbit_aut φ (φ.vertex.symm y)).symm + unfold orbitWalkKernel + apply div_pos _ (Nat.cast_pos.mpr (G.modularWalkDegree_pos hc hl _)) + apply Nat.cast_pos.mpr + apply Finset.card_pos.mpr + exact ⟨φ.vertex.symm y,Finset.mem_filter.mpr ⟨(G.finite_neighbors hl _).mem_toFinset.mpr hy,ho⟩⟩ + +lemma orbitWalkKernel_irreducible [Nontrivial V] (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (i j : G.VertexOrbit) : + Relation.ReflTransGen (fun u v => 0 < G.orbitWalkKernel hl u v) i j := by + have hpath := (G.fullGraph.reachable_iff_reflTransGen i.out j.out).mp (hc i.out j.out) + have hm : Relation.ReflTransGen (fun u v => 0 < G.orbitWalkKernel hl u v) + (G.vertexOrbit i.out) (G.vertexOrbit j.out) := + hpath.head_induction_on (Relation.ReflTransGen.refl) fun h _ ih => + (Relation.ReflTransGen.single + (r := fun u v : G.VertexOrbit => 0 < G.orbitWalkKernel hl u v) + (G.orbitWalkKernel_pos_of_adj hc hl h)).trans ih + simpa only [vertexOrbit,Quotient.out_eq'] using hm + +theorem exists_positive_orbit_stationary [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) : + ∃ μ : G.VertexOrbit → ℝ, (∀ i, 0 < μ i) ∧ + (∑ i, μ i = 1) ∧ orbitChainStep (G.orbitWalkKernel hl) μ = μ := by + let : Nonempty G.VertexOrbit := ⟨G.vertexOrbit (Classical.arbitrary V)⟩ + exact finite_orbit_stationary_positive (G.orbitWalkKernel hl) + (G.orbitWalkKernel_nonneg hl) (G.orbitWalkKernel_row_sum hc hl) + (G.orbitWalkKernel_irreducible hc hl) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OrbitNormalization.lean b/lean/OAI/Probability/BenjaminiSchramm/OrbitNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1d7b0f303226a039bf98148da944a162f189fe7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OrbitNormalization.lean @@ -0,0 +1,57 @@ +import OAI.Probability.BenjaminiSchramm.OrbitNeighborChain + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +def stationaryOrbitWeight (μ : G.VertexOrbit → ℝ) (x : V) : ℝ := + μ (G.vertexOrbit x) / G.modularWalkDegree x + +lemma stationaryOrbitWeight_pos [Nontrivial V] (hc : G.fullGraph.Connected) + (hl : G.LocallyFinite) (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) (x : V) : + 0 < G.stationaryOrbitWeight μ x := + div_pos (hμ _) (Nat.cast_pos.mpr (G.modularWalkDegree_pos hc hl x)) + +lemma stationaryOrbitWeight_aut (μ : G.VertexOrbit → ℝ) (φ : G.Aut) (x : V) : + G.stationaryOrbitWeight μ (φ.vertex x) = G.stationaryOrbitWeight μ x := by + simp only [stationaryOrbitWeight,G.vertexOrbit_aut,G.modularWalkDegree_aut] + +lemma stationaryOrbitWeight_out (μ : G.VertexOrbit → ℝ) (x : V) : + G.stationaryOrbitWeight μ x = G.stationaryOrbitWeight μ (G.vertexOrbit x).out := by + obtain ⟨φ,hφ⟩ := G.orbit_out_aut x + simpa only [hφ] using G.stationaryOrbitWeight_aut μ φ (G.vertexOrbit x).out + +theorem stationaryOrbitWeight_uniform_bounds [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) : + ∃ m M : ℝ, 0 < m ∧ ∀ x, m ≤ G.stationaryOrbitWeight μ x ∧ + G.stationaryOrbitWeight μ x ≤ M := by + let : Nonempty G.VertexOrbit := ⟨G.vertexOrbit (Classical.arbitrary V)⟩ + let w : G.VertexOrbit → ℝ := fun i => G.stationaryOrbitWeight μ i.out + obtain ⟨i,_,hi⟩ := Finset.exists_max_image Finset.univ + (show G.VertexOrbit → OrderDual ℝ from w) Finset.univ_nonempty + obtain ⟨j,_,hj⟩ := Finset.exists_max_image Finset.univ w Finset.univ_nonempty + refine ⟨w i,w j,G.stationaryOrbitWeight_pos hc hl μ hμ i.out,fun x => ?_⟩ + rw [G.stationaryOrbitWeight_out μ x] + exact ⟨hi (G.vertexOrbit x) (Finset.mem_univ _),hj (G.vertexOrbit x) (Finset.mem_univ _)⟩ + +theorem stationaryOrbitHeight_uniform_comparison [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) : + ∃ D : ℝ, 0 ≤ D ∧ ∀ x y, + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y-G.modularLogHeight x y| ≤ D := by + obtain ⟨m,M,hm,ha⟩ := G.stationaryOrbitWeight_uniform_bounds hc hl μ hμ + refine ⟨Real.log M-Real.log m,?_,fun x y => G.orbitAdjustedHeight_sub_bound _ m M hm ha x y⟩ + have hx := ha (Classical.arbitrary V) + exact sub_nonneg.mpr (Real.log_le_log hm (hx.1.trans hx.2)) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/OrbitTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/OrbitTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..01051eed48ff5dba9691f0ce164a7c4ec929a9bd --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/OrbitTransport.lean @@ -0,0 +1,235 @@ +import OAI.Probability.BenjaminiSchramm.OrbitNormalization +import OAI.Probability.CriticalPercolation.Modular.TiltedMassTransport + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +namespace OrbitRepresentatives +variable (R : G.OrbitRepresentatives) + +def orbitEquiv : {x // x ∈ R.roots} ≃ G.VertexOrbit := + Equiv.ofBijective (fun x => G.vertexOrbit x) (by + constructor + · intro x y h + obtain ⟨φ,hφ⟩ := MulAction.mem_orbit_iff.mp (Quotient.exact h.symm) + exact Subtype.ext (R.unique x x.property y y.property φ hφ) + · intro q + obtain ⟨x,hx,φ,hφ⟩ := R.cover q.out + refine ⟨⟨x,hx⟩,?_⟩ + have h := G.vertexOrbit_aut φ x + rw [hφ] at h + simpa only [vertexOrbit,Quotient.out_eq'] using h.symm) + +lemma sum_roots_eq_orbitSum [Fintype G.VertexOrbit] (f : G.VertexOrbit → ℝ) : + ∑ x ∈ R.roots, f (G.vertexOrbit x) = ∑ i, f i := by + rw [← Finset.sum_coe_sort R.roots (fun x => f (G.vertexOrbit x))] + exact (R.orbitEquiv G).sum_comp f + +end OrbitRepresentatives + +lemma orbitNeighborCount_eq_at_vertex (hl : G.LocallyFinite) (x : V) (i : G.VertexOrbit) : + G.orbitNeighborCount hl (G.vertexOrbit x) i = + (((G.finite_neighbors hl x).toFinset).filter fun y => G.vertexOrbit y = i).card := by + obtain ⟨φ,hφ⟩ := G.orbit_out_aut x + have himage : + ((((G.finite_neighbors hl (G.vertexOrbit x).out).toFinset).filter + fun y => G.vertexOrbit y = i).image φ.vertex) = + (((G.finite_neighbors hl x).toFinset).filter fun y => G.vertexOrbit y = i) := by + ext y + constructor + · rintro h + obtain ⟨z,hz,rfl⟩ := Finset.mem_image.mp h + obtain ⟨hz,ho⟩ := Finset.mem_filter.mp hz + refine Finset.mem_filter.mpr ⟨(G.finite_neighbors hl x).mem_toFinset.mpr ?_,?_⟩ + · rw [← hφ] + exact (Aut.fullGraph_adj G φ _ _).mpr ((G.finite_neighbors hl _).mem_toFinset.mp hz) + · simpa only [G.vertexOrbit_aut] using ho + · intro hy + obtain ⟨hy,ho⟩ := Finset.mem_filter.mp hy + refine Finset.mem_image.mpr ⟨φ.vertex.symm y,Finset.mem_filter.mpr ⟨?_,?_⟩, + Equiv.apply_symm_apply _ _⟩ + · apply (G.finite_neighbors hl _).mem_toFinset.mpr + apply (Aut.fullGraph_adj G φ _ _).mp + have hy' : G.fullGraph.Adj x y := (G.finite_neighbors hl x).mem_toFinset.mp hy + simpa only [hφ,Equiv.apply_symm_apply] using hy' + · have he : G.vertexOrbit (φ.vertex.symm y) = G.vertexOrbit y := by + simpa only [Equiv.apply_symm_apply] using (G.vertexOrbit_aut φ (φ.vertex.symm y)).symm + exact he.trans ho + rw [← himage,Finset.card_image_of_injective _ φ.vertex.injective] + rfl + +def orbitNeighborTransport (a : V → ℝ) (i : G.VertexOrbit) (x y : V) : ℝ := + if G.vertexOrbit y = i ∧ G.fullGraph.Adj x y then a x else 0 + +lemma orbitNeighborTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) (i : G.VertexOrbit) (φ : G.Aut) (x y : V) : + G.orbitNeighborTransport a i (φ.vertex x) (φ.vertex y) = + G.orbitNeighborTransport a i x y := by + simp only [orbitNeighborTransport,G.vertexOrbit_aut,Aut.fullGraph_adj,ha] + +lemma orbitNeighborTransport_row_finite (hl : G.LocallyFinite) (a : V → ℝ) + (i : G.VertexOrbit) (x : V) : (Function.support (G.orbitNeighborTransport a i x)).Finite := by + apply (G.finite_neighbors hl x).subset + intro y hy + by_contra h + exact hy (ite_eq_right (by simpa only [SimpleGraph.mem_neighborSet] using not_and_of_not_right _ h)) + +lemma orbitNeighborTransport_col_finite (hl : G.LocallyFinite) (a : V → ℝ) + (i : G.VertexOrbit) (y : V) : (Function.support (fun x => G.orbitNeighborTransport a i x y)).Finite := by + apply (G.finite_neighbors hl y).subset + intro x hx + by_contra h + apply hx + apply ite_eq_right + exact not_and_of_not_right _ (fun hxy => h hxy.symm) + +lemma orbitNeighborTransport_row (hl : G.LocallyFinite) (a : V → ℝ) + (i : G.VertexOrbit) (x : V) : + ∑' y, G.orbitNeighborTransport a i x y = + a x * G.orbitNeighborCount hl (G.vertexOrbit x) i := by + unfold orbitNeighborTransport + rw [tsum_eq_sum (f := fun y => if G.vertexOrbit y = i ∧ G.fullGraph.Adj x y then a x else 0) + (s := (G.finite_neighbors hl x).toFinset) (fun y hy => ite_eq_right (by + intro h + exact hy ((G.finite_neighbors hl x).mem_toFinset.mpr h.2)))] + rw [G.orbitNeighborCount_eq_at_vertex hl x i] + have he : (∑ y ∈ (G.finite_neighbors hl x).toFinset, + if G.vertexOrbit y = i ∧ G.fullGraph.Adj x y then a x else 0) = + ∑ y ∈ ((G.finite_neighbors hl x).toFinset).filter (fun y => G.vertexOrbit y = i), a x := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro y hy + have hxy : G.fullGraph.Adj x y := (G.finite_neighbors hl x).mem_toFinset.mp hy + simp only [hxy,and_true] + rw [he,Finset.sum_const,nsmul_eq_mul,mul_comm] + +def weightedNeighborIncoming (a : V → ℝ) (y : V) : ℝ := + ∑' x, if G.fullGraph.Adj x y then a x * G.modularRatio x y else 0 + +lemma weightedNeighborIncoming_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x) = a x) (φ : G.Aut) (y : V) : + G.weightedNeighborIncoming a (φ.vertex y) = G.weightedNeighborIncoming a y := by + unfold weightedNeighborIncoming + rw [← φ.vertex.tsum_eq (fun x => + if G.fullGraph.Adj x (φ.vertex y) then a x * G.modularRatio x (φ.vertex y) else 0)] + apply tsum_congr + intro x + simp only [Aut.fullGraph_adj,ha,Aut.modularRatio] + +lemma orbitNeighborTransport_incoming (a : V → ℝ) (i : G.VertexOrbit) (y : V) : + (∑' x, G.orbitNeighborTransport a i x y * G.modularRatio x y) = + if G.vertexOrbit y = i then G.weightedNeighborIncoming a y else 0 := by + by_cases hy : G.vertexOrbit y = i + · simp only [orbitNeighborTransport,hy,true_and,ite_true,weightedNeighborIncoming] + apply tsum_congr + intro x + split_ifs <;> simp only [zero_mul] + · simp only [orbitNeighborTransport,hy,false_and,ite_false,zero_mul,tsum_zero] + +theorem weightedNeighborIncoming_stationary [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) (y : V) : + G.weightedNeighborIncoming (G.stationaryOrbitWeight μ) y = μ (G.vertexOrbit y) := by + let R := G.orbitRepresentatives hq + let a := G.stationaryOrbitWeight μ + have ha := G.stationaryOrbitWeight_aut μ + have hout (i : G.VertexOrbit) : + (∑ x ∈ R.roots, ∑' z, G.orbitNeighborTransport a i x z) = μ i := by + calc + _ = ∑ x ∈ R.roots, a x * G.orbitNeighborCount hl (G.vertexOrbit x) i := by + apply Finset.sum_congr rfl + intro x _ + exact G.orbitNeighborTransport_row hl a i x + _ = ∑ j, (μ j / G.modularWalkDegree j.out) * G.orbitNeighborCount hl j i := by + rw [← R.sum_roots_eq_orbitSum G] + apply Finset.sum_congr rfl + intro x _ + rw [show a x = a (G.vertexOrbit x).out from G.stationaryOrbitWeight_out μ x] + simp only [a,stationaryOrbitWeight,vertexOrbit,Quotient.out_eq'] + _ = Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ i := by + unfold Percolation.BenjaminiSchramm.orbitChainStep orbitWalkKernel + apply Finset.sum_congr rfl + intro j _ + ring + _ = μ i := congrFun hstat i + have hin (i : G.VertexOrbit) : + (∑ z ∈ R.roots, ∑' x, G.orbitNeighborTransport a i x z * G.modularRatio x z) = + G.weightedNeighborIncoming a i.out := by + calc + _ = ∑ z ∈ R.roots, if G.vertexOrbit z = i then + G.weightedNeighborIncoming a (G.vertexOrbit z).out else 0 := by + apply Finset.sum_congr rfl + intro z _ + rw [G.orbitNeighborTransport_incoming] + obtain ⟨φ,hφ⟩ := G.orbit_out_aut z + by_cases hz : G.vertexOrbit z = i + · simp only [hz,ite_true] + have he := G.weightedNeighborIncoming_aut a ha φ (G.vertexOrbit z).out + rw [hφ] at he + simpa only [hz] using he + · simp only [hz,ite_false] + _ = ∑ j : G.VertexOrbit, if j = i then G.weightedNeighborIncoming a j.out else 0 := + R.sum_roots_eq_orbitSum G (fun j => if j = i then G.weightedNeighborIncoming a j.out else 0) + _ = _ := by simp + have hi (i : G.VertexOrbit) : G.weightedNeighborIncoming a i.out = μ i := by + rw [← hin i,← R.tilted_massTransport G hc hl _ + (G.orbitNeighborTransport_aut a ha i) (G.orbitNeighborTransport_row_finite hl a i) + (G.orbitNeighborTransport_col_finite hl a i)] + exact hout i + obtain ⟨φ,hφ⟩ := G.orbit_out_aut y + calc + _ = G.weightedNeighborIncoming a (G.vertexOrbit y).out := by + simpa only [hφ] using G.weightedNeighborIncoming_aut a ha φ (G.vertexOrbit y).out + _ = _ := hi (G.vertexOrbit y) + +theorem stationaryOrbitWeight_neighbor_sum [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) (x : V) : + (∑ y ∈ (G.finite_neighbors hl x).toFinset, + G.stationaryOrbitWeight μ y * G.modularRatio y x) = + G.stationaryOrbitWeight μ x * G.modularWalkDegree x := by + have he : G.weightedNeighborIncoming (G.stationaryOrbitWeight μ) x = + ∑ y ∈ (G.finite_neighbors hl x).toFinset, + G.stationaryOrbitWeight μ y * G.modularRatio y x := by + unfold weightedNeighborIncoming + rw [tsum_eq_sum (s := (G.finite_neighbors hl x).toFinset) + (fun y hy => ite_eq_right (fun hxy => hy ((G.finite_neighbors hl x).mem_toFinset.mpr hxy.symm)))] + apply Finset.sum_congr rfl + intro y hy + exact ite_eq_left ((G.finite_neighbors hl x).mem_toFinset.mp hy).symm + rw [← he,G.weightedNeighborIncoming_stationary hc hl hq μ hstat] + unfold stationaryOrbitWeight + rw [div_mul_cancel₀ _ (Nat.cast_ne_zero.mpr (G.modularWalkDegree_pos hc hl x).ne')] + +theorem stationaryOrbitHeight_harmonic [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) (x : V) : + (∑ y ∈ (G.finite_neighbors hl x).toFinset, + Real.exp (G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y)) = + G.modularWalkDegree x := by + have he (y : V) : + Real.exp (G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y) = + (G.stationaryOrbitWeight μ y * G.modularRatio y x) / G.stationaryOrbitWeight μ x := by + rw [orbitAdjustedHeight,modularLogHeight,Real.exp_sub,Real.exp_add, + Real.exp_log (G.modularRatio_pos hc hl y x), + Real.exp_log (G.stationaryOrbitWeight_pos hc hl μ hμ y), + Real.exp_log (G.stationaryOrbitWeight_pos hc hl μ hμ x)] + ring + simp_rw [he] + rw [← Finset.sum_div,G.stationaryOrbitWeight_neighbor_sum hc hl hq μ hstat] + exact mul_div_cancel_left₀ _ (G.stationaryOrbitWeight_pos hc hl μ hμ x).ne' + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PairedSprinkling.lean b/lean/OAI/Probability/BenjaminiSchramm/PairedSprinkling.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d7c4ace7ce8a1c1a518fa39fa53d367bea761da --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PairedSprinkling.lean @@ -0,0 +1,126 @@ +import OAI.Probability.CriticalPercolation.ProductMeasure.ProductEmbedding +import OAI.Probability.CriticalPercolation.ProductMeasure.ProductConditioning +import OAI.Probability.CriticalPercolation.ProductMeasure.MonotoneBernoulli +import OAI.Probability.UnimodularPercolation.Kernel.Sprinkling + +namespace OAI + +noncomputable section +open Set MeasureTheory ProbabilityTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BernoulliProduct +variable {E : Type*} + +def pairedParameters (q b : E → unitInterval) : E × Bool → unitInterval := + fun z => Percolation.pairParameter (q z.1) (b z.1) z.2 + +def whiteProjection (ω : Set (E × Bool)) : Set E := + (fun e => (e,true)) ⁻¹' ω + +def blueProjection (ω : Set (E × Bool)) : Set E := + (fun e => (e,false)) ⁻¹' ω + +def pairedUnion (ω : Set (E × Bool)) : Set E := {e | ∃ j, (e,j) ∈ ω} + +lemma measurable_whiteProjection : Measurable (whiteProjection (E := E)) := + Measurable.of_eval fun e => measurable_set_mem (e,true) + +lemma measurable_blueProjection : Measurable (blueProjection (E := E)) := + Measurable.of_eval fun e => measurable_set_mem (e,false) + +lemma measurable_pairedUnion : Measurable (pairedUnion (E := E)) := + Measurable.of_eval fun e => (Measurable.of_discrete : + Measurable (fun f : Bool → Prop => ∃ j, f j)).comp + (Measurable.of_eval fun j => measurable_set_mem (e,j)) + +lemma pairedUnion_eq (ω : Set (E × Bool)) : + pairedUnion ω=whiteProjection ω ∪ blueProjection ω := by + ext e + simp [pairedUnion,whiteProjection,blueProjection,Bool.exists_bool,or_comm] + +lemma paired_white_law (q b : E → unitInterval) : + (law (pairedParameters q b)).map whiteProjection=law q := by + change (law (pairedParameters q b)).map (fun ω => (fun e => (e,true)) ⁻¹' ω)=law q + simpa [whiteProjection,pairedParameters,Percolation.pairParameter, + Function.comp_def] using law_map_preimage (pairedParameters q b) + (fun e => (e,true)) (fun _ _ h => congrArg Prod.fst h) + +lemma paired_blue_law (q b : E → unitInterval) : + (law (pairedParameters q b)).map blueProjection=law b := by + change (law (pairedParameters q b)).map (fun ω => (fun e => (e,false)) ⁻¹' ω)=law b + simpa [blueProjection,pairedParameters,Percolation.pairParameter, + Function.comp_def] using law_map_preimage (pairedParameters q b) + (fun e => (e,false)) (fun _ _ h => congrArg Prod.fst h) + +lemma paired_union_law (q b : E → unitInterval) : + (law (pairedParameters q b)).map pairedUnion= + law (fun e => Percolation.sprinkleParameter (q e) (b e)) := by + simp only [law_eq_infinitePi] + change (Measure.infinitePi (fun z : E × Bool => bitMeasure (pairedParameters q b z))).map + (fun ω : E × Bool → Prop => fun e => ∃ j, ω (e,j))= + Measure.infinitePi (fun e => bitMeasure (Percolation.sprinkleParameter (q e) (b e))) + let c := MeasurableEquiv.curry E Bool Prop + let f := fun g : E → Bool → Prop => fun e => ∃ j, g e j + have hf : Measurable f := Measurable.of_eval fun e => + (Measurable.of_discrete : Measurable (fun g : Bool → Prop => ∃ j, g j)).comp + (measurable_pi_apply e) + change (Measure.infinitePi (fun z : E × Bool => bitMeasure (pairedParameters q b z))).map (f ∘ c)=_ + rw [←Measure.map_map hf c.measurable] + rw [Measure.infinitePi_map_curry (fun e j => bitMeasure (pairedParameters q b (e,j)))] + rw [Measure.infinitePi_map_pi _ (fun _ => Measurable.of_discrete)] + congr 1 + funext e + exact Percolation.map_bool_or (q e) (b e) + +def whiteBlock (Q : Set E) : Set (E × Bool) := {z | z.1 ∈ Q ∧ z.2=true} + +def erasedWhiteParameters (q : E → unitInterval) (Q : Set E) : E → unitInterval := + fun e => if e ∈ Q then 0 else q e + +lemma pinned_white_parameters (q b : E → unitInterval) (Q : Set E) : + pinnedParameters (pairedParameters q b) (whiteBlock Q) ∅= + pairedParameters (erasedWhiteParameters q Q) b := by + funext z + rcases z with ⟨e,j⟩ + cases j <;> by_cases he : e ∈ Q <;> + simp [pinnedParameters,pairedParameters,Percolation.pairParameter, + whiteBlock,erasedWhiteParameters,he] + +lemma fresh_paired_union_law (q b : E → unitInterval) (Q : Set E) : + (law (pairedParameters q b)).map + (pairedUnion ∘ forceOn (whiteBlock Q) ∅)= + law (fun e => Percolation.sprinkleParameter (erasedWhiteParameters q Q e) (b e)) := by + rw [←Measure.map_map measurable_pairedUnion (measurable_forceOn _ _), + forceOn_map_law,pinned_white_parameters,paired_union_law] + +def atParameters (q : E → unitInterval) (u : E → ℝ) : Set E := {e | u e < q e} + +lemma measurable_atParameters (q : E → unitInterval) : Measurable (atParameters q) := + Measurable.of_eval fun e => (measurable_pi_apply e).lt measurable_const + +lemma markLaw_map_atParameters (q : E → unitInterval) : + (markLaw (E := E)).map (atParameters q)=law q := by + rw [law_eq_infinitePi] + exact (Measure.infinitePi_map_pi (fun _ : E => Priority.uniform01) + (f := fun e t => t < (q e : ℝ)) + (fun _ => measurable_id.lt measurable_const)).trans + (congrArg Measure.infinitePi (funext fun e => uniform01_map_threshold (q e))) + +lemma law_mono_pointwise (q r : E → unitInterval) (hqr : ∀ e, q e ≤ r e) + (A : Set (Set E)) (hA : MeasurableSet A) (hup : IsUpperSet A) : + law q A ≤ law r A := by + rw [←markLaw_map_atParameters q,←markLaw_map_atParameters r, + Measure.map_apply (measurable_atParameters q) hA, + Measure.map_apply (measurable_atParameters r) hA] + apply measure_mono + intro u hu + apply hup _ hu + intro e he + exact (show u e < (q e : ℝ) from he).trans_le (hqr e) + +end CriticalPercolation.BernoulliProduct + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakBandProbability.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakBandProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..845d65f610e18c7d4d648f9970c6e2673b2297cb --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakBandProbability.lean @@ -0,0 +1,85 @@ +import OAI.Probability.BenjaminiSchramm.NormalizedPeakSurgery +import OAI.Probability.BenjaminiSchramm.BandMomentSummability + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def strictPeakBandEvent (a : V → ℝ) (l u : ℝ) (x : V) : Set (Set E) := + {ω | ∃ z, l < G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u ∧ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a x) x z} + +lemma strictPeakBandEvent_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (l u : ℝ) + (φ : G.Aut) (ω : Set E) (x : V) : + φ.edge '' ω ∈ G.strictPeakBandEvent a l u (φ.vertex x) ↔ + ω ∈ G.strictPeakBandEvent a l u x := by + have hconn (v w : V) : Percolation.Conn G.ends (φ.edge '' ω) (φ.vertex v) (φ.vertex w) ↔ + Percolation.Conn G.ends ω v w := by + rw [←Percolation.conn_aut_iff G.ends φ.preserves, + Set.preimage_image_eq _ φ.edge.injective] + have hpeak (z : V) : φ.edge '' ω ∈ strictHeightPeakConnection G.ends + (G.orbitAdjustedHeight a (φ.vertex x)) (φ.vertex x) (φ.vertex z) ↔ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a x) x z := by + constructor + · rintro ⟨h,hp⟩ + refine ⟨(hconn x z).mp h,fun y hy hyz => ?_⟩ + have hh := hp (φ.vertex y) ((hconn z y).mpr hy) (fun he => hyz (φ.vertex.injective he)) + simpa only [G.orbitAdjustedHeight_aut a ha] using hh + · rintro ⟨h,hp⟩ + refine ⟨(hconn x z).mpr h,?_⟩ + intro y hy hyz + obtain ⟨v,rfl⟩ := φ.vertex.surjective y + have hh := hp v ((hconn z v).mp hy) (fun he => hyz (congrArg φ.vertex he)) + simpa only [G.orbitAdjustedHeight_aut a ha] using hh + constructor + · rintro ⟨z,hz⟩ + obtain ⟨v,rfl⟩ := φ.vertex.surjective z + refine ⟨v,?_⟩ + simpa only [G.orbitAdjustedHeight_aut a ha,hpeak] using hz + · rintro ⟨z,hz⟩ + refine ⟨φ.vertex z,?_⟩ + simpa only [G.orbitAdjustedHeight_aut a ha,hpeak] using hz + +variable [Countable V] [Countable E] + +lemma measurableSet_strictPeakBandEvent (a : V → ℝ) (l u : ℝ) (x : V) : + MeasurableSet (G.strictPeakBandEvent a l u x) := by + exact (Measurable.exists fun z => measurable_const.and + (measurable_const.and (measurableSet_strictHeightPeakConnection G.ends _ x z).mem)).setOf + +lemma strictPeakBandEvent_probability_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (l u : ℝ) + (φ : G.Aut) (p : unitInterval) (x : V) : + G.law p (G.strictPeakBandEvent a l u (φ.vertex x)) = + G.law p (G.strictPeakBandEvent a l u x) := by + conv_lhs => rw [←G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + (G.measurableSet_strictPeakBandEvent a l u _)] + congr 1 + ext ω + exact G.strictPeakBandEvent_aut a ha l u φ ω x + +lemma strictPeakBandEvent_probability_le_weighted_roots + (O : G.OrbitRepresentatives) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (m : ℝ) (ham : ∀ x, m ≤ a x) (p : unitInterval) (l u : ℝ) (x : V) : + ENNReal.ofReal m*G.law p (G.strictPeakBandEvent a l u x) ≤ + ∑ r ∈ O.roots, ENNReal.ofReal (a r)*G.law p (G.strictPeakBandEvent a l u r) := by + obtain ⟨r,hr,φ,rfl⟩ := O.cover x + rw [G.strictPeakBandEvent_probability_aut a ha l u φ p r] + exact (mul_le_mul' (ENNReal.ofReal_le_ofReal (ham r)) le_rfl).trans + (Finset.single_le_sum (f := fun r => ENNReal.ofReal (a r)*G.law p (G.strictPeakBandEvent a l u r)) + (fun _ _ => bot_le) hr) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakBandSecondMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakBandSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..9be5121176d2f0f31c8dde07e3afef6539869b2c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakBandSecondMoment.lean @@ -0,0 +1,118 @@ +import OAI.Probability.BenjaminiSchramm.PeakBandTransport +import OAI.Probability.BenjaminiSchramm.LayerProfileAtRate + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma peakDownBandCount_le_four_layers (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (n : ℕ) (ω : Set E) (x : V) : + G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x ≤ + ∑ j ∈ Finset.range 4, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -((n+j+1 : ℕ) : ℤ)} ω x := by + unfold peakDownBandCount restrictedLayerCount + simp only [Set.mem_ofPred_eq] + rw [←Summable.tsum_finsetSum (fun _ _ => ENNReal.summable)] + apply ENNReal.tsum_le_tsum + intro y + by_cases h : R*((n : ℝ)+1) < G.orbitAdjustedHeight a y x ∧ + G.orbitAdjustedHeight a y x ≤ R*((n : ℝ)+4) ∧ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a y) y x + · have hhlo : -R*((n : ℝ)+4) ≤ G.orbitAdjustedHeight a x y := by + rw [G.orbitAdjustedHeight_reverse hc hl a y x] + linarith [h.2.1] + have hhhi : G.orbitAdjustedHeight a x y < -R*((n : ℝ)+1) := by + rw [G.orbitAdjustedHeight_reverse hc hl a y x] + linarith [h.1] + have hidx : -((n : ℤ)+4) ≤ G.adjustedLayerIndex a R 0 x y ∧ + G.adjustedLayerIndex a R 0 x y < -((n : ℤ)+1) := by + simp only [adjustedLayerIndex,add_zero,Int.floor_zero,sub_zero] + constructor + · apply Int.le_floor.mpr + apply (le_div_iff₀ hR).mpr + push_cast + nlinarith + · apply Int.floor_lt.mpr + apply (div_lt_iff₀ hR).mpr + push_cast + nlinarith + let j : ℕ := (-G.adjustedLayerIndex a R 0 x y-(n : ℤ)-1).toNat + have hj : j ∈ Finset.range 4 := by + simp only [Finset.mem_range,j] + omega + have he : G.adjustedLayerIndex a R 0 x y = -((n+j+1 : ℕ) : ℤ) := by + dsimp [j] + omega + have hconn : Percolation.Conn G.ends (ω ∩ Set.univ) x y := by + simpa only [Set.inter_univ] using Percolation.conn_symm G.ends ω h.2.2.1 + unfold peakUpBandTransport + rw [ite_eq_left h] + have hb := Finset.single_le_sum (s := Finset.range 4) (a := j) + (f := fun k => if G.adjustedLayerIndex a R 0 x y = -((n+k+1 : ℕ) : ℤ) ∧ + Percolation.Conn G.ends (ω ∩ Set.univ) x y then (1 : ℝ≥0∞) else 0) + (fun _ _ => bot_le) hj + rw [ite_eq_left (show G.adjustedLayerIndex a R 0 x y = -((n+j+1 : ℕ) : ℤ) ∧ + Percolation.Conn G.ends (ω ∩ Set.univ) x y from ⟨he,hconn⟩)] at hb + apply hb.trans_eq + apply Finset.sum_congr rfl + intro k _hk + by_cases hh : G.adjustedLayerIndex a R 0 x y = -((n+k+1 : ℕ) : ℤ) ∧ + Percolation.Conn G.ends (ω ∩ Set.univ) x y + · simp only [ite_eq_left hh] + · simp only [ite_eq_right hh] + · rw [peakUpBandTransport,ite_eq_right h] + exact bot_le + +variable [Countable V] [Countable E] + +theorem peakDownBandCount_second_moment_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (p : unitInterval) (β : ℝ) (hβ : R < β) + (K : ℝ≥0∞) + (hsecond : ∀ (k l : ℕ) (x : V), + (∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(k : ℤ)} ω x * + restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(l : ℤ)} ω x ∂G.law p) ≤ + K*ENNReal.ofReal (Real.exp (-(β-R)*((max k l : ℕ) : ℝ)))) (n : ℕ) (x : V) : + (∫⁻ ω, (G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x)^2 ∂G.law p) ≤ + 16*K*ENNReal.ofReal (Real.exp (-(β-R)*n)) := by + let N (j : ℕ) (ω : Set E) := restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -((n+j+1 : ℕ) : ℤ)} ω x + have hmeas (j : ℕ) : Measurable (N j) := measurable_restrictedLayerCount G.ends _ _ x + calc + _ ≤ ∫⁻ ω, (∑ j ∈ Finset.range 4, N j ω)^2 ∂G.law p := + lintegral_mono fun ω => pow_le_pow_left' (G.peakDownBandCount_le_four_layers hc hl a R hR n ω x) 2 + _ = ∑ j ∈ Finset.range 4, ∑ k ∈ Finset.range 4, ∫⁻ ω, N j ω*N k ω ∂G.law p := by + simp_rw [pow_two,Finset.sum_mul,Finset.mul_sum] + rw [lintegral_finsetSum (f := fun j ω => ∑ k ∈ Finset.range 4, N j ω*N k ω) + (Finset.range 4) (fun j _ => Finset.measurable_sum _ (fun k _ => (hmeas j).mul (hmeas k)))] + apply Finset.sum_congr rfl + intro j _ + exact lintegral_finsetSum (f := fun k ω => N j ω*N k ω) _ (fun k _ => (hmeas j).mul (hmeas k)) + _ ≤ ∑ _j ∈ Finset.range 4, ∑ _k ∈ Finset.range 4, + K*ENNReal.ofReal (Real.exp (-(β-R)*n)) := by + apply Finset.sum_le_sum + intro j _ + apply Finset.sum_le_sum + intro k _ + apply (hsecond (n+j+1) (n+k+1) x).trans + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hm : (n : ℝ) ≤ ((max (n+j+1) (n+k+1) : ℕ) : ℝ) := by + exact_mod_cast (show n ≤ max (n+j+1) (n+k+1) by omega) + nlinarith + _ = _ := by norm_num [Finset.sum_const,nsmul_eq_mul]; ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakBandTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakBandTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2d5e33fd44e514c834dc3480240209b85cb2aa7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakBandTransport.lean @@ -0,0 +1,126 @@ +import OAI.Probability.BenjaminiSchramm.PeakBandProbability + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def peakUpBandTransport (a : V → ℝ) (l u : ℝ) (ω : Set E) (y x : V) : ℝ≥0∞ := + if l < G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ u ∧ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a y) y x then 1 else 0 + +def peakDownBandCount (a : V → ℝ) (l u : ℝ) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, G.peakUpBandTransport a l u ω y x + +lemma peakUpBandTransport_outgoing (a : V → ℝ) (l u : ℝ) (ω : Set E) (y : V) : + (∑' x, G.peakUpBandTransport a l u ω y x) = + (G.strictPeakBandEvent a l u y).indicator (fun _ => (1 : ℝ≥0∞)) ω := by + by_cases he : ω ∈ G.strictPeakBandEvent a l u y + · obtain ⟨z,hz⟩ := he + rw [Set.indicator_of_mem (show ω ∈ G.strictPeakBandEvent a l u y from ⟨z,hz⟩), + tsum_eq_single z] + · exact ite_eq_left hz + · intro x hxz + apply ite_eq_right + rintro ⟨_,_,hxy,hpeak⟩ + have hzx := Percolation.conn_trans G.ends ω (Percolation.conn_symm G.ends ω hz.2.2.1) hxy + have hlt := hz.2.2.2 x hzx hxz + have hlt' := hpeak z (Percolation.conn_symm G.ends ω hzx) (Ne.symm hxz) + linarith + · rw [Set.indicator_of_notMem he] + apply ENNReal.tsum_eq_zero.mpr + intro x + exact ite_eq_right (fun hx => he ⟨x,hx⟩) + +lemma peakUpBandTransport_incoming_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (l u : ℝ) (ω : Set E) (x y : V) : + G.peakUpBandTransport a l u ω y x*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) ≤ + ENNReal.ofReal (Real.exp (-l))*G.peakUpBandTransport a l u ω y x := by + by_cases h : l < G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ u ∧ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a y) y x + · simp only [peakUpBandTransport,ite_eq_left h,one_mul,mul_one] + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + rw [G.orbitAdjustedHeight_reverse hc hl a y x] + linarith [h.1] + · simp only [peakUpBandTransport,ite_eq_right h,zero_mul,mul_zero,le_refl] + +variable [Countable V] [Countable E] + +lemma measurable_peakUpBandTransport (a : V → ℝ) (l u : ℝ) (y x : V) : + Measurable (fun ω => G.peakUpBandTransport a l u ω y x) := by + exact Measurable.ite (measurable_const.and (measurable_const.and + (measurableSet_strictHeightPeakConnection G.ends _ y x).mem)).setOf + measurable_const measurable_const + +lemma measurable_peakDownBandCount (a : V → ℝ) (l u : ℝ) (x : V) : + Measurable (fun ω => G.peakDownBandCount a l u ω x) := + Measurable.tsum fun y => G.measurable_peakUpBandTransport a l u y x + +omit [Countable V] [Countable E] in +lemma peakUpBandTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (l u : ℝ) + (φ : G.Aut) (ω : Set E) (y x : V) : + G.peakUpBandTransport a l u (φ.edge '' ω) (φ.vertex y) (φ.vertex x)= + G.peakUpBandTransport a l u ω y x := by + have hpeak : φ.edge '' ω ∈ strictHeightPeakConnection G.ends + (G.orbitAdjustedHeight a (φ.vertex y)) (φ.vertex y) (φ.vertex x) ↔ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a y) y x := by + have hconn (v w : V) : Percolation.Conn G.ends (φ.edge '' ω) (φ.vertex v) (φ.vertex w) ↔ + Percolation.Conn G.ends ω v w := by + rw [←Percolation.conn_aut_iff G.ends φ.preserves, + Set.preimage_image_eq _ φ.edge.injective] + constructor + · rintro ⟨h,hp⟩ + refine ⟨(hconn y x).mp h,fun z hz hzx => ?_⟩ + have hh := hp (φ.vertex z) ((hconn x z).mpr hz) (fun he => hzx (φ.vertex.injective he)) + simpa only [G.orbitAdjustedHeight_aut a ha] using hh + · rintro ⟨h,hp⟩ + refine ⟨(hconn y x).mpr h,?_⟩ + intro z hz hzx + obtain ⟨v,rfl⟩ := φ.vertex.surjective z + have hh := hp v ((hconn x v).mp hz) (fun he => hzx (congrArg φ.vertex he)) + simpa only [G.orbitAdjustedHeight_aut a ha] using hh + simp only [peakUpBandTransport,G.orbitAdjustedHeight_aut a ha,hpeak] + +theorem expected_peakDownBandCount_lower + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (p : unitInterval) (l u : ℝ) : + (∑ y ∈ O.roots, ENNReal.ofReal (a y)*G.law p (G.strictPeakBandEvent a l u y)) ≤ + ENNReal.ofReal (Real.exp (-l))* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.peakDownBandCount a l u ω x ∂G.law p)) := by + have he := OrbitRepresentatives.random_normalized_tilted_transport G O hc hl a hapos ha p + (G.peakUpBandTransport a l u) (G.measurable_peakUpBandTransport a l u) + (G.peakUpBandTransport_aut a ha l u) + simp_rw [G.peakUpBandTransport_outgoing, + lintegral_indicator_fun_one (G.measurableSet_strictPeakBandEvent a l u _)] at he + rw [he,Finset.mul_sum] + apply Finset.sum_le_sum + intro x _hx + calc + _ ≤ ENNReal.ofReal (a x)*(∫⁻ ω, + ENNReal.ofReal (Real.exp (-l))*G.peakDownBandCount a l u ω x ∂G.law p) := by + apply mul_le_mul' le_rfl + apply lintegral_mono + intro ω + change (∑' y, G.peakUpBandTransport a l u ω y x*ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y))) ≤ + ENNReal.ofReal (Real.exp (-l))*(∑' y, G.peakUpBandTransport a l u ω y x) + rw [←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum fun y => G.peakUpBandTransport_incoming_bound hc hl a l u ω x y + _ = _ := by + rw [lintegral_const_mul _ (G.measurable_peakDownBandCount a l u x)] + ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakClusterCorrelation.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakClusterCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e8371d7abc1d100cf320e7241c6012f95c9387c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakClusterCorrelation.lean @@ -0,0 +1,144 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry +import OAI.Probability.BenjaminiSchramm.LayerFreshSelection +import OAI.Probability.UnimodularPercolation.Splicing.GapCodes + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def restrictedSetHit (I : Set E) (A T : Set V) : Set (Set E) := + {ω | ∃ v ∈ A, ∃ t ∈ T, Conn G (ω ∩ I) v t} + +def peakConnectionCell (I J : Set E) (u w : V) (S T : Set V) : Set (Set E) := + {ω | cluster G (ω ∩ I) u=S ∧ + Conn G ((ω ∩ J) ∩ internalEdges G S) u w ∧ Disjoint S T} + +lemma peakConnectionCell_iff (I J : Set E) (hJI : J ⊆ I) (u w : V) (S T : Set V) + (ω : Set E) : + ω ∈ peakConnectionCell G I J u w S T ↔ + cluster G (ω ∩ I) u=S ∧ Conn G (ω ∩ J) u w ∧ Disjoint S T := by + constructor + · rintro ⟨hc,hw,hd⟩ + exact ⟨hc,conn_mono G Set.inter_subset_left hw,hd⟩ + · rintro ⟨hc,hw,hd⟩ + have hh := conn_restrict_cluster_of_subset G (ω ∩ I) u + (fun e he => ⟨he.1,hJI he.2⟩) (mem_cluster_self G _ u) hw + rw [hc] at hh + exact ⟨hc,hh,hd⟩ + +lemma masked_internal_configuration_dependsOn (J : Set E) (S : Set V) : + DependsOn (fun ω : Set E => (ω ∩ J) ∩ internalEdges G S) (ballIncidentEdges G S) := by + intro ω η hωη + ext e + change ((ω e ∧ e ∈ J) ∧ e ∈ internalEdges G S) ↔ + ((η e ∧ e ∈ J) ∧ e ∈ internalEdges G S) + by_cases he : e ∈ internalEdges G S + · have hi : e ∈ ballIncidentEdges G S := + ⟨(G e).out.1,he _ (Sym2.out_fst_mem _),Sym2.out_fst_mem _⟩ + rw [hωη e hi] + · simp only [he,and_false] + +lemma peakConnectionCell_dependsOn (I J : Set E) (u w : V) (S T : Set V) : + DependsOn (fun ω => ω ∈ peakConnectionCell G I J u w S T) (ballIncidentEdges G S) := by + intro ω η hωη + have hc := restricted_exactCluster_dependsOn G I u S hωη + have hm := masked_internal_configuration_dependsOn G J S hωη + change (cluster G (Set.inter ω I) u=S) = (cluster G (Set.inter η I) u=S) at hc + change (Set.inter (Set.inter ω J) (internalEdges G S)) = + (Set.inter (Set.inter η J) (internalEdges G S)) at hm + change (cluster G (Set.inter ω I) u=S ∧ + Conn G (Set.inter (Set.inter ω J) (internalEdges G S)) u w ∧ Disjoint S T) = + (cluster G (Set.inter η I) u=S ∧ + Conn G (Set.inter (Set.inter η J) (internalEdges G S)) u w ∧ Disjoint S T) + rw [hc,hm] + +lemma masked_exterior_configuration_dependsOn (I : Set E) (S : Set V) : + DependsOn (fun ω : Set E => (ω ∩ I) ∩ internalEdges G Sᶜ) (ballIncidentEdges G S)ᶜ := by + intro ω η hωη + ext e + change ((ω e ∧ e ∈ I) ∧ e ∈ internalEdges G Sᶜ) ↔ + ((η e ∧ e ∈ I) ∧ e ∈ internalEdges G Sᶜ) + by_cases he : e ∈ internalEdges G Sᶜ + · have hi : e ∈ (ballIncidentEdges G S)ᶜ := by + rintro ⟨v,hv,hve⟩ + exact (he v hve) hv + rw [hωη e hi] + · simp only [he,and_false] + +lemma peakConnectionCell_inter_hit (I J : Set E) (u w : V) (S A T : Set V) : + peakConnectionCell G I J u w S T ∩ restrictedSetHit G I A T = + peakConnectionCell G I J u w S T ∩ + restrictedSetHit G (I ∩ internalEdges G Sᶜ) A T := by + ext ω + constructor + · rintro ⟨hc,v,hv,t,ht,hvt⟩ + have htn : t ∉ cluster G (ω ∩ I) u := by + rw [hc.1] + exact fun h => Set.disjoint_left.mp hc.2.2 h ht + have hh := conn_restrict_away_from_cluster G (ω ∩ I) (ω ∩ I) Set.Subset.rfl + u t v htn (conn_symm G _ hvt) + rw [hc.1] at hh + refine ⟨hc,v,hv,t,ht,?_⟩ + simpa only [Set.inter_assoc] using conn_symm G _ hh + · rintro ⟨hc,v,hv,t,ht,hvt⟩ + exact ⟨hc,v,hv,t,ht,conn_mono G + (Set.inter_subset_inter_right _ Set.inter_subset_left) hvt⟩ + +variable [Countable V] [Countable E] + +lemma measurableSet_restrictedSetHit (I : Set E) (A T : Set V) : + MeasurableSet (restrictedSetHit G I A T) := by + have hm : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact (Measurable.exists fun v => measurable_const.and + (Measurable.exists fun t => measurable_const.and + ((measurableSet_conn G v t).mem.comp hm))).setOf + +lemma measurableSet_peakConnectionCell (I J : Set E) (u w : V) (S T : Set V) : + MeasurableSet (peakConnectionCell G I J u w S T) := by + have hm : Measurable (fun ω : Set E => (ω ∩ J) ∩ internalEdges G S) := + measurable_set_iff.mpr fun e => ((measurable_set_mem e).and measurable_const).and measurable_const + exact (measurableSet_restricted_exactCluster G I u S).inter + ((((measurableSet_conn G u w).mem.comp hm).and measurable_const).setOf) + +omit [Countable V] [Countable E] in +lemma restrictedSetHit_exterior_dependsOn (I : Set E) (A T S : Set V) : + DependsOn (fun ω => ω ∈ restrictedSetHit G (I ∩ internalEdges G Sᶜ) A T) + (ballIncidentEdges G S)ᶜ := by + intro ω η hωη + have hh := masked_exterior_configuration_dependsOn G I S hωη + change Set.inter (Set.inter ω I) (internalEdges G Sᶜ) = + Set.inter (Set.inter η I) (internalEdges G Sᶜ) at hh + have hh' : Set.inter ω (Set.inter I (internalEdges G Sᶜ)) = + Set.inter η (Set.inter I (internalEdges G Sᶜ)) := + (Set.inter_assoc ω I (internalEdges G Sᶜ)).symm.trans + (hh.trans (Set.inter_assoc η I (internalEdges G Sᶜ))) + exact congrArg (fun ξ : Set E => ∃ v ∈ A, ∃ t ∈ T, Conn G ξ v t) hh' + +lemma peakConnectionCell_hit_probability (p : unitInterval) + (I J : Set E) (u w : V) (S A T : Set V) : + law p (peakConnectionCell G I J u w S T ∩ restrictedSetHit G I A T) ≤ + law p (peakConnectionCell G I J u w S T)*law p (restrictedSetHit G I A T) := by + rw [peakConnectionCell_inter_hit] + have hlaw : CriticalPercolation.BernoulliProduct.law (fun _ : E => p) = law p := + CriticalPercolation.BernoulliProduct.law_const p + rw [←hlaw] + rw [CriticalPercolation.BernoulliProduct.measure_inter_of_separate_blocks (fun _ : E => p) + (ballIncidentEdges G S) _ _ (measurableSet_peakConnectionCell G I J u w S T) + (measurableSet_restrictedSetHit G _ A T) (peakConnectionCell_dependsOn G I J u w S T) + (restrictedSetHit_exterior_dependsOn G I A T S)] + apply mul_le_mul' le_rfl + apply measure_mono + rintro ω ⟨v,hv,t,ht,hvt⟩ + exact ⟨v,hv,t,ht,conn_mono G (Set.inter_subset_inter_right _ Set.inter_subset_left) hvt⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..f133d04252b5fc1ad3a0ef2f4e33c0c87ec6f307 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakComparison.lean @@ -0,0 +1,54 @@ +import OAI.Probability.BenjaminiSchramm.ExponentialDecay + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem bk_avoiding_increasing [Countable E] (p : unitInterval) + (A B D : Set (Set E)) (hA : IsUpperSet A) (hB : IsUpperSet B) (hD : IsUpperSet D) + (hfA : FiniteWitness A) (hfB : FiniteWitness B) (hfD : FiniteWitness D) : + (law p).real (DisjointOccurrence A B \ D) ≤ + (law p).real A * (law p).real B * (1 - (law p).real D) := by + let F := DisjointOccurrence A B + have hF : IsUpperSet F := disjointOccurrence_upper A B + have hfF : FiniteWitness F := finiteWitness_disjointOccurrence A B + have hh := association_finiteWitness p F D hF hD hfF hfD + have hd := measureReal_sdiff_add_inter (μ := law p) (s := F) + (measurableSet_finiteWitness D hD hfD) + have h1 : (law p).real D ≤ 1 := by + simp + have ha : (law p).real (F \ D) ≤ (law p).real F * (1 - (law p).real D) := by + nlinarith + exact ha.trans (mul_le_mul_of_nonneg_right (bk p A B hA hB hfA hfB) (by linarith)) + +def aboveConnection (G : BondGraph V E) (h : V → ℝ) (x : V) : Set (Set E) := + {ω | ∃ y, Conn G ω x y ∧ h x < h y} + +theorem aboveConnection_upper (G : BondGraph V E) (h : V → ℝ) (x : V) : + IsUpperSet (aboveConnection G h x) := by + rintro ω η hωη ⟨y,hy,hh⟩ + exact ⟨y,conn_mono G hωη hy,hh⟩ + +theorem aboveConnection_finiteWitness (G : BondGraph V E) (h : V → ℝ) (x : V) : + FiniteWitness (aboveConnection G h x) := by + rintro ω ⟨y,hy,hh⟩ + obtain ⟨s,hs,hsy⟩ := finiteWitness_conn G x y ω hy + exact ⟨s,hs,y,hsy,hh⟩ + +theorem bk_on_peak [Countable E] (G : BondGraph V E) (h : V → ℝ) (x : V) + (p : unitInterval) (A B : Set (Set E)) (hA : IsUpperSet A) (hB : IsUpperSet B) + (hfA : FiniteWitness A) (hfB : FiniteWitness B) : + (law p).real (DisjointOccurrence A B \ aboveConnection G h x) ≤ + (law p).real A * (law p).real B * (1 - (law p).real (aboveConnection G h x)) := + bk_avoiding_increasing p A B _ hA hB (aboveConnection_upper G h x) hfA hfB + (aboveConnection_finiteWitness G h x) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakComparisonAveraging.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakComparisonAveraging.lean new file mode 100644 index 0000000000000000000000000000000000000000..5da856e5506dbc571fc48893ea416aa99385977d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakComparisonAveraging.lean @@ -0,0 +1,104 @@ +import OAI.Probability.BenjaminiSchramm.PeakCountComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem peak_layer_comparison_averaged_in_domain (p : unitInterval) + (D D' K J : Set E) (hKD : K ⊆ D) (hJD : J ⊆ D) (hJK : Disjoint J K) + (hKD' : K ⊆ D') (hJD' : J ⊆ D') + (x : V) (U T W : Set V) (b : ℝ≥0∞) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G (ω ∩ D) v).Finite) + (hbound : ∀ u ∈ U, b ≤ + ∑' w, if w ∈ W then law p (connectionAvoidingHit G D J u w T) else 0) : + law p ((restrictedHit G D x T)ᶜ ∩ restrictedHit G K x U)*b ≤ + ∫⁻ ω, (restrictedHit G D x T)ᶜ.indicator + (fun ω => restrictedLayerCount G D' W ω x) ω ∂law p := by + let P := (restrictedHit G D x T)ᶜ + let ι := {A : Finset V // ((A : Set V) ∩ U).Nonempty ∧ Disjoint (A : Set V) T} + let C (i : ι) : Set (Set E) := {ω | cluster G (ω ∩ K) x=(i.val : Set V)} ∩ P + have hm (i : ι) : MeasurableSet (C i) := + (measurableSet_restricted_exactCluster G K x _).inter + (measurableSet_restrictedHit G D x T).compl + have hd : Pairwise (fun i j : ι => Disjoint (C i) (C j)) := by + intro i j hij + apply Set.disjoint_left.mpr + rintro ω ⟨hi,_⟩ ⟨hj,_⟩ + exact hij (Subtype.ext (Finset.coe_injective (hi.symm.trans hj))) + have hpart : law p (P ∩ restrictedHit G K x U)=∑' i : ι, law p (C i) := by + calc + _ = law p (⋃ i : ι, C i) := by + apply measure_congr + filter_upwards [hfin x] with ω hω + apply propext + constructor + · rintro ⟨hp,u,hu,hxu⟩ + have hfK : (cluster G (ω ∩ K) x).Finite := hω.subset fun v hv => + conn_mono G (Set.inter_subset_inter_right _ hKD) hv + let A := hfK.toFinset + have hA : cluster G (ω ∩ K) x=(A : Set V) := hfK.coe_toFinset.symm + have hU : ((A : Set V) ∩ U).Nonempty := ⟨u,hA ▸ hxu,hu⟩ + have hT : Disjoint (A : Set V) T := by + apply Set.disjoint_left.mpr + intro v hv hvT + apply hp + refine ⟨v,hvT,conn_mono G (Set.inter_subset_inter_right _ hKD) ?_⟩ + change v ∈ cluster G (ω ∩ K) x + rwa [hA] + exact Set.mem_iUnion.mpr ⟨⟨A,hU,hT⟩,hA,hp⟩ + · intro hh + obtain ⟨i,hi,hp⟩ := Set.mem_iUnion.mp hh + obtain ⟨u,hu,huU⟩ := i.property.1 + refine ⟨hp,u,huU,?_⟩ + change u ∈ cluster G (ω ∩ K) x + rwa [hi] + _ = _ := measure_iUnion hd hm + have hcell (i : ι) : law p (C i)*b ≤ + ∫⁻ ω, (C i).indicator (fun ω => restrictedLayerCount G D' W ω x) ω ∂law p := by + obtain ⟨u,hu,huU⟩ := i.property.1 + have hJI : J ⊆ D \ (K ∩ ballIncidentEdges G (i.val : Set V)) := by + intro e he + exact ⟨hJD he,fun h => Set.disjoint_left.mp hJK he h.1⟩ + have hf : ∀ᵐ ω ∂law p, + (cluster G (ω ∩ (D \ (K ∩ ballIncidentEdges G (i.val : Set V)))) u).Finite := by + filter_upwards [hfin u] with ω hω + exact hω.subset fun v hv => conn_mono G + (Set.inter_subset_inter_right _ Set.sdiff_subset) hv + exact (mul_le_mul' le_rfl (hbound u huU)).trans + (upper_cluster_peak_layer_comparison_in_domain G p D D' K J hKD hKD' hJD' x u _ T W hu i.property.2 hJI hf) + calc + _ = ∑' i : ι, law p (C i)*b := by rw [hpart,ENNReal.tsum_mul_right] + _ ≤ ∑' i : ι, ∫⁻ ω, (C i).indicator + (fun ω => restrictedLayerCount G D' W ω x) ω ∂law p := ENNReal.tsum_le_tsum hcell + _ = ∫⁻ ω in ⋃ i : ι, C i, restrictedLayerCount G D' W ω x ∂law p := by + simp_rw [lintegral_indicator (hm _)] + exact (lintegral_iUnion hm hd _).symm + _ ≤ ∫⁻ ω in P, restrictedLayerCount G D' W ω x ∂law p := by + apply lintegral_mono_set + intro ω hω + obtain ⟨i,hi⟩ := Set.mem_iUnion.mp hω + exact hi.2 + _ = _ := (lintegral_indicator (measurableSet_restrictedHit G D x T).compl + (fun ω => restrictedLayerCount G D' W ω x)).symm + +theorem peak_layer_comparison_averaged (p : unitInterval) + (D K J : Set E) (hKD : K ⊆ D) (hJD : J ⊆ D) (hJK : Disjoint J K) + (x : V) (U T W : Set V) (b : ℝ≥0∞) + (hfin : ∀ v, ∀ᵐ ω ∂law p, (cluster G (ω ∩ D) v).Finite) + (hbound : ∀ u ∈ U, b ≤ + ∑' w, if w ∈ W then law p (connectionAvoidingHit G D J u w T) else 0) : + law p ((restrictedHit G D x T)ᶜ ∩ restrictedHit G K x U)*b ≤ + ∫⁻ ω, (restrictedHit G D x T)ᶜ.indicator + (fun ω => restrictedLayerCount G D W ω x) ω ∂law p := + peak_layer_comparison_averaged_in_domain G p D D K J hKD hJD hJK hKD hJD x U T W b hfin hbound + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakComplementCorrelation.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakComplementCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c36bee722da8cb5307a8c634efe0c3268cbe5b5 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakComplementCorrelation.lean @@ -0,0 +1,38 @@ +import OAI.Probability.BenjaminiSchramm.PeakCorrelationAveraging + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma probability_complement_correlation {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (C B : Set Ω) + (hB : MeasurableSet B) (hneg : μ (C ∩ B) ≤ μ C * μ B) : + μ C * μ Bᶜ ≤ μ (C ∩ Bᶜ) := by + apply ENNReal.le_of_add_le_add_left (measure_ne_top μ (C ∩ B)) + calc + μ (C ∩ B) + μ C * μ Bᶜ ≤ μ C * μ B + μ C * μ Bᶜ := + add_le_add hneg le_rfl + _ = μ C := by rw [←mul_add,prob_add_prob_compl hB,mul_one] + _ = μ (C ∩ B) + μ (C ∩ Bᶜ) := by + simpa only [Set.sdiff_eq] using (measure_inter_add_sdiff (μ := μ) C hB).symm + +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem connection_avoiding_hit_complement_correlation (p : unitInterval) + (I J : Set E) (hJI : J ⊆ I) (u w : V) (A T : Set V) + (hfin : ∀ᵐ ω ∂law p, (cluster G (ω ∩ I) u).Finite) : + law p (connectionAvoidingHit G I J u w T) * law p (restrictedSetHit G I A T)ᶜ ≤ + law p (connectionAvoidingHit G I J u w T ∩ (restrictedSetHit G I A T)ᶜ) := + probability_complement_correlation (law p) _ _ + (measurableSet_restrictedSetHit G I A T) + (connection_avoiding_hit_negative_correlation G p I J hJI u w A T hfin) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakConditionalLayers.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakConditionalLayers.lean new file mode 100644 index 0000000000000000000000000000000000000000..79341d2a4d7cc2dba85f597be87d3b380604a848 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakConditionalLayers.lean @@ -0,0 +1,126 @@ +import OAI.Probability.BenjaminiSchramm.SubcriticalPeakSurvival + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma one_le_tsum_ite_one_of_pos {ι : Type*} (P : ι → Prop) + (h : 0 < ∑' i, if P i then (1 : ℝ≥0∞) else 0) : + 1 ≤ ∑' i, if P i then (1 : ℝ≥0∞) else 0 := by + have he : ∃ i, P i := by + by_contra! hn + have hz : (∑' i, if P i then (1 : ℝ≥0∞) else 0)=0 := + ENNReal.tsum_eq_zero.mpr fun i => ite_eq_right (hn i) + rw [hz] at h + exact lt_irrefl _ h + obtain ⟨i,hi⟩ := he + have hh := ENNReal.le_tsum (f := fun j => if P j then (1 : ℝ≥0∞) else 0) i + simpa only [ite_eq_left hi] using hh + +lemma one_le_tsum_of_zero_or_one {ι : Type*} (f : ι → ℝ≥0∞) + (hf : ∀ i, f i=0 ∨ f i=1) (h : 0 < ∑' i, f i) : 1 ≤ ∑' i, f i := by + have he : ∃ i, f i ≠ 0 := by + by_contra! hn + rw [ENNReal.tsum_eq_zero.mpr hn] at h + exact lt_irrefl _ h + obtain ⟨i,hi⟩ := he + have hh := ENNReal.le_tsum (f := f) i + rwa [(hf i).resolve_left hi] at hh + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def peakSurvivalProbability (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ≥0∞ := + ∑ x ∈ O.roots, ENNReal.ofReal (a x)* + G.law p {ω | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x} + +def peakSurvivalLayerMoment (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (n l : ℕ) : ℝ≥0∞ := + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => restrictedLayerCount G.ends Set.univ {y | G.adjustedLayerIndex a R 0 x y = -(l : ℤ)} η x) ω ∂G.law p) + +variable [Countable V] [Countable E] + +theorem peak_survival_layer_moment_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (p : unitInterval) (β : ℝ) (hβ : R < β) + (K : ℝ≥0∞) + (hsecond : ∀ (k l : ℕ) (x : V), + (∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(k : ℤ)} ω x * + restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(l : ℤ)} ω x ∂G.law p) ≤ + K*ENNReal.ofReal (Real.exp (-(β-R)*((max k l : ℕ) : ℝ)))) (n l : ℕ) (x : V) : + (∫⁻ ω, + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => restrictedLayerCount G.ends Set.univ {y | G.adjustedLayerIndex a R 0 x y = -(l : ℤ)} η x) ω ∂G.law p) ≤ + 4*K*ENNReal.ofReal (Real.exp (-(β-R)*((max n l : ℕ) : ℝ))) := by + let F (ω : Set E) := restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(l : ℤ)} ω x + let N (j : ℕ) (ω : Set E) := restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -((n+j+1 : ℕ) : ℤ)} ω x + have hmF : Measurable F := measurable_restrictedLayerCount G.ends _ _ x + have hmN (j : ℕ) : Measurable (N j) := measurable_restrictedLayerCount G.ends _ _ x + have hpoint (ω : Set E) : + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator F ω ≤ + F ω*(∑ j ∈ Finset.range 4, N j ω) := by + by_cases hω : 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x + · rw [Set.indicator_of_mem (show ω ∈ {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x} from hω)] + have hone : 1 ≤ G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x := + by + unfold peakDownBandCount peakUpBandTransport at hω ⊢ + exact one_le_tsum_of_zero_or_one _ (fun y => by split_ifs <;> simp) hω + exact (show F ω ≤ F ω*G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x by + simpa only [mul_one] using mul_le_mul' (le_refl (F ω)) hone).trans + (mul_le_mul' le_rfl (G.peakDownBandCount_le_four_layers hc hl a R hR n ω x)) + · rw [Set.indicator_of_notMem (show ω ∉ {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x} from hω)] + exact bot_le + calc + _ ≤ ∫⁻ ω, F ω*(∑ j ∈ Finset.range 4, N j ω) ∂G.law p := lintegral_mono hpoint + _ = ∑ j ∈ Finset.range 4, ∫⁻ ω, F ω*N j ω ∂G.law p := by + simp_rw [Finset.mul_sum] + exact lintegral_finsetSum (f := fun j ω => F ω*N j ω) _ (fun j _ => hmF.mul (hmN j)) + _ ≤ ∑ _j ∈ Finset.range 4, K*ENNReal.ofReal (Real.exp (-(β-R)*((max n l : ℕ) : ℝ))) := by + apply Finset.sum_le_sum + intro j _ + apply (hsecond l (n+j+1) x).trans + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hh : ((max n l : ℕ) : ℝ) ≤ ((max l (n+j+1) : ℕ) : ℝ) := by + exact_mod_cast (show max n l ≤ max l (n+j+1) by omega) + nlinarith + _ = _ := by simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul]; ring + +theorem peakSurvivalLayerMoment_bound + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (p : unitInterval) (β : ℝ) (hβ : R < β) + (K : ℝ≥0∞) + (hsecond : ∀ (k l : ℕ) (x : V), + (∫⁻ ω, restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(k : ℤ)} ω x * + restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y = -(l : ℤ)} ω x ∂G.law p) ≤ + K*ENNReal.ofReal (Real.exp (-(β-R)*((max k l : ℕ) : ℝ)))) (n l : ℕ) : + G.peakSurvivalLayerMoment O a R p n l ≤ + (∑ x ∈ O.roots, ENNReal.ofReal (a x))*(4*K)* + ENNReal.ofReal (Real.exp (-(β-R)*((max n l : ℕ) : ℝ))) := by + apply (Finset.sum_le_sum fun x _ => mul_le_mul' le_rfl + (G.peak_survival_layer_moment_bound hc hl a R hR p β hβ K hsecond n l x)).trans_eq + rw [←Finset.sum_mul] + ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakCorrelationAveraging.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakCorrelationAveraging.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dd8eb581c9bec07de74bf8dc6fda8986b53479f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakCorrelationAveraging.lean @@ -0,0 +1,82 @@ +import OAI.Probability.BenjaminiSchramm.PeakClusterCorrelation +import OAI.Probability.BenjaminiSchramm.FreshSlabConcatenation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def connectionAvoidingHit (I J : Set E) (u w : V) (T : Set V) : Set (Set E) := + {ω | Conn G (ω ∩ J) u w ∧ ω ∉ restrictedHit G I u T} + +omit [Countable V] [Countable E] in +lemma connectionAvoidingHit_finite_cells (I J : Set E) (hJI : J ⊆ I) + (u w : V) (T : Set V) (ω : Set E) (hf : (cluster G (ω ∩ I) u).Finite) : + ω ∈ connectionAvoidingHit G I J u w T ↔ + ∃ S : Finset V, ω ∈ peakConnectionCell G I J u w (S : Set V) T := by + constructor + · rintro ⟨hw,havoid⟩ + let S := hf.toFinset + have hs : cluster G (ω ∩ I) u=(S : Set V) := hf.coe_toFinset.symm + apply Exists.intro S + apply (peakConnectionCell_iff G I J hJI u w _ T ω).mpr + refine ⟨hs,hw,Set.disjoint_left.mpr ?_⟩ + intro v hv hvT + apply havoid + refine ⟨v,hvT,?_⟩ + change v ∈ cluster G (ω ∩ I) u + rwa [hs] + · rintro ⟨S,hS⟩ + obtain ⟨hs,hw,hdis⟩ := (peakConnectionCell_iff G I J hJI u w _ T ω).mp hS + refine ⟨hw,?_⟩ + rintro ⟨v,hvT,huv⟩ + apply Set.disjoint_left.mp hdis _ hvT + rw [←hs] + exact huv + +lemma measure_peakConnectionCell_partition (p : unitInterval) + (I J : Set E) (hJI : J ⊆ I) (u w : V) (T : Set V) + (hfin : ∀ᵐ ω ∂law p, (cluster G (ω ∩ I) u).Finite) + (B : Set (Set E)) (hB : MeasurableSet B) : + law p (connectionAvoidingHit G I J u w T ∩ B) = + ∑' S : Finset V, law p (peakConnectionCell G I J u w (S : Set V) T ∩ B) := by + have hdis : Pairwise (fun S U : Finset V => Disjoint + (peakConnectionCell G I J u w (S : Set V) T ∩ B) + (peakConnectionCell G I J u w (U : Set V) T ∩ B)) := by + intro S U hne + apply Set.disjoint_left.mpr + rintro ω ⟨hS,_⟩ ⟨hU,_⟩ + exact hne (Finset.coe_injective (hS.1.symm.trans hU.1)) + calc + _ = law p (⋃ S : Finset V, peakConnectionCell G I J u w (S : Set V) T ∩ B) := by + apply measure_congr + filter_upwards [hfin] with ω hω + simp only [Set.mem_inter_iff,Set.mem_iUnion] + rw [connectionAvoidingHit_finite_cells G I J hJI u w T ω hω] + exact propext exists_and_right.symm + _ = _ := measure_iUnion hdis fun S => + (measurableSet_peakConnectionCell G I J u w (S : Set V) T).inter hB + +theorem connection_avoiding_hit_negative_correlation (p : unitInterval) + (I J : Set E) (hJI : J ⊆ I) (u w : V) (A T : Set V) + (hfin : ∀ᵐ ω ∂law p, (cluster G (ω ∩ I) u).Finite) : + law p (connectionAvoidingHit G I J u w T ∩ restrictedSetHit G I A T) ≤ + law p (connectionAvoidingHit G I J u w T)*law p (restrictedSetHit G I A T) := by + have hpart : law p (connectionAvoidingHit G I J u w T) = + ∑' S : Finset V, law p (peakConnectionCell G I J u w (S : Set V) T) := by + simpa only [Set.inter_univ] using measure_peakConnectionCell_partition G p I J hJI u w T hfin + Set.univ MeasurableSet.univ + rw [measure_peakConnectionCell_partition G p I J hJI u w T hfin + (restrictedSetHit G I A T) (measurableSet_restrictedSetHit G I A T),hpart, + ←ENNReal.tsum_mul_right] + exact ENNReal.tsum_le_tsum fun S => peakConnectionCell_hit_probability G p I J u w _ A T + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakCostBound.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakCostBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d34b56d5ffeab819cc928d6c97828ad3b719cfe --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakCostBound.lean @@ -0,0 +1,62 @@ +import OAI.Probability.BenjaminiSchramm.PeakLayerCost +import OAI.Probability.BenjaminiSchramm.PeakSprinklingCost + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma exponential_continuation_cost_summable (g : ℕ → ℝ) (C a : ℝ) + (hg : ∀ l, 0 ≤ g l) (hC : 0 ≤ C) (hb : ∀ l, g l ≤ C) + (ha : 0 < a) (n : ℕ) : + Summable (fun l => g l*Real.exp (-a*max ((l : ℝ)-n) 0)) := by + simp_rw [exponential_continuation_weight] + exact (geometric_continuation_cost_bound g C (Real.exp (-a)) hg hC hb + (Real.exp_pos _).le (Real.exp_lt_one_iff.mpr (neg_neg_of_pos ha)) n).1 + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem peakSurvivalCostMoment_bound (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (g : ℕ → ℝ) (hg : ∀ l, 0 ≤ g l) + (C₀ : ℝ) (hC₀ : 0 ≤ C₀) (hgb : ∀ l, g l ≤ C₀) + (A C : ℝ) (hA : 0 < A) (hC : 0 ≤ C) (n : ℕ) + (hprofile : ∀ l : ℕ, G.peakSurvivalLayerMoment O a R p n l ≤ + G.peakSurvivalProbability O a R p n * + ENNReal.ofReal (C*Real.exp (-A*max ((l : ℝ)-n) 0))) : + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => G.downwardLayerCost a R g η x) ω ∂G.law p)) ≤ + G.peakSurvivalProbability O a R p n * + ENNReal.ofReal (C*(∑' l, g l*Real.exp (-A*max ((l : ℝ)-n) 0))) := by + rw [G.peakSurvivalCostMoment_eq] + let P := G.peakSurvivalProbability O a R p n + let f : ℕ → ℝ := fun l => g l*Real.exp (-A*max ((l : ℝ)-n) 0) + have hf : ∀ l, 0 ≤ f l := fun l => mul_nonneg (hg l) (Real.exp_nonneg _) + have hs : Summable f := exponential_continuation_cost_summable g C₀ A hg hC₀ hgb hA n + have he (l : ℕ) : ENNReal.ofReal (g l)*(P*ENNReal.ofReal + (C*Real.exp (-A*max ((l : ℝ)-n) 0)))=(P*ENNReal.ofReal C)*ENNReal.ofReal (f l) := by + rw [ENNReal.ofReal_mul hC,show f l=g l*Real.exp (-A*max ((l : ℝ)-n) 0) from rfl, + ENNReal.ofReal_mul (hg l)] + ring + calc + _ ≤ ∑' l, ENNReal.ofReal (g l)*(P*ENNReal.ofReal + (C*Real.exp (-A*max ((l : ℝ)-n) 0))) := + ENNReal.tsum_le_tsum fun l => mul_le_mul' le_rfl (hprofile l) + _ = (P*ENNReal.ofReal C)*(∑' l, ENNReal.ofReal (f l)) := by + simp_rw [he] + exact ENNReal.tsum_mul_left + _ = _ := by + rw [←ENNReal.ofReal_tsum_of_nonneg hf hs,mul_assoc,←ENNReal.ofReal_mul hC] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakCountComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakCountComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..e21c659121cdfc948cecba380d21e6868fabba4f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakCountComparison.lean @@ -0,0 +1,89 @@ +import OAI.Probability.BenjaminiSchramm.PeakExposureComparison +import OAI.Probability.BenjaminiSchramm.SlabSecondMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma lintegral_indicator_restrictedLayerCount (p : unitInterval) + (P : Set (Set E)) (hP : MeasurableSet P) (I : Set E) (W : Set V) (x : V) : + (∫⁻ ω, P.indicator (fun ω => restrictedLayerCount G I W ω x) ω ∂law p) = + ∑' w, if w ∈ W then law p (P ∩ {ω | Conn G (ω ∩ I) x w}) else 0 := by + have hm (w : V) : MeasurableSet (P ∩ {ω | Conn G (ω ∩ I) x w}) := by + have hi : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact hP.inter ((measurableSet_conn G x w).preimage hi) + have he (ω : Set E) : P.indicator (fun ω => restrictedLayerCount G I W ω x) ω = + ∑' w, if w ∈ W then (P ∩ {ω | Conn G (ω ∩ I) x w}).indicator + (fun _ => (1 : ℝ≥0∞)) ω else 0 := by + by_cases hp : ω ∈ P + · rw [Set.indicator_of_mem hp] + unfold restrictedLayerCount + apply tsum_congr + intro w + by_cases hw : w ∈ W <;> by_cases hc : Conn G (ω ∩ I) x w <;> + simp only [hw,hc,hp,Set.indicator,Set.mem_inter_iff,Set.mem_ofPred_eq, + and_true,and_false,ite_true,ite_false] + · rw [Set.indicator_of_notMem hp] + symm + apply ENNReal.tsum_eq_zero.mpr + intro w + by_cases hw : w ∈ W <;> + simp only [hw,hp,Set.indicator,Set.mem_inter_iff,false_and,ite_true,ite_false] + simp_rw [he] + rw [lintegral_tsum (fun w => (by + by_cases hw : w ∈ W + · simpa only [hw,ite_true] using ((measurable_const.indicator (hm w)).aemeasurable) + · simp only [hw,ite_false] + exact aemeasurable_const))] + apply tsum_congr + intro w + by_cases hw : w ∈ W + · simp only [hw,ite_true] + exact lintegral_indicator_one (hm w) + · simp only [hw,ite_false,lintegral_zero] + +theorem upper_cluster_peak_layer_comparison_in_domain (p : unitInterval) + (D D' K J : Set E) (hKD : K ⊆ D) (hKD' : K ⊆ D') (hJD' : J ⊆ D') (x u : V) (A T W : Set V) + (hu : u ∈ A) (hAT : Disjoint A T) + (hJI : J ⊆ D \ (K ∩ ballIncidentEdges G A)) + (hfin : ∀ᵐ ω ∂law p, + (cluster G (ω ∩ (D \ (K ∩ ballIncidentEdges G A))) u).Finite) : + law p ({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ) * + (∑' w, if w ∈ W then law p (connectionAvoidingHit G D J u w T) else 0) ≤ + ∫⁻ ω, ({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ).indicator + (fun ω => restrictedLayerCount G D' W ω x) ω ∂law p := by + rw [lintegral_indicator_restrictedLayerCount G p _ + ((measurableSet_restricted_exactCluster G K x A).inter + (measurableSet_restrictedHit G D x T).compl),←ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro w + by_cases hw : w ∈ W + · simp only [hw,ite_true] + exact upper_cluster_peak_connection_comparison_in_domain G p D D' K J hKD hKD' hJD' x u w A T hu hAT hJI hfin + · simp only [hw,ite_false,mul_zero] + exact le_rfl + +theorem upper_cluster_peak_layer_comparison (p : unitInterval) + (D K J : Set E) (hKD : K ⊆ D) (x u : V) (A T W : Set V) + (hu : u ∈ A) (hAT : Disjoint A T) + (hJI : J ⊆ D \ (K ∩ ballIncidentEdges G A)) + (hfin : ∀ᵐ ω ∂law p, + (cluster G (ω ∩ (D \ (K ∩ ballIncidentEdges G A))) u).Finite) : + law p ({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ) * + (∑' w, if w ∈ W then law p (connectionAvoidingHit G D J u w T) else 0) ≤ + ∫⁻ ω, ({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ).indicator + (fun ω => restrictedLayerCount G D W ω x) ω ∂law p := + upper_cluster_peak_layer_comparison_in_domain G p D D K J hKD hKD + (hJI.trans Set.sdiff_subset) x u A T W hu hAT hJI hfin + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakExposureComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakExposureComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..47f447386d39dd44f088d4edd5eb6e44752512d6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakExposureComparison.lean @@ -0,0 +1,113 @@ +import OAI.Probability.BenjaminiSchramm.PeakUpperExposure + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma connectionAvoidingHit_dependsOn (I J : Set E) (hJI : J ⊆ I) + (u w : V) (T : Set V) : + DependsOn (fun ω => ω ∈ connectionAvoidingHit G I J u w T) I := by + intro ω η hωη + have hJ : Set.inter ω J=Set.inter η J := by + ext e + change (ω e ∧ e ∈ J) ↔ (η e ∧ e ∈ J) + by_cases hj : e ∈ J + · exact and_congr (Iff.of_eq (hωη e (hJI hj))) Iff.rfl + · simp only [hj,and_false] + have hT := restrictedHit_dependsOn G I u T hωη + exact congrArg₂ And (congrArg (fun ξ : Set E => Conn G ξ u w) hJ) + (congrArg Not hT) + +variable [Countable V] [Countable E] + +lemma measurableSet_connectionAvoidingHit (I J : Set E) (u w : V) (T : Set V) : + MeasurableSet (connectionAvoidingHit G I J u w T) := by + have hm : Measurable (fun ω : Set E => ω ∩ J) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact (((measurableSet_conn G u w).mem.comp hm).setOf).inter + (measurableSet_restrictedHit G I u T).compl + +theorem upper_cluster_peak_connection_comparison_in_domain (p : unitInterval) + (D D' K J : Set E) (hKD : K ⊆ D) (hKD' : K ⊆ D') (hJD' : J ⊆ D') (x u w : V) (A T : Set V) + (hu : u ∈ A) (hAT : Disjoint A T) + (hJI : J ⊆ D \ (K ∩ ballIncidentEdges G A)) + (hfin : ∀ᵐ ω ∂law p, + (cluster G (ω ∩ (D \ (K ∩ ballIncidentEdges G A))) u).Finite) : + law p ({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ) * + law p (connectionAvoidingHit G D J u w T) ≤ + law p (({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ) ∩ + {ω | Conn G (ω ∩ D') x w}) := by + let C : Set (Set E) := {ω | cluster G (ω ∩ K) x=A} + let I := D \ (K ∩ ballIncidentEdges G A) + let B := restrictedSetHit G I A T + let F := connectionAvoidingHit G I J u w T + have hfresh : I ⊆ (K ∩ ballIncidentEdges G A)ᶜ := fun _ h => h.2 + have hCB : C ∩ (restrictedHit G D x T)ᶜ=C ∩ Bᶜ := by + ext ω + constructor + · rintro ⟨hc,havoid⟩ + exact ⟨hc,fun hh => havoid ((upper_cluster_forbidden_hit_iff G ω D K hKD x A T hc hAT).mpr hh)⟩ + · rintro ⟨hc,havoid⟩ + exact ⟨hc,fun hh => havoid ((upper_cluster_forbidden_hit_iff G ω D K hKD x A T hc hAT).mp hh)⟩ + have hBc : MeasurableSet Bᶜ := (measurableSet_restrictedSetHit G I A T).compl + have hdBc : DependsOn (fun ω => ω ∈ Bᶜ) I := by + intro ω η hωη + exact congrArg Not (restrictedSetHit_dependsOn G I A T hωη) + have hFB : MeasurableSet (F ∩ Bᶜ) := + (measurableSet_connectionAvoidingHit G I J u w T).inter hBc + have hdFB : DependsOn (fun ω => ω ∈ F ∩ Bᶜ) I := by + intro ω η hωη + exact congrArg₂ And (connectionAvoidingHit_dependsOn G I J hJI u w T hωη) + (hdBc hωη) + have hmon : law p (connectionAvoidingHit G D J u w T) ≤ law p F := by + apply measure_mono + rintro ω ⟨hc,havoid⟩ + refine ⟨hc,?_⟩ + rintro ⟨t,ht,hut⟩ + exact havoid ⟨t,ht,conn_mono G (Set.inter_subset_inter_right _ Set.sdiff_subset) hut⟩ + have hinc : C ∩ (F ∩ Bᶜ) ⊆ + (C ∩ (restrictedHit G D x T)ᶜ) ∩ {ω | Conn G (ω ∩ D') x w} := by + rintro ω ⟨hc,hF,hB⟩ + have hp : ω ∈ C ∩ (restrictedHit G D x T)ᶜ := by + rw [hCB] + exact ⟨hc,hB⟩ + have hxu : Conn G (ω ∩ K) x u := by + change u ∈ cluster G (ω ∩ K) x + rwa [hc] + exact ⟨hp,(conn_mono G (Set.inter_subset_inter_right _ hKD') hxu).trans + (conn_mono G (Set.inter_subset_inter_right _ hJD') hF.1)⟩ + change law p (C ∩ (restrictedHit G D x T)ᶜ)*_ ≤ _ + conv_lhs => rw [hCB,upper_cluster_fresh_factor G p K I x A hfresh Bᶜ hBc hdBc] + calc + (law p C*law p Bᶜ)*law p (connectionAvoidingHit G D J u w T) ≤ + (law p C*law p Bᶜ)*law p F := mul_le_mul' le_rfl hmon + _ = law p C*(law p F*law p Bᶜ) := by ring + _ ≤ law p C*law p (F ∩ Bᶜ) := mul_le_mul' le_rfl + (connection_avoiding_hit_complement_correlation G p I J hJI u w A T hfin) + _ = law p (C ∩ (F ∩ Bᶜ)) := + (upper_cluster_fresh_factor G p K I x A hfresh (F ∩ Bᶜ) hFB hdFB).symm + _ ≤ _ := measure_mono hinc + +theorem upper_cluster_peak_connection_comparison (p : unitInterval) + (D K J : Set E) (hKD : K ⊆ D) (x u w : V) (A T : Set V) + (hu : u ∈ A) (hAT : Disjoint A T) + (hJI : J ⊆ D \ (K ∩ ballIncidentEdges G A)) + (hfin : ∀ᵐ ω ∂law p, + (cluster G (ω ∩ (D \ (K ∩ ballIncidentEdges G A))) u).Finite) : + law p ({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ) * + law p (connectionAvoidingHit G D J u w T) ≤ + law p (({ω | cluster G (ω ∩ K) x=A} ∩ (restrictedHit G D x T)ᶜ) ∩ + {ω | Conn G (ω ∩ D) x w}) := + upper_cluster_peak_connection_comparison_in_domain G p D D K J hKD hKD + (hJI.trans Set.sdiff_subset) x u w A T hu hAT hJI hfin + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakExposureGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakExposureGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7968510ca6e36d46e125f4e780c99faab43cb8d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakExposureGeometry.lean @@ -0,0 +1,131 @@ +import OAI.Probability.BenjaminiSchramm.PeakComparisonAveraging +import OAI.Probability.BenjaminiSchramm.PeakHalfspaceGeometry + +namespace OAI + +noncomputable section +open Set +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma upper_mask_lower_bound (f : V → ℝ) (R b d : ℝ) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → |f w-f v| ≤ R) + (D : Set E) (hd : d ≤ b-R) : + D \ internalEdges G {z | f z ≤ b} ⊆ internalEdges G {z | d ≤ f z} := by + intro e he v hve + have hn : ¬∀ z ∈ G e, f z ≤ b := he.2 + push Not at hn + obtain ⟨z,hze,hz⟩ := hn + have hh := (abs_le.mp (hjump e z v hze hve)).1 + change d ≤ f v + linarith + +lemma upper_cluster_crossing_cover (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → |f w-f v| ≤ R) + (D : Set E) (ω : Set E) (x y : V) (hx : b < f x) (hy : f y ≤ b) + (hxy : Conn G (ω ∩ D) x y) : + ∃ z, b-R ≤ f z ∧ f z ≤ b ∧ + Conn G (ω ∩ (D \ internalEdges G {z | f z ≤ b})) x z := by + let K := D \ internalEdges G {z | f z ≤ b} + have aux : ∀ z, Conn G (ω ∩ D) x z → + (∃ v, b-R ≤ f v ∧ f v ≤ b ∧ Conn G (ω ∩ K) x v) ∨ + (b < f z ∧ Conn G (ω ∩ K) x z) := by + intro z hz + induction hz with + | refl => exact Or.inr ⟨hx,conn_refl G _ x⟩ + | @tail v w hxv hvw ih => + rcases ih with ih | ⟨hv,hxv⟩ + · exact Or.inl ih + · obtain ⟨e,he,heq⟩ := hvw + have heK : e ∈ K := ⟨he.2,fun hh => (not_le_of_gt hv) (hh v (by rw [heq]; simp))⟩ + have hxw : Conn G (ω ∩ K) x w := hxv.tail ⟨e,⟨he.1,heK⟩,heq⟩ + by_cases hw : f w ≤ b + · have hh := (abs_le.mp (hjump e v w (by rw [heq]; simp) (by rw [heq]; simp))).1 + exact Or.inl ⟨w,by linarith,hw,hxw⟩ + · exact Or.inr ⟨lt_of_not_ge hw,hxw⟩ + rcases aux y hxy with hh | hh + · exact hh + · exact ((not_lt_of_ge hy) hh.1).elim + +lemma connection_restrict_below_peak (D J : Set E) (hJD : J ⊆ D) + (f : V → ℝ) (c : ℝ) (ω : Set E) (x y : V) + (hpeak : ∀ z, Conn G (ω ∩ D) x z → f z ≤ c) + (hxy : Conn G (ω ∩ J) x y) : + Conn G (ω ∩ (J ∩ internalEdges G {z | f z ≤ c})) x y := by + have hh := conn_restrict_cluster_of_subset G (ω ∩ D) x + (Set.inter_subset_inter_right _ hJD) (mem_cluster_self G _ x) hxy + have hs : cluster G (ω ∩ D) x ⊆ {z | f z ≤ c} := hpeak + simpa only [Set.inter_assoc] using conn_mono G + (Set.inter_subset_inter_right _ (internalEdges_mono G hs)) hh + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma adjustedStrictHalfspacePeak_iff_avoid (a : V → ℝ) (d : ℝ) (ω : Set E) (x : V) : + G.adjustedStrictHalfspacePeak a d ω x x ↔ + ω ∉ restrictedHit G.ends (Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z}) x + {z | z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z} := by + constructor + · intro hp ⟨z,⟨hzx,hz⟩,hconn⟩ + exact (not_lt_of_ge hz) (hp z hconn hzx) + · intro hp z hz hzx + exact lt_of_not_ge fun hh => hp ⟨z,⟨hzx,hh⟩,hz⟩ + +lemma strict_peak_slab_band_count_eq (a : V → ℝ) (r l u : ℝ) (hlu : l ≤ u) + (ω : Set E) (x : V) : + G.strictPeakSlabBandCount a r l u ω x = + (restrictedHit G.ends (Percolation.internalEdges G.ends + {z | l-r ≤ G.orbitAdjustedHeight a x z}) x + {z | z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z})ᶜ.indicator + (fun ω => restrictedLayerCount G.ends (Percolation.internalEdges G.ends + {z | u-r ≤ G.orbitAdjustedHeight a x z}) + {z | l ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u} ω x) ω := by + by_cases hp : G.adjustedStrictHalfspacePeak a (l-r) ω x x + · have havoid := (G.adjustedStrictHalfspacePeak_iff_avoid a (l-r) ω x).mp hp + rw [Set.indicator_of_mem havoid] + apply tsum_congr + intro y + have hupper : ∀ z, Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | l-r ≤ G.orbitAdjustedHeight a x z}) x z → G.orbitAdjustedHeight a x z ≤ 0 := by + intro z hz + by_cases hzx : z=x + · simp only [hzx,G.orbitAdjustedHeight_self,le_refl] + · exact (hp z hz hzx).le + have hc : Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | u-r ≤ G.orbitAdjustedHeight a x z}) x y ↔ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | u-r ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ 0}) x y := by + constructor + · intro hh + have hj : Percolation.internalEdges G.ends {z | u-r ≤ G.orbitAdjustedHeight a x z} ⊆ + Percolation.internalEdges G.ends {z | l-r ≤ G.orbitAdjustedHeight a x z} := + Percolation.internalEdges_mono G.ends (fun z hz => by + change u-r ≤ G.orbitAdjustedHeight a x z at hz + change l-r ≤ G.orbitAdjustedHeight a x z + linarith) + have h := connection_restrict_below_peak G.ends _ _ hj (G.orbitAdjustedHeight a x) 0 ω x y hupper hh + apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ ?_) h + rintro e ⟨he,he'⟩ z hze + exact ⟨he z hze,he' z hze⟩ + · exact Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends (fun _ hz => hz.1))) + unfold strictPeakSlabBandTransport + simp only [hp,true_and,←hc,Set.mem_ofPred_eq,and_comm] + split_ifs <;> rfl + · have havoid := mt (G.adjustedStrictHalfspacePeak_iff_avoid a (l-r) ω x).mpr hp + rw [Set.indicator_of_notMem havoid] + apply ENNReal.tsum_eq_zero.mpr + intro y + simp only [strictPeakSlabBandTransport,hp,false_and,ite_false] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakExtension.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..792efff1c3509e6ead709a6661665b392e2566f4 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakExtension.lean @@ -0,0 +1,90 @@ +import OAI.Probability.BenjaminiSchramm.PeakSurgeryGeometry + +namespace OAI + +noncomputable section +open Set +open scoped Classical + +namespace Percolation.BenjaminiSchramm + +lemma walk_first_height_prefix {V : Type*} {H : SimpleGraph V} + (f : V → ℝ) {x y : V} (p : H.Walk x y) (t : ℝ) (hy : t ≤ f y) : + ∃ z, t ≤ f z ∧ ∃ q : H.Walk x z, q.length ≤ p.length ∧ + (∀ v ∈ q.support, v ∈ p.support) ∧ + ∀ v ∈ q.support, v ≠ z → f v < t := by + let S := p.support.toFinset.filter fun v => t ≤ f v + have hyS : y ∈ S := Finset.mem_filter.mpr ⟨List.mem_toFinset.mpr p.end_mem_support,hy⟩ + obtain ⟨z,hzS,hzp,hfirst⟩ := p.exists_mem_support_forall_mem_support_imp_eq S + ⟨y,Finset.mem_filter.mpr ⟨hyS,p.end_mem_support⟩⟩ + have hz : t ≤ f z := (Finset.mem_filter.mp hzS).2 + refine ⟨z,hz,p.takeUntil z hzp,p.length_takeUntil_le_length hzp, + fun v hv => p.support_takeUntil_subset_support hzp hv,?_⟩ + intro v hv hvz + by_contra hn + have hvS : v ∈ S := Finset.mem_filter.mpr + ⟨List.mem_toFinset.mpr (p.support_takeUntil_subset_support hzp hv),le_of_not_gt hn⟩ + exact hvz (hfirst v hvS hv) + +variable {V E : Type*} (G : BondGraph V E) + +lemma lowerFrontierCell_height_bounds (f : V → ℝ) (R b : ℝ) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → |f w-f v| ≤ R) + (x : V) (hx : f x ≤ b) (S F : Set V) {ω : Set E} + (hcell : ω ∈ lowerFrontierCell G (internalEdges G {v | f v ≤ b}) Set.univ x S F) + (u : V) (hu : u ∈ F) : b < f u ∧ f u ≤ b+R := by + have hF : openFrontier G ω S=F := by simpa only [Set.inter_univ] using hcell.2 + have huF : u ∈ openFrontier G ω (cluster G (ω ∩ internalEdges G {v | f v ≤ b}) x) := by + rwa [hcell.1,hF] + have huout := openFrontier_lowerCluster_outside G ω {v | f v ≤ b} x hx huF + obtain ⟨_,v,hv,e,he,heq⟩ := huF + have hvb := conn_internalEdges_end_mem G ω {v | f v ≤ b} hx hv + have hj := (abs_le.mp (hjump e v u (by rw [heq]; simp) (by rw [heq]; simp))).2 + change ¬f u ≤ b at huout + change f v ≤ b at hvb + exact ⟨lt_of_not_ge huout,by linarith⟩ + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_bounded_peak_extension [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) : + ∃ L : ℕ, ∀ x, ∃ z, ∃ w : G.fullGraph.Walk x z, + w.length ≤ L ∧ + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v) ∧ + (2*R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x z ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x z ≤ 3*R) ∧ + ∀ v ∈ w.support, v ≠ z → + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v < + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x z := by + obtain ⟨L,hpath⟩ := G.stationaryOrbitHeight_peak_extension hc hl hq μ hμ hstat hu R hR + refine ⟨L,fun x => ?_⟩ + obtain ⟨y,p,hlen,hmin,hy,_hpeak⟩ := hpath x + let f := G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x + obtain ⟨z,hz,w,hwlen,hsub,hbelow⟩ := walk_first_height_prefix f p (2*R) hy + have hj {v v' : V} (hv : G.fullGraph.Adj v v') : |f v'-f v| ≤ R := by + obtain ⟨⟨e,_he,heq⟩,_hne⟩ := (SimpleGraph.fromEdgeSet_adj _).mp hv + have hh := hjump e v v' (by rw [heq]; simp) (by rw [heq]; simp) + have he : f v'-f v=G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v v' := by + dsimp [f] + rw [G.orbitAdjustedHeight_change_base hc hl _ x v v',add_sub_cancel_left] + rwa [he] + have hzupper : f z ≤ 2*R+R := walk_endpoint_height_bound f R (2*R) hR.le hj w + (by simp only [f,G.orbitAdjustedHeight_self]; positivity) hbelow + refine ⟨z,w,hwlen.trans hlen,fun v hv => hmin v (hsub v hv),⟨hz,by linarith⟩,?_⟩ + intro v hv hvz + exact (hbelow v hv hvz).trans_le hz + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakFiniteEnergy.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakFiniteEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5e523ce6636d209c1d0a18a2d527733b26e3578 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakFiniteEnergy.lean @@ -0,0 +1,99 @@ +import OAI.Probability.BenjaminiSchramm.PeakSurgeryGeometry +import OAI.Probability.BenjaminiSchramm.BlockExposure + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {E : Type*} + +def finiteBondPattern (F : Finset E) (σ : Set E) : Set (Set E) := + {ω | ∀ e ∈ F, (e ∈ ω)=(e ∈ σ)} + +lemma finiteBondPattern_dependsOn (F : Finset E) (σ : Set E) : + DependsOn (fun ω => ω ∈ finiteBondPattern F σ) (F : Set E) := by + intro ω η h + apply propext + constructor + · intro hω e he + exact (h e he).symm.trans (hω e he) + · intro hη e he + exact (h e he).trans (hη e he) + +lemma measurableSet_finiteBondPattern [Countable E] (F : Finset E) (σ : Set E) : + MeasurableSet (finiteBondPattern F σ) := + (Measurable.forall fun e => measurable_const.imp + ((measurable_set_mem e).eq_const (e ∈ σ))).setOf + +lemma finiteBondPattern_probability_lower (p : unitInterval) (F : Finset E) (σ : Set E) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) ≤ law p (finiteBondPattern F σ) := by + let T : Set (F : Set E) := Subtype.val ⁻¹' σ + have he : finiteBondPattern F σ = + (fun ω : Set E => (Subtype.val ⁻¹' ω : Set (F : Set E))) ⁻¹' {T} := by + ext ω + change (∀ e ∈ F, (e ∈ ω)=(e ∈ σ)) ↔ Subtype.val ⁻¹' ω=T + constructor + · intro h + ext e + exact Iff.of_eq (h e e.property) + · intro h e he + exact propext (show (⟨e,he⟩ : (F : Set E)) ∈ Subtype.val ⁻¹' ω ↔ + (⟨e,he⟩ : (F : Set E)) ∈ T from by rw [h]) + have hprob : (law p).real (finiteBondPattern F σ) = + (p : ℝ)^T.ncard*(1-p : ℝ)^Tᶜ.ncard := by + unfold Measure.real + rw [he,←Measure.map_apply (measurable_set_restrict _) (MeasurableSet.singleton T),law_map_restrict] + change (ProbabilityTheory.setBernoulli Set.univ p).real {T}=_ + simpa only [←Set.compl_eq_univ_sdiff] using ProbabilityTheory.setBernoulli_real_singleton p + (Set.subset_univ T) (Set.toFinite Set.univ) + have hcard : T.ncard+Tᶜ.ncard=F.card := by + calc + _ = Nat.card (F : Set E) := Set.ncard_add_ncard_compl T + _ = F.card := by + rw [Nat.card_eq_fintype_card] + exact Fintype.card_coe F + have hmin : 0 ≤ min (p : ℝ) (1-p) := le_min p.2.1 (sub_nonneg.mpr p.2.2) + have hb : (min (p : ℝ) (1-p))^F.card ≤ (p : ℝ)^T.ncard*(1-p : ℝ)^Tᶜ.ncard := by + rw [←hcard,pow_add] + exact mul_le_mul (pow_le_pow_left₀ hmin (min_le_left _ _) _) + (pow_le_pow_left₀ hmin (min_le_right _ _) _) (pow_nonneg hmin _) (pow_nonneg p.2.1 _) + exact ENNReal.ofReal_le_of_le_toReal (hb.trans_eq hprob.symm) + +lemma fresh_finiteBondPattern_cell_lower [Countable E] + (p : unitInterval) (Q : Set E) (A : Set (Set E)) (hA : MeasurableSet A) + (hdep : DependsOn (fun ω => ω ∈ A) Q) + (F : Finset E) (hF : (F : Set E) ⊆ Qᶜ) (σ : Set E) : + law p A*ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) ≤ + law p (A ∩ finiteBondPattern F σ) := by + let B := finiteBondPattern F σ + have hB : MeasurableSet B := measurableSet_finiteBondPattern F σ + have hg : Measurable (B.indicator (fun _ => (1 : ℝ≥0∞))) := measurable_const.indicator hB + have hd : DependsOn (B.indicator (fun _ => (1 : ℝ≥0∞))) Qᶜ := by + change ∀ (ω η : Set E), (∀ e ∈ Qᶜ, (e ∈ ω)=(e ∈ η)) → + B.indicator (fun _ => (1 : ℝ≥0∞)) ω = B.indicator (fun _ => (1 : ℝ≥0∞)) η + intro ω η h + have he := finiteBondPattern_dependsOn F σ (fun e he => h e (hF he)) + change (ω ∈ B)=(η ∈ B) at he + by_cases hω : ω ∈ B + · have hη : η ∈ B := (Iff.of_eq he).mp hω + simp only [Set.indicator_of_mem hω,Set.indicator_of_mem hη] + · have hη : η ∉ B := fun hη => hω ((Iff.of_eq he).mpr hη) + simp only [Set.indicator_of_notMem hω,Set.indicator_of_notMem hη] + have hi := CriticalPercolation.BernoulliProduct.lintegral_indicator_fresh + (fun _ : E => p) Q A hA hdep _ hg hd + rw [CriticalPercolation.BernoulliProduct.law_const] at hi + have he : A.indicator (B.indicator (fun _ => (1 : ℝ≥0∞))) = + (A ∩ B).indicator (fun _ => (1 : ℝ≥0∞)) := by + funext ω + by_cases ha : ω ∈ A <;> by_cases hb : ω ∈ B <;> simp [Set.indicator,ha,hb] + rw [he,lintegral_indicator_fun_one (hA.inter hB),lintegral_indicator_fun_one hB] at hi + exact (mul_le_mul' le_rfl (finiteBondPattern_probability_lower p F σ)).trans_eq hi.symm + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakFirstMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakFirstMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..86cfcc57a2ceec41d79fb1bb507f25ddcf9adcfb --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakFirstMoment.lean @@ -0,0 +1,100 @@ +import OAI.Probability.BenjaminiSchramm.PeakLayerEstimate + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph + +variable {V E : Type*} (G : BondGraph V E) + +def normalizedPeakTransport (ω : Set E) (x y : V) : ℝ≥0∞ := + if y ∈ G.clusterPeaks ω x then ((G.clusterPeaks ω x).encard : ℝ≥0∞)⁻¹ else 0 + +lemma normalizedPeakTransport_aut (φ : G.Aut) (ω : Set E) (x y : V) : + G.normalizedPeakTransport (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.normalizedPeakTransport ω x y := by + unfold normalizedPeakTransport + rw [← φ.clusterPeaks_image, φ.vertex.injective.encard_image] + simp only [Set.mem_image, φ.vertex.injective.eq_iff, exists_eq_right] + +lemma measurable_normalizedPeakTransport [Countable V] [Countable E] (x y : V) : + Measurable (fun ω => G.normalizedPeakTransport ω x y) := by + apply Measurable.ite (G.measurable_mem_clusterPeaks x y).setOf _ measurable_const + apply Measurable.inv + apply (measurable_of_countable (fun n : ℕ∞ => (n : ℝ≥0∞))).comp + apply measurable_encard.comp + exact Measurable.of_eval (fun z => G.measurable_mem_clusterPeaks x z) + +lemma normalizedPeakTransport_outgoing (ω : Set E) (x : V) : + (∑' y, G.normalizedPeakTransport ω x y) ≤ 1 := by + have he : (∑' y, G.normalizedPeakTransport ω x y) = + ∑' _y : G.clusterPeaks ω x, ((G.clusterPeaks ω x).encard : ℝ≥0∞)⁻¹ := by + rw [tsum_subtype (G.clusterPeaks ω x) + (fun _ : V => ((G.clusterPeaks ω x).encard : ℝ≥0∞)⁻¹)] + rfl + rw [he, ENNReal.tsum_set_const] + exact ENNReal.mul_inv_le_one _ + +lemma normalizedPeakTransport_incoming (ω : Set E) (y : V) : + (∑' x, G.normalizedPeakTransport ω x y * G.stabilizerWeight y x) = + G.peakReturn ω y * G.modularMass y (G.cluster ω y) := by + by_cases hp : G.clusterPeak ω y + · rw [peakReturn, ite_eq_left hp, modularMass, ← ENNReal.tsum_mul_left] + apply tsum_congr + intro x + by_cases hx : x ∈ G.cluster ω y + · have hxy : y ∈ G.clusterPeaks ω x := ⟨hx.symm,hp⟩ + rw [normalizedPeakTransport, ite_eq_left hxy, ite_eq_left hx, + G.clusterPeaks_eq_of_reachable hx.symm] + · have hxy : y ∉ G.clusterPeaks ω x := fun hh => hx hh.1.symm + simp only [normalizedPeakTransport, ite_eq_right hxy, ite_eq_right hx, + zero_mul, mul_zero] + · rw [peakReturn, ite_eq_right hp, zero_mul] + apply ENNReal.tsum_eq_zero.mpr + intro x + have hxy : y ∉ G.clusterPeaks ω x := fun hh => hp hh.2 + simp only [normalizedPeakTransport, ite_eq_right hxy, zero_mul] + +lemma normalizedPeakTransport_eq_reverse (ω : Set E) (x y : V) : + G.normalizedPeakTransport ω x y = + if x ∈ G.cluster ω y then G.peakReturn ω y else 0 := by + by_cases hp : G.clusterPeak ω y + · by_cases hx : x ∈ G.cluster ω y + · have hxy : y ∈ G.clusterPeaks ω x := ⟨hx.symm,hp⟩ + rw [normalizedPeakTransport, ite_eq_left hxy, ite_eq_left hx, peakReturn, + ite_eq_left hp, G.clusterPeaks_eq_of_reachable hx.symm] + · have hxy : y ∉ G.clusterPeaks ω x := fun hh => hx hh.1.symm + simp only [normalizedPeakTransport, ite_eq_right hxy, ite_eq_right hx] + · have hxy : y ∉ G.clusterPeaks ω x := fun hh => hp hh.2 + simp only [normalizedPeakTransport, ite_eq_right hxy, peakReturn, ite_eq_right hp, + ite_self] + +theorem expected_peakReturn_modularMass_sum [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, G.peakReturn ω x * G.modularMass x (G.cluster ω x) ∂G.law p) ≤ + ((G.orbitRepresentatives hq).roots.card : ℝ≥0∞) := by + rw [← show (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ∑' y, G.normalizedPeakTransport ω x y ∂G.law p) = + ∑ y ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, G.peakReturn ω y * G.modularMass y (G.cluster ω y) ∂G.law p from by + rw [OrbitRepresentatives.random_tilted_transport G (G.orbitRepresentatives hq) hc hl p + G.normalizedPeakTransport G.measurable_normalizedPeakTransport G.normalizedPeakTransport_aut] + simp_rw [G.normalizedPeakTransport_incoming]] + calc + _ ≤ ∑ _x ∈ (G.orbitRepresentatives hq).roots, (1 : ℝ≥0∞) := by + apply Finset.sum_le_sum + intro x _ + exact (lintegral_mono fun ω => G.normalizedPeakTransport_outgoing ω x).trans_eq + (by simp) + _ = _ := by simp + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakFrontierTruncation.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakFrontierTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f587f5e669ee95dc9ae18a9eb514353bb20db241 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakFrontierTruncation.lean @@ -0,0 +1,47 @@ +import OAI.Probability.BenjaminiSchramm.PeakSurgeryProbability + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {E : Type*} + +lemma small_frontier_probability_lower (p : unitInterval) + (A : Set (Set E)) (Z : Set E → ℝ≥0∞) (hZ : Measurable Z) + (a M N : ℝ) (ha : 0 ≤ a) (hM : 0 ≤ M) (hN : 0 < N) + (hlower : ENNReal.ofReal a ≤ law p A) + (hmoment : (∫⁻ ω, Z ω ∂law p) ≤ ENNReal.ofReal M) + (hscale : 2*M ≤ N*a) : + ENNReal.ofReal (a/2) ≤ law p (A ∩ {ω | Z ω ≤ ENNReal.ofReal N}) := by + let B : Set (Set E) := {ω | Z ω ≤ ENNReal.ofReal N} + have hB : MeasurableSet B := measurableSet_le hZ measurable_const + have hbad : law p (A \ B) ≤ ENNReal.ofReal (M/N) := by + calc + _ ≤ law p {ω | ENNReal.ofReal N ≤ Z ω} := measure_mono fun ω hω => by + have hh : ¬ Z ω ≤ ENNReal.ofReal N := hω.2 + exact le_of_not_ge hh + _ ≤ (∫⁻ ω, Z ω ∂law p)/ENNReal.ofReal N := + meas_ge_le_lintegral_div hZ.aemeasurable + (ENNReal.ofReal_ne_zero_iff.mpr hN) ENNReal.ofReal_ne_top + _ ≤ ENNReal.ofReal M/ENNReal.ofReal N := ENNReal.div_le_div_right hmoment _ + _ = _ := (ENNReal.ofReal_div_of_pos hN).symm + have hbadreal : (law p).real (A \ B) ≤ M/N := by + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top hbad + rwa [ENNReal.toReal_ofReal (div_nonneg hM hN.le)] at hh + have hlowreal : a ≤ (law p).real A := by + have hh := ENNReal.toReal_mono (measure_ne_top _ _) hlower + rwa [ENNReal.toReal_ofReal ha] at hh + have hdiv : M/N ≤ a/2 := (div_le_iff₀ hN).mpr (by nlinarith) + have hsplit := measureReal_sdiff_add_inter (μ := law p) (s := A) hB + apply ENNReal.ofReal_le_of_le_toReal + change a/2 ≤ (law p).real (A ∩ B) + linarith + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakHalfspaceGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakHalfspaceGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a9bff5f5dc1cfae76799010f7f755b88f58c91b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakHalfspaceGeometry.lean @@ -0,0 +1,120 @@ +import OAI.Probability.BenjaminiSchramm.CeilingBandTransport +import OAI.Probability.BenjaminiSchramm.FreshSlabConcatenation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def adjustedHalfspaceConn (a : V → ℝ) (b : ℝ) (ω : Set E) (base x y : V) : Prop := + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | b ≤ G.orbitAdjustedHeight a base z}) x y + +def adjustedStrictHalfspacePeak (a : V → ℝ) (b : ℝ) (ω : Set E) (base x : V) : Prop := + ∀ z, G.adjustedHalfspaceConn a b ω base x z → z ≠ x → G.orbitAdjustedHeight a x z < 0 + +lemma adjustedStrictHalfspacePeak_unique + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) (b : ℝ) + (ω : Set E) (base x y : V) + (hxy : G.adjustedHalfspaceConn a b ω base x y) + (hx : G.adjustedStrictHalfspacePeak a b ω base x) + (hy : G.adjustedStrictHalfspacePeak a b ω base y) : x=y := by + by_contra hne + have hh := hx y hxy (Ne.symm hne) + have hh' := hy x (Percolation.conn_symm G.ends _ hxy) hne + rw [G.orbitAdjustedHeight_reverse hc hl a x y] at hh' + linarith + +def strictPeakBandTransport (a : V → ℝ) (r l u : ℝ) + (ω : Set E) (y x : V) : ℝ≥0∞ := + if G.adjustedHalfspaceConn a (-r) ω y y x ∧ + G.adjustedStrictHalfspacePeak a (-r) ω y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l then 1 else 0 + +def strictPeakSlabBandTransport (a : V → ℝ) (r l u : ℝ) + (ω : Set E) (x y : V) : ℝ≥0∞ := + if G.adjustedStrictHalfspacePeak a (l-r) ω x x ∧ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | u-r ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ 0}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u then 1 else 0 + +def strictPeakSlabBandCount (a : V → ℝ) (r l u : ℝ) + (ω : Set E) (x : V) : ℝ≥0∞ := ∑' y, G.strictPeakSlabBandTransport a r l u ω x y + +lemma strictPeakBandTransport_outgoing + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) (r l u : ℝ) + (ω : Set E) (y : V) : + (∑' x, G.strictPeakBandTransport a r l u ω y x) ≤ + if ω ∈ restrictedHit G.ends (Percolation.internalEdges G.ends + {z | -r ≤ G.orbitAdjustedHeight a y z}) y + {z | -u ≤ G.orbitAdjustedHeight a y z} then 1 else 0 := by + let P (x : V) := G.adjustedHalfspaceConn a (-r) ω y y x ∧ + G.adjustedStrictHalfspacePeak a (-r) ω y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l + by_cases hex : ∃ x, P x + · obtain ⟨x,hx⟩ := hex + have hhit : ω ∈ restrictedHit G.ends (Percolation.internalEdges G.ends + {z | -r ≤ G.orbitAdjustedHeight a y z}) y {z | -u ≤ G.orbitAdjustedHeight a y z} := + ⟨x,hx.2.2.1,hx.1⟩ + rw [ite_eq_left hhit,tsum_eq_single x] + · exact (ite_eq_left hx).le + · intro z hzx + apply ite_eq_right + intro hz + exact hzx (G.adjustedStrictHalfspacePeak_unique hc hl a (-r) ω y z x + ((Percolation.conn_symm G.ends _ hz.1).trans hx.1) hz.2.1 hx.2.1) + · have hz (x : V) : G.strictPeakBandTransport a r l u ω y x=0 := + ite_eq_right (fun h => hex ⟨x,h⟩) + rw [ENNReal.tsum_eq_zero.mpr hz] + exact bot_le + +lemma strictPeakSlabBandTransport_incoming_lower + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) (r l u : ℝ) + (ω : Set E) (x y : V) : + ENNReal.ofReal (Real.exp l)*G.strictPeakSlabBandTransport a r l u ω x y ≤ + G.strictPeakBandTransport a r l u ω y x * + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) := by + by_cases hp : G.adjustedStrictHalfspacePeak a (l-r) ω x x ∧ + Percolation.Conn G.ends (ω ∩ Percolation.internalEdges G.ends + {z | u-r ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ 0}) x y ∧ + l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u + · have hconn : G.adjustedHalfspaceConn a (-r) ω y y x := by + apply Percolation.conn_symm G.ends _ + apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hp.2.1 + intro z hz + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + change u-r ≤ G.orbitAdjustedHeight a x z ∧ _ at hz + change -r ≤ G.orbitAdjustedHeight a y z + linarith [hp.2.2.2,hz.1] + have hpeak : G.adjustedStrictHalfspacePeak a (-r) ω y x := by + intro z hz hzx + apply hp.1 z _ hzx + apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ + (Percolation.internalEdges_mono G.ends ?_)) hz + intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x y v + change -r ≤ G.orbitAdjustedHeight a y v at hv + change l-r ≤ G.orbitAdjustedHeight a x v + linarith [hp.2.2.1] + have ht : G.adjustedHalfspaceConn a (-r) ω y y x ∧ + G.adjustedStrictHalfspacePeak a (-r) ω y x ∧ + -u ≤ G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ -l := by + rw [G.orbitAdjustedHeight_reverse hc hl a x y] + exact ⟨hconn,hpeak,by linarith [hp.2.2.2],by linarith [hp.2.2.1]⟩ + simp only [strictPeakSlabBandTransport,strictPeakBandTransport,ite_eq_left hp, + ite_eq_left ht,mul_one,one_mul] + exact ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr hp.2.2.1) + · simp only [strictPeakSlabBandTransport,ite_eq_right hp,mul_zero] + exact bot_le + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakHalfspaceTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakHalfspaceTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..412be79ba47e7173a41ad3472c3d048a42b5728e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakHalfspaceTransport.lean @@ -0,0 +1,134 @@ +import OAI.Probability.BenjaminiSchramm.PeakHalfspaceGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma adjustedHalfspaceConn_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (b : ℝ) + (φ : G.Aut) (ω : Set E) (base x y : V) : + G.adjustedHalfspaceConn a b (φ.edge '' ω) (φ.vertex base) (φ.vertex x) (φ.vertex y) ↔ + G.adjustedHalfspaceConn a b ω base x y := by + have hD : φ.vertex ⁻¹' {z | b ≤ G.orbitAdjustedHeight a (φ.vertex base) z} = + {z | b ≤ G.orbitAdjustedHeight a base z} := by + ext z + simp only [Set.mem_preimage,Set.mem_ofPred_eq,G.orbitAdjustedHeight_aut a ha] + have hmask : φ.edge ⁻¹' (φ.edge '' ω ∩ Percolation.internalEdges G.ends + {z | b ≤ G.orbitAdjustedHeight a (φ.vertex base) z}) = + ω ∩ Percolation.internalEdges G.ends {z | b ≤ G.orbitAdjustedHeight a base z} := by + rw [Set.preimage_inter,Set.preimage_image_eq _ φ.edge.injective, + ←Percolation.internalEdges_aut_preimage G.ends φ.preserves,hD] + unfold adjustedHalfspaceConn + rw [←Percolation.conn_aut_iff G.ends φ.preserves,hmask] + +lemma adjustedStrictHalfspacePeak_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (b : ℝ) + (φ : G.Aut) (ω : Set E) (base x : V) : + G.adjustedStrictHalfspacePeak a b (φ.edge '' ω) (φ.vertex base) (φ.vertex x) = + G.adjustedStrictHalfspacePeak a b ω base x := by + apply propext + constructor + · intro h z hz hzx + have hh := h (φ.vertex z) ((G.adjustedHalfspaceConn_aut a ha b φ ω base x z).mpr hz) + (fun he => hzx (φ.vertex.injective he)) + simpa only [G.orbitAdjustedHeight_aut a ha] using hh + · intro h z hz hzx + obtain ⟨z,rfl⟩ := φ.vertex.surjective z + have hh := h z ((G.adjustedHalfspaceConn_aut a ha b φ ω base x z).mp hz) + (fun he => hzx (congrArg φ.vertex he)) + simpa only [G.orbitAdjustedHeight_aut a ha] using hh + +lemma strictPeakBandTransport_aut (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (r l u : ℝ) + (φ : G.Aut) (ω : Set E) (y x : V) : + G.strictPeakBandTransport a r l u (φ.edge '' ω) (φ.vertex y) (φ.vertex x) = + G.strictPeakBandTransport a r l u ω y x := by + simp only [strictPeakBandTransport,G.adjustedHalfspaceConn_aut a ha, + G.adjustedStrictHalfspacePeak_aut a ha,G.orbitAdjustedHeight_aut a ha] + +variable [Countable V] [Countable E] + +lemma measurable_adjustedHalfspaceConn (a : V → ℝ) (b : ℝ) (base x y : V) : + Measurable (fun ω => G.adjustedHalfspaceConn a b ω base x y) := by + have hm : Measurable (fun ω : Set E => ω ∩ Percolation.internalEdges G.ends + {z | b ≤ G.orbitAdjustedHeight a base z}) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact (Percolation.measurableSet_conn G.ends x y).mem.comp hm + +lemma measurable_adjustedStrictHalfspacePeak (a : V → ℝ) (b : ℝ) (base x : V) : + Measurable (fun ω => G.adjustedStrictHalfspacePeak a b ω base x) := by + exact Measurable.forall fun z => (G.measurable_adjustedHalfspaceConn a b base x z).imp + (measurable_const.imp measurable_const) + +lemma measurable_strictPeakBandTransport (a : V → ℝ) (r l u : ℝ) (y x : V) : + Measurable (fun ω => G.strictPeakBandTransport a r l u ω y x) := by + exact Measurable.ite (((G.measurable_adjustedHalfspaceConn a (-r) y y x).and + ((G.measurable_adjustedStrictHalfspacePeak a (-r) y x).and measurable_const)).setOf) + measurable_const measurable_const + +lemma measurable_strictPeakSlabBandTransport (a : V → ℝ) (r l u : ℝ) (x y : V) : + Measurable (fun ω => G.strictPeakSlabBandTransport a r l u ω x y) := by + have hm : Measurable (fun ω : Set E => ω ∩ Percolation.internalEdges G.ends + {z | u-r ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ 0}) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact Measurable.ite (((G.measurable_adjustedStrictHalfspacePeak a (l-r) x x).and + (((Percolation.measurableSet_conn G.ends x y).mem.comp hm).and measurable_const)).setOf) + measurable_const measurable_const + +lemma measurable_strictPeakSlabBandCount (a : V → ℝ) (r l u : ℝ) (x : V) : + Measurable (fun ω => G.strictPeakSlabBandCount a r l u ω x) := + Measurable.tsum fun y => G.measurable_strictPeakSlabBandTransport a r l u x y + +theorem expected_strictPeakSlabBandCount_bound + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (hapos : ∀ x, 0 < a x) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) (p : unitInterval) (r l u : ℝ) : + ENNReal.ofReal (Real.exp l)* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.strictPeakSlabBandCount a r l u ω x ∂G.law p)) ≤ + ∑ y ∈ O.roots, ENNReal.ofReal (a y)*G.law p + (restrictedHit G.ends (Percolation.internalEdges G.ends + {z | -r ≤ G.orbitAdjustedHeight a y z}) y {z | -u ≤ G.orbitAdjustedHeight a y z}) := by + have hin (ω : Set E) (x : V) : + ENNReal.ofReal (Real.exp l)*G.strictPeakSlabBandCount a r l u ω x ≤ + ∑' y, G.strictPeakBandTransport a r l u ω y x* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) := by + rw [strictPeakSlabBandCount,←ENNReal.tsum_mul_left] + exact ENNReal.tsum_le_tsum fun y => + G.strictPeakSlabBandTransport_incoming_lower hc hl a r l u ω x y + calc + _ = ∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, ENNReal.ofReal (Real.exp l)*G.strictPeakSlabBandCount a r l u ω x ∂G.law p) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + rw [lintegral_const_mul _ (G.measurable_strictPeakSlabBandCount a r l u x)] + ring + _ ≤ ∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, ∑' y, G.strictPeakBandTransport a r l u ω y x* + ENNReal.ofReal (Real.exp (G.orbitAdjustedHeight a x y)) ∂G.law p) := + Finset.sum_le_sum fun x _ => mul_le_mul' le_rfl (lintegral_mono fun ω => hin ω x) + _ = ∑ y ∈ O.roots, ENNReal.ofReal (a y)* + (∫⁻ ω, ∑' x, G.strictPeakBandTransport a r l u ω y x ∂G.law p) := + (OrbitRepresentatives.random_normalized_tilted_transport G O hc hl a hapos ha p + (G.strictPeakBandTransport a r l u) (G.measurable_strictPeakBandTransport a r l u) + (G.strictPeakBandTransport_aut a ha r l u)).symm + _ ≤ _ := by + apply Finset.sum_le_sum + intro y _ + apply mul_le_mul' le_rfl + apply (lintegral_mono fun ω => G.strictPeakBandTransport_outgoing hc hl a r l u ω y).trans_eq + simpa only [Set.indicator,Pi.one_apply] using lintegral_indicator_one (μ := G.law p) + (measurableSet_restrictedHit G.ends _ y _) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakLayerCost.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakLayerCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..70df1ca6d82c0149db1a8623276b8f301839a287 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakLayerCost.lean @@ -0,0 +1,152 @@ +import OAI.Probability.BenjaminiSchramm.SubcriticalPeakConditional + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma integer_downward_layer_cost {V : Type*} (f : V → ℤ) (P : V → Prop) (g : ℕ → ℝ≥0∞) : + (∑' l : ℕ, g l*(∑' y, if f y= -(l : ℤ) ∧ P y then (1 : ℝ≥0∞) else 0))= + ∑' y, if f y ≤ 0 ∧ P y then g (-f y).toNat else 0 := by + simp_rw [←ENNReal.tsum_mul_left] + rw [ENNReal.tsum_comm] + apply tsum_congr + intro y + by_cases hP : P y + · by_cases hf : f y ≤ 0 + · have hd : f y= -(((-f y).toNat : ℕ) : ℤ) := by + rw [Int.toNat_of_nonneg (neg_nonneg.mpr hf)] + ring + rw [ite_eq_left ⟨hf,hP⟩,tsum_eq_single (-f y).toNat] + · rw [ite_eq_left (show f y= -(((-f y).toNat : ℕ) : ℤ) ∧ P y from ⟨hd,hP⟩),mul_one] + · intro l hl + have hne : f y ≠ -(l : ℤ) := by + intro hh + have hcast : (((-f y).toNat : ℕ) : ℤ)=(l : ℤ) := by omega + exact hl (Int.ofNat_inj.mp hcast).symm + rw [ite_eq_right (fun h => hne h.1),mul_zero] + · rw [ite_eq_right (fun h => hf h.1)] + apply ENNReal.tsum_eq_zero.mpr + intro l + have hne : f y ≠ -(l : ℤ) := by omega + rw [ite_eq_right (fun h => hne h.1),mul_zero] + · rw [ite_eq_right (fun h => hP h.2)] + apply ENNReal.tsum_eq_zero.mpr + intro l + rw [ite_eq_right (fun h => hP h.2),mul_zero] + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def downwardLayerCost (a : V → ℝ) (R : ℝ) (g : ℕ → ℝ) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' l : ℕ, ENNReal.ofReal (g l)*restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y= -(l : ℤ)} ω x + +lemma downwardLayerCost_eq_vertex_sum (a : V → ℝ) (R : ℝ) (g : ℕ → ℝ) (ω : Set E) (x : V) : + G.downwardLayerCost a R g ω x= + ∑' y, if G.adjustedLayerIndex a R 0 x y ≤ 0 ∧ Percolation.Conn G.ends ω x y then + ENNReal.ofReal (g (-G.adjustedLayerIndex a R 0 x y).toNat) else 0 := by + unfold downwardLayerCost restrictedLayerCount + calc + _ = ∑' l : ℕ, ENNReal.ofReal (g l)*(∑' y, if G.adjustedLayerIndex a R 0 x y= -(l : ℤ) ∧ + Percolation.Conn G.ends ω x y then (1 : ℝ≥0∞) else 0) := by + apply tsum_congr + intro l + apply congrArg (fun b => ENNReal.ofReal (g l)*b) + apply tsum_congr + intro y + by_cases hh : G.adjustedLayerIndex a R 0 x y= -(l : ℤ) ∧ Percolation.Conn G.ends ω x y + · have hh' : y ∈ {z | G.adjustedLayerIndex a R 0 x z= -(l : ℤ)} ∧ Percolation.Conn G.ends ω x y := hh + simp only [Set.inter_univ] + rw [ite_eq_left hh',ite_eq_left hh] + · have hh' : ¬(y ∈ {z | G.adjustedLayerIndex a R 0 x z= -(l : ℤ)} ∧ Percolation.Conn G.ends ω x y) := hh + simp only [Set.inter_univ] + rw [ite_eq_right hh',ite_eq_right hh] + _ = _ := integer_downward_layer_cost _ _ _ + +lemma downwardLayerCost_of_exact_cluster (a : V → ℝ) (R : ℝ) (g : ℕ → ℝ) + (ω : Set E) (x : V) (S : Finset V) (hS : Percolation.cluster G.ends ω x=(S : Set V)) + (hbelow : ∀ y ∈ S, G.adjustedLayerIndex a R 0 x y ≤ 0) : + G.downwardLayerCost a R g ω x= + ∑ y ∈ S, ENNReal.ofReal (g (-G.adjustedLayerIndex a R 0 x y).toNat) := by + rw [G.downwardLayerCost_eq_vertex_sum] + rw [tsum_eq_sum (s := S)] + · apply Finset.sum_congr rfl + intro y hy + have hxy : Percolation.Conn G.ends ω x y := by + change y ∈ Percolation.cluster G.ends ω x + rw [hS] + exact hy + exact ite_eq_left ⟨hbelow y hy,hxy⟩ + · intro y hy + apply ite_eq_right + intro hh + have hys : y ∈ Percolation.cluster G.ends ω x := hh.2 + rw [hS] at hys + exact hy hys + +variable [Countable V] [Countable E] + +lemma measurable_downwardLayerCost (a : V → ℝ) (R : ℝ) (g : ℕ → ℝ) (x : V) : + Measurable (fun ω => G.downwardLayerCost a R g ω x) := + Measurable.tsum fun _l => measurable_const.mul (measurable_restrictedLayerCount G.ends _ _ x) + +theorem peakSurvivalCostMoment_eq (O : G.OrbitRepresentatives) (a : V → ℝ) + (R : ℝ) (p : unitInterval) (g : ℕ → ℝ) (n : ℕ) : + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => G.downwardLayerCost a R g η x) ω ∂G.law p))= + ∑' l, ENNReal.ofReal (g l)*G.peakSurvivalLayerMoment O a R p n l := by + have he (x : V) : + (fun ω => {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => G.downwardLayerCost a R g η x) ω)= + (fun ω => ∑' l, ENNReal.ofReal (g l)* + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y= -(l : ℤ)} η x) ω) := by + funext ω + by_cases hω : ω ∈ {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x} + · simp only [Set.indicator_of_mem hω,downwardLayerCost] + · simp only [Set.indicator_of_notMem hω,mul_zero,tsum_zero] + have hroot (x : V) : + (∫⁻ ω, {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => G.downwardLayerCost a R g η x) ω ∂G.law p)= + ∑' l, ENNReal.ofReal (g l)*(∫⁻ ω, + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y= -(l : ℤ)} η x) ω ∂G.law p) := by + have hmA : MeasurableSet {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x} := + measurableSet_lt measurable_const (G.measurable_peakDownBandCount a _ _ x) + rw [he] + rw [lintegral_tsum (f := fun j ω => ENNReal.ofReal (g j)* + {η | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) η x}.indicator + (fun η => restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y= -(j : ℤ)} η x) ω) + (fun j => (measurable_const.mul + ((measurable_restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y= -(j : ℤ)} x).indicator hmA)).aemeasurable)] + apply tsum_congr + intro l + exact lintegral_const_mul _ ((measurable_restrictedLayerCount G.ends Set.univ + {y | G.adjustedLayerIndex a R 0 x y= -(l : ℤ)} x).indicator hmA) + simp_rw [hroot,←ENNReal.tsum_mul_left] + rw [←Summable.tsum_finsetSum (fun _ _ => ENNReal.summable)] + apply tsum_congr + intro l + unfold peakSurvivalLayerMoment + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakLayerEstimate.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakLayerEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..669f8b4948072674edb146d94f5e933b52ab817a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakLayerEstimate.lean @@ -0,0 +1,161 @@ +import OAI.Probability.CriticalPercolation.Modular.PeakReturn + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph + +variable {V E : Type*} (G : BondGraph V E) + +def boundedPeakTransport (N : ℕ) (ω : Set E) (x y : V) : ℝ≥0∞ := + if y ∈ G.clusterPeaks ω x ∧ G.peakBound N ω x then 1 else 0 + +def boundedPeakMass (N : ℕ) (ω : Set E) (x : V) : ℝ≥0∞ := + if G.clusterPeak ω x ∧ G.peakBound N ω x then G.modularMass x (G.cluster ω x) else 0 + +lemma measurable_boundedPeakTransport [Countable V] [Countable E] (N : ℕ) (x y : V) : + Measurable (fun ω => G.boundedPeakTransport N ω x y) := by + exact measurable_const.ite + (((G.measurable_mem_clusterPeaks x y).and (G.measurable_peakBound N x)).setOf) + measurable_const + +lemma boundedPeakTransport_aut (N : ℕ) (φ : G.Aut) (ω : Set E) (x y : V) : + G.boundedPeakTransport N (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.boundedPeakTransport N ω x y := by + unfold boundedPeakTransport + rw [← φ.clusterPeaks_image, φ.peakBound_iff] + simp only [Set.mem_image, φ.vertex.injective.eq_iff, exists_eq_right] + +lemma boundedPeakTransport_outgoing (N : ℕ) (ω : Set E) (x : V) : + (∑' y, G.boundedPeakTransport N ω x y) ≤ N := by + by_cases hb : G.peakBound N ω x + · obtain ⟨S,hS,hcover⟩ := hb + rw [tsum_eq_sum (s := S) (fun y hy => by + simp only [boundedPeakTransport] + exact ite_eq_right (fun hh => hy (hcover hh.1)))] + calc + _ ≤ ∑ _y ∈ S, (1 : ℝ≥0∞) := Finset.sum_le_sum fun y _ => by + simp only [boundedPeakTransport] + split_ifs <;> simp + _ = (S.card : ℝ≥0∞) := by simp + _ ≤ N := by exact_mod_cast hS + · simp [boundedPeakTransport, hb] + +lemma boundedPeakTransport_incoming (N : ℕ) (ω : Set E) (y : V) : + (∑' x, G.boundedPeakTransport N ω x y * G.stabilizerWeight y x) = + G.boundedPeakMass N ω y := by + by_cases hy : G.clusterPeak ω y ∧ G.peakBound N ω y + · rw [boundedPeakMass, ite_eq_left hy] + apply tsum_congr + intro x + by_cases hx : x ∈ G.cluster ω y + · have hb : G.peakBound N ω x := + (G.peakBound_iff_of_reachable N hx).mp hy.2 + have hxy : y ∈ G.clusterPeaks ω x ∧ G.peakBound N ω x := ⟨⟨hx.symm,hy.1⟩,hb⟩ + simp only [boundedPeakTransport, ite_eq_left hxy, one_mul, ite_eq_left hx] + · have hn : ¬ (y ∈ G.clusterPeaks ω x ∧ G.peakBound N ω x) := + fun hh => hx hh.1.1.symm + simp only [boundedPeakTransport, ite_eq_right hn, zero_mul, ite_eq_right hx] + · rw [boundedPeakMass, ite_eq_right hy] + apply ENNReal.tsum_eq_zero.mpr + intro x + have hn : ¬ (y ∈ G.clusterPeaks ω x ∧ G.peakBound N ω x) := by + intro hh + exact hy ⟨hh.1.2,(G.peakBound_iff_of_reachable N hh.1.1).mp hh.2⟩ + simp only [boundedPeakTransport, ite_eq_right hn, zero_mul] + +theorem expected_boundedPeakMass_sum [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) (N : ℕ) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, G.boundedPeakMass N ω x ∂G.law p) ≤ + ((G.orbitRepresentatives hq).roots.card : ℝ≥0∞) * N := by + rw [← show (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ∑' y, G.boundedPeakTransport N ω x y ∂G.law p) = + ∑ y ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, G.boundedPeakMass N ω y ∂G.law p from by + rw [OrbitRepresentatives.random_tilted_transport G (G.orbitRepresentatives hq) hc hl p + (G.boundedPeakTransport N) (G.measurable_boundedPeakTransport N) + (G.boundedPeakTransport_aut N)] + simp_rw [G.boundedPeakTransport_incoming]] + calc + _ ≤ ∑ _x ∈ (G.orbitRepresentatives hq).roots, (N : ℝ≥0∞) := by + apply Finset.sum_le_sum + intro x _ + exact (lintegral_mono fun ω => G.boundedPeakTransport_outgoing N ω x).trans_eq + (by simp) + _ = _ := by simp [nsmul_eq_mul] + +lemma measurable_boundedPeakMass [Countable V] [Countable E] (N : ℕ) (x : V) : + Measurable (fun ω => G.boundedPeakMass N ω x) := by + exact (G.measurable_modularClusterMass x x).ite + (((G.measurable_clusterPeak x).and (G.measurable_peakBound N x)).setOf) + measurable_const + +lemma boundedPeakMass_aut (N : ℕ) (φ : G.Aut) (ω : Set E) (x : V) : + G.boundedPeakMass N (φ.edge '' ω) (φ.vertex x) = G.boundedPeakMass N ω x := by + unfold boundedPeakMass + rw [← φ.cluster_image, φ.modularMass_image, φ.clusterPeak_iff, φ.peakBound_iff] + +theorem expected_boundedPeakMass [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) (N : ℕ) (x : V) : + (∫⁻ ω, G.boundedPeakMass N ω x ∂G.law p) ≤ + ((G.orbitRepresentatives hq).roots.card : ℝ≥0∞) * N := by + obtain ⟨y,hy,φ,rfl⟩ := (G.orbitRepresentatives hq).cover x + have he : (∫⁻ ω, G.boundedPeakMass N ω (φ.vertex y) ∂G.law p) = + ∫⁻ ω, G.boundedPeakMass N ω y ∂G.law p := by + conv_lhs => rw [← G.law_map_aut p φ] + rw [lintegral_map (G.measurable_boundedPeakMass N _) (BernoulliProduct.measurable_image_equiv φ.edge)] + simp only [G.boundedPeakMass_aut] + rw [he] + exact (Finset.single_le_sum (fun _ _ => zero_le) hy).trans + (G.expected_boundedPeakMass_sum hc hl hq p N) + +def boundedPeakUpperLayerCount (N : ℕ) (a : ℝ≥0∞) (ω : Set E) (y : V) : ℝ≥0∞ := + if G.clusterPeak ω y ∧ G.peakBound N ω y then + ∑' x, if x ∈ G.cluster ω y ∧ a ≤ G.stabilizerWeight y x then 1 else 0 + else 0 + +lemma measurable_boundedPeakUpperLayerCount [Countable V] [Countable E] + (N : ℕ) (a : ℝ≥0∞) (y : V) : + Measurable (fun ω => G.boundedPeakUpperLayerCount N a ω y) := by + apply Measurable.ite + (((G.measurable_clusterPeak y).and (G.measurable_peakBound N y)).setOf) _ measurable_const + apply Measurable.tsum + intro x + exact measurable_const.ite (((G.measurable_reachable y x).and measurable_const).setOf) + measurable_const + +lemma weighted_boundedPeakUpperLayerCount (N : ℕ) (a : ℝ≥0∞) (ω : Set E) (y : V) : + a * G.boundedPeakUpperLayerCount N a ω y ≤ G.boundedPeakMass N ω y := by + unfold boundedPeakUpperLayerCount boundedPeakMass + split_ifs with hp + · rw [modularMass, ← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro x + by_cases hx : x ∈ G.cluster ω y + · simp only [hx, true_and, ↓reduceIte] + by_cases ha : a ≤ G.stabilizerWeight y x + · simpa only [ite_eq_left ha, mul_one] using ha + · simp [ha] + · simp [hx] + · simp + +theorem expected_boundedPeakUpperLayerCount [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) (N : ℕ) (a : ℝ≥0∞) (y : V) : + a * (∫⁻ ω, G.boundedPeakUpperLayerCount N a ω y ∂G.law p) ≤ + ((G.orbitRepresentatives hq).roots.card : ℝ≥0∞) * N := by + rw [← lintegral_const_mul _ (G.measurable_boundedPeakUpperLayerCount N a y)] + exact (lintegral_mono fun ω => G.weighted_boundedPeakUpperLayerCount N a ω y).trans + (G.expected_boundedPeakMass hc hl hq p N y) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakLayerTransport.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakLayerTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3d210ad65d51ab56e32ff9d2b692c2dac99bfa6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakLayerTransport.lean @@ -0,0 +1,103 @@ +import OAI.Probability.BenjaminiSchramm.PeakFirstMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph + +variable {V E : Type*} (G : BondGraph V E) + +def peakBandTransport (a b : ℝ≥0∞) (ω : Set E) (x y : V) : ℝ≥0∞ := + G.normalizedPeakTransport ω x y * + if a ≤ G.stabilizerWeight y x ∧ G.stabilizerWeight y x ≤ b then 1 else 0 + +def reverseWeightHit (b : ℝ≥0∞) (x : V) : Set (Set E) := + {ω | ∃ y, y ∈ G.cluster ω x ∧ G.stabilizerWeight y x ≤ b} + +def clusterBandCount (a b : ℝ≥0∞) (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, if y ∈ G.cluster ω x ∧ a ≤ G.stabilizerWeight x y ∧ + G.stabilizerWeight x y ≤ b then 1 else 0 + +lemma measurable_peakBandTransport [Countable V] [Countable E] + (a b : ℝ≥0∞) (x y : V) : + Measurable (fun ω => G.peakBandTransport a b ω x y) := + (G.measurable_normalizedPeakTransport x y).mul_const _ + +lemma peakBandTransport_aut (a b : ℝ≥0∞) (φ : G.Aut) (ω : Set E) (x y : V) : + G.peakBandTransport a b (φ.edge '' ω) (φ.vertex x) (φ.vertex y) = + G.peakBandTransport a b ω x y := by + simp only [peakBandTransport, G.normalizedPeakTransport_aut, Aut.stabilizerWeight] + +lemma measurableSet_reverseWeightHit [Countable V] [Countable E] + (b : ℝ≥0∞) (x : V) : MeasurableSet (G.reverseWeightHit b x) := + (Measurable.exists fun y => (G.measurable_reachable x y).and measurable_const).setOf + +lemma peakBandTransport_outgoing (a b : ℝ≥0∞) (ω : Set E) (x : V) : + (∑' y, G.peakBandTransport a b ω x y) ≤ + if ω ∈ G.reverseWeightHit b x then 1 else 0 := by + by_cases hh : ω ∈ G.reverseWeightHit b x + · rw [ite_eq_left hh] + apply le_trans _ (G.normalizedPeakTransport_outgoing ω x) + apply ENNReal.tsum_le_tsum + intro y + unfold peakBandTransport + split_ifs <;> simp + · rw [ite_eq_right hh] + apply le_of_eq (ENNReal.tsum_eq_zero.mpr _) + intro y + unfold peakBandTransport normalizedPeakTransport + by_cases hy : y ∈ G.clusterPeaks ω x + · have hb : ¬ (a ≤ G.stabilizerWeight y x ∧ G.stabilizerWeight y x ≤ b) := + fun hb => hh ⟨y,hy.1,hb.2⟩ + simp [hb] + · simp [hy] + +lemma peakBandTransport_incoming_lower (a b : ℝ≥0∞) (ω : Set E) (y : V) : + a * G.peakReturn ω y * G.clusterBandCount a b ω y ≤ + ∑' x, G.peakBandTransport a b ω x y * G.stabilizerWeight y x := by + rw [clusterBandCount, ← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro x + rw [peakBandTransport, G.normalizedPeakTransport_eq_reverse] + by_cases hx : x ∈ G.cluster ω y + · simp only [hx, true_and, ↓reduceIte] + by_cases hb : a ≤ G.stabilizerWeight y x ∧ G.stabilizerWeight y x ≤ b + · simp only [ite_eq_left hb, mul_one] + rw [mul_comm a] + gcongr + exact hb.1 + · simp [hb] + · simp [hx] + +theorem expected_peakBandCount_le_reverseWeightHit [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) (a b : ℝ≥0∞) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, a * G.peakReturn ω x * G.clusterBandCount a b ω x ∂G.law p) ≤ + ∑ x ∈ (G.orbitRepresentatives hq).roots, G.law p (G.reverseWeightHit b x) := by + calc + _ ≤ ∑ y ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ∑' x, G.peakBandTransport a b ω x y * G.stabilizerWeight y x ∂G.law p := by + apply Finset.sum_le_sum + intro y _ + exact lintegral_mono fun ω => G.peakBandTransport_incoming_lower a b ω y + _ = ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, ∑' y, G.peakBandTransport a b ω x y ∂G.law p := + (OrbitRepresentatives.random_tilted_transport G (G.orbitRepresentatives hq) hc hl p + (G.peakBandTransport a b) (G.measurable_peakBandTransport a b) + (G.peakBandTransport_aut a b)).symm + _ ≤ _ := by + apply Finset.sum_le_sum + intro x _ + apply le_trans (lintegral_mono fun ω => G.peakBandTransport_outgoing a b ω x) + simpa only [Set.indicator, Pi.one_apply] using + (lintegral_indicator_one (μ := G.law p) (G.measurableSet_reverseWeightHit b x)).le + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakOrbitComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakOrbitComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..07e86b06f70916e46ff6dd3fee8b0ceb25ad405a --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakOrbitComparison.lean @@ -0,0 +1,153 @@ +import OAI.Probability.BenjaminiSchramm.BoundedOrbitDescent +import OAI.Probability.BenjaminiSchramm.MixedHeightMoment +import OAI.Probability.BenjaminiSchramm.PeakExposureGeometry +import OAI.Probability.BenjaminiSchramm.CriticalPeakBand +import OAI.Probability.BenjaminiSchramm.PeakSurgeryProbability + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma mixedHeightLayerMoment_eq_of_orbit (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (p : unitInterval) (d c l u ad t : ℝ) {x y : V} + (h : G.vertexOrbit x=G.vertexOrbit y) : + G.mixedHeightLayerMoment a p d c l u ad t x = + G.mixedHeightLayerMoment a p d c l u ad t y := by + obtain ⟨φ,hφ⟩ := MulAction.mem_orbit_iff.mp (Quotient.exact h) + change φ.vertex y=x at hφ + rw [←hφ,G.mixedHeightLayerMoment_aut a ha] + +lemma mixedHeight_continuation_at_boundary + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (d N : ℕ) (hd : ∀ z, Percolation.degree G.ends z ≤ d) + (p : unitInterval) (R M k r ell : ℝ) (hR : 0 ≤ R) (hM : 0 ≤ M) + (hk : 0 ≤ k) (hr : 0 ≤ r) (hell : 0 < ell) (x u v₀ : V) + (hu : -ell-R ≤ G.orbitAdjustedHeight a x u ∧ G.orbitAdjustedHeight a x u ≤ -ell) + (hpath : ∃ v, ∃ q : G.fullGraph.Walk u v, + G.vertexOrbit v=G.vertexOrbit v₀ ∧ q.length ≤ N ∧ + (∀ z ∈ q.support, -M ≤ G.orbitAdjustedHeight a u z ∧ G.orbitAdjustedHeight a u z ≤ 0) ∧ + G.orbitAdjustedHeight a u v ≤ -R) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(N+1)))* + G.mixedHeightLayerMoment a p (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ ≤ + ∑' w, if -ell-k-M-2*R ≤ G.orbitAdjustedHeight a x w ∧ + G.orbitAdjustedHeight a x w ≤ -ell-k then + G.law p (connectionAvoidingHit G.ends + (Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z}) + (Percolation.internalEdges G.ends {z | -ell-k-r-R-M ≤ G.orbitAdjustedHeight a x z ∧ + G.orbitAdjustedHeight a x z ≤ -ell}) + u w {z | z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z}) else 0 := by + obtain ⟨v,q,horb,hlen,hq,hend⟩ := hpath + let P : Set V := {z | -ell-k-r-R-M ≤ G.orbitAdjustedHeight a x z ∧ + G.orbitAdjustedHeight a x z ≤ -ell} + let D := Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z} + let J := Percolation.internalEdges G.ends P + let T : Set V := {z | z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z} + let W : Set V := {z | -ell-k-M-2*R ≤ G.orbitAdjustedHeight a x z ∧ + G.orbitAdjustedHeight a x z ≤ -ell-k} + have hsupp : ∀ z ∈ q.support, z ∈ P := by + intro z hz + change -ell-k-r-R-M ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ -ell + rw [G.orbitAdjustedHeight_change_base hc hl a x u z] + have hh := hq z hz + constructor <;> linarith [hu.1,hu.2,hh.1,hh.2] + have hg : G.fullGraph=Percolation.openSimpleGraph G.ends Set.univ := + criticalModel_openGraph G.ends Set.univ + let f : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by simpa only [←hg,id_eq] using h⟩ + obtain ⟨q',hqlen,hqsupp⟩ := walk_internal_restriction G.ends (q.map f) P (by + intro z hz + rw [SimpleGraph.Walk.support_map] at hz + change z ∈ q.support.map id at hz + exact hsupp z (by simpa only [List.map_id_fun,id_eq] using hz)) + have hlen' : q'.length ≤ N := by + rw [hqlen,SimpleGraph.Walk.length_map] + exact hlen + have havoid : ∀ z ∈ q'.support, z ∉ T := by + intro z hz hzt + rw [hqsupp,SimpleGraph.Walk.support_map] at hz + change z ∈ q.support.map id at hz + have hzq : z ∈ q.support := by simpa only [List.map_id_fun,id_eq] using hz + have hh := (hsupp z hzq).2 + exact (not_le_of_gt hell) (by linarith [hzt.2]) + have hJD : J ⊆ D := Percolation.internalEdges_mono G.ends (by + intro z hz + change -ell-k-r-R-M ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ -ell at hz + change -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z + linarith [hz.1]) + have hroot := mixed_root_walk_layer_moment G.ends hl d hd p D J hJD T W u v q' havoid + have hδ : 0 ≤ min (p : ℝ) (1-p) := le_min p.2.1 (sub_nonneg.mpr p.2.2) + have hδ1 : min (p : ℝ) (1-p) ≤ 1 := (min_le_left _ _).trans p.2.2 + have hcost : ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(N+1))) ≤ + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(q'.length+1))) := + ENNReal.ofReal_le_ofReal (pow_le_pow_of_le_one hδ hδ1 + (Nat.mul_le_mul_left d (Nat.add_le_add_right hlen' 1))) + have hvlo : -ell-R-M ≤ G.orbitAdjustedHeight a x v := by + rw [G.orbitAdjustedHeight_change_base hc hl a x u v] + have hh := (hq v q.end_mem_support).1 + linarith [hu.1] + have hvhi : G.orbitAdjustedHeight a x v ≤ -ell-R := by + rw [G.orbitAdjustedHeight_change_base hc hl a x u v] + linarith [hu.2] + rw [←G.mixedHeightLayerMoment_eq_of_orbit a ha p _ _ _ _ _ _ horb] + have hroot' := hroot + simp only [D,J,T,W,Set.mem_ofPred_eq] at hroot' + exact (mul_le_mul' hcost + (G.mixedHeightLayerMoment_le_continuation hc hl a p R M k r ell hR hM x v hvlo hvhi)).trans hroot' + +def fullPeakDownHit (a : V → ℝ) (ell : ℝ) (x : V) : Set (Set E) := + strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a x) x x ∩ + restrictedHit G.ends Set.univ x {z | G.orbitAdjustedHeight a x z ≤ -ell} + +lemma measurableSet_fullPeakDownHit (a : V → ℝ) (ell : ℝ) (x : V) : + MeasurableSet (G.fullPeakDownHit a ell x) := + (measurableSet_strictHeightPeakConnection G.ends _ x x).inter + (measurableSet_restrictedHit G.ends Set.univ x _) + +omit [Countable V] [Countable E] in +lemma fullPeakDownHit_subset_exposed + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R M k r ell : ℝ) (hR : 0 ≤ R) (hM : 0 ≤ M) + (hk : 0 ≤ k) (hr : 0 ≤ r) (hell : 0 < ell) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (x : V) : + G.fullPeakDownHit a ell x ⊆ + (restrictedHit G.ends + (Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z}) + x {z | z ≠ x ∧ 0 ≤ G.orbitAdjustedHeight a x z})ᶜ ∩ + restrictedHit G.ends + ((Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z}) \ + Percolation.internalEdges G.ends {z | G.orbitAdjustedHeight a x z ≤ -ell}) + x {z | -ell-R ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ -ell} := by + rintro ω ⟨⟨_hxx,hpeak⟩,y,hy,hxy⟩ + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight a x w-G.orbitAdjustedHeight a x v| ≤ R := by + intro e v w hv hw + rw [G.orbitAdjustedHeight_change_base hc hl a x v w,add_sub_cancel_left] + exact hjump e v w hv hw + obtain ⟨z,hzlo,hzhi,hxz⟩ := upper_cluster_crossing_cover G.ends (G.orbitAdjustedHeight a x) + R (-ell) hj Set.univ ω x y (by rw [G.orbitAdjustedHeight_self]; linarith) hy hxy + have hmask : Set.univ \ Percolation.internalEdges G.ends {z | G.orbitAdjustedHeight a x z ≤ -ell} ⊆ + Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ G.orbitAdjustedHeight a x z} := + upper_mask_lower_bound G.ends (G.orbitAdjustedHeight a x) R (-ell) _ hj Set.univ (by linarith) + refine ⟨?_,z,⟨hzlo,hzhi⟩,?_⟩ + · rintro ⟨v,⟨hvx,hv⟩,hxv⟩ + have hh := hpeak v (Percolation.conn_mono G.ends Set.inter_subset_left hxv) hvx + have hself := G.orbitAdjustedHeight_self a x + linarith + · apply Percolation.conn_mono G.ends (Set.inter_subset_inter_right _ ?_) hxz + intro e he + exact ⟨hmask he,he.2⟩ + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakRateCancellation.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakRateCancellation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c9b6b7c1530a415ec81616262512792929841f9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakRateCancellation.lean @@ -0,0 +1,48 @@ +import OAI.Probability.BenjaminiSchramm.CriticalPeakComparison + +namespace OAI + +noncomputable section +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma peak_rate_cancellation (P X K : ℝ≥0∞) (c b ε t k L r : ℝ) (hc : 0 < c) + (hP : ENNReal.ofReal (c*Real.exp (-(b+ε)*t)) ≤ P) + (hX : P*X ≤ K*ENNReal.ofReal (Real.exp (L*r-b*(t+k)))) : + X ≤ ENNReal.ofReal c⁻¹*K*ENNReal.ofReal (Real.exp (L*r+ε*t-b*k)) := by + let A := ENNReal.ofReal (c*Real.exp (-(b+ε)*t)) + let D := ENNReal.ofReal (c⁻¹*Real.exp ((b+ε)*t)) + have hDA : D*A=1 := by + dsimp [D,A] + rw [←ENNReal.ofReal_mul (by positivity : 0 ≤ c⁻¹*Real.exp ((b+ε)*t))] + have he : (c⁻¹*Real.exp ((b+ε)*t))*(c*Real.exp (-(b+ε)*t))=1 := by + calc + _ = (c⁻¹*c)*(Real.exp ((b+ε)*t)*Real.exp (-(b+ε)*t)) := by ring + _ = 1 := by + rw [inv_mul_cancel₀ hc.ne',←Real.exp_add, + show (b+ε)*t+ -(b+ε)*t=0 by ring,Real.exp_zero,one_mul] + rw [he,ENNReal.ofReal_one] + calc + _ = D*(A*X) := by rw [←mul_assoc,hDA,one_mul] + _ ≤ D*(K*ENNReal.ofReal (Real.exp (L*r-b*(t+k)))) := + mul_le_mul' le_rfl ((mul_le_mul' hP le_rfl).trans hX) + _ = _ := by + dsimp [D] + have he : (c⁻¹*Real.exp ((b+ε)*t))*Real.exp (L*r-b*(t+k)) = + c⁻¹*Real.exp (L*r+ε*t-b*k) := by + rw [mul_assoc,←Real.exp_add] + congr 2 + ring + calc + _ = K*(ENNReal.ofReal (c⁻¹*Real.exp ((b+ε)*t))* + ENNReal.ofReal (Real.exp (L*r-b*(t+k)))) := by ac_rfl + _ = K*ENNReal.ofReal (c⁻¹*Real.exp (L*r+ε*t-b*k)) := by + rw [←ENNReal.ofReal_mul (by positivity : 0 ≤ c⁻¹*Real.exp ((b+ε)*t)),he] + _ = _ := by rw [ENNReal.ofReal_mul (inv_nonneg.mpr hc.le)]; ac_rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSlabComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSlabComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..71f69e521f48e0cce63c41fdabec54101debbed3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSlabComparison.lean @@ -0,0 +1,93 @@ +import OAI.Probability.BenjaminiSchramm.PeakOrbitComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem full_peak_lower_slab_comparison + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (d N : ℕ) (hd : ∀ z, Percolation.degree G.ends z ≤ d) + (p : unitInterval) (R M k r ell : ℝ) (hR : 0 ≤ R) (hM : 0 ≤ M) + (hk : 0 ≤ k) (hr : 0 ≤ r) (hell : 0 < ell) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (hpaths : ∀ u (j : G.VertexOrbit), ∃ v, ∃ q : G.fullGraph.Walk u v, + G.vertexOrbit v=j ∧ q.length ≤ N ∧ + (∀ z ∈ q.support, -M ≤ G.orbitAdjustedHeight a u z ∧ G.orbitAdjustedHeight a u z ≤ 0) ∧ + G.orbitAdjustedHeight a u v ≤ -R) + (hfin : ∀ v, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω v).Finite) + (x v₀ : V) : + (G.law p (G.fullPeakDownHit a ell x))* + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(N+1)))* + G.mixedHeightLayerMoment a p (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ ≤ + ∫⁻ ω, G.strictPeakSlabBandCount a (r+R+M) (-ell-k-M-2*R) (-ell-k) ω x ∂G.law p := by + let f := G.orbitAdjustedHeight a x + let D := Percolation.internalEdges G.ends {z | -ell-k-r-2*M-3*R ≤ f z} + let D' := Percolation.internalEdges G.ends {z | -ell-k-r-R-M ≤ f z} + let K := D \ Percolation.internalEdges G.ends {z | f z ≤ -ell} + let J := Percolation.internalEdges G.ends {z | -ell-k-r-R-M ≤ f z ∧ f z ≤ -ell} + let U : Set V := {z | -ell-R ≤ f z ∧ f z ≤ -ell} + let T : Set V := {z | z ≠ x ∧ 0 ≤ f z} + let W : Set V := {z | -ell-k-M-2*R ≤ f z ∧ f z ≤ -ell-k} + let b := ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(N+1)))* + G.mixedHeightLayerMoment a p (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ + have hj : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |f w-f v| ≤ R := by + intro e v w hv hw + dsimp [f] + rw [G.orbitAdjustedHeight_change_base hc hl a x v w,add_sub_cancel_left] + exact hjump e v w hv hw + have hD'D : D' ⊆ D := Percolation.internalEdges_mono G.ends (by + intro z hz + change -ell-k-r-R-M ≤ f z at hz + change -ell-k-r-2*M-3*R ≤ f z + linarith) + have hJD' : J ⊆ D' := Percolation.internalEdges_mono G.ends (fun _ hz => hz.1) + have hKD' : K ⊆ D' := upper_mask_lower_bound G.ends f R (-ell) _ hj D (by linarith) + have hJK : Disjoint J K := Set.disjoint_left.mpr (by + intro e heJ heK + exact heK.2 (fun z hz => (heJ z hz).2)) + have hfinD : ∀ v, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends (ω ∩ D) v).Finite := by + intro v + filter_upwards [hfin v] with ω hω + exact hω.subset fun z hz => Percolation.conn_mono G.ends Set.inter_subset_left hz + have hbound : ∀ u ∈ U, b ≤ + ∑' w, if w ∈ W then G.law p (connectionAvoidingHit G.ends D J u w T) else 0 := by + intro u hu + exact G.mixedHeight_continuation_at_boundary hc hl a ha d N hd p R M k r ell hR hM + hk hr hell x u v₀ hu (hpaths u (G.vertexOrbit v₀)) + have hcmp := peak_layer_comparison_averaged_in_domain G.ends p D D' K J + Set.sdiff_subset (hJD'.trans hD'D) hJK hKD' hJD' x U T W b hfinD (by + intro u hu + refine (hbound u hu).trans_eq ?_ + apply tsum_congr + intro w + split_ifs <;> rfl) + have hsub : G.fullPeakDownHit a ell x ⊆ + (restrictedHit G.ends D x T)ᶜ ∩ restrictedHit G.ends K x U := + G.fullPeakDownHit_subset_exposed hc hl a R M k r ell hR hM hk hr hell hjump x + have hdEq : (-ell-k-M-2*R)-(r+R+M)= -ell-k-r-2*M-3*R := by ring + have hcEq : (-ell-k)-(r+R+M)= -ell-k-r-R-M := by ring + have heq (ω : Set E) : G.strictPeakSlabBandCount a (r+R+M) (-ell-k-M-2*R) (-ell-k) ω x = + (restrictedHit G.ends D x T)ᶜ.indicator + (fun ω => restrictedLayerCount G.ends D' W ω x) ω := by + simpa only [hdEq,hcEq] using G.strict_peak_slab_band_count_eq a (r+R+M) + (-ell-k-M-2*R) (-ell-k) (by linarith) ω x + calc + _ = G.law p (G.fullPeakDownHit a ell x)*b := by dsimp [b]; rw [mul_assoc] + _ ≤ G.law p ((restrictedHit G.ends D x T)ᶜ ∩ restrictedHit G.ends K x U)*b := + mul_le_mul' (measure_mono hsub) le_rfl + _ ≤ ∫⁻ ω, (restrictedHit G.ends D x T)ᶜ.indicator + (fun ω => restrictedLayerCount G.ends D' W ω x) ω ∂G.law p := hcmp + _ = _ := lintegral_congr fun ω => (heq ω).symm + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingAverage.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..e56045d5daa8e47264afa6e8bbed2371d7460db8 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingAverage.lean @@ -0,0 +1,148 @@ +import OAI.Probability.BenjaminiSchramm.PeakSprinklingCell +import OAI.Probability.BenjaminiSchramm.PeakLayerCost +import OAI.Probability.BenjaminiSchramm.SprinklingAvoidanceProfile + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open BernoulliProduct Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma exactCluster_partition_measure (p : unitInterval) (x : V) + (hfin : ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) + (B : Set (Set E)) (hB : MeasurableSet B) : + G.law p B=∑' S : Finset V, G.law p ({ω | G.cluster ω x=(S : Set V)} ∩ B) := by + have hdis : Pairwise (fun S T : Finset V => Disjoint + ({ω | G.cluster ω x=(S : Set V)} ∩ B) ({ω | G.cluster ω x=(T : Set V)} ∩ B)) := by + intro S T hne + apply Set.disjoint_left.mpr + rintro ω ⟨hS,_⟩ ⟨hT,_⟩ + exact hne (Finset.coe_injective (hS.symm.trans hT)) + calc + _ = G.law p (⋃ S : Finset V, {ω | G.cluster ω x=(S : Set V)} ∩ B) := by + apply measure_congr + filter_upwards [hfin] with ω hω + apply propext + constructor + · intro hBω + exact Set.mem_iUnion.mpr ⟨hω.toFinset,hω.coe_toFinset.symm,hBω⟩ + · intro hω' + obtain ⟨S,_hS,hBω⟩ := Set.mem_iUnion.mp hω' + exact hBω + _ = _ := measure_iUnion hdis fun S => (G.measurableSet_exactCluster x _).inter hB + +theorem peak_sprinkling_average (q b p : unitInterval) + (hparam : Percolation.sprinkleParameter q b=p) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (ell : ℝ) (x : V) + (g : ℕ → ℝ) (hg : ∀ l, 0 ≤ g l) (t : ℝ) (ht : 0 ≤ t) + (hfin : ∀ᵐ ω ∂G.law q, (G.cluster ω x).Finite) + (havoid : ∀ (S : Finset V) (u : V), u ∈ S → G.orbitAdjustedHeight a x u ≤ 0 → + Real.exp (-g (-G.adjustedLayerIndex a R 0 x u).toNat) ≤ + (BernoulliProduct.law (fun e => Percolation.sprinkleParameter + (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e) b)).real + (exteriorEscape G.ends (S : Set V) (G.orbitAdjustedHeight a x) x u)ᶜ) + (B : Set (Set E)) (hB : MeasurableSet B) + (hBpeak : B ⊆ G.fullPeakDownHit a ell x) + (hBcost : ∀ ω ∈ B, G.downwardLayerCost a R g ω x ≤ ENNReal.ofReal t) : + G.law q B*ENNReal.ofReal (Real.exp (-t)) ≤ G.law p (G.fullPeakDownHit a ell x) := by + let μ := BernoulliProduct.law (pairedParameters (fun _ : E => q) (fun _ => b)) + let C (S : Finset V) : Set (Set (E × Bool)) := + ({ω | G.cluster (whiteProjection ω) x=(S : Set V)} ∩ + (pairedUnion ∘ forceOn (whiteBlock (G.incidentEdges (S : Set V))) ∅) ⁻¹' + G.exteriorAvoidance (S : Set V) a x) ∩ pairedUnion ⁻¹' G.fullPeakDownHit a ell x + have hCm (S : Finset V) : MeasurableSet (C S) := + (((G.measurableSet_exactCluster x _).preimage measurable_whiteProjection).inter + ((G.measurableSet_exteriorAvoidance _ a x).preimage + (measurable_pairedUnion.comp (measurable_forceOn _ _)))).inter + ((G.measurableSet_fullPeakDownHit a ell x).preimage measurable_pairedUnion) + have hCdis : Pairwise (fun S T : Finset V => Disjoint (C S) (C T)) := by + intro S T hne + apply Set.disjoint_left.mpr + rintro ω ⟨⟨hS,_⟩,_⟩ ⟨⟨hT,_⟩,_⟩ + exact hne (Finset.coe_injective (hS.symm.trans hT)) + have hlocal (S : Finset V) : + G.law q ({ω | G.cluster ω x=(S : Set V)} ∩ B)*ENNReal.ofReal (Real.exp (-t)) ≤ μ (C S) := by + by_cases he : ({ω | G.cluster ω x=(S : Set V)} ∩ B).Nonempty + · obtain ⟨ω,hS,hBω⟩ := he + have hprop : G.peakDownClusterProperty a ell x (S : Set V) := by + have hh := (G.fullPeakDownHit_iff_cluster_property a ell x ω).mp (hBpeak hBω) + rwa [hS] at hh + have hbelow (u : V) (hu : u ∈ S) : G.orbitAdjustedHeight a x u ≤ 0 := by + by_cases hux : u=x + · simp only [hux,G.orbitAdjustedHeight_self,le_refl] + · exact (hprop.1 u hu hux).le + have hSc : Percolation.cluster G.ends ω x=(S : Set V) := by + rwa [←G.cluster_eq_percolationCluster] + have hcostreal : (∑ u ∈ S, g (-G.adjustedLayerIndex a R 0 x u).toNat) ≤ t := by + have hh := hBcost ω hBω + rw [G.downwardLayerCost_of_exact_cluster a R g ω x S hSc + (fun u hu => (G.nonpositive_height_depth a R hR x u (hbelow u hu)).1)] at hh + rw [←ENNReal.ofReal_sum_of_nonneg (fun u _ => hg _)] at hh + exact (ENNReal.ofReal_le_ofReal_iff ht).mp hh + have hsubset : + ({η | G.cluster (whiteProjection η) x=(S : Set V)} ∩ + (pairedUnion ∘ forceOn (whiteBlock (G.incidentEdges (S : Set V))) ∅) ⁻¹' + G.exteriorAvoidance (S : Set V) a x) ⊆ pairedUnion ⁻¹' G.fullPeakDownHit a ell x := by + rintro η ⟨hη,hηavoid⟩ + exact G.peak_survives_white_cell a ell x _ hprop η hη hηavoid + have hCeq : C S= + {η | G.cluster (whiteProjection η) x=(S : Set V)} ∩ + (pairedUnion ∘ forceOn (whiteBlock (G.incidentEdges (S : Set V))) ∅) ⁻¹' + G.exteriorAvoidance (S : Set V) a x := Set.inter_eq_left.mpr hsubset + rw [hCeq] + calc + _ ≤ G.law q {η | G.cluster η x=(S : Set V)}* + ENNReal.ofReal (Real.exp (-(∑ u ∈ S, g (-G.adjustedLayerIndex a R 0 x u).toNat))) := by + apply mul_le_mul' (measure_mono Set.inter_subset_left) + exact ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr (neg_le_neg hcostreal)) + _ ≤ _ := G.peak_sprinkling_cell_lower q b a x S + (fun u => g (-G.adjustedLayerIndex a R 0 x u).toNat) + (fun u hu => havoid S u hu (hbelow u hu)) + · rw [Set.not_nonempty_iff_eq_empty.mp he,measure_empty,zero_mul] + exact bot_le + calc + _ = ∑' S : Finset V, G.law q ({ω | G.cluster ω x=(S : Set V)} ∩ B)* + ENNReal.ofReal (Real.exp (-t)) := by + rw [G.exactCluster_partition_measure q x hfin B hB,←ENNReal.tsum_mul_right] + _ ≤ ∑' S : Finset V, μ (C S) := ENNReal.tsum_le_tsum hlocal + _ = μ (⋃ S : Finset V, C S) := (measure_iUnion hCdis hCm).symm + _ ≤ μ (pairedUnion ⁻¹' G.fullPeakDownHit a ell x) := measure_mono + (Set.iUnion_subset fun S _ h => h.2) + _ = _ := by + rw [←Measure.map_apply measurable_pairedUnion (G.measurableSet_fullPeakDownHit a ell x)] + dsimp [μ] + rw [paired_union_law,hparam,BernoulliProduct.law_const] + rfl + +theorem weighted_peak_sprinkling_average (O : G.OrbitRepresentatives) + (q b p : unitInterval) (hparam : Percolation.sprinkleParameter q b=p) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (ell : ℝ) + (g : ℕ → ℝ) (hg : ∀ l, 0 ≤ g l) (t : ℝ) (ht : 0 ≤ t) + (hfin : ∀ x, ∀ᵐ ω ∂G.law q, (G.cluster ω x).Finite) + (havoid : ∀ (x : V) (S : Finset V) (u : V), u ∈ S → G.orbitAdjustedHeight a x u ≤ 0 → + Real.exp (-g (-G.adjustedLayerIndex a R 0 x u).toNat) ≤ + (BernoulliProduct.law (fun e => Percolation.sprinkleParameter + (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e) b)).real + (exteriorEscape G.ends (S : Set V) (G.orbitAdjustedHeight a x) x u)ᶜ) + (B : V → Set (Set E)) (hB : ∀ x, MeasurableSet (B x)) + (hBpeak : ∀ x, B x ⊆ G.fullPeakDownHit a ell x) + (hBcost : ∀ x ω, ω ∈ B x → G.downwardLayerCost a R g ω x ≤ ENNReal.ofReal t) : + ENNReal.ofReal (Real.exp (-t))*(∑ x ∈ O.roots, ENNReal.ofReal (a x)*G.law q (B x)) ≤ + G.fullPeakDownProbability O a p ell := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro x _ + calc + _ = ENNReal.ofReal (a x)*(G.law q (B x)*ENNReal.ofReal (Real.exp (-t))) := by ring + _ ≤ _ := mul_le_mul' le_rfl (G.peak_sprinkling_average q b p hparam a R hR ell x + g hg t ht (hfin x) (havoid x) (B x) (hB x) (hBpeak x) (hBcost x)) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingCell.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingCell.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d3ac57cfcc7a82c3eef55e879301651da6ead6e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingCell.lean @@ -0,0 +1,109 @@ +import OAI.Probability.BenjaminiSchramm.ExteriorEscape +import OAI.Probability.BenjaminiSchramm.PeakSurvivalRealHeight + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open BernoulliProduct Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def peakDownClusterProperty (a : V → ℝ) (ell : ℝ) (x : V) (S : Set V) : Prop := + (∀ y ∈ S, y ≠ x → G.orbitAdjustedHeight a x y < 0) ∧ + ∃ y ∈ S, G.orbitAdjustedHeight a x y ≤ -ell + +def exteriorAvoidance (S : Set V) (a : V → ℝ) (x : V) : Set (Set E) := + {η | ∀ u ∈ S, η ∉ exteriorEscape G.ends S (G.orbitAdjustedHeight a x) x u} + +lemma measurableSet_exteriorAvoidance [Countable V] [Countable E] + (S : Set V) (a : V → ℝ) (x : V) : MeasurableSet (G.exteriorAvoidance S a x) := + (Measurable.forall fun u => measurable_const.imp + (measurableSet_exteriorEscape G.ends S (G.orbitAdjustedHeight a x) x u).compl.mem).setOf + +lemma fullPeakDownHit_iff_cluster_property (a : V → ℝ) (ell : ℝ) (x : V) (ω : Set E) : + ω ∈ G.fullPeakDownHit a ell x ↔ G.peakDownClusterProperty a ell x (G.cluster ω x) := by + rw [G.cluster_eq_percolationCluster] + constructor + · rintro ⟨⟨_,hpeak⟩,y,hy,hxy⟩ + refine ⟨fun z hz hzx => ?_,y,?_,hy⟩ + · simpa only [G.orbitAdjustedHeight_self] using hpeak z hz hzx + · simpa only [Percolation.cluster,Set.mem_ofPred_eq,Set.inter_univ] using hxy + · rintro ⟨hpeak,y,hxy,hy⟩ + refine ⟨⟨Percolation.conn_refl G.ends ω x,?_⟩,y,hy,?_⟩ + · intro z hz hzx + simpa only [G.orbitAdjustedHeight_self] using hpeak z hz hzx + · simpa only [Percolation.cluster,Set.mem_ofPred_eq,Set.inter_univ] using hxy + +lemma peak_survives_white_cell (a : V → ℝ) (ell : ℝ) (x : V) (S : Set V) + (hprop : G.peakDownClusterProperty a ell x S) (ω : Set (E × Bool)) + (hS : G.cluster (whiteProjection ω) x=S) + (havoid : pairedUnion (forceOn (whiteBlock (G.incidentEdges S)) ∅ ω) ∈ G.exteriorAvoidance S a x) : + pairedUnion ω ∈ G.fullPeakDownHit a ell x := by + have hwhite : whiteProjection ω ∈ G.fullPeakDownHit a ell x := + (G.fullPeakDownHit_iff_cluster_property a ell x _).mpr (hS ▸ hprop) + have hSc : Percolation.cluster G.ends (whiteProjection ω) x=S := by + rwa [←G.cluster_eq_percolationCluster] + have hη : pairedUnion (forceOn (whiteBlock (G.incidentEdges S)) ∅ ω) \ + Percolation.internalEdges G.ends S=pairedUnion ω \ Percolation.internalEdges G.ends S := by + have hh := G.erasedWhiteCluster_exterior_eq ω x + rwa [hS] at hh + have hpeak : ∀ y, Percolation.Conn G.ends (pairedUnion ω) x y → y ≠ x → + G.orbitAdjustedHeight a x y < G.orbitAdjustedHeight a x x := by + rw [pairedUnion_eq] + apply union_strict_peak_of_exterior_avoidance G.ends (whiteProjection ω) (blueProjection ω) + (G.orbitAdjustedHeight a x) x hwhite.1.2 + intro u hu hescape + have huS : u ∈ S := hSc ▸ hu + apply havoid u huS + rcases hescape with ⟨y,hy,hheight,hyS,hconn⟩ + refine ⟨y,hy,hheight,?_,?_⟩ + · rwa [hSc] at hyS + · rw [hη,pairedUnion_eq,←hSc] + exact hconn + refine ⟨⟨Percolation.conn_refl G.ends _ x,hpeak⟩,?_⟩ + obtain ⟨y,hy,hxy⟩ := hwhite.2 + refine ⟨y,hy,?_⟩ + apply Percolation.conn_mono G.ends _ hxy + intro e he + exact ⟨(pairedUnion_eq ω).symm ▸ Or.inl he.1,he.2⟩ + +variable [Countable V] [Countable E] + +theorem peak_sprinkling_cell_lower (q b : unitInterval) (a : V → ℝ) + (x : V) (S : Finset V) + (g : V → ℝ) + (hbound : ∀ u ∈ S, Real.exp (-g u) ≤ + (BernoulliProduct.law (fun e => Percolation.sprinkleParameter + (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e) b)).real + (exteriorEscape G.ends (S : Set V) (G.orbitAdjustedHeight a x) x u)ᶜ) : + G.law q {η | G.cluster η x=(S : Set V)} * + ENNReal.ofReal (Real.exp (-(∑ u ∈ S, g u))) ≤ + BernoulliProduct.law (pairedParameters (fun _ => q) (fun _ => b)) + ({ω | G.cluster (whiteProjection ω) x=(S : Set V)} ∩ + (pairedUnion ∘ forceOn (whiteBlock (G.incidentEdges (S : Set V))) ∅) ⁻¹' + G.exteriorAvoidance (S : Set V) a x) := by + rw [fresh_white_union_event_factor (fun _ => q) (fun _ => b) + (G.incidentEdges (S : Set V)) {ω | G.cluster (whiteProjection ω) x=(S : Set V)} + ((G.measurableSet_exactCluster x _).preimage measurable_whiteProjection) + (G.paired_exactWhiteCluster_dependsOn x _) (G.exteriorAvoidance (S : Set V) a x) + (G.measurableSet_exteriorAvoidance _ a x)] + have hcell : BernoulliProduct.law (pairedParameters (fun _ : E => q) (fun _ => b)) + {ω | G.cluster (whiteProjection ω) x=(S : Set V)}= + G.law q {η | G.cluster η x=(S : Set V)} := by + change BernoulliProduct.law (pairedParameters (fun _ : E => q) (fun _ => b)) + (whiteProjection ⁻¹' {η | G.cluster η x=(S : Set V)})=_ + rw [←Measure.map_apply measurable_whiteProjection (G.measurableSet_exactCluster x _), + paired_white_law,BernoulliProduct.law_const] + rfl + rw [hcell] + exact mul_le_mul' le_rfl (exteriorEscape_avoidance_product G.ends _ S + (G.orbitAdjustedHeight a x) x g hbound) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingCost.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..87465db0d0e4a61e86881c5d2416b1119799de92 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingCost.lean @@ -0,0 +1,81 @@ +import Mathlib.Analysis.Asymptotics.SpecificAsymptotics +import Mathlib.Analysis.SpecificLimits.Basic +import Mathlib.Analysis.SpecialFunctions.Exp + +namespace OAI + +noncomputable section +open Filter Finset +open scoped Topology BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma geometric_continuation_cost_bound (g : ℕ → ℝ) (C q : ℝ) + (hg : ∀ l, 0 ≤ g l) (_hC : 0 ≤ C) (hb : ∀ l, g l ≤ C) + (hq0 : 0 ≤ q) (hq1 : q < 1) (n : ℕ) : + Summable (fun l => g l*q^(l-n)) ∧ + 0 ≤ (∑' l, g l*q^(l-n)) ∧ + (∑' l, g l*q^(l-n)) ≤ (∑ l ∈ range n, g l)+C*(1-q)⁻¹ := by + have hsgeom := summable_geometric_of_lt_one hq0 hq1 + have htail : Summable (fun k => g (k+n)*q^k) := + Summable.of_nonneg_of_le (fun k => mul_nonneg (hg _) (pow_nonneg hq0 _)) + (fun k => mul_le_mul_of_nonneg_right (hb _) (pow_nonneg hq0 _)) (hsgeom.mul_left C) + have hs : Summable (fun l => g l*q^(l-n)) := by + apply (summable_nat_add_iff n).mp + simpa only [Nat.add_sub_cancel] using htail + refine ⟨hs,tsum_nonneg (fun l => mul_nonneg (hg _) (pow_nonneg hq0 _)),?_⟩ + have hhead : (∑ l ∈ range n, g l*q^(l-n)) = ∑ l ∈ range n, g l := by + apply sum_congr rfl + intro l hl + rw [Nat.sub_eq_zero_of_le (Nat.le_of_lt (mem_range.mp hl)),pow_zero,mul_one] + calc + _ = (∑ l ∈ range n, g l*q^(l-n))+(∑' k, g (k+n)*q^k) := by + simpa only [Nat.add_sub_cancel] using (hs.sum_add_tsum_nat_add n).symm + _ ≤ (∑ l ∈ range n, g l)+∑' k, C*q^k := by + rw [hhead] + exact add_le_add le_rfl (htail.tsum_le_tsum + (fun k => mul_le_mul_of_nonneg_right (hb _) (pow_nonneg hq0 _)) + (hsgeom.mul_left C)) + _ = _ := by rw [tsum_mul_left,tsum_geometric_of_lt_one hq0 hq1] + +theorem geometric_continuation_cost_sublinear (g : ℕ → ℝ) (C q : ℝ) + (hg : ∀ l, 0 ≤ g l) (hC : 0 ≤ C) (hb : ∀ l, g l ≤ C) + (hq0 : 0 ≤ q) (hq1 : q < 1) (hlim : Tendsto g atTop (𝓝 0)) : + Tendsto (fun n : ℕ => (∑' l, g l*q^(l-n))/(n : ℝ)) atTop (𝓝 0) := by + have hces : Tendsto (fun n : ℕ => (∑ l ∈ range n, g l)/(n : ℝ)) atTop (𝓝 0) := by + simpa only [div_eq_mul_inv,mul_comm] using hlim.cesaro + have hconst : Tendsto (fun n : ℕ => (C*(1-q)⁻¹)/(n : ℝ)) atTop (𝓝 0) := by + exact tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop + have hupper : Tendsto (fun n : ℕ => + ((∑ l ∈ range n, g l)+C*(1-q)⁻¹)/(n : ℝ)) atTop (𝓝 0) := by + simpa only [add_div,zero_add] using hces.add hconst + apply squeeze_zero (fun n => div_nonneg + (geometric_continuation_cost_bound g C q hg hC hb hq0 hq1 n).2.1 (Nat.cast_nonneg n)) + (fun n => div_le_div_of_nonneg_right + (geometric_continuation_cost_bound g C q hg hC hb hq0 hq1 n).2.2 (Nat.cast_nonneg n)) hupper + +lemma exponential_continuation_weight (a : ℝ) (l n : ℕ) : + Real.exp (-a*max ((l : ℝ)-n) 0) = Real.exp (-a)^(l-n) := by + by_cases hn : n ≤ l + · rw [max_eq_left (sub_nonneg.mpr (Nat.cast_le.mpr hn)),←Real.exp_nat_mul, + Nat.cast_sub hn] + congr 1 + ring + · have hln : l ≤ n := Nat.le_of_lt (Nat.lt_of_not_ge hn) + rw [max_eq_right (sub_nonpos.mpr (Nat.cast_le.mpr hln)),mul_zero,Real.exp_zero, + Nat.sub_eq_zero_of_le hln,pow_zero] + +theorem exponential_continuation_cost_sublinear (g : ℕ → ℝ) (C a : ℝ) + (hg : ∀ l, 0 ≤ g l) (hC : 0 ≤ C) (hb : ∀ l, g l ≤ C) + (ha : 0 < a) (hlim : Tendsto g atTop (𝓝 0)) : + Tendsto (fun n : ℕ => + (∑' l, g l*Real.exp (-a*max ((l : ℝ)-n) 0))/(n : ℝ)) atTop (𝓝 0) := by + simp_rw [exponential_continuation_weight] + exact geometric_continuation_cost_sublinear g C (Real.exp (-a)) hg hC hb + (Real.exp_pos _).le (Real.exp_lt_one_iff.mpr (neg_neg_of_pos ha)) hlim + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingSurvival.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingSurvival.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2d996b074a716e274f1d965bc0b8e0725c152ce --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSprinklingSurvival.lean @@ -0,0 +1,83 @@ +import OAI.Probability.BenjaminiSchramm.PeakSprinklingAverage +import OAI.Probability.BenjaminiSchramm.PeakCostBound +import OAI.Probability.BenjaminiSchramm.WeightedCostRetention + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology BigOperators + +namespace CriticalPercolation.BondGraph +open BernoulliProduct Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem peak_sprinkling_eventual_survival + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (O : G.OrbitRepresentatives) (p q b : unitInterval) + (hparam : Percolation.sprinkleParameter q b=p) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) + (hfin : ∀ x, ∀ᵐ ω ∂G.law q, (G.cluster ω x).Finite) + (g : ℕ → ℝ) (hg : ∀ l, 0 ≤ g l) (C₀ : ℝ) (hC₀ : 0 ≤ C₀) + (hgb : ∀ l, g l ≤ C₀) (hglim : Tendsto g atTop (𝓝 0)) + (havoid : ∀ (x : V) (S : Finset V) (u : V), u ∈ S → G.orbitAdjustedHeight a x u ≤ 0 → + Real.exp (-g (-G.adjustedLayerIndex a R 0 x u).toNat) ≤ + (BernoulliProduct.law (fun e => Percolation.sprinkleParameter + (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e) b)).real + (exteriorEscape G.ends (S : Set V) (G.orbitAdjustedHeight a x) x u)ᶜ) + (c rate A C : ℝ) (hA : 0 < A) (hC : 0 ≤ C) + (hsurv : ∀ n : ℕ, 0 < n → ENNReal.ofReal (c*Real.exp (-rate*n)) ≤ + G.peakSurvivalProbability O a R q n) + (hprofile : ∀ n : ℕ, 0 < n → ∀ l : ℕ, G.peakSurvivalLayerMoment O a R q n l ≤ + G.peakSurvivalProbability O a R q n * + ENNReal.ofReal (C*Real.exp (-A*max ((l : ℝ)-n) 0))) + (ε : ℝ) (hε : 0 < ε) : + ∀ᶠ n : ℕ in atTop, ENNReal.ofReal ((c/2)*Real.exp (-(rate+ε)*n)) ≤ + G.fullPeakDownProbability O a p (R*n) := by + let Ev (n : ℕ) (x : V) : Set (Set E) := + {ω | 0 < G.peakDownBandCount a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x} + let Z (x : V) (ω : Set E) := G.downwardLayerCost a R g ω x + let F (n : ℕ) := C*(∑' l, g l*Real.exp (-A*max ((l : ℝ)-n) 0)) + have hEv (n : ℕ) (x : V) : MeasurableSet (Ev n x) := + measurableSet_lt measurable_const (G.measurable_peakDownBandCount a _ _ x) + have hZ (x : V) : Measurable (Z x) := G.measurable_downwardLayerCost a R g x + have hP (n : ℕ) : G.peakSurvivalProbability O a R q n < ⊤ := by + apply lt_top_iff_ne_top.mpr + exact ENNReal.sum_ne_top.mpr fun x _ => ENNReal.mul_ne_top + ENNReal.ofReal_ne_top (measure_ne_top _ _) + have hF : Tendsto (fun n : ℕ => F n/(n : ℝ)) atTop (𝓝 0) := by + have hh := (tendsto_const_nhds (x := C) (f := atTop)).mul + (exponential_continuation_cost_sublinear g C₀ A hg hC₀ hgb hA hglim) + simpa only [F,div_eq_mul_inv,mul_assoc,mul_zero] using hh + filter_upwards [sublinear_cost_eventually_small F hF (ε/2) (by positivity), + eventually_ge_atTop (1 : ℕ)] with n hn hn1 + have hn0 : 0 < n := by omega + have htn : 0 < ε*(n : ℝ) := mul_pos hε (Nat.cast_pos.mpr hn0) + have hcost : (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω in Ev n x, Z x ω ∂G.law q)) ≤ + G.peakSurvivalProbability O a R q n*ENNReal.ofReal (F n) := by + calc + _ = ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, (Ev n x).indicator (Z x) ω ∂G.law q) := by + apply Finset.sum_congr rfl + intro x _ + exact congrArg (fun z => ENNReal.ofReal (a x)*z) (lintegral_indicator (hEv n x) (Z x)).symm + _ ≤ _ := G.peakSurvivalCostMoment_bound O a R q g hg C₀ hC₀ hgb A C hA hC n (hprofile n hn0) + have hcost' := hcost.trans (mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal + (show F n ≤ ε*(n : ℝ)/2 by nlinarith [hn]))) + have hhalf := weighted_cost_retains_half O.roots (fun _ : V => G.law q) + (fun x => ENNReal.ofReal (a x)) (Ev n) (fun x _ => hEv n x) Z (fun x _ => hZ x) + (ε*n) htn (hP n) hcost' + let B (x : V) := Ev n x ∩ {ω | Z x ω ≤ ENNReal.ofReal (ε*n)} + have hB (x : V) : MeasurableSet (B x) := (hEv n x).inter (measurableSet_le (hZ x) measurable_const) + have hBpeak (x : V) : B x ⊆ G.fullPeakDownHit a (R*n) x := by + apply Set.Subset.trans Set.inter_subset_left + exact G.positive_peakDownBandCount_subset_fullPeakDownHit hc hl a _ _ (R*n) (by nlinarith [hR]) x + have htransfer := G.weighted_peak_sprinkling_average O q b p hparam a R hR (R*n) + g hg (ε*n) htn.le hfin havoid B hB hBpeak (fun _ _ h => h.2) + apply retained_peak_exponential_bound _ _ _ c rate ε n (hsurv n hn0) hhalf + simpa only [B,neg_mul] using htransfer + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryAverage.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4dfc71c768d6c6f61de9585bd2fe2fadb8b9998 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryAverage.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.PeakFrontierTruncation +import OAI.Probability.BenjaminiSchramm.LayerFrontierExpectation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma lowerFrontier_partition_measure (hloc : LocallyFinite G) (p : unitInterval) + (I J : Set E) (x : V) (hfin : ∀ᵐ ω ∂law p, (cluster G (ω ∩ I) x).Finite) + (B : Set (Set E)) (hB : MeasurableSet B) : + law p B = ∑' A : Finset V × Finset V, + law p (lowerFrontierCell G I J x (A.1 : Set V) (A.2 : Set V) ∩ B) := by + have hfin' : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law (fun _ : E => p), + (cluster G (ω ∩ I) x).Finite := by + simpa only [CriticalPercolation.BernoulliProduct.law_const,Percolation.law] using hfin + have hh := lintegral_lowerFrontier_partition G hloc (fun _ : E => p) I J x hfin' + (B.indicator (fun _ => (1 : ℝ≥0∞))) (measurable_const.indicator hB) + rw [CriticalPercolation.BernoulliProduct.law_const] at hh + change (∫⁻ ω, B.indicator (fun _ => (1 : ℝ≥0∞)) ω ∂law p) = _ at hh + rw [←lintegral_indicator_fun_one hB] + apply hh.trans + apply tsum_congr + intro A + have he : (lowerFrontierCell G I J x (A.1 : Set V) (A.2 : Set V)).indicator + (B.indicator (fun _ => (1 : ℝ≥0∞))) = + (lowerFrontierCell G I J x (A.1 : Set V) (A.2 : Set V) ∩ B).indicator + (fun _ => (1 : ℝ≥0∞)) := by + funext ω + by_cases ha : ω ∈ lowerFrontierCell G I J x (A.1 : Set V) (A.2 : Set V) + <;> by_cases hb : ω ∈ B <;> simp [Set.indicator,ha,hb] + rw [he,lintegral_indicator_fun_one ((measurableSet_lowerFrontierCell G I J x _ _).inter hB)] + rfl + +lemma peak_probability_of_frontier_surgery (hloc : LocallyFinite G) (p : unitInterval) + (I J : Set E) (x : V) (hfin : ∀ᵐ ω ∂law p, (cluster G (ω ∩ I) x).Finite) + (B : Set (Set E)) (hB : MeasurableSet B) (N L d : ℕ) (δ : ℝ) + (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hlocal : ∀ (S F : Finset V), + (lowerFrontierCell G I J x (S : Set V) (F : Set V)).Nonempty → + (0 < F.card ∧ F.card ≤ N) → + law p (lowerFrontierCell G I J x (S : Set V) (F : Set V))* + ENNReal.ofReal (δ^(d*(F.card+L+1))) ≤ + law p (lowerFrontierCell G I J x (S : Set V) (F : Set V) ∩ B)) : + law p {ω | 0 < frontierCount G I J ω x ∧ frontierCount G I J ω x ≤ (N : ℝ≥0∞)}* + ENNReal.ofReal (δ^(d*(N+L+1))) ≤ law p B := by + let C : Set (Set E) := {ω | 0 < frontierCount G I J ω x ∧ frontierCount G I J ω x ≤ (N : ℝ≥0∞)} + have hC : MeasurableSet C := + (measurableSet_lt measurable_const (measurable_frontierCount G I J x)).inter + (measurableSet_le (measurable_frontierCount G I J x) measurable_const) + rw [show law p {ω | 0 < frontierCount G I J ω x ∧ frontierCount G I J ω x ≤ (N : ℝ≥0∞)}=law p C from rfl, + lowerFrontier_partition_measure G hloc p I J x hfin C hC, + lowerFrontier_partition_measure G hloc p I J x hfin B hB,←ENNReal.tsum_mul_right] + apply ENNReal.tsum_le_tsum + intro A + let cell := lowerFrontierCell G I J x (A.1 : Set V) (A.2 : Set V) + by_cases hgood : 0 < A.2.card ∧ A.2.card ≤ N + · by_cases hcell : cell.Nonempty + · calc + _ ≤ law p cell*ENNReal.ofReal (δ^(d*(N+L+1))) := mul_le_mul' (measure_mono Set.inter_subset_left) le_rfl + _ ≤ law p cell*ENNReal.ofReal (δ^(d*(A.2.card+L+1))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (pow_le_pow_of_le_one hδ hδ1 (Nat.mul_le_mul_left d (by omega)))) + _ ≤ _ := hlocal A.1 A.2 hcell hgood + · have he : cell=∅ := Set.not_nonempty_iff_eq_empty.mp hcell + change law p (cell ∩ C)*_ ≤ law p (cell ∩ B) + simp only [he,Set.empty_inter,measure_empty,zero_mul,le_refl] + · have he : cell ∩ C=∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro ω ⟨hω,hωC⟩ + have hcard := frontierCount_eq_card_on_cell G I J x _ A.2 hω + have hgood' : (0 : ℝ≥0∞) < (A.2.card : ℝ≥0∞) ∧ (A.2.card : ℝ≥0∞) ≤ (N : ℝ≥0∞) := by + simpa only [C,Set.mem_ofPred_eq,hcard] using hωC + exact hgood (by exact_mod_cast hgood') + change law p (cell ∩ C)*_ ≤ _ + rw [he,measure_empty,zero_mul] + exact bot_le + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5fcc9e3a4531d228a4ea122e32132c473bea810 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryGeometry.lean @@ -0,0 +1,124 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry +import OAI.Probability.BenjaminiSchramm.SlabFirstVisit +import OAI.Probability.BenjaminiSchramm.HeightOrbitConnection + +namespace OAI + +noncomputable section +open Set +open scoped Classical + +namespace Percolation.BenjaminiSchramm + +lemma walk_first_strict_height_peak {V : Type*} {H : SimpleGraph V} + (f : V → ℝ) {x y : V} (p : H.Walk x y) (t : ℝ) + (hy : t ≤ f y) : + ∃ z, t ≤ f z ∧ ∃ q : H.Walk x z, q.length ≤ p.length ∧ + (∀ v ∈ q.support, v ∈ p.support) ∧ + ∀ v ∈ q.support, v ≠ z → f v < f z := by + let S := p.support.toFinset.filter fun v => t ≤ f v + have hyS : y ∈ S := Finset.mem_filter.mpr ⟨List.mem_toFinset.mpr p.end_mem_support,hy⟩ + obtain ⟨z,hzS,hzp,hfirst⟩ := p.exists_mem_support_forall_mem_support_imp_eq S + ⟨y,Finset.mem_filter.mpr ⟨hyS,p.end_mem_support⟩⟩ + have hz : t ≤ f z := (Finset.mem_filter.mp hzS).2 + refine ⟨z,hz,p.takeUntil z hzp,p.length_takeUntil_le_length hzp, + fun v hv => p.support_takeUntil_subset_support hzp hv,?_⟩ + intro v hv hvz + have hlt : f v < t := by + by_contra hn + have hvS : v ∈ S := Finset.mem_filter.mpr + ⟨List.mem_toFinset.mpr (p.support_takeUntil_subset_support hzp hv),le_of_not_gt hn⟩ + exact hvz (hfirst v hvS hv) + exact hlt.trans_le hz + +variable {V E : Type*} (G : BondGraph V E) + +lemma conn_mem_of_open_closed (η : Set E) (U : Set V) (x : V) (hx : x ∈ U) + (hclosed : ∀ e ∈ η, ∀ v ∈ G e, v ∈ U → ∀ w ∈ G e, w ∈ U) : + ∀ y, Conn G η x y → y ∈ U := by + intro y hy + induction hy with + | refl => exact hx + | @tail v w hconn hstep ih => + obtain ⟨e,he,heq⟩ := hstep + exact hclosed e he v (by rw [heq]; simp) ih w (by rw [heq]; simp) + +lemma openFrontier_reachable (ω : Set E) (I : Set E) (x : V) {u : V} + (hu : u ∈ openFrontier G ω (cluster G (ω ∩ I) x)) : Conn G ω x u := by + obtain ⟨_,v,hv,e,he,heq⟩ := hu + exact (conn_mono G Set.inter_subset_left hv).tail ⟨e,he,heq⟩ + +theorem strict_peak_of_lower_frontier_surgery + (ω η : Set E) (D S F P : Set V) (x u z : V) (f : V → ℝ) + (hS : cluster G (ω ∩ internalEdges G D) x=S) + (hF : openFrontier G ω S=F) (hu : u ∈ F) + (hagree : ∀ e ∈ ballIncidentEdges G S, (e ∈ ω)=(e ∈ η)) + (hpath : Conn G η u z) + (hclosed : ∀ e ∈ η, ∀ v ∈ G e, v ∈ F ∪ P → + ∀ w ∈ G e, w ∈ S ∪ F ∪ P) + (hbelow : ∀ v ∈ S ∪ F, f v < f z) + (hpeak : ∀ v ∈ P, v ≠ z → f v < f z) : + Conn G η x z ∧ ∀ y, Conn G η z y → y ≠ z → f y < f z := by + have hSη : cluster G (η ∩ internalEdges G D) x=S := by + have hh := restricted_exactCluster_dependsOn G (internalEdges G D) x S hagree + exact (Iff.of_eq hh).mp hS + have hFη : openFrontier G η S=F := by + have hh := openFrontier_dependsOn G S hagree + exact hh.symm.trans hF + have huη : u ∈ openFrontier G η (cluster G (η ∩ internalEdges G D) x) := by + rwa [hSη,hFη] + have hxz : Conn G η x z := (openFrontier_reachable G η _ x huη).trans hpath + have hxU : x ∈ S ∪ F ∪ P := Or.inl (Or.inl (hSη ▸ mem_cluster_self G _ x)) + have hclose : ∀ e ∈ η, ∀ v ∈ G e, v ∈ S ∪ F ∪ P → + ∀ w ∈ G e, w ∈ S ∪ F ∪ P := by + intro e he v hv hvU w hw + rcases hvU with (hvS | hvF) | hvP + · by_cases hwS : w ∈ S + · exact Or.inl (Or.inl hwS) + · have hwF : w ∈ F := by + rw [←hFη] + have hne : v ≠ w := fun hvw => hwS (hvw ▸ hvS) + exact ⟨hwS,v,hvS,e,he,(Sym2.mem_and_mem_iff hne).mp ⟨hv,hw⟩⟩ + exact Or.inl (Or.inr hwF) + · exact hclosed e he v hv (Or.inl hvF) w hw + · exact hclosed e he v hv (Or.inr hvP) w hw + refine ⟨hxz,?_⟩ + intro y hzy hyz + have hyU := conn_mem_of_open_closed G η (S ∪ F ∪ P) x hxU hclose y (hxz.trans hzy) + rcases hyU with hy | hy + · exact hbelow y hy + · exact hpeak y hy hyz + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_peak_extension [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) : + ∃ L : ℕ, ∀ x, ∃ z, ∃ w : G.fullGraph.Walk x z, + w.length ≤ L ∧ + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v) ∧ + 2*R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x z ∧ + ∀ v ∈ w.support, v ≠ z → + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v < + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x z := by + obtain ⟨A,B,_hA,_hB,hpath⟩ := G.stationaryOrbitHeight_orbit_above hc hl hq μ hμ hstat hu + obtain ⟨L,hL⟩ := exists_nat_ge (A*(2*R)+B) + refine ⟨L,fun x => ?_⟩ + obtain ⟨y,p,_horb,hlen,hmin,hy⟩ := hpath (2*R) (by positivity) x (G.vertexOrbit x) + obtain ⟨z,hz,w,hwlen,hsub,hpeak⟩ := walk_first_strict_height_peak + (G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x) p (2*R) hy + refine ⟨z,w,?_,fun v hv => hmin v (hsub v hv),hz,hpeak⟩ + have hpL : p.length ≤ L := by exact_mod_cast hlen.trans hL + exact hwlen.trans hpL + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryProbability.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..05636e59074290c241590ba11535205a499c0c15 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSurgeryProbability.lean @@ -0,0 +1,99 @@ +import OAI.Probability.BenjaminiSchramm.PeakFiniteEnergy +import OAI.Probability.UnimodularPercolation.Deformation.Derivatives + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def strictHeightPeakConnection (f : V → ℝ) (x z : V) : Set (Set E) := + {ω | Conn G ω x z ∧ ∀ y, Conn G ω z y → y ≠ z → f y < f z} + +lemma measurableSet_strictHeightPeakConnection [Countable V] [Countable E] + (f : V → ℝ) (x z : V) : MeasurableSet (strictHeightPeakConnection G f x z) := by + exact ((measurableSet_conn G x z).mem.and (Measurable.forall fun y => + (measurableSet_conn G z y).mem.imp (measurable_const.imp measurable_const))).setOf + +theorem lowerFrontierCell_strict_peak_probability [Countable V] [Countable E] + (hloc : LocallyFinite G) (d : ℕ) (hd : ∀ v, degree G v ≤ d) + (p : unitInterval) (D S : Set V) (F : Finset V) (x u z : V) + (f : V → ℝ) (hu : u ∈ F) (w : (openSimpleGraph G Set.univ).Walk u z) + (havoid : ∀ v ∈ w.support, v ∉ S) + (hbelow : ∀ v ∈ S ∪ (F : Set V), f v < f z) + (hpeak : ∀ v ∈ w.support, v ≠ z → f v < f z) : + law p (lowerFrontierCell G (internalEdges G D) Set.univ x S (F : Set V))* + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(F.card+w.length+1))) ≤ + law p (lowerFrontierCell G (internalEdges G D) Set.univ x S (F : Set V) ∩ + strictHeightPeakConnection G f x z) := by + let A := lowerFrontierCell G (internalEdges G D) Set.univ x S (F : Set V) + let Q := ballIncidentEdges G S + let P := w.support.toFinset + let W := F ∪ P + let J := (incidentSupport G hloc W).filter fun e => e ∉ Q + obtain ⟨l,hl,he,_ho⟩ := walk_lift_bonds G Set.univ w + let σ : Set E := (l.toFinset : Set E) + have hends (e : E) (he' : e ∈ l) (v : V) (hv : v ∈ G e) : v ∈ P := + List.mem_toFinset.mpr (SimpleGraph.Walk.mem_support_of_mem_edges + (he ▸ List.mem_map_of_mem he') hv) + have hmem (e : E) (he' : e ∈ l) : e ∈ J := by + apply Finset.mem_filter.mpr + constructor + · exact (mem_incidentSupport G hloc W e).mpr + ⟨(G e).out.1,Finset.mem_union_right F (hends e he' _ (Sym2.out_fst_mem _)),Sym2.out_fst_mem _⟩ + · rintro ⟨v,hv,hve⟩ + exact havoid v (List.mem_toFinset.mp (hends e he' v hve)) hv + have hJ : (J : Set E) ⊆ Qᶜ := fun e he => (Finset.mem_filter.mp he).2 + have hJcard : J.card ≤ d*(F.card+w.length+1) := by + have hP : P.card ≤ w.length+1 := by + exact (List.toFinset_card_le w.support).trans_eq w.length_support + calc + _ ≤ (incidentSupport G hloc W).card := Finset.card_filter_le _ _ + _ ≤ W.card*d := incidentSupport_card_le G hloc d hd W + _ ≤ (F.card+P.card)*d := Nat.mul_le_mul_right d (Finset.card_union_le F P) + _ ≤ (F.card+(w.length+1))*d := Nat.mul_le_mul_right d (Nat.add_le_add_left hP F.card) + _ = _ := by ring + have hsub : A ∩ finiteBondPattern J σ ⊆ A ∩ strictHeightPeakConnection G f x z := by + rintro η ⟨hη,hpat⟩ + have hSη : cluster G (η ∩ internalEdges G D) x=S := hη.1 + have hFη : openFrontier G η S=(F : Set V) := by + simpa only [Set.inter_univ] using hη.2 + have hpath : Conn G η u z := hl.conn (fun e he' => + (Iff.of_eq (hpat e (hmem e he'))).mpr (List.mem_toFinset.mpr he')) + have hclosed : ∀ e ∈ η, ∀ v ∈ G e, v ∈ (F : Set V) ∪ (P : Set V) → + ∀ v' ∈ G e, v' ∈ S ∪ (F : Set V) ∪ (P : Set V) := by + intro e heη v hv hvW v' hv' + by_cases heQ : e ∈ Q + · obtain ⟨a,ha,hae⟩ := heQ + by_cases hvS : v' ∈ S + · exact Or.inl (Or.inl hvS) + · have hne : a ≠ v' := fun hh => hvS (hh ▸ ha) + have hvF : v' ∈ openFrontier G η S := + ⟨hvS,a,ha,e,heη,(Sym2.mem_and_mem_iff hne).mp ⟨hae,hv'⟩⟩ + exact Or.inl (Or.inr (hFη ▸ hvF)) + · have heJ : e ∈ J := Finset.mem_filter.mpr + ⟨(mem_incidentSupport G hloc W e).mpr + ⟨v,Finset.mem_union.mpr hvW,hv⟩,heQ⟩ + have heσ : e ∈ σ := (Iff.of_eq (hpat e heJ)).mp heη + exact Or.inr (hends e (List.mem_toFinset.mp heσ) v' hv') + refine ⟨hη,?_⟩ + exact strict_peak_of_lower_frontier_surgery G η η D S (F : Set V) (P : Set V) + x u z f hSη hFη hu (fun _ _ => rfl) hpath hclosed hbelow + (fun v hv hvz => hpeak v (List.mem_toFinset.mp hv) hvz) + have hδ : 0 ≤ min (p : ℝ) (1-p) := le_min p.2.1 (sub_nonneg.mpr p.2.2) + have hδ1 : min (p : ℝ) (1-p) ≤ 1 := (min_le_left _ _).trans p.2.2 + calc + _ ≤ law p A*ENNReal.ofReal ((min (p : ℝ) (1-p))^J.card) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (pow_le_pow_of_le_one hδ hδ1 hJcard)) + _ ≤ law p (A ∩ finiteBondPattern J σ) := fresh_finiteBondPattern_cell_lower p Q A + (measurableSet_lowerFrontierCell G _ _ x S _) (lowerFrontierCell_dependsOn G _ _ x S _) J hJ σ + _ ≤ _ := measure_mono hsub + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSurvivalCauchy.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSurvivalCauchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee0fd1d688854f7bf512b40f1d0c2d1f25424412 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSurvivalCauchy.lean @@ -0,0 +1,78 @@ +import OAI.Probability.BenjaminiSchramm.PeakBandSecondMoment +import OAI.Probability.BenjaminiSchramm.WeightedMomentCauchy + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma peakDownBandCount_le_full_count (a : V → ℝ) (l u : ℝ) (ω : Set E) (x : V) : + G.peakDownBandCount a l u ω x ≤ + restrictedLayerCount G.ends Set.univ Set.univ ω x := by + apply ENNReal.tsum_le_tsum + intro y + by_cases h : l < G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ u ∧ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a y) y x + · have hc := Percolation.conn_symm G.ends ω h.2.2.1 + simp only [peakUpBandTransport,ite_eq_left h,Set.mem_univ,true_and,Set.inter_univ, + ite_eq_left hc,le_refl] + · rw [peakUpBandTransport,ite_eq_right h] + exact bot_le + +variable [Countable V] [Countable E] + +theorem weighted_peakDownBandCount_cauchy + (O : G.OrbitRepresentatives) (a : V → ℝ) (l u : ℝ) (p : unitInterval) + (C : ℝ≥0∞) (hC : C ≠ ⊤) + (hrow : ∀ x, (∑' y, G.law p {ω | Percolation.Conn G.ends ω x y}) ≤ C) + (hsecond : ∀ x ∈ O.roots, (∫⁻ ω, (G.peakDownBandCount a l u ω x)^2 ∂G.law p) ≠ ⊤) : + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.peakDownBandCount a l u ω x ∂G.law p))^2 ≤ + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*G.law p {ω | 0 < G.peakDownBandCount a l u ω x})* + (∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, (G.peakDownBandCount a l u ω x)^2 ∂G.law p)) := by + apply weighted_lintegral_support_cauchy (G.law p) O.roots _ _ _ + (fun _ _ => ENNReal.ofReal_ne_top) + (fun x _ => measurableSet_lt measurable_const (G.measurable_peakDownBandCount a l u x)) + (fun x _ => G.measurable_peakDownBandCount a l u x) + (fun x _ ω hω => le_antisymm (le_of_not_gt hω) bot_le) + (fun _ _ => measure_ne_top _ _) _ hsecond + intro x _ + apply ne_top_of_le_ne_top hC + exact (lintegral_mono fun ω => G.peakDownBandCount_le_full_count a l u ω x).trans + (restrictedLayerCount_expectation_le_row_bound G.ends p C hrow _ _ x) + +theorem peakDownBandCount_probability_lower_of_moments + (O : G.OrbitRepresentatives) (a : V → ℝ) (l u : ℝ) (p : unitInterval) + (C : ℝ≥0∞) (hC : C ≠ ⊤) + (hrow : ∀ x, (∑' y, G.law p {ω | Percolation.Conn G.ends ω x y}) ≤ C) + (c D t : ℝ) (hc : 0 < c) (hD : 0 < D) (ht : 0 < t) + (hlower : ENNReal.ofReal (c*t) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, G.peakDownBandCount a l u ω x ∂G.law p)) + (hsecond : ∀ x ∈ O.roots, (∫⁻ ω, (G.peakDownBandCount a l u ω x)^2 ∂G.law p) ≠ ⊤) + (hupper : (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, (G.peakDownBandCount a l u ω x)^2 ∂G.law p)) ≤ ENNReal.ofReal (D*t)) : + ENNReal.ofReal (c^2/D*t) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*G.law p {ω | 0 < G.peakDownBandCount a l u ω x} := by + let Q := ∑ x ∈ O.roots, ENNReal.ofReal (a x)*G.law p {ω | 0 < G.peakDownBandCount a l u ω x} + have hQ : Q ≠ ⊤ := ENNReal.sum_ne_top.mpr fun x _ => + ENNReal.mul_ne_top ENNReal.ofReal_ne_top (measure_ne_top _ _) + have hh := (pow_le_pow_left' hlower 2).trans + ((G.weighted_peakDownBandCount_cauchy O a l u p C hC hrow hsecond).trans (mul_le_mul' le_rfl hupper)) + have hreal := ENNReal.toReal_mono (ENNReal.mul_ne_top hQ ENNReal.ofReal_ne_top) hh + rw [ENNReal.toReal_pow,ENNReal.toReal_ofReal (mul_nonneg hc.le ht.le), + ENNReal.toReal_mul,ENNReal.toReal_ofReal (mul_nonneg hD.le ht.le)] at hreal + have he : c^2*t ≤ Q.toReal*D := (mul_le_mul_iff_right₀ ht).mp (by nlinarith) + apply ENNReal.ofReal_le_of_le_toReal + calc + c^2/D*t = (c^2*t)/D := by ring + _ ≤ Q.toReal := (div_le_iff₀ hD).mpr he + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakSurvivalRealHeight.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakSurvivalRealHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..1496bd03466c128e700b4a2d789c13bf92d7ccfd --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakSurvivalRealHeight.lean @@ -0,0 +1,87 @@ +import OAI.Probability.BenjaminiSchramm.PeakConditionalLayers +import OAI.Probability.BenjaminiSchramm.WeightedPeakSlabComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma positive_peakDownBandCount_subset_fullPeakDownHit + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (l u ell : ℝ) (hell : ell ≤ l) (x : V) : + {ω | 0 < G.peakDownBandCount a l u ω x} ⊆ G.fullPeakDownHit a ell x := by + intro ω hω + change 0 < G.peakDownBandCount a l u ω x at hω + have he : ∃ y, l < G.orbitAdjustedHeight a y x ∧ G.orbitAdjustedHeight a y x ≤ u ∧ + ω ∈ strictHeightPeakConnection G.ends (G.orbitAdjustedHeight a y) y x := by + by_contra hn + have hz : G.peakDownBandCount a l u ω x=0 := ENNReal.tsum_eq_zero.mpr fun y => + ite_eq_right (fun hy => hn ⟨y,hy⟩) + rw [hz] at hω + exact lt_irrefl _ hω + obtain ⟨y,hylo,_hyhi,hxy,hpeak⟩ := he + refine ⟨⟨Percolation.conn_refl G.ends ω x,?_⟩,y,?_,?_⟩ + · intro z hxz hzx + have hz := hpeak z hxz hzx + rw [G.orbitAdjustedHeight_change_base hc hl a y x z] at hz + rw [G.orbitAdjustedHeight_self] + linarith + · change G.orbitAdjustedHeight a x y ≤ -ell + rw [G.orbitAdjustedHeight_reverse hc hl a x y] at hylo + linarith + · simpa only [Set.inter_univ] using Percolation.conn_symm G.ends ω hxy + +lemma peakSurvivalProbability_le_fullPeakDownProbability + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) (ell : ℝ) + (hell : ell ≤ R*((n : ℝ)+1)) : + G.peakSurvivalProbability O a R p n ≤ G.fullPeakDownProbability O a p ell := by + apply Finset.sum_le_sum + intro x _ + exact mul_le_mul' le_rfl (measure_mono + (G.positive_peakDownBandCount_subset_fullPeakDownHit hc hl a _ _ ell hell x)) + +theorem full_peak_survival_real_lower + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (hR : 0 < R) (p : unitInterval) + (c b : ℝ) (hcpos : 0 < c) (hb : 0 ≤ b) + (hsurv : ∀ n : ℕ, 0 < n → ENNReal.ofReal (c*Real.exp (-b*n)) ≤ + G.peakSurvivalProbability O a R p n) (ell : ℝ) (hell : 0 < ell) : + ENNReal.ofReal ((c*Real.exp (-2*b))*Real.exp (-(b/R)*ell)) ≤ + G.fullPeakDownProbability O a p ell := by + let n : ℕ := ⌈ell/R⌉₊+1 + have hnpos : 0 < n := Nat.zero_lt_succ _ + have hnlo : ell ≤ R*(n : ℝ) := by + have hh := (div_le_iff₀ hR).mp (Nat.le_ceil (ell/R)) + dsimp [n] + push_cast + nlinarith + have hnhi : (n : ℝ) ≤ ell/R+2 := by + have hh := (Nat.ceil_lt_add_one (div_nonneg hell.le hR.le)).le + dsimp [n] + push_cast + linarith + have he : (c*Real.exp (-2*b))*Real.exp (-(b/R)*ell) = c*Real.exp (-b*(ell/R+2)) := by + rw [mul_assoc,←Real.exp_add] + congr 2 + ring + calc + _ ≤ ENNReal.ofReal (c*Real.exp (-b*n)) := by + apply ENNReal.ofReal_le_ofReal + rw [he] + apply mul_le_mul_of_nonneg_left _ hcpos.le + apply Real.exp_le_exp.mpr + nlinarith + _ ≤ G.peakSurvivalProbability O a R p n := hsurv n hnpos + _ ≤ _ := G.peakSurvivalProbability_le_fullPeakDownProbability O hc hl a R p n ell (by nlinarith) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PeakUpperExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/PeakUpperExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..43cefe9649496bb7ec3295d1e9323cd7a38b71a6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PeakUpperExposure.lean @@ -0,0 +1,89 @@ +import OAI.Probability.BenjaminiSchramm.PeakComplementCorrelation + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restricted_exactCluster_dependsOn_inter (K : Set E) (x : V) (A : Set V) : + DependsOn (fun ω => cluster G (ω ∩ K) x=A) (K ∩ ballIncidentEdges G A) := by + intro ω η hωη + have hh : ∀ e ∈ ballIncidentEdges G A, + (e ∈ Set.inter ω K)=(e ∈ Set.inter η K) := by + intro e he + change (ω e ∧ e ∈ K)=(η e ∧ e ∈ K) + by_cases hk : e ∈ K + · exact congrArg (fun P : Prop => P ∧ e ∈ K) (hωη e ⟨hk,he⟩) + · simp only [hk,and_false] + have h := (criticalModel G).exactCluster_dependsOn x A hh + change ((criticalModel G).cluster (Set.inter ω K) x=A) = + ((criticalModel G).cluster (Set.inter η K) x=A) at h + rw [criticalModel_cluster,criticalModel_cluster] at h + exact h + +lemma restrictedSetHit_dependsOn (I : Set E) (A T : Set V) : + DependsOn (fun ω => ω ∈ restrictedSetHit G I A T) I := by + intro ω η hωη + have he : Set.inter ω I=Set.inter η I := by + ext e + change (ω e ∧ e ∈ I) ↔ (η e ∧ e ∈ I) + by_cases hi : e ∈ I + · exact and_congr (Iff.of_eq (hωη e hi)) Iff.rfl + · simp only [hi,and_false] + exact congrArg (fun ξ : Set E => ∃ v ∈ A, ∃ t ∈ T, Conn G ξ v t) he + +theorem upper_cluster_forbidden_hit_iff (ω : Set E) (D K : Set E) (hKD : K ⊆ D) + (x : V) (A T : Set V) (hA : cluster G (ω ∩ K) x=A) (hAT : Disjoint A T) : + ω ∈ restrictedHit G D x T ↔ + ω ∈ restrictedSetHit G (D \ (K ∩ ballIncidentEdges G A)) A T := by + constructor + · rintro ⟨t,ht,hxt⟩ + have hxA : x ∈ A := hA ▸ mem_cluster_self G _ x + have htA : t ∉ A := fun h => Set.disjoint_left.mp hAT h ht + obtain ⟨z,hz,hzt⟩ := conn_last_exit_frontier G (ω ∩ D) A hxA htA hxt + obtain ⟨hzA,u,hu,e,he,heq⟩ := hz + have hek : e ∉ K := by + intro hk + apply hzA + rw [←hA] + have hxu : Conn G (ω ∩ K) x u := by + change u ∈ cluster G (ω ∩ K) x + rwa [hA] + exact hxu.tail ⟨e,⟨he.1,hk⟩,heq⟩ + have huz : Conn G (ω ∩ (D \ (K ∩ ballIncidentEdges G A))) u z := + (conn_refl G _ u).tail ⟨e,⟨he.1,he.2,fun h => hek h.1⟩,heq⟩ + refine ⟨u,hu,t,ht,huz.trans (conn_mono G ?_ hzt)⟩ + rintro e ⟨⟨he,heD⟩,heA⟩ + exact ⟨he,heD,fun h => heA h.2⟩ + · rintro ⟨u,hu,t,ht,hut⟩ + have hxu : Conn G (ω ∩ K) x u := by + change u ∈ cluster G (ω ∩ K) x + rwa [hA] + refine ⟨t,ht,(conn_mono G (Set.inter_subset_inter_right _ hKD) hxu).trans ?_⟩ + exact conn_mono G (Set.inter_subset_inter_right _ Set.sdiff_subset) hut + +variable [Countable V] [Countable E] + +lemma upper_cluster_fresh_factor (p : unitInterval) (K I : Set E) (x : V) (A : Set V) + (hfresh : I ⊆ (K ∩ ballIncidentEdges G A)ᶜ) + (B : Set (Set E)) (hB : MeasurableSet B) + (hdB : DependsOn (fun ω => ω ∈ B) I) : + law p ({ω | cluster G (ω ∩ K) x=A} ∩ B) = + law p {ω | cluster G (ω ∩ K) x=A} * law p B := by + have hlaw : CriticalPercolation.BernoulliProduct.law (fun _ : E => p)=law p := + CriticalPercolation.BernoulliProduct.law_const p + rw [←hlaw] + exact CriticalPercolation.BernoulliProduct.measure_inter_of_separate_blocks + (fun _ : E => p) (K ∩ ballIncidentEdges G A) _ B + (measurableSet_restricted_exactCluster G K x A) hB + (restricted_exactCluster_dependsOn_inter G K x A) (DependsOn.mono hfresh hdB) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PhaseInput.lean b/lean/OAI/Probability/BenjaminiSchramm/PhaseInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd0c337dce8c930f64956ed74fbfd50c342e71d3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PhaseInput.lean @@ -0,0 +1,108 @@ +import OAI.Probability.BenjaminiSchramm.Cayley +import OAI.Probability.CriticalPercolation.Clusters.ClusterNumber + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +def criticalModel (G : BondGraph V E) : CriticalPercolation.BondGraph V E := ⟨G⟩ + +theorem criticalModel_openGraph (G : BondGraph V E) (ω : Set E) : + (criticalModel G).openGraph ω = openSimpleGraph G ω := by + ext x y + simp only [CriticalPercolation.BondGraph.openGraph, SimpleGraph.fromEdgeSet_adj, + Set.mem_image, openSimpleGraph, criticalModel] + tauto + +theorem criticalModel_cluster (G : BondGraph V E) (ω : Set E) (x : V) : + (criticalModel G).cluster ω x = cluster G ω x := by + ext y + simp only [CriticalPercolation.BondGraph.cluster, criticalModel_openGraph, + Set.mem_ofPred_eq, cluster] + exact (conn_iff_reachable G ω x y).symm + +theorem criticalModel_connected [Nonempty V] (G : BondGraph V E) (hconn : Connected G) : + (criticalModel G).fullGraph.Connected := by + rw [CriticalPercolation.BondGraph.fullGraph, criticalModel_openGraph] + exact ⟨fun x y => (conn_iff_reachable G Set.univ x y).mp (conn_univ_of_connected G hconn x y)⟩ + +theorem criticalModel_quasiTransitive (G : BondGraph V E) (hqt : QuasiTransitive G) : + (criticalModel G).QuasiTransitive := by + obtain ⟨S, hS⟩ := hqt + refine ⟨S, S.finite_toSet, ?_⟩ + intro x + obtain ⟨o, ho, a, b, hab, hax⟩ := hS x + exact ⟨o, ho, ⟨a, b, hab⟩, hax⟩ + +theorem ae_exists_infinite_cluster_law [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (hp : pc G < p) : + ∀ᵐ ω ∂law p, ∃ x, (cluster G ω x).Infinite := by + have h := ae_exists_infinite_cluster_of_pc_lt G p hp + rw [ae_iff] at h ⊢ + rw [← map_openEdges p, Measure.map_apply (measurable_openEdges p) + (show MeasurableSet {ω : Set E | ¬ ∃ x, (cluster G ω x).Infinite} from + (measurableSet_exists_infinite_cluster G).compl)] + exact h + +theorem infiniteClusters_infinite_of_criticalModel (G : BondGraph V E) (ω : Set E) + (h : (criticalModel G).infinitelyManyInfiniteClusters ω) : + (infiniteClusters G ω).Infinite := by + classical + intro hf + let C := infiniteClusters G ω + let : Fintype C := hf.fintype + let root : C → V := fun c => Classical.choose c.property.2 + let S : Finset V := Finset.univ.image root + obtain ⟨v, hv, havoid⟩ := h S + rw [criticalModel_cluster] at hv + let c : C := ⟨cluster G ω v, hv, v, rfl⟩ + have hc : cluster G ω v = cluster G ω (root c) := Classical.choose_spec c.property.2 + have hr : root c ∈ S := Finset.mem_image.mpr ⟨c, Finset.mem_univ _, rfl⟩ + apply havoid (root c) hr + rw [criticalModel_openGraph] + apply (conn_iff_reachable G ω v (root c)).mp + change root c ∈ cluster G ω v + rw [hc] + exact mem_cluster_self G ω (root c) + +theorem publishedPhaseInput_proved [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) : PublishedPhaseInput G := by + classical + let : Countable V := countable_vertices hloc hconn + let : Countable E := countable_edges hloc + intro p hp hpu + have hp0 : (0 : ℝ) < p := lt_of_le_of_lt (pc G).2.1 hp + have hc := criticalModel_connected G hconn + have hq := criticalModel_quasiTransitive G hqt + rcases (criticalModel G).unique_or_infinitely_many_ae hc hloc hq p hp0 with hu | hi + · have hex := ae_exists_infinite_cluster_law G p hp + have hunique : ∀ᵐ ω ∂law p, ∃! C, C ∈ infiniteClusters G ω := by + filter_upwards [hu, hex] with ω hω hωinf + obtain ⟨x, hx⟩ := hωinf + refine ⟨cluster G ω x, ⟨hx, x, rfl⟩, ?_⟩ + rintro C ⟨hC, y, rfl⟩ + apply cluster_eq_of_conn G ω + apply (conn_iff_reachable G ω y x).mpr + rw [← criticalModel_openGraph] + apply hω y x + · rwa [criticalModel_cluster] + · rwa [criticalModel_cluster] + have hprob : law p {ω | ∃! C, C ∈ infiniteClusters G ω} = 1 := by + calc + _ = (law p : Measure (Set E)) Set.univ := by + apply measure_congr + filter_upwards [hunique] with ω hω + exact propext (iff_true_intro hω) + _ = 1 := measure_univ + exact False.elim (not_le_of_gt hpu (sInf_le hprob)) + · exact hi.mono (fun ω hω => infiniteClusters_infinite_of_criticalModel G ω hω) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PivotalExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/PivotalExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..f709293e577e92256cca4b70c14db9d17a380896 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PivotalExposure.lean @@ -0,0 +1,60 @@ +import OAI.Probability.BenjaminiSchramm.ClusterExposure +import OAI.Probability.BenjaminiSchramm.EdgeClosing + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +lemma exactCluster_boundary_closed {ω : Set E} {x u v : V} {S : Set V} {e : E} + (hends : G.ends e = s(u,v)) (hu : u ∈ S) (hv : v ∉ S) + (hS : G.cluster ω x = S) : e ∉ ω := by + intro he + have huv : u ≠ v := fun huv => hv (huv ▸ hu) + have hadj : (G.openGraph ω).Adj u v := + (SimpleGraph.fromEdgeSet_adj _).mpr ⟨⟨e,he,hends⟩,huv⟩ + have hxu : (G.openGraph ω).Reachable x u := by + change u ∈ G.cluster ω x + rwa [hS] + exact hv (hS ▸ (hxu.trans hadj.reachable)) + +theorem closed_cluster_pivotal_factor [Countable V] [Countable E] + (p : unitInterval) (hp : (p : ℝ) < 1) (x : V) (S : Set V) (e : E) + (u v : V) (hends : G.ends e = s(u,v)) (hu : u ∈ S) (hv : v ∉ S) + (F : Set E → ℝ≥0∞) (hF : Measurable F) : + (∫⁻ ω, if e ∈ ω then + ({η | G.cluster η x = S} : Set (Set E)).indicator + (fun η => F (G.eraseVertices η S)) (BernoulliProduct.forceOn {e} ∅ ω) + else 0 ∂G.law p) = + (ENNReal.ofReal (p : ℝ) / ENNReal.ofReal (1 - (p : ℝ))) * + G.law p {ω | G.cluster ω x = S} * + ∫⁻ η, F (G.eraseVertices η S) ∂G.law p := by + let f : Set E → ℝ≥0∞ := ({η | G.cluster η x = S} : Set (Set E)).indicator + (fun η => F (G.eraseVertices η S)) + have hf : Measurable f := (hF.comp (G.measurable_eraseVertices S)).indicator + (G.measurableSet_exactCluster x S) + have heq : (fun ω => if e ∉ ω then f ω else 0) = f := by + funext ω + by_cases hS : G.cluster ω x = S + · rw [ite_eq_left (G.exactCluster_boundary_closed hends hu hv hS)] + · simp only [f, Set.indicator, Set.mem_ofPred_eq, ite_eq_right hS, ite_self] + have hclose := BernoulliProduct.lintegral_edge_closing (fun _ : E => p) e hp f hf + rw [heq] at hclose + have hlaw : BernoulliProduct.law (fun _ : E => p) = G.law p := + BernoulliProduct.law_const p + rw [hlaw] at hclose + change (∫⁻ ω, if e ∈ ω then f (BernoulliProduct.forceOn {e} ∅ ω) else 0 ∂G.law p) = _ + rw [hclose] + change _ * (∫⁻ ω, ({ω | G.cluster ω x = S} : Set (Set E)).indicator + (fun ω => F (G.eraseVertices ω S)) ω ∂G.law p) = _ + rw [G.exactCluster_exterior_factor p x S F hF, mul_assoc] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PrefixMaximumBootstrap.lean b/lean/OAI/Probability/BenjaminiSchramm/PrefixMaximumBootstrap.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d5c1c2648f3983e9127416c0075646fad103472 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PrefixMaximumBootstrap.lean @@ -0,0 +1,58 @@ +import Mathlib.Data.Finset.Lattice.Fold +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +def prefixMaximum (h : ℕ → ℝ) (n : ℕ) : ℝ := + (Finset.range (n+1)).sup' ⟨0,by simp⟩ h + +lemma le_prefixMaximum (h : ℕ → ℝ) {j n : ℕ} (hj : j ≤ n) : + h j ≤ prefixMaximum h n := + Finset.le_sup' h (Finset.mem_range.mpr (Nat.lt_succ_of_le hj)) + +theorem prefix_max_bootstrap (h : ℕ → ℝ) (C : ℝ) + (hrec : ∀ n, 2*h n-prefixMaximum h n ≤ C) (n : ℕ) : h n ≤ C := by + obtain ⟨j,hj,he⟩ := (Finset.range (n+1)).exists_mem_eq_sup' ⟨0,by simp⟩ h + have hjn : j ≤ n := Nat.le_of_lt_succ (Finset.mem_range.mp hj) + have hmax : prefixMaximum h j = h j := by + apply le_antisymm + · apply Finset.sup'_le + intro i hi + exact (le_prefixMaximum h (by have hh := Finset.mem_range.mp hi; omega)).trans_eq he + · exact le_prefixMaximum h le_rfl + have hb := hrec j + rw [hmax] at hb + exact (le_prefixMaximum h le_rfl).trans (he.trans_le (by linarith)) + +theorem exponential_prefix_max_bootstrap (h : ℕ → ℝ) (C : ℝ) (hC : 0 < C) + (hrec : ∀ n, Real.exp (2*h n-prefixMaximum h n) ≤ C) (n : ℕ) : + Real.exp (h n) ≤ C := by + have hb := prefix_max_bootstrap h (Real.log C) + (fun k => by simpa only [Real.log_exp] using + Real.log_le_log (Real.exp_pos _) (hrec k)) n + exact (Real.exp_le_exp.mpr hb).trans_eq (Real.exp_log hC) + +theorem prefix_square_bootstrap (h : ℕ → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hrec : ∀ n, (h n)^2 ≤ C*prefixMaximum h n) (n : ℕ) : h n ≤ C := by + obtain ⟨j,hj,he⟩ := (Finset.range (n+1)).exists_mem_eq_sup' ⟨0,by simp⟩ h + have hjn : j ≤ n := Nat.le_of_lt_succ (Finset.mem_range.mp hj) + have hmax : prefixMaximum h j = h j := by + apply le_antisymm + · apply Finset.sup'_le + intro i hi + exact (le_prefixMaximum h (by have hh := Finset.mem_range.mp hi; omega)).trans_eq he + · exact le_prefixMaximum h le_rfl + have hb := hrec j + rw [hmax] at hb + have hbound : h j ≤ C := by + by_cases hh : h j ≤ 0 + · exact hh.trans hC + · have hp : 0 < h j := lt_of_not_ge hh + nlinarith + exact (le_prefixMaximum h le_rfl).trans (he.trans_le hbound) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ProbabilityLower.lean b/lean/OAI/Probability/BenjaminiSchramm/ProbabilityLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..2979018d44a3d2d300403244c35e02bc964c78de --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ProbabilityLower.lean @@ -0,0 +1,180 @@ +import OAI.Probability.BenjaminiSchramm.InputReduction + +namespace OAI + +open MeasureTheory Filter +open scoped Topology ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem cluster_finite_ae_of_finite_mass [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (x : V) + (hf : (∑' y, law p {ω | Conn G ω x y}) ≠ ⊤) : + ∀ᵐ ω ∂law p, (cluster G ω x).Finite := by + have hi : (∫⁻ ω, clusterMass G ω x ∂law p) ≠ ⊤ := by + rwa [lintegral_clusterMass] + filter_upwards [ae_lt_top (measurable_clusterMass G x) hi] with ω hω + by_contra hinf + have hinf : (cluster G ω x).Infinite := hinf + obtain ⟨n,hn⟩ := exists_nat_gt (clusterMass G ω x).toReal + have hvol : ω ∈ volumeEvent G x n := by + change (n : ℕ∞) ≤ (cluster G ω x).encard + rw [Set.encard_eq_top hinf] + exact le_top + have hb := ENNReal.toReal_mono hω.ne (volume_threshold_le_clusterMass G ω x n hvol) + rw [ENNReal.toReal_natCast] at hb + exact (not_lt_of_ge hb) hn + +theorem uniform_testSets_of_good_cost [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) + (hgood : ∀ x, ∃ S : Finset V, x ∈ S ∧ boundaryCost G hloc S x (p : ℝ) < 1) : + ∃ (L : ℕ) (a : ℝ), a < 1 ∧ ∀ x, ∃ S : Finset V, + x ∈ S ∧ S.card ≤ L ∧ boundaryCost G hloc S x (p : ℝ) ≤ a := by + obtain ⟨O,hO⟩ := hqt + choose S hmem hcost using hgood + have hOn : O.Nonempty := by + obtain ⟨o,ho,_⟩ := hO (Classical.ofNonempty : V) + exact ⟨o,ho⟩ + let L := O.sup (fun x => (S x).card) + let a := O.sup' hOn (fun x => boundaryCost G hloc (S x) x (p : ℝ)) + refine ⟨L,a,(Finset.sup'_lt_iff hOn).mpr (fun x _ => hcost x),?_⟩ + intro x + obtain ⟨o,ho,α,β,hαβ,rfl⟩ := hO x + refine ⟨(S o).map α.toEmbedding,?_,?_,?_⟩ + · simp only [Finset.mem_map,Equiv.toEmbedding_apply] + exact ⟨o,hmem o,rfl⟩ + · simpa only [Finset.card_map] using Finset.le_sup (f := fun x => (S x).card) ho + · rw [boundaryCost_aut G hloc hαβ] + exact Finset.le_sup' (f := fun x => boundaryCost G hloc (S x) x (p : ℝ)) ho + +theorem finite_mass_of_uniform_testSets [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (L : ℕ) (a : ℝ) (ha : a < 1) + (htest : ∀ x, ∃ S : Finset V, + x ∈ S ∧ S.card ≤ L ∧ boundaryCost G hloc S x (p : ℝ) ≤ a) (x : V) : + (∑' y, law p {ω | Conn G ω x y}) ≠ ⊤ := by + let : Encodable V := Encodable.ofCountable V + have hrow (F : Finset V) : ∑ y ∈ F, twoPoint G p x y ≤ (L : ℝ) / (1 - a) := by + apply le_of_tendsto (tendsto_finsetSum F (fun y _ => tendsto_domainTwoPoint G p x y)) + obtain ⟨N,hN⟩ := subset_vertexExhaustion F + filter_upwards [eventually_ge_atTop N] with n hn + have hFn : F ⊆ vertexExhaustion n := hN.trans (vertexExhaustion_mono hn) + exact (Finset.sum_le_sum_of_subset_of_nonneg hFn (fun _ _ _ => measureReal_nonneg)).trans + (domainRow_uniform_bound G hloc p L a ha htest (vertexExhaustion n) x) + have hs := summable_of_sum_le (twoPoint_nonneg G p x) hrow + have he : ENNReal.ofReal (susceptibility G p x) = + ∑' y, law p {ω | Conn G ω x y} := by + rw [susceptibility,ENNReal.ofReal_tsum_of_nonneg (twoPoint_nonneg G p x) hs] + apply tsum_congr + intro y + exact ENNReal.ofReal_toReal (measure_ne_top _ _) + rw [←he] + exact ENNReal.ofReal_ne_top + +theorem exists_bad_cost_of_pc_lt [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : pc G < p) : + ∃ x, ∀ S : Finset V, x ∈ S → 1 ≤ boundaryCost G hloc S x (p : ℝ) := by + by_contra! hgood + obtain ⟨L,a,ha,htest⟩ := uniform_testSets_of_good_cost G hloc hqt p hgood + have hfin (x : V) : ∀ᵐ ω ∂law p, (cluster G ω x).Finite := + cluster_finite_ae_of_finite_mass G p x + (finite_mass_of_uniform_testSets G hloc p L a ha htest x) + have hz : law p {ω | (infiniteClusters G ω).Nonempty} = 0 := by + have he : {ω | (infiniteClusters G ω).Nonempty} = + ⋃ x, {ω | (cluster G ω x).Infinite} := by + ext ω + simp only [infiniteClusters_nonempty_iff,Set.mem_iUnion,Set.mem_ofPred_eq] + rw [he] + exact measure_iUnion_null (fun x => ae_iff.mp (hfin x)) + obtain ⟨q,hq,hqp⟩ := sInf_lt_iff.mp hp + have hpos : 0 < law p {ω | (infiniteClusters G ω).Nonempty} := + hq.trans_le (exists_infinite_cluster_probability_mono G hqp.le) + rw [hz] at hpos + exact hpos.false + +theorem percolationProbability_mul_twoPoint_le [Countable E] + (G : BondGraph V E) (p : unitInterval) (x y : V) : + percolationProbability G p x * twoPoint G p x y ≤ percolationProbability G p y := by + apply (association_infinite_conn G p x x y).trans + apply measureReal_mono (h₂ := measure_ne_top _ _) + rintro ω ⟨hi,hc⟩ + change (cluster G ω y).Infinite + rwa [←cluster_eq_of_conn G ω hc] + +theorem percolationProbability_lower_of_bad_cost [Countable V] + (G : BondGraph V E) (hloc : LocallyFinite G) (x : V) (r p : unitInterval) + (hr : 0 < r) (hrp : r < p) (hp : p < 1) + (hcost : ∀ S : Finset V, x ∈ S → 1 ≤ boundaryCost G hloc S x (r : ℝ)) : + 1 - Real.exp ((r : ℝ) - p) ≤ percolationProbability G p x := by + apply infinite_cluster_probability_ge_of_escape G hloc x p + intro Λ + rw [←finite_escape_eq_law G hloc Λ x p] + apply (finite_escape_probability_lower G Λ x (incidentSupport G hloc Λ) + r p hr hrp hp ?_).2 + intro S hS hx + rw [boundaryExpectation_eq_of_incident_subset G hloc S x _ + (incidentSupport_mono G hloc hS)] + exact hcost S hx + +theorem one_sub_exp_neg_linear (s : ℝ) (hs0 : 0 ≤ s) (hs1 : s ≤ 1) : + Real.exp (-1) * s ≤ 1 - Real.exp (-s) := by + have hh := mul_le_mul_of_nonneg_right (Real.add_one_le_exp s) (Real.exp_pos (-s)).le + rw [←Real.exp_add,add_neg_cancel,Real.exp_zero] at hh + have he : Real.exp (-1) ≤ Real.exp (-s) := Real.exp_le_exp.mpr (by linarith) + have hl := mul_le_mul_of_nonneg_right he hs0 + nlinarith + +theorem percolationProbability_linear_lower [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (x : V) : + ∃ c : ℝ, 0 < c ∧ ∀ p : unitInterval, pc G < p → p < 1 → + c * ((p : ℝ) - pc G) ≤ percolationProbability G p x := by + obtain ⟨O,hO⟩ := hqt + have hqt : QuasiTransitive G := ⟨O,hO⟩ + have hOn : O.Nonempty := by + obtain ⟨o,ho,_⟩ := hO x + exact ⟨o,ho⟩ + have hpc0 : 0 < pc G := pc_pos G hloc hqt + let a : ℝ := O.inf' hOn (fun o => twoPoint G (pc G) o x) + have ha : 0 < a := (Finset.lt_inf'_iff hOn).mpr + (fun o _ => twoPoint_pos G hconn (pc G) hpc0 o x) + refine ⟨a * Real.exp (-1) / 2,by positivity,fun p hp hp1 => ?_⟩ + have hpR : (pc G : ℝ) < (p : ℝ) := hp + let r : unitInterval := ⟨((p : ℝ) + pc G) / 2, + ⟨by linarith [p.2.1,(pc G).2.1],by linarith [p.2.2,(pc G).2.2]⟩⟩ + have hrc : pc G < r := by change (pc G : ℝ) < ((p : ℝ) + pc G) / 2; linarith only [hpR] + have hrp : r < p := by change ((p : ℝ) + pc G) / 2 < (p : ℝ); linarith only [hpR] + obtain ⟨z,hcost⟩ := exists_bad_cost_of_pc_lt G hloc hqt r hrc + have hb := percolationProbability_lower_of_bad_cost G hloc z r p (hpc0.trans hrc) hrp hp1 hcost + obtain ⟨o,ho,α,β,hαβ,rfl⟩ := hO z + have hθ : 1 - Real.exp ((r : ℝ) - p) ≤ percolationProbability G p o := by + change 1 - Real.exp ((r : ℝ) - p) ≤ (law p).real {ω | (cluster G ω (α o)).Infinite} at hb + rw [infinite_cluster_aut G p hαβ] at hb + exact hb + have hτ : a ≤ twoPoint G p o x := + (Finset.inf'_le (f := fun o => twoPoint G (pc G) o x) ho).trans + (twoPoint_mono G o x hp.le) + have ht := (mul_le_mul_of_nonneg_left hτ + (show 0 ≤ percolationProbability G p o from ENNReal.toReal_nonneg)).trans + (percolationProbability_mul_twoPoint_le G p o x) + let s : ℝ := (p : ℝ) - r + have hs0 : 0 ≤ s := sub_nonneg.mpr hrp.le + have hs1 : s ≤ 1 := by dsimp [s]; linarith [p.2.2,r.2.1] + have hl := one_sub_exp_neg_linear s hs0 hs1 + have he : (r : ℝ) - p = -s := by dsimp [s]; ring + rw [he] at hθ + have hm := mul_le_mul_of_nonneg_right (hl.trans hθ) ha.le + have hid : (Real.exp (-1) * s) * a = + (a * Real.exp (-1) / 2) * ((p : ℝ) - pc G) := by dsimp [s,r]; ring + rw [hid] at hm + exact hm.trans ht + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ProbabilityUpper.lean b/lean/OAI/Probability/BenjaminiSchramm/ProbabilityUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b3d2753ec4133d3e0b3eac5dc3b4e00b522761b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ProbabilityUpper.lean @@ -0,0 +1,113 @@ +import OAI.Probability.BenjaminiSchramm.GhostEntropy + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem markedConnection_entropy_uniform + (G : BondGraph V E) (Q : Finset E) (x : V) (p q h : unitInterval) + (hp : (p : ℝ) ∈ Set.Ioo 0 1) (hq : (q : ℝ) ∈ Set.Ioo 0 1) + (hh : (h : ℝ) ∈ Set.Ioo 0 1) (d : ℕ) + (hdeg : ∀ v, (Q.filter (fun e => v ∈ G e)).card ≤ d) + (D : ℝ) (hD : 0 < D) (hden : D ≤ (q : ℝ) * (1-q)) + (hsmall : ((p : ℝ) - q) ^ 2 ≤ h) : + markedConnectionPolynomial G Q x h q ≤ + (2 + 2 * (d : ℝ) / D) * markedConnectionPolynomial G Q x h p := by + apply (markedConnection_entropy_comparison G Q x p q h hp hq hh d hdeg).trans + apply mul_le_mul_of_nonneg_right _ (by + rw [markedConnectionPolynomial_eq_tree] + exact ProbeTree.successMass_nonneg p h _) + apply add_le_add_right + have hd : 0 ≤ 2 * (d : ℝ) := by positivity + have hden0 : 0 < (q : ℝ) * (1-q) := hD.trans_le hden + calc + 2 * (d : ℝ) * ((p : ℝ) - q) ^ 2 / ((q : ℝ) * (1-q) * h) ≤ + 2 * (d : ℝ) * h / ((q : ℝ) * (1-q) * h) := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hsmall hd) + (mul_nonneg hden0.le hh.1.le) + _ = 2 * (d : ℝ) / ((q : ℝ) * (1-q)) := by field_simp [hh.1.ne'] + _ ≤ 2 * (d : ℝ) / D := div_le_div_of_nonneg_left hd hD hden + +theorem percolationProbability_upper_of_uniform_critical_volume [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hpc1 : (pc G : ℝ) < 1) + (C : ℝ) (hC : 0 < C) + (hvolume : ∀ x n, 0 < n → criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n) : + ∃ A η : ℝ, 0 < A ∧ 0 < η ∧ ∀ p : unitInterval, pc G < p → + (p : ℝ) - pc G < η → ∀ x, + percolationProbability G p x ≤ A * ((p : ℝ) - pc G) := by + obtain ⟨d,_hd,hdeg⟩ := exists_degree_bound G hqt + have hpc0 : 0 < (pc G : ℝ) := pc_pos G hloc hqt + let D : ℝ := (pc G : ℝ) * (1-pc G) / 2 + have hD : 0 < D := by dsimp [D]; positivity + let L : ℝ := 2 + 2 * (d : ℝ) / D + have hL : 0 < L := by dsimp [L]; positivity + let η : ℝ := min (1/4) ((1-pc G)/2) + have hη : 0 < η := lt_min (by norm_num) (by positivity) + refine ⟨12 * L * C,η,by positivity,hη,fun p hp hnear x => ?_⟩ + let δ : ℝ := (p : ℝ) - pc G + have hδ : 0 < δ := sub_pos.mpr hp + have hδsmall : δ < 1/4 := hnear.trans_le (min_le_left _ _) + have hδnear : δ < (1-pc G)/2 := hnear.trans_le (min_le_right _ _) + have hp1 : (p : ℝ) < 1 := by dsimp [δ] at hδnear; linarith + have hp0 : 0 < (p : ℝ) := hpc0.trans hp + have hden : D ≤ (p : ℝ) * (1-p) := by + have ht : (1-(pc G : ℝ))/2 ≤ 1-(p : ℝ) := by dsimp [δ] at hδnear; linarith + have hm := mul_le_mul (show (pc G : ℝ) ≤ p from hp.le) ht + (by positivity : 0 ≤ (1-(pc G : ℝ))/2) hp0.le + dsimp [D] + nlinarith + let h : unitInterval := ⟨δ ^ 2,⟨sq_nonneg _,by nlinarith⟩⟩ + have hh : (h : ℝ) ∈ Set.Ioo 0 1 := ⟨sq_pos_of_pos hδ,by dsimp [h]; nlinarith⟩ + let m : ℕ := ⌊1/δ⌋₊ + have hm1 : 1 ≤ m := (Nat.le_floor_iff (one_div_pos.mpr hδ).le).mpr + ((le_div_iff₀ hδ).mpr (by norm_num only [Nat.cast_one,one_mul]; linarith)) + have hm : 0 < m := hm1 + have hmR : 0 < (m : ℝ) := by exact_mod_cast hm + have hfloor : (m : ℝ) ≤ 1/δ := Nat.floor_le (one_div_pos.mpr hδ).le + have hδm : δ * m ≤ 1 := by + have hh := (le_div_iff₀ hδ).mp hfloor + nlinarith + have hscale : (h : ℝ) * (m : ℝ) ^ 2 ≤ 1 := by + dsimp [h] + have hh := (sq_le_sq₀ (mul_nonneg hδ.le hmR.le) zero_le_one).mpr hδm + nlinarith + have hfloor' : 1/δ < (m : ℝ) + 1 := Nat.lt_floor_add_one (1/δ) + have hinv : 1 / (m : ℝ) ≤ 2 * δ := by + have hmR1 : (1 : ℝ) ≤ m := by exact_mod_cast hm1 + have hh := (div_lt_iff₀ hδ).mp hfloor' + apply (div_le_iff₀ hmR).mpr + nlinarith + have hghost (Q : Finset E) : markedConnectionPolynomial G Q x h p ≤ 6 * L * C * δ := by + have hc := critical_ghost_bound_at_square_scale G C hC.le hvolume Q x (pc G) h + le_rfl m hm hscale + have ht := markedConnection_entropy_uniform G Q x (pc G) p h ⟨hpc0,hpc1⟩ ⟨hp0,hp1⟩ + hh d (fun z => (incident_filter_card_le_degree G hloc Q z).trans (hdeg z)) + D hD hden (by dsimp [h,δ]; nlinarith) + change _ ≤ L * markedConnectionPolynomial G Q x h (pc G) at ht + have hb := ht.trans (mul_le_mul_of_nonneg_left hc hL.le) + have hi := mul_le_mul_of_nonneg_left hinv (show 0 ≤ 3 * L * C by positivity) + have he : L * (3 * C / (m : ℝ)) = (3 * L * C) * (1/m) := by ring + rw [he] at hb + nlinarith + have hθ := percolationProbability_le_of_marked_bounds G x p h hh.1 (6 * L * C * δ) hghost + dsimp [δ] at hθ + nlinarith + +theorem percolationProbability_upper_of_critical_volume [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hpc1 : (pc G : ℝ) < 1) + (hvol : ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + ∃ A η : ℝ, 0 < A ∧ 0 < η ∧ ∀ p : unitInterval, pc G < p → + (p : ℝ) - pc G < η → ∀ x, + percolationProbability G p x ≤ A * ((p : ℝ) - pc G) := by + obtain ⟨C,hC,hvolume⟩ := uniform_critical_volume_upper_of_powerTail G hqt hvol + exact percolationProbability_upper_of_uniform_critical_volume G hloc hqt hpc1 C hC hvolume + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ProbeEntropy.lean b/lean/OAI/Probability/BenjaminiSchramm/ProbeEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b71f2e1e9674025a90fe99bf6aaa8dcf61c954e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ProbeEntropy.lean @@ -0,0 +1,156 @@ +import OAI.Probability.BenjaminiSchramm.EntropyEvent +import OAI.Probability.UnimodularPercolation.Exploration.Marked + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +open CriticalPercolation.FiniteEntropy + +namespace ProbeEntropy + +open ProbeTree + +theorem weight_pos (p h : ℝ) (hp : p ∈ Set.Ioo 0 1) (hh : h ∈ Set.Ioo 0 1) + (t : ProbeTree) (l : t.Leaf) : 0 < weight p h t l := by + induction t with + | done b => exact zero_lt_one + | edge t₀ t₁ ih₀ ih₁ => + cases l with + | inl l => exact mul_pos (sub_pos.mpr hp.2) (ih₀ l) + | inr l => exact mul_pos hp.1 (ih₁ l) + | mark t₀ t₁ ih₀ ih₁ => + cases l with + | inl l => exact mul_pos (sub_pos.mpr hh.2) (ih₀ l) + | inr l => exact mul_pos hh.1 (ih₁ l) + +noncomputable def totalQueries (p h : ℝ) (t : ProbeTree) : ℝ := + ∑ l, weight p h t l * (queries t l : ℝ) + +noncomputable def totalMarks (p h : ℝ) (t : ProbeTree) : ℝ := + ∑ l, weight p h t l * (marks t l : ℝ) + +noncomputable def treeDivergence (p q h : ℝ) (t : ProbeTree) : ℝ := + divergence (weight p h t) (weight q h t) + +@[simp] theorem totalQueries_done (p h : ℝ) (b : Bool) : totalQueries p h (.done b) = 0 := by + simp [totalQueries,queries] + +@[simp] theorem totalMarks_done (p h : ℝ) (b : Bool) : totalMarks p h (.done b) = 0 := by + simp [totalMarks,marks] + +theorem totalQueries_edge (p h : ℝ) (t₀ t₁ : ProbeTree) : + totalQueries p h (.edge t₀ t₁) = + 1 + (1-p) * totalQueries p h t₀ + p * totalQueries p h t₁ := by + simp only [totalQueries,Fintype.sum_sum_type,weight,queries,Nat.cast_add,Nat.cast_one] + simp_rw [mul_add,mul_one,mul_assoc] + simp only [Finset.sum_add_distrib,←Finset.mul_sum,sum_weight,mul_one] + ring + +theorem totalQueries_mark (p h : ℝ) (t₀ t₁ : ProbeTree) : + totalQueries p h (.mark t₀ t₁) = + (1-h) * totalQueries p h t₀ + h * totalQueries p h t₁ := by + simp only [totalQueries,Fintype.sum_sum_type,weight,queries,mul_assoc,←Finset.mul_sum] + +theorem totalMarks_edge (p h : ℝ) (t₀ t₁ : ProbeTree) : + totalMarks p h (.edge t₀ t₁) = + (1-p) * totalMarks p h t₀ + p * totalMarks p h t₁ := by + simp only [totalMarks,Fintype.sum_sum_type,weight,marks,mul_assoc,←Finset.mul_sum] + +theorem totalMarks_mark (p h : ℝ) (t₀ t₁ : ProbeTree) : + totalMarks p h (.mark t₀ t₁) = + 1 + (1-h) * totalMarks p h t₀ + h * totalMarks p h t₁ := by + simp only [totalMarks,Fintype.sum_sum_type,weight,marks,Nat.cast_add,Nat.cast_one] + simp_rw [mul_add,mul_one,mul_assoc] + simp only [Finset.sum_add_distrib,←Finset.mul_sum,sum_weight,mul_one] + ring + +theorem treeDivergence_edge (p q h : ℝ) (hp : p ∈ Set.Ioo 0 1) + (hq : q ∈ Set.Ioo 0 1) (hh : h ∈ Set.Ioo 0 1) (t₀ t₁ : ProbeTree) : + treeDivergence p q h (.edge t₀ t₁) = binaryDivergence p q + + (1-p) * treeDivergence p q h t₀ + p * treeDivergence p q h t₁ := by + have he : treeDivergence p q h (.edge t₀ t₁) = + divergence (fun l => (1-p) * weight p h t₀ l) (fun l => (1-q) * weight q h t₀ l) + + divergence (fun l => p * weight p h t₁ l) (fun l => q * weight q h t₁ l) := by + simp only [treeDivergence,divergence,Fintype.sum_sum_type,weight] + rw [he,divergence_mul _ _ (weight_pos p h hp hh t₀) (weight_pos q h hq hh t₀) + (sum_weight p h t₀) _ _ (sub_pos.mpr hp.2) (sub_pos.mpr hq.2), + divergence_mul _ _ (weight_pos p h hp hh t₁) (weight_pos q h hq hh t₁) + (sum_weight p h t₁) _ _ hp.1 hq.1] + dsimp [treeDivergence,binaryDivergence] + ring + +theorem treeDivergence_mark (p q h : ℝ) (hp : p ∈ Set.Ioo 0 1) + (hq : q ∈ Set.Ioo 0 1) (hh : h ∈ Set.Ioo 0 1) (t₀ t₁ : ProbeTree) : + treeDivergence p q h (.mark t₀ t₁) = + (1-h) * treeDivergence p q h t₀ + h * treeDivergence p q h t₁ := by + have he : treeDivergence p q h (.mark t₀ t₁) = + divergence (fun l => (1-h) * weight p h t₀ l) (fun l => (1-h) * weight q h t₀ l) + + divergence (fun l => h * weight p h t₁ l) (fun l => h * weight q h t₁ l) := by + simp only [treeDivergence,divergence,Fintype.sum_sum_type,weight] + rw [he,divergence_mul _ _ (weight_pos p h hp hh t₀) (weight_pos q h hq hh t₀) + (sum_weight p h t₀) _ _ (sub_pos.mpr hh.2) (sub_pos.mpr hh.2), + divergence_mul _ _ (weight_pos p h hp hh t₁) (weight_pos q h hq hh t₁) + (sum_weight p h t₁) _ _ hh.1 hh.1] + simp only [div_self (sub_pos.mpr hh.2).ne',div_self hh.1.ne',Real.log_one,mul_zero,add_zero, + treeDivergence] + +theorem treeDivergence_eq (p q h : ℝ) (hp : p ∈ Set.Ioo 0 1) + (hq : q ∈ Set.Ioo 0 1) (hh : h ∈ Set.Ioo 0 1) (t : ProbeTree) : + treeDivergence p q h t = binaryDivergence p q * totalQueries p h t := by + induction t with + | done b => simp [treeDivergence,divergence,weight] + | edge t₀ t₁ ih₀ ih₁ => + rw [treeDivergence_edge p q h hp hq hh,totalQueries_edge,ih₀,ih₁] + ring + | mark t₀ t₁ ih₀ ih₁ => + rw [treeDivergence_mark p q h hp hq hh,totalQueries_mark,ih₀,ih₁] + ring + +theorem successMass_transfer (p q h : ℝ) (hp : p ∈ Set.Ioo 0 1) + (hq : q ∈ Set.Ioo 0 1) (hh : h ∈ Set.Ioo 0 1) (t : ProbeTree) : + successMass q h t ≤ 2 * successMass p h t + + 2 * binaryDivergence p q * totalQueries p h t := by + have hb := event_mass_le_two_add_divergence (weight p h t) (weight q h t) + (outcome t) (fun l => (weight_pos p h hp hh t l).le) + (fun l => (weight_pos q h hq hh t l).le) (sum_weight p h t) (sum_weight q h t) + (fun l _ => weight_pos q h hq hh t l) + change successMass q h t ≤ 2 * successMass p h t + 2 * treeDivergence p q h t at hb + rw [treeDivergence_eq p q h hp hq hh] at hb + simpa only [mul_assoc] using hb + +theorem totalMarks_eq_successMass (p h : ℝ) {t : ProbeTree} (ht : IsMarkSearch t) : + h * totalMarks p h t = successMass p h t := by + induction ht with + | fail => simp + | @edge t₀ t₁ _ _ ih₀ ih₁ => + rw [totalMarks_edge,successMass_edge] + rw [←ih₀,←ih₁] + ring + | @mark t₀ _ ih => + rw [totalMarks_mark,successMass_mark] + simp only [totalMarks_done,successMass_done,ite_true,mul_zero,add_zero,mul_one] + rw [←ih] + ring + +theorem totalQueries_le (p h : unitInterval) {t : ProbeTree} (ht : IsMarkSearch t) + (d : ℕ) (hcost : ∀ l, queries t l ≤ d * marks t l) (hh : 0 < (h : ℝ)) : + totalQueries p h t ≤ (d : ℝ) * successMass p h t / h := by + apply (le_div_iff₀ hh).mpr + have hb : totalQueries p h t ≤ (d : ℝ) * totalMarks p h t := by + simp only [totalQueries,totalMarks,Finset.mul_sum] + apply Finset.sum_le_sum + intro l _ + have hh := mul_le_mul_of_nonneg_left + (show (queries t l : ℝ) ≤ (d : ℝ) * marks t l by exact_mod_cast hcost l) + (weight_nonneg p h t l) + nlinarith + have hm := mul_le_mul_of_nonneg_right hb hh.le + rw [mul_assoc,mul_comm (totalMarks p h t) (h : ℝ), + totalMarks_eq_successMass p h ht] at hm + exact hm + +end ProbeEntropy +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/PublishedConsequences.lean b/lean/OAI/Probability/BenjaminiSchramm/PublishedConsequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..223667a0875680351dd8cc0ceb269ad199aef7f8 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/PublishedConsequences.lean @@ -0,0 +1,277 @@ +import OAI.Probability.UnimodularPercolation.Kernel.TraceBounds + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation +namespace BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq + +structure PublishedSimpleGraph (G : BondGraph V E) : Prop where + injective : Function.Injective G + loopless : ∀ e x, G e ≠ s(x, x) + connected : Connected G + locallyFinite : LocallyFinite G + quasiTransitive : QuasiTransitive G + +noncomputable def triangleDiagram (G : BondGraph V E) (p : unitInterval) (x : V) : ℝ≥0∞ := + ∑' ab : V × V, ENNReal.ofReal + (twoPoint G p x ab.1 * twoPoint G p ab.1 ab.2 * twoPoint G p ab.2 x) + +noncomputable def graphDistance (G : BondGraph V E) (x y : V) : ℕ := + (openSimpleGraph G Set.univ).dist x y + +def ExponentialDecay (G : BondGraph V E) (p : unitInterval) : Prop := + ∃ A a : ℝ, 0 < A ∧ 0 < a ∧ ∀ x y, + twoPoint G p x y ≤ A * Real.exp (-a * graphDistance G x y) + +noncomputable def pexp (G : BondGraph V E) : unitInterval := + sSup {p | ExponentialDecay G p} + +def PowerTail (f : ℕ → ℝ) (exponent : ℝ) : Prop := + ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∀ n : ℕ, 0 < n → + c * (n : ℝ) ^ (-exponent) ≤ f n ∧ f n ≤ C * (n : ℝ) ^ (-exponent) + +def volumeEvent (G : BondGraph V E) (x : V) (n : ℕ) : Set (Set E) := + {ω | (n : ℕ∞) ≤ (cluster G ω x).encard} + +def intrinsicRadiusEvent (G : BondGraph V E) (x : V) (n : ℕ) : Set (Set E) := + {ω | ∃ y ∈ cluster G ω x, n ≤ (openSimpleGraph G ω).dist x y} + +def extrinsicRadiusEvent (G : BondGraph V E) (x : V) (n : ℕ) : Set (Set E) := + {ω | ∃ y ∈ cluster G ω x, n ≤ graphDistance G x y} + +noncomputable def criticalTail (G : BondGraph V E) + (A : V → ℕ → Set (Set E)) (x : V) (n : ℕ) : ℝ := + (law (pc G) (A x n)).toReal + +def CriticalTailLaws (G : BondGraph V E) : Prop := + ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2) ∧ + PowerTail (criticalTail G (intrinsicRadiusEvent G) x) 1 ∧ + PowerTail (criticalTail G (extrinsicRadiusEvent G) x) 1 + +def SusceptibilityLaw (G : BondGraph V E) : Prop := + ∀ x, ∃ c C δ : ℝ, 0 < c ∧ 0 < C ∧ 0 < δ ∧ + ∀ p : unitInterval, p < pc G → (pc G : ℝ) - p < δ → + c / ((pc G : ℝ) - p) ≤ susceptibility G p x ∧ + susceptibility G p x ≤ C / ((pc G : ℝ) - p) + +noncomputable def percolationProbability (G : BondGraph V E) (p : unitInterval) + (x : V) : ℝ := (law p {ω | (cluster G ω x).Infinite}).toReal + +def PercolationProbabilityLaw (G : BondGraph V E) : Prop := + ∀ x, ∃ c C δ : ℝ, 0 < c ∧ 0 < C ∧ 0 < δ ∧ + ∀ p : unitInterval, pc G < p → (p : ℝ) - pc G < δ → + c * ((p : ℝ) - pc G) ≤ percolationProbability G p x ∧ + percolationProbability G p x ≤ C * ((p : ℝ) - pc G) + +theorem triangle_hasSum + (G : BondGraph V E) (p : unitInterval) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) (x : V) : + HasSum (fun ab : V × V => + twoPoint G p x ab.1 * twoPoint G p ab.1 ab.2 * twoPoint G p ab.2 x) + (matrixCoeff (T ^ 3) x x).re := by + have ht := hT.positiveRealMatrix G p T + have hs := ht.triple_hasSum ht ht x x + rw [show T * T * T = T ^ 3 by simp only [pow_succ, pow_zero, one_mul]] at hs + simpa only [HasKernel.matrixCoeff_re G p T hT] using hs + +theorem triangleDiagram_eq_matrix + (G : BondGraph V E) (p : unitInterval) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) (x : V) : + triangleDiagram G p x = ENNReal.ofReal (matrixCoeff (T ^ 3) x x).re := by + have hs := triangle_hasSum G p T hT x + unfold triangleDiagram + have hn (ab : V × V) : + 0 ≤ twoPoint G p x ab.1 * twoPoint G p ab.1 ab.2 * twoPoint G p ab.2 x := + mul_nonneg (mul_nonneg (twoPoint_nonneg G p x ab.1) + (twoPoint_nonneg G p ab.1 ab.2)) (twoPoint_nonneg G p ab.2 x) + exact (ENNReal.ofReal_tsum_of_nonneg hn hs.summable).symm.trans + (congrArg ENNReal.ofReal hs.tsum_eq) + +theorem triangleDiagram_le_norm_cube + (G : BondGraph V E) (p : unitInterval) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) (x : V) : + triangleDiagram G p x ≤ ENNReal.ofReal (‖T‖ ^ 3) := by + rw [triangleDiagram_eq_matrix G p T hT x] + apply ENNReal.ofReal_le_ofReal + apply (Complex.re_le_norm _).trans + have hc : ‖matrixCoeff (T ^ 3) x x‖ ≤ ‖T ^ 3‖ := by + change ‖(T ^ 3) (lp.single 2 x (1 : ℂ)) x‖ ≤ ‖T ^ 3‖ + apply (lp.norm_apply_le_norm (by norm_num : (2 : ENNReal) ≠ 0) + ((T ^ 3) (lp.single 2 x (1 : ℂ))) x).trans + simpa only [lp.norm_single (by norm_num : 0 < (2 : ENNReal)), norm_one, mul_one] using + (T ^ 3).le_opNorm (lp.single 2 x (1 : ℂ)) + exact hc.trans (norm_pow_le' T (by norm_num : 0 < (3 : ℕ))) + +theorem triangleDiagram_le_operatorNorm_cube + (G : BondGraph V E) (p : unitInterval) (h : OperatorBounded G p) (x : V) : + triangleDiagram G p x ≤ operatorNorm G p ^ 3 := by + classical + obtain ⟨T, hT⟩ := h + rw [operatorNorm_of_hasKernel hT, ← ENNReal.ofReal_pow (norm_nonneg T)] + exact triangleDiagram_le_norm_cube G p T hT x + +theorem triangleDiagram_lt_top_of_bounded + (G : BondGraph V E) (p : unitInterval) (h : OperatorBounded G p) (x : V) : + triangleDiagram G p x < ⊤ := by + classical + obtain ⟨T, hT⟩ := h + exact (triangleDiagram_le_norm_cube G p T hT x).trans_lt ENNReal.ofReal_lt_top + +theorem critical_triangle_of_mainConclusion + (G : BondGraph V E) (h : MainConclusion G) (x : V) : + triangleDiagram G (pc G) x ≤ operatorNorm G (pc G) ^ 3 ∧ + triangleDiagram G (pc G) x < ⊤ := by + have hb := (operatorNorm_lt_top_iff G (pc G)).mp h.2.1 + exact ⟨triangleDiagram_le_operatorNorm_cube G (pc G) hb x, + triangleDiagram_lt_top_of_bounded G (pc G) hb x⟩ + +def HutchcroftExponentialInput (G : BondGraph V E) : Prop := + PublishedSimpleGraph G → ∀ p : unitInterval, 0 < p → p < ptwo G → + ∀ T : Hilbert V →L[ℂ] Hilbert V, HasKernel G p T → ∀ x y, + twoPoint G p x y ≤ 2 * ‖T‖ * + Real.exp (-(graphDistance G x y : ℝ) / (Real.exp 1 * ‖T‖)) + +theorem exponentialDecay_zero [Countable E] (G : BondGraph V E) : + ExponentialDecay G 0 := by + classical + refine ⟨1, 1, by norm_num, by norm_num, ?_⟩ + intro x y + by_cases hxy : x = y + · subst y + simp [graphDistance] + · rw [twoPoint_zero, ite_eq_right hxy] + positivity + +theorem exponentialDecay_of_publishedInput [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hpub : HutchcroftExponentialInput G) + (p : unitInterval) (hp : p < ptwo G) : ExponentialDecay G p := by + classical + by_cases hp0 : p = 0 + · simpa only [hp0] using exponentialDecay_zero G + have hp_pos : 0 < p := lt_of_le_of_ne bot_le (Ne.symm hp0) + obtain ⟨q, hq, hpq⟩ := lt_sSup_iff.mp hp + obtain ⟨T, hT⟩ := operatorBounded_of_le G hpq.le hq + have hnorm : 0 < ‖T‖ := by + let x : V := Classical.arbitrary V + have hcol := lp.norm_apply_le_norm (by norm_num : (2 : ENNReal) ≠ 0) + (T (lp.single 2 x (1 : ℂ))) x + rw [hT x x, twoPoint_self, Complex.ofReal_one, norm_one] at hcol + have hop := T.le_opNorm (lp.single 2 x (1 : ℂ)) + norm_num [lp.norm_single] at hop + exact zero_lt_one.trans_le (hcol.trans hop) + refine ⟨2 * ‖T‖, (Real.exp 1 * ‖T‖)⁻¹, by positivity, by positivity, ?_⟩ + intro x y + convert hpub hgraph p hp_pos hp T hT x y using 1 + congr 2 + simp only [div_eq_mul_inv, neg_mul, mul_neg, mul_comm] + +theorem ptwo_le_pexp_of_publishedInput [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hpub : HutchcroftExponentialInput G) : ptwo G ≤ pexp G := by + apply le_of_forall_lt_imp_le_of_dense + intro p hp + exact le_sSup (exponentialDecay_of_publishedInput G hgraph hpub p hp) + +theorem exponential_threshold_of_mainConclusion [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hpub : HutchcroftExponentialInput G) (hmain : MainConclusion G) : + pc G < ptwo G ∧ ptwo G ≤ pexp G := + ⟨hmain.2.2.1, ptwo_le_pexp_of_publishedInput G hgraph hpub⟩ + +theorem law_restrict_finite_cluster (G : BondGraph V E) (p : unitInterval) (x : V) + (hfin : ∀ᵐ ω ∂law p, (cluster G ω x).Finite) (A : Set (Set E)) : + law p {ω | ω ∈ A ∧ (cluster G ω x).Finite} = law p A := by + apply measure_congr + filter_upwards [hfin] with ω hω + exact propext (and_iff_left hω) + +noncomputable def criticalFiniteTail (G : BondGraph V E) + (A : V → ℕ → Set (Set E)) (x : V) (n : ℕ) : ℝ := + (law (pc G) {ω | ω ∈ A x n ∧ (cluster G ω x).Finite}).toReal + +theorem criticalFiniteTail_eq (G : BondGraph V E) + (A : V → ℕ → Set (Set E)) (x : V) + (hfin : ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite) : + criticalFiniteTail G A x = criticalTail G A x := by + funext n + unfold criticalFiniteTail criticalTail + rw [law_restrict_finite_cluster G (pc G) x hfin (A x n)] + +def HutchcroftCriticalVolumeInput (G : BondGraph V E) : Prop := + PublishedSimpleGraph G → pc G < ptwo G → ∀ x, + PowerTail (criticalFiniteTail G (volumeEvent G) x) (1 / 2) + +def HutchcroftCriticalRadiiInput (G : BondGraph V E) : Prop := + PublishedSimpleGraph G → pc G < ptwo G → ∀ x, + PowerTail (criticalFiniteTail G (intrinsicRadiusEvent G) x) 1 ∧ + PowerTail (criticalFiniteTail G (extrinsicRadiusEvent G) x) 1 + +theorem criticalTailLaws_of_publishedInputs (G : BondGraph V E) + (hgraph : PublishedSimpleGraph G) + (hvolume : HutchcroftCriticalVolumeInput G) + (hradii : HutchcroftCriticalRadiiInput G) + (hgap : pc G < ptwo G) + (hfin : ∀ x, ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite) : + CriticalTailLaws G := by + intro x + obtain ⟨hi, he⟩ := hradii hgraph hgap x + have hv := hvolume hgraph hgap x + rw [criticalFiniteTail_eq G (volumeEvent G) x (hfin x)] at hv + rw [criticalFiniteTail_eq G (intrinsicRadiusEvent G) x (hfin x)] at hi + rw [criticalFiniteTail_eq G (extrinsicRadiusEvent G) x (hfin x)] at he + exact ⟨hv, hi, he⟩ + +def HutchcroftFirstMomentInput (G : BondGraph V E) : Prop := + PublishedSimpleGraph G → pc G < ptwo G → ∀ x, + ∃ c C δ : ℝ, 0 < c ∧ 0 < C ∧ 0 < δ ∧ + ∀ p : unitInterval, p < pc G → (pc G : ℝ) - p < δ → + c / ((pc G : ℝ) - p) ≤ ∫ ω, ((cluster G ω x).ncard : ℝ) ∂law p ∧ + (∫ ω, ((cluster G ω x).ncard : ℝ) ∂law p) ≤ C / ((pc G : ℝ) - p) + +theorem susceptibilityLaw_of_publishedInput [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hpub : HutchcroftFirstMomentInput G) (hgap : pc G < ptwo G) : + SusceptibilityLaw G := by + intro x + obtain ⟨c, C, δ, hc, hC, hδ, hb⟩ := hpub hgraph hgap x + refine ⟨c, C, δ, hc, hC, hδ, ?_⟩ + intro p hp hnear + rw [(susceptibility_eq_integral G hgraph.locallyFinite hgraph.quasiTransitive p hp x).2] + exact hb p hp hnear + +def TrianglePercolationProbabilityInput (G : BondGraph V E) : Prop := + PublishedSimpleGraph G → (∀ x, triangleDiagram G (pc G) x < ⊤) → + PercolationProbabilityLaw G + +theorem percolationProbabilityLaw_of_publishedInput + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hpub : TrianglePercolationProbabilityInput G) + (hbounded : OperatorBounded G (pc G)) : PercolationProbabilityLaw G := + hpub hgraph (triangleDiagram_lt_top_of_bounded G (pc G) hbounded) + +theorem meanFieldLaws_of_publishedInputs [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hgraph : PublishedSimpleGraph G) + (hfirst : HutchcroftFirstMomentInput G) + (htheta : TrianglePercolationProbabilityInput G) + (hvolume : HutchcroftCriticalVolumeInput G) + (hradii : HutchcroftCriticalRadiiInput G) + (hmain : MainConclusion G) + (hfin : ∀ x, ∀ᵐ ω ∂law (pc G), (cluster G ω x).Finite) : + SusceptibilityLaw G ∧ PercolationProbabilityLaw G ∧ CriticalTailLaws G := by + have hb := (operatorNorm_lt_top_iff G (pc G)).mp hmain.2.1 + exact ⟨susceptibilityLaw_of_publishedInput G hgraph hfirst hmain.2.2.1, + percolationProbabilityLaw_of_publishedInput G hgraph htheta hb, + criticalTailLaws_of_publishedInputs G hgraph hvolume hradii hmain.2.2.1 hfin⟩ + +end BenjaminiSchramm +end Percolation + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/RadiusInputReduction.lean b/lean/OAI/Probability/BenjaminiSchramm/RadiusInputReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..913618903e8b22ce83629e99a9283ed593ed0046 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/RadiusInputReduction.lean @@ -0,0 +1,24 @@ +import OAI.Probability.BenjaminiSchramm.OperatorMeanFieldReduction +import OAI.Probability.BenjaminiSchramm.RadiusTransfer + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem full_application_gap [Infinite V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) + (hutchcroft2019 : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hconn) (subdivision_locallyFinite G hloc) → + pc (subdivision G) < ptwo (subdivision G)) : + MainConclusion G ∧ CriticalLawsConclusion G := by + exact full_application_radii G hconn hloc hqt hh hutchcroft2019 + (criticalRadiiInput_of_nonamenable (subdivision G) (subdivision_hV_pos G hloc hqt hh)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/RadiusTransfer.lean b/lean/OAI/Probability/BenjaminiSchramm/RadiusTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..99097fab6edf3aea978dbc4286c20ab69d919ea7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/RadiusTransfer.lean @@ -0,0 +1,185 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicBallisticity +import OAI.Probability.BenjaminiSchramm.IntrinsicRadiusUpper +import OAI.Probability.BenjaminiSchramm.IntrinsicRadiusLower + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem extrinsicRadiusEvent_subset_intrinsic (G : BondGraph V E) (x : V) (n : ℕ) : + extrinsicRadiusEvent G x n ⊆ intrinsicRadiusEvent G x n := by + rintro ω ⟨y,hc,hd⟩ + refine ⟨y,hc,hd.trans ?_⟩ + have hle : openSimpleGraph G ω ≤ openSimpleGraph G Set.univ := by + rintro a b ⟨hne,e,he,hab⟩ + exact ⟨hne,e,Set.mem_univ _,hab⟩ + exact SimpleGraph.Reachable.dist_anti hle ((conn_iff_reachable G ω x y).mp hc) + +theorem intrinsicRadiusEvent_subset_extrinsic_union (G : BondGraph V E) + (hconn : Connected G) (hloc : LocallyFinite G) (x : V) (m n : ℕ) : + intrinsicRadiusEvent G x m ⊆ extrinsicRadiusEvent G x n ∪ + ⋃ y ∈ (finite_reachBall hloc x n).toFinset, longConnectionEvent G x y m := by + rintro ω ⟨y,hc,hd⟩ + by_cases he : ω ∈ extrinsicRadiusEvent G x n + · exact Or.inl he + · right + have hdist : graphDistance G x y ≤ n := by + by_contra h + exact he ⟨y,hc,(Nat.le_of_lt (Nat.lt_of_not_ge h))⟩ + exact Set.mem_iUnion.mpr ⟨y,Set.mem_iUnion.mpr + ⟨(finite_reachBall hloc x n).mem_toFinset.mpr + (mem_reachBall_of_graphDistance_le G hconn x y n hdist),hc,hd⟩⟩ + +theorem intrinsic_radius_le_extrinsic_add [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (p : unitInterval) (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (d : ℕ) (hd : ∀ x, degree G x ≤ d) (x : V) (m n : ℕ) : + (law p).real (intrinsicRadiusEvent G x m) ≤ + (law p).real (extrinsicRadiusEvent G x n) + + ((d+1 : ℕ) : ℝ)^n * (2 * ‖T‖ * Real.exp (-(Real.log 2/(3*‖T‖))*m)) := by + let B := (finite_reachBall hloc x n).toFinset + let R := 2 * ‖T‖ * Real.exp (-(Real.log 2/(3*‖T‖))*m) + have hcard : (B.card : ℝ) ≤ ((d+1 : ℕ) : ℝ)^n := by + have hh := reachBall_ncard_le_pow G hloc d hd x n + rw [Set.ncard_eq_toFinset_card _ (finite_reachBall hloc x n)] at hh + exact_mod_cast hh + calc + _ ≤ (law p).real (extrinsicRadiusEvent G x n ∪ ⋃ y ∈ B, longConnectionEvent G x y m) := + ENNReal.toReal_mono (measure_ne_top _ _) + (measure_mono (intrinsicRadiusEvent_subset_extrinsic_union G hconn hloc x m n)) + _ ≤ (law p).real (extrinsicRadiusEvent G x n) + + (law p).real (⋃ y ∈ B, longConnectionEvent G x y m) := measureReal_union_le _ _ + _ ≤ (law p).real (extrinsicRadiusEvent G x n) + ∑ y ∈ B, (law p).real (longConnectionEvent G x y m) := + add_le_add le_rfl (measureReal_biUnion_finset_le B _) + _ ≤ (law p).real (extrinsicRadiusEvent G x n) + ∑ _y ∈ B, R := by + apply add_le_add le_rfl + exact Finset.sum_le_sum (fun y _ => longConnection_exponential_bound G hloc p T hT x y m) + _ = (law p).real (extrinsicRadiusEvent G x n) + B.card * R := by + simp only [Finset.sum_const,nsmul_eq_mul] + _ ≤ _ := add_le_add le_rfl (mul_le_mul_of_nonneg_right hcard (by positivity)) + +theorem exponential_quadratic_bound {t : ℝ} (ht : 0 < t) : + Real.exp (-t) ≤ 2/t^2 := by + have hh := Real.pow_div_factorial_le_exp t ht.le 2 + norm_num only [Nat.factorial_succ,Nat.factorial_zero,Nat.cast_mul,Nat.cast_one] at hh + rw [Real.exp_neg,inv_eq_one_div] + apply (div_le_div_iff₀ (Real.exp_pos t) (sq_pos_of_pos ht)).mpr + nlinarith + +theorem radius_transfer_error {a B c D : ℝ} (ha : 0 < a) (hB : 0 < B) + (hc : 0 < c) (hD : 0 < D) : + ∃ K : ℕ, 0 < K ∧ ∀ n : ℕ, 0 < n → + D^n * (B*Real.exp (-a*(K*n : ℕ))) ≤ (c/(2*K))/n := by + obtain ⟨K,hK⟩ := exists_nat_gt (max (2*Real.log D/a) (16*B/(a^2*c))) + have hKn : 0 < K := by + have hh := (le_max_right (2*Real.log D/a) (16*B/(a^2*c))).trans_lt hK + have : (0 : ℝ) < K := lt_trans (by positivity) hh + exact_mod_cast this + have hKr : (0 : ℝ) < K := by exact_mod_cast hKn + have hlog : 2*Real.log D ≤ a*K := by + have hh := (le_max_left (2*Real.log D/a) (16*B/(a^2*c))).trans_lt hK + exact (div_le_iff₀ ha).mp hh.le |>.trans_eq (mul_comm _ _) + have hsize : 16*B ≤ a^2*c*K := by + have hh := (le_max_right (2*Real.log D/a) (16*B/(a^2*c))).trans_lt hK + have h := (div_le_iff₀ (by positivity : 0 < a^2*c)).mp hh.le + nlinarith + refine ⟨K,hKn,?_⟩ + intro n hn + have hnr : (0 : ℝ) < n := by exact_mod_cast hn + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn + have ht : 0 < a*K*n/2 := by positivity + have hdecay : D^n * (B*Real.exp (-a*(K*n : ℕ))) ≤ B*Real.exp (-(a*K*n/2)) := by + have hexp : Real.log D*n - a*K*n ≤ -(a*K*n/2) := by nlinarith + calc + _ = B*Real.exp (Real.log D*n-a*K*n) := by + rw [Real.exp_sub,neg_mul,Real.exp_neg,mul_comm (Real.log D) (n : ℝ),Real.exp_nat_mul,Real.exp_log hD] + push_cast + rw [mul_assoc a (K : ℝ) (n : ℝ)] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexp) hB.le + have hpoly := mul_le_mul_of_nonneg_left (exponential_quadratic_bound ht) hB.le + have hrat : B*(2/(a*K*n/2)^2) ≤ (c/(2*K))/n := by + have hid : B*(2/(a*K*n/2)^2) = 8*B/(a^2*(K:ℝ)^2*(n:ℝ)^2) := by + field_simp + ring + rw [hid,div_div] + apply (div_le_div_iff₀ (by positivity) (by positivity)).mpr + have hh := mul_le_mul_of_nonneg_right hsize (by positivity : (0 : ℝ) ≤ K*n) + have hnn := mul_le_mul_of_nonneg_left hn1 (by positivity : (0 : ℝ) ≤ a^2*c*K^2*n) + nlinarith + exact hdecay.trans (hpoly.trans hrat) + +theorem extrinsic_radius_lower_of_intrinsic [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (p : unitInterval) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G p T) + (x : V) (c : ℝ) (hc : 0 < c) + (hint : ∀ m : ℕ, 0 < m → c/m ≤ (law p).real (intrinsicRadiusEvent G x m)) : + ∃ b : ℝ, 0 < b ∧ ∀ n : ℕ, 0 < n → b/n ≤ (law p).real (extrinsicRadiusEvent G x n) := by + obtain ⟨d,_,hd⟩ := exists_degree_bound G hqt + let a := Real.log 2/(3*‖T‖) + have hnorm : 0 < ‖T‖ := lt_of_lt_of_le zero_lt_one (hT.norm_one_le G p T) + have ha : 0 < a := div_pos (Real.log_pos (by norm_num)) (by positivity) + obtain ⟨K,hK,herr⟩ := radius_transfer_error ha (by positivity : 0 < 2*‖T‖) hc + (by positivity : (0 : ℝ) < (d+1 : ℕ)) + refine ⟨c/(2*K),by positivity,?_⟩ + intro n hn + have hKn : 0 < K*n := Nat.mul_pos hK hn + have hlow := hint (K*n) hKn + have hbound := intrinsic_radius_le_extrinsic_add G hconn hloc p T hT d hd x (K*n) n + have herror := herr n hn + have hid : c/(K*n : ℕ) = (c/(2*K))/n + (c/(2*K))/n := by + push_cast + field_simp + ring + rw [hid] at hlow + linarith + +theorem critical_radius_powerTails_of_operator [Infinite V] [Countable V] [Countable E] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (hpc1 : (pc G : ℝ) < 1) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) (x : V) : + PowerTail (criticalTail G (intrinsicRadiusEvent G) x) 1 ∧ + PowerTail (criticalTail G (extrinsicRadiusEvent G) x) 1 := by + obtain ⟨c,hc,hlo⟩ := critical_intrinsic_radius_lower_of_operator G hconn hloc hqt hh hpc1 T hT x + obtain ⟨C,hC,hup⟩ := critical_intrinsic_radius_upper_of_operator G hconn hloc hqt hh hpc1 T hT + have hint (n : ℕ) (hn : 0 < n) : criticalTail G (intrinsicRadiusEvent G) x n ≤ C/n := by + change (law (pc G) (intrinsicRadiusEvent G x n)).toReal ≤ C/n + simpa only [domainRadiusEvent,Set.inter_univ,Set.ofPred_mem_eq] using hup Set.univ x n hn + obtain ⟨b,hb,hext⟩ := extrinsic_radius_lower_of_intrinsic G hconn hloc hqt (pc G) T hT x c hc hlo + have hupper (n : ℕ) (hn : 0 < n) : criticalTail G (extrinsicRadiusEvent G) x n ≤ C/n := by + apply le_trans _ (hint n hn) + exact ENNReal.toReal_mono (measure_ne_top _ _) + (measure_mono (extrinsicRadiusEvent_subset_intrinsic G x n)) + constructor + · refine ⟨c,C,hc,hC,fun n hn => ?_⟩ + simpa only [Real.rpow_neg_one,div_eq_mul_inv] using And.intro (hlo n hn) (hint n hn) + · refine ⟨b,C,hb,hC,fun n hn => ?_⟩ + have hlow : b/n ≤ criticalTail G (extrinsicRadiusEvent G) x n := hext n hn + simpa only [Real.rpow_neg_one,div_eq_mul_inv] using And.intro hlow (hupper n hn) + +theorem criticalRadiiInput_of_nonamenable [Infinite V] + (G : BondGraph V E) (hh : 0 < hV G) : HutchcroftCriticalRadiiInput G := by + intro hgraph hgap x + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + have hp1 : (pc G : ℝ) < 1 := + (show (pc G : ℝ) < (ptwo G : ℝ) from hgap).trans_le (ptwo G).2.2 + obtain ⟨q,hq,hpq⟩ := lt_sSup_iff.mp hgap + obtain ⟨T,hT⟩ := operatorBounded_of_le G hpq.le hq + have hfin := critical_finite_general G hgraph.connected hgraph.locallyFinite hgraph.quasiTransitive hp1 + rw [criticalFiniteTail_eq G (intrinsicRadiusEvent G) x (hfin x), + criticalFiniteTail_eq G (extrinsicRadiusEvent G) x (hfin x)] + exact critical_radius_powerTails_of_operator G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hh hp1 T hT x + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ReciprocalDecay.lean b/lean/OAI/Probability/BenjaminiSchramm/ReciprocalDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..a96d8493e87b090766b28f87eebd04aa1da05e3f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ReciprocalDecay.lean @@ -0,0 +1,52 @@ +import Mathlib + +namespace OAI + +open Set + +namespace Percolation.BenjaminiSchramm + +theorem reciprocal_upper_of_derivative_lower + (f : ℝ → ℝ) (a b k : ℝ) (hk : 0 < k) + (hpos : ∀ x ∈ Ioo a b, 0 < f x) + (hdiff : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x) + (hderiv : ∀ x ∈ Ioo a b, k * (f x)^2 ≤ deriv f x) + (x : ℝ) (hx : x ∈ Ioo a b) : f x ≤ 1 / (k * (b-x)) := by + have hinv : k * (b-x) ≤ 1 / f x := by + apply le_of_forall_pos_le_add + intro ε hε + let δ := min ((b-x)/2) (ε/(2*k)) + have hδ : 0 < δ := lt_min (div_pos (sub_pos.mpr hx.2) (by norm_num)) + (div_pos hε (by positivity)) + have hδx : δ ≤ (b-x)/2 := min_le_left _ _ + have hδε : δ ≤ ε/(2*k) := min_le_right _ _ + let y := b-δ + have hxy : x < y := by dsimp [y]; linarith + have hyb : y < b := by dsimp [y]; linarith + have hsub : Icc x y ⊆ Ioo a b := fun z hz => + ⟨hx.1.trans_le hz.1,hz.2.trans_lt hyb⟩ + have hg (z : ℝ) (hz : z ∈ Icc x y) : + HasDerivAt (fun t => -(1 / f t)) (deriv f z / (f z)^2) z := by + have hh := ((hdiff z (hsub hz)).hasDerivAt.inv (hpos z (hsub hz)).ne').neg + simpa only [one_div,Pi.inv_apply,Pi.neg_apply,neg_div,neg_neg] using! hh + have hbound (z : ℝ) (hz : z ∈ interior (Icc x y)) : + k ≤ deriv (fun t => -(1 / f t)) z := by + rw [(hg z (interior_subset hz)).deriv] + exact (le_div_iff₀ (sq_pos_of_pos (hpos z (hsub (interior_subset hz))))).mpr + (hderiv z (hsub (interior_subset hz))) + have hdist := (convex_Icc x y).mul_sub_le_image_sub_of_le_deriv + (fun z hz => (hg z hz).continuousAt.continuousWithinAt) + (fun z hz => (hg z (interior_subset hz)).differentiableAt.differentiableWithinAt) + hbound x ⟨le_rfl,hxy.le⟩ y ⟨hxy.le,le_rfl⟩ hxy.le + have hn : 0 ≤ 1 / f y := (div_pos zero_lt_one (hpos y (hsub ⟨hxy.le,le_rfl⟩))).le + have he : 2*k*δ ≤ ε := by + simpa only [mul_comm δ] using (le_div_iff₀ (by positivity : 0 < 2*k)).mp hδε + dsimp only [y] at hdist + nlinarith + apply (le_div_iff₀ (mul_pos hk (sub_pos.mpr hx.2))).mpr + have hh := (le_div_iff₀ (hpos x hx)).mp hinv + nlinarith + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ReciprocalGrowth.lean b/lean/OAI/Probability/BenjaminiSchramm/ReciprocalGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a14dd0e0f0c9bd2aa624dc3c2650232d5a491e2 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ReciprocalGrowth.lean @@ -0,0 +1,51 @@ +import Mathlib + +namespace OAI + +open Set + +namespace Percolation.BenjaminiSchramm + +theorem reciprocal_lower_of_derivative_upper + (f : ℝ → ℝ) (a b K : ℝ) (hK : 0 < K) + (hpos : ∀ x ∈ Ioo a b, 0 < f x) + (hdiff : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x) + (hderiv : ∀ x ∈ Ioo a b, deriv f x ≤ K * (f x) ^ 2) + (hunbounded : ∀ x ∈ Ioo a b, ∀ B : ℝ, + ∃ y, x ≤ y ∧ y < b ∧ B < f y) + (x : ℝ) (hx : x ∈ Ioo a b) : 1 / (K * (b - x)) ≤ f x := by + have hinverse : 1 / f x ≤ K * (b - x) := by + apply le_of_forall_pos_le_add + intro ε hε + obtain ⟨y,hxy,hyb,hfy⟩ := hunbounded x hx (1 / ε) + have hy : y ∈ Ioo a b := ⟨hx.1.trans_le hxy,hyb⟩ + have hsub : Icc x y ⊆ Ioo a b := fun z hz => + ⟨hx.1.trans_le hz.1,hz.2.trans_lt hyb⟩ + have hg (z : ℝ) (hz : z ∈ Icc x y) : + HasDerivAt (fun t => 1 / f t) (-deriv f z / (f z) ^ 2) z := by + simpa only [one_div,Pi.inv_apply] using! + (hdiff z (hsub hz)).hasDerivAt.inv (hpos z (hsub hz)).ne' + have hbound (z : ℝ) (hz : z ∈ interior (Icc x y)) : + -K ≤ deriv (fun t => 1 / f t) z := by + rw [(hg z (interior_subset hz)).deriv,neg_div] + apply neg_le_neg + exact (div_le_iff₀ (sq_pos_of_pos (hpos z (hsub (interior_subset hz))))).mpr + (hderiv z (hsub (interior_subset hz))) + have hdist := (convex_Icc x y).mul_sub_le_image_sub_of_le_deriv + (fun z hz => (hg z hz).continuousAt.continuousWithinAt) + (fun z hz => (hg z (interior_subset hz)).differentiableAt.differentiableWithinAt) + hbound x ⟨le_rfl,hxy⟩ y ⟨hxy,le_rfl⟩ hxy + have hinv : 1 / f y < ε := by + apply (div_lt_iff₀ (hpos y hy)).mpr + have hh := (div_lt_iff₀ hε).mp hfy + nlinarith + have hKdist := mul_le_mul_of_nonneg_left (show y - x ≤ b - x by linarith) hK.le + linarith + have hmul := mul_le_mul_of_nonneg_right hinverse (hpos x hx).le + rw [div_mul_cancel₀ 1 (hpos x hx).ne'] at hmul + apply (div_le_iff₀ (mul_pos hK (sub_pos.mpr hx.2))).mpr + nlinarith + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/RestrictedMomentHolder.lean b/lean/OAI/Probability/BenjaminiSchramm/RestrictedMomentHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..a69b9a7ab6263af9b8d49e97852a0865b9a67f42 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/RestrictedMomentHolder.lean @@ -0,0 +1,29 @@ +import OAI.Probability.BenjaminiSchramm.LayerMomentDecomposition + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma restricted_fractional_moment_holder {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (B : Set Ω) (X : Ω → ℝ≥0∞) (hX : Measurable X) + {a : ℝ} (ha : 0 < a) (ha1 : a < 1) : + (∫⁻ ω in B, X ω^a ∂μ) ≤ (∫⁻ ω in B, X ω ∂μ)^a*(μ B)^(1-a) := by + have hc := Real.holderConjugate_one_div ha (sub_pos.mpr ha1) (by ring : a+(1-a)=1) + have hh := ENNReal.lintegral_mul_le_Lp_mul_Lq (μ.restrict B) hc + ((hX.pow_const a).aemeasurable) + (measurable_const.aemeasurable : AEMeasurable (fun _ : Ω => (1 : ℝ≥0∞)) (μ.restrict B)) + have hcancel : a*(1/a)=1 := by field_simp + have hinva : 1/(1/a)=a := by field_simp + have hinvb : 1/(1/(1-a))=1-a := by field_simp + simpa only [Pi.mul_apply,mul_one,ENNReal.one_rpow,←ENNReal.rpow_mul,hcancel,ENNReal.rpow_one, + lintegral_const,Measure.restrict_apply_univ,one_mul,hinva,hinvb] using hh + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/RootGhostSums.lean b/lean/OAI/Probability/BenjaminiSchramm/RootGhostSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb3f13fe081e013ace556688db084a7f8d34ad5f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/RootGhostSums.lean @@ -0,0 +1,40 @@ +import OAI.Probability.BenjaminiSchramm.RootTiltedGhost + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E ι : Type*} [Countable V] [Countable E] [Fintype ι] + [MeasurableSpace ι] [MeasurableSingletonClass ι] (G : BondGraph V E) (root : ι → V) + +lemma rootQuarterGhostMagnetization_eq_sum (p : unitInterval) {h : ℝ} (hh : 0 ≤ h) : + G.rootQuarterGhostMagnetization root p h = ∑ i, G.quarterGhostMagnetization p (root i) h := by + have hI := integrable_ghostKernel (Measure.count.prod (G.law p)) + (fun z => (G.rootQuarterMass root z).toReal) + (G.measurable_rootQuarterMass root).ennreal_toReal (fun _ => ENNReal.toReal_nonneg) hh + unfold rootQuarterGhostMagnetization ghostMagnetization + erw [integral_prod _ hI] + rw [integral_fintype Integrable.of_finite] + simp only [measureReal_def, Measure.count_singleton, ENNReal.toReal_one, one_smul] + rfl + +lemma rootQuarterGhostDerivative_eq_sum (p : unitInterval) {h : ℝ} (hh : 0 < h) : + G.rootQuarterGhostDerivative root p h = ∑ i, G.quarterGhostDerivative p (root i) h := by + have hI := (hasDerivAt_ghostMagnetization (Measure.count.prod (G.law p)) + (fun z => (G.rootQuarterMass root z).toReal) + (G.measurable_rootQuarterMass root).ennreal_toReal (fun _ => ENNReal.toReal_nonneg) hh).1 + unfold rootQuarterGhostDerivative ghostMagnetizationDerivative + erw [integral_prod _ hI] + rw [integral_fintype Integrable.of_finite] + simp only [measureReal_def, Measure.count_singleton, ENNReal.toReal_one, one_smul] + rfl + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/RootTiltedGhost.lean b/lean/OAI/Probability/BenjaminiSchramm/RootTiltedGhost.lean new file mode 100644 index 0000000000000000000000000000000000000000..da861d0141959ae7af12cb2798d7d88e528d07f2 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/RootTiltedGhost.lean @@ -0,0 +1,78 @@ +import OAI.Probability.BenjaminiSchramm.TiltedGhostSusceptibility + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped ENNReal BigOperators + +namespace CriticalPercolation.BondGraph + +variable {V E ι : Type*} (G : BondGraph V E) + [Fintype ι] [MeasurableSpace ι] [MeasurableSingletonClass ι] (root : ι → V) + +def rootQuarterMass (z : ι × Set E) : ℝ≥0∞ := G.quarterTiltedMass z.2 (root z.1) + +def rootQuarterGhostMagnetization (p : unitInterval) (h : ℝ) : ℝ := + Percolation.BenjaminiSchramm.ghostMagnetization (Measure.count.prod (G.law p)) + (fun z => (G.rootQuarterMass root z).toReal) h + +def rootQuarterGhostDerivative (p : unitInterval) (h : ℝ) : ℝ := + Percolation.BenjaminiSchramm.ghostMagnetizationDerivative (Measure.count.prod (G.law p)) + (fun z => (G.rootQuarterMass root z).toReal) h + +lemma measurable_rootQuarterMass [Countable V] [Countable E] : + Measurable (G.rootQuarterMass root) := + measurable_from_prod_countable_right fun i => G.measurable_quarterTiltedMass (root i) + +lemma lintegral_rootQuarterMass [Countable V] [Countable E] (p : unitInterval) : + (∫⁻ z, G.rootQuarterMass root z ∂Measure.count.prod (G.law p)) = + ∑ i, G.tiltedSusceptibility p (1 / 4) (root i) := by + rw [lintegral_prod _ (G.measurable_rootQuarterMass root).aemeasurable, lintegral_count, + tsum_fintype] + apply Finset.sum_congr rfl + intro i _ + exact G.lintegral_quarterTiltedMass p (root i) + +theorem root_quarterTiltedSusceptibility_lt_top_of_moment_and_differential + [Countable V] [Countable E] (p : unitInterval) + (hmoment : ∀ i, (∫⁻ ω, G.quarterTiltedMass ω (root i) ^ (3 / 4 : ℝ) ∂G.law p) < ⊤) + (C : ℝ) (hC : 0 ≤ C) + (hdiff : ∀ t, 0 < t → t ≤ 1 → + G.rootQuarterGhostMagnetization root p (t ^ 4) ≤ + C * G.rootQuarterGhostMagnetization root p (t ^ 4) ^ 2 + + t ^ 4 * G.rootQuarterGhostDerivative root p (t ^ 4) + + C * t ^ 6 * G.rootQuarterGhostDerivative root p (t ^ 4)) : + ∀ i, G.tiltedSusceptibility p (1 / 4) (root i) < ⊤ := by + let μ : Measure (ι × Set E) := (Measure.count : Measure ι).prod (G.law p) + have hmeas := G.measurable_rootQuarterMass root + have hpow : Measurable (fun z => G.rootQuarterMass root z ^ (3 / 4 : ℝ)) := + ENNReal.continuous_rpow_const.measurable.comp hmeas + have hmom : (∫⁻ z, G.rootQuarterMass root z ^ (3 / 4 : ℝ) ∂μ) < ⊤ := by + rw [lintegral_prod _ hpow.aemeasurable, lintegral_count, tsum_fintype] + exact ENNReal.sum_lt_top.mpr fun i _ => hmoment i + have hfinite : ∀ᵐ z ∂μ, G.rootQuarterMass root z < ⊤ := by + filter_upwards [ae_lt_top hpow hmom.ne] with z hz + exact (ENNReal.rpow_lt_top_iff_of_pos (by norm_num : (0 : ℝ) < 3 / 4)).mp hz + have hXi : Integrable (fun z => (G.rootQuarterMass root z).toReal ^ (3 / 4 : ℝ)) μ := by + simpa only [ENNReal.toReal_rpow] using + integrable_toReal_of_lintegral_ne_top hpow.aemeasurable hmom.ne + have hfin : (∫⁻ z, G.rootQuarterMass root z ∂μ) < ⊤ := by + have heq : (fun z => ENNReal.ofReal (G.rootQuarterMass root z).toReal) =ᵐ[μ] + G.rootQuarterMass root := + hfinite.mono fun _ hz => ENNReal.ofReal_toReal hz.ne + rw [← lintegral_congr_ae heq] + exact Percolation.BenjaminiSchramm.firstMoment_lt_top_of_threeQuarter_and_differential + μ (fun z => (G.rootQuarterMass root z).toReal) hmeas.ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) hXi C hC hdiff + rw [G.lintegral_rootQuarterMass root p] at hfin + intro i + exact lt_of_le_of_lt (Finset.single_le_sum + (f := fun j : ι => G.tiltedSusceptibility p (1 / 4) (root j)) + (fun _ _ => bot_le) (Finset.mem_univ i)) hfin + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SelectedLayerVertex.lean b/lean/OAI/Probability/BenjaminiSchramm/SelectedLayerVertex.lean new file mode 100644 index 0000000000000000000000000000000000000000..049662d0bc6aaa8499c78ca3063dc2eeb11b5726 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SelectedLayerVertex.lean @@ -0,0 +1,71 @@ +import OAI.Probability.BenjaminiSchramm.LayerFreshSelection +import OAI.Probability.BenjaminiSchramm.SlabHit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] (G : BondGraph V E) + +def firstLayerHitAt (I : Set E) (x : V) (A : Set V) (z : V) : Set (Set E) := + {ω | Conn G (ω ∩ I) x z ∧ z ∈ A ∧ ∀ w ∈ A, + Conn G (ω ∩ I) x w → Encodable.encode z ≤ Encodable.encode w} + +lemma firstLayerHitAt_pairwise (I : Set E) (x : V) (A : Set V) : + Pairwise (fun u v => Disjoint (firstLayerHitAt G I x A u) (firstLayerHitAt G I x A v)) := by + intro u v huv + apply Set.disjoint_left.mpr + rintro ω hu hv + exact huv (Encodable.encode_injective (le_antisymm (hu.2.2 v hv.2.1 hv.1) + (hv.2.2 u hu.2.1 hu.1))) + +lemma iUnion_firstLayerHitAt (I : Set E) (x : V) (A : Set V) : + (⋃ z, firstLayerHitAt G I x A z) = {ω | ∃ z ∈ A, Conn G (ω ∩ I) x z} := by + ext ω + constructor + · intro h + obtain ⟨z,hz⟩ := Set.mem_iUnion.mp h + exact ⟨z,hz.2.1,hz.1⟩ + · rintro ⟨z,hz,hconn⟩ + have hex : ∃ n : ℕ, ∃ w : V, Encodable.encode w = n ∧ w ∈ A ∧ Conn G (ω ∩ I) x w := + ⟨Encodable.encode z,z,rfl,hz,hconn⟩ + obtain ⟨w,hwn,hw,hwconn⟩ := Nat.find_spec hex + apply Set.mem_iUnion.mpr + refine ⟨w,hwconn,hw,?_⟩ + intro v hv hvconn + rw [hwn] + exact Nat.find_min' hex ⟨v,rfl,hv,hvconn⟩ + +lemma firstLayerHitAt_dependsOn (I : Set E) (x : V) (A : Set V) (z : V) : + DependsOn (fun ω => ω ∈ firstLayerHitAt G I x A z) I := by + intro ω η hωη + have he : Set.inter ω I = Set.inter η I := by + ext e + change (ω e ∧ e ∈ I) ↔ (η e ∧ e ∈ I) + by_cases hi : e ∈ I + · simp only [hi,and_true] + exact Iff.of_eq (hωη e hi) + · simp only [hi,and_false] + change (Conn G (Set.inter ω I) x z ∧ z ∈ A ∧ ∀ w ∈ A, + Conn G (Set.inter ω I) x w → Encodable.encode z ≤ Encodable.encode w) = + (Conn G (Set.inter η I) x z ∧ z ∈ A ∧ ∀ w ∈ A, + Conn G (Set.inter η I) x w → Encodable.encode z ≤ Encodable.encode w) + rw [he] + +lemma measurableSet_firstLayerHitAt [Countable E] (I : Set E) (x : V) (A : Set V) (z : V) : + MeasurableSet (firstLayerHitAt G I x A z) := by + have hm : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + have hc (y : V) : Measurable (fun ω : Set E => Conn G (ω ∩ I) x y) := + (measurableSet_conn G x y).mem.comp hm + exact ((hc z).and (measurable_const.and (Measurable.forall fun w => + measurable_const.imp ((hc w).imp measurable_const)))).setOf + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SignedUpperConvolution.lean b/lean/OAI/Probability/BenjaminiSchramm/SignedUpperConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d8e36e53484685d677d5c2d1e34e37627bf1139 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SignedUpperConvolution.lean @@ -0,0 +1,97 @@ +import OAI.Probability.BenjaminiSchramm.NegativeMomentConvolution + +namespace OAI + +noncomputable section +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma signed_upper_convolution_bound (S : ℕ → ℝ) (hS : ∀ n, 0 ≤ S n) + (β K χ : ℝ) (hβ : 0 < β) (hχ : 0 ≤ χ) + (hbound : ∀ n, S n ≤ χ) (hmul : ∀ n j, S (n+j) ≤ S n*S j) + (hdecay : ∀ n : ℕ, S n ≤ K*Real.exp (-(3*β/4)*n)) + (F : ℤ → ℝ≥0∞) (hF : ∀ i, F i ≤ ENNReal.ofReal χ) + (hFpos : ∀ i : ℕ, F i ≤ ENNReal.ofReal (χ*S i)) : + ∃ C : ℝ, 0 < C ∧ ∀ n : ℕ, + (∑' i : ℤ, if i ≤ (n : ℤ) then F i*(ENNReal.ofReal (S ((n : ℤ)-i).toNat))^2 else 0) ≤ + ENNReal.ofReal (C*Real.exp (-β*n)*prefixMaximum (fun j => Real.exp (β*j)*S j) n) := by + obtain ⟨A,hA,hpos⟩ := normalized_upper_convolution_bound S hS β K hβ hdecay + obtain ⟨D,hD,hneg⟩ := normalized_negative_square_convolution_bound S hS β K χ hβ hχ hbound hmul hdecay + refine ⟨χ*(A+D)+1,by positivity,fun n => ?_⟩ + let M := prefixMaximum (fun j => Real.exp (β*j)*S j) n + have hM : 0 ≤ M := (mul_nonneg (Real.exp_pos _).le (hS 0)).trans + (le_prefixMaximum (fun j => Real.exp (β*j)*S j) (Nat.zero_le n)) + let f (i : ℤ) : ℝ≥0∞ := if i ≤ (n : ℤ) then F i*(ENNReal.ofReal (S ((n : ℤ)-i).toNat))^2 else 0 + have hp : (∑' i : ℕ, f i) ≤ ENNReal.ofReal (χ*A*Real.exp (-β*n)*M) := by + rw [tsum_eq_sum (s := Finset.range (n+1)) (fun i hi => ?_)] + · calc + _ ≤ ∑ i ∈ Finset.range (n+1), ENNReal.ofReal (χ*(S i*(S (n-i))^2)) := by + apply Finset.sum_le_sum + intro i hi + have hin : i ≤ n := Nat.le_of_lt_succ (Finset.mem_range.mp hi) + have hz : (i : ℤ) ≤ n := by exact_mod_cast hin + have hid : ((n : ℤ)-(i : ℤ)).toNat=n-i := by omega + dsimp only [f] + rw [ite_eq_left hz,hid] + calc + _ ≤ ENNReal.ofReal (χ*S i)*(ENNReal.ofReal (S (n-i)))^2 := + mul_le_mul' (hFpos i) le_rfl + _ = _ := by + simp only [ENNReal.ofReal_mul hχ,ENNReal.ofReal_mul (hS i), + ENNReal.ofReal_pow (hS (n-i))] + ring + _ = ENNReal.ofReal (χ*(∑ i ∈ Finset.range (n+1), S i*(S (n-i))^2)) := by + rw [Finset.mul_sum,ENNReal.ofReal_sum_of_nonneg] + intro i hi + exact mul_nonneg hχ (mul_nonneg (hS i) (sq_nonneg _)) + _ ≤ _ := ENNReal.ofReal_le_ofReal (by + have hh := mul_le_mul_of_nonneg_left (hpos n) hχ + dsimp only [M] at * + nlinarith) + · have hin : n < i := by + have hh : ¬i < n+1 := by simpa only [Finset.mem_range] using hi + omega + have hz : ¬(i : ℤ) ≤ n := by omega + simp only [f,ite_eq_right hz] + have hn : (∑' j : ℕ, f (-(j+1))) ≤ ENNReal.ofReal (χ*D*Real.exp (-β*n)*M) := by + calc + _ ≤ ∑' j : ℕ, ENNReal.ofReal χ*ENNReal.ofReal ((S (n+(j+1)))^2) := by + apply ENNReal.tsum_le_tsum + intro j + have hz : -((j : ℤ)+1) ≤ (n : ℤ) := by omega + have hid : ((n : ℤ)-(-((j : ℤ)+1))).toNat=n+(j+1) := by omega + dsimp only [f] + rw [ite_eq_left hz,hid,ENNReal.ofReal_pow (hS _)] + exact mul_le_mul' (hF _) le_rfl + _ = ENNReal.ofReal χ*(∑' j : ℕ, ENNReal.ofReal ((S (n+(j+1)))^2)) := + ENNReal.tsum_mul_left + _ ≤ ENNReal.ofReal χ*(∑' j : ℕ, ENNReal.ofReal ((S (n+j))^2)) := by + apply mul_le_mul' le_rfl + exact ENNReal.tsum_comp_le_tsum_of_injective Nat.succ_injective + (fun j => ENNReal.ofReal ((S (n+j))^2)) + _ = ENNReal.ofReal (χ*(∑' j : ℕ, (S (n+j))^2)) := by + rw [←ENNReal.ofReal_tsum_of_nonneg (fun _ => sq_nonneg _) (hneg n).1, + ENNReal.ofReal_mul hχ] + _ ≤ _ := ENNReal.ofReal_le_ofReal (by + have hh := mul_le_mul_of_nonneg_left (hneg n).2 hχ + dsimp only [M] at * + nlinarith) + change (∑' i : ℤ, f i) ≤ _ + rw [tsum_of_nat_of_neg_add_one ENNReal.summable ENNReal.summable] + calc + _ ≤ ENNReal.ofReal (χ*A*Real.exp (-β*n)*M)+ENNReal.ofReal (χ*D*Real.exp (-β*n)*M) := + add_le_add hp hn + _ = ENNReal.ofReal ((χ*(A+D))*Real.exp (-β*n)*M) := by + rw [←ENNReal.ofReal_add (by positivity) (by positivity)] + congr 1 + ring + _ ≤ _ := ENNReal.ofReal_le_ofReal (by + apply mul_le_mul_of_nonneg_right _ hM + exact mul_le_mul_of_nonneg_right (by linarith) (Real.exp_pos _).le) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabCountBasic.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabCountBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..e469883b3cb662c831f16830d1f041925b5ef0f5 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabCountBasic.lean @@ -0,0 +1,69 @@ +import OAI.Probability.BenjaminiSchramm.FractionalSlabGeometry +import OAI.Probability.BenjaminiSchramm.LayerFrontierLocalization + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restrictedLayerCount_zero_or_one_le (I : Set E) (W : Set V) (ω : Set E) (x : V) : + restrictedLayerCount G I W ω x=0 ∨ 1 ≤ restrictedLayerCount G I W ω x := by + by_cases hex : ∃ y, y ∈ W ∧ Conn G (ω ∩ I) x y + · obtain ⟨y,hy⟩ := hex + apply Or.inr + unfold restrictedLayerCount + exact ((show (1 : ℝ≥0∞)=(if y ∈ W ∧ Conn G (ω ∩ I) x y then 1 else 0) from + (ite_eq_left hy).symm).le.trans (ENNReal.le_tsum + (f := fun z => if z ∈ W ∧ Conn G (ω ∩ I) x z then 1 else 0) y)) + · exact Or.inl (ENNReal.tsum_eq_zero.mpr fun y => ite_eq_right (fun h => hex ⟨y,h⟩)) + +lemma restrictedLayerCount_lt_top_of_finite (I : Set E) (W : Set V) (ω : Set E) (x : V) + (hfin : (cluster G ω x).Finite) : restrictedLayerCount G I W ω x < ⊤ := by + have hIF : (cluster G (ω ∩ I) x ∩ W).Finite := + (hfin.subset fun z hz => conn_mono G Set.inter_subset_left hz.1) + let S := hIF.toFinset + have he : restrictedLayerCount G I W ω x=S.card := + restrictedLayerCount_eq_card G I W ω x S (fun y => by + simp only [S,hIF.mem_toFinset,Set.mem_inter_iff] + exact and_comm) + rw [he] + exact ENNReal.natCast_lt_top _ + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma adjustedSlabBandCount_rpow_mono_exponent (a : V → ℝ) (d c l u : ℝ) + (ω : Set E) (x : V) {q q' : ℝ} (hq : 0 < q) (hqq' : q ≤ q') : + (G.adjustedSlabBandCount a d c l u ω x)^q ≤ + (G.adjustedSlabBandCount a d c l u ω x)^q' := by + simp only [G.adjustedSlabBandCount_eq_restricted] + rcases restrictedLayerCount_zero_or_one_le G.ends _ _ ω x with hz | ho + · rw [hz,ENNReal.zero_rpow_of_pos hq,ENNReal.zero_rpow_of_pos (hq.trans_le hqq')] + · exact ENNReal.rpow_le_rpow_of_exponent_le ho hqq' + +lemma one_le_adjustedSlabZeroBandCount (a : V → ℝ) (d c B : ℝ) + (hB : 0 ≤ B) (ω : Set E) (x : V) : + 1 ≤ G.adjustedSlabBandCount a d c (-B) B ω x := by + apply le_trans _ (ENNReal.le_tsum x) + unfold adjustedSlabBandTransport + rw [ite_eq_left] + exact ⟨Percolation.conn_refl G.ends _ x,by simpa using neg_nonpos.mpr hB,by simpa using hB⟩ + +lemma adjustedSlabBandCount_lt_top_of_finite (a : V → ℝ) (d c l u : ℝ) + (ω : Set E) (x : V) (hfin : (Percolation.cluster G.ends ω x).Finite) : + G.adjustedSlabBandCount a d c l u ω x < ⊤ := by + rw [G.adjustedSlabBandCount_eq_restricted] + exact restrictedLayerCount_lt_top_of_finite G.ends _ _ ω x hfin + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabCrossing.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabCrossing.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d76bd8ffbac62049982df976e279ef1f506fbff --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabCrossing.lean @@ -0,0 +1,70 @@ +import OAI.Probability.BenjaminiSchramm.ModularSlabs + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical + +namespace Percolation.BenjaminiSchramm +variable {V : Type*} {H : SimpleGraph V} + +lemma first_height_crossing_walk (f : V → ℝ) (R : ℝ) (hR : 0 ≤ R) + (hjump : ∀ {u v}, H.Adj u v → |f v - f u| ≤ R) + {x y : V} (p : H.Walk x y) (a b : ℝ) : + a ≤ f x → f x ≤ b → b ≤ f y → (∀ z ∈ p.support, a ≤ f z) → + ∃ z, ∃ q : H.Walk x z, + b ≤ f z ∧ f z ≤ b+R ∧ q.support ⊆ p.support ∧ + ∀ w ∈ q.support, a ≤ f w ∧ f w ≤ b+R := by + induction p with + | @nil u => + intro ha hb hend _ + refine ⟨_,SimpleGraph.Walk.nil,hend,by linarith,?_,?_⟩ + · exact fun _ h => h + · intro w hw + have hw' : w = u := by simpa only [SimpleGraph.Walk.support_nil,List.mem_singleton] using hw + subst w + exact ⟨ha,by linarith⟩ + | @cons x v y huv p ih => + intro ha hb hend hlow + by_cases hx : b ≤ f x + · refine ⟨x,SimpleGraph.Walk.nil,hx,by linarith,?_,?_⟩ + · intro w hw + have hw' : w = x := by simpa only [SimpleGraph.Walk.support_nil,List.mem_singleton] using hw + subst w + exact SimpleGraph.Walk.start_mem_support _ + · intro w hw + have hw' : w = x := by simpa only [SimpleGraph.Walk.support_nil,List.mem_singleton] using hw + subst w + exact ⟨ha,by linarith⟩ + have hav : a ≤ f v := hlow v (by simp) + by_cases hv : b ≤ f v + · have hvu := (abs_le.mp (hjump huv)).2 + refine ⟨v,SimpleGraph.Walk.cons huv SimpleGraph.Walk.nil,hv,by linarith,?_,?_⟩ + · intro w hw + simp only [SimpleGraph.Walk.support_cons,SimpleGraph.Walk.support_nil,List.mem_cons, + List.not_mem_nil,or_false] at hw + rcases hw with rfl | rfl + · exact SimpleGraph.Walk.start_mem_support _ + · simp + · intro w hw + simp only [SimpleGraph.Walk.support_cons,SimpleGraph.Walk.support_nil,List.mem_cons, + List.not_mem_nil,or_false] at hw + rcases hw with rfl | rfl <;> exact ⟨by assumption,by linarith⟩ + · obtain ⟨z,q,hz,hz',hq,hbound⟩ := ih hav (le_of_not_ge hv) hend + (fun w hw => hlow w (List.mem_cons_of_mem _ hw)) + refine ⟨z,q.cons huv,hz,hz',?_,?_⟩ + · intro w hw + simp only [SimpleGraph.Walk.support_cons,List.mem_cons] at hw ⊢ + exact hw.imp id (hq ·) + · intro w hw + simp only [SimpleGraph.Walk.support_cons,List.mem_cons] at hw + rcases hw with rfl | hw + · exact ⟨ha,by linarith⟩ + · exact hbound w hw + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabExtensionGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabExtensionGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5f8e4ce349e0187b5de0dc5f2a2f346d120ecef --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabExtensionGeometry.lean @@ -0,0 +1,125 @@ +import OAI.Probability.BenjaminiSchramm.LayerMonotoneLimit +import OAI.Probability.BenjaminiSchramm.SlabFractionalRecurrence + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restrictedLayerCount_le_adjustedSlab (a : V → ℝ) (I : Set E) (A : Set V) + (d c l u : ℝ) (ω : Set E) (x : V) + (hI : I ⊆ Percolation.internalEdges G.ends + {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) + (hA : A ⊆ {z | l ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u}) : + restrictedLayerCount G.ends I A ω x ≤ G.adjustedSlabBandCount a d c l u ω x := by + rw [G.adjustedSlabBandCount_eq_restricted] + exact (restrictedLayerCount_mono_edges G.ends hI A ω x).trans + (restrictedLayerCount_mono_vertices G.ends hA _ ω x) + +lemma height_difference_jump (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) + (hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → + |G.orbitAdjustedHeight a u v| ≤ R) (x : V) : + ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → + |G.orbitAdjustedHeight a x v-G.orbitAdjustedHeight a x u| ≤ R := by + intro e u v hu hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x u v + convert hjump e u v hu hv using 1 + congr 1 + linarith + +lemma lower_extension_frontier_count_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R c : ℝ) (hc0 : 0 ≤ c) (n : ℕ) (x z : V) + (hzlo : -((n+1 : ℕ) : ℝ)*R ≤ G.orbitAdjustedHeight a x z) + (hzhi : G.orbitAdjustedHeight a x z < -(n : ℝ)*R) (ω : Set E) : + restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -((n : ℝ)+1)*R ≤ G.orbitAdjustedHeight a x v ∧ + G.orbitAdjustedHeight a x v ≤ c}) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} ω z ≤ + G.adjustedSlabBandCount a (-(c+R)) (-G.orbitAdjustedHeight a x z+(c+R)) + (-G.orbitAdjustedHeight a x z-R) (-G.orbitAdjustedHeight a x z+R) ω z := by + have hcast : ((n+1 : ℕ) : ℝ)=(n : ℝ)+1 := by norm_cast + rw [hcast] at hzlo + apply G.restrictedLayerCount_le_adjustedSlab + · apply Percolation.internalEdges_mono G.ends + intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x z v + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + · intro v hv + have hh := G.orbitAdjustedHeight_change_base hc hl a x z v + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + +variable [Countable V] [Countable E] + +theorem lower_extension_fractional_recurrence + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (d : ℕ) (hd : ∀ u, (Percolation.finite_neighbors hl u).toFinset.card ≤ d) + (R c : ℝ) (hR : 0 ≤ R) (hc0 : 0 ≤ c) + (hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → |G.orbitAdjustedHeight a u v| ≤ R) + (p : unitInterval) (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (n : ℕ) (x : V) {q t : ℝ} (hq : 0 < q) (hq1 : q ≤ 1) (ht : 0 < t) (ht1 : t ≤ 1) + (L : ℝ≥0∞) + (hL : ∀ z, -((n : ℝ)+1)*R ≤ G.orbitAdjustedHeight a x z → + G.orbitAdjustedHeight a x z < -(n : ℝ)*R → + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | -((n : ℝ)+1)*R ≤ G.orbitAdjustedHeight a x v ∧ + G.orbitAdjustedHeight a x v ≤ c}) + {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} ω z)^q ∂G.law p) ≤ L) : + (∫⁻ ω, (G.adjustedSlabBandCount a (-((n : ℝ)+1)*R) c (-R) R ω x)^(q*t) ∂G.law p) ≤ + (∫⁻ ω, (G.adjustedSlabBandCount a (-(n : ℝ)*R) c (-R) R ω x)^(q*t) ∂G.law p)+ + (d : ℝ≥0∞)^t* + (∫⁻ ω, (G.adjustedSlabBandCount a (-(n : ℝ)*R) c (-(n : ℝ)*R-R) (-(n : ℝ)*R+R) ω x)^t ∂G.law p)*L^t := by + let f := fun z => -G.orbitAdjustedHeight a x z + let I := Percolation.internalEdges G.ends + {v | -(n : ℝ)*R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ c} + let J := Percolation.internalEdges G.ends + {v | -((n : ℝ)+1)*R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ c} + let W := {v | -R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ R} + have hIeq : Percolation.internalEdges G.ends {v | -c ≤ f v ∧ f v ≤ (n : ℝ)*R}=I := by + congr 1 + ext v + change (-c ≤ -G.orbitAdjustedHeight a x v ∧ -G.orbitAdjustedHeight a x v ≤ (n : ℝ)*R) ↔ _ + dsimp [I] + constructor <;> intro hv <;> constructor <;> linarith [hv.1,hv.2] + have hJ : J ⊆ Percolation.internalEdges G.ends {v | -c ≤ f v} := + Percolation.internalEdges_mono G.ends (fun v hv => by dsimp [f]; linarith [hv.2]) + have hj : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → |f v-f u| ≤ R := by + intro e u v hu hv + have hh := G.height_difference_jump hc hl a R hjump x e u v hu hv + simpa only [f,neg_sub_neg,abs_sub_comm] using hh + have hI : ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends (ω ∩ I) x).Finite := by + filter_upwards [hfin x] with ω hω + exact hω.subset fun v hv => Percolation.conn_mono G.ends inter_subset_left hv + have hrec := lower_slab_fractional_recurrence G.ends hl d hd (fun _ => p) f R (-c) ((n : ℝ)*R) + hj J hJ x (by simp only [f,G.orbitAdjustedHeight_self,neg_zero]; exact ⟨by linarith,by positivity⟩) + (by simpa only [hIeq,CriticalPercolation.BernoulliProduct.law_const,CriticalPercolation.BondGraph.law] using hI) W hq hq1 ht ht1 L + (fun z hzlo hzhi => by + simpa only [J,W,CriticalPercolation.BernoulliProduct.law_const,CriticalPercolation.BondGraph.law] using + hL z (by dsimp [f] at hzhi; linarith) (by dsimp [f] at hzlo; linarith)) + simp only [CriticalPercolation.BernoulliProduct.law_const] at hrec + change (∫⁻ ω, restrictedLayerCount G.ends J W ω x^(q*t) ∂G.law p) ≤ _ at hrec + rw [hIeq] at hrec + simp only [G.adjustedSlabBandCount_eq_restricted] + apply hrec.trans + apply add_le_add le_rfl + apply mul_le_mul' _ le_rfl + apply mul_le_mul' le_rfl + apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ ht.le + apply restrictedLayerCount_mono_vertices G.ends + intro v hv + dsimp [f] at hv + exact ⟨by linarith [hv.2],by linarith [hv.1]⟩ + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabFirstVisit.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabFirstVisit.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5bc293fd14c7c21f93500ca5e3f2eff832610cb --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabFirstVisit.lean @@ -0,0 +1,149 @@ +import OAI.Probability.BenjaminiSchramm.SlabSecondMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma walk_endpoint_height_bound {V : Type*} {H : SimpleGraph V} + (f : V → ℝ) (R b : ℝ) (hR : 0 ≤ R) + (hjump : ∀ {u v}, H.Adj u v → |f v-f u| ≤ R) + {x y : V} (p : H.Walk x y) (hx : f x < b) + (hbelow : ∀ v ∈ p.support, v ≠ y → f v < b) : f y ≤ b+R := by + induction p with + | nil => linarith + | @cons x v y hxv p ih => + by_cases hv : v = y + · subst v + have hh := (abs_le.mp (hjump hxv)).2 + linarith + · exact ih (hbelow v (by simp) hv) + (fun w hw hwy => hbelow w (List.mem_cons_of_mem _ hw) hwy) + +variable {V E : Type*} (G : BondGraph V E) + +lemma conn_first_height_disjoint (f : V → ℝ) (R b : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (I : Set E) (ω : Set E) (x y : V) (hx : f x < b) (hy : b ≤ f y) + (hconn : Conn G (ω ∩ I) x y) : + ∃ z, b ≤ f z ∧ f z ≤ b+R ∧ ω ∈ DisjointOccurrence + {η | Conn G (η ∩ (I ∩ internalEdges G {v | f v ≤ b+R})) x z} + {η | Conn G (η ∩ I) z y} := by + obtain ⟨p₀⟩ := (conn_iff_reachable G (ω ∩ I) x y).mp hconn + let p := p₀.toPath.val + let S := p.support.toFinset.filter fun v => b ≤ f v + have hyS : y ∈ S := Finset.mem_filter.mpr ⟨List.mem_toFinset.mpr p.end_mem_support,hy⟩ + obtain ⟨z,hzS,hzp,hfirst⟩ := p.exists_mem_support_forall_mem_support_imp_eq S + ⟨y,Finset.mem_filter.mpr ⟨hyS,p.end_mem_support⟩⟩ + have hz : b ≤ f z := (Finset.mem_filter.mp hzS).2 + have hbelow (v : V) (hv : v ∈ (p.takeUntil z hzp).support) (hvz : v ≠ z) : f v < b := by + by_contra hn + have hvS : v ∈ S := Finset.mem_filter.mpr + ⟨List.mem_toFinset.mpr (p.support_takeUntil_subset_support hzp hv),le_of_not_gt hn⟩ + exact hvz (hfirst v hvS hv) + have hj {u v : V} (huv : (openSimpleGraph G (ω ∩ I)).Adj u v) : |f v-f u| ≤ R := by + obtain ⟨e,_he,heq⟩ := huv.2 + exact hjump e u v (by rw [heq]; simp) (by rw [heq]; simp) + have hzR : f z ≤ b+R := walk_endpoint_height_bound f R b hR hj (p.takeUntil z hzp) hx hbelow + have hupper (v : V) (hv : v ∈ (p.takeUntil z hzp).support) : f v ≤ b+R := by + by_cases hvz : v=z + · simpa only [hvz] using hzR + · have hh := hbelow v hv hvz + linarith + obtain ⟨a,ha,hea,hoa⟩ := walk_lift_bonds G (ω ∩ I) (p.takeUntil z hzp) + obtain ⟨c,hc,hec,hoc⟩ := walk_lift_bonds G (ω ∩ I) (p.dropUntil z hzp) + have hain (e : E) (he : e ∈ a) : e ∈ internalEdges G {v | f v ≤ b+R} := by + intro v hv + have hGe : G e ∈ (p.takeUntil z hzp).edges := hea ▸ List.mem_map_of_mem he + exact hupper v (SimpleGraph.Walk.mem_support_of_mem_edges hGe hv) + have haI : (a.toFinset : Set E) ⊆ I ∩ internalEdges G {v | f v ≤ b+R} := by + intro e he + exact ⟨(hoa e (List.mem_toFinset.mp he)).2,hain e (List.mem_toFinset.mp he)⟩ + have hcI : (c.toFinset : Set E) ⊆ I := fun e he => (hoc e (List.mem_toFinset.mp he)).2 + refine ⟨z,hz,hzR,a.toFinset,c.toFinset,?_,?_,?_,?_,?_⟩ + · intro e he + exact (hoa e (List.mem_toFinset.mp he)).1 + · intro e he + exact (hoc e (List.mem_toFinset.mp he)).1 + · apply Finset.disjoint_left.mpr + intro e heA heC + exact List.disjoint_left.mp (p₀.toPath.property.isTrail.disjoint_edges_takeUntil_dropUntil hzp) + (hea ▸ List.mem_map_of_mem (List.mem_toFinset.mp heA)) + (hec ▸ List.mem_map_of_mem (List.mem_toFinset.mp heC)) + · have hh := ha.conn (fun e he => List.mem_toFinset.mpr he) + have hsub : (a.toFinset : Set E) ⊆ (a.toFinset : Set E) ∩ + (I ∩ internalEdges G {v | f v ≤ b+R}) := fun e he => ⟨he,haI he⟩ + exact conn_mono G hsub hh + · have hh := hc.conn (fun e he => List.mem_toFinset.mpr he) + have hsub : (c.toFinset : Set E) ⊆ (c.toFinset : Set E) ∩ I := fun e he => ⟨he,hcI he⟩ + exact conn_mono G hsub hh + +theorem first_height_connection_bound [Countable V] [Countable E] + (f : V → ℝ) (R b : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (I : Set E) (p : unitInterval) (x y : V) (hx : f x < b) (hy : b ≤ f y) : + law p {ω | Conn G (ω ∩ I) x y} ≤ + ∑' z, if b ≤ f z ∧ f z ≤ b+R then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ b+R})) x z} * + law p {ω | Conn G (ω ∩ I) z y} else 0 := by + let J := I ∩ internalEdges G {v | f v ≤ b+R} + let C := fun z => if b ≤ f z ∧ f z ≤ b+R then + DisjointOccurrence {ω | Conn G (ω ∩ J) x z} {ω | Conn G (ω ∩ I) z y} else ∅ + have hsub : {ω | Conn G (ω ∩ I) x y} ⊆ ⋃ z, C z := by + intro ω hω + obtain ⟨z,hz,hzR,hd⟩ := conn_first_height_disjoint G f R b hR hjump I ω x y hx hy hω + have hband : b ≤ f z ∧ f z ≤ b+R := ⟨hz,hzR⟩ + exact Set.mem_iUnion.mpr ⟨z,by simpa only [C,ite_eq_left hband] using hd⟩ + calc + _ ≤ law p (⋃ z, C z) := measure_mono hsub + _ ≤ ∑' z, law p (C z) := measure_iUnion_le _ + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : b ≤ f z ∧ f z ≤ b+R + · simp only [C,ite_eq_left hz] + exact bk_ennreal p _ _ + (fun _ _ h hconn => conn_mono G (Set.inter_subset_inter_left _ h) hconn) + (fun _ _ h hconn => conn_mono G (Set.inter_subset_inter_left _ h) hconn) + (finiteWitness_conn_restricted G J x z) (finiteWitness_conn_restricted G I z y) + · simp only [C,ite_eq_right hz,measure_empty,le_refl] + +theorem first_height_layer_moment_bound [Countable V] [Countable E] + (f : V → ℝ) (R b : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (I : Set E) (A : Set V) (p : unitInterval) (x : V) + (hx : f x < b) (hA : ∀ y ∈ A, b ≤ f y) : + (∫⁻ ω, restrictedLayerCount G I A ω x ∂law p) ≤ + ∑' z, (if b ≤ f z ∧ f z ≤ b+R then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ b+R})) x z} else 0) * + (∫⁻ ω, restrictedLayerCount G I A ω z ∂law p) := by + simp_rw [lintegral_restrictedLayerCount] + calc + _ ≤ ∑' y, ∑' z, (if b ≤ f z ∧ f z ≤ b+R then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ b+R})) x z} else 0) * + (if y ∈ A then law p {ω | Conn G (ω ∩ I) z y} else 0) := by + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : y ∈ A + · simp only [ite_eq_left hy] + have hh := first_height_connection_bound G f R b hR hjump I p x y hx (hA y hy) + refine hh.trans_eq (tsum_congr fun z => ?_) + by_cases hz : b ≤ f z ∧ f z ≤ b+R + · rw [ite_eq_left hz,ite_eq_left hz] + · rw [ite_eq_right hz,ite_eq_right hz,zero_mul] + · simp only [ite_eq_right hy] + exact bot_le + _ = _ := by + rw [ENNReal.tsum_comm] + congr 1 + funext z + exact ENNReal.tsum_mul_left + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabFractionalProfileShift.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabFractionalProfileShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2bbdc330e0390ace23bffc8c683c6fac20fb9a5 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabFractionalProfileShift.lean @@ -0,0 +1,95 @@ +import OAI.Probability.BenjaminiSchramm.SlabRootShift +import OAI.Probability.BenjaminiSchramm.FractionalSlabGeometry + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm + +lemma finite_energy_cancel_length (X Y : ℝ≥0∞) (δ A B c : ℝ) (N : ℕ) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hlen : (N : ℝ) ≤ A*c+B) + (hXY : ENNReal.ofReal (δ^N)*X ≤ Y) : + X ≤ ENNReal.ofReal (Real.exp (-Real.log δ*(A*c+B)))*Y := by + have he : Real.exp (-Real.log δ*(N : ℝ))*δ^N=1 := by + rw [←Real.exp_log hδ,←Real.exp_nat_mul,←Real.exp_add,Real.log_exp] + rw [show -Real.log δ*(N : ℝ)+(N : ℝ)*Real.log δ=0 by ring,Real.exp_zero] + have hc : ENNReal.ofReal (Real.exp (-Real.log δ*(N : ℝ)))*ENNReal.ofReal (δ^N)=1 := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),he,ENNReal.ofReal_one] + have hs : 0 ≤ -Real.log δ := neg_nonneg.mpr (Real.log_nonpos hδ.le hδ1) + calc + _ = ENNReal.ofReal (Real.exp (-Real.log δ*(N : ℝ)))*(ENNReal.ofReal (δ^N)*X) := by + rw [←mul_assoc,hc,one_mul] + _ ≤ ENNReal.ofReal (Real.exp (-Real.log δ*(N : ℝ)))*Y := mul_le_mul' le_rfl hXY + _ ≤ _ := mul_le_mul' (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_left hlen hs))) le_rfl + +end Percolation.BenjaminiSchramm + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def lowerSlabFractionalProfile (a : V → ℝ) (p : unitInterval) (R L : ℝ) : Prop := + ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount a (-k-r) 0 (-k-R) (-k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k+L*r)) + +theorem finite_ceiling_fractional_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (L : ℝ) (hprofile : G.lowerSlabFractionalProfile (G.stationaryOrbitWeight μ) p R L) : + ∃ T : ℝ, 0 < T ∧ ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → ζ ≤ 1 → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount (G.stationaryOrbitWeight μ) (-k-r) c (-k-R) (-k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp (ζ*k+L*r+T*c)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨A,B,hA,hB,hpaths⟩ := G.stationaryOrbitHeight_bounded_ascent_to_level + hc hl hq μ hμ hstat hu R hR.le hjump + let δ := min (p : ℝ) (1-p) + have hδ : 0 < δ := lt_min hp0 (sub_pos.mpr hp1) + have hδ1 : δ ≤ 1 := (min_le_left _ _).trans p.2.2 + let s := -Real.log δ + have hs : 0 ≤ s := neg_nonneg.mpr (Real.log_nonpos hδ.le hδ1) + let T := s*A+1 + refine ⟨T,by dsimp [T]; positivity,fun q hq0 hq1 ζ hζ hζ1 => ?_⟩ + obtain ⟨C,hC,hbound⟩ := hprofile q hq0 hq1 ζ hζ + refine ⟨C*ENNReal.ofReal (Real.exp (s*B+R)),ENNReal.mul_lt_top hC ENNReal.ofReal_lt_top, + fun k hk r hr c hc0 x => ?_⟩ + obtain ⟨y,w,hlen,hcy,hyc,hw⟩ := hpaths c hc0 x + have hXY := G.fractional_slab_root_ascent hc hl a p k r c R hk hr w hcy hw hq0.le + simp_rw [←G.adjustedSlabBandCount_eq_restricted] at hXY + have hh := finite_energy_cancel_length _ _ δ A B c w.length hδ hδ1 hlen hXY + have hlevel : 0 ≤ k+G.orbitAdjustedHeight a x y := add_nonneg hk (hc0.trans hcy) + have hb := hbound (k+G.orbitAdjustedHeight a x y) hlevel r hr y + apply hh.trans ((mul_le_mul' le_rfl hb).trans ?_) + have he : -Real.log δ*(A*c+B)+(ζ*(k+G.orbitAdjustedHeight a x y)+L*r) ≤ + (s*B+R)+(ζ*k+L*r+T*c) := by + have hζh : ζ*G.orbitAdjustedHeight a x y ≤ G.orbitAdjustedHeight a x y := + mul_le_of_le_one_left (hc0.trans hcy) hζ1 + dsimp [s,T] + nlinarith + calc + _ = C*ENNReal.ofReal (Real.exp (-Real.log δ*(A*c+B)+(ζ*(k+G.orbitAdjustedHeight a x y)+L*r))) := by + simp only [Real.exp_add,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ C*ENNReal.ofReal (Real.exp ((s*B+R)+(ζ*k+L*r+T*c))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by + rw [Real.exp_add (s*B+R) (ζ*k+L*r+T*c), + ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabFractionalRecurrence.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabFractionalRecurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..b83bb016a1a63c4ac3323f36ac19fa0b7dd589aa --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabFractionalRecurrence.lean @@ -0,0 +1,163 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierLocalization + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restrictedLayerCount_le_old_add_new (I J : Set E) (A : Set V) + (ω : Set E) (x : V) : + restrictedLayerCount G J A ω x ≤ + restrictedLayerCount G I A ω x + newLayerCount G I J A ω x := by + unfold restrictedLayerCount newLayerCount + rw [←ENNReal.tsum_add] + apply ENNReal.tsum_le_tsum + intro y + by_cases hy : y ∈ A ∧ Conn G (ω ∩ J) x y + · rw [ite_eq_left hy] + by_cases hi : Conn G (ω ∩ I) x y + · simp [hy.1,hy.2,hi] + · simp [hy.1,hy.2,hi] + · rw [ite_eq_right hy] + exact bot_le + +theorem lower_slab_frontier_location + (f : V → ℝ) (R m b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) (J : Set E) (hJ : J ⊆ internalEdges G {v | m ≤ f v}) + (x : V) (hx : m ≤ f x ∧ f x ≤ b) + {z : V} (hz : z ∈ openFrontier G (ω ∩ J) + (cluster G (ω ∩ internalEdges G {v | m ≤ f v ∧ f v ≤ b}) x)) : + b < f z ∧ f z ≤ b+R ∧ ∃ u ∈ cluster G + (ω ∩ internalEdges G {v | m ≤ f v ∧ f v ≤ b}) x, + b-R ≤ f u ∧ f u ≤ b ∧ ∃ e ∈ ω ∩ J, G e = s(u,z) := by + obtain ⟨hz,u,hu,e,he,heq⟩ := hz + have huD := conn_internalEdges_end_mem G ω _ hx hu + have hzD := openFrontier_lowerCluster_outside G ω + {v | m ≤ f v ∧ f v ≤ b} x hx ⟨hz,u,hu,e,he.1,heq⟩ + have hzlo : m ≤ f z := hJ he.2 z (by rw [heq]; simp) + have hzb : b < f z := lt_of_not_ge (fun hh => hzD ⟨hzlo,hh⟩) + have hj := (abs_le.mp (hjump e u z (by rw [heq]; simp) (by rw [heq]; simp))).2 + exact ⟨hzb,by linarith [huD.2],u,hu,by linarith,huD.2,e,he,heq⟩ + +theorem lower_slab_frontier_incident_top_band + (f : V → ℝ) (R m b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (ω : Set E) (J : Set E) (hJ : J ⊆ internalEdges G {v | m ≤ f v}) + (x : V) (hx : m ≤ f x ∧ f x ≤ b) + {u z : V} (hu : u ∈ cluster G + (ω ∩ internalEdges G {v | m ≤ f v ∧ f v ≤ b}) x) + (hz : z ∉ cluster G (ω ∩ internalEdges G {v | m ≤ f v ∧ f v ≤ b}) x) + {e : E} (he : e ∈ ω ∩ J) (heq : G e = s(u,z)) : + b-R ≤ f u ∧ f u ≤ b := by + have huD := conn_internalEdges_end_mem G ω _ hx hu + have hzD := openFrontier_lowerCluster_outside G ω + {v | m ≤ f v ∧ f v ≤ b} x hx ⟨hz,u,hu,e,he.1,heq⟩ + have hzlo : m ≤ f z := hJ he.2 z (by rw [heq]; simp) + have hzb : b < f z := lt_of_not_ge (fun hh => hzD ⟨hzlo,hh⟩) + have hj := (abs_le.mp (hjump e u z (by rw [heq]; simp) (by rw [heq]; simp))).2 + exact ⟨by linarith,huD.2⟩ + +variable [Countable V] [Countable E] + +theorem restrictedLayerCount_fractional_increment + (q : E → unitInterval) (I J : Set E) (A : Set V) (x : V) + {s : ℝ} (hs : 0 < s) (hs1 : s ≤ 1) : + (∫⁻ ω, restrictedLayerCount G J A ω x^s + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (∫⁻ ω, restrictedLayerCount G I A ω x^s + ∂CriticalPercolation.BernoulliProduct.law q) + + (∫⁻ ω, newLayerCount G I J A ω x^s + ∂CriticalPercolation.BernoulliProduct.law q) := by + calc + _ ≤ ∫⁻ ω, restrictedLayerCount G I A ω x^s + newLayerCount G I J A ω x^s + ∂CriticalPercolation.BernoulliProduct.law q := by + apply lintegral_mono + intro ω + exact (ENNReal.rpow_le_rpow (restrictedLayerCount_le_old_add_new G I J A ω x) hs.le).trans + (ENNReal.rpow_add_le_add_rpow _ _ hs.le hs1) + _ = _ := lintegral_add_left ((measurable_restrictedLayerCount G I A x).pow_const s) _ + +theorem lower_slab_newLayer_fractional_bound + (hloc : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hloc u).toFinset.card ≤ d) + (q : E → unitInterval) (f : V → ℝ) (R m b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (J : Set E) (hJ : J ⊆ internalEdges G {v | m ≤ f v}) + (x : V) (hx : m ≤ f x ∧ f x ≤ b) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ internalEdges G {v | m ≤ f v ∧ f v ≤ b}) x).Finite) + (A : Set V) {a c : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) + (hc : 0 < c) (hc1 : c ≤ 1) (L : ℝ≥0∞) + (hL : ∀ z, b < f z → f z ≤ b+R → + (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, newLayerCount G (internalEdges G {v | m ≤ f v ∧ f v ≤ b}) J A ω x^(a*c) + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (d : ℝ≥0∞)^c * (∫⁻ ω, + restrictedLayerCount G (internalEdges G {v | m ≤ f v ∧ f v ≤ b}) + {u | b-R ≤ f u ∧ f u ≤ b} ω x^c + ∂CriticalPercolation.BernoulliProduct.law q)*L^c := by + let I := internalEdges G {v | m ≤ f v ∧ f v ≤ b} + let B := {u | b-R ≤ f u ∧ f u ≤ b} + have hfront : (∫⁻ ω, frontierCount G I J ω x^c + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (d : ℝ≥0∞)^c * ∫⁻ ω, restrictedLayerCount G I B ω x^c + ∂CriticalPercolation.BernoulliProduct.law q := by + calc + _ ≤ ∫⁻ ω, ((d : ℝ≥0∞)*restrictedLayerCount G I B ω x)^c + ∂CriticalPercolation.BernoulliProduct.law q := by + apply lintegral_mono_ae + filter_upwards [hfin] with ω hω + apply ENNReal.rpow_le_rpow _ hc.le + exact frontierCount_le_boundary_layer G hloc d hd I J ω x B hω + (fun _ hu _ hz _ he heq => + lower_slab_frontier_incident_top_band G f R m b hjump ω J hJ x hx hu hz he heq) + _ = _ := by + simp_rw [ENNReal.mul_rpow_of_nonneg _ _ hc.le] + exact lintegral_const_mul _ ((measurable_restrictedLayerCount G I B x).pow_const c) + have hnew := newLayerCount_fractional_bound_on_frontier G hloc q I J x hfin A + ha ha1 hc hc1 L {z | b < f z ∧ f z ≤ b+R} + (fun ω z hz => (lower_slab_frontier_location G f R m b hjump ω J hJ x hx hz).imp_right + (fun hh => hh.1)) + (fun z hz => hL z hz.1 hz.2) + exact hnew.trans (mul_le_mul' hfront le_rfl) + +theorem lower_slab_fractional_recurrence + (hloc : LocallyFinite G) (d : ℕ) + (hd : ∀ u, (finite_neighbors hloc u).toFinset.card ≤ d) + (q : E → unitInterval) (f : V → ℝ) (R m b : ℝ) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (J : Set E) (hJ : J ⊆ internalEdges G {v | m ≤ f v}) + (x : V) (hx : m ≤ f x ∧ f x ≤ b) + (hfin : ∀ᵐ ω ∂CriticalPercolation.BernoulliProduct.law q, + (cluster G (ω ∩ internalEdges G {v | m ≤ f v ∧ f v ≤ b}) x).Finite) + (A : Set V) {a c : ℝ} (ha : 0 < a) (ha1 : a ≤ 1) + (hc : 0 < c) (hc1 : c ≤ 1) (L : ℝ≥0∞) + (hL : ∀ z, b < f z → f z ≤ b+R → + (∫⁻ ω, restrictedLayerCount G J A ω z^a + ∂CriticalPercolation.BernoulliProduct.law q) ≤ L) : + (∫⁻ ω, restrictedLayerCount G J A ω x^(a*c) + ∂CriticalPercolation.BernoulliProduct.law q) ≤ + (∫⁻ ω, restrictedLayerCount G (internalEdges G {v | m ≤ f v ∧ f v ≤ b}) A ω x^(a*c) + ∂CriticalPercolation.BernoulliProduct.law q) + + (d : ℝ≥0∞)^c * (∫⁻ ω, + restrictedLayerCount G (internalEdges G {v | m ≤ f v ∧ f v ≤ b}) + {u | b-R ≤ f u ∧ f u ≤ b} ω x^c + ∂CriticalPercolation.BernoulliProduct.law q)*L^c := by + have hac : a*c ≤ 1 := by + calc a*c ≤ a*1 := mul_le_mul_of_nonneg_left hc1 ha.le + _ ≤ 1 := by simpa only [mul_one] using ha1 + exact (restrictedLayerCount_fractional_increment G q _ J A x (mul_pos ha hc) hac).trans + (add_le_add le_rfl (lower_slab_newLayer_fractional_bound G hloc d hd q f R m b + hjump J hJ x hx hfin A ha ha1 hc hc1 L hL)) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabHit.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabHit.lean new file mode 100644 index 0000000000000000000000000000000000000000..85c9a72d816ce416d4c6039444780877e0181c18 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabHit.lean @@ -0,0 +1,49 @@ +import OAI.Probability.BenjaminiSchramm.SlabCrossing +import OAI.Probability.BenjaminiSchramm.EventLeftContinuity + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +def modularSlabHit (o : V) (a b c : ℝ) : Set (Set E) := + {ω | ∃ y, Percolation.Conn G.ends + (ω ∩ Percolation.internalEdges G.ends (G.modularSlab o a c)) o y ∧ + b ≤ G.modularLogHeight o y} + +lemma modularSlabHit_upper (o : V) (a b c : ℝ) : IsUpperSet (G.modularSlabHit o a b c) := by + rintro ω η hωη ⟨y,hxy,hy⟩ + exact ⟨y,Percolation.conn_mono G.ends (Set.inter_subset_inter_left _ hωη) hxy,hy⟩ + +lemma modularSlabHit_finiteWitness (o : V) (a b c : ℝ) : + Percolation.FiniteWitness (G.modularSlabHit o a b c) := by + rintro ω ⟨y,hxy,hy⟩ + obtain ⟨s,hs,hconn⟩ := Percolation.finiteWitness_conn G.ends o y _ hxy + refine ⟨s,fun _ he => (hs he).1,y,?_,hy⟩ + have hsub : (s : Set E) ⊆ (s : Set E) ∩ + Percolation.internalEdges G.ends (G.modularSlab o a c) := fun _ he => ⟨he,(hs he).2⟩ + exact Percolation.conn_mono G.ends hsub hconn + +lemma measurableSet_modularSlabHit [Countable E] (o : V) (a b c : ℝ) : + MeasurableSet (G.modularSlabHit o a b c) := + Percolation.measurableSet_finiteWitness _ (G.modularSlabHit_upper o a b c) + (G.modularSlabHit_finiteWitness o a b c) + +theorem modularSlabHit_left_tendsto [Countable E] (o : V) (a b c : ℝ) + (p : unitInterval) (q : ℕ → unitInterval) (hmono : Monotone q) + (hqp : ∀ n, q n ≤ p) (hq : Tendsto q atTop (𝓝 p)) : + Tendsto (fun n => G.law (q n) (G.modularSlabHit o a b c)) atTop + (𝓝 (G.law p (G.modularSlabHit o a b c))) := + law_finiteWitness_left_tendsto _ (G.modularSlabHit_upper o a b c) + (G.modularSlabHit_finiteWitness o a b c) p q hmono hqp hq + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabLastMaximum.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabLastMaximum.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3afa0a7790068220836b4c4871bc59922597332 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabLastMaximum.lean @@ -0,0 +1,120 @@ +import OAI.Probability.BenjaminiSchramm.SlabFirstVisit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma restricted_connection_measure_symm (I : Set E) (p : unitInterval) (x y : V) : + law p {ω | Conn G (ω ∩ I) x y} = law p {ω | Conn G (ω ∩ I) y x} := by + congr 1 + ext ω + exact ⟨conn_symm G _,conn_symm G _⟩ + +theorem last_height_connection_bound [Countable V] [Countable E] + (f : V → ℝ) (R b : ℝ) (hR : 0 ≤ R) + (hjump : ∀ e u v, u ∈ G e → v ∈ G e → |f v-f u| ≤ R) + (I : Set E) (p : unitInterval) (x y : V) (hx : f x ≤ b) (hy : b < f y) : + law p {ω | Conn G (ω ∩ I) x y} ≤ + ∑' z, if b-R ≤ f z ∧ f z ≤ b then + law p {ω | Conn G (ω ∩ I) x z} * + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | b-R ≤ f v})) z y} else 0 := by + rw [restricted_connection_measure_symm G I p x y] + have hj : ∀ e u v, u ∈ G e → v ∈ G e → |(-f v)-(-f u)| ≤ R := by + intro e u v hu hv + simpa only [neg_sub_neg,abs_sub_comm] using hjump e u v hu hv + have hh := first_height_connection_bound G (fun v => -f v) R (-b) hR hj I p y x + (neg_lt_neg hy) (neg_le_neg hx) + refine hh.trans_eq (tsum_congr fun z => ?_) + have hband : (-b ≤ -f z ∧ -f z ≤ -b+R) ↔ (b-R ≤ f z ∧ f z ≤ b) := by + constructor <;> rintro ⟨h₁,h₂⟩ <;> constructor <;> linarith + have hD : {v : V | -f v ≤ -b+R} = {v | b-R ≤ f v} := by + ext v + change (-f v ≤ -b+R) ↔ (b-R ≤ f v) + constructor <;> intro h <;> linarith + rw [hD] + by_cases hz : b-R ≤ f z ∧ f z ≤ b + · rw [ite_eq_left (hband.mpr hz),ite_eq_left hz, + restricted_connection_measure_symm G _ p y z,restricted_connection_measure_symm G I p z x, + mul_comm] + · rw [ite_eq_right (fun h => hz (hband.mp h)),ite_eq_right hz] + +lemma conn_max_height_disjoint (f : V → ℝ) (I : Set E) (ω : Set E) + (x y : V) (hconn : Conn G (ω ∩ I) x y) : + ∃ z, f x ≤ f z ∧ f y ≤ f z ∧ ω ∈ DisjointOccurrence + {η | Conn G (η ∩ (I ∩ internalEdges G {v | f v ≤ f z})) x z} + {η | Conn G (η ∩ (I ∩ internalEdges G {v | f v ≤ f z})) z y} := by + obtain ⟨p₀⟩ := (conn_iff_reachable G (ω ∩ I) x y).mp hconn + let p := p₀.toPath.val + obtain ⟨z,hz,hmax⟩ := Finset.exists_max_image p.support.toFinset f + ⟨x,List.mem_toFinset.mpr p.start_mem_support⟩ + have hzp : z ∈ p.support := List.mem_toFinset.mp hz + have hu (v : V) (hv : v ∈ p.support) : f v ≤ f z := hmax v (List.mem_toFinset.mpr hv) + obtain ⟨a,ha,hea,hoa⟩ := walk_lift_bonds G (ω ∩ I) (p.takeUntil z hzp) + obtain ⟨c,hc,hec,hoc⟩ := walk_lift_bonds G (ω ∩ I) (p.dropUntil z hzp) + have haI : (a.toFinset : Set E) ⊆ I ∩ internalEdges G {v | f v ≤ f z} := by + intro e he + refine ⟨(hoa e (List.mem_toFinset.mp he)).2,fun v hv => ?_⟩ + have hGe : G e ∈ (p.takeUntil z hzp).edges := hea ▸ List.mem_map_of_mem (List.mem_toFinset.mp he) + exact hu v (p.support_takeUntil_subset_support hzp (SimpleGraph.Walk.mem_support_of_mem_edges hGe hv)) + have hcI : (c.toFinset : Set E) ⊆ I ∩ internalEdges G {v | f v ≤ f z} := by + intro e he + refine ⟨(hoc e (List.mem_toFinset.mp he)).2,fun v hv => ?_⟩ + have hGe : G e ∈ (p.dropUntil z hzp).edges := hec ▸ List.mem_map_of_mem (List.mem_toFinset.mp he) + exact hu v (p.support_dropUntil_subset_support hzp (SimpleGraph.Walk.mem_support_of_mem_edges hGe hv)) + refine ⟨z,hu x p.start_mem_support,hu y p.end_mem_support,a.toFinset,c.toFinset,?_,?_,?_,?_,?_⟩ + · intro e he + exact (hoa e (List.mem_toFinset.mp he)).1 + · intro e he + exact (hoc e (List.mem_toFinset.mp he)).1 + · apply Finset.disjoint_left.mpr + intro e heA heC + exact List.disjoint_left.mp (p₀.toPath.property.isTrail.disjoint_edges_takeUntil_dropUntil hzp) + (hea ▸ List.mem_map_of_mem (List.mem_toFinset.mp heA)) + (hec ▸ List.mem_map_of_mem (List.mem_toFinset.mp heC)) + · have hh := ha.conn (fun e he => List.mem_toFinset.mpr he) + have hsub : (a.toFinset : Set E) ⊆ (a.toFinset : Set E) ∩ + (I ∩ internalEdges G {v | f v ≤ f z}) := fun e he => ⟨he,haI he⟩ + exact conn_mono G hsub hh + · have hh := hc.conn (fun e he => List.mem_toFinset.mpr he) + have hsub : (c.toFinset : Set E) ⊆ (c.toFinset : Set E) ∩ + (I ∩ internalEdges G {v | f v ≤ f z}) := fun e he => ⟨he,hcI he⟩ + exact conn_mono G hsub hh + +theorem max_height_connection_bound [Countable V] [Countable E] + (f : V → ℝ) (I : Set E) (p : unitInterval) (x y : V) : + law p {ω | Conn G (ω ∩ I) x y} ≤ + ∑' z, if f x ≤ f z ∧ f y ≤ f z then + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ f z})) x z} * + law p {ω | Conn G (ω ∩ (I ∩ internalEdges G {v | f v ≤ f z})) z y} else 0 := by + let J (z : V) := I ∩ internalEdges G {v | f v ≤ f z} + let C := fun z => if f x ≤ f z ∧ f y ≤ f z then + DisjointOccurrence {ω | Conn G (ω ∩ J z) x z} {ω | Conn G (ω ∩ J z) z y} else ∅ + have hsub : {ω | Conn G (ω ∩ I) x y} ⊆ ⋃ z, C z := by + intro ω hω + obtain ⟨z,hzx,hzy,hd⟩ := conn_max_height_disjoint G f I ω x y hω + have hband : f x ≤ f z ∧ f y ≤ f z := ⟨hzx,hzy⟩ + exact Set.mem_iUnion.mpr ⟨z,by simpa only [C,ite_eq_left hband] using hd⟩ + calc + _ ≤ law p (⋃ z, C z) := measure_mono hsub + _ ≤ ∑' z, law p (C z) := measure_iUnion_le _ + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f x ≤ f z ∧ f y ≤ f z + · simp only [C,ite_eq_left hz] + exact bk_ennreal p _ _ + (fun _ _ h hconn => conn_mono G (Set.inter_subset_inter_left _ h) hconn) + (fun _ _ h hconn => conn_mono G (Set.inter_subset_inter_left _ h) hconn) + (finiteWitness_conn_restricted G (J z) x z) (finiteWitness_conn_restricted G (J z) z y) + · simp only [C,ite_eq_right hz,measure_empty,le_refl] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabRootShift.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabRootShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..878a3b814959311006fb6e6aa7fae7efba07a50f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabRootShift.lean @@ -0,0 +1,71 @@ +import OAI.Probability.BenjaminiSchramm.FirstHeightPeakWalk +import OAI.Probability.BenjaminiSchramm.FiniteEnergyObservable + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem fractional_slab_root_ascent + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (p : unitInterval) (k r c B : ℝ) (hk : 0 ≤ k) (hr : 0 ≤ r) + {x y : V} (w : G.fullGraph.Walk x y) + (hcy : c ≤ G.orbitAdjustedHeight a x y) + (hw : ∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight a x v ∧ + G.orbitAdjustedHeight a x v ≤ G.orbitAdjustedHeight a x y) + {q : ℝ} (hq : 0 ≤ q) : + ENNReal.ofReal ((min (p : ℝ) (1-p))^w.length)* + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {z | -k-r ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) + {z | -k-B ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ -k+B} ω x)^q ∂G.law p) ≤ + ∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {z | -(k+G.orbitAdjustedHeight a x y)-r ≤ G.orbitAdjustedHeight a y z ∧ + G.orbitAdjustedHeight a y z ≤ 0}) + {z | -(k+G.orbitAdjustedHeight a x y)-B ≤ G.orbitAdjustedHeight a y z ∧ + G.orbitAdjustedHeight a y z ≤ -(k+G.orbitAdjustedHeight a x y)+B} ω y)^q ∂G.law p := by + let h := G.orbitAdjustedHeight a x y + let I := Percolation.internalEdges G.ends {z | -k-r ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c} + let J := Percolation.internalEdges G.ends {z | -(k+h)-r ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ 0} + let W : Set V := {z | -k-B ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ -k+B} + let Z : Set V := {z | -(k+h)-B ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ -(k+h)+B} + have hIJ : I ⊆ J := Percolation.internalEdges_mono G.ends (by + intro z hz + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + exact ⟨by dsimp [h]; linarith [hz.1],by linarith [hz.2]⟩) + have hWZ : W ⊆ Z := by + intro z hz + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + exact ⟨by dsimp [h]; linarith [hz.1],by dsimp [h]; linarith [hz.2]⟩ + let f : G.fullGraph →g Percolation.openSimpleGraph G.ends Set.univ := + ⟨id,fun {_ _} h => by + rw [←criticalModel_openGraph G.ends Set.univ] + exact h⟩ + obtain ⟨F,hF,hconn⟩ := walk_finite_open_restriction G.ends (w.reverse.map f) + {z | -(k+h)-r ≤ G.orbitAdjustedHeight a y z ∧ G.orbitAdjustedHeight a y z ≤ 0} (by + intro z hz + have hz' : z ∈ w.support := by + rw [SimpleGraph.Walk.support_map] at hz + change z ∈ w.reverse.support.map id at hz + simpa only [List.map_id_fun,id_eq,SimpleGraph.Walk.support_reverse,List.mem_reverse] using hz + have hh := G.orbitAdjustedHeight_change_base hc hl a x y z + exact ⟨by dsimp [h]; linarith [(hw z hz').1],by linarith [(hw z hz').2]⟩) + have hlen : F.card ≤ w.length := by + simpa only [SimpleGraph.Walk.length_map,SimpleGraph.Walk.length_reverse] using hF + have hcost : ENNReal.ofReal ((min (p : ℝ) (1-p))^w.length) ≤ + ENNReal.ofReal ((min (p : ℝ) (1-p))^F.card) := by + apply ENNReal.ofReal_le_ofReal + exact pow_le_pow_of_le_one (le_min p.2.1 (sub_nonneg.mpr p.2.2)) + ((min_le_left _ _).trans p.2.2) hlen + exact (mul_le_mul' hcost le_rfl).trans + (forced_path_fractional_layer_comparison G.ends p F I J W Z hIJ hWZ y x hconn hq) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SlabSecondMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/SlabSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..4bf60299092dc54fb0d33e342a347e346b801546 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SlabSecondMoment.lean @@ -0,0 +1,186 @@ +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry +import OAI.Probability.UnimodularPercolation.Clusters.KernelMoments + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma disjointOccurrence_restrict (I : Set E) (A B : Set (Set E)) : + (fun ω : Set E => ω ∩ I) ⁻¹' DisjointOccurrence A B ⊆ + DisjointOccurrence ((fun ω : Set E => ω ∩ I) ⁻¹' A) + ((fun ω : Set E => ω ∩ I) ⁻¹' B) := by + rintro ω ⟨s,t,hs,ht,hd,ha,hb⟩ + have hsI : (s : Set E) ⊆ I := fun e he => (hs he).2 + have htI : (t : Set E) ⊆ I := fun e he => (ht he).2 + refine ⟨s,t,fun e he => (hs he).1,fun e he => (ht he).1,hd,?_,?_⟩ + · change (s : Set E) ∩ I ∈ A + rwa [Set.inter_eq_self_of_subset_left hsI] + · change (t : Set E) ∩ I ∈ B + rwa [Set.inter_eq_self_of_subset_left htI] + +lemma conn_restricted_three_disjoint_arms (I : Set E) (ω : Set E) (x y z : V) + (hxy : Conn G (ω ∩ I) x y) (hxz : Conn G (ω ∩ I) x z) : + ∃ w, ω ∈ DisjointOccurrence {η | Conn G (η ∩ I) x w} + (DisjointOccurrence {η | Conn G (η ∩ I) w y} {η | Conn G (η ∩ I) w z}) := by + obtain ⟨w,hw⟩ := conn_three_disjoint_arms G (ω ∩ I) x y z hxy hxz + refine ⟨w,?_⟩ + have hh := disjointOccurrence_restrict I {η | Conn G η x w} + (DisjointOccurrence {η | Conn G η w y} {η | Conn G η w z}) hw + exact disjointOccurrence_mono (Set.Subset.refl _) + (disjointOccurrence_restrict I _ _) hh + +lemma finiteWitness_conn_restricted (I : Set E) (x y : V) : + FiniteWitness {ω | Conn G (ω ∩ I) x y} := by + intro ω hω + obtain ⟨s,hs,hconn⟩ := finiteWitness_conn G x y (ω ∩ I) hω + refine ⟨s,fun e he => (hs he).1,?_⟩ + have hsub : (s : Set E) ⊆ (s : Set E) ∩ I := fun e he => ⟨he,(hs he).2⟩ + exact conn_mono G hsub hconn + +lemma restricted_three_arm_bound [Countable V] [Countable E] + (I : Set E) (p : unitInterval) (x y z : V) : + law p {ω | Conn G (ω ∩ I) x y ∧ Conn G (ω ∩ I) x z} ≤ + ∑' w, law p {ω | Conn G (ω ∩ I) x w} * + law p {ω | Conn G (ω ∩ I) w y} * law p {ω | Conn G (ω ∩ I) w z} := by + let C := fun a b : V => {ω : Set E | Conn G (ω ∩ I) a b} + have hup (a b : V) : IsUpperSet (C a b) := + fun _ _ h hconn => conn_mono G (Set.inter_subset_inter_left _ h) hconn + have hf (a b : V) : FiniteWitness (C a b) := finiteWitness_conn_restricted G I a b + have hb (w : V) : law p (DisjointOccurrence (C x w) (DisjointOccurrence (C w y) (C w z))) ≤ + law p (C x w)*law p (C w y)*law p (C w z) := by + calc + _ ≤ law p (C x w)*law p (DisjointOccurrence (C w y) (C w z)) := + bk_ennreal p _ _ (hup x w) (disjointOccurrence_upper _ _) (hf x w) + (finiteWitness_disjointOccurrence _ _) + _ ≤ law p (C x w)*(law p (C w y)*law p (C w z)) := + mul_le_mul' le_rfl (bk_ennreal p _ _ (hup w y) (hup w z) (hf w y) (hf w z)) + _ = _ := (mul_assoc _ _ _).symm + calc + _ ≤ law p (⋃ w, DisjointOccurrence (C x w) (DisjointOccurrence (C w y) (C w z))) := by + apply measure_mono + intro ω hω + obtain ⟨w,hw⟩ := conn_restricted_three_disjoint_arms G I ω x y z hω.1 hω.2 + exact Set.mem_iUnion.mpr ⟨w,hw⟩ + _ ≤ ∑' w, law p (DisjointOccurrence (C x w) (DisjointOccurrence (C w y) (C w z))) := + measure_iUnion_le _ + _ ≤ _ := ENNReal.tsum_le_tsum hb + +lemma lintegral_restrictedLayerCount [Countable V] [Countable E] + (I : Set E) (A : Set V) (p : unitInterval) (x : V) : + (∫⁻ ω, restrictedLayerCount G I A ω x ∂law p) = + ∑' y, if y ∈ A then law p {ω | Conn G (ω ∩ I) x y} else 0 := by + unfold restrictedLayerCount + have hm (y : V) : Measurable (fun ω : Set E => + if y ∈ A ∧ Conn G (ω ∩ I) x y then (1 : ℝ≥0∞) else 0) := by + have hi : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + exact Measurable.ite (measurable_const.and + ((measurableSet_conn G x y).mem.comp hi)).setOf measurable_const measurable_const + rw [lintegral_tsum (fun y => (hm y).aemeasurable)] + apply tsum_congr + intro y + by_cases hy : y ∈ A + · simp only [hy,true_and,ite_true] + have hi : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + have hset : MeasurableSet {ω : Set E | Conn G (ω ∩ I) x y} := + (measurableSet_conn G x y).preimage hi + simpa only [Set.indicator,Pi.one_apply,Set.mem_ofPred_eq] using + lintegral_indicator_one (μ := law p) hset + · simp only [hy,false_and,ite_false,lintegral_zero] + +lemma restrictedLayerCount_mul (I : Set E) (A B : Set V) (ω : Set E) (x : V) : + restrictedLayerCount G I A ω x * restrictedLayerCount G I B ω x = + ∑' y, ∑' z, if y ∈ A ∧ z ∈ B ∧ Conn G (ω ∩ I) x y ∧ + Conn G (ω ∩ I) x z then (1 : ℝ≥0∞) else 0 := by + unfold restrictedLayerCount + rw [←ENNReal.tsum_mul_right] + apply tsum_congr + intro y + rw [←ENNReal.tsum_mul_left] + apply tsum_congr + intro z + split_ifs <;> simp_all + +lemma lintegral_restrictedLayerCount_mul [Countable V] [Countable E] + (I : Set E) (A B : Set V) (p : unitInterval) (x : V) : + (∫⁻ ω, restrictedLayerCount G I A ω x*restrictedLayerCount G I B ω x ∂law p) = + ∑' y, ∑' z, if y ∈ A ∧ z ∈ B then law p + {ω | Conn G (ω ∩ I) x y ∧ Conn G (ω ∩ I) x z} else 0 := by + have hi : Measurable (fun ω : Set E => ω ∩ I) := + measurable_set_iff.mpr fun e => (measurable_set_mem e).and measurable_const + have hset (y z : V) : MeasurableSet + {ω : Set E | Conn G (ω ∩ I) x y ∧ Conn G (ω ∩ I) x z} := + ((measurableSet_conn G x y).preimage hi).inter ((measurableSet_conn G x z).preimage hi) + have hm (y z : V) : Measurable (fun ω : Set E => + if y ∈ A ∧ z ∈ B ∧ Conn G (ω ∩ I) x y ∧ Conn G (ω ∩ I) x z + then (1 : ℝ≥0∞) else 0) := by + by_cases h : y ∈ A ∧ z ∈ B + · simpa only [←and_assoc,h,true_and] using + Measurable.ite (hset y z) measurable_const measurable_const + · have he : (fun ω : Set E => if y ∈ A ∧ z ∈ B ∧ Conn G (ω ∩ I) x y ∧ + Conn G (ω ∩ I) x z then (1 : ℝ≥0∞) else 0) = fun _ => 0 := by + funext ω + exact ite_eq_right (by tauto) + rw [he] + exact measurable_const + simp_rw [restrictedLayerCount_mul] + rw [lintegral_tsum (fun y => (Measurable.tsum (hm y)).aemeasurable)] + apply tsum_congr + intro y + rw [lintegral_tsum (fun z => (hm y z).aemeasurable)] + apply tsum_congr + intro z + by_cases h : y ∈ A ∧ z ∈ B + · simp only [←and_assoc,h,true_and,ite_true] + simpa only [Set.indicator,Pi.one_apply,Set.mem_ofPred_eq] using + lintegral_indicator_one (μ := law p) (hset y z) + · simp only [ite_eq_right h] + have he : (fun ω : Set E => if y ∈ A ∧ z ∈ B ∧ Conn G (ω ∩ I) x y ∧ + Conn G (ω ∩ I) x z then (1 : ℝ≥0∞) else 0) = fun _ => 0 := by + funext ω + exact ite_eq_right (by tauto) + rw [he,lintegral_zero] + +theorem restricted_layer_second_moment [Countable V] [Countable E] + (I : Set E) (A B : Set V) (p : unitInterval) (x : V) : + (∫⁻ ω, restrictedLayerCount G I A ω x*restrictedLayerCount G I B ω x ∂law p) ≤ + ∑' w, law p {ω | Conn G (ω ∩ I) x w} * + (∫⁻ ω, restrictedLayerCount G I A ω w ∂law p) * + (∫⁻ ω, restrictedLayerCount G I B ω w ∂law p) := by + simp_rw [lintegral_restrictedLayerCount_mul,lintegral_restrictedLayerCount] + calc + _ ≤ ∑' y, ∑' z, ∑' w, law p {ω | Conn G (ω ∩ I) x w} * + (if y ∈ A then law p {ω | Conn G (ω ∩ I) w y} else 0) * + (if z ∈ B then law p {ω | Conn G (ω ∩ I) w z} else 0) := by + apply ENNReal.tsum_le_tsum + intro y + apply ENNReal.tsum_le_tsum + intro z + by_cases h : y ∈ A ∧ z ∈ B + · simp only [ite_eq_left h,ite_eq_left h.1,ite_eq_left h.2] + exact restricted_three_arm_bound G I p x y z + · simp only [ite_eq_right h] + exact bot_le + _ = ∑' w, ∑' y, ∑' z, law p {ω | Conn G (ω ∩ I) x w} * + (if y ∈ A then law p {ω | Conn G (ω ∩ I) w y} else 0) * + (if z ∈ B then law p {ω | Conn G (ω ∩ I) w z} else 0) := by + rw [show (∑' y, ∑' z, ∑' w, law p {ω | Conn G (ω ∩ I) x w} * + (if y ∈ A then law p {ω | Conn G (ω ∩ I) w y} else 0) * + (if z ∈ B then law p {ω | Conn G (ω ∩ I) w z} else 0)) = + ∑' y, ∑' w, ∑' z, law p {ω | Conn G (ω ∩ I) x w} * + (if y ∈ A then law p {ω | Conn G (ω ∩ I) w y} else 0) * + (if z ∈ B then law p {ω | Conn G (ω ∩ I) w z} else 0) from + tsum_congr (fun _ => ENNReal.tsum_comm),ENNReal.tsum_comm] + _ = _ := by simp_rw [ENNReal.tsum_mul_left,ENNReal.tsum_mul_right,ENNReal.tsum_mul_left] + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SmallWalkKernel.lean b/lean/OAI/Probability/BenjaminiSchramm/SmallWalkKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..505fcaac295cf74be417a0683f12ef275125494f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SmallWalkKernel.lean @@ -0,0 +1,49 @@ +import OAI.Probability.BenjaminiSchramm.KernelExteriorBound + +namespace OAI + +open Filter +open scoped ENNReal Topology + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem exists_small_walk_kernel (G : BondGraph V E) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (ε : ℝ) (hε : 0 < ε) : + ∃ (d M : ℕ) (K : Hilbert V →L[ℂ] Hilbert V), + (∀ a, degree G a ≤ d) ∧ PositiveRealMatrix K ∧ ‖K‖ < ε ∧ + (∀ a, ∑' b, ennMatrixCoeff K a b = 1) ∧ + (∀ a b, b ∉ reachBall G a M → ennMatrixCoeff K a b = 0) := by + obtain ⟨d,P,hd,hdeg,hPn,_,hP⟩ := exists_strict_walk_operator G hloc hqt hh + have hdr : (0 : ℝ) < d := by exact_mod_cast hd + have ha : 0 ≤ (1 : ℝ)/(2*d) := by positivity + have had : (1 : ℝ)/(2*d)*d ≤ 1 := by + rw [div_mul_eq_mul_div] + apply (div_le_iff₀ (by positivity : 0 < 2*(d : ℝ))).mpr + nlinarith + have hpos : PositiveRealMatrix P := by + intro a b + change (P (lp.single 2 b (1 : ℂ)) a).im = 0 ∧ + 0 ≤ (P (lp.single 2 b (1 : ℂ)) a).re + rw [hP] + exact ⟨Complex.ofReal_im _,walkKernel_nonneg G hloc d hdeg _ ha had a b⟩ + have ht := tendsto_pow_atTop_nhds_zero_of_lt_one (norm_nonneg P) hPn + obtain ⟨M,hM,hMp⟩ := Filter.Eventually.exists + ((ht.eventually (gt_mem_nhds hε)).and (eventually_ge_atTop 1)) + refine ⟨d,M,P^M,hdeg,hpos.pow M, + (norm_pow_le' P (Nat.zero_lt_of_lt hMp)).trans_lt hM,?_,?_⟩ + · intro a + change (∑' b, ENNReal.ofReal (matrixCoeff (P^M) a b).re) = 1 + rw [←ENNReal.ofReal_tsum_of_nonneg (fun b => ((hpos.pow M) a b).2) + (walkPower_hasSum G hloc _ P hpos hP M a).summable, + (walkPower_hasSum G hloc _ P hpos hP M a).tsum_eq,ENNReal.ofReal_one] + · intro a b hb + change ENNReal.ofReal (matrixCoeff (P^M) a b).re = 0 + rw [walkPower_support G hloc _ P hpos hP M a b hb,ENNReal.ofReal_zero] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SmallWitness.lean b/lean/OAI/Probability/BenjaminiSchramm/SmallWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..86889ea86283441dd8a0bef606ba796351aa3698 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SmallWitness.lean @@ -0,0 +1,80 @@ +import OAI.Probability.UnimodularPercolation.Exploration.Marked +import OAI.Probability.UnimodularPercolation.Criticality.Susceptibility + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe v +variable {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem small_witness_derivative_bound (Q : Finset E) (A : Finset E → Prop) + (hmono : ∀ ω η, ω ⊆ η → A ω → A η) (r : ℕ) + (hcert : ∀ ω ⊆ Q, A ω → ∃ s ⊆ ω, s.card ≤ r ∧ ∀ η, s ⊆ η → A η) + (p : ℝ) (hp : p ∈ Set.Icc (0 : ℝ) 1) : + p * deriv (bernoulliPolynomial Q (fun ω => if A ω then 1 else 0)) p ≤ + (r : ℝ) * bernoulliPolynomial Q (fun ω => if A ω then 1 else 0) p := by + let f : Finset E → ℝ := fun ω => if A ω then 1 else 0 + have hrusso : p * deriv (bernoulliPolynomial Q f) p = + bernoulliPolynomial Q (fun ω => ∑ e ∈ Q, + if e ∈ ω then f ω - f (ω.erase e) else 0) p := by + rw [(hasDerivAt_bernoulliPolynomial Q f p).deriv, Finset.mul_sum, + bernoulliPolynomial_sum] + apply Finset.sum_congr rfl + intro e he + exact (bernoulliPolynomial_open_difference Q e he f p).symm + change p * deriv (bernoulliPolynomial Q f) p ≤ + (r : ℝ) * bernoulliPolynomial Q f p + rw [hrusso, ←bernoulliPolynomial_const_mul] + apply bernoulliPolynomial_mono Q _ _ p hp + intro ω hω + by_cases hA : A ω + · obtain ⟨s,hs,hsr,hsa⟩ := hcert ω hω hA + calc + _ ≤ ∑ e ∈ Q, if e ∈ s then (1 : ℝ) else 0 := by + apply Finset.sum_le_sum + intro e he + by_cases hes : e ∈ s + · by_cases heω : e ∈ ω <;> by_cases herase : A (ω.erase e) <;> + simp [f,hA,hes,heω,herase] + · have herase : A (ω.erase e) := hsa _ (by + intro a ha + exact Finset.mem_erase.mpr ⟨fun hae => hes (hae ▸ ha),hs ha⟩) + simp [f,hA,hes,herase] + _ = ((Q.filter (fun e => e ∈ s)).card : ℝ) := by + rw [Finset.card_filter, Nat.cast_sum] + simp only [Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + _ ≤ (s.card : ℝ) := by + exact_mod_cast Finset.card_le_card (show Q.filter (fun e => e ∈ s) ⊆ s from + fun e he => (Finset.mem_filter.mp he).2) + _ ≤ (r : ℝ) * f ω := by simpa [f,hA] using (show (s.card : ℝ) ≤ r by exact_mod_cast hsr) + · have herase (e : E) : ¬ A (ω.erase e) := fun h => + hA (hmono _ _ (Finset.erase_subset e ω) h) + simp [f,hA,herase] + +theorem small_witness_probability_transfer (Q : Finset E) (A : Finset E → Prop) + (hmono : ∀ ω η, ω ⊆ η → A ω → A η) (r : ℕ) + (hcert : ∀ ω ⊆ Q, A ω → ∃ s ⊆ ω, s.card ≤ r ∧ ∀ η, s ⊆ η → A η) + (p q : unitInterval) (hp : 0 < (p : ℝ)) (hpq : p ≤ q) : + bernoulliPolynomial Q (fun ω => if A ω then 1 else 0) q ≤ + Real.exp ((r : ℝ) / p * ((q : ℝ) - p)) * + bernoulliPolynomial Q (fun ω => if A ω then 1 else 0) p := by + let H := bernoulliPolynomial Q (fun ω => if A ω then (1 : ℝ) else 0) + apply exponential_transfer_of_deriv_bound H p q ((r : ℝ) / p) + (fun t => (hasDerivAt_bernoulliPolynomial Q _ t).differentiableAt) hpq + intro t ht + have ht0 : 0 < t := hp.trans_le ht.1 + have htI : t ∈ Set.Icc (0 : ℝ) 1 := ⟨ht0.le,ht.2.trans q.2.2⟩ + have hb := small_witness_derivative_bound Q A hmono r hcert t htI + have hH : 0 ≤ H t := bernoulliPolynomial_nonneg Q _ t htI (fun ω _ => by split <;> positivity) + calc + deriv H t ≤ (r : ℝ) * H t / t := (le_div_iff₀ ht0).mpr (by simpa only [mul_comm t] using hb) + _ ≤ (r : ℝ) * H t / p := div_le_div_of_nonneg_left (mul_nonneg (Nat.cast_nonneg r) hH) hp ht.1 + _ = _ := by ring + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SprinklingAvoidanceProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/SprinklingAvoidanceProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..84827d173419f635bc0c6480fad7870ce2071f45 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SprinklingAvoidanceProfile.lean @@ -0,0 +1,107 @@ +import OAI.Probability.BenjaminiSchramm.NormalizedEscapeRisk +import OAI.Probability.BenjaminiSchramm.AvoidanceCostProfile +import OAI.Probability.BenjaminiSchramm.PeakSprinklingCell + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal Topology BigOperators + +namespace CriticalPercolation.BondGraph +open BernoulliProduct Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma nonpositive_height_depth (a : V → ℝ) (R : ℝ) (hR : 0 < R) (x u : V) + (hu : G.orbitAdjustedHeight a x u ≤ 0) : + G.adjustedLayerIndex a R 0 x u ≤ 0 ∧ + R*(((-G.adjustedLayerIndex a R 0 x u).toNat-1 : ℕ) : ℝ) ≤ + -G.orbitAdjustedHeight a x u := by + have hf : G.adjustedLayerIndex a R 0 x u ≤ 0 := by + simpa only [adjustedLayerIndex,add_zero,Int.floor_zero,sub_zero] using + (Int.floor_mono (div_nonpos_of_nonpos_of_nonneg hu hR.le)) + refine ⟨hf,?_⟩ + let n := (-G.adjustedLayerIndex a R 0 x u).toNat + change R*((n-1 : ℕ) : ℝ) ≤ -G.orbitAdjustedHeight a x u + by_cases hn : n=0 + · simpa only [hn,Nat.zero_sub,Nat.cast_zero,mul_zero] using neg_nonneg.mpr hu + · have hn1 : 1 ≤ n := by omega + have hd : (n : ℤ)= -G.adjustedLayerIndex a R 0 x u := Int.toNat_of_nonneg (neg_nonneg.mpr hf) + have hheight := (G.adjustedLayerIndex_height_bounds a R 0 hR x u).2 + have he : (G.adjustedLayerIndex a R 0 x u : ℝ)= -(n : ℝ) := by exact_mod_cast (show G.adjustedLayerIndex a R 0 x u= -(n : ℤ) by omega) + change G.orbitAdjustedHeight a x u < R*((G.adjustedLayerIndex a R 0 x u : ℝ)+1) at hheight + rw [he] at hheight + change R*((n-1 : ℕ) : ℝ) ≤ -G.orbitAdjustedHeight a x u + rw [Nat.cast_sub hn1,Nat.cast_one] + nlinarith + +variable [Countable V] [Countable E] + +theorem sprinkling_avoidance_cost_profile + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (O : G.OrbitRepresentatives) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (p q b : unitInterval) (hparam : Percolation.sprinkleParameter q b=p) + (hb0 : 0 < (b : ℝ)) (hb1 : (b : ℝ) < 1) + (R : ℝ) (hR : 0 < R) (d : ℕ) (hd : ∀ x, Percolation.degree G.ends x ≤ d) + (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (G.cluster ω x).Finite) : + ∃ g : ℕ → ℝ, (∀ l, 0 ≤ g l) ∧ (∃ C : ℝ, ∀ l, g l ≤ C) ∧ + Tendsto g atTop (𝓝 0) ∧ ∀ (x : V) (S : Finset V) (u : V), u ∈ S → + G.orbitAdjustedHeight a x u ≤ 0 → + Real.exp (-g (-G.adjustedLayerIndex a R 0 x u).toNat) ≤ + (BernoulliProduct.law (fun e => Percolation.sprinkleParameter + (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e) b)).real + (exteriorEscape G.ends (S : Set V) (G.orbitAdjustedHeight a x) x u)ᶜ := by + let h : ℕ → ℝ := fun n => G.rootHeightHitProfile O a R p (n-1) + have hh : ∀ n, 0 ≤ h n := fun n => G.rootHeightHitProfile_nonneg O a R p (n-1) + have hlim : Tendsto h atTop (𝓝 0) := + (G.rootHeightHitProfile_tendsto_zero O a p R hR hfin).comp (tendsto_sub_atTop_nat 1) + let t : ℝ := min (b : ℝ) (1-b) + have ht : 0 < t := lt_min hb0 (sub_pos.mpr hb1) + have ht1 : t ≤ 1 := (min_le_left _ _).trans b.2.2 + let κ : ℝ := t^d + have hκ : 0 < κ := pow_pos ht _ + have hκ1 : κ ≤ 1 := pow_le_one₀ ht.le ht1 + obtain ⟨g,hg,hgb,hglim,havoid⟩ := exists_vanishing_avoidance_cost h hh O.roots.card + (fun n => G.rootHeightHitProfile_le_card O a R p (n-1)) hlim κ hκ hκ1 + refine ⟨g,hg,hgb,hglim,?_⟩ + intro x S u hu hxu + let r : E → unitInterval := fun e => Percolation.sprinkleParameter + (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e) b + let F := Percolation.incidentSupport G.ends hl {u} + have hF (e : E) (he : u ∈ G.ends e) : e ∈ F := + (Percolation.mem_incidentSupport G.ends hl {u} e).mpr ⟨u,Finset.mem_singleton_self u,he⟩ + have hFe (e : E) (he : e ∈ F) : r e=b := by + obtain ⟨v,hv,hve⟩ := (Percolation.mem_incidentSupport G.ends hl {u} e).mp he + have hvu : v=u := Finset.mem_singleton.mp hv + have heQ : e ∈ G.incidentEdges (S : Set V) := ⟨v,hvu ▸ hu,hve⟩ + apply Subtype.ext + simp only [r,erasedWhiteParameters,ite_eq_left heQ,Percolation.sprinkleParameter, + Set.Icc.coe_zero,sub_zero,one_mul,zero_add] + have hcard : F.card ≤ d := by + simpa only [Finset.card_singleton,one_mul] using + Percolation.incidentSupport_card_le G.ends hl d hd {u} + have henergy : κ ≤ (BernoulliProduct.law r).real + (exteriorEscape G.ends (S : Set V) (G.orbitAdjustedHeight a x) x u)ᶜ := by + apply (show κ ≤ t^F.card from pow_le_pow_of_le_one ht.le ht1 hcard).trans + exact exteriorEscape_avoidance_finite_energy G.ends r b (S : Set V) + (G.orbitAdjustedHeight a x) x u hu F hF hFe + have hr (e : E) : r e ≤ p := by + rw [←hparam] + apply Subtype.coe_le_coe.mp + have hq' : (erasedWhiteParameters (fun _ => q) (G.incidentEdges (S : Set V)) e : ℝ) ≤ q := by + unfold erasedWhiteParameters + split_ifs + · exact q.2.1 + · rfl + dsimp [r,Percolation.sprinkleParameter] + nlinarith [b.2.2] + have hdepth := G.nonpositive_height_depth a R hR x u hxu + exact havoid _ _ henergy (G.exteriorEscape_avoidance_profile hc hl O a ha r p hr + R _ (S : Set V) x u hdepth.2) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SprinklingParameter.lean b/lean/OAI/Probability/BenjaminiSchramm/SprinklingParameter.lean new file mode 100644 index 0000000000000000000000000000000000000000..a10f40731abc7a756306bb01d872981c5c1c5ab6 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SprinklingParameter.lean @@ -0,0 +1,26 @@ +import OAI.Probability.BenjaminiSchramm.PairedSprinkling + +namespace OAI + +noncomputable section + +namespace Percolation.BenjaminiSchramm + +theorem exists_sprinkling_parameter (q p : unitInterval) (hqp : q < p) (hp1 : p < 1) : + ∃ b : unitInterval, 0 < (b : ℝ) ∧ (b : ℝ) < 1 ∧ Percolation.sprinkleParameter q b=p := by + have hqp' : (q : ℝ) < p := hqp + have hp1' : (p : ℝ) < 1 := hp1 + have hden : 0 < 1-(q : ℝ) := by linarith + let b : unitInterval := ⟨((p : ℝ)-q)/(1-q), + (div_pos (sub_pos.mpr hqp') hden).le, + (div_le_one hden).mpr (by linarith [p.2.2])⟩ + refine ⟨b,div_pos (sub_pos.mpr hqp') hden,(div_lt_one hden).mpr (by linarith),?_⟩ + apply Subtype.ext + change (q : ℝ)+(1-q)*(((p : ℝ)-q)/(1-q))=(p : ℝ) + field_simp; ring + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SprinklingPeakGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/SprinklingPeakGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..4169add417921eeac63bbb97154b95e31a9e7049 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SprinklingPeakGeometry.lean @@ -0,0 +1,69 @@ +import OAI.Probability.BenjaminiSchramm.PeakSurgeryGeometry +import OAI.Probability.BenjaminiSchramm.LayerFrontierGeometry +import OAI.Probability.UnimodularPercolation.Kernel.Sprinkling + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} (G : BondGraph V E) + +lemma conn_last_exit_off_internal (ω : Set E) (S : Set V) {x y : V} + (hx : x ∈ S) (hy : y ∉ S) (hc : Conn G ω x y) : + ∃ u ∈ S, Conn G (ω \ internalEdges G S) u y := by + obtain ⟨z,⟨hz,u,hu,e,he,heq⟩,hzy⟩ := conn_last_exit_frontier G ω S hx hy hc + have heI : e ∉ internalEdges G S := fun h => hz (h z (by rw [heq]; simp)) + have huz : Conn G (ω \ internalEdges G S) u z := + Relation.ReflTransGen.single ⟨e,⟨he,heI⟩,heq⟩ + refine ⟨u,hu,huz.trans (conn_mono G ?_ hzy)⟩ + intro b hb + refine ⟨hb.1,fun hI => hb.2 ?_⟩ + exact ⟨(G b).out.1,hI _ (Sym2.out_fst_mem _),Sym2.out_fst_mem _⟩ + +lemma union_strict_peak_of_exterior_avoidance (white blue : Set E) (f : V → ℝ) (x : V) + (hpeak : ∀ y, Conn G white x y → y ≠ x → f y < f x) + (havoid : ∀ u ∈ cluster G white x, + ¬∃ y, y ≠ x ∧ f x ≤ f y ∧ y ∉ cluster G white x ∧ + Conn G ((white ∪ blue) \ internalEdges G (cluster G white x)) u y) : + ∀ y, Conn G (white ∪ blue) x y → y ≠ x → f y < f x := by + intro y hxy hyx + by_contra! hle + have hyS : y ∉ cluster G white x := fun hy => (hpeak y hy hyx).not_ge hle + obtain ⟨u,hu,huy⟩ := conn_last_exit_off_internal G (white ∪ blue) (cluster G white x) + (mem_cluster_self G white x) hyS hxy + exact havoid u hu ⟨y,hyx,hle,hyS,huy⟩ + +lemma no_blue_incident_exterior_avoidance (white blue : Set E) (x u : V) + (hu : u ∈ cluster G white x) + (hblue : ∀ e, u ∈ G e → e ∉ blue) : + ∀ y, y ∉ cluster G white x → + ¬Conn G ((white ∪ blue) \ internalEdges G (cluster G white x)) u y := by + have hnobond (v : V) : + ¬∃ e ∈ ((white ∪ blue) \ internalEdges G (cluster G white x)), G e=s(u,v) := by + rintro ⟨e,⟨he,heI⟩,heq⟩ + have hue : u ∈ G e := by rw [heq]; simp + have hew : e ∈ white := he.resolve_right (hblue e hue) + have hv : v ∈ cluster G white x := hu.trans (Relation.ReflTransGen.single ⟨e,hew,heq⟩) + apply heI + intro z hz + rw [heq] at hz + rcases Sym2.mem_iff.mp hz with hzu | hzv + · rwa [hzu] + · rwa [hzv] + have hsame (y : V) (hy : Conn G ((white ∪ blue) \ internalEdges G (cluster G white x)) u y) : y=u := by + induction hy with + | refl => rfl + | @tail a b _ hab ih => + subst a + exact False.elim (hnobond b hab) + intro y hy hconn + exact hy (hsame y hconn ▸ hu) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalCrossingBound.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalCrossingBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a2c176b664b62d1cd8888bee4528a4867918c8f --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalCrossingBound.lean @@ -0,0 +1,88 @@ +import OAI.Probability.BenjaminiSchramm.LayerCrossingComparison +import OAI.Probability.BenjaminiSchramm.MinimumHeightHit + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem unrestricted_upward_bound_of_layer_rate + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (C : ℝ≥0∞) (hC : C < ⊤) + (hrow : ∀ z, (∑' y, law p {ω | Conn G ω z y}) ≤ C) + (β : ℝ) + (hupper : ∀ ε : ℝ, 0 < ε → ∃ K : ℝ, 0 < K ∧ ∀ n : ℕ, + (criticalModel G).supAdjustedUpLayerMoment ((criticalModel G).stationaryOrbitWeight μ) R p n ≤ + ENNReal.ofReal (K*Real.exp (-(β-ε)*n))) : + ∃ B : ℝ, 0 < B ∧ ∀ (n : ℕ) (x : V), + law p (restrictedHit G Set.univ x + {y | R*((n : ℝ)-1) ≤ (criticalModel G).orbitAdjustedHeight + ((criticalModel G).stationaryOrbitWeight μ) x y}) ≤ ENNReal.ofReal (B*Real.exp (-β*n)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨α,hα,hαupper,hαlower,_hαlim⟩ := H.normalized_crossing_exponent hHc hl hHq μ hμ hstat hu p hp + have hβα := H.crossing_rate_ge_layer_rate hHc hl a R hR hjump p C hC hrow α β hα hαlower hupper + have hreal := normalized_crossing_real_bound G hc hl hq μ hμ p α hα hαupper + obtain ⟨A,D,_hA,_hD,hroot⟩ := normalized_halfspace_uniform_of_infimal_bound G hc hl hq hu μ hμ hstat p hp α hreal + let K : ℝ := (p : ℝ)^(-D) + have hK : 0 < K := Real.rpow_pos_of_pos hp _ + let B := 1+C.toReal*K*Real.exp (α*R) + have hB : 0 < B := by dsimp [B]; positivity + refine ⟨B,hB,fun n x => ?_⟩ + by_cases hn : n=0 + · subst n + have hB1 : (1 : ℝ) ≤ B := by dsimp [B]; exact le_add_of_nonneg_right (by positivity) + simpa only [Nat.cast_zero,mul_zero,Real.exp_zero,mul_one] using + (prob_le_one (μ := law p)).trans (by simpa only [ENNReal.ofReal_one] using ENNReal.ofReal_le_ofReal hB1) + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hn + have ht : 0 ≤ R*((n : ℝ)-1) := mul_nonneg hR.le (by linarith) + have hκ (z : V) : H.law p (H.adjustedHalfspaceHit a z 0 (R*((n : ℝ)-1))) ≤ + ENNReal.ofReal (K*Real.exp (-α*(R*((n : ℝ)-1)))) := by + have hh := hroot 0 (le_refl 0) z (R*((n : ℝ)-1)) ht + simp only [mul_zero,zero_add,neg_zero] at hh + have he := ENNReal.ofReal_le_ofReal hh + change ENNReal.ofReal ((H.law p (H.adjustedHalfspaceHit a z 0 (R*((n : ℝ)-1)))).toReal) ≤ + ENNReal.ofReal (K*Real.exp (-α*(R*((n : ℝ)-1)))) at he + rwa [ENNReal.ofReal_toReal (measure_ne_top _ _)] at he + have hh := H.unrestricted_adjusted_upward_hit_bound hHc hl a p C _ hrow _ hκ x + have hexp : Real.exp (-α*(R*((n : ℝ)-1))) ≤ Real.exp (α*R)*Real.exp (-β*n) := by + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + have hnnonneg : (0 : ℝ) ≤ n := Nat.cast_nonneg n + nlinarith + calc + _ ≤ C*ENNReal.ofReal (K*Real.exp (-α*(R*((n : ℝ)-1)))) := hh + _ = ENNReal.ofReal (C.toReal*K*Real.exp (-α*(R*((n : ℝ)-1)))) := by + calc + _ = ENNReal.ofReal C.toReal*ENNReal.ofReal (K*Real.exp (-α*(R*((n : ℝ)-1)))) := by + rw [ENNReal.ofReal_toReal hC.ne] + _ = _ := by rw [←ENNReal.ofReal_mul ENNReal.toReal_nonneg]; congr 1; ring + _ ≤ ENNReal.ofReal ((C.toReal*K*Real.exp (α*R))*Real.exp (-β*n)) := by + apply ENNReal.ofReal_le_ofReal + have he := mul_le_mul_of_nonneg_left hexp + (show 0 ≤ C.toReal*K from mul_nonneg ENNReal.toReal_nonneg hK.le) + simpa only [mul_assoc] using he + _ ≤ _ := by + apply ENNReal.ofReal_le_ofReal + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + dsimp [B] + linarith + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalFullLayerProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalFullLayerProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ab7b3fe4aa744d0ba66dca8239aa9d49fae3993 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalFullLayerProfile.lean @@ -0,0 +1,138 @@ +import OAI.Probability.BenjaminiSchramm.FullNegativeLayerProfile +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerPrefactor + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma symmetric_exponential_profile (F : ℤ → ℝ≥0∞) (χ K D R β : ℝ) + (hχ : 0 ≤ χ) (hK : 0 ≤ K) (hD : 0 ≤ D) (hR : 0 < R) (hβ : R < β) + (hbase : ∀ i, F i ≤ ENNReal.ofReal χ) + (hup : ∀ n : ℕ, F n ≤ ENNReal.ofReal (K*χ*Real.exp (-β*n))) + (hdown : ∀ n : ℕ, 3 ≤ n → F (-(n : ℤ)) ≤ + ENNReal.ofReal (D*K*χ*Real.exp (R+2*β)*Real.exp (-(β-R)*n))) : + ∃ C : ℝ, 0 < C ∧ ∀ i : ℤ, + F i ≤ ENNReal.ofReal (C*Real.exp (-(β-R)*|(i : ℝ)|)) := by + let a := β-R + have ha : 0 < a := sub_pos.mpr hβ + let M := χ+K*χ+D*K*χ*Real.exp (R+2*β)+1 + have hprod : 0 ≤ D*K*χ*Real.exp (R+2*β) := by positivity + have hM : 0 < M := by dsimp [M]; positivity + have hχM : χ ≤ M := by dsimp [M]; nlinarith [mul_nonneg hK hχ] + have hKM : K*χ ≤ M := by dsimp [M]; linarith + have hDM : D*K*χ*Real.exp (R+2*β) ≤ M := by + dsimp [M] + linarith [mul_nonneg hK hχ] + have hexp : (1 : ℝ) ≤ Real.exp (2*a) := Real.one_le_exp_iff.mpr (by positivity) + have hMC : M ≤ M*Real.exp (2*a) := by nlinarith + have hpos (n : ℕ) : F (n : ℤ) ≤ + ENNReal.ofReal (M*Real.exp (2*a)*Real.exp (-a*n)) := by + apply (hup n).trans + apply ENNReal.ofReal_le_ofReal + have he : Real.exp (-β*n) ≤ Real.exp (-a*n) := by + apply Real.exp_le_exp.mpr + dsimp [a] + nlinarith [(Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + exact (mul_le_mul (hKM.trans hMC) he (Real.exp_nonneg _) (by positivity)) + have hneg (n : ℕ) : F (-(n : ℤ)) ≤ + ENNReal.ofReal (M*Real.exp (2*a)*Real.exp (-a*n)) := by + by_cases hn : 3 ≤ n + · exact (hdown n hn).trans (ENNReal.ofReal_le_ofReal + (mul_le_mul_of_nonneg_right (hDM.trans hMC) (Real.exp_nonneg _))) + · apply (hbase _).trans + apply ENNReal.ofReal_le_ofReal + have hn2 : (n : ℝ) ≤ 2 := by exact_mod_cast (show n ≤ 2 by omega) + have he : (1 : ℝ) ≤ Real.exp (2*a-a*n) := + Real.one_le_exp_iff.mpr (by nlinarith) + rw [mul_assoc,←Real.exp_add] + have heq : 2*a + -a*(n : ℝ)=2*a-a*n := by ring + rw [heq] + exact hχM.trans (by nlinarith) + refine ⟨M*Real.exp (2*a),by positivity,?_⟩ + intro i + cases i with + | ofNat n => + change F (n : ℤ) ≤ ENNReal.ofReal (M*Real.exp (2*a)*Real.exp (-a*|(n : ℝ)|)) + simpa only [abs_of_nonneg (Nat.cast_nonneg n : (0 : ℝ) ≤ n)] using hpos n + | negSucc n => + have hi : Int.negSucc n = -((n+1 : ℕ) : ℤ) := rfl + simpa only [hi,Int.cast_neg,Int.cast_natCast,abs_neg, + abs_of_nonneg (Nat.cast_nonneg (n+1) : (0 : ℝ) ≤ ((n+1 : ℕ) : ℝ))] using hneg (n+1) + +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_full_layer_profile + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < pc G) : + ∃ β : ℝ, R < β ∧ ∃ C : ℝ, 0 < C ∧ ∀ i : ℤ, + (criticalModel G).supAdjustedFullLayerMoment ((criticalModel G).stationaryOrbitWeight μ) R p i ≤ + ENNReal.ofReal (C*Real.exp (-(β-R)*|(i : ℝ)|)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨χ,hχ,hrow⟩ := subcritical_ennreal_row_bound G hl hq p hpc + obtain ⟨β,hβ,_,K,hK,hup⟩ := subcritical_layer_prefactor G hc hl hq μ hμ hstat hu R hR hjump p hp hpc + obtain ⟨m,M,hm,hweights⟩ := H.stationaryOrbitWeight_uniform_bounds hHc hl μ hμ + let O := H.orbitRepresentatives hHq + let D : ℝ≥0∞ := (ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r)) + have hD : D ≠ ⊤ := ENNReal.mul_ne_top + (ENNReal.inv_ne_top.mpr (ENNReal.ofReal_ne_zero_iff.mpr hm)) + (ENNReal.sum_ne_top.mpr fun r _ => ENNReal.ofReal_ne_top) + have hDEq : ENNReal.ofReal D.toReal=D := ENNReal.ofReal_toReal hD + have hbase (i : ℤ) : H.supAdjustedFullLayerMoment a R p i ≤ ENNReal.ofReal χ := + H.supAdjustedFullLayerMoment_le_row_bound a R p _ hrow i + have hpositive (n : ℕ) : H.supAdjustedFullLayerMoment a R p n ≤ + ENNReal.ofReal (K*χ*Real.exp (-β*n)) := by + apply (H.supAdjustedFullLayerMoment_up_bound hHc hl a R hR hjump p _ hrow n).trans + apply (mul_le_mul' (hup n) le_rfl).trans_eq + rw [←ENNReal.ofReal_mul (mul_nonneg hK.le (Real.exp_nonneg _))] + congr 1 + ring + have hnegative (n : ℕ) (hn : 3 ≤ n) : H.supAdjustedFullLayerMoment a R p (-(n : ℤ)) ≤ + ENNReal.ofReal (D.toReal*K*χ*Real.exp (R+2*β)*Real.exp (-(β-R)*n)) := by + have hb : H.supAdjustedFullLayerMoment a R p (-(n : ℤ)) ≤ + D*ENNReal.ofReal (Real.exp (R*((n : ℝ)+1)))* + (H.supAdjustedUpLayerMoment a R p (n-2)*ENNReal.ofReal χ) := by + apply iSup_le + intro x + apply iSup_le + intro u + exact H.adjustedFullLayerMoment_negative_bound O hHc hl a + (H.stationaryOrbitWeight_pos hHc hl μ hμ) (H.stationaryOrbitWeight_aut μ) + m hm (fun x => (hweights x).1) R hR hjump p _ hrow n hn x u + apply hb.trans + apply (mul_le_mul' le_rfl (mul_le_mul' (hup (n-2)) le_rfl)).trans_eq + nth_rw 1 [←hDEq] + rw [←ENNReal.ofReal_mul ENNReal.toReal_nonneg, + ←ENNReal.ofReal_mul (mul_nonneg hK.le (Real.exp_nonneg _)), + ←ENNReal.ofReal_mul (mul_nonneg ENNReal.toReal_nonneg (Real.exp_nonneg _))] + congr 1 + rw [Nat.cast_sub (by omega : 2 ≤ n)] + push_cast + rw [show D.toReal*Real.exp (R*((n : ℝ)+1))*(K*Real.exp (-β*((n : ℝ)-2))*χ) = + D.toReal*K*χ*(Real.exp (R*((n : ℝ)+1))*Real.exp (-β*((n : ℝ)-2))) by ring, + ←Real.exp_add,show R*((n : ℝ)+1)+ -β*((n : ℝ)-2) = R+2*β + (-(β-R)*(n : ℝ)) by ring, + Real.exp_add] + ring + obtain ⟨C,hC,hprof⟩ := symmetric_exponential_profile + (H.supAdjustedFullLayerMoment a R p) χ K D.toReal R β hχ hK.le ENNReal.toReal_nonneg + hR hβ hbase hpositive hnegative + exact ⟨β,hβ,C,hC,hprof⟩ + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerConvolution.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..45c8b09ce5dd656323e32be889d393bc1fcdd927 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerConvolution.lean @@ -0,0 +1,118 @@ +import OAI.Probability.BenjaminiSchramm.TiltedMoments + +namespace OAI + +noncomputable section +open scoped ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +def expAbsLayerKernel (a : ℝ) (i : ℤ) : ℝ≥0∞ := + ENNReal.ofReal (Real.exp (-a*|(i : ℝ)|)) + +theorem expAbsLayerKernel_tsum_lt_top {a : ℝ} (ha : 0 < a) : + (∑' i : ℤ, expAbsLayerKernel a i) < ⊤ := by + have hn : Summable (fun n : ℕ => Real.exp ((n : ℝ)*(-a))) := + Real.summable_exp_nat_mul_iff.mpr (neg_neg_of_pos ha) + have hs : Summable (fun i : ℤ => Real.exp (-a*|(i : ℝ)|)) := by + apply summable_int_iff_summable_nat_and_neg.mpr + constructor + · convert hn using 1 + funext n + simp only [Int.cast_natCast,abs_of_nonneg (Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + congr 1 + ring + · convert hn using 1 + funext n + simp only [Int.cast_neg,Int.cast_natCast,abs_neg, + abs_of_nonneg (Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + congr 1 + ring + exact hs.tsum_ofReal_lt_top + +lemma three_layer_abs_bound (k l : ℕ) (i : ℝ) : + ((max k l : ℕ) : ℝ)+|i+(min k l : ℕ)| ≤ |i|+|-(k : ℝ)-i|+|-(l : ℝ)-i| := by + have hneg (r : ℕ) : |-(r : ℝ)-i| = |i+r| := by + rw [show -(r : ℝ)-i = -(i+r) by ring,abs_neg] + rw [hneg k,hneg l] + have htriangle (r : ℕ) : (r : ℝ) ≤ |i|+|i+r| := by + have hh := abs_add_le (-i) (i+(r : ℝ)) + rw [show -i+(i+(r : ℝ)) = (r : ℝ) by ring,abs_neg, + abs_of_nonneg (Nat.cast_nonneg r : (0 : ℝ) ≤ r)] at hh + exact hh + by_cases hkl : k ≤ l + · rw [max_eq_right hkl,min_eq_left hkl] + linarith [htriangle l] + · rw [max_eq_left (le_of_not_ge hkl),min_eq_right (le_of_not_ge hkl)] + linarith [htriangle k] + +theorem expAbsLayerKernel_triple_bound {a : ℝ} (ha : 0 ≤ a) + (k l : ℕ) (i : ℤ) : + expAbsLayerKernel a i * expAbsLayerKernel a (-(k : ℤ)-i) * + expAbsLayerKernel a (-(l : ℤ)-i) ≤ + ENNReal.ofReal (Real.exp (-a*((max k l : ℕ) : ℝ))) * + expAbsLayerKernel a (i+(min k l : ℕ)) := by + unfold expAbsLayerKernel + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),←ENNReal.ofReal_mul (mul_nonneg + (Real.exp_nonneg _) (Real.exp_nonneg _)),←ENNReal.ofReal_mul (Real.exp_nonneg _)] + apply ENNReal.ofReal_le_ofReal + rw [←Real.exp_add,←Real.exp_add,←Real.exp_add] + apply Real.exp_le_exp.mpr + simp only [Int.cast_sub,Int.cast_neg,Int.cast_natCast,Int.cast_add] + have hh := mul_le_mul_of_nonneg_left (three_layer_abs_bound k l (i : ℝ)) ha + linarith + +theorem expAbsLayerKernel_triple_sum_bound {a : ℝ} (ha : 0 ≤ a) (k l : ℕ) : + (∑' i : ℤ, expAbsLayerKernel a i * expAbsLayerKernel a (-(k : ℤ)-i) * + expAbsLayerKernel a (-(l : ℤ)-i)) ≤ + ENNReal.ofReal (Real.exp (-a*((max k l : ℕ) : ℝ))) * ∑' i : ℤ, expAbsLayerKernel a i := by + apply (ENNReal.tsum_le_tsum (expAbsLayerKernel_triple_bound ha k l)).trans_eq + rw [ENNReal.tsum_mul_left] + congr 1 + exact (Equiv.addRight ((min k l : ℕ) : ℤ)).tsum_eq (expAbsLayerKernel a) + +theorem subcritical_three_profile_convolution {a : ℝ} (ha : 0 ≤ a) + (C : ℝ≥0∞) (f g h : ℤ → ℝ≥0∞) + (hf : ∀ i, f i ≤ C*expAbsLayerKernel a i) + (hg : ∀ i, g i ≤ C*expAbsLayerKernel a i) + (hh : ∀ i, h i ≤ C*expAbsLayerKernel a i) (k l : ℕ) : + (∑' i : ℤ, f i*g (-(k : ℤ)-i)*h (-(l : ℤ)-i)) ≤ + C^3*ENNReal.ofReal (Real.exp (-a*((max k l : ℕ) : ℝ))) * + ∑' i : ℤ, expAbsLayerKernel a i := by + calc + _ ≤ ∑' i : ℤ, C^3*(expAbsLayerKernel a i * expAbsLayerKernel a (-(k : ℤ)-i) * + expAbsLayerKernel a (-(l : ℤ)-i)) := by + apply ENNReal.tsum_le_tsum + intro i + calc + _ ≤ (C*expAbsLayerKernel a i)*(C*expAbsLayerKernel a (-(k : ℤ)-i))* + (C*expAbsLayerKernel a (-(l : ℤ)-i)) := + mul_le_mul' (mul_le_mul' (hf i) (hg _)) (hh _) + _ = _ := by ring + _ ≤ C^3*(ENNReal.ofReal (Real.exp (-a*((max k l : ℕ) : ℝ)))* + ∑' i : ℤ, expAbsLayerKernel a i) := by + rw [ENNReal.tsum_mul_left] + exact mul_le_mul' le_rfl (expAbsLayerKernel_triple_sum_bound ha k l) + _ = _ := (mul_assoc _ _ _).symm + +theorem subcritical_three_profile_uniform_bound {a : ℝ} (ha : 0 < a) + (C : ℝ≥0∞) (hC : C < ⊤) : + ∃ K : ℝ≥0∞, K < ⊤ ∧ ∀ (f g h : ℤ → ℝ≥0∞), + (∀ i, f i ≤ C*expAbsLayerKernel a i) → + (∀ i, g i ≤ C*expAbsLayerKernel a i) → + (∀ i, h i ≤ C*expAbsLayerKernel a i) → ∀ k l : ℕ, + (∑' i : ℤ, f i*g (-(k : ℤ)-i)*h (-(l : ℤ)-i)) ≤ + K*ENNReal.ofReal (Real.exp (-a*((max k l : ℕ) : ℝ))) := by + refine ⟨C^3*(∑' i : ℤ, expAbsLayerKernel a i),?_,?_⟩ + · apply ENNReal.mul_lt_top _ (expAbsLayerKernel_tsum_lt_top ha) + simpa only [pow_succ,pow_zero,one_mul] using + ENNReal.mul_lt_top (ENNReal.mul_lt_top hC hC) hC + · intro f g h hf hg hh k l + exact (subcritical_three_profile_convolution ha.le C f g h hf hg hh k l).trans_eq + (by ring) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerPrefactor.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerPrefactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b6c92f02f1124c9bcdc05a32dfc11cbf7d20b05 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerPrefactor.lean @@ -0,0 +1,99 @@ +import OAI.Probability.BenjaminiSchramm.LayerPrefactorBootstrap +import OAI.Probability.BenjaminiSchramm.SubcriticalCrossingBound +import OAI.Probability.BenjaminiSchramm.BandMomentSummability +import OAI.Probability.BenjaminiSchramm.SignedUpperConvolution + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_layer_prefactor + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < pc G) : + ∃ β : ℝ, R < β ∧ + (∀ n : ℕ, ENNReal.ofReal (Real.exp (-β*n)) ≤ + (criticalModel G).supAdjustedUpLayerMoment ((criticalModel G).stationaryOrbitWeight μ) R p n) ∧ + ∃ K : ℝ, 0 < K ∧ ∀ n : ℕ, + (criticalModel G).supAdjustedUpLayerMoment ((criticalModel G).stationaryOrbitWeight μ) R p n ≤ + ENNReal.ofReal (K*Real.exp (-β*n)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hHq := criticalModel_quasiTransitive G hq + obtain ⟨χ,hχ,hrow⟩ := subcritical_ennreal_row_bound G hl hq p hpc + let C := ENNReal.ofReal χ + have hC : C < ⊤ := ENNReal.ofReal_lt_top + have hSbound (n : ℕ) : H.supAdjustedUpLayerMoment a R p n ≤ C := by + apply iSup_le + intro x + apply iSup_le + intro u + exact restrictedLayerCount_expectation_le_row_bound G p C hrow _ _ x + have hne (n : ℕ) : H.supAdjustedUpLayerMoment a R p n ≠ ⊤ := (lt_of_le_of_lt (hSbound n) hC).ne + let S : ℕ → ℝ := fun n => (H.supAdjustedUpLayerMoment a R p n).toReal + have hS (n : ℕ) : 0 ≤ S n := ENNReal.toReal_nonneg + have hSEq (n : ℕ) : ENNReal.ofReal (S n)=H.supAdjustedUpLayerMoment a R p n := ENNReal.ofReal_toReal (hne n) + have hSb (n : ℕ) : S n ≤ χ := by + have hh := ENNReal.toReal_mono hC.ne (hSbound n) + rwa [ENNReal.toReal_ofReal hχ] at hh + obtain ⟨β,_hβ,hlower,hupper,_hlim⟩ := H.subcritical_normalized_layer_rate hHc hl hHq hq + μ hμ hstat hu R hR hjump p hp hpc + have hlo (n : ℕ) : ENNReal.ofReal (Real.exp (-β*n)) ≤ H.supAdjustedUpLayerMoment a R p n := by + have hh := ENNReal.ofReal_le_ofReal (hlower n) + rwa [ENNReal.ofReal_toReal (hne n)] at hh + obtain ⟨m,M,hm,hweights⟩ := H.stationaryOrbitWeight_uniform_bounds hHc hl μ hμ + have hβR : R < β := H.normalized_layer_rate_strict_of_lower (H.orbitRepresentatives hHq) + hHc hl a (H.stationaryOrbitWeight_pos hHc hl μ hμ) (H.stationaryOrbitWeight_aut μ) + m hm (fun x => (hweights x).1) R hR p C hC hrow β hlo + have hβ : 0 < β := hR.trans hβR + obtain ⟨K,hK,hKbd⟩ := hupper (β/4) (by positivity) + have hdecay (n : ℕ) : S n ≤ K*Real.exp (-(3*β/4)*n) := by + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top (hKbd n) + rw [ENNReal.toReal_ofReal (mul_nonneg hK.le (Real.exp_nonneg _))] at hh + convert hh using 1 + congr 2 + ring + have hmul (n j : ℕ) : S (n+j) ≤ S n*S j := by + have hh := ENNReal.toReal_mono (ENNReal.mul_ne_top (hne n) (hne j)) + (H.supAdjustedUpLayerMoment_submultiplicative hHc hl a R hR hjump p n j) + simpa only [ENNReal.toReal_mul] using hh + have hF (i : ℤ) : H.supAdjustedFullLayerMoment a R p i ≤ ENNReal.ofReal χ := + H.supAdjustedFullLayerMoment_le_row_bound a R p C hrow i + have hFpos (i : ℕ) : H.supAdjustedFullLayerMoment a R p i ≤ ENNReal.ofReal (χ*S i) := by + apply (H.supAdjustedFullLayerMoment_up_bound hHc hl a R hR hjump p C hrow i).trans_eq + rw [←hSEq i] + change ENNReal.ofReal (S i)*ENNReal.ofReal χ=ENNReal.ofReal (χ*S i) + rw [←ENNReal.ofReal_mul (hS i)] + congr 1 + ring + obtain ⟨A,hA,hsecondbd⟩ := signed_upper_convolution_bound S hS β K χ hβ hχ hSb hmul hdecay + (H.supAdjustedFullLayerMoment a R p) hF hFpos + have hsecond (n : ℕ) (x : V) (u : ℝ) : + (∫⁻ ω, (restrictedLayerCount G + (internalEdges G {y | H.adjustedLayerIndex a R u x y ≤ (n : ℤ)}) + {y | H.adjustedLayerIndex a R u x y=(n : ℤ)} ω x)^2 ∂law p) ≤ + ENNReal.ofReal (A*Real.exp (-β*n)*prefixMaximum (fun j => Real.exp (β*j)*S j) n) := by + apply (H.adjusted_upper_layer_second_moment_bound hHc hl a R p x u n).trans + simpa only [hSEq] using hsecondbd n + obtain ⟨B,hB,hprob⟩ := unrestricted_upward_bound_of_layer_rate G hc hl hq μ hμ hstat hu + R hR hjump p hp C hC hrow β hupper + refine ⟨β,hβR,hlo,A*B,mul_pos hA hB,?_⟩ + exact H.adjusted_layer_prefactor_bootstrap a R hR p β A B hA.le hB.le hne hprob hsecond + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerSecondMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..2de8720381dae67961eef475aa122d9696f075a1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalLayerSecondMoment.lean @@ -0,0 +1,49 @@ +import OAI.Probability.BenjaminiSchramm.SubcriticalFullLayerProfile +import OAI.Probability.BenjaminiSchramm.LayerSecondMomentDecomposition +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerConvolution + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_downward_layer_second_moment + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < pc G) : + ∃ β : ℝ, R < β ∧ ∃ K : ℝ≥0∞, K < ⊤ ∧ ∀ (k l : ℕ) (x : V) (u : ℝ), + (∫⁻ ω, restrictedLayerCount G Set.univ + {y | (criticalModel G).adjustedLayerIndex ((criticalModel G).stationaryOrbitWeight μ) R u x y = -(k : ℤ)} ω x * + restrictedLayerCount G Set.univ + {y | (criticalModel G).adjustedLayerIndex ((criticalModel G).stationaryOrbitWeight μ) R u x y = -(l : ℤ)} ω x ∂law p) ≤ + K*ENNReal.ofReal (Real.exp (-(β-R)*((max k l : ℕ) : ℝ))) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + obtain ⟨β,hβ,C,hC,hprofile⟩ := subcritical_full_layer_profile G hc hl hq μ hμ hstat hu R hR hjump p hp hpc + have hprof (i : ℤ) : H.supAdjustedFullLayerMoment a R p i ≤ + ENNReal.ofReal C*expAbsLayerKernel (β-R) i := by + simpa only [expAbsLayerKernel,ENNReal.ofReal_mul hC.le] using hprofile i + obtain ⟨K,hK,hconv⟩ := subcritical_three_profile_uniform_bound (sub_pos.mpr hβ) + (ENNReal.ofReal C) ENNReal.ofReal_lt_top + refine ⟨β,hβ,K,hK,?_⟩ + intro k l x u + exact (H.adjusted_full_layer_second_moment_bound (criticalModel_connected G hc) hl a R p x u + (-(k : ℤ)) (-(l : ℤ))).trans + (hconv (H.supAdjustedFullLayerMoment a R p) (H.supAdjustedFullLayerMoment a R p) + (H.supAdjustedFullLayerMoment a R p) hprof hprof hprof k l) + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakConditional.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakConditional.lean new file mode 100644 index 0000000000000000000000000000000000000000..00c1988dc72f5e9d4a314ab0ab656db1902997a9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakConditional.lean @@ -0,0 +1,92 @@ +import OAI.Probability.BenjaminiSchramm.PeakConditionalLayers + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma exponential_max_factorization (a c D n l : ℝ) (hc : c ≠ 0) : + D*Real.exp (-a*max n l)= + (c*Real.exp (-a*n))*((D/c)*Real.exp (-a*max (l-n) 0)) := by + have hm : max n l=n+max (l-n) 0 := by + rcases le_total n l with h | h + · rw [max_eq_right h,max_eq_left (sub_nonneg.mpr h)] + ring + · rw [max_eq_left h,max_eq_right (sub_nonpos.mpr h)] + ring + rw [hm] + calc + _ = D*(Real.exp (-a*n)*Real.exp (-a*max (l-n) 0)) := by + rw [←Real.exp_add] + congr 2 + ring + _ = _ := by field_simp + +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_weighted_peak_conditional_layers + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < pc G) + (O : (criticalModel G).OrbitRepresentatives) : + ∃ β : ℝ, R < β ∧ ∃ K : ℝ, 0 < K ∧ + (∀ n : ℕ, (criticalModel G).supAdjustedUpLayerMoment + ((criticalModel G).stationaryOrbitWeight μ) R p n ≤ ENNReal.ofReal (K*Real.exp (-β*n))) ∧ + ∃ c : ℝ, 0 < c ∧ ∃ C : ℝ, 0 < C ∧ ∀ n : ℕ, 0 < n → + ENNReal.ofReal (c*Real.exp (-(β-R)*n)) ≤ + (criticalModel G).peakSurvivalProbability O ((criticalModel G).stationaryOrbitWeight μ) R p n ∧ + ∀ l : ℕ, (criticalModel G).peakSurvivalLayerMoment O + ((criticalModel G).stationaryOrbitWeight μ) R p n l ≤ + (criticalModel G).peakSurvivalProbability O ((criticalModel G).stationaryOrbitWeight μ) R p n * + ENNReal.ofReal (C*Real.exp (-(β-R)*max ((l : ℝ)-n) 0)) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + obtain ⟨β,hβR,K,hK,hup,c,hcpos,hsurv⟩ := subcritical_weighted_peak_survival G hc hl hq + μ hμ hstat hu R hR hjump p hp hpc O + obtain ⟨C₀,hC₀,hprofile⟩ := subcritical_full_layer_profile_at_rate G hc hl hq μ hμ + R hR hjump p hpc β K hβR hK hup + obtain ⟨K₂,hK₂,hsecond⟩ := H.adjusted_downward_layer_second_moment_at_rate + hHc hl a R p β C₀ hβR hC₀ hprofile + let B : ℝ≥0∞ := (∑ x ∈ O.roots, ENNReal.ofReal (a x))*(4*K₂) + have hB : B ≠ ⊤ := ENNReal.mul_ne_top + (ENNReal.sum_ne_top.mpr fun _ _ => ENNReal.ofReal_ne_top) + (ENNReal.mul_ne_top (by norm_num) hK₂.ne) + let D := B.toReal+1 + have hD : 0 < D := by dsimp [D]; positivity + have hBD : B ≤ ENNReal.ofReal D := by + rw [←ENNReal.ofReal_toReal hB] + exact ENNReal.ofReal_le_ofReal (by dsimp [D]; linarith) + refine ⟨β,hβR,K,hK,hup,c,hcpos,D/c,div_pos hD hcpos,?_⟩ + intro n hn + refine ⟨hsurv n hn,?_⟩ + intro l + calc + _ ≤ B*ENNReal.ofReal (Real.exp (-(β-R)*((max n l : ℕ) : ℝ))) := + H.peakSurvivalLayerMoment_bound O hHc hl a R hR p β hβR K₂ + (fun k j x => hsecond k j x 0) n l + _ ≤ ENNReal.ofReal D*ENNReal.ofReal (Real.exp (-(β-R)*((max n l : ℕ) : ℝ))) := + mul_le_mul' hBD le_rfl + _ = ENNReal.ofReal (c*Real.exp (-(β-R)*n))* + ENNReal.ofReal ((D/c)*Real.exp (-(β-R)*max ((l : ℝ)-n) 0)) := by + rw [←ENNReal.ofReal_mul hD.le,←ENNReal.ofReal_mul + (mul_nonneg hcpos.le (Real.exp_nonneg _))] + congr 1 + rw [Nat.cast_max] + exact exponential_max_factorization (β-R) c D n l hcpos.ne' + _ ≤ _ := mul_le_mul' (hsurv n hn) le_rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakProbability.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0f188da9cf1d496f7080b69f01f76758d34f642 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakProbability.lean @@ -0,0 +1,119 @@ +import OAI.Probability.BenjaminiSchramm.PeakBandProbability +import OAI.Probability.BenjaminiSchramm.PeakSurgeryAverage +import OAI.Probability.BenjaminiSchramm.UpwardFrontierProbability + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_peak_band_probability + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < pc G) : + ∃ β : ℝ, R < β ∧ ∃ K : ℝ, 0 < K ∧ + (∀ n : ℕ, (criticalModel G).supAdjustedUpLayerMoment + ((criticalModel G).stationaryOrbitWeight μ) R p n ≤ ENNReal.ofReal (K*Real.exp (-β*n))) ∧ + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, 0 < n → ∃ x : V, + ENNReal.ofReal (c*Real.exp (-β*n)) ≤ + (criticalModel G).law p ((criticalModel G).strictPeakBandEvent + ((criticalModel G).stationaryOrbitWeight μ) (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) x) := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + obtain ⟨β,hβR,hlo,K,hK,hup⟩ := subcritical_layer_prefactor G hc hl hq μ hμ hstat hu R hR hjump p hp hpc + have hβ : 0 < β := hR.trans hβR + obtain ⟨χ,hχ,hrow⟩ := subcritical_ennreal_row_bound G hl hq p hpc + obtain ⟨A,hA,hsecond⟩ := H.adjusted_upper_layer_second_moment_constant hHc hl a R hR hjump p + χ hχ hrow β K hβ hK hup + obtain ⟨L,hsurgery⟩ := normalized_peak_surgery G hc hl hq μ hμ hstat hu R hR hjump + obtain ⟨d,_hd,hd⟩ := exists_degree_bound G hq + obtain ⟨N,hN⟩ := exists_nat_gt (max (4*A*χ*K) 1) + have hNpos : (0 : ℝ) < N := lt_of_lt_of_le zero_lt_one (le_trans (le_max_right _ _) hN.le) + have hNscale : 4*A*χ*K ≤ (N : ℝ) := (le_max_left _ _).trans hN.le + let δ : ℝ := min (p : ℝ) (1-p) + have hp1 : (p : ℝ) < 1 := (show (p : ℝ) < (pc G : ℝ) from hpc).trans_le (pc G).2.2 + have hδ : 0 < δ := lt_min hp (sub_pos.mpr hp1) + have hδ1 : δ ≤ 1 := (min_le_left _ _).trans p.2.2 + let ε : ℝ := δ^(d*(N+L+1)) + have hε : 0 < ε := pow_pos hδ _ + refine ⟨β,hβR,K,hK,hup,ε/(4*A),div_pos hε (by positivity),?_⟩ + intro n hn + let t := Real.exp (-β*n) + have ht : 0 < t := Real.exp_pos _ + have hfront := H.adjusted_frontier_probability_lower a R p β A hA hlo hsecond n hn + have hhalf : ENNReal.ofReal (t/(2*A)) < H.supAdjustedFrontierProbability a R p n := by + apply lt_of_lt_of_le _ hfront + apply (ENNReal.ofReal_lt_ofReal_iff (by positivity : 0 < t/A)).mpr + apply (div_lt_div_iff₀ (by positivity : 0 < 2*A) hA).mpr + nlinarith + obtain ⟨x,hx⟩ := lt_iSup_iff.mp hhalf + obtain ⟨offset,hoffset⟩ := lt_iSup_iff.mp hx + let f := H.adjustedLayerIndex a R offset x + let I := internalEdges G {v | f v < (n : ℤ)} + let Z : Set E → ℝ≥0∞ := fun ω => frontierCount G I Set.univ ω x + have hfx : f x < (n : ℤ) := by + simp only [f,H.adjustedLayerIndex_self] + exact_mod_cast hn + have hfj : ∀ e v w, v ∈ G e → w ∈ G e → f w ≤ f v+1 := by + intro e v w hv hw + exact (H.adjustedLayerIndex_edge_jump hHc hl a R offset hR hjump x v w e hv hw).2 + have hmoment : (∫⁻ ω, Z ω ∂law p) ≤ ENNReal.ofReal (χ*K*t) := by + apply (lintegral_mono fun ω => integer_frontierCount_le_fullLayerCount G f n hfj ω x hfx).trans + apply (H.adjustedFullLayerMoment_up_bound hHc hl a R hR hjump p _ hrow n x offset).trans + apply (mul_le_mul' (hup n) le_rfl).trans_eq + rw [←ENNReal.ofReal_mul (mul_nonneg hK.le ht.le)] + congr 1 + ring + have hscale : 2*(χ*K*t) ≤ (N : ℝ)*(t/(2*A)) := by + calc + _ = (4*A*χ*K*t)/(2*A) := by field_simp; ring + _ ≤ ((N : ℝ)*t)/(2*A) := div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right hNscale ht.le) (by positivity) + _ = _ := by ring + have hsmall := small_frontier_probability_lower p {ω | 0 < Z ω} Z + (measurable_frontierCount G I Set.univ x) (t/(2*A)) (χ*K*t) N + (by positivity) (by positivity) hNpos hoffset.le hmoment hscale + have hfin : ∀ᵐ ω ∂law p, (cluster G (ω ∩ I) x).Finite := by + filter_upwards [subcritical_cluster_finite_ae G p hpc x] with ω hω + exact hω.subset (fun y hy => conn_mono G Set.inter_subset_left hy) + let B := H.strictPeakBandEvent a (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) x + have hlocal (S F : Finset V) + (hcell : (lowerFrontierCell G I Set.univ x (S : Set V) (F : Set V)).Nonempty) + (hgood : 0 < F.card ∧ F.card ≤ N) : + law p (lowerFrontierCell G I Set.univ x (S : Set V) (F : Set V))* + ENNReal.ofReal (δ^(d*(F.card+L+1))) ≤ + law p (lowerFrontierCell G I Set.univ x (S : Set V) (F : Set V) ∩ B) := + hsurgery p d hd n hn x offset S F hcell (Finset.card_pos.mp hgood.1) + have hs := peak_probability_of_frontier_surgery G hl p I Set.univ x hfin B + (H.measurableSet_strictPeakBandEvent a _ _ x) N L d δ hδ.le hδ1 hlocal + refine ⟨x,?_⟩ + apply le_trans _ hs + have hsmall' : ENNReal.ofReal (t/(4*A)) ≤ + law p {ω | 0 < Z ω ∧ Z ω ≤ (N : ℝ≥0∞)} := by + convert hsmall using 1 + · congr 1 + ring + · simp only [ENNReal.ofReal_natCast] + congr 1 + apply (mul_le_mul' hsmall' le_rfl).trans_eq' + rw [←ENNReal.ofReal_mul (by positivity : 0 ≤ t/(4*A))] + congr 1 + change (t/(4*A))*ε=ε/(4*A)*t + ring + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakSurvival.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakSurvival.lean new file mode 100644 index 0000000000000000000000000000000000000000..b41c6439595bc474a0ea0d98b5f0469aebed9609 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalPeakSurvival.lean @@ -0,0 +1,112 @@ +import OAI.Probability.BenjaminiSchramm.SubcriticalPeakProbability +import OAI.Probability.BenjaminiSchramm.PeakSurvivalCauchy + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Encodable V] [Countable E] [Nontrivial V] + (G : BondGraph V E) [Fintype (criticalModel G).VertexOrbit] + +theorem subcritical_weighted_peak_survival + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (μ : (criticalModel G).VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep ((criticalModel G).orbitWalkKernel hl) μ=μ) + (hu : ¬(criticalModel G).CombinatoriallyUnimodular) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G e → w ∈ G e → + |(criticalModel G).orbitAdjustedHeight ((criticalModel G).stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp : 0 < (p : ℝ)) (hpc : p < pc G) + (O : (criticalModel G).OrbitRepresentatives) : + ∃ β : ℝ, R < β ∧ ∃ K : ℝ, 0 < K ∧ + (∀ n : ℕ, (criticalModel G).supAdjustedUpLayerMoment + ((criticalModel G).stationaryOrbitWeight μ) R p n ≤ ENNReal.ofReal (K*Real.exp (-β*n))) ∧ + ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, 0 < n → + ENNReal.ofReal (c*Real.exp (-(β-R)*n)) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal ((criticalModel G).stationaryOrbitWeight μ x)* + (criticalModel G).law p {ω | 0 < (criticalModel G).peakDownBandCount + ((criticalModel G).stationaryOrbitWeight μ) (R*((n : ℝ)+1)) (R*((n : ℝ)+4)) ω x} := by + let H := criticalModel G + let a := H.stationaryOrbitWeight μ + have hHc := criticalModel_connected G hc + have hapos := H.stationaryOrbitWeight_pos hHc hl μ hμ + have ha := H.stationaryOrbitWeight_aut μ + obtain ⟨β,hβR,K,hK,hup,c,hcpos,hpeak⟩ := subcritical_peak_band_probability G hc hl hq + μ hμ hstat hu R hR hjump p hp hpc + obtain ⟨m,_M,hm,hweights⟩ := H.stationaryOrbitWeight_uniform_bounds hHc hl μ hμ + obtain ⟨χ,hχ,hrow⟩ := subcritical_ennreal_row_bound G hl hq p hpc + obtain ⟨C,hC,hprofile⟩ := subcritical_full_layer_profile_at_rate G hc hl hq μ hμ + R hR hjump p hpc β K hβR hK hup + obtain ⟨K₂,hK₂,hsecond⟩ := H.adjusted_downward_layer_second_moment_at_rate hHc hl a R p β C hβR hC hprofile + let c₁ := m*c*Real.exp R + have hc₁ : 0 < c₁ := mul_pos (mul_pos hm hcpos) (Real.exp_pos _) + let B : ℝ≥0∞ := (∑ x ∈ O.roots, ENNReal.ofReal (a x))*(16*K₂) + have hB : B ≠ ⊤ := ENNReal.mul_ne_top + (ENNReal.sum_ne_top.mpr fun _ _ => ENNReal.ofReal_ne_top) + (ENNReal.mul_ne_top (by norm_num) hK₂.ne) + let D := B.toReal+1 + have hD : 0 < D := by dsimp [D]; positivity + have hBD : B ≤ ENNReal.ofReal D := by + rw [←ENNReal.ofReal_toReal hB] + exact ENNReal.ofReal_le_ofReal (by dsimp [D]; linarith) + refine ⟨β,hβR,K,hK,hup,c₁^2/D,div_pos (sq_pos_of_pos hc₁) hD,?_⟩ + intro n hn + let l := R*((n : ℝ)+1) + let u := R*((n : ℝ)+4) + let t := Real.exp (-(β-R)*n) + have ht : 0 < t := Real.exp_pos _ + have hpweighted : ENNReal.ofReal (m*c*Real.exp (-β*n)) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*H.law p (H.strictPeakBandEvent a l u x) := by + obtain ⟨x,hx⟩ := hpeak n hn + calc + _ = ENNReal.ofReal m*ENNReal.ofReal (c*Real.exp (-β*n)) := by + rw [←ENNReal.ofReal_mul hm.le] + congr 1 + ring + _ ≤ ENNReal.ofReal m*H.law p (H.strictPeakBandEvent a l u x) := mul_le_mul' le_rfl hx + _ ≤ _ := H.strictPeakBandEvent_probability_le_weighted_roots O a ha m + (fun x => (hweights x).1) p l u x + have hfirst : ENNReal.ofReal (c₁*t) ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*(∫⁻ ω, H.peakDownBandCount a l u ω x ∂H.law p) := by + have heq : ENNReal.ofReal (c₁*t)= + ENNReal.ofReal (Real.exp l)*ENNReal.ofReal (m*c*Real.exp (-β*n)) := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _)] + congr 1 + change m*c*Real.exp R*Real.exp (-(β-R)*(n : ℝ))= + Real.exp (R*((n : ℝ)+1))*(m*c*Real.exp (-β*n)) + calc + _ = m*c*(Real.exp R*Real.exp (-(β-R)*(n : ℝ))) := by ring + _ = m*c*Real.exp (R+ -(β-R)*(n : ℝ)) := by rw [Real.exp_add] + _ = _ := by + rw [show R+ -(β-R)*(n : ℝ)=R*((n : ℝ)+1)+ -β*n by ring,Real.exp_add] + ring + rw [heq] + apply (mul_le_mul' le_rfl (hpweighted.trans + (H.expected_peakDownBandCount_lower O hHc hl a hapos ha p l u))).trans_eq + rw [←mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add, + add_neg_cancel,Real.exp_zero,ENNReal.ofReal_one,one_mul] + have hsec (x : V) : (∫⁻ ω, (H.peakDownBandCount a l u ω x)^2 ∂H.law p) ≤ (16*K₂)*ENNReal.ofReal t := by + exact H.peakDownBandCount_second_moment_bound hHc hl a R hR p β hβR K₂ + (fun k j x => hsecond k j x 0) n x + have hsecfin (x : V) : (∫⁻ ω, (H.peakDownBandCount a l u ω x)^2 ∂H.law p) ≠ ⊤ := + ne_top_of_le_ne_top (ENNReal.mul_ne_top (ENNReal.mul_ne_top (by norm_num) hK₂.ne) + ENNReal.ofReal_ne_top) (hsec x) + have hsectotal : (∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, (H.peakDownBandCount a l u ω x)^2 ∂H.law p)) ≤ ENNReal.ofReal (D*t) := by + calc + _ ≤ ∑ x ∈ O.roots, ENNReal.ofReal (a x)*((16*K₂)*ENNReal.ofReal t) := + Finset.sum_le_sum fun x _ => mul_le_mul' le_rfl (hsec x) + _ = B*ENNReal.ofReal t := by rw [←Finset.sum_mul]; dsimp [B]; ring + _ ≤ ENNReal.ofReal D*ENNReal.ofReal t := mul_le_mul' hBD le_rfl + _ = _ := (ENNReal.ofReal_mul hD.le).symm + exact H.peakDownBandCount_probability_lower_of_moments O a l u p _ ENNReal.ofReal_ne_top + hrow c₁ D t hc₁ hD ht hfirst (fun x _ => hsecfin x) hsectotal + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalUpperSecondMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalUpperSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..23275db9a4cbd73b5e05f70af7d0a001c88fd680 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalUpperSecondMoment.lean @@ -0,0 +1,86 @@ +import OAI.Probability.BenjaminiSchramm.SubcriticalLayerPrefactor + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] [Nonempty V] (G : BondGraph V E) + +theorem adjusted_upper_layer_second_moment_constant + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (p : unitInterval) (χ : ℝ) (hχ : 0 ≤ χ) + (hrow : ∀ x, (∑' y, G.law p {ω | Percolation.Conn G.ends ω x y}) ≤ ENNReal.ofReal χ) + (β K : ℝ) (hβ : 0 < β) (hK : 0 < K) + (hup : ∀ n : ℕ, G.supAdjustedUpLayerMoment a R p n ≤ ENNReal.ofReal (K*Real.exp (-β*n))) : + ∃ A : ℝ, 0 < A ∧ ∀ (n : ℕ) (x : V) (u : ℝ), + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | G.adjustedLayerIndex a R u x y ≤ (n : ℤ)}) + {y | G.adjustedLayerIndex a R u x y=(n : ℤ)} ω x)^2 ∂G.law p) ≤ + ENNReal.ofReal (A*Real.exp (-β*n)) := by + let S : ℕ → ℝ := fun n => (G.supAdjustedUpLayerMoment a R p n).toReal + have hne (n : ℕ) : G.supAdjustedUpLayerMoment a R p n ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.ofReal_ne_top (hup n) + have hS (n : ℕ) : 0 ≤ S n := ENNReal.toReal_nonneg + have hSEq (n : ℕ) : ENNReal.ofReal (S n)=G.supAdjustedUpLayerMoment a R p n := ENNReal.ofReal_toReal (hne n) + have hbound (n : ℕ) : S n ≤ χ := by + have hb : G.supAdjustedUpLayerMoment a R p n ≤ ENNReal.ofReal χ := by + apply iSup_le + intro x + apply iSup_le + intro u + exact restrictedLayerCount_expectation_le_row_bound G.ends p _ hrow _ _ x + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top hb + rwa [ENNReal.toReal_ofReal hχ] at hh + have hSK (n : ℕ) : S n ≤ K*Real.exp (-β*n) := by + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top (hup n) + rwa [ENNReal.toReal_ofReal (mul_nonneg hK.le (Real.exp_nonneg _))] at hh + have hdecay (n : ℕ) : S n ≤ K*Real.exp (-(3*β/4)*n) := by + apply (hSK n).trans + apply mul_le_mul_of_nonneg_left _ hK.le + apply Real.exp_le_exp.mpr + nlinarith [(Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + have hmul (n j : ℕ) : S (n+j) ≤ S n*S j := by + have hh := ENNReal.toReal_mono (ENNReal.mul_ne_top (hne n) (hne j)) + (G.supAdjustedUpLayerMoment_submultiplicative hc hl a R hR hjump p n j) + simpa only [ENNReal.toReal_mul] using hh + have hF (i : ℤ) : G.supAdjustedFullLayerMoment a R p i ≤ ENNReal.ofReal χ := + G.supAdjustedFullLayerMoment_le_row_bound a R p _ hrow i + have hFpos (n : ℕ) : G.supAdjustedFullLayerMoment a R p n ≤ ENNReal.ofReal (χ*S n) := by + apply (G.supAdjustedFullLayerMoment_up_bound hc hl a R hR hjump p _ hrow n).trans_eq + rw [←hSEq n] + rw [←ENNReal.ofReal_mul (hS n)] + congr 1 + ring + obtain ⟨A,hA,hsecond⟩ := signed_upper_convolution_bound S hS β K χ hβ hχ hbound hmul hdecay + (G.supAdjustedFullLayerMoment a R p) hF hFpos + have hprefix (n : ℕ) : prefixMaximum (fun j => Real.exp (β*j)*S j) n ≤ K := by + apply Finset.sup'_le + intro j _ + calc + _ ≤ Real.exp (β*j)*(K*Real.exp (-β*j)) := + mul_le_mul_of_nonneg_left (hSK j) (Real.exp_nonneg _) + _ = K := by + rw [show Real.exp (β*(j : ℝ))*(K*Real.exp (-β*j)) = + K*(Real.exp (β*j)*Real.exp (-β*j)) by ring,←Real.exp_add, + show β*(j : ℝ)+ -β*j=0 by ring,Real.exp_zero,mul_one] + refine ⟨A*K,mul_pos hA hK,?_⟩ + intro n x u + apply (G.adjusted_upper_layer_second_moment_bound hc hl a R p x u n).trans + have hb := hsecond n + simp only [hSEq] at hb + apply hb.trans + apply ENNReal.ofReal_le_ofReal + have hh := mul_le_mul_of_nonneg_left (hprefix n) (mul_nonneg hA.le (Real.exp_nonneg (-β*n))) + nlinarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubcriticalUpward.lean b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalUpward.lean new file mode 100644 index 0000000000000000000000000000000000000000..88c84306bfa5db9f937b726462d4ac018343e912 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubcriticalUpward.lean @@ -0,0 +1,45 @@ +import OAI.Probability.BenjaminiSchramm.CriticalUpwardDecay + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] [Nonempty V] (G : BondGraph V E) + +theorem subcritical_uniform_upward_exponential (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (p : unitInterval) (hp : p < pc G) : + ∃ C : ℝ, 0 < C ∧ ∀ x a, + (law p).real ((criticalModel G).weightHit (ENNReal.ofReal (Real.exp a)) x) ≤ + C * Real.exp (-a) := by + let H := criticalModel G + let hHq := criticalModel_quasiTransitive G hq + let S := ∑ o ∈ (H.orbitRepresentatives hHq).roots, H.tiltedSusceptibility p 1 o + have hS : S < ⊤ := ENNReal.sum_lt_top.mpr + (criticalModel_fullTiltedSusceptibility_lt_top_of_lt_pc G hc hl hq p hp) + have hχ (x : V) : H.tiltedSusceptibility p 1 x ≤ S := by + obtain ⟨o,ho,φ,rfl⟩ := (H.orbitRepresentatives hHq).cover x + rw [H.tiltedSusceptibility_aut] + exact Finset.single_le_sum (fun _ _ => bot_le) ho + refine ⟨S.toReal+1,by positivity,fun x a => ?_⟩ + have hb := ENNReal.toReal_mono hS.ne + ((H.weightHit_measure_mul_le p (ENNReal.ofReal (Real.exp a)) x).trans (hχ x)) + rw [ENNReal.toReal_mul,ENNReal.toReal_ofReal (Real.exp_pos a).le] at hb + have hlaw : H.law p = (law p : Measure (Set E)) := rfl + rw [hlaw] at hb + change Real.exp a * (law p).real (H.weightHit (ENNReal.ofReal (Real.exp a)) x) ≤ S.toReal at hb + have he : Real.exp a * Real.exp (-a) = 1 := by rw [← Real.exp_add]; simp + have hm := mul_le_mul_of_nonneg_right hb (Real.exp_pos (-a)).le + calc + _ = (Real.exp a * (law p).real (H.weightHit (ENNReal.ofReal (Real.exp a)) x)) * + Real.exp (-a) := by rw [mul_right_comm,he,one_mul] + _ ≤ S.toReal * Real.exp (-a) := hm + _ ≤ _ := mul_le_mul_of_nonneg_right (by linarith) (Real.exp_pos (-a)).le + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubdivisionConsequences.lean b/lean/OAI/Probability/BenjaminiSchramm/SubdivisionConsequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..5960844ce59dd9cc3b38fece7d188850dd088e90 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubdivisionConsequences.lean @@ -0,0 +1,314 @@ +import OAI.Probability.BenjaminiSchramm.Consequences +import OAI.Probability.BenjaminiSchramm.SubdivisionGeometry +import OAI.Probability.BenjaminiSchramm.EventMeasurability + +namespace OAI + +open MeasureTheory +open scoped Topology + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem percolationProbability_subdivision [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (q : unitInterval) (x : V) : + percolationProbability (subdivision G) q (.inl x) = + percolationProbability G (q ^ 2) x := by + unfold percolationProbability + congr 1 + rw [← law_map_subdivisionOpen G q, + Measure.map_apply (measurable_subdivisionOpen G) + (measurableSet_infinite_cluster (subdivision G) (.inl x)), + ← law_map_seriesOpen q, + Measure.map_apply measurable_seriesOpen (measurableSet_infinite_cluster G x)] + congr 1 + ext ν + exact not_congr (finite_cluster_subdivision_iff G hloc ν x) + +theorem subdivision_parameter_gap [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (q : unitInterval) : + ((q ^ 2 : unitInterval) : ℝ) - (pc G : ℝ) = + ((q : ℝ) - pc (subdivision G)) * ((q : ℝ) + pc (subdivision G)) := by + have hc := congrArg Subtype.val (pc_subdivision_sq G hloc) + change (q : ℝ) ^ 2 - (pc G : ℝ) = _ + change (pc (subdivision G) : ℝ) ^ 2 = (pc G : ℝ) at hc + rw [← hc] + ring + +theorem probabilityLaw_of_subdivision [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hθ : PercolationProbabilityLaw (subdivision G)) : + PercolationProbabilityLaw G := by + have hc : (0 : ℝ) < pc (subdivision G) := + pc_pos (subdivision G) (subdivision_locallyFinite G hloc) + (subdivision_quasiTransitive G hloc hqt) + intro x + obtain ⟨c, C, δ, hcp, hCp, hδ, hb⟩ := hθ (.inl x) + refine ⟨c / 2, C / (pc (subdivision G) : ℝ), δ * pc (subdivision G), + by positivity, div_pos hCp hc, mul_pos hδ hc, ?_⟩ + intro p hp hnear + let q := squareParameter.symm p + have hq2 : q ^ 2 = p := squareParameter.apply_symm_apply p + have hq : pc (subdivision G) < q := by + apply squareParameter.lt_iff_lt.mp + change pc (subdivision G) ^ 2 < q ^ 2 + rw [pc_subdivision_sq G hloc, hq2] + exact hp + have hgap := subdivision_parameter_gap G hloc q + rw [hq2] at hgap + have hqreal : (0 : ℝ) < (q : ℝ) - pc (subdivision G) := sub_pos.mpr hq + have hnearq : (q : ℝ) - pc (subdivision G) < δ := by + have hprod := mul_nonneg hqreal.le q.2.1 + nlinarith only [hgap, hnear, hprod, hc] + obtain ⟨hlo, hhi⟩ := hb q hq hnearq + rw [percolationProbability_subdivision G hloc q x, hq2] at hlo hhi + have hfac : (q : ℝ) + pc (subdivision G) ≤ 2 := + (add_le_add q.2.2 (pc (subdivision G)).2.2).trans_eq (by norm_num) + have hprod := mul_nonneg hqreal.le (sub_nonneg.mpr hfac) + have hbound : (p : ℝ) - pc G ≤ 2 * ((q : ℝ) - pc (subdivision G)) := by + nlinarith only [hgap, hprod] + constructor + · have hh := mul_le_mul_of_nonneg_left hbound hcp.le + nlinarith only [hlo, hh] + · apply hhi.trans + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hc).mpr + have hh := mul_le_mul_of_nonneg_left + (show ((q : ℝ) - pc (subdivision G)) * pc (subdivision G) ≤ + (p : ℝ) - pc G by + have hprod := mul_nonneg hqreal.le q.2.1 + nlinarith only [hgap, hprod]) hCp.le + simpa only [mul_assoc] using hh + +theorem graphDistance_subdivision (G : BondGraph V E) (x y : V) : + graphDistance (subdivision G) (.inl x) (.inl y) = 2 * graphDistance G x y := + subdivision_ambient_distance G x y + +theorem susceptibility_subdivision_bounds [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (d : ℕ) (hd : ∀ x, degree G x ≤ d) (q : unitInterval) + (hq : q < pc (subdivision G)) (x : V) : + susceptibility G (q ^ 2) x ≤ susceptibility (subdivision G) q (.inl x) ∧ + susceptibility (subdivision G) q (.inl x) ≤ + ((d : ℝ) + 1) * susceptibility G (q ^ 2) x := by + have hp : q ^ 2 < pc G := by + rw [← pc_subdivision_sq G hloc] + exact squareParameter.strictMono hq + let f := fun ω : Set E => ((cluster G ω x).ncard : ℝ) + let g := fun ω : Set (SubdivisionEdge G) => + ((cluster (subdivision G) ω (.inl x)).ncard : ℝ) + have hf : Measurable f := + (measurable_of_countable (fun n : ℕ => (n : ℝ))).comp (measurable_cluster_ncard G hloc x) + have hg : Measurable g := + (measurable_of_countable (fun n : ℕ => (n : ℝ))).comp + (measurable_cluster_ncard (subdivision G) (subdivision_locallyFinite G hloc) (.inl x)) + obtain ⟨hfi, hfe⟩ := susceptibility_eq_integral G hloc hqt (q ^ 2) hp x + obtain ⟨hgi, hge⟩ := susceptibility_eq_integral (subdivision G) + (subdivision_locallyFinite G hloc) (subdivision_quasiTransitive G hloc hqt) q hq (.inl x) + have hmpf : MeasurePreserving seriesOpen (law q : Measure (Set (E × Bool))) (law (q ^ 2)) := + ⟨measurable_seriesOpen, law_map_seriesOpen q⟩ + have hmpg : MeasurePreserving (subdivisionOpen G) + (law q : Measure (Set (E × Bool))) (law q) := + ⟨measurable_subdivisionOpen G, law_map_subdivisionOpen G q⟩ + have hfic : Integrable (f ∘ seriesOpen) (law q) := hmpf.integrable_comp_of_integrable hfi + have hgic : Integrable (g ∘ subdivisionOpen G) (law q) := hmpg.integrable_comp_of_integrable hgi + have hfe' : susceptibility G (q ^ 2) x = ∫ ν, f (seriesOpen ν) ∂law q := by + rw [hfe, ← law_map_seriesOpen q] + exact integral_map measurable_seriesOpen.aemeasurable hf.aestronglyMeasurable + have hge' : susceptibility (subdivision G) q (.inl x) = + ∫ ν, g (subdivisionOpen G ν) ∂law q := by + rw [hge, ← law_map_subdivisionOpen G q] + exact integral_map (measurable_subdivisionOpen G).aemeasurable hg.aestronglyMeasurable + have hfin : ∀ᵐ ν ∂(law q : Measure (Set (E × Bool))), (cluster G (seriesOpen ν) x).Finite := by + apply ae_of_ae_map (μ := (law q : Measure (Set (E × Bool)))) + (p := fun ω : Set E => (cluster G ω x).Finite) measurable_seriesOpen.aemeasurable + rw [law_map_seriesOpen] + exact subcritical_cluster_finite_ae G (q ^ 2) hp x + have hb : ∀ᵐ ν ∂(law q : Measure (Set (E × Bool))), + f (seriesOpen ν) ≤ g (subdivisionOpen G ν) ∧ + g (subdivisionOpen G ν) ≤ ((d : ℝ) + 1) * f (seriesOpen ν) := by + filter_upwards [hfin] with ν hν + obtain ⟨hlo, hhi⟩ := subdivision_cluster_ncard_bounds G hloc d hd ν x hν + constructor + · dsimp only [f, g] + exact_mod_cast hlo + · dsimp only [f, g] + exact_mod_cast hhi + rw [hfe', hge'] + refine ⟨integral_mono_ae hfic hgic (hb.mono fun _ h => h.1), ?_⟩ + rw [← integral_const_mul] + exact integral_mono_ae hgic (hfic.const_mul _) (hb.mono fun _ h => h.2) + +theorem susceptibilityLaw_of_subdivision [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hχ : SusceptibilityLaw (subdivision G)) : SusceptibilityLaw G := by + obtain ⟨d, _hdpos, hd⟩ := exists_degree_bound G hqt + have hc : (0 : ℝ) < pc (subdivision G) := + pc_pos (subdivision G) (subdivision_locallyFinite G hloc) + (subdivision_quasiTransitive G hloc hqt) + intro x + obtain ⟨c, C, δ, hcp, hCp, hδ, hb⟩ := hχ (.inl x) + refine ⟨c * pc (subdivision G) / ((d : ℝ) + 1), 2 * C, δ * pc (subdivision G), + by positivity, by positivity, mul_pos hδ hc, ?_⟩ + intro p hp hnear + let q := squareParameter.symm p + have hq2 : q ^ 2 = p := squareParameter.apply_symm_apply p + have hq : q < pc (subdivision G) := by + apply squareParameter.lt_iff_lt.mp + change q ^ 2 < pc (subdivision G) ^ 2 + rw [pc_subdivision_sq G hloc, hq2] + exact hp + have hgap : (pc G : ℝ) - p = + ((pc (subdivision G) : ℝ) - q) * ((q : ℝ) + pc (subdivision G)) := by + have hh := subdivision_parameter_gap G hloc q + rw [hq2] at hh + nlinarith only [hh] + have hqreal : (0 : ℝ) < (pc (subdivision G) : ℝ) - q := sub_pos.mpr hq + have hnearq : (pc (subdivision G) : ℝ) - q < δ := by + have hprod := mul_nonneg hqreal.le q.2.1 + nlinarith only [hgap, hnear, hprod, hc] + obtain ⟨hlo, hhi⟩ := hb q hq hnearq + obtain ⟨hcomp₁, hcomp₂⟩ := susceptibility_subdivision_bounds G hloc hqt d hd q hq x + rw [hq2] at hcomp₁ hcomp₂ + have hpReal : (0 : ℝ) < (pc G : ℝ) - p := sub_pos.mpr hp + have hdReal : (0 : ℝ) < (d : ℝ) + 1 := by positivity + have hfac : (q : ℝ) + pc (subdivision G) ≤ 2 := + (add_le_add q.2.2 (pc (subdivision G)).2.2).trans_eq (by norm_num) + have hlarge : ((pc (subdivision G) : ℝ) - q) * pc (subdivision G) ≤ + (pc G : ℝ) - p := by + have hprod := mul_nonneg hqreal.le q.2.1 + nlinarith only [hgap, hprod] + have hsmall : (pc G : ℝ) - p ≤ 2 * ((pc (subdivision G) : ℝ) - q) := by + have hprod := mul_nonneg hqreal.le (sub_nonneg.mpr hfac) + nlinarith only [hgap, hprod] + constructor + · have hbound := hlo.trans hcomp₂ + have hh := (div_le_iff₀ hqreal).mp hbound + apply (div_le_iff₀ hpReal).mpr + apply (div_le_iff₀ hdReal).mpr + have hχnonneg := susceptibility_nonneg G p x + have hmul := mul_le_mul_of_nonneg_right hlarge hχnonneg + have hmul' := mul_le_mul_of_nonneg_right hh hc.le + nlinarith only [hmul, hmul'] + · apply hcomp₁.trans + apply hhi.trans + apply (div_le_div_iff₀ hqreal hpReal).mpr + simpa only [mul_assoc, mul_left_comm] using mul_le_mul_of_nonneg_left hsmall hCp.le + +theorem PowerTail.of_sandwich {f g : ℕ → ℝ} {α : ℝ} (hg : PowerTail g α) + (k : ℕ) (hk : 0 < k) + (hlo : ∀ n, 0 < n → g (k * n) ≤ f n) + (hhi : ∀ n, 0 < n → f n ≤ g n) : PowerTail f α := by + obtain ⟨c, C, hc, hC, hb⟩ := hg + refine ⟨c * (k : ℝ) ^ (-α), C, + mul_pos hc (Real.rpow_pos_of_pos (Nat.cast_pos.mpr hk) _), hC, ?_⟩ + intro n hn + constructor + · calc + c * (k : ℝ) ^ (-α) * (n : ℝ) ^ (-α) = c * ((k * n : ℕ) : ℝ) ^ (-α) := by + rw [Nat.cast_mul, Real.mul_rpow (Nat.cast_nonneg k) (Nat.cast_nonneg n)] + ring + _ ≤ g (k * n) := (hb (k * n) (Nat.mul_pos hk hn)).1 + _ ≤ f n := hlo n hn + · exact (hhi n hn).trans (hb n hn).2 + +theorem PowerTail.of_rescale {f g : ℕ → ℝ} {α : ℝ} (hg : PowerTail g α) + (k : ℕ) (hk : 0 < k) (heq : ∀ n, 0 < n → f n = g (k * n)) : + PowerTail f α := by + obtain ⟨c, C, hc, hC, hb⟩ := hg + have hkpow : 0 < (k : ℝ) ^ (-α) := Real.rpow_pos_of_pos (Nat.cast_pos.mpr hk) _ + refine ⟨c * (k : ℝ) ^ (-α), C * (k : ℝ) ^ (-α), mul_pos hc hkpow, mul_pos hC hkpow, ?_⟩ + intro n hn + rw [heq n hn] + have he (a : ℝ) : a * (k : ℝ) ^ (-α) * (n : ℝ) ^ (-α) = + a * ((k * n : ℕ) : ℝ) ^ (-α) := by + rw [Nat.cast_mul, Real.mul_rpow (Nat.cast_nonneg k) (Nat.cast_nonneg n)] + ring + rw [he c, he C] + exact hb (k * n) (Nat.mul_pos hk hn) + +theorem subdivision_event_probability_le [Countable V] [Countable E] + (G : BondGraph V E) (q : unitInterval) + (A : Set (Set (SubdivisionEdge G))) (B : Set (Set E)) + (hA : MeasurableSet A) (hB : MeasurableSet B) + (h : ∀ ν, subdivisionOpen G ν ∈ A → seriesOpen ν ∈ B) : + (law q).real A ≤ (law (q ^ 2)).real B := by + rw [measureReal_def, measureReal_def, + ← law_map_subdivisionOpen G q, + Measure.map_apply (measurable_subdivisionOpen G) hA, + ← law_map_seriesOpen q, Measure.map_apply measurable_seriesOpen hB] + apply ENNReal.toReal_mono (measure_ne_top _ _) + exact measure_mono h + +theorem subdivision_event_probability_ge [Countable V] [Countable E] + (G : BondGraph V E) (q : unitInterval) + (A : Set (Set (SubdivisionEdge G))) (B : Set (Set E)) + (hA : MeasurableSet A) (hB : MeasurableSet B) + (h : ∀ ν, seriesOpen ν ∈ B → subdivisionOpen G ν ∈ A) : + (law (q ^ 2)).real B ≤ (law q).real A := by + rw [measureReal_def, measureReal_def, + ← law_map_subdivisionOpen G q, + Measure.map_apply (measurable_subdivisionOpen G) hA, + ← law_map_seriesOpen q, Measure.map_apply measurable_seriesOpen hB] + apply ENNReal.toReal_mono (measure_ne_top _ _) + exact measure_mono h + +theorem criticalTailLaws_of_subdivision [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (h : CriticalTailLaws (subdivision G)) : CriticalTailLaws G := by + obtain ⟨d, _hd, hd⟩ := exists_degree_bound G hqt + intro x + obtain ⟨hv, hi, he⟩ := h (.inl x) + have hlocH := subdivision_locallyFinite G hloc + have hpc := pc_subdivision_sq G hloc + have hvolume₁ (n : ℕ) : + criticalTail G (volumeEvent G) x n ≤ + criticalTail (subdivision G) (volumeEvent (subdivision G)) (.inl x) n := by + unfold criticalTail + rw [← hpc] + exact subdivision_event_probability_ge G (pc (subdivision G)) _ _ + (measurableSet_volumeEvent _ _ _) (measurableSet_volumeEvent _ _ _) + (fun ν => subdivision_volumeEvent_lower G ν x n) + have hvolume₂ (n : ℕ) : + criticalTail (subdivision G) (volumeEvent (subdivision G)) (.inl x) ((d + 1) * n) ≤ + criticalTail G (volumeEvent G) x n := by + unfold criticalTail + rw [← hpc] + exact subdivision_event_probability_le G (pc (subdivision G)) _ _ + (measurableSet_volumeEvent _ _ _) (measurableSet_volumeEvent _ _ _) + (fun ν => subdivision_volumeEvent_upper G hloc d hd ν x n) + have hiEq (n : ℕ) : criticalTail G (intrinsicRadiusEvent G) x n = + criticalTail (subdivision G) (intrinsicRadiusEvent (subdivision G)) (.inl x) (2 * n) := by + apply le_antisymm + · unfold criticalTail + rw [← hpc] + exact subdivision_event_probability_ge G (pc (subdivision G)) _ _ + (measurableSet_intrinsicRadiusEvent _ hlocH _ _) (measurableSet_intrinsicRadiusEvent _ hloc _ _) + (fun ν => (subdivision_intrinsicRadiusEvent G ν x n).mpr) + · unfold criticalTail + rw [← hpc] + exact subdivision_event_probability_le G (pc (subdivision G)) _ _ + (measurableSet_intrinsicRadiusEvent _ hlocH _ _) (measurableSet_intrinsicRadiusEvent _ hloc _ _) + (fun ν => (subdivision_intrinsicRadiusEvent G ν x n).mp) + have heEq (n : ℕ) : criticalTail G (extrinsicRadiusEvent G) x n = + criticalTail (subdivision G) (extrinsicRadiusEvent (subdivision G)) (.inl x) (2 * n) := by + apply le_antisymm + · unfold criticalTail + rw [← hpc] + exact subdivision_event_probability_ge G (pc (subdivision G)) _ _ + (measurableSet_extrinsicRadiusEvent _ _ _) (measurableSet_extrinsicRadiusEvent _ _ _) + (fun ν => (subdivision_extrinsicRadiusEvent G ν x n).mpr) + · unfold criticalTail + rw [← hpc] + exact subdivision_event_probability_le G (pc (subdivision G)) _ _ + (measurableSet_extrinsicRadiusEvent _ _ _) (measurableSet_extrinsicRadiusEvent _ _ _) + (fun ν => (subdivision_extrinsicRadiusEvent G ν x n).mp) + exact ⟨hv.of_sandwich (d + 1) (by omega) (fun n _ => hvolume₂ n) (fun n _ => hvolume₁ n), + hi.of_rescale 2 (by norm_num) (fun n _ => hiEq n), + he.of_rescale 2 (by norm_num) (fun n _ => heEq n)⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubdivisionGeometry.lean b/lean/OAI/Probability/BenjaminiSchramm/SubdivisionGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dc3fef44b89924d8d3e60c8aab377c1eed413ae --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubdivisionGeometry.lean @@ -0,0 +1,261 @@ +import OAI.Probability.BenjaminiSchramm.PublishedConsequences +import OAI.Probability.UnimodularPercolation.Subdivision.Coupling +import OAI.Probability.UnimodularPercolation.Deformation.Derivatives + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem subdivision_open_adj_inl_inr (G : BondGraph V E) (ν : Set (E × Bool)) + (x : V) (e : E) : + (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Adj (.inl x) (.inr e) ↔ + ∃ hx : x ∈ G e, (⟨(e, x), hx⟩ : SubdivisionEdge G) ∈ subdivisionOpen G ν := by + change (_ ≠ _ ∧ ∃ d ∈ subdivisionOpen G ν, subdivision G d = s(Sum.inl x, Sum.inr e)) ↔ _ + rw [and_iff_right (by simp)] + exact subdivision_open_adj_iff G ν x e + +theorem exists_subdivision_lift_walk (G : BondGraph V E) (ν : Set (E × Bool)) + {x y : V} (w : (openSimpleGraph G (seriesOpen ν)).Walk x y) : + ∃ q : (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Walk (.inl x) (.inl y), + q.length = 2 * w.length := by + induction w with + | nil => exact ⟨.nil, rfl⟩ + | @cons x z y h w ih => + obtain ⟨e, he, heq⟩ := h.2 + have hx : x ∈ G e := by simp [heq] + have hz : z ∈ G e := by simp [heq] + have hxe : (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Adj + (.inl x) (.inr e) := + (subdivision_open_adj_inl_inr G ν x e).mpr ⟨hx, he _⟩ + have hze : (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Adj + (.inl z) (.inr e) := + (subdivision_open_adj_inl_inr G ν z e).mpr ⟨hz, he _⟩ + obtain ⟨q, hq⟩ := ih + refine ⟨.cons hxe (.cons hze.symm q), ?_⟩ + simp only [SimpleGraph.Walk.length_cons, hq] + omega + +theorem exists_subdivision_compress_walk (G : BondGraph V E) (ν : Set (E × Bool)) + {x y : V} + (w : (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Walk (.inl x) (.inl y)) : + ∃ q : (openSimpleGraph G (seriesOpen ν)).Walk x y, + 2 * q.length ≤ w.length := by + generalize hn : w.length = n + induction n using Nat.strong_induction_on generalizing x y with + | h n ih => + cases w with + | nil => exact ⟨.nil, by simp⟩ + | @cons _ z _ h₁ w => + cases z with + | inl z => exact (subdivision_adj_inl_inl G x z ⟨_, h₁.2.choose_spec.2⟩).elim + | inr e => + cases w with + | @cons _ z _ h₂ w => + cases z with + | inr f => exact (subdivision_adj_inr_inr G e f ⟨_, h₂.2.choose_spec.2⟩).elim + | inl z => + simp only [SimpleGraph.Walk.length_cons] at hn + have hlen : w.length < n := by + omega + obtain ⟨q, hq⟩ := ih w.length hlen w rfl + by_cases hxz : x = z + · subst z + refine ⟨q, ?_⟩ + omega + · obtain ⟨hx, hxo⟩ := (subdivision_open_adj_inl_inr G ν x e).mp h₁ + obtain ⟨hz, hzo⟩ := (subdivision_open_adj_inl_inr G ν z e).mp h₂.symm + have hseries := seriesOpen_of_two_incident G ν e x z hx hz hxz hxo hzo + have hadj : (openSimpleGraph G (seriesOpen ν)).Adj x z := + ⟨hxz, e, hseries, (Sym2.mem_and_mem_iff hxz).mp ⟨hx, hz⟩⟩ + refine ⟨.cons hadj q, ?_⟩ + simp only [SimpleGraph.Walk.length_cons] + omega + +theorem subdivision_open_distance (G : BondGraph V E) (ν : Set (E × Bool)) + (x y : V) : + (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).dist (.inl x) (.inl y) = + 2 * (openSimpleGraph G (seriesOpen ν)).dist x y := by + by_cases hc : Conn G (seriesOpen ν) x y + · have hr := (conn_iff_reachable G (seriesOpen ν) x y).mp hc + have hs := (conn_iff_reachable (subdivision G) (subdivisionOpen G ν) (.inl x) (.inl y)).mp + ((conn_subdivision_iff G ν x y).mpr hc) + obtain ⟨w, hw⟩ := hr.exists_walk_length_eq_dist + obtain ⟨q, hq⟩ := exists_subdivision_lift_walk G ν w + have hu : (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).dist (.inl x) (.inl y) ≤ + 2 * (openSimpleGraph G (seriesOpen ν)).dist x y := by + rw [← hw, ← hq] + exact SimpleGraph.dist_le q + obtain ⟨w', hw'⟩ := hs.exists_walk_length_eq_dist + obtain ⟨q', hq'⟩ := exists_subdivision_compress_walk G ν w' + have hl := Nat.mul_le_mul_left 2 (SimpleGraph.dist_le q') + omega + · have hr : ¬(openSimpleGraph G (seriesOpen ν)).Reachable x y := + fun h => hc ((conn_iff_reachable G (seriesOpen ν) x y).mpr h) + have hs : ¬(openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Reachable + (.inl x) (.inl y) := by + intro h + exact hc ((conn_subdivision_iff G ν x y).mp + ((conn_iff_reachable (subdivision G) (subdivisionOpen G ν) (.inl x) (.inl y)).mpr h)) + rw [SimpleGraph.dist_eq_zero_of_not_reachable hr, + SimpleGraph.dist_eq_zero_of_not_reachable hs, mul_zero] + +theorem subdivision_ambient_distance (G : BondGraph V E) (x y : V) : + graphDistance (subdivision G) (.inl x) (.inl y) = 2 * graphDistance G x y := by + have ho : subdivisionOpen G (Set.univ : Set (E × Bool)) = Set.univ := by + ext e + simp [subdivisionOpen] + have hs : seriesOpen (Set.univ : Set (E × Bool)) = Set.univ := by + ext e + simp [seriesOpen] + simpa only [graphDistance, ho, hs] using + subdivision_open_distance G Set.univ x y + +theorem subdivision_cluster_ncard_bounds (G : BondGraph V E) (hloc : LocallyFinite G) + (d : ℕ) (hd : ∀ x, degree G x ≤ d) (ν : Set (E × Bool)) (x : V) + (hf : (cluster G (seriesOpen ν) x).Finite) : + (cluster G (seriesOpen ν) x).ncard ≤ + (cluster (subdivision G) (subdivisionOpen G ν) (.inl x)).ncard ∧ + (cluster (subdivision G) (subdivisionOpen G ν) (.inl x)).ncard ≤ + (d + 1) * (cluster G (seriesOpen ν) x).ncard := by + let S := hf.toFinset + let I := incidentSupport G hloc S + have hfin := (finite_cluster_subdivision_iff G hloc ν x).mpr hf + have hinl : (Sum.inl : V → V ⊕ E) '' cluster G (seriesOpen ν) x ⊆ + cluster (subdivision G) (subdivisionOpen G ν) (.inl x) := by + rintro _ ⟨y, hy, rfl⟩ + exact (conn_subdivision_iff G ν x y).mpr hy + have hcover : cluster (subdivision G) (subdivisionOpen G ν) (.inl x) ⊆ + (Sum.inl : V → V ⊕ E) '' cluster G (seriesOpen ν) x ∪ + (Sum.inr : E → V ⊕ E) '' (I : Set E) := by + intro z hz + cases z with + | inl y => exact Or.inl ⟨y, (conn_subdivision_iff G ν x y).mp hz, rfl⟩ + | inr e => + obtain ⟨y, hy, hye⟩ := conn_subdivision_inr G ν x e hz + apply Or.inr + refine ⟨e, ?_, rfl⟩ + exact (mem_incidentSupport G hloc S e).mpr ⟨y, hf.mem_toFinset.mpr hy, hye⟩ + constructor + · have hcard := Set.ncard_le_ncard hinl hfin + simpa only [Set.ncard_image_of_injective _ Sum.inl_injective] using hcard + · calc + _ ≤ ((Sum.inl : V → V ⊕ E) '' cluster G (seriesOpen ν) x ∪ + (Sum.inr : E → V ⊕ E) '' (I : Set E)).ncard := + Set.ncard_le_ncard hcover ((hf.image _).union (I.finite_toSet.image _)) + _ ≤ ((Sum.inl : V → V ⊕ E) '' cluster G (seriesOpen ν) x).ncard + + ((Sum.inr : E → V ⊕ E) '' (I : Set E)).ncard := Set.ncard_union_le _ _ + _ = (cluster G (seriesOpen ν) x).ncard + I.card := by + rw [Set.ncard_image_of_injective _ Sum.inl_injective, + Set.ncard_image_of_injective _ Sum.inr_injective, Set.ncard_coe_finset] + _ ≤ (cluster G (seriesOpen ν) x).ncard + S.card * d := + Nat.add_le_add_left (incidentSupport_card_le G hloc d hd S) _ + _ = (d + 1) * (cluster G (seriesOpen ν) x).ncard := by + simp only [S, Set.ncard_eq_toFinset_card _ hf] + ring + +theorem conn_subdivision_inr_adj (G : BondGraph V E) (ν : Set (E × Bool)) + (x : V) (e : E) + (hc : Conn (subdivision G) (subdivisionOpen G ν) (.inl x) (.inr e)) : + ∃ y, Conn G (seriesOpen ν) x y ∧ + (openSimpleGraph (subdivision G) (subdivisionOpen G ν)).Adj (.inl y) (.inr e) := by + rcases hc.cases_tail with h | ⟨z, hxz, hze⟩ + · cases h + · cases z with + | inl y => + exact ⟨y, (conn_subdivision_iff G ν x y).mp hxz, by exact ⟨by simp, hze⟩⟩ + | inr f => + obtain ⟨d, _, hd⟩ := hze + exact (subdivision_adj_inr_inr G f e ⟨d, hd⟩).elim + +theorem subdivision_intrinsicRadiusEvent (G : BondGraph V E) + (ν : Set (E × Bool)) (x : V) (n : ℕ) : + subdivisionOpen G ν ∈ intrinsicRadiusEvent (subdivision G) (.inl x) (2 * n) ↔ + seriesOpen ν ∈ intrinsicRadiusEvent G x n := by + constructor + · rintro ⟨z, hz, hdist⟩ + cases z with + | inl y => + refine ⟨y, (conn_subdivision_iff G ν x y).mp hz, ?_⟩ + rw [subdivision_open_distance G ν x y] at hdist + omega + | inr e => + obtain ⟨y, hy, hadj⟩ := conn_subdivision_inr_adj G ν x e hz + refine ⟨y, hy, ?_⟩ + have ht := hadj.reachable.dist_triangle_right (.inl x) + rw [SimpleGraph.dist_eq_one_iff_adj.mpr hadj, subdivision_open_distance G ν x y] at ht + omega + · rintro ⟨y, hy, hdist⟩ + refine ⟨.inl y, (conn_subdivision_iff G ν x y).mpr hy, ?_⟩ + rw [subdivision_open_distance G ν x y] + omega + +theorem subdivision_extrinsicRadiusEvent (G : BondGraph V E) + (ν : Set (E × Bool)) (x : V) (n : ℕ) : + subdivisionOpen G ν ∈ extrinsicRadiusEvent (subdivision G) (.inl x) (2 * n) ↔ + seriesOpen ν ∈ extrinsicRadiusEvent G x n := by + constructor + · rintro ⟨z, hz, hdist⟩ + cases z with + | inl y => + refine ⟨y, (conn_subdivision_iff G ν x y).mp hz, ?_⟩ + rw [subdivision_ambient_distance G x y] at hdist + omega + | inr e => + obtain ⟨y, hy, hadj⟩ := conn_subdivision_inr_adj G ν x e hz + refine ⟨y, hy, ?_⟩ + have hfull : (openSimpleGraph (subdivision G) Set.univ).Adj (.inl y) (.inr e) := by + obtain ⟨a, _, ha⟩ := hadj.2 + exact ⟨by simp, a, Set.mem_univ _, ha⟩ + have ht := hfull.reachable.dist_triangle_right (.inl x) + rw [SimpleGraph.dist_eq_one_iff_adj.mpr hfull] at ht + change graphDistance (subdivision G) (.inl x) (.inr e) ≤ + graphDistance (subdivision G) (.inl x) (.inl y) + 1 at ht + rw [subdivision_ambient_distance G x y] at ht + omega + · rintro ⟨y, hy, hdist⟩ + refine ⟨.inl y, (conn_subdivision_iff G ν x y).mpr hy, ?_⟩ + rw [subdivision_ambient_distance G x y] + omega + +theorem subdivision_volumeEvent_lower (G : BondGraph V E) + (ν : Set (E × Bool)) (x : V) (n : ℕ) + (h : seriesOpen ν ∈ volumeEvent G x n) : + subdivisionOpen G ν ∈ volumeEvent (subdivision G) (.inl x) n := by + change (n : ℕ∞) ≤ (cluster G (seriesOpen ν) x).encard at h + change (n : ℕ∞) ≤ (cluster (subdivision G) (subdivisionOpen G ν) (.inl x)).encard + apply h.trans + exact Set.encard_le_encard_of_injOn + (fun y hy => (conn_subdivision_iff G ν x y).mpr hy) Sum.inl_injective.injOn + +theorem subdivision_volumeEvent_upper (G : BondGraph V E) (hloc : LocallyFinite G) + (d : ℕ) (hd : ∀ x, degree G x ≤ d) (ν : Set (E × Bool)) (x : V) (n : ℕ) + (h : subdivisionOpen G ν ∈ volumeEvent (subdivision G) (.inl x) ((d + 1) * n)) : + seriesOpen ν ∈ volumeEvent G x n := by + by_cases hf : (cluster G (seriesOpen ν) x).Finite + · have hfin := (finite_cluster_subdivision_iff G hloc ν x).mpr hf + have hb := (subdivision_cluster_ncard_bounds G hloc d hd ν x hf).2 + have hcard : (d + 1) * n ≤ + (cluster (subdivision G) (subdivisionOpen G ν) (.inl x)).ncard := by + change (((d + 1) * n : ℕ) : ℕ∞) ≤ + (cluster (subdivision G) (subdivisionOpen G ν) (.inl x)).encard at h + rw [← hfin.cast_ncard_eq] at h + exact_mod_cast h + have hn : n ≤ (cluster G (seriesOpen ν) x).ncard := by + exact Nat.le_of_mul_le_mul_left (hcard.trans hb) (by omega : 0 < d + 1) + change (n : ℕ∞) ≤ (cluster G (seriesOpen ν) x).encard + rw [← hf.cast_ncard_eq] + exact_mod_cast hn + · change (n : ℕ∞) ≤ (cluster G (seriesOpen ν) x).encard + rw [Set.Infinite.encard_eq (Set.not_finite.mp hf)] + exact le_top + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SubdivisionOperator.lean b/lean/OAI/Probability/BenjaminiSchramm/SubdivisionOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..b47ba0c6eb106e988a9669c8459d411a3f2c8c13 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SubdivisionOperator.lean @@ -0,0 +1,227 @@ +import OAI.Probability.BenjaminiSchramm.SubdivisionGeometry +import OAI.Probability.UnimodularPercolation.Subdivision.Operator + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable +noncomputable local instance : DecidableEq (V ⊕ E) := Classical.decEq _ + +noncomputable def endpointRow (G : BondGraph V E) : V ⊕ E → Finset V + | .inl x => {x} + | .inr e => (G e).toFinset + +theorem endpointRow_card_le (G : BondGraph V E) (z : V ⊕ E) : + (endpointRow G z).card ≤ 2 := by + cases z with + | inl x => simp [endpointRow] + | inr e => simp only [endpointRow, Sym2.card_toFinset]; split_ifs <;> omega + +noncomputable def incidenceKernel (G : BondGraph V E) (z w : V ⊕ E) : ℝ := + if w ∈ (endpointRow G z).map ⟨Sum.inl, Sum.inl_injective⟩ then 1 else 0 + +theorem exists_incidence_operator (G : BondGraph V E) (hloc : LocallyFinite G) + (d : ℕ) (hd : ∀ x, degree G x ≤ d) : + ∃ Q : Hilbert (V ⊕ E) →L[ℂ] Hilbert (V ⊕ E), + ∀ z w, matrixCoeff Q z w = (incidenceKernel G z w : ℂ) := by + have hrow : ∀ z (s : Finset (V ⊕ E)), ∑ w ∈ s, incidenceKernel G z w ≤ (d : ℝ) + 3 := by + intro z s + have hs : (s.filter fun w => w ∈ (endpointRow G z).map + ⟨Sum.inl, Sum.inl_injective⟩) ⊆ + (endpointRow G z).map ⟨Sum.inl, Sum.inl_injective⟩ := by + intro w hw; exact (Finset.mem_filter.mp hw).2 + have hc := (Finset.card_le_card hs).trans (by simpa using endpointRow_card_le G z) + simp only [incidenceKernel, Finset.sum_boole] + exact_mod_cast (show (s.filter fun w => w ∈ (endpointRow G z).map + ⟨Sum.inl, Sum.inl_injective⟩).card ≤ d + 3 by omega) + have hcol : ∀ w (s : Finset (V ⊕ E)), ∑ z ∈ s, incidenceKernel G z w ≤ (d : ℝ) + 3 := by + intro w s + cases w with + | inr e => simpa [incidenceKernel, Finset.mem_map] using (show (0 : ℝ) ≤ d + 3 by positivity) + | inl x => + let F : Finset (V ⊕ E) := {Sum.inl x} ∪ (hloc x).toFinset.map + ⟨Sum.inr, Sum.inr_injective⟩ + have hs : (s.filter fun z : V ⊕ E => (Sum.inl x : V ⊕ E) ∈ (endpointRow G z).map + ⟨Sum.inl, Sum.inl_injective⟩) ⊆ F := by + intro z hz + have hm := (Finset.mem_filter.mp hz).2 + cases z with + | inl y => simpa [endpointRow, F, eq_comm] using hm + | inr e => + have hx : x ∈ G e := by simpa [endpointRow, Finset.mem_map] using hm + simp [F, (hloc x).mem_toFinset.mpr hx] + have hc : F.card ≤ d + 1 := by + calc + F.card ≤ 1 + (hloc x).toFinset.card := by + simpa only [F, Finset.card_singleton, Finset.card_map] using + Finset.card_union_le ({Sum.inl x} : Finset (V ⊕ E)) + ((hloc x).toFinset.map ⟨Sum.inr, Sum.inr_injective⟩) + _ ≤ d + 1 := by + have hh := (incident_ncard_le_degree G hloc x).trans (hd x) + rw [Set.ncard_eq_toFinset_card _ (hloc x)] at hh + omega + simp only [incidenceKernel, Finset.sum_boole] + exact_mod_cast (show (s.filter fun z => Sum.inl x ∈ (endpointRow G z).map + ⟨Sum.inl, Sum.inl_injective⟩).card ≤ d + 3 from + (Finset.card_le_card hs).trans (hc.trans (by omega))) + obtain ⟨Q, _, hQ⟩ := exists_operator_of_row_column_bound (incidenceKernel G) + (d + 3) (by positivity) (by intros; dsimp [incidenceKernel]; split_ifs <;> norm_num) + hrow hcol + exact ⟨Q, hQ⟩ + +theorem conn_subdivision_endpoints (G : BondGraph V E) (ν : Set (E × Bool)) + (z w : V ⊕ E) (hc : Conn (subdivision G) (subdivisionOpen G ν) z w) : + ∃ x ∈ endpointRow G z, ∃ y ∈ endpointRow G w, Conn G (seriesOpen ν) x y := by + cases z with + | inl x => + cases w with + | inl y => exact ⟨x, by simp [endpointRow], y, by simp [endpointRow], + (conn_subdivision_iff G ν x y).mp hc⟩ + | inr e => + obtain ⟨y, hxy, hy⟩ := conn_subdivision_inr G ν x e hc + exact ⟨x, by simp [endpointRow], y, Sym2.mem_toFinset.mpr hy, hxy⟩ + | inr e => + cases w with + | inl y => + obtain ⟨x, hyx, hx⟩ := conn_subdivision_inr G ν y e (conn_symm _ _ hc) + exact ⟨x, Sym2.mem_toFinset.mpr hx, y, by simp [endpointRow], conn_symm _ _ hyx⟩ + | inr f => + rcases hc.cases_head with h | ⟨z, hez, hzf⟩ + · have hef : e = f := Sum.inr.inj h + subst f + exact ⟨(G e).out.1, Sym2.mem_toFinset.mpr (Sym2.out_fst_mem _), + (G e).out.1, Sym2.mem_toFinset.mpr (Sym2.out_fst_mem _), conn_refl _ _ _⟩ + · cases z with + | inl x => + obtain ⟨hx, _⟩ := (subdivision_open_adj_iff G ν x e).mp + (by obtain ⟨a, ha, he⟩ := hez; exact ⟨a, ha, he.trans Sym2.eq_swap⟩) + obtain ⟨y, hxy, hy⟩ := conn_subdivision_inr G ν x f hzf + exact ⟨x, Sym2.mem_toFinset.mpr hx, y, Sym2.mem_toFinset.mpr hy, hxy⟩ + | inr a => + obtain ⟨b, _, hb⟩ := hez + exact (subdivision_adj_inr_inr G e a ⟨b, hb⟩).elim + +theorem twoPoint_subdivision_le_endpoint_sum [Countable V] [Countable E] + (G : BondGraph V E) (q : unitInterval) (z w : V ⊕ E) : + twoPoint (subdivision G) q z w ≤ + ∑ x ∈ endpointRow G z, ∑ y ∈ endpointRow G w, twoPoint G (q ^ 2) x y := by + let μ : Measure (Set (E × Bool)) := law q + have : IsProbabilityMeasure μ := inferInstance + have ht (x y : V) : μ.real {ν | Conn G (seriesOpen ν) x y} = twoPoint G (q ^ 2) x y := by + unfold twoPoint + rw [← law_map_seriesOpen q, Measure.map_apply measurable_seriesOpen (measurableSet_conn G x y)] + rfl + have hh : twoPoint (subdivision G) q z w = + μ.real {ν | Conn (subdivision G) (subdivisionOpen G ν) z w} := by + unfold twoPoint + rw [← law_map_subdivisionOpen G q, Measure.map_apply (measurable_subdivisionOpen G) + (measurableSet_conn (subdivision G) z w)] + rfl + rw [hh] + calc + _ ≤ μ.real (⋃ ab ∈ endpointRow G z ×ˢ endpointRow G w, + {ν | Conn G (seriesOpen ν) ab.1 ab.2}) := by + refine measureReal_mono ?_ (measure_ne_top μ _) + intro ν hν + obtain ⟨x, hx, y, hy, hxy⟩ := conn_subdivision_endpoints G ν z w hν + exact Set.mem_iUnion.mpr ⟨(x, y), Set.mem_iUnion.mpr + ⟨Finset.mem_product.mpr ⟨hx, hy⟩, hxy⟩⟩ + _ ≤ ∑ ab ∈ endpointRow G z ×ˢ endpointRow G w, + μ.real {ν | Conn G (seriesOpen ν) ab.1 ab.2} := measureReal_biUnion_finset_le _ _ + _ = _ := by simp only [ht, Finset.sum_product] + +theorem incidence_operator_apply (G : BondGraph V E) + (Q : Hilbert (V ⊕ E) →L[ℂ] Hilbert (V ⊕ E)) + (hQ : ∀ z w, matrixCoeff Q z w = (incidenceKernel G z w : ℂ)) + (f : Hilbert (V ⊕ E)) (z : V ⊕ E) : + Q f z = ∑ x ∈ endpointRow G z, f (Sum.inl x) := by + rw [← (operator_kernel_hasSum Q f z).tsum_eq] + have hs : (∑' w, matrixCoeff Q z w * f w) = + ∑ w ∈ (endpointRow G z).map ⟨Sum.inl, Sum.inl_injective⟩, + matrixCoeff Q z w * f w := by + apply tsum_eq_sum + intro w hw + rw [hQ] + simp [incidenceKernel, hw] + rw [hs, Finset.sum_map] + apply Finset.sum_congr rfl + intro x hx + rw [hQ] + simp [incidenceKernel, hx] + +theorem incidence_adjoint_single (G : BondGraph V E) + (Q : Hilbert (V ⊕ E) →L[ℂ] Hilbert (V ⊕ E)) + (hQ : ∀ z w, matrixCoeff Q z w = (incidenceKernel G z w : ℂ)) + (w : V ⊕ E) : + hilbertRestrictInl (star Q (lp.single 2 w (1 : ℂ))) = + ∑ y ∈ endpointRow G w, lp.single 2 y (1 : ℂ) := by + apply lp.ext + funext x + rw [hilbertRestrictInl_apply] + change matrixCoeff (star Q) (Sum.inl x) w = _ + rw [matrixCoeff_adjoint, hQ] + simp only [incidenceKernel, Finset.mem_map, Function.Embedding.coeFn_mk, Sum.inl.injEq, + exists_eq_right, lp.coeFn_sum, lp.coeFn_single] + by_cases hx : x ∈ endpointRow G w <;> simp [Pi.single_apply, hx] + +theorem operatorBounded_subdivision_of_bounded [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (q : unitInterval) (hb : OperatorBounded G (q ^ 2)) : + OperatorBounded (subdivision G) q := by + obtain ⟨d, _, hd⟩ := exists_degree_bound G hqt + obtain ⟨Q, hQ⟩ := exists_incidence_operator G hloc d hd + obtain ⟨A, hA⟩ := hb + dsimp only [HasKernel] at hA + let B : Hilbert (V ⊕ E) →L[ℂ] Hilbert (V ⊕ E) := + Q ∘L hilbertInl ∘L A ∘L hilbertRestrictInl ∘L star Q + let U (z w : V ⊕ E) : ℝ := + ∑ x ∈ endpointRow G z, ∑ y ∈ endpointRow G w, twoPoint G (q ^ 2) x y + have hB (z w : V ⊕ E) : B (lp.single 2 w (1 : ℂ)) z = (U z w : ℂ) := by + simp only [B, ContinuousLinearMap.comp_apply] + rw [incidence_operator_apply G Q hQ, incidence_adjoint_single G Q hQ] + simp only [hilbertInl_apply_inl, map_sum, lp.coeFn_sum, Finset.sum_apply, hA, + U, Complex.ofReal_sum] + obtain ⟨T, _, hT⟩ := exists_operator_of_matrix_domination U + (twoPoint (subdivision G) q) + (fun z w => Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => + twoPoint_nonneg G (q ^ 2) x y) + (fun z w => by + rw [abs_of_nonneg (twoPoint_nonneg _ _ _ _)] + exact twoPoint_subdivision_le_endpoint_sum G q z w) B hB + exact ⟨T, hT⟩ + +theorem operatorBounded_subdivision_iff [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (q : unitInterval) : + OperatorBounded (subdivision G) q ↔ OperatorBounded G (q ^ 2) := + ⟨operatorBounded_of_subdivision G q, + operatorBounded_subdivision_of_bounded G hloc hqt q⟩ + +theorem ptwo_subdivision_sq [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) : + ptwo (subdivision G) ^ 2 = ptwo G := by + change squareParameter (sSup {q | OperatorBounded (subdivision G) q}) = + sSup {p | OperatorBounded G p} + have he : squareParameter '' {q | OperatorBounded (subdivision G) q} = + {p | OperatorBounded G p} := by + ext p + constructor + · rintro ⟨q, hq, rfl⟩ + exact (operatorBounded_subdivision_iff G hloc hqt q).mp hq + · intro hp + change OperatorBounded G p at hp + refine ⟨squareParameter.symm p, ?_, squareParameter.apply_symm_apply p⟩ + apply (operatorBounded_subdivision_iff G hloc hqt _).mpr + change OperatorBounded G (squareParameter (squareParameter.symm p)) + simpa only [squareParameter.apply_symm_apply] using hp + rw [squareParameter.map_sSup, ← sSup_image, he] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..7aea3593ee69ca7401e9ff5ee8093de4f1e0a084 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityComparison.lean @@ -0,0 +1,59 @@ +import OAI.Probability.BenjaminiSchramm.SusceptibilityDerivativeLower + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem exists_susceptibility_comparison [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (p₀ : ℝ) (hp₀ : 0 < p₀) : + ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ ∀ (p : unitInterval), p₀ ≤ (p : ℝ) → p < pc G → + ∀ x b, c * susceptibility G p x ≤ susceptibility G p b ∧ + susceptibility G p b ≤ C * susceptibility G p x := by + obtain ⟨O,hO⟩ := hqt + have hqt : QuasiTransitive G := ⟨O,hO⟩ + let ι := {o : V // o ∈ O} + let : Fintype ι := inferInstance + obtain ⟨o,ho,_⟩ := hO (Classical.arbitrary V) + let : Nonempty ι := ⟨⟨o,ho⟩⟩ + let root : ι → V := Subtype.val + let N : ℝ := Fintype.card ι + have hN : 0 < N := by + dsimp only [N] + exact_mod_cast Fintype.card_pos (α := ι) + let weight : ι → ℝ := fun _ => N⁻¹ + have hw (i : ι) : 0 ≤ weight i := inv_nonneg.mpr hN.le + have hw1 : ∑ i, weight i = 1 := by + simp only [weight,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + exact mul_inv_cancel₀ hN.ne' + have hcover (x : V) : ∃ i, x ∈ vertexOrbit G (root i) := by + obtain ⟨y,hy,a,b,hab,hax⟩ := hO x + exact ⟨⟨y,hy⟩,a,b,hab,hax⟩ + obtain ⟨a,ha,hlo⟩ := exists_rootSusceptibility_lower G hconn hloc hqt root weight + hw hw1 hcover p₀ hp₀ + have hupper (p : unitInterval) (x : V) : + susceptibility G p x ≤ N * rootSusceptibility G root weight p := + susceptibility_le_rootSusceptibility G root weight hw hcover N hN.le + (fun _ => by dsimp [weight]; rw [mul_inv_cancel₀ hN.ne']) p x + let c := a/N + have hc : 0 < c := div_pos ha hN + have hcomp (p : unitInterval) (hp : p₀ ≤ (p : ℝ)) (hpp : p < pc G) (x b : V) : + c * susceptibility G p x ≤ susceptibility G p b := by + calc + _ ≤ c * (N * rootSusceptibility G root weight p) := + mul_le_mul_of_nonneg_left (hupper p x) hc.le + _ = a * rootSusceptibility G root weight p := by + dsimp only [c] + rw [←mul_assoc,div_mul_cancel₀ a hN.ne'] + _ ≤ _ := hlo p hp hpp b + refine ⟨c,c⁻¹,hc,inv_pos.mpr hc,fun p hp hpp x b => ⟨hcomp p hp hpp x b,?_⟩⟩ + rw [inv_mul_eq_div] + exact (le_div_iff₀ hc).mpr (by simpa only [mul_comm] using hcomp p hp hpp b x) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityDerivative.lean b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..86c61013a644c873c3ee162fc0bb500efd9526a9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityDerivative.lean @@ -0,0 +1,109 @@ +import OAI.Probability.BenjaminiSchramm.SusceptibilityUpper +import OAI.Probability.UnimodularPercolation.Kernel.RussoRows + +namespace OAI + +open MeasureTheory Filter +open scoped Topology ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +noncomputable def realSusceptibility (G : BondGraph V E) (x : V) (t : ℝ) : ℝ := + ∑' y, realTwoPoint G x y t + +@[simp] theorem realSusceptibility_coe (G : BondGraph V E) (x : V) (p : unitInterval) : + realSusceptibility G x (p : ℝ) = susceptibility G p x := by + simp only [realSusceptibility,realTwoPoint_coe,susceptibility] + +theorem summable_russoSlope [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) (x : V) : + Summable (fun y => russoSlope G x y (p : ℝ)) := by + exact (summable_russoMajorant G hloc hqt p hp x).of_nonneg_of_le + (fun y => russoSlope_nonneg G x y p p.2.2) + (fun y => russoSlope_le_majorant G hloc hqt p p hp le_rfl x y) + +theorem hasDerivAt_realSusceptibility [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) (x : V) : + HasDerivAt (realSusceptibility G x) (∑' y, russoSlope G x y (p : ℝ)) p := by + obtain ⟨b,hpb,hb⟩ := exists_between hp + apply hasDerivAt_tsum_of_isPreconnected (summable_russoMajorant G hloc hqt b hb x) + isOpen_Ioo isPreconnected_Ioo + (fun y t ht => hasDerivAt_realTwoPoint_slope G hloc hqt t + ⟨ht.1,lt_trans ht.2 hb⟩ x y) + (fun y t ht => ?_) (show (p : ℝ) ∈ Set.Ioo 0 (b : ℝ) from ⟨hp0,hpb⟩) + (by simpa only [realTwoPoint_coe] using summable_twoPoint_subcritical G hloc hqt p hp x) + ⟨hp0,hpb⟩ + let q : unitInterval := ⟨t,ht.1.le,ht.2.le.trans b.2.2⟩ + rw [Real.norm_eq_abs,abs_of_nonneg (russoSlope_nonneg G x y t q.2.2)] + exact russoSlope_le_majorant G hloc hqt b q hb ht.2.le x y + +theorem susceptibility_derivative_upper [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (d : ℕ) (hd : ∀ z, degree G z ≤ d) (p : unitInterval) + (hp0 : 0 < (p : ℝ)) (hp : p < pc G) (C : ℝ) (hC0 : 0 ≤ C) + (hC : ∀ z, susceptibility G p z ≤ C) (x : V) : + deriv (realSusceptibility G x) p ≤ (d : ℝ) * C ^ 2 / (1 - p) := by + rw [(hasDerivAt_realSusceptibility G hloc hqt p hp0 hp x).deriv] + have hmajor := (summable_russoSlope G hloc hqt p hp x).tsum_le_tsum + (fun y => russoSlope_le_majorant G hloc hqt p p hp le_rfl x y) + (summable_russoMajorant G hloc hqt p hp x) + have hCenn (z : V) : (∑' y, law p {ω | Conn G ω z y}) ≤ ENNReal.ofReal C := by + rw [←ennreal_susceptibility G hloc hqt p hp z] + exact ENNReal.ofReal_le_ofReal (hC z) + have hdiag := russoDiagram_row_bound G hloc d hd p (ENNReal.ofReal C) hCenn x + have htop : (d : ℝ≥0∞) * ENNReal.ofReal C ^ 2 ≠ ⊤ := by finiteness + have hreal := ENNReal.toReal_mono htop hdiag + rw [ENNReal.toReal_mul,ENNReal.toReal_pow,ENNReal.toReal_natCast, + ENNReal.toReal_ofReal hC0] at hreal + apply hmajor.trans + simp only [russoMajorant,tsum_div_const] + rw [←ENNReal.tsum_toReal_eq (russoDiagram_ne_top G hloc hqt p hp x)] + exact div_le_div_of_nonneg_right hreal + (sub_nonneg.mpr p.2.2) + +theorem hasDerivAt_realRootSusceptibility [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + {ι : Type*} [Fintype ι] (root : ι → V) (weight : ι → ℝ) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) : + HasDerivAt (realRootSusceptibility G root weight) + (∑ i, weight i * (∑' y, russoSlope G (root i) y (p : ℝ))) p := by + have he : realRootSusceptibility G root weight = + fun t => ∑ i, weight i * realSusceptibility G (root i) t := by + funext t + simp only [realRootSusceptibility,rootSusceptibility,susceptibility, + realSusceptibility,realTwoPoint] + rw [he] + exact HasDerivAt.fun_sum (u := Finset.univ) (fun i _ => + (hasDerivAt_realSusceptibility G hloc hqt p hp0 hp (root i)).const_mul (weight i)) + +theorem rootSusceptibility_derivative_upper [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + {ι : Type*} [Fintype ι] (root : ι → V) (weight : ι → ℝ) + (hw : ∀ i, 0 ≤ weight i) (hw1 : ∑ i, weight i = 1) + (d : ℕ) (hd : ∀ z, degree G z ≤ d) (c : ℝ) (hc : 0 ≤ c) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) + (hC : ∀ z, susceptibility G p z ≤ c * rootSusceptibility G root weight p) : + deriv (realRootSusceptibility G root weight) p ≤ + (d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 / (1 - p) := by + rw [(hasDerivAt_realRootSusceptibility G hloc hqt root weight p hp0 hp).deriv] + have hrow (i : ι) : (∑' y, russoSlope G (root i) y (p : ℝ)) ≤ + (d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 / (1 - p) := by + have hh := susceptibility_derivative_upper G hloc hqt d hd p hp0 hp + (c * rootSusceptibility G root weight p) + (mul_nonneg hc (rootSusceptibility_nonneg G root weight hw p)) hC (root i) + rwa [(hasDerivAt_realSusceptibility G hloc hqt p hp0 hp (root i)).deriv] at hh + calc + _ ≤ ∑ i, weight i * + ((d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 / (1 - p)) := + Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (hrow i) (hw i)) + _ = _ := by rw [←Finset.sum_mul,hw1,one_mul] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityDerivativeLower.lean b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityDerivativeLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..83fba3cdcd4bb2f6c976d9530367ae29c5fcaf79 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityDerivativeLower.lean @@ -0,0 +1,57 @@ +import OAI.Probability.BenjaminiSchramm.SmallWalkKernel + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem susceptibility_derivative_nonneg [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) (x : V) : + 0 ≤ deriv (realSusceptibility G x) p := by + rw [(hasDerivAt_realSusceptibility G hloc hqt p hp0 hp x).deriv] + exact tsum_nonneg (fun y => russoSlope_nonneg G x y p p.2.2) + +theorem susceptibility_derivative_lower_of_kernel [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (p : unitInterval) (hp0 : 0 < (p : ℝ)) (hp : p < pc G) + (T K : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) + (hK : PositiveRealMatrix K) (d M : ℕ) (hd : ∀ a, degree G a ≤ d) + (hrow : ∀ a, ∑' b, ennMatrixCoeff K a b = 1) + (hsupport : ∀ a b, b ∉ reachBall G a M → ennMatrixCoeff K a b = 0) + (c C : ℝ) (hc : 0 ≤ c) (hC : 0 ≤ C) (x : V) + (hmin : ∀ b, c * susceptibility G p x ≤ susceptibility G p b) + (hmax : ∀ b, susceptibility G p b ≤ C * susceptibility G p x) + (hsmall : C * (‖T‖^3 * ‖K‖) ≤ c/2) : + (c/2) * (susceptibility G p x)^2 ≤ + (p : ℝ)^(-(M : ℤ)) * ((d+1)^M : ℕ) * (1 - (p : ℝ)) * + deriv (realSusceptibility G x) p := by + have hχ := susceptibility_nonneg G p x + have hder := susceptibility_derivative_nonneg G hloc hqt p hp0 hp x + have hl := kernelExteriorPotential_lower_of_critical G hloc hqt p hp T K hT hK hrow + (ENNReal.ofReal (c * susceptibility G p x)) (ENNReal.ofReal (C * susceptibility G p x)) + (fun b => ENNReal.ofReal_le_ofReal (hmin b)) + (fun b => ENNReal.ofReal_le_ofReal (hmax b)) x + have hu := kernelExteriorPotential_le_derivative G hloc hqt p hp0 hp d hd M + (ennMatrixCoeff K) hrow hsupport x + have hh := hl.trans (add_le_add hu le_rfl) + have hr := ENNReal.toReal_mono (by finiteness) hh + rw [ENNReal.toReal_add (by finiteness) (by finiteness)] at hr + simp only [ENNReal.toReal_mul,ENNReal.toReal_ofReal + (mul_nonneg hc hχ),ENNReal.toReal_ofReal (mul_nonneg hC hχ), + ENNReal.toReal_ofReal hχ,ENNReal.toReal_ofReal (zpow_nonneg p.2.1 _), + ENNReal.toReal_natCast,ENNReal.toReal_ofReal (sub_nonneg.mpr p.2.2), + ENNReal.toReal_ofReal hder,ENNReal.toReal_ofReal + (mul_nonneg (pow_nonneg (norm_nonneg T) _) (norm_nonneg K))] at hr + have he := mul_le_mul_of_nonneg_right hsmall (sq_nonneg (susceptibility G p x)) + nlinarith + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityLaw.lean b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe88642f025f316720482b5a81ec6350d2eafea9 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityLaw.lean @@ -0,0 +1,128 @@ +import OAI.Probability.BenjaminiSchramm.SusceptibilityDerivative +import OAI.Probability.BenjaminiSchramm.CriticalSusceptibility +import OAI.Probability.BenjaminiSchramm.ReciprocalGrowth + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem rootSusceptibility_lower_of_critical_volume + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hpc0 : 0 < (pc G : ℝ)) (hpc1 : (pc G : ℝ) < 1) + {ι : Type*} [Fintype ι] (root : ι → V) (weight : ι → ℝ) + (hw : ∀ i, 0 ≤ weight i) (hw1 : ∑ i, weight i = 1) + (hcover : ∀ x, ∃ i, x ∈ vertexOrbit G (root i)) + (c : ℝ) (hc : 0 < c) (hmin : ∀ i, 1 ≤ c * weight i) + (hvol : ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + ∃ k : ℝ, 0 < k ∧ ∀ p : unitInterval, + (pc G : ℝ) / 2 < p → p < pc G → + k / ((pc G : ℝ) - p) ≤ rootSusceptibility G root weight p := by + obtain ⟨d,hd,hdeg⟩ := exists_degree_bound G hqt + let K : ℝ := (d : ℝ) * c ^ 2 / (1 - pc G) + have hK : 0 < K := by dsimp [K]; positivity + have hparam (t : ℝ) (ht : t ∈ Set.Ioo ((pc G : ℝ) / 2) (pc G : ℝ)) : + t ∈ Set.Icc (0 : ℝ) 1 := + ⟨(by linarith [ht.1]),ht.2.le.trans (pc G).2.2⟩ + have hC (p : unitInterval) (z : V) : + susceptibility G p z ≤ c * rootSusceptibility G root weight p := + susceptibility_le_rootSusceptibility G root weight hw hcover c hc.le hmin p z + have hderiv (t : ℝ) (ht : t ∈ Set.Ioo ((pc G : ℝ) / 2) (pc G : ℝ)) : + deriv (realRootSusceptibility G root weight) t ≤ + K * realRootSusceptibility G root weight t ^ 2 := by + let p : unitInterval := ⟨t,hparam t ht⟩ + have hp0 : 0 < (p : ℝ) := by dsimp [p]; linarith [ht.1] + have hp : p < pc G := ht.2 + have hh := rootSusceptibility_derivative_upper G hloc hqt root weight hw hw1 + d hdeg c hc.le p hp0 hp (hC p) + have hnum : 0 ≤ (d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 := by positivity + have hden : 0 < 1 - (pc G : ℝ) := sub_pos.mpr hpc1 + have hle : + (d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 / (1 - p) ≤ + (d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 / (1 - pc G) := + div_le_div_of_nonneg_left hnum hden (by change 1 - (pc G : ℝ) ≤ 1 - t; linarith [ht.2]) + have he : + (d : ℝ) * (c * rootSusceptibility G root weight p) ^ 2 / (1 - pc G) = + K * rootSusceptibility G root weight p ^ 2 := by dsimp [K]; ring + change deriv (realRootSusceptibility G root weight) (p : ℝ) ≤ + K * realRootSusceptibility G root weight (p : ℝ) ^ 2 + rw [realRootSusceptibility_coe] + exact hh.trans (hle.trans_eq he) + have hunbounded (t : ℝ) (ht : t ∈ Set.Ioo ((pc G : ℝ) / 2) (pc G : ℝ)) + (B : ℝ) : ∃ s, t ≤ s ∧ s < (pc G : ℝ) ∧ + B < realRootSusceptibility G root weight s := by + let p : unitInterval := ⟨t,hparam t ht⟩ + let x : V := Classical.ofNonempty + obtain ⟨q,hpq,hq,hB⟩ := susceptibility_unbounded_below_critical G hloc hqt hpc0 + x (hvol x) p ht.2 (c * B) + refine ⟨q,hpq,hq,?_⟩ + rw [realRootSusceptibility_coe] + have hh := hB.trans_le (hC q x) + nlinarith + refine ⟨1 / K,one_div_pos.mpr hK,fun p hp0 hp => ?_⟩ + have hh := reciprocal_lower_of_derivative_upper + (realRootSusceptibility G root weight) ((pc G : ℝ) / 2) (pc G : ℝ) K hK + (fun t ht => by + let q : unitInterval := ⟨t,hparam t ht⟩ + have hh := rootSusceptibility_one_le G hloc hqt root weight hw hw1 q ht.2 + rw [←realRootSusceptibility_coe] at hh + exact zero_lt_one.trans_le hh) + (fun t ht => by + let q : unitInterval := ⟨t,hparam t ht⟩ + have hq0 : 0 < (q : ℝ) := by dsimp [q]; linarith [ht.1] + exact (hasDerivAt_realRootSusceptibility G hloc hqt root weight q hq0 ht.2).differentiableAt) + hderiv hunbounded p ⟨hp0,hp⟩ + simpa only [realRootSusceptibility_coe,div_div] using hh + +theorem susceptibilityLaw_of_critical_volume [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hpc1 : (pc G : ℝ) < 1) + (hvol : ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + SusceptibilityLaw G := by + obtain ⟨O,hO⟩ := hqt + have hqt : QuasiTransitive G := ⟨O,hO⟩ + have hOne : O.Nonempty := by + obtain ⟨o,ho,_⟩ := hO (Classical.ofNonempty : V) + exact ⟨o,ho⟩ + let : Nonempty O := hOne.to_subtype + let root : O → V := Subtype.val + let c : ℝ := Fintype.card O + let weight : O → ℝ := fun _ => 1 / c + have hc : 0 < c := by dsimp [c]; exact_mod_cast Fintype.card_pos + have hw (i : O) : 0 ≤ weight i := (one_div_pos.mpr hc).le + have hw1 : ∑ i, weight i = 1 := by + simp only [weight,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + change c * (1 / c) = 1 + exact mul_one_div_cancel hc.ne' + have hmin (i : O) : 1 ≤ c * weight i := by + dsimp [weight] + rw [mul_one_div_cancel hc.ne'] + have hcover (x : V) : ∃ i, x ∈ vertexOrbit G (root i) := by + obtain ⟨o,ho,a,b,hab,hax⟩ := hO x + exact ⟨⟨o,ho⟩,a,b,hab,hax⟩ + have hpc0 : 0 < (pc G : ℝ) := pc_pos G hloc hqt + obtain ⟨k,hk,hroot⟩ := rootSusceptibility_lower_of_critical_volume G hloc hqt hpc0 hpc1 + root weight hw hw1 hcover c hc hmin hvol + obtain ⟨a,ha,hlower⟩ := exists_rootSusceptibility_lower G hconn hloc hqt root weight + hw hw1 hcover ((pc G : ℝ) / 2) (by positivity) + obtain ⟨A,hA,hupper⟩ := susceptibility_upper_of_critical_volume G hqt hvol + intro x + refine ⟨a*k,A,(pc G : ℝ)/2,mul_pos ha hk,hA,by positivity,?_⟩ + intro p hp hnear + have hp0 : (pc G : ℝ) / 2 < p := by linarith + refine ⟨?_,hupper p hp x⟩ + calc + a*k / ((pc G : ℝ) - p) = a * (k / ((pc G : ℝ) - p)) := by ring + _ ≤ a * rootSusceptibility G root weight p := + mul_le_mul_of_nonneg_left (hroot p hp0 hp) ha.le + _ ≤ susceptibility G p x := hlower p hp0.le hp x + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityUpper.lean b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..69e13341521a8514f0d4c07bfe67e0df236a9d17 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/SusceptibilityUpper.lean @@ -0,0 +1,184 @@ +import OAI.Probability.BenjaminiSchramm.GhostCritical + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem finite_tail_square_scale [Countable E] + (G : BondGraph V E) (C : ℝ) (hC : 0 < C) + (hvol : ∀ x n, 0 < n → criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n) + (Q : Finset E) (x : V) (p : unitInterval) (hp : p ≤ pc G) + (m n : ℕ) (hm : 0 < m) (hmC : 12 * C ≤ m) (hmn : m ^ 2 ≤ n) : + finiteClusterTail G Q x n p ≤ + (6 * C / m) * Real.exp (-((pc G : ℝ) - p) * m / (24 * C)) := by + have hmR : 0 < (m : ℝ) := by exact_mod_cast hm + have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast hm + let h : unitInterval := ⟨1 / (m : ℝ) ^ 2,⟨by positivity, + (div_le_one (by positivity)).mpr (by nlinarith)⟩⟩ + have hh : (h : ℝ) * (m : ℝ) ^ 2 = 1 := by dsimp [h]; field_simp + have hn : 1 ≤ (h : ℝ) * n := by + rw [←hh] + apply mul_le_mul_of_nonneg_left _ h.2.1 + exact_mod_cast hmn + have hB0 : 0 < 3 * C / m := by positivity + have hsmall : 3 * C / m ≤ 1 / 4 := by + apply (div_le_iff₀ hmR).mpr + linarith + have hb (r : unitInterval) (_hpr : p ≤ r) (hr : r ≤ pc G) (y : V) := + critical_ghost_bound_at_square_scale G C hC.le hvol Q y r h hr m hm hh.le + have ht := tail_transfer_of_ghost_bound G Q x n p (pc G) h (3 * C / m) + hp hn hB0 hsmall hb + have he : -((pc G : ℝ) - p) / (8 * (3 * C / m)) = + -((pc G : ℝ) - p) * m / (24 * C) := by field_simp; ring + rw [he] at ht + convert ht using 1; ring + +theorem finite_tail_antitone (G : BondGraph V E) (Q : Finset E) + (x : V) (p : unitInterval) : Antitone (fun n => finiteClusterTail G Q x n p) := by + intro n m hnm + apply bernoulliPolynomial_mono _ _ _ p p.2 + intro ω _ + dsimp [finiteClusterTailIndicator] + split_ifs <;> norm_num + omega + +theorem square_block_tail_sum (G : BondGraph V E) (Q : Finset E) + (x : V) (p : unitInterval) (m : ℕ) : + (∑ i ∈ Finset.Ico (m ^ 2) ((m + 1) ^ 2), finiteClusterTail G Q x (i + 1) p) ≤ + (2 * m + 1 : ℕ) * finiteClusterTail G Q x (m ^ 2) p := by + calc + _ ≤ ∑ _i ∈ Finset.Ico (m ^ 2) ((m + 1) ^ 2), finiteClusterTail G Q x (m ^ 2) p := by + apply Finset.sum_le_sum + intro i hi + exact finite_tail_antitone G Q x p ((Finset.mem_Ico.mp hi).1.trans (Nat.le_succ i)) + _ = _ := by + simp only [Finset.sum_const,Nat.card_Ico,nsmul_eq_mul] + congr 1 + have he : (m + 1) ^ 2 - m ^ 2 = 2 * m + 1 := by + have hh : (m + 1) ^ 2 = m ^ 2 + (2 * m + 1) := by ring + omega + rw [he] + +theorem sum_exp_neg_le (t : ℝ) (ht : 0 < t) (N : ℕ) : + (∑ i ∈ Finset.range N, Real.exp (-t * i)) ≤ 1 + 1 / t := by + have hq : Real.exp (-t) < 1 := Real.exp_lt_one_iff.mpr (by linarith) + have hden : 0 < 1 - Real.exp (-t) := sub_pos.mpr hq + have hsum : (∑ i ∈ Finset.range N, Real.exp (-t * i)) ≤ + 1 / (1 - Real.exp (-t)) := by + simp_rw [mul_comm (-t),Real.exp_nat_mul] + apply (le_div_iff₀ hden).mpr + rw [geom_sum_mul_neg] + linarith [pow_nonneg (Real.exp_pos (-t)).le N] + apply hsum.trans + apply (div_le_iff₀ hden).mpr + have he := Real.add_one_le_exp t + have he0 := Real.exp_pos t + rw [Real.exp_neg] + apply (mul_le_mul_iff_right₀ he0).mp + field_simp + nlinarith + +theorem finite_mean_upper_from_volume [Countable E] + (G : BondGraph V E) (C : ℝ) (hC : 0 < C) + (hvol : ∀ x n, 0 < n → criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n) + (M : ℕ) (hM : 0 < M) (hMC : 12 * C ≤ M) + (Q : Finset E) (x : V) (p : unitInterval) (hp : p < pc G) : + bernoulliPolynomial Q (fun ω => ((finiteRootComponent G ω x).card : ℝ)) p ≤ + (M : ℝ) ^ 2 + 18 * C * (1 + 24 * C / ((pc G : ℝ) - p)) := by + let δ : ℝ := (pc G : ℝ) - p + have hδ : 0 < δ := sub_pos.mpr hp + let f := fun n => finiteClusterTail G Q x (n + 1) p + let g := fun m : ℕ => Real.exp (-(δ / (24 * C)) * m) + have hpartial (K : ℕ) : (∑ i ∈ Finset.range (K ^ 2), f i) ≤ + (M : ℝ) ^ 2 + 18 * C * (∑ m ∈ Finset.range K, g m) := by + induction K with + | zero => simp + | succ K ih => + by_cases hKM : K < M + · have hf1 : (∑ i ∈ Finset.range ((K + 1) ^ 2), f i) ≤ ((K + 1) ^ 2 : ℕ) := by + calc + _ ≤ ∑ _i ∈ Finset.range ((K + 1) ^ 2), (1 : ℝ) := + Finset.sum_le_sum (fun i _ => finiteClusterTail_le_one G Q x (i + 1) p) + _ = _ := by simp + have hsq : (((K + 1) ^ 2 : ℕ) : ℝ) ≤ (M : ℝ) ^ 2 := by + exact_mod_cast Nat.pow_le_pow_left (show K + 1 ≤ M by omega) 2 + have hg0 : 0 ≤ 18 * C * (∑ m ∈ Finset.range (K + 1), g m) := + mul_nonneg (by positivity) (Finset.sum_nonneg (fun _ _ => (Real.exp_pos _).le)) + exact hf1.trans (hsq.trans (le_add_of_nonneg_right hg0)) + · have hMK : M ≤ K := by omega + have hK : 0 < K := hM.trans_le hMK + have hKC : 12 * C ≤ K := hMC.trans (by exact_mod_cast hMK) + have ht := finite_tail_square_scale G C hC hvol Q x p hp.le K (K ^ 2) hK hKC le_rfl + have hblock := square_block_tail_sum G Q x p K + have hK1 : (1 : ℝ) ≤ K := by exact_mod_cast hK + have hratio : (2 * (K : ℝ) + 1) * (6 * C / K) ≤ 18 * C := by + rw [←mul_div_assoc] + apply (div_le_iff₀ (show 0 < (K : ℝ) by positivity)).mpr + nlinarith + have hblock' : (∑ i ∈ Finset.Ico (K ^ 2) ((K + 1) ^ 2), f i) ≤ 18 * C * g K := by + apply hblock.trans + apply (mul_le_mul_of_nonneg_left ht (by positivity : (0 : ℝ) ≤ (2 * K + 1 : ℕ))).trans + have he : -δ * K / (24 * C) = -(δ / (24 * C)) * K := by ring + change (2 * K + 1 : ℕ) * ((6 * C / K) * Real.exp (-δ * K / (24 * C))) ≤ _ + rw [he] + have hh := mul_le_mul_of_nonneg_right hratio (Real.exp_pos (-(δ / (24 * C)) * K)).le + push_cast + simpa only [mul_assoc,g] using hh + rw [←Finset.sum_range_add_sum_Ico f (Nat.pow_le_pow_left (Nat.le_succ K) 2), + Finset.sum_range_succ] + have hh := add_le_add ih hblock' + simpa only [mul_add,add_assoc] using hh + let N := (insert x (searchVertices G Q)).card + have hN : N ≤ N ^ 2 := Nat.le_self_pow two_ne_zero N + rw [finiteClusterSize_eq_sum_tail] + have hle : (∑ i ∈ Finset.range N, f i) ≤ ∑ i ∈ Finset.range (N ^ 2), f i := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono hN) + (fun i _ _ => finiteClusterTail_nonneg G Q x (i + 1) p) + apply (hle.trans (hpartial N)).trans + have ht : 0 < δ / (24 * C) := by positivity + have hs := sum_exp_neg_le (δ / (24 * C)) ht N + have he : 1 / (δ / (24 * C)) = 24 * C / δ := by field_simp + rw [he] at hs + exact add_le_add le_rfl + (mul_le_mul_of_nonneg_left hs (show 0 ≤ 18 * C by positivity)) + +theorem susceptibility_upper_of_critical_volume [Countable E] + (G : BondGraph V E) (hqt : QuasiTransitive G) + (hvol : ∀ x, PowerTail (criticalTail G (volumeEvent G) x) (1 / 2)) : + ∃ A : ℝ, 0 < A ∧ ∀ p : unitInterval, p < pc G → ∀ x, + susceptibility G p x ≤ A / ((pc G : ℝ) - p) := by + obtain ⟨C,hC,hb⟩ := uniform_critical_volume_upper_of_powerTail G hqt hvol + obtain ⟨M,hMC⟩ := exists_nat_gt (12 * C) + have hM : 0 < M := by + have hh : (0 : ℝ) < M := (by positivity : 0 < 12 * C).trans hMC + exact_mod_cast hh + let A : ℝ := (M : ℝ) ^ 2 + 18 * C + 432 * C ^ 2 + have hA : 0 < A := by dsimp [A]; positivity + refine ⟨A,hA,?_⟩ + intro p hp x + have hδ : 0 < (pc G : ℝ) - p := sub_pos.mpr hp + have hδ1 : (pc G : ℝ) - p ≤ 1 := by linarith [(pc G).2.2,p.2.1] + have hbound := (susceptibility_bound_of_finite_size G x p + ((M : ℝ) ^ 2 + 18 * C * (1 + 24 * C / ((pc G : ℝ) - p))) + (fun Q => finite_mean_upper_from_volume G C hC hb M hM hMC.le Q x p hp)).2 + apply hbound.trans + apply (le_div_iff₀ hδ).mpr + have hbase := mul_le_mul_of_nonneg_left hδ1 + (show 0 ≤ (M : ℝ) ^ 2 + 18 * C by positivity) + have hid : + ((M : ℝ) ^ 2 + 18 * C * (1 + 24 * C / ((pc G : ℝ) - p))) * + ((pc G : ℝ) - p) = + ((M : ℝ) ^ 2 + 18 * C) * ((pc G : ℝ) - p) + 432 * C ^ 2 := by + field_simp + ring + rw [hid] + dsimp [A] + linarith + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ThinSphere.lean b/lean/OAI/Probability/BenjaminiSchramm/ThinSphere.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf3b4018f2c1bf7c29387ae6f5e43343195dac1e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ThinSphere.lean @@ -0,0 +1,79 @@ +import OAI.Probability.BenjaminiSchramm.IntrinsicSphere + +namespace OAI + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem exists_thin_intrinsicSphere (G : BondGraph V E) (hloc : LocallyFinite G) + (ω : Set E) (x : V) (r k : ℕ) (hf : (cluster G ω x).Finite) + (hsmall : (cluster G ω x).ncard < (r+1)*(k+1)) : + ∃ j ∈ Finset.Icc r (2*r), (intrinsicSphere G ω x j).ncard ≤ k := by + by_contra hnot + push Not at hnot + let F : ℕ → Finset V := fun j => (intrinsicSphere_finite G hloc ω x j).toFinset + have hdisj : (↑(Finset.Icc r (2*r)) : Set ℕ).PairwiseDisjoint F := by + intro i _ j _ hij + apply Finset.disjoint_left.mpr + intro y hi hj + exact Set.disjoint_left.mp (intrinsicSphere_disjoint G ω x hij) + ((intrinsicSphere_finite G hloc ω x i).mem_toFinset.mp hi) + ((intrinsicSphere_finite G hloc ω x j).mem_toFinset.mp hj) + have hsub : (Finset.Icc r (2*r)).biUnion F ⊆ hf.toFinset := by + intro y hy + obtain ⟨j,_,hj⟩ := Finset.mem_biUnion.mp hy + exact hf.mem_toFinset.mpr ((intrinsicSphere_finite G hloc ω x j).mem_toFinset.mp hj).1 + have hcards := Finset.card_le_card hsub + rw [Finset.card_biUnion hdisj] at hcards + have hlo : (r+1)*(k+1) ≤ ∑ j ∈ Finset.Icc r (2*r), (F j).card := by + calc + _ = ∑ j ∈ Finset.Icc r (2*r), (k+1) := by + rw [Finset.sum_const_nat (fun _ _ => rfl), Nat.card_Icc] + have he : 2*r+1-r = r+1 := by omega + rw [he] + _ ≤ _ := Finset.sum_le_sum (fun j hj => by + have h := hnot j hj + change k < (intrinsicSphere G ω x j).ncard at h + rw [Set.ncard_eq_toFinset_card _ (intrinsicSphere_finite G hloc ω x j)] at h + exact h) + have he : hf.toFinset.card = (cluster G ω x).ncard := (Set.ncard_eq_toFinset_card _ hf).symm + rw [he] at hcards + omega + +def thinSphereCell (G : BondGraph V E) (S : Set E) (x : V) (r k j : ℕ) + (U W : Finset V) : Set (Set E) := + {ω | r ≤ j ∧ j ≤ 2*r ∧ intrinsicBall G (ω ∩ S) x (j-1) = U ∧ + intrinsicBall G (ω ∩ S) x j = W ∧ + (intrinsicSphere G (ω ∩ S) x j).ncard ≤ k ∧ + ∀ i, r ≤ i → i < j → k < (intrinsicSphere G (ω ∩ S) x i).ncard} + +theorem thinSphereCell_pairwise (G : BondGraph V E) (S : Set E) (x : V) (r k : ℕ) : + Pairwise (fun a b : ℕ × Finset V × Finset V => + Disjoint (thinSphereCell G S x r k a.1 a.2.1 a.2.2) + (thinSphereCell G S x r k b.1 b.2.1 b.2.2)) := by + intro a b hab + apply Set.disjoint_left.mpr + rintro ω ha hb + have hj : a.1 = b.1 := by + by_contra hne + rcases lt_or_gt_of_ne hne with h | h + · exact (not_lt_of_ge ha.2.2.2.2.1) (hb.2.2.2.2.2 a.1 ha.1 h) + · exact (not_lt_of_ge hb.2.2.2.2.1) (ha.2.2.2.2.2 b.1 hb.1 h) + have hU : a.2.1 = b.2.1 := by + apply Finset.coe_injective + have haU : intrinsicBall G (ω ∩ S) x (b.1-1) = (a.2.1 : Set V) := by + simpa only [hj] using ha.2.2.1 + exact haU.symm.trans hb.2.2.1 + have hW : a.2.2 = b.2.2 := by + apply Finset.coe_injective + have haW : intrinsicBall G (ω ∩ S) x b.1 = (a.2.2 : Set V) := by + simpa only [hj] using ha.2.2.2.1 + exact haW.symm.trans hb.2.2.2.1 + exact hab (Prod.ext hj (Prod.ext hU hW)) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ThinSphereExposure.lean b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..9645ba68106f85055d8ac5f0c183840a3dc7e854 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereExposure.lean @@ -0,0 +1,102 @@ +import OAI.Probability.BenjaminiSchramm.ThinSphere + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem measurable_finite_local_nat (Q : Finset E) (f : Set E → ℕ) + (hf : ∀ ω, f ω = f (ω ∩ (Q : Set E))) : Measurable f := by + let g : Set (Q : Set E) → ℕ := fun η => f (Subtype.val '' η) + have he : f = g ∘ (fun ω : Set E => (Subtype.val ⁻¹' ω : Set (Q : Set E))) := by + funext ω + rw [hf ω] + congr 1 + ext e + simp [and_comm] + rw [he] + exact (measurable_of_finite g).comp (measurable_set_restrict (Q : Set E)) + +theorem measurable_intrinsicSphere_ncard (G : BondGraph V E) (hloc : LocallyFinite G) + (S : Set E) (x : V) (n : ℕ) (hn : 0 < n) : + Measurable (fun ω => (intrinsicSphere G (ω ∩ S) x n).ncard) := by + let Q := incidentSupport G hloc (finite_reachBall hloc x n).toFinset + apply measurable_finite_local_nat Q + intro ω + have hballs := intrinsicBall_history_eq_of_incident_agreement G + (ω ∩ S) ((ω ∩ (Q : Set E)) ∩ S) x n (by + rintro e ⟨a,ha,he⟩ + have haR : a ∈ reachBall G x n := reachBall_mono G x (Nat.sub_le n 1) + (intrinsicBall_subset_reachBall G (ω ∩ S) x (n-1) ha) + have heQ : e ∈ Q := (mem_incidentSupport G hloc _ e).mpr + ⟨a,(finite_reachBall hloc x n).mem_toFinset.mpr haR,he⟩ + simp only [Set.mem_inter_iff,Finset.mem_coe,heQ,and_true]) + rw [intrinsicSphere_eq_ball_sdiff G _ x n hn,intrinsicSphere_eq_ball_sdiff G _ x n hn, + hballs n le_rfl,hballs (n-1) (Nat.sub_le n 1)] + +theorem thinSphereCell_dependsOn (G : BondGraph V E) (S : Set E) (x : V) + (r k j : ℕ) (hr : 0 < r) (U W : Finset V) : + DependsOn + (fun ω => ω ∈ thinSphereCell G S x r k j U W) (ballIncidentEdges G U) := by + intro ω η hagree + apply propext + have hforward (ω η : Set E) + (hωη : ∀ e ∈ ballIncidentEdges G U, e ∈ ω ↔ e ∈ η) + (hω : ω ∈ thinSphereCell G S x r k j U W) : + η ∈ thinSphereCell G S x r k j U W := by + obtain ⟨hrj,hj2,hU,hW,hthin,hfirst⟩ := hω + have hballs := intrinsicBall_history_eq_of_incident_agreement G (ω ∩ S) (η ∩ S) x j (by + intro e he + rw [hU] at he + exact and_congr (hωη e he) Iff.rfl) + have hspheres (i : ℕ) (hi : r ≤ i) (hij : i ≤ j) : + intrinsicSphere G (ω ∩ S) x i = intrinsicSphere G (η ∩ S) x i := by + have hi0 : 0 < i := hr.trans_le hi + rw [intrinsicSphere_eq_ball_sdiff G _ x i hi0,intrinsicSphere_eq_ball_sdiff G _ x i hi0, + hballs i hij,hballs (i-1) ((Nat.sub_le i 1).trans hij)] + refine ⟨hrj,hj2,(hballs (j-1) (Nat.sub_le j 1)).symm.trans hU, + (hballs j le_rfl).symm.trans hW,?_,?_⟩ + · rw [←hspheres j hrj le_rfl] + exact hthin + · intro i hi hij + rw [←hspheres i hi hij.le] + exact hfirst i hi hij + exact ⟨hforward ω η (fun e he => (hagree e he).to_iff), + hforward η ω (fun e he => (hagree e he).symm.to_iff)⟩ + +theorem measurableSet_thinSphereCell [Countable V] + (G : BondGraph V E) (hloc : LocallyFinite G) (S : Set E) (x : V) + (r k j : ℕ) (hr : 0 < r) (U W : Finset V) : + MeasurableSet (thinSphereCell G S x r k j U W) := by + by_cases hrj : r ≤ j + · have hj0 : 0 < j := hr.trans_le hrj + have hfirst : Measurable (fun ω : Set E => ∀ i, r ≤ i → i < j → + k < (intrinsicSphere G (ω ∩ S) x i).ncard) := by + apply Measurable.forall + intro i + by_cases hri : r ≤ i + · exact measurable_const.imp (measurable_const.imp + (measurable_const.lt (measurable_intrinsicSphere_ncard G hloc S x i (hr.trans_le hri)))) + · have he : (fun ω : Set E => r ≤ i → i < j → + k < (intrinsicSphere G (ω ∩ S) x i).ncard) = fun _ => True := by + funext ω; simp [hri] + rw [he] + exact measurable_const + exact (measurable_const.and (measurable_const.and + ((measurableSet_intrinsicBall_eq G hloc S x (j-1) U).mem.and + ((measurableSet_intrinsicBall_eq G hloc S x j W).mem.and + ((measurableSet_le (measurable_intrinsicSphere_ncard G hloc S x j hj0) measurable_const).mem.and hfirst))))).setOf + · have he : thinSphereCell G S x r k j U W = ∅ := by + ext ω; simp only [thinSphereCell,Set.mem_ofPred_eq,Set.mem_empty_iff_false] + simp [hrj] + rw [he] + exact MeasurableSet.empty + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ThinSphereProbability.lean b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9983d5bc0f5e5fe92a50a2fdec040a1b78b4e1e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereProbability.lean @@ -0,0 +1,114 @@ +import OAI.Probability.BenjaminiSchramm.ThinSphereStopping +import OAI.Probability.BenjaminiSchramm.LayerFreshSelection + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem domainRadiusEvent_dependsOn (G : BondGraph V E) (S : Set E) (x : V) (n : ℕ) : + DependsOn (fun ω => ω ∈ domainRadiusEvent G S x n) S := by + intro ω η hagree + have he : Set.inter ω S = Set.inter η S := by + apply Set.ext + intro e + change (ω e ∧ e ∈ S) ↔ (η e ∧ e ∈ S) + by_cases he : e ∈ S + · simp only [he,and_true] + exact (hagree e he).to_iff + · simp only [he,and_false] + change (Set.inter ω S ∈ intrinsicRadiusEvent G x n) = + (Set.inter η S ∈ intrinsicRadiusEvent G x n) + exact congrArg (fun B : Set E => B ∈ intrinsicRadiusEvent G x n) he + +theorem activeThinSphereCell_fresh_factor [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (S : Set E) (x : V) (r k j : ℕ) (hr : 0 < r) (U W : Finset V) (z : V) : + law p (activeThinSphereCell G S x r k j U W ∩ + domainRadiusEvent G (S \ ballIncidentEdges G U) z r) = + law p (activeThinSphereCell G S x r k j U W) * + law p (domainRadiusEvent G (S \ ballIncidentEdges G U) z r) := by + unfold law + rw [←CriticalPercolation.BernoulliProduct.law_const] + apply CriticalPercolation.BernoulliProduct.measure_inter_of_separate_blocks + (fun _ => p) (ballIncidentEdges G U) _ _ + (measurableSet_activeThinSphereCell G hloc S x r k j hr U W) + (measurableSet_domainRadiusEvent G hloc _ z r) + (activeThinSphereCell_dependsOn G S x r k j hr U W) + intro ω η hagree + apply domainRadiusEvent_dependsOn G (S \ ballIncidentEdges G U) z r + intro e he + exact hagree e he.2 + +theorem activeThinSphereCell_continuation (G : BondGraph V E) (S ω : Set E) + (x : V) (r k j : ℕ) (hr : 0 < r) (U W : Finset V) + (hcell : ω ∈ activeThinSphereCell G S x r k j U W) + (hR : ω ∈ domainRadiusEvent G S x (3*r)) : + ∃ z ∈ W \ U, ω ∈ domainRadiusEvent G (S \ ballIncidentEdges G U) z r := by + have hj0 : 0 < j := hr.trans_le hcell.1.1 + have hj2 : j ≤ 2*r := hcell.1.2.1 + have hRjr : ω ∩ S ∈ intrinsicRadiusEvent G x (j+r) := by + obtain ⟨y,hc,hd⟩ := hR + exact ⟨y,hc,(by omega : j+r ≤ 3*r).trans hd⟩ + obtain ⟨z,hz,hfresh⟩ := intrinsic_radius_fresh_continuation G (ω ∩ S) x j r hj0 hRjr + have hU := hcell.1.2.2.1 + have hW := hcell.1.2.2.2.1 + have hzWU : z ∈ W \ U := by + rw [intrinsicSphere_eq_ball_sdiff G _ x j hj0,hU,hW] at hz + exact_mod_cast hz + refine ⟨z,hzWU,?_⟩ + change ω ∩ (S \ ballIncidentEdges G U) ∈ intrinsicRadiusEvent G z r + rw [hU] at hfresh + have he : (ω ∩ S) \ ballIncidentEdges G U = ω ∩ (S \ ballIncidentEdges G U) := by + ext e; simp only [Set.mem_sdiff,Set.mem_inter_iff]; tauto + rw [he] at hfresh + exact hfresh + +theorem activeThinSphereCell_frontier_card (G : BondGraph V E) (S ω : Set E) + (x : V) (r k j : ℕ) (hr : 0 < r) (U W : Finset V) + (hcell : ω ∈ activeThinSphereCell G S x r k j U W) : (W \ U).card ≤ k := by + have hthin := hcell.1.2.2.2.2.1 + rw [intrinsicSphere_eq_ball_sdiff G _ x j (hr.trans_le hcell.1.1), + hcell.1.2.2.1,hcell.1.2.2.2.1,←Finset.coe_sdiff,Set.ncard_coe_finset] at hthin + exact hthin + +theorem activeThinSphereCell_survival_bound [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (S : Set E) (x : V) (r k j : ℕ) (hr : 0 < r) (U W : Finset V) + (b : ℝ≥0∞) (hb : ∀ (I : Set E) z, law p (domainRadiusEvent G I z r) ≤ b) : + law p (activeThinSphereCell G S x r k j U W ∩ domainRadiusEvent G S x (3*r)) ≤ + law p (activeThinSphereCell G S x r k j U W) * k * b := by + let A := activeThinSphereCell G S x r k j U W + by_cases hA : A.Nonempty + · obtain ⟨ω,hω⟩ := hA + have hcard := activeThinSphereCell_frontier_card G S ω x r k j hr U W hω + have hsub : A ∩ domainRadiusEvent G S x (3*r) ⊆ + ⋃ z ∈ W \ U, A ∩ domainRadiusEvent G (S \ ballIncidentEdges G U) z r := by + rintro η ⟨hη,hR⟩ + obtain ⟨z,hz,hfresh⟩ := activeThinSphereCell_continuation G S η x r k j hr U W hη hR + exact Set.mem_iUnion.mpr ⟨z,Set.mem_iUnion.mpr ⟨hz,hη,hfresh⟩⟩ + calc + _ ≤ law p (⋃ z ∈ W \ U, A ∩ domainRadiusEvent G (S \ ballIncidentEdges G U) z r) := measure_mono hsub + _ ≤ ∑ z ∈ W \ U, law p (A ∩ domainRadiusEvent G (S \ ballIncidentEdges G U) z r) := + measure_biUnion_finset_le _ _ + _ ≤ ∑ _z ∈ W \ U, law p A * b := by + apply Finset.sum_le_sum + intro z _ + rw [activeThinSphereCell_fresh_factor G hloc p S x r k j hr U W z] + exact mul_le_mul' le_rfl (hb _ z) + _ = law p A * (W \ U).card * b := by simp only [Finset.sum_const,nsmul_eq_mul]; ring + _ ≤ _ := mul_le_mul' (mul_le_mul' le_rfl (by exact_mod_cast hcard)) le_rfl + · have he : A = ∅ := Set.not_nonempty_iff_eq_empty.mp hA + change law p (A ∩ _) ≤ law p A * _ * _ + rw [he] + simp + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ThinSphereRecurrence.lean b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereRecurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..722ab9a6d1579015aa5468b228ff9e17108e7cf7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereRecurrence.lean @@ -0,0 +1,68 @@ +import OAI.Probability.BenjaminiSchramm.ThinSphereProbability + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem domain_cluster_subset (G : BondGraph V E) (S ω : Set E) (x : V) : + cluster G (ω ∩ S) x ⊆ cluster G ω x := + fun _ h => conn_mono G Set.inter_subset_left h + +theorem radius_thin_sphere_recurrence [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (p : unitInterval) + (hfin : ∀ x, ∀ᵐ ω ∂law p, (cluster G ω x).Finite) + (r k : ℕ) (hr : 0 < r) (b : ℝ≥0∞) + (hb : ∀ (I : Set E) z, law p (domainRadiusEvent G I z r) ≤ b) + (S : Set E) (x : V) : + law p (domainRadiusEvent G S x (3*r)) ≤ + law p (volumeEvent G x ((r+1)*(k+1))) + k * b^2 := by + let A : (ℕ × Finset V × Finset V) → Set (Set E) := fun a => + activeThinSphereCell G S x r k a.1 a.2.1 a.2.2 + let R := domainRadiusEvent G S x (3*r) + have hmA (a) : MeasurableSet (A a) := + measurableSet_activeThinSphereCell G hloc S x r k a.1 hr a.2.1 a.2.2 + have hdisj : Pairwise (fun a c => Disjoint (A a) (A c)) := activeThinSphereCell_pairwise G S x r k + have hsub : R ≤ᵐ[law p] volumeEvent G x ((r+1)*(k+1)) ∪ ⋃ a, A a ∩ R := by + filter_upwards [hfin x] with ω hω + intro hR + by_cases hv : ω ∈ volumeEvent G x ((r+1)*(k+1)) + · exact Or.inl hv + · have hsmallG : (cluster G ω x).ncard < (r+1)*(k+1) := by + change ¬ (((r+1)*(k+1) : ℕ) : ℕ∞) ≤ (cluster G ω x).encard at hv + rw [←hω.cast_ncard_eq] at hv + exact_mod_cast lt_of_not_ge hv + have hdomain := domain_cluster_subset G S ω x + have hf := hω.subset hdomain + have hsmall : (cluster G (ω ∩ S) x).ncard < (r+1)*(k+1) := + (Set.ncard_le_ncard hdomain hω).trans_lt hsmallG + have hRr : ω ∈ domainRadiusEvent G S x r := by + obtain ⟨y,hc,hd⟩ := hR + exact ⟨y,hc,(by omega : r ≤ 3*r).trans hd⟩ + obtain ⟨a,ha⟩ := exists_activeThinSphereCell_of_small_cluster G hloc S ω x r k hf hsmall hRr + exact Or.inr (Set.mem_iUnion.mpr ⟨a,ha,hR⟩) + have hsumA : (∑' a, law p (A a)) ≤ b := by + rw [←measure_iUnion hdisj hmA] + apply (measure_mono (show (⋃ a, A a) ⊆ domainRadiusEvent G S x r from ?_)).trans (hb S x) + intro ω hω + obtain ⟨a,ha⟩ := Set.mem_iUnion.mp hω + exact ha.2 + have hsum : (∑' a, law p (A a ∩ R)) ≤ k * b^2 := by + calc + _ ≤ ∑' a, law p (A a) * k * b := ENNReal.tsum_le_tsum (fun a => + activeThinSphereCell_survival_bound G hloc p S x r k a.1 hr a.2.1 a.2.2 b hb) + _ = (∑' a, law p (A a)) * k * b := by rw [ENNReal.tsum_mul_right,ENNReal.tsum_mul_right] + _ ≤ b * k * b := mul_le_mul' (mul_le_mul' hsumA le_rfl) le_rfl + _ = _ := by ring + exact (measure_mono_ae hsub).trans ((measure_union_le _ _).trans + (add_le_add le_rfl ((measure_iUnion_le (fun a => A a ∩ R)).trans hsum))) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/ThinSphereStopping.lean b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereStopping.lean new file mode 100644 index 0000000000000000000000000000000000000000..55e2620120324bcae8d52e468d820e3baaa81a6d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/ThinSphereStopping.lean @@ -0,0 +1,91 @@ +import OAI.Probability.BenjaminiSchramm.ThinSphereExposure +import OAI.Probability.BenjaminiSchramm.IntrinsicFreshPath + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +def domainRadiusEvent (G : BondGraph V E) (S : Set E) (x : V) (n : ℕ) : Set (Set E) := + {ω | ω ∩ S ∈ intrinsicRadiusEvent G x n} + +def activeThinSphereCell (G : BondGraph V E) (S : Set E) (x : V) (r k j : ℕ) + (U W : Finset V) : Set (Set E) := + thinSphereCell G S x r k j U W ∩ domainRadiusEvent G S x r + +theorem measurableSet_domainRadiusEvent [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (S : Set E) (x : V) (n : ℕ) : + MeasurableSet (domainRadiusEvent G S x n) := by + have hm : Measurable (fun ω : Set E => ω ∩ S) := + measurable_set_iff.mpr (fun e => (measurable_set_mem e).and measurable_const) + exact (measurableSet_intrinsicRadiusEvent G hloc x n).preimage hm + +theorem measurableSet_activeThinSphereCell [Countable V] [Countable E] + (G : BondGraph V E) (hloc : LocallyFinite G) (S : Set E) (x : V) + (r k j : ℕ) (hr : 0 < r) (U W : Finset V) : + MeasurableSet (activeThinSphereCell G S x r k j U W) := + (measurableSet_thinSphereCell G hloc S x r k j hr U W).inter + (measurableSet_domainRadiusEvent G hloc S x r) + +theorem activeThinSphereCell_pairwise (G : BondGraph V E) (S : Set E) (x : V) (r k : ℕ) : + Pairwise (fun a b : ℕ × Finset V × Finset V => + Disjoint (activeThinSphereCell G S x r k a.1 a.2.1 a.2.2) + (activeThinSphereCell G S x r k b.1 b.2.1 b.2.2)) := by + intro a b hab + exact (thinSphereCell_pairwise G S x r k hab).mono Set.inter_subset_left Set.inter_subset_left + +theorem activeThinSphereCell_dependsOn (G : BondGraph V E) (S : Set E) (x : V) + (r k j : ℕ) (hr : 0 < r) (U W : Finset V) : + DependsOn (fun ω => ω ∈ activeThinSphereCell G S x r k j U W) (ballIncidentEdges G U) := by + intro ω η hagree + apply propext + have hforward (ω η : Set E) + (hωη : ∀ e ∈ ballIncidentEdges G U, (e ∈ ω) = (e ∈ η)) + (hω : ω ∈ activeThinSphereCell G S x r k j U W) : + η ∈ activeThinSphereCell G S x r k j U W := by + have hθη := ((thinSphereCell_dependsOn G S x r k j hr U W) hωη).to_iff.mp hω.1 + have hU := hω.1.2.2.1 + have hrj := hω.1.1 + have hballs := intrinsicBall_history_eq_of_incident_agreement G (ω ∩ S) (η ∩ S) x j (by + intro e he + rw [hU] at he + exact and_congr (hωη e he).to_iff Iff.rfl) + refine ⟨hθη,?_⟩ + have hR := hω.2 + change ω ∩ S ∈ intrinsicRadiusEvent G x r at hR + change η ∩ S ∈ intrinsicRadiusEvent G x r + rw [intrinsicRadiusEvent_iff_sphere,intrinsicSphere_eq_ball_sdiff G _ x r hr, + hballs r hrj,hballs (r-1) ((Nat.sub_le r 1).trans hrj)] at hR + rw [intrinsicRadiusEvent_iff_sphere,intrinsicSphere_eq_ball_sdiff G _ x r hr] + exact hR + exact ⟨hforward ω η hagree,hforward η ω (fun e he => (hagree e he).symm)⟩ + +theorem exists_activeThinSphereCell_of_small_cluster (G : BondGraph V E) + (hloc : LocallyFinite G) (S ω : Set E) (x : V) (r k : ℕ) + (hf : (cluster G (ω ∩ S) x).Finite) + (hsmall : (cluster G (ω ∩ S) x).ncard < (r+1)*(k+1)) + (hR : ω ∈ domainRadiusEvent G S x r) : + ∃ a : ℕ × Finset V × Finset V, + ω ∈ activeThinSphereCell G S x r k a.1 a.2.1 a.2.2 := by + obtain ⟨j,hj,hthin⟩ := exists_thin_intrinsicSphere G hloc (ω ∩ S) x r k hf hsmall + have hex : ∃ j : ℕ, r ≤ j ∧ j ≤ 2*r ∧ (intrinsicSphere G (ω ∩ S) x j).ncard ≤ k := + ⟨j,(Finset.mem_Icc.mp hj).1,(Finset.mem_Icc.mp hj).2,hthin⟩ + let j := Nat.find hex + have hj := Nat.find_spec hex + let hU := (finite_reachBall hloc x (j-1)).subset (intrinsicBall_subset_reachBall G (ω ∩ S) x (j-1)) + let hW := (finite_reachBall hloc x j).subset (intrinsicBall_subset_reachBall G (ω ∩ S) x j) + refine ⟨(j,hU.toFinset,hW.toFinset),?_,hR⟩ + refine ⟨hj.1,hj.2.1,hU.coe_toFinset.symm,hW.coe_toFinset.symm,hj.2.2,?_⟩ + intro i hri hij + by_contra hki + have hi := Nat.find_min hex hij + exact hi ⟨hri,(by omega),Nat.le_of_not_gt hki⟩ + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedGhost.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedGhost.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ad479e787521ca08feca09729c0da587fbc9caf --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedGhost.lean @@ -0,0 +1,200 @@ +import OAI.Probability.BenjaminiSchramm.TiltedMagnetization + +namespace OAI + +noncomputable section +open MeasureTheory Set Filter +open scoped Topology ENNReal + +namespace Percolation.BenjaminiSchramm + +def ghostKernel (h x : ℝ) : ℝ := 1 - Real.exp (-h * x) + +lemma ghostKernel_nonneg {h x : ℝ} (hh : 0 ≤ h) (hx : 0 ≤ x) : + 0 ≤ ghostKernel h x := by + apply sub_nonneg.mpr + exact (Real.exp_le_one_iff).mpr (by nlinarith) + +lemma ghostKernel_le_one (h x : ℝ) : ghostKernel h x ≤ 1 := by + exact sub_le_self _ (Real.exp_pos _).le + +lemma ghostKernel_le_product (h x : ℝ) : ghostKernel h x ≤ h * x := by + have he := Real.add_one_le_exp (-h * x) + dsimp [ghostKernel] + linarith + +lemma ghostKernel_scaled_derivative_le (h x : ℝ) : + h * (x * Real.exp (-h * x)) ≤ ghostKernel h x := by + have he := mul_le_mul_of_nonneg_right (Real.add_one_le_exp (h * x)) + (Real.exp_pos (-h * x)).le + have heq : Real.exp (h * x) * Real.exp (-h * x) = 1 := by + rw [← Real.exp_add] + simp + rw [heq] at he + dsimp [ghostKernel] + nlinarith + +lemma hasDerivAt_ghostKernel (h x : ℝ) : + HasDerivAt (fun r => ghostKernel r x) (x * Real.exp (-h * x)) h := by + have he : HasDerivAt (fun r : ℝ => Real.exp (-r * x)) + (-x * Real.exp (-h * x)) h := by + convert (((hasDerivAt_id h).neg.mul_const x).exp) using 1 + · funext r + rfl + · dsimp + ring + convert (hasDerivAt_const h (1 : ℝ)).sub he using 1 + · rfl + · ring + +lemma ghostKernel_le_threeQuarter {h x : ℝ} (hh : 0 ≤ h) (hx : 0 ≤ x) : + ghostKernel h x ≤ (h * x) ^ (3 / 4 : ℝ) := by + by_cases hu : h * x ≤ 1 + · exact (ghostKernel_le_product h x).trans + (Real.self_le_rpow_of_le_one (mul_nonneg hh hx) hu (by norm_num)) + · exact (ghostKernel_le_one h x).trans + (Real.one_le_rpow (le_of_not_ge hu) (by norm_num)) + +lemma ghostKernel_quartic_moment {t x : ℝ} (ht : 0 ≤ t) (hx : 0 ≤ x) : + ghostKernel (t ^ 4) x ≤ t ^ 3 * x ^ (3 / 4 : ℝ) := by + have he : (t ^ 4 : ℝ) ^ (3 / 4 : ℝ) = t ^ 3 := by + rw [← Real.rpow_natCast t 4, ← Real.rpow_mul ht] + norm_num + simpa only [Real.mul_rpow (pow_nonneg ht 4) hx, he] using + ghostKernel_le_threeQuarter (pow_nonneg ht 4) hx + +variable {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (X : Ω → ℝ) + +def ghostMagnetization (h : ℝ) : ℝ := ∫ ω, ghostKernel h (X ω) ∂μ + +def ghostMagnetizationDerivative (h : ℝ) : ℝ := + ∫ ω, X ω * Real.exp (-h * X ω) ∂μ + +lemma measurable_ghostKernel (hX : Measurable X) (h : ℝ) : + Measurable (fun ω => ghostKernel h (X ω)) := + measurable_const.sub ((measurable_const.mul hX).exp) + +lemma integrable_ghostKernel (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + {h : ℝ} (hh : 0 ≤ h) : Integrable (fun ω => ghostKernel h (X ω)) μ := by + apply (integrable_const (1 : ℝ)).mono' (measurable_ghostKernel X hX h).aestronglyMeasurable + exact ae_of_all _ fun ω => by + rw [Real.norm_eq_abs, abs_of_nonneg (ghostKernel_nonneg hh (hX0 ω))] + exact ghostKernel_le_one _ _ + +theorem hasDerivAt_ghostMagnetization (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + {h : ℝ} (hh : 0 < h) : + Integrable (fun ω => X ω * Real.exp (-h * X ω)) μ ∧ + HasDerivAt (ghostMagnetization μ X) (ghostMagnetizationDerivative μ X h) h := by + have hhalf : 0 < h / 2 := by positivity + apply hasDerivAt_integral_of_dominated_loc_of_deriv_le + (s := Ioi (h / 2)) (bound := fun _ => 2 / h) + (Ioi_mem_nhds (by linarith)) + (Eventually.of_forall fun r => (measurable_ghostKernel X hX r).aestronglyMeasurable) + (integrable_ghostKernel μ X hX hX0 hh.le) + (hX.mul ((measurable_const.mul hX).exp)).aestronglyMeasurable + · exact ae_of_all _ fun ω r hr => by + have hder0 : 0 ≤ X ω * Real.exp (-r * X ω) := + mul_nonneg (hX0 ω) (Real.exp_pos _).le + have hprod : r * (X ω * Real.exp (-r * X ω)) ≤ 1 := + (ghostKernel_scaled_derivative_le r (X ω)).trans (ghostKernel_le_one _ _) + change h / 2 < r at hr + rw [Real.norm_eq_abs, abs_of_nonneg hder0] + apply (le_div_iff₀ hh).mpr + nlinarith + · exact integrable_const _ + · exact ae_of_all _ fun ω r _ => hasDerivAt_ghostKernel r (X ω) + +omit [IsFiniteMeasure μ] in +lemma ghostMagnetization_nonneg (hX0 : ∀ ω, 0 ≤ X ω) {h : ℝ} (hh : 0 ≤ h) : + 0 ≤ ghostMagnetization μ X h := + integral_nonneg fun ω => ghostKernel_nonneg hh (hX0 ω) + +lemma ghostMagnetization_concave_bound (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + {h : ℝ} (hh : 0 < h) : + h * ghostMagnetizationDerivative μ X h ≤ ghostMagnetization μ X h := by + rw [ghostMagnetizationDerivative, ← integral_const_mul] + apply integral_mono ((hasDerivAt_ghostMagnetization μ X hX hX0 hh).1.const_mul h) + (integrable_ghostKernel μ X hX hX0 hh.le) + intro ω + exact ghostKernel_scaled_derivative_le _ _ + +lemma ghostMagnetization_quartic_moment (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + (hXi : Integrable (fun ω => X ω ^ (3 / 4 : ℝ)) μ) {t : ℝ} (ht : 0 ≤ t) : + ghostMagnetization μ X (t ^ 4) ≤ + (∫ ω, X ω ^ (3 / 4 : ℝ) ∂μ) * t ^ 3 := by + calc + _ ≤ ∫ ω, t ^ 3 * X ω ^ (3 / 4 : ℝ) ∂μ := + integral_mono (integrable_ghostKernel μ X hX hX0 (pow_nonneg ht 4)) + (hXi.const_mul _) (fun ω => ghostKernel_quartic_moment ht (hX0 ω)) + _ = _ := by rw [integral_const_mul, mul_comm] + +theorem firstMoment_le_of_ghost_quartic_ratio (hX : Measurable X) + (hX0 : ∀ ω, 0 ≤ X ω) (B : ℝ) + (hbound : ∀ t, 0 < t → t ≤ 1 → ghostMagnetization μ X (t ^ 4) / t ^ 4 ≤ B) : + (∫⁻ ω, ENNReal.ofReal (X ω) ∂μ) ≤ ENNReal.ofReal B := by + let t (n : ℕ) : ℝ := 1 / ((n : ℝ) + 1) + let h (n : ℕ) : ℝ := t n ^ 4 + have ht0 (n : ℕ) : 0 < t n := by dsimp [t]; positivity + have ht1 (n : ℕ) : t n ≤ 1 := by + dsimp [t] + apply (div_le_one (by positivity : 0 < (n : ℝ) + 1)).mpr + linarith [(Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + have hh0 (n : ℕ) : 0 < h n := pow_pos (ht0 n) 4 + have hlim : Tendsto h atTop (𝓝[>] (0 : ℝ)) := by + apply tendsto_nhdsWithin_iff.mpr + refine ⟨?_,Eventually.of_forall hh0⟩ + simpa only [h, zero_pow (by decide : 4 ≠ 0)] using + (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).pow 4 + let F (n : ℕ) (ω : Ω) := ENNReal.ofReal (ghostKernel (h n) (X ω) / h n) + have hF (n : ℕ) : Measurable (F n) := + ((measurable_ghostKernel X hX _).div_const _).ennreal_ofReal + have hF_lim (ω : Ω) : Tendsto (fun n => F n ω) atTop (𝓝 (ENNReal.ofReal (X ω))) := by + have hs := ((hasDerivAt_ghostKernel 0 (X ω)).tendsto_slope_zero_right).comp hlim + have hs' : Tendsto (fun n => ghostKernel (h n) (X ω) / h n) atTop (𝓝 (X ω)) := by + simpa only [Function.comp_def, zero_add, ghostKernel, neg_zero, zero_mul, mul_zero, + Real.exp_zero, mul_one, sub_self, sub_zero, smul_eq_mul, div_eq_mul_inv, mul_comm] using hs + exact ENNReal.continuous_ofReal.continuousAt.tendsto.comp hs' + calc + _ = ∫⁻ ω, liminf (fun n => F n ω) atTop ∂μ := + lintegral_congr fun ω => (hF_lim ω).liminf_eq.symm + _ ≤ liminf (fun n => ∫⁻ ω, F n ω ∂μ) atTop := lintegral_liminf_le hF + _ ≤ ENNReal.ofReal B := by + apply le_trans (liminf_le_liminf (Eventually.of_forall fun n => ?_)) (liminf_const _).le + rw [show (∫⁻ ω, F n ω ∂μ) = + ENNReal.ofReal (ghostMagnetization μ X (h n) / h n) from ?_] + · exact ENNReal.ofReal_le_ofReal (hbound (t n) (ht0 n) (ht1 n)) + · change (∫⁻ ω, ENNReal.ofReal (ghostKernel (h n) (X ω) / h n) ∂μ) = _ + rw [← ofReal_integral_eq_lintegral_ofReal] + · simp only [div_eq_mul_inv, integral_mul_const] + rfl + · exact (integrable_ghostKernel μ X hX hX0 (hh0 n).le).div_const _ + · exact ae_of_all _ fun ω => div_nonneg + (ghostKernel_nonneg (hh0 n).le (hX0 ω)) (hh0 n).le + +theorem firstMoment_lt_top_of_threeQuarter_and_differential + (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + (hXi : Integrable (fun ω => X ω ^ (3 / 4 : ℝ)) μ) + (C : ℝ) (hC : 0 ≤ C) + (hdiff : ∀ t, 0 < t → t ≤ 1 → + ghostMagnetization μ X (t ^ 4) ≤ C * ghostMagnetization μ X (t ^ 4) ^ 2 + + t ^ 4 * ghostMagnetizationDerivative μ X (t ^ 4) + + C * t ^ 6 * ghostMagnetizationDerivative μ X (t ^ 4)) : + (∫⁻ ω, ENNReal.ofReal (X ω) ∂μ) < ⊤ := by + let K := ∫ ω, X ω ^ (3 / 4 : ℝ) ∂μ + have hK : 0 ≤ K := integral_nonneg fun ω => Real.rpow_nonneg (hX0 ω) _ + apply lt_of_le_of_lt (firstMoment_le_of_ghost_quartic_ratio μ X hX hX0 + (ghostMagnetization μ X 1 + 2 * C * K ^ 2 + 4 * C * K) ?_) ENNReal.ofReal_lt_top + intro t ht ht1 + apply magnetization_ratio_bound_of_quartic_moment (ghostMagnetization μ X) + (ghostMagnetizationDerivative μ X) C K hC hK + (fun h hh => (hasDerivAt_ghostMagnetization μ X hX hX0 hh).2) + (fun h hh => ghostMagnetization_nonneg μ X hX0 hh.le) + (fun s hs _ => ghostMagnetization_quartic_moment μ X hX hX0 hXi hs.le) + (fun h hh => ghostMagnetization_concave_bound μ X hX hX0 hh) hdiff t ht ht1 + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedGhostSusceptibility.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedGhostSusceptibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..57323e29bbffee6017c85639f6969bb692ce8395 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedGhostSusceptibility.lean @@ -0,0 +1,101 @@ +import OAI.Probability.BenjaminiSchramm.TiltedGhost +import OAI.Probability.BenjaminiSchramm.TiltedSusceptibility + +namespace OAI + +noncomputable section +open MeasureTheory Set +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph + +variable {V E : Type*} (G : BondGraph V E) + +def quarterTiltedMass (ω : Set E) (x : V) : ℝ≥0∞ := + ∑' y, if (G.openGraph ω).Reachable x y then G.stabilizerWeight x y ^ (1 / 4 : ℝ) else 0 + +lemma measurable_quarterTiltedMass [Countable V] [Countable E] (x : V) : + Measurable (fun ω => G.quarterTiltedMass ω x) := by + apply Measurable.tsum + intro y + exact measurable_const.ite (G.measurable_reachable x y).setOf measurable_const + +lemma quarterTiltedMass_aut (φ : G.Aut) (ω : Set E) (x : V) : + G.quarterTiltedMass (φ.edge '' ω) (φ.vertex x) = G.quarterTiltedMass ω x := by + unfold quarterTiltedMass + rw [← φ.vertex.tsum_eq] + apply tsum_congr + intro y + rw [Aut.stabilizerWeight] + congr 1 + exact propext (SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω)) + +lemma quarterTiltedMass_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (ω : Set E) {x y : V} (hxy : (G.openGraph ω).Reachable x y) : + G.quarterTiltedMass ω y = + G.stabilizerWeight y x ^ (1 / 4 : ℝ) * G.quarterTiltedMass ω x := by + unfold quarterTiltedMass + rw [← ENNReal.tsum_mul_left] + apply tsum_congr + intro z + have hr : (G.openGraph ω).Reachable y z ↔ (G.openGraph ω).Reachable x z := + ⟨fun h => hxy.trans h,fun h => hxy.symm.trans h⟩ + rw [hr] + split_ifs + · rw [G.stabilizerWeight_change_base hc hl y x z, ENNReal.mul_rpow_of_nonneg _ _ (by norm_num)] + · simp + +lemma lintegral_quarterTiltedMass [Countable V] [Countable E] (p : unitInterval) (x : V) : + (∫⁻ ω, G.quarterTiltedMass ω x ∂G.law p) = G.tiltedSusceptibility p (1 / 4) x := by + unfold quarterTiltedMass tiltedSusceptibility + rw [lintegral_tsum] + · apply tsum_congr + intro y + simpa only [Set.indicator, Set.mem_ofPred_eq, connectionMeasure, mul_comm] using + lintegral_indicator_const (μ := G.law p) (G.measurable_reachable x y).setOf + (G.stabilizerWeight x y ^ (1 / 4 : ℝ)) + · intro y + exact (measurable_const.ite (G.measurable_reachable x y).setOf measurable_const).aemeasurable + +def quarterGhostMagnetization (p : unitInterval) (x : V) (h : ℝ) : ℝ := + Percolation.BenjaminiSchramm.ghostMagnetization (G.law p) + (fun ω => (G.quarterTiltedMass ω x).toReal) h + +def quarterGhostDerivative (p : unitInterval) (x : V) (h : ℝ) : ℝ := + Percolation.BenjaminiSchramm.ghostMagnetizationDerivative (G.law p) + (fun ω => (G.quarterTiltedMass ω x).toReal) h + +theorem quarterTiltedSusceptibility_lt_top_of_moment_and_differential + [Countable V] [Countable E] (p : unitInterval) (x : V) + (hmoment : (∫⁻ ω, G.quarterTiltedMass ω x ^ (3 / 4 : ℝ) ∂G.law p) < ⊤) + (C : ℝ) (hC : 0 ≤ C) + (hdiff : ∀ t, 0 < t → t ≤ 1 → + G.quarterGhostMagnetization p x (t ^ 4) ≤ + C * G.quarterGhostMagnetization p x (t ^ 4) ^ 2 + + t ^ 4 * G.quarterGhostDerivative p x (t ^ 4) + + C * t ^ 6 * G.quarterGhostDerivative p x (t ^ 4)) : + G.tiltedSusceptibility p (1 / 4) x < ⊤ := by + have hmeas := G.measurable_quarterTiltedMass x + have hpow : Measurable (fun ω => G.quarterTiltedMass ω x ^ (3 / 4 : ℝ)) := + ENNReal.continuous_rpow_const.measurable.comp hmeas + have hfinite : ∀ᵐ ω ∂G.law p, G.quarterTiltedMass ω x < ⊤ := by + filter_upwards [ae_lt_top hpow hmoment.ne] with ω hω + exact (ENNReal.rpow_lt_top_iff_of_pos (by norm_num : (0 : ℝ) < 3 / 4)).mp hω + have hXi : Integrable (fun ω => (G.quarterTiltedMass ω x).toReal ^ (3 / 4 : ℝ)) + (G.law p) := by + simpa only [ENNReal.toReal_rpow] using + integrable_toReal_of_lintegral_ne_top hpow.aemeasurable hmoment.ne + rw [← G.lintegral_quarterTiltedMass p x] + have heq : (fun ω => ENNReal.ofReal (G.quarterTiltedMass ω x).toReal) =ᵐ[G.law p] + (fun ω => G.quarterTiltedMass ω x) := + hfinite.mono fun _ hω => ENNReal.ofReal_toReal hω.ne + rw [← lintegral_congr_ae heq] + exact Percolation.BenjaminiSchramm.firstMoment_lt_top_of_threeQuarter_and_differential + (G.law p) (fun ω => (G.quarterTiltedMass ω x).toReal) hmeas.ennreal_toReal + (fun _ => ENNReal.toReal_nonneg) hXi C hC hdiff + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedHit.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedHit.lean new file mode 100644 index 0000000000000000000000000000000000000000..d15ab9e8928be7cfff514892c823ec2f55444a24 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedHit.lean @@ -0,0 +1,84 @@ +import OAI.Probability.BenjaminiSchramm.ModularSchur + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph + +variable {V E : Type*} (G : BondGraph V E) + +theorem zero_one_tiltedSusceptibility_duality [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, G.tiltedSusceptibility p 0 x) = + ∑ x ∈ (G.orbitRepresentatives hq).roots, G.tiltedSusceptibility p 1 x := by + simp only [tiltedSusceptibility, ENNReal.rpow_zero, ENNReal.rpow_one, mul_one] + rw [OrbitRepresentatives.tilted_massTransport_ennreal G (G.orbitRepresentatives hq) hc hl + (G.connectionMeasure p) (fun φ x y => G.connectionMeasure_aut p φ x y)] + apply Finset.sum_congr rfl + intro y _ + apply tsum_congr + intro x + rw [G.connectionMeasure_symm p x y] + +def weightHit (a : ℝ≥0∞) (x : V) : Set (Set E) := + {ω | ∃ y, (G.openGraph ω).Reachable x y ∧ a ≤ G.stabilizerWeight x y} + +lemma measurableSet_weightHit [Countable V] [Countable E] (a : ℝ≥0∞) (x : V) : + MeasurableSet (G.weightHit a x) := + (Measurable.exists fun y => (G.measurable_reachable x y).and measurable_const).setOf + +theorem weightHit_measure_mul_le [Countable V] [Countable E] + (p : unitInterval) (a : ℝ≥0∞) (x : V) : + a * G.law p (G.weightHit a x) ≤ G.tiltedSusceptibility p 1 x := by + have he : G.weightHit a x = ⋃ y, {ω | (G.openGraph ω).Reachable x y ∧ + a ≤ G.stabilizerWeight x y} := by ext ω; simp [weightHit] + rw [he] + calc + _ ≤ a * ∑' y, G.law p {ω | (G.openGraph ω).Reachable x y ∧ + a ≤ G.stabilizerWeight x y} := mul_le_mul' le_rfl (measure_iUnion_le _) + _ = ∑' y, a * G.law p {ω | (G.openGraph ω).Reachable x y ∧ + a ≤ G.stabilizerWeight x y} := ENNReal.tsum_mul_left.symm + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro y + by_cases ha : a ≤ G.stabilizerWeight x y + · simp only [ha, and_true, ENNReal.rpow_one] + rw [mul_comm] + exact mul_le_mul' le_rfl ha + · simp [ha] + +end CriticalPercolation.BondGraph + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} + +theorem criticalModel_fullTiltedSusceptibility_lt_top_of_lt_pc + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (p : unitInterval) (hp : p < pc G) : + ∀ x ∈ ((criticalModel G).orbitRepresentatives (criticalModel_quasiTransitive G hq)).roots, + (criticalModel G).tiltedSusceptibility p 1 x < ⊤ := by + let H := criticalModel G + let hHq := criticalModel_quasiTransitive G hq + have hzero (x : V) : H.tiltedSusceptibility p 0 x < ⊤ := by + change (criticalModel G).tiltedSusceptibility p 0 x < ⊤ + simp only [CriticalPercolation.BondGraph.tiltedSusceptibility, ENNReal.rpow_zero, mul_one, + criticalModel_connectionMeasure] + exact (summable_twoPoint_subcritical G hl hq p hp x).tsum_ofReal_lt_top + have hsum : (∑ x ∈ (H.orbitRepresentatives hHq).roots, H.tiltedSusceptibility p 1 x) < ⊤ := by + rw [← H.zero_one_tiltedSusceptibility_duality (criticalModel_connected G hc) hl hHq p] + exact ENNReal.sum_lt_top.mpr fun x _ => hzero x + intro x hx + exact lt_of_le_of_lt (Finset.single_le_sum (fun _ _ => bot_le) hx) hsum + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedMagnetization.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedMagnetization.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcfe95a304f9c5a00523da36fa12310ce72802fb --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedMagnetization.lean @@ -0,0 +1,87 @@ +import Mathlib + +namespace OAI + +open Set Filter +open scoped Topology + +namespace Percolation.BenjaminiSchramm + +theorem magnetization_ratio_bound_of_quartic_moment + (M d : ℝ → ℝ) (C K : ℝ) (hC : 0 ≤ C) (hK : 0 ≤ K) + (hd : ∀ h, 0 < h → HasDerivAt M (d h) h) + (hM : ∀ h, 0 < h → 0 ≤ M h) + (hmoment : ∀ t, 0 < t → t ≤ 1 → M (t ^ 4) ≤ K * t ^ 3) + (hconcave : ∀ h, 0 < h → h * d h ≤ M h) + (hdiff : ∀ t, 0 < t → t ≤ 1 → + M (t ^ 4) ≤ C * M (t ^ 4) ^ 2 + t ^ 4 * d (t ^ 4) + C * t ^ 6 * d (t ^ 4)) + (t : ℝ) (ht : 0 < t) (ht1 : t ≤ 1) : + M (t ^ 4) / t ^ 4 ≤ M 1 + 2 * C * K ^ 2 + 4 * C * K := by + let F (s : ℝ) := M (s ^ 4) / s ^ 4 + 2 * C * K ^ 2 * s ^ 2 + 4 * C * K * s + let D (s : ℝ) := + ((d (s ^ 4) * (4 * s ^ 3)) * s ^ 4 - M (s ^ 4) * (4 * s ^ 3)) / (s ^ 4) ^ 2 + + 4 * C * K ^ 2 * s + 4 * C * K + have hF (s : ℝ) (hs : 0 < s) : HasDerivAt F (D s) s := by + have hp4 : HasDerivAt (fun r : ℝ => r ^ 4) (4 * s ^ 3) s := by + convert (hasDerivAt_id s).pow 4 using 1 + · funext r + rfl + · norm_num + have hp2 : HasDerivAt (fun r : ℝ => r ^ 2) (2 * s) s := by + convert (hasDerivAt_id s).pow 2 using 1 + · funext r + rfl + · norm_num + have hm : HasDerivAt (fun r : ℝ => M (r ^ 4)) + (d (s ^ 4) * (4 * s ^ 3)) s := + (hd (s ^ 4) (pow_pos hs 4)).comp (h := fun r : ℝ => r ^ 4) s hp4 + convert ((hm.div hp4 (pow_ne_zero 4 hs.ne')).add + (hp2.const_mul (2 * C * K ^ 2))).add ((hasDerivAt_id s).const_mul (4 * C * K)) using 1 + · funext r + rfl + · dsimp [D] + ring + have hD (s : ℝ) (hs : 0 < s) (hs1 : s ≤ 1) : 0 ≤ D s := by + have hmom := hmoment s hs hs1 + have hsq : M (s ^ 4) ^ 2 ≤ K ^ 2 * s ^ 6 := by + calc + _ ≤ (K * s ^ 3) ^ 2 := + (sq_le_sq₀ (hM _ (pow_pos hs 4)) (mul_nonneg hK (pow_nonneg hs.le 3))).mpr hmom + _ = _ := by ring + have hterm : s ^ 6 * d (s ^ 4) ≤ K * s ^ 5 := by + calc + _ = s ^ 2 * (s ^ 4 * d (s ^ 4)) := by ring + _ ≤ s ^ 2 * M (s ^ 4) := + mul_le_mul_of_nonneg_left (hconcave _ (pow_pos hs 4)) (sq_nonneg s) + _ ≤ s ^ 2 * (K * s ^ 3) := mul_le_mul_of_nonneg_left hmom (sq_nonneg s) + _ = _ := by ring + have herror : 0 ≤ s ^ 4 * d (s ^ 4) - M (s ^ 4) + C * K ^ 2 * s ^ 6 + C * K * s ^ 5 := by + have hsqC := mul_le_mul_of_nonneg_left hsq hC + have htermC := mul_le_mul_of_nonneg_left hterm hC + nlinarith [hdiff s hs hs1] + have hn : 0 ≤ ((d (s ^ 4) * (4 * s ^ 3)) * s ^ 4 - M (s ^ 4) * (4 * s ^ 3)) + + (s ^ 4) ^ 2 * (4 * C * K ^ 2 * s + 4 * C * K) := by + convert mul_nonneg (by positivity : 0 ≤ 4 * s ^ 3) herror using 1 + ring + have hden : 0 < (s ^ 4) ^ 2 := pow_pos (pow_pos hs 4) 2 + dsimp [D] + rw [add_assoc, div_add' _ _ _ hden.ne'] + exact div_nonneg (by nlinarith [hn]) hden.le + have hmono : MonotoneOn F (Icc t 1) := by + apply monotoneOn_of_deriv_nonneg (convex_Icc t 1) + (fun s hs => (hF s (ht.trans_le hs.1)).continuousAt.continuousWithinAt) + (fun s hs => (hF s (ht.trans_le (interior_subset hs).1)).differentiableAt.differentiableWithinAt) + intro s hs + have hmem := interior_subset hs + rw [(hF s (ht.trans_le hmem.1)).deriv] + exact hD s (ht.trans_le hmem.1) hmem.2 + have hb := hmono ⟨le_rfl,ht1⟩ ⟨ht1,le_rfl⟩ ht1 + dsimp [F] at hb + norm_num only [one_pow, div_one, mul_one] at hb + have hnonneg1 : 0 ≤ 2 * C * K ^ 2 * t ^ 2 := by positivity + have hnonneg2 : 0 ≤ 4 * C * K * t := by positivity + linarith + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedMomentBridge.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedMomentBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..0531be347e55e2df29fc59bad54efb99418a5e4d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedMomentBridge.lean @@ -0,0 +1,55 @@ +import OAI.Probability.BenjaminiSchramm.TiltedMoments +import OAI.Probability.BenjaminiSchramm.TiltedGhostSusceptibility +import OAI.Probability.BenjaminiSchramm.CriticalFiniteness + +namespace OAI + +open MeasureTheory +open scoped ENNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +noncomputable def modularHeight (G : BondGraph V E) (o x : V) : ℝ := + Real.log ((criticalModel G).modularRatio x o) + +theorem quarterTiltedMass_eq_logarithmic_mass [Nonempty V] + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) (ω : Set E) (o : V) : + (criticalModel G).quarterTiltedMass ω o = + quarterTiltedClusterMass G (modularHeight G o) ω o := by + unfold CriticalPercolation.BondGraph.quarterTiltedMass quarterTiltedClusterMass + apply tsum_congr + intro x + have hr : ((criticalModel G).openGraph ω).Reachable o x ↔ Conn G ω o x := by + rw [criticalModel_openGraph] + exact (conn_iff_reachable G ω o x).symm + rw [hr] + split_ifs + · have hpos := (criticalModel G).modularRatio_pos (criticalModel_connected G hc) hl x o + rw [CriticalPercolation.BondGraph.stabilizerWeight, ENNReal.ofReal_rpow_of_pos hpos, + Real.rpow_def_of_pos hpos] + congr 2 + dsimp [modularHeight] + ring + · rfl + +theorem quarterTiltedMass_moment_lt_top_of_layers [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) + (p : unitInterval) (o : V) (C : ℝ) (hC : 0 ≤ C) + (hpos : ∀ k : ℤ, 0 ≤ k → + (∫⁻ ω, modularLayerCount G (modularHeight G o) ω o k ^ (3 / 4 : ℝ) ∂law p) ≤ + ENNReal.ofReal (C * Real.exp (-(k : ℝ) / 2))) + (hneg : ∀ k : ℤ, k ≤ 0 → + (∫⁻ ω, modularLayerCount G (modularHeight G o) ω o k ^ (3 / 4 : ℝ) ∂law p) ≤ + ENNReal.ofReal (C * Real.exp (-(k : ℝ) / 16))) : + (∫⁻ ω, (criticalModel G).quarterTiltedMass ω o ^ (3 / 4 : ℝ) + ∂(criticalModel G).law p) < ⊤ := by + simp_rw [quarterTiltedMass_eq_logarithmic_mass G hc hl] + exact quarterTilted_moment_lt_top_of_layer_bounds G p (modularHeight G o) o C hC hpos hneg + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedMoments.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d77eb51592b0d1d3571e62df217efcb2605aa0d --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedMoments.lean @@ -0,0 +1,185 @@ +import OAI.Probability.BenjaminiSchramm.Nonunimodular + +namespace OAI + +open MeasureTheory ProbabilityTheory +open scoped ENNReal NNReal + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.decEq Classical.propDecidable + +theorem threeQuarter_sum_le (f : ℤ → ℝ≥0∞) (s : Finset ℤ) : + (∑ k ∈ s, f k) ^ (3 / 4 : ℝ) ≤ ∑ k ∈ s, f k ^ (3 / 4 : ℝ) := by + induction s using Finset.induction_on with + | empty => norm_num + | insert k s hk ih => + simp only [Finset.sum_insert hk] + exact (ENNReal.rpow_add_le_add_rpow _ _ (by norm_num) (by norm_num)).trans + (add_le_add le_rfl ih) + +theorem threeQuarter_tsum_le (f : ℤ → ℝ≥0∞) : + (∑' k, f k) ^ (3 / 4 : ℝ) ≤ ∑' k, f k ^ (3 / 4 : ℝ) := by + rw [ENNReal.tsum_eq_iSup_sum] + change (ENNReal.orderIsoRpow (3 / 4) (by norm_num)) + (⨆ s : Finset ℤ, ∑ k ∈ s, f k) ≤ _ + rw [OrderIso.map_iSup] + exact iSup_le fun s => (threeQuarter_sum_le f s).trans (ENNReal.sum_le_tsum _) + +noncomputable def quarterTiltedClusterMass (G : BondGraph V E) (h : V → ℝ) + (ω : Set E) (o : V) : ℝ≥0∞ := + ∑' x, if Conn G ω o x then ENNReal.ofReal (Real.exp (h x / 4)) else 0 + +noncomputable def modularLayerCount (G : BondGraph V E) (h : V → ℝ) + (ω : Set E) (o : V) (k : ℤ) : ℝ≥0∞ := + ∑' x : {x : V // ⌊h x⌋ = k}, if Conn G ω o x then 1 else 0 + +theorem measurable_modularLayerCount [Countable V] [Countable E] + (G : BondGraph V E) (h : V → ℝ) (o : V) (k : ℤ) : + Measurable (fun ω => modularLayerCount G h ω o k) := by + apply Measurable.tsum + intro x + exact measurable_const.ite (measurableSet_conn G o x) measurable_const + +theorem quarterTiltedClusterMass_le_layers (G : BondGraph V E) (h : V → ℝ) + (ω : Set E) (o : V) : + quarterTiltedClusterMass G h ω o ≤ + ∑' k : ℤ, ENNReal.ofReal (Real.exp (((k : ℝ) + 1) / 4)) * + modularLayerCount G h ω o k := by + unfold quarterTiltedClusterMass + rw [← ENNReal.tsum_fiberwise _ (fun x => ⌊h x⌋)] + apply ENNReal.tsum_le_tsum + intro k + rw [modularLayerCount, ← ENNReal.tsum_mul_left] + apply ENNReal.tsum_le_tsum + intro x + by_cases hc : Conn G ω o x + · simp only [hc, ↓reduceIte, mul_one] + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hh := Int.lt_floor_add_one (h x) + have hx : ⌊h (x : V)⌋ = k := x.property + rw [hx] at hh + linarith + · simp [hc] + +theorem quarterTiltedClusterMass_threeQuarter_le_layers + (G : BondGraph V E) (h : V → ℝ) (ω : Set E) (o : V) : + quarterTiltedClusterMass G h ω o ^ (3 / 4 : ℝ) ≤ + ∑' k : ℤ, ENNReal.ofReal (Real.exp (3 * ((k : ℝ) + 1) / 16)) * + modularLayerCount G h ω o k ^ (3 / 4 : ℝ) := by + refine (ENNReal.rpow_le_rpow (quarterTiltedClusterMass_le_layers G h ω o) + (by norm_num : (0 : ℝ) ≤ 3 / 4)).trans ?_ + apply (threeQuarter_tsum_le _).trans + apply ENNReal.tsum_le_tsum + intro k + rw [ENNReal.mul_rpow_of_nonneg _ _ (by norm_num)] + have he : ENNReal.ofReal (Real.exp (((k : ℝ) + 1) / 4)) ^ (3 / 4 : ℝ) = + ENNReal.ofReal (Real.exp (3 * ((k : ℝ) + 1) / 16)) := by + rw [ENNReal.ofReal_rpow_of_nonneg (Real.exp_nonneg _) (by norm_num), + ← Real.exp_mul] + congr 2 + ring + rw [he] + +theorem quarterTilted_moment_le_layers [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (h : V → ℝ) (o : V) : + (∫⁻ ω, quarterTiltedClusterMass G h ω o ^ (3 / 4 : ℝ) ∂law p) ≤ + ∑' k : ℤ, ENNReal.ofReal (Real.exp (3 * ((k : ℝ) + 1) / 16)) * + ∫⁻ ω, modularLayerCount G h ω o k ^ (3 / 4 : ℝ) ∂law p := by + have hm (k : ℤ) : Measurable (fun ω => modularLayerCount G h ω o k ^ (3 / 4 : ℝ)) := + (ENNReal.continuous_rpow_const (y := (3 / 4 : ℝ))).measurable.comp + (measurable_modularLayerCount G h o k) + calc + _ ≤ ∫⁻ ω, ∑' k : ℤ, ENNReal.ofReal (Real.exp (3 * ((k : ℝ) + 1) / 16)) * + modularLayerCount G h ω o k ^ (3 / 4 : ℝ) ∂law p := + lintegral_mono fun ω => quarterTiltedClusterMass_threeQuarter_le_layers G h ω o + _ = _ := by + rw [lintegral_tsum] + · congr 1 + ext k + exact lintegral_const_mul _ (hm k) + · intro k + exact (measurable_const.mul (hm k)).aemeasurable + +theorem quarterTilted_moment_lt_top_of_layer_bounds [Countable V] [Countable E] + (G : BondGraph V E) (p : unitInterval) (h : V → ℝ) (o : V) + (C : ℝ) (hC : 0 ≤ C) + (hpos : ∀ k : ℤ, 0 ≤ k → + (∫⁻ ω, modularLayerCount G h ω o k ^ (3 / 4 : ℝ) ∂law p) ≤ + ENNReal.ofReal (C * Real.exp (-(k : ℝ) / 2))) + (hneg : ∀ k : ℤ, k ≤ 0 → + (∫⁻ ω, modularLayerCount G h ω o k ^ (3 / 4 : ℝ) ∂law p) ≤ + ENNReal.ofReal (C * Real.exp (-(k : ℝ) / 16))) : + (∫⁻ ω, quarterTiltedClusterMass G h ω o ^ (3 / 4 : ℝ) ∂law p) < ∞ := by + let F (k : ℤ) : ℝ := C * Real.exp (3 / 16) * Real.exp (-|(k : ℝ)| / 8) + have hs : Summable F := by + apply summable_int_iff_summable_nat_and_neg.mpr + have hn : Summable (fun n : ℕ => C * Real.exp (3 / 16) * + Real.exp ((n : ℝ) * (-1 / 8))) := + (Real.summable_exp_nat_mul_iff.mpr (by norm_num : (-1 / 8 : ℝ) < 0)).mul_left _ + constructor + · convert hn using 1 + ext n + simp only [F, Int.cast_natCast, abs_of_nonneg (Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + congr 2 + ring + · convert hn using 1 + ext n + simp only [F, Int.cast_neg, Int.cast_natCast, abs_neg, + abs_of_nonneg (Nat.cast_nonneg n : (0 : ℝ) ≤ n)] + congr 2 + ring + apply lt_of_le_of_lt (quarterTilted_moment_le_layers G p h o) + apply lt_of_le_of_lt _ hs.tsum_ofReal_lt_top + apply ENNReal.tsum_le_tsum + intro k + have hk : (0 : ℝ) ≤ k ∨ (k : ℝ) ≤ 0 := le_total 0 _ + rcases hk with hk | hk + · calc + _ ≤ ENNReal.ofReal (Real.exp (3 * ((k : ℝ) + 1) / 16)) * + ENNReal.ofReal (C * Real.exp (-(k : ℝ) / 2)) := by + gcongr + exact hpos k (by exact_mod_cast hk) + _ = ENNReal.ofReal (C * Real.exp (3 / 16) * Real.exp (-(5 * (k : ℝ)) / 16)) := by + rw [← ENNReal.ofReal_mul (Real.exp_nonneg _)] + congr 1 + have he : Real.exp (3 * ((k : ℝ) + 1) / 16) * Real.exp (-(k : ℝ) / 2) = + Real.exp (3 / 16) * Real.exp (-(5 * (k : ℝ)) / 16) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + calc + _ = C * (Real.exp (3 * ((k : ℝ) + 1) / 16) * + Real.exp (-(k : ℝ) / 2)) := by ring + _ = _ := by rw [he]; ring + _ ≤ ENNReal.ofReal (F k) := by + apply ENNReal.ofReal_le_ofReal + apply mul_le_mul_of_nonneg_left _ (mul_nonneg hC (Real.exp_nonneg _)) + apply Real.exp_le_exp.mpr + rw [abs_of_nonneg hk] + linarith + · calc + _ ≤ ENNReal.ofReal (Real.exp (3 * ((k : ℝ) + 1) / 16)) * + ENNReal.ofReal (C * Real.exp (-(k : ℝ) / 16)) := by + gcongr + exact hneg k (by exact_mod_cast hk) + _ = ENNReal.ofReal (C * Real.exp (3 / 16) * Real.exp ((k : ℝ) / 8)) := by + rw [← ENNReal.ofReal_mul (Real.exp_nonneg _)] + congr 1 + have he : Real.exp (3 * ((k : ℝ) + 1) / 16) * Real.exp (-(k : ℝ) / 16) = + Real.exp (3 / 16) * Real.exp ((k : ℝ) / 8) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + calc + _ = C * (Real.exp (3 * ((k : ℝ) + 1) / 16) * + Real.exp (-(k : ℝ) / 16)) := by ring + _ = _ := by rw [he]; ring + _ = ENNReal.ofReal (F k) := by simp [F, abs_of_nonpos hk] + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TiltedSusceptibility.lean b/lean/OAI/Probability/BenjaminiSchramm/TiltedSusceptibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..02c9e88e72b5d5c5d395a7596beb6100cfbb20a3 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TiltedSusceptibility.lean @@ -0,0 +1,108 @@ +import OAI.Probability.BenjaminiSchramm.PeakLayerEstimate +import OAI.Probability.CriticalPercolation.Modular.ModularClusterCount + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph + +variable {V E : Type*} (G : BondGraph V E) + +def connectionMeasure (p : unitInterval) (x y : V) : ℝ≥0∞ := + G.law p {ω | (G.openGraph ω).Reachable x y} + +def tiltedSusceptibility (p : unitInterval) (a : ℝ) (x : V) : ℝ≥0∞ := + ∑' y, G.connectionMeasure p x y * G.stabilizerWeight x y ^ a + +lemma connectionMeasure_symm (p : unitInterval) (x y : V) : + G.connectionMeasure p x y = G.connectionMeasure p y x := by + unfold connectionMeasure + congr 1 + ext ω + exact SimpleGraph.reachable_comm + +lemma connectionMeasure_aut [Countable V] [Countable E] (p : unitInterval) (φ : G.Aut) (x y : V) : + G.connectionMeasure p (φ.vertex x) (φ.vertex y) = G.connectionMeasure p x y := by + unfold connectionMeasure + conv_lhs => rw [← G.law_map_aut p φ] + rw [Measure.map_apply (BernoulliProduct.measurable_image_equiv φ.edge) + ((G.measurable_reachable _ _).setOf)] + congr 1 + ext ω + exact SimpleGraph.Iso.reachable_iff (φ := Aut.openGraphIso G φ ω) + +lemma tiltedSusceptibility_aut [Countable V] [Countable E] (p : unitInterval) (a : ℝ) + (φ : G.Aut) (x : V) : + G.tiltedSusceptibility p a (φ.vertex x) = G.tiltedSusceptibility p a x := by + unfold tiltedSusceptibility + rw [← φ.vertex.tsum_eq] + simp only [G.connectionMeasure_aut, Aut.stabilizerWeight] + +theorem quarterTiltedSusceptibility_duality [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, G.tiltedSusceptibility p (1 / 4) x) = + ∑ x ∈ (G.orbitRepresentatives hq).roots, G.tiltedSusceptibility p (3 / 4) x := by + rw [show (∑ x ∈ (G.orbitRepresentatives hq).roots, G.tiltedSusceptibility p (1 / 4) x) = + ∑ y ∈ (G.orbitRepresentatives hq).roots, + ∑' x, (G.connectionMeasure p x y * G.stabilizerWeight x y ^ (1 / 4 : ℝ)) * + G.stabilizerWeight y x from + OrbitRepresentatives.tilted_massTransport_ennreal G (G.orbitRepresentatives hq) hc hl + (fun x y => G.connectionMeasure p x y * G.stabilizerWeight x y ^ (1 / 4 : ℝ)) + (fun φ x y => by rw [G.connectionMeasure_aut, Aut.stabilizerWeight])] + apply Finset.sum_congr rfl + intro y _ + apply tsum_congr + intro x + rw [G.connectionMeasure_symm p x y, mul_assoc, + ← G.stabilizerWeight_inv hc hl y x, ENNReal.inv_rpow, + ← ENNReal.rpow_neg] + nth_rw 2 [← ENNReal.rpow_one (G.stabilizerWeight y x)] + rw [← ENNReal.rpow_add _ _ (G.stabilizerWeight_pos hc hl y x).ne' + (G.stabilizerWeight_ne_top y x)] + norm_num + +theorem halfTiltedSusceptibility_le_quarter_add_threeQuarter (p : unitInterval) (x : V) : + G.tiltedSusceptibility p (1 / 2) x ≤ + G.tiltedSusceptibility p (1 / 4) x + G.tiltedSusceptibility p (3 / 4) x := by + rw [tiltedSusceptibility, tiltedSusceptibility, tiltedSusceptibility, ← ENNReal.tsum_add] + apply ENNReal.tsum_le_tsum + intro y + rw [← mul_add] + gcongr + rcases le_total (G.stabilizerWeight x y) 1 with h | h + · exact (ENNReal.rpow_le_rpow_of_exponent_ge h (by norm_num : (1 / 4 : ℝ) ≤ 1 / 2)).trans + (le_add_right le_rfl) + · exact (ENNReal.rpow_le_rpow_of_exponent_le h (by norm_num : (1 / 2 : ℝ) ≤ 3 / 4)).trans + (le_add_left le_rfl) + +theorem uniform_halfTiltedSusceptibility_of_quarter [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) + (hfin : ∀ x ∈ (G.orbitRepresentatives hq).roots, + G.tiltedSusceptibility p (1 / 4) x < ∞) : + ∃ C : ℝ≥0∞, C < ∞ ∧ ∀ x, G.tiltedSusceptibility p (1 / 2) x ≤ C := by + let S := (G.orbitRepresentatives hq).roots + let C := (∑ x ∈ S, G.tiltedSusceptibility p (1 / 4) x) + + ∑ x ∈ S, G.tiltedSusceptibility p (3 / 4) x + have hqfin : (∑ x ∈ S, G.tiltedSusceptibility p (1 / 4) x) < ∞ := + ENNReal.sum_lt_top.mpr hfin + have htfin : (∑ x ∈ S, G.tiltedSusceptibility p (3 / 4) x) < ∞ := by + rw [← G.quarterTiltedSusceptibility_duality hc hl hq p] + exact hqfin + refine ⟨C, ENNReal.add_lt_top.mpr ⟨hqfin,htfin⟩, ?_⟩ + intro x + obtain ⟨y,hy,φ,rfl⟩ := (G.orbitRepresentatives hq).cover x + rw [G.tiltedSusceptibility_aut] + exact (G.halfTiltedSusceptibility_le_quarter_add_threeQuarter p y).trans + (add_le_add (Finset.single_le_sum (fun _ _ => zero_le) hy) + (Finset.single_le_sum (fun _ _ => zero_le) hy)) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TruncatedFractionalSummation.lean b/lean/OAI/Probability/BenjaminiSchramm/TruncatedFractionalSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..38e891b57c706aeb11670acc61aabc9327f090b7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TruncatedFractionalSummation.lean @@ -0,0 +1,76 @@ +import OAI.Probability.BenjaminiSchramm.RestrictedMomentHolder +import Mathlib.Analysis.SpecialFunctions.Exp + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma ennreal_exp_rpow (t a : ℝ) (ha : 0 ≤ a) : + ENNReal.ofReal (Real.exp t)^a=ENNReal.ofReal (Real.exp (t*a)) := by + rw [ENNReal.ofReal_rpow_of_nonneg (Real.exp_nonneg _) ha,←Real.exp_mul] + +lemma fractional_height_slice_bound {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : Set Ω) + (X : Ω → ℝ≥0∞) (hX : Measurable X) (C B : ℝ≥0∞) (t s : ℝ) (n : ℕ) + (hfirst : (∫⁻ ω in S, X ω ∂μ) ≤ C*ENNReal.ofReal (Real.exp (t*n))) + (hprob : μ S ≤ B*ENNReal.ofReal (Real.exp (-s*n))) + {a δ : ℝ} (ha : 0 < a) (ha1 : a < 1) (hδ : 0 ≤ δ) (hδa : δ ≤ 1-a) : + (∫⁻ ω in S, X ω^a ∂μ) ≤ + C^a*B^δ*ENNReal.ofReal (Real.exp ((t*a-s*δ)*n)) := by + have hmeasure : (μ S)^(1-a) ≤ (B*ENNReal.ofReal (Real.exp (-s*n)))^δ := + (ENNReal.rpow_le_rpow_of_exponent_ge (prob_le_one (μ := μ)) hδa).trans + (ENNReal.rpow_le_rpow hprob hδ) + have hh := (restricted_fractional_moment_holder μ S X hX ha ha1).trans + (mul_le_mul' (ENNReal.rpow_le_rpow hfirst ha.le) hmeasure) + rw [ENNReal.mul_rpow_of_nonneg _ _ ha.le,ENNReal.mul_rpow_of_nonneg _ _ hδ, + ennreal_exp_rpow _ _ ha.le,ennreal_exp_rpow _ _ hδ] at hh + have he : (C^a*ENNReal.ofReal (Real.exp (t*n*a)))* + (B^δ*ENNReal.ofReal (Real.exp (-s*n*δ))) = + C^a*B^δ*ENNReal.ofReal (Real.exp ((t*a-s*δ)*n)) := by + calc + _ = (C^a*B^δ)*(ENNReal.ofReal (Real.exp (t*n*a))*ENNReal.ofReal (Real.exp (-s*n*δ))) := by ac_rfl + _ = _ := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show t*(n : ℝ)*a+ -s*n*δ=(t*a-s*δ)*n by ring] + exact hh.trans_eq he + +theorem fractional_moment_of_height_slices {Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] (S : ℕ → Set Ω) (hS : ∀ n, MeasurableSet (S n)) + (hcover : ∀ᵐ ω ∂μ, ∃ n, ω ∈ S n) (X : Ω → ℝ≥0∞) (hX : Measurable X) + (C B : ℝ≥0∞) (t s : ℝ) + (hfirst : ∀ n : ℕ, (∫⁻ ω in S n, X ω ∂μ) ≤ C*ENNReal.ofReal (Real.exp (t*n))) + (hprob : ∀ n : ℕ, μ (S n) ≤ B*ENNReal.ofReal (Real.exp (-s*n))) + {a δ : ℝ} (ha : 0 < a) (ha1 : a < 1) (hδ : 0 ≤ δ) (hδa : δ ≤ 1-a) : + (∫⁻ ω, X ω^a ∂μ) ≤ + C^a*B^δ*(∑' n : ℕ, ENNReal.ofReal (Real.exp ((t*a-s*δ)*n))) := by + have he : (fun ω => X ω^a) =ᵐ[μ] (⋃ n, S n).indicator (fun ω => X ω^a) := by + filter_upwards [hcover] with ω hω + exact (Set.indicator_of_mem (Set.mem_iUnion.mpr hω) (fun ω => X ω^a)).symm + calc + _ = ∫⁻ ω in ⋃ n, S n, X ω^a ∂μ := by + rw [lintegral_congr_ae he,lintegral_indicator (MeasurableSet.iUnion hS) (fun ω => X ω^a)] + _ ≤ ∑' n : ℕ, ∫⁻ ω in S n, X ω^a ∂μ := lintegral_iUnion_le S _ + _ ≤ ∑' n : ℕ, C^a*B^δ*ENNReal.ofReal (Real.exp ((t*a-s*δ)*n)) := + ENNReal.tsum_le_tsum fun n => fractional_height_slice_bound μ (S n) X hX C B t s n + (hfirst n) (hprob n) ha ha1 hδ hδa + _ = _ := ENNReal.tsum_mul_left + +lemma fractional_height_geometric_sum_lt_top {t s a δ : ℝ} (hgap : t*a < s*δ) : + (∑' n : ℕ, ENNReal.ofReal (Real.exp ((t*a-s*δ)*n))) < ⊤ := by + have hh := Real.summable_exp_nat_mul_iff.mpr (sub_neg.mpr hgap) + convert hh.tsum_ofReal_lt_top using 1 + congr 1 + funext n + congr 1 + congr 1 + ring + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TruncatedSlabMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/TruncatedSlabMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..53e6233f627e1464219920901b52f1bcef6e40b4 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TruncatedSlabMoment.lean @@ -0,0 +1,45 @@ +import OAI.Probability.BenjaminiSchramm.CriticalPeakComparison +import OAI.Probability.BenjaminiSchramm.RestrictedMomentHolder + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +lemma mixedHeightLayerMoment_eq_lintegral (a : V → ℝ) (p : unitInterval) + (d c l u ad t : ℝ) (x : V) : + G.mixedHeightLayerMoment a p d c l u ad t x = + ∫⁻ ω, (restrictedHit G.ends + (Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a x z}) x + {z | t ≤ G.orbitAdjustedHeight a x z})ᶜ.indicator + (fun ω => restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c}) + {z | l ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u} ω x) ω ∂G.law p := by + let D := Percolation.internalEdges G.ends {z | ad ≤ G.orbitAdjustedHeight a x z} + let I := Percolation.internalEdges G.ends {z | d ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ c} + let W : Set V := {z | l ≤ G.orbitAdjustedHeight a x z ∧ G.orbitAdjustedHeight a x z ≤ u} + let P := (restrictedHit G.ends D x {z | t ≤ G.orbitAdjustedHeight a x z})ᶜ + change G.mixedHeightLayerMoment a p d c l u ad t x = + ∫⁻ ω, P.indicator (fun ω => restrictedLayerCount G.ends I W ω x) ω ∂Percolation.law p + rw [lintegral_indicator_restrictedLayerCount G.ends p P + (measurableSet_restrictedHit G.ends D x _).compl I W x] + unfold mixedHeightLayerMoment + apply tsum_congr + intro y + by_cases hy : l ≤ G.orbitAdjustedHeight a x y ∧ G.orbitAdjustedHeight a x y ≤ u + · simp only [W,Set.mem_ofPred_eq,hy] + apply congrArg (Percolation.law p) + ext ω + exact and_comm + · simp only [W,Set.mem_ofPred_eq,hy,ite_false] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/TwoGhost.lean b/lean/OAI/Probability/BenjaminiSchramm/TwoGhost.lean new file mode 100644 index 0000000000000000000000000000000000000000..5cb87f558e6a25bf484c57f66cfabccc3a7dd0d1 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/TwoGhost.lean @@ -0,0 +1,93 @@ +import OAI.Probability.BenjaminiSchramm.TiltedGhost + +namespace OAI + +noncomputable section +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +lemma one_sub_exp_le_single_add_two_ghost {u : ℝ} (hu : 0 ≤ u) : + 1 - Real.exp (-u) ≤ u * Real.exp (-u) + 2 * (1 - Real.exp (-(u / 2))) ^ 2 := by + let F (r : ℝ) := Real.exp r - 4 * Real.exp (r / 2) + 3 + r + have hF (r : ℝ) : HasDerivAt F (Real.exp r - 2 * Real.exp (r / 2) + 1) r := by + have hh : HasDerivAt (fun s : ℝ => Real.exp (s / 2)) (Real.exp (r / 2) / 2) r := by + convert (Real.hasDerivAt_exp (r / 2)).comp (h := fun s : ℝ => s / 2) r + ((hasDerivAt_id r).div_const 2) using 1 + · funext s + rfl + · ring + convert (((Real.hasDerivAt_exp r).sub (hh.const_mul 4)).add_const 3).add + (hasDerivAt_id r) using 1 + · funext s + rfl + · ring + have hmono : Monotone F := by + apply monotone_of_deriv_nonneg (fun r => (hF r).differentiableAt) + intro r + rw [(hF r).deriv] + have he : Real.exp (r / 2) ^ 2 = Real.exp r := by + rw [← Real.exp_nat_mul] + congr 1 + ring + nlinarith [sq_nonneg (Real.exp (r / 2) - 1)] + have hnonneg : 0 ≤ F u := by + have hm := hmono hu + norm_num [F] at hm ⊢ + exact hm + have hp := mul_nonneg (Real.exp_pos (-u)).le hnonneg + have h1 : Real.exp (-u) * Real.exp u = 1 := by + rw [← Real.exp_add] + simp + have h2 : Real.exp (-u) * Real.exp (u / 2) = Real.exp (-(u / 2)) := by + rw [← Real.exp_add] + congr 1 + ring + have h3 : Real.exp (-(u / 2)) ^ 2 = Real.exp (-u) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + dsimp [F] at hp + nlinarith + +lemma ghostKernel_le_derivative_add_two_ghost {h x : ℝ} (hh : 0 ≤ h) (hx : 0 ≤ x) : + ghostKernel h x ≤ h * (x * Real.exp (-h * x)) + 2 * ghostKernel (h / 2) x ^ 2 := by + have he := one_sub_exp_le_single_add_two_ghost (mul_nonneg hh hx) + have hhalf : -(h / 2) * x = -(h * x / 2) := by ring + dsimp [ghostKernel] + rw [hhalf] + simpa only [neg_mul, mul_assoc] using he + +variable {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] (X : Ω → ℝ) + +lemma integrable_ghostKernel_sq (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) + {h : ℝ} (hh : 0 ≤ h) : Integrable (fun ω => ghostKernel h (X ω) ^ 2) μ := by + apply (integrable_const (1 : ℝ)).mono' + ((measurable_ghostKernel X hX h).pow_const 2).aestronglyMeasurable + exact ae_of_all _ fun ω => by + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + nlinarith [ghostKernel_nonneg hh (hX0 ω), ghostKernel_le_one h (X ω)] + +theorem ghostMagnetization_le_derivative_add_two_ghost + (hX : Measurable X) (hX0 : ∀ ω, 0 ≤ X ω) {h : ℝ} (hh : 0 < h) : + ghostMagnetization μ X h ≤ h * ghostMagnetizationDerivative μ X h + + 2 * ∫ ω, ghostKernel (h / 2) (X ω) ^ 2 ∂μ := by + calc + _ ≤ ∫ ω, h * (X ω * Real.exp (-h * X ω)) + + 2 * ghostKernel (h / 2) (X ω) ^ 2 ∂μ := by + apply integral_mono (integrable_ghostKernel μ X hX hX0 hh.le) + (((hasDerivAt_ghostMagnetization μ X hX hX0 hh).1.const_mul h).add + ((integrable_ghostKernel_sq μ X hX hX0 (by positivity : 0 ≤ h / 2)).const_mul 2)) + intro ω + exact ghostKernel_le_derivative_add_two_ghost hh.le (hX0 ω) + _ = _ := by + rw [integral_add ((hasDerivAt_ghostMagnetization μ X hX hX0 hh).1.const_mul h) + ((integrable_ghostKernel_sq μ X hX hX0 (by positivity : 0 ≤ h / 2)).const_mul 2), + integral_const_mul, integral_const_mul] + rfl + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UnconditionalInputs.lean b/lean/OAI/Probability/BenjaminiSchramm/UnconditionalInputs.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab4985a0cdf8771d8efb2f45322afcd1e1c7ee5b --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UnconditionalInputs.lean @@ -0,0 +1,44 @@ +import OAI.Probability.BenjaminiSchramm.CriticalQuarterMoment +import OAI.Probability.BenjaminiSchramm.NonunimodularMomentReduction +import OAI.Probability.BenjaminiSchramm.CombinatorialUnimodularOperator + +namespace OAI + +namespace Percolation.BenjaminiSchramm +universe u v +variable {V : Type u} {E : Type v} [Infinite V] + +theorem simple_critical_bounded + (G : BondGraph V E) (hinj : Function.Injective G) + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hh : 0 < hV G) : OperatorBounded G (pc G) := by + classical + let : Countable V := countable_vertices hl hc + let : Countable E := countable_edges hl + by_cases hu : (criticalModel G).CombinatoriallyUnimodular + · exact critical_bounded_of_combinatorial_unimodular G hinj hc hl hq hh hu + · exact critical_operator_of_quarter_moments G hinj hc hl hq hh + (fun x _hx => critical_quarter_moment_finite G hc hl hq + (by exact_mod_cast pc_lt_one_of_nonamenable G hc hl hq hh) hu x) + +theorem simple_strict_gap + (G : BondGraph V E) (hinj : Function.Injective G) + (hc : Connected G) (hl : LocallyFinite G) (hq : QuasiTransitive G) + (hh : 0 < hV G) : pc G < ptwo G := + (mainConclusion_of_critical_bounded G hc hl hq + (simple_critical_bounded G hinj hc hl hq hh)).2.2.1 + +theorem subdivision_gap_input_proved + (G : BondGraph V E) (hc : Connected G) (hl : LocallyFinite G) + (hq : QuasiTransitive G) (hh : 0 < hV G) : + ¬ AutUnimodular (subdivision G) (subdivision_injective G) + (subdivision_connected G hc) (subdivision_locallyFinite G hl) → + pc (subdivision G) < ptwo (subdivision G) := by + intro _hu + exact simple_strict_gap (subdivision G) (subdivision_injective G) + (subdivision_connected G hc) (subdivision_locallyFinite G hl) + (subdivision_quasiTransitive G hl hq) (subdivision_hV_pos G hl hq hh) + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UniformHeightAscent.lean b/lean/OAI/Probability/BenjaminiSchramm/UniformHeightAscent.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cea246b3dac04cbe71799b8584c82d356955658 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UniformHeightAscent.lean @@ -0,0 +1,80 @@ +import OAI.Probability.BenjaminiSchramm.HarmonicHeightAscent + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_uniform_ascent [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) + (hu : ¬ G.CombinatoriallyUnimodular) : + ∃ ε : ℝ, 0 < ε ∧ ∃ L : ℕ, ∀ x, ∃ y, ∃ w : G.fullGraph.Walk x y, + w.length ≤ L ∧ + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v) ∧ + ε ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y := by + let : Nonempty G.VertexOrbit := ⟨G.vertexOrbit (Classical.arbitrary V)⟩ + choose y w hw hr using fun i : G.VertexOrbit => + G.stationaryOrbitHeight_ascent hc hl hq μ hμ hstat hu i.out + let a := G.stationaryOrbitWeight μ + let rise : G.VertexOrbit → ℝ := fun i => G.orbitAdjustedHeight a i.out (y i) + obtain ⟨i,_,hi⟩ := Finset.exists_min_image Finset.univ rise Finset.univ_nonempty + obtain ⟨j,_,hj⟩ := Finset.exists_max_image Finset.univ + (fun k : G.VertexOrbit => (w k).length) Finset.univ_nonempty + refine ⟨rise i,hr i,(w j).length,fun x => ?_⟩ + let k := G.vertexOrbit x + obtain ⟨φ,hφ⟩ := G.orbit_out_aut x + let f : G.fullGraph →g G.fullGraph := + ⟨φ.vertex,fun {_ _} h => (Aut.fullGraph_adj G φ _ _).mpr h⟩ + refine ⟨φ.vertex (y k),((w k).map f).copy hφ rfl,?_,?_,?_⟩ + · simpa only [SimpleGraph.Walk.length_copy,SimpleGraph.Walk.length_map] using + hj k (Finset.mem_univ _) + · intro v hv + simp only [SimpleGraph.Walk.support_copy,SimpleGraph.Walk.support_map,List.mem_map] at hv + obtain ⟨z,hz,rfl⟩ := hv + change 0 ≤ G.orbitAdjustedHeight a x (φ.vertex z) + rw [← hφ,G.orbitAdjustedHeight_aut a (G.stationaryOrbitWeight_aut μ)] + exact hw k z hz + · change rise i ≤ G.orbitAdjustedHeight a x (φ.vertex (y k)) + rw [← hφ,G.orbitAdjustedHeight_aut a (G.stationaryOrbitWeight_aut μ)] + exact hi k (Finset.mem_univ _) + +lemma height_ascent_iterate (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (ε : ℝ) (hε : 0 ≤ ε) (L : ℕ) + (hstep : ∀ x, ∃ y, ∃ w : G.fullGraph.Walk x y, w.length ≤ L ∧ + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight a x v) ∧ ε ≤ G.orbitAdjustedHeight a x y) + (n : ℕ) (x : V) : + ∃ y, ∃ w : G.fullGraph.Walk x y, w.length ≤ n*L ∧ + (∀ v ∈ w.support, 0 ≤ G.orbitAdjustedHeight a x v) ∧ + n*ε ≤ G.orbitAdjustedHeight a x y := by + induction n with + | zero => + refine ⟨x,.nil,by simp,?_,by simp⟩ + intro v hv + have he : v = x := List.mem_singleton.mp hv + rw [he,G.orbitAdjustedHeight_self] + | succ n ih => + obtain ⟨y,w,hlen,hw,hr⟩ := ih + obtain ⟨z,q,hqlen,hq,hqr⟩ := hstep y + refine ⟨z,w.append q,?_,?_,?_⟩ + · rw [SimpleGraph.Walk.length_append] + exact (Nat.add_le_add hlen hqlen).trans_eq (Nat.succ_mul n L).symm + · intro v hv + rcases (SimpleGraph.Walk.mem_support_append_iff _ _).mp hv with hv | hv + · exact hw v hv + · rw [G.orbitAdjustedHeight_change_base hc hl a x y v] + exact add_nonneg ((mul_nonneg (Nat.cast_nonneg n) hε).trans hr) (hq v hv) + · rw [G.orbitAdjustedHeight_change_base hc hl a x y z] + push_cast + nlinarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UniformHeightDescent.lean b/lean/OAI/Probability/BenjaminiSchramm/UniformHeightDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..820f16083fc6f9dcfaa438078b45babeb73db268 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UniformHeightDescent.lean @@ -0,0 +1,126 @@ +import OAI.Probability.BenjaminiSchramm.HarmonicHeightDescent +import OAI.Probability.BenjaminiSchramm.HeightOrbitConnection + +namespace OAI + +noncomputable section +open Set +open scoped Classical BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +theorem stationaryOrbitHeight_uniform_descent [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) + (hu : ¬ G.CombinatoriallyUnimodular) : + ∃ ε : ℝ, 0 < ε ∧ ∃ L : ℕ, ∀ x, ∃ y, ∃ w : G.fullGraph.Walk x y, + w.length ≤ L ∧ + (∀ v ∈ w.support, G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0) ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ≤ -ε := by + let : Nonempty G.VertexOrbit := ⟨G.vertexOrbit (Classical.arbitrary V)⟩ + choose y w hw hr using fun i : G.VertexOrbit => + G.stationaryOrbitHeight_descent hc hl hq μ hμ hstat hu i.out + let a := G.stationaryOrbitWeight μ + let fall : G.VertexOrbit → ℝ := fun i => -G.orbitAdjustedHeight a i.out (y i) + obtain ⟨i,_,hi⟩ := Finset.exists_min_image Finset.univ fall Finset.univ_nonempty + obtain ⟨j,_,hj⟩ := Finset.exists_max_image Finset.univ + (fun k : G.VertexOrbit => (w k).length) Finset.univ_nonempty + refine ⟨fall i,neg_pos.mpr (hr i),(w j).length,fun x => ?_⟩ + let k := G.vertexOrbit x + obtain ⟨φ,hφ⟩ := G.orbit_out_aut x + let f : G.fullGraph →g G.fullGraph := + ⟨φ.vertex,fun {_ _} h => (Aut.fullGraph_adj G φ _ _).mpr h⟩ + refine ⟨φ.vertex (y k),((w k).map f).copy hφ rfl,?_,?_,?_⟩ + · simpa only [SimpleGraph.Walk.length_copy,SimpleGraph.Walk.length_map] using + hj k (Finset.mem_univ _) + · intro v hv + simp only [SimpleGraph.Walk.support_copy,SimpleGraph.Walk.support_map,List.mem_map] at hv + obtain ⟨z,hz,rfl⟩ := hv + change G.orbitAdjustedHeight a x (φ.vertex z) ≤ 0 + rw [← hφ,G.orbitAdjustedHeight_aut a (G.stationaryOrbitWeight_aut μ)] + exact hw k z hz + · change G.orbitAdjustedHeight a x (φ.vertex (y k)) ≤ -fall i + rw [← hφ,G.orbitAdjustedHeight_aut a (G.stationaryOrbitWeight_aut μ)] + have hh := hi k (Finset.mem_univ _) + dsimp [fall] at hh ⊢ + linarith + +lemma height_descent_iterate (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (ε : ℝ) (hε : 0 ≤ ε) (L : ℕ) + (hstep : ∀ x, ∃ y, ∃ w : G.fullGraph.Walk x y, w.length ≤ L ∧ + (∀ v ∈ w.support, G.orbitAdjustedHeight a x v ≤ 0) ∧ G.orbitAdjustedHeight a x y ≤ -ε) + (n : ℕ) (x : V) : + ∃ y, ∃ w : G.fullGraph.Walk x y, w.length ≤ n*L ∧ + (∀ v ∈ w.support, G.orbitAdjustedHeight a x v ≤ 0) ∧ + G.orbitAdjustedHeight a x y ≤ -(n*ε) := by + induction n with + | zero => + refine ⟨x,.nil,by simp,?_,by simp⟩ + intro v hv + have he : v = x := List.mem_singleton.mp hv + rw [he,G.orbitAdjustedHeight_self] + | succ n ih => + obtain ⟨y,w,hlen,hw,hr⟩ := ih + obtain ⟨z,q,hqlen,hq,hqr⟩ := hstep y + refine ⟨z,w.append q,?_,?_,?_⟩ + · rw [SimpleGraph.Walk.length_append] + exact (Nat.add_le_add hlen hqlen).trans_eq (Nat.succ_mul n L).symm + · intro v hv + rcases (SimpleGraph.Walk.mem_support_append_iff _ _).mp hv with hv | hv + · exact hw v hv + · rw [G.orbitAdjustedHeight_change_base hc hl a x y v] + exact add_nonpos (hr.trans (neg_nonpos.mpr (mul_nonneg (Nat.cast_nonneg n) hε))) (hq v hv) + · rw [G.orbitAdjustedHeight_change_base hc hl a x y z] + push_cast + nlinarith + +theorem stationaryOrbitHeight_orbit_below [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : Percolation.BenjaminiSchramm.orbitChainStep (G.orbitWalkKernel hl) μ = μ) + (hu : ¬ G.CombinatoriallyUnimodular) : + ∃ A B : ℝ, 0 < A ∧ 0 ≤ B ∧ ∀ r : ℝ, 0 ≤ r → ∀ x (j : G.VertexOrbit), + ∃ y, ∃ w : G.fullGraph.Walk x y, G.vertexOrbit y = j ∧ + (w.length : ℝ) ≤ A*r+B ∧ + (∀ v ∈ w.support, G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0) ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x y ≤ -r := by + obtain ⟨ε,hε,L,hstep⟩ := G.stationaryOrbitHeight_uniform_descent hc hl hq μ hμ hstat hu + let a := G.stationaryOrbitWeight μ + obtain ⟨N,D,hD,hconn⟩ := G.height_uniform_orbit_connection_abs hc a (G.stationaryOrbitWeight_aut μ) + let A : ℝ := (L : ℝ)/ε+1 + let B : ℝ := (D/ε+1)*L+N + refine ⟨A,B,by dsimp [A]; positivity,by dsimp [B]; positivity,fun r hr x j => ?_⟩ + let n : ℕ := ⌈(r+D)/ε⌉₊ + have hn : r+D ≤ (n : ℝ)*ε := (div_le_iff₀ hε).mp (Nat.le_ceil ((r+D)/ε)) + have hn' : (n : ℝ) ≤ (r+D)/ε+1 := + (Nat.ceil_lt_add_one (div_nonneg (add_nonneg hr hD) hε.le)).le + obtain ⟨y,w,hwlen,hw,hwy⟩ := G.height_descent_iterate hc hl a ε hε.le L hstep n x + obtain ⟨z,q,hqorb,hqlen,hq⟩ := hconn y j + refine ⟨z,w.append q,hqorb,?_,?_,?_⟩ + · rw [SimpleGraph.Walk.length_append,Nat.cast_add] + have hwl : (w.length : ℝ) ≤ (n : ℝ)*L := by exact_mod_cast hwlen + have hql : (q.length : ℝ) ≤ N := by exact_mod_cast hqlen + have hm := mul_le_mul_of_nonneg_right hn' (Nat.cast_nonneg L : (0 : ℝ) ≤ L) + have he : (((r+D)/ε+1)*L+(N : ℝ)) = (L:ℝ)/ε*r+B := by dsimp [B]; ring + calc + _ ≤ (n : ℝ)*L+(N : ℝ) := add_le_add hwl hql + _ ≤ ((r+D)/ε+1)*L+(N : ℝ) := add_le_add hm le_rfl + _ = (L : ℝ)/ε*r+B := he + _ ≤ A*r+B := by dsimp [A]; nlinarith + · intro v hv + rcases (SimpleGraph.Walk.mem_support_append_iff _ _).mp hv with hv | hv + · exact hw v hv + · rw [G.orbitAdjustedHeight_change_base hc hl a x y v] + have hv' := (abs_le.mp (hq v hv)).2 + linarith + · rw [G.orbitAdjustedHeight_change_base hc hl a x y z] + have hz := (abs_le.mp (hq z q.end_mem_support)).2 + linarith + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UpperLayerSecondMoment.lean b/lean/OAI/Probability/BenjaminiSchramm/UpperLayerSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..62d205d3090ac150ca11f9717f18e28faa03052c --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UpperLayerSecondMoment.lean @@ -0,0 +1,116 @@ +import OAI.Probability.BenjaminiSchramm.LayerSecondMomentDecomposition + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem adjusted_upper_layer_second_moment_bound + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (a : V → ℝ) (R : ℝ) (p : unitInterval) (x : V) (u : ℝ) (n : ℕ) : + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | G.adjustedLayerIndex a R u x y ≤ (n : ℤ)}) + {y | G.adjustedLayerIndex a R u x y=(n : ℤ)} ω x)^2 ∂G.law p) ≤ + ∑' i : ℤ, if i ≤ (n : ℤ) then G.supAdjustedFullLayerMoment a R p i * + (G.supAdjustedUpLayerMoment a R p ((n : ℤ)-i).toNat)^2 else 0 := by + let f := G.adjustedLayerIndex a R u x + let I := Percolation.internalEdges G.ends {y | f y ≤ (n : ℤ)} + let A := {y | f y=(n : ℤ)} + let T (z : V) := G.law p {ω | Percolation.Conn G.ends (ω ∩ I) x z} + let M (z : V) := ∫⁻ ω, restrictedLayerCount G.ends I A ω z ∂G.law p + have hcont (z : V) (hz : f z ≤ (n : ℤ)) : + M z ≤ G.supAdjustedUpLayerMoment a R p ((n : ℤ)-f z).toNat := by + let v := G.orbitAdjustedHeight a x z/R+u + have hidx (y : V) : f y=f z+G.adjustedLayerIndex a R v z y := + G.adjustedLayerIndex_change_base hc hl a R u x z y + have hdom : {y : V | f y ≤ (n : ℤ)}= + {y | G.adjustedLayerIndex a R v z y ≤ (((n : ℤ)-f z).toNat : ℤ)} := by + ext y + change f y ≤ (n : ℤ) ↔ G.adjustedLayerIndex a R v z y ≤ (((n : ℤ)-f z).toNat : ℤ) + rw [hidx,Int.toNat_of_nonneg (sub_nonneg.mpr hz)] + omega + have htar : A={y | G.adjustedLayerIndex a R v z y = (((n : ℤ)-f z).toNat : ℤ)} := by + ext y + change f y=(n : ℤ) ↔ G.adjustedLayerIndex a R v z y = (((n : ℤ)-f z).toNat : ℤ) + rw [hidx,Int.toNat_of_nonneg (sub_nonneg.mpr hz)] + omega + change (∫⁻ ω, restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {y | f y ≤ (n : ℤ)}) A ω z ∂G.law p) ≤ _ + rw [hdom,htar] + exact G.adjustedUpLayerMoment_le_sup a R p _ z v + have hzero (z : V) (hz : ¬f z ≤ (n : ℤ)) : T z=0 := by + have hx : x ∈ {y | f y ≤ (n : ℤ)} := by + change f x ≤ (n : ℤ) + simp only [f,G.adjustedLayerIndex_self,Nat.cast_nonneg] + have he : {ω : Set E | Percolation.Conn G.ends (ω ∩ I) x z}=∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro ω hω + exact hz (Percolation.conn_internal_endpoint G.ends {y | f y ≤ (n : ℤ)} hx hω) + change G.law p {ω | Percolation.Conn G.ends (ω ∩ I) x z}=0 + rw [he,measure_empty] + have hrow (i : ℤ) : (∑' z, if f z=i then T z else 0) ≤ G.supAdjustedFullLayerMoment a R p i := by + apply le_trans _ (G.adjustedFullLayerMoment_le_sup a R p i x u) + rw [adjustedFullLayerMoment] + change _ ≤ ∫⁻ ω, restrictedLayerCount G.ends Set.univ {y | f y=i} ω x ∂Percolation.law p + rw [lintegral_restrictedLayerCount] + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z=i + · simp only [Set.mem_ofPred_eq,hz,ite_true,T] + exact measure_mono fun ω hω => Percolation.conn_mono G.ends + (show ω ∩ I ⊆ ω ∩ Set.univ from fun e he => ⟨he.1,Set.mem_univ e⟩) hω + · simp only [Set.mem_ofPred_eq,hz,ite_false,le_refl] + calc + _ ≤ ∑' z, T z*(M z)^2 := by + simpa only [pow_two,mul_assoc,T,M,I,A,f,law,Percolation.law] using + restricted_layer_second_moment G.ends I A A p x + _ ≤ ∑' z, if f z ≤ (n : ℤ) then + T z*(G.supAdjustedUpLayerMoment a R p ((n : ℤ)-f z).toNat)^2 else 0 := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z ≤ (n : ℤ) + · rw [ite_eq_left hz] + exact mul_le_mul' le_rfl (pow_le_pow_left' (hcont z hz) 2) + · rw [ite_eq_right hz,hzero z hz,zero_mul] + _ ≤ ∑' z, ∑' i : ℤ, if f z=i ∧ i ≤ (n : ℤ) then + T z*(G.supAdjustedUpLayerMoment a R p ((n : ℤ)-i).toNat)^2 else 0 := by + apply ENNReal.tsum_le_tsum + intro z + by_cases hz : f z ≤ (n : ℤ) + · rw [ite_eq_left hz] + have hband : f z=f z ∧ f z ≤ (n : ℤ) := ⟨rfl,hz⟩ + have ht := ENNReal.le_tsum (f := fun i : ℤ => if f z=i ∧ i ≤ (n : ℤ) then + T z*(G.supAdjustedUpLayerMoment a R p ((n : ℤ)-i).toNat)^2 else 0) (f z) + rwa [ite_eq_left hband] at ht + · rw [ite_eq_right hz] + exact bot_le + _ = ∑' i : ℤ, if i ≤ (n : ℤ) then (∑' z, if f z=i then T z else 0)* + (G.supAdjustedUpLayerMoment a R p ((n : ℤ)-i).toNat)^2 else 0 := by + rw [ENNReal.tsum_comm] + apply tsum_congr + intro i + by_cases hi : i ≤ (n : ℤ) + · rw [ite_eq_left hi,←ENNReal.tsum_mul_right] + apply tsum_congr + intro z + by_cases hz : f z=i <;> + simp only [hz,hi,true_and,false_and,ite_true,ite_false,zero_mul] + · simp only [hi,and_false,ite_false,tsum_zero] + _ ≤ _ := by + apply ENNReal.tsum_le_tsum + intro i + by_cases hi : i ≤ (n : ℤ) + · rw [ite_eq_left hi,ite_eq_left hi] + exact mul_le_mul' (hrow i) le_rfl + · simp only [hi,ite_false,le_refl] + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UpperMomentConvolution.lean b/lean/OAI/Probability/BenjaminiSchramm/UpperMomentConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac77c67c298c1e25780259ae756311bf8bd37424 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UpperMomentConvolution.lean @@ -0,0 +1,73 @@ +import OAI.Probability.BenjaminiSchramm.PrefixMaximumBootstrap +import OAI.Probability.BenjaminiSchramm.LayerMomentFekete + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma normalized_upper_convolution_bound (S : ℕ → ℝ) (hS : ∀ n, 0 ≤ S n) + (β K : ℝ) (hβ : 0 < β) + (hdecay : ∀ n : ℕ, S n ≤ K*Real.exp (-(3*β/4)*n)) : + ∃ A : ℝ, 0 < A ∧ ∀ n : ℕ, + (∑ i ∈ Finset.range (n+1), S i*(S (n-i))^2) ≤ + A*Real.exp (-β*n)*prefixMaximum (fun j => Real.exp (β*j)*S j) n := by + let H : ℕ → ℝ := fun j => Real.exp (β*j)*S j + let g : ℕ → ℝ := fun j => Real.exp (-β/2*j) + have hg : Summable g := by + simpa only [g,mul_comm] using + (Real.summable_exp_nat_mul_iff.mpr (by linarith : -β/2 < 0)) + have hg0 : ∀ j, 0 ≤ g j := fun _ => (Real.exp_pos _).le + let B := K^2*∑' j, g j + have hB : 0 ≤ B := mul_nonneg (sq_nonneg K) (tsum_nonneg hg0) + refine ⟨B+1,by linarith,fun n => ?_⟩ + let M := prefixMaximum H n + have hM : 0 ≤ M := (mul_nonneg (Real.exp_pos _).le (hS 0)).trans + (le_prefixMaximum H (Nat.zero_le n)) + have hs (i : ℕ) (hi : i ≤ n) : S i=Real.exp (-β*i)*H i := by + dsimp only [H] + rw [←mul_assoc,←Real.exp_add,show -β*(i : ℝ)+β*i=0 by ring,Real.exp_zero,one_mul] + have hp (i : ℕ) (hi : i ≤ n) : + S i*(S (n-i))^2 ≤ Real.exp (-β*n)*M*K^2*g (n-i) := by + have hsum : (i : ℝ)+(n-i : ℕ)=n := by exact_mod_cast (Nat.add_sub_of_le hi) + calc + _ = (Real.exp (-β*i)*H i)*(S (n-i))^2 := by rw [hs i hi] + _ ≤ (Real.exp (-β*i)*M)*(K*Real.exp (-(3*β/4)*(n-i : ℕ)))^2 := + mul_le_mul (mul_le_mul_of_nonneg_left (le_prefixMaximum H hi) (Real.exp_pos _).le) + (pow_le_pow_left₀ (hS (n-i)) (hdecay (n-i)) 2) (sq_nonneg _) + (mul_nonneg (Real.exp_pos _).le hM) + _ = Real.exp (-β*n)*M*K^2*g (n-i) := by + have he : Real.exp (-β*i)*(Real.exp (-(3*β/4)*(n-i : ℕ)))^2 = + Real.exp (-β*n)*g (n-i) := by + rw [pow_two,←Real.exp_add,←Real.exp_add] + dsimp only [g] + rw [←Real.exp_add] + congr 1 + nlinarith [hsum] + calc + _ = M*K^2*(Real.exp (-β*i)*(Real.exp (-(3*β/4)*(n-i : ℕ)))^2) := by ring + _ = _ := by rw [he]; ring + have hsumg : (∑ i ∈ Finset.range (n+1), g (n-i)) ≤ ∑' j, g j := by + have he := Finset.sum_range_reflect g (n+1) + simp only [Nat.add_sub_cancel] at he + rw [he] + exact hg.sum_le_tsum _ (fun j _ => hg0 j) + calc + _ ≤ ∑ i ∈ Finset.range (n+1), Real.exp (-β*n)*M*K^2*g (n-i) := + Finset.sum_le_sum fun i hi => hp i (Nat.le_of_lt_succ (Finset.mem_range.mp hi)) + _ = Real.exp (-β*n)*M*K^2*(∑ i ∈ Finset.range (n+1), g (n-i)) := + (Finset.mul_sum _ _ _).symm + _ ≤ Real.exp (-β*n)*M*K^2*(∑' j, g j) := + mul_le_mul_of_nonneg_left hsumg (by positivity) + _ = B*Real.exp (-β*n)*M := by dsimp only [B]; ring + _ ≤ (B+1)*Real.exp (-β*n)*M := by + apply mul_le_mul_of_nonneg_right _ hM + exact mul_le_mul_of_nonneg_right (by linarith) (Real.exp_pos _).le + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UpwardCeilingProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/UpwardCeilingProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b00eb4371c4c998f46fd00af9d4e710fff91534 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UpwardCeilingProfile.lean @@ -0,0 +1,183 @@ +import OAI.Probability.BenjaminiSchramm.HalfspaceFiniteShiftProfile +import OAI.Probability.BenjaminiSchramm.UpwardFractionalSlabProfile +import OAI.Probability.BenjaminiSchramm.FractionalBandEstimate +import OAI.Probability.BenjaminiSchramm.BoundedLayerShift + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +omit [Countable V] [Countable E] in +lemma adjustedCeilingBandCount_rpow_mono_exponent (a : V → ℝ) (c l u : ℝ) + (ω : Set E) (x : V) {q q' : ℝ} (hq : 0 < q) (hqq' : q ≤ q') : + (G.adjustedCeilingBandCount a c l u ω x)^q ≤ + (G.adjustedCeilingBandCount a c l u ω x)^q' := by + simp only [G.adjustedCeilingBandCount_eq_restrictedLayerCount] + rcases restrictedLayerCount_zero_or_one_le G.ends _ _ ω x with hz | ho + · rw [hz,ENNReal.zero_rpow_of_pos hq,ENNReal.zero_rpow_of_pos (hq.trans_le hqq')] + · exact ENNReal.rpow_le_rpow_of_exponent_le ho hqq' + +omit [Countable V] [Countable E] in +lemma one_le_adjustedCeilingZeroBandCount (a : V → ℝ) (c B : ℝ) + (hB : 0 ≤ B) (ω : Set E) (x : V) : + 1 ≤ G.adjustedCeilingBandCount a c (-B) B ω x := by + apply le_trans _ (ENNReal.le_tsum x) + unfold adjustedCeilingBandTransport + rw [ite_eq_left] + exact ⟨Percolation.conn_refl G.ends _ x,by simpa using neg_nonpos.mpr hB,by simpa using hB⟩ + +theorem upward_ceiling_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (Vcoef : ℝ) (hV : 0 < Vcoef) + (hdown : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ D : ℝ≥0∞, D < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 0}) + {v | -k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ -k+R} ω x)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ζ*k))) + (hzero : ∀ q : ℝ, 0 < q → q < 1 → ∃ Z : ℝ≥0∞, Z < ⊤ ∧ + ∀ c : ℝ, 0 ≤ c → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ c}) + {v | -(2*R) ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ 2*R} ω x)^q ∂G.law p) ≤ + Z*ENNReal.ofReal (Real.exp (Vcoef*c))) : + ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k}) + {v | k-R ≤ G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ∧ + G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) x v ≤ k+R} ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨m,M,hm,hbounds⟩ := G.stationaryOrbitWeight_uniform_bounds hc hl μ hμ + let O := G.orbitRepresentatives hq + let D := (ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r))*ENNReal.ofReal (Real.exp R) + have hD : D < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.inv_lt_top.mpr (ENNReal.ofReal_pos.mpr hm)) + (ENNReal.sum_lt_top.mpr fun _ _ => ENNReal.ofReal_lt_top)) ENNReal.ofReal_lt_top + intro q hq0 hq1 ζ hζ + let η := min ((1-q)/2) (min (ζ/4) (1/4)) + have hη : 0 < η := lt_min (by positivity) (lt_min (by positivity) (by norm_num)) + have hηq : η ≤ (1-q)/2 := min_le_left _ _ + have hηζ : η ≤ ζ/4 := (min_le_right _ _).trans (min_le_left _ _) + have hη1 : η ≤ 1/4 := (min_le_right _ _).trans (min_le_right _ _) + let q' := 1-η + have hq'0 : 0 < q' := by dsimp [q']; linarith + have hq'1 : q' < 1 := by dsimp [q']; linarith + have hqq' : q ≤ q' := by dsimp [q']; linarith + let δ := min ((1-q')/2) (ζ/(4*(Vcoef+1))) + have hδ : 0 < δ := lt_min (by positivity) (div_pos hζ (by positivity)) + have hδq' : δ ≤ 1-q' := (min_le_left _ _).trans (by linarith) + have hδ1 : δ < 1 := by linarith + have hδV : δ*Vcoef ≤ ζ/4 := by + have hh := (le_div_iff₀ (show 0 < 4*(Vcoef+1) by positivity)).mp + (min_le_right ((1-q')/2) (ζ/(4*(Vcoef+1)))) + change δ*(4*(Vcoef+1)) ≤ ζ at hh + nlinarith + let ε := min (ζ/4) (1/2) + have hε : 0 < ε := lt_min (by positivity) (by norm_num) + have hεζ : ε ≤ ζ/4 := min_le_left _ _ + obtain ⟨T,hT,hshift⟩ := G.halfspace_ceiling_shift_profile_fixed hc hl hq μ hμ hstat hu R hR.le hjump p hp0 hp1 ε + obtain ⟨C₁,hC₁,hbound₁⟩ := hshift (1-δ) (by linarith) + (hdown (1-δ) (by linarith) (by linarith) ε hε) + obtain ⟨C₂,hC₂,hbound₂⟩ := hzero q' hq'0 hq'1 + let Q := C₁*ENNReal.ofReal (Real.exp (T*R)) + let Z := C₂*ENNReal.ofReal (Real.exp (Vcoef*(2*R))) + have hQ : Q < ⊤ := ENNReal.mul_lt_top hC₁ ENNReal.ofReal_lt_top + have hZ : Z < ⊤ := ENNReal.mul_lt_top hC₂ ENNReal.ofReal_lt_top + let A := D*Q + have hA : A < ⊤ := ENNReal.mul_lt_top hD hQ + let C := A^q'*Z^δ + have hC : C < ⊤ := ENNReal.mul_lt_top + (ENNReal.rpow_lt_top_of_nonneg hq'0.le hA.ne) (ENNReal.rpow_lt_top_of_nonneg hδ.le hZ.ne) + refine ⟨C,hC,fun k hk x => ?_⟩ + have hzero' : (∫⁻ ω, (G.adjustedCeilingBandCount a (k+2*R) (-(2*R)) (2*R) ω x)^q' ∂G.law p) ≤ + Z*ENNReal.ofReal (Real.exp (Vcoef*k)) := by + have hh := hbound₂ (k+2*R) (by positivity) x + simp_rw [G.adjustedCeilingBandCount_eq_restrictedLayerCount] + apply hh.trans_eq + dsimp [Z] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show Vcoef*(k+2*R)=Vcoef*(2*R)+Vcoef*k by ring] + have hdown' (y : V) : (∫⁻ ω, (G.adjustedCeilingBandCount a R (-k-R) (-k+R) ω y)^(1-δ) ∂G.law p) ≤ + Q*ENNReal.ofReal (Real.exp (ε*k)) := by + have hh := hbound₁ k hk R hR.le y + simp_rw [G.adjustedCeilingBandCount_eq_restrictedLayerCount] + apply hh.trans_eq + dsimp [Q] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show ε*k+T*R=T*R+ε*k by ring] + have hZfin : ∀ᵐ ω ∂G.law p, + 1 ≤ G.adjustedCeilingBandCount a (k+2*R) (-(2*R)) (2*R) ω x ∧ + G.adjustedCeilingBandCount a (k+2*R) (-(2*R)) (2*R) ω x ≠ ⊤ := by + filter_upwards [hfin x] with ω hω + refine ⟨G.one_le_adjustedCeilingZeroBandCount a _ _ (by positivity) ω x,?_⟩ + rw [G.adjustedCeilingBandCount_eq_restrictedLayerCount] + exact (restrictedLayerCount_lt_top_of_finite G.ends _ _ ω x hω).ne + have hwidth : (k+R)-(k-R)=2*R := by ring + have hminus : (k-R)-(k+R)= -(2*R) := by ring + have hnegl : -(k-R)= -k+R := by ring + have hnegu : -(k+R)= -k-R := by ring + have hreverse : k+2*R-(k+R)=R := by ring + have hforward : k+2*R-2*R=k := by ring + have hh := G.fractional_ceiling_band_estimate O hc hl a (G.stationaryOrbitWeight_pos hc hl μ hμ) + (G.stationaryOrbitWeight_aut μ) m hm (fun z => (hbounds z).1) p (k+2*R) (k-R) (k+R) x + hq'0 hq'1 hδ.le hδq' + (by simpa only [hminus,hwidth] using hZfin) + (Z*ENNReal.ofReal (Real.exp (Vcoef*k))) (Q*ENNReal.ofReal (Real.exp (ε*k))) + (by simpa only [hminus,hwidth] using hzero') + (fun y _ => by simpa only [hreverse,hnegu,hnegl] using hdown' y) + simp only [hwidth,hforward] at hh + have hfactor : (((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-(k-R)))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*(Q*ENNReal.ofReal (Real.exp (ε*k)))) = + A*ENNReal.ofReal (Real.exp ((ε-1)*k)) := by + dsimp [A,D] + have he : Real.exp (-(k-R))*Real.exp (ε*k)=Real.exp R*Real.exp ((ε-1)*k) := by + rw [←Real.exp_add,←Real.exp_add] + congr 1 + ring + calc + _ = ((ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r))*Q)* + (ENNReal.ofReal (Real.exp (-(k-R)))*ENNReal.ofReal (Real.exp (ε*k))) := by ac_rfl + _ = _ := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),he,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + rw [hfactor] at hh + have heq : (A*ENNReal.ofReal (Real.exp ((ε-1)*k)))^q'* + (Z*ENNReal.ofReal (Real.exp (Vcoef*k)))^δ = + C*ENNReal.ofReal (Real.exp ((q'*(ε-1)+δ*Vcoef)*k)) := by + simpa only [mul_zero,add_zero] using + fractional_two_profile_product A Z (ε-1) 0 Vcoef 0 k 0 q' δ hq'0.le hδ.le + have hmono : (∫⁻ ω, (G.adjustedCeilingBandCount a k (k-R) (k+R) ω x)^q ∂G.law p) ≤ + ∫⁻ ω, (G.adjustedCeilingBandCount a k (k-R) (k+R) ω x)^q' ∂G.law p := + lintegral_mono (fun ω => G.adjustedCeilingBandCount_rpow_mono_exponent a _ _ _ ω x hq0 hqq') + simp_rw [←G.adjustedCeilingBandCount_eq_restrictedLayerCount] + apply (hmono.trans hh).trans + rw [heq] + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hqε : q'*ε ≤ ε := mul_le_of_le_one_left hε.le hq'1.le + have hrate : q'*(ε-1)+δ*Vcoef ≤ -1+ζ := by dsimp [q'] at hqε ⊢; nlinarith + exact mul_le_mul_of_nonneg_right hrate hk + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UpwardFractionalSlabProfile.lean b/lean/OAI/Probability/BenjaminiSchramm/UpwardFractionalSlabProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..82861db9ea5468d11181c9c1185631888e58b1ea --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UpwardFractionalSlabProfile.lean @@ -0,0 +1,179 @@ +import OAI.Probability.BenjaminiSchramm.SlabFractionalProfileShift +import OAI.Probability.BenjaminiSchramm.SlabCountBasic +import OAI.Probability.BenjaminiSchramm.FractionalSlabEstimate +import OAI.Probability.BenjaminiSchramm.CriticalFractionalSlab + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +lemma fractional_two_profile_product (A B : ℝ≥0∞) (t u v w k r a δ : ℝ) + (ha : 0 ≤ a) (hδ : 0 ≤ δ) : + (A*ENNReal.ofReal (Real.exp (t*k+u*r)))^a* + (B*ENNReal.ofReal (Real.exp (v*k+w*r)))^δ = + (A^a*B^δ)*ENNReal.ofReal (Real.exp ((a*t+δ*v)*k+(a*u+δ*w)*r)) := by + rw [ENNReal.mul_rpow_of_nonneg _ _ ha,ENNReal.mul_rpow_of_nonneg _ _ hδ, + ennreal_exp_rpow _ _ ha,ennreal_exp_rpow _ _ hδ] + calc + _ = (A^a*B^δ)*(ENNReal.ofReal (Real.exp ((t*k+u*r)*a))* + ENNReal.ofReal (Real.exp ((v*k+w*r)*δ))) := by ac_rfl + _ = _ := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show (t*k+u*r)*a+(v*k+w*r)*δ=(a*t+δ*v)*k+(a*u+δ*w)*r by ring] + +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem upward_fractional_slab_profile [Fintype G.VertexOrbit] [Nontrivial V] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (μ : G.VertexOrbit → ℝ) (hμ : ∀ i, 0 < μ i) + (hstat : orbitChainStep (G.orbitWalkKernel hl) μ=μ) + (hu : ¬G.CombinatoriallyUnimodular) (R : ℝ) (hR : 0 < R) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → + |G.orbitAdjustedHeight (G.stationaryOrbitWeight μ) v w| ≤ R) + (p : unitInterval) (hp0 : (0 : ℝ) < p) (hp1 : (p : ℝ) < 1) + (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (L₁ L₂ : ℝ) + (hprofile₁ : G.lowerSlabFractionalProfile (G.stationaryOrbitWeight μ) p R L₁) + (hprofile₂ : G.lowerSlabFractionalProfile (G.stationaryOrbitWeight μ) p (2*R) L₂) : + ∃ U : ℝ, 0 < U ∧ ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount (G.stationaryOrbitWeight μ) (-r) (k+r) (k-R) (k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k+U*r)) := by + let a := G.stationaryOrbitWeight μ + obtain ⟨T₁,hT₁,hshift₁⟩ := G.finite_ceiling_fractional_profile hc hl hq μ hμ hstat hu R hR hjump + p hp0 hp1 L₁ hprofile₁ + have hjump₂ : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ 2*R := by + intro e v w hv hw + exact (hjump e v w hv hw).trans (by linarith) + obtain ⟨T₂,hT₂,hshift₂⟩ := G.finite_ceiling_fractional_profile hc hl hq μ hμ hstat hu + (2*R) (by positivity) hjump₂ p hp0 hp1 L₂ hprofile₂ + obtain ⟨m,M,hm,hbounds⟩ := G.stationaryOrbitWeight_uniform_bounds hc hl μ hμ + let O := G.orbitRepresentatives hq + let D := (ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r))*ENNReal.ofReal (Real.exp R) + have hD : D < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.inv_lt_top.mpr (ENNReal.ofReal_pos.mpr hm)) + (ENNReal.sum_lt_top.mpr fun _ _ => ENNReal.ofReal_lt_top)) ENNReal.ofReal_lt_top + let U := |L₁|+T₁+|L₂|+T₂+1 + refine ⟨U,by dsimp [U]; positivity,?_⟩ + intro q hq0 hq1 ζ hζ + let η := min ((1-q)/2) (min (ζ/4) (1/4)) + have hη : 0 < η := lt_min (by positivity) (lt_min (by positivity) (by norm_num)) + have hηq : η ≤ (1-q)/2 := min_le_left _ _ + have hηζ : η ≤ ζ/4 := (min_le_right _ _).trans (min_le_left _ _) + have hη1 : η ≤ 1/4 := (min_le_right _ _).trans (min_le_right _ _) + let q' := 1-η + have hq'0 : 0 < q' := by dsimp [q']; linarith + have hq'1 : q' < 1 := by dsimp [q']; linarith + have hqq' : q ≤ q' := by dsimp [q']; linarith + let δ := min ((1-q')/2) (ζ/(4*(T₂+1))) + have hδ : 0 < δ := lt_min (by positivity) (div_pos hζ (by positivity)) + have hδq' : δ ≤ 1-q' := (min_le_left _ _).trans (by linarith) + have hδ1 : δ < 1 := by linarith + have hδT : δ*T₂ ≤ ζ/4 := by + have hh := (le_div_iff₀ (show 0 < 4*(T₂+1) by positivity)).mp (min_le_right ((1-q')/2) (ζ/(4*(T₂+1)))) + change δ*(4*(T₂+1)) ≤ ζ at hh + nlinarith + let ε := min (ζ/4) (1/2) + have hε : 0 < ε := lt_min (by positivity) (by norm_num) + have hε1 : ε ≤ 1 := (min_le_right _ _).trans (by norm_num) + have hεζ : ε ≤ ζ/4 := min_le_left _ _ + obtain ⟨C₁,hC₁,hbound₁⟩ := hshift₁ (1-δ) (by linarith) (by linarith) ε hε hε1 + obtain ⟨C₂,hC₂,hbound₂⟩ := hshift₂ q' hq'0 hq'1 ε hε hε1 + let Q := C₁*ENNReal.ofReal (Real.exp (L₁*R+T₁*R)) + let Z := C₂*ENNReal.ofReal (Real.exp (L₂*(2*R)+T₂*(2*R))) + have hQ : Q < ⊤ := ENNReal.mul_lt_top hC₁ ENNReal.ofReal_lt_top + have hZ : Z < ⊤ := ENNReal.mul_lt_top hC₂ ENNReal.ofReal_lt_top + let A := D*Q + have hA : A < ⊤ := ENNReal.mul_lt_top hD hQ + let C := A^q'*Z^δ + have hC : C < ⊤ := ENNReal.mul_lt_top + (ENNReal.rpow_lt_top_of_nonneg hq'0.le hA.ne) (ENNReal.rpow_lt_top_of_nonneg hδ.le hZ.ne) + refine ⟨C,hC,fun k hk r hr x => ?_⟩ + have hzero : (∫⁻ ω, (G.adjustedSlabBandCount a (-r-2*R) (k+r+2*R) (-2*R) (2*R) ω x)^q' ∂G.law p) ≤ + Z*ENNReal.ofReal (Real.exp (T₂*k+(L₂+T₂)*r)) := by + have hh := hbound₂ 0 (by norm_num) (r+2*R) (by positivity) (k+r+2*R) (by positivity) x + simp only [neg_zero,zero_sub,zero_add,mul_zero] at hh + rw [←neg_mul] at hh + rw [show -(r+2*R)= -r-2*R by ring] at hh + apply hh.trans_eq + dsimp [Z] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show L₂*(r+2*R)+T₂*(k+r+2*R)=(L₂*(2*R)+T₂*(2*R))+(T₂*k+(L₂+T₂)*r) by ring] + have hdown (y : V) : (∫⁻ ω, (G.adjustedSlabBandCount a (-k-r-R) (r+R) (-k-R) (-k+R) ω y)^(1-δ) ∂G.law p) ≤ + Q*ENNReal.ofReal (Real.exp (ε*k+(L₁+T₁)*r)) := by + have hh := hbound₁ k hk (r+R) (by positivity) (r+R) (by positivity) y + rw [show -k-(r+R)= -k-r-R by ring] at hh + apply hh.trans_eq + dsimp [Q] + rw [mul_assoc,←ENNReal.ofReal_mul (Real.exp_nonneg _),←Real.exp_add] + rw [show ε*k+L₁*(r+R)+T₁*(r+R)=(L₁*R+T₁*R)+(ε*k+(L₁+T₁)*r) by ring] + have hZfin : ∀ᵐ ω ∂G.law p, + 1 ≤ G.adjustedSlabBandCount a (-r-2*R) (k+r+2*R) (-2*R) (2*R) ω x ∧ + G.adjustedSlabBandCount a (-r-2*R) (k+r+2*R) (-2*R) (2*R) ω x ≠ ⊤ := by + filter_upwards [hfin x] with ω hω + exact ⟨by simpa only [neg_mul] using + G.one_le_adjustedSlabZeroBandCount a (-r-2*R) (k+r+2*R) (2*R) (by positivity) ω x, + (G.adjustedSlabBandCount_lt_top_of_finite a _ _ _ _ ω x hω).ne⟩ + have hwidth : (k+R)-(k-R)=2*R := by ring + have hnegl : -(k-R)= -k+R := by ring + have hnegu : -(k+R)= -k-R := by ring + have hlow : -r-2*R- (k-R)= -k-r-R := by ring + have hhigh : k+r+2*R-(k+R)=r+R := by ring + have hfwlo : -r-2*R+2*R= -r := by ring + have hfwup : k+r+2*R-2*R=k+r := by ring + have hminus : (k-R)-(k+R)= -2*R := by ring + have hh := G.fractional_slab_band_estimate O hc hl a (G.stationaryOrbitWeight_pos hc hl μ hμ) + (G.stationaryOrbitWeight_aut μ) m hm (fun z => (hbounds z).1) p (-r-2*R) (k+r+2*R) (k-R) (k+R) x + hq'0 hq'1 hδ.le hδq' + (by simpa only [hminus,hwidth] using hZfin) + (Z*ENNReal.ofReal (Real.exp (T₂*k+(L₂+T₂)*r))) (Q*ENNReal.ofReal (Real.exp (ε*k+(L₁+T₁)*r))) + (by simpa only [hminus,hwidth] using hzero) + (fun y _ => by simpa only [hlow,hhigh,hnegu,hnegl] using hdown y) + simp only [hwidth,hfwlo,hfwup] at hh + have hfactor : (((ENNReal.ofReal m)⁻¹*ENNReal.ofReal (Real.exp (-(k-R)))* + (∑ r ∈ O.roots, ENNReal.ofReal (a r)))*(Q*ENNReal.ofReal (Real.exp (ε*k+(L₁+T₁)*r)))) = + A*ENNReal.ofReal (Real.exp ((ε-1)*k+(L₁+T₁)*r)) := by + dsimp [A,D] + have he : Real.exp (-(k-R))*Real.exp (ε*k+(L₁+T₁)*r)=Real.exp R*Real.exp ((ε-1)*k+(L₁+T₁)*r) := by + rw [←Real.exp_add,←Real.exp_add] + congr 1 + ring + calc + _ = ((ENNReal.ofReal m)⁻¹*(∑ r ∈ O.roots, ENNReal.ofReal (a r))*Q)* + (ENNReal.ofReal (Real.exp (-(k-R)))*ENNReal.ofReal (Real.exp (ε*k+(L₁+T₁)*r))) := by ac_rfl + _ = _ := by + rw [←ENNReal.ofReal_mul (Real.exp_nonneg _),he,ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + rw [hfactor] at hh + have heq : (A*ENNReal.ofReal (Real.exp ((ε-1)*k+(L₁+T₁)*r)))^q'* + (Z*ENNReal.ofReal (Real.exp (T₂*k+(L₂+T₂)*r)))^δ = + C*ENNReal.ofReal (Real.exp ((q'*(ε-1)+δ*T₂)*k+(q'*(L₁+T₁)+δ*(L₂+T₂))*r)) := + fractional_two_profile_product A Z (ε-1) (L₁+T₁) T₂ (L₂+T₂) k r q' δ hq'0.le hδ.le + have hmono : (∫⁻ ω, (G.adjustedSlabBandCount a (-r) (k+r) (k-R) (k+R) ω x)^q ∂G.law p) ≤ + ∫⁻ ω, (G.adjustedSlabBandCount a (-r) (k+r) (k-R) (k+R) ω x)^q' ∂G.law p := + lintegral_mono (fun ω => G.adjustedSlabBandCount_rpow_mono_exponent a _ _ _ _ ω x hq0 hqq') + apply (hmono.trans hh).trans + rw [heq] + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + have hqε : q'*ε ≤ ε := mul_le_of_le_one_left hε.le hq'1.le + have hrate : q'*(ε-1)+δ*T₂ ≤ -1+ζ := by dsimp [q'] at hqε ⊢; nlinarith + have hcoef₁ : q'*(L₁+T₁) ≤ |L₁|+T₁ := + (mul_le_mul_of_nonneg_left (add_le_add (le_abs_self _) le_rfl) hq'0.le).trans + (mul_le_of_le_one_left (by positivity) hq'1.le) + have hcoef₂ : δ*(L₂+T₂) ≤ |L₂|+T₂ := + (mul_le_mul_of_nonneg_left (add_le_add (le_abs_self _) le_rfl) hδ.le).trans + (mul_le_of_le_one_left (by positivity) hδ1.le) + have hcoeff : q'*(L₁+T₁)+δ*(L₂+T₂) ≤ U := by dsimp [U]; linarith + exact add_le_add (mul_le_mul_of_nonneg_right hrate hk) (mul_le_mul_of_nonneg_right hcoeff hr) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UpwardFrontierProbability.lean b/lean/OAI/Probability/BenjaminiSchramm/UpwardFrontierProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8edc3bbbbd3e3b61ae6845ee41d336c9ba710f4 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UpwardFrontierProbability.lean @@ -0,0 +1,69 @@ +import OAI.Probability.BenjaminiSchramm.IntegerFrontierCrossing +import OAI.Probability.BenjaminiSchramm.SubcriticalUpperSecondMoment + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def supAdjustedFrontierProbability (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) : ℝ≥0∞ := + ⨆ x, ⨆ u : ℝ, G.law p {ω | 0 < frontierCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v < (n : ℤ)}) Set.univ ω x} + +omit [Countable V] [Countable E] in +lemma supAdjustedFrontierProbability_le_one (a : V → ℝ) (R : ℝ) (p : unitInterval) (n : ℕ) : + G.supAdjustedFrontierProbability a R p n ≤ 1 := by + apply iSup_le + intro x + apply iSup_le + intro u + exact prob_le_one + +theorem adjusted_frontier_probability_lower + (a : V → ℝ) (R : ℝ) (p : unitInterval) (β A : ℝ) (hA : 0 < A) + (hlower : ∀ n : ℕ, ENNReal.ofReal (Real.exp (-β*n)) ≤ G.supAdjustedUpLayerMoment a R p n) + (hsecond : ∀ (n : ℕ) (x : V) (u : ℝ), + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.adjustedLayerIndex a R u x v ≤ (n : ℤ)}) + {v | G.adjustedLayerIndex a R u x v=(n : ℤ)} ω x)^2 ∂G.law p) ≤ + ENNReal.ofReal (A*Real.exp (-β*n))) (n : ℕ) (hn : 0 < n) : + ENNReal.ofReal (Real.exp (-β*n)/A) ≤ G.supAdjustedFrontierProbability a R p n := by + let P := G.supAdjustedFrontierProbability a R p n + let t := Real.exp (-β*n) + have ht : 0 < t := Real.exp_pos _ + have hP : P ≠ ⊤ := ne_top_of_le_ne_top ENNReal.one_ne_top + (G.supAdjustedFrontierProbability_le_one a R p n) + have hsq : (G.supAdjustedUpLayerMoment a R p n)^2 ≤ P*ENNReal.ofReal (A*t) := by + apply ennreal_iSup_square_le + intro x + apply ennreal_iSup_square_le + intro u + let f := G.adjustedLayerIndex a R u x + have hfx : f x < (n : ℤ) := by + simp only [f,G.adjustedLayerIndex_self] + exact_mod_cast hn + have hprob := integer_upper_layer_hit_frontier_probability G.ends f (n : ℤ) x hfx p + have hsup : G.law p {ω | 0 < frontierCount G.ends + (Percolation.internalEdges G.ends {v | f v < (n : ℤ)}) Set.univ ω x} ≤ P := + le_iSup_of_le x (le_iSup_of_le u le_rfl) + exact (restrictedLayerCount_moment_cauchy G.ends _ _ p x).trans + (mul_le_mul' (hprob.trans hsup) (hsecond n x u)) + have hlo : (ENNReal.ofReal t)^2 ≤ P*ENNReal.ofReal (A*t) := + (pow_le_pow_left' (hlower n) 2).trans hsq + have hreal := ENNReal.toReal_mono (ENNReal.mul_ne_top hP ENNReal.ofReal_ne_top) hlo + rw [ENNReal.toReal_pow,ENNReal.toReal_mul,ENNReal.toReal_ofReal ht.le, + ENNReal.toReal_ofReal (mul_nonneg hA.le ht.le)] at hreal + have hc : t ≤ P.toReal*A := (mul_le_mul_iff_right₀ ht).mp (by nlinarith) + apply ENNReal.ofReal_le_of_le_toReal + exact (div_le_iff₀ hA).mpr (by nlinarith) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/UpwardHalfspaceFromContinuation.lean b/lean/OAI/Probability/BenjaminiSchramm/UpwardHalfspaceFromContinuation.lean new file mode 100644 index 0000000000000000000000000000000000000000..31ad113629ac6fea663e372fbdb6c4ab05e37193 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/UpwardHalfspaceFromContinuation.lean @@ -0,0 +1,186 @@ +import OAI.Probability.BenjaminiSchramm.CeilingZeroBand + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +theorem upward_halfspace_from_continuation + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (d : ℕ) (hd : ∀ u, (Percolation.finite_neighbors hl u).toFinset.card ≤ d) + (R : ℝ) (hR : 0 < R) + (hjump : ∀ e u v, u ∈ G.ends e → v ∈ G.ends e → |G.orbitAdjustedHeight a u v| ≤ R) + (p : unitInterval) (hfin : ∀ x, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω x).Finite) + (U : ℝ) (hup : ∀ q : ℝ, 0 < q → q < 1 → ∀ ζ : ℝ, 0 < ζ → + ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ r : ℝ, 0 ≤ r → ∀ x : V, + (∫⁻ ω, (G.adjustedSlabBandCount a (-r) (k+r) (k-R) (k+R) ω x)^q ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k+U*r))) + (q t ρ : ℝ) (hq : 0 < q) (hq1 : q ≤ 1) (ht : 0 < t) (ht1 : t < 1) + (hρ : 0 ≤ ρ) (hρ1 : ρ ≤ 3/4) + (D : ℝ≥0∞) (hD : D < ⊤) + (hdown : ∀ s : ℝ, 0 ≤ s → ∀ z : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | G.orbitAdjustedHeight a z v ≤ R}) + {v | -s-R ≤ G.orbitAdjustedHeight a z v ∧ G.orbitAdjustedHeight a z v ≤ -s+R} ω z)^q ∂G.law p) ≤ + D*ENNReal.ofReal (Real.exp (ρ*s))) : + ∀ ζ : ℝ, 0 < ζ → ∃ C : ℝ≥0∞, C < ⊤ ∧ ∀ k : ℝ, 0 ≤ k → ∀ x : V, + (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ G.orbitAdjustedHeight a x v}) + {v | k-R ≤ G.orbitAdjustedHeight a x v ∧ G.orbitAdjustedHeight a x v ≤ k+R} ω x)^(q*t) ∂G.law p) ≤ + C*ENNReal.ofReal (Real.exp ((-1+ζ)*k)) := by + intro ζ hζ + let ε := min ζ (1/8) + have hε : 0 < ε := lt_min hζ (by norm_num) + have hεζ : ε ≤ ζ := min_le_left _ _ + have hε1 : ε ≤ 1/8 := min_le_right _ _ + have hqt : 0 < q*t := mul_pos hq ht + have hqt1 : q*t < 1 := (mul_le_mul_of_nonneg_right hq1 ht.le).trans_lt (by simpa using ht1) + obtain ⟨A,hA,hab⟩ := hup t ht ht1 ε hε + obtain ⟨B,hB,hbb⟩ := hup (q*t) hqt hqt1 ε hε + let K := (d : ℝ≥0∞)^t*A*D^t* + ENNReal.ofReal (Real.exp (((-1+ε)+U)*R+t*ρ*(2*R))) + have hK : K < ⊤ := ENNReal.mul_lt_top + (ENNReal.mul_lt_top (ENNReal.mul_lt_top + (ENNReal.rpow_lt_top_of_nonneg ht.le (ENNReal.natCast_ne_top d)) hA) + (ENNReal.rpow_lt_top_of_nonneg ht.le hD.ne)) ENNReal.ofReal_lt_top + let B' := B*ENNReal.ofReal (Real.exp (U*R)) + have hB' : B' < ⊤ := ENNReal.mul_lt_top hB ENNReal.ofReal_lt_top + let S : ℝ≥0∞ := ∑' n : ℕ, ENNReal.ofReal (Real.exp (-(R/8)*n)) + have hS : S < ⊤ := by + apply Summable.tsum_ofReal_lt_top + simpa only [mul_comm] using Real.summable_exp_nat_mul_iff.mpr + (neg_neg_of_pos (show 0 < R/8 by positivity)) + refine ⟨B'+K*S,ENNReal.add_lt_top.mpr ⟨hB',ENNReal.mul_lt_top hK hS⟩,fun k hk x => ?_⟩ + let f := G.orbitAdjustedHeight a x + let W := {v | k-R ≤ f v ∧ f v ≤ k+R} + let F (n : ℕ) := ∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ k+R+(n : ℝ)*R}) W ω x)^(q*t) ∂G.law p + let Z := ENNReal.ofReal (Real.exp ((-1+ε)*k)) + have h0 : F 0 ≤ B'*Z := by + have hh := hbb k hk R hR.le x + apply le_trans _ (hh.trans_eq ?_) + · apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ hqt.le + rw [G.adjustedSlabBandCount_eq_restricted] + apply restrictedLayerCount_mono_edges G.ends + apply Percolation.internalEdges_mono G.ends + intro v hv + simp only [Nat.cast_zero,zero_mul,add_zero] at hv + exact ⟨by dsimp [f] at hv; linarith [hv.1],hv.2⟩ + · dsimp [B',Z] + rw [Real.exp_add ((-1+ε)*k) (U*R),ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + have hstep (n : ℕ) : F (n+1) ≤ F n+K*Z*ENNReal.ofReal (Real.exp (-(R/8)*n)) := by + let b := k+R+(n : ℝ)*R + let J := Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ k+R+((n : ℝ)+1)*R} + let L := D*ENNReal.ofReal (Real.exp (ρ*((n : ℝ)*R+2*R))) + have hL (z : V) (hzlo : b < f z) (hzhi : f z ≤ b+R) : + (∫⁻ ω, (restrictedLayerCount G.ends J W ω z)^q ∂G.law p) ≤ L := by + let s := f z-k + have hs : 0 ≤ s := by dsimp [s,b] at *; nlinarith [Nat.cast_nonneg (α := ℝ) n] + have hh := hdown s hs z + apply le_trans _ (hh.trans ?_) + · apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ hq.le + apply (restrictedLayerCount_mono_edges G.ends ?_ W ω z).trans + · apply restrictedLayerCount_mono_vertices G.ends + intro v hv + have he := G.orbitAdjustedHeight_change_base hc hl a x z v + dsimp [s,f,W] at hv ⊢ + exact ⟨by linarith [hv.1],by linarith [hv.2]⟩ + · apply Percolation.internalEdges_mono G.ends + intro v hv + have he := G.orbitAdjustedHeight_change_base hc hl a x z v + dsimp [J,f,b] at hv hzlo hzhi ⊢ + linarith [hv.2] + · apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + apply mul_le_mul_of_nonneg_left _ hρ + dsimp [s,b] at * + linarith + have hI : ∀ᵐ ω ∂G.law p, + (Percolation.cluster G.ends (ω ∩ Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ b}) x).Finite := by + filter_upwards [hfin x] with ω hω + exact hω.subset fun v hv => Percolation.conn_mono G.ends inter_subset_left hv + have hh := lower_slab_fractional_recurrence G.ends hl d hd (fun _ => p) f R 0 b + (G.height_difference_jump hc hl a R hjump x) J + (Percolation.internalEdges_mono G.ends (fun _ hv => hv.1)) x + (by simp only [f,G.orbitAdjustedHeight_self]; exact ⟨le_rfl,by dsimp [b]; positivity⟩) + (by simpa only [CriticalPercolation.BernoulliProduct.law_const,CriticalPercolation.BondGraph.law] using hI) + W hq hq1 ht ht1.le L + (fun z hzlo hzhi => by simpa only [CriticalPercolation.BernoulliProduct.law_const, + CriticalPercolation.BondGraph.law] using hL z hzlo hzhi) + simp only [CriticalPercolation.BernoulliProduct.law_const] at hh + have htop : (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ b}) + {v | b-R ≤ f v ∧ f v ≤ b} ω x)^t ∂G.law p) ≤ + A*ENNReal.ofReal (Real.exp ((-1+ε)*b+U*R)) := by + apply le_trans _ (hab b (by dsimp [b]; positivity) R hR.le x) + apply lintegral_mono + intro ω + apply ENNReal.rpow_le_rpow _ ht.le + apply G.restrictedLayerCount_le_adjustedSlab + · apply Percolation.internalEdges_mono G.ends + intro v hv + exact ⟨by dsimp [f] at hv; linarith [hv.1],by dsimp [f] at hv; linarith [hv.2]⟩ + · intro v hv + exact ⟨hv.1,by dsimp [f] at hv; linarith [hv.2]⟩ + have hcast : ((n+1 : ℕ) : ℝ)=(n : ℝ)+1 := by norm_cast + simp only [F,hcast] + apply hh.trans + apply add_le_add le_rfl + apply (mul_le_mul' (mul_le_mul' le_rfl htop) le_rfl).trans + dsimp [L] + rw [ENNReal.mul_rpow_of_nonneg _ _ ht.le,ennreal_exp_rpow _ _ ht.le] + have hrate : -1+ε+t*ρ ≤ -(1/8 : ℝ) := by + have hh := mul_le_of_le_one_left hρ ht1.le + linarith + have he : ((-1+ε)*b+U*R)+(ρ*((n : ℝ)*R+2*R))*t ≤ + (((-1+ε)+U)*R+t*ρ*(2*R))+((-1+ε)*k+(-(R/8)*(n : ℝ))) := by + have hh := mul_le_mul_of_nonneg_right hrate (mul_nonneg (Nat.cast_nonneg n) hR.le) + dsimp [b] + nlinarith + calc + _ = ((d : ℝ≥0∞)^t*A*D^t)*ENNReal.ofReal + (Real.exp (((-1+ε)*b+U*R)+(ρ*((n : ℝ)*R+2*R))*t)) := by + rw [Real.exp_add ((-1+ε)*b+U*R) ((ρ*((n : ℝ)*R+2*R))*t), + ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + _ ≤ ((d : ℝ≥0∞)^t*A*D^t)*ENNReal.ofReal (Real.exp + ((((-1+ε)+U)*R+t*ρ*(2*R))+((-1+ε)*k+(-(R/8)*(n : ℝ))))) := + mul_le_mul' le_rfl (ENNReal.ofReal_le_ofReal (Real.exp_le_exp.mpr he)) + _ = _ := by + dsimp [K,Z] + rw [Real.exp_add (((-1+ε)+U)*R+t*ρ*(2*R)) ((-1+ε)*k+(-(R/8)*(n : ℝ))), + ENNReal.ofReal_mul (Real.exp_nonneg _),Real.exp_add ((-1+ε)*k) (-(R/8)*(n : ℝ)), + ENNReal.ofReal_mul (Real.exp_nonneg _)] + ac_rfl + have hF := geometric_increment_factored F B' K Z (R/8) h0 hstep + have hlim := restrictedLayerMoment_iUnion G.ends + (fun n : ℕ => Percolation.internalEdges G.ends {v | 0 ≤ f v ∧ f v ≤ k+R+(n : ℝ)*R}) + (internalEdges_upperSlabs_monotone G.ends f R 0 (k+R) hR.le) W x p hqt + rw [internalEdges_upperSlabs_iUnion G.ends f R 0 (k+R) hR] at hlim + have hh : (∫⁻ ω, (restrictedLayerCount G.ends + (Percolation.internalEdges G.ends {v | 0 ≤ f v}) W ω x)^(q*t) ∂G.law p) ≤ (B'+K*S)*Z := by + simp only [CriticalPercolation.BondGraph.law,Percolation.law] at hlim ⊢ + rw [hlim] + exact iSup_le fun n => hF n + apply hh.trans + apply mul_le_mul' le_rfl + apply ENNReal.ofReal_le_ofReal + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right (by linarith : -1+ε ≤ -1+ζ) hk + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/VolumeEntropy.lean b/lean/OAI/Probability/BenjaminiSchramm/VolumeEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..053d604763aaa1b6898ff55508ac2a96975e0aeb --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/VolumeEntropy.lean @@ -0,0 +1,123 @@ +import OAI.Probability.BenjaminiSchramm.ProbabilityUpper + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem inverse_sqrt_div_min_bound (a s : ℝ) (ha : 0 < a) (hs : 1 ≤ s) : + (1 / s ^ 2) / min a (1/s) ≤ (1 + 1/a) / s := by + have hs0 : 0 < s := lt_of_lt_of_le zero_lt_one hs + rcases le_total a (1/s) with h | h + · rw [min_eq_left h] + apply (div_le_iff₀ ha).mpr + have hinv : 1/s^2 ≤ 1/s := by + apply one_div_le_one_div_of_le hs0 + nlinarith + have he : (1 + 1/a) / s * a = (a+1)/s := by field_simp + rw [he] + exact hinv.trans (div_le_div_of_nonneg_right (by linarith) hs0.le) + · rw [min_eq_right h] + have he : (1/s^2)/(1/s) = 1/s := by field_simp + rw [he] + apply div_le_div_of_nonneg_right _ hs0.le + exact le_add_of_nonneg_right (one_div_nonneg.mpr ha.le) + +theorem critical_volume_upper_of_susceptibility_upper + [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hloc : LocallyFinite G) (hqt : QuasiTransitive G) + (hpc1 : (pc G : ℝ) < 1) (A : ℝ) (hA : 0 < A) + (hχ : ∀ p : unitInterval, p < pc G → ∀ x, + susceptibility G p x ≤ A / ((pc G : ℝ) - p)) : + ∃ C : ℝ, 0 < C ∧ ∀ x n, 0 < n → + criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n := by + have hpc0 : 0 < (pc G : ℝ) := pc_pos G hloc hqt + obtain ⟨d,_hd,hdeg⟩ := exists_degree_bound G hqt + let D : ℝ := (pc G : ℝ) * (1-pc G) + have hD : 0 < D := by dsimp [D]; positivity + let L : ℝ := 2 + 2 * (d : ℝ) / D + have hL : 0 < L := by dsimp [L]; positivity + let a : ℝ := (pc G : ℝ) / 2 + have ha : 0 < a := half_pos hpc0 + let C : ℝ := 1 + 2 * L * A * (1 + 1/a) + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C,hC,fun x n hn => ?_⟩ + have hnR : (1 : ℝ) ≤ n := by exact_mod_cast hn + have hs : 1 ≤ Real.sqrt n := by + simpa only [Real.sqrt_one] using Real.sqrt_le_sqrt hnR + have hs0 : 0 < Real.sqrt n := lt_of_lt_of_le zero_lt_one hs + by_cases hn1 : n = 1 + · subst n + norm_num only [Nat.cast_one] + change (law (pc G)).real (volumeEvent G x 1) ≤ C / 1 + rw [div_one] + apply (measureReal_le_one).trans + have hc0 : 0 ≤ 2 * L * A * (1 + 1/a) := by positivity + dsimp only [C] + linarith + have hn2 : (1 : ℝ) < n := by exact_mod_cast (show 1 < n by omega) + let δ : ℝ := min a (1 / Real.sqrt n) + have hδ : 0 < δ := lt_min ha (one_div_pos.mpr hs0) + have hδa : δ ≤ a := min_le_left _ _ + have hδs : δ ≤ 1 / Real.sqrt n := min_le_right _ _ + let p : unitInterval := ⟨(pc G : ℝ) - δ,⟨by dsimp [a] at hδa; linarith, + by linarith [(pc G).2.2]⟩⟩ + have hp : p < pc G := by change (pc G : ℝ)-δ < pc G; linarith + have hp0 : 0 < (p : ℝ) := by + change 0 < (pc G : ℝ)-δ + dsimp only [a] at hδa + linarith + have hp1 : (p : ℝ) < 1 := lt_trans hp hpc1 + let h : unitInterval := ⟨1 / (n : ℝ),⟨by positivity, + (div_le_one (by positivity : 0 < (n : ℝ))).mpr hnR⟩⟩ + have hh : (h : ℝ) ∈ Set.Ioo 0 1 := ⟨by dsimp [h]; positivity, + (div_lt_one (by positivity : 0 < (n : ℝ))).mpr hn2⟩ + have hsq : ((p : ℝ) - pc G) ^ 2 ≤ h := by + have he := (sq_le_sq₀ hδ.le (one_div_pos.mpr hs0).le).mpr hδs + have hs2 := Real.sq_sqrt (show 0 ≤ (n : ℝ) by positivity) + change ((pc G : ℝ)-δ-pc G)^2 ≤ 1/(n : ℝ) + have hi : (1 / Real.sqrt n) ^ 2 = 1 / (n : ℝ) := by + rw [div_pow,one_pow,hs2] + rw [hi] at he + nlinarith + have hbound (Q : Finset E) : markedConnectionPolynomial G Q x h (pc G) ≤ + L * A * (1 + 1/a) / Real.sqrt n := by + have ht := markedConnection_entropy_uniform G Q x p (pc G) h ⟨hp0,hp1⟩ + ⟨hpc0,hpc1⟩ hh d + (fun z => (incident_filter_card_le_degree G hloc Q z).trans (hdeg z)) + D hD le_rfl hsq + have hb := (markedConnection_le_susceptibility G hloc hqt Q x h p hp).trans + (mul_le_mul_of_nonneg_left (hχ p hp x) h.2.1) + change _ ≤ L * markedConnectionPolynomial G Q x h p at ht + apply (ht.trans (mul_le_mul_of_nonneg_left hb hL.le)).trans + have he : (h : ℝ) * (A / ((pc G : ℝ) - p)) = A * ((1/(Real.sqrt n)^2)/δ) := by + dsimp [h,p] + rw [Real.sq_sqrt (show 0 ≤ (n : ℝ) by positivity)] + ring + rw [he] + have hi := mul_le_mul_of_nonneg_left + (inverse_sqrt_div_min_bound a (Real.sqrt n) ha hs) (mul_nonneg hL.le hA.le) + dsimp only [δ] + convert hi using 1 <;> ring + have hvol := volume_probability_le_of_finite_tails G x n (pc G) + (2 * (L * A * (1 + 1/a) / Real.sqrt n)) (fun Q => + (finiteClusterTail_le_markedConnection G Q x n (pc G) h + (by change 1 ≤ 1/(n : ℝ)*n; rw [div_mul_cancel₀ _ (by positivity)])).trans + (mul_le_mul_of_nonneg_left (hbound Q) (by norm_num : (0 : ℝ) ≤ 2))) + change (law (pc G)).real (volumeEvent G x n) ≤ C / Real.sqrt n + apply hvol.trans + dsimp [C] + have hi : 0 ≤ 1 / Real.sqrt n := (one_div_pos.mpr hs0).le + have he : (1 + 2 * L * A * (1 + 1/a)) / Real.sqrt n = + 1 / Real.sqrt n + 2 * (L * A * (1 + 1/a) / Real.sqrt n) := by ring + rw [he] + exact le_add_of_nonneg_left hi + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/VolumeLower.lean b/lean/OAI/Probability/BenjaminiSchramm/VolumeLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7f2d8762a9e6e612644f4ceb94c8e87ed374630 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/VolumeLower.lean @@ -0,0 +1,130 @@ +import OAI.Probability.BenjaminiSchramm.ProbabilityLower +import OAI.Probability.BenjaminiSchramm.OperatorSusceptibility + +namespace OAI + +open MeasureTheory + +namespace Percolation.BenjaminiSchramm + +universe u v +variable {V : Type u} {E : Type v} +attribute [local instance] Classical.propDecidable Classical.decEq + +theorem critical_volume_lower_of_upper [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hpc1 : (pc G : ℝ) < 1) + (C : ℝ) (hC : 0 < C) + (hvol : ∀ x n, 0 < n → criticalTail G (volumeEvent G) x n ≤ C / Real.sqrt n) + (x : V) : + ∃ a : ℝ, 0 < a ∧ ∀ n : ℕ, 0 < n → a / Real.sqrt n ≤ criticalTail G (volumeEvent G) x n := by + obtain ⟨c,hc,hθ⟩ := percolationProbability_linear_lower G hconn hloc hqt x + obtain ⟨d,_,hdeg⟩ := exists_degree_bound G hqt + have hpc0 : 0 < (pc G : ℝ) := pc_pos G hloc hqt + let D : ℝ := (pc G : ℝ) * (1-pc G)/2 + have hD : 0 < D := by dsimp [D]; positivity + let L : ℝ := 2 + 2*(d : ℝ)/D + have hL : 0 < L := by dsimp [L]; positivity + let b : ℝ := min (1/2) (min ((1-pc G)/2) (c/(8*L*C))) + have hb : 0 < b := lt_min (by norm_num) + (lt_min (by positivity) (div_pos hc (by positivity))) + have hbhalf : b ≤ 1/2 := min_le_left _ _ + have hbgap : b ≤ (1-pc G)/2 := (min_le_right _ _).trans (min_le_left _ _) + have hbsmall : b ≤ c/(8*L*C) := (min_le_right _ _).trans (min_le_right _ _) + have hbc : 8*L*C*b ≤ c := by + have hh := (le_div_iff₀ (by positivity : 0 < 8*L*C)).mp hbsmall + nlinarith + refine ⟨c*b/(4*L),by positivity,fun n hn => ?_⟩ + let s : ℝ := Real.sqrt n + have hs1 : 1 ≤ s := by + dsimp [s] + simpa only [Real.sqrt_one] using Real.sqrt_le_sqrt (show (1 : ℝ) ≤ n by exact_mod_cast hn) + have hs : 0 < s := zero_lt_one.trans_le hs1 + let δ : ℝ := b/s + have hδ : 0 < δ := div_pos hb hs + have hδb : δ ≤ b := div_le_self hb.le hs1 + have hδhalf : δ ≤ 1/2 := hδb.trans hbhalf + have hδgap : δ ≤ (1-pc G)/2 := hδb.trans hbgap + let q : unitInterval := ⟨(pc G : ℝ)+δ,⟨by positivity,by linarith⟩⟩ + have hq : pc G < q := by change (pc G : ℝ) < pc G+δ; linarith + have hq1 : (q : ℝ) < 1 := by change (pc G : ℝ)+δ < 1; linarith + have hq0 : 0 < (q : ℝ) := hpc0.trans hq + have hden : D ≤ (q : ℝ)*(1-q) := by + have ht : (1-(pc G : ℝ))/2 ≤ 1-(q : ℝ) := by dsimp [q]; linarith + have hm := mul_le_mul (show (pc G : ℝ) ≤ q from hq.le) ht + (by positivity : 0 ≤ (1-(pc G : ℝ))/2) hq0.le + dsimp [D] + nlinarith + let h : unitInterval := ⟨δ^2,⟨sq_nonneg _,by nlinarith⟩⟩ + have hh : (h : ℝ) ∈ Set.Ioo 0 1 := ⟨sq_pos_of_pos hδ,by dsimp [h]; nlinarith⟩ + have hmark (Q : Finset E) : markedConnectionPolynomial G Q x h (pc G) ≤ + (h : ℝ)*(2*C*s) + criticalTail G (volumeEvent G) x n := by + have hsum : (∑ i ∈ Finset.range n, finiteClusterTail G Q x (i+1) (pc G)) ≤ 2*C*s := by + calc + _ ≤ ∑ i ∈ Finset.range n, C / Real.sqrt (i+1 : ℕ) := + Finset.sum_le_sum (fun i _ => (finiteClusterTail_le_criticalTail G Q x (i+1) (pc G) le_rfl).trans + (hvol x (i+1) (by omega))) + _ = C * ∑ i ∈ Finset.range n, 1 / Real.sqrt (i+1 : ℕ) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ ≤ C*(2*s) := mul_le_mul_of_nonneg_left (sum_inverse_sqrt_le n) hC.le + _ = _ := by ring + exact (markedConnection_le_truncated_tails G Q x (pc G) h n).trans + (add_le_add (mul_le_mul_of_nonneg_left hsum h.2.1) + (finiteClusterTail_le_criticalTail G Q x n (pc G) le_rfl)) + have hghost (Q : Finset E) : markedConnectionPolynomial G Q x h q ≤ + L*((h : ℝ)*(2*C*s) + criticalTail G (volumeEvent G) x n) := by + have ht := markedConnection_entropy_uniform G Q x (pc G) q h ⟨hpc0,hpc1⟩ + ⟨hq0,hq1⟩ hh d (fun z => (incident_filter_card_le_degree G hloc Q z).trans (hdeg z)) + D hD hden (by change ((pc G : ℝ)-((pc G : ℝ)+δ))^2 ≤ δ^2; nlinarith) + exact ht.trans (mul_le_mul_of_nonneg_left (hmark Q) hL.le) + have hupper := percolationProbability_le_of_marked_bounds G x q h hh.1 _ hghost + have hlower := hθ q hq hq1 + have hδs : δ*s = b := div_mul_cancel₀ b hs.ne' + have hbound : c*δ ≤ 2*(L*(δ^2*(2*C*s) + criticalTail G (volumeEvent G) x n)) := by + dsimp only [q] at hlower + dsimp only [h] at hupper + linarith + have hm := mul_le_mul_of_nonneg_right hbound hs.le + have halg : (2*(L*(δ^2*(2*C*s) + criticalTail G (volumeEvent G) x n)))*s = + 4*L*C*b^2 + 2*L*(criticalTail G (volumeEvent G) x n*s) := by + rw [←hδs] + ring + rw [halg,mul_assoc c δ s,hδs] at hm + have hsmall : 4*L*C*b^2 ≤ c*b/2 := by + have ht := mul_le_mul_of_nonneg_right hbc hb.le + nlinarith + apply (div_le_iff₀ hs).mpr + apply (div_le_iff₀ (by positivity : 0 < 4*L)).mpr + nlinarith + +theorem critical_volume_powerTail_of_operator [Countable V] [Countable E] [Nonempty V] + (G : BondGraph V E) (hconn : Connected G) (hloc : LocallyFinite G) + (hqt : QuasiTransitive G) (hh : 0 < hV G) (hpc1 : (pc G : ℝ) < 1) + (T : Hilbert V →L[ℂ] Hilbert V) (hT : HasKernel G (pc G) T) (x : V) : + PowerTail (criticalTail G (volumeEvent G) x) (1/2) := by + obtain ⟨C,hC,hvol⟩ := critical_volume_upper_of_operator G hconn hloc hqt hh hpc1 T hT + obtain ⟨a,ha,hlo⟩ := critical_volume_lower_of_upper G hconn hloc hqt hpc1 C hC hvol x + refine ⟨a,C,ha,hC,fun n hn => ?_⟩ + rw [Real.rpow_neg (Nat.cast_nonneg n),←Real.sqrt_eq_rpow] + simpa only [div_eq_mul_inv] using And.intro (hlo n hn) (hvol x n hn) + +theorem criticalVolumeInput_of_nonamenable [Infinite V] + (G : BondGraph V E) (hh : 0 < hV G) : HutchcroftCriticalVolumeInput G := by + intro hgraph hgap x + let : Countable V := countable_vertices hgraph.locallyFinite hgraph.connected + let : Countable E := countable_edges hgraph.locallyFinite + have hp1 : (pc G : ℝ) < 1 := + (show (pc G : ℝ) < (ptwo G : ℝ) from hgap).trans_le (ptwo G).2.2 + obtain ⟨q,hq,hpq⟩ := lt_sSup_iff.mp hgap + obtain ⟨T,hT⟩ := operatorBounded_of_le G hpq.le hq + have hfin := critical_finite_general G hgraph.connected hgraph.locallyFinite hgraph.quasiTransitive hp1 + rw [criticalFiniteTail_eq G (volumeEvent G) x (hfin x)] + exact critical_volume_powerTail_of_operator G hgraph.connected hgraph.locallyFinite + hgraph.quasiTransitive hh hp1 T hT x + +end Percolation.BenjaminiSchramm + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/WeightedCostRetention.lean b/lean/OAI/Probability/BenjaminiSchramm/WeightedCostRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..21246a3c38f04d5851fdc97bee174ea403ecd538 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/WeightedCostRetention.lean @@ -0,0 +1,141 @@ +import OAI.Probability.BenjaminiSchramm.PeakSprinklingCost +import OAI.Probability.BenjaminiSchramm.RestrictedMomentHolder + +namespace OAI + +noncomputable section +open Set MeasureTheory Filter +open scoped Classical ENNReal BigOperators Topology + +namespace Percolation.BenjaminiSchramm + +lemma weighted_cost_retains_half {ι Ω : Type*} [MeasurableSpace Ω] + (I : Finset ι) (μ : ι → Measure Ω) (w : ι → ℝ≥0∞) + (A : ι → Set Ω) (hA : ∀ i ∈ I, MeasurableSet (A i)) + (Z : ι → Ω → ℝ≥0∞) (hZ : ∀ i ∈ I, Measurable (Z i)) + (t : ℝ) (ht : 0 < t) + (hP : (∑ i ∈ I, w i*μ i (A i)) < ⊤) + (hcost : (∑ i ∈ I, w i*(∫⁻ ω in A i, Z i ω ∂μ i)) ≤ + (∑ i ∈ I, w i*μ i (A i))*ENNReal.ofReal (t/2)) : + (∑ i ∈ I, w i*μ i (A i))/2 ≤ + ∑ i ∈ I, w i*μ i (A i ∩ {ω | Z i ω ≤ ENNReal.ofReal t}) := by + let P := ∑ i ∈ I, w i*μ i (A i) + let B := ∑ i ∈ I, w i*μ i (A i ∩ {ω | ENNReal.ofReal t < Z i ω}) + let Q := ∑ i ∈ I, w i*μ i (A i ∩ {ω | Z i ω ≤ ENNReal.ofReal t}) + have hBQ : B ≤ P ∧ Q ≤ P := by + constructor <;> apply Finset.sum_le_sum <;> intro i hi + all_goals exact mul_le_mul' le_rfl (measure_mono Set.inter_subset_left) + have hB : B ≠ ⊤ := ne_top_of_le_ne_top hP.ne hBQ.1 + have hQ : Q ≠ ⊤ := ne_top_of_le_ne_top hP.ne hBQ.2 + have hsum : Q+B=P := by + dsimp [P,Q,B] + rw [←Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i hi + rw [←mul_add] + congr 1 + have hmeas : MeasurableSet {ω | ENNReal.ofReal t < Z i ω} := (measurable_const.lt (hZ i hi)).setOf + have hdis : Disjoint (A i ∩ {ω | Z i ω ≤ ENNReal.ofReal t}) + (A i ∩ {ω | ENNReal.ofReal t < Z i ω}) := by + apply Set.disjoint_left.mpr + intro ω hω hω' + exact (not_lt_of_ge (show Z i ω ≤ ENNReal.ofReal t from hω.2)) hω'.2 + rw [←measure_union hdis ((hA i hi).inter hmeas)] + congr 1 + ext ω + simp only [Set.mem_union,Set.mem_inter_iff,Set.mem_ofPred_eq] + constructor + · exact fun h => h.elim And.left And.left + · intro h + rcases le_or_gt (Z i ω) (ENNReal.ofReal t) with hh | hh + · exact Or.inl ⟨h,hh⟩ + · exact Or.inr ⟨h,hh⟩ + have hmarkov : ENNReal.ofReal t*B ≤ P*ENNReal.ofReal (t/2) := by + apply le_trans _ hcost + dsimp [B] + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i hi + let S := A i ∩ {ω | ENNReal.ofReal t < Z i ω} + have hm : MeasurableSet S := (hA i hi).inter (measurable_const.lt (hZ i hi)).setOf + have hh : ENNReal.ofReal t*μ i S ≤ ∫⁻ ω in A i, Z i ω ∂μ i := by + calc + _ = ∫⁻ ω, ENNReal.ofReal t*S.indicator (fun _ => (1 : ℝ≥0∞)) ω ∂μ i := by + rw [lintegral_const_mul' _ _ ENNReal.ofReal_ne_top] + exact congrArg (fun b => ENNReal.ofReal t*b) (lintegral_indicator_fun_one hm).symm + _ ≤ ∫⁻ ω, (A i).indicator (Z i) ω ∂μ i := by + apply lintegral_mono + intro ω + change ENNReal.ofReal t*S.indicator (fun _ => (1 : ℝ≥0∞)) ω ≤ (A i).indicator (Z i) ω + by_cases hω : ω ∈ S + · rw [Set.indicator_of_mem hω (fun _ => (1 : ℝ≥0∞)),Set.indicator_of_mem hω.1 (Z i),mul_one] + exact hω.2.le + · rw [Set.indicator_of_notMem hω (fun _ => (1 : ℝ≥0∞)),mul_zero] + exact bot_le + _ = _ := lintegral_indicator (hA i hi) (Z i) + exact (show ENNReal.ofReal t*(w i*μ i S)=(w i)*(ENNReal.ofReal t*μ i S) by ac_rfl).le.trans + (mul_le_mul' le_rfl hh) + have hre := ENNReal.toReal_mono + (ENNReal.mul_ne_top hP.ne ENNReal.ofReal_ne_top) hmarkov + rw [ENNReal.toReal_mul,ENNReal.toReal_mul,ENNReal.toReal_ofReal ht.le, + ENNReal.toReal_ofReal (by positivity : 0 ≤ t/2)] at hre + have hb : B.toReal ≤ P.toReal/2 := by nlinarith + have hsumreal : Q.toReal+B.toReal=P.toReal := by + rw [←ENNReal.toReal_add hQ hB,hsum] + change P/2 ≤ Q + apply (ENNReal.toReal_le_toReal (ENNReal.div_ne_top hP.ne (by norm_num)) hQ).mp + rw [ENNReal.toReal_div,ENNReal.toReal_ofNat] + linarith + +lemma sublinear_cost_eventually_small (F : ℕ → ℝ) + (hF : Tendsto (fun n : ℕ => F n/(n : ℝ)) atTop (𝓝 0)) + (ε : ℝ) (hε : 0 < ε) : ∀ᶠ n : ℕ in atTop, F n ≤ ε*n := by + filter_upwards [hF.eventually (gt_mem_nhds hε),eventually_ge_atTop (1 : ℕ)] with n hn hn1 + have hn0 : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) + exact ((div_lt_iff₀ hn0).mp hn).le + +theorem weighted_cost_retains_half_eventually {ι Ω : Type*} [MeasurableSpace Ω] + (I : Finset ι) (μ : ι → Measure Ω) (w : ι → ℝ≥0∞) + (A : ℕ → ι → Set Ω) (hA : ∀ n i, i ∈ I → MeasurableSet (A n i)) + (Z : ℕ → ι → Ω → ℝ≥0∞) (hZ : ∀ n i, i ∈ I → Measurable (Z n i)) + (F : ℕ → ℝ) (hF : Tendsto (fun n : ℕ => F n/(n : ℝ)) atTop (𝓝 0)) + (hP : ∀ n, (∑ i ∈ I, w i*μ i (A n i)) < ⊤) + (hcost : ∀ n, (∑ i ∈ I, w i*(∫⁻ ω in A n i, Z n i ω ∂μ i)) ≤ + (∑ i ∈ I, w i*μ i (A n i))*ENNReal.ofReal (F n)) + (ε : ℝ) (hε : 0 < ε) : + ∀ᶠ n : ℕ in atTop, (∑ i ∈ I, w i*μ i (A n i))/2 ≤ + ∑ i ∈ I, w i*μ i (A n i ∩ {ω | Z n i ω ≤ ENNReal.ofReal (ε*n)}) := by + filter_upwards [sublinear_cost_eventually_small F hF (ε/2) (by positivity), + eventually_ge_atTop (1 : ℕ)] with n hn hn1 + have hn0 : (0 : ℝ) < n := by exact_mod_cast (show 0 < n by omega) + apply weighted_cost_retains_half I μ w (A n) (hA n) (Z n) (hZ n) + (ε*n) (mul_pos hε hn0) (hP n) + apply (hcost n).trans + apply mul_le_mul' le_rfl + exact ENNReal.ofReal_le_ofReal (by nlinarith [hn]) + +lemma retained_peak_exponential_bound (P Q T : ℝ≥0∞) (c b ε n : ℝ) + (hP : ENNReal.ofReal (c*Real.exp (-b*n)) ≤ P) + (hhalf : P/2 ≤ Q) (htransfer : ENNReal.ofReal (Real.exp (-ε*n))*Q ≤ T) : + ENNReal.ofReal ((c/2)*Real.exp (-(b+ε)*n)) ≤ T := by + have he : (c/2)*Real.exp (-(b+ε)*n)= + Real.exp (-ε*n)*((c*Real.exp (-b*n))/2) := by + have hexp : Real.exp (-(b+ε)*n)=Real.exp (-ε*n)*Real.exp (-b*n) := by + rw [←Real.exp_add] + congr 1 + ring + rw [hexp] + ring + calc + _ = ENNReal.ofReal (Real.exp (-ε*n))*(ENNReal.ofReal (c*Real.exp (-b*n))/2) := by + rw [he,ENNReal.ofReal_mul (Real.exp_nonneg _),ENNReal.ofReal_div_of_pos (by norm_num : (0 : ℝ)<2)] + norm_num + _ ≤ ENNReal.ofReal (Real.exp (-ε*n))*(P/2) := mul_le_mul' le_rfl (ENNReal.div_le_div_right hP 2) + _ ≤ ENNReal.ofReal (Real.exp (-ε*n))*Q := mul_le_mul' le_rfl hhalf + _ ≤ T := htransfer + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/WeightedGhostIncidence.lean b/lean/OAI/Probability/BenjaminiSchramm/WeightedGhostIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..d75b6134c148ca103fa6278dcad43cac0e20f9e7 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/WeightedGhostIncidence.lean @@ -0,0 +1,154 @@ +import OAI.Probability.BenjaminiSchramm.GhostTiltedTransport +import OAI.Probability.CriticalPercolation.Modular.ModularIncidence + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +variable {V E : Type*} (G : BondGraph V E) + +def ghostBondWeight (o : V) (e : E) : ℝ≥0∞ := + ∑ v ∈ (G.ends e).toFinset, G.stabilizerWeight o v ^ (3 / 8 : ℝ) + +def threeEighthMass (o : V) (S : Set V) : ℝ≥0∞ := + ∑' v, if v ∈ S then G.stabilizerWeight o v ^ (3 / 8 : ℝ) else 0 + +lemma ghostBondWeight_change_base (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (o v : V) (e : E) : G.ghostBondWeight o e = + G.stabilizerWeight o v ^ (3 / 8 : ℝ) * G.ghostBondWeight v e := by + unfold ghostBondWeight + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro y _ + rw [G.stabilizerWeight_change_base hc hl o v y, + ENNReal.mul_rpow_of_nonneg _ _ (by norm_num)] + +lemma ghostBondWeight_le_at_end (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (K : ℕ) (hK : ∀ v, (G.vertexBall v 1).ncard ≤ K) (o v : V) (e : E) + (hv : v ∈ G.ends e) : + G.ghostBondWeight o e ≤ (2 * (K : ℝ≥0∞) ^ (3 / 8 : ℝ)) * + G.stabilizerWeight o v ^ (3 / 8 : ℝ) := by + rw [G.ghostBondWeight_change_base hc hl o v e] + have hsum : G.ghostBondWeight v e ≤ 2 * (K : ℝ≥0∞) ^ (3 / 8 : ℝ) := by + calc + _ ≤ ∑ y ∈ (G.ends e).toFinset, (K : ℝ≥0∞) ^ (3 / 8 : ℝ) := by + apply Finset.sum_le_sum + intro y hy + have hy' := Sym2.mem_toFinset.mp hy + exact ENNReal.rpow_le_rpow + (G.stabilizerWeight_le_ball_bound hc hl K hK + (G.common_bond_ball_one hv hy') (G.common_bond_ball_one hy' hv)) (by norm_num) + _ = (G.ends e).toFinset.card * (K : ℝ≥0∞) ^ (3 / 8 : ℝ) := by + simp only [Finset.sum_const,nsmul_eq_mul] + _ ≤ _ := by + apply mul_le_mul' _ le_rfl + exact_mod_cast (show (G.ends e).toFinset.card ≤ 2 by + rw [Sym2.card_toFinset]; split_ifs <;> omega) + exact (mul_le_mul' le_rfl hsum).trans_eq (mul_comm _ _) + +lemma weighted_ghost_incidence_le (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) + (D K : ℕ) (hD : ∀ v, (G.incidentEdges {v}).ncard ≤ D) + (hK : ∀ v, (G.vertexBall v 1).ncard ≤ K) (o : V) (S : Set V) : + (∑' e, if e ∈ G.incidentEdges S then G.ghostBondWeight o e else 0) ≤ + ((D : ℝ≥0∞) * (2 * (K : ℝ≥0∞) ^ (3 / 8 : ℝ))) * G.threeEighthMass o S := by + let B := (2 : ℝ≥0∞) * (K : ℝ≥0∞) ^ (3 / 8 : ℝ) + calc + _ ≤ ∑' e : E, ∑' v : V, if v ∈ S ∧ v ∈ G.ends e then G.ghostBondWeight o e else 0 := by + apply ENNReal.tsum_le_tsum + intro e + by_cases he : e ∈ G.incidentEdges S + · rw [ite_eq_left he] + obtain ⟨v,hv,hve⟩ := he + simpa only [ite_eq_left (show v ∈ S ∧ v ∈ G.ends e from ⟨hv,hve⟩)] using + ENNReal.le_tsum v (f := fun v => if v ∈ S ∧ v ∈ G.ends e then G.ghostBondWeight o e else 0) + · rw [ite_eq_right he] + exact bot_le + _ = ∑' v : V, ∑' e : E, if v ∈ S ∧ v ∈ G.ends e then G.ghostBondWeight o e else 0 := + ENNReal.tsum_comm + _ ≤ ∑' v : V, if v ∈ S then (D : ℝ≥0∞) * B * G.stabilizerWeight o v ^ (3 / 8 : ℝ) else 0 := by + apply ENNReal.tsum_le_tsum + intro v + by_cases hv : v ∈ S + · simp only [hv,true_and,ite_true] + have hf : (G.incidentEdges {v}).Finite := by simpa [incidentEdges] using hl v + have hm (e : E) : e ∈ G.incidentEdges {v} ↔ v ∈ G.ends e := by simp [incidentEdges] + rw [tsum_eq_sum (s := hf.toFinset) (fun e he => by + simp only [hf.mem_toFinset,hm] at he + exact ite_eq_right he)] + calc + _ ≤ ∑ e ∈ hf.toFinset, B * G.stabilizerWeight o v ^ (3 / 8 : ℝ) := by + apply Finset.sum_le_sum + intro e he + rw [ite_eq_left ((hm e).mp (hf.mem_toFinset.mp he))] + exact G.ghostBondWeight_le_at_end hc hl K hK o v e + ((hm e).mp (hf.mem_toFinset.mp he)) + _ = ((G.incidentEdges {v}).ncard : ℝ≥0∞) * + (B * G.stabilizerWeight o v ^ (3 / 8 : ℝ)) := by + simp only [Finset.sum_const,nsmul_eq_mul,← Set.ncard_eq_toFinset_card _ hf] + _ ≤ (D : ℝ≥0∞) * (B * G.stabilizerWeight o v ^ (3 / 8 : ℝ)) := by + apply mul_le_mul' _ le_rfl + exact_mod_cast hD v + _ = _ := (mul_assoc _ _ _).symm + · simp only [hv,false_and,ite_false,tsum_zero,le_refl] + _ = _ := by + unfold threeEighthMass + rw [← ENNReal.tsum_mul_left] + apply tsum_congr + intro v + split_ifs <;> simp [B] + +lemma ghostWeightedCount_eq (h : ℝ) (ω : Set E) (x : V) : + G.ghostWeightedCount h ω x = + Percolation.BenjaminiSchramm.ghostAvoid h (G.quarterTiltedMass ω x) * + G.threeEighthMass x (G.cluster ω x) := by + unfold ghostWeightedCount threeEighthMass + rw [← ENNReal.tsum_mul_left] + apply tsum_congr + intro v + split_ifs <;> simp_all [cluster] + +theorem expected_ghost_boundary_weight_le [Countable V] [Countable E] + (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (hq : G.QuasiTransitive) + (p : unitInterval) {h : ℝ} (hh : 0 ≤ h) + (D K : ℕ) (hD : ∀ v, (G.incidentEdges {v}).ncard ≤ D) + (hK : ∀ v, (G.vertexBall v 1).ncard ≤ K) : + (∑ x ∈ (G.orbitRepresentatives hq).roots, ∫⁻ ω, + Percolation.BenjaminiSchramm.ghostAvoid h (G.quarterTiltedMass ω x) * + (∑' e, if e ∈ G.incidentEdges (G.cluster ω x) then G.ghostBondWeight x e else 0) + ∂G.law p) ≤ + ((D : ℝ≥0∞) * (2 * (K : ℝ≥0∞) ^ (3 / 8 : ℝ))) * + (2 * ∑ x ∈ (G.orbitRepresentatives hq).roots, ∫⁻ ω, + Percolation.BenjaminiSchramm.ghostAvoid h (G.quarterTiltedMass ω x) * + G.quarterTiltedMass ω x ∂G.law p) := by + let B := (D : ℝ≥0∞) * (2 * (K : ℝ≥0∞) ^ (3 / 8 : ℝ)) + have hB : B ≠ ⊤ := ENNReal.mul_ne_top ENNReal.coe_ne_top + (ENNReal.mul_ne_top (by norm_num) + (ENNReal.rpow_ne_top_of_nonneg (by norm_num) ENNReal.coe_ne_top)) + calc + _ ≤ ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, B * G.ghostWeightedCount h ω x ∂G.law p := by + apply Finset.sum_le_sum + intro x _ + apply lintegral_mono + intro ω + dsimp only + rw [G.ghostWeightedCount_eq] + exact (mul_le_mul' le_rfl + (G.weighted_ghost_incidence_le hc hl D K hD hK x (G.cluster ω x))).trans_eq + (by dsimp [B]; ac_rfl) + _ = B * ∑ x ∈ (G.orbitRepresentatives hq).roots, + ∫⁻ ω, G.ghostWeightedCount h ω x ∂G.law p := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + exact lintegral_const_mul' _ _ hB + _ ≤ _ := mul_le_mul' le_rfl (G.expected_ghostWeightedCount_le hc hl hq p hh) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/WeightedMomentCauchy.lean b/lean/OAI/Probability/BenjaminiSchramm/WeightedMomentCauchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..98d87864089395ca8fc7bfe74bf99af9435bbc4e --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/WeightedMomentCauchy.lean @@ -0,0 +1,50 @@ +import OAI.Probability.BenjaminiSchramm.LayerMomentCauchy + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace Percolation.BenjaminiSchramm + +lemma ennreal_finset_cauchy {ι : Type*} (s : Finset ι) (r f g : ι → ℝ≥0∞) + (hr : ∀ i ∈ s, r i ≠ ⊤) (hf : ∀ i ∈ s, f i ≠ ⊤) (hg : ∀ i ∈ s, g i ≠ ⊤) + (ht : ∀ i ∈ s, (r i)^2 ≤ f i*g i) : + (∑ i ∈ s, r i)^2 ≤ (∑ i ∈ s, f i)*(∑ i ∈ s, g i) := by + apply (ENNReal.toReal_le_toReal (ENNReal.pow_ne_top (ENNReal.sum_ne_top.mpr hr)) + (ENNReal.mul_ne_top (ENNReal.sum_ne_top.mpr hf) (ENNReal.sum_ne_top.mpr hg))).mp + rw [ENNReal.toReal_pow,ENNReal.toReal_sum hr,ENNReal.toReal_mul, + ENNReal.toReal_sum hf,ENNReal.toReal_sum hg] + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul s + (fun _ _ => ENNReal.toReal_nonneg) (fun _ _ => ENNReal.toReal_nonneg) + intro i hi + have hh := ENNReal.toReal_mono (ENNReal.mul_ne_top (hf i hi) (hg i hi)) (ht i hi) + simpa only [ENNReal.toReal_pow,ENNReal.toReal_mul] using hh + +lemma weighted_lintegral_support_cauchy {ι Ω : Type*} [MeasurableSpace Ω] + (μ : Measure Ω) (s : Finset ι) (w : ι → ℝ≥0∞) + (f : ι → Ω → ℝ≥0∞) (A : ι → Set Ω) + (hw : ∀ i ∈ s, w i ≠ ⊤) (hA : ∀ i ∈ s, MeasurableSet (A i)) + (hf : ∀ i ∈ s, Measurable (f i)) (hzero : ∀ i ∈ s, ∀ ω, ω ∉ A i → f i ω=0) + (hmass : ∀ i ∈ s, μ (A i) ≠ ⊤) + (hfirst : ∀ i ∈ s, (∫⁻ ω, f i ω ∂μ) ≠ ⊤) + (hsecond : ∀ i ∈ s, (∫⁻ ω, (f i ω)^2 ∂μ) ≠ ⊤) : + (∑ i ∈ s, w i*(∫⁻ ω, f i ω ∂μ))^2 ≤ + (∑ i ∈ s, w i*μ (A i))*(∑ i ∈ s, w i*(∫⁻ ω, (f i ω)^2 ∂μ)) := by + apply ennreal_finset_cauchy s _ _ _ + (fun i hi => ENNReal.mul_ne_top (hw i hi) (hfirst i hi)) + (fun i hi => ENNReal.mul_ne_top (hw i hi) (hmass i hi)) + (fun i hi => ENNReal.mul_ne_top (hw i hi) (hsecond i hi)) + intro i hi + calc + _ = (w i)^2*(∫⁻ ω, f i ω ∂μ)^2 := mul_pow _ _ _ + _ ≤ (w i)^2*(μ (A i)*(∫⁻ ω, (f i ω)^2 ∂μ)) := + mul_le_mul' le_rfl (lintegral_support_cauchy μ (f i) (hf i hi) (A i) (hA i hi) (hzero i hi)) + _ = _ := by ring + +end Percolation.BenjaminiSchramm + +end + +end OAI diff --git a/lean/OAI/Probability/BenjaminiSchramm/WeightedPeakSlabComparison.lean b/lean/OAI/Probability/BenjaminiSchramm/WeightedPeakSlabComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e678fc61be3e94805c73de365f90f0a1c564a21 --- /dev/null +++ b/lean/OAI/Probability/BenjaminiSchramm/WeightedPeakSlabComparison.lean @@ -0,0 +1,46 @@ +import OAI.Probability.BenjaminiSchramm.PeakSlabComparison + +namespace OAI + +noncomputable section +open Set MeasureTheory +open scoped Classical ENNReal BigOperators + +namespace CriticalPercolation.BondGraph +open Percolation.BenjaminiSchramm +variable {V E : Type*} [Countable V] [Countable E] (G : BondGraph V E) + +def fullPeakDownProbability (O : G.OrbitRepresentatives) (a : V → ℝ) + (p : unitInterval) (ell : ℝ) : ℝ≥0∞ := + ∑ x ∈ O.roots, ENNReal.ofReal (a x)*G.law p (G.fullPeakDownHit a ell x) + +theorem weighted_full_peak_lower_slab_comparison + (O : G.OrbitRepresentatives) (hc : G.fullGraph.Connected) (hl : G.LocallyFinite) (a : V → ℝ) + (ha : ∀ (φ : G.Aut) x, a (φ.vertex x)=a x) + (d N : ℕ) (hd : ∀ z, Percolation.degree G.ends z ≤ d) + (p : unitInterval) (R M k r ell : ℝ) (hR : 0 ≤ R) (hM : 0 ≤ M) + (hk : 0 ≤ k) (hr : 0 ≤ r) (hell : 0 < ell) + (hjump : ∀ e v w, v ∈ G.ends e → w ∈ G.ends e → |G.orbitAdjustedHeight a v w| ≤ R) + (hpaths : ∀ u (j : G.VertexOrbit), ∃ v, ∃ q : G.fullGraph.Walk u v, + G.vertexOrbit v=j ∧ q.length ≤ N ∧ + (∀ z ∈ q.support, -M ≤ G.orbitAdjustedHeight a u z ∧ G.orbitAdjustedHeight a u z ≤ 0) ∧ + G.orbitAdjustedHeight a u v ≤ -R) + (hfin : ∀ v, ∀ᵐ ω ∂G.law p, (Percolation.cluster G.ends ω v).Finite) (v₀ : V) : + G.fullPeakDownProbability O a p ell* + ENNReal.ofReal ((min (p : ℝ) (1-p))^(d*(N+1)))* + G.mixedHeightLayerMoment a p (-k-r) 0 (-k-R) (-k+R) (-k-r-2*M-2*R) ell v₀ ≤ + ∑ x ∈ O.roots, ENNReal.ofReal (a x)* + (∫⁻ ω, G.strictPeakSlabBandCount a (r+R+M) (-ell-k-M-2*R) (-ell-k) ω x ∂G.law p) := by + unfold fullPeakDownProbability + rw [Finset.sum_mul,Finset.sum_mul] + apply Finset.sum_le_sum + intro x _ + simpa only [mul_assoc] using mul_le_mul' (le_refl (ENNReal.ofReal (a x))) + (G.full_peak_lower_slab_comparison hc hl a ha d N hd p R M k r ell hR hM hk hr hell + hjump hpaths hfin x v₀) + +end CriticalPercolation.BondGraph + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Analytic/AnalyticTransfer.lean b/lean/OAI/Probability/BinarySweep/Analytic/AnalyticTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..5eca55650ea91c616327b1084b2da4fc45181c62 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Analytic/AnalyticTransfer.lean @@ -0,0 +1,151 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.EmptyGrid + +namespace OAI + +noncomputable section + +section + +open scoped Topology +open Set Complex Complex.HadamardThreeLines + +namespace BinaryCoordinateSweeps + +lemma cosh_norm_le (z : ℂ) : ‖Complex.cosh z‖ ≤ Real.cosh z.re := by + rw [Complex.cosh, norm_div] + norm_num only [Complex.norm_ofNat] + rw [Real.cosh_eq] + have h := norm_add_le (Complex.exp z) (Complex.exp (-z)) + rw [Complex.norm_exp,Complex.norm_exp,Complex.neg_re] at h + linarith + +def ellipseMap (v : ℝ) (z : ℂ) : ℂ := (v:ℂ)/2*(Complex.cosh z+1) + +lemma ellipseMap_norm {v L : ℝ} (hv : 0 ≤ v) (hL : 0 ≤ L) (z : ℂ) + (hz : z ∈ verticalClosedStrip 0 L) : + ‖ellipseMap v z‖ ≤ v/2*(Real.cosh L+1) := by + change 0 ≤ z.re ∧ z.re ≤ L at hz + have hc : Real.cosh z.re ≤ Real.cosh L := by + rw [Real.cosh_le_cosh,abs_of_nonneg hz.1,abs_of_nonneg hL] + exact hz.2 + have hn : ‖Complex.cosh z+1‖ ≤ Real.cosh L+1 := by + have := norm_add_le (Complex.cosh z) (1:ℂ) + norm_num only [norm_one] at this + linarith [cosh_norm_le z] + simpa only [ellipseMap,norm_mul,norm_div,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg hv,Complex.norm_ofNat] using mul_le_mul_of_nonneg_left hn (by positivity : 0 ≤ v/2) + +lemma ellipseMap_left {v : ℝ} (hv : 0 ≤ v) (z : ℂ) (hz : z.re=0) : + ∃ t : ℝ, 0 ≤ t ∧ t ≤ v ∧ ellipseMap v z=(t:ℂ) := by + have he : z=(z.im:ℂ)*Complex.I := by apply Complex.ext <;> simp [hz] + refine ⟨v/2*(Real.cos z.im+1),?_,?_,?_⟩ + · have := Real.neg_one_le_cos z.im + exact mul_nonneg (div_nonneg hv (by norm_num)) (by linarith) + · have := Real.cos_le_one z.im + nlinarith + · have hc : Complex.cosh z=(Real.cos z.im:ℂ) := by + calc Complex.cosh z = Complex.cosh ((z.im:ℂ)*Complex.I) := congrArg _ he + _ = (Real.cos z.im:ℂ) := by rw [Complex.cosh_mul_I,Complex.ofReal_cos] + rw [ellipseMap,hc] + push_cast + rfl + +theorem analytic_segment_transfer (R a : ℝ) (hR : 1 < R) (ha : 0 < a) : + ∃ θ : ℝ, 0 < θ ∧ θ ≤ 1 ∧ + ∀ E : Type*, ∀ [NormedAddCommGroup E] [NormedSpace ℂ E], + ∀ f : ℂ → E, Differentiable ℂ f → ∀ ε : ℝ, 0 ≤ ε → + (∀ z : ℂ, ‖z‖ ≤ R → ‖f z‖ ≤ 1) → + (∀ t : ℝ, 0 ≤ t → t ≤ a → ‖f (t:ℂ)‖ ≤ ε) → ‖f 1‖ ≤ ε^θ := by + let v := min a (1/2) + have hv : 0 < v := lt_min ha (by norm_num) + have hva : v ≤ a := min_le_left _ _ + have hv1 : v < 1 := (min_le_right _ _).trans_lt (by norm_num) + let x := Real.arcosh (2/v-1) + let L := Real.arcosh (2*R/v-1) + have hargx : 1 < 2/v-1 := by + have : (2:ℝ) < 2/v := (lt_div_iff₀ hv).mpr (by linarith) + linarith + have hargL : 2/v-1 < 2*R/v-1 := by + apply sub_lt_sub_right + apply (div_lt_div_iff_of_pos_right hv).2 + linarith + have hx : 0 < x := Real.arcosh_pos hargx + have hxL : x < L := (Real.arcosh_lt_arcosh (by linarith) (by linarith)).mpr hargL + have hL : 0 < L := hx.trans hxL + have hcoshx : Real.cosh x=2/v-1 := Real.cosh_arcosh hargx.le + have hcoshL : Real.cosh L=2*R/v-1 := Real.cosh_arcosh (hargx.trans hargL).le + have houter : v/2*(Real.cosh L+1)=R := by rw [hcoshL]; field_simp; ring + have hat : ellipseMap v (x:ℂ)=1 := by + rw [ellipseMap,←Complex.ofReal_cosh,hcoshx] + push_cast + have hvC : (v:ℂ) ≠ 0 := by exact_mod_cast hv.ne' + field_simp [hvC] + ring + refine ⟨1-x/L,by have := (div_lt_one hL).mpr hxL; linarith, + by have := div_nonneg hx.le hL.le; linarith,?_⟩ + intro E _ _ f hf ε hε hbound hsmall + let F : ℂ → E := fun z => f (ellipseMap v z) + have hmap : Differentiable ℂ (ellipseMap v) := + (Complex.differentiable_cosh.add_const 1).const_mul ((v:ℂ)/2) + have hFd : Differentiable ℂ F := hf.comp hmap + have hF1 : ∀z ∈ verticalClosedStrip 0 L, ‖F z‖ ≤ 1 := by + intro z hz + exact hbound _ ((ellipseMap_norm hv.le hL.le z hz).trans_eq houter) + have hc : BddAbove ((norm ∘ F) '' verticalClosedStrip 0 L) := by + use 1 + rintro y ⟨z,hz,rfl⟩ + exact hF1 z hz + have hleft : ∀z ∈ Complex.re ⁻¹' {(0:ℝ)}, ‖F z‖ ≤ ε := by + intro z hz + obtain ⟨t,ht,htv,he⟩ := ellipseMap_left hv.le z hz + dsimp [F] + rw [he] + exact hsmall t ht (htv.trans hva) + have hright : ∀z ∈ Complex.re ⁻¹' {L}, ‖F z‖ ≤ 1 := by + intro z hz + apply hF1 + change 0 ≤ z.re ∧ z.re ≤ L + change z.re=L at hz + rw [hz] + exact ⟨hL.le,le_rfl⟩ + have ht := norm_le_interp_of_mem_verticalClosedStrip' hL + (show (x:ℂ) ∈ verticalClosedStrip 0 L from ⟨hx.le,hxL.le⟩) + hFd.diffContOnCl hc hleft hright + simpa only [F,hat,Complex.ofReal_re,sub_zero,Real.one_rpow,mul_one] using ht + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +theorem grid_analytic_contraction : ∃ r : ℕ, 0 (hbits j).2) (RepSpace D) ρ hρ) + (hreal b hb bits hbits D ρ hi hρ) + rw [←Real.rpow_mul (Nat.cast_nonneg D)] at ht + have he : (-c0/(2*(q:ℝ)))*θ = -(c0/(2*q)*θ) := by ring + simpa only [he] using ht + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Analytic/ComplexGrid.lean b/lean/OAI/Probability/BinarySweep/Analytic/ComplexGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..0416bb3a0dab0dec74e749843cdd2ec72aa904e5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Analytic/ComplexGrid.lean @@ -0,0 +1,106 @@ +import Mathlib +import OAI.Probability.BinarySweep.Mixing.BinaryLineDisk +import OAI.Probability.BinarySweep.FiniteLaws.IndependentOperator + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +variable {b : ℕ} (bits : Fin b → ℕ) + +def gridStageHom (j : Fin b) : + (GridOutside bits j → Equiv.Perm (Slot (bits j))) →* Equiv.Perm (GridSlot bits) where + toFun f := (Equiv.piSplitAt j (fun i => Slot (bits i))).symm.permCongr + (Equiv.prodCongrLeft f) + map_one' := by + have h : Equiv.prodCongrLeft (1 : GridOutside bits j → Equiv.Perm (Slot (bits j)))=1 := by + ext x <;> rfl + change (Equiv.piSplitAt j (fun i => Slot (bits i))).symm.permCongrHom + (Equiv.prodCongrLeft 1)=1 + rw [h,map_one] + map_mul' f g := by + ext x + simp [Equiv.permCongr_apply,Equiv.prodCongrLeft_apply] + +lemma gridStageHom_layer (g : GridChoices bits) (j : Fin b) : + gridStageHom bits j (g j)=gridLayer bits g j := rfl + +def complexGridWeight (z : ℂ) (g : GridChoices bits) : ℂ := + ∏j, ∏y, complexLineLaw (bits j) z (g j y) + +lemma complexGridWeight_real (z : ℝ) (g : GridChoices bits) : + complexGridWeight bits (z:ℂ) g=(gridWeight bits z g:ℂ) := by + simp [complexGridWeight,gridWeight,complexLineLaw_real] + +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm (GridSlot bits)) V) + +def complexGridAverage (z : ℂ) : V →L[ℂ] V := + ∑g : GridChoices bits, complexGridWeight bits z g • continuousRep ρ (gridSweep bits g) + +lemma complexGridAverage_product (z : ℂ) : + complexGridAverage bits ρ z=(List.ofFn (fun j => + complexAverage (ρ.comp (gridStageHom bits j)) + (fun f => ∏y,complexLineLaw (bits j) z (f y)))).reverse.prod := by + unfold complexGridAverage complexGridWeight gridSweep + simp_rw [map_list_prod,List.map_reverse,List.map_ofFn,Function.comp_def] + change (∑g : GridChoices bits, (∏j, ∏y, complexLineLaw (bits j) z (g j y)) • + (List.ofFn (fun j => continuousRep ρ (gridStageHom bits j (g j)))).reverse.prod)=_ + rw [independent_average_product (X := fun j => GridOutside bits j → Equiv.Perm (Slot (bits j))) + (fun j f => ∏y,complexLineLaw (bits j) z (f y)) + (fun j f => continuousRep ρ (gridStageHom bits j f))] + congr 3 + funext j + rw [complexAverage_sum] + rfl + +lemma complexGridAverage_differentiable : Differentiable ℂ (complexGridAverage bits ρ) := by + unfold complexGridAverage + apply Differentiable.fun_sum + intro g _ + apply Differentiable.fun_smul + · unfold complexGridWeight + apply Differentiable.fun_finsetProd + intro j _ + apply Differentiable.fun_finsetProd + intro y _ + unfold complexLineLaw + fun_prop + · fun_prop + +lemma complexGridAverage_norm_le_one [Nontrivial V] (z : ℂ) + (hρ : ∀g v, ‖ρ g v‖=‖v‖) + (hline : ∀j : Fin b, + ∀σ : Representation ℂ (Equiv.Perm (Slot (bits j))) V, + (∀g v, ‖σ g v‖=‖v‖) → ‖complexAverage σ (complexLineLaw (bits j) z)‖ ≤ 1) : + ‖complexGridAverage bits ρ z‖ ≤ 1 := by + rw [complexGridAverage_product] + apply reverse_product_norm_le_one + intro j + exact pi_comp_average_norm_le_one (I := GridOutside bits j) + (G := Equiv.Perm (Slot (bits j))) (H := Equiv.Perm (GridSlot bits)) (V := V) + ρ (gridStageHom bits j) + (complexLineLaw (bits j) z) hρ (hline j) + +theorem complex_grid_disk (m : ℕ) : ∃ R : ℝ, 1 < R ∧ + ∀ (b : ℕ) (bits : Fin b → ℕ), (∀ j, bits j ≤ m) → + ∀ (V : Type*) [NormedAddCommGroup V] [InnerProductSpace ℂ V] + [FiniteDimensional ℂ V] [Nontrivial V], + ∀ρ : Representation ℂ (Equiv.Perm (GridSlot bits)) V, + (∀g v, ‖ρ g v‖=‖v‖) → ∀z : ℂ, ‖z‖ ≤ R → + ‖complexGridAverage bits ρ z‖ ≤ 1 := by + obtain ⟨R,hR,h⟩ := binary_lines_disk m + refine ⟨R,hR,?_⟩ + intro b bits hm V _ _ _ _ ρ hρ z hz + apply complexGridAverage_norm_le_one bits ρ z hρ + intro j σ hσ + exact h (bits j) (hm j) V σ hσ z hz + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Analytic/FiniteAverageGap.lean b/lean/OAI/Probability/BinarySweep/Analytic/FiniteAverageGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..fac085b8cd35213f9e31a562e68630fd452b911d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Analytic/FiniteAverageGap.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.FiniteUnitaryAverage + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +variable {G V : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +lemma realAverage_uniform_commute (ρ : Representation ℂ G V) {p : G → ℝ} + (hp : IsProbability p) (v : V) : + complexAverage ρ (fun g => (p g:ℂ)) + (complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v)= + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v ∧ + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) + (complexAverage ρ (fun g => (p g:ℂ)) v)= + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v := by + constructor + · rw [complexAverage_apply] + simp only [complexAverage_uniform_left,←Finset.sum_smul,←Complex.ofReal_sum,hp.2, + Complex.ofReal_one,one_smul] + · rw [complexAverage_apply ρ (fun g => (p g:ℂ)),map_sum] + simp only [map_smul,complexAverage_uniform_right,←Finset.sum_smul,←Complex.ofReal_sum, + hp.2,Complex.ofReal_one,one_smul] + +lemma realAverage_TV_bound (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) (p q : G → ℝ) (v : V) : + ‖complexAverage ρ (fun g => (p g:ℂ)) v- + complexAverage ρ (fun g => (q g:ℂ)) v‖ ≤ 2*totalVariation p q*‖v‖ := by + have he : ∑g, ‖((p g:ℂ)-(q g:ℂ))‖=2*totalVariation p q := by + simp only [←Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs,totalVariation] + ring + simpa only [complexAverage_sub,sub_apply,he] using + complexAverage_norm_apply ρ hρ (fun g => (p g:ℂ)-(q g:ℂ)) v + +omit [FiniteDimensional ℂ V] in +lemma contraction_power_drift (B : V →L[ℂ] V) (hB : ∀v, ‖B v‖ ≤ ‖v‖) (n : ℕ) (v : V) : + ‖v-(B^n) v‖ ≤ n*‖v-B v‖ := by + induction n with + | zero => simp + | succ n ih => + have he : v-(B^(n+1)) v=(v-B v)+B (v-(B^n) v) := by + rw [pow_succ',mul_apply_eq_comp,map_sub] + abel + rw [he,Nat.cast_add,Nat.cast_one,add_mul] + calc + _ ≤ ‖v-B v‖ + ‖B (v-(B^n) v)‖ := norm_add_le _ _ + _ ≤ ‖v-B v‖ + n*‖v-B v‖ := by linarith [hB (v-(B^n) v)] + _ = _ := by ring + +theorem finite_average_gap (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) {p : G → ℝ} (hp : IsProbability p) + (hp1 : 0 < p 1) {L : ℕ} (hL : 0 (uniformLaw G g:ℂ)) v=0) : + ‖complexAverage ρ (fun g => (p g:ℂ)) v‖^2 ≤ + (1-p 1/(4*(L:ℝ)^2))*‖v‖^2 := by + let B := complexAverage ρ (fun g => (p g:ℂ)) + have hLp : (0:ℝ) (uniformLaw G g:ℂ))+ + z • (complexAverage ρ (fun g => (p g:ℂ))- + complexAverage ρ (fun g => (uniformLaw G g:ℂ)))‖ ≤ 1 := by + let c : ℝ := p 1/(4*(L:ℝ)^2) + have hLp : (0:ℝ) hp.1 g) (Finset.mem_univ 1) + have hc : 0 (uniformLaw G g:ℂ)) + let B := complexAverage ρ (fun g => (p g:ℂ)) + apply ContinuousLinearMap.opNorm_le_bound _ (by norm_num) + intro v + rw [one_mul] + let u := P v + let w := v-u + have hPw : P w=0 := by + change P (v-P v)=0 + rw [map_sub,complexAverage_uniform_idem,sub_self] + have hPBw : P (B w)=0 := by + rw [(realAverage_uniform_commute ρ hp w).2,hPw] + have hiw : inner ℂ u w=0 := by + change inner ℂ (P v) w=0 + rw [complexAverage_uniform_inner ρ hρ,hPw,inner_zero_right] + have hiB : inner ℂ u (B w)=0 := by + change inner ℂ (P v) (B w)=0 + rw [complexAverage_uniform_inner ρ hρ,hPBw,inner_zero_right] + have hvsplit : v=u+w := by dsimp [w]; abel + have hvsq : ‖v‖^2=‖u‖^2+‖w‖^2 := by + calc ‖v‖^2=‖u+w‖^2 := congrArg (fun x : V => ‖x‖^2) hvsplit + _ = _ := by simpa only [pow_two] using + norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero u w hiw + have hB : ‖B w‖^2 ≤ (1-c)*‖w‖^2 := finite_average_gap ρ hρ hp hp1 hL hTV w hPw + have he : (P+z • (B-P)) v=u+z • B w := by + simp only [add_apply,smul_apply,sub_apply] + have hu : B u=u := (realAverage_uniform_commute ρ hp v).1 + have hb : B v=B u+B w := by rw [←map_add,←hvsplit] + rw [hb,hu,show P v=u from rfl] + abel_nf + change ‖(P+z • (B-P)) v‖ ≤ ‖v‖ + rw [he] + have hs : ‖u+z • B w‖^2=‖u‖^2+‖z‖^2*‖B w‖^2 := by + have hi : inner ℂ u (z • B w)=0 := by rw [inner_smul_right,hiB,mul_zero] + have hh := norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero u (z • B w) hi + simpa only [←pow_two,norm_smul,mul_pow] using hh + have hzq : ‖z‖^2 ≤ R^2 := pow_le_pow_left₀ (norm_nonneg _) hz 2 + have htot : ‖z‖^2*‖B w‖^2 ≤ ‖w‖^2 := by + calc _ ≤ R^2*‖B w‖^2 := mul_le_mul_of_nonneg_right hzq (sq_nonneg _) + _ ≤ R^2*((1-c)*‖w‖^2) := mul_le_mul_of_nonneg_left hB (sq_nonneg _) + _ ≤ ‖w‖^2 := by nlinarith [mul_le_mul_of_nonneg_right hRq (sq_nonneg ‖w‖)] + nlinarith [norm_nonneg (u+z • B w),norm_nonneg v] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Analytic/OneAxis.lean b/lean/OAI/Probability/BinarySweep/Analytic/OneAxis.lean new file mode 100644 index 0000000000000000000000000000000000000000..273d5697d2d61d7cbb8bffece1354b140093adb1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Analytic/OneAxis.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.IndependentHistory +import OAI.Probability.BinarySweep.Representations.IrrepSupport +import OAI.Probability.BinarySweep.FiniteLaws.SumDite + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +instance oneAxisOutsideEmpty : IsEmpty {i : Fin 1 // i ≠ 0} := + ⟨fun i => i.property (Subsingleton.elim _ _)⟩ + +noncomputable def oneAxisSlotEquiv (bits : Fin 1 → ℕ) : GridSlot bits ≃ Slot (bits 0) := + Equiv.piUnique _ +noncomputable def oneAxisChoiceEquiv (bits : Fin 1 → ℕ) : + GridChoices bits ≃ Equiv.Perm (Slot (bits 0)) := + (Equiv.piUnique _).trans (Equiv.funUnique _ _) +noncomputable def oneAxisSweepEquiv (bits : Fin 1 → ℕ) : + GridChoices bits ≃ Equiv.Perm (GridSlot bits) := + (oneAxisChoiceEquiv bits).trans ((oneAxisSlotEquiv bits).symm.permCongr) + +lemma oneAxisSweepEquiv_apply (bits : Fin 1 → ℕ) (g : GridChoices bits) : + oneAxisSweepEquiv bits g = gridSweep bits g := by + apply Equiv.ext + intro x + funext i + have hi : i = 0 := Subsingleton.elim _ _ + subst i + simp only [gridSweep, List.ofFn_succ, List.ofFn_zero, List.reverse_cons, + List.reverse_nil, List.nil_append, List.prod_cons, List.prod_nil, mul_one] + change _ = gridLayer bits g 0 x 0 + simp only [oneAxisSweepEquiv, oneAxisChoiceEquiv, oneAxisSlotEquiv, Equiv.trans_apply, + Equiv.permCongr_apply, Equiv.piUnique_apply, + Equiv.funUnique_apply, gridLayer, Equiv.piSplitAt_apply, Equiv.prodCongrLeft_apply, + Equiv.piSplitAt_symm_apply, dite_true, eq_self] + simp only [Equiv.symm_symm, Equiv.piUnique_symm_apply, Equiv.piUnique_apply] + have aux (y : GridOutside bits default) (i : Fin 1) : + uniqueElim (α := fun j => Slot (bits j)) ((g default y) (x default)) i = + (g i (fun j => x j.val)) (x i) := by + obtain rfl := Unique.eq_default i + rw [uniqueElim_default] + apply congrArg (fun y : GridOutside bits default => g default y (x default)) + funext j + exact (j.property (Subsingleton.elim _ _)).elim + exact aux _ 0 + +lemma oneAxis_pathEvent_iff {h : ℕ} {bits : Fin 1 → ℕ} (H : PathFamily bits h) + (g : GridChoices bits) : pathEvent H g ↔ + ∀ k, gridSweep bits g (H.position 0 k) = H.position (Fin.last 1) k := by + constructor + · exact fun hg k => gridSweep_path H g hg k + · intro hg j k + have hj : j = 0 := Subsingleton.elim _ _ + subst j + simpa [gridSweep, List.ofFn_succ] using hg k + +def assignmentResidualEquiv {X I : Type*} [Fintype X] [Fintype I] + (A B : I ↪ X) (c : {x : X // x ∉ Set.range A} ≃ {x : X // x ∉ Set.range B}) : + {σ : Equiv.Perm X // Assigns A B σ} ≃ Equiv.Perm {x : X // x ∉ Set.range A} := by + classical + let eA := Equiv.ofInjective A A.injective + let eB := Equiv.ofInjective B B.injective + let e₀ : Set.range A ≃ Set.range B := eA.symm.trans eB + let e : {σ : Equiv.Perm X // Assigns A B σ} ≃ + {σ : X ≃ X // ∀ x : Set.range A, σ x = e₀ x} := + Equiv.subtypeEquiv (Equiv.refl _) (by + intro σ + constructor + · intro hs x + obtain ⟨i, hi⟩ := x.property + have hx : x = eA i := Subtype.ext hi.symm + rw [hx] + simpa [e₀, eA, eB] using hs i + · intro hs i + simpa [e₀, eA, eB] using hs (eA i)) + exact (e.trans (Equiv.Set.compl e₀)).trans (Equiv.equivCongr (Equiv.refl _) c.symm) + +lemma assignmentResidualEquiv_apply {X I : Type*} [Fintype X] [Fintype I] + (A B : I ↪ X) (c : {x : X // x ∉ Set.range A} ≃ {x : X // x ∉ Set.range B}) + (σ : {σ : Equiv.Perm X // Assigns A B σ}) (x : {x : X // x ∉ Set.range A}) : + (c (assignmentResidualEquiv A B c σ x)).val = σ.val x := by + simp [assignmentResidualEquiv, Equiv.equivCongr, Equiv.Set.compl] + rfl + +def oneAxisRemainingEquiv {h : ℕ} {bits : Fin 1 → ℕ} (H : PathFamily bits h) : + {g : GridChoices bits // pathEvent H g} ≃ Equiv.Perm (FreeSlot H 0) := by + let A : Fin h ↪ GridSlot bits := ⟨H.position 0, H.disjoint 0⟩ + let B : Fin h ↪ GridSlot bits := ⟨H.position (Fin.last 1), H.disjoint _⟩ + exact (Equiv.subtypeEquiv (oneAxisSweepEquiv bits) (by + intro g + simpa only [Assigns, oneAxisSweepEquiv_apply, A, B, Function.Embedding.coeFn_mk] using oneAxis_pathEvent_iff H g)).trans + (assignmentResidualEquiv A B (freeIdentification H)) + +lemma oneAxisRemainingEquiv_apply {h : ℕ} {bits : Fin 1 → ℕ} (H : PathFamily bits h) + (g : {g : GridChoices bits // pathEvent H g}) : + oneAxisRemainingEquiv H g = remainingPerm H g.val g.property := by + apply Equiv.ext + intro x + apply (freeIdentification H).injective + apply Subtype.ext + have he := assignmentResidualEquiv_apply + (⟨H.position 0, H.disjoint 0⟩ : Fin h ↪ GridSlot bits) + (⟨H.position (Fin.last 1), H.disjoint _⟩ : Fin h ↪ GridSlot bits) + (freeIdentification H) + ((Equiv.subtypeEquiv (oneAxisSweepEquiv bits) (by + intro g + simpa only [Assigns, oneAxisSweepEquiv_apply, Function.Embedding.coeFn_mk] using oneAxis_pathEvent_iff H g)) g) x + simpa only [oneAxisRemainingEquiv, Equiv.trans_apply, Equiv.subtypeEquiv_apply, + oneAxisSweepEquiv_apply, remainingPerm, Equiv.apply_symm_apply, remainingBijection, + Equiv.coe_fn_mk] using he + +lemma oneAxis_gridWeight (bits : Fin 1 → ℕ) (z : ℝ) (g : GridChoices bits) : + gridWeight bits z g = lineLaw (bits 0) z (oneAxisChoiceEquiv bits g) := by + simp [gridWeight, oneAxisChoiceEquiv, Equiv.piUnique, Equiv.funUnique] + +lemma oneAxis_gridWeight_zero (bits : Fin 1 → ℕ) (g : GridChoices bits) : + gridWeight bits 0 g = (Fintype.card (Equiv.Perm (GridSlot bits)) : ℝ)⁻¹ := by + rw [oneAxis_gridWeight] + simp only [lineLaw, sub_zero, one_mul, zero_mul, add_zero, uniformLaw] + congr 2 + exact Fintype.card_congr (oneAxisSlotEquiv bits).symm.permCongr + +lemma oneAxis_conditionalOperator_zero {h D : ℕ} {bits : Fin 1 → ℕ} + (H : PathFamily bits h) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + [ρ.IsIrreducible] (hD : 1 < D) : conditionalOperator H 0 ρ = 0 := by + have hdim : 1 < Module.finrank ℂ (RepSpace D) := by simpa using hD + have hsum := Irrep.sum_eq_zero_of_finrank_gt_one ρ hdim + have hperm : (∑ g : {g : GridChoices bits // pathEvent H g}, + ρ (remainingPerm H g.val g.property)) = 0 := by + calc + _ = ∑ g : {g : GridChoices bits // pathEvent H g}, ρ (oneAxisRemainingEquiv H g) := by + simp only [oneAxisRemainingEquiv_apply] + _ = 0 := ((oneAxisRemainingEquiv H).sum_comp (fun σ => ρ σ)).trans hsum + unfold conditionalOperator + have he : (∑ g : GridChoices bits, if hg : pathEvent H g then + (gridWeight bits 0 g : ℂ) • ρ (remainingPerm H g hg) else 0) = 0 := by + rw [sum_dite_zero] + simp only [oneAxis_gridWeight_zero, ← Finset.smul_sum] + apply smul_eq_zero.mpr + right + convert hperm using 1 + rw [he, smul_zero] + rfl + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Analytic/OneAxisBase.lean b/lean/OAI/Probability/BinarySweep/Analytic/OneAxisBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..85cd2d9121c362803a90d4cd6ad427a110f04d07 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Analytic/OneAxisBase.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Probability.BinarySweep.Analytic.OneAxisPerturbation +import OAI.Probability.BinarySweep.FiniteLaws.QuantitativeMoment +import OAI.Probability.BinarySweep.Conditional.MainEasyCases + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +def oneAxisRadius (r : ℕ) : ℝ := + (2 * (((2^(2*r) : ℕ).factorial : ℝ))^2)⁻¹ + +lemma oneAxisRadius_pos (r : ℕ) : 0 < oneAxisRadius r := by + unfold oneAxisRadius + positivity + +lemma oneAxisRadius_le_half (r : ℕ) : oneAxisRadius r ≤ 1/2 := by + have hB : (1 : ℝ) ≤ ((2^(2*r) : ℕ).factorial : ℝ) := by + exact_mod_cast Nat.factorial_pos (2^(2*r)) + unfold oneAxisRadius + calc + _ ≤ (2 : ℝ)⁻¹ := inv_anti₀ (by norm_num) (by nlinarith) + _ = 1/2 := by norm_num + +lemma oneAxis_size_le {r : ℕ} {bits : Fin 1 → ℕ} (hd : ∀ j, bits j ≤ 2*r) : + gridSize bits ≤ 2^(2*r) := by + simp only [gridSize, Fin.prod_univ_one] + exact Nat.pow_le_pow_right (by omega) (hd 0) + +lemma oneAxis_norm_le_inv_dimension {r h D : ℕ} {bits : Fin 1 → ℕ} + (hd : ∀ j, bits j ≤ 2*r) (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hzr : z ≤ oneAxisRadius r) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + [ρ.IsIrreducible] (hρ : IsUnitaryRep ρ) (hD : 1 < D) : + ‖conditionalOperator H z ρ‖ ≤ (D : ℝ)⁻¹ := by + let B : ℝ := ((2^(2*r) : ℕ).factorial : ℝ) + have hB : 0 < B := by dsimp [B]; positivity + have hfac : ((gridSize bits).factorial : ℝ) ≤ B := by + dsimp [B] + exact_mod_cast Nat.factorial_le (oneAxis_size_le hd) + have hdim : D ≤ (gridSize bits).factorial := by + have hbound := Irrep.finrank_le_card ρ + simp only [finrank_euclideanSpace_fin, Fintype.card_perm, card_freeSlot] at hbound + exact hbound.trans (Nat.factorial_le (Nat.sub_le _ _)) + have hDB : (D : ℝ) ≤ B := (by exact_mod_cast hdim : + (D : ℝ) ≤ ((gridSize bits).factorial : ℝ)).trans hfac + have hD0 : (0 : ℝ) < D := by exact_mod_cast (by omega : 0 < D) + calc + _ ≤ 2 * ((gridSize bits).factorial : ℝ) * z := + oneAxis_conditional_norm_le H hz (hzr.trans (oneAxisRadius_le_half r)) ρ hρ hD + _ ≤ 2 * B * oneAxisRadius r := by gcongr + _ = B⁻¹ := by dsimp [oneAxisRadius, B]; field_simp + _ ≤ (D : ℝ)⁻¹ := inv_anti₀ hD0 hDB + +theorem conditional_moment_one_axis {r q : ℕ} + (hr : (400000000 : ℝ) ≤ (r : ℝ) * Real.log 2) (hq : 0 < q) + (bits : Fin 1 → ℕ) (hd : ∀ j, r ≤ bits j ∧ bits j ≤ 2*r) + {h D : ℕ} (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) + (hzr : z ≤ oneAxisRadius r) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + [ρ.IsIrreducible] (hρ : IsUnitaryRep ρ) : + logMoment (traceMoment q (conditionalOperator H z ρ)) ≤ + ((-cExponent (gridSize bits) * Real.log D + + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H : ℝ) : EReal) := by + have ha := grid_parameter_allowance (by omega : 1 ≤ 1) (fun j => (hd j).1) hr H + have hl0 : 0 ≤ Real.log (gridSize bits) := Real.log_nonneg (by + exact_mod_cast gridSize_pos bits) + have hallow : 0 ≤ eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H := by + apply le_trans _ ha.2.2 + unfold e0 + positivity + by_cases hD : 1 < D + · have hn := oneAxis_norm_le_inv_dimension (fun j => (hd j).2) H hz hzr ρ hρ hD + apply (logMoment_le_neg_log_dimension (by omega) hq _ hn).trans + have hc : cExponent (gridSize bits) ≤ 1 := by + have := ha.1 + unfold c0 at this + linarith + have hlog : 0 ≤ Real.log D := Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ D)) + exact_mod_cast (show -Real.log D ≤ -cExponent (gridSize bits) * Real.log D + + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H by nlinarith) + · have hlog : Real.log D = 0 := by + have hD' : D = 0 ∨ D = 1 := by omega + rcases hD' with rfl | rfl <;> norm_num + apply conditional_moment_of_automatic_regime H hz + (lt_of_le_of_lt (hzr.trans (oneAxisRadius_le_half r)) (by norm_num)) q ρ hρ + simpa only [hlog, mul_zero] using hallow + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Analytic/OneAxisPerturbation.lean b/lean/OAI/Probability/BinarySweep/Analytic/OneAxisPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..960f61af12d93a4442fbe37388e1208b9b2ed550 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Analytic/OneAxisPerturbation.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.MomentBounds +import OAI.Probability.BinarySweep.Analytic.OneAxis + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +lemma oneAxis_gridWeight_affine (bits : Fin 1 → ℕ) (z : ℝ) (g : GridChoices bits) : + gridWeight bits z g = (1-z)*gridWeight bits 0 g + z*gridWeight bits 1 g := by + simp only [oneAxis_gridWeight, lineLaw] + ring + +lemma oneAxis_gridWeight_one_nonneg (bits : Fin 1 → ℕ) (g : GridChoices bits) : + 0 ≤ gridWeight bits 1 g := by + simp only [oneAxis_gridWeight, lineLaw, sub_self, zero_mul, one_mul, zero_add] + exact finiteLaw_nonneg (binarySweep _) _ + +lemma oneAxis_conditional_norm_le_z_div {h D : ℕ} {bits : Fin 1 → ℕ} + (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + [ρ.IsIrreducible] (hρ : IsUnitaryRep ρ) (hD : 1 < D) : + ‖conditionalOperator H z ρ‖ ≤ z / conditionalNormalizer H z := by + have hZ := conditionalNormalizer_pos H hz hz1 + apply (conditionalOperator H z ρ).opNorm_le_bound (div_nonneg hz hZ.le) + intro x + let F (w : ℝ) : RepSpace D := ∑ g : GridChoices bits, if hg : pathEvent H g then + (gridWeight bits w g : ℂ) • ρ (remainingPerm H g hg) x else 0 + have hF0 : F 0 = 0 := by + have he := congrArg (fun K : RepSpace D →L[ℂ] RepSpace D => K x) + (oneAxis_conditionalOperator_zero H ρ hD) + rw [conditionalOperator_apply] at he + change (conditionalNormalizer H 0 : ℂ)⁻¹ • F 0 = 0 at he + exact (smul_eq_zero.mp he).resolve_left (inv_ne_zero (by + exact_mod_cast (conditionalNormalizer_pos H (by norm_num : (0 : ℝ) ≤ 0) + (by norm_num : (0 : ℝ) < 1)).ne')) + have hFz : F z = (z : ℂ) • F 1 := by + have hl : F z = ((1-z : ℝ) : ℂ) • F 0 + (z : ℂ) • F 1 := by + simp only [F, Finset.smul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro g _ + by_cases hg : pathEvent H g + · simp only [dite_eq_left hg, oneAxis_gridWeight_affine bits z g, + Complex.ofReal_add, Complex.ofReal_mul, add_smul, mul_smul] + · simp only [dite_eq_right hg, smul_zero, add_zero] + simpa only [hF0, smul_zero, zero_add] using hl + have hF1 : ‖F 1‖ ≤ ‖x‖ := by + calc + _ ≤ ∑ g : GridChoices bits, ‖if hg : pathEvent H g then + (gridWeight bits 1 g : ℂ) • ρ (remainingPerm H g hg) x else 0‖ := norm_sum_le _ _ + _ ≤ ∑ g : GridChoices bits, gridWeight bits 1 g * ‖x‖ := by + apply Finset.sum_le_sum + intro g _ + by_cases hg : pathEvent H g + · simp only [dite_eq_left hg, norm_smul, hρ (remainingPerm H g hg) x, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (oneAxis_gridWeight_one_nonneg bits g), le_refl] + · simp only [dite_eq_right hg, norm_zero] + exact mul_nonneg (oneAxis_gridWeight_one_nonneg bits g) (norm_nonneg _) + _ = ‖x‖ := by rw [← Finset.sum_mul, gridWeight_sum, one_mul] + rw [conditionalOperator_apply] + change ‖(conditionalNormalizer H z : ℂ)⁻¹ • F z‖ ≤ _ + rw [hFz, norm_smul, norm_smul, norm_inv, Complex.norm_real, Real.norm_eq_abs, + abs_of_pos hZ, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hz] + calc + _ ≤ (conditionalNormalizer H z)⁻¹ * (z * ‖x‖) := by gcongr + _ = _ := by rw [div_eq_mul_inv]; ring + +lemma oneAxis_normalizer_lower {h : ℕ} {bits : Fin 1 → ℕ} + (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) (hzhalf : z ≤ 1/2) : + (2 * ((gridSize bits).factorial : ℝ))⁻¹ ≤ conditionalNormalizer H z := by + have hz1 : z < 1 := by linarith + obtain ⟨g, hg⟩ := pathEvent_nonempty H + have hu : (Fintype.card (Equiv.Perm (GridSlot bits)) : ℝ)⁻¹ = + ((gridSize bits).factorial : ℝ)⁻¹ := by rw [Fintype.card_perm, card_gridSlot] + calc + _ = (1/2 : ℝ) * (Fintype.card (Equiv.Perm (GridSlot bits)) : ℝ)⁻¹ := by + rw [hu, mul_inv_rev]; ring + _ ≤ gridWeight bits z g := by + rw [oneAxis_gridWeight_affine, oneAxis_gridWeight_zero] + have hp := mul_nonneg hz (oneAxis_gridWeight_one_nonneg bits g) + have hn : 0 ≤ (Fintype.card (Equiv.Perm (GridSlot bits)) : ℝ)⁻¹ := by positivity + nlinarith + _ ≤ conditionalNormalizer H z := by + unfold conditionalNormalizer + have he := Finset.single_le_sum (fun (g' : GridChoices bits) _ => + show 0 ≤ if pathEvent H g' then gridWeight bits z g' else 0 by + split_ifs <;> first | exact (gridWeight_pos bits hz hz1 g').le | exact le_rfl) + (Finset.mem_univ g) + simpa only [ite_eq_left hg] using he + +theorem oneAxis_conditional_norm_le {h D : ℕ} {bits : Fin 1 → ℕ} + (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) (hzhalf : z ≤ 1/2) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + [ρ.IsIrreducible] (hρ : IsUnitaryRep ρ) (hD : 1 < D) : + ‖conditionalOperator H z ρ‖ ≤ 2 * ((gridSize bits).factorial : ℝ) * z := by + have hz1 : z < 1 := by linarith + have hb := oneAxis_normalizer_lower H hz hzhalf + have hF : (0 : ℝ) < 2 * ((gridSize bits).factorial : ℝ) := by positivity + calc + _ ≤ z / conditionalNormalizer H z := oneAxis_conditional_norm_le_z_div H hz hz1 ρ hρ hD + _ ≤ z / (2 * ((gridSize bits).factorial : ℝ))⁻¹ := + div_le_div_of_nonneg_left hz (inv_pos.mpr hF) hb + _ = _ := by rw [div_inv_eq_mul]; ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/AugmentedBlock.lean b/lean/OAI/Probability/BinarySweep/Conditional/AugmentedBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cf5894073aacb7b9fa7bf9e7ddd137013f79493 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/AugmentedBlock.lean @@ -0,0 +1,198 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.LinearEvenMoment +import OAI.Probability.BinarySweep.SparseBounds.ConditionalCentered + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (x : Placement H k 0) (g₀ : ConditionalChoices H) + {A W : Type*} [Fintype A] [NormedAddCommGroup W] [InnerProductSpace ℂ W] + [FiniteDimensional ℂ W] (e : A ⊕ Fin k ≃ FreeSlot H 0) + (σ : Representation ℂ (Equiv.Perm A) W) + +def augmentedFrame : Equiv.Perm A := + ((augmentedInputBasis H x g₀ e).trans (freeIdentification (augmentByChoice H x g₀))).trans + (augmentedOutputBasis H x g₀ e).symm + +def augmentedRepresentation : Representation ℂ (Equiv.Perm (FreeSlot (augmentByChoice H x g₀) 0)) W := + σ.comp (augmentedInputBasis H x g₀ e).symm.permCongrHom.toMonoidHom + +lemma augmented_subgroup_perm (g : ConditionalChoices (augmentByChoice H x g₀)) : + ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm + ((placementSection e (augmentedOutputIndex H x g₀))⁻¹* + remainingPerm H g.val ((augmentByChoice_extension H x g₀).pathEvent_mono g.property))).1 = + augmentedFrame H x g₀ e * (augmentedInputBasis H x g₀ e).symm.permCongr + (remainingPerm (augmentByChoice H x g₀) g.val g.property) := by + rw [augmented_subgroup_bijection] + ext a + simp only [augmentedFrame,Equiv.Perm.mul_apply,Equiv.permCongr_apply,Equiv.trans_apply, + Equiv.symm_symm,Equiv.apply_symm_apply,remainingPerm] + +omit [FiniteDimensional ℂ W] in +lemma placementBlock_expectation (z : ℝ) (y : Placement H k 0) : + hilbertBlock (groupAverage (coindHilbertRep (blockPerm e) σ + (fun x => (placementSection e x)⁻¹) (placement_cosets_bijective e)) + (fun a => (conditionalGroupLaw H z a:ℂ))) y x = + ∑g : ConditionalChoices H, conditionalChoiceWeight H z g • + (if x.trans (remainingPerm H g.val g.property).toEmbedding=y then + σ ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e y)⁻¹* + remainingPerm H g.val g.property)).1 else 0) := by + have hs (r : ℝ) (T : W →ₗ[ℂ] W) : (r:ℂ) • T = r • T := + algebraMap_smul ℂ r T + calc + _ = ∑a, conditionalGroupLaw H z a • + hilbertBlock (coindHilbertRep (blockPerm e) σ (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e) a) y x := by + ext v + simp only [groupAverage,hilbertBlock,LinearMap.comp_apply,LinearMap.sum_apply,LinearMap.smul_apply,map_sum,map_smul] + apply Finset.sum_congr rfl + intro a _ + exact algebraMap_smul ℂ (conditionalGroupLaw H z a) _ + _ = _ := by + rw [conditionalGroupLaw_expectation] + apply Finset.sum_congr rfl + intro g _ + rw [placement_hilbertBlock] + split_ifs <;> rfl + +omit [FiniteDimensional ℂ W] in +theorem augmented_block_average (z : ℝ) + (hp : conditionalNormalizer (augmentByChoice H x g₀) z≠0) : + hilbertBlock (groupAverage (coindHilbertRep (blockPerm e) σ + (fun x => (placementSection e x)⁻¹) (placement_cosets_bijective e)) + (fun a => (conditionalGroupLaw H z a:ℂ))) (augmentedOutputIndex H x g₀) x = + (conditionalNormalizer (augmentByChoice H x g₀) z / conditionalNormalizer H z) • + (σ (augmentedFrame H x g₀ e) * + groupAverage (augmentedRepresentation H x g₀ e σ) + (fun a => (conditionalGroupLaw (augmentByChoice H x g₀) z a:ℂ))) := by + rw [placementBlock_expectation] + have he := (augmentByChoice_extension H x g₀).conditional_sum z hp + (fun g => σ ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e (augmentedOutputIndex H x g₀))⁻¹* + remainingPerm H g.val ((augmentByChoice_extension H x g₀).pathEvent_mono g.property))).1) + refine Eq.trans ?_ (Eq.trans he ?_) + · apply Finset.sum_congr rfl + intro g _ + by_cases hg : pathEvent (augmentByChoice H x g₀) g.val + · rw [dite_eq_left hg,ite_eq_left ((augmentedOutputIndex_event H x g₀ g).mpr hg)] + · rw [dite_eq_right hg,ite_eq_right (fun he => hg ((augmentedOutputIndex_event H x g₀ g).mp he)),smul_zero] + · congr 1 + simp_rw [augmented_subgroup_perm,map_mul] + rw [groupAverage] + have hh := conditionalGroupLaw_expectation (augmentByChoice H x g₀) z + (fun a => augmentedRepresentation H x g₀ e σ a) + have hc : (∑a, (conditionalGroupLaw (augmentByChoice H x g₀) z a:ℂ) • + augmentedRepresentation H x g₀ e σ a) = + ∑g : ConditionalChoices (augmentByChoice H x g₀), + conditionalChoiceWeight (augmentByChoice H x g₀) z g • + augmentedRepresentation H x g₀ e σ (remainingPerm (augmentByChoice H x g₀) g.val g.property) := by + refine Eq.trans ?_ hh + apply Finset.sum_congr rfl + intro a _ + exact algebraMap_smul ℂ (conditionalGroupLaw (augmentByChoice H x g₀) z a) + (augmentedRepresentation H x g₀ e σ a) + rw [hc,Finset.mul_sum] + apply Finset.sum_congr rfl + intro g _ + rw [mul_smul_comm] + rfl + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma placementBijection_index (x : Placement H k 0) (g : ConditionalChoices H) : + placementBijection H k g x = placementIdentification H k (augmentedOutputIndex H x g) := by + apply Function.Embedding.ext + intro i + change remainingBijection H g.val g.property (x i) = + freeIdentification H ((freeIdentification H).symm (remainingBijection H g.val g.property (x i))) + exact (Equiv.apply_symm_apply _ _).symm + +lemma placementKernel_ratio (z : ℝ) (x : Placement H k 0) (g : ConditionalChoices H) : + placementKernel H z x (augmentedOutputIndex H x g) = + conditionalNormalizer (augmentByChoice H x g) z / conditionalNormalizer H z := by + unfold placementKernel + rw [← placementBijection_index H x g,placementProbability_augmentation, + pathExtension_event_ratio (augmentByChoice_extension H x g)] + +lemma placementKernel_output_pos {z : ℝ} (hz : 0≤z) (hz1 : z<1) + (x : Placement H k 0) (g : ConditionalChoices H) : + 0 (placementSection e x)⁻¹) (placement_cosets_bijective e)) + (fun a => (conditionalGroupLaw H z a:ℂ))) y x = 0 := by + rw [placementBlock_expectation] + apply Finset.sum_eq_zero + intro g _ + have hn : x.trans (remainingPerm H g.val g.property).toEmbedding ≠ y := by + intro he + have ht := placementKernel_output_pos H hz hz1 x g + change 0 (placementSection e x)⁻¹) (placement_cosets_bijective e)) + (fun a => (conditionalGroupLaw H z a:ℂ))) (augmentedOutputIndex H x g) x) = + (placementKernel H z x (augmentedOutputIndex H x g))^(2*q) * + evenMoment q (groupAverage (augmentedRepresentation H x g e σ) + (fun a => (conditionalGroupLaw (augmentByChoice H x g) z a:ℂ))) := by + rw [augmented_block_average H x g e σ z (conditionalNormalizer_pos _ hz hz1).ne', + evenMoment_smul,evenMoment_unitary_left] + · rw [placementKernel_ratio] + · rw [unitary_rep_adjoint σ hσ,←map_mul,inv_mul_cancel,map_one] + +lemma placementBlock_moment_root {z : ℝ} (hz : 0≤z) (hz1 : z<1) + (hσ : ∀ g v, ‖σ g v‖=‖v‖) {q : ℕ} (hq : 0 (placementSection e x)⁻¹) (placement_cosets_bijective e)) + (fun a => (conditionalGroupLaw H z a:ℂ))) (augmentedOutputIndex H x g) x)^(((2*q:ℕ):ℝ)⁻¹) = + placementKernel H z x (augmentedOutputIndex H x g) * + evenMoment q (groupAverage (augmentedRepresentation H x g e σ) + (fun a => (conditionalGroupLaw (augmentByChoice H x g) z a:ℂ)))^(((2*q:ℕ):ℝ)⁻¹) := by + rw [placementBlock_moment H e σ hz hz1 hσ] + have hp := (placementKernel_output_pos H hz hz1 x g).le + rw [Real.mul_rpow (pow_nonneg hp _) (evenMoment_nonneg _ _), + ← Real.rpow_natCast,← Real.rpow_mul hp] + have hn : ((2*q:ℕ):ℝ)≠0 := by positivity + rw [mul_inv_cancel₀ hn,Real.rpow_one] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/AugmentedComplement.lean b/lean/OAI/Probability/BinarySweep/Conditional/AugmentedComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f6bbdf80de55daf30d04492f8331128d906b110 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/AugmentedComplement.lean @@ -0,0 +1,196 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungPlacement +import OAI.Probability.BinarySweep.Trajectories.TrajectoryComplement +import OAI.Probability.BinarySweep.Conditional.ComplementBlocks + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (x : Placement H k 0) (g₀ : ConditionalChoices H) + +def augmentedOutputIndex : Placement H k 0 := + x.trans (remainingPerm H g₀.val g₀.property).toEmbedding + +lemma augmentedOutputIndex_physical : + (augmentedPlacement H x g₀ (Fin.last b)).trans (freeIdentification H).symm.toEmbedding = + augmentedOutputIndex H x g₀ := by + apply Function.Embedding.ext + intro i + apply (freeIdentification H).injective + simp only [Function.Embedding.trans_apply,Equiv.toEmbedding_apply,Equiv.apply_symm_apply] + change augmentedPlacement H x g₀ (Fin.last b) i= + (freeIdentification H) ((freeIdentification H).symm (remainingBijection H g₀.val g₀.property (x i))) + rw [Equiv.apply_symm_apply] + apply Subtype.ext + exact congrArg (fun a : Equiv.Perm (GridSlot bits) => a (x i).val) (gridPartialSweep_last bits g₀.val) + +def augmentationInputComplement : FreeSlot (augmentByChoice H x g₀) 0 ≃ PlacementComplement x := + (augmentationFreeEquiv H x g₀ 0).trans + (complementMap (Equiv.refl _) _ x (by + simpa only [Equiv.refl_toEmbedding,Function.Embedding.trans_refl] using augmentedPlacement_zero H x g₀)) + +def augmentationOutputComplement : FreeSlot (augmentByChoice H x g₀) (Fin.last b) ≃ + PlacementComplement (augmentedOutputIndex H x g₀) := + (augmentationFreeEquiv H x g₀ (Fin.last b)).trans + (complementMap (freeIdentification H).symm _ _ (augmentedOutputIndex_physical H x g₀)) + +lemma augmentationInputComplement_val (w : FreeSlot (augmentByChoice H x g₀) 0) : + (augmentationInputComplement H x g₀ w).val.val=w.val := rfl + +lemma augmentationOutputComplement_val (w : FreeSlot (augmentByChoice H x g₀) (Fin.last b)) : + (augmentationOutputComplement H x g₀ w).val= + (freeIdentification H).symm (augmentationFreeEquiv H x g₀ (Fin.last b) w).val := rfl + +lemma augmentedOutputIndex_event (g : ConditionalChoices H) : + x.trans (remainingPerm H g.val g.property).toEmbedding=augmentedOutputIndex H x g₀ ↔ + pathEvent (augmentByChoice H x g₀) g.val := by + rw [← placementEvent_iff_augmentation H x g₀ g] + constructor + · intro he + apply Function.Embedding.ext + intro i + apply (freeIdentification H).symm.injective + exact congrArg (fun y : Placement H k 0 => y i) he + · intro he + apply Function.Embedding.ext + intro i + exact congrArg (fun y : Placement H k (Fin.last b) => (freeIdentification H).symm (y i)) he + +lemma augmented_event (g : ConditionalChoices (augmentByChoice H x g₀)) : + x.trans (remainingPerm H g.val ((augmentByChoice_extension H x g₀).pathEvent_mono g.property)).toEmbedding = + augmentedOutputIndex H x g₀ := + (augmentedOutputIndex_event H x g₀ ((augmentByChoice_extension H x g₀).restrictChoice g)).mpr g.property + +lemma augmentation_complement_square (g : ConditionalChoices (augmentByChoice H x g₀)) + (w : FreeSlot (augmentByChoice H x g₀) 0) : + augmentationOutputComplement H x g₀ + (remainingBijection (augmentByChoice H x g₀) g.val g.property w) = + complementMap (remainingPerm H g.val ((augmentByChoice_extension H x g₀).pathEvent_mono g.property)) + x (augmentedOutputIndex H x g₀) + (augmented_event H x g₀ g) + (augmentationInputComplement H x g₀ w) := by + apply Subtype.ext + rw [augmentationOutputComplement_val,complementMap_val] + exact congrArg (freeIdentification H).symm (augmented_gridSweep H x g₀ g w) + +variable {A : Type*} [Fintype A] (e : A ⊕ Fin k ≃ FreeSlot H 0) + +def augmentedInputBasis : A ≃ FreeSlot (augmentByChoice H x g₀) 0 := + (placementComplementEquiv e x).trans (augmentationInputComplement H x g₀).symm + +def augmentedOutputBasis : A ≃ FreeSlot (augmentByChoice H x g₀) (Fin.last b) := + (placementComplementEquiv e (augmentedOutputIndex H x g₀)).trans + (augmentationOutputComplement H x g₀).symm + +lemma augmented_subgroup_bijection (g : ConditionalChoices (augmentByChoice H x g₀)) : + ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm + ((placementSection e (augmentedOutputIndex H x g₀))⁻¹* + remainingPerm H g.val ((augmentByChoice_extension H x g₀).pathEvent_mono g.property))).1 = + ((augmentedInputBasis H x g₀ e).trans + (remainingBijection (augmentByChoice H x g₀) g.val g.property)).trans + (augmentedOutputBasis H x g₀ e).symm := by + rw [placement_subgroup_complement e + (remainingPerm H g.val ((augmentByChoice_extension H x g₀).pathEvent_mono g.property)) + x (augmentedOutputIndex H x g₀) (augmented_event H x g₀ g)] + ext a + apply (placementComplementEquiv e (augmentedOutputIndex H x g₀)).injective + simp only [Equiv.trans_apply,Equiv.apply_symm_apply,augmentedInputBasis,augmentedOutputBasis, + Equiv.symm_trans_apply] + exact (augmentation_complement_square H x g₀ g + ((augmentationInputComplement H x g₀).symm (placementComplementEquiv e x a))).symm.trans + (by rfl) + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] + + def subPlacement (A : Finset I) (x : I ↪ X) : A ↪ X := + (Function.Embedding.subtype (fun i => i∈A)).trans x + +omit [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] in +lemma subPlacement_move (A : Finset I) (g : Equiv.Perm X) (x : I ↪ X) : + subPlacement A (movePlacement g x)=movePlacement g (subPlacement A x) := rfl + +def placementMoveEquiv (g : Equiv.Perm X) : (I ↪ X) ≃ (I ↪ X) := + (Equiv.refl I).embeddingCongr g + +omit [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] in +lemma move_sub_eq_iff (A : Finset I) (g : Equiv.Perm X) + (x : I ↪ X) (u : A ↪ X) : + subPlacement A (movePlacement g x)=u ↔ subPlacement A x=movePlacement g⁻¹ u := by + rw [subPlacement_move] + constructor + · intro h + have he := congrArg (movePlacement g⁻¹) h + simpa only [← movePlacement_mul,inv_mul_cancel,movePlacement_one] using he + · intro h + rw [h,← movePlacement_mul,mul_inv_cancel,movePlacement_one] + +def placementMarginal (A : Finset I) : ((I ↪ X) → ℂ) →ₗ[ℂ] ((A ↪ X) → ℂ) where + toFun v u := ∑x : I ↪ X, if subPlacement A x=u then v x else 0 + map_add' v w := by + funext u + simp only [Pi.add_apply] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + split_ifs <;> simp + map_smul' c v := by + funext u + simp only [Pi.smul_apply,smul_eq_mul,RingHom.id_apply] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + split_ifs <;> simp + +omit [DecidableEq I] in +lemma placementMarginal_intertwines (A : Finset I) (g : Equiv.Perm X) + (v : (I ↪ X) → ℂ) : + placementMarginal A (placementRep g v)=placementRep g (placementMarginal A v) := by + funext u + change (∑x : I ↪ X, if subPlacement A x=u then v (movePlacement g⁻¹ x) else 0) = + ∑x : I ↪ X, if subPlacement A x=movePlacement g⁻¹ u then v x else 0 + rw [← (placementMoveEquiv (I:=I) g).sum_comp + (fun x => if subPlacement A x=u then v (movePlacement g⁻¹ x) else 0)] + apply Finset.sum_congr rfl + intro x _ + change (if subPlacement A (movePlacement g x)=u then + v (movePlacement g⁻¹ (movePlacement g x)) else 0)=_ + simp only [move_sub_eq_iff,← movePlacement_mul,inv_mul_cancel,movePlacement_one] + +variable (μ : YoungDiagram) + +theorem spechtPlacement_marginal_zero (A : Finset (Tail μ)) + (hA : A≠Finset.univ) (v : SpechtSpace μ) : + placementMarginal A (spechtPlacement μ v)=0 := by + let f := (placementMarginal A).comp (spechtPlacement μ) + have hcard : Fintype.card A < Fintype.card (Cell μ) - μ.rowLen 0 := by + rw [← card_tail] + simp only [Fintype.card_coe] + exact Finset.card_lt_card (Finset.ssubset_univ_iff.mpr hA) + have hf : ∀g w, f (spechtRep μ g w)=placementRep g (f w) := by + intro g w + simp only [f,LinearMap.comp_apply,spechtPlacement_intertwines,placementMarginal_intertwines] + have he := no_short_placement_intertwiner μ hcard f hf + exact congrArg (fun f => f v) he + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/ComplementBlocks.lean b/lean/OAI/Probability/BinarySweep/Conditional/ComplementBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8237b0cd906296ac705aed52443784d4b3258ed --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/ComplementBlocks.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.SumDite +import OAI.Probability.BinarySweep.Trajectories.PathExtension +import OAI.Probability.BinarySweep.Conditional.PlacementBlocks + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {A B X Y : Type*} [Fintype A] [Fintype B] [Fintype X] + +def complementMap (f : X ≃ Y) (x : B ↪ X) (y : B ↪ Y) + (hf : x.trans f.toEmbedding=y) : PlacementComplement x ≃ PlacementComplement y where + toFun u := ⟨f u.val,by + rintro ⟨b,hb⟩ + apply u.property + refine ⟨b,f.injective ?_⟩ + exact (congrArg (fun y : B ↪ Y => y b) hf).trans hb⟩ + invFun u := ⟨f.symm u.val,by + rintro ⟨b,hb⟩ + apply u.property + refine ⟨b,?_⟩ + exact (congrArg (fun y : B ↪ Y => y b) hf).symm.trans + ((congrArg f hb).trans (f.apply_symm_apply _))⟩ + left_inv u := Subtype.ext (f.symm_apply_apply _) + right_inv u := Subtype.ext (f.apply_symm_apply _) + +omit [Fintype B] [Fintype X] in +lemma complementMap_val (f : X ≃ Y) (x : B ↪ X) (y : B ↪ Y) + (hf : x.trans f.toEmbedding=y) (u : PlacementComplement x) : + (complementMap f x y hf u).val=f u.val := rfl + +omit [Fintype B] [Fintype X] in +lemma placement_inverse_event (a : Equiv.Perm X) (x y : B ↪ X) + (he : x.trans a.toEmbedding=y) : y.trans a.symm.toEmbedding=x := by + ext b + change a.symm (y b)=x b + rw [← he] + exact a.symm_apply_apply _ + +omit [Fintype A] [Fintype B] [Fintype X] in +lemma blockPerm_inl (e : A ⊕ B ≃ X) (a : Equiv.Perm A) (u : A) : + blockPerm e a (e (Sum.inl u))=e (Sum.inl (a u)) := by + change e (Equiv.sumCongr a (1:Equiv.Perm B) (e.symm (e (Sum.inl u))))=_ + rw [e.symm_apply_apply] + rfl + +omit [Fintype X] in +lemma placement_subgroup_complement (e : A ⊕ B ≃ X) (a : Equiv.Perm X) + (x y : B ↪ X) (he : x.trans a.toEmbedding=y) : + ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e y)⁻¹*a)).1 = + ((placementComplementEquiv e x).trans (complementMap a x y he)).trans + (placementComplementEquiv e y).symm := by + have hh := placementCoset_subgroup e a y + rw [placement_inverse_event a x y he] at hh + ext u + apply (placementComplementEquiv e y).injective + apply Subtype.ext + have hu := congrArg (placementSection e y) (Equiv.congr_fun hh (e (Sum.inl u))) + simp only [blockPerm_inl,Equiv.Perm.mul_apply,Equiv.Perm.inv_def, + Equiv.apply_symm_apply] at hu + simp only [Equiv.trans_apply, Equiv.apply_symm_apply] + change placementSection e y (e (Sum.inl _)) = a (placementSection e x (e (Sum.inl u))) + simpa only [Equiv.Perm.inv_def] using hu + +end BinaryCoordinateSweeps.Irrep + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h h' : ℕ} {bits : Fin b → ℕ} +variable {H : PathFamily bits h} {H' : PathFamily bits h'} + +def PathExtension.restrictChoice (E : PathExtension H H') + (g : ConditionalChoices H') : ConditionalChoices H := + ⟨g.val,E.pathEvent_mono g.property⟩ + +lemma PathExtension.choiceWeight (E : PathExtension H H') (z : ℝ) + (hpos : conditionalNormalizer H' z ≠ 0) (g : ConditionalChoices H') : + conditionalChoiceWeight H z (E.restrictChoice g) = + (conditionalNormalizer H' z / conditionalNormalizer H z) * + conditionalChoiceWeight H' z g := by + unfold conditionalChoiceWeight PathExtension.restrictChoice + simp only + field_simp + +lemma PathExtension.sum_restrict {V : Type*} [AddCommMonoid V] + (E : PathExtension H H') (f : ConditionalChoices H' → V) : + (∑g : ConditionalChoices H, + if hg : pathEvent H' g.val then f ⟨g.val,hg⟩ else 0) = + ∑g : ConditionalChoices H',f g := by + have hL := sum_dite_zero (pathEvent H) + (fun (g : GridChoices bits) (_ : pathEvent H g) => + if hg' : pathEvent H' g then f ⟨g,hg'⟩ else 0) + have hR := sum_dite_zero (pathEvent H') (fun g hg => f ⟨g,hg⟩) + refine Eq.trans ?_ (Eq.trans hL.symm (Eq.trans ?_ (Eq.trans hR ?_))) + · apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + intro g _ + split_ifs <;> rfl + · apply Finset.sum_congr rfl + intro g _ + by_cases hg : pathEvent H' g + · simp only [hg,E.pathEvent_mono hg,dite_eq_left] + · simp [hg] + · apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + intro g _ + rfl + +lemma PathExtension.conditional_sum {V : Type*} [AddCommGroup V] [Module ℝ V] + (E : PathExtension H H') (z : ℝ) (hpos : conditionalNormalizer H' z ≠ 0) + (f : ConditionalChoices H' → V) : + (∑g : ConditionalChoices H, + if hg : pathEvent H' g.val then conditionalChoiceWeight H z g • f ⟨g.val,hg⟩ else 0) = + (conditionalNormalizer H' z / conditionalNormalizer H z) • + ∑g : ConditionalChoices H', conditionalChoiceWeight H' z g • f g := by + rw [Finset.smul_sum] + simp_rw [← mul_smul] + rw [← E.sum_restrict (fun g => + ((conditionalNormalizer H' z / conditionalNormalizer H z) * + conditionalChoiceWeight H' z g) • f g)] + apply Finset.sum_congr rfl + intro g _ + split_ifs with hg + · rw [← E.choiceWeight z hpos ⟨g.val,hg⟩] + rfl + · rfl + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/ConditionalAverage.lean b/lean/OAI/Probability/BinarySweep/Conditional/ConditionalAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f7657fd3914e8faa7c62a483f503902a002c291 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/ConditionalAverage.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicMoment +import OAI.Probability.BinarySweep.Conditional.Placement + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation + +variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) (z : ℝ) + +def conditionalGroupLaw (a : Equiv.Perm (FreeSlot H 0)) : ℝ := + ∑ g : ConditionalChoices H, if remainingPerm H g.val g.property=a then + conditionalChoiceWeight H z g else 0 + +lemma conditionalGroupLaw_nonneg {z : ℝ} (hz : 0 ≤ z) (hz1 : z<1) + (a : Equiv.Perm (FreeSlot H 0)) : 0 ≤ conditionalGroupLaw H z a := by + apply Finset.sum_nonneg + intro g _ + split_ifs + · exact conditionalChoiceWeight_nonneg H hz hz1 g + · rfl + +lemma conditionalGroupLaw_sum {z : ℝ} (hz : 0 ≤ z) (hz1 : z<1) : + ∑ a, conditionalGroupLaw H z a = 1 := by + simp only [conditionalGroupLaw] + rw [Finset.sum_comm] + simpa using conditionalChoiceWeight_sum H hz hz1 + +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +omit [FiniteDimensional ℂ V] in +lemma groupAverage_conditional (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) : + groupAverage ρ (fun a => (conditionalGroupLaw H z a : ℂ)) = + ∑ g : ConditionalChoices H, (conditionalChoiceWeight H z g : ℂ) • + ρ (remainingPerm H g.val g.property) := by + simp only [groupAverage,conditionalGroupLaw,Complex.ofReal_sum,Finset.sum_smul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro g _ + simp only [apply_ite,Complex.ofReal_zero,ite_smul,zero_smul] + simp + +omit [FiniteDimensional ℂ V] in +lemma groupAverage_conditional_grid (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) : + groupAverage ρ (fun a => (conditionalGroupLaw H z a : ℂ)) = + (conditionalNormalizer H z : ℂ)⁻¹ • ∑ g : GridChoices bits, + if hg : pathEvent H g then (gridWeight bits z g : ℂ) • + ρ (remainingPerm H g hg) else 0 := by + rw [groupAverage_conditional] + have hs : ∀ g : ConditionalChoices H, + (conditionalChoiceWeight H z g : ℂ) • ρ (remainingPerm H g.val g.property) = + (conditionalNormalizer H z : ℂ)⁻¹ • + ((gridWeight bits z g.val : ℂ) • ρ (remainingPerm H g.val g.property)) := by + intro g + rw [conditionalChoiceWeight, Complex.ofReal_div, div_eq_mul_inv, mul_comm, mul_smul] + simp_rw [hs] + rw [← Finset.smul_sum] + congr 1 + let F : GridChoices bits → (V →ₗ[ℂ] V) := fun g => + if hg : pathEvent H g then (gridWeight bits z g : ℂ) • ρ (remainingPerm H g hg) else 0 + have hF : ∑ g : ConditionalChoices H, F g.val = ∑ g, F g := by + rw [← Finset.sum_filter_of_ne (p := pathEvent H) (f := F) (by + intro g _ hg + by_contra hn + simp [F,hn] at hg)] + exact (Finset.sum_subtype _ (by simp) _).symm + simpa only [F,dite_eq_left (Subtype.property _)] using hF + +lemma conditionalOperator_groupAverage {D : ℕ} + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) : + (conditionalOperator H z ρ).toLinearMap = + groupAverage ρ (fun a => (conditionalGroupLaw H z a : ℂ)) := by + rw [groupAverage_conditional_grid] + rfl + +lemma conditionalMoment_evenMoment {D : ℕ} + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) (q : ℕ) : + traceMoment q (conditionalOperator H z ρ) = + evenMoment q (groupAverage ρ (fun a => (conditionalGroupLaw H z a : ℂ))) := by + rw [← conditionalOperator_groupAverage] + simp only [traceMoment,evenMoment,ContinuousLinearMap.toLinearMap_pow, + ContinuousLinearMap.toLinearMap_mul,ContinuousLinearMap.adjoint_toLinearMap] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/ConditionalSign.lean b/lean/OAI/Probability/BinarySweep/Conditional/ConditionalSign.lean new file mode 100644 index 0000000000000000000000000000000000000000..62dd3cb608363371b714b3c13b3f5ee273c5a0d9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/ConditionalSign.lean @@ -0,0 +1,72 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.ConditionalCentered +import OAI.Probability.BinarySweep.Trajectories.PathSign +import OAI.Probability.BinarySweep.FiniteLaws.RemainingSign + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma conditional_full_sign (z : ℝ) : + (∑g : ConditionalChoices H, conditionalChoiceWeight H z g*realSign (gridSweep bits g.val)) = + (∑g : GridChoices bits, if pathEvent H g then + gridWeight bits z g*realSign (gridSweep bits g) else 0)/conditionalNormalizer H z := by + unfold conditionalChoiceWeight + simp_rw [div_mul_eq_mul_div] + rw [←Finset.sum_div] + congr 1 + have he := sum_dite_zero (pathEvent H) + (fun g _ => gridWeight bits z g*realSign (gridSweep bits g)) + refine Eq.trans ?_ he.symm + apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + intro g _ + rfl + +theorem conditional_sign_zero (z : ℝ) + (hs : (∑g : GridChoices bits, if pathEvent H g then + gridWeight bits z g*realSign (gridSweep bits g) else 0)=0) : + (∑a, conditionalGroupLaw H z a*realSign a)=0 := by + change (∑a, conditionalGroupLaw H z a • realSign a)=0 + rw [conditionalGroupLaw_expectation] + by_cases hn : Nonempty (ConditionalChoices H) + · obtain ⟨g₀⟩ := hn + simp only [smul_eq_mul] + have he (g : ConditionalChoices H) : + conditionalChoiceWeight H z g * + (realSign (remainingPerm H g₀.val g₀.property)/realSign (gridSweep bits g₀.val)* + realSign (gridSweep bits g.val)) = + (realSign (remainingPerm H g₀.val g₀.property)/realSign (gridSweep bits g₀.val))* + (conditionalChoiceWeight H z g*realSign (gridSweep bits g.val)) := by ring + have hf (g : ConditionalChoices H) : + conditionalChoiceWeight H z g*realSign (remainingPerm H g.val g.property) = + (realSign (remainingPerm H g₀.val g₀.property)/realSign (gridSweep bits g₀.val))* + (conditionalChoiceWeight H z g*realSign (gridSweep bits g.val)) := by + rw [remaining_realSign_factor H g g₀] + exact he g + simp_rw [hf] + rw [←Finset.mul_sum,conditional_full_sign H z,hs,zero_div,mul_zero] + · have : IsEmpty (ConditionalChoices H) := not_nonempty_iff.mp hn + exact Finset.sum_eq_zero (fun g _ => isEmptyElim g) + +lemma conditional_sign_zero_empty (z : ℝ) (j : Fin b) (hj : 0 p (e.permCongr g)) := by + unfold groupAverage + rw [← Equiv.sum_comp e.permCongr] + apply Finset.sum_congr rfl + intro g _ + congr 1 + change ρ (e.permCongr.symm (e.permCongr g))=ρ g + rw [Equiv.symm_apply_apply] + +theorem conditional_specht_hs (μ : YoungDiagram) (e : Cell μ ≃ FreeSlot H 0) + (a : Tail μ ≃ Fin k) (z : ℝ) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ + ∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H z (fun i => ((x i).val,(y i).val)))^2 := by + rw [groupAverage_comp_slots] + have hs : (gridSize bits:ℝ)≠0 := by exact_mod_cast (gridSize_pos bits).ne' + have he := specht_moment_one_le_centered_matrix μ (gridSize bits) hs + (fun g => (conditionalGroupLaw H z (e.permCongr g):ℂ)) + have hr := centeredMatrix_hs_reindex a e (gridSize bits) + (fun g => (conditionalGroupLaw H z (e.permCongr g):ℂ)) + simp only [Equiv.apply_symm_apply] at hr + rw [← hr] at he + refine he.trans_eq ?_ + change (∑x : Placement H k 0, ∑y : Placement H k 0, + ‖centeredMatrix (gridSize bits) (fun g => (conditionalGroupLaw H z g:ℂ)) y x‖^2)=_ + apply Finset.sum_congr rfl + intro x _ + simp_rw [centeredMatrix_conditional H z,Complex.norm_real,Real.norm_eq_abs,sq_abs] + exact Equiv.sum_comp (placementIdentification H k) (fun y : Placement H k (Fin.last b) => + (centeredEndpointKernel H z (fun i => ((x i).val,(y i).val)))^2) + +theorem conditional_specht_many_bound (μ : YoungDiagram) (e : Cell μ ≃ FreeSlot H 0) + (a : Tail μ ≃ Fin k) (hd : ∀j, bits j≤2*r) {z : ℝ} + (hz : 0≤z) (hzr : z≤linePerturbationRadius r) (hz1 : z<1) + (hsmall : ((k+h:ℕ):ℝ) * (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j)) ≤ 1) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ + ((2:ℝ)^k * Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k * (((k+h:ℕ):ℝ) * + (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j)))^((k+1)/2)) := + (conditional_specht_hs H μ e a z).trans + (centeredEndpointKernel_hs_bound H hd hz hzr hz1 hsmall) + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter Topology + +namespace BinaryCoordinateSweeps +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma continuous_lineLaw (d : ℕ) (g : Equiv.Perm (Slot d)) : + Continuous (fun z => lineLaw d z g) := by + unfold lineLaw + fun_prop + +lemma continuous_gridWeight (g : GridChoices bits) : Continuous (fun z => gridWeight bits z g) := by + unfold gridWeight + exact continuous_finsetProd _ (fun j _ => continuous_finsetProd _ (fun y _ => continuous_lineLaw _ _)) + +lemma continuous_conditionalNormalizer : Continuous (conditionalNormalizer H) := by + unfold conditionalNormalizer + apply continuous_finsetSum + intro g _ + split_ifs + · exact continuous_gridWeight g + · exact continuous_const + +lemma continuousAt_conditionalChoiceWeight (g : ConditionalChoices H) : + ContinuousAt (fun z => conditionalChoiceWeight H z g) 0 := + (continuous_gridWeight g.val).continuousAt.div (continuous_conditionalNormalizer H).continuousAt + (conditionalNormalizer_pos H (le_refl 0) (by norm_num)).ne' + +lemma continuousAt_conditionalGroupLaw (a : Equiv.Perm (FreeSlot H 0)) : + ContinuousAt (fun z => conditionalGroupLaw H z a) 0 := by + unfold conditionalGroupLaw + apply tendsto_finsetSum + intro g _ + split_ifs + · exact continuousAt_conditionalChoiceWeight H g + · exact continuousAt_const + +lemma continuousAt_endpointProbability {I : Type*} [Fintype I] [DecidableEq I] + (A : Finset I) (e : I → GridSlot bits × GridSlot bits) : + ContinuousAt (fun z => endpointProbability H z A e) 0 := by + simp_rw [endpointProbability_conditional] + unfold conditionalEventWeight + apply tendsto_finsetSum + intro g _ + split_ifs + · exact continuousAt_conditionalChoiceWeight H g + · exact continuousAt_const + +lemma continuousAt_centeredEndpointKernel {I : Type*} [Fintype I] [DecidableEq I] + (e : I → GridSlot bits × GridSlot bits) : + ContinuousAt (fun z => centeredEndpointKernel H z e) 0 := by + unfold centeredEndpointKernel alternatingSubsetSum + apply ContinuousAt.mul continuousAt_const + apply tendsto_finsetSum + intro A _ + exact continuousAt_const.mul (continuousAt_endpointProbability H A e) + +lemma continuousAt_centeredEndpointHS (k : ℕ) : + ContinuousAt (fun z => ∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H z (fun i => ((x i).val,(y i).val)))^2) 0 := by + apply tendsto_finsetSum + intro x _ + apply tendsto_finsetSum + intro y _ + exact (continuousAt_centeredEndpointKernel H _).pow 2 + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/CycleAugmentation.lean b/lean/OAI/Probability/BinarySweep/Conditional/CycleAugmentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f432a49aa6c75344551a6e1974183a7d4987e131 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/CycleAugmentation.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.PlacementCycleMoment +import OAI.Probability.BinarySweep.Conditional.WeightedCycle + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation + +variable {b h k r : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {A W : Type*} [Fintype A] [NormedAddCommGroup W] [InnerProductSpace ℂ W] + [FiniteDimensional ℂ W] (e : A ⊕ Fin k ≃ FreeSlot H 0) + (σ : Representation ℂ (Equiv.Perm A) W) + +lemma placement_weighted_cycle_bound_pos (hd : ∀j, bits j≤2*r) {z : ℝ} + (hz : 0≤z) (hzr : z≤linePerturbationRadius r) + {N : ℕ} (hN : 0 exact placementFiberMoment_nonneg H e σ z q _ _ + · intro j _; exact hedge x j + · apply Finset.prod_nonneg + intro j _ + unfold placementEdge + split_ifs <;> exact placementKernel_nonneg H hz hz1 _ _ + _ = Real.exp B * (∑x : Fin (2*q) → Placement H k 0, ∏j, + placementEdge H z (rev j) (x j) (x (finRotate (2*q) j))* + Real.exp (-placementEdgeCost H z (rev j) (x j) (x (finRotate (2*q) j))/((2*q:ℕ):ℝ))) := by + simp_rw [Finset.prod_mul_distrib,hconst] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + _ ≤ Real.exp B * Real.exp (-pathCost H+Real.log 4*k*b) := + mul_le_mul_of_nonneg_left (placement_weighted_cycle_bound_pos H hd hz hzr + (by omega) rev) (Real.exp_pos B).le + _ = _ := by rw [←Real.exp_add]; congr 1; ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/MainEasyCases.lean b/lean/OAI/Probability/BinarySweep/Conditional/MainEasyCases.lean new file mode 100644 index 0000000000000000000000000000000000000000..885f4ca2d404ba3f6f691f2486460f67d4b6dce1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/MainEasyCases.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.MomentBounds +import OAI.Probability.BinarySweep.Trajectories.PathExtension + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +lemma grid_log_lower {b r : ℕ} {bits : Fin b → ℕ} (hd : ∀ j, r ≤ bits j) : + (b : ℝ) * ((r : ℝ) * Real.log 2) ≤ Real.log (gridSize bits) := by + calc + _ = ∑ _j : Fin b, (r : ℝ) * Real.log 2 := by simp + _ ≤ ∑ j : Fin b, (bits j : ℝ) * Real.log 2 := by + apply Finset.sum_le_sum + intro j _ + apply mul_le_mul_of_nonneg_right (by exact_mod_cast hd j) + exact (Real.log_pos (by norm_num : (1 : ℝ) < 2)).le + _ = _ := by + rw [log_gridSize] + simp only [Nat.cast_pow, Nat.cast_ofNat, Real.log_pow] + +lemma grid_parameter_allowance {b h r : ℕ} {bits : Fin b → ℕ} + (hb : 1 ≤ b) (hd : ∀ j, r ≤ bits j) + (hr : (400000000 : ℝ) ≤ (r : ℝ) * Real.log 2) (H : PathFamily bits h) : + cExponent (gridSize bits) ≤ 2*c0 ∧ + e0/2 ≤ eExponent (gridSize bits) ∧ + (e0/4) * h * Real.log (gridSize bits) ≤ + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H := by + have hlogb := grid_log_lower hd + have hbc : (1 : ℝ) ≤ b := by exact_mod_cast hb + have hbn : (0 : ℝ) ≤ b := by positivity + have hm := mul_le_mul_of_nonneg_left hr hbn + have hbl : (400000000 : ℝ) * b ≤ Real.log (gridSize bits) := by nlinarith + have hl : (400000000 : ℝ) ≤ Real.log (gridSize bits) := by nlinarith + have hs : (20000 : ℝ) ≤ Real.sqrt (Real.log (gridSize bits)) := by + apply Real.le_sqrt_of_sq_le + norm_num + exact hl + have hs' : 1 / Real.sqrt (Real.log (gridSize bits)) ≤ (1 / 20000 : ℝ) := + one_div_le_one_div_of_le (by norm_num) hs + have hc : cExponent (gridSize bits) ≤ 2*c0 := by + unfold cExponent c0 + linarith + have he : e0/2 ≤ eExponent (gridSize bits) := by + unfold eExponent e0 + linarith + refine ⟨hc, he, ?_⟩ + have hh : (0 : ℝ) ≤ h := by positivity + have hl0 : 0 ≤ Real.log (gridSize bits) := by linarith + have he' := mul_le_mul_of_nonneg_right he (mul_nonneg hh hl0) + have hbb : (b : ℝ) ≤ (e0/4) * Real.log (gridSize bits) := by + unfold e0 + nlinarith + have hcost := (pathCost_le H).trans (mul_le_mul_of_nonneg_right hbb hh) + nlinarith + +lemma exists_main_scale : ∃ r : ℕ, 0 < r ∧ (400000000 : ℝ) ≤ (r : ℝ) * Real.log 2 := by + have hl : 0 < Real.log 2 := Real.log_pos (by norm_num) + obtain ⟨r, hr⟩ := exists_nat_gt ((400000000 : ℝ) / Real.log 2) + have hr' : (400000000 : ℝ) < (r : ℝ) * Real.log 2 := (div_lt_iff₀ hl).mp hr + refine ⟨r, ?_, hr'.le⟩ + have hp : (0 : ℝ) < r := by nlinarith + exact_mod_cast hp + +theorem conditional_moment_one_dimensional : + ∃ r : ℕ, 0 < r ∧ ∃ zStar : ℝ, 0 < zStar ∧ + ∀ b : ℕ, 1 ≤ b → ∀ bits : Fin b → ℕ, (∀ j, r ≤ bits j ∧ bits j ≤ 2*r) → + ∀ h : ℕ, ∀ H : PathFamily bits h, ∀ z : ℝ, 0 ≤ z → z ≤ zStar → + ∀ q : ℕ, ∀ ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace 1), + IsUnitaryRep ρ → + logMoment (traceMoment q (conditionalOperator H z ρ)) ≤ + ((-cExponent (gridSize bits) * Real.log (1 : ℕ) + + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H : ℝ) : EReal) := by + obtain ⟨r, hr0, hr⟩ := exists_main_scale + refine ⟨r, hr0, 1/2, by norm_num, ?_⟩ + intro b hb bits hd h H z hz hzr q ρ hρ + have hz1 : z < 1 := by linarith + apply conditional_moment_of_automatic_regime H hz hz1 q ρ hρ + have ha := (grid_parameter_allowance hb (fun j => (hd j).1) hr H).2.2 + have hl0 : 0 ≤ Real.log (gridSize bits) := Real.log_nonneg (by + exact_mod_cast gridSize_pos bits) + have hn : 0 ≤ (e0/4) * h * Real.log (gridSize bits) := by + unfold e0 + positivity + simpa only [Nat.cast_one, Real.log_one, mul_zero] using hn.trans ha + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/MainMomentInterface.lean b/lean/OAI/Probability/BinarySweep/Conditional/MainMomentInterface.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4365a2dc77d5746da42e98fdc5938066afe7f49 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/MainMomentInterface.lean @@ -0,0 +1,154 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.ManySparse +import OAI.Probability.BinarySweep.GridBounds.BalancedGrid + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Young Irrep Representation Signed + +def SpechtMomentBound (q : ℕ) {b : ℕ} (bits : Fin b → ℕ) (z : ℝ) : Prop := + ∀h : ℕ, ∀H : PathFamily bits h, ∀μ : YoungDiagram, ∀e : Cell μ ≃ FreeSlot H 0, + evenMoment q (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ + Real.exp (-cExponent (gridSize bits)*diagramF μ+ + eExponent (gridSize bits)*h*Real.log (gridSize bits)-pathCost H) + +lemma spechtMomentBound_enumerated {q b : ℕ} {bits : Fin b → ℕ} {z : ℝ} + (hB : SpechtMomentBound q bits z) : EnumeratedMomentBound q bits z := by + intro h H α + let e : Cell (diagram α) ≃ FreeSlot H 0 := + (cellsEquivFin α).trans (Fintype.equivFin _).symm + have hb := hB h H (diagram α) e + have he : groupAverage ((hilbertSpecht (diagram α)).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ)) = + groupAverage (partitionHilbertRep α) + (fun a => (conditionalGroupLaw H z ((Fintype.equivFin _).symm.permCongr a):ℂ)) := by + rw [groupAverage_comp_slots] + symm + rw [partitionHilbertRep,groupAverage_comp_slots] + rfl + rw [he] at hb + simpa only [typeF,hilbertSpecht_finrank,diagramF] using hb + +lemma hilbert_specht_complete {X V : Type*} [Fintype X] [DecidableEq X] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm X) V) [ρ.IsIrreducible] : + ∃(μ : YoungDiagram) (e : Cell μ ≃ X), Nonempty (ρ.Equiv + ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom)) := by + obtain ⟨μ,e,⟨f⟩⟩ := specht_complete ρ + let σ : Representation ℂ (Equiv.Perm X) (SpechtSpace μ) := (spechtRep μ).comp e.symm.permCongrHom.toMonoidHom + let τ : Representation ℂ (Equiv.Perm X) (SpechtHilbert μ) := (hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom + have a : σ.Equiv τ := .mk (spechtHilbertEquiv μ) (by + intro g + apply LinearMap.ext + intro v + change spechtHilbertEquiv μ (spechtRep μ _ v)= + spechtHilbertEquiv μ (spechtRep μ _ ((spechtHilbertEquiv μ).symm (spechtHilbertEquiv μ v))) + rw [LinearEquiv.symm_apply_apply]) + exact ⟨μ,e,⟨f.trans a⟩⟩ + +lemma spechtMomentBound_main {q b : ℕ} {bits : Fin b → ℕ} {z : ℝ} + (hB : SpechtMomentBound q bits z) (h D : ℕ) (H : PathFamily bits h) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + [ρ.IsIrreducible] (hρ : IsUnitaryRep ρ) : + logMoment (traceMoment q (conditionalOperator H z ρ)) ≤ + ((-cExponent (gridSize bits)*Real.log D+ + eExponent (gridSize bits)*h*Real.log (gridSize bits)-pathCost H:ℝ):EReal) := by + obtain ⟨μ,e,⟨f⟩⟩ := hilbert_specht_complete ρ + have he := equivalent_evenMoment _ _ f hρ (fun g v => hilbertSpecht_unitary μ _ v) + (fun g => (conditionalGroupLaw H z g:ℂ)) q + have hD := f.toLinearEquiv.finrank_eq + rw [finrank_euclideanSpace_fin,hilbertSpecht_finrank] at hD + apply (logMoment_le_iff_le_exp _ _).mpr + rw [conditionalMoment_evenMoment,he] + simpa only [hD,diagramF] using hB h H μ e + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps +open Young Irrep Representation GridSplit + +theorem conditional_moment_main : ConditionalMomentTarget := by + obtain ⟨S,hS⟩ := sparse_closing_radius + have hq : 2 ≤ mainMomentPower := by norm_num [mainMomentPower] + obtain ⟨T,hT⟩ := eventually_atTop.mp (dense_induction_step_eventually mainMomentPower hq) + let A : ℝ := max ((10:ℝ)^26) ((max S T:ℕ):ℝ) + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + obtain ⟨r,hr⟩ := exists_nat_gt (max (2:ℝ) (A/Real.log 2)) + have hr2 : 2 ≤ r := by + have : (2:ℝ) < r := (le_max_left _ _).trans_lt hr + exact_mod_cast this.le + have hrA : A ≤ (r:ℝ)*Real.log 2 := by + have : A/Real.log 2 < r := (le_max_right _ _).trans_lt hr + exact (div_lt_iff₀ hlog2).mp this |>.le + have hrL : (10:ℝ)^26 ≤ (r:ℝ)*Real.log 2 := (le_max_left _ _).trans hrA + have hrM : ((max S T:ℕ):ℝ) ≤ (r:ℝ)*Real.log 2 := (le_max_right _ _).trans hrA + have hr4 : (4000000000:ℝ) ≤ (r:ℝ)*Real.log 2 := by linarith + obtain ⟨δ,hδ,hδline,hsp⟩ := hS r hr2 hr4 + let zStar := min δ (oneAxisRadius r) + have hzStar : 0 < zStar := lt_min hδ (oneAxisRadius_pos r) + have hlarge {b : ℕ} (hb : 1 ≤ b) (bits : Fin b → ℕ) + (hd : ∀j,r ≤ bits j ∧ bits j ≤ 2*r) : + max S T ≤ gridSize bits ∧ (10:ℝ)^26 ≤ Real.log (gridSize bits) := by + have hl := grid_log_lower (fun j => (hd j).1) + have hbR : (1:ℝ) ≤ b := by exact_mod_cast hb + have hr0 : 0 ≤ (r:ℝ)*Real.log 2 := by positivity + have hbase : (r:ℝ)*Real.log 2 ≤ Real.log (gridSize bits) := by + have := mul_le_mul_of_nonneg_right hbR hr0 + nlinarith + refine ⟨?_,hrL.trans hbase⟩ + have hpos : (0:ℝ) < gridSize bits := by exact_mod_cast gridSize_pos bits + have hexp := Real.log_le_sub_one_of_pos hpos + have : ((max S T:ℕ):ℝ) ≤ gridSize bits := by linarith [hrM.trans hbase] + exact_mod_cast this + have hproof : ∀b : ℕ, 1 ≤ b → ∀bits : Fin b → ℕ, + (∀j,r ≤ bits j ∧ bits j ≤ 2*r) → ∀z : ℝ, 0 ≤ z → z ≤ zStar → + SpechtMomentBound mainMomentPower bits z := by + intro b + induction b using Nat.strong_induction_on with + | h b ih => + intro hb bits hd z hz hzr h H μ e + by_cases hb1 : b=1 + · subst b + have := irreducible_comp_equiv e.symm.permCongrHom (hilbertSpecht μ) + have hbase := hilbert_conditional_one_axis (by linarith : (400000000:ℝ) ≤ (r:ℝ)*Real.log 2) + (by omega : 0 < mainMomentPower) bits hd H hz (hzr.trans (min_le_right _ _)) + ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g v => hilbertSpecht_unitary μ _ v) + simpa only [hilbertSpecht_finrank,diagramF] using hbase + · have hb2 : 2 ≤ b := by omega + obtain ⟨m,n,rfl,hm,hn,hmb,hnb,hmn,hnm⟩ := balanced_counts b hb2 + obtain ⟨hsize,hL⟩ := hlarge hb bits hd + by_cases hF : (gridSize bits:ℝ)^(399/400:ℝ) ≤ diagramF μ + · obtain ⟨hu,hv,hub,hvb,haxes⟩ := balanced_grid_bounds bits hm hn hmn hnm hd (by linarith) + apply hT (gridSize bits) ((le_max_right S T).trans hsize) m n h r bits H rfl + hu hv hub hvb (fun j => (hd j).2) haxes μ e hF z hz + ((hzr.trans (min_le_left _ _)).trans hδline) + · apply spechtMomentBound_enumerated + exact ih m hmb hm (leftBits bits) (fun j => hd (j.castAdd n)) z hz hzr + · apply spechtMomentBound_enumerated + exact ih n hnb hn (rightBits bits) (fun j => hd (j.natAdd m)) z hz hzr + · exact hsp (gridSize bits) ((le_max_left S T).trans hsize) (m+n) h bits rfl hb hd hL H μ e + (lt_of_not_ge hF) z hz (hzr.trans (min_le_left _ _)) + refine ⟨r,by omega,mainMomentPower,by omega,zStar,hzStar,?_⟩ + intro b hb bits hd h H z hz hzr D ρ hi hρ + have := hi + exact spechtMomentBound_main (hproof b hb bits hd z hz hzr) h D H ρ hρ + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/MomentOperatorBound.lean b/lean/OAI/Probability/BinarySweep/Conditional/MomentOperatorBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7973fd593e8ae7247dc9b6289cbb1e93490b380 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/MomentOperatorBound.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.SchattenTriangle +import OAI.Probability.BinarySweep.FiniteLaws.HilbertMainCases + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator Classical + +namespace BinaryCoordinateSweeps +open TraceHolder Irrep + +lemma norm_le_momentRoot {ι : Type*} [Fintype ι] [DecidableEq ι] + {q : ℕ} (hq : 0 if P j a then w j a else 0)).symm + +lemma conditionalWeight_factor {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (g : GridChoices bits) : + (if pathEvent H g then gridWeight bits z g else 0) = + ∏ j, ∏ y, if Assigns (lineInput H j y) (lineOutput H j y) (g j y) then + lineLaw (bits j) z (g j y) else 0 := by + classical + rw [pathEvent_iff_assigns] + simp only [Fintype.prod_ite_zero] + split_ifs <;> rfl + +lemma sum_prod_grid {b : ℕ} (bits : Fin b → ℕ) + (f : ∀ j : Fin b, GridOutside bits j → Equiv.Perm (Slot (bits j)) → ℝ) : + (∑ g : GridChoices bits, ∏ j, ∏ y, f j y (g j y)) = + ∏ j, ∏ y, ∑ σ, f j y σ := by + rw [← Fintype.prod_sum (fun (j : Fin b) + (g : GridOutside bits j → Equiv.Perm (Slot (bits j))) => ∏ y, f j y (g y))] + apply Finset.prod_congr rfl + intro j _ + exact (Fintype.prod_sum (f j)).symm + +lemma conditionalNormalizer_eq_prod {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) : conditionalNormalizer H z = ∏ j, ∏ y, localPathWeight H z j y := by + let f (j : Fin b) (y : GridOutside bits j) (σ : Equiv.Perm (Slot (bits j))) : ℝ := + if Assigns (lineInput H j y) (lineOutput H j y) σ then lineLaw (bits j) z σ else 0 + have hL : conditionalNormalizer H z = + ∑ g : GridChoices bits, ∏ j, ∏ y, f j y (g j y) := by + unfold conditionalNormalizer + apply Finset.sum_congr rfl + intro g _ + rw [conditionalWeight_factor] + have hR : (∏ j, ∏ y, localPathWeight H z j y) = + ∏ j, ∏ y, ∑ σ, f j y σ := by + apply Finset.prod_congr rfl + intro j _ + apply Finset.prod_congr rfl + intro y _ + unfold localPathWeight assignmentWeight + refine Finset.sum_congr ?_ ?_ + · ext σ + simp only [Finset.mem_univ] + intro σ _ + unfold f + split_ifs <;> rfl + rw [hL, hR] + exact sum_prod_grid bits f + +abbrev ConditionalChoices {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) := + {g : GridChoices bits // pathEvent H g} + +instance conditionalChoicesFintype {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + Fintype (ConditionalChoices H) := Fintype.ofFinite _ + +instance conditionalChoicesNonempty {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + Nonempty (ConditionalChoices H) := by + obtain ⟨g, hg⟩ := pathEvent_nonempty H + exact ⟨⟨g, hg⟩⟩ + +def conditionalChoiceWeight {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (g : ConditionalChoices H) : ℝ := + gridWeight bits z g.val / conditionalNormalizer H z + +lemma conditionalChoiceWeight_nonneg {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) (g : ConditionalChoices H) : + 0 ≤ conditionalChoiceWeight H z g := + le_of_lt (div_pos (gridWeight_pos bits hz hz1 g.val) (conditionalNormalizer_pos H hz hz1)) + +lemma conditionalChoiceWeight_sum {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) : + ∑ g : ConditionalChoices H, conditionalChoiceWeight H z g = 1 := by + classical + unfold conditionalChoiceWeight + rw [← Finset.sum_div] + have hs : (∑ g : ConditionalChoices H, gridWeight bits z g.val) = + conditionalNormalizer H z := by + unfold conditionalNormalizer + rw [← Finset.sum_filter] + exact (Finset.sum_subtype _ (by simp) _).symm + rw [hs, div_self (conditionalNormalizer_pos H hz hz1).ne'] + +abbrev Placement {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (k : ℕ) (t : Fin (b+1)) := Fin k ↪ FreeSlot H t + +def placementBijection {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (k : ℕ) (g : ConditionalChoices H) : + Placement H k 0 ≃ Placement H k (Fin.last b) := + (Equiv.refl (Fin k)).embeddingCongr (remainingBijection H g.val g.property) + +def placementProbability {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) {k : ℕ} (x : Placement H k 0) (y : Placement H k (Fin.last b)) : ℝ := by + classical + exact ∑ g : ConditionalChoices H, + if placementBijection H k g x = y then conditionalChoiceWeight H z g else 0 + +section FiniteBijectionKernel +variable {Ω A B : Type*} [Fintype Ω] [Fintype A] [Fintype B] + +def bijectionKernel (w : Ω → ℝ) (e : Ω → A ≃ B) (x : A) (y : B) : ℝ := + ∑ ω, if e ω x = y then w ω else 0 + +omit [Fintype A] [Fintype B] in +lemma bijectionKernel_nonneg (w : Ω → ℝ) (e : Ω → A ≃ B) + (hw : ∀ ω, 0 ≤ w ω) (x : A) (y : B) : 0 ≤ bijectionKernel w e x y := by + apply Finset.sum_nonneg + intro ω _ + split_ifs + · exact hw ω + · exact le_rfl + +omit [Fintype A] in +lemma bijectionKernel_rowSum (w : Ω → ℝ) (e : Ω → A ≃ B) (x : A) : + ∑ y, bijectionKernel w e x y = ∑ ω, w ω := by + unfold bijectionKernel + rw [Finset.sum_comm] + simp + +lemma bijectionKernel_colSum (w : Ω → ℝ) (e : Ω → A ≃ B) (y : B) : + ∑ x, bijectionKernel w e x y = ∑ ω, w ω := by + unfold bijectionKernel + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro ω _ + rw [(e ω).sum_comp (fun x => if x = y then w ω else 0)] + simp + +end FiniteBijectionKernel + +lemma placementProbability_eq_kernel {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) {k : ℕ} + (x : Placement H k 0) (y : Placement H k (Fin.last b)) : + placementProbability H z x y = + bijectionKernel (conditionalChoiceWeight H z) (placementBijection H k) x y := by + unfold placementProbability bijectionKernel + apply Finset.sum_congr rfl + intro g _ + split_ifs <;> rfl + +lemma placementProbability_nonneg {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) {k : ℕ} + (x : Placement H k 0) (y : Placement H k (Fin.last b)) : + 0 ≤ placementProbability H z x y := by + rw [placementProbability_eq_kernel] + exact bijectionKernel_nonneg _ _ (conditionalChoiceWeight_nonneg H hz hz1) x y + +lemma placementProbability_rowSum {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) {k : ℕ} (x : Placement H k 0) : + ∑ y, placementProbability H z x y = 1 := by + simp_rw [placementProbability_eq_kernel] + rw [bijectionKernel_rowSum, conditionalChoiceWeight_sum H hz hz1] + +lemma placementProbability_colSum {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) {k : ℕ} (y : Placement H k (Fin.last b)) : + ∑ x, placementProbability H z x y = 1 := by + simp_rw [placementProbability_eq_kernel] + rw [bijectionKernel_colSum, conditionalChoiceWeight_sum H hz hz1] + +lemma card_placement {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (k : ℕ) (t : Fin (b+1)) : + Fintype.card (Placement H k t) = (gridSize bits - h).descFactorial k := by + rw [Fintype.card_embedding_eq, card_freeSlot, Fintype.card_fin] + +def placementIdentification {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) (k : ℕ) : + Placement H k 0 ≃ Placement H k (Fin.last b) := + (Equiv.refl (Fin k)).embeddingCongr (freeIdentification H) + +def placementKernel {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) {k : ℕ} (x y : Placement H k 0) : ℝ := + placementProbability H z x (placementIdentification H k y) + +lemma placementKernel_nonneg {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) {k : ℕ} (x y : Placement H k 0) : + 0 ≤ placementKernel H z x y := placementProbability_nonneg H hz hz1 _ _ + +lemma placementKernel_rowSum {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) {k : ℕ} (x : Placement H k 0) : + ∑ y, placementKernel H z x y = 1 := by + unfold placementKernel + rw [(placementIdentification H k).sum_comp] + exact placementProbability_rowSum H hz hz1 x + +lemma placementKernel_colSum {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) {k : ℕ} (y : Placement H k 0) : + ∑ x, placementKernel H z x y = 1 := placementProbability_colSum H hz hz1 _ + +def placementEdge {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (reverse : Bool) {k : ℕ} (x y : Placement H k 0) : ℝ := + if reverse then placementKernel H z y x else placementKernel H z x y + +theorem placement_cycle_bound {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) (k n : ℕ) (reverse : Fin (n+1) → Bool) : + (∑ x : Fin (n+1) → Placement H k 0, + ∏ i, (placementEdge H z (reverse i) (x i) (x (finRotate (n+1) i))) ^ + ((n : ℝ) / (n+1 : ℝ))) ≤ ((gridSize bits - h).descFactorial k : ℝ) := by + rw [← card_placement H k 0] + apply Cyclic.sum_cycle_rpow_le_card + · intro i x y + unfold placementEdge + split_ifs <;> exact placementKernel_nonneg H hz hz1 _ _ + · intro i y + unfold placementEdge + cases reverse i with + | false => exact placementKernel_colSum H hz hz1 y + | true => exact placementKernel_rowSum H hz hz1 y + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/PlacementAlternation.lean b/lean/OAI/Probability/BinarySweep/Conditional/PlacementAlternation.lean new file mode 100644 index 0000000000000000000000000000000000000000..013837641e859ba841222d202553a618a27449d3 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/PlacementAlternation.lean @@ -0,0 +1,41 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +variable {I : Type*} [DecidableEq I] + +def alternatingSubsetSum (U : Finset I) (s : ℝ) (p : Finset I → ℝ) : ℝ := + ∑A ∈ U.powerset, (-1:ℝ)^(U.card-A.card)*s^A.card*p A + +lemma alternatingSubsetSum_of_isolated (U : Finset I) {s : ℝ} (hs : s≠0) + (p : Finset I → ℝ) (i : I) (hi : i∈U) + (hp : ∀A ⊆ U.erase i, p (insert i A)=s⁻¹*p A) : + alternatingSubsetSum U s p=0 := by + have hUi : U=insert i (U.erase i) := (Finset.insert_erase hi).symm + have hn : i∉U.erase i := Finset.notMem_erase i U + unfold alternatingSubsetSum + rw [hUi,Finset.sum_powerset_insert hn,← Finset.sum_add_distrib] + apply Finset.sum_eq_zero + intro A hA + have hAU : A⊆U.erase i := Finset.mem_powerset.mp hA + have hiA : i∉A := fun h => hn (hAU h) + have hcard := Finset.card_le_card hAU + rw [Finset.card_insert_of_notMem hiA,hp A hAU] + have he : (insert i (U.erase i)).card-A.card = + ((insert i (U.erase i)).card-(A.card+1))+1 := by + rw [Finset.card_insert_of_notMem hn] + omega + rw [he,pow_succ,pow_succ] + simp only [mul_assoc] + field_simp + ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/PlacementBlocks.lean b/lean/OAI/Probability/BinarySweep/Conditional/PlacementBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c4be2848cbeb9eb1974b74a23d93f1c7fcd56c6 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/PlacementBlocks.lean @@ -0,0 +1,109 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.HookInducedMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation Equiv Equiv.Perm + +variable {A B X : Type*} [Fintype A] [Fintype B] [Fintype X] + (e : A ⊕ B ≃ X) + +abbrev PlacementComplement (x : B ↪ X) := {u : X // u ∉ Set.range x} + +def placementComplementEquiv (x : B ↪ X) : A ≃ PlacementComplement x where + toFun a := ⟨placementSection e x (e (Sum.inl a)), by + rintro ⟨b,hb⟩ + have he := (placementSection e x).injective ((placementSection_apply e x b).trans hb) + exact Sum.inl_ne_inr (e.injective he).symm⟩ + invFun u := (e.symm ((placementSection e x)⁻¹ u.val)).getLeft (by + cases h : e.symm ((placementSection e x)⁻¹ u.val) with + | inl _ => rfl + | inr b => + exfalso + apply u.property + refine ⟨b,?_⟩ + have hh := congrArg (fun t => placementSection e x (e t)) h + simpa only [e.apply_symm_apply,Equiv.Perm.inv_def,Equiv.apply_symm_apply, + show placementSection e x (e (Sum.inr b)) = x b from placementSection_apply e x b] using hh.symm) + left_inv a := by + simp only [Equiv.Perm.inv_def,Equiv.symm_apply_apply,e.symm_apply_apply,Sum.getLeft_inl] + right_inv u := by + apply Subtype.ext + have hl : (e.symm ((placementSection e x)⁻¹ u.val)).isLeft := by + cases h : e.symm ((placementSection e x)⁻¹ u.val) with + | inl _ => rfl + | inr b => + exfalso + apply u.property + refine ⟨b,?_⟩ + have hh := congrArg (fun t => placementSection e x (e t)) h + simpa only [e.apply_symm_apply,Equiv.Perm.inv_def,Equiv.apply_symm_apply, + show placementSection e x (e (Sum.inr b)) = x b from placementSection_apply e x b] using hh.symm + change placementSection e x (e (Sum.inl ((e.symm ((placementSection e x)⁻¹ u.val)).getLeft _))) = u.val + rw [show Sum.inl ((e.symm ((placementSection e x)⁻¹ u.val)).getLeft hl) = + e.symm ((placementSection e x)⁻¹ u.val) from Sum.inl_getLeft _ hl] + simp + +omit [Fintype X] in +lemma placementCoset_index (a : Equiv.Perm X) (y : B ↪ X) : + cosetIndexAction (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e) a y = y.trans a.symm.toEmbedding := by + let c := (cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e y)⁻¹*a) + have he : blockPerm e c.1 * (placementSection e c.2)⁻¹ = (placementSection e y)⁻¹*a := + (cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).apply_symm_apply _ + have hi := congrArg (fun g : Equiv.Perm X => g⁻¹) he + ext b + have hb := Equiv.congr_fun hi (basePlacement e b) + simp only [mul_inv_rev,inv_inv,Equiv.Perm.mul_apply,← map_inv,placementSection_apply] at hb + change placementSection e c.2 ((blockPerm e c.1⁻¹) (e (Sum.inr b))) = _ at hb + rw [blockPerm_inr] at hb + exact (placementSection_apply e c.2 b).symm.trans hb + +omit [Fintype X] in +lemma placementCoset_subgroup (a : Equiv.Perm X) (y : B ↪ X) : + blockPerm e ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e y)⁻¹*a)).1 = + (placementSection e y)⁻¹*a*placementSection e (y.trans a.symm.toEmbedding) := by + have he := (cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).apply_symm_apply ((placementSection e y)⁻¹*a) + change blockPerm e _ * (placementSection e _)⁻¹ = _ at he + have hi := placementCoset_index e a y + change ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e y)⁻¹*a)).2 = _ at hi + rw [hi] at he + exact (mul_inv_eq_iff_eq_mul.mp he) + +variable {W : Type*} [NormedAddCommGroup W] [InnerProductSpace ℂ W] + (σ : Representation ℂ (Equiv.Perm A) W) + +omit [Fintype X] in +lemma placement_hilbertBlock (a : Equiv.Perm X) (x y : B ↪ X) : + hilbertBlock (coindHilbertRep (blockPerm e) σ (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e) a) y x = + if x.trans a.toEmbedding = y then + σ ((cosetEquiv (blockPerm e) (fun x => (placementSection e x)⁻¹) + (placement_cosets_bijective e)).symm ((placementSection e y)⁻¹*a)).1 else 0 := by + rw [hilbertBlock_coind,placementCoset_index] + congr 1 + apply propext + constructor + · intro h + ext b + have hb := congrArg (fun x : B ↪ X => a (x b)) h + exact hb.symm.trans (by simp) + · intro h + ext b + have hb := congrArg (fun x : B ↪ X => a⁻¹ (x b)) h + simpa using hb.symm + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Conditional/PlacementCycleMoment.lean b/lean/OAI/Probability/BinarySweep/Conditional/PlacementCycleMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b19e18ed97494bfdbb242a480ee329d5f60f3db --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Conditional/PlacementCycleMoment.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.AugmentedBlock +import OAI.Probability.BinarySweep.MatrixBounds.HilbertBlockTrace + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {A W : Type*} [Fintype A] [NormedAddCommGroup W] [InnerProductSpace ℂ W] + [FiniteDimensional ℂ W] (e : A ⊕ Fin k ≃ FreeSlot H 0) + (σ : Representation ℂ (Equiv.Perm A) W) + +abbrev inducedPlacementAverage (z : ℝ) := + groupAverage (coindHilbertRep (blockPerm e) σ + (fun x => (placementSection e x)⁻¹) (placement_cosets_bijective e)) + (fun a => (conditionalGroupLaw H z a:ℂ)) + +def placementFiberMoment (z : ℝ) (q : ℕ) (x y : Placement H k 0) : ℝ := + if hp : 0 (conditionalGroupLaw (augmentByChoice H x g) z a:ℂ))) + else 0 + +lemma realizedOutputIndex (z : ℝ) (x y : Placement H k 0) + (hp : 0 congr 1 + ring + cases reverse with + | false => exact hsingle x y hp + | true => exact hsingle y x hp + +lemma linePerturbationRadius_lt_one (r : ℕ) : linePerturbationRadius r < 1 := by + have hf : (1 : ℝ) ≤ ((2 ^ (2 * r)).factorial : ℝ) := by + exact_mod_cast Nat.factorial_pos (2 ^ (2 * r)) + unfold linePerturbationRadius + apply (div_lt_one (by positivity)).mpr + linarith + +theorem placement_weighted_cycle_bound {b h r : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) + (k n : ℕ) (reverse : Fin (n+1) → Bool) : + (∑ x : Fin (n+1) → Placement H k 0, + ∏ i, placementEdge H z (reverse i) (x i) (x (finRotate (n+1) i)) * + Real.exp (-placementEdgeCost H z (reverse i) (x i) (x (finRotate (n+1) i)) / + (n+1 : ℝ))) ≤ Real.exp (-pathCost H + Real.log 4 * k * b) := by + have hz1 := hzr.trans_lt (linePerturbationRadius_lt_one r) + have hc := weighted_cycle_le_card (A := Placement H k 0) n + (fun i => placementEdge H z (reverse i)) + (fun i => placementEdgeCost H z (reverse i)) + (-(k : ℝ) * Real.log (gridSize bits) - pathCost H + Real.log 4 * k * b) + (by + intro i x y + unfold placementEdge + split_ifs <;> exact placementKernel_nonneg H hz hz1 _ _) + (by + intro i y + unfold placementEdge + cases reverse i with + | false => exact placementKernel_colSum H hz hz1 y + | true => exact placementKernel_rowSum H hz hz1 y) + (by intro i x y hp; exact placementEdge_bound H hd hz hzr (reverse i) x y hp) + rw [card_placement] at hc + apply hc.trans + have hcard : ((gridSize bits - h).descFactorial k : ℝ) ≤ (gridSize bits : ℝ) ^ k := by + exact_mod_cast (Nat.descFactorial_le_pow (gridSize bits - h) k).trans + (Nat.pow_le_pow_left (Nat.sub_le (gridSize bits) h) k) + have hs : (0 : ℝ) < gridSize bits := by exact_mod_cast gridSize_pos bits + calc + _ ≤ Real.exp (-(k : ℝ) * Real.log (gridSize bits) - pathCost H + Real.log 4 * k * b) * + (gridSize bits : ℝ) ^ k := + mul_le_mul_of_nonneg_left hcard (Real.exp_pos _).le + _ = _ := by + have he : (gridSize bits : ℝ) ^ k = + Real.exp ((k : ℝ) * Real.log (gridSize bits)) := by + rw [Real.exp_nat_mul, Real.exp_log hs] + rw [he, ← Real.exp_add] + congr 1 + ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/ActiveTypes.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/ActiveTypes.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6ef446e3d0cdd98e887054179812c9931d78fa0 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/ActiveTypes.lean @@ -0,0 +1,105 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungResolution +import OAI.Probability.BinarySweep.TensorBounds.SignedWhitening + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +open Matrix + +namespace BinaryCoordinateSweeps +open Density Irrep Representation + +lemma orthogonal_idempotents_independent {I X : Type*} [Fintype I] [Fintype X] + (P : I → Matrix X X ℂ) (hp : ∀i, P i*P i=P i) + (hz : ∀i j, i≠j → P i*P j=0) (hne : ∀i, P i≠0) : + LinearIndependent ℂ P := by + rw [Fintype.linearIndependent_iff] + intro c hc i + have hh := congrArg (fun M => P i*M) hc + rw [Matrix.mul_zero,Matrix.mul_sum] at hh + have he : (∑j, P i*(c j • P j))=c i • P i := by + rw [Finset.sum_eq_single i] + · rw [Matrix.mul_smul,hp] + · intro j _ hji; rw [Matrix.mul_smul,hz i j hji.symm,smul_zero] + · simp + rw [he] at hh + exact (smul_eq_zero.mp hh).resolve_right (hne i) + +namespace Signed +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +def typeProjection (p : A → Bool) (α : n.Partition) := + isotypicProjection p (Young.partitionHilbertRep α) + +lemma typeProjection_linear (p : A → Bool) (α : n.Partition) : + (typeProjection p α).toEuclideanLin= + (isotypicSpan (Young.partitionHilbertRep α) (hilbertTensorRep p n)).starProjection.toLinearMap := by + rw [hilbert_isotypic_eq] + exact projectionMatrix_linear _ + +lemma typeProjection_idempotent (p : A → Bool) (α : n.Partition) : + typeProjection p α*typeProjection p α=typeProjection p α := projectionMatrix_idempotent _ + +lemma typeProjection_orthogonal (p : A → Bool) (α β : n.Partition) (h : α≠β) : + typeProjection p α*typeProjection p β=0 := by + apply Matrix.toEuclideanLin.injective + simp only [Matrix.toLpLin_mul_same,map_zero,typeProjection_linear] + apply LinearMap.ext + intro v + change (isotypicSpan (Young.partitionHilbertRep α) (hilbertTensorRep p n)).starProjection + ((isotypicSpan (Young.partitionHilbertRep β) (hilbertTensorRep p n)).starProjection v)=0 + apply (Submodule.starProjection_apply_eq_zero_iff _).mpr + apply isotypic_orthogonal (Young.partitionHilbertRep α) (Young.partitionHilbertRep β) + (hilbertTensorRep p n) (Young.partitionHilbertRep_unitary α) + (Young.partitionHilbertRep_unitary β) (hilbertTensorRep_unitary p) + (fun ⟨e⟩ => h (Young.partitionHilbertRep_equiv_injective α β e)) + exact Submodule.starProjection_apply_mem _ _ + +abbrev ActiveType (p : A → Bool) (n : ℕ) := {α : n.Partition // typeProjection p α≠0} + +lemma activeType_card (p : A → Bool) (n : ℕ) : + Fintype.card (ActiveType p n) ≤ (n+1)^((Fintype.card A)^2) := by + let P (α : ActiveType p n) : invariantSubspace p n := + ⟨typeProjection p α.val,isotypicProjection_invariant p _⟩ + have hi : LinearIndependent ℂ (fun α : ActiveType p n => typeProjection p α.val) := + orthogonal_idempotents_independent _ (fun α => typeProjection_idempotent p α.val) + (fun α β h => typeProjection_orthogonal p α.val β.val (fun he => h (Subtype.ext he))) + (fun α => α.property) + have hP : LinearIndependent ℂ P := by + rw [Fintype.linearIndependent_iff] + intro c hc + apply Fintype.linearIndependent_iff.mp hi c + have hh := congrArg (fun v : invariantSubspace p n => v.val) hc + simpa only [Submodule.coe_sum,Submodule.coe_smul,Submodule.coe_zero,P] using hh + exact hP.fintype_card_le_finrank.trans (invariantSubspace_finrank p n) + +lemma all_typeProjection_sum (p : A → Bool) (n : ℕ) : + (∑α : n.Partition, typeProjection p α)=1 := by + apply Matrix.toEuclideanLin.injective + simp only [map_sum,typeProjection_linear,Matrix.toLpLin_one] + apply LinearMap.ext + intro v + simp only [LinearMap.sum_apply,ContinuousLinearMap.coe_coe,LinearMap.id_apply] + exact Young.partition_projection_sum (hilbertTensorRep p n) (hilbertTensorRep_unitary p) v + +theorem active_typeProjection_sum (p : A → Bool) (n : ℕ) : + (∑α : ActiveType p n, typeProjection p α.val)=1 := by + rw [← all_typeProjection_sum p n] + classical + rw [← Finset.sum_subtype (Finset.univ.filter (fun α : n.Partition => typeProjection p α≠0)) + (by simp) (fun α => typeProjection p α)] + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro α _ + split_ifs with h + · rfl + · exact (not_ne_iff.mp h).symm + +end Signed +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/AssignmentSign.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/AssignmentSign.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a16383f15f4c79dd828a1c394a3cd6a39edd96d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/AssignmentSign.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.IndependentHistory + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +variable {I X : Type*} [Fintype I] [Fintype X] [DecidableEq X] + +lemma realSign_swap {u v : X} (huv : u≠v) : realSign (Equiv.swap u v) = -1 := by + simp [realSign,Equiv.Perm.sign_swap huv] + +omit [Fintype I] [Fintype X] in +lemma assigns_swap_left (A B : I ↪ X) {u v : X} + (hu : u∉Set.range B) (hv : v∉Set.range B) (σ : Equiv.Perm X) : + Assigns A B (Equiv.swap u v*σ) ↔ Assigns A B σ := by + have hf (i : I) : Equiv.swap u v (B i)=B i := by + apply Equiv.swap_apply_of_ne_of_ne + · intro he; exact hu ⟨i,he⟩ + · intro he; exact hv ⟨i,he⟩ + constructor + · intro hh i + apply (Equiv.swap u v).injective + exact (hh i).trans (hf i).symm + · intro hh i + change Equiv.swap u v (σ (A i))=B i + rw [hh i,hf] + +omit [Fintype I] in +theorem sum_sign_assigns_zero (A B : I ↪ X) {u v : X} + (huv : u≠v) (hu : u∉Set.range B) (hv : v∉Set.range B) : + (∑σ : Equiv.Perm X, if Assigns A B σ then realSign σ else 0) = 0 := by + classical + let f (σ : Equiv.Perm X) := if Assigns A B σ then realSign σ else 0 + have ht (σ : Equiv.Perm X) : f (Equiv.swap u v*σ) = -f σ := by + dsimp [f] + rw [assigns_swap_left A B hu hv,map_mul,realSign_swap huv] + split_ifs <;> ring + have he := Equiv.sum_comp (Equiv.mulLeft (Equiv.swap u v)) f + change (∑σ, f (Equiv.swap u v*σ))=∑σ,f σ at he + simp_rw [ht] at he + rw [Finset.sum_neg_distrib] at he + dsimp [f] at he + linarith + +omit [Fintype I] in +lemma uniform_sign_assigns_zero (A B : I ↪ X) {u v : X} + (huv : u≠v) (hu : u∉Set.range B) (hv : v∉Set.range B) : + (∑σ : Equiv.Perm X, if Assigns A B σ then + uniformLaw (Equiv.Perm X) σ * realSign σ else 0) = 0 := by + have ht (σ : Equiv.Perm X) : + (if Assigns A B σ then uniformLaw (Equiv.Perm X) σ*realSign σ else 0) = + (Fintype.card (Equiv.Perm X):ℝ)⁻¹*(if Assigns A B σ then realSign σ else 0) := by + split_ifs <;> simp [uniformLaw] + simp_rw [ht] + rw [←Finset.mul_sum,sum_sign_assigns_zero A B huv hu hv,mul_zero] + +lemma uniform_sign_zero [Nontrivial X] : + (∑σ : Equiv.Perm X, uniformLaw (Equiv.Perm X) σ*realSign σ)=0 := by + obtain ⟨u,v,huv⟩ := exists_pair_ne X + let E : Fin 0 ↪ X := ⟨Fin.elim0,by intro i; exact Fin.elim0 i⟩ + have hs := uniform_sign_assigns_zero E E huv + (by rintro ⟨i,_⟩; exact Fin.elim0 i) (by rintro ⟨i,_⟩; exact Fin.elim0 i) + simpa [Assigns] using hs + +lemma lineLaw_sign_zero {d : ℕ} (hd : 0 + intro hd + by_cases hsmall : d≤2*r + · refine ⟨1,by omega,fun _ => d,fun _ => ⟨hd,hsmall⟩,?_⟩ + simp + obtain ⟨b,hb,bits,hbits,hsum⟩ := ih (d-r) (by omega) (by omega) + refine ⟨b+1,by omega,Fin.cons r bits,?_,?_⟩ + · intro j + refine Fin.cases ?_ (fun i => ?_) j + · simp only [Fin.cons_zero]; omega + · simpa using hbits i + · rw [Fin.sum_univ_succ] + simp only [Fin.cons_zero,Fin.cons_succ,hsum,Nat.add_sub_of_le hd] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/CyclicHolder.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/CyclicHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fca685d99a6824be7e88b216aff950e9c53f9cf --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/CyclicHolder.lean @@ -0,0 +1,156 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Cyclic + +variable {A : Type*} [Fintype A] + +def chainWeight (n : ℕ) (p : Fin n → A → A → ℝ) (x : Fin (n+1) → A) : ℝ := + ∏ i, p i (x i.castSucc) (x i.succ) + +omit [Fintype A] in +lemma chainWeight_cons (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (a : A) (x : Fin (n+1) → A) : + chainWeight (n+1) p (Fin.cons a x) = + p 0 a (x 0) * chainWeight n (fun i => p i.succ) x := by + unfold chainWeight + rw [Fin.prod_univ_succ] + simp + +lemma sum_chainWeight (n : ℕ) (p : Fin n → A → A → ℝ) + (hp : ∀ i y, ∑ x, p i x y = 1) : + ∑ x : Fin (n+1) → A, chainWeight n p x = (Fintype.card A : ℝ) := by + induction n with + | zero => simp [chainWeight] + | succ n ih => + rw [← (Fin.consEquiv (fun _ : Fin (n+2) => A)).sum_comp] + rw [Fintype.sum_prod_type, Finset.sum_comm] + change (∑ x : Fin (n+1) → A, ∑ a : A, chainWeight (n+1) p (Fin.cons a x)) = _ + simp_rw [chainWeight_cons] + simp only [← Finset.sum_mul, hp, one_mul] + exact ih (fun i => p i.succ) (fun i => hp i.succ) + +def deletedWeight (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (r : Fin (n+1)) (x : Fin (n+1) → A) : ℝ := + ∏ i, if i = r then 1 else p i (x i) (x (finRotate (n+1) i)) + +omit [Fintype A] in +lemma deletedWeight_last (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (x : Fin (n+1) → A) : + deletedWeight n p (Fin.last n) x = chainWeight n (fun i => p i.castSucc) x := by + unfold deletedWeight chainWeight + rw [Fin.prod_univ_castSucc] + simp [finRotate_apply, Fin.coeSucc_eq_succ] + +omit [Fintype A] in +lemma deletedWeight_reindex (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (r : Fin (n+1)) (x : Fin (n+1) → A) : + let e := finCycle (r - Fin.last n) + deletedWeight n p r x = + deletedWeight n (fun i => p (e i)) (Fin.last n) (fun i => x (e i)) := by + dsimp only + let e := finCycle (r - Fin.last n) + have helast : e (Fin.last n) = r := by simp [e, finCycle_apply] + have heq (i : Fin (n+1)) : e i = r ↔ i = Fin.last n := by + rw [← helast, e.injective.eq_iff] + have hecomm (i : Fin (n+1)) : e (finRotate (n+1) i) = finRotate (n+1) (e i) := by + simp only [e, finCycle_apply, finRotate_apply] + abel + unfold deletedWeight + rw [← Equiv.prod_comp e (fun i => if i = r then (1 : ℝ) else p i (x i) (x (finRotate (n+1) i)))] + apply Finset.prod_congr rfl + intro i _ + simp only [heq, ← hecomm] + rfl + +lemma sum_deletedWeight (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (hp : ∀ i y, ∑ x, p i x y = 1) (r : Fin (n+1)) : + ∑ x : Fin (n+1) → A, deletedWeight n p r x = (Fintype.card A : ℝ) := by + let e := finCycle (r - Fin.last n) + have hdel (x : Fin (n+1) → A) : deletedWeight n p r x = + chainWeight n (fun i => p (e i.castSucc)) (fun i => x (e i)) := by + rw [deletedWeight_reindex n p r x, deletedWeight_last] + simp_rw [hdel] + have he : (∑ x : Fin (n+1) → A, + chainWeight n (fun i => p (e i.castSucc)) (fun i => x (e i))) = + ∑ x : Fin (n+1) → A, chainWeight n (fun i => p (e i.castSucc)) x := by + exact (Equiv.arrowCongr e.symm (Equiv.refl A)).sum_comp _ + rw [he] + exact sum_chainWeight n _ (fun i => hp (e i.castSucc)) + +omit [Fintype A] in +lemma deletedWeight_nonneg (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (hp : ∀ i x y, 0 ≤ p i x y) (r : Fin (n+1)) (x : Fin (n+1) → A) : + 0 ≤ deletedWeight n p r x := by + apply Finset.prod_nonneg + intro i _ + split_ifs + · exact zero_le_one + · exact hp _ _ _ + +omit [Fintype A] in +lemma prod_deletedWeight (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (x : Fin (n+1) → A) : + ∏ r, deletedWeight n p r x = + ∏ i, (p i (x i) (x (finRotate (n+1) i))) ^ n := by + unfold deletedWeight + rw [Finset.prod_comm] + apply Finset.prod_congr rfl + intro i _ + rw [Finset.prod_ite] + simp only [Finset.prod_const_one, one_mul, Finset.prod_const] + congr 1 + have hset : Finset.univ.filter (fun r : Fin (n+1) => ¬ i = r) = + Finset.univ.erase i := by ext r; simp [ne_comm] + rw [hset, Finset.card_erase_of_mem (Finset.mem_univ _)] + simp + +omit [Fintype A] in +lemma prod_deletedWeight_rpow (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (hp : ∀ i x y, 0 ≤ p i x y) (x : Fin (n+1) → A) : + (∏ r, (deletedWeight n p r x) ^ (1 / (n+1 : ℝ))) = + ∏ i, (p i (x i) (x (finRotate (n+1) i))) ^ ((n : ℝ) / (n+1 : ℝ)) := by + rw [Real.finsetProd_rpow _ _ (fun r _ => deletedWeight_nonneg n p hp r x), + prod_deletedWeight, + ← Real.finsetProd_rpow _ _ (fun i _ => pow_nonneg (hp _ _ _) _)] + apply Finset.prod_congr rfl + intro i _ + rw [← Real.rpow_natCast, ← Real.rpow_mul (hp _ _ _)] + congr 1 + ring + +theorem sum_cycle_rpow_le_card (n : ℕ) (p : Fin (n+1) → A → A → ℝ) + (hp : ∀ i x y, 0 ≤ p i x y) + (hsum : ∀ i y, ∑ x, p i x y = 1) : + (∑ x : Fin (n+1) → A, + ∏ i, (p i (x i) (x (finRotate (n+1) i))) ^ ((n : ℝ) / (n+1 : ℝ))) + ≤ (Fintype.card A : ℝ) := by + have hn : (n+1 : ℝ) ≠ 0 := by positivity + calc + _ = ∑ x : Fin (n+1) → A, + ∏ r, (deletedWeight n p r x) ^ (1 / (n+1 : ℝ)) := by + apply Finset.sum_congr rfl + intro x _ + exact (prod_deletedWeight_rpow n p hp x).symm + _ ≤ ∑ x : Fin (n+1) → A, + ∑ r, (1 / (n+1 : ℝ)) * deletedWeight n p r x := by + apply Finset.sum_le_sum + intro x _ + apply Real.geom_mean_le_arith_mean_weighted + · intro r _; positivity + · simp [hn] + · intro r _; exact deletedWeight_nonneg n p hp r x + _ = (Fintype.card A : ℝ) := by + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, sum_deletedWeight n p hsum] + simp [hn] + +end BinaryCoordinateSweeps.Cyclic + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/FiniteLawAverage.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/FiniteLawAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..a24656bdc5ffaac8ead7b4105079829a186e438b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/FiniteLawAverage.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.IndependentOperator + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +lemma finiteLaw_complex_expectation {Ω G R : Type*} [Fintype Ω] [Fintype G] + [AddCommMonoid R] [Module ℂ R] (f : Ω → G) (A : G → R) : + (∑g, (finiteLaw f g:ℂ) • A g)= + (Fintype.card Ω:ℂ)⁻¹ • ∑ω, A (f ω) := by + simp only [finiteLaw,Complex.ofReal_sum,Complex.ofReal_inv,Complex.ofReal_natCast, + apply_ite,Complex.ofReal_zero,Finset.sum_smul] + rw [Finset.sum_comm] + simp only [ite_smul,zero_smul] + simp [Finset.smul_sum] + +lemma uniform_average_product {R : Type*} [Semiring R] [Algebra ℂ R] {n : ℕ} + {X : Fin n → Type*} [∀j, Fintype (X j)] (A : (j : Fin n) → X j → R) : + (Fintype.card (∀j,X j):ℂ)⁻¹ • + (∑f : ∀j,X j, (List.ofFn (fun j => A j (f j))).reverse.prod)= + (List.ofFn (fun j => (Fintype.card (X j):ℂ)⁻¹ • ∑a, A j a)).reverse.prod := by + have he : (Fintype.card (∀j,X j):ℂ)⁻¹=∏j,(Fintype.card (X j):ℂ)⁻¹ := by + simp [Fintype.card_pi,Finset.prod_inv_distrib] + rw [he,Finset.smul_sum] + simpa only [Finset.smul_sum] using independent_average_product + (fun j _ => (Fintype.card (X j):ℂ)⁻¹) A + +lemma complexAverage_finiteLaw {G V Ω : Type*} [Group G] [Fintype G] [Fintype Ω] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ G V) (f : Ω → G) : + complexAverage ρ (fun g => (finiteLaw f g:ℂ))= + (Fintype.card Ω:ℂ)⁻¹ • ∑ω,continuousRep ρ (f ω) := by + rw [complexAverage_sum,finiteLaw_complex_expectation] + +lemma binary_average_product {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] + [FiniteDimensional ℂ V] (d : ℕ) (ρ : Representation ℂ (Equiv.Perm (Slot d)) V) : + complexAverage ρ (fun g => (binaryLaw d g:ℂ))= + (List.ofFn (fun j => (Fintype.card (({i : Fin d // i≠j} → Bool) → Bool):ℂ)⁻¹ • + ∑c,continuousRep ρ (coordinateLayer d j c))).reverse.prod := by + rw [binaryLaw,complexAverage_finiteLaw] + simp_rw [binarySweep,map_list_prod,List.map_reverse,List.map_ofFn,Function.comp_def] + exact uniform_average_product (fun j c => continuousRep ρ (coordinateLayer d j c)) + +lemma finiteLaw_pi {I : Type*} [Fintype I] {Ω X : I → Type*} + [∀i, Fintype (Ω i)] [∀i,Fintype (X i)] + (f : ∀i, Ω i → X i) (x : ∀i, X i) : + finiteLaw (fun (ω : ∀i, Ω i) i => f i (ω i)) x=∏i, finiteLaw (f i) (x i) := by + classical + unfold finiteLaw + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro ω _ + have he : (fun i => f i (ω i))=x ↔ ∀i, f i (ω i)=x i := funext_iff + rw [he] + by_cases h : ∀i, f i (ω i)=x i + · simp [h,Fintype.card_pi,Finset.prod_inv_distrib] + · obtain ⟨i,hi⟩ := not_forall.mp h + rw [ite_eq_right (by aesop)] + symm + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +lemma finiteLaw_equiv {Ω Ω' X : Type*} [Fintype Ω] [Fintype Ω'] [Fintype X] + (e : Ω ≃ Ω') (f : Ω' → X) : finiteLaw (f ∘ e)=finiteLaw f := by + funext x + unfold finiteLaw + rw [Fintype.card_congr e] + exact e.sum_comp (fun ω' => if f ω'=x then (Fintype.card Ω':ℝ)⁻¹ else 0) + +lemma finiteLaw_complex_comp_expectation {Ω X R : Type*} [Fintype Ω] [Fintype X] + [AddCommMonoid R] [Module ℂ R] (f : Ω → X) (A : X → R) : + (Fintype.card Ω:ℂ)⁻¹ • ∑ω,A (f ω)=∑x,(finiteLaw f x:ℂ) • A x := + (finiteLaw_complex_expectation f A).symm + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +def pushLaw {A B : Type*} [Fintype A] (p : A → ℝ) (f : A → B) (b : B) : ℝ := + ∑a, if f a=b then p a else 0 + +lemma finiteLaw_pushLaw {A B : Type*} [Fintype A] [Fintype B] (f : A → B) : + finiteLaw f=pushLaw (uniformLaw A) f := rfl + +lemma pushLaw_expectation {A B R : Type*} [Fintype A] [Fintype B] + [AddCommMonoid R] [Module ℝ R] (p : A → ℝ) (f : A → B) (F : B → R) : + (∑b,pushLaw p f b • F b)=∑a,p a • F (f a) := by + unfold pushLaw + simp only [Finset.sum_smul] + rw [Finset.sum_comm] + simp [ite_smul] + +lemma pushLaw_comp {A B C : Type*} [Fintype A] [Fintype B] + (p : A → ℝ) (f : A → B) (g : B → C) : + pushLaw (pushLaw p f) g=pushLaw p (g ∘ f) := by + funext c + have he := pushLaw_expectation p f (fun b => if g b=c then (1:ℝ) else 0) + simpa [pushLaw,smul_eq_mul,mul_ite] using he + +lemma pushLaw_equiv {A B C : Type*} [Fintype A] [Fintype B] + (e : A ≃ B) (p : B → ℝ) (f : B → C) : + pushLaw (p ∘ e) (f ∘ e)=pushLaw p f := by + funext c + exact e.sum_comp (fun b => if f b=c then p b else 0) + +lemma pushLaw_equiv_apply {A B : Type*} [Fintype A] + (e : A ≃ B) (p : A → ℝ) (b : B) : pushLaw p e b=p (e.symm b) := by + simp only [pushLaw,←e.eq_symm_apply] + simp + +lemma pushLaw_id {A : Type*} [Fintype A] (p : A → ℝ) : pushLaw p id=p := by + funext a; simp [pushLaw] + +lemma pushLaw_prod {A B X Y : Type*} [Fintype A] [Fintype B] + (p : A → ℝ) (q : B → ℝ) (f : A → X) (g : B → Y) : + pushLaw (fun ab : A×B => p ab.1*q ab.2) (Prod.map f g)= + fun xy => pushLaw p f xy.1 * pushLaw q g xy.2 := by + funext xy + simp only [pushLaw,Fintype.sum_prod_type,Finset.sum_mul,Finset.mul_sum] + rw [Finset.sum_comm (f := fun b a => (if f a=xy.1 then p a else 0)*(if g b=xy.2 then q b else 0))] + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + rcases xy with ⟨x,y⟩ + simp only [Prod.map_apply,Prod.mk.injEq] + split_ifs <;> simp_all + +lemma pushLaw_pi {I : Type*} [Fintype I] [DecidableEq I] {A X : I → Type*} + [∀i,Fintype (A i)] [∀i,Fintype (X i)] + (p : ∀i,A i → ℝ) (f : ∀i,A i → X i) : + pushLaw (fun a : ∀i,A i => ∏i,p i (a i)) (fun a i => f i (a i))= + fun x => ∏i,pushLaw (p i) (f i) (x i) := by + funext x + unfold pushLaw + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro a _ + rw [funext_iff] + by_cases h : ∀i,f i (a i)=x i + · simp [h] + · obtain ⟨i,hi⟩ := not_forall.mp h + rw [ite_eq_right (by aesop)] + symm + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +lemma uniformLaw_prod {A B : Type*} [Fintype A] [Fintype B] : + uniformLaw (A×B)=fun ab => uniformLaw A ab.1 * uniformLaw B ab.2 := by + funext ab + simp [uniformLaw,Fintype.card_prod,mul_comm] + +lemma uniformLaw_pi {I : Type*} [Fintype I] [DecidableEq I] {A : I → Type*} [∀i,Fintype (A i)] : + uniformLaw (∀i,A i)=fun a => ∏i,uniformLaw (A i) (a i) := by + funext a + simp [uniformLaw,Fintype.card_pi,Finset.prod_inv_distrib] + +lemma uniformLaw_equiv {A B : Type*} [Fintype A] [Fintype B] (e : A ≃ B) : + uniformLaw B ∘ e=uniformLaw A := by + funext a + simp [uniformLaw,Fintype.card_congr e] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/FiniteProductProbability.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/FiniteProductProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..0085d13b9f2f788162cebc3e2e4f7d5475bf739a --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/FiniteProductProbability.lean @@ -0,0 +1,138 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {I Ω : Type*} [Fintype I] [DecidableEq I] [Fintype Ω] + +def productWeight (p : Ω → ℝ) (x : I → Ω) : ℝ := ∏ i, p (x i) + +def productProbability (p : Ω → ℝ) (E : (I → Ω) → Prop) : ℝ := + ∑ x, productWeight p x * (if E x then 1 else 0) + +omit [DecidableEq I] [Fintype Ω] in +lemma productWeight_nonneg {p : Ω → ℝ} (hp : ∀ u, 0 ≤ p u) (x : I → Ω) : + 0 ≤ productWeight p x := Finset.prod_nonneg (fun i _ => hp (x i)) + +lemma productWeight_sum (p : Ω → ℝ) (hp : ∑ u, p u = 1) : + ∑ x : I → Ω, productWeight p x = 1 := by + unfold productWeight + rw [← Fintype.prod_sum] + simp [hp] + +omit [DecidableEq I] in +lemma indicator_prod (P : I → Prop) : + (∏ i, (if P i then (1:ℝ) else 0)) = if ∀ i, P i then 1 else 0 := by + classical + by_cases h : ∀ i, P i + · simp [h] + · obtain ⟨i,hi⟩ := not_forall.mp h + rw [ite_eq_right h] + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +omit [DecidableEq I] [Fintype Ω] in +lemma productWeight_split (p : Ω → ℝ) (T : I → Prop) [DecidablePred T] + (u : {i // T i} → Ω) (v : {i // ¬ T i} → Ω) : + productWeight p ((Equiv.piEquivPiSubtypeProd T (fun _ => Ω)).symm (u,v)) = + productWeight p u * productWeight p v := by + unfold productWeight + rw [← Fintype.prod_subtype_mul_prod_subtype T] + congr 1 + · apply Finset.prod_congr rfl + intro i _ + simp [Equiv.piEquivPiSubtypeProd_symm_apply,i.property] + · apply Finset.prod_congr rfl + intro i _ + simp [Equiv.piEquivPiSubtypeProd_symm_apply,i.property] + +lemma productProbability_nonneg {p : Ω → ℝ} (hp : ∀ u, 0 ≤ p u) + (E : (I → Ω) → Prop) : 0 ≤ productProbability p E := by + apply Finset.sum_nonneg + intro x _ + exact mul_nonneg (productWeight_nonneg hp x) (by split_ifs <;> norm_num) + +lemma productProbability_mono {p : Ω → ℝ} (hp : ∀ u, 0 ≤ p u) + {E F : (I → Ω) → Prop} (h : ∀ x, E x → F x) : + productProbability p E ≤ productProbability p F := by + apply Finset.sum_le_sum + intro x _ + apply mul_le_mul_of_nonneg_left _ (productWeight_nonneg hp x) + by_cases hx : E x + · simp [hx,h x hx] + · simp [hx]; split_ifs <;> norm_num + +lemma productProbability_union_le {J : Type*} [Fintype J] {p : Ω → ℝ} + (hp : ∀ u, 0 ≤ p u) (E : J → (I → Ω) → Prop) : + productProbability p (fun x => ∃ j, E j x) ≤ ∑ j, productProbability p (E j) := by + unfold productProbability + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro x _ + rw [← Finset.mul_sum] + apply mul_le_mul_of_nonneg_left _ (productWeight_nonneg hp x) + by_cases h : ∃ j, E j x + · obtain ⟨j,hj⟩ := h + rw [ite_eq_left ⟨j,hj⟩] + exact (show (1:ℝ) ≤ if E j x then 1 else 0 by simp [hj]).trans + (Finset.single_le_sum (f:=fun i:J => if E i x then (1:ℝ) else 0) (fun i _ => by split_ifs <;> norm_num) (Finset.mem_univ j)) + · rw [ite_eq_right h] + exact Finset.sum_nonneg (fun i _ => by split_ifs <;> norm_num) + +theorem depthOne_probability_le {H : Type*} [Fintype H] + (p : Ω → ℝ) (hp : ∀ u, 0 ≤ p u) (hp1 : ∑ u, p u = 1) + (R : Ω → Ω → Prop) (ω : ℝ) (_hω : 0 ≤ ω) + (hR : ∀ v, (∑ u, p u * (if R u v then 1 else 0)) ≤ ω) + (T : Finset I) (f : T → {i // i ∉ T} ⊕ H) (roots : H → Ω) : + productProbability p (fun x : I → Ω => ∀ i : T, R (x i) ((f i).elim (fun j : {i // i ∉ T} => x j.val) roots)) ≤ + ω^T.card := by + classical + let : Fintype T := Subtype.fintype (fun i => i ∈ T) + let e := Equiv.piEquivPiSubtypeProd (fun i => i ∈ T) (fun _ => Ω) + unfold productProbability + rw [← e.symm.sum_comp] + rw [Fintype.sum_prod_type,Finset.sum_comm] + have he (u : T → Ω) (v : {i // i ∉ T} → Ω) (i : T) : + R (e.symm (u,v) i) ((f i).elim (fun j : {i // i ∉ T} => e.symm (u,v) j.val) roots) ↔ + R (u i) ((f i).elim v roots) := by + cases hf : f i with + | inl j => simp [e,Equiv.piEquivPiSubtypeProd_symm_apply,i.property,j.property] + | inr h => simp [e,Equiv.piEquivPiSubtypeProd_symm_apply,i.property] + change (∑ v : {i // i ∉ T} → Ω, ∑ u : T → Ω, + productWeight p (e.symm (u,v)) * _) ≤ _ + have hsplit (u : T → Ω) (v : {i // i ∉ T} → Ω) : + productWeight p (e.symm (u,v)) = productWeight p u * productWeight p v := by + exact productWeight_split p (fun i => i ∈ T) u v + simp_rw [hsplit] + have ht (v : {i // i ∉ T} → Ω) : + (∑ u : T → Ω, productWeight p u * + (if ∀ i : T, R (e.symm (u,v) i) ((f i).elim (fun j : {i // i ∉ T} => e.symm (u,v) j.val) roots) + then 1 else 0)) ≤ ω^T.card := by + simp_rw [he,← indicator_prod,productWeight,← Finset.prod_mul_distrib] + rw [← Fintype.prod_sum (fun (i : T) (u : Ω) => p u * (if R u ((f i).elim v roots) then 1 else 0))] + simpa using Finset.prod_le_prod₀ (s:=Finset.univ) (fun i _ => Finset.sum_nonneg (fun u _ => + mul_nonneg (hp u) (by split_ifs <;> norm_num))) (fun i _ => hR ((f i).elim v roots)) + calc + _ = ∑ v : {i // i ∉ T} → Ω, productWeight p v * + (∑ u : T → Ω, productWeight p u * + (if ∀ i : T, R (e.symm (u,v) i) ((f i).elim (fun j : {i // i ∉ T} => e.symm (u,v) j.val) roots) + then 1 else 0)) := by + apply Finset.sum_congr rfl + intro v _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + rw [mul_assoc, mul_left_comm] + congr 2 + simp only [he] + _ ≤ ∑ v : {i // i ∉ T} → Ω, productWeight p v * ω^T.card := + Finset.sum_le_sum (fun v _ => mul_le_mul_of_nonneg_left (ht v) (productWeight_nonneg hp v)) + _ = ω^T.card := by rw [← Finset.sum_mul,productWeight_sum p hp1,one_mul] + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/HilbertMainCases.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/HilbertMainCases.lean new file mode 100644 index 0000000000000000000000000000000000000000..e050390802bd615575dc409770bc861fe01d7793 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/HilbertMainCases.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Probability.BinarySweep.Analytic.OneAxisBase +import OAI.Probability.BinarySweep.Conditional.ConditionalAverage +import OAI.Probability.BinarySweep.GridBounds.GroupedLogBounds + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Signed + +lemma logMoment_le_iff_le_exp (T x : ℝ) : logMoment T ≤ (x:EReal) ↔ T ≤ Real.exp x := by + by_cases hT : T ≤ 0 + · simp only [logMoment,ENNReal.ofReal_eq_zero.mpr hT, ENNReal.log_zero,bot_le,true_iff] + exact hT.trans (Real.exp_pos _).le + · have hT' := lt_of_not_ge hT + rw [logMoment,ENNReal.log_ofReal_of_pos hT',EReal.coe_le_coe_iff] + exact Real.log_le_iff_le_exp hT' + +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +lemma hilbert_conditional_dimension {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (hz : 0 ≤ z) (hz1 : z < 1) (q : ℕ) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) + (hρ : ∀g v, ‖ρ g v‖=‖v‖) : + evenMoment q (groupAverage ρ (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ Module.finrank ℂ V := by + let E := (stdOrthonormalBasis ℂ V).repr + let σ := conjugateRep ρ E.toLinearEquiv + have hσ (g) (v) : ‖σ g v‖=‖v‖ := by + change ‖E (ρ g (E.symm v))‖=‖v‖ + rw [E.norm_map,hρ,E.symm.norm_map] + have he := equivalent_evenMoment ρ σ (conjugateEquiv ρ E.toLinearEquiv) hρ hσ + (fun g => (conditionalGroupLaw H z g:ℂ)) q + rw [he,←conditionalMoment_evenMoment H z σ q] + exact traceMoment_le_dimension q _ (conditionalOperator_norm_le_one H hz hz1 σ hσ) + +lemma hilbert_conditional_automatic {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (hz : 0 ≤ z) (hz1 : z < 1) (q : ℕ) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) [ρ.IsIrreducible] + (hρ : ∀g v, ‖ρ g v‖=‖v‖) + (ha : (1+cExponent (gridSize bits))*Real.log (Module.finrank ℂ V) ≤ + eExponent (gridSize bits)*h*Real.log (gridSize bits)-pathCost H) : + evenMoment q (groupAverage ρ (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ + Real.exp (-cExponent (gridSize bits)*Real.log (Module.finrank ℂ V)+ + eExponent (gridSize bits)*h*Real.log (gridSize bits)-pathCost H) := by + have hD : (0:ℝ) < Module.finrank ℂ V := by exact_mod_cast irreducible_finrank_pos ρ + refine (hilbert_conditional_dimension H z hz hz1 q ρ hρ).trans ?_ + rw [←Real.exp_log hD] + apply Real.exp_le_exp.mpr + rw [Real.log_exp] + linarith + +lemma hilbert_conditional_one_axis {r q : ℕ} + (hr : (400000000:ℝ) ≤ (r:ℝ)*Real.log 2) (hq : 0 < q) + (bits : Fin 1 → ℕ) (hd : ∀j,r ≤ bits j ∧ bits j ≤ 2*r) + {h : ℕ} (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) (hzr : z ≤ oneAxisRadius r) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) [ρ.IsIrreducible] + (hρ : ∀g v,‖ρ g v‖=‖v‖) : + evenMoment q (groupAverage ρ (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ + Real.exp (-cExponent (gridSize bits)*Real.log (Module.finrank ℂ V)+ + eExponent (gridSize bits)*h*Real.log (gridSize bits)-pathCost H) := by + let E := (stdOrthonormalBasis ℂ V).repr + let σ := conjugateRep ρ E.toLinearEquiv + have : σ.IsIrreducible := irreducible_equiv ρ σ (conjugateEquiv ρ E.toLinearEquiv) + have hσ (g) (v) : ‖σ g v‖=‖v‖ := by + change ‖E (ρ g (E.symm v))‖=‖v‖ + rw [E.norm_map,hρ,E.symm.norm_map] + have he := equivalent_evenMoment ρ σ (conjugateEquiv ρ E.toLinearEquiv) hρ hσ + (fun g => (conditionalGroupLaw H z g:ℂ)) q + rw [he,←conditionalMoment_evenMoment H z σ q] + exact (logMoment_le_iff_le_exp _ _).mp (conditional_moment_one_axis hr hq bits hd H hz hzr σ hσ) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/HilbertTranspose.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/HilbertTranspose.lean new file mode 100644 index 0000000000000000000000000000000000000000..913848c94df3584742596796871062e6626475cc --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/HilbertTranspose.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungTranspose +import OAI.Probability.BinarySweep.Conditional.ConditionalSpecht + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +open Irrep Representation + +variable (μ : YoungDiagram) + +lemma norm_signC (g : G μ) : ‖signC μ g‖=1 := by + have h := congrArg Norm.norm (signC_sq μ g) + rw [norm_mul,norm_one] at h + nlinarith [norm_nonneg (signC μ g)] + +lemma hilbert_transpose_equiv : Nonempty ((hilbertSpecht μ).Equiv + (signTwist μ ((hilbertSpecht μ.transpose).comp (transposeCells μ).permCongrHom.toMonoidHom))) := by + obtain ⟨f⟩ := specht_transpose_sign μ + let E := (spechtHilbertEquiv μ).symm.trans (f.toLinearEquiv.trans (spechtHilbertEquiv μ.transpose)) + refine ⟨.mk E ?_⟩ + intro g + apply LinearMap.ext + intro v + obtain ⟨w,rfl⟩ := (spechtHilbertEquiv μ).surjective v + change spechtHilbertEquiv μ.transpose + (f.toLinearEquiv.toFun ((spechtHilbertEquiv μ).symm.toFun + (spechtHilbertEquiv μ (spechtRep μ g ((spechtHilbertEquiv μ).symm.toFun + (spechtHilbertEquiv μ w)))))) = + signC μ g • spechtHilbertEquiv μ.transpose + (spechtRep μ.transpose ((transposeCells μ).permCongr g) + ((spechtHilbertEquiv μ.transpose).symm.toFun + (spechtHilbertEquiv μ.transpose (f.toLinearEquiv.toFun + ((spechtHilbertEquiv μ).symm.toFun (spechtHilbertEquiv μ w)))))) + have hs (ν : YoungDiagram) (x : SpechtSpace ν) : + (spechtHilbertEquiv ν).symm.toFun (spechtHilbertEquiv ν x) = x := + (spechtHilbertEquiv ν).symm_apply_apply x + simp only [hs] + have h := Representation.IntertwiningMap.isIntertwining _ _ f.toIntertwiningMap g w + change f.toLinearEquiv.toFun (spechtRep μ g w) = signC μ g • + spechtRep μ.transpose ((transposeCells μ).permCongr g) (f.toLinearEquiv.toFun w) at h + exact (congrArg (spechtHilbertEquiv μ.transpose).toFun h).trans (map_smul _ _ _) + +lemma hilbert_transpose_moment (p : G μ → ℂ) (q : ℕ) : + evenMoment q (groupAverage (hilbertSpecht μ) p) = + evenMoment q (groupAverage (hilbertSpecht μ.transpose) + (fun g => p ((transposeCells μ).symm.permCongr g)*signC μ.transpose g)) := by + obtain ⟨f⟩ := hilbert_transpose_equiv μ + rw [equivalent_evenMoment _ _ f (hilbertSpecht_unitary μ) (fun g v => by + change ‖signC μ g • hilbertSpecht μ.transpose ((transposeCells μ).permCongr g) v‖=‖v‖ + rw [norm_smul,norm_signC,hilbertSpecht_unitary,one_mul])] + congr 1 + unfold groupAverage + rw [←Equiv.sum_comp (transposeCells μ).permCongr] + apply Finset.sum_congr rfl + intro g _ + change p g • (signC μ g • hilbertSpecht μ.transpose ((transposeCells μ).permCongr g)) = _ + dsimp only + rw [smul_smul,transpose_sign] + rw [show (transposeCells μ).symm.permCongr ((transposeCells μ).permCongr g)=g from + (transposeCells μ).permCongr.symm_apply_apply g] + +end BinaryCoordinateSweeps.Young +namespace BinaryCoordinateSweeps +open Young Irrep + +lemma realSign_permCongr_complex {X Y : Type*} [Fintype X] [Fintype Y] + [DecidableEq X] [DecidableEq Y] (e : X≃Y) (g : Equiv.Perm X) : + (realSign (e.permCongr g):ℂ)=(realSign g:ℂ) := by + exact congrArg (fun sign : ℤˣ => (((sign : ℤ) : ℝ) : ℂ)) + (Equiv.Perm.sign_permCongr e g) + +lemma conditional_transpose_moment {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (μ : YoungDiagram) (e : Cell μ ≃ FreeSlot H 0) (z : ℝ) (q : ℕ) : + evenMoment q (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ))) = + evenMoment q (groupAverage ((hilbertSpecht μ.transpose).comp + ((transposeCells μ).symm.trans e).symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g*realSign g:ℂ))) := by + rw [groupAverage_comp_slots,groupAverage_comp_slots,hilbert_transpose_moment] + congr 2 + funext g + congr 1 + rw [realSign_permCongr_complex] + change ((Equiv.Perm.sign g:ℤ):ℂ)=(((Equiv.Perm.sign g:ℤ):ℝ):ℂ) + norm_cast + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/IndependentOperator.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/IndependentOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..49f1cf0197cfbd663b02e8a072170da8e8ee9403 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/IndependentOperator.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.FiniteUnitaryAverage + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +lemma independent_reverse_product {R : Type*} [Semiring R] {n : ℕ} + {X : Fin n → Type*} [∀j, Fintype (X j)] (A : (j : Fin n) → X j → R) : + (List.ofFn (fun j => ∑a, A j a)).reverse.prod= + ∑f : ∀j, X j, (List.ofFn (fun j => A j (f j))).reverse.prod := by + induction n with + | zero => simp + | succ n ih => + rw [List.ofFn_succ,List.reverse_cons,List.prod_append,List.prod_singleton,ih] + rw [←Equiv.sum_comp (Fin.consEquiv X),Fintype.sum_prod_type] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro f _ + simp only [Fin.consEquiv,Equiv.coe_fn_mk,List.ofFn_succ,List.reverse_cons, + List.prod_append,List.prod_singleton,Fin.cons_zero,Fin.cons_succ] + +lemma weighted_reverse_product {R : Type*} [Semiring R] [Algebra ℂ R] {n : ℕ} + (w : Fin n → ℂ) (A : Fin n → R) : + (List.ofFn (fun j => w j • A j)).reverse.prod= + (∏j,w j) • (List.ofFn A).reverse.prod := by + induction n with + | zero => simp + | succ n ih => + simp only [List.ofFn_succ,List.reverse_cons,List.prod_append,List.prod_singleton, + Fin.prod_univ_succ] + rw [ih,smul_mul_smul_comm,mul_comm (∏j : Fin n, w j.succ) (w 0)] + +lemma independent_average_product {R : Type*} [Semiring R] [Algebra ℂ R] {n : ℕ} + {X : Fin n → Type*} [∀j, Fintype (X j)] + (w : (j : Fin n) → X j → ℂ) (A : (j : Fin n) → X j → R) : + (∑f : ∀j, X j, (∏j,w j (f j)) • + (List.ofFn (fun j => A j (f j))).reverse.prod)= + (List.ofFn (fun j => ∑a, w j a • A j a)).reverse.prod := by + rw [independent_reverse_product] + exact Finset.sum_congr rfl (fun f _ => (weighted_reverse_product _ _).symm) + +lemma reverse_product_norm_le_one {R : Type*} [NormedRing R] [NormOneClass R] + {n : ℕ} (A : Fin n → R) (hA : ∀j, ‖A j‖≤1) : + ‖(List.ofFn A).reverse.prod‖≤1 := by + induction n with + | zero => simp + | succ n ih => + simp only [List.ofFn_succ,List.reverse_cons,List.prod_append,List.prod_singleton] + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) + (ih _ (fun index => hA index.succ))).trans (hA 0)) + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +lemma pi_single_reverse {I G : Type*} [Fintype I] [DecidableEq I] [Group G] + (f : I → G) (e : Fin (Fintype.card I) ≃ I) : + (List.ofFn (fun j => Pi.mulSingle (e j) (f (e j)))).reverse.prod=f := by + funext i + have hh := List.prod_map_eq_pow_single (e.symm i) + (fun j => (Pi.mulSingle (e j) (f (e j)) : I → G) i) + (l := (List.ofFn (fun j : Fin (Fintype.card I) => j)).reverse) (by + intro j hj _ + have hne : i ≠ e j := by + intro he + apply hj + exact e.injective (he.symm.trans (e.apply_symm_apply i).symm) + simp [Pi.mulSingle,hne]) + have hc : ((List.ofFn (fun j : Fin (Fintype.card I) => j)).reverse).count (e.symm i)=1 := by + apply List.count_eq_one_of_mem + · exact List.nodup_reverse.mpr (List.nodup_ofFn.mpr Function.injective_id) + · simp + rw [hc,pow_one,e.apply_symm_apply,Pi.mulSingle_eq_same] at hh + simp only [List.map_reverse,List.map_ofFn,Function.comp_def] at hh + change (Pi.evalMonoidHom (fun _ : I => G) i) + ((List.ofFn (fun j => Pi.mulSingle (e j) (f (e j)))).reverse.prod)=f i + rw [map_list_prod,List.map_reverse,List.map_ofFn] + exact hh + +variable {G V : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +def continuousRep (ρ : Representation ℂ G V) : G →* (V →L[ℂ] V) where + toFun g := (ρ g).toContinuousLinearMap + map_one' := by ext v; simp + map_mul' g h := by ext v; simp + +lemma complexAverage_sum (ρ : Representation ℂ G V) (p : G → ℂ) : + complexAverage ρ p=∑g,p g • continuousRep ρ g := by + ext v + simp [complexAverage_apply,continuousRep] + +theorem pi_average_norm_le_one {I : Type*} [Fintype I] [DecidableEq I] [DecidableEq G] [Nontrivial V] + (ρ : Representation ℂ (I → G) V) (p : I → G → ℂ) + (h : ∀i, ‖complexAverage (ρ.comp (MonoidHom.mulSingle (fun _ : I => G) i)) (p i)‖≤1) : + ‖complexAverage ρ (fun f => ∏i,p i (f i))‖≤1 := by + let e : Fin (Fintype.card I) ≃ I := (Fintype.equivFin I).symm + let E : (Fin (Fintype.card I) → G) ≃ (I → G) := Equiv.piCongrLeft (fun _ => G) e + have he (f : Fin (Fintype.card I) → G) : ∀j, E f (e j)=f j := by + intro j; simp [E,Equiv.piCongrLeft] + have hf : complexAverage ρ (fun f => ∏i,p i (f i))= + (List.ofFn (fun j => complexAverage + (ρ.comp (MonoidHom.mulSingle (fun _ : I => G) (e j))) (p (e j)))).reverse.prod := by + rw [complexAverage_sum,←Equiv.sum_comp E] + simp_rw [←e.prod_comp (fun i => p i (E _ i))] + have ht (f : Fin (Fintype.card I) → G) : continuousRep ρ (E f)= + (List.ofFn (fun j => continuousRep ρ (Pi.mulSingle (e j) (f j)))).reverse.prod := by + rw [←pi_single_reverse (E f) e,map_list_prod,List.map_reverse,List.map_ofFn] + simp only [Function.comp_def,he] + simp_rw [ht,he] + rw [independent_average_product (X := fun _ => G) + (fun j a => p (e j) a) (fun j a => continuousRep ρ (Pi.mulSingle (e j) a))] + congr 3 + funext j + rw [complexAverage_sum] + rfl + rw [hf] + exact reverse_product_norm_le_one _ (fun j => h (e j)) + +lemma pi_comp_average_norm_le_one {I H : Type*} [Fintype I] [DecidableEq I] [DecidableEq G] [Group H] [Fintype H] + [Nontrivial V] (ρ : Representation ℂ H V) (φ : (I → G) →* H) + (p : G → ℂ) (hρ : ∀g v, ‖ρ g v‖=‖v‖) + (hp : ∀σ : Representation ℂ G V, (∀g v, ‖σ g v‖=‖v‖) → + ‖complexAverage σ p‖≤1) : + ‖complexAverage (ρ.comp φ) (fun f => ∏i,p (f i))‖≤1 := by + apply pi_average_norm_le_one + intro i + apply hp + exact fun g v => hρ _ v + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/IndependentPush.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/IndependentPush.lean new file mode 100644 index 0000000000000000000000000000000000000000..b10b4638d0da30d085defc5963c40eaf154c6daa --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/IndependentPush.lean @@ -0,0 +1,51 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +variable {I : Type*} [Fintype I] {Ω G : I → Type*} + [∀i,Fintype (Ω i)] [∀i,Fintype (G i)] + +def finitePush {X Y : Type*} [Fintype X] (w : X → ℂ) (f : X → Y) (y : Y) : ℂ := + ∑x, if f x=y then w x else 0 + +omit [∀ i, Fintype (G i)] in +lemma finitePush_pi (w : ∀i, Ω i → ℂ) (f : ∀i, Ω i → G i) (g : ∀i, G i) : + (∏i, finitePush (w i) (f i) (g i)) = + finitePush (fun x : ∀i, Ω i => ∏i,w i (x i)) (fun x i => f i (x i)) g := by + unfold finitePush + rw [Fintype.prod_sum] + apply Finset.sum_congr rfl + intro x _ + rw [Fintype.prod_ite_zero] + congr 1 + exact propext funext_iff.symm + +lemma finitePush_expectation {X Y V : Type*} [Fintype X] [Fintype Y] + [AddCommMonoid V] [Module ℂ V] (w : X → ℂ) (f : X → Y) (F : Y → V) : + (∑y, finitePush w f y • F y)=∑x,w x • F (f x) := by + classical + unfold finitePush + simp only [Finset.sum_smul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + simp only [ite_smul,zero_smul] + simp + +lemma independentPush_expectation {V : Type*} [AddCommMonoid V] [Module ℂ V] + (w : ∀i, Ω i → ℂ) (f : ∀i, Ω i → G i) (F : (∀i,G i) → V) : + (∑g : ∀i,G i, (∏i,finitePush (w i) (f i) (g i)) • F g)= + ∑x : ∀i,Ω i, (∏i,w i (x i)) • F (fun i=>f i (x i)) := by + simp_rw [finitePush_pi] + exact finitePush_expectation _ _ _ + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/LightLineBound.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/LightLineBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a232d7459fdb60a2f11ac2a42ac803ac802d3b4 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/LightLineBound.lean @@ -0,0 +1,185 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.CenteredLineMoment + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse + +lemma fallingMoment_le_two_pow {m h v : ℕ} (hm : 0 < m) + (hl : (h:ℝ)+v ≤ (m:ℝ)/2) : fallingMoment m h v ≤ (2:ℝ)^v := by + induction v with + | zero => simp + | succ v ih => + have hmr : (0:ℝ) < m := Nat.cast_pos.mpr hm + have hv : h+v < m := by exact_mod_cast (show (h:ℝ)+v < m by push_cast at hl; linarith) + have hi := ih (by push_cast at hl; linarith) + have hn := (fallingMoment_pos hm (Nat.le_of_lt hv)).le + have hn' := (fallingMoment_pos hm (by exact_mod_cast (show (h:ℝ)+(v+1) ≤ m by push_cast at hl; linarith))).le + have hs := fallingMoment_succ hv + have hd : (m:ℝ)/2 ≤ (m:ℝ)-h-v := by push_cast at hl; linarith + have ha := mul_le_mul_of_nonneg_right hd hn' + have hb := mul_le_mul_of_nonneg_left hi hmr.le + rw [pow_succ] + nlinarith + +lemma light_real_lt {m h n : ℕ} {η : ℝ} (hm : 0 < m) (hη : η ≤ 1/4) + (hl : (h:ℝ)+n ≤ m*η) : h+n < m := by + have hp : (0:ℝ) < m := Nat.cast_pos.mpr hm + exact_mod_cast (show (h:ℝ)+n < m by nlinarith) + +theorem centeredLineMoment_light {m h u v : ℕ} {η : ℝ} + (hm : 0 < m) (hη0 : 0 ≤ η) (hη : η ≤ 1/4) + (hl : (h:ℝ)+u+v ≤ m*η) : + 0 ≤ centeredLineMoment m h u v ∧ + centeredLineMoment m h u v ≤ (2:ℝ)^v * (4*Real.sqrt η)^u := by + have hmr : (0:ℝ) < m := Nat.cast_pos.mpr hm + have hr0 : 0 ≤ 4*Real.sqrt η := by positivity + have hr2 : 4*Real.sqrt η ≤ 2 := by + have hs := Real.sq_sqrt hη0 + have hs0 := Real.sqrt_nonneg η + nlinarith + have hrsq : (4*Real.sqrt η)^2 = 16*η := by rw [mul_pow,Real.sq_sqrt hη0]; norm_num + have hetr : η ≤ 4*Real.sqrt η := by nlinarith [Real.sq_sqrt hη0,Real.sqrt_nonneg η] + induction u using Nat.strong_induction_on with + | h u ih => + cases u with + | zero => + rw [centeredLineMoment_zero,pow_zero,mul_one] + have hv : h+v ≤ m := Nat.le_of_lt (light_real_lt hm hη (by simpa using hl)) + exact ⟨(fallingMoment_pos hm hv).le,fallingMoment_le_two_pow hm (by nlinarith)⟩ + | succ u => + cases u with + | zero => + have hb := fallingMoment_le_two_pow hm (show (h:ℝ)+v ≤ m/2 by push_cast at hl; nlinarith) + have hv : h+v < m := light_real_lt hm hη (by push_cast at hl; linarith) + have hbn := (fallingMoment_pos hm (Nat.le_of_lt hv)).le + have he := centeredLineMoment_one hv + have hd : 0 < (m:ℝ)-h-v := by + have hv' : (h:ℝ)+v < m := by exact_mod_cast hv + linarith + have hp : 0 ≤ centeredLineMoment m h 1 v := by + apply nonneg_of_mul_nonneg_right (by rw [he]; positivity) hd + refine ⟨hp,?_⟩ + rw [pow_one] + have ha : (m:ℝ)/2 ≤ (m:ℝ)-h-v := by push_cast at hl; nlinarith + have hc : (h:ℝ)+v ≤ m*η := by push_cast at hl; linarith + have hb' := mul_le_mul_of_nonneg_left hb (show 0 ≤ (h:ℝ)+v by positivity) + have hc' := mul_le_mul_of_nonneg_right hc (show (0:ℝ) ≤ 2^v by positivity) + have ha' := mul_le_mul_of_nonneg_right ha hp + have hr : 2*η ≤ 4*Real.sqrt η := by nlinarith [Real.sq_sqrt hη0,Real.sqrt_nonneg η] + have hr' := mul_le_mul_of_nonneg_left hr (show 0 ≤ (m:ℝ)*(2:ℝ)^v by positivity) + nlinarith + | succ u => + have hu1 := ih (u+1) (by omega) (by push_cast at hl ⊢; linarith) + have hu0 := ih u (by omega) (by push_cast at hl ⊢; linarith) + have hv : h+v+u+1 < m := by + have hh : (h:ℝ)+(v+u+1) ≤ m*η := by push_cast at hl; linarith + have ht := light_real_lt (h := h) (n := v+u+1) hm hη (by simpa only [Nat.cast_add,Nat.cast_one] using hh) + omega + have he := centeredLineMoment_recurrence hv + have hd : 0 < (m:ℝ)-h-v-u-1 := by + have hv' : (h:ℝ)+v+u+1 < m := by exact_mod_cast hv + linarith + have hp : 0 ≤ centeredLineMoment m h (u+2) v := by + apply nonneg_of_mul_nonneg_right (by + rw [he] + exact add_nonneg (mul_nonneg (by positivity) hu1.1) + (mul_nonneg (by positivity) hu0.1)) hd + refine ⟨hp,?_⟩ + have ha : (m:ℝ)/2 ≤ (m:ℝ)-h-v-u-1 := by push_cast at hl; nlinarith + have hc : (h:ℝ)+v+2*u+2 ≤ 2*m*η := by + have hhv : (0:ℝ) ≤ h+v := by positivity + push_cast at hl + linarith + have hc0 : 0 ≤ (h:ℝ)+v+2*u+2 := by positivity + have hb : (u:ℝ)+1 ≤ m*η := by + have hhv : (0:ℝ) ≤ h+v := by positivity + push_cast at hl + linarith + have ha' := mul_le_mul_of_nonneg_right ha hp + have hc' := mul_le_mul hc hu1.2 hu1.1 (by positivity : 0 ≤ 2*(m:ℝ)*η) + have hb' := mul_le_mul hb hu0.2 hu0.1 (by positivity : 0 ≤ (m:ℝ)*η) + have hr : 4*η*(4*Real.sqrt η)+2*η ≤ (4*Real.sqrt η)^2 := by + rw [hrsq] + nlinarith + have hr' := mul_le_mul_of_nonneg_left hr + (show 0 ≤ (m:ℝ)/2*((2:ℝ)^v*(4*Real.sqrt η)^u) by positivity) + simp only [pow_succ] at hc' ⊢ + nlinarith + +end BinaryCoordinateSweeps.Sparse + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse + +variable {L : Type*} [Fintype L] + +def multilineMoment (m h : L → ℕ) : MvPolynomial L ℝ →ₗ[ℝ] ℝ := + (MvPolynomial.basisMonomials L ℝ).constr ℝ + (fun n => ∏ l, fallingMoment (m l) (h l) (n l)) + +lemma multilineMoment_monomial (m h : L → ℕ) (n : L →₀ ℕ) : + multilineMoment m h (MvPolynomial.monomial n 1) = + ∏ l, fallingMoment (m l) (h l) (n l) := by + exact (MvPolynomial.basisMonomials L ℝ).constr_basis ℝ _ n + +lemma multiline_prod_X (n : L → ℕ) : + (∏ l, (MvPolynomial.X l : MvPolynomial L ℝ) ^ n l) = + MvPolynomial.monomial (Finsupp.equivFunOnFinite.symm n) 1 := by + rw [← MvPolynomial.prod_X_pow_eq_monomial] + change (∏ l, MvPolynomial.X l ^ (Finsupp.equivFunOnFinite.symm n) l) = _ + symm + apply Finset.prod_subset (Finset.subset_univ _) + intro l _ hl + have hz := Finsupp.notMem_support_iff.mp hl + change n l = 0 at hz + change (MvPolynomial.X l : MvPolynomial L ℝ)^n l = 1 + rw [hz,pow_zero] + +theorem multilineMoment_factor (m h : L → ℕ) (P : L → Polynomial ℝ) : + multilineMoment m h (∏ l, Polynomial.aeval (MvPolynomial.X l) (P l)) = + ∏ l, lineMoment (m l) (h l) (P l) := by + let f : MultilinearMap ℝ (fun _ : L => Polynomial ℝ) ℝ := + (multilineMoment m h).compMultilinearMap + ((MultilinearMap.mkPiAlgebra ℝ L (MvPolynomial L ℝ)).compLinearMap + (fun l => (Polynomial.aeval (MvPolynomial.X l)).toLinearMap)) + let g : MultilinearMap ℝ (fun _ : L => Polynomial ℝ) ℝ := + (MultilinearMap.mkPiAlgebra ℝ L ℝ).compLinearMap (fun l => lineMoment (m l) (h l)) + have he : f = g := by + apply Module.Basis.ext_multilinear (fun _ : L => Polynomial.basisMonomials ℝ) + intro n + change multilineMoment m h (∏ l, Polynomial.aeval (MvPolynomial.X l) + (Polynomial.basisMonomials ℝ (n l))) = + ∏ l, lineMoment (m l) (h l) (Polynomial.basisMonomials ℝ (n l)) + simp only [Polynomial.coe_basisMonomials,Polynomial.aeval_monomial,map_one,one_mul, + lineMoment_monomial] + rw [multiline_prod_X,multilineMoment_monomial] + rfl + exact congrArg (fun a => a P) he + +lemma multilineMoment_centered (m h u v : L → ℕ) : + multilineMoment m h (∏ l, (MvPolynomial.X l : MvPolynomial L ℝ)^v l * + (MvPolynomial.X l-1)^u l) = + ∏ l, centeredLineMoment (m l) (h l) (u l) (v l) := by + change multilineMoment m h _ = ∏ l, lineMoment (m l) (h l) + (Polynomial.X^v l * (Polynomial.X-1)^u l) + rw [← multilineMoment_factor] + apply congrArg (multilineMoment m h) + apply Finset.prod_congr rfl + intro l _ + rw [map_mul,map_pow,map_pow,map_sub,map_one,Polynomial.aeval_X] + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/LinearEvenMoment.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/LinearEvenMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..4977e102c5a85168411ec43326c12ae38ec50ba3 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/LinearEvenMoment.lean @@ -0,0 +1,64 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicMoment +import OAI.Probability.BinarySweep.MatrixBounds.SchattenBasic + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open TraceHolder + +variable {V ι : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] + [FiniteDimensional ℂ V] [Fintype ι] [DecidableEq ι] + +lemma trace_orthonormalMatrix (v : OrthonormalBasis ι ℂ V) (A : V →ₗ[ℂ] V) : + LinearMap.trace ℂ V A = Matrix.trace (LinearMap.toMatrixOrthonormal v A) := + LinearMap.trace_eq_matrix_trace ℂ v.toBasis A + +lemma evenMoment_orthonormalMatrix (v : OrthonormalBasis ι ℂ V) (q : ℕ) (A : V →ₗ[ℂ] V) : + evenMoment q A=matrixMoment q (LinearMap.toMatrixOrthonormal v A) := by + unfold evenMoment matrixMoment + rw [trace_orthonormalMatrix v] + simp only [map_pow,map_mul,← LinearMap.star_eq_adjoint,map_star] + +lemma evenMoment_nonneg (q : ℕ) (A : V →ₗ[ℂ] V) : 0≤evenMoment q A := by + rw [evenMoment_orthonormalMatrix (stdOrthonormalBasis ℂ V)] + exact matrixMoment_nonneg _ _ + +lemma evenMoment_adjoint (q : ℕ) (A : V →ₗ[ℂ] V) : evenMoment q A.adjoint=evenMoment q A := by + rw [evenMoment_orthonormalMatrix (stdOrthonormalBasis ℂ V), + evenMoment_orthonormalMatrix (stdOrthonormalBasis ℂ V)] + rw [← LinearMap.star_eq_adjoint,map_star] + exact matrixMoment_star q _ + +lemma evenMoment_smul (q : ℕ) (r : ℝ) (A : V →ₗ[ℂ] V) : + evenMoment q (r • A)=r^(2*q)*evenMoment q A := by + rw [evenMoment_orthonormalMatrix (stdOrthonormalBasis ℂ V), + evenMoment_orthonormalMatrix (stdOrthonormalBasis ℂ V)] + rw [← algebraMap_smul ℂ r A,map_smul] + rw [algebraMap_smul ℂ r] + exact matrixMoment_smul q r _ + +lemma evenMoment_unitary_left (q : ℕ) (U A : V →ₗ[ℂ] V) (hu : U.adjoint*U=1) : + evenMoment q (U*A)=evenMoment q A := by + unfold evenMoment + rw [show (U*A).adjoint*(U*A)=A.adjoint*A by + rw [← LinearMap.star_eq_adjoint,star_mul]; calc + _ = A.adjoint*(U.adjoint*U)*A := by noncomm_ring + _ = _ := by rw [hu,mul_one]] + +lemma linear_trace_holder {q : ℕ} (hq : 0 LinearMap.toMatrixOrthonormal v (A j)) + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/MomentBounds.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/MomentBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e7ef613240c9446ea606a7f26f050f14e9e8170 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/MomentBounds.lean @@ -0,0 +1,126 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.GridSweepPath + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +lemma conditionalOperator_apply {b h D : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) (x : RepSpace D) : + conditionalOperator H z ρ x = (conditionalNormalizer H z : ℂ)⁻¹ • + ∑ g : GridChoices bits, if hg : pathEvent H g then + (gridWeight bits z g : ℂ) • ρ (remainingPerm H g hg) x else 0 := by + classical + unfold conditionalOperator + simp only [LinearMap.coe_toContinuousLinearMap', LinearMap.smul_apply, LinearMap.sum_apply] + congr 1 + apply Finset.sum_congr rfl + intro g _ + split_ifs <;> rfl + +theorem conditionalOperator_norm_le_one {b h D : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + (hρ : IsUnitaryRep ρ) : ‖conditionalOperator H z ρ‖ ≤ 1 := by + classical + apply (conditionalOperator H z ρ).opNorm_le_bound (by norm_num) + intro x + rw [one_mul, conditionalOperator_apply, norm_smul] + have hZ := conditionalNormalizer_pos H hz hz1 + have hsum : ‖∑ g : GridChoices bits, if hg : pathEvent H g then + (gridWeight bits z g : ℂ) • ρ (remainingPerm H g hg) x else 0‖ ≤ + conditionalNormalizer H z * ‖x‖ := by + calc + _ ≤ ∑ g : GridChoices bits, ‖if hg : pathEvent H g then + (gridWeight bits z g : ℂ) • ρ (remainingPerm H g hg) x else 0‖ := norm_sum_le _ _ + _ = _ := by + unfold conditionalNormalizer + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro g _ + by_cases hg : pathEvent H g + · simp only [dite_eq_left hg, ite_eq_left hg, norm_smul, hρ (remainingPerm H g hg) x, + Complex.norm_real, Real.norm_eq_abs, abs_of_pos (gridWeight_pos bits hz hz1 g)] + · simp only [dite_eq_right hg, ite_eq_right hg, norm_zero, zero_mul] + calc + _ ≤ ‖(conditionalNormalizer H z : ℂ)⁻¹‖ * (conditionalNormalizer H z * ‖x‖) := + mul_le_mul_of_nonneg_left hsum (norm_nonneg _) + _ = ‖x‖ := by + rw [norm_inv, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hZ, + ← mul_assoc, inv_mul_cancel₀ hZ.ne', one_mul] + +theorem traceMoment_le_dimension {D : ℕ} (q : ℕ) (K : RepSpace D →L[ℂ] RepSpace D) + (hK : ‖K‖ ≤ 1) : traceMoment q K ≤ D := by + let B := ((ContinuousLinearMap.adjoint K) * K) ^ q + have hB : ‖B‖ ≤ 1 := by + cases q with + | zero => exact ContinuousLinearMap.norm_id_le + | succ q => + change ‖((ContinuousLinearMap.adjoint K) * K) ^ (q+1)‖ ≤ 1 + calc + _ ≤ ‖(ContinuousLinearMap.adjoint K) * K‖ ^ (q+1) := norm_pow_le' _ (by omega) + _ ≤ 1 ^ (q+1) := by + gcongr + calc + _ ≤ ‖ContinuousLinearMap.adjoint K‖ * ‖K‖ := norm_mul_le _ _ + _ = ‖K‖ * ‖K‖ := by rw [ContinuousLinearMap.adjoint.norm_map] + _ ≤ 1 * 1 := mul_le_mul hK hK (norm_nonneg _) (by norm_num) + _ = 1 := one_mul _ + _ = 1 := one_pow _ + unfold traceMoment + rw [LinearMap.trace_eq_sum_inner _ (EuclideanSpace.basisFun (Fin D) ℂ), Complex.re_sum] + calc + _ ≤ ∑ _i : Fin D, (1 : ℝ) := by + apply Finset.sum_le_sum + intro i _ + have hb : ‖EuclideanSpace.basisFun (Fin D) ℂ i‖ = 1 := + (EuclideanSpace.basisFun (Fin D) ℂ).orthonormal.1 i + calc + _ ≤ ‖inner ℂ (EuclideanSpace.basisFun (Fin D) ℂ i) + (B (EuclideanSpace.basisFun (Fin D) ℂ i))‖ := Complex.re_le_norm _ + _ ≤ ‖EuclideanSpace.basisFun (Fin D) ℂ i‖ * + ‖B (EuclideanSpace.basisFun (Fin D) ℂ i)‖ := norm_inner_le_norm _ _ + _ ≤ 1 := by + rw [hb, one_mul] + exact (B.le_opNorm _).trans (by rw [hb, mul_one]; exact hB) + _ = _ := by simp + +lemma logMoment_traceMoment_le_log_dimension {D : ℕ} (q : ℕ) + (K : RepSpace D →L[ℂ] RepSpace D) (hK : ‖K‖ ≤ 1) : + logMoment (traceMoment q K) ≤ (Real.log D : EReal) := by + have ht := traceMoment_le_dimension q K hK + unfold logMoment + cases D with + | zero => + have he : ENNReal.ofReal (traceMoment q K) = 0 := ENNReal.ofReal_eq_zero.mpr (by simpa only [Nat.cast_zero] using ht) + rw [he, ENNReal.log_zero] + exact bot_le + | succ D => + have hp : (0 : ℝ) < D+1 := by positivity + have he := ENNReal.log_le_log (ENNReal.ofReal_le_ofReal ht) + simpa only [Nat.cast_add, Nat.cast_one, ENNReal.log_ofReal_of_pos hp] using he + +theorem conditional_moment_of_automatic_regime {b h D : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) + (q : ℕ) (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) + (hρ : IsUnitaryRep ρ) + (ha : (1 + cExponent (gridSize bits)) * Real.log D ≤ + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H) : + logMoment (traceMoment q (conditionalOperator H z ρ)) ≤ + ((-cExponent (gridSize bits) * Real.log D + + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H : ℝ) : EReal) := by + apply (logMoment_traceMoment_le_log_dimension q _ + (conditionalOperator_norm_le_one H hz hz1 ρ hρ)).trans + exact_mod_cast (show Real.log D ≤ -cExponent (gridSize bits) * Real.log D + + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H by linarith) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/OccurrenceMoment.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/OccurrenceMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..74d781639b92e03a8f749770d4fdba60ec58eba5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/OccurrenceMoment.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.LightLineBound + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {L A B : Type*} [Fintype L] [Fintype A] [Fintype B] + +def occurrences (f : A → L) (l : L) : ℕ := Fintype.card {a : A // f a = l} + +lemma sum_occurrences (f : A → L) : ∑ l, occurrences f l = Fintype.card A := by + simpa only [occurrences,Finset.sum_const,Finset.card_univ,smul_eq_mul,mul_one] using + (Fintype.sum_fiberwise' f (fun _ : L => (1:ℕ))) + +lemma prod_occurrences {R : Type*} [CommMonoid R] (f : A → L) (x : L → R) : + (∏ a, x (f a)) = ∏ l, x l ^ occurrences f l := by + simpa only [occurrences,Finset.prod_const,Finset.card_univ] using + (Fintype.prod_fiberwise' f x).symm + +lemma occurrenceMoment_eq (m h : L → ℕ) (f : A → L) (g : B → L) : + multilineMoment m h ((∏ a, ((MvPolynomial.X (f a) : MvPolynomial L ℝ)-1)) * + ∏ b, MvPolynomial.X (g b)) = + ∏ l, centeredLineMoment (m l) (h l) (occurrences f l) (occurrences g l) := by + rw [prod_occurrences (R := MvPolynomial L ℝ) f (fun l => MvPolynomial.X l-1), prod_occurrences (R := MvPolynomial L ℝ) g MvPolynomial.X, + ← Finset.prod_mul_distrib] + calc + _ = multilineMoment m h (∏ l, (MvPolynomial.X l : MvPolynomial L ℝ)^occurrences g l * + (MvPolynomial.X l-1)^occurrences f l) := + congrArg (multilineMoment m h) (Finset.prod_congr rfl (fun l _ => mul_comm _ _)) + _ = _ := multilineMoment_centered m h _ _ + +theorem occurrenceMoment_light (m h : L → ℕ) (f : A → L) (g : B → L) + {η : ℝ} (hm : ∀ l, 0 < m l) (hη0 : 0 ≤ η) (hη : η ≤ 1/4) + (hl : ∀ l, (h l:ℝ)+occurrences f l+occurrences g l ≤ m l*η) : + 0 ≤ multilineMoment m h ((∏ a, ((MvPolynomial.X (f a) : MvPolynomial L ℝ)-1)) * + ∏ b, MvPolynomial.X (g b)) ∧ + multilineMoment m h ((∏ a, ((MvPolynomial.X (f a) : MvPolynomial L ℝ)-1)) * + ∏ b, MvPolynomial.X (g b)) ≤ + 2^(Fintype.card B) * (4*Real.sqrt η)^(Fintype.card A) := by + rw [occurrenceMoment_eq] + have hb (l : L) := centeredLineMoment_light (u := occurrences f l) (v := occurrences g l) + (hm l) hη0 hη (hl l) + refine ⟨Finset.prod_nonneg (fun l _ => (hb l).1), ?_⟩ + calc + _ ≤ ∏ l, (2:ℝ)^occurrences g l * (4*Real.sqrt η)^occurrences f l := + Finset.prod_le_prod₀ (fun l _ => (hb l).1) (fun l _ => (hb l).2) + _ = _ := by + rw [Finset.prod_mul_distrib,Finset.prod_pow_eq_pow_sum,Finset.prod_pow_eq_pow_sum, + sum_occurrences,sum_occurrences] + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/OneCard.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/OneCard.lean new file mode 100644 index 0000000000000000000000000000000000000000..58f82a6d2e9b61c1f49fbb0cfac8c63a265fe89b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/OneCard.lean @@ -0,0 +1,205 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.UniformFiniteProbability + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +lemma coordinateLayer_apply_at (d : ℕ) (j : Fin d) + (c : ({i : Fin d // i≠j} → Bool) → Bool) (x : Slot d) : + coordinateLayer d j c x j = (x j ^^ c (fun i => x i)) := by + simp [coordinateLayer,Equiv.piSplitAt_symm_apply] + +lemma coordinateLayer_apply_other (d : ℕ) (j i : Fin d) (hi : i≠j) + (c : ({i : Fin d // i≠j} → Bool) → Bool) (x : Slot d) : + coordinateLayer d j c x i = x i := by + simp [coordinateLayer,Equiv.piSplitAt_symm_apply,hi] + +def binaryPosition {d : ℕ} (x y : Slot d) (t : Fin (d+1)) : Slot d := + fun i => if i.val coordinateLayer d j (c j))).take t.val).reverse.prod + +@[simp] lemma binaryPartialSweep_zero (d : ℕ) (c : SweepCoins d) : binaryPartialSweep d c 0=1 := by + simp [binaryPartialSweep] + +@[simp] lemma binaryPartialSweep_last (d : ℕ) (c : SweepCoins d) : + binaryPartialSweep d c (Fin.last d)=binarySweep d c := by + unfold binaryPartialSweep binarySweep + rw [List.take_of_length_le (by simp)] + +lemma binaryPartialSweep_succ (d : ℕ) (c : SweepCoins d) (j : Fin d) : + binaryPartialSweep d c j.succ=coordinateLayer d j (c j)*binaryPartialSweep d c j.castSucc := by + unfold binaryPartialSweep + simp only [Fin.val_succ,Fin.val_castSucc] + rw [List.take_succ_eq_append_getElem (by simp)] + simp only [List.reverse_append,List.reverse_singleton,List.prod_append, + List.prod_singleton,List.getElem_ofFn,Fin.eta] + +lemma singleCoordinate_trajectory {d : ℕ} {β : Fin d → Type*} + (x : Fin (d+1) → ∀i, β i) + (hmov : ∀j i : Fin d, i≠j → x j.succ i=x j.castSucc i) + (t : Fin (d+1)) (i : Fin d) : + x t i = if i.val intro _; rfl + | succ j ih => + intro ht + have hij : i≠j := by intro h; subst j; simp at ht + rw [hmov j i hij,ih] + exact Nat.le_trans (Nat.le_succ j.val) ht + have hafter : ∀t : Fin (d+1), i.val intro _; rfl + | cast j ih => + intro ht + have hij : i≠j := by intro h; subst j; simp at ht + rw [← hmov j i hij,ih] + exact Nat.lt_succ_of_lt ht + split_ifs with h + · exact hafter t h + · exact hbefore t (Nat.le_of_not_lt h) + +lemma binarySweep_endpoint_iff (d : ℕ) (c : SweepCoins d) (x y : Slot d) : + binarySweep d c x=y ↔ ∀j, c j (fun i => binaryPosition x y j.castSucc i)= (x j ^^ y j) := by + constructor + · intro he j + have hp (t : Fin (d+1)) : binaryPartialSweep d c t x=binaryPosition x y t := by + funext i + rw [singleCoordinate_trajectory (fun t => binaryPartialSweep d c t x) + (by intro j i hi; rw [binaryPartialSweep_succ,Equiv.Perm.mul_apply, + coordinateLayer_apply_other d j i hi])] + simp only [binaryPartialSweep_last,binaryPartialSweep_zero,Equiv.Perm.one_apply,he,binaryPosition] + have hj := congrFun (hp j.succ) j + rw [binaryPartialSweep_succ,Equiv.Perm.mul_apply,hp j.castSucc,coordinateLayer_apply_at] at hj + simp only [binaryPosition,Fin.val_succ,Fin.val_castSucc,lt_self_iff_false,ite_false, + Nat.lt_succ_self,ite_true] at hj + cases hx : x j <;> cases hy : y j <;> cases hc : c j (fun i => binaryPosition x y j.castSucc i) <;> + simp_all [binaryPosition] + · intro he + have hp (t : Fin (d+1)) : binaryPartialSweep d c t x=binaryPosition x y t := by + induction t using Fin.induction with + | zero => ext i; simp [binaryPosition] + | succ j ih => + rw [binaryPartialSweep_succ,Equiv.Perm.mul_apply,ih] + funext i + by_cases hi : i=j + · subst i + rw [coordinateLayer_apply_at,he j] + simp [binaryPosition] + · rw [coordinateLayer_apply_other d j i hi] + dsimp [binaryPosition] + congr 1 + exact propext (by have hij : i.val≠j.val := fun h => hi (Fin.ext h); omega) + have hy : binaryPosition x y (Fin.last d)=y := by ext i; simp [binaryPosition] + simpa only [binaryPartialSweep_last,hy] using hp (Fin.last d) + +lemma uniform_coin_evaluation {I : Type*} [Fintype I] [DecidableEq I] (i : I) (b : Bool) : + (∑c : I → Bool, if c i=b then (Fintype.card (I → Bool):ℝ)⁻¹ else 0) = (1/2:ℝ) := by + have h := Sparse.uniform_projection_probability (Equiv.piSplitAt i (fun _ : I => Bool)) b + simpa only [Sparse.finiteProbability,Sparse.uniformWeight,Equiv.piSplitAt_apply, + Fintype.card_bool,Nat.cast_ofNat,one_div,mul_ite,mul_one,mul_zero] using h + +lemma uniform_independent_event {J : Type*} [Fintype J] [DecidableEq J] {X : J → Type*} + [∀j, Fintype (X j)] (P : ∀j, X j → Prop) : + (∑x : ∀j, X j, if ∀j, P j (x j) then (Fintype.card (∀j, X j):ℝ)⁻¹ else 0) = + ∏j, ∑a : X j, if P j a then (Fintype.card (X j):ℝ)⁻¹ else 0 := by + have h := independent_event_weight (fun j (_ : X j) => (Fintype.card (X j):ℝ)⁻¹) P + have hc : (∏j, (Fintype.card (X j):ℝ)⁻¹) = (Fintype.card (∀j, X j):ℝ)⁻¹ := by + rw [Finset.prod_inv_distrib,← Nat.cast_prod,Fintype.card_pi] + refine Eq.trans ?_ h + apply Finset.sum_congr + · ext x; simp only [Finset.mem_univ] + intro x _ + split_ifs <;> simp only [hc] + +lemma uniform_pi_coin_evaluation {J : Type*} [Fintype J] [DecidableEq J] {I : J → Type*} + [∀j,Fintype (I j)] [∀j,DecidableEq (I j)] (i : ∀j,I j) (b : J → Bool) : + (∑c : ∀j,I j → Bool, if ∀j,c j (i j)=b j then + (Fintype.card (∀j,I j → Bool):ℝ)⁻¹ else 0) = (1/2:ℝ)^Fintype.card J := by + have h := uniform_independent_event (X:=fun j => I j → Bool) (fun j a => a (i j)=b j) + refine Eq.trans ?_ (Eq.trans h ?_) + · apply Finset.sum_congr rfl + intro c _ + by_cases hc : ∀j,c j (i j)=b j <;> simp [hc] + · calc + _ = ∏j, (1/2:ℝ) := by + apply Finset.prod_congr rfl + intro j _ + refine Eq.trans ?_ (uniform_coin_evaluation (i j) (b j)) + apply Finset.sum_congr rfl + intro c _ + by_cases hc : c (i j)=b j <;> simp [hc] + _ = _ := by simp only [Finset.prod_const,Finset.card_univ] + +lemma binary_one_card (d : ℕ) (x y : Slot d) : + ∑σ, binaryLaw d σ * (if σ x=y then (1:ℝ) else 0) = (Fintype.card (Slot d):ℝ)⁻¹ := by + rw [binaryLaw,finiteLaw_expectation] + simp_rw [binarySweep_endpoint_iff] + rw [Finset.mul_sum] + simp only [mul_ite,mul_one,mul_zero] + have h := uniform_pi_coin_evaluation (J:=Fin d) + (I:=fun j => {i : Fin d // i≠j} → Bool) + (fun j i => binaryPosition x y j.castSucc i) (fun j => (x j ^^ y j)) + have hc : (1/2:ℝ)^Fintype.card (Fin d) = (Fintype.card (Slot d):ℝ)⁻¹ := by + simp [Slot,inv_pow,one_div] + refine Eq.trans ?_ (h.trans hc) + apply Finset.sum_congr + · ext c; simp only [Finset.mem_univ] + intro c _ + by_cases hh : ∀j, c j (fun i => binaryPosition x y j.castSucc i)= (x j ^^ y j) + · simp only [hh] + · simp only [hh,ite_false] + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +lemma uniform_one_card {X : Type*} [Fintype X] [DecidableEq X] (x y : X) : + (∑σ : Equiv.Perm X, uniformLaw (Equiv.Perm X) σ * (if σ x=y then (1:ℝ) else 0)) = + (Fintype.card X:ℝ)⁻¹ := by + let A : Unit ↪ X := ⟨fun _ => x,fun _ _ _ => Subsingleton.elim _ _⟩ + let B : Unit ↪ X := ⟨fun _ => y,fun _ _ _ => Subsingleton.elim _ _⟩ + have h := assignmentWeight_uniform A B + have he (σ : Equiv.Perm X) : Assigns A B σ ↔ σ x=y := by + change (∀u : Unit, σ x=y) ↔ σ x=y + simp only [forall_const] + simp only [assignmentWeight,he,uniformLaw,mul_ite,mul_one,mul_zero, + Fintype.card_unique,Nat.descFactorial_one] at h ⊢ + refine Eq.trans ?_ h + apply Finset.sum_congr + · ext σ; simp only [Finset.mem_univ] + intro σ _ + split_ifs <;> simp only [Fintype.card_perm] + +lemma line_one_card (d : ℕ) (z : ℝ) (x y : Slot d) : + (∑σ, lineLaw d z σ * (if σ x=y then (1:ℝ) else 0)) = (Fintype.card (Slot d):ℝ)⁻¹ := by + simp only [lineLaw,add_mul,mul_assoc,Finset.sum_add_distrib,← Finset.mul_sum] + rw [uniform_one_card (X:=Slot d) x y,binary_one_card d x y] + ring + +lemma line_one_card_ite (d : ℕ) (z : ℝ) (x y : Slot d) : + (∑σ, if σ x=y then lineLaw d z σ else 0) = (Fintype.card (Slot d):ℝ)⁻¹ := by + simpa only [mul_ite,mul_one,mul_zero] using line_one_card d z x y + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/PiCentrality.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/PiCentrality.lean new file mode 100644 index 0000000000000000000000000000000000000000..100daa844e5f092bdf9a16e10645019edcd909a5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/PiCentrality.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.PiTensorMatrices +import OAI.Probability.BinarySweep.TensorBounds.SignedConjugation + +namespace OAI + +noncomputable section +open scoped BigOperators Classical Kronecker +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [DecidableEq I] + {A : I → Type*} [∀ i, Fintype (A i)] [∀ i, DecidableEq (A i)] + +omit [∀ i, Fintype (A i)] [∀ i, DecidableEq (A i)] in +lemma piTensorMatrices_split (i : I) (P : ∀i, Matrix (A i) (A i) ℂ) : + piTensorMatrices P = (P i ⊗ₖ piTensorMatrices (fun j : {j // j≠i} => P j)).submatrix + (Equiv.piSplitAt i A) (Equiv.piSplitAt i A) := by + ext x y + change (∏j, P j (x j) (y j)) = P i (x i) (y i) * ∏j : {j // j≠i}, P j (x j) (y j) + rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ i)] + congr 1 + exact Finset.prod_subtype (Finset.univ.erase i) (by intro j; simp [ne_comm]) _ + +def siteMatrix (i : I) (P : Matrix (A i) (A i) ℂ) : Matrix (∀i,A i) (∀i,A i) ℂ := + (P ⊗ₖ (1 : Matrix (∀j : {j // j≠i}, A j) (∀j : {j // j≠i}, A j) ℂ)).submatrix + (Equiv.piSplitAt i A) (Equiv.piSplitAt i A) + +omit [∀ i, Fintype (A i)] in +lemma siteMatrix_eq_mask (i : I) (P : ∀i, Matrix (A i) (A i) ℂ) : + siteMatrix i (P i) = piTensorMatrices (fun j => if j=i then P j else 1) := by + rw [piTensorMatrices_split i] + simp only + have he : piTensorMatrices (fun j : {j // j≠i} => if j.val=i then P j else 1)=1 := by + have hh : (fun j : {j // j≠i} => if j.val=i then P j else 1) = (fun j : {j // j≠i} => (1 : Matrix (A j) (A j) ℂ)) := by + funext j + exact ite_eq_right j.property + rw [hh] + exact piTensorMatrices_one + rw [he] + rfl + +lemma siteMatrix_centrality {G : Type*} (i : I) (T : G → Matrix (A i) (A i) ℂ) + (P : Matrix (A i) (A i) ℂ) + (hP : ∀ X : Matrix (A i) (A i) ℂ, (∀g, X*T g=T g*X) → X*P=P*X) + (M : Matrix (∀i,A i) (∀i,A i) ℂ) (hM : ∀g, M*siteMatrix i (T g)=siteMatrix i (T g)*M) : + M*siteMatrix i P=siteMatrix i P*M := by + let e := Equiv.piSplitAt i A + let E := Matrix.reindexAlgEquiv ℂ ℂ e + have he (Q : Matrix (A i) (A i) ℂ) : E (siteMatrix i Q)=Q ⊗ₖ 1 := by + ext x y + change (Q ⊗ₖ 1) (e (e.symm x)) (e (e.symm y))=(Q ⊗ₖ 1) x y + rw [Equiv.apply_symm_apply,Equiv.apply_symm_apply] + have hc : ∀g, E M*(T g ⊗ₖ 1)=(T g ⊗ₖ 1)*E M := by + intro g + simpa only [map_mul,he] using congrArg E (hM g) + apply E.injective + simp only [map_mul,he] + exact kronecker_centrality T P hP (E M) hc + +theorem piTensor_centrality {G : I → Type*} (T : ∀ i, G i → Matrix (A i) (A i) ℂ) + (P : ∀i, Matrix (A i) (A i) ℂ) + (hP : ∀i, ∀X : Matrix (A i) (A i) ℂ, (∀g, X*T i g=T i g*X) → X*P i=P i*X) + (M : Matrix (∀i,A i) (∀i,A i) ℂ) + (hM : ∀i g, M*siteMatrix i (T i g)=siteMatrix i (T i g)*M) : + M*piTensorMatrices P=piTensorMatrices P*M := by + have hi (i : I) : M*siteMatrix i (P i)=siteMatrix i (P i)*M := + siteMatrix_centrality i (T i) (P i) (hP i) M (hM i) + have hh (s : Finset I) : M*piTensorMatrices (fun i => if i∈s then P i else 1)= + piTensorMatrices (fun i => if i∈s then P i else 1)*M := by + induction s using Finset.induction_on with + | empty => simp only [Finset.notMem_empty,ite_false,piTensorMatrices_one,mul_one,one_mul] + | @insert i s his ih => + have he : piTensorMatrices (fun j => if j∈insert i s then P j else 1)= + siteMatrix i (P i)*piTensorMatrices (fun j => if j∈s then P j else 1) := by + rw [siteMatrix_eq_mask,piTensorMatrices_mul] + congr 1 + funext j + by_cases hji : j=i + · subst j; simp [his] + · simp [hji,Finset.mem_insert] + rw [he,← mul_assoc,hi,mul_assoc,ih,← mul_assoc] + simpa only [Finset.mem_univ,ite_true] using hh Finset.univ + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/QuantitativeMoment.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/QuantitativeMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..0970f84749fde4c48d806496d15711ce91138d28 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/QuantitativeMoment.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.Basic + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +lemma traceMoment_le_dimension_mul_pow {D q : ℕ} (hq : 0 < q) + (K : RepSpace D →L[ℂ] RepSpace D) {η : ℝ} (hη : 0 ≤ η) (hK : ‖K‖ ≤ η) : + traceMoment q K ≤ D * η ^ (2*q) := by + let B := ((ContinuousLinearMap.adjoint K) * K) ^ q + have hKK : ‖(ContinuousLinearMap.adjoint K) * K‖ ≤ η^2 := by + calc + _ ≤ ‖ContinuousLinearMap.adjoint K‖ * ‖K‖ := norm_mul_le _ _ + _ = ‖K‖ * ‖K‖ := by rw [ContinuousLinearMap.adjoint.norm_map] + _ ≤ η * η := mul_le_mul hK hK (norm_nonneg _) hη + _ = _ := (sq η).symm + have hB : ‖B‖ ≤ η ^ (2*q) := by + calc + _ ≤ ‖(ContinuousLinearMap.adjoint K) * K‖^q := norm_pow_le' _ hq + _ ≤ (η^2)^q := pow_le_pow_left₀ (norm_nonneg _) hKK q + _ = _ := (pow_mul η 2 q).symm + unfold traceMoment + rw [LinearMap.trace_eq_sum_inner _ (EuclideanSpace.basisFun (Fin D) ℂ), Complex.re_sum] + calc + _ ≤ ∑ _i : Fin D, η^(2*q) := by + apply Finset.sum_le_sum + intro i _ + have hb : ‖EuclideanSpace.basisFun (Fin D) ℂ i‖ = 1 := + (EuclideanSpace.basisFun (Fin D) ℂ).orthonormal.1 i + calc + _ ≤ ‖inner ℂ (EuclideanSpace.basisFun (Fin D) ℂ i) + (B (EuclideanSpace.basisFun (Fin D) ℂ i))‖ := Complex.re_le_norm _ + _ ≤ ‖EuclideanSpace.basisFun (Fin D) ℂ i‖ * + ‖B (EuclideanSpace.basisFun (Fin D) ℂ i)‖ := norm_inner_le_norm _ _ + _ ≤ η^(2*q) := by + rw [hb, one_mul] + exact (B.le_opNorm _).trans (by rw [hb, mul_one]; exact hB) + _ = _ := by simp + +lemma logMoment_le_neg_log_dimension {D q : ℕ} (hD : 0 < D) (hq : 0 < q) + (K : RepSpace D →L[ℂ] RepSpace D) (hK : ‖K‖ ≤ (D : ℝ)⁻¹) : + logMoment (traceMoment q K) ≤ (-Real.log D : EReal) := by + have hD0 : (0 : ℝ) < D := by exact_mod_cast hD + have hD1 : (1 : ℝ) ≤ D := by exact_mod_cast hD + have hi0 : 0 ≤ (D : ℝ)⁻¹ := inv_nonneg.mpr hD0.le + have hi1 : (D : ℝ)⁻¹ ≤ 1 := (inv_le_one₀ hD0).mpr hD1 + have hm := traceMoment_le_dimension_mul_pow hq K hi0 hK + have ht : traceMoment q K ≤ (D : ℝ)⁻¹ := by + calc + _ ≤ D * ((D : ℝ)⁻¹)^(2*q) := hm + _ ≤ D * ((D : ℝ)⁻¹)^2 := by + exact mul_le_mul_of_nonneg_left (pow_le_pow_of_le_one hi0 hi1 (by omega)) hD0.le + _ = _ := by field_simp + have he := ENNReal.log_le_log (ENNReal.ofReal_le_ofReal ht) + simpa only [logMoment, ENNReal.log_ofReal_of_pos (inv_pos.mpr hD0), Real.log_inv, EReal.coe_neg] using he + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/RemainingSign.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/RemainingSign.lean new file mode 100644 index 0000000000000000000000000000000000000000..916c20f34fd873b5b101fd98bfa7906d7e79bc74 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/RemainingSign.lean @@ -0,0 +1,72 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.Placement + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma realSign_ne_zero {X : Type*} [Fintype X] [DecidableEq X] (g : Equiv.Perm X) : + realSign g≠0 := by + simp [realSign] + +lemma realSign_inv {X : Type*} [Fintype X] [DecidableEq X] (f : Equiv.Perm X) : + realSign f⁻¹=(realSign f)⁻¹ := by + have hm : realSign f⁻¹*realSign f=1 := by rw [←map_mul,inv_mul_cancel,map_one] + calc + realSign f⁻¹ = (realSign f⁻¹*realSign f)*(realSign f)⁻¹ := by + rw [mul_assoc,mul_inv_cancel₀ (realSign_ne_zero f),mul_one] + _ = _ := by rw [hm,one_mul] + +lemma remaining_relative_realSign (g g₀ : ConditionalChoices H) : + realSign ((remainingPerm H g₀.val g₀.property)⁻¹*remainingPerm H g.val g.property)= + realSign ((gridSweep bits g₀.val)⁻¹*gridSweep bits g.val) := by + let f := (gridSweep bits g₀.val)⁻¹*gridSweep bits g.val + have hfix (i : Fin h) : f (H.position 0 i)=H.position 0 i := by + change (gridSweep bits g₀.val).symm (gridSweep bits g.val (H.position 0 i))=_ + rw [gridSweep_path H g.val g.property,←gridSweep_path H g₀.val g₀.property, + Equiv.symm_apply_apply] + have hp (x : GridSlot bits) : f x∉Set.range (H.position 0) ↔ x∉Set.range (H.position 0) := by + constructor + · intro hx hi; obtain ⟨i,rfl⟩ := hi; exact hx ⟨i,hfix i |>.symm⟩ + · intro hx hi; obtain ⟨i,hi⟩ := hi + exact hx ⟨i,f.injective ((hfix i).trans hi)⟩ + have hs := Equiv.Perm.sign_subtypePerm f (p := fun x => x∉Set.range (H.position 0)) hp (by + intro x hx hi; obtain ⟨i,rfl⟩ := hi; exact hx (hfix i)) + have he : Equiv.Perm.subtypePerm f hp = + (remainingPerm H g₀.val g₀.property)⁻¹*remainingPerm H g.val g.property := by + apply Equiv.ext + intro x + apply Subtype.ext + change f x.val = + (gridSweep bits g₀.val).symm + ((freeIdentification H) ((freeIdentification H).symm + ((remainingBijection H g.val g.property) x))).val + rw [Equiv.apply_symm_apply] + rfl + rw [he] at hs + convert congrArg (fun u : ℤˣ => ((u:ℤ):ℝ)) hs using 1 + · unfold realSign; dsimp; congr 3 + congr 1; exact Subsingleton.elim _ _ + · rfl + +theorem remaining_realSign_factor (g g₀ : ConditionalChoices H) : + realSign (remainingPerm H g.val g.property) = + (realSign (remainingPerm H g₀.val g₀.property)/realSign (gridSweep bits g₀.val))* + realSign (gridSweep bits g.val) := by + have he := remaining_relative_realSign H g g₀ + simp only [map_mul,realSign_inv] at he + have h₀ := realSign_ne_zero (remainingPerm H g₀.val g₀.property) + have h₁ := realSign_ne_zero (gridSweep bits g₀.val) + field_simp [h₀,h₁] at he ⊢ + nlinarith [he] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/SampleMoment.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/SampleMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec7eee862d3153c140d29482353cae7a8b94c3f6 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/SampleMoment.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicProjectionMoment +import OAI.Probability.BinarySweep.FiniteLaws.LinearEvenMoment +import OAI.Probability.BinarySweep.FiniteLaws.IndependentPush + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation TraceHolder Density + +lemma matrixMoment_linear {I : Type*} [Fintype I] [DecidableEq I] + (q : ℕ) (M : Matrix I I ℂ) : matrixMoment q M=evenMoment q M.toEuclideanLin := by + unfold matrixMoment evenMoment + rw [← trace_toEuclideanLinear] + simp only [euclidean_pow,Matrix.toLpLin_mul_same,←Module.End.mul_eq_comp, + Matrix.star_eq_conjTranspose,Matrix.toEuclideanLin_conjTranspose_eq_adjoint] + +namespace Signed +variable {A X : Type*} [Fintype A] [DecidableEq A] [Fintype X] {N : ℕ} + {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +def sampleMatrix (p : A → Bool) (w : X → ℂ) (f : X → Equiv.Perm (Fin N)) := + ∑x, w x • actionMatrix p (f x) + +lemma sampleMatrix_linear (p : A → Bool) (w : X → ℂ) (f : X → Equiv.Perm (Fin N)) : + (sampleMatrix p w f).toEuclideanLin=∑x, w x • hilbertTensorRep p N (f x) := by + simp only [sampleMatrix,map_sum,map_smul,actionMatrix_linear] + +lemma sampleMatrix_average (p : A → Bool) (w : X → ℂ) (f : X → Equiv.Perm (Fin N)) : + sampleMatrix p w f=signedAverage p (finitePush w f) := by + exact (finitePush_expectation w f (actionMatrix p)).symm + +omit [FiniteDimensional ℂ V] in +lemma sampleMatrix_commute (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin N)) V) (w : X → ℂ) (f : X → Equiv.Perm (Fin N)) : + isotypicProjection p ρ*sampleMatrix p w f=sampleMatrix p w f*isotypicProjection p ρ := by + rw [sampleMatrix_average]; exact isotypicProjection_commutes_average p ρ _ + +lemma sample_projected_moment (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin N)) V) [ρ.IsIrreducible] + (hρ : ∀g v, ‖ρ g v‖=‖v‖) (w : X → ℂ) (f : X → Equiv.Perm (Fin N)) {q : ℕ} (hq : 0 + ⟨(a.2.val+p,a.1.val), μ.up_left_mem le_rfl + (show a.1.val ≤ p from Nat.le_of_lt_succ a.1.isLt) + (by simpa using (mem_southeast μ p _).mp (YoungDiagram.mem_iff_lt_colLen.mpr a.2.isLt))⟩ + have hf : Function.Injective f := by + intro a b h + have h1 := congrArg (fun x : Cell μ => x.val.1) h + have h2 := congrArg (fun x : Cell μ => x.val.2) h + apply Prod.ext (Fin.ext h2) + apply Fin.ext + change a.2.val+p = b.2.val+p at h1 + exact Nat.add_right_cancel h1 + simpa only [Fintype.card_prod,Fintype.card_fin] using Fintype.card_le_of_injective f hf + +lemma southeast_width_mul_le_card : + (p+1)*(southeast μ p).rowLen 0 ≤ Fintype.card (Cell μ) := by + let f : Fin (p+1) × Fin ((southeast μ p).rowLen 0) → Cell μ := fun a => + ⟨(a.1.val,a.2.val+p), μ.up_left_mem + (show a.1.val ≤ p from Nat.le_of_lt_succ a.1.isLt) le_rfl + (by simpa using (mem_southeast μ p _).mp (YoungDiagram.mem_iff_lt_rowLen.mpr a.2.isLt))⟩ + have hf : Function.Injective f := by + intro a b h + have h1 := congrArg (fun x : Cell μ => x.val.1) h + have h2 := congrArg (fun x : Cell μ => x.val.2) h + apply Prod.ext (Fin.ext h1) + apply Fin.ext + change a.2.val+p = b.2.val+p at h2 + exact Nat.add_right_cancel h2 + simpa only [Fintype.card_prod,Fintype.card_fin] using Fintype.card_le_of_injective f hf + +lemma southeast_diagonal_bound (x : Cell (southeast μ p)) : + diagonal (southeast μ p) x < 2*(Fintype.card (Cell μ)/(p+1)) := by + have hh : (southeast μ p).colLen 0 ≤ Fintype.card (Cell μ)/(p+1) := (Nat.le_div_iff_mul_le (show 0 if h : P x then f x h else 0) + rw [Fintype.sum_sum_type] at he + rw [← he] + simp only [Equiv.Set.sumCompl_apply_inl, Equiv.Set.sumCompl_apply_inr] + have hp : (∑ x : {x // P x}, if h : P x.val then f x.val h else 0) = + ∑ x : {x // P x}, f x.val x.property := by + apply Finset.sum_congr rfl + intro x _ + exact dite_eq_left x.property + have hn : (∑ x : {x // ¬P x}, if h : P x.val then f x.val h else 0) = 0 := by + apply Finset.sum_eq_zero + intro x _ + exact dite_eq_right x.property + exact (congrArg₂ (· + ·) hp hn).trans (add_zero _) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/FiniteLaws/UniformFiniteProbability.lean b/lean/OAI/Probability/BinarySweep/FiniteLaws/UniformFiniteProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d624fdd120c8fd06419bf634ee4c64231c5b61d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/FiniteLaws/UniformFiniteProbability.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.Trajectory +import OAI.Probability.BinarySweep.Trajectories.SharingProbability + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {Ω V W : Type*} [Fintype Ω] [Fintype V] [Fintype W] + + def uniformWeight (_u : Ω) : ℝ := 1 / Fintype.card Ω + +lemma uniformWeight_nonneg (u : Ω) : 0 ≤ uniformWeight u := by + unfold uniformWeight; positivity + +lemma uniformWeight_sum [Nonempty Ω] : ∑ u : Ω, uniformWeight u = 1 := by + simp [uniformWeight,ne_of_gt (Fintype.card_pos : 0 < Fintype.card Ω)] + +def finiteProbability (p : Ω → ℝ) (E : Ω → Prop) : ℝ := + ∑ u, p u * (if E u then 1 else 0) + +lemma finiteProbability_union {T : Type*} [Fintype T] + (p : Ω → ℝ) (hp : ∀ u, 0 ≤ p u) (E : T → Ω → Prop) : + finiteProbability p (fun u => ∃ t, E t u) ≤ ∑ t, finiteProbability p (E t) := by + unfold finiteProbability + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro u _ + rw [← Finset.mul_sum] + apply mul_le_mul_of_nonneg_left _ (hp u) + by_cases h : ∃ t, E t u + · obtain ⟨t,ht⟩ := h + rw [ite_eq_left ⟨t,ht⟩] + exact (show (1:ℝ) ≤ if E t u then 1 else 0 by simp [ht]).trans + (Finset.single_le_sum (f:=fun t:T => if E t u then (1:ℝ) else 0) + (fun t _ => by split_ifs <;> norm_num) (Finset.mem_univ t)) + · rw [ite_eq_right h] + exact Finset.sum_nonneg (fun t _ => by split_ifs <;> norm_num) + +lemma uniform_projection_probability [Nonempty W] (e : Ω ≃ V × W) (v : V) : + finiteProbability uniformWeight (fun u => (e u).1 = v) = 1 / Fintype.card V := by + classical + unfold finiteProbability uniformWeight + rw [← e.symm.sum_comp] + simp only [Equiv.apply_symm_apply] + rw [Fintype.sum_prod_type,Fintype.card_congr e,Fintype.card_prod] + have hW : (Fintype.card W : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (ne_of_gt Fintype.card_pos) + simp [Nat.cast_mul] + +end BinaryCoordinateSweeps.Sparse + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +namespace Sparse +variable {b : ℕ} {bits : Fin b → ℕ} + +def independentPosition (z : GridSlot bits × GridSlot bits) (t : Fin (b+1)) : GridSlot bits := + fun i => if i.val h (Fin.ext he) + simp only [independentPosition,Fin.val_succ,Fin.val_castSucc] + have he : i.val funext i <;> dsimp [independentPosition] <;> split <;> rfl + right_inv z := by + apply Prod.ext <;> funext i <;> dsimp [independentPosition] <;> split <;> rfl + +lemma independentPosition_uniform (t : Fin (b+1)) (v : GridSlot bits) : + finiteProbability uniformWeight (fun z : GridSlot bits × GridSlot bits => + independentPosition z t=v)=1/gridSize bits := by + have hh := uniform_projection_probability (endpointSwap (bits:=bits) t) v + convert hh using 1 <;> simp only [endpointSwap,Equiv.coe_fn_mk,card_gridSlot] + +def shareVertex (z w : GridSlot bits × GridSlot bits) : Prop := + ∃t : Fin (b+1), independentPosition z t=independentPosition w t + +lemma shareVertex_symmetric : + ∀ ⦃first second⦄, shareVertex (bits:=bits) first second → shareVertex second first := by + rintro z w ⟨t,ht⟩ + exact ⟨t,ht.symm⟩ + +lemma shareVertex_probability (w : GridSlot bits × GridSlot bits) : + finiteProbability uniformWeight (fun z => shareVertex (bits:=bits) z w) ≤ + (b+1:ℝ)/gridSize bits := by + have hh := finiteProbability_union uniformWeight uniformWeight_nonneg + (fun (t : Fin (b+1)) (z : GridSlot bits × GridSlot bits) => + independentPosition z t=independentPosition w t) + simp_rw [independentPosition_uniform] at hh + simpa only [shareVertex,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + Nat.cast_add,Nat.cast_one,mul_one_div] using hh + +theorem independent_trajectory_sharing {k h : ℕ} + (roots : Fin h → GridSlot bits × GridSlot bits) (w : ℕ) + (hs : ((k+h:ℕ):ℝ)*((b+1:ℝ)/gridSize bits) ≤ 1) : + productProbability uniformWeight (fun z : Fin k → GridSlot bits × GridSlot bits => + w ≤ (incidentSet shareVertex roots z).card) ≤ + (2:ℝ)^k * (((k+h:ℕ):ℝ)*((b+1:ℝ)/gridSize bits))^((w+1)/2) := by + have hh := sharing_probability_le (I:=Fin k) uniformWeight uniformWeight_nonneg uniformWeight_sum + shareVertex shareVertex_symmetric roots ((b+1:ℝ)/gridSize bits) (by positivity) + (fun v => shareVertex_probability v) w (by simpa only [Fintype.card_fin] using hs) + simpa only [Fintype.card_fin] using hh + +def endpointLineEquiv (j : Fin b) : + (GridSlot bits × GridSlot bits) ≃ + GridOutside bits j × (Slot (bits j) × GridSlot bits) := + (endpointSwap j.castSucc).trans + (((Equiv.piSplitAt j (fun i : Fin b => Slot (bits i))).trans (Equiv.prodComm _ _)).prodCongr + (Equiv.refl _)) |>.trans (Equiv.prodAssoc _ _ _) + +lemma independent_line_uniform (j : Fin b) (y : GridOutside bits j) : + finiteProbability uniformWeight (fun z : GridSlot bits × GridSlot bits => + (fun i : {i : Fin b // i≠j} => independentPosition z j.castSucc i)=y)= + 1/Fintype.card (GridOutside bits j) := by + exact uniform_projection_probability (endpointLineEquiv j) y + +lemma finiteProbability_mem {Ω L : Type*} [Fintype Ω] [Fintype L] [DecidableEq L] + (p : Ω → ℝ) (f : Ω → L) (S : Finset L) : + finiteProbability p (fun u => f u∈S)=∑l∈S, finiteProbability p (fun u => f u=l) := by + unfold finiteProbability + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u _ + rw [← Finset.mul_sum] + congr 1 + simp only [eq_comm,Finset.sum_ite_eq'] + by_cases h : f u∈S <;> simp only [h,ite_true,ite_false] + +lemma independent_line_set_uniform (j : Fin b) (S : Finset (GridOutside bits j)) : + finiteProbability uniformWeight (fun z : GridSlot bits × GridSlot bits => + (fun i : {i : Fin b // i≠j} => independentPosition z j.castSucc i)∈S)= + S.card/Fintype.card (GridOutside bits j) := by + rw [finiteProbability_mem] + simp_rw [independent_line_uniform] + simp [div_eq_mul_inv] + +end Sparse +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/BalancedGrid.lean b/lean/OAI/Probability/BinarySweep/GridBounds/BalancedGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..963f87339b48772d416b25b0dae17f886e1ef523 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/BalancedGrid.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.FewSparseBases + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open GridSplit + +lemma balanced_counts (b : ℕ) (hb : 2 ≤ b) : ∃m n : ℕ, + b=m+n ∧ 1 ≤ m ∧ 1 ≤ n ∧ m < b ∧ n < b ∧ m ≤ 2*n ∧ n ≤ 2*m := by + refine ⟨b/2,b-b/2,by omega,by omega,by omega,by omega,by omega,by omega,by omega⟩ + +lemma balanced_grid_bounds {m n r : ℕ} (bits : Fin (m+n) → ℕ) + (hm : 1 ≤ m) (hn : 1 ≤ n) (hmn : m ≤ 2*n) (hnm : n ≤ 2*m) + (hd : ∀j,r ≤ bits j ∧ bits j ≤ 2*r) (hr : 400000000 ≤ (r:ℝ)*Real.log 2) : + 1 ≤ Real.log (gridSize (leftBits bits)) ∧ 1 ≤ Real.log (gridSize (rightBits bits)) ∧ + Real.log (gridSize (leftBits bits)) ≤ (4/5:ℝ)*Real.log (gridSize bits) ∧ + Real.log (gridSize (rightBits bits)) ≤ (4/5:ℝ)*Real.log (gridSize bits) ∧ + Real.log 4*(m+n) ≤ (1/1000:ℝ)*Real.log (gridSize bits) := by + have hl := grid_log_lower (fun j : Fin m => (hd (j.castAdd n)).1) + have hr' := grid_log_lower (fun j : Fin n => (hd (j.natAdd m)).1) + have hlu := grid_log_upper (fun j : Fin m => (hd (j.castAdd n)).2) + have hru := grid_log_upper (fun j : Fin n => (hd (j.natAdd m)).2) + change (m:ℝ)*((r:ℝ)*Real.log 2) ≤ Real.log (gridSize (leftBits bits)) at hl + change (n:ℝ)*((r:ℝ)*Real.log 2) ≤ Real.log (gridSize (rightBits bits)) at hr' + change Real.log (gridSize (leftBits bits)) ≤ (m:ℝ)*(2*r*Real.log 2) at hlu + change Real.log (gridSize (rightBits bits)) ≤ (n:ℝ)*(2*r*Real.log 2) at hru + have hsum : Real.log (gridSize bits)=Real.log (gridSize (leftBits bits))+Real.log (gridSize (rightBits bits)) := by + rw [size_split,Nat.cast_mul] + exact Real.log_mul (by exact_mod_cast (gridSize_pos (leftBits bits)).ne') + (by exact_mod_cast (gridSize_pos (rightBits bits)).ne') + have hmR : (1:ℝ) ≤ m := by exact_mod_cast hm + have hnR : (1:ℝ) ≤ n := by exact_mod_cast hn + have hmnR : (m:ℝ) ≤ 2*n := by exact_mod_cast hmn + have hnmR : (n:ℝ) ≤ 2*m := by exact_mod_cast hnm + have hscale : 0 ≤ (r:ℝ)*Real.log 2 := by linarith + have hmnl := mul_le_mul_of_nonneg_right hmnR hscale + have hnml := mul_le_mul_of_nonneg_right hnmR hscale + have hm1 := mul_le_mul_of_nonneg_right hmR hscale + have hn1 := mul_le_mul_of_nonneg_right hnR hscale + have haxes := grid_log_lower (fun j => (hd j).1) + have hlog4 : Real.log 4 ≤ 4 := (Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<4)).trans (by norm_num) + have hbR : (0:ℝ) ≤ m+n := by positivity + have hax := mul_le_mul_of_nonneg_right hlog4 hbR + have hsc := mul_le_mul_of_nonneg_left hr hbR + push_cast at haxes + refine ⟨by nlinarith,by nlinarith,by nlinarith,by nlinarith,by nlinarith⟩ + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/BoardLaw.lean b/lean/OAI/Probability/BinarySweep/GridBounds/BoardLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..0eb5d7198cc8beca81085806a2fa03ad579bd3e0 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/BoardLaw.lean @@ -0,0 +1,123 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridSplitSweep +import OAI.Probability.BinarySweep.FiniteLaws.FiniteLawAverage + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open GridSplit + +variable {X Y : Type*} [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + +abbrev BoardChoices (X Y : Type*) := (Y → Equiv.Perm X) × (X → Equiv.Perm Y) +def boardWeight (p : Equiv.Perm X → ℝ) (q : Equiv.Perm Y → ℝ) + (LR : BoardChoices X Y) : ℝ := (∏y,p (LR.1 y))*(∏x,q (LR.2 x)) +def boardSweep (LR : BoardChoices X Y) : Equiv.Perm (X×Y) := + columnPerm LR.2 * rowPerm LR.1 +def boardLaw (p : Equiv.Perm X → ℝ) (q : Equiv.Perm Y → ℝ) : Equiv.Perm (X×Y) → ℝ := + pushLaw (boardWeight p q) boardSweep + +lemma boardSampleLaw {A B : Type*} [Fintype A] [Fintype B] + (p : A → ℝ) (q : B → ℝ) (f : A → Equiv.Perm X) (g : B → Equiv.Perm Y) : + pushLaw (fun LR : (Y → A)×(X → B) => (∏y,p (LR.1 y))*(∏x,q (LR.2 x))) + (fun LR => columnPerm (g ∘ LR.2) * rowPerm (f ∘ LR.1))= + boardLaw (pushLaw p f) (pushLaw q g) := by + have he := pushLaw_prod (fun L : Y → A => ∏y,p (L y)) (fun R : X → B => ∏x,q (R x)) + (fun L y => f (L y)) (fun R x => g (R x)) + rw [pushLaw_pi,pushLaw_pi] at he + unfold boardLaw boardWeight + rw [←he,pushLaw_comp] + rfl + +variable {X' Y' : Type*} [Fintype X'] [Fintype Y'] [DecidableEq X'] [DecidableEq Y'] + +def boardChoicesEquiv (e : X ≃ X') (f : Y ≃ Y') : BoardChoices X Y ≃ BoardChoices X' Y' := + Equiv.prodCongr (f.arrowCongr e.permCongr) (e.arrowCongr f.permCongr) + +omit [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + [Fintype X'] [Fintype Y'] [DecidableEq X'] [DecidableEq Y'] in +lemma rowPerm_congr (e : X ≃ X') (f : Y ≃ Y') (L : Y → Equiv.Perm X) : + (Equiv.prodCongr e f).permCongr (rowPerm L)= + rowPerm (f.arrowCongr e.permCongr L) := by + apply Equiv.ext + intro xy + apply Prod.ext <;> simp [rowPerm,Equiv.permCongr_apply,Equiv.arrowCongr_apply] + +omit [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + [Fintype X'] [Fintype Y'] [DecidableEq X'] [DecidableEq Y'] in +lemma columnPerm_congr (e : X ≃ X') (f : Y ≃ Y') (R : X → Equiv.Perm Y) : + (Equiv.prodCongr e f).permCongr (columnPerm R)= + columnPerm (e.arrowCongr f.permCongr R) := by + apply Equiv.ext + intro xy + apply Prod.ext <;> simp [columnPerm,Equiv.permCongr_apply,Equiv.arrowCongr_apply] + +omit [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + [Fintype X'] [Fintype Y'] [DecidableEq X'] [DecidableEq Y'] in +lemma boardSweep_congr (e : X ≃ X') (f : Y ≃ Y') (LR : BoardChoices X Y) : + (Equiv.prodCongr e f).permCongr (boardSweep LR)= + boardSweep (boardChoicesEquiv e f LR) := by + change (Equiv.prodCongr e f).permCongrHom (columnPerm LR.2 * rowPerm LR.1)=_ + rw [map_mul] + change (Equiv.prodCongr e f).permCongr (columnPerm LR.2) * + (Equiv.prodCongr e f).permCongr (rowPerm LR.1)=_ + rw [rowPerm_congr,columnPerm_congr] + rfl + +omit [DecidableEq X'] [DecidableEq Y'] in +lemma boardWeight_congr (e : X ≃ X') (f : Y ≃ Y') + (p : Equiv.Perm X → ℝ) (q : Equiv.Perm Y → ℝ) (LR : BoardChoices X Y) : + boardWeight (pushLaw p e.permCongr) (pushLaw q f.permCongr) + (boardChoicesEquiv e f LR)=boardWeight p q LR := by + unfold boardWeight boardChoicesEquiv + simp only [Equiv.prodCongr_apply,pushLaw_equiv_apply] + rw [←f.prod_comp,←e.prod_comp] + have he (σ : Equiv.Perm X) : e.symm.permCongr (e.permCongr σ)=σ := + e.permCongr.symm_apply_apply σ + have hf (σ : Equiv.Perm Y) : f.symm.permCongr (f.permCongr σ)=σ := + f.permCongr.symm_apply_apply σ + simp [Equiv.arrowCongr_apply,he,hf] + +lemma boardLaw_congr (e : X ≃ X') (f : Y ≃ Y') + (p : Equiv.Perm X → ℝ) (q : Equiv.Perm Y → ℝ) : + pushLaw (boardLaw p q) (Equiv.prodCongr e f).permCongr= + boardLaw (pushLaw p e.permCongr) (pushLaw q f.permCongr) := by + unfold boardLaw + rw [pushLaw_comp] + have hw : boardWeight (pushLaw p e.permCongr) (pushLaw q f.permCongr) ∘ + boardChoicesEquiv e f=boardWeight p q := funext (boardWeight_congr e f p q) + have hs : (Equiv.prodCongr e f).permCongr ∘ boardSweep= + boardSweep ∘ boardChoicesEquiv e f := funext (boardSweep_congr e f) + rw [hs,←hw] + exact pushLaw_equiv (boardChoicesEquiv e f) _ _ + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +variable {X Y A B Ω : Type*} [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + [Fintype A] [Fintype B] [Fintype Ω] +lemma board_equiv_sample (p : A → ℝ) (q : B → ℝ) + (f : A → Equiv.Perm X) (g : B → Equiv.Perm Y) + (e : Ω ≃ (Y → A)×(X → B)) (w : Ω → ℝ) (F : Ω → Equiv.Perm (X×Y)) + (hw : ∀c,w c=(∏y,p ((e c).1 y))*(∏x,q ((e c).2 x))) + (hF : ∀c,F c=GridSplit.columnPerm (g ∘ (e c).2)*GridSplit.rowPerm (f ∘ (e c).1)) : + pushLaw w F=boardLaw (pushLaw p f) (pushLaw q g) := by + have hw' : w=(fun LR : (Y→A)×(X→B) => (∏y,p (LR.1 y))*(∏x,q (LR.2 x))) ∘ e := funext hw + have hf' : F=(fun LR : (Y→A)×(X→B) => GridSplit.columnPerm (g ∘ LR.2)*GridSplit.rowPerm (f ∘ LR.1)) ∘ e := funext hF + rw [hw',hf',pushLaw_equiv] + exact boardSampleLaw p q f g +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/BoardOverlap.lean b/lean/OAI/Probability/BinarySweep/GridBounds/BoardOverlap.lean new file mode 100644 index 0000000000000000000000000000000000000000..9dfa0746c0688dc892efe0c115b112c5e9babe9a --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/BoardOverlap.lean @@ -0,0 +1,190 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GroupedMoments +import OAI.Probability.BinarySweep.MatrixBounds.TraceDensityComparison + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder MatrixOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation + +variable {A I J U W V : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + [Fintype U] [Fintype W] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +omit [FiniteDimensional ℂ V] in +theorem regularized_board_overlap {n : ℕ} (e : Fin n ↪ I × J) (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] + (R Q : Matrix (Fin n → A) (Fin n → A) ℂ) + (hR : R.IsHermitian) (hQ : Q.IsHermitian) (hRR : R*R=R) (hQQ : Q*Q=Q) + (hPQ : isotypicProjection p ρ * Q = Q * isotypicProjection p ρ) + (hCQ : ∀ M : Matrix A A ℂ, M.PosSemidef → + (∀ a b, p a ≠ p b → M a b = 0) → matrixTensorPower n M * Q = Q * matrixTensorPower n M) + (r : U → I → Matrix A A ℂ) (v : W → J → Matrix A A ℂ) + (hr : ∀ u i, (r u i).PosSemidef) (hv : ∀ w j, (v w j).PosSemidef) + (htr : ∀ u i, (r u i).trace=1) (htv : ∀ w j, (v w j).trace=1) + (her : ∀ u i a b, p a ≠ p b → r u i a b=0) + (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) + (hdr : ((a:ℂ) • ∑u, tensorMatrices (fun t : Fin n => r u (e t).1)-R).PosSemidef) + (hdv : ((b:ℂ) • ∑w, tensorMatrices (fun t : Fin n => v w (e t).2)-Q).PosSemidef) + {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) : + (Module.finrank ℂ V : ℝ) * (1-ε)^n * ‖Q * isotypicProjection p ρ * R‖^2 ≤ + a*b*Fintype.card U*Fintype.card W* + Real.exp (Fintype.card I * Fintype.card J - (n : ℝ)) := by + let P := isotypicProjection p ρ + let d : ℝ := Module.finrank ℂ V + let L : ℝ := (1-ε)^n + let E := Real.exp (Fintype.card I * Fintype.card J - (n : ℝ)) + let T (u : U) := tensorMatrices (fun t : Fin n => r u (e t).1) + let Z (w : W) := tensorMatrices (fun t : Fin n => v w (e t).2) + have hL : 0 ≤ L := pow_nonneg (sub_nonneg.mpr hε1) n + have hd : 0 ≤ d := Nat.cast_nonneg _ + have hP : P.PosSemidef := isotypicProjection_psd p ρ + have hPP : P*P=P := projectionMatrix_idempotent _ + have hn := projection_overlap_norm_trace R Q P hR hQ hP.isHermitian hRR hQQ hPP hPQ + have hQP := commuting_projection_product_psd P Q hP hQ hQQ hPQ + have hrow := trace_right_density_domination R (Q*P) a T hQP hdr + rw [← mul_assoc R Q P] at hrow + have hlocal (u : U) : L * (d * (T u*Q*P).trace.re) ≤ b*(Fintype.card W*E) := by + let M := regularizedMean (r u) ε + have hM : M.PosDef := regularizedMean_posDef (r u) (hr u) hε hε1 + have heM := regularizedMean_even (r u) p (her u) ε + obtain ⟨B,C,hB,hC,hBB,hBC,hCB,heB,heC⟩ := exists_even_whitening p M hM heM + let H := matrixTensorPower n C + have hH : H.PosSemidef := tensorMatrices_psd _ (fun _ => hC) + have hcap := signed_tensor_whitening p ρ M B C hB hC hBB hBC + (regularizedMean_trace (r u) (htr u) ε) heM heC + change (H.conjTranspose*H-(d:ℂ)•P).PosSemidef at hcap + rw [hH.isHermitian.eq] at hcap + have hcomp := compress_whitening_cap P Q H (d:ℂ) hQ hQQ hPQ (hCQ C hC heC) hcap + have htu : (T u).PosSemidef := tensorMatrices_psd _ (fun t => hr u (e t).1) + have ht := trace_density_whitening (T u) Q P H d b Z htu hH.isHermitian hcomp hdv + have hCMC : C * regularizedMean (r u) ε * C = 1 := by + change C * M * C = 1 + rw [← hBB,← mul_assoc C B B,hCB,one_mul,hBC] + have hz (w : W) : L * (H*T u*H*Z w).trace.re ≤ E := by + have hh := whitened_board_budget e (r u) (v w) C (hr u) (hv w) (htv w) + hε.le hε1 hC.isHermitian hCMC + change L * (tensorMatrices (fun _ : Fin n => C) * T u * + tensorMatrices (fun _ : Fin n => C) * Z w).trace.re ≤ E + simpa only [T,Z,L,E,tensorMatrices_mul] using hh + calc + L*(d*(T u*Q*P).trace.re) ≤ L*(b*∑w, (H*T u*H*Z w).trace.re) := + mul_le_mul_of_nonneg_left ht hL + _ = b*∑w, L*(H*T u*H*Z w).trace.re := by simp only [Finset.mul_sum]; congr 1; ring_nf + _ ≤ b*∑w : W, E := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum (fun w _ => hz w)) hb + _ = b*(Fintype.card W*E) := by simp + change d*L*‖Q*P*R‖^2 ≤ a*b*Fintype.card U*Fintype.card W*E + calc + _ ≤ d*L*(a*∑u, (T u*(Q*P)).trace.re) := + mul_le_mul_of_nonneg_left (hn.trans hrow) (mul_nonneg hd hL) + _ = a*∑u, L*(d*(T u*Q*P).trace.re) := by + simp only [← mul_assoc,Finset.mul_sum] + ring_nf + _ ≤ a*∑u : U, b*(Fintype.card W*E) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun u _ => hlocal u)) ha + _ = _ := by simp; ring + +omit [FiniteDimensional ℂ V] in +theorem board_overlap {n : ℕ} (e : Fin n ↪ I × J) (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] + (R Q : Matrix (Fin n → A) (Fin n → A) ℂ) + (hR : R.IsHermitian) (hQ : Q.IsHermitian) (hRR : R*R=R) (hQQ : Q*Q=Q) + (hPQ : isotypicProjection p ρ * Q = Q * isotypicProjection p ρ) + (hCQ : ∀ M : Matrix A A ℂ, M.PosSemidef → + (∀ a b, p a ≠ p b → M a b = 0) → matrixTensorPower n M * Q = Q * matrixTensorPower n M) + (r : U → I → Matrix A A ℂ) (v : W → J → Matrix A A ℂ) + (hr : ∀ u i, (r u i).PosSemidef) (hv : ∀ w j, (v w j).PosSemidef) + (htr : ∀ u i, (r u i).trace=1) (htv : ∀ w j, (v w j).trace=1) + (her : ∀ u i a b, p a ≠ p b → r u i a b=0) + (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) + (hdr : ((a:ℂ) • ∑u, tensorMatrices (fun t : Fin n => r u (e t).1)-R).PosSemidef) + (hdv : ((b:ℂ) • ∑w, tensorMatrices (fun t : Fin n => v w (e t).2)-Q).PosSemidef) + : (Module.finrank ℂ V : ℝ) * ‖Q * isotypicProjection p ρ * R‖^2 ≤ + a*b*Fintype.card U*Fintype.card W* + Real.exp (Fintype.card I * Fintype.card J - (n : ℝ)) := by + have hε1 : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0), ε < 1 := + (eventually_lt_nhds (by norm_num : (0:ℝ)<1)).filter_mono nhdsWithin_le_nhds + have hbound : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0), + (Module.finrank ℂ V : ℝ) * (1-ε)^n * ‖Q*isotypicProjection p ρ*R‖^2 ≤ + a*b*Fintype.card U*Fintype.card W* + Real.exp (Fintype.card I * Fintype.card J - (n : ℝ)) := by + filter_upwards [self_mem_nhdsWithin,hε1] with ε hε hε1 + exact regularized_board_overlap e p ρ R Q hR hQ hRR hQQ hPQ hCQ r v hr hv + htr htv her a b ha hb hdr hdv hε hε1.le + apply le_of_tendsto _ hbound + have ht : Filter.Tendsto (fun ε : ℝ => (Module.finrank ℂ V:ℝ)*(1-ε)^n* + ‖Q*isotypicProjection p ρ*R‖^2) (nhdsWithin 0 (Set.Ioi 0)) + (nhds ((Module.finrank ℂ V:ℝ)*(1-(0:ℝ))^n*‖Q*isotypicProjection p ρ*R‖^2)) := by + exact (show Continuous (fun ε : ℝ => (Module.finrank ℂ V:ℝ)*(1-ε)^n* + ‖Q*isotypicProjection p ρ*R‖^2) by fun_prop).continuousWithinAt.tendsto + simpa using ht + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical ComplexOrder MatrixOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation + +variable {A I J : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + [Fintype I] [LinearOrder I] [Nonempty I] [Fintype J] [LinearOrder J] + {nR : I → ℕ} {nC : J → ℕ} {N : ℕ} + {VR : I → Type*} [∀i, NormedAddCommGroup (VR i)] + [∀i, InnerProductSpace ℂ (VR i)] [∀i, FiniteDimensional ℂ (VR i)] + {VC : J → Type*} [∀j, NormedAddCommGroup (VC j)] + [∀j, InnerProductSpace ℂ (VC j)] [∀j, FiniteDimensional ℂ (VC j)] + {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +omit [FiniteDimensional ℂ V] in +theorem actual_board_overlap (board : Fin N ↪ I × J) (p : A → Bool) + (eR : (Σₗ i, Fin (nR i)) ≃o Fin N) (eC : (Σₗ j, Fin (nC j)) ≃o Fin N) + (gR gC : Equiv.Perm (Fin N)) + (hR : ∀t, groupOf eR gR t=(board t).1) (hC : ∀t, groupOf eC gC t=(board t).2) + (ρ : Representation ℂ (Equiv.Perm (Fin N)) V) [ρ.IsIrreducible] + (α : ∀i, Representation ℂ (Equiv.Perm (Fin (nR i))) (VR i)) [∀i, (α i).IsIrreducible] + (β : ∀j, Representation ℂ (Equiv.Perm (Fin (nC j))) (VC j)) [∀j, (β j).IsIrreducible] : + (Module.finrank ℂ V:ℝ)* + ‖groupedProjection eC gC p β*isotypicProjection p ρ*groupedProjection eR gR p α‖^2 ≤ + (∏i, (Module.finrank ℂ (VR i):ℝ)*(nR i+1:ℝ)^(2*(Fintype.card A)^2))* + (∏j, (Module.finrank ℂ (VC j):ℝ)*(nC j+1:ℝ)^(2*(Fintype.card A)^2))* + Fintype.card (∀i, LocalDensityIndex p (nR i))*Fintype.card (∀j, LocalDensityIndex p (nC j))* + Real.exp (Fintype.card I*Fintype.card J-(N:ℝ)) := by + apply board_overlap board p ρ _ _ + (groupedProjection_psd eR gR p α).isHermitian + (groupedProjection_psd eC gC p β).isHermitian + (groupedProjection_idempotent eR gR p α) + (groupedProjection_idempotent eC gC p β) + (groupedProjection_commutes eC gC p β _ (isotypicProjection_invariant p ρ)) + (fun M _ he => groupedProjection_commutes eC gC p β _ (even_tensor_invariant p M he)) + (fun u i => localDensity p (nR i) (u i)) (fun w j => localDensity p (nC j) (w j)) + (fun u i => localDensity_psd p _ _) (fun w j => localDensity_psd p _ _) + (fun u i => localDensity_trace p _ _) (fun w j => localDensity_trace p _ _) + (fun u i => localDensity_even p _ _) + · positivity + · positivity + · have h := grouped_density_domination eR gR p α + rw [show groupOf eR gR = (fun t => (board t).1) from funext hR] at h + simpa only [hR,Complex.ofReal_prod,Complex.ofReal_mul,Complex.ofReal_natCast, + Complex.ofReal_pow,Complex.ofReal_add,Complex.ofReal_one] using h + · have h := grouped_density_domination eC gC p β + rw [show groupOf eC gC = (fun t => (board t).2) from funext hC] at h + simpa only [hC,Complex.ofReal_prod,Complex.ofReal_mul,Complex.ofReal_natCast, + Complex.ofReal_pow,Complex.ofReal_add,Complex.ofReal_one] using h + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/BoardProduct.lean b/lean/OAI/Probability/BinarySweep/GridBounds/BoardProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..f63c4255776bbdcbae5865c5aa2bace43e216bc9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/BoardProduct.lean @@ -0,0 +1,42 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Density + +theorem product_on_board_le_exp {I : Type*} [Fintype I] [DecidableEq I] + (S : Finset I) (x : I → ℝ) (hx : ∀ i, 0 ≤ x i) (C : ℝ) + (hs : ∑ i, x i ≤ C) : + ∏ i ∈ S, x i ≤ Real.exp (C - S.card) := by + have he (a : ℝ) : a ≤ Real.exp (a-1) := by + have := Real.add_one_le_exp (a-1) + linarith + calc + _ ≤ ∏ i ∈ S, Real.exp (x i - 1) := + Finset.prod_le_prod₀ (fun index _ => hx index) (fun index _ => he (x index)) + _ = Real.exp ((∑ i ∈ S, x i) - S.card) := by + rw [← Real.exp_sum,Finset.sum_sub_distrib] + simp + _ ≤ Real.exp (C - S.card) := by + apply Real.exp_le_exp.mpr + exact sub_le_sub_right ((Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ S) (fun i _ _ => hx i)).trans hs) _ + + theorem rectangular_product_holes {I J : Type*} [Fintype I] [Fintype J] + [DecidableEq I] [DecidableEq J] (S : Finset (I × J)) (x : I → J → ℝ) + (hx : ∀ i j, 0 ≤ x i j) + (hs : ∀ j, ∑ i, x i j ≤ Fintype.card I) : + ∏ t ∈ S, x t.1 t.2 ≤ + Real.exp (Fintype.card I * Fintype.card J - S.card) := by + apply product_on_board_le_exp S (fun t => x t.1 t.2) (fun t => hx t.1 t.2) + rw [Fintype.sum_prod_type,Finset.sum_comm] + simpa [mul_comm] using Finset.sum_le_sum (s:=Finset.univ) (fun j _ => hs j) + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/DenseAssembly.lean b/lean/OAI/Probability/BinarySweep/GridBounds/DenseAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..55b79c1f0adaa8420fb77e888cfe3a4276444181 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/DenseAssembly.lean @@ -0,0 +1,110 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.GenericHookAux +import OAI.Probability.BinarySweep.YoungTheory.PhysicalHookInduced +import OAI.Probability.BinarySweep.Conditional.CycleAugmentation + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps +open Irrep Representation Young GridSplit Signed + +def EnumeratedMomentBound (q : ℕ) {b : ℕ} (bits : Fin b → ℕ) (z : ℝ) : Prop := + ∀ h : ℕ, ∀ H : PathFamily bits h, ∀ α : (Fintype.card (FreeSlot H 0)).Partition, + evenMoment q (groupAverage (partitionHilbertRep α) + (fun a => (conditionalGroupLaw H z ((Fintype.equivFin _).symm.permCongr a):ℂ))) ≤ + Real.exp (-cExponent (gridSize bits)*typeF α+ + eExponent (gridSize bits)*h*Real.log (gridSize bits)-pathCost H) + +def diagramF (μ : YoungDiagram) : ℝ := Real.log (Module.finrank ℂ (SpechtSpace μ)) + +lemma moment_divide_dimension {D T B : ℝ} (hD : 0 (conditionalGroupLaw HH z a:ℂ)))≤ + Real.exp (-(cExponent s+inductionGap s)*diagramF (hookPart μ t)+ + (eExponent s-inductionGap s)*h'*Real.log s-pathCost HH+(s:ℝ)^(9/10:ℝ))) : + evenMoment q (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun a => (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-(cExponent s+inductionGap s)*diagramF (hookPart μ t)+ + (eExponent s-inductionGap s)*(h+Fintype.card (Cell (southeast μ t)))*Real.log s+ + (s:ℝ)^(9/10:ℝ)-pathCost H+ + Real.log 4*Fintype.card (Cell (southeast μ t))*(m+n)-diagramF (southeast μ t)) := by + let k := Fintype.card (Cell (southeast μ t)) + let f := hookPlacementBasis H μ t e + let σ := hilbertSpecht (hookPart μ t) + let B := -(cExponent s+inductionGap s)*diagramF (hookPart μ t)+ + (eExponent s-inductionGap s)*(h+k)*Real.log s+(s:ℝ)^(9/10:ℝ) + have hf (x y : Placement H k 0) (hp : 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-(cExponent s+inductionGap s)*diagramF (hookPart μ t)+ + (eExponent s-inductionGap s)*(h+Fintype.card (Cell (southeast μ t)))*Real.log s+ + (s:ℝ)^(9/10:ℝ)-pathCost H+ + Real.log 4*Fintype.card (Cell (southeast μ t))*(m+n)-diagramF (southeast μ t)) := by + filter_upwards [specht_hook_auxiliary_eventually q hq] with s hs + intro m n h r bits H hsize hu hv hub hvb hd t ht hts μ e z hz hzr hR hC + apply dense_of_auxiliary_hook s q t (by omega) bits H hd μ e z hz hzr + intro h' HH ee + exact hs m n h' bits HH hsize hu hv hub hvb t ht hts + (hookPart μ t) (hookPart_inHook μ t) ee z + (fun y a => hR _ (rowFamily bits HH y) a.val) + (fun x a => hC _ (columnFamily bits HH x) a.val) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/DenseClosing.lean b/lean/OAI/Probability/BinarySweep/GridBounds/DenseClosing.lean new file mode 100644 index 0000000000000000000000000000000000000000..df66ac768feb696693da535ddaa530ed660eff65 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/DenseClosing.lean @@ -0,0 +1,59 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.DenseAssembly +import OAI.Probability.BinarySweep.FiniteLaws.SoutheastDimension + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps +open Young Irrep Representation GridSplit Signed + +lemma diagramF_nonneg (μ : YoungDiagram) : 0≤diagramF μ := by + apply Real.log_nonneg + have hpos := irreducible_finrank_pos (hilbertSpecht μ) + rw [hilbertSpecht_finrank] at hpos + exact_mod_cast Nat.one_le_of_lt hpos + +theorem dense_induction_step_eventually (q : ℕ) (hq : 2≤q) : ∀ᶠ s : ℕ in atTop, + ∀ m n h r : ℕ, ∀ bits : Fin (m+n) → ℕ, ∀ H : PathFamily bits h, + gridSize bits=s → + 1≤Real.log (gridSize (leftBits bits)) → 1≤Real.log (gridSize (rightBits bits)) → + Real.log (gridSize (leftBits bits))≤(4/5:ℝ)*Real.log s → + Real.log (gridSize (rightBits bits))≤(4/5:ℝ)*Real.log s → + (∀j, bits j≤2*r) → Real.log 4*(m+n)≤(1/1000:ℝ)*Real.log s → + ∀ μ : YoungDiagram, ∀ e : Cell μ ≃ FreeSlot H 0, + (s:ℝ)^(399/400:ℝ)≤diagramF μ → ∀z : ℝ, + 0≤z → z≤linePerturbationRadius r → + EnumeratedMomentBound q (leftBits bits) z → EnumeratedMomentBound q (rightBits bits) z → + evenMoment q (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun a => (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-cExponent s*diagramF μ+eExponent s*h*Real.log s-pathCost H) := by + filter_upwards [dense_branch_operator_eventually q hq, + dense_induction_absorption_eventually (Real.log 2+1),eventually_ge_atTop (1:ℕ)] with s hop hab hs + intro m n h r bits H hsize hu hv hub hvb hd haxes μ e hF z hz hzr hR hC + have hs0 : 0 ⟨diagonal μ x,hL x⟩ + have hf : fiberStabilizer f = diagonalStabilizer μ := by + ext g + constructor + · intro hg x + exact congrArg Fin.val (hg x) + · intro hg x + exact Fin.ext (hg x) + have hb := factorial_le_colorings_mul_stabilizer f + rw [Fintype.card_fin, hf, Nat.card_eq_fintype_card] at hb + exact hb.trans (Nat.mul_le_mul_left _ (diagonal_card_le_dimension μ)) + +lemma specht_dimension_pos : 0 < Module.finrank ℂ (SpechtSpace μ) := + lt_of_lt_of_le (Fintype.card_pos) (diagonal_card_le_dimension μ) + +theorem log_dimension_lower_of_diagonal_bound (L : ℕ) (hpos : 0 < L) + (hk : 0 < Fintype.card (Cell μ)) (hL : ∀ x : Cell μ, diagonal μ x < L) : + (Fintype.card (Cell μ) : ℝ) * + (Real.log (Fintype.card (Cell μ)) - Real.log L - 1) ≤ + Real.log (Module.finrank ℂ (SpechtSpace μ)) := by + let k := Fintype.card (Cell μ) + let D := Module.finrank ℂ (SpechtSpace μ) + have hD : (0 : ℝ) < D := by exact_mod_cast specht_dimension_pos μ + have hLr : (0 : ℝ) < L := by exact_mod_cast hpos + have hfac : (0 : ℝ) < k.factorial := by positivity + have hbound : (k.factorial : ℝ) ≤ (L : ℝ)^k * D := by + exact_mod_cast factorial_le_diagonal_dimension μ L hL + have hlog := Real.log_le_log hfac hbound + rw [Real.log_mul (pow_ne_zero _ hLr.ne') hD.ne', Real.log_pow] at hlog + have hst := Stirling.le_log_factorial_stirling (show k ≠ 0 from hk.ne') + have hpi : 0 ≤ Real.log (2*Real.pi) := Real.log_nonneg (by linarith [Real.pi_gt_three]) + have hklog : 0 ≤ Real.log k := Real.log_nonneg (by exact_mod_cast hk) + change (k : ℝ) * (Real.log k - Real.log L - 1) ≤ Real.log D + nlinarith + +lemma diagonal_lt_height_add_width (x : Cell μ) : + diagonal μ x < μ.colLen 0 + μ.rowLen 0 := by + have hr : row x < μ.colLen (col x) := YoungDiagram.mem_iff_lt_colLen.mp x.property + have hc : col x < μ.rowLen (row x) := YoungDiagram.mem_iff_lt_rowLen.mp x.property + have hr' := μ.colLen_anti 0 (col x) (Nat.zero_le _) + have hc' := μ.rowLen_anti 0 (row x) (Nat.zero_le _) + unfold diagonal + omega + +lemma width_add_rectangle_le_card (x : Cell μ) : + μ.rowLen 0 + row x * (col x+1) ≤ Fintype.card (Cell μ) := by + let f : Fin (μ.rowLen 0) ⊕ (Fin (row x) × Fin (col x+1)) → Cell μ := + Sum.elim (fun a => ⟨(0,a.val), YoungDiagram.mem_iff_lt_rowLen.mpr a.isLt⟩) + (fun a => ⟨(a.1.val+1,a.2.val), μ.up_left_mem + (show a.1.val+1 ≤ row x from a.1.isLt) + (show a.2.val ≤ col x from Nat.le_of_lt_succ a.2.isLt) x.property⟩) + have hf : Function.Injective f := by + intro a b he + have he' := congrArg Subtype.val he + cases a with + | inl a => + cases b with + | inl b => + have hab : a = b := Fin.ext (congrArg Prod.snd he') + exact congrArg Sum.inl hab + | inr b => + have hh := congrArg Prod.fst he' + change 0 = b.1.val+1 at hh + omega + | inr a => + cases b with + | inl b => + have hh := congrArg Prod.fst he' + change a.1.val+1 = 0 at hh + omega + | inr b => + congr 1 + apply Prod.ext + · apply Fin.ext + have hh := congrArg Prod.fst he' + change a.1.val+1 = b.1.val+1 at hh + omega + · exact Fin.ext (congrArg Prod.snd he') + simpa only [Fintype.card_sum, Fintype.card_prod, Fintype.card_fin] using + Fintype.card_le_of_injective f hf + +lemma height_add_rectangle_le_card (x : Cell μ) : + μ.colLen 0 + col x * (row x+1) ≤ Fintype.card (Cell μ) := by + let y : Cell μ.transpose := ⟨x.val.swap, YoungDiagram.mem_transpose.mpr x.property⟩ + have hh := width_add_rectangle_le_card μ.transpose y + have hc : Fintype.card (Cell μ.transpose) = Fintype.card (Cell μ) := by + simpa only [Cell, Fintype.card_coe, YoungDiagram.card] using YoungDiagram.card_transpose μ + simpa only [YoungDiagram.rowLen_transpose, hc, y, row, col, Prod.fst_swap, Prod.snd_swap] using hh + +lemma height_width_le_card : max (μ.colLen 0) (μ.rowLen 0) ≤ Fintype.card (Cell μ) := by + by_cases h : Nonempty (Cell μ) + · obtain ⟨x⟩ := h + exact max_le (by have := height_add_rectangle_le_card μ x; omega) + (by have := width_add_rectangle_le_card μ x; omega) + · have hempty : μ = ⊥ := by + apply YoungDiagram.ext + ext x + simp only [YoungDiagram.cells_bot, Finset.notMem_empty, iff_false] + intro hx + exact h ⟨⟨x,hx⟩⟩ + subst μ + simp [YoungDiagram.colLen, YoungDiagram.rowLen] + +lemma diagonal_twice_le (x : Cell μ) : + 2*(diagonal μ x+1) ≤ Fintype.card (Cell μ) + max (μ.colLen 0) (μ.rowLen 0) := by + have hr : row x < μ.colLen 0 := + (YoungDiagram.mem_iff_lt_colLen.mp x.property).trans_le (μ.colLen_anti 0 _ (Nat.zero_le _)) + have hc : col x < μ.rowLen 0 := + (YoungDiagram.mem_iff_lt_rowLen.mp x.property).trans_le (μ.rowLen_anti 0 _ (Nat.zero_le _)) + have hm := height_width_le_card μ + unfold diagonal + by_cases hrow : row x = 0 + · rw [hrow] + omega + by_cases hcol : col x = 0 + · rw [hcol] + omega + rcases le_total (μ.colLen 0) (μ.rowLen 0) with h | h + · rw [max_eq_right h] + have hh := width_add_rectangle_le_card μ x + have hm2 : 2*row x ≤ row x*(col x+1) := by + rw [mul_comm 2] + exact Nat.mul_le_mul_left _ (by omega) + omega + · rw [max_eq_left h] + have hh := height_add_rectangle_le_card μ x + have hm2 : 2*col x ≤ col x*(row x+1) := by + rw [mul_comm 2] + exact Nat.mul_le_mul_left _ (by omega) + omega + +lemma diagonal_lt_half_card_add_max (x : Cell μ) : + diagonal μ x < (Fintype.card (Cell μ) + max (μ.colLen 0) (μ.rowLen 0))/2 := by + have hh := diagonal_twice_le μ x + omega + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable {X Y : Type*} [Fintype X] [Fintype Y] + +def assembleFiberPerm (f : X → Y) (p : ∀ y, Equiv.Perm {x // f x = y}) : + fiberStabilizer f := + ⟨(Equiv.sigmaFiberEquiv f).permCongr (Equiv.sigmaCongrRight p), by + intro x + exact (p (f x) ⟨x,rfl⟩).property⟩ + +omit [Fintype X] [Fintype Y] in +lemma assembleFiberPerm_injective (f : X → Y) : Function.Injective (assembleFiberPerm f) := by + intro p q he + have hh := congrArg Subtype.val he + have hh' : Equiv.sigmaCongrRight p = Equiv.sigmaCongrRight q := + (Equiv.sigmaFiberEquiv f).permCongr.injective hh + exact Equiv.Perm.sigmaCongrRightHom_injective hh' + +lemma product_factorial_le_stabilizer (f : X → Y) : + (∏ y, (Fintype.card {x // f x = y}).factorial) ≤ Nat.card (fiberStabilizer f) := by + have hi := Nat.card_le_card_of_injective (assembleFiberPerm f) (assembleFiberPerm_injective f) + simpa only [Nat.card_eq_fintype_card, Fintype.card_pi, Fintype.card_perm] using hi + +lemma two_pow_sub_one_le_factorial (n : ℕ) : 2^(n-1) ≤ n.factorial := by + cases n with + | zero => simp + | succ n => + induction n with + | zero => simp + | succ n ih => + rw [Nat.succ_sub_one, pow_succ, Nat.factorial_succ] + have hp : 2 ≤ n+1+1 := by omega + simpa only [Nat.succ_sub_one, mul_comm] using Nat.mul_le_mul ih hp + +lemma two_pow_card_sub_colors_le_stabilizer (f : X → Y) : + 2^(Fintype.card X - Fintype.card Y) ≤ Nat.card (fiberStabilizer f) := by + have hsum : ∑ y, Fintype.card {x // f x = y} = Fintype.card X := by + rw [← Fintype.card_sigma] + exact Fintype.card_congr (Equiv.sigmaFiberEquiv f) + have hexp : Fintype.card X - Fintype.card Y ≤ + ∑ y, (Fintype.card {x // f x = y} - 1) := by + have hh := Finset.sum_le_sum (s := Finset.univ) (fun (y : Y) _ => + show Fintype.card {x // f x = y} ≤ (Fintype.card {x // f x = y} - 1) + 1 from by omega) + rw [hsum, Finset.sum_add_distrib] at hh + simp only [Finset.sum_const, Finset.card_univ, smul_eq_mul, mul_one] at hh + omega + calc + _ ≤ 2^(∑ y, (Fintype.card {x // f x = y} - 1)) := Nat.pow_le_pow_right (by decide) hexp + _ = ∏ y, 2^(Fintype.card {x // f x = y} - 1) := (Finset.prod_pow_eq_pow_sum _ _ _).symm + _ ≤ ∏ y, (Fintype.card {x // f x = y}).factorial := + Finset.prod_le_prod (fun y _ => two_pow_sub_one_le_factorial _) + _ ≤ _ := product_factorial_le_stabilizer f + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/DiagonalRigidity.lean b/lean/OAI/Probability/BinarySweep/GridBounds/DiagonalRigidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ffb11243732ce139b3c276ccbeb8821b56ae38b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/DiagonalRigidity.lean @@ -0,0 +1,188 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungSpecht + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +lemma diagonal_rigidity_aux {X : Type*} [Fintype X] (A B : X → ℝ) + (r c : Equiv.Perm X) (hr : ∀ x, A (r x) = A x) + (hc : ∀ x, B (c x) = B x) + (hd : ∀ x, A ((r*c) x) + B ((r*c) x) = A x + B x) : + ∀ x, A (c x) = A x := by + have hq (x : X) : B ((r*c) x) = A x + B x - A (c x) := by + have he := hd x + change A (r (c x)) + _ = _ at he + rw [hr] at he + linarith + have hxc : ∑ x, A (c x) * B x = ∑ x, A x * B x := by + simpa only [hc] using Equiv.sum_comp c (fun x => A x * B x) + have hxx : ∑ x, (A (c x))^2 = ∑ x, (A x)^2 := + Equiv.sum_comp c (fun x => (A x)^2) + have hprod : ∑ x, (A (c x) * A x + A (c x) * B x - (A (c x))^2) = + ∑ x, A x * B x := by + calc + _ = ∑ x, A ((r*c) x) * B ((r*c) x) := by + apply Finset.sum_congr rfl + intro x _ + rw [hq] + change _ = A (r (c x)) * _ + rw [hr] + ring + _ = _ := Equiv.sum_comp (r*c) (fun x => A x * B x) + rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, hxc] at hprod + have hcross : ∑ x, A (c x) * A x = ∑ x, (A (c x))^2 := by linarith + have hzero : ∑ x, (A (c x) - A x)^2 = 0 := by + calc + _ = (∑ x, (A (c x))^2) - 2 * (∑ x, A (c x)*A x) + ∑ x, (A x)^2 := by + simp only [Finset.mul_sum, ← Finset.sum_sub_distrib, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + ring + _ = 0 := by rw [hcross, hxx]; ring + intro x + have hx : (A (c x) - A x)^2 = 0 := + (Finset.sum_eq_zero_iff_of_nonneg (fun x _ => sq_nonneg (A (c x) - A x))).mp hzero x + (Finset.mem_univ x) + nlinarith [sq_nonneg (A (c x) - A x)] + +def diagonal (μ : YoungDiagram) (x : Cell μ) : ℕ := row x + col x +abbrev diagonalStabilizer (μ : YoungDiagram) := fiberStabilizer (diagonal μ) +instance diagonalStabilizer_fintype (μ : YoungDiagram) : Fintype (diagonalStabilizer μ) := + Fintype.ofFinite _ + +lemma diagonal_row_column (μ : YoungDiagram) (r : rowStabilizer μ) (c : C μ) + (hd : r.val*c.val ∈ diagonalStabilizer μ) : r = 1 ∧ c = 1 := by + have he := diagonal_rigidity_aux (fun x : Cell μ => (row x : ℝ)) + (fun x => (col x : ℝ)) r.val c.val + (fun x => congrArg Nat.cast (r.property x)) (fun x => congrArg Nat.cast (c.property x)) + (fun x => by exact_mod_cast hd x) + have hc : c.val ∈ rowStabilizer μ := fun x => by exact_mod_cast he x + have hi : c.val ∈ rowStabilizer μ ⊓ colStabilizer μ := ⟨hc,c.property⟩ + rw [row_col_intersection] at hi + have hc1 : c = 1 := Subtype.ext hi + have hr1 : r = 1 := by + apply Subtype.ext + apply Equiv.ext + intro x + apply Subtype.ext + apply Prod.ext (r.property x) + have hh := hd x + rw [hc1] at hh + change row (r.val x) + col (r.val x) = row x + col x at hh + rw [r.property] at hh + exact Nat.add_left_cancel hh + exact ⟨hr1,hc1⟩ + +lemma diagonal_column_row (μ : YoungDiagram) (c : C μ) (r : rowStabilizer μ) + (hd : c.val*r.val ∈ diagonalStabilizer μ) : c = 1 ∧ r = 1 := by + have hi := (diagonalStabilizer μ).inv_mem hd + have he : (r⁻¹).val * (c⁻¹).val ∈ diagonalStabilizer μ := by simpa using hi + obtain ⟨hr,hc⟩ := diagonal_row_column μ r⁻¹ c⁻¹ he + exact ⟨inv_eq_one.mp hc, inv_eq_one.mp hr⟩ + +variable (μ : YoungDiagram) + +lemma diagonal_tabloid_eq (g h : diagonalStabilizer μ) (c : C μ) : + tabloidOfPerm μ (g.val*c.val) = tabloidOfPerm μ h.val ↔ g = h ∧ c = 1 := by + constructor + · intro he + let r : rowStabilizer μ := ⟨(g.val*c.val)⁻¹*h.val, + (tabloidOfPerm_eq_iff μ _ _).mp he⟩ + have hr : c.val*r.val = g.val⁻¹*h.val := by dsimp only [r]; group + have hd : c.val*r.val ∈ diagonalStabilizer μ := by + rw [hr] + exact (diagonalStabilizer μ).mul_mem ((diagonalStabilizer μ).inv_mem g.property) h.property + obtain ⟨hc,hr1⟩ := diagonal_column_row μ c r hd + refine ⟨?_,hc⟩ + rw [hc,hr1] at hr + have hg : g.val = h.val := inv_mul_eq_one.mp (by simpa using hr.symm) + exact Subtype.ext hg + · rintro ⟨rfl,rfl⟩ + simp + +lemma diagonal_poly_coefficient (g h : diagonalStabilizer μ) : + tabloidRepresentation μ g.val (polytabloid μ) (tabloidOfPerm μ h.val) = + if g = h then (1 : ℂ) else 0 := by + rw [polytabloid, columnAnti_apply] + simp_rw [rep_basis, smul_tabloidOfPerm, mul_one] + rw [map_sum] + simp_rw [map_smul, rep_basis, smul_tabloidOfPerm] + simp only [Finset.sum_apply, Pi.smul_apply, tabloidBasis, Pi.single_apply] + have he (c : C μ) : tabloidOfPerm μ h.val = tabloidOfPerm μ (g.val*c.val) ↔ + g = h ∧ c = 1 := (eq_comm).trans (diagonal_tabloid_eq μ g h c) + simp only [he] + by_cases hgh : g = h + · simp [hgh] + · simp [hgh] + +theorem diagonal_polytabloids_independent : LinearIndependent ℂ + (fun g : diagonalStabilizer μ => spechtRep μ g.val (spechtPoly μ)) := by + apply LinearIndependent.of_comp (f := spechtInclude μ) + rw [Fintype.linearIndependent_iff] + intro a ha g + have he := congrFun ha (tabloidOfPerm μ g.val) + simp only [Finset.sum_apply, Pi.smul_apply, Function.comp_apply, Pi.zero_apply] at he + simp_rw [spechtInclude_rep, spechtInclude_poly, diagonal_poly_coefficient] at he + simpa using he + +theorem diagonal_card_le_dimension : Fintype.card (diagonalStabilizer μ) ≤ + Module.finrank ℂ (SpechtSpace μ) := by + let : Module.Finite ℂ (SpechtSpace μ) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace μ)) + exact (diagonal_polytabloids_independent μ).fintype_card_le_finrank + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable {X Y : Type*} [Fintype X] [Fintype Y] + +def fiberQuotientLabel (f : X → Y) : + (Equiv.Perm X ⧸ fiberStabilizer f) → (X → Y) := + Quotient.lift (fun (g : Equiv.Perm X) => fun x => f (g⁻¹ x)) (by + intro g h he + have he' := (QuotientGroup.leftRel_apply.mp he : g⁻¹*h ∈ fiberStabilizer f) + funext x + have hh := he' (h⁻¹ x) + simpa using hh) + +omit [Fintype X] [Fintype Y] in +lemma fiberQuotientLabel_injective (f : X → Y) : + Function.Injective (fiberQuotientLabel f) := by + intro a b + induction a using Quotient.inductionOn with | h g => + induction b using Quotient.inductionOn with | h h => + intro he + apply Quotient.sound + apply QuotientGroup.leftRel_apply.mpr + intro x + have hh := congrFun he (h x) + simpa [fiberQuotientLabel] using hh + +theorem factorial_le_colorings_mul_stabilizer (f : X → Y) : + (Fintype.card X).factorial ≤ + (Fintype.card Y)^(Fintype.card X) * Nat.card (fiberStabilizer f) := by + have hi : Nat.card (Equiv.Perm X ⧸ fiberStabilizer f) ≤ Nat.card (X → Y) := + Nat.card_le_card_of_injective (fiberQuotientLabel f) (fiberQuotientLabel_injective f) + have he := Subgroup.card_eq_card_quotient_mul_card_subgroup (fiberStabilizer f) + rw [Nat.card_eq_fintype_card, Fintype.card_perm] at he + simp only [Nat.card_eq_fintype_card, Fintype.card_fun] at hi + simp only [Nat.card_eq_fintype_card] at he ⊢ + rw [he] + exact Nat.mul_le_mul_right _ hi + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/EmptyGrid.lean b/lean/OAI/Probability/BinarySweep/GridBounds/EmptyGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..e15ce32ff1bf8efd2d9dee9c022cd27c3a09f123 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/EmptyGrid.lean @@ -0,0 +1,116 @@ +import Mathlib +import OAI.Probability.BinarySweep.Analytic.ComplexGrid +import OAI.Probability.BinarySweep.Conditional.MomentOperatorBound +import OAI.Probability.BinarySweep.Conditional.MainMomentInterface + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +variable {b : ℕ} (bits : Fin b → ℕ) + +def emptyPaths : PathFamily bits 0 where + position _ k := k.elim0 + disjoint _ := fun k => k.elim0 + changes_only_stage _ k := k.elim0 + +lemma emptyPaths_event (g : GridChoices bits) : pathEvent (emptyPaths bits) g := by + intro j k; exact k.elim0 + +def emptyFree (t : Fin (b+1)) : FreeSlot (emptyPaths bits) t ≃ GridSlot bits where + toFun := Subtype.val + invFun x := ⟨x,by rintro ⟨k,_⟩; exact k.elim0⟩ + left_inv _ := rfl + right_inv _ := rfl + +def emptyFrame : Equiv.Perm (GridSlot bits) := + (emptyFree bits (Fin.last b)).symm.trans + ((freeIdentification (emptyPaths bits)).symm.trans (emptyFree bits 0)) + +lemma emptyPerm (g : GridChoices bits) (hg : pathEvent (emptyPaths bits) g) : + (emptyFree bits 0).permCongr (remainingPerm (emptyPaths bits) g hg)= + emptyFrame bits * gridSweep bits g := by + ext x + rfl + +lemma empty_normalizer (z : ℝ) : conditionalNormalizer (emptyPaths bits) z=1 := by + simp only [conditionalNormalizer,emptyPaths_event,ite_true,gridWeight_sum] + +lemma empty_cost : pathCost (emptyPaths bits)=0 := by + have hh (j : Fin b) (y : GridOutside bits j) : lineHoles (emptyPaths bits) j y=0 := by + unfold lineHoles + exact Fintype.card_eq_zero + simp [pathCost,hh] + +lemma empty_operator {D : ℕ} + (ρ : Representation ℂ (Equiv.Perm (GridSlot bits)) (RepSpace D)) + (z : ℝ) (x : RepSpace D) : + conditionalOperator (emptyPaths bits) z + (ρ.comp (emptyFree bits 0).permCongrHom.toMonoidHom) x= + ρ (emptyFrame bits) (complexGridAverage bits ρ (z:ℂ) x) := by + rw [conditionalOperator_apply,empty_normalizer] + simp only [Complex.ofReal_one,inv_one,one_smul,dite_true,emptyPaths_event] + simp only [complexGridAverage,sum_apply,smul_apply, + complexGridWeight_real,map_sum,map_smul] + apply Finset.sum_congr rfl + intro g _ + congr 1 + change ρ ((emptyFree bits 0).permCongr (remainingPerm _ g _)) x= _ + rw [emptyPerm,map_mul] + rfl + +lemma empty_operator_norm {D : ℕ} + (ρ : Representation ℂ (Equiv.Perm (GridSlot bits)) (RepSpace D)) + (hρ : IsUnitaryRep ρ) (z : ℝ) : + ‖conditionalOperator (emptyPaths bits) z + (ρ.comp (emptyFree bits 0).permCongrHom.toMonoidHom)‖= + ‖complexGridAverage bits ρ (z:ℂ)‖ := by + apply ContinuousLinearMap.opNorm_ext + intro x + rw [empty_operator,hρ] + +theorem real_grid_bound : ∃ r : ℕ, 0 < r ∧ ∃ q : ℕ, 0 < q ∧ + ∃ a : ℝ, 0 < a ∧ ∀b : ℕ, 1 ≤ b → ∀bits : Fin b → ℕ, + (∀j, r ≤ bits j ∧ bits j ≤ 2*r) → ∀D : ℕ, + ∀ρ : Representation ℂ (Equiv.Perm (GridSlot bits)) (RepSpace D), + ρ.IsIrreducible → IsUnitaryRep ρ → ∀z : ℝ, 0 ≤ z → z ≤ a → + ‖complexGridAverage bits ρ (z:ℂ)‖ ≤ (D:ℝ)^(-c0/(2*q)) := by + obtain ⟨r,hr,q,hq,a,ha,h⟩ := conditional_moment_main + refine ⟨r,hr,q,hq,a,ha,?_⟩ + intro b hb bits hd D ρ hi hρ z hz hza + let := hi + let σ : Representation ℂ (Equiv.Perm (FreeSlot (emptyPaths bits) 0)) (RepSpace D) := ρ.comp (emptyFree bits 0).permCongrHom.toMonoidHom + have hiσ : σ.IsIrreducible := Irrep.irreducible_comp_equiv _ ρ + have huσ : IsUnitaryRep σ := fun g x => hρ _ x + have hlog := h b hb bits hd 0 (emptyPaths bits) z hz hza D σ hiσ huσ + simp only [Nat.cast_zero,mul_zero,zero_mul,add_zero,empty_cost,sub_zero] at hlog + have hop := opNorm_of_logMoment hq _ hlog + rw [empty_operator_norm bits ρ hρ z] at hop + have hD : 0 < D := by + simpa only [RepSpace,finrank_euclideanSpace,Fintype.card_fin] using + Signed.irreducible_finrank_pos ρ + have hD' : 0 < (D:ℝ) := by exact_mod_cast hD + have hc : c0 ≤ cExponent (gridSize bits) := by + unfold cExponent + exact le_add_of_nonneg_right (by positivity) + have hlogD : 0 ≤ Real.log D := Real.log_nonneg (by exact_mod_cast hD) + have hqe : 0 < (2:ℝ)*q := by positivity + have hh : (-cExponent (gridSize bits)*Real.log D)/(2*q) ≤ + (-c0/(2*q))*Real.log D := by + apply (div_le_iff₀ hqe).mpr + have := mul_le_mul_of_nonneg_right hc hlogD + field_simp + nlinarith + apply hop.trans + rw [Real.rpow_def_of_pos hD'] + apply Real.exp_le_exp.mpr + simpa only [mul_comm] using hh + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridBoardAverage.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridBoardAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..303a92f3ea873992e020860f1ca9a10041a8fbe2 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridBoardAverage.lean @@ -0,0 +1,105 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridChildAverage + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +open Signed Irrep Representation + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + {A : Type*} [Fintype A] [DecidableEq A] + +local instance : LinearOrder (GridSlot (rightBits bits)) := rowOrder bits +local instance : LinearOrder (GridSlot (leftBits bits)) := columnOrder bits + +def inputToJunction : FreeSlot H 0 ≃ Fin (junctionSize bits H) := + (rowReference bits H).trans (junctionEnum bits H) + +def junctionTensorRep (p : A → Bool) : + Representation ℂ (Equiv.Perm (FreeSlot H 0)) (TensorSpace A (junctionSize bits H)) := + (hilbertTensorRep p (junctionSize bits H)).comp + (inputToJunction bits H).permCongrHom.toMonoidHom + +def rowChildWeight (z : ℝ) (y : GridSlot (rightBits bits)) + (a : Equiv.Perm (Fin (Fintype.card (FreeSlot (rowFamily bits H y) 0)))) : ℂ := + conditionalGroupLaw (rowFamily bits H y) z ((Fintype.equivFin _).symm.permCongr a) + +def columnChildWeight (z : ℝ) (x : GridSlot (leftBits bits)) + (a : Equiv.Perm (Fin (Fintype.card (FreeSlot (columnFamily bits H x) 0)))) : ℂ := + conditionalGroupLaw (columnFamily bits H x) z ((Fintype.equivFin _).symm.permCongr a) + +def rowMatrix (p : A → Bool) (z : ℝ) := + groupedAverage (groupingOrder (rowGrouping bits H)) (groupingPerm (rowGrouping bits H)) p + (rowChildWeight bits H z) + +def columnMatrix (p : A → Bool) (z : ℝ) := + groupedAverage (groupingOrder (columnGrouping bits H)) (groupingPerm (columnGrouping bits H)) p + (columnChildWeight bits H z) + +lemma row_perm_to_junction (a : ∀y, Equiv.Perm (FreeSlot (rowFamily bits H y) 0)) : + (inputToJunction bits H).permCongr + ((rowInputEquiv bits H).symm.permCongr (Equiv.Perm.sigmaCongrRight a))= + (rowGrouping bits H).permCongr (Equiv.Perm.sigmaCongrRight a) := by + ext t + simp [inputToJunction,rowGrouping,Equiv.permCongr_apply] + +lemma column_perm_to_junction (a : ∀x, Equiv.Perm (FreeSlot (columnFamily bits H x) 0)) : + (inputToJunction bits H).permCongr + ((rowReference bits H).symm.permCongr + ((columnFreeEquiv bits H 0).symm.permCongr (Equiv.Perm.sigmaCongrRight a)))= + (columnGrouping bits H).permCongr (Equiv.Perm.sigmaCongrRight a) := by + ext t + simp [inputToJunction,columnGrouping,Equiv.permCongr_apply] + +lemma rowMatrix_linear (p : A → Bool) (z : ℝ) : + (rowMatrix bits H p z).toEuclideanLin= + ∑a : ∀y, Equiv.Perm (FreeSlot (rowFamily bits H y) 0), + (∏y, (conditionalGroupLaw (rowFamily bits H y) z (a y):ℂ)) • + hilbertTensorRep p _ ((rowGrouping bits H).permCongr (Equiv.Perm.sigmaCongrRight a)) := by + refine Eq.trans (groupedAverage_literal_linear (I := GridSlot (rightBits bits)) + (X := fun y => FreeSlot (rowFamily bits H y) 0) (N := junctionSize bits H) + (A := A) (rowGrouping bits H) p + (fun y a => (conditionalGroupLaw (rowFamily bits H y) z a : ℂ))) ?_ + apply Finset.sum_congr + · ext a; simp only [Finset.mem_univ] + · intro a _; rfl + +lemma columnMatrix_linear (p : A → Bool) (z : ℝ) : + (columnMatrix bits H p z).toEuclideanLin= + ∑a : ∀x, Equiv.Perm (FreeSlot (columnFamily bits H x) 0), + (∏x, (conditionalGroupLaw (columnFamily bits H x) z (a x):ℂ)) • + hilbertTensorRep p _ ((columnGrouping bits H).permCongr (Equiv.Perm.sigmaCongrRight a)) := by + refine Eq.trans (groupedAverage_literal_linear (I := GridSlot (leftBits bits)) + (X := fun x => FreeSlot (columnFamily bits H x) 0) (N := junctionSize bits H) + (A := A) (columnGrouping bits H) p + (fun x a => (conditionalGroupLaw (columnFamily bits H x) z a : ℂ))) ?_ + apply Finset.sum_congr + · ext a; simp only [Finset.mem_univ] + · intro a _; rfl + +theorem rowAverage_matrix (p : A → Bool) (z : ℝ) : + rowAverage bits H (junctionTensorRep bits H p) z=(rowMatrix bits H p z).toEuclideanLin := by + rw [rowAverage_child_laws,rowMatrix_linear] + apply Finset.sum_congr + · ext a; simp only [Finset.mem_univ] + intro a _ + congr 1 + +theorem columnAverage_matrix (p : A → Bool) (z : ℝ) : + columnAverage bits H (junctionTensorRep bits H p) z=(columnMatrix bits H p z).toEuclideanLin := by + rw [columnAverage_child_laws,columnMatrix_linear] + apply Finset.sum_congr + · ext a; simp only [Finset.mem_univ] + intro a _ + congr 1 + change hilbertTensorRep p _ ((inputToJunction bits H).permCongr _) = _ + rw [column_perm_to_junction] + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridChildAverage.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridChildAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..8128e9e55c47e13d3acb46bb6ed3baf0cf153576 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridChildAverage.lean @@ -0,0 +1,234 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GroupedMoments +import OAI.Probability.BinarySweep.GridBounds.GroupingGeometry +import OAI.Probability.BinarySweep.GridBounds.GridSplitFree +import OAI.Probability.BinarySweep.FiniteLaws.IndependentPush + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Representation + +lemma finitePush_conditional {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (a : Equiv.Perm (FreeSlot H 0)) : + finitePush (fun g : ConditionalChoices H => (conditionalChoiceWeight H z g:ℂ)) + (fun g => remainingPerm H g.val g.property) a = (conditionalGroupLaw H z a:ℂ) := by + simp only [finitePush,conditionalGroupLaw,Complex.ofReal_sum,apply_ite,Complex.ofReal_zero] + +lemma independentConditional_expectation {I : Type*} [Fintype I] + (b h : I → ℕ) (bits : ∀i, Fin (b i) → ℕ) (H : ∀i, PathFamily (bits i) (h i)) + {V : Type*} [AddCommMonoid V] [Module ℂ V] (z : ℝ) + (F : (∀i, Equiv.Perm (FreeSlot (H i) 0)) → V) : + (∑a, (∏i, (conditionalGroupLaw (H i) z (a i):ℂ)) • F a) = + ∑g : ∀i, ConditionalChoices (H i), + (∏i, (conditionalChoiceWeight (H i) z (g i):ℂ)) • + F (fun i => remainingPerm (H i) (g i).val (g i).property) := by + have he := independentPush_expectation + (fun i (g : ConditionalChoices (H i)) => (conditionalChoiceWeight (H i) z g:ℂ)) + (fun i (g : ConditionalChoices (H i)) => remainingPerm (H i) g.val g.property) F + simpa only [finitePush_conditional] using he + +private lemma sigma_relative {I X Y : Type*} {A B : I → Type*} + (e : X ≃ Σ i, A i) (f : Y ≃ Σ i, B i) (g r : ∀ i, A i ≃ B i) : + (e.trans ((Equiv.sigmaCongrRight g).trans f.symm)).trans + (e.trans ((Equiv.sigmaCongrRight r).trans f.symm)).symm = + e.symm.permCongr (Equiv.Perm.sigmaCongrRight (fun i => (g i).trans (r i).symm)) := by + ext x + simp [Equiv.permCongr_apply, Equiv.sigmaCongrRight, Equiv.Perm.sigmaCongrRight] + +namespace GridSplit +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +def rowInputEquiv : FreeSlot H 0 ≃ + Σy : GridSlot (rightBits bits), FreeSlot (rowFamily bits H y) 0 := rowFreeEquiv bits H 0 + +lemma rowRelative_sigma (g : RowSamples bits H) : + rowRelative bits H g = (rowInputEquiv bits H).symm.permCongr + (Equiv.Perm.sigmaCongrRight (fun y => + remainingPerm (rowFamily bits H y) (g y).val (g y).property)) := by + exact sigma_relative (rowFreeEquiv bits H 0) (rowFreeEquiv bits H (Fin.last m)) + (fun y => remainingBijection (rowFamily bits H y) (g y).val (g y).property) + (fun y => freeIdentification (rowFamily bits H y)) + +lemma columnRelative_sigma (g : ColumnSamples bits H) : + columnRelative bits H g = (columnFreeEquiv bits H 0).symm.permCongr + (Equiv.Perm.sigmaCongrRight (fun x => + remainingPerm (columnFamily bits H x) (g x).val (g x).property)) := by + exact sigma_relative (columnFreeEquiv bits H 0) (columnFreeEquiv bits H (Fin.last n)) + (fun x => remainingBijection (columnFamily bits H x) (g x).val (g x).property) + (fun x => freeIdentification (columnFamily bits H x)) + +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) + +omit [FiniteDimensional ℂ V] in +theorem rowAverage_child_laws (z : ℝ) : + rowAverage bits H ρ z = + ∑a : ∀y, Equiv.Perm (FreeSlot (rowFamily bits H y) 0), + (∏y, (conditionalGroupLaw (rowFamily bits H y) z (a y):ℂ)) • + ρ ((rowInputEquiv bits H).symm.permCongr (Equiv.Perm.sigmaCongrRight a)) := by + trans ∑g : RowSamples bits H, + (∏y, (conditionalChoiceWeight (rowFamily bits H y) z (g y):ℂ)) • + ρ ((rowInputEquiv bits H).symm.permCongr (Equiv.Perm.sigmaCongrRight + (fun y => remainingPerm (rowFamily bits H y) (g y).val (g y).property))) + · unfold rowAverage + apply Finset.sum_congr rfl + intro g _ + rw [rowRelative_sigma] + · let F : (∀y, Equiv.Perm (FreeSlot (rowFamily bits H y) 0)) → Module.End ℂ V := + fun a => ρ ((rowInputEquiv bits H).symm.permCongr (Equiv.Perm.sigmaCongrRight a)) + have he := independentConditional_expectation (I := GridSlot (rightBits bits)) (fun _ => m) + (fun y => Fintype.card (RowLabels bits H y)) (fun _ => leftBits bits) (rowFamily bits H) z + F + apply Eq.symm + refine Eq.trans ?_ (Eq.trans he ?_) + all_goals + apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + · intro g _; rfl + +omit [FiniteDimensional ℂ V] in +theorem columnAverage_child_laws (z : ℝ) : + columnAverage bits H ρ z = + ∑a : ∀x, Equiv.Perm (FreeSlot (columnFamily bits H x) 0), + (∏x, (conditionalGroupLaw (columnFamily bits H x) z (a x):ℂ)) • + ρ ((rowReference bits H).symm.permCongr + ((columnFreeEquiv bits H 0).symm.permCongr (Equiv.Perm.sigmaCongrRight a))) := by + trans ∑g : ColumnSamples bits H, + (∏x, (conditionalChoiceWeight (columnFamily bits H x) z (g x):ℂ)) • + ρ ((rowReference bits H).symm.permCongr + ((columnFreeEquiv bits H 0).symm.permCongr (Equiv.Perm.sigmaCongrRight + (fun x => remainingPerm (columnFamily bits H x) (g x).val (g x).property)))) + · unfold columnAverage + apply Finset.sum_congr rfl + intro g _ + rw [columnRelative_sigma] + · let F : (∀x, Equiv.Perm (FreeSlot (columnFamily bits H x) 0)) → Module.End ℂ V := + fun a => ρ ((rowReference bits H).symm.permCongr + ((columnFreeEquiv bits H 0).symm.permCongr (Equiv.Perm.sigmaCongrRight a))) + have he := independentConditional_expectation (I := GridSlot (leftBits bits)) (fun _ => n) + (fun x => Fintype.card (ColumnLabels bits H x)) (fun _ => rightBits bits) (columnFamily bits H) z + F + apply Eq.symm + refine Eq.trans ?_ (Eq.trans he ?_) + all_goals + apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + · intro g _; rfl + +end GridSplit +end BinaryCoordinateSweeps + +namespace BinaryCoordinateSweeps.GridSplit +open Signed + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +local instance rowOrder : LinearOrder (GridSlot (rightBits bits)) := + LinearOrder.lift' (Fintype.equivFin _) (Fintype.equivFin _).injective +local instance columnOrder : LinearOrder (GridSlot (leftBits bits)) := + LinearOrder.lift' (Fintype.equivFin _) (Fintype.equivFin _).injective + +abbrev Junction := FreeSlot H (rightTime (m:=m) 0) +abbrev junctionSize := Fintype.card (Junction bits H) + +def junctionEnum : Junction bits H ≃ Fin (junctionSize bits H) := Fintype.equivFin _ + +def physicalBoard : Fin (junctionSize bits H) ↪ + GridSlot (rightBits bits) × GridSlot (leftBits bits) where + toFun t := (rightSlot bits ((junctionEnum bits H).symm t).val, + leftSlot bits ((junctionEnum bits H).symm t).val) + inj' := by + intro t u he + apply (junctionEnum bits H).symm.injective + apply Subtype.ext + apply (slotEquiv bits).injective + exact Prod.ext (congrArg Prod.snd he) (congrArg Prod.fst he) + +def rowGrouping : (Σy : GridSlot (rightBits bits), FreeSlot (rowFamily bits H y) 0) ≃ + Fin (junctionSize bits H) := + (rowInputEquiv bits H).symm.trans ((rowReference bits H).trans (junctionEnum bits H)) + +def columnGrouping : (Σx : GridSlot (leftBits bits), FreeSlot (columnFamily bits H x) 0) ≃ + Fin (junctionSize bits H) := + (columnFreeEquiv bits H 0).symm.trans (junctionEnum bits H) + +lemma rowReference_right (a : FreeSlot H 0) : + rightSlot bits (rowReference bits H a).val=rightSlot bits a.val := by + exact right_join bits _ _ + +lemma rowGrouping_first (t : Fin (junctionSize bits H)) : + ((rowGrouping bits H).symm t).1=(physicalBoard bits H t).1 := by + change rightSlot bits ((rowReference bits H).symm ((junctionEnum bits H).symm t)).val = + rightSlot bits ((junctionEnum bits H).symm t).val + symm + simpa only [Equiv.apply_symm_apply] using + rowReference_right bits H ((rowReference bits H).symm ((junctionEnum bits H).symm t)) + +lemma columnGrouping_first (t : Fin (junctionSize bits H)) : + ((columnGrouping bits H).symm t).1=(physicalBoard bits H t).2 := rfl + +lemma physicalBoard_row (t : Fin (junctionSize bits H)) : + groupOf (groupingOrder (rowGrouping bits H)) (groupingPerm (rowGrouping bits H)) t= + (physicalBoard bits H t).1 := by + rw [grouping_groupOf,rowGrouping_first] + +lemma physicalBoard_column (t : Fin (junctionSize bits H)) : + groupOf (groupingOrder (columnGrouping bits H)) (groupingPerm (columnGrouping bits H)) t= + (physicalBoard bits H t).2 := by + rw [grouping_groupOf,columnGrouping_first] + +lemma junctionSize_eq : junctionSize bits H=gridSize bits-h := by + exact card_freeSlot H _ + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Signed +variable {I A : Type*} [Fintype I] [LinearOrder I] [Fintype A] [DecidableEq A] + {X : I → Type*} [∀i,Fintype (X i)] {N : ℕ} + +def finBlockPermEquiv : (∀i, Equiv.Perm (X i)) ≃ + (∀i, Equiv.Perm (Fin (Fintype.card (X i)))) := + Equiv.piCongrRight (fun i => (Fintype.equivFin (X i)).permCongr) + +theorem groupedAverage_literal (e : (Σi, X i) ≃ Fin N) (p : A → Bool) + (w : ∀i, Equiv.Perm (X i) → ℂ) : + groupedAverage (groupingOrder e) (groupingPerm e) p + (fun i a => w i ((Fintype.equivFin (X i)).symm.permCongr a)) = + ∑a : ∀i, Equiv.Perm (X i), (∏i, w i (a i)) • + actionMatrix p (e.permCongr (Equiv.Perm.sigmaCongrRight a)) := by + rw [groupedAverage_law,← (finBlockPermEquiv (X:=X)).sum_comp] + apply Finset.sum_congr rfl + intro a _ + rw [grouping_permutation] + have he (i : I) : (Fintype.equivFin (X i)).symm.permCongr + (finBlockPermEquiv a i)=a i := by + ext x + simp [finBlockPermEquiv,Equiv.permCongr_apply] + simp only [he] + rfl + +lemma groupedAverage_literal_linear (e : (Σi, X i) ≃ Fin N) (p : A → Bool) + (w : ∀i, Equiv.Perm (X i) → ℂ) : + (groupedAverage (groupingOrder e) (groupingPerm e) p + (fun i a => w i ((Fintype.equivFin (X i)).symm.permCongr a))).toEuclideanLin = + ∑a : ∀i, Equiv.Perm (X i), (∏i, w i (a i)) • + hilbertTensorRep p N (e.permCongr (Equiv.Perm.sigmaCongrRight a)) := by + rw [groupedAverage_literal] + simp only [map_sum,map_smul,actionMatrix_linear] + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridDenseCost.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridDenseCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..8839cc2342fe694dafc9380ec7642b24e2e5ba7e --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridDenseCost.lean @@ -0,0 +1,197 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridSplitCost + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation Signed + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +lemma sum_row_holes : ∑y, Fintype.card (RowLabels bits H y)=h := by + rw [←Fintype.card_sigma] + have he := Fintype.card_congr (Equiv.sigmaFiberEquiv (fun k : Fin h => rightSlot bits (H.position 0 k))) + exact he.trans (Fintype.card_fin h) + +lemma sum_column_holes : ∑x, Fintype.card (ColumnLabels bits H x)=h := by + rw [←Fintype.card_sigma] + have he := Fintype.card_congr (Equiv.sigmaFiberEquiv + (fun k : Fin h => leftSlot bits (H.position (rightTime (m:=m) 0) k))) + exact he.trans (Fintype.card_fin h) + +lemma child_error_sum (e : ℝ) : + (∑y, (e*Fintype.card (RowLabels bits H y)*Real.log (gridSize (leftBits bits))- + pathCost (rowFamily bits H y)))+ + (∑x, (e*Fintype.card (ColumnLabels bits H x)*Real.log (gridSize (rightBits bits))- + pathCost (columnFamily bits H x)))= + e*h*Real.log (gridSize bits)-pathCost H := by + rw [Finset.sum_sub_distrib,Finset.sum_sub_distrib,←Finset.sum_mul,←Finset.mul_sum, + ←Finset.sum_mul,←Finset.mul_sum,←Nat.cast_sum,←Nat.cast_sum, + sum_row_holes,sum_column_holes,pathCost_split,size_split,Nat.cast_mul, + Real.log_mul (by exact_mod_cast (gridSize_pos (leftBits bits)).ne') + (by exact_mod_cast (gridSize_pos (rightBits bits)).ne')] + ring + +lemma blockLogSize_le {I : Type*} [Fintype I] (f : I → ℕ) (s : ℕ) (hf : ∀i, f i ≤ s) : + blockLogSize f ≤ Fintype.card I*Real.log (s+1:ℝ) := by + calc + _ ≤ ∑_i : I, Real.log (s+1:ℝ) := by + apply Finset.sum_le_sum + intro i _ + exact Real.log_le_log (by positivity) (by exact_mod_cast Nat.add_le_add_right (hf i) 1) + _ = _ := by simp + +lemma blocksLog_le : + blockLogSize (rowFreeSize bits H)+blockLogSize (columnFreeSize bits H)≤ + (gridSize (rightBits bits):ℝ)*Real.log (gridSize (leftBits bits)+1:ℝ)+ + (gridSize (leftBits bits):ℝ)*Real.log (gridSize (rightBits bits)+1:ℝ) := by + have hr := blockLogSize_le (rowFreeSize bits H) (gridSize (leftBits bits)) (fun _ => by + rw [rowFreeSize,card_freeSlot] + exact Nat.sub_le _ _) + have hc := blockLogSize_le (columnFreeSize bits H) (gridSize (rightBits bits)) (fun _ => by + rw [columnFreeSize,card_freeSlot] + exact Nat.sub_le _ _) + simpa only [card_gridSlot] using add_le_add hr hc + +theorem conditional_hook_with_cost {t : ℕ} (ht : 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-c*typeF α+e*h*Real.log (gridSize bits)-pathCost H+c*h+ + (1+4*c+2*(q:ℝ))*(2*(t:ℝ))^2* + ((gridSize (rightBits bits):ℝ)*Real.log (gridSize (leftBits bits)+1:ℝ)+ + (gridSize (leftBits bits):ℝ)*Real.log (gridSize (rightBits bits)+1:ℝ))) := by + have hr : ∀y (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (rowFreeSize bits H y)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (rowChildWeight bits H z y))≤ + Real.exp (-c*typeF a.val+(e*Fintype.card (RowLabels bits H y)* + Real.log (gridSize (leftBits bits))-pathCost (rowFamily bits H y))) := by + intros; simpa only [add_sub_assoc] using hchildR _ _ + have hc' : ∀x (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (columnFreeSize bits H x)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (columnChildWeight bits H z x))≤ + Real.exp (-c*typeF a.val+(e*Fintype.card (ColumnLabels bits H x)* + Real.log (gridSize (rightBits bits))-pathCost (columnFamily bits H x))) := by + intros; simpa only [add_sub_assoc] using hchildC _ _ + refine (conditional_hook_dense_bound bits H ht α hα z hq c hc hcq _ _ hr hc').trans ?_ + apply Real.exp_le_exp.mpr + rw [add_assoc (-c*typeF α),child_error_sum] + have hb := mul_le_mul_of_nonneg_left (blocksLog_le bits H) + (by positivity : 0≤(1+4*c+2*(q:ℝ))*(2*(t:ℝ))^2) + linarith + +end BinaryCoordinateSweeps.GridSplit + +end + +open Filter Asymptotics +open scoped Topology + +namespace BinaryCoordinateSweeps + +def inductionGap (s : ℝ) : ℝ := 1 / (20 * Real.sqrt (Real.log s)) + +lemma dense_error_eventually : ∀ᶠ s : ℝ in atTop, + s ^ (9/10 : ℝ) + s ^ (199/200 : ℝ) * Real.log s ≤ + inductionGap s * s ^ (399/400 : ℝ) := by + have ho := isLittleO_log_rpow_rpow_atTop (3/2 : ℝ) (by norm_num : (0 : ℝ) < 1/400) + have he := ho.bound (by norm_num : (0 : ℝ) < 1/40) + filter_upwards [he, Real.tendsto_log_atTop.eventually_ge_atTop 1, + eventually_ge_atTop (1 : ℝ)] with s hs hl h1 + have hs0 : 0 < s := lt_of_lt_of_le zero_lt_one h1 + have hl0 : 0 < Real.log s := lt_of_lt_of_le zero_lt_one hl + have ht : (Real.log s) ^ (3/2 : ℝ) ≤ (1/40 : ℝ) * s ^ (1/400 : ℝ) := by + simpa only [Real.norm_of_nonneg (Real.rpow_nonneg hl0.le _), + Real.norm_of_nonneg (Real.rpow_nonneg hs0.le _)] using hs + have hl32 : Real.sqrt (Real.log s) * Real.log s = (Real.log s) ^ (3/2 : ℝ) := by + rw [Real.sqrt_eq_rpow] + calc + (Real.log s) ^ (1/2 : ℝ) * Real.log s = + (Real.log s) ^ (1/2 : ℝ) * (Real.log s) ^ (1 : ℝ) := by rw [Real.rpow_one] + _ = (Real.log s) ^ (3/2 : ℝ) := by rw [← Real.rpow_add hl0]; norm_num + have hpow : s ^ (9/10 : ℝ) ≤ s ^ (199/200 : ℝ) := + Real.rpow_le_rpow_of_exponent_le h1 (by norm_num) + have hpow0 : 0 ≤ s ^ (199/200 : ℝ) := Real.rpow_nonneg hs0.le _ + have hsq0 : 0 < Real.sqrt (Real.log s) := Real.sqrt_pos.mpr hl0 + unfold inductionGap + rw [div_mul_eq_mul_div, one_mul] + apply (le_div_iff₀ (by positivity : 0 < 20 * Real.sqrt (Real.log s))).mpr + calc + (s ^ (9/10 : ℝ) + s ^ (199/200 : ℝ) * Real.log s) * + (20 * Real.sqrt (Real.log s)) ≤ + (2 * s ^ (199/200 : ℝ) * Real.log s) * (20 * Real.sqrt (Real.log s)) := by + gcongr + nlinarith + _ = 40 * s ^ (199/200 : ℝ) * (Real.log s) ^ (3/2 : ℝ) := by + rw [← hl32] + ring + _ ≤ 40 * s ^ (199/200 : ℝ) * ((1/40 : ℝ) * s ^ (1/400 : ℝ)) := by gcongr + _ = s ^ (399/400 : ℝ) := by + rw [show 40 * s ^ (199/200 : ℝ) * ((1/40 : ℝ) * s ^ (1/400 : ℝ)) = + s ^ (199/200 : ℝ) * s ^ (1/400 : ℝ) by ring, ← Real.rpow_add hs0] + norm_num + +theorem dense_induction_absorption_eventually (C : ℝ) : ∀ᶠ s : ℕ in atTop, + ∀ b h k F G J : ℝ, 0 ≤ h → 0 ≤ k → 0 ≤ J → + Real.log 4 * b ≤ (1/1000 : ℝ) * Real.log s → + F ≤ G + k * Real.log s → + (s : ℝ) ^ (399/400 : ℝ) ≤ F → + ((s : ℝ) ^ (199/200 : ℝ) ≤ k → + k * ((1/200 : ℝ) * Real.log s - C) ≤ J) → + -(cExponent s + inductionGap s) * G + + (eExponent s - inductionGap s) * (h+k) * Real.log s + + (s : ℝ) ^ (9/10 : ℝ) + Real.log 4 * k * b - J ≤ + -cExponent s * F + eExponent s * h * Real.log s := by + have hlim : Tendsto (fun s : ℕ => (s : ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have hloglim := Real.tendsto_log_atTop.comp hlim + filter_upwards [hlim.eventually dense_error_eventually, + hloglim.eventually_ge_atTop (max 1 (1000*C))] with s herr hlarge + have hl : 1 ≤ Real.log s := (le_max_left _ _).trans hlarge + have hC : 1000*C ≤ Real.log s := (le_max_right _ _).trans hlarge + have hl0 : 0 < Real.log s := by linarith + have hg0 : 0 < inductionGap s := by unfold inductionGap; positivity + have hc0 : 0 ≤ cExponent s + inductionGap s := by unfold cExponent c0; positivity + intro b h k F G J hh hk hJ hb hdim hF hremoved + have hce : cExponent s + inductionGap s + (eExponent s - inductionGap s) = + (1/5000 : ℝ) := by unfold cExponent eExponent c0 e0; ring + have hextra : (1/5000 : ℝ) * k * Real.log s + Real.log 4 * k * b - J ≤ + (s : ℝ) ^ (199/200 : ℝ) * Real.log s := by + by_cases hbig : (s : ℝ) ^ (199/200 : ℝ) ≤ k + · have hpay := hremoved hbig + have hb' := mul_le_mul_of_nonneg_left hb hk + have hcost : (1/5000 : ℝ) * k * Real.log s + Real.log 4 * k * b - J ≤ 0 := by + have hcoef : (1/5000 : ℝ) * Real.log s + (1/1000 : ℝ) * Real.log s ≤ + (1/200 : ℝ) * Real.log s - C := by nlinarith + have hcoef' := mul_le_mul_of_nonneg_left hcoef hk + nlinarith + exact hcost.trans (mul_nonneg (Real.rpow_nonneg (Nat.cast_nonneg s) _) hl0.le) + · have hk' : k ≤ (s : ℝ) ^ (199/200 : ℝ) := (lt_of_not_ge hbig).le + have hb' := mul_le_mul_of_nonneg_left hb hk + have hkl := mul_le_mul_of_nonneg_right hk' hl0.le + have hkl0 := mul_nonneg hk hl0.le + nlinarith + have hce' := congrArg (fun t : ℝ => t * k * Real.log s) hce + have hdim' := mul_le_mul_of_nonneg_left hdim hc0 + have hsave := mul_le_mul_of_nonneg_left hF hg0.le + have hholes := mul_nonneg (mul_nonneg hg0.le hh) hl0.le + nlinarith + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridLaw.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b2a78979e0cc6385d9b4316bcb375d93a8e1d10 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridLaw.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Probability.BinarySweep.Analytic.OneAxis +import OAI.Probability.BinarySweep.GridBounds.BoardLaw +import OAI.Probability.BinarySweep.Mixing.BinarySplitChoices + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +open GridSplit + +def gridLaw {b : ℕ} (bits : Fin b → ℕ) : Equiv.Perm (GridSlot bits) → ℝ := + pushLaw (gridWeight bits 1) (gridSweep bits) + +lemma pushLaw_inverse {A B : Type*} [Fintype A] [Fintype B] + (e : A ≃ B) (p : A → ℝ) : pushLaw (pushLaw p e) e.symm=p := by + rw [pushLaw_comp] + have he : e.symm ∘ e = id := funext e.symm_apply_apply + rw [he,pushLaw_id] + +lemma pushLaw_injective {A B : Type*} [Fintype A] [Fintype B] + (e : A ≃ B) : Function.Injective (fun p : A → ℝ => pushLaw p e) := by + intro p q he + have hh := congrArg (fun w => pushLaw w e.symm) he + simpa only [pushLaw_inverse] using hh + +lemma binary_splitLaw (m n : ℕ) : + pushLaw (binaryLaw (m+n)) Signed.splitWord.permCongr= + boardLaw (binaryLaw m) (binaryLaw n) := by + unfold binaryLaw + rw [finiteLaw_pushLaw,finiteLaw_pushLaw,finiteLaw_pushLaw,pushLaw_comp] + let e := BinarySplit.choicesEquiv (m:=m) (n:=n) + have hs : Signed.splitWord.permCongr ∘ binarySweep (m+n)= + (fun LR : (Slot n → SweepCoins m) × (Slot m → SweepCoins n) => + columnPerm (binarySweep n ∘ LR.2)*rowPerm (binarySweep m ∘ LR.1)) ∘ e := + funext BinarySplit.binarySweep_split + rw [hs,←uniformLaw_equiv e,pushLaw_equiv] + have hu : uniformLaw ((Slot n → SweepCoins m)×(Slot m → SweepCoins n))= + fun LR => (∏y,uniformLaw (SweepCoins m) (LR.1 y))* + (∏x,uniformLaw (SweepCoins n) (LR.2 x)) := by + rw [uniformLaw_prod] + simp only [uniformLaw_pi (I:=Slot n) (A:=fun _ => SweepCoins m), + uniformLaw_pi (I:=Slot m) (A:=fun _ => SweepCoins n)] + rw [hu] + exact boardSampleLaw _ _ _ _ + +lemma grid_splitLaw {m n : ℕ} (bits : Fin (m+n) → ℕ) : + pushLaw (gridLaw bits) (slotEquiv (m:=m) (n:=n) bits).permCongr= + boardLaw (gridLaw (leftBits (m:=m) (n:=n) bits)) (gridLaw (rightBits (m:=m) (n:=n) bits)) := by + let : DecidableEq (GridSlot (leftBits (m:=m) (n:=n) bits)) := inferInstance + let : DecidableEq (GridSlot (rightBits (m:=m) (n:=n) bits)) := inferInstance + let : Fintype (GridChoices (leftBits (m:=m) (n:=n) bits)) := inferInstance + let : Fintype (GridChoices (rightBits (m:=m) (n:=n) bits)) := inferInstance + unfold gridLaw + rw [pushLaw_comp] + exact board_equiv_sample + (gridWeight (leftBits (m:=m) (n:=n) bits) 1) + (gridWeight (rightBits (m:=m) (n:=n) bits) 1) + (gridSweep (leftBits (m:=m) (n:=n) bits)) + (gridSweep (rightBits (m:=m) (n:=n) bits)) + (GridSplit.choicesEquiv (m:=m) (n:=n) bits) _ _ + (gridWeight_split (m:=m) (n:=n) bits 1) (gridSweep_split (m:=m) (n:=n) bits) + +lemma oneAxis_gridLaw (bits : Fin 1 → ℕ) : + pushLaw (gridLaw bits) (oneAxisSlotEquiv bits).permCongr=binaryLaw (bits 0) := by + unfold gridLaw + rw [pushLaw_comp] + have hw : gridWeight bits 1=binaryLaw (bits 0) ∘ oneAxisChoiceEquiv bits := by + funext c + simp [oneAxis_gridWeight,lineLaw] + have hs : (oneAxisSlotEquiv bits).permCongr ∘ gridSweep bits=oneAxisChoiceEquiv bits := by + funext c + rw [Function.comp_apply,←oneAxisSweepEquiv_apply] + exact (oneAxisSlotEquiv bits).permCongr.apply_symm_apply _ + rw [hw,hs] + have hh := pushLaw_equiv (oneAxisChoiceEquiv bits) (binaryLaw (bits 0)) id + simpa only [Function.id_comp,pushLaw_id] using hh + +theorem gridLaw_binary : ∀b : ℕ, 1≤b → ∀bits : Fin b → ℕ, + ∃d : ℕ, d=∑j,bits j ∧ ∃e : GridSlot bits ≃ Slot d, + pushLaw (gridLaw bits) e.permCongr=binaryLaw d := by + intro b + induction b using Nat.case_strong_induction_on with + | hz => intro hb; omega + | hi b ih => + intro hb bits + by_cases hb0 : b=0 + · subst b + exact ⟨bits 0,by simp,oneAxisSlotEquiv bits,oneAxis_gridLaw bits⟩ + obtain ⟨dL,hdL,eL,heL⟩ := ih b (by omega) (by omega) (leftBits (n:=1) bits) + let eR := oneAxisSlotEquiv (rightBits (m:=b) bits) + have heR := oneAxis_gridLaw (rightBits (m:=b) bits) + let dR := rightBits (m:=b) (n:=1) bits 0 + let ep := Equiv.prodCongr eL eR + let e := ((slotEquiv (m:=b) (n:=1) bits).trans ep).trans Signed.splitWord.symm + refine ⟨dL+dR,?_,e,?_⟩ + · rw [Fin.sum_univ_add,←hdL] + simp [dR] + · apply pushLaw_injective Signed.splitWord.permCongr + change pushLaw (pushLaw (gridLaw bits) e.permCongr) Signed.splitWord.permCongr= + pushLaw (binaryLaw (dL+dR)) Signed.splitWord.permCongr + rw [binary_splitLaw,pushLaw_comp] + have he : Signed.splitWord.permCongr ∘ e.permCongr= + ep.permCongr ∘ (slotEquiv (m:=b) (n:=1) bits).permCongr := by + funext σ + apply Equiv.ext + intro xy + simp [e,Equiv.permCongr_apply] + let : DecidableEq (GridSlot (leftBits (m:=b) (n:=1) bits) × GridSlot (rightBits (m:=b) (n:=1) bits)) := inferInstance + rw [he,←pushLaw_comp (gridLaw bits) (slotEquiv (m:=b) (n:=1) bits).permCongr ep.permCongr] + rw [grid_splitLaw (m:=b) (n:=1)] + change pushLaw (boardLaw _ _) (Equiv.prodCongr eL eR).permCongr = _ + rw [boardLaw_congr eL eR,heL,heR] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridProjectedMoment.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridProjectedMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..153d2c95198354c94900a16068d6631fc7ead568 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridProjectedMoment.lean @@ -0,0 +1,191 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.ProjectionSplitting +import OAI.Probability.BinarySweep.GridBounds.GroupedLogBounds +import OAI.Probability.BinarySweep.GridBounds.GridBoardAverage +import OAI.Probability.BinarySweep.FiniteLaws.SampleMoment + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation Signed TraceHolder Density + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + {A : Type*} [Fintype A] [DecidableEq A] + +local instance : LinearOrder (GridSlot (rightBits bits)) := rowOrder bits +local instance : LinearOrder (GridSlot (leftBits bits)) := columnOrder bits + +def junctionAverage (p : A → Bool) (z : ℝ) := + sampleMatrix p (fun a => (conditionalGroupLaw H z a:ℂ)) (inputToJunction bits H).permCongr + +def junctionFrame (p : A → Bool) := + actionMatrix p ((inputToJunction bits H).permCongr (framePermutation bits H)) + +lemma junctionAverage_linear (p : A → Bool) (z : ℝ) : + (junctionAverage bits H p z).toEuclideanLin= + groupAverage (junctionTensorRep bits H p) (fun a => (conditionalGroupLaw H z a:ℂ)) := by + exact sampleMatrix_linear p _ _ + +lemma junctionAverage_split (p : A → Bool) (z : ℝ) : + junctionAverage bits H p z=junctionFrame bits H p*columnMatrix bits H p z*rowMatrix bits H p z := by + apply Matrix.toEuclideanLin.injective + rw [junctionAverage_linear,groupAverage_split,rowAverage_matrix,columnAverage_matrix] + simp only [Matrix.toLpLin_mul_same,←Module.End.mul_eq_comp,junctionFrame,actionMatrix_linear] + rfl + +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm (Fin (junctionSize bits H))) V) + +omit [FiniteDimensional ℂ V] in +lemma projection_commutes_column (p : A → Bool) (z : ℝ) : + isotypicProjection p ρ*columnMatrix bits H p z=columnMatrix bits H p z*isotypicProjection p ρ := by + unfold columnMatrix + rw [groupedAverage_law] + simp only [Finset.mul_sum,Finset.sum_mul,mul_smul_comm,smul_mul_assoc,typeProjection_commutes_action] + +omit [FiniteDimensional ℂ V] in +lemma junction_projected_moment (p : A → Bool) (z : ℝ) (q : ℕ) : + matrixMoment q (isotypicProjection p ρ*junctionAverage bits H p z)= + matrixMoment q (columnMatrix bits H p z*isotypicProjection p ρ*rowMatrix bits H p z) := by + rw [junctionAverage_split,←mul_assoc,←mul_assoc] + have hu : isotypicProjection p ρ*junctionFrame bits H p= + junctionFrame bits H p*isotypicProjection p ρ := typeProjection_commutes_action p ρ _ + rw [hu,mul_assoc (junctionFrame bits H p),projection_commutes_column, + mul_assoc (junctionFrame bits H p)] + rw [matrixMoment_linear,matrixMoment_linear,Matrix.toLpLin_mul_same, + ←Module.End.mul_eq_comp] + apply evenMoment_unitary_left + change (Matrix.toEuclideanLin (junctionFrame bits H p)).adjoint* + Matrix.toEuclideanLin (junctionFrame bits H p)=1 + unfold junctionFrame + rw [actionMatrix_linear,unitary_rep_adjoint _ (hilbertTensorRep_unitary p),←map_mul, + inv_mul_cancel,map_one] + +theorem conditional_le_junction [ρ.IsIrreducible] + (hρ : ∀g v, ‖ρ g v‖=‖v‖) (p : A → Bool) + (hocc : 0 (conditionalGroupLaw H z a:ℂ)))≤ + matrixMoment q (columnMatrix bits H p z*isotypicProjection p ρ*rowMatrix bits H p z) := by + rw [←junction_projected_moment bits H ρ p z q] + exact sampleMoment_le_projected p ρ hρ hocc _ _ hq + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.Signed +open Irrep Representation TraceHolder + +variable {A I J : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + [Fintype I] [LinearOrder I] [Nonempty I] [Fintype J] [LinearOrder J] + {n : I → ℕ} {m : J → ℕ} {N : ℕ} + +def typeF {n : ℕ} (α : n.Partition) : ℝ := Real.log (Module.finrank ℂ (Young.PartitionHilbert α):ℝ) + +def blockLogSize {I : Type*} [Fintype I] (n : I → ℕ) : ℝ := ∑i, Real.log (n i+1:ℝ) + +omit [Nonempty A] [Nonempty I] in +lemma blockActive_card_exp (p : A → Bool) : + (Fintype.card (∀i, ActiveType p (n i)):ℝ)≤ + Real.exp ((Fintype.card A:ℝ)^2*blockLogSize n) := by + have hc : (Fintype.card (∀i, ActiveType p (n i)):ℝ)≤∏i,(n i+1:ℝ)^((Fintype.card A)^2) := by + exact_mod_cast blockActive_card (n:=n) p + refine hc.trans_eq ?_ + rw [blockLogSize,Finset.mul_sum,Real.exp_sum] + apply Finset.prod_congr rfl + intro i _ + exact_mod_cast natShift_pow_exp (n i) ((Fintype.card A)^2) + +theorem grouped_dense_bound + {W : Type*} [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (board : Fin N ↪ I × J) (p : A → Bool) + (eR : (Σₗ i, Fin (n i)) ≃o Fin N) (eC : (Σₗ j, Fin (m j)) ≃o Fin N) + (gR gC : Equiv.Perm (Fin N)) + (hR : ∀t, groupOf eR gR t=(board t).1) (hC : ∀t, groupOf eC gC t=(board t).2) + (ρ : Representation ℂ (Equiv.Perm (Fin N)) W) [ρ.IsIrreducible] + (wR : ∀i, Equiv.Perm (Fin (n i)) → ℂ) (wC : ∀j, Equiv.Perm (Fin (m j)) → ℂ) + {q : ℕ} (hq : 0 + groupedProjection eR gR p (fun i => Young.partitionHilbertRep (a i).val) + let C := fun a : ∀j, ActiveType p (m j) => + groupedProjection eC gC p (fun j => Young.partitionHilbertRep (a j).val) + let FR := fun a : ∀i, ActiveType p (n i) => ∑i, typeF (a i).val + let FC := fun a : ∀j, ActiveType p (m j) => ∑j, typeF (a j).val + let L := blockLogSize n+blockLogSize m + let D : ℝ := (Fintype.card A:ℝ)^2 + let E := (∑i, ER i)+(∑j, EC j)+D*L + have hchild (a : ∀i, ActiveType p (n i)) (b : ∀j, ActiveType p (m j)) : + matrixMoment q (groupedAverage eC gC p wC*C b)* + matrixMoment q (R a*groupedAverage eR gR p wR)≤Real.exp (-c*(FR a+FC b)+E) := by + have hr := grouped_projected_exp_bound eR gR p + (fun i => Young.partitionHilbertRep (a i).val) + (fun i => Young.partitionHilbertRep_unitary (a i).val) wR hq + (fun i => -c*typeF (a i).val+ER i) (fun i => hchildR i (a i)) + have ht := grouped_projected_exp_bound eC gC p + (fun j => Young.partitionHilbertRep (b j).val) + (fun j => Young.partitionHilbertRep_unitary (b j).val) wC hq + (fun j => -c*typeF (b j).val+EC j) (fun j => hchildC j (b j)) + rw [groupedProjection_commutes_average] at ht + refine (mul_le_mul ht hr (matrixMoment_nonneg _ _) (Real.exp_pos _).le).trans_eq ?_ + rw [←Real.exp_add] + congr 1 + simp only [FR,FC,E,D,L,blockLogSize,Finset.sum_add_distrib, + ←Finset.mul_sum,Nat.cast_pow] + ring + have ho (a : ∀i, ActiveType p (n i)) (b : ∀j, ActiveType p (m j)) : + ‖C b*isotypicProjection p ρ*R a‖^2≤Real.exp + (FR a+FC b-Real.log (Module.finrank ℂ W:ℝ)+ + (Fintype.card I*Fintype.card J-(N:ℝ))+4*D*L) := by + exact actual_board_overlap_exp board p eR eC gR gC hR hC ρ + (fun i => Young.partitionHilbertRep (a i).val) (fun j => Young.partitionHilbertRep (b j).val) + have hk (a : ∀i, ActiveType p (n i)) (b : ∀j, ActiveType p (m j)) : + ‖C b*isotypicProjection p ρ*R a‖≤1 := + groupedProjection_overlap_contract eR eC gR gC p ρ + (fun i => Young.partitionHilbertRep (a i).val) (fun j => Young.partitionHilbertRep (b j).val) + have hb := matrixMoment_dense_exponential hq (groupedAverage eR gR p wR) + (groupedAverage eC gC p wC) (isotypicProjection p ρ) R C + (fun a => groupedProjection_idempotent eR gR p _) (fun b => groupedProjection_idempotent eC gC p _) + (groupedActive_projection_sum eR gR p) (groupedActive_projection_sum eC gC p) + FR FC c (Real.log (Module.finrank ℂ W:ℝ)) (Fintype.card I*Fintype.card J-(N:ℝ)) + E (4*D*L) hc hcq hchild ho hk + have hn : ((Fintype.card (∀i, ActiveType p (n i))*Fintype.card (∀j, ActiveType p (m j)):ℕ):ℝ) ≤ + Real.exp (D*L) := by + rw [Nat.cast_mul] + refine (mul_le_mul (blockActive_card_exp (n:=n) p) (blockActive_card_exp (n:=m) p) + (by positivity) (Real.exp_pos _).le).trans_eq ?_ + rw [←Real.exp_add] + congr 1 + dsimp [D,L] + ring + refine hb.trans ((mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) hn (2*q)) + (Real.exp_pos _).le).trans_eq ?_) + rw [←Real.exp_nat_mul,←Real.exp_add] + congr 1 + dsimp [E,D,L] + push_cast + ring + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridSplit.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..f36bc4d72da97ce993b9b72c39650688bc91e308 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplit.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.Trajectory + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) + +abbrev leftBits : Fin m → ℕ := fun i => bits (i.castAdd n) +abbrev rightBits : Fin n → ℕ := fun i => bits (i.natAdd m) +def leftSlot (x : GridSlot bits) : GridSlot (leftBits bits) := fun i => x (i.castAdd n) +def rightSlot (x : GridSlot bits) : GridSlot (rightBits bits) := fun i => x (i.natAdd m) +def joinSlot (x : GridSlot (leftBits bits)) (y : GridSlot (rightBits bits)) : GridSlot bits := + Fin.addCases x y + +def slotEquiv : GridSlot bits ≃ GridSlot (leftBits bits) × GridSlot (rightBits bits) where + toFun x := (leftSlot bits x,rightSlot bits x) + invFun xy := joinSlot bits xy.1 xy.2 + left_inv x := by + funext i + induction i using Fin.addCases with + | left i => simp [joinSlot,leftSlot] + | right i => simp [joinSlot,rightSlot] + right_inv xy := by + apply Prod.ext <;> funext i + · simp [leftSlot,joinSlot] + · simp [rightSlot,joinSlot] + +lemma size_split : gridSize bits=gridSize (leftBits bits)*gridSize (rightBits bits) := by + rw [← card_gridSlot, Fintype.card_congr (slotEquiv bits),Fintype.card_prod, + card_gridSlot,card_gridSlot] + +def leftTime (t : Fin (m+1)) : Fin (m+n+1) := ⟨t.val,by omega⟩ +def rightTime (t : Fin (n+1)) : Fin (m+n+1) := ⟨m+t.val,by omega⟩ + +variable (H : PathFamily bits h) + +lemma rightSlot_leftTime (t : Fin (m+1)) (k : Fin h) : + rightSlot bits (H.position (leftTime t) k)=rightSlot bits (H.position 0 k) := by + funext i + unfold rightSlot + have he := trajectory_coordinates (fun t => H.position t k) + (fun j i hi => H.changes_only_stage j k i hi) (leftTime t) (i.natAdd m) + rw [ite_eq_right (show ¬(i.natAdd m).val < (leftTime t).val from by + change ¬m+i.val H.position t k) + (fun j i hi => H.changes_only_stage j k i hi) (rightTime u) (i.castAdd n) + rw [ite_eq_left (show (i.castAdd n).val < (rightTime u).val from by + change i.val < m + u.val; omega)] at he + exact he + exact (he t).trans (he 0).symm + +abbrev RowLabels (y : GridSlot (rightBits bits)) := + {k : Fin h // rightSlot bits (H.position 0 k)=y} +abbrev ColumnLabels (x : GridSlot (leftBits bits)) := + {k : Fin h // leftSlot bits (H.position (rightTime (m:=m) 0) k)=x} + +noncomputable instance rowLabelsFintype (y : GridSlot (rightBits bits)) : + Fintype (RowLabels bits H y) := Fintype.ofFinite _ +noncomputable instance columnLabelsFintype (x : GridSlot (leftBits bits)) : + Fintype (ColumnLabels bits H x) := Fintype.ofFinite _ + +def rowFamily (y : GridSlot (rightBits bits)) : + PathFamily (leftBits bits) (Fintype.card (RowLabels bits H y)) where + position t k := leftSlot bits (H.position (leftTime t) ((Fintype.equivFin (RowLabels bits H y)).symm k).val) + disjoint t a b he := by + apply (Fintype.equivFin (RowLabels bits H y)).symm.injective + apply Subtype.ext + apply H.disjoint (leftTime t) + apply (slotEquiv bits).injective + apply Prod.ext + · exact he + · change rightSlot bits (H.position (leftTime t) _) = rightSlot bits (H.position (leftTime t) _) + simp only [rightSlot_leftTime] + exact ((Fintype.equivFin (RowLabels bits H y)).symm a).property.trans + ((Fintype.equivFin (RowLabels bits H y)).symm b).property.symm + changes_only_stage j k i hi := by + change H.position (leftTime j.succ) _ (i.castAdd n) = H.position (leftTime j.castSucc) _ (i.castAdd n) + exact H.changes_only_stage (j.castAdd n) _ (i.castAdd n) + (fun he => hi (Fin.ext (congrArg (fun q : Fin (m+n) => q.val) he))) + +def columnFamily (x : GridSlot (leftBits bits)) : + PathFamily (rightBits bits) (Fintype.card (ColumnLabels bits H x)) where + position t k := rightSlot bits (H.position (rightTime t) ((Fintype.equivFin (ColumnLabels bits H x)).symm k).val) + disjoint t a b he := by + apply (Fintype.equivFin (ColumnLabels bits H x)).symm.injective + apply Subtype.ext + apply H.disjoint (rightTime t) + apply (slotEquiv bits).injective + apply Prod.ext + · change leftSlot bits (H.position (rightTime t) _) = leftSlot bits (H.position (rightTime t) _) + simp only [leftSlot_rightTime] + exact ((Fintype.equivFin (ColumnLabels bits H x)).symm a).property.trans + ((Fintype.equivFin (ColumnLabels bits H x)).symm b).property.symm + · exact he + changes_only_stage j k i hi := by + change H.position (rightTime j.succ) _ (i.natAdd m) = H.position (rightTime j.castSucc) _ (i.natAdd m) + exact H.changes_only_stage (j.natAdd m) _ (i.natAdd m) + (fun he => hi (Fin.ext (by have hh := congrArg (fun q : Fin (m+n) => q.val) he; simpa using hh))) + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +variable {m n : ℕ} (bits : Fin (m+n) → ℕ) + +def fillSlot {b : ℕ} (a : Fin b → ℕ) (j : Fin b) (u : GridOutside a j) : GridSlot a := + (Equiv.piSplitAt j (fun i => Slot (a i))).symm (fun _ => false,u) + +lemma fillSlot_other {b : ℕ} (a : Fin b → ℕ) (j : Fin b) (u : GridOutside a j) + (i : Fin b) (hi : i≠j) : fillSlot a j u i=u ⟨i,hi⟩ := by + simp [fillSlot,Equiv.piSplitAt,hi] + +def leftOutsideEquiv (j : Fin m) : + GridOutside bits (j.castAdd n) ≃ GridSlot (rightBits bits) × GridOutside (leftBits bits) j where + toFun u := (fun i => u ⟨i.natAdd m,by intro h; have hh := congrArg (fun q:Fin (m+n) => q.val) h; simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega⟩, + fun i => u ⟨i.val.castAdd n,fun h => i.property (Fin.ext (congrArg (fun q:Fin (m+n) => q.val) h))⟩) + invFun yu i := joinSlot bits (fillSlot (leftBits bits) j yu.2) yu.1 i.val + left_inv u := by + funext i + rcases i with ⟨i,hi⟩ + revert hi + induction i using Fin.addCases with + | left i => + intro hi + have hij : i≠j := fun h => hi (congrArg (Fin.castAdd n) h) + simp only [joinSlot,Fin.addCases_left,fillSlot_other _ _ _ _ hij] + | right i => intro hi; simp only [joinSlot,Fin.addCases_right] + right_inv yu := by + apply Prod.ext + · funext i + simp only [joinSlot,Fin.addCases_right] + · funext i + simp only [joinSlot,Fin.addCases_left,fillSlot_other _ _ _ _ i.property] + +def rightOutsideEquiv (j : Fin n) : + GridOutside bits (j.natAdd m) ≃ GridSlot (leftBits bits) × GridOutside (rightBits bits) j where + toFun u := (fun i => u ⟨i.castAdd n,by intro h; have hh := congrArg (fun q:Fin (m+n) => q.val) h; simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega⟩, + fun i => u ⟨i.val.natAdd m,fun h => i.property (Fin.ext (by have hh := congrArg (fun q:Fin (m+n) => q.val) h; simpa using hh))⟩) + invFun xu i := joinSlot bits xu.1 (fillSlot (rightBits bits) j xu.2) i.val + left_inv u := by + funext i + rcases i with ⟨i,hi⟩ + revert hi + induction i using Fin.addCases with + | left i => intro hi; simp only [joinSlot,Fin.addCases_left] + | right i => + intro hi + have hij : i≠j := fun h => hi (congrArg (Fin.natAdd m) h) + simp only [joinSlot,Fin.addCases_right,fillSlot_other _ _ _ _ hij] + right_inv xu := by + apply Prod.ext + · funext i + simp only [joinSlot,Fin.addCases_left] + · funext i + simp only [joinSlot,Fin.addCases_right,fillSlot_other _ _ _ _ i.property] + +def rowChoices (g : GridChoices bits) (y : GridSlot (rightBits bits)) : GridChoices (leftBits bits) := + fun j u => g (j.castAdd n) ((leftOutsideEquiv bits j).symm (y,u)) +def columnChoices (g : GridChoices bits) (x : GridSlot (leftBits bits)) : GridChoices (rightBits bits) := + fun j u => g (j.natAdd m) ((rightOutsideEquiv bits j).symm (x,u)) + +def joinChoices (L : GridSlot (rightBits bits) → GridChoices (leftBits bits)) + (R : GridSlot (leftBits bits) → GridChoices (rightBits bits)) : GridChoices bits := + Fin.addCases (fun j u => L ((leftOutsideEquiv bits j) u).1 j ((leftOutsideEquiv bits j) u).2) + (fun j u => R ((rightOutsideEquiv bits j) u).1 j ((rightOutsideEquiv bits j) u).2) + +def choicesEquiv : GridChoices bits ≃ + (GridSlot (rightBits bits) → GridChoices (leftBits bits)) × + (GridSlot (leftBits bits) → GridChoices (rightBits bits)) where + toFun g := (rowChoices bits g,columnChoices bits g) + invFun LR := joinChoices bits LR.1 LR.2 + left_inv g := by + funext j u + induction j using Fin.addCases with + | left j => simp [joinChoices,rowChoices] + | right j => simp [joinChoices,columnChoices] + right_inv LR := by + apply Prod.ext + · funext y j u + simp [rowChoices,joinChoices] + · funext x j u + simp [columnChoices,joinChoices] + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitCost.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..531af0c9d480b394833212a175b55a4c5c6cf96e --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitCost.lean @@ -0,0 +1,189 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridSplit +import OAI.Probability.BinarySweep.GridBounds.GridProjectedMoment +import OAI.Probability.BinarySweep.YoungTheory.HookHilbertOccurrence + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +lemma left_path_address (j : Fin m) (k : Fin h) : + leftOutsideEquiv bits j (fun i => H.position (j.castAdd n).castSucc k i)= + (rightSlot bits (H.position 0 k), + fun i : {i : Fin m // i≠j} => leftSlot bits (H.position (leftTime j.castSucc) k) i) := by + apply Prod.ext + · change rightSlot bits (H.position (leftTime j.castSucc) k)=_ + exact rightSlot_leftTime bits H j.castSucc k + · rfl + +lemma right_path_address (j : Fin n) (k : Fin h) : + rightOutsideEquiv bits j (fun i => H.position (j.natAdd m).castSucc k i)= + (leftSlot bits (H.position (rightTime (m:=m) 0) k), + fun i : {i : Fin n // i≠j} => rightSlot bits (H.position (rightTime j.castSucc) k) i) := by + apply Prod.ext + · change leftSlot bits (H.position (rightTime j.castSucc) k)=_ + exact leftSlot_rightTime bits H j.castSucc k + · rfl + +lemma card_pair_fiber {K Y U : Type*} [Fintype K] {l : ℕ} + (f : K → Y) (g : K → U) (y : Y) (u : U) + (e : {k : K // f k=y} ≃ Fin l) : + Fintype.card {k : K // (f k,g k)=(y,u)} = + Fintype.card {i : Fin l // g (e.symm i).val=u} := by + apply Fintype.card_congr + refine { toFun := fun k => ⟨e ⟨k.val,congrArg Prod.fst k.property⟩, ?_⟩ + invFun := fun i => ⟨(e.symm i.val).val, ?_⟩ + left_inv := ?_ + right_inv := ?_ } + · simpa only [Equiv.symm_apply_apply] using congrArg Prod.snd k.property + · exact Prod.ext (e.symm i.val).property i.property + · intro k; apply Subtype.ext; simp only [Equiv.symm_apply_apply] + · intro i; apply Subtype.ext + exact e.apply_symm_apply i.val + +lemma lineHoles_left (j : Fin m) (u : GridOutside bits (j.castAdd n)) : + lineHoles H (j.castAdd n) u = + lineHoles (rowFamily bits H ((leftOutsideEquiv bits j) u).1) j + ((leftOutsideEquiv bits j) u).2 := by + unfold lineHoles + let y := ((leftOutsideEquiv bits j) u).1 + let v := ((leftOutsideEquiv bits j) u).2 + have he (k : Fin h) : (fun i : {i : Fin (m+n) // i≠j.castAdd n} => H.position (j.castAdd n).castSucc k i)=u ↔ + (rightSlot bits (H.position 0 k), + fun i : {i : Fin m // i≠j} => leftSlot bits (H.position (leftTime j.castSucc) k) i)=(y,v) := by + rw [← Equiv.apply_eq_iff_eq (leftOutsideEquiv bits j),left_path_address] + rw [Fintype.card_congr (Equiv.subtypeEquivRight he)] + convert card_pair_fiber (fun k => rightSlot bits (H.position 0 k)) + (fun k => fun i : {i : Fin m // i≠j} => leftSlot bits (H.position (leftTime j.castSucc) k) i) y v + (@Fintype.equivFin (RowLabels bits H y) (rowLabelsFintype bits H y)) using 1 <;> + congr! + +lemma lineHoles_right (j : Fin n) (u : GridOutside bits (j.natAdd m)) : + lineHoles H (j.natAdd m) u = + lineHoles (columnFamily bits H ((rightOutsideEquiv bits j) u).1) j + ((rightOutsideEquiv bits j) u).2 := by + unfold lineHoles + let x := ((rightOutsideEquiv bits j) u).1 + let v := ((rightOutsideEquiv bits j) u).2 + have he (k : Fin h) : (fun i : {i : Fin (m+n) // i≠j.natAdd m} => H.position (j.natAdd m).castSucc k i)=u ↔ + (leftSlot bits (H.position (rightTime (m:=m) 0) k), + fun i : {i : Fin n // i≠j} => rightSlot bits (H.position (rightTime j.castSucc) k) i)=(x,v) := by + rw [← Equiv.apply_eq_iff_eq (rightOutsideEquiv bits j),right_path_address] + rw [Fintype.card_congr (Equiv.subtypeEquivRight he)] + convert card_pair_fiber (fun k => leftSlot bits (H.position (rightTime (m:=m) 0) k)) + (fun k => fun i : {i : Fin n // i≠j} => rightSlot bits (H.position (rightTime j.castSucc) k) i) x v + (@Fintype.equivFin (ColumnLabels bits H x) (columnLabelsFintype bits H x)) using 1 <;> + congr! + +theorem pathCost_split : pathCost H = + (∑y, pathCost (rowFamily bits H y)) + (∑x, pathCost (columnFamily bits H x)) := by + unfold pathCost + rw [Fin.sum_univ_add] + congr 1 + · rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j _ + simp_rw [lineHoles_left] + have he := Equiv.sum_comp (leftOutsideEquiv bits j) (fun yu => + Real.log (((2^leftBits bits j:ℕ):ℝ)^lineHoles (rowFamily bits H yu.1) j yu.2 / + (Nat.descFactorial (2^leftBits bits j) (lineHoles (rowFamily bits H yu.1) j yu.2):ℝ))) + simpa only [Fintype.sum_prod_type] using he + · rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j _ + simp_rw [lineHoles_right] + have he := Equiv.sum_comp (rightOutsideEquiv bits j) (fun xu => + Real.log (((2^rightBits bits j:ℕ):ℝ)^lineHoles (columnFamily bits H xu.1) j xu.2 / + (Nat.descFactorial (2^rightBits bits j) (lineHoles (columnFamily bits H xu.1) j xu.2):ℝ))) + simpa only [Fintype.sum_prod_type] using he + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation Signed TraceHolder Density + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + +local instance : LinearOrder (GridSlot (rightBits bits)) := rowOrder bits +local instance : LinearOrder (GridSlot (leftBits bits)) := columnOrder bits +local instance : Nonempty (GridSlot (rightBits bits)) := ⟨fun _ _ => false⟩ + +def rowFreeSize (y : GridSlot (rightBits bits)) := Fintype.card (FreeSlot (rowFamily bits H y) 0) +def columnFreeSize (x : GridSlot (leftBits bits)) := Fintype.card (FreeSlot (columnFamily bits H x) 0) + +lemma holeCount_junction : + (Fintype.card (GridSlot (rightBits bits)):ℝ)*Fintype.card (GridSlot (leftBits bits))- + (junctionSize bits H:ℝ)=h := by + have hh : h≤gridSize bits := by + have he := Fintype.card_le_of_injective (H.position 0) (H.disjoint 0) + simpa only [Fintype.card_fin,card_gridSlot] using he + rw [junctionSize_eq,Nat.cast_sub hh,card_gridSlot,card_gridSlot, + size_split,Nat.cast_mul] + ring + +theorem conditional_dense_bound + {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm (Fin (junctionSize bits H))) V) [ρ.IsIrreducible] + (hρ : ∀g v, ‖ρ g v‖=‖v‖) (p : A → Bool) + (hocc : 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-c*Real.log (Module.finrank ℂ V:ℝ)+(∑y, ER y)+(∑x, EC x)+c*h+ + (1+4*c+2*(q:ℝ))*(Fintype.card A:ℝ)^2* + (blockLogSize (rowFreeSize bits H)+blockLogSize (columnFreeSize bits H))) := by + refine (conditional_le_junction bits H ρ hρ p hocc z hq).trans ?_ + have hb := grouped_dense_bound (physicalBoard bits H) p + (groupingOrder (rowGrouping bits H)) (groupingOrder (columnGrouping bits H)) + (groupingPerm (rowGrouping bits H)) (groupingPerm (columnGrouping bits H)) + (physicalBoard_row bits H) (physicalBoard_column bits H) ρ + (rowChildWeight bits H z) (columnChildWeight bits H z) hq c hc hcq ER EC hchildR hchildC + rw [holeCount_junction] at hb + exact hb + +theorem conditional_hook_dense_bound {t : ℕ} (ht : 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-c*typeF α+(∑y, ER y)+(∑x, EC x)+c*h+ + (1+4*c+2*(q:ℝ))*(2*(t:ℝ))^2* + (blockLogSize (rowFreeSize bits H)+blockLogSize (columnFreeSize bits H))) := by + let : NeZero t := ⟨ne_of_gt ht⟩ + have hb := conditional_dense_bound bits H (Young.partitionHilbertRep α) + (Young.partitionHilbertRep_unitary α) (Prod.fst : Bool × Fin t → Bool) + (Young.hookHilbert_occurs α hα) z hq c hc hcq ER EC hchildR hchildC + simpa only [Fintype.card_prod,Fintype.card_bool,Fintype.card_fin,Nat.cast_mul,Nat.cast_ofNat,typeF] using hb + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitFree.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitFree.lean new file mode 100644 index 0000000000000000000000000000000000000000..5636d3e472ab99351ab3aee367d1d219ad2b8929 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitFree.lean @@ -0,0 +1,211 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.LinearEvenMoment +import OAI.Probability.BinarySweep.Conditional.ConditionalAverage +import OAI.Probability.BinarySweep.GridBounds.GridSplitSweep + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +@[simp] lemma left_join (x : GridSlot (leftBits bits)) (y : GridSlot (rightBits bits)) : + leftSlot bits (joinSlot bits x y)=x := by funext i; simp [leftSlot,joinSlot] +@[simp] lemma right_join (x : GridSlot (leftBits bits)) (y : GridSlot (rightBits bits)) : + rightSlot bits (joinSlot bits x y)=y := by funext i; simp [rightSlot,joinSlot] +@[simp] lemma join_left_right (x : GridSlot bits) : + joinSlot bits (leftSlot bits x) (rightSlot bits x)=x := (slotEquiv bits).symm_apply_apply x + +def rowFreeEquiv (t : Fin (m+1)) : FreeSlot H (leftTime t) ≃ + Σy : GridSlot (rightBits bits), FreeSlot (rowFamily bits H y) t where + toFun x := ⟨rightSlot bits x.val,⟨leftSlot bits x.val,by + rintro ⟨a,ha⟩ + let k := (Fintype.equivFin (RowLabels bits H (rightSlot bits x.val))).symm a + apply x.property + refine ⟨k.val,?_⟩ + apply (slotEquiv bits).injective + apply Prod.ext + · exact ha + · exact (rightSlot_leftTime bits H t k.val).trans k.property⟩⟩ + invFun yx := ⟨joinSlot bits yx.2.val yx.1,by + rintro ⟨k,hk⟩ + have he := congrArg (slotEquiv bits) hk + have hr : rightSlot bits (H.position 0 k)=yx.1 := by + rw [←rightSlot_leftTime bits H t k] + exact (congrArg Prod.snd he).trans (congrArg Prod.snd ((slotEquiv bits).apply_symm_apply (yx.2.val,yx.1))) + apply yx.2.property + refine ⟨Fintype.equivFin (RowLabels bits H yx.1) ⟨k,hr⟩,?_⟩ + simp only [rowFamily,Equiv.symm_apply_apply] + exact (congrArg Prod.fst he).trans (congrArg Prod.fst ((slotEquiv bits).apply_symm_apply (yx.2.val,yx.1)))⟩ + left_inv x := by + apply Subtype.ext + exact (slotEquiv bits).symm_apply_apply x.val + right_inv yx := by + rcases yx with ⟨y,x⟩ + have he := (slotEquiv bits).apply_symm_apply (x.val,y) + apply Sigma.ext (congrArg Prod.snd he) + have hr : rightSlot bits (joinSlot bits x.val y)=y := congrArg Prod.snd he + apply (Subtype.heq_iff_coe_eq (by + intro a + change a∉Set.range ((rowFamily bits H (rightSlot bits (joinSlot bits x.val y))).position t) ↔ _ + rw [hr])).mpr + exact congrArg Prod.fst he + +def columnFreeEquiv (t : Fin (n+1)) : FreeSlot H (rightTime t) ≃ + Σx : GridSlot (leftBits bits), FreeSlot (columnFamily bits H x) t where + toFun y := ⟨leftSlot bits y.val,⟨rightSlot bits y.val,by + rintro ⟨a,ha⟩ + let k := (Fintype.equivFin (ColumnLabels bits H (leftSlot bits y.val))).symm a + apply y.property + refine ⟨k.val,?_⟩ + apply (slotEquiv bits).injective + apply Prod.ext + · exact (leftSlot_rightTime bits H t k.val).trans k.property + · exact ha⟩⟩ + invFun xy := ⟨joinSlot bits xy.1 xy.2.val,by + rintro ⟨k,hk⟩ + have he := congrArg (slotEquiv bits) hk + have hl : leftSlot bits (H.position (rightTime (m:=m) 0) k)=xy.1 := by + rw [←leftSlot_rightTime bits H t k] + exact (congrArg Prod.fst he).trans (congrArg Prod.fst ((slotEquiv bits).apply_symm_apply (xy.1,xy.2.val))) + apply xy.2.property + refine ⟨Fintype.equivFin (ColumnLabels bits H xy.1) ⟨k,hl⟩,?_⟩ + simp only [columnFamily,Equiv.symm_apply_apply] + exact (congrArg Prod.snd he).trans (congrArg Prod.snd ((slotEquiv bits).apply_symm_apply (xy.1,xy.2.val)))⟩ + left_inv y := by + apply Subtype.ext + exact (slotEquiv bits).symm_apply_apply y.val + right_inv xy := by + rcases xy with ⟨x,y⟩ + have he := (slotEquiv bits).apply_symm_apply (x,y.val) + apply Sigma.ext (congrArg Prod.fst he) + have hl : leftSlot bits (joinSlot bits x y.val)=x := congrArg Prod.fst he + apply (Subtype.heq_iff_coe_eq (by + intro a + change a∉Set.range ((columnFamily bits H (leftSlot bits (joinSlot bits x y.val))).position t) ↔ _ + rw [hl])).mpr + exact congrArg Prod.snd he + +abbrev RowSamples := ∀y, ConditionalChoices (rowFamily bits H y) +abbrev ColumnSamples := ∀x, ConditionalChoices (columnFamily bits H x) + +def rowRemaining (g : RowSamples bits H) : FreeSlot H 0 ≃ FreeSlot H (rightTime (m:=m) 0) := + (rowFreeEquiv bits H 0).trans ((Equiv.sigmaCongrRight (fun y => + remainingBijection (rowFamily bits H y) (g y).val (g y).property)).trans + (rowFreeEquiv bits H (Fin.last m)).symm) + +def columnRemaining (g : ColumnSamples bits H) : + FreeSlot H (rightTime (m:=m) 0) ≃ FreeSlot H (Fin.last (m+n)) := + (columnFreeEquiv bits H 0).trans ((Equiv.sigmaCongrRight (fun x => + remainingBijection (columnFamily bits H x) (g x).val (g x).property)).trans + (columnFreeEquiv bits H (Fin.last n)).symm) + +@[simp] lemma rowRemaining_val (g : RowSamples bits H) (a : FreeSlot H 0) : + (rowRemaining bits H g a).val = joinSlot bits + (gridSweep (leftBits bits) (g (rightSlot bits a.val)).val (leftSlot bits a.val)) + (rightSlot bits a.val) := rfl + +@[simp] lemma columnRemaining_val (g : ColumnSamples bits H) + (a : FreeSlot H (rightTime (m:=m) 0)) : + (columnRemaining bits H g a).val = joinSlot bits (leftSlot bits a.val) + (gridSweep (rightBits bits) (g (leftSlot bits a.val)).val (rightSlot bits a.val)) := rfl + +lemma remainingBijection_split (g : ConditionalChoices H) : + remainingBijection H g.val g.property = + (rowRemaining bits H ((conditionalChoicesEquiv bits H g).1)).trans + (columnRemaining bits H ((conditionalChoicesEquiv bits H g).2)) := by + apply Equiv.ext + intro a + apply Subtype.ext + change gridSweep bits g.val a.val = + (columnRemaining bits H ((conditionalChoicesEquiv bits H g).2) + (rowRemaining bits H ((conditionalChoicesEquiv bits H g).1) a)).val + rw [columnRemaining_val,rowRemaining_val,left_join,right_join] + apply (slotEquiv bits).injective + have he := Equiv.congr_fun (gridSweep_split bits g.val) (slotEquiv bits a.val) + simpa [conditionalChoicesEquiv,Equiv.permCongr_apply,rowPerm,columnPerm, + slotEquiv] using he + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +def rowReference : FreeSlot H 0 ≃ FreeSlot H (rightTime (m:=m) 0) := + (rowFreeEquiv bits H 0).trans ((Equiv.sigmaCongrRight (fun y => + freeIdentification (rowFamily bits H y))).trans + (rowFreeEquiv bits H (Fin.last m)).symm) + +def columnReference : FreeSlot H (rightTime (m:=m) 0) ≃ FreeSlot H (Fin.last (m+n)) := + (columnFreeEquiv bits H 0).trans ((Equiv.sigmaCongrRight (fun x => + freeIdentification (columnFamily bits H x))).trans + (columnFreeEquiv bits H (Fin.last n)).symm) + +def rowRelative (g : RowSamples bits H) : Equiv.Perm (FreeSlot H 0) := + (rowRemaining bits H g).trans (rowReference bits H).symm + +def columnRelative (g : ColumnSamples bits H) : Equiv.Perm (FreeSlot H (rightTime (m:=m) 0)) := + (columnRemaining bits H g).trans (columnReference bits H).symm + +def framePermutation : Equiv.Perm (FreeSlot H 0) := + ((rowReference bits H).trans (columnReference bits H)).trans (freeIdentification H).symm + +theorem remainingPerm_factor (g : ConditionalChoices H) : + remainingPerm H g.val g.property = framePermutation bits H * + (rowReference bits H).symm.permCongr + (columnRelative bits H ((conditionalChoicesEquiv bits H g).2)) * + rowRelative bits H ((conditionalChoicesEquiv bits H g).1) := by + unfold remainingPerm + rw [remainingBijection_split] + apply Equiv.ext + intro x + simp [framePermutation,rowRelative,columnRelative,Equiv.permCongr_apply] + +variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) V) + +def rowAverage (z : ℝ) : V →ₗ[ℂ] V := + ∑g : RowSamples bits H, + ((∏y, conditionalChoiceWeight (rowFamily bits H y) z (g y)):ℂ) • ρ (rowRelative bits H g) + +def columnAverage (z : ℝ) : V →ₗ[ℂ] V := + ∑g : ColumnSamples bits H, + ((∏x, conditionalChoiceWeight (columnFamily bits H x) z (g x)):ℂ) • + ρ ((rowReference bits H).symm.permCongr (columnRelative bits H g)) + +omit [FiniteDimensional ℂ V] in +theorem groupAverage_split (z : ℝ) : + groupAverage ρ (fun a => (conditionalGroupLaw H z a:ℂ)) = + ρ (framePermutation bits H) * columnAverage bits H ρ z * rowAverage bits H ρ z := by + rw [groupAverage_conditional,← Equiv.sum_comp (conditionalChoicesEquiv bits H).symm] + simp_rw [conditionalChoiceWeight_split,remainingPerm_factor, + Equiv.apply_symm_apply,map_mul,Complex.ofReal_mul] + rw [Fintype.sum_prod_type] + unfold columnAverage rowAverage + simp only [Finset.mul_sum,Finset.sum_mul,smul_mul_assoc,mul_smul_comm, + Finset.smul_sum,smul_smul,Complex.ofReal_prod] + +theorem conditional_evenMoment_split (z : ℝ) (q : ℕ) + (hρ : ∀g v, ‖ρ g v‖=‖v‖) : + evenMoment q (groupAverage ρ (fun a => (conditionalGroupLaw H z a:ℂ))) = + evenMoment q (columnAverage bits H ρ z * rowAverage bits H ρ z) := by + rw [groupAverage_split,mul_assoc] + apply evenMoment_unitary_left + rw [unitary_rep_adjoint ρ hρ,←map_mul,inv_mul_cancel,map_one] + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitSweep.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitSweep.lean new file mode 100644 index 0000000000000000000000000000000000000000..77555f0da4203465b3f6a5e3ea54b85946fd7e3c --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitSweep.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridSplitWeights + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit + +variable {X Y : Type*} +def rowPerm (f : Y → Equiv.Perm X) : Equiv.Perm (X×Y) where + toFun xy := (f xy.2 xy.1,xy.2) + invFun xy := ((f xy.2).symm xy.1,xy.2) + left_inv xy := by simp + right_inv xy := by simp + +def rowPermHom : (Y → Equiv.Perm X) →* Equiv.Perm (X×Y) where + toFun := rowPerm + map_one' := by ext xy <;> rfl + map_mul' f g := by ext xy <;> rfl + +def columnPerm (f : X → Equiv.Perm Y) : Equiv.Perm (X×Y) where + toFun xy := (xy.1,f xy.1 xy.2) + invFun xy := (xy.1,(f xy.1).symm xy.2) + left_inv xy := by simp + right_inv xy := by simp + +def columnPermHom : (X → Equiv.Perm Y) →* Equiv.Perm (X×Y) where + toFun := columnPerm + map_one' := by ext xy <;> rfl + map_mul' f g := by ext xy <;> rfl + +variable {m n : ℕ} (bits : Fin (m+n) → ℕ) + +lemma gridLayer_left (g : GridChoices bits) (j : Fin m) (x : GridSlot bits) : + (slotEquiv bits) (gridLayer bits g (j.castAdd n) x) = + (gridLayer (leftBits bits) (rowChoices bits g (rightSlot bits x)) j (leftSlot bits x), + rightSlot bits x) := by + apply Prod.ext + · simp only + funext i + change gridLayer bits g (j.castAdd n) x (i.castAdd n)=_ + by_cases hi : i=j + · subst i + rw [gridLayer_at,gridLayer_at,rowChoices_at] + rfl + · rw [gridLayer_other bits g _ _ (fun he => hi (Fin.castAdd_injective m n he)), + gridLayer_other _ _ _ _ hi] + rfl + · funext i + exact gridLayer_other bits g _ _ (by + intro he + have hh := congrArg (fun i : Fin (m+n) => i.val) he + simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega) x + +lemma gridLayer_right (g : GridChoices bits) (j : Fin n) (x : GridSlot bits) : + (slotEquiv bits) (gridLayer bits g (j.natAdd m) x) = + (leftSlot bits x, + gridLayer (rightBits bits) (columnChoices bits g (leftSlot bits x)) j (rightSlot bits x)) := by + apply Prod.ext + · funext i + exact gridLayer_other bits g _ _ (by + intro he + have hh := congrArg (fun i : Fin (m+n) => i.val) he + simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega) x + · simp only + funext i + change gridLayer bits g (j.natAdd m) x (i.natAdd m)=_ + by_cases hi : i=j + · subst i + rw [gridLayer_at,gridLayer_at,columnChoices_at] + rfl + · rw [gridLayer_other bits g _ _ (fun he => hi (Fin.natAdd_injective n m he)), + gridLayer_other _ _ _ _ hi] + rfl + +lemma layer_left_congr (g : GridChoices bits) (j : Fin m) : + (slotEquiv bits).permCongr (gridLayer bits g (j.castAdd n)) = + rowPerm (fun y => gridLayer (leftBits bits) (rowChoices bits g y) j) := by + apply Equiv.ext + intro xy + have he := gridLayer_left bits g j ((slotEquiv bits).symm xy) + change (slotEquiv bits) (gridLayer bits g (j.castAdd n) ((slotEquiv bits).symm xy))= _ + rw [he] + have ht := (slotEquiv bits).apply_symm_apply xy + rw [show leftSlot bits ((slotEquiv bits).symm xy)=xy.1 from congrArg Prod.fst ht, + show rightSlot bits ((slotEquiv bits).symm xy)=xy.2 from congrArg Prod.snd ht] + rfl + +lemma layer_right_congr (g : GridChoices bits) (j : Fin n) : + (slotEquiv bits).permCongr (gridLayer bits g (j.natAdd m)) = + columnPerm (fun x => gridLayer (rightBits bits) (columnChoices bits g x) j) := by + apply Equiv.ext + intro xy + have he := gridLayer_right bits g j ((slotEquiv bits).symm xy) + change (slotEquiv bits) (gridLayer bits g (j.natAdd m) ((slotEquiv bits).symm xy))= _ + rw [he] + have ht := (slotEquiv bits).apply_symm_apply xy + rw [show leftSlot bits ((slotEquiv bits).symm xy)=xy.1 from congrArg Prod.fst ht, + show rightSlot bits ((slotEquiv bits).symm xy)=xy.2 from congrArg Prod.snd ht] + rfl + +lemma prod_rows (L : List (Y → Equiv.Perm X)) : + (L.map rowPerm).prod=rowPerm (fun y => (L.map (fun f => f y)).prod) := by + induction L with + | nil => rfl + | cons f L ih => + simp only [List.map_cons,List.prod_cons,ih] + apply Equiv.ext + intro xy + rfl +lemma prod_columns (L : List (X → Equiv.Perm Y)) : + (L.map columnPerm).prod=columnPerm (fun x => (L.map (fun f => f x)).prod) := by + induction L with + | nil => rfl + | cons f L ih => + simp only [List.map_cons,List.prod_cons,ih] + apply Equiv.ext + intro xy + rfl + +theorem gridSweep_split (g : GridChoices bits) : + (slotEquiv bits).permCongr (gridSweep bits g) = + columnPerm (fun x => gridSweep (rightBits bits) (columnChoices bits g x)) * + rowPerm (fun y => gridSweep (leftBits bits) (rowChoices bits g y)) := by + change (slotEquiv bits).permCongrHom (gridSweep bits g)=_ + unfold gridSweep + rw [List.ofFn_add,List.reverse_append,List.prod_append] + rw [map_mul] + congr 1 + · rw [map_list_prod (slotEquiv bits).permCongrHom,List.map_reverse,List.map_ofFn] + change (List.ofFn (fun j : Fin n => (slotEquiv bits).permCongr (gridLayer bits g (j.natAdd m)))).reverse.prod=_ + simp_rw [layer_right_congr] + simpa only [List.map_reverse,List.map_ofFn,Function.comp_def] using + (prod_columns (List.ofFn (fun j : Fin n => fun x => + gridLayer (rightBits bits) (columnChoices bits g x) j)).reverse) + · rw [map_list_prod (slotEquiv bits).permCongrHom,List.map_reverse,List.map_ofFn] + change (List.ofFn (fun j : Fin m => (slotEquiv bits).permCongr (gridLayer bits g (j.castAdd n)))).reverse.prod=_ + simp_rw [layer_left_congr] + simpa only [List.map_reverse,List.map_ofFn,Function.comp_def] using + (prod_rows (List.ofFn (fun j : Fin m => fun y => + gridLayer (leftBits bits) (rowChoices bits g y) j)).reverse) + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitWeights.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4b130cf28410f1430387e1ff65ff996715212b5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GridSplitWeights.lean @@ -0,0 +1,235 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridSplit +import OAI.Probability.BinarySweep.Trajectories.EndpointEvents + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit + +section +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) + +lemma outside_left (j : Fin m) (x : GridSlot bits) : + (leftOutsideEquiv bits j) (fun i => x i.val) = + (rightSlot bits x,fun i : {i : Fin m // i≠j} => leftSlot bits x i.val) := rfl +lemma outside_right (j : Fin n) (x : GridSlot bits) : + (rightOutsideEquiv bits j) (fun i => x i.val) = + (leftSlot bits x,fun i : {i : Fin n // i≠j} => rightSlot bits x i.val) := rfl + +lemma rowChoices_at (g : GridChoices bits) (x : GridSlot bits) (j : Fin m) : + rowChoices bits g (rightSlot bits x) j (fun i => leftSlot bits x i.val) = + g (j.castAdd n) (fun i => x i.val) := by + unfold rowChoices + rw [← outside_left,Equiv.symm_apply_apply] + +lemma columnChoices_at (g : GridChoices bits) (x : GridSlot bits) (j : Fin n) : + columnChoices bits g (leftSlot bits x) j (fun i => rightSlot bits x i.val) = + g (j.natAdd m) (fun i => x i.val) := by + unfold columnChoices + rw [← outside_right,Equiv.symm_apply_apply] + +lemma gridWeight_split (z : ℝ) (g : GridChoices bits) : + gridWeight bits z g = + (∏y : GridSlot (rightBits bits), gridWeight (leftBits bits) z (rowChoices bits g y)) * + (∏x : GridSlot (leftBits bits), gridWeight (rightBits bits) z (columnChoices bits g x)) := by + unfold gridWeight + rw [Fin.prod_univ_add] + congr 1 + · rw [Finset.prod_comm] + apply Finset.prod_congr rfl + intro j _ + have he := (leftOutsideEquiv bits j).symm.prod_comp (fun u => lineLaw (bits (j.castAdd n)) z (g (j.castAdd n) u)) + rw [Fintype.prod_prod_type] at he + exact he.symm + · rw [Finset.prod_comm] + apply Finset.prod_congr rfl + intro j _ + have he := (rightOutsideEquiv bits j).symm.prod_comp (fun u => lineLaw (bits (j.natAdd m)) z (g (j.natAdd m) u)) + rw [Fintype.prod_prod_type] at he + exact he.symm + +lemma gridLayer_path_iff {b h : ℕ} {a : Fin b → ℕ} (H : PathFamily a h) + (g : GridChoices a) (j : Fin b) (k : Fin h) : + gridLayer a g j (H.position j.castSucc k)=H.position j.succ k ↔ + g j (fun i => H.position j.castSucc k i.val) (H.position j.castSucc k j)=H.position j.succ k j := by + constructor + · intro he + have hh := congrFun he j + rwa [gridLayer_at] at hh + · intro he + funext i + by_cases hi : i=j + · subst i; exact (gridLayer_at g j _).trans he + · rw [gridLayer_other a g j i hi,H.changes_only_stage j k i hi] + +end + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +lemma row_stage_iff (g : GridChoices bits) (y : GridSlot (rightBits bits)) + (j : Fin m) (a : RowLabels bits H y) : + gridLayer (leftBits bits) (rowChoices bits g y) j + ((rowFamily bits H y).position j.castSucc (Fintype.equivFin (RowLabels bits H y) a)) = + (rowFamily bits H y).position j.succ (Fintype.equivFin (RowLabels bits H y) a) ↔ + gridLayer bits g (j.castAdd n) (H.position (leftTime j.castSucc) a.val) = + H.position (leftTime j.succ) a.val := by + change _ ↔ gridLayer bits g (j.castAdd n) + (H.position (j.castAdd n).castSucc a.val)=H.position (j.castAdd n).succ a.val + rw [gridLayer_path_iff (rowFamily bits H y), + gridLayer_path_iff H g (j.castAdd n) a.val] + simp only [rowFamily,Equiv.symm_apply_apply] + have hr : rightSlot bits (H.position (leftTime j.castSucc) a.val)=y := + (rightSlot_leftTime bits H j.castSucc a.val).trans a.property + have hc : rowChoices bits g y j + (fun i => leftSlot bits (H.position (leftTime j.castSucc) a.val) i.val) = + g (j.castAdd n) (fun i => H.position (leftTime j.castSucc) a.val i.val) := by + simpa only [hr] using rowChoices_at bits g (H.position (leftTime j.castSucc) a.val) j + rw [hc] + rfl + +lemma column_stage_iff (g : GridChoices bits) (x : GridSlot (leftBits bits)) + (j : Fin n) (a : ColumnLabels bits H x) : + gridLayer (rightBits bits) (columnChoices bits g x) j + ((columnFamily bits H x).position j.castSucc (Fintype.equivFin (ColumnLabels bits H x) a)) = + (columnFamily bits H x).position j.succ (Fintype.equivFin (ColumnLabels bits H x) a) ↔ + gridLayer bits g (j.natAdd m) (H.position (rightTime j.castSucc) a.val) = + H.position (rightTime j.succ) a.val := by + change _ ↔ gridLayer bits g (j.natAdd m) + (H.position (j.natAdd m).castSucc a.val)=H.position (j.natAdd m).succ a.val + rw [gridLayer_path_iff (columnFamily bits H x), + gridLayer_path_iff H g (j.natAdd m) a.val] + simp only [columnFamily,Equiv.symm_apply_apply] + have hr : leftSlot bits (H.position (rightTime j.castSucc) a.val)=x := + (leftSlot_rightTime bits H j.castSucc a.val).trans a.property + have hc : columnChoices bits g x j + (fun i => rightSlot bits (H.position (rightTime j.castSucc) a.val) i.val) = + g (j.natAdd m) (fun i => H.position (rightTime j.castSucc) a.val i.val) := by + simpa only [hr] using columnChoices_at bits g (H.position (rightTime j.castSucc) a.val) j + rw [hc] + rfl + +theorem pathEvent_split (g : GridChoices bits) : + pathEvent H g ↔ + (∀y, pathEvent (rowFamily bits H y) (rowChoices bits g y)) ∧ + (∀x, pathEvent (columnFamily bits H x) (columnChoices bits g x)) := by + constructor + · intro hg + constructor + · intro y j k + obtain ⟨a,rfl⟩ := (Fintype.equivFin (RowLabels bits H y)).surjective k + exact (row_stage_iff bits H g y j a).mpr (hg _ _) + · intro x j k + obtain ⟨a,rfl⟩ := (Fintype.equivFin (ColumnLabels bits H x)).surjective k + exact (column_stage_iff bits H g x j a).mpr (hg _ _) + · rintro ⟨hL,hR⟩ j k + induction j using Fin.addCases with + | left j => + let y := rightSlot bits (H.position 0 k) + let a : RowLabels bits H y := ⟨k,rfl⟩ + exact (row_stage_iff bits H g y j a).mp (hL y j _) + | right j => + let x := leftSlot bits (H.position (rightTime (m:=m) 0) k) + let a : ColumnLabels bits H x := ⟨k,rfl⟩ + exact (column_stage_iff bits H g x j a).mp (hR x j _) + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.GridSplit +attribute [local instance] Classical.propDecidable +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +lemma rowChoices_symm (LR : (GridSlot (rightBits bits) → GridChoices (leftBits bits)) × + (GridSlot (leftBits bits) → GridChoices (rightBits bits))) : + rowChoices bits ((choicesEquiv bits).symm LR)=LR.1 := + congrArg Prod.fst ((choicesEquiv bits).apply_symm_apply LR) +lemma columnChoices_symm (LR : (GridSlot (rightBits bits) → GridChoices (leftBits bits)) × + (GridSlot (leftBits bits) → GridChoices (rightBits bits))) : + columnChoices bits ((choicesEquiv bits).symm LR)=LR.2 := + congrArg Prod.snd ((choicesEquiv bits).apply_symm_apply LR) + +lemma eventWeight_split (z : ℝ) (g : GridChoices bits) : + (if pathEvent H g then gridWeight bits z g else 0) = + (∏y, if pathEvent (rowFamily bits H y) (rowChoices bits g y) then + gridWeight (leftBits bits) z (rowChoices bits g y) else 0) * + (∏x, if pathEvent (columnFamily bits H x) (columnChoices bits g x) then + gridWeight (rightBits bits) z (columnChoices bits g x) else 0) := by + classical + rw [pathEvent_split,gridWeight_split] + simp only [Fintype.prod_ite_zero] + split_ifs <;> simp_all + +theorem conditionalNormalizer_split (z : ℝ) : + conditionalNormalizer H z = + (∏y, conditionalNormalizer (rowFamily bits H y) z) * + (∏x, conditionalNormalizer (columnFamily bits H x) z) := by + classical + let : Fintype (GridChoices (leftBits bits)) := inferInstance + let : Fintype (GridChoices (rightBits bits)) := inferInstance + have he := (choicesEquiv bits).symm.sum_comp + (fun g => if pathEvent H g then gridWeight bits z g else 0) + have hs (LR : (GridSlot (rightBits bits) → GridChoices (leftBits bits)) × + (GridSlot (leftBits bits) → GridChoices (rightBits bits))) : + (if pathEvent H ((choicesEquiv bits).symm LR) then + gridWeight bits z ((choicesEquiv bits).symm LR) else 0) = + (∏y, if pathEvent (rowFamily bits H y) (LR.1 y) then + gridWeight (leftBits bits) z (LR.1 y) else 0) * + (∏x, if pathEvent (columnFamily bits H x) (LR.2 x) then + gridWeight (rightBits bits) z (LR.2 x) else 0) := by + classical + rw [eventWeight_split,rowChoices_symm,columnChoices_symm] + simp_rw [hs] at he + unfold conditionalNormalizer + rw [← he,Fintype.sum_prod_type] + simp_rw [← Finset.mul_sum] + rw [← Finset.sum_mul] + congr 1 + · exact (Fintype.prod_sum (fun (y : GridSlot (rightBits bits)) (g : GridChoices (leftBits bits)) => + if pathEvent (rowFamily bits H y) g then gridWeight (leftBits bits) z g else 0)).symm + · exact (Fintype.prod_sum (fun (x : GridSlot (leftBits bits)) (g : GridChoices (rightBits bits)) => + if pathEvent (columnFamily bits H x) g then gridWeight (rightBits bits) z g else 0)).symm + +def conditionalChoicesEquiv : ConditionalChoices H ≃ + (∀y, ConditionalChoices (rowFamily bits H y)) × + (∀x, ConditionalChoices (columnFamily bits H x)) where + toFun g := (fun y => ⟨rowChoices bits g.val y,(pathEvent_split bits H g.val).mp g.property |>.1 y⟩, + fun x => ⟨columnChoices bits g.val x,(pathEvent_split bits H g.val).mp g.property |>.2 x⟩) + invFun LR := ⟨(choicesEquiv bits).symm (fun y => (LR.1 y).val,fun x => (LR.2 x).val), by + rw [pathEvent_split,rowChoices_symm,columnChoices_symm] + exact ⟨fun y => (LR.1 y).property,fun x => (LR.2 x).property⟩⟩ + left_inv g := by + classical + apply Subtype.ext + exact (choicesEquiv bits).symm_apply_apply g.val + right_inv LR := by + classical + apply Prod.ext <;> funext a <;> apply Subtype.ext + · exact congrFun (rowChoices_symm bits _) a + · exact congrFun (columnChoices_symm bits _) a + +theorem conditionalChoiceWeight_split (z : ℝ) (g : ConditionalChoices H) : + conditionalChoiceWeight H z g = + (∏y, conditionalChoiceWeight (rowFamily bits H y) z + ((conditionalChoicesEquiv bits H g).1 y)) * + (∏x, conditionalChoiceWeight (columnFamily bits H x) z + ((conditionalChoicesEquiv bits H g).2 x)) := by + classical + unfold conditionalChoiceWeight + rw [gridWeight_split,conditionalNormalizer_split] + simp only [Finset.prod_div_distrib,conditionalChoicesEquiv] + exact mul_div_mul_comm _ _ _ _ + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GroupedLogBounds.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GroupedLogBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..74b27876e90321d71d039b3151f01f8162bcb089 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GroupedLogBounds.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.LinearEvenMoment +import OAI.Probability.BinarySweep.GridBounds.BoardOverlap + +namespace OAI + +noncomputable section +open scoped BigOperators Classical MonoidAlgebra ComplexOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation TraceHolder + +lemma prod_pos_log_exp {I : Type*} [Fintype I] (d : I → ℝ) (hd : ∀i, 0 natShift_pow_exp (n i) _) + +lemma irreducible_finrank_pos {G W : Type*} [Group G] + [AddCommGroup W] [Module ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G W) [ρ.IsIrreducible] : 0 Young.partitionHilbertRep (a i).val))=1 := by + unfold blockProjection + rw [←submatrix_sum_eq] + have hs := piTensorMatrices_sum (fun i (a : ActiveType p (n i)) => + isotypicProjection p (Young.partitionHilbertRep a.val)) + rw [←hs] + have he : (fun i => ∑a : ActiveType p (n i), + isotypicProjection p (Young.partitionHilbertRep a.val)) = (fun i => (1 : Matrix (Fin (n i) → A) (Fin (n i) → A) ℂ)) := by + funext i + exact active_typeProjection_sum p (n i) + rw [he,piTensorMatrices_one,Matrix.submatrix_one_equiv] + +lemma groupedActive_projection_sum (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : Equiv.Perm (Fin N)) (p : A → Bool) : + (∑a : ∀i, ActiveType p (n i), + groupedProjection e g p (fun i => Young.partitionHilbertRep (a i).val))=1 := by + unfold groupedProjection signedConj + rw [←Finset.sum_mul,←Finset.mul_sum,blockActive_projection_sum,mul_one,actionMatrix_unitary] + +lemma blockActive_card (p : A → Bool) : + Fintype.card (∀i, ActiveType p (n i))≤∏i,(n i+1)^((Fintype.card A)^2) := by + rw [Fintype.card_pi] + exact Finset.prod_le_prod (fun i _ => activeType_card p (n i)) + +end BinaryCoordinateSweeps.Signed + +end + +section + +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {A I J : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + +omit [Nonempty A] in +theorem whitened_board_budget {n : ℕ} (e : Fin n ↪ I × J) + (r : I → Matrix A A ℂ) (v : J → Matrix A A ℂ) (C : Matrix A A ℂ) + (hr : ∀ i, (r i).PosSemidef) (hv : ∀ j, (v j).PosSemidef) + (htv : ∀ j, (v j).trace = 1) {ε : ℝ} (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hC : C.IsHermitian) (hCMC : C * regularizedMean r ε * C = 1) : + (1-ε)^n * (tensorMatrices (fun t : Fin n => C * r (e t).1 * C) * + tensorMatrices (fun t : Fin n => v (e t).2)).trace.re ≤ + Real.exp (Fintype.card I * Fintype.card J - (n : ℝ)) := by + let x : I → J → ℝ := fun i j => (C*r i*C*v j).trace.re + have hp (i : I) : (C*r i*C).PosSemidef := by + simpa only [hC.eq] using (hr i).mul_mul_conjTranspose_same C + have hx (i : I) (j : J) : 0 ≤ x i j := trace_product_re_nonneg (hp i) (hv j) + have hs (j : J) : ∑ i, (1-ε)*x i j ≤ Fintype.card I := by + rw [← Finset.mul_sum] + exact whitened_column_budget r (v j) C hr (hv j) (htv j) hε hC hCMC + have he := rectangular_product_holes (Finset.univ.map e) (fun i j => (1-ε)*x i j) + (fun i j => mul_nonneg (sub_nonneg.mpr hε1) (hx i j)) hs + rw [Finset.prod_map,Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ, + Fintype.card_fin,Finset.card_map,Finset.card_univ,Fintype.card_fin] at he + rw [tensor_product_trace_re _ _ (fun t => hp (e t).1) (fun t => hv (e t).2)] + exact he + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder MatrixOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [DecidableEq I] + +lemma matrix_norm_sq_le_trace (M : Matrix I I ℂ) : ‖M‖^2 ≤ (M.conjTranspose*M).trace.re := by + have h := pow_le_pow_left₀ (norm_nonneg M) (TraceHolder.op_norm_le_schatten (q:=1) (by omega) M) 2 + have he := TraceHolder.schatten_pow (q:=1) (by omega) M + simpa only [Nat.mul_one,he,TraceHolder.matrixMoment,pow_one,Matrix.star_eq_conjTranspose] using h + +lemma projection_overlap_norm_trace (R Q P : Matrix I I ℂ) + (hR : R.IsHermitian) (hQ : Q.IsHermitian) (hP : P.IsHermitian) + (hRR : R*R=R) (hQQ : Q*Q=Q) (hPP : P*P=P) (hPQ : P*Q=Q*P) : + ‖Q*P*R‖^2 ≤ (R*Q*P).trace.re := by + have h := matrix_norm_sq_le_trace (Q*P*R) + have he : ((Q*P*R).conjTranspose*(Q*P*R)).trace = (R*Q*P).trace := by + simp only [Matrix.conjTranspose_mul,hR.eq,hQ.eq,hP.eq] + calc + _ = (R*(P*(Q*Q)*P)*R).trace := by congr 1; noncomm_ring + _ = (R*(Q*P)*R).trace := by rw [hQQ,hPQ,mul_assoc Q P P,hPP] + _ = (R*R*(Q*P)).trace := by rw [Matrix.trace_mul_cycle] + _ = _ := by rw [hRR,mul_assoc] + rw [he] at h + exact h + +omit [DecidableEq I] in +lemma commuting_projection_product_psd (P Q : Matrix I I ℂ) + (hP : P.PosSemidef) (hQ : Q.IsHermitian) (hQQ : Q*Q=Q) (hPQ : P*Q=Q*P) : + (Q*P).PosSemidef := by + have h := hP.mul_mul_conjTranspose_same Q + rw [hQ.eq,mul_assoc, hPQ,← mul_assoc,hQQ] at h + exact h + +omit [DecidableEq I] in +lemma compress_whitening_cap (P Q C : Matrix I I ℂ) (d : ℂ) + (hQ : Q.IsHermitian) (hQQ : Q*Q=Q) (hPQ : P*Q=Q*P) (hCQ : C*Q=Q*C) + (hc : (C*C-d•P).PosSemidef) : (C*Q*C-d•(Q*P)).PosSemidef := by + have h := hc.mul_mul_conjTranspose_same Q + rw [hQ.eq,Matrix.mul_sub,Matrix.sub_mul,Matrix.mul_smul,Matrix.smul_mul] at h + have he1 : Q*(C*C)*Q = C*Q*C := by + calc + _ = (Q*C)*(C*Q) := by noncomm_ring + _ = (C*Q)*(Q*C) := by rw [hCQ,← hCQ] + _ = C*(Q*Q)*C := by noncomm_ring + _ = _ := by rw [hQQ] + have he2 : Q*P*Q = Q*P := by rw [mul_assoc,hPQ,← mul_assoc,hQQ] + rwa [he1,he2] at h + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GroupedTypes.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GroupedTypes.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c006f792686388d6afd3f2782728056d349092d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GroupedTypes.lean @@ -0,0 +1,73 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.BlockTypes + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation + +variable {I A : Type*} [Fintype I] [LinearOrder I] + [Fintype A] [DecidableEq A] {n : I → ℕ} {N : ℕ} + {V : I → Type*} [∀i, NormedAddCommGroup (V i)] + [∀i, InnerProductSpace ℂ (V i)] [∀i, FiniteDimensional ℂ (V i)] + +def groupOf (e : (Σₗ i, Fin (n i)) ≃o Fin N) (g : Equiv.Perm (Fin N)) (t : Fin N) : I := + (ofLex (e.symm (g⁻¹ t))).1 + +def groupedProjection (e : (Σₗ i, Fin (n i)) ≃o Fin N) (g : Equiv.Perm (Fin N)) + (p : A → Bool) (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) := + signedConj p g (blockProjection e p ρ) + +omit [∀i, FiniteDimensional ℂ (V i)] in +lemma groupedProjection_psd (e : (Σₗ i, Fin (n i)) ≃o Fin N) (g : Equiv.Perm (Fin N)) + (p : A → Bool) (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) : + (groupedProjection e g p ρ).PosSemidef := + signedConj_psd p g _ (blockProjection_psd e p ρ) + +omit [∀i, FiniteDimensional ℂ (V i)] in +lemma groupedProjection_idempotent (e : (Σₗ i, Fin (n i)) ≃o Fin N) (g : Equiv.Perm (Fin N)) + (p : A → Bool) (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) : + groupedProjection e g p ρ*groupedProjection e g p ρ=groupedProjection e g p ρ := by + unfold groupedProjection + rw [← signedConj_mul,blockProjection_idempotent] + +omit [∀i, FiniteDimensional ℂ (V i)] in +lemma groupedProjection_commutes (e : (Σₗ i, Fin (n i)) ≃o Fin N) (g : Equiv.Perm (Fin N)) + (p : A → Bool) (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) + (M : Matrix (Fin N → A) (Fin N → A) ℂ) (hM : Invariant p M) : + M*groupedProjection e g p ρ=groupedProjection e g p ρ*M := by + apply signedConj_commutes p g M _ (invariant_matrix_commutes p M hM g) + apply blockProjection_central e p ρ + intro h + exact invariant_matrix_commutes p M hM (blockPerm e h) + +lemma grouped_density_domination [Nonempty A] (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : Equiv.Perm (Fin N)) (p : A → Bool) + (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) + [∀i, (ρ i).IsIrreducible] : + (((∏i, (Module.finrank ℂ (V i):ℂ)*(n i+1:ℂ)^(2*(Fintype.card A)^2))) • + (∑u : ∀i, LocalDensityIndex p (n i), + tensorMatrices (fun t => localDensity p (n (groupOf e g t)) (u (groupOf e g t)))) - + groupedProjection e g p ρ).PosSemidef := by + have h := signedConj_psd p g _ (block_density_domination e p ρ) + rw [signedConj_sub_smul_sum] at h + have he (u : ∀i, LocalDensityIndex p (n i)) : + signedConj p g (tensorMatrices (fun t => localDensity p (n (ofLex (e.symm t)).1) (u (ofLex (e.symm t)).1))) = + tensorMatrices (fun t => localDensity p (n (groupOf e g t)) (u (groupOf e g t))) := by + exact even_tensor_covariance p g _ (fun t => localDensity_even p _ _) + simpa only [he,groupedProjection] using h + +lemma grouped_density_card_bound (p : A → Bool) : + Fintype.card (∀i, LocalDensityIndex p (n i)) ≤ ∏i, (n i+1)^(2*(Fintype.card A)^2) := by + rw [Fintype.card_pi] + exact Finset.prod_le_prod (fun i _ => localDensityIndex_card p (n i)) + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/GroupingGeometry.lean b/lean/OAI/Probability/BinarySweep/GridBounds/GroupingGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9ee15ab627c180c5a96bb88637ef4cbd3d9b1df --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/GroupingGeometry.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GroupedTypes + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Signed +variable {I : Type*} [Fintype I] [LinearOrder I] + {X : I → Type*} [∀i,Fintype (X i)] {N : ℕ} + +omit [LinearOrder I] in +theorem groupingCard (e : (Σi, X i) ≃ Fin N) : + Fintype.card (Σₗ i, Fin (Fintype.card (X i)))=N := by + change Fintype.card (Σi, Fin (Fintype.card (X i)))=N + have he := Fintype.card_congr e + simpa only [Fintype.card_sigma,Fintype.card_fin] using he + +def groupingOrder (e : (Σi, X i) ≃ Fin N) : + (Σₗ i, Fin (Fintype.card (X i))) ≃o Fin N := + (Fintype.orderIsoFinOfCardEq _ (groupingCard e)).symm + +def groupingPerm (e : (Σi, X i) ≃ Fin N) : Equiv.Perm (Fin N) := + ((groupingOrder e).symm.toEquiv.trans ofLex).trans + ((Equiv.sigmaCongrRight (fun i => (Fintype.equivFin (X i)).symm)).trans e) + +lemma groupingPerm_apply (e : (Σi, X i) ≃ Fin N) (i : I) (a : Fin (Fintype.card (X i))) : + groupingPerm e (groupingOrder e (toLex ⟨i,a⟩))=e ⟨i,(Fintype.equivFin (X i)).symm a⟩ := by + simp [groupingPerm,Equiv.sigmaCongrRight] + +@[simp] lemma groupingPerm_inv_apply (e : (Σi, X i) ≃ Fin N) (i : I) (x : X i) : + (groupingPerm e)⁻¹ (e ⟨i,x⟩)=groupingOrder e (toLex ⟨i,Fintype.equivFin (X i) x⟩) := by + apply (groupingPerm e).injective + rw [groupingPerm_apply,Equiv.symm_apply_apply] + exact (groupingPerm e).apply_symm_apply _ + +lemma grouping_groupOf (e : (Σi, X i) ≃ Fin N) (t : Fin N) : + groupOf (groupingOrder e) (groupingPerm e) t=(e.symm t).1 := by + simp [groupOf,groupingPerm,Equiv.sigmaCongrRight] + +lemma grouping_permutation (e : (Σi, X i) ≃ Fin N) + (a : ∀i, Equiv.Perm (X i)) : + e.permCongr (Equiv.Perm.sigmaCongrRight a)= + groupingPerm e*blockPerm (groupingOrder e) + (fun i => (Fintype.equivFin (X i)).permCongr (a i))*(groupingPerm e)⁻¹ := by + apply Equiv.ext + intro t + obtain ⟨⟨i,x⟩,rfl⟩ := e.surjective t + simp only [Equiv.Perm.mul_apply,groupingPerm_inv_apply,blockPerm_apply,groupingPerm_apply, + Equiv.permCongr_apply,Equiv.symm_apply_apply] + rfl + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/GridBounds/ProjectionSplitting.lean b/lean/OAI/Probability/BinarySweep/GridBounds/ProjectionSplitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..795863ec91fe515636bac1106452ce9050c28c93 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/GridBounds/ProjectionSplitting.lean @@ -0,0 +1,130 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.SchattenTriangle + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι α β : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] [Fintype β] + +lemma projection_sandwich_split (X Y P : M ι) (R : α → M ι) (C : β → M ι) + (hR : ∀a, R a*R a=R a) (hC : ∀b, C b*C b=C b) + (hsR : ∑a, R a=1) (hsC : ∑b, C b=1) : + Y*P*X = ∑b, ∑a, (Y*C b)*(C b*P*R a)*(R a*X) := by + have he (a : α) (b : β) : (Y*C b)*(C b*P*R a)*(R a*X)=Y*C b*P*R a*X := by + simp only [mul_assoc,← mul_assoc (C b) (C b),hC b, + ← mul_assoc (R a) (R a),hR a] + simp_rw [he] + simp only [← Finset.sum_mul,← Finset.mul_sum,hsR,hsC,mul_one] + +theorem schatten_projection_split {q : ℕ} (hq : 0 schatten_sandwich hq _ _ _ + +theorem matrixMoment_projection_split_bound {q : ℕ} (hq : 0 Finset.sum_le_sum fun a _ => ht a b + _ = _ := by simp [mul_comm,mul_assoc] + have hh := pow_le_pow_left₀ (schatten_nonneg _ _) hs (2*q) + simpa only [schatten_pow hq,mul_pow] using hh + +end BinaryCoordinateSweeps.TraceHolder + +end + +open scoped BigOperators Classical Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder + +lemma overlap_power_le {x c L : ℝ} {q : ℕ} (hx : 0≤x) (hx1 : x≤1) + (hc : 0≤c) (hcq : c≤q) (hq : 0 A j (x j) (Fin.snoc (α := fun _ => P) x b j.succ)).prod + +omit [Fintype P] [DecidableEq P] in +lemma snoc_cons_succ {n : ℕ} (a : P) (x : Fin n → P) (b : P) (j : Fin (n+1)) : + Fin.snoc (α := fun _ => P) (Fin.cons a x) b j.succ = + Fin.snoc (α := fun _ => P) x b j := by + refine Fin.lastCases ?_ (fun i => ?_) j + · simp + · rw [Fin.succ_castSucc] + simp only [Fin.snoc_castSucc, Fin.cons_succ] + +omit [Fintype P] [DecidableEq P] in +lemma pathProduct_cons {n : ℕ} (A : Fin (n+1) → Matrix P P R) + (a : P) (x : Fin n → P) (b : P) : + pathProduct A (Fin.cons a x) b = + A 0 a (Fin.snoc (α := fun _ => P) x b 0) * pathProduct (fun j => A j.succ) x b := by + simp only [pathProduct, List.ofFn_succ, List.prod_cons, Fin.cons_zero, Fin.cons_succ, + snoc_cons_succ] + +lemma prod_apply_sum_path {n : ℕ} (A : Fin (n+1) → Matrix P P R) (a b : P) : + (List.ofFn A).prod a b = ∑ x : Fin n → P, pathProduct A (Fin.cons a x) b := by + induction n generalizing a with + | zero => simp [pathProduct, Fin.snoc] + | succ n ih => + rw [List.ofFn_succ, List.prod_cons, Matrix.mul_apply] + simp_rw [ih] + rw [← (Fin.consEquiv (fun _ : Fin (n+1) => P)).sum_comp, Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro c _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + change A 0 a c * pathProduct (fun j => A j.succ) (Fin.cons c x) b = + pathProduct A (Fin.cons a (Fin.cons c x)) b + rw [pathProduct_cons A] + congr 2 + +omit [Fintype P] [DecidableEq P] in +lemma snoc_cycle {n : ℕ} (x : Fin (n+1) → P) (j : Fin (n+1)) : + Fin.snoc (α := fun _ => P) x (x 0) j.succ = x (finRotate (n+1) j) := by + refine Fin.lastCases ?_ (fun i => ?_) j + · simp + · rw [Fin.succ_castSucc, Fin.snoc_castSucc] + simp [finRotate_apply, Fin.coeSucc_eq_succ] + +lemma trace_prod_eq_sum_cycles {n : ℕ} (A : Fin (n+1) → Matrix P P R) : + Matrix.trace (List.ofFn A).prod = + ∑ x : Fin (n+1) → P, + (List.ofFn fun j => A j (x j) (x (finRotate (n+1) j))).prod := by + change (∑ i : P, (List.ofFn A).prod i i) = _ + simp_rw [prod_apply_sum_path] + calc + _ = ∑ y : P × (Fin n → P), pathProduct A (Fin.cons y.1 y.2) y.1 := by + exact (Fintype.sum_prod_type (fun y : P × (Fin n → P) => + pathProduct A (Fin.cons y.1 y.2) y.1)).symm + _ = ∑ x : Fin (n+1) → P, pathProduct A x (x 0) := by + simpa only [Fin.consEquiv, Equiv.coe_fn_mk, Fin.cons_zero] using + (Fin.consEquiv (fun _ : Fin (n+1) => P)).sum_comp (fun x => pathProduct A x (x 0)) + _ = _ := by + apply Finset.sum_congr rfl + intro x _ + simp only [pathProduct, snoc_cycle] +end Expansion + +variable {P ι : Type*} [Fintype P] [DecidableEq P] [Fintype ι] [DecidableEq ι] + +def flattenBlocks (A : Matrix P P (M ι)) : M (P × ι) := + fun x y => A x.1 y.1 x.2 y.2 + +omit [DecidableEq P] [DecidableEq ι] in +lemma flattenBlocks_mul (A B : Matrix P P (M ι)) : + flattenBlocks (A * B) = flattenBlocks A * flattenBlocks B := by + ext x y + simp only [flattenBlocks, Matrix.mul_apply, Fintype.sum_prod_type, Matrix.sum_apply] + +omit [Fintype P] [Fintype ι] in +lemma flattenBlocks_one : flattenBlocks (1 : Matrix P P (M ι)) = 1 := by + ext ⟨x,i⟩ ⟨y,j⟩ + by_cases hxy : x = y <;> by_cases hij : i = j <;> + simp [flattenBlocks, Matrix.one_apply, hxy, hij, Prod.mk.injEq] + +def flattenBlocksHom : Matrix P P (M ι) →* M (P × ι) where + toFun := flattenBlocks + map_one' := flattenBlocks_one + map_mul' := flattenBlocks_mul + +omit [DecidableEq P] [DecidableEq ι] in +lemma trace_flattenBlocks (A : Matrix P P (M ι)) : + Matrix.trace (flattenBlocks A) = Matrix.trace (Matrix.trace A) := by + change (∑ x : P × ι, A x.1 x.1 x.2 x.2) = ∑ i : ι, (∑ p : P, A p p) i i + simp only [Fintype.sum_prod_type, Matrix.sum_apply] + exact Finset.sum_comm + +lemma trace_flatten_prod {n : ℕ} (A : Fin (n+1) → Matrix P P (M ι)) : + Matrix.trace (List.ofFn (fun j => flattenBlocks (A j))).prod = + ∑ x : Fin (n+1) → P, + Matrix.trace (List.ofFn fun j => A j (x j) (x (finRotate (n+1) j))).prod := by + have hp : (List.ofFn (fun j => flattenBlocks (A j))).prod = + flattenBlocks (List.ofFn A).prod := by + simpa only [List.map_ofFn, flattenBlocksHom, MonoidHom.coe_mk, OneHom.coe_mk, Function.comp_def] using + (map_list_prod (flattenBlocksHom (P := P) (ι := ι)) (List.ofFn A)).symm + rw [hp, trace_flattenBlocks, trace_prod_eq_sum_cycles, Matrix.trace_sum] + +theorem block_trace_holder {q : ℕ} (hq : 0 < q) + (A : Fin (2*q) → Matrix P P (M ι)) : + ‖Matrix.trace (List.ofFn (fun j => flattenBlocks (A j))).prod‖ ≤ + ∑ x : Fin (2*q) → P, + ∏ j, matrixMoment q (A j (x j) (x (finRotate (2*q) j))) ^ (((2*q : ℕ) : ℝ)⁻¹) := by + have ht : Matrix.trace (List.ofFn (fun j => flattenBlocks (A j))).prod = + ∑ x : Fin (2*q) → P, + Matrix.trace (List.ofFn fun j => A j (x j) (x (finRotate (2*q) j))).prod := by + generalize hm : 2*q = m at A ⊢ + cases m with + | zero => omega + | succ n => exact trace_flatten_prod A + rw [ht] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun x _ => matrix_trace_holder hq _) + +theorem weighted_block_trace_holder {q : ℕ} (hq : 0 < q) + (p : Fin (2*q) → P → P → ℝ) (hp : ∀ j x y, 0 ≤ p j x y) + (F : Fin (2*q) → P → P → M ι) : + ‖Matrix.trace (List.ofFn fun j => flattenBlocks + (fun x y => p j x y • F j x y)).prod‖ ≤ + ∑ x : Fin (2*q) → P, + (∏ j, p j (x j) (x (finRotate (2*q) j))) * + ∏ j, matrixMoment q (F j (x j) (x (finRotate (2*q) j))) ^ (((2*q : ℕ) : ℝ)⁻¹) := by + have ht : Matrix.trace (List.ofFn fun j => flattenBlocks + (fun x y => p j x y • F j x y)).prod = + ∑ x : Fin (2*q) → P, + Matrix.trace (List.ofFn fun j => p j (x j) (x (finRotate (2*q) j)) • + F j (x j) (x (finRotate (2*q) j))).prod := by + generalize hm : 2*q = m at p F ⊢ + cases m with + | zero => omega + | succ n => exact trace_flatten_prod _ + rw [ht] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro x _ + rw [prod_ofFn_smul, Matrix.trace_smul, norm_smul, Real.norm_eq_abs, + abs_of_nonneg (Finset.prod_nonneg (fun j _ => hp j _ _))] + exact mul_le_mul_of_nonneg_left (matrix_trace_holder hq _) + (Finset.prod_nonneg (fun j _ => hp j _ _)) + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/CenteredMatrix.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/CenteredMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..c01fd3b054594ea00ae44e288469627a08b2900f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/CenteredMatrix.lean @@ -0,0 +1,50 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.MatrixProjection +import OAI.Probability.BinarySweep.SparseBounds.CenteredMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexConjugate + +namespace BinaryCoordinateSweeps.Young +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] + +def centeredMatrix (s : ℝ) (p : Equiv.Perm X → ℂ) : Matrix (I ↪ X) (I ↪ X) ℂ := + ∑A ∈ (Finset.univ : Finset I).powerset, + ((-1:ℂ)^(Fintype.card I-A.card)*(s:ℂ)^A.card/(s:ℂ)^Fintype.card I) • + ∑g, p g • partialKernel A g + +omit [DecidableEq I] in +lemma centeredMatrix_toLin (s : ℝ) (p : Equiv.Perm X → ℂ) : + (centeredMatrix (I:=I) s p).toEuclideanLin=centeredHilbert s p := by + simp only [centeredMatrix,map_sum,map_smul,partialKernel_toLin,centeredHilbert_sum] + +lemma evenMoment_one_matrix {J : Type*} [Fintype J] [DecidableEq J] + (M : Matrix J J ℂ) : Irrep.evenMoment 1 M.toEuclideanLin = ∑x,∑y, ‖M y x‖^2 := by + have hc (z : ℂ) : (star z*z).re=‖z‖^2 := by + rw [Complex.star_def,Complex.conj_mul',← Complex.ofReal_pow,Complex.ofReal_re] + unfold Irrep.evenMoment + rw [pow_one,← Matrix.toEuclideanLin_conjTranspose_eq_adjoint,Module.End.mul_eq_comp,← Matrix.toLpLin_mul_same, + Density.trace_toEuclideanLinear] + simp only [Matrix.trace,Matrix.diag,Matrix.mul_apply,Matrix.conjTranspose_apply, + Complex.re_sum] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro y _ + exact hc (M y x) + +theorem specht_moment_one_le_centered_matrix (μ : YoungDiagram) (s : ℝ) (hs : s≠0) + (p : G μ → ℂ) : + Irrep.evenMoment 1 (Irrep.groupAverage (hilbertSpecht μ) p) ≤ + ∑x : Tail μ ↪ Cell μ, ∑y, ‖centeredMatrix s p y x‖^2 := by + have he := centeredHilbert_moment μ s hs p 1 + rw [← centeredMatrix_toLin,evenMoment_one_matrix] at he + exact he + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/FourierTrace.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/FourierTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..5da21e364ef3c5610ab032ed06cefea04730ec24 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/FourierTrace.lean @@ -0,0 +1,60 @@ +import Mathlib +import OAI.Probability.BinarySweep.Model +import OAI.Probability.BinarySweep.Representations.IsotypicProjectionMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Fourier +open Representation Irrep Young + +theorem young_trace_resolution {n : ℕ} (p : Equiv.Perm (Fin n) → ℂ) (q : ℕ) : + evenMoment q (groupAverage (regular (Equiv.Perm (Fin n))) p)= + ∑ℓ : n.Partition,(Module.finrank ℂ (PartitionHilbert ℓ):ℝ)* + evenMoment q (groupAverage (partitionHilbertRep ℓ) p) := by + let σ := regular (Equiv.Perm (Fin n)) + let B := ((groupAverage σ p).adjoint*groupAverage σ p)^q + let S := fun ℓ : n.Partition => isotypicSpan (partitionHilbertRep ℓ) σ + have hP : (∑ℓ : n.Partition,(S ℓ).starProjection.toLinearMap)=1 := by + apply LinearMap.ext + intro v + simp only [LinearMap.sum_apply,ContinuousLinearMap.coe_coe,Module.End.one_apply] + exact partition_projection_sum σ (regular_unitary _) v + have he (ℓ : n.Partition) : + LinearMap.trace ℂ (RegularSpace (Equiv.Perm (Fin n))) + (B*(S ℓ).starProjection.toLinearMap)= + (Module.finrank ℂ (PartitionHilbert ℓ):ℂ)* + LinearMap.trace ℂ (PartitionHilbert ℓ) + (((groupAverage (partitionHilbertRep ℓ) p).adjoint* + groupAverage (partitionHilbertRep ℓ) p)^q) := by + have hc := even_compatible (partitionHilbertRep ℓ) σ p + (partitionHilbertRep_unitary ℓ) (regular_unitary _) q + rw [trace_mul_projection _ _ (isotypic_invariant_of_compatible _ _ _ _ hc), + isotypic_trace _ _ _ _ hc,regular_multiplicity] + unfold evenMoment + change (LinearMap.trace ℂ _ B).re=_ + rw [←mul_one B,←hP,Finset.mul_sum,map_sum,Complex.re_sum] + apply Finset.sum_congr rfl + intro ℓ _ + rw [he] + simp + +theorem variation_fourier_bound {n : ℕ} (p q : Equiv.Perm (Fin n) → ℝ) : + totalVariation p q ^2 ≤ (1/4:ℝ)* + ∑ℓ : n.Partition,(Module.finrank ℂ (PartitionHilbert ℓ):ℝ)* + evenMoment 1 (groupAverage (partitionHilbertRep ℓ) (fun g => (p g-q g:ℂ))) := by + have hc := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset (Equiv.Perm (Fin n))) + (fun _ => (1:ℝ)) (fun g => |p g-q g|) + simp only [one_mul,one_pow,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_one,sq_abs] at hc + rw [←young_trace_resolution,regular_moment_one] + simp only [←Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs,sq_abs] + unfold totalVariation + nlinarith + +end BinaryCoordinateSweeps.Fourier + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/HilbertBlockTrace.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/HilbertBlockTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..27c9d5b84daaee4741c7bc1050ca4afdc0f71040 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/HilbertBlockTrace.lean @@ -0,0 +1,145 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.LinearEvenMoment +import OAI.Probability.BinarySweep.YoungTheory.HookInducedMoment +import OAI.Probability.BinarySweep.MatrixBounds.BlockTrace + +namespace OAI + + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open TraceHolder + +variable {I W : Type*} [Fintype I] [DecidableEq I] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] +local notation "HW" => CoindHilbertSpace (I:=I) (W:=W) + +omit [DecidableEq I] [FiniteDimensional ℂ W] in +lemma fiber_sum (v : HW) : ∑i, fiberInclude i (v i)=v := by + classical + apply (WithLp.linearEquiv 2 ℂ (I → W)).injective + simp only [map_sum] + ext i + simp only [fiberInclude,LinearMap.comp_apply,LinearEquiv.coe_coe, + LinearEquiv.apply_symm_apply,LinearMap.single_apply,Finset.sum_apply,Pi.single_apply] + simp only [WithLp.coe_linearEquiv] + let : DecidableEq I := fun i j => Classical.propDecidable (i=j) + exact (Finset.sum_ite_eq Finset.univ i (fun x => v x)).trans (ite_eq_left (Finset.mem_univ i)) + +omit [DecidableEq I] [FiniteDimensional ℂ W] in +lemma fiber_identity : (∑i : I, (fiberInclude i).comp (fiberProject i))=(1 : HW →ₗ[ℂ] HW) := by + apply LinearMap.ext + intro v + simpa only [LinearMap.sum_apply,LinearMap.comp_apply, fiberProject, Module.End.one_apply, + LinearEquiv.coe_coe, LinearMap.proj_apply, WithLp.coe_linearEquiv] using fiber_sum v + +omit [DecidableEq I] [FiniteDimensional ℂ W] in +lemma hilbertBlock_mul (A B : HW →ₗ[ℂ] HW) (i j : I) : + hilbertBlock (A*B) i j = ∑a, hilbertBlock A i a * hilbertBlock B a j := by + ext v + change A (B (fiberInclude j v)) i = _ + conv_lhs => rw [← fiber_sum (B (fiberInclude j v))] + simp only [map_sum,LinearMap.sum_apply,Module.End.mul_apply] + change (WithLp.linearEquiv 2 ℂ (I → W)) (∑ x, A (fiberInclude x (B (fiberInclude j v) x))) i = _ + rw [map_sum,Finset.sum_apply] + rfl + +omit [Fintype I] [FiniteDimensional ℂ W] in +lemma hilbertBlock_one (i j : I) : hilbertBlock (1 : HW →ₗ[ℂ] HW) i j = if i=j then 1 else 0 := by + ext v + change fiberInclude j v i = _ + rw [fiberInclude_apply] + split_ifs <;> rfl + +omit [Fintype I] [DecidableEq I] [FiniteDimensional ℂ W] in +lemma hilbertBlock_sum {J : Type*} (s : Finset J) (A : J → HW →ₗ[ℂ] HW) (i j : I) : + hilbertBlock (∑a∈s,A a) i j = ∑a∈s,hilbertBlock (A a) i j := by + ext v + simp [hilbertBlock,LinearMap.sum_apply,LinearMap.comp_apply,map_sum] + +omit [Fintype I] [DecidableEq I] [FiniteDimensional ℂ W] in +lemma hilbertBlock_smul (r : ℝ) (A : HW →ₗ[ℂ] HW) (i j : I) : + hilbertBlock (r • A) i j=r • hilbertBlock A i j := by + ext v + simp [hilbertBlock] + +lemma fiber_adjoint (i : I) : (fiberInclude i : W →ₗ[ℂ] HW).adjoint=fiberProject i := by + symm + apply (LinearMap.eq_adjoint_iff _ _).mpr + intro x y + simp only [PiLp.inner_apply,fiberInclude_apply,apply_ite,inner_zero_right] + change _ = ∑j, if j=i then inner ℂ (x j) y else 0 + simp only [fiberProject,LinearMap.comp_apply,LinearMap.proj_apply,LinearEquiv.coe_coe, + WithLp.coe_linearEquiv,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + +lemma hilbertBlock_adjoint (A : HW →ₗ[ℂ] HW) (i j : I) : + hilbertBlock A.adjoint i j=(hilbertBlock A j i).adjoint := by + unfold hilbertBlock + rw [LinearMap.adjoint_comp,LinearMap.adjoint_comp,fiber_adjoint, + ← fiber_adjoint (W:=W) j,LinearMap.adjoint_adjoint] + rfl + +def hilbertBlocksHom : (HW →ₗ[ℂ] HW) →* Matrix I I (W →ₗ[ℂ] W) where + toFun A := hilbertBlock A + map_one' := by funext i j; exact hilbertBlock_one i j + map_mul' A B := by funext i j; exact hilbertBlock_mul A B i j + +omit [DecidableEq I] in +lemma trace_hilbertBlocks (A : HW →ₗ[ℂ] HW) : + LinearMap.trace ℂ HW A = ∑i, LinearMap.trace ℂ W (hilbertBlock A i i) := by + conv_lhs => rw [← mul_one A,← fiber_identity] + rw [Finset.mul_sum,map_sum] + apply Finset.sum_congr rfl + intro i _ + change LinearMap.trace ℂ HW ((A.comp (fiberInclude i)).comp (fiberProject i)) = _ + rw [LinearMap.trace_comp_comm'] + rfl + +lemma trace_hilbertBlocks_prod {n : ℕ} (A : Fin (n+1) → HW →ₗ[ℂ] HW) : + LinearMap.trace ℂ HW (List.ofFn A).prod = + ∑x : Fin (n+1) → I, LinearMap.trace ℂ W + (List.ofFn (fun j => hilbertBlock (A j) (x j) (x (finRotate (n+1) j)))).prod := by + rw [trace_hilbertBlocks] + rw [← map_sum] + change LinearMap.trace ℂ W (Matrix.trace (hilbertBlocksHom (I:=I) (W:=W) (List.ofFn A).prod)) = _ + have hm := (hilbertBlocksHom (I:=I) (W:=W)).map_list_prod (List.ofFn A) + rw [List.map_ofFn] at hm + rw [hm,trace_prod_eq_sum_cycles,map_sum] + rfl + +theorem hilbert_block_trace_holder {q : ℕ} (hq : 0 hilbertBlock (A j) (x j) (x (finRotate (2*q) j)))).prod := by + generalize hm : 2*q=m at A ⊢ + cases m with + | zero => omega + | succ n => exact trace_hilbertBlocks_prod A + rw [ht] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum (fun _ _ => linear_trace_holder hq _)) + +theorem evenMoment_blocks_le {q : ℕ} (hq : 0 if j.val%2=0 then K.adjoint else K) + rw [alternating_prod] at ht + refine (Complex.re_le_norm _).trans (ht.trans_eq ?_) + apply Finset.sum_congr rfl + intro x _ + apply Finset.prod_congr rfl + intro j _ + split_ifs <;> simp only [hilbertBlock_adjoint,evenMoment_adjoint] + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixProjection.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..89c23a0e1afb6fe88fbf9b3b4272178b5a7d0109 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixProjection.lean @@ -0,0 +1,71 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [DecidableEq I] + +def projectionMatrix (S : Submodule ℂ (EuclideanSpace ℂ I)) : Matrix I I ℂ := + (Matrix.toEuclideanCLM (𝕜 := ℂ)).symm S.starProjection + +lemma projectionMatrix_linear (S : Submodule ℂ (EuclideanSpace ℂ I)) : + (projectionMatrix S).toEuclideanLin = S.starProjection.toLinearMap := by + have h := (Matrix.toEuclideanCLM (𝕜 := ℂ)).apply_symm_apply S.starProjection + exact congrArg ContinuousLinearMap.toLinearMap h + +lemma projectionMatrix_psd (S : Submodule ℂ (EuclideanSpace ℂ I)) : + (projectionMatrix S).PosSemidef := by + rw [← Matrix.isPositive_toEuclideanLin_iff, projectionMatrix_linear] + exact (Submodule.isSymmetricProjection_starProjection S).isPositive + +lemma projectionMatrix_idempotent (S : Submodule ℂ (EuclideanSpace ℂ I)) : + projectionMatrix S * projectionMatrix S = projectionMatrix S := by + apply (Matrix.toEuclideanCLM (𝕜 := ℂ)).injective + simp only [map_mul] + have h : (Matrix.toEuclideanCLM (𝕜 := ℂ)).toRingEquiv (projectionMatrix S) = + S.starProjection := (Matrix.toEuclideanCLM (𝕜 := ℂ)).apply_symm_apply _ + rw [h] + exact S.isIdempotentElem_starProjection + +lemma trace_toEuclideanLinear (M : Matrix I I ℂ) : + LinearMap.trace ℂ (EuclideanSpace ℂ I) M.toEuclideanLin = M.trace := by + rw [LinearMap.trace_eq_sum_inner _ (EuclideanSpace.basisFun I ℂ)] + unfold Matrix.trace + apply Finset.sum_congr rfl + intro i _ + simp [EuclideanSpace.basisFun_apply, PiLp.inner_apply, Matrix.ofLp_toLpLin, + Matrix.toLin'_apply, PiLp.ofLp_single, Matrix.mulVec, dotProduct, Pi.single_apply] + +lemma projectionMatrix_trace (S : Submodule ℂ (EuclideanSpace ℂ I)) : + (projectionMatrix S).trace = (Module.finrank ℂ S : ℂ) := by + rw [← trace_toEuclideanLinear, projectionMatrix_linear] + have h : LinearMap.IsProj S S.starProjection.toLinearMap := + ⟨S.starProjection_apply_mem, fun v hv => Submodule.starProjection_eq_self_iff.mpr hv⟩ + exact h.trace + +lemma projectionMatrix_coeff (S : Submodule ℂ (EuclideanSpace ℂ I)) : + LinearMap.toMatrix' ((WithLp.linearEquiv 2 ℂ (I → ℂ)).conj S.starProjection.toLinearMap) = + projectionMatrix S := by + apply Matrix.toEuclideanLin.injective + rw [projectionMatrix_linear] + ext v i + simp only [Matrix.toEuclideanLin, Matrix.toLpLin, LinearEquiv.conj_apply] + simp + +omit [DecidableEq I] in +lemma projectionMatrix_commutes (S : Submodule ℂ (EuclideanSpace ℂ I)) + (f : EuclideanSpace ℂ I →ₗᵢ[ℂ] EuclideanSpace ℂ I) (hf : S.map f.toLinearMap = S) + (v : EuclideanSpace ℂ I) : + f (S.starProjection v) = S.starProjection (f v) := by + have h := f.map_starProjection S v + simpa only [hf] using h + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixRegularize.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixRegularize.lean new file mode 100644 index 0000000000000000000000000000000000000000..b90a13e7b5538b769e4330b9014a8ca005b4f193 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixRegularize.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.Whitening + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder MatrixOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {A I : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + [Fintype I] [Nonempty I] + +def meanDensity (r : I → Matrix A A ℂ) : Matrix A A ℂ := + (Fintype.card I : ℂ)⁻¹ • ∑ i, r i + +def regularizedMean (r : I → Matrix A A ℂ) (ε : ℝ) : Matrix A A ℂ := + (1-ε : ℂ) • meanDensity r + (ε/(Fintype.card A) : ℂ) • 1 + +omit [Fintype A] [DecidableEq A] [Nonempty A] [Nonempty I] in +lemma meanDensity_psd (r : I → Matrix A A ℂ) (hr : ∀ i, (r i).PosSemidef) : + (meanDensity r).PosSemidef := by + exact (Matrix.posSemidef_sum _ (fun i _ => hr i)).smul (by positivity) + +omit [DecidableEq A] [Nonempty A] in +lemma meanDensity_trace (r : I → Matrix A A ℂ) (ht : ∀ i, (r i).trace = 1) : + (meanDensity r).trace = 1 := by + simp [meanDensity,Matrix.trace_sum,Matrix.trace_smul,ht, + ne_of_gt (Fintype.card_pos : 0 < Fintype.card I)] + +lemma regularizedMean_trace (r : I → Matrix A A ℂ) (ht : ∀ i, (r i).trace = 1) (ε : ℝ) : + (regularizedMean r ε).trace = 1 := by + simp [regularizedMean,Matrix.trace_smul,meanDensity_trace r ht,Matrix.trace_one, + ne_of_gt (Fintype.card_pos : 0 < Fintype.card A)] + +omit [Nonempty I] in +lemma regularizedMean_posDef (r : I → Matrix A A ℂ) (hr : ∀ i, (r i).PosSemidef) + {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) : (regularizedMean r ε).PosDef := by + rw [regularizedMean,add_comm] + apply Matrix.PosDef.add_posSemidef + · apply Matrix.PosDef.one.smul + exact_mod_cast div_pos hε (Nat.cast_pos.mpr (Fintype.card_pos : 0 < Fintype.card A)) + · exact (meanDensity_psd r hr).smul (by exact_mod_cast sub_nonneg.mpr hε1) + +omit [Nonempty A] [Nonempty I] in +lemma regularizedMean_even (r : I → Matrix A A ℂ) (p : A → Bool) + (he : ∀ i a b, p a ≠ p b → r i a b = 0) (ε : ℝ) : + ∀ a b, p a ≠ p b → regularizedMean r ε a b = 0 := by + intro a b hab + have hn : a ≠ b := fun h => hab (congrArg p h) + simp [regularizedMean,meanDensity,Matrix.smul_apply,Matrix.sum_apply,he,hab,hn] + +omit [Nonempty A] in +lemma whitened_column_budget (r : I → Matrix A A ℂ) (v C : Matrix A A ℂ) + (_hr : ∀ i, (r i).PosSemidef) (hv : v.PosSemidef) (htv : v.trace = 1) + {ε : ℝ} (hε : 0 ≤ ε) (hC : C.IsHermitian) + (hCMC : C * regularizedMean r ε * C = 1) : + (1-ε) * (∑ i, (C * r i * C * v).trace.re) ≤ Fintype.card I := by + have hd : (regularizedMean r ε - (1-ε:ℂ) • meanDensity r).PosSemidef := by + simp only [regularizedMean,add_sub_cancel_left] + exact Matrix.PosSemidef.one.smul (by exact_mod_cast div_nonneg hε (Nat.cast_nonneg (Fintype.card A))) + have hc := hd.mul_mul_conjTranspose_same C + rw [hC.eq,Matrix.mul_sub,Matrix.sub_mul,hCMC,Matrix.mul_smul,Matrix.smul_mul] at hc + have ht := trace_product_re_nonneg hc hv + rw [Matrix.sub_mul,Matrix.one_mul,Matrix.smul_mul,Matrix.trace_sub,Matrix.trace_smul,htv] at ht + simp only [Complex.sub_re,Complex.one_re,smul_eq_mul,Complex.mul_re,Complex.sub_im,Complex.one_im,Complex.ofReal_re,Complex.ofReal_im,sub_zero,zero_mul] at ht + have hn : (Fintype.card I : ℝ) > 0 := Nat.cast_pos.mpr Fintype.card_pos + have hs : (C * meanDensity r * C * v).trace.re = + (Fintype.card I : ℝ)⁻¹ * ∑ i, (C * r i * C * v).trace.re := by + simp [meanDensity,Matrix.mul_sum,Matrix.sum_mul, + Matrix.trace_sum,Matrix.trace_smul,Complex.mul_re] + rw [hs] at ht + have := mul_nonneg hn.le ht + field_simp at this + nlinarith + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixSqrtBlocks.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixSqrtBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..a909bcf127a5d092083787fe001f2e24c1245d3a --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/MatrixSqrtBlocks.lean @@ -0,0 +1,47 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I J : Type*} [Fintype I] [DecidableEq I] [DecidableEq J] + +lemma block_diagonal_commute (f : I → J) (Q : Matrix I I ℂ) + (hQ : ∀ i j, f i ≠ f j → Q i j = 0) (a : J) : + Commute Q (Matrix.diagonal (fun i => if f i = a then (1 : ℂ) else 0)) := by + ext i j + simp only [Matrix.mul_diagonal, Matrix.diagonal_mul] + by_cases h : f i = f j + · rw [h]; ring + · rw [hQ i j h]; ring + +lemma sqrt_block_diagonal (f : I → J) (Q : Matrix I I ℂ) + (hQ : ∀ i j, f i ≠ f j → Q i j = 0) : + ∀ i j, f i ≠ f j → CFC.sqrt Q i j = 0 := by + intro i j hij + have h := (block_diagonal_commute f Q hQ (f i)).cfc_nnreal NNReal.sqrt + rw [← CFC.sqrt_eq_cfc] at h + have hh := congrFun (congrFun h.eq i) j + simp only [Matrix.mul_diagonal, Matrix.diagonal_mul, ite_true, + ite_eq_right (Ne.symm hij), mul_zero, one_mul] at hh + exact hh.symm + +lemma sqrt_submatrix_invariant (Q : Matrix I I ℂ) (hQ : Q.PosSemidef) + (e : Equiv.Perm I) (he : Q.submatrix e e = Q) : + (CFC.sqrt Q).submatrix e e = CFC.sqrt Q := by + apply Eq.symm + apply CFC.sqrt_unique _ ((CFC.sqrt_nonneg Q).posSemidef.submatrix e).nonneg + rw [Matrix.submatrix_mul_equiv, CFC.sqrt_mul_sqrt_self Q hQ.nonneg, he] + +lemma sqrt_gram (Q : Matrix I I ℂ) (hQ : Q.PosSemidef) : + CFC.sqrt Q * (CFC.sqrt Q).conjTranspose = Q := by + rw [(CFC.sqrt_nonneg Q).posSemidef.1.eq, CFC.sqrt_mul_sqrt_self Q hQ.nonneg] + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/PositiveTraceRestriction.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/PositiveTraceRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6908fe8431aaf7dae2011a5ed2a1d6da596fface --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/PositiveTraceRestriction.lean @@ -0,0 +1,66 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder + +namespace BinaryCoordinateSweeps +variable {W : Type*} [NormedAddCommGroup W] [InnerProductSpace ℂ W] + [FiniteDimensional ℂ W] + +lemma positive_pow {B : W →ₗ[ℂ] W} (hB : B.IsPositive) (q : ℕ) : (B^q).IsPositive := + match q with + | 0 => LinearMap.isPositive_one + | 1 => by simpa using hB + | n+2 => by + rw [pow_succ,pow_succ'] + simpa only [Module.End.mul_eq_comp,LinearMap.comp_assoc,hB.adjoint_eq] using (positive_pow hB n).conj_adjoint B + +theorem positive_trace_restrict_le (S : Submodule ℂ W) (B : W →ₗ[ℂ] W) + (hB : B.IsPositive) (hS : ∀ x ∈ S, B x ∈ S) : + (LinearMap.trace ℂ S (B.restrict hS)).re ≤ (LinearMap.trace ℂ W B).re := by + let P := S.starProjection.toLinearMap + let Q : W →ₗ[ℂ] W := 1-P + have hPsy : P.IsSymmetric := (Submodule.isSymmetricProjection_starProjection S).isSymmetric + have hQsy : Q.IsSymmetric := LinearMap.IsSymmetric.id.sub hPsy + have hPP : P*P = P := by + ext x + exact congrArg (fun t : W →L[ℂ] W => t x) S.isIdempotentElem_starProjection + have hQQ : Q*Q = Q := by + dsimp [Q] + noncomm_ring [hPP] + have hQBQ : (Q*B*Q).IsPositive := by + simpa only [Module.End.mul_eq_comp,LinearMap.comp_assoc,hQsy.adjoint_eq] using hB.conj_adjoint Q + have hpRange : ∀ x, ((P*B)*P) x ∈ S := by + intro x + exact S.starProjection_apply_mem _ + have hpRestr : ((P*B)*P).restrict (fun x _ => hpRange x) = B.restrict hS := by + ext x + change P (B (P x.val)) = B x.val + rw [show P x.val = x.val from Submodule.starProjection_eq_self_iff.mpr x.property] + exact Submodule.starProjection_eq_self_iff.mpr (hS x.val x.property) + have hTrP : LinearMap.trace ℂ W (P*B*P) = LinearMap.trace ℂ W (B*P) := by + change LinearMap.trace ℂ W (P.comp (B*P)) = _ + rw [LinearMap.trace_comp_comm'] + change LinearMap.trace ℂ W (B*P*P) = _ + rw [mul_assoc,hPP] + have hTrQ : LinearMap.trace ℂ W (Q*B*Q) = LinearMap.trace ℂ W B - + LinearMap.trace ℂ W (B*P) := by + change LinearMap.trace ℂ W (Q.comp (B*Q)) = _ + rw [LinearMap.trace_comp_comm'] + change LinearMap.trace ℂ W (B*Q*Q) = _ + rw [mul_assoc,hQQ] + dsimp [Q] + rw [mul_sub,mul_one,map_sub] + have hTrace := LinearMap.trace_restrict_eq_of_forall_mem S (P*B*P) hpRange + rw [hpRestr,hTrP] at hTrace + have hn := (Complex.nonneg_iff.mp hQBQ.trace_nonneg).1 + rw [hTrQ,Complex.sub_re,← hTrace] at hn + linarith + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenBasic.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..dddac2396d8d3118dadd708364bdc8d671aee3e9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenBasic.lean @@ -0,0 +1,130 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.SchattenBounds + +namespace OAI + +noncomputable section +open scoped BigOperators Classical Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma alternating_prod {R : Type*} [Monoid R] (q : ℕ) (x y : R) : + (List.ofFn (fun i : Fin (2*q) => if i.val%2=0 then x else y)).prod=(x*y)^q := by + induction q with + | zero => simp + | succ q ih => + rw [show 2*(q+1)=2*q+1+1 by omega] + simp only [List.ofFn_succ,List.prod_cons,Fin.val_zero,Fin.val_succ] + norm_num only [Nat.zero_mod,Nat.reduceMod,ite_eq_left,ite_eq_right] + have he (i : Fin (2*q)) : (i.val+1+1)%2=i.val%2 := by omega + simp_rw [he] + rw [ih,pow_succ'] + exact (mul_assoc _ _ _).symm + +lemma alternating_prod_real (q : ℕ) (x y : ℝ) : + (∏i : Fin (2*q), if i.val%2=0 then x else y)=(x*y)^q := by + rw [← List.prod_ofFn] + exact alternating_prod q x y + +lemma alternating_gram (q : ℕ) (A : M ι) : + (List.ofFn (fun i : Fin (2*q) => if i.val%2=0 then star A else A)).prod= + (star A*A)^q := alternating_prod q _ _ + +lemma mul_pow_rotate {R : Type*} [Monoid R] (q : ℕ) (x y : R) : + (x*y)^(q+1)=x*(y*x)^q*y := by + induction q with + | zero => simp + | succ q ih => rw [pow_succ,ih,pow_succ]; simp only [mul_assoc] + +lemma matrixMoment_smul (q : ℕ) (r : ℝ) (A : M ι) : + matrixMoment q (r • A)=r^(2*q)*matrixMoment q A := by + unfold matrixMoment + rw [star_smul,star_trivial,smul_mul_smul_comm,smul_pow,Matrix.trace_smul] + simp only [Complex.real_smul,Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero] + rw [← pow_two,← pow_mul] + +lemma momentRoot_pow {q : ℕ} (hq : 0 < q) (A : M ι) : + (matrixMoment q A ^ (((2*q:ℕ):ℝ)⁻¹))^(2*q)=matrixMoment q A := by + rw [← Real.rpow_natCast,← Real.rpow_mul (matrixMoment_nonneg q A), + inv_mul_cancel₀ (show ((2*q:ℕ):ℝ)≠0 by positivity),Real.rpow_one] + +lemma matrixMoment_of_density_sandwich_le {q : ℕ} (hq : 0 d) (fun _ => hd) (fun _ => hs) + (fun _ => ((2*q:ℕ):ℝ)⁻¹) (fun _ => by positivity) + (by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]; + exact mul_inv_cancel₀ (by positivity)) + (fun i : Fin (2*q) => if i.val%2=0 then star V else U) + (fun i : Fin (2*q) => if i.val%2=0 then star U else V) + (by intro i; split_ifs <;> simpa only [norm_star] using (by assumption)) + (by intro i; split_ifs <;> simpa only [norm_star] using (by assumption)) + have he : (fun i : Fin (2*q) => + (if i.val%2=0 then star V else U)*D*(if i.val%2=0 then star U else V))= + fun i => if i.val%2=0 then star (U*D*V) else U*D*V := by + funext i + split_ifs <;> simp only [star_mul,hD,mul_assoc] + change ‖Matrix.trace (List.ofFn (fun i : Fin (2*q) => + (if i.val%2=0 then star V else U)*D*(if i.val%2=0 then star U else V))).prod‖≤1 at hb + rw [he,alternating_gram] at hb + exact (Complex.re_le_norm _).trans hb + +lemma matrixMoment_contract_left {q : ℕ} (hq : 0 rw [he] + rw [mul_smul_comm] + congr 1 + simp only [mul_assoc] + rw [hec,matrixMoment_smul,momentRoot_pow hq A] + exact mul_le_of_le_one_right ht.le (matrixMoment_of_density_sandwich_le hq d hd hs + (C*U) V ((norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) hC).trans hU)) hV) + +lemma matrixMoment_contract_right {q : ℕ} (hq : 0 rw [he,smul_mul_assoc,matrixMoment_smul] + exact mul_le_mul_of_nonneg_left (matrixMoment_contract_left hq _ A hf) (pow_nonneg hn.le _) + +lemma matrixMoment_unitary_conj (q : ℕ) (U : Matrix.unitaryGroup ι ℂ) (A : M ι) : + matrixMoment q ((U:M ι)*A*star (U:M ι))=matrixMoment q A := by + unfold matrixMoment + have he : star ((U:M ι)*A*star (U:M ι))*((U:M ι)*A*star (U:M ι))= + (U:M ι)*(star A*A)*star (U:M ι) := by + simp only [star_mul,star_star,mul_assoc,← mul_assoc (star (U:M ι)) (U:M ι), + Unitary.coe_star_mul_self,one_mul] + rw [he,unitary_conj_pow,trace_unitary_conj] + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenBounds.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..578e2d6178a824f82c62194ccdafb89875451638 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenBounds.lean @@ -0,0 +1,266 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.TraceHolder + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma trace_mul_pow_comm (A B : M ι) (q : ℕ) : + Matrix.trace ((A * B)^q) = Matrix.trace ((B * A)^q) := by + cases q with + | zero => rfl + | succ q => + rw [pow_succ, ← mul_assoc, mul_pow_mul, Matrix.trace_mul_comm, + ← mul_assoc, ← pow_succ'] + +lemma matrixMoment_star (q : ℕ) (A : M ι) : + matrixMoment q (star A) = matrixMoment q A := by + simp only [matrixMoment, star_star] + rw [trace_mul_pow_comm] + +def schatten (q : ℕ) (A : M ι) : ℝ := + matrixMoment q A ^ (((2*q : ℕ) : ℝ)⁻¹) + +lemma schatten_nonneg (q : ℕ) (A : M ι) : 0 ≤ schatten q A := + Real.rpow_nonneg (matrixMoment_nonneg _ _) _ + +lemma schatten_star (q : ℕ) (A : M ι) : schatten q (star A) = schatten q A := by + simp only [schatten, matrixMoment_star] + +lemma schatten_pow {q : ℕ} (hq : 0 < q) (A : M ι) : + schatten q A ^ (2*q) = matrixMoment q A := by + exact Real.rpow_inv_natCast_pow (matrixMoment_nonneg _ _) (by omega : 2*q ≠ 0) + +lemma schatten_zero {q : ℕ} (hq : 0 < q) : schatten q (0 : M ι) = 0 := by + rw [schatten, (matrixMoment_eq_zero_iff hq _).mpr rfl] + exact Real.zero_rpow (inv_ne_zero (by exact_mod_cast (show 2*q ≠ 0 by omega))) + +lemma prod_ofFn_sum {R κ : Type*} [Semiring R] [Fintype κ] {m : ℕ} + (A : Fin m → κ → R) : + (List.ofFn (fun j => ∑ k, A j k)).prod = + ∑ f : Fin m → κ, (List.ofFn (fun j => A j (f j))).prod := by + induction m with + | zero => simp + | succ m ih => + rw [List.ofFn_succ, List.prod_cons, ih] + rw [← (Fin.consEquiv (fun _ : Fin (m+1) => κ)).sum_comp, Fintype.sum_prod_type] + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro k _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro f _ + simp only [Fin.consEquiv, Equiv.coe_fn_mk, List.ofFn_succ, List.prod_cons, + Fin.cons_zero, Fin.cons_succ] + +lemma trace_holder_sums {κ : Type*} [Fintype κ] {q : ℕ} (hq : 0 < q) + (A : Fin (2*q) → κ → M ι) : + ‖Matrix.trace (List.ofFn (fun j => ∑ k, A j k)).prod‖ ≤ + ∏ j, ∑ k, schatten q (A j k) := by + rw [prod_ofFn_sum, Matrix.trace_sum] + calc + _ ≤ ∑ f : Fin (2*q) → κ, ‖Matrix.trace (List.ofFn (fun j => A j (f j))).prod‖ := + norm_sum_le _ _ + _ ≤ ∑ f : Fin (2*q) → κ, ∏ j, schatten q (A j (f j)) := by + exact Finset.sum_le_sum (fun f _ => matrix_trace_holder hq _) + _ = ∏ j, ∑ k, schatten q (A j k) := by + exact (Fintype.prod_sum (fun j k => schatten q (A j k))).symm + +lemma prod_alternating {R : Type*} [Monoid R] (q : ℕ) (A B : R) : + (List.ofFn (fun j : Fin (2*q) => if j.val % 2 = 0 then A else B)).prod = + (A * B)^q := by + induction q with + | zero => simp + | succ q ih => + rw [Nat.mul_succ] + have hf : (fun j : Fin (2*q+2) => if j.val % 2 = 0 then A else B) = + Fin.append (fun j : Fin (2*q) => if j.val % 2 = 0 then A else B) + (fun j : Fin 2 => if j.val % 2 = 0 then A else B) := by + funext j + refine Fin.addCases (fun i => ?_) (fun i => ?_) j + · simp + · simp [Nat.add_mod] + rw [hf, List.ofFn_fin_append, List.prod_append, ih, pow_succ] + simp [List.ofFn_succ] + +lemma matrixMoment_le_sum_pow {κ : Type*} [Fintype κ] {q : ℕ} (hq : 0 < q) + (A : κ → M ι) : + matrixMoment q (∑ k, A k) ≤ (∑ k, schatten q (A k))^(2*q) := by + let W : Fin (2*q) → κ → M ι := + fun j k => if j.val % 2 = 0 then star (A k) else A k + have hW : (List.ofFn (fun j => ∑ k, W j k)).prod = + (star (∑ k, A k) * (∑ k, A k))^q := by + have heq : (fun j => ∑ k, W j k) = + (fun j : Fin (2*q) => if j.val % 2 = 0 then star (∑ k, A k) else ∑ k, A k) := by + funext j + dsimp [W] + split_ifs <;> simp [star_sum] + rw [heq, prod_alternating] + have hS : ∀ j : Fin (2*q), (∑ k, schatten q (W j k)) = ∑ k, schatten q (A k) := by + intro j + apply Finset.sum_congr rfl + intro k _ + dsimp [W] + split_ifs <;> simp only [schatten_star] + have hh := trace_holder_sums hq W + rw [hW] at hh + simp only [hS, Finset.prod_const, Finset.card_univ, Fintype.card_fin] at hh + exact (Complex.re_le_norm _).trans hh + +theorem schatten_sum_le {κ : Type*} [Fintype κ] {q : ℕ} (hq : 0 < q) + (A : κ → M ι) : schatten q (∑ k, A k) ≤ ∑ k, schatten q (A k) := by + have hn : 0 ≤ ∑ k, schatten q (A k) := Finset.sum_nonneg fun k _ => schatten_nonneg _ _ + have hh := Real.rpow_le_rpow (matrixMoment_nonneg q (∑ k, A k)) + (matrixMoment_le_sum_pow hq A) (show 0 ≤ (((2*q : ℕ) : ℝ)⁻¹) by positivity) + rw [Real.pow_rpow_inv_natCast hn (by omega : 2*q ≠ 0)] at hh + exact hh + +lemma matrix_one_norm_le : ‖(1 : M ι)‖ ≤ 1 := by + rw [← Matrix.diagonal_one, Matrix.l2_opNorm_diagonal] + exact (pi_norm_le_iff_of_nonneg zero_le_one).mpr (by simp) + +theorem trace_holder_contractions {q : ℕ} (hq : 0 < q) + (A U V : Fin (2*q) → M ι) (hU : ∀ j, ‖U j‖ ≤ 1) (hV : ∀ j, ‖V j‖ ≤ 1) : + ‖Matrix.trace (List.ofFn (fun j => U j * A j * V j)).prod‖ ≤ + ∏ j, schatten q (A j) := by + have hm : 0 < 2*q := by omega + have hm' : 0 < ((2*q : ℕ) : ℝ) := by exact_mod_cast hm + by_cases hz : ∃ j, matrixMoment q (A j) = 0 + · obtain ⟨j, hj⟩ := hz + have hAj : A j = 0 := (matrixMoment_eq_zero_iff hq _).mp hj + have hp : (List.ofFn (fun j => U j * A j * V j)).prod = 0 := by + apply List.prod_eq_zero + exact List.mem_ofFn.mpr ⟨j, by simp [hAj]⟩ + rw [hp, Matrix.trace_zero, norm_zero] + exact Finset.prod_nonneg fun k _ => schatten_nonneg _ _ + · have ht : ∀ j, 0 < matrixMoment q (A j) := by + intro j + exact lt_of_le_of_ne (matrixMoment_nonneg _ _) (Ne.symm (fun h => hz ⟨j,h⟩)) + choose S T d hS hT hd hs heq using fun j => normalized_svd hq (A j) (ht j) + let C : Fin (2*q) → M ι := fun j => + (U j * S j) * diagPower (d j) (((((2*q : ℕ) : ℝ)⁻¹ : ℝ) : ℂ)) * (T j * V j) + have hc : ‖Matrix.trace (List.ofFn C).prod‖ ≤ 1 := by + refine trace_diagonal_sandwich_pos hm d hd hs (fun _ => ((2*q : ℕ) : ℝ)⁻¹) + (fun _ => (inv_pos.mpr hm').le) ?_ (fun j => U j*S j) (fun j => T j*V j) ?_ ?_ + · simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + exact mul_inv_cancel₀ hm'.ne' + · intro j + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) (hU j)).trans (hS j)) + · intro j + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) (hT j)).trans (hV j)) + have hEq : (fun j => U j * A j * V j) = (fun j => schatten q (A j) • C j) := by + funext j + conv_lhs => rw [heq j] + simp only [mul_smul_comm, smul_mul_assoc, mul_assoc, C, schatten] + rw [hEq, prod_ofFn_smul, Matrix.trace_smul, norm_smul, Real.norm_eq_abs, + abs_of_nonneg (Finset.prod_nonneg fun j _ => schatten_nonneg _ _)] + exact mul_le_of_le_one_right (Finset.prod_nonneg fun j _ => schatten_nonneg _ _) hc + +lemma matrixMoment_contraction_left {q : ℕ} (hq : 0 < q) (C A : M ι) (hC : ‖C‖ ≤ 1) : + matrixMoment q (C*A) ≤ matrixMoment q A := by + let W : Fin (2*q) → M ι := fun j => if j.val % 2 = 0 then star A else A + let U : Fin (2*q) → M ι := fun j => if j.val % 2 = 0 then 1 else C + let V : Fin (2*q) → M ι := fun j => if j.val % 2 = 0 then star C else 1 + have hU : ∀ j, ‖U j‖ ≤ 1 := by + intro j; dsimp [U]; split_ifs + · exact matrix_one_norm_le + · exact hC + have hV : ∀ j, ‖V j‖ ≤ 1 := by + intro j; dsimp [V]; split_ifs + · simpa only [norm_star] using hC + · exact matrix_one_norm_le + have heq : (fun j => U j * W j * V j) = + (fun j : Fin (2*q) => if j.val % 2 = 0 then star (C*A) else C*A) := by + funext j + dsimp [U,W,V] + split_ifs <;> simp only [one_mul, mul_one, star_mul] + have hs : ∀ j, schatten q (W j) = schatten q A := by + intro j; dsimp [W]; split_ifs <;> simp only [schatten_star] + have hh := trace_holder_contractions hq W U V hU hV + rw [heq, prod_alternating] at hh + simp only [hs, Finset.prod_const, Finset.card_univ, Fintype.card_fin, schatten_pow hq] at hh + exact (Complex.re_le_norm _).trans hh + +lemma schatten_contraction_left {q : ℕ} (hq : 0 < q) (C A : M ι) (hC : ‖C‖ ≤ 1) : + schatten q (C*A) ≤ schatten q A := + Real.rpow_le_rpow (matrixMoment_nonneg _ _) (matrixMoment_contraction_left hq C A hC) + (by positivity) + +lemma matrixMoment_smul_real (q : ℕ) (r : ℝ) (A : M ι) : + matrixMoment q (r • A) = r^(2*q) * matrixMoment q A := by + simp only [matrixMoment, star_smul, star_trivial, smul_mul_smul_comm, smul_pow, + Matrix.trace_smul, Complex.real_smul, Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, zero_mul, sub_zero] + rw [← sq, ← pow_mul] + +lemma schatten_smul_nonneg {q : ℕ} (hq : 0 < q) {r : ℝ} (hr : 0 ≤ r) (A : M ι) : + schatten q (r • A) = r * schatten q A := by + unfold schatten + rw [matrixMoment_smul_real, Real.mul_rpow (pow_nonneg hr _) (matrixMoment_nonneg _ _), + Real.pow_rpow_inv_natCast hr (by omega : 2*q ≠ 0)] + +theorem schatten_mul_le_op_left {q : ℕ} (hq : 0 < q) (A B : M ι) : + schatten q (A*B) ≤ ‖A‖ * schatten q B := by + by_cases hA : A = 0 + · simp [hA, schatten_zero hq] + · have hn : 0 < ‖A‖ := norm_pos_iff.mpr hA + let C : M ι := ‖A‖⁻¹ • A + have hC : ‖C‖ ≤ 1 := by + dsimp [C] + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr hn.le), + inv_mul_cancel₀ hn.ne'] + have heq : A*B = ‖A‖ • (C*B) := by + dsimp only [C] + rw [smul_mul_assoc, smul_smul, mul_inv_cancel₀ hn.ne', one_smul] + rw [heq, schatten_smul_nonneg hq hn.le] + exact mul_le_mul_of_nonneg_left (schatten_contraction_left hq C B hC) hn.le + +theorem schatten_mul_le_op_right {q : ℕ} (hq : 0 < q) (A B : M ι) : + schatten q (A*B) ≤ schatten q A * ‖B‖ := by + have h := schatten_mul_le_op_left hq (star B) (star A) + simpa only [← star_mul, schatten_star, norm_star, mul_comm] using h + +lemma op_norm_le_schatten {q : ℕ} (hq : 0 < q) (A : M ι) : ‖A‖ ≤ schatten q A := by + obtain ⟨U,V,s,hs,hU,hA,hg⟩ := exists_partial_svd A + have ht := matrixMoment_of_svd A q V s hg + have hd : ‖diagReal s‖ ≤ schatten q A := by + rw [diagReal, Matrix.l2_opNorm_diagonal] + apply (pi_norm_le_iff_of_nonneg (schatten_nonneg _ _)).mpr + intro i + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hs i)] + have hi : s i^(2*q) ≤ matrixMoment q A := by + rw [ht] + exact Finset.single_le_sum (fun j _ => pow_nonneg (hs j) _) (Finset.mem_univ i) + have h := Real.rpow_le_rpow (pow_nonneg (hs i) _) hi + (show 0 ≤ (((2*q : ℕ) : ℝ)⁻¹) by positivity) + rw [Real.pow_rpow_inv_natCast (hs i) (by omega : 2*q ≠ 0)] at h + exact h + calc + ‖A‖ = ‖U * diagReal s * star (V : M ι)‖ := congrArg norm hA + _ ≤ (‖U‖ * ‖diagReal s‖) * ‖star (V : M ι)‖ := + (norm_mul_le _ _).trans (mul_le_mul_of_nonneg_right (norm_mul_le _ _) (norm_nonneg _)) + _ ≤ (1 * schatten q A) * 1 := by + apply mul_le_mul + · exact mul_le_mul hU hd (norm_nonneg _) zero_le_one + · simpa only [norm_star] using unitary_norm_le_one V + · exact norm_nonneg _ + · exact mul_nonneg zero_le_one (schatten_nonneg _ _) + _ = _ := by ring + +theorem schatten_triple_le {q : ℕ} (hq : 0 < q) (A B C : M ι) : + schatten q (A*B*C) ≤ schatten q A * ‖B‖ * schatten q C := by + calc + _ ≤ schatten q (A*B) * ‖C‖ := schatten_mul_le_op_right hq _ _ + _ ≤ (schatten q A * ‖B‖) * schatten q C := + mul_le_mul (schatten_mul_le_op_right hq A B) (op_norm_le_schatten hq C) + (norm_nonneg _) (mul_nonneg (schatten_nonneg _ _) (norm_nonneg _)) + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenTriangle.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenTriangle.lean new file mode 100644 index 0000000000000000000000000000000000000000..cae62d440bd980277f62b3fa5a040b259105f779 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/SchattenTriangle.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.SchattenBasic + +namespace OAI + +noncomputable section +open scoped BigOperators Classical Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma matrixMoment_sum_le {α : Type*} [Fintype α] {q : ℕ} (hq : 0 if j.val%2=0 then star (A a) else A a + have he : (fun j : Fin (2*q) => if j.val%2=0 then star (∑a, A a) else ∑a, A a)= + fun j => ∑a, B j a := by + funext j + dsimp [B] + split_ifs <;> simp only [star_sum] + calc + _ ≤ ‖Matrix.trace ((star (∑a, A a)*(∑a, A a))^q)‖ := Complex.re_le_norm _ + _ = ‖∑x : Fin (2*q) → α, Matrix.trace (List.ofFn (fun j => B j (x j))).prod‖ := by + rw [← alternating_gram,he,prod_ofFn_sum,Matrix.trace_sum] + _ ≤ ∑x : Fin (2*q) → α, ‖Matrix.trace (List.ofFn (fun j => B j (x j))).prod‖ := norm_sum_le _ _ + _ ≤ ∑x : Fin (2*q) → α, ∏j, schatten q (A (x j)) := by + apply Finset.sum_le_sum + intro x _ + convert matrix_trace_holder hq (fun j => B j (x j)) using 1 + apply Finset.prod_congr rfl + intro coordinate _ + dsimp [B,schatten] + split_ifs <;> simp only [matrixMoment_star] + _ = (∑a, schatten q (A a))^(2*q) := by + rw [← Fintype.prod_sum (fun (_ : Fin (2*q)) a => schatten q (A a))] + simp + +lemma schatten_mul_left {q : ℕ} (hq : 0 hd j) (Finset.mem_univ i) + have hD : ‖diagPower d ((((2*q:ℕ):ℝ)⁻¹:ℝ):ℂ)‖≤ 1 := + diagPower_norm_le_one d hd hd1 (by simp) + conv_lhs => rw [he,norm_smul,Real.norm_eq_abs] + change |schatten q A| * _ ≤ schatten q A + rw [abs_of_nonneg (schatten_nonneg q A)] + apply mul_le_of_le_one_right (schatten_nonneg _ _) + refine (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) ?_).trans hV) + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) hU).trans hD) + +lemma schatten_sandwich {q : ℕ} (hq : 0 if f i = a then x i else 0 + +def pinch (f : I → J) (A : Matrix I I ℂ) : Matrix I I ℂ := + fun i j => if f i = f j then A i j else 0 + +omit [Fintype I] in +lemma sum_blockVec (f : I → J) (x : I → ℂ) : ∑ a, blockVec f a x = x := by + ext i + simp [blockVec] + +omit [Fintype I] [Fintype J] in +lemma pinch_hermitian (f : I → J) {A : Matrix I I ℂ} (hA : A.IsHermitian) : + (pinch f A).IsHermitian := by + ext i j + change star (if f j = f i then A j i else 0) = if f i = f j then A i j else 0 + by_cases h : f i = f j + · rw [ite_eq_left h, ite_eq_left h.symm] + exact congrFun (congrFun hA i) j + · rw [ite_eq_right h, ite_eq_right (Ne.symm h), star_zero] + +lemma pinch_form (f : I → J) (A : Matrix I I ℂ) (x : I → ℂ) : + star x ⬝ᵥ (pinch f A).mulVec x = + ∑ a, star (blockVec f a x) ⬝ᵥ A.mulVec (blockVec f a x) := by + simp only [dotProduct, mulVec, blockVec, pinch, Pi.star_apply, apply_ite, star_zero, + Finset.mul_sum] + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + simp only [ite_mul, zero_mul, mul_ite, mul_zero] + by_cases h : f i = f j + · rw [h] + simp + · simp [h] + +lemma pinch_posSemidef (f : I → J) {A : Matrix I I ℂ} (hA : A.PosSemidef) : + (pinch f A).PosSemidef := by + refine .of_dotProduct_mulVec_nonneg (pinch_hermitian f hA.1) (fun x => ?_) + rw [pinch_form] + exact Finset.sum_nonneg (fun a _ => hA.dotProduct_mulVec_nonneg _) + +lemma form_cross_le {A : Matrix I I ℂ} (hA : A.PosSemidef) (x y : I → ℂ) : + star x ⬝ᵥ A.mulVec y + star y ⬝ᵥ A.mulVec x ≤ + star x ⬝ᵥ A.mulVec x + star y ⬝ᵥ A.mulVec y := by + have h := hA.dotProduct_mulVec_nonneg (x-y) + rw [star_sub, mulVec_sub, sub_dotProduct, dotProduct_sub, dotProduct_sub] at h + exact sub_nonneg.mp (by convert h using 1; abel) + +omit [Fintype J] in +lemma block_form_zero (f : I → J) (A : Matrix I I ℂ) (a b : J) + (h : ∀ i j, f i = a → f j = b → A i j = 0) (x : I → ℂ) : + star (blockVec f a x) ⬝ᵥ A.mulVec (blockVec f b x) = 0 := by + simp only [dotProduct, mulVec, blockVec, Pi.star_apply, apply_ite, star_zero, + Finset.mul_sum] + apply Finset.sum_eq_zero + intro i hi + apply Finset.sum_eq_zero + intro j hj + by_cases ha : f i = a + · by_cases hb : f j = b + · simp [ha, hb, h i j ha hb] + · simp [hb] + · simp [ha] + +theorem sparse_pinching (f : I → J) (R : J → J → Prop) [DecidableRel R] + (hR : ∀ ⦃left right⦄, R left right → R right left) + (D : ℕ) (hD : ∀ a, (Finset.univ.filter (R a)).card ≤ D) + {A : Matrix I I ℂ} (hA : A.PosSemidef) + (hz : ∀ i j, ¬ R (f i) (f j) → A i j = 0) : + ((D : ℂ) • pinch f A - A).PosSemidef := by + have hp := pinch_hermitian f hA.1 + refine .of_dotProduct_mulVec_nonneg ((hp.smul (by simp)).sub hA.1) (fun x => ?_) + let t : J → J → ℂ := fun a b => star (blockVec f a x) ⬝ᵥ A.mulVec (blockVec f b x) + have hdiag (a : J) : 0 ≤ t a a := hA.dotProduct_mulVec_nonneg _ + have ht (a b : J) (hab : ¬R a b) : t a b = 0 := by + apply block_form_zero + intro i j hi hj + exact hz i j (by simpa [hi, hj] using hab) + have hsum : ∑ a, ∑ b ∈ Finset.univ.filter (R a), t a b = star x ⬝ᵥ A.mulVec x := by + simp_rw [Finset.sum_filter] + have ht' : ∀ a b, (if R a b then t a b else 0) = t a b := by + intro a b + split_ifs with h + · rfl + · exact (ht a b h).symm + simp_rw [ht'] + dsimp [t] + simp_rw [← dotProduct_sum, ← mulVec_sum, sum_blockVec] + rw [← sum_dotProduct, ← star_sum, sum_blockVec] + have hswap : ∑ a, ∑ b ∈ Finset.univ.filter (R a), t b a = + ∑ a, ∑ b ∈ Finset.univ.filter (R a), t a b := by + simp only [Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + have he : R b a ↔ R a b := ⟨fun h => hR h, fun h => hR h⟩ + simp only [he] + have hdeg : ∑ a, ∑ b ∈ Finset.univ.filter (R a), (t a a + t b b) = + 2 * ∑ a, ((Finset.univ.filter (R a)).card : ℂ) * t a a := by + simp only [Finset.sum_add_distrib] + have hs : ∑ a, ∑ b ∈ Finset.univ.filter (R a), t b b = + ∑ a, ∑ b ∈ Finset.univ.filter (R a), t a a := by + simp only [Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + simp only [show R b a ↔ R a b from ⟨fun h => hR h, fun h => hR h⟩] + rw [hs] + simp [two_mul] + have hle := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset J)) => + Finset.sum_le_sum (fun b (_ : b ∈ Finset.univ.filter (R a)) => + form_cross_le hA (blockVec f a x) (blockVec f b x))) + change (∑ a, ∑ b ∈ Finset.univ.filter (R a), (t a b + t b a)) ≤ _ at hle + simp only [Finset.sum_add_distrib] at hle + rw [hswap, hsum] at hle + have hc : star x ⬝ᵥ A.mulVec x ≤ ∑ a, ((Finset.univ.filter (R a)).card : ℂ) * t a a := by + have hh := hdeg + simp only [Finset.sum_add_distrib] at hh + rw [hh] at hle + simp only [two_mul, Complex.le_def, Complex.add_re, Complex.add_im] at hle + exact Complex.le_def.mpr ⟨by linarith [hle.1], by linarith [hle.2]⟩ + have hd : ∑ a, ((Finset.univ.filter (R a)).card : ℂ) * t a a ≤ + (D : ℂ) * ∑ a, t a a := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro a ha + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hD a) (hdiag a) + have hf := hc.trans hd + rw [sub_mulVec, dotProduct_sub, smul_mulVec, dotProduct_smul, smul_eq_mul] + apply sub_nonneg.mpr + simpa only [pinch_form, t] using hf + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [LinearOrder I] + +def subsetCode (k : ℕ) (s : Finset I) : Fin k → Option I := + fun i => if h : i.val < s.card then some (s.orderEmbOfFin rfl ⟨i.val,h⟩) else none + +omit [Fintype I] in +lemma subsetCode_range (k : ℕ) (s : Finset I) (hs : s.card ≤ k) (j : I) : + some j ∈ Set.range (subsetCode k s) ↔ j ∈ s := by + constructor + · rintro ⟨i,hi⟩ + dsimp only [subsetCode] at hi + split_ifs at hi with h + · have hj := Option.some.inj hi + rw [← hj] + exact Finset.orderEmbOfFin_mem s rfl _ + · intro hj + have hr : j ∈ Set.range (s.orderEmbOfFin rfl) := by + rw [Finset.range_orderEmbOfFin]; exact hj + obtain ⟨i,hi⟩ := hr + refine ⟨⟨i.val, i.isLt.trans_le hs⟩, ?_⟩ + simp only [subsetCode, dite_eq_left i.isLt] + exact congrArg some hi + +lemma card_small_subsets_le (k : ℕ) : + Fintype.card {s : Finset I // s.card ≤ k} ≤ (Fintype.card I + 1)^k := by + let f : {s : Finset I // s.card ≤ k} → (Fin k → Option I) := fun s => subsetCode k s.val + have hf : Function.Injective f := by + intro s t h + apply Subtype.ext + ext j + rw [← subsetCode_range k s.val s.property j, ← subsetCode_range k t.val t.property j] + rw [show Set.range (subsetCode k s.val) = Set.range (subsetCode k t.val) from + congrArg Set.range h] + have hc := Fintype.card_le_of_injective f hf + simpa only [Fintype.card_fun, Fintype.card_fin, Fintype.card_option] using hc + +def hamming (a b : I → Bool) : ℕ := (Finset.univ.filter (fun i => a i ≠ b i)).card + +omit [LinearOrder I] in +lemma hamming_symm (a b : I → Bool) : hamming a b = hamming b a := by + unfold hamming + congr 1 + ext i + simp only [Finset.mem_filter, Finset.mem_univ, true_and, ne_comm] + +lemma hamming_degree (a : I → Bool) (k : ℕ) : + (Finset.univ.filter (fun b => hamming a b ≤ k)).card ≤ (Fintype.card I + 1)^k := by + let f : {b : I → Bool // hamming a b ≤ k} → {s : Finset I // s.card ≤ k} := + fun b => ⟨Finset.univ.filter (fun i => a i ≠ b.val i), b.property⟩ + have hf : Function.Injective f := by + intro b c h + apply Subtype.ext + funext i + have hi := Finset.ext_iff.mp (congrArg Subtype.val h) i + simp only [f, Finset.mem_filter, Finset.mem_univ, true_and] at hi + cases ha : a i <;> cases hb : b.val i <;> cases hc : c.val i <;> + simp_all only [Bool.false_eq_true, Bool.true_eq_false, not_false_eq_true, ne_eq, + not_true_eq_false, iff_false, iff_true] + have hh := (Fintype.card_le_of_injective f hf).trans (card_small_subsets_le (I := I) k) + simpa only [Fintype.card_subtype] using hh + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/SpectralMoment.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/SpectralMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..427bf41436a390ba985bf36c1d630ccb144ff600 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/SpectralMoment.lean @@ -0,0 +1,106 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.TraceInterpolation + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def matrixMoment (q : ℕ) (A : M ι) : ℝ := (Matrix.trace ((star A * A)^q)).re + +lemma diagReal_pow (s : ι → ℝ) (q : ℕ) : + (diagReal s)^q = diagReal (fun i => s i ^ q) := by + simp [diagReal, Matrix.diagonal_pow] + +lemma trace_unitary_conj (V : Matrix.unitaryGroup ι ℂ) (B : M ι) : + Matrix.trace ((V : M ι) * B * star (V : M ι)) = Matrix.trace B := by + rw [Matrix.trace_mul_cycle, Unitary.coe_star_mul_self, one_mul] + +lemma unitary_conj_pow (V : Matrix.unitaryGroup ι ℂ) (B : M ι) (q : ℕ) : + ((V : M ι) * B * star (V : M ι))^q = (V : M ι) * B^q * star (V : M ι) := by + have h := ((Unitary.conjStarAlgAut ℂ (M ι) V).toAlgEquiv.map_pow B q).symm + change (Unitary.conjStarAlgAut ℂ (M ι) V B)^q = + Unitary.conjStarAlgAut ℂ (M ι) V (B^q) at h + simpa only [Unitary.conjStarAlgAut_apply, Unitary.coe_star] using h + +lemma matrixMoment_of_svd (A : M ι) (q : ℕ) (V : Matrix.unitaryGroup ι ℂ) + (s : ι → ℝ) (hgram : star A * A = (V : M ι) * diagReal (fun i => s i^2) * star (V : M ι)) : + matrixMoment q A = ∑ i, s i ^ (2*q) := by + rw [matrixMoment, hgram, unitary_conj_pow, trace_unitary_conj, diagReal_pow] + simp only [diagReal, Matrix.trace_diagonal, + Complex.re_sum, Complex.ofReal_re, ← pow_mul] + +lemma matrixMoment_nonneg (q : ℕ) (A : M ι) : 0 ≤ matrixMoment q A := by + obtain ⟨U, V, s, hs, hU, hA, hg⟩ := exists_partial_svd A + rw [matrixMoment_of_svd A q V s hg] + exact Finset.sum_nonneg (fun i _ => pow_nonneg (hs i) _) + +lemma matrixMoment_eq_zero_iff {q : ℕ} (hq : 0 < q) (A : M ι) : + matrixMoment q A = 0 ↔ A = 0 := by + constructor + · intro h + obtain ⟨U, V, s, hs, hU, hA, hg⟩ := exists_partial_svd A + rw [matrixMoment_of_svd A q V s hg] at h + have hi : ∀ i, s i = 0 := by + intro i + have hz := (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => pow_nonneg (hs j) (2*q))).mp h + exact (pow_eq_zero_iff (by omega : 2*q ≠ 0)).mp (hz i (Finset.mem_univ _)) + rw [hA] + simp [diagReal, hi] + · intro h + simp [matrixMoment, h, zero_pow (by omega : q ≠ 0)] + +lemma unitary_norm_le_one (V : Matrix.unitaryGroup ι ℂ) : ‖(V : M ι)‖ ≤ 1 := by + have h1 : ‖(1 : M ι)‖ ≤ 1 := by + rw [← Matrix.diagonal_one, Matrix.l2_opNorm_diagonal] + exact (pi_norm_le_iff_of_nonneg zero_le_one).mpr (by simp) + have h : ‖(V : M ι)‖ * ‖(V : M ι)‖ ≤ 1 := by + rw [← CStarRing.norm_star_mul_self, Unitary.coe_star_mul_self] + exact h1 + nlinarith [norm_nonneg (V : M ι)] + +omit [Fintype ι] in +lemma diagPower_real (d : ι → ℝ) (hd : ∀ i, 0 ≤ d i) {x : ℝ} (hx : 0 < x) : + diagPower d (x : ℂ) = diagReal (fun i => (d i) ^ x) := by + unfold diagPower diagReal + congr 1 + funext i + by_cases hi : d i = 0 + · simp [hi, Real.zero_rpow hx.ne'] + · rw [ite_eq_right hi] + change Complex.exp ((x : ℂ) * (Real.log (d i) : ℂ)) = ((d i ^ x : ℝ) : ℂ) + rw [Real.rpow_def_of_pos (lt_of_le_of_ne (hd i) (Ne.symm hi))] + rw [← Complex.ofReal_mul, ← Complex.ofReal_exp] + congr 2 + ring + +lemma density_normalization {m : ℕ} (hm : 0 < m) (s : ι → ℝ) (hs : ∀ i, 0 ≤ s i) + {t : ℝ} (ht : 0 < t) (hts : ∑ i, s i^m = t) : + let d : ι → ℝ := fun i => s i ^ m / t + (∀ i, 0 ≤ d i) ∧ (∑ i, d i = 1) ∧ + diagReal s = (t ^ ((m : ℝ)⁻¹) : ℝ) • diagPower d (((m : ℝ)⁻¹ : ℝ) : ℂ) := by + dsimp only + have hm' : 0 < (m : ℝ) := by exact_mod_cast hm + have hd : ∀ i, 0 ≤ s i^m/t := fun i => div_nonneg (pow_nonneg (hs i) _) ht.le + refine ⟨hd, ?_, ?_⟩ + · rw [← Finset.sum_div, hts, div_self ht.ne'] + · rw [diagPower_real _ hd (inv_pos.mpr hm')] + unfold diagReal + rw [← Matrix.diagonal_smul] + congr 1 + funext i + change (s i : ℂ) = ((t ^ (m : ℝ)⁻¹ : ℝ) : ℂ) * + (((s i ^ m / t) ^ (m : ℝ)⁻¹ : ℝ) : ℂ) + rw [Real.div_rpow (pow_nonneg (hs i) _) ht.le, + Real.pow_rpow_inv_natCast (hs i) (Nat.ne_of_gt hm)] + norm_cast + exact (mul_div_cancel₀ (s i) (Real.rpow_pos_of_pos ht _).ne').symm + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/SymmetricDensity.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/SymmetricDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3f4171aab65e06124cb48f35d32db6057b5c357 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/SymmetricDensity.lean @@ -0,0 +1,119 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.EmpiricalTensor + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [DecidableEq I] + +lemma psd_trace_domination {B : Matrix I I ℂ} (hB : B.PosSemidef) : + (B.trace • (1 : Matrix I I ℂ) - B).PosSemidef := by + let U : unitaryGroup I ℂ := hB.1.eigenvectorUnitary + let e : I → ℝ := hB.1.eigenvalues + have he (i) : 0 ≤ e i := hB.eigenvalues_nonneg i + have htr : B.trace = ∑ j, (e j : ℂ) := hB.1.trace_eq_sum_eigenvalues + have hs : B = (U : Matrix I I ℂ) * Matrix.diagonal (fun i => (e i : ℂ)) * + star (U : Matrix I I ℂ) := hB.1.spectral_theorem + let d : I → ℂ := fun i => B.trace - (e i : ℂ) + have hd : ∀ i, 0 ≤ d i := by + intro i + have hh := Finset.single_le_sum (fun j _ => he j) (Finset.mem_univ i) + have hc : (e i : ℂ) ≤ ∑ j, (e j : ℂ) := by exact_mod_cast hh + dsimp only [d] + rw [htr] + exact sub_nonneg.mpr hc + have hp := (Matrix.PosSemidef.diagonal hd).mul_mul_conjTranspose_same (U : Matrix I I ℂ) + have hdiag : Matrix.diagonal d = B.trace • (1 : Matrix I I ℂ) - + Matrix.diagonal (fun i => (e i : ℂ)) := by + ext i j + by_cases hij : i = j <;> simp [hij, d] + have hmain : (U : Matrix I I ℂ) * Matrix.diagonal d * star (U : Matrix I I ℂ) = + B.trace • 1 - B := by + rw [hdiag, Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_smul, Matrix.smul_mul, + Matrix.mul_one, ← Unitary.coe_star, Unitary.coe_mul_star_self, Unitary.coe_star, ← hs] + exact hmain ▸ hp + +omit [DecidableEq I] in +lemma rankOne_conjugate {J : Type*} [Fintype J] [DecidableEq J] (P : Matrix J I ℂ) (v : I → ℂ) : + P * rankOne v * P.conjTranspose = rankOne (P.mulVec v) := by + simp only [rankOne, Matrix.mul_vecMulVec, Matrix.vecMulVec_mul, Matrix.vecMul_conjTranspose, + star_star] + +lemma rankOne_projection_bound (P : Matrix I I ℂ) (hP : P.IsHermitian) + (hPP : P * P = P) (v : I → ℂ) (hv : P.mulVec v = v) : + ((rankOne v).trace • P - rankOne v).PosSemidef := by + have hh := (psd_trace_domination (rankOne_psd v)).mul_mul_conjTranspose_same P + have he : P * ((rankOne v).trace • (1 : Matrix I I ℂ) - rankOne v) * P.conjTranspose = + (rankOne v).trace • P - rankOne v := by + rw [Matrix.mul_sub, Matrix.sub_mul, rankOne_conjugate, hv, + Matrix.mul_smul, Matrix.smul_mul, Matrix.mul_one, hP.eq, hPP] + exact he ▸ hh + +variable {A : Type*} [Fintype A] [DecidableEq A] + +lemma symmetricProjector_identity (n : ℕ) (x : (Fin n → A) → ℂ) + (hx : ∀ w v, wordCounts w = wordCounts v → x w = x v) : + (symmetricProjector n).mulVec x = x := by + funext w + change (∑ v, (if wordType n w = wordType n v then + ((Nat.multinomial Finset.univ (wordType n w).val : ℝ)⁻¹ : ℂ) else 0) * x v) = x w + have he (v) : (if wordType n w = wordType n v then + ((Nat.multinomial Finset.univ (wordType n w).val : ℝ)⁻¹ : ℂ) else 0) * x v = + if wordType n v = wordType n w then + ((Nat.multinomial Finset.univ (wordType n w).val : ℝ)⁻¹ : ℂ) * x w else 0 := by + by_cases h : wordType n w = wordType n v + · rw [ite_eq_left h, ite_eq_left h.symm, hx w v ((wordType_eq_iff n w v).mp h)] + · simp [h, Ne.symm h] + simp_rw [he] + rw [← Finset.sum_filter] + simp only [Finset.sum_const, nsmul_eq_mul] + have hc : (Finset.univ.filter (fun v : Fin n → A => wordType n v = wordType n w)).card = + Nat.multinomial Finset.univ (wordType n w).val := by + rw [← Fintype.card_subtype, card_wordType] + rw [hc] + have hn : (Nat.multinomial Finset.univ (wordType n w).val : ℂ) ≠ 0 := by + exact_mod_cast (Nat.ne_of_gt (Nat.multinomial_pos Finset.univ (wordType n w).val)) + push_cast + field_simp + +lemma symmetricProjector_idempotent (n : ℕ) : + symmetricProjector (A := A) n * symmetricProjector n = symmetricProjector n := by + ext w v + have h := symmetricProjector_identity n (fun u => symmetricProjector n u v) (by + intro u t hut + simp only [symmetricProjector, wordType_eq_iff, hut] + have ht : wordType n u = wordType n t := (wordType_eq_iff n u t).mpr hut + rw [ht]) + exact congrFun h w + +lemma symmetric_rankOne_bound (n : ℕ) (v : (Fin n → A) → ℂ) + (hv : ∀ w u, wordCounts w = wordCounts u → v w = v u) : + ((rankOne v).trace • symmetricProjector n - rankOne v).PosSemidef := + rankOne_projection_bound _ (symmetricProjector_psd n).1 + (symmetricProjector_idempotent n) _ (symmetricProjector_identity n v hv) + +theorem symmetric_vector_postselection (n : ℕ) (hn : 0 < n) (v : (Fin n → A) → ℂ) + (hv : ∀ w u, wordCounts w = wordCounts u → v w = v u) : + (((rankOne v).trace * ((n+1 : ℕ) : ℂ)^Fintype.card A) • + (∑ c : WordType A n, phaseAverage n (empirical n c)) - rankOne v).PosSemidef := by + have hh := (finite_postselection (A := A) n hn).smul (rankOne_psd v).trace_nonneg + have hr := symmetric_rankOne_bound n v hv + have he : ((rankOne v).trace * ((n+1 : ℕ) : ℂ)^Fintype.card A) • + (∑ c : WordType A n, phaseAverage n (empirical n c)) - rankOne v = + (rankOne v).trace • ((((n+1 : ℕ) : ℂ)^Fintype.card A) • + (∑ c : WordType A n, phaseAverage n (empirical n c)) - symmetricProjector n) + + ((rankOne v).trace • symmetricProjector n - rankOne v) := by + simp only [smul_sub, smul_smul] + abel + rw [he] + exact hh.add hr + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceConvex.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceConvex.lean new file mode 100644 index 0000000000000000000000000000000000000000..02d420f18777f2d85caf36e18492f61abaf371eb --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceConvex.lean @@ -0,0 +1,225 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.TraceInterpolation + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Matrix.Norms.L2Operator +open Complex + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma trace_mul_diagonal_le (A : M ι) (d : ι → ℝ) + (hA : ‖A‖ ≤ 1) (hd : ∀ i, 0 ≤ d i) : + ‖Matrix.trace (A * Matrix.diagonal (fun i => (d i : ℂ)))‖ ≤ ∑ i, d i := by + unfold Matrix.trace + simp only [Matrix.diag_apply, Matrix.mul_diagonal] + refine (norm_sum_le _ _).trans (Finset.sum_le_sum fun i _ => ?_) + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hd i)] + exact mul_le_of_le_one_left (hd i) ((entry_norm_le A i i).trans hA) + +lemma trace_prod_density_le (L : List (M ι)) (A : M ι) (d : ι → ℝ) + (hL : ∀ B ∈ L, ‖B‖ ≤ 1) (hA : ‖A‖ ≤ 1) (hd : ∀ i, 0 ≤ d i) + (hmem : A * Matrix.diagonal (fun i => (d i : ℂ)) ∈ L) : + ‖Matrix.trace L.prod‖ ≤ ∑ i, d i := by + obtain ⟨l, r, rfl⟩ := List.mem_iff_append.mp hmem + have hl : ‖l.prod‖ ≤ 1 := prod_norm_le_one l (fun B hB => hL B (by simp [hB])) + have hr : ‖r.prod‖ ≤ 1 := prod_norm_le_one r (fun B hB => hL B (by simp [hB])) + simp only [List.prod_append, List.prod_cons] + rw [← mul_assoc, Matrix.trace_mul_cycle] + rw [← mul_assoc] + apply trace_mul_diagonal_le _ d _ hd + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) + ((norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) hr).trans hl))).trans hA) + +def Admissible {m : ℕ} (d : Fin m → ι → ℝ) (x : Fin m → ℝ) : Prop := + ∀ A : Fin m → M ι, (∀ j, ‖A j‖ ≤ 1) → + ‖traceWord A d (fun j => (x j : ℂ))‖ ≤ 1 + +def exponentSet {m : ℕ} (d : Fin m → ι → ℝ) : Set (Fin m → ℝ) := + {x | (∀ j, 0 ≤ x j) ∧ Admissible d x} + +lemma word_absorb_phase {m : ℕ} (A : Fin m → M ι) (d : Fin m → ι → ℝ) + (x : Fin m → ℂ) : + word A d x = word (fun j => A j * diagPower (d j) ((x j).im * I)) d + (fun j => ((x j).re : ℂ)) := by + unfold word + congr 1 + apply List.ofFn_inj.mpr + funext j + have hx : x j = ((x j).im : ℂ) * I + ((x j).re : ℂ) := by + rw [add_comm]; exact (Complex.re_add_im (x j)).symm + calc + A j * diagPower (d j) (x j) = A j * + diagPower (d j) (((x j).im : ℂ) * I + ((x j).re : ℂ)) := by rw [← hx] + _ = _ := by rw [diagPower_add, mul_assoc] + +lemma admissible_complex {m : ℕ} (d : Fin m → ι → ℝ) (x : Fin m → ℝ) + (hx : Admissible d x) (A : Fin m → M ι) (hA : ∀ j, ‖A j‖ ≤ 1) + (z : Fin m → ℂ) (hz : ∀ j, (z j).re = x j) : ‖traceWord A d z‖ ≤ 1 := by + unfold traceWord + rw [word_absorb_phase] + simp only [hz] + apply hx + intro j + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) (hA j)).trans + (diagPower_imag_norm_le_one _ _)) + +lemma vertex_mem_exponentSet {m : ℕ} (d : Fin m → ι → ℝ) + (hd : ∀ j i, 0 ≤ d j i) (hs : ∀ j, ∑ i, d j i = 1) (j : Fin m) : + Pi.single j 1 ∈ exponentSet d := by + have hd1 : ∀ j i, d j i ≤ 1 := by + intro j i + rw [← hs j] + exact Finset.single_le_sum (fun i _ => hd j i) (Finset.mem_univ i) + constructor + · intro i; simp only [Pi.single_apply]; split_ifs <;> norm_num + · intro A hA + have hv0 : ∀ i : Fin m, 0 ≤ (((Pi.single j 1 : Fin m → ℝ) i) : ℂ).re := by + intro i; simp only [ofReal_re, Pi.single_apply]; split_ifs <;> norm_num + have hmem : A j * Matrix.diagonal (fun i => (d j i : ℂ)) ∈ + List.ofFn (fun k => A k * diagPower (d k) (((Pi.single j 1 : Fin m → ℝ) k) : ℂ)) := by + apply List.mem_ofFn.mpr + refine ⟨j, ?_⟩ + simp [diagPower_one _ (hd j)] + have hlist : ∀ B ∈ List.ofFn (fun k => A k * + diagPower (d k) (((Pi.single j 1 : Fin m → ℝ) k) : ℂ)), ‖B‖ ≤ 1 := by + intro B hB + obtain ⟨k, rfl⟩ := List.mem_ofFn.mp hB + exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) (hA k)).trans + (diagPower_norm_le_one _ (hd k) (hd1 k) (hv0 k))) + unfold traceWord word + exact (trace_prod_density_le _ _ (d j) hlist (hA j) (hd j) hmem).trans_eq (hs j) + +lemma convex_exponentSet {m : ℕ} (d : Fin m → ι → ℝ) + (hd : ∀ j i, 0 ≤ d j i) (hd1 : ∀ j i, d j i ≤ 1) : + Convex ℝ (exponentSet d) := by + intro x hx y hy a b ha hb hab + constructor + · intro j + exact add_nonneg (mul_nonneg ha (hx.1 j)) (mul_nonneg hb (hy.1 j)) + · intro A hA + let e (j : Fin m) (z : ℂ) := (1-z) * (x j : ℂ) + z * (y j : ℂ) + let f (z : ℂ) := traceWord A d (fun j => e j z) + have he : ∀ j, Differentiable ℂ (e j) := fun j => + (((differentiable_const (1 : ℂ)).sub differentiable_id).mul_const _).add + (differentiable_id.mul_const _) + have hf : Differentiable ℂ f := differentiable_traceWord A d e he + have hre (j : Fin m) (z : ℂ) : (e j z).re = (1-z.re)*x j + z.re*y j := by + simp [e, Complex.mul_re] + have hbound : BddAbove ((norm ∘ f) '' HadamardThreeLines.verticalClosedStrip 0 1) := by + refine ⟨Fintype.card ι, ?_⟩ + rintro t ⟨z, hz, rfl⟩ + have hz' : 0 ≤ z.re ∧ z.re ≤ 1 := hz + have hw : ‖word A d (fun j => e j z)‖ ≤ 1 := + word_norm_le_one A d _ hA hd hd1 (fun j => by + rw [hre] + exact add_nonneg (mul_nonneg (sub_nonneg.mpr hz'.2) (hx.1 j)) + (mul_nonneg hz'.1 (hy.1 j))) + exact (trace_norm_le _).trans (mul_le_of_le_one_right (Nat.cast_nonneg _) hw) + have hleft : ∀ z ∈ Complex.re ⁻¹' {(0 : ℝ)}, ‖f z‖ ≤ 1 := by + intro z hz + have hz' : z.re = 0 := hz + exact admissible_complex d x hx.2 A hA _ (fun j => by rw [hre, hz']; ring) + have hright : ∀ z ∈ Complex.re ⁻¹' {(1 : ℝ)}, ‖f z‖ ≤ 1 := by + intro z hz + have hz' : z.re = 1 := hz + exact admissible_complex d y hy.2 A hA _ (fun j => by rw [hre, hz']; ring) + have hb1 : b ≤ 1 := by linarith + have hbi : (b : ℂ) ∈ HadamardThreeLines.verticalClosedStrip 0 1 := ⟨hb, hb1⟩ + have hthree := HadamardThreeLines.norm_le_interp_of_mem_verticalClosedStrip₀₁' + f hbi hf.diffContOnCl hbound hleft hright + have heval : f (b : ℂ) = traceWord A d (fun j => ((a • x + b • y) j : ℂ)) := by + change traceWord A d (fun j => e j (b : ℂ)) = _ + apply congrArg (traceWord A d) + funext j + dsimp only [e] + simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul, Complex.ofReal_add, + Complex.ofReal_mul] + have ha' : (a : ℂ) = 1 - (b : ℂ) := by exact_mod_cast (show a = 1-b by linarith) + rw [ha'] + simpa [heval] using hthree + +theorem trace_diagonal_simplex {m : ℕ} (d : Fin m → ι → ℝ) + (hd : ∀ j i, 0 ≤ d j i) (hs : ∀ j, ∑ i, d j i = 1) + (x : Fin m → ℝ) (hx : ∀ j, 0 ≤ x j) (hsx : ∑ j, x j = 1) + (A : Fin m → M ι) (hA : ∀ j, ‖A j‖ ≤ 1) : + ‖traceWord A d (fun j => (x j : ℂ))‖ ≤ 1 := by + have hd1 : ∀ j i, d j i ≤ 1 := by + intro j i + rw [← hs j] + exact Finset.single_le_sum (fun i _ => hd j i) (Finset.mem_univ i) + have hc := convex_exponentSet d hd hd1 + have hsum := hc.sum_mem (t := Finset.univ) (w := x) (z := fun j => Pi.single j (1 : ℝ)) + (fun j _ => hx j) hsx (fun j _ => vertex_mem_exponentSet d hd hs j) + have heq : ∑ j, x j • Pi.single j (1 : ℝ) = x := by + ext j + simp [Finset.sum_apply, Pi.single_apply] + rw [heq] at hsum + exact hsum.2 A hA + +end BinaryCoordinateSweeps.TraceHolder + +end + +open scoped BigOperators Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma prod_sandwich_succ {α : Type*} [Monoid α] (n : ℕ) + (U D V : Fin (n+1) → α) : + (List.ofFn (fun j => U j * D j * V j)).prod = + U 0 * D 0 * (List.ofFn (fun j : Fin n => + (V j.castSucc * U j.succ) * D j.succ)).prod * V (Fin.last n) := by + induction n with + | zero => simp + | succ n ih => + rw [List.ofFn_succ, List.prod_cons] + rw [ih (fun j => U j.succ) (fun j => D j.succ) (fun j => V j.succ)] + simp only [List.ofFn_succ, List.prod_cons, Fin.castSucc_zero, Fin.succ_zero_eq_one, + Fin.succ_last, Fin.castSucc_succ] + simp only [mul_assoc] + +lemma trace_prod_sandwich {n : ℕ} (U D V : Fin (n+1) → M ι) : + Matrix.trace (List.ofFn (fun j => U j * D j * V j)).prod = + Matrix.trace (List.ofFn (Fin.cons (V (Fin.last n) * U 0 * D 0) + (fun j : Fin n => (V j.castSucc * U j.succ) * D j.succ))).prod := by + rw [prod_sandwich_succ, List.ofFn_succ, List.prod_cons] + simp only [Fin.cons_zero, Fin.cons_succ] + rw [Matrix.trace_mul_comm] + congr 1 + simp only [mul_assoc] + +theorem trace_diagonal_sandwich {n : ℕ} (d : Fin (n+1) → ι → ℝ) + (hd : ∀ j i, 0 ≤ d j i) (hs : ∀ j, ∑ i, d j i = 1) + (x : Fin (n+1) → ℝ) (hx : ∀ j, 0 ≤ x j) (hsx : ∑ j, x j = 1) + (U V : Fin (n+1) → M ι) (hU : ∀ j, ‖U j‖ ≤ 1) (hV : ∀ j, ‖V j‖ ≤ 1) : + ‖Matrix.trace (List.ofFn (fun j => U j * diagPower (d j) (x j : ℂ) * V j)).prod‖ ≤ 1 := by + let A : Fin (n+1) → M ι := Fin.cons (V (Fin.last n) * U 0) + (fun j : Fin n => V j.castSucc * U j.succ) + have hA : ∀ j, ‖A j‖ ≤ 1 := by + intro j + refine Fin.cases ?_ (fun k => ?_) j + · exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) (hV _)).trans (hU _)) + · exact (norm_mul_le _ _).trans ((mul_le_of_le_one_left (norm_nonneg _) (hV _)).trans (hU _)) + have heq : Matrix.trace (List.ofFn (fun j => U j * diagPower (d j) (x j : ℂ) * V j)).prod = + traceWord A d (fun j => (x j : ℂ)) := by + rw [trace_prod_sandwich] + unfold traceWord word + congr 2 + apply List.ofFn_inj.mpr + funext j + refine Fin.cases ?_ (fun k => ?_) j <;> rfl + rw [heq] + exact trace_diagonal_simplex d hd hs x hx hsx A hA + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceDensityComparison.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceDensityComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..11071736be74c79645ae9d7f1de7095a61137787 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceDensityComparison.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.Whitening + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I W : Type*} [Fintype I] [DecidableEq I] [Fintype W] + +omit [DecidableEq I] in +lemma trace_re_real_smul (a : ℝ) (X : Matrix I I ℂ) : + ((a : ℂ) • X).trace.re = a * X.trace.re := by + simp [Matrix.trace_smul,Complex.mul_re] + +omit [DecidableEq I] in +lemma trace_re_nat_smul (a : ℕ) (X : Matrix I I ℂ) : + ((a : ℂ) • X).trace.re = a * X.trace.re := by + simpa only [Complex.ofReal_natCast] using trace_re_real_smul (a:ℝ) X + +lemma trace_density_whitening (R Q P C : Matrix I I ℂ) (d a : ℝ) + (V : W → Matrix I I ℂ) (hR : R.PosSemidef) (hC : C.IsHermitian) + (hcap : (C*Q*C-(d:ℂ)•(Q*P)).PosSemidef) + (hdom : ((a:ℂ)•∑w, V w-Q).PosSemidef) : + d*(R*Q*P).trace.re ≤ a*∑w, (C*R*C*V w).trace.re := by + have h1 := trace_product_re_mono hR hcap + rw [Matrix.mul_smul,trace_re_real_smul,← mul_assoc R Q P] at h1 + have h2 := hdom.mul_mul_conjTranspose_same C + rw [hC.eq,Matrix.mul_sub,Matrix.sub_mul,Matrix.mul_smul,Matrix.smul_mul, + Matrix.mul_sum,Matrix.sum_mul] at h2 + have h3 := trace_product_re_mono hR h2 + rw [Matrix.mul_smul,trace_re_real_smul,Matrix.mul_sum,Matrix.trace_sum, + Complex.re_sum] at h3 + have he (w : W) : (R*(C*V w*C)).trace = (C*R*C*V w).trace := by + rw [← mul_assoc R (C*V w) C,Matrix.trace_mul_cycle] + congr 1 + noncomm_ring + simp only [he] at h3 + exact h1.trans h3 + +lemma trace_right_density_domination (R S : Matrix I I ℂ) (a : ℝ) + (U : W → Matrix I I ℂ) (hS : S.PosSemidef) + (hdom : ((a:ℂ)•∑w, U w-R).PosSemidef) : + (R*S).trace.re ≤ a * ∑w, (U w*S).trace.re := by + have ht := trace_product_re_mono hS hdom + rw [Matrix.mul_smul,trace_re_real_smul,Matrix.mul_sum,Matrix.trace_sum,Complex.re_sum, + Matrix.trace_mul_comm S R] at ht + simpa only [Matrix.trace_mul_comm S] using ht + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceHolder.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..34d9f2af9874b6556dab325f502629deb3221403 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceHolder.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.SpectralMoment +import OAI.Probability.BinarySweep.MatrixBounds.TraceConvex + +namespace OAI + +noncomputable section +open scoped BigOperators Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +lemma normalized_svd {q : ℕ} (hq : 0 < q) (A : M ι) (ht : 0 < matrixMoment q A) : + ∃ (U V : M ι) (d : ι → ℝ), ‖U‖ ≤ 1 ∧ ‖V‖ ≤ 1 ∧ + (∀ i, 0 ≤ d i) ∧ (∑ i, d i = 1) ∧ + A = (matrixMoment q A ^ ((2*q : ℕ) : ℝ)⁻¹ : ℝ) • + (U * diagPower d ((((2*q : ℕ) : ℝ)⁻¹ : ℝ) : ℂ) * V) := by + obtain ⟨U, W, s, hs, hU, hA, hg⟩ := exists_partial_svd A + have hsum := matrixMoment_of_svd A q W s hg + obtain ⟨hd, hsumd, heq⟩ := density_normalization (by omega : 0 < 2*q) s hs ht hsum.symm + refine ⟨U, star (W : M ι), fun i => s i ^ (2*q) / matrixMoment q A, + hU, ?_, hd, hsumd, ?_⟩ + · simpa only [norm_star] using unitary_norm_le_one W + · conv_lhs => rw [hA, heq] + simp only [mul_smul_comm, smul_mul_assoc] + +lemma prod_ofFn_smul {m : ℕ} (r : Fin m → ℝ) (A : Fin m → M ι) : + (List.ofFn (fun j => r j • A j)).prod = (∏ j, r j) • (List.ofFn A).prod := by + induction m with + | zero => simp + | succ m ih => + simp only [List.ofFn_succ, List.prod_cons, Fin.prod_univ_succ] + rw [ih] + rw [smul_mul_smul_comm] + +lemma trace_diagonal_sandwich_pos {m : ℕ} (hm : 0 < m) (d : Fin m → ι → ℝ) + (hd : ∀ j i, 0 ≤ d j i) (hs : ∀ j, ∑ i, d j i = 1) + (x : Fin m → ℝ) (hx : ∀ j, 0 ≤ x j) (hsx : ∑ j, x j = 1) + (U V : Fin m → M ι) (hU : ∀ j, ‖U j‖ ≤ 1) (hV : ∀ j, ‖V j‖ ≤ 1) : + ‖Matrix.trace (List.ofFn (fun j => U j * diagPower (d j) (x j : ℂ) * V j)).prod‖ ≤ 1 := by + cases m with + | zero => omega + | succ n => exact trace_diagonal_sandwich d hd hs x hx hsx U V hU hV + +theorem matrix_trace_holder {q : ℕ} (hq : 0 < q) (A : Fin (2*q) → M ι) : + ‖Matrix.trace (List.ofFn A).prod‖ ≤ + ∏ j, matrixMoment q (A j) ^ (((2*q : ℕ) : ℝ)⁻¹) := by + classical + have hm : 0 < 2*q := by omega + have hm' : 0 < ((2*q : ℕ) : ℝ) := by exact_mod_cast hm + by_cases hzero : ∃ j, matrixMoment q (A j) = 0 + · obtain ⟨j, hj⟩ := hzero + have hAj : A j = 0 := (matrixMoment_eq_zero_iff hq (A j)).mp hj + have hp : (List.ofFn A).prod = 0 := List.prod_eq_zero (List.mem_ofFn.mpr ⟨j, hAj⟩) + rw [hp, Matrix.trace_zero, norm_zero] + exact Finset.prod_nonneg (fun k _ => Real.rpow_nonneg (matrixMoment_nonneg _ _) _) + · have ht : ∀ j, 0 < matrixMoment q (A j) := by + intro j + exact lt_of_le_of_ne (matrixMoment_nonneg _ _) (Ne.symm (fun h => hzero ⟨j, h⟩)) + choose U V d hU hV hd hs heq using fun j => normalized_svd hq (A j) (ht j) + let r : Fin (2*q) → ℝ := fun j => matrixMoment q (A j) ^ (((2*q : ℕ) : ℝ)⁻¹) + let B : Fin (2*q) → M ι := fun j => + U j * diagPower (d j) (((((2*q : ℕ) : ℝ)⁻¹ : ℝ) : ℂ)) * V j + have hb : ‖Matrix.trace (List.ofFn B).prod‖ ≤ 1 := by + apply trace_diagonal_sandwich_pos hm d hd hs (fun _ => ((2*q : ℕ) : ℝ)⁻¹) + (fun _ => (inv_pos.mpr hm').le) _ U V hU hV + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + exact mul_inv_cancel₀ hm'.ne' + have hEq : A = fun j => r j • B j := funext heq + conv_lhs => rw [hEq, prod_ofFn_smul, Matrix.trace_smul, norm_smul] + have hr : 0 ≤ ∏ j, r j := Finset.prod_nonneg fun j _ => Real.rpow_nonneg (ht j).le _ + rw [Real.norm_eq_abs, abs_of_nonneg hr] + exact mul_le_of_le_one_right hr hb + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceInterpolation.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b628652a1abc82f6f608538d21d673ce612bd23c --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/TraceInterpolation.lean @@ -0,0 +1,236 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Matrix.Norms.L2Operator +open Complex + +namespace BinaryCoordinateSweeps.TraceHolder + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +abbrev M (ι : Type*) := Matrix ι ι ℂ + +lemma entry_norm_le (A : M ι) (i j : ι) : ‖A i j‖ ≤ ‖A‖ := by + let e : EuclideanSpace ℂ ι := PiLp.single 2 j 1 + have he : ‖e‖ = 1 := by simp [e] + have hi := PiLp.norm_apply_le ((Matrix.toEuclideanCLM (𝕜 := ℂ) (n := ι)) A e) i + have hval : ((Matrix.toEuclideanCLM (𝕜 := ℂ) (n := ι)) A e).ofLp i = A i j := by + simp only [Matrix.ofLp_toEuclideanCLM, e, PiLp.ofLp_single, Matrix.mulVec_single, MulOpposite.op_one, one_smul, Matrix.col_apply] + rw [hval] at hi + exact hi.trans (by simpa only [he, mul_one, ← Matrix.cstar_norm_def] using ((Matrix.toEuclideanCLM (𝕜 := ℂ) (n := ι)) A).le_opNorm e) + +lemma trace_norm_le (A : M ι) : ‖Matrix.trace A‖ ≤ Fintype.card ι * ‖A‖ := by + unfold Matrix.trace + calc + _ ≤ ∑ i, ‖A i i‖ := norm_sum_le _ _ + _ ≤ ∑ _i : ι, ‖A‖ := Finset.sum_le_sum fun i _ => entry_norm_le A i i + _ = _ := by simp + +lemma prod_norm_le_one (l : List (M ι)) + (hl : ∀ a ∈ l, ‖a‖ ≤ 1) : ‖l.prod‖ ≤ 1 := by + induction l with + | nil => + change ‖(1 : M ι)‖ ≤ 1 + rw [← Matrix.diagonal_one, Matrix.l2_opNorm_diagonal] + exact (pi_norm_le_iff_of_nonneg zero_le_one).mpr (by simp) + | cons a l ih => + rw [List.prod_cons] + exact (norm_mul_le _ _).trans + ((mul_le_of_le_one_left (norm_nonneg _) (hl _ (by simp))).trans + (ih (fun b hb => hl b (by simp [hb])))) + +def diagPower (d : ι → ℝ) (z : ℂ) : M ι := + Matrix.diagonal fun i => if d i = 0 then 0 else Complex.exp (z * (Real.log (d i) : ℂ)) + +lemma diagPower_add (d : ι → ℝ) (z w : ℂ) : + diagPower d (z+w) = diagPower d z * diagPower d w := by + ext i j + by_cases hij : i = j + · subst j + simp only [diagPower, Matrix.diagonal_mul_diagonal, Matrix.diagonal_apply_eq] + split_ifs <;> simp [add_mul, Complex.exp_add] + · simp [diagPower, Matrix.diagonal_apply_ne _ hij] + +lemma diagPower_norm_le_one (d : ι → ℝ) (hd0 : ∀ i, 0 ≤ d i) (hd : ∀ i, d i ≤ 1) + {z : ℂ} (hz : 0 ≤ z.re) : ‖diagPower d z‖ ≤ 1 := by + rw [diagPower, Matrix.l2_opNorm_diagonal] + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro i + split_ifs with hi + · simp + · rw [Complex.norm_exp] + apply Real.exp_le_one_iff.mpr + simp only [Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, mul_zero, sub_zero] + exact mul_nonpos_of_nonneg_of_nonpos hz (Real.log_nonpos (hd0 i) (hd i)) + +lemma diagPower_imag_norm_le_one (d : ι → ℝ) (t : ℝ) : + ‖diagPower d ((t : ℂ) * Complex.I)‖ ≤ 1 := by + rw [diagPower, Matrix.l2_opNorm_diagonal] + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro i + split_ifs <;> simp [Complex.norm_exp, Complex.mul_re] + +omit [Fintype ι] in +lemma diagPower_one (d : ι → ℝ) (hd : ∀ i, 0 ≤ d i) : + diagPower d 1 = Matrix.diagonal (fun i => (d i : ℂ)) := by + ext i j + by_cases hij : i = j + · subst j + simp only [diagPower, Matrix.diagonal_apply_eq, one_mul] + by_cases hi : d i = 0 + · simp [hi] + · rw [ite_eq_right hi, ← Complex.ofReal_exp, Real.exp_log (lt_of_le_of_ne (hd i) (Ne.symm hi))] + · simp [diagPower, Matrix.diagonal_apply_ne _ hij] + +lemma differentiable_diagPower (d : ι → ℝ) : Differentiable ℂ (diagPower d) := by + let L := (Matrix.diagonalLinearMap ι ℂ ℂ).toContinuousLinearMap + change Differentiable ℂ (fun z => L (fun i => if d i = 0 then 0 else + Complex.exp (z * (Real.log (d i) : ℂ)))) + apply L.differentiable.comp + apply differentiable_pi.mpr + intro i + by_cases hi : d i = 0 + · simp [hi] + · simp only [hi, ite_false] + exact Complex.differentiable_exp.comp (differentiable_id.mul_const _) + +def word {m : ℕ} (A : Fin m → M ι) (d : Fin m → ι → ℝ) (x : Fin m → ℂ) : M ι := + (List.ofFn (fun j => A j * diagPower (d j) (x j))).prod + +def traceWord {m : ℕ} (A : Fin m → M ι) (d : Fin m → ι → ℝ) (x : Fin m → ℂ) : ℂ := + Matrix.trace (word A d x) + +lemma word_norm_le_one {m : ℕ} (A : Fin m → M ι) (d : Fin m → ι → ℝ) + (x : Fin m → ℂ) (hA : ∀ j, ‖A j‖ ≤ 1) (hd0 : ∀ j i, 0 ≤ d j i) (hd : ∀ j i, d j i ≤ 1) + (hx : ∀ j, 0 ≤ (x j).re) : ‖word A d x‖ ≤ 1 := by + apply prod_norm_le_one + intro B hB + obtain ⟨j, rfl⟩ := List.mem_ofFn.mp hB + exact (norm_mul_le _ _).trans + ((mul_le_of_le_one_left (norm_nonneg _) (hA j)).trans + (diagPower_norm_le_one (d j) (hd0 j) (hd j) (hx j))) + +lemma differentiable_word {m : ℕ} (A : Fin m → M ι) (d : Fin m → ι → ℝ) + (x : Fin m → ℂ → ℂ) (hx : ∀ j, Differentiable ℂ (x j)) : + Differentiable ℂ (fun z => word A d (fun j => x j z)) := by + induction m with + | zero => simp [word] + | succ m ih => + simp only [word, List.ofFn_succ, List.prod_cons] + apply Differentiable.mul + · have h₀ : Differentiable ℂ (fun z => diagPower (d 0) (x 0 z)) := + (differentiable_diagPower (d 0)).comp (hx 0) + exact (differentiable_const (A 0)).mul h₀ + · exact ih (fun j => A j.succ) (fun j => d j.succ) (fun j => x j.succ) + (fun j => hx j.succ) + +lemma differentiable_traceWord {m : ℕ} (A : Fin m → M ι) (d : Fin m → ι → ℝ) + (x : Fin m → ℂ → ℂ) (hx : ∀ j, Differentiable ℂ (x j)) : + Differentiable ℂ (fun z => traceWord A d (fun j => x j z)) := by + exact (Matrix.traceLinearMap ι ℂ ℂ).toContinuousLinearMap.differentiable.comp + (differentiable_word A d x hx) + +end BinaryCoordinateSweeps.TraceHolder + +end + +open scoped BigOperators Matrix.Norms.L2Operator + +namespace BinaryCoordinateSweeps.TraceHolder +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def diagReal (s : ι → ℝ) : M ι := Matrix.diagonal (fun i => (s i : ℂ)) + +omit [Fintype ι] in +lemma star_diagReal (s : ι → ℝ) : star (diagReal s) = diagReal s := by + simp [diagReal, Matrix.star_eq_conjTranspose, Matrix.diagonal_conjTranspose] + +lemma diagReal_mul (s t : ι → ℝ) : diagReal s * diagReal t = diagReal (fun i => s i*t i) := by + simp [diagReal, Matrix.diagonal_mul_diagonal, Complex.ofReal_mul] + +omit [DecidableEq ι] in +lemma gram_product (X Y : M ι) : + star (X*Y) * (X*Y) = star Y * (star X * X) * Y := by + simp only [star_mul, mul_assoc] + +lemma gram_diagonal_factor (X : M ι) (s : ι → ℝ) + (hX : star X * X = diagReal (fun i => s i ^ 2)) : + ∃ U : M ι, ‖U‖ ≤ 1 ∧ X = U * diagReal s := by + let t : ι → ℝ := fun i => (s i)⁻¹ + let U := X * diagReal t + have hU : star U * U = diagReal (fun i => if s i = 0 then 0 else 1) := by + rw [gram_product, hX, star_diagReal, diagReal_mul, diagReal_mul] + congr 1 + funext i + dsimp [t] + split_ifs with hi + · simp [hi] + · field_simp + have hUnorm : ‖U‖ ≤ 1 := by + have h : ‖star U * U‖ ≤ 1 := by + rw [hU, diagReal, Matrix.l2_opNorm_diagonal] + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro i + split_ifs <;> norm_num + rw [CStarRing.norm_star_mul_self] at h + nlinarith [norm_nonneg U] + let w : ι → ℝ := fun i => 1 - t i * s i + have hz : star (X * diagReal w) * (X * diagReal w) = 0 := by + rw [gram_product, hX, star_diagReal, diagReal_mul, diagReal_mul] + have hw : (fun i => (w i * s i ^ 2) * w i) = 0 := by + funext i + dsimp [w, t] + by_cases hi : s i = 0 <;> simp [hi] + rw [hw] + simp [diagReal] + have hzero : X * diagReal w = 0 := (CStarRing.star_mul_self_eq_zero_iff _).mp hz + have hw : diagReal w = 1 - diagReal t * diagReal s := by + rw [diagReal_mul] + dsimp [diagReal, w] + rw [← Matrix.diagonal_one, Matrix.diagonal_sub] + congr 1 + funext i + simp + rw [hw, mul_sub, mul_one] at hzero + refine ⟨U, hUnorm, ?_⟩ + exact (sub_eq_zero.mp hzero).trans (mul_assoc _ _ _).symm + +theorem exists_partial_svd (A : M ι) : + ∃ (U : M ι) (V : Matrix.unitaryGroup ι ℂ) (s : ι → ℝ), + (∀ i, 0 ≤ s i) ∧ ‖U‖ ≤ 1 ∧ + A = U * diagReal s * star (V : M ι) ∧ + star A * A = (V : M ι) * diagReal (fun i => s i ^ 2) * star (V : M ι) := by + let h := Matrix.isHermitian_conjTranspose_mul_self A + let V := h.eigenvectorUnitary + let s : ι → ℝ := fun i => Real.sqrt (h.eigenvalues i) + have hs0 : ∀ i, 0 ≤ s i := fun i => Real.sqrt_nonneg _ + have hs : ∀ i, s i ^ 2 = h.eigenvalues i := fun i => + Real.sq_sqrt (Matrix.eigenvalues_conjTranspose_mul_self_nonneg A i) + have hdiag : star (V : M ι) * (star A * A) * (V : M ι) = + diagReal (fun i => s i ^ 2) := by + simpa only [V, s, hs, diagReal, Matrix.star_eq_conjTranspose, Function.comp_def, + Unitary.conjStarAlgAut_star_apply] using! h.conjStarAlgAut_star_eigenvectorUnitary + have hgram : star (A * (V : M ι)) * (A * (V : M ι)) = + diagReal (fun i => s i ^ 2) := by rw [gram_product, hdiag] + obtain ⟨U, hU, heq⟩ := gram_diagonal_factor (A * (V : M ι)) s hgram + have hVV : (V : M ι) * star (V : M ι) = 1 := by + simpa only [Unitary.coe_star] using Unitary.coe_mul_star_self V + refine ⟨U, V, s, hs0, hU, ?_, ?_⟩ + · have heq' := congrArg (fun X => X * star (V : M ι)) heq + simpa only [mul_assoc, hVV, mul_one] using heq' + · calc + star A * A = ((V : M ι) * star (V : M ι)) * (star A * A) * + ((V : M ι) * star (V : M ι)) := by rw [hVV, one_mul, mul_one] + _ = (V : M ι) * (star (V : M ι) * (star A * A) * (V : M ι)) * + star (V : M ι) := by simp only [mul_assoc] + _ = _ := by rw [hdiag] + +end BinaryCoordinateSweeps.TraceHolder + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/MatrixBounds/Whitening.lean b/lean/OAI/Probability/BinarySweep/MatrixBounds/Whitening.lean new file mode 100644 index 0000000000000000000000000000000000000000..85203760d38ea7ccd9dee6577972a59c50f18090 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/MatrixBounds/Whitening.lean @@ -0,0 +1,189 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.TensorProductMatrices +import OAI.Probability.BinarySweep.Representations.IsotypicSpectral + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + +lemma symmetric_projection_commutes (S : Submodule ℂ W) (A : Module.End ℂ W) + (hA : A.IsSymmetric) (hS : ∀ w ∈ S, A w ∈ S) (w : W) : + A (S.starProjection w) = S.starProjection (A w) := by + symm + apply S.eq_starProjection_of_mem_of_inner_eq_zero (hS _ (S.starProjection_apply_mem w)) + intro u hu + rw [← map_sub, hA] + exact S.starProjection_inner_eq_zero w (A u) (hS u hu) + +omit [Fintype G] [FiniteDimensional ℂ V] in +lemma isotypic_norm_cap [ρ.IsIrreducible] (B : Module.End ℂ W) + (hT : ∀ g w, (B.adjoint * B) (σ g w) = σ g ((B.adjoint * B) w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (ht : (LinearMap.trace ℂ W (B.adjoint * B)).re = 1) + {w : W} (hw : w ∈ isotypicSpan ρ σ) : + (Module.finrank ℂ V : ℝ) * ‖B w‖^2 ≤ ‖w‖^2 := by + have hp : (B.adjoint * B).IsPositive := LinearMap.isPositive_adjoint_comp_self B + have hc := (isotypic_restriction_cap ρ σ (B.adjoint*B) hp hT hσ).2 ⟨w,hw⟩ + have hr := hc + change 0 ≤ (inner ℂ ((↑((LinearMap.trace ℂ W) (B.adjoint*B)).re : ℂ) • w - + (Module.finrank ℂ V : ℂ) • B.adjoint (B w)) w).re at hr + rw [ht,Complex.ofReal_one,one_smul,inner_sub_left,inner_smul_left, + LinearMap.adjoint_inner_left,inner_self_eq_norm_sq_to_K,inner_self_eq_norm_sq_to_K] at hr + simp only [← RCLike.ofReal_pow,Complex.sub_re,Complex.mul_re,Complex.natCast_re, + Complex.natCast_im,map_natCast,zero_mul,sub_zero] at hr + change 0 ≤ ‖w‖^2 - (Module.finrank ℂ V : ℝ)*‖B w‖^2 at hr + linarith + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem whitening_norm [ρ.IsIrreducible] (B A : Module.End ℂ W) + (hA : A.IsSymmetric) (hAc : ∀ g w, A (σ g w) = σ g (A w)) + (hBA : B*A = 1) + (hT : ∀ g w, (B.adjoint * B) (σ g w) = σ g ((B.adjoint * B) w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (ht : (LinearMap.trace ℂ W (B.adjoint * B)).re = 1) (w : W) : + (Module.finrank ℂ V : ℝ) * ‖(isotypicSpan ρ σ).starProjection w‖^2 ≤ ‖A w‖^2 := by + let S := isotypicSpan ρ σ + have hi := commuting_isotypic_invariant ρ σ A hAc + have hb : B (A (S.starProjection w)) = S.starProjection w := by + exact congrArg (fun T : Module.End ℂ W => T (S.starProjection w)) hBA + have hn := isotypic_norm_cap ρ σ B hT hσ ht + (hi _ (S.starProjection_apply_mem w)) + rw [hb,symmetric_projection_commutes S A hA hi] at hn + exact hn.trans (pow_le_pow_left₀ (norm_nonneg _) (S.norm_starProjection_apply_le (A w)) 2) + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem whitening_positive [ρ.IsIrreducible] (B A : Module.End ℂ W) + (hA : A.IsSymmetric) (hAc : ∀ g w, A (σ g w) = σ g (A w)) + (hBA : B*A = 1) + (hT : ∀ g w, (B.adjoint * B) (σ g w) = σ g ((B.adjoint * B) w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (ht : (LinearMap.trace ℂ W (B.adjoint * B)).re = 1) : + (A.adjoint * A - (Module.finrank ℂ V : ℂ) • + (isotypicSpan ρ σ).starProjection.toLinearMap).IsPositive := by + have hsym := (LinearMap.isPositive_adjoint_comp_self A).1 + have hP : (isotypicSpan ρ σ).starProjection.toLinearMap.IsSymmetric := + fun u v => (isotypicSpan ρ σ).inner_starProjection_left_eq_right u v + refine ⟨hsym.sub (hP.smul (by simp)),?_⟩ + intro w + have hn := whitening_norm ρ σ B A hA hAc hBA hT hσ ht w + change 0 ≤ (inner ℂ (A.adjoint (A w) - + (Module.finrank ℂ V : ℂ) • (isotypicSpan ρ σ).starProjection w) w).re + rw [inner_sub_left,inner_smul_left,LinearMap.adjoint_inner_left, + inner_self_eq_norm_sq_to_K] + simp only [Complex.sub_re,Complex.mul_re,Complex.natCast_re,Complex.natCast_im, + ← RCLike.ofReal_pow,map_natCast,zero_mul,sub_zero] + change 0 ≤ ‖A w‖^2 - (Module.finrank ℂ V : ℝ) * + RCLike.re (inner ℂ ((isotypicSpan ρ σ).starProjection w) w) + rw [(isotypicSpan ρ σ).re_inner_starProjection_eq_normSq] + exact sub_nonneg.mpr hn + +end BinaryCoordinateSweeps.Irrep + +end + +section + +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [DecidableEq I] + +lemma trace_product_nonneg {A B : Matrix I I ℂ} + (hA : A.PosSemidef) (hB : B.PosSemidef) : 0 ≤ (A*B).trace := by + obtain ⟨X,hX⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.nonneg + rw [hX,Matrix.star_eq_conjTranspose,Matrix.trace_mul_cycle,Matrix.trace_mul_cycle] + exact (hB.mul_mul_conjTranspose_same X).trace_nonneg + +lemma trace_product_mono {A B C : Matrix I I ℂ} + (hA : A.PosSemidef) (hBC : (C-B).PosSemidef) : (A*B).trace ≤ (A*C).trace := by + have h := trace_product_nonneg hA hBC + rw [Matrix.mul_sub,Matrix.trace_sub] at h + exact sub_nonneg.mp h + +lemma trace_product_re_nonneg {A B : Matrix I I ℂ} + (hA : A.PosSemidef) (hB : B.PosSemidef) : 0 ≤ (A*B).trace.re := + (Complex.nonneg_iff.mp (trace_product_nonneg hA hB)).1 + +lemma trace_product_re_mono {A B C : Matrix I I ℂ} + (hA : A.PosSemidef) (hBC : (C-B).PosSemidef) : + (A*B).trace.re ≤ (A*C).trace.re := + (Complex.le_def.mp (trace_product_mono hA hBC)).1 + +lemma tensor_product_trace_re {J A : Type*} [Fintype J] [DecidableEq J] + [Fintype A] [DecidableEq A] (R C : J → Matrix A A ℂ) + (hR : ∀ j, (R j).PosSemidef) (hC : ∀ j, (C j).PosSemidef) : + (tensorMatrices R * tensorMatrices C).trace.re = ∏ j, (R j * C j).trace.re := by + rw [tensorMatrices_mul,tensorMatrices_trace] + have hh (j : J) : (R j * C j).trace = ((R j * C j).trace.re : ℂ) := by + apply Complex.ext <;> simp [ (Complex.nonneg_iff.mp (trace_product_nonneg (hR j) (hC j))).2] + rw [show (∏ j, (R j * C j).trace) = ∏ j, ((R j * C j).trace.re : ℂ) from + Finset.prod_congr rfl (fun j _ => hh j)] + rw [← Complex.ofReal_prod,Complex.ofReal_re] + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder MatrixOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {A : Type*} [Fintype A] [DecidableEq A] + +def parityProjection (p : A → Bool) : Matrix A A ℂ := + Matrix.diagonal (fun a => if p a then 1 else 0) + +lemma commutes_parity_iff (p : A → Bool) (M : Matrix A A ℂ) : + Commute M (parityProjection p) ↔ ∀ a b, p a ≠ p b → M a b = 0 := by + constructor + · intro h a b hab + have he := congrArg (fun N : Matrix A A ℂ => N a b) h.eq + simp only [parityProjection,Matrix.mul_diagonal,Matrix.diagonal_mul] at he + cases ha : p a <;> cases hb : p b <;> simp_all + · intro h + apply Matrix.ext + intro a b + simp only [parityProjection,Matrix.mul_diagonal,Matrix.diagonal_mul] + by_cases he : p a = p b + · rw [he]; ring + · rw [h a b he]; simp + +lemma sqrt_commutes {M N : Matrix A A ℂ} (hM : M.PosSemidef) (hc : Commute M N) : + Commute (CFC.sqrt M) N := by + rw [CFC.sqrt_eq_real_sqrt M hM.nonneg] + exact hc.cfcₙ (by rwa [hM.isHermitian.star_eq]) Real.sqrt + +theorem exists_even_whitening (p : A → Bool) (M : Matrix A A ℂ) + (hM : M.PosDef) (he : ∀ a b, p a ≠ p b → M a b = 0) : + ∃ B C : Matrix A A ℂ, + B.PosSemidef ∧ C.PosSemidef ∧ B*B = M ∧ B*C = 1 ∧ C*B = 1 ∧ + (∀ a b, p a ≠ p b → B a b = 0) ∧ (∀ a b, p a ≠ p b → C a b = 0) := by + let B := CFC.sqrt M + have hB : B.PosSemidef := (CFC.sqrt_nonneg M).posSemidef + have hBB : B*B = M := CFC.sqrt_mul_sqrt_self M hM.posSemidef.nonneg + have hu : IsUnit B := (CFC.isUnit_sqrt_iff M hM.posSemidef.nonneg).mpr hM.isUnit + let := hu.nonempty_invertible.some + have heB := sqrt_commutes hM.posSemidef ((commutes_parity_iff p M).mpr he) + refine ⟨B,⅟B,hB,?_,hBB,mul_invOf_self B,invOf_mul_self B, + (commutes_parity_iff p B).mp heB,(commutes_parity_iff p (⅟B)).mp heB.invOf_left⟩ + rw [Matrix.invOf_eq_nonsing_inv] + exact hB.inv + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/BinaryContraction.lean b/lean/OAI/Probability/BinarySweep/Mixing/BinaryContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae1246847ec57c364f224978fdd75689933972af --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/BinaryContraction.lean @@ -0,0 +1,213 @@ +import Mathlib +import OAI.Probability.BinarySweep.Analytic.AnalyticTransfer +import OAI.Probability.BinarySweep.GridBounds.GridLaw +import OAI.Probability.BinarySweep.FiniteLaws.BitBlocks + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +lemma averageOperator_sum {G : Type*} [Fintype G] [Monoid G] {D : ℕ} + (p : G → ℝ) (ρ : Representation ℂ G (RepSpace D)) : + averageOperator p ρ=∑g,(p g:ℂ) • Module.End.toContinuousLinearMap (RepSpace D) (ρ g) := by + apply ContinuousLinearMap.coe_injective + simp [averageOperator,Module.End.toContinuousLinearMap] + +lemma pushLaw_complex_expectation {A B R : Type*} [Fintype A] [Fintype B] + [AddCommMonoid R] [Module ℂ R] (p : A → ℝ) (f : A → B) (F : B → R) : + (∑b,(pushLaw p f b:ℂ) • F b)=∑a,(p a:ℂ) • F (f a) := by + unfold pushLaw + simp only [Complex.ofReal_sum,apply_ite,Complex.ofReal_zero,Finset.sum_smul] + rw [Finset.sum_comm] + simp [ite_smul] + +lemma gridAverage_relabel {b D d : ℕ} (bits : Fin b → ℕ) (e : GridSlot bits ≃ Slot d) + (ρ : Representation ℂ (Equiv.Perm (Slot d)) (RepSpace D)) + (he : pushLaw (gridLaw bits) e.permCongr=binaryLaw d) : + complexGridAverage bits (ρ.comp e.permCongrHom.toMonoidHom) 1= + averageOperator (binaryLaw d) ρ := by + rw [averageOperator_sum,←he,pushLaw_complex_expectation] + unfold gridLaw + rw [pushLaw_complex_expectation] + unfold complexGridAverage + apply Finset.sum_congr rfl + intro c _ + rw [show (1:ℂ)=(1:ℝ) from rfl,complexGridWeight_real] + rfl + +theorem binary_contraction : BinaryContractionTarget := by + obtain ⟨r,hr,g,hg,hgrid⟩ := grid_analytic_contraction + refine ⟨g,hg,r,?_⟩ + intro d hd D ρ hi hu + have := hi + obtain ⟨b,hb,bits,hbits,hsum⟩ := exists_bit_blocks r hr d hd + obtain ⟨d',hd',e,he⟩ := gridLaw_binary b hb bits + have hdd : d'=d := hd'.trans hsum + cases hdd + have hσ : Representation.IsIrreducible (ρ.comp e.permCongrHom.toMonoidHom) := + Irrep.irreducible_comp_equiv e.permCongrHom ρ + have hunit : IsUnitaryRep (ρ.comp e.permCongrHom.toMonoidHom) := fun g v => hu _ _ + have hh := hgrid b hb bits hbits D (ρ.comp e.permCongrHom.toMonoidHom) hσ hunit + rwa [gridAverage_relabel bits e ρ he] at hh + +open Irrep + +variable {G V : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +lemma complexAverage_transport (ρ : Representation ℂ G V) (p : G → ℂ) + (v : V) : + (stdOrthonormalBasis ℂ V).repr (complexAverage ρ p v)= + complexAverage (conjugateRep ρ (stdOrthonormalBasis ℂ V).repr.toLinearEquiv) p + ((stdOrthonormalBasis ℂ V).repr v) := by + simp only [complexAverage_apply,map_sum,map_smul] + apply Finset.sum_congr rfl + intro g _ + congr 1 + change _ = (stdOrthonormalBasis ℂ V).repr + (ρ g ((stdOrthonormalBasis ℂ V).repr.symm ((stdOrthonormalBasis ℂ V).repr v))) + rw [LinearIsometryEquiv.symm_apply_apply] + +lemma hilbert_norm_of_coordinates (ρ : Representation ℂ G V) (p : G → ℂ) {a : ℝ} + (ha : 0≤a) + (h : ‖complexAverage (conjugateRep ρ (stdOrthonormalBasis ℂ V).repr.toLinearEquiv) p‖≤a) : + ‖complexAverage ρ p‖≤a := by + apply ContinuousLinearMap.opNorm_le_bound _ ha + intro v + rw [←(stdOrthonormalBasis ℂ V).repr.norm_map (complexAverage ρ p v), + complexAverage_transport] + exact ((complexAverage _ _).le_opNorm _).trans (by + rw [LinearIsometryEquiv.norm_map] + exact mul_le_mul_of_nonneg_right h (norm_nonneg _)) + +theorem binary_hilbert_contraction : ∃ g : ℝ, 0 (binaryLaw d g:ℂ))‖≤(Module.finrank ℂ V:ℝ)^(-g) := by + obtain ⟨g,hg,d₀,hh⟩ := binary_contraction + refine ⟨g,hg,d₀,?_⟩ + intro d hd V _ _ _ ρ hi hu + let := hi + let E := (stdOrthonormalBasis ℂ V).repr + let σ := conjugateRep ρ E.toLinearEquiv + have hσ : σ.IsIrreducible := irreducible_equiv ρ σ (conjugateEquiv ρ E.toLinearEquiv) + have hunit : IsUnitaryRep σ := by + intro g v + change ‖E (ρ g (E.symm v))‖=‖v‖ + rw [E.norm_map,hu,E.symm.norm_map] + exact hilbert_norm_of_coordinates ρ _ (by positivity) (hh d hd _ σ hσ hunit) + +lemma evenMoment_one_norm_bound (A : V →L[ℂ] V) {a : ℝ} (_ha : 0≤a) (hA : ‖A‖≤a) : + evenMoment 1 A.toLinearMap ≤ (Module.finrank ℂ V:ℝ)*a^2 := by + let e := stdOrthonormalBasis ℂ V + unfold evenMoment + rw [pow_one,LinearMap.trace_eq_sum_inner _ e,Complex.re_sum] + calc + _ ≤ ∑i : Fin (Module.finrank ℂ V),a^2 := by + apply Finset.sum_le_sum + intro i _ + rw [Module.End.mul_apply,LinearMap.adjoint_inner_right] + have hn : ‖e i‖=1 := e.orthonormal.1 i + have hb := (A.le_opNorm (e i)).trans + (mul_le_mul_of_nonneg_right hA (norm_nonneg _)) + rw [hn,mul_one] at hb + rw [inner_self_eq_norm_sq_to_K] + norm_cast + exact pow_le_pow_left₀ (norm_nonneg _) hb 2 + _ = _ := by simp + +lemma complexAverage_uniform_zero (ρ : Representation ℂ G V) [ρ.IsIrreducible] + (hD : 1 (uniformLaw G g:ℂ))=0 := by + apply ContinuousLinearMap.coe_injective + change groupAverage ρ _ = 0 + simp only [groupAverage,uniformLaw,Complex.ofReal_inv,Complex.ofReal_natCast, + ←Finset.smul_sum,Irrep.sum_eq_zero_of_finrank_gt_one ρ hD,smul_zero] + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) + +lemma swap_tabloid_eq {I : Type*} [DecidableEq I] + (a : Cell μ) (ha : row a≠0) (u : I ↪ Cell μ) (hu : ∀i,row (u i)=0) + (hfix : ∀c : C μ, ∀i,c.val (u i)=u i) (i j : I) (c : C μ) : + tabloidOfPerm μ (Equiv.swap a (u i)*c.val)=tabloidOfPerm μ (Equiv.swap a (u j)) ↔ + i=j ∧ c=1 := by + have hau (i : I) : a≠u i := fun he => ha (he ▸ hu i) + constructor + · intro he + have hij : i=j := by + by_contra hij + have huij : u j≠u i := fun hh => hij (u.injective hh).symm + have hju : u j≠a := (hau j).symm + have hh := congrArg (fun t : Tabloid μ => t.val (u j)) he + have hc := hfix c⁻¹ j + have hs : Equiv.swap a (u i) (u j)=u j := Equiv.swap_apply_of_ne_of_ne hju huij + simp only [tabloidOfPerm,labels,mul_inv_rev,Equiv.swap_inv, + Equiv.Perm.mul_apply,hs,Equiv.swap_apply_right] at hh + change row (c.val⁻¹ (u j))=row a at hh + rw [show c.val⁻¹ (u j)=u j from hc,hu] at hh + exact ha hh.symm + subst j + have hc : c.val⁻¹ ∈ rowStabilizer μ := by + have hh := (tabloidOfPerm_eq_iff μ _ _).mp he + simpa only [mul_inv_rev,mul_assoc,inv_mul_cancel,mul_one] using hh + have hc' : c.val ∈ rowStabilizer μ := by + simpa using (rowStabilizer μ).inv_mem hc + have hh : c.val ∈ rowStabilizer μ ⊓ colStabilizer μ := ⟨hc',c.property⟩ + rw [row_col_intersection] at hh + exact ⟨rfl,Subtype.ext hh⟩ + · rintro ⟨rfl,rfl⟩ + simp + +lemma swap_poly_coefficient {I : Type*} [DecidableEq I] + (a : Cell μ) (ha : row a≠0) (u : I ↪ Cell μ) (hu : ∀i,row (u i)=0) + (hfix : ∀c : C μ, ∀i,c.val (u i)=u i) (i j : I) : + tabloidRepresentation μ (Equiv.swap a (u i)) (polytabloid μ) + (tabloidOfPerm μ (Equiv.swap a (u j)))=if i=j then (1:ℂ) else 0 := by + rw [polytabloid,columnAnti_apply] + simp_rw [rep_basis,smul_tabloidOfPerm,mul_one] + rw [map_sum] + simp_rw [map_smul,rep_basis,smul_tabloidOfPerm] + simp only [Finset.sum_apply,Pi.smul_apply,tabloidBasis,Pi.single_apply] + have he (c : C μ) : tabloidOfPerm μ (Equiv.swap a (u j))= + tabloidOfPerm μ (Equiv.swap a (u i)*c.val) ↔ i=j ∧ c=1 := + eq_comm.trans (swap_tabloid_eq μ a ha u hu hfix i j c) + simp only [he] + by_cases hij : i=j <;> simp [hij] + +theorem singleton_column_dimension {I : Type*} [Fintype I] [DecidableEq I] + (a : Cell μ) (ha : row a≠0) (u : I ↪ Cell μ) (hu : ∀i,row (u i)=0) + (hfix : ∀c : C μ, ∀i,c.val (u i)=u i) : + Fintype.card I ≤ Module.finrank ℂ (SpechtSpace μ) := by + have hind : LinearIndependent ℂ + (fun i : I => spechtRep μ (Equiv.swap a (u i)) (spechtPoly μ)) := by + apply LinearIndependent.of_comp (f:=spechtInclude μ) + rw [Fintype.linearIndependent_iff] + intro t ht j + have hh := congrFun ht (tabloidOfPerm μ (Equiv.swap a (u j))) + simp only [Finset.sum_apply,Pi.smul_apply,Function.comp_apply,Pi.zero_apply] at hh + simp_rw [spechtInclude_rep,spechtInclude_poly,swap_poly_coefficient μ a ha u hu hfix] at hh + simpa using hh + let : Module.Finite ℂ (SpechtSpace μ) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace μ)) + exact hind.fintype_card_le_finrank + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/BinaryLineDisk.lean b/lean/OAI/Probability/BinarySweep/Mixing/BinaryLineDisk.lean new file mode 100644 index 0000000000000000000000000000000000000000..604aebd661521942d2a3e672d65faaff4055c0cd --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/BinaryLineDisk.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.PointMassOne +import OAI.Probability.BinarySweep.Analytic.FiniteAverageGap + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +def complexLineLaw (d : ℕ) (z : ℂ) (g : Equiv.Perm (Slot d)) : ℂ := + (1-z)*(uniformLaw (Equiv.Perm (Slot d)) g:ℂ)+z*(binaryLaw d g:ℂ) + +lemma complexLineLaw_real (d : ℕ) (z : ℝ) (g : Equiv.Perm (Slot d)) : + complexLineLaw d (z:ℂ) g=(lineLaw d z g:ℂ) := by + simp [complexLineLaw,lineLaw] + +lemma complexLine_average {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] + [FiniteDimensional ℂ V] (d : ℕ) (ρ : Representation ℂ (Equiv.Perm (Slot d)) V) + (z : ℂ) : complexAverage ρ (complexLineLaw d z)= + complexAverage ρ (fun g => (uniformLaw (Equiv.Perm (Slot d)) g:ℂ))+ + z • (complexAverage ρ (fun g => (binaryLaw d g:ℂ))- + complexAverage ρ (fun g => (uniformLaw (Equiv.Perm (Slot d)) g:ℂ))) := by + ext v + simp only [complexAverage_apply,complexLineLaw,add_smul,mul_smul, + Finset.sum_add_distrib,←Finset.smul_sum,add_apply, + smul_apply,sub_apply] + module + +theorem binary_line_disk (d : ℕ) : ∃ R : ℝ, 1 + obtain ⟨R,hR,h⟩ := binary_line_disk 0 + refine ⟨R,hR,?_⟩ + intro d hd + have : d=0 := by omega + subst d + exact h + | succ m ih => + obtain ⟨R,hR,h⟩ := ih + obtain ⟨S,hS,k⟩ := binary_line_disk (m+1) + refine ⟨min R S,lt_min hR hS,?_⟩ + intro d hd V _ _ _ ρ hρ z hz + by_cases he : d=m+1 + · subst d + exact k V ρ hρ z (hz.trans (min_le_right _ _)) + · exact h d (by omega) V ρ hρ z (hz.trans (min_le_left _ _)) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/BinaryMixingBounds.lean b/lean/OAI/Probability/BinarySweep/Mixing/BinaryMixingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..09dbf1d538c71a61d3553dac755ee93c00cf0d9f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/BinaryMixingBounds.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.BinarySweep.Mixing.DimensionSeries + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Young + +lemma decay_eighth {D : ℝ} (hD : 0 (binaryLaw d g:ℂ))‖≤(Module.finrank ℂ V:ℝ)^(-g)) : + (Module.finrank ℂ V:ℝ)*evenMoment 1 + (groupAverage ρ (fun g => (sweepLaw d w g-uniformLaw _ g:ℂ))) ≤ + ((Module.finrank ℂ V:ℝ)^8)⁻¹ := by + obtain ⟨v,hv⟩ := Module.finrank_pos_iff_exists_ne_zero.mp + (show 0 (sweepLaw d w g-uniformLaw _ g:ℂ))= + (complexAverage ρ (fun g => (binaryLaw d g:ℂ)))^w := by + simp only [complexAverage_sub,complexAverage_uniform_zero ρ hD, + sub_zero,sweepLaw,complexAverage_power] + have hb : ‖complexAverage ρ (fun g => (sweepLaw d w g-uniformLaw _ g:ℂ))‖≤D^(-5:ℝ) := by + rw [he] + calc + _ ≤ ‖complexAverage ρ (fun g => (binaryLaw d g:ℂ))‖^w := norm_pow_le _ _ + _ ≤ (D^(-g))^w := pow_le_pow_left₀ (norm_nonneg _) hA w + _ = D^((-g)*(w:ℝ)) := (Real.rpow_mul_natCast hp.le _ _).symm + _ ≤ D^(-5:ℝ) := Real.rpow_le_rpow_of_exponent_le hone (by nlinarith) + have hm := evenMoment_one_norm_bound + (complexAverage ρ (fun g => (sweepLaw d w g-uniformLaw _ g:ℂ))) + (Real.rpow_nonneg hp.le _) hb + change evenMoment 1 (groupAverage ρ _)≤D*(D^(-5:ℝ))^2 at hm + exact (mul_le_mul_of_nonneg_left hm hp.le).trans_eq (decay_eighth hp) + +def binarySlotsFin (d : ℕ) : Slot d ≃ Fin (2^d) := + Fintype.equivOfCardEq (by simp [Slot]) + +lemma partition_slot_flat {d : ℕ} (p : (2^d).Partition) (w : ℕ) + (hd : 0 (sweepLaw d w g-uniformLaw _ g:ℂ)))=0 := by + have he : (partitionHilbertRep p).comp (binarySlotsFin d).permCongrHom.toMonoidHom= + (hilbertSpecht (diagram p)).comp + ((cellsEquivFin p).trans (binarySlotsFin d).symm).symm.permCongrHom.toMonoidHom := by + rfl + rw [he] + exact flat_shape_moment_zero _ _ _ hp (sweep_centered_mass d w) (sweep_centered_sign hd hw) + +theorem binary_variation_bound_exists : ∃ w : ℕ, 0 partitionHilbertRep_unitary p _ v)) + +end BinaryCoordinateSweeps + +end + +namespace BinaryCoordinateSweeps + +def BinaryMainTarget : Prop := BinaryContractionTarget ∧ + (∀ d : ℕ, 0 < d → ∑ g : Equiv.Perm (Slot d), + binaryLaw d g * realSign g = 0) ∧ UniformSweepMixingTarget +end BinaryCoordinateSweeps + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Young + +lemma binary_dimension_series_tendsto : Filter.Tendsto (fun d : ℕ => dimensionSeries (2^d)) + Filter.atTop (nhds 0) := by + apply dimensionSeries_tendsto.comp + apply Filter.tendsto_atTop.2 + intro b + exact Filter.eventually_atTop.2 ⟨b,fun d hd => hd.trans (Nat.le_of_lt d.lt_two_pow_self)⟩ + +theorem constant_sweep_mixing : ConstantSweepMixingTarget := by + obtain ⟨w,hw,d₀,hbound⟩ := binary_variation_bound_exists + refine ⟨w,?_⟩ + intro ε hε + have heps : 0<4*ε^2 := by positivity + have ht : ∀ᶠ d : ℕ in Filter.atTop, dimensionSeries (2^d)<4*ε^2 := + (Filter.Tendsto.eventually_lt_const heps binary_dimension_series_tendsto) + obtain ⟨d₁,hd₁⟩ := Filter.eventually_atTop.1 ht + refine ⟨max d₀ d₁,?_⟩ + intro d hd τ + rw [totalVariation_fromInitial] + have hb := hbound d ((le_max_left _ _).trans hd) + have hs := hd₁ d ((le_max_right _ _).trans hd) + have hh : totalVariation (sweepLaw d w) (uniformLaw (Equiv.Perm (Slot d)))^2<ε^2 := by + nlinarith + nlinarith + +theorem uniform_sweep_mixing : UniformSweepMixingTarget := by + obtain ⟨w,hw⟩ := constant_sweep_mixing + refine ⟨w,?_⟩ + intro ε hε + obtain ⟨d₀,hd₀⟩ := hw ε hε + exact ⟨d₀,fun d hd τ => (hd₀ d hd τ).le⟩ + +theorem binary_main : BinaryMainTarget := + ⟨binary_contraction,binary_sign_annihilated,uniform_sweep_mixing⟩ + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/BinarySplitChoices.lean b/lean/OAI/Probability/BinarySweep/Mixing/BinarySplitChoices.lean new file mode 100644 index 0000000000000000000000000000000000000000..9973044082b983254db8fbe529e7f4b6cc1d4dd3 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/BinarySplitChoices.lean @@ -0,0 +1,216 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedBlock +import OAI.Probability.BinarySweep.GridBounds.GridSplitSweep +import OAI.Probability.BinarySweep.FiniteLaws.OneCard + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.BinarySplit +variable {m n : ℕ} + +def fillSlot {d : ℕ} (j : Fin d) (u : {i : Fin d // i≠j} → Bool) : Slot d := + (Equiv.piSplitAt j (fun _ => Bool)).symm (false,u) + +lemma fillSlot_other {d : ℕ} (j : Fin d) (u : {i : Fin d // i≠j} → Bool) + (i : Fin d) (hi : i≠j) : fillSlot j u i=u ⟨i,hi⟩ := by + simp [fillSlot,Equiv.piSplitAt,hi] + +def leftOutsideEquiv (j : Fin m) : + ({i : Fin (m+n) // i≠j.castAdd n} → Bool) ≃ Slot n × ({i : Fin m // i≠j} → Bool) where + toFun u := (fun i => u ⟨i.natAdd m,by intro h; have hh := congrArg (fun q:Fin (m+n) => q.val) h; simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega⟩, + fun i => u ⟨i.val.castAdd n,fun h => i.property (Fin.ext (congrArg (fun q:Fin (m+n) => q.val) h))⟩) + invFun yu i := Fin.addCases (fillSlot j yu.2) yu.1 i.val + left_inv u := by + funext i + rcases i with ⟨i,hi⟩ + revert hi + induction i using Fin.addCases with + | left i => + intro hi + have hij : i≠j := fun h => hi (congrArg (Fin.castAdd n) h) + simp only [Fin.addCases_left,fillSlot_other _ _ _ hij] + | right i => intro hi; simp only [Fin.addCases_right] + right_inv yu := by + apply Prod.ext + · funext i + simp only [Fin.addCases_right] + · funext i + simp only [Fin.addCases_left,fillSlot_other _ _ _ i.property] + +def rightOutsideEquiv (j : Fin n) : + ({i : Fin (m+n) // i≠j.natAdd m} → Bool) ≃ Slot m × ({i : Fin n // i≠j} → Bool) where + toFun u := (fun i => u ⟨i.castAdd n,by intro h; have hh := congrArg (fun q:Fin (m+n) => q.val) h; simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega⟩, + fun i => u ⟨i.val.natAdd m,fun h => i.property (Fin.ext (by have hh := congrArg (fun q:Fin (m+n) => q.val) h; simpa using hh))⟩) + invFun xu i := Fin.addCases xu.1 (fillSlot j xu.2) i.val + left_inv u := by + funext i + rcases i with ⟨i,hi⟩ + revert hi + induction i using Fin.addCases with + | left i => intro hi; simp only [Fin.addCases_left] + | right i => + intro hi + have hij : i≠j := fun h => hi (congrArg (Fin.natAdd m) h) + simp only [Fin.addCases_right,fillSlot_other _ _ _ hij] + right_inv xu := by + apply Prod.ext + · funext i + simp only [Fin.addCases_left] + · funext i + simp only [Fin.addCases_right,fillSlot_other _ _ _ i.property] + +def rowChoices (g : SweepCoins (m+n)) (y : Slot n) : SweepCoins m := + fun j u => g (j.castAdd n) ((leftOutsideEquiv j).symm (y,u)) +def columnChoices (g : SweepCoins (m+n)) (x : Slot m) : SweepCoins n := + fun j u => g (j.natAdd m) ((rightOutsideEquiv j).symm (x,u)) + +def joinChoices (L : Slot n → SweepCoins m) + (R : Slot m → SweepCoins n) : SweepCoins (m+n) := + Fin.addCases (fun j u => L ((leftOutsideEquiv j) u).1 j ((leftOutsideEquiv j) u).2) + (fun j u => R ((rightOutsideEquiv j) u).1 j ((rightOutsideEquiv j) u).2) + +def choicesEquiv : SweepCoins (m+n) ≃ + (Slot n → SweepCoins m) × + (Slot m → SweepCoins n) where + toFun g := (rowChoices g,columnChoices g) + invFun LR := joinChoices LR.1 LR.2 + left_inv g := by + funext j u + induction j using Fin.addCases with + | left j => simp [joinChoices,rowChoices] + | right j => simp [joinChoices,columnChoices] + right_inv LR := by + apply Prod.ext + · funext y j u + simp [rowChoices,joinChoices] + · funext x j u + simp [columnChoices,joinChoices] + +end BinaryCoordinateSweeps.BinarySplit + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.BinarySplit +open GridSplit + +variable {m n : ℕ} + +lemma rowChoices_at (c : SweepCoins (m+n)) (x : Slot (m+n)) (j : Fin m) : + rowChoices c (Signed.splitWord x).2 j (fun i => (Signed.splitWord x).1 i)= + c (j.castAdd n) (fun i => x i) := by + unfold rowChoices + congr 1 + apply (leftOutsideEquiv j).injective + rw [Equiv.apply_symm_apply] + rfl + +lemma columnChoices_at (c : SweepCoins (m+n)) (x : Slot (m+n)) (j : Fin n) : + columnChoices c (Signed.splitWord x).1 j (fun i => (Signed.splitWord x).2 i)= + c (j.natAdd m) (fun i => x i) := by + unfold columnChoices + congr 1 + apply (rightOutsideEquiv j).injective + rw [Equiv.apply_symm_apply] + rfl + +lemma layer_left (c : SweepCoins (m+n)) (j : Fin m) (x : Slot (m+n)) : + Signed.splitWord (coordinateLayer (m+n) (j.castAdd n) (c (j.castAdd n)) x)= + (coordinateLayer m j (rowChoices c (Signed.splitWord x).2 j) (Signed.splitWord x).1, + (Signed.splitWord x).2) := by + apply Prod.ext + · dsimp only + funext i + change coordinateLayer _ _ _ x (i.castAdd n)=_ + by_cases hi : i=j + · subst i + rw [coordinateLayer_apply_at,coordinateLayer_apply_at,rowChoices_at] + rfl + · rw [coordinateLayer_apply_other _ _ _ (fun he => hi (Fin.ext + (congrArg (fun i : Fin (m+n) => i.val) he))),coordinateLayer_apply_other _ _ _ hi] + rfl + · dsimp only + funext i + exact coordinateLayer_apply_other (m+n) (j.castAdd n) (i.natAdd m) (by + intro he + have hh := congrArg (fun i : Fin (m+n) => i.val) he + simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega) _ x + +lemma layer_right (c : SweepCoins (m+n)) (j : Fin n) (x : Slot (m+n)) : + Signed.splitWord (coordinateLayer (m+n) (j.natAdd m) (c (j.natAdd m)) x)= + ((Signed.splitWord x).1, + coordinateLayer n j (columnChoices c (Signed.splitWord x).1 j) (Signed.splitWord x).2) := by + apply Prod.ext + · dsimp only + funext i + exact coordinateLayer_apply_other (m+n) (j.natAdd m) (i.castAdd n) (by + intro he + have hh := congrArg (fun i : Fin (m+n) => i.val) he + simp only [Fin.val_natAdd,Fin.val_castAdd] at hh; omega) _ x + · dsimp only + funext i + change coordinateLayer _ _ _ x (i.natAdd m)=_ + by_cases hi : i=j + · subst i + rw [coordinateLayer_apply_at,coordinateLayer_apply_at,columnChoices_at] + rfl + · rw [coordinateLayer_apply_other _ _ _ (fun he => hi (Fin.ext (by + have hh := congrArg (fun i : Fin (m+n) => i.val) he; simpa using hh))), + coordinateLayer_apply_other _ _ _ hi] + rfl + +lemma layer_left_congr (c : SweepCoins (m+n)) (j : Fin m) : + Signed.splitWord.permCongr (coordinateLayer (m+n) (j.castAdd n) (c (j.castAdd n)))= + rowPerm (fun y => coordinateLayer m j (rowChoices c y j)) := by + apply Equiv.ext + intro xy + have he := layer_left c j (Signed.splitWord.symm xy) + change Signed.splitWord (coordinateLayer _ _ _ (Signed.splitWord.symm xy))=_ + rw [he,Equiv.apply_symm_apply] + rfl + +lemma layer_right_congr (c : SweepCoins (m+n)) (j : Fin n) : + Signed.splitWord.permCongr (coordinateLayer (m+n) (j.natAdd m) (c (j.natAdd m)))= + columnPerm (fun x => coordinateLayer n j (columnChoices c x j)) := by + apply Equiv.ext + intro xy + have he := layer_right c j (Signed.splitWord.symm xy) + change Signed.splitWord (coordinateLayer _ _ _ (Signed.splitWord.symm xy))=_ + rw [he,Equiv.apply_symm_apply] + rfl + +theorem binarySweep_split (c : SweepCoins (m+n)) : + Signed.splitWord.permCongr (binarySweep (m+n) c)= + columnPerm (fun x => binarySweep n (columnChoices c x)) * + rowPerm (fun y => binarySweep m (rowChoices c y)) := by + change Signed.splitWord.permCongrHom (binarySweep (m+n) c)=_ + unfold binarySweep + rw [List.ofFn_add,List.reverse_append,List.prod_append,map_mul] + congr 1 + · rw [map_list_prod Signed.splitWord.permCongrHom,List.map_reverse,List.map_ofFn] + change (List.ofFn (fun j : Fin n => Signed.splitWord.permCongr + (coordinateLayer _ (j.natAdd m) (c (j.natAdd m))))).reverse.prod=_ + simp_rw [layer_right_congr] + simpa only [List.map_reverse,List.map_ofFn,Function.comp_def] using + (prod_columns (List.ofFn (fun j : Fin n => fun x => + coordinateLayer n j (columnChoices c x j))).reverse) + · rw [map_list_prod Signed.splitWord.permCongrHom,List.map_reverse,List.map_ofFn] + change (List.ofFn (fun j : Fin m => Signed.splitWord.permCongr + (coordinateLayer _ (j.castAdd n) (c (j.castAdd n))))).reverse.prod=_ + simp_rw [layer_left_congr] + simpa only [List.map_reverse,List.map_ofFn,Function.comp_def] using + (prod_rows (List.ofFn (fun j : Fin m => fun y => + coordinateLayer m j (rowChoices c y j))).reverse) + +end BinaryCoordinateSweeps.BinarySplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/DimensionSeries.lean b/lean/OAI/Probability/BinarySweep/Mixing/DimensionSeries.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbf53de49846bc26b49a6be9b83457735823335a --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/DimensionSeries.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Probability.BinarySweep.Mixing.ShapeDimension + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +def dimensionInv {n : ℕ} (p : n.Partition) : ℝ := + ((Module.finrank ℂ (PartitionHilbert p):ℝ)^8)⁻¹ + +def dimensionFiber (n k : ℕ) : ℝ := if k=0 then 0 else + ∑p : {p : n.Partition // flatTail (diagram p)=k},dimensionInv p.val + +def dimensionSeries (n : ℕ) : ℝ := + ∑p : n.Partition, if flatTail (diagram p)=0 then 0 else dimensionInv p + +lemma dimensionInv_nonneg {n : ℕ} (p : n.Partition) : 0≤dimensionInv p := by + unfold dimensionInv; positivity + +lemma dimensionInv_exponential {n k : ℕ} (p : n.Partition) (hp : flatTail (diagram p)=k) : + dimensionInv p≤(1/16:ℝ)^k := by + have hD : (0:ℝ) dimensionInv_nonneg _) + +lemma dimensionFiber_bound (n k : ℕ) : dimensionFiber n k≤2*(1/8:ℝ)^k := by + by_cases hk : k=0 + · simp [dimensionFiber,hk] + rw [dimensionFiber,ite_eq_right hk] + calc + _ ≤ (Fintype.card {p : n.Partition // flatTail (diagram p)=k}:ℝ)*(1/16:ℝ)^k := by + calc + _ ≤ ∑p : {p : n.Partition // flatTail (diagram p)=k}, (1/16:ℝ)^k := + Finset.sum_le_sum (fun p _ => dimensionInv_exponential p.val p.property) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + _ ≤ (2*2^k:ℝ)*(1/16:ℝ)^k := by + have hh : (Fintype.card {p : n.Partition // flatTail (diagram p)=k}:ℝ)≤2*2^k := by + exact_mod_cast flatTail_card n k + exact mul_le_mul_of_nonneg_right hh (by positivity) + _ = _ := by rw [mul_assoc,←mul_pow]; norm_num + +lemma dimensionFiber_grows_bound {n k : ℕ} (hk : 0 dimensionFiber n k) Filter.atTop (nhds 0) := by + by_cases hk : k=0 + · subst k + simpa only [dimensionFiber,ite_true] using + (tendsto_const_nhds : Filter.Tendsto (fun _ : ℕ => (0:ℝ)) Filter.atTop (nhds 0)) + have ht : Filter.Tendsto (fun n : ℕ => n-2*k) Filter.atTop Filter.atTop := by + apply Filter.tendsto_atTop.2 + intro b + exact Filter.eventually_atTop.2 ⟨b+2*k,fun n hn => by omega⟩ + have hr : Filter.Tendsto (fun n : ℕ => ((n-2*k:ℕ):ℝ)) Filter.atTop Filter.atTop := + tendsto_natCast_atTop_atTop.comp ht + have hlim : Filter.Tendsto (fun n : ℕ => (2*2^k:ℝ)*(((n-2*k:ℕ):ℝ)⁻¹)^8) + Filter.atTop (nhds 0) := by + simpa using (hr.inv_tendsto_atTop.pow 8).const_mul (2*2^k:ℝ) + apply squeeze_zero' (Filter.Eventually.of_forall (fun n => dimensionFiber_nonneg n k)) _ hlim + exact Filter.eventually_atTop.2 ⟨2*k+1,fun n hn => dimensionFiber_grows_bound (by omega) (by omega)⟩ + +lemma dimensionFiber_eq_filter (n k : ℕ) : dimensionFiber n k= + ∑p ∈ Finset.univ.filter (fun p : n.Partition => flatTail (diagram p)=k), + if flatTail (diagram p)=0 then 0 else dimensionInv p := by + unfold dimensionFiber + split + · subst k + symm + apply Finset.sum_eq_zero + intro p hp + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hp + simp only [hp,ite_true] + · rename_i hk + rw [Finset.sum_subtype _ (by simp : ∀p : n.Partition, + p ∈ Finset.univ.filter (fun p => flatTail (diagram p)=k) ↔ flatTail (diagram p)=k)] + apply Finset.sum_congr rfl + intro p _ + rw [ite_eq_right (by rw [p.property]; exact hk)] + +lemma dimensionSeries_tsum (n : ℕ) : dimensionSeries n=∑'k,dimensionFiber n k := by + rw [tsum_eq_sum (s:=Finset.range (n+1))] + · simp_rw [dimensionFiber_eq_filter] + symm + apply Finset.sum_fiberwise_of_maps_to + intro p _ + simp only [Finset.mem_range] + have ht : flatTail (diagram p)≤n := by unfold flatTail; rw [diagram_card]; omega + omega + · intro k hk + by_cases he : k=0 + · simp [dimensionFiber,he] + rw [dimensionFiber,ite_eq_right he] + apply Finset.sum_eq_zero + intro p _ + have ht : flatTail (diagram p.val)≤n := by unfold flatTail; rw [diagram_card]; omega + have hp := p.property + simp only [Finset.mem_range,not_lt] at hk + omega + +theorem dimensionSeries_tendsto : Filter.Tendsto dimensionSeries Filter.atTop (nhds 0) := by + have hs : Summable (fun k : ℕ => 2*(1/8:ℝ)^k) := + Summable.mul_left 2 (summable_geometric_of_norm_lt_one (by norm_num)) + have ht := tendsto_tsum_of_dominated_convergence hs dimensionFiber_tendsto + (Filter.Eventually.of_forall (fun n k => by + rw [Real.norm_eq_abs,abs_of_nonneg (dimensionFiber_nonneg n k)] + exact dimensionFiber_bound n k)) + simpa only [←dimensionSeries_tsum,tsum_zero] using ht + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/LongRowDimension.lean b/lean/OAI/Probability/BinarySweep/Mixing/LongRowDimension.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bbaf5a90234284b34d85771331383d0d7ec77f9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/LongRowDimension.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Probability.BinarySweep.Mixing.BinaryContraction + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) + +def longRowCells : Fin (μ.rowLen 0-μ.rowLen 1) ↪ Cell μ where + toFun j := ⟨(0,μ.rowLen 1+j.val),YoungDiagram.mem_iff_lt_rowLen.mpr (by + have hj := j.isLt + have hm := μ.rowLen_anti 0 1 (by omega) + omega)⟩ + inj' i j := by + intro he + apply Fin.ext + have hh := congrArg (fun x : Cell μ => x.val.2) he + dsimp at hh + omega + +lemma longRowCells_fixed (c : C μ) (j : Fin (μ.rowLen 0-μ.rowLen 1)) : + c.val (longRowCells μ j)=longRowCells μ j := by + have hc := c.property (longRowCells μ j) + have hm := YoungDiagram.mem_iff_lt_rowLen.mp (c.val (longRowCells μ j)).property + have hr : row (c.val (longRowCells μ j))=0 := by + by_contra hne + have ha := μ.rowLen_anti 1 (row (c.val (longRowCells μ j))) (by omega) + change col (c.val (longRowCells μ j)) < μ.rowLen (row (c.val (longRowCells μ j))) at hm + change col (c.val (longRowCells μ j))=μ.rowLen 1+j.val at hc + omega + apply Subtype.ext + exact Prod.ext hr hc + +theorem long_row_dimension (hrow : 0<μ.rowLen 1) : + μ.rowLen 0-μ.rowLen 1 ≤ Module.finrank ℂ (SpechtSpace μ) := by + let a : Cell μ := ⟨(1,0),YoungDiagram.mem_iff_lt_rowLen.mpr hrow⟩ + have hh := singleton_column_dimension μ a (by change (1:ℕ)≠0; omega) + (longRowCells μ) (fun _ => rfl) (longRowCells_fixed μ) + simpa only [Fintype.card_fin] using hh + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +def flatTail (μ : YoungDiagram) : ℕ := μ.card-max (μ.colLen 0) (μ.rowLen 0) +def longOriented (μ : YoungDiagram) : YoungDiagram := + if μ.colLen 0 ≤ μ.rowLen 0 then μ else μ.transpose + +lemma transpose_card (μ : YoungDiagram) : μ.transpose.card=μ.card := by + simp + +lemma rowLens_sum (μ : YoungDiagram) : μ.rowLens.sum=μ.card := by + have h := card_cellsOfRowLens μ.rowLens + change (YoungDiagram.ofRowLens μ.rowLens μ.rowLens_sorted).card=_ at h + rw [YoungDiagram.ofRowLens_to_rowLens_eq_self] at h + exact h.symm + +lemma rowLens_head (μ : YoungDiagram) : μ.rowLens.headD 0=μ.rowLen 0 := by + by_cases h : μ.colLen 0=0 + · have hr : μ.rowLen 0=0 := by + by_contra hn + have hm : (0,0)∈μ := YoungDiagram.mem_iff_lt_rowLen.mpr (by omega) + have hc := YoungDiagram.mem_iff_lt_colLen.mp hm + omega + simp [YoungDiagram.rowLens,h,hr] + · obtain ⟨a,ha⟩ : ∃a, μ.colLen 0=a+1 := ⟨μ.colLen 0-1,by omega⟩ + simp [YoungDiagram.rowLens,ha,List.range_succ_eq_map] + +lemma rowLens_tail_sum (μ : YoungDiagram) : μ.rowLens.tail.sum=μ.card-μ.rowLen 0 := by + have hh : μ.rowLens.headD 0+μ.rowLens.tail.sum=μ.rowLens.sum := by + cases μ.rowLens <;> simp + rw [rowLens_head,rowLens_sum] at hh + omega + +lemma longOriented_card (μ : YoungDiagram) : (longOriented μ).card=μ.card := by + unfold longOriented + split <;> simp_all + +lemma longOriented_row (μ : YoungDiagram) : + (longOriented μ).rowLen 0=max (μ.colLen 0) (μ.rowLen 0) := by + unfold longOriented + split <;> simp_all [YoungDiagram.rowLen_transpose,Nat.le_of_lt] + +lemma positive_list_tail_injective {a b : List ℕ} + (ha : ∀x∈a,0 + cases b with + | nil => rfl + | cons x b => + have hh := hb x (by simp) + simp only [List.sum_nil,List.sum_cons] at hs + omega + | cons x a => + cases b with + | nil => + have hh := ha x (by simp) + simp only [List.sum_nil,List.sum_cons] at hs + omega + | cons y b => + simp only [List.tail_cons] at ht + subst b + simp only [List.sum_cons] at hs + have he : x=y := by omega + subst y + rfl + +def tailCode {n k : ℕ} (p : {p : n.Partition // flatTail (diagram p)=k}) : + Bool × Composition k := + (decide ((diagram p.val).colLen 0 ≤ (diagram p.val).rowLen 0), + ⟨(longOriented (diagram p.val)).rowLens.tail, + fun {i} hi => YoungDiagram.pos_of_mem_rowLens _ _ (List.mem_of_mem_tail hi),by + rw [rowLens_tail_sum,longOriented_card,longOriented_row] + exact p.property⟩) + +lemma tailCode_injective {n k : ℕ} : Function.Injective (tailCode (n:=n) (k:=k)) := by + intro p q he + have ho : longOriented (diagram p.val)=longOriented (diagram q.val) := by + apply YoungDiagram.equivListRowLens.injective + apply Subtype.ext + apply positive_list_tail_injective (YoungDiagram.pos_of_mem_rowLens _) (YoungDiagram.pos_of_mem_rowLens _) + · rw [rowLens_sum,rowLens_sum,longOriented_card,longOriented_card,diagram_card,diagram_card] + · exact congrArg (fun c : Bool × Composition k => c.2.blocks) he + have hb := congrArg Prod.fst he + change decide ((diagram p.val).colLen 0 ≤ (diagram p.val).rowLen 0)= + decide ((diagram q.val).colLen 0 ≤ (diagram q.val).rowLen 0) at hb + have hi := of_decide_eq_true (show decide (((diagram p.val).colLen 0 ≤ (diagram p.val).rowLen 0) ↔ + ((diagram q.val).colLen 0 ≤ (diagram q.val).rowLen 0))=true from by simp [hb]) + apply Subtype.ext + apply diagram_injective + unfold longOriented at ho + by_cases hp : (diagram p.val).colLen 0 ≤ (diagram p.val).rowLen 0 + · simpa [hp,hi.mp hp] using ho + · have hq : ¬(diagram q.val).colLen 0 ≤ (diagram q.val).rowLen 0 := fun hh => hp (hi.mpr hh) + have hh := congrArg YoungDiagram.transpose ho + simpa [hp,hq] using hh + +theorem flatTail_card (n k : ℕ) : + Fintype.card {p : n.Partition // flatTail (diagram p)=k} ≤ 2*2^k := by + have h := Fintype.card_le_of_injective (tailCode (n:=n) (k:=k)) tailCode_injective + simp only [Fintype.card_prod,Fintype.card_bool,composition_card] at h + exact h.trans (Nat.mul_le_mul_left 2 (Nat.pow_le_pow_right (by omega) (by omega))) + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Mixing/ShapeDimension.lean b/lean/OAI/Probability/BinarySweep/Mixing/ShapeDimension.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e21e62599fcb4a5db048e416708e3be4b210b5e --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Mixing/ShapeDimension.lean @@ -0,0 +1,224 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.FourierTrace +import OAI.Probability.BinarySweep.Mixing.LongRowDimension + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +lemma rowLen_one_le_tail (μ : YoungDiagram) : μ.rowLen 1 ≤ μ.rowLens.tail.sum := by + by_cases hh : μ.colLen 0≤1 + · have hz : μ.rowLen 1=0 := by + by_contra hn + have hm : (1,0)∈μ := YoungDiagram.mem_iff_lt_rowLen.mpr (by omega) + have hc := YoungDiagram.mem_iff_lt_colLen.mp hm + omega + rw [hz]; omega + · have hl : 1<μ.rowLens.length := by rw [YoungDiagram.length_rowLens]; omega + have hmem : μ.rowLen 1 ∈ μ.rowLens.tail := by + have hh := List.getElem_mem (show 0<μ.rowLens.tail.length from by simp; omega) + simpa using hh + exact List.single_le_sum (by simp) _ hmem + +lemma rowLen_one_pos_of_tail (μ : YoungDiagram) (h : 0<μ.card-μ.rowLen 0) : + 0<μ.rowLen 1 := by + have ht : 0<μ.rowLens.tail.sum := by rwa [rowLens_tail_sum] + have hc : 1<μ.colLen 0 := by + by_contra hn + have ha : μ.colLen 0=0 ∨ μ.colLen 0=1 := by omega + rcases ha with ha|ha <;> simp [YoungDiagram.rowLens,ha] at ht + exact YoungDiagram.mem_iff_lt_rowLen.mp (YoungDiagram.mem_iff_lt_colLen.mpr hc) + +lemma longOriented_dimension (μ : YoungDiagram) : + Module.finrank ℂ (SpechtSpace (longOriented μ))=Module.finrank ℂ (SpechtSpace μ) := by + by_cases h : μ.colLen 0 ≤ μ.rowLen 0 + · exact congrArg (fun ν => Module.finrank ℂ (SpechtSpace ν)) (ite_eq_left h) + · exact (congrArg (fun ν => Module.finrank ℂ (SpechtSpace ν)) (ite_eq_right h)).trans + (specht_finrank_transpose μ).symm + +lemma dimension_grows (μ : YoungDiagram) (hk : 0 < flatTail μ) : + μ.card-2*flatTail μ ≤ Module.finrank ℂ (SpechtSpace μ) := by + have ht : (longOriented μ).card-(longOriented μ).rowLen 0=flatTail μ := by + rw [longOriented_card,longOriented_row]; rfl + have hr := rowLen_one_pos_of_tail (longOriented μ) (by rwa [ht]) + have hh := long_row_dimension (longOriented μ) hr + rw [longOriented_dimension] at hh + have hle := rowLen_one_le_tail (longOriented μ) + rw [rowLens_tail_sum,ht] at hle + have hc := height_width_le_card μ + have hc' : max (μ.colLen 0) (μ.rowLen 0)≤μ.card := by simpa using hc + rw [longOriented_row] at hh + unfold flatTail at * + omega + +lemma partition_dimension_pos {n : ℕ} (p : n.Partition) : + 0 p g*(realSign g:ℂ))) := by + rw [groupAverage_comp_slots,groupAverage_comp_slots,hilbert_transpose_moment] + congr 2 + funext g + congr 1 + change signC μ.transpose g=(realSign (((transposeCells μ).symm.trans e).permCongr g):ℂ) + rw [realSign_permCongr_complex] + change ((Equiv.Perm.sign g:ℤ):ℂ)=(((Equiv.Perm.sign g:ℤ):ℝ):ℂ) + norm_cast + +theorem flat_shape_moment_zero {X : Type*} [Fintype X] [DecidableEq X] + (μ : YoungDiagram) (e : Cell μ ≃ X) (p : Equiv.Perm X → ℂ) + (hμ : flatTail μ=0) (hp : ∑g,p g=0) (hs : ∑g,p g*(realSign g:ℂ)=0) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) p)=0 := by + have hc : max (μ.colLen 0) (μ.rowLen 0)≤μ.card := by simpa using height_width_le_card μ + have hh : μ.card=μ.rowLen 0 ∨ μ.card=μ.colLen 0 := by + unfold flatTail at hμ + omega + rcases hh with hh|hh + · rw [row_average_zero μ hh e p hp] + simp [evenMoment] + · rw [transpose_slot_moment] + have ht : μ.transpose.card=μ.transpose.rowLen 0 := by + rw [transpose_card,YoungDiagram.rowLen_transpose,hh] + rw [row_average_zero μ.transpose ht _ _ hs] + simp [evenMoment] + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep Young + +lemma sign_convolution {X : Type*} [Fintype X] [DecidableEq X] + (p q : Equiv.Perm X → ℝ) : + (∑g,convolution p q g*realSign g)=(∑g,p g*realSign g)*(∑g,q g*realSign g) := by + simp only [convolution,Finset.sum_mul] + rw [Finset.sum_comm] + calc + _ = ∑x,∑y,p x*q y*realSign (x*y) := by + apply Finset.sum_congr rfl + intro x _ + simpa only [Equiv.coe_mulLeft,inv_mul_cancel_left] using + (Equiv.sum_comp (Equiv.mulLeft x) (fun g => p x*q (x⁻¹*g)*realSign g)).symm + _ = _ := by + simp only [map_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro y _ + ring + +lemma sweep_sign_zero {d w : ℕ} (hd : 0 (p g-q g:ℂ))) := by + have ht := Fourier.variation_fourier_bound (p ∘ e.symm.permCongr) (q ∘ e.symm.permCongr) + have he : totalVariation (p ∘ e.symm.permCongr) (q ∘ e.symm.permCongr)=totalVariation p q := by + unfold totalVariation + congr 1 + exact Equiv.sum_comp e.symm.permCongr (fun g => |p g-q g|) + rw [he] at ht + convert ht using 2 + apply Finset.sum_congr rfl + intro ℓ _ + have hh := groupAverage_comp_slots e.symm (partitionHilbertRep ℓ) + (fun g => (p g-q g:ℂ)) + simpa only [Equiv.symm_symm,Function.comp_apply] using + congrArg (fun A => (Module.finrank ℂ (PartitionHilbert ℓ):ℝ)*evenMoment 1 A) hh + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Model.lean b/lean/OAI/Probability/BinarySweep/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..a358e2bf026134cd0dc06701624ce4a3b4ee6a55 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Model.lean @@ -0,0 +1,93 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace BinaryCoordinateSweeps + +/-- The positions of a binary deck of dimension d. -/ +abbrev Slot (d : ℕ) := Fin d → Bool + +/-- Independent switches on the edges parallel to one coordinate. -/ +def coordinateLayer (d : ℕ) (j : Fin d) + (c : (({i : Fin d // i ≠ j} → Bool)) → Bool) : Equiv.Perm (Slot d) := + let e := Equiv.piSplitAt j (fun _ : Fin d => Bool) + let sw : Equiv.Perm (Bool × ({i : Fin d // i ≠ j} → Bool)) := + { toFun := fun x => (x.1 ^^ c x.2, x.2) + invFun := fun x => (x.1 ^^ c x.2, x.2) + left_inv := fun x => by simp + right_inv := fun x => by simp } + e.trans (sw.trans e.symm) + +abbrev SweepCoins (d : ℕ) := + (j : Fin d) → ({i : Fin d // i ≠ j} → Bool) → Bool + +/-- The coordinate layers are applied in increasing coordinate order. -/ +def binarySweep (d : ℕ) (c : SweepCoins d) : Equiv.Perm (Slot d) := + (List.ofFn (fun j => coordinateLayer d j (c j))).reverse.prod + +def finiteLaw {Ω G : Type*} [Fintype Ω] [Fintype G] (f : Ω → G) (g : G) : ℝ := by + classical + exact ∑ ω, if f ω = g then (Fintype.card Ω : ℝ)⁻¹ else 0 + +/-- Half the unnormalized sum of absolute probability-mass differences. -/ +def totalVariation {G : Type*} [Fintype G] (p q : G → ℝ) : ℝ := + (1 / ((2 : ℕ) : ℝ)) * ∑ g, |p g - q g| + +def uniformLaw (G : Type*) [Fintype G] : G → ℝ := + fun _ => (Fintype.card G : ℝ)⁻¹ + +def binaryLaw (d : ℕ) : Equiv.Perm (Slot d) → ℝ := + finiteLaw (binarySweep d) + +abbrev RepSpace (D : ℕ) := EuclideanSpace ℂ (Fin D) + +def IsUnitaryRep {G : Type*} [Monoid G] + {D : ℕ} (ρ : Representation ℂ G (RepSpace D)) : Prop := + ∀ g x, ‖ρ g x‖ = ‖x‖ + +def averageOperator {G : Type*} [Fintype G] [Monoid G] {D : ℕ} + (p : G → ℝ) (ρ : Representation ℂ G (RepSpace D)) : + RepSpace D →L[ℂ] RepSpace D := + LinearMap.toContinuousLinearMap (∑ g, (p g : ℂ) • ρ g) + +def BinaryContractionTarget : Prop := + ∃ g : ℝ, 0 < g ∧ ∃ d₀ : ℕ, ∀ d ≥ d₀, ∀ D : ℕ, + ∀ ρ : Representation ℂ (Equiv.Perm (Slot d)) (RepSpace D), + ρ.IsIrreducible → IsUnitaryRep ρ → + ‖averageOperator (binaryLaw d) ρ‖ ≤ (D : ℝ) ^ (-g) + +def realSign {α : Type*} [Fintype α] [DecidableEq α] : Equiv.Perm α →* ℝ := + (Int.castRingHom ℝ).toMonoidHom.comp ((Units.coeHom ℤ).comp Equiv.Perm.sign) + +section FiniteLaws +variable {G : Type*} [Fintype G] [Group G] + +def convolution (p q : G → ℝ) (g : G) : ℝ := ∑ x, p x * q (x⁻¹ * g) + +def pointMassOne (g : G) : ℝ := by + classical + exact if g = 1 then 1 else 0 + +/-- The law of independent repetitions, with the empty product at the identity. -/ +def convolutionPower (p : G → ℝ) : ℕ → G → ℝ + | 0 => pointMassOne + | n + 1 => convolution p (convolutionPower p n) + +end FiniteLaws + +def sweepLaw (d t : ℕ) : Equiv.Perm (Slot d) → ℝ := + convolutionPower (binaryLaw d) t + +/-- A single number of sweeps works uniformly over deterministic initial decks. -/ +def UniformSweepMixingTarget : Prop := + ∃ w : ℕ, ∀ ε : ℝ, 0 < ε → ∃ d₀ : ℕ, ∀ d ≥ d₀, + ∀ τ : Equiv.Perm (Slot d), + totalVariation (fun g => sweepLaw d w (g * τ⁻¹)) + (uniformLaw (Equiv.Perm (Slot d))) ≤ ε + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/AssignmentWeight.lean b/lean/OAI/Probability/BinarySweep/Processes/AssignmentWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..f058ab0dd55bfb42f8e0c239e962aa93f99f192f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/AssignmentWeight.lean @@ -0,0 +1,221 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.IndependentHistory + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps +section AssignmentWeights +attribute [local instance] Classical.propDecidable +variable {X I J : Type*} [Fintype X] [Fintype I] [Fintype J] + +def assignmentWeight (p : Equiv.Perm X → ℝ) (A B : I ↪ X) : ℝ := + ∑ σ, if Assigns A B σ then p σ else 0 + +omit [Fintype I] in +lemma assignmentWeight_mono (p q : Equiv.Perm X → ℝ) + (hpq : ∀ σ, p σ ≤ q σ) (A B : I ↪ X) : + assignmentWeight p A B ≤ assignmentWeight q A B := by + apply Finset.sum_le_sum + intro σ _ + split_ifs + · exact hpq σ + · exact le_rfl + +omit [Fintype I] in +lemma assignmentWeight_nonneg {p : Equiv.Perm X → ℝ} + (hp : ∀ σ, 0 ≤ p σ) (A B : I ↪ X) : 0 ≤ assignmentWeight p A B := by + apply Finset.sum_nonneg + intro σ _ + split_ifs + · exact hp σ + · exact le_rfl + +omit [Fintype I] in +lemma assignmentWeight_smul (p : Equiv.Perm X → ℝ) (c : ℝ) (A B : I ↪ X) : + assignmentWeight (fun σ => c * p σ) A B = c * assignmentWeight p A B := by + simp only [assignmentWeight, Finset.mul_sum] + apply Finset.sum_congr rfl + intro σ _ + split_ifs <;> simp + +lemma assignmentWeight_uniform (A B : I ↪ X) : + assignmentWeight (fun _ => (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) A B = + (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ)⁻¹ := + uniform_assignment_probability A B + +lemma assignmentWeight_uniform_pos (A B : I ↪ X) : + 0 < assignmentWeight (fun _ => (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) A B := by + rw [assignmentWeight_uniform] + apply inv_pos.mpr + exact_mod_cast Nat.descFactorial_pos.mpr (Fintype.card_le_of_injective A A.injective) + +lemma assignmentWeight_comparison {p : Equiv.Perm X → ℝ} + (hl : ∀ σ, (1 / 2 : ℝ) * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹ ≤ p σ) + (hu : ∀ σ, p σ ≤ 2 * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) + (A B : I ↪ X) : + (1 / 2 : ℝ) * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ)⁻¹ ≤ + assignmentWeight p A B ∧ + assignmentWeight p A B ≤ + 2 * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ)⁻¹ := by + constructor + · simpa [assignmentWeight_smul, assignmentWeight_uniform] using + assignmentWeight_mono (fun _ => (1 / 2 : ℝ) * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) p hl A B + · simpa [assignmentWeight_smul, assignmentWeight_uniform] using + assignmentWeight_mono p (fun _ => 2 * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) hu A B + +lemma assignmentWeight_ratio_le {p : Equiv.Perm X → ℝ} + (hl : ∀ σ, (1 / 2 : ℝ) * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹ ≤ p σ) + (hu : ∀ σ, p σ ≤ 2 * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) + (A B : I ↪ X) (A' B' : J ↪ X) : + assignmentWeight p A' B' / assignmentWeight p A B ≤ + 4 * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ) / + (Nat.descFactorial (Fintype.card X) (Fintype.card J) : ℝ) := by + have hi : (0 : ℝ) < Nat.descFactorial (Fintype.card X) (Fintype.card I) := by + exact_mod_cast Nat.descFactorial_pos.mpr (Fintype.card_le_of_injective A A.injective) + have hj : (0 : ℝ) < Nat.descFactorial (Fintype.card X) (Fintype.card J) := by + exact_mod_cast Nat.descFactorial_pos.mpr (Fintype.card_le_of_injective A' A'.injective) + have hden := (assignmentWeight_comparison hl hu A B).1 + have hnum := (assignmentWeight_comparison hl hu A' B').2 + have hdp : 0 < assignmentWeight p A B := + lt_of_lt_of_le (mul_pos (by norm_num) (inv_pos.mpr hi)) hden + apply (div_le_iff₀ hdp).mpr + calc + _ ≤ 2 * (Nat.descFactorial (Fintype.card X) (Fintype.card J) : ℝ)⁻¹ := hnum + _ = (4 * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ) / + (Nat.descFactorial (Fintype.card X) (Fintype.card J) : ℝ)) * + ((1 / 2 : ℝ) * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ)⁻¹) := by + field_simp + ring + _ ≤ _ := mul_le_mul_of_nonneg_left hden (by positivity) + +end AssignmentWeights + +attribute [local instance] Classical.propDecidable + +abbrev LinePaths {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (j : Fin b) (y : GridOutside bits j) := + {k : Fin h // (fun i : {i : Fin b // i ≠ j} => H.position j.castSucc k i) = y} + +def lineInput {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (j : Fin b) (y : GridOutside bits j) : LinePaths H j y ↪ Slot (bits j) where + toFun k := H.position j.castSucc k.val j + inj' k l he := by + apply Subtype.ext + apply H.disjoint j.castSucc + funext i + by_cases hi : i = j + · subst i; exact he + · exact (congrFun k.property ⟨i, hi⟩).trans (congrFun l.property ⟨i, hi⟩).symm + +def lineOutput {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (j : Fin b) (y : GridOutside bits j) : LinePaths H j y ↪ Slot (bits j) where + toFun k := H.position j.succ k.val j + inj' k l he := by + apply Subtype.ext + apply H.disjoint j.succ + funext i + by_cases hi : i = j + · subst i; exact he + · rw [H.changes_only_stage j k.val i hi, H.changes_only_stage j l.val i hi] + exact (congrFun k.property ⟨i, hi⟩).trans (congrFun l.property ⟨i, hi⟩).symm + +lemma lineHoles_le {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (j : Fin b) (y : GridOutside bits j) : lineHoles H j y ≤ 2 ^ bits j := by + simpa [lineHoles, Slot, Fintype.card_pi] using + Fintype.card_le_of_injective (lineInput H j y) (lineInput H j y).injective + +lemma sum_lineHoles {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (j : Fin b) : ∑ y, lineHoles H j y = h := by + classical + have hh := Fintype.card_congr (Equiv.sigmaFiberEquiv + (fun k : Fin h => (fun i : {i : Fin b // i ≠ j} => H.position j.castSucc k i))) + simpa only [Fintype.card_sigma, Fintype.card_fin, lineHoles] using hh + +lemma pathCost_nonneg {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + 0 ≤ pathCost H := by + apply Finset.sum_nonneg + intro j _ + apply Finset.sum_nonneg + intro y _ + exact fallingCost_nonneg (by positivity) (lineHoles_le H j y) + +lemma pathCost_le {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + pathCost H ≤ (b : ℝ) * h := by + calc + pathCost H ≤ ∑ j : Fin b, ∑ y, (lineHoles H j y : ℝ) := by + apply Finset.sum_le_sum + intro j _ + apply Finset.sum_le_sum + intro y _ + exact fallingCost_le (by positivity) (lineHoles_le H j y) + _ = _ := by simp only [← Nat.cast_sum, sum_lineHoles]; simp + +lemma pathEvent_iff_assigns {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (g : GridChoices bits) : pathEvent H g ↔ + ∀ (j : Fin b) (y : GridOutside bits j), Assigns (lineInput H j y) (lineOutput H j y) (g j y) := by + constructor + · intro hg j y k + change g j y (H.position j.castSucc k.val j) = H.position j.succ k.val j + have he := congrArg (fun x : GridSlot bits => x j) (hg j k.val) + simpa only [gridLayer, Equiv.trans_apply, Equiv.piSplitAt_apply, + Equiv.prodCongrLeft_apply, Equiv.piSplitAt_symm_apply, dite_true, eq_self, + lineInput, lineOutput, Function.Embedding.coeFn_mk, k.property] using he + · intro hg j k + apply (Equiv.piSplitAt j (fun i => Slot (bits i))).injective + simp only [gridLayer, Equiv.trans_apply, Equiv.apply_symm_apply, + Equiv.piSplitAt_apply, Equiv.prodCongrLeft_apply] + apply Prod.ext + · exact hg j _ ⟨k, rfl⟩ + · funext i + exact (H.changes_only_stage j k i.val i.property).symm + +lemma finiteLaw_le_one {Ω G : Type*} [Fintype Ω] [Fintype G] [Nonempty Ω] + (f : Ω → G) (g : G) : finiteLaw f g ≤ 1 := by + calc + _ ≤ ∑ x, finiteLaw f x := Finset.single_le_sum (fun x _ => finiteLaw_nonneg f x) (Finset.mem_univ _) + _ = 1 := finiteLaw_sum f + +def linePerturbationRadius (r : ℕ) : ℝ := 1 / (2 * ((2 ^ (2 * r)).factorial : ℝ)) + +lemma linePerturbationRadius_pos (r : ℕ) : 0 < linePerturbationRadius r := by + unfold linePerturbationRadius + positivity + +lemma lineLaw_comparison (r d : ℕ) (hd : d ≤ 2 * r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) (g : Equiv.Perm (Slot d)) : + (1 / 2 : ℝ) * uniformLaw (Equiv.Perm (Slot d)) g ≤ lineLaw d z g ∧ + lineLaw d z g ≤ 2 * uniformLaw (Equiv.Perm (Slot d)) g := by + have hf1 : (1 : ℝ) ≤ ((2 ^ (2 * r)).factorial : ℝ) := by + exact_mod_cast Nat.factorial_pos (2 ^ (2 * r)) + have hzp : z ≤ 1 / 2 := hzr.trans (by + unfold linePerturbationRadius + apply one_div_le_one_div_of_le (by norm_num) + linarith) + have hfd : (Fintype.card (Equiv.Perm (Slot d)) : ℝ) ≤ ((2 ^ (2 * r)).factorial : ℝ) := by + exact_mod_cast (show Fintype.card (Equiv.Perm (Slot d)) ≤ (2 ^ (2 * r)).factorial from by + simp only [Fintype.card_perm, Slot, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] + exact Nat.factorial_le (Nat.pow_le_pow_right (by norm_num) hd)) + have hup : 0 < uniformLaw (Equiv.Perm (Slot d)) g := by + unfold uniformLaw + have hp : (0 : ℝ) < Fintype.card (Equiv.Perm (Slot d)) := by exact_mod_cast Fintype.card_pos + positivity + have hzU : z ≤ uniformLaw (Equiv.Perm (Slot d)) g := hzr.trans (by + unfold linePerturbationRadius uniformLaw + rw [one_div] + apply inv_anti₀ (by exact_mod_cast Fintype.card_pos) + linarith) + have hB0 : 0 ≤ binaryLaw d g := finiteLaw_nonneg _ _ + have hB1 : binaryLaw d g ≤ 1 := finiteLaw_le_one _ _ + constructor + · unfold lineLaw + nlinarith + · unfold lineLaw + nlinarith [mul_le_mul_of_nonneg_left hB1 hz] + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/Basic.lean b/lean/OAI/Probability/BinarySweep/Processes/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..137a17d254b709b418c5d63f977d7776628600eb --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/Basic.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Probability.BinarySweep.Model + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +abbrev Coins (d : ℕ) := Slot d → Bool + +def physical (d : ℕ) (c : Coins d) : Equiv.Perm (Slot (d + 1)) where + toFun x := Fin.snoc (Fin.tail x) (x 0 ^^ c (Fin.tail x)) + invFun y := Fin.cons (y (Fin.last d) ^^ c (Fin.init y)) (Fin.init y) + left_inv x := by + simp + right_inv y := by + simp + +def physicalHistory (d t : ℕ) (c : Fin t → Coins d) : Equiv.Perm (Slot (d + 1)) := + (List.ofFn (fun i => physical d (c i))).reverse.prod + +def physicalLaw (d t : ℕ) : Equiv.Perm (Slot (d + 1)) → ℝ := + finiteLaw (physicalHistory d t) + +def c0 : ℝ := (1 / 100 : ℝ) / 100 +def e0 : ℝ := (1 / 100 : ℝ) / 100 +def cExponent (s : ℕ) : ℝ := c0 + 1 / Real.sqrt (Real.log s) +def eExponent (s : ℕ) : ℝ := e0 - 1 / Real.sqrt (Real.log s) + +def traceMoment {D : ℕ} (q : ℕ) (K : RepSpace D →L[ℂ] RepSpace D) : ℝ := + (LinearMap.trace ℂ (RepSpace D) + (((ContinuousLinearMap.adjoint K) * K) ^ q).toLinearMap).re + +def logMoment (T : ℝ) : EReal := (ENNReal.ofReal T).log + +section FiniteProbability +variable {Ω G : Type*} [Fintype Ω] [Fintype G] + +lemma finiteLaw_nonneg (f : Ω → G) (g : G) : 0 ≤ finiteLaw f g := by + classical + exact Finset.sum_nonneg (fun _ _ => by split_ifs <;> positivity) + +lemma finiteLaw_sum [Nonempty Ω] (f : Ω → G) : ∑ g, finiteLaw f g = 1 := by + classical + simp only [finiteLaw] + rw [Finset.sum_comm] + simp [Fintype.card_ne_zero] + +lemma uniformLaw_sum [Nonempty G] : ∑ g, uniformLaw G g = 1 := by + simp [uniformLaw, Fintype.card_ne_zero] + +lemma finiteLaw_eq_zero_outside (f : Ω → G) (s : Finset G) + (hs : ∀ ω, f ω ∈ s) {g : G} (hg : g ∉ s) : finiteLaw f g = 0 := by + classical + apply Finset.sum_eq_zero + intro ω _ + rw [ite_eq_right] + intro he + exact hg (he ▸ hs ω) + +lemma event_le_totalVariation (p q : G → ℝ) (heq : ∑ g, p g = ∑ g, q g) + (s : Finset G) : ∑ g ∈ s, (p g - q g) ≤ totalVariation p q := by + classical + have hzero : ∑ g, (p g - q g) = 0 := by + rw [Finset.sum_sub_distrib, heq, sub_self] + have hsplit := Finset.sum_add_sum_compl s (fun g => p g - q g) + rw [hzero] at hsplit + have hspabs := Finset.sum_add_sum_compl s (fun g => |p g - q g|) + have h₁ : ∑ g ∈ s, (p g - q g) ≤ ∑ g ∈ s, |p g - q g| := + Finset.sum_le_sum (fun _ _ => le_abs_self _) + have h₂ : -(∑ g ∈ sᶜ, (p g - q g)) ≤ ∑ g ∈ sᶜ, |p g - q g| := by + rw [← Finset.sum_neg_distrib] + exact Finset.sum_le_sum (fun _ _ => neg_le_abs _) + unfold totalVariation + linarith + +theorem uniform_image_support_obstruction [Nonempty Ω] [Nonempty G] (f : Ω → G) : + 1 - (Fintype.card Ω : ℝ) / Fintype.card G ≤ + totalVariation (finiteLaw f) (uniformLaw G) := by + classical + let s : Finset G := Finset.univ.image f + have hs (ω : Ω) : f ω ∈ s := Finset.mem_image.mpr ⟨ω, Finset.mem_univ _, rfl⟩ + have hsum : ∑ g ∈ s, finiteLaw f g = 1 := by + have hout : ∑ g ∈ sᶜ, finiteLaw f g = 0 := by + apply Finset.sum_eq_zero + intro g hg + exact finiteLaw_eq_zero_outside f s hs (Finset.mem_compl.mp hg) + have h := Finset.sum_add_sum_compl s (finiteLaw f) + rw [hout, add_zero, finiteLaw_sum] at h + exact h + have he : ∑ g ∈ s, (finiteLaw f g - uniformLaw G g) = + 1 - (s.card : ℝ) / Fintype.card G := by + rw [Finset.sum_sub_distrib, hsum] + simp [uniformLaw, div_eq_mul_inv] + have ht := event_le_totalVariation (finiteLaw f) (uniformLaw G) + (by rw [finiteLaw_sum, uniformLaw_sum]) s + rw [he] at ht + have hcard : (s.card : ℝ) ≤ Fintype.card Ω := by + exact_mod_cast (Finset.card_image_le : s.card ≤ Finset.univ.card) + have hden : (0 : ℝ) < Fintype.card G := by exact_mod_cast Fintype.card_pos + calc + 1 - (Fintype.card Ω : ℝ) / Fintype.card G ≤ + 1 - (s.card : ℝ) / Fintype.card G := + sub_le_sub_left (div_le_div_of_nonneg_right hcard hden.le) 1 + _ ≤ _ := ht + +end FiniteProbability + +theorem physical_support_obstruction (d t : ℕ) : + 1 - (2 : ℝ) ^ (t * 2 ^ d) / (Nat.factorial (2 ^ (d + 1)) : ℝ) ≤ + totalVariation (physicalLaw d t) (uniformLaw (Equiv.Perm (Slot (d + 1)))) := by + have h := uniform_image_support_obstruction (physicalHistory d t) + simpa [physicalLaw, Coins, Slot, Fintype.card_fun, Fintype.card_perm, + Nat.cast_pow, ← pow_mul, mul_comm] using h + +def supportTimeBound (d : ℕ) : ℝ := + (2 / (2 : ℝ) ^ (d + 1)) * + Real.logb 2 (3 * (Nat.factorial (2 ^ (d + 1)) : ℝ) / 4) + +theorem physical_threshold_time (d t : ℕ) + (ht : totalVariation (physicalLaw d t) + (uniformLaw (Equiv.Perm (Slot (d + 1)))) ≤ 1 / 4) : + ⌈supportTimeBound d⌉ ≤ (t : ℤ) := by + apply Int.ceil_le.mpr + have h := (physical_support_obstruction d t).trans ht + have hfact : (0 : ℝ) < Nat.factorial (2 ^ (d + 1)) := by positivity + have hpow : (0 : ℝ) < (2 : ℝ) ^ d := by positivity + have hlog : (0 : ℝ) < Real.log 2 := Real.log_pos (by norm_num) + have hb : 3 * (Nat.factorial (2 ^ (d + 1)) : ℝ) / 4 ≤ + (2 : ℝ) ^ (t * 2 ^ d) := by + have : (3 / 4 : ℝ) ≤ + (2 : ℝ) ^ (t * 2 ^ d) / (Nat.factorial (2 ^ (d + 1)) : ℝ) := by linarith + have := (le_div_iff₀ hfact).mp this + linarith + have hl := Real.log_le_log (by positivity) hb + rw [Real.log_pow, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] at hl + have hdiv : Real.log (3 * (Nat.factorial (2 ^ (d + 1)) : ℝ) / 4) / + Real.log 2 ≤ (t : ℝ) * (2 : ℝ) ^ d := (div_le_iff₀ hlog).mpr hl + rw [Int.cast_natCast] + change (2 / (2 : ℝ) ^ (d + 1)) * + (Real.log (3 * (Nat.factorial (2 ^ (d + 1)) : ℝ) / 4) / Real.log 2) ≤ (t : ℝ) + rw [pow_succ] + have hmul := mul_le_mul_of_nonneg_left hdiv (show 0 ≤ 2 / ((2 : ℝ)^d * 2) by positivity) + calc + _ ≤ (2 / ((2 : ℝ)^d * 2)) * ((t : ℝ) * (2 : ℝ)^d) := hmul + _ = (t : ℝ) := by field_simp + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/CoordinateLayerEdgeSwap.lean b/lean/OAI/Probability/BinarySweep/Processes/CoordinateLayerEdgeSwap.lean new file mode 100644 index 0000000000000000000000000000000000000000..021b0c2743b6842430e5ae0f22cbf9a87a4d4db8 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/CoordinateLayerEdgeSwap.lean @@ -0,0 +1,208 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.SupportTimeBoundBounds + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +lemma coordinateLayer_edgeSwap (d : ℕ) (j : Fin d) (x : Slot d) : + coordinateLayer d j (fun y => decide (y = fun i : {i : Fin d // i ≠ j} => x i)) = + Equiv.swap x (Function.update x j (!x j)) := by + classical + let e := Equiv.piSplitAt j (fun _ : Fin d => Bool) + let z : {i : Fin d // i ≠ j} → Bool := fun i => x i + change (e.trans (Equiv.prodCongrLeft (fun y => boolSwitch (decide (y = z))))).trans e.symm = _ + rw [fiber_boolSwitch_eq_swap z (x j), Equiv.trans_swap_trans_symm] + have hx : e.symm (x j, z) = x := by + exact e.symm_apply_apply x + have hy : e.symm (!x j, z) = Function.update x j (!x j) := by + ext i + by_cases h : i = j + · subst i; simp [e, Equiv.piSplitAt_symm_apply] + · simp [e, z, Equiv.piSplitAt_symm_apply, h] + rw [hx, hy] + +lemma swap_update_mem_reachable (d : ℕ) (j : Fin d) (x : Slot d) (b : Bool) : + Equiv.swap x (Function.update x j b) ∈ sweepReachable d := by + classical + by_cases h : b = x j + · subst b + simp only [Function.update_eq_self, Equiv.swap_self] + exact (sweepReachable d).one_mem + · have hb : b = !x j := by cases b <;> cases hx : x j <;> simp_all + rw [hb, ← coordinateLayer_edgeSwap] + exact coordinateLayer_mem_reachable d j _ + +lemma swap_mem_sweepReachable (d : ℕ) (x y : Slot d) : + Equiv.swap x y ∈ sweepReachable d := by + classical + have h (s : Finset (Fin d)) : + Equiv.swap x (fun i => if i ∈ s then y i else x i) ∈ sweepReachable d := by + induction s using Finset.induction_on with + | empty => + simp only [Finset.notMem_empty, ite_false, Equiv.swap_self] + exact (sweepReachable d).one_mem + | @insert j s hj ih => + have he : (fun i => if i ∈ insert j s then y i else x i) = + Function.update (fun i => if i ∈ s then y i else x i) j (y j) := by + ext i + by_cases hi : i = j + · subst i; simp + · simp [hi] + rw [he] + exact SubmonoidClass.swap_mem_trans (sweepReachable d) ih + (swap_update_mem_reachable d j _ _) + simpa using h Finset.univ + +theorem every_permutation_sweepReachable (d : ℕ) (g : Equiv.Perm (Slot d)) : + g ∈ sweepReachable d := by + classical + induction g using Equiv.Perm.swap_induction_on with + | one => exact (sweepReachable d).one_mem + | swap_mul g x y h ih => + exact (sweepReachable d).mul_mem (swap_mem_sweepReachable d x y) ih + +section FiniteRandomWalk +variable {G : Type*} [Fintype G] [Group G] + +def IsProbability (p : G → ℝ) : Prop := (∀ g, 0 ≤ p g) ∧ ∑ g, p g = 1 + +lemma sum_mulLeft (a : G) (f : G → ℝ) : ∑ g, f (a * g) = ∑ g, f g := + Equiv.sum_comp (Equiv.mulLeft a) f + +lemma sum_inv_mulRight (a : G) (f : G → ℝ) : ∑ g, f (g⁻¹ * a) = ∑ g, f g := + ((Equiv.inv G).trans (Equiv.mulRight a)).sum_comp f + +lemma convolution_sum (p q : G → ℝ) : + ∑ g, convolution p q g = (∑ g, p g) * (∑ g, q g) := by + simp only [convolution] + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, sum_mulLeft] + rw [Finset.sum_mul] + +lemma convolution_nonneg {p q : G → ℝ} (hp : ∀ g, 0 ≤ p g) (hq : ∀ g, 0 ≤ q g) : + ∀ g, 0 ≤ convolution p q g := fun _ => + Finset.sum_nonneg (fun x _ => mul_nonneg (hp x) (hq _)) + +lemma convolution_probability {p q : G → ℝ} (hp : IsProbability p) (hq : IsProbability q) : + IsProbability (convolution p q) := by + exact ⟨convolution_nonneg hp.1 hq.1, by rw [convolution_sum, hp.2, hq.2, one_mul]⟩ + +lemma convolution_uniform_right {p : G → ℝ} (hp : ∑ g, p g = 1) : + convolution p (uniformLaw G) = uniformLaw G := by + funext g + simp [convolution, uniformLaw, ← Finset.sum_mul, hp] + +lemma convolution_uniform_left {p : G → ℝ} (hp : ∑ g, p g = 1) : + convolution (uniformLaw G) p = uniformLaw G := by + funext g + simp [convolution, uniformLaw, ← Finset.mul_sum, sum_inv_mulRight, hp] + +lemma convolution_assoc (p q r : G → ℝ) : + convolution (convolution p q) r = convolution p (convolution q r) := by + funext g + simp only [convolution, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + rw [← sum_mulLeft x (fun y => p x * q (x⁻¹ * y) * r (y⁻¹ * g))] + simp [mul_assoc] + +omit [Group G] in +lemma totalVariation_nonneg (p q : G → ℝ) : 0 ≤ totalVariation p q := + mul_nonneg (by norm_num) (Finset.sum_nonneg (fun _ _ => abs_nonneg _)) + +omit [Group G] in +lemma totalVariation_le_one {p q : G → ℝ} (hp : IsProbability p) (hq : IsProbability q) : + totalVariation p q ≤ 1 := by + have h : ∑ g, |p g - q g| ≤ 2 := by + calc + _ ≤ ∑ g, (p g + q g) := Finset.sum_le_sum (fun g _ => + (abs_sub (p g) (q g)).trans_eq (by rw [abs_of_nonneg (hp.1 g), abs_of_nonneg (hq.1 g)])) + _ = 2 := by rw [Finset.sum_add_distrib, hp.2, hq.2]; norm_num + unfold totalVariation + linarith + +lemma convolution_tv_contract {p : G → ℝ} (hp : ∀ g, 0 ≤ p g) (q r : G → ℝ) : + totalVariation (convolution p q) (convolution p r) ≤ + (∑ g, p g) * totalVariation q r := by + have h : ∑ g, |convolution p q g - convolution p r g| ≤ + (∑ g, p g) * ∑ g, |q g - r g| := by + calc + _ = ∑ g, |∑ x, p x * (q (x⁻¹ * g) - r (x⁻¹ * g))| := by + simp_rw [convolution, ← Finset.sum_sub_distrib, ← mul_sub] + _ ≤ ∑ g, ∑ x, p x * |q (x⁻¹ * g) - r (x⁻¹ * g)| := by + apply Finset.sum_le_sum + intro g _ + simpa only [abs_mul, abs_of_nonneg (hp _)] using + (Finset.abs_sum_le_sum_abs (s := Finset.univ) + (f := fun x => p x * (q (x⁻¹ * g) - r (x⁻¹ * g)))) + _ = _ := by + rw [Finset.sum_comm] + have hs (x : G) : ∑ g, |q (x⁻¹ * g) - r (x⁻¹ * g)| = ∑ g, |q g - r g| := + sum_mulLeft x⁻¹ (fun g => |q g - r g|) + simp_rw [← Finset.mul_sum, hs] + rw [Finset.sum_mul] + unfold totalVariation + nlinarith + +end FiniteRandomWalk + +abbrev GridSlot {b : ℕ} (bits : Fin b → ℕ) := (j : Fin b) → Slot (bits j) +abbrev GridOutside {b : ℕ} (bits : Fin b → ℕ) (j : Fin b) := + (i : {i : Fin b // i ≠ j}) → Slot (bits i) +abbrev GridChoices {b : ℕ} (bits : Fin b → ℕ) := + (j : Fin b) → GridOutside bits j → Equiv.Perm (Slot (bits j)) + +def gridSize {b : ℕ} (bits : Fin b → ℕ) := ∏ j, 2 ^ bits j + +lemma card_gridSlot {b : ℕ} (bits : Fin b → ℕ) : + Fintype.card (GridSlot bits) = gridSize bits := by + simp [GridSlot, Slot, gridSize, Fintype.card_pi] + +def gridLayer {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) (j : Fin b) : + Equiv.Perm (GridSlot bits) := + let e := Equiv.piSplitAt j (fun i => Slot (bits i)) + e.trans ((Equiv.prodCongrLeft (g j)).trans e.symm) + +def gridSweep {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) : + Equiv.Perm (GridSlot bits) := (List.ofFn (gridLayer bits g)).reverse.prod + +def lineLaw (d : ℕ) (z : ℝ) (g : Equiv.Perm (Slot d)) : ℝ := + (1 - z) * uniformLaw (Equiv.Perm (Slot d)) g + z * binaryLaw d g + +def gridWeight {b : ℕ} (bits : Fin b → ℕ) (z : ℝ) (g : GridChoices bits) : ℝ := + ∏ j, ∏ y, lineLaw (bits j) z (g j y) + +structure PathFamily {b : ℕ} (bits : Fin b → ℕ) (h : ℕ) where + position : Fin (b + 1) → Fin h → GridSlot bits + disjoint : ∀ t, Function.Injective (position t) + changes_only_stage : ∀ (j : Fin b) (k : Fin h) (i : Fin b), i ≠ j → + position j.succ k i = position j.castSucc k i + +def pathEvent {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (g : GridChoices bits) : Prop := + ∀ (j : Fin b) (k : Fin h), + gridLayer bits g j (H.position j.castSucc k) = H.position j.succ k + +lemma chronological_trajectory {α : Type*} (b : ℕ) (f : Fin b → Equiv.Perm α) + (x : Fin (b + 1) → α) (h : ∀ j, f j (x j.castSucc) = x j.succ) : + (List.ofFn f).reverse.prod (x 0) = x (Fin.last b) := by + induction b with + | zero => simp + | succ b ih => + simp only [List.ofFn_succ, List.reverse_cons, List.prod_append, List.prod_singleton, + Equiv.Perm.mul_apply] + have h0 : f 0 (x 0) = x (Fin.succ 0) := by simpa using h 0 + rw [h0] + have ht (j : Fin b) : f j.succ (x j.castSucc.succ) = x j.succ.succ := by + simpa only [Fin.succ_castSucc] using h j.succ + exact ih (fun j => f j.succ) (fun i => x i.succ) ht + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/GridSweepPath.lean b/lean/OAI/Probability/BinarySweep/Processes/GridSweepPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..224ec93ce42911fc2fa96ebf23adf44682388409 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/GridSweepPath.lean @@ -0,0 +1,215 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.CoordinateLayerEdgeSwap + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +lemma gridSweep_path {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (g : GridChoices bits) (hg : pathEvent H g) (k : Fin h) : + gridSweep bits g (H.position 0 k) = H.position (Fin.last b) k := + chronological_trajectory b (gridLayer bits g) (fun t => H.position t k) (fun j => hg j k) + +abbrev FreeSlot {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (t : Fin (b + 1)) := {x : GridSlot bits // x ∉ Set.range (H.position t)} + +instance freeSlotFintype {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (t : Fin (b + 1)) : Fintype (FreeSlot H t) := Fintype.ofFinite _ + +lemma card_freeSlot {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (t : Fin (b + 1)) : Fintype.card (FreeSlot H t) = gridSize bits - h := by + classical + rw [show Fintype.card (FreeSlot H t) = + Fintype.card (GridSlot bits) - Fintype.card (Set.range (H.position t)) from + Fintype.card_subtype_compl (fun x => x ∈ Set.range (H.position t))] + rw [card_gridSlot] + have hr : Fintype.card (Set.range (H.position t)) = h := by + let e : Fin h ↪ GridSlot bits := ⟨H.position t, H.disjoint t⟩ + simpa [e] using Fintype.card_range e + rw [hr] + +def freeIdentification {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + FreeSlot H 0 ≃ FreeSlot H (Fin.last b) := + Fintype.equivOfCardEq (by rw [card_freeSlot, card_freeSlot]) + +def remainingBijection {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (g : GridChoices bits) (hg : pathEvent H g) : + FreeSlot H 0 ≃ FreeSlot H (Fin.last b) where + toFun x := ⟨gridSweep bits g x, by + rintro ⟨k, hk⟩ + exact x.property ⟨k, (gridSweep bits g).injective ((gridSweep_path H g hg k).trans hk)⟩⟩ + invFun y := ⟨(gridSweep bits g).symm y, by + rintro ⟨k, hk⟩ + apply y.property + refine ⟨k, ?_⟩ + rw [← gridSweep_path H g hg k, hk] + exact (gridSweep bits g).apply_symm_apply y⟩ + left_inv x := by apply Subtype.ext; exact (gridSweep bits g).symm_apply_apply x + right_inv y := by apply Subtype.ext; exact (gridSweep bits g).apply_symm_apply y + +def remainingPerm {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (g : GridChoices bits) (hg : pathEvent H g) : Equiv.Perm (FreeSlot H 0) := + (remainingBijection H g hg).trans (freeIdentification H).symm + +def conditionalNormalizer {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) : ℝ := by + classical + exact ∑ g : GridChoices bits, if pathEvent H g then gridWeight bits z g else 0 + +def conditionalOperator {b h D : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D)) : + RepSpace D →L[ℂ] RepSpace D := by + classical + exact LinearMap.toContinuousLinearMap + ((conditionalNormalizer H z : ℂ)⁻¹ • ∑ g : GridChoices bits, + if hg : pathEvent H g then (gridWeight bits z g : ℂ) • ρ (remainingPerm H g hg) + else 0) + +def lineHoles {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (j : Fin b) (y : GridOutside bits j) : ℕ := by + classical + exact Fintype.card {k : Fin h // (fun i : {i : Fin b // i ≠ j} => + H.position j.castSucc k i) = y} + +def pathCost {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : ℝ := + ∑ j, ∑ y : GridOutside bits j, + Real.log (((2 ^ bits j : ℕ) : ℝ) ^ lineHoles H j y / + (Nat.descFactorial (2 ^ bits j) (lineHoles H j y) : ℝ)) + +def ConditionalMomentTarget : Prop := + ∃ r : ℕ, 0 < r ∧ ∃ q : ℕ, 0 < q ∧ ∃ zStar : ℝ, 0 < zStar ∧ + ∀ b : ℕ, 1 ≤ b → ∀ bits : Fin b → ℕ, (∀ j, r ≤ bits j ∧ bits j ≤ 2 * r) → + ∀ h : ℕ, ∀ H : PathFamily bits h, ∀ z : ℝ, 0 ≤ z → z ≤ zStar → + ∀ D : ℕ, ∀ ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (RepSpace D), + ρ.IsIrreducible → IsUnitaryRep ρ → + logMoment (traceMoment q (conditionalOperator H z ρ)) ≤ + ((-cExponent (gridSize bits) * Real.log D + + eExponent (gridSize bits) * h * Real.log (gridSize bits) - pathCost H : ℝ) : EReal) + +theorem pathEvent_nonempty {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + ∃ g : GridChoices bits, pathEvent H g := by + classical + let A (j : Fin b) (y : GridOutside bits j) := + {k : Fin h // (fun i : {i : Fin b // i ≠ j} => H.position j.castSucc k i) = y} + have hp (j : Fin b) (y : GridOutside bits j) : + ∃ σ : Equiv.Perm (Slot (bits j)), ∀ k : A j y, + σ (H.position j.castSucc k.val j) = H.position j.succ k.val j := by + apply Equiv.Perm.exists_extending_pair + · intro k l he + apply Subtype.ext + apply H.disjoint j.castSucc + funext i + by_cases hi : i = j + · subst i; exact he + · exact (congrFun k.property ⟨i, hi⟩).trans (congrFun l.property ⟨i, hi⟩).symm + · intro k l he + apply Subtype.ext + apply H.disjoint j.succ + funext i + by_cases hi : i = j + · subst i; exact he + · rw [H.changes_only_stage j k.val i hi, H.changes_only_stage j l.val i hi] + exact (congrFun k.property ⟨i, hi⟩).trans (congrFun l.property ⟨i, hi⟩).symm + choose g hg using hp + refine ⟨g, ?_⟩ + intro j k + apply (Equiv.piSplitAt j (fun i => Slot (bits i))).injective + simp only [gridLayer, Equiv.trans_apply, Equiv.apply_symm_apply, + Equiv.piSplitAt_apply, Equiv.prodCongrLeft_apply] + apply Prod.ext + · exact hg j _ ⟨k, rfl⟩ + · funext i + exact (H.changes_only_stage j k i.val i.property).symm + +lemma lineLaw_pos (d : ℕ) {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) + (g : Equiv.Perm (Slot d)) : 0 < lineLaw d z g := by + have hu : 0 < uniformLaw (Equiv.Perm (Slot d)) g := by + unfold uniformLaw + have hc : (0 : ℝ) < Fintype.card (Equiv.Perm (Slot d)) := by exact_mod_cast Fintype.card_pos + exact inv_pos.mpr hc + exact add_pos_of_pos_of_nonneg (mul_pos (sub_pos.mpr hz1) hu) + (mul_nonneg hz (finiteLaw_nonneg (binarySweep d) g)) + +lemma lineLaw_sum (d : ℕ) (z : ℝ) : ∑ g, lineLaw d z g = 1 := by + simp only [lineLaw, Finset.sum_add_distrib, ← Finset.mul_sum, + uniformLaw_sum, binaryLaw, finiteLaw_sum] + ring + +lemma gridWeight_pos {b : ℕ} (bits : Fin b → ℕ) {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) + (g : GridChoices bits) : 0 < gridWeight bits z g := by + apply Finset.prod_pos + intro j _ + exact Finset.prod_pos (fun y _ => lineLaw_pos (bits j) hz hz1 (g j y)) + +lemma gridWeight_sum {b : ℕ} (bits : Fin b → ℕ) (z : ℝ) : + ∑ g : GridChoices bits, gridWeight bits z g = 1 := by + classical + unfold gridWeight + rw [← Fintype.prod_sum (fun (j : Fin b) + (g : GridOutside bits j → Equiv.Perm (Slot (bits j))) => ∏ y, lineLaw (bits j) z (g y))] + have hj (j : Fin b) : ∑ g : GridOutside bits j → Equiv.Perm (Slot (bits j)), + ∏ y, lineLaw (bits j) z (g y) = 1 := by + rw [← Fintype.prod_sum (fun (_ : GridOutside bits j) + (g : Equiv.Perm (Slot (bits j))) => lineLaw (bits j) z g)] + simp [lineLaw_sum] + simp [hj] + +theorem conditionalNormalizer_pos {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {z : ℝ} (hz : 0 ≤ z) (hz1 : z < 1) : 0 < conditionalNormalizer H z := by + classical + obtain ⟨g, hg⟩ := pathEvent_nonempty H + apply Finset.sum_pos' + · intro g' _ + split_ifs + · exact (gridWeight_pos bits hz hz1 g').le + · exact le_rfl + · exact ⟨g, Finset.mem_univ _, by simpa [hg] using gridWeight_pos bits hz hz1 g⟩ + +variable {G : Type*} [Fintype G] [Group G] + +lemma uniformLaw_probability : IsProbability (uniformLaw G) := + ⟨fun _ => by unfold uniformLaw; positivity, uniformLaw_sum⟩ + +lemma convolution_sub_left (p q r : G → ℝ) : + convolution (fun g => p g - q g) r = fun g => convolution p r g - convolution q r g := by + funext g + simp [convolution, sub_mul, Finset.sum_sub_distrib] + +lemma convolution_smul_left (a : ℝ) (p q : G → ℝ) : + convolution (fun g => a * p g) q = fun g => a * convolution p q g := by + funext g + simp [convolution, mul_assoc, Finset.mul_sum] + +lemma convolution_uniform_right_mass (p : G → ℝ) : + convolution p (uniformLaw G) = fun g => (∑ x, p x) * uniformLaw G g := by + funext g + simp [convolution, uniformLaw, Finset.sum_mul] + +lemma convolution_minorization {p q : G → ℝ} (hp : IsProbability p) (hq : IsProbability q) + (δ : ℝ) (hδ : ∀ g, δ * uniformLaw G g ≤ p g) : + totalVariation (convolution p q) (uniformLaw G) ≤ + (1 - δ) * totalVariation q (uniformLaw G) := by + let r : G → ℝ := fun g => p g - δ * uniformLaw G g + have hr : ∀ g, 0 ≤ r g := fun g => sub_nonneg.mpr (hδ g) + have hmass : ∑ g, r g = 1 - δ := by + simp [r, Finset.sum_sub_distrib, ← Finset.mul_sum, hp.2, uniformLaw_sum] + have he : totalVariation (convolution p q) (uniformLaw G) = + totalVariation (convolution r q) (convolution r (uniformLaw G)) := by + have hdiff (g : G) : convolution r q g - convolution r (uniformLaw G) g = + convolution p q g - uniformLaw G g := by + rw [show r = (fun g => p g - δ * uniformLaw G g) from rfl, + convolution_sub_left, convolution_smul_left, convolution_uniform_left hq.2] + rw [← show r = (fun g => p g - δ * uniformLaw G g) from rfl, + convolution_uniform_right_mass, hmass] + ring + simp only [totalVariation, hdiff] + rw [he] + simpa only [hmass] using convolution_tv_contract hr q (uniformLaw G) + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/IndependentHistory.lean b/lean/OAI/Probability/BinarySweep/Processes/IndependentHistory.lean new file mode 100644 index 0000000000000000000000000000000000000000..e12d9150b93f32de5b6c6700e6ec755f5e81b36d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/IndependentHistory.lean @@ -0,0 +1,203 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.PointMassOne + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps +section IndependentLaw +variable {G Ω Ξ : Type*} [Fintype G] [Group G] [Fintype Ω] [Fintype Ξ] + +def independentHistory (f : Ω → G) (n : ℕ) (c : Fin n → Ω) : G := + (List.ofFn (fun i => f (c i))).reverse.prod + +omit [Fintype G] [Fintype Ω] in +lemma independentHistory_succ (f : Ω → G) (n : ℕ) (a : Ω) (c : Fin n → Ω) : + independentHistory f (n + 1) (Fin.snoc c a) = f a * independentHistory f n c := by + unfold independentHistory + rw [List.ofFn_succ'] + simp + +lemma finiteLaw_independentHistory [Nonempty Ω] (f : Ω → G) (n : ℕ) : + finiteLaw (independentHistory f n) = convolutionPower (finiteLaw f) n := by + induction n with + | zero => + classical + funext g + simp [finiteLaw, independentHistory, convolutionPower, pointMassOne, eq_comm] + | succ n ih => + let e : Ω × (Fin n → Ω) ≃ (Fin (n + 1) → Ω) := Fin.snocEquiv (fun _ => Ω) + rw [← finiteLaw_reindex e] + have he : (independentHistory f (n + 1)) ∘ e = + fun a : Ω × (Fin n → Ω) => f a.1 * independentHistory f n a.2 := by + funext a + exact independentHistory_succ f n a.1 a.2 + rw [he, finiteLaw_independent_mul, ih] + rfl + +end IndependentLaw + +section Assignments +attribute [local instance] Classical.propDecidable +variable {X I : Type*} [Fintype X] [Fintype I] + +def Assigns (A B : I ↪ X) (σ : Equiv.Perm X) : Prop := ∀ i, σ (A i) = B i + +lemma card_assignment_completions (A B : I ↪ X) : + Fintype.card {σ : Equiv.Perm X // Assigns A B σ} = + (Fintype.card X - Fintype.card I).factorial := by + classical + let eA := Equiv.ofInjective A A.injective + let eB := Equiv.ofInjective B B.injective + let e₀ : Set.range A ≃ Set.range B := eA.symm.trans eB + have ha : Fintype.card (Set.range A) = Fintype.card I := Fintype.card_congr eA.symm + have hb : Fintype.card (Set.range B) = Fintype.card I := Fintype.card_congr eB.symm + let e : {σ : Equiv.Perm X // Assigns A B σ} ≃ + {σ : X ≃ X // ∀ x : Set.range A, σ x = e₀ x} := + Equiv.subtypeEquiv (Equiv.refl _) (by + intro σ + constructor + · intro h x + obtain ⟨i, hi⟩ := x.property + have hx : x = eA i := Subtype.ext hi.symm + rw [hx] + simpa [e₀, eA, eB] using h i + · intro h i + simpa [e₀, eA, eB] using h (eA i)) + let c : ↥((Set.range A)ᶜ) ≃ ↥((Set.range B)ᶜ) := Fintype.equivOfCardEq (by + change Fintype.card {x : X // x ∉ Set.range A} = Fintype.card {x : X // x ∉ Set.range B} + rw [Fintype.card_subtype_compl, Fintype.card_subtype_compl, ha, hb]) + rw [Fintype.card_congr (e.trans (Equiv.Set.compl e₀)), Fintype.card_equiv c] + change (Fintype.card {x : X // x ∉ Set.range A}).factorial = _ + rw [Fintype.card_subtype_compl, ha] + +lemma uniform_assignment_probability (A B : I ↪ X) : + (∑ σ : Equiv.Perm X, if Assigns A B σ then + (Fintype.card (Equiv.Perm X) : ℝ)⁻¹ else 0) = + (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ)⁻¹ := by + classical + have hn : Fintype.card I ≤ Fintype.card X := Fintype.card_le_of_injective A A.injective + have hcard : (Fintype.card {σ : Equiv.Perm X // Assigns A B σ} : ℝ) = + ((Fintype.card X - Fintype.card I).factorial : ℝ) := by + exact_mod_cast card_assignment_completions A B + have hsum : (∑ σ : Equiv.Perm X, if Assigns A B σ then + (Fintype.card (Equiv.Perm X) : ℝ)⁻¹ else 0) = + (Fintype.card {σ : Equiv.Perm X // Assigns A B σ} : ℝ) * + (Fintype.card (Equiv.Perm X) : ℝ)⁻¹ := by + simp [Fintype.card_subtype, Finset.sum_ite] + rw [hsum, hcard, Fintype.card_perm, + ← Nat.factorial_mul_descFactorial hn, Nat.cast_mul, mul_inv_rev] + have hf : (((Fintype.card X - Fintype.card I).factorial : ℕ) : ℝ) ≠ 0 := by + exact_mod_cast (Nat.factorial_ne_zero (Fintype.card X - Fintype.card I)) + field_simp + +end Assignments + +lemma physicalLaw_eq_convolutionPower (d t : ℕ) : + physicalLaw d t = convolutionPower (finiteLaw (physical d)) t := + finiteLaw_independentHistory (physical d) t + +def sweepHistory (d t : ℕ) (coins : Fin t → SweepCoins d) : Equiv.Perm (Slot d) := + independentHistory (binarySweep d) t coins + +lemma sweepLaw_eq_finiteLaw (d t : ℕ) : sweepLaw d t = finiteLaw (sweepHistory d t) := + (finiteLaw_independentHistory (binarySweep d) t).symm + +def fromInitial {G : Type*} [Group G] (p : G → ℝ) (initial : G) : G → ℝ := + fun g => p (g * initial⁻¹) + +lemma totalVariation_fromInitial {G : Type*} [Fintype G] [Group G] + (p : G → ℝ) (initial : G) : + totalVariation (fromInitial p initial) (uniformLaw G) = totalVariation p (uniformLaw G) := by + unfold totalVariation fromInitial uniformLaw + congr 1 + exact Equiv.sum_comp (Equiv.mulRight initial⁻¹) + (fun g => |p g - (Fintype.card G : ℝ)⁻¹|) + +theorem fixed_dimension_sweep_convergence_fromInitial (d : ℕ) + (initial : Equiv.Perm (Slot d)) : + Filter.Tendsto (fun t => totalVariation (fromInitial (sweepLaw d t) initial) + (uniformLaw (Equiv.Perm (Slot d)))) Filter.atTop (nhds 0) := by + simp only [totalVariation_fromInitial] + exact fixed_dimension_sweep_convergence d + +def ConstantSweepMixingTarget : Prop := + ∃ w : ℕ, ∀ ε : ℝ, 0 < ε → ∃ d₀ : ℕ, ∀ d ≥ d₀, + ∀ initial : Equiv.Perm (Slot d), + totalVariation (fromInitial (sweepLaw d w) initial) + (uniformLaw (Equiv.Perm (Slot d))) < ε + +def fallingCost (m u : ℕ) : ℝ := Real.log ((m : ℝ) ^ u / (m.descFactorial u : ℝ)) + +lemma fallingCost_sum {m u : ℕ} (hm : 0 < m) (hu : u ≤ m) : + fallingCost m u = ∑ j ∈ Finset.range u, Real.log ((m : ℝ) / (m - j : ℕ)) := by + have hmp : (0 : ℝ) < m := by exact_mod_cast hm + have hdf : (0 : ℝ) < m.descFactorial u := by exact_mod_cast (Nat.descFactorial_pos.mpr hu) + have hdiff (j : ℕ) (hj : j ∈ Finset.range u) : (m - j : ℕ) ≠ 0 := by + simp only [Finset.mem_range] at hj + omega + have hlog (j : ℕ) (hj : j ∈ Finset.range u) : + Real.log ((m : ℝ) / (m - j : ℕ)) = Real.log m - Real.log (m - j : ℕ) := + Real.log_div hmp.ne' (by exact_mod_cast hdiff j hj) + rw [fallingCost, Real.log_div (pow_ne_zero _ hmp.ne') hdf.ne', Real.log_pow, + Nat.descFactorial_eq_prod_range, Nat.cast_prod, Real.log_prod (fun j hj => by exact_mod_cast hdiff j hj)] + rw [Finset.sum_congr rfl hlog, Finset.sum_sub_distrib] + simp + +lemma fallingCost_nonneg {m u : ℕ} (hm : 0 < m) (hu : u ≤ m) : 0 ≤ fallingCost m u := by + rw [fallingCost_sum hm hu] + apply Finset.sum_nonneg + intro j hj + have hdiff : (0 : ℝ) < (m - j : ℕ) := by + exact_mod_cast (Nat.sub_pos_of_lt ((Finset.mem_range.mp hj).trans_le hu)) + apply Real.log_nonneg + exact (le_div_iff₀ hdiff).mpr (by simp) + +lemma prefix_sum_le_of_full_sum_le {m u : ℕ} (hm : 0 < m) (hu : u ≤ m) (f : ℕ → ℝ) + (hf : ∀ i < u, ∀ j, u ≤ j → j < m → f i ≤ f j) + (hfull : ∑ j ∈ Finset.range m, f j ≤ m) : + ∑ j ∈ Finset.range u, f j ≤ u := by + have hc : ((m : ℝ) - u) * (∑ i ∈ Finset.range u, f i) ≤ + (u : ℝ) * ∑ j ∈ Finset.Ico u m, f j := by + calc + _ = ∑ i ∈ Finset.range u, ∑ _j ∈ Finset.Ico u m, f i := by + simp [Nat.cast_sub hu, Finset.mul_sum] + _ ≤ ∑ i ∈ Finset.range u, ∑ j ∈ Finset.Ico u m, f j := by + apply Finset.sum_le_sum + intro i hi + apply Finset.sum_le_sum + intro j hj + exact hf i (Finset.mem_range.mp hi) j (Finset.mem_Ico.mp hj).1 (Finset.mem_Ico.mp hj).2 + _ = _ := by simp + have hsplit := Finset.sum_range_add_sum_Ico f hu + have hmp : (0 : ℝ) < m := by exact_mod_cast hm + have hu0 : (0 : ℝ) ≤ u := by positivity + nlinarith + +lemma fallingCost_le {m u : ℕ} (hm : 0 < m) (hu : u ≤ m) : fallingCost m u ≤ u := by + have hmp : (0 : ℝ) < m := by exact_mod_cast hm + have hfull : fallingCost m m ≤ m := by + have hst := Stirling.le_log_factorial_stirling hm.ne' + have hlog : 0 ≤ Real.log (m : ℝ) := Real.log_nonneg (by exact_mod_cast hm) + have hpi : 0 ≤ Real.log (2 * Real.pi) := Real.log_nonneg (by linarith [Real.pi_gt_three]) + rw [fallingCost, Nat.descFactorial_self, Real.log_div (pow_ne_zero _ hmp.ne') (by positivity), Real.log_pow] + linarith + rw [fallingCost_sum hm hu] + apply prefix_sum_le_of_full_sum_le hm hu + · intro i hi j huj hjm + apply Real.log_le_log + · exact div_pos hmp (by exact_mod_cast Nat.sub_pos_of_lt (hi.trans_le hu)) + · apply div_le_div_of_nonneg_left hmp.le + · exact_mod_cast Nat.sub_pos_of_lt hjm + · exact_mod_cast Nat.sub_le_sub_left (hi.le.trans huj) m + · rwa [← fallingCost_sum hm le_rfl] + +attribute [local instance] Classical.propDecidable +variable {X I J : Type*} [Fintype X] [Fintype I] [Fintype J] + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/LocalPathWeight.lean b/lean/OAI/Probability/BinarySweep/Processes/LocalPathWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d02de1b650094252f73922c5f8aa11901d52ef2 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/LocalPathWeight.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.AssignmentWeight + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +def localPathWeight {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (j : Fin b) (y : GridOutside bits j) : ℝ := + assignmentWeight (lineLaw (bits j) z) (lineInput H j y) (lineOutput H j y) + +lemma fallingCost_formula {m u : ℕ} (hm : 0 < m) (hu : u ≤ m) : + fallingCost m u = (u : ℝ) * Real.log m - Real.log (m.descFactorial u : ℕ) := by + have hmp : (m : ℝ) ≠ 0 := by exact_mod_cast hm.ne' + have hdf : (m.descFactorial u : ℝ) ≠ 0 := by exact_mod_cast (Nat.descFactorial_pos.mpr hu).ne' + rw [fallingCost, Real.log_div (pow_ne_zero _ hmp) hdf, Real.log_pow] + +lemma assignmentWeight_eq_of_card_eq {X I J : Type*} [Fintype X] [Fintype I] [Fintype J] + (p : Equiv.Perm X → ℝ) (A B : I ↪ X) (A' B' : J ↪ X) (f : I ↪ J) + (hA : ∀ i, A' (f i) = A i) (hB : ∀ i, B' (f i) = B i) + (hcard : Fintype.card I = Fintype.card J) : assignmentWeight p A' B' = assignmentWeight p A B := by + have hsur : Function.Surjective f := by + by_contra hn + have hc := Fintype.card_lt_of_injective_not_surjective f f.injective hn + omega + have he (σ : Equiv.Perm X) : Assigns A' B' σ ↔ Assigns A B σ := by + constructor + · intro hσ i + simpa only [hA, hB] using hσ (f i) + · intro hσ j + obtain ⟨i, rfl⟩ := hsur j + simpa only [hA, hB] using hσ i + simp only [assignmentWeight, he] + +lemma assignmentWeight_log_ratio_le {X I J : Type*} [Fintype X] [Fintype I] [Fintype J] + (hm : 0 < Fintype.card X) {p : Equiv.Perm X → ℝ} + (hl : ∀ σ, (1 / 2 : ℝ) * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹ ≤ p σ) + (hu : ∀ σ, p σ ≤ 2 * (Fintype.card (Equiv.Perm X) : ℝ)⁻¹) + (A B : I ↪ X) (A' B' : J ↪ X) (f : I ↪ J) + (hA : ∀ i, A' (f i) = A i) (hB : ∀ i, B' (f i) = B i) : + Real.log (assignmentWeight p A' B' / assignmentWeight p A B) ≤ + fallingCost (Fintype.card X) (Fintype.card J) - fallingCost (Fintype.card X) (Fintype.card I) - + ((Fintype.card J : ℝ) - Fintype.card I) * Real.log (Fintype.card X) + + Real.log 4 * ((Fintype.card J : ℝ) - Fintype.card I) := by + have hI := Fintype.card_le_of_injective A A.injective + have hJ := Fintype.card_le_of_injective A' A'.injective + have hi : (0 : ℝ) < Nat.descFactorial (Fintype.card X) (Fintype.card I) := by + exact_mod_cast Nat.descFactorial_pos.mpr hI + have hj : (0 : ℝ) < Nat.descFactorial (Fintype.card X) (Fintype.card J) := by + exact_mod_cast Nat.descFactorial_pos.mpr hJ + have wi : 0 < assignmentWeight p A B := lt_of_lt_of_le (by positivity) (assignmentWeight_comparison hl hu A B).1 + have wj : 0 < assignmentWeight p A' B' := lt_of_lt_of_le (by positivity) (assignmentWeight_comparison hl hu A' B').1 + by_cases hc : Fintype.card I = Fintype.card J + · rw [assignmentWeight_eq_of_card_eq p A B A' B' f hA hB hc, div_self wi.ne', Real.log_one, hc] + simp + · have hIJ := Fintype.card_le_of_injective f f.injective + have hgap : (1 : ℝ) ≤ (Fintype.card J : ℝ) - Fintype.card I := by + have hh : Fintype.card I + 1 ≤ Fintype.card J := by omega + exact_mod_cast (show (1 : ℤ) ≤ (Fintype.card J : ℤ) - Fintype.card I from by omega) + have hl4 : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num) + calc + _ ≤ Real.log (4 * (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ) / + (Nat.descFactorial (Fintype.card X) (Fintype.card J) : ℝ)) := + Real.log_le_log (div_pos wj wi) (assignmentWeight_ratio_le hl hu A B A' B') + _ = Real.log 4 + Real.log (Nat.descFactorial (Fintype.card X) (Fintype.card I) : ℝ) - + Real.log (Nat.descFactorial (Fintype.card X) (Fintype.card J) : ℝ) := by + rw [Real.log_div (by positivity) hj.ne', Real.log_mul (by norm_num) hi.ne'] + _ ≤ _ := by + rw [fallingCost_formula hm hI, fallingCost_formula hm hJ] + nlinarith + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/PointMassOne.lean b/lean/OAI/Probability/BinarySweep/Processes/PointMassOne.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a83f81902925c40e2f4151a10def4cea81e56a9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/PointMassOne.lean @@ -0,0 +1,200 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.GridSweepPath + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps +section FiniteRandomWalkConvergence +variable {G : Type*} [Fintype G] [Group G] + +lemma pointMassOne_probability : IsProbability (pointMassOne : G → ℝ) := by + classical + constructor + · intro g; unfold pointMassOne; split_ifs <;> norm_num + · simp [pointMassOne] + +lemma convolution_one_left (p : G → ℝ) : convolution pointMassOne p = p := by + classical + funext g + simp [convolution, pointMassOne, ite_mul] + +lemma convolution_one_right (p : G → ℝ) : convolution p pointMassOne = p := by + classical + funext g + simp [convolution, pointMassOne, mul_ite, inv_mul_eq_one] + +lemma convolutionPower_probability {p : G → ℝ} (hp : IsProbability p) (n : ℕ) : + IsProbability (convolutionPower p n) := by + induction n with + | zero => exact pointMassOne_probability + | succ n ih => exact convolution_probability hp ih + +lemma convolutionPower_add (p : G → ℝ) (m n : ℕ) : + convolutionPower p (m + n) = convolution (convolutionPower p m) (convolutionPower p n) := by + induction m with + | zero => simp [convolutionPower, convolution_one_left] + | succ m ih => + simpa only [Nat.succ_add, convolutionPower, ih] using + (convolution_assoc p (convolutionPower p m) (convolutionPower p n)).symm + +lemma convolutionPower_one (p : G → ℝ) : convolutionPower p 1 = p := + convolution_one_right p + +lemma convolutionPower_succ_right (p : G → ℝ) (n : ℕ) : + convolutionPower p (n + 1) = convolution (convolutionPower p n) p := by + rw [convolutionPower_add, convolutionPower_one] + +lemma convolutionPower_block_bound {p : G → ℝ} (hp : IsProbability p) (L : ℕ) + {δ : ℝ} (hδ0 : 0 ≤ 1 - δ) + (hδ : ∀ g, δ * uniformLaw G g ≤ convolutionPower p L g) (k : ℕ) : + totalVariation (convolutionPower p (L * k)) (uniformLaw G) ≤ (1 - δ) ^ k := by + induction k with + | zero => + simp only [mul_zero, pow_zero] + exact totalVariation_le_one (convolutionPower_probability hp 0) uniformLaw_probability + | succ k ih => + rw [Nat.mul_succ, Nat.add_comm, convolutionPower_add] + calc + _ ≤ (1 - δ) * totalVariation (convolutionPower p (L * k)) (uniformLaw G) := + convolution_minorization (convolutionPower_probability hp L) + (convolutionPower_probability hp (L * k)) δ hδ + _ ≤ (1 - δ) * (1 - δ) ^ k := mul_le_mul_of_nonneg_left ih hδ0 + _ = _ := by rw [pow_succ]; ring + +lemma convolutionPower_all_time_bound {p : G → ℝ} (hp : IsProbability p) (L : ℕ) + {δ : ℝ} (hδ0 : 0 ≤ 1 - δ) + (hδ : ∀ g, δ * uniformLaw G g ≤ convolutionPower p L g) (t : ℕ) : + totalVariation (convolutionPower p t) (uniformLaw G) ≤ (1 - δ) ^ (t / L) := by + have he := convolutionPower_add p (t % L) (L * (t / L)) + rw [Nat.mod_add_div] at he + rw [he, ← convolution_uniform_right (convolutionPower_probability hp (t % L)).2] + have hc := convolution_tv_contract (convolutionPower_probability hp (t % L)).1 + (convolutionPower p (L * (t / L))) (uniformLaw G) + rw [(convolutionPower_probability hp (t % L)).2, one_mul] at hc + exact hc.trans (convolutionPower_block_bound hp L hδ0 hδ (t / L)) + +lemma uniformLaw_le_one (g : G) : uniformLaw G g ≤ 1 := by + have hc : (1 : ℝ) ≤ Fintype.card G := by exact_mod_cast Fintype.card_pos (α := G) + exact (inv_le_one₀ (by linarith)).mpr hc + +theorem convolutionPower_tendsto_uniform {p : G → ℝ} (hp : IsProbability p) + {L : ℕ} (hL : 0 < L) (hpos : ∀ g, 0 < convolutionPower p L g) : + Filter.Tendsto (fun t => totalVariation (convolutionPower p t) (uniformLaw G)) + Filter.atTop (nhds 0) := by + classical + let ε := Finset.univ.inf' Finset.univ_nonempty (convolutionPower p L) + have hε : 0 < ε := (Finset.lt_inf'_iff Finset.univ_nonempty).mpr (fun g _ => hpos g) + let δ : ℝ := min (1 / 2) ε + have hδpos : 0 < δ := lt_min (by norm_num) hε + have hδhalf : δ ≤ 1 / 2 := min_le_left _ _ + have hδ0 : 0 ≤ 1 - δ := by linarith + have hδ : ∀ g, δ * uniformLaw G g ≤ convolutionPower p L g := by + intro g + calc + _ ≤ δ * 1 := mul_le_mul_of_nonneg_left (uniformLaw_le_one g) hδpos.le + _ = δ := mul_one _ + _ ≤ ε := min_le_right _ _ + _ ≤ _ := Finset.inf'_le _ (Finset.mem_univ g) + apply squeeze_zero (fun _ => totalVariation_nonneg _ _) + (convolutionPower_all_time_bound hp L hδ0 hδ) + exact (tendsto_pow_atTop_nhds_zero_of_lt_one hδ0 (by linarith)).comp + (Nat.tendsto_div_const_atTop hL.ne') + +end FiniteRandomWalkConvergence + +lemma finiteLaw_pos_of_mem {Ω G : Type*} [Fintype Ω] [Fintype G] + (f : Ω → G) (ω : Ω) : 0 < finiteLaw f (f ω) := by + classical + have : Nonempty Ω := ⟨ω⟩ + apply Finset.sum_pos' + · intro a _; split_ifs <;> positivity + · exact ⟨ω, Finset.mem_univ _, by simp [Fintype.card_pos]⟩ + +section ReachableRandomWalk +variable {G Ω : Type*} [Fintype G] [Group G] [Fintype Ω] [Nonempty Ω] + +lemma convolution_pos_at_mul {p q : G → ℝ} (hp : ∀ x, 0 ≤ p x) (hq : ∀ x, 0 ≤ q x) + {g h : G} (hg : 0 < p g) (hh : 0 < q h) : 0 < convolution p q (g * h) := by + classical + apply Finset.sum_pos' + · intro x _; exact mul_nonneg (hp x) (hq _) + · refine ⟨g, Finset.mem_univ _, ?_⟩ + simpa using mul_pos hg hh + +lemma convolutionPower_pos_list (f : Ω → G) (l : List Ω) : + 0 < convolutionPower (finiteLaw f) l.length (l.map f).prod := by + induction l with + | nil => simp [convolutionPower, pointMassOne] + | cons a l ih => + simpa only [List.length_cons, List.map_cons, List.prod_cons, convolutionPower] using + convolution_pos_at_mul (finiteLaw_nonneg f) + (convolutionPower_probability ⟨finiteLaw_nonneg f, finiteLaw_sum f⟩ l.length).1 + (finiteLaw_pos_of_mem f a) ih + +lemma convolutionPower_pos_later {p : G → ℝ} (hp : IsProbability p) (h1 : 0 < p 1) + {g : G} {n m : ℕ} (hn : 0 < convolutionPower p n g) (hnm : n ≤ m) : + 0 < convolutionPower p m g := by + obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hnm + clear hnm + induction k with + | zero => simpa using hn + | succ k ih => + change 0 < convolution p (convolutionPower p (n + k)) g + simpa only [one_mul] using + convolution_pos_at_mul hp.1 (convolutionPower_probability hp (n + k)).1 h1 ih + +lemma finiteLaw_fullSupport_power (f : Ω → G) (ω₀ : Ω) (hω₀ : f ω₀ = 1) + (hgen : ∀ g : G, ∃ l : List Ω, (l.map f).prod = g) : + ∃ L : ℕ, 0 < L ∧ ∀ g, 0 < convolutionPower (finiteLaw f) L g := by + classical + choose l hl using hgen + let L := 1 + ∑ g : G, (l g).length + refine ⟨L, by dsimp [L]; omega, ?_⟩ + intro g + apply convolutionPower_pos_later ⟨finiteLaw_nonneg f, finiteLaw_sum f⟩ + (hω₀ ▸ finiteLaw_pos_of_mem f ω₀) + · rw [← hl g] + exact convolutionPower_pos_list f (l g) + · exact (Finset.single_le_sum (fun i _ => Nat.zero_le ((l i).length)) + (Finset.mem_univ g)).trans (Nat.le_add_left _ _) + +end ReachableRandomWalk + +theorem fixed_dimension_sweep_convergence (d : ℕ) : + Filter.Tendsto (fun t => totalVariation (sweepLaw d t) + (uniformLaw (Equiv.Perm (Slot d)))) Filter.atTop (nhds 0) := by + obtain ⟨L, hL, hpos⟩ := finiteLaw_fullSupport_power (binarySweep d) + (fun _ _ => false) (binarySweep_zero d) (every_permutation_sweepReachable d) + exact convolutionPower_tendsto_uniform + ⟨finiteLaw_nonneg (binarySweep d), finiteLaw_sum (binarySweep d)⟩ hL hpos + +variable {G Ω Ξ : Type*} [Fintype G] [Group G] [Fintype Ω] [Fintype Ξ] + +omit [Group G] in +lemma finiteLaw_reindex (e : Ω ≃ Ξ) (f : Ξ → G) : finiteLaw (f ∘ e) = finiteLaw f := by + classical + funext g + unfold finiteLaw + rw [Fintype.card_congr e] + exact Equiv.sum_comp e (fun ξ => if f ξ = g then (Fintype.card Ξ : ℝ)⁻¹ else 0) + +lemma finiteLaw_independent_mul (f : Ω → G) (k : Ξ → G) : + finiteLaw (fun a : Ω × Ξ => f a.1 * k a.2) = convolution (finiteLaw f) (finiteLaw k) := by + classical + funext g + rw [convolution, finiteLaw_expectation] + simp only [finiteLaw, Fintype.card_prod, Nat.cast_mul, mul_inv_rev, Fintype.sum_prod_type, + Finset.mul_sum, eq_inv_mul_iff_mul_eq] + apply Finset.sum_congr rfl + intro ω _ + apply Finset.sum_congr rfl + intro ξ _ + split_ifs <;> ring + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean b/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..79c85d5ecf154cf83e79db3df25433c93db0f768 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Processes/SupportTimeBoundBounds.lean @@ -0,0 +1,202 @@ +import Mathlib +import OAI.Probability.BinarySweep.Processes.Basic + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps + +theorem supportTimeBound_bounds (d : ℕ) : + (2 : ℝ) * (d + 1) - 6 ≤ supportTimeBound d ∧ + supportTimeBound d ≤ (2 : ℝ) * (d + 1) := by + let N : ℕ := 2 ^ (d + 1) + have hN : (2 : ℝ) ≤ N := by + dsimp [N] + rw [Nat.cast_pow, Nat.cast_ofNat, pow_succ] + have : (1 : ℝ) ≤ (2 : ℝ) ^ d := one_le_pow₀ (by norm_num) + linarith + have hNp : (0 : ℝ) < N := by linarith + have hNne : N ≠ 0 := by exact_mod_cast hNp.ne' + have hfac : (0 : ℝ) < N.factorial := by positivity + have hlog : (0 : ℝ) < Real.log 2 := Real.log_pos (by norm_num) + have hhalf : (1 / 2 : ℝ) ≤ Real.log 2 := by + have := Real.one_sub_inv_le_log_of_pos (x := (2 : ℝ)) (by norm_num) + norm_num at this ⊢ + exact this + have hlogN : Real.log (N : ℝ) = ((d : ℝ) + 1) * Real.log 2 := by + simp [N, Real.log_pow] + have hlogNN : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by linarith) + have hpi : 0 ≤ Real.log (2 * Real.pi) := + Real.log_nonneg (by linarith [Real.pi_gt_three]) + have hst := Stirling.le_log_factorial_stirling hNne + have hfaclow : (N : ℝ) * Real.log N - N ≤ Real.log (N.factorial : ℝ) := by + linarith + have hfacup : Real.log (N.factorial : ℝ) ≤ (N : ℝ) * Real.log N := by + have h := Real.log_le_log hfac (show (N.factorial : ℝ) ≤ (N : ℝ) ^ N by + exact_mod_cast Nat.factorial_le_pow N) + rwa [Real.log_pow] at h + have hconstlow : -(1 : ℝ) ≤ Real.log (3 / 4 : ℝ) := by + have := Real.one_sub_inv_le_log_of_pos (x := (3 / 4 : ℝ)) (by norm_num) + norm_num at this + linarith + have hconstup : Real.log (3 / 4 : ℝ) ≤ 0 := Real.log_nonpos (by norm_num) (by norm_num) + have hL : Real.log (3 * (N.factorial : ℝ) / 4) = + Real.log (N.factorial : ℝ) + Real.log (3 / 4 : ℝ) := by + rw [show 3 * (N.factorial : ℝ) / 4 = (N.factorial : ℝ) * (3 / 4) by ring] + exact Real.log_mul hfac.ne' (by norm_num) + have hlow : (N : ℝ) * (((d : ℝ) + 1) * Real.log 2) - N - 1 ≤ + Real.log (3 * (N.factorial : ℝ) / 4) := by + rw [hL] + rw [hlogN] at hfaclow + linarith + have hup : Real.log (3 * (N.factorial : ℝ) / 4) ≤ + (N : ℝ) * (((d : ℝ) + 1) * Real.log 2) := by + rw [hL] + rw [hlogN] at hfacup + linarith + have hrewrite : supportTimeBound d = + 2 * Real.log (3 * (N.factorial : ℝ) / 4) / ((N : ℝ) * Real.log 2) := by + simp only [supportTimeBound, Real.logb] + have hcast : (N : ℝ) = (2 : ℝ) ^ (d + 1) := by simp [N] + rw [← hcast] + ring + rw [hrewrite] + constructor + · apply (le_div_iff₀ (mul_pos hNp hlog)).mpr + have hprod : (N : ℝ) / 2 ≤ (N : ℝ) * Real.log 2 := by + nlinarith [mul_nonneg hNp.le (sub_nonneg.mpr hhalf)] + nlinarith + · apply (div_le_iff₀ (mul_pos hNp hlog)).mpr + nlinarith + +theorem support_ceiling_asymptotic (d : ℕ) : + |(⌈supportTimeBound d⌉ : ℝ) - 2 * (d + 1)| ≤ 6 := by + obtain ⟨hlow, hupp⟩ := supportTimeBound_bounds d + have hceilow := Int.le_ceil (supportTimeBound d) + have hup : ⌈supportTimeBound d⌉ ≤ (2 * (d + 1) : ℤ) := by + apply Int.ceil_le.mpr + push_cast + exact hupp + have hupR : (⌈supportTimeBound d⌉ : ℝ) ≤ 2 * ((d : ℝ) + 1) := by + exact_mod_cast hup + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +def boolSwitch (c : Bool) : Equiv.Perm Bool where + toFun x := x ^^ c + invFun x := x ^^ c + left_inv x := by simp + right_inv x := by simp + +lemma sign_boolSwitch (c : Bool) : + Equiv.Perm.sign (boolSwitch c) = if c then (-1 : ℤˣ) else 1 := by + cases c + · have : boolSwitch false = 1 := by ext x; cases x <;> rfl + rw [this]; rfl + · have : boolSwitch true = Equiv.swap false true := by + ext x; cases x <;> simp [boolSwitch] + rw [this, Equiv.Perm.sign_swap (by decide)]; rfl + +lemma realSign_coordinateLayer (d : ℕ) (j : Fin d) + (c : ({i : Fin d // i ≠ j} → Bool) → Bool) : + realSign (coordinateLayer d j c) = ∏ y, (if c y then (-1 : ℝ) else 1) := by + classical + have he : coordinateLayer d j c = + (Equiv.piSplitAt j (fun _ : Fin d => Bool)).trans + ((Equiv.prodCongrLeft (fun y => boolSwitch (c y))).trans + (Equiv.piSplitAt j (fun _ : Fin d => Bool)).symm) := rfl + rw [he] + simp [realSign, Equiv.Perm.sign_prodCongrLeft, sign_boolSwitch, apply_ite] + +lemma sum_realSign_coordinateLayer (d : ℕ) (j : Fin d) : + ∑ c : ({i : Fin d // i ≠ j} → Bool) → Bool, + realSign (coordinateLayer d j c) = 0 := by + classical + simp_rw [realSign_coordinateLayer] + rw [← Fintype.prod_sum (fun (_ : {i : Fin d // i ≠ j} → Bool) (b : Bool) => + if b then (-1 : ℝ) else 1)] + simp + +lemma realSign_binarySweep (d : ℕ) (c : SweepCoins d) : + realSign (binarySweep d c) = ∏ j, realSign (coordinateLayer d j (c j)) := by + classical + simp [binarySweep, map_list_prod, List.map_reverse, List.prod_reverse, + List.map_ofFn, List.prod_ofFn] + +lemma sum_realSign_binarySweep (d : ℕ) (hd : 0 < d) : + ∑ c : SweepCoins d, realSign (binarySweep d c) = 0 := by + classical + simp_rw [realSign_binarySweep] + rw [← Fintype.prod_sum (fun (j : Fin d) (c : ({i : Fin d // i ≠ j} → Bool) → Bool) => + realSign (coordinateLayer d j c))] + apply Finset.prod_eq_zero (i := ⟨0, hd⟩) (Finset.mem_univ _) + exact sum_realSign_coordinateLayer d ⟨0, hd⟩ + +lemma finiteLaw_expectation {Ω G : Type*} [Fintype Ω] [Fintype G] + (f : Ω → G) (a : G → ℝ) : + ∑ g, finiteLaw f g * a g = (Fintype.card Ω : ℝ)⁻¹ * ∑ ω, a (f ω) := by + classical + simp only [finiteLaw, Finset.sum_mul] + rw [Finset.sum_comm] + simp [ite_mul, Finset.mul_sum] + +theorem binary_sign_annihilated (d : ℕ) (hd : 0 < d) : + ∑ g : Equiv.Perm (Slot d), binaryLaw d g * realSign g = 0 := by + rw [binaryLaw, finiteLaw_expectation, sum_realSign_binarySweep d hd, mul_zero] + +lemma coordinateLayer_zero (d : ℕ) (j : Fin d) : + coordinateLayer d j (fun _ => false) = 1 := by + ext x i + simp [coordinateLayer, Equiv.piSplitAt_symm_apply] + intro h + rw [h] + +lemma prod_reverse_ofFn_single {G : Type*} [Monoid G] (n : ℕ) (j : Fin n) (g : G) : + (List.ofFn (fun i : Fin n => if i = j then g else 1)).reverse.prod = g := by + induction n with + | zero => exact Fin.elim0 j + | succ n ih => + refine Fin.cases ?_ (fun j => ?_) j + · simp [List.ofFn_succ, List.ofFn_const] + · simpa [List.ofFn_succ, (Fin.succ_ne_zero j).symm] using ih j + +lemma binarySweep_zero (d : ℕ) : binarySweep d (fun _ _ => false) = 1 := by + simp [binarySweep, coordinateLayer_zero, List.ofFn_const] + +lemma binarySweep_singleLayer (d : ℕ) (j : Fin d) + (c : ({i : Fin d // i ≠ j} → Bool) → Bool) : + binarySweep d (Function.update ((fun _ _ => false) : SweepCoins d) j c) = coordinateLayer d j c := by + classical + have h (i : Fin d) : + coordinateLayer d i ((Function.update ((fun _ _ => false) : SweepCoins d) j c) i) = + if i = j then coordinateLayer d j c else 1 := by + by_cases hi : i = j + · subst i; simp + · simp [coordinateLayer_zero, hi] + simp only [binarySweep, h] + exact prod_reverse_ofFn_single d j _ + +def sweepReachable (d : ℕ) : Submonoid (Equiv.Perm (Slot d)) where + carrier := {g | ∃ l : List (SweepCoins d), (l.map (binarySweep d)).prod = g} + one_mem' := ⟨[], rfl⟩ + mul_mem' := by + rintro g h ⟨l, rfl⟩ ⟨k, rfl⟩ + exact ⟨l ++ k, by simp⟩ + +lemma coordinateLayer_mem_reachable (d : ℕ) (j : Fin d) + (c : ({i : Fin d // i ≠ j} → Bool) → Bool) : + coordinateLayer d j c ∈ sweepReachable d := by + refine ⟨[Function.update ((fun _ _ => false) : SweepCoins d) j c], ?_⟩ + simp [binarySweep_singleLayer] + +lemma fiber_boolSwitch_eq_swap {Y : Type*} [DecidableEq Y] (y : Y) (a : Bool) : + Equiv.prodCongrLeft (fun z => boolSwitch (decide (z = y))) = + Equiv.swap (a, y) (!a, y) := by + ext ⟨b, z⟩ <;> cases a <;> cases b <;> by_cases h : z = y <;> + simp [boolSwitch, Equiv.swap_apply_def, h] + +end BinaryCoordinateSweeps +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/CharacterComplete.lean b/lean/OAI/Probability/BinarySweep/Representations/CharacterComplete.lean new file mode 100644 index 0000000000000000000000000000000000000000..53107c69c95e6dfbfd1023f858e3891f287b500e --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/CharacterComplete.lean @@ -0,0 +1,62 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IrrepTransport + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +variable {G I : Type*} [Group G] [Fintype G] [Fintype I] + {V : I → Type*} [∀ i, AddCommGroup (V i)] [∀ i, Module ℂ (V i)] + [∀ i, FiniteDimensional ℂ (V i)] + (σ : ∀ i, Representation ℂ G (V i)) [∀ i, Representation.IsIrreducible (σ i)] + +theorem linearIndependent_classCharacters + (hdiff : ∀ i j, Nonempty (Representation.Equiv (σ i) (σ j)) → i = j) : + LinearIndependent ℂ (fun i => classCharacter (σ i)) := by + apply Fintype.linearIndependent_iff.mpr + intro a ha i + have h := congrArg (classPairRight (classCharacter (σ i))) ha + simp only [map_sum, map_smul, map_zero, smul_eq_mul] at h + have hi (j : I) : Nonempty (Representation.Equiv (σ i) (σ j)) ↔ i = j := by + constructor + · exact hdiff i j + · rintro rfl + exact ⟨Representation.Equiv.refl _⟩ + simp_rw [classPair_characters, hi] at h + simpa only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] using h + +theorem complete_of_card_ge [Nonempty I] + (hdiff : ∀ i j, Nonempty (Representation.Equiv (σ i) (σ j)) → i = j) + (hcard : Nat.card (ConjClasses G) ≤ Fintype.card I) + {W : Type*} [AddCommGroup W] [Module ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G W) [ρ.IsIrreducible] : + ∃ i, Nonempty (Representation.Equiv ρ (σ i)) := by + let : Fintype (ConjClasses G) := Fintype.ofFinite _ + have hli := linearIndependent_classCharacters σ hdiff + have hdim : Fintype.card I = Module.finrank ℂ (ConjClasses G → ℂ) := by + apply le_antisymm hli.fintype_card_le_finrank + simpa only [Module.finrank_pi, Nat.card_eq_fintype_card] using hcard + have ht := hli.span_eq_top_of_card_eq_finrank hdim + by_contra hn + push Not at hn + have hzero (i : I) : classPairRight (classCharacter ρ) (classCharacter (σ i)) = 0 := by + have hi : ¬ Nonempty (Representation.Equiv ρ (σ i)) := fun ⟨f⟩ => (hn i).false f + rw [classPair_characters, ite_eq_right hi] + have hle : Submodule.span ℂ (Set.range (fun i => classCharacter (σ i))) ≤ + (classPairRight (classCharacter ρ)).ker := by + rw [Submodule.span_le] + rintro _ ⟨i, rfl⟩ + exact hzero i + rw [ht] at hle + have he : classPairRight (classCharacter ρ) (classCharacter ρ) = 0 := + hle (Submodule.mem_top) + rw [classPair_character_self] at he + exact one_ne_zero he + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/FiniteUnitaryAverage.lean b/lean/OAI/Probability/BinarySweep/Representations/FiniteUnitaryAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..3958fff10b4f9acf6e5581b04a6a8fa523079993 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/FiniteUnitaryAverage.lean @@ -0,0 +1,146 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicMoment +import OAI.Probability.BinarySweep.Processes.CoordinateLayerEdgeSwap + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +variable {G V : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +def complexAverage (ρ : Representation ℂ G V) (p : G → ℂ) : V →L[ℂ] V := + (Irrep.groupAverage ρ p).toContinuousLinearMap + +lemma complexAverage_apply (ρ : Representation ℂ G V) (p : G → ℂ) (v : V) : + complexAverage ρ p v = ∑ g, p g • ρ g v := by + simp [complexAverage,Irrep.groupAverage] + +lemma complexAverage_norm_apply (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) (p : G → ℂ) (v : V) : + ‖complexAverage ρ p v‖ ≤ (∑g, ‖p g‖)*‖v‖ := by + rw [complexAverage_apply,Finset.sum_mul] + exact (norm_sum_le _ _).trans_eq (by simp [norm_smul,hρ]) + +lemma realAverage_contraction (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) {p : G → ℝ} (hp : IsProbability p) (v : V) : + ‖complexAverage ρ (fun g => (p g:ℂ)) v‖ ≤ ‖v‖ := by + have he : (∑g, ‖(p g:ℂ)‖)=1 := by + simpa only [Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg (hp.1 _)] using hp.2 + simpa only [he,one_mul] using complexAverage_norm_apply ρ hρ (fun g => (p g:ℂ)) v + +lemma complexAverage_sub (ρ : Representation ℂ G V) (p q : G → ℂ) : + complexAverage ρ (fun g => p g-q g)=complexAverage ρ p-complexAverage ρ q := by + ext v + simp [complexAverage_apply,sub_smul,Finset.sum_sub_distrib] + +lemma complexAverage_convolution (ρ : Representation ℂ G V) (p q : G → ℝ) : + complexAverage ρ (fun g => (convolution p q g:ℂ)) = + complexAverage ρ (fun g => (p g:ℂ))*complexAverage ρ (fun g => (q g:ℂ)) := by + ext v + calc + _ = ∑ x, ∑ y, (p x:ℂ) • (q y:ℂ) • ρ (x*y) v := by + rw [complexAverage_apply] + simp only [convolution,Complex.ofReal_sum,Finset.sum_smul, + Complex.ofReal_mul,mul_smul] + conv_lhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + simpa only [Equiv.coe_mulLeft,inv_mul_cancel_left] using + (Equiv.sum_comp (Equiv.mulLeft x) + (fun y => (p x:ℂ) • (q (x⁻¹*y):ℂ) • ρ y v)).symm + _ = _ := by + rw [mul_apply_eq_comp,complexAverage_apply] + apply Finset.sum_congr rfl + intro x _ + rw [complexAverage_apply,map_sum,Finset.smul_sum] + apply Finset.sum_congr rfl + intro y _ + rw [map_smul,map_mul,Module.End.mul_apply] + +lemma complexAverage_pointMass (ρ : Representation ℂ G V) : + complexAverage ρ (fun g => (pointMassOne g:ℂ))=1 := by + ext v + simp [complexAverage_apply,pointMassOne] + +lemma complexAverage_power (ρ : Representation ℂ G V) (p : G → ℝ) (n : ℕ) : + complexAverage ρ (fun g => (convolutionPower p n g:ℂ))= + (complexAverage ρ (fun g => (p g:ℂ)))^n := by + induction n with + | zero => exact complexAverage_pointMass ρ + | succ n ih => rw [convolutionPower,complexAverage_convolution,ih,pow_succ'] + +lemma complexAverage_uniform_left (ρ : Representation ℂ G V) (g : G) (v : V) : + ρ g (complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v)= + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v := by + simp only [complexAverage_apply,map_sum,map_smul,←Module.End.mul_apply,←map_mul,uniformLaw] + simpa only [Equiv.coe_mulLeft,Complex.ofReal_inv] using + Equiv.sum_comp (Equiv.mulLeft g) (fun x => ((Fintype.card G:ℝ)⁻¹:ℂ) • ρ x v) + +lemma complexAverage_uniform_right (ρ : Representation ℂ G V) (g : G) (v : V) : + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) (ρ g v)= + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v := by + simp only [complexAverage_apply,←Module.End.mul_apply,←map_mul,uniformLaw] + simpa only [Equiv.coe_mulRight,Complex.ofReal_inv] using + Equiv.sum_comp (Equiv.mulRight g) (fun x => ((Fintype.card G:ℝ)⁻¹:ℂ) • ρ x v) + +lemma complexAverage_uniform_idem (ρ : Representation ℂ G V) (v : V) : + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) + (complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v) = + complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v := by + rw [complexAverage_apply] + simp only [complexAverage_uniform_left,←Finset.sum_smul,←Complex.ofReal_sum,uniformLaw_sum, + Complex.ofReal_one,one_smul] + +lemma complexAverage_uniform_inner (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) (v w : V) : + inner ℂ (complexAverage ρ (fun g => (uniformLaw G g:ℂ)) v) w = + inner ℂ v (complexAverage ρ (fun g => (uniformLaw G g:ℂ)) w) := by + simp only [complexAverage_apply,inner_sum,inner_smul_left, sum_inner, + inner_smul_right,Complex.conj_ofReal] + have he (g : G) : inner ℂ (ρ g v) w=inner ℂ v (ρ g⁻¹ w) := by + rw [←LinearMap.adjoint_inner_right,Irrep.unitary_rep_adjoint ρ hρ] + simp_rw [he] + simpa only [uniformLaw,Equiv.inv_apply,Complex.ofReal_inv] using + Equiv.sum_comp (Equiv.inv G) (fun g => ((Fintype.card G:ℝ)⁻¹:ℂ)*inner ℂ v (ρ g w)) + +lemma complexAverage_variance (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) {p : G → ℝ} (hp : IsProbability p) (v : V) : + ∑g, p g * ‖ρ g v-complexAverage ρ (fun g => (p g:ℂ)) v‖^2 = + ‖v‖^2-‖complexAverage ρ (fun g => (p g:ℂ)) v‖^2 := by + let B := complexAverage ρ (fun g => (p g:ℂ)) + have hi : ∑g, p g * (inner ℂ (ρ g v) (B v)).re=‖B v‖^2 := by + have he : ∑g, (p g:ℂ)*inner ℂ (ρ g v) (B v)=inner ℂ (B v) (B v) := by + rw [show B v=∑g, (p g:ℂ) • ρ g v from complexAverage_apply ρ _ v] + rw [sum_inner] + simp only [inner_smul_left,Complex.conj_ofReal] + have hre := congrArg Complex.re he + have hsq : (inner ℂ (B v) (B v)).re=‖B v‖^2 := inner_self_eq_norm_sq (𝕜:=ℂ) (B v) + rw [hsq] at hre + simpa only [Complex.re_sum,Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im, + zero_mul,sub_zero,inner_self_eq_norm_sq] using hre + simp only [@norm_sub_sq ℂ V _ _,hρ,mul_add,mul_sub,Finset.sum_add_distrib,Finset.sum_sub_distrib] + rw [←Finset.sum_mul,hp.2,one_mul,←Finset.sum_mul,hp.2,one_mul] + have hs : (∑g, p g*(2*(inner ℂ (ρ g v) (B v)).re))=2*‖B v‖^2 := by + rw [←hi,Finset.mul_sum] + exact Finset.sum_congr rfl (fun _ _ => by ring) + change ‖v‖^2-(∑g, p g*(2*(inner ℂ (ρ g v) (B v)).re))+‖B v‖^2=_ + rw [hs] + ring + +lemma realAverage_identity_defect (ρ : Representation ℂ G V) + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) {p : G → ℝ} (hp : IsProbability p) (v : V) : + p 1*‖v-complexAverage ρ (fun g => (p g:ℂ)) v‖^2 ≤ + ‖v‖^2-‖complexAverage ρ (fun g => (p g:ℂ)) v‖^2 := by + rw [←complexAverage_variance ρ hρ hp] + simpa only [map_one,Module.End.one_apply] using Finset.single_le_sum (fun g _ => mul_nonneg (hp.1 g) + (sq_nonneg ‖ρ g v-complexAverage ρ (fun g => (p g:ℂ)) v‖)) + (Finset.mem_univ (1:G)) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IrrepSupport.lean b/lean/OAI/Probability/BinarySweep/Representations/IrrepSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..f71fb6295598e1a0940b80282682dd4a507c0a55 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IrrepSupport.lean @@ -0,0 +1,66 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators MonoidAlgebra + +namespace BinaryCoordinateSweeps +namespace Irrep + +variable {G V : Type*} [Group G] [Fintype G] + [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ G V) [ρ.IsIrreducible] + +omit [Fintype G] [FiniteDimensional ℂ V] in +lemma invariant_eq_zero_of_finrank_gt_one (hD : 1 < Module.finrank ℂ V) + (v : V) (hv : ∀ g, ρ g v = v) : v = 0 := by + let f : Representation.IntertwiningMap (1 : Representation ℂ G ℂ) ρ := + (LinearMap.toSpanSingleton ℂ V v).intertwiningMap_of_isIntertwiningMap _ _ (by + intro g c + simp only [MonoidHom.one_apply, Module.End.one_apply, LinearMap.toSpanSingleton_apply, + map_smul, hv]) + rcases Representation.IsIrreducible.surjective_or_eq_zero f with hf | hf + · have hd := LinearMap.finrank_le_finrank_of_surjective (f := f.toLinearMap) hf + simp only [Module.finrank_self] at hd + omega + · have hh := congrArg (fun a : Representation.IntertwiningMap + (1 : Representation ℂ G ℂ) ρ => a (1 : ℂ)) hf + simpa [f] using hh + +omit [FiniteDimensional ℂ V] in +lemma sum_apply_eq_zero_of_finrank_gt_one (hD : 1 < Module.finrank ℂ V) (x : V) : + ∑ g : G, ρ g x = 0 := by + apply invariant_eq_zero_of_finrank_gt_one ρ hD + intro g + simp only [map_sum, ← Module.End.mul_apply, ← map_mul] + exact Function.Bijective.sum_comp (Group.mulLeft_bijective g) (fun h : G => ρ h x) + +omit [FiniteDimensional ℂ V] in +lemma sum_eq_zero_of_finrank_gt_one (hD : 1 < Module.finrank ℂ V) : + ∑ g : G, ρ g = 0 := by + ext x + simpa using sum_apply_eq_zero_of_finrank_gt_one ρ hD x + +include ρ in +omit [FiniteDimensional ℂ V] in +lemma finrank_le_card : Module.finrank ℂ V ≤ Fintype.card G := by + let : IsSimpleModule ℂ[G] ρ.asModule := inferInstance + let : Nontrivial ρ.asModule := IsSimpleModule.nontrivial ℂ[G] ρ.asModule + obtain ⟨v, hv⟩ := exists_ne (0 : ρ.asModule) + let f : ℂ[G] →ₗ[ℂ] ρ.asModule := + (LinearMap.toSpanSingleton ℂ[G] ρ.asModule v).restrictScalars ℂ + have hf : Function.Surjective f := IsSimpleModule.toSpanSingleton_surjective ℂ[G] hv + have hd := LinearMap.finrank_le_finrank_of_surjective (f := f) hf + have he : Module.finrank ℂ ρ.asModule = Module.finrank ℂ V := + ρ.asModuleEquiv.finrank_eq + rw [he] at hd + rw [Module.finrank_eq_card_basis (MonoidAlgebra.basis G ℂ)] at hd + exact hd + +end Irrep +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IrrepTransport.lean b/lean/OAI/Probability/BinarySweep/Representations/IrrepTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..71c1482c1c0cdd283ea1f8dbfd359b11103ca554 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IrrepTransport.lean @@ -0,0 +1,67 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators MonoidAlgebra Classical + +namespace BinaryCoordinateSweeps.Irrep +variable {G H V : Type*} [Group G] [Group H] [AddCommGroup V] [Module ℂ V] + +def subrepresentationCongr (e : H ≃* G) (ρ : Representation ℂ G V) : + Subrepresentation ρ ≃o Subrepresentation (ρ.comp e.toMonoidHom) where + toFun U := ⟨U.toSubmodule, fun h _ hv => U.apply_mem_toSubmodule (e h) hv⟩ + invFun U := ⟨U.toSubmodule, fun g v hv => by + have h := U.apply_mem_toSubmodule (e.symm g) hv + change ρ (e (e.symm g)) v ∈ U.toSubmodule at h + rwa [e.apply_symm_apply] at h⟩ + left_inv U := by rfl + right_inv U := by rfl + map_rel_iff' := Iff.rfl + +lemma irreducible_comp_equiv (e : H ≃* G) (ρ : Representation ℂ G V) [ρ.IsIrreducible] : + Representation.IsIrreducible (k := ℂ) (G := H) (V := V) (ρ.comp e.toMonoidHom) := + (subrepresentationCongr e ρ).isSimpleOrder_iff.mp inferInstance + +variable [Fintype G] [FiniteDimensional ℂ V] + +def classCharacter (ρ : Representation ℂ G V) : ConjClasses G → ℂ := + Quotient.lift ρ.character (fun g h hgh => by + obtain ⟨c, rfl⟩ := isConj_iff.mp hgh + exact (ρ.char_conj g c).symm) + +omit [Fintype G] [FiniteDimensional ℂ V] in +@[simp] lemma classCharacter_mk (ρ : Representation ℂ G V) (g : G) : + classCharacter ρ (ConjClasses.mk g) = ρ.character g := rfl + +def classPairRight (f : ConjClasses G → ℂ) : (ConjClasses G → ℂ) →ₗ[ℂ] ℂ where + toFun h := (Nat.card G : ℂ)⁻¹ * ∑ g, h (ConjClasses.mk g) * f (ConjClasses.mk g⁻¹) + map_add' h k := by simp only [Pi.add_apply, add_mul, Finset.sum_add_distrib]; ring + map_smul' a h := by + simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply] + rw [show (∑ g : G, a * h (ConjClasses.mk g) * f (ConjClasses.mk g⁻¹)) = + a * ∑ g : G, h (ConjClasses.mk g) * f (ConjClasses.mk g⁻¹) by + rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring] + ring + +lemma classPair_character_self (ρ : Representation ℂ G V) [ρ.IsIrreducible] : + classPairRight (classCharacter ρ) (classCharacter ρ) = 1 := by + let : Invertible (Nat.card G : ℂ) := + invertibleOfNonzero (Nat.cast_ne_zero.mpr (Nat.card_pos.ne')) + have he : Nonempty (Representation.Equiv ρ ρ) := ⟨Representation.Equiv.refl ρ⟩ + simpa [classPairRight, he] using Representation.char_orthonormal ρ ρ + +lemma classPair_characters {W : Type*} [AddCommGroup W] [Module ℂ W] + [FiniteDimensional ℂ W] (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + [ρ.IsIrreducible] [σ.IsIrreducible] : + classPairRight (classCharacter σ) (classCharacter ρ) = + if Nonempty (Representation.Equiv σ ρ) then 1 else 0 := by + let : Invertible (Nat.card G : ℂ) := + invertibleOfNonzero (Nat.cast_ne_zero.mpr (Nat.card_pos.ne')) + exact Representation.char_orthonormal ρ σ + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicCentrality.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicCentrality.lean new file mode 100644 index 0000000000000000000000000000000000000000..66d24e17e08168af74a657851003fd9326ad10d8 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicCentrality.lean @@ -0,0 +1,50 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.MatrixIsotypicWhitening +import OAI.Probability.BinarySweep.Representations.IsotypicOrthogonal + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +open Matrix + +namespace BinaryCoordinateSweeps.Irrep +open Representation Density + +variable {G V W I : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + [Fintype I] [DecidableEq I] + +lemma projection_commutes_of_adjoint_invariant (S : Submodule ℂ W) (T : Module.End ℂ W) + (hT : ∀ w ∈ S, T w ∈ S) (hTadj : ∀ w ∈ S, T.adjoint w ∈ S) (w : W) : + T (S.starProjection w)=S.starProjection (T w) := by + symm + apply S.eq_starProjection_of_mem_of_inner_eq_zero (hT _ (S.starProjection_apply_mem w)) + intro u hu + rw [← map_sub,← LinearMap.adjoint_inner_right] + exact S.starProjection_inner_eq_zero w (T.adjoint u) (hTadj u hu) + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem isotypicProjection_central (ρ : Representation ℂ G V) + (σ : Representation ℂ G (EuclideanSpace ℂ I)) + (hσ : ∀ g v, ‖σ g v‖=‖v‖) (M : Matrix I I ℂ) + (hc : ∀ g v, M.toEuclideanLin (σ g v)=σ g (M.toEuclideanLin v)) : + M*projectionMatrix (isotypicSpan ρ σ)=projectionMatrix (isotypicSpan ρ σ)*M := by + let f : IntertwiningMap σ σ := + ⟨M.toEuclideanLin,fun g => LinearMap.ext (hc g)⟩ + have hf : ∀ w ∈ isotypicSpan ρ σ, M.toEuclideanLin.adjoint w ∈ isotypicSpan ρ σ := by + intro w hw + exact map_isotypic_le ρ σ σ (adjointIntertwiner σ σ hσ hσ f) ⟨w,hw,rfl⟩ + apply Matrix.toEuclideanLin.injective + simp only [Matrix.toLpLin_mul_same,projectionMatrix_linear] + apply LinearMap.ext + intro v + exact projection_commutes_of_adjoint_invariant (isotypicSpan ρ σ) M.toEuclideanLin + (commuting_isotypic_invariant ρ σ M.toEuclideanLin hc) hf v + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicDensity.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6befcad706a043a42a6ec0fbf28ce9a74c70d58 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicDensity.lean @@ -0,0 +1,120 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedCommutant +import OAI.Probability.BinarySweep.MatrixBounds.MatrixProjection +import OAI.Probability.BinarySweep.TensorBounds.SignedPinching + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder +open Equiv Equiv.Perm Matrix Representation + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +omit [DecidableEq A] in +lemma coeff_actHilbert (p : A → Bool) (g : Equiv.Perm (Fin n)) (v : TensorSpace A n) : + coeffEquiv A n (actHilbert p g v) = act p g (coeffEquiv A n v) := rfl + +omit [DecidableEq A] in +lemma coeff_symm_act (p : A → Bool) (g : Equiv.Perm (Fin n)) (v : (Fin n → A) → ℂ) : + (coeffEquiv A n).symm (act p g v) = actHilbert p g ((coeffEquiv A n).symm v) := rfl + +def projectionIntertwiner (p : A → Bool) (S : Submodule ℂ ((Fin n → A) → ℂ)) + (hS : ∀ g, S.map (act p g) = S) : + IntertwiningMap (tensorRep p n) (tensorRep p n) where + toLinearMap := (coeffEquiv A n).conj (hilbertSubspace S).starProjection.toLinearMap + isIntertwining' g := by + apply LinearMap.ext + intro v + change coeffEquiv A n ((hilbertSubspace S).starProjection ((coeffEquiv A n).symm (act p g v))) = + act p g (coeffEquiv A n ((hilbertSubspace S).starProjection ((coeffEquiv A n).symm v))) + rw [coeff_symm_act, ← coeff_actHilbert] + congr 1 + exact (projectionMatrix_commutes (hilbertSubspace S) (actionIsometry p g) + (hilbertSubspace_map p S hS g) ((coeffEquiv A n).symm v)).symm + +lemma projectionMatrix_invariant (p : A → Bool) (S : Submodule ℂ ((Fin n → A) → ℂ)) + (hS : ∀ g, S.map (act p g) = S) : + Invariant p (projectionMatrix (hilbertSubspace S)) := by + have h := intertwiner_matrix_invariant p (projectionIntertwiner p S hS) + change Invariant p (LinearMap.toMatrix' ((coeffEquiv A n).conj + (hilbertSubspace S).starProjection.toLinearMap)) at h + rw [show coeffEquiv A n = WithLp.linearEquiv 2 ℂ ((Fin n → A) → ℂ) from rfl, + projectionMatrix_coeff] at h + exact h + +variable {V : Type*} [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + +def isotypicProjection (p : A → Bool) (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) : + Matrix (Fin n → A) (Fin n → A) ℂ := + projectionMatrix (hilbertSubspace (isotypicSpan ρ (tensorRep p n))) + +omit [FiniteDimensional ℂ V] in +lemma isotypicProjection_psd (p : A → Bool) (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) : + (isotypicProjection p ρ).PosSemidef := projectionMatrix_psd _ + +omit [FiniteDimensional ℂ V] in +lemma isotypicProjection_invariant (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) : Invariant p (isotypicProjection p ρ) := by + apply projectionMatrix_invariant + exact isotypicSpan_map ρ (tensorRep p n) + +omit [FiniteDimensional ℂ V] in +lemma isotypicProjection_trace (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) : + (isotypicProjection p ρ).trace = + (Module.finrank ℂ (isotypicSpan ρ (tensorRep p n)) : ℂ) := by + rw [isotypicProjection, projectionMatrix_trace, hilbertSubspace_finrank] + +lemma isotypicSpan_rank_bound (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] : + Module.finrank ℂ (isotypicSpan ρ (tensorRep p n)) ≤ + Module.finrank ℂ V * (n+1)^((Fintype.card A)^2) := by + exact (isotypicSpan_finrank ρ (tensorRep p n)).trans (Nat.mul_le_mul_left _ + ((multiplicity_le_commutant ρ (tensorRep p n)).trans (tensor_commutant_finrank p n))) + +theorem isotypic_density_domination (n : ℕ) (hn : 0 < n) (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] : + (((Module.finrank ℂ V : ℂ) * (n+1 : ℂ)^(2*(Fintype.card A)^2)) • + (∑ c : WordType (MatchedPair p) n, ∑ t : MatchedPair p → ZMod (n+1), + matrixTensorPower n (reducedPhaseDensity n (matchedEmbedding p) c t)) - + isotypicProjection p ρ).PosSemidef := by + let Q := ∑ c : WordType (MatchedPair p) n, ∑ t : MatchedPair p → ZMod (n+1), + matrixTensorPower n (reducedPhaseDensity n (matchedEmbedding p) c t) + have hQ : Q.PosSemidef := by + apply Matrix.posSemidef_sum + intro c _ + apply Matrix.posSemidef_sum + intro t _ + rw [reducedPhaseDensity, ← tensor_gram] + exact gram_psd _ + have hd := signed_psd_postselection n hn p (isotypicProjection p ρ) + (isotypicProjection_psd p ρ) (isotypicProjection_invariant p ρ) + rw [isotypicProjection_trace] at hd + simp only [Nat.cast_add, Nat.cast_one] at hd + have hr : (Module.finrank ℂ (isotypicSpan ρ (tensorRep p n)) : ℂ) ≤ + (Module.finrank ℂ V : ℂ) * (n+1 : ℂ)^((Fintype.card A)^2) := by + exact_mod_cast isotypicSpan_rank_bound p ρ + have hc : (0 : ℂ) ≤ (n+1 : ℂ)^((Fintype.card A)^2) := by positivity + have hh := hQ.smul (mul_nonneg hc (sub_nonneg.mpr hr)) + have he : (n+1 : ℂ)^((Fintype.card A)^2) * + ((Module.finrank ℂ V : ℂ) * (n+1 : ℂ)^((Fintype.card A)^2) - + (Module.finrank ℂ (isotypicSpan ρ (tensorRep p n)) : ℂ)) + + (n+1 : ℂ)^((Fintype.card A)^2) * + (Module.finrank ℂ (isotypicSpan ρ (tensorRep p n)) : ℂ) = + (Module.finrank ℂ V : ℂ) * (n+1 : ℂ)^(2*(Fintype.card A)^2) := by + rw [two_mul, pow_add] + ring + have hi := hh.add hd + change (_ • Q + (_ • Q - isotypicProjection p ρ)).PosSemidef at hi + rw [← add_sub_assoc, ← add_smul, he] at hi + exact hi + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicMoment.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea5112fb386756c7de653cd1ede5d8c1127859f1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicMoment.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicTrace +import OAI.Probability.BinarySweep.MatrixBounds.PositiveTraceRestriction + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + +def groupAverage (p : G → ℂ) : V →ₗ[ℂ] V := ∑ g, p g • ρ g + +def evenMoment (q : ℕ) (A : V →ₗ[ℂ] V) : ℝ := + (LinearMap.trace ℂ V ((A.adjoint*A)^q)).re + +omit [Fintype G] in +lemma unitary_rep_adjoint (hρ : ∀ g v, ‖ρ g v‖ = ‖v‖) (g : G) : + (ρ g).adjoint = ρ g⁻¹ := by + symm + apply (LinearMap.eq_adjoint_iff _ _).mpr + intro x y + let U : V →ₗᵢ[ℂ] V := { toLinearMap := ρ g, norm_map' := hρ g } + have he := U.inner_map_map (ρ g⁻¹ x) y + change inner ℂ (ρ g (ρ g⁻¹ x)) (ρ g y) = inner ℂ (ρ g⁻¹ x) y at he + rw [← Module.End.mul_apply,← map_mul,mul_inv_cancel,map_one,Module.End.one_apply] at he + exact he.symm + +omit [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma average_compatible (p : G → ℂ) (f : IntertwiningMap ρ σ) (v : V) : + groupAverage σ p (f v) = f (groupAverage ρ p v) := by + simp only [groupAverage,LinearMap.sum_apply,LinearMap.smul_apply,map_sum,map_smul, + IntertwiningMap.isIntertwining] + +lemma adjoint_average_compatible (p : G → ℂ) + (hρ : ∀ g v, ‖ρ g v‖ = ‖v‖) (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (f : IntertwiningMap ρ σ) (v : V) : + (groupAverage σ p).adjoint (f v) = f ((groupAverage ρ p).adjoint v) := by + simp only [groupAverage,map_sum,map_smulₛₗ,unitary_rep_adjoint ρ hρ, + unitary_rep_adjoint σ hσ,LinearMap.sum_apply,LinearMap.smul_apply, + IntertwiningMap.isIntertwining, RingHom.id_apply] + +lemma even_compatible (p : G → ℂ) + (hρ : ∀ g v, ‖ρ g v‖ = ‖v‖) (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (q : ℕ) (f : IntertwiningMap ρ σ) (v : V) : + (((groupAverage σ p).adjoint * groupAverage σ p)^q) (f v) = + f ((((groupAverage ρ p).adjoint * groupAverage ρ p)^q) v) := by + induction q generalizing v with + | zero => simp + | succ q ih => + rw [pow_succ',pow_succ',Module.End.mul_apply,Module.End.mul_apply,ih] + rw [Module.End.mul_apply,average_compatible,adjoint_average_compatible ρ σ p hρ hσ] + rfl + +theorem multiplicity_moment_le [ρ.IsIrreducible] (p : G → ℂ) + (hρ : ∀ g v, ‖ρ g v‖ = ‖v‖) (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) (q : ℕ) : + (Module.finrank ℂ (IntertwiningMap ρ σ) : ℝ) * evenMoment q (groupAverage ρ p) ≤ + evenMoment q (groupAverage σ p) := by + let A := ((groupAverage ρ p).adjoint * groupAverage ρ p)^q + let B := ((groupAverage σ p).adjoint * groupAverage σ p)^q + have hAB := even_compatible ρ σ p hρ hσ q + have hBp : B.IsPositive := positive_pow (LinearMap.isPositive_adjoint_comp_self _) q + have hle := positive_trace_restrict_le (isotypicSpan ρ σ) B hBp + (isotypic_invariant_of_compatible ρ σ A B hAB) + rw [isotypic_trace ρ σ A B hAB] at hle + simpa only [A, B, evenMoment, Complex.mul_re,Complex.natCast_re,Complex.natCast_im,zero_mul,sub_zero] using hle + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicOrthogonal.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicOrthogonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..c184f0a5247b44647a155ae19a3a91a53058f349 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicOrthogonal.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W Z : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + [NormedAddCommGroup Z] [InnerProductSpace ℂ Z] [FiniteDimensional ℂ Z] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) (τ : Representation ℂ G Z) + +def adjointIntertwiner (hρ : ∀ g v, ‖ρ g v‖=‖v‖) (hσ : ∀ g w, ‖σ g w‖=‖w‖) + (f : IntertwiningMap ρ σ) : IntertwiningMap σ ρ where + toLinearMap := f.toLinearMap.adjoint + isIntertwining' g := by + have he := congrArg LinearMap.adjoint (f.isIntertwining' g⁻¹) + simpa only [LinearMap.adjoint_comp,unitary_rep_adjoint ρ hρ, + unitary_rep_adjoint σ hσ,inv_inv] using he.symm + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma intertwiner_zero_of_inequivalent [ρ.IsIrreducible] [σ.IsIrreducible] + (h : ¬ Nonempty (ρ.Equiv σ)) (f : IntertwiningMap ρ σ) : f=0 := by + exact (IsIrreducible.bijective_or_eq_zero f).resolve_left (fun hf => h ⟨f.ofBijective hf⟩) + +omit [Fintype G] [FiniteDimensional ℂ W] in +theorem isotypic_orthogonal [ρ.IsIrreducible] [σ.IsIrreducible] + (hρ : ∀ g v, ‖ρ g v‖=‖v‖) (_hσ : ∀ g w, ‖σ g w‖=‖w‖) + (hτ : ∀ g z, ‖τ g z‖=‖z‖) + (hne : ¬ Nonempty (ρ.Equiv σ)) : + isotypicSpan σ τ ≤ (isotypicSpan ρ τ)ᗮ := by + unfold isotypicSpan + rw [← Submodule.iInf_orthogonal] + apply iSup_le + intro f + rw [le_iInf_iff] + intro g + rintro _ ⟨w,rfl⟩ + rw [Submodule.mem_orthogonal] + rintro _ ⟨v,rfl⟩ + have hn : ¬Nonempty (σ.Equiv ρ) := fun ⟨e⟩ => hne ⟨e.symm⟩ + have hz := intertwiner_zero_of_inequivalent σ ρ hn + ((adjointIntertwiner ρ τ hρ hτ g).comp f) + have he := congrArg (fun F : IntertwiningMap σ ρ => F w) hz + change g.toLinearMap.adjoint (f.toLinearMap w) = 0 at he + rw [← LinearMap.adjoint_inner_right,he] + simp + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicProjectionMoment.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicProjectionMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e0888d59e22e2fc00a5c3f53f67a2c333b67661 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicProjectionMoment.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedTypeCentrality +import OAI.Probability.BinarySweep.MatrixBounds.SpectralMoment + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder MonoidAlgebra +open Matrix + +namespace BinaryCoordinateSweeps +open Density Irrep Representation + +lemma euclidean_pow {I : Type*} [Fintype I] [DecidableEq I] + (M : Matrix I I ℂ) (q : ℕ) : (M^q).toEuclideanLin=M.toEuclideanLin^q := by + induction q with + | zero => simp only [pow_zero,Matrix.toLpLin_one,Module.End.one_eq_id] + | succ q ih => rw [pow_succ,Matrix.toLpLin_mul_same,ih,pow_succ,Module.End.mul_eq_comp] + +lemma projected_gram_power {I : Type*} [Fintype I] [DecidableEq I] + (P M : Matrix I I ℂ) (hP : P.IsHermitian) (hPP : P*P=P) (hPM : P*M=M*P) + {q : ℕ} (hq : 0 < q) : + (star (P*M)*(P*M))^q = (star M*M)^q*P := by + have hs : P*star M=star M*P := by + have hh := congrArg star hPM + simpa only [star_mul,show star P=P from hP.eq] using hh.symm + have hc : Commute (star M*M) P := by + change star M*M*P=P*(star M*M) + rw [mul_assoc,← hPM,← mul_assoc,← hs,mul_assoc] + have he : star (P*M)*(P*M)=(star M*M)*P := by + simp only [star_mul,show star P=P from hP.eq] + rw [mul_assoc,← mul_assoc P P M,hPP,hPM,← mul_assoc] + rw [he,hc.mul_pow,(show IsIdempotentElem P from hPP).pow_eq (ne_of_gt hq)] + +lemma trace_mul_projection {W : Type*} [NormedAddCommGroup W] [InnerProductSpace ℂ W] + [FiniteDimensional ℂ W] (S : Submodule ℂ W) (B : W →ₗ[ℂ] W) + (hS : ∀w∈S, B w∈S) : + LinearMap.trace ℂ W (B*S.starProjection.toLinearMap)= + LinearMap.trace ℂ S (B.restrict hS) := by + have hm (w : W) : (B*S.starProjection.toLinearMap) w∈S := + hS _ (S.starProjection_apply_mem w) + have he : (B*S.starProjection.toLinearMap).restrict (fun w _ => hm w)=B.restrict hS := by + ext w + change B (S.starProjection w.val)=B w.val + rw [Submodule.starProjection_eq_self_iff.mpr w.property] + rw [← LinearMap.trace_restrict_eq_of_forall_mem S _ hm,he] + +namespace Signed +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +def signedAverage (p : A → Bool) (w : Equiv.Perm (Fin n) → ℂ) : + Matrix (Fin n → A) (Fin n → A) ℂ := ∑g, w g • actionMatrix p g + +lemma signedAverage_linear (p : A → Bool) (w : Equiv.Perm (Fin n) → ℂ) : + (signedAverage p w).toEuclideanLin=groupAverage (hilbertTensorRep p n) w := by + simp only [signedAverage,map_sum,map_smul,actionMatrix_linear,groupAverage] + +omit [FiniteDimensional ℂ V] in +lemma isotypicProjection_commutes_average (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) (w : Equiv.Perm (Fin n) → ℂ) : + isotypicProjection p ρ*signedAverage p w=signedAverage p w*isotypicProjection p ρ := by + simp only [signedAverage,Finset.mul_sum,Finset.sum_mul,mul_smul_comm,smul_mul_assoc, + typeProjection_commutes_action] + +theorem local_projected_moment (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] + (hρ : ∀g v, ‖ρ g v‖=‖v‖) (w : Equiv.Perm (Fin n) → ℂ) {q : ℕ} (hq : 0 < q) : + TraceHolder.matrixMoment q (isotypicProjection p ρ*signedAverage p w)= + (Module.finrank ℂ (IntertwiningMap ρ (hilbertTensorRep p n)):ℝ)*evenMoment q (groupAverage ρ w) := by + unfold TraceHolder.matrixMoment + rw [projected_gram_power _ _ (isotypicProjection_psd p ρ).isHermitian + (projectionMatrix_idempotent _) (isotypicProjection_commutes_average p ρ w) hq] + rw [← trace_toEuclideanLinear] + simp only [Matrix.toLpLin_mul_same,← Module.End.mul_eq_comp,euclidean_pow, + Matrix.star_eq_conjTranspose,Matrix.toEuclideanLin_conjTranspose_eq_adjoint,signedAverage_linear] + have hP : (isotypicProjection p ρ).toEuclideanLin= + (isotypicSpan ρ (hilbertTensorRep p n)).starProjection.toLinearMap := by + rw [hilbert_isotypic_eq]; exact projectionMatrix_linear _ + rw [hP] + have hc := even_compatible ρ (hilbertTensorRep p n) w hρ (hilbertTensorRep_unitary p) q + rw [trace_mul_projection _ _ (isotypic_invariant_of_compatible ρ _ _ _ hc), + isotypic_trace ρ _ _ _ hc] + simp only [evenMoment,Complex.mul_re,Complex.natCast_re,Complex.natCast_im,zero_mul,sub_zero] + +lemma hilbert_multiplicity_bound (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] : + Module.finrank ℂ (IntertwiningMap ρ (hilbertTensorRep p n)) ≤ (n+1)^((Fintype.card A)^2) := by + have hd : 0 < Module.finrank ℂ V := by + let : Nontrivial ρ.asModule := IsSimpleModule.nontrivial ℂ[Equiv.Perm (Fin n)] ρ.asModule + rw [← ρ.asModuleEquiv.finrank_eq] + exact Module.finrank_pos + have h := isotypicSpan_rank_bound p ρ + rw [← hilbertSubspace_finrank,← hilbert_isotypic_eq p ρ,isotypicSpan_finrank_eq] at h + exact Nat.le_of_mul_le_mul_left h hd + +theorem local_projected_moment_le (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] + (hρ : ∀g v, ‖ρ g v‖=‖v‖) (w : Equiv.Perm (Fin n) → ℂ) {q : ℕ} (hq : 0 < q) : + TraceHolder.matrixMoment q (isotypicProjection p ρ*signedAverage p w) ≤ + (n+1:ℝ)^((Fintype.card A)^2)*evenMoment q (groupAverage ρ w) := by + rw [local_projected_moment p ρ hρ w hq] + apply mul_le_mul_of_nonneg_right + · exact_mod_cast hilbert_multiplicity_bound p ρ + · exact (Complex.nonneg_iff.mp (positive_pow (LinearMap.isPositive_adjoint_comp_self _) q).trace_nonneg).1 + +end Signed +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Fourier +open Representation + +variable (G : Type*) [Group G] [Fintype G] + +abbrev RegularSpace := EuclideanSpace ℂ G + +def regularMap (g : G) : RegularSpace G →ₗ[ℂ] RegularSpace G where + toFun v := WithLp.toLp 2 (fun x => v (g⁻¹*x)) + map_add' v w := by ext x; rfl + map_smul' a v := by ext x; rfl + +def regular : Representation ℂ G (RegularSpace G) where + toFun := regularMap G + map_one' := by ext v x; simp [regularMap] + map_mul' g h := by ext v x; simp [regularMap,mul_assoc] + +omit [Fintype G] in +@[simp] lemma regular_apply (g : G) (v : RegularSpace G) (x : G) : + regular G g v x=v (g⁻¹*x) := rfl + +lemma regular_unitary (g : G) (v : RegularSpace G) : ‖regular G g v‖=‖v‖ := by + simp only [EuclideanSpace.norm_eq] + congr 1 + exact Equiv.sum_comp (Equiv.mulLeft g⁻¹) (fun x => ‖v x‖^2) + +lemma regular_character (g : G) : + (regular G).character g=if g=1 then (Fintype.card G:ℂ) else 0 := by + rw [Representation.character,LinearMap.trace_eq_sum_inner _ (EuclideanSpace.basisFun G ℂ)] + by_cases hg : g=1 + · subst g; simp + · rw [ite_eq_right hg] + apply Finset.sum_eq_zero + intro x _ + rw [EuclideanSpace.basisFun_inner,regular_apply,EuclideanSpace.basisFun_apply] + simp only [PiLp.single_apply] + have hh : g⁻¹*x≠x := by + intro he + have := mul_right_cancel (show g⁻¹*x=1*x from by simpa using he) + exact hg (inv_eq_one.mp this) + simp [hh] + +lemma regular_multiplicity {V : Type*} [AddCommGroup V] [Module ℂ V] + [FiniteDimensional ℂ V] (ρ : Representation ℂ G V) : + Module.finrank ℂ (IntertwiningMap ρ (regular G))=Module.finrank ℂ V := by + have hc : (Nat.card G:ℂ)≠0 := by + rw [Nat.card_eq_fintype_card] + exact_mod_cast Fintype.card_ne_zero + let : Invertible (Nat.card G:ℂ) := invertibleOfNonzero hc + have hh := card_inv_mul_sum_char_mul_char_eq_finrank ρ (regular G) + simp only [regular_character,ite_mul,zero_mul] at hh + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true,inv_one,char_one] at hh + rw [←Nat.card_eq_fintype_card,←mul_assoc,inv_mul_cancel₀ hc,one_mul] at hh + exact_mod_cast hh.symm + +lemma regular_average_apply (p : G → ℂ) (v : RegularSpace G) (x : G) : + Irrep.groupAverage (regular G) p v x=∑g,p g*v (g⁻¹*x) := by + simp [Irrep.groupAverage,LinearMap.sum_apply,LinearMap.smul_apply] + +lemma regular_moment_one (p : G → ℂ) : + Irrep.evenMoment 1 (Irrep.groupAverage (regular G) p)= + (Fintype.card G:ℝ)*(∑g,‖p g‖^2) := by + unfold Irrep.evenMoment + rw [pow_one,LinearMap.trace_eq_sum_inner _ (EuclideanSpace.basisFun G ℂ)] + simp only [Complex.re_sum,Module.End.mul_apply,LinearMap.adjoint_inner_right,inner_self_eq_norm_sq_to_K] + have he (x : G) : ‖Irrep.groupAverage (regular G) p ((EuclideanSpace.basisFun G ℂ) x)‖^2= + ∑g,‖p g‖^2 := by + rw [EuclideanSpace.norm_sq_eq] + have ha (y : G) : Irrep.groupAverage (regular G) p ((EuclideanSpace.basisFun G ℂ) x) y=p (y*x⁻¹) := by + rw [regular_average_apply] + simp only [EuclideanSpace.basisFun_apply,PiLp.single_apply] + have hiff (g : G) : x=g⁻¹*y ↔ g=y*x⁻¹ := by + constructor <;> intro hh + · calc g=(g*x)*x⁻¹ := by group + _=y*x⁻¹ := by rw [hh]; simp + · subst g; group + simp_rw [eq_comm (a:=_⁻¹*y) (b:=x),hiff,mul_ite,mul_one,mul_zero] + simp + simp_rw [ha] + exact Equiv.sum_comp (Equiv.mulRight x⁻¹) (fun g => ‖p g‖^2) + change (∑i, ((‖Irrep.groupAverage (regular G) p ((EuclideanSpace.basisFun G ℂ) i)‖:ℂ)^2).re)=_ + simp only [←Complex.ofReal_pow,Complex.ofReal_re] + simp_rw [he] + simp + +end BinaryCoordinateSweeps.Fourier + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicSpectral.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicSpectral.lean new file mode 100644 index 0000000000000000000000000000000000000000..6097443986344b359f4cd5b2098458be6b0463e0 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicSpectral.lean @@ -0,0 +1,170 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.MultiplicityBound +import OAI.Probability.BinarySweep.MatrixBounds.PositiveTraceRestriction + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + +omit [Fintype G] [FiniteDimensional ℂ W] in +lemma commuting_eigenspace_map (T : Module.End ℂ W) + (hT : ∀ g w, T (σ g w) = σ g (T w)) (μ : ℂ) (g : G) : + (T.eigenspace μ).map (σ g) = T.eigenspace μ := by + apply le_antisymm + · rintro w ⟨v,hv,rfl⟩ + apply Module.End.mem_eigenspace_iff.mpr + rw [hT,Module.End.mem_eigenspace_iff.mp hv,map_smul] + · intro w hw + refine ⟨σ g⁻¹ w, ?_, ?_⟩ + · apply Module.End.mem_eigenspace_iff.mpr + rw [hT,Module.End.mem_eigenspace_iff.mp hw,map_smul] + · rw [← Module.End.mul_apply,← map_mul,mul_inv_cancel,map_one,Module.End.one_apply] + +def eigenspaceProjectionIntertwiner (T : Module.End ℂ W) + (hT : ∀ g w, T (σ g w) = σ g (T w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) (μ : ℂ) : IntertwiningMap σ σ where + toLinearMap := (T.eigenspace μ).starProjection.toLinearMap + isIntertwining' g := by + ext w + change (T.eigenspace μ).starProjection (σ g w) = σ g ((T.eigenspace μ).starProjection w) + let U : W →ₗᵢ[ℂ] W := {toLinearMap := σ g, norm_map' := hσ g} + have he := U.map_starProjection (T.eigenspace μ) w + change σ g ((T.eigenspace μ).starProjection w) = + ((T.eigenspace μ).map (σ g)).starProjection (σ g w) at he + simpa only [commuting_eigenspace_map σ T hT μ g] using he.symm + +omit [Fintype G] [FiniteDimensional ℂ V] in +lemma eigenvalue_multiplicity_ge [ρ.IsIrreducible] (T : Module.End ℂ W) + (hT : ∀ g w, T (σ g w) = σ g (T w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) (μ : ℂ) + {w : W} (hw : w ∈ isotypicSpan ρ σ) (he : T w = μ • w) (hn : w ≠ 0) : + Module.finrank ℂ V ≤ Module.finrank ℂ (T.eigenspace μ) := by + let P := eigenspaceProjectionIntertwiner σ T hT hσ μ + have hP : ∃ f : IntertwiningMap ρ σ, P.comp f ≠ 0 := by + by_contra! hall + have hz : P w = 0 := by + change w ∈ ⨆ f : IntertwiningMap ρ σ, LinearMap.range f.toLinearMap at hw + refine Submodule.iSup_induction _ (motive := fun x => P x = 0) hw ?_ (map_zero P) ?_ + · intro f x hx + obtain ⟨v,rfl⟩ := hx + exact DFunLike.congr_fun (hall f) v + · intro x y hx hy + rw [map_add,hx,hy,zero_add] + have hpw : P w = w := Submodule.starProjection_eq_self_iff.mpr + (Module.End.mem_eigenspace_iff.mpr he) + exact hn (hpw.symm.trans hz) + obtain ⟨f,hf⟩ := hP + have hi := (IsIrreducible.injective_or_eq_zero (P.comp f)).resolve_right hf + let Q : V →ₗ[ℂ] T.eigenspace μ := (P.comp f).toLinearMap.codRestrict _ + (fun v => (T.eigenspace μ).starProjection_apply_mem (f v)) + apply LinearMap.finrank_le_finrank_of_injective (f:=Q) + intro v v' hv + exact hi (congrArg Subtype.val hv) + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem isotypic_eigenvalue_trace_le [ρ.IsIrreducible] (T : Module.End ℂ W) + (hpos : T.IsPositive) (hT : ∀ g w, T (σ g w) = σ g (T w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) {μ : ℝ} (hμ : 0 ≤ μ) + {w : W} (hw : w ∈ isotypicSpan ρ σ) (he : T w = (μ:ℂ) • w) (hn : w ≠ 0) : + (Module.finrank ℂ V : ℝ) * μ ≤ (LinearMap.trace ℂ W T).re := by + let E := T.eigenspace (μ:ℂ) + have hE : ∀ x ∈ E, T x ∈ E := by + intro x hx + rw [Module.End.mem_eigenspace_iff] at hx ⊢ + rw [hx,map_smul,hx] + have hr : T.restrict hE = (μ:ℂ) • (LinearMap.id : E →ₗ[ℂ] E) := by + ext x + exact Module.End.mem_eigenspace_iff.mp x.property + have ht := positive_trace_restrict_le E T hpos hE + rw [hr,map_smul,LinearMap.trace_id] at ht + have hd := eigenvalue_multiplicity_ge ρ σ T hT hσ (μ:ℂ) hw he hn + have hd' : (Module.finrank ℂ V : ℝ) ≤ (Module.finrank ℂ E : ℝ) := by exact_mod_cast hd + have ht' : μ * (Module.finrank ℂ E : ℝ) ≤ (LinearMap.trace ℂ W T).re := by + simpa using ht + nlinarith + +end BinaryCoordinateSweeps.Irrep + +end + +open scoped BigOperators Classical ComplexOrder + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + +def commutingIntertwiner (T : Module.End ℂ W) + (hT : ∀ g w, T (σ g w) = σ g (T w)) : IntertwiningMap σ σ where + toLinearMap := T + isIntertwining' g := by ext w; exact hT g w + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma commuting_isotypic_invariant (T : Module.End ℂ W) + (hT : ∀ g w, T (σ g w) = σ g (T w)) : + ∀ w ∈ isotypicSpan ρ σ, T w ∈ isotypicSpan ρ σ := by + intro w hw + apply Submodule.iSup_induction (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) + (motive := fun w => T w ∈ isotypicSpan ρ σ) hw + · intro f w hw + obtain ⟨v,rfl⟩ := hw + let F := (commutingIntertwiner σ T hT).comp f + exact (le_iSup (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) F) ⟨v,rfl⟩ + · simp + · intro x y hx hy + simpa only [map_add] using Submodule.add_mem _ hx hy + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma isotypic_restrict_positive (T : Module.End ℂ W) (hpos : T.IsPositive) + (hT : ∀ g w, T (σ g w) = σ g (T w)) : + (T.restrict (commuting_isotypic_invariant ρ σ T hT)).IsPositive := + ⟨hpos.isSymmetric.restrict_invariant _, fun x => hpos.2 x.val⟩ + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem isotypic_restriction_cap [ρ.IsIrreducible] (T : Module.End ℂ W) + (hpos : T.IsPositive) (hT : ∀ g w, T (σ g w) = σ g (T w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) : + (((LinearMap.trace ℂ W T).re : ℂ) • (LinearMap.id : isotypicSpan ρ σ →ₗ[ℂ] isotypicSpan ρ σ) - + (Module.finrank ℂ V : ℂ) • T.restrict (commuting_isotypic_invariant ρ σ T hT)).IsPositive := by + let S := isotypicSpan ρ σ + let R := T.restrict (commuting_isotypic_invariant ρ σ T hT) + have hR : R.IsPositive := isotypic_restrict_positive ρ σ T hpos hT + let b := hR.isSymmetric.eigenvectorBasis rfl + apply (LinearMap.posSemidef_toMatrix_iff b).mp + rw [map_sub,map_smul,map_smul,LinearMap.toMatrix_id] + rw [show LinearMap.toMatrix b.toBasis b.toBasis R = + Matrix.diagonal (fun i => (hR.isSymmetric.eigenvalues rfl i : ℂ)) from + hR.isSymmetric.toMatrix_eigenvectorBasis rfl] + rw [← Matrix.diagonal_one,← Matrix.diagonal_smul,← Matrix.diagonal_smul,Matrix.diagonal_sub] + apply Matrix.posSemidef_diagonal_iff.mpr + intro i + have hi := isotypic_eigenvalue_trace_le ρ σ T hpos hT hσ + (hR.nonneg_eigenvalues rfl i) (b i).property + (congrArg Subtype.val (hR.isSymmetric.apply_eigenvectorBasis rfl i)) + (fun hz => (hR.isSymmetric.hasEigenvector_eigenvectorBasis rfl i).2 (Subtype.ext hz)) + change 0 ≤ ((LinearMap.trace ℂ W T).re : ℂ)*1 - _ + have he : (0:ℂ) ≤ (((LinearMap.trace ℂ W T).re - + (Module.finrank ℂ V : ℝ)*hR.isSymmetric.eigenvalues rfl i : ℝ):ℂ) := by + exact_mod_cast sub_nonneg.mpr hi + simpa using he + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/IsotypicTrace.lean b/lean/OAI/Probability/BinarySweep/Representations/IsotypicTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..75771d20120373fd3d0d2f13e0ce7b6a0269452b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/IsotypicTrace.lean @@ -0,0 +1,73 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.MultiplicityBound + +namespace OAI + +noncomputable section +open scoped BigOperators Classical TensorProduct + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + [AddCommGroup W] [Module ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) [ρ.IsIrreducible] + +def evaluationToIsotypic : V ⊗[ℂ] IntertwiningMap ρ σ →ₗ[ℂ] isotypicSpan ρ σ := + (evaluation ρ σ).codRestrict _ (fun x => by + rw [← evaluation_range]; exact ⟨x,rfl⟩) + +lemma evaluationToIsotypic_bijective : Function.Bijective (evaluationToIsotypic ρ σ) := by + constructor + · intro x y h + apply evaluation_injective ρ σ + exact congrArg Subtype.val h + · intro y + have hy : y.val ∈ LinearMap.range (evaluation ρ σ) := by + rw [evaluation_range]; exact y.property + obtain ⟨x,hx⟩ := hy + exact ⟨x,Subtype.ext hx⟩ + +def evaluationEquiv : V ⊗[ℂ] IntertwiningMap ρ σ ≃ₗ[ℂ] isotypicSpan ρ σ := + LinearEquiv.ofBijective (evaluationToIsotypic ρ σ) (evaluationToIsotypic_bijective ρ σ) + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] [ρ.IsIrreducible] in +lemma isotypic_invariant_of_compatible (A : V →ₗ[ℂ] V) (B : W →ₗ[ℂ] W) + (hAB : ∀ f : IntertwiningMap ρ σ, ∀ v : V, B (f v) = f (A v)) : + ∀ w ∈ isotypicSpan ρ σ, B w ∈ isotypicSpan ρ σ := by + intro w hw + apply Submodule.iSup_induction (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) + (motive := fun w => B w ∈ isotypicSpan ρ σ) hw + · intro f w hw + obtain ⟨v,rfl⟩ := hw + rw [show f.toLinearMap v = f v from rfl,hAB] + exact (le_iSup (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) f) ⟨A v,rfl⟩ + · simp + · intro x y hx hy; simpa only [map_add] using Submodule.add_mem _ hx hy + +theorem isotypic_trace (A : V →ₗ[ℂ] V) (B : W →ₗ[ℂ] W) + (hAB : ∀ f : IntertwiningMap ρ σ, ∀ v : V, B (f v) = f (A v)) : + LinearMap.trace ℂ (isotypicSpan ρ σ) + (B.restrict (isotypic_invariant_of_compatible ρ σ A B hAB)) = + (Module.finrank ℂ (IntertwiningMap ρ σ) : ℂ) * LinearMap.trace ℂ V A := by + let e := evaluationEquiv ρ σ + let C := B.restrict (isotypic_invariant_of_compatible ρ σ A B hAB) + have he : e.symm.conj C = TensorProduct.map A (LinearMap.id : + IntertwiningMap ρ σ →ₗ[ℂ] IntertwiningMap ρ σ) := by + apply TensorProduct.ext' + intro v f + apply e.injective + change e (e.symm (C (e (v ⊗ₜ[ℂ] f)))) = e (A v ⊗ₜ[ℂ] f) + rw [e.apply_symm_apply] + apply Subtype.ext + exact hAB f v + have ht := LinearMap.trace_conj' C e.symm + rw [he,LinearMap.trace_tensorProduct',LinearMap.trace_id] at ht + exact ht.symm.trans (mul_comm _ _) + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/MatrixIsotypicWhitening.lean b/lean/OAI/Probability/BinarySweep/Representations/MatrixIsotypicWhitening.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c7750cf355e12c1a9afdbabe82e33b214e28f6f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/MatrixIsotypicWhitening.lean @@ -0,0 +1,211 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.Whitening +import OAI.Probability.BinarySweep.MatrixBounds.MatrixProjection + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Irrep +open Representation Density + +variable {G V I : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [Fintype I] [DecidableEq I] + (ρ : Representation ℂ G V) (σ : Representation ℂ G (EuclideanSpace ℂ I)) + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem matrix_whitening_positive [ρ.IsIrreducible] (B C : Matrix I I ℂ) + (hC : C.IsHermitian) + (hCc : ∀ g w, C.toEuclideanLin (σ g w) = σ g (C.toEuclideanLin w)) + (hBC : B*C = 1) + (hT : ∀ g w, (B.conjTranspose*B).toEuclideanLin (σ g w) = + σ g ((B.conjTranspose*B).toEuclideanLin w)) + (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (ht : (B.conjTranspose*B).trace.re = 1) : + (C.conjTranspose*C - (Module.finrank ℂ V : ℂ) • + projectionMatrix (isotypicSpan ρ σ)).PosSemidef := by + rw [← Matrix.isPositive_toEuclideanLin_iff] + have hsym : C.toEuclideanLin.IsSymmetric := by + apply (LinearMap.isSymmetric_iff_isSelfAdjoint _).mpr + change C.toEuclideanLin.adjoint = C.toEuclideanLin + rw [← Matrix.toEuclideanLin_conjTranspose_eq_adjoint,hC.eq] + have h := whitening_positive ρ σ B.toEuclideanLin C.toEuclideanLin hsym hCc + (by simpa only [Matrix.toLpLin_mul_same,← Module.End.mul_eq_comp,Matrix.toLpLin_one,← Module.End.one_eq_id] using + congrArg Matrix.toEuclideanLin hBC) + (by simpa only [Matrix.toLpLin_mul_same,← Module.End.mul_eq_comp,Matrix.toEuclideanLin_conjTranspose_eq_adjoint] using hT) + hσ (by + rw [← Matrix.toEuclideanLin_conjTranspose_eq_adjoint,Module.End.mul_eq_comp,← Matrix.toLpLin_mul_same, + trace_toEuclideanLinear] + exact ht) + simpa only [map_sub,map_smul,projectionMatrix_linear,Matrix.toLpLin_mul_same,← Module.End.mul_eq_comp, + Matrix.toEuclideanLin_conjTranspose_eq_adjoint] using h + +end BinaryCoordinateSweeps.Irrep + +end + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W U : Type*} [Group G] + [AddCommGroup V] [Module ℂ V] [AddCommGroup W] [Module ℂ W] + [AddCommGroup U] [Module ℂ U] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) (τ : Representation ℂ G U) + +lemma map_isotypic_le (f : IntertwiningMap σ τ) : + (isotypicSpan ρ σ).map f.toLinearMap ≤ isotypicSpan ρ τ := by + rintro _ ⟨w,hw,rfl⟩ + apply Submodule.iSup_induction (fun g : IntertwiningMap ρ σ => LinearMap.range g.toLinearMap) + (motive:=fun w => f w ∈ isotypicSpan ρ τ) hw + · intro g w hw + obtain ⟨v,rfl⟩ := hw + exact (le_iSup (fun g : IntertwiningMap ρ τ => LinearMap.range g.toLinearMap) (f.comp g)) ⟨v,rfl⟩ + · simp + · intro x y hx hy; simpa only [map_add] using (isotypicSpan ρ τ).add_mem hx hy + +lemma map_isotypic_equiv (e : σ.Equiv τ) : + (isotypicSpan ρ σ).map e.toLinearEquiv.toLinearMap = isotypicSpan ρ τ := by + apply le_antisymm (map_isotypic_le ρ σ τ e.toIntertwiningMap) + intro u hu + refine ⟨e.symm u,?_,e.toLinearEquiv.apply_symm_apply u⟩ + apply map_isotypic_le ρ τ σ e.symm.toIntertwiningMap + exact ⟨u,hu,rfl⟩ + +end BinaryCoordinateSweeps.Irrep + +open scoped BigOperators Classical +open Matrix + +namespace BinaryCoordinateSweeps.Irrep +open Representation Density + +variable {G V I : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [Fintype I] [DecidableEq I] + (ρ : Representation ℂ G V) (σ : Representation ℂ G (EuclideanSpace ℂ I)) + +omit [Fintype G] [FiniteDimensional ℂ V] in +theorem isotypicProjection_commutes (M : Matrix I I ℂ) (hM : M.IsHermitian) + (hc : ∀ g v, M.toEuclideanLin (σ g v) = σ g (M.toEuclideanLin v)) : + M * projectionMatrix (isotypicSpan ρ σ) = projectionMatrix (isotypicSpan ρ σ) * M := by + apply Matrix.toEuclideanLin.injective + simp only [Matrix.toLpLin_mul_same,projectionMatrix_linear] + apply LinearMap.ext + intro v + change M.toEuclideanLin ((isotypicSpan ρ σ).starProjection v) = + (isotypicSpan ρ σ).starProjection (M.toEuclideanLin v) + apply symmetric_projection_commutes + · apply (LinearMap.isSymmetric_iff_isSelfAdjoint _).mpr + change M.toEuclideanLin.adjoint = M.toEuclideanLin + rw [← Matrix.toEuclideanLin_conjTranspose_eq_adjoint,hM.eq] + · exact commuting_isotypic_invariant ρ σ M.toEuclideanLin hc + +end BinaryCoordinateSweeps.Irrep + +end + +open scoped BigOperators Classical MonoidAlgebra + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +universe uG uW uV uI +variable {G : Type uG} [Group G] [Fintype G] + {W : Type uW} [AddCommGroup W] [Module ℂ W] + (σ : Representation ℂ G W) + +def algebraSubmoduleInclusion (m : Submodule ℂ[G] σ.asModule) : + IntertwiningMap (Representation.ofModule (k:=ℂ) (G:=G) m) σ where + toFun v := σ.asModuleEquiv (m.subtype (RestrictScalars.addEquiv ℂ ℂ[G] m v)) + map_add' x y := by simp + map_smul' c v := by + simp only [RestrictScalars.addEquiv_map_smul,algebraMap_smul,RingHom.id_apply] + change σ.asModuleEquiv (c • (m.subtype (RestrictScalars.addEquiv ℂ ℂ[G] m v))) = _ + exact map_smul σ.asModuleEquiv c _ + isIntertwining' g := by + apply LinearMap.ext + intro v + change σ.asModuleEquiv (m.subtype ((RestrictScalars.addEquiv ℂ ℂ[G] m) + (Representation.ofModule m g v))) = σ g + (σ.asModuleEquiv (m.subtype (RestrictScalars.addEquiv ℂ ℂ[G] m v))) + rw [← Representation.asAlgebraHom_of,Representation.ofModule_asAlgebraHom_apply_apply] + simp only [AddEquiv.apply_symm_apply,map_smul,Representation.asModuleEquiv_map_smul, + Representation.asAlgebraHom_of] + +omit [Fintype G] in +lemma algebraSubmoduleInclusion_injective (m : Submodule ℂ[G] σ.asModule) : + Function.Injective (algebraSubmoduleInclusion σ m) := by + intro x y h + apply (RestrictScalars.addEquiv ℂ ℂ[G] m).injective + apply Subtype.val_injective + exact σ.asModuleEquiv.injective h + +variable [FiniteDimensional ℂ W] + {I : Type uI} {V : I → Type uV} + [∀ i, AddCommGroup (V i)] [∀ i, Module ℂ (V i)] + [∀ i, FiniteDimensional ℂ (V i)] + (ρ : ∀ i, Representation ℂ G (V i)) + +omit [∀ i, FiniteDimensional ℂ (V i)] in +theorem iSup_isotypic_eq_top + (complete : ∀ (U : Type uW) [AddCommGroup U] [Module ℂ U] [FiniteDimensional ℂ U] + (τ : Representation ℂ G U), τ.IsIrreducible → ∃ i, Nonempty (τ.Equiv (ρ i))) : + (⨆ i, isotypicSpan (ρ i) σ) = ⊤ := by + let T : Subrepresentation σ := { + toSubmodule := ⨆ i, isotypicSpan (ρ i) σ + apply_mem_toSubmodule := by + intro g v hv + apply Submodule.iSup_induction (fun i => isotypicSpan (ρ i) σ) + (motive:=fun v => σ g v ∈ ⨆ i, isotypicSpan (ρ i) σ) hv + · intro i v hv + apply (le_iSup (fun i => isotypicSpan (ρ i) σ) i) + rw [← isotypicSpan_map (ρ i) σ g] + exact ⟨v,hv,rfl⟩ + · simp + · intro x y hx hy; simpa only [map_add] using Submodule.add_mem _ hx hy } + have htop : T.asSubmodule = ⊤ := by + apply top_unique + rw [← IsSemisimpleModule.sSup_simples_eq_top ℂ[G] σ.asModule] + apply sSup_le + intro m hm + let group : AddCommGroup (RestrictScalars ℂ ℂ[G] m) := + Module.addCommMonoidToAddCommGroup ℂ + let _ := group + let _ : @Module ℂ (RestrictScalars ℂ ℂ[G] m) _ group.toAddCommMonoid := + RestrictScalars.module ℂ ℂ[G] m + let τ := Representation.ofModule (k:=ℂ) (G:=G) m + let f := algebraSubmoduleInclusion σ m + have : FiniteDimensional ℂ (RestrictScalars ℂ ℂ[G] m) := + FiniteDimensional.of_injective f.toLinearMap (algebraSubmoduleInclusion_injective σ m) + have : IsSimpleModule ℂ[G] m := hm + have hτ : τ.IsIrreducible := + (Representation.isSimpleModule_iff_irreducible_ofModule m).mp hm + obtain ⟨i,⟨e⟩⟩ := complete _ τ hτ + intro x hx + let v : RestrictScalars ℂ ℂ[G] m := (RestrictScalars.addEquiv ℂ ℂ[G] m).symm ⟨x,hx⟩ + change σ.asModuleEquiv x ∈ ⨆ i, isotypicSpan (ρ i) σ + apply (le_iSup (fun i => isotypicSpan (ρ i) σ) i) + apply (le_iSup (fun f : IntertwiningMap (ρ i) σ => LinearMap.range f.toLinearMap) + (f.comp e.symm.toIntertwiningMap)) + refine ⟨e.toLinearEquiv.toFun v,?_⟩ + change f (e.toLinearEquiv.symm.toFun (e.toLinearEquiv.toFun v)) = σ.asModuleEquiv x + exact congrArg f.toLinearMap.toFun (e.toLinearEquiv.symm_apply_apply v) + have hT : T = ⊤ := Subrepresentation.subrepresentationSubmoduleOrderIso.injective + (htop.trans (Subrepresentation.subrepresentationSubmoduleOrderIso.map_top).symm) + exact congrArg Subrepresentation.toSubmodule hT + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/MultiplicityBound.lean b/lean/OAI/Probability/BinarySweep/Representations/MultiplicityBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f989f5899702ab5ecf0c097912283a46457bea9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/MultiplicityBound.lean @@ -0,0 +1,203 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators MonoidAlgebra Classical TensorProduct + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + [AddCommGroup W] [Module ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + +omit [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma intertwiner_retraction (f : IntertwiningMap ρ σ) (hf : Function.Injective f) : + ∃ r : IntertwiningMap σ ρ, ∀ v, r (f v) = v := by + let fm := IntertwiningMap.equivLinearMapAsModule ρ σ f + have hm : LinearMap.ker fm = ⊥ := LinearMap.ker_eq_bot.mpr hf + have : NeZero (Nat.card G : ℂ) := ⟨by exact_mod_cast Nat.card_pos.ne'⟩ + obtain ⟨r,hr⟩ := MonoidAlgebra.exists_leftInverse_of_injective fm hm + refine ⟨(IntertwiningMap.equivLinearMapAsModule σ ρ).symm r, fun v => ?_⟩ + exact DFunLike.congr_fun hr v + +theorem multiplicity_le_commutant [ρ.IsIrreducible] : + Module.finrank ℂ (IntertwiningMap ρ σ) ≤ Module.finrank ℂ (IntertwiningMap σ σ) := by + by_cases h : ∃ f : IntertwiningMap ρ σ, f ≠ 0 + · obtain ⟨f,hf⟩ := h + have hfi : Function.Injective f := (IsIrreducible.injective_or_eq_zero f).resolve_right hf + obtain ⟨r,hr⟩ := intertwiner_retraction ρ σ f hfi + let T : IntertwiningMap ρ σ →ₗ[ℂ] IntertwiningMap σ σ := + (IntertwiningMap.llcomp σ ρ σ).flip r + have hT : Function.Injective T := by + intro a b hab + ext v + have hh := congrArg (fun t : IntertwiningMap σ σ => t (f v)) hab + change a (r (f v)) = b (r (f v)) at hh + change a v = b v + simpa only [hr] using hh + exact LinearMap.finrank_le_finrank_of_injective hT + · have hs : Subsingleton (IntertwiningMap ρ σ) := ⟨by + intro a b + have ha : a=0 := by_contra (fun ha => h ⟨a,ha⟩) + have hb : b=0 := by_contra (fun hb => h ⟨b,hb⟩) + exact ha.trans hb.symm⟩ + rw [Module.finrank_eq_zero_of_subsingleton] + exact Nat.zero_le _ + +def isotypicSpan : Submodule ℂ W := + ⨆ f : IntertwiningMap ρ σ, LinearMap.range f.toLinearMap + +def evaluation : V ⊗[ℂ] IntertwiningMap ρ σ →ₗ[ℂ] W := + TensorProduct.lift { + toFun := fun v => { + toFun := fun f => f v + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + map_add' := by intro u v; ext f; exact map_add f u v + map_smul' := by intro c v; ext f; exact map_smul f c v } + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma evaluation_range : LinearMap.range (evaluation ρ σ) = isotypicSpan ρ σ := by + apply le_antisymm + · rintro _ ⟨t,rfl⟩ + induction t using TensorProduct.inductionOn with + | tmul v f => + exact (le_iSup (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) f) ⟨v,rfl⟩ + | add t u ht hu => simpa only [map_add] using Submodule.add_mem _ ht hu + · apply iSup_le + intro f w hw + obtain ⟨v,rfl⟩ := hw + exact ⟨TensorProduct.tmul ℂ v f, rfl⟩ + +omit [Fintype G] in +lemma isotypicSpan_finrank : Module.finrank ℂ (isotypicSpan ρ σ) ≤ + Module.finrank ℂ V * Module.finrank ℂ (IntertwiningMap ρ σ) := by + rw [← evaluation_range] + simpa only [Module.finrank_tensorProduct] using LinearMap.finrank_range_le (evaluation ρ σ) + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma isotypicSpan_stable (g : G) (w : W) (hw : w ∈ isotypicSpan ρ σ) : + σ g w ∈ isotypicSpan ρ σ := by + apply Submodule.iSup_induction (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) + (motive := fun w => σ g w ∈ isotypicSpan ρ σ) hw + · intro f x hx + obtain ⟨v,rfl⟩ := hx + change σ g (f v) ∈ isotypicSpan ρ σ + rw [← IntertwiningMap.isIntertwining ρ σ f g v] + exact (le_iSup (fun f : IntertwiningMap ρ σ => LinearMap.range f.toLinearMap) f) + ⟨ρ g v,rfl⟩ + · simpa only [map_zero] using (isotypicSpan ρ σ).zero_mem + · intro x y hx hy + simpa only [map_add] using (isotypicSpan ρ σ).add_mem hx hy + +omit [Fintype G] [FiniteDimensional ℂ V] [FiniteDimensional ℂ W] in +lemma isotypicSpan_map (g : G) : (isotypicSpan ρ σ).map (σ g) = isotypicSpan ρ σ := by + apply le_antisymm + · rintro _ ⟨w,hw,rfl⟩ + exact isotypicSpan_stable ρ σ g w hw + · intro w hw + refine ⟨σ g⁻¹ w, isotypicSpan_stable ρ σ g⁻¹ w hw, ?_⟩ + simp only [← Module.End.mul_apply, ← map_mul, mul_inv_cancel, map_one, Module.End.one_apply] + +end BinaryCoordinateSweeps.Irrep + +end + +open scoped BigOperators Classical TensorProduct + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W : Type*} [Group G] [Fintype G] + [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + [AddCommGroup W] [Module ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) [ρ.IsIrreducible] + +def schurScalar : IntertwiningMap ρ ρ ≃ₗ[ℂ] ℂ := + (LinearEquiv.ofBijective (Algebra.linearMap ℂ (IntertwiningMap ρ ρ)) + IsIrreducible.algebraMap_intertwiningMap_bijective_of_isAlgClosed).symm + +omit [Fintype G] in +lemma schurScalar_smul (f : IntertwiningMap ρ ρ) (v : V) : + schurScalar ρ f • v = f v := by + have he := (schurScalar ρ).symm_apply_apply f + exact congrArg (fun t : IntertwiningMap ρ ρ => t v) he + +omit [Fintype G] in +lemma schurScalar_one : schurScalar ρ (1 : IntertwiningMap ρ ρ) = 1 := by + apply (schurScalar ρ).symm.injective + rw [LinearEquiv.symm_apply_apply] + change (1 : IntertwiningMap ρ ρ) = algebraMap ℂ (IntertwiningMap ρ ρ) 1 + exact (map_one _).symm + +def intertwinerPairing : IntertwiningMap ρ σ →ₗ[ℂ] + IntertwiningMap σ ρ →ₗ[ℂ] ℂ := + (LinearMap.compr₂ ((IntertwiningMap.llcomp ρ σ ρ).flip) (schurScalar ρ).toLinearMap) + +omit [FiniteDimensional ℂ W] in +lemma intertwinerPairing_injective : Function.Injective (intertwinerPairing ρ σ) := by + apply (LinearMap.ker_eq_bot).mp + apply le_antisymm _ bot_le + intro f hf + change f = 0 + by_contra hn + have hfi := (IsIrreducible.injective_or_eq_zero f).resolve_right hn + obtain ⟨r,hr⟩ := intertwiner_retraction ρ σ f hfi + have hc : r.comp f = 1 := by ext v; exact hr v + have hz : intertwinerPairing ρ σ f = 0 := hf + have he := DFunLike.congr_fun hz r + change schurScalar ρ (r.comp f) = 0 at he + rw [hc,schurScalar_one] at he + exact one_ne_zero he + +lemma exists_intertwiner_dual (l : Module.Dual ℂ (IntertwiningMap ρ σ)) : + ∃ r : IntertwiningMap σ ρ, ∀ f : IntertwiningMap ρ σ, ∀ v : V, + r (f v) = l f • v := by + have hs := (LinearMap.flip_surjective_iff₁ (B := intertwinerPairing ρ σ)).mpr + (intertwinerPairing_injective ρ σ) + obtain ⟨r,hr⟩ := hs l + refine ⟨r,fun f v => ?_⟩ + have he := DFunLike.congr_fun hr f + change schurScalar ρ (r.comp f) = l f at he + rw [← he] + exact (schurScalar_smul ρ (r.comp f) v).symm + +theorem evaluation_injective : Function.Injective (evaluation ρ σ) := by + let b := Module.finBasis ℂ (IntertwiningMap ρ σ) + let e := TensorProduct.equivFinsuppOfBasisRight (M := V) b + apply (LinearMap.ker_eq_bot).mp + apply le_antisymm _ bot_le + intro t ht + change t = 0 + have ht0 : evaluation ρ σ t = 0 := ht + apply e.injective + apply Finsupp.ext + intro i + obtain ⟨r,hr⟩ := exists_intertwiner_dual ρ σ (b.coord i) + have he : ∀ x : V ⊗[ℂ] IntertwiningMap ρ σ, + r (evaluation ρ σ x) = e x i := by + intro x + induction x using TensorProduct.inductionOn with + | tmul v f => + change r (f v) = _ + rw [hr] + exact (TensorProduct.equivFinsuppOfBasisRight_apply_tmul_apply b v f i).symm + | add x y hx hy => simp only [map_add,Finsupp.add_apply,hx,hy] + simpa only [ht0,map_zero,Finsupp.zero_apply] using (he t).symm + +lemma isotypicSpan_finrank_eq : Module.finrank ℂ (isotypicSpan ρ σ) = + Module.finrank ℂ V * Module.finrank ℂ (IntertwiningMap ρ σ) := by + rw [← evaluation_range, LinearMap.finrank_range_of_inj (evaluation_injective ρ σ), + Module.finrank_tensorProduct] + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Representations/UnitaryTransport.lean b/lean/OAI/Probability/BinarySweep/Representations/UnitaryTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab2d022d74829906ea4f156ad760520e31381f37 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Representations/UnitaryTransport.lean @@ -0,0 +1,52 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IsotypicMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +section Algebra +variable {G V W : Type*} [Group G] [AddCommGroup V] [Module ℂ V] + [AddCommGroup W] [Module ℂ W] + +def conjugateRep (ρ : Representation ℂ G V) (e : V ≃ₗ[ℂ] W) : Representation ℂ G W := + e.conjRingEquiv.toMonoidHom.comp ρ + +def conjugateEquiv (ρ : Representation ℂ G V) (e : V ≃ₗ[ℂ] W) : ρ.Equiv (conjugateRep ρ e) := + .mk e (by intro g; ext v; change e (ρ g v) = e (ρ g (e.symm (e v))); rw [e.symm_apply_apply]) + +lemma irreducible_equiv (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + (e : ρ.Equiv σ) [ρ.IsIrreducible] : σ.IsIrreducible := by + apply (irreducible_iff_isSimpleModule_asModule σ).mpr + exact IsSimpleModule.congr (LinearEquiv.ofBijective + (IntertwiningMap.equivLinearMapAsModule ρ σ e.toIntertwiningMap) e.toLinearEquiv.bijective).symm + +end Algebra +variable {G V W : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) + +lemma equivalent_evenMoment (e : ρ.Equiv σ) + (hρ : ∀ g v, ‖ρ g v‖ = ‖v‖) (hσ : ∀ g w, ‖σ g w‖ = ‖w‖) + (p : G → ℂ) (q : ℕ) : + evenMoment q (groupAverage ρ p) = evenMoment q (groupAverage σ p) := by + have he : e.toLinearEquiv.conj (((groupAverage ρ p).adjoint * groupAverage ρ p)^q) = + ((groupAverage σ p).adjoint * groupAverage σ p)^q := by + ext w + obtain ⟨v,rfl⟩ := e.toLinearEquiv.surjective w + simp only [LinearEquiv.conj_apply,LinearMap.comp_apply,LinearEquiv.coe_coe, + LinearEquiv.symm_apply_apply] + exact (even_compatible ρ σ p hρ hσ q e.toIntertwiningMap v).symm + unfold evenMoment + rw [← he,LinearMap.trace_conj'] + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredLineMoment.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredLineMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cbf5c7ba6a53feb89bcfe393ce4eaa8c0ee30e5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredLineMoment.lean @@ -0,0 +1,90 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.FallingMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +open Polynomial + +lemma lineMoment_stein (m h : ℕ) (P : ℝ[X]) (hp : h+P.natDegree < m) : + lineMoment m h (stein m h P) = 0 := by + let L := (lineMoment m h).comp (stein m h) + change L P = 0 + conv_lhs => rw [← P.sum_monomial_eq] + simp only [Polynomial.sum_def,map_sum] + apply Finset.sum_eq_zero + intro n hn + exact lineMoment_stein_monomial (show h+n < m from lt_of_le_of_lt + (Nat.add_le_add_left (le_natDegree_of_ne_zero (mem_support_iff.mp hn)) h) hp) _ + +lemma lineMoment_C_mul (m h : ℕ) (a : ℝ) (P : ℝ[X]) : + lineMoment m h (C a * P) = a * lineMoment m h P := by + rw [← smul_eq_C_mul,map_smul,smul_eq_mul] + +def centeredLineMoment (m h u v : ℕ) : ℝ := + lineMoment m h (X^v*(X-1)^u) + +@[simp] lemma centeredLineMoment_zero (m h v : ℕ) : + centeredLineMoment m h 0 v = fallingMoment m h v := by + simp only [centeredLineMoment,pow_zero,mul_one,lineMoment_X_pow] + +lemma X_derivative_X_pow (v : ℕ) : + (X:ℝ[X]) * derivative (X^v) = C (v:ℝ) * X^v := by + cases v with + | zero => simp + | succ v => simp only [derivative_X_pow, Nat.add_sub_cancel]; ring + +lemma stein_centered (m h u v : ℕ) : + stein m h (X^v*(X-1)^(u+1)) = + C ((m:ℝ)-h-v-u-1) * (X^v*(X-1)^(u+2)) - + C ((h:ℝ)+v+2*u+2) * (X^v*(X-1)^(u+1)) - + C ((u:ℝ)+1) * (X^v*(X-1)^u) := by + rw [stein_apply,derivative_mul] + have hv := X_derivative_X_pow v + have hd : derivative ((X-1)^(u+1) : ℝ[X]) = C ((u:ℝ)+1)*(X-1)^u := by + simp [derivative_pow,derivative_sub,Nat.cast_add] + rw [hd] + have he : (X:ℝ[X])^2 * (derivative (X^v)*(X-1)^(u+1)) = + C (v:ℝ)*X^(v+1)*(X-1)^(u+1) := by + rw [show (X:ℝ[X])^2 * (derivative (X^v)*(X-1)^(u+1)) = + X * (X*derivative (X^v))*(X-1)^(u+1) from by ring,hv,pow_succ] + ring + rw [mul_add,he] + simp only [map_sub,map_add,map_mul,map_one,C_ofNat,pow_succ] + ring + +lemma centeredLineMoment_recurrence {m h u v : ℕ} (hu : h+v+u+1 < m) : + ((m:ℝ)-h-v-u-1) * centeredLineMoment m h (u+2) v = + ((h:ℝ)+v+2*u+2) * centeredLineMoment m h (u+1) v + + ((u:ℝ)+1) * centeredLineMoment m h u v := by + have hp : (X^v*(X-1)^(u+1) : ℝ[X]).natDegree ≤ v+(u+1) := by + apply natDegree_mul_le.trans + simp only [natDegree_pow,natDegree_X,mul_one] + exact Nat.add_le_add_left (by simpa using + (Nat.mul_le_mul_left (u+1) (natDegree_X_sub_C_le (1:ℝ)))) v + have hs := lineMoment_stein m h (X^v*(X-1)^(u+1)) (by omega) + rw [stein_centered] at hs + simp only [LinearMap.map_sub,lineMoment_C_mul] at hs + change _ * centeredLineMoment m h (u+2) v - + _ * centeredLineMoment m h (u+1) v - _ * centeredLineMoment m h u v = 0 at hs + linarith + +lemma centeredLineMoment_one {m h v : ℕ} (hv : h+v < m) : + ((m:ℝ)-h-v) * centeredLineMoment m h 1 v = + ((h:ℝ)+v) * fallingMoment m h v := by + have he : centeredLineMoment m h 1 v = + fallingMoment m h (v+1) - fallingMoment m h v := by + rw [centeredLineMoment,pow_one,mul_sub,mul_one,← pow_succ,map_sub, + lineMoment_X_pow,lineMoment_X_pow] + rw [he] + have hh := fallingMoment_succ hv + linear_combination hh + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredMoment.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ed18e8be4b0cdd808617f5e95f5a556aafee2bb --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredMoment.lean @@ -0,0 +1,77 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.CenteredPlacement + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +variable {G V W : Type*} [Group G] [Fintype G] + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + +lemma groupAverage_adjoint (ρ : Representation ℂ G V) + (hρ : ∀g v, ‖ρ g v‖=‖v‖) (p : G → ℂ) : + (groupAverage ρ p).adjoint=groupAverage ρ (fun g => star (p g⁻¹)) := by + simp only [groupAverage,map_sum,map_smulₛₗ,unitary_rep_adjoint ρ hρ,starRingEnd_apply] + have he := Equiv.sum_comp (Equiv.inv G) (fun g => star (p g⁻¹) • ρ g) + simpa only [Equiv.inv_apply,inv_inv] using he + +lemma even_compatible_maps (A : V →ₗ[ℂ] V) (B : W →ₗ[ℂ] W) + (f : V →ₗ[ℂ] W) (hf : ∀v, B (f v)=f (A v)) + (hs : ∀v, B.adjoint (f v)=f (A.adjoint v)) (q : ℕ) (v : V) : + ((B.adjoint*B)^q) (f v)=f (((A.adjoint*A)^q) v) := by + induction q generalizing v with + | zero => simp + | succ q ih => + rw [pow_succ',pow_succ',Module.End.mul_apply,Module.End.mul_apply,ih] + rw [Module.End.mul_apply,hf,hs] + rfl + +theorem evenMoment_le_of_injective (A : V →ₗ[ℂ] V) (B : W →ₗ[ℂ] W) + (f : V →ₗ[ℂ] W) (hi : Function.Injective f) + (hf : ∀v, B (f v)=f (A v)) (hs : ∀v, B.adjoint (f v)=f (A.adjoint v)) (q : ℕ) : + evenMoment q A ≤ evenMoment q B := by + let S := LinearMap.range f + let a := (A.adjoint*A)^q + let b := (B.adjoint*B)^q + have hb : ∀w∈S, b w∈S := by + intro w hw + obtain ⟨v,rfl⟩ := hw + exact ⟨a v,(even_compatible_maps A B f hf hs q v).symm⟩ + let e : V ≃ₗ[ℂ] S := LinearEquiv.ofInjective f hi + have he : e.symm.conj (b.restrict hb)=a := by + apply LinearMap.ext + intro v + apply e.injective + change e (e.symm ((b.restrict hb) (e v)))=e (a v) + rw [LinearEquiv.apply_symm_apply] + apply Subtype.ext + exact even_compatible_maps A B f hf hs q v + have ht := LinearMap.trace_conj' (b.restrict hb) e.symm + rw [he] at ht + have hle := positive_trace_restrict_le S b + (positive_pow (LinearMap.isPositive_adjoint_comp_self B) q) hb + rw [← ht] at hle + exact hle + +end BinaryCoordinateSweeps.Irrep +namespace BinaryCoordinateSweeps.Young + +theorem centeredHilbert_moment (μ : YoungDiagram) (s : ℝ) (hs : s≠0) + (p : G μ → ℂ) (q : ℕ) : + Irrep.evenMoment q (Irrep.groupAverage (hilbertSpecht μ) p) ≤ + Irrep.evenMoment q (centeredHilbert (I:=Tail μ) s p) := by + apply Irrep.evenMoment_le_of_injective _ _ (spechtPlacementHilbert μ) + (spechtPlacementHilbert_injective μ) + · exact centeredHilbert_specht μ s hs p + · intro v + rw [centeredHilbert_adjoint,Irrep.groupAverage_adjoint _ (hilbertSpecht_unitary μ)] + exact centeredHilbert_specht μ s hs _ v + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredPlacement.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredPlacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b940f2107ac19552cb02e5704862c848ac3f15b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredPlacement.lean @@ -0,0 +1,200 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.AugmentedComplement + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] + +omit [DecidableEq I] [Fintype X] [DecidableEq X] in +lemma subPlacement_univ_injective : + Function.Injective (subPlacement (X:=X) (Finset.univ : Finset I)) := by + intro x y he + ext i + exact congrArg (fun t => t ⟨i,Finset.mem_univ _⟩) he + + def partialPlacement (A : Finset I) (g : Equiv.Perm X) : + ((I ↪ X) → ℂ) →ₗ[ℂ] ((I ↪ X) → ℂ) where + toFun v y := placementMarginal A v (movePlacement g⁻¹ (subPlacement A y)) + map_add' v w := by ext y; simp only [map_add,Pi.add_apply] + map_smul' c v := by ext y; simp only [map_smul,RingHom.id_apply,Pi.smul_apply] + +omit [DecidableEq I] in +lemma partialPlacement_apply (A : Finset I) (g : Equiv.Perm X) + (v : (I ↪ X) → ℂ) (y : I ↪ X) : + partialPlacement A g v y = ∑x : I ↪ X, + if subPlacement A (movePlacement g x)=subPlacement A y then v x else 0 := by + simp only [partialPlacement,placementMarginal,LinearMap.coe_mk,AddHom.coe_mk, + move_sub_eq_iff] + +omit [DecidableEq I] in +lemma partialPlacement_univ (g : Equiv.Perm X) : + partialPlacement (Finset.univ : Finset I) g = placementRep g := by + apply LinearMap.ext + intro v + funext y + change (∑x : I ↪ X, + if subPlacement Finset.univ x=movePlacement g⁻¹ (subPlacement Finset.univ y) + then v x else 0)=v (movePlacement g⁻¹ y) + simp only [← subPlacement_move,subPlacement_univ_injective.eq_iff] + simp + + def placementAverage (p : Equiv.Perm X → ℂ) : + ((I ↪ X) → ℂ) →ₗ[ℂ] ((I ↪ X) → ℂ) := ∑g, p g • placementRep g + + def partialPlacementAverage (A : Finset I) (p : Equiv.Perm X → ℂ) : + ((I ↪ X) → ℂ) →ₗ[ℂ] ((I ↪ X) → ℂ) := ∑g, p g • partialPlacement A g + + def centeredPlacement (s : ℂ) (p : Equiv.Perm X → ℂ) : + ((I ↪ X) → ℂ) →ₗ[ℂ] ((I ↪ X) → ℂ) := + ∑A ∈ (Finset.univ : Finset I).powerset, + ((-1:ℂ)^(Fintype.card I-A.card)*s^A.card/s^Fintype.card I) • partialPlacementAverage A p + +lemma partialPlacement_specht_zero (μ : YoungDiagram) (A : Finset (Tail μ)) + (hA : A≠Finset.univ) (g : G μ) (v : SpechtSpace μ) : + partialPlacement A g (spechtPlacement μ v)=0 := by + ext y + change placementMarginal A (spechtPlacement μ v) _=0 + rw [spechtPlacement_marginal_zero μ A hA] + rfl + +lemma partialPlacementAverage_specht_zero (μ : YoungDiagram) (A : Finset (Tail μ)) + (hA : A≠Finset.univ) (p : G μ → ℂ) (v : SpechtSpace μ) : + partialPlacementAverage A p (spechtPlacement μ v)=0 := by + simp only [partialPlacementAverage,LinearMap.sum_apply,LinearMap.smul_apply, + partialPlacement_specht_zero μ A hA,smul_zero,Finset.sum_const_zero] + +theorem centeredPlacement_specht (μ : YoungDiagram) (s : ℂ) (hs : s≠0) + (p : G μ → ℂ) (v : SpechtSpace μ) : + centeredPlacement s p (spechtPlacement μ v) = + placementAverage p (spechtPlacement μ v) := by + unfold centeredPlacement + simp only [LinearMap.sum_apply,LinearMap.smul_apply] + rw [Finset.sum_eq_single Finset.univ] + · simp only [Finset.card_univ,Nat.sub_self,pow_zero,one_mul, + div_self (pow_ne_zero _ hs),one_smul,partialPlacementAverage, + partialPlacement_univ,placementAverage,LinearMap.sum_apply,LinearMap.smul_apply] + · intro A _ hA + rw [partialPlacementAverage_specht_zero μ A hA,smul_zero] + · intro hn + exact (hn (Finset.mem_powerset.mpr (Finset.Subset.refl _))).elim + +lemma placementAverage_specht (μ : YoungDiagram) (p : G μ → ℂ) (v : SpechtSpace μ) : + placementAverage p (spechtPlacement μ v)= + spechtPlacement μ (∑g, p g • spechtRep μ g v) := by + simp only [placementAverage,LinearMap.sum_apply,LinearMap.smul_apply,map_sum,map_smul, + spechtPlacement_intertwines] + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] + + def placementCoeffs : EuclideanSpace ℂ (I ↪ X) ≃ₗ[ℂ] ((I ↪ X) → ℂ) := + WithLp.linearEquiv 2 ℂ _ + def partialHilbert (A : Finset I) (g : Equiv.Perm X) : + EuclideanSpace ℂ (I ↪ X) →ₗ[ℂ] EuclideanSpace ℂ (I ↪ X) := + placementCoeffs.symm.conj (partialPlacement A g) + def partialKernel (A : Finset I) (g : Equiv.Perm X) : Matrix (I ↪ X) (I ↪ X) ℂ := + fun y x => if subPlacement A (movePlacement g x)=subPlacement A y then 1 else 0 + +omit [DecidableEq I] in +lemma partialKernel_toLin (A : Finset I) (g : Equiv.Perm X) : + (partialKernel A g).toEuclideanLin=partialHilbert A g := by + apply LinearMap.ext + intro v + apply (placementCoeffs (I:=I) (X:=X)).injective + funext y + change (∑x, partialKernel A g y x*v x)=partialPlacement A g (placementCoeffs v) y + rw [partialPlacement_apply] + apply Finset.sum_congr rfl + intro x _ + dsimp [partialKernel] + split_ifs <;> simp [placementCoeffs] + +omit [Fintype I] [DecidableEq I] [Fintype X] in +lemma partialKernel_adjoint (A : Finset I) (g : Equiv.Perm X) : + (partialKernel A g).conjTranspose=partialKernel A g⁻¹ := by + ext y x + have he : subPlacement A (movePlacement g y)=subPlacement A x ↔ + subPlacement A (movePlacement g⁻¹ x)=subPlacement A y := by + rw [move_sub_eq_iff,← subPlacement_move] + exact eq_comm + simp only [Matrix.conjTranspose_apply,partialKernel,he] + split_ifs <;> simp + +omit [DecidableEq I] in +lemma partialHilbert_adjoint (A : Finset I) (g : Equiv.Perm X) : + (partialHilbert A g).adjoint=partialHilbert A g⁻¹ := by + rw [← partialKernel_toLin,← Matrix.toEuclideanLin_conjTranspose_eq_adjoint, + partialKernel_adjoint,partialKernel_toLin] + + def centeredHilbert (s : ℝ) (p : Equiv.Perm X → ℂ) : + EuclideanSpace ℂ (I ↪ X) →ₗ[ℂ] EuclideanSpace ℂ (I ↪ X) := + placementCoeffs.symm.conj (centeredPlacement (s:ℂ) p) + +omit [DecidableEq I] in +lemma centeredHilbert_sum (s : ℝ) (p : Equiv.Perm X → ℂ) : + centeredHilbert (I:=I) s p = ∑A ∈ (Finset.univ : Finset I).powerset, + ((-1:ℂ)^(Fintype.card I-A.card)*(s:ℂ)^A.card/(s:ℂ)^Fintype.card I) • + ∑g, p g • partialHilbert A g := by + simp only [centeredHilbert,centeredPlacement,partialPlacementAverage,map_sum,map_smul, + partialHilbert] + +omit [DecidableEq I] in +lemma centeredHilbert_adjoint (s : ℝ) (p : Equiv.Perm X → ℂ) : + (centeredHilbert (I:=I) s p).adjoint=centeredHilbert s (fun g => star (p g⁻¹)) := by + simp only [centeredHilbert_sum,map_sum,map_smulₛₗ,partialHilbert_adjoint, + map_div₀,map_mul,map_pow,map_neg,map_one,Complex.star_def,Complex.conj_ofReal] + apply Finset.sum_congr rfl + intro A _ + congr 1 + have he := Equiv.sum_comp (Equiv.inv (Equiv.Perm X)) (fun g => star (p g⁻¹) • partialHilbert A g) + simp only [starRingEnd_apply] + simpa only [Equiv.inv_apply,inv_inv] using he + + def spechtPlacementHilbert (μ : YoungDiagram) : + SpechtHilbert μ →ₗ[ℂ] EuclideanSpace ℂ (Tail μ ↪ Cell μ) := + placementCoeffs.symm.toLinearMap.comp ((spechtPlacement μ).comp (spechtHilbertEquiv μ).symm.toLinearMap) + +lemma spechtPlacementHilbert_injective (μ : YoungDiagram) : + Function.Injective (spechtPlacementHilbert μ) := + placementCoeffs.symm.injective.comp ((spechtPlacement_injective μ).comp (spechtHilbertEquiv μ).symm.injective) + +lemma centeredHilbert_specht (μ : YoungDiagram) (s : ℝ) (hs : s≠0) + (p : G μ → ℂ) (v : SpechtHilbert μ) : + centeredHilbert s p (spechtPlacementHilbert μ v)= + spechtPlacementHilbert μ (Irrep.groupAverage (hilbertSpecht μ) p v) := by + obtain ⟨u,rfl⟩ := (spechtHilbertEquiv μ).surjective v + apply placementCoeffs.injective + simp only [centeredHilbert,spechtPlacementHilbert,LinearMap.comp_apply, + LinearEquiv.conj_apply,LinearEquiv.coe_coe,LinearEquiv.symm_symm, + LinearEquiv.apply_symm_apply,LinearEquiv.symm_apply_apply] + change centeredPlacement (s:ℂ) p (spechtPlacement μ u)= + spechtPlacement μ ((spechtHilbertEquiv μ).symm (Irrep.groupAverage (hilbertSpecht μ) p + (spechtHilbertEquiv μ u))) + rw [centeredPlacement_specht μ _ (by exact_mod_cast hs),placementAverage_specht] + congr 1 + simp only [Irrep.groupAverage,LinearMap.sum_apply,LinearMap.smul_apply,map_sum,map_smul] + apply Finset.sum_congr rfl + intro g _ + congr 1 + change spechtRep μ g u=(spechtHilbertEquiv μ).symm + ((spechtHilbertEquiv μ) (spechtRep μ g ((spechtHilbertEquiv μ).symm ((spechtHilbertEquiv μ) u)))) + simp only [LinearEquiv.symm_apply_apply] + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredReindex.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1bb93a48b63e453fd9d72d062a78782ab05cbb6 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/CenteredReindex.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.CenteredMatrix + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable {I J X Y : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype X] [DecidableEq X] [Fintype Y] [DecidableEq Y] + +omit [Fintype I] [DecidableEq I] [Fintype X] [DecidableEq X] in +lemma partialKernel_iff (A : Finset I) (g : Equiv.Perm X) (x y : I ↪ X) : + subPlacement A (movePlacement g x)=subPlacement A y ↔ ∀i∈A, g (x i)=y i := by + constructor + · intro h i hi + exact congrArg (fun u => u ⟨i,hi⟩) h + · intro h + apply Function.Embedding.ext + intro i + exact h i.val i.property + +omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype X] [Fintype Y] in +lemma partialKernel_reindex (a : I ≃ J) (e : X ≃ Y) (A : Finset I) + (g : Equiv.Perm X) (x y : I ↪ X) : + partialKernel (a.finsetCongr A) (e.permCongr g) + (Equiv.embeddingCongr a e y) (Equiv.embeddingCongr a e x)=partialKernel A g y x := by + unfold partialKernel + congr 1 + rw [partialKernel_iff,partialKernel_iff] + apply propext + constructor + · intro he i hi + have ht := he (a i) (by simpa using hi) + simpa using ht + · intro he j hj + obtain ⟨i,rfl⟩ := a.surjective j + have ht := he i (by simpa using hj) + simpa using congrArg e ht + +omit [DecidableEq I] [DecidableEq J] in +theorem centeredMatrix_reindex (a : I ≃ J) (e : X ≃ Y) (s : ℝ) + (p : Equiv.Perm X → ℂ) (x y : I ↪ X) : + centeredMatrix s (fun g => p (e.permCongr.symm g)) + (Equiv.embeddingCongr a e y) (Equiv.embeddingCongr a e x)=centeredMatrix s p y x := by + simp only [centeredMatrix,Finset.powerset_univ,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + have ht := Equiv.sum_comp a.finsetCongr (fun A : Finset J => + ((-1:ℂ)^(Fintype.card J-A.card)*(s:ℂ)^A.card/(s:ℂ)^Fintype.card J) * + ∑g, p (e.permCongr.symm g) * partialKernel A g + (Equiv.embeddingCongr a e y) (Equiv.embeddingCongr a e x)) + rw [← ht] + apply Finset.sum_congr rfl + intro A _ + have hc : (a.finsetCongr A).card=A.card := by simp + rw [hc,← Fintype.card_congr a] + congr 1 + have hu := Equiv.sum_comp e.permCongr (fun g => + p (e.permCongr.symm g) * partialKernel (a.finsetCongr A) g + (Equiv.embeddingCongr a e y) (Equiv.embeddingCongr a e x)) + rw [← hu] + apply Finset.sum_congr rfl + intro g _ + rw [Equiv.symm_apply_apply,partialKernel_reindex] + +omit [DecidableEq I] [DecidableEq J] in +lemma centeredMatrix_hs_reindex (a : I ≃ J) (e : X ≃ Y) (s : ℝ) + (p : Equiv.Perm X → ℂ) : + (∑x : J ↪ Y, ∑y, ‖centeredMatrix s (fun g => p (e.permCongr.symm g)) y x‖^2)= + ∑x : I ↪ X, ∑y, ‖centeredMatrix s p y x‖^2 := by + rw [← Equiv.sum_comp (Equiv.embeddingCongr a e)] + apply Finset.sum_congr rfl + intro x _ + rw [← Equiv.sum_comp (Equiv.embeddingCongr a e)] + simp_rw [centeredMatrix_reindex] + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/ConditionalCentered.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/ConditionalCentered.lean new file mode 100644 index 0000000000000000000000000000000000000000..246cfceb97f8e7b30d33291da5c7b3a9d855ff83 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/ConditionalCentered.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.ConditionalAverage +import OAI.Probability.BinarySweep.MatrixBounds.CenteredMatrix +import OAI.Probability.BinarySweep.SparseBounds.SparseKernel +import OAI.Probability.BinarySweep.Trajectories.EndpointPlacement + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Young Sparse + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma conditionalGroupLaw_expectation {W : Type*} [AddCommMonoid W] [Module ℝ W] + (z : ℝ) (f : Equiv.Perm (FreeSlot H 0) → W) : + (∑a, conditionalGroupLaw H z a • f a) = + ∑g : ConditionalChoices H, conditionalChoiceWeight H z g • f (remainingPerm H g.val g.property) := by + unfold conditionalGroupLaw + simp only [Finset.sum_smul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro g _ + simp only [ite_smul,zero_smul] + simp + +lemma partialKernel_event (g : ConditionalChoices H) (A : Finset (Fin k)) + (x y : Placement H k 0) : + subPlacement A (movePlacement (remainingPerm H g.val g.property) x)=subPlacement A y ↔ + ∀i∈A, gridSweep bits g.val (x i).val=((placementIdentification H k y i).val) := by + constructor + · intro he i hi + have hh := congrArg (fun u => u ⟨i,hi⟩) he + have he' : remainingPerm H g.val g.property (x i)=y i := hh + have ht := congrArg (freeIdentification H) he' + change (freeIdentification H) ((freeIdentification H).symm + (remainingBijection H g.val g.property (x i)))=(freeIdentification H) (y i) at ht + rw [Equiv.apply_symm_apply] at ht + exact congrArg Subtype.val ht + · intro he + apply Function.Embedding.ext + intro i + change (freeIdentification H).symm (remainingBijection H g.val g.property (x i.val))=y i.val + apply (freeIdentification H).injective + rw [Equiv.apply_symm_apply] + apply Subtype.ext + exact he i.val i.property + +lemma partialKernel_conditional (z : ℝ) (A : Finset (Fin k)) (x y : Placement H k 0) : + (∑a : Equiv.Perm (FreeSlot H 0), (conditionalGroupLaw H z a:ℂ) * partialKernel A a y x)= + (endpointProbability H z A (fun i => ((x i).val,(placementIdentification H k y i).val)):ℂ) := by + have he := conditionalGroupLaw_expectation H z (fun a => partialKernel A a y x) + simp only [Complex.real_smul] at he + rw [he,endpointProbability_conditional] + unfold conditionalEventWeight + rw [Complex.ofReal_sum] + apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + intro g _ + simp only [partialKernel,partialKernel_event H g A x y] + split_ifs <;> simp + +theorem centeredMatrix_conditional (z : ℝ) (x y : Placement H k 0) : + centeredMatrix (gridSize bits) (fun a => (conditionalGroupLaw H z a:ℂ)) y x = + (centeredEndpointKernel H z (fun i => ((x i).val,(placementIdentification H k y i).val)):ℂ) := by + simp only [centeredMatrix,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + simp_rw [partialKernel_conditional H z] + unfold centeredEndpointKernel alternatingSubsetSum + simp only [Complex.ofReal_mul,Complex.ofReal_pow,Complex.ofReal_inv,Complex.ofReal_natCast, + Complex.ofReal_sum,Complex.ofReal_neg,Complex.ofReal_one,Finset.card_univ] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro A _ + simp only [div_eq_mul_inv,inv_pow] + ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparse.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparse.lean new file mode 100644 index 0000000000000000000000000000000000000000..046cec626dfc451a2c502122ac7bd05e23e5a3ac --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparse.lean @@ -0,0 +1,203 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedPlacement +import OAI.Probability.BinarySweep.SparseBounds.FewSparseBases +import OAI.Probability.BinarySweep.SparseBounds.FewSparseNumerics +import OAI.Probability.BinarySweep.Trajectories.EndpointGood + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +section +open Sparse Young Irrep + +theorem centeredEndpointHS_few_sparse {b r h k : ℕ} {bits : Fin b → ℕ} + (hb : 1 ≤ b) (hbB : b ≤ 16000) (hd : ∀j, r ≤ bits j ∧ bits j ≤ 2*r) + (hL : (10:ℝ)^26 ≤ Real.log (gridSize bits)) (hk : 1 ≤ k) + (htail : ((k+h:ℕ):ℝ) ≤ (gridSize bits:ℝ)^(1599/1600:ℝ)) (hh : h ≤ 100000*k) + (H : PathFamily bits h) : + (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H 0 (fun i => ((x i).val,(y i).val)))^2) ≤ + Real.exp (-(k:ℝ)*Real.log (gridSize bits)/1000000000000) := by + let L := Real.log (gridSize bits) + let η := Real.exp (-L/160000) + have hs : (0:ℝ) < gridSize bits := by exact_mod_cast gridSize_pos bits + have hL0 : 0 ≤ L := (by positivity : (0:ℝ) ≤ 10^26).trans hL + obtain ⟨hη1,hg⟩ := few_eta_good b hbB hL + have hv := few_vertex_base b h k hs hbB hL htail + have hx := few_line_base h h k hs hL htail (by omega) + have hy := few_line_base k h k hs hL htail (by omega) + have he (a : ℝ) (ha : 0 < a) : Real.exp (-L/a) ≤ 1 := by + rw [Real.exp_le_one_iff] + exact div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hL0) ha.le + obtain ⟨ht,htv,htl⟩ := few_cutoff_bounds b k hb hbB + have hbound := centeredEndpointKernel_few_hs H (fun j => (hd j).2) + (Real.exp_pos (-L/160000)) hη1 (hg.trans (he _ (by norm_num))) + (k/4+1) (k/(8*b)+1) ht (hv.trans (he _ (by norm_num))) + (hx.trans (he _ (by norm_num))) (hy.trans (he _ (by norm_num))) + apply hbound.trans + apply few_hs_scalar b h k (k/4+1) (k/(8*b)+1) + (fun j => (Fintype.card (GridOutside bits j)+1:ℕ)^⌊2*(k:ℝ)/((2^bits j:ℕ)*η)⌋₊) + hbB hk (by exact_mod_cast hh) hL htv htl (by positivity) hg (by positivity) hv + (by positivity) hx (by positivity) hy (fun _ => by positivity) + intro j + convert adaptive_count_small (Fintype.card (GridOutside bits j)) k hs hL + (outside_card_add_one_le bits j) (few_axis_eta_large hbB hd hL j) using 1 + push_cast + rfl + +theorem conditional_specht_few_sparse {b r h k : ℕ} {bits : Fin b → ℕ} + (hb : 1 ≤ b) (hbB : b ≤ 16000) (hd : ∀j, r ≤ bits j ∧ bits j ≤ 2*r) + (hL : (10:ℝ)^26 ≤ Real.log (gridSize bits)) (hk : 1 ≤ k) + (htail : ((k+h:ℕ):ℝ) ≤ (gridSize bits:ℝ)^(1599/1600:ℝ)) (hh : h ≤ 100000*k) + (H : PathFamily bits h) (μ : YoungDiagram) (e : Cell μ ≃ FreeSlot H 0) + (a : Tail μ ≃ Fin k) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H 0 g:ℂ))) ≤ + Real.exp (-(k:ℝ)*Real.log (gridSize bits)/1000000000000) := + (conditional_specht_hs H μ e a 0).trans + (centeredEndpointHS_few_sparse hb hbB hd hL hk htail hh H) + +end + +lemma sparse_tail_le_quarter {s : ℝ} (hs : 0 < s) (hL : (10:ℝ)^26 ≤ Real.log s) : + s^(1599/1600:ℝ) ≤ s/4 := by + have hc : (4:ℝ) ≤ Real.exp (Real.log s/1600) := + (show (4:ℝ) ≤ Real.log s/1600+1 from by linarith).trans (Real.add_one_le_exp _) + apply (le_div_iff₀ (by norm_num : (0:ℝ)<4)).mpr + calc + _ ≤ Real.exp ((1599/1600:ℝ)*Real.log s)*Real.exp (Real.log s/1600) := by + rw [Real.rpow_def_of_pos hs] + simpa only [mul_comm (Real.log s)] using mul_le_mul_of_nonneg_left hc + (Real.exp_pos ((1599/1600:ℝ)*Real.log s)).le + _ = s := by rw [←Real.exp_add,show (1599/1600:ℝ)*Real.log s+Real.log s/1600=Real.log s by ring,Real.exp_log hs] + +lemma few_sparse_sign_geometry {b h k : ℕ} {bits : Fin b → ℕ} + (hL : (10:ℝ)^26 ≤ Real.log (gridSize bits)) + (htail : ((k+h:ℕ):ℝ) ≤ (gridSize bits:ℝ)^(1599/1600:ℝ)) + (j : Fin b) (hj : 2 ≤ bits j) : + h+k+Fintype.card (GridOutside bits j) < gridSize bits := by + have hs : (0:ℝ) < gridSize bits := by exact_mod_cast gridSize_pos bits + have hquarter := htail.trans (sparse_tail_le_quarter hs hL) + have ha : 4 ≤ 2^bits j := (show 4=2^2 by norm_num) ▸ Nat.pow_le_pow_right (by omega : 1 ≤ 2) hj + have ho : 4*Fintype.card (GridOutside bits j) ≤ gridSize bits := by + have he := outside_card_mul_axis bits j + nlinarith [Nat.mul_le_mul_left (Fintype.card (GridOutside bits j)) ha] + have hoR : (4:ℝ)*Fintype.card (GridOutside bits j) ≤ gridSize bits := by exact_mod_cast ho + have hl : ((h+k+Fintype.card (GridOutside bits j):ℕ):ℝ) < gridSize bits := by + push_cast at hquarter ⊢ + linarith + exact_mod_cast hl + +lemma many_sparse_sign_geometry {b h k : ℕ} {bits : Fin b → ℕ} + (hbase : ((k+h:ℕ):ℝ)*(∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j)) < 1) + (j : Fin b) : h+k < Fintype.card (GridOutside bits j) := by + have hp : (0:ℝ) < Fintype.card (GridOutside bits j) := by exact_mod_cast Fintype.card_pos + have he : (1:ℝ)/Fintype.card (GridOutside bits j) ≤ + ∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j) := + Finset.single_le_sum (f := fun j : Fin b => (1:ℝ)/Fintype.card (GridOutside bits j)) (fun _ _ => by positivity) (Finset.mem_univ j) + have hh := (mul_le_mul_of_nonneg_left he (show (0:ℝ) ≤ (k+h:ℕ) by positivity)).trans_lt hbase + rw [mul_one_div] at hh + have hl := (div_lt_one hp).mp hh + simpa only [Nat.add_comm] using (show k+h < Fintype.card (GridOutside bits j) by exact_mod_cast hl) + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter Topology + +namespace BinaryCoordinateSweeps + +instance finitePathFamily {b h : ℕ} {bits : Fin b → ℕ} : Finite (PathFamily bits h) := + Finite.of_injective PathFamily.position (by + intro H J he + cases H + cases J + cases he + rfl) + +def sparseEndpointBound {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) (k : ℕ) (z : ℝ) : Prop := + (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H z (fun i => ((x i).val,(y i).val)))^2) ≤ + Real.exp (-(k:ℝ)*Real.log (gridSize bits)/2000000000000) ∧ + signedCenteredHS H k z ≤ Real.exp (-(k:ℝ)*Real.log (gridSize bits)/2000000000000) + +lemma sparseEndpointBound_eventually {b r h k : ℕ} {bits : Fin b → ℕ} + (hb : 1 ≤ b) (hbB : b ≤ 16000) (hr : 2 ≤ r) (hd : ∀j, r ≤ bits j ∧ bits j ≤ 2*r) + (hL : (10:ℝ)^26 ≤ Real.log (gridSize bits)) (hk : 1 ≤ k) + (htail : ((k+h:ℕ):ℝ) ≤ (gridSize bits:ℝ)^(1599/1600:ℝ)) (hh : h ≤ 100000*k) + (H : PathFamily bits h) : ∀ᶠ z in 𝓝 0, sparseEndpointBound H k z := by + have hbound := centeredEndpointHS_few_sparse hb hbB hd hL hk htail hh H + have hstrict : (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H 0 (fun i => ((x i).val,(y i).val)))^2) < + Real.exp (-(k:ℝ)*Real.log (gridSize bits)/2000000000000) := by + apply hbound.trans_lt (Real.exp_lt_exp.mpr ?_) + have hkR : (0:ℝ) < k := by exact_mod_cast hk + have hKL : 0 < (k:ℝ)*Real.log (gridSize bits) := mul_pos hkR (by linarith) + linarith + let j : Fin b := ⟨0,by omega⟩ + have hgeom := few_sparse_sign_geometry hL htail j (hr.trans (hd j).1) + have hzero : signedCenteredHS H k 0=0 := signedCenteredHS_zero H k 0 (fun l hl x y => + signedPlacementEntry_zero_few H j (by omega) x y) + have hsigned : signedCenteredHS H k 0 < Real.exp (-(k:ℝ)*Real.log (gridSize bits)/2000000000000) := by + rw [hzero] + exact Real.exp_pos _ + filter_upwards [(continuousAt_centeredEndpointHS H k).eventually_lt continuousAt_const hstrict, + (continuousAt_signedCenteredHS H k).eventually_lt continuousAt_const hsigned] with z h1 h2 + exact ⟨h1.le,h2.le⟩ + +theorem sparse_finite_radius (r : ℕ) (hr : 2 ≤ r) : + ∃ δ : ℝ, 0 < δ ∧ ∀ b : ℕ, 1 ≤ b → b ≤ 16000 → + ∀bits : Fin b → ℕ, (∀j, r ≤ bits j ∧ bits j ≤ 2*r) → + ∀h k : ℕ, h ≤ gridSize bits → k ≤ gridSize bits → + (10:ℝ)^26 ≤ Real.log (gridSize bits) → 1 ≤ k → + ((k+h:ℕ):ℝ) ≤ (gridSize bits:ℝ)^(1599/1600:ℝ) → h ≤ 100000*k → + ∀H : PathFamily bits h, ∀z : ℝ, 0 ≤ z → z ≤ δ → sparseEndpointBound H k z := by + have hev : ∀ᶠ z : ℝ in 𝓝 0, + ∀b : Fin 16001, ∀ds : Fin b.val → Fin (2*r+1), + ∀h : Fin (gridSize (fun j => (ds j).val)+1), + ∀k : Fin (gridSize (fun j => (ds j).val)+1), + ∀H : PathFamily (fun j => (ds j).val) h.val, + (1 ≤ b.val ∧ (∀j, r ≤ (ds j).val) ∧ + (10:ℝ)^26 ≤ Real.log (gridSize (fun j => (ds j).val)) ∧ 1 ≤ k.val ∧ + ((k.val+h.val:ℕ):ℝ) ≤ (gridSize (fun j => (ds j).val):ℝ)^(1599/1600:ℝ) ∧ + h.val ≤ 100000*k.val) → sparseEndpointBound H k.val z := by + apply eventually_all.mpr + intro b + apply eventually_all.mpr + intro ds + apply eventually_all.mpr + intro h + apply eventually_all.mpr + intro k + apply eventually_all.mpr + intro H + by_cases hc : 1 ≤ b.val ∧ (∀j, r ≤ (ds j).val) ∧ + (10:ℝ)^26 ≤ Real.log (gridSize (fun j => (ds j).val)) ∧ 1 ≤ k.val ∧ + ((k.val+h.val:ℕ):ℝ) ≤ (gridSize (fun j => (ds j).val):ℝ)^(1599/1600:ℝ) ∧ + h.val ≤ 100000*k.val + · filter_upwards [sparseEndpointBound_eventually hc.1 (by omega) hr + (fun j => ⟨hc.2.1 j,by have := (ds j).isLt; omega⟩) + hc.2.2.1 hc.2.2.2.1 hc.2.2.2.2.1 hc.2.2.2.2.2 H] with z hz + exact fun _ => hz + · exact Eventually.of_forall (fun _ h => False.elim (hc h)) + obtain ⟨ε,hε,he⟩ := Metric.eventually_nhds_iff.mp hev + refine ⟨ε/2,by linarith,?_⟩ + intro b hb hbB bits hd h k hh hk hL hk0 htail hholes H z hz hze + have hdist : dist z 0 < ε := by rw [Real.dist_eq,sub_zero,abs_of_nonneg hz]; linarith + exact he hdist ⟨b,by omega⟩ (fun j => ⟨bits j,(hd j).2.trans_lt (Nat.lt_succ_self _)⟩) + ⟨h,by change h < gridSize bits+1; omega⟩ ⟨k,by change k < gridSize bits+1; omega⟩ H ⟨hb,fun j => (hd j).1,hL,hk0,htail,hholes⟩ + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bb168adac66c7013b9ac7ca11c33f6277d9c9f3 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseBases.lean @@ -0,0 +1,156 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.SparseReduction + +namespace OAI + +noncomputable section + +namespace BinaryCoordinateSweeps.Sparse + +lemma few_eta_good (b : ℕ) {L : ℝ} (hb : b ≤ 16000) (hL : (10:ℝ)^26 ≤ L) : + Real.exp (-L/160000) ≤ 1/4 ∧ + 4*(b:ℝ)*Real.sqrt (Real.exp (-L/160000)) ≤ Real.exp (-L/640000) := by + have hbR : (b:ℝ) ≤ 16000 := by exact_mod_cast hb + constructor + · have hc : (4:ℝ) ≤ Real.exp (L/160000) := by + apply (show (4:ℝ) ≤ L/160000+1 from by linarith).trans (Real.add_one_le_exp _) + rw [show -L/160000=-(L/160000) by ring,Real.exp_neg] + simpa only [one_div] using inv_anti₀ (by norm_num : (0:ℝ)<4) hc + · have hc : 4*(b:ℝ) ≤ Real.exp (L/640000) := by + apply (show 4*(b:ℝ) ≤ L/640000+1 from by linarith).trans (Real.add_one_le_exp _) + have hs : Real.sqrt (Real.exp (-L/160000))=Real.exp (-L/320000) := by + apply (Real.sqrt_eq_iff_mul_self_eq_of_pos (Real.exp_pos _)).mpr + rw [←Real.exp_add] + congr 1 + ring + rw [hs] + refine (mul_le_mul_of_nonneg_right hc (Real.exp_pos _).le).trans_eq ?_ + rw [←Real.exp_add] + congr 1 + ring + +lemma few_vertex_base (b h k : ℕ) {s : ℝ} (hs : 0 (hd j).2) + have hux := mul_le_mul_of_nonneg_right hbR hr + have hj := mul_le_mul_of_nonneg_right (show (r:ℝ) ≤ bits j by exact_mod_cast (hd j).1) + (Real.log_nonneg (by norm_num : (1:ℝ) ≤ 2)) + calc + _ ≤ Real.log (gridSize bits)/40000+1 := by linarith + _ ≤ Real.exp (Real.log (gridSize bits)/40000) := Real.add_one_le_exp _ + _ ≤ _ := by + rw [←Real.exp_log (by positivity : (0:ℝ)<((2^bits j:ℕ):ℝ)),←Real.exp_add] + apply Real.exp_le_exp.mpr + simp only [Nat.cast_pow,Nat.cast_ofNat,Real.log_pow] + linarith + +lemma outside_card_add_one_le {b : ℕ} (bits : Fin b → ℕ) (j : Fin b) : + (Fintype.card (GridOutside bits j)+1:ℝ) ≤ 2*(gridSize bits:ℝ) := by + have he := outside_card_mul_axis bits j + have hp : 1 ≤ 2^bits j := Nat.one_le_pow _ _ (by omega) + have hle : Fintype.card (GridOutside bits j) ≤ gridSize bits := by nlinarith + have hg : 1 ≤ gridSize bits := gridSize_pos bits + exact_mod_cast (show Fintype.card (GridOutside bits j)+1 ≤ 2*gridSize bits from by omega) + +lemma few_cutoff_bounds (b k : ℕ) (hb : 1 ≤ b) (hbB : b ≤ 16000) : + 2*((k/4+1)-1+2*b*((k/(8*b)+1)-1)) ≤ k ∧ + (k:ℝ) ≤ 8*(((k/4+1+1)/2:ℕ):ℝ) ∧ + (k:ℝ) ≤ 128000*(k/(8*b)+1:ℕ) := by + have h1 := Nat.div_mul_le_self k 4 + have h2 := Nat.div_mul_le_self k (8*b) + have hmod := Nat.mod_lt k (by omega : 0<8*b) + have he := Nat.mod_add_div k (8*b) + constructor + · simp only [Nat.add_sub_cancel] + nlinarith + constructor + · exact_mod_cast (show k ≤ 8*((k/4+1+1)/2) from by omega) + · have ht : k ≤ (8*b)*(k/(8*b)+1) := by nlinarith + have hh := ht.trans (Nat.mul_le_mul_right _ (show 8*b ≤ 128000 from by omega)) + exact_mod_cast hh + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseNumerics.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseNumerics.lean new file mode 100644 index 0000000000000000000000000000000000000000..71ac6e1c12a2d842843c599c8417968acaf5e98f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/FewSparseNumerics.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.SparseNumerics + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Sparse + +lemma sparse_amplitudes_small (b h k : ℕ) {L : ℝ} (hb : b≤16000) + (hh : (h:ℝ)≤100000*k) (hL : (10:ℝ)^26≤L) : + ((2:ℝ)^(k+k*b)*Real.exp ((b*h+k+k*b:ℕ):ℝ))^2≤Real.exp ((k:ℝ)*L/2000000000) ∧ + ((2:ℝ)^k*Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2≤Real.exp ((k:ℝ)*L/2000000000) ∧ + (2:ℝ)^k≤Real.exp ((k:ℝ)*L/2000000000) := by + have hbR : (b:ℝ)≤16000 := by exact_mod_cast hb + have h2 : Real.log 2≤2 := (Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2)).trans (by norm_num) + have h4 : Real.log 4≤4 := (Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<4)).trans (by norm_num) + have hbK := mul_le_mul_of_nonneg_right hbR (show (0:ℝ)≤k by positivity) + have hhB := mul_le_mul_of_nonneg_left hh (show (0:ℝ)≤b by positivity) + have hLK := mul_le_mul_of_nonneg_right hL (show (0:ℝ)≤k by positivity) + have hp (n : ℕ) : (2:ℝ)^n=Real.exp ((n:ℝ)*Real.log 2) := by + rw [Real.exp_nat_mul,Real.exp_log (by norm_num)] + constructor + · rw [hp,←Real.exp_add,←Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have h2K := mul_le_mul_of_nonneg_left h2 (show (0:ℝ)≤(k+k*b:ℕ) by positivity) + push_cast at h2K ⊢ + nlinarith only [h2K,hhB,hbK,hLK] + constructor + · rw [hp,←Real.exp_add,←Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have h2K := mul_le_mul_of_nonneg_left h2 (show (0:ℝ)≤k by positivity) + have h4K := mul_le_mul_of_nonneg_right h4 (show (0:ℝ)≤k*b by positivity) + norm_num + nlinarith only [h2K,h4K,hhB,hbK,hLK] + · rw [hp] + apply Real.exp_le_exp.mpr + have h2K := mul_le_mul_of_nonneg_left h2 (show (0:ℝ)≤k by positivity) + nlinarith only [h2K,hLK] + +lemma few_hs_scalar (b h k wv wl : ℕ) {L g v x y : ℝ} (C : Fin b → ℝ) + (hb : b≤16000) (hk : 1≤k) (hh : (h:ℝ)≤100000*k) (hL : (10:ℝ)^26≤L) + (htv : (k:ℝ)≤8*(((wv+1)/2:ℕ):ℝ)) (htl : (k:ℝ)≤128000*wl) + (hg0 : 0≤g) (hg : g≤Real.exp (-L/640000)) + (hv0 : 0≤v) (hv : v≤Real.exp (-L/3200)) + (hx0 : 0≤x) (hx : x≤Real.exp (-L/3200)) + (hy0 : 0≤y) (hy : y≤Real.exp (-L/3200)) + (hC0 : ∀j,0≤C j) (hC : ∀j,C j≤Real.exp ((k:ℝ)*L/2000000000)) : + ((2:ℝ)^(k+k*b)*Real.exp ((b*h+k+k*b:ℕ):ℝ)*g^((k+1)/2))^2+ + ((2:ℝ)^k*Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k*v^((wv+1)/2)+∑j : Fin b, ((2:ℝ)^k*x^wl+C j*(2:ℝ)^k*y^wl))≤ + Real.exp (-(k:ℝ)*L/1000000000000) := by + have hL0 : 0≤L := (by positivity : (0:ℝ)≤10^26).trans hL + have hkR : (1:ℝ)≤k := by exact_mod_cast hk + have hbR : (b:ℝ)≤16000 := by exact_mod_cast hb + have hKL := mul_nonneg (Nat.cast_nonneg k) hL0 + have hkt : (k:ℝ)≤2*(((k+1)/2:ℕ):ℝ) := by exact_mod_cast (show k≤2*((k+1)/2) from by omega) + obtain ⟨hA,hB,h2⟩ := sparse_amplitudes_small b h k hb hh hL + have hgpow : (g^((k+1)/2))^2≤Real.exp (-(k:ℝ)*L/1000000000) := by + have he := nat_pow_le_exp_of_le hg0 hg ((k+1)/2) + have he2 := pow_le_pow_left₀ (pow_nonneg hg0 _) he 2 + rw [←Real.exp_nat_mul] at he2 + refine he2.trans (Real.exp_le_exp.mpr ?_) + have ht := mul_le_mul_of_nonneg_right hkt hL0 + norm_num + nlinarith only [ht,hKL] + have hpow (a : ℝ) (ha0 : 0≤a) (ha : a≤Real.exp (-L/3200)) + (t : ℕ) (ht : (k:ℝ)≤128000*t) : + a^t≤Real.exp (-2*(k:ℝ)*L/1000000000) := by + apply (nat_pow_le_exp_of_le ha0 ha t).trans (Real.exp_le_exp.mpr ?_) + have he := mul_le_mul_of_nonneg_right ht hL0 + nlinarith only [he,hKL] + have hlx := hpow x hx0 hx wl htl + have hly := hpow y hy0 hy wl htl + have hlv := hpow v hv0 hv ((wv+1)/2) (htv.trans (by nlinarith only [show (0:ℝ)≤(((wv+1)/2:ℕ):ℝ) by positivity])) + have hgood : ((2:ℝ)^(k+k*b)*Real.exp ((b*h+k+k*b:ℕ):ℝ)*g^((k+1)/2))^2 ≤ + Real.exp (-(k:ℝ)*L/2000000000) := by + rw [mul_pow] + refine (mul_le_mul hA hgpow (by positivity) (Real.exp_pos _).le).trans_eq ?_ + rw [←Real.exp_add] + congr 1 + ring + have hvertex : (2:ℝ)^k*v^((wv+1)/2)≤Real.exp (-(k:ℝ)*L/1000000000) := by + refine (mul_le_mul h2 hlv (by positivity) (Real.exp_pos _).le).trans ?_ + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith only [hKL] + have hholes : (2:ℝ)^k*x^wl≤Real.exp (-(k:ℝ)*L/1000000000) := by + refine (mul_le_mul h2 hlx (by positivity) (Real.exp_pos _).le).trans ?_ + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith only [hKL] + have hparticles (j : Fin b) : C j*(2:ℝ)^k*y^wl≤Real.exp (-(k:ℝ)*L/1000000000) := by + have hc0 := hC0 j + refine (mul_le_mul (mul_le_mul (hC j) h2 (by positivity) (Real.exp_pos _).le) + hly (by positivity) (by positivity)).trans_eq ?_ + rw [←Real.exp_add,←Real.exp_add] + congr 1 + ring + have hevents : (2:ℝ)^k*v^((wv+1)/2)+∑j : Fin b, ((2:ℝ)^k*x^wl+C j*(2:ℝ)^k*y^wl) ≤ + (1+2*b)*Real.exp (-(k:ℝ)*L/1000000000) := by + refine (add_le_add hvertex (Finset.sum_le_sum (fun j _ => add_le_add hholes (hparticles j)))).trans_eq ?_ + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + have hbad : ((2:ℝ)^k*Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k*v^((wv+1)/2)+∑j : Fin b, ((2:ℝ)^k*x^wl+C j*(2:ℝ)^k*y^wl)) ≤ + (1+2*b)*Real.exp (-(k:ℝ)*L/2000000000) := by + have hev0 : 0≤ (2:ℝ)^k*v^((wv+1)/2)+∑j : Fin b, ((2:ℝ)^k*x^wl+C j*(2:ℝ)^k*y^wl) := by + apply add_nonneg (by positivity) + apply Finset.sum_nonneg + intro j _ + have hc0 := hC0 j + positivity + refine (mul_le_mul hB hevents hev0 (Real.exp_pos _).le).trans_eq ?_ + rw [mul_left_comm,←Real.exp_add] + congr 1 + ring_nf + have hcount : 2+2*(b:ℝ)≤Real.exp ((k:ℝ)*L/4000000000) := by + apply (show 2+2*(b:ℝ)≤(k:ℝ)*L/4000000000+1 from ?_).trans (Real.add_one_le_exp _) + have hh := mul_le_mul_of_nonneg_right hkR hL0 + nlinarith only [hh,hL,hbR] + calc + _ ≤ (2+2*b)*Real.exp (-(k:ℝ)*L/2000000000) := by nlinarith only [hgood,hbad] + _ ≤ Real.exp ((k:ℝ)*L/4000000000)*Real.exp (-(k:ℝ)*L/2000000000) := + mul_le_mul_of_nonneg_right hcount (Real.exp_pos _).le + _ ≤ _ := by + rw [←Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith only [hKL] + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/ManySparse.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/ManySparse.lean new file mode 100644 index 0000000000000000000000000000000000000000..00dd52f355d1acb5796071509ec855dc2d77a21c --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/ManySparse.lean @@ -0,0 +1,233 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.HilbertMainCases +import OAI.Probability.BinarySweep.FiniteLaws.HilbertTranspose +import OAI.Probability.BinarySweep.SparseBounds.FewSparse + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps +open Sparse Young Irrep + +theorem conditional_specht_many_sparse_eventually : ∀ᶠ s : ℕ in atTop, + ∀ b r h k : ℕ, ∀ bits : Fin b → ℕ, gridSize bits=s → 16000≤b → + (∀j, r≤bits j ∧ bits j≤2*r) → 4000000000≤(r:ℝ)*Real.log 2 → + ((k+h:ℕ):ℝ)≤(s:ℝ)^(1599/1600:ℝ) → h≤100000*k → + ∀ H : PathFamily bits h, ∀ μ : YoungDiagram, ∀ e : Cell μ ≃ FreeSlot H 0, + ∀ _a : Tail μ ≃ Fin k, ∀z : ℝ, 0≤z → z≤linePerturbationRadius r → + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ)))≤Real.exp (-(k:ℝ)*Real.log s/16000) := by + filter_upwards [many_collision_base_eventually] with s hs + intro b r h k bits he hb hd hr hk hh H μ e a z hz hzr + have hL : 4000000000*(b:ℝ)≤Real.log s := by + have hl := grid_log_lower (fun j => (hd j).1) + rw [he] at hl + nlinarith [mul_le_mul_of_nonneg_left hr (Nat.cast_nonneg b)] + have hbase := hs b r h k bits he hb hd (by linarith) hk + have hl0 : 0≤Real.log (s:ℝ) := (by positivity : (0:ℝ)≤4000000000*b).trans hL + have hsmall := hbase.trans (show Real.exp (-Real.log s/4000)≤1 by + rw [Real.exp_le_one_iff]; linarith) + have hbound := conditional_specht_many_bound H μ e a (fun j => (hd j).2) hz hzr + (hzr.trans_lt (linePerturbationRadius_lt_one r)) hsmall + exact hbound.trans (many_hs_scalar b h k (by omega) (by exact_mod_cast hh) hL + (by positivity) hbase) + +end BinaryCoordinateSweeps + +end + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open TraceHolder + +lemma sum_pow_le_sum_pow {ι : Type*} [Fintype ι] (a : ι → ℝ) (ha : ∀i,0≤a i) + {q : ℕ} (hq : 0 simp + | succ q hq ih => + have hs : 0≤∑i,a i := Finset.sum_nonneg (fun i _ => ha i) + calc + _ = ∑i,a i^q*a i := by simp only [pow_succ] + _ ≤ ∑i,a i^q*(∑j,a j) := Finset.sum_le_sum (fun i _ => + mul_le_mul_of_nonneg_left (Finset.single_le_sum (fun j _ => ha j) (Finset.mem_univ i)) + (pow_nonneg (ha i) q)) + _ = (∑i,a i^q)*(∑j,a j) := by rw [Finset.sum_mul] + _ ≤ (∑i,a i)^q*(∑j,a j) := mul_le_mul_of_nonneg_right ih hs + _ = _ := (pow_succ _ _).symm + +lemma evenMoment_le_one_pow {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] + [FiniteDimensional ℂ V] {q : ℕ} (hq : 0 s i^2) (fun i => sq_nonneg _) hq + +lemma evenMoment_le_exp {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] + [FiniteDimensional ℂ V] {q : ℕ} (hq : 0 (conditionalGroupLaw H z g:ℂ))) ≤ Real.exp (-(4:ℝ)*k*Real.log s)) ∧ + (evenMoment mainMomentPower (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g*realSign g:ℂ))) ≤ Real.exp (-(4:ℝ)*k*Real.log s)) := by + obtain ⟨S,hS⟩ := eventually_atTop.mp + (conditional_specht_many_sparse_eventually.and many_collision_base_eventually) + refine ⟨S,?_⟩ + intro r hr hrL + obtain ⟨δ,hδ,hbound⟩ := sparse_finite_radius r hr + refine ⟨min δ (linePerturbationRadius r),lt_min hδ (linePerturbationRadius_pos r),min_le_right _ _,?_⟩ + intro s hSs + obtain ⟨hs,hc⟩ := hS s hSs + intro b h k bits he hb hd hL hk htail hh H μ e a z hz hzr + have hzδ := hzr.trans (min_le_left _ _) + have hzline := hzr.trans (min_le_right _ _) + have hone : + (evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ)))≤Real.exp (-(k:ℝ)*Real.log s/2000000000000)) ∧ + (evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g*realSign g:ℂ)))≤Real.exp (-(k:ℝ)*Real.log s/2000000000000)) := by + by_cases hbB : b≤16000 + · have hhS : h≤gridSize bits := by + have hec := Fintype.card_le_of_injective (H.position 0) (H.disjoint 0) + simpa only [Fintype.card_fin,card_gridSlot] using hec + have hkS : k≤gridSize bits := by + have ht : ((k+h:ℕ):ℝ)≤gridSize bits := htail.trans + (by rw [he]; exact Real.rpow_le_self_of_one_le (by exact_mod_cast (he ▸ gridSize_pos bits)) (by norm_num)) + have : k+h≤gridSize bits := by exact_mod_cast ht + omega + have hf := hbound b hb hbB bits hd h k hhS hkS (by simpa only [he] using hL) hk (by simpa only [he] using htail) hh H z hz hzδ + constructor + · exact (conditional_specht_hs H μ e a z).trans (by simpa only [he] using hf.1) + · exact (conditional_signed_specht_hs H μ e a z).trans (by simpa only [he] using hf.2) + · constructor + · refine (hs b r h k bits he (by omega) hd hrL htail hh H μ e a z hz hzline).trans ?_ + apply Real.exp_le_exp.mpr + have : 0≤(k:ℝ)*Real.log s := mul_nonneg (Nat.cast_nonneg _) (by linarith) + linarith + · let j : Fin b := ⟨0,by omega⟩ + have hbase := hc b r h k bits he (by omega) hd (by linarith) htail + have hsmall : Real.exp (-Real.log s/4000)<1 := by rw [Real.exp_lt_one_iff]; linarith + have hgeom := many_sparse_sign_geometry (hbase.trans_lt hsmall) j + exact (conditional_signed_specht_many H μ e a z j (by have := (hd j).1; omega) hgeom).trans + (Real.exp_pos _).le + have hq : 0 < mainMomentPower := by norm_num [mainMomentPower] + constructor + · have h := evenMoment_le_exp hq _ _ hone.1 + convert h using 1 + congr 1 + norm_num [mainMomentPower] + ring + · have h := evenMoment_le_exp hq _ _ hone.2 + convert h using 1 + congr 1 + norm_num [mainMomentPower] + ring + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps +open Young Irrep + +theorem sparse_closing_radius : ∃ S : ℕ, ∀r : ℕ, 2 ≤ r → + 4000000000 ≤ (r:ℝ)*Real.log 2 → + ∃δ : ℝ, 0 < δ ∧ δ ≤ linePerturbationRadius r ∧ ∀s : ℕ, S ≤ s → + ∀b h : ℕ, ∀bits : Fin b → ℕ, gridSize bits=s → 1 ≤ b → + (∀j,r ≤ bits j ∧ bits j ≤ 2*r) → (10:ℝ)^26 ≤ Real.log s → + ∀H : PathFamily bits h, ∀μ : YoungDiagram, ∀e : Cell μ ≃ FreeSlot H 0, + diagramF μ < (s:ℝ)^(399/400:ℝ) → ∀z : ℝ, 0 ≤ z → z ≤ δ → + evenMoment mainMomentPower (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ + Real.exp (-cExponent s*diagramF μ+eExponent s*h*Real.log s-pathCost H) := by + obtain ⟨S,hS⟩ := sparse_uniform_radius + obtain ⟨T,hT⟩ := eventually_atTop.mp sparse_reduction_eventually + refine ⟨max S T,?_⟩ + intro r hr hrL + obtain ⟨δ,hδ,hδline,hsp⟩ := hS r hr hrL + refine ⟨δ,hδ,hδline,?_⟩ + intro s hSs + have hs := hsp s ((le_max_left S T).trans hSs) + have hred := hT s ((le_max_right S T).trans hSs) + intro b h bits he hb hd hL H μ e hF z hz hzδ + have := irreducible_comp_equiv e.symm.permCongrHom (hilbertSpecht μ) + have hz1 := (hzδ.trans hδline).trans_lt (linePerturbationRadius_lt_one r) + have hunit (g : Equiv.Perm (FreeSlot H 0)) (v : SpechtHilbert μ) : + ‖((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) g v‖=‖v‖ := + hilbertSpecht_unitary μ _ v + by_cases ha : (1+cExponent s)*diagramF μ ≤ eExponent s*h*Real.log s-pathCost H + · have hh := hilbert_conditional_automatic H z hz hz1 mainMomentPower _ hunit + simp only [hilbertSpecht_finrank,he] at hh + exact hh ha + · obtain ⟨hk,hh,htail⟩ := hred b r h bits he hb (fun j => (hd j).1) (by linarith) H μ e hF ha + let k := minTail μ + have hm : Fintype.card (Cell μ) ≤ s := by + rw [Fintype.card_congr e,card_freeSlot,he] + exact Nat.sub_le _ _ + have hupper := diagramF_le_minTail μ s (he ▸ gridSize_pos bits) hm + have hg := grid_parameter_allowance hb (fun j => (hd j).1) (by linarith : 400000000 ≤ (r:ℝ)*Real.log 2) H + rw [he] at hg + have hc : cExponent s ≤ 1 := by have := hg.1; unfold c0 at this; linarith + have hallow : 0 ≤ eExponent s*h*Real.log s-pathCost H := by + apply le_trans _ hg.2.2 + unfold e0 + positivity + have hbound : evenMoment mainMomentPower + (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g:ℂ))) ≤ Real.exp (-(4:ℝ)*k*Real.log s) := by + rcases minTail_orientation μ with ht | ht + · let a : Tail μ ≃ Fin k := (Fintype.equivFin _).trans (finCongr ht) + exact (hs b h k bits he hb hd hL hk htail hh H μ e a z hz hzδ).1 + · let a : Tail μ.transpose ≃ Fin k := (Fintype.equivFin _).trans (finCongr ht) + rw [conditional_transpose_moment] + exact (hs b h k bits he hb hd hL hk htail hh H μ.transpose ((transposeCells μ).symm.trans e) + a z hz hzδ).2 + refine hbound.trans (Real.exp_le_exp.mpr ?_) + have hF0 := diagramF_nonneg μ + change diagramF μ ≤ (k:ℝ)*Real.log s at hupper + nlinarith [mul_le_mul_of_nonneg_right hc hF0] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/SparseAmplitude.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseAmplitude.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b553c9bc7c533754b4386020649c0ebe067ec40 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseAmplitude.lean @@ -0,0 +1,210 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.SparseKernel +import OAI.Probability.BinarySweep.Trajectories.EndpointPlacement + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h k r : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma placementProbability_uniform_bound (hd : ∀j, bits j≤2*r) {z : ℝ} + (hz : 0≤z) (hzr : z≤linePerturbationRadius r) (hz1 : z<1) + (x : Placement H k 0) (y : Placement H k (Fin.last b)) : + (gridSize bits : ℝ)^k * placementProbability H z x y ≤ + Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b) := by + have hs : (0:ℝ) ((x i).val,(y i).val)) ≤ + Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b) := by + rw [endpointProbability_placement] + have hb := placementProbability_uniform_bound H hd hz hzr hz1 + (restrictPlacement H x A) (restrictPlacement H y A) + simp only [Fintype.card_coe] at hb + refine hb.trans (Real.exp_le_exp.mpr ?_) + have hk : (A.card:ℝ) ≤ k := by exact_mod_cast (show A.card ≤ k from (by simpa only [Fintype.card_fin] using A.card_le_univ)) + have hl : 0≤Real.log 4 := Real.log_nonneg (by norm_num) + have hbk := mul_le_mul_of_nonneg_left hk (show (0:ℝ)≤b by positivity) + have hbkl := mul_le_mul_of_nonneg_left hbk hl + nlinarith + +lemma alternatingSubsetSum_abs_le {I : Type*} [DecidableEq I] (U : Finset I) + (s : ℝ) (p : Finset I → ℝ) (C : ℝ) + (hp : ∀ A ⊆ U, 0 ≤ s^A.card*p A ∧ s^A.card*p A ≤ C) : + |alternatingSubsetSum U s p|≤(2:ℝ)^U.card*C := by + unfold alternatingSubsetSum + calc + _ ≤ ∑A ∈ U.powerset, |(-1:ℝ)^(U.card-A.card)*s^A.card*p A| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑_A ∈ U.powerset, C := by + apply Finset.sum_le_sum + intro A hA + rw [mul_assoc,abs_mul,abs_pow,abs_neg,abs_one,one_pow,one_mul, + abs_of_nonneg (hp A (Finset.mem_powerset.mp hA)).1] + exact (hp A (Finset.mem_powerset.mp hA)).2 + _ = _ := by simp + +theorem centeredEndpointKernel_amplitude (hd : ∀j, bits j≤2*r) {z : ℝ} + (hz : 0≤z) (hzr : z≤linePerturbationRadius r) (hz1 : z<1) + (x : Placement H k 0) (y : Placement H k (Fin.last b)) : + |(gridSize bits:ℝ)^k * centeredEndpointKernel H z (fun i => ((x i).val,(y i).val))| ≤ + (2:ℝ)^k * Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b) := by + unfold centeredEndpointKernel + simp only [Fintype.card_fin] + rw [← mul_assoc,← mul_pow,mul_inv_cancel₀ (by exact_mod_cast (gridSize_pos bits).ne'), + one_pow,one_mul] + have hb := alternatingSubsetSum_abs_le Finset.univ (gridSize bits) + (fun A => endpointProbability H z A (fun i => ((x i).val,(y i).val))) + (Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b)) (by + intro A _ + constructor + · rw [endpointProbability_placement] + exact mul_nonneg (by positivity) (placementProbability_nonneg H hz hz1 _ _) + · exact endpointProbability_scaled_bound H hd hz hzr hz1 x y A) + simpa only [Finset.card_univ,Fintype.card_fin] using hb + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {P Ω I : Type*} [Fintype P] [Fintype Ω] [Fintype I] [DecidableEq I] + +lemma productProbability_uniform (E : (I → Ω) → Prop) : + productProbability uniformWeight E=finiteProbability uniformWeight E := by + unfold productProbability finiteProbability productWeight uniformWeight + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fun,Nat.cast_pow,one_div,inv_pow] + +lemma sum_injective_le (f : P → Ω) (hi : Function.Injective f) (w : Ω → ℝ) + (hw : ∀u, 0≤w u) : ∑i, w (f i) ≤ ∑u, w u := by + classical + rw [← Finset.sum_image (fun x _ y _ hxy => hi hxy)] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun u _ _ => hw u) + +theorem sum_square_le_uniform_event (f : P → Ω) (hi : Function.Injective f) + (Q : Ω → ℝ) (a C : ℝ) (ha : 0 Q u≠0) := by + have hcard : (Fintype.card Ω:ℝ)≠0 := by rw [hN]; positivity + have hp : (Fintype.card Ω:ℝ)*finiteProbability uniformWeight (fun u => Q u≠0) = + ∑u : Ω, if Q u≠0 then (1:ℝ) else 0 := by + unfold finiteProbability uniformWeight + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + rw [← mul_assoc,mul_one_div_cancel hcard,one_mul] + split_ifs <;> rfl + have hle : a^2*(∑i, (Q (f i))^2) ≤ + ∑u : Ω, if Q u≠0 then C^2 else 0 := by + rw [Finset.mul_sum] + refine (Finset.sum_le_sum (fun i _ => ?_)).trans + (sum_injective_le f hi (fun u => if Q u≠0 then C^2 else 0) + (fun u => by + split_ifs + · exact pow_nonneg hC 2 + · exact le_rfl)) + by_cases hz : Q (f i)=0 + · simp only [hz,ne_eq,not_true_eq_false,ite_false,zero_pow (by decide : 2≠0),mul_zero] + exact le_rfl + · rw [ite_eq_left hz,← mul_pow] + simpa only [sq_abs] using pow_le_pow_left₀ (abs_nonneg _) (hb i) 2 + have he : (∑u : Ω, if Q u≠0 then C^2 else 0)= + C^2 * ((Fintype.card Ω:ℝ)*finiteProbability uniformWeight (fun u => Q u≠0)) := by + rw [hp,Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + split_ifs <;> simp + rw [he,hN] at hle + nlinarith [sq_pos_of_pos ha] + +end BinaryCoordinateSweeps.Sparse +namespace BinaryCoordinateSweeps +open Sparse + +variable {b h k r : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + + def placementEndpointArray (xy : Placement H k 0 × Placement H k (Fin.last b)) : + Fin k → GridSlot bits × GridSlot bits := fun i => ((xy.1 i).val,(xy.2 i).val) + +lemma placementEndpointArray_injective : Function.Injective (placementEndpointArray (k:=k) H) := by + intro x y he + apply Prod.ext + · apply Function.Embedding.ext + intro i + apply Subtype.ext + exact congrArg (fun z => (z i).1) he + · apply Function.Embedding.ext + intro i + apply Subtype.ext + exact congrArg (fun z => (z i).2) he + +theorem centeredEndpointKernel_hs_bound (hd : ∀j, bits j≤2*r) {z : ℝ} + (hz : 0≤z) (hzr : z≤linePerturbationRadius r) (hz1 : z<1) + (hsmall : ((k+h:ℕ):ℝ) * (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j)) ≤ 1) : + (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H z (fun i => ((x i).val,(y i).val)))^2) ≤ + ((2:ℝ)^k * Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k * (((k+h:ℕ):ℝ) * + (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j)))^((k+1)/2)) := by + have hs : (0:ℝ) centeredEndpointKernel_amplitude H hd hz hzr hz1 xy.1 xy.2) + rw [← productProbability_uniform] at he + have hp := centeredEndpointKernel_exceptional_probability (I:=Fin k) H z + (by simpa only [Fintype.card_fin] using hsmall) + simp only [Fintype.card_fin] at hp + have heq : (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H z (fun i => ((x i).val,(y i).val)))^2) = + ∑xy : Placement H k 0 × Placement H k (Fin.last b), + (centeredEndpointKernel H z (placementEndpointArray H xy))^2 := by + rw [Fintype.sum_prod_type] + apply Finset.sum_congr + · ext x; simp only [Finset.mem_univ] + intro x _ + apply Finset.sum_congr + · ext y; simp only [Finset.mem_univ] + intro y _ + rfl + rw [heq] + exact he.trans (mul_le_mul_of_nonneg_left hp (sq_nonneg _)) + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/SparseKernel.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdba766bc89a83fe6d5755ac6eeca32ede6635f6 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseKernel.lean @@ -0,0 +1,97 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.IsolatedCancellation +import OAI.Probability.BinarySweep.Conditional.PlacementAlternation + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +open Sparse + +variable {b h : ℕ} {bits : Fin b → ℕ} {I : Type*} [Fintype I] [DecidableEq I] + +def centeredEndpointKernel (H : PathFamily bits h) (z : ℝ) + (e : I → GridSlot bits × GridSlot bits) : ℝ := + (gridSize bits:ℝ)⁻¹ ^ Fintype.card I * + alternatingSubsetSum Finset.univ (gridSize bits) (fun A => endpointProbability H z A e) + +lemma centeredEndpointKernel_isolated (H : PathFamily bits h) (z : ℝ) + (e : I → GridSlot bits × GridSlot bits) (i : I) + (hh : ∀j k, (fun a : {a : Fin b // a≠j} => H.position j.castSucc k a) ≠ endpointLine (e i) j) + (ha : ∀j a, a≠i → endpointLine (e a) j≠endpointLine (e i) j) : + centeredEndpointKernel H z e=0 := by + unfold centeredEndpointKernel + rw [alternatingSubsetSum_of_isolated Finset.univ + (by exact_mod_cast (gridSize_pos bits).ne') _ i (Finset.mem_univ _) ?_,mul_zero] + intro A hA + exact endpointProbability_insert_isolated H z A e i hh + (fun j a haA => ha j a (Finset.mem_erase.mp (hA haA)).1) + +def pathEndpoints (H : PathFamily bits h) (k : Fin h) : GridSlot bits × GridSlot bits := + (H.position 0 k,H.position (Fin.last b) k) + +lemma endpointLine_path (H : PathFamily bits h) (k : Fin h) (j : Fin b) : + endpointLine (pathEndpoints H k) j=(fun a : {a : Fin b // a≠j} => H.position j.castSucc k a) := by + unfold endpointLine pathEndpoints + rw [independentPosition_of_path (fun t => H.position t k) (fun j i hi => H.changes_only_stage j k i hi)] + +def shareLine (e f : GridSlot bits × GridSlot bits) : Prop := + ∃j, endpointLine e j=endpointLine f j + +lemma shareLine_symmetric : + ∀ ⦃first second : GridSlot bits × GridSlot bits⦄, + shareLine first second → shareLine second first := by + rintro e f ⟨j,hj⟩ + exact ⟨j,hj.symm⟩ + +lemma shareLine_probability (f : GridSlot bits × GridSlot bits) : + finiteProbability uniformWeight (fun e => shareLine (bits:=bits) e f) ≤ + ∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j) := by + have he := finiteProbability_union uniformWeight uniformWeight_nonneg + (fun (j : Fin b) (e : GridSlot bits × GridSlot bits) => endpointLine e j=endpointLine f j) + have hj (j : Fin b) : finiteProbability uniformWeight + (fun e : GridSlot bits × GridSlot bits => endpointLine e j=endpointLine f j)= + (1:ℝ)/Fintype.card (GridOutside bits j) := + independent_line_uniform j (endpointLine f j) + simpa only [hj,shareLine] using he + +lemma centeredEndpointKernel_support (H : PathFamily bits h) (z : ℝ) + (e : I → GridSlot bits × GridSlot bits) (he : centeredEndpointKernel H z e≠0) : + incidentSet shareLine (pathEndpoints H) e=Finset.univ := by + apply Finset.eq_univ_of_forall + intro i + by_contra hi + have hn : ¬((∃a, i≠a ∧ shareLine (e i) (e a)) ∨ ∃k, shareLine (e i) (pathEndpoints H k)) := by + simpa only [incidentSet,Finset.mem_filter,Finset.mem_univ,true_and] using hi + apply he + apply centeredEndpointKernel_isolated H z e i + · intro j k hk + apply hn + exact Or.inr ⟨k,j,hk.symm.trans (endpointLine_path H k j).symm⟩ + · intro j a hai hj + exact hn (Or.inl ⟨a,Ne.symm hai,j,hj.symm⟩) + +theorem centeredEndpointKernel_exceptional_probability (H : PathFamily bits h) (z : ℝ) + (hsmall : ((Fintype.card I+h:ℕ):ℝ) * + (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j)) ≤ 1) : + productProbability (uniformWeight (Ω:=GridSlot bits × GridSlot bits)) + (fun e : I → GridSlot bits × GridSlot bits => centeredEndpointKernel H z e≠0) ≤ + (2:ℝ)^Fintype.card I * + (((Fintype.card I+h:ℕ):ℝ) * (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j))) ^ + ((Fintype.card I+1)/2) := by + have hh := sharing_probability_le (I:=I) uniformWeight uniformWeight_nonneg uniformWeight_sum + shareLine shareLine_symmetric (pathEndpoints H) _ (by positivity) + shareLine_probability (Fintype.card I) (by simpa only [Fintype.card_fin] using hsmall) + simp only [Fintype.card_fin] at hh + apply (productProbability_mono uniformWeight_nonneg ?_).trans hh + intro e he + rw [centeredEndpointKernel_support H z e he,Finset.card_univ] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/SparseNumerics.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseNumerics.lean new file mode 100644 index 0000000000000000000000000000000000000000..72059c38fcf9c12377e2734ba154f1297268c53d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseNumerics.lean @@ -0,0 +1,59 @@ +import Mathlib + +namespace OAI + +noncomputable section +open Filter Asymptotics + +namespace BinaryCoordinateSweeps.Sparse + +lemma nat_pow_le_exp_of_le {x A : ℝ} (hx : 0≤x) (h : x≤Real.exp A) (n : ℕ) : + x^n≤Real.exp ((n:ℝ)*A) := by + simpa only [←Real.exp_nat_mul] using pow_le_pow_left₀ hx h n + +lemma log_le_small_rpow_eventually {ε : ℝ} (hε : 0<ε) : ∀ᶠ s : ℕ in atTop, + Real.log (s:ℝ)≤(s:ℝ)^ε := by + have hh := (isLittleO_log_rpow_rpow_atTop (1:ℝ) hε).bound (by norm_num : (0:ℝ)<1) + have hc : Tendsto (fun s : ℕ => (s:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + filter_upwards [hc.eventually hh,eventually_ge_atTop (1:ℕ)] with s hs hs1 + have hl : 0≤Real.log (s:ℝ) := Real.log_nonneg (by exact_mod_cast hs1) + simpa only [Real.rpow_one,Real.norm_of_nonneg hl, + Real.norm_of_nonneg (Real.rpow_nonneg (Nat.cast_nonneg s) ε),one_mul] using hs + +lemma many_hs_scalar (b h k : ℕ) {L x : ℝ} (hb : 1≤b) + (hh : (h:ℝ)≤100000*k) (hL : 4000000000*(b:ℝ)≤L) + (hx0 : 0≤x) (hx : x≤Real.exp (-L/4000)) : + ((2:ℝ)^k*Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k*x^((k+1)/2)) ≤ Real.exp (-(k:ℝ)*L/16000) := by + have hL0 : 0≤L := (by positivity : (0:ℝ)≤4000000000*b).trans hL + have hbk : (1:ℝ)≤b := by exact_mod_cast hb + have hkt : (k:ℝ)≤2*(((k+1)/2:ℕ):ℝ) := by exact_mod_cast (show k≤2*((k+1)/2) from by omega) + have hal : x^((k+1)/2)≤Real.exp (-(k:ℝ)*L/8000) := by + apply (nat_pow_le_exp_of_le hx0 hx _).trans + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_right hkt hL0] + have hlog2 : Real.log 2≤2 := (Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2)).trans (by norm_num) + have hlog4 : Real.log 4≤4 := (Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<4)).trans (by norm_num) + have hp (n : ℕ) : (2:ℝ)^n=Real.exp ((n:ℝ)*Real.log 2) := by + rw [Real.exp_nat_mul,Real.exp_log (by norm_num)] + calc + _ ≤ ((2:ℝ)^k*Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k*Real.exp (-(k:ℝ)*L/8000)) := by gcongr + _ = Real.exp (3*(k:ℝ)*Real.log 2+2*((b:ℝ)*(h+k)+Real.log 4*k*b)-(k:ℝ)*L/8000) := by + simp only [hp,←Real.exp_add,←Real.exp_nat_mul] + congr 1 + ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hh' := mul_le_mul_of_nonneg_left hh (show (0:ℝ)≤b by positivity) + have h2 := mul_le_mul_of_nonneg_left hlog2 (show (0:ℝ)≤k by positivity) + have h4 := mul_le_mul_of_nonneg_right hlog4 (show (0:ℝ)≤k*b by positivity) + have hkb := mul_le_mul_of_nonneg_left hbk (show (0:ℝ)≤k by positivity) + have hLc := mul_le_mul_of_nonneg_right hL (show (0:ℝ)≤k by positivity) + nlinarith + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/SparseReduction.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..476e7f961decffa61ca408f385b411f2f3c0a2f7 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseReduction.lean @@ -0,0 +1,221 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.MainEasyCases +import OAI.Probability.BinarySweep.YoungTheory.YoungDimensionLower +import OAI.Probability.BinarySweep.GridBounds.DenseClosing +import OAI.Probability.BinarySweep.SparseBounds.SparseNumerics +import OAI.Probability.BinarySweep.YoungTheory.YoungTranspose + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps.Young +open Irrep Signed + +def minTail (μ : YoungDiagram) : ℕ := min (Fintype.card (Cell μ)-μ.rowLen 0) + (Fintype.card (Cell μ)-μ.colLen 0) + +lemma diagramF_le_rowTail (μ : YoungDiagram) (s : ℕ) (hs : 0 < s) + (hM : Fintype.card (Cell μ) ≤ s) : + diagramF μ ≤ (Fintype.card (Cell μ)-μ.rowLen 0:ℕ)*Real.log s := by + have hD : (0:ℝ) < Module.finrank ℂ (SpechtSpace μ) := by + rw [←hilbertSpecht_finrank] + exact_mod_cast irreducible_finrank_pos (hilbertSpecht μ) + have hb := (specht_finrank_le_power μ).trans (Nat.pow_le_pow_left hM _) + have hl := (Real.log_le_log_iff hD (pow_pos (Nat.cast_pos.mpr hs) _)).mpr + (show (Module.finrank ℂ (SpechtSpace μ):ℝ) ≤ + (s:ℝ)^(Fintype.card (Cell μ)-μ.rowLen 0) by exact_mod_cast hb) + rw [Real.log_pow] at hl + exact hl + +lemma diagramF_transpose (μ : YoungDiagram) : diagramF μ.transpose=diagramF μ := by + unfold diagramF + rw [←specht_finrank_transpose] + +lemma minTail_orientation (μ : YoungDiagram) : + Fintype.card (Tail μ)=minTail μ ∨ Fintype.card (Tail μ.transpose)=minTail μ := by + have hc := Fintype.card_congr (transposeCells μ) + rw [card_tail,card_tail,YoungDiagram.rowLen_transpose,←hc] + exact (le_total (Fintype.card (Cell μ)-μ.rowLen 0) (Fintype.card (Cell μ)-μ.colLen 0)).elim + (fun h => Or.inl (min_eq_left h).symm) (fun h => Or.inr (min_eq_right h).symm) + +lemma diagramF_le_minTail (μ : YoungDiagram) (s : ℕ) (hs : 0 < s) + (hM : Fintype.card (Cell μ) ≤ s) : diagramF μ ≤ (minTail μ:ℝ)*Real.log s := by + rcases minTail_orientation μ with ht | ht + · simpa only [←card_tail,ht] using diagramF_le_rowTail μ s hs hM + · have hc : Fintype.card (Cell μ.transpose) ≤ s := + (Fintype.card_congr (transposeCells μ)).symm.trans_le hM + simpa only [diagramF_transpose,←card_tail,ht] using diagramF_le_rowTail μ.transpose s hs hc + +lemma minTail_le_diagramF (μ : YoungDiagram) : + (minTail μ:ℝ) ≤ (2/Real.log 2)*diagramF μ := by + have hl := log_dimension_lower_min_tail μ + have htwo := Real.log_pos (by norm_num : (1:ℝ) < 2) + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ htwo).mpr + change Real.log 2/2*(minTail μ:ℝ) ≤ diagramF μ at hl + nlinarith + +end BinaryCoordinateSweeps.Young +namespace BinaryCoordinateSweeps +open Young Irrep Signed + +lemma const_mul_rpow_eventually (C u v : ℝ) (huv : u < v) : ∀ᶠ s : ℕ in atTop, + C*(s:ℝ)^u ≤ (s:ℝ)^v := by + have ht := (tendsto_rpow_atTop (sub_pos.mpr huv)).comp + (tendsto_natCast_atTop_atTop (R:=ℝ)) + filter_upwards [ht.eventually_ge_atTop C,eventually_ge_atTop (1:ℕ)] with s hs hs1 + have hp : (0:ℝ) < s := by exact_mod_cast hs1 + calc + _ ≤ (s:ℝ)^(v-u)*(s:ℝ)^u := mul_le_mul_of_nonneg_right hs (Real.rpow_pos_of_pos hp _).le + _ = _ := by rw [←Real.rpow_add hp]; congr 1; ring + +lemma sparse_reduction_eventually : ∀ᶠ s : ℕ in atTop, + ∀ b r h : ℕ, ∀bits : Fin b → ℕ, gridSize bits=s → 1 ≤ b → + (∀j,r ≤ bits j) → 400000000 ≤ (r:ℝ)*Real.log 2 → + ∀H : PathFamily bits h, ∀μ : YoungDiagram, ∀_e : Cell μ ≃ FreeSlot H 0, + diagramF μ < (s:ℝ)^(399/400:ℝ) → + ¬((1+cExponent s)*diagramF μ ≤ eExponent s*h*Real.log s-pathCost H) → + 1 ≤ minTail μ ∧ h ≤ 100000*minTail μ ∧ + ((minTail μ+h:ℕ):ℝ) ≤ (s:ℝ)^(1599/1600:ℝ) := by + filter_upwards [const_mul_rpow_eventually (80000+2/Real.log 2) (399/400) (1599/1600) + (by norm_num)] with s hs + intro b r h bits he hb hd hr H μ e hF hnot + have ha := grid_parameter_allowance hb hd hr H + rw [he] at ha + have hLF := grid_log_lower hd + rw [he] at hLF + have hbR : (1:ℝ) ≤ b := by exact_mod_cast hb + have hL : 1 ≤ Real.log s := by nlinarith [mul_le_mul_of_nonneg_left hr (Nat.cast_nonneg b)] + have hF0 := diagramF_nonneg μ + have hM : Fintype.card (Cell μ) ≤ s := by + rw [Fintype.card_congr e,card_freeSlot,he] + exact Nat.sub_le _ _ + have hp : 0 < s := he ▸ gridSize_pos bits + have hupper := diagramF_le_minTail μ s hp hM + have hlow := minTail_le_diagramF μ + have hallow0 : 0 ≤ eExponent s*h*Real.log s-pathCost H := by + apply le_trans _ ha.2.2 + unfold e0 + positivity + have hc : cExponent s ≤ 1 := by have := ha.1; unfold c0 at this; linarith + have hn := lt_of_not_ge hnot + have hhL : (h:ℝ)*Real.log s < 80000*diagramF μ := by + have hh := ha.2.2 + unfold e0 at hh + nlinarith [mul_le_mul_of_nonneg_right hc hF0] + have hkpos : 0 < minTail μ := by + by_contra hk + have hk0 : minTail μ=0 := by omega + rw [hk0,Nat.cast_zero,zero_mul] at hupper + have : diagramF μ=0 := le_antisymm hupper hF0 + rw [this,mul_zero] at hn + linarith + have hhk : h ≤ 100000*minTail μ := by + have hr' : (h:ℝ) ≤ 100000*(minTail μ:ℝ) := by + have hh' := hhL.trans_le (mul_le_mul_of_nonneg_left hupper (by norm_num)) + have : (h:ℝ) < 80000*minTail μ := by nlinarith + nlinarith [show (0:ℝ) ≤ minTail μ by positivity] + exact_mod_cast hr' + refine ⟨hkpos,hhk,?_⟩ + have hhF : (h:ℝ) ≤ 80000*diagramF μ := by nlinarith + have hsum : ((minTail μ+h:ℕ):ℝ) ≤ (80000+2/Real.log 2)*diagramF μ := by + push_cast + nlinarith + refine hsum.trans ((mul_le_mul_of_nonneg_left hF.le ?_).trans hs) + have := Real.log_pos (by norm_num : (1:ℝ) < 2) + positivity + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps +open Sparse + +lemma outside_card_mul_axis {b : ℕ} (bits : Fin b → ℕ) (j : Fin b) : + Fintype.card (GridOutside bits j)*2^bits j=gridSize bits := by + have he := Fintype.card_congr (Equiv.piSplitAt j (fun i => Slot (bits i))) + change Fintype.card (GridSlot bits)=Fintype.card (Slot (bits j) × GridOutside bits j) at he + have hs : Fintype.card (Slot (bits j))=2^bits j := by simp [Slot] + have hg : Fintype.card (GridSlot bits)=gridSize bits := by simp [GridSlot,gridSize,Slot] + simpa only [Fintype.card_prod,hs,hg,mul_comm] using he.symm + +lemma outside_inv_axis_ratio {b : ℕ} (bits : Fin b → ℕ) (j : Fin b) : + (1:ℝ)/Fintype.card (GridOutside bits j)=(2^bits j:ℕ)/(gridSize bits:ℝ) := by + have hp : (0:ℝ)<(2^bits j:ℕ) := by positivity + have he : (Fintype.card (GridOutside bits j):ℝ)*(2^bits j:ℕ)=gridSize bits := by + exact_mod_cast outside_card_mul_axis bits j + rw [←he] + field_simp + +lemma many_axis_size_bound {b r : ℕ} {bits : Fin b → ℕ} + (hb : 16000≤b) (hd : ∀j, r≤bits j ∧ bits j≤2*r) (j : Fin b) : + ((2^bits j:ℕ):ℝ)≤Real.exp (Real.log (gridSize bits)/8000) := by + have hbR : (16000:ℝ)≤b := by exact_mod_cast hb + have hr : 0≤(r:ℝ)*Real.log 2 := mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by norm_num)) + have hl := grid_log_lower (fun j => (hd j).1) + have ha := mul_le_mul_of_nonneg_right hbR hr + have hj := mul_le_mul_of_nonneg_right (show (bits j:ℝ)≤2*r by exact_mod_cast (hd j).2) + (Real.log_nonneg (by norm_num : (1:ℝ)≤2)) + have hp : (0:ℝ)<((2^bits j:ℕ):ℝ) := by positivity + rw [←Real.exp_log hp] + apply Real.exp_le_exp.mpr + simp only [Nat.cast_pow,Nat.cast_ofNat,Real.log_pow] + linarith + +lemma many_collision_base_eventually : ∀ᶠ s : ℕ in atTop, + ∀ b r h k : ℕ, ∀ bits : Fin b → ℕ, gridSize bits=s → 16000≤b → + (∀j, r≤bits j ∧ bits j≤2*r) → 1≤(r:ℝ)*Real.log 2 → + ((k+h:ℕ):ℝ)≤(s:ℝ)^(1599/1600:ℝ) → + ((k+h:ℕ):ℝ)*(∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j))≤ + Real.exp (-Real.log s/4000) := by + filter_upwards [log_le_small_rpow_eventually (by norm_num : (0:ℝ)<1/4000)] with s hs + intro b r h k bits he hb hd hr hk + have sp : (0:ℝ) (hd j).1) + rw [he] at hl + have hbL : (b:ℝ)≤Real.log s := by nlinarith [mul_le_mul_of_nonneg_left hr (Nat.cast_nonneg b)] + have hbE : (b:ℝ)≤Real.exp (Real.log s/4000) := by + refine (hbL.trans hs).trans_eq ?_ + rw [Real.rpow_def_of_pos sp] + congr 1 + ring + have hsum : (∑j : Fin b, (1:ℝ)/Fintype.card (GridOutside bits j))≤ + (b:ℝ)*Real.exp (Real.log s/8000)/(s:ℝ) := by + calc + _ ≤ ∑_j : Fin b, Real.exp (Real.log s/8000)/(s:ℝ) := by + apply Finset.sum_le_sum + intro j _ + rw [outside_inv_axis_ratio,he] + exact div_le_div_of_nonneg_right (by simpa only [he] using many_axis_size_bound hb hd j) sp.le + _ = _ := by simp; ring + have hkE : ((k+h:ℕ):ℝ)≤Real.exp ((1599/1600:ℝ)*Real.log s) := by + simpa only [Real.rpow_def_of_pos sp,mul_comm] using hk + calc + _ ≤ Real.exp ((1599/1600:ℝ)*Real.log s)* + (Real.exp (Real.log s/4000)*Real.exp (Real.log s/8000)/(s:ℝ)) := by + apply mul_le_mul hkE + · exact hsum.trans (div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right hbE (Real.exp_pos _).le) sp.le) + · positivity + · positivity + _ = _ := by + rw [←Real.exp_log sp,←Real.exp_add,←Real.exp_sub,←Real.exp_add] + simp only [Real.log_exp] + congr 1 + ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/SparseBounds/SparseSignGeometry.lean b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseSignGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..83a83984c925e1fe587ff8259fb00b4366c447fe --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/SparseBounds/SparseSignGeometry.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.PathSign + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma exists_untouched_line (j : Fin b) (hh : h Nat.one_le_iff_ne_zero.mpr (hn y)) + simp only [Finset.sum_const,Finset.card_univ,smul_eq_mul,mul_one,sum_lineHoles] at he + omega + +lemma signed_path_weight_zero_sparse (z : ℝ) (j : Fin b) (hj : 0 huv (Subtype.ext he)),u.property,v.property⟩ + +lemma exists_line_two_free (j : Fin b) + (hh : h+Fintype.card (GridOutside bits j) Slot (bits i))) + change Fintype.card (GridSlot bits)=Fintype.card (Slot (bits j) × GridOutside bits j) at he + have hs : Fintype.card (Slot (bits j))=2^bits j := by simp [Slot] + have hg : Fintype.card (GridSlot bits)=gridSize bits := by simp [GridSlot,gridSize,Slot] + simpa only [Fintype.card_prod,hs,hg,mul_comm] using he.symm + have he : ∃y : GridOutside bits j, lineHoles H j y+1<2^bits j := by + by_contra hn + push Not at hn + have hf := Finset.sum_le_sum (s:=Finset.univ) (fun y _ => hn y) + simp only [Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,smul_eq_mul, + mul_one,sum_lineHoles,hfull] at hf + omega + obtain ⟨y,hy⟩ := he + refine ⟨y,?_⟩ + apply two_outside_embedding (lineOutput H j y) + have hc : Fintype.card (LinePaths H j y)=lineHoles H j y := by + unfold LinePaths lineHoles + congr 1 + rw [hc] + simpa [Slot] using hy + +lemma signed_path_weight_zero_few (j : Fin b) + (hh : h+Fintype.card (GridOutside bits j) isotypicProjection p (ρ i))).submatrix (blockWords e) (blockWords e) + +omit [∀i, FiniteDimensional ℂ (V i)] in +lemma blockProjection_psd (e : (Σₗ i, Fin (n i)) ≃o Fin N) (p : A → Bool) + (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) : + (blockProjection e p ρ).PosSemidef := + (piTensorMatrices_psd _ (fun i => isotypicProjection_psd p (ρ i))).submatrix _ + +omit [∀i, FiniteDimensional ℂ (V i)] in +lemma blockProjection_idempotent (e : (Σₗ i, Fin (n i)) ≃o Fin N) (p : A → Bool) + (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) : + blockProjection e p ρ*blockProjection e p ρ=blockProjection e p ρ := by + unfold blockProjection + rw [Matrix.submatrix_mul_equiv,piTensorMatrices_mul] + have hh : (fun i => isotypicProjection p (ρ i)*isotypicProjection p (ρ i)) = + (fun i => isotypicProjection p (ρ i)) := by + funext i + exact projectionMatrix_idempotent (hilbertSubspace (isotypicSpan (ρ i) (tensorRep p (n i)))) + rw [hh] + +omit [Fintype A] [DecidableEq A] in +lemma block_tensor_density (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (r : I → Matrix A A ℂ) : + (piTensorMatrices (fun i => matrixTensorPower (n i) (r i))).submatrix + (blockWords e) (blockWords e) = tensorMatrices (fun t => r (ofLex (e.symm t)).1) := by + ext x y + change (∏i, ∏a : Fin (n i), r i (x (e (toLex ⟨i,a⟩))) (y (e (toLex ⟨i,a⟩)))) = + ∏t, r (ofLex (e.symm t)).1 (x t) (y t) + calc + _ = ∏t : Σ i, Fin (n i), r t.1 (x (e (toLex t))) (y (e (toLex t))) := (Fintype.prod_sigma _).symm + _ = _ := by + have hh := (toLex.trans e.toEquiv).prod_comp (fun t => r (ofLex (e.symm t)).1 (x t) (y t)) + change (∏t : Σ i, Fin (n i), r (ofLex (e.symm (e (toLex t)))).1 (x (e (toLex t))) (y (e (toLex t)))) = _ at hh + simpa only [OrderIso.symm_apply_apply, ofLex_toLex] using hh + +lemma block_density_domination [Nonempty A] (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (p : A → Bool) (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) + [∀i, (ρ i).IsIrreducible] : + (((∏i, (Module.finrank ℂ (V i):ℂ)*(n i+1:ℂ)^(2*(Fintype.card A)^2))) • + (∑u : ∀i, LocalDensityIndex p (n i), + tensorMatrices (fun t => localDensity p (n (ofLex (e.symm t)).1) (u (ofLex (e.symm t)).1))) - + blockProjection e p ρ).PosSemidef := by + have h := piTensor_density_domination (fun i => isotypicProjection p (ρ i)) + (fun i u => matrixTensorPower (n i) (localDensity p (n i) u)) + (fun i => (Module.finrank ℂ (V i):ℂ)*(n i+1:ℂ)^(2*(Fintype.card A)^2)) + (fun i => isotypicProjection_psd p (ρ i)) + (fun i => local_type_density_domination p (n i) (ρ i)) + have hh := h.submatrix (blockWords (A:=A) e) + simpa only [Matrix.submatrix_sub,Matrix.submatrix_smul,Pi.sub_apply,Pi.smul_apply,submatrix_sum_eq, + block_tensor_density,blockProjection] using hh + +omit [∀i, FiniteDimensional ℂ (V i)] in +lemma blockProjection_central (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (p : A → Bool) (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) + (M : Matrix (Fin N → A) (Fin N → A) ℂ) + (hc : ∀g : ∀i, Equiv.Perm (Fin (n i)), + M*actionMatrix p (blockPerm e g)=actionMatrix p (blockPerm e g)*M) : + M*blockProjection e p ρ=blockProjection e p ρ*M := by + let E := Matrix.reindexAlgEquiv ℂ ℂ (blockWords (A:=A) e) + have he (g : ∀i, Equiv.Perm (Fin (n i))) : + E (actionMatrix p (blockPerm e g))=piTensorMatrices (fun i => actionMatrix p (g i)) := by + change E (LinearMap.toMatrix' (act p (blockPerm e g)))=_ + rw [actionMatrix_blocks] + ext x y + change (piTensorMatrices (fun i => actionMatrix p (g i))) (blockWords e ((blockWords e).symm x)) (blockWords e ((blockWords e).symm y)) = _ + simp + have hP : E (blockProjection e p ρ)=piTensorMatrices (fun i => isotypicProjection p (ρ i)) := by + ext x y + change (piTensorMatrices (fun i => isotypicProjection p (ρ i))) (blockWords e ((blockWords e).symm x)) (blockWords e ((blockWords e).symm y)) = _ + simp + have hsingle (i : I) (g : Equiv.Perm (Fin (n i))) : + piTensorMatrices (fun j => actionMatrix p (Pi.mulSingle (M:=fun j => Equiv.Perm (Fin (n j))) i g j)) = + siteMatrix i (actionMatrix p g) := by + have hs := siteMatrix_eq_mask (i:=i) (P:=fun j => actionMatrix p (Pi.mulSingle (M:=fun j => Equiv.Perm (Fin (n j))) i g j)) + simp only [Pi.mulSingle_eq_same] at hs + rw [hs] + congr 1 + funext j + by_cases hji : j=i + · subst j; simp + · simp [Pi.mulSingle_eq_of_ne hji,actionMatrix_one] + apply E.injective + simp only [map_mul,hP] + apply piTensor_centrality (fun i g => actionMatrix p g) (fun i => isotypicProjection p (ρ i)) + (fun i => typeProjection_central p (ρ i)) + intro i g + have hh := congrArg E (hc (Pi.mulSingle (M:=fun j => Equiv.Perm (Fin (n j))) i g)) + simpa only [map_mul,he,hsingle] using hh + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps +open Density TraceHolder Irrep Representation + +lemma piTensorMatrices_pow {I : Type*} [Fintype I] [DecidableEq I] + {A : I → Type*} [∀i, Fintype (A i)] [∀i, DecidableEq (A i)] + (M : ∀i, Matrix (A i) (A i) ℂ) (q : ℕ) : + (piTensorMatrices M)^q=piTensorMatrices (fun i => M i^q) := by + induction q with + | zero => simp only [pow_zero,piTensorMatrices_one] + | succ q ih => rw [pow_succ,ih,piTensorMatrices_mul]; simp only [pow_succ] + +lemma gram_trace_real {I : Type*} [Fintype I] [DecidableEq I] + (M : Matrix I I ℂ) (q : ℕ) : ((matrixMoment q M:ℝ):ℂ)=((star M*M)^q).trace := by + have hh := ((Matrix.posSemidef_conjTranspose_mul_self M).pow q).trace_nonneg + apply Complex.ext + · rfl + · simpa only [Complex.ofReal_im, Matrix.star_eq_conjTranspose] using (Complex.nonneg_iff.mp hh).2 + +lemma tensor_matrixMoment {I : Type*} [Fintype I] [DecidableEq I] + {A : I → Type*} [∀i, Fintype (A i)] [∀i, DecidableEq (A i)] + (M : ∀i, Matrix (A i) (A i) ℂ) (q : ℕ) : + matrixMoment q (piTensorMatrices M)=∏i, matrixMoment q (M i) := by + unfold matrixMoment + rw [Matrix.star_eq_conjTranspose,piTensorMatrices_star,piTensorMatrices_mul, + piTensorMatrices_pow,piTensorMatrices_trace] + have he (i : I) : (((M i).conjTranspose*M i)^q).trace= + ((matrixMoment q (M i):ℝ):ℂ) := (gram_trace_real (M i) q).symm + simp_rw [he] + rw [← Complex.ofReal_prod,Complex.ofReal_re] + rfl + +lemma matrixMoment_reindex {I J : Type*} [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] (e : I ≃ J) (M : Matrix J J ℂ) (q : ℕ) : + matrixMoment q (M.submatrix e e)=matrixMoment q M := by + have hp (B : Matrix J J ℂ) : (B.submatrix e e)^q=(B^q).submatrix e e := by + induction q with + | zero => simp only [pow_zero,Matrix.submatrix_one_equiv] + | succ q ih => rw [pow_succ,ih,Matrix.submatrix_mul_equiv,← pow_succ] + unfold matrixMoment + rw [Matrix.star_eq_conjTranspose,Matrix.conjTranspose_submatrix, + Matrix.submatrix_mul_equiv,hp] + congr 1 + exact e.sum_comp (fun i => ((M.conjTranspose*M)^q) i i) + +namespace Signed +variable {I A : Type*} [Fintype I] [LinearOrder I] + [Fintype A] [DecidableEq A] {n : I → ℕ} {N : ℕ} + {V : I → Type*} [∀i, NormedAddCommGroup (V i)] + [∀i, InnerProductSpace ℂ (V i)] [∀i, FiniteDimensional ℂ (V i)] + +def blockAverage (e : (Σₗ i, Fin (n i)) ≃o Fin N) (p : A → Bool) + (w : ∀i, Equiv.Perm (Fin (n i)) → ℂ) : Matrix (Fin N → A) (Fin N → A) ℂ := + ∑g : ∀i, Equiv.Perm (Fin (n i)), (∏i, w i (g i)) • actionMatrix p (blockPerm e g) + +lemma blockAverage_tensor (e : (Σₗ i, Fin (n i)) ≃o Fin N) (p : A → Bool) + (w : ∀i, Equiv.Perm (Fin (n i)) → ℂ) : + blockAverage e p w=(piTensorMatrices (fun i => signedAverage p (w i))).submatrix + (blockWords e) (blockWords e) := by + unfold blockAverage signedAverage + rw [piTensorMatrices_sum,submatrix_sum_eq] + apply Finset.sum_congr rfl + intro g _ + rw [piTensorMatrices_smul,Matrix.submatrix_smul] + congr 1 + exact actionMatrix_blocks e g p + +lemma block_projected_moment (e : (Σₗ i, Fin (n i)) ≃o Fin N) (p : A → Bool) + (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) + [∀i, (ρ i).IsIrreducible] (hρ : ∀i g v, ‖ρ i g v‖=‖v‖) + (w : ∀i, Equiv.Perm (Fin (n i)) → ℂ) {q : ℕ} (hq : 0 < q) : + matrixMoment q (blockProjection e p ρ*blockAverage e p w)= + ∏i, (Module.finrank ℂ (IntertwiningMap (ρ i) (hilbertTensorRep p (n i))):ℝ)* + evenMoment q (groupAverage (ρ i) (w i)) := by + rw [blockAverage_tensor,blockProjection,Matrix.submatrix_mul_equiv, + piTensorMatrices_mul,matrixMoment_reindex,tensor_matrixMoment] + apply Finset.prod_congr rfl + intro i _ + exact local_projected_moment p (ρ i) (hρ i) (w i) hq + +theorem block_projected_moment_le (e : (Σₗ i, Fin (n i)) ≃o Fin N) (p : A → Bool) + (ρ : ∀i, Representation ℂ (Equiv.Perm (Fin (n i))) (V i)) + [∀i, (ρ i).IsIrreducible] (hρ : ∀i g v, ‖ρ i g v‖=‖v‖) + (w : ∀i, Equiv.Perm (Fin (n i)) → ℂ) {q : ℕ} (hq : 0 < q) : + matrixMoment q (blockProjection e p ρ*blockAverage e p w) ≤ + ∏i, (n i+1:ℝ)^((Fintype.card A)^2)*evenMoment q (groupAverage (ρ i) (w i)) := by + rw [blockAverage_tensor,blockProjection,Matrix.submatrix_mul_equiv, + piTensorMatrices_mul,matrixMoment_reindex,tensor_matrixMoment] + apply Finset.prod_le_prod₀ + · intro i _; exact matrixMoment_nonneg _ _ + · intro i _; exact local_projected_moment_le p (ρ i) (hρ i) (w i) hq + +end Signed +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/EmpiricalTensor.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/EmpiricalTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..696fc69a2da53d7d83064f94c85302e0001fe512 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/EmpiricalTensor.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.TensorPhases + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {A : Type*} [Fintype A] [DecidableEq A] + +def tensorAmplitude (n : ℕ) (r : A → ℝ) (w : Fin n → A) : ℝ := ∏ i, Real.sqrt (r (w i)) + +def tensorProductVector (n : ℕ) (v : A → ℂ) : (Fin n → A) → ℂ := fun w => ∏ i, v (w i) + +def phasedVector (n : ℕ) (r : A → ℝ) (θ : A → ZMod (n+1)) : A → ℂ := + fun a => (Real.sqrt (r a) : ℂ) * ZMod.stdAddChar (θ a) + +omit [Fintype A] [DecidableEq A] in +lemma tensorProductVector_phased (n : ℕ) (r : A → ℝ) (θ : A → ZMod (n+1)) (w : Fin n → A) : + tensorProductVector n (phasedVector n r θ) w = + (tensorAmplitude n r w : ℂ) * tensorPhase n θ w := by + simp only [tensorProductVector, phasedVector, tensorAmplitude, tensorPhase, + Finset.prod_mul_distrib, Complex.ofReal_prod] + +lemma tensorAmplitude_counts (n : ℕ) (r : A → ℝ) (w : Fin n → A) : + tensorAmplitude n r w = ∏ a, Real.sqrt (r a)^wordCounts w a := + prod_wordCounts (fun a => Real.sqrt (r a)) w + +lemma tensorAmplitude_sq (n : ℕ) (r : A → ℝ) (hr : ∀ a, 0 ≤ r a) (w : Fin n → A) : + tensorAmplitude n r w * tensorAmplitude n r w = ∏ a, (r a)^wordCounts w a := by + rw [tensorAmplitude_counts, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro a ha + rw [← mul_pow, Real.mul_self_sqrt (hr a)] + +def phaseAverage (n : ℕ) (r : A → ℝ) : Matrix (Fin n → A) (Fin n → A) ℂ := + (((n+1 : ℕ) : ℂ)^Fintype.card A)⁻¹ • + ∑ θ : A → ZMod (n+1), rankOne (tensorProductVector n (phasedVector n r θ)) + +lemma phaseAverage_psd (n : ℕ) (r : A → ℝ) : (phaseAverage n r).PosSemidef := by + apply Matrix.PosSemidef.smul (Matrix.posSemidef_sum _ (fun θ _ => rankOne_psd _)) + exact inv_nonneg.mpr (pow_nonneg (by exact_mod_cast Nat.zero_le (n+1)) _) + +lemma phaseAverage_apply (n : ℕ) (r : A → ℝ) (hr : ∀ a, 0 ≤ r a) + (w v : Fin n → A) : + phaseAverage n r w v = if wordCounts w = wordCounts v then + ((∏ a, r a^wordCounts w a : ℝ) : ℂ) else 0 := by + simp only [phaseAverage, Matrix.smul_apply, Matrix.sum_apply, rankOne, vecMulVec, + Matrix.of_apply, Pi.star_apply, tensorProductVector_phased, star_mul, Complex.star_def, + Complex.conj_ofReal] + have hfactor : (∑ θ : A → ZMod (n+1), + ((tensorAmplitude n r w : ℂ) * tensorPhase n θ w) * + (star (tensorPhase n θ v) * (tensorAmplitude n r v : ℂ))) = + ((tensorAmplitude n r w : ℂ) * (tensorAmplitude n r v : ℂ)) * + ∑ θ : A → ZMod (n+1), tensorPhase n θ w * star (tensorPhase n θ v) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro θ hθ + ring + change (((n+1 : ℕ) : ℂ)^Fintype.card A)⁻¹ * _ = _ + simp only [Complex.star_def] at hfactor + rw [hfactor] + change _ * (_ * ∑ θ : A → ZMod (n+1), tensorPhase n θ w * star (tensorPhase n θ v)) = _ + rw [phase_pair_sum] + by_cases h : wordCounts w = wordCounts v + · rw [ite_eq_left h, ite_eq_left h] + have ha : tensorAmplitude n r w = tensorAmplitude n r v := by + simp only [tensorAmplitude_counts, h] + rw [← ha, ← Complex.ofReal_mul, tensorAmplitude_sq n r hr w] + have hp : (((n+1 : ℕ) : ℂ)^Fintype.card A) ≠ 0 := pow_ne_zero _ (by exact_mod_cast Nat.succ_ne_zero n) + field_simp + · simp [h] + +lemma phaseAverage_kernel (n : ℕ) (r : A → ℝ) (hr : ∀ a, 0 ≤ r a) : + phaseAverage n r = ∑ c : WordType A n, + ((∏ a, r a ^ c.val a : ℝ) : ℂ) • typeOnes (wordType n) c := by + ext w v + rw [phaseAverage_apply n r hr, sum_typeOnes] + simp only [wordType_eq_iff] + rfl + +omit [Fintype A] [DecidableEq A] in +lemma phasedVector_norm (n : ℕ) (r : A → ℝ) (hr : ∀ a, 0 ≤ r a) + (θ : A → ZMod (n+1)) (a : A) : + phasedVector n r θ a * star (phasedVector n r θ a) = (r a : ℂ) := by + have he : ZMod.stdAddChar (θ a) * star (ZMod.stdAddChar (θ a)) = 1 := by + rw [phase_star, ← AddChar.map_add_eq_mul, add_neg_cancel, AddChar.map_zero_eq_one] + simp only [phasedVector, star_mul, Complex.star_def, Complex.conj_ofReal] + calc + _ = ((Real.sqrt (r a) : ℂ) * Real.sqrt (r a)) * + (ZMod.stdAddChar (θ a) * star (ZMod.stdAddChar (θ a))) := by simp only [Complex.star_def]; ring + _ = _ := by rw [he, mul_one, ← Complex.ofReal_mul, Real.mul_self_sqrt (hr a)] + +omit [DecidableEq A] in +lemma phasedVector_trace (n : ℕ) (r : A → ℝ) (hr : ∀ a, 0 ≤ r a) + (hs : ∑ a, r a = 1) (θ : A → ZMod (n+1)) : + Matrix.trace (rankOne (phasedVector n r θ)) = 1 := by + simp only [Matrix.trace, Matrix.diag, rankOne, vecMulVec, Matrix.of_apply, Pi.star_apply, + phasedVector_norm n r hr, ← Complex.ofReal_sum, hs, Complex.ofReal_one] + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {A : Type*} [Fintype A] [DecidableEq A] + +def empirical (n : ℕ) (c : WordType A n) : A → ℝ := fun a => c.val a / (n : ℝ) + +lemma empirical_nonneg (n : ℕ) (c : WordType A n) (a : A) : 0 ≤ empirical n c a := + div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + +lemma empirical_sum (n : ℕ) (hn : 0 < n) (c : WordType A n) : ∑ a, empirical n c a = 1 := by + simp only [empirical, ← Finset.sum_div, ← Nat.cast_sum, wordType_total, + div_self (by exact_mod_cast Nat.ne_of_gt hn : (n : ℝ) ≠ 0)] + +lemma type_mass_inv (n : ℕ) (hn : 0 < n) (c : WordType A n) : + (Nat.multinomial Finset.univ c.val : ℝ)⁻¹ ≤ + ((n+1 : ℕ) : ℝ)^Fintype.card A * ∏ a, empirical n c a ^ c.val a := by + have hm : 0 < (Nat.multinomial Finset.univ c.val : ℝ) := by exact_mod_cast Nat.multinomial_pos _ _ + rw [inv_eq_one_div] + apply (div_le_iff₀ hm).mpr + have hh := type_mass_lower n hn c.val (wordType_total n c) + simpa only [empirical, mul_assoc, mul_left_comm, mul_comm] using hh + +theorem finite_postselection (n : ℕ) (hn : 0 < n) : + ((((n+1 : ℕ) : ℂ)^Fintype.card A) • + (∑ c : WordType A n, phaseAverage n (empirical n c)) - symmetricProjector n).PosSemidef := by + let d : WordType A n → ℝ := fun t => ((n+1 : ℕ) : ℝ)^Fintype.card A * + ∑ c : WordType A n, ∏ a, empirical n c a ^ t.val a + have hd (t : WordType A n) : (Nat.multinomial Finset.univ t.val : ℝ)⁻¹ ≤ d t := by + refine (type_mass_inv n hn t).trans ?_ + apply mul_le_mul_of_nonneg_left _ (pow_nonneg (Nat.cast_nonneg _) _) + exact Finset.single_le_sum (f := fun c : WordType A n => ∏ a, empirical n c a ^ t.val a) + (fun c _ => Finset.prod_nonneg + (fun a _ => pow_nonneg (empirical_nonneg n c a) _)) (Finset.mem_univ t) + convert typeKernel_mono (wordType (A := A) n) + (fun t => (Nat.multinomial Finset.univ t.val : ℝ)⁻¹) d hd using 1 + apply Iff.of_eq + congr 1 + ext w v + simp only [Matrix.sub_apply, Matrix.smul_apply, Matrix.sum_apply, + phaseAverage_apply n _ (empirical_nonneg n _), symmetricProjector, smul_eq_mul, + wordType_eq_iff, Pi.sub_apply] + split_ifs with h + · simp only [d, Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_natCast, + Complex.ofReal_sum, Complex.ofReal_inv] + rfl + · simp + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/EvenPostselection.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/EvenPostselection.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c90b5cefe7dc1550b08d7d0a336e897d36552d1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/EvenPostselection.lean @@ -0,0 +1,230 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungHilbert +import OAI.Probability.BinarySweep.TensorBounds.TensorReduction +import OAI.Probability.BinarySweep.MatrixBounds.MatrixSqrtBlocks + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {K A B : Type*} [Fintype K] [DecidableEq K] [Fintype A] [DecidableEq A] + [Fintype B] [DecidableEq B] + +lemma reduced_postselection (n : ℕ) (hn : 0 < n) (e : K → A × B) + (v : (Fin n → K) → ℂ) + (hv : ∀ w u, wordCounts w = wordCounts u → v w = v u) : + ((rankOne v).trace • (∑ c : WordType K n, ∑ t : K → ZMod (n+1), + matrixTensorPower n (reducedPhaseDensity n e c t)) - + reshape (wordPair n e) v * (reshape (wordPair n e) v).conjTranspose).PosSemidef := by + have h := densityChannel_psd (wordPair n e) (symmetric_vector_postselection n hn v hv) + rw [densityChannel_sub, densityChannel_smul, densityChannel_sum] at h + simp only [phaseAverage, densityChannel_smul, densityChannel_sum, + densityChannel_tensorRankOne, ← Finset.smul_sum, smul_smul] at h + have hd : (((n+1 : ℕ) : ℂ)^Fintype.card K) ≠ 0 := + pow_ne_zero _ (by exact_mod_cast Nat.succ_ne_zero n) + rw [mul_assoc, mul_inv_cancel₀ hd, mul_one, densityChannel_rankOne] at h + exact h + +variable {P : Type*} [DecidableEq P] + +def MatchedPair (p : A → P) := {x : A × A // p x.1 = p x.2} +instance (p : A → P) : Fintype (MatchedPair p) := + inferInstanceAs (Fintype {pair : A × A // p pair.1 = p pair.2}) +instance (p : A → P) : DecidableEq (MatchedPair p) := + inferInstanceAs (DecidableEq {pair : A × A // p pair.1 = p pair.2}) + +def matchedEmbedding (p : A → P) : MatchedPair p → A × A := Subtype.val + +omit [Fintype A] [DecidableEq A] [DecidableEq P] in +lemma matchedEmbedding_injective (p : A → P) : Function.Injective (matchedEmbedding p) := + Subtype.val_injective + +def pairVector (n : ℕ) (p : A → P) (Q : Matrix (Fin n → A) (Fin n → A) ℂ) : + (Fin n → MatchedPair p) → ℂ := + fun w => Q (fun i => (w i).val.1) (fun i => (w i).val.2) + +lemma reshape_pairVector (n : ℕ) (p : A → P) (Q : Matrix (Fin n → A) (Fin n → A) ℂ) + (hQ : ∀ x y, (fun i => p (x i)) ≠ (fun i => p (y i)) → Q x y = 0) : + reshape (wordPair n (matchedEmbedding p)) (pairVector n p Q) = Q := by + ext x y + by_cases h : (fun i => p (x i)) = (fun i => p (y i)) + · let w : Fin n → MatchedPair p := fun i => ⟨(x i,y i), congrFun h i⟩ + have hw : wordPair n (matchedEmbedding p) w = (x,y) := rfl + have ht := reshape_injective_apply (wordPair n (matchedEmbedding p)) + (wordPair_injective n _ (matchedEmbedding_injective p)) (pairVector n p Q) w + rw [hw] at ht + exact ht + · have hn : (x,y) ∉ Set.range (wordPair n (matchedEmbedding p)) := by + rintro ⟨w,hw⟩ + apply h + funext i + have hi := (wordPair_eq_iff n _ w x y).mp hw i + have hh := (w i).property + change p (matchedEmbedding p (w i)).1 = p (matchedEmbedding p (w i)).2 at hh + rw [hi] at hh + exact hh + rw [reshape_outside _ _ x y hn, hQ x y h] + +def wordPerm (n : ℕ) (g : Equiv.Perm (Fin n)) : Equiv.Perm (Fin n → A) where + toFun x := x ∘ g + invFun x := x ∘ g.symm + left_inv x := by funext i; simp + right_inv x := by funext i; simp + +omit [Fintype A] [DecidableEq P] in +lemma pairVector_symmetric (n : ℕ) (p : A → P) (Q : Matrix (Fin n → A) (Fin n → A) ℂ) + (hQ : ∀ (g : Equiv.Perm (Fin n)) x y, Q (x ∘ g) (y ∘ g) = Q x y) : + ∀ w u, wordCounts w = wordCounts u → pairVector n p Q w = pairVector n p Q u := by + intro w u h + obtain ⟨g,hg⟩ := exists_perm_eq_of_wordCounts h + have hw : w = u ∘ g := (funext hg).symm + rw [hw] + simpa only [pairVector, Function.comp_def] using + hQ g (fun i => (u i).val.1) (fun i => (u i).val.2) + +theorem even_block_postselection (n : ℕ) (hn : 0 < n) (p : A → P) + (Q : Matrix (Fin n → A) (Fin n → A) ℂ) (hQ : Q.PosSemidef) + (hblock : ∀ x y, (p ∘ x) ≠ (p ∘ y) → Q x y = 0) + (hperm : ∀ (g : Equiv.Perm (Fin n)) x y, Q (x ∘ g) (y ∘ g) = Q x y) : + (Q.trace • (∑ c : WordType (MatchedPair p) n, ∑ t : MatchedPair p → ZMod (n+1), + matrixTensorPower n (reducedPhaseDensity n (matchedEmbedding p) c t)) - Q).PosSemidef := by + let S := CFC.sqrt Q + have hSblock : ∀ x y, (p ∘ x) ≠ (p ∘ y) → S x y = 0 := + sqrt_block_diagonal (fun x => p ∘ x) Q hblock + have hSperm (g : Equiv.Perm (Fin n)) (x y) : S (x ∘ g) (y ∘ g) = S x y := by + have hh := sqrt_submatrix_invariant Q hQ (wordPerm n g) (by + ext u v; exact hperm g u v) + exact congrFun (congrFun hh x) y + let v := pairVector n p S + have hr : reshape (wordPair n (matchedEmbedding p)) v = S := + reshape_pairVector n p S hSblock + have ht : (rankOne v).trace = Q.trace := by + rw [← reshape_trace (wordPair n (matchedEmbedding p)) + (wordPair_injective n _ (matchedEmbedding_injective p)) v, hr, sqrt_gram Q hQ] + have hh := reduced_postselection n hn (matchedEmbedding p) v (pairVector_symmetric n p S hSperm) + rw [ht, hr, sqrt_gram Q hQ] at hh + exact hh + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder +open Equiv Equiv.Perm Matrix + +namespace BinaryCoordinateSweeps.Signed +variable {A : Type*} {n : ℕ} + +def signC (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) : ℂ := + ((koszulSign β g : ℤ) : ℂ) + +@[simp] lemma signC_one (β : Fin n → Bool) : signC β 1 = 1 := by simp [signC] +lemma signC_mul (β : Fin n → Bool) (f g : Equiv.Perm (Fin n)) : + signC β (f*g) = signC (β ∘ g.symm) f * signC β g := by + simp only [signC, koszulSign_mul, Units.val_mul, Int.cast_mul] +lemma signC_sq (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) : + signC β g * signC β g = 1 := by + unfold signC + rw [← Int.cast_mul, ← Units.val_mul, koszulSign_sq] + norm_num +@[simp] lemma signC_star (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) : + star (signC β g) = signC β g := by simp [signC] +lemma signC_swap (β : Fin n → Bool) (a b : Fin n) (hab : a ≠ b) (hβ : β a = β b) : + signC β (Equiv.swap a b) = if β a = true then -1 else 1 := by + simp only [signC, koszulSign_swap β a b hab hβ] + split_ifs <;> norm_num + +def act (p : A → Bool) (g : Equiv.Perm (Fin n)) : + ((Fin n → A) → ℂ) →ₗ[ℂ] ((Fin n → A) → ℂ) where + toFun v x := signC (p ∘ x) g⁻¹ * v (x ∘ g) + map_add' u v := by ext x; simp only [Pi.add_apply, mul_add] + map_smul' c v := by ext x; simp only [Pi.smul_apply, smul_eq_mul, mul_left_comm, + RingHom.id_apply] + +@[simp] lemma act_apply (p : A → Bool) (g : Equiv.Perm (Fin n)) (v : (Fin n → A) → ℂ) (x) : + act p g v x = signC (p ∘ x) g⁻¹ * v (x ∘ g) := rfl + +lemma act_one (p : A → Bool) : act (n := n) p 1 = 1 := by + ext v x + simp [act] + +lemma act_mul (p : A → Bool) (g h : Equiv.Perm (Fin n)) : + act p (g*h) = act p g * act p h := by + apply LinearMap.ext + intro v + funext x + change signC (p ∘ x) (g*h)⁻¹ * v (x ∘ ⇑(g*h)) = + signC (p ∘ x) g⁻¹ * (signC (p ∘ (x ∘ g)) h⁻¹ * v ((x ∘ g) ∘ h)) + simp only [_root_.mul_inv_rev, signC_mul] + have he : (p ∘ x) ∘ (Equiv.symm g⁻¹) = p ∘ (x ∘ g) := rfl + rw [he] + have hw : x ∘ ⇑(g*h) = (x ∘ g) ∘ h := rfl + rw [hw] + ring + +def tensorRep (p : A → Bool) (n : ℕ) : Representation ℂ (Equiv.Perm (Fin n)) ((Fin n → A) → ℂ) where + toFun := act p + map_one' := act_one p + map_mul' := act_mul p + +def Invariant (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) : Prop := + ∀ (g : Equiv.Perm (Fin n)) x y, + M (x ∘ g) (y ∘ g) = signC (p ∘ x) g⁻¹ * signC (p ∘ y) g⁻¹ * M x y + +lemma invariant_same_parity (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hM : Invariant p M) (g : Equiv.Perm (Fin n)) (x y : Fin n → A) + (h : p ∘ x = p ∘ y) : M (x ∘ g) (y ∘ g) = M x y := by + rw [hM g x y, h, signC_sq, one_mul] + +lemma comp_swap_eq {T : Type*} (x : Fin n → T) (i j : Fin n) (h : x i = x j) : + x ∘ Equiv.swap i j = x := by + funext k + simp only [Function.comp_apply, Equiv.swap_apply_def] + split_ifs <;> simp_all + +lemma invariant_repeated_mismatch_zero (p : A → Bool) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) (hM : Invariant p M) + (x y : Fin n → A) (i j : Fin n) (hij : i ≠ j) + (hx : x i = x j) (hy : y i = y j) (hp : p (x i) ≠ p (y i)) : M x y = 0 := by + have h := hM (Equiv.swap i j) x y + rw [comp_swap_eq x i j hx, comp_swap_eq y i j hy, Equiv.swap_inv, + signC_swap _ i j hij (by change p (x i)=p (x j); rw [hx]), + signC_swap _ i j hij (by change p (y i)=p (y j); rw [hy])] at h + simp only [Function.comp_apply] at h + cases hx' : p (x i) <;> cases hy' : p (y i) + · exact False.elim (hp (hx'.trans hy'.symm)) + · simp only [hx', hy', Bool.false_eq_true, ↓reduceIte, one_mul, neg_one_mul] at h + linear_combination (1/2 : ℂ) * h + · simp only [hx', hy', Bool.false_eq_true, ↓reduceIte, mul_one, neg_one_mul] at h + linear_combination (1/2 : ℂ) * h + · exact False.elim (hp (hx'.trans hy'.symm)) + +variable [Fintype A] + +lemma invariant_mismatch_card (p : A → Bool) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) (hM : Invariant p M) + (x y : Fin n → A) (hxy : M x y ≠ 0) : + (Finset.univ.filter (fun i => p (x i) ≠ p (y i))).card ≤ (Fintype.card A)^2 := by + let T := {i : Fin n // p (x i) ≠ p (y i)} + let f : T → A × A := fun i => (x i.val,y i.val) + have hf : Function.Injective f := by + intro i j hij + apply Subtype.ext + by_contra h + have hx := congrArg Prod.fst hij + have hy := congrArg Prod.snd hij + exact hxy (invariant_repeated_mismatch_zero p M hM x y i j h hx hy i.property) + have hc := Fintype.card_le_of_injective f hf + simpa only [T, Fintype.card_subtype, Fintype.card_prod, pow_two] using hc + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/PiTensorMatrices.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/PiTensorMatrices.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b83448ec631412ad13ac8631d803da440601a77 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/PiTensorMatrices.lean @@ -0,0 +1,111 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I : Type*} [Fintype I] [DecidableEq I] + {A B C : I → Type*} [∀ i, Fintype (A i)] [∀ i, DecidableEq (A i)] + [∀ i, Fintype (B i)] [∀ i, DecidableEq (B i)] + [∀ i, Fintype (C i)] [∀ i, DecidableEq (C i)] + +def piTensorMatrices (M : ∀ i, Matrix (A i) (B i) ℂ) : + Matrix (∀ i, A i) (∀ i, B i) ℂ := fun x y => ∏ i, M i (x i) (y i) + +omit [∀ index, Fintype (A index)] [∀ index, DecidableEq (A index)] + [∀ index, DecidableEq (B index)] [∀ index, Fintype (C index)] + [∀ index, DecidableEq (C index)] in +lemma piTensorMatrices_mul (M : ∀ i, Matrix (A i) (B i) ℂ) + (N : ∀ i, Matrix (B i) (C i) ℂ) : + piTensorMatrices M * piTensorMatrices N = piTensorMatrices (fun i => M i*N i) := by + ext x z + simp only [Matrix.mul_apply,piTensorMatrices,← Finset.prod_mul_distrib] + exact (Fintype.prod_sum (fun i b => M i (x i) b * N i b (z i))).symm + +omit [DecidableEq I] [∀ index, Fintype (A index)] [∀ index, DecidableEq (A index)] + [∀ index, Fintype (B index)] [∀ index, DecidableEq (B index)] in +lemma piTensorMatrices_star (M : ∀ i, Matrix (A i) (B i) ℂ) : + (piTensorMatrices M).conjTranspose = piTensorMatrices (fun i => (M i).conjTranspose) := by + ext x y + simp [piTensorMatrices] + +omit [DecidableEq I] [∀ index, Fintype (A index)] in +lemma piTensorMatrices_one : piTensorMatrices (fun i : I => (1 : Matrix (A i) (A i) ℂ))=1 := by + ext x y + by_cases h : x=y + · subst y; simp [piTensorMatrices] + · obtain ⟨i,hi⟩ := Function.ne_iff.mp h + simp only [piTensorMatrices,Matrix.one_apply,ite_eq_right h] + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +lemma piTensorMatrices_psd (M : ∀ i, Matrix (A i) (A i) ℂ) (hM : ∀ i, (M i).PosSemidef) : + (piTensorMatrices M).PosSemidef := by + have hx (i : I) : ∃ X : Matrix (A i) (A i) ℂ, M i=X.conjTranspose*X := + CStarAlgebra.nonneg_iff_eq_star_mul_self.mp (hM i).nonneg + choose X hX using hx + have he : piTensorMatrices M = (piTensorMatrices X).conjTranspose*piTensorMatrices X := by + rw [piTensorMatrices_star,piTensorMatrices_mul] + congr 1 + funext i + exact hX i + rw [he] + exact Matrix.posSemidef_conjTranspose_mul_self _ + +omit [∀ index, DecidableEq (A index)] in +lemma piTensorMatrices_trace (M : ∀ i, Matrix (A i) (A i) ℂ) : + (piTensorMatrices M).trace = ∏ i, (M i).trace := by + simp only [Matrix.trace,Matrix.diag,piTensorMatrices] + exact (Fintype.prod_sum (fun i a => M i a a)).symm + +omit [DecidableEq I] [∀ index, Fintype (A index)] [∀ index, DecidableEq (A index)] + [∀ index, Fintype (B index)] [∀ index, DecidableEq (B index)] in +lemma piTensorMatrices_smul (c : I → ℂ) (M : ∀ i, Matrix (A i) (B i) ℂ) : + piTensorMatrices (fun i => c i • M i) = (∏i, c i) • piTensorMatrices M := by + ext x y + simp only [piTensorMatrices,Matrix.smul_apply,smul_eq_mul,Finset.prod_mul_distrib] + +omit [∀ index, Fintype (A index)] [∀ index, DecidableEq (A index)] + [∀ index, Fintype (B index)] [∀ index, DecidableEq (B index)] in +lemma piTensorMatrices_sum {W : I → Type*} [∀ i, Fintype (W i)] + (M : ∀ i, W i → Matrix (A i) (B i) ℂ) : + piTensorMatrices (fun i => ∑w, M i w) = ∑f : ∀ i, W i, piTensorMatrices (fun i => M i (f i)) := by + ext x y + simp only [piTensorMatrices,Matrix.sum_apply] + exact Fintype.prod_sum (fun i w => M i w (x i) (y i)) + +lemma piTensorMatrices_mono (M N : ∀ i, Matrix (A i) (A i) ℂ) + (hM : ∀ i, (M i).PosSemidef) (hMN : ∀ i, (N i-M i).PosSemidef) : + (piTensorMatrices N-piTensorMatrices M).PosSemidef := by + let T (i : I) (b : Bool) := if b then N i-M i else M i + have he : piTensorMatrices N = ∑f : I → Bool, piTensorMatrices (fun i => T i (f i)) := by + rw [← piTensorMatrices_sum] + congr 1 + funext i + simp [T] + have hf : piTensorMatrices M = piTensorMatrices (fun i => T i false) := by simp [T] + rw [he,hf,← Finset.sum_erase_add _ _ (Finset.mem_univ (fun _ : I => false)),add_sub_cancel_right] + apply Matrix.posSemidef_sum + intro f _ + apply piTensorMatrices_psd + intro i + dsimp [T] + split + · exact hMN i + · exact hM i + +theorem piTensor_density_domination {W : I → Type*} [∀ i, Fintype (W i)] + (P : ∀ i, Matrix (A i) (A i) ℂ) (r : ∀ i, W i → Matrix (A i) (A i) ℂ) + (c : I → ℂ) (hP : ∀ i, (P i).PosSemidef) + (hdom : ∀ i, (c i • ∑w, r i w-P i).PosSemidef) : + ((∏i, c i) • (∑f : ∀ i, W i, piTensorMatrices (fun i => r i (f i)))-piTensorMatrices P).PosSemidef := by + have h := piTensorMatrices_mono P (fun i => c i • ∑w, r i w) hP hdom + rwa [piTensorMatrices_smul,piTensorMatrices_sum] at h + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedBlock.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c4fb7d7351a4a22009cc31fc1fe144197c74655 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedBlock.lean @@ -0,0 +1,129 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungResolution + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical Kronecker +open Equiv Matrix + +namespace BinaryCoordinateSweeps.Signed +variable {A : Type*} [Fintype A] [DecidableEq A] {n m : ℕ} + +@[simp] lemma sumPerm_inv (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) : + (sumPerm g h)⁻¹ = sumPerm g⁻¹ h⁻¹ := by + apply Equiv.ext + intro i + apply (sumPerm g h).injective + change (sumPerm g h) ((sumPerm g h).symm i) = _ + rw [Equiv.apply_symm_apply] + induction i using Fin.addCases with + | left i => simp + | right i => simp + +lemma signC_sum (β : Fin (n+m) → Bool) + (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) : + signC β (sumPerm g h) = + signC (fun i => β (i.castAdd m)) g * signC (fun i => β (i.natAdd n)) h := by + simp only [signC,koszulSign_sum,Units.val_mul,Int.cast_mul] + +def splitWord : (Fin (n+m) → A) ≃ (Fin n → A) × (Fin m → A) := + (finSumFinEquiv.symm.arrowCongr (Equiv.refl A)).trans (Equiv.sumArrowEquivProdArrow _ _ _) + +omit [Fintype A] [DecidableEq A] in +@[simp] lemma splitWord_fst (x : Fin (n+m) → A) (i : Fin n) : + (splitWord x).1 i = x (i.castAdd m) := rfl +omit [Fintype A] [DecidableEq A] in +@[simp] lemma splitWord_snd (x : Fin (n+m) → A) (i : Fin m) : + (splitWord x).2 i = x (i.natAdd n) := rfl + +omit [Fintype A] [DecidableEq A] in +lemma splitWord_comp (x : Fin (n+m) → A) (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) : + splitWord (x ∘ sumPerm g h) = ((splitWord x).1 ∘ g,(splitWord x).2 ∘ h) := by + apply Prod.ext <;> funext i <;> simp + +lemma actionMatrix_apply (p : A → Bool) (g : Equiv.Perm (Fin n)) (x y : Fin n → A) : + LinearMap.toMatrix' (act p g) x y = if x ∘ g = y then signC (p ∘ x) g⁻¹ else 0 := by + simp only [LinearMap.toMatrix'_apply,act_apply,Pi.single_apply] + split_ifs with h + · simp + · simp + +theorem actionMatrix_sum (p : A → Bool) (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) : + LinearMap.toMatrix' (act p (sumPerm g h)) = + ((LinearMap.toMatrix' (act p g)) ⊗ₖ (LinearMap.toMatrix' (act p h))).submatrix splitWord splitWord := by + ext x y + change LinearMap.toMatrix' (act p (sumPerm g h)) x y = + LinearMap.toMatrix' (act p g) (splitWord x).1 (splitWord y).1 * + LinearMap.toMatrix' (act p h) (splitWord x).2 (splitWord y).2 + rw [actionMatrix_apply,actionMatrix_apply,actionMatrix_apply,sumPerm_inv,signC_sum] + have he : x ∘ sumPerm g h = y ↔ + (splitWord x).1 ∘ g = (splitWord y).1 ∧ (splitWord x).2 ∘ h = (splitWord y).2 := by + rw [← splitWord.injective.eq_iff,splitWord_comp,Prod.mk.injEq] + simp only [he] + split_ifs <;> simp_all only [zero_mul,mul_zero,and_self,not_true_eq_false,true_and,false_and]; rfl + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +abbrev actionMatrix (p : A → Bool) (g : Equiv.Perm (Fin n)) := LinearMap.toMatrix' (act p g) + +lemma actionMatrix_conjugate_apply (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) (x y : Fin n → A) : + (actionMatrix p g * M * (actionMatrix p g).conjTranspose) x y= + signC (p ∘ x) g⁻¹ * signC (p ∘ y) g⁻¹ * M (x ∘ g) (y ∘ g) := by + simp only [Matrix.mul_apply,Matrix.conjTranspose_apply,actionMatrix_apply] + simp [apply_ite,signC_star,mul_assoc,mul_left_comm,mul_comm] + +lemma actionMatrix_unitary (p : A → Bool) (g : Equiv.Perm (Fin n)) : + actionMatrix p g * (actionMatrix p g).conjTranspose=1 := by + have he (x y : Fin n → A) : x ∘ g = y ∘ g ↔ x=y := + (wordReorder g).injective.eq_iff + ext x y + have hh := actionMatrix_conjugate_apply p g 1 x y + rw [mul_one] at hh + rw [hh] + by_cases h:x=y + · subst y + simp only [Matrix.one_apply,ite_true,signC_sq,mul_one] + · simp [he,h] + +lemma actionMatrix_star_mul (p : A → Bool) (g : Equiv.Perm (Fin n)) : + (actionMatrix p g).conjTranspose * actionMatrix p g = 1 := + mul_eq_one_comm.mp (actionMatrix_unitary p g) + +theorem even_tensor_covariance (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M : Fin n → Matrix A A ℂ) + (hM : ∀ i a b, p a ≠ p b → M i a b=0) : + actionMatrix p g * tensorMatrices M * (actionMatrix p g).conjTranspose = + tensorMatrices (fun i => M (g⁻¹ i)) := by + ext x y + rw [actionMatrix_conjugate_apply] + have he : tensorMatrices M (x ∘ g) (y ∘ g) = tensorMatrices (fun i => M (g⁻¹ i)) x y := by + simpa [tensorMatrices] using + Equiv.prod_comp g (fun i => M (g⁻¹ i) (x i) (y i)) + rw [he] + by_cases h : p ∘ x=p ∘ y + · rw [h,signC_sq,one_mul] + · obtain ⟨i,hi⟩ := Function.ne_iff.mp h + have hz : tensorMatrices (fun i => M (g⁻¹ i)) x y=0 := + Finset.prod_eq_zero (Finset.mem_univ i) (hM _ _ _ hi) + rw [hz,mul_zero] + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedBlocks.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6f4272417fbe19c12f9fb1a4c4636241ff8ceb3 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedBlocks.lean @@ -0,0 +1,197 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedBlock +import OAI.Probability.BinarySweep.Representations.IsotypicDensity +import OAI.Probability.BinarySweep.TensorBounds.PiTensorMatrices +import OAI.Probability.BinarySweep.YoungTheory.KoszulBlocks + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Signed +open Matrix Density + +variable {I A : Type*} [Fintype I] [LinearOrder I] + [Fintype A] [DecidableEq A] {n : I → ℕ} {N : ℕ} + +omit [Fintype I] in +@[simp] lemma blockPerm_inv (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) : (blockPerm e g)⁻¹=blockPerm e (fun i => (g i)⁻¹) := by + apply Equiv.ext + intro x + obtain ⟨⟨i,a⟩,rfl⟩ := (toLex.trans e.toEquiv).surjective x + apply (blockPerm e g).injective + change blockPerm e g ((blockPerm e g).symm (e (toLex ⟨i,a⟩))) = _ + rw [Equiv.apply_symm_apply] + simp + +lemma signC_blocks (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (β : Fin N → Bool) : + signC β (blockPerm e g) = ∏i, signC (fun a => β (e (toLex ⟨i,a⟩))) (g i) := by + simp only [signC,koszulSign_blocks,Units.coe_prod,Int.cast_prod] + +def blockWords (e : (Σₗ i, Fin (n i)) ≃o Fin N) : + (Fin N → A) ≃ (∀i, Fin (n i) → A) := + ((toLex.trans e.toEquiv).symm.arrowCongr (Equiv.refl A)).trans (Equiv.piCurry (fun _ _ => A)) + +omit [Fintype I] [Fintype A] [DecidableEq A] in +@[simp] lemma blockWords_apply (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (x : Fin N → A) (i : I) (a : Fin (n i)) : blockWords e x i a=x (e (toLex ⟨i,a⟩)) := rfl + +omit [Fintype I] [Fintype A] [DecidableEq A] in +lemma blockWords_comp (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (x : Fin N → A) : + blockWords e (x ∘ blockPerm e g) = fun i => (blockWords e x i) ∘ g i := by + funext i a + simp + +theorem actionMatrix_blocks (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (p : A → Bool) : + LinearMap.toMatrix' (act p (blockPerm e g)) = + (piTensorMatrices (fun i => LinearMap.toMatrix' (act p (g i)))).submatrix + (blockWords e) (blockWords e) := by + ext x y + change LinearMap.toMatrix' (act p (blockPerm e g)) x y = + ∏i, LinearMap.toMatrix' (act p (g i)) (blockWords e x i) (blockWords e y i) + simp only [actionMatrix_apply] + have he : x ∘ blockPerm e g=y ↔ ∀i, (blockWords e x i) ∘ g i=blockWords e y i := by + rw [← (blockWords e).injective.eq_iff,blockWords_comp] + exact funext_iff + by_cases h : x ∘ blockPerm e g=y + · rw [ite_eq_left h,blockPerm_inv,signC_blocks] + apply Finset.prod_congr rfl + intro i _ + rw [ite_eq_left (he.mp h i)] + rfl + · rw [ite_eq_right h] + have hh := h + rw [he] at hh + push Not at hh + obtain ⟨i,hi⟩ := hh + symm + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical ComplexOrder MonoidAlgebra +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation + +variable {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A] + +def vacuumDensity : Matrix A A ℂ := Matrix.diagonal (fun a => if a=Classical.choice (inferInstance : Nonempty A) then 1 else 0) + +omit [Fintype A] in +lemma vacuumDensity_psd : (vacuumDensity (A:=A)).PosSemidef := by + apply Matrix.posSemidef_diagonal_iff.mpr + intro a + split <;> norm_num + +lemma vacuumDensity_trace : (vacuumDensity (A:=A)).trace=1 := by + simp [vacuumDensity,Matrix.trace,Matrix.diag] + +omit [Fintype A] in +lemma vacuumDensity_even (p : A → Bool) (a b : A) (h : p a ≠ p b) : + vacuumDensity a b=0 := by + have hh : a≠b := fun he => h (congrArg p he) + simp [vacuumDensity,hh] + +abbrev LocalDensityIndex (p : A → Bool) (n : ℕ) := + WordType (MatchedPair p) n × (MatchedPair p → ZMod (n+1)) + +def localDensity (p : A → Bool) (n : ℕ) (u : LocalDensityIndex p n) : Matrix A A ℂ := + if n=0 then vacuumDensity else reducedPhaseDensity n (matchedEmbedding p) u.1 u.2 + +lemma localDensity_psd (p : A → Bool) (n : ℕ) (u : LocalDensityIndex p n) : + (localDensity p n u).PosSemidef := by + unfold localDensity + split + · exact vacuumDensity_psd + · exact reducedPhaseDensity_psd _ _ _ _ + +lemma localDensity_trace (p : A → Bool) (n : ℕ) (u : LocalDensityIndex p n) : + (localDensity p n u).trace=1 := by + unfold localDensity + split + · exact vacuumDensity_trace + · exact reducedPhaseDensity_trace n (by omega) _ (matchedEmbedding_injective p) _ _ + +lemma localDensity_even (p : A → Bool) (n : ℕ) (u : LocalDensityIndex p n) + (a b : A) (h : p a ≠ p b) : localDensity p n u a b=0 := by + unfold localDensity + split + · exact vacuumDensity_even p a b h + · exact reducedPhaseDensity_even n p p (matchedEmbedding p) (fun k => k.property) _ _ a b h + +omit [Nonempty A] in +lemma localDensityIndex_card (p : A → Bool) (n : ℕ) : + Fintype.card (LocalDensityIndex p n) ≤ (n+1)^(2*(Fintype.card A)^2) := by + have hc : Fintype.card (MatchedPair p) ≤ (Fintype.card A)^2 := by + simpa only [Fintype.card_prod,pow_two] using Fintype.card_le_of_injective + (matchedEmbedding p) (matchedEmbedding_injective p) + calc + _ = Fintype.card (WordType (MatchedPair p) n) * (n+1)^Fintype.card (MatchedPair p) := by + rw [Fintype.card_prod,Fintype.card_fun,ZMod.card] + _ ≤ (n+1)^Fintype.card (MatchedPair p) * (n+1)^Fintype.card (MatchedPair p) := + Nat.mul_le_mul_right _ (by simpa only [Fintype.card_coe] using card_types_le (A:=MatchedPair p) n) + _ = (n+1)^(2*Fintype.card (MatchedPair p)) := by rw [two_mul,pow_add] + _ ≤ _ := Nat.pow_le_pow_right (by omega) (Nat.mul_le_mul_left 2 hc) + +lemma localDensityIndex_nonempty (p : A → Bool) (n : ℕ) : Nonempty (LocalDensityIndex p n) := by + let a : A := Classical.choice inferInstance + exact ⟨wordType n (fun _ => ⟨(a,a),rfl⟩),fun _ => 0⟩ + +lemma projection_complement_psd {I : Type*} [Fintype I] [DecidableEq I] + (P : Matrix I I ℂ) (hP : P.IsHermitian) (hPP : P*P=P) : (1-P).PosSemidef := by + have he : (1-P).conjTranspose*(1-P)=1-P := by + simp only [Matrix.conjTranspose_sub,Matrix.conjTranspose_one,hP.eq,mul_sub,sub_mul, + one_mul,mul_one,hPP] + abel + rw [← he] + exact Matrix.posSemidef_conjTranspose_mul_self _ + +variable {V : Type*} [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + +theorem local_type_density_domination (p : A → Bool) (n : ℕ) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] : + (((Module.finrank ℂ V : ℂ)*(n+1 : ℂ)^(2*(Fintype.card A)^2)) • + (∑u : LocalDensityIndex p n, matrixTensorPower n (localDensity p n u)) - + isotypicProjection p ρ).PosSemidef := by + by_cases hn : n=0 + · subst n + have : Nonempty (LocalDensityIndex p 0) := localDensityIndex_nonempty p 0 + have hc : Fintype.card (LocalDensityIndex p 0)=1 := le_antisymm + (by simp) (Fintype.card_pos_iff.mpr inferInstance) + have he (u : LocalDensityIndex p 0) : matrixTensorPower 0 (localDensity p 0 u)=1 := by + ext x y + simp [matrixTensorPower,Matrix.one_apply,Subsingleton.elim x y] + simp only [he,Finset.sum_const,Finset.card_univ,hc,one_nsmul,Nat.cast_zero,zero_add,one_pow,mul_one] + have : Nontrivial ρ.asModule := IsSimpleModule.nontrivial ℂ[Equiv.Perm (Fin 0)] ρ.asModule + have hd : (1:ℂ) ≤ (Module.finrank ℂ V : ℂ) := by + have hh : 0 < Module.finrank ℂ V := by + rw [← ρ.asModuleEquiv.finrank_eq] + exact Module.finrank_pos + exact_mod_cast hh + have h := (Matrix.PosSemidef.one : (1 : Matrix (Fin 0 → A) (Fin 0 → A) ℂ).PosSemidef).smul + (sub_nonneg.mpr hd) + have hp := projection_complement_psd (isotypicProjection p ρ) + (isotypicProjection_psd p ρ).isHermitian (projectionMatrix_idempotent _) + convert h.add hp using 1 + simp only [sub_smul,one_smul] + abel + · simpa only [localDensity,ite_eq_right hn,Fintype.sum_prod_type] using + isotypic_density_domination n (by omega) p ρ + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedCommutant.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedCommutant.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fd823e0f9711df9a1ba6901082284e7ce033ec2 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedCommutant.lean @@ -0,0 +1,200 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.EvenPostselection + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical +open Equiv Equiv.Perm Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +def invariantSubspace (p : A → Bool) (n : ℕ) : + Submodule ℂ (Matrix (Fin n → A) (Fin n → A) ℂ) where + carrier := {M | Invariant p M} + zero_mem' := by intro g x y; simp + add_mem' := by + intro M N hM hN g x y + simp only [Matrix.add_apply, hM g x y, hN g x y, mul_add] + smul_mem' := by + intro c M hM g x y + simp only [Matrix.smul_apply, smul_eq_mul, hM g x y] + ring + +abbrev RealizedType (A : Type*) [Fintype A] [DecidableEq A] (n : ℕ) := + Set.range (wordType (A := A × A) n) + +def typeRepresentative (c : RealizedType A n) : Fin n → A × A := c.property.choose + +lemma typeRepresentative_type (c : RealizedType A n) : + wordType n (typeRepresentative c) = c.val := c.property.choose_spec + +def invariantCode (p : A → Bool) (n : ℕ) : + invariantSubspace p n →ₗ[ℂ] (RealizedType A n → ℂ) where + toFun M c := M.val (Prod.fst ∘ typeRepresentative c) (Prod.snd ∘ typeRepresentative c) + map_add' _ _ := rfl + map_smul' _ _ := rfl + +lemma invariantCode_injective (p : A → Bool) (n : ℕ) : + Function.Injective (invariantCode p n) := by + intro M N h + apply Subtype.ext + ext x y + let w : Fin n → A × A := fun i => (x i,y i) + let c : RealizedType A n := ⟨wordType n w, ⟨w,rfl⟩⟩ + have hc : wordCounts w = wordCounts (typeRepresentative c) := + (wordType_eq_iff n w _).mp (typeRepresentative_type c).symm + obtain ⟨g,hg⟩ := exists_perm_eq_of_wordCounts hc + have hx : (Prod.fst ∘ typeRepresentative c) ∘ g = x := by + funext i + exact congrArg Prod.fst (hg i) + have hy : (Prod.snd ∘ typeRepresentative c) ∘ g = y := by + funext i + exact congrArg Prod.snd (hg i) + have hm := M.property g (Prod.fst ∘ typeRepresentative c) (Prod.snd ∘ typeRepresentative c) + have hn := N.property g (Prod.fst ∘ typeRepresentative c) (Prod.snd ∘ typeRepresentative c) + rw [hx,hy] at hm hn + rw [hm,hn] + exact congrArg (fun z : ℂ => signC (p ∘ (Prod.fst ∘ typeRepresentative c)) g⁻¹ * + signC (p ∘ (Prod.snd ∘ typeRepresentative c)) g⁻¹ * z) (congrFun h c) + +lemma invariantSubspace_finrank (p : A → Bool) (n : ℕ) : + Module.finrank ℂ (invariantSubspace p n) ≤ (n+1)^((Fintype.card A)^2) := by + let : Fintype (RealizedType A n) := Fintype.ofFinite _ + have h := LinearMap.finrank_le_finrank_of_injective (f := invariantCode p n) + (invariantCode_injective p n) + rw [Module.finrank_pi] at h + have hc := Fintype.card_le_of_injective (fun c : RealizedType A n => c.val) Subtype.val_injective + have ht := card_types_le (A := A × A) n + simp only [Fintype.card_coe, Fintype.card_prod, ← pow_two] at hc ht + exact h.trans (hc.trans ht) + +omit [Fintype A] in +lemma act_single_comp (p : A → Bool) (g : Equiv.Perm (Fin n)) (y : Fin n → A) : + act p g (Pi.single (y ∘ g) (1 : ℂ)) = + signC (p ∘ y) g⁻¹ • Pi.single y (1 : ℂ) := by + funext x + change signC (p ∘ x) g⁻¹ * ((Pi.single (y ∘ g) (1 : ℂ) : (Fin n → A) → ℂ) (x ∘ g)) = _ + by_cases h : x=y + · subst x + simp + · have hg : x ∘ g ≠ y ∘ g := by + intro he + apply h + funext i + simpa only [Function.comp_apply, Equiv.apply_symm_apply] using congrFun he (g.symm i) + simp [h, hg] + +lemma intertwiner_matrix_invariant (p : A → Bool) + (f : Representation.IntertwiningMap (tensorRep p n) (tensorRep p n)) : + Invariant p (LinearMap.toMatrix' f.toLinearMap) := by + intro g x y + have h := congrFun (Representation.IntertwiningMap.isIntertwining _ _ f g (Pi.single (y ∘ g) (1 : ℂ))) x + change f (act p g (Pi.single (y ∘ g) 1)) x = signC (p ∘ x) g⁻¹ * f (Pi.single (y ∘ g) 1) (x ∘ g) at h + rw [act_single_comp, map_smul] at h + simp only [Pi.smul_apply, smul_eq_mul] at h + simp only [LinearMap.toMatrix'_apply, Representation.IntertwiningMap.toLinearMap_apply] + have hs := signC_sq (p ∘ x) g⁻¹ + calc + _ = (signC (p ∘ x) g⁻¹ * signC (p ∘ x) g⁻¹) * f (Pi.single (y ∘ g) 1) (x ∘ g) := by rw [hs,one_mul] + _ = _ := by rw [mul_assoc, ← h]; ring + +def commutantToInvariant (p : A → Bool) (n : ℕ) : + Representation.IntertwiningMap (tensorRep p n) (tensorRep p n) →ₗ[ℂ] + invariantSubspace p n where + toFun f := ⟨LinearMap.toMatrix' f.toLinearMap, intertwiner_matrix_invariant p f⟩ + map_add' f g := by apply Subtype.ext; simp + map_smul' c f := by apply Subtype.ext; simp + +lemma commutantToInvariant_injective (p : A → Bool) (n : ℕ) : + Function.Injective (commutantToInvariant p n) := by + intro f g h + apply Representation.IntertwiningMap.toLinearMap_injective + apply LinearMap.toMatrix'.injective + exact congrArg Subtype.val h + +theorem tensor_commutant_finrank (p : A → Bool) (n : ℕ) : + Module.finrank ℂ (Representation.IntertwiningMap (tensorRep p n) (tensorRep p n)) ≤ + (n+1)^((Fintype.card A)^2) := + (LinearMap.finrank_le_finrank_of_injective (f := commutantToInvariant p n) + (commutantToInvariant_injective p n)).trans (invariantSubspace_finrank p n) + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical ComplexOrder +open Equiv Equiv.Perm Matrix + +namespace BinaryCoordinateSweeps.Signed +variable {A : Type*} [Fintype A] {n : ℕ} + +abbrev TensorSpace (A : Type*) (n : ℕ) := EuclideanSpace ℂ (Fin n → A) + +def coeffEquiv (A : Type*) [Fintype A] (n : ℕ) : + TensorSpace A n ≃ₗ[ℂ] ((Fin n → A) → ℂ) := WithLp.linearEquiv 2 ℂ _ + +def wordReorder (g : Equiv.Perm (Fin n)) : (Fin n → A) ≃ (Fin n → A) where + toFun x := x ∘ g + invFun x := x ∘ g.symm + left_inv x := by ext i; simp + right_inv x := by ext i; simp + +def actHilbert (p : A → Bool) (g : Equiv.Perm (Fin n)) : + TensorSpace A n →ₗ[ℂ] TensorSpace A n := (coeffEquiv A n).symm.conj (act p g) + +lemma actHilbert_apply (p : A → Bool) (g : Equiv.Perm (Fin n)) (v : TensorSpace A n) (x) : + actHilbert p g v x = signC (p ∘ x) g⁻¹ * v (x ∘ g) := rfl + +lemma actHilbert_inner (p : A → Bool) (g : Equiv.Perm (Fin n)) (v w : TensorSpace A n) : + inner ℂ (actHilbert p g v) (actHilbert p g w) = inner ℂ v w := by + simp only [PiLp.inner_apply, actHilbert_apply, RCLike.inner_apply, map_mul, + starRingEnd_apply, signC_star] + have he (x : Fin n → A) : signC (p ∘ x) g⁻¹ * w (x ∘ g) * + (signC (p ∘ x) g⁻¹ * star (v (x ∘ g))) = w (x ∘ g) * star (v (x ∘ g)) := by + calc + _ = (signC (p ∘ x) g⁻¹ * signC (p ∘ x) g⁻¹) * + (w (x ∘ g) * star (v (x ∘ g))) := by ring + _ = _ := by rw [signC_sq, one_mul] + simp_rw [he] + exact Equiv.sum_comp (wordReorder g) (fun x => w x * star (v x)) + +def actionIsometry (p : A → Bool) (g : Equiv.Perm (Fin n)) : + TensorSpace A n →ₗᵢ[ℂ] TensorSpace A n := (actHilbert p g).isometryOfInner (actHilbert_inner p g) + +def hilbertSubspace (S : Submodule ℂ ((Fin n → A) → ℂ)) : Submodule ℂ (TensorSpace A n) := + S.map (coeffEquiv A n).symm.toLinearMap + +lemma hilbertSubspace_finrank (S : Submodule ℂ ((Fin n → A) → ℂ)) : + Module.finrank ℂ (hilbertSubspace S) = Module.finrank ℂ S := + (Submodule.equivMapOfInjective (coeffEquiv A n).symm.toLinearMap + (coeffEquiv A n).symm.injective S).finrank_eq.symm + +lemma hilbertSubspace_map (p : A → Bool) (S : Submodule ℂ ((Fin n → A) → ℂ)) + (hS : ∀ g, S.map (act p g) = S) (g : Equiv.Perm (Fin n)) : + (hilbertSubspace S).map (actHilbert p g) = hilbertSubspace S := by + apply le_antisymm + · rintro _ ⟨u,⟨v,hv,rfl⟩,rfl⟩ + refine ⟨act p g v, ?_, ?_⟩ + · rw [← hS g] + exact ⟨v,hv,rfl⟩ + · simp only [actHilbert, LinearEquiv.conj_apply, LinearMap.comp_apply, + LinearEquiv.coe_coe, LinearEquiv.symm_symm, LinearEquiv.apply_symm_apply] + · rintro _ ⟨v,hv,rfl⟩ + have hm : v ∈ S.map (act p g) := (hS g).symm ▸ hv + obtain ⟨w,hw,rfl⟩ := hm + refine ⟨(coeffEquiv A n).symm w, ⟨w,hw,rfl⟩, ?_⟩ + simp only [actHilbert, LinearEquiv.conj_apply, LinearMap.comp_apply, + LinearEquiv.coe_coe, LinearEquiv.symm_symm, LinearEquiv.apply_symm_apply] + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedConjugation.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedConjugation.lean new file mode 100644 index 0000000000000000000000000000000000000000..46095bd5b218c300a124eb44db9b0b90a5857a52 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedConjugation.lean @@ -0,0 +1,117 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedBlock + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +lemma actionMatrix_mul (p : A → Bool) (g h : Equiv.Perm (Fin n)) : + actionMatrix p (g*h)=actionMatrix p g*actionMatrix p h := by + change LinearMap.toMatrix' ((tensorRep p n) (g*h))=_ + rw [map_mul] + exact LinearMap.toMatrix'_comp _ _ + +lemma actionMatrix_one (p : A → Bool) : actionMatrix (n:=n) p 1=1 := by + change LinearMap.toMatrix' ((tensorRep p n) 1)=_ + rw [map_one] + exact LinearMap.toMatrix'_id + +lemma actionMatrix_inv (p : A → Bool) (g : Equiv.Perm (Fin n)) : + actionMatrix p g⁻¹=(actionMatrix p g).conjTranspose := by + calc + _ = actionMatrix p g⁻¹*(actionMatrix p g*(actionMatrix p g).conjTranspose) := by + rw [actionMatrix_unitary,mul_one] + _ = _ := by rw [← mul_assoc,← actionMatrix_mul,inv_mul_cancel,actionMatrix_one,one_mul] + +def signedConj (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) := + actionMatrix p g*M*(actionMatrix p g).conjTranspose + +lemma signedConj_mul (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M L : Matrix (Fin n → A) (Fin n → A) ℂ) : + signedConj p g (M*L)=signedConj p g M*signedConj p g L := by + unfold signedConj + simp only [mul_assoc,← mul_assoc (actionMatrix p g).conjTranspose (actionMatrix p g), + actionMatrix_star_mul,one_mul] + +lemma signedConj_psd (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) (hM : M.PosSemidef) : + (signedConj p g M).PosSemidef := hM.mul_mul_conjTranspose_same _ + +lemma signedConj_fixed (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hc : M*actionMatrix p g=actionMatrix p g*M) : signedConj p g M=M := by + unfold signedConj + rw [← hc,mul_assoc,actionMatrix_unitary,mul_one] + +lemma signedConj_commutes (p : A → Bool) (g : Equiv.Perm (Fin n)) + (M Q : Matrix (Fin n → A) (Fin n → A) ℂ) + (hc : M*actionMatrix p g=actionMatrix p g*M) (hq : M*Q=Q*M) : + M*signedConj p g Q=signedConj p g Q*M := by + rw [← signedConj_fixed p g M hc,← signedConj_mul,← signedConj_mul,hq] + +lemma signedConj_sub_smul_sum {U : Type*} [Fintype U] (p : A → Bool) (g : Equiv.Perm (Fin n)) + (c : ℂ) (M : U → Matrix (Fin n → A) (Fin n → A) ℂ) + (Q : Matrix (Fin n → A) (Fin n → A) ℂ) : + signedConj p g (c • ∑u, M u-Q)=c • ∑u, signedConj p g (M u)-signedConj p g Q := by + simp [signedConj,mul_sub,sub_mul,Matrix.mul_sum,Matrix.sum_mul] + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical Kronecker +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {A B G : Type*} [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + +def matrixSlice (M : Matrix (A×B) (A×B) ℂ) (b c : B) : Matrix A A ℂ := + fun a a' => M (a,b) (a',c) + +omit [DecidableEq A] in +lemma matrixSlice_mul_left (M : Matrix (A×B) (A×B) ℂ) (T : Matrix A A ℂ) (b c : B) : + matrixSlice ((T ⊗ₖ (1 : Matrix B B ℂ))*M) b c = T*matrixSlice M b c := by + ext a a' + simp [matrixSlice,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.one_apply,mul_ite,ite_mul] + +omit [DecidableEq A] in +lemma matrixSlice_mul_right (M : Matrix (A×B) (A×B) ℂ) (T : Matrix A A ℂ) (b c : B) : + matrixSlice (M*(T ⊗ₖ (1 : Matrix B B ℂ))) b c = matrixSlice M b c*T := by + ext a a' + simp [matrixSlice,Matrix.mul_apply,Fintype.sum_prod_type, + Matrix.one_apply,mul_ite] + +omit [DecidableEq A] in +theorem kronecker_centrality (T : G → Matrix A A ℂ) (P : Matrix A A ℂ) + (hP : ∀ X : Matrix A A ℂ, (∀ g, X*T g=T g*X) → X*P=P*X) + (M : Matrix (A×B) (A×B) ℂ) + (hM : ∀ g, M*(T g ⊗ₖ (1 : Matrix B B ℂ))=(T g ⊗ₖ (1 : Matrix B B ℂ))*M) : + M*(P ⊗ₖ (1 : Matrix B B ℂ))=(P ⊗ₖ (1 : Matrix B B ℂ))*M := by + ext ⟨a,b⟩ ⟨a',c⟩ + have hc : ∀ g, matrixSlice M b c*T g=T g*matrixSlice M b c := by + intro g + have hh := congrArg (fun X => matrixSlice X b c) (hM g) + simpa only [matrixSlice_mul_left,matrixSlice_mul_right] using hh + have hh := hP (matrixSlice M b c) hc + have he : matrixSlice (M*(P ⊗ₖ (1 : Matrix B B ℂ))) b c = + matrixSlice ((P ⊗ₖ (1 : Matrix B B ℂ))*M) b c := by + simpa only [matrixSlice_mul_left,matrixSlice_mul_right] using hh + exact congrFun (congrFun he a) a' + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedPinching.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedPinching.lean new file mode 100644 index 0000000000000000000000000000000000000000..03fa0782d3f715dfee419322df48a2da72edb762 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedPinching.lean @@ -0,0 +1,85 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.EvenPostselection +import OAI.Probability.BinarySweep.MatrixBounds.SparsePinching + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder +open Equiv Equiv.Perm Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +lemma pinch_trace {I J : Type*} [Fintype I] [DecidableEq J] (f : I → J) (M : Matrix I I ℂ) : + (pinch f M).trace = M.trace := by + simp only [Matrix.trace, Matrix.diag, pinch, ite_true] + +omit [Fintype A] [DecidableEq A] in +lemma comp_parity_eq_iff (p : A → Bool) (x y : Fin n → A) (g : Equiv.Perm (Fin n)) : + p ∘ (x ∘ g) = p ∘ (y ∘ g) ↔ p ∘ x = p ∘ y := by + constructor + · intro h + funext i + simpa only [Function.comp_apply, Equiv.apply_symm_apply] using congrFun h (g.symm i) + · intro h + exact congrArg (fun f => f ∘ g) h + +omit [Fintype A] [DecidableEq A] in +lemma pinch_block (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (x y : Fin n → A) (h : p ∘ x ≠ p ∘ y) : + pinch (fun w => p ∘ w) M x y = 0 := ite_eq_right h + +omit [Fintype A] [DecidableEq A] in +lemma pinch_invariant (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hM : Invariant p M) (g : Equiv.Perm (Fin n)) (x y : Fin n → A) : + pinch (fun w => p ∘ w) M (x ∘ g) (y ∘ g) = pinch (fun w => p ∘ w) M x y := by + simp only [pinch, comp_parity_eq_iff] + split_ifs with h + · exact invariant_same_parity p M hM g x y h + · rfl + +omit [DecidableEq A] in +lemma signed_sparse_pinching (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hM : M.PosSemidef) (hInv : Invariant p M) : + (((n+1 : ℕ)^((Fintype.card A)^2) : ℂ) • pinch (fun w => p ∘ w) M - M).PosSemidef := by + let R : (Fin n → Bool) → (Fin n → Bool) → Prop := + fun a b => hamming a b ≤ (Fintype.card A)^2 + have hR : ∀ ⦃left right⦄, R left right → R right left := by + intro a b h + change hamming b a ≤ (Fintype.card A)^2 + rw [hamming_symm b a] + exact h + have hD : ∀ a : Fin n → Bool, (Finset.univ.filter (R a)).card ≤ + (n+1)^((Fintype.card A)^2) := by + intro a + simpa only [Fintype.card_fin] using hamming_degree a ((Fintype.card A)^2) + have hz : ∀ x y : Fin n → A, ¬R (p ∘ x) (p ∘ y) → M x y = 0 := by + intro x y h + by_contra hn + exact h (invariant_mismatch_card p M hInv x y hn) + simpa only [Nat.cast_pow] using + sparse_pinching (fun w => p ∘ w) R hR ((n+1)^((Fintype.card A)^2)) hD hM hz + +theorem signed_psd_postselection (n : ℕ) (hn : 0 < n) (p : A → Bool) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) (hM : M.PosSemidef) (hInv : Invariant p M) : + ((((n+1 : ℕ)^((Fintype.card A)^2) : ℂ) * M.trace) • + (∑ c : WordType (MatchedPair p) n, ∑ t : MatchedPair p → ZMod (n+1), + matrixTensorPower n (reducedPhaseDensity n (matchedEmbedding p) c t)) - M).PosSemidef := by + let Q := pinch (fun w => p ∘ w) M + have hQ := pinch_posSemidef (fun w => p ∘ w) hM + have hd := even_block_postselection n hn p Q hQ (pinch_block p M) (pinch_invariant p M hInv) + rw [pinch_trace] at hd + have hc : (0 : ℂ) ≤ ((n+1 : ℕ)^((Fintype.card A)^2) : ℂ) := by + exact_mod_cast Nat.zero_le ((n+1)^((Fintype.card A)^2)) + have hh := (hd.smul hc).add (signed_sparse_pinching p M hM hInv) + simp only [smul_sub, smul_smul] at hh + convert hh using 1; dsimp only [Q]; abel + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedPlacement.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedPlacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d9ca7f4d1e64f10c3dafabf762dcf2bcb275a2f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedPlacement.lean @@ -0,0 +1,214 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.ConditionalSpecht +import OAI.Probability.BinarySweep.FiniteLaws.RemainingSign +import OAI.Probability.BinarySweep.SparseBounds.SparseSignGeometry + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps + +section +attribute [local instance] Classical.propDecidable +variable {b h h' k : ℕ} {bits : Fin b → ℕ} {H : PathFamily bits h} {H' : PathFamily bits h'} + +lemma PathExtension.signed_restrict_zero (E : PathExtension H H') (z : ℝ) + (hs : (∑g : GridChoices bits, if pathEvent H' g then + gridWeight bits z g*realSign (gridSweep bits g) else 0)=0) : + (∑g : ConditionalChoices H, if pathEvent H' g.val then + conditionalChoiceWeight H z g*realSign (remainingPerm H g.val g.property) else 0)=0 := by + obtain ⟨g₀,hg₀⟩ := pathEvent_nonempty H + let a := realSign (remainingPerm H g₀ hg₀)/realSign (gridSweep bits g₀) + have hs' : (∑g : ConditionalChoices H', gridWeight bits z g.val*realSign (gridSweep bits g.val))=0 := by + have he := sum_dite_zero (pathEvent H') + (fun g _ => gridWeight bits z g*realSign (gridSweep bits g)) + rw [←hs] + refine Eq.trans ?_ he.symm + apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + intro g _; rfl + calc + _ = (a/conditionalNormalizer H z)* + (∑g : ConditionalChoices H, if pathEvent H' g.val then + gridWeight bits z g.val*realSign (gridSweep bits g.val) else 0) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro g _ + by_cases hg : pathEvent H' g.val + · rw [ite_eq_left hg,ite_eq_left hg,remaining_realSign_factor H g ⟨g₀,hg₀⟩] + dsimp [a,conditionalChoiceWeight] + ring + · simp only [ite_eq_right hg,mul_zero] + _ = (a/conditionalNormalizer H z)* + (∑g : ConditionalChoices H', gridWeight bits z g.val*realSign (gridSweep bits g.val)) := by + congr 1 + exact E.sum_restrict (fun g => gridWeight bits z g.val*realSign (gridSweep bits g.val)) + _ = 0 := by rw [hs',mul_zero] + +variable (H) +def signedPlacementEntry (z : ℝ) (x : Placement H k 0) (y : Placement H k (Fin.last b)) : ℝ := + ∑g : ConditionalChoices H, if placementBijection H k g x=y then + conditionalChoiceWeight H z g*realSign (remainingPerm H g.val g.property) else 0 + +lemma signedPlacementEntry_zero (z : ℝ) (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (hs : ∀g₀ : ConditionalChoices H, + (∑g : GridChoices bits, if pathEvent (augmentByChoice H x g₀) g then + gridWeight bits z g*realSign (gridSweep bits g) else 0)=0) : + signedPlacementEntry H z x y=0 := by + by_cases he : ∃g₀ : ConditionalChoices H, placementBijection H k g₀ x=y + · obtain ⟨g₀,rfl⟩ := he + have hz := (augmentByChoice_extension H x g₀).signed_restrict_zero z (hs g₀) + refine Eq.trans ?_ hz + unfold signedPlacementEntry + apply Finset.sum_congr rfl + intro g _ + simp only [placementEvent_iff_augmentation] + · unfold signedPlacementEntry + apply Finset.sum_eq_zero + intro g _ + exact ite_eq_right (fun hg => he ⟨g,hg⟩) + +theorem signedPlacementEntry_zero_many (z : ℝ) (j : Fin b) (hj : 0 + signed_path_weight_zero_sparse (augmentByChoice H x g₀) z j hj hh) + +theorem signedPlacementEntry_zero_few (j : Fin b) + (hh : h+k+Fintype.card (GridOutside bits j) + signed_path_weight_zero_few (augmentByChoice H x g₀) j hh) + +end + +open Young Irrep + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma signed_partialKernel_conditional (z : ℝ) (A : Finset (Fin k)) + (x y : Placement H k 0) : + (∑a : Equiv.Perm (FreeSlot H 0), (conditionalGroupLaw H z a*realSign a:ℂ)*partialKernel A a y x)= + (signedPlacementEntry H z (restrictPlacement H x A) + (restrictPlacement H (placementIdentification H k y) A):ℂ) := by + have he := conditionalGroupLaw_expectation H z (fun a => (realSign a:ℂ)*partialKernel A a y x) + simp only [Complex.real_smul] at he + simp only [mul_assoc] + rw [he] + unfold signedPlacementEntry + rw [Complex.ofReal_sum] + apply Finset.sum_congr + · ext g; simp only [Finset.mem_univ] + intro g _ + simp only [partialKernel, partialKernel_event H g A x y, restrictPlacement_event] + split_ifs <;> simp + +lemma signed_centeredMatrix_zero (z : ℝ) + (hh : ∀ l ≤ k, ∀x : Placement H l 0, ∀y : Placement H l (Fin.last b), + signedPlacementEntry H z x y=0) : + centeredMatrix (I:=Fin k) (gridSize bits) + (fun a => (conditionalGroupLaw H z a*realSign a:ℂ))=0 := by + ext y x + simp only [centeredMatrix,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul,Matrix.zero_apply] + apply Finset.sum_eq_zero + intro A _ + rw [signed_partialKernel_conditional H z A x y] + have hA : Fintype.card A ≤ k := by simpa using Finset.card_le_univ A + rw [hh _ hA,Complex.ofReal_zero,mul_zero] + +theorem conditional_signed_specht_one_le_zero (μ : YoungDiagram) + (e : Cell μ ≃ FreeSlot H 0) (a : Tail μ ≃ Fin k) (z : ℝ) + (hh : ∀ l ≤ k, ∀x : Placement H l 0, ∀y : Placement H l (Fin.last b), + signedPlacementEntry H z x y=0) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g*realSign g:ℂ))) ≤ 0 := by + rw [groupAverage_comp_slots] + have hs : (gridSize bits:ℝ)≠0 := by exact_mod_cast (gridSize_pos bits).ne' + have he := specht_moment_one_le_centered_matrix μ (gridSize bits) hs + (fun g => (conditionalGroupLaw H z (e.permCongr g)*realSign (e.permCongr g):ℂ)) + have hr := centeredMatrix_hs_reindex a e (gridSize bits) + (fun g => (conditionalGroupLaw H z (e.permCongr g)*realSign (e.permCongr g):ℂ)) + simp only [Equiv.apply_symm_apply] at hr + rw [←hr,signed_centeredMatrix_zero H z hh] at he + simpa using he + +theorem conditional_signed_specht_many (μ : YoungDiagram) + (e : Cell μ ≃ FreeSlot H 0) (a : Tail μ ≃ Fin k) (z : ℝ) + (j : Fin b) (hj : 0 < bits j) (hh : h+k < Fintype.card (GridOutside bits j)) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g*realSign g:ℂ))) ≤ 0 := + conditional_signed_specht_one_le_zero H μ e a z (fun l hl x y => + signedPlacementEntry_zero_many H z j hj (by omega) x y) + +theorem conditional_signed_specht_few (μ : YoungDiagram) + (e : Cell μ ≃ FreeSlot H 0) (a : Tail μ ≃ Fin k) + (j : Fin b) (hh : h+k+Fintype.card (GridOutside bits j) < gridSize bits) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H 0 g*realSign g:ℂ))) ≤ 0 := + conditional_signed_specht_one_le_zero H μ e a 0 (fun l hl x y => + signedPlacementEntry_zero_few H j (by omega) x y) + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter Topology + +namespace BinaryCoordinateSweeps +open Young Irrep + +variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +def signedCenteredHS (k : ℕ) (z : ℝ) : ℝ := ∑x : Placement H k 0, ∑y : Placement H k 0, + ‖centeredMatrix (gridSize bits) (fun a => (conditionalGroupLaw H z a*realSign a:ℂ)) y x‖^2 + +lemma continuousAt_signedCenteredHS (k : ℕ) : ContinuousAt (signedCenteredHS H k) 0 := by + unfold signedCenteredHS + apply tendsto_finsetSum + intro x _ + apply tendsto_finsetSum + intro y _ + apply ContinuousAt.pow + apply ContinuousAt.norm + simp only [centeredMatrix,Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul] + apply tendsto_finsetSum + intro A _ + apply ContinuousAt.mul continuousAt_const + apply tendsto_finsetSum + intro g _ + have hc := Complex.continuous_ofReal.continuousAt.comp (continuousAt_conditionalGroupLaw H g) + exact (hc.mul continuousAt_const).mul continuousAt_const + +lemma signedCenteredHS_zero (k : ℕ) (z : ℝ) + (hh : ∀ l ≤ k, ∀x : Placement H l 0, ∀y : Placement H l (Fin.last b), + signedPlacementEntry H z x y=0) : signedCenteredHS H k z=0 := by + unfold signedCenteredHS + rw [signed_centeredMatrix_zero H z hh] + simp + +lemma conditional_signed_specht_hs {k : ℕ} (μ : YoungDiagram) + (e : Cell μ ≃ FreeSlot H 0) (a : Tail μ ≃ Fin k) (z : ℝ) : + evenMoment 1 (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun g => (conditionalGroupLaw H z g*realSign g:ℂ))) ≤ signedCenteredHS H k z := by + rw [groupAverage_comp_slots] + have hs : (gridSize bits:ℝ)≠0 := by exact_mod_cast (gridSize_pos bits).ne' + have he := specht_moment_one_le_centered_matrix μ (gridSize bits) hs + (fun g => (conditionalGroupLaw H z (e.permCongr g)*realSign (e.permCongr g):ℂ)) + have hr := centeredMatrix_hs_reindex a e (gridSize bits) + (fun g => (conditionalGroupLaw H z (e.permCongr g)*realSign (e.permCongr g):ℂ)) + simp only [Equiv.apply_symm_apply] at hr + rwa [←hr] at he + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedTypeCentrality.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedTypeCentrality.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7c74c6a8b7360932d3cd41dd80d222f4719929d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedTypeCentrality.lean @@ -0,0 +1,59 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedBlock +import OAI.Probability.BinarySweep.TensorBounds.SignedWhitening +import OAI.Probability.BinarySweep.Representations.IsotypicCentrality + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density Irrep Representation + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +lemma actionMatrix_linear (p : A → Bool) (g : Equiv.Perm (Fin n)) : + (actionMatrix p g).toEuclideanLin=hilbertTensorRep p n g := by + ext v x + change ((LinearMap.toMatrix' (act p g)).mulVec (coeffEquiv A n v)) x = _ + rw [LinearMap.toMatrix'_mulVec] + rfl + +lemma invariant_matrix_commutes (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hM : Invariant p M) (g : Equiv.Perm (Fin n)) : + M*actionMatrix p g=actionMatrix p g*M := by + apply Matrix.toEuclideanLin.injective + simp only [Matrix.toLpLin_mul_same,actionMatrix_linear] + apply LinearMap.ext + intro v + apply (coeffEquiv A n).injective + exact invariant_mulVec_commutes p M hM g (coeffEquiv A n v) + +omit [FiniteDimensional ℂ V] in +lemma typeProjection_commutes_action (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) (g : Equiv.Perm (Fin n)) : + isotypicProjection p ρ*actionMatrix p g=actionMatrix p g*isotypicProjection p ρ := + invariant_matrix_commutes p _ (isotypicProjection_invariant p ρ) g + +omit [FiniteDimensional ℂ V] in +lemma typeProjection_central (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) + (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hc : ∀g, M*actionMatrix p g=actionMatrix p g*M) : + M*isotypicProjection p ρ=isotypicProjection p ρ*M := by + have hh (g : Equiv.Perm (Fin n)) (v : TensorSpace A n) : + M.toEuclideanLin (hilbertTensorRep p n g v)=hilbertTensorRep p n g (M.toEuclideanLin v) := by + have h := congrArg (fun Q => Q.toEuclideanLin v) (hc g) + simpa only [Matrix.toLpLin_mul_same,LinearMap.comp_apply,actionMatrix_linear] using h + have h := isotypicProjection_central ρ (hilbertTensorRep p n) + (hilbertTensorRep_unitary p) M hh + simpa only [hilbert_isotypic_eq,isotypicProjection] using h + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/SignedWhitening.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedWhitening.lean new file mode 100644 index 0000000000000000000000000000000000000000..e93a6bc15c34eb21b0093fe9548a1ca80fc74b02 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/SignedWhitening.lean @@ -0,0 +1,73 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.MatrixIsotypicWhitening +import OAI.Probability.BinarySweep.Representations.IsotypicDensity + +namespace OAI + +noncomputable section +open scoped BigOperators Classical ComplexOrder MatrixOrder Matrix.Norms.L2Operator +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Irrep Density Representation + +variable {A V : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + [NormedAddCommGroup V] [InnerProductSpace ℂ V] [FiniteDimensional ℂ V] + +def hilbertTensorRep (p : A → Bool) (n : ℕ) : + Representation ℂ (Equiv.Perm (Fin n)) (TensorSpace A n) := + conjugateRep (tensorRep p n) (coeffEquiv A n).symm + +omit [DecidableEq A] in +lemma hilbertTensorRep_apply (p : A → Bool) (g : Equiv.Perm (Fin n)) (v : TensorSpace A n) : + hilbertTensorRep p n g v = actHilbert p g v := rfl + +omit [DecidableEq A] in +lemma hilbertTensorRep_unitary (p : A → Bool) (g : Equiv.Perm (Fin n)) (v : TensorSpace A n) : + ‖hilbertTensorRep p n g v‖ = ‖v‖ := (actionIsometry p g).norm_map v + +omit [FiniteDimensional ℂ V] [DecidableEq A] in +lemma hilbert_isotypic_eq (p : A → Bool) (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) : + isotypicSpan ρ (hilbertTensorRep p n) = hilbertSubspace (isotypicSpan ρ (tensorRep p n)) := by + exact (map_isotypic_equiv ρ (tensorRep p n) (hilbertTensorRep p n) + (conjugateEquiv (tensorRep p n) (coeffEquiv A n).symm)).symm + +lemma even_tensor_hilbert_commutes (p : A → Bool) (M : Matrix A A ℂ) + (hM : ∀ a b, p a ≠ p b → M a b = 0) (g : Equiv.Perm (Fin n)) (v : TensorSpace A n) : + (matrixTensorPower n M).toEuclideanLin (hilbertTensorRep p n g v) = + hilbertTensorRep p n g ((matrixTensorPower n M).toEuclideanLin v) := by + apply (coeffEquiv A n).injective + exact invariant_mulVec_commutes p (matrixTensorPower n M) (even_tensor_invariant p M hM) g + (coeffEquiv A n v) + +omit [FiniteDimensional ℂ V] in +theorem signed_tensor_whitening (p : A → Bool) + (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] + (M B C : Matrix A A ℂ) (hB : B.PosSemidef) (hC : C.PosSemidef) + (hBB : B*B=M) (hBC : B*C=1) (ht : M.trace=1) + (heM : ∀ a b, p a ≠ p b → M a b = 0) + (heC : ∀ a b, p a ≠ p b → C a b = 0) : + ((matrixTensorPower n C).conjTranspose * matrixTensorPower n C - + (Module.finrank ℂ V : ℂ) • isotypicProjection p ρ).PosSemidef := by + have hpow (N : Matrix A A ℂ) : matrixTensorPower n N = tensorMatrices (fun _ : Fin n => N) := rfl + have hBA : matrixTensorPower n B * matrixTensorPower n C = 1 := by + rw [hpow,hpow,tensorMatrices_mul] + simpa only [hBC] using (tensorMatrices_one (I:=Fin n) (A:=A)) + have hBT : (matrixTensorPower n B).conjTranspose * matrixTensorPower n B = + matrixTensorPower n M := by + rw [hpow,hpow,tensorMatrices_star,tensorMatrices_mul] + simp only [hB.isHermitian.eq,hBB] + have hCt : (matrixTensorPower n C).PosSemidef := by + rw [hpow]; exact tensorMatrices_psd _ (fun _ => hC) + have h := matrix_whitening_positive ρ (hilbertTensorRep p n) + (matrixTensorPower n B) (matrixTensorPower n C) hCt.isHermitian + (even_tensor_hilbert_commutes p C heC) hBA (by + rw [hBT]; exact even_tensor_hilbert_commutes p M heM) + (hilbertTensorRep_unitary p) (by rw [hBT,hpow,tensorMatrices_trace]; simp [ht]) + simpa only [hilbert_isotypic_eq,isotypicProjection] using h + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/TensorPhases.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/TensorPhases.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2e24bc5093b328402c44006f7c75eb85fe94130 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/TensorPhases.lean @@ -0,0 +1,180 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.TypeMass + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Density +variable {A : Type*} [Fintype A] [DecidableEq A] + +omit [DecidableEq A] in +lemma wordCounts_le (n : ℕ) (w : Fin n → A) (a : A) : wordCounts w a ≤ n := by + have h := Finset.single_le_sum (f := fun a => wordCounts w a) + (fun _ _ => Nat.zero_le _) (Finset.mem_univ a) + simpa only [wordCounts_sum, Fintype.card_fin] using h + +lemma phase_star (n : ℕ) (j : ZMod (n+1)) : + star (ZMod.stdAddChar j) = ZMod.stdAddChar (-j) := by + change (starRingEnd ℂ) (ZMod.stdAddChar j) = _ + rw [AddChar.starComp_apply (by rw [ringChar.eq (ZMod (n+1)) (n+1)]; omega : 0 < ringChar (ZMod (n+1)))] + rfl + +omit [Fintype A] in +lemma phase_sum_prod (n : ℕ) (f : A → ZMod (n+1)) (s : Finset A) : + ZMod.stdAddChar (∑ a ∈ s, f a) = ∏ a ∈ s, ZMod.stdAddChar (f a) := by + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => simp only [Finset.sum_insert ha, Finset.prod_insert ha, + AddChar.map_add_eq_mul, ih] + +lemma phase_sum (n : ℕ) (b : A → ZMod (n+1)) : + (∑ θ : A → ZMod (n+1), ZMod.stdAddChar (∑ a, θ a * b a)) = + if b = 0 then ((n+1 : ℕ) : ℂ) ^ Fintype.card A else 0 := by + classical + simp_rw [phase_sum_prod] + rw [← Fintype.prod_sum (fun a (x : ZMod (n+1)) => ZMod.stdAddChar (x * b a))] + simp_rw [AddChar.sum_mulShift _ (ZMod.isPrimitive_stdAddChar _), ZMod.card] + by_cases hb : b = 0 + · simp [hb] + · rw [ite_eq_right hb] + obtain ⟨a, ha⟩ : ∃ a, b a ≠ 0 := by simpa only [funext_iff, not_forall, Pi.zero_apply] using hb + exact Finset.prod_eq_zero (Finset.mem_univ a) (by simp [ha]) + +def tensorPhase (n : ℕ) (θ : A → ZMod (n+1)) (w : Fin n → A) : ℂ := + ∏ i, ZMod.stdAddChar (θ (w i)) + +lemma tensorPhase_counts (n : ℕ) (θ : A → ZMod (n+1)) (w : Fin n → A) : + tensorPhase n θ w = ZMod.stdAddChar (∑ a, θ a * (wordCounts w a : ZMod (n+1))) := by + rw [tensorPhase, prod_wordCounts (fun a => ZMod.stdAddChar (θ a)) w] + simp_rw [phase_sum_prod, ← AddChar.map_nsmul_eq_pow, nsmul_eq_mul] + simp_rw [mul_comm] + +lemma phase_pair_sum (n : ℕ) (w v : Fin n → A) : + (∑ θ : A → ZMod (n+1), tensorPhase n θ w * star (tensorPhase n θ v)) = + if wordCounts w = wordCounts v then ((n+1 : ℕ) : ℂ)^Fintype.card A else 0 := by + simp_rw [tensorPhase_counts, phase_star, ← AddChar.map_add_eq_mul, ← sub_eq_add_neg, + ← Finset.sum_sub_distrib, ← mul_sub] + rw [phase_sum] + congr 1 + apply propext + constructor + · intro h + apply Finsupp.ext + intro a + have h' := congrFun h a + dsimp at h' + have hh := congrArg ZMod.val (sub_eq_zero.mp h') + simpa only [ZMod.val_natCast_of_lt (Nat.lt_succ_of_le (wordCounts_le n w a)), + ZMod.val_natCast_of_lt (Nat.lt_succ_of_le (wordCounts_le n v a))] using hh + · intro h + simp only [h, sub_self, Pi.zero_def] + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density + +variable {I T : Type*} [Fintype I] [DecidableEq I] [Fintype T] [DecidableEq T] + +def rankOne (v : I → ℂ) : Matrix I I ℂ := vecMulVec v (star v) + +omit [DecidableEq I] in +lemma rankOne_psd (v : I → ℂ) : (rankOne v).PosSemidef := by + let A : Matrix I Unit ℂ := fun i _ => v i + have hA : rankOne v = A * Aᴴ := by + ext i j + change v i * star (v j) = ∑ _ : Unit, v i * star (v j) + simp + rw [hA] + exact posSemidef_self_mul_conjTranspose A + +def typeVector (f : I → T) (t : T) : I → ℂ := fun i => if f i = t then 1 else 0 + +def typeOnes (f : I → T) (t : T) : Matrix I I ℂ := rankOne (typeVector f t) + +omit [Fintype I] [DecidableEq I] [Fintype T] in +lemma typeOnes_apply (f : I → T) (t : T) (i j : I) : + typeOnes f t i j = if f i = t ∧ f j = t then 1 else 0 := by + simp only [typeOnes, rankOne, vecMulVec, typeVector, Pi.star_apply] + by_cases hi : f i = t <;> by_cases hj : f j = t <;> simp [hi, hj] + +omit [DecidableEq I] [Fintype T] in +lemma typeOnes_psd (f : I → T) (t : T) : (typeOnes f t).PosSemidef := rankOne_psd _ + +omit [Fintype I] [DecidableEq I] in +lemma sum_typeOnes (f : I → T) (c : T → ℝ) (i j : I) : + (∑ t, (c t : ℂ) • typeOnes f t : Matrix I I ℂ) i j = if f i = f j then (c (f i) : ℂ) else 0 := by + simp only [Matrix.sum_apply, Matrix.smul_apply, smul_eq_mul, typeOnes_apply] + rw [Finset.sum_eq_single (f i)] + · by_cases h : f i = f j <;> simp [h, eq_comm] + · intro b hb hba + simp [Ne.symm hba] + · simp + +omit [DecidableEq I] in +lemma typeKernel_psd (f : I → T) (c : T → ℝ) (hc : ∀ t, 0 ≤ c t) : + Matrix.PosSemidef (fun i j => if f i = f j then (c (f i) : ℂ) else 0 : Matrix I I ℂ) := by + have hh : (fun i j => if f i = f j then (c (f i) : ℂ) else 0 : Matrix I I ℂ) = + ∑ t, (c t : ℂ) • typeOnes f t := by ext i j; exact (sum_typeOnes f c i j).symm + rw [hh] + exact Matrix.posSemidef_sum _ (fun t _ => (typeOnes_psd f t).smul (by exact_mod_cast hc t)) + +omit [DecidableEq I] in +lemma typeKernel_mono (f : I → T) (c d : T → ℝ) (h : ∀ t, c t ≤ d t) : + Matrix.PosSemidef ((fun i j => if f i = f j then (d (f i) : ℂ) else 0) - + (fun i j => if f i = f j then (c (f i) : ℂ) else 0) : Matrix I I ℂ) := by + have hkernel : + ((fun i j => if f i = f j then (d (f i) : ℂ) else 0) - + (fun i j => if f i = f j then (c (f i) : ℂ) else 0) : Matrix I I ℂ) = + (fun i j => if f i = f j then ((d (f i) - c (f i) : ℝ) : ℂ) else 0) := by + ext i j + by_cases hh : f i = f j <;> simp [hh] + rw [hkernel] + exact typeKernel_psd f (fun t => d t - c t) (fun t => sub_nonneg.mpr (h t)) + +variable {A : Type*} [Fintype A] [DecidableEq A] + +abbrev WordType (A : Type*) [Fintype A] [DecidableEq A] (n : ℕ) := + ↥(Finset.piAntidiag (Finset.univ : Finset A) n) + +def wordType (n : ℕ) (w : Fin n → A) : WordType A n := + ⟨fun a => wordCounts w a, Finset.mem_piAntidiag.mpr ⟨by simpa using wordCounts_sum w, by simp⟩⟩ + +lemma wordType_eq_iff (n : ℕ) (w v : Fin n → A) : + wordType n w = wordType n v ↔ wordCounts w = wordCounts v := by + simp only [wordType, Subtype.ext_iff, funext_iff, Finsupp.ext_iff] + +lemma wordType_total (n : ℕ) (c : WordType A n) : ∑ a, c.val a = n := + (Finset.mem_piAntidiag.mp c.property).1 + +lemma card_wordType (n : ℕ) (c : WordType A n) : + Fintype.card {w : Fin n → A // wordType n w = c} = Nat.multinomial Finset.univ c.val := by + have he : {w : Fin n → A // wordType n w = c} ≃ + {w : Fin n → A // ∀ a, wordCounts w a = c.val a} := + Equiv.subtypeEquivRight (fun w => by simp only [wordType, Subtype.ext_iff, funext_iff]) + rw [Fintype.card_congr he, card_words_counts_fun n c.val (wordType_total n c)] + +def symmetricProjector (n : ℕ) : Matrix (Fin n → A) (Fin n → A) ℂ := + fun w v => if wordType n w = wordType n v then + ((Nat.multinomial Finset.univ (wordType n w).val : ℝ)⁻¹ : ℂ) else 0 + +lemma symmetricProjector_psd (n : ℕ) : (symmetricProjector (A := A) n).PosSemidef := by + unfold symmetricProjector + simpa only [Complex.ofReal_inv] using typeKernel_psd (wordType (A := A) n) + (fun c => (Nat.multinomial Finset.univ c.val : ℝ)⁻¹) + (fun _ => inv_nonneg.mpr (Nat.cast_nonneg _)) + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/TensorProductMatrices.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/TensorProductMatrices.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4c0bd2efe77e9a95eefc889d0a138f2e9b4d91d --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/TensorProductMatrices.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.SignedCommutant + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder MatrixOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {I A B C : Type*} [Fintype I] [DecidableEq I] + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] [Fintype C] [DecidableEq C] + +def tensorMatrices (M : I → Matrix A B ℂ) : Matrix (I → A) (I → B) ℂ := + fun x y => ∏ i, M i (x i) (y i) + +omit [Fintype A] [DecidableEq A] [DecidableEq B] [Fintype C] [DecidableEq C] in +lemma tensorMatrices_mul (M : I → Matrix A B ℂ) (N : I → Matrix B C ℂ) : + tensorMatrices M * tensorMatrices N = tensorMatrices (fun i => M i * N i) := by + ext x z + simp only [Matrix.mul_apply,tensorMatrices,← Finset.prod_mul_distrib] + exact (Fintype.prod_sum (fun i b => M i (x i) b * N i b (z i))).symm + +omit [DecidableEq I] [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] in +lemma tensorMatrices_star (M : I → Matrix A B ℂ) : + (tensorMatrices M).conjTranspose = tensorMatrices (fun i => (M i).conjTranspose) := by + ext x y + simp [tensorMatrices] + +omit [DecidableEq I] [Fintype A] in +lemma tensorMatrices_one : tensorMatrices (fun _ : I => (1 : Matrix A A ℂ)) = 1 := by + ext x y + by_cases h : x = y + · subst y; simp [tensorMatrices] + · have ⟨i,hi⟩ := Function.ne_iff.mp h + simp only [tensorMatrices,Matrix.one_apply,ite_eq_right h] + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +omit [DecidableEq A] in +lemma tensorMatrices_trace (M : I → Matrix A A ℂ) : + (tensorMatrices M).trace = ∏ i, (M i).trace := by + simp only [Matrix.trace,tensorMatrices,diag] + exact (Fintype.prod_sum (fun i a => M i a a)).symm + +lemma tensorMatrices_psd (M : I → Matrix A A ℂ) (hM : ∀ i, (M i).PosSemidef) : + (tensorMatrices M).PosSemidef := by + have hex (i : I) : ∃ X : Matrix A A ℂ, M i = X.conjTranspose * X := by + exact CStarAlgebra.nonneg_iff_eq_star_mul_self.mp (hM i).nonneg + choose X hX using hex + have he : tensorMatrices M = (tensorMatrices X).conjTranspose * tensorMatrices X := by + rw [tensorMatrices_star,tensorMatrices_mul] + congr 1 + funext i + exact hX i + rw [he] + exact Matrix.posSemidef_conjTranspose_mul_self _ + +omit [DecidableEq I] [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] in +lemma tensorMatrices_smul (a : I → ℂ) (M : I → Matrix A B ℂ) : + tensorMatrices (fun i => a i • M i) = (∏ i, a i) • tensorMatrices M := by + ext x y + simp only [tensorMatrices,Matrix.smul_apply,smul_eq_mul,Finset.prod_mul_distrib] + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Signed +open Density + +variable {A : Type*} [Fintype A] [DecidableEq A] {n : ℕ} + +omit [Fintype A] [DecidableEq A] in +lemma even_tensor_invariant (p : A → Bool) (M : Matrix A A ℂ) + (hM : ∀ a b, p a ≠ p b → M a b = 0) : + Invariant p (matrixTensorPower n M) := by + intro g x y + have hr : matrixTensorPower n M (x ∘ g) (y ∘ g) = matrixTensorPower n M x y := by + exact Equiv.prod_comp g (fun i => M (x i) (y i)) + rw [hr] + by_cases h : p ∘ x = p ∘ y + · rw [h,signC_sq,one_mul] + · obtain ⟨i,hi⟩ := Function.ne_iff.mp h + have hz : matrixTensorPower n M x y = 0 := + Finset.prod_eq_zero (Finset.mem_univ i) (hM (x i) (y i) hi) + simp [hz] + +omit [DecidableEq A] in +lemma invariant_mulVec_commutes (p : A → Bool) (M : Matrix (Fin n → A) (Fin n → A) ℂ) + (hM : Invariant p M) (g : Equiv.Perm (Fin n)) (v : (Fin n → A) → ℂ) : + M.mulVec (act p g v) = act p g (M.mulVec v) := by + funext x + simp only [Matrix.mulVec,dotProduct,act_apply,Finset.mul_sum] + conv_rhs => rw [← (wordReorder (A:=A) g).sum_comp] + apply Finset.sum_congr rfl + intro y _ + have he := hM g x y + dsimp only [wordReorder,Equiv.coe_fn_mk] + rw [he] + linear_combination -(signC (p ∘ y) g⁻¹ * M x y * v (y ∘ g)) * signC_sq (p ∘ x) g⁻¹ + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/TensorReduction.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/TensorReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1995618c7172549fc44b3d99aad3e7d952e2494 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/TensorReduction.lean @@ -0,0 +1,207 @@ +import Mathlib +import OAI.Probability.BinarySweep.MatrixBounds.SymmetricDensity + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {K A B : Type*} [Fintype K] [DecidableEq K] [Fintype A] [DecidableEq A] + [Fintype B] [DecidableEq B] + +def reshape (e : K → A × B) (v : K → ℂ) : Matrix A B ℂ := + fun a b => ∑ k, if e k = (a,b) then v k else 0 + +def kraus (e : K → A × B) (b : B) : Matrix A K ℂ := + fun a k => if e k = (a,b) then 1 else 0 + +def densityChannel (e : K → A × B) (M : Matrix K K ℂ) : Matrix A A ℂ := + ∑ b, kraus e b * M * (kraus e b).conjTranspose + +omit [DecidableEq K] in +lemma densityChannel_psd (e : K → A × B) {M : Matrix K K ℂ} (hM : M.PosSemidef) : + (densityChannel e M).PosSemidef := + Matrix.posSemidef_sum _ (fun _ _ => hM.mul_mul_conjTranspose_same _) + +omit [DecidableEq K] [Fintype A] in +lemma densityChannel_sub (e : K → A × B) (M N : Matrix K K ℂ) : + densityChannel e (M-N) = densityChannel e M - densityChannel e N := by + simp only [densityChannel, Matrix.mul_sub, Matrix.sub_mul, Finset.sum_sub_distrib] + +omit [DecidableEq K] [Fintype A] in +lemma densityChannel_smul (e : K → A × B) (c : ℂ) (M : Matrix K K ℂ) : + densityChannel e (c • M) = c • densityChannel e M := by + simp only [densityChannel, Matrix.mul_smul, Matrix.smul_mul, Finset.smul_sum] + +omit [DecidableEq K] [Fintype A] in +lemma densityChannel_sum {T : Type*} [Fintype T] (e : K → A × B) (M : T → Matrix K K ℂ) : + densityChannel e (∑ t, M t) = ∑ t, densityChannel e (M t) := by + simp only [densityChannel, Matrix.mul_sum, Matrix.sum_mul] + exact Finset.sum_comm + +omit [DecidableEq K] [Fintype A] [Fintype B] in +lemma kraus_mulVec (e : K → A × B) (v : K → ℂ) (b : B) : + (kraus e b).mulVec v = fun a => reshape e v a b := by + ext a + simp only [Matrix.mulVec, dotProduct, kraus, reshape, ite_mul, one_mul, zero_mul] + +omit [DecidableEq K] in +lemma densityChannel_rankOne (e : K → A × B) (v : K → ℂ) : + densityChannel e (rankOne v) = reshape e v * (reshape e v).conjTranspose := by + simp only [densityChannel, rankOne_conjugate, kraus_mulVec] + ext a b + simp only [Matrix.sum_apply, rankOne, vecMulVec_apply, Pi.star_apply, + Matrix.mul_apply, Matrix.conjTranspose_apply] + +omit [Fintype A] [Fintype B] in +lemma reshape_injective_apply (e : K → A × B) (he : Function.Injective e) (v : K → ℂ) (k : K) : + reshape e v (e k).1 (e k).2 = v k := by + simp only [reshape, Prod.mk.eta, he.eq_iff, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + +omit [DecidableEq K] [Fintype A] [Fintype B] in +lemma reshape_outside (e : K → A × B) (v : K → ℂ) (a : A) (b : B) + (h : (a,b) ∉ Set.range e) : reshape e v a b = 0 := by + apply Finset.sum_eq_zero + intro k hk + exact ite_eq_right (fun hh => h ⟨k,hh⟩) + +def wordPair (n : ℕ) (e : K → A × B) : (Fin n → K) → (Fin n → A) × (Fin n → B) := + fun w => (fun i => (e (w i)).1, fun i => (e (w i)).2) + +omit [Fintype K] [DecidableEq K] [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] in +lemma wordPair_eq_iff (n : ℕ) (e : K → A × B) (w : Fin n → K) + (x : Fin n → A) (y : Fin n → B) : wordPair n e w = (x,y) ↔ ∀ i, e (w i) = (x i,y i) := by + simp only [wordPair, funext_iff, Prod.ext_iff] + exact ⟨fun h i => ⟨h.1 i,h.2 i⟩, fun h => ⟨fun i => (h i).1, fun i => (h i).2⟩⟩ + +omit [Fintype K] [DecidableEq K] [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] in +lemma wordPair_injective (n : ℕ) (e : K → A × B) (he : Function.Injective e) : + Function.Injective (wordPair n e) := by + intro w v h + funext i + apply he + exact Prod.ext (congrFun (congrArg Prod.fst h) i) (congrFun (congrArg Prod.snd h) i) + +omit [DecidableEq K] [Fintype A] [Fintype B] in +lemma reshape_tensor (n : ℕ) (e : K → A × B) (u : K → ℂ) + (x : Fin n → A) (y : Fin n → B) : + reshape (wordPair n e) (tensorProductVector n u) x y = ∏ i, reshape e u (x i) (y i) := by + simp only [reshape, tensorProductVector, wordPair_eq_iff] + rw [Fintype.prod_sum (fun i k => if e k = (x i,y i) then u k else 0)] + apply Finset.sum_congr rfl + intro w hw + by_cases h : ∀ i, e (w i) = (x i,y i) + · simp only [ite_eq_left h] + apply Finset.prod_congr rfl + intro i hi + rw [ite_eq_left (h i)] + · rw [ite_eq_right h] + obtain ⟨i,hi⟩ := not_forall.mp h + exact (Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi)).symm + +def matrixTensorPower (n : ℕ) (M : Matrix A A ℂ) : Matrix (Fin n → A) (Fin n → A) ℂ := + fun x y => ∏ i, M (x i) (y i) + +def matrixTensorRect (n : ℕ) (U : Matrix A B ℂ) : Matrix (Fin n → A) (Fin n → B) ℂ := + fun x y => ∏ i, U (x i) (y i) + +omit [Fintype A] [DecidableEq A] [DecidableEq B] in +lemma tensor_gram (n : ℕ) (U : Matrix A B ℂ) : + matrixTensorRect n U * (matrixTensorRect n U).conjTranspose = + matrixTensorPower n (U * U.conjTranspose) := by + ext x z + simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, matrixTensorPower, matrixTensorRect, star_prod, + ← Finset.prod_mul_distrib] + exact (Fintype.prod_sum (fun i b => U (x i) b * star (U (z i) b))).symm + +omit [DecidableEq K] in +lemma densityChannel_tensorRankOne (n : ℕ) (e : K → A × B) (u : K → ℂ) : + densityChannel (wordPair n e) (rankOne (tensorProductVector n u)) = + matrixTensorPower n (reshape e u * (reshape e u).conjTranspose) := by + rw [densityChannel_rankOne] + have he : reshape (wordPair n e) (tensorProductVector n u) = + matrixTensorRect n (reshape e u) := by + ext x y + exact reshape_tensor n e u x y + rw [he, tensor_gram] + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical ComplexOrder +open Matrix + +namespace BinaryCoordinateSweeps.Density +variable {K A B : Type*} [Fintype K] [DecidableEq K] [Fintype A] [DecidableEq A] + [Fintype B] [DecidableEq B] + +lemma reshape_trace (e : K → A × B) (he : Function.Injective e) (v : K → ℂ) : + (reshape e v * (reshape e v).conjTranspose).trace = (rankOne v).trace := by + simp only [Matrix.trace, Matrix.diag, Matrix.mul_apply, Matrix.conjTranspose_apply, + rankOne, Matrix.vecMulVec_apply, Pi.star_apply] + symm + calc + _ = ∑ x : A × B, reshape e v x.1 x.2 * star (reshape e v x.1 x.2) := + Fintype.sum_of_injective e he (fun k => v k * star (v k)) + (fun x : A × B => reshape e v x.1 x.2 * star (reshape e v x.1 x.2)) + (by rintro ⟨a,b⟩ h; rw [reshape_outside e v a b h]; simp) + (by intro k; rw [reshape_injective_apply e he]) + _ = _ := Fintype.sum_prod_type _ + +omit [DecidableEq A] in +lemma gram_psd (U : Matrix A B ℂ) : (U * U.conjTranspose).PosSemidef := by + simpa only [Matrix.mul_one] using + (Matrix.PosSemidef.one : (1 : Matrix B B ℂ).PosSemidef).mul_mul_conjTranspose_same U + +omit [DecidableEq K] [Fintype A] in +lemma reshape_even {P : Type*} (pa : A → P) (pb : B → P) (e : K → A × B) + (he : ∀ k, pa (e k).1 = pb (e k).2) (v : K → ℂ) (a a' : A) + (haa : pa a ≠ pa a') : (reshape e v * (reshape e v).conjTranspose) a a' = 0 := by + apply Finset.sum_eq_zero + intro b hb + change reshape e v a b * star (reshape e v a' b) = 0 + by_cases ha : pa a = pb b + · have hn : (a', b) ∉ Set.range e := by + rintro ⟨k,hk⟩ + have hh := he k + rw [hk] at hh + exact haa (ha.trans hh.symm) + rw [reshape_outside e v a' b hn, star_zero, mul_zero] + · have hn : (a,b) ∉ Set.range e := by + rintro ⟨k,hk⟩ + have hh := he k + rw [hk] at hh + exact ha hh + rw [reshape_outside e v a b hn, zero_mul] + +def reducedPhaseDensity (n : ℕ) (e : K → A × B) (c : WordType K n) + (t : K → ZMod (n+1)) : Matrix A A ℂ := + reshape e (phasedVector n (empirical n c) t) * + (reshape e (phasedVector n (empirical n c) t)).conjTranspose + +lemma reducedPhaseDensity_psd (n : ℕ) (e : K → A × B) (c : WordType K n) + (t : K → ZMod (n+1)) : (reducedPhaseDensity n e c t).PosSemidef := gram_psd _ + +lemma reducedPhaseDensity_trace (n : ℕ) (hn : 0 < n) (e : K → A × B) + (he : Function.Injective e) (c : WordType K n) (t : K → ZMod (n+1)) : + (reducedPhaseDensity n e c t).trace = 1 := by + rw [reducedPhaseDensity, reshape_trace e he] + exact phasedVector_trace n (empirical n c) (empirical_nonneg n c) (empirical_sum n hn c) t + +omit [Fintype A] in +lemma reducedPhaseDensity_even {P : Type*} (n : ℕ) (pa : A → P) (pb : B → P) + (e : K → A × B) (he : ∀ k, pa (e k).1 = pb (e k).2) + (c : WordType K n) (t : K → ZMod (n+1)) (a a' : A) (haa : pa a ≠ pa a') : + reducedPhaseDensity n e c t a a' = 0 := reshape_even pa pb e he _ a a' haa + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/TensorBounds/TypeMass.lean b/lean/OAI/Probability/BinarySweep/TensorBounds/TypeMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..b91db21d8b5d7048977bcfcca544111fa8bb1b14 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/TensorBounds/TypeMass.lean @@ -0,0 +1,200 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Density + +lemma factorial_mode (b c : ℕ) : c.factorial * c^b ≤ b.factorial * c^c := by + rcases le_total c b with h | h + · have hi := Nat.factorial_mul_pow_sub_le_factorial h + calc + c.factorial * c^b = (c.factorial * c^(b-c)) * c^c := by + rw [mul_assoc, ← pow_add, Nat.sub_add_cancel h] + _ ≤ b.factorial * c^c := Nat.mul_le_mul_right _ hi + · have hi : c.factorial ≤ b.factorial * c^(c-b) := by + calc + c.factorial = b.factorial * c.descFactorial (c-b) := by + simpa only [Nat.sub_sub_self h] using + (Nat.factorial_mul_descFactorial (Nat.sub_le c b)).symm + _ ≤ _ := Nat.mul_le_mul_left _ (Nat.descFactorial_le_pow _ _) + calc + c.factorial * c^b ≤ (b.factorial * c^(c-b)) * c^b := Nat.mul_le_mul_right _ hi + _ = b.factorial * c^c := by rw [mul_assoc, ← pow_add, Nat.sub_add_cancel h] + +variable {A : Type*} [Fintype A] [DecidableEq A] + +omit [DecidableEq A] in +lemma multinomial_mode (n : ℕ) (c b : A → ℕ) (hc : ∑ a, c a = n) (hb : ∑ a, b a = n) : + Nat.multinomial Finset.univ b * ∏ a, (c a)^(b a) ≤ + Nat.multinomial Finset.univ c * ∏ a, (c a)^(c a) := by + have h := Finset.prod_le_prod (fun a (_ : a ∈ (Finset.univ : Finset A)) => factorial_mode (b a) (c a)) + simp only [Finset.prod_mul_distrib] at h + have hbs := Nat.multinomial_spec (s := Finset.univ) (f := b) + have hcs := Nat.multinomial_spec (s := Finset.univ) (f := c) + rw [hb] at hbs + rw [hc] at hcs + refine Nat.le_of_mul_le_mul_left (c := n.factorial) ?_ (Nat.factorial_pos n) + calc + n.factorial * (Nat.multinomial Finset.univ b * ∏ a, c a ^ b a) = + (Nat.multinomial Finset.univ b * Nat.multinomial Finset.univ c) * + ((∏ a, (c a).factorial) * ∏ a, c a ^ b a) := by rw [← hcs]; ring + _ ≤ (Nat.multinomial Finset.univ b * Nat.multinomial Finset.univ c) * + ((∏ a, (b a).factorial) * ∏ a, c a ^ c a) := Nat.mul_le_mul_left _ h + _ = n.factorial * (Nat.multinomial Finset.univ c * ∏ a, c a ^ c a) := by rw [← hbs]; ring + +lemma card_types_le (n : ℕ) : + (Finset.piAntidiag (Finset.univ : Finset A) n).card ≤ (n+1)^(Fintype.card A) := by + classical + let T := ↥(Finset.piAntidiag (Finset.univ : Finset A) n) + let : Fintype T := FinsetCoe.fintype _ + let f : T → (A → Fin (n+1)) := fun b a => ⟨b.val a, by + have hb := (Finset.mem_piAntidiag.mp b.property).1 + have hh := Finset.single_le_sum (f := b.val) (fun _ _ => Nat.zero_le _) (Finset.mem_univ a) + exact Nat.lt_succ_of_le (hh.trans_eq hb)⟩ + have hf : Function.Injective f := by + intro b c h + apply Subtype.ext + funext a + exact congrArg Fin.val (congrFun h a) + have h := Fintype.card_le_of_injective f hf + simpa [T, Fintype.card_pi] using h + +theorem type_mass_lower_nat (n : ℕ) (c : A → ℕ) (hc : ∑ a, c a = n) : + n^n ≤ (n+1)^(Fintype.card A) * + (Nat.multinomial Finset.univ c * ∏ a, c a ^ c a) := by + calc + n^n = ∑ b ∈ Finset.piAntidiag Finset.univ n, + Nat.multinomial Finset.univ b * ∏ a, c a ^ b a := by + simpa only [Nat.cast_id, hc] using Finset.sum_pow_eq_sum_piAntidiag Finset.univ c n + _ ≤ ∑ _b ∈ Finset.piAntidiag (Finset.univ : Finset A) n, + Nat.multinomial Finset.univ c * ∏ a, c a ^ c a := by + apply Finset.sum_le_sum + intro b hb + exact multinomial_mode n c b hc (Finset.mem_piAntidiag.mp hb).1 + _ = (Finset.piAntidiag (Finset.univ : Finset A) n).card * + (Nat.multinomial Finset.univ c * ∏ a, c a ^ c a) := by simp + _ ≤ _ := Nat.mul_le_mul_right _ (card_types_le n) + +theorem type_mass_lower (n : ℕ) (hn : 0 < n) (c : A → ℕ) (hc : ∑ a, c a = n) : + 1 ≤ ((n+1 : ℕ) : ℝ)^(Fintype.card A) * + ((Nat.multinomial Finset.univ c : ℝ) * ∏ a, ((c a : ℝ) / n) ^ c a) := by + have h : (n : ℝ)^n ≤ ((n+1 : ℕ) : ℝ)^(Fintype.card A) * + ((Nat.multinomial Finset.univ c : ℝ) * ∏ a, (c a : ℝ)^c a) := by + exact_mod_cast type_mass_lower_nat n c hc + have hn' : 0 < (n : ℝ)^n := pow_pos (by exact_mod_cast hn) _ + simp_rw [div_pow] + rw [Finset.prod_div_distrib, Finset.prod_pow_eq_pow_sum, hc] + rw [← mul_div_assoc, ← mul_div_assoc] + apply (le_div_iff₀ hn').mpr + simpa only [one_mul, mul_div_assoc] using h + +end BinaryCoordinateSweeps.Density + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Density +variable {A I : Type*} [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + +def wordCounts (w : I → A) : A →₀ ℕ := ∑ i, Finsupp.single (w i) 1 + +omit [Fintype A] [DecidableEq I] in +lemma wordCounts_apply (w : I → A) (a : A) : + wordCounts w a = (Finset.univ.filter (fun i => w i = a)).card := by + simp only [wordCounts, Finsupp.finsetSum_apply, Finsupp.single_apply, Finset.card_filter] + +omit [Fintype A] [DecidableEq I] in +lemma wordCounts_fiber (w : I → A) (a : A) : + wordCounts w a = Fintype.card {i // w i = a} := by + rw [Fintype.card_subtype, wordCounts_apply] + +omit [Fintype A] [DecidableEq A] [DecidableEq I] in +lemma wordCounts_total (w : I → A) : (wordCounts w).sum (fun _ k => k) = Fintype.card I := by + rw [wordCounts, ← Finsupp.sum_finsetSum_index (fun _ => rfl) (fun _ _ _ => rfl)] + simp + +omit [DecidableEq A] [DecidableEq I] in +lemma wordCounts_sum (w : I → A) : ∑ a, wordCounts w a = Fintype.card I := by + have h := wordCounts_total w + rw [Finsupp.sum_of_support_subset _ (Finset.subset_univ _) (fun _ k => k) (by simp)] at h + exact h + +omit [DecidableEq I] in +lemma prod_wordCounts {M : Type*} [CommMonoid M] (v : A → M) (w : I → A) : + ∏ i, v (w i) = ∏ a, v a ^ wordCounts w a := by + rw [← Fintype.prod_fiberwise' w v] + apply Finset.prod_congr rfl + intro a ha + simp only [Finset.prod_const, Finset.card_univ, wordCounts_fiber] + +omit [Fintype A] [DecidableEq A] [DecidableEq I] in +lemma wordCounts_comp (w : I → A) (g : Equiv.Perm I) : wordCounts (w ∘ g) = wordCounts w := by + unfold wordCounts + exact Equiv.sum_comp g (fun i => Finsupp.single (w i) 1) + +omit [Fintype A] [DecidableEq I] in +lemma exists_perm_eq_of_wordCounts {w v : I → A} (h : wordCounts w = wordCounts v) : + ∃ g : Equiv.Perm I, ∀ i, v (g i) = w i := by + have hc (a : A) : Fintype.card {i // w i = a} = Fintype.card {i // v i = a} := by + rw [← wordCounts_fiber, ← wordCounts_fiber, h] + let e (a : A) := Fintype.equivOfCardEq (hc a) + let g := (Equiv.sigmaFiberEquiv w).symm.trans + ((Equiv.sigmaCongrRight e).trans (Equiv.sigmaFiberEquiv v)) + refine ⟨g, fun i => ?_⟩ + change v ((e (w i) ⟨i,rfl⟩).val) = w i + exact (e (w i) ⟨i,rfl⟩).property + +omit [DecidableEq A] in +lemma word_polynomial (n : ℕ) : + (∑ a, MvPolynomial.X a : MvPolynomial A ℕ)^n = + ∑ w : Fin n → A, MvPolynomial.monomial (wordCounts w) 1 := by + calc + _ = ∏ _i : Fin n, (∑ a, MvPolynomial.X a : MvPolynomial A ℕ) := by simp + _ = ∑ w : Fin n → A, ∏ i, (MvPolynomial.X (w i) : MvPolynomial A ℕ) := by + exact Fintype.prod_sum _ + _ = _ := by + apply Finset.sum_congr rfl + intro w hw + rw [wordCounts, MvPolynomial.monomial_sum_one] + rfl + +lemma card_words_counts (n : ℕ) (c : A →₀ ℕ) (hc : c.sum (fun _ k => k) = n) : + Fintype.card {w : Fin n → A // wordCounts w = c} = c.multinomial := by + have he := congrArg (fun polynomial : MvPolynomial A ℕ => polynomial.coeff c) + (word_polynomial (A := A) n) + rw [MvPolynomial.coeff_sum_X_pow_of_fintype, ite_eq_left hc] at he + simp only [MvPolynomial.coeff_sum, MvPolynomial.coeff_monomial, Nat.cast_id] at he + rw [Fintype.card_subtype, Finset.card_filter] + convert he.symm using 1 + +lemma card_words_counts_fun (n : ℕ) (c : A → ℕ) (hc : ∑ a, c a = n) : + Fintype.card {w : Fin n → A // ∀ a, wordCounts w a = c a} = + Nat.multinomial Finset.univ c := by + let c' : A →₀ ℕ := Finsupp.equivFunOnFinite.symm c + have htotal : c'.sum (fun _ k => k) = n := by + rw [Finsupp.sum_of_support_subset _ (Finset.subset_univ _) _ (by simp)] + exact hc + have he : {w : Fin n → A // ∀ a, wordCounts w a = c a} ≃ + {w : Fin n → A // wordCounts w = c'} := Equiv.subtypeEquivRight (fun w => by + constructor + · intro h + apply Finsupp.ext + exact h + · intro h a + exact congrArg (fun b : A →₀ ℕ => b a) h) + rw [Fintype.card_congr he, card_words_counts n c' htotal, + Finsupp.multinomial_eq_of_support_subset (Finset.subset_univ _)] + rfl + +end BinaryCoordinateSweeps.Density + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointEntryBound.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointEntryBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..34f9eb2b09bfcbc56da49bd7de49155439179d1f --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointEntryBound.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.PathMomentMixed + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma Sparse.mobiusSum_abs_le {I : Type*} [DecidableEq I] + (U : Finset I) (f : Finset I → ℝ) (B : ℝ) + (hb : ∀A⊆U, |f A|≤B) : |mobiusSum U f|≤(2:ℝ)^U.card*B := by + unfold mobiusSum + calc + _ ≤ ∑A∈U.powerset, |(-1:ℝ)^(U.card-A.card)*f A| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑A∈U.powerset, B := by + apply Finset.sum_le_sum + intro A hA + simpa only [abs_mul,abs_pow,abs_neg,abs_one,one_pow,one_mul] using hb A (Finset.mem_powerset.mp hA) + _ = _ := by simp only [Finset.sum_const,Finset.card_powerset,nsmul_eq_mul,Nat.cast_pow,Nat.cast_ofNat] + +lemma occurrences_injective_le {I J L : Type*} [Fintype I] [Fintype J] + (f : I → L) (g : J → L) (e : I → J) (hi : Function.Injective e) + (he : ∀i, g (e i)=f i) (l : L) : occurrences f l≤occurrences g l := by + apply Fintype.card_le_of_injective + (fun a : {i // f i=l} => (⟨e a.val,(he a.val).trans a.property⟩ : {j // g j=l})) + intro a c hac + exact Subtype.ext (hi (congrArg Subtype.val hac)) + +lemma endpoint_mixed_occurrences_le (e : Fin k → GridSlot bits × GridSlot bits) + (G J : Finset (Fin k)) (hd : Disjoint J G) (l : EndpointLineIndex bits) : + occurrences (Sum.elim (fun a : J × Fin b => endpointPathLine e a.1 a.2) + (fun a : G × Fin b => endpointPathLine e a.1 a.2)) l ≤ + endpointLineCount Finset.univ e l.1 l.2 := by + let emb : (J × Fin b) ⊕ (G × Fin b) → ↥(Finset.univ : Finset (Fin k)) × Fin b := + Sum.elim (fun a => (⟨a.1.val,Finset.mem_univ _⟩,a.2)) + (fun a => (⟨a.1.val,Finset.mem_univ _⟩,a.2)) + have hi : Function.Injective emb := by + intro a c hac + cases a with + | inl a => cases c with + | inl c => exact congrArg Sum.inl (Prod.ext (Subtype.ext (congrArg (fun x => x.1.val) hac)) (congrArg (fun v : ↥(Finset.univ : Finset (Fin k)) × Fin b => v.2) hac)) + | inr c => + have he : a.1.val=c.1.val := congrArg (fun x => x.1.val) hac + exact False.elim (Finset.disjoint_left.mp hd a.1.property (he.symm ▸ c.1.property)) + | inr a => cases c with + | inl c => + have he : a.1.val=c.1.val := congrArg (fun x => x.1.val) hac + exact False.elim (Finset.disjoint_left.mp hd c.1.property (he ▸ a.1.property)) + | inr c => exact congrArg Sum.inr (Prod.ext (Subtype.ext (congrArg (fun x => x.1.val) hac)) (congrArg (fun v : ↥(Finset.univ : Finset (Fin k)) × Fin b => v.2) hac)) + have ht := occurrences_injective_le + (Sum.elim (fun a : J × Fin b => endpointPathLine e a.1 a.2) + (fun a : G × Fin b => endpointPathLine e a.1 a.2)) (fun a : ↥(Finset.univ : Finset (Fin k)) × Fin b => + endpointPathLine e a.1 a.2) emb hi (fun a => by cases a <;> rfl) l + rcases l with ⟨j,y⟩ + simpa only [pathLine_occurrences] using ht + +def endpointLight (η : ℝ) (e : Fin k → GridSlot bits × GridSlot bits) + (l : EndpointLineIndex bits) : Prop := + (lineHoles H l.1 l.2:ℝ)+endpointLineCount Finset.univ e l.1 l.2 ≤ (2^bits l.1:ℕ)*η + +lemma endpoint_pathMoment_bound (e : Fin k → GridSlot bits × GridSlot bits) + (G J : Finset (Fin k)) (hd : Disjoint J G) {η : ℝ} (hη0 : 0≤η) (hη : η≤1/4) + (hl : ∀i∈G, ∀j, endpointLight H η e (endpointPathLine e i j)) : + let P := (∏i∈G, (endpointPathPolynomial e i-1))*∏i∈J,endpointPathPolynomial e i + 0 ≤ multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) (fun l => lineHoles H l.1 l.2) P ∧ + multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) (fun l => lineHoles H l.1 l.2) P ≤ + Real.exp ((b*h+k+k*b:ℕ):ℝ)*2^(k*b)*(4*b*Real.sqrt η)^G.card := by + dsimp only + have hb := pathMoment_mixed + (fun l : EndpointLineIndex bits => 2^bits l.1) (fun l => lineHoles H l.1 l.2) + (fun i : G => endpointPathLine e i) (fun a : J × Fin b => endpointPathLine e a.1 a.2) + (η:=η) (fun _ => by positivity) hη0 hη (fun i j => by + have hn := endpoint_mixed_occurrences_le e G J hd (endpointPathLine e i j) + have hn' : (occurrences (Sum.elim (fun a : J × Fin b => endpointPathLine e a.1 a.2) + (fun a : G × Fin b => endpointPathLine e a.1 a.2)) (endpointPathLine e i j):ℝ) ≤ + endpointLineCount Finset.univ e j (endpointLine (e i) j) := by exact_mod_cast hn + have ht := hl i i.property j + change (lineHoles H j (endpointLine (e i) j):ℝ)+_≤_ at ht ⊢ + dsimp only [endpointPathLine] at ht hn' ⊢ + linarith only [hn',ht]) + dsimp only at hb + have hp1 : (∏i : G, ((∏j, (MvPolynomial.X (endpointPathLine e i j) : MvPolynomial (EndpointLineIndex bits) ℝ))-1)) = + ∏i∈G, (endpointPathPolynomial e i-1) := + Finset.prod_coe_sort G (fun i => endpointPathPolynomial e i-1) + have hp2 : (∏a : J × Fin b, (MvPolynomial.X (endpointPathLine e a.1 a.2) : MvPolynomial (EndpointLineIndex bits) ℝ)) = + ∏i∈J, endpointPathPolynomial e i := + (Fintype.prod_prod_type _).trans (Finset.prod_coe_sort J (endpointPathPolynomial e)) + rw [hp1,hp2] at hb + simp only [Fintype.card_prod,Fintype.card_coe,Fintype.card_fin] at hb + refine ⟨hb.1,hb.2.trans ?_⟩ + have hc : J.card+G.card≤k := by + rw [← Finset.card_union_of_disjoint hd] + exact (Finset.card_le_card (Finset.subset_univ _)).trans_eq (Finset.card_fin k) + have hg : G.card≤k := by omega + have hpow : J.card*b+G.card*b≤k*b := by nlinarith + have hh : (∑l : EndpointLineIndex bits, (lineHoles H l.1 l.2:ℝ))=(b*h:ℕ) := by + rw [Fintype.sum_sigma] + simp only [← Nat.cast_sum,sum_lineHoles,Finset.sum_const,Finset.card_univ,Fintype.card_fin,smul_eq_mul] + rw [hh] + calc + _ ≤ (b:ℝ)^G.card * (Real.exp ((b*h+k+k*b:ℕ):ℝ)*2^(k*b)*(4*Real.sqrt η)^G.card) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply mul_le_mul + · apply Real.exp_le_exp.mpr + exact_mod_cast (show b*h+G.card+(J.card*b)+G.card*b≤b*h+k+k*b by omega) + · exact pow_le_pow_right₀ (by norm_num) hpow + · positivity + · positivity + _ = _ := by rw [show 4*(b:ℝ)*Real.sqrt η=b*(4*Real.sqrt η) by ring,mul_pow]; ring + +theorem centeredEndpointKernel_good_bound (x : Placement H k 0) + (y : Placement H k (Fin.last b)) (G : Finset (Fin k)) {η : ℝ} + (hη0 : 0≤η) (hη : η≤1/4) + (hi : ∀i∈G, vertexIsolated H (fun i => ((x i).val,(y i).val)) i) + (hl : ∀i∈G, ∀j, endpointLight H η (fun i => ((x i).val,(y i).val)) + (endpointPathLine (fun i => ((x i).val,(y i).val)) i j)) : + |(gridSize bits:ℝ)^k*centeredEndpointKernel H 0 (fun i => ((x i).val,(y i).val))| ≤ + (2:ℝ)^(k+k*b)*Real.exp ((b*h+k+k*b:ℕ):ℝ)*(4*b*Real.sqrt η)^G.card := by + rw [centeredEndpointKernel_good_expansion H x y G hi] + have hc : (Finset.univ\G).card≤k := (Finset.card_le_card (Finset.sdiff_subset)).trans_eq (Finset.card_fin k) + have hb := mobiusSum_abs_le (Finset.univ\G) (fun J => + if EndpointValid H J (fun i => ((x i).val,(y i).val)) then + multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) (fun l => lineHoles H l.1 l.2) + ((∏i∈G,(endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i-1))* + ∏i∈J,endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i) + else 0) (Real.exp ((b*h+k+k*b:ℕ):ℝ)*2^(k*b)*(4*b*Real.sqrt η)^G.card) (fun J hJ => by + have hd : Disjoint J G := Finset.disjoint_sdiff.symm.mono_left hJ + have he := endpoint_pathMoment_bound H (fun i => ((x i).val,(y i).val)) G J hd hη0 hη hl + split_ifs + · rw [abs_of_nonneg he.1]; exact he.2 + · simp only [abs_zero]; positivity) + apply hb.trans + calc + _ ≤ (2:ℝ)^k*(Real.exp ((b*h+k+k*b:ℕ):ℝ)*2^(k*b)*(4*b*Real.sqrt η)^G.card) := + mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) hc) (by positivity) + _ = _ := by rw [pow_add]; ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointEvents.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointEvents.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a854def85304bb36fd75380b89310b504c0b2d0 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointEvents.lean @@ -0,0 +1,128 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.UniformFiniteProbability + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +open Sparse + +variable {b h : ℕ} {bits : Fin b → ℕ} + +lemma gridLayer_at (g : GridChoices bits) (j : Fin b) (x : GridSlot bits) : + gridLayer bits g j x j = g j (fun i => x i) (x j) := by + simp [gridLayer,Equiv.piSplitAt_symm_apply] + +@[simp] lemma independentPosition_zero (e : GridSlot bits × GridSlot bits) : + independentPosition e 0=e.1 := by ext i; simp [independentPosition] + +@[simp] lemma independentPosition_last (e : GridSlot bits × GridSlot bits) : + independentPosition e (Fin.last b)=e.2 := by ext i; simp [independentPosition] + +def endpointLine (e : GridSlot bits × GridSlot bits) (j : Fin b) : GridOutside bits j := + fun i => independentPosition e j.castSucc i + +lemma endpoint_gridLayer_iff (g : GridChoices bits) (e : GridSlot bits × GridSlot bits) (j : Fin b) : + gridLayer bits g j (independentPosition e j.castSucc)=independentPosition e j.succ ↔ + g j (endpointLine e j) (e.1 j)=e.2 j := by + unfold endpointLine + constructor + · intro he + have hh := congrFun he j + simpa only [gridLayer_at,endpointLine,independentPosition,Fin.val_castSucc, + Fin.val_succ,lt_self_iff_false,ite_false,Nat.lt_succ_self,ite_true] using hh + · intro he + funext i + by_cases hi : i=j + · subst i + simpa only [gridLayer_at,endpointLine,independentPosition,Fin.val_castSucc, + Fin.val_succ,lt_self_iff_false,ite_false,Nat.lt_succ_self,ite_true] using he + · rw [gridLayer_other bits g j i hi] + exact (independentPosition_changes e j i hi).symm + +lemma gridSweep_endpoint_iff (g : GridChoices bits) (e : GridSlot bits × GridSlot bits) : + gridSweep bits g e.1=e.2 ↔ ∀j, g j (endpointLine e j) (e.1 j)=e.2 j := by + constructor + · intro he j + have hp (t : Fin (b+1)) : gridPartialSweep bits g t e.1=independentPosition e t := by + have hh := independentPosition_of_path (fun t => gridPartialSweep bits g t e.1) + (gridPartialSweep_changes bits g e.1) t + simpa only [gridPartialSweep_zero,Equiv.Perm.one_apply,gridPartialSweep_last,he] using hh.symm + apply (endpoint_gridLayer_iff g e j).mp + rw [← hp j.castSucc,← hp j.succ,gridPartialSweep_succ,Equiv.Perm.mul_apply] + · intro he + have hh := chronological_trajectory b (gridLayer bits g) (independentPosition e) + (fun j => (endpoint_gridLayer_iff g e j).mpr (he j)) + simpa only [independentPosition_zero,independentPosition_last,gridSweep] using hh + +variable {I : Type*} [Fintype I] [DecidableEq I] + +def localEndpointEvent (A : Finset I) (e : I → GridSlot bits × GridSlot bits) + (j : Fin b) (y : GridOutside bits j) (σ : Equiv.Perm (Slot (bits j))) : Prop := + ∀i ∈ A, endpointLine (e i) j=y → σ ((e i).1 j)=(e i).2 j + +def endpointMass (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) : ℝ := + ∑g : GridChoices bits, if pathEvent H g ∧ ∀i ∈ A, gridSweep bits g (e i).1=(e i).2 then + gridWeight bits z g else 0 + +def localEndpointMass (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) (j : Fin b) (y : GridOutside bits j) : ℝ := + ∑σ, if Assigns (lineInput H j y) (lineOutput H j y) σ ∧ localEndpointEvent A e j y σ then + lineLaw (bits j) z σ else 0 + +lemma endpointMass_factor (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) : + endpointMass H z A e = ∏j, ∏y, localEndpointMass H z A e j y := by + have he (g : GridChoices bits) : + (pathEvent H g ∧ ∀i ∈ A, gridSweep bits g (e i).1=(e i).2) ↔ + ∀j y, Assigns (lineInput H j y) (lineOutput H j y) (g j y) ∧ + localEndpointEvent A e j y (g j y) := by + rw [pathEvent_iff_assigns] + simp_rw [gridSweep_endpoint_iff] + constructor + · rintro ⟨hg,hp⟩ j y + refine ⟨hg j y,?_⟩ + intro i hi hiy + rw [← hiy] + exact hp i hi j + · intro hh + refine ⟨fun j y => (hh j y).1,?_⟩ + intro i hi j + exact (hh j (endpointLine (e i) j)).2 i hi rfl + unfold endpointMass localEndpointMass + rw [← sum_prod_grid] + apply Finset.sum_congr rfl + intro g _ + simp only [Fintype.prod_ite_zero] + simp only [he,gridWeight] + split_ifs <;> rfl + +omit [Fintype I] in +lemma localEndpointEvent_insert (A : Finset I) (e : I → GridSlot bits × GridSlot bits) + (i : I) (j : Fin b) (y : GridOutside bits j) (σ : Equiv.Perm (Slot (bits j))) : + localEndpointEvent (insert i A) e j y σ ↔ + (endpointLine (e i) j=y → σ ((e i).1 j)=(e i).2 j) ∧ localEndpointEvent A e j y σ := by + simp only [localEndpointEvent,Finset.mem_insert,forall_eq_or_imp] + +omit [Fintype I] [DecidableEq I] in +lemma localEndpointEvent_empty_line (A : Finset I) (e : I → GridSlot bits × GridSlot bits) + (j : Fin b) (y : GridOutside bits j) (ha : ∀i ∈ A, endpointLine (e i) j≠y) + (σ : Equiv.Perm (Slot (bits j))) : localEndpointEvent A e j y σ := by + intro i hi hiy + exact (ha i hi hiy).elim + +lemma assigns_empty_line (H : PathFamily bits h) (j : Fin b) (y : GridOutside bits j) + (hn : ∀k, (fun i : {i : Fin b // i≠j} => H.position j.castSucc k i) ≠ y) + (σ : Equiv.Perm (Slot (bits j))) : Assigns (lineInput H j y) (lineOutput H j y) σ := by + intro k + exact (hn k.val k.property).elim + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointFactors.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b5bf7deb5cd40603947ab5f5f3bc9758f91b80c --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointFactors.lean @@ -0,0 +1,197 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.EndpointPlacement +import OAI.Probability.BinarySweep.Trajectories.EndpointValidity +import OAI.Probability.BinarySweep.FiniteLaws.OccurrenceMoment + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +abbrev EndpointLineIndex (bits : Fin b → ℕ) := Σj, GridOutside bits j + +def endpointPathLine {I : Type*} (e : I → GridSlot bits × GridSlot bits) + (i : I) (j : Fin b) : EndpointLineIndex bits := ⟨j,endpointLine (e i) j⟩ + +def endpointLineCount {I : Type*} [Fintype I] [DecidableEq I] + (A : Finset I) (e : I → GridSlot bits × GridSlot bits) + (j : Fin b) (y : GridOutside bits j) : ℕ := + Fintype.card {i : A // endpointLine (e i) j=y} + +lemma trackedLineCount_restrict (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (A : Finset (Fin k)) (g : ConditionalChoices H) + (he : ∀i∈A, gridSweep bits g.val (x i).val=(y i).val) + (j : Fin b) (l : GridOutside bits j) : + trackedLineCount H (restrictPlacement H x A) g j l = + endpointLineCount A (fun i => ((x i).val,(y i).val)) j l := by + apply Fintype.card_congr + apply ((Fintype.equivFin A).symm).subtypeEquiv + intro i + change (fun a : {a : Fin b // a≠j} => gridPartialSweep bits g.val j.castSucc + (x ((Fintype.equivFin A).symm i)).val a)=l ↔ _ + rw [gridPartialSweep_endpoint g.val + ((x ((Fintype.equivFin A).symm i)).val,(y ((Fintype.equivFin A).symm i)).val) + (he _ ((Fintype.equivFin A).symm i).property)] + rfl + +theorem endpointProbability_zero_scaled (x : Placement H k 0) + (y : Placement H k (Fin.last b)) (A : Finset (Fin k)) : + (gridSize bits:ℝ)^A.card * endpointProbability H 0 A (fun i => ((x i).val,(y i).val)) = + if EndpointValid H A (fun i => ((x i).val,(y i).val)) then + ∏j, ∏l : GridOutside bits j, + fallingMoment (2^bits j) (lineHoles H j l) + (endpointLineCount A (fun i => ((x i).val,(y i).val)) j l) + else 0 := by + by_cases hv : EndpointValid H A (fun i => ((x i).val,(y i).val)) + · rw [ite_eq_left hv] + obtain ⟨g,hg⟩ := (endpointValid_placement_iff H x y A).mp hv + have he := (restrictPlacement_event H x y A g).mpr hg + rw [endpointProbability_placement,← he] + simpa only [Fintype.card_coe,trackedLineCount_restrict H x y A g hg] using + placementProbability_zero_scaled H (restrictPlacement H x A) g + · rw [ite_eq_right hv,endpointProbability_conditional] + have hz : conditionalEventWeight H 0 (fun g => ∀i∈A, + gridSweep bits g (x i).val=(y i).val)=0 := by + unfold conditionalEventWeight + apply Finset.sum_eq_zero + intro g _ + rw [ite_eq_right] + exact fun hg => hv (endpointValid_of_placement_event H x y A g hg) + rw [hz,mul_zero] + +lemma pathLine_occurrences {I : Type*} [Fintype I] [DecidableEq I] + (A : Finset I) (e : I → GridSlot bits × GridSlot bits) + (j : Fin b) (y : GridOutside bits j) : + occurrences (fun a : A × Fin b => endpointPathLine e a.1 a.2) ⟨j,y⟩ = + endpointLineCount A e j y := by + let : DecidableEq (EndpointLineIndex bits) := Classical.decEq _ + unfold occurrences endpointLineCount + exact Fintype.card_congr + {toFun := fun ⟨⟨i,a⟩,ha⟩ => ⟨i,by + have hj : a=j := congrArg Sigma.fst ha + subst a + exact (Sigma.mk.inj ha).2.eq⟩ + invFun := fun a => ⟨(a.val,j),congrArg (Sigma.mk j) a.property⟩ + left_inv := fun ⟨⟨i,a⟩,ha⟩ => by + have hj : a=j := congrArg Sigma.fst ha + subst a + rfl + right_inv := fun a => rfl} + +lemma multilineMoment_X_prod {L A : Type*} [Fintype L] [Fintype A] + (m h : L → ℕ) (f : A → L) : + multilineMoment m h (∏a, (MvPolynomial.X (f a) : MvPolynomial L ℝ)) = + ∏l, fallingMoment (m l) (h l) (occurrences f l) := by + have hh := occurrenceMoment_eq m h (fun a : Empty => a.elim) f + simpa only [Finset.univ_eq_empty,Finset.prod_empty,one_mul,occurrences, + Fintype.card_of_isEmpty,centeredLineMoment_zero] using hh + +theorem endpointProbability_zero_polynomial (x : Placement H k 0) + (y : Placement H k (Fin.last b)) (A : Finset (Fin k)) : + (gridSize bits:ℝ)^A.card * endpointProbability H 0 A (fun i => ((x i).val,(y i).val)) = + if EndpointValid H A (fun i => ((x i).val,(y i).val)) then + multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) + (fun l => lineHoles H l.1 l.2) + (∏i : A, ∏j : Fin b, (MvPolynomial.X + (endpointPathLine (fun i => ((x i).val,(y i).val)) i j) : + MvPolynomial (EndpointLineIndex bits) ℝ)) + else 0 := by + rw [endpointProbability_zero_scaled] + congr 1 + have hp := Fintype.prod_prod_type (fun a : A × Fin b => + (MvPolynomial.X (endpointPathLine (fun i => ((x i).val,(y i).val)) a.1 a.2) : + MvPolynomial (EndpointLineIndex bits) ℝ)) + rw [← hp,multilineMoment_X_prod,Fintype.prod_sigma] + simp only [pathLine_occurrences] + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {I R : Type*} [DecidableEq I] [CommRing R] + +def mobiusSum (U : Finset I) (f : Finset I → R) : R := + ∑A ∈ U.powerset, (-1:R)^(U.card-A.card)*f A + +omit [DecidableEq I] in +lemma mobiusSum_empty (f : Finset I → R) : mobiusSum ∅ f=f ∅ := by simp [mobiusSum] + +omit [DecidableEq I] in +lemma mobiusSum_congr (U : Finset I) (f g : Finset I → R) + (hfg : ∀A⊆U, f A=g A) : mobiusSum U f=mobiusSum U g := by + apply Finset.sum_congr rfl + intro A hA + rw [hfg A (Finset.mem_powerset.mp hA)] + +omit [DecidableEq I] in +lemma mobiusSum_sub (U : Finset I) (f g : Finset I → R) : + mobiusSum U (fun A => f A-g A)=mobiusSum U f-mobiusSum U g := by + simp only [mobiusSum,mul_sub,Finset.sum_sub_distrib] + +lemma mobiusSum_insert (U : Finset I) (i : I) (hi : i∉U) (f : Finset I → R) : + mobiusSum (insert i U) f=mobiusSum U (fun A => f (insert i A)-f A) := by + unfold mobiusSum + rw [Finset.sum_powerset_insert hi,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro A hA + have hAU := Finset.mem_powerset.mp hA + have hiA : i∉A := fun ha => hi (hAU ha) + have hc := Finset.card_le_card hAU + rw [Finset.card_insert_of_notMem hi,Finset.card_insert_of_notMem hiA] + rw [show U.card+1-A.card=U.card-A.card+1 by omega, + show U.card+1-(A.card+1)=U.card-A.card by omega,pow_succ] + ring + +lemma mobiusSum_union (G C : Finset I) (hGC : Disjoint G C) (f : Finset I → R) : + mobiusSum (G∪C) f=mobiusSum C (fun J => mobiusSum G (fun B => f (J∪B))) := by + induction C using Finset.induction_on generalizing f with + | empty => simp only [Finset.union_empty,mobiusSum_empty,Finset.empty_union] + | @insert i C hi ih => + have hiG : i∉G := fun hg => Finset.disjoint_left.mp hGC hg (Finset.mem_insert_self _ _) + have hGC' : Disjoint G C := hGC.mono_right (Finset.subset_insert _ _) + have hiU : i∉G∪C := by simp only [Finset.mem_union,not_or]; exact ⟨hiG,hi⟩ + rw [Finset.union_insert,mobiusSum_insert _ _ hiU,mobiusSum_insert _ _ hi] + rw [ih hGC'] + apply mobiusSum_congr + intro J _ + rw [← mobiusSum_sub] + apply mobiusSum_congr + intro B _ + rw [Finset.insert_union] + +variable [Algebra ℝ R] + +lemma mobiusSum_linear_product (U : Finset I) (L : R →ₗ[ℝ] ℝ) (X : I → R) (P : R) : + mobiusSum U (fun A => L (P*∏i∈A, X i))=L (P*∏i∈U, (X i-1)) := by + induction U using Finset.induction_on generalizing P with + | empty => simp only [mobiusSum_empty,Finset.prod_empty,mul_one] + | @insert i U hi ih => + rw [mobiusSum_insert _ _ hi,Finset.prod_insert hi] + trans mobiusSum U (fun A => L ((P*(X i-1))*∏a∈A,X a)) + · apply mobiusSum_congr + intro A hA + have hiA : i∉A := fun ha => hi (hA ha) + rw [Finset.prod_insert hiA,← map_sub] + congr 1 + ring + · rw [ih] + congr 1 + ring + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointGood.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointGood.lean new file mode 100644 index 0000000000000000000000000000000000000000..952bcb2038f878a0d13f989ac9126d324d3391e1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointGood.lean @@ -0,0 +1,237 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.SparseAmplitude +import OAI.Probability.BinarySweep.Trajectories.EndpointOccupancy + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +lemma Sparse.productProbability_or_le {I Ω : Type*} [Fintype I] [DecidableEq I] [Fintype Ω] + (p : Ω → ℝ) (hp : ∀u, 0≤p u) (E F : (I → Ω) → Prop) : + productProbability p (fun x => E x ∨ F x) ≤ productProbability p E+productProbability p F := by + unfold productProbability + rw [← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro x _ + have hx := productWeight_nonneg hp x + by_cases he : E x <;> by_cases hf : F x <;> simp [he,hf,hx] + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +def endpointVertexIncident (e : Fin k → GridSlot bits × GridSlot bits) : Finset (Fin k) := + incidentSet shareVertex (fun a => (H.position 0 a,H.position (Fin.last b) a)) e + +lemma vertexIsolated_of_not_incident (e : Fin k → GridSlot bits × GridSlot bits) (i : Fin k) + (hi : i∉endpointVertexIncident H e) : vertexIsolated H e i := by + have hh (a : Fin h) (t : Fin (b+1)) : + independentPosition (H.position 0 a,H.position (Fin.last b) a) t=H.position t a := + independentPosition_of_path (fun t => H.position t a) (fun j i hi => H.changes_only_stage j a i hi) t + have hn : ¬((∃j,i≠j ∧ shareVertex (e i) (e j)) ∨ + ∃a, shareVertex (e i) (H.position 0 a,H.position (Fin.last b) a)) := by + simpa only [endpointVertexIncident,incidentSet,Finset.mem_filter,Finset.mem_univ,true_and] using hi + constructor + · intro t a he + exact hn (Or.inr ⟨a,t,he.trans (hh a t).symm⟩) + · intro t a ha he + exact hn (Or.inl ⟨a,ha.symm,t,he.symm⟩) + +def endpointGoodSet (η : ℝ) (e : Fin k → GridSlot bits × GridSlot bits) : Finset (Fin k) := + Finset.univ.filter (fun i => i∉endpointVertexIncident H e ∧ + ∀j, endpointLight H η e (endpointPathLine e i j)) + +def endpointHoleBad (η : ℝ) (e : Fin k → GridSlot bits × GridSlot bits) (j : Fin b) : Finset (Fin k) := + Finset.univ.filter (fun i => endpointLine (e i) j∈holeHeavyLines H j η) + +def endpointParticleBad (η : ℝ) (e : Fin k → GridSlot bits × GridSlot bits) (j : Fin b) : Finset (Fin k) := + Finset.univ.filter (fun i => endpointLine (e i) j∈particleHeavyLines e j η) + +lemma endpointGood_cover (η : ℝ) (e : Fin k → GridSlot bits × GridSlot bits) : + k ≤ (endpointGoodSet H η e).card+(endpointVertexIncident H e).card+ + (∑j, (endpointHoleBad H η e j).card)+(∑j, (endpointParticleBad η e j).card) := by + let G := endpointGoodSet H η e + let V := endpointVertexIncident H e + let S := Finset.univ.biUnion (endpointHoleBad H η e) + let T := Finset.univ.biUnion (endpointParticleBad η e) + have hc : (Finset.univ : Finset (Fin k))⊆((G∪V)∪S)∪T := by + intro i _ + by_cases hv : i∈V + · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_right _ hv)) + by_cases hl : ∀j, endpointLight H η e (endpointPathLine e i j) + · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_left _ + (Finset.mem_filter.mpr ⟨Finset.mem_univ _,hv,hl⟩))) + push Not at hl + obtain ⟨j,hj⟩ := hl + obtain hh | ht := endpoint_not_light H e j (endpointLine (e i) j) η hj + · apply Finset.mem_union_left + apply Finset.mem_union_right + exact Finset.mem_biUnion.mpr ⟨j,Finset.mem_univ _,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hh⟩⟩ + · apply Finset.mem_union_right + exact Finset.mem_biUnion.mpr ⟨j,Finset.mem_univ _,Finset.mem_filter.mpr ⟨Finset.mem_univ _,ht⟩⟩ + have h1 := Finset.card_le_card hc + have h2 := Finset.card_union_le ((G∪V)∪S) T + have h3 := Finset.card_union_le (G∪V) S + have h4 := Finset.card_union_le G V + have h5 := Finset.card_biUnion_le (s:=Finset.univ) (t:=endpointHoleBad H η e) + have h6 := Finset.card_biUnion_le (s:=Finset.univ) (t:=endpointParticleBad η e) + simp only [Finset.card_univ,Fintype.card_fin] at h1 + dsimp [G,V,S,T] at h1 h2 h3 h4 + omega + +lemma few_good_implies_bad (η : ℝ) (e : Fin k → GridSlot bits × GridSlot bits) + (wv wl : ℕ) (hb : 2*(wv-1+2*b*(wl-1))≤k) + (hg : 2*(endpointGoodSet H η e).card by have := (hn.2 j).1; omega) + _ = _ := by simp + have ht : (∑j, (endpointParticleBad η e j).card)≤b*(wl-1) := by + calc + _ ≤ ∑j : Fin b, (wl-1) := Finset.sum_le_sum (fun j _ => by have := (hn.2 j).2; omega) + _ = _ := by simp + have hc := endpointGood_cover H η e + have hm : 2*b*(wl-1)=b*(wl-1)+b*(wl-1) := by ring + omega + +lemma few_good_probability_bound {η : ℝ} (hη : 0<η) (wv wl : ℕ) + (hb : 2*(wv-1+2*b*(wl-1))≤k) + (hv : ((k+h:ℕ):ℝ)*((b+1:ℝ)/gridSize bits)≤1) + (hh : 2*h/((gridSize bits:ℝ)*η)≤1) (hk : 2*k/((gridSize bits:ℝ)*η)≤1) : + productProbability uniformWeight (fun e : Fin k → GridSlot bits × GridSlot bits => + 2*(endpointGoodSet H η e).card few_good_implies_bad H η e wv wl hb he) + have h2 := productProbability_or_le uniformWeight uniformWeight_nonneg V (fun e => ∃j, B j e) + have h3 := productProbability_union_le uniformWeight_nonneg B + have h4 : productProbability uniformWeight V≤ + (2:ℝ)^k*(((k+h:ℕ):ℝ)*((b+1:ℝ)/gridSize bits))^((wv+1)/2) := + independent_trajectory_sharing (fun a => (H.position 0 a,H.position (Fin.last b) a)) wv hv + have h5 : ∀j, productProbability uniformWeight (B j)≤ + (2:ℝ)^k*(2*h/((gridSize bits:ℝ)*η))^wl + + (Fintype.card (GridOutside bits j)+1:ℕ)^⌊2*(k:ℝ)/((2^bits j:ℕ)*η)⌋₊ * + (2:ℝ)^k*(2*k/((gridSize bits:ℝ)*η))^wl := by + intro j + exact (productProbability_or_le uniformWeight uniformWeight_nonneg _ _).trans + (add_le_add (holeHeavy_occupancy_bound H j hη hh wl) (particleHeavy_occupancy_bound j hη hk wl)) + exact h1.trans (h2.trans (add_le_add h4 (h3.trans (Finset.sum_le_sum (fun j _ => h5 j))))) + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +attribute [local instance] Classical.propDecidable +variable {P Ω : Type*} [Fintype P] [Fintype Ω] + +lemma sum_square_le_uniform_split (f : P → Ω) (hi : Function.Injective f) + (Q : Ω → ℝ) (E : Ω → Prop) (a C B : ℝ) (ha : 0 ?_)).trans + (sum_injective_le f hi (fun u => C^2+if E u then B^2 else 0) + (fun u => by split_ifs <;> positivity)) + by_cases hE : E (f i) + · rw [ite_eq_left hE,← mul_pow] + have hs := pow_le_pow_left₀ (abs_nonneg _) (hb i) 2 + rw [sq_abs] at hs + linarith [sq_nonneg C] + · rw [ite_eq_right hE,add_zero,← mul_pow] + simpa only [sq_abs] using pow_le_pow_left₀ (abs_nonneg _) (hc i hE) 2 + have he : (∑u : Ω, (C^2+if E u then B^2 else 0)) = + (Fintype.card Ω:ℝ)*(C^2+B^2*finiteProbability uniformWeight E) := by + rw [Finset.sum_add_distrib,Finset.sum_const,nsmul_eq_mul,mul_add,mul_left_comm _ (B^2),hp,Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro u _ + split_ifs <;> simp + rw [he,hN] at hle + exact (mul_le_mul_iff_right₀ (sq_pos_of_pos ha)).mp hle + +end BinaryCoordinateSweeps.Sparse +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +variable {b h k r : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +theorem centeredEndpointKernel_few_hs (hd : ∀j, bits j≤2*r) {η : ℝ} + (hη : 0<η) (hη1 : η≤1/4) (hηb : 4*(b:ℝ)*Real.sqrt η≤1) + (wv wl : ℕ) (ht : 2*(wv-1+2*b*(wl-1))≤k) + (hv : ((k+h:ℕ):ℝ)*((b+1:ℝ)/gridSize bits)≤1) + (hh : 2*h/((gridSize bits:ℝ)*η)≤1) (hk : 2*k/((gridSize bits:ℝ)*η)≤1) : + (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H 0 (fun i => ((x i).val,(y i).val)))^2) ≤ + ((2:ℝ)^(k+k*b)*Real.exp ((b*h+k+k*b:ℕ):ℝ)*(4*b*Real.sqrt η)^((k+1)/2))^2 + + ((2:ℝ)^k*Real.exp ((b:ℝ)*(h+k)+Real.log 4*k*b))^2 * + ((2:ℝ)^k*(((k+h:ℕ):ℝ)*((b+1:ℝ)/gridSize bits))^((wv+1)/2) + + ∑j : Fin b, ((2:ℝ)^k*(2*h/((gridSize bits:ℝ)*η))^wl + + (Fintype.card (GridOutside bits j)+1:ℕ)^⌊2*(k:ℝ)/((2^bits j:ℕ)*η)⌋₊ * + (2:ℝ)^k*(2*k/((gridSize bits:ℝ)*η))^wl)) := by + let f := placementEndpointArray (k:=k) H + let E (e : Fin k → GridSlot bits × GridSlot bits) := 2*(endpointGoodSet H η e).card ?_) (fun xy => centeredEndpointKernel_amplitude H hd (le_refl 0) + (linePerturbationRadius_pos r).le (by norm_num) xy.1 xy.2) + · rw [← productProbability_uniform] at he + have hp := few_good_probability_bound H hη wv wl ht hv hh hk + have heq : (∑x : Placement H k 0, ∑y : Placement H k (Fin.last b), + (centeredEndpointKernel H 0 (fun i => ((x i).val,(y i).val)))^2) = + ∑xy : Placement H k 0 × Placement H k (Fin.last b), + (centeredEndpointKernel H 0 (f xy))^2 := by + rw [Fintype.sum_prod_type] + rfl + rw [heq] + exact he.trans (add_le_add (le_refl _) (mul_le_mul_of_nonneg_left hp (sq_nonneg _))) + · have hi : ∀i∈endpointGoodSet H η (f xy), vertexIsolated H (f xy) i := by + intro i hi + exact vertexIsolated_of_not_incident H (f xy) i (Finset.mem_filter.mp hi).2.1 + have hl := fun i (hi : i∈endpointGoodSet H η (f xy)) => (Finset.mem_filter.mp hi).2.2 + have hh := centeredEndpointKernel_good_bound H xy.1 xy.2 (endpointGoodSet H η (f xy)) hη.le hη1 hi hl + apply hh.trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply pow_le_pow_of_le_one (by positivity) hηb + dsimp [E] at hE + omega + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointOccupancy.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointOccupancy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a63c948cc0d4813f4860a5a0baef32d3b22a2236 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointOccupancy.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.EndpointEntryBound +import OAI.Probability.BinarySweep.Trajectories.SparseOccupancy + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma card_gridOutside_mul (j : Fin b) : + Fintype.card (GridOutside bits j)*2^bits j=gridSize bits := by + have he := Fintype.card_congr (Equiv.piSplitAt j (fun i : Fin b => Slot (bits i))) + simpa only [Fintype.card_prod,card_gridSlot,Slot,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin,Nat.mul_comm] using he.symm + +lemma sum_endpointLineCount (e : Fin k → GridSlot bits × GridSlot bits) (j : Fin b) : + ∑y, endpointLineCount Finset.univ e j y=k := by + have he := Fintype.card_congr (Equiv.sigmaFiberEquiv + (fun i : ↥(Finset.univ : Finset (Fin k)) => endpointLine (e i) j)) + simpa only [Fintype.card_sigma,Fintype.card_coe,Finset.card_univ,Fintype.card_fin, + endpointLineCount] using he + +lemma heavy_count {L : Type*} [Fintype L] (f : L → ℕ) (τ : ℝ) : + τ*(Finset.univ.filter (fun l => τ<(f l:ℝ))).card ≤ ∑l, (f l:ℝ) := by + let S := Finset.univ.filter (fun l => τ<(f l:ℝ)) + calc + _ = ∑l∈S, τ := by simp [S,mul_comm] + _ ≤ ∑l∈S, (f l:ℝ) := Finset.sum_le_sum (fun l hl => (Finset.mem_filter.mp hl).2.le) + _ ≤ ∑l, (f l:ℝ) := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (by intros; positivity) + +def holeHeavyLines (j : Fin b) (η : ℝ) : Finset (GridOutside bits j) := + Finset.univ.filter (fun l => (2^bits j:ℕ)*η/2<(lineHoles H j l:ℝ)) + +def particleHeavyLines (e : Fin k → GridSlot bits × GridSlot bits) (j : Fin b) (η : ℝ) : + Finset (GridOutside bits j) := + Finset.univ.filter (fun l => (2^bits j:ℕ)*η/2<(endpointLineCount Finset.univ e j l:ℝ)) + +lemma holeHeavy_card (j : Fin b) {η : ℝ} (hη : 0<η) : + ((holeHeavyLines H j η).card:ℝ) ≤ 2*h/((2^bits j:ℕ)*η) := by + have hh := heavy_count (lineHoles H j) ((2^bits j:ℕ)*η/2) + rw [← Nat.cast_sum,sum_lineHoles] at hh + apply (le_div_iff₀ (by positivity)).mpr + change (2^bits j:ℕ)*η/2*(holeHeavyLines H j η).card≤(h:ℝ) at hh + nlinarith + +lemma particleHeavy_card (e : Fin k → GridSlot bits × GridSlot bits) (j : Fin b) + {η : ℝ} (hη : 0<η) : + (particleHeavyLines e j η).card ≤ ⌊2*(k:ℝ)/((2^bits j:ℕ)*η)⌋₊ := by + apply Nat.le_floor + have hh := heavy_count (endpointLineCount Finset.univ e j) ((2^bits j:ℕ)*η/2) + rw [← Nat.cast_sum,sum_endpointLineCount] at hh + apply (le_div_iff₀ (by positivity)).mpr + change (2^bits j:ℕ)*η/2*(particleHeavyLines e j η).card≤(k:ℝ) at hh + nlinarith + +lemma endpoint_not_light (e : Fin k → GridSlot bits × GridSlot bits) + (j : Fin b) (l : GridOutside bits j) (η : ℝ) + (hn : ¬endpointLight H η e ⟨j,l⟩) : + l∈holeHeavyLines H j η ∨ l∈particleHeavyLines e j η := by + simp only [holeHeavyLines,particleHeavyLines,Finset.mem_filter,Finset.mem_univ,true_and] + change ¬((lineHoles H j l:ℝ)+endpointLineCount Finset.univ e j l≤(2^bits j:ℕ)*η) at hn + push Not at hn + rcases lt_or_ge ((2^bits j:ℕ)*η/2) (lineHoles H j l:ℝ) with hh | hh + · exact Or.inl hh + · exact Or.inr (by linarith) + +lemma endpoint_line_set_mass (j : Fin b) (S : Finset (GridOutside bits j)) : + finiteProbability uniformWeight (fun z : GridSlot bits × GridSlot bits => endpointLine z j∈S)= + (S.card:ℝ)*(2^bits j:ℕ)/gridSize bits := by + change finiteProbability uniformWeight (fun z : GridSlot bits × GridSlot bits => + (fun i : {i : Fin b // i≠j} => independentPosition z j.castSucc i)∈S)=_ + rw [independent_line_set_uniform] + have he : (Fintype.card (GridOutside bits j):ℝ)*(2^bits j:ℕ)=gridSize bits := by + exact_mod_cast card_gridOutside_mul j + have hs : (gridSize bits:ℝ)≠0 := by exact_mod_cast (gridSize_pos bits).ne' + have hm : ((2^bits j:ℕ):ℝ)≠0 := by positivity + rw [← he] + field_simp + +lemma holeHeavy_mass (j : Fin b) {η : ℝ} (hη : 0<η) : + finiteProbability uniformWeight (fun z : GridSlot bits × GridSlot bits => + endpointLine z j∈holeHeavyLines H j η) ≤ 2*h/((gridSize bits:ℝ)*η) := by + rw [endpoint_line_set_mass] + have hh := holeHeavy_card H j hη + have hs : (0:ℝ) endpointLine z j∈S) ≤ + 2*k/((gridSize bits:ℝ)*η) := by + rw [endpoint_line_set_mass] + have hnon : 0≤2*(k:ℝ)/((2^bits j:ℕ)*η) := by positivity + have hh : (S.card:ℝ)≤2*(k:ℝ)/((2^bits j:ℕ)*η) := + (Nat.cast_le.mpr hS).trans (Nat.floor_le hnon) + have hs : (0:ℝ) + w ≤ (Finset.univ.filter (fun i => endpointLine (e i) j∈holeHeavyLines H j η)).card) ≤ + (2:ℝ)^k*(2*h/((gridSize bits:ℝ)*η))^w := by + have he := occupancy_probability_le (I:=Fin k) uniformWeight uniformWeight_nonneg uniformWeight_sum + (fun z : GridSlot bits × GridSlot bits => endpointLine z j∈holeHeavyLines H j η) _ + (by positivity) hsmall (holeHeavy_mass H j hη) w + simp only [Fintype.card_fin] at he + convert he using 1 + congr 1 + funext e + congr 1 + congr 1 + ext i + simp only [Finset.mem_filter,Finset.mem_univ,true_and] + +lemma particleHeavy_occupancy_bound (j : Fin b) {η : ℝ} (hη : 0<η) + (hsmall : 2*k/((gridSize bits:ℝ)*η)≤1) (w : ℕ) : + productProbability uniformWeight (fun e : Fin k → GridSlot bits × GridSlot bits => + w ≤ (Finset.univ.filter (fun i => endpointLine (e i) j∈particleHeavyLines e j η)).card) ≤ + (Fintype.card (GridOutside bits j)+1:ℕ)^⌊2*(k:ℝ)/((2^bits j:ℕ)*η)⌋₊ * + (2:ℝ)^k*(2*k/((gridSize bits:ℝ)*η))^w := by + have hb := line_sets_occupancy_probability_le (I:=Fin k) uniformWeight uniformWeight_nonneg uniformWeight_sum + (fun z : GridSlot bits × GridSlot bits => endpointLine z j) _ w _ (by positivity) + hsmall (small_lines_mass j hη) + apply le_trans (b:=productProbability uniformWeight (fun e : Fin k → GridSlot bits × GridSlot bits => + ∃S : Finset (GridOutside bits j), S.card≤⌊2*(k:ℝ)/((2^bits j:ℕ)*η)⌋₊ ∧ + w≤(Finset.univ.filter (fun i => endpointLine (e i) j∈S)).card)) + · exact productProbability_mono uniformWeight_nonneg (fun e he => + ⟨particleHeavyLines e j η,particleHeavy_card e j hη,he⟩) + · simpa only [Fintype.card_fin] using hb + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointPlacement.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointPlacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf98c75397881a354ef57a9eb462d52598ae048e --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointPlacement.lean @@ -0,0 +1,86 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.SumDite +import OAI.Probability.BinarySweep.Trajectories.IsolatedCancellation + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +def restrictPlacement {t : Fin (b+1)} (x : Placement H k t) (A : Finset (Fin k)) : + Placement H (Fintype.card A) t where + toFun i := x ((Fintype.equivFin A).symm i).val + inj' _ _ he := (Fintype.equivFin A).symm.injective + (Subtype.ext (x.injective he)) + +lemma restrictPlacement_event (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (A : Finset (Fin k)) (g : ConditionalChoices H) : + placementBijection H (Fintype.card A) g (restrictPlacement H x A)=restrictPlacement H y A ↔ + ∀i ∈ A, gridSweep bits g.val (x i).val=(y i).val := by + constructor + · intro he i hi + have hh := congrArg (fun q => (q (Fintype.equivFin A ⟨i,hi⟩)).val) he + change gridSweep bits g.val (x ((Fintype.equivFin A).symm + (Fintype.equivFin A ⟨i,hi⟩)).val).val = + (y ((Fintype.equivFin A).symm (Fintype.equivFin A ⟨i,hi⟩)).val).val at hh + simpa only [Equiv.symm_apply_apply] using hh + · intro he + apply Function.Embedding.ext + intro i + apply Subtype.ext + exact he _ ((Fintype.equivFin A).symm i).property + +lemma endpointProbability_conditional {I : Type*} [Fintype I] [DecidableEq I] + (z : ℝ) (A : Finset I) (e : I → GridSlot bits × GridSlot bits) : + endpointProbability H z A e = + conditionalEventWeight H z (fun g => ∀i ∈ A, gridSweep bits g (e i).1=(e i).2) := by + unfold endpointProbability endpointMass conditionalEventWeight conditionalChoiceWeight + have hh (g : ConditionalChoices H) : + (if ∀i ∈ A, gridSweep bits g.val (e i).1=(e i).2 then + gridWeight bits z g.val / conditionalNormalizer H z else 0) = + (if ∀i ∈ A, gridSweep bits g.val (e i).1=(e i).2 then gridWeight bits z g.val else 0) / + conditionalNormalizer H z := by split_ifs <;> simp + have hR : (∑g : ConditionalChoices H, + if ∀i ∈ A, gridSweep bits g.val (e i).1=(e i).2 then + gridWeight bits z g.val / conditionalNormalizer H z else 0) = + (∑g : ConditionalChoices H, if ∀i ∈ A, gridSweep bits g.val (e i).1=(e i).2 then + gridWeight bits z g.val else 0) / conditionalNormalizer H z := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro g _ + exact hh g + refine Eq.trans ?_ (Eq.trans hR.symm ?_) + · congr 1 + have hs := sum_dite_zero (pathEvent H) (fun g _ => + if ∀i ∈ A, gridSweep bits g (e i).1=(e i).2 then gridWeight bits z g else 0) + refine Eq.trans ?_ (hs.trans ?_) + · apply Finset.sum_congr rfl + intro g _ + split_ifs <;> simp_all + · apply Finset.sum_congr (by ext sample; simp) + intro g _ + rfl + · apply Finset.sum_congr rfl + intro g _ + split_ifs <;> rfl + +theorem endpointProbability_placement (z : ℝ) + (x : Placement H k 0) (y : Placement H k (Fin.last b)) (A : Finset (Fin k)) : + endpointProbability H z A (fun i => ((x i).val,(y i).val)) = + placementProbability H z (restrictPlacement H x A) (restrictPlacement H y A) := by + rw [endpointProbability_conditional] + unfold conditionalEventWeight placementProbability + apply Finset.sum_congr rfl + intro g _ + simp only [restrictPlacement_event] + split_ifs <;> rfl + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/EndpointValidity.lean b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointValidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..f35b297c7aa11c579f3d44e3afab3311395bf758 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/EndpointValidity.lean @@ -0,0 +1,126 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.EndpointEvents + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +variable {b h : ℕ} {bits : Fin b → ℕ} + +lemma gridPartialSweep_endpoint (g : GridChoices bits) (e : GridSlot bits × GridSlot bits) + (he : gridSweep bits g e.1=e.2) (t : Fin (b+1)) : + gridPartialSweep bits g t e.1=independentPosition e t := by + have hh := independentPosition_of_path (fun t => gridPartialSweep bits g t e.1) + (gridPartialSweep_changes bits g e.1) t + simpa only [gridPartialSweep_zero,Equiv.Perm.one_apply,gridPartialSweep_last,he] using hh.symm + +lemma path_completion_finite {L : Type*} [Fintype L] + (pos : Fin (b+1) → L → GridSlot bits) (hi : ∀t, Function.Injective (pos t)) + (hc : ∀j l i, i≠j → pos j.succ l i=pos j.castSucc l i) : + ∃g : GridChoices bits, ∀j l, gridLayer bits g j (pos j.castSucc l)=pos j.succ l := by + let K : PathFamily bits (Fintype.card L) := + {position := fun t i => pos t ((Fintype.equivFin L).symm i) + disjoint := fun t => (hi t).comp (Fintype.equivFin L).symm.injective + changes_only_stage := fun j k i h => hc j _ i h} + obtain ⟨g,hg⟩ := pathEvent_nonempty K + refine ⟨g,fun j l => ?_⟩ + have hh := hg j (Fintype.equivFin L l) + change gridLayer bits g j (pos j.castSucc ((Fintype.equivFin L).symm + (Fintype.equivFin L l)))=pos j.succ ((Fintype.equivFin L).symm (Fintype.equivFin L l)) at hh + simpa only [Equiv.symm_apply_apply] using hh + +variable {I : Type*} [Fintype I] [DecidableEq I] (H : PathFamily bits h) + +def EndpointValid (A : Finset I) (e : I → GridSlot bits × GridSlot bits) : Prop := + (∀t, ∀i∈A, ∀a∈A, independentPosition (e i) t=independentPosition (e a) t → i=a) ∧ + (∀t, ∀i∈A, ∀k, independentPosition (e i) t≠H.position t k) + +omit [Fintype I] [DecidableEq I] in +lemma endpointValid_mono {A B : Finset I} {e : I → GridSlot bits × GridSlot bits} + (hAB : A⊆B) (he : EndpointValid H B e) : EndpointValid H A e := + ⟨fun t i hi a ha => he.1 t i (hAB hi) a (hAB ha), + fun t i hi k => he.2 t i (hAB hi) k⟩ + +omit [Fintype I] [DecidableEq I] in +lemma endpointValid_completion (A : Finset I) (e : I → GridSlot bits × GridSlot bits) + (he : EndpointValid H A e) : + ∃g : GridChoices bits, pathEvent H g ∧ ∀i∈A, gridSweep bits g (e i).1=(e i).2 := by + let pos (t : Fin (b+1)) : Fin h ⊕ A → GridSlot bits := + Sum.elim (H.position t) (fun i => independentPosition (e i) t) + have hi (t) : Function.Injective (pos t) := by + apply (H.disjoint t).sumElim + · intro i a hh + exact Subtype.ext (he.1 t i i.property a a.property hh) + · intro k i hh + exact he.2 t i i.property k hh.symm + have hc (j : Fin b) (l : Fin h ⊕ A) (i : Fin b) (hij : i≠j) : + pos j.succ l i=pos j.castSucc l i := by + cases l with + | inl k => exact H.changes_only_stage j k i hij + | inr a => exact independentPosition_changes (e a) j i hij + obtain ⟨g,hg⟩ := path_completion_finite pos hi hc + refine ⟨g,fun j k => hg j (.inl k),?_⟩ + intro i hi + apply (gridSweep_endpoint_iff g (e i)).mpr + intro j + exact (endpoint_gridLayer_iff g (e i) j).mp (hg j (.inr ⟨i,hi⟩)) + +lemma endpointValid_of_placement_event {k : ℕ} (x : Placement H k 0) + (y : Placement H k (Fin.last b)) (A : Finset (Fin k)) + (g : ConditionalChoices H) (he : ∀i∈A, gridSweep bits g.val (x i).val=(y i).val) : + EndpointValid H A (fun i => ((x i).val,(y i).val)) := by + constructor + · intro t i hi a ha hp + rw [← gridPartialSweep_endpoint g.val _ (he i hi), + ← gridPartialSweep_endpoint g.val _ (he a ha)] at hp + exact x.injective (Subtype.ext ((gridPartialSweep bits g.val t).injective hp)) + · intro t i hi k hp + rw [← gridPartialSweep_endpoint g.val _ (he i hi), + ← gridPartialSweep_path H g.val g.property] at hp + exact (x i).property ⟨k,((gridPartialSweep bits g.val t).injective hp).symm⟩ + +lemma endpointValid_placement_iff {k : ℕ} (x : Placement H k 0) + (y : Placement H k (Fin.last b)) (A : Finset (Fin k)) : + EndpointValid H A (fun i => ((x i).val,(y i).val)) ↔ + ∃g : ConditionalChoices H, ∀i∈A, gridSweep bits g.val (x i).val=(y i).val := by + constructor + · intro he + obtain ⟨g,hg,hp⟩ := endpointValid_completion H A _ he + exact ⟨⟨g,hg⟩,hp⟩ + · rintro ⟨g,hg⟩ + exact endpointValid_of_placement_event H x y A g hg + +omit [Fintype I] in +lemma endpointValid_insert (A : Finset I) (e : I → GridSlot bits × GridSlot bits) (i : I) + (hh : ∀t k, independentPosition (e i) t≠H.position t k) + (ha : ∀t a, a≠i → independentPosition (e a) t≠independentPosition (e i) t) : + EndpointValid H (insert i A) e ↔ EndpointValid H A e := by + constructor + · exact endpointValid_mono H (Finset.subset_insert _ _) + · rintro ⟨hp,hq⟩ + constructor + · intro t a hA c hC hac + rcases Finset.mem_insert.mp hA with rfl | hA + · rcases Finset.mem_insert.mp hC with rfl | hC + · rfl + · by_contra hne + exact ha t c (Ne.symm hne) hac.symm + · rcases Finset.mem_insert.mp hC with rfl | hC + · by_contra hne + exact ha t a hne hac + · exact hp t a hA c hC hac + · intro t a hA k + rcases Finset.mem_insert.mp hA with rfl | hA + · exact hh t k + · exact hq t a hA k + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/FallingMoment.lean b/lean/OAI/Probability/BinarySweep/Trajectories/FallingMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..b52bd74c41091409f0a5cc41521931c14eeac037 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/FallingMoment.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.Trajectory + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +open Polynomial + +def fallingMoment (m h n : ℕ) : ℝ := (m:ℝ)^n / ((m-h).descFactorial n : ℝ) + +@[simp] lemma fallingMoment_zero (m h : ℕ) : fallingMoment m h 0 = 1 := by + simp [fallingMoment] + +lemma fallingMoment_pos {m h n : ℕ} (hm : 0 < m) (hn : h+n ≤ m) : + 0 < fallingMoment m h n := by + apply div_pos (pow_pos (Nat.cast_pos.mpr hm) _) + exact Nat.cast_pos.mpr (Nat.descFactorial_pos.mpr (by omega)) + +lemma fallingMoment_succ {m h n : ℕ} (hn : h+n < m) : + ((m:ℝ)-h-n) * fallingMoment m h (n+1) = m * fallingMoment m h n := by + have hh : h ≤ m := by omega + have hi : n ≤ m-h := by omega + have hd : ((m-h).descFactorial n : ℝ) ≠ 0 := + ne_of_gt (Nat.cast_pos.mpr (Nat.descFactorial_pos.mpr hi)) + have hc : ((m:ℝ)-h-n) ≠ 0 := by + have hh' : (h:ℝ)+n < m := by exact_mod_cast hn + exact ne_of_gt (by linarith) + simp only [fallingMoment,Nat.descFactorial_succ,Nat.cast_mul,Nat.cast_sub hh, + Nat.cast_sub hi,pow_succ] + field_simp + +def lineMoment (m h : ℕ) : ℝ[X] →ₗ[ℝ] ℝ := + Polynomial.lsum (fun n => (fallingMoment m h n) • LinearMap.id) + +lemma lineMoment_monomial (m h n : ℕ) (c : ℝ) : + lineMoment m h (monomial n c) = c * fallingMoment m h n := by + simp [lineMoment,Polynomial.lsum_apply,Polynomial.sum_monomial_index,mul_comm] + +lemma lineMoment_X_pow (m h n : ℕ) : + lineMoment m h (X^n) = fallingMoment m h n := by + simpa only [one_mul,monomial_one_right_eq_X_pow] using lineMoment_monomial m h n 1 + +def stein (m h : ℕ) : ℝ[X] →ₗ[ℝ] ℝ[X] := + (LinearMap.mulLeft ℝ (C ((m:ℝ)-h) * X)) - + (LinearMap.mulLeft ℝ (X^2)).comp (Polynomial.derivative) - + LinearMap.mulLeft ℝ (C (m:ℝ)) + +lemma stein_apply (m h : ℕ) (P : ℝ[X]) : + stein m h P = C ((m:ℝ)-h)*X*P - X^2*derivative P - C (m:ℝ)*P := rfl + +lemma lineMoment_stein_monomial {m h n : ℕ} (hn : h+n < m) (c : ℝ) : + lineMoment m h (stein m h (monomial n c)) = 0 := by + rw [stein_apply,mul_assoc,X_mul_monomial,C_mul_monomial,derivative_monomial, + X_pow_mul_monomial,C_mul_monomial] + simp only [LinearMap.map_sub,lineMoment_monomial] + have hh := fallingMoment_succ hn + cases n with + | zero => simp only [Nat.cast_zero,mul_zero,zero_mul,sub_zero] at *; linear_combination c * hh + | succ n => simp only [Nat.add_sub_cancel] at *; linear_combination c * hh + +end BinaryCoordinateSweeps.Sparse + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + +lemma lineLaw_zero (d : ℕ) (σ : Equiv.Perm (Slot d)) : + lineLaw d 0 σ = (Fintype.card (Equiv.Perm (Slot d)):ℝ)⁻¹ := by + simp only [lineLaw, sub_zero, one_mul, zero_mul, add_zero, uniformLaw] + +lemma assignmentWeight_uniform_of_eq {X I : Type*} [Fintype X] [Fintype I] + (p : Equiv.Perm X → ℝ) (hp : ∀σ, p σ=((Fintype.card X).factorial:ℝ)⁻¹) + (A B : I ↪ X) : + assignmentWeight p A B = ((Fintype.card X).descFactorial (Fintype.card I):ℝ)⁻¹ := by + have he : p = fun _ => (Fintype.card (Equiv.Perm X):ℝ)⁻¹ := by + funext σ + rw [hp] + simp only [Fintype.card_perm] + rw [he] + exact assignmentWeight_uniform A B + +lemma localPathWeight_zero (j : Fin b) (y : GridOutside bits j) : + localPathWeight H 0 j y = ((2^bits j).descFactorial (lineHoles H j y):ℝ)⁻¹ := by + have hp (σ : Equiv.Perm (Slot (bits j))) : + lineLaw (bits j) 0 σ=((Fintype.card (Slot (bits j))).factorial:ℝ)⁻¹ := by + rw [lineLaw_zero] + simp only [Fintype.card_perm] + have hw := assignmentWeight_uniform_of_eq _ hp (lineInput H j y) (lineOutput H j y) + have hc : Fintype.card (Slot (bits j))=2^bits j := by + simp only [Slot,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin] + have hh : Fintype.card (LinePaths H j y)=lineHoles H j y := by + unfold lineHoles LinePaths + congr! + rw [hc,hh] at hw + exact hw + +lemma card_fin_sum_pred {a c : ℕ} (P : Fin (a+c) → Prop) : + Fintype.card {i // P i} = Fintype.card {i : Fin a // P (i.castAdd c)} + + Fintype.card {i : Fin c // P (i.natAdd a)} := by + have he := Fintype.card_congr ((finSumFinEquiv.symm).subtypeEquiv + (p := P) (q := fun i : Fin a ⊕ Fin c => P (finSumFinEquiv i)) + (fun _ => by simp)) + change Fintype.card {i : Fin (a+c) // P i} = + Fintype.card {i : Fin a ⊕ Fin c // P (finSumFinEquiv i)} at he + rw [he,Fintype.card_congr (Equiv.subtypeSum (p := fun i : Fin a ⊕ Fin c => P (finSumFinEquiv i))), + Fintype.card_sum] + rfl + +def trackedLineCount (x : Placement H k 0) (g : ConditionalChoices H) + (j : Fin b) (y : GridOutside bits j) : ℕ := + Fintype.card {i : Fin k // (fun a : {a : Fin b // a≠j} => + gridPartialSweep bits g.val j.castSucc (x i).val a)=y} + +lemma lineHoles_augment (x : Placement H k 0) (g : ConditionalChoices H) + (j : Fin b) (y : GridOutside bits j) : + lineHoles (augmentByChoice H x g) j y = lineHoles H j y + trackedLineCount H x g j y := by + unfold lineHoles + have he := card_fin_sum_pred (fun i : Fin (h+k) => + (fun a : {a : Fin b // a≠j} => (augmentByChoice H x g).position j.castSucc i a)=y) + trans Fintype.card {i : Fin h // (fun a : {a : Fin b // a≠j} => + (augmentByChoice H x g).position j.castSucc (i.castAdd k) a)=y} + + Fintype.card {i : Fin k // (fun a : {a : Fin b // a≠j} => + (augmentByChoice H x g).position j.castSucc (i.natAdd h) a)=y} + · convert he using 1 <;> congr! + congr 1 + · apply Fintype.card_congr + apply Equiv.subtypeEquivRight + intro i + change (fun a : {a : Fin b // a≠j} => gridPartialSweep bits g.val j.castSucc + (Fin.append (H.position 0) (fun i => (x i).val) (i.castAdd k)) a)=y ↔ _ + rw [Fin.append_left,gridPartialSweep_path H g.val g.property] + · unfold trackedLineCount + apply Fintype.card_congr + apply Equiv.subtypeEquivRight + intro i + change (fun a : {a : Fin b // a≠j} => gridPartialSweep bits g.val j.castSucc + (Fin.append (H.position 0) (fun i => (x i).val) (i.natAdd h)) a)=y ↔ _ + rw [Fin.append_right] + +lemma uniform_extension_ratio {m a c : ℕ} (ha : a ≤ m) : + ((m.descFactorial (a+c):ℝ)⁻¹ / (m.descFactorial a:ℝ)⁻¹) = + ((m-a).descFactorial c:ℝ)⁻¹ := by + have he := Nat.descFactorial_mul_descFactorial (show a≤a+c by omega) (n:=m) + simp only [Nat.add_sub_cancel_left] at he + rw [← he,Nat.cast_mul,mul_inv_rev,div_inv_eq_mul] + have hn : (m.descFactorial a:ℝ)≠0 := by + exact_mod_cast (Nat.descFactorial_pos.mpr ha).ne' + field_simp + +theorem placementProbability_zero_factor (x : Placement H k 0) (g : ConditionalChoices H) : + placementProbability H 0 x (placementBijection H k g x) = + ∏j, ∏y : GridOutside bits j, + ((2^bits j-lineHoles H j y).descFactorial (trackedLineCount H x g j y):ℝ)⁻¹ := by + rw [placementProbability_augmentation,pathExtension_event_ratio (augmentByChoice_extension H x g), + conditionalNormalizer_eq_prod,conditionalNormalizer_eq_prod,← Finset.prod_div_distrib] + apply Finset.prod_congr rfl + intro j _ + rw [← Finset.prod_div_distrib] + apply Finset.prod_congr rfl + intro y _ + rw [localPathWeight_zero,localPathWeight_zero,lineHoles_augment] + exact uniform_extension_ratio (lineHoles_le H j y) + +lemma sum_trackedLineCount (x : Placement H k 0) (g : ConditionalChoices H) (j : Fin b) : + ∑y : GridOutside bits j, trackedLineCount H x g j y=k := by + have he := Fintype.card_sigma (α := fun y : GridOutside bits j => {i : Fin k // + (fun a : {a : Fin b // a≠j} => gridPartialSweep bits g.val j.castSucc (x i).val a)=y}) + unfold trackedLineCount + rw [← he] + trans Fintype.card (Fin k) + · exact Fintype.card_congr (Equiv.sigmaFiberEquiv (fun i : Fin k => + fun a : {a : Fin b // a≠j} => gridPartialSweep bits g.val j.castSucc (x i).val a)) + · exact Fintype.card_fin k + +theorem placementProbability_zero_scaled (x : Placement H k 0) (g : ConditionalChoices H) : + (gridSize bits:ℝ)^k * placementProbability H 0 x (placementBijection H k g x) = + ∏j, ∏y : GridOutside bits j, + Sparse.fallingMoment (2^bits j) (lineHoles H j y) (trackedLineCount H x g j y) := by + rw [placementProbability_zero_factor] + have he : (gridSize bits:ℝ)^k = ∏j, ∏y : GridOutside bits j, + ((2^bits j:ℕ):ℝ)^trackedLineCount H x g j y := by + simp_rw [Finset.prod_pow_eq_pow_sum,sum_trackedLineCount] + rw [Finset.prod_pow] + congr 1 + simp only [gridSize,Nat.cast_prod,Nat.cast_pow] + rw [he,← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro j _ + rw [← Finset.prod_mul_distrib] + rfl + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/IsolatedCancellation.lean b/lean/OAI/Probability/BinarySweep/Trajectories/IsolatedCancellation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5e98f5d85c8449afed4a21a0863801d365c8a36 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/IsolatedCancellation.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.EndpointEvents +import OAI.Probability.BinarySweep.FiniteLaws.OneCard + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable +variable {b h : ℕ} {bits : Fin b → ℕ} +variable {I : Type*} [DecidableEq I] + +omit [DecidableEq I] in +lemma localEndpointMass_empty_line (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) (j : Fin b) (y : GridOutside bits j) + (hh : ∀k, (fun i : {i : Fin b // i≠j} => H.position j.castSucc k i) ≠ y) + (ha : ∀i ∈ A, endpointLine (e i) j≠y) : + localEndpointMass H z A e j y=1 := by + unfold localEndpointMass + simp only [assigns_empty_line H j y hh,localEndpointEvent_empty_line A e j y ha, + and_self,ite_true,lineLaw_sum] + +lemma localEndpointMass_insert_at (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) (i : I) (j : Fin b) + (hh : ∀k, (fun a : {a : Fin b // a≠j} => H.position j.castSucc k a) ≠ endpointLine (e i) j) + (ha : ∀a ∈ A, endpointLine (e a) j≠endpointLine (e i) j) : + localEndpointMass H z (insert i A) e j (endpointLine (e i) j)= + (Fintype.card (Slot (bits j)):ℝ)⁻¹ := by + unfold localEndpointMass + simp only [assigns_empty_line H j _ hh,localEndpointEvent_insert, + localEndpointEvent_empty_line A e j _ ha,true_and,and_true, + forall_true_left] + exact line_one_card_ite (bits j) z ((e i).1 j) ((e i).2 j) + +lemma localEndpointMass_insert_other (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) (i : I) (j : Fin b) (y : GridOutside bits j) + (hy : y≠endpointLine (e i) j) : + localEndpointMass H z (insert i A) e j y=localEndpointMass H z A e j y := by + unfold localEndpointMass + apply Finset.sum_congr rfl + intro σ _ + simp only [localEndpointEvent_insert,Ne.symm hy,IsEmpty.forall_iff,true_and] + +lemma prod_one_coordinate {J : Type*} [Fintype J] [DecidableEq J] + (f g : J → ℝ) (j : J) (a : ℝ) (hf : f j=1) (hg : g j=a) + (he : ∀k, k≠j → g k=f k) : ∏k, g k=a*∏k, f k := by + calc + _ = ∏k, (if k=j then a else 1)*f k := by + apply Finset.prod_congr rfl + intro k _ + by_cases hk : k=j + · subst k; simp [hf,hg] + · simp [hk,he k hk] + _ = _ := by rw [Finset.prod_mul_distrib]; simp + +variable [Fintype I] + +lemma endpointMass_insert_isolated (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) (i : I) + (hh : ∀j k, (fun a : {a : Fin b // a≠j} => H.position j.castSucc k a) ≠ endpointLine (e i) j) + (ha : ∀j, ∀a ∈ A, endpointLine (e a) j≠endpointLine (e i) j) : + endpointMass H z (insert i A) e=(gridSize bits:ℝ)⁻¹ * endpointMass H z A e := by + rw [endpointMass_factor,endpointMass_factor] + have hj (j : Fin b) : (∏y, localEndpointMass H z (insert i A) e j y) = + (Fintype.card (Slot (bits j)):ℝ)⁻¹ * ∏y, localEndpointMass H z A e j y := by + exact prod_one_coordinate _ _ (endpointLine (e i) j) _ + (localEndpointMass_empty_line H z A e j _ (hh j) (ha j)) + (localEndpointMass_insert_at H z A e i j (hh j) (ha j)) + (fun y hy => localEndpointMass_insert_other H z A e i j y hy) + simp only [hj,Finset.prod_mul_distrib,Finset.prod_inv_distrib] + congr 2 + simp only [Slot,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin,Nat.cast_pow, + gridSize,Nat.cast_prod] + +def endpointProbability (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) : ℝ := endpointMass H z A e / conditionalNormalizer H z + +lemma endpointProbability_insert_isolated (H : PathFamily bits h) (z : ℝ) (A : Finset I) + (e : I → GridSlot bits × GridSlot bits) (i : I) + (hh : ∀j k, (fun a : {a : Fin b // a≠j} => H.position j.castSucc k a) ≠ endpointLine (e i) j) + (ha : ∀j, ∀a ∈ A, endpointLine (e a) j≠endpointLine (e i) j) : + endpointProbability H z (insert i A) e=(gridSize bits:ℝ)⁻¹ * endpointProbability H z A e := by + unfold endpointProbability + rw [endpointMass_insert_isolated H z A e i hh ha,mul_div_assoc] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/PathExtension.lean b/lean/OAI/Probability/BinarySweep/Trajectories/PathExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..2650fea4d3bbc9ef5cf56db15cc6609f5b3efa5a --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/PathExtension.lean @@ -0,0 +1,198 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.Placement + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +structure PathExtension {b h h' : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (H' : PathFamily bits h') where + labels : Fin h ↪ Fin h' + position_eq : ∀ t i, H'.position t (labels i) = H.position t i + +namespace PathExtension +variable {b h h' : ℕ} {bits : Fin b → ℕ} + {H : PathFamily bits h} {H' : PathFamily bits h'} + +def lineEmbedding (E : PathExtension H H') (j : Fin b) (y : GridOutside bits j) : + LinePaths H j y ↪ LinePaths H' j y where + toFun i := ⟨E.labels i.val, by + change (fun a : {a : Fin b // a ≠ j} => H'.position j.castSucc (E.labels i.val) a) = y + rw [E.position_eq] + exact i.property⟩ + inj' i k hik := Subtype.ext (E.labels.injective (congrArg Subtype.val hik)) + +lemma lineInput_eq (E : PathExtension H H') (j : Fin b) (y : GridOutside bits j) + (i : LinePaths H j y) : + lineInput H' j y (E.lineEmbedding j y i) = lineInput H j y i := by + change H'.position j.castSucc (E.labels i.val) j = H.position j.castSucc i.val j + rw [E.position_eq] + +lemma lineOutput_eq (E : PathExtension H H') (j : Fin b) (y : GridOutside bits j) + (i : LinePaths H j y) : + lineOutput H' j y (E.lineEmbedding j y i) = lineOutput H j y i := by + change H'.position j.succ (E.labels i.val) j = H.position j.succ i.val j + rw [E.position_eq] + +lemma pathEvent_mono (E : PathExtension H H') {g : GridChoices bits} + (hg : pathEvent H' g) : pathEvent H g := by + intro j i + simpa only [E.position_eq] using hg j (E.labels i) + +lemma card_le (E : PathExtension H H') : h ≤ h' := by + simpa only [Fintype.card_fin] using Fintype.card_le_of_injective E.labels E.labels.injective + +end PathExtension + +lemma localPathWeight_pos_comparison {b h r : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) + (j : Fin b) (y : GridOutside bits j) : 0 < localPathWeight H z j y := by + unfold localPathWeight + have hw := @assignmentWeight_comparison (Slot (bits j)) (LinePaths H j y) _ _ + (lineLaw (bits j) z) ?_ ?_ (lineInput H j y) (lineOutput H j y) + · have hm : 0 < (Nat.descFactorial (Fintype.card (Slot (bits j))) + (Fintype.card (LinePaths H j y)) : ℝ) := by + exact_mod_cast Nat.descFactorial_pos.mpr + (Fintype.card_le_of_injective (lineInput H j y) (lineInput H j y).injective) + exact lt_of_lt_of_le (by positivity) hw.1 + · intro σ + simpa only [uniformLaw, Fintype.card_perm] using + (lineLaw_comparison r (bits j) (hd j) hz hzr σ).1 + · intro σ + simpa only [uniformLaw, Fintype.card_perm] using + (lineLaw_comparison r (bits j) (hd j) hz hzr σ).2 + +lemma lineExtension_log_bound {b h h' r : ℕ} {bits : Fin b → ℕ} + {H : PathFamily bits h} {H' : PathFamily bits h'} (E : PathExtension H H') + (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) + (j : Fin b) (y : GridOutside bits j) : + Real.log (localPathWeight H' z j y / localPathWeight H z j y) ≤ + fallingCost (2^bits j) (lineHoles H' j y) - fallingCost (2^bits j) (lineHoles H j y) - + ((lineHoles H' j y : ℝ) - lineHoles H j y) * Real.log (2^bits j : ℕ) + + Real.log 4 * ((lineHoles H' j y : ℝ) - lineHoles H j y) := by + have he := @assignmentWeight_log_ratio_le (Slot (bits j)) (LinePaths H j y) + (LinePaths H' j y) _ _ _ Fintype.card_pos (lineLaw (bits j) z) + ?_ ?_ (lineInput H j y) (lineOutput H j y) (lineInput H' j y) (lineOutput H' j y) + (E.lineEmbedding j y) (E.lineInput_eq j y) (E.lineOutput_eq j y) + · simpa only [localPathWeight, lineHoles, Slot, Fintype.card_fun, Fintype.card_fin, + Fintype.card_bool] using he + · intro σ + simpa only [uniformLaw, Fintype.card_perm] using + (lineLaw_comparison r (bits j) (hd j) hz hzr σ).1 + · intro σ + simpa only [uniformLaw, Fintype.card_perm] using + (lineLaw_comparison r (bits j) (hd j) hz hzr σ).2 + +lemma log_gridSize {b : ℕ} (bits : Fin b → ℕ) : + Real.log (gridSize bits : ℝ) = ∑ j, Real.log (2^bits j : ℕ) := by + unfold gridSize + rw [Nat.cast_prod, Real.log_prod] + intro j _ + positivity + +lemma sum_lineHoles_sub {b h h' : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (H' : PathFamily bits h') (j : Fin b) : + ∑ y : GridOutside bits j, ((lineHoles H' j y : ℝ) - lineHoles H j y) = (h' : ℝ) - h := by + rw [Finset.sum_sub_distrib, ← Nat.cast_sum, ← Nat.cast_sum, sum_lineHoles, sum_lineHoles] + +lemma pathCost_eq_sum {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) : + pathCost H = ∑ j, ∑ y, fallingCost (2^bits j) (lineHoles H j y) := rfl + +theorem pathExtension_log_ratio {b h h' r : ℕ} {bits : Fin b → ℕ} + {H : PathFamily bits h} {H' : PathFamily bits h'} (E : PathExtension H H') + (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) : + Real.log (conditionalNormalizer H' z / conditionalNormalizer H z) ≤ + pathCost H' - pathCost H - ((h' : ℝ) - h) * Real.log (gridSize bits) + + Real.log 4 * ((h' : ℝ) - h) * b := by + have hposH := localPathWeight_pos_comparison H hd hz hzr + have hposH' := localPathWeight_pos_comparison H' hd hz hzr + rw [conditionalNormalizer_eq_prod, conditionalNormalizer_eq_prod] + rw [← Finset.prod_div_distrib] + simp_rw [← Finset.prod_div_distrib] + rw [Real.log_prod (fun j _ => Finset.prod_ne_zero_iff.mpr (fun y _ => + (div_pos (hposH' j y) (hposH j y)).ne'))] + simp_rw [Real.log_prod (fun y _ => (div_pos (hposH' _ y) (hposH _ y)).ne')] + calc + _ ≤ ∑ j, ∑ y, + (fallingCost (2^bits j) (lineHoles H' j y) - fallingCost (2^bits j) (lineHoles H j y) - + ((lineHoles H' j y : ℝ) - lineHoles H j y) * Real.log (2^bits j : ℕ) + + Real.log 4 * ((lineHoles H' j y : ℝ) - lineHoles H j y)) := by + apply Finset.sum_le_sum + intro j _ + exact Finset.sum_le_sum (fun y _ => lineExtension_log_bound E hd hz hzr j y) + _ = _ := by + simp_rw [Finset.sum_add_distrib, Finset.sum_sub_distrib, + ← Finset.sum_mul, ← Finset.mul_sum] + simp_rw [sum_lineHoles_sub] + rw [pathCost_eq_sum, pathCost_eq_sum, log_gridSize] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + rw [← Finset.mul_sum] + ring + +def conditionalEventWeight {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (z : ℝ) (P : GridChoices bits → Prop) : ℝ := + ∑ g : ConditionalChoices H, if P g.val then conditionalChoiceWeight H z g else 0 + +lemma pathExtension_event_ratio {b h h' : ℕ} {bits : Fin b → ℕ} + {H : PathFamily bits h} {H' : PathFamily bits h'} (E : PathExtension H H') (z : ℝ) : + conditionalEventWeight H z (pathEvent H') = + conditionalNormalizer H' z / conditionalNormalizer H z := by + unfold conditionalEventWeight conditionalChoiceWeight + have hdiv (g : ConditionalChoices H) : + (if pathEvent H' g.val then gridWeight bits z g.val / conditionalNormalizer H z else 0) = + (if pathEvent H' g.val then gridWeight bits z g.val else 0) / conditionalNormalizer H z := by + split_ifs <;> simp only [zero_div] + simp_rw [hdiv] + rw [← Finset.sum_div] + congr 1 + rw [← Finset.sum_subtype (Finset.univ.filter (pathEvent H)) (by simp) + (fun g => if pathEvent H' g then gridWeight bits z g else 0)] + rw [Finset.sum_filter] + unfold conditionalNormalizer + apply Finset.sum_congr rfl + intro g _ + by_cases hg : pathEvent H' g + · simp only [hg, E.pathEvent_mono hg, ite_true] + · simp only [hg, ite_false, ite_self] + +lemma gridSize_pos {b : ℕ} (bits : Fin b → ℕ) : 0 < gridSize bits := by + unfold gridSize + exact Finset.prod_pos (fun j _ => Nat.pow_pos (by norm_num)) + +theorem pathExtension_probability_bound {b h k r : ℕ} {bits : Fin b → ℕ} + {H : PathFamily bits h} {H' : PathFamily bits (h+k)} (E : PathExtension H H') + (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) : + conditionalEventWeight H z (pathEvent H') ≤ + (gridSize bits : ℝ) ^ (-(k : ℝ)) * + Real.exp (pathCost H' - pathCost H + Real.log 4 * k * b) := by + rw [pathExtension_event_ratio E] + have hp : 0 < conditionalNormalizer H' z / conditionalNormalizer H z := by + rw [conditionalNormalizer_eq_prod, conditionalNormalizer_eq_prod] + apply div_pos <;> apply Finset.prod_pos <;> intro j _ <;> + apply Finset.prod_pos <;> intro y _ + · exact localPathWeight_pos_comparison H' hd hz hzr j y + · exact localPathWeight_pos_comparison H hd hz hzr j y + have hs : (0 : ℝ) < gridSize bits := by exact_mod_cast gridSize_pos bits + have he := pathExtension_log_ratio E hd hz hzr + simp only [Nat.cast_add, add_sub_cancel_left] at he + calc + _ ≤ Real.exp (pathCost H' - pathCost H - (k : ℝ) * Real.log (gridSize bits) + + Real.log 4 * k * b) := (Real.log_le_iff_le_exp hp).mp he + _ = _ := by + rw [Real.rpow_def_of_pos hs, ← Real.exp_add] + congr 1 + ring + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/PathMomentMixed.lean b/lean/OAI/Probability/BinarySweep/Trajectories/PathMomentMixed.lean new file mode 100644 index 0000000000000000000000000000000000000000..04471e7f82123f96bde6658fc9654319184846c3 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/PathMomentMixed.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Probability.BinarySweep.SparseBounds.SparseKernel +import OAI.Probability.BinarySweep.Trajectories.EndpointFactors +import OAI.Probability.BinarySweep.Trajectories.PathTelescope + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse + +lemma centeredLineMoment_mixed {m h u v : ℕ} {η : ℝ} + (hm : 0 < m) (hη0 : 0≤η) (hη : η≤1/4) + (hl : 0 (hb l).1),?_⟩ + calc + _ ≤ ∏l, Real.exp ((h l:ℝ)+occurrences f l+occurrences g l) * + 2^occurrences g l * (4*Real.sqrt η)^occurrences f l := + Finset.prod_le_prod₀ (fun l _ => (hb l).1) (fun l _ => (hb l).2) + _ = _ := by + rw [Finset.prod_mul_distrib,Finset.prod_mul_distrib,← Real.exp_sum, + Finset.prod_pow_eq_pow_sum,Finset.prod_pow_eq_pow_sum, + sum_occurrences,sum_occurrences] + congr 2 + simp only [Finset.sum_add_distrib,← Nat.cast_sum,sum_occurrences] + +theorem pathMoment_mixed {b : ℕ} (m h : L → ℕ) (f : A → Fin b → L) (g : B → L) + {η : ℝ} (hm : ∀l, 0 < m l) (hη0 : 0≤η) (hη : η≤1/4) + (hl : ∀a j, (h (f a j):ℝ)+ + occurrences (Sum.elim g (fun a : A × Fin b => f a.1 a.2)) (f a j) ≤ m (f a j)*η) : + let P := (∏a, ((∏j, (MvPolynomial.X (f a j) : MvPolynomial L ℝ))-1)) * + (∏k, MvPolynomial.X (g k)) + 0 ≤ multilineMoment m h P ∧ multilineMoment m h P ≤ + (b:ℝ)^Fintype.card A * + (Real.exp ((∑l, (h l:ℝ))+Fintype.card A+Fintype.card B+Fintype.card A*b) * + 2^(Fintype.card B+Fintype.card A*b)*(4*Real.sqrt η)^Fintype.card A) := by + dsimp only + rw [path_telescope_expansion,map_sum] + have hb (c : A → Fin b) := occurrenceMoment_mixed m h (centeredLine f c) + (Sum.elim g (suffixLine f c)) hm hη0 hη (fun l hlu => by + obtain ⟨a,ha⟩ := (Fintype.card_pos_iff.mp hlu) + have hn := telescope_occurrences_le f g c l + have hn' : (occurrences (centeredLine f c) l:ℝ)+ + occurrences (Sum.elim g (suffixLine f c)) l ≤ + occurrences (Sum.elim g (fun a : A × Fin b => f a.1 a.2)) l := by exact_mod_cast hn + have hx := hl a (c a) + change f a (c a)=l at ha + rw [ha] at hx + linarith) + refine ⟨Finset.sum_nonneg (fun c _ => (hb c).1),?_⟩ + calc + _ ≤ ∑c : A → Fin b, + Real.exp ((∑l, (h l:ℝ))+Fintype.card A+Fintype.card B+Fintype.card A*b) * + 2^(Fintype.card B+Fintype.card A*b)*(4*Real.sqrt η)^Fintype.card A := by + apply Finset.sum_le_sum + intro c _ + apply (hb c).2.trans + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply mul_le_mul + · apply Real.exp_le_exp.mpr + have hc : (Fintype.card (Suffixes c):ℝ)≤Fintype.card A*b := by + exact_mod_cast card_suffixes_le c + simp only [Fintype.card_sum,Nat.cast_add] + linarith + · apply pow_le_pow_right₀ (by norm_num) + simpa using Nat.add_le_add_left (card_suffixes_le c) (Fintype.card B) + · positivity + · positivity + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fun, + Fintype.card_fin,nsmul_eq_mul,Nat.cast_pow] + +end BinaryCoordinateSweeps.Sparse + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Sparse + +attribute [local instance] Classical.propDecidable +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) +variable {I : Type*} [Fintype I] [DecidableEq I] + +def endpointPathPolynomial (e : I → GridSlot bits × GridSlot bits) (i : I) : + MvPolynomial (EndpointLineIndex bits) ℝ := ∏j, MvPolynomial.X (endpointPathLine e i j) + +def vertexIsolated (e : I → GridSlot bits × GridSlot bits) (i : I) : Prop := + (∀t a, independentPosition (e i) t≠H.position t a) ∧ + (∀t a, a≠i → independentPosition (e a) t≠independentPosition (e i) t) + +omit [Fintype I] in +lemma endpointValid_union_isolated (e : I → GridSlot bits × GridSlot bits) + (G J : Finset I) (hi : ∀i∈G, vertexIsolated H e i) : + EndpointValid H (J∪G) e ↔ EndpointValid H J e := by + induction G using Finset.induction_on with + | empty => simp only [Finset.union_empty] + | @insert i G hn ih => + rw [Finset.union_insert,endpointValid_insert H _ e i + (hi i (Finset.mem_insert_self _ _)).1 (hi i (Finset.mem_insert_self _ _)).2] + exact ih (fun a ha => hi a (Finset.mem_insert_of_mem ha)) + +lemma endpoint_subset_polynomial (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (A : Finset (Fin k)) : + (gridSize bits:ℝ)^A.card * endpointProbability H 0 A (fun i => ((x i).val,(y i).val)) = + if EndpointValid H A (fun i => ((x i).val,(y i).val)) then + multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) + (fun l => lineHoles H l.1 l.2) + (∏i∈A, endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i) + else 0 := by + rw [endpointProbability_zero_polynomial] + congr 1 + apply congrArg (multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) + (fun l => lineHoles H l.1 l.2)) + exact Finset.prod_coe_sort A (endpointPathPolynomial (fun i => ((x i).val,(y i).val))) + +lemma centeredEndpointKernel_scaled (z : ℝ) (e : I → GridSlot bits × GridSlot bits) : + (gridSize bits:ℝ)^Fintype.card I * centeredEndpointKernel H z e = + mobiusSum Finset.univ (fun A => (gridSize bits:ℝ)^A.card * endpointProbability H z A e) := by + unfold centeredEndpointKernel alternatingSubsetSum mobiusSum + rw [← mul_assoc,← mul_pow,mul_inv_cancel₀ (show (gridSize bits:ℝ)≠0 by + exact_mod_cast (gridSize_pos bits).ne'),one_pow,one_mul] + apply Finset.sum_congr rfl + intro A _ + ring + +theorem centeredEndpointKernel_good_expansion (x : Placement H k 0) + (y : Placement H k (Fin.last b)) (G : Finset (Fin k)) + (hi : ∀i∈G, vertexIsolated H (fun i => ((x i).val,(y i).val)) i) : + (gridSize bits:ℝ)^k * centeredEndpointKernel H 0 (fun i => ((x i).val,(y i).val)) = + mobiusSum (Finset.univ\G) (fun J => + if EndpointValid H J (fun i => ((x i).val,(y i).val)) then + multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) + (fun l => lineHoles H l.1 l.2) + ((∏i∈G, (endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i-1)) * + ∏i∈J, endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i) + else 0) := by + have hs := centeredEndpointKernel_scaled H 0 (fun i => ((x i).val,(y i).val)) + simp only [Fintype.card_fin] at hs + rw [hs] + conv_lhs => rw [show (Finset.univ : Finset (Fin k))=G∪(Finset.univ\G) by ext i; simp] + rw [mobiusSum_union _ _ Finset.disjoint_sdiff] + apply mobiusSum_congr + intro J hJ + have hJG : Disjoint J G := (Finset.disjoint_sdiff.symm).mono_left hJ + trans mobiusSum G (fun A => if EndpointValid H J (fun i => ((x i).val,(y i).val)) then + multilineMoment (fun l : EndpointLineIndex bits => 2^bits l.1) + (fun l => lineHoles H l.1 l.2) + ((∏i∈J, endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i)* + ∏i∈A, endpointPathPolynomial (fun i => ((x i).val,(y i).val)) i) else 0) + · apply mobiusSum_congr + intro A hA + rw [endpoint_subset_polynomial,endpointValid_union_isolated H _ A J (fun i hiA => hi i (hA hiA))] + rw [Finset.prod_union (hJG.mono_right hA)] + · by_cases hv : EndpointValid H J (fun i => ((x i).val,(y i).val)) + · simp only [ite_eq_left hv] + rw [mobiusSum_linear_product,mul_comm] + · simp only [ite_eq_right hv,mobiusSum,mul_zero,Finset.sum_const_zero] + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/PathSign.lean b/lean/OAI/Probability/BinarySweep/Trajectories/PathSign.lean new file mode 100644 index 0000000000000000000000000000000000000000..045d2881db0299c54f5f0804aca552148dad34ab --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/PathSign.lean @@ -0,0 +1,74 @@ +import Mathlib +import OAI.Probability.BinarySweep.Conditional.Placement +import OAI.Probability.BinarySweep.FiniteLaws.AssignmentSign + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +lemma realSign_gridLayer {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) (j : Fin b) : + realSign (gridLayer bits g j)=∏y, realSign (g j y) := by + simp [gridLayer,realSign,Equiv.Perm.sign_prodCongrLeft,map_prod] + +lemma realSign_gridSweep {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) : + realSign (gridSweep bits g)=∏j, ∏y, realSign (g j y) := by + simp [gridSweep,map_list_prod,List.map_reverse,List.prod_reverse, + List.map_ofFn,List.prod_ofFn,realSign_gridLayer] + +lemma signed_path_integrand_factor {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) (g : GridChoices bits) : + (if pathEvent H g then gridWeight bits z g*realSign (gridSweep bits g) else 0) = + ∏j, ∏y, if Assigns (lineInput H j y) (lineOutput H j y) (g j y) then + lineLaw (bits j) z (g j y)*realSign (g j y) else 0 := by + rw [pathEvent_iff_assigns,realSign_gridSweep] + simp only [Fintype.prod_ite_zero,Finset.prod_mul_distrib,gridWeight] + split_ifs <;> rfl + +lemma signed_path_weight_factor {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) : + (∑g : GridChoices bits, if pathEvent H g then + gridWeight bits z g*realSign (gridSweep bits g) else 0) = + ∏j, ∏y, ∑σ : Equiv.Perm (Slot (bits j)), + if Assigns (lineInput H j y) (lineOutput H j y) σ then + lineLaw (bits j) z σ*realSign σ else 0 := by + simp_rw [signed_path_integrand_factor H z] + exact sum_prod_grid bits (fun j y σ => + if Assigns (lineInput H j y) (lineOutput H j y) σ then + lineLaw (bits j) z σ*realSign σ else 0) + +theorem signed_path_weight_zero_uniform {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (j : Fin b) (y : GridOutside bits j) + {u v : Slot (bits j)} (huv : u≠v) + (hu : u∉Set.range (lineOutput H j y)) (hv : v∉Set.range (lineOutput H j y)) : + (∑g : GridChoices bits, if pathEvent H g then + gridWeight bits 0 g*realSign (gridSweep bits g) else 0)=0 := by + rw [signed_path_weight_factor] + apply Finset.prod_eq_zero (Finset.mem_univ j) + apply Finset.prod_eq_zero (Finset.mem_univ y) + simpa only [lineLaw,sub_zero,one_mul,zero_mul,add_zero] using + uniform_sign_assigns_zero (lineInput H j y) (lineOutput H j y) huv hu hv + +theorem signed_path_weight_zero_empty {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) (j : Fin b) (hj : 0 simp + | succ b ih => + simp only [Finset.prod_filter,Fin.prod_univ_succ,Fin.sum_univ_succ, + Fin.not_lt_zero,ite_false,Fin.succ_pos,ite_true,Fin.succ_lt_succ_iff,one_mul] + have hs := ih (fun j => x j.succ) + simp only [Finset.prod_filter] at hs + rw [← hs] + ring + +variable {L A B : Type*} [Fintype L] [Fintype A] [Fintype B] + +abbrev Suffixes {b : ℕ} (c : A → Fin b) := (a : A) × {j : Fin b // c a f a (c a) + +def suffixLine {b : ℕ} (f : A → Fin b → L) (c : A → Fin b) : Suffixes c → L := + fun a => f a.1 a.2 + +omit [Fintype L] in +lemma path_telescope_expansion {b : ℕ} (f : A → Fin b → L) (g : B → L) : + (∏ a, ((∏ j, (MvPolynomial.X (f a j) : MvPolynomial L ℝ))-1)) * + (∏ k, MvPolynomial.X (g k)) = + ∑ c : A → Fin b, + (∏ a, (MvPolynomial.X (centeredLine f c a)-1)) * + (∏ k : B ⊕ Suffixes c, MvPolynomial.X (Sum.elim g (suffixLine f c) k)) := by + simp_rw [prod_sub_one_telescope] + rw [Fintype.prod_sum,Finset.sum_mul] + apply Finset.sum_congr rfl + intro c _ + simp only [Finset.prod_mul_distrib,Fintype.prod_sum_type,Fintype.prod_sigma,Sum.elim_inl,Sum.elim_inr,centeredLine,suffixLine] + have he : ∏ a, ∏ j : Fin b with c a MvPolynomial.X (f a j)) + rw [he] + ring + +end + +variable {L A B C : Type*} [Fintype L] [Fintype A] [Fintype B] [Fintype C] + +omit [Fintype L] in +lemma occurrences_le_of_injective (f : A → L) (g : B → L) (e : A → B) + (hi : Function.Injective e) (he : ∀ a, g (e a) = f a) (l : L) : + occurrences f l ≤ occurrences g l := by + apply Fintype.card_le_of_injective (fun a : {a // f a=l} => + (⟨e a, (he a).trans a.property⟩ : {b // g b=l})) + intro a b h + exact Subtype.ext (hi (congrArg Subtype.val h)) + +omit [Fintype L] in +lemma occurrences_sum (f : A → L) (g : B → L) (l : L) : + occurrences (Sum.elim f g) l = occurrences f l + occurrences g l := by + have h := Fintype.card_congr (Equiv.subtypeSum (p := fun a : A ⊕ B => Sum.elim f g a=l)) + exact h.trans Fintype.card_sum + +variable {b : ℕ} + +def telescopeInjection (c : A → Fin b) : A ⊕ (B ⊕ Suffixes c) → B ⊕ (A × Fin b) + | .inl a => .inr (a,c a) + | .inr (.inl k) => .inl k + | .inr (.inr a) => .inr (a.1,a.2) + +omit [Fintype A] [Fintype B] in +lemma telescopeInjection_injective (c : A → Fin b) : Function.Injective (telescopeInjection (B:=B) c) := by + rintro (a | (k | ⟨a,j,hj⟩)) (a' | (k' | ⟨a',j',hj'⟩)) h <;> + simp only [telescopeInjection,Sum.inl.injEq,Sum.inr.injEq,Sum.inl_ne_inr, + Sum.inr_ne_inl,Prod.mk.injEq] at h + · exact congrArg Sum.inl h.1 + · rcases h with ⟨rfl,rfl⟩ + exact False.elim (lt_irrefl _ hj') + · exact congrArg (Sum.inr ∘ Sum.inl) h + · rcases h with ⟨rfl,rfl⟩ + exact False.elim (lt_irrefl _ hj) + · rcases h with ⟨rfl,rfl⟩; rfl + +omit [Fintype L] in +lemma telescope_occurrences_le (f : A → Fin b → L) (g : B → L) (c : A → Fin b) (l : L) : + occurrences (centeredLine f c) l + + occurrences (Sum.elim g (suffixLine f c)) l ≤ + occurrences (Sum.elim g (fun a : A × Fin b => f a.1 a.2)) l := by + rw [← occurrences_sum] + apply occurrences_le_of_injective _ _ (telescopeInjection c) (telescopeInjection_injective c) + rintro (a | (k | a)) <;> rfl + +lemma card_suffixes_le (c : A → Fin b) : Fintype.card (Suffixes c) ≤ Fintype.card A * b := by + apply (Fintype.card_le_of_injective (fun a : Suffixes c => (a.1, a.2.val)) ?_).trans_eq + (by simp) + intro a a' h + obtain ⟨a,j,hj⟩ := a + obtain ⟨a',j',hj'⟩ := a' + cases h + rfl + +theorem pathMoment_light (m h : L → ℕ) (f : A → Fin b → L) (g : B → L) + {η : ℝ} (hm : ∀ l, 0 < m l) (hη0 : 0 ≤ η) (hη : η ≤ 1/4) + (hl : ∀ l, (h l:ℝ)+ + occurrences (Sum.elim g (fun a : A × Fin b => f a.1 a.2)) l ≤ m l*η) : + let P := (∏ a, ((∏ j, (MvPolynomial.X (f a j) : MvPolynomial L ℝ))-1)) * + (∏ k, MvPolynomial.X (g k)) + 0 ≤ multilineMoment m h P ∧ multilineMoment m h P ≤ + (b:ℝ)^(Fintype.card A) * 2^(Fintype.card B+Fintype.card A*b) * + (4*Real.sqrt η)^(Fintype.card A) := by + dsimp only + rw [path_telescope_expansion,map_sum] + have hb (c : A → Fin b) := occurrenceMoment_light m h (centeredLine f c) + (Sum.elim g (suffixLine f c)) hm hη0 hη (fun l => by + have hn := telescope_occurrences_le f g c l + have hn' : (occurrences (centeredLine f c) l : ℝ) + + occurrences (Sum.elim g (suffixLine f c)) l ≤ + occurrences (Sum.elim g (fun a : A × Fin b => f a.1 a.2)) l := by exact_mod_cast hn + linarith [hl l]) + refine ⟨Finset.sum_nonneg (fun c _ => (hb c).1), ?_⟩ + calc + _ ≤ ∑ c : A → Fin b, (2:ℝ)^(Fintype.card B+Fintype.card A*b) * + (4*Real.sqrt η)^(Fintype.card A) := by + apply Finset.sum_le_sum + intro c _ + apply (hb c).2.trans + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply pow_le_pow_right₀ (by norm_num) + simpa using Nat.add_le_add_left (card_suffixes_le c) (Fintype.card B) + _ = _ := by simp [Fintype.card_pi,← mul_assoc] + +end BinaryCoordinateSweeps.Sparse + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse + +lemma fallingMoment_nonneg (m h n : ℕ) : 0≤fallingMoment m h n := by + unfold fallingMoment + positivity + +lemma fallingMoment_log {m h n : ℕ} (hm : 0 < m) (hn : h+n ≤ m) : + Real.log (fallingMoment m h n)=fallingCost m (h+n)-fallingCost m h := by + have hh : h ≤ m := by omega + have hp : (m:ℝ)≠0 := by exact_mod_cast hm.ne' + have hnh : n ≤ m-h := by omega + have hdf : ((m-h).descFactorial n:ℝ)≠0 := by + exact_mod_cast (Nat.descFactorial_pos.mpr hnh).ne' + have hdh : (m.descFactorial h:ℝ)≠0 := by + exact_mod_cast (Nat.descFactorial_pos.mpr hh).ne' + have he : (m-h).descFactorial n * m.descFactorial h=m.descFactorial (h+n) := by + simpa only [Nat.add_sub_cancel_left] using + (Nat.descFactorial_mul_descFactorial (show h≤h+n by omega) (n:=m)) + rw [fallingMoment,Real.log_div (pow_ne_zero _ hp) hdf,Real.log_pow, + fallingCost_formula hm hn,fallingCost_formula hm hh,← he,Nat.cast_mul, + Real.log_mul hdf hdh,Nat.cast_add] + ring + +lemma fallingMoment_le_exp {m h n : ℕ} (hm : 0 < m) : + fallingMoment m h n≤Real.exp (h+n) := by + by_cases hn : h+n ≤ m + · have hp := fallingMoment_pos hm hn + rw [← Real.exp_log hp] at ⊢ + apply Real.exp_le_exp.mpr + rw [fallingMoment_log hm hn] + have h1 := fallingCost_le hm hn + have h0 := fallingCost_nonneg hm (show h ≤ m by omega) + push_cast at h1 + linarith + · by_cases hn0 : n=0 + · subst n + simp only [fallingMoment_zero,Nat.cast_zero,add_zero] + exact Real.one_le_exp (by positivity) + · have hd : (m-h).descFactorial n=0 := + Nat.descFactorial_eq_zero_iff_lt.mpr (by omega) + simp only [fallingMoment,hd,Nat.cast_zero,div_zero] + exact (Real.exp_pos _).le + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/SharingProbability.lean b/lean/OAI/Probability/BinarySweep/Trajectories/SharingProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..95b15496b9ac94c4b64ec3065c3fe8972ab60fcb --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/SharingProbability.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.SharingWitness +import OAI.Probability.BinarySweep.FiniteLaws.FiniteProductProbability + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {I H Ω : Type*} [Fintype I] [DecidableEq I] [Fintype H] [Fintype Ω] + + def sharingGraph (R : Ω → Ω → Prop) + (hs : ∀ ⦃first second⦄, R first second → R second first) (x : I → Ω) : SimpleGraph I where + Adj i j := i ≠ j ∧ R (x i) (x j) + symm := ⟨fun _ _ h => ⟨h.1.symm,hs h.2⟩⟩ + loopless := ⟨fun _ h => h.1 rfl⟩ + +def incidentSet (R : Ω → Ω → Prop) (roots : H → Ω) (x : I → Ω) : Finset I := + Finset.univ.filter (fun i => (∃ j, i ≠ j ∧ R (x i) (x j)) ∨ ∃ h, R (x i) (roots h)) + +omit [Fintype Ω] in +lemma sharing_depthOne (R : Ω → Ω → Prop) + (hs : ∀ ⦃first second⦄, R first second → R second first) + (roots : H → Ω) (x : I → Ω) (w : ℕ) (hw : w ≤ (incidentSet R roots x).card) : + ∃ T : Finset I, w ≤ 2*T.card ∧ + ∃ f : T → {i // i ∉ T} ⊕ H, ∀ i : T, + R (x i) ((f i).elim (fun j : {i // i ∉ T} => x j.val) roots) := by + classical + obtain ⟨T,_,hc,hT⟩ := sharing_witness (sharingGraph R hs x) (fun i h => R (x i) (roots h)) + have hc' : (incidentSet R roots x).card ≤ 2*T.card := by + convert hc using 1 + congr 1 + ext i + simp only [incidentSet, Finset.mem_filter, Finset.mem_univ, true_and] + rfl + + refine ⟨T,hw.trans hc',?_⟩ + have hp (i : T) : ∃ a : {i // i ∉ T} ⊕ H, + R (x i) (a.elim (fun j : {i // i ∉ T} => x j.val) roots) := by + obtain ⟨j,hj,hij⟩ | ⟨h,hi⟩ := hT i i.property + · exact ⟨Sum.inl ⟨j,hj⟩,hij.2⟩ + · exact ⟨Sum.inr h,hi⟩ + choose f hf using hp + exact ⟨f,hf⟩ + +theorem sharing_probability_le + (p : Ω → ℝ) (hp : ∀ u, 0 ≤ p u) (hp1 : ∑ u, p u = 1) + (R : Ω → Ω → Prop) + (hs : ∀ ⦃first second⦄, R first second → R second first) (roots : H → Ω) + (ω : ℝ) (hω : 0 ≤ ω) + (hR : ∀ v, (∑ u, p u * (if R u v then 1 else 0)) ≤ ω) + (w : ℕ) (hsmall : ((Fintype.card I + Fintype.card H : ℕ) : ℝ)*ω ≤ 1) : + productProbability p (fun x : I → Ω => w ≤ (incidentSet R roots x).card) ≤ + (2:ℝ)^Fintype.card I * + (((Fintype.card I + Fintype.card H : ℕ):ℝ)*ω)^((w+1)/2) := by + classical + let E (T : Finset I) (f : T → {i // i ∉ T} ⊕ H) (x : I → Ω) := + ∀ i : T, R (x i) ((f i).elim (fun j : {i // i ∉ T} => x j.val) roots) + let r : ℝ := ((Fintype.card I + Fintype.card H : ℕ):ℝ)*ω + have hr : 0 ≤ r := mul_nonneg (Nat.cast_nonneg _) hω + have hT (T : Finset I) : productProbability p (fun x => w ≤ 2*T.card ∧ ∃ f, E T f x) ≤ + r^((w+1)/2) := by + by_cases hc : w ≤ 2*T.card + · have h1 := productProbability_union_le hp (E T) + have h2 : (∑ f, productProbability p (E T f)) ≤ + (Fintype.card (T → {i // i ∉ T} ⊕ H) : ℝ)*ω^T.card := by + simpa [E] using Finset.sum_le_sum (s:=Finset.univ) (fun f _ => depthOne_probability_le p hp hp1 R ω hω hR T f roots) + have hd : Fintype.card ({i // i ∉ T} ⊕ H) ≤ Fintype.card I + Fintype.card H := by + rw [Fintype.card_sum] + exact Nat.add_le_add_right (Fintype.card_subtype_le _) _ + have h3 : (Fintype.card (T → {i // i ∉ T} ⊕ H) : ℝ)*ω^T.card ≤ r^T.card := by + rw [Fintype.card_fun,Fintype.card_coe,Nat.cast_pow] + dsimp [r] + rw [mul_pow] + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hω _) + exact pow_le_pow_left₀ (Nat.cast_nonneg _) (by exact_mod_cast hd) _ + have he : (w+1)/2 ≤ T.card := by omega + simpa only [hc,true_and] using h1.trans (h2.trans (h3.trans + (pow_le_pow_of_le_one hr hsmall he))) + · simp only [hc,false_and,productProbability,ite_false,mul_zero,Finset.sum_const_zero] + exact pow_nonneg hr _ + calc + _ ≤ productProbability p (fun x => ∃ T : Finset I, w ≤ 2*T.card ∧ ∃ f, E T f x) := + productProbability_mono hp (fun x hx => sharing_depthOne R hs roots x w hx) + _ ≤ ∑ T : Finset I, productProbability p (fun x => w ≤ 2*T.card ∧ ∃ f, E T f x) := + productProbability_union_le hp _ + _ ≤ ∑ T : Finset I, r^((w+1)/2) := Finset.sum_le_sum (fun T _ => hT T) + _ = _ := by simp [r,Fintype.card_finset] + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/SharingWitness.lean b/lean/OAI/Probability/BinarySweep/Trajectories/SharingWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cd028c26dfb97f00a0e2c648021bb51292f061c --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/SharingWitness.lean @@ -0,0 +1,52 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {I H : Type*} [Fintype I] [Fintype H] [DecidableEq I] + +theorem sharing_witness (G : SimpleGraph I) (R : I → H → Prop) : + let S := Finset.univ.filter (fun i => (∃ j, G.Adj i j) ∨ ∃ h, R i h) + ∃ T : Finset I, T ⊆ S ∧ S.card ≤ 2*T.card ∧ + ∀ i ∈ T, (∃ j, j ∉ T ∧ G.Adj i j) ∨ ∃ h, R i h := by + classical + intro S + obtain ⟨A,hA⟩ := G.maximumIndepSet_exists + have hm := hA.isMaximalIndepSet A + have hi := (G.isIndepSet_iff).mp hm.1 + have hn (i : I) (hiA : i ∉ A) : ∃ j ∈ A, G.Adj i j := by + by_contra! h + have hins : G.IsIndepSet (insert i (A : Set I)) := by + apply G.isIndepSet_iff.mpr + intro x hx y hy hxy + rcases hx with rfl | hx <;> rcases hy with rfl | hy + · exact (hxy rfl).elim + · exact h y hy + · exact fun hadj => h x hx hadj.symm + · exact hi hx hy hxy + have hj := hm.2 hins (Set.subset_insert i (A : Set I)) (Set.mem_insert i (A : Set I)) + exact hiA hj + have hcard := Finset.card_sdiff_add_card_inter S A + by_cases hc : (S \ A).card ≤ (S ∩ A).card + · refine ⟨S ∩ A,Finset.inter_subset_left,by omega,?_⟩ + intro i hiT + obtain ⟨hiS, hiA⟩ := Finset.mem_inter.mp hiT + obtain hiS | hiS := (Finset.mem_filter.mp hiS).2 + · obtain ⟨j,hij⟩ := hiS + refine Or.inl ⟨j,?_,hij⟩ + intro hj + exact hi hiA (Finset.mem_inter.mp hj).2 (G.ne_of_adj hij) hij + · exact Or.inr hiS + · refine ⟨S \ A,Finset.sdiff_subset,by omega,?_⟩ + intro i hiT + obtain ⟨j,hj,hij⟩ := hn i (Finset.mem_sdiff.mp hiT).2 + exact Or.inl ⟨j,fun hjT => (Finset.mem_sdiff.mp hjT).2 hj,hij⟩ + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/SparseOccupancy.lean b/lean/OAI/Probability/BinarySweep/Trajectories/SparseOccupancy.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ae45562fad630b862c16485d8c871014ba117fd --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/SparseOccupancy.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Probability.BinarySweep.FiniteLaws.UniformFiniteProbability + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Sparse +variable {I Ω L : Type*} [Fintype I] [DecidableEq I] [Fintype Ω] + +theorem occupancy_probability_le [Nonempty Ω] + (p : Ω → ℝ) (hp : ∀u, 0 ≤ p u) (hp1 : ∑u, p u=1) + (E : Ω → Prop) (δ : ℝ) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hE : finiteProbability p E ≤ δ) (w : ℕ) : + productProbability p (fun x : I → Ω => w ≤ (Finset.univ.filter (fun i => E (x i))).card) ≤ + (2:ℝ)^Fintype.card I * δ^w := by + let root : Ω := Classical.choice inferInstance + have hT (T : Finset I) : + productProbability p (fun x : I → Ω => w ≤ T.card ∧ ∀i∈T, E (x i)) ≤ δ^w := by + by_cases h : w ≤ T.card + · have hb := depthOne_probability_le p hp hp1 (fun u _ => E u) δ hδ + (fun _ => hE) T (fun _ => Sum.inr ()) (fun _ : Unit => root) + have he : (fun x : I → Ω => w ≤ T.card ∧ ∀i∈T, E (x i)) = + (fun x : I → Ω => ∀i : T, E (x i)) := by + funext x + simp only [h,true_and,Subtype.forall] + rw [he] + exact hb.trans (pow_le_pow_of_le_one hδ hδ1 h) + · simp only [h,false_and,productProbability,ite_false,mul_zero,Finset.sum_const_zero] + exact pow_nonneg hδ w + calc + _ ≤ productProbability p (fun x : I → Ω => ∃T : Finset I, w ≤ T.card ∧ ∀i∈T, E (x i)) := + productProbability_mono hp (fun x hx => ⟨_,hx,fun i hi => (Finset.mem_filter.mp hi).2⟩) + _ ≤ ∑T : Finset I, productProbability p (fun x : I → Ω => w ≤ T.card ∧ ∀i∈T, E (x i)) := + productProbability_union_le hp _ + _ ≤ _ := by + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_finset,nsmul_eq_mul,Nat.cast_pow,Nat.cast_ofNat] + using Finset.sum_le_sum (s:=Finset.univ) (fun T _ => hT T) + +variable [Fintype L] [DecidableEq L] + +def smallSetEncode {r : ℕ} (S : {S : Finset L // S.card ≤ r}) : Fin r → Option L := + fun i => if h : i.val < S.val.card then + some ((Fintype.equivFin S.val).symm ⟨i.val,by simpa using h⟩).val else none + +omit [Fintype L] [DecidableEq L] in +lemma smallSetEncode_mem {r : ℕ} (S : {S : Finset L // S.card ≤ r}) (l : L) : + l∈S.val ↔ ∃i, smallSetEncode S i=some l := by + constructor + · intro hl + let j := Fintype.equivFin S.val ⟨l,hl⟩ + have hj : j.val < S.val.card := by simpa using j.isLt + refine ⟨⟨j.val,lt_of_lt_of_le hj S.property⟩,?_⟩ + simp only [smallSetEncode,dite_eq_left hj] + have he : (⟨j.val,by simpa using hj⟩ : Fin (Fintype.card S.val))=j := rfl + rw [he,Equiv.symm_apply_apply] + · rintro ⟨i,hi⟩ + unfold smallSetEncode at hi + split_ifs at hi with h + · cases Option.some.inj hi + exact ((Fintype.equivFin S.val).symm ⟨i.val,by simpa using h⟩).property + +omit [Fintype L] [DecidableEq L] in +lemma smallSetEncode_injective (r : ℕ) : Function.Injective (smallSetEncode (L:=L) (r:=r)) := by + intro S T h + apply Subtype.ext + ext l + rw [smallSetEncode_mem,smallSetEncode_mem,h] + +omit [DecidableEq L] in +lemma smallSet_card_bound (r : ℕ) : + Fintype.card {S : Finset L // S.card ≤ r} ≤ (Fintype.card L+1)^r := by + simpa only [Fintype.card_fun,Fintype.card_option,Fintype.card_fin] + using Fintype.card_le_of_injective _ (smallSetEncode_injective (L:=L) r) + +theorem line_sets_occupancy_probability_le [Nonempty Ω] + (p : Ω → ℝ) (hp : ∀u, 0 ≤ p u) (hp1 : ∑u, p u=1) + (line : Ω → L) (r w : ℕ) (δ : ℝ) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hmass : ∀S : Finset L, S.card ≤ r → finiteProbability p (fun u => line u∈S) ≤ δ) : + productProbability p (fun x : I → Ω => ∃S : Finset L, S.card ≤ r ∧ + w ≤ (Finset.univ.filter (fun i => line (x i)∈S)).card) ≤ + ((Fintype.card L+1:ℕ):ℝ)^r * (2:ℝ)^Fintype.card I * δ^w := by + let E (S : {S : Finset L // S.card ≤ r}) (x : I → Ω) := + w ≤ (Finset.univ.filter (fun i => line (x i)∈S.val)).card + have h1 := productProbability_union_le hp E + have h2 : (∑S, productProbability p (E S)) ≤ + (Fintype.card {S : Finset L // S.card ≤ r}:ℝ)*((2:ℝ)^Fintype.card I*δ^w) := by + calc + _ ≤ ∑ S : {S : Finset L // S.card ≤ r}, ((2:ℝ)^Fintype.card I*δ^w) := by + apply Finset.sum_le_sum + intro S _ + convert occupancy_probability_le p hp hp1 (fun u => line u∈S.val) δ hδ hδ1 + (hmass S.val S.property) w (I:=I) using 1 + unfold productProbability E + apply Finset.sum_congr rfl + intro x _ + congr 2 + apply congrArg (fun t : Finset I => w ≤ t.card) + ext i + simp only [Finset.mem_filter,Finset.mem_univ,true_and] + _ = _ := by simp + have h3 : (Fintype.card {S : Finset L // S.card ≤ r}:ℝ) ≤ ((Fintype.card L+1:ℕ):ℝ)^r := by + exact_mod_cast smallSet_card_bound (L:=L) r + have he : (fun x : I → Ω => ∃S : Finset L, S.card ≤ r ∧ + w ≤ (Finset.univ.filter (fun i => line (x i)∈S)).card) = (fun x => ∃S, E S x) := by + funext x + simp only [E,Subtype.exists,exists_prop] + rw [he] + apply h1.trans (h2.trans _) + rw [mul_assoc] + exact mul_le_mul_of_nonneg_right h3 (mul_nonneg (pow_nonneg (by norm_num) _) (pow_nonneg hδ w)) + +end BinaryCoordinateSweeps.Sparse + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/Trajectory.lean b/lean/OAI/Probability/BinarySweep/Trajectories/Trajectory.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f604d7ca058951a69a87ecc1d139270b72b72c8 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/Trajectory.lean @@ -0,0 +1,212 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.PathExtension + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +attribute [local instance] Classical.propDecidable + +lemma trajectory_coordinates {b : ℕ} {bits : Fin b → ℕ} + (x : Fin (b+1) → GridSlot bits) + (hmov : ∀ (j : Fin b) (i : Fin b), i ≠ j → x j.succ i = x j.castSucc i) + (t : Fin (b+1)) (i : Fin b) : + x t i = if i.val < t.val then x (Fin.last b) i else x 0 i := by + have hbefore : ∀ t : Fin (b+1), t.val ≤ i.val → x t i = x 0 i := by + intro t + induction t using Fin.induction with + | zero => intro _; rfl + | succ j ih => + intro ht + have hij : i ≠ j := by intro h; subst j; simp at ht + rw [hmov j i hij, ih] + exact Nat.le_trans (Nat.le_succ j.val) ht + have hafter : ∀ t : Fin (b+1), i.val < t.val → x t i = x (Fin.last b) i := by + intro t + induction t using Fin.reverseInduction with + | last => intro _; rfl + | cast j ih => + intro ht + have hij : i ≠ j := by intro h; subst j; simp at ht + rw [← hmov j i hij, ih] + exact Nat.lt_succ_of_lt ht + split_ifs with h + · exact hafter t h + · exact hbefore t (Nat.le_of_not_lt h) + +lemma trajectory_unique {b : ℕ} {bits : Fin b → ℕ} + (x y : Fin (b+1) → GridSlot bits) + (hx : ∀ (j i : Fin b), i ≠ j → x j.succ i = x j.castSucc i) + (hy : ∀ (j i : Fin b), i ≠ j → y j.succ i = y j.castSucc i) + (h0 : x 0 = y 0) (hb : x (Fin.last b) = y (Fin.last b)) : x = y := by + funext t i + rw [trajectory_coordinates x hx, trajectory_coordinates y hy, h0, hb] + +def gridPartialSweep {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) + (t : Fin (b+1)) : Equiv.Perm (GridSlot bits) := + ((List.ofFn (gridLayer bits g)).take t.val).reverse.prod + +@[simp] lemma gridPartialSweep_zero {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) : + gridPartialSweep bits g 0 = 1 := by simp [gridPartialSweep] + +@[simp] lemma gridPartialSweep_last {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) : + gridPartialSweep bits g (Fin.last b) = gridSweep bits g := by + unfold gridPartialSweep gridSweep + rw [List.take_of_length_le (by simp)] + +lemma gridPartialSweep_succ {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) (j : Fin b) : + gridPartialSweep bits g j.succ = gridLayer bits g j * gridPartialSweep bits g j.castSucc := by + unfold gridPartialSweep + simp only [Fin.val_succ, Fin.val_castSucc] + rw [List.take_succ_eq_append_getElem (by simp)] + simp only [List.reverse_append, List.reverse_singleton, List.prod_append, + List.prod_singleton, List.getElem_ofFn, Fin.eta] + +lemma gridLayer_other {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) + (j i : Fin b) (hi : i ≠ j) (x : GridSlot bits) : gridLayer bits g j x i = x i := by + simp [gridLayer, Equiv.piSplitAt, hi] + +lemma gridPartialSweep_changes {b : ℕ} (bits : Fin b → ℕ) (g : GridChoices bits) + (x : GridSlot bits) (j i : Fin b) (hi : i ≠ j) : + gridPartialSweep bits g j.succ x i = gridPartialSweep bits g j.castSucc x i := by + rw [gridPartialSweep_succ, Equiv.Perm.mul_apply, gridLayer_other bits g j i hi] + +lemma gridPartialSweep_path {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (g : GridChoices bits) (hg : pathEvent H g) + (t : Fin (b+1)) (i : Fin h) : + gridPartialSweep bits g t (H.position 0 i) = H.position t i := by + induction t using Fin.induction with + | zero => simp + | succ j ih => rw [gridPartialSweep_succ, Equiv.Perm.mul_apply, ih, hg j i] + +lemma pathEvent_of_endpoints {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (g : GridChoices bits) + (he : ∀ i, gridSweep bits g (H.position 0 i) = H.position (Fin.last b) i) : + pathEvent H g := by + have hx (i : Fin h) : (fun t => gridPartialSweep bits g t (H.position 0 i)) = + (fun t => H.position t i) := by + apply trajectory_unique + · exact gridPartialSweep_changes bits g (H.position 0 i) + · exact fun j a ha => H.changes_only_stage j i a ha + · simp + · simpa using he i + intro j i + have ha := congrFun (hx i) j.castSucc + have hb := congrFun (hx i) j.succ + rw [gridPartialSweep_succ, Equiv.Perm.mul_apply, ha] at hb + exact hb + +def augmentByChoice {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {k : ℕ} (x : Placement H k 0) (g : ConditionalChoices H) : PathFamily bits (h+k) where + position t a := gridPartialSweep bits g.val t (Fin.append (H.position 0) (fun i => (x i).val) a) + disjoint t := (gridPartialSweep bits g.val t).injective.comp (Fin.append_injective_iff.mpr + ⟨H.disjoint 0, Subtype.val_injective.comp x.injective, fun i j he => (x j).property ⟨i, he⟩⟩) + changes_only_stage j _ i hi := gridPartialSweep_changes bits g.val _ j i hi + +def augmentByChoice_extension {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + {k : ℕ} (x : Placement H k 0) (g : ConditionalChoices H) : + PathExtension H (augmentByChoice H x g) where + labels := ⟨Fin.castAdd k, Fin.castAdd_injective h k⟩ + position_eq t i := by + change gridPartialSweep bits g.val t (Fin.append _ _ (Fin.castAdd k i)) = _ + rw [Fin.append_left, gridPartialSweep_path H g.val g.property] + +lemma placementEvent_iff_augmentation {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) {k : ℕ} (x : Placement H k 0) (g g' : ConditionalChoices H) : + placementBijection H k g' x = placementBijection H k g x ↔ + pathEvent (augmentByChoice H x g) g'.val := by + constructor + · intro he + apply pathEvent_of_endpoints + intro a + change gridSweep bits g'.val (gridPartialSweep bits g.val 0 (Fin.append _ _ a)) = + gridPartialSweep bits g.val (Fin.last b) (Fin.append _ _ a) + simp only [gridPartialSweep_zero, gridPartialSweep_last, Equiv.Perm.one_apply] + induction a using Fin.addCases with + | left i => + rw [Fin.append_left, gridSweep_path H g'.val g'.property, gridSweep_path H g.val g.property] + | right i => + rw [Fin.append_right] + exact congrArg (fun y : Placement H k (Fin.last b) => (y i).val) he + · intro he + apply Function.Embedding.ext + intro i + apply Subtype.ext + change gridSweep bits g'.val (x i).val = gridSweep bits g.val (x i).val + have hi := gridSweep_path (augmentByChoice H x g) g'.val he (Fin.natAdd h i) + simpa only [augmentByChoice, Fin.append_right, gridPartialSweep_zero, + gridPartialSweep_last, Equiv.Perm.one_apply] using hi + +lemma placementProbability_augmentation {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) {k : ℕ} (x : Placement H k 0) (g : ConditionalChoices H) : + placementProbability H z x (placementBijection H k g x) = + conditionalEventWeight H z (pathEvent (augmentByChoice H x g)) := by + unfold placementProbability conditionalEventWeight + apply Finset.sum_congr rfl + intro g' _ + simp only [placementEvent_iff_augmentation] + +theorem placement_probability_cost {b h r : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) + {k : ℕ} (x : Placement H k 0) (g : ConditionalChoices H) : + placementProbability H z x (placementBijection H k g x) ≤ + (gridSize bits : ℝ) ^ (-(k : ℝ)) * + Real.exp (pathCost (augmentByChoice H x g) - pathCost H + Real.log 4 * k * b) := by + rw [placementProbability_augmentation] + exact pathExtension_probability_bound (augmentByChoice_extension H x g) hd hz hzr + +lemma placementProbability_pos_has_choice {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) {k : ℕ} + (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (hp : 0 < placementProbability H z x y) : + ∃ g : ConditionalChoices H, placementBijection H k g x = y := by + unfold placementProbability at hp + by_contra he + push Not at he + have hs : (∑ g : ConditionalChoices H, + if placementBijection H k g x = y then conditionalChoiceWeight H z g else 0) = 0 := by + apply Finset.sum_eq_zero + intro g _ + simp only [he g, ite_false] + rw [hs] at hp + exact (lt_irrefl _ hp) + +def realizePlacement {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) {k : ℕ} + (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (hp : 0 < placementProbability H z x y) : ConditionalChoices H := + Classical.choose (placementProbability_pos_has_choice H z x y hp) + +lemma realizePlacement_spec {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) {k : ℕ} + (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (hp : 0 < placementProbability H z x y) : + placementBijection H k (realizePlacement H z x y hp) x = y := + Classical.choose_spec (placementProbability_pos_has_choice H z x y hp) + +def placementTransitionCost {b h : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (z : ℝ) {k : ℕ} + (x : Placement H k 0) (y : Placement H k (Fin.last b)) : ℝ := + if hp : 0 < placementProbability H z x y then + pathCost (augmentByChoice H x (realizePlacement H z x y hp)) else 0 + +theorem placement_probability_cost_of_pos {b h r : ℕ} {bits : Fin b → ℕ} + (H : PathFamily bits h) (hd : ∀ j, bits j ≤ 2*r) {z : ℝ} + (hz : 0 ≤ z) (hzr : z ≤ linePerturbationRadius r) + {k : ℕ} (x : Placement H k 0) (y : Placement H k (Fin.last b)) + (hp : 0 < placementProbability H z x y) : + placementProbability H z x y ≤ (gridSize bits : ℝ) ^ (-(k : ℝ)) * + Real.exp (placementTransitionCost H z x y - pathCost H + Real.log 4 * k * b) := by + have he := placement_probability_cost H hd hz hzr x (realizePlacement H z x y hp) + unfold placementTransitionCost + rw [dite_eq_left hp] + rwa [realizePlacement_spec] at he + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/Trajectories/TrajectoryComplement.lean b/lean/OAI/Probability/BinarySweep/Trajectories/TrajectoryComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..84e6b31cf3b58cd546471c731b5079641bcde2b5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/Trajectories/TrajectoryComplement.lean @@ -0,0 +1,85 @@ +import Mathlib +import OAI.Probability.BinarySweep.Trajectories.Trajectory +import OAI.Probability.BinarySweep.Conditional.PlacementBlocks + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps +open Irrep + +variable {b h k : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (x : Placement H k 0) (g : ConditionalChoices H) + +def augmentedPlacement (t : Fin (b+1)) : Placement H k t where + toFun i := ⟨gridPartialSweep bits g.val t (x i).val, by + rintro ⟨j,hj⟩ + have he := gridPartialSweep_path H g.val g.property t j + have hx := (gridPartialSweep bits g.val t).injective (he.trans hj) + exact (x i).property ⟨j,hx⟩⟩ + inj' i j hij := x.injective (Subtype.ext + ((gridPartialSweep bits g.val t).injective (congrArg Subtype.val hij))) + +lemma augmentedPosition_left (t : Fin (b+1)) (i : Fin h) : + (augmentByChoice H x g).position t (Fin.castAdd k i) = H.position t i := by + change gridPartialSweep bits g.val t (Fin.append _ _ (Fin.castAdd k i)) = _ + rw [Fin.append_left,gridPartialSweep_path H g.val g.property] + +lemma augmentedPosition_right (t : Fin (b+1)) (i : Fin k) : + (augmentByChoice H x g).position t (Fin.natAdd h i) = (augmentedPlacement H x g t i).val := by + change gridPartialSweep bits g.val t (Fin.append _ _ (Fin.natAdd h i)) = _ + rw [Fin.append_right]; rfl + +lemma augmentedPlacement_zero : augmentedPlacement H x g 0 = x := by + apply Function.Embedding.ext + intro index + apply Subtype.ext + change gridPartialSweep bits g.val 0 (x index).val = (x index).val + rw [gridPartialSweep_zero, Equiv.Perm.one_apply] + +lemma augmentedPlacement_last : augmentedPlacement H x g (Fin.last b) = placementBijection H k g x := by + apply Function.Embedding.ext + intro index + apply Subtype.ext + change gridPartialSweep bits g.val (Fin.last b) (x index).val = + gridSweep bits g.val (x index).val + rw [gridPartialSweep_last] + +def augmentationFreeEquiv (t : Fin (b+1)) : + FreeSlot (augmentByChoice H x g) t ≃ PlacementComplement (augmentedPlacement H x g t) where + toFun w := ⟨⟨w.val, by + rintro ⟨i,hi⟩ + exact w.property ⟨Fin.castAdd k i,(augmentedPosition_left H x g t i).trans hi⟩⟩,by + rintro ⟨i,hi⟩ + exact w.property ⟨Fin.natAdd h i,(augmentedPosition_right H x g t i).trans + (congrArg Subtype.val hi)⟩⟩ + invFun w := ⟨w.val.val,by + rintro ⟨i,hi⟩ + induction i using Fin.addCases with + | left i => + rw [augmentedPosition_left] at hi + exact w.val.property ⟨i,hi⟩ + | right i => + rw [augmentedPosition_right] at hi + exact w.property ⟨i,Subtype.ext hi⟩⟩ + left_inv w := rfl + right_inv w := rfl + +lemma augmentationFreeEquiv_val (t : Fin (b+1)) (w : FreeSlot (augmentByChoice H x g) t) : + (augmentationFreeEquiv H x g t w).val.val = w.val := rfl + +lemma augmented_gridSweep (g' : ConditionalChoices (augmentByChoice H x g)) + (w : FreeSlot (augmentByChoice H x g) 0) : + (augmentationFreeEquiv H x g (Fin.last b) + (remainingBijection (augmentByChoice H x g) g'.val g'.property w)).val = + remainingBijection H g'.val + ((augmentByChoice_extension H x g).pathEvent_mono g'.property) + (augmentationFreeEquiv H x g 0 w).val := rfl + +end BinaryCoordinateSweeps + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/CoindFibers.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/CoindFibers.lean new file mode 100644 index 0000000000000000000000000000000000000000..15d883ec1924d92437beca9dfb251d6aa24a9eb2 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/CoindFibers.lean @@ -0,0 +1,206 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.CoinductionTools + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep + +section +open Representation + +variable {G H I W : Type*} [Group G] [Group H] + [AddCommMonoid W] [Module ℂ W] + (φ : H →* G) (σ : Representation ℂ H W) (r : I → G) + (hc : Function.Bijective (fun a : H × I => φ a.1 * r a.2)) + +def cosetEquiv : H × I ≃ G := Equiv.ofBijective _ hc + +lemma cosetEquiv_symm_mul (h : H) (g : G) : + (cosetEquiv φ r hc).symm (φ h * g) = + (h * ((cosetEquiv φ r hc).symm g).1, ((cosetEquiv φ r hc).symm g).2) := by + apply (cosetEquiv φ r hc).injective + rw [Equiv.apply_symm_apply] + change φ h * g = φ (h * _) * r _ + rw [map_mul,mul_assoc] + exact congrArg (fun a => φ h*a) ((cosetEquiv φ r hc).apply_symm_apply g).symm + +lemma cosetEquiv_symm_rep (i : I) : (cosetEquiv φ r hc).symm (r i) = (1,i) := by + apply (cosetEquiv φ r hc).injective + simp only [Equiv.apply_symm_apply, cosetEquiv, Equiv.ofBijective_apply] + simp + +def coindFiberInverse (v : I → W) : coindV φ σ := + ⟨fun g => σ ((cosetEquiv φ r hc).symm g).1 (v ((cosetEquiv φ r hc).symm g).2), by + intro h g + dsimp only + rw [cosetEquiv_symm_mul] + simp only [map_mul,Module.End.mul_apply]⟩ + +def coindFiberEquiv : coindV φ σ ≃ₗ[ℂ] (I → W) where + toFun := coindEvaluation φ σ r + invFun := coindFiberInverse φ σ r hc + left_inv f := by + ext g + change σ _ (f.val (r _)) = f.val g + rw [← f.property] + exact congrArg f.val ((cosetEquiv φ r hc).apply_symm_apply g) + right_inv v := by + funext i + change σ _ (v _) = v i + rw [cosetEquiv_symm_rep] + simp + map_add' := (coindEvaluation φ σ r).map_add + map_smul' := (coindEvaluation φ σ r).map_smul + +lemma coindFiberEquiv_action (a : G) (f : coindV φ σ) (i : I) : + coindFiberEquiv φ σ r hc (coind φ σ a f) i = + σ ((cosetEquiv φ r hc).symm (r i*a)).1 + (coindFiberEquiv φ σ r hc f ((cosetEquiv φ r hc).symm (r i*a)).2) := by + change f.val (r i*a) = σ _ (f.val (r _)) + rw [← f.property] + exact congrArg f.val ((cosetEquiv φ r hc).apply_symm_apply (r i*a)).symm + +variable {A B X : Type*} [Fintype A] [Fintype B] [Fintype X] + (e : A ⊕ B ≃ X) + +omit [Fintype X] in +lemma placement_cosets_bijective : Function.Bijective + (fun u : Equiv.Perm A × (B ↪ X) => blockPerm e u.1 * (placementSection e u.2)⁻¹) := by + constructor + · rintro ⟨a,x⟩ ⟨b,y⟩ h + have hxy : x = y := by + ext k + have he := Equiv.congr_fun (congrArg (fun g : Equiv.Perm X => g⁻¹) h) + (basePlacement e k) + simp only [mul_inv_rev,inv_inv,Equiv.Perm.mul_apply] at he + have ha : (blockPerm e a)⁻¹ (basePlacement e k) = basePlacement e k := by + rw [← map_inv]; exact blockPerm_inr e a⁻¹ k + have hb : (blockPerm e b)⁻¹ (basePlacement e k) = basePlacement e k := by + rw [← map_inv]; exact blockPerm_inr e b⁻¹ k + simpa only [ha,hb,placementSection_apply] using he + subst y + have hab : blockPerm e a = blockPerm e b := mul_right_cancel h + have hh : a = b := by + ext k + have hk := Equiv.congr_fun hab (e (Sum.inl k)) + change e (Equiv.sumCongr a 1 (e.symm (e (Sum.inl k)))) = + e (Equiv.sumCongr b 1 (e.symm (e (Sum.inl k)))) at hk + simpa only [e.symm_apply_apply,Equiv.sumCongr_apply,Sum.map_inl,Sum.inl.injEq] using e.injective hk + simp only [hh] + · intro g + obtain ⟨a,x,h⟩ := placementSection_covers e g + exact ⟨(a,x),h.symm⟩ + +end + +open Representation + +variable {G H I W : Type*} [Group G] [Group H] + [Fintype I] [NormedAddCommGroup W] [InnerProductSpace ℂ W] + (φ : H →* G) (σ : Representation ℂ H W) (r : I → G) + (hc : Function.Bijective (fun a : H × I => φ a.1 * r a.2)) + +omit [Fintype I] in +lemma cosetIndex_mul (a b : G) (i : I) : + ((cosetEquiv φ r hc).symm (r i*(a*b))).2 = + ((cosetEquiv φ r hc).symm + (r ((cosetEquiv φ r hc).symm (r i*a)).2 * b)).2 := by + have he := (cosetEquiv φ r hc).apply_symm_apply (r i*a) + change φ _ * r _ = r i*a at he + conv_lhs => rw [← mul_assoc,← he,mul_assoc,cosetEquiv_symm_mul] + +def cosetIndexAction (a : G) : I ≃ I where + toFun i := ((cosetEquiv φ r hc).symm (r i*a)).2 + invFun i := ((cosetEquiv φ r hc).symm (r i*a⁻¹)).2 + left_inv i := by dsimp only; rw [← cosetIndex_mul,mul_inv_cancel,mul_one,cosetEquiv_symm_rep] + right_inv i := by dsimp only; rw [← cosetIndex_mul,inv_mul_cancel,mul_one,cosetEquiv_symm_rep] + +abbrev CoindHilbertSpace := PiLp 2 (fun _ : I => W) + +def coindHilbertEquiv : coindV φ σ ≃ₗ[ℂ] CoindHilbertSpace (I := I) (W := W) := + (coindFiberEquiv φ σ r hc).trans (WithLp.linearEquiv 2 ℂ (I → W)).symm + +def coindHilbertRep : Representation ℂ G (CoindHilbertSpace (I := I) (W := W)) where + toFun g := (coindHilbertEquiv φ σ r hc).conj (coind φ σ g) + map_one' := by rw [map_one]; exact (coindHilbertEquiv φ σ r hc).conjRingEquiv.map_one + map_mul' a b := by rw [map_mul]; exact (coindHilbertEquiv φ σ r hc).conjRingEquiv.map_mul _ _ + +omit [Fintype I] in +lemma coindHilbertEquiv_apply (f : coindV φ σ) (i : I) : + coindHilbertEquiv φ σ r hc f i = f.val (r i) := rfl + +omit [Fintype I] in +lemma coindHilbertRep_apply (a : G) (v : CoindHilbertSpace (I := I) (W := W)) (i : I) : + coindHilbertRep φ σ r hc a v i = + σ ((cosetEquiv φ r hc).symm (r i*a)).1 + (v (cosetIndexAction φ r hc a i)) := by + obtain ⟨f,rfl⟩ := (coindHilbertEquiv φ σ r hc).surjective v + change coindHilbertEquiv φ σ r hc + (coind φ σ a ((coindHilbertEquiv φ σ r hc).symm + (coindHilbertEquiv φ σ r hc f))) i = _ + rw [LinearEquiv.symm_apply_apply] + exact coindFiberEquiv_action φ σ r hc a f i + +lemma coindHilbert_unitary (hu : ∀ h v w, inner ℂ (σ h v) (σ h w) = inner ℂ v w) + (a : G) (v w : CoindHilbertSpace (I := I) (W := W)) : + inner ℂ (coindHilbertRep φ σ r hc a v) (coindHilbertRep φ σ r hc a w) = inner ℂ v w := by + simp only [PiLp.inner_apply,coindHilbertRep_apply,hu] + exact Equiv.sum_comp (cosetIndexAction φ r hc a) (fun i => inner ℂ (v i) (w i)) + +end BinaryCoordinateSweeps.Irrep + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W V' W' : Type*} [Group G] + [AddCommMonoid V] [Module ℂ V] [AddCommMonoid W] [Module ℂ W] + [AddCommMonoid V'] [Module ℂ V'] [AddCommMonoid W'] [Module ℂ W'] + {ρ : Representation ℂ G V} {σ : Representation ℂ G W} + {ρ' : Representation ℂ G V'} {σ' : Representation ℂ G W'} + +def homCongr (e : ρ.Equiv ρ') (f : σ.Equiv σ') : + IntertwiningMap ρ σ ≃ₗ[ℂ] IntertwiningMap ρ' σ' where + toFun a := f.toIntertwiningMap.comp (a.comp e.symm.toIntertwiningMap) + invFun a := f.symm.toIntertwiningMap.comp (a.comp e.toIntertwiningMap) + left_inv a := by + ext v + change f.symm (f (a (e.symm (e v)))) = a v + rw [Representation.Equiv.symm_apply_apply,Representation.Equiv.symm_apply_apply] + right_inv a := by + ext v + change f (f.symm (a (e (e.symm v)))) = a v + rw [Representation.Equiv.apply_symm_apply,Representation.Equiv.apply_symm_apply] + map_add' a b := by + ext v + change f (a (e.symm v) + b (e.symm v)) = _ + rw [map_add] + rfl + map_smul' c a := by + ext v + change f (c • a (e.symm v)) = _ + rw [map_smul] + rfl + +lemma multiplicity_congr (e : ρ.Equiv ρ') (f : σ.Equiv σ') : + Module.finrank ℂ (IntertwiningMap ρ σ) = Module.finrank ℂ (IntertwiningMap ρ' σ') := + (homCongr e f).finrank_eq + +def repEquiv_comp {H : Type*} [Group H] (e : ρ.Equiv ρ') (φ : H →* G) : + Representation.Equiv (ρ.comp φ) (ρ'.comp φ) := + .mk e.toLinearEquiv (fun h => e.isIntertwining' (φ h)) + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/CoinductionTools.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/CoinductionTools.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1139912565f3b2f99f1de55acf0519034b3fac5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/CoinductionTools.lean @@ -0,0 +1,190 @@ +import Mathlib + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G H V W : Type*} [Group G] [Group H] + [AddCommMonoid V] [Module ℂ V] [AddCommMonoid W] [Module ℂ W] + (φ : H →* G) (ρ : Representation ℂ G V) (σ : Representation ℂ H W) + +def toCoind (f : IntertwiningMap (ρ.comp φ) σ) : IntertwiningMap ρ (coind φ σ) where + toLinearMap := { + toFun := fun v => ⟨fun g => f (ρ g v), by + intro h g + change f (ρ (φ h * g) v) = σ h (f (ρ g v)) + rw [map_mul,Module.End.mul_apply] + exact IntertwiningMap.isIntertwining _ _ f h (ρ g v)⟩ + map_add' := by intro a b; ext g; simp only [map_add]; rfl + map_smul' := by intro c a; ext g; simp only [map_smul]; rfl } + isIntertwining' a := by + ext v g + change f (ρ g (ρ a v)) = f (ρ (g*a) v) + rw [map_mul,Module.End.mul_apply] + +def fromCoind (f : IntertwiningMap ρ (coind φ σ)) : IntertwiningMap (ρ.comp φ) σ where + toLinearMap := { + toFun := fun v => (f v).val 1 + map_add' := by intros; simp only [map_add]; rfl + map_smul' := by intros; simp only [map_smul]; rfl } + isIntertwining' h := by + ext v + have he := congrArg (fun u : coindV φ σ => u.val 1) + (IntertwiningMap.isIntertwining _ _ f (φ h) v) + change (f (ρ (φ h) v)).val 1 = σ h ((f v).val 1) + rw [he] + change (f v).val (1*φ h) = _ + simpa only [one_mul,mul_one] using (f v).property h 1 + +def coindHomEquiv : IntertwiningMap (ρ.comp φ) σ ≃ₗ[ℂ] IntertwiningMap ρ (coind φ σ) where + toFun := toCoind φ ρ σ + invFun := fromCoind φ ρ σ + left_inv f := by ext v; change f (ρ 1 v) = f v; simp + right_inv f := by + ext v g + change (f (ρ g v)).val 1 = (f v).val g + rw [IntertwiningMap.isIntertwining] + change (f v).val (1*g) = _ + rw [one_mul] + map_add' a b := by ext v g; rfl + map_smul' c a := by ext v g; rfl + +variable [Fintype G] [Fintype H] [Module.Finite ℂ V] [Module.Finite ℂ W] + +lemma multiplicity_symm (σ : Representation ℂ G W) : + Module.finrank ℂ (IntertwiningMap ρ σ) = Module.finrank ℂ (IntertwiningMap σ ρ) := by + let : AddCommGroup V := Module.addCommMonoidToAddCommGroup ℂ + let : AddCommGroup W := Module.addCommMonoidToAddCommGroup ℂ + let : Invertible (Nat.card G : ℂ) := invertibleOfNonzero (by exact_mod_cast Nat.card_pos.ne') + have h₁ := card_inv_mul_sum_char_mul_char_eq_finrank ρ σ + have h₂ := card_inv_mul_sum_char_mul_char_eq_finrank σ ρ + have he : ∑ g : G, σ.character g * ρ.character g⁻¹ = + ∑ g : G, ρ.character g * σ.character g⁻¹ := by + rw [← Equiv.sum_comp (Equiv.inv G) (fun g => ρ.character g * σ.character g⁻¹)] + simp only [Equiv.inv_apply,inv_inv,mul_comm] + apply Nat.cast_injective (R := ℂ) + exact h₁.symm.trans ((congrArg (fun z : ℂ => (Nat.card G : ℂ)⁻¹*z) he).trans h₂) + +def coindEvaluation {I : Type*} (r : I → G) : coindV φ σ →ₗ[ℂ] (I → W) where + toFun := fun f i => f.val (r i) + map_add' := by intros; rfl + map_smul' := by intros; rfl + +omit [Fintype G] [Fintype H] [Module.Finite ℂ W] in +lemma coindEvaluation_injective {I : Type*} (r : I → G) + (hr : ∀ g : G, ∃ h : H, ∃ i : I, g = φ h * r i) : + Function.Injective (coindEvaluation φ σ r) := by + intro f a he + apply Subtype.ext + funext g + obtain ⟨h,i,rfl⟩ := hr g + rw [f.property,a.property] + exact congrArg (σ h) (congrFun he i) + +omit [Fintype G] [Fintype H] in +lemma coind_finrank_le {I : Type*} [Fintype I] (r : I → G) + (hr : ∀ g : G, ∃ h : H, ∃ i : I, g = φ h * r i) : + Module.finrank ℂ (coindV φ σ) ≤ Fintype.card I * Module.finrank ℂ W := by + let : AddCommGroup W := Module.addCommMonoidToAddCommGroup ℂ + simpa only [Module.finrank_pi_fintype,Finset.sum_const,Finset.card_univ,smul_eq_mul] using + (LinearMap.finrank_le_finrank_of_injective (coindEvaluation_injective φ σ r hr)) + +end BinaryCoordinateSweeps.Irrep + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation Equiv Equiv.Perm + +variable {A B X : Type*} [Fintype A] [Fintype B] [Fintype X] + (e : A ⊕ B ≃ X) + +def blockPerm : Equiv.Perm A →* Equiv.Perm X := + e.permCongrHom.toMonoidHom.comp ((sumCongrHom A B).comp (MonoidHom.inl _ _)) + +omit [Fintype A] [Fintype B] [Fintype X] in +lemma blockPerm_inr (a : Equiv.Perm A) (b : B) : + blockPerm e a (e (Sum.inr b)) = e (Sum.inr b) := by + change e (Equiv.sumCongr a (1:Equiv.Perm B) (e.symm (e (Sum.inr b)))) = _ + rw [e.symm_apply_apply] + rfl + +omit [Fintype X] in +lemma blockPerm_of_fixed (g : Equiv.Perm X) (hg : ∀ b, g (e (Sum.inr b)) = e (Sum.inr b)) : + ∃ a : Equiv.Perm A, blockPerm e a = g := by + let d := e.symm.permCongr g + have hd (b : B) : d (Sum.inr b) = Sum.inr b := by + change e.symm (g (e (Sum.inr b))) = _ + rw [hg,e.symm_apply_apply] + have hh : d ∈ (sumCongrHom A B).range := by + apply mem_sumCongrHom_range_of_perm_mapsTo_inl + apply (perm_mapsTo_inl_iff_mapsTo_inr d).mpr + rintro y ⟨b,rfl⟩ + exact ⟨b,(hd b).symm⟩ + obtain ⟨⟨a,b⟩,hab⟩ := hh + have hb : b = 1 := by + ext x + have hx := Equiv.congr_fun hab (Sum.inr x) + rw [hd] at hx + exact Sum.inr_injective hx + subst b + refine ⟨a,?_⟩ + change e.permCongr ((sumCongrHom A B) (a,1)) = g + have he := congrArg e.permCongr hab + simpa only [d,← Equiv.permCongr_symm,Equiv.apply_symm_apply] using he + +def basePlacement : B ↪ X := ⟨fun b => e (Sum.inr b), e.injective.comp Sum.inr_injective⟩ + +omit [Fintype A] [Fintype X] in +lemma placement_extension (x : B ↪ X) : ∃ g : Equiv.Perm X, ∀ b, g (basePlacement e b) = x b := + Equiv.Perm.exists_extending_pair (basePlacement e) x (basePlacement e).injective x.injective + +def placementSection (x : B ↪ X) : Equiv.Perm X := (placement_extension e x).choose + +omit [Fintype A] [Fintype X] in +lemma placementSection_apply (x : B ↪ X) (b : B) : + placementSection e x (basePlacement e b) = x b := (placement_extension e x).choose_spec b + +omit [Fintype X] in +lemma placementSection_covers (g : Equiv.Perm X) : + ∃ a : Equiv.Perm A, ∃ x : B ↪ X, g = blockPerm e a * (placementSection e x)⁻¹ := by + let x : B ↪ X := (basePlacement e).trans g.symm.toEmbedding + have hx : ∀ b, (g*placementSection e x) (e (Sum.inr b)) = e (Sum.inr b) := by + intro b + change g (placementSection e x (basePlacement e b)) = _ + rw [placementSection_apply] + exact g.apply_symm_apply _ + obtain ⟨a,ha⟩ := blockPerm_of_fixed e (g*placementSection e x) hx + exact ⟨a,x,by rw [ha,mul_inv_cancel_right]⟩ + +variable {W : Type*} [AddCommMonoid W] [Module ℂ W] [Module.Finite ℂ W] + (σ : Representation ℂ (Equiv.Perm A) W) + +theorem placement_coind_finrank : + Module.finrank ℂ (coindV (blockPerm e) σ) ≤ + Fintype.card (B ↪ X) * Module.finrank ℂ W := + coind_finrank_le (blockPerm e) σ (fun x => (placementSection e x)⁻¹) + (placementSection_covers e) + +theorem placement_coind_finrank_pow : + Module.finrank ℂ (coindV (blockPerm e) σ) ≤ + (Fintype.card X)^(Fintype.card B) * Module.finrank ℂ W := by + apply (placement_coind_finrank e σ).trans + apply Nat.mul_le_mul_right + simpa only [Fintype.card_fun] using + Fintype.card_le_of_injective (fun x : B ↪ X => (x : B → X)) DFunLike.coe_injective + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/CutBranching.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/CutBranching.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca0b402b220c01ca9e0f163acd6a86423579d836 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/CutBranching.lean @@ -0,0 +1,184 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.CoinductionTools +import OAI.Probability.BinarySweep.YoungTheory.CutTensor + +namespace OAI + +noncomputable section + +namespace BinaryCoordinateSweeps.Young + +local instance (ν : YoungDiagram) : Module.Finite ℂ (SpechtSpace ν) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace ν)) + +local instance (ν : YoungDiagram) : + @Module.IsTorsionFree ℂ (SpechtSpace ν) _ + (SpechtSpace.instAddCommGroup ν).toAddCommMonoid inferInstance := + DivisionSemiring.to_moduleIsTorsionFree + +local instance {G V W : Type*} [Monoid G] [AddCommMonoid V] [Module ℂ V] + [AddCommMonoid W] [Module ℂ W] [Module.Finite ℂ V] [Module.Finite ℂ W] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) : + Module.Finite ℂ (Representation.IntertwiningMap ρ σ) := by + let : AddCommGroup V := Module.addCommMonoidToAddCommGroup ℂ + let : AddCommGroup W := Module.addCommMonoidToAddCommGroup ℂ + exact Module.Finite.of_injective (Representation.IntertwiningMap.toLinearMapl (ρ := ρ) (σ := σ)) + (Representation.IntertwiningMap.toLinearMap_injective ρ σ) + +section + +open scoped BigOperators Classical TensorProduct + +open Representation + +variable (μ : YoungDiagram) (p : ℕ) + +abbrev CutGroup := G (hookPart μ p) × G (southeast μ p) + +def cutSpechtRep : Representation ℂ (CutGroup μ p) (CutTensor μ p) := + Representation.tprod ((spechtRep (hookPart μ p)).comp (MonoidHom.fst _ _)) + ((spechtRep (southeast μ p)).comp (MonoidHom.snd _ _)) + +lemma cutSpechtRep_tmul (g : CutGroup μ p) (v : SpechtSpace (hookPart μ p)) + (w : SpechtSpace (southeast μ p)) : + cutSpechtRep μ p g (v ⊗ₜ[ℂ] w) = + spechtRep (hookPart μ p) g.1 v ⊗ₜ[ℂ] spechtRep (southeast μ p) g.2 w := rfl + +def cutTabloidRep : Representation ℂ (CutGroup μ p) (CutTabloids μ p → ℂ) where + toFun g := { + toFun := fun v t => v (g.1⁻¹ • t.1, g.2⁻¹ • t.2) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v t; simp + map_mul' g d := by ext v t; simp [mul_smul] + +lemma cutRestriction_rep (g : CutGroup μ p) (v : SpechtSpace μ) : + cutRestriction μ p (spechtRep μ (cutPerm μ p g) v) = + cutTabloidRep μ p g (cutRestriction μ p v) := by + ext t + change spechtInclude μ (spechtRep μ (cutPerm μ p g) v) (glueTabloid μ p t) = + spechtInclude μ v (glueTabloid μ p (g.1⁻¹ • t.1,g.2⁻¹ • t.2)) + rw [spechtInclude_rep,tabloidRepresentation_apply,← map_inv,← glueTabloid_smul] + rfl + +lemma cutTensorInclude_rep (g : CutGroup μ p) (v : CutTensor μ p) : + cutTensorInclude μ p (cutSpechtRep μ p g v) = + cutTabloidRep μ p g (cutTensorInclude μ p v) := by + induction v using TensorProduct.inductionOn with + | tmul v w => + ext t + rw [cutSpechtRep_tmul,cutTensorInclude_tmul,spechtInclude_rep,spechtInclude_rep] + rfl + | add u v hu hv => simp only [map_add,hu,hv] + +def cutRestrictionIntertwiner : IntertwiningMap + ((spechtRep μ).comp (cutPerm μ p)) (cutTabloidRep μ p) where + toLinearMap := cutRestriction μ p + isIntertwining' g := LinearMap.ext (cutRestriction_rep μ p g) + +def cutTensorIntertwiner : IntertwiningMap (cutSpechtRep μ p) (cutTabloidRep μ p) where + toLinearMap := cutTensorInclude μ p + isIntertwining' g := LinearMap.ext (cutTensorInclude_rep μ p g) + +theorem hook_removal_embedding : + ∃ l : IntertwiningMap (cutSpechtRep μ p) ((spechtRep μ).comp (cutPerm μ p)), + Function.Injective l := by + obtain ⟨l,hl⟩ := Irrep.lift_intertwiner _ _ _ + (cutRestrictionIntertwiner μ p) (cutTensorIntertwiner μ p) (cutTensor_range_le μ p) + refine ⟨l,?_⟩ + intro v w h + apply cutTensorInclude_injective μ p + exact (hl v).symm.trans ((congrArg (cutRestrictionIntertwiner μ p) h).trans (hl w)) + +def hookPerm : G (hookPart μ p) →* G μ := + (cutPerm μ p).comp (MonoidHom.inl _ _) + +def hookRestriction : Representation ℂ (G (hookPart μ p)) (SpechtSpace μ) := + (spechtRep μ).comp (hookPerm μ p) + +def cutSlice (l : IntertwiningMap (cutSpechtRep μ p) ((spechtRep μ).comp (cutPerm μ p))) + (w : SpechtSpace (southeast μ p)) : + IntertwiningMap (spechtRep (hookPart μ p)) (hookRestriction μ p) where + toLinearMap := { + toFun := fun v => l (v ⊗ₜ[ℂ] w) + map_add' := by intro a b; rw [TensorProduct.add_tmul,map_add] + map_smul' := by intro c a; rw [← TensorProduct.smul_tmul',map_smul]; rfl } + isIntertwining' g := by + ext v + have hh := IntertwiningMap.isIntertwining _ _ l (g,1) (v ⊗ₜ[ℂ] w) + rw [cutSpechtRep_tmul,map_one,Module.End.one_apply] at hh + exact hh + +def cutSliceMap (l : IntertwiningMap (cutSpechtRep μ p) ((spechtRep μ).comp (cutPerm μ p))) : + SpechtSpace (southeast μ p) →ₗ[ℂ] + IntertwiningMap (spechtRep (hookPart μ p)) (hookRestriction μ p) where + toFun := cutSlice μ p l + map_add' a b := by ext v; exact (congrArg l (TensorProduct.tmul_add _ _ _)).trans (map_add l _ _) + map_smul' c a := by ext v; exact (congrArg l (TensorProduct.tmul_smul c v a)).trans (map_smul l _ _) + +lemma cutSliceMap_injective + (l : IntertwiningMap (cutSpechtRep μ p) ((spechtRep μ).comp (cutPerm μ p))) + (hl : Function.Injective l) : Function.Injective (cutSliceMap μ p l) := by + intro w z h + have hh := DFunLike.congr_fun h (spechtPoly (hookPart μ p)) + change l (_ ⊗ₜ[ℂ] w) = l (_ ⊗ₜ[ℂ] z) at hh + have he := congrArg (cutTensorInclude μ p) (hl hh) + apply spechtInclude_injective (southeast μ p) + ext t + have ht := congrFun he (tabloidOfPerm (hookPart μ p) 1,t) + simpa only [cutTensorInclude_tmul,spechtInclude_poly,polytabloid_base,one_mul] using ht + +theorem hook_removal_multiplicity : + Module.finrank ℂ (SpechtSpace (southeast μ p)) ≤ + Module.finrank ℂ (IntertwiningMap (spechtRep (hookPart μ p)) (hookRestriction μ p)) := by + obtain ⟨l,hl⟩ := hook_removal_embedding μ p + exact LinearMap.finrank_le_finrank_of_injective (cutSliceMap_injective μ p l hl) + +end + +open scoped BigOperators Classical + +open Representation + +variable (μ : YoungDiagram) (p : ℕ) + +abbrev HookInducedSpace := coindV (hookPerm μ p) (spechtRep (hookPart μ p)) + +def hookInducedRep : Representation ℂ (G μ) (HookInducedSpace μ p) := + coind (hookPerm μ p) (spechtRep (hookPart μ p)) + +lemma hookPerm_block : hookPerm μ p = Irrep.blockPerm (cutEquiv μ p) := rfl + +theorem hook_induced_multiplicity : + Module.finrank ℂ (SpechtSpace (southeast μ p)) ≤ + Module.finrank ℂ (IntertwiningMap (spechtRep μ) (hookInducedRep μ p)) := by + have he := (Irrep.coindHomEquiv (hookPerm μ p) (spechtRep μ) + (spechtRep (hookPart μ p))).finrank_eq + have hs := Irrep.multiplicity_symm (spechtRep (hookPart μ p)) (hookRestriction μ p) + change Module.finrank ℂ (IntertwiningMap (spechtRep (hookPart μ p)) (hookRestriction μ p)) = + Module.finrank ℂ (IntertwiningMap (hookRestriction μ p) (spechtRep (hookPart μ p))) at hs + exact (hook_removal_multiplicity μ p).trans (by rw [hs]; exact Nat.le_of_eq he) + +lemma hook_induced_dimension : + Module.finrank ℂ (SpechtSpace μ) ≤ Module.finrank ℂ (HookInducedSpace μ p) := by + have hp : 0 < Module.finrank ℂ (SpechtSpace (southeast μ p)) := + Module.finrank_pos_iff_exists_ne_zero.mpr ⟨spechtPoly _,spechtPoly_ne_zero _⟩ + let : AddCommGroup (HookInducedSpace μ p) := Module.addCommMonoidToAddCommGroup ℂ + have hi := lt_of_lt_of_le hp (hook_induced_multiplicity μ p) + obtain ⟨f,hf⟩ := Module.finrank_pos_iff_exists_ne_zero.mp hi + exact LinearMap.finrank_le_finrank_of_injective + ((IsIrreducible.injective_or_eq_zero f).resolve_right hf) + +theorem hook_removal_dimension_upper : + Module.finrank ℂ (SpechtSpace μ) ≤ + (Fintype.card (Cell μ))^(Fintype.card (Cell (southeast μ p))) * + Module.finrank ℂ (SpechtSpace (hookPart μ p)) := by + apply (hook_induced_dimension μ p).trans + change Module.finrank ℂ (coindV (hookPerm μ p) _) ≤ _ + exact Irrep.placement_coind_finrank_pow (cutEquiv μ p) (spechtRep (hookPart μ p)) + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/CutColumns.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/CutColumns.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f7dbb4ba9eb0bc5eed9b5b544175e8ceace86e5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/CutColumns.lean @@ -0,0 +1,162 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.HookCut + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +section +open Equiv Equiv.Perm + +variable (μ : YoungDiagram) (p : ℕ) + +lemma cutPerm_mem_column_iff (g : G (hookPart μ p) × G (southeast μ p)) : + cutPerm μ p g ∈ C μ ↔ g.1 ∈ C (hookPart μ p) ∧ g.2 ∈ C (southeast μ p) := by + constructor + · intro h + constructor + · intro x + simpa only [cutPerm_apply_hook,col_hookIn] using h (hookIn μ p x) + · intro x + simpa only [cutPerm_apply_southeast,col_southeastIn,Nat.add_right_cancel_iff] using + h (southeastIn μ p x) + · rintro ⟨h1,h2⟩ x + obtain ⟨y,rfl⟩ := (cutEquiv μ p).surjective x + cases y with + | inl y => simpa only [cutEquiv_inl,cutPerm_apply_hook,col_hookIn] using h1 y + | inr y => simpa only [cutEquiv_inr,cutPerm_apply_southeast,col_southeastIn] using + congrArg (fun k : ℕ => k+p) (h2 y) + +def cutColumns : C (hookPart μ p) × C (southeast μ p) ↪ C μ where + toFun g := ⟨cutPerm μ p (g.1.val,g.2.val), (cutPerm_mem_column_iff μ p _).mpr ⟨g.1.property,g.2.property⟩⟩ + inj' a b h := by + have hh := cutPerm_injective μ p (congrArg (fun c : C μ => c.val) h) + exact Prod.ext (Subtype.ext (congrArg Prod.fst hh)) (Subtype.ext (congrArg Prod.snd hh)) + +lemma column_glue_in_range (c : C μ) + (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) + (he : tabloidOfPerm μ c.val = glueTabloid μ p t) : c ∈ Set.range (cutColumns μ p) := by + let q := (cutEquiv μ p).symm.permCongr c.val⁻¹ + have hinr : Set.MapsTo q (Set.range Sum.inr) (Set.range Sum.inr) := by + rintro x ⟨y,rfl⟩ + have hh := congrArg (fun v : Tabloid μ => v.val (southeastIn μ p y)) he + change row (c.val⁻¹ (southeastIn μ p y)) = glueLabels μ p t (southeastIn μ p y) at hh + rw [glueLabels_southeast] at hh + have hc := (C μ).inv_mem c.property (southeastIn μ p y) + rcases hq : q (Sum.inr y) with a | b + · have hcell : c.val⁻¹ (southeastIn μ p y) = hookIn μ p a := by + have h := congrArg (cutEquiv μ p) hq + simpa only [q,Equiv.permCongr_apply,Equiv.symm_symm, + Equiv.apply_symm_apply,cutEquiv_inr,cutEquiv_inl] using h + rw [hcell,row_hookIn] at hh + rw [hcell,col_hookIn,col_southeastIn] at hc + have ha := hookPart_inHook μ p a + omega + · exact ⟨b,rfl⟩ + have hq := mem_sumCongrHom_range_of_perm_mapsTo_inl + ((perm_mapsTo_inl_iff_mapsTo_inr q).mpr hinr) + obtain ⟨g,hg⟩ := hq + have hinv : cutPerm μ p g = c.val⁻¹ := by + change (cutEquiv μ p).permCongr (sumCongrHom _ _ g) = _ + rw [hg] + exact (cutEquiv μ p).permCongr.apply_symm_apply _ + have hg' : cutPerm μ p g⁻¹ = c.val := by rw [map_inv,hinv,inv_inv] + have hgcol := (cutPerm_mem_column_iff μ p g⁻¹).mp (hg' ▸ c.property) + refine ⟨(⟨g⁻¹.1,hgcol.1⟩,⟨g⁻¹.2,hgcol.2⟩),?_⟩ + apply Subtype.ext + exact hg' + +end + +variable (μ : YoungDiagram) (p : ℕ) + +lemma polytabloid_coefficient (t : Tabloid μ) : + polytabloid μ t = ∑ c : C μ, if t = tabloidOfPerm μ c.val then signC μ c.val else 0 := by + rw [polytabloid,columnAnti_apply] + simp_rw [rep_basis,smul_tabloidOfPerm,mul_one] + simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul,tabloidBasis,Pi.single_apply] + apply Finset.sum_congr rfl + intro c _ + split_ifs <;> simp + +lemma cut_column_coefficient (a : C (hookPart μ p) × C (southeast μ p)) + (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) : + (if glueTabloid μ p t = tabloidOfPerm μ (cutColumns μ p a).val + then signC μ (cutColumns μ p a).val else 0) = + (if t.1 = tabloidOfPerm (hookPart μ p) a.1.val then signC (hookPart μ p) a.1.val else 0) * + (if t.2 = tabloidOfPerm (southeast μ p) a.2.val then signC (southeast μ p) a.2.val else 0) := by + change (if glueTabloid μ p t = tabloidOfPerm μ (cutPerm μ p (a.1.val,a.2.val)) + then signC μ (cutPerm μ p (a.1.val,a.2.val)) else 0) = _ + simp only [← glueTabloid_perm, (glueTabloid_injective μ p).eq_iff,Prod.ext_iff,signC_cutPerm] + split_ifs <;> simp_all + +theorem polytabloid_glue (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) : + polytabloid μ (glueTabloid μ p t) = + polytabloid (hookPart μ p) t.1 * polytabloid (southeast μ p) t.2 := by + rw [polytabloid_coefficient] + let e := cutColumns μ p + let f : C μ → ℂ := fun c => + if glueTabloid μ p t = tabloidOfPerm μ c.val then signC μ c.val else 0 + change ∑ c, f c = _ + have hs : ∑ c ∈ Finset.univ.image e, f c = ∑ c, f c := by + apply Finset.sum_subset (Finset.subset_univ _) + intro c _ hc + have hn : glueTabloid μ p t ≠ tabloidOfPerm μ c.val := by + intro he + obtain ⟨a,ha⟩ := column_glue_in_range μ p c t he.symm + apply hc + exact Finset.mem_image.mpr ⟨a,Finset.mem_univ _,ha⟩ + exact ite_eq_right hn + rw [← hs,Finset.sum_image e.injective.injOn] + change (∑ a, if glueTabloid μ p t = tabloidOfPerm μ (cutColumns μ p a).val + then signC μ (cutColumns μ p a).val else 0) = _ + simp_rw [cut_column_coefficient] + rw [Fintype.sum_prod_type,polytabloid_coefficient,polytabloid_coefficient,Finset.sum_mul_sum] + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V : Type*} [Group G] [AddCommGroup V] [Module ℂ V] + (ρ : Representation ℂ G V) [ρ.IsIrreducible] + +lemma span_orbit_eq_top (v : V) (hv : v ≠ 0) : + Submodule.span ℂ (Set.range (fun g : G => ρ g v)) = ⊤ := by + let U : Subrepresentation ρ := { + toSubmodule := Submodule.span ℂ (Set.range (fun g : G => ρ g v)) + apply_mem_toSubmodule := by + intro g w hw + induction hw using Submodule.span_induction with + | mem x hx => + obtain ⟨h,rfl⟩ := hx + rw [← Module.End.mul_apply,← map_mul] + exact Submodule.subset_span ⟨g*h,rfl⟩ + | zero => simpa only [map_zero] using Submodule.zero_mem _ + | add x y hx hy hx' hy' => simpa only [map_add] using Submodule.add_mem _ hx' hy' + | smul c x hx hx' => simpa only [map_smul] using Submodule.smul_mem _ c hx' } + have hvm : v ∈ U := by + change v ∈ Submodule.span ℂ (Set.range (fun g : G => ρ g v)) + apply Submodule.subset_span + exact ⟨1,by simp⟩ + rcases eq_bot_or_eq_top U with h | h + · have hem : v ∈ (⊥ : Subrepresentation ρ) := h ▸ hvm + have hv0 : v = 0 := hem + exact (hv hv0).elim + · exact congrArg Subrepresentation.toSubmodule h + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/CutTensor.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/CutTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..53d3cce3ef03ce195b97fe45bdba8b5bde87bba9 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/CutTensor.lean @@ -0,0 +1,193 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.CutColumns + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical TensorProduct + +namespace BinaryCoordinateSweeps.Young +lemma tensor_map_injective_complex {V W X Y : Type*} + [AddCommMonoid V] [Module ℂ V] [AddCommMonoid W] [Module ℂ W] + [AddCommMonoid X] [Module ℂ X] [AddCommMonoid Y] [Module ℂ Y] + (f : V →ₗ[ℂ] X) (g : W →ₗ[ℂ] Y) + (hf : Function.Injective f) (hg : Function.Injective g) : + Function.Injective (TensorProduct.map f g) := by + let : AddCommGroup X := Module.addCommMonoidToAddCommGroup ℂ + let : AddCommGroup W := Module.addCommMonoidToAddCommGroup ℂ + exact TensorProduct.map_injective_of_flat_flat f g hf hg + +variable (μ : YoungDiagram) (p : ℕ) + +abbrev CutTensor := SpechtSpace (hookPart μ p) ⊗[ℂ] SpechtSpace (southeast μ p) +abbrev CutTabloids := Tabloid (hookPart μ p) × Tabloid (southeast μ p) + +def cutTensorInclude : CutTensor μ p →ₗ[ℂ] (CutTabloids μ p → ℂ) := + TensorProduct.lift { + toFun := fun v => { + toFun := fun w t => spechtInclude (hookPart μ p) v t.1 * spechtInclude (southeast μ p) w t.2 + map_add' := by intro a b; ext t; simp only [map_add,Pi.add_apply,mul_add] + map_smul' := by intro c a; ext t; simp only [map_smul,Pi.smul_apply,smul_eq_mul,RingHom.id_apply]; ring } + map_add' := by intro a b; ext w t; simp only [map_add,Pi.add_apply,add_mul,LinearMap.add_apply,LinearMap.coe_mk,AddHom.coe_mk] + map_smul' := by intro c a; ext w t; simp only [map_smul,Pi.smul_apply,smul_eq_mul,LinearMap.smul_apply,LinearMap.coe_mk,AddHom.coe_mk,RingHom.id_apply]; ring } + +@[simp] lemma cutTensorInclude_tmul (v : SpechtSpace (hookPart μ p)) + (w : SpechtSpace (southeast μ p)) (t : CutTabloids μ p) : + cutTensorInclude μ p (v ⊗ₜ[ℂ] w) t = + spechtInclude (hookPart μ p) v t.1 * spechtInclude (southeast μ p) w t.2 := rfl + +lemma cutTensorInclude_injective : Function.Injective (cutTensorInclude μ p) := by + let T := TensorProduct.map (spechtInclude (hookPart μ p)) (spechtInclude (southeast μ p)) + have hT : Function.Injective T := tensor_map_injective_complex + (spechtInclude (hookPart μ p)) (spechtInclude (southeast μ p)) + (spechtInclude_injective (hookPart μ p)) (spechtInclude_injective (southeast μ p)) + let E := TensorProduct.piScalarRight ℂ ℂ (Tabloid (hookPart μ p) → ℂ) (Tabloid (southeast μ p)) + have hE (u : CutTensor μ p) (t : CutTabloids μ p) : + E (T u) t.2 t.1 = cutTensorInclude μ p u t := by + induction u using TensorProduct.inductionOn with + | tmul v w => + change E (spechtInclude _ v ⊗ₜ[ℂ] spechtInclude _ w) t.2 t.1 = _ + simp only [cutTensorInclude_tmul,E,TensorProduct.piScalarRight_apply, + TensorProduct.piScalarRightHom_tmul,Pi.smul_apply,smul_eq_mul] + exact mul_comm _ _ + | add u v hu hv => simp only [map_add,Pi.add_apply,hu,hv] + intro u v h + apply hT + apply E.injective + ext s t + exact (hE u (t,s)).trans ((congrFun h (t,s)).trans (hE v (t,s)).symm) + +def cutRestriction : SpechtSpace μ →ₗ[ℂ] (CutTabloids μ p → ℂ) where + toFun v t := spechtInclude μ v (glueTabloid μ p t) + map_add' a b := by ext t; simp + map_smul' c a := by ext t; simp + +lemma cutRestriction_poly : + cutRestriction μ p (spechtPoly μ) = + cutTensorInclude μ p (spechtPoly (hookPart μ p) ⊗ₜ[ℂ] spechtPoly (southeast μ p)) := by + ext t + change spechtInclude μ (spechtPoly μ) (glueTabloid μ p t) = _ + simp only [spechtInclude_poly,polytabloid_glue,cutTensorInclude_tmul] + +lemma cutRestriction_translate (g : G (hookPart μ p) × G (southeast μ p)) : + cutRestriction μ p (spechtRep μ (cutPerm μ p g) (spechtPoly μ)) = + cutTensorInclude μ p + (spechtRep (hookPart μ p) g.1 (spechtPoly (hookPart μ p)) ⊗ₜ[ℂ] + spechtRep (southeast μ p) g.2 (spechtPoly (southeast μ p))) := by + ext t + change spechtInclude μ (spechtRep μ (cutPerm μ p g) (spechtPoly μ)) + (glueTabloid μ p t) = _ + rw [spechtInclude_rep,tabloidRepresentation_apply,← map_inv,← glueTabloid_smul, + spechtInclude_poly,polytabloid_glue,cutTensorInclude_tmul, + spechtInclude_rep,spechtInclude_rep] + rfl + +lemma cut_tensor_orbit_mem_range (g : G (hookPart μ p)) (d : G (southeast μ p)) : + cutTensorInclude μ p (spechtRep (hookPart μ p) g (spechtPoly (hookPart μ p)) ⊗ₜ[ℂ] + spechtRep (southeast μ p) d (spechtPoly (southeast μ p))) ∈ + LinearMap.range (cutRestriction μ p) := + ⟨spechtRep μ (cutPerm μ p (g,d)) (spechtPoly μ),cutRestriction_translate μ p (g,d)⟩ + +private lemma spechtPoly_span_top (ν : YoungDiagram) : + Submodule.span ℂ (Set.range (fun g : G ν => spechtRep ν g (spechtPoly ν))) = ⊤ := + Irrep.span_orbit_eq_top (spechtRep ν) (spechtPoly ν) (spechtPoly_ne_zero ν) + +lemma cut_tensor_tmul_mem_range (v : SpechtSpace (hookPart μ p)) + (w : SpechtSpace (southeast μ p)) : + cutTensorInclude μ p (v ⊗ₜ[ℂ] w) ∈ LinearMap.range (cutRestriction μ p) := by + have hv : v ∈ Submodule.span ℂ (Set.range (fun g : G (hookPart μ p) => + spechtRep (hookPart μ p) g (spechtPoly (hookPart μ p)))) := by + rw [spechtPoly_span_top] + trivial + induction hv using Submodule.span_induction with + | mem x hx => + obtain ⟨g,rfl⟩ := hx + have hw : w ∈ Submodule.span ℂ (Set.range (fun d : G (southeast μ p) => + spechtRep (southeast μ p) d (spechtPoly (southeast μ p)))) := by + rw [spechtPoly_span_top] + trivial + induction hw using Submodule.span_induction with + | mem y hy => obtain ⟨d,rfl⟩ := hy; exact cut_tensor_orbit_mem_range μ p g d + | zero => simp + | add x y hx hy hx' hy' => simpa only [TensorProduct.tmul_add,map_add] using Submodule.add_mem _ hx' hy' + | smul c x hx hx' => simpa only [TensorProduct.tmul_smul,map_smul] using Submodule.smul_mem _ c hx' + | zero => simp + | add x y hx hy hx' hy' => simpa only [TensorProduct.add_tmul,map_add] using Submodule.add_mem _ hx' hy' + | smul c x hx hx' => simpa only [← TensorProduct.smul_tmul',map_smul] using Submodule.smul_mem _ c hx' + +theorem cutTensor_range_le : LinearMap.range (cutTensorInclude μ p) ≤ + LinearMap.range (cutRestriction μ p) := by + rintro _ ⟨u,rfl⟩ + induction u using TensorProduct.inductionOn with + | tmul v w => exact cut_tensor_tmul_mem_range μ p v w + | add u v hu hv => simpa only [map_add] using Submodule.add_mem _ hu hv + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G V W P : Type*} [Group G] [Fintype G] + [AddCommMonoid V] [Module ℂ V] [AddCommMonoid W] [Module ℂ W] + [AddCommMonoid P] [Module ℂ P] + (ρ : Representation ℂ G V) (σ : Representation ℂ G W) (τ : Representation ℂ G P) + +def averageLinear (l : P →ₗ[ℂ] V) : P →ₗ[ℂ] V := + (Fintype.card G : ℂ)⁻¹ • ∑ g : G, (ρ g⁻¹).comp (l.comp (τ g)) + +lemma averageLinear_apply (l : P →ₗ[ℂ] V) (v : P) : + averageLinear ρ τ l v = (Fintype.card G : ℂ)⁻¹ • ∑ g : G, ρ g⁻¹ (l (τ g v)) := by + simp only [averageLinear,LinearMap.smul_apply,LinearMap.sum_apply,LinearMap.comp_apply] + +lemma averageLinear_intertwines (l : P →ₗ[ℂ] V) (a : G) (v : P) : + averageLinear ρ τ l (τ a v) = ρ a (averageLinear ρ τ l v) := by + simp only [averageLinear_apply,map_smul,map_sum,← Module.End.mul_apply,← map_mul] + congr 1 + have hh := Equiv.sum_comp (Equiv.mulRight a) (fun g : G => + ρ (a*g⁻¹) (l (τ g v))) + rw [← hh] + apply Finset.sum_congr rfl + intro g _ + simp only [Equiv.coe_mulRight,mul_inv_rev,mul_inv_cancel_left] + +def averagedIntertwiner (l : P →ₗ[ℂ] V) : IntertwiningMap τ ρ where + toLinearMap := averageLinear ρ τ l + isIntertwining' a := LinearMap.ext (averageLinear_intertwines ρ τ l a) + +lemma averageLinear_lift (l : P →ₗ[ℂ] V) (f : IntertwiningMap ρ σ) + (g : IntertwiningMap τ σ) (hl : ∀ v, f (l v) = g v) (v : P) : + f (averageLinear ρ τ l v) = g v := by + rw [averageLinear_apply,map_smul,map_sum] + simp only [hl,IntertwiningMap.isIntertwining, + ← Module.End.mul_apply,← map_mul,inv_mul_cancel,map_one,Module.End.one_apply] + rw [Finset.sum_const,Finset.card_univ,← Nat.cast_smul_eq_nsmul ℂ,smul_smul, + inv_mul_cancel₀ (show (Fintype.card G : ℂ) ≠ 0 from Nat.cast_ne_zero.mpr Fintype.card_ne_zero),one_smul] + +theorem lift_intertwiner (f : IntertwiningMap ρ σ) (g : IntertwiningMap τ σ) + (h : LinearMap.range g.toLinearMap ≤ LinearMap.range f.toLinearMap) : + ∃ l : IntertwiningMap τ ρ, ∀ v, f (l v) = g v := by + let : AddCommGroup V := Module.addCommMonoidToAddCommGroup ℂ + let : AddCommGroup W := Module.addCommMonoidToAddCommGroup ℂ + let : AddCommGroup P := Module.addCommMonoidToAddCommGroup ℂ + let f0 := f.toLinearMap.rangeRestrict + obtain ⟨r,hr⟩ := f0.exists_rightInverse_of_surjective f.toLinearMap.range_rangeRestrict + let g0 : P →ₗ[ℂ] LinearMap.range f.toLinearMap := + g.toLinearMap.codRestrict _ (fun v => h ⟨v,rfl⟩) + let l := r.comp g0 + have hl (v : P) : f (l v) = g v := by + have hh := DFunLike.congr_fun hr (g0 v) + exact congrArg Subtype.val hh + exact ⟨averagedIntertwiner ρ τ l,averageLinear_lift ρ σ τ l f g hl⟩ + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/GenericHookAux.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/GenericHookAux.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d666ed3b22c1557ce82b7680fdbc5c4936f2962 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/GenericHookAux.lean @@ -0,0 +1,204 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.HookScalar + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation Signed + +variable {m n h : ℕ} (bits : Fin (m+n) → ℕ) (H : PathFamily bits h) + +theorem conditional_occurring_with_cost {t : ℕ} (ht : 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-c*Real.log (Module.finrank ℂ V:ℝ)+e*h*Real.log (gridSize bits)-pathCost H+c*h+ + (1+4*c+2*(q:ℝ))*(2*(t:ℝ))^2* + ((gridSize (rightBits bits):ℝ)*Real.log (gridSize (leftBits bits)+1:ℝ)+ + (gridSize (leftBits bits):ℝ)*Real.log (gridSize (rightBits bits)+1:ℝ))) := by + have hr : ∀y (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (rowFreeSize bits H y)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (rowChildWeight bits H z y))≤ + Real.exp (-c*typeF a.val+(e*Fintype.card (RowLabels bits H y)* + Real.log (gridSize (leftBits bits))-pathCost (rowFamily bits H y))) := by + intros; simpa only [add_sub_assoc] using hchildR _ _ + have hc' : ∀x (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (columnFreeSize bits H x)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (columnChildWeight bits H z x))≤ + Real.exp (-c*typeF a.val+(e*Fintype.card (ColumnLabels bits H x)* + Real.log (gridSize (rightBits bits))-pathCost (columnFamily bits H x))) := by + intros; simpa only [add_sub_assoc] using hchildC _ _ + let : NeZero t := ⟨ne_of_gt ht⟩ + have hh := conditional_dense_bound bits H ρ hρ (Prod.fst : Bool × Fin t → Bool) + hocc z hq c hc hcq _ _ hr hc' + simp only [Fintype.card_prod,Fintype.card_bool,Fintype.card_fin,Nat.cast_mul,Nat.cast_ofNat] at hh + refine hh.trans ?_ + apply Real.exp_le_exp.mpr + rw [add_assoc (-c*Real.log (Module.finrank ℂ V:ℝ)),child_error_sum] + have hb := mul_le_mul_of_nonneg_left (blocksLog_le bits H) + (by positivity : 0≤(1+4*c+2*(q:ℝ))*(2*(t:ℝ))^2) + linarith + +theorem occurring_auxiliary_eventually (q : ℕ) (hq : 2≤q) : ∀ᶠ s : ℕ in atTop, + ∀ m n h : ℕ, ∀ bits : Fin (m+n) → ℕ, ∀ H : PathFamily bits h, + gridSize bits=s → + 1≤Real.log (gridSize (leftBits bits)) → 1≤Real.log (gridSize (rightBits bits)) → + Real.log (gridSize (leftBits bits))≤(4/5:ℝ)*Real.log s → + Real.log (gridSize (rightBits bits))≤(4/5:ℝ)*Real.log s → + ∀ t : ℕ, 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-(cExponent s+inductionGap s)*Real.log (Module.finrank ℂ V:ℝ)+ + (eExponent s-inductionGap s)*h*Real.log s-pathCost H+(s:ℝ)^(9/10:ℝ)) := by + have hcast : Tendsto (fun s : ℕ => (s:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + filter_upwards [hcast.eventually (hook_polynomial_error_eventually q), + (Real.tendsto_log_atTop.comp hcast).eventually_ge_atTop 1600] with s herr hs + intro m n h bits H hsize hu hv hub hvb t ht hts V _ _ _ ρ _ hρ hocc z hR hC + let u := gridSize (leftBits bits) + let v := gridSize (rightBits bits) + let c := min (cExponent u) (cExponent v) + let e := max (eExponent u) (eExponent v) + have hq0 : 0 unfold cExponent + · linarith [child_exponent_gap hl0 hu0 hub] + · linarith [child_exponent_gap hl0 hv0 hvb] + have heg : e≤e0-(11/10:ℝ)/Real.sqrt (Real.log s) := by + apply max_le <;> unfold eExponent + · linarith [child_exponent_gap hl0 hu0 hub] + · linarith [child_exponent_gap hl0 hv0 hvb] + have weaken (U N : ℕ) (F C : ℝ) (hF : 0≤F) (hU : 0≤Real.log U) + (hcu : c≤cExponent U) (heu : eExponent U≤e) : + -cExponent U*F+eExponent U*N*Real.log U-C≤-c*F+e*N*Real.log U-C := by + have h1 := mul_le_mul_of_nonneg_right hcu hF + have h2 := mul_le_mul_of_nonneg_right heu + (mul_nonneg (Nat.cast_nonneg N) hU) + nlinarith + have hRR : ∀y (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (rowFreeSize bits H y)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (rowChildWeight bits H z y))≤ + Real.exp (-c*typeF a.val+e*Fintype.card (RowLabels bits H y)* + Real.log (gridSize (leftBits bits))-pathCost (rowFamily bits H y)) := by + intro y a + exact (hR y a).trans (Real.exp_le_exp.mpr + (weaken u _ _ _ (typeF_nonneg _) hu0.le (min_le_left _ _) (le_max_left _ _))) + have hCC : ∀x (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (columnFreeSize bits H x)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (columnChildWeight bits H z x))≤ + Real.exp (-c*typeF a.val+e*Fintype.card (ColumnLabels bits H x)* + Real.log (gridSize (rightBits bits))-pathCost (columnFamily bits H x)) := by + intro x a + exact (hC x a).trans (Real.exp_le_exp.mpr + (weaken v _ _ _ (typeF_nonneg _) hv0.le (min_le_right _ _) (le_max_right _ _))) + have hup : (u:ℝ)≤(s:ℝ)^(4/5:ℝ) := by + rw [←Real.exp_log (show 0<(u:ℝ) by exact_mod_cast gridSize_pos (leftBits bits)),Real.rpow_def_of_pos (by + rw [←hsize]; exact_mod_cast gridSize_pos bits)] + exact Real.exp_le_exp.mpr (by simpa only [mul_comm] using hub) + have hvp : (v:ℝ)≤(s:ℝ)^(4/5:ℝ) := by + rw [←Real.exp_log (show 0<(v:ℝ) by exact_mod_cast gridSize_pos (rightBits bits)),Real.rpow_def_of_pos (by + rw [←hsize]; exact_mod_cast gridSize_pos bits)] + exact Real.exp_le_exp.mpr (by simpa only [mul_comm] using hvb) + have hE := herr u v t c (by exact_mod_cast gridSize_pos (leftBits bits)) + (by exact_mod_cast gridSize_pos (rightBits bits)) (by positivity) hts hup hvp hc hc2 + refine (conditional_occurring_with_cost bits H ht ρ hρ hocc z hq0 c e hc hcq hRR hCC).trans ?_ + apply Real.exp_le_exp.mpr + rw [hsize] + exact hook_strengthened_scalar hs (Real.log_nonneg (by exact_mod_cast irreducible_finrank_pos ρ)) (by positivity) hcg hc2 heg hE + +end BinaryCoordinateSweeps.GridSplit + +end + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation Signed Young + +theorem specht_hook_auxiliary_eventually (q : ℕ) (hq : 2≤q) : ∀ᶠ s : ℕ in atTop, + ∀ m n h : ℕ, ∀ bits : Fin (m+n) → ℕ, ∀ H : PathFamily bits h, + gridSize bits=s → + 1≤Real.log (gridSize (leftBits bits)) → 1≤Real.log (gridSize (rightBits bits)) → + Real.log (gridSize (leftBits bits))≤(4/5:ℝ)*Real.log s → + Real.log (gridSize (rightBits bits))≤(4/5:ℝ)*Real.log s → + ∀ t : ℕ, 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-(cExponent s+inductionGap s)*Real.log (Module.finrank ℂ (SpechtSpace μ):ℝ)+ + (eExponent s-inductionGap s)*h*Real.log s-pathCost H+(s:ℝ)^(9/10:ℝ)) := by + filter_upwards [occurring_auxiliary_eventually q hq] with s hs + intro m n h bits H hsize hu hv hub hvb t ht hts μ hμ e z hR hC + let eJ := e.trans (inputToJunction bits H) + let ρ : Representation ℂ (Equiv.Perm (Fin (junctionSize bits H))) (SpechtHilbert μ) := (hilbertSpecht μ).comp eJ.symm.permCongrHom.toMonoidHom + let : ρ.IsIrreducible := irreducible_comp_equiv eJ.symm.permCongrHom (hilbertSpecht μ) + have hρ : ∀g v, ‖ρ g v‖=‖v‖ := fun g v => hilbertSpecht_unitary μ _ v + have hb := hs m n h bits H hsize hu hv hub hvb t ht hts (SpechtHilbert μ) ρ hρ + (hookHilbert_occursAt μ hμ eJ) z hR hC + have he : ρ.comp (inputToJunction bits H).permCongrHom.toMonoidHom = + (hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom := by + apply MonoidHom.ext + intro g + change hilbertSpecht μ (eJ.symm.permCongr ((inputToJunction bits H).permCongr g)) = + hilbertSpecht μ (e.symm.permCongr g) + apply congrArg (hilbertSpecht μ) + apply Equiv.ext + intro a + simp [eJ,Equiv.permCongr_apply] + rw [he,hilbertSpecht_finrank] at hb + exact hb + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/HookCut.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/HookCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..53f696aa93562b05bfbf458e6194f14ebd23a0bd --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/HookCut.lean @@ -0,0 +1,230 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.HookWord + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +variable (μ : YoungDiagram) (p : ℕ) + +def hookPart : YoungDiagram where + cells := μ.cells.filter (fun x => x.1 < p ∨ x.2 < p) + isLowerSet := by + intro y x hxy hx + rcases Finset.mem_filter.mp hx with ⟨hx,hp⟩ + apply Finset.mem_filter.mpr + refine ⟨μ.isLowerSet hxy hx, ?_⟩ + rcases hp with hp | hp + · exact Or.inl (lt_of_le_of_lt hxy.1 hp) + · exact Or.inr (lt_of_le_of_lt hxy.2 hp) + +def shiftCell (x : ℕ × ℕ) : ℕ × ℕ := (x.1+p,x.2+p) + +lemma shiftCell_injective : Function.Injective (shiftCell p) := by + intro x y h + have h1 := congrArg Prod.fst h + have h2 := congrArg Prod.snd h + apply Prod.ext <;> simp_all [shiftCell] + +def southeast : YoungDiagram where + cells := μ.cells.preimage (shiftCell p) (shiftCell_injective p).injOn + isLowerSet := by + intro y x hxy hx + apply Finset.mem_preimage.mpr + apply μ.isLowerSet _ (Finset.mem_preimage.mp hx) + exact ⟨Nat.add_le_add_right hxy.1 _, Nat.add_le_add_right hxy.2 _⟩ + +@[simp] lemma mem_hookPart (x : ℕ × ℕ) : + x ∈ hookPart μ p ↔ x ∈ μ ∧ (x.1 < p ∨ x.2 < p) := by + change x ∈ μ.cells.filter (fun x => x.1 < p ∨ x.2 < p) ↔ + x ∈ μ.cells ∧ (x.1 < p ∨ x.2 < p) + exact Finset.mem_filter + +@[simp] lemma mem_southeast (x : ℕ × ℕ) : + x ∈ southeast μ p ↔ (x.1+p,x.2+p) ∈ μ := by + change x ∈ μ.cells.preimage (shiftCell p) (shiftCell_injective p).injOn ↔ shiftCell p x ∈ μ.cells + exact Finset.mem_preimage + +lemma hookPart_inHook : InHook (hookPart μ p) p := by + intro x + exact ((mem_hookPart μ p x.val).mp x.property).2 + +def hookIn : Cell (hookPart μ p) ↪ Cell μ where + toFun x := ⟨x.val, ((mem_hookPart μ p x.val).mp x.property).1⟩ + inj' _ _ h := Subtype.ext (congrArg (fun a : Cell μ => a.val) h) + +def southeastIn : Cell (southeast μ p) ↪ Cell μ where + toFun x := ⟨(x.val.1+p,x.val.2+p), (mem_southeast μ p x.val).mp x.property⟩ + inj' _ _ h := Subtype.ext ((shiftCell_injective p) (congrArg Subtype.val h)) + +@[simp] lemma row_hookIn (x : Cell (hookPart μ p)) : row (hookIn μ p x) = row x := rfl +@[simp] lemma col_hookIn (x : Cell (hookPart μ p)) : col (hookIn μ p x) = col x := rfl +@[simp] lemma row_southeastIn (x : Cell (southeast μ p)) : row (southeastIn μ p x) = row x+p := rfl +@[simp] lemma col_southeastIn (x : Cell (southeast μ p)) : col (southeastIn μ p x) = col x+p := rfl + +def cutEquiv : Cell (hookPart μ p) ⊕ Cell (southeast μ p) ≃ Cell μ where + toFun := Sum.elim (hookIn μ p) (southeastIn μ p) + invFun x := if h : row x < p ∨ col x < p then + Sum.inl ⟨x.val,(mem_hookPart μ p x.val).mpr ⟨x.property,h⟩⟩ + else Sum.inr ⟨(row x-p,col x-p), (mem_southeast μ p _).mpr (by + have hr : p ≤ row x := by omega + have hc : p ≤ col x := by omega + change (row x-p+p,col x-p+p) ∈ μ + rw [Nat.sub_add_cancel hr,Nat.sub_add_cancel hc] + exact x.property)⟩ + left_inv := by + intro x + cases x with + | inl x => + dsimp only [Sum.elim] + split_ifs with h + · rfl + · exact (h (hookPart_inHook μ p x)).elim + | inr x => + dsimp only [Sum.elim] + split_ifs with h + · have h' : row x+p

t.1.val a) (fun a => t.2.val a+p) ((cutEquiv μ p).symm x) + +@[simp] lemma glueLabels_hook (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) + (x : Cell (hookPart μ p)) : glueLabels μ p t (hookIn μ p x) = t.1.val x := by + change Sum.elim _ _ ((cutEquiv μ p).symm ((cutEquiv μ p) (Sum.inl x))) = _ + rw [Equiv.symm_apply_apply] + rfl + +@[simp] lemma glueLabels_southeast (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) + (x : Cell (southeast μ p)) : glueLabels μ p t (southeastIn μ p x) = t.2.val x+p := by + change Sum.elim _ _ ((cutEquiv μ p).symm ((cutEquiv μ p) (Sum.inr x))) = _ + rw [Equiv.symm_apply_apply] + rfl + +lemma labels_cutPerm (g : G (hookPart μ p) × G (southeast μ p)) : + labels μ (cutPerm μ p g) = + glueLabels μ p (tabloidOfPerm (hookPart μ p) g.1,tabloidOfPerm (southeast μ p) g.2) := by + funext x + obtain ⟨y,rfl⟩ := (cutEquiv μ p).surjective x + cases y with + | inl y => + simp only [labels,← map_inv,cutEquiv_inl,cutPerm_apply_hook,row_hookIn,glueLabels_hook] + rfl + | inr y => + simp only [labels,← map_inv,cutEquiv_inr,cutPerm_apply_southeast,row_southeastIn,glueLabels_southeast] + rfl + +def glueTabloid (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) : Tabloid μ := by + refine ⟨glueLabels μ p t, ?_⟩ + obtain ⟨g,hg⟩ := tabloidOfPerm_surjective (hookPart μ p) t.1 + obtain ⟨d,hd⟩ := tabloidOfPerm_surjective (southeast μ p) t.2 + refine ⟨cutPerm μ p (g,d),?_⟩ + rw [labels_cutPerm,hg,hd] + +@[simp] lemma glueTabloid_val (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) : + (glueTabloid μ p t).val = glueLabels μ p t := rfl + +lemma glueTabloid_injective : Function.Injective (glueTabloid μ p) := by + intro t u h + apply Prod.ext + · apply Subtype.ext + funext x + have hh := congrArg (fun v : Tabloid μ => v.val (hookIn μ p x)) h + simpa only [glueTabloid_val,glueLabels_hook] using hh + · apply Subtype.ext + funext x + have hh := congrArg (fun v : Tabloid μ => v.val (southeastIn μ p x)) h + simpa only [glueTabloid_val,glueLabels_southeast,Nat.add_right_cancel_iff] using hh + +lemma glueTabloid_perm (g : G (hookPart μ p) × G (southeast μ p)) : + glueTabloid μ p (tabloidOfPerm (hookPart μ p) g.1,tabloidOfPerm (southeast μ p) g.2) = + tabloidOfPerm μ (cutPerm μ p g) := by + apply Subtype.ext + exact (labels_cutPerm μ p g).symm + +lemma glueTabloid_smul (g : G (hookPart μ p) × G (southeast μ p)) + (t : Tabloid (hookPart μ p) × Tabloid (southeast μ p)) : + glueTabloid μ p (g.1 • t.1,g.2 • t.2) = cutPerm μ p g • glueTabloid μ p t := by + obtain ⟨a,ha⟩ := tabloidOfPerm_surjective (hookPart μ p) t.1 + obtain ⟨b,hb⟩ := tabloidOfPerm_surjective (southeast μ p) t.2 + have ht : t = (tabloidOfPerm (hookPart μ p) a,tabloidOfPerm (southeast μ p) b) := + Prod.ext ha.symm hb.symm + rw [ht] + dsimp only + rw [smul_tabloidOfPerm,smul_tabloidOfPerm,glueTabloid_perm μ p (g.1*a,g.2*b), + glueTabloid_perm μ p (a,b),smul_tabloidOfPerm] + congr 1 + exact map_mul (cutPerm μ p) g (a,b) + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/HookHilbertOccurrence.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/HookHilbertOccurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..109918f65730dafbf9926cbfac96fdbdf1977aac --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/HookHilbertOccurrence.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GroupedLogBounds +import OAI.Probability.BinarySweep.YoungTheory.HookWord + +namespace OAI + +noncomputable section +open scoped BigOperators Classical MonoidAlgebra + +namespace BinaryCoordinateSweeps.Young +open Representation Irrep Signed + +variable {N p : ℕ} (α : N.Partition) (h : InHook (diagram α) p) + +def hookHilbertMap : IntertwiningMap (partitionHilbertRep α) + (hilbertTensorRep (Prod.fst : Bool × Fin p → Bool) N) where + toLinearMap := (coeffEquiv (Bool × Fin p) N).symm.toLinearMap.comp + ((hookMap h (cellsEquivFin α)).toLinearMap.comp (spechtHilbertEquiv (diagram α)).symm.toLinearMap) + isIntertwining' g := by + apply LinearMap.ext + intro v + apply (coeffEquiv (Bool × Fin p) N).injective + change hookMap h (cellsEquivFin α) + ((spechtHilbertEquiv (diagram α)).symm (partitionHilbertRep α g v)) = + tensorRep Prod.fst N g (hookMap h (cellsEquivFin α) ((spechtHilbertEquiv (diagram α)).symm v)) + have he := LinearMap.congr_fun ((hookMap h (cellsEquivFin α)).isIntertwining' + ((cellsEquivFin α).symm.permCongr g)) ((spechtHilbertEquiv (diagram α)).symm v) + have hg : (cellsEquivFin α).permCongr ((cellsEquivFin α).symm.permCongr g)=g := by + ext t; simp [Equiv.permCongr_apply] + change hookMap h (cellsEquivFin α) + ((spechtHilbertEquiv (diagram α)).symm ((spechtHilbertEquiv (diagram α)) + (spechtRep (diagram α) ((cellsEquivFin α).symm.permCongr g) + ((spechtHilbertEquiv (diagram α)).symm v)))) = _ + rw [LinearEquiv.symm_apply_apply] + change hookMap h (cellsEquivFin α) + (spechtRep (diagram α) ((cellsEquivFin α).symm.permCongr g) + ((spechtHilbertEquiv (diagram α)).symm v)) = + tensorRep Prod.fst N ((cellsEquivFin α).permCongr ((cellsEquivFin α).symm.permCongr g)) + (hookMap h (cellsEquivFin α) ((spechtHilbertEquiv (diagram α)).symm v)) at he + rw [hg] at he + exact he + +lemma hookHilbertMap_injective : Function.Injective (hookHilbertMap α h) := + (coeffEquiv (Bool × Fin p) N).symm.injective.comp + ((hookMap_injective h (cellsEquivFin α)).comp (spechtHilbertEquiv (diagram α)).symm.injective) + +include h in +lemma hookHilbert_occurs : + 0 SpechtHilbert (hookPart μ p)) + +def hookHilbertInduced : Representation ℂ (G μ) (HookHilbertInducedSpace μ p) := + coindHilbertRep (hookPerm μ p) (hilbertSpecht (hookPart μ p)) + (fun x => (placementSection (cutEquiv μ p) x)⁻¹) + (placement_cosets_bijective (cutEquiv μ p)) + +def hookHilbertFiberEquiv : Representation.Equiv + (coind (hookPerm μ p) (hilbertSpecht (hookPart μ p))) (hookHilbertInduced μ p) := + conjugateEquiv _ (coindHilbertEquiv (hookPerm μ p) (hilbertSpecht (hookPart μ p)) + (fun x => (placementSection (cutEquiv μ p) x)⁻¹) + (placement_cosets_bijective (cutEquiv μ p))) + +lemma hookHilbertInduced_inner (g : G μ) (v w : HookHilbertInducedSpace μ p) : + inner ℂ (hookHilbertInduced μ p g v) (hookHilbertInduced μ p g w) = inner ℂ v w := + coindHilbert_unitary _ _ _ _ (hilbertSpecht_inner (hookPart μ p)) g v w + +lemma hookHilbertInduced_unitary (g : G μ) (v : HookHilbertInducedSpace μ p) : + ‖hookHilbertInduced μ p g v‖ = ‖v‖ := + ((hookHilbertInduced μ p g).isometryOfInner (hookHilbertInduced_inner μ p g)).norm_map v + +lemma hook_hilbert_multiplicity : + Module.finrank ℂ (SpechtSpace (southeast μ p)) ≤ + Module.finrank ℂ (IntertwiningMap (hilbertSpecht μ) (hookHilbertInduced μ p)) := by + let : Module.Finite ℂ (SpechtSpace μ) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace μ)) + let : Module.Finite ℂ (SpechtSpace (hookPart μ p)) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace (hookPart μ p))) + have hs := Irrep.multiplicity_symm (spechtRep (hookPart μ p)) (hookRestriction μ p) + have he := Irrep.multiplicity_congr + (repEquiv_comp (conjugateEquiv (spechtRep μ) (spechtHilbertEquiv μ)) (hookPerm μ p)) + (conjugateEquiv (spechtRep (hookPart μ p)) (spechtHilbertEquiv (hookPart μ p))) + have hr := (coindHomEquiv (hookPerm μ p) (hilbertSpecht μ) + (hilbertSpecht (hookPart μ p))).finrank_eq + have hd := multiplicity_congr (Representation.Equiv.refl (hilbertSpecht μ)) + (hookHilbertFiberEquiv μ p) + exact (hook_removal_multiplicity μ p).trans (Nat.le_of_eq (hs.trans (he.trans (hr.trans hd)))) + +theorem hook_induced_moment_le (w : G μ → ℂ) (q : ℕ) : + (Module.finrank ℂ (SpechtSpace (southeast μ p)) : ℝ) * + evenMoment q (groupAverage (hilbertSpecht μ) w) ≤ + evenMoment q (groupAverage (hookHilbertInduced μ p) w) := by + have hm := multiplicity_moment_le (hilbertSpecht μ) (hookHilbertInduced μ p) w + (hilbertSpecht_unitary μ) (hookHilbertInduced_unitary μ p) q + have hp : 0 ≤ evenMoment q (groupAverage (hilbertSpecht μ) w) := + (Complex.nonneg_iff.mp (positive_pow + (LinearMap.isPositive_adjoint_comp_self _) q).trace_nonneg).1 + exact (mul_le_mul_of_nonneg_right (by exact_mod_cast hook_hilbert_multiplicity μ p) hp).trans hm + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Irrep +open Representation + +variable {G H I W : Type*} [Group G] [Group H] + [Fintype I] [NormedAddCommGroup W] [InnerProductSpace ℂ W] + (φ : H →* G) (σ : Representation ℂ H W) (r : I → G) + (hc : Function.Bijective (fun a : H × I => φ a.1 * r a.2)) + +def fiberInclude (i : I) : W →ₗ[ℂ] CoindHilbertSpace (I := I) (W := W) := + (WithLp.linearEquiv 2 ℂ (I → W)).symm.toLinearMap.comp (LinearMap.single ℂ (fun _ : I => W) i) + +def fiberProject (i : I) : CoindHilbertSpace (I := I) (W := W) →ₗ[ℂ] W := + (LinearMap.proj i).comp (WithLp.linearEquiv 2 ℂ (I → W)).toLinearMap + +def hilbertBlock (A : CoindHilbertSpace (I := I) (W := W) →ₗ[ℂ] + CoindHilbertSpace (I := I) (W := W)) (i j : I) : W →ₗ[ℂ] W := + (fiberProject i).comp (A.comp (fiberInclude j)) + +omit [Fintype I] in +lemma fiberInclude_apply (i j : I) (w : W) : fiberInclude i w j = if j=i then w else 0 := by + simp [fiberInclude,eq_comm] + +omit [Fintype I] in +lemma hilbertBlock_coind (a : G) (i j : I) : + hilbertBlock (coindHilbertRep φ σ r hc a) i j = + if cosetIndexAction φ r hc a i = j then + σ ((cosetEquiv φ r hc).symm (r i*a)).1 else 0 := by + ext w + change coindHilbertRep φ σ r hc a (fiberInclude j w) i = _ + rw [coindHilbertRep_apply,fiberInclude_apply] + split_ifs <;> simp_all + +variable [Fintype G] [FiniteDimensional ℂ W] + +omit [FiniteDimensional ℂ W] in +lemma hilbertBlock_average (p : G → ℂ) (i j : I) : + hilbertBlock (groupAverage (coindHilbertRep φ σ r hc) p) i j = + ∑ a, if cosetIndexAction φ r hc a i = j then + p a • σ ((cosetEquiv φ r hc).symm (r i*a)).1 else 0 := by + have he : hilbertBlock (groupAverage (coindHilbertRep φ σ r hc) p) i j = + ∑ a, p a • hilbertBlock (coindHilbertRep φ σ r hc a) i j := by + ext w + simp [hilbertBlock,groupAverage,LinearMap.sum_apply,LinearMap.smul_apply] + rw [he] + apply Finset.sum_congr rfl + intro a _ + rw [hilbertBlock_coind] + split_ifs <;> simp + +end BinaryCoordinateSweeps.Irrep + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/HookScalar.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/HookScalar.lean new file mode 100644 index 0000000000000000000000000000000000000000..38eaf5f4e6d14cdb64c1ad5b5af521997765bac8 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/HookScalar.lean @@ -0,0 +1,228 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.GridDenseCost + +namespace OAI + +noncomputable section + +section + +open Filter Asymptotics +open scoped Topology + +namespace BinaryCoordinateSweeps + +lemma hook_polynomial_error_eventually (q : ℕ) : ∀ᶠ s : ℝ in atTop, + ∀ u v p c : ℝ, 1≤u → 1≤v → 0≤p → p≤ s^(1/100:ℝ) → + u≤ s^(4/5:ℝ) → v≤ s^(4/5:ℝ) → 0≤c → c≤2 → + (1+4*c+2*(q:ℝ))*(2*p)^2*(v*Real.log (u+1)+u*Real.log (v+1)) ≤ + s^(9/10:ℝ) := by + let C : ℝ := 16*(9+2*(q:ℝ)) + have hC : 00 by norm_num) hsq + have heq : (11/10:ℝ)/Real.sqrt (Real.log s)= + 1/Real.sqrt (Real.log s)+(1/20:ℝ)/Real.sqrt (Real.log s)+(1/20:ℝ)/Real.sqrt (Real.log s) := by ring + rw [heq] at hc + linarith + have he' : e*Real.log s+c≤(e0-1/Real.sqrt (Real.log s)-(1/20:ℝ)/Real.sqrt (Real.log s))*Real.log s := by + have h1 := mul_le_mul_of_nonneg_right he hl.le + have heq : (11/10:ℝ)/Real.sqrt (Real.log s)= + 1/Real.sqrt (Real.log s)+2*((1/20:ℝ)/Real.sqrt (Real.log s)) := by ring + rw [heq] at h1 + nlinarith + have hf := mul_le_mul_of_nonneg_right hc' hF + have hholes := mul_le_mul_of_nonneg_right he' hh + nlinarith + +end BinaryCoordinateSweeps + +end + +open scoped BigOperators Classical +open Filter + +namespace BinaryCoordinateSweeps.GridSplit +open Irrep Representation Signed + +lemma typeF_nonneg {n : ℕ} (α : n.Partition) : 0≤typeF α := by + apply Real.log_nonneg + exact_mod_cast irreducible_finrank_pos (Young.partitionHilbertRep α) + +lemma cExponent_nonneg (s : ℕ) : 0≤cExponent s := by + unfold cExponent c0 + positivity + +lemma cExponent_le_two {s : ℕ} (hs : 1≤Real.log s) : cExponent s≤2 := by + have hsq : 1≤Real.sqrt (Real.log s) := Real.le_sqrt_of_sq_le (by norm_num; exact hs) + have hi := one_div_le_one_div_of_le (by norm_num : (0:ℝ)<1) hsq + unfold cExponent c0 + norm_num at hi ⊢ + linarith + +theorem hook_auxiliary_eventually (q : ℕ) (hq : 2≤q) : ∀ᶠ s : ℕ in atTop, + ∀ m n h : ℕ, ∀ bits : Fin (m+n) → ℕ, ∀ H : PathFamily bits h, + gridSize bits=s → + 1≤Real.log (gridSize (leftBits bits)) → 1≤Real.log (gridSize (rightBits bits)) → + Real.log (gridSize (leftBits bits))≤(4/5:ℝ)*Real.log s → + Real.log (gridSize (rightBits bits))≤(4/5:ℝ)*Real.log s → + ∀ t : ℕ, 0 (conditionalGroupLaw H z a:ℂ)))≤ + Real.exp (-(cExponent s+inductionGap s)*typeF α+ + (eExponent s-inductionGap s)*h*Real.log s-pathCost H+(s:ℝ)^(9/10:ℝ)) := by + have hcast : Tendsto (fun s : ℕ => (s:ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + filter_upwards [hcast.eventually (hook_polynomial_error_eventually q), + (Real.tendsto_log_atTop.comp hcast).eventually_ge_atTop 1600] with s herr hs + intro m n h bits H hsize hu hv hub hvb t ht hts α hα z hR hC + let u := gridSize (leftBits bits) + let v := gridSize (rightBits bits) + let c := min (cExponent u) (cExponent v) + let e := max (eExponent u) (eExponent v) + have hq0 : 0 unfold cExponent + · linarith [child_exponent_gap hl0 hu0 hub] + · linarith [child_exponent_gap hl0 hv0 hvb] + have heg : e≤e0-(11/10:ℝ)/Real.sqrt (Real.log s) := by + apply max_le <;> unfold eExponent + · linarith [child_exponent_gap hl0 hu0 hub] + · linarith [child_exponent_gap hl0 hv0 hvb] + have weaken (U N : ℕ) (F C : ℝ) (hF : 0≤F) (hU : 0≤Real.log U) + (hcu : c≤cExponent U) (heu : eExponent U≤e) : + -cExponent U*F+eExponent U*N*Real.log U-C≤-c*F+e*N*Real.log U-C := by + have h1 := mul_le_mul_of_nonneg_right hcu hF + have h2 := mul_le_mul_of_nonneg_right heu + (mul_nonneg (Nat.cast_nonneg N) hU) + nlinarith + have hRR : ∀y (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (rowFreeSize bits H y)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (rowChildWeight bits H z y))≤ + Real.exp (-c*typeF a.val+e*Fintype.card (RowLabels bits H y)* + Real.log (gridSize (leftBits bits))-pathCost (rowFamily bits H y)) := by + intro y a + exact (hR y a).trans (Real.exp_le_exp.mpr + (weaken u _ _ _ (typeF_nonneg _) hu0.le (min_le_left _ _) (le_max_left _ _))) + have hCC : ∀x (a : ActiveType (Prod.fst : Bool × Fin t → Bool) (columnFreeSize bits H x)), + evenMoment q (groupAverage (Young.partitionHilbertRep a.val) (columnChildWeight bits H z x))≤ + Real.exp (-c*typeF a.val+e*Fintype.card (ColumnLabels bits H x)* + Real.log (gridSize (rightBits bits))-pathCost (columnFamily bits H x)) := by + intro x a + exact (hC x a).trans (Real.exp_le_exp.mpr + (weaken v _ _ _ (typeF_nonneg _) hv0.le (min_le_right _ _) (le_max_right _ _))) + have hup : (u:ℝ)≤(s:ℝ)^(4/5:ℝ) := by + rw [←Real.exp_log (show 0<(u:ℝ) by exact_mod_cast gridSize_pos (leftBits bits)),Real.rpow_def_of_pos (by + rw [←hsize]; exact_mod_cast gridSize_pos bits)] + exact Real.exp_le_exp.mpr (by simpa only [mul_comm] using hub) + have hvp : (v:ℝ)≤(s:ℝ)^(4/5:ℝ) := by + rw [←Real.exp_log (show 0<(v:ℝ) by exact_mod_cast gridSize_pos (rightBits bits)),Real.rpow_def_of_pos (by + rw [←hsize]; exact_mod_cast gridSize_pos bits)] + exact Real.exp_le_exp.mpr (by simpa only [mul_comm] using hvb) + have hE := herr u v t c (by exact_mod_cast gridSize_pos (leftBits bits)) + (by exact_mod_cast gridSize_pos (rightBits bits)) (by positivity) hts hup hvp hc hc2 + refine (conditional_hook_with_cost bits H ht α hα z hq0 c e hc hcq hRR hCC).trans ?_ + apply Real.exp_le_exp.mpr + rw [hsize] + exact hook_strengthened_scalar hs (typeF_nonneg _) (by positivity) hcg hc2 heg hE + +end BinaryCoordinateSweeps.GridSplit + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/HookWord.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/HookWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7f8c5f1994b6fecb12fa684f22364fa275799df --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/HookWord.lean @@ -0,0 +1,237 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungInducedMap + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical +open Equiv Equiv.Perm + +namespace BinaryCoordinateSweeps.Young + +def InHook (μ : YoungDiagram) (p : ℕ) : Prop := + ∀ x : Cell μ, row x < p ∨ col x < p + +variable {μ : YoungDiagram} {p : ℕ} + +def hookLabel (h : InHook μ p) (x : Cell μ) : Bool × Fin p := + if hr : row x < p then (false, ⟨row x,hr⟩) + else (true, ⟨col x,(h x).resolve_left hr⟩) + +lemma hookLabel_top (h : InHook μ p) (x : Cell μ) : + (hookLabel h x).1 = false ↔ row x < p := by + unfold hookLabel + split_ifs <;> simp_all + +lemma hookLabel_bottom (h : InHook μ p) (x : Cell μ) : + (hookLabel h x).1 = true ↔ ¬row x < p := by + unfold hookLabel + split_ifs <;> simp_all + +lemma hookLabel_eq_top (h : InHook μ p) (x y : Cell μ) + (hx : row x < p) (he : hookLabel h y = hookLabel h x) : row y = row x := by + have hy : row y < p := (hookLabel_top h y).mp + ((congrArg Prod.fst he).trans ((hookLabel_top h x).mpr hx)) + have hh := congrArg (fun z : Bool × Fin p => z.2.val) he + simpa only [hookLabel, dite_eq_left hx, dite_eq_left hy] using hh + +lemma hookLabel_eq_bottom (h : InHook μ p) (x y : Cell μ) + (hx : ¬row x < p) (he : hookLabel h y = hookLabel h x) : col y = col x := by + have hy : ¬row y < p := (hookLabel_bottom h y).mp + ((congrArg Prod.fst he).trans ((hookLabel_bottom h x).mpr hx)) + have hh := congrArg (fun z : Bool × Fin p => z.2.val) he + simpa only [hookLabel, dite_eq_right hx, dite_eq_right hy] using hh + +lemma hook_return_column_fixes (h : InHook μ p) (c : C μ) (r : rowStabilizer μ) + (hr : ∀ x, hookLabel h ((c.val*r.val) x) = hookLabel h x) + (x : Cell μ) (hx : row x < p) : c.val x = x := by + have hrinv : row (r.val⁻¹ x) = row x := (r⁻¹).property x + have hz : row (r.val⁻¹ x) < p := by rwa [hrinv] + have hh := hr (r.val⁻¹ x) + simp only [mul_apply, show r.val (r.val⁻¹ x) = x from r.val.apply_symm_apply x] at hh + apply Subtype.ext + apply Prod.ext + · exact (hookLabel_eq_top h _ _ hz hh).trans ((r⁻¹).property x) + · exact c.property x + +lemma hook_return_row_fixes (h : InHook μ p) (c : C μ) (r : rowStabilizer μ) + (hr : ∀ x, hookLabel h ((c.val*r.val) x) = hookLabel h x) + (x : Cell μ) (hx : ¬row x < p) : r.val x = x := by + apply Subtype.ext + apply Prod.ext + · exact r.property x + · have hh := hookLabel_eq_bottom h x ((c.val*r.val) x) hx (hr x) + change col (c.val (r.val x)) = col x at hh + rw [c.property] at hh + exact hh + +variable {n : ℕ} +def hookWord (h : InHook μ p) (e : Cell μ ≃ Fin n) : Fin n → Bool × Fin p := + hookLabel h ∘ e.symm + +lemma hookWord_comp_eq (h : InHook μ p) (e : Cell μ ≃ Fin n) (g : G μ) : + hookWord h e ∘ e.permCongr g = hookWord h e ↔ + ∀ x, hookLabel h (g x) = hookLabel h x := by + constructor + · intro hh x + have he := congrFun hh (e x) + simpa only [hookWord, Function.comp_apply, Equiv.permCongr_apply, + Equiv.apply_symm_apply, Equiv.symm_apply_apply] using he + · intro hh + funext i + simpa only [hookWord, Function.comp_apply, Equiv.permCongr_apply, + Equiv.apply_symm_apply, Equiv.symm_apply_apply] using hh (e.symm i) + +lemma hook_return_sign (h : InHook μ p) (e : Cell μ ≃ Fin n) + (c : C μ) (r : rowStabilizer μ) + (hr : hookWord h e ∘ e.permCongr (c.val*r.val) = hookWord h e) : + Signed.signC (Prod.fst ∘ hookWord h e) (e.permCongr (c.val*r.val))⁻¹ = signC μ c.val := by + let β := Prod.fst ∘ hookWord h e + have hh := (hookWord_comp_eq h e _).mp hr + have hc : ∀ i, β i ≠ true → e.permCongr c.val i = i := by + intro i hi + have hx : row (e.symm i) < p := by + apply (hookLabel_top h _).mp + exact Bool.eq_false_of_not_eq_true hi + have hf := hook_return_column_fixes h c r hh (e.symm i) hx + simp only [Equiv.permCongr_apply, hf, Equiv.apply_symm_apply] + have hrf : ∀ i, β i ≠ false → e.permCongr r.val i = i := by + intro i hi + have hx : ¬row (e.symm i) < p := by + intro hx + exact hi ((hookLabel_top h _).mpr hx) + have hf := hook_return_row_fixes h c r hh (e.symm i) hx + simp only [Equiv.permCongr_apply, hf, Equiv.apply_symm_apply] + have hcm := Signed.mask_fixed_complement β true (e.permCongr c.val) hc + have hrm := Signed.mask_fixed_complement β false (e.permCongr r.val) hrf + have hcs := Signed.koszulSign_of_fixed_complement β true (e.permCongr c.val) hc + have hrs := Signed.koszulSign_of_fixed_complement β false (e.permCongr r.val) hrf + simp only [ite_true, Bool.false_eq_true, ite_false] at hcs hrs + have hs : Signed.koszulSign β (e.permCongr (c.val*r.val)) = Equiv.Perm.sign c.val := by + rw [Equiv.permCongr_mul, Signed.koszulSign_mul, hrm, hcs, hrs, mul_one, + Equiv.Perm.sign_permCongr] + have hm : β ∘ (e.permCongr (c.val*r.val)).symm = β := by + change Prod.fst ∘ hookWord h e ∘ (e.permCongr (c.val*r.val)).symm = β + have hi := congrArg (fun w => w ∘ (e.permCongr (c.val*r.val)).symm) hr + have hi' : hookWord h e = hookWord h e ∘ (e.permCongr (c.val*r.val)).symm := by + simpa only [Function.comp_assoc, Equiv.self_comp_symm, Function.comp_id] using hi + exact congrArg (fun w => Prod.fst ∘ w) hi'.symm + have hinv := Signed.koszulSign_inv β (e.permCongr (c.val*r.val)) + rw [hm,hs] at hinv + change ((Signed.koszulSign β _ : ℤ) : ℂ) = _ + rw [hinv] + rfl + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical +open Equiv Equiv.Perm Representation + +namespace BinaryCoordinateSweeps.Young +variable {μ : YoungDiagram} {p n : ℕ} + +instance rowStabilizer_fintype (μ : YoungDiagram) : Fintype (rowStabilizer μ) := Fintype.ofFinite _ + +def hookRep (e : Cell μ ≃ Fin n) (p : ℕ) : + Representation ℂ (G μ) ((Fin n → Bool × Fin p) → ℂ) := + (Signed.tensorRep Prod.fst n).comp e.permCongrHom.toMonoidHom + +def hookRowVector (h : InHook μ p) (e : Cell μ ≃ Fin n) : + (Fin n → Bool × Fin p) → ℂ := + ∑ r : rowStabilizer μ, hookRep e p r.val (Pi.single (hookWord h e) 1) + +lemma hookRowVector_fixed (h : InHook μ p) (e : Cell μ ≃ Fin n) (r : rowStabilizer μ) : + hookRep e p r.val (hookRowVector h e) = hookRowVector h e := by + rw [hookRowVector,map_sum] + simp only [← Module.End.mul_apply, ← map_mul] + exact Equiv.sum_comp (Equiv.mulLeft r) (fun t : rowStabilizer μ => + hookRep e p t.val (Pi.single (hookWord h e) 1)) + +def hookMap (h : InHook μ p) (e : Cell μ ≃ Fin n) : + IntertwiningMap (spechtRep μ) (hookRep e p) where + toLinearMap := (fromTabloid μ (hookRep e p) (hookRowVector h e)).comp (spechtInclude μ) + isIntertwining' g := by + apply LinearMap.ext + intro v + simp only [LinearMap.comp_apply, spechtInclude_rep] + exact fromTabloid_intertwines μ _ _ (hookRowVector_fixed h e) g (spechtInclude μ v) + +lemma hookMap_poly (h : InHook μ p) (e : Cell μ ≃ Fin n) : + hookMap h e (spechtPoly μ) = + ∑ c : C μ, ∑ r : rowStabilizer μ, + signC μ c.val • hookRep e p (c.val*r.val) (Pi.single (hookWord h e) 1) := by + change fromTabloid μ (hookRep e p) (hookRowVector h e) + (spechtInclude μ (spechtPoly μ)) = _ + rw [spechtInclude_poly, polytabloid, columnAnti_apply, map_sum] + apply Finset.sum_congr rfl + intro c _ + rw [map_smul, fromTabloid_intertwines μ _ _ (hookRowVector_fixed h e), + fromTabloid_basis, tabloidVector_eq μ _ _ (hookRowVector_fixed h e), map_one, + Module.End.one_apply, hookRowVector, map_sum, Finset.smul_sum] + apply Finset.sum_congr rfl + intro r _ + rw [map_mul, Module.End.mul_apply] + +lemma hook_term_coefficient (h : InHook μ p) (e : Cell μ ≃ Fin n) + (c : C μ) (r : rowStabilizer μ) : + (signC μ c.val • hookRep e p (c.val*r.val) (Pi.single (hookWord h e) 1)) (hookWord h e) = + if hookWord h e ∘ e.permCongr (c.val*r.val) = hookWord h e then (1 : ℂ) else 0 := by + change signC μ c.val * (Signed.signC (Prod.fst ∘ hookWord h e) + (e.permCongr (c.val*r.val))⁻¹ * + (Pi.single (hookWord h e) (1 : ℂ) : (Fin n → Bool × Fin p) → ℂ) + (hookWord h e ∘ e.permCongr (c.val*r.val))) = _ + by_cases hh : hookWord h e ∘ e.permCongr (c.val*r.val) = hookWord h e + · rw [ite_eq_left hh, hook_return_sign h e c r hh, hh, Pi.single_eq_same, mul_one, signC_sq] + · rw [ite_eq_right hh, Pi.single_eq_of_ne hh, mul_zero, mul_zero] + +lemma hookMap_poly_coefficient (h : InHook μ p) (e : Cell μ ≃ Fin n) : + hookMap h e (spechtPoly μ) (hookWord h e) = + ∑ c : C μ, ∑ r : rowStabilizer μ, + if hookWord h e ∘ e.permCongr (c.val*r.val) = hookWord h e then (1 : ℂ) else 0 := by + rw [hookMap_poly] + simp only [Finset.sum_apply, hook_term_coefficient] + +lemma hookMap_nonzero (h : InHook μ p) (e : Cell μ ≃ Fin n) : hookMap h e ≠ 0 := by + intro hz + have he := hookMap_poly_coefficient h e + rw [hz] at he + change (0 : ℂ) = _ at he + have hre := congrArg Complex.re he + simp only [Complex.zero_re, Complex.re_sum, apply_ite, + Complex.one_re, Complex.zero_re] at hre + have hs (c : C μ) (r : rowStabilizer μ) : + (0 : ℝ) ≤ if hookWord h e ∘ e.permCongr (c.val*r.val) = hookWord h e then 1 else 0 := by + split_ifs <;> norm_num + have hid : (1 : ℝ) ≤ ∑ r : rowStabilizer μ, + if hookWord h e ∘ e.permCongr ((1 : C μ).val*r.val) = hookWord h e then 1 else 0 := by + have hi := Finset.single_le_sum (s := Finset.univ) (f := fun r : rowStabilizer μ => + if hookWord h e ∘ e.permCongr ((1 : C μ).val*r.val) = hookWord h e then (1 : ℝ) else 0) + (fun r _ => hs 1 r) (Finset.mem_univ (1 : rowStabilizer μ)) + have he1 : e.permCongr (1 : G μ) = (1 : Equiv.Perm (Fin n)) := by + apply Equiv.ext + intro i + exact e.apply_symm_apply i + simpa only [Subgroup.coe_one, one_mul, he1, Equiv.Perm.coe_one, Function.comp_id, + ite_true] using hi + have hle := Finset.single_le_sum (s := Finset.univ) (f := fun c : C μ => + ∑ r : rowStabilizer μ, + if hookWord h e ∘ e.permCongr (c.val*r.val) = hookWord h e then (1 : ℝ) else 0) + (fun c _ => Finset.sum_nonneg (fun r _ => hs c r)) (Finset.mem_univ (1 : C μ)) + linarith + +theorem hookMap_injective (h : InHook μ p) (e : Cell μ ≃ Fin n) : + Function.Injective (hookMap h e) := + (Representation.IsIrreducible.injective_or_eq_zero (k := ℂ) (G := G μ) + (V := SpechtSpace μ) (W := (Fin n → Bool × Fin p) → ℂ) (hookMap h e)).resolve_right + (hookMap_nonzero h e) + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/KoszulBlocks.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/KoszulBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c06a6ad1d90444c226db705caff5dcc64018e54 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/KoszulBlocks.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungResolution + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Signed +variable {I : Type*} [Fintype I] [LinearOrder I] {n : I → ℕ} {N : ℕ} + +def orderedBlocks (n : I → ℕ) : (Σₗ i, Fin (n i)) ≃o Fin (∑i,n i) := + (Fintype.orderIsoFinOfCardEq (Σₗ i, Fin (n i)) (by simp)).symm + +def blockPerm (e : (Σₗ i, Fin (n i)) ≃o Fin N) (g : ∀i, Equiv.Perm (Fin (n i))) : + Equiv.Perm (Fin N) := (toLex.trans e.toEquiv).permCongr (Equiv.Perm.sigmaCongrRight g) + +omit [Fintype I] in +@[simp] lemma blockPerm_apply (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (i : I) (a : Fin (n i)) : + blockPerm e g (e (toLex ⟨i,a⟩)) = e (toLex ⟨i,g i a⟩) := by + simp [blockPerm, Equiv.permCongr_apply] + +omit [Fintype I] in +private lemma block_lt_iff (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (i j : I) (a : Fin (n i)) (b : Fin (n j)) : + e (toLex ⟨i,a⟩) < e (toLex ⟨j,b⟩) ↔ i < j ∨ ∃ h : i = j, h ▸ a < b := + e.lt_iff_lt.trans Sigma.lex_iff + +omit [Fintype I] in +private lemma block_le_iff (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (i j : I) (a : Fin (n i)) (b : Fin (n j)) : + e (toLex ⟨i,a⟩) ≤ e (toLex ⟨j,b⟩) ↔ i < j ∨ ∃ h : i = j, h ▸ a ≤ b := + e.le_iff_le.trans Sigma.lex_iff + +omit [Fintype I] in +lemma pairWeight_sameBlock (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (β : Fin N → Bool) (i : I) (a b : Fin (n i)) : + pairWeight β (blockPerm e g) (e (toLex ⟨i,a⟩)) (e (toLex ⟨i,b⟩)) = + pairWeight (fun a => β (e (toLex ⟨i,a⟩))) (g i) a b := by + simp only [pairWeight, blockPerm_apply, block_lt_iff, block_le_iff] + simp + +omit [Fintype I] in +lemma pairWeight_differentBlock (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (β : Fin N → Bool) + {i j : I} (hji : j≠i) (a : Fin (n i)) (b : Fin (n j)) : + pairWeight β (blockPerm e g) (e (toLex ⟨i,a⟩)) (e (toLex ⟨j,b⟩)) = 1 := by + simp only [pairWeight, blockPerm_apply, block_lt_iff, block_le_iff] + rcases lt_or_gt_of_ne hji with h | h + · simp [h, hji, hji.symm, not_lt_of_gt h] + · simp [hji, not_lt_of_gt h] + +theorem koszulSign_blocks (e : (Σₗ i, Fin (n i)) ≃o Fin N) + (g : ∀i, Equiv.Perm (Fin (n i))) (β : Fin N → Bool) : + koszulSign β (blockPerm e g) = ∏i, koszulSign (fun a => β (e (toLex ⟨i,a⟩))) (g i) := by + rw [koszulSign_eq_prod,← Equiv.prod_comp e.toEquiv] + change (∏x : Σ i, Fin (n i), ∏b, pairWeight β (blockPerm e g) (e (toLex x)) b)=_ + rw [Fintype.prod_sigma] + apply Finset.prod_congr rfl + intro i _ + rw [koszulSign_eq_prod] + apply Finset.prod_congr rfl + intro a _ + rw [← Equiv.prod_comp e.toEquiv] + change (∏y : Σ j, Fin (n j), pairWeight β (blockPerm e g) (e (toLex ⟨i,a⟩)) (e (toLex y)))=_ + rw [Fintype.prod_sigma] + rw [Finset.prod_eq_single i] + · apply Finset.prod_congr rfl + intro b _ + exact pairWeight_sameBlock e g β i a b + · intro j _ hji + apply Finset.prod_eq_one + intro b _ + exact pairWeight_differentBlock e g β hji a b + · simp + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/PhysicalHookInduced.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/PhysicalHookInduced.lean new file mode 100644 index 0000000000000000000000000000000000000000..9064c0b2a48f9f5ccc3167747e86d6502f419a5a --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/PhysicalHookInduced.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IrrepTransport +import OAI.Probability.BinarySweep.Conditional.PlacementCycleMoment + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +open Irrep Representation + +variable {b h : ℕ} {bits : Fin b → ℕ} (H : PathFamily bits h) + (μ : YoungDiagram) (p : ℕ) (e : Cell μ ≃ FreeSlot H 0) + +def hookPlacementBasis : Cell (hookPart μ p) ⊕ Fin (Fintype.card (Cell (southeast μ p))) ≃ FreeSlot H 0 := + ((Equiv.sumCongr (Equiv.refl _) (Fintype.equivFin (Cell (southeast μ p))).symm).trans + (cutEquiv μ p)).trans e + +lemma hookPlacement_restriction : + ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom).comp + (blockPerm (hookPlacementBasis H μ p e)) = (hilbertSpecht μ).comp (hookPerm μ p) := by + apply MonoidHom.ext + intro g + change hilbertSpecht μ + (e.symm.permCongr (blockPerm (hookPlacementBasis H μ p e) g)) = + hilbertSpecht μ (hookPerm μ p g) + apply congrArg (hilbertSpecht μ) + rw [hookPerm_block] + apply Equiv.ext + intro a + obtain ⟨a,rfl⟩ := (cutEquiv μ p).surjective a + cases a with + | inl a => simp [hookPlacementBasis,blockPerm,Equiv.permCongr_apply] + | inr a => simp [hookPlacementBasis,blockPerm,Equiv.permCongr_apply] + +lemma hook_hilbert_restriction_multiplicity : + Module.finrank ℂ (SpechtSpace (southeast μ p)) ≤ Module.finrank ℂ + (IntertwiningMap ((hilbertSpecht μ).comp (hookPerm μ p)) (hilbertSpecht (hookPart μ p))) := by + let : Module.Finite ℂ (SpechtSpace μ) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace μ)) + let : Module.Finite ℂ (SpechtSpace (hookPart μ p)) := + inferInstanceAs (FiniteDimensional ℂ (SpechtSpace (hookPart μ p))) + have hs := multiplicity_symm (spechtRep (hookPart μ p)) (hookRestriction μ p) + have he := multiplicity_congr + (repEquiv_comp (conjugateEquiv (spechtRep μ) (spechtHilbertEquiv μ)) (hookPerm μ p)) + (conjugateEquiv (spechtRep (hookPart μ p)) (spechtHilbertEquiv (hookPart μ p))) + exact (hook_removal_multiplicity μ p).trans (Nat.le_of_eq (hs.trans he)) + +lemma hook_placement_multiplicity : + Module.finrank ℂ (SpechtSpace (southeast μ p)) ≤ Module.finrank ℂ + (IntertwiningMap ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (coindHilbertRep (blockPerm (hookPlacementBasis H μ p e)) (hilbertSpecht (hookPart μ p)) + (fun x => (placementSection (hookPlacementBasis H μ p e) x)⁻¹) + (placement_cosets_bijective (hookPlacementBasis H μ p e)))) := by + let ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (SpechtHilbert μ) := + (hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom + let f := hookPlacementBasis H μ p e + let σ := hilbertSpecht (hookPart μ p) + have hr := (coindHomEquiv (blockPerm f) ρ σ).finrank_eq + have hd := multiplicity_congr (Representation.Equiv.refl ρ) + (conjugateEquiv (coind (blockPerm f) σ) + (coindHilbertEquiv (blockPerm f) σ (fun x => (placementSection f x)⁻¹) + (placement_cosets_bijective f))) + have he : ρ.comp (blockPerm f)=(hilbertSpecht μ).comp (hookPerm μ p) := + hookPlacement_restriction H μ p e + rw [he] at hr + exact (hook_hilbert_restriction_multiplicity μ p).trans (Nat.le_of_eq (hr.trans hd)) + +theorem conditional_hook_induced_moment_le (z : ℝ) (q : ℕ) : + (Module.finrank ℂ (SpechtSpace (southeast μ p)):ℝ)* + evenMoment q (groupAverage ((hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom) + (fun a => (conditionalGroupLaw H z a:ℂ))) ≤ + evenMoment q (inducedPlacementAverage H (hookPlacementBasis H μ p e) + (hilbertSpecht (hookPart μ p)) z) := by + let ρ : Representation ℂ (Equiv.Perm (FreeSlot H 0)) (SpechtHilbert μ) := + (hilbertSpecht μ).comp e.symm.permCongrHom.toMonoidHom + let : ρ.IsIrreducible := irreducible_comp_equiv e.symm.permCongrHom (hilbertSpecht μ) + let f := hookPlacementBasis H μ p e + let σ := coindHilbertRep (blockPerm f) (hilbertSpecht (hookPart μ p)) + (fun x => (placementSection f x)⁻¹) (placement_cosets_bijective f) + have hσ (a) (v) : ‖σ a v‖=‖v‖ := + ((σ a).isometryOfInner (coindHilbert_unitary _ _ _ _ + (hilbertSpecht_inner (hookPart μ p)) a)).norm_map v + have hm := multiplicity_moment_le ρ σ (fun a => (conditionalGroupLaw H z a:ℂ)) + (fun a v => hilbertSpecht_unitary μ _ v) hσ q + exact (mul_le_mul_of_nonneg_right (by exact_mod_cast hook_placement_multiplicity H μ p e) + (evenMoment_nonneg q _)).trans hm + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungAnti.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungAnti.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cdf76c12de24919e4c86cfd26c829daeca57fb1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungAnti.lean @@ -0,0 +1,171 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungTabloid + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) + +def signC : G μ →* ℂ := + ((Int.castRingHom ℂ).toMonoidHom.comp (Units.coeHom ℤ)).comp Equiv.Perm.sign + +lemma signC_eq (g : G μ) : signC μ g = ((Equiv.Perm.sign g : ℤ) : ℂ) := rfl + +lemma signC_sq (g : G μ) : signC μ g * signC μ g = 1 := by + rw [signC_eq, ← Int.cast_mul] + norm_cast + exact congrArg Units.val (Int.units_mul_self (Equiv.Perm.sign g)) + +lemma signC_ne_zero (g : G μ) : signC μ g ≠ 0 := by + intro h + have hh := signC_sq μ g + simp [h] at hh + +lemma signC_inv (g : G μ) : signC μ g⁻¹ = signC μ g := by + apply (mul_left_cancel₀ (signC_ne_zero μ g)) + rw [← map_mul, mul_inv_cancel, map_one, signC_sq] + +lemma signC_swap {x y : Cell μ} (h : x ≠ y) : signC μ (Equiv.swap x y) = -1 := by + simp [signC_eq, Equiv.Perm.sign_swap h] + +abbrev C := colStabilizer μ +instance : Fintype (C μ) := Fintype.ofFinite _ + +def columnAnti : Module.End ℂ (Tabloid μ → ℂ) := + ∑ c : C μ, signC μ c.val • tabloidRepresentation μ c.val + +lemma columnAnti_apply (v : Tabloid μ → ℂ) : + columnAnti μ v = ∑ c : C μ, signC μ c.val • tabloidRepresentation μ c.val v := by + simp [columnAnti, LinearMap.sum_apply] + +lemma columnAnti_rep (c : C μ) (v : Tabloid μ → ℂ) : + columnAnti μ (tabloidRepresentation μ c.val v) = signC μ c.val • columnAnti μ v := by + rw [columnAnti_apply, columnAnti_apply, Finset.smul_sum] + have h := Equiv.sum_comp (Equiv.mulRight c) + (fun d : C μ => signC μ c.val • (signC μ d.val • tabloidRepresentation μ d.val v)) + rw [← h] + apply Finset.sum_congr rfl + intro d hd + change signC μ d.val • tabloidRepresentation μ d.val (tabloidRepresentation μ c.val v) = + signC μ c.val • (signC μ (d * c).val • tabloidRepresentation μ (d * c).val v) + simp only [Subgroup.coe_mul, map_mul, Module.End.mul_apply, smul_smul] + rw [show signC μ c.val * (signC μ d.val * signC μ c.val) = signC μ d.val from by + calc + _ = signC μ d.val * (signC μ c.val * signC μ c.val) := by ring + _ = signC μ d.val := by rw [signC_sq, mul_one]] + +def polytabloid : Tabloid μ → ℂ := + columnAnti μ (tabloidBasis μ (tabloidOfPerm μ 1)) + +lemma columnAnti_basis_column (c : C μ) : + columnAnti μ (tabloidBasis μ (tabloidOfPerm μ c.val)) = signC μ c.val • polytabloid μ := by + rw [← mul_one c.val, ← smul_tabloidOfPerm, ← rep_basis, columnAnti_rep] + rfl + +lemma col_fixes_base_iff (c : C μ) : + c.val • tabloidOfPerm μ 1 = tabloidOfPerm μ 1 ↔ c = 1 := by + rw [smul_tabloidOfPerm, mul_one, tabloidOfPerm_eq_iff] + constructor + · intro hc + have hr : c.val ∈ rowStabilizer μ := by + have h := (rowStabilizer μ).inv_mem hc + simpa using h + have hi : c.val ∈ rowStabilizer μ ⊓ colStabilizer μ := ⟨hr, c.property⟩ + rw [row_col_intersection] at hi + exact Subtype.ext hi + · intro hc + subst c + simp + +lemma polytabloid_base : polytabloid μ (tabloidOfPerm μ 1) = 1 := by + rw [polytabloid, columnAnti_apply] + simp_rw [rep_basis, smul_tabloidOfPerm, mul_one] + simp only [Finset.sum_apply, Pi.smul_apply, tabloidBasis, Pi.single_apply] + have he (c : C μ) : tabloidOfPerm μ 1 = tabloidOfPerm μ c.val ↔ c = 1 := by + simpa [smul_tabloidOfPerm, eq_comm] using (col_fixes_base_iff μ c) + simp only [he] + simp + +lemma polytabloid_ne_zero : polytabloid μ ≠ 0 := by + intro h + have hh := congrFun h (tabloidOfPerm μ 1) + rw [polytabloid_base] at hh + exact one_ne_zero hh + +lemma swap_mem_fiber {X Y : Type*} [DecidableEq X] (f : X → Y) {x y : X} + (h : f x = f y) : Equiv.swap x y ∈ fiberStabilizer f := by + intro z + exact Equiv.apply_swap_eq_self h z + +lemma swap_fixes_tabloid (t : Tabloid μ) {x y : Cell μ} (h : t.val x = t.val y) : + (Equiv.swap x y : G μ) • t = t := by + apply Subtype.ext + funext z + change t.val ((Equiv.swap x y)⁻¹ z) = t.val z + simpa only [Equiv.swap_inv] using Equiv.apply_swap_eq_self h z + +lemma columnAnti_basis_collision (π : G μ) {x y : Cell μ} + (hne : x ≠ y) (hc : col x = col y) (hr : row (π⁻¹ x) = row (π⁻¹ y)) : + columnAnti μ (tabloidBasis μ (tabloidOfPerm μ π)) = 0 := by + let c : C μ := ⟨Equiv.swap x y, swap_mem_fiber _ hc⟩ + have hf : c.val • tabloidOfPerm μ π = tabloidOfPerm μ π := + swap_fixes_tabloid μ _ hr + have h := columnAnti_rep μ c (tabloidBasis μ (tabloidOfPerm μ π)) + rw [rep_basis, hf] at h + have hs : signC μ c.val = -1 := signC_swap μ hne + rw [hs, neg_one_smul] at h + ext t + have ht := congrFun h t + simp only [Pi.neg_apply] at ht + change columnAnti μ (tabloidBasis μ (tabloidOfPerm μ π)) t = 0 + linear_combination (1 / 2 : ℂ) * ht + +lemma columnAnti_basis_span (t : Tabloid μ) : + ∃ a : ℂ, columnAnti μ (tabloidBasis μ t) = a • polytabloid μ := by + obtain ⟨π, rfl⟩ := tabloidOfPerm_surjective μ t + rcases row_col_alternative μ π⁻¹ with ⟨x, y, hne, hc, hr⟩ | ⟨r, hr, c, hc, he⟩ + · exact ⟨0, by rw [columnAnti_basis_collision μ π hne hc hr, zero_smul]⟩ + · have hp : π = c⁻¹ * r⁻¹ := by simpa using congrArg Inv.inv he + rw [hp, tabloidOfPerm_row_mul μ c⁻¹ ⟨r⁻¹, (rowStabilizer μ).inv_mem hr⟩] + exact ⟨signC μ c⁻¹, columnAnti_basis_column μ ⟨c⁻¹, (colStabilizer μ).inv_mem hc⟩⟩ + +lemma sum_tabloidBasis (v : Tabloid μ → ℂ) : + ∑ t : Tabloid μ, v t • tabloidBasis μ t = v := by + ext t + simp [tabloidBasis, Pi.single_apply, Finset.sum_apply] + +theorem columnAnti_rank_one (v : Tabloid μ → ℂ) : + columnAnti μ v = (columnAnti μ v (tabloidOfPerm μ 1)) • polytabloid μ := by + have hv : ∃ a : ℂ, columnAnti μ v = a • polytabloid μ := by + choose a ha using columnAnti_basis_span μ + refine ⟨∑ t, v t * a t, ?_⟩ + conv_lhs => rw [← sum_tabloidBasis μ v] + rw [map_sum, Finset.sum_smul] + apply Finset.sum_congr rfl + intro t ht + rw [map_smul, ha, smul_smul] + obtain ⟨a, ha⟩ := hv + have he := congrFun ha (tabloidOfPerm μ 1) + simp only [Pi.smul_apply, polytabloid_base, smul_eq_mul, mul_one] at he + rw [he, ha] + +lemma columnAnti_square (v : Tabloid μ → ℂ) : + columnAnti μ (columnAnti μ v) = (Fintype.card (C μ) : ℂ) • columnAnti μ v := by + rw [columnAnti_apply μ v] + rw [map_sum] + simp_rw [map_smul, columnAnti_rep, smul_smul, signC_sq, one_smul] + rw [← columnAnti_apply] + simp only [Finset.sum_const, Finset.card_univ, ← Nat.cast_smul_eq_nsmul ℂ] + +lemma columnAnti_polytabloid : + columnAnti μ (polytabloid μ) = (Fintype.card (C μ) : ℂ) • polytabloid μ := + columnAnti_square μ _ + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungClassification.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungClassification.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb458caefe2a0e75852c414f04da6803abaef395 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungClassification.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungFinite +import OAI.Probability.BinarySweep.Representations.CharacterComplete + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young + +theorem partitionRep_complete {n : ℕ} {V : Type*} [AddCommGroup V] [Module ℂ V] + [FiniteDimensional ℂ V] (ρ : Representation ℂ (Equiv.Perm (Fin n)) V) [ρ.IsIrreducible] : + ∃ p : n.Partition, Nonempty (Representation.Equiv ρ (partitionRep p)) := by + refine Irrep.complete_of_card_ge (G := Equiv.Perm (Fin n)) + (V := fun p : n.Partition => PartitionSpace p) + (fun p : n.Partition => partitionRep p) ?_ ?_ ρ + · intro p q ⟨f⟩ + exact partitionRep_equiv_injective p q f + · let : Fintype (ConjClasses (Equiv.Perm (Fin n))) := Fintype.ofFinite _ + have h := Fintype.card_le_of_injective (conjPartition (X := Fin n)) conjPartition_injective + simpa only [Nat.card_eq_fintype_card, Fintype.card_fin] using h + +theorem specht_complete {X V : Type*} [Fintype X] [DecidableEq X] + [AddCommGroup V] [Module ℂ V] [FiniteDimensional ℂ V] + (ρ : Representation ℂ (Equiv.Perm X) V) [ρ.IsIrreducible] : + ∃ (μ : YoungDiagram) (e : Cell μ ≃ X), Nonempty (Representation.Equiv ρ + ((spechtRep μ).comp e.symm.permCongrHom.toMonoidHom)) := by + let a : X ≃ Fin (Fintype.card X) := Fintype.equivFin X + let ρ' : Representation ℂ (Equiv.Perm (Fin (Fintype.card X))) V := + ρ.comp a.symm.permCongrHom.toMonoidHom + have : ρ'.IsIrreducible := Irrep.irreducible_comp_equiv _ _ + obtain ⟨p, ⟨f⟩⟩ := partitionRep_complete ρ' + let e : Cell (diagram p) ≃ X := (cellsEquivFin p).trans a.symm + refine ⟨diagram p, e, ⟨Representation.Equiv.mk f.toLinearEquiv ?_⟩⟩ + intro g + apply LinearMap.ext + intro v + have h := Representation.IntertwiningMap.isIntertwining ρ' (partitionRep p) + f.toIntertwiningMap (a.permCongr g) v + change f.toLinearEquiv (ρ (a.symm.permCongr (a.permCongr g)) v) = + spechtRep (diagram p) ((cellsEquivFin p).symm.permCongr (a.permCongr g)) (f.toLinearEquiv v) at h + rw [show a.symm.permCongr (a.permCongr g) = g from + a.permCongr.symm_apply_apply g] at h + exact h + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungDimensionLower.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungDimensionLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..55ed847289cdb7a0c0ecd1320e0b6368a8e95e5b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungDimensionLower.lean @@ -0,0 +1,59 @@ +import Mathlib +import OAI.Probability.BinarySweep.GridBounds.DiagonalDimension + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) + +lemma two_pow_card_sub_diagonal_le_dimension (L : ℕ) + (hL : ∀ x : Cell μ, diagonal μ x < L) : + 2^(Fintype.card (Cell μ)-L) ≤ Module.finrank ℂ (SpechtSpace μ) := by + let f : Cell μ → Fin L := fun x => ⟨diagonal μ x,hL x⟩ + have hf : fiberStabilizer f = diagonalStabilizer μ := by + ext g + constructor + · intro hg x; exact congrArg Fin.val (hg x) + · intro hg x; exact Fin.ext (hg x) + have hb := two_pow_card_sub_colors_le_stabilizer f + rw [Fintype.card_fin, hf, Nat.card_eq_fintype_card] at hb + exact hb.trans (diagonal_card_le_dimension μ) + +theorem log_dimension_lower : + (Real.log 2 / 2) * + (Fintype.card (Cell μ) - max (μ.colLen 0) (μ.rowLen 0) : ℕ) ≤ + Real.log (Module.finrank ℂ (SpechtSpace μ)) := by + let N := Fintype.card (Cell μ) + let W := max (μ.colLen 0) (μ.rowLen 0) + let L := (N+W)/2 + have hWN : W ≤ N := height_width_le_card μ + have hLN : L ≤ N := by dsimp only [L]; omega + have hnat : N-W ≤ 2*(N-L) := by dsimp only [L]; omega + have hr : ((N-W : ℕ) : ℝ) ≤ 2*((N-L : ℕ) : ℝ) := by exact_mod_cast hnat + have hb := two_pow_card_sub_diagonal_le_dimension μ L (diagonal_lt_half_card_add_max μ) + have hbr : (2 : ℝ)^(N-L) ≤ (Module.finrank ℂ (SpechtSpace μ) : ℝ) := by exact_mod_cast hb + have hlog := Real.log_le_log (show (0 : ℝ) < 2^(N-L) from by positivity) hbr + rw [Real.log_pow] at hlog + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + change (Real.log 2 / 2) * ((N-W : ℕ) : ℝ) ≤ _ + nlinarith + +lemma tail_min_eq_card_sub_max : + min (Fintype.card (Cell μ) - μ.rowLen 0) (Fintype.card (Cell μ) - μ.colLen 0) = + Fintype.card (Cell μ) - max (μ.colLen 0) (μ.rowLen 0) := by omega + +theorem log_dimension_lower_min_tail : + (Real.log 2 / 2) * + (min (Fintype.card (Cell μ)-μ.rowLen 0) (Fintype.card (Cell μ)-μ.colLen 0) : ℕ) ≤ + Real.log (Module.finrank ℂ (SpechtSpace μ)) := by + rw [tail_min_eq_card_sub_max] + exact log_dimension_lower μ + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungDominance.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungDominance.lean new file mode 100644 index 0000000000000000000000000000000000000000..acd860a2186e322ec36c3d44d8cb906935b6854b --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungDominance.lean @@ -0,0 +1,238 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungSpecht + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young + +def rowPrefix (μ : YoungDiagram) (k : ℕ) : ℕ := + (Finset.univ.filter (fun x : Cell μ => row x < k)).card + +def Dominates (μ ν : YoungDiagram) : Prop := ∀ k, rowPrefix ν k ≤ rowPrefix μ k + +lemma filter_column_card (μ : YoungDiagram) (j k : ℕ) : + ((columnCells μ j).filter (fun x => row x < k)).card = min k (μ.colLen j) := by + have hinj := row_injectiveOn_column μ j + rw [← Finset.card_image_of_injOn (hinj.mono (by intro x hx; exact (Finset.mem_filter.mp hx).1))] + have he : (((columnCells μ j).filter (fun x => row x < k)).image row) = + Finset.range (min k (μ.colLen j)) := by + ext i + simp only [Finset.mem_image, Finset.mem_filter, Finset.mem_range, lt_min_iff] + constructor + · rintro ⟨x, ⟨hx, hk⟩, rfl⟩ + exact ⟨hk, Finset.mem_range.mp (image_row_columnCells μ j ▸ + Finset.mem_image.mpr ⟨x, hx, rfl⟩)⟩ + · rintro ⟨hk, hj⟩ + obtain ⟨x, hx, he⟩ := Finset.mem_image.mp + ((image_row_columnCells μ j).symm ▸ Finset.mem_range.mpr hj) + exact ⟨x, ⟨hx, he ▸ hk⟩, he⟩ + rw [he, Finset.card_range] + +lemma filter_injective_column_le (μ : YoungDiagram) (f : Cell μ → ℕ) (j k : ℕ) + (hf : Set.InjOn f (columnCells μ j)) : + ((columnCells μ j).filter (fun x => f x < k)).card ≤ min k (μ.colLen j) := by + apply le_min + · calc + _ ≤ (Finset.range k).card := by + apply Finset.card_le_card_of_injOn f + · intro x hx + exact Finset.mem_range.mpr (Finset.mem_filter.mp hx).2 + · exact hf.mono (by intro x hx; exact (Finset.mem_filter.mp hx).1) + _ = k := Finset.card_range k + · rw [← card_columnCells μ j] + exact Finset.card_le_card (Finset.filter_subset _ _) + +lemma card_filter_eq_sum_columns (μ : YoungDiagram) (p : Cell μ → Prop) [DecidablePred p] : + (Finset.univ.filter p).card = + ∑ j ∈ (Finset.univ : Finset (Cell μ)).image col, ((columnCells μ j).filter p).card := by + simp only [Finset.card_filter] + symm + exact Finset.sum_fiberwise_of_maps_to + (fun x hx => Finset.mem_image.mpr ⟨x, hx, rfl⟩) (fun x => if p x then 1 else 0) + +theorem dominates_of_column_injective (μ ν : YoungDiagram) (e : Cell μ ≃ Cell ν) + (he : ∀ j, Set.InjOn (fun x => row (e x)) (columnCells μ j)) : Dominates μ ν := by + intro k + have hc : rowPrefix ν k = (Finset.univ.filter (fun x : Cell μ => row (e x) < k)).card := by + simp only [rowPrefix, Finset.card_filter] + exact (Equiv.sum_comp e (fun x => if row x < k then 1 else 0)).symm + rw [hc, card_filter_eq_sum_columns, rowPrefix, card_filter_eq_sum_columns] + apply Finset.sum_le_sum + intro j hj + rw [filter_column_card] + exact filter_injective_column_le μ _ j k (he j) + +lemma rowPrefix_succ (μ : YoungDiagram) (k : ℕ) : + rowPrefix μ (k+1) = rowPrefix μ k + μ.rowLen k := by + have he : (Finset.univ.filter (fun x : Cell μ => row x < k+1)) = + (Finset.univ.filter (fun x : Cell μ => row x < k)) ∪ + (Finset.univ.filter (fun x : Cell μ => row x = k)) := by + ext x + simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_union] + omega + have hd : Disjoint (Finset.univ.filter (fun x : Cell μ => row x < k)) + (Finset.univ.filter (fun x : Cell μ => row x = k)) := by + rw [Finset.disjoint_left] + intro x hx hy + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hx hy + omega + rw [rowPrefix, he, Finset.card_union_of_disjoint hd] + congr 1 + rw [YoungDiagram.rowLen_eq_card] + apply Finset.card_bij (fun (x : Cell μ) _ => x.val) + · intro x hx + rw [YoungDiagram.mem_row_iff] + exact ⟨x.property, (Finset.mem_filter.mp hx).2⟩ + · intro x hx y hy he + exact Subtype.ext he + · intro x hx + have h := YoungDiagram.mem_row_iff.mp hx + exact ⟨⟨x, h.1⟩, by simp only [Finset.mem_filter, Finset.mem_univ, true_and]; exact h.2, rfl⟩ + +lemma dominates_antisymm {μ ν : YoungDiagram} (hμ : Dominates μ ν) (hν : Dominates ν μ) : μ = ν := by + have hp (k : ℕ) : rowPrefix μ k = rowPrefix ν k := le_antisymm (hν k) (hμ k) + have hr (k : ℕ) : μ.rowLen k = ν.rowLen k := by + have h := hp (k+1) + rw [rowPrefix_succ, rowPrefix_succ, hp k] at h + exact Nat.add_left_cancel h + apply SetLike.coe_injective + ext x + rcases x with ⟨i,j⟩ + simp only [SetLike.mem_coe, YoungDiagram.mem_iff_lt_rowLen, hr] + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young +variable {μ ν : YoungDiagram} + +def crossAnti (e : Cell μ ≃ Cell ν) : Module.End ℂ (Tabloid ν → ℂ) := + ∑ c : C μ, signC μ c.val • tabloidRepresentation ν (e.permCongr c.val) + +lemma crossAnti_apply (e : Cell μ ≃ Cell ν) (v : Tabloid ν → ℂ) : + crossAnti e v = ∑ c : C μ, signC μ c.val • + tabloidRepresentation ν (e.permCongr c.val) v := by + simp [crossAnti, LinearMap.sum_apply] + +lemma crossAnti_rep (e : Cell μ ≃ Cell ν) (c : C μ) (v : Tabloid ν → ℂ) : + crossAnti e (tabloidRepresentation ν (e.permCongr c.val) v) = + signC μ c.val • crossAnti e v := by + rw [crossAnti_apply, crossAnti_apply, Finset.smul_sum] + have h := Equiv.sum_comp (Equiv.mulRight c) + (fun d : C μ => signC μ c.val • + (signC μ d.val • tabloidRepresentation ν (e.permCongr d.val) v)) + rw [← h] + apply Finset.sum_congr rfl + intro d hd + change signC μ d.val • tabloidRepresentation ν (e.permCongr d.val) + (tabloidRepresentation ν (e.permCongr c.val) v) = + signC μ c.val • (signC μ (d*c).val • + tabloidRepresentation ν (e.permCongr (d*c).val) v) + simp only [Subgroup.coe_mul, map_mul, Equiv.permCongr_mul, Module.End.mul_apply, smul_smul] + rw [show signC μ c.val * (signC μ d.val * signC μ c.val) = signC μ d.val from by + calc + _ = signC μ d.val * (signC μ c.val * signC μ c.val) := by ring + _ = signC μ d.val := by rw [signC_sq, mul_one]] + +lemma crossAnti_basis_collision (e : Cell μ ≃ Cell ν) (t : Tabloid ν) + {x y : Cell μ} (hne : x ≠ y) (hc : col x = col y) (ht : t.val (e x) = t.val (e y)) : + crossAnti e (tabloidBasis ν t) = 0 := by + let c : C μ := ⟨Equiv.swap x y, swap_mem_fiber _ hc⟩ + have he : e.permCongr c.val = Equiv.swap (e x) (e y) := by + apply Equiv.ext + intro z + change e (Equiv.swap x y (e.symm z)) = _ + rw [Function.Injective.map_swap e.injective, e.apply_symm_apply] + have hf : e.permCongr c.val • t = t := by + rw [he] + exact swap_fixes_tabloid ν _ ht + have h := crossAnti_rep e c (tabloidBasis ν t) + rw [rep_basis, hf, show signC μ c.val = -1 from signC_swap μ hne, neg_one_smul] at h + ext u + have hu := congrFun h u + simp only [Pi.neg_apply] at hu + change crossAnti e (tabloidBasis ν t) u = 0 + linear_combination (1/2 : ℂ) * hu + +theorem crossAnti_eq_zero_of_not_dominates (e : Cell μ ≃ Cell ν) (h : ¬ Dominates μ ν) : + crossAnti e = 0 := by + have hb (t : Tabloid ν) : crossAnti e (tabloidBasis ν t) = 0 := by + obtain ⟨π, rfl⟩ := tabloidOfPerm_surjective ν t + by_contra hn + apply h + apply dominates_of_column_injective μ ν (e.trans π.symm) + intro j x hx y hy hxy + by_contra hne + apply hn + exact crossAnti_basis_collision e _ hne + ((Finset.mem_filter.mp hx).2.trans (Finset.mem_filter.mp hy).2.symm) hxy + apply LinearMap.ext + intro v + have hv : crossAnti e v = 0 := by + conv_lhs => rw [← sum_tabloidBasis ν v] + simp only [map_sum, map_smul, hb, smul_zero, Finset.sum_const_zero] + exact hv + +lemma spechtInclude_column_sum : + (∑ c : C μ, signC μ c.val • spechtRep μ c.val (spechtPoly μ)) = + (Fintype.card (C μ) : ℂ) • spechtPoly μ := by + apply spechtInclude_injective μ + simp only [map_sum, map_smul, spechtInclude_rep, spechtInclude_poly] + simpa only [columnAnti_apply] using columnAnti_polytabloid μ + +theorem intertwiner_dominance (e : Cell μ ≃ Cell ν) + (f : SpechtSpace μ →ₗ[ℂ] (Tabloid ν → ℂ)) + (hf : ∀ g v, f (spechtRep μ g v) = tabloidRepresentation ν (e.permCongr g) (f v)) + (hne : f (spechtPoly μ) ≠ 0) : Dominates μ ν := by + by_contra h + have he : crossAnti e (f (spechtPoly μ)) = (Fintype.card (C μ) : ℂ) • f (spechtPoly μ) := by + rw [crossAnti_apply] + simp_rw [← hf] + have hh := congrArg f (spechtInclude_column_sum (μ := μ)) + simpa only [map_sum, map_smul] using hh + rw [crossAnti_eq_zero_of_not_dominates e h, LinearMap.zero_apply] at he + exact hne ((smul_eq_zero.mp he.symm).resolve_left + (Nat.cast_ne_zero.mpr Fintype.card_ne_zero)) + +theorem equivalence_implies_diagram_eq (e : Cell μ ≃ Cell ν) + (f : SpechtSpace μ ≃ₗ[ℂ] SpechtSpace ν) + (hf : ∀ g v, f (spechtRep μ g v) = spechtRep ν (e.permCongr g) (f v)) : μ = ν := by + apply dominates_antisymm + · apply intertwiner_dominance e ((spechtInclude ν).comp f.toLinearMap) + · intro g v + simp only [LinearMap.comp_apply, LinearEquiv.coe_coe, hf, spechtInclude_rep] + · intro hz + apply spechtPoly_ne_zero μ + apply f.injective + apply spechtInclude_injective ν + simpa using hz + · apply intertwiner_dominance e.symm ((spechtInclude μ).comp f.symm.toLinearMap) + · intro g v + simp only [LinearMap.comp_apply, LinearEquiv.coe_coe] + rw [show f.symm (spechtRep ν g v) = + spechtRep μ (e.symm.permCongr g) (f.symm v) from by + apply f.injective + rw [LinearEquiv.apply_symm_apply, hf, LinearEquiv.apply_symm_apply] + congr 2 + exact (e.permCongr.apply_symm_apply g).symm] + exact spechtInclude_rep μ _ _ + · intro hz + apply spechtPoly_ne_zero ν + apply f.symm.injective + apply spechtInclude_injective μ + simpa using hz + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungFactor.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d130495cf3f88bf291affd0a6439a7495fb1ed1 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungFactor.lean @@ -0,0 +1,211 @@ +import Mathlib + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young + +abbrev Cell (μ : YoungDiagram) := {c // c ∈ μ.cells} +def row {μ : YoungDiagram} (x : Cell μ) : ℕ := x.val.1 +def col {μ : YoungDiagram} (x : Cell μ) : ℕ := x.val.2 + +lemma nat_le_strictMono {n : ℕ} (f : Fin n → ℕ) (hf : StrictMono f) (i : Fin n) : + i.val ≤ f i := by + obtain ⟨i, hi⟩ := i + induction i with + | zero => exact Nat.zero_le _ + | succ i ih => + have hi' : i < n := by omega + have hl := hf (show (⟨i, hi'⟩ : Fin n) < ⟨i+1, hi⟩ from by simp) + have hp := ih hi' + change i ≤ f ⟨i, hi'⟩ at hp + change i + 1 ≤ f ⟨i+1, hi⟩ + omega + +lemma sum_orderEmb (s : Finset ℕ) : + ∑ i : Fin s.card, s.orderEmbOfFin rfl i = ∑ i ∈ s, i := by + have h := Finset.sum_map (s := (Finset.univ : Finset (Fin s.card))) + (s.orderEmbOfFin rfl).toEmbedding (fun i : ℕ => i) + rw [s.map_orderEmbOfFin_univ rfl] at h + exact h.symm + +lemma range_sum_le (s : Finset ℕ) : + ∑ i ∈ Finset.range s.card, i ≤ ∑ i ∈ s, i := by + let e := s.orderEmbOfFin rfl + have h := Finset.sum_le_sum (s := Finset.univ) + (fun i _ => nat_le_strictMono e e.strictMono i) + simpa only [← Fin.sum_univ_eq_sum_range, e, sum_orderEmb] using h + +lemma eq_range_of_sum_eq (s : Finset ℕ) + (h : ∑ i ∈ s, i = ∑ i ∈ Finset.range s.card, i) : s = Finset.range s.card := by + let e := s.orderEmbOfFin rfl + have he : ∀ i : Fin s.card, e i = i.val := by + have hsum : ∑ i : Fin s.card, i.val = ∑ i : Fin s.card, e i := by + dsimp only [e] + rw [sum_orderEmb, Fin.sum_univ_eq_sum_range (fun i : ℕ => i)] + exact h.symm + have hh := (Finset.sum_eq_sum_iff_of_le + (fun (i : Fin s.card) _ => nat_le_strictMono e e.strictMono i)).mp hsum + exact fun i => (hh i (Finset.mem_univ i)).symm + ext i + constructor + · intro hi + obtain ⟨j, hj⟩ := (s.range_orderEmbOfFin rfl ▸ hi : i ∈ Set.range e) + rw [← hj, he] + exact Finset.mem_range.mpr j.isLt + · intro hi + let j : Fin s.card := ⟨i, Finset.mem_range.mp hi⟩ + rw [← show e j = i from he j] + exact s.orderEmbOfFin_mem rfl j + +def columnCells (μ : YoungDiagram) (j : ℕ) : Finset (Cell μ) := + Finset.univ.filter (fun x => col x = j) + +lemma mem_columnCells {μ : YoungDiagram} {j : ℕ} {x : Cell μ} : + x ∈ columnCells μ j ↔ col x = j := by simp [columnCells] + +lemma row_injectiveOn_column (μ : YoungDiagram) (j : ℕ) : + Set.InjOn (row (μ := μ)) (↑(columnCells μ j) : Set (Cell μ)) := by + intro x hx y hy hxy + apply Subtype.ext + apply Prod.ext hxy + exact (mem_columnCells.mp hx).trans (mem_columnCells.mp hy).symm + +lemma image_row_columnCells (μ : YoungDiagram) (j : ℕ) : + (columnCells μ j).image row = Finset.range (μ.colLen j) := by + ext i + simp only [Finset.mem_image, Finset.mem_range] + constructor + · rintro ⟨x, hx, rfl⟩ + have hc := x.property + have hj := mem_columnCells.mp hx + change x.val.2 = j at hj + rw [← hj] + exact YoungDiagram.mem_iff_lt_colLen.mp hc + · intro hi + refine ⟨⟨(i,j), YoungDiagram.mem_iff_lt_colLen.mpr hi⟩, ?_, rfl⟩ + exact mem_columnCells.mpr rfl + +lemma card_columnCells (μ : YoungDiagram) (j : ℕ) : + (columnCells μ j).card = μ.colLen j := by + rw [← Finset.card_image_of_injOn (row_injectiveOn_column μ j), image_row_columnCells] + exact Finset.card_range _ + +lemma sum_row_columnCells (μ : YoungDiagram) (j : ℕ) : + ∑ x ∈ columnCells μ j, row x = ∑ i ∈ Finset.range (μ.colLen j), i := by + rw [← image_row_columnCells μ j] + exact (Finset.sum_image (f := fun i : ℕ => i) (row_injectiveOn_column μ j)).symm + +lemma sum_columnCells_le (μ : YoungDiagram) (f : Cell μ → ℕ) (j : ℕ) + (hf : Set.InjOn f (columnCells μ j)) : + ∑ x ∈ columnCells μ j, row x ≤ ∑ x ∈ columnCells μ j, f x := by + have h := range_sum_le ((columnCells μ j).image f) + rw [Finset.card_image_of_injOn hf, card_columnCells, Finset.sum_image hf] at h + rwa [sum_row_columnCells] + +lemma column_image_of_total_sum (μ : YoungDiagram) (f : Cell μ → ℕ) + (hf : ∀ j, Set.InjOn f (columnCells μ j)) + (hsum : ∑ x, f x = ∑ x : Cell μ, row x) (j : ℕ) : + (columnCells μ j).image f = Finset.range (μ.colLen j) := by + classical + let J := (Finset.univ : Finset (Cell μ)).image col + have hmaps : ∀ x ∈ (Finset.univ : Finset (Cell μ)), col x ∈ J := by + intro x hx + exact Finset.mem_image.mpr ⟨x, hx, rfl⟩ + have hfib (g : Cell μ → ℕ) : + ∑ j ∈ J, ∑ x ∈ columnCells μ j, g x = ∑ x, g x := + Finset.sum_fiberwise_of_maps_to hmaps g + have heq : ∑ j ∈ J, ∑ x ∈ columnCells μ j, row x = + ∑ j ∈ J, ∑ x ∈ columnCells μ j, f x := by rw [hfib, hfib, hsum] + have hone := (Finset.sum_eq_sum_iff_of_le + (fun j (_ : j ∈ J) => sum_columnCells_le μ f j (hf j))).mp heq + by_cases hj : j ∈ J + · have hc : ((columnCells μ j).image f).card = μ.colLen j := by + rw [Finset.card_image_of_injOn (hf j), card_columnCells] + have h : ∑ i ∈ (columnCells μ j).image f, i = + ∑ i ∈ Finset.range ((columnCells μ j).image f).card, i := by + rw [hc, Finset.sum_image (hf j), ← sum_row_columnCells] + exact (hone j hj).symm + simpa only [hc] using eq_range_of_sum_eq _ h + · have hc : columnCells μ j = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro x hx + apply hj + exact Finset.mem_image.mpr ⟨x, Finset.mem_univ _, mem_columnCells.mp hx⟩ + have hz : μ.colLen j = 0 := by rw [← card_columnCells, hc]; rfl + simp [hc, hz] + +lemma rearranged_row_mem (μ : YoungDiagram) (π : Equiv.Perm (Cell μ)) + (hc : ∀ j, Set.InjOn (fun x => row (π x)) (columnCells μ j)) (x : Cell μ) : + (row (π x), col x) ∈ μ := by + have he := column_image_of_total_sum μ (fun x => row (π x)) hc + (Equiv.sum_comp π row) (col x) + have hm : row (π x) ∈ (columnCells μ (col x)).image (fun x => row (π x)) := + Finset.mem_image.mpr ⟨x, mem_columnCells.mpr rfl, rfl⟩ + rw [he, Finset.mem_range] at hm + exact YoungDiagram.mem_iff_lt_colLen.mpr hm + +def fiberStabilizer {X Y : Type*} (f : X → Y) : Subgroup (Equiv.Perm X) where + carrier := {π | ∀ x, f (π x) = f x} + one_mem' := by intro x; rfl + mul_mem' := by intro a b ha hb x; exact (ha (b x)).trans (hb x) + inv_mem' := by + intro a ha x + have h := ha (a⁻¹ x) + simpa using h.symm + +abbrev rowStabilizer (μ : YoungDiagram) := fiberStabilizer (row (μ := μ)) +abbrev colStabilizer (μ : YoungDiagram) := fiberStabilizer (col (μ := μ)) + +lemma row_col_intersection (μ : YoungDiagram) : + rowStabilizer μ ⊓ colStabilizer μ = ⊥ := by + apply le_antisymm + · intro π hπ + change π = 1 + apply Equiv.ext + intro x + apply Subtype.ext + exact Prod.ext (hπ.1 x) (hπ.2 x) + · exact bot_le + +theorem row_col_factorization (μ : YoungDiagram) (π : Equiv.Perm (Cell μ)) + (hc : ∀ j, Set.InjOn (fun x => row (π x)) (columnCells μ j)) : + ∃ r ∈ rowStabilizer μ, ∃ c ∈ colStabilizer μ, π = r * c := by + let t : Cell μ → Cell μ := fun x => + ⟨(row (π x), col x), rearranged_row_mem μ π hc x⟩ + have ht : Function.Injective t := by + intro x y hxy + have hcol := congrArg (fun z : Cell μ => col z) hxy + change col x = col y at hcol + have hrow := congrArg (fun z : Cell μ => row z) hxy + change row (π x) = row (π y) at hrow + exact hc (col x) (mem_columnCells.mpr rfl) (mem_columnCells.mpr hcol.symm) hrow + let c : Equiv.Perm (Cell μ) := Equiv.ofBijective t + ⟨ht, (Finite.injective_iff_surjective).mp ht⟩ + have cc : c ∈ colStabilizer μ := by intro x; rfl + have cr : ∀ x, row (c x) = row (π x) := by intro x; rfl + refine ⟨π * c⁻¹, ?_, c, cc, ?_⟩ + · intro x + change row (π (c⁻¹ x)) = row x + rw [← cr] + simp + · simp + +theorem row_col_alternative (μ : YoungDiagram) (π : Equiv.Perm (Cell μ)) : + (∃ x y : Cell μ, x ≠ y ∧ col x = col y ∧ row (π x) = row (π y)) ∨ + (∃ r ∈ rowStabilizer μ, ∃ c ∈ colStabilizer μ, π = r * c) := by + by_cases hc : ∀ j, Set.InjOn (fun x => row (π x)) (columnCells μ j) + · exact Or.inr (row_col_factorization μ π hc) + · left + simp only [Set.InjOn] at hc + push Not at hc + obtain ⟨j, x, hx, y, hy, hrow, hne⟩ := hc + exact ⟨x, y, hne, (mem_columnCells.mp hx).trans (mem_columnCells.mp hy).symm, hrow⟩ + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungFinite.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungFinite.lean new file mode 100644 index 0000000000000000000000000000000000000000..88b79851ce0fae8db85dc12be3f52221d509e745 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungFinite.lean @@ -0,0 +1,48 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungDominance +import OAI.Probability.BinarySweep.YoungTheory.YoungPartition +import OAI.Probability.BinarySweep.Representations.IrrepTransport + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young + +abbrev PartitionSpace {n : ℕ} (p : n.Partition) := SpechtSpace (diagram p) + +def partitionRep {n : ℕ} (p : n.Partition) : + Representation ℂ (Equiv.Perm (Fin n)) (PartitionSpace p) := + (spechtRep (diagram p)).comp ((cellsEquivFin p).symm.permCongrHom.toMonoidHom) + +instance {n : ℕ} (p : n.Partition) : + Representation.IsIrreducible (k := ℂ) (G := Equiv.Perm (Fin n)) + (V := PartitionSpace p) (partitionRep p) := + Irrep.irreducible_comp_equiv _ _ + +lemma partitionRep_apply {n : ℕ} (p : n.Partition) (g : Equiv.Perm (Fin n)) + (v : PartitionSpace p) : partitionRep p g v = + spechtRep (diagram p) ((cellsEquivFin p).symm.permCongr g) v := rfl + +lemma partitionRep_equiv_injective {n : ℕ} (p q : n.Partition) + (f : Representation.Equiv (partitionRep p) (partitionRep q)) : p = q := by + apply diagram_injective + let e := (cellsEquivFin p).trans (cellsEquivFin q).symm + apply equivalence_implies_diagram_eq e f.toLinearEquiv + intro g v + have h := Representation.IntertwiningMap.isIntertwining + (partitionRep p) (partitionRep q) f.toIntertwiningMap ((cellsEquivFin p).permCongr g) v + simp only [partitionRep_apply] at h + change f.toLinearEquiv _ = _ at h + have hep : ((cellsEquivFin p).symm.permCongr ((cellsEquivFin p).permCongr g)) = g := + (cellsEquivFin p).permCongr.symm_apply_apply g + rw [hep] at h + rw [h] + congr 2 + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungHilbert.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungHilbert.lean new file mode 100644 index 0000000000000000000000000000000000000000..89b3bfbaf79334862f013470cbb5d4ba31cd8bc5 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungHilbert.lean @@ -0,0 +1,205 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungSpecht +import OAI.Probability.BinarySweep.Representations.UnitaryTransport + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +open Representation + +variable (μ : YoungDiagram) + +def spechtHilbertInclude : SpechtSpace μ →ₗ[ℂ] EuclideanSpace ℂ (Tabloid μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm.toLinearMap.comp (spechtInclude μ) + +lemma spechtHilbertInclude_injective : Function.Injective (spechtHilbertInclude μ) := + (WithLp.linearEquiv 2 ℂ (Tabloid μ → ℂ)).symm.injective.comp (spechtInclude_injective μ) + +abbrev SpechtHilbert := (spechtHilbertInclude μ).range + +def spechtHilbertEquiv : SpechtSpace μ ≃ₗ[ℂ] SpechtHilbert μ := + LinearEquiv.ofInjective (spechtHilbertInclude μ) (spechtHilbertInclude_injective μ) + +def hilbertSpecht : Representation ℂ (G μ) (SpechtHilbert μ) := + letI : AddCommGroup (SpechtSpace μ) := Module.addCommMonoidToAddCommGroup ℂ + Irrep.conjugateRep (spechtRep μ) (spechtHilbertEquiv μ) + +instance : (hilbertSpecht μ).IsIrreducible := + letI : AddCommGroup (SpechtSpace μ) := Module.addCommMonoidToAddCommGroup ℂ + Irrep.irreducible_equiv _ _ (Irrep.conjugateEquiv _ _) + +lemma spechtHilbertEquiv_coeff (v : SpechtSpace μ) (t : Tabloid μ) : + (spechtHilbertEquiv μ v).val t = spechtInclude μ v t := rfl + +lemma hilbertSpecht_coeff (g : G μ) (v : SpechtHilbert μ) (t : Tabloid μ) : + (hilbertSpecht μ g v).val t = v.val (g⁻¹ • t) := by + obtain ⟨w,rfl⟩ := (spechtHilbertEquiv μ).surjective v + change (spechtHilbertEquiv μ (spechtRep μ g ((spechtHilbertEquiv μ).symm + (spechtHilbertEquiv μ w)))).val t = _ + rw [LinearEquiv.symm_apply_apply,spechtHilbertEquiv_coeff,spechtInclude_rep] + rfl + +instance hilbertNormed : NormedAddCommGroup (SpechtHilbert μ) := + Submodule.normedAddCommGroup _ +instance hilbertInner : InnerProductSpace ℂ (SpechtHilbert μ) := + Submodule.innerProductSpace _ + +lemma hilbertSpecht_inner (g : G μ) (v w : SpechtHilbert μ) : + inner ℂ (hilbertSpecht μ g v) (hilbertSpecht μ g w) = inner ℂ v w := by + change inner ℂ (hilbertSpecht μ g v).val (hilbertSpecht μ g w).val = inner ℂ v.val w.val + simp only [PiLp.inner_apply,RCLike.inner_apply,hilbertSpecht_coeff] + exact Equiv.sum_comp (MulAction.toPerm g⁻¹) (fun t => w.val t * star (v.val t)) + +lemma hilbertSpecht_unitary (g : G μ) (v : SpechtHilbert μ) : + ‖hilbertSpecht μ g v‖ = ‖v‖ := + ((hilbertSpecht μ g).isometryOfInner (hilbertSpecht_inner μ g)).norm_map v + +lemma hilbertSpecht_finrank : Module.finrank ℂ (SpechtHilbert μ) = Module.finrank ℂ (SpechtSpace μ) := + (spechtHilbertEquiv μ).finrank_eq.symm + +end BinaryCoordinateSweeps.Young + +end + +section + +open scoped BigOperators Classical +open Equiv Equiv.Perm Finset + +namespace BinaryCoordinateSweeps.Signed +variable {n : ℕ} + +def koszulSign (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) : ℤˣ := + ∏ x ∈ finPairsLT n, if β x.1 = true ∧ β x.2 = true then + (if g x.1 ≤ g x.2 then -1 else 1) else 1 + +@[simp] lemma koszulSign_one (β : Fin n → Bool) : koszulSign β 1 = 1 := by + apply Finset.prod_eq_one + intro x hx + simp only [one_apply] + rw [ite_eq_right (mem_finPairsLT.mp hx).not_ge] + simp + +lemma koszulSign_inv (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) : + koszulSign (β ∘ g.symm) g⁻¹ = koszulSign β g := by + unfold koszulSign + apply prod_nbij (signBijAux g⁻¹) signBijAux_mem signBijAux_injOn signBijAux_surj + rintro ⟨a,b⟩ hab + have hab' : b < a := mem_finPairsLT.mp hab + by_cases h : g.symm b < g.symm a + · simp [signBijAux, h, hab'.not_ge] + · simp [signBijAux, h, hab'.le, and_comm, le_of_not_gt h] + +lemma koszulSign_mul (β : Fin n → Bool) (f g : Equiv.Perm (Fin n)) : + koszulSign β (f*g) = koszulSign (β ∘ g.symm) f * koszulSign β g := by + rw [← koszulSign_inv β g] + unfold koszulSign + rw [← Finset.prod_mul_distrib] + apply prod_nbij (signBijAux g) signBijAux_mem signBijAux_injOn signBijAux_surj + rintro ⟨a,b⟩ hab + dsimp only [signBijAux] + rw [mem_finPairsLT] at hab + by_cases hg : g b < g a + · simp [hg, mul_apply, hab.not_ge] + obtain hf | hf := (f.injective.ne (g.injective.ne hab.ne)).lt_or_gt <;> + simp_all [mul_apply, le_of_lt, not_le_of_gt, not_lt_of_ge, and_comm] + +lemma koszulSign_sq (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) : + koszulSign β g * koszulSign β g = 1 := by + exact Int.units_mul_self _ + +end BinaryCoordinateSweeps.Signed + +end + +open scoped BigOperators Classical +open Equiv Equiv.Perm Finset + +namespace BinaryCoordinateSweeps.Signed +variable {n : ℕ} + +lemma adjacent_swap_inversion (a b i j : Fin n) (hab : a.val + 1 = b.val) (hij : j < i) : + Equiv.swap a b i ≤ Equiv.swap a b j ↔ i = b ∧ j = a := by + have hn : a ≠ b := by intro h; subst b; omega + simp only [Equiv.swap_apply_def] + split_ifs <;> simp_all only [Fin.le_def, Fin.lt_def, Fin.ext_iff, and_true, and_false, iff_true, iff_false] <;> omega + +lemma koszulSign_swap_adjacent (β : Fin n → Bool) (a b : Fin n) (hab : a.val+1=b.val) : + koszulSign β (Equiv.swap a b) = if β a = true ∧ β b = true then -1 else 1 := by + unfold koszulSign + rw [Finset.prod_eq_single (⟨b,a⟩ : Σ _ : Fin n, Fin n)] + · simp only [swap_apply_right, swap_apply_left] + rw [ite_eq_left (show a ≤ b by omega)] + simp only [and_comm] + · rintro ⟨i,j⟩ hij hne + have hi : ¬ Equiv.swap a b i ≤ Equiv.swap a b j := by + rw [adjacent_swap_inversion a b i j hab (mem_finPairsLT.mp hij)] + rintro ⟨rfl,rfl⟩; exact hne rfl + simp [hi] + · intro h + exact False.elim (h (mem_finPairsLT.mpr (show a < b by omega))) + +lemma mask_swap (β : Fin n → Bool) (a b : Fin n) (h : β a = β b) : + β ∘ Equiv.swap a b = β := by + funext i + simp only [Function.comp_apply, Equiv.swap_apply_def] + split_ifs <;> simp_all + +lemma koszulSign_conjugate (β : Fin n → Bool) (g f : Equiv.Perm (Fin n)) + (hf : β ∘ f.symm = β) : + koszulSign (β ∘ g.symm) (g*f*g⁻¹) = koszulSign β f := by + have hc : (g*f*g⁻¹)*g = g*f := by group + have h := congrArg (koszulSign β) hc + rw [koszulSign_mul β (g*f*g⁻¹) g, koszulSign_mul β g f, hf] at h + have he : koszulSign β g * koszulSign β f = koszulSign β f * koszulSign β g := mul_comm _ _ + rw [he] at h + exact mul_right_cancel h + +lemma exists_perm_pair (a b c d : Fin n) (hab : a ≠ b) (hcd : c ≠ d) : + ∃ g : Equiv.Perm (Fin n), g a = c ∧ g b = d := by + let h := Equiv.swap a c + have hh : h b ≠ c := by + intro hbc + have ha : h a = c := by simp [h] + exact hab (h.injective (ha.trans hbc.symm)) + refine ⟨Equiv.swap (h b) d * h, ?_, ?_⟩ + · change Equiv.swap (h b) d (h a) = c + rw [show h a = c by simp [h]] + exact Equiv.swap_apply_of_ne_of_ne (Ne.symm hh) hcd + · simp + +lemma koszulSign_swap (β : Fin n → Bool) (a b : Fin n) (hab : a ≠ b) + (hβ : β a = β b) : + koszulSign β (Equiv.swap a b) = if β a = true then -1 else 1 := by + have hn : 2 ≤ n := by + by_contra h + have ha := a.isLt + have hb := b.isLt + apply hab + apply Fin.ext + omega + let c : Fin n := ⟨0, by omega⟩ + let d : Fin n := ⟨1, by omega⟩ + have hcd : c ≠ d := by intro hh; have := congrArg Fin.val hh; dsimp [c,d] at this; omega + obtain ⟨g,hga,hgb⟩ := exists_perm_pair a b c d hab hcd + have hc := koszulSign_conjugate β g (Equiv.swap a b) (by simpa using mask_swap β a b hβ) + have hconj : g * Equiv.swap a b * g⁻¹ = Equiv.swap c d := by + have ht := Equiv.symm_trans_swap_trans a b g + change g * Equiv.swap a b * g⁻¹ = Equiv.swap (g a) (g b) at ht + simpa only [hga,hgb] using ht + rw [hconj, koszulSign_swap_adjacent _ c d (by rfl)] at hc + have hgca : g.symm c = a := by rw [← hga]; simp + have hgdb : g.symm d = b := by rw [← hgb]; simp + simpa only [Function.comp_apply, hgca, hgdb, ← hβ, and_self] using hc.symm + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungInducedMap.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungInducedMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..3aaa583bcd13522a67ec31ff49c158d9480b6d22 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungInducedMap.lean @@ -0,0 +1,157 @@ +import Mathlib +import OAI.Probability.BinarySweep.TensorBounds.EvenPostselection +import OAI.Probability.BinarySweep.YoungTheory.YoungSpecht + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) +variable {V : Type*} [AddCommMonoid V] [Module ℂ V] + +def tabloidVector (ρ : Representation ℂ (G μ) V) (v : V) (t : Tabloid μ) : V := + ρ ((tabloidOfPerm_surjective μ t).choose) v + +lemma tabloidVector_eq (ρ : Representation ℂ (G μ) V) (v : V) + (hv : ∀ r : rowStabilizer μ, ρ r.val v = v) (g : G μ) : + tabloidVector μ ρ v (tabloidOfPerm μ g) = ρ g v := by + let h := (tabloidOfPerm_surjective μ (tabloidOfPerm μ g)).choose + have hh : tabloidOfPerm μ h = tabloidOfPerm μ g := + (tabloidOfPerm_surjective μ (tabloidOfPerm μ g)).choose_spec + have hr : g⁻¹ * h ∈ rowStabilizer μ := (tabloidOfPerm_eq_iff μ _ _).mp hh.symm + have he := hv ⟨g⁻¹*h,hr⟩ + have he' := congrArg (ρ g) he + rw [← Module.End.mul_apply, ← map_mul, mul_inv_cancel_left] at he' + exact he' + +lemma tabloidVector_smul (ρ : Representation ℂ (G μ) V) (v : V) + (hv : ∀ r : rowStabilizer μ, ρ r.val v = v) (g : G μ) (t : Tabloid μ) : + tabloidVector μ ρ v (g • t) = ρ g (tabloidVector μ ρ v t) := by + obtain ⟨h,rfl⟩ := tabloidOfPerm_surjective μ t + rw [smul_tabloidOfPerm, tabloidVector_eq μ ρ v hv, tabloidVector_eq μ ρ v hv, + map_mul, Module.End.mul_apply] + +def fromTabloid (ρ : Representation ℂ (G μ) V) (v : V) : (Tabloid μ → ℂ) →ₗ[ℂ] V where + toFun w := ∑ t, w t • tabloidVector μ ρ v t + map_add' x y := by simp only [Pi.add_apply, add_smul, Finset.sum_add_distrib] + map_smul' c w := by simp only [Pi.smul_apply, smul_eq_mul, mul_smul, Finset.smul_sum, + RingHom.id_apply] + +lemma fromTabloid_basis (ρ : Representation ℂ (G μ) V) (v : V) (t : Tabloid μ) : + fromTabloid μ ρ v (tabloidBasis μ t) = tabloidVector μ ρ v t := by + simp [fromTabloid, tabloidBasis, Pi.single_apply] + +lemma fromTabloid_intertwines (ρ : Representation ℂ (G μ) V) (v : V) + (hv : ∀ r : rowStabilizer μ, ρ r.val v = v) (g : G μ) (w : Tabloid μ → ℂ) : + fromTabloid μ ρ v (tabloidRepresentation μ g w) = ρ g (fromTabloid μ ρ v w) := by + conv_lhs => rw [← sum_tabloidBasis μ w] + rw [map_sum, map_sum] + conv_rhs => rw [← sum_tabloidBasis μ w] + rw [map_sum, map_sum] + apply Finset.sum_congr rfl + intro t ht + simp only [map_smul, rep_basis, fromTabloid_basis, tabloidVector_smul μ ρ v hv] + +lemma spechtPoly_column (c : C μ) : + spechtRep μ c.val (spechtPoly μ) = signC μ c.val • spechtPoly μ := by + apply spechtInclude_injective μ + simp only [spechtInclude_rep, spechtInclude_poly, map_smul] + have he : tabloidRepresentation μ c.val (polytabloid μ) = + signC μ c.val • polytabloid μ := by + unfold polytabloid + rw [columnAnti_apply, map_sum] + have hh := Equiv.sum_comp (Equiv.mulLeft c) + (fun d : C μ => signC μ c.val • (signC μ d.val • + tabloidRepresentation μ d.val (tabloidBasis μ (tabloidOfPerm μ 1)))) + rw [Finset.smul_sum, ← hh] + apply Finset.sum_congr rfl + intro d hd + change tabloidRepresentation μ c.val + (signC μ d.val • tabloidRepresentation μ d.val (tabloidBasis μ (tabloidOfPerm μ 1))) = + signC μ c.val • (signC μ (c*d).val • + tabloidRepresentation μ (c*d).val (tabloidBasis μ (tabloidOfPerm μ 1))) + simp only [map_smul, Subgroup.coe_mul, map_mul, Module.End.mul_apply, smul_smul] + rw [show signC μ c.val * (signC μ c.val * signC μ d.val) = signC μ d.val from by + rw [← mul_assoc, signC_sq, one_mul]] + exact he + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical +open Equiv Equiv.Perm + +namespace BinaryCoordinateSweeps.Signed +variable {n : ℕ} + +lemma mask_ofSubtype (β : Fin n → Bool) (b : Bool) + (f : Equiv.Perm {i // β i = b}) : β ∘ (Equiv.Perm.ofSubtype f).symm = β := by + funext i + change β ((Equiv.Perm.ofSubtype f⁻¹) i) = β i + by_cases h : β i = b + · rw [Equiv.Perm.ofSubtype_apply_of_mem f⁻¹ h] + exact (f⁻¹ ⟨i,h⟩).property.trans h.symm + · rw [Equiv.Perm.ofSubtype_apply_of_not_mem f⁻¹ h] + +lemma koszulSign_ofSubtype (β : Fin n → Bool) (b : Bool) + (f : Equiv.Perm {i // β i = b}) : + koszulSign β (Equiv.Perm.ofSubtype f) = if b = true then Equiv.Perm.sign f else 1 := by + induction f using Equiv.Perm.swap_induction_on with + | one => simp + | swap_mul f a c hac ih => + rw [map_mul, koszulSign_mul, mask_ofSubtype, ofSubtype_swap_eq, + koszulSign_swap _ _ _ (fun h => hac (Subtype.ext h)) (a.property.trans c.property.symm), + a.property, ih, map_mul, Equiv.Perm.sign_swap hac] + split_ifs <;> simp + +lemma mask_of_fixed_complement (β : Fin n → Bool) (b : Bool) (g : Equiv.Perm (Fin n)) + (hg : ∀ i, β i ≠ b → g i = i) : ∀ i, β (g i) = b ↔ β i = b := by + intro i + constructor + · intro h + by_contra hi + rw [hg i hi] at h + exact hi h + · intro h + by_contra hi + have he := hg (g i) hi + have eq := g.injective he + rw [eq] at hi + exact hi h + +lemma mask_fixed_complement (β : Fin n → Bool) (b : Bool) (g : Equiv.Perm (Fin n)) + (hg : ∀ i, β i ≠ b → g i = i) : β ∘ g.symm = β := by + let f : Equiv.Perm {i // β i = b} := + g.subtypePerm (mask_of_fixed_complement β b g hg) + have he : Equiv.Perm.ofSubtype f = g := by + apply Equiv.Perm.ofSubtype_subtypePerm + intro i hi + by_contra h + exact hi (hg i h) + simpa only [he] using mask_ofSubtype β b f + +lemma koszulSign_of_fixed_complement (β : Fin n → Bool) (b : Bool) + (g : Equiv.Perm (Fin n)) (hg : ∀ i, β i ≠ b → g i = i) : + koszulSign β g = if b = true then Equiv.Perm.sign g else 1 := by + let f : Equiv.Perm {i // β i = b} := + g.subtypePerm (mask_of_fixed_complement β b g hg) + have he : Equiv.Perm.ofSubtype f = g := by + apply Equiv.Perm.ofSubtype_subtypePerm + intro i hi + by_contra h + exact hi (hg i h) + have hs := koszulSign_ofSubtype β b f + rw [← Equiv.Perm.sign_ofSubtype f, he] at hs + exact hs + +end BinaryCoordinateSweeps.Signed + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungPartition.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae04c08630d31e5ba9bb94e92b3549ea9348f387 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungPartition.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungFactor + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young + +lemma card_cellsOfRowLens (w : List ℕ) : (YoungDiagram.cellsOfRowLens w).card = w.sum := by + induction w with + | nil => simp [YoungDiagram.cellsOfRowLens] + | cons a w ih => + rw [YoungDiagram.cellsOfRowLens, Finset.card_union_of_disjoint] + · simpa using congrArg (a + ·) ih + · rw [Finset.disjoint_left] + intro x hx hy + obtain ⟨y, hy, he⟩ := Finset.mem_map.mp hy + have hx0 := (Finset.mem_product.mp hx).1 + simp only [Finset.mem_singleton] at hx0 + have hf := congrArg Prod.fst he + change Nat.succ y.1 = x.1 at hf + omega + +def diagram {n : ℕ} (p : n.Partition) : YoungDiagram := + YoungDiagram.ofRowLens (p.parts.sort (· ≥ ·)) (Multiset.pairwise_sort _ _).sortedGE + +lemma diagram_card {n : ℕ} (p : n.Partition) : (diagram p).card = n := by + change (YoungDiagram.cellsOfRowLens (p.parts.sort (· ≥ ·))).card = n + rw [card_cellsOfRowLens, ← Multiset.sum_coe, Multiset.sort_eq, p.parts_sum] + +lemma diagram_rowLens {n : ℕ} (p : n.Partition) : + (diagram p).rowLens = p.parts.sort (· ≥ ·) := by + apply YoungDiagram.rowLens_ofRowLens_eq_self + intro x hx + apply p.parts_pos + simpa only [Multiset.mem_sort] using hx + +lemma diagram_injective {n : ℕ} : Function.Injective (diagram (n := n)) := by + intro p q h + apply Nat.Partition.ext + have hh := congrArg (fun μ => (μ.rowLens : Multiset ℕ)) h + simpa only [diagram_rowLens, Multiset.sort_eq] using hh + +def cellsEquivFin {n : ℕ} (p : n.Partition) : Cell (diagram p) ≃ Fin n := + Fintype.equivFinOfCardEq (by simpa using diagram_card p) + +def conjPartition {X : Type*} [Fintype X] [DecidableEq X] : + ConjClasses (Equiv.Perm X) → (Fintype.card X).Partition := + Quotient.lift Equiv.Perm.partition (fun _ _ h => Equiv.Perm.partition_eq_of_isConj.mp h) + +lemma conjPartition_injective {X : Type*} [Fintype X] [DecidableEq X] : + Function.Injective (conjPartition (X := X)) := by + intro c d + obtain ⟨c, rfl⟩ := ConjClasses.mk_surjective c + obtain ⟨d, rfl⟩ := ConjClasses.mk_surjective d + intro h + exact ConjClasses.mk_eq_mk_iff_isConj.mpr (Equiv.Perm.partition_eq_of_isConj.mpr h) + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungPlacement.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungPlacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..104e0035a26dbd2485b64457c66e846b7156b507 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungPlacement.lean @@ -0,0 +1,234 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungDominance + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young + +variable {X J : Type*} [Fintype X] [DecidableEq X] [Fintype J] + +def movePlacement (g : Equiv.Perm X) (x : J ↪ X) : J ↪ X := x.trans g.toEmbedding + +omit [Fintype X] [DecidableEq X] [Fintype J] in +lemma movePlacement_mul (g h : Equiv.Perm X) (x : J ↪ X) : + movePlacement (g*h) x = movePlacement g (movePlacement h x) := rfl + +omit [Fintype X] [DecidableEq X] [Fintype J] in +@[simp] lemma movePlacement_one (x : J ↪ X) : movePlacement 1 x = x := by ext; rfl + +def placementRep : Representation ℂ (Equiv.Perm X) ((J ↪ X) → ℂ) where + toFun g := { + toFun := fun v x => v (movePlacement g⁻¹ x) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext; simp + map_mul' g h := by ext v x; rfl + +lemma placementRep_basis (g : Equiv.Perm X) (x : J ↪ X) : + placementRep (X := X) (J := J) g (Pi.single x (1 : ℂ)) = + (Pi.single (movePlacement g x) (1 : ℂ) : (J ↪ X) → ℂ) := by + ext y + change (Pi.single x (1 : ℂ) : (J ↪ X) → ℂ) (movePlacement g⁻¹ y) = _ + simp only [Pi.single_apply] + have he : movePlacement g⁻¹ y = x ↔ y = movePlacement g x := by + constructor <;> intro h + · have hh := congrArg (movePlacement g) h + simpa only [← movePlacement_mul, mul_inv_cancel, movePlacement_one] using hh + · subst y + simp only [← movePlacement_mul, inv_mul_cancel, movePlacement_one] + simp only [he] + +variable (μ : YoungDiagram) + +abbrev Tail := {x : Cell μ // row x ≠ 0} + +lemma perm_same_tail_tabloid (g h : G μ) + (he : ∀ x : Tail μ, g x.val = h x.val) : tabloidOfPerm μ g = tabloidOfPerm μ h := by + apply (tabloidOfPerm_eq_iff μ _ _).mpr + intro x + by_cases hx : row x ≠ 0 + · have hh := he ⟨x,hx⟩ + change row (g⁻¹ (h x)) = row x + rw [← hh] + exact congrArg row (g.symm_apply_apply x) + · have hx0 : row x = 0 := not_ne_iff.mp hx + change row (g⁻¹ (h x)) = row x + rw [hx0] + by_contra hr + have hh := he ⟨g⁻¹ (h x),hr⟩ + change g (g.symm (h x)) = _ at hh + rw [g.apply_symm_apply] at hh + have hh' : x = g⁻¹ (h x) := h.injective hh + exact hr (hh' ▸ hx0) + +lemma placement_extends (x : Tail μ ↪ Cell μ) : + ∃ g : G μ, ∀ a : Tail μ, g a.val = x a := + Equiv.Perm.exists_extending_pair Subtype.val x Subtype.val_injective x.injective + +def placementTabloid (x : Tail μ ↪ Cell μ) : Tabloid μ := + tabloidOfPerm μ (placement_extends μ x).choose + +lemma placementTabloid_eq (x : Tail μ ↪ Cell μ) (g : G μ) + (hg : ∀ a : Tail μ, g a.val = x a) : placementTabloid μ x = tabloidOfPerm μ g := by + apply perm_same_tail_tabloid + intro a + rw [(placement_extends μ x).choose_spec, hg] + +lemma placementTabloid_surjective : Function.Surjective (placementTabloid μ) := by + intro t + obtain ⟨g,rfl⟩ := tabloidOfPerm_surjective μ t + exact ⟨⟨fun a => g a.val, g.injective.comp Subtype.val_injective⟩, + placementTabloid_eq μ _ g (fun _ => rfl)⟩ + +lemma placementTabloid_move (g : G μ) (x : Tail μ ↪ Cell μ) : + placementTabloid μ (movePlacement g x) = g • placementTabloid μ x := by + obtain ⟨h,hh⟩ := placement_extends μ x + rw [placementTabloid_eq μ x h hh, smul_tabloidOfPerm] + apply placementTabloid_eq + intro a + change g (h a.val) = g (x a) + rw [hh] + +def spechtPlacement : SpechtSpace μ →ₗ[ℂ] ((Tail μ ↪ Cell μ) → ℂ) where + toFun v x := spechtInclude μ v (placementTabloid μ x) + map_add' v w := by ext x; simp + map_smul' z v := by ext x; simp + +lemma spechtPlacement_injective : Function.Injective (spechtPlacement μ) := by + intro v w h + apply spechtInclude_injective μ + ext t + obtain ⟨x,rfl⟩ := placementTabloid_surjective μ t + exact congrFun h x + +lemma spechtPlacement_intertwines (g : G μ) (v : SpechtSpace μ) : + spechtPlacement μ (spechtRep μ g v) = placementRep g (spechtPlacement μ v) := by + ext x + change spechtInclude μ (spechtRep μ g v) (placementTabloid μ x) = + spechtInclude μ v (placementTabloid μ (movePlacement g⁻¹ x)) + rw [spechtInclude_rep, placementTabloid_move] + rfl + +theorem specht_finrank_le_placements : + Module.finrank ℂ (SpechtSpace μ) ≤ Fintype.card (Tail μ ↪ Cell μ) := by + simpa using LinearMap.finrank_le_finrank_of_injective (spechtPlacement_injective μ) + +lemma card_tail : Fintype.card (Tail μ) = Fintype.card (Cell μ) - μ.rowLen 0 := by + rw [Fintype.card_subtype_compl] + congr 1 + rw [Fintype.card_subtype] + have h := rowPrefix_succ μ 0 + simpa [rowPrefix] using h + +theorem specht_finrank_le_power : Module.finrank ℂ (SpechtSpace μ) ≤ + Fintype.card (Cell μ) ^ (Fintype.card (Cell μ) - μ.rowLen 0) := by + calc + _ ≤ Fintype.card (Tail μ ↪ Cell μ) := specht_finrank_le_placements μ + _ ≤ Fintype.card (Tail μ → Cell μ) := Fintype.card_le_of_injective + (fun f : Tail μ ↪ Cell μ => (f : Tail μ → Cell μ)) DFunLike.coe_injective + _ = _ := by rw [Fintype.card_fun, card_tail] + +lemma col_lt_firstRow (x : Cell μ) : col x < μ.rowLen 0 := by + exact lt_of_lt_of_le (YoungDiagram.mem_iff_lt_rowLen.mp x.property) + (μ.rowLen_anti 0 (row x) (Nat.zero_le _)) + +lemma placement_column_collision (x : J ↪ Cell μ) + (hj : Fintype.card J < Fintype.card (Cell μ) - μ.rowLen 0) : + ∃ a b : Cell μ, a ≠ b ∧ a ∉ Set.range x ∧ b ∉ Set.range x ∧ col a = col b := by + classical + by_contra hn + have hinj : Function.Injective (fun a : {a : Cell μ // a ∉ Set.range x} => + (⟨col a.val, col_lt_firstRow μ a.val⟩ : Fin (μ.rowLen 0))) := by + intro a b hab + apply Subtype.ext + by_contra hne + exact hn ⟨a.val,b.val,hne,a.property,b.property,congrArg Fin.val hab⟩ + have hh := Fintype.card_le_of_injective _ hinj + rw [Fintype.card_subtype_compl, Fintype.card_range, Fintype.card_fin] at hh + have hjn : Fintype.card J ≤ Fintype.card (Cell μ) := Fintype.card_le_of_injective x x.injective + omega + +section ColumnSum +variable {V : Type*} [AddCommGroup V] [Module ℂ V] + +def columnSum (ρ : Representation ℂ (G μ) V) : Module.End ℂ V := + ∑ c : C μ, signC μ c.val • ρ c.val + +lemma columnSum_apply (ρ : Representation ℂ (G μ) V) (v : V) : + columnSum μ ρ v = ∑ c : C μ, signC μ c.val • ρ c.val v := by + simp [columnSum, LinearMap.sum_apply] + +lemma columnSum_rep (ρ : Representation ℂ (G μ) V) (c : C μ) (v : V) : + columnSum μ ρ (ρ c.val v) = signC μ c.val • columnSum μ ρ v := by + rw [columnSum_apply, columnSum_apply, Finset.smul_sum] + have h := Equiv.sum_comp (Equiv.mulRight c) + (fun d : C μ => signC μ c.val • (signC μ d.val • ρ d.val v)) + rw [← h] + apply Finset.sum_congr rfl + intro d hd + change signC μ d.val • ρ d.val (ρ c.val v) = + signC μ c.val • (signC μ (d * c).val • ρ (d * c).val v) + simp only [Subgroup.coe_mul, map_mul, Module.End.mul_apply, smul_smul] + rw [show signC μ c.val * (signC μ d.val * signC μ c.val) = signC μ d.val from by + calc + _ = signC μ d.val * (signC μ c.val * signC μ c.val) := by ring + _ = signC μ d.val := by rw [signC_sq, mul_one]] + +end ColumnSum + +lemma columnSum_placement_zero + (hj : Fintype.card J < Fintype.card (Cell μ) - μ.rowLen 0) : + columnSum μ (placementRep (X := Cell μ) (J := J)) = 0 := by + have hb (x : J ↪ Cell μ) : columnSum μ placementRep (Pi.single x (1 : ℂ)) = 0 := by + obtain ⟨a,b,hne,ha,hb,hcol⟩ := placement_column_collision μ x hj + let c : C μ := ⟨Equiv.swap a b, swap_mem_fiber _ hcol⟩ + have hf : movePlacement c.val x = x := by + apply Function.Embedding.ext + intro j + change Equiv.swap a b (x j) = x j + apply Equiv.swap_apply_of_ne_of_ne + · exact fun h => ha ⟨j,h⟩ + · exact fun h => hb ⟨j,h⟩ + have he := columnSum_rep μ placementRep c (Pi.single x (1 : ℂ)) + rw [placementRep_basis, hf, show signC μ c.val = -1 from signC_swap μ hne, + neg_one_smul] at he + ext y + have hy := congrFun he y + simp only [Pi.neg_apply] at hy + change columnSum μ placementRep (Pi.single x (1 : ℂ)) y = 0 + linear_combination (1/2 : ℂ) * hy + apply LinearMap.ext + intro v + have hv : v = ∑ x : J ↪ Cell μ, v x • Pi.single x (1 : ℂ) := by + ext y + simp [Pi.single_apply, Finset.sum_apply] + conv_lhs => rw [hv] + simp only [map_sum, map_smul, hb, smul_zero, Finset.sum_const_zero, LinearMap.zero_apply] + +theorem no_short_placement_intertwiner + (hj : Fintype.card J < Fintype.card (Cell μ) - μ.rowLen 0) + (f : SpechtSpace μ →ₗ[ℂ] ((J ↪ Cell μ) → ℂ)) + (hf : ∀ g v, f (spechtRep μ g v) = placementRep g (f v)) : f = 0 := by + have he : columnSum μ placementRep (f (spechtPoly μ)) = + (Fintype.card (C μ) : ℂ) • f (spechtPoly μ) := by + rw [columnSum_apply] + simp_rw [← hf] + have hh := congrArg f (spechtInclude_column_sum (μ := μ)) + simpa only [map_sum, map_smul] using hh + rw [columnSum_placement_zero μ hj, LinearMap.zero_apply] at he + have hp : f (spechtPoly μ) = 0 := (smul_eq_zero.mp he.symm).resolve_left + (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) + let f' := f.intertwiningMap_of_isIntertwiningMap (spechtRep μ) placementRep hf + rcases Representation.IsIrreducible.injective_or_eq_zero (k := ℂ) (G := G μ) + (V := SpechtSpace μ) (W := (J ↪ Cell μ) → ℂ) f' with hinj | hz + · exact False.elim (spechtPoly_ne_zero μ (hinj (hp.trans f.map_zero.symm))) + · exact congrArg (fun g => g.toLinearMap) hz + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungResolution.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungResolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ac4bbf580e85ecdc4dc2bf5ea4406ef831a0a15 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungResolution.lean @@ -0,0 +1,142 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungClassification +import OAI.Probability.BinarySweep.Representations.MatrixIsotypicWhitening +import OAI.Probability.BinarySweep.Representations.IsotypicOrthogonal + +namespace OAI + +noncomputable section + +section + +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +open Representation + +abbrev PartitionHilbert {n : ℕ} (p : n.Partition) := SpechtHilbert (diagram p) + +def partitionHilbertRep {n : ℕ} (p : n.Partition) : + Representation ℂ (Equiv.Perm (Fin n)) (PartitionHilbert p) := + (hilbertSpecht (diagram p)).comp (cellsEquivFin p).symm.permCongrHom.toMonoidHom + +instance {n : ℕ} (p : n.Partition) : (partitionHilbertRep p).IsIrreducible := + Irrep.irreducible_comp_equiv _ _ + +def partitionHilbertEquiv {n : ℕ} (p : n.Partition) : + (partitionRep p).Equiv (partitionHilbertRep p) := + .mk (spechtHilbertEquiv (diagram p)) (by + intro g + apply LinearMap.ext + intro v + change spechtHilbertEquiv (diagram p) (spechtRep (diagram p) _ v) = + spechtHilbertEquiv (diagram p) (spechtRep (diagram p) _ + ((spechtHilbertEquiv (diagram p)).symm (spechtHilbertEquiv (diagram p) v))) + rw [LinearEquiv.symm_apply_apply]) + +lemma partitionHilbertRep_unitary {n : ℕ} (p : n.Partition) + (g : Equiv.Perm (Fin n)) (v : PartitionHilbert p) : + ‖partitionHilbertRep p g v‖=‖v‖ := hilbertSpecht_unitary _ _ _ + +lemma partitionHilbertRep_equiv_injective {n : ℕ} (p q : n.Partition) + (e : (partitionHilbertRep p).Equiv (partitionHilbertRep q)) : p=q := + partitionRep_equiv_injective p q + ((partitionHilbertEquiv p).trans (e.trans (partitionHilbertEquiv q).symm)) + +lemma partitionHilbertRep_complete {n : ℕ} {W : Type*} [AddCommGroup W] [Module ℂ W] + [FiniteDimensional ℂ W] (σ : Representation ℂ (Equiv.Perm (Fin n)) W) + [σ.IsIrreducible] : ∃ p : n.Partition, Nonempty (σ.Equiv (partitionHilbertRep p)) := by + obtain ⟨p,⟨e⟩⟩ := partitionRep_complete σ + exact ⟨p,⟨e.trans (partitionHilbertEquiv p)⟩⟩ + +lemma partition_isotypic_top {n : ℕ} {W : Type*} [AddCommGroup W] [Module ℂ W] + [FiniteDimensional ℂ W] (σ : Representation ℂ (Equiv.Perm (Fin n)) W) : + (⨆ p : n.Partition, Irrep.isotypicSpan (partitionHilbertRep p) σ)=⊤ := by + apply Irrep.iSup_isotypic_eq_top σ (fun p => partitionHilbertRep p) + intro U _ _ _ τ hτ + have := hτ + exact partitionHilbertRep_complete τ + +lemma partition_isotypic_orthogonal {n : ℕ} {W : Type*} + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (σ : Representation ℂ (Equiv.Perm (Fin n)) W) + (hσ : ∀ g v, ‖σ g v‖=‖v‖) : + OrthogonalFamily ℂ (fun p : n.Partition => Irrep.isotypicSpan (partitionHilbertRep p) σ) + (fun p => (Irrep.isotypicSpan (partitionHilbertRep p) σ).subtypeₗᵢ) := by + apply OrthogonalFamily.of_pairwise + intro p q hpq + apply Irrep.isotypic_orthogonal (partitionHilbertRep q) (partitionHilbertRep p) σ + (partitionHilbertRep_unitary q) (partitionHilbertRep_unitary p) hσ + rintro ⟨e⟩ + exact hpq (partitionHilbertRep_equiv_injective q p e).symm + +theorem partition_projection_sum {n : ℕ} {W : Type*} + [NormedAddCommGroup W] [InnerProductSpace ℂ W] [FiniteDimensional ℂ W] + (σ : Representation ℂ (Equiv.Perm (Fin n)) W) + (hσ : ∀ g v, ‖σ g v‖=‖v‖) (v : W) : + (∑ p : n.Partition, (Irrep.isotypicSpan (partitionHilbertRep p) σ).starProjection v)=v := by + apply (partition_isotypic_orthogonal σ hσ).sum_projection_of_mem_iSup + rw [partition_isotypic_top] + trivial + +end BinaryCoordinateSweeps.Young + +end + +open scoped BigOperators Classical +open Equiv Equiv.Perm Finset + +namespace BinaryCoordinateSweeps.Signed + +def pairWeight {n : ℕ} (β : Fin n → Bool) (g : Equiv.Perm (Fin n)) + (a b : Fin n) : ℤˣ := + if b pairWeight β g x.1 x.2)] + have he : finPairsLT n = Finset.univ.filter (fun x : Σ _ : Fin n, Fin n => x.2 by_cases h1 : β x.1=true <;> by_cases h2 : β x.2=true <;> simp [h,h1,h2] + +def sumPerm {n m : ℕ} (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) : + Equiv.Perm (Fin (n+m)) := finSumFinEquiv.permCongr (Equiv.sumCongr g h) + +@[simp] lemma sumPerm_left {n m : ℕ} (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) (i : Fin n) : + sumPerm g h (i.castAdd m) = (g i).castAdd m := by + change sumPerm g h (finSumFinEquiv (Sum.inl i)) = finSumFinEquiv (Sum.inl (g i)) + simp [sumPerm] + +@[simp] lemma sumPerm_right {n m : ℕ} (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) (i : Fin m) : + sumPerm g h (i.natAdd n) = (h i).natAdd n := by + change sumPerm g h (finSumFinEquiv (Sum.inr i)) = finSumFinEquiv (Sum.inr (h i)) + simp [sumPerm] + +theorem koszulSign_sum {n m : ℕ} (β : Fin (n+m) → Bool) + (g : Equiv.Perm (Fin n)) (h : Equiv.Perm (Fin m)) : + koszulSign β (sumPerm g h) = + koszulSign (fun i => β (i.castAdd m)) g * koszulSign (fun i => β (i.natAdd n)) h := by + have hll (a b : Fin n) : pairWeight β (sumPerm g h) (a.castAdd m) (b.castAdd m) = + pairWeight (fun i => β (i.castAdd m)) g a b := by + simp only [pairWeight, sumPerm_left, Fin.lt_def, Fin.le_def, Fin.val_castAdd] + have hrr (a b : Fin m) : pairWeight β (sumPerm g h) (a.natAdd n) (b.natAdd n) = + pairWeight (fun i => β (i.natAdd n)) h a b := by + simp [pairWeight] + have hlr (a : Fin n) (b : Fin m) : pairWeight β (sumPerm g h) (a.castAdd m) (b.natAdd n) = 1 := by + simp [pairWeight,Fin.lt_def, show ¬ n+b.val + columnAnti μ ((tabloidRepresentation μ).asModuleEquiv w) (tabloidOfPerm μ 1)) huv + simp only [map_add, Pi.add_apply, hc, zero_add, polyModule, + LinearEquiv.apply_symm_apply, columnAnti_polytabloid, + Pi.smul_apply, polytabloid_base, smul_eq_mul, mul_one] at hh + exact hh + have hne : (Fintype.card (C μ) : ℂ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hSV : Specht μ ≤ V := (Specht_le_iff μ V).mpr + ((scalar_polyModule_mem_iff μ V (he.trans_ne hne)).mp hav) + apply le_antisymm _ bot_le + calc U ≤ U ⊓ V := le_inf le_rfl (hU.le.trans hSV) + _ = ⊥ := hUV.inf_eq_bot + · have hSU : Specht μ ≤ U := (Specht_le_iff μ U).mpr + ((scalar_polyModule_mem_iff μ U hc).mp hau) + exact (hU.not_ge hSU).elim + +instance Specht_isSimpleModule : IsSimpleModule ℂ[G μ] (Specht μ) := + isSimpleModule_iff_isAtom.mpr (Specht_isAtom μ) + +end BinaryCoordinateSweeps.Young + +end + +open scoped MonoidAlgebra BigOperators + +namespace BinaryCoordinateSweeps.Young + +variable {A V : Type*} [Ring A] [Algebra ℂ A] [AddCommGroup V] + [Module A V] [Module ℂ V] [IsScalarTower ℂ A V] + +def restrictLinearEquiv : RestrictScalars ℂ A V ≃ₗ[ℂ] V where + __ := RestrictScalars.addEquiv ℂ A V + map_smul' a v := by + change RestrictScalars.addEquiv ℂ A V (a • v) = a • RestrictScalars.addEquiv ℂ A V v + rw [RestrictScalars.addEquiv_map_smul, algebraMap_smul] + +variable (μ : YoungDiagram) +abbrev SpechtSpace := RestrictScalars ℂ ℂ[G μ] (Specht μ) + +-- Use the same additive monoid for the restricted module and its additive group. +instance SpechtSpace.instAddCommGroup : AddCommGroup (SpechtSpace μ) := + Module.addCommMonoidToAddCommGroup ℂ + +instance : @Module ℂ (SpechtSpace μ) _ (SpechtSpace.instAddCommGroup μ).toAddCommMonoid := + RestrictScalars.module ℂ ℂ[G μ] (Specht μ) + +def spechtRep : Representation ℂ (G μ) (SpechtSpace μ) := Representation.ofModule (Specht μ) + +instance : Representation.IsIrreducible (k := ℂ) (G := G μ) (V := SpechtSpace μ) (spechtRep μ) := + (Representation.isSimpleModule_iff_irreducible_ofModule (Specht μ)).mp inferInstance + +instance : FiniteDimensional ℂ (Specht μ) := + Module.Finite.of_injective ((Specht μ).subtype.restrictScalars ℂ) Subtype.val_injective + +instance : FiniteDimensional ℂ (SpechtSpace μ) := + Module.Finite.equiv (restrictLinearEquiv (A := ℂ[G μ]) (V := Specht μ)).symm + +def spechtInclude : SpechtSpace μ →ₗ[ℂ] (Tabloid μ → ℂ) := + (tabloidRepresentation μ).asModuleEquiv.toLinearMap.comp + (((Specht μ).subtype.restrictScalars ℂ).comp + (restrictLinearEquiv (A := ℂ[G μ]) (V := Specht μ)).toLinearMap) + +lemma spechtInclude_injective : Function.Injective (spechtInclude μ) := + (tabloidRepresentation μ).asModuleEquiv.injective.comp + (Subtype.val_injective.comp restrictLinearEquiv.injective) + +lemma spechtInclude_rep (g : G μ) (v : SpechtSpace μ) : + spechtInclude μ (spechtRep μ g v) = tabloidRepresentation μ g (spechtInclude μ v) := by + change (tabloidRepresentation μ).asModuleEquiv + ((RestrictScalars.addEquiv ℂ ℂ[G μ] (Specht μ) (Representation.ofModule (Specht μ) g v)).val) = _ + simp only [Representation.ofModule, MonoidAlgebra.lift_symm_apply, + RestrictScalars.lsmul_apply_apply, AddEquiv.apply_symm_apply, Submodule.coe_smul_of_tower, + Representation.asModuleEquiv_map_smul, + Representation.asAlgebraHom_single, one_smul] + rfl + +def spechtPoly : SpechtSpace μ := + (restrictLinearEquiv (A := ℂ[G μ]) (V := Specht μ)).symm + ⟨polyModule μ, polyModule_mem_Specht μ⟩ + +lemma spechtInclude_poly : spechtInclude μ (spechtPoly μ) = polytabloid μ := by + change (tabloidRepresentation μ).asModuleEquiv + ((restrictLinearEquiv (A := ℂ[G μ]) (V := Specht μ) + ((restrictLinearEquiv (A := ℂ[G μ]) (V := Specht μ)).symm + (⟨polyModule μ, polyModule_mem_Specht μ⟩ : Specht μ))).val) = _ + rw [LinearEquiv.apply_symm_apply] + exact (tabloidRepresentation μ).asModuleEquiv.apply_symm_apply _ + +lemma spechtPoly_ne_zero : spechtPoly μ ≠ 0 := by + intro h + have he := congrArg (spechtInclude μ) h + rw [map_zero, spechtInclude_poly] at he + exact polytabloid_ne_zero μ he + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungTabloid.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungTabloid.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0179d13df68fbcf30dcf88d98f7c54252116569 --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungTabloid.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Probability.BinarySweep.YoungTheory.YoungFactor + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) +abbrev G := Equiv.Perm (Cell μ) + +def labels (π : G μ) : Cell μ → ℕ := fun x => row (π⁻¹ x) + +def Tabloid := Set.range (labels μ) + +def tabloidOfPerm (π : G μ) : Tabloid μ := ⟨labels μ π, π, rfl⟩ + +lemma tabloidOfPerm_surjective : Function.Surjective (tabloidOfPerm μ) := by + rintro ⟨f, π, rfl⟩ + exact ⟨π, rfl⟩ + +instance : Fintype (Tabloid μ) := Fintype.ofSurjective _ (tabloidOfPerm_surjective μ) +instance : DecidableEq (Tabloid μ) := Classical.decEq _ + +noncomputable def actTabloid (π : G μ) (t : Tabloid μ) : Tabloid μ := by + refine ⟨fun x => t.val (π⁻¹ x), ?_⟩ + obtain ⟨g, hg⟩ := t.property + refine ⟨π * g, ?_⟩ + ext x + simp [labels, ← hg] + +instance : MulAction (G μ) (Tabloid μ) where + smul := actTabloid μ + one_smul t := by + change actTabloid μ 1 t = t + apply Subtype.ext + funext x + simp [actTabloid] + mul_smul π σ t := by + change actTabloid μ (π * σ) t = actTabloid μ π (actTabloid μ σ t) + apply Subtype.ext + funext x + simp [actTabloid] + +lemma smul_tabloid_apply (π : G μ) (t : Tabloid μ) (x : Cell μ) : + (π • t).val x = t.val (π⁻¹ x) := rfl + +@[simp] lemma smul_tabloidOfPerm (π σ : G μ) : + π • tabloidOfPerm μ σ = tabloidOfPerm μ (π * σ) := by + apply Subtype.ext + funext x + simp [smul_tabloid_apply, tabloidOfPerm, labels] + +lemma tabloidOfPerm_eq_iff (π σ : G μ) : + tabloidOfPerm μ π = tabloidOfPerm μ σ ↔ π⁻¹ * σ ∈ rowStabilizer μ := by + constructor + · intro h x + have he := congrArg (fun t : Tabloid μ => t.val (σ x)) h + simpa [tabloidOfPerm, labels] using he + · intro h + apply Subtype.ext + funext x + have he := h (σ⁻¹ x) + simpa [tabloidOfPerm, labels] using he + +lemma tabloidOfPerm_row_mul (π : G μ) (r : rowStabilizer μ) : + tabloidOfPerm μ (π * r.val) = tabloidOfPerm μ π := by + apply (tabloidOfPerm_eq_iff μ _ _).mpr + simp + +def tabloidRepresentation : Representation ℂ (G μ) (Tabloid μ → ℂ) where + toFun π := + { toFun := fun v t => v (π⁻¹ • t) + map_add' := by intros; rfl + map_smul' := by intros; rfl } + map_one' := by ext v t; simp + map_mul' π σ := by ext v t; simp [mul_smul] + +lemma tabloidRepresentation_apply (π : G μ) (v : Tabloid μ → ℂ) (t : Tabloid μ) : + tabloidRepresentation μ π v t = v (π⁻¹ • t) := rfl + +def tabloidBasis (t : Tabloid μ) : Tabloid μ → ℂ := Pi.single t 1 + +lemma rep_basis (π : G μ) (t : Tabloid μ) : + tabloidRepresentation μ π (tabloidBasis μ t) = tabloidBasis μ (π • t) := by + ext u + simp only [tabloidRepresentation_apply, tabloidBasis, Pi.single_apply] + simp only [inv_smul_eq_iff] + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/BinarySweep/YoungTheory/YoungTranspose.lean b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungTranspose.lean new file mode 100644 index 0000000000000000000000000000000000000000..6351ed6f40e33a6676bbe3e38d3c319c2af8f0be --- /dev/null +++ b/lean/OAI/Probability/BinarySweep/YoungTheory/YoungTranspose.lean @@ -0,0 +1,137 @@ +import Mathlib +import OAI.Probability.BinarySweep.Representations.IrrepTransport +import OAI.Probability.BinarySweep.YoungTheory.YoungInducedMap + +namespace OAI + +noncomputable section +open scoped BigOperators Classical + +namespace BinaryCoordinateSweeps.Young +variable (μ : YoungDiagram) +variable {V : Type*} [AddCommMonoid V] [Module ℂ V] + +def signTwist (ρ : Representation ℂ (G μ) V) : Representation ℂ (G μ) V where + toFun g := signC μ g • ρ g + map_one' := by simp + map_mul' g h := by + ext v + simp only [map_mul, LinearMap.smul_apply, Module.End.mul_apply, map_smul, smul_smul] + rw [mul_comm] + +def signTwistSubrep (ρ : Representation ℂ (G μ) V) : + Subrepresentation ρ ≃o Subrepresentation (signTwist μ ρ) where + toFun U := ⟨U.toSubmodule, fun g v hv => U.toSubmodule.smul_mem _ (U.apply_mem_toSubmodule g hv)⟩ + invFun U := ⟨U.toSubmodule, fun g v hv => by + have h := U.toSubmodule.smul_mem (signC μ g) (U.apply_mem_toSubmodule g hv) + change signC μ g • (signC μ g • ρ g v) ∈ U.toSubmodule at h + rwa [smul_smul, signC_sq, one_smul] at h⟩ + left_inv U := rfl + right_inv U := rfl + map_rel_iff' := Iff.rfl + +instance signTwist_irreducible {V : Type*} [AddCommGroup V] [Module ℂ V] + (ρ : Representation ℂ (G μ) V) [ρ.IsIrreducible] : + Representation.IsIrreducible (k := ℂ) (G := G μ) (V := V) (signTwist μ ρ) := + (signTwistSubrep μ ρ).isSimpleOrder_iff.mp inferInstance + +def transposeCells : Cell μ ≃ Cell μ.transpose where + toFun x := ⟨x.val.swap, YoungDiagram.mem_transpose.mpr (by simp)⟩ + invFun x := ⟨x.val.swap, YoungDiagram.mem_transpose.mp x.property⟩ + left_inv x := by apply Subtype.ext; exact Prod.swap_swap _ + right_inv x := by apply Subtype.ext; exact Prod.swap_swap _ + +lemma transpose_sign (g : G μ) : signC μ.transpose ((transposeCells μ).permCongr g) = + signC μ g := by rw [signC_eq, signC_eq, Equiv.Perm.sign_permCongr] + +lemma transpose_row_to_col (r : rowStabilizer μ) : + (transposeCells μ).permCongr r.val ∈ colStabilizer μ.transpose := by + intro x + exact r.property ((transposeCells μ).symm x) + +lemma transpose_col_to_row (c : C μ) : + (transposeCells μ).permCongr c.val ∈ rowStabilizer μ.transpose := by + intro x + exact c.property ((transposeCells μ).symm x) + +def transposeRep : Representation ℂ (G μ) (SpechtSpace μ.transpose) := + (spechtRep μ.transpose).comp (transposeCells μ).permCongrHom.toMonoidHom + +instance : Representation.IsIrreducible (k := ℂ) (G := G μ) + (V := SpechtSpace μ.transpose) (transposeRep μ) := + Irrep.irreducible_comp_equiv _ _ + +lemma transposePoly_row_fixed (r : rowStabilizer μ) : + signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ) r.val (spechtPoly μ.transpose) = spechtPoly μ.transpose := by + change signC μ r.val • spechtRep μ.transpose ((transposeCells μ).permCongr r.val) + (spechtPoly μ.transpose) = _ + rw [spechtPoly_column μ.transpose ⟨_,transpose_row_to_col μ r⟩, + transpose_sign, smul_smul, signC_sq, one_smul] + +def transposeMap : SpechtSpace μ →ₗ[ℂ] SpechtSpace μ.transpose := + (fromTabloid μ (signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ)) (spechtPoly μ.transpose)).comp (spechtInclude μ) + +lemma transposeMap_intertwines (g : G μ) (v : SpechtSpace μ) : + transposeMap μ (spechtRep μ g v) = + signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ) g (transposeMap μ v) := by + simp only [transposeMap, LinearMap.comp_apply, spechtInclude_rep] + exact fromTabloid_intertwines μ _ _ (transposePoly_row_fixed μ) g _ + +lemma row_fixes_base_evaluation (r : rowStabilizer μ) (v : Tabloid μ → ℂ) : + tabloidRepresentation μ r.val v (tabloidOfPerm μ 1) = v (tabloidOfPerm μ 1) := by + change v (r.val⁻¹ • tabloidOfPerm μ 1) = _ + rw [smul_tabloidOfPerm, mul_one] + congr 1 + exact (tabloidOfPerm_eq_iff μ _ _).mpr (by simp [r.property]) + +lemma transposeMap_poly_evaluation : spechtInclude μ.transpose + (transposeMap μ (spechtPoly μ)) (tabloidOfPerm μ.transpose 1) = Fintype.card (C μ) := by + change spechtInclude μ.transpose + (fromTabloid μ (signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ)) (spechtPoly μ.transpose) + (spechtInclude μ (spechtPoly μ))) _ = _ + rw [spechtInclude_poly, polytabloid, columnAnti_apply, map_sum] + simp only [map_smul, rep_basis, smul_tabloidOfPerm, mul_one, fromTabloid_basis] + simp_rw [tabloidVector_eq μ _ _ (transposePoly_row_fixed μ)] + have ht (c : C μ) : signC μ c.val • signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ) c.val + (spechtPoly μ.transpose) = spechtRep μ.transpose ((transposeCells μ).permCongr c.val) + (spechtPoly μ.transpose) := by + change signC μ c.val • (signC μ c.val • + spechtRep μ.transpose ((transposeCells μ).permCongr c.val) (spechtPoly μ.transpose)) = _ + rw [smul_smul, signC_sq, one_smul] + simp_rw [ht] + rw [map_sum] + simp only [Finset.sum_apply, spechtInclude_rep, spechtInclude_poly] + have he (c : C μ) : tabloidRepresentation μ.transpose ((transposeCells μ).permCongr c.val) + (polytabloid μ.transpose) (tabloidOfPerm μ.transpose 1) = 1 := by + rw [row_fixes_base_evaluation μ.transpose ⟨_,transpose_col_to_row μ c⟩, + polytabloid_base] + simp only [he, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] + +theorem specht_transpose_sign : Nonempty (Representation.Equiv (spechtRep μ) + (signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ))) := by + let f := (transposeMap μ).intertwiningMap_of_isIntertwiningMap + (spechtRep μ) (signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ)) (transposeMap_intertwines μ) + have hn : f ≠ 0 := by + intro h + have hz : transposeMap μ (spechtPoly μ) = 0 := by + exact congrArg (fun g : Representation.IntertwiningMap (spechtRep μ) + (signTwist (V := SpechtSpace μ.transpose) μ (transposeRep μ)) => g (spechtPoly μ)) h + have he := transposeMap_poly_evaluation μ + rw [hz, map_zero, Pi.zero_apply] at he + exact (Nat.cast_ne_zero.mpr Fintype.card_ne_zero : (Fintype.card (C μ) : ℂ) ≠ 0) he.symm + have : (signTwist μ (transposeRep μ)).IsIrreducible := + signTwist_irreducible μ (transposeRep μ) + have hf := (Representation.IsIrreducible.bijective_or_eq_zero (k := ℂ) (G := G μ) + (V := SpechtSpace μ) (W := SpechtSpace μ.transpose) f).resolve_right hn + exact ⟨f.ofBijective hf⟩ + +lemma specht_finrank_transpose : Module.finrank ℂ (SpechtSpace μ) = + Module.finrank ℂ (SpechtSpace μ.transpose) := by + obtain ⟨e⟩ := specht_transpose_sign μ + exact e.toLinearEquiv.finrank_eq + +end BinaryCoordinateSweeps.Young + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AmplitudeLaw.lean b/lean/OAI/Probability/ClassicalON/AmplitudeLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3e4769821fafccc28e6f733d0de84192f92c536 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AmplitudeLaw.lean @@ -0,0 +1,137 @@ +import OAI.Probability.ClassicalON.FinFKG + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory Set +namespace ClassicalON + +abbrev Amplitude := Set.Icc (0 : ℝ) 1 + +def amplitudeReference : Measure Amplitude := volume.comap Subtype.val + +instance amplitudeReference_isProbability : IsProbabilityMeasure amplitudeReference := by + constructor + rw [amplitudeReference,comap_subtype_coe_apply measurableSet_Icc volume .univ] + simp only [Set.image_univ,Subtype.range_val] + norm_num + +def transverseAmplitude (r : Amplitude) : ℝ := Real.sqrt (1-(r:ℝ)^2) + +theorem continuous_transverseAmplitude : Continuous transverseAmplitude := by + unfold transverseAmplitude; fun_prop + +theorem transverseAmplitude_nonneg (r : Amplitude) : 0 ≤ transverseAmplitude r := Real.sqrt_nonneg _ + +theorem transverseAmplitude_antitone : Antitone transverseAmplitude := by + intro r s hrs + apply Real.sqrt_le_sqrt + have hr := r.property.1 + have hs := s.property.1 + change (r : ℝ) ≤ s at hrs + nlinarith + +theorem transverseAmplitude_inf (r s : Amplitude) : + transverseAmplitude (r⊓s)=max (transverseAmplitude r) (transverseAmplitude s) := by + rcases le_total r s with h | h + · rw [inf_eq_left.mpr h,max_eq_left (transverseAmplitude_antitone h)] + · rw [inf_eq_right.mpr h,max_eq_right (transverseAmplitude_antitone h)] + +theorem transverseAmplitude_sup (r s : Amplitude) : + transverseAmplitude (r⊔s)=min (transverseAmplitude r) (transverseAmplitude s) := by + rcases le_total r s with h | h + · rw [sup_eq_right.mpr h,min_eq_right (transverseAmplitude_antitone h)] + · rw [sup_eq_left.mpr h,min_eq_left (transverseAmplitude_antitone h)] + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def isingAmplitudePartition (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : ℝ := + amplitudePartition isingReference (isingEnergy left right) left right b (fun v => (r v : ℝ)) + +def planarAmplitudePartition (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : ℝ := + amplitudePartition planarReference (planarEnergy left right) left right b (fun v => transverseAmplitude (r v)) + +def amplitudeDensity (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : ℝ := + isingAmplitudePartition left right b r*planarAmplitudePartition left right b r + +theorem isingAmplitudePartition_pos (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + 0 < isingAmplitudePartition left right b r := + amplitudePartition_pos _ _ _ _ _ (fun _ => continuous_of_discreteTopology) _ + +theorem planarAmplitudePartition_pos (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + 0 continuous_of_discreteTopology)).comp + fun_prop + +theorem continuous_planarAmplitudePartition (left right : E → V) (b : E → ℝ) : + Continuous (planarAmplitudePartition left right b) := by + apply (continuous_amplitudePartition planarReference (planarEnergy left right) left right b + (continuous_planarEnergy _ _)).comp + exact continuous_pi (fun v => continuous_transverseAmplitude.comp (continuous_apply v)) + +theorem amplitudeDensity_pos (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + 0 continuous_of_discreteTopology) (ising_edge_covariance_nonneg left right) + (ising_reference_mean_nonneg left right) hb (fun v => (r v).property.1) (fun v => (s v).property.1) + +theorem planarAmplitudePartition_logSupermodular (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0 ≤ b e) : LogSupermodular (planarAmplitudePartition left right b) := by + intro r s + have hh := amplitudePartition_supermodular planarReference (planarEnergy left right) left right b + (continuous_planarEnergy _ _) (planar_edge_covariance_nonneg left right) + (planar_reference_mean_nonneg left right) hb + (fun v => transverseAmplitude_nonneg (r v)) (fun v => transverseAmplitude_nonneg (s v)) + have hmin : (fun v => transverseAmplitude ((r⊓s) v))= + ((fun v => transverseAmplitude (r v))⊔(fun v => transverseAmplitude (s v))) := by + funext v; exact transverseAmplitude_inf _ _ + have hmax : (fun v => transverseAmplitude ((r⊔s) v))= + ((fun v => transverseAmplitude (r v))⊓(fun v => transverseAmplitude (s v))) := by + funext v; exact transverseAmplitude_sup _ _ + unfold planarAmplitudePartition + rw [hmin,hmax] + simpa only [mul_comm] using hh + +theorem amplitudeDensity_logSupermodular (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0 ≤ b e) : LogSupermodular (amplitudeDensity left right b) := by + intro r s + have hi := isingAmplitudePartition_logSupermodular left right b hb r s + have hp := planarAmplitudePartition_logSupermodular left right b hb r s + have hh := mul_le_mul hi hp + (mul_nonneg (planarAmplitudePartition_pos _ _ _ _).le (planarAmplitudePartition_pos _ _ _ _).le) + (mul_nonneg (isingAmplitudePartition_pos _ _ _ _).le (isingAmplitudePartition_pos _ _ _ _).le) + unfold amplitudeDensity + nlinarith only [hh] + +theorem amplitude_associated (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) : + ContinuousAssociated (Measure.pi (fun _ : V => amplitudeReference)) (amplitudeDensity left right b) := + continuousFKG_pi amplitudeReference _ (continuous_amplitudeDensity _ _ _) + (amplitudeDensity_pos _ _ _) (amplitudeDensity_logSupermodular _ _ _ hb) + +theorem amplitude_associated_any (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) : + ContinuousAssociated (Measure.pi (fun _ : V => μ)) (amplitudeDensity left right b) := + continuousFKG_pi μ _ (continuous_amplitudeDensity _ _ _) + (amplitudeDensity_pos _ _ _) (amplitudeDensity_logSupermodular _ _ _ hb) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AmplitudeModular.lean b/lean/OAI/Probability/ClassicalON/AmplitudeModular.lean new file mode 100644 index 0000000000000000000000000000000000000000..856ca838fc67beecdac387f50b3909c5db747b4d --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AmplitudeModular.lean @@ -0,0 +1,86 @@ +import OAI.Probability.ClassicalON.AmplitudePartition + +namespace OAI + +universe uE uV uX + +noncomputable section +open MeasureTheory Set +open scoped BigOperators +namespace ClassicalON + +section +variable {X : Type uX} {V : Type uV} {E : Type uE} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] + [BorelSpace X] [Fintype E] (μ : Measure X) [IsProbabilityMeasure μ] + (T : E → X → ℝ) (left right : E → V) (b : E → ℝ) + (hT : ∀ e,Continuous (T e)) (hCov : EdgeCovarianceNonneg μ T) + (h0 : ∀ e,0≤∫ x,T e x ∂μ) (hb : ∀ e,0≤b e) + +include hT hCov h0 hb + +theorem log_amplitudePartition_increment_mono {a c d : V → ℝ} + (ha : ∀ v,0≤a v) (hac : ∀ v,a v≤c v) (hd : ∀ v,0≤d v) : + Real.log (amplitudePartition μ T left right b (fun v => a v+d v))- + Real.log (amplitudePartition μ T left right b a) ≤ + Real.log (amplitudePartition μ T left right b (fun v => c v+d v))- + Real.log (amplitudePartition μ T left right b c) := by + let F := fun t => Real.log (amplitudePartition μ T left right b (fun v => c v+t*d v))- + Real.log (amplitudePartition μ T left right b (fun v => a v+t*d v)) + have hD (t : ℝ) := (log_amplitudePartition_direction_derivative μ T left right b hT c d t).sub + (log_amplitudePartition_direction_derivative μ T left right b hT a d t) + have hM : MonotoneOn F (Icc 0 1) := by + apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc 0 1) + (fun t _ => (hD t).continuousAt.continuousWithinAt) + (fun t _ => (hD t).hasDerivWithinAt) + intro t ht + have ht0 : 0≤t := (interior_subset ht).1 + apply sub_nonneg.mpr + apply Finset.sum_le_sum + intro e _ + have hJa : ∀ g,0≤amplitudeCoupling left right b (fun v => a v+t*d v) g := by + intro g + unfold amplitudeCoupling + exact mul_nonneg (mul_nonneg (hb g) (add_nonneg (ha _) (mul_nonneg ht0 (hd _)))) + (add_nonneg (ha _) (mul_nonneg ht0 (hd _))) + have hJ : ∀ g,amplitudeCoupling left right b (fun v => a v+t*d v) g≤ + amplitudeCoupling left right b (fun v => c v+t*d v) g := by + apply amplitudeCoupling_mono left right b hb + · intro v; exact add_nonneg (ha v) (mul_nonneg ht0 (hd v)) + · intro v; exact add_le_add (hac v) le_rfl + have hm := edgeMean_mono_couplings μ T hT hCov hJa hJ e + apply mul_le_mul (amplitudeSlope_mono left right b hb hd hac t e) hm + · exact edgeMean_nonneg μ T hT hCov h0 _ hJa e + · exact amplitudeSlope_nonneg left right b hb (fun v => (ha v).trans (hac v)) hd ht0 e + have hi := hM (by simp : (0 : ℝ)∈Icc 0 1) (by simp : (1 : ℝ)∈Icc 0 1) (by norm_num) + simp only [F,zero_mul,add_zero,one_mul] at hi + linarith + +theorem amplitudePartition_supermodular {u v : V → ℝ} + (hu : ∀ i,0≤u i) (hv : ∀ i,0≤v i) : + amplitudePartition μ T left right b u*amplitudePartition μ T left right b v ≤ + amplitudePartition μ T left right b (u⊓v)*amplitudePartition μ T left right b (u⊔v) := by + let a := u⊓v + let d := fun i => u i-a i + have ha : ∀ i,0≤a i := by intro i; exact le_min (hu i) (hv i) + have hd : ∀ i,0≤d i := by intro i; exact sub_nonneg.mpr (min_le_left _ _) + have had : (fun i => a i+d i)=u := by funext i; dsimp [d]; ring + have hvd : (fun i => v i+d i)=u⊔v := by + funext i + dsimp [d,a] + rcases le_total (u i) (v i) with h | h + · rw [min_eq_left h,max_eq_right h]; ring + · rw [min_eq_right h,max_eq_left h]; ring + have hi := log_amplitudePartition_increment_mono μ T left right b hT hCov h0 hb + ha (fun i => min_le_right (u i) (v i)) hd + rw [had,hvd] at hi + have hp := amplitudePartition_pos μ T left right b hT + apply (Real.log_le_log_iff (mul_pos (hp u) (hp v)) (mul_pos (hp _) (hp _))).mp + rw [Real.log_mul (hp u).ne' (hp v).ne',Real.log_mul (hp _).ne' (hp _).ne'] + linarith + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AmplitudePartition.lean b/lean/OAI/Probability/ClassicalON/AmplitudePartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..57eac2d03802cb7494c735f75d9990d08e582517 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AmplitudePartition.lean @@ -0,0 +1,107 @@ +import OAI.Probability.ClassicalON.ProductFKG + +namespace OAI + +universe uE uV uX + +noncomputable section +open MeasureTheory Set +open scoped BigOperators +namespace ClassicalON + +section +variable {X : Type uX} {V : Type uV} {E : Type uE} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] + [BorelSpace X] [Fintype E] (μ : Measure X) [IsProbabilityMeasure μ] + (T : E → X → ℝ) (left right : E → V) (b : E → ℝ) + +def amplitudeCoupling (a : V → ℝ) (e : E) : ℝ := b e*a (left e)*a (right e) + +def amplitudePartition (a : V → ℝ) : ℝ := + ∫ x,Real.exp (edgeHamiltonian T (amplitudeCoupling left right b a) x) ∂μ + +def amplitudeSlope (a d : V → ℝ) (t : ℝ) (e : E) : ℝ := + b e*(d (left e)*(a (right e)+t*d (right e))+(a (left e)+t*d (left e))*d (right e)) + +omit [CompactSpace X] [MeasurableSpace X] [BorelSpace X] in + theorem continuous_amplitudeHamiltonian (hT : ∀ e,Continuous (T e)) : + Continuous (fun p : (V → ℝ)×X => edgeHamiltonian T + (amplitudeCoupling left right b p.1) p.2) := by + unfold edgeHamiltonian amplitudeCoupling + fun_prop + +theorem amplitudePartition_pos (hT : ∀ e,Continuous (T e)) (a : V → ℝ) : + 0 Real.exp_pos _) + +theorem continuous_amplitudePartition [Fintype V] (hT : ∀ e,Continuous (T e)) : + Continuous (amplitudePartition μ T left right b) := by + exact compact_parametric_integral _ (continuous_amplitudeHamiltonian T left right b hT).rexp + +omit [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] in +theorem amplitudeHamiltonian_direction_derivative (a d : V → ℝ) (t : ℝ) (x : X) : + HasDerivAt (fun u => edgeHamiltonian T + (amplitudeCoupling left right b (fun v => a v+u*d v)) x) + (edgeHamiltonian T (amplitudeSlope left right b a d t) x) t := by + unfold edgeHamiltonian + apply HasDerivAt.fun_sum + intro e _ + have hl := ((hasDerivAt_id t).mul_const (d (left e))).const_add (a (left e)) + have hr := ((hasDerivAt_id t).mul_const (d (right e))).const_add (a (right e)) + exact (((hl.const_mul (b e)).mul hr).mul_const (T e x)).congr_deriv (by + simp only [id_eq,amplitudeSlope]; ring) + +theorem log_amplitudePartition_direction_derivative (hT : ∀ e,Continuous (T e)) + (a d : V → ℝ) (t : ℝ) : + HasDerivAt (fun u => Real.log (amplitudePartition μ T left right b (fun v => a v+u*d v))) + (∑ e,amplitudeSlope left right b a d t e* + edgeMean μ T (amplitudeCoupling left right b (fun v => a v+t*d v)) (T e)) t := by + let H := fun u x => edgeHamiltonian T + (amplitudeCoupling left right b (fun v => a v+u*d v)) x + let A := fun u x => edgeHamiltonian T (amplitudeSlope left right b a d u) x + have hc : Continuous (fun p : ℝ×X => H p.1 p.2) := by + unfold H edgeHamiltonian amplitudeCoupling; fun_prop + have ha : Continuous (fun p : ℝ×X => A p.1 p.2) := by + unfold A edgeHamiltonian amplitudeSlope; fun_prop + have hI := hasDerivAt_integral_compact μ (fun u x => Real.exp (H u x)) + (fun u x => Real.exp (H u x)*A u x) hc.rexp (hc.rexp.mul ha) (fun u x => + (amplitudeHamiltonian_direction_derivative T left right b a d u x).exp) t + have hz := amplitudePartition_pos μ T left right b hT (fun v => a v+t*d v) + apply (hI.log hz.ne').congr_deriv + change exponentialMean μ (H t) (A t)=_ + unfold A edgeHamiltonian + rw [exponentialMean_sum μ (continuous_edgeHamiltonian T hT _) _ (fun e => by fun_prop)] + simp only [exponentialMean_const_mul,edgeMean] + +omit [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] [Fintype E] in + theorem amplitudeCoupling_mono (hb : ∀ e,0≤b e) {a c : V → ℝ} + (ha : ∀ v,0≤a v) (hac : ∀ v,a v≤c v) (e : E) : + amplitudeCoupling left right b a e≤amplitudeCoupling left right b c e := by + unfold amplitudeCoupling + exact mul_le_mul (mul_le_mul_of_nonneg_left (hac _) (hb e)) (hac _) + (ha _) (mul_nonneg (hb e) ((ha _).trans (hac _))) + +omit [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] [Fintype E] in + theorem amplitudeSlope_nonneg (hb : ∀ e,0≤b e) {a d : V → ℝ} + (ha : ∀ v,0≤a v) (hd : ∀ v,0≤d v) {t : ℝ} (ht : 0≤t) (e : E) : + 0≤amplitudeSlope left right b a d t e := by + unfold amplitudeSlope + exact mul_nonneg (hb e) (add_nonneg + (mul_nonneg (hd _) (add_nonneg (ha _) (mul_nonneg ht (hd _)))) + (mul_nonneg (add_nonneg (ha _) (mul_nonneg ht (hd _))) (hd _))) + +omit [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] [Fintype E] in + theorem amplitudeSlope_mono (hb : ∀ e,0≤b e) {a c d : V → ℝ} + (hd : ∀ v,0≤d v) (hac : ∀ v,a v≤c v) (t : ℝ) (e : E) : + amplitudeSlope left right b a d t e≤amplitudeSlope left right b c d t e := by + unfold amplitudeSlope + apply mul_le_mul_of_nonneg_left _ (hb e) + exact add_le_add + (mul_le_mul_of_nonneg_left (add_le_add (hac _) le_rfl) (hd _)) + (mul_le_mul_of_nonneg_right (add_le_add (hac _) le_rfl) (hd _)) + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AmplitudeSplit.lean b/lean/OAI/Probability/ClassicalON/AmplitudeSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2c213776a55f9116e6722a776f88214f2dc16a8 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AmplitudeSplit.lean @@ -0,0 +1,69 @@ +import OAI.Probability.ClassicalON.UpperEndpoint + +namespace OAI + +universe uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Topology Classical +namespace ClassicalON + +variable {V : Type uV} [Fintype V] + +def glueAmplitude (B : Set V) (a : B → Amplitude) (r : ↥(Bᶜ) → Amplitude) : V → Amplitude := + (MeasurableEquiv.piEquivPiSubtypeProd (fun _ : V => Amplitude) (·∈B)).symm (a,r) + +omit [Fintype V] in +theorem continuous_glueAmplitude (B : Set V) : + Continuous (fun p : (B → Amplitude)×(↥(Bᶜ) → Amplitude) => glueAmplitude B p.1 p.2) := + (Homeomorph.piEquivPiSubtypeProd (·∈B) (fun _ : V => Amplitude)).symm.continuous + +omit [Fintype V] in +@[simp] theorem glueAmplitude_in (B : Set V) (a : B → Amplitude) (r : ↥(Bᶜ) → Amplitude) + (v : B) : glueAmplitude B a r v=a v := by + simp [glueAmplitude,MeasurableEquiv.piEquivPiSubtypeProd,Equiv.piEquivPiSubtypeProd,v.property] + +omit [Fintype V] in +@[simp] theorem glueAmplitude_out (B : Set V) (a : B → Amplitude) (r : ↥(Bᶜ) → Amplitude) + (v : ↥(Bᶜ)) : glueAmplitude B a r v=r v := by + simp [glueAmplitude,MeasurableEquiv.piEquivPiSubtypeProd,Equiv.piEquivPiSubtypeProd,show v.val∉B from v.property] + +theorem integral_amplitude_split (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (B : Set V) (F : (V → Amplitude) → ℝ) (hF : Continuous F) : + (∫ r,F r ∂Measure.pi (fun _ : V => μ))= + ∫ a,∫ r,F (glueAmplitude B a r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ) + ∂Measure.pi (fun _ : B => μ) := by + let e := MeasurableEquiv.piEquivPiSubtypeProd (fun _ : V => Amplitude) (·∈B) + have hp := (measurePreserving_piEquivPiSubtypeProd (fun _ : V => μ) (·∈B)).symm e + rw [← hp.map_eq,integral_map hp.measurable.aemeasurable hF.aestronglyMeasurable] + exact integral_prod _ (compact_integrable (hF.comp (continuous_glueAmplitude B))) + +theorem pinEndpoint_nonneg (μ : Measure Amplitude) [IsProbabilityMeasure μ] + [μ.IsOpenPosMeasure] (B : Set V) {F : (V → Amplitude) → ℝ} (hF : Continuous F) + (ht : ∀ h : (B → Amplitude) → ℝ,Continuous h → (∀ a,0≤h a) → Monotone h → + 0≤∫ r,h (fun v : B => r v)*F r ∂Measure.pi (fun _ : V => μ)) : + 0≤∫ r,F (glueAmplitude B ⊤ r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ) := by + have hc : Continuous (fun a => ∫ r,F (glueAmplitude B a r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ)) := + compact_parametric_integral _ (hF.comp (continuous_glueAmplitude B)) + apply upperEndpoint_nonneg (Measure.pi (fun _ : B => μ)) hc + intro h hh hn hm + have hh' : Continuous (fun r : V → Amplitude => h (fun v : B => r v)) := by + apply hh.comp + exact continuous_pi (fun v => continuous_apply v.val) + have hs := integral_amplitude_split μ B (fun r => h (fun v : B => r v)*F r) (hh'.mul hF) + have he : (fun a => ∫ r,h (fun v : B => glueAmplitude B a r v)*F (glueAmplitude B a r) + ∂Measure.pi (fun _ : ↥(Bᶜ) => μ))= + (fun a => h a*(∫ r,F (glueAmplitude B a r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ))) := by + funext a + simp only [glueAmplitude_in] + exact integral_const_mul _ _ + rw [he] at hs + rw [← hs] + exact ht h hh hn hm + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusBlocks.lean b/lean/OAI/Probability/ClassicalON/AnnulusBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..c34e35c8dd439c819d5629a6dd89fe858a3f3837 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusBlocks.lean @@ -0,0 +1,80 @@ +import OAI.Probability.ClassicalON.BlockLocal + +namespace OAI + +universe uK + +noncomputable section +open Set +open scoped Classical +namespace ClassicalON.LatticeGraph +variable {K : Type uK} + +def annulusFreeEquiv (G : LatticeGraph) (N : ℤ) (hN : 0≤N) (z : K → Site) + (hz : SeparatedCenters N z) (i : K) : + BlockVertex (G.allAnnulusPins N z) (G.annulusVertexLabel N z) (some i) ≃ + ↥((G.annulusPins N (z i))ᶜ) where + toFun v := ⟨⟨v.val.val.val,Finset.mem_filter.mpr ⟨v.val.val.property, + (centerLabel_some_iff N z hz _ i).mp v.property⟩⟩, + fun hp => v.val.property ⟨i,hp⟩⟩ + invFun v := ⟨⟨G.restrictVertex _ v.val,fun hp => v.property + ((local_centerPins_iff N hN z hz _ i (Finset.mem_filter.mp v.val.property).2).mp hp)⟩, + (centerLabel_some_iff N z hz _ i).mpr (Finset.mem_filter.mp v.val.property).2⟩ + left_inv _ := rfl + right_inv _ := rfl + +def annulusEdgesEquiv (G : LatticeGraph) (N : ℤ) (z : K → Site) + (hz : SeparatedCenters N z) (i : K) : + {e : G.edges // G.annulusEdgeLabel N z e=some i} ≃ (G.annulusGraph N (z i)).edges := + (Equiv.subtypeEquivRight (fun e => G.annulusEdgeLabel_some_iff N z hz e i)).trans + (G.restrictEdgeEquiv (·∈annulusSites N (z i))) + +@[simp] theorem annulusEdgesEquiv_restrictEdge (G : LatticeGraph) (N : ℤ) (z : K → Site) + (hz : SeparatedCenters N z) (i : K) (e : {e : G.edges // G.annulusEdgeLabel N z e=some i}) : + G.restrictEdge _ (G.annulusEdgesEquiv N z hz i e)=e.val := rfl + +theorem annulus_blockSpin (G : LatticeGraph) (N : ℤ) (hN : 0≤N) (z : K → Site) + (hz : SeparatedCenters N z) (i : K) (s : ↥((G.annulusPins N (z i))ᶜ) → Spin 3) + (v : (G.annulusGraph N (z i)).vertices) : + glueFamily (G.annulusPins N (z i)) (fun _ => poleSpin true) s v= + blockSpin (G.allAnnulusPins N z) (G.annulusVertexLabel N z) (some i) + (fun w => s (G.annulusFreeEquiv N hN z hz i w)) (G.restrictVertex _ v) := by + by_cases hp : v∈G.annulusPins N (z i) + · have hB : G.restrictVertex _ v∈G.allAnnulusPins N z := ⟨i,hp⟩ + rw [show glueFamily (G.annulusPins N (z i)) (fun _ => poleSpin true) s v=poleSpin true from + glueFamily_in _ _ _ ⟨v,hp⟩] + simp only [blockSpin,hB,↓reduceDIte] + · have hB : G.restrictVertex _ v∉G.allAnnulusPins N z := by + intro h + exact hp ((local_centerPins_iff N hN z hz v.val i (Finset.mem_filter.mp v.property).2).mp h) + have hl : G.annulusVertexLabel N z (G.restrictVertex _ v)=some i := + (centerLabel_some_iff N z hz v.val i).mpr (Finset.mem_filter.mp v.property).2 + rw [show glueFamily (G.annulusPins N (z i)) (fun _ => poleSpin true) s v=s ⟨v,hp⟩ from + glueFamily_out _ _ _ ⟨v,hp⟩] + simp only [blockSpin,hB,hl,↓reduceDIte] + rfl + +theorem annulus_blockMean (G : LatticeGraph) (b : G.edges → ℝ) (N : ℤ) (hN : 0≤N) + (z : K → Site) (hz : SeparatedCenters N z) (i : K) + (f : ((G.annulusGraph N (z i)).edges → Bool) → ℝ) : + poleBondMean (fun e : (G.annulusGraph N (z i)).edges => e.val.1) (fun e => e.val.2) + (G.annulusCoupling b N (z i)) (G.annulusPins N (z i)) (fun _ => true) f= + blockBondMean (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (G.allAnnulusPins N z) (G.annulusVertexLabel N z) (G.annulusEdgeLabel N z) (some i) + (fun η => f (arrowEquiv (G.annulusEdgesEquiv N z hz i) η)) := by + apply blockBondMean_local (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (G.allAnnulusPins N z) (G.annulusVertexLabel N z) (G.annulusEdgeLabel N z) (some i) + (fun e : (G.annulusGraph N (z i)).edges => e.val.1) (fun e => e.val.2) + (G.annulusCoupling b N (z i)) (G.annulusPins N (z i)) (G.annulusFreeEquiv N hN z hz i) + (G.annulusEdgesEquiv N z hz i) + · intro e; rfl + · intro s e + exact G.annulus_blockSpin N hN z hz i s (G.annulusEdgesEquiv N z hz i e).val.1 + · intro s e + exact G.annulus_blockSpin N hN z hz i s (G.annulusEdgesEquiv N z hz i e).val.2 + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusCrossing.lean b/lean/OAI/Probability/ClassicalON/AnnulusCrossing.lean new file mode 100644 index 0000000000000000000000000000000000000000..62094d972dc11c4af1e6c620b1131887b2dea057 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusCrossing.lean @@ -0,0 +1,93 @@ +import OAI.Probability.ClassicalON.PoleCrossing + +namespace OAI + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Classical +namespace ClassicalON.LatticeGraph + +def innerSet (G : LatticeGraph) (k : ℕ) : Set G.vertices := + {x | |(scaledSite k x.val).1|≤1 ∧ |(scaledSite k x.val).2|≤1} + +def outerSet (G : LatticeGraph) (k : ℕ) : Set G.vertices := + {x | 2≤|(scaledSite k x.val).1| ∨ 2≤|(scaledSite k x.val).2|} + +theorem inner_outer_disjoint (G : LatticeGraph) (k : ℕ) : Disjoint (G.innerSet k) (G.outerSet k) := by + apply Set.disjoint_left.mpr + intro x hx ho + rcases ho with h | h <;> linarith [hx.1,hx.2] + +def positiveLayerPins (G : LatticeGraph) (I O : Set G.vertices) : G.vertices → Option (Spin 3) := + (poleSystem (fun e : G.edges => e.val.1) (fun e => e.val.2) (fun _ => 0) (I∪O) (fun _ => true)).pin + +theorem positiveLayerPins_boundary (G : LatticeGraph) (k : ℕ) (I O : Set G.vertices) + (hI : I⊆G.innerSet k) (hO : O⊆G.outerSet k) : + G.BoundaryPins k 3 (G.positiveLayerPins I O) := by + intro x s hs + by_cases h : x∈I∪O + · rcases h with h | h + · exact Or.inl (hI h) + · exact Or.inr (hO h) + · simp only [positiveLayerPins,poleSystem,h,↓reduceDIte] at hs + cases hs + +theorem rotate_positiveLayerPins_pi (G : LatticeGraph) (k : ℕ) (I O : Set G.vertices) + (hI : I⊆G.innerSet k) (hO : O⊆G.outerSet k) : + G.rotatedBoundaryPins k (G.positiveLayerPins I O) Real.pi= + (poleSystem (fun e : G.edges => e.val.1) (fun e => e.val.2) (fun _ => 0) (I∪O) + (fun v => layerSigns I v)).pin := by + funext x + by_cases hx : x∈I∪O + · have htheta : G.thetaPotential k x=if x∈I then 1 else 0 := by + by_cases h : x∈I + · simp only [h,ite_true,thetaPotential] + exact squareTheta_one _ (hI h).1 (hI h).2 + · simp only [h,ite_false,thetaPotential] + exact squareTheta_zero _ (hO (hx.resolve_left h)) + simp only [rotatedBoundaryPins,positiveLayerPins,poleSystem,hx,↓reduceDIte,Option.map_some] + by_cases hi : x∈I + · rw [show layerSigns I x=false by simp [layerSigns,hi]] + congr 1 + exact rotate_pole _ _ (by simpa [hi] using htheta) + · rw [show layerSigns I x=true by simp [layerSigns,hi]] + congr 1 + exact rotation_zero_potential _ _ _ (by simpa [hi] using htheta) _ + · simp only [rotatedBoundaryPins,positiveLayerPins,poleSystem,hx,↓reduceDIte,Option.map_none] + +theorem rotate_positiveLayerPins_zero (G : LatticeGraph) (k : ℕ) (I O : Set G.vertices) : + G.rotatedBoundaryPins k (G.positiveLayerPins I O) 0=G.positiveLayerPins I O := by + funext x + simp only [rotatedBoundaryPins] + cases hp : G.positiveLayerPins I O x with + | none => rfl + | some s => + simp only [Option.map_some] + congr 1 + apply Subtype.ext + change NormedSpace.exp ((0*G.thetaPotential k x) • axisC) s.val=s.val + simp [zero_smul ℝ axisC] + +theorem annulus_crossing_small (β : ℝ) (hβ : 0≤β) (ε : ℝ) (hε : 0<ε) : + ∃ k : ℕ,4≤k ∧ ∀ (G : LatticeGraph),G.WithinDyadicBox k → + ∀ (b : G.edges → ℝ),(∀ e,0≤b e ∧ b e≤β) → + ∀ (I O : Set G.vertices),I⊆G.innerSet k → O⊆G.outerSet k → + poleBondMean (fun e : G.edges => e.val.1) (fun e => e.val.2) b (I∪O) (fun _ => true) + (crossingIndicator (fun e : G.edges => e.val.1) (fun e => e.val.2) I O)≤ε := by + obtain ⟨k,hk,hr⟩ := annulus_partition_ratio β hβ ε hε + refine ⟨k,hk,?_⟩ + intro G hG b hb I O hI hO + have hd : Disjoint I O := (G.inner_outer_disjoint k).mono hI hO + rw [pole_crossing_ratio _ _ _ (fun e => (hb e).1) _ _ hd] + have h := hr G hG b hb (G.positiveLayerPins I O) + (G.positiveLayerPins_boundary k I O hI hO) Real.pi 0 + rw [G.rotate_positiveLayerPins_pi k I O hI hO,G.rotate_positiveLayerPins_zero k I O] at h + change 1-ε≤(poleSystem _ _ b (I∪O) (fun v => layerSigns I v)).Z (fun _ => 1)/ + (poleSystem _ _ b (I∪O) (fun _ => true)).Z (fun _ => 1) at h + linarith + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusCut.lean b/lean/OAI/Probability/ClassicalON/AnnulusCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa9cd349c7c437584c968854e79abb3dc57365d4 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusCut.lean @@ -0,0 +1,118 @@ +import OAI.Probability.ClassicalON.SeparatedAnnuli + +namespace OAI + +noncomputable section +open Set +open scoped Classical +namespace ClassicalON.LatticeGraph + +def extendAnnulusSign (G : LatticeGraph) (N : ℤ) (z : Site) + (s : (G.annulusGraph N z).vertices → Bool) (v : G.vertices) : Bool := + if h : v.val∈annulusSites N z then + s ⟨v.val,Finset.mem_filter.mpr ⟨v.property,h⟩⟩ else decide (2*N e.val.1) + (fun e => e.val.2) (G.annulusPins N z) (layerSigns (G.annulusInner N z)) + (fun e => η (G.restrictEdge _ e))) : + G.extendAnnulusSign N z s∈compatibleSigns (fun e : G.edges => e.val.1) (fun e => e.val.2) η := by + intro e he + have hstep := siteRadius_neighbor_step z (Or.inl (G.nearest e.val e.property)) + by_cases hl : siteRadius z e.val.1.val e.val.1) (fun e => e.val.2) η x y) : + G.annulusIndicator N z η=1 := by + have hd : Disjoint (G.annulusInner N z) (G.annulusOuter N z) := by + apply Set.disjoint_left.mpr + intro v hv hw + change siteRadius z v.val=N at hv + change siteRadius z v.val=2*N at hw + omega + have hc : bondCrossing (fun e : (G.annulusGraph N z).edges => e.val.1) (fun e => e.val.2) + (G.annulusInner N z) (G.annulusOuter N z) (fun e => η (G.restrictEdge _ e)) := by + by_contra hn + obtain ⟨s,hs⟩ := (layerSigns_consistent_iff (fun e : (G.annulusGraph N z).edges => e.val.1) + (fun e => e.val.2) _ _ hd _).mpr hn + have he := compatibleSigns_connected _ _ η (G.extendAnnulusSign_compatible N hN z η s hs) hxy + rw [G.extendAnnulusSign_inner N hN z s hs.2 x hx,G.extendAnnulusSign_outer N hN z s hs.2 y hy] at he + cases he + exact ite_eq_left hc + +theorem annulus_crossing_of_component (G : LatticeGraph) (N : ℤ) (hN : 0 e.val.1) (fun e => e.val.2) η x y) + (hxw : bondConnected (fun e : G.edges => e.val.1) (fun e => e.val.2) η x w) + (z : Site) (hw : siteRadius z w.val≤N) : G.annulusIndicator N z η=1 := by + have hout : 2*N≤ siteRadius z x.val ∨ 2*N≤ siteRadius z y.val := by + have ht := siteRadius_triangle x.val z y.val + rw [siteRadius_symm x.val z] at ht + omega + rcases hout with hx | hy + · exact G.annulus_crossing_of_connected N hN z η w x hw hx (bondConnected_symm _ _ _ hxw) + · exact G.annulus_crossing_of_connected N hN z η w y hw hy + (bondConnected_trans _ _ _ (bondConnected_symm _ _ _ hxw) hxy) + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusLabels.lean b/lean/OAI/Probability/ClassicalON/AnnulusLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..8841cc736d7b02957fb7e1c231b51a80db2309db --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusLabels.lean @@ -0,0 +1,140 @@ +import OAI.Probability.ClassicalON.LatticeRadius + +namespace OAI + +universe uK + +noncomputable section +open Set +open scoped Classical +namespace ClassicalON +variable {K : Type uK} + +def SeparatedCenters (N : ℤ) (z : K → Site) : Prop := ∀ i j,i≠j → 4*N ⟨i,h⟩ + +namespace LatticeGraph + +def annulusVertexLabel (G : LatticeGraph) (N : ℤ) (z : K → Site) : G.vertices → Option K := + fun v => centerLabel N z v.val + +def annulusEdgeLabel (G : LatticeGraph) (N : ℤ) (z : K → Site) (e : G.edges) : Option K := + if h : ∃ i,e.val.1.val∈annulusSites N (z i) ∧ e.val.2.val∈annulusSites N (z i) then some h.choose else none + +def allAnnulusPins (G : LatticeGraph) (N : ℤ) (z : K → Site) : Set G.vertices := + {v | v.val∈centerPins N z} + +theorem annulusEdgeLabel_some_iff (G : LatticeGraph) (N : ℤ) (z : K → Site) + (hz : SeparatedCenters N z) (e : G.edges) (i : K) : + G.annulusEdgeLabel N z e=some i ↔ + e.val.1.val∈annulusSites N (z i) ∧ e.val.2.val∈annulusSites N (z i) := by + unfold annulusEdgeLabel + split_ifs with h + · constructor + · intro he + exact Option.some.inj he ▸ h.choose_spec + · intro hv + congr 1 + exact annulus_unique N z hz _ h.choose_spec.1 hv.1 + · constructor + · intro he; cases he + · intro hv; exact False.elim (h ⟨i,hv⟩) + +theorem annulus_vertex_edge_label (G : LatticeGraph) (N : ℤ) (_hN : 0≤N) (z : K → Site) + (hz : SeparatedCenters N z) (e : G.edges) (v w : G.vertices) + (he : (v=e.val.1 ∧ w=e.val.2) ∨ (v=e.val.2 ∧ w=e.val.1)) + (hv : v∉G.allAnnulusPins N z) : G.annulusVertexLabel N z v=G.annulusEdgeLabel N z e := by + have hstep : PositiveNeighbor v.val w.val ∨ PositiveNeighbor w.val v.val := by + rcases he with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact Or.inl (G.nearest e.val e.property) + · exact Or.inr (G.nearest e.val e.property) + have hvp : v.val∉centerPins N z := hv + cases hl : G.annulusVertexLabel N z v with + | none => + cases hel : G.annulusEdgeLabel N z e with + | none => rfl + | some i => + have hh := (G.annulusEdgeLabel_some_iff N z hz e i).mp hel + have hh' : v.val∈annulusSites N (z i) := by rcases he with ⟨rfl,_⟩ | ⟨rfl,_⟩; exact hh.1; exact hh.2 + have := (centerLabel_some_iff N z hz v.val i).mpr hh' + change G.annulusVertexLabel N z v=some i at this + rw [hl] at this + cases this + | some i => + have hi := (centerLabel_some_iff N z hz v.val i).mp hl + have hvi : v.val∈annulusInterior N (z i) := + (annulusSites_not_boundary N (z i) v.val).mp ⟨hi,fun h => hvp ⟨i,h⟩⟩ + have hwi := neighbor_in_annulus hvi hstep + symm + apply (G.annulusEdgeLabel_some_iff N z hz e i).mpr + rcases he with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact ⟨hi,hwi⟩ + · exact ⟨hwi,hi⟩ + +theorem annulus_left_label (G : LatticeGraph) (N : ℤ) (hN : 0≤N) (z : K → Site) + (hz : SeparatedCenters N z) (e : G.edges) (hv : e.val.1∉G.allAnnulusPins N z) : + G.annulusVertexLabel N z e.val.1=G.annulusEdgeLabel N z e := + G.annulus_vertex_edge_label N hN z hz e e.val.1 e.val.2 (Or.inl ⟨rfl,rfl⟩) hv + +theorem annulus_right_label (G : LatticeGraph) (N : ℤ) (hN : 0≤N) (z : K → Site) + (hz : SeparatedCenters N z) (e : G.edges) (hv : e.val.2∉G.allAnnulusPins N z) : + G.annulusVertexLabel N z e.val.2=G.annulusEdgeLabel N z e := + G.annulus_vertex_edge_label N hN z hz e e.val.2 e.val.1 (Or.inr ⟨rfl,rfl⟩) hv + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusPartition.lean b/lean/OAI/Probability/ClassicalON/AnnulusPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..74fd9efc109bd43b9b0ae86e09afc1fec476f187 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusPartition.lean @@ -0,0 +1,61 @@ +import OAI.Probability.ClassicalON.PeriodicPartition + +namespace OAI + +noncomputable section +namespace ClassicalON.LatticeGraph + +def thetaPotential (G : LatticeGraph) (k : ℕ) (x : G.vertices) : ℝ := + squareTheta (scaledSite k x.val) + +def rotatedBoundaryPins (G : LatticeGraph) (k : ℕ) (P : G.vertices → Option (Spin 3)) + (t : ℝ) : G.vertices → Option (Spin 3) := + fun x => (P x).map (spinRotation (SpinSystem.potentialRotation (G.thetaPotential k) t x)) + +theorem thetaPotential_binary_pins (G : LatticeGraph) (k : ℕ) + (P : G.vertices → Option (Spin 3)) (hP : G.BoundaryPins k 3 P) : + ∀ x s, P x=some s → G.thetaPotential k x=0 ∨ G.thetaPotential k x=1 := by + intro x s hs + rcases hP x s hs with h | h + · exact Or.inr (squareTheta_one _ h.1 h.2) + · exact Or.inl (squareTheta_zero _ h) + +theorem rotatedBoundaryPins_boundary (G : LatticeGraph) (k : ℕ) + (P : G.vertices → Option (Spin 3)) (hP : G.BoundaryPins k 3 P) (t : ℝ) : + G.BoundaryPins k 3 (G.rotatedBoundaryPins k P t) := by + intro x s hs + cases hp : P x with + | none => simp [rotatedBoundaryPins,hp] at hs + | some u => exact hP x u hp + +theorem rotatePotential_spinSystem (G : LatticeGraph) (k : ℕ) (b : G.edges → ℝ) + (P : G.vertices → Option (Spin 3)) (t : ℝ) : + (G.spinSystem 3 b P).rotatePotential (G.thetaPotential k) t = + G.spinSystem 3 b (G.rotatedBoundaryPins k P t) := rfl + +theorem annulus_partition_ratio (β : ℝ) (hβ : 0 ≤ β) (ε : ℝ) (hε : 0<ε) : + ∃ k : ℕ, 4 ≤ k ∧ ∀ (G : LatticeGraph), G.WithinDyadicBox k → + ∀ (b : G.edges → ℝ), (∀ e,0 ≤ b e ∧ b e ≤ β) → + ∀ (P : G.vertices → Option (Spin 3)), G.BoundaryPins k 3 P → ∀ x y : ℝ, + 1-ε ≤ (G.spinSystem 3 b (G.rotatedBoundaryPins k P x)).Z (fun _ => 1) / + (G.spinSystem 3 b (G.rotatedBoundaryPins k P y)).Z (fun _ => 1) := by + let δ := 2*ε/(2*Real.pi)^2 + have hδ : 0<δ := by dsimp [δ]; positivity + obtain ⟨k,hk,hR⟩ := annulus_response_small β hβ δ hδ + refine ⟨k,hk,?_⟩ + intro G hG b hb P hP x y + have hp := G.thetaPotential_binary_pins k P hP + have hr (t : ℝ) : -((G.spinSystem 3 b P).rotatePotential (G.thetaPotential k) t).secondAxisResponse + ((G.spinSystem 3 b P).differential (G.thetaPotential k)) + ((G.spinSystem 3 b P).differential (G.thetaPotential k)) ≤ δ := by + exact hR G hG b hb (G.rotatedBoundaryPins k P t) (G.rotatedBoundaryPins_boundary k P hP t) + have h := (G.spinSystem 3 b P).potential_partition_ratio (G.thetaPotential k) δ hδ.le hp hr x y + have he : δ*(2*Real.pi)^2/2=ε := by dsimp [δ]; field_simp + rw [he] at h + exact h + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusResponse.lean b/lean/OAI/Probability/ClassicalON/AnnulusResponse.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a5103e95aa370f2cc06f48f90ff64b420ce2b3e --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusResponse.lean @@ -0,0 +1,103 @@ +import OAI.Probability.ClassicalON.RotationInequality + +namespace OAI + +universe uE uV + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +namespace SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem response_imaginary_multiple (S : SpinSystem 3 V E) (u : E → ℝ) (r : ℝ) : + (S.complexSecondResponse (fun e => -Complex.I*((r*u e:ℝ):ℂ)) + (fun e => conj (-Complex.I*((r*u e:ℝ):ℂ)))).re = r^2*S.secondAxisResponse u u := by + have hf : (fun e => -Complex.I*((r*u e:ℝ):ℂ)) = (-Complex.I*(r:ℂ)) • (fun e => (u e:ℂ)) := by + ext e; simp only [Pi.smul_apply,smul_eq_mul,Complex.ofReal_mul]; ring + have hg : (fun e => conj (-Complex.I*((r*u e:ℝ):ℂ))) = (Complex.I*(r:ℂ)) • (fun e => (u e:ℂ)) := by + ext e; simp only [map_mul,map_neg,Complex.conj_I,neg_neg,Complex.conj_ofReal,Pi.smul_apply,smul_eq_mul,Complex.ofReal_mul]; ring + rw [hf,hg,S.complexSecondResponse_smul_left,S.complexSecondResponse_smul_right,S.complexSecondResponse_ofReal] + simp only [Complex.mul_re,Complex.mul_im,Complex.neg_re,Complex.neg_im,Complex.I_re,Complex.I_im,Complex.ofReal_re,Complex.ofReal_im] + ring + +end SpinSystem + +namespace LatticeGraph + +def spinSystem (G : LatticeGraph) (n : ℕ) (b : G.edges → ℝ) (P : G.vertices → Option (Spin n)) : + SpinSystem n G.vertices G.edges := ⟨fun e => e.val.1,fun e => e.val.2,b,P⟩ + +def BoundaryPins (G : LatticeGraph) (k n : ℕ) (P : G.vertices → Option (Spin n)) : Prop := + ∀ x s, P x=some s → + (|(scaledSite k x.val).1| ≤ 1 ∧ |(scaledSite k x.val).2| ≤ 1) ∨ + (2 ≤ |(scaledSite k x.val).1| ∨ 2 ≤ |(scaledSite k x.val).2|) + +theorem modes_zero_pins (G : LatticeGraph) (k n : ℕ) (P : G.vertices → Option (Spin n)) + (hP : G.BoundaryPins k n P) (i : ModeIndex k) (x : G.vertices) (s : Spin n) (hs : P x=some s) : + G.modes i x=0 := by + have hp : squareProfile i.1.1 i.1.2 (scaledSite k x.val)=0 := by + rcases hP x s hs with h | h + · exact squareProfile_zero_inner _ _ _ h.1 h.2 + · exact squareProfile_zero_outer _ _ _ h + simp [modes,latticeMode,hp] + +theorem system_modes_commutator (G : LatticeGraph) (k : ℕ) (b : G.edges → ℝ) (P : G.vertices → Option (Spin 3)) : + (∑ i : ModeIndex k, (G.spinSystem 3 b P).commutatorForm (G.modes i) (fun x => conj (G.modes i x))) = + (fun e => -Complex.I*((dyadicLambda k*G.profileEdge k e:ℝ):ℂ)) := by + ext e + rw [Finset.sum_apply] + convert G.modes_commutator e using 1 + apply Finset.sum_congr rfl + intro i _ + simp only [SpinSystem.commutatorForm,SpinSystem.complexCross,Pi.smul_apply,smul_eq_mul, + spinSystem,modes,modeCommutator] + ring + +theorem profile_response_bound (G : LatticeGraph) (k : ℕ) (hk : 0 < k) (hG : G.WithinDyadicBox k) + (β : ℝ) (hβ : 0 ≤ β) (b : G.edges → ℝ) (hb : ∀ e, 0 ≤ b e ∧ b e ≤ β) + (P : G.vertices → Option (Spin 3)) (hP : G.BoundaryPins k 3 P) + (C : ℝ) (hC : 0 ≤ C) (hv : ∀ m s z, |squareProfile m s z| ≤ C) + (hLip : ∀ m s z w, |squareProfile m s w-squareProfile m s z| ≤ C*‖w-z‖) : + -(G.spinSystem 3 b P).secondAxisResponse (G.profileEdge k) (G.profileEdge k) ≤ + 4*((6*β^2+4*β*Real.sqrt β+β)*(48*(2*modeBlockConstant C)^4)+ + β*(576*C^2*(2*modeBlockConstant C)^2))/(k:ℝ) := by + let a := 2*modeBlockConstant C + let M := (6*β^2+4*β*Real.sqrt β+β)*(48*a^4)+β*(576*C^2*a^2) + have ha (m s : Bool) := G.scaledModes_squareBound hG C hv hLip m s + have hM : 0 ≤ M := by dsimp only [M]; positivity + have hLam : (k:ℝ)/2 ≤ dyadicLambda k := dyadicLambda_lower k + have hkR : (0:ℝ) G.modes_zero_pins k 3 P hP i x s hs) + have hd : (fun i : ModeIndex k => (G.spinSystem 3 b P).differential (G.modes i)) = G.modeDifferences := rfl + rw [G.system_modes_commutator k b P, (G.spinSystem 3 b P).response_imaginary_multiple,hd] at h + have hHS := G.modes_HS_bound a ha + have hmin := G.modes_min_bound a C hC hv ha + have hK : 0 ≤ 6*β^2+4*β*Real.sqrt β+β := by positivity + have hcost : (6*β^2+4*β*Real.sqrt β+β)*familyHSSquare (G.modeDifferences (k := k))+ + β*(∑ i : ModeIndex k, ∑ j : ModeIndex k, + min (‖G.modes i‖^2*∑ e, ‖G.modeDifferences j e‖^2) + (‖G.modes j‖^2*∑ e, ‖G.modeDifferences i e‖^2)) ≤ M*(k:ℝ) := by + calc _ ≤ (6*β^2+4*β*Real.sqrt β+β)*(48*a^4*(k:ℝ))+β*(576*C^2*a^2*(k:ℝ)) := + add_le_add (mul_le_mul_of_nonneg_left hHS hK) (mul_le_mul_of_nonneg_left hmin hβ) + _ = _ := by dsimp only [M]; ring + have hfinal : -(G.spinSystem 3 b P).secondAxisResponse (G.profileEdge k) (G.profileEdge k) ≤ 4*M/(k:ℝ) := by + by_cases hr : (G.spinSystem 3 b P).secondAxisResponse (G.profileEdge k) (G.profileEdge k) ≤ 0 + · apply (le_div_iff₀ hkR).mpr + have hsq : (k:ℝ)^2/4 ≤ (dyadicLambda k)^2 := by nlinarith + have hh := mul_le_mul_of_nonneg_right hsq (neg_nonneg.mpr hr) + have ht := h.trans hcost + nlinarith + · have hh : 0 ≤ 4*M/(k:ℝ) := by positivity + linarith + exact hfinal + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AnnulusSmall.lean b/lean/OAI/Probability/ClassicalON/AnnulusSmall.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef72ccc7b8df5ae1881a3c398781dba2ffee1b61 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AnnulusSmall.lean @@ -0,0 +1,90 @@ +import OAI.Probability.ClassicalON.AnnulusResponse + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate Topology +open Filter +namespace ClassicalON +namespace LatticeGraph + +def rotationCostConstant (β C : ℝ) : ℝ := + 4*((6*β^2+4*β*Real.sqrt β+β)*(48*(2*modeBlockConstant C)^4)+ + β*(576*C^2*(2*modeBlockConstant C)^2)) + +def transferCostConstant (β L D : ℝ) : ℝ := + β*(512*D*(2*L+D))+2*(β*512*D)*Real.sqrt (β*(512*L^2))+(β*512*D)^2 + +theorem theta_response_bound (G : LatticeGraph) (k : ℕ) (hk : 0 (G.profileEdge k e:ℂ)) + (fun e => conj (G.profileEdge k e:ℂ))).re ≤ a := by + simp only [Complex.conj_ofReal,S.complexSecondResponse_ofReal,Complex.ofReal_re] + exact G.profile_response_bound k hk hG β hβ b hb P hP C hC hv hLip + have ht := S.response_transfer β a hβ ha hb + (fun e => (G.thetaEdge k e:ℂ)) (fun e => (G.profileEdge k e:ℂ)) hr + simp only [Complex.conj_ofReal,S.complexSecondResponse_ofReal,Complex.ofReal_re, + ← Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs] at ht + obtain ⟨hs1,hs2,hs3⟩ := G.theta_sum_bounds k hG L D hL hD he + have hsq : Real.sqrt (β*∑ e, |G.thetaEdge k e|^2) ≤ Real.sqrt (β*(512*L^2)) := + Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hs2 hβ) + have h1n : 0 ≤ β*∑ e, |G.thetaEdge k e-G.profileEdge k e| := by positivity + have hh : -(S.secondAxisResponse (G.thetaEdge k) (G.thetaEdge k)) ≤ a+ + β*(512*D*(2*L+D)/N^2)+2*(β*(512*D/N))*Real.sqrt (β*(512*L^2))+(β*(512*D/N))^2 := by + exact ht.trans (add_le_add (add_le_add (add_le_add le_rfl + (mul_le_mul_of_nonneg_left hs3 hβ)) + (mul_le_mul (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hs1 hβ) (by norm_num)) + hsq (Real.sqrt_nonneg _) (by positivity))) + (pow_le_pow_left₀ h1n (mul_le_mul_of_nonneg_left hs1 hβ) 2)) + apply hh.trans + change a+β*(512*D*(2*L+D)/N^2)+2*(β*(512*D/N))*Real.sqrt (β*(512*L^2))+(β*(512*D/N))^2 ≤ a+transferCostConstant β L D/N + rw [add_assoc a,add_assoc a] + apply add_le_add le_rfl + have hN2 : N ≤ N^2 := by nlinarith + have hQ : 0 ≤ β*(512*D*(2*L+D))+(β*512*D)^2 := by positivity + calc _ = (β*(512*D*(2*L+D))+(β*512*D)^2)/N^2+ + (2*(β*512*D)*Real.sqrt (β*(512*L^2)))/N := by ring + _ ≤ (β*(512*D*(2*L+D))+(β*512*D)^2)/N+ + (2*(β*512*D)*Real.sqrt (β*(512*L^2)))/N := + add_le_add (div_le_div_of_nonneg_left hQ hN hN2) le_rfl + _ = _ := by unfold transferCostConstant; ring + +theorem annulus_response_small (β : ℝ) (hβ : 0 ≤ β) (ε : ℝ) (hε : 0<ε) : + ∃ k : ℕ, 4 ≤ k ∧ ∀ (G : LatticeGraph), G.WithinDyadicBox k → + ∀ (b : G.edges → ℝ), (∀ e,0 ≤ b e ∧ b e ≤ β) → + ∀ (P : G.vertices → Option (Spin 3)), G.BoundaryPins k 3 P → + -(G.spinSystem 3 b P).secondAxisResponse (G.thetaEdge k) (G.thetaEdge k) ≤ ε := by + obtain ⟨C,hC,hv,hLip⟩ := profiles_uniform_bound + obtain ⟨L,D,hL,hD,he⟩ := theta_edge_bounds + have ht1 : Tendsto (fun k : ℕ => rotationCostConstant β C/(k:ℝ)) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop + have ht2 : Tendsto (fun k : ℕ => transferCostConstant β L D/(2:ℝ)^k) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) + have ht : Tendsto (fun k : ℕ => rotationCostConstant β C/(k:ℝ)+transferCostConstant β L D/(2:ℝ)^k) atTop (𝓝 0) := by + simpa only [add_zero] using ht1.add ht2 + obtain ⟨k,hk,hkε⟩ := ((eventually_ge_atTop 4).and (ht.eventually_lt_const hε)).exists + refine ⟨k,hk,?_⟩ + intro G hG b hb P hP + exact (G.theta_response_bound k (by omega) hG β hβ b hb P hP C L D (by linarith) hL hD hv hLip + (he G k hk)).trans hkε.le + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AssociationCore.lean b/lean/OAI/Probability/ClassicalON/AssociationCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..102aa0a14814ce213a31d4fcc6bfb13edbc901f4 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AssociationCore.lean @@ -0,0 +1,104 @@ +import OAI.Probability.ClassicalON.CoarseCodes + +namespace OAI + +universe uX uY + +noncomputable section +open MeasureTheory Set +open scoped Topology +namespace ClassicalON + +section CompactIntegral +variable {X : Type uX} {Y : Type uY} [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [CompactSpace Y] + [MeasurableSpace Y] [BorelSpace Y] {μ : Measure X} [IsFiniteMeasure μ] + +theorem compact_integrable {f : X → ℝ} (hf : Continuous f) : Integrable f μ := + hf.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace f) + +theorem compact_integral_pos [IsProbabilityMeasure μ] {w : X → ℝ} + (hw : Continuous w) (hp : ∀ x,0 (hp x).le) (compact_integrable hw)).2 + have he : Function.support w=univ := by ext x; simp [Function.mem_support,(hp x).ne'] + rw [he,measure_univ] + exact zero_lt_one + +omit [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] in +theorem compact_parametric_integral [FirstCountableTopology Y] [LocallyCompactSpace Y] + (f : Y → X → ℝ) (hf : Continuous f.uncurry) : Continuous (fun y => ∫ x,f y x ∂μ) := by + simpa only [Measure.restrict_univ] using + (continuous_parametric_integral_of_continuous hf (isCompact_univ : IsCompact (univ : Set X))) + +end CompactIntegral + +def weightedMean {X : Type uX} [MeasurableSpace X] (μ : Measure X) (w f : X → ℝ) : ℝ := + (∫ x,w x*f x ∂μ)/(∫ x,w x ∂μ) + +def ContinuousAssociated {X : Type uX} [MeasurableSpace X] [TopologicalSpace X] + [Preorder X] (μ : Measure X) (w : X → ℝ) : Prop := + ∀ f g : X → ℝ, Continuous f → Continuous g → (∀ x,0≤f x) → (∀ x,0≤g x) → + Monotone f → Monotone g → + weightedMean μ w f * weightedMean μ w g ≤ weightedMean μ w (fun x => f x*g x) + +section Weighted +variable {X : Type uX} [MeasurableSpace X] [TopologicalSpace X] [CompactSpace X] + [BorelSpace X] {μ : Measure X} [IsProbabilityMeasure μ] {w : X → ℝ} + (hw : Continuous w) (hp : ∀ x,0 mul_nonneg (hp x).le (hf x))) + (compact_integral_pos hw hp).le + +theorem weightedMean_mono {f g : X → ℝ} (hf : Continuous f) (hg : Continuous g) + (hfg : ∀ x,f x≤g x) : weightedMean μ w f ≤ weightedMean μ w g := by + exact div_le_div_of_nonneg_right + (integral_mono (compact_integrable (hw.mul hf)) (compact_integrable (hw.mul hg)) + (fun x => mul_le_mul_of_nonneg_left (hfg x) (hp x).le)) (compact_integral_pos hw hp).le + +theorem weightedMean_inequality_iff {f g : X → ℝ} : + weightedMean μ w f * weightedMean μ w g ≤ weightedMean μ w (fun x => f x*g x) ↔ + (∫ x,w x*f x ∂μ)*(∫ x,w x*g x ∂μ) ≤ (∫ x,w x ∂μ)*(∫ x,w x*(f x*g x) ∂μ) := by + unfold weightedMean + have hm := compact_integral_pos (μ := μ) hw hp + rw [div_mul_div_comm,div_le_div_iff₀ (mul_pos hm hm) hm] + constructor <;> intro h <;> nlinarith + +end Weighted + +theorem continuousAssociated_chain {X : Type uX} [LinearOrder X] [TopologicalSpace X] + [CompactSpace X] [MeasurableSpace X] [BorelSpace X] [SecondCountableTopology X] + (μ : Measure X) [IsProbabilityMeasure μ] (w : X → ℝ) + (hw : Continuous w) (hp : ∀ x,0 + w p.1*f p.1*(w p.2*g p.2)+w p.1*g p.1*(w p.2*f p.2)) from by fun_prop)) + (compact_integrable (μ := μ.prod μ) (show Continuous (fun p : X×X => + w p.1*(f p.1*g p.1)*w p.2+w p.1*(w p.2*(f p.2*g p.2))) from by fun_prop)) + (fun p => hc p.1 p.2) + rw [integral_add (compact_integrable (by fun_prop)) (compact_integrable (by fun_prop)), + integral_add (compact_integrable (by fun_prop)) (compact_integrable (by fun_prop))] at hint + rw [integral_prod_mul (fun x => w x*f x) (fun x => w x*g x), + integral_prod_mul (fun x => w x*g x) (fun x => w x*f x), + integral_prod_mul (fun x => w x*(f x*g x)) w, + integral_prod_mul w (fun x => w x*(f x*g x))] at hint + nlinarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/AxisRotation.lean b/lean/OAI/Probability/ClassicalON/AxisRotation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2f15a34e16adc02431117eb0071435300c873af --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/AxisRotation.lean @@ -0,0 +1,72 @@ +import OAI.Probability.ClassicalON.AnnulusSmall + +namespace OAI + +noncomputable section +open scoped Real +namespace ClassicalON + +theorem axisC_cube : axisC^3 = -axisC := by + rw [axisC,← map_pow,← map_neg] + congr 1 + ext i j + fin_cases i <;> fin_cases j <;> + norm_num [axisMatrixC,pow_succ,Matrix.mul_apply,Fin.sum_univ_succ] + +theorem axisC_sq_mul : axisC^2*axisC = -axisC := by + rw [← pow_succ,axisC_cube] + +theorem axis_smul_mul (r : ℝ) (A B : SpinOperator 3) : (r • A)*B = r • (A*B) := + Algebra.smul_mul_assoc r A B + +theorem axis_mul_smul (r : ℝ) (A B : SpinOperator 3) : A*(r • B) = r • (A*B) := + Algebra.mul_smul_comm r A B + +def axisPolynomial (t : ℝ) : SpinOperator 3 := + 1 + (Real.sin t) • axisC + (1-Real.cos t) • axisC^2 + +theorem axisPolynomial_derivative (t : ℝ) : + HasDerivAt axisPolynomial (axisPolynomial t*axisC) t := by + have h := ((hasDerivAt_const t (1:SpinOperator 3)).add ((Real.hasDerivAt_sin t).smul_const axisC)).add + (((hasDerivAt_const t (1:ℝ)).sub (Real.hasDerivAt_cos t)).smul_const (axisC^2)) + apply h.congr_deriv + change 0 + (Real.cos t) • axisC + (0 - -Real.sin t) • axisC^2 = axisPolynomial t*axisC + simp only [axisPolynomial,add_mul,one_mul,axis_smul_mul,axisC_sq_mul,← pow_two] + module + +theorem axisPolynomial_commute (t : ℝ) : Commute (axisPolynomial t) axisC := by + change axisPolynomial t*axisC = axisC*axisPolynomial t + simp only [axisPolynomial,add_mul,mul_add,one_mul,mul_one,axis_smul_mul, + axis_mul_smul,← pow_succ,← pow_succ'] + +theorem exp_axisC (t : ℝ) : NormedSpace.exp (t • axisC)=axisPolynomial t := by + let f := fun t : ℝ => NormedSpace.exp (t • (-axisC))*axisPolynomial t + have hd (t : ℝ) : HasDerivAt f 0 t := by + apply ((hasDerivAt_exp_smul_const (-axisC) t).mul (axisPolynomial_derivative t)).congr_deriv + rw [mul_assoc,neg_mul axisC (axisPolynomial t),← (axisPolynomial_commute t).eq] + simp + have he : f t = f 0 := is_const_of_deriv_eq_zero (fun t => (hd t).differentiableAt) + (fun t => (hd t).deriv) t 0 + have h0 : f 0 = 1 := by simp [f,axisPolynomial,zero_smul ℝ axisC,zero_smul ℝ (axisC^2)] + rw [h0] at he + have hm := congrArg (fun Q : SpinOperator 3 => NormedSpace.exp (t • axisC)*Q) he + dsimp only [f] at hm + rw [← mul_assoc,smul_neg,← NormedSpace.exp_add_of_commute (Commute.refl (t • axisC)).neg_right, + add_neg_cancel,NormedSpace.exp_zero,mul_one,one_mul] at hm + exact hm.symm + +theorem exp_axisC_periodic : Function.Periodic (fun t : ℝ => NormedSpace.exp (t • axisC)) (2*Real.pi) := by + intro t + simp [exp_axisC,axisPolynomial,Real.sin_add_two_pi,Real.cos_add_two_pi] + +theorem exp_axisC_pi_apply (v : EuclideanSpace ℝ (Fin 3)) : + NormedSpace.exp (Real.pi • axisC) v = WithLp.toLp 2 ![-v 0,-v 1,v 2] := by + rw [exp_axisC] + ext i + fin_cases i <;> simp [axisPolynomial,axisC_apply,pow_two] <;> ring + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BlockGeometry.lean b/lean/OAI/Probability/ClassicalON/BlockGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..8143a7cedb5b78c7c6c8b5ce20830fc0bc184738 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BlockGeometry.lean @@ -0,0 +1,119 @@ +import OAI.Probability.ClassicalON.OrthogonalAverage + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace Classical +namespace ClassicalON + +abbrev ThreeBlock (k : ℕ) := WithLp 2 (EuclideanSpace ℝ (Fin 3) × EuclideanSpace ℝ (Fin k)) + +def splitThree (k : ℕ) : EuclideanSpace ℝ (Fin (3+k)) ≃ₗᵢ[ℝ] ThreeBlock k := + (LinearIsometryEquiv.piLpCongrLeft 2 ℝ ℝ (finSumFinEquiv.symm : Fin (3+k) ≃ Fin 3 ⊕ Fin k)).trans + (PiLp.sumPiLpEquivProdLpPiLp 2 (fun _ : Fin 3 ⊕ Fin k => ℝ)) + +def blockHead (k : ℕ) (s : Spin (3+k)) : EuclideanSpace ℝ (Fin 3) := (splitThree k s.val).fst +def blockTail (k : ℕ) (s : Spin (3+k)) : EuclideanSpace ℝ (Fin k) := (splitThree k s.val).snd +def blockRadius (k : ℕ) (s : Spin (3+k)) : ℝ := ‖blockHead k s‖ + +theorem blockRadius_nonneg (k : ℕ) (s : Spin (3+k)) : 0≤blockRadius k s := norm_nonneg _ + +theorem blockRadius_le_one (k : ℕ) (s : Spin (3+k)) : blockRadius k s≤1 := by + have h := WithLp.norm_fst_le _ (splitThree k s.val) + simpa only [blockRadius,blockHead,LinearIsometryEquiv.norm_map,spin_norm] using h + +theorem block_norm_sq (k : ℕ) (s : Spin (3+k)) : blockRadius k s^2+‖blockTail k s‖^2=1 := by + have h := WithLp.prod_norm_sq_eq_of_L2 (splitThree k s.val) + simpa only [blockRadius,blockHead,blockTail,LinearIsometryEquiv.norm_map,spin_norm,one_pow] using h.symm + +theorem block_inner (k : ℕ) (s t : Spin (3+k)) : + ⟪s.val,t.val⟫_ℝ=⟪blockHead k s,blockHead k t⟫_ℝ+⟪blockTail k s,blockTail k t⟫_ℝ := by + rw [← (splitThree k).inner_map_map] + rfl + +theorem blockHead_first (k : ℕ) (s : Spin (3+k)) : (blockHead k s) 0=s.val ⟨0,by omega⟩ := rfl + +theorem continuous_blockHead (k : ℕ) : Continuous (blockHead k) := + (WithLp.continuous_fst _ _ _).comp ((splitThree k).continuous.comp continuous_subtype_val) +theorem continuous_blockTail (k : ℕ) : Continuous (blockTail k) := + (WithLp.continuous_snd _ _ _).comp ((splitThree k).continuous.comp continuous_subtype_val) +theorem continuous_blockRadius (k : ℕ) : Continuous (blockRadius k) := (continuous_blockHead k).norm + +def blockDirection (k : ℕ) (s : Spin (3+k)) : Spin 3 := + if h : blockHead k s=0 then cylindricalSpin ⊤ true 0 else + ⟨(blockRadius k s)⁻¹ • blockHead k s,by + rw [Metric.mem_sphere,dist_zero_right,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr (blockRadius_nonneg k s))] + exact inv_mul_cancel₀ (norm_ne_zero_iff.mpr h)⟩ + +theorem block_head_direction (k : ℕ) (s : Spin (3+k)) : + blockRadius k s • (blockDirection k s).val=blockHead k s := by + unfold blockDirection + split_ifs with h + · simp only [blockRadius,h,norm_zero,zero_smul] + · have hn : blockRadius k s ≠ 0 := norm_ne_zero_iff.mpr h + simp only [smul_smul,mul_inv_cancel₀ hn,one_smul] + +def blockFiber (k : ℕ) (s : Spin (3+k)) (t : Spin 3) : Spin (3+k) := + ⟨(splitThree k).symm (WithLp.toLp 2 (blockRadius k s • t.val,blockTail k s)),by + rw [Metric.mem_sphere,dist_zero_right,LinearIsometryEquiv.norm_map] + have he := WithLp.prod_norm_sq_eq_of_L2 (WithLp.toLp 2 (blockRadius k s • t.val,blockTail k s)) + have hn := block_norm_sq k s + simp only [WithLp.fst,WithLp.snd,norm_smul,Real.norm_of_nonneg (blockRadius_nonneg k s),spin_norm,mul_one] at he + nlinarith [norm_nonneg (WithLp.toLp 2 (blockRadius k s • t.val,blockTail k s))]⟩ + +@[simp] theorem blockHead_fiber (k : ℕ) (s : Spin (3+k)) (t : Spin 3) : + blockHead k (blockFiber k s t)=blockRadius k s • t.val := by + simp [blockHead,blockFiber] +@[simp] theorem blockTail_fiber (k : ℕ) (s : Spin (3+k)) (t : Spin 3) : + blockTail k (blockFiber k s t)=blockTail k s := by + simp [blockTail,blockFiber] + +theorem blockFiber_inner (k : ℕ) (s q : Spin (3+k)) (t u : Spin 3) : + ⟪(blockFiber k s t).val,(blockFiber k q u).val⟫_ℝ= + blockRadius k s*blockRadius k q*⟪t.val,u.val⟫_ℝ+⟪blockTail k s,blockTail k q⟫_ℝ := by + rw [block_inner,blockHead_fiber,blockHead_fiber,blockTail_fiber,blockTail_fiber] + simp only [real_inner_smul_left,real_inner_smul_right] + ring + +theorem continuous_blockFiber (k : ℕ) : Continuous (Function.uncurry (blockFiber k)) := by + apply Continuous.subtype_mk + apply (splitThree k).symm.continuous.comp + exact (WithLp.prodContinuousLinearEquiv 2 ℝ _ _).symm.continuous.comp + ((((continuous_blockRadius k).comp continuous_fst).smul (continuous_subtype_val.comp continuous_snd)).prodMk + ((continuous_blockTail k).comp continuous_fst)) + +def blockRotation (k : ℕ) (Q : SpinOrthogonal 3) : + EuclideanSpace ℝ (Fin (3+k)) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin (3+k)) := + ((splitThree k).trans (LinearIsometryEquiv.withLpProdCongr 2 (Unitary.linearIsometryEquiv Q) (.refl ℝ _))).trans (splitThree k).symm + +def blockRotateSpin (k : ℕ) (Q : SpinOrthogonal 3) (s : Spin (3+k)) : Spin (3+k) := + spinRotation (blockRotation k Q) s + +theorem blockRotateSpin_fiber (k : ℕ) (Q : SpinOrthogonal 3) (s : Spin (3+k)) : + blockRotateSpin k Q s=blockFiber k s (orthogonalSpin Q (blockDirection k s)) := by + apply Subtype.ext + apply (splitThree k).injective + change splitThree k ((splitThree k).symm _)=splitThree k ((splitThree k).symm _) + simp only [LinearIsometryEquiv.apply_symm_apply] + apply (WithLp.equiv 2 _).injective + apply Prod.ext + · change (Unitary.linearIsometryEquiv Q) (blockHead k s)= + blockRadius k s • ((Unitary.linearIsometryEquiv Q) (blockDirection k s).val) + rw [← map_smul,block_head_direction] + · rfl + +theorem continuous_blockRotateSpin (k : ℕ) : Continuous (Function.uncurry (blockRotateSpin k)) := by + apply Continuous.subtype_mk + change Continuous (fun p : SpinOrthogonal 3×Spin (3+k) => + (splitThree k).symm (WithLp.toLp 2 (((p.1:SpinOperator 3) (blockHead k p.2)),blockTail k p.2))) + apply (splitThree k).symm.continuous.comp + apply (WithLp.prodContinuousLinearEquiv 2 ℝ _ _).symm.continuous.comp + exact ((continuous_subtype_val.comp continuous_fst).clm_apply ((continuous_blockHead k).comp continuous_snd)).prodMk + ((continuous_blockTail k).comp continuous_snd) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BlockKernel.lean b/lean/OAI/Probability/ClassicalON/BlockKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..876825f5a3ba292c8ecd61e0c31baf1e69dad54f --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BlockKernel.lean @@ -0,0 +1,92 @@ +import OAI.Probability.ClassicalON.BlockOrbit + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def blockCoupling (k : ℕ) (left right : E → V) (b : E → ℝ) (s : V → Spin (3+k)) : E → ℝ := + fun e => b e*blockRadius k (s (left e))*blockRadius k (s (right e)) + +def blockTailEnergy (k : ℕ) (left right : E → V) (b : E → ℝ) (s : V → Spin (3+k)) : ℝ := + ∑ e,b e*⟪blockTail k (s (left e)),blockTail k (s (right e))⟫_ℝ + +omit [Fintype V] [Fintype E] in +theorem blockCoupling_bounds (k : ℕ) (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) + (s : V → Spin (3+k)) (e : E) : 0 ≤ blockCoupling k left right b s e ∧ blockCoupling k left right b s e ≤ b e := by + unfold blockCoupling + constructor + · exact mul_nonneg (mul_nonneg (hb e) (blockRadius_nonneg _ _)) (blockRadius_nonneg _ _) + · calc + _ ≤ b e*1*1 := mul_le_mul (mul_le_mul_of_nonneg_left (blockRadius_le_one _ _) (hb e)) + (blockRadius_le_one _ _) (blockRadius_nonneg _ _) (by simpa using hb e) + _ = b e := by ring + +omit [Fintype V] in +theorem blockFiberConfiguration_energy (k : ℕ) (left right : E → V) (b : E → ℝ) + (s : V → Spin (3+k)) (t : V → Spin 3) : + freeSpinEnergy (3+k) left right b (blockFiberConfiguration k s t)= + freeSpinEnergy 3 left right (blockCoupling k left right b s) t+blockTailEnergy k left right b s := by + unfold freeSpinEnergy blockTailEnergy blockFiberConfiguration + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e _ + rw [blockFiber_inner] + unfold blockCoupling + ring + +omit [Fintype V] [Fintype E] in +theorem blockFiberConfiguration_first (k : ℕ) (x y : V) (s : V → Spin (3+k)) (t : V → Spin 3) : + coordinateSpinProduct (3+k) ⟨0,by omega⟩ x y (blockFiberConfiguration k s t)= + (blockRadius k (s x)*blockRadius k (s y))*firstSpinProduct x y t := by + unfold coordinateSpinProduct blockFiberConfiguration + rw [← blockHead_first,← blockHead_first,blockHead_fiber,blockHead_fiber] + simp only [PiLp.smul_apply,smul_eq_mul,firstSpinProduct] + ring + +def freeSpinPartition (n : ℕ) (left right : E → V) (b : E → ℝ) : ℝ := + ∫ s,Real.exp (freeSpinEnergy n left right b s) ∂freeSpinReference n + +theorem freeSpinPartition_pos (n : ℕ) [NeZero n] (left right : E → V) (b : E → ℝ) : + 0 < freeSpinPartition n left right b := + compact_integral_pos (continuous_freeSpinEnergy _ _ _ _).rexp (fun _ => Real.exp_pos _) + +theorem block_fiber_partition (k : ℕ) (left right : E → V) (b : E → ℝ) (s : V → Spin (3+k)) : + (∫ t,Real.exp (freeSpinEnergy (3+k) left right b (blockFiberConfiguration k s t)) ∂freeSpinReference 3)= + Real.exp (blockTailEnergy k left right b s)*freeSpinPartition 3 left right (blockCoupling k left right b s) := by + simp_rw [blockFiberConfiguration_energy,Real.exp_add] + rw [integral_mul_const] + exact mul_comm _ _ + +theorem block_fiber_numerator (k : ℕ) (left right : E → V) (b : E → ℝ) + (x y : V) (s : V → Spin (3+k)) : + (∫ t,Real.exp (freeSpinEnergy (3+k) left right b (blockFiberConfiguration k s t))* + coordinateSpinProduct (3+k) ⟨0,by omega⟩ x y (blockFiberConfiguration k s t) ∂freeSpinReference 3)= + (Real.exp (blockTailEnergy k left right b s)*freeSpinPartition 3 left right (blockCoupling k left right b s))* + ((blockRadius k (s x)*blockRadius k (s y))* + freeSpinMean 3 left right (blockCoupling k left right b s) (firstSpinProduct x y)) := by + have hz := (freeSpinPartition_pos 3 left right (blockCoupling k left right b s)).ne' + simp_rw [blockFiberConfiguration_energy,Real.exp_add,blockFiberConfiguration_first] + have he (t : V → Spin 3) : + Real.exp (freeSpinEnergy 3 left right (blockCoupling k left right b s) t)* + Real.exp (blockTailEnergy k left right b s)* + (blockRadius k (s x)*blockRadius k (s y)*firstSpinProduct x y t)= + (Real.exp (blockTailEnergy k left right b s)*(blockRadius k (s x)*blockRadius k (s y)))* + (Real.exp (freeSpinEnergy 3 left right (blockCoupling k left right b s) t)*firstSpinProduct x y t) := by ring + simp_rw [he] + rw [integral_const_mul] + unfold freeSpinMean weightedMean + change _=(_*freeSpinPartition 3 left right (blockCoupling k left right b s))* + (_*(_/freeSpinPartition 3 left right (blockCoupling k left right b s))) + field_simp + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BlockLocal.lean b/lean/OAI/Probability/ClassicalON/BlockLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e0526c99ecd6023724f96d476bebe74c1213dfc --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BlockLocal.lean @@ -0,0 +1,51 @@ +import OAI.Probability.ClassicalON.SpinReindex + +namespace OAI + +universe uE uF uK uV uW + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {W : Type uW} {E : Type uE} {F : Type uF} {K : Type uK} [Fintype V] [Fintype W] [Fintype E] [Fintype F] [Fintype K] + +omit [Fintype K] in +theorem blockBondMean_local (l r : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (k : K) (l' r' : F → W) (b' : F → ℝ) (B' : Set W) + (ev : BlockVertex B label k ≃ ↥(B'ᶜ)) (ee : {e // elabel e=k} ≃ F) + (hb : ∀ e,b' (ee e)=b e.val) + (hl : ∀ (s : ↥(B'ᶜ) → Spin 3) e, + glueFamily B' (fun _ => poleSpin true) s (l' (ee e))= + blockSpin B label k (fun v => s (ev v)) (l e.val)) + (hr : ∀ (s : ↥(B'ᶜ) → Spin 3) e, + glueFamily B' (fun _ => poleSpin true) s (r' (ee e))= + blockSpin B label k (fun v => s (ev v)) (r e.val)) + (f : (F → Bool) → ℝ) : + poleBondMean l' r' b' B' (fun _ => true) f= + blockBondMean l r b B label elabel k (fun η => f (arrowEquiv ee η)) := by + rw [poleBondMean_collapse] + have he (s : ↥(B'ᶜ) → Spin 3) : + freeSpinEnergy 3 l' r' b' (glueFamily B' (fun _ => poleSpin true) s)= + blockEnergy l r b B label elabel k (fun v => s (ev v)) := + freeSpinEnergy_edgeEquiv 3 ee _ _ _ _ _ _ _ _ hb (hl s) (hr s) + have hs (s : ↥(B'ᶜ) → Spin 3) : + (∑ η,spinBondWeight l' r' b' (glueFamily B' (fun _ => poleSpin true) s) η*f η)= + ∑ η,blockBondWeight l r b B label elabel k (fun v => s (ev v)) η*f (arrowEquiv ee η) := by + have h := sum_spinBondWeight_edgeEquiv ee (fun e => l e.val) (fun e => r e.val) l' r' + (fun e => b e.val) b' (blockSpin B label k (fun v => s (ev v))) + (glueFamily B' (fun _ => poleSpin true) s) hb (hl s) (hr s) + (fun η => f (arrowEquiv ee η)) + simp only [arrowEquiv,Equiv.coe_fn_mk,Equiv.apply_symm_apply] at h + convert h using 1; congr! + simp_rw [he,hs] + unfold blockBondMean + convert weightedMean_pi_reindex ev (fun _ => sphereProbability 3) + (fun s => Real.exp (blockEnergy l r b B label elabel k s)) + (fun s => ∑ η,blockBondWeight l r b B label elabel k s η*f (arrowEquiv ee η)) using 1 + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BlockOrbit.lean b/lean/OAI/Probability/ClassicalON/BlockOrbit.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca727a2ae9492206079739569a2ffb559afc7274 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BlockOrbit.lean @@ -0,0 +1,108 @@ +import OAI.Probability.ClassicalON.BlockGeometry + +namespace OAI + +universe uV + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace Classical +namespace ClassicalON + +theorem orthogonalSpin_eval_preserves (n : ℕ) [NeZero n] (s : Spin n) : + MeasurePreserving (fun Q : SpinOrthogonal n => orthogonalSpin Q s) + (orthogonalLaw n) (sphereProbability n) := by + have hc : Continuous (fun Q : SpinOrthogonal n => orthogonalSpin Q s) := + (continuous_orthogonalSpin n).comp (continuous_id.prodMk continuous_const) + refine ⟨hc.measurable,?_⟩ + apply Measure.ext_of_integral_eq_on_compactlySupported + intro f + rw [integral_map (f := fun x => f x) hc.measurable.aemeasurable f.continuous.aestronglyMeasurable] + exact integral_orthogonalSpin_eq f f.continuous s + +variable {V : Type uV} [Fintype V] + +def blockFiberConfiguration (k : ℕ) (s : V → Spin (3+k)) (t : V → Spin 3) : V → Spin (3+k) := + fun v => blockFiber k (s v) (t v) + +omit [Fintype V] in +theorem continuous_blockFiberConfiguration (k : ℕ) : + Continuous (Function.uncurry (blockFiberConfiguration (V := V) k)) := by + apply continuous_pi + intro v + exact (continuous_blockFiber k).comp + (f := fun p : (V → Spin (3+k))×(V → Spin 3) => (p.1 v,p.2 v)) + (((continuous_apply v).comp continuous_fst).prodMk ((continuous_apply v).comp continuous_snd)) + +def blockRotateConfiguration (k : ℕ) (Q : V → SpinOrthogonal 3) : + (V → Spin (3+k)) ≃ₜ (V → Spin (3+k)) := + SpinSystem.rotateConfiguration (fun v => blockRotation k (Q v)) + +omit [Fintype V] in +theorem blockRotateConfiguration_fiber (k : ℕ) (Q : V → SpinOrthogonal 3) (s : V → Spin (3+k)) : + blockRotateConfiguration k Q s= + blockFiberConfiguration k s (fun v => orthogonalSpin (Q v) (blockDirection k (s v))) := by + funext v + exact blockRotateSpin_fiber k (Q v) (s v) + +omit [Fintype V] in +theorem continuous_blockRotateConfiguration (k : ℕ) : Continuous + (fun p : (V → SpinOrthogonal 3)×(V → Spin (3+k)) => blockRotateConfiguration k p.1 p.2) := by + apply continuous_pi + intro v + exact (continuous_blockRotateSpin k).comp + (f := fun p : (V → SpinOrthogonal 3)×(V → Spin (3+k)) => (p.1 v,p.2 v)) + (((continuous_apply v).comp continuous_fst).prodMk ((continuous_apply v).comp continuous_snd)) + +theorem blockRotateConfiguration_preserves (k : ℕ) (Q : V → SpinOrthogonal 3) : + MeasurePreserving (blockRotateConfiguration k Q) (freeSpinReference (3+k)) (freeSpinReference (3+k)) := + measurePreserving_pi (fun _ : V => sphereProbability (3+k)) (fun _ => sphereProbability (3+k)) + (fun v => spinRotation_preserves_probability (blockRotation k (Q v))) + +def orthogonalConfigurationLaw : Measure (V → SpinOrthogonal 3) := Measure.pi (fun _ => orthogonalLaw 3) +instance orthogonalConfigurationLaw_isProbability : IsProbabilityMeasure (orthogonalConfigurationLaw (V := V)) := by + unfold orthogonalConfigurationLaw + infer_instance + +theorem integral_block_orbit (k : ℕ) (f : (V → Spin (3+k)) → ℝ) (hf : Continuous f) + (s : V → Spin (3+k)) : + (∫ Q,f (blockRotateConfiguration k Q s) ∂orthogonalConfigurationLaw)= + ∫ t,f (blockFiberConfiguration k s t) ∂freeSpinReference 3 := by + have hp := measurePreserving_pi (fun _ : V => orthogonalLaw 3) (fun _ => sphereProbability 3) + (fun v => orthogonalSpin_eval_preserves 3 (blockDirection k (s v))) + have hc : Continuous (fun t : V → Spin 3 => f (blockFiberConfiguration k s t)) := + hf.comp ((continuous_blockFiberConfiguration k).comp + (f := fun t : V → Spin 3 => (s,t)) (continuous_const.prodMk continuous_id)) + rw [show freeSpinReference (V := V) 3= + (orthogonalConfigurationLaw (V := V)).map + (fun Q v => orthogonalSpin (Q v) (blockDirection k (s v))) from hp.map_eq.symm, + integral_map hp.measurable.aemeasurable hc.aestronglyMeasurable] + apply integral_congr_ae + filter_upwards with Q + rw [blockRotateConfiguration_fiber] + +theorem integral_freeSpinReference_block (k : ℕ) (f : (V → Spin (3+k)) → ℝ) (hf : Continuous f) : + (∫ s,f s ∂freeSpinReference (3+k))= + ∫ s,∫ t,f (blockFiberConfiguration k s t) ∂freeSpinReference 3 ∂freeSpinReference (3+k) := by + let : NeZero (3+k) := ⟨by omega⟩ + have hc : Continuous (fun p : (V → Spin (3+k))×(V → SpinOrthogonal 3) => + f (blockRotateConfiguration k p.2 p.1)) := + hf.comp ((continuous_blockRotateConfiguration k).comp + (f := (Prod.swap : (V → Spin (3+k))×(V → SpinOrthogonal 3) → + (V → SpinOrthogonal 3)×(V → Spin (3+k)))) continuous_swap) + have he := integral_integral_swap (μ := freeSpinReference (3+k)) (ν := orthogonalConfigurationLaw) + (f := fun s Q => f (blockRotateConfiguration k Q s)) (compact_integrable hc) + have hi (Q : V → SpinOrthogonal 3) : + (∫ s,f (blockRotateConfiguration k Q s) ∂freeSpinReference (3+k))=∫ s,f s ∂freeSpinReference (3+k) := + (blockRotateConfiguration_preserves k Q).integral_comp + (blockRotateConfiguration k Q).measurableEmbedding f + simp_rw [hi] at he + simp only [integral_const,probReal_univ,one_smul] at he + rw [← he] + exact integral_congr_ae (Filter.Eventually.of_forall (integral_block_orbit k f hf)) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BlockReduction.lean b/lean/OAI/Probability/ClassicalON/BlockReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..47359daaf9d0144ec35c1cbb56c2295d9ca8b178 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BlockReduction.lean @@ -0,0 +1,74 @@ +import OAI.Probability.ClassicalON.BlockKernel + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem coordinateSpinMean_block_bounds (k : ℕ) (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0 ≤ b e) (x y : V) (C : ℝ) + (hthree : ∀ c : E → ℝ,(∀ e,0 ≤ c e ∧ c e ≤ b e) → + 0 ≤ freeSpinMean 3 left right c (firstSpinProduct x y) ∧ + freeSpinMean 3 left right c (firstSpinProduct x y) ≤ C) : + 0 ≤ freeSpinMean (3+k) left right b (coordinateSpinProduct (3+k) ⟨0,by omega⟩ x y) ∧ + freeSpinMean (3+k) left right b (coordinateSpinProduct (3+k) ⟨0,by omega⟩ x y) ≤ C := by + let : NeZero (3+k) := ⟨by omega⟩ + let W : (V → Spin (3+k)) → ℝ := fun s => Real.exp (freeSpinEnergy (3+k) left right b s) + let F := coordinateSpinProduct (3+k) ⟨0,by omega⟩ x y + have hW : Continuous W := (continuous_freeSpinEnergy _ _ _ _).rexp + have hF : Continuous F := continuous_coordinateSpinProduct _ _ _ _ + have hWF : Continuous (fun s => W s*F s) := hW.mul hF + have hpoint (s : V → Spin (3+k)) : + 0 ≤ (∫ t,W (blockFiberConfiguration k s t)*F (blockFiberConfiguration k s t) ∂freeSpinReference 3) ∧ + (∫ t,W (blockFiberConfiguration k s t)*F (blockFiberConfiguration k s t) ∂freeSpinReference 3) ≤ + C*(∫ t,W (blockFiberConfiguration k s t) ∂freeSpinReference 3) := by + dsimp only [W,F] + rw [block_fiber_numerator,block_fiber_partition] + have h3 := hthree (blockCoupling k left right b s) (blockCoupling_bounds k left right b hb s) + have hr0 : 0 ≤ blockRadius k (s x)*blockRadius k (s y) := + mul_nonneg (blockRadius_nonneg _ _) (blockRadius_nonneg _ _) + have hr1 : blockRadius k (s x)*blockRadius k (s y) ≤ 1 := + (mul_le_of_le_one_left (blockRadius_nonneg _ _) (blockRadius_le_one _ _)).trans + (blockRadius_le_one _ _) + have hD : 0 ≤ Real.exp (blockTailEnergy k left right b s)* + freeSpinPartition 3 left right (blockCoupling k left right b s) := + mul_nonneg (Real.exp_pos _).le (freeSpinPartition_pos _ _ _ _).le + constructor + · exact mul_nonneg hD (mul_nonneg hr0 h3.1) + · calc + _ ≤ (Real.exp (blockTailEnergy k left right b s)* + freeSpinPartition 3 left right (blockCoupling k left right b s))*C := + mul_le_mul_of_nonneg_left + ((mul_le_of_le_one_left h3.1 hr1).trans h3.2) hD + _ = _ := mul_comm _ _ + have hNi : Integrable (fun s : V → Spin (3+k) => + ∫ t,W (blockFiberConfiguration k s t)*F (blockFiberConfiguration k s t) ∂freeSpinReference 3) + (freeSpinReference (3+k)) := + compact_integrable (compact_parametric_integral _ + (hWF.comp (continuous_blockFiberConfiguration k))) + have hDi : Integrable (fun s : V → Spin (3+k) => + ∫ t,W (blockFiberConfiguration k s t) ∂freeSpinReference 3) (freeSpinReference (3+k)) := + compact_integrable (compact_parametric_integral _ + (hW.comp (continuous_blockFiberConfiguration k))) + have hN : 0 ≤ ∫ s,W s*F s ∂freeSpinReference (3+k) := by + rw [integral_freeSpinReference_block k _ hWF] + exact integral_nonneg (fun s => (hpoint s).1) + have hND : (∫ s,W s*F s ∂freeSpinReference (3+k)) ≤ C*(∫ s,W s ∂freeSpinReference (3+k)) := by + rw [integral_freeSpinReference_block k _ hWF,integral_freeSpinReference_block k _ hW,← integral_const_mul] + exact integral_mono hNi (hDi.const_mul C) (fun s => (hpoint s).2) + have hD : 0 < ∫ s,W s ∂freeSpinReference (3+k) := + compact_integral_pos hW (fun _ => Real.exp_pos _) + constructor + · exact div_nonneg hN hD.le + · exact (div_le_iff₀ hD).mpr hND + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondAssociation.lean b/lean/OAI/Probability/ClassicalON/BondAssociation.lean new file mode 100644 index 0000000000000000000000000000000000000000..250e7369444720c8824c70f8ef45888e1aa95dc0 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondAssociation.lean @@ -0,0 +1,55 @@ +import OAI.Probability.ClassicalON.SignedSigns + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem rawBond_tilt_defect_nonneg (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + {f g : (V → Amplitude) → (E → Bool) → ℝ} + (hf : ∀ η,Continuous (fun r => f r η)) (hg : ∀ η,Continuous (fun r => g r η)) + (hfn : ∀ r η,0≤f r η) (hgn : ∀ r η,0≤g r η) + (hfr : ∀ η,Monotone (fun r => f r η)) (hgr : ∀ η,Monotone (fun r => g r η)) + (hfη : ∀ r,Monotone (f r)) (hgη : ∀ r,Monotone (g r)) : + 0≤∫ r,∑ η,amplitudeBondWeight left right b r η*g r η* + (f r η-jointBondMean μ left right b f) ∂Measure.pi (fun _ : V => μ) := by + let c := jointBondMean μ left right b f + have h := jointBond_associated μ left right b hb hf hg hfn hgn hfr hgr hfη hgη + change c*jointBondMean μ left right b g≤jointBondMean μ left right b (fun r η => f r η*g r η) at h + rw [jointBondMean_raw _ _ _ _ hb,jointBondMean_raw _ _ _ _ hb] at h + have hD : 0<∫ r,∑ η,amplitudeBondWeight left right b r η ∂Measure.pi (fun _ : V => μ) := by + simp_rw [amplitudeBondWeight_sum] + exact compact_integral_pos (continuous_amplitudeDensity _ _ _) (amplitudeDensity_pos _ _ _) + rw [← mul_div_assoc,div_le_div_iff_of_pos_right hD] at h + have hi1 : Integrable (fun r => ∑ η,amplitudeBondWeight left right b r η*(f r η*g r η)) + (Measure.pi (fun _ : V => μ)) := by + apply compact_integrable + exact continuous_finsetSum _ (fun η _ => (continuous_amplitudeBondWeight _ _ _ η).mul ((hf η).mul (hg η))) + have hi2 : Integrable (fun r => c*∑ η,amplitudeBondWeight left right b r η*g r η) + (Measure.pi (fun _ : V => μ)) := by + apply compact_integrable + exact continuous_const.mul (continuous_finsetSum _ (fun η _ => (continuous_amplitudeBondWeight _ _ _ η).mul (hg η))) + have he (r : V → Amplitude) : + (∑ η,amplitudeBondWeight left right b r η*g r η*(f r η-c))= + (∑ η,amplitudeBondWeight left right b r η*(f r η*g r η))- + c*∑ η,amplitudeBondWeight left right b r η*g r η := by + rw [Finset.mul_sum,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro η _ + ring + change 0≤∫ r,∑ η,amplitudeBondWeight left right b r η*g r η*(f r η-c) ∂Measure.pi (fun _ : V => μ) + simp_rw [he] + rw [integral_sub hi1 hi2,integral_const_mul] + exact sub_nonneg.mpr h + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondConnectivity.lean b/lean/OAI/Probability/ClassicalON/BondConnectivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..44a7364454137329c89a82d2d9d7489159183a25 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondConnectivity.lean @@ -0,0 +1,55 @@ +import OAI.Probability.ClassicalON.PinnedSigns + +namespace OAI + +universe uE uV + +noncomputable section +open scoped Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} + +def bondGraph (left right : E → V) (η : E → Bool) : SimpleGraph V where + Adj x y := x≠y ∧ ∃ e,η e=true ∧ + ((left e=x ∧ right e=y) ∨ (left e=y ∧ right e=x)) + symm := ⟨by + intro x y ⟨h,e,he,hor⟩ + exact ⟨h.symm,e,he,hor.elim (fun ⟨a,b⟩ => Or.inr ⟨a,b⟩) (fun ⟨a,b⟩ => Or.inl ⟨a,b⟩)⟩⟩ + loopless := ⟨by intro x; simp⟩ + +theorem bondGraph_endpoint_reachable (left right : E → V) (η : E → Bool) (e : E) + (he : η e=true) : (bondGraph left right η).Reachable (left e) (right e) := by + by_cases h : left e=right e + · rw [h] + · exact SimpleGraph.Adj.reachable ⟨h,e,he,Or.inl ⟨rfl,rfl⟩⟩ + +theorem bondConnected_iff_reachable (left right : E → V) (η : E → Bool) (x y : V) : + bondConnected left right η x y ↔ (bondGraph left right η).Reachable x y := by + constructor + · intro h + let s : V → SignField := fun v => if (bondGraph left right η).Reachable x v then 0 else 1 + have hs : s∈bondSubspace left right η := by + intro e he + have hh := bondGraph_endpoint_reachable left right η e he + have hi : (bondGraph left right η).Reachable x (left e) ↔ + (bondGraph left right η).Reachable x (right e) := + ⟨fun hp => hp.trans hh,fun hp => hp.trans hh.symm⟩ + simp only [s,hi] + have hh := h s hs + by_contra hy + simp [s,hy] at hh + · rintro ⟨p⟩ s hs + induction p with + | nil => rfl + | @cons u v w huv p ih => + apply Eq.trans _ ih + obtain ⟨_,e,he,hor⟩ := huv + rcases hor with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact hs e he + · exact (hs e he).symm + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondExpansion.lean b/lean/OAI/Probability/ClassicalON/BondExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..204bb1459e17efc01ac57166a87e992cc1f9672d --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondExpansion.lean @@ -0,0 +1,95 @@ +import OAI.Probability.ClassicalON.DiscreteReference + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def bondSignProduct (left right : E → V) (t : E → ℝ) (η : E → Bool) (s : V → Bool) : ℝ := + ∏ e,if η e then (if s (left e)=s (right e) then t e else 0) else 1 + +omit [Fintype V] in +theorem bondSignProduct_eq (left right : E → V) (t : E → ℝ) (η : E → Bool) (s : V → Bool) : + bondSignProduct left right t η s= + bondProduct t η*(if s∈compatibleSigns left right η then 1 else 0) := by + by_cases h : s∈compatibleSigns left right η + · simp only [h,ite_true,mul_one,bondSignProduct,bondProduct] + apply Finset.prod_congr rfl + intro e _ + cases he : η e + · simp + · simp [h e he] + · simp only [h,ite_false,mul_zero] + obtain ⟨e,he,hs⟩ : ∃ e,η e=true ∧ s (left e)≠s (right e) := by + change ¬(∀ e,η e=true → s (left e)=s (right e)) at h + push Not at h + exact h + apply Finset.prod_eq_zero (Finset.mem_univ e) + simp [he,hs] + +omit [Fintype V] in +theorem ising_expansion (left right : E → V) (K : E → ℝ) (s : V → Bool) : + Real.exp (edgeHamiltonian (isingEnergy left right) K s)= + Real.exp (-∑ e,K e)*∑ η : E → Bool,bondSignProduct left right + (fun e => Real.exp (2*K e)-1) η s := by + have hedge (k : ℝ) (a b : Bool) : + Real.exp (k*(signValue a*signValue b))= + Real.exp (-k)*(∑ η : Bool,if η then (if a=b then Real.exp (2*k)-1 else 0) else 1) := by + cases a <;> cases b <;> simp [signValue] + all_goals ring_nf + all_goals rw [← Real.exp_add] + all_goals (congr 1; ring) + unfold edgeHamiltonian isingEnergy + rw [Real.exp_sum] + simp_rw [hedge] + rw [Finset.prod_mul_distrib,← Real.exp_sum,Finset.sum_neg_distrib,Fintype.prod_sum] + rfl + +omit [Fintype V] in +theorem signValue_fieldSign (s : Bool) : signValue s=fieldSign (signFieldEquiv s) := by + cases s <;> rfl + +omit [Fintype E] in +theorem compatible_sign_correlation_sum (left right : E → V) (η : E → Bool) (x y : V) : + (∑ s : V → Bool,(if s∈compatibleSigns left right η then (1:ℝ) else 0)* + (signValue (s x)*signValue (s y)))= + if bondConnected left right η x y then clusterWeight left right η else 0 := by + have he := Equiv.sum_comp (compatibleSignsEquiv left right η) + (fun s : bondSubspace left right η => fieldSign (s.val x)*fieldSign (s.val y)) + have hh : (∑ s : compatibleSigns left right η,signValue (s.val x)*signValue (s.val y))= + ∑ s : bondSubspace left right η,fieldSign (s.val x)*fieldSign (s.val y) := by + convert he using 1 + congr 1 + ext s + simp only [signValue_fieldSign] + rfl + rw [← bond_sign_correlation left right η x y,← hh] + rw [← Finset.sum_subtype (Finset.univ.filter (fun s : V → Bool => s∈compatibleSigns left right η)) + (by simp) (fun s => signValue (s x)*signValue (s y)),Finset.sum_filter] + apply Finset.sum_congr rfl + intro s _ + split_ifs <;> simp + +theorem ising_partition_bond_sum (left right : E → V) (K : E → ℝ) : + (∫ s,Real.exp (edgeHamiltonian (isingEnergy left right) K s) ∂isingReference)= + (2 : ℝ)⁻¹^Fintype.card V*Real.exp (-∑ e,K e)* + ∑ η,bondWeight left right (fun e => Real.exp (2*K e)-1) η := by + rw [integral_isingReference] + simp_rw [ising_expansion,bondSignProduct_eq] + rw [← Finset.mul_sum,Finset.sum_comm] + simp_rw [← Finset.mul_sum,compatibleSigns_sum] + unfold bondWeight + simp only [mul_comm (bondProduct _ _) (clusterWeight _ _ _)] + ring + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondLaw.lean b/lean/OAI/Probability/ClassicalON/BondLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..58c07d690d2cbcb97042764e561c468130131746 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondLaw.lean @@ -0,0 +1,126 @@ +import OAI.Probability.ClassicalON.BondSubspace + +namespace OAI + +universe uE uV uX + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def bondProduct (t : E → ℝ) (η : E → Bool) : ℝ := ∏ e,if η e then t e else 1 + +def bondWeight (left right : E → V) (t : E → ℝ) (η : E → Bool) : ℝ := + clusterWeight left right η*bondProduct t η + +theorem bondProduct_nonneg {t : E → ℝ} (ht : ∀ e,0 ≤ t e) (η : E → Bool) : + 0 ≤ bondProduct t η := Finset.prod_nonneg fun e _ => by split <;> [exact ht e; exact zero_le_one] + +omit [Fintype V] in +theorem bondWeight_nonneg (left right : E → V) {t : E → ℝ} (ht : ∀ e,0 ≤ t e) + (η : E → Bool) : 0 ≤ bondWeight left right t η := + mul_nonneg (clusterWeight_pos _ _ _).le (bondProduct_nonneg ht η) + +theorem bondProduct_holley {t s : E → ℝ} (ht : ∀ e,0 ≤ t e) (hts : t ≤ s) + (η ξ : E → Bool) : + bondProduct t η*bondProduct s ξ ≤ bondProduct t (η⊓ξ)*bondProduct s (η⊔ξ) := by + unfold bondProduct + rw [← Finset.prod_mul_distrib,← Finset.prod_mul_distrib] + apply Finset.prod_le_prod₀ + · intro e _ + exact mul_nonneg (by split <;> [exact ht e; exact zero_le_one]) (by split <;> [exact le_trans (ht e) (hts e); exact zero_le_one]) + · intro e _ + simp only [Pi.inf_apply,Pi.sup_apply] + have hh (a b : Bool) : (if a then t e else 1)*(if b then s e else 1) ≤ + (if a⊓b then t e else 1)*(if a⊔b then s e else 1) := by + cases a <;> cases b <;> simp [hts e] + exact hh _ _ + +theorem bondWeight_holley (left right : E → V) {t s : E → ℝ} + (ht : ∀ e,0 ≤ t e) (hts : t ≤ s) (η ξ : E → Bool) : + bondWeight left right t η*bondWeight left right s ξ ≤ + bondWeight left right t (η⊓ξ)*bondWeight left right s (η⊔ξ) := by + unfold bondWeight + rw [mul_mul_mul_comm,mul_mul_mul_comm (clusterWeight left right (η⊓ξ))] + exact mul_le_mul (clusterWeight_supermodular _ _ η ξ) (bondProduct_holley ht hts η ξ) + (mul_nonneg (bondProduct_nonneg ht η) (bondProduct_nonneg (fun e => le_trans (ht e) (hts e)) ξ)) + (mul_nonneg (clusterWeight_pos _ _ _).le (clusterWeight_pos _ _ _).le) + +def finiteMean {X : Type uX} [Fintype X] (w f : X → ℝ) : ℝ := (∑ x,w x*f x)/(∑ x,w x) + +omit [Fintype V] in +theorem bondWeight_sum_pos (left right : E → V) {t : E → ℝ} (ht : ∀ e,0 ≤ t e) : + 0 < ∑ η,bondWeight left right t η := by + apply Finset.sum_pos' (fun η _ => bondWeight_nonneg left right ht η) + refine ⟨fun _ => false,Finset.mem_univ _,?_⟩ + simpa [bondWeight,bondProduct] using clusterWeight_pos left right (fun _ => false) + +section Finite +variable {X : Type uX} [Fintype X] + +theorem finiteMean_nonneg {w f : X → ℝ} (hw : ∀ x,0 ≤ w x) (hf : ∀ x,0 ≤ f x) : + 0 ≤ finiteMean w f := + div_nonneg (Finset.sum_nonneg fun x _ => mul_nonneg (hw x) (hf x)) (Finset.sum_nonneg fun x _ => hw x) + +theorem finiteMean_le {w f : X → ℝ} {a : ℝ} (hw : ∀ x,0 ≤ w x) + (hp : 0 < ∑ x,w x) (hf : ∀ x,f x ≤ a) : finiteMean w f ≤ a := by + apply (div_le_iff₀ hp).2 + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro x _ + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hf x) (hw x) + +theorem finiteMean_mono {w f g : X → ℝ} (hw : ∀ x,0 ≤ w x) (hf : f ≤ g) : + finiteMean w f ≤ finiteMean w g := by + apply div_le_div_of_nonneg_right _ (Finset.sum_nonneg fun x _ => hw x) + exact Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_left (hf x) (hw x) + +variable [DistribLattice X] + +theorem finiteMean_associated {w f g : X → ℝ} (hw : ∀ x,0 ≤ w x) (hp : 0 < ∑ x,w x) + (hLS : ∀ x y,w x*w y ≤ w (x⊓y)*w (x⊔y)) + (hf : ∀ x,0 ≤ f x) (hg : ∀ x,0 ≤ g x) (hfm : Monotone f) (hgm : Monotone g) : + finiteMean w f*finiteMean w g ≤ finiteMean w (fun x => f x*g x) := by + have hh := fkg f g w hw hf hg hfm hgm hLS + unfold finiteMean + rw [div_mul_div_comm,div_le_div_iff₀ (mul_pos hp hp) hp] + nlinarith + +theorem finiteMean_holley {w v f : X → ℝ} (hw : ∀ x,0 ≤ w x) (hv : ∀ x,0 ≤ v x) + (hp : 0 < ∑ x,w x) (hvp : 0 < ∑ x,v x) (hf : ∀ x,0 ≤ f x) (hfm : Monotone f) + (hH : ∀ x y,w x*v y ≤ w (x⊓y)*v (x⊔y)) : finiteMean w f ≤ finiteMean v f := by + have hh := four_functions_theorem_univ v (fun x => w x*f x) w (fun x => v x*f x) + hv (fun x => mul_nonneg (hw x) (hf x)) hw (fun x => mul_nonneg (hv x) (hf x)) + (fun x y => show v x*(w y*f y) ≤ w (x⊓y)*(v (x⊔y)*f (x⊔y)) from by + have h := mul_le_mul (hH y x) (hfm (show y ≤ x⊔y from le_sup_right)) + (hf y) (mul_nonneg (hw (y⊓x)) (hv (y⊔x))) + simpa only [inf_comm,sup_comm,mul_assoc,mul_left_comm] using h) + unfold finiteMean + apply (div_le_div_iff₀ hp hvp).2 + nlinarith +end Finite + +theorem bondMean_mono (left right : E → V) {t s : E → ℝ} + (ht : ∀ e,0 ≤ t e) (hts : t ≤ s) {f : (E → Bool) → ℝ} + (hf : ∀ η,0 ≤ f η) (hfm : Monotone f) : + finiteMean (bondWeight left right t) f ≤ finiteMean (bondWeight left right s) f := + finiteMean_holley (bondWeight_nonneg left right ht) + (bondWeight_nonneg left right (fun e => le_trans (ht e) (hts e))) + (bondWeight_sum_pos left right ht) (bondWeight_sum_pos left right (fun e => le_trans (ht e) (hts e))) + hf hfm (bondWeight_holley left right ht hts) + +theorem bondMean_associated (left right : E → V) {t : E → ℝ} (ht : ∀ e,0 ≤ t e) + {f g : (E → Bool) → ℝ} (hf : ∀ η,0 ≤ f η) (hg : ∀ η,0 ≤ g η) + (hfm : Monotone f) (hgm : Monotone g) : + finiteMean (bondWeight left right t) f*finiteMean (bondWeight left right t) g ≤ + finiteMean (bondWeight left right t) (fun η => f η*g η) := + finiteMean_associated (bondWeight_nonneg left right ht) (bondWeight_sum_pos left right ht) + (bondWeight_holley left right ht le_rfl) hf hg hfm hgm + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondMeanOrder.lean b/lean/OAI/Probability/ClassicalON/BondMeanOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ab6d50fb13a9aff8dc9ebbf2072b4094b297156 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondMeanOrder.lean @@ -0,0 +1,72 @@ +import OAI.Probability.ClassicalON.SpinCorrelation + +namespace OAI + +universe uE uK uV + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} {K : Type uK} [Fintype V] [Fintype E] [Fintype K] + +theorem freeBondMean_nonneg (l r : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + {f : (E → Bool) → ℝ} (hf : ∀ η,0≤f η) : 0≤freeBondMean l r b f := by + rw [freeBondMean_eq_jointBondMean _ _ _ hb] + exact jointBondMean_nonneg _ _ _ _ hb (fun _ η => hf η) + +theorem freeBondMean_mono (l r : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + {f g : (E → Bool) → ℝ} (hfg : ∀ η,f η≤g η) : freeBondMean l r b f≤freeBondMean l r b g := by + rw [freeBondMean_eq_jointBondMean _ _ _ hb,freeBondMean_eq_jointBondMean _ _ _ hb] + exact jointBondMean_mono _ _ _ _ hb (fun _ => continuous_const) (fun _ => continuous_const) (fun _ η => hfg η) + +theorem freeBondMean_sum (l r : E → V) (b : E → ℝ) (f : K → (E → Bool) → ℝ) : + freeBondMean l r b (fun η => ∑ k,f k η)=∑ k,freeBondMean l r b (f k) := by + unfold freeBondMean freeSpinMean weightedMean + simp_rw [Finset.mul_sum] + rw [show (fun s : V → Spin 3 => ∑ η,∑ k,Real.exp (freeSpinEnergy 3 l r b s)* + (spinBondWeight l r b s η*f k η))= + (fun s => ∑ k,∑ η,Real.exp (freeSpinEnergy 3 l r b s)*(spinBondWeight l r b s η*f k η)) by + funext s; rw [Finset.sum_comm]] + rw [integral_finsetSum,Finset.sum_div] + intro k _ + exact compact_integrable (continuous_finsetSum _ (fun η _ => + (continuous_freeSpinEnergy _ _ _ _).rexp.mul ((continuous_spinBondWeight _ _ _ _).mul continuous_const))) + +theorem freeBondMean_one (l r : E → V) (b : E → ℝ) : freeBondMean l r b (fun _ => 1)=1 := by + unfold freeBondMean freeSpinMean weightedMean + simp only [mul_one,spinBondWeight_sum] + exact div_self (ne_of_gt (compact_integral_pos (continuous_freeSpinEnergy 3 l r b).rexp (fun _ => Real.exp_pos _))) + +omit [Fintype K] in +theorem blockBondMean_one (l r : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (k : K) : blockBondMean l r b B label elabel k (fun _ => 1)=1 := by + have hs (s : BlockVertex B label k → Spin 3) : + (∑ η,blockBondWeight l r b B label elabel k s η)=1 := by + convert spinBondWeight_sum (fun e : {e // elabel e=k} => l e.val) (fun e => r e.val) + (fun e => b e.val) (blockSpin B label k s) using 1; congr! + unfold blockBondMean weightedMean + simp only [mul_one,hs] + apply div_self + apply ne_of_gt + exact compact_integral_pos + ((continuous_freeSpinEnergy _ _ _ _).comp (continuous_blockSpin B label k)).rexp + (fun _ => Real.exp_pos _) + +omit [Fintype K] in +theorem blockBondMean_nonneg (l r : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (B : Set V) (label : V → K) (elabel : E → K) (k : K) + {f : ({e // elabel e=k} → Bool) → ℝ} (hf : ∀ η,0≤f η) : + 0≤blockBondMean l r b B label elabel k f := by + apply weightedMean_nonneg + ((continuous_freeSpinEnergy _ _ _ _).comp (continuous_blockSpin B label k)).rexp + (fun _ => Real.exp_pos _) + intro s + exact Finset.sum_nonneg (fun η _ => mul_nonneg (spinBondWeight_nonneg (fun e : {e // elabel e=k} => l e.val) + (fun e => r e.val) (fun e => b e.val) (fun e => hb e.val) _ _) (hf η)) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondMoments.lean b/lean/OAI/Probability/ClassicalON/BondMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdd210a301d34d63c608347942d8927ca1314abf --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondMoments.lean @@ -0,0 +1,59 @@ +import OAI.Probability.ClassicalON.JointBond + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem ising_numerator_bond_sum (left right : E → V) (K : E → ℝ) (x y : V) : + (∫ s,Real.exp (edgeHamiltonian (isingEnergy left right) K s)*(signValue (s x)*signValue (s y)) ∂isingReference)= + (2:ℝ)⁻¹^Fintype.card V*Real.exp (-∑ e,K e)* + ∑ η,bondWeight left right (fun e => Real.exp (2*K e)-1) η* + (if bondConnected left right η x y then 1 else 0) := by + have hs (η : E → Bool) : + (∑ s : V → Bool,Real.exp (-∑ e,K e)*(bondProduct (fun e => Real.exp (2*K e)-1) η* + (if s∈compatibleSigns left right η then 1 else 0))*(signValue (s x)*signValue (s y)))= + Real.exp (-∑ e,K e)*bondWeight left right (fun e => Real.exp (2*K e)-1) η* + (if bondConnected left right η x y then 1 else 0) := by + calc + _ = (Real.exp (-∑ e,K e)*bondProduct (fun e => Real.exp (2*K e)-1) η)* + ∑ s : V → Bool,(if s∈compatibleSigns left right η then 1 else 0)*(signValue (s x)*signValue (s y)) := by + rw [Finset.mul_sum]; congr 1; ext s; ring + _ = _ := by + rw [compatible_sign_correlation_sum] + split_ifs <;> simp [bondWeight] + ring + have hall : (∑ s : V → Bool,Real.exp (edgeHamiltonian (isingEnergy left right) K s)* + (signValue (s x)*signValue (s y)))= + Real.exp (-∑ e,K e)*∑ η,bondWeight left right (fun e => Real.exp (2*K e)-1) η* + (if bondConnected left right η x y then 1 else 0) := by + simp_rw [ising_expansion,bondSignProduct_eq,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + simp_rw [hs] + simp_rw [mul_assoc] + rw [integral_isingReference,hall] + ring + +theorem isingAmplitudePartition_bond_sum (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + isingAmplitudePartition left right b r= + (2:ℝ)⁻¹^Fintype.card V*Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (r v:ℝ)) e)* + ∑ η,bondWeight left right (amplitudeBondParam left right b r) η := by + have hp : (fun e => Real.exp (2*amplitudeCoupling left right b (fun v => (r v:ℝ)) e)-1)= + amplitudeBondParam left right b r := by + funext e + unfold amplitudeBondParam amplitudeCoupling + congr 2 + ring + rw [isingAmplitudePartition,amplitudePartition,ising_partition_bond_sum,hp] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondPin.lean b/lean/OAI/Probability/ClassicalON/BondPin.lean new file mode 100644 index 0000000000000000000000000000000000000000..462a5ae15c34372bca2bee5fc65a7ce7fe073ddd --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondPin.lean @@ -0,0 +1,69 @@ +import OAI.Probability.ClassicalON.SpinBonds + +namespace OAI + +universe uE uV + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] + +def pinRestriction (B : Set V) : (V → SignField) →ₗ[SignField] (B → SignField) where + toFun s := fun v => s v + map_add' _ _ := rfl + map_smul' _ _ := rfl + +def bondPinRank (left right : E → V) (B : Set V) (η : E → Bool) : ℕ := + Module.finrank SignField ((bondSubspace left right η).map (pinRestriction B)) + +def bondPinFactor (left right : E → V) (B : Set V) (η : E → Bool) : ℝ := + (2^bondPinRank left right B η)⁻¹ + +omit [Fintype V] in +theorem bondPinFactor_pos (left right : E → V) (B : Set V) (η : E → Bool) : + 0 < bondPinFactor left right B η := by unfold bondPinFactor; positivity + +theorem bondPinRank_antitone (left right : E → V) (B : Set V) : + Antitone (bondPinRank left right B) := by + intro η ξ h + apply Submodule.finrank_mono + exact Submodule.map_mono (bondSubspace_antitone left right h) + +theorem bondPinFactor_monotone (left right : E → V) (B : Set V) : + Monotone (bondPinFactor left right B) := by + intro η ξ h + apply inv_anti₀ (by positivity : 0 < (2:ℝ)^bondPinRank left right B ξ) + exact pow_le_pow_right₀ (by norm_num) (bondPinRank_antitone left right B h) + +def pinnedBondSubspace (left right : E → V) (B : Set V) (η : E → Bool) : + Submodule SignField (V → SignField) := + bondSubspace left right η⊓LinearMap.ker (pinRestriction B) + +theorem pinnedBond_rank_add (left right : E → V) (B : Set V) (η : E → Bool) : + Module.finrank SignField (pinnedBondSubspace left right B η)+bondPinRank left right B η = + bondRank left right η := by + let K := bondSubspace left right η + let f := (pinRestriction B).domRestrict K + have hk : LinearMap.ker f=(pinnedBondSubspace left right B η).comap K.subtype := by + ext s + simp [f,pinnedBondSubspace,K] + have hh := LinearMap.finrank_range_add_finrank_ker f + rw [show LinearMap.range f=K.map (pinRestriction B) from LinearMap.range_domRestrict K _,hk, + (Submodule.comapSubtypeEquivOfLe (show pinnedBondSubspace left right B η ≤ K from inf_le_left)).finrank_eq] at hh + exact (Nat.add_comm _ _).trans hh + +theorem pinnedBond_card (left right : E → V) (B : Set V) (η : E → Bool) : + (Fintype.card (pinnedBondSubspace left right B η) : ℝ)= + clusterWeight left right η*bondPinFactor left right B η := by + rw [Module.card_eq_pow_finrank (K := SignField)] + simp only [SignField,ZMod.card,Nat.cast_pow,Nat.cast_ofNat] + unfold clusterWeight bondPinFactor + rw [← pinnedBond_rank_add left right B η,pow_add,mul_assoc,mul_inv_cancel₀ (by positivity),mul_one] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondSigns.lean b/lean/OAI/Probability/ClassicalON/BondSigns.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9cc49dff51480619faa5d018bf4d8fd1150be9f --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondSigns.lean @@ -0,0 +1,109 @@ +import OAI.Probability.ClassicalON.BondLaw + +namespace OAI + +universe uE uV + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON + +def signFieldEquiv : Bool ≃ SignField where + toFun b := if b then 0 else 1 + invFun a := a=0 + left_inv b := by cases b <;> decide + right_inv a := by + have ha : a=0 ∨ a=1 := by fin_cases a <;> [exact Or.inl rfl; exact Or.inr rfl] + rcases ha with rfl | rfl <;> simp + +@[simp] theorem signFieldEquiv_true : signFieldEquiv true=0 := rfl +@[simp] theorem signFieldEquiv_false : signFieldEquiv false=1 := rfl + +def fieldSign (a : SignField) : ℝ := if a=0 then 1 else -1 + +theorem signField_cases (a : SignField) : a=0 ∨ a=1 := by + fin_cases a <;> [exact Or.inl rfl; exact Or.inr rfl] + +@[simp] theorem fieldSign_zero : fieldSign 0=1 := by simp [fieldSign] +@[simp] theorem fieldSign_one : fieldSign 1= -1 := by simp [fieldSign] + +theorem fieldSign_add (a b : SignField) : fieldSign (a+b)=fieldSign a*fieldSign b := by + have htwo : (1 : SignField)+1=0 := rfl + rcases signField_cases a with rfl | rfl <;> rcases signField_cases b with rfl | rfl <;> simp [htwo] + +theorem fieldSign_sq (a : SignField) : fieldSign a*fieldSign a=1 := by + rcases signField_cases a with rfl | rfl <;> simp + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def compatibleSigns (left right : E → V) (η : E → Bool) : Set (V → Bool) := + {s | ∀ e,η e=true → s (left e)=s (right e)} + +def compatibleSignsEquiv (left right : E → V) (η : E → Bool) : + compatibleSigns left right η ≃ bondSubspace left right η := + (Equiv.piCongrRight (fun _ : V => signFieldEquiv)).subtypeEquiv (by + intro s + change (∀ e,η e=true → s (left e)=s (right e)) ↔ + ∀ e,η e=true → signFieldEquiv (s (left e))=signFieldEquiv (s (right e)) + simp only [Equiv.apply_eq_iff_eq]) + +omit [Fintype E] in +theorem compatibleSigns_card (left right : E → V) (η : E → Bool) : + Fintype.card (compatibleSigns left right η)=2^bondRank left right η := by + rw [Fintype.card_congr (compatibleSignsEquiv left right η),Module.card_eq_pow_finrank (K := SignField)] + simp [bondRank,SignField] + +omit [Fintype E] in +theorem compatibleSigns_sum (left right : E → V) (η : E → Bool) : + (∑ s : V → Bool,if s∈compatibleSigns left right η then (1:ℝ) else 0)=clusterWeight left right η := by + rw [Finset.sum_boole,← Fintype.card_subtype] + unfold clusterWeight + exact_mod_cast compatibleSigns_card left right η + +omit [Fintype V] [Fintype E] in +def bondConnected (left right : E → V) (η : E → Bool) (x y : V) : Prop := + ∀ s∈bondSubspace left right η,s x=s y + +omit [Fintype V] [Fintype E] in +theorem bondConnected_mono (left right : E → V) (x y : V) : + Monotone (fun η => bondConnected left right η x y) := by + intro η ξ h hη s hs + exact hη s (bondSubspace_antitone left right h hs) + +omit [Fintype E] in +theorem bond_sign_correlation (left right : E → V) (η : E → Bool) (x y : V) : + (∑ s : bondSubspace left right η,fieldSign (s.val x)*fieldSign (s.val y))= + if bondConnected left right η x y then clusterWeight left right η else 0 := by + split_ifs with h + · have he (s : bondSubspace left right η) : fieldSign (s.val x)*fieldSign (s.val y)=1 := by + rw [h s.val s.property]; exact fieldSign_sq _ + simp_rw [he] + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_one] + unfold clusterWeight bondRank + norm_cast + rw [Module.card_eq_pow_finrank (K := SignField)] + simp [SignField] + · obtain ⟨s,hs,hxy⟩ : ∃ s∈bondSubspace left right η,s x≠s y := by + unfold bondConnected at h + push Not at h + exact h + let u : bondSubspace left right η := ⟨s,hs⟩ + have hc : fieldSign (s x)*fieldSign (s y)= -1 := by + have hlocal (a b : SignField) (hab : a≠b) : fieldSign a*fieldSign b= -1 := by + rcases signField_cases a with rfl | rfl <;> rcases signField_cases b with rfl | rfl <;> simp_all + exact hlocal _ _ hxy + have hh := Equiv.sum_comp (Equiv.addRight u) (fun t : bondSubspace left right η => fieldSign (t.val x)*fieldSign (t.val y)) + have he (t : bondSubspace left right η) : + fieldSign ((t+u).val x)*fieldSign ((t+u).val y)= -(fieldSign (t.val x)*fieldSign (t.val y)) := by + change fieldSign (t.val x+s x)*fieldSign (t.val y+s y)= _ + rw [fieldSign_add,fieldSign_add,mul_mul_mul_comm,hc,mul_neg_one] + change (∑ t : bondSubspace left right η,fieldSign ((t+u).val x)*fieldSign ((t+u).val y))=_ at hh + simp_rw [he] at hh + rw [Finset.sum_neg_distrib] at hh + linarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/BondSubspace.lean b/lean/OAI/Probability/ClassicalON/BondSubspace.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb876047a7ad375126c5bb5bfe9ad7236b689cee --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/BondSubspace.lean @@ -0,0 +1,73 @@ +import OAI.Probability.ClassicalON.PinnedCylinder + +namespace OAI + +universe uE uV + +noncomputable section +open scoped BigOperators +namespace ClassicalON + +abbrev SignField := ZMod 2 + +variable {V : Type uV} {E : Type uE} + +def bondSubspace (left right : E → V) (η : E → Bool) : Submodule SignField (V → SignField) where + carrier := {s | ∀ e,η e=true → s (left e)=s (right e)} + zero_mem' := by simp + add_mem' := by intro f g hf hg e he; simp only [Pi.add_apply,hf e he,hg e he] + smul_mem' := by intro c f hf e he; simp only [Pi.smul_apply,hf e he] + +@[simp] theorem mem_bondSubspace (left right : E → V) (η : E → Bool) (s : V → SignField) : + s∈bondSubspace left right η ↔ ∀ e,η e=true → s (left e)=s (right e) := Iff.rfl + +theorem bondSubspace_antitone (left right : E → V) : Antitone (bondSubspace left right) := by + intro η ξ h s hs e he + apply hs e + have hh := h e + rw [he] at hh + exact le_antisymm (show ξ e ≤ true from Bool.le_true _) hh + +theorem bondSubspace_sup (left right : E → V) (η ξ : E → Bool) : + bondSubspace left right (η⊔ξ)=bondSubspace left right η⊓bondSubspace left right ξ := by + apply le_antisymm + · exact le_inf (bondSubspace_antitone left right le_sup_left) (bondSubspace_antitone left right le_sup_right) + · intro s hs e he + have ht : η e=true ∨ ξ e=true := by simpa using he + rcases ht with ht | ht + · exact hs.1 e ht + · exact hs.2 e ht + +variable [Fintype V] + +def bondRank (left right : E → V) (η : E → Bool) : ℕ := + Module.finrank SignField (bondSubspace left right η) + +theorem bondRank_supermodular (left right : E → V) (η ξ : E → Bool) : + bondRank left right η+bondRank left right ξ≤ + bondRank left right (η⊓ξ)+bondRank left right (η⊔ξ) := by + unfold bondRank + rw [bondSubspace_sup,← Submodule.finrank_sup_add_finrank_inf_eq] + apply Nat.add_le_add_right + apply Submodule.finrank_mono + exact sup_le (bondSubspace_antitone left right inf_le_left) (bondSubspace_antitone left right inf_le_right) + +def clusterWeight (left right : E → V) (η : E → Bool) : ℝ := + 2^bondRank left right η + +omit [Fintype V] in +theorem clusterWeight_pos (left right : E → V) (η : E → Bool) : 0 e.val.1) (fun e => e.val.2) b (I∪O) (fun _ => true) + (crossingIndicator (fun e : G.edges => e.val.1) (fun e => e.val.2) I O)≤ε := by + obtain ⟨k,hk,hsmall⟩ := annulus_crossing_small β hβ ε hε + refine ⟨k,hk,?_⟩ + intro G z hG b hb I O hI hO + let H := G.translate z + let ev : G.vertices ≃ H.vertices := G.translateVertexEquiv z + let ee : G.edges ≃ H.edges := G.translateEdgeEquiv z + let I' : Set H.vertices := ev.symm ⁻¹' I + let O' : Set H.vertices := ev.symm ⁻¹' O + have hi (v : G.vertices) : ev v∈I' ↔ v∈I := by simp only [I',mem_preimage,Equiv.symm_apply_apply] + have ho (v : G.vertices) : ev v∈O' ↔ v∈O := by simp only [O',mem_preimage,Equiv.symm_apply_apply] + have hl (e : G.edges) : (ee e).val.1=ev e.val.1 := rfl + have hr (e : G.edges) : (ee e).val.2=ev e.val.2 := rfl + have he (η : H.edges → Bool) : + crossingIndicator (fun e : H.edges => e.val.1) (fun e => e.val.2) I' O' η= + crossingIndicator (fun e : G.edges => e.val.1) (fun e => e.val.2) I O (fun e => η (ee e)) := by + unfold crossingIndicator + rw [bondCrossing_reindex ev ee _ _ _ _ hl hr I O I' O' hi ho] + have hmean := poleBondMean_reindex ev ee (fun e : G.edges => e.val.1) (fun e => e.val.2) + (fun e : H.edges => e.val.1) (fun e => e.val.2) b (fun e => b (ee.symm e)) (I∪O) (I'∪O') + (fun e => by simp) hl hr (fun v => by simp only [mem_union,hi,ho]) + (crossingIndicator (fun e : G.edges => e.val.1) (fun e => e.val.2) I O) + have hbox : H.WithinDyadicBox k := by + intro v + obtain ⟨v,rfl⟩ := ev.surjective v + change |v.val.1-z.1|≤2*(2^k:ℕ) ∧ |v.val.2-z.2|≤2*(2^k:ℕ) + exact (siteRadius_le_iff z v.val _).mp (hG v) + have hinner : I'⊆H.innerSet k := by + intro v hv + obtain ⟨v,rfl⟩ := ev.surjective v + have hv' := (siteRadius_le_iff z v.val _).mp (hI v ((hi v).mp hv)) + have hn : (0:ℝ)<2^k := by positivity + change |((v.val.1-z.1:ℤ):ℝ)/(2:ℝ)^k|≤1 ∧ |((v.val.2-z.2:ℤ):ℝ)/(2:ℝ)^k|≤1 + simp only [abs_div,abs_of_pos hn,div_le_one hn] + exact ⟨by exact_mod_cast hv'.1,by exact_mod_cast hv'.2⟩ + have houter : O'⊆H.outerSet k := by + intro v hv + obtain ⟨v,rfl⟩ := ev.surjective v + have hv' := hO v ((ho v).mp hv) + have hn : (0:ℝ)<2^k := by positivity + change 2≤|((v.val.1-z.1:ℤ):ℝ)/(2:ℝ)^k| ∨ 2≤|((v.val.2-z.2:ℤ):ℝ)/(2:ℝ)^k| + simp only [abs_div,abs_of_pos hn,le_div_iff₀ hn] + change _≤ max _ _ at hv' + rcases le_max_iff.mp hv' with h | h + · left; exact_mod_cast h + · right; exact_mod_cast h + have hs := hsmall H hbox (fun e => b (ee.symm e)) (fun e => hb _) I' O' hinner houter + rw [show crossingIndicator (fun e : H.edges => e.val.1) (fun e => e.val.2) I' O'= + (fun η => crossingIndicator (fun e : G.edges => e.val.1) (fun e => e.val.2) I O + (fun e => η (ee e))) from funext he] at hs + rwa [hmean] at hs + +theorem local_annulus_small (β : ℝ) (hβ : 0≤β) (ε : ℝ) (hε : 0<ε) : + ∃ k : ℕ,4≤k ∧ ∀ (G : LatticeGraph) (b : G.edges → ℝ),(∀ e,0≤b e ∧ b e≤β) → + ∀ z : Site,let H := G.annulusGraph (2^k:ℕ) z + poleBondMean (fun e : H.edges => e.val.1) (fun e => e.val.2) (G.annulusCoupling b (2^k:ℕ) z) + (G.annulusPins (2^k:ℕ) z) (fun _ => true) + (crossingIndicator (fun e : H.edges => e.val.1) (fun e => e.val.2) + (G.annulusInner (2^k:ℕ) z) (G.annulusOuter (2^k:ℕ) z))≤ε := by + obtain ⟨k,hk,hs⟩ := centered_crossing_small β hβ ε hε + refine ⟨k,hk,?_⟩ + intro G b hb z + apply hs (G.annulusGraph (2^k:ℕ) z) z + · intro v + exact ((Finset.mem_filter.mp v.property).2).2 + · intro e + exact hb (G.restrictEdge _ e) + · intro v hv + exact le_of_eq hv + · intro v hv + exact le_of_eq hv.symm + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CoarseCodes.lean b/lean/OAI/Probability/ClassicalON/CoarseCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..c206e1106c134c396866b277690acf5b761bddac --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CoarseCodes.lean @@ -0,0 +1,64 @@ +import OAI.Probability.ClassicalON.CoarseGeometry + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON + +abbrev CoarseDirection := Fin 3 × Fin 3 +abbrev CoarseCode (L : ℕ) := Fin L → CoarseDirection + +def directionVector (d : CoarseDirection) : Site := ((d.1.val:ℤ)-1,(d.2.val:ℤ)-1) +def codePosition {L : ℕ} (z : Site) (c : CoarseCode L) (i : Fin (L+1)) : Site := + z+Fin.partialSum (directionVector ∘ c) i + +@[simp] theorem codePosition_zero {L : ℕ} (z : Site) (c : CoarseCode L) : codePosition z c 0=z := by + simp [codePosition] + +theorem codePosition_succ {L : ℕ} (z : Site) (c : CoarseCode L) (i : Fin L) : + codePosition z c i.succ=codePosition z c i.castSucc+directionVector (c i) := by + simp only [codePosition,Fin.partialSum_succ,Function.comp_apply,add_assoc] + +theorem directionVector_surj {z w : Site} (h : siteRadius z w≤1) : + ∃ d,directionVector d=w-z := by + have hh := (siteRadius_le_iff z w 1).mp h + have h1 := abs_le.mp hh.1 + have h2 := abs_le.mp hh.2 + refine ⟨(⟨(w.1-z.1+1).toNat,by omega⟩,⟨(w.2-z.2+1).toNat,by omega⟩),?_⟩ + apply Prod.ext <;> dsimp [directionVector] <;> omega + +theorem codePosition_exists {L : ℕ} (p : Fin (L+1) → Site) + (h : ∀ i : Fin L,siteRadius (p i.castSucc) (p i.succ)≤1) : + ∃ c : CoarseCode L,codePosition (p 0) c=p := by + choose c hc using fun i => directionVector_surj (h i) + refine ⟨c,funext fun i => ?_⟩ + induction i using Fin.induction with + | zero => exact codePosition_zero _ _ + | succ i ih => rw [codePosition_succ,ih,hc]; abel + +abbrev SimpleCoarseCode (z : Site) (L : ℕ) := {c : CoarseCode L // Function.Injective (codePosition z c)} + +theorem card_simpleCoarseCode (z : Site) (L : ℕ) : Fintype.card (SimpleCoarseCode z L)≤9^L := by + calc + _≤Fintype.card (CoarseCode L) := Fintype.card_subtype_le _ + _=9^L := by simp [CoarseCode,CoarseDirection] + +theorem codeColor_exists (t : ℕ) (z : Site) (c : CoarseCode (25*t)) : + ∃ q : SiteColor,t≤Fintype.card {i : Fin (25*t+1) // siteColor (codePosition z c i)=q} := by + obtain ⟨q,hq⟩ := Fintype.exists_le_card_fiber_of_mul_le_card + (fun i => siteColor (codePosition z c i)) (n := t) (by simp [SiteColor]) + exact ⟨q,by simpa only [Fintype.card_subtype] using hq⟩ + +def codeColor (t : ℕ) (z : Site) (c : CoarseCode (25*t)) : SiteColor := + (codeColor_exists t z c).choose + +theorem codeColor_card (t : ℕ) (z : Site) (c : CoarseCode (25*t)) : + t≤Fintype.card {i : Fin (25*t+1) // siteColor (codePosition z c i)=codeColor t z c} := + (codeColor_exists t z c).choose_spec + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CoarseExponential.lean b/lean/OAI/Probability/ClassicalON/CoarseExponential.lean new file mode 100644 index 0000000000000000000000000000000000000000..c49c092582d82e9defdec1d49905288c8bbacfbb --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CoarseExponential.lean @@ -0,0 +1,83 @@ +import OAI.Probability.ClassicalON.CoarseTail + +namespace OAI + +noncomputable section +open scoped Classical +namespace ClassicalON + +theorem siteDistance_nonneg (x y : Site) : 0 ≤ siteDistance x y := Real.sqrt_nonneg _ + +theorem siteDistance_le_radius_twice (x y : Site) : siteDistance x y ≤ 2*(siteRadius x y:ℝ) := by + have hi := siteRadius_nonneg x y + have h1 : |(y.1:ℝ)-(x.1:ℝ)| ≤ (siteRadius x y:ℝ) := by + exact_mod_cast (le_max_left |y.1-x.1| |y.2-x.2|) + have h2 : |(y.2:ℝ)-(x.2:ℝ)| ≤ (siteRadius x y:ℝ) := by + exact_mod_cast (le_max_right |y.1-x.1| |y.2-x.2|) + have hr : (0:ℝ) ≤ siteRadius x y := by exact_mod_cast hi + rw [abs_sub_comm] at h1 h2 + have hs1 := mul_self_le_mul_self (abs_nonneg _) h1 + have hs2 := mul_self_le_mul_self (abs_nonneg _) h2 + have hab1 := sq_abs ((x.1:ℝ)-(y.1:ℝ)) + have hab2 := sq_abs ((x.2:ℝ)-(y.2:ℝ)) + unfold siteDistance + apply Real.sqrt_le_iff.mpr + constructor + · positivity + · nlinarith + +theorem half_pow_exp (t : ℕ) : (1/2:ℝ)^t=Real.exp (-Real.log 2*(t:ℝ)) := by + rw [mul_comm,Real.exp_nat_mul,Real.exp_neg,Real.exp_log (by norm_num : (0:ℝ) < 2)] + norm_num + +namespace LatticeGraph + +theorem connection_exponential (β : ℝ) (hβ : 0 ≤ β) : + ∃ m : ℝ,0 < m ∧ ∀ (G : LatticeGraph) (b : G.edges → ℝ),(∀ e,0 ≤ b e ∧ b e ≤ β) → + ∀ x y : G.vertices,G.connectionProbability b x y ≤ 4*Real.exp (-m*siteDistance x.val y.val) := by + obtain ⟨N,hN,ht⟩ := connection_geometric_tail β hβ + have hNr : (0:ℝ) < N := by exact_mod_cast hN + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + let m := Real.log 2/(50*(N:ℝ)) + refine ⟨m,by positivity,?_⟩ + intro G b hb x y + let f := siteDistance x.val y.val/(50*(N:ℝ)) + have hf : 0 ≤ f := div_nonneg (siteDistance_nonneg _ _) (by positivity) + let t : ℕ := Nat.floor f-1 + have hft : f < (t:ℝ)+2 := by + have h1 := Nat.lt_floor_add_one f + have h2 : Nat.floor f ≤ t+1 := by dsimp [t]; omega + have h3 : (Nat.floor f:ℝ) ≤ (t:ℝ)+1 := by exact_mod_cast h2 + linarith + have hp : G.connectionProbability b x y ≤ (1/2:ℝ)^t := by + by_cases ht0 : t=0 + · simpa only [ht0,pow_zero] using G.connectionProbability_le_one b (fun e => (hb e).1) x y + · apply ht G b hb x y t + have he : Nat.floor f=t+1 := by dsimp [t] at *; omega + have hfl := Nat.floor_le hf + rw [he,Nat.cast_add,Nat.cast_one] at hfl + have hmul := (le_div_iff₀ (show (0:ℝ) < 50*(N:ℝ) by positivity)).mp hfl + have hd := siteDistance_le_radius_twice x.val y.val + have hr : (N:ℝ)*((25*t:ℕ)+4) ≤ (siteRadius x.val y.val:ℝ) := by + push_cast + nlinarith + exact_mod_cast hr + apply le_trans hp + rw [half_pow_exp] + calc + _ ≤ Real.exp (Real.log 2*(2-f)) := Real.exp_le_exp.mpr (by nlinarith) + _=4*Real.exp (-m*siteDistance x.val y.val) := by + have he : Real.exp (Real.log 2*2)=(4:ℝ) := by + rw [mul_comm,show (2:ℝ)=(2:ℕ) by norm_num,Real.exp_nat_mul] + norm_num [Real.exp_log] + rw [show Real.log 2*(2-f)=Real.log 2*2+(-Real.log 2*f) by ring,Real.exp_add,he] + congr 2 + dsimp [f,m] + ring + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CoarseGeometry.lean b/lean/OAI/Probability/ClassicalON/CoarseGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5a9ff81c42e6cf2e3728c81c40d80ca60c85990 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CoarseGeometry.lean @@ -0,0 +1,93 @@ +import OAI.Probability.ClassicalON.AnnulusLabels + +namespace OAI + +universe uι + +noncomputable section +open scoped Classical +namespace ClassicalON + +def coarseSite (N : ℤ) (v : Site) : Site := (v.1/N,v.2/N) +def coarseCenter (N : ℤ) (v : Site) : Site := (N*v.1,N*v.2) + +theorem siteRadius_scale (N : ℤ) (hN : 0≤N) (x y : Site) : + siteRadius (coarseCenter N x) (coarseCenter N y)=N*siteRadius x y := by + simp only [siteRadius,coarseCenter,← mul_sub,abs_mul,abs_of_nonneg hN] + exact (mul_max_of_nonneg _ _ hN).symm + +theorem coarseSite_close (N : ℤ) (hN : 0.mp h + exact max_le (coarse_quotient_step N hN _ _ hh.1) (coarse_quotient_step N hN _ _ hh.2) + +theorem coarseSite_distance (N : ℤ) (hN : 0 c.1.val) h + have h2 := congrArg (fun c : SiteColor => c.2.val) h + change (x.1%5).toNat=(y.1%5).toNat at h1 + change (x.2%5).toNat=(y.2%5).toNat at h2 + by_contra hn + have hr : |y.1-x.1|≤4 ∧ |y.2-x.2|≤4 := (siteRadius_le_iff x y 4).mp (by omega) + have ha := abs_le.mp hr.1 + have hb := abs_le.mp hr.2 + apply hxy + apply Prod.ext <;> omega + +theorem sameColor_separated {ι : Type uι} (N : ℤ) (hN : 0 coarseCenter N (v i.val)) := by + intro i j hij + rw [siteRadius_scale N (le_of_lt hN)] + have hd : v i.val≠v j.val := fun h => hij (Subtype.ext (hv h)) + have hh := sameColor_far hd (i.property.trans j.property.symm) + nlinarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CoarsePaths.lean b/lean/OAI/Probability/ClassicalON/CoarsePaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..157df6581ed6c6acf5c3243ca442b84f00d446db --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CoarsePaths.lean @@ -0,0 +1,106 @@ +import OAI.Probability.ClassicalON.AnnulusCut + +namespace OAI + +noncomputable section +open scoped Classical +namespace ClassicalON.LatticeGraph + +def cellVisited (G : LatticeGraph) (η : G.edges → Bool) (x : G.vertices) (N : ℤ) (z : Site) : Prop := + ∃ v : G.vertices,bondConnected (fun e : G.edges => e.val.1) (fun e => e.val.2) η x v ∧ coarseSite N v.val=z + +def coarseCluster (G : LatticeGraph) (η : G.edges → Bool) (x : G.vertices) (N : ℤ) : SimpleGraph Site where + Adj z w := z≠w ∧ siteRadius z w≤1 ∧ G.cellVisited η x N z ∧ G.cellVisited η x N w + symm := ⟨by intro z w ⟨h,hd,hz,hw⟩; exact ⟨h.symm,by simpa only [siteRadius_symm] using hd,hw,hz⟩⟩ + loopless := ⟨by intro z; simp⟩ + +theorem fine_edge_radius (G : LatticeGraph) (η : G.edges → Bool) {v w : G.vertices} + (h : (bondGraph (fun e : G.edges => e.val.1) (fun e => e.val.2) η).Adj v w) : + siteRadius v.val w.val=1 := by + obtain ⟨_,e,_,he⟩ := h + rcases he with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact siteRadius_neighbor (G.nearest e.val e.property) + · rw [siteRadius_symm]; exact siteRadius_neighbor (G.nearest e.val e.property) + +theorem coarse_reachable_of_walk (G : LatticeGraph) (η : G.edges → Bool) (x : G.vertices) + (N : ℤ) (hN : 0 e.val.1) (fun e => e.val.2) η).Walk v w) + (hv : bondConnected (fun e : G.edges => e.val.1) (fun e => e.val.2) η x v) : + (G.coarseCluster η x N).Reachable (coarseSite N v.val) (coarseSite N w.val) := by + induction p with + | nil => exact SimpleGraph.Reachable.refl _ + | @cons v w u hvw p ih => + have hw := bondConnected_trans _ _ _ hv ((bondConnected_iff_reachable _ _ _ _ _).mpr hvw.reachable) + apply SimpleGraph.Reachable.trans (v := coarseSite N w.val) ?_ (ih hw) + by_cases he : coarseSite N v.val=coarseSite N w.val + · rw [he] + · apply SimpleGraph.Adj.reachable + refine ⟨he,coarseSite_step N hN (le_of_eq (G.fine_edge_radius η hvw)),⟨v,hv,rfl⟩,⟨w,hw,rfl⟩⟩ + +theorem coarse_walk_visited (G : LatticeGraph) (η : G.edges → Bool) (x : G.vertices) + (N : ℤ) {z w : Site} (p : (G.coarseCluster η x N).Walk z w) + (hz : G.cellVisited η x N z) (i : ℕ) : G.cellVisited η x N (p.getVert i) := by + induction p generalizing i with + | nil => exact hz + | @cons z v w h p ih => + cases i with + | zero => exact hz + | succ i => exact ih h.2.2.2 i + +theorem coarse_walk_radius (G : LatticeGraph) (η : G.edges → Bool) (x : G.vertices) + (N : ℤ) {z w : Site} (p : (G.coarseCluster η x N).Walk z w) : siteRadius z w≤p.length := by + induction p with + | nil => simp + | @cons z v w h p ih => + have ht := siteRadius_triangle z v w + have hs := h.2.1 + simpa only [SimpleGraph.Walk.length_cons,Nat.cast_add,Nat.cast_one] using (show siteRadius z w≤(p.length:ℤ)+1 by omega) + +theorem connected_has_coarse_code (G : LatticeGraph) (η : G.edges → Bool) (x y : G.vertices) + (N : ℤ) (hN : 0 e.val.1) (fun e => e.val.2) η x y) : + ∃ c : SimpleCoarseCode (coarseSite N x.val) L, + ∀ i : Fin (L+1),G.cellVisited η x N (codePosition (coarseSite N x.val) c.val i) := by + obtain ⟨p⟩ := (bondConnected_iff_reachable _ _ _ _ _).mp hxy + obtain ⟨q⟩ := G.coarse_reachable_of_walk η x N hN p (fun _ _ => rfl) + let r := q.toPath.val + have hr : r.IsPath := q.toPath.property + have hl : L≤r.length := by + have hd := coarseSite_distance N hN x.val y.val + have hq := G.coarse_walk_radius η x N r + by_contra hn + have hln : (r.length:ℤ)<(L:ℤ) := by exact_mod_cast (Nat.lt_of_not_ge hn) + nlinarith + let a : Fin (L+1) → Site := fun i => r.getVert i.val + have ha : Function.Injective a := by + intro i j hij + apply Fin.ext + exact hr.getVert_injOn (by simp only [Set.mem_ofPred_eq]; omega) (by simp only [Set.mem_ofPred_eq]; omega) hij + have hs (i : Fin L) : siteRadius (a i.castSucc) (a i.succ)≤1 := + (r.adj_getVert_succ (by omega : i.val rfl),rfl⟩ i.val + +theorem connected_code_crossings (G : LatticeGraph) (η : G.edges → Bool) (x y : G.vertices) + (N : ℤ) (hN : 0 e.val.1) (fun e => e.val.2) η x y) : + ∃ c : SimpleCoarseCode (coarseSite N x.val) L, + ∀ i : Fin (L+1),G.annulusIndicator N (coarseCenter N (codePosition (coarseSite N x.val) c.val i)) η=1 := by + obtain ⟨c,hc⟩ := G.connected_has_coarse_code η x y N hN L (by nlinarith) hxy + refine ⟨c,?_⟩ + intro i + obtain ⟨w,hw,he⟩ := hc i + apply G.annulus_crossing_of_component N hN η x y w (by nlinarith) hxy hw + rw [← he] + exact le_of_lt (coarseSite_close N hN w.val) + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CoarseTail.lean b/lean/OAI/Probability/ClassicalON/CoarseTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..252e2523be020114843085c34da8e7f46b0928e8 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CoarseTail.lean @@ -0,0 +1,86 @@ +import OAI.Probability.ClassicalON.CoarsePaths + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON.LatticeGraph + +def codeEvent (G : LatticeGraph) (N : ℤ) (t : ℕ) (z : Site) (c : CoarseCode (25*t)) + (η : G.edges → Bool) : ℝ := + ∏ i : {i : Fin (25*t+1) // siteColor (codePosition z c i)=codeColor t z c}, + G.annulusIndicator N (coarseCenter N (codePosition z c i.val)) η + +theorem codeEvent_nonneg (G : LatticeGraph) (N : ℤ) (t : ℕ) (z : Site) (c : CoarseCode (25*t)) + (η : G.edges → Bool) : 0≤G.codeEvent N t z c η := + Finset.prod_nonneg (fun _ _ => G.annulusIndicator_nonneg _ _ _) + +def connectionProbability (G : LatticeGraph) (b : G.edges → ℝ) (x y : G.vertices) : ℝ := + freeBondMean (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (fun η => if bondConnected (fun e : G.edges => e.val.1) (fun e => e.val.2) η x y then 1 else 0) + +theorem connectionProbability_le_one (G : LatticeGraph) (b : G.edges → ℝ) (hb : ∀ e,0≤b e) (x y : G.vertices) : + G.connectionProbability b x y≤1 := by + unfold connectionProbability + calc + _≤freeBondMean (fun e : G.edges => e.val.1) (fun e => e.val.2) b (fun _ => 1) := by + apply freeBondMean_mono _ _ _ hb + intro η + split_ifs <;> norm_num + _=1 := freeBondMean_one _ _ _ + +theorem connection_le_codeSum (G : LatticeGraph) (b : G.edges → ℝ) (hb : ∀ e,0≤b e) + (x y : G.vertices) (N : ℤ) (hN : 0 e.val.1) (fun e => e.val.2) b (G.codeEvent N t (coarseSite N x.val) c.val) := by + rw [← freeBondMean_sum] + apply freeBondMean_mono _ _ _ hb + intro η + split_ifs with hxy + · obtain ⟨c,hc⟩ := G.connected_code_crossings η x y N hN (25*t) hfar hxy + have he : G.codeEvent N t (coarseSite N x.val) c.val η=1 := by + unfold codeEvent + simp only [hc,Finset.prod_const_one] + rw [← he] + exact Finset.single_le_sum (fun c _ => G.codeEvent_nonneg _ _ _ c.val η) (Finset.mem_univ c) + · exact Finset.sum_nonneg (fun c _ => G.codeEvent_nonneg _ _ _ c.val η) + +theorem connection_geometric_tail (β : ℝ) (hβ : 0≤β) : + ∃ N : ℕ,0 (hb e).1) x y _ hN t hfar) + calc + _≤∑ _c : SimpleCoarseCode (coarseSite (2^k:ℕ) x.val) (25*t),ε^t := by + apply Finset.sum_le_sum + intro c _ + have hh := hs G b hb {i : Fin (25*t+1) // siteColor (codePosition (coarseSite (2^k:ℕ) x.val) c.val i)= + codeColor t (coarseSite (2^k:ℕ) x.val) c.val} + (fun i => coarseCenter (2^k:ℕ) (codePosition (coarseSite (2^k:ℕ) x.val) c.val i.val)) + (sameColor_separated _ hN _ c.property _) + apply le_trans hh + exact pow_le_pow_of_le_one (le_of_lt hε) hε1 (codeColor_card t _ c.val) + _=(Fintype.card (SimpleCoarseCode (coarseSite (2^k:ℕ) x.val) (25*t)):ℝ)*ε^t := by simp + _≤(9:ℝ)^(25*t)*ε^t := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact_mod_cast card_simpleCoarseCode (coarseSite (2^k:ℕ) x.val) (25*t) + _=(1/2:ℝ)^t := by + rw [pow_mul,← mul_pow] + congr 1 + dsimp [ε] + field_simp + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ComplexWard.lean b/lean/OAI/Probability/ClassicalON/ComplexWard.lean new file mode 100644 index 0000000000000000000000000000000000000000..8090105fe694d80aecefff53f2f7e1f7a18fea25 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ComplexWard.lean @@ -0,0 +1,510 @@ +import OAI.Probability.ClassicalON.MixedWard + +namespace OAI + +universe uA uE uK uL uV uΩ + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace + +noncomputable section + +structure ComplexFourForm (A : Type uA) [AddCommMonoid A] [Module ℂ A] where + toFun : A → A → A → A → ℂ + add_first : ∀ u u' v w z, toFun (u+u') v w z = toFun u v w z + toFun u' v w z + add_second : ∀ u v v' w z, toFun u (v+v') w z = toFun u v w z + toFun u v' w z + add_third : ∀ u v w w' z, toFun u v (w+w') z = toFun u v w z + toFun u v w' z + add_fourth : ∀ u v w z z', toFun u v w (z+z') = toFun u v w z + toFun u v w z' + smul_first : ∀ r u v w z, toFun (r • u) v w z = r * toFun u v w z + smul_second : ∀ r u v w z, toFun u (r • v) w z = r * toFun u v w z + smul_third : ∀ r u v w z, toFun u v (r • w) z = r * toFun u v w z + smul_fourth : ∀ r u v w z, toFun u v w (r • z) = r * toFun u v w z + +instance {A : Type uA} [AddCommMonoid A] [Module ℂ A] : + CoeFun (ComplexFourForm A) (fun _ => A → A → A → A → ℂ) := ⟨ComplexFourForm.toFun⟩ + +theorem complex_linear_zero_of_real {V : Type uV} (P : V → Prop) + (L : (V → ℂ) → ℂ) + (ha : ∀ u v, L (u+v) = L u + L v) + (hs : ∀ r u, L (r • u) = r * L u) + (hr : ∀ u : V → ℝ, (∀ x, P x → u x = 0) → L (fun x => (u x : ℂ)) = 0) + (u : V → ℂ) (hu : ∀ x, P x → u x = 0) : L u = 0 := by + have hre : ∀ x, P x → (u x).re = 0 := by + intro x hx + rw [hu x hx, Complex.zero_re] + have him : ∀ x, P x → (u x).im = 0 := by + intro x hx + rw [hu x hx, Complex.zero_im] + have hd : u = (fun x => ((u x).re : ℂ)) + Complex.I • (fun x => ((u x).im : ℂ)) := by + ext x + simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul] + rw [mul_comm] + exact (Complex.re_add_im (u x)).symm + rw [hd, ha, hs, hr _ hre, hr _ him] + simp only [mul_zero, add_zero] + +theorem ComplexFourForm.zero_of_real {V : Type uV} (F : ComplexFourForm (V → ℂ)) + (P : V → Prop) + (hr : ∀ u v w z : V → ℝ, + (∀ x, P x → u x = 0) → (∀ x, P x → v x = 0) → + (∀ x, P x → w x = 0) → (∀ x, P x → z x = 0) → + F (fun x => (u x : ℂ)) (fun x => (v x : ℂ)) + (fun x => (w x : ℂ)) (fun x => (z x : ℂ)) = 0) + (u v w z : V → ℂ) + (hu : ∀ x, P x → u x = 0) (hv : ∀ x, P x → v x = 0) + (hw : ∀ x, P x → w x = 0) (hz : ∀ x, P x → z x = 0) : + F u v w z = 0 := by + apply complex_linear_zero_of_real P (fun u => F u v w z) + (fun u u' => F.add_first u u' v w z) (fun r u => F.smul_first r u v w z) ?_ u hu + intro a ha + apply complex_linear_zero_of_real P (fun v => F (fun x => (a x : ℂ)) v w z) + (fun v v' => F.add_second (fun x => (a x : ℂ)) v v' w z) + (fun r v => F.smul_second r (fun x => (a x : ℂ)) v w z) ?_ v hv + intro b hb + apply complex_linear_zero_of_real P + (fun w => F (fun x => (a x : ℂ)) (fun x => (b x : ℂ)) w z) + (fun w w' => F.add_third (fun x => (a x : ℂ)) (fun x => (b x : ℂ)) w w' z) + (fun r w => F.smul_third r (fun x => (a x : ℂ)) (fun x => (b x : ℂ)) w z) ?_ w hw + intro c hc + apply complex_linear_zero_of_real P + (fun z => F (fun x => (a x : ℂ)) (fun x => (b x : ℂ)) (fun x => (c x : ℂ)) z) + (fun z z' => F.add_fourth (fun x => (a x : ℂ)) (fun x => (b x : ℂ)) (fun x => (c x : ℂ)) z z') + (fun r z => F.smul_fourth r (fun x => (a x : ℂ)) (fun x => (b x : ℂ)) (fun x => (c x : ℂ)) z) + ?_ z hz + intro d hd + exact hr a b c d ha hb hc hd + +namespace MixedAlgebra +variable {E : Type uE} {K : Type uK} {L : Type uL} [Fintype E] [CommRing K] [CommRing L] + +def Coeffs.map (φ : K →+* L) (J : Coeffs E K) : Coeffs E L where + a := φ ∘ J.a + b := φ ∘ J.b + aa := φ ∘ J.aa + ab := φ ∘ J.ab + bb := φ ∘ J.bb + aab := φ ∘ J.aab + abb := φ ∘ J.abb + aabb := φ ∘ J.aabb + +theorem weighted_map (φ : K →+* L) (J u : E → K) : + weighted (φ ∘ J) (φ ∘ u) = φ (weighted J u) := by + simp [weighted] + +theorem four_map (φ : K →+* L) (J : Coeffs E K) (u v w z : E → K) : + four (J.map φ) (φ ∘ u) (φ ∘ v) (φ ∘ w) (φ ∘ z) = φ (four J u v w z) := by + simp only [four, Coeffs.map, weighted, Function.comp_apply, Pi.mul_apply, + map_add, map_mul, map_sum] + +theorem weighted_smul (J u : E → K) (r : K) : + weighted J (r • u) = r * weighted J u := by + exact weighted_const_mul J u r + +theorem four_smul_first (J : Coeffs E K) (u v w z : E → K) (r : K) : + four J (r • u) v w z = r * four J u v w z := by + simp only [four, smul_mul_assoc, weighted_smul] + ring + +theorem four_smul_second (J : Coeffs E K) (u v w z : E → K) (r : K) : + four J u (r • v) w z = r * four J u v w z := by + simp only [four, mul_smul_comm, smul_mul_assoc, weighted_smul] + ring + +theorem four_smul_third (J : Coeffs E K) (u v w z : E → K) (r : K) : + four J u v (r • w) z = r * four J u v w z := by + rw [four_swap_first_third, four_smul_first, four_swap_first_third J w] + +theorem four_smul_fourth (J : Coeffs E K) (u v w z : E → K) (r : K) : + four J u v w (r • z) = r * four J u v w z := by + rw [four_swap_second_fourth, four_smul_second, four_swap_second_fourth J u z] + +end MixedAlgebra + +namespace ClassicalON.SpinSystem +variable {n : ℕ} {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem integrable_complex_integrand [NeZero n] (S : SpinSystem n V E) + {f : (V → Spin n) → ℂ} (hf : Continuous f) : + Integrable (fun σ => f σ * (Real.exp (S.energy (fun _ => 1) σ) : ℂ)) S.reference := + (hf.mul (Complex.continuous_ofReal.comp (S.continuous_energy _).rexp)).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +def averageComplexLinear [NeZero n] (S : SpinSystem n V E) : C((V → Spin n), ℂ) →ₗ[ℂ] ℂ where + toFun f := (∫ σ, f σ * (Real.exp (S.energy (fun _ => 1) σ) : ℂ) ∂S.reference) / + (S.Z (fun _ => 1) : ℂ) + map_add' f g := by + simp only [ContinuousMap.add_apply, add_mul] + rw [integral_add (S.integrable_complex_integrand f.continuous) + (S.integrable_complex_integrand g.continuous), add_div] + map_smul' c f := by + simp only [ContinuousMap.smul_apply, smul_eq_mul, mul_assoc, + integral_const_mul, RingHom.id_apply, mul_div_assoc] + +def ofRealObservable {Ω : Type uΩ} [TopologicalSpace Ω] (f : C(Ω, ℝ)) : C(Ω, ℂ) := + ⟨fun σ => (f σ : ℂ), Complex.continuous_ofReal.comp f.continuous⟩ + +@[simp] theorem averageComplex_ofReal [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℝ)) : + S.averageComplexLinear (ofRealObservable f) = (S.averageLinear f : ℂ) := by + change (∫ σ, (f σ : ℂ) * (Real.exp (S.energy (fun _ => 1) σ) : ℂ) ∂S.reference) / + (S.Z (fun _ => 1) : ℂ) = _ + simp only [← Complex.ofReal_mul, integral_complex_ofReal, ← Complex.ofReal_div] + rfl + +def complexCoefficients (S : SpinSystem 3 V E) (σ : V → Spin 3) : MixedAlgebra.Coeffs E ℂ := + (S.mixedCoefficients σ).map Complex.ofRealHom + +omit [Fintype V] in +@[fun_prop] theorem continuous_complexWeighted (S : SpinSystem n V E) + (M : SpinOperator n) (u : E → ℂ) : + Continuous (fun σ => MixedAlgebra.weighted + (fun e => (S.localCoefficient M σ e : ℂ)) u) := by + unfold MixedAlgebra.weighted localCoefficient + fun_prop + +omit [Fintype V] in +@[fun_prop] theorem continuous_complexMixedPolynomial (S : SpinSystem 3 V E) + (u v w z : E → ℂ) : + Continuous (fun σ => MixedAlgebra.four (S.complexCoefficients σ) u v w z) := by + simp only [MixedAlgebra.four, complexCoefficients, MixedAlgebra.Coeffs.map, + mixedCoefficients, Function.comp_def, Complex.ofRealHom_eq_coe] + fun_prop + +def complexMixedObservable (S : SpinSystem 3 V E) (u v w z : E → ℂ) : C((V → Spin 3), ℂ) := + ⟨_, S.continuous_complexMixedPolynomial u v w z⟩ + +def complexMixedResponse (S : SpinSystem 3 V E) (u v w z : E → ℂ) : ℂ := + S.averageComplexLinear (S.complexMixedObservable u v w z) + +theorem complexMixedResponse_ofReal (S : SpinSystem 3 V E) (u v w z : E → ℝ) : + S.complexMixedResponse (fun e => (u e : ℂ)) (fun e => (v e : ℂ)) + (fun e => (w e : ℂ)) (fun e => (z e : ℂ)) = (S.mixedResponse u v w z : ℂ) := by + have hc : S.complexMixedObservable (fun e => (u e : ℂ)) (fun e => (v e : ℂ)) + (fun e => (w e : ℂ)) (fun e => (z e : ℂ)) = ofRealObservable (S.mixedObservable u v w z) := by + ext σ + exact MixedAlgebra.four_map Complex.ofRealHom (S.mixedCoefficients σ) u v w z + unfold complexMixedResponse + rw [hc, S.averageComplex_ofReal] + rfl + +theorem complexMixedResponse_add_first (S : SpinSystem 3 V E) (u v w z u' : E → ℂ) : + S.complexMixedResponse (u+u') v w z = S.complexMixedResponse u v w z + S.complexMixedResponse u' v w z := by + have hp : S.complexMixedObservable (u+u') v w z = S.complexMixedObservable u v w z + + S.complexMixedObservable u' v w z := by + ext σ + exact MixedAlgebra.four_add_first (S.complexCoefficients σ) u u' v w z + unfold complexMixedResponse + rw [hp, map_add] + +theorem complexMixedResponse_smul_first (S : SpinSystem 3 V E) (u v w z : E → ℂ) (r : ℂ) : + S.complexMixedResponse (r • u) v w z = r * S.complexMixedResponse u v w z := by + have hp : S.complexMixedObservable (r • u) v w z = r • S.complexMixedObservable u v w z := by + ext σ + exact MixedAlgebra.four_smul_first (S.complexCoefficients σ) u v w z r + unfold complexMixedResponse + rw [hp, map_smul, smul_eq_mul] + +theorem complexMixedResponse_add_second (S : SpinSystem 3 V E) (u v w z v' : E → ℂ) : + S.complexMixedResponse u (v+v') w z = S.complexMixedResponse u v w z + S.complexMixedResponse u v' w z := by + have hp : S.complexMixedObservable u (v+v') w z = S.complexMixedObservable u v w z + + S.complexMixedObservable u v' w z := by + ext σ + exact MixedAlgebra.four_add_second (S.complexCoefficients σ) u v v' w z + unfold complexMixedResponse + rw [hp, map_add] + +theorem complexMixedResponse_smul_second (S : SpinSystem 3 V E) (u v w z : E → ℂ) (r : ℂ) : + S.complexMixedResponse u (r • v) w z = r * S.complexMixedResponse u v w z := by + have hp : S.complexMixedObservable u (r • v) w z = r • S.complexMixedObservable u v w z := by + ext σ + exact MixedAlgebra.four_smul_second (S.complexCoefficients σ) u v w z r + unfold complexMixedResponse + rw [hp, map_smul, smul_eq_mul] + +theorem complexMixedResponse_add_third (S : SpinSystem 3 V E) (u v w z w' : E → ℂ) : + S.complexMixedResponse u v (w+w') z = S.complexMixedResponse u v w z + S.complexMixedResponse u v w' z := by + have hp : S.complexMixedObservable u v (w+w') z = S.complexMixedObservable u v w z + + S.complexMixedObservable u v w' z := by + ext σ + exact MixedAlgebra.four_add_third (S.complexCoefficients σ) u v w w' z + unfold complexMixedResponse + rw [hp, map_add] + +theorem complexMixedResponse_smul_third (S : SpinSystem 3 V E) (u v w z : E → ℂ) (r : ℂ) : + S.complexMixedResponse u v (r • w) z = r * S.complexMixedResponse u v w z := by + have hp : S.complexMixedObservable u v (r • w) z = r • S.complexMixedObservable u v w z := by + ext σ + exact MixedAlgebra.four_smul_third (S.complexCoefficients σ) u v w z r + unfold complexMixedResponse + rw [hp, map_smul, smul_eq_mul] + +theorem complexMixedResponse_add_fourth (S : SpinSystem 3 V E) (u v w z z' : E → ℂ) : + S.complexMixedResponse u v w (z+z') = S.complexMixedResponse u v w z + S.complexMixedResponse u v w z' := by + have hp : S.complexMixedObservable u v w (z+z') = S.complexMixedObservable u v w z + + S.complexMixedObservable u v w z' := by + ext σ + exact MixedAlgebra.four_add_fourth (S.complexCoefficients σ) u v w z z' + unfold complexMixedResponse + rw [hp, map_add] + +theorem complexMixedResponse_smul_fourth (S : SpinSystem 3 V E) (u v w z : E → ℂ) (r : ℂ) : + S.complexMixedResponse u v w (r • z) = r * S.complexMixedResponse u v w z := by + have hp : S.complexMixedObservable u v w (r • z) = r • S.complexMixedObservable u v w z := by + ext σ + exact MixedAlgebra.four_smul_fourth (S.complexCoefficients σ) u v w z r + unfold complexMixedResponse + rw [hp, map_smul, smul_eq_mul] + +def complexEnergy (S : SpinSystem n V E) (M : SpinOperator n) (u : E → ℂ) + (σ : V → Spin n) : ℂ := MixedAlgebra.weighted + (fun e => (S.localCoefficient M σ e : ℂ)) u + +omit [Fintype V] in +@[fun_prop] theorem continuous_complexEnergy (S : SpinSystem n V E) + (M : SpinOperator n) (u : E → ℂ) : Continuous (S.complexEnergy M u) := + S.continuous_complexWeighted M u + +omit [Fintype V] in +theorem complexEnergy_ofReal (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℝ) (σ : V → Spin n) : + S.complexEnergy M (fun e => (u e : ℂ)) σ = + (S.energy (fun e => u e • M) σ : ℂ) := by + rw [S.energy_weighted] + exact MixedAlgebra.weighted_map Complex.ofRealHom (S.localCoefficient M σ) u + +omit [Fintype V] in +@[simp] theorem complexEnergy_add (S : SpinSystem n V E) (M : SpinOperator n) + (u v : E → ℂ) (σ : V → Spin n) : + S.complexEnergy M (u+v) σ = S.complexEnergy M u σ + S.complexEnergy M v σ := + MixedAlgebra.weighted_add _ u v + +omit [Fintype V] in +@[simp] theorem complexEnergy_smul (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℂ) (r : ℂ) (σ : V → Spin n) : + S.complexEnergy M (r • u) σ = r * S.complexEnergy M u σ := + MixedAlgebra.weighted_smul _ u r + +omit [Fintype V] in +@[fun_prop] theorem continuous_complexSecondPolynomial (S : SpinSystem 3 V E) + (u v : E → ℂ) : Continuous (fun σ => S.complexEnergy (axisC^2) (u*v) σ + + S.complexEnergy axisC u σ * S.complexEnergy axisC v σ) := by + fun_prop + +def complexSecondObservable (S : SpinSystem 3 V E) (u v : E → ℂ) : C((V → Spin 3), ℂ) := + ⟨_, S.continuous_complexSecondPolynomial u v⟩ + +def complexSecondResponse (S : SpinSystem 3 V E) (u v : E → ℂ) : ℂ := + S.averageComplexLinear (S.complexSecondObservable u v) + +theorem complexSecondResponse_ofReal (S : SpinSystem 3 V E) (u v : E → ℝ) : + S.complexSecondResponse (fun e => (u e : ℂ)) (fun e => (v e : ℂ)) = + (S.secondAxisResponse u v : ℂ) := by + have hp : S.complexSecondObservable (fun e => (u e : ℂ)) (fun e => (v e : ℂ)) = + ofRealObservable (S.secondObservable u v) := by + ext σ + change S.complexEnergy (axisC^2) ((fun e => (u e : ℂ)) * (fun e => (v e : ℂ))) σ + + S.complexEnergy axisC (fun e => (u e : ℂ)) σ * + S.complexEnergy axisC (fun e => (v e : ℂ)) σ = _ + rw [show ((fun e => (u e : ℂ)) * (fun e => (v e : ℂ))) = + (fun e => ((u e*v e : ℝ) : ℂ)) from by ext; simp] + simp only [complexEnergy_ofReal, ← Complex.ofReal_add, ← Complex.ofReal_mul] + rfl + unfold complexSecondResponse + rw [hp, S.averageComplex_ofReal, S.secondObservable_average] + +theorem complexSecondResponse_add_left (S : SpinSystem 3 V E) (u v w : E → ℂ) : + S.complexSecondResponse (u+v) w = S.complexSecondResponse u w + S.complexSecondResponse v w := by + have hp : S.complexSecondObservable (u+v) w = + S.complexSecondObservable u w + S.complexSecondObservable v w := by + ext σ + change S.complexEnergy (axisC^2) ((u+v)*w) σ + + S.complexEnergy axisC (u+v) σ * S.complexEnergy axisC w σ = + (S.complexEnergy (axisC^2) (u*w) σ + + S.complexEnergy axisC u σ * S.complexEnergy axisC w σ) + + (S.complexEnergy (axisC^2) (v*w) σ + + S.complexEnergy axisC v σ * S.complexEnergy axisC w σ) + rw [add_mul, complexEnergy_add, complexEnergy_add] + ring + unfold complexSecondResponse + rw [hp, map_add] + +theorem complexSecondResponse_symm (S : SpinSystem 3 V E) (u v : E → ℂ) : + S.complexSecondResponse u v = S.complexSecondResponse v u := by + have hp : S.complexSecondObservable u v = S.complexSecondObservable v u := by + ext σ + change S.complexEnergy (axisC^2) (u*v) σ + + S.complexEnergy axisC u σ * S.complexEnergy axisC v σ = + S.complexEnergy (axisC^2) (v*u) σ + + S.complexEnergy axisC v σ * S.complexEnergy axisC u σ + rw [mul_comm u v, mul_comm (S.complexEnergy axisC u σ)] + exact congrArg S.averageComplexLinear hp + +theorem complexSecondResponse_add_right (S : SpinSystem 3 V E) (u v w : E → ℂ) : + S.complexSecondResponse u (v+w) = S.complexSecondResponse u v + S.complexSecondResponse u w := by + rw [S.complexSecondResponse_symm, S.complexSecondResponse_add_left, + S.complexSecondResponse_symm v, S.complexSecondResponse_symm w] + +theorem complexSecondResponse_smul_left (S : SpinSystem 3 V E) (u v : E → ℂ) (r : ℂ) : + S.complexSecondResponse (r • u) v = r * S.complexSecondResponse u v := by + have hp : S.complexSecondObservable (r • u) v = r • S.complexSecondObservable u v := by + ext σ + change S.complexEnergy (axisC^2) ((r • u)*v) σ + + S.complexEnergy axisC (r • u) σ * S.complexEnergy axisC v σ = + r * (S.complexEnergy (axisC^2) (u*v) σ + + S.complexEnergy axisC u σ * S.complexEnergy axisC v σ) + rw [smul_mul_assoc, complexEnergy_smul, complexEnergy_smul] + ring + unfold complexSecondResponse + rw [hp, map_smul, smul_eq_mul] + +theorem complexSecondResponse_smul_right (S : SpinSystem 3 V E) (u v : E → ℂ) (r : ℂ) : + S.complexSecondResponse u (r • v) = r * S.complexSecondResponse u v := by + rw [S.complexSecondResponse_symm, S.complexSecondResponse_smul_left, + S.complexSecondResponse_symm v] + +omit [Fintype V] [Fintype E] in +def complexCross (S : SpinSystem 3 V E) (f g : V → ℂ) : E → ℂ := + fun e => f (S.left e)*g (S.right e) - g (S.left e)*f (S.right e) + +omit [Fintype V] [Fintype E] in +theorem complexCross_ofReal (S : SpinSystem 3 V E) (f g : V → ℝ) : + S.complexCross (fun x => (f x : ℂ)) (fun x => (g x : ℂ)) = + fun e => (S.crossForm f g e : ℂ) := by + ext e + simp [complexCross, crossForm] + +omit [Fintype V] [Fintype E] in +theorem differential_ofReal (S : SpinSystem n V E) (f : V → ℝ) : + S.differential (fun x => (f x : ℂ)) = fun e => (S.differential (K := ℝ) f e : ℂ) := by + ext e + simp [differential] + +omit [Fintype V] [Fintype E] in +theorem complexCross_add_left (S : SpinSystem 3 V E) (f g h : V → ℂ) : + S.complexCross (f+h) g = S.complexCross f g + S.complexCross h g := by + ext e + simp only [complexCross, Pi.add_apply] + ring + +omit [Fintype V] [Fintype E] in +theorem complexCross_smul_left (S : SpinSystem 3 V E) (f g : V → ℂ) (r : ℂ) : + S.complexCross (r • f) g = r • S.complexCross f g := by + ext e + simp only [complexCross, Pi.smul_apply, smul_eq_mul] + ring + +omit [Fintype V] [Fintype E] in +theorem complexCross_add_right (S : SpinSystem 3 V E) (f g h : V → ℂ) : + S.complexCross f (g+h) = S.complexCross f g + S.complexCross f h := by + ext e + simp only [complexCross, Pi.add_apply] + ring + +omit [Fintype V] [Fintype E] in +theorem complexCross_smul_right (S : SpinSystem 3 V E) (f g : V → ℂ) (r : ℂ) : + S.complexCross f (r • g) = r • S.complexCross f g := by + ext e + simp only [complexCross, Pi.smul_apply, smul_eq_mul] + ring + +omit [Fintype V] [Fintype E] in +theorem complexDifferential_add (S : SpinSystem n V E) (f g : V → ℂ) : + S.differential (f+g) = S.differential f + S.differential g := by + ext e + simp only [differential, Pi.add_apply] + ring + +omit [Fintype V] [Fintype E] in +theorem complexDifferential_smul (S : SpinSystem n V E) (f : V → ℂ) (r : ℂ) : + S.differential (r • f) = r • S.differential f := by + ext e + simp only [differential, Pi.smul_apply, smul_eq_mul] + ring + +def complexWardDefect (S : SpinSystem 3 V E) : ComplexFourForm (V → ℂ) where + toFun f g h k := 4 * S.complexMixedResponse (S.differential f) (S.differential g) + (S.differential h) (S.differential k) - + (S.complexSecondResponse (S.complexCross f g) (S.complexCross h k) + + S.complexSecondResponse (S.complexCross f k) (S.complexCross h g)) + add_first := by + intro f f' g h k + simp only [complexDifferential_add, complexMixedResponse_add_first, + complexCross_add_left, complexSecondResponse_add_left] + ring + add_second := by + intro f g g' h k + simp only [complexDifferential_add, complexMixedResponse_add_second, + complexCross_add_right, complexSecondResponse_add_left, complexSecondResponse_add_right] + ring + add_third := by + intro f g h h' k + simp only [complexDifferential_add, complexMixedResponse_add_third, + complexCross_add_left, complexSecondResponse_add_right] + ring + add_fourth := by + intro f g h k k' + simp only [complexDifferential_add, complexMixedResponse_add_fourth, + complexCross_add_right, complexSecondResponse_add_left, complexSecondResponse_add_right] + ring + smul_first := by + intro r f g h k + simp only [complexDifferential_smul, complexMixedResponse_smul_first, + complexCross_smul_left, complexSecondResponse_smul_left] + ring + smul_second := by + intro r f g h k + simp only [complexDifferential_smul, complexMixedResponse_smul_second, + complexCross_smul_right, complexSecondResponse_smul_left, complexSecondResponse_smul_right] + ring + smul_third := by + intro r f g h k + simp only [complexDifferential_smul, complexMixedResponse_smul_third, + complexCross_smul_left, complexSecondResponse_smul_right] + ring + smul_fourth := by + intro r f g h k + simp only [complexDifferential_smul, complexMixedResponse_smul_fourth, + complexCross_smul_right, complexSecondResponse_smul_left, complexSecondResponse_smul_right] + ring + +theorem complexWardDefect_real (S : SpinSystem 3 V E) (f g h k : V → ℝ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) + (hh : ∀ x s, S.pin x = some s → h x = 0) + (hk : ∀ x s, S.pin x = some s → k x = 0) : + S.complexWardDefect (fun x => (f x : ℂ)) (fun x => (g x : ℂ)) + (fun x => (h x : ℂ)) (fun x => (k x : ℂ)) = 0 := by + change _ - _ = 0 + apply sub_eq_zero.mpr + simp only [differential_ofReal, complexCross_ofReal, complexMixedResponse_ofReal, + complexSecondResponse_ofReal] + exact_mod_cast S.mixedResponse_ward f g h k hf hg hh hk + +theorem complexMixedResponse_ward (S : SpinSystem 3 V E) (f g h k : V → ℂ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) + (hh : ∀ x s, S.pin x = some s → h x = 0) + (hk : ∀ x s, S.pin x = some s → k x = 0) : + 4 * S.complexMixedResponse (S.differential f) (S.differential g) + (S.differential h) (S.differential k) = + S.complexSecondResponse (S.complexCross f g) (S.complexCross h k) + + S.complexSecondResponse (S.complexCross f k) (S.complexCross h g) := by + apply sub_eq_zero.mp + change S.complexWardDefect f g h k = 0 + refine S.complexWardDefect.zero_of_real (fun x => ∃ s, S.pin x = some s) ?_ f g h k ?_ ?_ ?_ ?_ + · intro a b c d ha hb hc hd + exact S.complexWardDefect_real a b c d + (fun x s hs => ha x ⟨s, hs⟩) (fun x s hs => hb x ⟨s, hs⟩) + (fun x s hs => hc x ⟨s, hs⟩) (fun x s hs => hd x ⟨s, hs⟩) + · rintro x ⟨s, hs⟩; exact hf x s hs + · rintro x ⟨s, hs⟩; exact hg x s hs + · rintro x ⟨s, hs⟩; exact hh x s hs + · rintro x ⟨s, hs⟩; exact hk x s hs + +end ClassicalON.SpinSystem + +end +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CylindricalConfiguration.lean b/lean/OAI/Probability/ClassicalON/CylindricalConfiguration.lean new file mode 100644 index 0000000000000000000000000000000000000000..903ba2d887a0703b73f8def02144f84b7a86cfdd --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CylindricalConfiguration.lean @@ -0,0 +1,108 @@ +import OAI.Probability.ClassicalON.CylindricalLaw + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def freeSpinReference (n : ℕ) : Measure (V → Spin n) := Measure.pi (fun _ => sphereProbability n) +instance freeSpinReference_isProbability (n : ℕ) [NeZero n] : + IsProbabilityMeasure (freeSpinReference (V := V) n) := by unfold freeSpinReference; infer_instance + +def freeSpinEnergy (n : ℕ) (left right : E → V) (b : E → ℝ) (s : V → Spin n) : ℝ := + ∑ e,b e*⟪(s (left e)).val,(s (right e)).val⟫_ℝ + +omit [Fintype V] in +theorem continuous_freeSpinEnergy (n : ℕ) (left right : E → V) (b : E → ℝ) : + Continuous (freeSpinEnergy n left right b) := by unfold freeSpinEnergy; fun_prop + +def freeSpinMean (n : ℕ) (left right : E → V) (b : E → ℝ) (f : (V → Spin n) → ℝ) : ℝ := + weightedMean (freeSpinReference n) (fun s => Real.exp (freeSpinEnergy n left right b s)) f + +def cylindricalConfiguration (r : V → Amplitude) (τ : V → Bool) (θ : V → PlanarAngle) : V → Spin 3 := + fun v => cylindricalSpin (r v) (τ v) (θ v) + +omit [Fintype V] [Fintype E] in +theorem continuous_cylindricalConfiguration : + Continuous (fun p : (V → Amplitude)×(V → Bool)×(V → PlanarAngle) => + cylindricalConfiguration p.1 p.2.1 p.2.2) := by + apply continuous_pi + intro v + exact continuous_cylindricalSpin.comp + (f := fun p : (V → Amplitude)×(V → Bool)×(V → PlanarAngle) => (p.1 v,p.2.1 v,p.2.2 v)) + (((continuous_apply v).comp continuous_fst).prodMk + (((continuous_apply v).comp (continuous_fst.comp continuous_snd)).prodMk + ((continuous_apply v).comp (continuous_snd.comp continuous_snd)))) + +omit [Fintype E] in +theorem cylindricalConfiguration_preserves : MeasurePreserving + (fun p : (V → Amplitude)×(V → Bool)×(V → PlanarAngle) => cylindricalConfiguration p.1 p.2.1 p.2.2) + ((Measure.pi fun _ : V => sphericalAmplitudeLaw).prod ((isingReference (V := V)).prod planarReference)) + (freeSpinReference 3) := by + let A := MeasurableEquiv.arrowProdEquivProdArrow Amplitude (Bool×PlanarAngle) V + let B := MeasurableEquiv.arrowProdEquivProdArrow Bool PlanarAngle V + have hA := (measurePreserving_arrowProdEquivProdArrow Amplitude (Bool×PlanarAngle) V + (fun _ => sphericalAmplitudeLaw) (fun _ => cylinderLaw)).symm A + have hB := (measurePreserving_arrowProdEquivProdArrow Bool PlanarAngle V + (fun _ => signLaw) (fun _ => angleLaw)).symm B + have h1 := (MeasurePreserving.id (Measure.pi fun _ : V => sphericalAmplitudeLaw)).prod hB + have h2 := hA.comp h1 + have h3 := measurePreserving_pi (fun _ : V => sphericalAmplitudeLaw.prod cylinderLaw) + (fun _ => sphereProbability 3) (fun _ => cylindricalSpin_preserves) + exact h3.comp h2 + +omit [Fintype E] in +theorem integral_freeSpinReference_cylinder (f : (V → Spin 3) → ℝ) (hf : Continuous f) : + (∫ s,f s ∂freeSpinReference 3)= + ∫ r,∫ τ,∫ θ,f (cylindricalConfiguration r τ θ) ∂planarReference ∂isingReference + ∂Measure.pi (fun _ : V => sphericalAmplitudeLaw) := by + let : BorelSpace ((V → Amplitude) × (V → Bool) × (V → PlanarAngle)) := Prod.borelSpace + have hc : Continuous (fun p : (V → Amplitude)×(V → Bool)×(V → PlanarAngle) => + f (cylindricalConfiguration p.1 p.2.1 p.2.2)) := hf.comp continuous_cylindricalConfiguration + rw [← cylindricalConfiguration_preserves.map_eq, + integral_map continuous_cylindricalConfiguration.measurable.aemeasurable hf.aestronglyMeasurable, + integral_prod _ (compact_integrable hc)] + apply integral_congr_ae + filter_upwards with r + have hr : Continuous (fun p : (V → Bool)×(V → PlanarAngle) => f (cylindricalConfiguration r p.1 p.2)) := + hc.comp (continuous_const.prodMk continuous_id) + exact integral_prod _ (compact_integrable hr) + +omit [Fintype V] [Fintype E] in +theorem cylindricalSpin_inner (r q : Amplitude) (τ υ : Bool) (θ φ : PlanarAngle) : + ⟪(cylindricalSpin r τ θ).val,(cylindricalSpin q υ φ).val⟫_ℝ= + (r:ℝ)*(q:ℝ)*(signValue τ*signValue υ)+ + transverseAmplitude r*transverseAmplitude q*planarCos (θ-φ) := by + rw [EuclideanSpace.inner_eq_star_dotProduct] + simp only [dotProduct,Fin.sum_univ_succ,Fin.isValue,cylindricalSpin, + WithLp.ofLp_toLp,Matrix.cons_val_zero,Matrix.cons_val_succ,star_trivial,Finset.univ_eq_empty, + Finset.sum_empty,add_zero] + simp only [planarCos,planarSin,sub_eq_add_neg,planarCharacter_add,planarCharacter_neg, + Complex.mul_re,Complex.conj_re,Complex.conj_im] + ring + +omit [Fintype V] in +theorem cylindricalConfiguration_energy (left right : E → V) (b : E → ℝ) + (r : V → Amplitude) (τ : V → Bool) (θ : V → PlanarAngle) : + freeSpinEnergy 3 left right b (cylindricalConfiguration r τ θ)= + edgeHamiltonian (isingEnergy left right) (amplitudeCoupling left right b (fun v => (r v:ℝ))) τ+ + edgeHamiltonian (planarEnergy left right) (amplitudeCoupling left right b (fun v => transverseAmplitude (r v))) θ := by + unfold freeSpinEnergy edgeHamiltonian cylindricalConfiguration + simp_rw [cylindricalSpin_inner] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e _ + unfold amplitudeCoupling isingEnergy planarEnergy + ring + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CylindricalFiber.lean b/lean/OAI/Probability/ClassicalON/CylindricalFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..73d01fd15d422230b4f133ca8db638cceff2f421 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CylindricalFiber.lean @@ -0,0 +1,110 @@ +import OAI.Probability.ClassicalON.CylindricalGeometry + +namespace OAI + +noncomputable section +open MeasureTheory +namespace ClassicalON + +def firstAmplitude (s : Spin 3) : Amplitude := ⟨|s.val 0|,abs_nonneg _,by + simpa only [Real.norm_eq_abs,spin_norm] using PiLp.norm_apply_le s.val 0⟩ + +theorem continuous_firstAmplitude : Continuous firstAmplitude := by + apply Continuous.subtype_mk + exact ((PiLp.continuous_apply 2 _ 0).comp continuous_subtype_val).abs + +@[simp] theorem firstAmplitude_cylindricalSpin (r : Amplitude) (τ : Bool) (θ : PlanarAngle) : + firstAmplitude (cylindricalSpin r τ θ)=r := by + apply Subtype.ext + change |(r:ℝ)*signValue τ|=(r:ℝ) + cases τ <;> simp [signValue,abs_of_nonneg r.property.1] + +theorem planarAngle_exists (a b : ℝ) (hab : a^2+b^2=1) : + ∃ θ : PlanarAngle,planarCos θ=a ∧ planarSin θ=b := by + let z : Circle := ⟨⟨a,b⟩,by + change (⟨a,b⟩ : ℂ) ∈ Metric.sphere 0 1 + rw [mem_sphere_zero_iff_norm] + apply (sq_eq_sq₀ (norm_nonneg _) (by norm_num : (0:ℝ)≤1)).mp + rw [← Complex.normSq_eq_norm_sq] + simpa [Complex.normSq_apply,pow_two] using hab⟩ + obtain ⟨θ,hθ⟩ := (AddCircle.homeomorphCircle (T := (1:ℝ)) (by norm_num)).surjective z + rw [AddCircle.homeomorphCircle_apply] at hθ + exact ⟨θ,congrArg (fun z : Circle => (z:ℂ).re) hθ,congrArg (fun z : Circle => (z:ℂ).im) hθ⟩ + +theorem cylindricalSpin_surjective_fiber (s : Spin 3) : + ∃ τ θ,cylindricalSpin (firstAmplitude s) τ θ=s := by + let r := firstAmplitude s + let q := transverseAmplitude r + have hq : q^2=s.val 1^2+s.val 2^2 := by + have hh := normSq_three s.val + rw [spin_norm] at hh + have hr : (r:ℝ)^2=s.val 0^2 := sq_abs _ + dsimp only [q] + rw [transverseAmplitude_sq,hr] + nlinarith + obtain ⟨τ,hτ⟩ : ∃ τ,(r:ℝ)*signValue τ=s.val 0 := by + by_cases hs : 0 ≤ s.val 0 + · exact ⟨true,by simp [r,firstAmplitude,signValue,abs_of_nonneg hs]⟩ + · exact ⟨false,by simp [r,firstAmplitude,signValue,abs_of_neg (lt_of_not_ge hs)]⟩ + by_cases hzero : q=0 + · refine ⟨τ,0,Subtype.ext ?_⟩ + ext i + have h1 : s.val 1=0 := by nlinarith [sq_nonneg (s.val 2)] + have h2 : s.val 2=0 := by nlinarith [sq_nonneg (s.val 1)] + fin_cases i + · exact hτ + · change q*planarCos 0=s.val 1 + rw [hzero,h1,zero_mul] + · change q*planarSin 0=s.val 2 + rw [hzero,h2,zero_mul] + · have hab : (s.val 1/q)^2+(s.val 2/q)^2=1 := by + field_simp + nlinarith + obtain ⟨θ,hc,hs⟩ := planarAngle_exists _ _ hab + refine ⟨τ,θ,Subtype.ext ?_⟩ + ext i + fin_cases i + · exact hτ + · change q*planarCos θ=s.val 1 + rw [hc,mul_div_cancel₀ _ hzero] + · change q*planarSin θ=s.val 2 + rw [hs,mul_div_cancel₀ _ hzero] + +theorem cylinderRotation_cylindricalSpin (τ υ : Bool) (θ φ : PlanarAngle) (r : Amplitude) : + spinRotation (cylinderRotation τ θ) (cylindricalSpin r υ φ)= + cylindricalSpin r (τ==υ) (θ+φ) := by + apply Subtype.ext + ext i + fin_cases i + · change signValue τ*((r:ℝ)*signValue υ)=(r:ℝ)*signValue (τ==υ) + cases τ <;> cases υ <;> simp [signValue] + · change planarCos θ*(transverseAmplitude r*planarCos φ)- + planarSin θ*(transverseAmplitude r*planarSin φ)=transverseAmplitude r*planarCos (θ+φ) + rw [planarCos_add]; ring + · change planarSin θ*(transverseAmplitude r*planarCos φ)+ + planarCos θ*(transverseAmplitude r*planarSin φ)=transverseAmplitude r*planarSin (θ+φ) + rw [planarSin_add]; ring + +theorem continuous_cylinderSpinRotation : + Continuous (fun p : (Bool×PlanarAngle)×Spin 3 => + spinRotation (cylinderRotation p.1.1 p.1.2) p.2) := by + apply Continuous.subtype_mk + change Continuous (fun p : (Bool×PlanarAngle)×Spin 3 => cylinderLinear p.1.1 p.1.2 p.2.val) + unfold cylinderLinear + apply (PiLp.continuous_toLp 2 _).comp + apply continuous_pi + intro i + have hc : Continuous (fun p : (Bool×PlanarAngle)×Spin 3 => planarCos p.1.2) := continuous_planarCos.comp (continuous_snd.comp continuous_fst) + have hs : Continuous (fun p : (Bool×PlanarAngle)×Spin 3 => planarSin p.1.2) := continuous_planarSin.comp (continuous_snd.comp continuous_fst) + have ht : Continuous (fun p : (Bool×PlanarAngle)×Spin 3 => signValue p.1.1) := (show Continuous signValue from continuous_of_discreteTopology).comp (continuous_fst.comp continuous_fst) + have hv (j : Fin 3) : Continuous (fun p : (Bool×PlanarAngle)×Spin 3 => p.2.val j) := (PiLp.continuous_apply 2 _ j).comp (continuous_subtype_val.comp continuous_snd) + fin_cases i + · exact ht.mul (hv 0) + · exact (hc.mul (hv 1)).sub (hs.mul (hv 2)) + · exact (hs.mul (hv 1)).add (hc.mul (hv 2)) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CylindricalGeometry.lean b/lean/OAI/Probability/ClassicalON/CylindricalGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..e365d677d84d298c7f8437822cd4797de9c6897e --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CylindricalGeometry.lean @@ -0,0 +1,97 @@ +import OAI.Probability.ClassicalON.AmplitudeLaw + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace +namespace ClassicalON + +theorem planarCos_sq_add_sin_sq (θ : PlanarAngle) : planarCos θ^2+planarSin θ^2=1 := by + have h := Circle.normSq_coe (AddCircle.toCircle θ) + simpa [Complex.normSq_apply,planarCos,planarSin,planarCharacter,pow_two] using h + +theorem planarCos_add (θ φ : PlanarAngle) : + planarCos (θ+φ)=planarCos θ*planarCos φ-planarSin θ*planarSin φ := by + simp [planarCos,planarSin,planarCharacter_add,Complex.mul_re] + +theorem planarSin_add (θ φ : PlanarAngle) : + planarSin (θ+φ)=planarSin θ*planarCos φ+planarCos θ*planarSin φ := by + simp [planarCos,planarSin,planarCharacter_add,Complex.mul_im,add_comm] + +theorem signValue_sq (τ : Bool) : signValue τ^2=1 := by cases τ <;> norm_num [signValue] + +theorem transverseAmplitude_sq (r : Amplitude) : transverseAmplitude r^2=1-(r:ℝ)^2 := by + apply Real.sq_sqrt + have h0:=r.property.1 + have h1:=r.property.2 + nlinarith + +theorem normSq_three (v : EuclideanSpace ℝ (Fin 3)) : ‖v‖^2=v 0^2+v 1^2+v 2^2 := by + rw [EuclideanSpace.real_norm_sq_eq] + simp [Fin.sum_univ_succ,add_assoc] + +def cylindricalSpin (r : Amplitude) (τ : Bool) (θ : PlanarAngle) : Spin 3 := + ⟨WithLp.toLp 2 ![(r:ℝ)*signValue τ,transverseAmplitude r*planarCos θ, + transverseAmplitude r*planarSin θ],by + rw [mem_sphere_zero_iff_norm] + have h := planarCos_sq_add_sin_sq θ + have hq := transverseAmplitude_sq r + have ht := signValue_sq τ + apply (sq_eq_sq₀ (norm_nonneg _) (by norm_num : (0:ℝ)≤1)).mp + rw [normSq_three] + change ((r:ℝ)*signValue τ)^2+(transverseAmplitude r*planarCos θ)^2+ + (transverseAmplitude r*planarSin θ)^2=1^2 + calc + _ = (r:ℝ)^2*signValue τ^2+transverseAmplitude r^2*(planarCos θ^2+planarSin θ^2) := by ring + _ = 1^2 := by rw [ht,h,hq]; ring⟩ + +theorem continuous_cylindricalSpin : + Continuous (fun p : Amplitude×Bool×PlanarAngle => cylindricalSpin p.1 p.2.1 p.2.2) := by + apply Continuous.subtype_mk + apply (PiLp.continuous_toLp 2 _).comp + apply continuous_pi + intro i + fin_cases i + · change Continuous (fun p : Amplitude×Bool×PlanarAngle => (p.1:ℝ)*signValue p.2.1) + exact continuous_fst.subtype_val.mul ((show Continuous signValue from continuous_of_discreteTopology).comp (continuous_fst.comp continuous_snd)) + · exact (continuous_transverseAmplitude.comp continuous_fst).mul + (continuous_planarCos.comp (continuous_snd.comp continuous_snd)) + · exact (continuous_transverseAmplitude.comp continuous_fst).mul + (continuous_planarSin.comp (continuous_snd.comp continuous_snd)) + +def cylinderLinear (τ : Bool) (θ : PlanarAngle) : + EuclideanSpace ℝ (Fin 3) →ₗ[ℝ] EuclideanSpace ℝ (Fin 3) where + toFun v := WithLp.toLp 2 ![signValue τ*v 0, + planarCos θ*v 1-planarSin θ*v 2,planarSin θ*v 1+planarCos θ*v 2] + map_add' v w := by ext i; fin_cases i <;> simp <;> ring + map_smul' a v := by ext i; fin_cases i <;> simp <;> ring + +theorem cylinderLinear_norm (τ : Bool) (θ : PlanarAngle) (v : EuclideanSpace ℝ (Fin 3)) : + ‖cylinderLinear τ θ v‖=‖v‖ := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [normSq_three,normSq_three] + have h := planarCos_sq_add_sin_sq θ + have ht := signValue_sq τ + change (signValue τ*v 0)^2+(planarCos θ*v 1-planarSin θ*v 2)^2+ + (planarSin θ*v 1+planarCos θ*v 2)^2=_ + nlinarith [congrArg (fun a : ℝ => a*(v 1^2+v 2^2)) h, + congrArg (fun a : ℝ => a*v 0^2) ht] + +def cylinderRotation (τ : Bool) (θ : PlanarAngle) : + EuclideanSpace ℝ (Fin 3) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 3) := + LinearIsometryEquiv.ofSurjective + {cylinderLinear τ θ with norm_map' := cylinderLinear_norm τ θ} + (LinearMap.surjective_of_injective + (show Function.Injective (cylinderLinear τ θ) from + (show EuclideanSpace ℝ (Fin 3) →ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 3) from + {cylinderLinear τ θ with norm_map' := cylinderLinear_norm τ θ}).injective)) + +@[simp] theorem cylinderRotation_apply (τ : Bool) (θ : PlanarAngle) (v : EuclideanSpace ℝ (Fin 3)) : + cylinderRotation τ θ v=cylinderLinear τ θ v := rfl + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/CylindricalLaw.lean b/lean/OAI/Probability/ClassicalON/CylindricalLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..25e4ec815625c5b86c3c4a8d0386e692bf2fe597 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/CylindricalLaw.lean @@ -0,0 +1,95 @@ +import OAI.Probability.ClassicalON.CylindricalFiber + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped ENNReal +namespace ClassicalON + +def cylinderLaw : Measure (Bool×PlanarAngle) := signLaw.prod angleLaw +instance cylinderLaw_isProbability : IsProbabilityMeasure cylinderLaw := by + unfold cylinderLaw; infer_instance + +def sphericalAmplitudeLaw : Measure Amplitude := (sphereProbability 3).map firstAmplitude +instance sphericalAmplitudeLaw_isProbability : IsProbabilityMeasure sphericalAmplitudeLaw := + (Measure.isProbabilityMeasure_map_iff continuous_firstAmplitude.measurable.aemeasurable).2 inferInstance + +theorem integral_signLaw (f : Bool → ℝ) : (∫ τ,f τ ∂signLaw)=(f false+f true)/2 := by + simp [signLaw,integral_smul_measure,integral_count,div_eq_mul_inv] + ring + +theorem integral_cylinderLaw (f : Bool×PlanarAngle → ℝ) (hf : Continuous f) : + (∫ p,f p ∂cylinderLaw)=((∫ θ,f (false,θ) ∂angleLaw)+(∫ θ,f (true,θ) ∂angleLaw))/2 := by + rw [cylinderLaw,integral_prod _ (compact_integrable hf),integral_signLaw] + +theorem cylinder_orbit_average (f : Spin 3 → ℝ) (hf : Continuous f) (s : Spin 3) : + (∫ p,f (spinRotation (cylinderRotation p.1 p.2) s) ∂cylinderLaw)= + ∫ p,f (cylindricalSpin (firstAmplitude s) p.1 p.2) ∂cylinderLaw := by + obtain ⟨υ,φ,hspin⟩ := cylindricalSpin_surjective_fiber s + have he (p : Bool×PlanarAngle) : + spinRotation (cylinderRotation p.1 p.2) s= + cylindricalSpin (firstAmplitude s) (p.1==υ) (p.2+φ) := by + conv_lhs => rw [← hspin] + rw [cylinderRotation_cylindricalSpin] + simp_rw [he] + have hc : Continuous (fun p : Bool×PlanarAngle => f (cylindricalSpin (firstAmplitude s) p.1 p.2)) := + hf.comp (continuous_cylindricalSpin.comp (continuous_const.prodMk continuous_id)) + have hm : Continuous (fun p : Bool×PlanarAngle => (p.1==υ,p.2+φ)) := + ((show Continuous (fun τ : Bool => τ==υ) from continuous_of_discreteTopology).comp continuous_fst).prodMk + (continuous_snd.add continuous_const) + have hh : Continuous (fun p : Bool×PlanarAngle => f (cylindricalSpin (firstAmplitude s) (p.1==υ) (p.2+φ))) := hc.comp hm + rw [integral_cylinderLaw _ hh,integral_cylinderLaw _ hc] + have hshift (τ : Bool) : + (∫ θ,f (cylindricalSpin (firstAmplitude s) τ (θ+φ)) ∂angleLaw)= + ∫ θ,f (cylindricalSpin (firstAmplitude s) τ θ) ∂angleLaw := + integral_add_right_eq_self (fun θ => f (cylindricalSpin (firstAmplitude s) τ θ)) φ + cases υ <;> simp only [Bool.false_beq,Bool.true_beq,Bool.not_false,Bool.not_true] + all_goals rw [hshift,hshift] + all_goals ring + +theorem integral_sphere_orbit (f : Spin 3 → ℝ) (hf : Continuous f) : + (∫ s,∫ p,f (spinRotation (cylinderRotation p.1 p.2) s) ∂cylinderLaw ∂sphereProbability 3)= + ∫ s,f s ∂sphereProbability 3 := by + have hcont : Continuous (fun p : Spin 3×(Bool×PlanarAngle) => f (spinRotation (cylinderRotation p.2.1 p.2.2) p.1)) := + hf.comp (continuous_cylinderSpinRotation.comp (f := (Prod.swap : Spin 3×(Bool×PlanarAngle) → (Bool×PlanarAngle)×Spin 3)) continuous_swap) + have hi := integral_integral_swap (μ := sphereProbability 3) (ν := cylinderLaw) + (f := fun s p => f (spinRotation (cylinderRotation p.1 p.2) s)) + (compact_integrable hcont) + rw [hi] + have hp (p : Bool×PlanarAngle) : + (∫ s,f (spinRotation (cylinderRotation p.1 p.2) s) ∂sphereProbability 3)=∫ s,f s ∂sphereProbability 3 := + (spinRotation_preserves_probability _).integral_comp (spinRotation _).measurableEmbedding f + simp_rw [hp] + simp + +theorem integral_sphere_cylinder (f : Spin 3 → ℝ) (hf : Continuous f) : + (∫ s,f s ∂sphereProbability 3)= + ∫ r,∫ p,f (cylindricalSpin r p.1 p.2) ∂cylinderLaw ∂sphericalAmplitudeLaw := by + have hc : Continuous (fun p : Amplitude×(Bool×PlanarAngle) => f (cylindricalSpin p.1 p.2.1 p.2.2)) := + hf.comp continuous_cylindricalSpin + have hm : Continuous (fun r => ∫ p,f (cylindricalSpin r p.1 p.2) ∂cylinderLaw) := + compact_parametric_integral _ hc + rw [sphericalAmplitudeLaw,integral_map continuous_firstAmplitude.measurable.aemeasurable hm.measurable.aestronglyMeasurable] + calc + _ = ∫ s,∫ p,f (spinRotation (cylinderRotation p.1 p.2) s) ∂cylinderLaw ∂sphereProbability 3 := + (integral_sphere_orbit f hf).symm + _ = _ := integral_congr_ae (Filter.Eventually.of_forall (cylinder_orbit_average f hf)) + +theorem cylindricalSpin_preserves : MeasurePreserving + (fun p : Amplitude×Bool×PlanarAngle => cylindricalSpin p.1 p.2.1 p.2.2) + (sphericalAmplitudeLaw.prod cylinderLaw) (sphereProbability 3) := by + refine ⟨continuous_cylindricalSpin.measurable,?_⟩ + apply Measure.ext_of_integral_eq_on_compactlySupported + intro f + have hc : Continuous (fun p : Amplitude×Bool×PlanarAngle => f (cylindricalSpin p.1 p.2.1 p.2.2)) := + f.continuous.comp continuous_cylindricalSpin + rw [integral_map (f := fun x => f x) continuous_cylindricalSpin.measurable.aemeasurable f.continuous.aestronglyMeasurable, + integral_prod _ (compact_integrable hc)] + exact (integral_sphere_cylinder f f.continuous).symm + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/DiscreteReference.lean b/lean/OAI/Probability/ClassicalON/DiscreteReference.lean new file mode 100644 index 0000000000000000000000000000000000000000..364693c8277c7a4a24168c6223a69a1b3d2c91e2 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/DiscreteReference.lean @@ -0,0 +1,32 @@ +import OAI.Probability.ClassicalON.BondSigns + +namespace OAI + +universe uV + +noncomputable section +open MeasureTheory +open scoped BigOperators ENNReal +namespace ClassicalON + +variable {V : Type uV} [Fintype V] + +theorem isingReference_singleton (s : V → Bool) : + isingReference {s}=(2 : ℝ≥0∞)⁻¹^Fintype.card V := by + classical + rw [isingReference,Measure.pi_singleton] + simp [signLaw] + +open scoped Classical in +theorem integral_isingReference (f : (V → Bool) → ℝ) : + (∫ s,f s ∂isingReference)=(2 : ℝ)⁻¹^Fintype.card V*∑ s,f s := by + classical + rw [integral_fintype (compact_integrable continuous_of_discreteTopology)] + simp only [Measure.real,isingReference_singleton,ENNReal.toReal_pow,ENNReal.toReal_inv, + ENNReal.toReal_ofNat,smul_eq_mul,← Finset.mul_sum] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/DyadicFourier.lean b/lean/OAI/Probability/ClassicalON/DyadicFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..15726d4ab6d730f79ae1c5ebca13c7774725574e --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/DyadicFourier.lean @@ -0,0 +1,99 @@ +import OAI.Probability.ClassicalON.TorusFourier + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +abbrev DyadicFreq (k : ℕ) := Σ j : Fin k, Fin (2^j.val) × Fin (2*2^j.val+1) + +def dyadicRadius {k : ℕ} (p : DyadicFreq k) : ℕ := 2^p.1.val + +def dyadicPoint {k : ℕ} (p : DyadicFreq k) : ℤ × ℤ := + ((dyadicRadius p : ℤ)+p.2.1.val, (p.2.2.val:ℤ)-dyadicRadius p) + +theorem dyadicRadius_pos {k : ℕ} (p : DyadicFreq k) : 0 < dyadicRadius p := by + unfold dyadicRadius + positivity + +theorem dyadicRadius_le {k : ℕ} (p : DyadicFreq k) : dyadicRadius p ≤ 2^k := by + exact Nat.pow_le_pow_right (by decide) p.1.isLt.le + +theorem dyadicPoint_bounds {k : ℕ} (p : DyadicFreq k) : + (dyadicRadius p:ℤ) ≤ (dyadicPoint p).1 ∧ (dyadicPoint p).1 < 2*dyadicRadius p ∧ + -(dyadicRadius p:ℤ) ≤ (dyadicPoint p).2 ∧ (dyadicPoint p).2 ≤ dyadicRadius p := by + have h1 := p.2.1.isLt + have h2 := p.2.2.isLt + simp only [dyadicPoint, dyadicRadius] + omega + +theorem dyadicPoint_injective {k : ℕ} : Function.Injective (dyadicPoint (k := k)) := by + intro p q he + have hf := congrArg Prod.fst he + have hs := congrArg Prod.snd he + have hp := dyadicPoint_bounds p + have hq := dyadicPoint_bounds q + have hj : p.1 = q.1 := by + apply Fin.ext + by_contra h + rcases lt_or_gt_of_ne h with hlt | hgt + · have hr : 2*dyadicRadius p ≤ dyadicRadius q := by + have hh := Nat.pow_le_pow_right (n := 2) (by decide : 1 ≤ 2) (Nat.succ_le_of_lt hlt) + simpa only [dyadicRadius, pow_succ, Nat.mul_comm] using hh + have hr' : (2*dyadicRadius p:ℤ) ≤ dyadicRadius q := by exact_mod_cast hr + omega + · have hr : 2*dyadicRadius q ≤ dyadicRadius p := by + have hh := Nat.pow_le_pow_right (n := 2) (by decide : 1 ≤ 2) (Nat.succ_le_of_lt hgt) + simpa only [dyadicRadius, pow_succ, Nat.mul_comm] using hh + have hr' : (2*dyadicRadius q:ℤ) ≤ dyadicRadius p := by exact_mod_cast hr + omega + rcases p with ⟨j,a,b⟩ + rcases q with ⟨j',a',b'⟩ + dsimp only at hj + subst j' + have ha : a = a' := by apply Fin.ext; simp only [dyadicPoint, dyadicRadius] at hf; omega + have hb : b = b' := by apply Fin.ext; simp only [dyadicPoint, dyadicRadius] at hs; omega + subst a'; subst b'; rfl + +theorem zmod_cast_inj_interval (L : ℕ) (c a b : ℤ) + (ha : c ≤ a ∧ a < c+L) (hb : c ≤ b ∧ b < c+L) + (he : (a:ZMod L) = (b:ZMod L)) : a=b := by + have hh : ((a-c:ℤ):ZMod L) = ((b-c:ℤ):ZMod L) := by simpa only [Int.cast_sub] using congrArg (fun z : ZMod L => z-(c:ZMod L)) he + have ha' : a-c ∈ Set.Ico (0:ℤ) L := by constructor <;> omega + have hb' : b-c ∈ Set.Ico (0:ℤ) L := by constructor <;> omega + have hz := CharP.intCast_injOn_Ico (R := ZMod L) L ha' hb' hh + omega + +def dyadicTorusPoint {k : ℕ} (p : DyadicFreq k) : DiscreteTorus (16*2^k) := + (((dyadicPoint p).1:ZMod (16*2^k)), ((dyadicPoint p).2:ZMod (16*2^k))) + +theorem dyadicTorusPoint_injective {k : ℕ} : Function.Injective (dyadicTorusPoint (k := k)) := by + intro p q he + apply dyadicPoint_injective + apply Prod.ext + · apply zmod_cast_inj_interval (16*2^k) 0 _ _ + · have hp := dyadicPoint_bounds p; have hr := dyadicRadius_le p; have hn : 0 < 2^k := by positivity + constructor <;> omega + · have hq := dyadicPoint_bounds q; have hr := dyadicRadius_le q; have hn : 0 < 2^k := by positivity + constructor <;> omega + · exact congrArg Prod.fst he + · apply zmod_cast_inj_interval (16*2^k) (-(2^k:ℕ):ℤ) _ _ + · have hp := dyadicPoint_bounds p; have hr := dyadicRadius_le p; have hn : 0 < 2^k := by positivity + constructor <;> omega + · have hq := dyadicPoint_bounds q; have hr := dyadicRadius_le q; have hn : 0 < 2^k := by positivity + constructor <;> omega + · exact congrArg Prod.snd he + +theorem dyadic_shell_card_bounds (j : ℕ) : + 2*(2^j)^2 ≤ Fintype.card (Fin (2^j) × Fin (2*2^j+1)) ∧ + Fintype.card (Fin (2^j) × Fin (2*2^j+1)) ≤ 3*(2^j)^2 := by + simp only [Fintype.card_prod, Fintype.card_fin] + have h : 1 ≤ 2^j := Nat.one_le_iff_ne_zero.mpr (pow_ne_zero _ (by decide)) + constructor <;> nlinarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/DyadicModes.lean b/lean/OAI/Probability/ClassicalON/DyadicModes.lean new file mode 100644 index 0000000000000000000000000000000000000000..07350595d577fc76d741a5f5778fa27ab438f82a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/DyadicModes.lean @@ -0,0 +1,67 @@ +import OAI.Probability.ClassicalON.DyadicSine + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +variable {k : ℕ} + +def groupedPoint (m s : Bool) (p : DyadicFreq k) : ℤ × ℤ := + let q := if m then (dyadicPoint p).swap else dyadicPoint p + if s then -q else q + +def groupedTorusPoint (m s : Bool) (p : DyadicFreq k) : DiscreteTorus (16*2^k) := + (((groupedPoint m s p).1:ZMod (16*2^k)), ((groupedPoint m s p).2:ZMod (16*2^k))) + +instance dyadicModulus_neZero (k : ℕ) : NeZero (16*2^k) := ⟨by positivity⟩ + +theorem groupedTorusPoint_injective (m s : Bool) : + Function.Injective (groupedTorusPoint (k := k) m s) := by + have hs := dyadicTorusPoint_injective (k := k) + cases m <;> cases s <;> intro p q h <;> apply hs + · exact h + · simpa [groupedTorusPoint, groupedPoint, dyadicTorusPoint, Prod.ext_iff] using h + · exact Prod.ext (congrArg Prod.snd h) (congrArg Prod.fst h) + · have h' : (dyadicTorusPoint p).swap = (dyadicTorusPoint q).swap := by + simpa [groupedTorusPoint, groupedPoint, dyadicTorusPoint, Prod.ext_iff] using h + exact Prod.swap_injective h' + +def dyadicWeight (p : DyadicFreq k) : ℝ := + 1/((dyadicRadius p:ℝ)*Real.sqrt (dyadicRadius p:ℝ)) + +theorem dyadicWeight_pos (p : DyadicFreq k) : 0 < dyadicWeight p := by + have h : (0:ℝ) hp p + +def dyadicReflect {k : ℕ} (p : DyadicFreq k) : DyadicFreq k := + ⟨p.1, p.2.1, p.2.2.rev⟩ + +@[simp] theorem dyadicReflect_radius {k : ℕ} (p : DyadicFreq k) : + dyadicRadius (dyadicReflect p) = dyadicRadius p := rfl + +@[simp] theorem dyadicReflect_point {k : ℕ} (p : DyadicFreq k) : + (dyadicPoint (dyadicReflect p)).2 = -(dyadicPoint p).2 := by + simp only [dyadicPoint, dyadicReflect, dyadicRadius, Fin.val_rev] + have h := p.2.2.isLt + omega + +@[simp] theorem dyadicReflect_involution {k : ℕ} (p : DyadicFreq k) : + dyadicReflect (dyadicReflect p) = p := by + simp [dyadicReflect] + +theorem dyadic_sin_cancel (k : ℕ) : + (∑ p : DyadicFreq k, (1/(dyadicRadius p:ℝ))^3 * + Real.sin (dyadicAngle k (dyadicPoint p).2)) = 0 := by + let e : DyadicFreq k ≃ DyadicFreq k := ⟨dyadicReflect, dyadicReflect, dyadicReflect_involution, dyadicReflect_involution⟩ + have he := Equiv.sum_comp e + (fun p : DyadicFreq k => (1/(dyadicRadius p:ℝ))^3 * Real.sin (dyadicAngle k (dyadicPoint p).2)) + change (∑ p : DyadicFreq k, (1/(dyadicRadius (dyadicReflect p):ℝ))^3 * Real.sin (dyadicAngle k (dyadicPoint (dyadicReflect p)).2)) = _ at he + simp only [dyadicReflect_radius, dyadicReflect_point, + Int.cast_neg, dyadicAngle_neg, Real.sin_neg, mul_neg, Finset.sum_neg_distrib] at he + linarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/DyadicSums.lean b/lean/OAI/Probability/ClassicalON/DyadicSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..96699a579291d103cf2f33d5afdff53867d9fcfc --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/DyadicSums.lean @@ -0,0 +1,121 @@ +import OAI.Probability.ClassicalON.LatticeModes + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace ClassicalON + +theorem dyadic_inverse_square_sum (k : ℕ) : + (∑ p : DyadicFreq k, (1/(dyadicRadius p:ℝ))^2) ≤ 3*(k:ℝ) := by + rw [Fintype.sum_sigma] + calc _ ≤ ∑ j : Fin k, (3:ℝ) := by + apply Finset.sum_le_sum + intro j _ + simp only [dyadicRadius, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + have hr : (0:ℝ) < (2^j.val:ℕ) := by positivity + have hc : (Fintype.card (Fin (2^j.val) × Fin (2*2^j.val+1)):ℝ) ≤ 3*((2^j.val:ℕ):ℝ)^2 := by + exact_mod_cast (dyadic_shell_card_bounds j.val).2 + calc _ ≤ (3*((2^j.val:ℕ):ℝ)^2)*(1/((2^j.val:ℕ):ℝ))^2 := + mul_le_mul_of_nonneg_right hc (sq_nonneg _) + _ = 3 := by field_simp + _ = _ := by simp; ring + +theorem sum_dyadic_ratio_lower (k i : ℕ) : + (∑ j ∈ Finset.range k, if j ≤ i then (2:ℝ)^j/2^i else 0) ≤ 2 := by + classical + rw [← Finset.sum_filter] + have hs : (Finset.range k).filter (fun j => j ≤ i) ⊆ Finset.range (i+1) := by + intro j hj + simp only [Finset.mem_filter, Finset.mem_range] at hj ⊢ + omega + calc _ ≤ ∑ j ∈ Finset.range (i+1), (2:ℝ)^j/2^i := + Finset.sum_le_sum_of_subset_of_nonneg hs (fun _ _ _ => by positivity) + _ ≤ 2 := by + rw [← Finset.sum_div] + have hh := geom_sum_mul (2:ℝ) (i+1) + have hp : (0:ℝ) < 2^i := by positivity + rw [div_le_iff₀ hp] + simp only [show (2:ℝ)-1=1 by norm_num, mul_one, + pow_succ] at hh + linarith + +theorem dyadic_min_ratio_sum (k : ℕ) : + (∑ i : Fin k, ∑ j : Fin k, min ((2:ℝ)^i.val/2^j.val) (2^j.val/2^i.val)) ≤ 4*(k:ℝ) := by + classical + have point (i j : Fin k) : min ((2:ℝ)^i.val/2^j.val) (2^j.val/2^i.val) ≤ + (if j.val ≤ i.val then (2:ℝ)^j.val/2^i.val else 0)+ + (if i.val ≤ j.val then (2:ℝ)^i.val/2^j.val else 0) := by + by_cases h : j.val ≤ i.val + · rw [ite_eq_left h] + exact (min_le_right _ _).trans (le_add_of_nonneg_right (by split_ifs <;> positivity)) + · have hh : i.val ≤ j.val := by omega + rw [ite_eq_right h, ite_eq_left hh, zero_add] + exact min_le_left _ _ + have hs : (∑ i : Fin k, ∑ j : Fin k, if j.val ≤ i.val then (2:ℝ)^j.val/2^i.val else 0) ≤ 2*(k:ℝ) := by + calc _ ≤ ∑ _i : Fin k, (2:ℝ) := by + apply Finset.sum_le_sum + intro i _ + rw [← Finset.sum_range (fun j => if j ≤ i.val then (2:ℝ)^j/2^i.val else 0)] + exact sum_dyadic_ratio_lower k i.val + _ = _ := by simp; ring + calc _ ≤ ∑ i : Fin k, ∑ j : Fin k, + ((if j.val ≤ i.val then (2:ℝ)^j.val/2^i.val else 0)+ + (if i.val ≤ j.val then (2:ℝ)^i.val/2^j.val else 0)) := + Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => point i j + _ = 2*∑ i : Fin k, ∑ j : Fin k, if j.val ≤ i.val then (2:ℝ)^j.val/2^i.val else 0 := by + simp only [Finset.sum_add_distrib] + rw [Finset.sum_comm (f := fun i j : Fin k => if i.val ≤ j.val then (2:ℝ)^i.val/2^j.val else 0)] + ring + _ ≤ _ := by linarith + +theorem weighted_dyadic_min_pair (a b : ℝ) (ha : 0 field_simp + +theorem dyadic_min_cost_sum (k : ℕ) : + (∑ p : DyadicFreq k, ∑ q : DyadicFreq k, + min ((1/(dyadicRadius p:ℝ))^3*(1/(dyadicRadius q:ℝ))) + ((1/(dyadicRadius q:ℝ))^3*(1/(dyadicRadius p:ℝ)))) ≤ 36*(k:ℝ) := by + simp only [Fintype.sum_sigma] + have he : (∑ i : Fin k, ∑ a : Fin (2^i.val) × Fin (2*2^i.val+1), + ∑ j : Fin k, ∑ b : Fin (2^j.val) × Fin (2*2^j.val+1), + min ((1/(dyadicRadius ⟨i,a⟩:ℝ))^3*(1/(dyadicRadius ⟨j,b⟩:ℝ))) + ((1/(dyadicRadius ⟨j,b⟩:ℝ))^3*(1/(dyadicRadius ⟨i,a⟩:ℝ)))) = + ∑ i : Fin k, ∑ j : Fin k, + (Fintype.card (Fin (2^i.val) × Fin (2*2^i.val+1)):ℝ)* + (Fintype.card (Fin (2^j.val) × Fin (2*2^j.val+1)):ℝ)* + min ((1/(2:ℝ)^i.val)^3*(1/(2:ℝ)^j.val)) + ((1/(2:ℝ)^j.val)^3*(1/(2:ℝ)^i.val)) := by + apply Finset.sum_congr rfl + intro i _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j _ + simp only [dyadicRadius, Nat.cast_pow, Nat.cast_ofNat, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + ring + rw [he] + calc _ ≤ ∑ i : Fin k, ∑ j : Fin k, 9*min ((2:ℝ)^i.val/2^j.val) (2^j.val/2^i.val) := by + apply Finset.sum_le_sum; intro i _ + apply Finset.sum_le_sum; intro j _ + have hi : (Fintype.card (Fin (2^i.val) × Fin (2*2^i.val+1)):ℝ) ≤ 3*((2:ℝ)^i.val)^2 := by + exact_mod_cast (dyadic_shell_card_bounds i.val).2 + have hj : (Fintype.card (Fin (2^j.val) × Fin (2*2^j.val+1)):ℝ) ≤ 3*((2:ℝ)^j.val)^2 := by + exact_mod_cast (dyadic_shell_card_bounds j.val).2 + calc _ ≤ (3*((2:ℝ)^i.val)^2)*(3*((2:ℝ)^j.val)^2)* + min ((1/(2:ℝ)^i.val)^3*(1/(2:ℝ)^j.val)) ((1/(2:ℝ)^j.val)^3*(1/(2:ℝ)^i.val)) := by + gcongr + _ = _ := by + rw [show (3*((2:ℝ)^i.val)^2)*(3*((2:ℝ)^j.val)^2) = 9*(((2:ℝ)^i.val)^2*((2:ℝ)^j.val)^2) by ring, + mul_assoc, weighted_dyadic_min_pair _ _ (by positivity) (by positivity), min_comm] + _ ≤ _ := by + simp only [← Finset.mul_sum] + have hs := dyadic_min_ratio_sum k + linarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/EdgeOperators.lean b/lean/OAI/Probability/ClassicalON/EdgeOperators.lean new file mode 100644 index 0000000000000000000000000000000000000000..611365614b376e327ec0db9a92d92020dcb0e750 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/EdgeOperators.lean @@ -0,0 +1,59 @@ +import OAI.Probability.ClassicalON.FourierOperator + +namespace OAI + +universe uP uX uY + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +theorem restricted_modulated_fourier_bound {X : Type uX} {P : Type uP} {Y : Type uY} + [Fintype X] [Fintype P] [Fintype Y] [DecidableEq P] + (W : X → P → ℂ) (M C A : ℝ) (hM : 0 ≤ M) + (hW : ∀ p q, (∑ x, W x p*conj (W x q)) = if p=q then (M:ℂ) else 0) + (i : Y → X) (hi : Function.Injective i) (d : Y → ℂ) (a v : P → ℂ) + (hd : ∀ y, ‖d y‖ ≤ C) (ha : ∀ p, ‖a p‖ ≤ A) : + (∑ y, ‖d y*(∑ p, W (i y) p*(a p*v p))‖^2) ≤ (C^2*M*A^2)*∑ p, ‖v p‖^2 := by + calc _ ≤ C^2*∑ y, ‖∑ p, W (i y) p*(a p*v p)‖^2 := sum_norm_pointwise_mul_sq_le _ _ C hd + _ ≤ C^2*∑ x, ‖∑ p, W x p*(a p*v p)‖^2 := + mul_le_mul_of_nonneg_left (sum_norm_sq_restrict i hi (fun x => ∑ p, W x p*(a p*v p))) (sq_nonneg _) + _ ≤ C^2*((M*A^2)*∑ p, ‖v p‖^2) := mul_le_mul_of_nonneg_left + (parseval_diagonal_bound W M A hM hW a v ha) (sq_nonneg _) + _ = _ := by ring + +theorem edge_cutoff_squareBound {P : Type uP} {Y : Type uY} [Fintype P] [Fintype Y] [DecidableEq P] + {L : ℕ} [NeZero L] (p : P → DiscreteTorus L) (hp : Function.Injective p) + (i : Y → DiscreteTorus L) (hi : Function.Injective i) (h : DiscreteTorus L) + (φ₀ φ₁ : Y → ℂ) (a : P → ℂ) + (D C A B : ℝ) (hD : ∀ y, ‖φ₁ y-φ₀ y‖ ≤ D) (hC : ∀ y, ‖φ₁ y‖ ≤ C) + (hA : ∀ q, ‖a q‖ ≤ A) (hB : ∀ q, ‖a q*(torusWave (p q) h-1)‖ ≤ B) : + SquareBound (fun y q => a q*(φ₁ y*torusWave (p q) (i y+h)-φ₀ y*torusWave (p q) (i y))) + (Real.sqrt (2*(L:ℝ)^2*(D^2*A^2+C^2*B^2))) := by + intro v + rw [Real.sq_sqrt (by positivity)] + let f := fun y => (φ₁ y-φ₀ y)*(∑ q, torusWave (p q) (i y)*(a q*v q)) + let g := fun y => φ₁ y*(∑ q, torusWave (p q) (i y)*((a q*(torusWave (p q) h-1))*v q)) + have he (y : Y) : + (∑ q, a q*(φ₁ y*torusWave (p q) (i y+h)-φ₀ y*torusWave (p q) (i y))*v q) = f y+g y := by + simp only [f, g, Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro q _ + rw [torusWave_add] + ring + simp_rw [he] + have hf := restricted_modulated_fourier_bound (fun x q => torusWave (p q) x) ((L:ℝ)^2) D A + (sq_nonneg _) (fun q r => by simpa only [Complex.ofReal_pow] using torusWave_orthogonal_subfamily p hp q r) + i hi (fun y => φ₁ y-φ₀ y) a v hD hA + have hg := restricted_modulated_fourier_bound (fun x q => torusWave (p q) x) ((L:ℝ)^2) C B + (sq_nonneg _) (fun q r => by simpa only [Complex.ofReal_pow] using torusWave_orthogonal_subfamily p hp q r) + i hi φ₁ (fun q => a q*(torusWave (p q) h-1)) v hC hB + have ht := sum_norm_add_sq_le f g + dsimp only [f, g] at ht ⊢ + linarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ExpMoments.lean b/lean/OAI/Probability/ClassicalON/ExpMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bdf08b60585d21623dfa5cba7978b06b24875f1 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ExpMoments.lean @@ -0,0 +1,72 @@ +import OAI.Probability.ClassicalON.IsingReference + +namespace OAI + +universe uE uX + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +theorem real_hasSum_exp (x : ℝ) : HasSum (fun k : ℕ => x^k/(k.factorial : ℝ)) (Real.exp x) := by + simpa only [Real.exp_eq_exp_ℝ] using NormedSpace.expSeries_div_hasSum_exp x + +section +variable {X : Type uX} [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] (μ : Measure X) [IsFiniteMeasure μ] + +theorem hasSum_integral_mul_exp {f h : X → ℝ} (hf : Continuous f) (hh : Continuous h) : + HasSum (fun k : ℕ => (∫ x,f x*h x^k ∂μ)/(k.factorial : ℝ)) + (∫ x,f x*Real.exp (h x) ∂μ) := by + let F : ℕ → X → ℝ := fun k x => f x*(h x^k/(k.factorial : ℝ)) + let B : ℕ → X → ℝ := fun k x => ‖f x‖*(‖h x‖^k/(k.factorial : ℝ)) + have hF : ∀ k,AEStronglyMeasurable (F k) μ := by + intro k + exact (compact_integrable (show Continuous (F k) from (hf.mul ((hh.pow k).div_const _)))).aestronglyMeasurable + have hB : ∀ k,∀ᵐ x ∂μ,‖F k x‖≤B k x := by + intro k + filter_upwards with x + simp only [F,B,norm_mul,norm_div,norm_pow,Real.norm_natCast] + exact le_rfl + have hS : ∀ᵐ x ∂μ,Summable (fun k => B k x) := by + filter_upwards with x + exact ((real_hasSum_exp ‖h x‖).mul_left ‖f x‖).summable + have hI : Integrable (fun x => ∑' k,B k x) μ := by + have he : (fun x => ∑' k : ℕ,B k x) = (fun x => ‖f x‖*Real.exp ‖h x‖) := by + funext x; exact ((real_hasSum_exp ‖h x‖).mul_left ‖f x‖).tsum_eq + rw [he] + exact compact_integrable (hf.norm.mul hh.norm.rexp) + have hL : ∀ᵐ x ∂μ,HasSum (fun k => F k x) (f x*Real.exp (h x)) := by + filter_upwards with x + exact (real_hasSum_exp (h x)).mul_left (f x) + have ht := hasSum_integral_of_dominated_convergence B hF hB hS hI hL + simpa only [F,← mul_div_assoc,integral_div] using ht + +theorem integral_mul_exp_nonneg_of_moments {f h : X → ℝ} (hf : Continuous f) (hh : Continuous h) + (hm : ∀ k : ℕ,0≤∫ x,f x*h x^k ∂μ) : 0≤∫ x,f x*Real.exp (h x) ∂μ := + (hasSum_integral_mul_exp μ hf hh).nonneg (fun k => div_nonneg (hm k) (Nat.cast_nonneg _)) + +theorem integral_mul_sum_exp_nonneg {E : Type uE} [Fintype E] + {f : X → ℝ} {a : E → X → ℝ} (hf : Continuous f) + (ha : ∀ e,Continuous (a e)) (b : E → ℝ) (hb : ∀ e,0≤b e) + (hm : ∀ (k : ℕ) (p : Fin k → E),0≤∫ x,f x*∏ i,a (p i) x ∂μ) : + 0≤∫ x,f x*Real.exp (∑ e,b e*a e x) ∂μ := by + apply integral_mul_exp_nonneg_of_moments μ hf (by fun_prop) + intro k + simp_rw [Fintype.sum_pow,Finset.mul_sum] + rw [integral_finsetSum _ (fun p _ => compact_integrable (by fun_prop))] + apply Finset.sum_nonneg + intro p _ + have he : (fun x => f x*∏ i,b (p i)*a (p i) x)= + (fun x => (∏ i,b (p i))*(f x*∏ i,a (p i) x)) := by + funext x; rw [Finset.prod_mul_distrib]; ring + rw [he,integral_const_mul] + exact mul_nonneg (Finset.prod_nonneg (fun i _ => hb (p i))) (hm k p) + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FamilyAlgebra.lean b/lean/OAI/Probability/ClassicalON/FamilyAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..8033f421be652bb61e3bbd6871cdbe25fcff6b55 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FamilyAlgebra.lean @@ -0,0 +1,150 @@ +import OAI.Probability.ClassicalON.ComplexWard + +namespace OAI + +universe uE uI uJ uK + +noncomputable section +open scoped BigOperators ComplexConjugate + +namespace MixedAlgebra +variable {I : Type uI} {J : Type uJ} {E : Type uE} {K : Type uK} [Fintype I] [Fintype J] [Fintype E] [CommRing K] + +lemma sum_three_rotate (F : I → J → E → K) : + (∑ i, ∑ j, ∑ e, F i j e) = ∑ e, ∑ i, ∑ j, F i j e := by + calc _ = ∑ i, ∑ e, ∑ j, F i j e := by + apply Finset.sum_congr rfl + intro i _ + exact Finset.sum_comm + _ = _ := Finset.sum_comm + +lemma sum_weighted_separated (A : E → K) (p : I → E → K) (q : J → E → K) + (a : I → K) (b : J → K) : + (∑ i, ∑ j, weighted A (p i * q j) * a i * b j) = + ∑ e, A e * (∑ i, p i e * a i) * (∑ j, q j e * b j) := by + simp only [weighted, Finset.sum_mul, Pi.mul_apply] + rw [sum_three_rotate] + apply Finset.sum_congr rfl + intro e _ + simp only [Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma sum_current (B : E → K) (p : I → E → K) (a : I → K) : + (∑ i, a i * weighted B (p i)) = weighted B (fun e => ∑ i, a i * p i e) := by + simp only [weighted, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + apply Finset.sum_congr rfl + intro i _ + ring + +lemma contract_two_current (A B C : E → K) (p q : I → E → K) (r s : J → E → K) : + (∑ i, ∑ j, weighted A (p i * r j) * weighted B (q i) * weighted C (s j)) = + ∑ e, A e * weighted B (fun l => ∑ i, p i e * q i l) * + weighted C (fun l => ∑ j, r j e * s j l) := by + rw [sum_weighted_separated] + simp only [sum_current] + +lemma contract_two_two (A B : E → K) (p q : I → E → K) (r s : J → E → K) : + (∑ i, ∑ j, weighted A (p i * r j) * weighted B (q i * s j)) = + ∑ e, ∑ l, A e * B l * (∑ i, p i e * q i l) * (∑ j, r j e * s j l) := by + have h (i : I) (j : J) : weighted A (p i * r j) * weighted B (q i * s j) = + ∑ l, B l * (weighted A (p i*r j) * q i l * s j l) := by + simp only [weighted, Finset.mul_sum, Pi.mul_apply] + apply Finset.sum_congr rfl + intro l _ + ring + simp_rw [h] + rw [sum_three_rotate] + simp_rw [← Finset.mul_sum] + simp_rw [sum_weighted_separated] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro l _ + ring + +lemma contract_three_current (A B : E → K) (p q : I → E → K) (r s : J → E → K) : + (∑ i, ∑ j, weighted A (p i*q i*r j) * weighted B (s j)) = + ∑ e, A e * (∑ i, p i e*q i e) * weighted B (fun l => ∑ j, r j e*s j l) := by + have h := sum_weighted_separated A (fun i => p i*q i) r (fun _ => 1) + (fun j => weighted B (s j)) + simpa only [mul_one, Pi.mul_apply, sum_current] using h + +lemma contract_four (A : E → K) (p q : I → E → K) (r s : J → E → K) : + (∑ i, ∑ j, weighted A (p i*q i*r j*s j)) = + ∑ e, A e * (∑ i, p i e*q i e) * (∑ j, r j e*s j e) := by + have h := sum_weighted_separated A (fun i => p i*q i) (fun j => r j*s j) + (fun _ => 1) (fun _ => 1) + simpa only [mul_one, Pi.mul_apply, mul_assoc] using h + +lemma four_grouped (C : Coeffs E K) (u v w z : E → K) : + four C u v w z = + (weighted C.a u * weighted C.b v + weighted C.ab (u*v)) * + (weighted C.a w * weighted C.b z + weighted C.ab (w*z)) + + (weighted C.aa (u*w) * weighted C.b v * weighted C.b z + + weighted C.ab (u*z) * weighted C.b v * weighted C.a w + + weighted C.ab (v*w) * weighted C.a u * weighted C.b z + + weighted C.bb (v*z) * weighted C.a u * weighted C.a w + + weighted C.aa (u*w) * weighted C.bb (v*z) + + weighted C.ab (u*z) * weighted C.ab (v*w) + + weighted C.aab (u*v*w) * weighted C.b z + + weighted C.abb (u*v*z) * weighted C.a w + + weighted C.aab (u*w*z) * weighted C.b v + + weighted C.abb (v*w*z) * weighted C.a u + + weighted C.aabb (u*v*w*z)) := by + unfold four + ring + +lemma contract_current_three (A B : E → K) (p q : I → E → K) (r s : J → E → K) : + (∑ i, ∑ j, weighted A (p i*r j*s j) * weighted B (q i)) = + ∑ e, A e * (∑ j, r j e*s j e) * weighted B (fun l => ∑ i, p i e*q i l) := by + rw [Finset.sum_comm] + simpa only [mul_comm, mul_left_comm, mul_assoc] using contract_three_current A B r s p q + +omit [Fintype J] in +def paired (C : Coeffs E K) (p q : I → E → K) : K := + ∑ i, (weighted C.a (p i) * weighted C.b (q i) + weighted C.ab (p i*q i)) + +omit [Fintype J] in +def kernel (p q : I → E → K) (e l : E) : K := ∑ i, p i e*q i l + +lemma four_family_contraction (C : Coeffs E K) (p q : I → E → K) (r s : J → E → K) : + (∑ i, ∑ j, four C (p i) (q i) (r j) (s j)) = + paired C p q * paired C r s + + ((∑ e, C.aa e * weighted C.b (kernel p q e) * weighted C.b (kernel r s e)) + + (∑ e, C.ab e * weighted C.b (kernel p q e) * weighted C.a (kernel s r e)) + + (∑ e, C.ab e * weighted C.a (kernel q p e) * weighted C.b (kernel r s e)) + + (∑ e, C.bb e * weighted C.a (kernel q p e) * weighted C.a (kernel s r e)) + + (∑ e, ∑ l, C.aa e*C.bb l * kernel p q e l * kernel r s e l) + + (∑ e, ∑ l, C.ab e*C.ab l * kernel p q e l * kernel s r e l) + + (∑ e, C.aab e * kernel p q e e * weighted C.b (kernel r s e)) + + (∑ e, C.abb e * kernel p q e e * weighted C.a (kernel s r e)) + + (∑ e, C.aab e * kernel r s e e * weighted C.b (kernel p q e)) + + (∑ e, C.abb e * kernel r s e e * weighted C.a (kernel q p e)) + + (∑ e, C.aabb e * kernel p q e e * kernel r s e e)) := by + simp only [four_grouped, Finset.sum_add_distrib] + have hp : (∑ i, ∑ j, + (weighted C.a (p i)*weighted C.b (q i) + weighted C.ab (p i*q i)) * + (weighted C.a (r j)*weighted C.b (s j) + weighted C.ab (r j*s j))) = + paired C p q * paired C r s := by + simp only [paired, Finset.sum_mul_sum] + rw [hp, contract_two_current, contract_two_current, contract_two_current, + contract_two_current, contract_two_two, contract_two_two, + contract_three_current, contract_three_current, contract_current_three, + contract_current_three, contract_four] + rfl + +end MixedAlgebra + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FamilyBound.lean b/lean/OAI/Probability/ClassicalON/FamilyBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..2470080d88590ed343d8308d843b400606c130ca --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FamilyBound.lean @@ -0,0 +1,92 @@ +import OAI.Probability.ClassicalON.ThetaEstimates + +namespace OAI + +universe uE uI uJ uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} {I : Type uI} [Fintype V] [Fintype E] [Fintype I] + +omit [Fintype V] [Fintype E] [Fintype I] in +theorem coefficientObservable_norm_le (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) (e : E) (σ : V → Spin 3) : + ‖S.coefficientObservable M e σ‖ ≤ β := by + change ‖(S.localCoefficient M σ e : ℂ)‖ ≤ β + rw [Complex.norm_real, Real.norm_eq_abs] + exact S.abs_localCoefficient_le β hb M hM σ e + +omit [Fintype I] in +theorem averageComplex_pos_square (S : SpinSystem 3 V E) (F : C((V → Spin 3), ℂ)) : + 0 ≤ (S.averageComplexLinear (F * conjugateObservable F)).re := by + rw [S.averageComplex_re] + apply S.averageLinear_nonneg + intro σ + change 0 ≤ (F σ * conj (F σ)).re + rw [Complex.mul_conj, Complex.ofReal_re] + exact Complex.normSq_nonneg _ + +omit [Fintype I] in +theorem norm_averageComplex_sum_le {J : Type uJ} [Fintype J] + (S : SpinSystem 3 V E) (F : J → C((V → Spin 3), ℂ)) (bound : J → ℝ) + (hF : ∀ j, ‖S.averageComplexLinear (F j)‖ ≤ bound j) : + ‖S.averageComplexLinear (∑ j, F j)‖ ≤ ∑ j, bound j := by + rw [map_sum] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun j _ => hF j) + +def familyPaired (S : SpinSystem 3 V E) (u : I → E → ℂ) : C((V → Spin 3), ℂ) := + ∑ i, (S.currentObservable axisA (u i) * + S.currentObservable axisB (fun e => conj (u i e)) + + S.currentObservable mixedAB (fun e => u i e * conj (u i e))) + +def familyRemainder (S : SpinSystem 3 V E) (u : I → E → ℂ) : C((V → Spin 3), ℂ) := + let T := familyKernel u + let X := fun M e => S.currentObservable M (T e) + let C := S.coefficientObservable + let bar := conjugateObservable + let k := fun z => ContinuousMap.const (V → Spin 3) z + (∑ e, C (axisA^2) e * X axisB e * bar (X axisB e)) + + (∑ e, C mixedAB e * X axisB e * X axisA e) + + (∑ e, C mixedAB e * bar (X axisA e) * bar (X axisB e)) + + (∑ e, C (axisB^2) e * bar (X axisA e) * X axisA e) + + (∑ e, ∑ l, C (axisA^2) e * C (axisB^2) l * k (T e l * conj (T e l))) + + (∑ e, ∑ l, C mixedAB e * C mixedAB l * k (T e l ^ 2)) + + (∑ e, C mixedAAB e * k (T e e) * bar (X axisB e)) + + (∑ e, C mixedABB e * k (T e e) * X axisA e) + + (∑ e, C mixedAAB e * k (conj (T e e)) * X axisB e) + + (∑ e, C mixedABB e * k (conj (T e e)) * bar (X axisA e)) + + (∑ e, C mixedAABB e * k (T e e * conj (T e e))) + +omit [Fintype V] in + +theorem familyObservable_contraction (S : SpinSystem 3 V E) (u : I → E → ℂ) : + (∑ i, ∑ j, S.complexMixedObservable (u i) (fun e => conj (u i e)) + (fun e => conj (u j e)) (u j)) = + S.familyPaired u * conjugateObservable (S.familyPaired u) + S.familyRemainder u := by + ext σ + have h := MixedAlgebra.four_family_contraction (S.complexCoefficients σ) u + (fun i e => conj (u i e)) (fun i e => conj (u i e)) u + simp only [ContinuousMap.sum_apply, ContinuousMap.mul_apply, ContinuousMap.add_apply, + complexMixedObservable, ContinuousMap.coe_mk] + rw [h] + simp only [familyPaired, familyRemainder, ContinuousMap.sum_apply, + ContinuousMap.add_apply, ContinuousMap.mul_apply, conjugateObservable_apply, + ContinuousMap.const_apply, currentObservable, coefficientObservable, + ContinuousMap.coe_mk, MixedAlgebra.paired, MixedAlgebra.kernel, + familyKernel, complexCoefficients, MixedAlgebra.Coeffs.map, + mixedCoefficients, Function.comp_def, Complex.ofRealHom_eq_coe, + complexEnergy, map_sum, map_add, map_mul, + starRingEnd_self_apply, pow_two] + congr 1 + all_goals simp only [MixedAlgebra.weighted, MixedAlgebra.kernel, familyKernel, + map_sum, map_mul, Complex.conj_ofReal, starRingEnd_self_apply, Pi.mul_apply, mul_assoc] + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FamilyEstimate.lean b/lean/OAI/Probability/ClassicalON/FamilyEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..d156c2b43f18ae2c73a79800edf614fd397992bb --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FamilyEstimate.lean @@ -0,0 +1,77 @@ +import OAI.Probability.ClassicalON.FamilyBound + +namespace OAI + +universe uE uI uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} {I : Type uI} [Fintype V] [Fintype E] [Fintype I] + +omit [Fintype I] in +theorem norm_avg_coeff_two (S : SpinSystem 3 V E) (β v : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) (e : E) + (F G : C((V → Spin 3), ℂ)) + (hF : S.averageLinear (normObservable F * normObservable F) ≤ v) + (hG : S.averageLinear (normObservable G * normObservable G) ≤ v) : + ‖S.averageComplexLinear (S.coefficientObservable M e * F * G)‖ ≤ β*v := + S.norm_averageComplex_mul_mul_le_of_moments _ F G β v hβ + (S.coefficientObservable_norm_le β hb M hM e) hF hG + +omit [Fintype I] in +theorem norm_avg_coeff_coeff_const (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M N : SpinOperator 3) (hM : ‖M‖ ≤ 1) (hN : ‖N‖ ≤ 1) (e l : E) (z : ℂ) : + ‖S.averageComplexLinear (S.coefficientObservable M e * S.coefficientObservable N l * + ContinuousMap.const _ z)‖ ≤ β^2*‖z‖ := by + apply S.norm_averageComplex_le_const + intro σ + simp only [ContinuousMap.mul_apply, ContinuousMap.const_apply, norm_mul] + apply mul_le_mul_of_nonneg_right _ (norm_nonneg z) + rw [pow_two] + exact mul_le_mul (S.coefficientObservable_norm_le β hb M hM e σ) + (S.coefficientObservable_norm_le β hb N hN l σ) (norm_nonneg _) hβ + +omit [Fintype I] in +theorem norm_avg_coeff_const_current (S : SpinSystem 3 V E) (β q : ℝ) + (hβ : 0 ≤ β) (hq : 0 ≤ q) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) (e : E) (z : ℂ) + (hz : ‖z‖ ≤ Real.sqrt q) (F : C((V → Spin 3), ℂ)) + (hF : S.averageLinear (normObservable F * normObservable F) ≤ β*q) : + ‖S.averageComplexLinear (S.coefficientObservable M e * ContinuousMap.const _ z * F)‖ ≤ + β*Real.sqrt β*q := by + have hcoeff (σ : V → Spin 3) : + ‖(S.coefficientObservable M e * ContinuousMap.const (V → Spin 3) z) σ‖ ≤ β*‖z‖ := by + simp only [ContinuousMap.mul_apply, ContinuousMap.const_apply, norm_mul] + exact mul_le_mul_of_nonneg_right (S.coefficientObservable_norm_le β hb M hM e σ) + (norm_nonneg z) + calc _ ≤ (β*‖z‖)*Real.sqrt (β*q) := + S.norm_averageComplex_mul_le_of_moment _ F (β*‖z‖) (β*q) + (mul_nonneg hβ (norm_nonneg z)) hcoeff hF + _ ≤ (β*Real.sqrt q)*Real.sqrt (β*q) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hz hβ) (Real.sqrt_nonneg _) + _ = β*Real.sqrt β*q := by + rw [Real.sqrt_mul hβ] + calc _ = β*Real.sqrt β*(Real.sqrt q*Real.sqrt q) := by ring + _ = _ := by rw [Real.mul_self_sqrt hq] + +omit [Fintype I] in +theorem norm_avg_coeff_const (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) (e : E) (z : ℂ) : + ‖S.averageComplexLinear (S.coefficientObservable M e * ContinuousMap.const _ z)‖ ≤ β*‖z‖ := by + apply S.norm_averageComplex_le_const + intro σ + simp only [ContinuousMap.mul_apply, ContinuousMap.const_apply, norm_mul] + exact mul_le_mul_of_nonneg_right (S.coefficientObservable_norm_le β hb M hM e σ) (norm_nonneg z) + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FamilyKernel.lean b/lean/OAI/Probability/ClassicalON/FamilyKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..56f8032483207d8502adf14a7732defcd76d7268 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FamilyKernel.lean @@ -0,0 +1,113 @@ +import OAI.Probability.ClassicalON.ObservableBounds + +namespace OAI + +universe uE uI uV uΩ + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON +variable {I : Type uI} {E : Type uE} [Fintype I] [Fintype E] + +def familyKernel (u : I → E → ℂ) (e l : E) : ℂ := ∑ i, u i e * conj (u i l) + +def rowSquare (u : I → E → ℂ) (e : E) : ℝ := ∑ l, ‖familyKernel u e l‖^2 + +def familyHSSquare (u : I → E → ℂ) : ℝ := ∑ e, rowSquare u e + +omit [Fintype E] in +@[simp] theorem familyKernel_conj (u : I → E → ℂ) (e l : E) : + familyKernel (fun i e => conj (u i e)) e l = conj (familyKernel u e l) := by + simp [familyKernel] + +theorem rowSquare_nonneg (u : I → E → ℂ) (e : E) : 0 ≤ rowSquare u e := + Finset.sum_nonneg fun _ _ => sq_nonneg _ + +theorem familyHSSquare_nonneg (u : I → E → ℂ) : 0 ≤ familyHSSquare u := + Finset.sum_nonneg fun e _ => rowSquare_nonneg u e + +theorem kernel_diag_sq_le_row (u : I → E → ℂ) (e : E) : + ‖familyKernel u e e‖^2 ≤ rowSquare u e := + Finset.single_le_sum (fun l _ => sq_nonneg ‖familyKernel u e l‖) (Finset.mem_univ e) + +theorem kernel_diag_norm_le_sqrt (u : I → E → ℂ) (e : E) : + ‖familyKernel u e e‖ ≤ Real.sqrt (rowSquare u e) := + Real.le_sqrt_of_sq_le (kernel_diag_sq_le_row u e) + +namespace SpinSystem +variable {n : ℕ} {V : Type uV} [Fintype V] + +omit [Fintype V] [Fintype I] in +def coefficientObservable (S : SpinSystem n V E) (M : SpinOperator n) (e : E) : + C((V → Spin n), ℂ) := ⟨fun σ => (S.localCoefficient M σ e : ℂ), by + unfold localCoefficient + fun_prop⟩ + +omit [Fintype V] [Fintype I] in +def currentObservable (S : SpinSystem n V E) (M : SpinOperator n) (u : E → ℂ) : + C((V → Spin n), ℂ) := ⟨_, S.continuous_complexEnergy M u⟩ + +omit [Fintype V] [Fintype I] [Fintype E] in +def conjugateObservable {Ω : Type uΩ} [TopologicalSpace Ω] (f : C(Ω, ℂ)) : C(Ω, ℂ) := + ⟨fun σ => conj (f σ), Complex.continuous_conj.comp f.continuous⟩ + +omit [Fintype V] [Fintype I] [Fintype E] in +@[simp] theorem conjugateObservable_apply {Ω : Type uΩ} [TopologicalSpace Ω] + (f : C(Ω, ℂ)) (σ : Ω) : conjugateObservable f σ = conj (f σ) := rfl + +omit [Fintype V] [Fintype I] [Fintype E] in +@[simp] theorem normObservable_conjugate {Ω : Type uΩ} [TopologicalSpace Ω] + (f : C(Ω, ℂ)) : normObservable (conjugateObservable f) = normObservable f := by + ext σ + exact Complex.norm_conj (f σ) + +omit [Fintype V] [Fintype I] in +@[simp] theorem currentObservable_conj (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℂ) : S.currentObservable M (fun e => conj (u e)) = + conjugateObservable (S.currentObservable M u) := by + ext σ + exact S.complexEnergy_conj M u σ + +omit [Fintype V] [Fintype I] [Fintype E] in +@[simp] theorem coefficientObservable_conj (S : SpinSystem n V E) (M : SpinOperator n) + (e : E) : conjugateObservable (S.coefficientObservable M e) = + S.coefficientObservable M e := by + ext σ + exact Complex.conj_ofReal _ + +omit [Fintype V] [Fintype E] in +theorem familyKernel_differential (S : SpinSystem n V E) (f : I → V → ℂ) (e : E) : + familyKernel (fun i => S.differential (f i)) e = + S.differential (fun x => ∑ i, S.differential (f i) e * conj (f i x)) := by + funext l + simp only [familyKernel, differential, map_sub, mul_sub, Finset.sum_sub_distrib] + +theorem row_current_moment [NeZero n] (S : SpinSystem n V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator n) (hM : M ∈ skewAdjoint (SpinOperator n)) (hMn : ‖M‖ ≤ 1) + (f : I → V → ℂ) (hP : ∀ i x s, S.pin x = some s → f i x = 0) (e : E) : + S.averageLinear (normObservable (S.currentObservable M + (familyKernel (fun i => S.differential (f i)) e)) * + normObservable (S.currentObservable M + (familyKernel (fun i => S.differential (f i)) e))) ≤ + β * rowSquare (fun i => S.differential (f i)) e := by + have hp : ∀ x s, S.pin x = some s → + (∑ i, S.differential (f i) e * conj (f i x)) = 0 := by + intro x s hs + simp [hP _ x s hs] + have h := S.complex_gradient_current_bound β hb M hM hMn + (fun x => ∑ i, S.differential (f i) e * conj (f i x)) hp + rw [← S.familyKernel_differential f e] at h + change S.average (fun σ => + ‖S.complexEnergy M (familyKernel (fun i => S.differential (f i)) e) σ‖ * + ‖S.complexEnergy M (familyKernel (fun i => S.differential (f i)) e) σ‖) ≤ _ + simpa only [rowSquare, pow_two] using h + +end SpinSystem +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FamilyLower.lean b/lean/OAI/Probability/ClassicalON/FamilyLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..63a2f79d46830270e82c0bf5e2e3d3ce885050ea --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FamilyLower.lean @@ -0,0 +1,132 @@ +import OAI.Probability.ClassicalON.FamilyEstimate + +namespace OAI + +universe uE uI uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} {I : Type uI} [Fintype V] [Fintype E] [Fintype I] + +theorem norm_avg_row_sum (S : SpinSystem 3 V E) (u : I → E → ℂ) + (F : E → C((V → Spin 3), ℂ)) (c : ℝ) + (hF : ∀ e, ‖S.averageComplexLinear (F e)‖ ≤ c * rowSquare u e) : + ‖S.averageComplexLinear (∑ e, F e)‖ ≤ c * familyHSSquare u := by + simpa only [familyHSSquare, Finset.mul_sum] using + S.norm_averageComplex_sum_le F (fun e => c * rowSquare u e) hF + +omit [Fintype I] in +theorem norm_avg_add_le (S : SpinSystem 3 V E) (F G : C((V → Spin 3), ℂ)) + (a b : ℝ) (hF : ‖S.averageComplexLinear F‖ ≤ a) + (hG : ‖S.averageComplexLinear G‖ ≤ b) : + ‖S.averageComplexLinear (F+G)‖ ≤ a+b := by + rw [map_add] + exact (norm_add_le _ _).trans (add_le_add hF hG) + +theorem norm_familyRemainder_le (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (f : I → V → ℂ) (hP : ∀ i x s, S.pin x = some s → f i x = 0) : + ‖S.averageComplexLinear (S.familyRemainder (fun i => S.differential (f i)))‖ ≤ + (6*β^2+4*β*Real.sqrt β+β) * familyHSSquare (fun i => S.differential (f i)) := by + let u := fun i => S.differential (f i) + let T := familyKernel u + let X := fun M e => S.currentObservable M (T e) + let C := S.coefficientObservable + let bar := conjugateObservable (Ω := V → Spin 3) + let k : ℂ → C((V → Spin 3), ℂ) := ContinuousMap.const (V → Spin 3) + let H := familyHSSquare u + have ha (e : E) : S.averageLinear (normObservable (X axisA e) * normObservable (X axisA e)) ≤ + β * rowSquare u e := S.row_current_moment β hb axisA axisA_skew axisA_norm_le f hP e + have hb' (e : E) : S.averageLinear (normObservable (X axisB e) * normObservable (X axisB e)) ≤ + β * rowSquare u e := S.row_current_moment β hb axisB axisB_skew axisB_norm_le f hP e + have hac (e : E) : S.averageLinear (normObservable (bar (X axisA e)) * + normObservable (bar (X axisA e))) ≤ β * rowSquare u e := by + simpa only [bar, normObservable_conjugate] using ha e + have hbc (e : E) : S.averageLinear (normObservable (bar (X axisB e)) * + normObservable (bar (X axisB e))) ≤ β * rowSquare u e := by + simpa only [bar, normObservable_conjugate] using hb' e + have row (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) + (F G : E → C((V → Spin 3), ℂ)) + (hF : ∀ e, S.averageLinear (normObservable (F e)*normObservable (F e)) ≤ β*rowSquare u e) + (hG : ∀ e, S.averageLinear (normObservable (G e)*normObservable (G e)) ≤ β*rowSquare u e) : + ‖S.averageComplexLinear (∑ e, C M e * F e * G e)‖ ≤ β^2*H := by + apply S.norm_avg_row_sum u _ (β^2) + intro e + exact (S.norm_avg_coeff_two β (β*rowSquare u e) hβ hb M hM e (F e) (G e) + (hF e) (hG e)).trans_eq (by ring) + have b1 := row (axisA^2) (norm_square_le_one axisA axisA_norm_le) + (X axisB) (fun e => bar (X axisB e)) hb' hbc + have b2 := row mixedAB mixedAB_norm_le (X axisB) (X axisA) hb' ha + have b3 := row mixedAB mixedAB_norm_le (fun e => bar (X axisA e)) + (fun e => bar (X axisB e)) hac hbc + have b4 := row (axisB^2) (norm_square_le_one axisB axisB_norm_le) + (fun e => bar (X axisA e)) (X axisA) hac ha + have pair (M N : SpinOperator 3) (hM : ‖M‖ ≤ 1) (hN : ‖N‖ ≤ 1) + (z : E → E → ℂ) (hz : ∀ e l, ‖z e l‖ = ‖T e l‖^2) : + ‖S.averageComplexLinear (∑ e, ∑ l, C M e * C N l * k (z e l))‖ ≤ β^2*H := by + apply S.norm_avg_row_sum u _ (β^2) + intro e + calc _ ≤ ∑ l, β^2*‖T e l‖^2 := by + apply S.norm_averageComplex_sum_le + intro l + exact (S.norm_avg_coeff_coeff_const β hβ hb M N hM hN e l (z e l)).trans_eq + (by rw [hz e l]) + _ = _ := by rw [← Finset.mul_sum]; rfl + have b5 := pair (axisA^2) (axisB^2) (norm_square_le_one axisA axisA_norm_le) + (norm_square_le_one axisB axisB_norm_le) (fun e l => T e l*conj (T e l)) + (by intro e l; simp only [norm_mul, Complex.norm_conj, pow_two]) + have b6 := pair mixedAB mixedAB mixedAB_norm_le mixedAB_norm_le (fun e l => T e l^2) + (by intro e l; exact norm_pow _ _) + have triple (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) + (z : E → ℂ) (hz : ∀ e, ‖z e‖ ≤ Real.sqrt (rowSquare u e)) + (F : E → C((V → Spin 3), ℂ)) + (hF : ∀ e, S.averageLinear (normObservable (F e)*normObservable (F e)) ≤ β*rowSquare u e) : + ‖S.averageComplexLinear (∑ e, C M e * k (z e) * F e)‖ ≤ β*Real.sqrt β*H := by + apply S.norm_avg_row_sum u _ (β*Real.sqrt β) + intro e + exact S.norm_avg_coeff_const_current β (rowSquare u e) hβ (rowSquare_nonneg u e) + hb M hM e (z e) (hz e) (F e) (hF e) + have hz (e : E) : ‖T e e‖ ≤ Real.sqrt (rowSquare u e) := kernel_diag_norm_le_sqrt u e + have hzc (e : E) : ‖conj (T e e)‖ ≤ Real.sqrt (rowSquare u e) := by + rw [Complex.norm_conj]; exact hz e + have b7 := triple mixedAAB mixedAAB_norm_le (fun e => T e e) hz + (fun e => bar (X axisB e)) hbc + have b8 := triple mixedABB mixedABB_norm_le (fun e => T e e) hz (X axisA) ha + have b9 := triple mixedAAB mixedAAB_norm_le (fun e => conj (T e e)) hzc (X axisB) hb' + have b10 := triple mixedABB mixedABB_norm_le (fun e => conj (T e e)) hzc + (fun e => bar (X axisA e)) hac + have b11 : ‖S.averageComplexLinear (∑ e, C mixedAABB e * k (T e e*conj (T e e)))‖ ≤ β*H := by + apply S.norm_avg_row_sum u _ β + intro e + calc _ ≤ β*‖T e e*conj (T e e)‖ := S.norm_avg_coeff_const β hb mixedAABB mixedAABB_norm_le e _ + _ = β*‖T e e‖^2 := by rw [norm_mul, Complex.norm_conj, pow_two] + _ ≤ β*rowSquare u e := mul_le_mul_of_nonneg_left (kernel_diag_sq_le_row u e) hβ + have hadd := S.norm_avg_add_le + have h := hadd _ _ _ _ (hadd _ _ _ _ (hadd _ _ _ _ (hadd _ _ _ _ (hadd _ _ _ _ + (hadd _ _ _ _ (hadd _ _ _ _ (hadd _ _ _ _ (hadd _ _ _ _ (hadd _ _ _ _ b1 b2) + b3) b4) b5) b6) b7) b8) b9) b10) b11 + change ‖S.averageComplexLinear (S.familyRemainder u)‖ ≤ _ at h ⊢ + exact h.trans_eq (by dsimp only [H]; ring) + +theorem fourth_family_lower (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (f : I → V → ℂ) (hP : ∀ i x s, S.pin x = some s → f i x = 0) : + -((6*β^2+4*β*Real.sqrt β+β)*familyHSSquare (fun i => S.differential (f i))) ≤ + (S.averageComplexLinear (∑ i, ∑ j, + S.complexMixedObservable (S.differential (f i)) (fun e => conj (S.differential (f i) e)) + (fun e => conj (S.differential (f j) e)) (S.differential (f j)))).re := by + rw [S.familyObservable_contraction, map_add, Complex.add_re] + have hp := S.averageComplex_pos_square (S.familyPaired (fun i => S.differential (f i))) + have hr := S.norm_familyRemainder_le β hβ hb f hP + have hre := (abs_le.mp (Complex.abs_re_le_norm (S.averageComplexLinear + (S.familyRemainder (fun i => S.differential (f i)))))).1 + linarith + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FerromagneticMean.lean b/lean/OAI/Probability/ClassicalON/FerromagneticMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..763ef789276743d2611b1271b186b8ce7009d085 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FerromagneticMean.lean @@ -0,0 +1,95 @@ +import OAI.Probability.ClassicalON.WeightedLinear + +namespace OAI + +universe uE uX + +noncomputable section +open MeasureTheory Set +open scoped BigOperators +namespace ClassicalON + +section +variable {X : Type uX} {E : Type uE} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] + [BorelSpace X] [Fintype E] (μ : Measure X) [IsProbabilityMeasure μ] + (T : E → X → ℝ) + +def edgeHamiltonian (b : E → ℝ) (x : X) : ℝ := ∑ e,b e*T e x + +def edgeMean (b : E → ℝ) (f : X → ℝ) : ℝ := exponentialMean μ (edgeHamiltonian T b) f + +omit [CompactSpace X] [MeasurableSpace X] [BorelSpace X] in +theorem continuous_edgeHamiltonian (hT : ∀ e,Continuous (T e)) (b : E → ℝ) : + Continuous (edgeHamiltonian T b) := by + exact continuous_finsetSum _ (fun e _ => continuous_const.mul (hT e)) + +def EdgeCovarianceNonneg : Prop := ∀ b : E → ℝ,(∀ e,0≤b e) → ∀ e f : E, + edgeMean μ T b (T e)*edgeMean μ T b (T f)≤edgeMean μ T b (fun x => T e x*T f x) + +omit [TopologicalSpace X] [CompactSpace X] [BorelSpace X] in +theorem edgeMean_zero (f : X → ℝ) : edgeMean μ T (fun _ => 0) f=∫ x,f x ∂μ := by + have hz : edgeHamiltonian T (fun _ => 0)=(fun _ => 0) := by funext x; simp [edgeHamiltonian] + unfold edgeMean + rw [hz,exponentialMean_zero] + +theorem edgeMean_direction_derivative (hT : ∀ e,Continuous (T e)) (b d : E → ℝ) + (e : E) (t : ℝ) : + HasDerivAt (fun u => edgeMean μ T (fun g => b g+u*d g) (T e)) + (∑ g,d g*(edgeMean μ T (fun h => b h+t*d h) (fun x => T e x*T g x)- + edgeMean μ T (fun h => b h+t*d h) (T e)* + edgeMean μ T (fun h => b h+t*d h) (T g))) t := by + have he (u : ℝ) (x : X) : edgeHamiltonian T (fun g => b g+u*d g) x= + edgeHamiltonian T b x+u*edgeHamiltonian T d x := by + simp only [edgeHamiltonian,add_mul,Finset.sum_add_distrib,Finset.mul_sum,mul_assoc] + have hd := hasDerivAt_exponentialMean μ (continuous_edgeHamiltonian T hT b) + (continuous_edgeHamiltonian T hT d) (hT e) t + simp_rw [← he] at hd + change HasDerivAt (fun u => exponentialMean μ (edgeHamiltonian T (fun g => b g+u*d g)) (T e)) _ _ + apply hd.congr_deriv + rw [show (fun x => T e x*edgeHamiltonian T d x)= + (fun x => ∑ g,d g*(T e x*T g x)) by funext; simp only [edgeHamiltonian,Finset.mul_sum]; apply Finset.sum_congr rfl; intros; ring] + rw [exponentialMean_sum μ (continuous_edgeHamiltonian T hT _) _ (fun g => by fun_prop)] + change (∑ g,exponentialMean μ _ (fun x => d g*(T e x*T g x)))- + exponentialMean μ _ (T e)*exponentialMean μ _ (fun x => ∑ g,d g*T g x)=_ + rw [exponentialMean_sum μ (continuous_edgeHamiltonian T hT _) _ (fun g => by fun_prop)] + simp only [exponentialMean_const_mul,Finset.mul_sum,← Finset.sum_sub_distrib,edgeMean] + apply Finset.sum_congr rfl + intro g _ + ring + +theorem edgeMean_mono_couplings (hT : ∀ e,Continuous (T e)) + (hCov : EdgeCovarianceNonneg μ T) {a b : E → ℝ} + (ha : ∀ e,0≤a e) (hab : ∀ e,a e≤b e) (e : E) : + edgeMean μ T a (T e)≤edgeMean μ T b (T e) := by + let d := fun g => b g-a g + let F := fun t => edgeMean μ T (fun g => a g+t*d g) (T e) + have hD := edgeMean_direction_derivative μ T hT a d e + have hM : MonotoneOn F (Icc 0 1) := by + apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc 0 1) + (fun t _ => (hD t).continuousAt.continuousWithinAt) + (fun t _ => (hD t).hasDerivWithinAt) + intro t ht + apply Finset.sum_nonneg + intro g _ + apply mul_nonneg (sub_nonneg.mpr (hab g)) + apply sub_nonneg.mpr + apply hCov + intro h + have ht0 : 0≤t := (interior_subset ht).1 + exact add_nonneg (ha h) (mul_nonneg ht0 (sub_nonneg.mpr (hab h))) + have hh := hM (by simp : (0 : ℝ)∈Icc 0 1) (by simp : (1 : ℝ)∈Icc 0 1) (by norm_num) + simpa only [F,d,zero_mul,add_zero,one_mul,add_sub_cancel] using hh + +theorem edgeMean_nonneg (hT : ∀ e,Continuous (T e)) (hCov : EdgeCovarianceNonneg μ T) + (h0 : ∀ e,0≤∫ x,T e x ∂μ) (b : E → ℝ) (hb : ∀ e,0≤b e) (e : E) : + 0≤edgeMean μ T b (T e) := by + have hh := edgeMean_mono_couplings μ T hT hCov (fun _ => le_rfl) hb e + rw [edgeMean_zero] at hh + exact (h0 e).trans hh + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FinFKG.lean b/lean/OAI/Probability/ClassicalON/FinFKG.lean new file mode 100644 index 0000000000000000000000000000000000000000..543c8c85c19d7dbc3f935312a3544407c49594cc --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FinFKG.lean @@ -0,0 +1,108 @@ +import OAI.Probability.ClassicalON.PlanarPositive + +namespace OAI + +universe uA uX uY uι + +noncomputable section +open MeasureTheory +namespace ClassicalON + +section Equivalence +variable {X : Type uX} {Y : Type uY} [MeasurableSpace X] [MeasurableSpace Y] + [TopologicalSpace X] [TopologicalSpace Y] [Lattice X] [Lattice Y] + {μ : Measure X} {ν : Measure Y} + +omit [TopologicalSpace X] [TopologicalSpace Y] [Lattice X] [Lattice Y] in +theorem weightedMean_equiv (e : X ≃ᵐ Y) (he : MeasurePreserving e μ ν) (w f : Y → ℝ) : + weightedMean μ (w ∘ e) (f ∘ e) = weightedMean ν w f := by + unfold weightedMean + change (∫ x,(fun y => w y*f y) (e x) ∂μ)/(∫ x,w (e x) ∂μ) = _ + rw [he.integral_comp' (fun y => w y*f y),he.integral_comp' w] + +theorem continuousFKG_equiv (e : X ≃ᵐ Y) (he : MeasurePreserving e μ ν) + (hc : Continuous e) (hm : Monotone e) + (hi : ∀ x y,e (x⊓y)=e x⊓e y) (hs : ∀ x y,e (x⊔y)=e x⊔e y) + (hX : ContinuousFKG μ) : ContinuousFKG ν := by + intro w hw hp hLS f g hf hg hfn hgn hfm hgm + have hL : LogSupermodular (w ∘ e) := by + intro x y + simpa [Function.comp_def,hi,hs] using hLS (e x) (e y) + have h := hX (w ∘ e) (hw.comp hc) (fun x => hp (e x)) hL + (f ∘ e) (g ∘ e) (hf.comp hc) (hg.comp hc) (fun x => hfn (e x)) + (fun x => hgn (e x)) (hfm.comp hm) (hgm.comp hm) + change weightedMean μ (w ∘ e) (f ∘ e)*weightedMean μ (w ∘ e) (g ∘ e) ≤ + weightedMean μ (w ∘ e) ((fun y => f y*g y) ∘ e) at h + simpa only [weightedMean_equiv e he] using h + +end Equivalence + +theorem continuousFKG_subsingleton {X : Type uX} [Subsingleton X] [Nonempty X] + [MeasurableSpace X] [TopologicalSpace X] [Lattice X] + (μ : Measure X) [IsProbabilityMeasure μ] : ContinuousFKG μ := by + intro w _ hp _ f g _ _ _ _ _ _ + let x : X := Classical.choice inferInstance + have hw : w=fun _ => w x := funext fun y => congrArg w (Subsingleton.elim y x) + have hf : f=fun _ => f x := funext fun y => congrArg f (Subsingleton.elim y x) + have hg : g=fun _ => g x := funext fun y => congrArg g (Subsingleton.elim y x) + rw [hw,hf,hg] + simp only [weightedMean,integral_const,probReal_univ,one_smul] + field_simp [(hp x).ne'] + exact le_rfl + +section Finite +variable {A : Type uA} [LinearOrder A] [TopologicalSpace A] [CompactSpace A] + [MeasurableSpace A] [BorelSpace A] [SecondCountableTopology A] + [LocallyCompactSpace A] (μ : Measure A) [IsProbabilityMeasure μ] + +theorem continuousFKG_fin (k : ℕ) : ContinuousFKG (Measure.pi (fun _ : Fin k => μ)) := by + induction k with + | zero => exact continuousFKG_subsingleton _ + | succ k ih => + let e := (MeasurableEquiv.piFinSuccAbove (fun _ : Fin (k+1) => A) 0).symm + have he : MeasurePreserving e (μ.prod (Measure.pi (fun _ : Fin k => μ))) + (Measure.pi (fun _ : Fin (k+1) => μ)) := + (measurePreserving_piFinSuccAbove (fun _ : Fin (k+1) => μ) 0).symm + have ha (p : A×(Fin k → A)) : e p = Fin.cons p.1 p.2 := by + simp [e,MeasurableEquiv.piFinSuccAbove_symm_apply,Fin.insertNthEquiv,Fin.insertNth_zero'] + apply continuousFKG_equiv e he + · apply continuous_pi + intro i + cases i using Fin.cases with + | zero => simpa [ha] using (continuous_fst : Continuous (fun p : A×(Fin k → A) => p.1)) + | succ j => simpa [ha,Function.comp_def] using (continuous_apply j).comp (continuous_snd : Continuous (fun p : A×(Fin k → A) => p.2)) + · intro p q hpq i + cases i using Fin.cases with + | zero => simpa [ha] using hpq.1 + | succ j => simpa [ha] using hpq.2 j + · intro p q + ext i + cases i using Fin.cases <;> simp [ha] + · intro p q + ext i + cases i using Fin.cases <;> simp [ha] + · exact continuousFKG_prod ih + +theorem continuousFKG_pi {ι : Type uι} [Fintype ι] : + ContinuousFKG (Measure.pi (fun _ : ι => μ)) := by + let f := (Fintype.equivFin ι).symm + let e := MeasurableEquiv.piCongrLeft (fun _ : ι => A) f + have ha (u : Fin (Fintype.card ι) → A) (i : ι) : e u i=u (f.symm i) := by + simpa only [e,f.apply_symm_apply] using + MeasurableEquiv.piCongrLeft_apply_apply (β := fun _ : ι => A) f u (f.symm i) + apply continuousFKG_equiv e (measurePreserving_piCongrLeft (fun _ : ι => μ) f) + · apply continuous_pi + intro i + simpa only [ha] using (continuous_apply (f.symm i) : Continuous (fun u : Fin (Fintype.card ι) → A => u (f.symm i))) + · intro u v huv i + simpa only [ha] using huv (f.symm i) + · intro u v; ext i; simp only [ha,Pi.inf_apply] + · intro u v; ext i; simp only [ha,Pi.sup_apply] + · exact continuousFKG_fin μ _ + +end Finite +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FiniteVolume.lean b/lean/OAI/Probability/ClassicalON/FiniteVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..61140b893031c3d44c4bff8c7d5e8a382a2feb8a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FiniteVolume.lean @@ -0,0 +1,1245 @@ +import OAI.Probability.ClassicalON.Model + +namespace OAI + +universe uE uF uR uS uV uΩ + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace + +namespace ClassicalON + +@[simp] theorem spin_norm {n : ℕ} (s : Spin n) : ‖s.val‖ = 1 := by + exact mem_sphere_zero_iff_norm.mp s.property + +instance sphereProbability_isProbability (n : ℕ) [NeZero n] : + IsProbabilityMeasure (sphereProbability n) := by + have hs : (volume : Measure (EuclideanSpace ℝ (Fin n))).toSphere ≠ 0 := + Measure.toSphere_ne_zero _ + constructor + dsimp [sphereProbability] + exact ENNReal.inv_mul_cancel (Measure.measure_univ_eq_zero.not.mpr hs) + (measure_ne_top _ _) + +instance referenceLaw_isProbability (n : ℕ) [NeZero n] (G : LatticeGraph) : + IsProbabilityMeasure (referenceLaw n G) := by + unfold referenceLaw + infer_instance + +theorem continuous_interaction (n : ℕ) (G : LatticeGraph) (b : G.edges → ℝ) : + Continuous (interaction n G b) := by + unfold interaction + fun_prop + +theorem continuous_spinDot (n : ℕ) (G : LatticeGraph) (x y : G.vertices) : + Continuous (fun σ : Configuration n G => ⟪(σ x).val, (σ y).val⟫_ℝ) := by + fun_prop + +theorem integrable_weight (n : ℕ) [NeZero n] (G : LatticeGraph) (b : G.edges → ℝ) : + Integrable (fun σ => Real.exp (interaction n G b σ)) (referenceLaw n G) := by + exact (continuous_interaction n G b).rexp.integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +theorem partition_pos (n : ℕ) [NeZero n] (G : LatticeGraph) (b : G.edges → ℝ) : + 0 < partition n G b := by + unfold partition + apply (integral_pos_iff_support_of_nonneg + (fun σ => (Real.exp_pos _).le) (integrable_weight n G b)).mpr + have hs : Function.support (fun σ => Real.exp (interaction n G b σ)) = Set.univ := by + ext σ + simp [Function.mem_support, Real.exp_ne_zero] + rw [hs, measure_univ] + exact zero_lt_one + +theorem integrable_twoPoint (n : ℕ) [NeZero n] (G : LatticeGraph) + (b : G.edges → ℝ) (x y : G.vertices) : + Integrable (fun σ => ⟪(σ x).val, (σ y).val⟫_ℝ * + Real.exp (interaction n G b σ)) (referenceLaw n G) := by + exact ((continuous_spinDot n G x y).mul (continuous_interaction n G b).rexp).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +@[simp] theorem correlation_self (n : ℕ) [NeZero n] (G : LatticeGraph) + (b : G.edges → ℝ) (x : G.vertices) : correlation n G b x x = 1 := by + unfold correlation + have hd : ∀ σ : Configuration n G, ⟪(σ x).val, (σ x).val⟫_ℝ = 1 := by + intro σ + rw [real_inner_self_eq_norm_sq, spin_norm, one_pow] + simp_rw [hd, one_mul] + exact div_self (partition_pos n G b).ne' + +theorem hasDerivAt_integral_compact + {Ω : Type uΩ} {F : Type uF} [TopologicalSpace Ω] [CompactSpace Ω] [MeasurableSpace Ω] + [OpensMeasurableSpace Ω] [NormedAddCommGroup F] [NormedSpace ℝ F] + (μ : Measure Ω) [IsFiniteMeasure μ] (f fd : ℝ → Ω → F) + (hf : Continuous (Function.uncurry f)) (hfd : Continuous (Function.uncurry fd)) + (hd : ∀ t ω, HasDerivAt (fun u => f u ω) (fd t ω) t) (t : ℝ) : + HasDerivAt (fun u => ∫ ω, f u ω ∂μ) (∫ ω, fd t ω ∂μ) t := by + have hi (u : ℝ) : Integrable (f u) μ := + (hf.comp (continuous_const.prodMk continuous_id)).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + have hdi (u : ℝ) : Integrable (fd u) μ := + (hfd.comp (continuous_const.prodMk continuous_id)).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + obtain ⟨C, hC⟩ := (((isCompact_closedBall t 1).prod + (isCompact_univ : IsCompact (Set.univ : Set Ω))).image hfd).isBounded.exists_norm_le + exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le + (s := Metric.closedBall t 1) (bound := fun _ => C) + (Metric.closedBall_mem_nhds t zero_lt_one) + (Filter.Eventually.of_forall fun u => (hi u).aestronglyMeasurable) + (hi t) (hdi t).aestronglyMeasurable + (Filter.Eventually.of_forall fun ω u hu => hC _ ⟨(u, ω), ⟨hu, Set.mem_univ _⟩, rfl⟩) + (integrable_const C) + (Filter.Eventually.of_forall fun ω u _ => hd u ω)).2 + +def spinRotation {n : ℕ} + (R : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + Spin n ≃ₜ Spin n := + R.toHomeomorph.subtype fun x => by + simp only [mem_sphere_zero_iff_norm] + change ‖x‖ = 1 ↔ ‖R x‖ = 1 + rw [R.norm_map] + +@[simp] theorem spinRotation_val {n : ℕ} + (R : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) (s : Spin n) : + (spinRotation R s).val = R s.val := rfl + +theorem spinRotation_preserves_surface {n : ℕ} + (R : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + MeasurePreserving (spinRotation R) + (volume : Measure (EuclideanSpace ℝ (Fin n))).toSphere + (volume : Measure (EuclideanSpace ℝ (Fin n))).toSphere := by + open scoped Pointwise in + refine ⟨(spinRotation R).measurable, Measure.ext fun s hs => ?_⟩ + rw [Measure.map_apply (spinRotation R).measurable hs, + Measure.toSphere_apply' _ ((spinRotation R).measurable hs), + Measure.toSphere_apply' _ hs] + congr 1 + have hcone : Set.Ioo (0 : ℝ) 1 • (Subtype.val '' ((spinRotation R) ⁻¹' s)) = + R ⁻¹' (Set.Ioo (0 : ℝ) 1 • (Subtype.val '' s)) := by + ext v + constructor + · rintro ⟨r, hr, w, ⟨t, ht, rfl⟩, rfl⟩ + exact ⟨r, hr, R t.val, ⟨spinRotation R t, ht, rfl⟩, (R.map_smul r t.val).symm⟩ + · rintro ⟨r, hr, w, ⟨t, ht, rfl⟩, hv⟩ + refine ⟨r, hr, R.symm t.val, ⟨(spinRotation R).symm t, ?_, rfl⟩, ?_⟩ + · simpa only [Set.mem_preimage, Homeomorph.apply_symm_apply] using ht + · apply R.injective + simpa only [map_smul, LinearIsometryEquiv.apply_symm_apply] using hv + rw [hcone] + have hm := R.toHomeomorph.measurableEmbedding.map_apply + (volume : Measure (EuclideanSpace ℝ (Fin n))) + (Set.Ioo (0 : ℝ) 1 • (Subtype.val '' s)) + change (Measure.map R volume) _ = volume (R ⁻¹' _) at hm + rw [R.measurePreserving.map_eq] at hm + exact hm.symm + +theorem spinRotation_preserves_probability {n : ℕ} + (R : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + MeasurePreserving (spinRotation R) (sphereProbability n) (sphereProbability n) := + (spinRotation_preserves_surface R).smul_measure _ + +def siteReference (n : ℕ) (p : Option (Spin n)) : Measure (Spin n) := + match p with + | none => sphereProbability n + | some s => Measure.dirac s + +instance siteReference_isProbability (n : ℕ) [NeZero n] (p : Option (Spin n)) : + IsProbabilityMeasure (siteReference n p) := by + cases p <;> dsimp [siteReference] <;> infer_instance + +structure SpinSystem (n : ℕ) (V : Type uV) (E : Type uE) where + left : E → V + right : E → V + strength : E → ℝ + pin : V → Option (Spin n) + +abbrev SpinOperator (n : ℕ) := + EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n) + +instance spinOperator_completeSpace (dimension : ℕ) : CompleteSpace (SpinOperator dimension) := + ContinuousLinearMap.instCompleteSpace + +instance spinOperator_ratNormedAlgebra (n : ℕ) : NormedAlgebra ℚ (SpinOperator n) := + NormedAlgebra.restrictScalars ℚ ℝ _ + +def rotationExp {n : ℕ} (A : SpinOperator n) (hA : A ∈ skewAdjoint (SpinOperator n)) : + EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) := + Unitary.linearIsometryEquiv + ⟨NormedSpace.exp A, NormedSpace.exp_mem_unitary_of_mem_skewAdjoint hA⟩ + +@[simp] theorem rotationExp_apply {n : ℕ} (A : SpinOperator n) + (hA : A ∈ skewAdjoint (SpinOperator n)) (v : EuclideanSpace ℝ (Fin n)) : + rotationExp A hA v = NormedSpace.exp A v := rfl + +@[simp] theorem rotationExp_symm_apply {n : ℕ} (A : SpinOperator n) + (hA : A ∈ skewAdjoint (SpinOperator n)) (v : EuclideanSpace ℝ (Fin n)) : + (rotationExp A hA).symm v = NormedSpace.exp (-A) v := by + change (star (NormedSpace.exp A)) v = _ + rw [NormedSpace.star_exp, skewAdjoint.mem_iff.mp hA] + +namespace SpinSystem +variable {n : ℕ} {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def reference (S : SpinSystem n V E) : Measure (V → Spin n) := + Measure.pi (fun x => siteReference n (S.pin x)) + +instance reference_isProbability [NeZero n] (S : SpinSystem n V E) : + IsProbabilityMeasure S.reference := by + unfold reference + infer_instance + +def energy (S : SpinSystem n V E) (K : E → SpinOperator n) (σ : V → Spin n) : ℝ := + ∑ e, S.strength e * ⟪(σ (S.left e)).val, K e (σ (S.right e)).val⟫_ℝ + +def Z (S : SpinSystem n V E) (K : E → SpinOperator n) : ℝ := + ∫ σ, Real.exp (S.energy K σ) ∂S.reference + +omit [Fintype V] in +theorem continuous_energy (S : SpinSystem n V E) (K : E → SpinOperator n) : + Continuous (S.energy K) := by + unfold energy + fun_prop + +theorem integrable_weight [NeZero n] (S : SpinSystem n V E) (K : E → SpinOperator n) : + Integrable (fun σ => Real.exp (S.energy K σ)) S.reference := + (S.continuous_energy K).rexp.integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +theorem Z_pos [NeZero n] (S : SpinSystem n V E) (K : E → SpinOperator n) : + 0 < S.Z K := by + unfold Z + apply (integral_pos_iff_support_of_nonneg + (fun σ => (Real.exp_pos _).le) (S.integrable_weight K)).mpr + have hs : Function.support (fun σ => Real.exp (S.energy K σ)) = Set.univ := by + ext σ + simp [Function.mem_support, Real.exp_ne_zero] + rw [hs, measure_univ] + exact zero_lt_one + +def rotateConfiguration + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + (V → Spin n) ≃ₜ (V → Spin n) := + Homeomorph.piCongrRight (fun x => spinRotation (U x)) + +def rotatePins (S : SpinSystem n V E) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + SpinSystem n V E := + { S with pin := fun x => (S.pin x).map (spinRotation (U x)) } + +def gauge (S : SpinSystem n V E) (K : E → SpinOperator n) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + E → SpinOperator n := + fun e => (U (S.left e)).symm.toContinuousLinearEquiv.toContinuousLinearMap * K e * + (U (S.right e)).toContinuousLinearEquiv.toContinuousLinearMap + +omit [Fintype E] in +theorem rotateConfiguration_preserves_reference [NeZero n] (S : SpinSystem n V E) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + MeasurePreserving (rotateConfiguration U) S.reference (S.rotatePins U).reference := by + change MeasurePreserving (fun σ x => spinRotation (U x) (σ x)) + (Measure.pi (fun x => siteReference n (S.pin x))) + (Measure.pi (fun x => siteReference n ((S.pin x).map (spinRotation (U x))))) + apply measurePreserving_pi + intro x + cases S.pin x with + | none => exact spinRotation_preserves_probability (U x) + | some s => + exact ⟨(spinRotation (U x)).measurable, Measure.map_dirac s⟩ + +omit [Fintype V] in +theorem energy_gauge (S : SpinSystem n V E) (K : E → SpinOperator n) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) + (σ : V → Spin n) : + S.energy (S.gauge K U) σ = (S.rotatePins U).energy K (rotateConfiguration U σ) := by + apply Finset.sum_congr rfl + intro e _ + congr 1 + change ⟪(σ (S.left e)).val, + (U (S.left e)).symm (K e (U (S.right e) (σ (S.right e)).val))⟫_ℝ = + ⟪U (S.left e) (σ (S.left e)).val, K e (U (S.right e) (σ (S.right e)).val)⟫_ℝ + simpa only [LinearIsometryEquiv.apply_symm_apply] using + ((U (S.left e)).inner_map_map (σ (S.left e)).val + ((U (S.left e)).symm (K e (U (S.right e) (σ (S.right e)).val)))).symm + +theorem Z_gauge [NeZero n] (S : SpinSystem n V E) (K : E → SpinOperator n) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + S.Z (S.gauge K U) = (S.rotatePins U).Z K := by + unfold Z + simp_rw [energy_gauge] + exact (S.rotateConfiguration_preserves_reference U).integral_comp + (rotateConfiguration U).measurableEmbedding + (fun σ => Real.exp ((S.rotatePins U).energy K σ)) + +omit [Fintype V] [Fintype E] in + +theorem rotatePins_eq_self (S : SpinSystem n V E) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) + (hU : ∀ x s, S.pin x = some s → spinRotation (U x) s = s) : + S.rotatePins U = S := by + suffices hp : (fun x => (S.pin x).map (spinRotation (U x))) = S.pin by + unfold rotatePins + rw [hp] + funext x + cases h : S.pin x with + | none => rfl + | some s => simp only [Option.map_some, hU x s h] + +theorem Z_gauge_of_fixes_pins [NeZero n] (S : SpinSystem n V E) + (K : E → SpinOperator n) + (U : V → EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) + (hU : ∀ x s, S.pin x = some s → spinRotation (U x) s = s) : + S.Z (S.gauge K U) = S.Z K := by + rw [S.Z_gauge K U, S.rotatePins_eq_self U hU] + +def W (S : SpinSystem n V E) (A : E → SpinOperator n) : ℝ := + S.Z (fun e => NormedSpace.exp (A e)) / S.Z (fun _ => 1) + +@[simp] theorem W_zero [NeZero n] (S : SpinSystem n V E) : S.W 0 = 1 := by + simp only [W, Pi.zero_apply, NormedSpace.exp_zero] + exact div_self (S.Z_pos _).ne' + +def gaugeProduct (S : SpinSystem n V E) (F : V → SpinOperator n) : E → SpinOperator n := + fun e => NormedSpace.exp (F (S.left e)) * + NormedSpace.exp (F (S.right e) - F (S.left e)) * + NormedSpace.exp (-F (S.right e)) + +theorem noncommuting_gauge [NeZero n] (S : SpinSystem n V E) + (F : V → SpinOperator n) (hF : ∀ x, F x ∈ skewAdjoint (SpinOperator n)) + (hP : ∀ x s, S.pin x = some s → F x = 0) : + S.Z (fun e => NormedSpace.exp (F (S.right e) - F (S.left e))) = + S.Z (S.gaugeProduct F) := by + let U := fun x => rotationExp (-F x) ((skewAdjoint _).neg_mem (hF x)) + have hfix : ∀ x s, S.pin x = some s → spinRotation (U x) s = s := by + intro x s hs + apply Subtype.ext + change NormedSpace.exp (-F x) s.val = s.val + rw [hP x s hs, neg_zero, NormedSpace.exp_zero] + rfl + have hg : S.gauge (fun e => NormedSpace.exp (F (S.right e) - F (S.left e))) U = + S.gaugeProduct F := by + funext e + apply ContinuousLinearMap.ext + intro v + change (U (S.left e)).symm + (NormedSpace.exp (F (S.right e) - F (S.left e)) (U (S.right e) v)) = _ + simp only [U, rotationExp_symm_apply, rotationExp_apply, neg_neg, + gaugeProduct, mul_apply_eq_comp] + rw [← hg] + exact (S.Z_gauge_of_fixes_pins _ U hfix).symm + +def twistEnergy (S : SpinSystem n V E) (A : E → SpinOperator n) + (k : ℕ) (t : ℝ) (σ : V → Spin n) : ℝ := + S.energy (fun e => NormedSpace.exp (t • A e) * A e ^ k) σ + +omit [Fintype V] in +theorem continuous_twistEnergy (S : SpinSystem n V E) (A : E → SpinOperator n) + (k : ℕ) : Continuous (Function.uncurry (S.twistEnergy A k)) := by + unfold twistEnergy energy Function.uncurry + fun_prop + +omit [Fintype V] in +theorem hasDerivAt_twistEnergy (S : SpinSystem n V E) (A : E → SpinOperator n) + (k : ℕ) (t : ℝ) (σ : V → Spin n) : + HasDerivAt (fun u => S.twistEnergy A k u σ) (S.twistEnergy A (k+1) t σ) t := by + unfold twistEnergy energy + have he (e : E) : HasDerivAt + (fun u => NormedSpace.exp (u • A e) * A e ^ k) + (NormedSpace.exp (t • A e) * A e ^ (k+1)) t := by + exact ((hasDerivAt_exp_smul_const (A e) t).mul_const (A e ^ k)).congr_deriv + (by rw [pow_succ', mul_assoc]) + apply HasDerivAt.fun_sum + intro e _ + exact (((hasDerivAt_const t (σ (S.left e)).val).inner ℝ + ((he e).clm_apply (hasDerivAt_const t (σ (S.right e)).val))).const_mul + (S.strength e)).congr_deriv (by simp) + +def firstWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : ℝ := + Real.exp (S.twistEnergy A 0 t σ) * S.twistEnergy A 1 t σ + +def secondWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : ℝ := + Real.exp (S.twistEnergy A 0 t σ) * + (S.twistEnergy A 2 t σ + (S.twistEnergy A 1 t σ)^2) + +omit [Fintype V] in +theorem continuous_firstWeight (S : SpinSystem n V E) (A : E → SpinOperator n) : + Continuous (Function.uncurry (S.firstWeight A)) := by + exact (S.continuous_twistEnergy A 0).rexp.mul (S.continuous_twistEnergy A 1) + +omit [Fintype V] in +theorem continuous_secondWeight (S : SpinSystem n V E) (A : E → SpinOperator n) : + Continuous (Function.uncurry (S.secondWeight A)) := by + exact (S.continuous_twistEnergy A 0).rexp.mul + ((S.continuous_twistEnergy A 2).add ((S.continuous_twistEnergy A 1).pow 2)) + +omit [Fintype V] in +theorem hasDerivAt_weight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : + HasDerivAt (fun u => Real.exp (S.twistEnergy A 0 u σ)) (S.firstWeight A t σ) t := by + exact (S.hasDerivAt_twistEnergy A 0 t σ).exp + +omit [Fintype V] in +theorem hasDerivAt_firstWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : + HasDerivAt (fun u => S.firstWeight A u σ) (S.secondWeight A t σ) t := by + exact ((S.hasDerivAt_weight A t σ).mul (S.hasDerivAt_twistEnergy A 1 t σ)).congr_deriv + (by unfold firstWeight secondWeight; ring) + +theorem hasDerivAt_twistZ [NeZero n] (S : SpinSystem n V E) + (A : E → SpinOperator n) (t : ℝ) : + HasDerivAt (fun u => S.Z (fun e => NormedSpace.exp (u • A e))) + (∫ σ, S.firstWeight A t σ ∂S.reference) t := by + simpa only [twistEnergy, pow_zero, mul_one, Z] using + hasDerivAt_integral_compact S.reference + (fun u σ => Real.exp (S.twistEnergy A 0 u σ)) (S.firstWeight A) + (S.continuous_twistEnergy A 0).rexp (S.continuous_firstWeight A) + (S.hasDerivAt_weight A) t + +theorem hasDerivAt_firstVariation [NeZero n] (S : SpinSystem n V E) + (A : E → SpinOperator n) (t : ℝ) : + HasDerivAt (fun u => ∫ σ, S.firstWeight A u σ ∂S.reference) + (∫ σ, S.secondWeight A t σ ∂S.reference) t := + hasDerivAt_integral_compact S.reference (S.firstWeight A) (S.secondWeight A) + (S.continuous_firstWeight A) (S.continuous_secondWeight A) + (S.hasDerivAt_firstWeight A) t + +def thirdWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : ℝ := + Real.exp (S.twistEnergy A 0 t σ) * + (S.twistEnergy A 3 t σ + 3 * S.twistEnergy A 1 t σ * S.twistEnergy A 2 t σ + + (S.twistEnergy A 1 t σ)^3) + +def fourthWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : ℝ := + Real.exp (S.twistEnergy A 0 t σ) * + (S.twistEnergy A 4 t σ + 4 * S.twistEnergy A 1 t σ * S.twistEnergy A 3 t σ + + 3 * (S.twistEnergy A 2 t σ)^2 + + 6 * (S.twistEnergy A 1 t σ)^2 * S.twistEnergy A 2 t σ + + (S.twistEnergy A 1 t σ)^4) + +omit [Fintype V] in +theorem continuous_thirdWeight (S : SpinSystem n V E) (A : E → SpinOperator n) : + Continuous (Function.uncurry (S.thirdWeight A)) := by + exact (S.continuous_twistEnergy A 0).rexp.mul + (((S.continuous_twistEnergy A 3).add + (((S.continuous_twistEnergy A 1).const_mul 3).mul + (S.continuous_twistEnergy A 2))).add ((S.continuous_twistEnergy A 1).pow 3)) + +omit [Fintype V] in +theorem continuous_fourthWeight (S : SpinSystem n V E) (A : E → SpinOperator n) : + Continuous (Function.uncurry (S.fourthWeight A)) := by + exact (S.continuous_twistEnergy A 0).rexp.mul + (((((S.continuous_twistEnergy A 4).add + (((S.continuous_twistEnergy A 1).const_mul 4).mul + (S.continuous_twistEnergy A 3))).add + (((S.continuous_twistEnergy A 2).pow 2).const_mul 3)).add + ((((S.continuous_twistEnergy A 1).pow 2).const_mul 6).mul + (S.continuous_twistEnergy A 2))).add ((S.continuous_twistEnergy A 1).pow 4)) + +omit [Fintype V] in +theorem hasDerivAt_secondWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : + HasDerivAt (fun u => S.secondWeight A u σ) (S.thirdWeight A t σ) t := by + exact ((S.hasDerivAt_weight A t σ).mul + ((S.hasDerivAt_twistEnergy A 2 t σ).add + ((S.hasDerivAt_twistEnergy A 1 t σ).pow 2))).congr_deriv + (by dsimp [firstWeight, thirdWeight]; ring) + +omit [Fintype V] in +theorem hasDerivAt_thirdWeight (S : SpinSystem n V E) (A : E → SpinOperator n) + (t : ℝ) (σ : V → Spin n) : + HasDerivAt (fun u => S.thirdWeight A u σ) (S.fourthWeight A t σ) t := by + exact ((S.hasDerivAt_weight A t σ).mul + (((S.hasDerivAt_twistEnergy A 3 t σ).add + (((S.hasDerivAt_twistEnergy A 1 t σ).const_mul 3).mul + (S.hasDerivAt_twistEnergy A 2 t σ))).add + ((S.hasDerivAt_twistEnergy A 1 t σ).pow 3))).congr_deriv + (by dsimp [firstWeight, fourthWeight]; ring) + +theorem hasDerivAt_secondVariation [NeZero n] (S : SpinSystem n V E) + (A : E → SpinOperator n) (t : ℝ) : + HasDerivAt (fun u => ∫ σ, S.secondWeight A u σ ∂S.reference) + (∫ σ, S.thirdWeight A t σ ∂S.reference) t := + hasDerivAt_integral_compact S.reference (S.secondWeight A) (S.thirdWeight A) + (S.continuous_secondWeight A) (S.continuous_thirdWeight A) + (S.hasDerivAt_secondWeight A) t + +theorem hasDerivAt_thirdVariation [NeZero n] (S : SpinSystem n V E) + (A : E → SpinOperator n) (t : ℝ) : + HasDerivAt (fun u => ∫ σ, S.thirdWeight A u σ ∂S.reference) + (∫ σ, S.fourthWeight A t σ ∂S.reference) t := + hasDerivAt_integral_compact S.reference (S.thirdWeight A) (S.fourthWeight A) + (S.continuous_thirdWeight A) (S.continuous_fourthWeight A) + (S.hasDerivAt_thirdWeight A) t + +omit [Fintype V] [Fintype E] in + +theorem exp_smul_add (g : SpinOperator n) (r s : ℝ) : + NormedSpace.exp ((r+s) • g) = NormedSpace.exp (r • g) * NormedSpace.exp (s • g) := by + rw [add_smul r s g] + apply NormedSpace.exp_add_of_commute + change (r • g) * (s • g) = (s • g) * (r • g) + rw [Algebra.smul_mul_assoc r g (s • g), Algebra.mul_smul_comm s g g, + smul_smul r s (g*g), Algebra.smul_mul_assoc s g (r • g), + Algebra.mul_smul_comm r g g, smul_smul s r (g*g), mul_comm r s] + +theorem W_add_gradient [NeZero n] (S : SpinSystem n V E) (g : SpinOperator n) + (hg : g ∈ skewAdjoint (SpinOperator n)) (h : E → ℝ) (f : V → ℝ) + (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.W (fun e => (h e + f (S.right e) - f (S.left e)) • g) = + S.W (fun e => h e • g) := by + let U := fun x => rotationExp (-(f x • g)) ((skewAdjoint _).neg_mem (skewAdjoint.smul_mem _ hg)) + have hfix : ∀ x s, S.pin x = some s → spinRotation (U x) s = s := by + intro x s hs + apply Subtype.ext + change NormedSpace.exp (-(f x • g)) s.val = s.val + rw [hP x s hs, zero_smul ℝ g, neg_zero, NormedSpace.exp_zero] + rfl + have hK : S.gauge + (fun e => NormedSpace.exp ((h e + f (S.right e) - f (S.left e)) • g)) U = + (fun e => NormedSpace.exp (h e • g)) := by + funext e + apply ContinuousLinearMap.ext + intro v + change (U (S.left e)).symm + (NormedSpace.exp ((h e + f (S.right e) - f (S.left e)) • g) + (U (S.right e) v)) = _ + simp only [U, rotationExp_symm_apply, rotationExp_apply, neg_neg] + rw [← mul_apply_eq_comp, ← mul_apply_eq_comp, ← neg_smul (f (S.right e)) g, + ← exp_smul_add, + ← exp_smul_add] + have hc : f (S.left e) + (h e + f (S.right e) - f (S.left e)) + -f (S.right e) = + h e := by ring + rw [hc] + unfold W + congr 1 + rw [← hK] + exact (S.Z_gauge_of_fixes_pins _ U hfix).symm + +theorem W_gradient [NeZero n] (S : SpinSystem n V E) (g : SpinOperator n) + (hg : g ∈ skewAdjoint (SpinOperator n)) (f : V → ℝ) + (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.W (fun e => (f (S.right e) - f (S.left e)) • g) = 1 := by + have h := S.W_add_gradient g hg 0 f hP + simp only [Pi.zero_apply, zero_add, zero_smul ℝ g] at h + exact h.trans (S.W_zero) + +def average (S : SpinSystem n V E) (f : (V → Spin n) → ℝ) : ℝ := + (∫ σ, f σ * Real.exp (S.energy (fun _ => 1) σ) ∂S.reference) / S.Z (fun _ => 1) + +theorem integrable_average_integrand [NeZero n] (S : SpinSystem n V E) + {f : (V → Spin n) → ℝ} (hf : Continuous f) : + Integrable (fun σ => f σ * Real.exp (S.energy (fun _ => 1) σ)) S.reference := + (hf.mul (S.continuous_energy _).rexp).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +@[simp] theorem average_const [NeZero n] (S : SpinSystem n V E) (c : ℝ) : + S.average (fun _ => c) = c := by + unfold average + rw [integral_const_mul] + change c * S.Z (fun _ => 1) / S.Z (fun _ => 1) = c + exact mul_div_cancel_right₀ c (S.Z_pos _).ne' + +theorem average_add [NeZero n] (S : SpinSystem n V E) + {f g : (V → Spin n) → ℝ} (hf : Continuous f) (hg : Continuous g) : + S.average (f+g) = S.average f + S.average g := by + unfold average + simp only [Pi.add_apply, add_mul] + rw [integral_add (S.integrable_average_integrand hf) + (S.integrable_average_integrand hg), add_div] + +theorem average_mono [NeZero n] (S : SpinSystem n V E) + {f g : (V → Spin n) → ℝ} (hf : Continuous f) (hg : Continuous g) + (hfg : ∀ σ, f σ ≤ g σ) : S.average f ≤ S.average g := by + apply div_le_div_of_nonneg_right _ (S.Z_pos _).le + apply integral_mono (S.integrable_average_integrand hf) (S.integrable_average_integrand hg) + intro σ + exact mul_le_mul_of_nonneg_right (hfg σ) (Real.exp_pos _).le + +theorem average_nonneg [NeZero n] (S : SpinSystem n V E) + {f : (V → Spin n) → ℝ} (hf : ∀ σ, 0 ≤ f σ) : 0 ≤ S.average f := + div_nonneg (integral_nonneg fun σ => mul_nonneg (hf σ) (Real.exp_pos _).le) (S.Z_pos _).le + +omit [Fintype V] [Fintype E] in + +def axisGradient (S : SpinSystem n V E) (f : V → ℝ) (g : SpinOperator n) : E → SpinOperator n := + fun e => (f (S.right e) - f (S.left e)) • g + +theorem Z_gradient_line [NeZero n] (S : SpinSystem n V E) (g : SpinOperator n) + (hg : g ∈ skewAdjoint (SpinOperator n)) (f : V → ℝ) + (hP : ∀ x s, S.pin x = some s → f x = 0) (t : ℝ) : + S.Z (fun e => NormedSpace.exp (t • S.axisGradient f g e)) = S.Z (fun _ => 1) := by + have hp : ∀ x s, S.pin x = some s → t * f x = 0 := by + intro x s hs + rw [hP x s hs, mul_zero] + have h := S.W_gradient g hg (fun x => t * f x) hp + unfold W at h + have ha : (fun e => (t * f (S.right e) - t * f (S.left e)) • g) = + (fun e => t • S.axisGradient f g e) := by + funext e + simp only [axisGradient, smul_smul, mul_sub] + rw [ha] at h + exact (div_eq_one_iff_eq (S.Z_pos _).ne').mp h + +theorem second_gradient_identity [NeZero n] (S : SpinSystem n V E) (g : SpinOperator n) + (hg : g ∈ skewAdjoint (SpinOperator n)) (f : V → ℝ) + (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.average (fun σ => S.energy (fun e => S.axisGradient f g e ^ 2) σ + + (S.energy (S.axisGradient f g) σ)^2) = 0 := by + let A := S.axisGradient f g + have hZ : (fun t => S.Z (fun e => NormedSpace.exp (t • A e))) = + (fun _ : ℝ => S.Z (fun _ => 1)) := funext (S.Z_gradient_line g hg f hP) + have hfirst : (fun t => ∫ σ, S.firstWeight A t σ ∂S.reference) = (fun _ : ℝ => 0) := by + funext t + have h := S.hasDerivAt_twistZ A t + rw [hZ] at h + exact h.unique (hasDerivAt_const t _) + have hsecond : (∫ σ, S.secondWeight A 0 σ ∂S.reference) = 0 := by + have h := S.hasDerivAt_firstVariation A 0 + rw [hfirst] at h + exact h.unique (hasDerivAt_const 0 0) + unfold average + have hfun : (fun σ => (S.energy (fun e => A e ^ 2) σ + (S.energy A σ)^2) * + Real.exp (S.energy (fun _ => 1) σ)) = (fun σ => S.secondWeight A 0 σ) := by + funext σ + have hz (e : E) : (0:ℝ) • A e = 0 := zero_smul ℝ (A e) + simp only [secondWeight, twistEnergy, hz, NormedSpace.exp_zero, one_mul, + pow_zero, pow_one] + exact mul_comm _ _ + change (∫ σ, (S.energy (fun e => A e ^ 2) σ + (S.energy A σ)^2) * + Real.exp (S.energy (fun _ => 1) σ) ∂S.reference) / S.Z (fun _ => 1) = 0 + rw [hfun, hsecond, zero_div] + +omit [Fintype V] in + +theorem abs_energy_le (S : SpinSystem n V E) (K : E → SpinOperator n) + (σ : V → Spin n) : |S.energy K σ| ≤ ∑ e, |S.strength e| * ‖K e‖ := by + unfold energy + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro e _ + rw [abs_mul] + apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) + calc + |⟪(σ (S.left e)).val, K e (σ (S.right e)).val⟫_ℝ| ≤ + ‖(σ (S.left e)).val‖ * ‖K e (σ (S.right e)).val‖ := abs_real_inner_le_norm _ _ + _ ≤ ‖(σ (S.left e)).val‖ * (‖K e‖ * ‖(σ (S.right e)).val‖) := + mul_le_mul_of_nonneg_left ((K e).le_opNorm _) (norm_nonneg _) + _ = ‖K e‖ := by simp + +omit [Fintype V] in + +theorem abs_axis_secondEnergy_le (S : SpinSystem n V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (h : E → ℝ) (g : SpinOperator n) (hg : ‖g‖ ≤ 1) (σ : V → Spin n) : + |S.energy (fun e => (h e • g)^2) σ| ≤ β * ∑ e, (h e)^2 := by + apply (S.abs_energy_le _ σ).trans + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro e _ + rw [abs_of_nonneg (hb e).1] + have hA : ‖h e • g‖ ≤ |h e| := by + rw [norm_smul (h e) g, Real.norm_eq_abs] + exact mul_le_of_le_one_right (abs_nonneg _) hg + have hp : ‖(h e • g)^2‖ ≤ (h e)^2 := by + calc + ‖(h e • g)^2‖ ≤ ‖h e • g‖^2 := by simpa only [pow_two] using norm_mul_le (h e • g) (h e • g) + _ ≤ |h e|^2 := pow_le_pow_left₀ (norm_nonneg _) hA 2 + _ = (h e)^2 := sq_abs _ + exact mul_le_mul (hb e).2 hp (norm_nonneg _) ((hb e).1.trans (hb e).2) + +theorem gradient_current_bound [NeZero n] (S : SpinSystem n V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (g : SpinOperator n) (hg : g ∈ skewAdjoint (SpinOperator n)) (hgn : ‖g‖ ≤ 1) + (f : V → ℝ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.average (fun σ => (S.energy (S.axisGradient f g) σ)^2) ≤ + β * ∑ e, (f (S.right e) - f (S.left e))^2 := by + let A := S.axisGradient f g + let C := β * ∑ e, (f (S.right e) - f (S.left e))^2 + have hc1 := (S.continuous_energy A).pow 2 + have hc2 := (S.continuous_energy (fun e => A e^2)).add hc1 + have hbound (σ : V → Spin n) : (S.energy A σ)^2 ≤ + (S.energy (fun e => A e^2) σ + (S.energy A σ)^2) + C := by + have hh := (abs_le.mp (S.abs_axis_secondEnergy_le β hb + (fun e => f (S.right e) - f (S.left e)) g hgn σ)).1 + change -C ≤ S.energy (fun e => A e^2) σ at hh + linarith + have h := S.average_mono hc1 (hc2.add continuous_const) hbound + rw [S.average_add hc2 continuous_const, S.average_const] at h + have hi := S.second_gradient_identity g hg f hP + change S.average (fun σ => S.energy (fun e => A e^2) σ + (S.energy A σ)^2) = 0 at hi + change S.average (fun σ => (S.energy A σ)^2) ≤ + S.average (fun σ => S.energy (fun e => A e^2) σ + (S.energy A σ)^2) + C at h + rw [hi, zero_add] at h + exact h + +end SpinSystem + +def fourthBell {Ω : Type uΩ} (F : ℕ → ℝ → Ω → ℝ) (t : ℝ) (ω : Ω) : ℝ := + Real.exp (F 0 t ω) * (F 4 t ω + 4 * F 1 t ω * F 3 t ω + 3 * (F 2 t ω)^2 + + 6 * (F 1 t ω)^2 * F 2 t ω + (F 1 t ω)^4) + +theorem iteratedDeriv_four_integral_exp + {Ω : Type uΩ} [TopologicalSpace Ω] [CompactSpace Ω] [MeasurableSpace Ω] + [OpensMeasurableSpace Ω] (μ : Measure Ω) [IsFiniteMeasure μ] + (F : ℕ → ℝ → Ω → ℝ) + (hC : ∀ k, Continuous (Function.uncurry (F k))) + (hD : ∀ k t ω, HasDerivAt (fun u => F k u ω) (F (k+1) t ω) t) (t : ℝ) : + iteratedDeriv 4 (fun u => ∫ ω, Real.exp (F 0 u ω) ∂μ) t = + ∫ ω, fourthBell F t ω ∂μ := by + let w0 := fun u ω => Real.exp (F 0 u ω) + let w1 := fun u ω => Real.exp (F 0 u ω) * F 1 u ω + let w2 := fun u ω => Real.exp (F 0 u ω) * (F 2 u ω + (F 1 u ω)^2) + let w3 := fun u ω => Real.exp (F 0 u ω) * + (F 3 u ω + 3 * F 1 u ω * F 2 u ω + (F 1 u ω)^3) + let w4 := fourthBell F + have c0 : Continuous (Function.uncurry w0) := (hC 0).rexp + have c1 : Continuous (Function.uncurry w1) := (hC 0).rexp.mul (hC 1) + have c2 : Continuous (Function.uncurry w2) := + (hC 0).rexp.mul ((hC 2).add ((hC 1).pow 2)) + have c3 : Continuous (Function.uncurry w3) := (hC 0).rexp.mul + (((hC 3).add (((hC 1).const_mul 3).mul (hC 2))).add ((hC 1).pow 3)) + have c4 : Continuous (Function.uncurry w4) := (hC 0).rexp.mul + (((((hC 4).add (((hC 1).const_mul 4).mul (hC 3))).add + (((hC 2).pow 2).const_mul 3)).add ((((hC 1).pow 2).const_mul 6).mul + (hC 2))).add ((hC 1).pow 4)) + have d0 (u : ℝ) (ω : Ω) : HasDerivAt (fun v => w0 v ω) (w1 u ω) u := (hD 0 u ω).exp + have d1 (u : ℝ) (ω : Ω) : HasDerivAt (fun v => w1 v ω) (w2 u ω) u := + ((d0 u ω).mul (hD 1 u ω)).congr_deriv (by dsimp [w0, w1, w2]; ring) + have d2 (u : ℝ) (ω : Ω) : HasDerivAt (fun v => w2 v ω) (w3 u ω) u := + ((d0 u ω).mul ((hD 2 u ω).add ((hD 1 u ω).pow 2))).congr_deriv + (by dsimp [w0, w1, w3]; ring) + have d3 (u : ℝ) (ω : Ω) : HasDerivAt (fun v => w3 v ω) (w4 u ω) u := + ((d0 u ω).mul (((hD 3 u ω).add (((hD 1 u ω).const_mul 3).mul + (hD 2 u ω))).add ((hD 1 u ω).pow 3))).congr_deriv + (by dsimp [w0, w1, w4, fourthBell]; ring) + have e0 : deriv (fun u => ∫ ω, w0 u ω ∂μ) = (fun u => ∫ ω, w1 u ω ∂μ) := + funext fun u => (hasDerivAt_integral_compact μ w0 w1 c0 c1 d0 u).deriv + have e1 : deriv (fun u => ∫ ω, w1 u ω ∂μ) = (fun u => ∫ ω, w2 u ω ∂μ) := + funext fun u => (hasDerivAt_integral_compact μ w1 w2 c1 c2 d1 u).deriv + have e2 : deriv (fun u => ∫ ω, w2 u ω ∂μ) = (fun u => ∫ ω, w3 u ω ∂μ) := + funext fun u => (hasDerivAt_integral_compact μ w2 w3 c2 c3 d2 u).deriv + have e3 : deriv (fun u => ∫ ω, w3 u ω ∂μ) = (fun u => ∫ ω, w4 u ω ∂μ) := + funext fun u => (hasDerivAt_integral_compact μ w3 w4 c3 c4 d3 u).deriv + change iteratedDeriv 4 (fun u => ∫ ω, w0 u ω ∂μ) t = ∫ ω, w4 t ω ∂μ + simp only [iteratedDeriv_succ, iteratedDeriv_zero, e0, e1, e2, e3] + +def expPower {n : ℕ} (X : SpinOperator n) (a : ℕ) (t : ℝ) : SpinOperator n := + NormedSpace.exp (t • X) * X^a + +theorem hasDerivAt_expPower {n : ℕ} (X : SpinOperator n) (a : ℕ) (t : ℝ) : + HasDerivAt (expPower X a) (expPower X (a+1) t) t := by + exact ((hasDerivAt_exp_smul_const X t).mul_const (X^a)).congr_deriv + (by simp only [expPower, pow_succ', mul_assoc]) + +theorem continuous_expPower {n : ℕ} (X : SpinOperator n) (a : ℕ) : + Continuous (expPower X a) := by + unfold expPower + fun_prop + +def tripleJet {n : ℕ} (X Y Z : SpinOperator n) : ℕ → ℕ → ℕ → ℕ → ℝ → SpinOperator n + | 0, a, b, c, t => expPower X a t * expPower Y b t * expPower Z c t + | k+1, a, b, c, t => tripleJet X Y Z k (a+1) b c t + + tripleJet X Y Z k a (b+1) c t + tripleJet X Y Z k a b (c+1) t + +theorem continuous_tripleJet {n : ℕ} (X Y Z : SpinOperator n) + (k a b c : ℕ) : Continuous (tripleJet X Y Z k a b c) := by + induction k generalizing a b c with + | zero => exact ((continuous_expPower X a).mul (continuous_expPower Y b)).mul (continuous_expPower Z c) + | succ k ih => exact ((ih (a+1) b c).add (ih a (b+1) c)).add (ih a b (c+1)) + +theorem hasDerivAt_tripleJet {n : ℕ} (X Y Z : SpinOperator n) + (k a b c : ℕ) (t : ℝ) : + HasDerivAt (tripleJet X Y Z k a b c) (tripleJet X Y Z (k+1) a b c t) t := by + induction k generalizing a b c with + | zero => + exact (((hasDerivAt_expPower X a t).mul (hasDerivAt_expPower Y b t)).mul + (hasDerivAt_expPower Z c t)).congr_deriv (by dsimp [tripleJet]; rw [add_mul, add_assoc]) + | succ k ih => exact ((ih (a+1) b c).add (ih a (b+1) c)).add (ih a b (c+1)) + +@[simp] theorem expPower_zero {n : ℕ} (X : SpinOperator n) (a : ℕ) : + expPower X a 0 = X^a := by + rw [expPower, zero_smul ℝ X, NormedSpace.exp_zero, one_mul] + +theorem gaugeJets_zero_one {n : ℕ} (X Y : SpinOperator n) : + tripleJet X (Y-X) (-Y) 0 0 0 0 0 = 1 ∧ + tripleJet X (Y-X) (-Y) 1 0 0 0 0 = 0 := by + simp [tripleJet] + +theorem gaugeJet_two {n : ℕ} (X Y : SpinOperator n) : + tripleJet X (Y-X) (-Y) 2 0 0 0 0 = X*Y-Y*X := by + apply ContinuousLinearMap.ext + intro v + simp only [tripleJet, expPower_zero, Nat.reduceAdd, pow_zero, pow_one, one_mul, mul_one, pow_two, + add_apply, sub_apply, neg_apply, mul_apply_eq_comp, map_sub, map_neg] + abel + +namespace SpinSystem +variable {n : ℕ} {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def gaugeEnergy (S : SpinSystem n V E) (F : V → SpinOperator n) + (k : ℕ) (t : ℝ) (σ : V → Spin n) : ℝ := + S.energy (fun e => tripleJet (F (S.left e)) + (F (S.right e)-F (S.left e)) (-F (S.right e)) k 0 0 0 t) σ + +omit [Fintype V] in +theorem continuous_gaugeEnergy (S : SpinSystem n V E) (F : V → SpinOperator n) (k : ℕ) : + Continuous (Function.uncurry (S.gaugeEnergy F k)) := by + unfold gaugeEnergy energy + apply continuous_finsetSum + intro e _ + exact continuous_const.mul + (((continuous_apply (S.left e)).comp continuous_snd).subtype_val.inner + (((continuous_tripleJet _ _ _ k 0 0 0).comp continuous_fst).clm_apply + (((continuous_apply (S.right e)).comp continuous_snd).subtype_val))) + +omit [Fintype V] in +theorem hasDerivAt_gaugeEnergy (S : SpinSystem n V E) (F : V → SpinOperator n) + (k : ℕ) (t : ℝ) (σ : V → Spin n) : + HasDerivAt (fun u => S.gaugeEnergy F k u σ) (S.gaugeEnergy F (k+1) t σ) t := by + unfold gaugeEnergy energy + apply HasDerivAt.fun_sum + intro e _ + exact (((hasDerivAt_const t (σ (S.left e)).val).inner ℝ + ((hasDerivAt_tripleJet _ _ _ k 0 0 0 t).clm_apply + (hasDerivAt_const t (σ (S.right e)).val))).const_mul + (S.strength e)).congr_deriv (by simp) + +omit [Fintype V] in +@[simp] theorem energy_zero (S : SpinSystem n V E) (σ : V → Spin n) : + S.energy 0 σ = 0 := by simp [energy] + +omit [Fintype V] in +theorem gaugeEnergy_at_zero (S : SpinSystem n V E) (F : V → SpinOperator n) + (σ : V → Spin n) : + S.gaugeEnergy F 0 0 σ = S.energy (fun _ => 1) σ ∧ + S.gaugeEnergy F 1 0 σ = 0 ∧ + S.gaugeEnergy F 2 0 σ = S.energy + (fun e => F (S.left e)*F (S.right e)-F (S.right e)*F (S.left e)) σ := by + have h0 := fun e => (gaugeJets_zero_one (F (S.left e)) (F (S.right e))).1 + have h1 := fun e => (gaugeJets_zero_one (F (S.left e)) (F (S.right e))).2 + simp only [gaugeEnergy, h0, h1, gaugeJet_two] + exact ⟨True.intro, S.energy_zero σ, True.intro⟩ + +theorem fourth_noncommuting_identity [NeZero n] (S : SpinSystem n V E) + (F : V → SpinOperator n) (hF : ∀ x, F x ∈ skewAdjoint (SpinOperator n)) + (hP : ∀ x s, S.pin x = some s → F x = 0) : + (∫ σ, S.fourthWeight (fun e => F (S.right e)-F (S.left e)) 0 σ ∂S.reference) = + ∫ σ, Real.exp (S.energy (fun _ => 1) σ) * + (S.gaugeEnergy F 4 0 σ + 3 * (S.energy + (fun e => F (S.left e)*F (S.right e)-F (S.right e)*F (S.left e)) σ)^2) + ∂S.reference := by + let A : E → SpinOperator n := fun e => F (S.right e)-F (S.left e) + have heq : (fun t => ∫ σ, Real.exp (S.twistEnergy A 0 t σ) ∂S.reference) = + (fun t => ∫ σ, Real.exp (S.gaugeEnergy F 0 t σ) ∂S.reference) := by + funext t + have htP : ∀ x s, S.pin x = some s → t • F x = 0 := by + intro x s hs + rw [hP x s hs] + exact smul_zero (M := ℝ) (A := SpinOperator n) t + have h := S.noncommuting_gauge (fun x => t • F x) + (fun x => skewAdjoint.smul_mem t (hF x)) htP + have hd (e : E) : t • F (S.right e) - t • F (S.left e) = t • A e := + (smul_sub t (F (S.right e)) (F (S.left e))).symm + have hGP : S.gaugeProduct (fun x => t • F x) = + (fun e => tripleJet (F (S.left e)) (F (S.right e)-F (S.left e)) + (-F (S.right e)) 0 0 0 0 t) := by + funext e + change NormedSpace.exp (t • F (S.left e)) * + NormedSpace.exp (t • F (S.right e) - t • F (S.left e)) * + NormedSpace.exp (-(t • F (S.right e))) = _ + rw [hd] + simp only [tripleJet, expPower, pow_zero, mul_one] + rw [smul_neg t (F (S.right e))] + rw [hGP] at h + simpa only [Z, twistEnergy, pow_zero, mul_one, gaugeEnergy, hd] using h + have hl := iteratedDeriv_four_integral_exp S.reference (S.twistEnergy A) + (S.continuous_twistEnergy A) (S.hasDerivAt_twistEnergy A) 0 + have hr := iteratedDeriv_four_integral_exp S.reference (S.gaugeEnergy F) + (S.continuous_gaugeEnergy F) (S.hasDerivAt_gaugeEnergy F) 0 + rw [heq, hr] at hl + refine hl.symm.trans (integral_congr_ae (Filter.Eventually.of_forall ?_)) + intro σ + have hz := S.gaugeEnergy_at_zero F σ + simp [fourthBell, hz.1, hz.2.1, hz.2.2] + +end SpinSystem + +open scoped Matrix + +def matrixOperator {n : ℕ} : Matrix (Fin n) (Fin n) ℝ ≃ₐ[ℝ] SpinOperator n := + (Matrix.toLinAlgEquiv (PiLp.basisFun 2 ℝ (Fin n))).trans + (Module.End.toContinuousLinearMap (EuclideanSpace ℝ (Fin n))) +theorem matrixOperator_apply {n : ℕ} (M : Matrix (Fin n) (Fin n) ℝ) + (v : EuclideanSpace ℝ (Fin n)) : + matrixOperator M v = WithLp.toLp 2 (M *ᵥ v.ofLp) := by + change (Matrix.toLin (PiLp.basisFun 2 ℝ (Fin n)) (PiLp.basisFun 2 ℝ (Fin n)) M) v = _ + rw [← Matrix.toLpLin_eq_toLin, Matrix.toLpLin_apply] + +def axisMatrixA : Matrix (Fin 3) (Fin 3) ℝ := !![0,0,0; 0,0,-1; 0,1,0] +def axisMatrixB : Matrix (Fin 3) (Fin 3) ℝ := !![0,0,1; 0,0,0; -1,0,0] +def axisMatrixC : Matrix (Fin 3) (Fin 3) ℝ := !![0,-1,0; 1,0,0; 0,0,0] +def axisA : SpinOperator 3 := matrixOperator axisMatrixA +def axisB : SpinOperator 3 := matrixOperator axisMatrixB +def axisC : SpinOperator 3 := matrixOperator axisMatrixC + +theorem axisA_apply (v : EuclideanSpace ℝ (Fin 3)) : + axisA v = WithLp.toLp 2 ![0, -v 2, v 1] := by + rw [axisA, matrixOperator_apply] + congr 1 + ext i + fin_cases i <;> simp [axisMatrixA, Matrix.mulVec, dotProduct, Fin.sum_univ_succ] + +theorem matrixOperator_star {n : ℕ} (M : Matrix (Fin n) (Fin n) ℝ) : + star (matrixOperator M) = matrixOperator M.transpose := by + apply ContinuousLinearMap.ext + intro x + apply ext_inner_left ℝ + intro y + rw [ContinuousLinearMap.star_eq_adjoint, ContinuousLinearMap.adjoint_inner_right, + matrixOperator_apply, matrixOperator_apply] + simp only [EuclideanSpace.inner_eq_star_dotProduct, star_trivial] + rw [Matrix.dotProduct_mulVec, Matrix.mulVec_transpose] + +theorem axisA_skew : axisA ∈ skewAdjoint (SpinOperator 3) := by + rw [skewAdjoint.mem_iff, axisA, matrixOperator_star, ← map_neg] + congr 1 + ext i j + fin_cases i <;> fin_cases j <;> norm_num [axisMatrixA] + +theorem axisA_norm_le : ‖axisA‖ ≤ 1 := by + apply axisA.opNorm_le_bound zero_le_one + intro v + rw [one_mul] + apply nonneg_le_nonneg_of_sq_le_sq (norm_nonneg _) + simp only [← pow_two] + rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq, axisA_apply] + simp [Fin.sum_univ_three, Matrix.cons_val_two] + nlinarith [sq_nonneg ‖v.ofLp 0‖] + +theorem axisB_skew : axisB ∈ skewAdjoint (SpinOperator 3) := by + rw [skewAdjoint.mem_iff, axisB, matrixOperator_star, ← map_neg] + congr 1 + ext i j + fin_cases i <;> fin_cases j <;> norm_num [axisMatrixB] + +theorem axisC_skew : axisC ∈ skewAdjoint (SpinOperator 3) := by + rw [skewAdjoint.mem_iff, axisC, matrixOperator_star, ← map_neg] + congr 1 + ext i j + fin_cases i <;> fin_cases j <;> norm_num [axisMatrixC] + +theorem axisB_apply (v : EuclideanSpace ℝ (Fin 3)) : + axisB v = WithLp.toLp 2 ![v 2, 0, -v 0] := by + rw [axisB, matrixOperator_apply] + congr 1 + ext i + fin_cases i <;> simp [axisMatrixB, Matrix.mulVec, dotProduct, Fin.sum_univ_succ] + +theorem axisC_apply (v : EuclideanSpace ℝ (Fin 3)) : + axisC v = WithLp.toLp 2 ![-v 1, v 0, 0] := by + rw [axisC, matrixOperator_apply] + congr 1 + ext i + fin_cases i <;> simp [axisMatrixC, Matrix.mulVec, dotProduct, Fin.sum_univ_succ] + +theorem axisB_norm_le : ‖axisB‖ ≤ 1 := by + apply axisB.opNorm_le_bound zero_le_one + intro v + rw [one_mul] + apply nonneg_le_nonneg_of_sq_le_sq (norm_nonneg _) + simp only [← pow_two] + rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq, axisB_apply] + simp [Fin.sum_univ_three, Matrix.cons_val_two] + nlinarith [sq_nonneg ‖v.ofLp 1‖] + +theorem axisC_norm_le : ‖axisC‖ ≤ 1 := by + apply axisC.opNorm_le_bound zero_le_one + intro v + rw [one_mul] + apply nonneg_le_nonneg_of_sq_le_sq (norm_nonneg _) + simp only [← pow_two] + rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq, axisC_apply] + simp [Fin.sum_univ_three, Matrix.cons_val_two] + nlinarith [sq_nonneg ‖v.ofLp 2‖] + +def tripleMoment {R : Type uR} [Ring R] (X Y Z : R) : ℕ → ℕ → ℕ → ℕ → R + | 0, a, b, c => X^a * Y^b * Z^c + | k+1, a, b, c => tripleMoment X Y Z k (a+1) b c + + tripleMoment X Y Z k a (b+1) c + tripleMoment X Y Z k a b (c+1) + +theorem tripleMoment_four {R : Type uR} [Ring R] (X Y Z : R) : + tripleMoment X Y Z 4 0 0 0 = X^4+Y^4+Z^4 + + 4 • (X^3*Y+X^3*Z+X*Y^3+Y^3*Z+X*Z^3+Y*Z^3) + + 6 • (X^2*Y^2+X^2*Z^2+Y^2*Z^2) + + 12 • (X^2*Y*Z+X*Y^2*Z+X*Y*Z^2) := by + simp only [tripleMoment, Nat.reduceAdd, pow_zero, pow_one, one_mul, mul_one] + noncomm_ring + +def plane (f g : ℝ) : Matrix (Fin 3) (Fin 3) ℝ := !![0,0,g; 0,0,-f; -g,f,0] +def third : Matrix (Fin 3) (Fin 3) ℝ := !![0,-1,0; 1,0,0; 0,0,0] + +lemma plane_sub (f g h k : ℝ) : plane f g - plane h k = plane (f-h) (g-k) := by + ext i j + fin_cases i <;> fin_cases j <;> simp [plane] <;> ring +lemma plane_neg (f g : ℝ) : -plane f g = plane (-f) (-g) := by + ext i j + fin_cases i <;> fin_cases j <;> simp [plane] + +def moment4Plane (f g h k : ℝ) : Matrix (Fin 3) (Fin 3) ℝ := + tripleMoment (plane f g) (plane h k - plane f g) (-plane h k) 4 0 0 0 + +@[simp] lemma moment4_plane_even_00 (f g h k : ℝ) : + moment4Plane f g h k 0 0 + moment4Plane f (-g) h (-k) 0 0 = -6 * (f*k-g*h)^2 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + ring + +@[simp] lemma moment4_plane_even_01 (f g h k : ℝ) : + moment4Plane f g h k 0 1 + moment4Plane f (-g) h (-k) 0 1 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + ring + +@[simp] lemma moment4_plane_even_02 (f g h k : ℝ) : + moment4Plane f g h k 0 2 + moment4Plane f (-g) h (-k) 0 2 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + +@[simp] lemma moment4_plane_even_10 (f g h k : ℝ) : + moment4Plane f g h k 1 0 + moment4Plane f (-g) h (-k) 1 0 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + ring + +@[simp] lemma moment4_plane_even_11 (f g h k : ℝ) : + moment4Plane f g h k 1 1 + moment4Plane f (-g) h (-k) 1 1 = -6 * (f*k-g*h)^2 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + ring + +@[simp] lemma moment4_plane_even_12 (f g h k : ℝ) : + moment4Plane f g h k 1 2 + moment4Plane f (-g) h (-k) 1 2 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + +@[simp] lemma moment4_plane_even_20 (f g h k : ℝ) : + moment4Plane f g h k 2 0 + moment4Plane f (-g) h (-k) 2 0 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + +@[simp] lemma moment4_plane_even_21 (f g h k : ℝ) : + moment4Plane f g h k 2 1 + moment4Plane f (-g) h (-k) 2 1 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + +@[simp] lemma moment4_plane_even_22 (f g h k : ℝ) : + moment4Plane f g h k 2 2 + moment4Plane f (-g) h (-k) 2 2 = 0 := by + unfold moment4Plane + rw [plane_sub, plane_neg, plane_sub, plane_neg] + simp only [tripleMoment_four] + norm_num [plane, pow_succ, Matrix.cons_val_two] + ring + +lemma moment4_plane_even (f g h k : ℝ) : + moment4Plane f g h k + moment4Plane f (-g) h (-k) = + (6 * (f*k-g*h)^2) • third^2 := by + ext i j + fin_cases i <;> fin_cases j <;> simp [third, pow_two, Matrix.cons_val_two] + +theorem tripleJet_at_zero {n : ℕ} (X Y Z : SpinOperator n) (k a b c : ℕ) : + tripleJet X Y Z k a b c 0 = tripleMoment X Y Z k a b c := by + induction k generalizing a b c with + | zero => + simp only [tripleJet, expPower, tripleMoment, + zero_smul ℝ X, zero_smul ℝ Y, zero_smul ℝ Z, NormedSpace.exp_zero, one_mul] + | succ k ih => simp only [tripleJet, tripleMoment, ih] + +theorem map_tripleMoment {R : Type uR} {S : Type uS} [Ring R] [Ring S] + (φ : R →+* S) (X Y Z : R) (k a b c : ℕ) : + φ (tripleMoment X Y Z k a b c) = + tripleMoment (φ X) (φ Y) (φ Z) k a b c := by + induction k generalizing a b c with + | zero => simp [tripleMoment] + | succ k ih => simp [tripleMoment, ih] + +def planeOperator (f g : ℝ) : SpinOperator 3 := matrixOperator (plane f g) + +theorem planeOperator_eq (f g : ℝ) : planeOperator f g = f • axisA + g • axisB := by + rw [planeOperator, axisA, axisB, ← map_smul, ← map_smul, ← map_add] + congr 1 + ext i j + fin_cases i <;> fin_cases j <;> simp [plane, axisMatrixA, axisMatrixB] + +theorem plane_commutator (f g h k : ℝ) : + plane f g * plane h k - plane h k * plane f g = (f*k-g*h) • third := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [plane, third, Matrix.cons_val_two] <;> ring + +theorem planeOperator_commutator (f g h k : ℝ) : + planeOperator f g * planeOperator h k - planeOperator h k * planeOperator f g = + (f*k-g*h) • axisC := by + rw [planeOperator, planeOperator, ← map_mul, ← map_mul, ← map_sub, plane_commutator, + map_smul] + rfl + +theorem gaugeJet_plane_four_even (f g h k : ℝ) : + tripleJet (planeOperator f g) (planeOperator h k-planeOperator f g) + (-planeOperator h k) 4 0 0 0 0 + + tripleJet (planeOperator f (-g)) (planeOperator h (-k)-planeOperator f (-g)) + (-planeOperator h (-k)) 4 0 0 0 0 = (6*(f*k-g*h)^2) • axisC^2 := by + simp only [tripleJet_at_zero, planeOperator] + have hm (f g h k : ℝ) := map_tripleMoment matrixOperator.toRingHom + (plane f g) (plane h k-plane f g) (-plane h k) 4 0 0 0 + change ∀ f g h k, matrixOperator (tripleMoment (plane f g) + (plane h k-plane f g) (-plane h k) 4 0 0 0) = + tripleMoment (matrixOperator (plane f g)) (matrixOperator (plane h k-plane f g)) + (matrixOperator (-plane h k)) 4 0 0 0 at hm + simp only [map_sub, map_neg] at hm + rw [← hm, ← hm, ← map_add] + change matrixOperator (moment4Plane f g h k + moment4Plane f (-g) h (-k)) = _ + rw [moment4_plane_even, map_smul, map_pow] + rfl + +def mixedMatrixAB : Matrix (Fin 3) (Fin 3) ℝ := !![0,1/2,0;1/2,0,0;0,0,0] +def mixedMatrixAAB : Matrix (Fin 3) (Fin 3) ℝ := (-1/3 : ℝ) • axisMatrixB +def mixedMatrixABB : Matrix (Fin 3) (Fin 3) ℝ := (-1/3 : ℝ) • axisMatrixA +def mixedMatrixAABB : Matrix (Fin 3) (Fin 3) ℝ := (-1/6 : ℝ) • (axisMatrixA^2+axisMatrixB^2) + +theorem plane_matrix_square (f g : ℝ) : + plane f g ^ 2 = f^2 • axisMatrixA^2 + (2*f*g) • mixedMatrixAB + g^2 • axisMatrixB^2 := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [plane, axisMatrixA, axisMatrixB, mixedMatrixAB, pow_succ, Matrix.cons_val_two] <;> ring + +theorem plane_matrix_cube (f g : ℝ) : + plane f g ^ 3 = f^3 • axisMatrixA^3 + (3*f^2*g) • mixedMatrixAAB + (3*f*g^2) • mixedMatrixABB + g^3 • axisMatrixB^3 := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [plane, axisMatrixA, axisMatrixB, mixedMatrixAAB, mixedMatrixABB, pow_succ, Matrix.cons_val_two] <;> ring + +theorem plane_matrix_four_even (f g : ℝ) : + plane f g ^ 4 + plane f (-g) ^ 4 = (2*f^4) • axisMatrixA^4 + + (12*f^2*g^2) • mixedMatrixAABB + (2*g^4) • axisMatrixB^4 := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [plane, axisMatrixA, axisMatrixB, mixedMatrixAABB, pow_succ, Matrix.cons_val_two] <;> ring + +theorem mixedMatrixAB_sym : mixedMatrixAB = (1/2 : ℝ) • (axisMatrixA*axisMatrixB+axisMatrixB*axisMatrixA) := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [axisMatrixA, axisMatrixB, mixedMatrixAB, Matrix.cons_val_two] + +def mixedAB : SpinOperator 3 := matrixOperator mixedMatrixAB +def mixedAAB : SpinOperator 3 := matrixOperator mixedMatrixAAB +def mixedABB : SpinOperator 3 := matrixOperator mixedMatrixABB +def mixedAABB : SpinOperator 3 := matrixOperator mixedMatrixAABB + +theorem planeOperator_square (f g : ℝ) : + planeOperator f g ^ 2 = f^2 • axisA^2 + (2*f*g) • mixedAB + g^2 • axisB^2 := by + have h := congrArg matrixOperator (plane_matrix_square f g) + simpa only [map_add, map_smul, map_pow, planeOperator, axisA, axisB, mixedAB, mixedAAB, mixedABB, mixedAABB] using h + +theorem planeOperator_cube (f g : ℝ) : + planeOperator f g ^ 3 = f^3 • axisA^3 + (3*f^2*g) • mixedAAB + + (3*f*g^2) • mixedABB + g^3 • axisB^3 := by + have h := congrArg matrixOperator (plane_matrix_cube f g) + simpa only [map_add, map_smul, map_pow, planeOperator, axisA, axisB, mixedAB, mixedAAB, mixedABB, mixedAABB] using h + +theorem planeOperator_four_even (f g : ℝ) : + planeOperator f g ^ 4 + planeOperator f (-g) ^ 4 = (2*f^4) • axisA^4 + + (12*f^2*g^2) • mixedAABB + (2*g^4) • axisB^4 := by + have h := congrArg matrixOperator (plane_matrix_four_even f g) + simpa only [map_add, map_smul, map_pow, planeOperator, axisA, axisB, mixedAB, mixedAAB, mixedABB, mixedAABB] using h + +namespace SpinSystem +variable {n : ℕ} {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +omit [Fintype V] in +theorem energy_add (S : SpinSystem n V E) (K L : E → SpinOperator n) (σ : V → Spin n) : + S.energy (K+L) σ = S.energy K σ + S.energy L σ := by + simp [energy, inner_add_right, mul_add, Finset.sum_add_distrib] + +omit [Fintype V] in +theorem energy_smul (S : SpinSystem n V E) (r : ℝ) (K : E → SpinOperator n) + (σ : V → Spin n) : S.energy (r • K) σ = r * S.energy K σ := by + simp only [energy, Pi.smul_apply, smul_apply, real_inner_smul_right, + Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + +omit [Fintype V] in +theorem energy_neg (S : SpinSystem n V E) (K : E → SpinOperator n) (σ : V → Spin n) : + S.energy (-K) σ = -S.energy K σ := by + simp [energy] + +theorem average_mul_const (S : SpinSystem n V E) (r : ℝ) (f : (V → Spin n) → ℝ) : + S.average (fun σ => r * f σ) = r * S.average f := by + simp only [average, mul_assoc, integral_const_mul, mul_div_assoc] + +def fourthPolynomial (F : ℕ → ℝ) : ℝ := + F 4 + 4 * F 1 * F 3 + 3 * (F 2)^2 + 6 * (F 1)^2 * F 2 + (F 1)^4 + +def fourthResponse (S : SpinSystem n V E) (A : E → SpinOperator n) : ℝ := + S.average (fun σ => fourthPolynomial (fun k => S.energy (fun e => A e ^ k) σ)) + +theorem fourthResponse_integral [NeZero n] (S : SpinSystem n V E) + (A : E → SpinOperator n) : + S.fourthResponse A = (∫ σ, S.fourthWeight A 0 σ ∂S.reference) / S.Z (fun _ => 1) := by + unfold fourthResponse average + congr 1 + apply integral_congr_ae (Filter.Eventually.of_forall _) + intro σ + have hz (e : E) : (0:ℝ) • A e = 0 := zero_smul ℝ (A e) + simp only [fourthWeight, twistEnergy, hz, NormedSpace.exp_zero, one_mul, pow_zero, + fourthPolynomial] + ring + +theorem fourthResponse_gauge [NeZero n] (S : SpinSystem n V E) + (F : V → SpinOperator n) (hF : ∀ x, F x ∈ skewAdjoint (SpinOperator n)) + (hP : ∀ x s, S.pin x = some s → F x = 0) : + S.fourthResponse (fun e => F (S.right e)-F (S.left e)) = + S.average (fun σ => S.gaugeEnergy F 4 0 σ + 3 * (S.energy + (fun e => F (S.left e)*F (S.right e)-F (S.right e)*F (S.left e)) σ)^2) := by + rw [S.fourthResponse_integral, S.fourth_noncommuting_identity F hF hP] + unfold average + congr 1 + apply integral_congr_ae (Filter.Eventually.of_forall _) + intro σ + exact mul_comm _ _ + +omit [Fintype V] [Fintype E] in +def crossForm (S : SpinSystem 3 V E) (f g : V → ℝ) : E → ℝ := + fun e => f (S.left e)*g (S.right e)-g (S.left e)*f (S.right e) + +omit [Fintype V] [Fintype E] in +def planarGradient (S : SpinSystem 3 V E) (f g : V → ℝ) : E → SpinOperator 3 := + fun e => planeOperator (f (S.right e)) (g (S.right e)) - + planeOperator (f (S.left e)) (g (S.left e)) + +def secondAxisResponse (S : SpinSystem 3 V E) (h k : E → ℝ) : ℝ := + S.average (fun σ => S.energy (fun e => (h e*k e) • axisC^2) σ + + S.energy (fun e => h e • axisC) σ * S.energy (fun e => k e • axisC) σ) + +end SpinSystem + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/FourierOperator.lean b/lean/OAI/Probability/ClassicalON/FourierOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba9b9cbf906651246158dff6763c5c7f4e26d719 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/FourierOperator.lean @@ -0,0 +1,81 @@ +import OAI.Probability.ClassicalON.MatrixSquare + +namespace OAI + +universe uP uX uY + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +variable {X : Type uX} {P : Type uP} {Y : Type uY} [Fintype X] [Fintype P] [Fintype Y] + +theorem sum_norm_pointwise_mul_sq_le (d v : X → ℂ) (c : ℝ) (hd : ∀ x, ‖d x‖ ≤ c) : + (∑ x, ‖d x*v x‖^2) ≤ c^2*∑ x, ‖v x‖^2 := by + rw [Finset.mul_sum] + exact Finset.sum_le_sum fun x _ => by + rw [norm_mul, mul_pow] + exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) (hd x) 2) (sq_nonneg _) + +theorem sum_norm_sq_restrict (i : Y → X) (hi : Function.Injective i) (v : X → ℂ) : + (∑ y, ‖v (i y)‖^2) ≤ ∑ x, ‖v x‖^2 := by + classical + calc _ = ∑ x ∈ Finset.univ.image i, ‖v x‖^2 := (Finset.sum_image (fun a _ b _ h => hi h)).symm + _ ≤ _ := Finset.sum_le_univ_sum_of_nonneg fun x => sq_nonneg _ + +theorem modulated_fourier_bound [DecidableEq P] (W : X → P → ℂ) (M C A : ℝ) + (hM : 0 ≤ M) + (hW : ∀ p q, (∑ x, W x p*conj (W x q)) = if p=q then (M:ℂ) else 0) + (d : X → ℂ) (a v : P → ℂ) (hd : ∀ x, ‖d x‖ ≤ C) (ha : ∀ p, ‖a p‖ ≤ A) : + (∑ x, ‖d x*(∑ p, W x p*(a p*v p))‖^2) ≤ (C^2*M*A^2)*∑ p, ‖v p‖^2 := by + calc _ ≤ C^2*∑ x, ‖∑ p, W x p*(a p*v p)‖^2 := sum_norm_pointwise_mul_sq_le _ _ C hd + _ ≤ C^2*((M*A^2)*∑ p, ‖v p‖^2) := mul_le_mul_of_nonneg_left + (parseval_diagonal_bound W M A hM hW a v ha) (sq_nonneg _) + _ = _ := by ring + +theorem cutoff_fourier_difference_bound {L : ℕ} [NeZero L] [DecidableEq P] + (p : P → DiscreteTorus L) (hp : Function.Injective p) + (φ : DiscreteTorus L → ℂ) (h : DiscreteTorus L) (a v : P → ℂ) + (D C A B : ℝ) (hD : ∀ x, ‖φ (x+h)-φ x‖ ≤ D) + (hC : ∀ x, ‖φ (x+h)‖ ≤ C) (hA : ∀ q, ‖a q‖ ≤ A) + (hB : ∀ q, ‖a q*(torusWave (p q) h-1)‖ ≤ B) : + (∑ x, ‖∑ q, (a q*(φ (x+h)*torusWave (p q) (x+h)-φ x*torusWave (p q) x))*v q‖^2) ≤ + (2*(L:ℝ)^2*(D^2*A^2+C^2*B^2))*∑ q, ‖v q‖^2 := by + let f := fun x => (φ (x+h)-φ x)*(∑ q, torusWave (p q) x*(a q*v q)) + let g := fun x => φ (x+h)*(∑ q, torusWave (p q) x*((a q*(torusWave (p q) h-1))*v q)) + have he (x : DiscreteTorus L) : + (∑ q, a q*(φ (x+h)*torusWave (p q) (x+h)-φ x*torusWave (p q) x)*v q) = f x+g x := by + simp only [f, g, Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro q _ + rw [torus_mode_difference] + ring + simp_rw [he] + have hf := modulated_fourier_bound (fun x q => torusWave (p q) x) ((L:ℝ)^2) D A + (sq_nonneg _) (fun i j => by simpa only [Complex.ofReal_pow] using torusWave_orthogonal_subfamily p hp i j) (fun x => φ (x+h)-φ x) a v hD hA + have hg := modulated_fourier_bound (fun x q => torusWave (p q) x) ((L:ℝ)^2) C B + (sq_nonneg _) (fun i j => by simpa only [Complex.ofReal_pow] using torusWave_orthogonal_subfamily p hp i j) (fun x => φ (x+h)) + (fun q => a q*(torusWave (p q) h-1)) v hC hB + have ht := sum_norm_add_sq_le f g + dsimp only [f, g] at ht ⊢ + linarith + +theorem restricted_cutoff_squareBound {L : ℕ} [NeZero L] [DecidableEq P] + (p : P → DiscreteTorus L) (hp : Function.Injective p) + (φ : DiscreteTorus L → ℂ) (h : DiscreteTorus L) (a : P → ℂ) + (i : Y → DiscreteTorus L) (hi : Function.Injective i) + (D C A B : ℝ) (hD : ∀ x, ‖φ (x+h)-φ x‖ ≤ D) + (hC : ∀ x, ‖φ (x+h)‖ ≤ C) (hA : ∀ q, ‖a q‖ ≤ A) + (hB : ∀ q, ‖a q*(torusWave (p q) h-1)‖ ≤ B) : + SquareBound (fun y q => a q*(φ (i y+h)*torusWave (p q) (i y+h)-φ (i y)*torusWave (p q) (i y))) + (Real.sqrt (2*(L:ℝ)^2*(D^2*A^2+C^2*B^2))) := by + intro v + rw [Real.sq_sqrt (by positivity)] + exact (sum_norm_sq_restrict i hi _).trans + (cutoff_fourier_difference_bound p hp φ h a v D C A B hD hC hA hB) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/GibbsCovariance.lean b/lean/OAI/Probability/ClassicalON/GibbsCovariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..a860759a88079da64b65d941337886b22038928a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/GibbsCovariance.lean @@ -0,0 +1,47 @@ +import OAI.Probability.ClassicalON.ProductMoments + +namespace OAI + +universe uX + +noncomputable section +open MeasureTheory +namespace ClassicalON + +section +variable {X : Type uX} [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] [SecondCountableTopology X] + (μ : Measure X) [IsProbabilityMeasure μ] + +theorem doubled_covariance_identity {w f g : X → ℝ} + (hw : Continuous w) (hf : Continuous f) (hg : Continuous g) : + (∫ p : X×X,w p.1*w p.2*(f p.1-f p.2)*(g p.1-g p.2) ∂μ.prod μ) = + 2*((∫ x,w x ∂μ)*(∫ x,w x*(f x*g x) ∂μ)- + (∫ x,w x*f x ∂μ)*(∫ x,w x*g x ∂μ)) := by + have he : (fun p : X×X => w p.1*w p.2*(f p.1-f p.2)*(g p.1-g p.2)) = + (fun p : X×X => (w p.1*(f p.1*g p.1)*w p.2+w p.1*(w p.2*(f p.2*g p.2)))- + (w p.1*f p.1*(w p.2*g p.2)+w p.1*g p.1*(w p.2*f p.2))) := by + funext p; ring + rw [he,integral_sub (compact_integrable (by fun_prop)) (compact_integrable (by fun_prop)), + integral_add (compact_integrable (by fun_prop)) (compact_integrable (by fun_prop)), + integral_add (compact_integrable (by fun_prop)) (compact_integrable (by fun_prop))] + rw [integral_prod_mul (fun x => w x*(f x*g x)) w, + integral_prod_mul w (fun x => w x*(f x*g x)), + integral_prod_mul (fun x => w x*f x) (fun x => w x*g x), + integral_prod_mul (fun x => w x*g x) (fun x => w x*f x)] + ring + +theorem covariance_nonneg_of_doubled {w f g : X → ℝ} + (hw : Continuous w) (hp : ∀ x,0 f x*g x) := by + rw [doubled_covariance_identity μ hw hf hg] at h + apply (weightedMean_inequality_iff hw hp).2 + linarith + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/GibbsDerivative.lean b/lean/OAI/Probability/ClassicalON/GibbsDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4984855d4bf2c0ce752085f66eee43b4b8d382c --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/GibbsDerivative.lean @@ -0,0 +1,52 @@ +import OAI.Probability.ClassicalON.AssociationCore + +namespace OAI + +universe uX + +noncomputable section +open MeasureTheory +namespace ClassicalON + +section +variable {X : Type uX} [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] (μ : Measure X) [IsProbabilityMeasure μ] + +def exponentialMean (H f : X → ℝ) : ℝ := weightedMean μ (fun x => Real.exp (H x)) f + +theorem exponentialMean_continuous {H : ℝ×X → ℝ} (hH : Continuous H) + {f : X → ℝ} (hf : Continuous f) : + Continuous (fun t => exponentialMean μ (fun x => H (t,x)) f) := by + apply (compact_parametric_integral (fun t x => Real.exp (H (t,x))*f x) (by fun_prop)).div + (compact_parametric_integral (fun t x => Real.exp (H (t,x))) (by fun_prop)) + exact fun t => (compact_integral_pos (by fun_prop) (fun x => Real.exp_pos (H (t,x)))).ne' + +theorem hasDerivAt_exponentialIntegral {H A f : X → ℝ} + (hH : Continuous H) (hA : Continuous A) (hf : Continuous f) (t : ℝ) : + HasDerivAt (fun u => ∫ x,Real.exp (H x+u*A x)*f x ∂μ) + (∫ x,Real.exp (H x+t*A x)*(f x*A x) ∂μ) t := by + apply hasDerivAt_integral_compact μ + (fun u x => Real.exp (H x+u*A x)*f x) + (fun u x => Real.exp (H x+u*A x)*(f x*A x)) (by fun_prop) (by fun_prop) + intro u x + exact ((((hasDerivAt_id u).mul_const (A x)).const_add (H x)).exp.mul_const (f x)).congr_deriv (by simp only [id_eq]; ring) + +theorem hasDerivAt_exponentialMean {H A f : X → ℝ} + (hH : Continuous H) (hA : Continuous A) (hf : Continuous f) (t : ℝ) : + HasDerivAt (fun u => exponentialMean μ (fun x => H x+u*A x) f) + (exponentialMean μ (fun x => H x+t*A x) (fun x => f x*A x)- + exponentialMean μ (fun x => H x+t*A x) f* + exponentialMean μ (fun x => H x+t*A x) A) t := by + have hN := hasDerivAt_exponentialIntegral μ hH hA hf t + have hD := hasDerivAt_exponentialIntegral μ hH hA continuous_const t (f := fun _ => 1) + simp only [mul_one,one_mul] at hD + have hz : (∫ x,Real.exp (H x+t*A x) ∂μ)≠0 := + (compact_integral_pos (by fun_prop) (fun x => Real.exp_pos _)).ne' + exact (hN.div hD hz).congr_deriv (by unfold exponentialMean weightedMean; field_simp) + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/GradientComplex.lean b/lean/OAI/Probability/ClassicalON/GradientComplex.lean new file mode 100644 index 0000000000000000000000000000000000000000..253e48cc54a7cb8128fbc7e0c914160da7620761 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/GradientComplex.lean @@ -0,0 +1,218 @@ +import OAI.Probability.ClassicalON.FamilyAlgebra + +namespace OAI + +universe uE uV uΩ + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {n : ℕ} {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def normObservable {Ω : Type uΩ} [TopologicalSpace Ω] (f : C(Ω, ℂ)) : C(Ω, ℝ) := + ⟨fun σ => ‖f σ‖, f.continuous.norm⟩ + +def reObservable {Ω : Type uΩ} [TopologicalSpace Ω] (f : C(Ω, ℂ)) : C(Ω, ℝ) := + ⟨fun σ => (f σ).re, Complex.continuous_re.comp f.continuous⟩ + +def imObservable {Ω : Type uΩ} [TopologicalSpace Ω] (f : C(Ω, ℂ)) : C(Ω, ℝ) := + ⟨fun σ => (f σ).im, Complex.continuous_im.comp f.continuous⟩ + +theorem averageLinear_nonneg [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℝ)) (hf : ∀ σ, 0 ≤ f σ) : 0 ≤ S.averageLinear f := + S.average_nonneg hf + +theorem averageLinear_mono [NeZero n] (S : SpinSystem n V E) + (f g : C((V → Spin n), ℝ)) (hfg : ∀ σ, f σ ≤ g σ) : + S.averageLinear f ≤ S.averageLinear g := S.average_mono f.continuous g.continuous hfg + +theorem averageLinear_mul_self_nonneg [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℝ)) : 0 ≤ S.averageLinear (f*f) := + S.averageLinear_nonneg _ (fun σ => mul_self_nonneg (f σ)) + +theorem averageLinear_cauchySchwarz [NeZero n] (S : SpinSystem n V E) + (f g : C((V → Spin n), ℝ)) : + (S.averageLinear (f*g))^2 ≤ S.averageLinear (f*f) * S.averageLinear (g*g) := by + have hp (t : ℝ) : 0 ≤ S.averageLinear (f*f) * (t*t) + + (2*S.averageLinear (f*g))*t + S.averageLinear (g*g) := by + have h := S.averageLinear_mul_self_nonneg (t • f + g) + have he : (t • f + g)*(t • f + g) = + (t*t) • (f*f) + (2*t) • (f*g) + g*g := by + ext σ + simp only [ContinuousMap.mul_apply, ContinuousMap.add_apply, + ContinuousMap.smul_apply, smul_eq_mul] + ring + rw [he, map_add, map_add, map_smul, map_smul, smul_eq_mul, smul_eq_mul] at h + nlinarith + have h := discrim_le_zero hp + unfold discrim at h + nlinarith + +theorem averageLinear_mul_le_sqrt [NeZero n] (S : SpinSystem n V E) + (f g : C((V → Spin n), ℝ)) : + S.averageLinear (f*g) ≤ + Real.sqrt (S.averageLinear (f*f)) * Real.sqrt (S.averageLinear (g*g)) := by + rw [← Real.sqrt_mul (S.averageLinear_mul_self_nonneg f)] + exact Real.le_sqrt_of_sq_le (S.averageLinear_cauchySchwarz f g) + +theorem norm_averageComplex_le [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℂ)) : + ‖S.averageComplexLinear f‖ ≤ S.averageLinear (normObservable f) := by + change ‖(∫ σ, f σ * (Real.exp (S.energy (fun _ => 1) σ) : ℂ) ∂S.reference) / + (S.Z (fun _ => 1) : ℂ)‖ ≤ _ + rw [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos (S.Z_pos _)] + calc _ ≤ (∫ σ, ‖f σ * (Real.exp (S.energy (fun _ => 1) σ) : ℂ)‖ ∂S.reference) / + S.Z (fun _ => 1) := + div_le_div_of_nonneg_right (norm_integral_le_integral_norm _) (S.Z_pos _).le + _ = S.averageLinear (normObservable f) := by + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_pos (Real.exp_pos _)] + rfl + +omit [Fintype V] in +@[simp] theorem complexEnergy_re (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℂ) (σ : V → Spin n) : + (S.complexEnergy M u σ).re = S.energy (fun e => (u e).re • M) σ := by + rw [S.energy_weighted] + simp [complexEnergy, MixedAlgebra.weighted, Complex.mul_re] + +omit [Fintype V] in +@[simp] theorem complexEnergy_im (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℂ) (σ : V → Spin n) : + (S.complexEnergy M u σ).im = S.energy (fun e => (u e).im • M) σ := by + rw [S.energy_weighted] + simp [complexEnergy, MixedAlgebra.weighted, Complex.mul_im] + +omit [Fintype V] in +@[simp] theorem complexEnergy_conj (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℂ) (σ : V → Spin n) : + S.complexEnergy M (fun e => conj (u e)) σ = conj (S.complexEnergy M u σ) := by + simp [complexEnergy, MixedAlgebra.weighted] + +theorem complex_gradient_current_bound [NeZero n] (S : SpinSystem n V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator n) (hM : M ∈ skewAdjoint (SpinOperator n)) (hMn : ‖M‖ ≤ 1) + (f : V → ℂ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.average (fun σ => ‖S.complexEnergy M (S.differential f) σ‖^2) ≤ + β * ∑ e, ‖S.differential f e‖^2 := by + have hr := S.gradient_current_bound β hb M hM hMn (fun x => (f x).re) + (fun x s hs => by rw [hP x s hs, Complex.zero_re]) + have hi := S.gradient_current_bound β hb M hM hMn (fun x => (f x).im) + (fun x s hs => by rw [hP x s hs, Complex.zero_im]) + have he (σ : V → Spin n) : ‖S.complexEnergy M (S.differential f) σ‖^2 = + (S.energy (S.axisGradient (fun x => (f x).re) M) σ)^2 + + (S.energy (S.axisGradient (fun x => (f x).im) M) σ)^2 := by + rw [Complex.sq_norm, Complex.normSq_apply, complexEnergy_re, complexEnergy_im] + simp only [differential, Complex.sub_re, Complex.sub_im, pow_two] + rfl + have he' : (fun σ => ‖S.complexEnergy M (S.differential f) σ‖^2) = + (fun σ => (S.energy (S.axisGradient (fun x => (f x).re) M) σ)^2) + + (fun σ => (S.energy (S.axisGradient (fun x => (f x).im) M) σ)^2) := funext he + rw [he', S.average_add + (f := fun σ => (S.energy (S.axisGradient (fun x => (f x).re) M) σ)^2) + (g := fun σ => (S.energy (S.axisGradient (fun x => (f x).im) M) σ)^2) + ((S.continuous_energy _).pow 2) ((S.continuous_energy _).pow 2)] + have hn : (∑ e, ‖S.differential f e‖^2) = + (∑ e, ((f (S.right e)).re - (f (S.left e)).re)^2) + + (∑ e, ((f (S.right e)).im - (f (S.left e)).im)^2) := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro e _ + rw [Complex.sq_norm] + simp [Complex.normSq_apply, differential, pow_two] + rw [hn, mul_add] + exact add_le_add hr hi + +theorem averageComplex_re [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℂ)) : + (S.averageComplexLinear f).re = S.averageLinear (reObservable f) := by + change ((∫ σ, f σ * (Real.exp (S.energy (fun _ => 1) σ) : ℂ) ∂S.reference) / + (S.Z (fun _ => 1) : ℂ)).re = _ + rw [Complex.div_ofReal_re] + have h := integral_re (S.integrable_complex_integrand f.continuous) + simp only [RCLike.re_to_complex] at h + rw [← h] + simp only [Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, mul_zero, sub_zero] + rfl + +theorem averageComplex_conj [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℂ)) : + S.averageComplexLinear ⟨fun σ => conj (f σ), Complex.continuous_conj.comp f.continuous⟩ = + conj (S.averageComplexLinear f) := by + change (∫ σ, conj (f σ) * (Real.exp (S.energy (fun _ => 1) σ) : ℂ) ∂S.reference) / + (S.Z (fun _ => 1) : ℂ) = + conj ((∫ σ, f σ * (Real.exp (S.energy (fun _ => 1) σ) : ℂ) ∂S.reference) / + (S.Z (fun _ => 1) : ℂ)) + conv_lhs => arg 1; arg 2; ext σ; rw [← Complex.conj_ofReal (Real.exp _), ← map_mul] + rw [integral_conj, map_div₀] + congr 1 + exact (Complex.conj_ofReal _).symm + +omit [Fintype V] [Fintype E] in +theorem abs_localCoefficient_le (S : SpinSystem n V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator n) (hM : ‖M‖ ≤ 1) (σ : V → Spin n) (e : E) : + |S.localCoefficient M σ e| ≤ β := by + have hi : |⟪(σ (S.left e)).val, M (σ (S.right e)).val⟫_ℝ| ≤ 1 := by + calc _ ≤ ‖(σ (S.left e)).val‖ * ‖M (σ (S.right e)).val‖ := abs_real_inner_le_norm _ _ + _ ≤ ‖(σ (S.left e)).val‖ * (‖M‖ * ‖(σ (S.right e)).val‖) := + mul_le_mul_of_nonneg_left (M.le_opNorm _) (norm_nonneg _) + _ = ‖M‖ := by simp + _ ≤ 1 := hM + rw [localCoefficient, abs_mul, abs_of_nonneg (hb e).1] + exact (mul_le_of_le_one_right (hb e).1 hi).trans (hb e).2 + +end ClassicalON.SpinSystem + +namespace ClassicalON + +theorem norm_square_le_one {n : ℕ} (M : SpinOperator n) (hM : ‖M‖ ≤ 1) : ‖M^2‖ ≤ 1 := by + calc ‖M^2‖ ≤ ‖M‖ * ‖M‖ := by simpa only [pow_two] using norm_mul_le M M + _ ≤ 1 * 1 := mul_le_mul hM hM (norm_nonneg _) zero_le_one + _ = 1 := one_mul _ + +theorem mixedAB_norm_le : ‖mixedAB‖ ≤ 1 := by + have he : mixedAB = (1/2 : ℝ) • (axisA*axisB+axisB*axisA) := by + have h := congrArg matrixOperator mixedMatrixAB_sym + simpa only [map_smul, map_add, map_mul, mixedAB, axisA, axisB] using h + rw [he, norm_smul] + have hab := (norm_mul_le axisA axisB).trans + (mul_le_mul axisA_norm_le axisB_norm_le (norm_nonneg _) zero_le_one) + have hba := (norm_mul_le axisB axisA).trans + (mul_le_mul axisB_norm_le axisA_norm_le (norm_nonneg _) zero_le_one) + have hsum := norm_add_le (axisA*axisB) (axisB*axisA) + norm_num at hab hba ⊢ + linarith + +theorem mixedAAB_norm_le : ‖mixedAAB‖ ≤ 1 := by + have he : mixedAAB = (-1/3 : ℝ) • axisB := by + simp only [mixedAAB, mixedMatrixAAB, map_smul, axisB] + rw [he, norm_smul] + norm_num + linarith [axisB_norm_le] + +theorem mixedABB_norm_le : ‖mixedABB‖ ≤ 1 := by + have he : mixedABB = (-1/3 : ℝ) • axisA := by + simp only [mixedABB, mixedMatrixABB, map_smul, axisA] + rw [he, norm_smul] + norm_num + linarith [axisA_norm_le] + +theorem mixedAABB_norm_le : ‖mixedAABB‖ ≤ 1 := by + have he : mixedAABB = (-1/6 : ℝ) • (axisA^2+axisB^2) := by + simp only [mixedAABB, mixedMatrixAABB, map_smul, map_add, map_pow, axisA, axisB] + rw [he, norm_smul] + have hsum := norm_add_le (axisA^2) (axisB^2) + have ha := norm_square_le_one axisA axisA_norm_le + have hb := norm_square_le_one axisB axisB_norm_le + norm_num + linarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/IsingGinibre.lean b/lean/OAI/Probability/ClassicalON/IsingGinibre.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d18c738bb210d2152f3ef5bc0496a20145eb4b0 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/IsingGinibre.lean @@ -0,0 +1,121 @@ +import OAI.Probability.ClassicalON.GibbsCovariance + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def isingEnergy (left right : E → V) (e : E) (s : V → Bool) : ℝ := + signValue (s (left e))*signValue (s (right e)) + +def isingHamiltonian (left right : E → V) (b : E → ℝ) (s : V → Bool) : ℝ := + ∑ e,b e*isingEnergy left right e s + +def isingMean (left right : E → V) (b : E → ℝ) (f : (V → Bool) → ℝ) : ℝ := + exponentialMean isingReference (isingHamiltonian left right b) f + +def isingDoubleVariable (i : V×Bool) (p : V → Bool×Bool) : ℝ := + if i.2 then isingU (p i.1) else isingW (p i.1) + +def isingDoubleEnergy (left right : E → V) (e : E) (p : V → Bool×Bool) : ℝ := + isingU (p (left e))*isingU (p (right e))+isingW (p (left e))*isingW (p (right e)) + +def isingDoubleDifference (left right : E → V) (e : E) (p : V → Bool×Bool) : ℝ := + 2*(isingU (p (left e))*isingW (p (right e))+isingW (p (left e))*isingU (p (right e))) + +omit [Fintype V] [Fintype E] in +theorem isingDoubleEnergy_cone (left right : E → V) (e : E) : + MomentCone isingDoubleVariable (isingDoubleEnergy left right e) := by + exact momentCone_add + (momentCone_mul (momentCone_coordinate (left e,true)) (momentCone_coordinate (right e,true))) + (momentCone_mul (momentCone_coordinate (left e,false)) (momentCone_coordinate (right e,false))) + +omit [Fintype V] [Fintype E] in +theorem isingDoubleDifference_cone (left right : E → V) (e : E) : + MomentCone isingDoubleVariable (isingDoubleDifference left right e) := by + exact momentCone_mul (momentCone_const (by norm_num : (0 : ℝ)≤2)) (momentCone_add + (momentCone_mul (momentCone_coordinate (left e,true)) (momentCone_coordinate (right e,false))) + (momentCone_mul (momentCone_coordinate (left e,false)) (momentCone_coordinate (right e,true)))) + +omit [Fintype E] in +theorem isingDoubleVariable_moments (k : ℕ) (p : Fin k → V×Bool) : + 0≤∫ z : V → Bool×Bool,∏ i,isingDoubleVariable (p i) z + ∂Measure.pi (fun _ => signLaw.prod signLaw) := by + classical + have hh := independent_moments_nonneg (V := V) (signLaw.prod signLaw) + (fun b t => if b then isingU t else isingW t) isingUW_product_moment (List.ofFn p) + simpa only [isingDoubleVariable,List.map_ofFn,List.prod_ofFn,Function.comp_def] using hh + +omit [Fintype V] [Fintype E] in +theorem isingDoubleEnergy_identity (left right : E → V) (e : E) (p : V → Bool×Bool) : + isingEnergy left right e (fun v => (p v).1)+ + isingEnergy left right e (fun v => (p v).2)=2*isingDoubleEnergy left right e p := by + unfold isingEnergy isingDoubleEnergy isingU isingW + ring + +omit [Fintype V] [Fintype E] in +theorem isingDoubleDifference_identity (left right : E → V) (e : E) (p : V → Bool×Bool) : + isingEnergy left right e (fun v => (p v).1)- + isingEnergy left right e (fun v => (p v).2)=isingDoubleDifference left right e p := by + unfold isingEnergy isingDoubleDifference isingU isingW + ring + +theorem ising_edge_covariance_nonneg (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0≤b e) (e f : E) : + isingMean left right b (isingEnergy left right e)* + isingMean left right b (isingEnergy left right f) ≤ + isingMean left right b (fun s => isingEnergy left right e s*isingEnergy left right f s) := by + classical + let T := isingEnergy left right + let H := isingHamiltonian left right b + let D := isingDoubleDifference left right + let A := isingDoubleEnergy left right + let μ := (isingReference (V := V)).prod (isingReference (V := V)) + let ν := Measure.pi (fun _ : V => signLaw.prod signLaw) + let F : ((V → Bool)×(V → Bool)) → ℝ := fun p => + Real.exp (H p.1)*Real.exp (H p.2)*(T e p.1-T e p.2)*(T f p.1-T f p.2) + apply covariance_nonneg_of_doubled isingReference (continuous_of_discreteTopology) + (fun s => Real.exp_pos (H s)) continuous_of_discreteTopology continuous_of_discreteTopology + change 0≤∫ p,F p ∂μ + let h := measurePreserving_arrowProdEquivProdArrow Bool Bool V (fun _ => signLaw) (fun _ => signLaw) + change 0≤∫ p,F p ∂(Measure.pi (fun _ : V => signLaw)).prod (Measure.pi (fun _ : V => signLaw)) + rw [← h.integral_comp' F] + have he : (fun p => F (MeasurableEquiv.arrowProdEquivProdArrow Bool Bool V p))= + (fun p => (D e p*D f p)*Real.exp (∑ g,(2*b g)*A g p)) := by + funext p + change Real.exp (H (fun v => (p v).1))*Real.exp (H (fun v => (p v).2))* + (T e (fun v => (p v).1)-T e (fun v => (p v).2))* + (T f (fun v => (p v).1)-T f (fun v => (p v).2))=_ + rw [← Real.exp_add] + have hH : H (fun v => (p v).1)+H (fun v => (p v).2)=∑ g,(2*b g)*A g p := by + simp only [H,isingHamiltonian,← Finset.sum_add_distrib,← mul_add,isingDoubleEnergy_identity] + apply Finset.sum_congr rfl; intro g _; change b g*(2*A g p)=(2*b g)*A g p; ring + rw [hH] + change Real.exp _*(isingEnergy _ _ _ _-isingEnergy _ _ _ _)* + (isingEnergy _ _ _ _-isingEnergy _ _ _ _)=_ + rw [isingDoubleDifference_identity,isingDoubleDifference_identity] + dsimp only [D] + ring + rw [he] + apply integral_mul_sum_exp_nonneg ν continuous_of_discreteTopology + (fun _ => continuous_of_discreteTopology) (fun g => 2*b g) + (fun g => mul_nonneg (by norm_num) (hb g)) + intro k p + apply momentCone_integral_nonneg ν (fun _ => continuous_of_discreteTopology) + isingDoubleVariable_moments + apply momentCone_mul + · exact momentCone_mul (isingDoubleDifference_cone _ _ e) (isingDoubleDifference_cone _ _ f) + · exact momentCone_finsetProd Finset.univ (fun i => A (p i)) + (fun i _ => isingDoubleEnergy_cone _ _ _) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/IsingPositive.lean b/lean/OAI/Probability/ClassicalON/IsingPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..d27944eab25dda8acad3b203cbb3ec8693c30031 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/IsingPositive.lean @@ -0,0 +1,48 @@ +import OAI.Probability.ClassicalON.IsingGinibre + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators ENNReal +namespace ClassicalON + +theorem signValue_product_moment (l : List Unit) : + 0≤∫ t,(l.map (fun _ => signValue t)).prod ∂signLaw := by + have he (t : Bool) : (l.map (fun _ => signValue t)).prod=signValue t^l.length := by simp + simp_rw [he] + simp only [signLaw,integral_smul_measure,ENNReal.toReal_inv,ENNReal.toReal_ofNat, + smul_eq_mul,integral_count,Fintype.sum_bool,signValue,Bool.false_eq_true,ite_false,ite_true, + one_pow] + have hh : -1≤(-1 : ℝ)^l.length := by + simpa only [abs_pow,abs_neg,abs_one,one_pow] using neg_abs_le ((-1 : ℝ)^l.length) + norm_num at * + linarith + +variable {V : Type uV} {E : Type uE} [Fintype V] + +theorem ising_reference_mean_nonneg (left right : E → V) (e : E) : + 0≤∫ s,isingEnergy left right e s ∂isingReference := by + classical + have hh := independent_moments_nonneg (V := V) signLaw (fun (_ : Unit) t => signValue t) + signValue_product_moment [(left e,()),(right e,())] + simpa only [List.map_cons,List.map_nil,List.prod_cons,List.prod_nil,mul_one,isingEnergy, + isingReference] using hh + +variable [Fintype E] + +theorem ising_edge_mean_nonneg (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) (e : E) : + 0 ≤ isingMean left right b (isingEnergy left right e) := by + apply edgeMean_nonneg isingReference (isingEnergy left right) + (fun _ => continuous_of_discreteTopology) + · exact ising_edge_covariance_nonneg left right + · exact ising_reference_mean_nonneg left right + · exact hb + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/IsingReference.lean b/lean/OAI/Probability/ClassicalON/IsingReference.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0f363b1a5780f8474be19ca00638faa77d5a880 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/IsingReference.lean @@ -0,0 +1,71 @@ +import OAI.Probability.ClassicalON.AmplitudeModular + +namespace OAI + +universe uV + +noncomputable section +open MeasureTheory +open scoped BigOperators ENNReal +namespace ClassicalON + +def signValue (t : Bool) : ℝ := if t then 1 else -1 + +def signLaw : Measure Bool := (2 : ℝ≥0∞)⁻¹ • Measure.count + +instance signLaw_isProbability : IsProbabilityMeasure signLaw := by + constructor + norm_num [signLaw,Measure.count_apply_finite] + exact ENNReal.inv_mul_cancel (by norm_num) (by norm_num) + +variable {V : Type uV} [Fintype V] + +def isingReference : Measure (V → Bool) := Measure.pi (fun _ => signLaw) + +instance isingReference_isProbability : IsProbabilityMeasure (isingReference (V := V)) := by + unfold isingReference; infer_instance + +def isingU (t : Bool×Bool) : ℝ := (signValue t.1+signValue t.2)/2 + +def isingW (t : Bool×Bool) : ℝ := (signValue t.1-signValue t.2)/2 + +omit [Fintype V] in +theorem isingUW_moment (k l : ℕ) : + 0≤∫ t : Bool×Bool,isingU t^k*isingW t^l ∂signLaw.prod signLaw := by + rw [integral_prod _ (compact_integrable (by fun_prop))] + simp only [signLaw,integral_smul_measure,ENNReal.toReal_inv,ENNReal.toReal_ofNat, + smul_eq_mul,integral_count,Fintype.sum_bool] + simp only [isingU,isingW,signValue,Bool.false_eq_true,ite_false,ite_true] + norm_num + by_cases hk : k=0 <;> by_cases hl : l=0 + · subst k; subst l; norm_num + · subst k + simp only [pow_zero,one_mul,zero_pow hl] + have h' : -1≤(-1 : ℝ)^l := by + simpa only [abs_pow,abs_neg,abs_one,one_pow] using neg_abs_le ((-1 : ℝ)^l) + nlinarith + · subst l + simp only [pow_zero,mul_one,zero_pow hk] + have h' : -1≤(-1 : ℝ)^k := by + simpa only [abs_pow,abs_neg,abs_one,one_pow] using neg_abs_le ((-1 : ℝ)^k) + nlinarith + · simp [zero_pow hk,zero_pow hl] + +omit [Fintype V] in +theorem isingUW_product_moment (l : List Bool) : + 0≤∫ t : Bool×Bool,(l.map (fun b => if b then isingU t else isingW t)).prod + ∂signLaw.prod signLaw := by + have he (t : Bool×Bool) : + (l.map (fun b => if b then isingU t else isingW t)).prod = + isingU t^(l.count true)*isingW t^(l.count false) := by + induction l with + | nil => simp + | cons b l ih => cases b <;> simp [ih,pow_succ] <;> ring + simp_rw [he] + exact isingUW_moment _ _ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/JointBond.lean b/lean/OAI/Probability/ClassicalON/JointBond.lean new file mode 100644 index 0000000000000000000000000000000000000000..534e2b1b98cbaefaeee8d5c91e2332513dbce267 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/JointBond.lean @@ -0,0 +1,109 @@ +import OAI.Probability.ClassicalON.SpinBondKernel + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def amplitudeBondParam (left right : E → V) (b : E → ℝ) (r : V → Amplitude) (e : E) : ℝ := + Real.exp (2*b e*(r (left e):ℝ)*(r (right e):ℝ))-1 + +omit [Fintype V] [Fintype E] in +theorem amplitudeBondParam_nonneg (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0 ≤ b e) (r : V → Amplitude) (e : E) : + 0 ≤ amplitudeBondParam left right b r e := by + apply sub_nonneg.mpr + apply Real.one_le_exp + exact mul_nonneg (mul_nonneg (mul_nonneg (by norm_num) (hb e)) (r (left e)).property.1) (r (right e)).property.1 + +omit [Fintype V] [Fintype E] in +theorem amplitudeBondParam_monotone (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0 ≤ b e) : Monotone (amplitudeBondParam left right b) := by + intro r s hrs e + apply sub_le_sub_right + apply Real.exp_le_exp.mpr + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left (hrs (left e)) (mul_nonneg (by norm_num) (hb e)) + · exact hrs (right e) + · exact (r (right e)).property.1 + · exact mul_nonneg (mul_nonneg (by norm_num) (hb e)) (s (left e)).property.1 + +omit [Fintype V] [Fintype E] in +theorem continuous_amplitudeBondParam (left right : E → V) (b : E → ℝ) (e : E) : + Continuous (fun r => amplitudeBondParam left right b r e) := by + unfold amplitudeBondParam; fun_prop + +def bondConditionalMean (left right : E → V) (b : E → ℝ) + (f : (V → Amplitude) → (E → Bool) → ℝ) (r : V → Amplitude) : ℝ := + finiteMean (bondWeight left right (amplitudeBondParam left right b r)) (f r) + +omit [Fintype V] in +theorem continuous_bondConditionalMean (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) + {f : (V → Amplitude) → (E → Bool) → ℝ} (hf : ∀ η,Continuous (fun r => f r η)) : + Continuous (bondConditionalMean left right b f) := by + have hw (η : E → Bool) : Continuous (fun r => bondWeight left right (amplitudeBondParam left right b r) η) := by + unfold bondWeight bondProduct + apply Continuous.mul continuous_const + apply continuous_finsetProd + intro e _ + split + · exact continuous_amplitudeBondParam left right b e + · exact continuous_const + exact (continuous_finsetSum _ (fun η _ => (hw η).mul (hf η))).div + (continuous_finsetSum _ (fun η _ => hw η)) + (fun r => (bondWeight_sum_pos left right (amplitudeBondParam_nonneg left right b hb r)).ne') + +omit [Fintype V] in +theorem bondConditionalMean_nonneg (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) + {f : (V → Amplitude) → (E → Bool) → ℝ} (hf : ∀ r η,0 ≤ f r η) (r : V → Amplitude) : + 0 ≤ bondConditionalMean left right b f r := + finiteMean_nonneg (bondWeight_nonneg left right (amplitudeBondParam_nonneg left right b hb r)) (hf r) + +theorem bondConditionalMean_monotone (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) + {f : (V → Amplitude) → (E → Bool) → ℝ} (hf : ∀ r η,0 ≤ f r η) + (hmr : ∀ η,Monotone (fun r => f r η)) (hmη : ∀ r,Monotone (f r)) : + Monotone (bondConditionalMean left right b f) := by + intro r s hrs + apply le_trans (bondMean_mono left right (amplitudeBondParam_nonneg left right b hb r) + (amplitudeBondParam_monotone left right b hb hrs) (hf r) (hmη r)) + exact finiteMean_mono (bondWeight_nonneg left right (amplitudeBondParam_nonneg left right b hb s)) + (fun η => hmr η hrs) + +def jointBondMean (μ : Measure Amplitude) (left right : E → V) (b : E → ℝ) + (f : (V → Amplitude) → (E → Bool) → ℝ) : ℝ := + weightedMean (Measure.pi (fun _ : V => μ)) (amplitudeDensity left right b) + (bondConditionalMean left right b f) + +theorem jointBond_associated (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (left right : E → V) (b : E → ℝ) (hb : ∀ e,0 ≤ b e) + {f g : (V → Amplitude) → (E → Bool) → ℝ} + (hf : ∀ η,Continuous (fun r => f r η)) (hg : ∀ η,Continuous (fun r => g r η)) + (hfn : ∀ r η,0 ≤ f r η) (hgn : ∀ r η,0 ≤ g r η) + (hfr : ∀ η,Monotone (fun r => f r η)) (hgr : ∀ η,Monotone (fun r => g r η)) + (hfη : ∀ r,Monotone (f r)) (hgη : ∀ r,Monotone (g r)) : + jointBondMean μ left right b f*jointBondMean μ left right b g ≤ + jointBondMean μ left right b (fun r η => f r η*g r η) := by + have hcf := continuous_bondConditionalMean left right b hb hf + have hcg := continuous_bondConditionalMean left right b hb hg + apply le_trans (amplitude_associated_any μ left right b hb + _ _ hcf hcg (bondConditionalMean_nonneg left right b hb hfn) + (bondConditionalMean_nonneg left right b hb hgn) + (bondConditionalMean_monotone left right b hb hfn hfr hfη) + (bondConditionalMean_monotone left right b hb hgn hgr hgη)) + apply weightedMean_mono (continuous_amplitudeDensity _ _ _) (amplitudeDensity_pos _ _ _) + (hcf.mul hcg) (continuous_bondConditionalMean left right b hb (fun η => (hf η).mul (hg η))) + intro r + exact bondMean_associated left right (amplitudeBondParam_nonneg left right b hb r) + (hfn r) (hgn r) (hfη r) (hgη r) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/LatticeGeometry.lean b/lean/OAI/Probability/ClassicalON/LatticeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..568f121761ef893d4451d2783c32024df7ffe9df --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/LatticeGeometry.lean @@ -0,0 +1,108 @@ +import OAI.Probability.ClassicalON.ProfileEstimates + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace ClassicalON + +def latticeAxis (m : Bool) : Site := if m then (0,1) else (1,0) + +def latticeTorus (L : ℕ) (x : Site) : DiscreteTorus L := ((x.1:ZMod L),(x.2:ZMod L)) + +@[simp] theorem latticeTorus_add (L : ℕ) (x y : Site) : + latticeTorus L (x+y) = latticeTorus L x+latticeTorus L y := by + ext <;> simp [latticeTorus] + +def scaledSite (k : ℕ) (x : Site) : ℝ × ℝ := + ((x.1:ℝ)/(2:ℝ)^k, (x.2:ℝ)/(2:ℝ)^k) + +@[simp] theorem scaledSite_add_axis (k : ℕ) (x : Site) (m : Bool) : + scaledSite k (x+latticeAxis m) = squareStep m (1/(2:ℝ)^k) (scaledSite k x) := by + cases m <;> ext <;> simp [scaledSite, latticeAxis, squareStep, add_div] + +namespace LatticeGraph + +def edgeDirection (G : LatticeGraph) (e : G.edges) : Bool := + decide (e.val.2.val.1 = e.val.1.val.1) + +theorem edge_step (G : LatticeGraph) (e : G.edges) : + e.val.2.val = e.val.1.val+latticeAxis (G.edgeDirection e) := by + rcases G.nearest e.val e.property with h | h + · have hn : e.val.2.val.1 ≠ e.val.1.val.1 := by omega + simp only [edgeDirection, decide_eq_false hn, latticeAxis, Bool.false_eq_true, ↓reduceIte] + exact Prod.ext h.1 (by simpa using h.2) + · simp only [edgeDirection, h.1, decide_true, latticeAxis, ↓reduceIte] + exact Prod.ext (by simpa using h.1) h.2 + +abbrev DirectionalEdges (G : LatticeGraph) (m : Bool) := {e : G.edges // G.edgeDirection e=m} + +theorem directional_origin_injective (G : LatticeGraph) (m : Bool) : + Function.Injective (fun e : G.DirectionalEdges m => e.val.val.1) := by + intro e f h + change e.val.val.1 = f.val.val.1 at h + have he := G.edge_step e.val + have hf := G.edge_step f.val + rw [e.property] at he + rw [f.property] at hf + have hy : e.val.val.2 = f.val.val.2 := by + apply Subtype.ext + rw [he, hf, h] + apply Subtype.ext + apply Subtype.ext + exact Prod.ext h hy + +def WithinDyadicBox (G : LatticeGraph) (k : ℕ) : Prop := + ∀ x : G.vertices, |x.val.1| ≤ 2*(2^k:ℕ) ∧ |x.val.2| ≤ 2*(2^k:ℕ) + +theorem torus_site_injective (G : LatticeGraph) (k : ℕ) (hG : G.WithinDyadicBox k) : + Function.Injective (fun x : G.vertices => latticeTorus (16*2^k) x.val) := by + intro x y h + apply Subtype.ext + apply Prod.ext + · apply zmod_cast_inj_interval (16*2^k) (-(2*(2^k:ℕ)):ℤ) _ _ + · have hx := abs_le.mp (hG x).1; have hN : 0<2^k := by positivity + constructor <;> omega + · have hy := abs_le.mp (hG y).1; have hN : 0<2^k := by positivity + constructor <;> omega + · exact congrArg Prod.fst h + · apply zmod_cast_inj_interval (16*2^k) (-(2*(2^k:ℕ)):ℤ) _ _ + · have hx := abs_le.mp (hG x).2; have hN : 0<2^k := by positivity + constructor <;> omega + · have hy := abs_le.mp (hG y).2; have hN : 0<2^k := by positivity + constructor <;> omega + · exact congrArg Prod.snd h + +theorem directional_torus_injective (G : LatticeGraph) (k : ℕ) (hG : G.WithinDyadicBox k) (m : Bool) : + Function.Injective (fun e : G.DirectionalEdges m => latticeTorus (16*2^k) e.val.val.1.val) := + (G.torus_site_injective k hG).comp (G.directional_origin_injective m) + +theorem edge_card_bound (G : LatticeGraph) (k : ℕ) (hG : G.WithinDyadicBox k) : + (Fintype.card G.edges:ℝ) ≤ 512*((2:ℝ)^k)^2 := by + let i := fun e : G.edges => (G.edgeDirection e, latticeTorus (16*2^k) e.val.1.val) + have hi : Function.Injective i := by + intro e f h + have hm : G.edgeDirection e = G.edgeDirection f := congrArg Prod.fst h + have hx := (G.torus_site_injective k hG) (congrArg Prod.snd h) + have he := G.edge_step e + have hf := G.edge_step f + have hy : e.val.2 = f.val.2 := by + apply Subtype.ext + rw [he,hf,hm,hx] + apply Subtype.ext + exact Prod.ext hx hy + have hc := Fintype.card_le_of_injective i hi + simp only [Fintype.card_prod, Fintype.card_bool, ZMod.card] at hc + have hh : (Fintype.card G.edges:ℝ) ≤ 2*((16*(2:ℝ)^k)*(16*(2:ℝ)^k)) := by exact_mod_cast hc + nlinarith + +theorem scaled_edge_distance (G : LatticeGraph) (k : ℕ) (e : G.edges) : + ‖scaledSite k e.val.2.val-scaledSite k e.val.1.val‖ = 1/(2:ℝ)^k := by + rw [G.edge_step e, scaledSite_add_axis, squareStep_distance, abs_of_pos (by positivity)] + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/LatticeModes.lean b/lean/OAI/Probability/ClassicalON/LatticeModes.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d0c0d55446401b73b70a40827320e025e17a3be --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/LatticeModes.lean @@ -0,0 +1,100 @@ +import OAI.Probability.ClassicalON.SquareEstimates + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +variable {k : ℕ} + +def latticeMode (m s : Bool) (p : DyadicFreq k) (x : Site) : ℂ := + (dyadicWeight p:ℂ) * (squareProfile m s (scaledSite k x):ℂ) * + torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) x) + +theorem groupedPoint_abs_bound (m s : Bool) (p : DyadicFreq k) : + |(groupedPoint m s p).1| ≤ 2*(dyadicRadius p:ℤ) ∧ + |(groupedPoint m s p).2| ≤ 2*(dyadicRadius p:ℤ) := by + have hp := dyadicPoint_bounds p + have hr : (0:ℤ) omega) + have h2 : |(dyadicPoint p).2| ≤ 2*(dyadicRadius p:ℤ) := abs_le.mpr (by constructor <;> omega) + cases m <;> cases s + · simpa [groupedPoint] using And.intro h1 h2 + · simpa [groupedPoint] using And.intro h1 h2 + · simpa [groupedPoint] using And.intro h2 h1 + · simpa [groupedPoint] using And.intro h2 h1 + +theorem groupedWave_axis (m s j : Bool) (p : DyadicFreq k) : + torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) (latticeAxis j)) = + ZMod.stdAddChar ((if j then (groupedPoint m s p).2 else (groupedPoint m s p).1):ZMod (16*2^k)) := by + cases j <;> simp [torusWave, groupedTorusPoint, latticeTorus, latticeAxis] + +theorem groupedWave_axis_sine (m s j : Bool) (p : DyadicFreq k) : + torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) (latticeAxis j)) = + Complex.exp (Complex.I*((dyadicAngle k ((if j then (groupedPoint m s p).2 else (groupedPoint m s p).1):ℤ):ℝ):ℂ)) := by + rw [groupedWave_axis] + cases j <;> simp only [Bool.false_eq_true, ↓reduceIte] + all_goals + rw [ZMod.stdAddChar_coe] + congr 1 + unfold dyadicAngle + push_cast + ring + +theorem groupedWave_multiplier_bound (m s j : Bool) (p : DyadicFreq k) : + ‖((1/(dyadicRadius p:ℝ)):ℂ) * + (torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) (latticeAxis j))-1)‖ ≤ + Real.pi/(4*(2:ℝ)^k) := by + have hr : (0:ℝ) exact norm_stdAddChar_intCast_sub_one (L := 16*2^k) _ + calc _ ≤ (1/(dyadicRadius p:ℝ))*((2*Real.pi/(16*2^k:ℕ))*|(((if j then (groupedPoint m s p).2 else (groupedPoint m s p).1):ℤ):ℝ)|) := + mul_le_mul_of_nonneg_left hchar (by positivity) + _ ≤ (1/(dyadicRadius p:ℝ))*((2*Real.pi/(16*2^k:ℕ))*(2*(dyadicRadius p:ℝ))) := by gcongr + _ = Real.pi/(4*(2:ℝ)^k) := by push_cast; field_simp [ne_of_gt hr]; ring + +theorem latticeMode_norm_bound (m s : Bool) (p : DyadicFreq k) (x : Site) (C : ℝ) + (hC : |squareProfile m s (scaledSite k x)| ≤ C) : ‖latticeMode m s p x‖ ≤ dyadicWeight p*C := by + simp only [latticeMode, norm_mul, torusWave_norm, mul_one, Complex.norm_real, Real.norm_eq_abs] + rw [abs_of_pos (dyadicWeight_pos p)] + exact mul_le_mul_of_nonneg_left hC (dyadicWeight_pos p).le + +namespace LatticeGraph + +def modeGradient (G : LatticeGraph) (m s : Bool) (p : DyadicFreq k) (e : G.edges) : ℂ := + latticeMode m s p e.val.2.val-latticeMode m s p e.val.1.val + +def scaledModeGradient (G : LatticeGraph) (m s : Bool) (p : DyadicFreq k) (e : G.edges) : ℂ := + (Real.sqrt (dyadicRadius p:ℝ):ℂ)*G.modeGradient m s p e + +theorem scaledModeGradient_formula (G : LatticeGraph) (m s : Bool) (p : DyadicFreq k) (e : G.edges) : + G.scaledModeGradient m s p e = + ((1/(dyadicRadius p:ℝ)):ℂ) * + ((squareProfile m s (scaledSite k e.val.2.val):ℂ)*torusWave (groupedTorusPoint m s p) + (latticeTorus (16*2^k) e.val.1.val+latticeTorus (16*2^k) (latticeAxis (G.edgeDirection e))) - + (squareProfile m s (scaledSite k e.val.1.val):ℂ)*torusWave (groupedTorusPoint m s p) + (latticeTorus (16*2^k) e.val.1.val)) := by + have h := congrArg Complex.ofReal (dyadicWeight_mul_sqrt p) + push_cast at h + simp only [scaledModeGradient, modeGradient, latticeMode] + rw [G.edge_step e, latticeTorus_add] + linear_combination ( ((squareProfile m s (scaledSite k (e.val.1.val+latticeAxis (G.edgeDirection e))):ℂ)* + torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) e.val.1.val+latticeTorus (16*2^k) (latticeAxis (G.edgeDirection e)))) - + ((squareProfile m s (scaledSite k e.val.1.val):ℂ)*torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) e.val.1.val)) ) * h + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/LatticeRadius.lean b/lean/OAI/Probability/ClassicalON/LatticeRadius.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c61d9be875a1346ccd829065bbbbc43b226f516 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/LatticeRadius.lean @@ -0,0 +1,100 @@ +import OAI.Probability.ClassicalON.LatticeRestriction + +namespace OAI + +noncomputable section +open Set +open scoped Classical +namespace ClassicalON + +def siteRadius (z v : Site) : ℤ := max |v.1-z.1| |v.2-z.2| + +@[simp] theorem siteRadius_self (z : Site) : siteRadius z z=0 := by simp [siteRadius] + +theorem siteRadius_nonneg (z v : Site) : 0≤ siteRadius z v := le_trans (abs_nonneg _) (le_max_left _ _) + +theorem siteRadius_symm (z v : Site) : siteRadius z v=siteRadius v z := by + simp only [siteRadius,abs_sub_comm] + +theorem siteRadius_le_iff (z v : Site) (N : ℤ) : + siteRadius z v≤N ↔ |v.1-z.1|≤N ∧ |v.2-z.2|≤N := max_le_iff + +theorem siteRadius_triangle (x y z : Site) : siteRadius x z≤ siteRadius x y+siteRadius y z := by + apply max_le + · have h := abs_add_le (y.1-x.1) (z.1-y.1) + have h1 : |y.1-x.1|≤ siteRadius x y := le_max_left _ _ + have h2 : |z.1-y.1|≤ siteRadius y z := le_max_left _ _ + have he : (y.1-x.1)+(z.1-y.1)=z.1-x.1 := by ring + rw [he] at h + omega + · have h := abs_add_le (y.2-x.2) (z.2-y.2) + have h1 : |y.2-x.2|≤ siteRadius x y := le_max_right _ _ + have h2 : |z.2-y.2|≤ siteRadius y z := le_max_right _ _ + have he : (y.2-x.2)+(z.2-y.2)=z.2-x.2 := by ring + rw [he] at h + omega + +theorem siteRadius_neighbor {x y : Site} (h : PositiveNeighbor x y) : siteRadius x y=1 := by + rcases h with ⟨h1,h2⟩ | ⟨h1,h2⟩ <;> simp [siteRadius,h1,h2] + +theorem siteRadius_neighbor_step (z : Site) {x y : Site} (h : PositiveNeighbor x y ∨ PositiveNeighbor y x) : + siteRadius z y≤ siteRadius z x+1 ∧ siteRadius z x≤ siteRadius z y+1 := by + have hh : siteRadius x y=1 := by + rcases h with h | h + · exact siteRadius_neighbor h + · rw [siteRadius_symm]; exact siteRadius_neighbor h + constructor + · simpa only [hh] using siteRadius_triangle z x y + · have := siteRadius_triangle z y x + rwa [siteRadius_symm y x,hh] at this + +def annulusSites (N : ℤ) (z : Site) : Set Site := {v | N≤ siteRadius z v ∧ siteRadius z v≤2*N} + +def annulusBoundary (N : ℤ) (z : Site) : Set Site := {v | siteRadius z v=N ∨ siteRadius z v=2*N} + +def annulusInterior (N : ℤ) (z : Site) : Set Site := {v | N b (G.restrictEdge _ e) + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/LatticeRestriction.lean b/lean/OAI/Probability/ClassicalON/LatticeRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..5cc199d893f83a5b190b785487528e12a4ace2dd --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/LatticeRestriction.lean @@ -0,0 +1,89 @@ +import OAI.Probability.ClassicalON.LatticeGeometry + +namespace OAI + +noncomputable section +open Set +open scoped Classical +namespace ClassicalON.LatticeGraph + +def restrictVertices (G : LatticeGraph) (P : Site → Prop) : Finset Site := G.vertices.filter P + +def restrictVertex (G : LatticeGraph) (P : Site → Prop) (v : G.restrictVertices P) : G.vertices := + ⟨v.val,(Finset.mem_filter.mp v.property).1⟩ + +def restrict (G : LatticeGraph) (P : Site → Prop) : LatticeGraph where + vertices := G.restrictVertices P + edges := Finset.univ.filter (fun e : G.restrictVertices P × G.restrictVertices P => + (G.restrictVertex P e.1,G.restrictVertex P e.2)∈G.edges) + nearest _e he := G.nearest _ (Finset.mem_filter.mp he).2 + +def restrictEdge (G : LatticeGraph) (P : Site → Prop) (e : (G.restrict P).edges) : G.edges := + ⟨(G.restrictVertex P e.val.1,G.restrictVertex P e.val.2),(Finset.mem_filter.mp e.property).2⟩ + +def restrictVertexEquiv (G : LatticeGraph) (P : Site → Prop) : + {v : G.vertices // P v.val} ≃ (G.restrict P).vertices where + toFun v := ⟨v.val.val,Finset.mem_filter.mpr ⟨v.val.property,v.property⟩⟩ + invFun v := ⟨G.restrictVertex P v,(Finset.mem_filter.mp v.property).2⟩ + left_inv _ := rfl + right_inv _ := rfl + +def restrictEdgeEquiv (G : LatticeGraph) (P : Site → Prop) : + {e : G.edges // P e.val.1.val ∧ P e.val.2.val} ≃ (G.restrict P).edges where + toFun e := ⟨(⟨e.val.val.1.val,Finset.mem_filter.mpr ⟨e.val.val.1.property,e.property.1⟩⟩, + ⟨e.val.val.2.val,Finset.mem_filter.mpr ⟨e.val.val.2.property,e.property.2⟩⟩), + Finset.mem_filter.mpr ⟨Finset.mem_univ _,e.val.property⟩⟩ + invFun e := ⟨G.restrictEdge P e,(Finset.mem_filter.mp e.val.1.property).2, + (Finset.mem_filter.mp e.val.2.property).2⟩ + left_inv _ := rfl + right_inv _ := rfl + +@[simp] theorem restrictVertexEquiv_val (G : LatticeGraph) (P : Site → Prop) + (v : {v : G.vertices // P v.val}) : (G.restrictVertexEquiv P v).val=v.val.val := rfl + +@[simp] theorem restrictEdgeEquiv_left (G : LatticeGraph) (P : Site → Prop) + (e : {e : G.edges // P e.val.1.val ∧ P e.val.2.val}) : + (G.restrictEdgeEquiv P e).val.1=G.restrictVertexEquiv P ⟨e.val.val.1,e.property.1⟩ := rfl + +@[simp] theorem restrictEdgeEquiv_right (G : LatticeGraph) (P : Site → Prop) + (e : {e : G.edges // P e.val.1.val ∧ P e.val.2.val}) : + (G.restrictEdgeEquiv P e).val.2=G.restrictVertexEquiv P ⟨e.val.val.2,e.property.2⟩ := rfl + +def translateVertexEquiv (G : LatticeGraph) (z : Site) : + G.vertices ≃ G.vertices.map (Equiv.addRight (-z)).toEmbedding := + Finset.equivMap (Equiv.addRight (-z)).toEmbedding G.vertices + +def translate (G : LatticeGraph) (z : Site) : LatticeGraph where + vertices := G.vertices.map (Equiv.addRight (-z)).toEmbedding + edges := G.edges.map ((Equiv.prodCongr (G.translateVertexEquiv z) (G.translateVertexEquiv z)).toEmbedding) + nearest e he := by + obtain ⟨e',he',rfl⟩ := Finset.mem_map.mp he + have h := G.nearest e' he' + change PositiveNeighbor (e'.1.val+-z) (e'.2.val+-z) + rcases h with h | h + · left + constructor <;> simp only [Prod.fst_add,Prod.snd_add,Prod.fst_neg,Prod.snd_neg] + · omega + · omega + · right + constructor <;> simp only [Prod.fst_add,Prod.snd_add,Prod.fst_neg,Prod.snd_neg] + · omega + · omega + +def translateEdgeEquiv (G : LatticeGraph) (z : Site) : G.edges ≃ (G.translate z).edges := + Finset.equivMap ((Equiv.prodCongr (G.translateVertexEquiv z) (G.translateVertexEquiv z)).toEmbedding) G.edges + +@[simp] theorem translateVertexEquiv_val (G : LatticeGraph) (z : Site) (v : G.vertices) : + (G.translateVertexEquiv z v).val=v.val-z := rfl + +@[simp] theorem translateEdgeEquiv_left (G : LatticeGraph) (z : Site) (e : G.edges) : + (G.translateEdgeEquiv z e).val.1=G.translateVertexEquiv z e.val.1 := rfl + +@[simp] theorem translateEdgeEquiv_right (G : LatticeGraph) (z : Site) (e : G.edges) : + (G.translateEdgeEquiv z e).val.2=G.translateVertexEquiv z e.val.2 := rfl + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/Main.lean b/lean/OAI/Probability/ClassicalON/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..b838a422bbd33393382b95b9ed2f8c6a5177b134 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/Main.lean @@ -0,0 +1,48 @@ +import OAI.Probability.ClassicalON.BlockReduction + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace BigOperators Classical +namespace ClassicalON + +theorem correlation_eq_freeSpinMean (n : ℕ) (G : LatticeGraph) (b : G.edges → ℝ) (x y : G.vertices) : + correlation n G b x y=freeSpinMean n (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (fun s => ⟪(s x).val,(s y).val⟫_ℝ) := by + unfold correlation partition interaction referenceLaw freeSpinMean weightedMean freeSpinEnergy freeSpinReference + congr 1 + apply integral_congr_ae + filter_upwards with s + exact mul_comm _ _ + +theorem main : ExponentialDecay := by + intro n hn β hβ + obtain ⟨k,rfl⟩ := Nat.exists_eq_add_of_le hn + let : NeZero (3+k) := ⟨by omega⟩ + obtain ⟨m,hm,hexp⟩ := LatticeGraph.connection_exponential β hβ.le + refine ⟨(3+k:ℕ)*4,m,hm,?_⟩ + intro G b hb x y + have hthree (c : G.edges → ℝ) (hc : ∀ e,0 ≤ c e ∧ c e ≤ b e) : + 0 ≤ freeSpinMean 3 (fun e : G.edges => e.val.1) (fun e => e.val.2) c (firstSpinProduct x y) ∧ + freeSpinMean 3 (fun e : G.edges => e.val.1) (fun e => e.val.2) c (firstSpinProduct x y) ≤ + 4*Real.exp (-m*siteDistance x.val y.val) := by + have hfirst := firstSpinMean_bounds (fun e : G.edges => e.val.1) (fun e => e.val.2) c + (fun e => (hc e).1) x y + exact ⟨hfirst.1,hfirst.2.trans (hexp G c (fun e => ⟨(hc e).1,(hc e).2.trans (hb e).2⟩) x y)⟩ + have hbound := coordinateSpinMean_block_bounds k (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (fun e => (hb e).1) x y (4*Real.exp (-m*siteDistance x.val y.val)) hthree + rw [correlation_eq_freeSpinMean,innerSpinMean_eq_coordinate (3+k) + (fun e : G.edges => e.val.1) (fun e => e.val.2) b ⟨0,by omega⟩ x y] + constructor + · exact mul_nonneg (Nat.cast_nonneg _) hbound.1 + · calc + _ ≤ (3+k:ℕ)*(4*Real.exp (-m*siteDistance x.val y.val)) := + mul_le_mul_of_nonneg_left hbound.2 (Nat.cast_nonneg _) + _ = _ := by ring + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/MatrixSquare.lean b/lean/OAI/Probability/ClassicalON/MatrixSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..db2ba32ea098662f1de20551d98a19a9a6af8543 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/MatrixSquare.lean @@ -0,0 +1,99 @@ +import OAI.Probability.ClassicalON.DyadicModes + +namespace OAI + +universe uP uX + +noncomputable section +open scoped BigOperators ComplexConjugate + +namespace ClassicalON + +def SquareBound {X : Type uX} {P : Type uP} [Fintype X] [Fintype P] + (U : X → P → ℂ) (a : ℝ) : Prop := + ∀ v : P → ℂ, (∑ x, ‖∑ p, U x p*v p‖^2) ≤ a^2*∑ p, ‖v p‖^2 + +variable {X : Type uX} {P : Type uP} [Fintype X] [Fintype P] + +theorem SquareBound.column {U : X → P → ℂ} {a : ℝ} (h : SquareBound U a) (p : P) : + ∑ x, ‖U x p‖^2 ≤ a^2 := by + classical + have hs : (∑ q : P, ‖((Pi.single p (1:ℂ)) : P → ℂ) q‖^2) = 1 := by + simp only [Pi.single_apply, apply_ite, norm_one, norm_zero, ite_pow, one_pow, + zero_pow (by decide : 2 ≠ 0), Finset.sum_ite_eq', Finset.mem_univ, ite_true] + have he := h (Pi.single p 1) + rw [hs, mul_one] at he + simpa only [Pi.single_apply, mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] using he + +theorem SquareBound.gram_weighted {U : X → P → ℂ} {a : ℝ} + (h : SquareBound U a) (d : P → ℂ) : + (∑ x, ∑ y, ‖∑ p, U x p*d p*conj (U y p)‖^2) ≤ a^4*∑ p, ‖d p‖^2 := by + calc _ = ∑ y, ∑ x, ‖∑ p, U x p*(d p*conj (U y p))‖^2 := by + simp only [mul_assoc] + exact Finset.sum_comm + _ ≤ ∑ y, a^2*∑ p, ‖d p*conj (U y p)‖^2 := + Finset.sum_le_sum fun y _ => h (fun p => d p*conj (U y p)) + _ = a^2*∑ p, ‖d p‖^2*(∑ y, ‖U y p‖^2) := by + simp only [norm_mul, Complex.norm_conj, mul_pow, Finset.mul_sum] + rw [Finset.sum_comm] + _ ≤ a^2*∑ p, ‖d p‖^2*a^2 := by + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + exact Finset.sum_le_sum fun p _ => mul_le_mul_of_nonneg_left (h.column p) (sq_nonneg _) + _ = _ := by rw [← Finset.sum_mul]; ring + +theorem sum_norm_add_sq_le (f g : X → ℂ) : + (∑ x, ‖f x+g x‖^2) ≤ 2*(∑ x, ‖f x‖^2)+2*(∑ x, ‖g x‖^2) := by + rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro x _ + have hv := norm_add_le (f x) (g x) + have hsq := sq_le_sq₀ (norm_nonneg _) (add_nonneg (norm_nonneg _) (norm_nonneg _)) |>.mpr hv + nlinarith [sq_nonneg (‖f x‖-‖g x‖)] + +theorem parseval_of_orthogonal [DecidableEq P] (W : X → P → ℂ) (M : ℝ) + (ho : ∀ p q, (∑ x, W x p*conj (W x q)) = if p=q then (M:ℂ) else 0) + (v : P → ℂ) : + (∑ x, ‖∑ p, W x p*v p‖^2) = M*∑ p, ‖v p‖^2 := by + classical + have he : (∑ x, (∑ p, W x p*v p)*conj (∑ q, W x q*v q)) = + (M:ℂ)*∑ p, v p*conj (v p) := by + simp only [map_sum, map_mul, Finset.sum_mul, Finset.mul_sum] + calc + (∑ x, ∑ q, ∑ p, W x p*v p*(conj (W x q)*conj (v q))) = + ∑ q, ∑ p, ∑ x, W x p*v p*(conj (W x q)*conj (v q)) := by + rw [Finset.sum_comm] + exact Finset.sum_congr rfl (fun q _ => Finset.sum_comm) + _ = ∑ p, ∑ q, (∑ x, W x p*conj (W x q))*(v p*conj (v q)) := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro x _ + ring + _ = _ := by simp [ho] + have hr := congrArg Complex.re he + simp only [Complex.mul_conj, Complex.normSq_eq_norm_sq, + Complex.ofReal_re, ← Complex.ofReal_sum, ← Complex.ofReal_mul] at hr + exact hr + +theorem parseval_diagonal_bound [DecidableEq P] (W : X → P → ℂ) (M c : ℝ) (hM : 0 ≤ M) + (ho : ∀ p q, (∑ x, W x p*conj (W x q)) = if p=q then (M:ℂ) else 0) + (d v : P → ℂ) (hd : ∀ p, ‖d p‖ ≤ c) : + (∑ x, ‖∑ p, W x p*(d p*v p)‖^2) ≤ (M*c^2)*∑ p, ‖v p‖^2 := by + rw [parseval_of_orthogonal W M ho, mul_assoc] + apply mul_le_mul_of_nonneg_left _ hM + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro p _ + rw [norm_mul, mul_pow] + exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) (hd p) 2) (sq_nonneg _) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/MixedWard.lean b/lean/OAI/Probability/ClassicalON/MixedWard.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff889721286c60fb316dad5f88384af710ed3c16 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/MixedWard.lean @@ -0,0 +1,343 @@ +import OAI.Probability.ClassicalON.RotationWork + +namespace OAI + +universe uE uK uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace + +namespace MixedAlgebra +variable {E : Type uE} {K : Type uK} [Fintype E] [CommRing K] +theorem weighted_const_mul (J u : E → K) (r : K) : + weighted J (fun e => r * u e) = r * weighted J u := by + simp only [weighted, Finset.mul_sum] + apply Finset.sum_congr rfl + intro e _ + ring +end MixedAlgebra + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +omit [Fintype V] in +theorem planeEnergy_two (S : SpinSystem 3 V E) (u v : E → ℝ) (σ : V → Spin 3) : + S.energy (fun e => planeOperator (u e) (v e)^2) σ = + MixedAlgebra.weighted (S.mixedCoefficients σ).aa (u*u) + + 2 * MixedAlgebra.weighted (S.mixedCoefficients σ).ab (u*v) + + MixedAlgebra.weighted (S.mixedCoefficients σ).bb (v*v) := by + simp only [planeOperator_square] + change S.energy (((fun e => u e^2 • axisA^2) + + (fun e => (2*u e*v e) • mixedAB)) + (fun e => v e^2 • axisB^2)) σ = _ + rw [S.energy_add, S.energy_add, S.energy_weighted, S.energy_weighted, S.energy_weighted] + simp only [mixedCoefficients, pow_two, mul_assoc] + rw [MixedAlgebra.weighted_const_mul] + rfl + +omit [Fintype V] in +theorem planeEnergy_three (S : SpinSystem 3 V E) (u v : E → ℝ) (σ : V → Spin 3) : + S.energy (fun e => planeOperator (u e) (v e)^3) σ = + MixedAlgebra.weighted (S.localCoefficient (axisA^3) σ) (u^3) + + 3 * MixedAlgebra.weighted (S.mixedCoefficients σ).aab (u*u*v) + + 3 * MixedAlgebra.weighted (S.mixedCoefficients σ).abb (u*v*v) + + MixedAlgebra.weighted (S.localCoefficient (axisB^3) σ) (v^3) := by + simp only [planeOperator_cube] + change S.energy ((((fun e => u e^3 • axisA^3) + + (fun e => (3*u e^2*v e) • mixedAAB)) + + (fun e => (3*u e*v e^2) • mixedABB)) + (fun e => v e^3 • axisB^3)) σ = _ + rw [S.energy_add, S.energy_add, S.energy_add, + S.energy_weighted, S.energy_weighted, S.energy_weighted, S.energy_weighted] + simp only [mixedCoefficients, pow_two, mul_assoc] + rw [MixedAlgebra.weighted_const_mul, MixedAlgebra.weighted_const_mul] + rfl + +omit [Fintype V] in +theorem planeEnergy_four_even (S : SpinSystem 3 V E) (u v : E → ℝ) (σ : V → Spin 3) : + S.energy (fun e => planeOperator (u e) (v e)^4) σ + + S.energy (fun e => planeOperator (u e) (-v e)^4) σ = + 2 * MixedAlgebra.weighted (S.localCoefficient (axisA^4) σ) (u^4) + + 12 * MixedAlgebra.weighted (S.mixedCoefficients σ).aabb (u*u*v*v) + + 2 * MixedAlgebra.weighted (S.localCoefficient (axisB^4) σ) (v^4) := by + rw [← S.energy_add] + have hp : (fun e => planeOperator (u e) (v e)^4) + + (fun e => planeOperator (u e) (-v e)^4) = + ((fun e => (2*u e^4) • axisA^4) + + (fun e => (12*u e^2*v e^2) • mixedAABB)) + + (fun e => (2*v e^4) • axisB^4) := by + funext e + exact planeOperator_four_even (u e) (v e) + rw [hp, S.energy_add, S.energy_add, S.energy_weighted, S.energy_weighted, S.energy_weighted] + simp only [mixedCoefficients, pow_two, mul_assoc] + rw [MixedAlgebra.weighted_const_mul, MixedAlgebra.weighted_const_mul, + MixedAlgebra.weighted_const_mul] + rfl + +variable {n : ℕ} + +omit [Fintype V] [Fintype E] in +theorem operator_smul_pow (r : ℝ) (M : SpinOperator n) (k : ℕ) : + (r • M)^k = r^k • M^k := by + induction k with + | zero => simp only [pow_zero, one_smul] + | succ k ih => + rw [pow_succ, ih, Algebra.smul_mul_assoc (r^k) (M^k) (r • M), + Algebra.mul_smul_comm r (M^k) M, smul_smul (r^k) r (M^k*M), + ← pow_succ, ← pow_succ] + +omit [Fintype V] in +theorem energy_scaled_power (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℝ) (k : ℕ) (σ : V → Spin n) : + S.energy (fun e => (u e • M)^k) σ = + MixedAlgebra.weighted (S.localCoefficient (M^k) σ) (u^k) := by + have hp : (fun e => (u e • M)^k) = (fun e => (u e)^k • M^k) := + funext (fun e => operator_smul_pow (u e) M k) + rw [hp] + exact S.energy_weighted (M^k) (u^k) σ + +def averageLinear [NeZero n] (S : SpinSystem n V E) : C((V → Spin n), ℝ) →ₗ[ℝ] ℝ where + toFun f := S.average f + map_add' f g := S.average_add f.continuous g.continuous + map_smul' r f := S.average_mul_const r f + +@[simp] theorem averageLinear_apply [NeZero n] (S : SpinSystem n V E) + (f : C((V → Spin n), ℝ)) : S.averageLinear f = S.average f := rfl + +attribute [local fun_prop] continuous_energy + +omit [Fintype V] in +theorem continuous_fourthPolynomial (S : SpinSystem n V E) (A : E → SpinOperator n) : + Continuous (fun σ => fourthPolynomial (fun k => S.energy (fun e => A e^k) σ)) := by + unfold fourthPolynomial + fun_prop + +def fourthObservable (S : SpinSystem n V E) (A : E → SpinOperator n) : C((V → Spin n), ℝ) := + ⟨_, S.continuous_fourthPolynomial A⟩ + +@[simp] theorem average_fourthObservable [NeZero n] (S : SpinSystem n V E) + (A : E → SpinOperator n) : S.averageLinear (S.fourthObservable A) = S.fourthResponse A := rfl + +omit [Fintype V] in +@[fun_prop] theorem continuous_weighted_coefficient (S : SpinSystem n V E) + (M : SpinOperator n) (u : E → ℝ) : + Continuous (fun σ => MixedAlgebra.weighted (S.localCoefficient M σ) u) := by + have he : (fun σ => MixedAlgebra.weighted (S.localCoefficient M σ) u) = + S.energy (fun e => u e • M) := by + funext σ + exact (S.energy_weighted M u σ).symm + rw [he] + exact S.continuous_energy _ + +omit [Fintype V] in +@[fun_prop] theorem continuous_mixedPolynomial (S : SpinSystem 3 V E) + (u v w z : E → ℝ) : + Continuous (fun σ => MixedAlgebra.four (S.mixedCoefficients σ) u v w z) := by + simp only [MixedAlgebra.four, mixedCoefficients] + fun_prop + +def mixedObservable (S : SpinSystem 3 V E) (u v w z : E → ℝ) : C((V → Spin 3), ℝ) := + ⟨_, S.continuous_mixedPolynomial u v w z⟩ + +def mixedResponse (S : SpinSystem 3 V E) (u v w z : E → ℝ) : ℝ := + S.averageLinear (S.mixedObservable u v w z) + +omit [Fintype V] in +theorem fourthObservable_even (S : SpinSystem 3 V E) (u v : E → ℝ) : + S.fourthObservable (fun e => planeOperator (u e) (v e)) + + S.fourthObservable (fun e => planeOperator (u e) (-v e)) - + (2:ℝ) • S.fourthObservable (fun e => u e • axisA) - + (2:ℝ) • S.fourthObservable (fun e => v e • axisB) = + (12:ℝ) • S.mixedObservable u v u v := by + ext σ + change fourthPolynomial (fun k => S.energy (fun e => planeOperator (u e) (v e)^k) σ) + + fourthPolynomial (fun k => S.energy (fun e => planeOperator (u e) (-v e)^k) σ) - + 2 * fourthPolynomial (fun k => S.energy (fun e => (u e • axisA)^k) σ) - + 2 * fourthPolynomial (fun k => S.energy (fun e => (v e • axisB)^k) σ) = + 12 * MixedAlgebra.four (S.mixedCoefficients σ) u v u v + simp only [fourthPolynomial, pow_one, planeEnergy_one, planeEnergy_two, + planeEnergy_three, energy_scaled_power, energy_weighted] + have hn : (fun e => -v e) = -v := rfl + have hv3 : (-v)^3 = -(v^3) := by ring + simp only [hn, hv3, neg_mul, mul_neg, neg_neg, MixedAlgebra.weighted_neg] + have hp := S.planeEnergy_four_even u v σ + have hb := bell4_even + (MixedAlgebra.weighted (S.mixedCoefficients σ).a u) + (MixedAlgebra.weighted (S.mixedCoefficients σ).b v) + (MixedAlgebra.weighted (S.mixedCoefficients σ).aa (u*u)) + (MixedAlgebra.weighted (S.mixedCoefficients σ).ab (u*v)) + (MixedAlgebra.weighted (S.mixedCoefficients σ).bb (v*v)) + (MixedAlgebra.weighted (S.localCoefficient (axisA^3) σ) (u^3)) + (MixedAlgebra.weighted (S.mixedCoefficients σ).aab (u*u*v)) + (MixedAlgebra.weighted (S.mixedCoefficients σ).abb (u*v*v)) + (MixedAlgebra.weighted (S.localCoefficient (axisB^3) σ) (v^3)) + (S.energy (fun e => planeOperator (u e) (v e)^4) σ) + (S.energy (fun e => planeOperator (u e) (-v e)^4) σ) + (MixedAlgebra.weighted (S.localCoefficient (axisA^4) σ) (u^4)) + (MixedAlgebra.weighted (S.mixedCoefficients σ).aabb (u*u*v*v)) + (MixedAlgebra.weighted (S.localCoefficient (axisB^4) σ) (v^4)) hp + rw [MixedAlgebra.four_diagonal] + simp only [bell4, mixedCoefficients] at hb ⊢ + convert hb using 1 + ring_nf + +theorem mixedResponse_diagonal (S : SpinSystem 3 V E) (f g : V → ℝ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) : + 2 * S.mixedResponse (S.differential f) (S.differential g) + (S.differential f) (S.differential g) = + S.secondAxisResponse (S.crossForm f g) (S.crossForm f g) := by + have h := congrArg S.averageLinear + (S.fourthObservable_even (S.differential f) (S.differential g)) + simp only [map_sub, map_add, map_smul, smul_eq_mul, + average_fourthObservable] at h + have hp := S.fourthResponse_plane_even f g hf hg + have ha := S.fourthResponse_axisGradient axisA axisA_skew f hf + have hb := S.fourthResponse_axisGradient axisB axisB_skew g hg + rw [S.planarGradient_eq, S.planarGradient_eq] at hp + have hm : S.differential (-g) = fun e => -S.differential g e := by + funext e + simp only [differential, Pi.neg_apply] + ring + rw [hm] at hp + change S.fourthResponse (fun e => S.differential f e • axisA) = 0 at ha + change S.fourthResponse (fun e => S.differential g e • axisB) = 0 at hb + rw [ha, hb] at h + unfold mixedResponse + linarith + +theorem mixedResponse_polarize_a (S : SpinSystem 3 V E) (u w v : E → ℝ) : + S.mixedResponse (u+w) v (u+w) v = S.mixedResponse u v u v + + 2 * S.mixedResponse u v w v + S.mixedResponse w v w v := by + have hp : S.mixedObservable (u+w) v (u+w) v = S.mixedObservable u v u v + + (2:ℝ) • S.mixedObservable u v w v + S.mixedObservable w v w v := by + ext σ + exact MixedAlgebra.four_polarize_a (S.mixedCoefficients σ) u w v + unfold mixedResponse + rw [hp, map_add, map_add, map_smul, smul_eq_mul] + +theorem mixedResponse_polarize_b (S : SpinSystem 3 V E) (u w v z : E → ℝ) : + S.mixedResponse u (v+z) w (v+z) = S.mixedResponse u v w v + + 2 * S.mixedResponse u v w z + S.mixedResponse u z w z := by + have hp : S.mixedObservable u (v+z) w (v+z) = S.mixedObservable u v w v + + (2:ℝ) • S.mixedObservable u v w z + S.mixedObservable u z w z := by + ext σ + exact MixedAlgebra.four_polarize_b (S.mixedCoefficients σ) u w v z + unfold mixedResponse + rw [hp, map_add, map_add, map_smul, smul_eq_mul] + +omit [Fintype V] in +@[fun_prop] theorem continuous_secondPolynomial (S : SpinSystem 3 V E) (h k : E → ℝ) : + Continuous (fun σ => S.energy (fun e => (h e*k e) • axisC^2) σ + + S.energy (fun e => h e • axisC) σ * S.energy (fun e => k e • axisC) σ) := by + fun_prop + +def secondObservable (S : SpinSystem 3 V E) (h k : E → ℝ) : C((V → Spin 3), ℝ) := + ⟨_, S.continuous_secondPolynomial h k⟩ + +@[simp] theorem secondObservable_average (S : SpinSystem 3 V E) (h k : E → ℝ) : + S.averageLinear (S.secondObservable h k) = S.secondAxisResponse h k := rfl + +omit [Fintype V] in +theorem secondObservable_add_left (S : SpinSystem 3 V E) (u v w : E → ℝ) : + S.secondObservable (u+v) w = S.secondObservable u w + S.secondObservable v w := by + ext σ + change S.energy (fun e => (((u+v) e)*w e) • axisC^2) σ + + S.energy (fun e => (u+v) e • axisC) σ * S.energy (fun e => w e • axisC) σ = + (S.energy (fun e => (u e*w e) • axisC^2) σ + + S.energy (fun e => u e • axisC) σ * S.energy (fun e => w e • axisC) σ) + + (S.energy (fun e => (v e*w e) • axisC^2) σ + + S.energy (fun e => v e • axisC) σ * S.energy (fun e => w e • axisC) σ) + simp only [energy_weighted] + change MixedAlgebra.weighted (S.localCoefficient (axisC^2) σ) ((u+v)*w) + + MixedAlgebra.weighted (S.localCoefficient axisC σ) (u+v) * + MixedAlgebra.weighted (S.localCoefficient axisC σ) w = _ + rw [add_mul, MixedAlgebra.weighted_add, MixedAlgebra.weighted_add] + simp only [MixedAlgebra.weighted, Pi.mul_apply] + ring + +omit [Fintype V] in +theorem secondObservable_symm (S : SpinSystem 3 V E) (u v : E → ℝ) : + S.secondObservable u v = S.secondObservable v u := by + ext σ + change S.energy (fun e => (u e*v e) • axisC^2) σ + + S.energy (fun e => u e • axisC) σ * S.energy (fun e => v e • axisC) σ = _ + simp only [mul_comm, secondObservable, ContinuousMap.coe_mk] + +theorem secondAxisResponse_add_left (S : SpinSystem 3 V E) (u v w : E → ℝ) : + S.secondAxisResponse (u+v) w = S.secondAxisResponse u w + S.secondAxisResponse v w := by + have h := congrArg S.averageLinear (S.secondObservable_add_left u v w) + simpa only [map_add, secondObservable_average] using h + +theorem secondAxisResponse_symm (S : SpinSystem 3 V E) (u v : E → ℝ) : + S.secondAxisResponse u v = S.secondAxisResponse v u := by + exact congrArg S.averageLinear (S.secondObservable_symm u v) + +theorem secondAxisResponse_add_right (S : SpinSystem 3 V E) (u v w : E → ℝ) : + S.secondAxisResponse u (v+w) = S.secondAxisResponse u v + S.secondAxisResponse u w := by + rw [S.secondAxisResponse_symm, S.secondAxisResponse_add_left, + S.secondAxisResponse_symm v, S.secondAxisResponse_symm w] + +omit [Fintype V] [Fintype E] in +theorem differential_add (S : SpinSystem n V E) (f g : V → ℝ) : + S.differential (f+g) = S.differential f + S.differential g := by + funext e + simp only [differential, Pi.add_apply] + ring + +omit [Fintype V] [Fintype E] in +theorem crossForm_add_left (S : SpinSystem 3 V E) (f g h : V → ℝ) : + S.crossForm (f+g) h = S.crossForm f h + S.crossForm g h := by + funext e + simp only [crossForm, Pi.add_apply] + ring + +omit [Fintype V] [Fintype E] in +theorem crossForm_add_right (S : SpinSystem 3 V E) (f g h : V → ℝ) : + S.crossForm f (g+h) = S.crossForm f g + S.crossForm f h := by + funext e + simp only [crossForm, Pi.add_apply] + ring + +theorem mixedResponse_a_polarized (S : SpinSystem 3 V E) (f h g : V → ℝ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hh : ∀ x s, S.pin x = some s → h x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) : + 2 * S.mixedResponse (S.differential f) (S.differential g) + (S.differential h) (S.differential g) = + S.secondAxisResponse (S.crossForm f g) (S.crossForm h g) := by + have hfh : ∀ x s, S.pin x = some s → (f+h) x = 0 := by + intro x s hs + simp only [Pi.add_apply, hf x s hs, hh x s hs, add_zero] + have hp := S.mixedResponse_diagonal (f+h) g hfh hg + rw [S.differential_add, S.mixedResponse_polarize_a, S.crossForm_add_left, + S.secondAxisResponse_add_left, S.secondAxisResponse_add_right, + S.secondAxisResponse_add_right, S.secondAxisResponse_symm (S.crossForm h g)] at hp + have hdiagf := S.mixedResponse_diagonal f g hf hg + have hdiagh := S.mixedResponse_diagonal h g hh hg + linarith + +theorem mixedResponse_ward (S : SpinSystem 3 V E) (f g h k : V → ℝ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) + (hh : ∀ x s, S.pin x = some s → h x = 0) + (hk : ∀ x s, S.pin x = some s → k x = 0) : + 4 * S.mixedResponse (S.differential f) (S.differential g) + (S.differential h) (S.differential k) = + S.secondAxisResponse (S.crossForm f g) (S.crossForm h k) + + S.secondAxisResponse (S.crossForm f k) (S.crossForm h g) := by + have hgk : ∀ x s, S.pin x = some s → (g+k) x = 0 := by + intro x s hs + simp only [Pi.add_apply, hg x s hs, hk x s hs, add_zero] + have hp := S.mixedResponse_a_polarized f h (g+k) hf hh hgk + rw [S.differential_add, S.mixedResponse_polarize_b, S.crossForm_add_right, + S.crossForm_add_right, S.secondAxisResponse_add_left, + S.secondAxisResponse_add_right, S.secondAxisResponse_add_right] at hp + have hdiagg := S.mixedResponse_a_polarized f h g hf hh hg + have hdiagk := S.mixedResponse_a_polarized f h k hf hh hk + linarith + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ModeBounds.lean b/lean/OAI/Probability/ClassicalON/ModeBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..2dc37072efbf63b056419fa094b29d6b2fdb8ddc --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ModeBounds.lean @@ -0,0 +1,65 @@ +import OAI.Probability.ClassicalON.DyadicSums + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON +namespace LatticeGraph +variable {k : ℕ} + +def modeBlockConstant (C : ℝ) : ℝ := Real.sqrt (512*(C^2+C^2*(Real.pi/4)^2)) + +theorem scaledModes_direction_bound (G : LatticeGraph) (hG : G.WithinDyadicBox k) + (C : ℝ) + (hval : ∀ m s z, |squareProfile m s z| ≤ C) + (hLip : ∀ m s z w, |squareProfile m s w-squareProfile m s z| ≤ C*‖w-z‖) + (m s j : Bool) : + SquareBound (fun (e : G.DirectionalEdges j) (p : DyadicFreq k) => G.scaledModeGradient m s p e.val) + (modeBlockConstant C) := by + classical + have hN : (2:ℝ)^k ≠ 0 := by positivity + have hd (e : G.DirectionalEdges j) : + ‖(squareProfile m s (scaledSite k e.val.val.2.val):ℂ)- + (squareProfile m s (scaledSite k e.val.val.1.val):ℂ)‖ ≤ C/(2:ℝ)^k := by + rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] + simpa only [G.scaled_edge_distance, div_eq_mul_inv, one_mul] using + hLip m s (scaledSite k e.val.val.1.val) (scaledSite k e.val.val.2.val) + have hv (e : G.DirectionalEdges j) : + ‖(squareProfile m s (scaledSite k e.val.val.2.val):ℂ)‖ ≤ C := by + simpa only [Complex.norm_real, Real.norm_eq_abs] using hval m s (scaledSite k e.val.val.2.val) + have ha (p : DyadicFreq k) : ‖((1/(dyadicRadius p:ℝ)):ℂ)‖ ≤ 1 := by + have hp : (1:ℝ) ≤ dyadicRadius p := by exact_mod_cast dyadicRadius_pos p + simp only [norm_div, norm_one, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (by linarith : (0:ℝ) ≤ dyadicRadius p)] + exact (div_le_one (by positivity)).mpr hp + have hh := edge_cutoff_squareBound (groupedTorusPoint m s) (groupedTorusPoint_injective m s) + (fun e : G.DirectionalEdges j => latticeTorus (16*2^k) e.val.val.1.val) + (G.directional_torus_injective k hG j) (latticeTorus (16*2^k) (latticeAxis j)) + (fun e => (squareProfile m s (scaledSite k e.val.val.1.val):ℂ)) + (fun e => (squareProfile m s (scaledSite k e.val.val.2.val):ℂ)) + (fun p => ((1/(dyadicRadius p:ℝ)):ℂ)) (C/(2:ℝ)^k) C 1 (Real.pi/(4*(2:ℝ)^k)) + hd hv ha (groupedWave_multiplier_bound m s j) + have hc : Real.sqrt (2*((16*2^k:ℕ):ℝ)^2*((C/(2:ℝ)^k)^2*1^2+C^2*(Real.pi/(4*(2:ℝ)^k))^2)) = modeBlockConstant C := by + congr 1 + push_cast + field_simp [hN] + ring + rw [hc] at hh + have hdir (e : G.DirectionalEdges j) : G.edgeDirection e.val=j := e.property + exact fun v => by simpa only [G.scaledModeGradient_formula, hdir] using hh v + +theorem scaledModes_squareBound (G : LatticeGraph) (hG : G.WithinDyadicBox k) + (C : ℝ) + (hval : ∀ m s z, |squareProfile m s z| ≤ C) + (hLip : ∀ m s z w, |squareProfile m s w-squareProfile m s z| ≤ C*‖w-z‖) + (m s : Bool) : + SquareBound (fun e (p : DyadicFreq k) => G.scaledModeGradient m s p e) (2*modeBlockConstant C) := by + apply SquareBound.combine_directions _ G.edgeDirection + exact fun j => G.scaledModes_direction_bound hG C hval hLip m s j + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ModeCommutator.lean b/lean/OAI/Probability/ClassicalON/ModeCommutator.lean new file mode 100644 index 0000000000000000000000000000000000000000..28fe82c3b83636815f80c46e23f786ab9172c993 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ModeCommutator.lean @@ -0,0 +1,86 @@ +import OAI.Probability.ClassicalON.ModeCosts + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON +variable {k : ℕ} + +theorem dyadic_sine_main_sum (k : ℕ) : + (∑ p : DyadicFreq k, (dyadicWeight p)^2*Real.sin (dyadicAngle k (dyadicPoint p).1)) = + dyadicLambda k/(2:ℝ)^k := by + simp only [dyadicWeight_sq, dyadicLambda] + rw [mul_div_cancel_left₀ _ (by positivity : (2:ℝ)^k ≠ 0)] + +theorem grouped_sine_sum (m s j : Bool) : + (∑ p : DyadicFreq k, (dyadicWeight p)^2* + Real.sin (dyadicAngle k (if j then (groupedPoint m s p).2 else (groupedPoint m s p).1))) = + if m=j then (if s then -(dyadicLambda k/(2:ℝ)^k) else dyadicLambda k/(2:ℝ)^k) else 0 := by + have h1 := dyadic_sine_main_sum k + have h2 := dyadic_sin_cancel k + cases m <;> cases s <;> cases j <;> + simp_all [groupedPoint] + +namespace LatticeGraph + +def modeCommutator (G : LatticeGraph) (m s : Bool) (p : DyadicFreq k) (e : G.edges) : ℂ := + (latticeMode m s p e.val.1.val*conj (latticeMode m s p e.val.2.val)- + conj (latticeMode m s p e.val.1.val)*latticeMode m s p e.val.2.val)/2 + +def profileEdge (G : LatticeGraph) (k : ℕ) (e : G.edges) : ℝ := + (1/(2:ℝ)^k)*(squareProfile (G.edgeDirection e) false (scaledSite k e.val.1.val)* + squareProfile (G.edgeDirection e) false (scaledSite k e.val.2.val)- + squareProfile (G.edgeDirection e) true (scaledSite k e.val.1.val)* + squareProfile (G.edgeDirection e) true (scaledSite k e.val.2.val)) + +def thetaEdge (G : LatticeGraph) (k : ℕ) (e : G.edges) : ℝ := + squareTheta (scaledSite k e.val.2.val)-squareTheta (scaledSite k e.val.1.val) + +theorem modeCommutator_formula (G : LatticeGraph) (m s : Bool) (p : DyadicFreq k) (e : G.edges) : + G.modeCommutator m s p e = -Complex.I * + ((squareProfile m s (scaledSite k e.val.1.val)*squareProfile m s (scaledSite k e.val.2.val)* + ((dyadicWeight p)^2*Real.sin (dyadicAngle k + (if G.edgeDirection e then (groupedPoint m s p).2 else (groupedPoint m s p).1))):ℝ):ℂ) := by + have hy : latticeMode m s p e.val.2.val = + (((dyadicWeight p*squareProfile m s (scaledSite k e.val.2.val)):ℝ):ℂ)* + torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) e.val.1.val)* + Complex.exp (Complex.I*((dyadicAngle k + (if G.edgeDirection e then (groupedPoint m s p).2 else (groupedPoint m s p).1):ℝ):ℂ)) := by + unfold latticeMode + rw [show latticeTorus (16*2^k) e.val.2.val = latticeTorus (16*2^k) e.val.1.val+ + latticeTorus (16*2^k) (latticeAxis (G.edgeDirection e)) by rw [G.edge_step e,latticeTorus_add], + torusWave_add, groupedWave_axis_sine] + push_cast + ring + have hh := wave_commutator (dyadicWeight p) + (squareProfile m s (scaledSite k e.val.1.val)) (squareProfile m s (scaledSite k e.val.2.val)) + (dyadicAngle k (if G.edgeDirection e then (groupedPoint m s p).2 else (groupedPoint m s p).1)) + (torusWave (groupedTorusPoint m s p) (latticeTorus (16*2^k) e.val.1.val)) + (torusWave_norm _ _) + unfold modeCommutator + rw [hy] + simp only [latticeMode, Complex.ofReal_mul] at hh ⊢ + linear_combination hh + +theorem mode_group_commutator (G : LatticeGraph) (m s : Bool) (e : G.edges) : + (∑ p : DyadicFreq k, G.modeCommutator m s p e) = -Complex.I* + ((squareProfile m s (scaledSite k e.val.1.val)*squareProfile m s (scaledSite k e.val.2.val)* + (if m=G.edgeDirection e then (if s then -(dyadicLambda k/(2:ℝ)^k) else dyadicLambda k/(2:ℝ)^k) else 0):ℝ):ℂ) := by + simp only [G.modeCommutator_formula, ← Finset.mul_sum, ← Complex.ofReal_sum] + rw [grouped_sine_sum] + +theorem modes_commutator (G : LatticeGraph) (e : G.edges) : + (∑ i : ModeIndex k, G.modeCommutator i.1.1 i.1.2 i.2 e) = + -Complex.I*((dyadicLambda k*G.profileEdge k e:ℝ):ℂ) := by + simp only [Fintype.sum_prod_type, G.mode_group_commutator, Fintype.sum_bool] + cases h : G.edgeDirection e <;> + simp [profileEdge, h] + all_goals ring + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ModeCosts.lean b/lean/OAI/Probability/ClassicalON/ModeCosts.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b314fa95e953b21b8f5499b1936b8c32abe7f84 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ModeCosts.lean @@ -0,0 +1,121 @@ +import OAI.Probability.ClassicalON.FamilyKernel + +namespace OAI + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON +namespace LatticeGraph +variable {k : ℕ} + +theorem mode_gradient_square_sum_le (G : LatticeGraph) (m s : Bool) (a : ℝ) + (h : SquareBound (fun e (p : DyadicFreq k) => G.scaledModeGradient m s p e) a) (p : DyadicFreq k) : + (∑ e, ‖G.modeGradient m s p e‖^2) ≤ a^2/(dyadicRadius p:ℝ) := by + have hr : (0:ℝ) latticeMode m s p x.val)‖^2 ≤ C^2*(1/(dyadicRadius p:ℝ))^3 := by + have hnorm : ‖(fun x : G.vertices => latticeMode m s p x.val)‖ ≤ dyadicWeight p*C := by + apply (pi_norm_le_iff_of_nonneg (mul_nonneg (dyadicWeight_pos p).le hC)).mpr + exact fun x => latticeMode_norm_bound m s p x.val C (hv _) + calc _ ≤ (dyadicWeight p*C)^2 := pow_le_pow_left₀ (norm_nonneg _) hnorm 2 + _ = _ := by rw [mul_pow, dyadicWeight_sq]; ring + +theorem mode_gram_reweight (G : LatticeGraph) (m s : Bool) (e l : G.edges) : + (∑ p : DyadicFreq k, G.scaledModeGradient m s p e*((1/(dyadicRadius p:ℝ)):ℂ)* + conj (G.scaledModeGradient m s p l)) = ∑ p : DyadicFreq k, + G.modeGradient m s p e*conj (G.modeGradient m s p l) := by + apply Finset.sum_congr rfl + intro p _ + have hr : (0:ℝ) G.scaledModeGradient m s p e) a) : + (∑ e, ∑ l, ‖∑ p : DyadicFreq k, G.modeGradient m s p e*conj (G.modeGradient m s p l)‖^2) + ≤ 3*a^4*(k:ℝ) := by + have hh := h.gram_weighted (fun p => ((1/(dyadicRadius p:ℝ)):ℂ)) + simp_rw [G.mode_gram_reweight] at hh + have he (p : DyadicFreq k) : ‖((1/(dyadicRadius p:ℝ)):ℂ)‖^2 = (1/(dyadicRadius p:ℝ))^2 := by + have hr : (0:ℝ) ≤ dyadicRadius p := by positivity + simp only [norm_div, norm_one, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hr] + simp_rw [he] at hh + exact hh.trans (by nlinarith [mul_le_mul_of_nonneg_left (dyadic_inverse_square_sum k) (by positivity : 0≤a^4)]) + +abbrev ModeIndex (k : ℕ) := (Bool × Bool) × DyadicFreq k + +def modes (G : LatticeGraph) (i : ModeIndex k) (x : G.vertices) : ℂ := + latticeMode i.1.1 i.1.2 i.2 x.val + +def modeDifferences (G : LatticeGraph) (i : ModeIndex k) (e : G.edges) : ℂ := + G.modeGradient i.1.1 i.1.2 i.2 e + +theorem modes_HS_bound (G : LatticeGraph) (a : ℝ) + (h : ∀ m s, SquareBound (fun e (p : DyadicFreq k) => G.scaledModeGradient m s p e) a) : + familyHSSquare (G.modeDifferences (k := k)) ≤ 48*a^4*(k:ℝ) := by + unfold familyHSSquare rowSquare familyKernel modeDifferences + simp only [Fintype.sum_prod_type] + have hh := gram_groups_bound + (fun (i : Bool × Bool) e l => ∑ p : DyadicFreq k, + G.modeGradient i.1 i.2 p e*conj (G.modeGradient i.1 i.2 p l)) + (3*a^4*(k:ℝ)) (fun i => G.mode_group_gram_bound i.1 i.2 a (h i.1 i.2)) + simpa only [Fintype.sum_prod_type, Fintype.card_prod, Fintype.card_bool, Nat.cast_mul, Nat.cast_ofNat, + show ((2:ℝ)*2)^2*(3*a^4*(k:ℝ)) = 48*a^4*(k:ℝ) by ring] using hh + +theorem modes_min_bound (G : LatticeGraph) (a C : ℝ) (hC : 0 ≤ C) + (hv : ∀ m s z, |squareProfile m s z| ≤ C) + (h : ∀ m s, SquareBound (fun e (p : DyadicFreq k) => G.scaledModeGradient m s p e) a) : + (∑ i : ModeIndex k, ∑ j : ModeIndex k, + min (‖G.modes i‖^2*∑ e, ‖G.modeDifferences j e‖^2) + (‖G.modes j‖^2*∑ e, ‖G.modeDifferences i e‖^2)) ≤ 576*C^2*a^2*(k:ℝ) := by + have hv' (i : ModeIndex k) : ‖G.modes i‖^2 ≤ C^2*(1/(dyadicRadius i.2:ℝ))^3 := + G.mode_sup_square_le i.1.1 i.1.2 i.2 C hC (hv i.1.1 i.1.2) + have hd' (i : ModeIndex k) : (∑ e, ‖G.modeDifferences i e‖^2) ≤ a^2/(dyadicRadius i.2:ℝ) := + G.mode_gradient_square_sum_le i.1.1 i.1.2 a (h i.1.1 i.1.2) i.2 + have hm (i j : ModeIndex k) : + min (‖G.modes i‖^2*∑ e, ‖G.modeDifferences j e‖^2) + (‖G.modes j‖^2*∑ e, ‖G.modeDifferences i e‖^2) ≤ + C^2*a^2*min ((1/(dyadicRadius i.2:ℝ))^3*(1/(dyadicRadius j.2:ℝ))) + ((1/(dyadicRadius j.2:ℝ))^3*(1/(dyadicRadius i.2:ℝ))) := by + rw [mul_min_of_nonneg _ _ (mul_nonneg (sq_nonneg _) (sq_nonneg _))] + apply min_le_min + · calc _ ≤ (C^2*(1/(dyadicRadius i.2:ℝ))^3)*(a^2/(dyadicRadius j.2:ℝ)) := + mul_le_mul (hv' i) (hd' j) (Finset.sum_nonneg fun _ _ => sq_nonneg _) (by positivity) + _ = _ := by ring + · calc _ ≤ (C^2*(1/(dyadicRadius j.2:ℝ))^3)*(a^2/(dyadicRadius i.2:ℝ)) := + mul_le_mul (hv' j) (hd' i) (Finset.sum_nonneg fun _ _ => sq_nonneg _) (by positivity) + _ = _ := by ring + calc _ ≤ ∑ i : ModeIndex k, ∑ j : ModeIndex k, + C^2*a^2*min ((1/(dyadicRadius i.2:ℝ))^3*(1/(dyadicRadius j.2:ℝ))) + ((1/(dyadicRadius j.2:ℝ))^3*(1/(dyadicRadius i.2:ℝ))) := + Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => hm i j + _ = 16*C^2*a^2*∑ p : DyadicFreq k, ∑ q : DyadicFreq k, + min ((1/(dyadicRadius p:ℝ))^3*(1/(dyadicRadius q:ℝ))) + ((1/(dyadicRadius q:ℝ))^3*(1/(dyadicRadius p:ℝ))) := by + simp only [ModeIndex, Fintype.sum_prod_type, Finset.sum_const, Finset.card_univ, + Fintype.card_prod, Fintype.card_bool, Nat.cast_mul, nsmul_eq_mul, Nat.cast_ofNat, ← Finset.mul_sum] + ring + _ ≤ _ := by + have hd := mul_le_mul_of_nonneg_left (dyadic_min_cost_sum k) + (by positivity : 0 ≤ 16*C^2*a^2) + nlinarith + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/Model.lean b/lean/OAI/Probability/ClassicalON/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..f10ed6afb42b67437a80509e17fedb49274d10d3 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/Model.lean @@ -0,0 +1,57 @@ +import Mathlib + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace + +namespace ClassicalON + +abbrev Site := ℤ × ℤ + +def PositiveNeighbor (x y : Site) : Prop := + (y.1 = x.1 + 1 ∧ y.2 = x.2) ∨ (y.1 = x.1 ∧ y.2 = x.2 + 1) + +structure LatticeGraph where + vertices : Finset Site + edges : Finset (vertices × vertices) + nearest : ∀ e ∈ edges, PositiveNeighbor e.1.val e.2.val + +abbrev Spin (n : ℕ) := ↥(Metric.sphere (0 : EuclideanSpace ℝ (Fin n)) 1) +abbrev Configuration (n : ℕ) (G : LatticeGraph) := G.vertices → Spin n + +def sphereProbability (n : ℕ) : Measure (Spin n) := + let surface := (volume : Measure (EuclideanSpace ℝ (Fin n))).toSphere + (surface Set.univ)⁻¹ • surface + +def referenceLaw (n : ℕ) (G : LatticeGraph) : Measure (Configuration n G) := + Measure.pi (fun _ => sphereProbability n) + +def interaction (n : ℕ) (G : LatticeGraph) (b : G.edges → ℝ) + (σ : Configuration n G) : ℝ := + ∑ e : G.edges, b e * ⟪(σ e.val.1).val, (σ e.val.2).val⟫_ℝ + +def partition (n : ℕ) (G : LatticeGraph) (b : G.edges → ℝ) : ℝ := + ∫ σ, Real.exp (interaction n G b σ) ∂referenceLaw n G + +def correlation (n : ℕ) (G : LatticeGraph) (b : G.edges → ℝ) + (x y : G.vertices) : ℝ := + (∫ σ, ⟪(σ x).val, (σ y).val⟫_ℝ * Real.exp (interaction n G b σ) + ∂referenceLaw n G) / partition n G b + +def siteDistance (x y : Site) : ℝ := + Real.sqrt (((x.1 : ℝ) - (y.1 : ℝ)) ^ 2 + ((x.2 : ℝ) - (y.2 : ℝ)) ^ 2) + +def ExponentialDecay : Prop := + ∀ (n : ℕ), 3 ≤ n → ∀ (β : ℝ), 0 < β → + ∃ A m : ℝ, 0 < m ∧ ∀ (G : LatticeGraph) (b : G.edges → ℝ), + (∀ e, 0 ≤ b e ∧ b e ≤ β) → ∀ x y : G.vertices, + 0 ≤ correlation n G b x y ∧ + correlation n G b x y ≤ A * Real.exp (-m * siteDistance x.val y.val) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/MomentCone.lean b/lean/OAI/Probability/ClassicalON/MomentCone.lean new file mode 100644 index 0000000000000000000000000000000000000000..15a32d742162f7b81a66802f7c2803b7ccb3b2e2 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/MomentCone.lean @@ -0,0 +1,109 @@ +import OAI.Probability.ClassicalON.ExpMoments + +namespace OAI + +universe uI uJ uX + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +def MomentCone {X : Type uX} {I : Type uI} (a : I → X → ℝ) (f : X → ℝ) : Prop := + ∃ (k : ℕ) (c : Fin k → ℝ) (p : Fin k → List I), + (∀ j,0≤c j) ∧ ∀ x,f x=∑ j,c j*((p j).map (fun i => a i x)).prod + +variable {X : Type uX} {I : Type uI} {a : I → X → ℝ} + +theorem momentCone_const {c : ℝ} (hc : 0≤c) : MomentCone a (fun _ => c) := by + refine ⟨1,fun _ => c,fun _ => [],fun _ => hc,?_⟩ + intro x; simp + +theorem momentCone_coordinate (i : I) : MomentCone a (a i) := by + refine ⟨1,fun _ => 1,fun _ => [i],fun _ => by norm_num,?_⟩ + intro x; simp + +theorem momentCone_add {f g : X → ℝ} (hf : MomentCone a f) (hg : MomentCone a g) : + MomentCone a (fun x => f x+g x) := by + rcases hf with ⟨k,c,p,hc,hf⟩ + rcases hg with ⟨l,d,q,hd,hg⟩ + refine ⟨k+l,Fin.append c d,Fin.append p q,?_,?_⟩ + · intro j; cases j using Fin.addCases <;> simp_all + · intro x + change f x+g x=_ + rw [hf,hg,Fin.sum_univ_add] + simp + +theorem momentCone_mul {f g : X → ℝ} (hf : MomentCone a f) (hg : MomentCone a g) : + MomentCone a (fun x => f x*g x) := by + classical + rcases hf with ⟨k,c,p,hc,hf⟩ + rcases hg with ⟨l,d,q,hd,hg⟩ + let e := (finProdFinEquiv : Fin k × Fin l ≃ Fin (k*l)).symm + refine ⟨k*l,fun j => c (e j).1*d (e j).2, + fun j => p (e j).1 ++ q (e j).2, + fun j => mul_nonneg (hc _) (hd _),?_⟩ + intro x + simp only [List.map_append,List.prod_append] + rw [Equiv.sum_comp e (fun z : Fin k × Fin l => c z.1*d z.2* + ((List.map (fun i => a i x) (p z.1)).prod*(List.map (fun i => a i x) (q z.2)).prod))] + simp only [Fintype.sum_prod_type] + rw [hf,hg,Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + +theorem momentCone_finsetProd {J : Type uJ} (s : Finset J) (f : J → X → ℝ) + (hf : ∀ j∈s,MomentCone a (f j)) : MomentCone a (fun x => ∏ j∈s,f j x) := by + classical + induction s using Finset.induction_on with + | empty => simpa using (momentCone_const (a := a) (by norm_num : (0 : ℝ)≤1)) + | @insert i s hi ih => + simpa only [Finset.prod_insert hi] using + momentCone_mul (hf i (by simp)) (ih (fun j hj => hf j (by simp [hj]))) + +section Integral +variable [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] + (μ : Measure X) [IsFiniteMeasure μ] + +theorem momentCone_integral_nonneg (ha : ∀ i,Continuous (a i)) + (hm : ∀ (k : ℕ) (p : Fin k → I),0≤∫ x,∏ i,a (p i) x ∂μ) + {f : X → ℝ} (hf : MomentCone a f) : 0≤∫ x,f x ∂μ := by + rcases hf with ⟨k,c,p,hc,hf⟩ + simp_rw [hf] + have hp : ∀ l : List I,Continuous (fun x => (l.map (fun i => a i x)).prod) := by + intro l + induction l with + | nil => simpa using (continuous_const : Continuous (fun _ : X => (1 : ℝ))) + | cons i l ih => + simp only [List.map_cons,List.prod_cons] + apply Continuous.mul + · exact ha i + · exact ih + have hI (j : Fin k) : Integrable (fun x => c j*(List.map (fun i => a i x) (p j)).prod) μ := + compact_integrable (by + apply Continuous.mul + · exact continuous_const + · exact hp (p j)) + rw [integral_finsetSum _ (fun j _ => hI j)] + apply Finset.sum_nonneg + intro j _ + rw [integral_const_mul] + apply mul_nonneg (hc j) + have he (x : X) : (List.map (fun i => a i x) (p j)).prod = + ∏ i : Fin (p j).length,a ((p j).get i) x := by + have hh := List.ofFn_comp' (List.get (p j)) (fun i => a i x) + rw [List.ofFn_get] at hh + rw [← hh,List.prod_ofFn] + simp_rw [he] + exact hm (p j).length (fun i => (p j).get i) + +end Integral +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ObservableBounds.lean b/lean/OAI/Probability/ClassicalON/ObservableBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..514f76d7efa6bce78fec4b0b89712970086bfcaa --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ObservableBounds.lean @@ -0,0 +1,101 @@ +import OAI.Probability.ClassicalON.GradientComplex + +namespace OAI + +universe uE uV uΩ + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {n : ℕ} {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] [NeZero n] + +@[simp] theorem averageLinear_const (S : SpinSystem n V E) (c : ℝ) : + S.averageLinear (ContinuousMap.const _ c) = c := S.average_const c + +@[simp] theorem averageLinear_one (S : SpinSystem n V E) : S.averageLinear 1 = 1 := + S.average_const 1 + +@[simp] theorem normObservable_mul {Ω : Type uΩ} [TopologicalSpace Ω] (f g : C(Ω, ℂ)) : + normObservable (f*g) = normObservable f * normObservable g := by + ext x + exact norm_mul (f x) (g x) + +theorem norm_averageComplex_le_const (S : SpinSystem n V E) + (f : C((V → Spin n), ℂ)) (c : ℝ) (h : ∀ σ, ‖f σ‖ ≤ c) : + ‖S.averageComplexLinear f‖ ≤ c := by + calc _ ≤ S.averageLinear (normObservable f) := S.norm_averageComplex_le f + _ ≤ S.averageLinear (ContinuousMap.const _ c) := S.averageLinear_mono _ _ h + _ = c := S.averageLinear_const c + +theorem norm_averageComplex_mul_le (S : SpinSystem n V E) + (f g : C((V → Spin n), ℂ)) : + ‖S.averageComplexLinear (f*g)‖ ≤ + Real.sqrt (S.averageLinear (normObservable f * normObservable f)) * + Real.sqrt (S.averageLinear (normObservable g * normObservable g)) := by + calc _ ≤ S.averageLinear (normObservable (f*g)) := S.norm_averageComplex_le _ + _ = S.averageLinear (normObservable f * normObservable g) := by rw [normObservable_mul] + _ ≤ _ := S.averageLinear_mul_le_sqrt _ _ + +theorem averageLinear_norm_le_sqrt (S : SpinSystem n V E) + (f : C((V → Spin n), ℂ)) : + S.averageLinear (normObservable f) ≤ + Real.sqrt (S.averageLinear (normObservable f * normObservable f)) := by + simpa only [mul_one, one_mul, S.averageLinear_one, Real.sqrt_one] using + S.averageLinear_mul_le_sqrt (normObservable f) 1 + +theorem norm_averageComplex_mul_mul_le (S : SpinSystem n V E) + (a f g : C((V → Spin n), ℂ)) (c : ℝ) (hc : 0 ≤ c) + (ha : ∀ σ, ‖a σ‖ ≤ c) : + ‖S.averageComplexLinear (a*f*g)‖ ≤ c * + (Real.sqrt (S.averageLinear (normObservable f * normObservable f)) * + Real.sqrt (S.averageLinear (normObservable g * normObservable g))) := by + have hpt : ∀ σ, normObservable (a*f*g) σ ≤ + (c • (normObservable f * normObservable g)) σ := by + intro σ + change ‖a σ*f σ*g σ‖ ≤ c * (‖f σ‖*‖g σ‖) + rw [norm_mul, norm_mul, mul_assoc] + exact mul_le_mul_of_nonneg_right (ha σ) (mul_nonneg (norm_nonneg _) (norm_nonneg _)) + calc _ ≤ S.averageLinear (normObservable (a*f*g)) := S.norm_averageComplex_le _ + _ ≤ S.averageLinear (c • (normObservable f * normObservable g)) := + S.averageLinear_mono _ _ hpt + _ = c * S.averageLinear (normObservable f * normObservable g) := by + rw [map_smul, smul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_left (S.averageLinear_mul_le_sqrt _ _) hc + +theorem norm_averageComplex_mul_mul_le_of_moments (S : SpinSystem n V E) + (a f g : C((V → Spin n), ℂ)) (c v : ℝ) (hc : 0 ≤ c) + (ha : ∀ σ, ‖a σ‖ ≤ c) + (hf : S.averageLinear (normObservable f * normObservable f) ≤ v) + (hg : S.averageLinear (normObservable g * normObservable g) ≤ v) : + ‖S.averageComplexLinear (a*f*g)‖ ≤ c*v := by + have hv : 0 ≤ v := (S.averageLinear_mul_self_nonneg (normObservable f)).trans hf + calc _ ≤ c * (Real.sqrt (S.averageLinear (normObservable f * normObservable f)) * + Real.sqrt (S.averageLinear (normObservable g * normObservable g))) := + S.norm_averageComplex_mul_mul_le a f g c hc ha + _ ≤ c * (Real.sqrt v * Real.sqrt v) := + mul_le_mul_of_nonneg_left + (mul_le_mul (Real.sqrt_le_sqrt hf) (Real.sqrt_le_sqrt hg) + (Real.sqrt_nonneg _) (Real.sqrt_nonneg _)) hc + _ = c*v := by rw [Real.mul_self_sqrt hv] + +theorem norm_averageComplex_mul_le_of_moment (S : SpinSystem n V E) + (a f : C((V → Spin n), ℂ)) (c v : ℝ) (hc : 0 ≤ c) + (ha : ∀ σ, ‖a σ‖ ≤ c) + (hf : S.averageLinear (normObservable f * normObservable f) ≤ v) : + ‖S.averageComplexLinear (a*f)‖ ≤ c*Real.sqrt v := by + have h := S.norm_averageComplex_mul_mul_le a f 1 c hc ha + simp only [mul_one] at h + have h1 : normObservable (1 : C((V → Spin n), ℂ)) = 1 := by + ext σ + change ‖(1 : ℂ)‖ = (1 : ℝ) + exact norm_one + rw [h1, mul_one, S.averageLinear_one, Real.sqrt_one, mul_one] at h + exact h.trans (mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt hf) hc) + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/OrthogonalAverage.lean b/lean/OAI/Probability/ClassicalON/OrthogonalAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2d202f94ef5e25a23dd171e5b823e7eb1bdbff4 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/OrthogonalAverage.lean @@ -0,0 +1,101 @@ +import OAI.Probability.ClassicalON.SpinIsotropy + +namespace OAI + +noncomputable section +open MeasureTheory +open scoped InnerProductSpace +namespace ClassicalON + +instance spinOperator_continuousStar (n : ℕ) : ContinuousStar (SpinOperator n) := + ⟨ContinuousLinearMap.adjoint.continuous⟩ + +abbrev SpinOrthogonal (n : ℕ) := unitary (SpinOperator n) + +instance spinOrthogonal_compact (n : ℕ) [NeZero n] : CompactSpace (SpinOrthogonal n) := by + apply isCompact_iff_compactSpace.mp + apply (isCompact_closedBall (0 : SpinOperator n) 1).of_isClosed_subset isClosed_unitary + intro Q hQ + simpa only [Metric.mem_closedBall,dist_zero_right,CStarRing.norm_coe_unitary ⟨Q,hQ⟩] using (le_rfl : (1:ℝ) ≤ 1) + +instance spinOrthogonal_measurableSpace (n : ℕ) : MeasurableSpace (SpinOrthogonal n) := borel _ +instance spinOrthogonal_borelSpace (n : ℕ) : BorelSpace (SpinOrthogonal n) := ⟨rfl⟩ + +def orthogonalLaw (n : ℕ) [NeZero n] : Measure (SpinOrthogonal n) := + ((Measure.haar : Measure (SpinOrthogonal n)) Set.univ)⁻¹ • Measure.haar + +instance orthogonalLaw_isProbability (n : ℕ) [NeZero n] : IsProbabilityMeasure (orthogonalLaw n) := by + constructor + unfold orthogonalLaw + rw [Measure.smul_apply,smul_eq_mul] + exact ENNReal.inv_mul_cancel (ne_of_gt (isOpen_univ.measure_pos Measure.haar Set.univ_nonempty)) (measure_ne_top _ _) + +instance orthogonalLaw_isHaar (n : ℕ) [NeZero n] : (orthogonalLaw n).IsHaarMeasure := by + unfold orthogonalLaw + exact Measure.IsHaarMeasure.smul _ (ENNReal.inv_ne_zero.mpr (measure_ne_top _ _)) + (ENNReal.inv_ne_top.mpr (ne_of_gt (isOpen_univ.measure_pos Measure.haar Set.univ_nonempty))) + +instance orthogonalLaw_isRightInvariant (n : ℕ) [NeZero n] : + (orthogonalLaw n).IsMulRightInvariant := by + constructor + intro R + have hm : Measurable (fun Q : SpinOrthogonal n => Q*R) := (continuous_id.mul continuous_const).measurable + have : IsProbabilityMeasure ((orthogonalLaw n).map (·*R)) := + (Measure.isProbabilityMeasure_map_iff hm.aemeasurable).2 inferInstance + have he := Measure.isMulInvariant_eq_smul_of_compactSpace + ((orthogonalLaw n).map (·*R)) (orthogonalLaw n) + have hmass := congrArg (fun μ : Measure (SpinOrthogonal n) => μ Set.univ) he + simp only [measure_univ,Measure.smul_apply,ENNReal.smul_def,smul_eq_mul,mul_one] at hmass + have hc : Measure.haarScalarFactor ((orthogonalLaw n).map (·*R)) (orthogonalLaw n)=1 := by + exact_mod_cast hmass.symm + rw [hc,one_smul] at he + exact he + +def orthogonalSpin {n : ℕ} (Q : SpinOrthogonal n) (s : Spin n) : Spin n := + spinRotation (Unitary.linearIsometryEquiv Q) s + +theorem continuous_orthogonalSpin (n : ℕ) : + Continuous (Function.uncurry (orthogonalSpin (n := n))) := by + apply Continuous.subtype_mk + exact (continuous_subtype_val.comp continuous_fst).clm_apply (continuous_subtype_val.comp continuous_snd) + +@[simp] theorem orthogonalSpin_mul {n : ℕ} (Q R : SpinOrthogonal n) (s : Spin n) : + orthogonalSpin (Q*R) s=orthogonalSpin Q (orthogonalSpin R s) := by + rfl + +theorem orthogonalSpin_transitive {n : ℕ} (s t : Spin n) : + ∃ Q : SpinOrthogonal n,orthogonalSpin Q s=t := by + let R := (Submodule.span ℝ {s.val-t.val})ᗮ.reflection + refine ⟨Unitary.linearIsometryEquiv.symm R,?_⟩ + apply Subtype.ext + change (Unitary.linearIsometryEquiv (Unitary.linearIsometryEquiv.symm R)) s.val=t.val + rw [MulEquiv.apply_symm_apply] + exact Submodule.reflection_sub (by rw [spin_norm,spin_norm]) + +theorem orthogonalSpin_preserves {n : ℕ} (Q : SpinOrthogonal n) : + MeasurePreserving (orthogonalSpin Q) (sphereProbability n) (sphereProbability n) := + spinRotation_preserves_probability _ + +theorem integral_orthogonalSpin_eq {n : ℕ} [NeZero n] (f : Spin n → ℝ) + (hf : Continuous f) (s : Spin n) : + (∫ Q, f (orthogonalSpin Q s) ∂orthogonalLaw n)=∫ t,f t ∂sphereProbability n := by + have he (t : Spin n) : (∫ Q,f (orthogonalSpin Q t) ∂orthogonalLaw n)= + ∫ Q,f (orthogonalSpin Q s) ∂orthogonalLaw n := by + obtain ⟨R,rfl⟩ := orthogonalSpin_transitive s t + simp_rw [← orthogonalSpin_mul] + exact integral_mul_right_eq_self (fun Q => f (orthogonalSpin Q s)) R + have hh := integral_integral_swap (μ := sphereProbability n) (ν := orthogonalLaw n) + (f := fun t Q => f (orthogonalSpin Q t)) (compact_integrable (show Continuous (fun p : Spin n×SpinOrthogonal n => f (orthogonalSpin p.2 p.1)) from + hf.comp ((continuous_orthogonalSpin n).comp continuous_swap))) + simp_rw [he] at hh + rw [integral_const,probReal_univ,one_smul] at hh + have hp (Q : SpinOrthogonal n) : (∫ t,f (orthogonalSpin Q t) ∂sphereProbability n)=∫ t,f t ∂sphereProbability n := + (orthogonalSpin_preserves Q).integral_comp (spinRotation (Unitary.linearIsometryEquiv Q)).measurableEmbedding f + simp_rw [hp] at hh + simpa using hh + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PeriodicODE.lean b/lean/OAI/Probability/ClassicalON/PeriodicODE.lean new file mode 100644 index 0000000000000000000000000000000000000000..915a796ff37287b9df909e4636e3bc8abfb13029 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PeriodicODE.lean @@ -0,0 +1,72 @@ +import OAI.Probability.ClassicalON.PotentialRotation + +namespace OAI + +noncomputable section +open Set + +namespace ClassicalON + +theorem lower_second_derivative_tangent (f f' f'' : ℝ → ℝ) (a c x : ℝ) + (h1 : ∀ t, HasDerivAt f (f' t) t) (h2 : ∀ t, HasDerivAt f' (f'' t) t) + (hsec : ∀ t, -c ≤ f'' t) (ha : f' a = 0) : + f a - c/2*(x-a)^2 ≤ f x := by + let g := fun t => f t + c/2*(t-a)^2 + let g' := fun t => f' t + c*(t-a) + let g'' := fun t => f'' t + c + have hg (t : ℝ) : HasDerivAt g (g' t) t := by + convert (h1 t).add ((((hasDerivAt_id t).sub_const a).pow 2).const_mul (c/2)) using 1 <;> + first | rfl | (change f' t + c * (t-a) = f' t + c/2*(2*(t-a)^(2-1)*1); ring) + have hg' (t : ℝ) : HasDerivAt g' (g'' t) t := by + convert (h2 t).add (((hasDerivAt_id t).sub_const a).const_mul c) using 1 <;> + first | rfl | (change f'' t + c = f'' t + c*1; ring) + have hcv : ConvexOn ℝ univ g := by + apply convexOn_of_hasDerivWithinAt2_nonneg convex_univ + (fun t _ => (hg t).continuousAt.continuousWithinAt) + (fun t _ => (hg t).hasDerivWithinAt) + (fun t _ => (hg' t).hasDerivWithinAt) + intro t _ + dsimp only [g''] + linarith [hsec t] + have hd : derivWithin g (Ioi a) a = 0 := by + rw [(hg a).hasDerivWithinAt.derivWithin (uniqueDiffWithinAt_Ioi a)] + simp [g', ha] + have hm := hcv.isMinOn_of_rightDeriv_eq_zero (by simp) hd (mem_univ x) + change f a + c/2*(a-a)^2 ≤ f x + c/2*(x-a)^2 at hm + nlinarith + +theorem periodic_ode_ratio (f f' f'' : ℝ → ℝ) (P δ : ℝ) (hP : 0 < P) (hδ : 0 ≤ δ) + (hper : Function.Periodic f P) (hfpos : ∀ t, 0 < f t) + (h1 : ∀ t, HasDerivAt f (f' t) t) (h2 : ∀ t, HasDerivAt f' (f'' t) t) + (hode : ∀ t, -(δ*f t) ≤ f'' t) (x y : ℝ) : + 1 - δ*P^2/2 ≤ f x / f y := by + have hf : Continuous f := continuous_iff_continuousAt.mpr fun t => (h1 t).continuousAt + obtain ⟨a, ha, ham⟩ := isCompact_Icc.exists_isMaxOn + (show (Icc (0:ℝ) P).Nonempty from ⟨0, le_rfl, hP.le⟩) hf.continuousOn + have hmax (t : ℝ) : f t ≤ f a := by + obtain ⟨s, hs, he⟩ := hper.exists_mem_Ioc hP t 0 + rw [he] + exact ham ⟨hs.1.le, by simpa only [zero_add] using hs.2⟩ + have halocal : IsLocalMax f a := Filter.Eventually.of_forall hmax + have hstationary : f' a = 0 := by rw [← (h1 a).deriv, halocal.deriv_eq_zero] + have hsec (t : ℝ) : -(δ*f a) ≤ f'' t := + (neg_le_neg (mul_le_mul_of_nonneg_left (hmax t) hδ)).trans (hode t) + obtain ⟨s, hs, he⟩ := hper.exists_mem_Ioc hP x a + have ht := lower_second_derivative_tangent f f' f'' a (δ*f a) s h1 h2 hsec hstationary + have hdist : (s-a)^2 ≤ P^2 := by + apply pow_le_pow_left₀ (sub_nonneg.mpr hs.1.le) + linarith [hs.2] + have hnear : f a*(1-δ*P^2/2) ≤ f x := by + rw [he] + have hm := mul_le_mul_of_nonneg_left hdist (div_nonneg (mul_nonneg hδ (hfpos a).le) (by norm_num : (0:ℝ) ≤ 2)) + nlinarith + apply (le_div_iff₀ (hfpos y)).mpr + by_cases hc : 0 ≤ 1-δ*P^2/2 + · exact (mul_le_mul_of_nonneg_left (hmax y) hc).trans (by simpa only [mul_comm] using hnear) + · exact (mul_nonpos_of_nonpos_of_nonneg (le_of_not_ge hc) (hfpos y).le).trans (hfpos x).le + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PeriodicPartition.lean b/lean/OAI/Probability/ClassicalON/PeriodicPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..5484b3439be2340109e1f5e8b59b2c3f2b2af71a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PeriodicPartition.lean @@ -0,0 +1,43 @@ +import OAI.Probability.ClassicalON.PeriodicODE + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem potential_partition_ratio (S : SpinSystem 3 V E) (f : V → ℝ) (δ : ℝ) (hδ : 0 ≤ δ) + (hP : ∀ x s, S.pin x=some s → f x=0 ∨ f x=1) + (hR : ∀ t, -(S.rotatePotential f t).secondAxisResponse (S.differential f) (S.differential f) ≤ δ) + (x y : ℝ) : + 1-δ*(2*Real.pi)^2/2 ≤ (S.rotatePotential f x).Z (fun _ => 1) / + (S.rotatePotential f y).Z (fun _ => 1) := by + let A := S.potentialOperators f + let F := fun t : ℝ => S.Z (fun e => NormedSpace.exp (t • A e)) + let F' := fun t => ∫ σ, S.firstWeight A t σ ∂S.reference + let F'' := fun t => ∫ σ, S.secondWeight A t σ ∂S.reference + have hZ (t : ℝ) : F t=(S.rotatePotential f t).Z (fun _ => 1) := by + have h := S.potential_shift_Z f t 0 + simpa only [add_zero,zero_smul ℝ (S.potentialOperators f _),NormedSpace.exp_zero] using h + have hper : Function.Periodic F (2*Real.pi) := by + intro t + rw [hZ,hZ,S.rotatePotential_periodic f hP t] + have hpos (t : ℝ) : 0 μ) + +def pinnedBondMean (μ : Measure Amplitude) (left right : E → V) (b : E → ℝ) + (B : Set V) (f : (E → Bool) → ℝ) : ℝ := + pinnedBondNumerator μ left right b B f/pinnedBondNumerator μ left right b B (fun _ => 1) + +theorem continuous_pinWeightedSum (left right : E → V) (b : E → ℝ) (B : Set V) + (f : (E → Bool) → ℝ) : + Continuous (fun r => ∑ η,amplitudeBondWeight left right b r η*bondPinFactor left right B η*f η) := by + exact continuous_finsetSum _ (fun η _ => ((continuous_amplitudeBondWeight _ _ _ η).mul continuous_const).mul continuous_const) + +theorem pinWeightedSum_pos (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (B : Set V) (r : V → Amplitude) : + 0<∑ η,amplitudeBondWeight left right b r η*bondPinFactor left right B η*(1:ℝ) := by + apply Finset.sum_pos' + · intro η _ + exact mul_nonneg (mul_nonneg (amplitudeBondWeight_nonneg _ _ _ hb r η) + (bondPinFactor_pos _ _ _ _).le) zero_le_one + · refine ⟨fun _ => false,Finset.mem_univ _,?_⟩ + simp only [amplitudeBondWeight,bondWeight,bondProduct,Bool.false_eq_true,ite_false,Finset.prod_const_one,mul_one] + exact mul_pos (mul_pos (amplitudeBondPrefactor_pos _ _ _ _) (clusterWeight_pos _ _ _)) (bondPinFactor_pos _ _ _ _) + +theorem pinnedBondNumerator_one_pos (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) (B : Set V) : + 0 1) := by + apply compact_integral_pos + · exact (continuous_pinWeightedSum _ _ _ _ _).comp + ((continuous_glueAmplitude B).comp (continuous_const.prodMk continuous_id)) + · intro r + exact pinWeightedSum_pos _ _ _ hb _ _ + +theorem jointBond_le_pinnedBond (μ : Measure Amplitude) [IsProbabilityMeasure μ] + [μ.IsOpenPosMeasure] (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (B : Set V) (f : (E → Bool) → ℝ) (hfn : ∀ η,0≤f η) (hfm : Monotone f) : + jointBondMean μ left right b (fun _ η => f η)≤pinnedBondMean μ left right b B f := by + let c := jointBondMean μ left right b (fun _ η => f η) + let F : (V → Amplitude) → ℝ := fun r => ∑ η,amplitudeBondWeight left right b r η* + bondPinFactor left right B η*(f η-c) + have hF : Continuous F := continuous_pinWeightedSum _ _ _ _ _ + have ht : 0≤∫ r,F (glueAmplitude B ⊤ r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ) := by + apply pinEndpoint_nonneg μ B hF + intro h hh hn hm + let g : (V → Amplitude) → (E → Bool) → ℝ := fun r η => h (fun v : B => r v)*bondPinFactor left right B η + have hgr : ∀ η,Monotone (fun r => g r η) := by + intro η r s hrs + exact mul_le_mul_of_nonneg_right (hm (fun v => hrs v)) (bondPinFactor_pos _ _ _ _).le + have hgη : ∀ r,Monotone (g r) := by + intro r η ξ hη + exact mul_le_mul_of_nonneg_left (bondPinFactor_monotone _ _ _ hη) (hn _) + have hgc : ∀ η,Continuous (fun r => g r η) := by + intro η + exact (hh.comp (continuous_pi (fun v : B => continuous_apply v.val))).mul continuous_const + have hi := rawBond_tilt_defect_nonneg μ left right b hb + (f := fun _ η => f η) (g := g) + (fun _ => continuous_const) hgc (fun _ η => hfn η) + (fun r η => mul_nonneg (hn _) (bondPinFactor_pos _ _ _ _).le) + (fun _ => monotone_const) hgr (fun _ => hfm) hgη + convert hi using 1 + congr 1 + funext r + dsimp only [F,g,c] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro η _ + ring + have he (r : ↥(Bᶜ) → Amplitude) : F (glueAmplitude B ⊤ r)= + (∑ η,amplitudeBondWeight left right b (glueAmplitude B ⊤ r) η*bondPinFactor left right B η*f η)- + c*(∑ η,amplitudeBondWeight left right b (glueAmplitude B ⊤ r) η*bondPinFactor left right B η*1) := by + dsimp only [F] + rw [Finset.mul_sum,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro η _ + ring + simp_rw [he] at ht + have hc (q : (E → Bool) → ℝ) : Continuous (fun r : ↥(Bᶜ) → Amplitude => + ∑ η,amplitudeBondWeight left right b (glueAmplitude B ⊤ r) η*bondPinFactor left right B η*q η) := + (continuous_pinWeightedSum _ _ _ _ q).comp ((continuous_glueAmplitude B).comp (continuous_const.prodMk continuous_id)) + rw [integral_sub (compact_integrable (hc f)) ((compact_integrable (hc (fun _ => 1))).const_mul c),integral_const_mul] at ht + apply (le_div_iff₀ (pinnedBondNumerator_one_pos μ _ _ _ hb B)).2 + exact sub_nonneg.mp ht + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PinnedBlocks.lean b/lean/OAI/Probability/ClassicalON/PinnedBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a5e61f75debfadebdc455391b8a3743144361e1 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PinnedBlocks.lean @@ -0,0 +1,160 @@ +import OAI.Probability.ClassicalON.WeightedProduct + +namespace OAI + +universe uE uK uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} {K : Type uK} [Fintype V] [Fintype E] [Fintype K] + +omit [Fintype E] in +theorem sum_fibers (label : V → K) (f : V → ℝ) : + (∑ k,∑ v : {v // label v=k},f v.val)=∑ v,f v := by + rw [← Fintype.sum_sigma (fun v : Σ k : K,{v // label v=k} => f v.2.val)] + exact (Equiv.sigmaFiberEquiv label).sum_comp f + +omit [Fintype E] in +theorem prod_fibers (label : V → K) (f : V → ℝ) : + (∏ k,∏ v : {v // label v=k},f v.val)=∏ v,f v := by + rw [← Fintype.prod_sigma (fun v : Σ k : K,{v // label v=k} => f v.2.val)] + exact (Equiv.sigmaFiberEquiv label).prod_comp f + +abbrev BlockVertex (B : Set V) (label : V → K) (k : K) := {v : ↥(Bᶜ) // label v.val=k} + +def blockSpin (B : Set V) (label : V → K) (k : K) (s : BlockVertex B label k → Spin 3) : V → Spin 3 := + fun v => if hv : v∈B then poleSpin true else + if hk : label v=k then s ⟨⟨v,hv⟩,hk⟩ else poleSpin true + +omit [Fintype V] [Fintype E] [Fintype K] in +theorem continuous_blockSpin (B : Set V) (label : V → K) (k : K) : + Continuous (blockSpin B label k) := by + apply continuous_pi + intro v + by_cases hv : v∈B + · simp only [blockSpin,hv,↓reduceDIte] + exact continuous_const + · by_cases hk : label v=k + · simp only [blockSpin,hv,hk,↓reduceDIte] + exact continuous_apply _ + · simp only [blockSpin,hv,hk,↓reduceDIte] + exact continuous_const + +omit [Fintype V] [Fintype E] [Fintype K] in +theorem blockSpin_eq_glue (B : Set V) (label : V → K) (k : K) (s : ↥(Bᶜ) → Spin 3) + (v : V) (h : v∉B → label v=k) : + blockSpin B label k (fun w => s w.val) v=glueFamily B (fun _ => poleSpin true) s v := by + by_cases hv : v∈B + · rw [show glueFamily B (fun _ => poleSpin true) s v=poleSpin true from + glueFamily_in B _ _ ⟨v,hv⟩] + simp only [blockSpin,hv,↓reduceDIte] + · rw [show glueFamily B (fun _ => poleSpin true) s v=s ⟨v,hv⟩ from + glueFamily_out B _ _ ⟨v,hv⟩] + simp only [blockSpin,hv,h hv,↓reduceDIte] + +def blockEnergy (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (k : K) (s : BlockVertex B label k → Spin 3) : ℝ := + freeSpinEnergy 3 (fun e : {e // elabel e=k} => left e.val) (fun e => right e.val) + (fun e => b e.val) (blockSpin B label k s) + +def blockBondWeight (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (k : K) (s : BlockVertex B label k → Spin 3) + (η : {e // elabel e=k} → Bool) : ℝ := + spinBondWeight (fun e : {e // elabel e=k} => left e.val) (fun e => right e.val) + (fun e => b e.val) (blockSpin B label k s) η + +def blockBondMean (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (k : K) (f : ({e // elabel e=k} → Bool) → ℝ) : ℝ := + weightedMean (Measure.pi (fun _ : BlockVertex B label k => sphereProbability 3)) + (fun s => Real.exp (blockEnergy left right b B label elabel k s)) + (fun s => ∑ η,blockBondWeight left right b B label elabel k s η*f η) + +omit [Fintype V] in +theorem block_energy_sum (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (hl : ∀ e,left e∉B → label (left e)=elabel e) + (hr : ∀ e,right e∉B → label (right e)=elabel e) (s : ↥(Bᶜ) → Spin 3) : + (∑ k,blockEnergy left right b B label elabel k (fun v => s v.val))= + freeSpinEnergy 3 left right b (glueFamily B (fun _ => poleSpin true) s) := by + unfold blockEnergy freeSpinEnergy + have he (k : K) (e : {e // elabel e=k}) : + b e.val*⟪(blockSpin B label k (fun v => s v.val) (left e.val)).val, + (blockSpin B label k (fun v => s v.val) (right e.val)).val⟫_ℝ= + b e.val*⟪(glueFamily B (fun _ => poleSpin true) s (left e.val)).val, + (glueFamily B (fun _ => poleSpin true) s (right e.val)).val⟫_ℝ := by + rw [blockSpin_eq_glue _ _ _ _ _ (fun h => (hl _ h).trans e.property), + blockSpin_eq_glue _ _ _ _ _ (fun h => (hr _ h).trans e.property)] + simp_rw [he] + convert sum_fibers elabel (fun e => b e*⟪(glueFamily B (fun _ => poleSpin true) s (left e)).val, + (glueFamily B (fun _ => poleSpin true) s (right e)).val⟫_ℝ) using 1 + +omit [Fintype V] in +theorem block_bond_product (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (hl : ∀ e,left e∉B → label (left e)=elabel e) + (hr : ∀ e,right e∉B → label (right e)=elabel e) (s : ↥(Bᶜ) → Spin 3) (η : E → Bool) : + (∏ k,blockBondWeight left right b B label elabel k (fun v => s v.val) (fun e => η e.val))= + spinBondWeight left right b (glueFamily B (fun _ => poleSpin true) s) η := by + unfold blockBondWeight spinBondWeight spinBondParameter + have he (k : K) (e : {e // elabel e=k}) : + blockSpin B label k (fun v => s v.val) (left e.val)=glueFamily B (fun _ => poleSpin true) s (left e.val) := + blockSpin_eq_glue _ _ _ _ _ (fun h => (hl _ h).trans e.property) + have he' (k : K) (e : {e // elabel e=k}) : + blockSpin B label k (fun v => s v.val) (right e.val)=glueFamily B (fun _ => poleSpin true) s (right e.val) := + blockSpin_eq_glue _ _ _ _ _ (fun h => (hr _ h).trans e.property) + simp_rw [he,he'] + convert prod_fibers elabel (fun e => if η e then spinBondParameter left right b + (glueFamily B (fun _ => poleSpin true) s) e else 1-spinBondParameter left right b + (glueFamily B (fun _ => poleSpin true) s) e) using 1 <;> congr! + +theorem poleBondMean_collapse (left right : E → V) (b : E → ℝ) (B : Set V) (f : (E → Bool) → ℝ) : + poleBondMean left right b B (fun _ => true) f= + weightedMean (Measure.pi (fun _ : ↥(Bᶜ) => sphereProbability 3)) + (fun s => Real.exp (freeSpinEnergy 3 left right b (glueFamily B (fun _ => poleSpin true) s))) + (fun s => ∑ η,spinBondWeight left right b (glueFamily B (fun _ => poleSpin true) s) η*f η) := by + unfold poleBondMean weightedMean + rw [poleSystem_reference] + have hc : Continuous (fun s : V → Spin 3 => Real.exp (freeSpinEnergy 3 left right b s)* + ∑ η,spinBondWeight left right b s η*f η) := + (continuous_freeSpinEnergy _ _ _ _).rexp.mul + (continuous_finsetSum _ (fun _ _ => (continuous_spinBondWeight _ _ _ _).mul continuous_const)) + rw [integral_pinProductMeasure _ _ _ _ hc, + integral_pinProductMeasure _ _ _ _ (continuous_freeSpinEnergy 3 left right b).rexp] + +omit [Fintype V] in +theorem block_event_product (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (hl : ∀ e,left e∉B → label (left e)=elabel e) + (hr : ∀ e,right e∉B → label (right e)=elabel e) + (f : (k : K) → ({e // elabel e=k} → Bool) → ℝ) (s : ↥(Bᶜ) → Spin 3) : + (∑ η,spinBondWeight left right b (glueFamily B (fun _ => poleSpin true) s) η* + ∏ k,f k (fun e => η e.val))= + ∏ k,∑ η,blockBondWeight left right b B label elabel k (fun v => s v.val) η*f k η := by + have hp (η : E → Bool) := (block_bond_product left right b B label elabel hl hr s η).symm + simp_rw [hp,← Finset.prod_mul_distrib] + convert sum_grouped_product (C := fun _ => Bool) elabel (fun k η => + blockBondWeight left right b B label elabel k (fun v => s v.val) η*f k η) using 1 + +theorem poleBondMean_blocks (left right : E → V) (b : E → ℝ) (B : Set V) (label : V → K) + (elabel : E → K) (hl : ∀ e,left e∉B → label (left e)=elabel e) + (hr : ∀ e,right e∉B → label (right e)=elabel e) + (f : (k : K) → ({e // elabel e=k} → Bool) → ℝ) : + poleBondMean left right b B (fun _ => true) (fun η => ∏ k,f k (fun e => η e.val))= + ∏ k,blockBondMean left right b B label elabel k (f k) := by + rw [poleBondMean_collapse] + have hw (s : ↥(Bᶜ) → Spin 3) : + Real.exp (freeSpinEnergy 3 left right b (glueFamily B (fun _ => poleSpin true) s))= + ∏ k,Real.exp (blockEnergy left right b B label elabel k (fun v => s v.val)) := by + rw [← block_energy_sum _ _ _ _ _ _ hl hr,Real.exp_sum] + have hf := block_event_product left right b B label elabel hl hr f + simp_rw [hw,hf] + unfold blockBondMean + convert weightedMean_grouped_product (fun _ : ↥(Bᶜ) => Spin 3) (fun v => label v.val) + (fun _ => sphereProbability 3) + (fun k s => Real.exp (blockEnergy left right b B label elabel k s)) + (fun k s => ∑ η,blockBondWeight left right b B label elabel k s η*f k η) using 1 + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PinnedBonds.lean b/lean/OAI/Probability/ClassicalON/PinnedBonds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d22f7c70073c47e227df52a45988ccf3c883c80 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PinnedBonds.lean @@ -0,0 +1,174 @@ +import OAI.Probability.ClassicalON.PinComparison + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def pinNormalization (B : Set V) : ℝ := + (2:ℝ)⁻¹^Fintype.card ↥(Bᶜ)/((2:ℝ)⁻¹^Fintype.card V) + +theorem pinNormalization_pos (B : Set V) : 0 p v) τ))= + bondProduct t η*(Fintype.card (prescribedCompatibleSigns left right B p η):ℝ) := by + rw [sum_glueFamily] + simp_rw [bondSignProduct_eq] + have he (s : V → Bool) : + (if (fun v : B => s v)=(fun v : B => p v) then + bondProduct t η*(if s∈compatibleSigns left right η then 1 else 0) else 0)= + bondProduct t η*(if s∈prescribedCompatibleSigns left right B p η then 1 else 0) := by + have h : (fun v : B => s v)=(fun v : B => p v) ↔ ∀ v∈B,s v=p v := by + simp only [funext_iff,Subtype.forall] + have hp : s∈prescribedCompatibleSigns left right B p η ↔ + s∈compatibleSigns left right η ∧ ∀ v∈B,s v=p v := Iff.rfl + simp only [hp,h] + by_cases hB : ∀ v∈B,s v=p v + · rw [ite_eq_left hB] + by_cases hC : s∈compatibleSigns left right η + · rw [ite_eq_left hC,ite_eq_left ⟨hC,hB⟩] + · rw [ite_eq_right hC,ite_eq_right (fun h => hC h.1)] + · rw [ite_eq_right hB,ite_eq_right (fun h => hB h.2),mul_zero] + simp_rw [he] + rw [← Finset.mul_sum,Finset.sum_boole,← Fintype.card_subtype] + +theorem integral_pole_spinBondWeight_card (left right : E → V) (b : E → ℝ) + (B : Set V) (p : V → Bool) (η : E → Bool) : + (∫ s,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η + ∂(poleSystem left right b B (fun v => p v)).reference)= + pinNormalization B * ∫ r,amplitudeBondPrefactor left right b (glueAmplitude B ⊤ r)* + bondProduct (amplitudeBondParam left right b (glueAmplitude B ⊤ r)) η* + (Fintype.card (prescribedCompatibleSigns left right B p η):ℝ) + ∂Measure.pi (fun _ : ↥(Bᶜ) => sphericalAmplitudeLaw) := by + have hc : Continuous (fun s : V → Spin 3 => Real.exp (freeSpinEnergy 3 left right b s)* + spinBondWeight left right b s η) := + (continuous_freeSpinEnergy 3 left right b).rexp.mul (continuous_spinBondWeight left right b η) + rw [integral_poleSystem_cylinder _ _ _ _ _ _ hc,← integral_const_mul] + apply integral_congr_ae + filter_upwards with r + simp_rw [cylindrical_spin_bond_weight,integral_const_mul] + change (∫ τ,Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (glueAmplitude B ⊤ r v:ℝ)) e)* + bondSignProduct left right (fun e => Real.exp (2*amplitudeCoupling left right b + (fun v => (glueAmplitude B ⊤ r v:ℝ)) e)-1) η (glueFamily B (fun v => p v) τ)* + planarAmplitudePartition left right b (glueAmplitude B ⊤ r) ∂isingReference)=_ + rw [integral_mul_const,integral_const_mul,integral_isingReference] + have hh := sum_prescribed_bondSignProduct left right + (fun e => Real.exp (2*amplitudeCoupling left right b (fun v => (glueAmplitude B ⊤ r v:ℝ)) e)-1) B p η + convert_to Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (glueAmplitude B ⊤ r v:ℝ)) e)* + ((2:ℝ)⁻¹^Fintype.card ↥(Bᶜ)* + (∑ τ : ↥(Bᶜ) → Bool,bondSignProduct left right + (fun e => Real.exp (2*amplitudeCoupling left right b (fun v => (glueAmplitude B ⊤ r v:ℝ)) e)-1) η + (glueFamily B (fun v => p v) τ)))* + planarAmplitudePartition left right b (glueAmplitude B ⊤ r)=_ using 1 + · congr! + rw [hh,amplitudeBondParam_eq] + unfold amplitudeBondPrefactor pinNormalization + have hn : ((2:ℝ)⁻¹^Fintype.card V)≠0 := by positivity + field_simp + +omit [Fintype E] in +theorem prescribed_positive_card (left right : E → V) (B : Set V) (η : E → Bool) : + (Fintype.card (prescribedCompatibleSigns left right B (fun _ => true) η):ℝ)= + clusterWeight left right η*bondPinFactor left right B η := + positiveCompatibleSigns_card _ _ _ _ + +theorem integral_positive_spinBondWeight (left right : E → V) (b : E → ℝ) + (B : Set V) (η : E → Bool) : + (∫ s,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η + ∂(poleSystem left right b B (fun _ => true)).reference)= + pinNormalization B * ∫ r,amplitudeBondWeight left right b (glueAmplitude B ⊤ r) η* + bondPinFactor left right B η ∂Measure.pi (fun _ : ↥(Bᶜ) => sphericalAmplitudeLaw) := by + rw [integral_pole_spinBondWeight_card left right b B (fun _ => true) η] + simp_rw [prescribed_positive_card] + simp only [amplitudeBondWeight,bondWeight,mul_assoc,mul_left_comm,mul_comm] + +theorem integral_layer_spinBondWeight (left right : E → V) (b : E → ℝ) + (I O : Set V) (hIO : Disjoint I O) (η : E → Bool) : + (∫ s,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η + ∂(poleSystem left right b (I∪O) (fun v => layerSigns I v)).reference)= + pinNormalization (I∪O) * ∫ r,amplitudeBondWeight left right b (glueAmplitude (I∪O) ⊤ r) η* + bondPinFactor left right (I∪O) η*(if bondCrossing left right I O η then 0 else 1) + ∂Measure.pi (fun _ : ↥((I∪O)ᶜ) => sphericalAmplitudeLaw) := by + rw [integral_pole_spinBondWeight_card] + simp_rw [layerSigns_card _ _ _ _ hIO] + simp only [amplitudeBondWeight,bondWeight,mul_assoc,mul_left_comm,mul_comm] + all_goals congr! + +def poleBondMean (left right : E → V) (b : E → ℝ) (B : Set V) (p : B → Bool) + (f : (E → Bool) → ℝ) : ℝ := + weightedMean (poleSystem left right b B p).reference (fun s => Real.exp (freeSpinEnergy 3 left right b s)) + (fun s => ∑ η,spinBondWeight left right b s η*f η) + +theorem integral_spinWeight_sum (left right : E → V) (b : E → ℝ) + (μ : Measure (V → Spin 3)) [IsFiniteMeasure μ] : + (∫ s,Real.exp (freeSpinEnergy 3 left right b s) ∂μ)= + ∑ η,∫ s,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η ∂μ := by + rw [← integral_finsetSum] + · apply integral_congr_ae + filter_upwards with s + rw [← Finset.mul_sum,spinBondWeight_sum,mul_one] + · intro η _ + exact compact_integrable ((continuous_freeSpinEnergy _ _ _ _).rexp.mul (continuous_spinBondWeight _ _ _ _)) + +theorem positive_Z (left right : E → V) (b : E → ℝ) (B : Set V) : + (poleSystem left right b B (fun _ => true)).Z (fun _ => 1)= + pinNormalization B*pinnedBondNumerator sphericalAmplitudeLaw left right b B (fun _ => 1) := by + change (∫ s,Real.exp (freeSpinEnergy 3 left right b s) ∂(poleSystem left right b B (fun _ => true)).reference)=_ + rw [integral_spinWeight_sum] + simp_rw [integral_positive_spinBondWeight] + rw [← Finset.mul_sum,← integral_finsetSum] + · simp only [mul_one,pinnedBondNumerator] + · intro η _ + exact compact_integrable (((continuous_amplitudeBondWeight _ _ _ _).comp + ((continuous_glueAmplitude B).comp (continuous_const.prodMk continuous_id))).mul continuous_const) + +theorem layer_Z (left right : E → V) (b : E → ℝ) (I O : Set V) (hIO : Disjoint I O) : + (poleSystem left right b (I∪O) (fun v => layerSigns I v)).Z (fun _ => 1)= + pinNormalization (I∪O)*pinnedBondNumerator sphericalAmplitudeLaw left right b (I∪O) + (fun η => if bondCrossing left right I O η then 0 else 1) := by + change (∫ s,Real.exp (freeSpinEnergy 3 left right b s) ∂(poleSystem left right b (I∪O) (fun v => layerSigns I v)).reference)=_ + rw [integral_spinWeight_sum] + simp_rw [integral_layer_spinBondWeight _ _ _ _ _ hIO] + rw [← Finset.mul_sum,← integral_finsetSum] + · simp only [pinnedBondNumerator] + congr! + · intro η _ + exact compact_integrable ((((continuous_amplitudeBondWeight _ _ _ _).comp + ((continuous_glueAmplitude (I∪O)).comp (continuous_const.prodMk continuous_id))).mul continuous_const).mul continuous_const) + +theorem poleBondMean_eq_pinnedBondMean (left right : E → V) (b : E → ℝ) (B : Set V) + (f : (E → Bool) → ℝ) : + poleBondMean left right b B (fun _ => true) f= + pinnedBondMean sphericalAmplitudeLaw left right b B f := by + unfold poleBondMean weightedMean + change _/(poleSystem left right b B (fun _ => true)).Z (fun _ => 1)=_ + rw [positive_Z] + simp_rw [Finset.mul_sum,← mul_assoc] + rw [integral_finsetSum] + · simp_rw [integral_mul_const,integral_positive_spinBondWeight] + simp_rw [mul_assoc (pinNormalization B)] + rw [← Finset.mul_sum] + simp_rw [← integral_mul_const] + rw [← integral_finsetSum] + · exact mul_div_mul_left _ _ (ne_of_gt (pinNormalization_pos B)) + · intro η _ + exact compact_integrable ((((continuous_amplitudeBondWeight _ _ _ _).comp + ((continuous_glueAmplitude B).comp (continuous_const.prodMk continuous_id))).mul continuous_const).mul continuous_const) + · intro η _ + exact (compact_integrable ((continuous_freeSpinEnergy _ _ _ _).rexp.mul + (continuous_spinBondWeight _ _ _ _))).mul_const _ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PinnedCylinder.lean b/lean/OAI/Probability/ClassicalON/PinnedCylinder.lean new file mode 100644 index 0000000000000000000000000000000000000000..41ede6b0747f3fb17ed2a70cae553bd07ebb0e54 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PinnedCylinder.lean @@ -0,0 +1,87 @@ +import OAI.Probability.ClassicalON.PinnedReference + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def poleSpin (τ : Bool) : Spin 3 := cylindricalSpin ⊤ τ 0 + +theorem cylindricalSpin_top (τ : Bool) (θ : PlanarAngle) : cylindricalSpin ⊤ τ θ=poleSpin τ := by + apply Subtype.ext + ext i + fin_cases i <;> simp [poleSpin,cylindricalSpin,transverseAmplitude] + +def poleSystem (left right : E → V) (b : E → ℝ) (B : Set V) (t : B → Bool) : SpinSystem 3 V E := + ⟨left,right,b,fun v => if h : v∈B then some (poleSpin (t ⟨v,h⟩)) else none⟩ + +omit [Fintype E] in +theorem poleSystem_reference (left right : E → V) (b : E → ℝ) (B : Set V) (t : B → Bool) : + (poleSystem left right b B t).reference=pinProductMeasure (sphereProbability 3) B (fun v => poleSpin (t v)) := by + unfold SpinSystem.reference poleSystem pinProductMeasure + congr 1 + funext v + by_cases h : v∈B <;> simp [siteReference,h] + +omit [Fintype V] in +theorem poleSystem_energy (left right : E → V) (b : E → ℝ) (B : Set V) (t : B → Bool) (s : V → Spin 3) : + (poleSystem left right b B t).energy (fun _ => 1) s=freeSpinEnergy 3 left right b s := rfl + +omit [Fintype V] [Fintype E] in +theorem glue_cylindrical (B : Set V) (t : B → Bool) (r : ↥(Bᶜ) → Amplitude) + (τ : ↥(Bᶜ) → Bool) (θ : V → PlanarAngle) : + glueFamily B (fun v => poleSpin (t v)) + (cylindricalConfiguration r τ (fun v : ↥(Bᶜ) => θ v))= + cylindricalConfiguration (glueAmplitude B ⊤ r) (glueFamily B t τ) θ := by + funext v + by_cases hv : v∈B + · have h1 := glueFamily_in B (fun v => poleSpin (t v)) + (cylindricalConfiguration r τ (fun v : ↥(Bᶜ) => θ v)) ⟨v,hv⟩ + rw [h1] + change _=cylindricalSpin (glueAmplitude B ⊤ r (⟨v,hv⟩ : B)) (glueFamily B t τ (⟨v,hv⟩ : B)) (θ v) + rw [glueAmplitude_in,glueFamily_in] + exact (cylindricalSpin_top _ _).symm + · have h1 := glueFamily_out B (fun v => poleSpin (t v)) + (cylindricalConfiguration r τ (fun v : ↥(Bᶜ) => θ v)) ⟨v,hv⟩ + rw [h1] + change _=cylindricalSpin (glueAmplitude B ⊤ r (⟨v,hv⟩ : ↥(Bᶜ))) + (glueFamily B t τ (⟨v,hv⟩ : ↥(Bᶜ))) (θ v) + rw [glueAmplitude_out,glueFamily_out] + rfl + +omit [Fintype E] in +theorem integral_poleSystem_cylinder (left right : E → V) (b : E → ℝ) (B : Set V) (t : B → Bool) + (f : (V → Spin 3) → ℝ) (hf : Continuous f) : + (∫ s,f s ∂(poleSystem left right b B t).reference)= + ∫ r,∫ τ,∫ θ,f (cylindricalConfiguration (glueAmplitude B ⊤ r) (glueFamily B t τ) θ) + ∂planarReference ∂isingReference ∂Measure.pi (fun _ : ↥(Bᶜ) => sphericalAmplitudeLaw) := by + rw [poleSystem_reference,integral_pinProductMeasure _ _ _ _ hf] + have hc : Continuous (fun s : ↥(Bᶜ) → Spin 3 => f (glueFamily B (fun v => poleSpin (t v)) s)) := + hf.comp ((continuous_glueFamily B).comp (continuous_const.prodMk continuous_id)) + change (∫ s,f (glueFamily B (fun v => poleSpin (t v)) s) ∂freeSpinReference 3)=_ + rw [integral_freeSpinReference_cylinder _ hc] + apply integral_congr_ae + filter_upwards with r + apply integral_congr_ae + filter_upwards with τ + have hθ : Continuous (fun θ : ↥(Bᶜ) → PlanarAngle => + f (glueFamily B (fun v => poleSpin (t v)) (cylindricalConfiguration r τ θ))) := + hc.comp (continuous_cylindricalConfiguration.comp (continuous_const.prodMk (continuous_const.prodMk continuous_id))) + have he := integral_pi_restriction angleLaw B _ hθ + change (∫ θ,f (glueFamily B (fun v => poleSpin (t v)) (cylindricalConfiguration r τ θ)) + ∂Measure.pi (fun _ : ↥(Bᶜ) => angleLaw))=_ + rw [← he] + apply integral_congr_ae + filter_upwards with θ + rw [glue_cylindrical] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PinnedReference.lean b/lean/OAI/Probability/ClassicalON/PinnedReference.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba764eb54d952e83a25cb22025290b69aed656ae --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PinnedReference.lean @@ -0,0 +1,122 @@ +import OAI.Probability.ClassicalON.AmplitudeSplit + +namespace OAI + +universe uA uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {A : Type uA} [Fintype V] + +def glueFamily (B : Set V) (a : B → A) (r : ↥(Bᶜ) → A) : V → A := + (Equiv.piEquivPiSubtypeProd (·∈B) (fun _ : V => A)).symm (a,r) + +omit [Fintype V] in +@[simp] theorem glueFamily_in (B : Set V) (a : B → A) (r : ↥(Bᶜ) → A) (v : B) : + glueFamily B a r v=a v := by simp [glueFamily,Equiv.piEquivPiSubtypeProd,v.property] + +omit [Fintype V] in +@[simp] theorem glueFamily_out (B : Set V) (a : B → A) (r : ↥(Bᶜ) → A) (v : ↥(Bᶜ)) : + glueFamily B a r v=r v := by + simp [glueFamily,Equiv.piEquivPiSubtypeProd,show v.val∉B from v.property] + +omit [Fintype V] in +theorem continuous_glueFamily [TopologicalSpace A] (B : Set V) : + Continuous (fun p : (B → A)×(↥(Bᶜ) → A) => glueFamily B p.1 p.2) := + (Homeomorph.piEquivPiSubtypeProd (·∈B) (fun _ : V => A)).symm.continuous + +theorem sum_glueFamily [Fintype A] (B : Set V) (a : B → A) (f : (V → A) → ℝ) : + (∑ r : ↥(Bᶜ) → A,f (glueFamily B a r))= + ∑ s : V → A,if (fun v : B => s v)=a then f s else 0 := by + let e := Equiv.piEquivPiSubtypeProd (·∈B) (fun _ : V => A) + rw [← e.symm.sum_comp (fun s => if (fun v : B => s v)=a then f s else 0)] + rw [Fintype.sum_prod_type] + have he (p : B → A) (r : ↥(Bᶜ) → A) : (fun v : B => (e.symm (p,r)) v)=p := by + funext v + exact glueFamily_in B p r v + simp_rw [he] + simp only [Finset.sum_ite_irrel,Finset.sum_const_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rfl + +section Measure +variable [MeasurableSpace A] [MeasurableSingletonClass A] + +def pinProductMeasure (μ : Measure A) (B : Set V) (a : B → A) : Measure (V → A) := + Measure.pi (fun v => if h : v∈B then Measure.dirac (a ⟨v,h⟩) else μ) + +instance pinProductMeasure_isProbability (μ : Measure A) [IsProbabilityMeasure μ] + (B : Set V) (a : B → A) : IsProbabilityMeasure (pinProductMeasure μ B a) := by + unfold pinProductMeasure + have : ∀ v : V,IsProbabilityMeasure (if h : v∈B then Measure.dirac (a ⟨v,h⟩) else μ) := by + intro v; split <;> infer_instance + infer_instance + +theorem measure_pi_dirac (a : V → A) : (Measure.pi (fun v => Measure.dirac (a v)))=Measure.dirac a := by + apply Measure.pi_eq + intro s hs + by_cases h : ∀ v,a v∈s v + · simp [h] + · obtain ⟨v,hv⟩ := not_forall.mp h + have hn : a∉Set.pi Set.univ s := by + intro ha + exact hv (ha v (Set.mem_univ v)) + rw [Measure.dirac_apply,Set.indicator_of_notMem hn] + symm + apply Finset.prod_eq_zero (Finset.mem_univ v) + simp [hv] + +variable [TopologicalSpace A] [CompactSpace A] [T2Space A] [SecondCountableTopology A] [BorelSpace A] + +omit [T2Space A] in +theorem integral_pinProductMeasure (μ : Measure A) [IsProbabilityMeasure μ] + (B : Set V) (a : B → A) (f : (V → A) → ℝ) (hf : Continuous f) : + (∫ s,f s ∂pinProductMeasure μ B a)= + ∫ r,f (glueFamily B a r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ) := by + let ν (v : V) : Measure A := if h : v∈B then Measure.dirac (a ⟨v,h⟩) else μ + have : ∀ v,IsProbabilityMeasure (ν v) := by intro v; dsimp [ν]; split <;> infer_instance + let e := MeasurableEquiv.piEquivPiSubtypeProd (fun _ : V => A) (·∈B) + have hp := (measurePreserving_piEquivPiSubtypeProd ν (·∈B)).symm e + have hB : (fun v : B => ν v)=(fun v : B => Measure.dirac (a v)) := by funext v; simp [ν,v.property] + have hC : (fun v : ↥(Bᶜ) => ν v)=(fun _ : ↥(Bᶜ) => μ) := by + funext v; simp [ν,show v.val∉B from v.property] + change (∫ s,f s ∂Measure.pi ν)=_ + rw [← hp.map_eq,integral_map hp.measurable.aemeasurable hf.aestronglyMeasurable] + change (∫ p : (B → A)×(↥(Bᶜ) → A), f (glueFamily B p.1 p.2) + ∂(Measure.pi (fun v : B => ν v)).prod (Measure.pi (fun v : ↥(Bᶜ) => ν v)))=_ + rw [hB,hC,measure_pi_dirac] + have hi : Integrable (fun p : (B → A)×(↥(Bᶜ) → A) => f (glueFamily B p.1 p.2)) + ((Measure.dirac a).prod (Measure.pi (fun _ : ↥(Bᶜ) => μ))) := + compact_integrable (hf.comp (continuous_glueFamily B)) + rw [integral_prod _ hi] + rw [integral_dirac] + +omit [MeasurableSingletonClass A] in +theorem integral_pi_split (μ : Measure A) [IsProbabilityMeasure μ] + (B : Set V) (f : (V → A) → ℝ) (hf : Continuous f) : + (∫ s,f s ∂Measure.pi (fun _ : V => μ))= + ∫ a,∫ r,f (glueFamily B a r) ∂Measure.pi (fun _ : ↥(Bᶜ) => μ) + ∂Measure.pi (fun _ : B => μ) := by + let e := MeasurableEquiv.piEquivPiSubtypeProd (fun _ : V => A) (·∈B) + have hp := (measurePreserving_piEquivPiSubtypeProd (fun _ : V => μ) (·∈B)).symm e + rw [← hp.map_eq,integral_map hp.measurable.aemeasurable hf.aestronglyMeasurable] + exact integral_prod _ (compact_integrable (hf.comp (continuous_glueFamily B))) + +omit [MeasurableSingletonClass A] in +theorem integral_pi_restriction (μ : Measure A) [IsProbabilityMeasure μ] + (B : Set V) (f : (↥(Bᶜ) → A) → ℝ) (hf : Continuous f) : + (∫ s,f (fun v : ↥(Bᶜ) => s v) ∂Measure.pi (fun _ : V => μ))= + ∫ r,f r ∂Measure.pi (fun _ : ↥(Bᶜ) => μ) := by + have hc : Continuous (fun s : V → A => f (fun v : ↥(Bᶜ) => s v)) := + hf.comp (continuous_pi (fun v => continuous_apply v.val)) + rw [integral_pi_split μ B _ hc] + simp only [glueFamily_out] + simp + +end Measure +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PinnedSigns.lean b/lean/OAI/Probability/ClassicalON/PinnedSigns.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4718a0cf75525ad47d770ccc7e072bd0b4b72a8 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PinnedSigns.lean @@ -0,0 +1,42 @@ +import OAI.Probability.ClassicalON.BondPin + +namespace OAI + +universe uE uV + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] + +def positiveCompatibleSigns (left right : E → V) (B : Set V) (η : E → Bool) : Set (V → Bool) := + {s | s∈compatibleSigns left right η ∧ ∀ v∈B,s v=true} + +def positiveCompatibleSignsEquiv (left right : E → V) (B : Set V) (η : E → Bool) : + positiveCompatibleSigns left right B η ≃ pinnedBondSubspace left right B η := + (Equiv.piCongrRight (fun _ : V => signFieldEquiv)).subtypeEquiv (by + intro s + change ((∀ e,η e=true → s (left e)=s (right e)) ∧ ∀ v∈B,s v=true) ↔ + ((∀ e,η e=true → signFieldEquiv (s (left e))=signFieldEquiv (s (right e))) ∧ + (fun v : B => signFieldEquiv (s v))=0) + simp only [Equiv.apply_eq_iff_eq,funext_iff,Pi.zero_apply,Subtype.forall, + ← signFieldEquiv_true,Equiv.apply_eq_iff_eq]) + +theorem positiveCompatibleSigns_card (left right : E → V) (B : Set V) (η : E → Bool) : + (Fintype.card (positiveCompatibleSigns left right B η):ℝ)= + clusterWeight left right η*bondPinFactor left right B η := by + rw [Fintype.card_congr (positiveCompatibleSignsEquiv left right B η)] + exact pinnedBond_card left right B η + +theorem positiveCompatibleSigns_sum (left right : E → V) (B : Set V) (η : E → Bool) : + (∑ s : V → Bool,if s∈positiveCompatibleSigns left right B η then (1:ℝ) else 0)= + clusterWeight left right η*bondPinFactor left right B η := by + rw [Finset.sum_boole,← Fintype.card_subtype] + exact positiveCompatibleSigns_card left right B η + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PlanarAlgebra.lean b/lean/OAI/Probability/ClassicalON/PlanarAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..d32ccec5b1510ffb83704fe748d101e8c4c5ae67 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PlanarAlgebra.lean @@ -0,0 +1,92 @@ +import OAI.Probability.ClassicalON.TorusDouble + +namespace OAI + +universe uE uV + +noncomputable section +namespace ClassicalON + +open scoped ComplexConjugate + +def planarCharacter (t : PlanarAngle) : ℂ := AddCircle.toCircle t + +def planarCos (t : PlanarAngle) : ℝ := (planarCharacter t).re + +def planarSin (t : PlanarAngle) : ℝ := (planarCharacter t).im + +theorem continuous_planarCos : Continuous planarCos := by + unfold planarCos planarCharacter + exact Complex.continuous_re.comp (continuous_subtype_val.comp AddCircle.continuous_toCircle) + +theorem continuous_planarSin : Continuous planarSin := by + unfold planarSin planarCharacter + exact Complex.continuous_im.comp (continuous_subtype_val.comp AddCircle.continuous_toCircle) + +theorem planarCharacter_add (x y : PlanarAngle) : + planarCharacter (x+y)=planarCharacter x*planarCharacter y := by + simp only [planarCharacter,AddCircle.toCircle_add,Circle.coe_mul] + +theorem planarCharacter_neg (x : PlanarAngle) : + planarCharacter (-x)=conj (planarCharacter x) := by + simp only [planarCharacter,AddCircle.toCircle_neg,Circle.coe_inv_eq_conj] + +theorem planarCos_add_sub (x y : PlanarAngle) : + planarCos (x+y)+planarCos (x-y)=2*planarCos x*planarCos y := by + simp only [planarCos,sub_eq_add_neg,planarCharacter_add,planarCharacter_neg, + Complex.mul_re,Complex.conj_re,Complex.conj_im] + ring + +theorem planarCos_subtraction (x y : PlanarAngle) : + planarCos (x+y)-planarCos (x-y)= -2*planarSin x*planarSin y := by + simp only [planarCos,planarSin,sub_eq_add_neg,planarCharacter_add,planarCharacter_neg, + Complex.mul_re,Complex.conj_re,Complex.conj_im] + ring + +variable {V : Type uV} {E : Type uE} + +def planarEnergy (left right : E → V) (e : E) (θ : V → PlanarAngle) : ℝ := + planarCos (θ (left e)-θ (right e)) + +def planarSine (left right : E → V) (e : E) (θ : V → PlanarAngle) : ℝ := + planarSin (θ (left e)-θ (right e)) + +theorem continuous_planarEnergy (left right : E → V) (e : E) : + Continuous (planarEnergy left right e) := by + exact continuous_planarCos.comp ((continuous_apply _).sub (continuous_apply _)) + +theorem continuous_planarSine (left right : E → V) (e : E) : + Continuous (planarSine left right e) := by + exact continuous_planarSin.comp ((continuous_apply _).sub (continuous_apply _)) + +theorem planarEnergy_double_sum (left right : E → V) (e : E) + (p : (V → PlanarAngle)×(V → PlanarAngle)) : + planarEnergy left right e (torusDouble p).1+planarEnergy left right e (torusDouble p).2= + 2*planarEnergy left right e p.1*planarEnergy left right e p.2 := by + change planarCos ((p.1+p.2) (left e)-(p.1+p.2) (right e))+ + planarCos ((p.1-p.2) (left e)-(p.1-p.2) (right e))=_ + simp only [Pi.add_apply,Pi.sub_apply] + rw [show p.1 (left e)+p.2 (left e)-(p.1 (right e)+p.2 (right e))= + (p.1 (left e)-p.1 (right e))+(p.2 (left e)-p.2 (right e)) by abel, + show p.1 (left e)-p.2 (left e)-(p.1 (right e)-p.2 (right e))= + (p.1 (left e)-p.1 (right e))-(p.2 (left e)-p.2 (right e)) by abel] + exact planarCos_add_sub _ _ + +theorem planarEnergy_double_sub (left right : E → V) (e : E) + (p : (V → PlanarAngle)×(V → PlanarAngle)) : + planarEnergy left right e (torusDouble p).1-planarEnergy left right e (torusDouble p).2= + -2*planarSine left right e p.1*planarSine left right e p.2 := by + change planarCos ((p.1+p.2) (left e)-(p.1+p.2) (right e))- + planarCos ((p.1-p.2) (left e)-(p.1-p.2) (right e))=_ + simp only [Pi.add_apply,Pi.sub_apply] + rw [show p.1 (left e)+p.2 (left e)-(p.1 (right e)+p.2 (right e))= + (p.1 (left e)-p.1 (right e))+(p.2 (left e)-p.2 (right e)) by abel, + show p.1 (left e)-p.2 (left e)-(p.1 (right e)-p.2 (right e))= + (p.1 (left e)-p.1 (right e))-(p.2 (left e)-p.2 (right e)) by abel] + exact planarCos_subtraction _ _ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PlanarGinibre.lean b/lean/OAI/Probability/ClassicalON/PlanarGinibre.lean new file mode 100644 index 0000000000000000000000000000000000000000..39e2b8adbab3cddb403e27edff13287a48726d7a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PlanarGinibre.lean @@ -0,0 +1,78 @@ +import OAI.Probability.ClassicalON.PositiveKernel + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def planarHamiltonian (left right : E → V) (b : E → ℝ) (θ : V → PlanarAngle) : ℝ := + ∑ e,b e*planarEnergy left right e θ + +omit [Fintype V] in +theorem continuous_planarHamiltonian (left right : E → V) (b : E → ℝ) : + Continuous (planarHamiltonian left right b) := by + exact continuous_finsetSum _ (fun e _ => continuous_const.mul (continuous_planarEnergy _ _ e)) + +def planarMean (left right : E → V) (b : E → ℝ) (f : (V → PlanarAngle) → ℝ) : ℝ := + exponentialMean planarReference (planarHamiltonian left right b) f + +omit [Fintype V] in +theorem planarHamiltonian_double (left right : E → V) (b : E → ℝ) + (p : (V → PlanarAngle)×(V → PlanarAngle)) : + planarHamiltonian left right b (torusDouble p).1+ + planarHamiltonian left right b (torusDouble p).2 = + ∑ e,(2*b e)*(planarEnergy left right e p.1*planarEnergy left right e p.2) := by + simp only [planarHamiltonian,← Finset.sum_add_distrib,← mul_add, + planarEnergy_double_sum] + apply Finset.sum_congr rfl; intro e _; ring + +theorem planar_edge_covariance_nonneg (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0≤b e) (e f : E) : + planarMean left right b (planarEnergy left right e)* + planarMean left right b (planarEnergy left right f) ≤ + planarMean left right b (fun θ => planarEnergy left right e θ*planarEnergy left right f θ) := by + classical + let T := planarEnergy left right + let S := planarSine left right + let H := planarHamiltonian left right b + have hT : ∀ g,Continuous (T g) := continuous_planarEnergy _ _ + have hS : ∀ g,Continuous (S g) := continuous_planarSine _ _ + have hH : Continuous H := continuous_planarHamiltonian _ _ _ + let F : ((V → PlanarAngle)×(V → PlanarAngle)) → ℝ := fun p => + Real.exp (H p.1)*Real.exp (H p.2)*(T e p.1-T e p.2)*(T f p.1-T f p.2) + have hF : Continuous F := by unfold F; fun_prop + apply covariance_nonneg_of_doubled planarReference hH.rexp + (fun θ => Real.exp_pos (H θ)) (hT e) (hT f) + change 0≤∫ p,F p ∂(planarReference (V := V)).prod planarReference + have hi : (∫ p,F (torusDouble p) ∂(planarReference (V := V)).prod planarReference)= + ∫ p,F p ∂(planarReference (V := V)).prod planarReference := by + have hm := integral_map (μ := (planarReference (V := V)).prod planarReference) + (torusDouble_preserves (V := V)).measurable.aemeasurable + hF.aestronglyMeasurable + rw [(torusDouble_preserves (V := V)).map_eq] at hm + exact hm.symm + rw [← hi] + have hp : (fun p => F (torusDouble p))=(fun p => + 4*((S e p.1*S f p.1)*(S e p.2*S f p.2)* + Real.exp (∑ g,(2*b g)*(T g p.1*T g p.2)))) := by + funext p + dsimp only [F,H,T,S] + rw [← Real.exp_add,planarHamiltonian_double, + planarEnergy_double_sub,planarEnergy_double_sub] + ring + rw [hp,integral_const_mul] + apply mul_nonneg (by norm_num) + exact exp_gram_integral_nonneg planarReference ((hS e).mul (hS f)) hT + (fun g => 2*b g) (fun g => mul_nonneg (by norm_num) (hb g)) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PlanarPositive.lean b/lean/OAI/Probability/ClassicalON/PlanarPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..95dd329b11ad1b27ec53ee1c178dcd69250eade9 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PlanarPositive.lean @@ -0,0 +1,58 @@ +import OAI.Probability.ClassicalON.PlanarGinibre + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +namespace ClassicalON + +theorem planar_antipode_exists : ∃ t : PlanarAngle,planarCharacter t= -1 := by + let h := AddCircle.homeomorphCircle (T := (1 : ℝ)) one_ne_zero + refine ⟨h.symm (-1),?_⟩ + change (AddCircle.toCircle (h.symm (-1)) : ℂ)= -1 + rw [← AddCircle.homeomorphCircle_apply one_ne_zero] + change (h (h.symm (-1)) : ℂ)= -1 + simp + +theorem planarCos_add_antipode {s : PlanarAngle} (hs : planarCharacter s= -1) (t : PlanarAngle) : + planarCos (s+t)= -planarCos t := by + simp [planarCos,planarCharacter_add,hs] + +variable {V : Type uV} {E : Type uE} [Fintype V] + +theorem planar_reference_mean_nonneg (left right : E → V) (e : E) : + 0≤∫ θ : V → PlanarAngle,planarEnergy left right e θ ∂planarReference := by + classical + by_cases h : left e=right e + · simp [planarEnergy,h,planarCos,planarCharacter] + obtain ⟨t,ht⟩ := planar_antipode_exists + let v : V → PlanarAngle := Function.update (fun _ => 0) (left e) t + have he (θ : V → PlanarAngle) : + planarEnergy left right e (v+θ)= -planarEnergy left right e θ := by + unfold planarEnergy + have hv : (v+θ) (left e)-(v+θ) (right e)=t+(θ (left e)-θ (right e)) := by + simp only [Pi.add_apply,v,Function.update_self,Function.update_of_ne (Ne.symm h),zero_add] + abel + rw [hv,planarCos_add_antipode ht] + have hh := integral_add_left_eq_self (μ := planarReference) (planarEnergy left right e) v + simp_rw [he] at hh + rw [integral_neg] at hh + linarith + +variable [Fintype E] + +theorem planar_edge_mean_nonneg (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) (e : E) : + 0≤planarMean left right b (planarEnergy left right e) := by + apply edgeMean_nonneg planarReference (planarEnergy left right) + (continuous_planarEnergy left right) + · exact planar_edge_covariance_nonneg left right + · exact planar_reference_mean_nonneg left right + · exact hb + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PoleCrossing.lean b/lean/OAI/Probability/ClassicalON/PoleCrossing.lean new file mode 100644 index 0000000000000000000000000000000000000000..28e640ffdf82dec9b24a4e8abcd13db438fdfe48 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PoleCrossing.lean @@ -0,0 +1,83 @@ +import OAI.Probability.ClassicalON.AnnulusPartition + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def crossingIndicator (left right : E → V) (I O : Set V) (η : E → Bool) : ℝ := + if bondCrossing left right I O η then 1 else 0 + +omit [Fintype V] [Fintype E] in +theorem crossingIndicator_nonneg (left right : E → V) (I O : Set V) (η : E → Bool) : + 0≤crossingIndicator left right I O η := by unfold crossingIndicator; split_ifs <;> positivity + +omit [Fintype V] [Fintype E] in +theorem crossingIndicator_monotone (left right : E → V) (I O : Set V) : + Monotone (crossingIndicator left right I O) := by + intro η ξ hη + have h : bondCrossing left right I O η → bondCrossing left right I O ξ := by + rintro ⟨x,hx,y,hy,hxy⟩ + exact ⟨x,hx,y,hy,bondConnected_mono left right x y hη hxy⟩ + unfold crossingIndicator + split_ifs <;> simp_all + +theorem pinnedBondNumerator_sub (μ : Measure Amplitude) [IsFiniteMeasure μ] + (left right : E → V) (b : E → ℝ) (B : Set V) (f g : (E → Bool) → ℝ) : + pinnedBondNumerator μ left right b B (fun η => f η-g η)= + pinnedBondNumerator μ left right b B f-pinnedBondNumerator μ left right b B g := by + unfold pinnedBondNumerator + simp only [mul_sub,Finset.sum_sub_distrib] + apply integral_sub + all_goals exact compact_integrable ((continuous_pinWeightedSum _ _ _ _ _).comp + ((continuous_glueAmplitude B).comp (continuous_const.prodMk continuous_id))) + +theorem pole_crossing_ratio (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (I O : Set V) (hIO : Disjoint I O) : + poleBondMean left right b (I∪O) (fun _ => true) (crossingIndicator left right I O)= + 1-(poleSystem left right b (I∪O) (fun v => layerSigns I v)).Z (fun _ => 1)/ + (poleSystem left right b (I∪O) (fun _ => true)).Z (fun _ => 1) := by + rw [poleBondMean_eq_pinnedBondMean,layer_Z _ _ _ _ _ hIO,positive_Z, + mul_div_mul_left _ _ (ne_of_gt (pinNormalization_pos (I∪O)))] + have he : (fun η : E → Bool => if bondCrossing left right I O η then (0:ℝ) else 1)= + (fun η => 1-crossingIndicator left right I O η) := by + funext η + unfold crossingIndicator + split_ifs <;> norm_num + rw [he,pinnedBondNumerator_sub,sub_div,div_self + (ne_of_gt (pinnedBondNumerator_one_pos sphericalAmplitudeLaw _ _ _ hb _))] + unfold pinnedBondMean + ring + +theorem freeBondMean_le_poleBondMean (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (B : Set V) (f : (E → Bool) → ℝ) (hf : ∀ η,0≤f η) (hm : Monotone f) : + freeBondMean left right b f≤poleBondMean left right b B (fun _ => true) f := by + rw [freeBondMean_eq_jointBondMean _ _ _ hb,poleBondMean_eq_pinnedBondMean] + exact jointBond_le_pinnedBond _ _ _ _ hb _ _ hf hm + +omit [Fintype V] [Fintype E] in +theorem rotate_pole (a : V → ℝ) (x : V) (h : a x=1) : + spinRotation (SpinSystem.potentialRotation a Real.pi x) (poleSpin true)=poleSpin false := by + apply Subtype.ext + change NormedSpace.exp ((Real.pi*a x) • axisC) (poleSpin true).val=(poleSpin false).val + rw [h,mul_one,exp_axisC_pi_apply] + ext i + fin_cases i <;> simp [poleSpin,cylindricalSpin,transverseAmplitude,signValue] + +omit [Fintype V] [Fintype E] in +theorem rotation_zero_potential (a : V → ℝ) (t : ℝ) (x : V) (h : a x=0) (s : Spin 3) : + spinRotation (SpinSystem.potentialRotation a t x) s=s := by + apply Subtype.ext + change NormedSpace.exp ((t*a x) • axisC) s.val=s.val + simp [h,zero_smul ℝ axisC] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PositiveKernel.lean b/lean/OAI/Probability/ClassicalON/PositiveKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..58d21d649fb5f26ceb7cc7de273dae3c628fd40e --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PositiveKernel.lean @@ -0,0 +1,31 @@ +import OAI.Probability.ClassicalON.PlanarAlgebra + +namespace OAI + +universe uE uX + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +theorem exp_gram_integral_nonneg {X : Type uX} {E : Type uE} [Fintype E] + [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] + [SecondCountableTopology X] (μ : Measure X) [IsFiniteMeasure μ] + {f : X → ℝ} {a : E → X → ℝ} (hf : Continuous f) (ha : ∀ e,Continuous (a e)) + (b : E → ℝ) (hb : ∀ e,0≤b e) : + 0≤∫ p : X×X,f p.1*f p.2*Real.exp (∑ e,b e*(a e p.1*a e p.2)) ∂μ.prod μ := by + apply integral_mul_sum_exp_nonneg (μ.prod μ) (by fun_prop) + (a := fun e p => a e p.1*a e p.2) (fun e => by fun_prop) b hb + intro k p + have he : (fun z : X×X => f z.1*f z.2*∏ i,a (p i) z.1*a (p i) z.2) = + (fun z : X×X => (f z.1*∏ i,a (p i) z.1)*(f z.2*∏ i,a (p i) z.2)) := by + funext z; rw [Finset.prod_mul_distrib]; ring + rw [he,integral_prod_mul (fun x => f x*∏ i,a (p i) x) (fun x => f x*∏ i,a (p i) x)] + exact mul_self_nonneg _ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/PotentialRotation.lean b/lean/OAI/Probability/ClassicalON/PotentialRotation.lean new file mode 100644 index 0000000000000000000000000000000000000000..881211c4da32905ae21162890a2e628434a130f2 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/PotentialRotation.lean @@ -0,0 +1,110 @@ +import OAI.Probability.ClassicalON.AxisRotation + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +namespace ClassicalON +namespace SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def potentialRotation (f : V → ℝ) (t : ℝ) (x : V) : + EuclideanSpace ℝ (Fin 3) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 3) := + rotationExp ((t*f x) • axisC) (skewAdjoint.smul_mem _ axisC_skew) + +def rotatePotential (S : SpinSystem 3 V E) (f : V → ℝ) (t : ℝ) : SpinSystem 3 V E := + S.rotatePins (potentialRotation f t) + +def potentialOperators (S : SpinSystem 3 V E) (f : V → ℝ) : E → SpinOperator 3 := + fun e => S.differential f e • axisC + +omit [Fintype V] [Fintype E] in +theorem gauge_potential_shift (S : SpinSystem 3 V E) (f : V → ℝ) (t u : ℝ) : + S.gauge (fun e => NormedSpace.exp (u • S.potentialOperators f e)) (potentialRotation f t) = + (fun e => NormedSpace.exp ((t+u) • S.potentialOperators f e)) := by + funext e + apply ContinuousLinearMap.ext + intro v + change (potentialRotation f t (S.left e)).symm + (NormedSpace.exp (u • S.potentialOperators f e) (potentialRotation f t (S.right e) v)) = _ + simp only [potentialRotation,rotationExp_symm_apply,rotationExp_apply,potentialOperators, + smul_smul,← neg_smul (t*f (S.left e)) axisC] + rw [← mul_apply_eq_comp,← mul_apply_eq_comp,← exp_smul_add,← exp_smul_add] + apply congrArg (fun r : ℝ => NormedSpace.exp (r • axisC) v) + simp only [differential] + ring + +theorem potential_shift_Z (S : SpinSystem 3 V E) (f : V → ℝ) (t u : ℝ) : + S.Z (fun e => NormedSpace.exp ((t+u) • S.potentialOperators f e)) = + (S.rotatePotential f t).Z (fun e => NormedSpace.exp (u • S.potentialOperators f e)) := by + rw [← S.gauge_potential_shift] + exact S.Z_gauge _ _ + +theorem potential_shift_first (S : SpinSystem 3 V E) (f : V → ℝ) (t u : ℝ) : + (∫ σ, S.firstWeight (S.potentialOperators f) (t+u) σ ∂S.reference) = + ∫ σ, (S.rotatePotential f t).firstWeight (S.potentialOperators f) u σ ∂(S.rotatePotential f t).reference := by + have h := (S.hasDerivAt_twistZ (S.potentialOperators f) (t+u)).comp u + ((hasDerivAt_id u).const_add t) + simp only [mul_one] at h + have he : (fun v => S.Z (fun e => NormedSpace.exp ((t+v) • S.potentialOperators f e))) = + (fun v => (S.rotatePotential f t).Z (fun e => NormedSpace.exp (v • S.potentialOperators f e))) := + funext fun v => S.potential_shift_Z f t v + change HasDerivAt (fun v => S.Z (fun e => NormedSpace.exp ((t+v) • S.potentialOperators f e))) _ u at h + rw [he] at h + exact h.unique ((S.rotatePotential f t).hasDerivAt_twistZ (S.potentialOperators f) u) + +theorem potential_shift_second (S : SpinSystem 3 V E) (f : V → ℝ) (t u : ℝ) : + (∫ σ, S.secondWeight (S.potentialOperators f) (t+u) σ ∂S.reference) = + ∫ σ, (S.rotatePotential f t).secondWeight (S.potentialOperators f) u σ ∂(S.rotatePotential f t).reference := by + have h := (S.hasDerivAt_firstVariation (S.potentialOperators f) (t+u)).comp u + ((hasDerivAt_id u).const_add t) + simp only [mul_one] at h + have he : (fun v => ∫ σ, S.firstWeight (S.potentialOperators f) (t+v) σ ∂S.reference) = + (fun v => ∫ σ, (S.rotatePotential f t).firstWeight (S.potentialOperators f) v σ ∂(S.rotatePotential f t).reference) := + funext fun v => S.potential_shift_first f t v + change HasDerivAt (fun v => ∫ σ, S.firstWeight (S.potentialOperators f) (t+v) σ ∂S.reference) _ u at h + rw [he] at h + exact h.unique ((S.rotatePotential f t).hasDerivAt_firstVariation (S.potentialOperators f) u) + +theorem potential_second_response (S : SpinSystem 3 V E) (f : V → ℝ) (t : ℝ) : + (∫ σ, S.secondWeight (S.potentialOperators f) t σ ∂S.reference) / + S.Z (fun e => NormedSpace.exp (t • S.potentialOperators f e)) = + (S.rotatePotential f t).secondAxisResponse (S.differential f) (S.differential f) := by + have hZ := S.potential_shift_Z f t 0 + have h2 := S.potential_shift_second f t 0 + simp only [add_zero,zero_smul ℝ (S.potentialOperators f _),NormedSpace.exp_zero] at hZ + simp only [add_zero] at h2 + rw [hZ,h2,(S.rotatePotential f t).secondAxisResponse_integral] + rfl + +omit [Fintype V] [Fintype E] in +theorem spinRotation_potential_periodic (f : V → ℝ) (x : V) + (h : f x=0 ∨ f x=1) (s : Spin 3) (t : ℝ) : + spinRotation (potentialRotation f (t+2*Real.pi) x) s = + spinRotation (potentialRotation f t x) s := by + apply Subtype.ext + simp only [spinRotation_val,potentialRotation,rotationExp_apply] + rcases h with h | h + · simp only [h,mul_zero] + · simp only [h,mul_one,exp_axisC_periodic t] + +omit [Fintype V] [Fintype E] in +theorem rotatePotential_periodic (S : SpinSystem 3 V E) (f : V → ℝ) + (hP : ∀ x s, S.pin x=some s → f x=0 ∨ f x=1) : + Function.Periodic (S.rotatePotential f) (2*Real.pi) := by + intro t + have hpin : (S.rotatePotential f (t+2*Real.pi)).pin = (S.rotatePotential f t).pin := by + funext x + apply Option.map_congr + intro s hs + exact spinRotation_potential_periodic f x (hP x s hs) s t + exact congrArg (fun p => SpinSystem.mk S.left S.right S.strength p) hpin + +end SpinSystem +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ProductFKG.lean b/lean/OAI/Probability/ClassicalON/ProductFKG.lean new file mode 100644 index 0000000000000000000000000000000000000000..65a1b5d57adf3abfa09208d7d97387abb32174e9 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ProductFKG.lean @@ -0,0 +1,98 @@ +import OAI.Probability.ClassicalON.WeightedTilt + +namespace OAI + +universe uX uY + +noncomputable section +open MeasureTheory +namespace ClassicalON + +def LogSupermodular {X : Type uX} [Lattice X] (w : X → ℝ) : Prop := + ∀ x y,w x*w y≤w (x⊓y)*w (x⊔y) + +def ContinuousFKG {X : Type uX} [Lattice X] [TopologicalSpace X] [MeasurableSpace X] + (μ : Measure X) : Prop := + ∀ w : X → ℝ,Continuous w → (∀ x,0 w (y,x)) := by + intro u v + simpa only [Prod.inf_def,Prod.sup_def,inf_idem,sup_idem] using h (y,u) (y,v) + +theorem logSupermodular_ratio_monotone {w : Y×X → ℝ} (h : LogSupermodular w) + (hp : ∀ p,0 w (t,x)/w (s,x)) := by + intro u v huv + have hh := h (t,u) (s,v) + simp only [Prod.inf_def,Prod.sup_def,inf_eq_right.mpr hst,inf_eq_left.mpr huv, + sup_eq_left.mpr hst,sup_eq_right.mpr huv] at hh + exact (div_le_div_iff₀ (hp (s,u)) (hp (s,v))).2 (by nlinarith) + +end Lattice + +section Product +variable {X : Type uX} {Y : Type uY} [Lattice X] [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] [SecondCountableTopology X] + [LinearOrder Y] [TopologicalSpace Y] [CompactSpace Y] + [MeasurableSpace Y] [BorelSpace Y] [SecondCountableTopology Y] + [FirstCountableTopology Y] [LocallyCompactSpace Y] + {μ : Measure X} {ν : Measure Y} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] + +omit [SecondCountableTopology X] [CompactSpace Y] [MeasurableSpace Y] + [BorelSpace Y] [SecondCountableTopology Y] [FirstCountableTopology Y] + [LocallyCompactSpace Y] in +theorem conditionalMean_monotone (hX : ContinuousFKG μ) {w f : Y×X → ℝ} + (hw : Continuous w) (hp : ∀ p,0 w (s,x)) := + hX _ (by fun_prop) (fun x => hp (s,x)) (logSupermodular_slice hLS s) + calc + conditionalMean μ w f s ≤ weightedMean μ (fun x => w (t,x)) (fun x => f (s,x)) := by + apply weightedMean_tilt_mono (by fun_prop) (by fun_prop) + (fun x => hp (s,x)) (fun x => hp (t,x)) hs (by fun_prop) (fun x => hfn (s,x)) + · exact fun u v huv => hfm ⟨le_rfl,huv⟩ + · exact logSupermodular_ratio_monotone hLS hp hst + _ ≤ conditionalMean μ w f t := by + apply weightedMean_mono (by fun_prop) (fun x => hp (t,x)) (by fun_prop) (by fun_prop) + exact fun x => hfm ⟨hst,le_rfl⟩ + +theorem continuousFKG_prod (hX : ContinuousFKG μ) : ContinuousFKG (ν.prod μ) := by + intro w hw hp hLS f g hf hg hfn hgn hfm hgm + let m := marginalWeight μ w + let F := conditionalMean μ w f + let H := conditionalMean μ w g + let J := conditionalMean μ w (fun p => f p*g p) + have hmc : Continuous m := marginalWeight_continuous μ hw + have hmp : ∀ y,0 < m y := marginalWeight_pos μ hw hp + have hFc : Continuous F := conditionalMean_continuous μ hw hf hp + have hHc : Continuous H := conditionalMean_continuous μ hw hg hp + have hJc : Continuous J := conditionalMean_continuous μ hw (hf.mul hg) hp + have hFn : ∀ y,0≤F y := fun y => weightedMean_nonneg (by fun_prop) + (fun x => hp (y,x)) (fun x => hfn (y,x)) + have hHn : ∀ y,0≤H y := fun y => weightedMean_nonneg (by fun_prop) + (fun x => hp (y,x)) (fun x => hgn (y,x)) + have hFm : Monotone F := conditionalMean_monotone hX hw hp hLS hf hfn hfm + have hHm : Monotone H := conditionalMean_monotone hX hw hp hLS hg hgn hgm + have hpoint : ∀ y,F y*H y≤J y := by + intro y + exact hX _ (show Continuous (fun x => w (y,x)) from by fun_prop) (fun x => hp (y,x)) + (logSupermodular_slice hLS y) _ _ (by fun_prop) (by fun_prop) + (fun x => hfn (y,x)) (fun x => hgn (y,x)) + (fun u v huv => hfm ⟨le_rfl,huv⟩) (fun u v huv => hgm ⟨le_rfl,huv⟩) + rw [weightedMean_prod μ ν hw hf hp,weightedMean_prod μ ν hw hg hp, + weightedMean_prod μ ν hw (show Continuous (fun p => f p*g p) from hf.mul hg) hp] + exact ((continuousAssociated_chain ν m hmc hmp) F H hFc hHc hFn hHn hFm hHm).trans + (weightedMean_mono hmc hmp (hFc.mul hHc) hJc hpoint) + +end Product +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ProductGrouping.lean b/lean/OAI/Probability/ClassicalON/ProductGrouping.lean new file mode 100644 index 0000000000000000000000000000000000000000..f66cd3bc2c290572d09955524069ff0ed02f15e4 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ProductGrouping.lean @@ -0,0 +1,97 @@ +import OAI.Probability.ClassicalON.PinnedBonds + +namespace OAI + +universe uA uC uD uK uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {K : Type uK} [Fintype V] [Fintype K] +variable (A : V → Type uA) (label : V → K) + +abbrev GroupedFamily := (k : K) → (v : {v // label v=k}) → A v.val + +def groupedEquiv : GroupedFamily A label ≃ ((v : V) → A v) where + toFun s v := s (label v) ⟨v,rfl⟩ + invFun s k v := s v.val + left_inv s := by + funext k v + rcases v with ⟨v,h⟩ + subst k + rfl + right_inv _ := rfl + +variable [∀ v,MeasurableSpace (A v)] + +def groupedMeasurableEquiv : GroupedFamily A label ≃ᵐ ((v : V) → A v) where + toEquiv := groupedEquiv A label + measurable_toFun := Measurable.of_eval (fun v => (measurable_pi_apply (⟨v,rfl⟩ : {w // label w=label v})).comp (measurable_pi_apply (label v))) + measurable_invFun := Measurable.of_eval (fun _ => Measurable.of_eval (fun v => measurable_pi_apply v.val)) + +theorem grouped_measurePreserving (μ : (v : V) → Measure (A v)) [∀ v,SigmaFinite (μ v)] : + MeasurePreserving (groupedMeasurableEquiv A label) + (Measure.pi (fun k : K => Measure.pi (fun v : {v // label v=k} => μ v.val))) (Measure.pi μ) := by + refine ⟨(groupedMeasurableEquiv A label).measurable,?_⟩ + symm + apply Measure.pi_eq + intro s hs + rw [MeasurableEquiv.map_apply] + have he : (groupedMeasurableEquiv A label) ⁻¹' (Set.pi Set.univ s)= + Set.pi Set.univ (fun k : K => Set.pi Set.univ (fun v : {v // label v=k} => s v.val)) := by + ext x + simp only [Set.mem_preimage,Set.mem_pi,Set.mem_univ,true_implies] + constructor + · intro h k v + have hv := h v.val + rcases v with ⟨v,hv'⟩ + subst k + exact hv + · intro h v + exact h (label v) ⟨v,rfl⟩ + rw [he,Measure.pi_pi] + simp_rw [Measure.pi_pi] + rw [← Fintype.prod_sigma (fun v : Σ k : K, {v // label v=k} => μ v.2.val (s v.2.val))] + exact (Equiv.sigmaFiberEquiv label).prod_comp (fun v => μ v (s v)) + +theorem integral_grouped_product (μ : (v : V) → Measure (A v)) [∀ v,SigmaFinite (μ v)] + (f : (k : K) → ((v : {v // label v=k}) → A v.val) → ℝ) : + (∫ s,(∏ k,f k (fun v => s v.val)) ∂Measure.pi μ)= + ∏ k,∫ s,f k s ∂Measure.pi (fun v : {v // label v=k} => μ v.val) := by + rw [← (grouped_measurePreserving A label μ).integral_comp'] + have he (s : GroupedFamily A label) : + (∏ k,f k (fun v => groupedMeasurableEquiv A label s v.val))=∏ k,f k (s k) := by + apply Finset.prod_congr rfl + intro k _ + congr 1 + funext v + rcases v with ⟨v,h⟩ + subst k + rfl + simp_rw [he] + exact integral_fintype_prod_eq_prod _ + +theorem sum_grouped_product {D : Type uD} [Fintype D] (elabel : D → K) + {C : D → Type uC} [∀ e,Fintype (C e)] + (f : (k : K) → ((e : {e // elabel e=k}) → C e.val) → ℝ) : + (∑ η : (e : D) → C e,∏ k,f k (fun e => η e.val))= + ∏ k,∑ η,f k η := by + rw [← (groupedEquiv C elabel).sum_comp] + have he (s : GroupedFamily C elabel) : + (∏ k,f k (fun e => groupedEquiv C elabel s e.val))=∏ k,f k (s k) := by + apply Finset.prod_congr rfl + intro k _ + congr 1 + funext e + rcases e with ⟨e,h⟩ + subst k + rfl + simp_rw [he] + exact (Fintype.prod_sum f).symm + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ProductMoments.lean b/lean/OAI/Probability/ClassicalON/ProductMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcc38bdad94533b4f7f9beb4e7d30526e3fb80fd --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ProductMoments.lean @@ -0,0 +1,48 @@ +import OAI.Probability.ClassicalON.MomentCone + +namespace OAI + +universe uI uV uX + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +variable {V : Type uV} {I : Type uI} {X : Type uX} [Fintype V] [DecidableEq V] + +def retainedIndices (v : V) (l : List (V×I)) : List I := + l.filterMap (fun p => if p.1=v then some p.2 else none) + +theorem site_grouping (a : I → X → ℝ) (l : List (V×I)) (x : V → X) : + (l.map (fun p => a p.2 (x p.1))).prod = + ∏ v,((retainedIndices v l).map (fun i => a i (x v))).prod := by + induction l with + | nil => simp [retainedIndices] + | cons p l ih => + have hv (v : V) : + ((retainedIndices v (p::l)).map (fun i => a i (x v))).prod = + (if p.1=v then a p.2 (x p.1) else 1)* + ((retainedIndices v l).map (fun i => a i (x v))).prod := by + by_cases h : p.1=v + · subst v; simp [retainedIndices] + · simp [retainedIndices,h] + simp only [List.map_cons,List.prod_cons,ih,hv,Finset.prod_mul_distrib] + congr 1 + simp + +theorem independent_moments_nonneg [MeasurableSpace X] (μ : Measure X) [SigmaFinite μ] + (a : I → X → ℝ) + (hm : ∀ l : List I,0≤∫ x,(l.map (fun i => a i x)).prod ∂μ) + (l : List (V×I)) : + 0≤∫ x : V → X,(l.map (fun p => a p.2 (x p.1))).prod ∂Measure.pi (fun _ => μ) := by + simp_rw [site_grouping a l] + rw [integral_fintype_prod_eq_prod (fun v x => + (List.map (fun i => a i x) (retainedIndices v l)).prod)] + exact Finset.prod_nonneg (fun v _ => hm (retainedIndices v l)) + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ProfileEstimates.lean b/lean/OAI/Probability/ClassicalON/ProfileEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..92ffb5b4e8af81d2cdfc7e692ab7b82c0ddc61fe --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ProfileEstimates.lean @@ -0,0 +1,135 @@ +import OAI.Probability.ClassicalON.SmoothBounds + +namespace OAI + +noncomputable section +open Set Function +open scoped ContDiff BigOperators +namespace ClassicalON + +def squareStep (m : Bool) (ε : ℝ) (z : ℝ × ℝ) : ℝ × ℝ := + if m then (z.1,z.2+ε) else (z.1+ε,z.2) + +@[simp] theorem squareStep_distance (m : Bool) (ε : ℝ) (z : ℝ × ℝ) : + ‖squareStep m ε z-z‖ = |ε| := by + cases m <;> simp [squareStep, Prod.norm_def, Real.norm_eq_abs, abs_nonneg] + +theorem profiles_uniform_bound : ∃ C : ℝ, 1 ≤ C ∧ + (∀ m s z, |squareProfile m s z| ≤ C) ∧ + (∀ m s z w, |squareProfile m s w-squareProfile m s z| ≤ C*‖w-z‖) := by + have he (m s : Bool) := smooth_compact_lipschitz_bound + (squareProfile_compact m s) (squareProfile_contDiff m s) + choose C hC hval hLip using he + let M : ℝ := 1+∑ m, ∑ s, C m s + have hsum : 0 ≤ ∑ m : Bool, ∑ s : Bool, C m s := + Finset.sum_nonneg fun m _ => Finset.sum_nonneg fun s _ => hC m s + have hCM (m s : Bool) : C m s ≤ M := by + have hs := Finset.single_le_sum (fun t _ => hC m t) (Finset.mem_univ s) + have hm : (∑ t : Bool, C m t) ≤ ∑ u : Bool, ∑ t : Bool, C u t := Finset.single_le_sum (fun t _ => Finset.sum_nonneg fun t' _ => hC t t') (Finset.mem_univ m) + dsimp only [M] + linarith + refine ⟨M, by dsimp only [M]; linarith, fun m s z => (hval m s z).trans (hCM m s), ?_⟩ + intro m s z w + exact (hLip m s z w).trans (mul_le_mul_of_nonneg_right (hCM m s) (norm_nonneg _)) + +theorem theta_trapezoid_bound : ∃ C : ℝ, 0 ≤ C ∧ ∀ x y : ℝ, + |thetaBump y-thetaBump x-(y-x)/2*(deriv thetaBump x+deriv thetaBump y)| ≤ + C*|y-x|^3 := by + have hd : ContDiff ℝ ∞ (deriv thetaBump) := + (contDiff_infty_iff_deriv.mp (thetaBump.contDiff : ContDiff ℝ ∞ thetaBump)).2 + have hdd : ContDiff ℝ ∞ (deriv (deriv thetaBump)) := (contDiff_infty_iff_deriv.mp hd).2 + obtain ⟨C,hC,_hval,hL⟩ := smooth_compact_lipschitz_bound + (thetaBump.hasCompactSupport.deriv.deriv) hdd + refine ⟨2*C, by positivity, fun x y => ?_⟩ + exact trapezoid_error_bound thetaBump (deriv thetaBump) (deriv (deriv thetaBump)) C hC + (fun t => ((thetaBump.contDiff : ContDiff ℝ ∞ thetaBump).differentiable (by simp) t).hasDerivAt) + (fun t => (hd.differentiable (by simp) t).hasDerivAt) hL x y + +theorem squareCutoff_near_gradient (m : Bool) (z w : ℝ × ℝ) + (h1 : |w.1-z.1| ≤ 1/16) (h2 : |w.2-z.2| ≤ 1/16) + (hg : squareGradient m z ≠ 0) : squareCutoff w = 1 := by + have ha1 : |w.1| ≤ |w.1-z.1|+|z.1| := by simpa only [sub_add_cancel] using (abs_add_le (w.1-z.1) z.1) + have ha2 : |w.2| ≤ |w.2-z.2|+|z.2| := by simpa only [sub_add_cancel] using (abs_add_le (w.2-z.2) z.2) + have hb1 : |z.1| ≤ |w.1-z.1|+|w.1| := by + simpa only [sub_add_cancel, abs_sub_comm] using (abs_add_le (z.1-w.1) w.1) + have hb2 : |z.2| ≤ |w.2-z.2|+|w.2| := by + simpa only [sub_add_cancel, abs_sub_comm] using (abs_add_le (z.2-w.2) w.2) + cases m + · have hd : deriv thetaBump z.1 ≠ 0 := by intro h; apply hg; simp [squareGradient, h] + have ht : thetaBump z.2 ≠ 0 := by intro h; apply hg; simp [squareGradient, h] + have hx : 4/3 < |z.1| ∧ |z.1| < 5/3 := ⟨ + lt_of_not_ge (fun h => hd (thetaBump_deriv_zero_inner h)), + lt_of_not_ge (fun h => hd (thetaBump_deriv_zero_outer h))⟩ + have hy : |z.2| < 5/3 := lt_of_not_ge (fun h => ht (thetaBump_zero h)) + simp [squareCutoff, outerBump_one (by linarith : |w.1| ≤ 7/4), + outerBump_one (by linarith : |w.2| ≤ 7/4), innerBump_zero (by linarith : 5/4 ≤ |w.1|)] + · have hd : deriv thetaBump z.2 ≠ 0 := by intro h; apply hg; simp [squareGradient, h] + have ht : thetaBump z.1 ≠ 0 := by intro h; apply hg; simp [squareGradient, h] + have hy : 4/3 < |z.2| ∧ |z.2| < 5/3 := ⟨ + lt_of_not_ge (fun h => hd (thetaBump_deriv_zero_inner h)), + lt_of_not_ge (fun h => hd (thetaBump_deriv_zero_outer h))⟩ + have hx : |z.1| < 5/3 := lt_of_not_ge (fun h => ht (thetaBump_zero h)) + simp [squareCutoff, outerBump_one (by linarith : |w.1| ≤ 7/4), + outerBump_one (by linarith : |w.2| ≤ 7/4), innerBump_zero (by linarith : 5/4 ≤ |w.2|)] + +theorem squareProfile_product_difference (m : Bool) (z w : ℝ × ℝ) + (h1 : |w.1-z.1| ≤ 1/16) (h2 : |w.2-z.2| ≤ 1/16) : + squareProfile m false z*squareProfile m false w- + squareProfile m true z*squareProfile m true w = + (squareGradient m z+squareGradient m w)/2 := by + have hzw : squareGradient m z*squareCutoff w = squareGradient m z := by + by_cases hg : squareGradient m z=0 + · simp [hg] + · rw [squareCutoff_near_gradient m z w h1 h2 hg, mul_one] + have hwz : squareCutoff z*squareGradient m w = squareGradient m w := by + by_cases hg : squareGradient m w=0 + · simp [hg] + · rw [squareCutoff_near_gradient m w z (by simpa only [abs_sub_comm] using h1) + (by simpa only [abs_sub_comm] using h2) hg, one_mul] + simp only [squareProfile, Bool.false_eq_true, ↓reduceIte] + nlinarith + +theorem squareTheta_step_error : ∃ C : ℝ, 0 ≤ C ∧ ∀ (m : Bool) (z : ℝ × ℝ) (ε : ℝ), + |ε| ≤ 1/16 → + |squareTheta (squareStep m ε z)-squareTheta z- + ε*(squareProfile m false z*squareProfile m false (squareStep m ε z)- + squareProfile m true z*squareProfile m true (squareStep m ε z))| ≤ C*|ε|^3 := by + obtain ⟨C,hC,hT⟩ := theta_trapezoid_bound + refine ⟨C,hC,?_⟩ + intro m z ε hε + have hp := squareProfile_product_difference m z (squareStep m ε z) + (by cases m + · simpa only [squareStep, Bool.false_eq_true, ↓reduceIte, add_sub_cancel_left] using hε + · simp [squareStep]) + (by cases m + · simp [squareStep] + · simpa only [squareStep, ↓reduceIte, add_sub_cancel_left] using hε) + rw [hp] + have hb (x : ℝ) : |thetaBump x| ≤ 1 := by rw [abs_of_nonneg thetaBump.nonneg]; exact thetaBump.le_one + cases m + · have h := hT z.1 (z.1+ε) + simp only [add_sub_cancel_left] at h + have he : squareTheta (squareStep false ε z)-squareTheta z- + ε*((squareGradient false z+squareGradient false (squareStep false ε z))/2) = + thetaBump z.2*(thetaBump (z.1+ε)-thetaBump z.1-ε/2*(deriv thetaBump z.1+deriv thetaBump (z.1+ε))) := by + simp only [squareTheta, squareStep, squareGradient, Bool.false_eq_true, ↓reduceIte] + ring + rw [he, abs_mul] + calc _ ≤ 1*(C*|ε|^3) := mul_le_mul (hb z.2) h (abs_nonneg _) (by norm_num) + _ = _ := one_mul _ + · have h := hT z.2 (z.2+ε) + simp only [add_sub_cancel_left] at h + have he : squareTheta (squareStep true ε z)-squareTheta z- + ε*((squareGradient true z+squareGradient true (squareStep true ε z))/2) = + thetaBump z.1*(thetaBump (z.2+ε)-thetaBump z.2-ε/2*(deriv thetaBump z.2+deriv thetaBump (z.2+ε))) := by + simp only [squareTheta, squareStep, squareGradient, ↓reduceIte] + ring + rw [he, abs_mul] + calc _ ≤ 1*(C*|ε|^3) := mul_le_mul (hb z.1) h (abs_nonneg _) (by norm_num) + _ = _ := one_mul _ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/RawBond.lean b/lean/OAI/Probability/ClassicalON/RawBond.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a4d8bbb6c7064653db287ee1d420f1b014d01cf --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/RawBond.lean @@ -0,0 +1,81 @@ +import OAI.Probability.ClassicalON.BondMoments + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ClassicalON + +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def amplitudeBondPrefactor (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : ℝ := + (2:ℝ)⁻¹^Fintype.card V*Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (r v:ℝ)) e)* + planarAmplitudePartition left right b r + +def amplitudeBondWeight (left right : E → V) (b : E → ℝ) (r : V → Amplitude) (η : E → Bool) : ℝ := + amplitudeBondPrefactor left right b r*bondWeight left right (amplitudeBondParam left right b r) η + +theorem amplitudeBondPrefactor_pos (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + 0 amplitudeBondWeight left right b r η) := by + apply (continuous_amplitudeBondPrefactor _ _ _).mul + unfold bondWeight bondProduct + apply Continuous.mul continuous_const + apply continuous_finsetProd + intro e _ + split + · exact continuous_amplitudeBondParam left right b e + · exact continuous_const + +theorem amplitudeBondWeight_nonneg (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (r : V → Amplitude) (η : E → Bool) : 0≤amplitudeBondWeight left right b r η := + mul_nonneg (amplitudeBondPrefactor_pos _ _ _ _).le + (bondWeight_nonneg _ _ (amplitudeBondParam_nonneg _ _ _ hb r) η) + +theorem amplitudeBondWeight_sum (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + (∑ η,amplitudeBondWeight left right b r η)=amplitudeDensity left right b r := by + unfold amplitudeBondWeight amplitudeDensity + rw [isingAmplitudePartition_bond_sum] + rw [← Finset.mul_sum] + unfold amplitudeBondPrefactor + ring + +theorem amplitudeDensity_bondConditionalMean (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0≤b e) (f : (V → Amplitude) → (E → Bool) → ℝ) (r : V → Amplitude) : + amplitudeDensity left right b r*bondConditionalMean left right b f r= + ∑ η,amplitudeBondWeight left right b r η*f r η := by + rw [← amplitudeBondWeight_sum left right b r] + unfold amplitudeBondWeight bondConditionalMean finiteMean + rw [← Finset.mul_sum] + simp_rw [mul_assoc] + rw [← Finset.mul_sum] + have hs := (bondWeight_sum_pos left right (amplitudeBondParam_nonneg left right b hb r)).ne' + field_simp + +theorem jointBondMean_raw (μ : Measure Amplitude) (left right : E → V) (b : E → ℝ) + (hb : ∀ e,0≤b e) (f : (V → Amplitude) → (E → Bool) → ℝ) : + jointBondMean μ left right b f= + (∫ r,∑ η,amplitudeBondWeight left right b r η*f r η ∂Measure.pi (fun _ : V => μ))/ + (∫ r,∑ η,amplitudeBondWeight left right b r η ∂Measure.pi (fun _ : V => μ)) := by + unfold jointBondMean weightedMean + simp_rw [amplitudeDensity_bondConditionalMean _ _ _ hb,amplitudeBondWeight_sum] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ReindexIntegral.lean b/lean/OAI/Probability/ClassicalON/ReindexIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..5054a50b3489bdfc9c40d4aff7e90ac8ebdecca2 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ReindexIntegral.lean @@ -0,0 +1,33 @@ +import OAI.Probability.ClassicalON.PinnedBlocks + +namespace OAI + +universe uA uV uW + +noncomputable section +open MeasureTheory +namespace ClassicalON +variable {V : Type uV} {W : Type uW} {A : Type uA} [Fintype V] [Fintype W] [MeasurableSpace A] + +theorem integral_pi_reindex (e : V ≃ W) (μ : W → Measure A) [∀ w,SigmaFinite (μ w)] + (f : (V → A) → ℝ) : + (∫ s : W → A,f (fun v => s (e v)) ∂Measure.pi μ)= + ∫ s : V → A,f s ∂Measure.pi (fun v => μ (e v)) := by + have h := (measurePreserving_piCongrLeft (fun v => μ (e v)) e.symm).integral_comp' f + have he (s : W → A) : MeasurableEquiv.piCongrLeft (fun _ : V => A) e.symm s=(fun v => s (e v)) := by + funext v + simp [MeasurableEquiv.coe_piCongrLeft,Equiv.piCongrLeft_apply] + simpa only [he,Equiv.apply_symm_apply] using h + +theorem weightedMean_pi_reindex (e : V ≃ W) (μ : W → Measure A) [∀ w,SigmaFinite (μ w)] + (w f : (V → A) → ℝ) : + weightedMean (Measure.pi μ) (fun s => w (fun v => s (e v))) (fun s => f (fun v => s (e v)))= + weightedMean (Measure.pi (fun v => μ (e v))) w f := by + unfold weightedMean + rw [integral_pi_reindex e μ (fun s => w s*f s),integral_pi_reindex e μ w] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ResponseTransfer.lean b/lean/OAI/Probability/ClassicalON/ResponseTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..5eeb7fa5de8163a61796c351db095fcb2bf1d31e --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ResponseTransfer.lean @@ -0,0 +1,157 @@ +import OAI.Probability.ClassicalON.SecondBound + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +omit [Fintype V] in +theorem complexEnergy_norm_le (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (M : SpinOperator 3) (hM : ‖M‖ ≤ 1) (u : E → ℂ) (σ : V → Spin 3) : + ‖S.complexEnergy M u σ‖ ≤ β*∑ e, ‖u e‖ := by + unfold complexEnergy MixedAlgebra.weighted + calc _ ≤ ∑ e, ‖(S.localCoefficient M σ e : ℂ)*u e‖ := norm_sum_le _ _ + _ ≤ ∑ e, β*‖u e‖ := by + apply Finset.sum_le_sum + intro e _ + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (S.abs_localCoefficient_le β hb M hM σ e) (norm_nonneg _) + _ = _ := (Finset.mul_sum _ _ _).symm + +omit [Fintype V] in +@[simp] theorem complexEnergy_sub (S : SpinSystem 3 V E) (M : SpinOperator 3) + (u v : E → ℂ) (σ : V → Spin 3) : + S.complexEnergy M (u-v) σ = S.complexEnergy M u σ - S.complexEnergy M v σ := by + simp only [complexEnergy, MixedAlgebra.weighted, Pi.sub_apply, mul_sub, Finset.sum_sub_distrib] + +def quadraticObservable (S : SpinSystem 3 V E) (u : E → ℂ) : C((V → Spin 3), ℝ) := + reObservable (S.currentObservable (axisC^2) (u*(fun e => conj (u e)))) + +omit [Fintype V] in +@[simp] theorem quadraticObservable_apply (S : SpinSystem 3 V E) (u : E → ℂ) (σ) : + S.quadraticObservable u σ = ∑ e, S.localCoefficient (axisC^2) σ e*‖u e‖^2 := + S.complexEnergy_normSq_re (axisC^2) u σ + +omit [Fintype V] in +theorem quadraticObservable_lower (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) (u : E → ℂ) (σ) : + -(β*∑ e, ‖u e‖^2) ≤ S.quadraticObservable u σ := by + rw [quadraticObservable_apply, Finset.mul_sum, ← Finset.sum_neg_distrib] + apply Finset.sum_le_sum + intro e _ + have h := (abs_le.mp (S.abs_localCoefficient_le β hb (axisC^2) + (norm_square_le_one axisC axisC_norm_le) σ e)).1 + nlinarith [sq_nonneg ‖u e‖] + +theorem complexSecondResponse_re_decomposition (S : SpinSystem 3 V E) (u : E → ℂ) : + (S.complexSecondResponse u (fun e => conj (u e))).re = + S.averageLinear (S.quadraticObservable u) + + S.averageLinear (normObservable (S.currentObservable axisC u) * + normObservable (S.currentObservable axisC u)) := by + unfold complexSecondResponse + rw [S.averageComplex_re, ← map_add] + congr 1 + ext σ + change (S.complexEnergy (axisC^2) (u*(fun e => conj (u e))) σ + + S.complexEnergy axisC u σ*S.complexEnergy axisC (fun e => conj (u e)) σ).re = _ + rw [complexEnergy_conj, Complex.add_re, Complex.mul_conj, Complex.ofReal_re, + Complex.normSq_eq_norm_sq] + change _ + ‖S.complexEnergy axisC u σ‖^2 = _ + ‖S.complexEnergy axisC u σ‖*‖S.complexEnergy axisC u σ‖ + exact congrArg ((S.complexEnergy (axisC^2) (u*(fun e => conj (u e))) σ).re + ·) (pow_two _) + +theorem current_moment_of_response_nonpos (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) (u : E → ℂ) + (hR : (S.complexSecondResponse u (fun e => conj (u e))).re ≤ 0) : + S.averageLinear (normObservable (S.currentObservable axisC u) * + normObservable (S.currentObservable axisC u)) ≤ β*∑ e, ‖u e‖^2 := by + rw [S.complexSecondResponse_re_decomposition] at hR + have h := S.averageLinear_mono (ContinuousMap.const _ (-(β*∑ e, ‖u e‖^2))) + (S.quadraticObservable u) (S.quadraticObservable_lower β hb u) + rw [S.averageLinear_const] at h + linarith + +theorem current_moment_difference (S : SpinSystem 3 V E) + (F G : C((V → Spin 3), ℂ)) (b v : ℝ) (hb : 0 ≤ b) + (hFG : ∀ σ, ‖F σ-G σ‖ ≤ b) + (hF : S.averageLinear (normObservable F * normObservable F) ≤ v) : + S.averageLinear (normObservable G * normObservable G) - + S.averageLinear (normObservable F * normObservable F) ≤ 2*b*Real.sqrt v+b^2 := by + have hpt (σ : V → Spin 3) : (normObservable G * normObservable G) σ ≤ + (normObservable F * normObservable F + (2*b) • normObservable F + ContinuousMap.const (V → Spin 3) (b^2)) σ := by + change ‖G σ‖*‖G σ‖ ≤ ‖F σ‖*‖F σ‖+2*b*‖F σ‖+b^2 + have hn : ‖G σ‖ ≤ ‖F σ‖+b := by + calc _ ≤ ‖F σ‖+‖G σ-F σ‖ := norm_le_insert' _ _ + _ ≤ _ := by rw [norm_sub_rev]; exact add_le_add le_rfl (hFG σ) + nlinarith [norm_nonneg (F σ), norm_nonneg (G σ)] + have hm := S.averageLinear_mono _ _ hpt + simp only [map_add, map_smul, smul_eq_mul, S.averageLinear_const] at hm + have hav := (S.averageLinear_norm_le_sqrt F).trans (Real.sqrt_le_sqrt hF) + have hmul := mul_le_mul_of_nonneg_left hav (mul_nonneg (by norm_num : (0:ℝ) ≤ 2) hb) + linarith + +theorem abs_norm_sq_sub_norm_sq (z w : ℂ) : + |‖z‖^2-‖w‖^2| ≤ ‖z-w‖*(‖z‖+‖w‖) := by + calc _ = |‖z‖-‖w‖| * (‖z‖+‖w‖) := by + rw [← abs_of_nonneg (add_nonneg (norm_nonneg z) (norm_nonneg w)), ← abs_mul] + congr 1 + ring + _ ≤ _ := mul_le_mul_of_nonneg_right (abs_norm_sub_norm_le z w) + (add_nonneg (norm_nonneg z) (norm_nonneg w)) + +omit [Fintype V] in +theorem quadraticObservable_difference (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) (u v : E → ℂ) (σ) : + S.quadraticObservable v σ - S.quadraticObservable u σ ≤ + β*∑ e, ‖u e-v e‖*(‖u e‖+‖v e‖) := by + simp only [quadraticObservable_apply, ← Finset.sum_sub_distrib, Finset.mul_sum, ← mul_sub] + apply Finset.sum_le_sum + intro e _ + calc _ ≤ |S.localCoefficient (axisC^2) σ e*(‖v e‖^2-‖u e‖^2)| := le_abs_self _ + _ = |S.localCoefficient (axisC^2) σ e| * |‖v e‖^2-‖u e‖^2| := abs_mul _ _ + _ ≤ β*(‖u e-v e‖*(‖u e‖+‖v e‖)) := by + apply mul_le_mul (S.abs_localCoefficient_le β hb (axisC^2) + (norm_square_le_one axisC axisC_norm_le) σ e) _ (abs_nonneg _) + (abs_nonneg _ |>.trans (S.abs_localCoefficient_le β hb (axisC^2) + (norm_square_le_one axisC axisC_norm_le) σ e)) + simpa only [abs_sub_comm] using abs_norm_sq_sub_norm_sq (u e) (v e) + +theorem response_transfer (S : SpinSystem 3 V E) (β a : ℝ) (hβ : 0 ≤ β) (ha : 0 ≤ a) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) (u v : E → ℂ) + (hr : -(S.complexSecondResponse v (fun e => conj (v e))).re ≤ a) : + -(S.complexSecondResponse u (fun e => conj (u e))).re ≤ a + + β*∑ e, ‖u e-v e‖*(‖u e‖+‖v e‖) + + 2*(β*∑ e, ‖u e-v e‖)*Real.sqrt (β*∑ e, ‖u e‖^2) + + (β*∑ e, ‖u e-v e‖)^2 := by + have hb' : 0 ≤ β*∑ e, ‖u e-v e‖ := mul_nonneg hβ (Finset.sum_nonneg fun _ _ => norm_nonneg _) + have hl : 0 ≤ β*∑ e, ‖u e-v e‖*(‖u e‖+‖v e‖) := mul_nonneg hβ + (Finset.sum_nonneg fun _ _ => mul_nonneg (norm_nonneg _) (add_nonneg (norm_nonneg _) (norm_nonneg _))) + by_cases hR : (S.complexSecondResponse u (fun e => conj (u e))).re ≤ 0 + · have hm := S.current_moment_difference (S.currentObservable axisC u) (S.currentObservable axisC v) + (β*∑ e, ‖u e-v e‖) (β*∑ e, ‖u e‖^2) hb' + (fun σ => by + change ‖S.complexEnergy axisC u σ-S.complexEnergy axisC v σ‖ ≤ _ + rw [← S.complexEnergy_sub] + exact S.complexEnergy_norm_le β hb axisC axisC_norm_le (u-v) σ) + (S.current_moment_of_response_nonpos β hb u hR) + have hq := S.averageLinear_mono (S.quadraticObservable v-S.quadraticObservable u) + (ContinuousMap.const _ (β*∑ e, ‖u e-v e‖*(‖u e‖+‖v e‖))) + (S.quadraticObservable_difference β hb u v) + rw [map_sub, S.averageLinear_const] at hq + rw [S.complexSecondResponse_re_decomposition] at hr ⊢ + linarith + · have he : 0 ≤ 2*(β*∑ e, ‖u e-v e‖)*Real.sqrt (β*∑ e, ‖u e‖^2) := + mul_nonneg (mul_nonneg (by norm_num) hb') (Real.sqrt_nonneg _) + linarith [sq_nonneg (β*∑ e, ‖u e-v e‖)] + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/RotationInequality.lean b/lean/OAI/Probability/ClassicalON/RotationInequality.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7a287d4de573df61601f82c66383aea885ec3a4 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/RotationInequality.lean @@ -0,0 +1,163 @@ +import OAI.Probability.ClassicalON.FamilyLower + +namespace OAI + +universe uE uI uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} {I : Type uI} [Fintype V] [Fintype E] [Fintype I] + +omit [Fintype I] in +def complexSecondBilin (S : SpinSystem 3 V E) : (E → ℂ) →ₗ[ℂ] (E → ℂ) →ₗ[ℂ] ℂ where + toFun u := { + toFun := S.complexSecondResponse u + map_add' := S.complexSecondResponse_add_right u + map_smul' := fun r v => by simpa only [smul_eq_mul, RingHom.id_apply] using S.complexSecondResponse_smul_right u v r } + map_add' u v := by ext w; exact S.complexSecondResponse_add_left u v w + map_smul' r u := by + ext v + change S.complexSecondResponse (r • u) v = r * S.complexSecondResponse u v + exact S.complexSecondResponse_smul_left u v r + +omit [Fintype I] in +@[simp] theorem complexSecondResponse_neg_neg (S : SpinSystem 3 V E) (u v : E → ℂ) : + S.complexSecondResponse (-u) (-v) = S.complexSecondResponse u v := by + change S.complexSecondBilin (-u) (-v) = S.complexSecondBilin u v + simp + +omit [Fintype V] [Fintype E] [Fintype I] in +theorem commutatorForm_antisymm (S : SpinSystem 3 V E) (f g : V → ℂ) : + S.commutatorForm g f = -S.commutatorForm f g := by + ext e + simp only [commutatorForm, complexCross, Pi.neg_apply, Pi.smul_apply, smul_eq_mul] + ring + +omit [Fintype V] [Fintype E] [Fintype I] in +theorem commutatorForm_conj (S : SpinSystem 3 V E) (f g : V → ℂ) : + S.commutatorForm (fun x => conj (f x)) (fun x => conj (g x)) = + (fun e => conj (S.commutatorForm f g e)) := by + ext e + simp only [commutatorForm, complexCross, Pi.smul_apply, smul_eq_mul, + map_mul, map_sub, map_div₀, map_one, map_ofNat] + +omit [Fintype I] in +theorem commutatorForm_bound_right (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (f g : V → ℂ) (hP : ∀ x s, S.pin x = some s → g x = 0) : + -(S.complexSecondResponse (S.commutatorForm f g) + (fun e => conj (S.commutatorForm f g e))).re ≤ + β*(‖g‖^2*∑ e, ‖S.differential f e‖^2) := by + have h := S.commutatorForm_bound_left β hβ hb g f hP + rw [S.commutatorForm_antisymm] at h + have hc : (fun e => conj ((-S.commutatorForm f g) e)) = + -(fun e => conj (S.commutatorForm f g e)) := by + ext e; simp only [Pi.neg_apply, map_neg] + rw [hc, S.complexSecondResponse_neg_neg] at h + exact h + +omit [Fintype I] in +theorem commutatorForm_bound (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (f g : V → ℂ) (hP : ∀ x s, S.pin x = some s → f x = 0) + (hQ : ∀ x s, S.pin x = some s → g x = 0) : + -(S.complexSecondResponse (S.commutatorForm f g) + (fun e => conj (S.commutatorForm f g e))).re ≤ + β*min (‖f‖^2*∑ e, ‖S.differential g e‖^2) (‖g‖^2*∑ e, ‖S.differential f e‖^2) := by + rw [mul_min_of_nonneg _ _ hβ] + exact le_min (S.commutatorForm_bound_left β hβ hb f g hP) + (S.commutatorForm_bound_right β hβ hb f g hQ) + +omit [Fintype I] in +theorem complexMixedResponse_commutator (S : SpinSystem 3 V E) (f g h k : V → ℂ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) + (hh : ∀ x s, S.pin x = some s → h x = 0) + (hk : ∀ x s, S.pin x = some s → k x = 0) : + S.complexMixedResponse (S.differential f) (S.differential g) + (S.differential h) (S.differential k) = + S.complexSecondResponse (S.commutatorForm f g) (S.commutatorForm h k) + + S.complexSecondResponse (S.commutatorForm f k) (S.commutatorForm h g) := by + have hw := S.complexMixedResponse_ward f g h k hf hg hh hk + simp only [commutatorForm, S.complexSecondResponse_smul_left, S.complexSecondResponse_smul_right] + linear_combination (1/4 : ℂ) * hw + +omit [Fintype I] in +theorem complexMixedResponse_paired (S : SpinSystem 3 V E) (f g : V → ℂ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) : + S.complexMixedResponse (S.differential f) (fun e => conj (S.differential f e)) + (fun e => conj (S.differential g e)) (S.differential g) = + S.complexSecondResponse (S.commutatorForm f (fun x => conj (f x))) + (fun e => conj (S.commutatorForm g (fun x => conj (g x)) e)) - + S.complexSecondResponse (S.commutatorForm f g) (fun e => conj (S.commutatorForm f g e)) := by + have hfc : ∀ x s, S.pin x = some s → conj (f x) = 0 := by + intro x s hs; rw [hf x s hs, map_zero] + have hgc : ∀ x s, S.pin x = some s → conj (g x) = 0 := by + intro x s hs; rw [hg x s hs, map_zero] + have h := S.complexMixedResponse_commutator f (fun x => conj (f x)) + (fun x => conj (g x)) g hf hfc hgc hg + have df (a : V → ℂ) : S.differential (fun x => conj (a x)) = + fun e => conj (S.differential a e) := by ext e; simp only [differential, map_sub] + have cc : S.commutatorForm (fun x => conj (g x)) g = + (fun e => conj (S.commutatorForm g (fun x => conj (g x)) e)) := by + simpa only [starRingEnd_self_apply] using S.commutatorForm_conj g (fun x => conj (g x)) + have cd : S.commutatorForm (fun x => conj (g x)) (fun x => conj (f x)) = + -(fun e => conj (S.commutatorForm f g e)) := by + rw [S.commutatorForm_antisymm, S.commutatorForm_conj] + rw [df f, df g, cc, cd] at h + change S.complexMixedResponse _ _ _ _ = S.complexSecondBilin _ _ + S.complexSecondBilin _ (-_) at h + simpa only [map_neg, sub_eq_add_neg, complexSecondBilin, LinearMap.coe_mk, AddHom.coe_mk] using h + +theorem rotation_family_bound (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (f : I → V → ℂ) (hP : ∀ i x s, S.pin x = some s → f i x = 0) : + -(S.complexSecondResponse (∑ i, S.commutatorForm (f i) (fun x => conj (f i x))) + (fun e => conj ((∑ i, S.commutatorForm (f i) (fun x => conj (f i x))) e))).re ≤ + (6*β^2+4*β*Real.sqrt β+β) * familyHSSquare (fun i => S.differential (f i)) + + β*∑ i, ∑ j, min (‖f i‖^2*∑ e, ‖S.differential (f j) e‖^2) + (‖f j‖^2*∑ e, ‖S.differential (f i) e‖^2) := by + let Q := ∑ i, S.commutatorForm (f i) (fun x => conj (f i x)) + have hsum : S.complexSecondResponse Q (fun e => conj (Q e)) = + ∑ i, ∑ j, S.complexSecondResponse (S.commutatorForm (f i) (fun x => conj (f i x))) + (fun e => conj (S.commutatorForm (f j) (fun x => conj (f j x)) e)) := by + have hq : (fun e => conj (Q e)) = ∑ i, (fun e => conj (S.commutatorForm (f i) (fun x => conj (f i x)) e)) := by + ext e; simp only [Q, Finset.sum_apply, map_sum] + rw [hq] + change S.complexSecondBilin (∑ i, _) (∑ j, _) = _ + simp only [map_sum, LinearMap.sum_apply] + rw [Finset.sum_comm] + rfl + have hid : (∑ i, ∑ j, S.complexMixedResponse (S.differential (f i)) + (fun e => conj (S.differential (f i) e)) (fun e => conj (S.differential (f j) e)) + (S.differential (f j))) = S.complexSecondResponse Q (fun e => conj (Q e)) - + ∑ i, ∑ j, S.complexSecondResponse (S.commutatorForm (f i) (f j)) + (fun e => conj (S.commutatorForm (f i) (f j) e)) := by + simp only [S.complexMixedResponse_paired _ _ (hP _) (hP _), + Finset.sum_sub_distrib, hsum] + have hl := S.fourth_family_lower β hβ hb f hP + simp only [map_sum] at hl + have hu : ∑ i, ∑ j, -(S.complexSecondResponse (S.commutatorForm (f i) (f j)) + (fun e => conj (S.commutatorForm (f i) (f j) e))).re ≤ + β*∑ i, ∑ j, min (‖f i‖^2*∑ e, ‖S.differential (f j) e‖^2) + (‖f j‖^2*∑ e, ‖S.differential (f i) e‖^2) := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + rw [Finset.mul_sum] + exact Finset.sum_le_sum fun j _ => + S.commutatorForm_bound β hβ hb (f i) (f j) (hP i) (hP j) + have hir := congrArg Complex.re hid + simp only [Complex.sub_re, complexMixedResponse] at hir + simp only [Complex.re_sum, Finset.sum_neg_distrib] at hir hl hu + change -(S.complexSecondResponse Q (fun e => conj (Q e))).re ≤ _ + linarith + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/RotationWork.lean b/lean/OAI/Probability/ClassicalON/RotationWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..d67d6de5dc356d671b9db31b73957a833770e240 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/RotationWork.lean @@ -0,0 +1,300 @@ +import OAI.Probability.ClassicalON.ModeBounds + +namespace OAI + +universe uE uK uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace +noncomputable section +open scoped BigOperators +namespace MixedAlgebra +variable {E : Type uE} {K : Type uK} [Fintype E] [CommRing K] + +def weighted (J u : E → K) : K := ∑ e, J e * u e + +@[simp] theorem weighted_add (J u v : E → K) : + weighted J (u+v) = weighted J u + weighted J v := by + simp [weighted, mul_add, Finset.sum_add_distrib] + +@[simp] theorem weighted_neg (J u : E → K) : weighted J (-u) = -weighted J u := by + simp [weighted] + +structure Coeffs (E : Type uE) (K : Type uK) where + a : E → K + b : E → K + aa : E → K + ab : E → K + bb : E → K + aab : E → K + abb : E → K + aabb : E → K + +def four (J : Coeffs E K) (u v w z : E → K) : K := + weighted J.a u * weighted J.b v * weighted J.a w * weighted J.b z + + weighted J.ab (u*v) * weighted J.a w * weighted J.b z + + weighted J.aa (u*w) * weighted J.b v * weighted J.b z + + weighted J.ab (u*z) * weighted J.b v * weighted J.a w + + weighted J.ab (v*w) * weighted J.a u * weighted J.b z + + weighted J.bb (v*z) * weighted J.a u * weighted J.a w + + weighted J.ab (w*z) * weighted J.a u * weighted J.b v + + weighted J.ab (u*v) * weighted J.ab (w*z) + + weighted J.aa (u*w) * weighted J.bb (v*z) + + weighted J.ab (u*z) * weighted J.ab (v*w) + + weighted J.aab (u*v*w) * weighted J.b z + + weighted J.abb (u*v*z) * weighted J.a w + + weighted J.aab (u*w*z) * weighted J.b v + + weighted J.abb (v*w*z) * weighted J.a u + + weighted J.aabb (u*v*w*z) + +theorem four_add_first (J : Coeffs E K) (u u' v w z : E → K) : + four J (u+u') v w z = four J u v w z + four J u' v w z := by + simp only [four, add_mul, weighted_add] + ring + +theorem four_add_second (J : Coeffs E K) (u v v' w z : E → K) : + four J u (v+v') w z = four J u v w z + four J u v' w z := by + simp only [four, add_mul, mul_add, weighted_add] + ring + +theorem four_swap_first_third (J : Coeffs E K) (u v w z : E → K) : + four J u v w z = four J w v u z := by + unfold four + simp only [mul_comm, mul_left_comm, mul_assoc] + ring + +theorem four_swap_second_fourth (J : Coeffs E K) (u v w z : E → K) : + four J u v w z = four J u z w v := by + unfold four + simp only [mul_comm, mul_left_comm, mul_assoc] + ring + +end MixedAlgebra + +namespace MixedAlgebra +variable {E : Type uE} {K : Type uK} [Fintype E] [CommRing K] + +theorem four_add_third (J : Coeffs E K) (u v w w' z : E → K) : + four J u v (w+w') z = four J u v w z + four J u v w' z := by + rw [four_swap_first_third, four_add_first, four_swap_first_third J w, + four_swap_first_third J w'] + +theorem four_add_fourth (J : Coeffs E K) (u v w z z' : E → K) : + four J u v w (z+z') = four J u v w z + four J u v w z' := by + rw [four_swap_second_fourth, four_add_second, four_swap_second_fourth J u z, + four_swap_second_fourth J u z'] + +theorem four_polarize_a (J : Coeffs E K) (u w v : E → K) : + four J (u+w) v (u+w) v = four J u v u v + 2 * four J u v w v + four J w v w v := by + rw [four_add_first, four_add_third, four_add_third, four_swap_first_third J w v u] + ring + +theorem four_polarize_b (J : Coeffs E K) (u w v z : E → K) : + four J u (v+z) w (v+z) = four J u v w v + 2 * four J u v w z + four J u z w z := by + rw [four_add_second, four_add_fourth, four_add_fourth, four_swap_second_fourth J u z w v] + ring + +end MixedAlgebra + +namespace MixedAlgebra +variable {E : Type uE} {K : Type uK} [Fintype E] [CommRing K] + +theorem four_diagonal (J : Coeffs E K) (u v : E → K) : + four J u v u v = + (weighted J.a u)^2 * (weighted J.b v)^2 + + weighted J.aa (u*u) * (weighted J.b v)^2 + + weighted J.bb (v*v) * (weighted J.a u)^2 + + 4 * weighted J.ab (u*v) * weighted J.a u * weighted J.b v + + weighted J.aa (u*u) * weighted J.bb (v*v) + + 2 * (weighted J.ab (u*v))^2 + + 2 * weighted J.aab (u*u*v) * weighted J.b v + + 2 * weighted J.abb (u*v*v) * weighted J.a u + + weighted J.aabb (u*u*v*v) := by + simp only [four, mul_comm, mul_left_comm] + ring + +end MixedAlgebra + +def bell4 (x y z w : ℝ) : ℝ := w+4*x*z+3*y^2+6*x^2*y+x^4 + +theorem bell4_even (a b aa ab bb aaa aab abb bbb p q aaaa aabb bbbb : ℝ) + (h : p+q = 2*aaaa+12*aabb+2*bbbb) : + bell4 (a+b) (aa+2*ab+bb) (aaa+3*aab+3*abb+bbb) p + + bell4 (a-b) (aa-2*ab+bb) (aaa-3*aab+3*abb-bbb) q - + 2*bell4 a aa aaa aaaa - 2*bell4 b bb bbb bbbb = + 12*(a^2*b^2+aa*b^2+bb*a^2+4*ab*a*b+aa*bb+2*ab^2+ + 2*aab*b+2*abb*a+aabb) := by + unfold bell4 + nlinarith only [h] + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem fourthResponse_plane_even (S : SpinSystem 3 V E) (f g : V → ℝ) + (hf : ∀ x s, S.pin x = some s → f x = 0) + (hg : ∀ x s, S.pin x = some s → g x = 0) : + S.fourthResponse (S.planarGradient f g) + + S.fourthResponse (S.planarGradient f (-g)) = + 6 * S.secondAxisResponse (S.crossForm f g) (S.crossForm f g) := by + have hsk (f g : V → ℝ) (x : V) : + planeOperator (f x) (g x) ∈ skewAdjoint (SpinOperator 3) := by + rw [planeOperator_eq] + exact (skewAdjoint _).add_mem (skewAdjoint.smul_mem _ axisA_skew) + (skewAdjoint.smul_mem _ axisB_skew) + have hp : ∀ x s, S.pin x = some s → planeOperator (f x) (g x) = 0 := by + intro x s hs + rw [hf x s hs, hg x s hs, planeOperator_eq] + simp only [zero_smul ℝ axisA, zero_smul ℝ axisB, add_zero] + have hm : ∀ x s, S.pin x = some s → planeOperator (f x) ((-g) x) = 0 := by + intro x s hs + rw [Pi.neg_apply, hg x s hs, neg_zero, hf x s hs, planeOperator_eq] + simp only [zero_smul ℝ axisA, zero_smul ℝ axisB, add_zero] + change S.fourthResponse (fun e => planeOperator (f (S.right e)) (g (S.right e)) - + planeOperator (f (S.left e)) (g (S.left e))) + S.fourthResponse (fun e => + planeOperator (f (S.right e)) ((-g) (S.right e)) - + planeOperator (f (S.left e)) ((-g) (S.left e))) = _ + rw [S.fourthResponse_gauge _ (hsk f g) hp, + S.fourthResponse_gauge _ (hsk f (-g)) hm] + let w := S.crossForm f g + have he (σ : V → Spin 3) : + S.gaugeEnergy (fun x => planeOperator (f x) (g x)) 4 0 σ + + S.gaugeEnergy (fun x => planeOperator (f x) ((-g) x)) 4 0 σ = + S.energy (fun e => (6*(w e)^2) • axisC^2) σ := by + rw [gaugeEnergy, gaugeEnergy, ← S.energy_add] + apply congrArg (fun K => S.energy K σ) + funext e + have ht := gaugeJet_plane_four_even (f (S.left e)) (g (S.left e)) + (f (S.right e)) (g (S.right e)) + dsimp only [Pi.add_apply, Pi.neg_apply, w, crossForm] + with_reducible exact ht + have hcm : (fun e => + planeOperator (f (S.left e)) ((-g) (S.left e)) * + planeOperator (f (S.right e)) ((-g) (S.right e)) - + planeOperator (f (S.right e)) ((-g) (S.right e)) * + planeOperator (f (S.left e)) ((-g) (S.left e))) = -(fun e => w e • axisC) := by + funext e + rw [planeOperator_commutator] + change (f (S.left e) * (-g) (S.right e) - (-g) (S.left e) * f (S.right e)) • axisC = -(w e • axisC) + rw [← neg_smul (w e) axisC] + congr 1 + dsimp only [w, crossForm, Pi.neg_apply] + ring + have hcp : (fun e => + planeOperator (f (S.left e)) (g (S.left e)) * + planeOperator (f (S.right e)) (g (S.right e)) - + planeOperator (f (S.right e)) (g (S.right e)) * + planeOperator (f (S.left e)) (g (S.left e))) = (fun e => w e • axisC) := by + funext e + exact planeOperator_commutator _ _ _ _ + rw [hcp, hcm] + simp only [S.energy_neg, neg_sq] + have hc (F : V → SpinOperator 3) : Continuous (fun σ => + S.gaugeEnergy F 4 0 σ + 3 * (S.energy (fun e => w e • axisC) σ)^2) := + ((S.continuous_gaugeEnergy F 4).comp (continuous_const.prodMk continuous_id)).add + (continuous_const.mul ((S.continuous_energy _).pow 2)) + rw [← S.average_add (hc _) (hc _)] + have hpoint : (fun σ => + (S.gaugeEnergy (fun x => planeOperator (f x) (g x)) 4 0 σ + + 3 * (S.energy (fun e => w e • axisC) σ)^2) + + (S.gaugeEnergy (fun x => planeOperator (f x) ((-g) x)) 4 0 σ + + 3 * (S.energy (fun e => w e • axisC) σ)^2)) = + (fun σ => 6 * (S.energy (fun e => (w e*w e) • axisC^2) σ + + S.energy (fun e => w e • axisC) σ * S.energy (fun e => w e • axisC) σ)) := by + funext σ + have ht := he σ + have hsc : (fun e => (6*(w e)^2) • axisC^2) = + (6 : ℝ) • (fun e => (w e*w e) • axisC^2) := by + funext e + simp only [Pi.smul_apply, smul_smul, pow_two] + rw [hsc, S.energy_smul] at ht + nlinarith + change S.average (fun σ => + (S.gaugeEnergy (fun x => planeOperator (f x) (g x)) 4 0 σ + + 3 * (S.energy (fun e => w e • axisC) σ)^2) + + (S.gaugeEnergy (fun x => planeOperator (f x) ((-g) x)) 4 0 σ + + 3 * (S.energy (fun e => w e • axisC) σ)^2)) = _ + rw [hpoint, S.average_mul_const] + rfl + +variable {n : ℕ} + +theorem fourthResponse_axisGradient [NeZero n] (S : SpinSystem n V E) + (g : SpinOperator n) (hg : g ∈ skewAdjoint (SpinOperator n)) (f : V → ℝ) + (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.fourthResponse (S.axisGradient f g) = 0 := by + let A := S.axisGradient f g + have hZ : (fun t => S.Z (fun e => NormedSpace.exp (t • A e))) = + (fun _ : ℝ => S.Z (fun _ => 1)) := funext (S.Z_gradient_line g hg f hP) + have hfirst : (fun t => ∫ σ, S.firstWeight A t σ ∂S.reference) = (fun _ : ℝ => 0) := by + funext t + have h := S.hasDerivAt_twistZ A t + rw [hZ] at h + exact h.unique (hasDerivAt_const t _) + have hsecond : (fun t => ∫ σ, S.secondWeight A t σ ∂S.reference) = (fun _ : ℝ => 0) := by + funext t + have h := S.hasDerivAt_firstVariation A t + rw [hfirst] at h + exact h.unique (hasDerivAt_const t 0) + have hthird : (fun t => ∫ σ, S.thirdWeight A t σ ∂S.reference) = (fun _ : ℝ => 0) := by + funext t + have h := S.hasDerivAt_secondVariation A t + rw [hsecond] at h + exact h.unique (hasDerivAt_const t 0) + have hfourth : (∫ σ, S.fourthWeight A 0 σ ∂S.reference) = 0 := by + have h := S.hasDerivAt_thirdVariation A 0 + rw [hthird] at h + exact h.unique (hasDerivAt_const 0 0) + rw [S.fourthResponse_integral, hfourth, zero_div] + +def localCoefficient (S : SpinSystem n V E) (M : SpinOperator n) + (σ : V → Spin n) (e : E) : ℝ := + S.strength e * ⟪(σ (S.left e)).val, M (σ (S.right e)).val⟫_ℝ + +omit [Fintype V] in +theorem energy_weighted (S : SpinSystem n V E) (M : SpinOperator n) + (u : E → ℝ) (σ : V → Spin n) : + S.energy (fun e => u e • M) σ = MixedAlgebra.weighted (S.localCoefficient M σ) u := by + unfold energy MixedAlgebra.weighted localCoefficient + apply Finset.sum_congr rfl + intro e _ + simp only [smul_apply, real_inner_smul_right] + ring + +def mixedCoefficients (S : SpinSystem 3 V E) (σ : V → Spin 3) : MixedAlgebra.Coeffs E ℝ where + a := S.localCoefficient axisA σ + b := S.localCoefficient axisB σ + aa := S.localCoefficient (axisA^2) σ + ab := S.localCoefficient mixedAB σ + bb := S.localCoefficient (axisB^2) σ + aab := S.localCoefficient mixedAAB σ + abb := S.localCoefficient mixedABB σ + aabb := S.localCoefficient mixedAABB σ + +omit [Fintype V] in +def differential (S : SpinSystem n V E) {K : Type uK} [Sub K] (f : V → K) : E → K := + fun e => f (S.right e) - f (S.left e) + +omit [Fintype V] [Fintype E] in +theorem planarGradient_eq (S : SpinSystem 3 V E) (f g : V → ℝ) : + S.planarGradient f g = fun e => planeOperator (S.differential f e) (S.differential g e) := by + funext e + simp only [planarGradient, planeOperator_eq, differential] + module + +omit [Fintype V] in +theorem planeEnergy_one (S : SpinSystem 3 V E) (u v : E → ℝ) (σ : V → Spin 3) : + S.energy (fun e => planeOperator (u e) (v e)) σ = + MixedAlgebra.weighted (S.mixedCoefficients σ).a u + + MixedAlgebra.weighted (S.mixedCoefficients σ).b v := by + simp only [planeOperator_eq] + change S.energy ((fun e => u e • axisA) + (fun e => v e • axisB)) σ = _ + rw [S.energy_add, S.energy_weighted, S.energy_weighted] + rfl + +end ClassicalON.SpinSystem + +end +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SecondBound.lean b/lean/OAI/Probability/ClassicalON/SecondBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b5de1d42a63cf36596dc3befeb5108399154188 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SecondBound.lean @@ -0,0 +1,110 @@ +import OAI.Probability.ClassicalON.SecondGauge + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +omit [Fintype V] in +theorem complexEnergy_normSq_re (S : SpinSystem 3 V E) (M : SpinOperator 3) + (u : E → ℂ) (σ : V → Spin 3) : + (S.complexEnergy M (fun e => u e * conj (u e)) σ).re = + ∑ e, S.localCoefficient M σ e * ‖u e‖^2 := by + simp [complexEnergy, MixedAlgebra.weighted, Complex.mul_conj, Complex.normSq_eq_norm_sq, -Complex.ofReal_pow] + +theorem complexSecondResponse_upper (S : SpinSystem 3 V E) (β : ℝ) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) (u : E → ℂ) : + -(S.complexSecondResponse u (fun e => conj (u e))).re ≤ β*∑ e, ‖u e‖^2 := by + unfold complexSecondResponse + rw [S.averageComplex_re] + have h (σ : V → Spin 3) : + -(β*∑ e, ‖u e‖^2) ≤ + reObservable (S.complexSecondObservable u (fun e => conj (u e))) σ := by + change _ ≤ (S.complexEnergy (axisC^2) (u*(fun e => conj (u e))) σ + + S.complexEnergy axisC u σ * S.complexEnergy axisC (fun e => conj (u e)) σ).re + rw [complexEnergy_conj, Complex.mul_conj, Complex.add_re, Complex.ofReal_re] + have hc := S.complexEnergy_normSq_re (axisC^2) u σ + change (S.complexEnergy (axisC^2) (u*(fun e => conj (u e))) σ).re = _ at hc + rw [hc] + have he : -(β*∑ e, ‖u e‖^2) ≤ ∑ e, S.localCoefficient (axisC^2) σ e*‖u e‖^2 := by + rw [Finset.mul_sum, ← Finset.sum_neg_distrib] + apply Finset.sum_le_sum + intro e _ + have hb' := (abs_le.mp (S.abs_localCoefficient_le β hb (axisC^2) + (norm_square_le_one axisC axisC_norm_le) σ e)).1 + nlinarith [sq_nonneg ‖u e‖] + exact he.trans (le_add_of_nonneg_right (Complex.normSq_nonneg _)) + have hm := S.averageLinear_mono (ContinuousMap.const _ (-(β*∑ e, ‖u e‖^2))) + (reObservable (S.complexSecondObservable u (fun e => conj (u e)))) h + rw [S.averageLinear_const] at hm + linarith + +omit [Fintype V] [Fintype E] in + +def commutatorForm (S : SpinSystem 3 V E) (f g : V → ℂ) : E → ℂ := + (1/2 : ℂ) • S.complexCross f g + +omit [Fintype V] [Fintype E] in +theorem commutatorForm_adjust (S : SpinSystem 3 V E) (f g : V → ℂ) : + S.commutatorForm f g + S.differential ((1/2 : ℂ) • (f*g)) = + fun e => ((f (S.left e)+f (S.right e))/2) * S.differential g e := by + ext e + simp only [commutatorForm, complexCross, differential, Pi.add_apply, Pi.mul_apply, + Pi.smul_apply, smul_eq_mul] + ring + +omit [Fintype E] in +theorem commutatorForm_adjust_norm (S : SpinSystem 3 V E) (f g : V → ℂ) (e : E) : + ‖((f (S.left e)+f (S.right e))/2) * S.differential g e‖ ≤ + ‖f‖ * ‖S.differential g e‖ := by + rw [norm_mul, norm_div] + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + norm_num + have h := norm_add_le (f (S.left e)) (f (S.right e)) + have hx := norm_le_pi_norm f (S.left e) + have hy := norm_le_pi_norm f (S.right e) + linarith + +theorem commutatorForm_bound_left (S : SpinSystem 3 V E) (β : ℝ) (hβ : 0 ≤ β) + (hb : ∀ e, 0 ≤ S.strength e ∧ S.strength e ≤ β) + (f g : V → ℂ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + -(S.complexSecondResponse (S.commutatorForm f g) + (fun e => conj (S.commutatorForm f g e))).re ≤ + β*(‖f‖^2*∑ e, ‖S.differential g e‖^2) := by + let F : V → ℂ := (1/2 : ℂ) • (f*g) + have hp (x) (s) (hs : S.pin x = some s) : F x = 0 := by + simp only [F, Pi.smul_apply, Pi.mul_apply, hP x s hs, zero_mul, smul_zero] + have hq (x) (s) (hs : S.pin x = some s) : conj (F x) = 0 := by rw [hp x s hs, map_zero] + have hd : S.differential (fun x => conj (F x)) = fun e => conj (S.differential F e) := by + ext e + simp only [differential, map_sub] + have hid := S.complexSecondResponse_add_gradients (S.commutatorForm f g) + (fun e => conj (S.commutatorForm f g e)) F (fun x => conj (F x)) hp hq + rw [hd] at hid + have hc : ((fun e => conj (S.commutatorForm f g e)) + (fun e => conj (S.differential F e))) = + (fun e => conj ((S.commutatorForm f g + S.differential F) e)) := by + ext e + simp only [Pi.add_apply, map_add] + rw [hc] at hid + rw [← hid] + apply (S.complexSecondResponse_upper β hb _).trans + apply mul_le_mul_of_nonneg_left _ hβ + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro e _ + change ‖(S.commutatorForm f g + S.differential ((1/2 : ℂ) • (f*g))) e‖^2 ≤ _ + rw [S.commutatorForm_adjust] + have h := S.commutatorForm_adjust_norm f g e + exact (pow_le_pow_left₀ (norm_nonneg _) h 2).trans_eq (mul_pow _ _ _) + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SecondGauge.lean b/lean/OAI/Probability/ClassicalON/SecondGauge.lean new file mode 100644 index 0000000000000000000000000000000000000000..f85d75908695ef583043d8e232f27bd5cb6d682d --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SecondGauge.lean @@ -0,0 +1,137 @@ +import OAI.Probability.ClassicalON.ModeCommutator + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace ComplexConjugate + +namespace ClassicalON.SpinSystem +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +theorem secondAxisResponse_integral (S : SpinSystem 3 V E) (u : E → ℝ) : + S.secondAxisResponse u u = + (∫ σ, S.secondWeight (fun e => u e • axisC) 0 σ ∂S.reference) / S.Z (fun _ => 1) := by + unfold secondAxisResponse average + congr 1 + apply integral_congr_ae (Filter.Eventually.of_forall _) + intro σ + have hz (e : E) : (0 : ℝ) • (u e • axisC) = 0 := zero_smul ℝ (u e • axisC) + simp only [secondWeight, twistEnergy, hz, NormedSpace.exp_zero, one_mul, + pow_zero, pow_one] + have hp (e : E) : (u e • axisC)^2 = (u e*u e) • axisC^2 := by + rw [operator_smul_pow, sq] + simp only [hp, pow_two] + ring + +theorem Z_axis_add_gradient (S : SpinSystem 3 V E) (u : E → ℝ) (f : V → ℝ) + (hP : ∀ x s, S.pin x = some s → f x = 0) (t : ℝ) : + S.Z (fun e => NormedSpace.exp (t • ((u+S.differential f) e • axisC))) = + S.Z (fun e => NormedSpace.exp (t • (u e • axisC))) := by + have hp (x) (s) (hs : S.pin x = some s) : t*f x = 0 := by rw [hP x s hs, mul_zero] + have h := S.W_add_gradient axisC axisC_skew (fun e => t*u e) (fun x => t*f x) hp + unfold W at h + have ha : (fun e => (t*u e + t*f (S.right e) - t*f (S.left e)) • axisC) = + (fun e => t • ((u+S.differential f) e • axisC)) := by + funext e + simp only [Pi.add_apply, differential, smul_smul] + congr 1 + ring + rw [ha] at h + simpa only [← smul_smul] using (div_left_inj' (S.Z_pos _).ne').mp h + +theorem secondAxisResponse_gradient_diag (S : SpinSystem 3 V E) (u : E → ℝ) + (f : V → ℝ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.secondAxisResponse (u+S.differential f) (u+S.differential f) = + S.secondAxisResponse u u := by + let A : E → SpinOperator 3 := fun e => (u+S.differential f) e • axisC + let B : E → SpinOperator 3 := fun e => u e • axisC + have hZ : (fun t => S.Z (fun e => NormedSpace.exp (t • A e))) = + (fun t => S.Z (fun e => NormedSpace.exp (t • B e))) := + funext (S.Z_axis_add_gradient u f hP) + have hfirst : (fun t => ∫ σ, S.firstWeight A t σ ∂S.reference) = + (fun t => ∫ σ, S.firstWeight B t σ ∂S.reference) := by + funext t + have h := S.hasDerivAt_twistZ A t + rw [hZ] at h + exact h.unique (S.hasDerivAt_twistZ B t) + have hsecond : (∫ σ, S.secondWeight A 0 σ ∂S.reference) = + (∫ σ, S.secondWeight B 0 σ ∂S.reference) := by + have h := S.hasDerivAt_firstVariation A 0 + rw [hfirst] at h + exact h.unique (S.hasDerivAt_firstVariation B 0) + rw [S.secondAxisResponse_integral, S.secondAxisResponse_integral] + exact congrArg (fun q => q / S.Z (fun _ => 1)) hsecond + +theorem secondAxisResponse_gradient_right (S : SpinSystem 3 V E) (u : E → ℝ) + (f : V → ℝ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.secondAxisResponse u (S.differential f) = 0 := by + have h := S.secondAxisResponse_gradient_diag u f hP + have hz := S.secondAxisResponse_gradient_diag 0 f hP + have he (v : E → ℝ) : S.secondAxisResponse 0 v = 0 := by + unfold secondAxisResponse + have h0 (σ : V → Spin 3) : S.energy (fun _ => (0 : SpinOperator 3)) σ = 0 := + S.energy_zero σ + simp only [Pi.zero_apply, zero_mul, zero_smul ℝ (axisC^2), zero_smul ℝ axisC, h0, zero_add] + exact S.average_const 0 + simp only [zero_add, he] at hz + rw [S.secondAxisResponse_add_left, S.secondAxisResponse_add_right, + S.secondAxisResponse_add_right, S.secondAxisResponse_symm (S.differential f), hz] at h + linarith + +omit [Fintype V] [Fintype E] in +theorem differential_add_complex (S : SpinSystem 3 V E) (f g : V → ℂ) : + S.differential (f+g) = S.differential f + S.differential g := by + ext e + simp only [differential, Pi.add_apply] + ring + +omit [Fintype V] [Fintype E] in +theorem differential_smul_complex (S : SpinSystem 3 V E) (r : ℂ) (f : V → ℂ) : + S.differential (r • f) = r • S.differential f := by + ext e + simp only [differential, Pi.smul_apply, smul_eq_mul, mul_sub] + +theorem complexSecondResponse_gradient_right (S : SpinSystem 3 V E) (u : E → ℂ) + (f : V → ℂ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.complexSecondResponse u (S.differential f) = 0 := by + apply complex_linear_zero_of_real (fun _ : E => False) + (fun u => S.complexSecondResponse u (S.differential f)) + (fun u v => S.complexSecondResponse_add_left u v _) + (fun r u => S.complexSecondResponse_smul_left u _ r) ?_ u (fun _ h => h.elim) + intro a _ + apply complex_linear_zero_of_real (fun x => ∃ s, S.pin x = some s) + (fun f => S.complexSecondResponse (fun e => (a e : ℂ)) (S.differential f)) ?_ ?_ ?_ f ?_ + · intro f g + rw [S.differential_add_complex, S.complexSecondResponse_add_right] + · intro r f + rw [S.differential_smul_complex, S.complexSecondResponse_smul_right] + · intro b hb + rw [S.differential_ofReal, S.complexSecondResponse_ofReal, + S.secondAxisResponse_gradient_right a b (fun x s hs => hb x ⟨s,hs⟩), + Complex.ofReal_zero] + · intro x hx + obtain ⟨s, hs⟩ := hx + exact hP x s hs + +theorem complexSecondResponse_add_gradient_right (S : SpinSystem 3 V E) (u v : E → ℂ) + (f : V → ℂ) (hP : ∀ x s, S.pin x = some s → f x = 0) : + S.complexSecondResponse u (v+S.differential f) = S.complexSecondResponse u v := by + rw [S.complexSecondResponse_add_right, S.complexSecondResponse_gradient_right u f hP, add_zero] + +theorem complexSecondResponse_add_gradients (S : SpinSystem 3 V E) (u v : E → ℂ) + (f g : V → ℂ) (hP : ∀ x s, S.pin x = some s → f x = 0) + (hQ : ∀ x s, S.pin x = some s → g x = 0) : + S.complexSecondResponse (u+S.differential f) (v+S.differential g) = + S.complexSecondResponse u v := by + rw [S.complexSecondResponse_add_gradient_right _ v g hQ, + S.complexSecondResponse_symm, S.complexSecondResponse_add_gradient_right _ u f hP, + S.complexSecondResponse_symm] + +end ClassicalON.SpinSystem + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SeparatedAnnuli.lean b/lean/OAI/Probability/ClassicalON/SeparatedAnnuli.lean new file mode 100644 index 0000000000000000000000000000000000000000..51a68aee441a2d06d3030f23614742fe1a7352b7 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SeparatedAnnuli.lean @@ -0,0 +1,91 @@ +import OAI.Probability.ClassicalON.BondMeanOrder + +namespace OAI + +universe uK + +noncomputable section +open Set +open scoped BigOperators Classical +namespace ClassicalON.LatticeGraph +variable {K : Type uK} [Fintype K] + +def annulusIndicator (G : LatticeGraph) (N : ℤ) (z : Site) (η : G.edges → Bool) : ℝ := + crossingIndicator (fun e : (G.annulusGraph N z).edges => e.val.1) (fun e => e.val.2) + (G.annulusInner N z) (G.annulusOuter N z) (fun e => η (G.restrictEdge _ e)) + +omit [Fintype K] in +theorem annulusIndicator_nonneg (G : LatticeGraph) (N : ℤ) (z : Site) (η : G.edges → Bool) : + 0≤G.annulusIndicator N z η := crossingIndicator_nonneg _ _ _ _ _ + +omit [Fintype K] in +theorem annulusIndicator_monotone (G : LatticeGraph) (N : ℤ) (z : Site) : + Monotone (G.annulusIndicator N z) := by + intro η ξ h + apply crossingIndicator_monotone + intro e + exact h (G.restrictEdge _ e) + +omit [Fintype K] in +theorem annulusEdgesEquiv_symm_val (G : LatticeGraph) (N : ℤ) (z : K → Site) + (hz : SeparatedCenters N z) (i : K) (e : (G.annulusGraph N (z i)).edges) : + ((G.annulusEdgesEquiv N z hz i).symm e).val=G.restrictEdge _ e := by + obtain ⟨e,rfl⟩ := (G.annulusEdgesEquiv N z hz i).surjective e + simp only [Equiv.symm_apply_apply,annulusEdgesEquiv_restrictEdge] + +theorem separated_annuli_factor (G : LatticeGraph) (b : G.edges → ℝ) (N : ℤ) (hN : 0≤N) + (z : K → Site) (hz : SeparatedCenters N z) + (f : (i : K) → ((G.annulusGraph N (z i)).edges → Bool) → ℝ) : + poleBondMean (fun e : G.edges => e.val.1) (fun e => e.val.2) b (G.allAnnulusPins N z) + (fun _ => true) (fun η => ∏ i,f i (fun e => η (G.restrictEdge _ e)))= + ∏ i,poleBondMean (fun e : (G.annulusGraph N (z i)).edges => e.val.1) (fun e => e.val.2) + (G.annulusCoupling b N (z i)) (G.annulusPins N (z i)) (fun _ => true) (f i) := by + let F : (k : Option K) → ({e : G.edges // G.annulusEdgeLabel N z e=k} → Bool) → ℝ := + fun k => match k with + | none => fun _ => 1 + | some i => fun η => f i (arrowEquiv (G.annulusEdgesEquiv N z hz i) η) + have he (η : G.edges → Bool) : (∏ k,F k (fun e => η e.val))= + ∏ i,f i (fun e => η (G.restrictEdge _ e)) := by + rw [Fintype.prod_option] + simp only [F,one_mul,arrowEquiv,Equiv.coe_fn_mk,annulusEdgesEquiv_symm_val] + have hp := poleBondMean_blocks (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (G.allAnnulusPins N z) (G.annulusVertexLabel N z) (G.annulusEdgeLabel N z) + (fun e => G.annulus_left_label N hN z hz e) (fun e => G.annulus_right_label N hN z hz e) F + simpa only [he,Fintype.prod_option,F,blockBondMean_one,one_mul,← G.annulus_blockMean b N hN z hz] using hp + +theorem separated_annuli_small (β : ℝ) (hβ : 0≤β) (ε : ℝ) (hε : 0<ε) : + ∃ k : ℕ,4≤k ∧ ∀ (G : LatticeGraph) (b : G.edges → ℝ),(∀ e,0≤b e ∧ b e≤β) → + ∀ (K : Type) [Fintype K] (z : K → Site),SeparatedCenters (2^k:ℕ) z → + freeBondMean (fun e : G.edges => e.val.1) (fun e => e.val.2) b + (fun η => ∏ i,G.annulusIndicator (2^k:ℕ) (z i) η)≤ε^Fintype.card K := by + obtain ⟨k,hk,hs⟩ := local_annulus_small β hβ ε hε + refine ⟨k,hk,?_⟩ + intro G b hb K _ z hz + have hn : (0:ℤ)≤(2^k:ℕ) := by positivity + apply le_trans (freeBondMean_le_poleBondMean _ _ _ (fun e => (hb e).1) (G.allAnnulusPins (2^k:ℕ) z) + _ (fun η => Finset.prod_nonneg (fun i _ => G.annulusIndicator_nonneg _ _ η)) ?_) + · rw [show (fun η => ∏ i,G.annulusIndicator (2^k:ℕ) (z i) η)= + (fun η => ∏ i,crossingIndicator (fun e : (G.annulusGraph (2^k:ℕ) (z i)).edges => e.val.1) + (fun e => e.val.2) (G.annulusInner (2^k:ℕ) (z i)) (G.annulusOuter (2^k:ℕ) (z i)) + (fun e => η (G.restrictEdge _ e))) from rfl] + rw [G.separated_annuli_factor b _ hn z hz] + calc + _≤∏ _i : K,ε := by + apply Finset.prod_le_prod₀ + · intro i _ + rw [G.annulus_blockMean b _ hn z hz i] + exact blockBondMean_nonneg _ _ _ (fun e => (hb e).1) _ _ _ _ + (fun η => crossingIndicator_nonneg _ _ _ _ _) + · intro i _ + exact hs G b hb (z i) + _=ε^Fintype.card K := by simp + · intro η ξ h + apply Finset.prod_le_prod₀ + · intro i _; exact G.annulusIndicator_nonneg _ _ η + · intro i _; exact G.annulusIndicator_monotone _ _ h + +end ClassicalON.LatticeGraph + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SignedSigns.lean b/lean/OAI/Probability/ClassicalON/SignedSigns.lean new file mode 100644 index 0000000000000000000000000000000000000000..e086e660286bfd6fe4da9a2a5b7f987bf6ec624a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SignedSigns.lean @@ -0,0 +1,138 @@ +import OAI.Probability.ClassicalON.BondConnectivity + +namespace OAI + +universe uE uV + +noncomputable section +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} + +theorem bondConnected_refl (left right : E → V) (η : E → Bool) (x : V) : + bondConnected left right η x x := fun _ _ => rfl + +theorem bondConnected_symm (left right : E → V) (η : E → Bool) {x y : V} + (h : bondConnected left right η x y) : bondConnected left right η y x := fun s hs => (h s hs).symm + +theorem bondConnected_trans (left right : E → V) (η : E → Bool) {x y z : V} + (h : bondConnected left right η x y) (k : bondConnected left right η y z) : + bondConnected left right η x z := fun s hs => (h s hs).trans (k s hs) + +theorem bondConnected_endpoints (left right : E → V) (η : E → Bool) (e : E) (he : η e=true) : + bondConnected left right η (left e) (right e) := fun _ hs => hs e he + +theorem compatibleSigns_connected (left right : E → V) (η : E → Bool) + {s : V → Bool} (hs : s∈compatibleSigns left right η) {x y : V} + (h : bondConnected left right η x y) : s x=s y := by + apply signFieldEquiv.injective + apply h + intro e he + exact congrArg signFieldEquiv (hs e he) + +def prescribedCompatibleSigns (left right : E → V) (B : Set V) (p : V → Bool) (η : E → Bool) : Set (V → Bool) := + {s | s∈compatibleSigns left right η ∧ ∀ v∈B,s v=p v} + +def signTranslate (t : V → Bool) : (V → Bool) ≃ (V → Bool) where + toFun s v := s v==t v + invFun s v := s v==t v + left_inv s := by funext v; change ((s v==t v)==t v)=s v; cases s v <;> cases t v <;> rfl + right_inv s := by funext v; change ((s v==t v)==t v)=s v; cases s v <;> cases t v <;> rfl + +theorem signTranslate_compatible (left right : E → V) (η : E → Bool) (t : V → Bool) + (ht : t∈compatibleSigns left right η) (s : V → Bool) : + signTranslate t s∈compatibleSigns left right η ↔ s∈compatibleSigns left right η := by + change (∀ e,η e=true → (s (left e)==t (left e))=(s (right e)==t (right e))) ↔ _ + constructor + · intro h e he + have h' := h e he + rw [ht e he] at h' + have hc (a b c : Bool) : (a==c)=(b==c) ↔ a=b := by + cases a <;> cases b <;> cases c <;> decide + exact (hc _ _ _).mp h' + · intro h e he + rw [h e he,ht e he] + +def prescribedCompatibleSignsEquiv (left right : E → V) (B : Set V) (p : V → Bool) (η : E → Bool) + (t : prescribedCompatibleSigns left right B p η) : + positiveCompatibleSigns left right B η ≃ prescribedCompatibleSigns left right B p η := + (signTranslate t.val).subtypeEquiv (by + intro s + change (s∈compatibleSigns left right η ∧ ∀ v∈B,s v=true) ↔ + (signTranslate t.val s∈compatibleSigns left right η ∧ ∀ v∈B,(s v==t.val v)=p v) + rw [signTranslate_compatible left right η t.val t.property.1] + apply and_congr Iff.rfl + apply forall_congr' + intro v + apply forall_congr' + intro hv + rw [← t.property.2 v hv] + cases s v <;> cases t.val v <;> decide) + +variable [Fintype V] + +theorem prescribedCompatibleSigns_card_of_nonempty (left right : E → V) (B : Set V) + (p : V → Bool) (η : E → Bool) (h : (prescribedCompatibleSigns left right B p η).Nonempty) : + (Fintype.card (prescribedCompatibleSigns left right B p η):ℝ)= + clusterWeight left right η*bondPinFactor left right B η := by + obtain ⟨t,ht⟩ := h + rw [← Fintype.card_congr (prescribedCompatibleSignsEquiv left right B p η ⟨t,ht⟩)] + exact positiveCompatibleSigns_card _ _ _ _ + +def bondCrossing (left right : E → V) (I O : Set V) (η : E → Bool) : Prop := + ∃ x∈I,∃ y∈O,bondConnected left right η x y + +def layerSigns (I : Set V) (v : V) : Bool := if v∈I then false else true + +omit [Fintype V] in +theorem layerSigns_consistent_iff (left right : E → V) (I O : Set V) (hIO : Disjoint I O) + (η : E → Bool) : (prescribedCompatibleSigns left right (I∪O) (layerSigns I) η).Nonempty ↔ + ¬bondCrossing left right I O η := by + constructor + · rintro ⟨s,hs,hp⟩ ⟨x,hx,y,hy,hxy⟩ + have he := compatibleSigns_connected left right η hs hxy + have hx' := hp x (Or.inl hx) + have hy' := hp y (Or.inr hy) + have hyI : y∉I := fun h => Set.disjoint_left.mp hIO h hy + simp only [layerSigns,hx,hyI,ite_true,ite_false] at hx' hy' + rw [hx',hy'] at he + cases he + · intro hn + let t : V → Bool := fun v => if ∃ x∈I,bondConnected left right η x v then false else true + refine ⟨t,?_,?_⟩ + · intro e he + have hc := bondConnected_endpoints left right η e he + have hi : (∃ x∈I,bondConnected left right η x (left e)) ↔ + ∃ x∈I,bondConnected left right η x (right e) := by + constructor + · rintro ⟨x,hx,hxc⟩ + exact ⟨x,hx,bondConnected_trans left right η hxc hc⟩ + · rintro ⟨x,hx,hxc⟩ + exact ⟨x,hx,bondConnected_trans left right η hxc (bondConnected_symm left right η hc)⟩ + simp only [t,hi] + · intro v hv + rcases hv with hv | hv + · have hc : ∃ x∈I,bondConnected left right η x v := ⟨v,hv,bondConnected_refl _ _ _ _⟩ + simp [t,layerSigns,hv,hc] + · have hc : ¬∃ x∈I,bondConnected left right η x v := by + rintro ⟨x,hx,hxv⟩ + exact hn ⟨x,hx,v,hv,hxv⟩ + have hvI : v∉I := fun h => Set.disjoint_left.mp hIO h hv + simp [t,layerSigns,hvI,hc] + +theorem layerSigns_card (left right : E → V) (I O : Set V) (hIO : Disjoint I O) (η : E → Bool) : + (Fintype.card (prescribedCompatibleSigns left right (I∪O) (layerSigns I) η):ℝ)= + clusterWeight left right η*bondPinFactor left right (I∪O) η* + (if bondCrossing left right I O η then 0 else 1) := by + split_ifs with h + · have he : prescribedCompatibleSigns left right (I∪O) (layerSigns I) η=∅ := by + exact Set.not_nonempty_iff_eq_empty.mp (fun hn => (layerSigns_consistent_iff _ _ _ _ hIO _).mp hn h) + simp [he] + · rw [prescribedCompatibleSigns_card_of_nonempty _ _ _ _ _ ((layerSigns_consistent_iff _ _ _ _ hIO _).mpr h)] + simp + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SmoothBounds.lean b/lean/OAI/Probability/ClassicalON/SmoothBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..4efce1898c844feba99e8ec8e68529a66291589f --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SmoothBounds.lean @@ -0,0 +1,110 @@ +import OAI.Probability.ClassicalON.SmoothProfiles + +namespace OAI + +universe uE uF + +noncomputable section +open Set Function +open scoped ContDiff +namespace ClassicalON + +variable {E : Type uE} {F : Type uF} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] + +omit [NormedSpace ℝ E] [NormedSpace ℝ F] in +theorem compact_continuous_norm_bound {f : E → F} (hc : HasCompactSupport f) (hf : Continuous f) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ x, ‖f x‖ ≤ C := by + obtain ⟨C,hC⟩ := (hc.isCompact_range hf).isBounded.exists_norm_le + exact ⟨max C 0, le_max_right _ _, fun x => (hC _ ⟨x,rfl⟩).trans (le_max_left _ _)⟩ + +theorem smooth_compact_lipschitz_bound {f : E → F} + (hc : HasCompactSupport f) (hf : ContDiff ℝ ∞ f) : + ∃ C : ℝ, 0 ≤ C ∧ (∀ x, ‖f x‖ ≤ C) ∧ + (∀ x y, ‖f y-f x‖ ≤ C*‖y-x‖) := by + obtain ⟨A,hA,hfA⟩ := compact_continuous_norm_bound hc hf.continuous + obtain ⟨B,hB,hfB⟩ := compact_continuous_norm_bound (hc.fderiv ℝ) + (hf.fderiv_right (m := ∞) (by simp)).continuous + refine ⟨A+B, add_nonneg hA hB, fun x => (hfA x).trans (le_add_of_nonneg_right hB), ?_⟩ + intro x y + calc ‖f y-f x‖ ≤ B*‖y-x‖ := + Convex.norm_image_sub_le_of_norm_fderiv_le (fun z _ => hf.differentiable (by simp) z) + (fun z _ => hfB z) convex_univ (mem_univ x) (mem_univ y) + _ ≤ (A+B)*‖y-x‖ := by gcongr; exact le_add_of_nonneg_left hA + +theorem scalar_lipschitz_of_deriv_bound (f f' : ℝ → ℝ) (C : ℝ) + (hf : ∀ x, HasDerivAt f (f' x) x) (hC : ∀ x, |f' x| ≤ C) (x y : ℝ) : + |f y-f x| ≤ C*|y-x| := by + exact Convex.norm_image_sub_le_of_norm_hasDerivWithin_le + (fun z _ => (hf z).hasDerivWithinAt) (fun z _ => hC z) convex_univ + (mem_univ x) (mem_univ y) + +theorem abs_sub_left_le_of_uIcc {x y z : ℝ} (hz : z ∈ uIcc x y) : + |z-x| ≤ |y-x| := by + rcases le_total x y with h | h + · rw [uIcc_of_le h] at hz + rw [abs_of_nonneg (sub_nonneg.mpr hz.1), abs_of_nonneg (sub_nonneg.mpr h)] + linarith [hz.2] + · rw [uIcc_of_ge h] at hz + rw [abs_of_nonpos (sub_nonpos.mpr hz.2), abs_of_nonpos (sub_nonpos.mpr h)] + linarith [hz.1] + +theorem first_remainder_bound (f f' : ℝ → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ x, HasDerivAt f (f' x) x) + (hL : ∀ x y, |f' y-f' x| ≤ C*|y-x|) (x y : ℝ) : + |f y-f x-f' x*(y-x)| ≤ C*|y-x|^2 := by + let g := fun z => f z-f' x*z + have hg (z : ℝ) : HasDerivAt g (f' z-f' x) z := by + convert (hf z).sub ((hasDerivAt_id z).const_mul (f' x)) using 1 <;> first | rfl | ring + have hb (z : ℝ) (hz : z ∈ uIcc x y) : |f' z-f' x| ≤ C*|y-x| := + (hL x z).trans (mul_le_mul_of_nonneg_left (abs_sub_left_le_of_uIcc hz) hC) + have H := Convex.norm_image_sub_le_of_norm_hasDerivWithin_le + (fun z (_ : z ∈ uIcc x y) => (hg z).hasDerivWithinAt) + (fun z hz => hb z hz) (convex_uIcc x y) (left_mem_uIcc) (right_mem_uIcc) + change |g y-g x| ≤ _ at H + convert H using 1 + · congr 1; ring + · rw [Real.norm_eq_abs]; ring + +theorem second_remainder_bound (f f' f'' : ℝ → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ x, HasDerivAt f (f' x) x) (hf' : ∀ x, HasDerivAt f' (f'' x) x) + (hL : ∀ x y, |f'' y-f'' x| ≤ C*|y-x|) (x y : ℝ) : + |f y-f x-f' x*(y-x)-f'' x/2*(y-x)^2| ≤ C*|y-x|^3 := by + let g := fun z => f z-f' x*(z-x)-f'' x/2*(z-x)^2 + have hg (z : ℝ) : HasDerivAt g (f' z-f' x-f'' x*(z-x)) z := by + have ht : HasDerivAt (fun t : ℝ => t-x) 1 z := (hasDerivAt_id z).sub_const x + have hq := ((hf z).sub (ht.const_mul (f' x))).sub ((ht.pow 2).const_mul (f'' x/2)) + convert hq using 1; first | rfl | ring + have hb (z : ℝ) (hz : z ∈ uIcc x y) : |f' z-f' x-f'' x*(z-x)| ≤ C*|y-x|^2 := by + exact (first_remainder_bound f' f'' C hC hf' hL x z).trans + (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (abs_nonneg _) (abs_sub_left_le_of_uIcc hz) 2) hC) + have H := Convex.norm_image_sub_le_of_norm_hasDerivWithin_le + (fun z (_ : z ∈ uIcc x y) => (hg z).hasDerivWithinAt) + (fun z hz => hb z hz) (convex_uIcc x y) (left_mem_uIcc) (right_mem_uIcc) + change |g y-g x| ≤ _ at H + convert H using 1 + · congr 1; ring + · rw [Real.norm_eq_abs]; ring + +theorem trapezoid_error_bound (f f' f'' : ℝ → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ x, HasDerivAt f (f' x) x) (hf' : ∀ x, HasDerivAt f' (f'' x) x) + (hL : ∀ x y, |f'' y-f'' x| ≤ C*|y-x|) (x y : ℝ) : + |f y-f x-(y-x)/2*(f' x+f' y)| ≤ 2*C*|y-x|^3 := by + have h1 := second_remainder_bound f f' f'' C hC hf hf' hL x y + have h2 := first_remainder_bound f' f'' C hC hf' hL x y + have he : f y-f x-(y-x)/2*(f' x+f' y) = + (f y-f x-f' x*(y-x)-f'' x/2*(y-x)^2) - + (y-x)/2*(f' y-f' x-f'' x*(y-x)) := by ring + rw [he] + calc _ ≤ |f y-f x-f' x*(y-x)-f'' x/2*(y-x)^2| + + |(y-x)/2*(f' y-f' x-f'' x*(y-x))| := abs_sub _ _ + _ ≤ C*|y-x|^3+|y-x|/2*(C*|y-x|^2) := by + rw [abs_mul, abs_div, abs_of_pos (by norm_num : (0:ℝ)<2)] + gcongr + _ ≤ _ := by nlinarith [mul_nonneg hC (pow_nonneg (abs_nonneg (y-x)) 3)] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SmoothProfiles.lean b/lean/OAI/Probability/ClassicalON/SmoothProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..62c522473b3b9bcf0b087166cb6a8b3a487788c0 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SmoothProfiles.lean @@ -0,0 +1,168 @@ +import OAI.Probability.ClassicalON.DyadicFourier + +namespace OAI + +noncomputable section +open Set Function +open scoped Topology ContDiff + +namespace ClassicalON + +def thetaBump : ContDiffBump (0 : ℝ) := ⟨4/3, 5/3, by norm_num, by norm_num⟩ +def outerBump : ContDiffBump (0 : ℝ) := ⟨7/4, 15/8, by norm_num, by norm_num⟩ +def innerBump : ContDiffBump (0 : ℝ) := ⟨9/8, 5/4, by norm_num, by norm_num⟩ + +def squareTheta (z : ℝ × ℝ) : ℝ := thetaBump z.1 * thetaBump z.2 + +def squareCutoff (z : ℝ × ℝ) : ℝ := + outerBump z.1 * outerBump z.2 * (1-innerBump z.1*innerBump z.2) + +def squareGradient (m : Bool) (z : ℝ × ℝ) : ℝ := + if m then thetaBump z.1 * deriv thetaBump z.2 else deriv thetaBump z.1 * thetaBump z.2 + +def squareProfile (m sign : Bool) (z : ℝ × ℝ) : ℝ := + if sign then (squareCutoff z-squareGradient m z)/2 else + (squareCutoff z+squareGradient m z)/2 + +theorem thetaBump_one {x : ℝ} (hx : |x| ≤ 4/3) : thetaBump x = 1 := by + apply thetaBump.one_of_mem_closedBall + simpa [Metric.mem_closedBall, Real.dist_eq, thetaBump] using hx + +theorem thetaBump_zero {x : ℝ} (hx : 5/3 ≤ |x|) : thetaBump x = 0 := by + apply thetaBump.zero_of_le_dist + simpa [Real.dist_eq, thetaBump] using hx + +theorem thetaBump_deriv_zero_inner {x : ℝ} (hx : |x| ≤ 4/3) : deriv thetaBump x = 0 := by + apply IsLocalMax.deriv_eq_zero + apply Filter.Eventually.of_forall + intro y + rw [thetaBump_one hx] + exact thetaBump.le_one + +theorem thetaBump_deriv_zero_outer {x : ℝ} (hx : 5/3 ≤ |x|) : deriv thetaBump x = 0 := by + apply IsLocalMin.deriv_eq_zero + apply Filter.Eventually.of_forall + intro y + rw [thetaBump_zero hx] + exact thetaBump.nonneg + +theorem outerBump_one {x : ℝ} (hx : |x| ≤ 7/4) : outerBump x = 1 := by + apply outerBump.one_of_mem_closedBall + simpa [Metric.mem_closedBall, Real.dist_eq, outerBump] using hx + +theorem outerBump_zero {x : ℝ} (hx : 15/8 ≤ |x|) : outerBump x = 0 := by + apply outerBump.zero_of_le_dist + simpa [Real.dist_eq, outerBump] using hx + +theorem innerBump_one {x : ℝ} (hx : |x| ≤ 9/8) : innerBump x = 1 := by + apply innerBump.one_of_mem_closedBall + simpa [Metric.mem_closedBall, Real.dist_eq, innerBump] using hx + +theorem innerBump_zero {x : ℝ} (hx : 5/4 ≤ |x|) : innerBump x = 0 := by + apply innerBump.zero_of_le_dist + simpa [Real.dist_eq, innerBump] using hx + +theorem squareTheta_one (z : ℝ × ℝ) (hx : |z.1| ≤ 1) (hy : |z.2| ≤ 1) : + squareTheta z = 1 := by + rw [squareTheta, thetaBump_one (by linarith), thetaBump_one (by linarith), mul_one] + +theorem squareTheta_zero (z : ℝ × ℝ) (h : 2 ≤ |z.1| ∨ 2 ≤ |z.2|) : + squareTheta z = 0 := by + rcases h with hx | hy + · simp [squareTheta, thetaBump_zero (by linarith : 5/3 ≤ |z.1|)] + · simp [squareTheta, thetaBump_zero (by linarith : 5/3 ≤ |z.2|)] + +theorem squareCutoff_gradient (m : Bool) (z : ℝ × ℝ) : + squareCutoff z * squareGradient m z = squareGradient m z := by + cases m + · simp only [squareGradient, Bool.false_eq_true, ↓reduceIte] + by_cases hg : deriv thetaBump z.1 = 0 + · simp [hg] + by_cases ht : thetaBump z.2 = 0 + · simp [ht] + have hx : 4/3 < |z.1| ∧ |z.1| < 5/3 := by + constructor + · exact lt_of_not_ge (fun h => hg (thetaBump_deriv_zero_inner h)) + · exact lt_of_not_ge (fun h => hg (thetaBump_deriv_zero_outer h)) + have hy : |z.2| < 5/3 := lt_of_not_ge (fun h => ht (thetaBump_zero h)) + simp [squareCutoff, outerBump_one (by linarith : |z.1| ≤ 7/4), + outerBump_one (by linarith : |z.2| ≤ 7/4), innerBump_zero (by linarith : 5/4 ≤ |z.1|)] + · simp only [squareGradient, ↓reduceIte] + by_cases hg : deriv thetaBump z.2 = 0 + · simp [hg] + by_cases ht : thetaBump z.1 = 0 + · simp [ht] + have hy : 4/3 < |z.2| ∧ |z.2| < 5/3 := by + constructor + · exact lt_of_not_ge (fun h => hg (thetaBump_deriv_zero_inner h)) + · exact lt_of_not_ge (fun h => hg (thetaBump_deriv_zero_outer h)) + have hx : |z.1| < 5/3 := lt_of_not_ge (fun h => ht (thetaBump_zero h)) + simp [squareCutoff, outerBump_one (by linarith : |z.1| ≤ 7/4), + outerBump_one (by linarith : |z.2| ≤ 7/4), innerBump_zero (by linarith : 5/4 ≤ |z.2|)] + +theorem squareProfile_squares (m : Bool) (z : ℝ × ℝ) : + squareProfile m false z ^ 2 - squareProfile m true z ^ 2 = squareGradient m z := by + simp only [squareProfile, Bool.false_eq_true, ↓reduceIte] + have h := squareCutoff_gradient m z + nlinarith + +theorem squareProfile_zero_inner (m s : Bool) (z : ℝ × ℝ) + (hx : |z.1| ≤ 1) (hy : |z.2| ≤ 1) : squareProfile m s z = 0 := by + have hc : squareCutoff z = 0 := by + simp [squareCutoff, innerBump_one (by linarith : |z.1| ≤ 9/8), + innerBump_one (by linarith : |z.2| ≤ 9/8)] + have hg : squareGradient m z = 0 := by + cases m <;> simp [squareGradient, + thetaBump_deriv_zero_inner (by linarith : |z.1| ≤ 4/3), + thetaBump_deriv_zero_inner (by linarith : |z.2| ≤ 4/3)] + cases s <;> simp [squareProfile, hc, hg] + +theorem squareProfile_zero_outer (m s : Bool) (z : ℝ × ℝ) + (h : 2 ≤ |z.1| ∨ 2 ≤ |z.2|) : squareProfile m s z = 0 := by + have hc : squareCutoff z = 0 := by + rcases h with hx | hy + · simp [squareCutoff, outerBump_zero (by linarith : 15/8 ≤ |z.1|)] + · simp [squareCutoff, outerBump_zero (by linarith : 15/8 ≤ |z.2|)] + have hg : squareGradient m z = 0 := by + rcases h with hx | hy + · cases m <;> simp [squareGradient, + thetaBump_zero (by linarith : 5/3 ≤ |z.1|), + thetaBump_deriv_zero_outer (by linarith : 5/3 ≤ |z.1|)] + · cases m <;> simp [squareGradient, + thetaBump_zero (by linarith : 5/3 ≤ |z.2|), + thetaBump_deriv_zero_outer (by linarith : 5/3 ≤ |z.2|)] + cases s <;> simp [squareProfile, hc, hg] + +theorem squareTheta_contDiff : ContDiff ℝ ∞ squareTheta := by + exact (thetaBump.contDiff.comp contDiff_fst).mul (thetaBump.contDiff.comp contDiff_snd) + +theorem squareCutoff_contDiff : ContDiff ℝ ∞ squareCutoff := by + apply ((outerBump.contDiff.comp contDiff_fst).mul (outerBump.contDiff.comp contDiff_snd)).mul + exact contDiff_const.sub ((innerBump.contDiff.comp contDiff_fst).mul (innerBump.contDiff.comp contDiff_snd)) + +theorem squareGradient_contDiff (m : Bool) : ContDiff ℝ ∞ (squareGradient m) := by + have hd : ContDiff ℝ ∞ (deriv thetaBump) := (contDiff_infty_iff_deriv.mp (thetaBump.contDiff : ContDiff ℝ ∞ thetaBump)).2 + cases m + · exact (hd.comp contDiff_fst).mul (thetaBump.contDiff.comp contDiff_snd) + · exact (thetaBump.contDiff.comp contDiff_fst).mul (hd.comp contDiff_snd) + +theorem squareProfile_contDiff (m s : Bool) : ContDiff ℝ ∞ (squareProfile m s) := by + cases s + · exact (squareCutoff_contDiff.add (squareGradient_contDiff m)).div_const 2 + · exact (squareCutoff_contDiff.sub (squareGradient_contDiff m)).div_const 2 + +theorem squareProfile_compact (m s : Bool) : HasCompactSupport (squareProfile m s) := by + apply HasCompactSupport.intro (isCompact_Icc.prod isCompact_Icc : + IsCompact (Icc (-2:ℝ) 2 ×ˢ Icc (-2:ℝ) 2)) + intro z hz + apply squareProfile_zero_outer + by_contra h + push Not at h + apply hz + constructor <;> constructor <;> nlinarith [abs_le.mp h.1.le, abs_le.mp h.2.le] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SpinBondKernel.lean b/lean/OAI/Probability/ClassicalON/SpinBondKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e115c31f165b70671c48586e56c4b2c754d561a --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SpinBondKernel.lean @@ -0,0 +1,112 @@ +import OAI.Probability.ClassicalON.BondExpansion + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def spinBondParameter (left right : E → V) (b : E → ℝ) (s : V → Spin 3) (e : E) : ℝ := + 1-Real.exp (-2*b e*max ((s (left e)).val 0*(s (right e)).val 0) 0) + +def spinBondWeight (left right : E → V) (b : E → ℝ) (s : V → Spin 3) (η : E → Bool) : ℝ := + ∏ e,if η e then spinBondParameter left right b s e else 1-spinBondParameter left right b s e + +omit [Fintype V] [Fintype E] in +theorem continuous_spinBondParameter (left right : E → V) (b : E → ℝ) (e : E) : + Continuous (fun s => spinBondParameter left right b s e) := by + unfold spinBondParameter + fun_prop + +omit [Fintype V] in +theorem continuous_spinBondWeight (left right : E → V) (b : E → ℝ) (η : E → Bool) : + Continuous (fun s => spinBondWeight left right b s η) := by + unfold spinBondWeight + apply continuous_finsetProd + intro e _ + split <;> [exact continuous_spinBondParameter _ _ _ _;exact continuous_const.sub (continuous_spinBondParameter _ _ _ _)] + +omit [Fintype V] [Fintype E] in +theorem spinBondParameter_bounds (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (s : V → Spin 3) (e : E) : 0 ≤ spinBondParameter left right b s e ∧ spinBondParameter left right b s e≤1 := by + have hn : -2*b e*max ((s (left e)).val 0*(s (right e)).val 0) 0≤0 := + mul_nonpos_of_nonpos_of_nonneg (mul_nonpos_of_nonpos_of_nonneg (by norm_num) (hb e)) (le_max_right _ _) + have h := Real.exp_le_one_iff.mpr hn + have hp := Real.exp_pos (-2*b e*max ((s (left e)).val 0*(s (right e)).val 0) 0) + constructor <;> unfold spinBondParameter <;> linarith + +omit [Fintype V] in +theorem spinBondWeight_nonneg (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (s : V → Spin 3) (η : E → Bool) : 0 ≤ spinBondWeight left right b s η := by + apply Finset.prod_nonneg + intro e _ + split + · exact (spinBondParameter_bounds _ _ _ hb s e).1 + · exact sub_nonneg.mpr (spinBondParameter_bounds _ _ _ hb s e).2 + +omit [Fintype V] in +theorem spinBondWeight_sum (left right : E → V) (b : E → ℝ) (s : V → Spin 3) : + (∑ η,spinBondWeight left right b s η)=1 := by + unfold spinBondWeight + change (∑ η : E → Bool, ∏ e, (fun (e : E) (z : Bool) => if z then spinBondParameter left right b s e else 1-spinBondParameter left right b s e) e (η e)) = 1 + rw [← Fintype.prod_sum (fun (e : E) (z : Bool) => if z then spinBondParameter left right b s e else 1-spinBondParameter left right b s e)] + simp + +omit [Fintype V] [Fintype E] in +theorem spinBondParameter_cylinder (left right : E → V) (b : E → ℝ) + (r : V → Amplitude) (τ : V → Bool) (θ : V → PlanarAngle) (e : E) : + spinBondParameter left right b (cylindricalConfiguration r τ θ) e= + if τ (left e)=τ (right e) then 1-Real.exp (-2*amplitudeCoupling left right b (fun v => (r v:ℝ)) e) else 0 := by + have hp : 0≤(r (left e):ℝ)*(r (right e):ℝ) := mul_nonneg (r (left e)).property.1 (r (right e)).property.1 + unfold spinBondParameter cylindricalConfiguration cylindricalSpin + simp only [Fin.isValue,Matrix.cons_val_zero] + have hmul : (r (left e):ℝ)*signValue (τ (left e))*((r (right e):ℝ)*signValue (τ (right e)))= + (r (left e):ℝ)*(r (right e):ℝ)*(signValue (τ (left e))*signValue (τ (right e))) := by ring + rw [hmul] + cases τ (left e) <;> cases τ (right e) <;> simp only [signValue,Bool.false_eq_true,ite_false,ite_true, + mul_neg,neg_mul,mul_one,neg_neg] + all_goals simp only [max_eq_left hp,max_eq_right (neg_nonpos.mpr hp),mul_zero,neg_zero,Real.exp_zero,sub_self] + all_goals (congr 2 <;> (unfold amplitudeCoupling; ring)) + +omit [Fintype V] in +theorem cylindrical_ising_bond_weight (left right : E → V) (K : E → ℝ) (τ : V → Bool) (η : E → Bool) : + Real.exp (edgeHamiltonian (isingEnergy left right) K τ)* + (∏ e,if η e then (if τ (left e)=τ (right e) then 1-Real.exp (-2*K e) else 0) + else 1-(if τ (left e)=τ (right e) then 1-Real.exp (-2*K e) else 0))= + Real.exp (-∑ e,K e)*bondSignProduct left right (fun e => Real.exp (2*K e)-1) η τ := by + have he (k : ℝ) (a d z : Bool) : + Real.exp (k*(signValue a*signValue d))*(if z then (if a=d then 1-Real.exp (-2*k) else 0) + else 1-(if a=d then 1-Real.exp (-2*k) else 0))= + Real.exp (-k)*(if z then (if a=d then Real.exp (2*k)-1 else 0) else 1) := by + have h1 : Real.exp k*Real.exp (-(2*k))=Real.exp (-k) := by rw [← Real.exp_add]; congr 1; ring + have h2 : Real.exp (-k)*Real.exp (2*k)=Real.exp k := by rw [← Real.exp_add]; congr 1; ring + cases a <;> cases d <;> cases z <;> simp [signValue,mul_sub,h1,h2] + unfold edgeHamiltonian isingEnergy + rw [Real.exp_sum,← Finset.prod_mul_distrib] + simp_rw [he] + rw [Finset.prod_mul_distrib,← Real.exp_sum,Finset.sum_neg_distrib] + rfl + +omit [Fintype V] in +theorem cylindrical_spin_bond_weight (left right : E → V) (b : E → ℝ) + (r : V → Amplitude) (τ : V → Bool) (θ : V → PlanarAngle) (η : E → Bool) : + Real.exp (freeSpinEnergy 3 left right b (cylindricalConfiguration r τ θ))* + spinBondWeight left right b (cylindricalConfiguration r τ θ) η= + Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (r v:ℝ)) e)* + bondSignProduct left right (fun e => Real.exp (2*amplitudeCoupling left right b (fun v => (r v:ℝ)) e)-1) η τ* + Real.exp (edgeHamiltonian (planarEnergy left right) + (amplitudeCoupling left right b (fun v => transverseAmplitude (r v))) θ) := by + rw [cylindricalConfiguration_energy,Real.exp_add] + unfold spinBondWeight + simp_rw [spinBondParameter_cylinder] + rw [mul_right_comm, cylindrical_ising_bond_weight] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SpinBonds.lean b/lean/OAI/Probability/ClassicalON/SpinBonds.lean new file mode 100644 index 0000000000000000000000000000000000000000..95defa4b454776e54433f8e05552b140682e2f76 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SpinBonds.lean @@ -0,0 +1,84 @@ +import OAI.Probability.ClassicalON.RawBond + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +omit [Fintype V] [Fintype E] in +theorem amplitudeBondParam_eq (left right : E → V) (b : E → ℝ) (r : V → Amplitude) : + (fun e => Real.exp (2*amplitudeCoupling left right b (fun v => (r v:ℝ)) e)-1)= + amplitudeBondParam left right b r := by + funext e + unfold amplitudeBondParam amplitudeCoupling + congr 2 + ring + +theorem integral_spinBondWeight (left right : E → V) (b : E → ℝ) (η : E → Bool) : + (∫ s,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η ∂freeSpinReference 3)= + ∫ r,amplitudeBondWeight left right b r η ∂Measure.pi (fun _ : V => sphericalAmplitudeLaw) := by + have hc : Continuous (fun s : V → Spin 3 => Real.exp (freeSpinEnergy 3 left right b s)* + spinBondWeight left right b s η) := + (continuous_freeSpinEnergy 3 left right b).rexp.mul (continuous_spinBondWeight left right b η) + rw [integral_freeSpinReference_cylinder _ hc] + apply integral_congr_ae + filter_upwards with r + simp_rw [cylindrical_spin_bond_weight,integral_const_mul] + change (∫ τ,Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (r v:ℝ)) e)* + bondSignProduct left right (fun e => Real.exp (2*amplitudeCoupling left right b (fun v => (r v:ℝ)) e)-1) η τ* + planarAmplitudePartition left right b r ∂isingReference)=_ + rw [integral_mul_const,integral_const_mul,integral_isingReference] + simp_rw [bondSignProduct_eq,← Finset.mul_sum,compatibleSigns_sum] + rw [amplitudeBondParam_eq] + unfold amplitudeBondWeight amplitudeBondPrefactor bondWeight + ring + +theorem integral_freeSpinWeight (left right : E → V) (b : E → ℝ) : + (∫ s,Real.exp (freeSpinEnergy 3 left right b s) ∂freeSpinReference 3)= + ∫ r,amplitudeDensity left right b r ∂Measure.pi (fun _ : V => sphericalAmplitudeLaw) := by + have he (s : V → Spin 3) : Real.exp (freeSpinEnergy 3 left right b s)= + ∑ η,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η := by + rw [← Finset.mul_sum,spinBondWeight_sum,mul_one] + rw [show (fun s : V → Spin 3 => Real.exp (freeSpinEnergy 3 left right b s))= + (fun s => ∑ η,Real.exp (freeSpinEnergy 3 left right b s)*spinBondWeight left right b s η) from funext he] + rw [integral_finsetSum] + · simp_rw [integral_spinBondWeight] + rw [← integral_finsetSum] + · simp_rw [amplitudeBondWeight_sum] + · intro η _ + exact compact_integrable (continuous_amplitudeBondWeight _ _ _ _) + · intro η _ + exact compact_integrable ((continuous_freeSpinEnergy _ _ _ _).rexp.mul (continuous_spinBondWeight _ _ _ _)) + +def freeBondMean (left right : E → V) (b : E → ℝ) (f : (E → Bool) → ℝ) : ℝ := + freeSpinMean 3 left right b (fun s => ∑ η,spinBondWeight left right b s η*f η) + +theorem freeBondMean_eq_jointBondMean (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + (f : (E → Bool) → ℝ) : + freeBondMean left right b f=jointBondMean sphericalAmplitudeLaw left right b (fun _ η => f η) := by + rw [jointBondMean_raw _ _ _ _ hb] + unfold freeBondMean freeSpinMean weightedMean + rw [integral_freeSpinWeight] + simp_rw [amplitudeBondWeight_sum] + congr 1 + simp_rw [Finset.mul_sum,← mul_assoc] + rw [integral_finsetSum,integral_finsetSum] + · apply Finset.sum_congr rfl + intro η _ + rw [integral_mul_const,integral_mul_const,integral_spinBondWeight] + · intro η _ + exact (compact_integrable (continuous_amplitudeBondWeight _ _ _ _)).mul_const _ + · intro η _ + exact (compact_integrable ((continuous_freeSpinEnergy _ _ _ _).rexp.mul + (continuous_spinBondWeight _ _ _ _))).mul_const _ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SpinCorrelation.lean b/lean/OAI/Probability/ClassicalON/SpinCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e369c7d714deec1953fd7543a88f2325fe5d522 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SpinCorrelation.lean @@ -0,0 +1,104 @@ +import OAI.Probability.ClassicalON.CenteredAnnulus + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def firstSpinProduct (x y : V) (s : V → Spin 3) : ℝ := (s x).val 0*(s y).val 0 + +omit [Fintype V] [Fintype E] in +theorem continuous_firstSpinProduct (x y : V) : Continuous (firstSpinProduct x y) := by + unfold firstSpinProduct + fun_prop + +omit [Fintype V] [Fintype E] in +theorem cylindrical_firstSpinProduct (x y : V) (r : V → Amplitude) (τ : V → Bool) (θ : V → PlanarAngle) : + firstSpinProduct x y (cylindricalConfiguration r τ θ)= + (r x:ℝ)*(r y:ℝ)*(signValue (τ x)*signValue (τ y)) := by + change ((r x:ℝ)*signValue (τ x))*((r y:ℝ)*signValue (τ y))=_ + ring + +theorem integral_cylinder_firstSpin (left right : E → V) (b : E → ℝ) (x y : V) (r : V → Amplitude) : + (∫ τ,∫ θ,Real.exp (freeSpinEnergy 3 left right b (cylindricalConfiguration r τ θ))* + firstSpinProduct x y (cylindricalConfiguration r τ θ) ∂planarReference ∂isingReference)= + ∑ η,amplitudeBondWeight left right b r η* + ((r x:ℝ)*(r y:ℝ)*(if bondConnected left right η x y then 1 else 0)) := by + have he (τ : V → Bool) (θ : V → PlanarAngle) : + Real.exp (freeSpinEnergy 3 left right b (cylindricalConfiguration r τ θ))* + firstSpinProduct x y (cylindricalConfiguration r τ θ)= + ((r x:ℝ)*(r y:ℝ))*(Real.exp (edgeHamiltonian (isingEnergy left right) + (amplitudeCoupling left right b (fun v => (r v:ℝ))) τ)*(signValue (τ x)*signValue (τ y)))* + Real.exp (edgeHamiltonian (planarEnergy left right) + (amplitudeCoupling left right b (fun v => transverseAmplitude (r v))) θ) := by + rw [cylindricalConfiguration_energy,Real.exp_add,cylindrical_firstSpinProduct] + ring + simp_rw [he,integral_const_mul] + rw [integral_mul_const,integral_const_mul,ising_numerator_bond_sum,amplitudeBondParam_eq] + change ((r x:ℝ)*(r y:ℝ))*((2:ℝ)⁻¹^Fintype.card V* + Real.exp (-∑ e,amplitudeCoupling left right b (fun v => (r v:ℝ)) e)* + ∑ η,bondWeight left right (amplitudeBondParam left right b r) η* + (if bondConnected left right η x y then 1 else 0))*planarAmplitudePartition left right b r=_ + rw [Finset.mul_sum,Finset.mul_sum,Finset.sum_mul] + apply Finset.sum_congr rfl + intro η _ + unfold amplitudeBondWeight amplitudeBondPrefactor + ring + +theorem firstSpinMean_eq_jointBondMean (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) (x y : V) : + freeSpinMean 3 left right b (firstSpinProduct x y)= + jointBondMean sphericalAmplitudeLaw left right b + (fun r η => (r x:ℝ)*(r y:ℝ)*(if bondConnected left right η x y then 1 else 0)) := by + rw [jointBondMean_raw _ _ _ _ hb] + unfold freeSpinMean weightedMean + rw [integral_freeSpinWeight] + simp_rw [amplitudeBondWeight_sum] + congr 1 + have hc : Continuous (fun s : V → Spin 3 => Real.exp (freeSpinEnergy 3 left right b s)*firstSpinProduct x y s) := + (continuous_freeSpinEnergy 3 left right b).rexp.mul (continuous_firstSpinProduct x y) + rw [integral_freeSpinReference_cylinder _ hc] + simp_rw [integral_cylinder_firstSpin] + +theorem jointBondMean_nonneg (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + {f : (V → Amplitude) → (E → Bool) → ℝ} (hf : ∀ r η,0≤f r η) : + 0≤jointBondMean μ left right b f := + weightedMean_nonneg (continuous_amplitudeDensity _ _ _) (amplitudeDensity_pos _ _ _) + (bondConditionalMean_nonneg _ _ _ hb hf) + +theorem jointBondMean_mono (μ : Measure Amplitude) [IsProbabilityMeasure μ] + (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) + {f g : (V → Amplitude) → (E → Bool) → ℝ} + (hf : ∀ η,Continuous (fun r => f r η)) (hg : ∀ η,Continuous (fun r => g r η)) + (hfg : ∀ r η,f r η≤g r η) : jointBondMean μ left right b f≤jointBondMean μ left right b g := by + apply weightedMean_mono (continuous_amplitudeDensity _ _ _) (amplitudeDensity_pos _ _ _) + (continuous_bondConditionalMean _ _ _ hb hf) (continuous_bondConditionalMean _ _ _ hb hg) + intro r + exact finiteMean_mono (bondWeight_nonneg _ _ (amplitudeBondParam_nonneg _ _ _ hb r)) (hfg r) + +theorem firstSpinMean_bounds (left right : E → V) (b : E → ℝ) (hb : ∀ e,0≤b e) (x y : V) : + 0≤freeSpinMean 3 left right b (firstSpinProduct x y) ∧ + freeSpinMean 3 left right b (firstSpinProduct x y)≤ + freeBondMean left right b (fun η => if bondConnected left right η x y then 1 else 0) := by + rw [firstSpinMean_eq_jointBondMean _ _ _ hb,freeBondMean_eq_jointBondMean _ _ _ hb] + constructor + · apply jointBondMean_nonneg _ _ _ _ hb + intro r η + exact mul_nonneg (mul_nonneg (r x).property.1 (r y).property.1) (by split_ifs <;> norm_num) + · apply jointBondMean_mono _ _ _ _ hb + · intro η; fun_prop + · intro η; exact continuous_const + · intro r η + split_ifs <;> simp only [mul_one,mul_zero,le_refl] + exact (mul_le_of_le_one_left (r y).property.1 (r x).property.2).trans (r y).property.2 + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SpinIsotropy.lean b/lean/OAI/Probability/ClassicalON/SpinIsotropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad31c128e27b6bb402b1afbcf3dadebd6c58a980 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SpinIsotropy.lean @@ -0,0 +1,91 @@ +import OAI.Probability.ClassicalON.CoarseExponential + +namespace OAI + +universe uE uV + +noncomputable section +open MeasureTheory +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] + +def coordinateRotation (n : ℕ) (i j : Fin n) : + EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n) := + LinearIsometryEquiv.piLpCongrLeft 2 ℝ ℝ (Equiv.swap i j) + +omit [Fintype V] [Fintype E] in +theorem coordinateRotation_apply (n : ℕ) (i j k : Fin n) (v : EuclideanSpace ℝ (Fin n)) : + coordinateRotation n i j v k=v (Equiv.swap i j k) := by + simp [coordinateRotation,LinearIsometryEquiv.piLpCongrLeft_apply,Equiv.piCongrLeft'] + +omit [Fintype E] in +theorem freeSpinReference_rotation (n : ℕ) [NeZero n] (U : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) : + MeasurePreserving (SpinSystem.rotateConfiguration (fun _ : V => U)) (freeSpinReference n) (freeSpinReference n) := + measurePreserving_pi (fun _ : V => sphereProbability n) (fun _ => sphereProbability n) + (fun _ => spinRotation_preserves_probability U) + +omit [Fintype V] in +theorem freeSpinEnergy_rotation (n : ℕ) (left right : E → V) (b : E → ℝ) + (U : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin n)) (s : V → Spin n) : + freeSpinEnergy n left right b (SpinSystem.rotateConfiguration (fun _ : V => U) s)= + freeSpinEnergy n left right b s := by + apply Finset.sum_congr rfl + intro e _ + change b e*⟪U (s (left e)).val,U (s (right e)).val⟫_ℝ=_ + rw [U.inner_map_map] + +def coordinateSpinProduct (n : ℕ) (i : Fin n) (x y : V) (s : V → Spin n) : ℝ := + (s x).val i*(s y).val i + +omit [Fintype V] [Fintype E] in +theorem continuous_coordinateSpinProduct (n : ℕ) (i : Fin n) (x y : V) : + Continuous (coordinateSpinProduct n i x y) := by + unfold coordinateSpinProduct + fun_prop + +theorem coordinateSpinMean_eq (n : ℕ) [NeZero n] (left right : E → V) (b : E → ℝ) (i j : Fin n) (x y : V) : + freeSpinMean n left right b (coordinateSpinProduct n i x y)= + freeSpinMean n left right b (coordinateSpinProduct n j x y) := by + let U := coordinateRotation n i j + have he (s : V → Spin n) : + coordinateSpinProduct n i x y (SpinSystem.rotateConfiguration (fun _ : V => U) s)= + coordinateSpinProduct n j x y s := by + change (U (s x).val) i*(U (s y).val) i=_ + simp only [U,coordinateRotation_apply,Equiv.swap_apply_left,coordinateSpinProduct] + have hi := (freeSpinReference_rotation (V := V) n U).integral_comp + (SpinSystem.rotateConfiguration (fun _ : V => U)).measurableEmbedding + (fun s => Real.exp (freeSpinEnergy n left right b s)*coordinateSpinProduct n i x y s) + simp_rw [freeSpinEnergy_rotation,he] at hi + unfold freeSpinMean weightedMean + rw [hi] + +theorem innerSpinMean_eq_coordinate (n : ℕ) [NeZero n] (left right : E → V) (b : E → ℝ) + (i : Fin n) (x y : V) : + freeSpinMean n left right b (fun s => ⟪(s x).val,(s y).val⟫_ℝ)= + n*freeSpinMean n left right b (coordinateSpinProduct n i x y) := by + have he (s : V → Spin n) : ⟪(s x).val,(s y).val⟫_ℝ= + ∑ j : Fin n,coordinateSpinProduct n j x y s := by + rw [EuclideanSpace.inner_eq_star_dotProduct] + simp only [dotProduct,coordinateSpinProduct,star_trivial] + apply Finset.sum_congr rfl + intro j _ + ring + have hh : freeSpinMean n left right b (fun s => ⟪(s x).val,(s y).val⟫_ℝ)= + ∑ j : Fin n,freeSpinMean n left right b (coordinateSpinProduct n j x y) := by + unfold freeSpinMean weightedMean + simp_rw [he,Finset.mul_sum] + rw [integral_finsetSum] + · rw [Finset.sum_div] + · intro j _ + exact compact_integrable ((continuous_freeSpinEnergy _ _ _ _).rexp.mul + (continuous_coordinateSpinProduct _ _ _ _)) + rw [hh] + simp_rw [coordinateSpinMean_eq n left right b _ i x y] + simp + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SpinReindex.lean b/lean/OAI/Probability/ClassicalON/SpinReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2bedb394083755ed5bddf48e814fd7becc534d3 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SpinReindex.lean @@ -0,0 +1,116 @@ +import OAI.Probability.ClassicalON.ReindexIntegral + +namespace OAI + +universe uA uE uF uV uW + +noncomputable section +open MeasureTheory Set +open scoped BigOperators InnerProductSpace Classical +namespace ClassicalON +variable {V : Type uV} {W : Type uW} {E : Type uE} {F : Type uF} {A : Type uA} [Fintype V] [Fintype W] [Fintype E] [Fintype F] + +def arrowEquiv (e : E ≃ F) : (E → A) ≃ (F → A) where + toFun η := fun f => η (e.symm f) + invFun η := fun f => η (e f) + left_inv η := by funext f; simp + right_inv η := by funext f; simp + +omit [Fintype V] [Fintype W] in +theorem freeSpinEnergy_edgeEquiv (n : ℕ) (ee : E ≃ F) + (l r : E → V) (l' r' : F → W) (b : E → ℝ) (b' : F → ℝ) + (s : V → Spin n) (s' : W → Spin n) + (hb : ∀ e,b' (ee e)=b e) (hl : ∀ e,s' (l' (ee e))=s (l e)) + (hr : ∀ e,s' (r' (ee e))=s (r e)) : + freeSpinEnergy n l' r' b' s'=freeSpinEnergy n l r b s := by + unfold freeSpinEnergy + rw [← ee.sum_comp] + simp_rw [hb,hl,hr] + +omit [Fintype V] [Fintype W] in +theorem spinBondWeight_edgeEquiv (ee : E ≃ F) + (l r : E → V) (l' r' : F → W) (b : E → ℝ) (b' : F → ℝ) + (s : V → Spin 3) (s' : W → Spin 3) + (hb : ∀ e,b' (ee e)=b e) (hl : ∀ e,s' (l' (ee e))=s (l e)) + (hr : ∀ e,s' (r' (ee e))=s (r e)) (η : F → Bool) : + spinBondWeight l' r' b' s' η=spinBondWeight l r b s (fun e => η (ee e)) := by + unfold spinBondWeight spinBondParameter + rw [← ee.prod_comp] + simp_rw [hb,hl,hr] + +omit [Fintype V] [Fintype W] in +theorem sum_spinBondWeight_edgeEquiv (ee : E ≃ F) + (l r : E → V) (l' r' : F → W) (b : E → ℝ) (b' : F → ℝ) + (s : V → Spin 3) (s' : W → Spin 3) + (hb : ∀ e,b' (ee e)=b e) (hl : ∀ e,s' (l' (ee e))=s (l e)) + (hr : ∀ e,s' (r' (ee e))=s (r e)) (f : (E → Bool) → ℝ) : + (∑ η,spinBondWeight l' r' b' s' η*f (fun e => η (ee e)))= + ∑ η,spinBondWeight l r b s η*f η := by + simp_rw [spinBondWeight_edgeEquiv ee l r l' r' b b' s s' hb hl hr] + exact (arrowEquiv (A := Bool) ee).symm.sum_comp (fun η => spinBondWeight l r b s η*f η) + +theorem poleBondMean_reindex (ev : V ≃ W) (ee : E ≃ F) + (l r : E → V) (l' r' : F → W) (b : E → ℝ) (b' : F → ℝ) + (B : Set V) (B' : Set W) (hb : ∀ e,b' (ee e)=b e) + (hl : ∀ e,l' (ee e)=ev (l e)) (hr : ∀ e,r' (ee e)=ev (r e)) + (hB : ∀ v,ev v∈B' ↔ v∈B) (f : (E → Bool) → ℝ) : + poleBondMean l' r' b' B' (fun _ => true) (fun η => f (fun e => η (ee e)))= + poleBondMean l r b B (fun _ => true) f := by + unfold poleBondMean + rw [poleSystem_reference,poleSystem_reference] + have he (s : W → Spin 3) : freeSpinEnergy 3 l' r' b' s= + freeSpinEnergy 3 l r b (fun v => s (ev v)) := + freeSpinEnergy_edgeEquiv 3 ee _ _ _ _ _ _ _ _ hb + (fun e => congrArg s (hl e)) (fun e => congrArg s (hr e)) + have hs (s : W → Spin 3) := sum_spinBondWeight_edgeEquiv ee l r l' r' b b' + (fun v => s (ev v)) s hb (fun e => congrArg s (hl e)) (fun e => congrArg s (hr e)) f + simp_rw [he,hs] + let μ (w : W) : Measure (Spin 3) := if w∈B' then Measure.dirac (poleSpin true) else sphereProbability 3 + have : ∀ w,IsProbabilityMeasure (μ w) := by intro w; dsimp [μ]; split <;> infer_instance + change weightedMean (Measure.pi μ) _ _=_ + rw [weightedMean_pi_reindex ev μ (fun s => Real.exp (freeSpinEnergy 3 l r b s)) + (fun s => ∑ η,spinBondWeight l r b s η*f η)] + have hμ : (fun v => μ (ev v))=(fun v => if v∈B then Measure.dirac (poleSpin true) else sphereProbability 3) := by + funext v + simp only [μ,hB] + rw [hμ] + rfl + +omit [Fintype V] [Fintype W] [Fintype E] [Fintype F] in +theorem bondConnected_reindex (ev : V ≃ W) (ee : E ≃ F) + (l r : E → V) (l' r' : F → W) + (hl : ∀ e,l' (ee e)=ev (l e)) (hr : ∀ e,r' (ee e)=ev (r e)) + (η : F → Bool) (x y : V) : + bondConnected l' r' η (ev x) (ev y) ↔ bondConnected l r (fun e => η (ee e)) x y := by + constructor + · intro h s hs + have ht : (fun w => s (ev.symm w))∈bondSubspace l' r' η := by + intro f hf + obtain ⟨e,rfl⟩ := ee.surjective f + simpa only [hl,hr,Equiv.symm_apply_apply] using hs e hf + simpa only [Equiv.symm_apply_apply] using h _ ht + · intro h s hs + apply h (fun v => s (ev v)) + intro e he + simpa only [hl,hr] using hs (ee e) he + +omit [Fintype V] [Fintype W] [Fintype E] [Fintype F] in +theorem bondCrossing_reindex (ev : V ≃ W) (ee : E ≃ F) + (l r : E → V) (l' r' : F → W) + (hl : ∀ e,l' (ee e)=ev (l e)) (hr : ∀ e,r' (ee e)=ev (r e)) + (I O : Set V) (I' O' : Set W) (hI : ∀ v,ev v∈I' ↔ v∈I) + (hO : ∀ v,ev v∈O' ↔ v∈O) (η : F → Bool) : + bondCrossing l' r' I' O' η ↔ bondCrossing l r I O (fun e => η (ee e)) := by + constructor + · rintro ⟨x,hx,y,hy,hxy⟩ + obtain ⟨x,rfl⟩ := ev.surjective x + obtain ⟨y,rfl⟩ := ev.surjective y + exact ⟨x,(hI x).mp hx,y,(hO y).mp hy,(bondConnected_reindex ev ee l r l' r' hl hr η x y).mp hxy⟩ + · rintro ⟨x,hx,y,hy,hxy⟩ + exact ⟨ev x,(hI x).mpr hx,ev y,(hO y).mpr hy,(bondConnected_reindex ev ee l r l' r' hl hr η x y).mpr hxy⟩ + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/SquareEstimates.lean b/lean/OAI/Probability/ClassicalON/SquareEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3d5ba06638ea5fa7d3be222b20c91d012472e23 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/SquareEstimates.lean @@ -0,0 +1,64 @@ +import OAI.Probability.ClassicalON.EdgeOperators + +namespace OAI + +universe uI uP uX + +noncomputable section +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +variable {X : Type uX} {P : Type uP} {I : Type uI} [Fintype X] [Fintype P] [Fintype I] + +theorem norm_sum_sq_le_card (f : I → ℂ) : + ‖∑ i, f i‖^2 ≤ (Fintype.card I:ℝ)*∑ i, ‖f i‖^2 := by + calc _ ≤ (∑ i, ‖f i‖)^2 := pow_le_pow_left₀ (norm_nonneg _) (norm_sum_le _ _) 2 + _ ≤ _ := by + have h := Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul (R := ℝ) + (s := Finset.univ) (r := fun i => ‖f i‖) (f := fun _ => 1) + (g := fun i => ‖f i‖^2) (fun _ _ => by norm_num) (fun i _ => sq_nonneg _) + (fun i _ => le_of_eq (one_mul _).symm) + simpa using h + +theorem SquareBound.mono {U : X → P → ℂ} {a b : ℝ} + (ha : SquareBound U a) (hab : a^2 ≤ b^2) : SquareBound U b := by + intro v + exact (ha v).trans (mul_le_mul_of_nonneg_right hab (Finset.sum_nonneg fun _ _ => sq_nonneg _)) + +theorem sum_by_fibers [DecidableEq I] (d : X → I) (f : X → ℝ) : + (∑ x, f x) = ∑ i, ∑ x : {x // d x=i}, f x := by + classical + simpa only [Fintype.sum_sigma, Equiv.sigmaFiberEquiv_apply] using + (Equiv.sum_comp (Equiv.sigmaFiberEquiv d) f).symm + +theorem SquareBound.combine_directions (U : X → P → ℂ) (d : X → Bool) (a : ℝ) + (h : ∀ m : Bool, SquareBound (fun (x : {x // d x=m}) p => U x p) a) : + SquareBound U (2*a) := by + intro v + rw [sum_by_fibers d] + calc _ ≤ ∑ _m : Bool, a^2*∑ p, ‖v p‖^2 := + Finset.sum_le_sum fun m _ => h m v + _ ≤ (2*a)^2*∑ p, ‖v p‖^2 := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_bool, nsmul_eq_mul, Nat.cast_ofNat] + have hs : 0 ≤ ∑ p : P, ‖v p‖^2 := Finset.sum_nonneg fun p _ => sq_nonneg ‖v p‖ + nlinarith [mul_nonneg (sq_nonneg a) hs] + +theorem gram_groups_bound (T : I → X → X → ℂ) (C : ℝ) + (h : ∀ i, (∑ x, ∑ y, ‖T i x y‖^2) ≤ C) : + (∑ x, ∑ y, ‖∑ i, T i x y‖^2) ≤ (Fintype.card I:ℝ)^2*C := by + calc _ ≤ ∑ x, ∑ y, (Fintype.card I:ℝ)*∑ i, ‖T i x y‖^2 := + Finset.sum_le_sum fun x _ => Finset.sum_le_sum fun y _ => norm_sum_sq_le_card _ + _ = (Fintype.card I:ℝ)*∑ i, ∑ x, ∑ y, ‖T i x y‖^2 := by + simp only [← Finset.mul_sum] + congr 1 + calc (∑ x, ∑ y, ∑ i, ‖T i x y‖^2) = ∑ x, ∑ i, ∑ y, ‖T i x y‖^2 := + Finset.sum_congr rfl (fun _ _ => Finset.sum_comm) + _ = _ := Finset.sum_comm + _ ≤ (Fintype.card I:ℝ)*∑ _i : I, C := by gcongr with i; exact h i + _ = _ := by simp; ring + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/ThetaEstimates.lean b/lean/OAI/Probability/ClassicalON/ThetaEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..067d692c59308e50a3f75f1f65acd049bd20e079 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/ThetaEstimates.lean @@ -0,0 +1,89 @@ +import OAI.Probability.ClassicalON.ResponseTransfer + +namespace OAI + +noncomputable section +open Set +open scoped BigOperators ComplexConjugate +namespace ClassicalON + +theorem squareTheta_compact : HasCompactSupport squareTheta := by + apply HasCompactSupport.intro (isCompact_Icc.prod isCompact_Icc : + IsCompact (Icc (-2:ℝ) 2 ×ˢ Icc (-2:ℝ) 2)) + intro z hz + apply squareTheta_zero + by_contra h + push Not at h + apply hz + constructor <;> constructor <;> nlinarith [abs_le.mp h.1.le, abs_le.mp h.2.le] + +theorem theta_lipschitz_bound : ∃ C : ℝ, 0 ≤ C ∧ ∀ z w, + |squareTheta w-squareTheta z| ≤ C*‖w-z‖ := by + obtain ⟨C,hC,_,hL⟩ := smooth_compact_lipschitz_bound squareTheta_compact squareTheta_contDiff + exact ⟨C,hC,by simpa only [Real.norm_eq_abs] using hL⟩ + +namespace LatticeGraph + +theorem theta_edge_bounds : ∃ L D : ℝ, 0 ≤ L ∧ 0 ≤ D ∧ + ∀ (G : LatticeGraph) (k : ℕ), 4 ≤ k → ∀ e : G.edges, + |G.thetaEdge k e| ≤ L/(2:ℝ)^k ∧ + |G.thetaEdge k e-G.profileEdge k e| ≤ D/((2:ℝ)^k)^3 := by + obtain ⟨L,hL,hLip⟩ := theta_lipschitz_bound + obtain ⟨D,hD,hR⟩ := squareTheta_step_error + refine ⟨L,D,hL,hD,?_⟩ + intro G k hk e + constructor + · have h := hLip (scaledSite k e.val.1.val) (scaledSite k e.val.2.val) + rw [G.scaled_edge_distance] at h + exact h.trans_eq (by ring) + · have hN : (16:ℝ) ≤ (2:ℝ)^k := by + calc (16:ℝ) = (2:ℝ)^4 := by norm_num + _ ≤ _ := pow_le_pow_right₀ (by norm_num) hk + have hmesh : |1/(2:ℝ)^k| ≤ 1/16 := by + rw [abs_of_pos (by positivity)] + exact one_div_le_one_div_of_le (by norm_num) hN + have h := hR (G.edgeDirection e) (scaledSite k e.val.1.val) (1/(2:ℝ)^k) hmesh + rw [← scaledSite_add_axis, ← G.edge_step e,abs_of_pos (by positivity : 0 < 1/(2:ℝ)^k)] at h + simpa only [thetaEdge,profileEdge,div_pow,one_pow,mul_one_div] using h + +theorem theta_sum_bounds (G : LatticeGraph) (k : ℕ) (hG : G.WithinDyadicBox k) + (L D : ℝ) (hL : 0 ≤ L) (hD : 0 ≤ D) + (he : ∀ e : G.edges, |G.thetaEdge k e| ≤ L/(2:ℝ)^k ∧ + |G.thetaEdge k e-G.profileEdge k e| ≤ D/((2:ℝ)^k)^3) : + (∑ e, |G.thetaEdge k e-G.profileEdge k e|) ≤ 512*D/(2:ℝ)^k ∧ + (∑ e, |G.thetaEdge k e|^2) ≤ 512*L^2 ∧ + (∑ e, |G.thetaEdge k e-G.profileEdge k e| * + (|G.thetaEdge k e| + |G.profileEdge k e|)) ≤ 512*D*(2*L+D)/((2:ℝ)^k)^2 := by + let N : ℝ := (2:ℝ)^k + have hN : 0 < N := by dsimp [N]; positivity + have hN1 : 1 ≤ N := one_le_pow₀ (by norm_num) + have hcount := G.edge_card_bound k hG + change (Fintype.card G.edges:ℝ) ≤ 512*N^2 at hcount + have hv (e : G.edges) : |G.profileEdge k e| ≤ (L+D)/N := by + have htri : |G.profileEdge k e| ≤ |G.thetaEdge k e| + |G.thetaEdge k e-G.profileEdge k e| := by + simpa only [add_sub_cancel, abs_sub_comm] using abs_add_le (G.thetaEdge k e) (G.profileEdge k e-G.thetaEdge k e) + have hpow : N ≤ N^3 := by nlinarith [sq_nonneg (N-1)] + calc _ ≤ L/N+D/N^3 := htri.trans (add_le_add (he e).1 (he e).2) + _ ≤ L/N+D/N := add_le_add_right (div_le_div_of_nonneg_left hD hN hpow) _ + _ = _ := by ring + have hs1 : (∑ e, |G.thetaEdge k e-G.profileEdge k e|) ≤ (Fintype.card G.edges:ℝ)*(D/N^3) := by + simpa only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] using Finset.sum_le_sum (s := Finset.univ) (fun e _ => (he e).2) + have hs2 : (∑ e, |G.thetaEdge k e|^2) ≤ (Fintype.card G.edges:ℝ)*(L/N)^2 := by + simpa only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] using Finset.sum_le_sum (s := Finset.univ) + (fun e _ => pow_le_pow_left₀ (abs_nonneg _) (he e).1 2) + have hs3 : (∑ e, |G.thetaEdge k e-G.profileEdge k e| *(|G.thetaEdge k e| + |G.profileEdge k e|)) ≤ + (Fintype.card G.edges:ℝ)*(D/N^3*((2*L+D)/N)) := by + simpa only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] using Finset.sum_le_sum (s := Finset.univ) + (fun e _ => mul_le_mul (he e).2 (show |G.thetaEdge k e| + |G.profileEdge k e| ≤ (2*L+D)/N from + (add_le_add (he e).1 (hv e)).trans_eq (by ring)) (by positivity) (by positivity)) + refine ⟨hs1.trans ?_,hs2.trans ?_,hs3.trans ?_⟩ + all_goals + calc _ ≤ 512*N^2*_ := mul_le_mul_of_nonneg_right hcount (by positivity) + _ = _ := by dsimp only [N]; field_simp + +end LatticeGraph +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/TorusDouble.lean b/lean/OAI/Probability/ClassicalON/TorusDouble.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ec67e2d44253b2d86fdd59998ed2cb9e222d7fe --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/TorusDouble.lean @@ -0,0 +1,68 @@ +import OAI.Probability.ClassicalON.IsingPositive + +namespace OAI + +universe uV + +noncomputable section +open MeasureTheory +namespace ClassicalON + +abbrev PlanarAngle := UnitAddCircle + +def angleLaw : Measure PlanarAngle := AddCircle.haarAddCircle + +instance angleLaw_isProbability : IsProbabilityMeasure angleLaw := by + unfold angleLaw; infer_instance +instance angleLaw_isAddHaar : angleLaw.IsAddHaarMeasure := by + unfold angleLaw; infer_instance + +variable {V : Type uV} [Fintype V] + +def planarReference : Measure (V → PlanarAngle) := Measure.pi (fun _ => angleLaw) + +instance planarReference_isProbability : IsProbabilityMeasure (planarReference (V := V)) := by + unfold planarReference; infer_instance +instance planarReference_isAddHaar : (planarReference (V := V)).IsAddHaarMeasure := by + unfold planarReference; infer_instance + +def torusDouble : ((V → PlanarAngle)×(V → PlanarAngle)) →+ + ((V → PlanarAngle)×(V → PlanarAngle)) where + toFun p := (p.1+p.2,p.1-p.2) + map_zero' := by simp + map_add' := by intros; ext <;> simp <;> abel + +omit [Fintype V] in +theorem torusDouble_continuous : Continuous (torusDouble (V := V)) := by + change Continuous (fun p : (V → PlanarAngle)×(V → PlanarAngle) => (p.1+p.2,p.1-p.2)) + fun_prop + +omit [Fintype V] in +theorem torusDouble_surjective : Function.Surjective (torusDouble (V := V)) := by + intro p + let v := DivisibleBy.div (p.1+p.2) (2 : ℤ) + have hv : (2 : ℤ) • v=p.1+p.2 := DivisibleBy.div_cancel _ (by norm_num) + refine ⟨(v,p.1-v),?_⟩ + apply Prod.ext + · change v+(p.1-v)=p.1; abel + · change v-(p.1-v)=p.2 + rw [show v-(p.1-v)=(2 : ℤ) • v-p.1 by simp only [two_zsmul]; abel,hv] + abel + +theorem torusDouble_preserves : MeasurePreserving (torusDouble (V := V)) + ((planarReference (V := V)).prod (planarReference (V := V))) + ((planarReference (V := V)).prod (planarReference (V := V))) := + by + classical + let : BorelSpace (V → PlanarAngle) := Pi.borelSpace + let : SFinite (planarReference (V := V)) := inferInstance + let : MeasurableAdd (V → PlanarAngle) := inferInstance + let : ((planarReference (V := V)).prod (planarReference (V := V))).IsAddHaarMeasure := + Measure.prod.instIsAddHaarMeasure _ _ + exact AddMonoidHom.measurePreserving torusDouble_continuous torusDouble_surjective rfl + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/TorusFourier.lean b/lean/OAI/Probability/ClassicalON/TorusFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..97828c263c6597a3574df681e1356763ab59a729 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/TorusFourier.lean @@ -0,0 +1,108 @@ +import OAI.Probability.ClassicalON.FiniteVolume + +namespace OAI + +universe uP + +noncomputable section +open scoped BigOperators ComplexConjugate + +namespace ClassicalON + +abbrev DiscreteTorus (L : ℕ) := ZMod L × ZMod L + +def torusWave {L : ℕ} [NeZero L] (p x : DiscreteTorus L) : ℂ := + ZMod.stdAddChar (p.1*x.1+p.2*x.2) + +variable {L : ℕ} [NeZero L] + +@[simp] theorem torusWave_norm (p x : DiscreteTorus L) : ‖torusWave p x‖ = 1 := + AddChar.norm_apply _ _ + +@[simp] theorem torusWave_add (p x y : DiscreteTorus L) : + torusWave p (x+y) = torusWave p x * torusWave p y := by + unfold torusWave + rw [← AddChar.map_add_eq_mul] + congr 1 + simp only [Prod.fst_add, Prod.snd_add] + ring + +@[simp] theorem torusWave_zero (p : DiscreteTorus L) : torusWave p 0 = 1 := by + simp [torusWave] + +@[simp] theorem torusWave_conj (p x : DiscreteTorus L) : + conj (torusWave p x) = torusWave (-p) x := by + unfold torusWave + rw [← AddChar.map_neg_eq_conj] + congr 1 + simp only [Prod.fst_neg, Prod.snd_neg] + ring + +theorem torusWave_mul_conj (p q x : DiscreteTorus L) : + torusWave p x*conj (torusWave q x) = torusWave (p-q) x := by + rw [torusWave_conj] + unfold torusWave + rw [← AddChar.map_add_eq_mul] + congr 1 + simp only [Prod.fst_sub, Prod.snd_sub, Prod.fst_neg, Prod.snd_neg] + ring + +theorem sum_stdAddChar_mul (t : ZMod L) : + (∑ i : ZMod L, ZMod.stdAddChar (t*i)) = if t=0 then (L:ℂ) else 0 := by + classical + split_ifs with h + · simp [h] + · exact AddChar.sum_eq_zero_of_ne_one (ZMod.isPrimitive_stdAddChar L h) + +theorem sum_torusWave (p : DiscreteTorus L) : + (∑ x : DiscreteTorus L, torusWave p x) = if p=0 then (L:ℂ)^2 else 0 := by + classical + simp only [torusWave, Fintype.sum_prod_type, AddChar.map_add_eq_mul] + rw [← Finset.sum_mul_sum, sum_stdAddChar_mul, sum_stdAddChar_mul] + by_cases h1 : p.1=0 <;> by_cases h2 : p.2=0 <;> + simp [h1, h2, Prod.ext_iff, pow_two] + +theorem torusWave_orthogonal (p q : DiscreteTorus L) : + (∑ x : DiscreteTorus L, torusWave p x*conj (torusWave q x)) = + if p=q then ((L:ℝ)^2 : ℂ) else 0 := by + simp only [torusWave_mul_conj, sum_torusWave, sub_eq_zero, + Complex.ofReal_natCast] + +theorem torusWave_orthogonal_subfamily {P : Type uP} [DecidableEq P] + (p : P → DiscreteTorus L) (hp : Function.Injective p) (i j : P) : + (∑ x : DiscreteTorus L, torusWave (p i) x*conj (torusWave (p j) x)) = + if i=j then ((L:ℝ)^2 : ℂ) else 0 := by + simp only [torusWave_orthogonal, hp.eq_iff] + +theorem torusWave_intCast (p x : ℤ × ℤ) : + torusWave (L := L) ((p.1:ZMod L),(p.2:ZMod L)) ((x.1:ZMod L),(x.2:ZMod L)) = + Complex.exp (Complex.I * ((2*Real.pi*((p.1:ℝ)*(x.1:ℝ)+(p.2:ℝ)*(x.2:ℝ))/(L:ℝ)):ℂ)) := by + unfold torusWave + simp only [← Int.cast_mul, ← Int.cast_add] + rw [ZMod.stdAddChar_coe] + congr 1 + push_cast + ring + +theorem norm_stdAddChar_intCast_sub_one (p : ℤ) : + ‖ZMod.stdAddChar (p : ZMod L)-1‖ ≤ (2*Real.pi/(L:ℝ))*|(p:ℝ)| := by + rw [ZMod.stdAddChar_coe] + have he : (2*Real.pi*Complex.I*(p:ℂ)/(L:ℂ)) = + Complex.I*((2*Real.pi/(L:ℝ)*(p:ℝ):ℝ):ℂ) := by push_cast; ring + rw [he] + refine (Real.norm_exp_I_mul_ofReal_sub_one_le (x := 2*Real.pi/(L:ℝ)*(p:ℝ))).trans ?_ + rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg] + positivity + +theorem torus_mode_difference (φ : DiscreteTorus L → ℂ) (p x h : DiscreteTorus L) : + φ (x+h)*torusWave p (x+h)-φ x*torusWave p x = + (φ (x+h)-φ x)*torusWave p x + + φ (x+h)*torusWave p x*(torusWave p h-1) := by + rw [torusWave_add] + ring + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/UpperEndpoint.lean b/lean/OAI/Probability/ClassicalON/UpperEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..6363b0a452696469b74856defc77281db03585c8 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/UpperEndpoint.lean @@ -0,0 +1,87 @@ +import OAI.Probability.ClassicalON.CylindricalConfiguration + +namespace OAI + +universe uI + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Topology Classical +namespace ClassicalON + +instance sphereProbability_isOpenPos (n : ℕ) [NeZero n] : + (sphereProbability n).IsOpenPosMeasure := by + unfold sphereProbability + exact Measure.isOpenPosMeasure_smul _ (ENNReal.inv_ne_zero.mpr (measure_ne_top _ _)) + +instance sphericalAmplitudeLaw_isOpenPos : sphericalAmplitudeLaw.IsOpenPosMeasure := + continuous_firstAmplitude.isOpenPosMeasure_map (fun r => + ⟨cylindricalSpin r true 0,firstAmplitude_cylindricalSpin r true 0⟩) + +variable {I : Type uI} [Fintype I] + +def upperTent (δ : ℝ) (r : I → Amplitude) : ℝ := ∏ i,max 0 ((r i:ℝ)-(1-δ)) + +theorem continuous_upperTent (δ : ℝ) : Continuous (upperTent (I := I) δ) := by + unfold upperTent + fun_prop + +theorem upperTent_nonneg (δ : ℝ) (r : I → Amplitude) : 0≤upperTent δ r := + Finset.prod_nonneg (fun _ _ => le_max_left _ _) + +theorem upperTent_monotone (δ : ℝ) : Monotone (upperTent (I := I) δ) := by + intro r s hrs + apply Finset.prod_le_prod₀ (fun _ _ => le_max_left _ _) + intro i _ + exact max_le_max le_rfl (sub_le_sub_right (show (r i:ℝ)≤(s i:ℝ) from hrs i) _) + +theorem upperTent_top_pos {δ : ℝ} (hδ : 0<δ) : 0 -(h r*F r)) := ((continuous_upperTent δ).mul hF).neg + have hp : ∀ r,0≤ -(h r*F r) := by + intro r + by_cases hr : h r=0 + · simp [hr] + · have hx := hd (upperTent_support_ball hδ hr) + rw [Real.dist_eq,abs_lt] at hx + have hfn : F r<0 := by linarith + exact neg_nonneg.mpr (mul_nonpos_of_nonneg_of_nonpos (upperTent_nonneg δ r) hfn.le) + have hs : (Function.support (fun r => -(h r*F r))).Nonempty := by + refine ⟨⊤,?_⟩ + exact neg_ne_zero.mpr (mul_ne_zero (upperTent_top_pos hδ).ne' hneg.ne) + have hi : 0<∫ r,-(h r*F r) ∂μ := + (integral_pos_iff_support_of_nonneg hp (compact_integrable hc)).2 + (hc.isOpen_support.measure_pos μ hs) + rw [integral_neg] at hi + have hn := ht h (continuous_upperTent δ) (upperTent_nonneg δ) (upperTent_monotone δ) + linarith + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/WeightedLinear.lean b/lean/OAI/Probability/ClassicalON/WeightedLinear.lean new file mode 100644 index 0000000000000000000000000000000000000000..de2de0914e499822459ed9cf63c7b568c8bba100 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/WeightedLinear.lean @@ -0,0 +1,61 @@ +import OAI.Probability.ClassicalON.GibbsDerivative + +namespace OAI + +universe uE uX + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ClassicalON + +section +variable {X : Type uX} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] + [BorelSpace X] (μ : Measure X) [IsProbabilityMeasure μ] + {w : X → ℝ} + +omit [TopologicalSpace X] [CompactSpace X] [BorelSpace X] [IsProbabilityMeasure μ] in +theorem weightedMean_const_mul (c : ℝ) (f : X → ℝ) : + weightedMean μ w (fun x => c*f x)=c*weightedMean μ w f := by + unfold weightedMean + simp only [show (fun x => w x*(c*f x))=(fun x => c*(w x*f x)) from by funext; ring, + integral_const_mul] + ring + +theorem weightedMean_add (hw : Continuous w) {f g : X → ℝ} (hf : Continuous f) (hg : Continuous g) : + weightedMean μ w (fun x => f x+g x)=weightedMean μ w f+weightedMean μ w g := by + unfold weightedMean + simp_rw [mul_add] + have hI : Integrable (fun x => w x*f x) μ := compact_integrable (by fun_prop) + have hJ : Integrable (fun x => w x*g x) μ := compact_integrable (by fun_prop) + rw [integral_add hI hJ,add_div] + +theorem weightedMean_sum (hw : Continuous w) {E : Type uE} [Fintype E] (f : E → X → ℝ) + (hf : ∀ e,Continuous (f e)) : weightedMean μ w (fun x => ∑ e,f e x)= + ∑ e,weightedMean μ w (f e) := by + unfold weightedMean + simp_rw [Finset.mul_sum] + have hI (e : E) : Integrable (fun x => w x*f e x) μ := compact_integrable (by fun_prop) + rw [integral_finsetSum _ (fun e _ => hI e),Finset.sum_div] + +omit [TopologicalSpace X] [CompactSpace X] [BorelSpace X] [IsProbabilityMeasure μ] in +theorem exponentialMean_const_mul (H : X → ℝ) (c : ℝ) (f : X → ℝ) : + exponentialMean μ H (fun x => c*f x)=c*exponentialMean μ H f := + weightedMean_const_mul μ c f + +theorem exponentialMean_sum {E : Type uE} [Fintype E] {H : X → ℝ} + (hH : Continuous H) (f : E → X → ℝ) (hf : ∀ e,Continuous (f e)) : + exponentialMean μ H (fun x => ∑ e,f e x)=∑ e,exponentialMean μ H (f e) := + weightedMean_sum μ hH.rexp f hf + +omit [TopologicalSpace X] [CompactSpace X] [BorelSpace X] in +theorem exponentialMean_zero (f : X → ℝ) : + exponentialMean μ (fun _ => 0) f=∫ x,f x ∂μ := by + simp [exponentialMean,weightedMean] + +end +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/WeightedProduct.lean b/lean/OAI/Probability/ClassicalON/WeightedProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba08b5af1fd0e71560d83f8e8f49d64efbf572b9 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/WeightedProduct.lean @@ -0,0 +1,28 @@ +import OAI.Probability.ClassicalON.ProductGrouping + +namespace OAI + +universe uA uK uV + +noncomputable section +open MeasureTheory Set +open scoped BigOperators Classical +namespace ClassicalON +variable {V : Type uV} {K : Type uK} [Fintype V] [Fintype K] +variable (A : V → Type uA) [∀ v,MeasurableSpace (A v)] (label : V → K) + +theorem weightedMean_grouped_product (μ : (v : V) → Measure (A v)) [∀ v,SigmaFinite (μ v)] + (w f : (k : K) → ((v : {v // label v=k}) → A v.val) → ℝ) : + weightedMean (Measure.pi μ) (fun s => ∏ k,w k (fun v => s v.val)) + (fun s => ∏ k,f k (fun v => s v.val))= + ∏ k,weightedMean (Measure.pi (fun v : {v // label v=k} => μ v.val)) (w k) (f k) := by + unfold weightedMean + simp_rw [← Finset.prod_mul_distrib] + rw [integral_grouped_product A label μ (fun k s => w k s*f k s), + integral_grouped_product A label μ w,Finset.prod_div_distrib] + +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/ClassicalON/WeightedTilt.lean b/lean/OAI/Probability/ClassicalON/WeightedTilt.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecff0da7d8a7dd7d9c1a92c6308172e07bc8f168 --- /dev/null +++ b/lean/OAI/Probability/ClassicalON/WeightedTilt.lean @@ -0,0 +1,80 @@ +import OAI.Probability.ClassicalON.FerromagneticMean + +namespace OAI + +universe uX uY + +noncomputable section +open MeasureTheory +namespace ClassicalON + +section Tilt +variable {X : Type uX} [Preorder X] [TopologicalSpace X] [CompactSpace X] + [MeasurableSpace X] [BorelSpace X] {μ : Measure X} [IsProbabilityMeasure μ] + +theorem weightedMean_tilt_mono {w v f : X → ℝ} (hw : Continuous w) (hv : Continuous v) + (hp : ∀ x,0 v x/w x)) : weightedMean μ w f ≤ weightedMean μ v f := by + have hrc : Continuous (fun x => v x/w x) := hv.div hw (fun x => (hp x).ne') + have h := hA f (fun x => v x/w x) hf hrc hfn + (fun x => div_nonneg (hvp x).le (hp x).le) hfm hr + rw [weightedMean_inequality_iff hw hp] at h + have he1 : (fun x => w x*(v x/w x))=v := by + funext x + field_simp [(hp x).ne'] + have he2 : (fun x => w x*(f x*(v x/w x)))=(fun x => v x*f x) := by + funext x + field_simp [(hp x).ne'] + rw [he1,he2] at h + unfold weightedMean + exact (div_le_div_iff₀ (compact_integral_pos hw hp) (compact_integral_pos hv hvp)).2 (by nlinarith) + +end Tilt + +section Product +variable {X : Type uX} {Y : Type uY} [TopologicalSpace X] [CompactSpace X] [MeasurableSpace X] [BorelSpace X] + [TopologicalSpace Y] [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] + [SecondCountableTopology X] [FirstCountableTopology Y] [LocallyCompactSpace Y] + (μ : Measure X) (ν : Measure Y) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] + +def marginalWeight (w : Y×X → ℝ) (y : Y) : ℝ := ∫ x,w (y,x) ∂μ + +def conditionalMean (w f : Y×X → ℝ) (y : Y) : ℝ := + weightedMean μ (fun x => w (y,x)) (fun x => f (y,x)) + +omit [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] [SecondCountableTopology X] in +theorem marginalWeight_continuous {w : Y×X → ℝ} (hw : Continuous w) : + Continuous (marginalWeight μ w) := compact_parametric_integral _ hw + +omit [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] [SecondCountableTopology X] + [FirstCountableTopology Y] [LocallyCompactSpace Y] in +theorem marginalWeight_pos {w : Y×X → ℝ} (hw : Continuous w) (hp : ∀ p,0 hp (y,x)) + +omit [CompactSpace Y] [MeasurableSpace Y] [BorelSpace Y] [SecondCountableTopology X] in +theorem conditionalMean_continuous {w f : Y×X → ℝ} (hw : Continuous w) (hf : Continuous f) + (hp : ∀ p,0 (marginalWeight_pos μ hw hp y).ne') + +omit [FirstCountableTopology Y] [LocallyCompactSpace Y] in +theorem weightedMean_prod {w f : Y×X → ℝ} (hw : Continuous w) (hf : Continuous f) + (hp : ∀ p,0 w p*f p) (compact_integrable (show Continuous (fun p => w p*f p) from hw.mul hf)), + integral_prod w (compact_integrable hw)] + congr 1 + apply integral_congr_ae + filter_upwards with y + dsimp only [marginalWeight,conditionalMean,weightedMean] + have hm : (∫ x,w (y,x) ∂μ)≠0 := (marginalWeight_pos μ hw hp y).ne' + field_simp + +end Product +end ClassicalON + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/AcceptedChain.lean b/lean/OAI/Probability/Contingency/AcceptedChain.lean new file mode 100644 index 0000000000000000000000000000000000000000..31c3adbe8fdaa9e23430d3fdb5b470b6f22ae50b --- /dev/null +++ b/lean/OAI/Probability/Contingency/AcceptedChain.lean @@ -0,0 +1,715 @@ +import Mathlib +import OAI.Probability.Contingency.ChildLogConcavity +import OAI.Probability.Contingency.SafeBins + +namespace OAI + +/-! Accepted Chain. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.FiniteChain +noncomputable section +variable {V : Type*} [Fintype V] [DecidableEq V] [Nonempty V] + + + +structure AcceptedData (V : Type*) [Fintype V] where + f : V → ℝ + fpos : ∀ x, 0 A.fpos x) Finset.univ_nonempty + +def rate (x y : V) : ℝ := A.q*A.count x y/A.f x + +def kernel (x y : V) : ℝ := if x=y then 1-∑ z,A.rate x z else A.rate x y + +omit [DecidableEq V] [Nonempty V] in +theorem rate_nonneg (x y : V) : 0≤A.rate x y := + div_nonneg (mul_nonneg A.qpos (A.nonneg x y)) (A.fpos x).le + +omit [DecidableEq V] [Nonempty V] in +theorem rate_sum (x : V) : (∑ y,A.rate x y)≤1/2 := by + simp only [rate,← Finset.sum_div,← Finset.mul_sum] + apply (div_le_iff₀ (A.fpos x)).mpr + have := A.hold x + linarith + +omit [DecidableEq V] [Nonempty V] in +@[simp] theorem rate_self (x : V) : A.rate x x=0 := by simp [rate,A.diagonal] + +def chain : Chain V where + π := fun x => A.f x/A.total + P := A.kernel + positive := fun x => div_pos (A.fpos x) A.total_pos + normalized := by simp only [← Finset.sum_div]; exact div_self A.total_pos.ne' + nonneg := by + intro x y + by_cases h : x=y + · subst y; simp only [kernel,ite_true] + linarith [A.rate_sum x] + · simp only [kernel,ite_eq_right h]; exact A.rate_nonneg x y + stochastic := by + intro x + have he : (∑ y,A.kernel x y)=1-∑ y,A.rate x y+∑ y,A.rate x y := by + calc + _ = ∑ y, ((if x=y then 1-∑ z,A.rate x z else 0)+A.rate x y) := by + apply Finset.sum_congr rfl; intro y _ + by_cases h : x=y + · subst y; simp [kernel] + · simp [kernel,h] + _ = _ := by simp [Finset.sum_add_distrib] + rw [he]; ring + reversible := by + intro x y + by_cases h : x=y + · subst y; rfl + · simp only [kernel,ite_eq_right h,ite_eq_right (Ne.symm h),rate] + rw [A.symmetric] + field_simp [A.total_pos.ne',(A.fpos x).ne',(A.fpos y).ne'] + lazy := by + intro x + simp only [kernel,ite_true] + linarith [A.rate_sum x] + +@[simp] theorem chain_pi (x : V) : A.chain.π x=A.f x/A.total := rfl +@[simp] theorem chain_P (x y : V) : A.chain.P x y=A.kernel x y := rfl + +theorem offdiagonal_flow (x y : V) (h : x≠y) : + A.chain.π x*A.chain.P x y=A.q*A.count x y/A.total := by + simp only [chain_pi,chain_P,kernel,ite_eq_right h,rate] + field_simp [(A.fpos x).ne'] + +theorem energy_formula (H : V → ℝ) : + A.chain.energy H = (A.q/A.total)*(∑ x,∑ y,A.count x y*(H x-H y)^2)/2 := by + unfold Chain.energy + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro x _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro y _ + by_cases h : x=y + · subst y; simp + · rw [A.offdiagonal_flow x y h]; ring + + + +theorem variance_formula (H : V → ℝ) : + A.chain.variance H = weightedVariance A.f H/A.total := by + unfold Chain.variance Chain.mean weightedVariance + simp only [chain_pi] + have he : (∑ x,A.f x/A.total*H x)=(∑ x,A.f x*H x)/A.total := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl; intro x _; ring + rw [he] + simp only [weightedMean,totalWeight,total,Finset.sum_div] + apply Finset.sum_congr rfl; intro x _ + ring + +end AcceptedData +end +end Contingency.FiniteChain + + + + + +open scoped BigOperators +namespace Contingency.FiniteChain.Chain +noncomputable section +variable {V : Type*} [Fintype V] [DecidableEq V] (C : Chain V) + +def mass (A : Finset V) : ℝ := ∑ x ∈ A, C.π x +def cut (A : Finset V) : ℝ := ∑ x, ∑ y, + if x∈A ∧ y∉A then C.π x*C.P x y else 0 +def variationEnergy (f : V → ℝ) : ℝ := + (∑ x, ∑ y, C.π x*C.P x y*|f x-f y|)/2 + +def positiveSupport (f : V → ℝ) : Finset V := Finset.univ.filter fun x => 0 (C.positive x).le) + +omit [DecidableEq V] in +theorem mass_nonneg (A : Finset V) : 0≤C.mass A := + Finset.sum_nonneg fun x _ => (C.positive x).le + +omit [DecidableEq V] in +theorem mass_le_one (A : Finset V) : C.mass A≤1 := by + have h := C.mass_mono (Finset.subset_univ A) + simpa only [mass,C.normalized] using h + +theorem cut_as_restricted (A : Finset V) : + C.cut A=∑ x∈A, ∑ y∈Finset.univ\A, C.π x*C.P x y := by + have hn : Finset.univ.filter (fun x : V => x∉A)=Finset.univ\A := by ext; simp + simp only [cut,ite_and,Finset.sum_ite_irrel,Finset.sum_const_zero,← Finset.sum_filter] + rw [hn] + simp only [Finset.filter_mem_eq_inter,Finset.univ_inter] + +theorem indicator_energy (A : Finset V) : + C.variationEnergy (fun x => if x∈A then 1 else 0)=C.cut A := by + have he (x y : V) : + C.π x*C.P x y*|(if x∈A then 1 else 0)-(if y∈A then 1 else 0)| = + (if x∈A ∧ y∉A then C.π x*C.P x y else 0)+ + (if y∈A ∧ x∉A then C.π y*C.P y x else 0) := by + by_cases hx : x∈A <;> by_cases hy : y∈A <;> simp [hx,hy,C.reversible] + have hs : (∑ x, ∑ y, if y∈A ∧ x∉A then C.π y*C.P y x else 0)=C.cut A := by + rw [Finset.sum_comm]; rfl + simp only [variationEnergy,he,Finset.sum_add_distrib] + rw [hs] + change (C.cut A+C.cut A)/2=C.cut A + ring + + + +theorem coarea (κ : ℝ) + (hcut : ∀ A : Finset V, κ*min (C.mass A) (1-C.mass A)≤C.cut A) + (f : V → ℝ) (hf : ∀ x, 0≤f x) (hs : C.mass (positiveSupport f)≤1/2) : + κ*C.mean f≤C.variationEnergy f := by + generalize hn : (positiveSupport f).card=n + induction n using Nat.strong_induction_on generalizing f with + | h n ih => + by_cases hz : positiveSupport f=∅ + · have hf0 : ∀ x, f x=0 := by + intro x + have hh : ¬0 if 0 hxg (he.symm ▸ hx)⟩ + have hgS : C.mass (positiveSupport g)≤1/2 := (C.mass_mono hsub).trans hs + have hi := ih _ hlt g hg hgS rfl + have hc : κ*C.mass (positiveSupport f)≤C.cut (positiveSupport f) := by + have hh := hcut (positiveSupport f) + rwa [min_eq_left (by linarith)] at hh + have decomp (y : V) : f y=δ*(if y∈positiveSupport f then 1 else 0)+g y := by + by_cases hy : 0 by_cases hz : 0 g x^2))^2 ≤ 2*C.energy g*C.normSq g := by + have hc : (∑ xy : V×V, C.π xy.1*C.P xy.1 xy.2*|g xy.1^2-g xy.2^2|)^2 ≤ + (∑ xy : V×V, C.π xy.1*C.P xy.1 xy.2*(g xy.1-g xy.2)^2)* + (∑ xy : V×V, C.π xy.1*C.P xy.1 xy.2*(g xy.1+g xy.2)^2) := by + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul + · intro xy _; exact mul_nonneg (mul_nonneg (C.positive _).le (C.nonneg _ _)) (sq_nonneg _) + · intro xy _; exact mul_nonneg (mul_nonneg (C.positive _).le (C.nonneg _ _)) (sq_nonneg _) + · intro xy _; rw [mul_pow,sq_abs]; nlinarith only [] + have hp : (∑ x, ∑ y, C.π x*C.P x y*(g x+g y)^2)≤4*C.normSq g := by + calc + _ ≤ ∑ x, ∑ y, (2*(C.π x*C.P x y*g x^2)+2*(C.π x*C.P x y*g y^2)) := by + apply Finset.sum_le_sum; intro x _ + apply Finset.sum_le_sum; intro y _ + have hh : (g x+g y)^2≤2*g x^2+2*g y^2 := by nlinarith [sq_nonneg (g x-g y)] + have hm := mul_le_mul_of_nonneg_left hh (mul_nonneg (C.positive x).le (C.nonneg x y)) + nlinarith only [hm] + _ = _ := by + simp only [Finset.sum_add_distrib,← Finset.mul_sum] + rw [C.edge_sums_left,C.edge_sums_right]; ring + have he : 0≤C.energy g := by + unfold energy + apply div_nonneg _ (by norm_num) + exact Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => + mul_nonneg (mul_nonneg (C.positive x).le (C.nonneg x y)) (sq_nonneg _) + simp only [Fintype.sum_prod_type] at hc + have hh := mul_le_mul_of_nonneg_left hp he + unfold variationEnergy energy at * + nlinarith only [hc,hh] + +theorem small_support_poincare (κ : ℝ) (hκ : 0<κ) + (hcut : ∀ A : Finset V, κ*min (C.mass A) (1-C.mass A)≤C.cut A) + (g : V → ℝ) (hg : ∀ x, 0≤g x) (hs : C.mass (positiveSupport g)≤1/2) : + C.normSq g ≤ (2/κ^2)*C.energy g := by + have hs' : positiveSupport (fun x => g x^2)=positiveSupport g := by + ext x + simp only [positiveSupport,Finset.mem_filter,Finset.mem_univ,true_and] + constructor + · intro h; exact lt_of_le_of_ne (hg x) (Ne.symm (sq_pos_iff.mp h)) + · intro h; exact sq_pos_of_pos h + have hc := C.coarea κ hcut (fun x => g x^2) (fun x => sq_nonneg _) (hs' ▸ hs) + change κ*C.normSq g ≤ _ at hc + have hv : 0≤C.variationEnergy (fun x => g x^2) := by + unfold variationEnergy + apply div_nonneg _ (by norm_num) + exact Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => + mul_nonneg (mul_nonneg (C.positive x).le (C.nonneg x y)) (abs_nonneg _) + have hh := (sq_le_sq₀ (mul_nonneg hκ.le (C.normSq_nonneg g)) hv).mpr hc + have hcs := C.variation_square_cauchy g + by_cases hz : C.normSq g=0 + · rw [hz] + apply mul_nonneg (by positivity) + unfold energy + apply div_nonneg _ (by norm_num) + exact Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => + mul_nonneg (mul_nonneg (C.positive x).le (C.nonneg x y)) (sq_nonneg _) + · have hn : 0 a f x 1/2≤C.mass (Finset.univ.filter fun y => f y≤f x) + have hA : A.Nonempty := by + obtain ⟨x,hx,hmax⟩ := Finset.exists_max_image Finset.univ f hV + refine ⟨x,?_⟩ + simp only [A,Finset.mem_filter,Finset.mem_univ,true_and] + have he : Finset.univ.filter (fun y => f y≤f x)=Finset.univ := by + ext y; simp [hmax y (Finset.mem_univ y)] + rw [he,mass,C.normalized] + norm_num + obtain ⟨x,hx,hmin⟩ := Finset.exists_min_image A f hA + have hmed : 1/2≤C.mass (Finset.univ.filter fun y => f y≤f x) := by simpa [A] using hx + refine ⟨f x,?_,?_⟩ + · have he : C.mass (Finset.univ.filter fun y => f x f y≤f x)=1 := by + simp only [mass,Finset.sum_filter,← Finset.sum_add_distrib] + calc + _ = ∑ y, C.π y := by + apply Finset.sum_congr rfl; intro y _ + by_cases h : f x f y f y f y≤f z) := by + intro y hy + simp only [Finset.mem_filter,Finset.mem_univ,true_and] + exact hmax y hy + have hzA : z∈A := by + simp only [A,Finset.mem_filter,Finset.mem_univ,true_and] + exact hl.le.trans (C.mass_mono hsub) + exact (not_le.mpr hzlt) (hmin z hzA) + +omit [DecidableEq V] in +theorem variance_le_constant (f : V → ℝ) (a : ℝ) : + C.variance f≤∑ x, C.π x*(f x-a)^2 := by + have hm : (∑ x, C.π x*(f x-C.mean f))=0 := by + simp only [mul_sub,Finset.sum_sub_distrib,← Finset.sum_mul,C.normalized,one_mul] + change C.mean f-C.mean f=0 + ring + have he (x : V) : C.π x*(f x-a)^2 = + C.π x*(f x-C.mean f)^2 + 2*(C.mean f-a)*(C.π x*(f x-C.mean f)) + + (C.mean f-a)^2*C.π x := by ring + simp only [he,Finset.sum_add_distrib,← Finset.mul_sum,hm,C.normalized,mul_zero,add_zero,mul_one] + change C.variance f≤C.variance f+(C.mean f-a)^2 + exact le_add_of_nonneg_right (sq_nonneg _) + +theorem positive_negative_squares (u : ℝ) : (max u 0)^2+(max (-u) 0)^2=u^2 := by + by_cases h : 0≤u + · rw [max_eq_left h,max_eq_right (neg_nonpos.mpr h)]; ring + · rw [max_eq_right (le_of_not_ge h),max_eq_left (by linarith)]; ring + +theorem positive_negative_edge (u v : ℝ) : + (max u 0-max v 0)^2+(max (-u) 0-max (-v) 0)^2≤(u-v)^2 := by + by_cases hu : 0≤u <;> by_cases hv : 0≤v + · rw [max_eq_left hu,max_eq_left hv,max_eq_right (neg_nonpos.mpr hu),max_eq_right (neg_nonpos.mpr hv)] + simp + · have hv' : v≤0 := le_of_not_ge hv + rw [max_eq_left hu,max_eq_right hv',max_eq_right (neg_nonpos.mpr hu),max_eq_left (neg_nonneg.mpr hv')] + nlinarith [mul_nonpos_of_nonneg_of_nonpos hu hv'] + · have hu' : u≤0 := le_of_not_ge hu + rw [max_eq_right hu',max_eq_left hv,max_eq_left (neg_nonneg.mpr hu'),max_eq_right (neg_nonpos.mpr hv)] + nlinarith [mul_nonpos_of_nonpos_of_nonneg hu' hv] + · have hu' : u≤0 := le_of_not_ge hu + have hv' : v≤0 := le_of_not_ge hv + rw [max_eq_right hu',max_eq_right hv',max_eq_left (neg_nonneg.mpr hu'),max_eq_left (neg_nonneg.mpr hv')] + nlinarith + + +theorem cheeger_poincare (κ : ℝ) (hκ : 0<κ) + (hcut : ∀ A : Finset V, κ*min (C.mass A) (1-C.mass A)≤C.cut A) + (f : V → ℝ) : C.variance f≤(2/κ^2)*C.energy f := by + obtain ⟨a,hupper,hlower⟩ := C.median_exists f + let g := fun x => max (f x-a) 0 + let h := fun x => max (a-f x) 0 + have hgS : positiveSupport g=Finset.univ.filter (fun x => a f x le_max_right _ _) (by rw [hgS]; exact hupper) + have hh := C.small_support_poincare κ hκ hcut h (fun x => le_max_right _ _) (by rw [hhS]; exact hlower) + have hs : C.normSq g+C.normSq h=∑ x, C.π x*(f x-a)^2 := by + simp only [normSq,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl; intro x _ + have he := positive_negative_squares (f x-a) + have he' : (g x)^2+(h x)^2=(f x-a)^2 := by + simpa only [g,h,neg_sub] using he + nlinarith only [congrArg (fun z => C.π x*z) he'] + have he : C.energy g+C.energy h≤C.energy f := by + unfold energy + rw [← add_div] + apply div_le_div_of_nonneg_right _ (by norm_num) + simp only [← Finset.sum_add_distrib] + apply Finset.sum_le_sum; intro x _ + apply Finset.sum_le_sum; intro y _ + have he := positive_negative_edge (f x-a) (f y-a) + have he' : (g x-g y)^2+(h x-h y)^2≤(f x-f y)^2 := by + simpa only [g,h,neg_sub,sub_sub_sub_cancel_right] using he + have hm := mul_le_mul_of_nonneg_left he' (mul_nonneg (C.positive x).le (C.nonneg x y)) + nlinarith only [hm] + have hv := C.variance_le_constant f a + rw [← hs] at hv + have he' := mul_le_mul_of_nonneg_left he (show 0≤2/κ^2 by positivity) + nlinarith only [hg,hh,hv,he'] + +end +end Contingency.FiniteChain.Chain + + + + + +open scoped BigOperators +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} +open Contingency.FiniteChain + +def Adj (v w : Vertex q K) : Prop := ∃ i,neighbors (corner v) (corner w) i + +theorem adj_symm (v w : Vertex q K) : Adj v w ↔ Adj w v := by + constructor <;> rintro ⟨i,hi⟩ <;> exact ⟨i,neighbors_symm _ _ _ hi⟩ + +theorem adj_irrefl (v : Vertex q K) : ¬Adj v v := by + rintro ⟨i,hi⟩ + rcases hi.1 with h | h <;> omega + +def axis {v : Vertex q K} (w : {w : Vertex q K // Adj v w}) : Fin q := w.property.choose + +theorem axis_spec {v : Vertex q K} (w : {w : Vertex q K // Adj v w}) : + neighbors (corner v) (corner w.val) (axis w) := w.property.choose_spec + +def signedAxis {v : Vertex q K} (w : {w : Vertex q K // Adj v w}) : Fin q×Bool := by + classical + exact (axis w,decide ((v (axis w)).val+1=(w.val (axis w)).val)) + +theorem signedAxis_injective (v : Vertex q K) : Function.Injective (@signedAxis q K v) := by + classical + intro w z h + have ha : axis w=axis z := congrArg Prod.fst h + have hb := congrArg Prod.snd h + simp only [signedAxis] at hb + have hw := axis_spec w + have hz := axis_spec z + rw [← ha] at hb hz + apply Subtype.ext + funext j + apply Fin.ext + by_cases hj : j=axis w + · subst j + have hw' := hw.1 + have hz' := hz.1 + dsimp [corner] at hw' hz' + by_cases hw0 : (v (axis w)).val+1=(w.val (axis w)).val <;> + by_cases hz0 : (v (axis w)).val+1=(z.val (axis w)).val <;> + simp [hw0,hz0] at hb <;> omega + · exact (hw.2 j hj).symm.trans (hz.2 j hj) + +theorem neighbor_card (v : Vertex q K) : Nat.card {w : Vertex q K // Adj v w} ≤ 2*q := by + classical + let := Fintype.ofFinite {w : Vertex q K // Adj v w} + have h := Fintype.card_le_of_injective (@signedAxis q K v) (signedAxis_injective v) + simpa [Nat.card_eq_fintype_card,Nat.mul_comm] using h + +def edgeWeight (W : Vertex q K → ℝ) (v w : Vertex q K) : ℝ := by + classical + exact if Adj v w then min (W v) (W w) else 0 + +theorem edgeWeight_nonneg (W : Vertex q K → ℝ) (hW : ∀ v,0 Adj v w) _ (by intro w; simp)] + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ _ := by + have hh : (Nat.card {w : Vertex q K // Adj v w}:ℝ)≤2*q := by exact_mod_cast neighbor_card v + exact mul_le_mul_of_nonneg_right hh (hW v).le + + +def metropolis [Nonempty (Vertex q K)] (W : Vertex q K → ℝ) (hW : ∀ v,0 vw.1∈A ∧ vw.2∉A ∧ Adj vw.1 vw.2) + (by intro vw; simp only [Finset.mem_filter,Finset.mem_univ,true_and]; rfl) + (fun vw => min (W vw.1) (W vw.2)) + rw [hh,Fintype.sum_prod_type] + apply Finset.sum_congr rfl; intro v _ + apply Finset.sum_congr rfl; intro w _ + unfold edgeWeight + by_cases h1 : v∈A <;> by_cases h2 : w∈A <;> by_cases h3 : Adj v w <;> simp [h1,h2,h3] + +theorem metropolis_cut [Nonempty (Vertex q K)] (W : Vertex q K → ℝ) (hW : ∀ v,0 ⟨0,D.Kpos⟩⟩ + exact (metropolis D.weight D.weight_pos p D.d (by linarith [D.hd]) D.hq hp0 hp).chain + +theorem chain_mass (p : ℝ) (hp0 : 0 ≤ p) (hp : p ≤ 1/(8*D.d)) (V : Finset (Vertex q K)) : + (D.chain p hp0 hp).mass V=(∑ v∈V,D.weight v)/D.Z := by + simp only [Chain.mass,chain,AcceptedData.chain,metropolis,AcceptedData.total, Z,Finset.sum_div] + +theorem chain_cut (p : ℝ) (hp0 : 0 ≤ p) (hp : p ≤ 1/(8*D.d)) (V : Finset (Vertex q K)) : + (D.chain p hp0 hp).cut V=p/D.Z*border V D.weight := by + let : Nonempty (Vertex q K) := ⟨fun _ => ⟨0,D.Kpos⟩⟩ + exact metropolis_cut D.weight D.weight_pos p D.d _ D.hq hp0 hp V + +def kappa : ℝ := 1/(100000*D.d^2*K) + +theorem kappa_pos : 0 by exact_mod_cast D.hR i) + (fun j => by exact_mod_cast D.hP j) (fun i => by exact_mod_cast D.hRmax i) + (fun j => by exact_mod_cast D.hPmax j) (fun i j => by exact Nat.cast_nonneg _) + D.widthhi p hplo V hV hVc + have hh' := (div_le_div_iff_of_pos_right D.Zpos).mpr hh + change D.kappa*min (∑ v∈V,D.weight v) (∑ v∈Vᶜ,D.weight v)/D.Z ≤ p*border V D.weight/D.Z at hh' + convert hh' using 1 <;> ring + · have he : Vᶜ=∅ := Finset.not_nonempty_iff_eq_empty.mp hVc + have hzero : min (∑ v∈V,D.weight v) (∑ v∈Vᶜ,D.weight v)=0 := by + rw [he,Finset.sum_empty,min_eq_right (Finset.sum_nonneg fun v _ => (D.weight_pos v).le)] + rw [hzero,zero_div,mul_zero] + apply mul_nonneg (div_nonneg hp0 D.Zpos.le) + unfold border + exact Finset.sum_nonneg fun e _ => le_min (D.weight_pos _).le (D.weight_pos _).le + · have he : V=∅ := Finset.not_nonempty_iff_eq_empty.mp hV + have hzero : min (∑ v∈V,D.weight v) (∑ v∈Vᶜ,D.weight v)=0 := by + rw [he,Finset.sum_empty,min_eq_left (Finset.sum_nonneg fun v _ => (D.weight_pos v).le)] + rw [hzero,zero_div,mul_zero] + apply mul_nonneg (div_nonneg hp0 D.Zpos.le) + unfold border + exact Finset.sum_nonneg fun e _ => le_min (D.weight_pos _).le (D.weight_pos _).le + +theorem chain_poincare (p : ℝ) (hp0 : 0 ≤ p) (hp : p ≤ 1/(8*D.d)) + (hplo : 1/(16*D.d) ≤ p) (f : Vertex q K → ℝ) : + (D.chain p hp0 hp).variance f ≤ (2/D.kappa^2)*(D.chain p hp0 hp).energy f := by + apply (D.chain p hp0 hp).cheeger_poincare D.kappa D.kappa_pos + exact D.chain_conductance p hp0 hp hplo + +end +end Contingency.Dense.BinProblem + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/AllMarginLaw.lean b/lean/OAI/Probability/Contingency/AllMarginLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c6ce337a9b8d7044bb9d2346fa623a0b71e422f --- /dev/null +++ b/lean/OAI/Probability/Contingency/AllMarginLaw.lean @@ -0,0 +1,678 @@ +import Mathlib +import OAI.Probability.Contingency.DirectCases +import OAI.Probability.Contingency.ParseNatRuns + +namespace OAI + +/-! All Margin Law. -/ + +noncomputable section + +open scoped BigOperators +open Filter +open scoped BigOperators +namespace Contingency +noncomputable section +variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) +local instance allMarginLawTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + +namespace Parameters + + +theorem D_positive (m n N : ℕ) : 0 Parameters.D m n (∑ i,r i) +variable (hrc : (∑ i,r i)=∑ j,c j) +local notation "p" => arbitraryDraw r c hrc (2*D) + + +def arbitraryResidual (X : Tables r c) : ℕ := correctionCount p D X + +theorem arbitraryResidual_data : + (∀ X : Tables r c, (arbitraryResidual r c hrc X:ℤ)= + (2:ℤ)^((p).bits+D)-(Fintype.card (Tables r c):ℤ)*((2:ℤ)^D-1)*(p).count X) ∧ + (∑ X,arbitraryResidual r c hrc X)=Fintype.card (Tables r c)*2^(p).bits := by + let := tables_nonempty r c hrc + exact correction_counts p D + (by simpa only [Nat.card_eq_fintype_card] using Parameters.table_card_D_all r c hrc) + (arbitraryDraw_tv r c hrc _ (by have := Parameters.D_positive m n (∑ i,r i); omega)) + +theorem arbitraryResidual_total_pos : 0<∑ X,arbitraryResidual r c hrc X := by + let := tables_nonempty r c hrc + rw [(arbitraryResidual_data r c hrc).2] + exact Nat.mul_pos Fintype.card_pos (by positivity) + + + +theorem arbitrary_corrected_exact (X : Tables r c) : + letI := Classical.decEq (Tables r c) + (1-1/(2:ℝ)^D)*(p).toLaw.mass X+(1/(2:ℝ)^D)* + (∑' j : ℕ,IntegerDraw.stoppingMass (arbitraryResidual r c hrc) j X)= + 1/(Fintype.card (Tables r c):ℝ) := by + classical + let := tables_nonempty r c hrc + have hM : Fintype.card (Tables r c)≤2^D := by + simpa only [Nat.card_eq_fintype_card] using Parameters.table_card_D_all r c hrc + have ht := arbitraryDraw_tv r c hrc (2*D) + (by have := Parameters.D_positive m n (∑ i,r i); omega) + rw [IntegerDraw.rejection_exact _ (arbitraryResidual_total_pos r c hrc) X, + (arbitraryResidual_data r c hrc).2] + push_cast + exact corrected_exact p D hM ht X + +end +end Contingency + + + + + +namespace Contingency.BinaryArithmetic + + +def predCost : PosNum → ℕ + | .one => 1 + | .bit1 _ => 1 + | .bit0 a => predCost a+2 + +theorem predCost_le (a : PosNum) : predCost a ≤ 2*a.natSize := by + induction a <;> simp_all [predCost,PosNum.natSize,Nat.succ_eq_add_one] <;> omega + +theorem pred_size_le (a : PosNum) : a.pred'.natSize ≤ a.natSize := by + rw [Num.natSize_to_nat,PosNum.pred'_to_nat,PosNum.natSize_to_nat] + exact Nat.size_le_size (Nat.pred_le _) + + +def signedSize (z : ZNum) : ℕ := z.abs.natSize + +@[simp] theorem signedSize_pos (a : PosNum) : signedSize (.pos a)=a.natSize := rfl +@[simp] theorem signedSize_neg (a : PosNum) : signedSize (.neg a)=a.natSize := rfl +@[simp] theorem signedSize_zero : signedSize 0=0 := rfl +@[simp] theorem signedSize_toZNum (a : Num) : signedSize a.toZNum=a.natSize := by cases a <;> rfl +@[simp] theorem signedSize_toZNumNeg (a : Num) : signedSize a.toZNumNeg=a.natSize := by cases a <;> rfl + +theorem signedSize_bit0 (a : ZNum) : signedSize a.bit0 ≤ signedSize a+1 := by + cases a <;> simp [signedSize,ZNum.bit0,ZNum.abs,Num.natSize,PosNum.natSize,Nat.succ_eq_add_one] + +theorem predCase_size (a : Num) : (Num.casesOn (motive := fun _ => PosNum) a 1 PosNum.bit1).natSize ≤ a.natSize+1 := by + cases a <;> simp [Num.natSize,PosNum.natSize,Nat.succ_eq_add_one] + +theorem signedSize_bit1 (a : ZNum) : signedSize a.bit1 ≤ signedSize a+1 := by + cases a with + | zero => decide + | pos a => exact le_rfl + | neg a => + change (Num.casesOn (motive := fun _ => PosNum) a.pred' 1 PosNum.bit1).natSize ≤ a.natSize+1 + exact (predCase_size a.pred').trans (by have := pred_size_le a; omega) + +theorem signedSize_bitm1 (a : ZNum) : signedSize a.bitm1 ≤ signedSize a+1 := by + cases a with + | zero => decide + | neg a => exact le_rfl + | pos a => + change (Num.casesOn (motive := fun _ => PosNum) a.pred' 1 PosNum.bit1).natSize ≤ a.natSize+1 + exact (predCase_size a.pred').trans (by have := pred_size_le a; omega) + +theorem sub'_size (a b : PosNum) : signedSize (a.sub' b) ≤ a.natSize+b.natSize := by + induction a generalizing b with + | one => + change signedSize ((1:PosNum).sub' b) ≤ _ + rw [PosNum.one_sub',signedSize_toZNumNeg] + have := pred_size_le b + simp only [PosNum.natSize]; omega + | bit0 a ih => + cases b with + | one => + change signedSize ((PosNum.bit0 a).pred'.toZNum) ≤ _ + rw [signedSize_toZNum] + exact (pred_size_le a.bit0).trans (by omega) + | bit0 b => + have := (signedSize_bit0 (a.sub' b)).trans (Nat.add_le_add_right (ih b) 1) + simp only [PosNum.sub',PosNum.natSize,Nat.succ_eq_add_one]; omega + | bit1 b => + have := (signedSize_bitm1 (a.sub' b)).trans (Nat.add_le_add_right (ih b) 1) + simp only [PosNum.sub',PosNum.natSize,Nat.succ_eq_add_one]; omega + | bit1 a ih => + cases b with + | one => + change signedSize ((PosNum.bit1 a).pred'.toZNum) ≤ _ + rw [signedSize_toZNum] + exact (pred_size_le a.bit1).trans (by omega) + | bit0 b => + have := (signedSize_bit1 (a.sub' b)).trans (Nat.add_le_add_right (ih b) 1) + simp only [PosNum.sub',PosNum.natSize,Nat.succ_eq_add_one]; omega + | bit1 b => + have := (signedSize_bit0 (a.sub' b)).trans (Nat.add_le_add_right (ih b) 1) + simp only [PosNum.sub',PosNum.natSize,Nat.succ_eq_add_one]; omega + + +def signedBitCost : ZNum → ℕ + | .zero => 2 + | .pos a => predCost a+2 + | .neg a => predCost a+2 + +theorem signedBitCost_le (a : ZNum) : signedBitCost a ≤ 2*signedSize a+2 := by + cases a with + | zero => decide + | pos a => have := predCost_le a; simpa only [signedBitCost,signedSize_pos] using Nat.add_le_add_right this 2 + | neg a => have := predCost_le a; simpa only [signedBitCost,signedSize_neg] using Nat.add_le_add_right this 2 + + +def subCost : PosNum → PosNum → ℕ + | a,.one => predCost a+2 + | .one,b => predCost b+2 + | .bit0 a,.bit0 b => subCost a b+2 + | .bit1 a,.bit1 b => subCost a b+2 + | .bit0 a,.bit1 b => subCost a b+signedBitCost (a.sub' b)+2 + | .bit1 a,.bit0 b => subCost a b+signedBitCost (a.sub' b)+2 + +theorem subCost_le (a b : PosNum) : subCost a b ≤ 4*(a.natSize+b.natSize+1)^2 := by + induction a generalizing b with + | one => + cases b with + | one => decide + | bit0 b => + have := predCost_le b.bit0 + simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one] at * + nlinarith [Nat.zero_le b.natSize] + | bit1 b => + have := predCost_le b.bit1 + simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one] at * + nlinarith [Nat.zero_le b.natSize] + | bit0 a ih => + cases b with + | one => have := predCost_le a.bit0; simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one] at *; nlinarith + | bit0 b => have := ih b; simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize] + | bit1 b => + have := ih b + have hk : signedBitCost (a.sub' b) ≤ 2*(a.natSize+b.natSize)+2 := + (signedBitCost_le (a.sub' b)).trans (by have := sub'_size a b; omega) + simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith + | bit1 a ih => + cases b with + | one => have := predCost_le a.bit1; simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one] at *; nlinarith + | bit0 b => + have := ih b + have hk : signedBitCost (a.sub' b) ≤ 2*(a.natSize+b.natSize)+2 := + (signedBitCost_le (a.sub' b)).trans (by have := sub'_size a b; omega) + simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith + | bit1 b => have := ih b; simp only [subCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize] + + +def divisionAuxCost (r : Num) (d : PosNum) : ℕ := + match r with + | .zero => d.natSize+4 + | .pos a => subCost a d+4 + +theorem divisionAuxCost_le (r : Num) (d : PosNum) : + divisionAuxCost r d ≤ 5*(r.natSize+d.natSize+2)^2 := by + cases r with + | zero => simp only [divisionAuxCost,Num.natSize]; nlinarith [Nat.zero_le d.natSize] + | pos a => + have := subCost_le a d + simp only [divisionAuxCost,Num.natSize]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le d.natSize] + + + +def divisionCost (d : PosNum) : PosNum → ℕ + | .one => divisionAuxCost 1 d+2 + | .bit0 n => divisionCost d n+divisionAuxCost (Num.bit0 (d.divMod n).2) d+2 + | .bit1 n => divisionCost d n+divisionAuxCost (Num.bit1 (d.divMod n).2) d+2 + +theorem remainder_size (d n : PosNum) : (d.divMod n).2.natSize ≤ d.natSize := by + apply numSize_le_of_lt + rw [← (PosNum.divMod_to_nat d n).2] + have hd : (d:ℕ)<2^d.natSize := by rw [PosNum.natSize_to_nat]; exact Nat.size_le.mp le_rfl + exact (Nat.mod_lt _ (PosNum.to_nat_pos d)).trans hd + +theorem numBit0_size (n : Num) : (Num.bit0 n).natSize ≤ n.natSize+1 := by + cases n <;> simp [Num.bit0,Num.natSize,PosNum.natSize,Nat.succ_eq_add_one] + +theorem numBit1_size (n : Num) : (Num.bit1 n).natSize ≤ n.natSize+1 := by + cases n <;> simp [Num.bit1,Num.natSize,PosNum.natSize,Nat.succ_eq_add_one] + +theorem divisionCost_le (d n : PosNum) : + divisionCost d n ≤ n.natSize*(7*(2*d.natSize+3)^2) := by + have haux (r : Num) (hr : r.natSize ≤ d.natSize+1) : + divisionAuxCost r d+2 ≤ 7*(2*d.natSize+3)^2 := by + have hh := (divisionAuxCost_le r d).trans + (Nat.mul_le_mul_left 5 (Nat.pow_le_pow_left (by omega : r.natSize+d.natSize+2 ≤ 2*d.natSize+3) 2)) + nlinarith [Nat.zero_le d.natSize] + induction n with + | one => + simpa only [divisionCost,PosNum.natSize,one_mul] using haux 1 (by change 1 ≤ d.natSize+1; omega) + | bit0 n ih => + have hh := haux (Num.bit0 (d.divMod n).2) + ((numBit0_size _).trans (Nat.add_le_add_right (remainder_size d n) 1)) + simp only [divisionCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith only [ih,hh] + | bit1 n ih => + have hh := haux (Num.bit1 (d.divMod n).2) + ((numBit1_size _).trans (Nat.add_le_add_right (remainder_size d n) 1)) + simp only [divisionCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith only [ih,hh] + + + +theorem division_certificate (d n : PosNum) : + ((d.divMod n).1:ℕ)=(n:ℕ)/(d:ℕ) ∧ + ((d.divMod n).2:ℕ)=(n:ℕ)%(d:ℕ) ∧ + divisionCost d n ≤ n.natSize*(7*(2*d.natSize+3)^2) := + ⟨(PosNum.divMod_to_nat d n).1.symm,(PosNum.divMod_to_nat d n).2.symm,divisionCost_le d n⟩ + +end Contingency.BinaryArithmetic + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section + +namespace Grid + +theorem vertex_card (q K : ℕ) : Nat.card (Vertex q K)=K^q := by + rw [Nat.card_eq_fintype_card] + simp [Vertex] + +theorem vertex_card_dyadic {q K d b : ℕ} (hq : q≤d) (hK : K≤2^b) : + Nat.card (Vertex q K)≤2^(d*b) := by + rw [vertex_card] + calc + K^q ≤ (2^b)^q := Nat.pow_le_pow_left hK _ + _ ≤ (2^b)^d := Nat.pow_le_pow_right (by positivity) hq + _ = _ := by rw [← pow_mul]; congr 1; ring + +end Grid +namespace Dense + +theorem offsets_card_dyadic {q d b : ℕ} (w : Fin q → ℕ) + (hq : q≤d) (hw : ∀ i,w i≤2^b) : Nat.card (Offsets w)≤2^(d*b) := by + rw [Nat.card_eq_fintype_card] + simp only [Offsets,Fintype.card_pi,Fintype.card_fin] + calc + (∏ i,w i) ≤ ∏ i : Fin q,2^b := Finset.prod_le_prod (fun i _ => hw i) + _ = (2^b)^q := by simp + _ ≤ (2^b)^d := Nat.pow_le_pow_right (by positivity) hq + _ = _ := by rw [← pow_mul]; congr 1; ring + +end Dense +namespace IntegerTabulation + + + +def arithmeticTerms (S V H JD T Jo : ℕ) : ℕ := + S*(H*V^2+V^3+JD*V)+S^2*V+T*S^2+S*V^2+Jo*V + + + +theorem arithmeticTerms_bound (e H JD T Jo : ℕ) : + arithmeticTerms (2^(2*e)) (2^e) H JD T Jo≤ + 2^(10*e)*(H+JD+T+Jo+3) := by + let V := 2^e + have hV : 1≤V := Nat.one_le_pow _ _ (by norm_num) + have h2 : 2^(2*e)=V^2 := by dsimp [V]; rw [← pow_mul]; congr 1; omega + have h10 : 2^(10*e)=V^10 := by dsimp [V]; rw [← pow_mul]; congr 1; omega + rw [h2,h10] + change arithmeticTerms (V^2) V H JD T Jo≤_ + have hp (a : ℕ) (ha : a≤10) : V^a≤V^10 := Nat.pow_le_pow_right hV ha + unfold arithmeticTerms + calc + _ = H*V^4+V^5+JD*V^3+V^5+T*V^4+V^4+Jo*V := by ring + _ ≤ H*V^10+V^10+JD*V^10+V^10+T*V^10+V^10+Jo*V^10 := by + gcongr <;> first | omega | simpa using hp 1 (by omega) + _ = _ := by ring + +end IntegerTabulation +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +open Contingency.Grid +variable {a c q K : ℕ} + + +def cornerEntries (D : BinProblem a c q K) (v : Vertex q K) : + Fin (a+1) → Fin (c+1) → ℤ := + integerComplete D.R D.P (fun i j => D.w (D.e.symm (i,j))*(v (D.e.symm (i,j))).val) + + + +def rationalPenalty (D : BinProblem a c q K) (d : ℕ) (v : Vertex q K) : ℚ := + max 0 (Finset.univ.sup' Finset.univ_nonempty fun s : Fin (a+1)×Fin (c+1) => + -(D.cornerEntries v s.1 s.2:ℚ)/(min (D.R s.1) (D.P s.2):ℕ)-(d:ℚ)/(d:ℚ)^8) + + +def rationalExponent (D : BinProblem a c q K) (d : ℕ) (v : Vertex q K) : ℕ := + (⌊(d:ℚ)^4*D.rationalPenalty d v⌋:ℤ).toNat + +noncomputable section +variable (D : BinProblem a c q K) + +theorem cornerEntries_cast (v : Vertex q K) (i j) : + (D.cornerEntries v i j:ℝ)= + scaled (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths + (fun s => realCorner v (D.e.symm s)) i j := by + unfold cornerEntries + rw [integerComplete_cast] + congr 1 + funext i j + simp [widths,realCorner] + +theorem rationalPenalty_cast (d : ℕ) (hD : D.d=d) (v : Vertex q K) : + (D.rationalPenalty d v:ℝ)= + penalty (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths + (D.d^8) D.d (fun s => realCorner v (D.e.symm s)) := by + unfold rationalPenalty penalty + rw [Rat.cast_max] + simp only [Rat.cast_zero] + congr 1 + rw [Finset.apply_sup'_eq_sup'_comp _ (fun x : ℚ => (x:ℝ)) + (fun x y => Rat.cast_max x y)] + congr 1 + funext s + simp only [Function.comp_apply,Rat.cast_sub,Rat.cast_div,Rat.cast_neg, + Rat.cast_intCast,Rat.cast_natCast,Rat.cast_pow,Nat.cast_min] + rw [D.cornerEntries_cast] + simp [normalized,scale,hD,Rat.cast_min,neg_div] + +theorem rationalExponent_eq (d : ℕ) (hD : D.d=d) (v : Vertex q K) : + D.rationalExponent d v=D.exponent v := by + unfold rationalExponent exponent + congr 1 + rw [← Rat.floor_cast (α:=ℝ)] + simp only [Rat.cast_mul,Rat.cast_pow,Rat.cast_natCast,D.rationalPenalty_cast d hD] + unfold binExponent + rw [hD] + +end +end Contingency.Dense.BinProblem + + + + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +open Contingency.Grid +variable {a c q K : ℕ} + + + +def cellExponent (D : BinProblem a c q K) (d : ℕ) (v : Vertex q K) + (i : Fin (a+1)) (j : Fin (c+1)) : ℤ := + ((-D.cornerEntries v i j*(d:ℤ)^8-(d:ℤ)*(min (D.R i) (D.P j):ℕ))*(d:ℤ)^4) / + ((min (D.R i) (D.P j)*d^8:ℕ):ℤ) + +def integerExponent (D : BinProblem a c q K) (d : ℕ) (v : Vertex q K) : ℕ := + (max 0 (Finset.univ.sup' Finset.univ_nonempty + (fun s : Fin (a+1)×Fin (c+1) => D.cellExponent d v s.1 s.2))).toNat + +noncomputable section +variable (D : BinProblem a c q K) + +theorem cellExponent_eq (d : ℕ) (hd : 0 (d:ℚ)^4*x) + (fun x y => mul_max_of_nonneg x y (by positivity))] + rw [Finset.apply_sup'_eq_sup'_comp _ (fun x : ℚ => (⌊x⌋:ℤ)) + (fun x y => Int.floor_mono.map_max)] + congr 1 + funext s + exact D.cellExponent_eq d hd v s.1 s.2 + +theorem integerExponent_eq (d : ℕ) (hD : D.d=d) (v : Vertex q K) : + D.integerExponent d v=D.exponent v := by + have hd : 0 .push 6 false 1 + | _ => .halt +abbrev pushProgram : Program := ⟨2,8,0,pushCode⟩ +abbrev back : Program := Sequence.program pushProgram 4 0 (Transfer.code (6 : Fin 8) 5) +abbrev program : Program := Sequence.program (Transfer.program (5 : Fin 8) 6) back.labels back.start back.code + +theorem push_noCoin (q) : NoCoin (pushProgram.code q) := by fin_cases q <;> trivial +theorem back_noCoin : ∀ q,NoCoin (back.code q) := by + apply noCoin_sequence _ _ _ _ push_noCoin + intro q; fin_cases q <;> trivial +theorem noCoin : ∀ q,NoCoin (program.code q) := by + apply noCoin_sequence (Transfer.program (5 : Fin 8) 6) back.labels back.start back.code ?_ back_noCoin + intro q; fin_cases q <;> trivial + +theorem back_run (bs : List Bool) (m : Memory 8) (h : m.stack 6=bs) : + (List.replicate (2+(2*(bs.length+1)+2)) false).foldl (fun c b => step back b c) + ⟨some back.start,m⟩= + ⟨none,Transfer.memory (6 : Fin 8) (5 : Fin 8) (false::bs) (m.push 6 false)⟩ := by + have hf : Sequence.FirstHalt pushProgram ⟨some pushProgram.start,m⟩ [false,false] := +by + constructor + · intro h; cases h + constructor + · intro h; cases h + rfl + have he := Sequence.link_run pushProgram 4 0 (Transfer.code (6 : Fin 8) 5) + ⟨some pushProgram.start,m⟩ [false,false] (List.replicate (2*(bs.length+1)+2) false) hf + have ht := Transfer.run (6 : Fin 8) 5 (by decide) (false::bs) (m.push 6 false) + (by simp [Memory.push,h]) + change (List.replicate (2*(bs.length+1)+2) false).foldl + (fun c b => step (Transfer.program (6 : Fin 8) 5) b c) + ⟨some (0 : Fin 4),m.push 6 false⟩=_ at ht + rw [List.replicate_add] + change ([false,false]++List.replicate (2*(bs.length+1)+2) false).foldl + (fun c b => step back b c) ⟨some back.start,m⟩=_ + change ([false,false]++List.replicate (2*(bs.length+1)+2) false).foldl + (fun c b => step back b c) ⟨some back.start,m⟩= + Sequence.right pushProgram 4 0 (Transfer.code (6 : Fin 8) 5) + ((List.replicate (2*(bs.length+1)+2) false).foldl + (fun c b => step (Transfer.program (6 : Fin 8) 5) b c) ⟨some (0 : Fin 4),m.push 6 false⟩) at he + exact he.trans (congrArg (Sequence.right pushProgram 4 0 (Transfer.code (6 : Fin 8) 5)) ht) + + + +theorem pad (bs : List Bool) (m : Memory 8) (h5 : m.stack 5=bs) (h6 : m.stack 6=[]) : + ∃ (t : ℕ) (m' : Memory 8),t≤4*bs.length+8 ∧ m'.stack 5=bs++[false] ∧ + m'.stack 6=[] ∧ (∀ i : Fin 8,i≠5 → i≠6 → m'.stack i=m.stack i) ∧ + m'.input=m.input ∧ m'.outputRev=m.outputRev ∧ + ∀ coins : List Bool,coins.length=t → + coins.foldl (fun c b => step program b c) ⟨some program.start,m⟩=⟨none,m'⟩ := by + let m₁ := Transfer.memory (5 : Fin 8) 6 bs m + have hrun := Transfer.run (5 : Fin 8) 6 (by decide) bs m h5 + have hm₁ := Transfer.memory_fields (5 : Fin 8) 6 (by decide) bs m h5 + have hs6 : m₁.stack 6=bs.reverse := by simpa [m₁,h6] using hm₁.2.1 + let m₂ := Transfer.memory (6 : Fin 8) (5 : Fin 8) (false::bs.reverse) (m₁.push 6 false) + have hs : (m₁.push 6 false).stack 6=false::bs.reverse := by simp [Memory.push,hs6] + have hm₂ := Transfer.memory_fields (6 : Fin 8) 5 (by decide) (false::bs.reverse) (m₁.push 6 false) hs + have hhal : (Transfer.exec (5 : Fin 8) 6 (2*bs.length+2) (Transfer.config 5 6 0 m)).state=none := by rw [hrun] + obtain ⟨k,hk,hfirst⟩ := Sequence.deterministic_first_time (Transfer.program (5 : Fin 8) 6) + (Transfer.deterministic 5 6) (Transfer.config 5 6 0 m) (2*bs.length+2) hhal + have hf := hfirst (List.replicate k false) (by simp) + have hf' : (List.replicate k false).foldl (fun c b => step (Transfer.program (5 : Fin 8) 6) b c) + (Transfer.config 5 6 0 m)=⟨none,m₁⟩ := hf.2.trans hrun + have h₅ : (m₁.push 6 false).stack 5=[] := by simpa [Memory.push] using hm₁.1 + let T := 2+(2*(bs.reverse.length+1)+2) + refine ⟨k+T,m₂,?_,?_,hm₂.1,?_,?_,?_,?_⟩ + · simp only [T,List.length_reverse]; omega + · simpa only [List.reverse_cons,List.reverse_reverse,h₅,List.append_nil] using hm₂.2.1 + · intro i hi hj + exact (hm₂.2.2.1 i hj hi).trans ((show (m₁.push 6 false).stack i=m₁.stack i by simp [Memory.push,hj]).trans (hm₁.2.2.1 i hi hj)) + · exact hm₂.2.2.2.1.trans hm₁.2.2.2.1 + · exact hm₂.2.2.2.2.1.trans hm₁.2.2.2.2.1 + · intro coins hc + rw [Sequence.deterministic_fold program (noCoin_deterministic program noCoin) _ _ + (List.replicate (k+T) false) (by simpa using hc),List.replicate_add] + have he := Sequence.link_run (Transfer.program (5 : Fin 8) 6) back.labels back.start back.code + (Transfer.config 5 6 0 m) (List.replicate k false) (List.replicate T false) hf.1 + rw [hf'] at he + have hb := back_run bs.reverse m₁ hs6 + change (List.replicate k false++List.replicate T false).foldl (fun c b => step program b c) + ⟨some program.start,m⟩= + Sequence.right (Transfer.program (5 : Fin 8) 6) back.labels back.start back.code + ((List.replicate T false).foldl (fun c b => step back b c) ⟨some back.start,m₁⟩) at he + exact he.trans (congrArg (fun c : Config back => + Sequence.right (Transfer.program (5 : Fin 8) 6) back.labels back.start back.code c) hb) + +end Contingency.BitModel.StackCode.HighPad + + + + + + + +namespace Contingency.BitModel.StackCode.PreparedIntegerCall +noncomputable section + +def outputRegister : Fin program.work := ⟨5,by decide⟩ + +theorem finite_memory_safe (N : ℕ) (rest xs : List Bool) + (h : (xs.foldl (fun c b => step program b c) + (initial program (encodeNat N++rest))).state=none) : + ∃ u : Fin (N+1), + (xs.foldl (fun c b => step program b c) (initial program (encodeNat N++rest))).memory.stack outputRegister= + (IntegerDraw.integerWord N u).reverse ∧ + (xs.foldl (fun c b => step program b c) (initial program (encodeNat N++rest))).memory.input=rest ∧ + (xs.foldl (fun c b => step program b c) (initial program (encodeNat N++rest))).memory.outputRev=[] := by + obtain ⟨t,ht,hr⟩ := refinement N rest + let ys := xs++List.replicate t false + have hl : (ys.take t).length=t := by simp [ys] + obtain ⟨c,hc,hm,hi,ho⟩ := hr (ys.take t) hl (ys.drop t) + rw [List.take_append_drop] at hc + have he : ys.foldl (fun c b => step program b c) (initial program (encodeNat N++rest))= + xs.foldl (fun c b => step program b c) (initial program (encodeNat N++rest)) := by + unfold ys + rw [List.foldl_append] + exact Sequence.halted_fold program _ h _ + rw [he] at hc + have ch : c.state=none := by + have hh := h + rw [hc] at hh + exact Option.map_eq_none_iff.mp hh + have ih : ((ys.drop t).foldl (fun c b => step IntegerDraw.program b c) + (initial IntegerDraw.program (IntegerDraw.rawMaximum N))).state=none := by + exact hm.1.symm.trans ch + let b := ys.drop t + have hh : (run IntegerDraw.program (IntegerDraw.rawMaximum N) b.get).state=none := by + simpa only [run,List.ofFn_get] using ih + obtain ⟨u,hu⟩ := IntegerDraw.stack_safe (IntegerDraw.rawMaximum N) b.get hh + let v : Fin (N+1) := ⟨u,by simpa using u.isLt⟩ + refine ⟨v,?_,?_,?_⟩ + · rw [hc] + change c.memory.stack 5=_ + apply hm.2.2.2.trans + have hu' : (b.foldl (fun c b => step IntegerDraw.program b c) + (initial IntegerDraw.program (IntegerDraw.rawMaximum N))).memory.outputRev.reverse= + IntegerDraw.integerWord N v := by + simpa only [run,List.ofFn_get,IntegerDraw.integerWord,IntegerDraw.validWord,v] using hu + simpa only [List.reverse_reverse] using congrArg List.reverse hu' + · rw [hc]; exact hi + · rw [hc]; exact ho + +end +end Contingency.BitModel.StackCode.PreparedIntegerCall + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/BinaryAddition.lean b/lean/OAI/Probability/Contingency/BinaryAddition.lean new file mode 100644 index 0000000000000000000000000000000000000000..3041ed409fb3d930128f5f5551a6b9b4dc0ca6a7 --- /dev/null +++ b/lean/OAI/Probability/Contingency/BinaryAddition.lean @@ -0,0 +1,679 @@ +import Mathlib +import OAI.Probability.Contingency.GreedyTable +import OAI.Probability.Contingency.StackSafety + +namespace OAI + +/-! Binary Addition. -/ + +noncomputable section + + +namespace Contingency.BitModel.StackCode.BinaryAdd +open BinarySubtract +noncomputable section + +theorem value_append (as bs : List Bool) : + value (as++bs)=value as+2^as.length*value bs := by + induction as with + | nil => simp [value] + | cons a as ih => + simp only [List.cons_append,value,List.length_cons,pow_succ,ih] + ring + +theorem full_output_value (ds : List Digit) (c : Bool) : + value (output ds c++[carry ds c])=value (ds.map Digit.a)+value (ds.map Digit.b)+c.toNat := by + rw [value_append,output_length] + simpa only [value,Nat.mul_zero,Nat.add_zero] using (word_identity ds c).symm + + + +theorem add_tape (ds : List Digit) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (h2 : m.stack 2=[]) : + ∃ m' : Memory 4,m'.stack 0=[] ∧ m'.stack 1=[] ∧ + (m'.stack 2).length=ds.length+1 ∧ + value (m'.stack 2).reverse=value (ds.map Digit.a)+value (ds.map Digit.b) ∧ + m'.stack 3=m.stack 3 ∧ m'.input=m.input ∧ m'.outputRev=m.outputRev ∧ + ∀ coins : Fin ((3*ds.length+3)*2)→Bool, + (List.ofFn coins).foldl (fun cfg b => (compile program).step b cfg) + (encode program (config (.start false) m))=encode program ⟨none,m'⟩ := by + let m' := ((wordMemory ds false m).pop 0).push 2 (carry ds false) + have hf := wordMemory_stacks ds false m ha hb + have h0 : m'.stack 0=[] := by simp [m',Memory.push,Memory.pop,hf.1] + have h1 : m'.stack 1=[] := by simpa [m',Memory.push,Memory.pop] using hf.2.1 + have ho : m'.stack 2=carry ds false::(output ds false).reverse := by + simp [m',Memory.push,Memory.pop,hf.2.2.1,h2] + have h3 : m'.stack 3=m.stack 3 := by simpa [m',Memory.push,Memory.pop] using hf.2.2.2.1 + refine ⟨m',h0,h1,?_,?_,h3,hf.2.2.2.2.1,hf.2.2.2.2.2,?_⟩ + · simp [ho,output_length] + · rw [ho,List.reverse_cons,List.reverse_reverse] + simpa using full_output_value ds false + · intro coins + rw [BinarySubtract.fold_compiled] + rw [fold_independent _ (List.replicate (3*ds.length+3) false) (by simp)] + have hr := finish_run ds false m ha hb (List.replicate (3*ds.length) false) (by simp) false false false + have he : List.replicate (3*ds.length+3) false=List.replicate (3*ds.length) false++[false,false,false] := by + rw [List.replicate_add]; rfl + rw [he,hr] + + + +theorem add_naturals (x y n : ℕ) (hx : x.size≤n) (hy : y.size≤n) (m : Memory 4) + (h0 : m.stack 0=bits n x) (h1 : m.stack 1=bits n y) (h2 : m.stack 2=[]) : + ∃ m' : Memory 4,value (m'.stack 2).reverse=x+y ∧ (m'.stack 2).length=n+1 ∧ + ∀ coins : Fin ((3*n+3)*2)→Bool, + (List.ofFn coins).foldl (fun cfg b => (compile program).step b cfg) + (encode program (config (.start false) m))=encode program ⟨none,m'⟩ := by + let ds := digits (bits n x) (bits n y) + have hl : (bits n x).length=(bits n y).length := by rw [bits_length _ _ (Nat.size_le.mp hx),bits_length _ _ (Nat.size_le.mp hy)] + obtain ⟨ha,hb,hd⟩ := digits_maps (bits n x) (bits n y) hl + obtain ⟨m',_,_,hm,he,_,_,_,hr⟩ := add_tape ds m (h0.trans ha.symm) (h1.trans hb.symm) h2 + have hn : ds.length=n := hd.trans (bits_length n x (Nat.size_le.mp hx)) + refine ⟨m',?_,by simpa [hn] using hm,?_⟩ + · simpa [ds,ha,hb,bits_value] using he + · let S : ℕ→Prop := fun T => ∀ coins : Fin T→Bool, + (List.ofFn coins).foldl (fun cfg b => (compile program).step b cfg) + (encode program (config (.start false) m))=encode program ⟨none,m'⟩ + have hr' : S ((3*ds.length+3)*2) := hr + have ht : (3*ds.length+3)*2=(3*n+3)*2 := by rw [hn] + exact Eq.mp (congrArg S ht) hr' + +end +end Contingency.BitModel.StackCode.BinaryAdd + + + + + + + +namespace Contingency.BitModel.StackCode.WeightedScan +open BinarySubtract +noncomputable section + +inductive Q + | start (c : Bool) + | read (c a : Bool) + | place (c a b : Bool) + | advance + | restore + | back (b : Bool) + | selected + | out + | finish + deriving DecidableEq, Fintype + +def label (q : Q) : Fin (Fintype.card Q) := Fintype.equivFin Q q + +def code : Q→Op (Fintype.card Q) 4 + | .start c => .pop 0 (label (if c then .selected else .advance)) (label (.read c false)) (label (.read c true)) + | .read c a => .read (label (.place c a false)) (label (.place c a false)) (label (.place c a true)) + | .place c a b => .push 2 (outBit a b c) (label (.start (nextBorrow a b c))) + | .advance => .push 3 false (label .restore) + | .restore => .pop 2 (label (.start false)) (label (.back false)) (label (.back true)) + | .back b => .push 0 b (label .restore) + | .selected => .pop 3 (label .finish) (label .out) (label .out) + | .out => .emit false (label .selected) + | .finish => .halt + +def program : Program := ⟨Fintype.card Q,4,label (.start false),fun pc => code ((Fintype.equivFin Q).symm pc)⟩ +def config (q : Q) (m : Memory 4) : Config program := ⟨some (label q),m⟩ + +def exec (t : ℕ) (cfg : Config program) : Config program := + (List.replicate t false).foldl (fun cfg b => step program b cfg) cfg + +theorem exec_add (s t : ℕ) (cfg : Config program) : exec (s+t) cfg=exec t (exec s cfg) := by + simp only [exec,List.replicate_add,List.foldl_append] + +@[simp] theorem exec_zero (cfg : Config program) : exec 0 cfg=cfg := rfl +@[simp] theorem exec_one (cfg : Config program) : exec 1 cfg=step program false cfg := rfl + +theorem one_step (q : Q) (m : Memory 4) (coin : Bool) : + step program coin (config q m)=⟨(effect (code q) coin m).1,(effect (code q) coin m).2⟩ := by + simp [step,program,config,label] + +theorem first_step (m : Memory 4) (c a coin : Bool) (as : List Bool) (ha : m.stack 0=a::as) : + step program coin (config (.start c) m)=config (.read c a) (m.pop 0) := by + rw [one_step] + cases a <;> simp [code,effect,branch,ha,config] <;> rfl + +theorem second_step (m : Memory 4) (c a b coin : Bool) (bs : List Bool) (hb : m.input=b::bs) : + step program coin (config (.read c a) m)=config (.place c a b) m.read := by + rw [one_step] + cases b <;> simp [code,effect,branch,hb,config] <;> rfl + +theorem third_step (m : Memory 4) (c a b coin : Bool) : + step program coin (config (.place c a b) m)=config (.start (nextBorrow a b c)) (m.push 2 (outBit a b c)) := by + rw [one_step]; rfl + +def digitMemory (d : Digit) (c : Bool) (m : Memory 4) : Memory 4 := + ((m.pop 0).read).push 2 (outBit d.a d.b c) + +def wordMemory : List Digit→Bool→Memory 4→Memory 4 + | [],_,m => m + | d::ds,c,m => wordMemory ds (nextBorrow d.a d.b c) (digitMemory d c m) + +theorem three_steps (m : Memory 4) (d : Digit) (c : Bool) (as bs : List Bool) + (ha : m.stack 0=d.a::as) (hb : m.input=d.b::bs) : + exec 3 (config (.start c) m)=config (.start (nextBorrow d.a d.b c)) (digitMemory d c m) := by + change step program false (step program false (step program false (config (.start c) m)))=_ + rw [first_step m c d.a false as ha,second_step _ c d.a d.b false bs,third_step] + · rfl + · exact hb + +theorem pass (ds : List Digit) (c : Bool) (m : Memory 4) (rest : List Bool) + (ha : m.stack 0=ds.map Digit.a) (hb : m.input=ds.map Digit.b++rest) : + exec (3*ds.length) (config (.start c) m)=config (.start (borrow ds c)) (wordMemory ds c m) := by + induction ds generalizing c m with + | nil => rfl + | cons d ds ih => + have he : 3*(d::ds).length=3+3*ds.length := by simp; omega + rw [he,exec_add,three_steps m d c _ _ ha hb,ih] + · rfl + · simp [digitMemory,Memory.push,Memory.pop,Memory.read,ha] + · simp [digitMemory,Memory.push,Memory.pop,Memory.read,hb] + +theorem wordMemory_stacks (ds : List Digit) (c : Bool) (m : Memory 4) (rest : List Bool) + (ha : m.stack 0=ds.map Digit.a) (hb : m.input=ds.map Digit.b++rest) : + (wordMemory ds c m).stack 0=[] ∧ + (wordMemory ds c m).stack 2=(output ds c).reverse++m.stack 2 ∧ + (wordMemory ds c m).stack 3=m.stack 3 ∧ + (wordMemory ds c m).input=rest ∧ + (wordMemory ds c m).outputRev=m.outputRev := by + induction ds generalizing c m with + | nil => exact ⟨ha,rfl,rfl,hb,rfl⟩ + | cons d ds ih => + have h0 : (digitMemory d c m).stack 0=ds.map Digit.a := by + simp [digitMemory,Memory.push,Memory.pop,Memory.read,ha] + have hi : (digitMemory d c m).input=ds.map Digit.b++rest := by + simp [digitMemory,Memory.push,Memory.pop,Memory.read,hb] + have hh := ih (nextBorrow d.a d.b c) (digitMemory d c m) h0 hi + refine ⟨hh.1,?_,?_,hh.2.2.2.1,hh.2.2.2.2⟩ + · simpa [wordMemory,output,List.reverse_cons,List.append_assoc,digitMemory,Memory.push,Memory.pop,Memory.read] using hh.2.1 + · simpa [wordMemory,digitMemory,Memory.push,Memory.pop,Memory.read] using hh.2.2.1 + +end +end Contingency.BitModel.StackCode.WeightedScan + + + + + +namespace Contingency.BitModel.StackCode.WeightedScan +open BinarySubtract +noncomputable section + +theorem end_word (m : Memory 4) (c : Bool) (h0 : m.stack 0=[]) : + exec 1 (config (.start c) m)=config (if c then .selected else .advance) (m.pop 0) := by + rw [exec_one,one_step] + simp [code,effect,branch,h0,config]; rfl + +theorem advance (m : Memory 4) : + exec 1 (config .advance m)=config .restore (m.push 3 false) := by + rw [exec_one,one_step]; rfl + +theorem restore_empty (m : Memory 4) (h2 : m.stack 2=[]) : + exec 1 (config .restore m)=config (.start false) (m.pop 2) := by + rw [exec_one,one_step] + simp [code,effect,branch,h2,config]; rfl + +theorem restore_bit (m : Memory 4) (b : Bool) (bs : List Bool) (h2 : m.stack 2=b::bs) : + exec 2 (config .restore m)=config .restore ((m.pop 2).push 0 b) := by + change step program false (step program false (config .restore m))=_ + rw [one_step] + have he : (⟨(effect (code .restore) false m).1,(effect (code .restore) false m).2⟩ : Config program)= + config (.back b) (m.pop 2) := by + cases b <;> simp [code,effect,branch,h2,config] <;> rfl + rw [he,one_step] + rfl + +def restoreMemory : List Bool→Memory 4→Memory 4 + | [],m => m.pop 2 + | b::bs,m => restoreMemory bs ((m.pop 2).push 0 b) + +theorem restore_run (bs : List Bool) (m : Memory 4) (h2 : m.stack 2=bs) : + exec (2*bs.length+1) (config .restore m)=config (.start false) (restoreMemory bs m) := by + induction bs generalizing m with + | nil => exact restore_empty m h2 + | cons b bs ih => + have he : 2*(b::bs).length+1=2+(2*bs.length+1) := by simp; omega + rw [he,exec_add,restore_bit m b bs h2,ih] + · rfl + · simp [Memory.push,Memory.pop,h2] + +theorem restoreMemory_stacks (bs : List Bool) (m : Memory 4) (h2 : m.stack 2=bs) : + (restoreMemory bs m).stack 0=bs.reverse++m.stack 0 ∧ + (restoreMemory bs m).stack 2=[] ∧ + (restoreMemory bs m).stack 3=m.stack 3 ∧ + (restoreMemory bs m).input=m.input ∧ + (restoreMemory bs m).outputRev=m.outputRev := by + induction bs generalizing m with + | nil => simp [restoreMemory,Memory.pop,h2] + | cons b bs ih => + have hh := ih ((m.pop 2).push 0 b) (by simp [Memory.pop,Memory.push,h2]) + simpa [restoreMemory,Memory.pop,Memory.push,List.reverse_cons,List.append_assoc] using hh + +theorem selected_empty (m : Memory 4) (h3 : m.stack 3=[]) : + exec 2 (config .selected m)=⟨none,m.pop 3⟩ := by + change step program false (step program false (config .selected m))=_ + rw [one_step] + have he : (⟨(effect (code .selected) false m).1,(effect (code .selected) false m).2⟩ : Config program)= + config .finish (m.pop 3) := by + simp [code,effect,branch,h3,config]; rfl + rw [he,one_step] + rfl + +def emitMemory (m : Memory 4) : Memory 4 := + {m.pop 3 with outputRev:=false::m.outputRev} + +theorem selected_bit (m : Memory 4) (bs : List Bool) (h3 : m.stack 3=false::bs) : + exec 2 (config .selected m)=config .selected (emitMemory m) := by + change step program false (step program false (config .selected m))=_ + rw [one_step] + have he : (⟨(effect (code .selected) false m).1,(effect (code .selected) false m).2⟩ : Config program)= + config .out (m.pop 3) := by + simp [code,effect,branch,h3,config]; rfl + rw [he,one_step] + rfl + +def selectedMemory : ℕ→Memory 4→Memory 4 + | 0,m => m.pop 3 + | i+1,m => selectedMemory i (emitMemory m) + +theorem selected_run (i : ℕ) (m : Memory 4) (h3 : m.stack 3=List.replicate i false) : + exec (2*i+2) (config .selected m)=⟨none,selectedMemory i m⟩ := by + induction i generalizing m with + | zero => exact selected_empty m h3 + | succ i ih => + have he : 2*(i+1)+2=2+(2*i+2) := by omega + rw [he,exec_add,selected_bit m (List.replicate i false) h3,ih] + · rfl + · simp [emitMemory,Memory.pop,h3,List.replicate_succ] + +theorem selectedMemory_output (i : ℕ) (m : Memory 4) : + (selectedMemory i m).outputRev=List.replicate i false++m.outputRev := by + induction i generalizing m with + | zero => rfl + | succ i ih => + rw [selectedMemory,ih] + change List.replicate i false++false::m.outputRev=_ + rw [show List.replicate (i+1) false=List.replicate i false++[false] by rw [List.replicate_add]; rfl,List.append_assoc] + rfl + + + +theorem skip_weight (ds : List Digit) (m : Memory 4) (rest : List Bool) (i : ℕ) + (ha : m.stack 0=ds.map Digit.a) (hb : m.input=ds.map Digit.b++rest) + (h2 : m.stack 2=[]) (h3 : m.stack 3=List.replicate i false) + (hsub : value (ds.map Digit.b)≤value (ds.map Digit.a)) : + ∃ m', exec (5*ds.length+3) (config (.start false) m)=config (.start false) m' ∧ + m'.stack 0=output ds false ∧ m'.stack 2=[] ∧ + m'.stack 3=List.replicate (i+1) false ∧ m'.input=rest ∧ m'.outputRev=m.outputRev := by + let w := wordMemory ds false m + have hw := wordMemory_stacks ds false m rest ha hb + have hc := (subtract_correct ds hsub).1 + let a := (w.pop 0).push 3 false + have ha2 : a.stack 2=(output ds false).reverse := by + simpa [a,Memory.push,Memory.pop,h2,w] using hw.2.1 + have hr := restoreMemory_stacks (output ds false).reverse a ha2 + refine ⟨restoreMemory (output ds false).reverse a,?_,?_,hr.2.1,?_,?_,?_⟩ + · have he : 5*ds.length+3=3*ds.length+1+1+(2*(output ds false).reverse.length+1) := by simp; omega + rw [he,exec_add (3*ds.length+1+1) (2*(output ds false).reverse.length+1),exec_add (3*ds.length+1) 1,exec_add (3*ds.length) 1,pass ds false m rest ha hb,hc,end_word _ false hw.1] + change exec (2*(output ds false).reverse.length+1) (exec 1 (config .advance (w.pop 0)))=_ + rw [advance,restore_run _ _ ha2] + · simpa [a,Memory.push,Memory.pop,w,hw.1] using hr.1 + · have hm3 : a.stack 3=List.replicate (i+1) false := by + simp [a,Memory.push,Memory.pop,w,hw.2.2.1,h3,List.replicate_succ] + exact hr.2.2.1.trans hm3 + · exact hr.2.2.2.1.trans hw.2.2.2.1 + · exact hr.2.2.2.2.trans hw.2.2.2.2 + + +theorem hit_weight (ds : List Digit) (m : Memory 4) (rest : List Bool) (i : ℕ) + (ha : m.stack 0=ds.map Digit.a) (hb : m.input=ds.map Digit.b++rest) + (h3 : m.stack 3=List.replicate i false) + (hlt : value (ds.map Digit.a) [] + | w::ws,i => (i,value w)::indexedWeights ws (i+1) + +@[simp] theorem indexed_total (ws : List (List Bool)) (i : ℕ) : + Contingency.IntegerDraw.total (indexedWeights ws i)=weightTotal ws := by + induction ws generalizing i with + | nil => rfl + | cons w ws ih => simp [indexedWeights,Contingency.IntegerDraw.total,weightTotal,ih] + + + +theorem scan_run (ws : List (List Bool)) (as : List Bool) (m : Memory 4) + (rest : List Bool) (i : ℕ) + (hlen : ∀ w∈ws,w.length=as.length) + (ha : m.stack 0=as) (hi : m.input=ws.flatten++rest) + (h2 : m.stack 2=[]) (h3 : m.stack 3=List.replicate i false) + (hz : value as simp [weightTotal] at hz + | cons w ws ih => + have hw : w.length=as.length := hlen w (by simp) + let ds := digits as w + obtain ⟨hda,hdb,hdl⟩ := digits_maps as w hw.symm + have hha : m.stack 0=ds.map Digit.a := ha.trans hda.symm + have hhi : m.input=ds.map Digit.b++(ws.flatten++rest) := by + simpa [ds,hdb,List.flatten_cons,List.append_assoc] using hi + by_cases hlt : value as rfl + | some pc => + unfold step + dsimp only [program] + cases (Fintype.equivFin Q).symm pc <;> rfl + +theorem fold_independent (xs ys : List Bool) (hl : xs.length=ys.length) (cfg : Config program) : + xs.foldl (fun cfg b => step program b cfg) cfg=ys.foldl (fun cfg b => step program b cfg) cfg := by + induction xs generalizing ys cfg with + | nil => cases ys <;> simp_all + | cons x xs ih => + cases ys with + | nil => simp at hl + | cons y ys => + simp only [List.length_cons,Nat.add_right_cancel_iff] at hl + simp only [List.foldl_cons] + rw [step_independent _ x y] + exact ih _ hl _ + + + +theorem scan_tape (ws : List (List Bool)) (as : List Bool) (m : Memory 4) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=as.length) + (ha : m.stack 0=as) (hi : m.input=ws.flatten++rest) + (h2 : m.stack 2=[]) (h3 : m.stack 3=[]) + (hz : value as (compile program).step b cfg) + (encode program (config (.start false) m))=encode program ⟨none,m'⟩ := by + obtain ⟨j,m',hj,hs,hr,ho⟩ := scan_run ws as m rest 0 hlen ha hi h2 h3 hz + let t := 3*as.length+2*0+3+j*(5*as.length+5) + refine ⟨t,j,m',?_,hj,by simpa using hs,by simpa using ho,?_⟩ + · have hm := Nat.mul_le_mul_left (5*as.length+5) (Nat.succ_le_iff.mpr hj) + dsimp only [t] + nlinarith only [hm] + · intro coins + rw [BinarySubtract.fold_compiled] + have he := fold_independent (List.ofFn fun i : Fin t => coins (second i)) (List.replicate t false) (by simp) (config (.start false) m) + rw [he] + change encode program (exec t (config (.start false) m))=_ + rw [hr] + +end +end Contingency.BitModel.StackCode.WeightedScan + + + + + + + +namespace Contingency.BitModel.StackCode + +namespace Internal + +def work {w : ℕ} (i : Fin w) : Fin (w+2) := i.castSucc.castSucc + +def input (w : ℕ) : Fin (w+2) := (Fin.last w).castSucc + +def output (w : ℕ) : Fin (w+2) := Fin.last (w+1) + +@[simp] theorem work_inj {w : ℕ} (i j : Fin w) : work i=work j ↔ i=j := by simp [work] +@[simp] theorem work_ne_input {w : ℕ} (i : Fin w) : work i≠input w := by simp [work,input] +@[simp] theorem work_ne_output {w : ℕ} (i : Fin w) : work i≠output w := by simp [work,output] +@[simp] theorem input_ne_output (w : ℕ) : input w≠output w := by simp [input,output] +@[simp] theorem input_ne_work {w : ℕ} (i : Fin w) : input w≠work i := (work_ne_input i).symm +@[simp] theorem output_ne_work {w : ℕ} (i : Fin w) : output w≠work i := (work_ne_output i).symm +@[simp] theorem output_ne_input (w : ℕ) : output w≠input w := (input_ne_output w).symm + +def op {l w : ℕ} : Op l w→Op l (w+2) + | .push i b q => .push (work i) b q + | .pop i e z o => .pop (work i) e z o + | .read e z o => .pop (input w) e z o + | .coin z o => .coin z o + | .emit b q => .push (output w) b q + | .jump q => .jump q + | .halt => .halt + +def program (P : Program) : Program := ⟨P.labels,P.work+2,P.start,fun q => op (P.code q)⟩ + + + +def MemoryRel {w : ℕ} (a : Memory w) (b : Memory (w+2)) : Prop := + (∀ i,b.stack (work i)=a.stack i) ∧ + b.stack (input w)=a.input ∧ b.stack (output w)=a.outputRev + +theorem push_work {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) + (i : Fin w) (v : Bool) : MemoryRel (a.push i v) (b.push (work i) v) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simp [Memory.push,Function.update_apply,hw] + · simpa [Memory.push] using hi + · simpa [Memory.push] using ho + +theorem pop_work {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) + (i : Fin w) : MemoryRel (a.pop i) (b.pop (work i)) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simp [Memory.pop,Function.update_apply,hw] + · simpa [Memory.pop] using hi + · simpa [Memory.pop] using ho + +theorem read_input {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) : + MemoryRel a.read (b.pop (input w)) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simpa [Memory.pop,Memory.read] using hw j + · simp [Memory.pop,Memory.read,hi] + · simpa [Memory.pop,Memory.read] using ho + +theorem emit_output {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) (v : Bool) : + MemoryRel {a with outputRev:=v::a.outputRev} (b.push (output w) v) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simpa [Memory.push] using hw j + · simpa [Memory.push] using hi + · simp [Memory.push,ho] + +theorem effect_rel {l w : ℕ} (code : Op l w) (coin : Bool) + {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) : + (effect (op code) coin b).1=(effect code coin a).1 ∧ + MemoryRel (effect code coin a).2 (effect (op code) coin b).2 := by + cases code with + | push i v q => exact ⟨rfl,push_work h i v⟩ + | pop i e z o => exact ⟨by simp [op,effect,h.1 i],pop_work h i⟩ + | read e z o => exact ⟨by simp [op,effect,h.2.1],read_input h⟩ + | coin z o => exact ⟨rfl,h⟩ + | emit v q => exact ⟨rfl,emit_output h v⟩ + | jump q => exact ⟨rfl,h⟩ + | halt => exact ⟨rfl,h⟩ + +def ConfigRel (P : Program) (a : Config P) (b : Config (program P)) : Prop := + b.state=a.state ∧ MemoryRel a.memory b.memory + +theorem step_rel (P : Program) (coin : Bool) {a : Config P} {b : Config (program P)} + (h : ConfigRel P a b) : ConfigRel P (step P coin a) (step (program P) coin b) := by + rcases a with ⟨sa,ma⟩ + rcases b with ⟨sb,mb⟩ + obtain ⟨hs,hm⟩ := h + dsimp only at hs hm + subst sb + cases sa with + | none => exact ⟨rfl,hm⟩ + | some pc => exact effect_rel (P.code pc) coin hm + +theorem fold_rel (P : Program) (coins : List Bool) {a : Config P} {b : Config (program P)} + (h : ConfigRel P a b) : + ConfigRel P (coins.foldl (fun c v => step P v c) a) + (coins.foldl (fun c v => step (program P) v c) b) := by + induction coins generalizing a b with + | nil => exact h + | cons v coins ih => exact ih (step_rel P v h) + + + +def loaded (P : Program) (xs : List Bool) (external : Memory (P.work+2)) : Config (program P) := + ⟨some P.start,{external with stack:=Fin.lastCases [] (Fin.lastCases xs (fun _ => []))}⟩ + +theorem loaded_rel (P : Program) (xs : List Bool) (external : Memory (P.work+2)) : + ConfigRel P (initial P xs) (loaded P xs external) := by + refine ⟨rfl,?_,?_,?_⟩ + · intro i + simp [loaded,initial,work] + · simp [loaded,initial,input] + · simp [loaded,initial,output] + + + +theorem loaded_run (P : Program) (xs : List Bool) (external : Memory (P.work+2)) + {t : ℕ} (coins : Fin t→Bool) : + ConfigRel P (run P xs coins) + ((List.ofFn coins).foldl (fun c v => step (program P) v c) (loaded P xs external)) := + fold_rel P _ (loaded_rel P xs external) + +end Internal +end Contingency.BitModel.StackCode + + + + + +namespace Contingency.BitModel.StackCode.Internal + +theorem effect_frame {l w : ℕ} (code : Op l w) (coin : Bool) (b : Memory (w+2)) : + (effect (op code) coin b).2.input=b.input ∧ + (effect (op code) coin b).2.outputRev=b.outputRev ∧ + (effect (op code) coin b).2.consumed=b.consumed := by + cases code <;> exact ⟨rfl,rfl,rfl⟩ + +theorem step_frame (P : Program) (coin : Bool) (b : Config (program P)) : + (step (program P) coin b).memory.input=b.memory.input ∧ + (step (program P) coin b).memory.outputRev=b.memory.outputRev ∧ + (step (program P) coin b).memory.consumed=b.memory.consumed := by + rcases b with ⟨s,m⟩ + cases s with + | none => exact ⟨rfl,rfl,rfl⟩ + | some q => exact effect_frame (P.code q) coin m + +theorem fold_frame (P : Program) (coins : List Bool) (b : Config (program P)) : + (coins.foldl (fun c v => step (program P) v c) b).memory.input=b.memory.input ∧ + (coins.foldl (fun c v => step (program P) v c) b).memory.outputRev=b.memory.outputRev ∧ + (coins.foldl (fun c v => step (program P) v c) b).memory.consumed=b.memory.consumed := by + induction coins generalizing b with + | nil => exact ⟨rfl,rfl,rfl⟩ + | cons c coins ih => + have hh := ih (step (program P) c b) + have he := step_frame P c b + exact ⟨hh.1.trans he.1,hh.2.1.trans he.2.1,hh.2.2.trans he.2.2⟩ + +theorem tape_fold (P : Program) (cfg : Config P) {t : ℕ} (coins : Fin (t*2)→Bool) : + (List.ofFn coins).foldl (fun cfg b => (compile P).step b cfg) (encode P cfg)= + encode P ((List.ofFn (fun i : Fin t => coins (second i))).foldl (fun cfg b => step P b cfg) cfg) := by + rw [coins_as_pairs,fold_pairs] + congr 1 + have hh := List.foldl_map (f:=Prod.snd) (g:=fun cfg b => step P b cfg) + (l:=List.ofFn fun i : Fin t => (coins (first i),coins (second i))) (init:=cfg) + simpa only [List.map_ofFn,Function.comp_def] using hh.symm + + + +theorem loaded_tape (P : Program) (xs : List Bool) (external : Memory (P.work+2)) + {t : ℕ} (coins : Fin (t*2)→Bool) : + ∃ b : Config (program P), + (List.ofFn coins).foldl (fun cfg v => (compile (program P)).step v cfg) + (encode (program P) (loaded P xs external))=encode (program P) b ∧ + b.state=(run P xs (fun i : Fin t => coins (second i))).state ∧ + (∀ i,b.memory.stack (work i)=(run P xs (fun i : Fin t => coins (second i))).memory.stack i) ∧ + b.memory.stack (input P.work)=(run P xs (fun i : Fin t => coins (second i))).memory.input ∧ + b.memory.stack (output P.work)=(run P xs (fun i : Fin t => coins (second i))).memory.outputRev ∧ + b.memory.input=external.input ∧ b.memory.outputRev=external.outputRev ∧ + b.memory.consumed=external.consumed := by + let bs := List.ofFn fun i : Fin t => coins (second i) + let b := bs.foldl (fun c v => step (program P) v c) (loaded P xs external) + have hr := loaded_run P xs external (fun i : Fin t => coins (second i)) + have hf := fold_frame P bs (loaded P xs external) + exact ⟨b,tape_fold (program P) (loaded P xs external) coins,hr.1,hr.2.1,hr.2.2.1,hr.2.2.2,hf.1,hf.2.1,hf.2.2⟩ + +end Contingency.BitModel.StackCode.Internal + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/ChildLogConcavity.lean b/lean/OAI/Probability/Contingency/ChildLogConcavity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fa78712b0f1c6c7382998dbba8c0de9cef68213 --- /dev/null +++ b/lean/OAI/Probability/Contingency/ChildLogConcavity.lean @@ -0,0 +1,624 @@ +import Mathlib +import OAI.Probability.Contingency.LawComposition +import OAI.Probability.Contingency.RootTransport + +namespace OAI + +/-! Child Log Concavity. -/ + +noncomputable section + +open scoped BigOperators +open Filter +open scoped BigOperators +open QuadraticMap Filter + +namespace Contingency + + +theorem bool_signature_determinant (M : Bool → Bool → ℝ) + (hs : sigPos (matrixForm M) ≤ 1) (hm : M true false = M false true) + (ha : 0 < M true true) : + M true true * M false false ≤ M true false ^ 2 := by + let e : Bool → ℝ := fun b => if b then 1 else 0 + let v : Bool → ℝ := fun b => if b then 0 else 1 + have he : matrixForm M e = M true true := by + simp [matrixForm_apply, e] + have hv : matrixForm M v = M false false := by + simp [matrixForm_apply, v] + have he' : 0 < matrixForm M e := he ▸ ha + have hve : (matrixForm M).associated v e = M true false := by + rw [QuadraticMap.associated_apply] + norm_num + simp [matrixForm_apply,e,v,hm] + ring + have h := positive_projection (matrixForm M) hs e v he' + rw [he,hv,hve] at h + have := (le_div_iff₀ ha).mp h + nlinarith + +def childProfile (C j : ℤ) : Bool → ℤ := fun b => if b then j else C-j + + + +theorem signature_child_logconcave (C : ℕ) (f : (Bool → ℤ) → ℝ) + (hp : PositiveSlice f (fun _ => (C:ℤ)) C) + (hs : HasSignature f (fun _ => (C:ℤ)) C) + (j : ℤ) (hj : 1 ≤ j) (hjC : j < C) : + f (childProfile C (j-1)) * f (childProfile C (j+1)) ≤ + f (childProfile C j)^2 := by + let p : Bool → ℤ := fun b => if b then j+1 else (C:ℤ)-j+1 + have hb : InBox (fun _ => (C:ℤ)) p := by + intro b; cases b <;> dsimp [p] <;> omega + have ht : (∑ b, p b) = (C:ℤ)+2 := by simp [p]; omega + have hrem (i k : Bool) : removePair p i k = + childProfile C (j+1 - (if i then 1 else 0) - (if k then 1 else 0)) := by + funext b + cases i <;> cases k <;> cases b <;> simp [removePair,p,childProfile] <;> omega + have ha : 0 < f (childProfile C (j-1)) := by + apply hp.1 + · intro b; cases b <;> dsimp [childProfile] <;> omega + · simp [childProfile] + have h := bool_signature_determinant (twoRemoval f p) (hs p hb ht) + (by simp only [twoRemoval]; rw [removePair_comm]) + (by simpa [twoRemoval,hrem] using ha) + simpa [twoRemoval,hrem] using h + + + +theorem positive_logconcave_min (f : ℤ → ℝ) (a b j : ℤ) + (haj : a ≤ j) (hjb : j ≤ b) + (hp : ∀ i ∈ Finset.Icc a b, 0 < f i) + (hl : ∀ i, a < i → i < b → f (i-1)*f (i+1) ≤ f i ^ 2) : + min (f a) (f b) ≤ f j := by + classical + by_contra hh + have hh' : f j < min (f a) (f b) := lt_of_not_ge hh + obtain ⟨k,hk,hmin⟩ := Finset.exists_min_image (Finset.Icc a b) f + ⟨j,Finset.mem_Icc.mpr ⟨haj,hjb⟩⟩ + let A := (Finset.Icc a b).filter (fun i => f i = f k) + have hA : A.Nonempty := ⟨k,by simp [A,hk]⟩ + let i := A.min' hA + have hi : i ∈ A := Finset.min'_mem A hA + have hi' := Finset.mem_filter.mp hi + have hib := Finset.mem_Icc.mp hi'.1 + have hik : f i = f k := hi'.2 + have hfi : f i < min (f a) (f b) := by + rw [hik]; exact lt_of_le_of_lt (hmin j (Finset.mem_Icc.mpr ⟨haj,hjb⟩)) hh' + have hia : a < i := by + have hne : i ≠ a := by intro h; rw [h] at hfi; exact (not_lt_of_ge (min_le_left _ _)) hfi + omega + have hib' : i < b := by + have hne : i ≠ b := by intro h; rw [h] at hfi; exact (not_lt_of_ge (min_le_right _ _)) hfi + omega + have himem : i-1 ∈ Finset.Icc a b := Finset.mem_Icc.mpr (by omega) + have hinmem : i+1 ∈ Finset.Icc a b := Finset.mem_Icc.mpr (by omega) + have hprev : f i < f (i-1) := by + have hle : f i ≤ f (i-1) := hik ▸ hmin (i-1) himem + apply lt_of_le_of_ne hle + intro he + have hm : i-1 ∈ A := Finset.mem_filter.mpr ⟨himem,he.symm.trans hik⟩ + have := Finset.min'_le A (i-1) hm + change i ≤ i-1 at this + omega + have hnext : f i ≤ f (i+1) := hik ▸ hmin (i+1) hinmem + have hpos := hp i hi'.1 + have hloc := hl i hia hib' + have hx := mul_lt_mul_of_pos_right hprev hpos + have hy := mul_le_mul_of_nonneg_left hnext (le_of_lt (lt_trans hpos hprev)) + nlinarith + + +theorem signature_child_min (C : ℕ) (f : (Bool → ℤ) → ℝ) + (hp : PositiveSlice f (fun _ => (C:ℤ)) C) + (hs : HasSignature f (fun _ => (C:ℤ)) C) + (a b j : ℤ) (ha : 0 ≤ a) (haj : a ≤ j) (hjb : j ≤ b) (hb : b ≤ C) : + min (f (childProfile C a)) (f (childProfile C b)) ≤ f (childProfile C j) := by + apply positive_logconcave_min (fun i => f (childProfile C i)) a b j haj hjb + · intro i hi + have hi' := Finset.mem_Icc.mp hi + apply hp.1 + · intro k; cases k <;> dsimp [childProfile] <;> omega + · simp [childProfile] + · intro i hi hi' + exact signature_child_logconcave C f hp hs i (by omega) (by omega) + + + +theorem zero_child_min (C : ℕ) (f : ℝ → (Bool → ℤ) → ℝ) + (hc : ∀ x, Continuous (fun η => f η x)) + (hp : ∀ η, 0 < η → η < 1 → PositiveSlice (f η) (fun _ => (C:ℤ)) C) + (hs : ∀ η, 0 < η → η < 1 → HasSignature (f η) (fun _ => (C:ℤ)) C) + (a b j : ℤ) (ha : 0 ≤ a) (haj : a ≤ j) (hjb : j ≤ b) (hb : b ≤ C) : + min (f 0 (childProfile C a)) (f 0 (childProfile C b)) ≤ f 0 (childProfile C j) := by + apply le_of_tendsto_of_tendsto + (((hc _).continuousAt.min (hc _).continuousAt).comp softSequence_tendsto) + ((hc _).continuousAt.tendsto.comp softSequence_tendsto) + exact Filter.Eventually.of_forall fun k => signature_child_min C (f (softSequence k)) + (hp _ (softSequence_range k).1 (softSequence_range k).2) + (hs _ (softSequence_range k).1 (softSequence_range k).2) a b j ha haj hjb hb + +end Contingency + + + + + +open scoped BigOperators + +namespace Contingency +section FiniteVariance +variable {α : Type*} [Fintype α] + +noncomputable def totalWeight (w : α → ℝ) : ℝ := ∑ x, w x +noncomputable def weightedMean (w H : α → ℝ) : ℝ := (∑ x, w x*H x) / totalWeight w +noncomputable def weightedVariance (w H : α → ℝ) : ℝ := + ∑ x, w x * (H x-weightedMean w H)^2 + +theorem centered_sum (w H : α → ℝ) (hw : totalWeight w ≠ 0) : + (∑ x, w x*(H x-weightedMean w H))=0 := by + simp only [mul_sub,Finset.sum_sub_distrib,← Finset.sum_mul] + change (∑ x, w x*H x) - totalWeight w*((∑ x, w x*H x)/totalWeight w) = 0 + field_simp + ring + +theorem variance_translate (w H : α → ℝ) (hw : totalWeight w ≠ 0) (a : ℝ) : + (∑ x, w x*(H x-a)^2) = + weightedVariance w H + totalWeight w*(weightedMean w H-a)^2 := by + have h (x : α) : w x*(H x-a)^2 = + w x*(H x-weightedMean w H)^2 + + 2*(weightedMean w H-a)*(w x*(H x-weightedMean w H)) + + w x*(weightedMean w H-a)^2 := by ring + simp only [h,Finset.sum_add_distrib,← Finset.mul_sum,← Finset.sum_mul] + rw [centered_sum w H hw] + simp [weightedVariance,totalWeight] + +theorem variance_secondMoment (w H : α → ℝ) (hw : totalWeight w ≠ 0) : + weightedVariance w H = (∑ x, w x*H x^2) - + (∑ x, w x*H x)^2 / totalWeight w := by + have h := variance_translate w H hw 0 + simp only [sub_zero] at h + rw [weightedMean] at h + have he : totalWeight w*((∑ x, w x*H x)/totalWeight w)^2 = + (∑ x, w x*H x)^2 / totalWeight w := by field_simp + rw [he] at h + linarith + +theorem variance_pair_formula (w H : α → ℝ) (hw : totalWeight w ≠ 0) : + weightedVariance w H = + (∑ a, ∑ b, w a*w b*(H a-H b)^2) / (2*totalWeight w) := by + have hexp (a b : α) : w a*w b*(H a-H b)^2 = + (w a*H a^2)*w b + w a*(w b*H b^2) -2*(w a*H a)*(w b*H b) := by ring + simp only [hexp,Finset.sum_sub_distrib,Finset.sum_add_distrib, + ← Finset.mul_sum,← Finset.sum_mul] + rw [variance_secondMoment w H hw] + unfold totalWeight at * + field_simp [hw] + ring + +theorem variance_nonneg (w H : α → ℝ) (hw : ∀ x, 0 ≤ w x) : + 0 ≤ weightedVariance w H := + Finset.sum_nonneg fun x _ => mul_nonneg (hw x) (sq_nonneg _) + + + +theorem variance_le_card_sq (w H : α → ℝ) (hw : 0 < totalWeight w) + (B : ℝ) (hB : 0 ≤ B) + (hp : ∀ a b, w a*w b/totalWeight w*(H a-H b)^2 ≤ B) : + weightedVariance w H ≤ (Fintype.card α:ℝ)^2*B := by + rw [variance_pair_formula w H hw.ne'] + have hb : (∑ a, ∑ b, w a*w b*(H a-H b)^2) ≤ + (Fintype.card α:ℝ)^2*(totalWeight w*B) := by + calc + _ ≤ ∑ a : α, ∑ b : α, totalWeight w*B := by + apply Finset.sum_le_sum; intro a ha + apply Finset.sum_le_sum; intro b hb + have h := (div_le_iff₀ hw).mp (show w a*w b*(H a-H b)^2/totalWeight w ≤ B by + simpa only [div_mul_eq_mul_div] using hp a b) + nlinarith + _ = _ := by simp; ring + apply (div_le_iff₀ (mul_pos (by norm_num) hw)).mpr + have hc : 0 ≤ (Fintype.card α:ℝ)^2 := sq_nonneg _ + nlinarith [mul_nonneg hc hB] + +end FiniteVariance + + +theorem interval_square_bound (H : ℕ → ℝ) (a b : ℕ) (hab : a ≤ b) : + (H a-H b)^2 ≤ (b-a:ℕ)*(∑ j ∈ Finset.Ico a b, (H j-H (j+1))^2) := by + have htel : (∑ j ∈ Finset.Ico a b, (H j-H (j+1))) = H a-H b := by + calc + _ = -(∑ j ∈ Finset.Ico a b, (H (j+1)-H j)) := by + rw [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl; intro j hj; ring + _ = H a-H b := by rw [Finset.sum_Ico_sub H hab]; ring + rw [← htel] + calc + _ ≤ (∑ j ∈ Finset.Ico a b, (1:ℝ)) * + ∑ j ∈ Finset.Ico a b, (H j-H (j+1))^2 := by + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul + · intros; norm_num + · intros; positivity + · intros; simp + _ = _ := by simp + + + +theorem child_pair_bound (U : ℕ) (z H : ℕ → ℝ) (Z A E : ℝ) + (hZ : 0 < Z) (hz : ∀ j ≤ U, 0 ≤ z j) (hzZ : ∀ j ≤ U, z j ≤ Z) + (hA : 0 ≤ A) (hE : 0 ≤ E) + (hmin : ∀ a b j, a ≤ j → j ≤ b → b ≤ U → min (z a) (z b) ≤ z j) + (hadj : ∀ j < U, min (z j) (z (j+1))*(H j-H (j+1))^2 ≤ A*E) + (a b : ℕ) (hab : a ≤ b) (hbU : b ≤ U) : + z a*z b/Z*(H a-H b)^2 ≤ (U:ℝ)^2*A*E := by + have haU := hab.trans hbU + have hzmin : 0 ≤ min (z a) (z b) := le_min (hz a haU) (hz b hbU) + have hpmin : z a*z b/Z ≤ min (z a) (z b) := by + apply le_min + · apply (div_le_iff₀ hZ).mpr + exact mul_le_mul_of_nonneg_left (hzZ b hbU) (hz a haU) + · apply (div_le_iff₀ hZ).mpr + nlinarith [mul_le_mul_of_nonneg_right (hzZ a haU) (hz b hbU)] + have hedge (j : ℕ) (hj : j ∈ Finset.Ico a b) : + min (z a) (z b)*(H j-H (j+1))^2 ≤ A*E := by + have hj' := Finset.mem_Ico.mp hj + have hm : min (z a) (z b) ≤ min (z j) (z (j+1)) := by + apply le_min + · exact hmin a b j hj'.1 (by omega) hbU + · exact hmin a b (j+1) (by omega) (by omega) hbU + exact (mul_le_mul_of_nonneg_right hm (sq_nonneg _)).trans (hadj j (by omega)) + have hs : min (z a) (z b)*(∑ j ∈ Finset.Ico a b, (H j-H (j+1))^2) ≤ + ((b-a:ℕ):ℝ)*(A*E) := by + rw [Finset.mul_sum] + calc + _ ≤ ∑ j ∈ Finset.Ico a b, A*E := Finset.sum_le_sum hedge + _ = _ := by simp + have hlen : ((b-a:ℕ):ℝ) ≤ U := by exact_mod_cast (show b-a ≤ U by omega) + have hlen0 : (0:ℝ) ≤ ((b-a:ℕ):ℝ) := Nat.cast_nonneg _ + have hlenSq : (((b-a:ℕ):ℝ))^2 ≤ (U:ℝ)^2 := by + exact sq_le_sq₀ hlen0 (Nat.cast_nonneg U) |>.mpr hlen + calc + _ ≤ min (z a) (z b)*(H a-H b)^2 := mul_le_mul_of_nonneg_right hpmin (sq_nonneg _) + _ ≤ min (z a) (z b)*(((b-a:ℕ):ℝ)*∑ j ∈ Finset.Ico a b, (H j-H (j+1))^2) := + mul_le_mul_of_nonneg_left (interval_square_bound H a b hab) hzmin + _ = ((b-a:ℕ):ℝ)*(min (z a) (z b)*∑ j ∈ Finset.Ico a b, (H j-H (j+1))^2) := by ring + _ ≤ ((b-a:ℕ):ℝ)*(((b-a:ℕ):ℝ)*(A*E)) := mul_le_mul_of_nonneg_left hs hlen0 + _ ≤ (U:ℝ)^2*A*E := by nlinarith [mul_le_mul_of_nonneg_right hlenSq (mul_nonneg hA hE)] + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.FiniteChain + + +structure Chain (V : Type*) [Fintype V] where + π : V → ℝ + P : V → V → ℝ + positive : ∀ x, 0 < π x + normalized : ∑ x, π x = 1 + nonneg : ∀ x y, 0 ≤ P x y + stochastic : ∀ x, ∑ y, P x y = 1 + reversible : ∀ x y, π x*P x y = π y*P y x + lazy : ∀ x, 1/2 ≤ P x x + +namespace Chain +noncomputable section + +variable {V : Type*} [Fintype V] (C : Chain V) + +def mean (f : V → ℝ) : ℝ := ∑ x, C.π x*f x +def inner (f g : V → ℝ) : ℝ := ∑ x, C.π x*f x*g x +def normSq (f : V → ℝ) : ℝ := ∑ x, C.π x*f x^2 +def step (f : V → ℝ) (x : V) : ℝ := ∑ y, C.P x y*f y +def energy (f : V → ℝ) : ℝ := (∑ x, ∑ y, C.π x*C.P x y*(f x-f y)^2)/2 + +theorem stationary (y : V) : (∑ x, C.π x*C.P x y)=C.π y := by + simp_rw [C.reversible] + rw [← Finset.mul_sum,C.stochastic,mul_one] + +theorem normSq_nonneg (f : V → ℝ) : 0≤C.normSq f := + Finset.sum_nonneg fun x _ => mul_nonneg (C.positive x).le (sq_nonneg _) + +theorem inner_self (f : V → ℝ) : C.inner f f=C.normSq f := by + simp only [inner,normSq,pow_two,mul_assoc] + +theorem step_mean (f : V → ℝ) : C.mean (C.step f)=C.mean f := by + simp only [mean,step,Finset.mul_sum] + rw [Finset.sum_comm] + simp only [← mul_assoc,← Finset.sum_mul,C.stationary] + +theorem step_selfadjoint (f g : V → ℝ) : C.inner f (C.step g)=C.inner (C.step f) g := by + simp only [inner,step,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro x _ + apply Finset.sum_congr rfl; intro y _ + calc + C.π y*f y*(C.P y x*g x) = (C.π y*C.P y x)*f y*g x := by ring + _ = _ := by rw [C.reversible]; ring + +theorem inner_comm (f g : V → ℝ) : C.inner f g=C.inner g f := by + unfold inner + apply Finset.sum_congr rfl; intro x _; ring + +theorem edge_sums_left (f : V → ℝ) : + (∑ x, ∑ y, C.π x*C.P x y*f x^2)=C.normSq f := by + simp only [mul_right_comm (C.π _) (C.P _ _),← Finset.mul_sum,C.stochastic,mul_one,normSq] + +theorem edge_sums_right (f : V → ℝ) : + (∑ x, ∑ y, C.π x*C.P x y*f y^2)=C.normSq f := by + rw [Finset.sum_comm] + simp only [← Finset.sum_mul,C.stationary,normSq] + +theorem edge_cross (f g : V → ℝ) : + (∑ x, ∑ y, C.π x*C.P x y*f x*g y)=C.inner f (C.step g) := by + simp only [inner,step,Finset.mul_sum] + apply Finset.sum_congr rfl; intro x _ + apply Finset.sum_congr rfl; intro y _; ring + +theorem energy_identity (f : V → ℝ) : + C.energy f=C.normSq f-C.inner f (C.step f) := by + have h (x y) : C.π x*C.P x y*(f x-f y)^2 = + C.π x*C.P x y*f x^2+C.π x*C.P x y*f y^2 - + 2*(C.π x*C.P x y*f x*f y) := by ring + simp only [energy,h,Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum] + rw [C.edge_sums_left,C.edge_sums_right,C.edge_cross] + ring + +theorem step_positive (f : V → ℝ) : 0≤C.inner f (C.step f) := by + classical + have hn : 0≤∑ x, ∑ y, C.π x*(C.P x y-if x=y then 1/2 else 0)*(f x+f y)^2 := by + apply Finset.sum_nonneg; intro x _ + apply Finset.sum_nonneg; intro y _ + apply mul_nonneg + · apply mul_nonneg (C.positive x).le + by_cases h : x=y + · subst y; simp only [ite_true]; linarith [C.lazy x] + · simp only [ite_eq_right h,sub_zero]; exact C.nonneg x y + · exact sq_nonneg _ + have he : (∑ x, ∑ y, C.π x*(C.P x y-if x=y then 1/2 else 0)*(f x+f y)^2) = + 2*C.inner f (C.step f) := by + have h (x y) : C.π x*(C.P x y-if x=y then 1/2 else 0)*(f x+f y)^2 = + (C.π x*C.P x y*f x^2 + C.π x*C.P x y*f y^2 + + 2*(C.π x*C.P x y*f x*f y)) - + (if x=y then 2*(C.π x*f x^2) else 0) := by + by_cases hh : x=y + · subst y; simp only [ite_true]; ring + · simp only [ite_eq_right hh]; ring + simp only [h,Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] + rw [C.edge_sums_left,C.edge_sums_right,C.edge_cross] + simp only [normSq,← Finset.mul_sum]; ring + rw [he] at hn + linarith + + + +theorem step_cauchy (f g : V → ℝ) : + (C.inner f (C.step g))^2 ≤ C.inner f (C.step f)*C.inner g (C.step g) := by + have hh (t : ℝ) : 0 ≤ C.inner f (C.step f)*t^2 + + 2*C.inner f (C.step g)*t+C.inner g (C.step g) := by + have h := C.step_positive (fun x => t*f x+g x) + have he : C.inner (fun x => t*f x+g x) (C.step (fun x => t*f x+g x)) = + C.inner f (C.step f)*t^2 + + (C.inner f (C.step g)+C.inner g (C.step f))*t+C.inner g (C.step g) := by + simp only [inner,step,Finset.mul_sum,Finset.sum_mul,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl; intro x _ + apply Finset.sum_congr rfl; intro y _ + ring + rw [he,C.inner_comm g (C.step f),← C.step_selfadjoint f g] at h + nlinarith only [h] + have hd := discrim_le_zero (by + intro t + simpa only [pow_two] using hh t) + unfold discrim at hd + nlinarith only [hd] + +end +end Chain +end Contingency.FiniteChain + + + + + +open scoped BigOperators +namespace Contingency.FiniteChain.Chain +noncomputable section +variable {V : Type*} [Fintype V] (C : Chain V) + +def variance (f : V → ℝ) : ℝ := ∑ x, C.π x*(f x-C.mean f)^2 + +theorem variance_centered (f : V → ℝ) (h : C.mean f=0) : C.variance f=C.normSq f := by + simp only [variance,h,sub_zero,normSq] + +theorem gap_inner (K : ℝ) (hK : 1≤K) + (hvar : ∀ f : V → ℝ, C.variance f ≤ K*C.energy f) + (f : V → ℝ) (hf : C.mean f=0) : + C.inner f (C.step f) ≤ (1-1/K)*C.normSq f := by + have h := hvar f + rw [C.variance_centered f hf,C.energy_identity] at h + have hk0 : 0 f + | t+1, f => C.step (iterate t f) + +theorem iterate_mean (t : ℕ) (f : V → ℝ) : C.mean (C.iterate t f)=C.mean f := by + induction t with + | zero => rfl + | succ t ih => simpa only [iterate,C.step_mean] using ih + +theorem iterate_normSq (K : ℝ) (hK : 1≤K) + (hvar : ∀ f : V → ℝ, C.variance f ≤ K*C.energy f) + (t : ℕ) (f : V → ℝ) (hf : C.mean f=0) : + C.normSq (C.iterate t f) ≤ (1-1/K)^(2*t)*C.normSq f := by + induction t with + | zero => simp [iterate] + | succ t ih => + have hg := C.gap_normSq K hK hvar (C.iterate t f) (by rw [C.iterate_mean,hf]) + have hi := mul_le_mul_of_nonneg_left ih (sq_nonneg (1-1/K)) + simp only [iterate] + calc + _ ≤ (1-1/K)^2*C.normSq (C.iterate t f) := hg + _ ≤ (1-1/K)^2*((1-1/K)^(2*t)*C.normSq f) := hi + _ = _ := by rw [show 2*(t+1)=2+2*t by omega,pow_add]; ring + + +def law [DecidableEq V] : ℕ → V → V → ℝ + | 0, x, y => if x=y then 1 else 0 + | t+1, x, y => ∑ z, law t x z*C.P z y + +def initialDensity [DecidableEq V] (x y : V) : ℝ := + (if x=y then 1 else 0)/C.π x-1 + +theorem density_mean [DecidableEq V] (x : V) : C.mean (C.initialDensity x)=0 := by + simp only [mean,initialDensity,mul_sub,mul_one,Finset.sum_sub_distrib] + rw [C.normalized] + simp only [ite_div,mul_ite,mul_zero,zero_div,Finset.sum_ite_eq, + Finset.mem_univ,ite_true] + field_simp [(C.positive x).ne'] + ring + +theorem density_normSq [DecidableEq V] (x : V) : + C.normSq (C.initialDensity x)=1/C.π x-1 := by + have h (y) : C.π y*(C.initialDensity x y)^2 = + (if x=y then 1/C.π x-2 else 0)+C.π y := by + by_cases hh : x=y + · subst y + simp only [initialDensity,ite_true] + field_simp [(C.positive x).ne'] + ring + · simp [initialDensity,hh] + simp only [normSq,h,Finset.sum_add_distrib,Finset.sum_ite_eq, + Finset.mem_univ,ite_true,C.normalized] + ring + +theorem density_law [DecidableEq V] (t : ℕ) (x y : V) : + C.π y*(1+C.iterate t (C.initialDensity x) y)=C.law t x y := by + induction t generalizing y with + | zero => + by_cases h : x=y + · subst y + simp [iterate,initialDensity,law,(C.positive x).ne'] + · simp [iterate,initialDensity,law,h] + | succ t ih => + simp only [iterate,step,law] + calc + _ = ∑ z, C.π y*C.P y z*(1+C.iterate t (C.initialDensity x) z) := by + simp only [mul_add,mul_one,Finset.sum_add_distrib,← Finset.mul_sum,C.stochastic] + simp only [mul_assoc,← Finset.mul_sum] + _ = ∑ z, (C.π z*(1+C.iterate t (C.initialDensity x) z))*C.P z y := by + apply Finset.sum_congr rfl; intro z _ + rw [C.reversible]; ring + _ = _ := by simp_rw [ih] + + +def tv [DecidableEq V] (t : ℕ) (x : V) : ℝ := + (∑ y, |C.law t x y-C.π y|)/2 + +theorem tv_density [DecidableEq V] (t : ℕ) (x : V) : + C.tv t x = (∑ y, C.π y*|C.iterate t (C.initialDensity x) y|)/2 := by + unfold tv + congr 1 + apply Finset.sum_congr rfl; intro y _ + rw [← C.density_law] + have he : C.π y*(1+C.iterate t (C.initialDensity x) y)-C.π y= + C.π y*C.iterate t (C.initialDensity x) y := by ring + rw [he,abs_mul,abs_of_pos (C.positive y)] + +theorem weighted_abs_sq (f : V → ℝ) : + (∑ x, C.π x*|f x|)^2 ≤ C.normSq f := by + calc + _ ≤ (∑ x, C.π x)*(∑ x, C.π x*f x^2) := by + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul + · intro x _; exact (C.positive x).le + · intro x _; exact mul_nonneg (C.positive x).le (sq_nonneg _) + · intro x _; rw [mul_pow,sq_abs]; nlinarith only [] + _ = _ := by rw [C.normalized,one_mul]; rfl + +theorem tv_sq [DecidableEq V] (t : ℕ) (x : V) : + (C.tv t x)^2 ≤ C.normSq (C.iterate t (C.initialDensity x))/4 := by + rw [C.tv_density] + have h := C.weighted_abs_sq (C.iterate t (C.initialDensity x)) + nlinarith only [h] + + + +theorem mixing_bound [DecidableEq V] (K : ℝ) (hK : 1≤K) + (hvar : ∀ f : V → ℝ, C.variance f ≤ K*C.energy f) + (t : ℕ) (x : V) : + C.tv t x ≤ (C.π x)⁻¹*Real.exp (-(t:ℝ)/K) := by + have hk0 : 0 (C.positive y).le) (Finset.mem_univ x) + _ = 1 := C.normalized + have hi : 1≤(C.π x)⁻¹ := (one_le_inv₀ (C.positive x)).mpr hπ + have hic : (1/C.π x-1)/4≤((C.π x)⁻¹)^2 := by + simp only [one_div] + nlinarith only [hi,sq_nonneg ((C.π x)⁻¹-1)] + have he0 : 0≤(Real.exp (-(t:ℝ)/K))^2 := sq_nonneg _ + have hfinal := mul_le_mul_of_nonneg_right hic he0 + have htv := C.tv_sq t x + have hi0 : 0≤C.tv t x := by unfold tv; positivity + have hout0 : 0≤(C.π x)⁻¹*Real.exp (-(t:ℝ)/K) := by positivity + apply (sq_le_sq₀ hi0 hout0).mp + nlinarith only [htv,hn,hp,hfinal] + +theorem mixing_bound_min [DecidableEq V] (K : ℝ) (hK : 1≤K) + (hvar : ∀ f : V → ℝ, C.variance f ≤ K*C.energy f) + (pmin : ℝ) (hpmin : 0 + if i=i₀ then + if j=j₀ then R i₀-∑ j ∈ Finset.univ.erase j₀, P j else P j + else if j=j₀ then R i else 0 + +@[simp] theorem adjustment_row (i₀ : Fin m) (j₀ : Fin n) (R : Fin m → ℤ) (P : Fin n → ℤ) + (i : Fin m) : (∑ j, adjustment i₀ j₀ R P i j)=R i := by + classical + rw [← Finset.sum_erase_add _ _ (Finset.mem_univ j₀)] + by_cases hi : i=i₀ + · subst i + simp only [adjustment,ite_true] + have he : (∑ j ∈ Finset.univ.erase j₀, if j=j₀ then R i₀-∑ j ∈ Finset.univ.erase j₀,P j else P j)= + ∑ j ∈ Finset.univ.erase j₀,P j := by + apply Finset.sum_congr rfl; intro j hj + rw [ite_eq_right (Finset.mem_erase.mp hj).1] + rw [he]; ring + · simp only [adjustment,ite_eq_right hi,ite_true] + have he : (∑ j ∈ Finset.univ.erase j₀, if j=j₀ then R i else 0)=0 := by + apply Finset.sum_eq_zero; intro j hj + rw [ite_eq_right (Finset.mem_erase.mp hj).1] + rw [he]; ring + +@[simp] theorem adjustment_col (i₀ : Fin m) (j₀ : Fin n) (R : Fin m → ℤ) (P : Fin n → ℤ) + (heq : (∑ i,R i)=∑ j,P j) (j : Fin n) : (∑ i,adjustment i₀ j₀ R P i j)=P j := by + classical + rw [← Finset.sum_erase_add _ _ (Finset.mem_univ i₀)] + have he : (∑ i ∈ Finset.univ.erase i₀, adjustment i₀ j₀ R P i j)= + ∑ i ∈ Finset.univ.erase i₀, if j=j₀ then R i else 0 := by + apply Finset.sum_congr rfl; intro i hi + rw [adjustment,ite_eq_right (Finset.mem_erase.mp hi).1] + rw [he] + by_cases hj : j=j₀ + · subst j + simp only [adjustment,ite_true] + have hR := Finset.sum_erase_add Finset.univ R (Finset.mem_univ i₀) + have hP := Finset.sum_erase_add Finset.univ P (Finset.mem_univ j₀) + omega + · simp [adjustment,hj] + +@[simp] theorem adjustment_neg (i₀ : Fin m) (j₀ : Fin n) (R : Fin m → ℤ) (P : Fin n → ℤ) + (i : Fin m) (j : Fin n) : + adjustment i₀ j₀ (fun i => -R i) (fun j => -P j) i j = -adjustment i₀ j₀ R P i j := by + simp only [adjustment,Finset.sum_neg_distrib] + split_ifs <;> ring + + + +def Accepted (r : Fin m → ℕ) (c : Fin n → ℕ) (D : Fin m → Fin n → ℤ) := + {X : Tables r c // ∀ i j, 0≤(X.val i j:ℤ)+D i j} + +instance (r : Fin m → ℕ) (c : Fin n → ℕ) (D : Fin m → Fin n → ℤ) : Finite (Accepted r c D) := + inferInstanceAs (Finite {X : Tables r c // ∀ i j, 0≤(X.val i j:ℤ)+D i j}) + +noncomputable def translate (r r' : Fin m → ℕ) (c c' : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) + (hR : ∀ i, ∑ j,D i j=(r' i:ℤ)-r i) (hP : ∀ j,∑ i,D i j=(c' j:ℤ)-c j) + (X : Accepted r c D) : Accepted r' c' (fun i j => -D i j) := by + let Y := fun i j => ((X.val.val i j:ℤ)+D i j).toNat + have hY (i j) : (Y i j:ℤ)=(X.val.val i j:ℤ)+D i j := Int.toNat_of_nonneg (X.property i j) + refine ⟨⟨Y,?_,?_⟩,?_⟩ + · intro i + apply Int.ofNat_inj.mp + simp only [Nat.cast_sum,hY,Finset.sum_add_distrib,hR] + have hh := X.val.property.1 i + have hh' : (∑ j,(X.val.val i j:ℤ))=(r i:ℤ) := by exact_mod_cast hh + rw [hh']; ring + · intro j + apply Int.ofNat_inj.mp + simp only [Nat.cast_sum,hY,Finset.sum_add_distrib,hP] + have hh := X.val.property.2 j + have hh' : (∑ i,(X.val.val i j:ℤ))=(c j:ℤ) := by exact_mod_cast hh + rw [hh']; ring + · intro i j + change 0≤(Y i j:ℤ)+(-D i j) + rw [hY]; omega + +@[simp] theorem translate_value (r r' : Fin m → ℕ) (c c' : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) + (hR : ∀ i, ∑ j,D i j=(r' i:ℤ)-r i) (hP : ∀ j,∑ i,D i j=(c' j:ℤ)-c j) + (X : Accepted r c D) (i j) : + ((translate r r' c c' D hR hP X).val.val i j:ℤ)=(X.val.val i j:ℤ)+D i j := + Int.toNat_of_nonneg (X.property i j) + +noncomputable def translationEquiv (r r' : Fin m → ℕ) (c c' : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) + (hR : ∀ i, ∑ j,D i j=(r' i:ℤ)-r i) (hP : ∀ j,∑ i,D i j=(c' j:ℤ)-c j) : + Accepted r c D ≃ Accepted r' c' (fun i j => -D i j) := by + have hnR : ∀ i,∑ j,-D i j=(r i:ℤ)-r' i := by + intro i; rw [Finset.sum_neg_distrib,hR]; ring + have hnP : ∀ j,∑ i,-D i j=(c j:ℤ)-c' j := by + intro j; rw [Finset.sum_neg_distrib,hP]; ring + let inv : Accepted r' c' (fun i j => -D i j) → Accepted r c D := fun Y => + ⟨(translate r' r c' c (fun i j => -D i j) hnR hnP Y).val,by + intro i j + simp⟩ + refine ⟨translate r r' c c' D hR hP,inv,?_,?_⟩ + · intro X + apply Subtype.ext; apply Subtype.ext + funext i j; apply Int.ofNat_inj.mp + change ((translate r' r c' c _ hnR hnP (translate r r' c c' D hR hP X)).val.val i j:ℤ)=_ + rw [translate_value,translate_value]; ring + · intro Y + apply Subtype.ext; apply Subtype.ext + funext i j; apply Int.ofNat_inj.mp + rw [translate_value] + change ((translate r' r c' c _ hnR hnP Y).val.val i j:ℤ)+D i j=(Y.val.val i j:ℤ) + rw [translate_value]; ring + + +theorem accepted_card_symm (r r' : Fin m → ℕ) (c c' : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) + (hR : ∀ i, ∑ j,D i j=(r' i:ℤ)-r i) (hP : ∀ j,∑ i,D i j=(c' j:ℤ)-c j) : + Nat.card (Accepted r c D)=Nat.card (Accepted r' c' (fun i j => -D i j)) := + Nat.card_congr (translationEquiv r r' c c' D hR hP) + + + +def Rejected (r : Fin m → ℕ) (c : Fin n → ℕ) (D : Fin m → Fin n → ℤ) := + {X : Tables r c // ¬∀ i j, 0≤(X.val i j:ℤ)+D i j} + +theorem rejection_union_count (r : Fin m → ℕ) (c : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) (t : ℕ) (hD : ∀ i j, -(t:ℤ)≤D i j) : + Nat.card (Rejected r c D) ≤ ∑ s : Cell m n, Nat.card (SmallEntryBad r c s.1 s.2 t) := by + classical + have hb (X : Rejected r c D) : ∃ s : Cell m n, X.val.val s.1 s.2 ⟨(hb X).choose,⟨X.val,(hb X).choose_spec⟩⟩ + have hi : Function.Injective F := by + intro X Y he + apply Subtype.ext + exact congrArg (fun z : Σ s : Cell m n, SmallEntryBad r c s.1 s.2 t => z.2.val) he + have hh := Nat.card_le_card_of_injective F hi + rw [Nat.card_sigma] at hh + exact hh + +theorem rejection_count (d a t : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) (hd : 1≤d) (hm : m≤d) (hn : n≤d) + (ha : 4*d≤a) (hr : ∀ i,a≤r i) (hc : ∀ j,a≤c j) (ht : 2*t≤a) + (hD : ∀ i j, -(t:ℤ)≤D i j) : + Nat.card (Rejected r c D)*a ≤ 4*t*d^3*(m*n)*Nat.card (Tables r c) := by + have hu := Nat.mul_le_mul_right a (rejection_union_count r c D t hD) + have hh : (∑ s : Cell m n, Nat.card (SmallEntryBad r c s.1 s.2 t))*a ≤ + ∑ s : Cell m n, 4*t*d^3*Nat.card (Tables r c) := by + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro s _ + exact small_entry_count d a t r c s.1 s.2 hd hm hn ha (hr s.1) (hc s.2) ht + have he : (∑ s : Cell m n, 4*t*d^3*Nat.card (Tables r c))= + 4*t*d^3*(m*n)*Nat.card (Tables r c) := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_prod,Fintype.card_fin,nsmul_eq_mul,Nat.cast_id] + ring + exact hu.trans (he ▸ hh) + +theorem accepted_rejected_count (r : Fin m → ℕ) (c : Fin n → ℕ) (D : Fin m → Fin n → ℤ) : + Nat.card (Accepted r c D)+Nat.card (Rejected r c D)=Nat.card (Tables r c) := by + classical + have hh := Nat.card_congr (Equiv.sumCompl (fun X : Tables r c => ∀ i j,0≤(X.val i j:ℤ)+D i j)) + rw [Nat.card_sum] at hh + exact hh + + + +theorem accepted_half (d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (D : Fin m → Fin n → ℤ) (hd : 14≤d) (hm : m≤d) (hn : n≤d) (hmn : m*n≤d) + (hr : ∀ i,d^12≤r i) (hc : ∀ j,d^12≤c j) + (hD : ∀ i j, -(10*(d:ℤ))≤D i j) : + Nat.card (Tables r c) ≤ 2*Nat.card (Accepted r c D) := by + have hd1 : 1≤d := by omega + have hd7 : 80≤d^7 := by + calc + 80 ≤ 14^7 := by norm_num + _ ≤ d^7 := Nat.pow_le_pow_left hd _ + have hd5 : 1≤d^5 := one_le_pow₀ hd1 + have hd11 : 80≤d^11 := by + calc + 80 ≤ 14^11 := by norm_num + _ ≤ d^11 := Nat.pow_le_pow_left hd _ + have he12 : d^12=d*d^11 := by ring + have h4 : 4*d≤d^12 := by nlinarith only [hd11,he12] + have ht : 2*(10*d)≤d^12 := by nlinarith only [hd11,he12] + have hD' : ∀ i j, -((10*d:ℕ):ℤ)≤D i j := by simpa only [Nat.cast_mul,Nat.cast_ofNat] using hD + have hh := rejection_count d (d^12) (10*d) r c D hd1 hm hn h4 hr hc ht hD' + have hhalf : 2*(4*(10*d)*d^3*(m*n))≤d^12 := by + calc + _ ≤ 80*d^5 := by nlinarith only [Nat.mul_le_mul_left (40*d^4) hmn] + _ ≤ d^12 := by + have := Nat.mul_le_mul_left (d^5) hd7 + nlinarith only [this,show d^12=d^5*d^7 by ring] + have hwhole := accepted_rejected_count r c D + have hc' := Nat.mul_le_mul_right (Nat.card (Tables r c)) hhalf + have hb : 2*Nat.card (Rejected r c D)≤Nat.card (Tables r c) := by + by_contra h + have hpos : 0 U≤r i) (fun j => U≤c j) er ec + (fun i hi => by + unfold rowNat + rw [residualRow_zero U L r c _ (graph_feasible U r c X) i (by omega)] + rfl) + (fun j hj => by + unfold colNat + rw [residualCol_zero U L r c _ (graph_feasible U r c X) j (by omega)] + rfl)) + +theorem block_totals (X : GraphState U r c) (h : (∑ i,r i)=∑ j,c j) : + (∑ i,blockRow U L r c er X i)=∑ j,blockCol U L r c ec X j := by + obtain ⟨A⟩ := completion_nonempty U L r c X h + let B := blockEquiv U L r c er ec X A + calc + _ = ∑ i,∑ j,B.val i j := by simp only [B.property.1] + _ = ∑ j,∑ i,B.val i j := Finset.sum_comm + _ = _ := by simp only [B.property.2] + +include ec in +theorem block_row_lower (X : GraphState U r c) (i : Fin a) (j : Fin b) : + L≤blockRow U L r c er X i := by + have hf := graph_feasible U r c X + have hh := (hf.2.2.1 (er i).val).1 + have hp : (L:ℤ)≤rowPadding U L r c (er i).val := by + unfold rowPadding + have he : IsLarge U r c ((er i).val,(ec j).val) := ⟨(er i).property,(ec j).property⟩ + have h := Finset.single_le_sum (f:=fun j => if IsLarge U r c ((er i).val,j) then (L:ℤ) else 0) + (fun j _ => by split_ifs <;> positivity) (Finset.mem_univ (ec j).val) + simpa only [ite_eq_left he] using h + apply Int.ofNat_le.mp + change (L:ℤ)≤(rowNat U L r c _ _ :ℤ) + rw [rowNat_cast U L r c _ hf] + dsimp [residualRow]; omega + +include er in +theorem block_col_lower (X : GraphState U r c) (i : Fin a) (j : Fin b) : + L≤blockCol U L r c ec X j := by + have hf := graph_feasible U r c X + have hh := (hf.2.2.2 (ec j).val).1 + have hp : (L:ℤ)≤colPadding U L r c (ec j).val := by + unfold colPadding + have he : IsLarge U r c ((er i).val,(ec j).val) := ⟨(er i).property,(ec j).property⟩ + have h := Finset.single_le_sum (f:=fun i => if IsLarge U r c (i,(ec j).val) then (L:ℤ) else 0) + (fun i _ => by split_ifs <;> positivity) (Finset.mem_univ (er i).val) + simpa only [ite_eq_left he] using h + apply Int.ofNat_le.mp + change (L:ℤ)≤(colNat U L r c _ _ :ℤ) + rw [colNat_cast U L r c _ hf] + dsimp [residualCol]; omega + +include er ec in +theorem block_dimensions : a ≤ m ∧ b ≤ n := by + constructor + · have h := Fintype.card_le_of_injective (fun i : Fin a => (er i).val) + (Subtype.val_injective.comp er.injective) + simpa using h + · have h := Fintype.card_le_of_injective (fun j : Fin b => (ec j).val) + (Subtype.val_injective.comp ec.injective) + simpa using h + +theorem block_movement (X Y : GraphState U r c) (h : GraphAdj U r c X Y) : + (∀ i,|(blockRow U L r c er Y i:ℤ)-blockRow U L r c er X i|≤2) ∧ + (∀ j,|(blockCol U L r c ec Y j:ℤ)-blockCol U L r c ec X j|≤2) := by + have hh := graph_margin_movement U L r c X Y h + constructor + · intro i + simpa only [blockRow,rowNat_cast U L r c _ (graph_feasible U r c Y), + rowNat_cast U L r c _ (graph_feasible U r c X)] using hh.1 (er i).val + · intro j + simpa only [blockCol,colNat_cast U L r c _ (graph_feasible U r c Y), + colNat_cast U L r c _ (graph_feasible U r c X)] using hh.2 (ec j).val + +end +end Contingency.PaddedGraph + +namespace Contingency.CompletionTranslation +variable {m n : ℕ} + +theorem adjustment_bound (d : ℕ) (hd : 1≤d) (hn : n≤d) + (i₀ : Fin m) (j₀ : Fin n) (R : Fin m → ℤ) (P : Fin n → ℤ) + (hR : ∀ i,|R i|≤2) (hP : ∀ j,|P j|≤2) (i : Fin m) (j : Fin n) : + |adjustment i₀ j₀ R P i j|≤10*(d:ℤ) := by + have hd' : (1:ℤ)≤d := by exact_mod_cast hd + have hb : |∑ j ∈ Finset.univ.erase j₀,P j|≤2*(d:ℤ) := by + calc + _ ≤ ∑ j ∈ Finset.univ.erase j₀,|P j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ j ∈ Finset.univ.erase j₀,(2:ℤ) := Finset.sum_le_sum (fun j _ => hP j) + _ ≤ 2*(d:ℤ) := by + simp only [Finset.sum_const,nsmul_eq_mul] + have hh : (Finset.univ.erase j₀).card≤d := + (Finset.card_le_card (Finset.erase_subset _ _)).trans (by simpa using hn) + exact_mod_cast (by omega : (Finset.univ.erase j₀).card*2≤2*d) + unfold adjustment + split_ifs + · exact (abs_sub _ _).trans (by linarith [hR i₀]) + · linarith [hP j] + · linarith [hR i] + · simp +end Contingency.CompletionTranslation + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open CompletionTranslation +variable {m n a b : ℕ} (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // U≤r i}) (ec : Fin b ≃ {j // U≤c j}) + (i₀ : Fin a) (j₀ : Fin b) + +def blockD (X Y : GraphState U r c) : Fin a → Fin b → ℤ := + adjustment i₀ j₀ + (fun i => (blockRow U L r c er Y i:ℤ)-blockRow U L r c er X i) + (fun j => (blockCol U L r c ec Y j:ℤ)-blockCol U L r c ec X j) + +theorem blockD_row (X Y : GraphState U r c) (i : Fin a) : + (∑ j,blockD U L r c er ec i₀ j₀ X Y i j)= + (blockRow U L r c er Y i:ℤ)-blockRow U L r c er X i := + adjustment_row _ _ _ _ _ + +theorem blockD_col (X Y : GraphState U r c) (hrc : (∑ i,r i)=∑ j,c j) (j : Fin b) : + (∑ i,blockD U L r c er ec i₀ j₀ X Y i j)= + (blockCol U L r c ec Y j:ℤ)-blockCol U L r c ec X j := by + apply adjustment_col + simp only [Finset.sum_sub_distrib,← Nat.cast_sum,block_totals U L r c er ec _ hrc] + +theorem blockD_reverse (X Y : GraphState U r c) : + blockD U L r c er ec i₀ j₀ Y X=fun i j => -blockD U L r c er ec i₀ j₀ X Y i j := by + have heR : (fun i => (blockRow U L r c er X i:ℤ)-blockRow U L r c er Y i)= + (fun i => -((blockRow U L r c er Y i:ℤ)-blockRow U L r c er X i)) := by funext i; ring + have heP : (fun j => (blockCol U L r c ec X j:ℤ)-blockCol U L r c ec Y j)= + (fun j => -((blockCol U L r c ec Y j:ℤ)-blockCol U L r c ec X j)) := by funext j; ring + funext i j + simp only [blockD,heR,heP,adjustment_neg] + +def acceptCount (X Y : GraphState U r c) : ℕ := + Nat.card (Accepted (blockRow U L r c er X) (blockCol U L r c ec X) + (blockD U L r c er ec i₀ j₀ X Y)) + +theorem acceptCount_symm (X Y : GraphState U r c) (hrc : (∑ i,r i)=∑ j,c j) : + acceptCount U L r c er ec i₀ j₀ X Y=acceptCount U L r c er ec i₀ j₀ Y X := by + unfold acceptCount + rw [blockD_reverse U L r c er ec i₀ j₀ X Y] + exact accepted_card_symm _ _ _ _ _ (blockD_row U L r c er ec i₀ j₀ X Y) + (blockD_col U L r c er ec i₀ j₀ X Y hrc) + +theorem block_card (X : GraphState U r c) : + Nat.card (Tables (blockRow U L r c er X) (blockCol U L r c ec X))= + weight U L r c (graphUnderlying U r c X) := by + rw [weight,ite_eq_left (graph_feasible U r c X)] + exact (Nat.card_congr (blockEquiv U L r c er ec X)).symm + +theorem acceptCount_le (X Y : GraphState U r c) : + acceptCount U L r c er ec i₀ j₀ X Y≤weight U L r c (graphUnderlying U r c X) := by + rw [← block_card U L r c er ec X] + exact Nat.card_le_card_of_injective Subtype.val Subtype.val_injective + +theorem acceptCount_half (d : ℕ) (hd : 14≤d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n≤d) + (X Y : GraphState U r c) (h : GraphAdj U r c X Y) : + weight U (d^12) r c (graphUnderlying U r c X)≤2*acceptCount U (d^12) r c er ec i₀ j₀ X Y := by + rw [← block_card U (d^12) r c er ec X] + have hdim := block_dimensions U r c er ec + apply accepted_half d _ _ _ hd (hdim.1.trans hm) (hdim.2.trans hn) + ((Nat.mul_le_mul hdim.1 hdim.2).trans hmn) + (fun i => block_row_lower U (d^12) r c er ec X i j₀) + (fun j => block_col_lower U (d^12) r c er ec X i₀ j) + intro i j + have hh := block_movement U (d^12) r c er ec X Y h + have hb := adjustment_bound d (by omega) (hdim.2.trans hn) i₀ j₀ _ _ hh.1 hh.2 i j + exact (abs_le.mp hb).1 + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open CompletionTranslation FiniteChain +variable {m n a b : ℕ} (U L d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // U≤r i}) (ec : Fin b ≃ {j // U≤c j}) + (i₀ : Fin a) (j₀ : Fin b) + +def edgeCount (X Y : GraphState U r c) : ℝ := + if GraphAdj U r c X Y then (acceptCount U L r c er ec i₀ j₀ X Y:ℝ) else 0 + +theorem edgeCount_nonneg (X Y : GraphState U r c) : 0≤edgeCount U L r c er ec i₀ j₀ X Y := by + unfold edgeCount; split_ifs <;> positivity + +theorem edgeCount_symm (hrc : (∑ i,r i)=∑ j,c j) (X Y : GraphState U r c) : + edgeCount U L r c er ec i₀ j₀ X Y=edgeCount U L r c er ec i₀ j₀ Y X := by + unfold edgeCount + have he : GraphAdj U r c X Y ↔ GraphAdj U r c Y X := ⟨GraphAdj.symm U r c,GraphAdj.symm U r c⟩ + simp only [he,acceptCount_symm U L r c er ec i₀ j₀ X Y hrc] + +theorem edgeCount_diagonal (X : GraphState U r c) : edgeCount U L r c er ec i₀ j₀ X X=0 := by + simp [edgeCount,GraphAdj.irrefl] + +theorem edgeCount_sum (hmn : m*n≤d) (X : GraphState U r c) : + (∑ Y,edgeCount U L r c er ec i₀ j₀ X Y)≤ + (5*(d:ℝ)^2+1)*weight U L r c (graphUnderlying U r c X) := by + simp only [edgeCount,← Finset.sum_filter] + calc + _ ≤ ∑ Y ∈ Finset.univ.filter (GraphAdj U r c X), + (weight U L r c (graphUnderlying U r c X):ℝ) := by + apply Finset.sum_le_sum; intro Y _ + exact_mod_cast acceptCount_le U L r c er ec i₀ j₀ X Y + _ = ((Finset.univ.filter (GraphAdj U r c X)).card:ℝ)*weight U L r c (graphUnderlying U r c X) := by simp + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact_mod_cast graph_degree U r c d hmn X + +theorem proposal_hold (hd : 1≤d) : proposalRate (32*d^2)*(5*(d:ℝ)^2+1)≤1/2 := by + have hb := (smallProposal_bounds d hd).2 + have hd' : (1:ℝ)≤d := by exact_mod_cast hd + have hd2 : (1:ℝ)≤(d:ℝ)^2 := one_le_pow₀ hd' + calc + _ ≤ (1/(32*(d:ℝ)^2))*(5*(d:ℝ)^2+1) := mul_le_mul_of_nonneg_right hb (by positivity) + _ ≤ 1/2 := by + rw [one_div_mul_eq_div] + apply (div_le_iff₀ (by positivity : 0<32*(d:ℝ)^2)).mpr + nlinarith + +def smallData (hrc : (∑ i,r i)=∑ j,c j) (hd : 1≤d) (hmn : m*n≤d) : AcceptedData (GraphState U r c) where + f X := weight U L r c (graphUnderlying U r c X) + fpos X := by exact_mod_cast graph_weight_pos U L r c X hrc + count := edgeCount U L r c er ec i₀ j₀ + nonneg := edgeCount_nonneg U L r c er ec i₀ j₀ + symmetric := edgeCount_symm U L r c er ec i₀ j₀ hrc + diagonal := edgeCount_diagonal U L r c er ec i₀ j₀ + q := proposalRate (32*d^2) + qpos := by unfold proposalRate; positivity + hold X := by + have hq : 0≤proposalRate (32*d^2) := by unfold proposalRate; positivity + have hh := mul_le_mul_of_nonneg_left (edgeCount_sum U L d r c er ec i₀ j₀ hmn X) hq + calc + _ ≤ proposalRate (32*d^2)*((5*(d:ℝ)^2+1)*weight U L r c (graphUnderlying U r c X)) := hh + _ = (proposalRate (32*d^2)*(5*(d:ℝ)^2+1))*weight U L r c (graphUnderlying U r c X) := by ring + _ ≤ (1/2)*weight U L r c (graphUnderlying U r c X) := + mul_le_mul_of_nonneg_right (proposal_hold d hd) (by positivity) + _ = _ := by ring + +variable [Nonempty (GraphState U r c)] + +theorem small_transition_lower (hrc : (∑ i,r i)=∑ j,c j) + (hd : 14≤d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n≤d) + (X Y : GraphState U r c) (h : GraphAdj U r c X Y) : + (smallData U (d^12) d r c er ec i₀ j₀ hrc (by omega) hmn).chain.P X Y ≥ + 1/(128*(d:ℝ)^2)*min 1 + ((weight U (d^12) r c (graphUnderlying U r c Y):ℝ)/weight U (d^12) r c (graphUnderlying U r c X)) := by + have hne : X≠Y := by rintro rfl; exact GraphAdj.irrefl U r c X h + have hf : (0:ℝ) 0) + +@[simp] theorem extendGraph_apply (H : GraphState U r c → ℝ) (X : GraphState U r c) : + extendGraph U r c H (graphUnderlying U r c X)=H X := + (graphUnderlying_injective U r c).extend_apply H (fun _ => 0) X + +lemma sum_le_mapped_support {α β : Type*} [DecidableEq α] [Fintype β] + (E : Finset α) (f : α → ℝ) (F : β → α) + (hf : ∀ e,0≤f e) (hs : ∀ e∈E,f e≠0 → ∃ x,F x=e) : + (∑ e∈E,f e) ≤ ∑ x,if F x∈E then f (F x) else 0 := by + classical + let I := Finset.univ.image F + let g := fun e => if e∈E then f e else 0 + have hg : ∀ e,0≤g e := by + intro e; dsimp [g]; split_ifs + · exact hf e + · exact le_rfl + have heq : (∑ e∈E,f e)=∑ e∈E,g e := by + apply Finset.sum_congr rfl; intro e he + exact (ite_eq_left he).symm + have hz : ∀ e∈E∪I,e∉I → g e=0 := by + intro e _ hi + dsimp [g] + split_ifs with he + · by_contra hp + obtain ⟨x,hx⟩ := hs e he hp + exact hi (Finset.mem_image.mpr ⟨x,Finset.mem_univ _,hx⟩) + · rfl + have hi : (∑ e∈I,g e)=∑ e∈E∪I,g e := Finset.sum_subset Finset.subset_union_right hz + calc + _ = ∑ e∈E,g e := heq + _ ≤ ∑ e∈E∪I,g e := Finset.sum_le_sum_of_subset_of_nonneg Finset.subset_union_left (fun e _ _ => hg e) + _ = ∑ e∈I,g e := hi.symm + _ ≤ ∑ x,g (F x) := Finset.sum_image_le_of_nonneg (fun e _ => hg e) + +theorem graphEdge_value (hrc : (∑ i,r i)=∑ j,c j) + (hC : ∀ i,paddedRow U L r c i≤C) (H : GraphState U r c → ℝ) + (X Y : GraphState U r c) : + edgeEnergy (smallKernel 0 U L C r c) (extendGraph U r c H ∘ coordinatesState U r c) + s(graphCoordinates U r c X,graphCoordinates U r c Y) = + min (weight U L r c (graphUnderlying U r c X):ℝ) (weight U L r c (graphUnderlying U r c Y):ℝ)*(H X-H Y)^2 := by + rw [edgeEnergy_mk] + simp only [Function.comp_apply,graphCoordinates, + coordinates_state_inverse U r c _ (graph_feasible U r c X).2.1, + coordinates_state_inverse U r c _ (graph_feasible U r c Y).2.1, + state_kernel_weight U L C r c hrc hC _ (graph_feasible U r c X), + state_kernel_weight U L C r c hrc hC _ (graph_feasible U r c Y),extendGraph_apply] + +theorem graphEnergy_le_pairs (H : GraphState U r c → ℝ) : + graphEnergy U L C r c (extendGraph U r c H) ≤ + ∑ xy : GraphState U r c × GraphState U r c, + if s(graphCoordinates U r c xy.1,graphCoordinates U r c xy.2)∈fullEdges U r c then + edgeEnergy (smallKernel 0 U L C r c) (extendGraph U r c H ∘ coordinatesState U r c) + s(graphCoordinates U r c xy.1,graphCoordinates U r c xy.2) else 0 := by + classical + have hh := sum_le_mapped_support (fullEdges U r c) + (edgeEnergy (smallKernel 0 U L C r c) (extendGraph U r c H ∘ coordinatesState U r c)) + (fun xy : GraphState U r c × GraphState U r c => + s(graphCoordinates U r c xy.1,graphCoordinates U r c xy.2)) + (edgeEnergy_nonneg _ _ (smallKernel_nonneg 0 (by positivity) U L C r c)) + (fun e he hp => by + obtain ⟨X,Y,hXY⟩ := positive_edge U L C r c (extendGraph U r c H) e he hp + exact ⟨(X,Y),hXY.symm⟩) + exact hh + +theorem graphEnergy_le_ordered (hrc : (∑ i,r i)=∑ j,c j) + (hC : ∀ i,paddedRow U L r c i≤C) (H : GraphState U r c → ℝ) : + graphEnergy U L C r c (extendGraph U r c H) ≤ + ∑ X,∑ Y,if GraphAdj U r c X Y then + min (weight U L r c (graphUnderlying U r c X):ℝ) (weight U L r c (graphUnderlying U r c Y):ℝ)*(H X-H Y)^2 else 0 := by + classical + have hh := graphEnergy_le_pairs U L C r c H + rw [Fintype.sum_prod_type] at hh + refine hh.trans_eq ?_ + apply Finset.sum_congr rfl; intro X _ + apply Finset.sum_congr rfl; intro Y _ + by_cases h : GraphAdj U r c X Y + · have h' : s(graphCoordinates U r c X,graphCoordinates U r c Y)∈fullEdges U r c := h + simp only [ite_eq_left h,ite_eq_left h'] + exact graphEdge_value U L C r c hrc hC H X Y + · have h' : s(graphCoordinates U r c X,graphCoordinates U r c Y)∉fullEdges U r c := h + simp only [ite_eq_right h,ite_eq_right h'] + +variable (er : Fin a ≃ {i // U≤r i}) (ec : Fin b ≃ {j // U≤c j}) + (i₀ : Fin a) (j₀ : Fin b) + +theorem graphEnergy_le_accepted (hrc : (∑ i,r i)=∑ j,c j) + (hd : 14≤d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n≤d) + (hC : ∀ i,paddedRow U (d^12) r c i≤C) (H : GraphState U r c → ℝ) : + graphEnergy U (d^12) C r c (extendGraph U r c H) ≤ + 2*(∑ X,∑ Y,edgeCount U (d^12) r c er ec i₀ j₀ X Y*(H X-H Y)^2) := by + apply (graphEnergy_le_ordered U (d^12) C r c hrc hC H).trans + simp only [Finset.mul_sum] + apply Finset.sum_le_sum; intro X _ + apply Finset.sum_le_sum; intro Y _ + by_cases h : GraphAdj U r c X Y + · simp only [ite_eq_left h,edgeCount] + rw [← mul_assoc] + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + apply (min_le_left _ _).trans + exact_mod_cast acceptCount_half U r c er ec i₀ j₀ d hd hm hn hmn X Y h + · simp [h,edgeCount] + +end +end Contingency.PaddedGraph + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/Completions.lean b/lean/OAI/Probability/Contingency/Completions.lean new file mode 100644 index 0000000000000000000000000000000000000000..88b0e8b64d91e868b6efb8996e97d8f82a07f54a --- /dev/null +++ b/lean/OAI/Probability/Contingency/Completions.lean @@ -0,0 +1,526 @@ +import Mathlib +import OAI.Probability.Contingency.DenseDyadic + +namespace OAI + +/-! Completions. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators + +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +def rowPadding (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (i : Fin m) : ℤ := + ∑ j, if IsLarge U r c (i,j) then (L:ℤ) else 0 + +def colPadding (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (j : Fin n) : ℤ := + ∑ i, if IsLarge U r c (i,j) then (L:ℤ) else 0 + + + +def Completion (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (X : State m n) := + { A : Cell m n → ℤ // (∀ w, 0 ≤ A w) ∧ + (∀ w, IsSmall U r c w → A w = 0) ∧ + (∀ i, rowSum A i = r i - rowSum X.x i + rowPadding U L r c i) ∧ + (∀ j, colSum A j = c j - colSum X.q j + colPadding U L r c j) } + +instance completionFinite (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (X : State m n) : + Finite (Completion U L r c X) := by + let f : Completion U L r c X → (w : Cell m n) → + Fin ((r w.1 - rowSum X.x w.1 + rowPadding U L r c w.1).toNat + 1) := + fun A w => ⟨(A.val w).toNat, by + have h := coordinate_le_rowSum A.val A.property.1 w + rw [A.property.2.2.1 w.1] at h + have hh := Int.toNat_le_toNat h + omega⟩ + apply Finite.of_injective f + intro A B he + apply Subtype.ext + funext w + have h := congrArg (fun g => (g w).val) he + dsimp [f] at h + have hA := A.property.1 w + have hB := B.property.1 w + omega + +def completionRepair (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) + (A : Completion U L r c X) : Completion U L r c (repair U r c s t X) := by + let B := fun w => A.val w + if IsLarge U r c (receiver s t) then unit (receiver s t) w else 0 + refine ⟨B, ?_, ?_, ?_, ?_⟩ + · intro w + have h := A.property.1 w + dsimp [B,unit] + split_ifs <;> omega + · intro w hw + dsimp [B] + rw [A.property.2.1 w hw] + by_cases hv : IsLarge U r c (receiver s t) + · have he : w ≠ receiver s t := by intro he; exact hw (he ▸ hv) + simp [hv,unit,he] + · simp [hv] + · intro i + rw [repair_rowSum U r c s t X i] + by_cases hv : IsLarge U r c (receiver s t) + · have hb : B = fun w => A.val w - 0 + unit (receiver s t) w := by + funext w; simp [B,hv] + rw [hb,rowSum_sub_add,rowSum_unit,A.property.2.2.1 i] + simp only [hv,true_and] + have hz : rowSum (fun _ : Cell m n => (0:ℤ)) i = 0 := by simp [rowSum] + rw [hz] + dsimp [receiver] + omega + · have hb : B = A.val := by funext w; simp [B,hv] + rw [hb,A.property.2.2.1 i] + simp [hv] + · intro j + rw [repair_colSum U r c s t X hd j] + by_cases hv : IsLarge U r c (receiver s t) + · have hb : B = fun w => A.val w - 0 + unit (receiver s t) w := by + funext w; simp [B,hv] + rw [hb,colSum_sub_add,colSum_unit,A.property.2.2.2 j] + simp only [hv,true_and] + have hz : colSum (fun _ : Cell m n => (0:ℤ)) j = 0 := by simp [colSum] + rw [hz] + dsimp [receiver] + omega + · have hb : B = A.val := by funext w; simp [B,hv] + rw [hb,A.property.2.2.2 j] + simp [hv] + +theorem completionRepair_injective (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) : + Function.Injective (completionRepair U L r c s t X hd) := by + intro A B he + apply Subtype.ext + funext w + have h := congrArg (fun A : Completion U L r c (repair U r c s t X) => A.val w) he + dsimp [completionRepair] at h + linarith + + +noncomputable def weight (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (X : State m n) : ℕ := by + classical + exact if Feasible U r c X then Nat.card (Completion U L r c X) else 0 + +theorem weight_repair_le (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) : + weight U L r c X ≤ weight U L r c (repair U r c s t X) := by + classical + by_cases hx : Feasible U r c X + · rw [weight,ite_eq_left hx,weight,ite_eq_left (repair_feasible U r c s t X hx hd)] + exact Nat.card_le_card_of_injective _ (completionRepair_injective U L r c s t X hd) + · simp [weight,hx] + + + +theorem joint_repair_injective (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) : + Function.Injective (fun Z : Σ X : {X : State m n // DefectAt U r c s t X}, + Completion U L r c X.val => + (⟨repair U r c s t Z.1.val, + completionRepair U L r c s t Z.1.val Z.1.property Z.2⟩ : + Σ Y : State m n, Completion U L r c Y)) := by + rintro ⟨⟨X,hX⟩,A⟩ ⟨⟨Y,hY⟩,B⟩ he + have hs := congrArg Sigma.fst he + have hxy := repair_injective U r c s t X Y hX hY hs + subst Y + have ha : completionRepair U L r c s t X hX A = completionRepair U L r c s t X hY B := by + exact (Sigma.mk.inj he).2.eq + have hab := completionRepair_injective U L r c s t X hX ha + subst B + rfl + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators + +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +instance feasibleFinite (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finite {X : State m n // Feasible U r c X} := by + let f : {X : State m n // Feasible U r c X} → Cell m n → Fin (U+1) × Fin (U+1) := + fun X w => (⟨(X.val.x w).toNat, by have h := X.property.1 w; omega⟩, + ⟨(X.val.q w).toNat, by have h := X.property.1 w; omega⟩) + apply Finite.of_injective f + intro X Y he + apply Subtype.ext + have hx : X.val.x=Y.val.x := by + funext w + have h := congrArg (fun g => (g w).1.val) he + dsimp [f] at h + have hX := (X.property.1 w).1 + have hY := (Y.property.1 w).1 + omega + have hq : X.val.q=Y.val.q := by + funext w + have h := congrArg (fun g => (g w).2.val) he + dsimp [f] at h + have hX := (X.property.1 w).2.2.1 + have hY := (Y.property.1 w).2.2.1 + omega + cases X with | mk X hX => + cases Y with | mk Y hY => + cases X; cases Y + simp_all + +def Prefix (s : Cell m n) (σ : Cell m n → ℤ) (X : State m n) : Prop := + ∀ w, Before w s → X.x w = σ w ∧ X.q w = σ w + +def ChildStates (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) := + {X : {X : State m n // Feasible U r c X} // + Transversal X.val ∧ Prefix s σ X.val ∧ X.val.x s = l} + +def DefectStates (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) := + {X : {X : State m n // Feasible U r c X} // + DefectAt U r c s t X.val ∧ Prefix s σ X.val ∧ X.val.x s = l-1} + +instance (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) : Finite (ChildStates U r c s σ l) := + by unfold ChildStates; infer_instance +instance (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) : Finite (DefectStates U r c s t σ l) := + by unfold DefectStates; infer_instance + +noncomputable def conditionalRepair (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) (hst : Before s t) + (X : DefectStates U r c s t σ l) : + ChildStates U r c s σ (if t.1=s.1 then l else l-1) := by + refine ⟨⟨repair U r c s t X.val.val, + repair_feasible U r c s t X.val.val X.val.property X.property.1⟩, + repair_transversal U r c s t X.val.val,?_, + repair_special U r c s t X.val.val X.property.1 l X.property.2.2⟩ + intro w hw + have h := repair_prefix U r c s t X.val.val X.property.1 hst w hw + have h' := X.property.2.1 w hw + exact ⟨h.1.trans h'.1,h.2.trans h'.2⟩ + +def childFiber (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) := + Σ X : ChildStates U r c s σ l, Completion U L r c X.val.val + +def defectFiber (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) := + Σ X : DefectStates U r c s t σ l, Completion U L r c X.val.val + +instance (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) : Finite (childFiber U L r c s σ l) := + inferInstanceAs (Finite (Sigma _)) +instance (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) : Finite (defectFiber U L r c s t σ l) := + inferInstanceAs (Finite (Sigma _)) + +noncomputable def conditionalCompletionRepair (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) (hst : Before s t) + (Z : defectFiber U L r c s t σ l) : childFiber U L r c s σ (if t.1=s.1 then l else l-1) := + ⟨conditionalRepair U r c s t σ l hst Z.1, + completionRepair U L r c s t Z.1.val.val Z.1.property.1 Z.2⟩ + +theorem conditionalCompletionRepair_injective (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) (hst : Before s t) : + Function.Injective (conditionalCompletionRepair U L r c s t σ l hst) := by + rintro ⟨⟨⟨X,hfX⟩,hX⟩,A⟩ ⟨⟨⟨Y,hfY⟩,hY⟩,B⟩ he + have hxy : repair U r c s t X = repair U r c s t Y := + congrArg (fun Z => Z.1.val.val) he + have hxy' := repair_injective U r c s t X Y hX.1 hY.1 hxy + subst Y + have ha : completionRepair U L r c s t X hX.1 A = completionRepair U L r c s t X hY.1 B := + (Sigma.mk.inj he).2.eq + have hab := completionRepair_injective U L r c s t X hX.1 ha + subst B + rfl + +noncomputable def childMass (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) : ℕ := + Nat.card (childFiber U L r c s σ l) + +noncomputable def defectMass (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) : ℕ := + Nat.card (defectFiber U L r c s t σ l) + + + +theorem conditional_repair_bound (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) (hst : Before s t) : + defectMass U L r c s t σ l ≤ + if t.1=s.1 then childMass U L r c s σ l else childMass U L r c s σ (l-1) := by + have h := Nat.card_le_card_of_injective _ + (conditionalCompletionRepair_injective U L r c s t σ l hst) + change defectMass U L r c s t σ l ≤ childMass U L r c s σ (if t.1=s.1 then l else l-1) at h + split_ifs at * <;> exact h + +theorem conditional_repair_max (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (σ : Cell m n → ℤ) (l : ℤ) (hst : Before s t) : + defectMass U L r c s t σ l ≤ max (childMass U L r c s σ (l-1)) (childMass U L r c s σ l) := by + have h := conditional_repair_bound U L r c s t σ l hst + split_ifs at h + · exact h.trans (le_max_right _ _) + · exact h.trans (le_max_left _ _) + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators + +namespace Contingency + + + +theorem softPenalty_zero_iff {m n : ℕ} + (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) (B : Cell m n → ℤ) + (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) : + softPenalty r rb c cb B small p = 0 ↔ + (∀ i : Fin m, (∑ j : Fin n, p (true,(i,j))) = rb i) ∧ + (∀ j : Fin n, (∑ i : Fin m, (B (i,j) - p (false,(i,j)))) = cb j) ∧ + (∀ i : Fin m, (∑ j : Fin n, if (i,j) ∈ small then p (true,(i,j)) else 0) ≤ r i) ∧ + (∀ j : Fin n, (∑ i : Fin m, if (i,j) ∈ small then B (i,j)-p (false,(i,j)) else 0) ≤ c j) := by + classical + rw [softPenalty_expansion] + simp only [Nat.add_eq_zero_iff,Finset.sum_eq_zero_iff,Finset.mem_univ,true_implies, + Int.natAbs_eq_zero,sub_eq_zero,Int.toNat_eq_zero,sub_nonpos] + tauto + +namespace PaddedGraph +variable {m n : ℕ} + +def smallSet (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : Finset (Cell m n) := + Finset.univ.filter (IsSmall U r c) + +def capacity (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (w : Cell m n) : ℤ := + if IsLarge U r c w then C else U + +def paddedRow (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (i : Fin m) : ℤ := + r i + rowPadding U L r c i + +def paddedCol (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (j : Fin n) : ℤ := + c j + colPadding U L r c j + + + +def fullCoordinates (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (A : Cell m n → ℤ) : Coordinate m n → ℤ := + fun w => if w.1 then X.x w.2 + A w.2 else capacity U C r c w.2 - (X.q w.2 + A w.2) + +theorem fullCoordinates_x (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (A : Cell m n → ℤ) (w : Cell m n) : + fullCoordinates U C r c X A (true,w) = X.x w + A w := rfl + +theorem fullCoordinates_q (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (A : Cell m n → ℤ) (w : Cell m n) : + capacity U C r c w - fullCoordinates U C r c X A (false,w) = X.q w + A w := by + simp [fullCoordinates] + +theorem completion_cell_le (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hf : Feasible U r c X) (A : Completion U L r c X) + (w : Cell m n) : A.val w ≤ paddedRow U L r c w.1 := by + have h := coordinate_le_rowSum A.val A.property.1 w + rw [A.property.2.2.1 w.1] at h + have hrow : 0 ≤ rowSum X.x w.1 := by + apply Finset.sum_nonneg; intro j hj; exact (hf.1 (w.1,j)).1 + dsimp [paddedRow] + omega + +theorem fullCoordinates_inBox (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hf : Feasible U r c X) (A : Completion U L r c X) + (hC : ∀ i, paddedRow U L r c i ≤ C) : + InBox (fun w => capacity U C r c w.2) (fullCoordinates U C r c X A.val) := by + rintro ⟨b,w⟩ + have hX := hf.1 w + by_cases hw : IsLarge U r c w + · have hx0 := hf.2.1 w hw + have hA := A.property.1 w + have hAc := (completion_cell_le U L r c X hf A w).trans (hC w.1) + cases b <;> simp [fullCoordinates,capacity,hw,hx0] <;> omega + · have hA := A.property.2.1 w hw + cases b <;> simp [fullCoordinates,capacity,hw,hA] <;> omega + +theorem fullCoordinates_penalty_zero (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hf : Feasible U r c X) (A : Completion U L r c X) : + softPenalty (fun i => r i) (paddedRow U L r c) (fun j => c j) (paddedCol U L r c) + (capacity U C r c) (smallSet U r c) (fullCoordinates U C r c X A.val) = 0 := by + rw [softPenalty_zero_iff] + have hsx (w : Cell m n) : + (if w ∈ smallSet U r c then fullCoordinates U C r c X A.val (true,w) else 0) = X.x w := by + by_cases hw : IsSmall U r c w + · simp [smallSet,hw,fullCoordinates,A.property.2.1 w hw] + · have hx := hf.2.1 w (Classical.not_not.mp hw) + simp [smallSet,hw,hx] + have hsq (w : Cell m n) : + (if w ∈ smallSet U r c then capacity U C r c w - + fullCoordinates U C r c X A.val (false,w) else 0) = X.q w := by + rw [fullCoordinates_q] + by_cases hw : IsSmall U r c w + · simp [smallSet,hw,A.property.2.1 w hw] + · have hx := hf.2.1 w (Classical.not_not.mp hw) + simp [smallSet,hw,hx] + refine ⟨?_,?_,?_,?_⟩ + · intro i + simp only [fullCoordinates_x,Finset.sum_add_distrib] + change rowSum X.x i + rowSum A.val i = _ + rw [A.property.2.2.1 i] + dsimp [paddedRow] + ring + · intro j + simp only [fullCoordinates_q,Finset.sum_add_distrib] + change colSum X.q j + colSum A.val j = _ + rw [A.property.2.2.2 j] + dsimp [paddedCol] + ring + · intro i; simp only [hsx]; exact (hf.2.2.1 i).1 + · intro j; simp only [hsq]; exact (hf.2.2.2 j).1 + +theorem sum_rowSum (x : Cell m n → ℤ) : (∑ i, rowSum x i) = ∑ w, x w := by + simp [rowSum,Fintype.sum_prod_type] + +theorem sum_colSum (x : Cell m n → ℤ) : (∑ j, colSum x j) = ∑ w, x w := by + rw [← sum_rowSum] + exact Finset.sum_comm + +theorem padding_totals (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + (∑ i, rowPadding U L r c i) = ∑ j, colPadding U L r c j := by + exact Finset.sum_comm + +theorem completion_small_totals (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) (X : State m n) (A : Completion U L r c X) : + (∑ w, X.x w) = ∑ w, X.q w := by + have hrow := congrArg (fun f : Fin m → ℤ => ∑ i, f i) (funext A.property.2.2.1) + have hcol := congrArg (fun f : Fin n → ℤ => ∑ j, f j) (funext A.property.2.2.2) + simp only [Finset.sum_add_distrib,Finset.sum_sub_distrib,sum_rowSum,sum_colSum] at hrow hcol + have he : (∑ i, (r i:ℤ)) = ∑ j, (c j:ℤ) := by exact_mod_cast hrc + have hpad := padding_totals U L r c + omega + +theorem fullCoordinates_total (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) (X : State m n) (A : Completion U L r c X) : + (∑ w, fullCoordinates U C r c X A.val w) = ∑ w, capacity U C r c w := by + simp only [Fintype.sum_prod_type,Fintype.sum_bool,fullCoordinates,ite_true,Bool.false_eq_true,ite_false] + simp only [← Finset.sum_add_distrib] + have he := completion_small_totals U L r c hrc X A + simp only [Fintype.sum_prod_type] at he + have hs : (∑ i, ∑ j, (X.x (i,j)+A.val (i,j) + + (capacity U C r c (i,j)-(X.q (i,j)+A.val (i,j))))) = + (∑ i, ∑ j, capacity U C r c (i,j)) + + (∑ i, ∑ j, X.x (i,j)) - (∑ i, ∑ j, X.q (i,j)) := by + simp only [← Finset.sum_add_distrib,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl; intro i hi + apply Finset.sum_congr rfl; intro j hj + ring + rw [hs,he] + ring + + + +theorem completion_softWeight_one (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) (X : State m n) (hf : Feasible U r c X) + (A : Completion U L r c X) (hC : ∀ i, paddedRow U L r c i ≤ C) : + softWeight 0 (fun i => r i) (paddedRow U L r c) (fun j => c j) (paddedCol U L r c) + (capacity U C r c) (smallSet U r c) (fullCoordinates U C r c X A.val) = 1 := by + rw [softWeight_zero,ite_eq_left] + exact ⟨fullCoordinates_inBox U L C r c X hf A hC, + fullCoordinates_total U L C r c hrc X A, + fullCoordinates_penalty_zero U L C r c X hf A⟩ + + +def LargeChoices (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + {A : Cell m n → ℤ // ∀ w, 0 ≤ A w ∧ A w ≤ C ∧ (IsSmall U r c w → A w=0)} + +instance (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : Finite (LargeChoices U C r c) := by + let f : LargeChoices U C r c → Cell m n → Fin (C+1) := + fun A w => ⟨(A.val w).toNat,by have h := A.property w; omega⟩ + apply Finite.of_injective f + intro A B h + apply Subtype.ext; funext w + have he := congrArg (fun z => (z w).val) h + have hA := (A.property w).1 + have hB := (B.property w).1 + dsimp [f] at he + omega + +noncomputable instance (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Fintype (LargeChoices U C r c) := Fintype.ofFinite _ + +def CompletionEquations (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (A : Cell m n → ℤ) : Prop := + (∀ i, rowSum A i = r i-rowSum X.x i+rowPadding U L r c i) ∧ + (∀ j, colSum A j = c j-colSum X.q j+colPadding U L r c j) + +def choiceCompletion (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (A : LargeChoices U C r c) + (he : CompletionEquations U L r c X A.val) : Completion U L r c X := + ⟨A.val,fun w => (A.property w).1,fun w => (A.property w).2.2,he⟩ + +def completionChoice (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hf : Feasible U r c X) + (hC : ∀ i, paddedRow U L r c i ≤ C) (A : Completion U L r c X) : + LargeChoices U C r c := + ⟨A.val,fun w => ⟨A.property.1 w,(completion_cell_le U L r c X hf A w).trans (hC w.1), + A.property.2.1 w⟩⟩ + +def completionChoiceEquiv (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hf : Feasible U r c X) (hC : ∀ i, paddedRow U L r c i ≤ C) : + Completion U L r c X ≃ {A : LargeChoices U C r c // CompletionEquations U L r c X A.val} where + toFun A := ⟨completionChoice U L C r c X hf hC A,A.property.2.2⟩ + invFun A := choiceCompletion U L C r c X A.val A.property + left_inv _ := rfl + right_inv _ := rfl + +theorem choice_softWeight (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) (X : State m n) (hf : Feasible U r c X) + (A : LargeChoices U C r c) (hC : ∀ i, paddedRow U L r c i ≤ C) : + softWeight 0 (fun i => r i) (paddedRow U L r c) (fun j => c j) (paddedCol U L r c) + (capacity U C r c) (smallSet U r c) (fullCoordinates U C r c X A.val) = + (by classical exact if CompletionEquations U L r c X A.val then (1:ℝ) else 0) := by + classical + by_cases he : CompletionEquations U L r c X A.val + · exact (completion_softWeight_one U L C r c hrc X hf + (choiceCompletion U L C r c X A he) hC).trans (ite_eq_left he).symm + · rw [ite_eq_right he,softWeight_zero,ite_eq_right] + rintro ⟨_,_,hp⟩ + apply he + rw [softPenalty_zero_iff] at hp + constructor + · intro i + have h := hp.1 i + simp only [fullCoordinates_x,Finset.sum_add_distrib] at h + change rowSum X.x i + rowSum A.val i = r i + rowPadding U L r c i at h + omega + · intro j + have h := hp.2.1 j + simp only [fullCoordinates_q,Finset.sum_add_distrib] at h + change colSum X.q j + colSum A.val j = c j + colPadding U L r c j at h + omega + + + +theorem sum_choice_softWeight (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) (X : State m n) (hf : Feasible U r c X) + (hC : ∀ i, paddedRow U L r c i ≤ C) : + (∑ A : LargeChoices U C r c, + softWeight 0 (fun i => r i) (paddedRow U L r c) (fun j => c j) (paddedCol U L r c) + (capacity U C r c) (smallSet U r c) (fullCoordinates U C r c X A.val)) = + (Nat.card (Completion U L r c X) : ℝ) := by + classical + simp_rw [choice_softWeight U L C r c hrc X hf _ hC] + rw [Nat.card_congr (completionChoiceEquiv U L C r c X hf hC)] + rw [Nat.card_eq_fintype_card,Fintype.card_subtype] + simp + +end PaddedGraph +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/ConcreteContexts.lean b/lean/OAI/Probability/Contingency/ConcreteContexts.lean new file mode 100644 index 0000000000000000000000000000000000000000..82cfa7dae38f770c0b376a7135df2a158c3af585 --- /dev/null +++ b/lean/OAI/Probability/Contingency/ConcreteContexts.lean @@ -0,0 +1,557 @@ +import Mathlib +import OAI.Probability.Contingency.ConcreteKernel + +namespace OAI + +/-! Concrete Contexts. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +def smallRank (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (s : SmallSlot U r c) : Fin (m*n) := + finProdFinEquiv s.val + +theorem smallRank_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Function.Injective (smallRank U r c) := by + intro s t h + exact Subtype.ext (finProdFinEquiv.injective h) + + + +noncomputable def smallIndex (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Fin (Fintype.card (SmallSlot U r c)) ≃ SmallSlot U r c := by + letI := LinearOrder.lift' (smallRank U r c) (smallRank_injective U r c) + exact (monoEquivOfFin (SmallSlot U r c) rfl).toEquiv + +theorem smallRank_lt_iff (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : SmallSlot U r c) : smallRank U r c s < smallRank U r c t ↔ Before s.val t.val := by + change s.val.2.val+n*s.val.1.val < t.val.2.val+n*t.val.1.val ↔ _ + have hs := s.val.2.isLt + have ht := t.val.2.isLt + unfold Before + constructor + · intro hh + by_cases hi : s.val.1 < t.val.1 + · exact Or.inl hi + · have hti : t.val.1 ≤ s.val.1 := le_of_not_gt hi + have he : s.val.1=t.val.1 := by + apply Fin.ext + by_contra hn + have hlt : t.val.1.val+1 ≤ s.val.1.val := by omega + have hm := Nat.mul_le_mul_left n hlt + simp only [Nat.mul_add,Nat.mul_one] at hm + omega + exact Or.inr ⟨he,by rw [he] at hh; omega⟩ + · rintro (hi | ⟨hi,hj⟩) + · have hm := Nat.mul_le_mul_left n (show s.val.1.val+1 ≤ t.val.1.val by omega) + simp only [Nat.mul_add,Nat.mul_one] at hm + omega + · rw [hi]; omega + +theorem smallIndex_lt (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Fin (Fintype.card (SmallSlot U r c))) : + Before (smallIndex U r c s).val (smallIndex U r c t).val ↔ s < t := by + let := LinearOrder.lift' (smallRank U r c) (smallRank_injective U r c) + rw [← smallRank_lt_iff] + exact @OrderIso.lt_iff_lt _ _ _ + (LinearOrder.lift' (smallRank U r c) (smallRank_injective U r c)).toPreorder + (monoEquivOfFin (SmallSlot U r c) rfl) s t + + + +noncomputable def contextCoordinates (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) : + SmallCoord U r c ≃ ((Fin k × Bool) ⊕ PairCoords Bool a) := + (((smallIndex U r c).symm.trans (finCongr h)).trans finSumFinEquiv.symm |>.prodCongr (Equiv.refl Bool)).trans + ((Equiv.sumProdDistrib (Fin k) (Fin (a+1)) Bool).trans + (Equiv.sumCongr (Equiv.refl _) (smallCoords a).symm)) + +noncomputable def contextKernel (η : ℝ) (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) + (σ : Fin k → Fin (U+1)) (p : PairCoords Bool a → ℤ) : ℝ := + smallKernel η U L C r c ((Sum.elim (balanceProfile (fun _ => U) σ) p) ∘ + contextCoordinates U r c k a h) + +theorem balanceProfile_box (U k : ℕ) (σ : Fin k → Fin (U+1)) : + InBox (fun _ => (U:ℤ)) (balanceProfile (fun _ => U) σ) := by + intro ⟨s,b⟩ + have hs := (σ s).isLt + cases b <;> dsimp [balanceProfile] <;> omega + +theorem balanceProfile_total (U k : ℕ) (σ : Fin k → Fin (U+1)) : + (∑ w, balanceProfile (fun _ => U) σ w) = (k:ℤ)*U := by + rw [Fintype.sum_prod_type] + simp [balanceProfile] + + + +theorem contextKernel_signature (η : ℝ) (hη : 0 < η) (hη1 : η < 1) + (U L C : ℕ) (hC : 2 ≤ C) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) : + PositiveSlice (contextKernel η U L C r c k a h σ) (fun _ => (U:ℤ)) (((a+1:ℕ):ℤ)*U) ∧ + HasSignature (contextKernel η U L C r c k a h σ) (fun _ => (U:ℤ)) (((a+1:ℕ):ℤ)*U) := by + obtain ⟨hp,hs⟩ := smallKernel_signature η hη hη1 U L C hC r c + have hp' := hp.reindex (contextCoordinates U r c k a h) + have hs' := hs.reindex (contextCoordinates U r c k a h) + have hbox : (fun _ : SmallCoord U r c => (U:ℤ)) ∘ (contextCoordinates U r c k a h).symm = + Sum.elim (fun _ : Fin k × Bool => (U:ℤ)) (fun _ : PairCoords Bool a => (U:ℤ)) := by + funext w; cases w <;> rfl + rw [hbox] at hp' hs' + have hp'' := hp'.fixedContext _ (balanceProfile_box U k σ) + have hs'' := hs'.fixedContext _ (balanceProfile_box U k σ) + rw [balanceProfile_total,h] at hp'' hs'' + have he : ((k+(a+1):ℕ):ℤ)*U-(k:ℤ)*U = ((a+1:ℕ):ℤ)*U := by push_cast; ring + rw [he] at hp'' hs'' + exact ⟨hp'',hs''⟩ + +theorem contextKernel_continuous (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) + (σ : Fin k → Fin (U+1)) (p : PairCoords Bool a → ℤ) : + Continuous (fun η => contextKernel η U L C r c k a h σ p) := + smallKernel_continuous U L C r c _ + +theorem contextKernel_nonneg (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) + (σ : Fin k → Fin (U+1)) (p : PairCoords Bool a → ℤ) : + 0 ≤ contextKernel 0 U L C r c k a h σ p := + smallKernel_nonneg 0 (by norm_num) U L C r c _ + +theorem context_child_no_holes (U L C : ℕ) (hU : 2 ≤ U) (hC : 2 ≤ C) + (r : Fin m → ℕ) (c : Fin n → ℕ) (k a : ℕ) + (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (u v j : ℕ) (huj : u ≤ j) (hjv : j ≤ v) (hv : v ≤ U) : + min (nodeMass U a (contextKernel 0 U L C r c k a h σ) u) + (nodeMass U a (contextKernel 0 U L C r c k a h σ) v) ≤ + nodeMass U a (contextKernel 0 U L C r c k a h σ) j := + nodeMass_min U hU a _ (contextKernel_continuous U L C r c k a h σ) + (fun η hη hη' => (contextKernel_signature η hη hη' U L C hC r c k a h σ).1) + (fun η hη hη' => (contextKernel_signature η hη hη' U L C hC r c k a h σ).2) + u v j huj hjv hv + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +universe u + +noncomputable def branchEquiv (C : ℕ) : (n : ℕ) → Branches C n ≃ (Fin n → Fin (C+1)) + | 0 => { toFun := fun _ i => Fin.elim0 i + invFun := fun _ => PUnit.unit + left_inv := fun x => by cases x; rfl + right_inv := fun x => by funext i; exact Fin.elim0 i } + | n+1 => ((Equiv.refl (Fin (C+1))).prodCongr (branchEquiv C n)).trans + (piHeadEquiv (fun _ : Fin (n+1) => Fin (C+1))).symm + +theorem branchEquiv_value (C n : ℕ) (a : Branches C n) (s : Fin n) : + branchEquiv C n a s = branchValue C n a s := by + induction n with + | zero => exact Fin.elim0 s + | succ n ih => + refine Fin.cases ?_ (fun t => ?_) s + · rfl + · exact ih a.2 t + +theorem allBalance_sum_leaf {ι : Type u} (C n : ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (p : ι → ℤ) : + allBalance C n f p = ∑ a : Branches C n, f (leafDisplay C n p a) := by + induction n generalizing ι with + | zero => simp [allBalance,leafDisplay] + | succ n ih => + change (∑ j ∈ Finset.range (C+1), allBalance C n f (pairAssembly p (j:ℤ) ((C:ℤ)-j))) = _ + rw [← Fin.sum_univ_eq_sum_range] + simp_rw [ih] + change _ = ∑ a : Fin (C+1) × Branches C n, f (leafDisplay C (n+1) p a) + rw [Fintype.sum_prod_type] + rfl + +noncomputable def mixedDisplay {ι : Type u} (n : ℕ) (D : Fin n → ℕ) + (p : ι → ℤ) (a : ∀ s, Fin (D s+1)) : PairCoords ι n → ℤ := + Sum.elim p (balanceProfile D a) ∘ pairCoordsEquiv ι n + +@[simp] theorem mixedDisplay_base {ι : Type u} (n : ℕ) (D : Fin n → ℕ) + (p : ι → ℤ) (a : ∀ s, Fin (D s+1)) (i : ι) : + mixedDisplay n D p a ((pairCoordsEquiv ι n).symm (.inl i)) = p i := by + simp [mixedDisplay] + +@[simp] theorem mixedDisplay_slot {ι : Type u} (n : ℕ) (D : Fin n → ℕ) + (p : ι → ℤ) (a : ∀ s, Fin (D s+1)) (s : Fin n) (b : Bool) : + mixedDisplay n D p a ((pairCoordsEquiv ι n).symm (.inr (s,b))) = + if b then ((a s:ℕ):ℤ) else (D s:ℤ)-(a s:ℕ) := by + simp [mixedDisplay,balanceProfile] + +theorem leafDisplay_mixed {ι : Type u} (C n : ℕ) (p : ι → ℤ) (a : Branches C n) : + leafDisplay C n p a = mixedDisplay n (fun _ => C) p (branchEquiv C n a) := by + funext i + obtain ⟨q,rfl⟩ := (pairCoordsEquiv ι n).symm.surjective i + rcases q with i | ⟨s,b⟩ + · rw [leafDisplay_base,mixedDisplay_base] + · rw [leafDisplay_slot,mixedDisplay_slot,branchEquiv_value] + +theorem mixedDisplay_injective {ι : Type u} (n : ℕ) (D : Fin n → ℕ) (p : ι → ℤ) : + Function.Injective (mixedDisplay n D p) := by + intro a b hab + funext s + have hh := congrFun hab ((pairCoordsEquiv ι n).symm (.inr (s,true))) + simp only [mixedDisplay_slot,ite_true] at hh + apply Fin.ext + exact_mod_cast hh + +theorem leafDisplay_injective {ι : Type u} (C n : ℕ) (p : ι → ℤ) : + Function.Injective (leafDisplay C n p) := by + intro a b hab + simp only [leafDisplay_mixed] at hab + exact (branchEquiv C n).injective (mixedDisplay_injective n _ p hab) + +noncomputable def mixedBalance {ι : Type u} (n : ℕ) (D : Fin n → ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (p : ι → ℤ) : ℝ := + ∑ a : ∀ s, Fin (D s+1), f (mixedDisplay n D p a) + +theorem allBalance_mixed {ι : Type u} (C n : ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (p : ι → ℤ) : + allBalance C n f p = mixedBalance n (fun _ => C) f p := by + rw [allBalance_sum_leaf] + simp only [leafDisplay_mixed,mixedBalance] + exact Equiv.sum_comp (branchEquiv C n) (fun a => f (mixedDisplay n (fun _ => C) p a)) + + + +theorem mixedDisplay_succ {ι : Type u} (n : ℕ) (D : Fin (n+1) → ℕ) + (p : ι → ℤ) (a : ∀ s, Fin (D s+1)) : + mixedDisplay (n+1) D p a = mixedDisplay n (fun s => D s.succ) + (pairAssembly p (a 0:ℕ) ((D 0:ℤ)-(a 0:ℕ))) (fun s => a s.succ) := by + funext i + obtain ⟨q,rfl⟩ := (pairCoordsEquiv (ι ⊕ Bool) n).symm.surjective i + rcases q with (i | b) | ⟨s,b⟩ <;> + simp only [mixedDisplay, Function.comp_apply, pairCoordsEquiv, Equiv.trans_apply, + Equiv.apply_symm_apply, joinPairHead, Equiv.coe_fn_mk, balanceProfile, pairAssembly, + Sum.elim_inl, Sum.elim_inr] + +theorem mixedBalance_succ {ι : Type u} (n : ℕ) (D : Fin (n+1) → ℕ) + (f : (PairCoords ι (n+1) → ℤ) → ℝ) (p : ι → ℤ) : + mixedBalance (n+1) D f p = ∑ j : Fin (D 0+1), + mixedBalance n (fun s => D s.succ) f (pairAssembly p (j:ℕ) ((D 0:ℤ)-(j:ℕ))) := by + unfold mixedBalance + rw [← Equiv.sum_comp (piHeadEquiv (fun s => Fin (D s+1))).symm] + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl; intro j hj + apply Finset.sum_congr rfl; intro a ha + congr 1 + rw [mixedDisplay_succ] + rfl + +noncomputable def surplusCaps (C n : ℕ) (t : Fin n) (s : Fin n) : ℕ := + if s=t then C+1 else C + + + +theorem allSurplus_sum_types {ι : Type u} (C n : ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (p : ι → ℤ) : + allSurplus C n f p = ∑ t : Fin n, mixedBalance n (surplusCaps C n t) f p := by + induction n generalizing ι with + | zero => simp [allSurplus] + | succ n ih => + rw [Fin.sum_univ_succ] + change balancedMarginal (allBalance C n f) (C+1) p + + balancedMarginal (allSurplus C n f) C p = _ + congr 1 + · rw [mixedBalance_succ] + simp only [surplusCaps,ite_eq_left,Fin.succ_ne_zero,ite_false] + unfold balancedMarginal + rw [← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl; intro j hj + exact allBalance_mixed C n f _ + · have hs (t : Fin n) : mixedBalance (n+1) (surplusCaps C (n+1) t.succ) f p = + ∑ j : Fin (C+1), mixedBalance n (surplusCaps C n t) f + (pairAssembly p (j:ℕ) ((C:ℤ)-(j:ℕ))) := by + have he : surplusCaps C (n+1) t.succ = Fin.cases C (surplusCaps C n t) := by + funext s + refine Fin.cases ?_ (fun v => ?_) s + · simp [surplusCaps,Ne.symm (Fin.succ_ne_zero t)] + · simp [surplusCaps] + rw [he,mixedBalance_succ] + rfl + simp_rw [hs] + rw [Finset.sum_comm] + unfold balancedMarginal + rw [← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl; intro j hj + exact ih f _ + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +noncomputable def splitSlots (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) : + SmallSlot U r c ≃ (Fin k ⊕ Fin (a+1)) := + ((smallIndex U r c).symm.trans (finCongr h)).trans finSumFinEquiv.symm + +noncomputable def prefixSlot (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (s : Fin k) := + (splitSlots U r c k a h).symm (.inl s) + +noncomputable def suffixSlot (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (s : Fin (a+1)) := + (splitSlots U r c k a h).symm (.inr s) + +@[simp] theorem contextCoordinates_prefix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (s : Fin k) (b : Bool) : + contextCoordinates U r c k a h (prefixSlot U r c k a h s,b) = .inl (s,b) := by + change ((Equiv.sumCongr (Equiv.refl _) (smallCoords a).symm) + ((Equiv.sumProdDistrib (Fin k) (Fin (a+1)) Bool) + (splitSlots U r c k a h ((splitSlots U r c k a h).symm (.inl s)),b))) = _ + rw [Equiv.apply_symm_apply]; rfl + +@[simp] theorem contextCoordinates_suffix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (s : Fin (a+1)) (b : Bool) : + contextCoordinates U r c k a h (suffixSlot U r c k a h s,b) = + .inr ((smallCoords a).symm (s,b)) := by + change ((Equiv.sumCongr (Equiv.refl _) (smallCoords a).symm) + ((Equiv.sumProdDistrib (Fin k) (Fin (a+1)) Bool) + (splitSlots U r c k a h ((splitSlots U r c k a h).symm (.inr s)),b))) = _ + rw [Equiv.apply_symm_apply]; rfl + +theorem prefix_before_suffix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (s : Fin k) (t : Fin (a+1)) : + Before (prefixSlot U r c k a h s).val (suffixSlot U r c k a h t).val := by + apply (smallIndex_lt U r c _ _).2 + change ((finCongr h).symm (finSumFinEquiv (.inl s))) < + ((finCongr h).symm (finSumFinEquiv (.inr t))) + change s.val < k+t.val + omega + +theorem suffix_before (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (s t : Fin (a+1)) (hst : s exact Or.inl ⟨s,rfl⟩ + | inr s => exact Or.inr ⟨s,rfl⟩ + +noncomputable def contextState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) : State m n := + coordinatesState U r c (Sum.elim (balanceProfile (fun _ => U) σ) p ∘ contextCoordinates U r c k a h) + +@[simp] theorem contextState_prefix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (s : Fin k) : + (contextState U r c k a h σ p).x (prefixSlot U r c k a h s).val = (σ s:ℕ) ∧ + (contextState U r c k a h σ p).q (prefixSlot U r c k a h s).val = (σ s:ℕ) := by + simp [contextState,balanceProfile] + +@[simp] theorem contextState_suffix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (s : Fin (a+1)) : + (contextState U r c k a h σ p).x (suffixSlot U r c k a h s).val = p ((smallCoords a).symm (s,true)) ∧ + (contextState U r c k a h σ p).q (suffixSlot U r c k a h s).val = U-p ((smallCoords a).symm (s,false)) := by + simp [contextState] + +theorem contextState_supported (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (w : Cell m n) (hw : IsLarge U r c w) : + (contextState U r c k a h σ p).x w=0 ∧ (contextState U r c k a h σ p).q w=0 := + coordinatesState_supported U r c _ w hw + +theorem contextState_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) : + Function.Injective (contextState U r c k a h σ) := by + intro p q hpq + have he := congrArg (stateCoordinates U r c) hpq + dsimp [contextState] at he + simp only [stateCoordinates_coordinatesState] at he + funext i + have hh := congrFun he ((contextCoordinates U r c k a h).symm (.inr i)) + simpa using hh + +theorem contextKernel_weight (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) : + contextKernel 0 U L C r c k a h σ p = (weight U L r c (contextState U r c k a h σ p):ℝ) := by + classical + let X := contextState U r c k a h σ p + by_cases hx : Feasible U r c X + · rw [weight,ite_eq_left hx] + have he := smallKernel_zero_count U L C r c hrc X hx hC + simpa only [X,contextState,stateCoordinates_coordinatesState,contextKernel] using he + · rw [weight,ite_eq_right hx,Nat.cast_zero] + exact smallKernel_zero_infeasible U L C r c _ hx + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +@[ext] theorem State.ext {X Y : State m n} (hx : X.x=Y.x) (hq : X.q=Y.q) : X=Y := by + cases X; cases Y; simp_all + +variable (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (k a : ℕ) + (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + +@[simp] theorem suffixSlot_val_inj (s t : Fin (a+1)) : + (suffixSlot U r c k a h s).val=(suffixSlot U r c k a h t).val ↔ s=t := by + constructor + · intro he + have he' := Subtype.ext he + exact Sum.inr.inj ((splitSlots U r c k a h).symm.injective he') + · rintro rfl; rfl + +@[simp] theorem prefix_suffix_ne (s : Fin k) (t : Fin (a+1)) : + (prefixSlot U r c k a h s).val ≠ (suffixSlot U r c k a h t).val := by + intro he + have he' := Subtype.ext he + have hh := (splitSlots U r c k a h).symm.injective he' + cases hh + +@[simp] theorem mixedDisplay_current (D : Fin a → ℕ) (p : Bool → ℤ) + (α : ∀ s, Fin (D s+1)) (b : Bool) : + mixedDisplay a D p α ((smallCoords a).symm (0,b)) = p b := by + exact mixedDisplay_base a D p α b + +@[simp] theorem mixedDisplay_ordinary (D : Fin a → ℕ) (p : Bool → ℤ) + (α : ∀ s, Fin (D s+1)) (s : Fin a) (b : Bool) : + mixedDisplay a D p α ((smallCoords a).symm (s.succ,b)) = + if b then ((α s:ℕ):ℤ) else (D s:ℤ)-(α s:ℕ) := by + exact mixedDisplay_slot a D p α s b + + + +def defectProfile (j : ℕ) : Bool → ℤ := fun b => if b then (j:ℤ) else (U:ℤ)-j-1 + +@[simp] theorem adjacent_removePair (j : ℕ) : + removePair (adjacentDisplay U j) true false = defectProfile U j := by + funext b; cases b <;> simp [removePair,adjacentDisplay,defectProfile] + +noncomputable def defectState (j : ℕ) (t : Fin a) (α : ∀ v, Fin (surplusCaps U a t v+1)) : State m n := + contextState U r c k a h σ (mixedDisplay a (surplusCaps U a t) (defectProfile U j) α) + +@[simp] theorem defectState_current (j : ℕ) (t : Fin a) (α : ∀ v, Fin (surplusCaps U a t v+1)) : + (defectState U r c k a h σ j t α).x (suffixSlot U r c k a h 0).val = j ∧ + (defectState U r c k a h σ j t α).q (suffixSlot U r c k a h 0).val = (j:ℤ)+1 := by + have hh := contextState_suffix U r c k a h σ (mixedDisplay a (surplusCaps U a t) (defectProfile U j) α) 0 + refine ⟨hh.1.trans ?_,hh.2.trans ?_⟩ + · simp only [mixedDisplay_current,defectProfile,ite_true] + · simp only [mixedDisplay_current,defectProfile,Bool.false_eq_true,ite_false] + ring + +@[simp] theorem defectState_ordinary (j : ℕ) (t v : Fin a) (α : ∀ v, Fin (surplusCaps U a t v+1)) : + (defectState U r c k a h σ j t α).x (suffixSlot U r c k a h v.succ).val = (α v:ℕ) ∧ + (defectState U r c k a h σ j t α).q (suffixSlot U r c k a h v.succ).val = + (α v:ℕ)-(if v=t then (1:ℤ) else 0) := by + have hh := contextState_suffix U r c k a h σ (mixedDisplay a (surplusCaps U a t) (defectProfile U j) α) v.succ + simp only [mixedDisplay_ordinary,Bool.false_eq_true,ite_true,ite_false] at hh + refine ⟨hh.1,hh.2.trans ?_⟩ + unfold surplusCaps + split_ifs <;> push_cast <;> ring + +theorem defectState_defect (j : ℕ) (t : Fin a) (α : ∀ v, Fin (surplusCaps U a t v+1)) : + DefectAt U r c (suffixSlot U r c k a h 0).val (suffixSlot U r c k a h t.succ).val + (defectState U r c k a h σ j t α) := by + refine ⟨(suffixSlot U r c k a h 0).property,(suffixSlot U r c k a h t.succ).property,?_,?_⟩ + · rw [ne_eq,suffixSlot_val_inj] + exact Ne.symm (Fin.succ_ne_zero t) + · funext w + by_cases hw : IsSmall U r c w + · rcases slot_cases U r c k a h ⟨w,hw⟩ with ⟨v,hv⟩ | ⟨v,hv⟩ + · have he : w=(prefixSlot U r c k a h v).val := congrArg Subtype.val hv + subst w + have hp := contextState_prefix U r c k a h σ + (mixedDisplay a (surplusCaps U a t) (defectProfile U j) α) v + dsimp [defectState] at * + rw [hp.1,hp.2] + simp [unit] + · have he : w=(suffixSlot U r c k a h v).val := congrArg Subtype.val hv + subst w + refine Fin.cases ?_ (fun v => ?_) v + · rw [(defectState_current U r c k a h σ j t α).1, + (defectState_current U r c k a h σ j t α).2] + simp [unit,Ne.symm (Fin.succ_ne_zero t)] + · rw [(defectState_ordinary U r c k a h σ j t v α).1, + (defectState_ordinary U r c k a h σ j t v α).2] + simp [unit] + · have hl : IsLarge U r c w := Classical.not_not.mp hw + have hh := contextState_supported U r c k a h σ + (mixedDisplay a (surplusCaps U a t) (defectProfile U j) α) w hl + have hs : w ≠ (suffixSlot U r c k a h 0).val := by + rintro rfl; exact (suffixSlot U r c k a h 0).property hl + have ht : w ≠ (suffixSlot U r c k a h t.succ).val := by + rintro rfl; exact (suffixSlot U r c k a h t.succ).property hl + change _ = _-unit _ _+unit _ _ + simp only [defectState] at * + rw [hh.1,hh.2]; simp [unit,hs,ht] + +noncomputable def stateSuffix (X : State m n) (hf : Feasible U r c X) : Fin a → Fin (U+1) := + fun v => ⟨(X.x (suffixSlot U r c k a h v.succ).val).toNat,by + have hh := hf.1 (suffixSlot U r c k a h v.succ).val; omega⟩ + + + +theorem contextState_reconstruct (X : State m n) (hf : Feasible U r c X) + (htr : Transversal X) (hp : ∀ v, X.x (prefixSlot U r c k a h v).val=(σ v:ℕ)) + (j : ℕ) (hj : X.x (suffixSlot U r c k a h 0).val=(j:ℤ)) : + contextState U r c k a h σ (mixedDisplay a (fun _ => U) (childProfile U j) + (stateSuffix U r c k a h X hf)) = X := by + apply State.ext + · funext w + by_cases hw : IsSmall U r c w + · rcases slot_cases U r c k a h ⟨w,hw⟩ with ⟨v,hv⟩ | ⟨v,hv⟩ + · have he : w=(prefixSlot U r c k a h v).val := congrArg Subtype.val hv + subst w + rw [(contextState_prefix U r c k a h σ _ v).1,hp] + · have he : w=(suffixSlot U r c k a h v).val := congrArg Subtype.val hv + subst w + rw [(contextState_suffix U r c k a h σ _ v).1] + refine Fin.cases ?_ (fun t => ?_) v + · simpa [childProfile] using hj.symm + · simp only [mixedDisplay_ordinary,ite_true,stateSuffix] + exact Int.toNat_of_nonneg (hf.1 _).1 + · exact (contextState_supported U r c k a h σ _ w (Classical.not_not.mp hw)).1.trans + ((hf.2.1 w (Classical.not_not.mp hw)).1.symm) + · funext w + by_cases hw : IsSmall U r c w + · rcases slot_cases U r c k a h ⟨w,hw⟩ with ⟨v,hv⟩ | ⟨v,hv⟩ + · have he : w=(prefixSlot U r c k a h v).val := congrArg Subtype.val hv + subst w + rw [(contextState_prefix U r c k a h σ _ v).2,htr,hp] + · have he : w=(suffixSlot U r c k a h v).val := congrArg Subtype.val hv + subst w + rw [(contextState_suffix U r c k a h σ _ v).2,htr] + refine Fin.cases ?_ (fun t => ?_) v + · simp [childProfile,hj] + · simp only [mixedDisplay_ordinary,Bool.false_eq_true,ite_false,stateSuffix] + rw [Int.toNat_of_nonneg (hf.1 _).1]; ring + · exact (contextState_supported U r c k a h σ _ w (Classical.not_not.mp hw)).2.trans + ((hf.2.1 w (Classical.not_not.mp hw)).2.symm) + +end Contingency.PaddedGraph + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/ConcreteKernel.lean b/lean/OAI/Probability/Contingency/ConcreteKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..2172a0dafe23e17d3c3980394af3325126cd2ba1 --- /dev/null +++ b/lean/OAI/Probability/Contingency/ConcreteKernel.lean @@ -0,0 +1,575 @@ +import Mathlib +import OAI.Probability.Contingency.Completions + +namespace OAI + +/-! Concrete Kernel. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators + +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +abbrev SmallSlot (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + {w : Cell m n // IsSmall U r c w} +abbrev LargeSlot (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + {w : Cell m n // IsLarge U r c w} +abbrev SmallCoord (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + SmallSlot U r c × Bool + +noncomputable def largeIndex (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + Fintype.equivFin (LargeSlot U r c) + + + +noncomputable def wholeCoordinates (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Coordinate m n ≃ (SmallCoord U r c ⊕ (Fin (Fintype.card (LargeSlot U r c)) × Bool)) where + toFun w := if h : IsSmall U r c w.2 then .inl (⟨w.2,h⟩,w.1) + else .inr (largeIndex U r c ⟨w.2,Classical.not_not.mp h⟩,w.1) + invFun w := match w with + | .inl (s,b) => (b,s.val) + | .inr (s,b) => (b,((largeIndex U r c).symm s).val) + left_inv w := by + rcases w with ⟨b,w⟩ + by_cases hw : IsSmall U r c w + · simp only [dite_eq_left hw] + · simp only [dite_eq_right hw,Equiv.symm_apply_apply] + right_inv w := by + rcases w with ⟨s,b⟩ | ⟨s,b⟩ + · dsimp; rw [dite_eq_left s.property] + · dsimp + rw [dite_eq_right (show ¬IsSmall U r c ((largeIndex U r c).symm s).val from + fun h => h ((largeIndex U r c).symm s).property)] + simp + +@[simp] theorem wholeCoordinates_small (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : SmallSlot U r c) (b : Bool) : + wholeCoordinates U r c (b,s.val) = Sum.inl (s,b) := by + simp only [wholeCoordinates,Equiv.coe_fn_mk,dite_eq_left s.property] + +@[simp] theorem wholeCoordinates_large (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s : LargeSlot U r c) (b : Bool) : + wholeCoordinates U r c (b,s.val) = Sum.inr (largeIndex U r c s,b) := by + simp only [wholeCoordinates,Equiv.coe_fn_mk,dite_eq_right (show ¬IsSmall U r c s.val from + fun h => h s.property)] + + theorem capacity_box (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + (fun w : Coordinate m n => capacity U C r c w.2) ∘ (wholeCoordinates U r c).symm = + balanceBox (fun _ : SmallCoord U r c => (U:ℤ)) (fun _ => C) := by + funext w + rcases w with ⟨s,b⟩ | ⟨s,b⟩ + · simp [wholeCoordinates,capacity,balanceBox,(show ¬IsLarge U r c s.val from s.property)] + · simp [wholeCoordinates,capacity,balanceBox,((largeIndex U r c).symm s).property] + + theorem capacity_total (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + (∑ w, capacity U C r c w) = + (Fintype.card (SmallSlot U r c):ℤ)*U+(Fintype.card (LargeSlot U r c):ℤ)*C := by + have h := Fintype.sum_subtype_add_sum_subtype (IsLarge U r c) (capacity U C r c) + have hl (w : LargeSlot U r c) : capacity U C r c w.val = (C:ℤ) := by + simp [capacity,w.property] + have hs (w : SmallSlot U r c) : capacity U C r c w.val = (U:ℤ) := by + simp [capacity,(show ¬IsLarge U r c w.val from w.property)] + change (∑ w : LargeSlot U r c, capacity U C r c w.val) + + (∑ w : SmallSlot U r c, capacity U C r c w.val) = _ at h + simp only [hl,hs,Finset.sum_const,Finset.card_univ, nsmul_eq_mul] at h + linarith + +noncomputable def smallKernel (η : ℝ) (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) : ℝ := + balancedSlots (fun q => softWeight η (fun i => r i) (paddedRow U L r c) + (fun j => c j) (paddedCol U L r c) (capacity U C r c) (smallSet U r c) + (q ∘ wholeCoordinates U r c)) (fun _ => C) p + + + +theorem smallKernel_signature (η : ℝ) (hη : 0 < η) (hη1 : η < 1) + (U L C : ℕ) (hC : 2 ≤ C) (r : Fin m → ℕ) (c : Fin n → ℕ) : + PositiveSlice (smallKernel η U L C r c) (fun _ => (U:ℤ)) + ((Fintype.card (SmallSlot U r c):ℤ)*U) ∧ + HasSignature (smallKernel η U L C r c) (fun _ => (U:ℤ)) + ((Fintype.card (SmallSlot U r c):ℤ)*U) := by + have hp := (softWeight_positive η hη (fun i => r i) (paddedRow U L r c) + (fun j => c j) (paddedCol U L r c) (capacity U C r c) (smallSet U r c)).reindex + (wholeCoordinates U r c) + have hs := (softWeight_signature η hη hη1 (fun i => r i) (paddedRow U L r c) + (fun j => c j) (paddedCol U L r c) (capacity U C r c) (smallSet U r c)).reindex + (wholeCoordinates U r c) + rw [capacity_box] at hp hs + have h := balancedSlots_closure _ _ _ (fun _ => C) (fun _ => hC) _ hp hs + rw [capacity_total] at h + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Fintype.card_fin,add_sub_cancel_right] at h + exact h + +noncomputable def stateCoordinates (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (w : SmallCoord U r c) : ℤ := + if w.2 then X.x w.1.val else (U:ℤ)-X.q w.1.val + +noncomputable def coordinatesState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) : State m n where + x w := if h : IsSmall U r c w then p (⟨w,h⟩,true) else 0 + q w := if h : IsSmall U r c w then (U:ℤ)-p (⟨w,h⟩,false) else 0 + +@[simp] theorem coordinatesState_x (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) (w : SmallSlot U r c) : + (coordinatesState U r c p).x w.val = p (w,true) := by simp [coordinatesState,w.property] +@[simp] theorem coordinatesState_q (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) (w : SmallSlot U r c) : + (coordinatesState U r c p).q w.val = (U:ℤ)-p (w,false) := by simp [coordinatesState,w.property] + +@[simp] theorem stateCoordinates_coordinatesState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) : + stateCoordinates U r c (coordinatesState U r c p) = p := by + funext ⟨w,b⟩ + cases b <;> simp [stateCoordinates] + +def largeChoicesEquiv (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + LargeChoices U C r c ≃ (LargeSlot U r c → Fin (C+1)) where + toFun A w := ⟨(A.val w.val).toNat,by have h := A.property w.val; omega⟩ + invFun a := ⟨(fun w => if h : IsLarge U r c w then (a ⟨w,h⟩:ℕ) else 0),by + intro w + dsimp + by_cases hw : IsLarge U r c w + · rw [dite_eq_left hw] + have h := (a ⟨w,hw⟩).isLt + exact ⟨by omega,by omega,fun hh => (hh hw).elim⟩ + · rw [dite_eq_right hw] + exact ⟨by omega,by omega,fun _ => rfl⟩⟩ + left_inv A := by + apply Subtype.ext + funext w + dsimp + by_cases hw : IsLarge U r c w + · rw [ite_eq_left hw,Int.toNat_of_nonneg (A.property w).1] + · rw [ite_eq_right hw,(A.property w).2.2 hw] + right_inv a := by + funext w + apply Fin.ext + simp only [dite_eq_left w.property,Int.toNat_natCast] + +noncomputable def largeProfileEquiv (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + LargeChoices U C r c ≃ (Fin (Fintype.card (LargeSlot U r c)) → Fin (C+1)) := + (largeChoicesEquiv U C r c).trans ((largeIndex U r c).arrowCongr (Equiv.refl _)) + + theorem balanced_fullCoordinates (U C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hX : ∀ w, IsLarge U r c w → X.x w=0 ∧ X.q w=0) + (A : LargeChoices U C r c) : + (Sum.elim (stateCoordinates U r c X) (balanceProfile (fun _ => C) (largeProfileEquiv U C r c A))) ∘ + wholeCoordinates U r c = fullCoordinates U C r c X A.val := by + funext ⟨b,w⟩ + by_cases hw : IsSmall U r c w + · have hA := (A.property w).2.2 hw + have he := wholeCoordinates_small U r c ⟨w,hw⟩ b + simp only [Function.comp_apply,he,Sum.elim_inl,stateCoordinates] + cases b <;> simp [fullCoordinates,capacity,(show ¬IsLarge U r c w from hw),hA] + · have hl := Classical.not_not.mp hw + have hx := hX w hl + have he := wholeCoordinates_large U r c ⟨w,hl⟩ b + simp only [Function.comp_apply,he,Sum.elim_inr,balanceProfile] + have ha : (largeProfileEquiv U C r c A (largeIndex U r c ⟨w,hl⟩):ℕ) = (A.val w).toNat := by + simp [largeProfileEquiv,largeChoicesEquiv] + rfl + rw [ha,Int.toNat_of_nonneg (A.property w).1] + cases b <;> simp [fullCoordinates,capacity,hl,hx] + + +theorem smallKernel_zero_count (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) (X : State m n) (hf : Feasible U r c X) + (hC : ∀ i, paddedRow U L r c i ≤ C) : + smallKernel 0 U L C r c (stateCoordinates U r c X) = + (Nat.card (Completion U L r c X):ℝ) := by + unfold smallKernel balancedSlots + rw [← Equiv.sum_comp (largeProfileEquiv U C r c)] + simp_rw [balanced_fullCoordinates U C r c X hf.2.1] + exact sum_choice_softWeight U L C r c hrc X hf hC + + theorem full_zero_feasible (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hX : ∀ w, IsLarge U r c w → X.x w=0 ∧ X.q w=0) + (A : LargeChoices U C r c) + (hb : InBox (fun w => capacity U C r c w.2) (fullCoordinates U C r c X A.val)) + (hp : softPenalty (fun i => r i) (paddedRow U L r c) + (fun j => c j) (paddedCol U L r c) (capacity U C r c) (smallSet U r c) + (fullCoordinates U C r c X A.val)=0) : Feasible U r c X := by + rw [softPenalty_zero_iff] at hp + have hsx (w : Cell m n) : + (if w ∈ smallSet U r c then fullCoordinates U C r c X A.val (true,w) else 0) = X.x w := by + by_cases hw : IsSmall U r c w + · simp [smallSet,hw,fullCoordinates,(A.property w).2.2 hw] + · simp [smallSet,hw,(hX w (Classical.not_not.mp hw)).1] + have hsq (w : Cell m n) : + (if w ∈ smallSet U r c then capacity U C r c w - + fullCoordinates U C r c X A.val (false,w) else 0) = X.q w := by + rw [fullCoordinates_q] + by_cases hw : IsSmall U r c w + · simp [smallSet,hw,(A.property w).2.2 hw] + · simp [smallSet,hw,(hX w (Classical.not_not.mp hw)).2] + refine ⟨?_,hX,?_,?_⟩ + · intro w + by_cases hw : IsLarge U r c w + · rw [(hX w hw).1,(hX w hw).2]; exact ⟨by omega,by omega,by omega,by omega⟩ + · have hx := hb (true,w) + have hq := hb (false,w) + simp only [fullCoordinates,capacity,ite_eq_right hw,(A.property w).2.2 hw, + Bool.false_eq_true,ite_false,ite_true,add_zero] at hx hq + omega + · intro i + have hi := hp.2.2.1 i + simp only [hsx] at hi + refine ⟨hi,?_⟩ + intro hno + have ha (j : Fin n) : A.val (i,j)=0 := (A.property (i,j)).2.2 (hno j) + have he := hp.1 i + simp only [fullCoordinates_x,ha,add_zero] at he + simpa [rowSum,paddedRow,rowPadding,hno] using he + · intro j + have hj := hp.2.2.2 j + simp only [hsq] at hj + refine ⟨hj,?_⟩ + intro hno + have ha (i : Fin m) : A.val (i,j)=0 := (A.property (i,j)).2.2 (hno i) + have he := hp.2.1 j + simp only [fullCoordinates_q,ha,add_zero] at he + simpa [colSum,paddedCol,colPadding,hno] using he + + theorem coordinatesState_supported (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) : + ∀ w, IsLarge U r c w → (coordinatesState U r c p).x w=0 ∧ + (coordinatesState U r c p).q w=0 := by + intro w hw + have hs : ¬IsSmall U r c w := fun h => h hw + simp [coordinatesState,hs] + + theorem smallKernel_zero_infeasible (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) (hf : ¬Feasible U r c (coordinatesState U r c p)) : + smallKernel 0 U L C r c p = 0 := by + let X := coordinatesState U r c p + have hX := coordinatesState_supported U r c p + have he : p = stateCoordinates U r c X := (stateCoordinates_coordinatesState U r c p).symm + rw [he] + unfold smallKernel balancedSlots + rw [← Equiv.sum_comp (largeProfileEquiv U C r c)] + simp_rw [balanced_fullCoordinates U C r c X hX] + apply Finset.sum_eq_zero + intro A hA + rw [softWeight_zero,ite_eq_right] + rintro ⟨hb,ht,hp⟩ + exact hf (full_zero_feasible U L C r c X hX A hb hp) + + theorem smallKernel_continuous (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) : Continuous (fun η : ℝ => smallKernel η U L C r c p) := by + unfold smallKernel balancedSlots + apply continuous_finsetSum + intro a _ + exact softWeight_continuous _ _ _ _ _ _ _ + + theorem smallKernel_nonneg (η : ℝ) (hη : 0 ≤ η) (U L C : ℕ) + (r : Fin m → ℕ) (c : Fin n → ℕ) (p : SmallCoord U r c → ℤ) : + 0 ≤ smallKernel η U L C r c p := by + unfold smallKernel balancedSlots + apply Finset.sum_nonneg + intro a _ + unfold softWeight + dsimp only + split_ifs + · exact pow_nonneg hη _ + · rfl + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators + +namespace Contingency +section Nonnegative +variable {α : Type*} [Fintype α] + +theorem weight_zero_of_total_zero (w : α → ℝ) (hw : ∀ x, 0 ≤ w x) + (hz : totalWeight w = 0) : ∀ x, w x=0 := by + have h := (Finset.sum_eq_zero_iff_of_nonneg fun x _ => hw x).mp hz + exact fun x => h x (Finset.mem_univ x) + +theorem mass_mul_mean (w H : α → ℝ) (hw : ∀ x, 0 ≤ w x) : + totalWeight w*weightedMean w H = ∑ x, w x*H x := by + by_cases hz : totalWeight w = 0 + · have h := weight_zero_of_total_zero w hw hz + simp [hz,h] + · unfold weightedMean + exact mul_div_cancel₀ _ hz + +theorem centered_sum_nonneg (w H : α → ℝ) (hw : ∀ x, 0 ≤ w x) : + (∑ x, w x*(H x-weightedMean w H))=0 := by + simp only [mul_sub,Finset.sum_sub_distrib,← Finset.sum_mul] + change (∑ x, w x*H x)-totalWeight w*weightedMean w H = 0 + rw [mass_mul_mean w H hw,sub_self] + +theorem variance_translate_nonneg (w H : α → ℝ) (hw : ∀ x, 0 ≤ w x) (a : ℝ) : + (∑ x, w x*(H x-a)^2) = + weightedVariance w H + totalWeight w*(weightedMean w H-a)^2 := by + have h (x : α) : w x*(H x-a)^2 = + w x*(H x-weightedMean w H)^2 + + 2*(weightedMean w H-a)*(w x*(H x-weightedMean w H)) + + w x*(weightedMean w H-a)^2 := by ring + simp only [h,Finset.sum_add_distrib,← Finset.mul_sum,← Finset.sum_mul] + rw [centered_sum_nonneg w H hw] + simp [weightedVariance,totalWeight] + +theorem variance_le_deviation (w H : α → ℝ) (hw : ∀ x, 0 ≤ w x) (a : ℝ) : + weightedVariance w H ≤ ∑ x, w x*(H x-a)^2 := by + rw [variance_translate_nonneg w H hw a] + have hZ : 0 ≤ totalWeight w := Finset.sum_nonneg fun x _ => hw x + exact le_add_of_nonneg_right (mul_nonneg hZ (sq_nonneg _)) + +end Nonnegative + +section Decomposition +variable {α β : Type*} [Fintype α] [Fintype β] + + + +theorem variance_decompose (w H : α × β → ℝ) (hw : ∀ x, 0 ≤ w x) : + weightedVariance w H = + (∑ a, weightedVariance (fun b => w (a,b)) (fun b => H (a,b))) + + weightedVariance (fun a => totalWeight (fun b => w (a,b))) + (fun a => weightedMean (fun b => w (a,b)) (fun b => H (a,b))) := by + have hmean : weightedMean w H = + weightedMean (fun a => totalWeight (fun b => w (a,b))) + (fun a => weightedMean (fun b => w (a,b)) (fun b => H (a,b))) := by + unfold weightedMean + congr 1 + · simp_rw [show ∀ a, totalWeight (fun b => w (a,b)) * + ((∑ b, w (a,b)*H (a,b))/totalWeight (fun b => w (a,b))) = + ∑ b, w (a,b)*H (a,b) from fun a => mass_mul_mean _ _ (fun b => hw (a,b))] + exact Fintype.sum_prod_type _ + · simp [totalWeight,Fintype.sum_prod_type] + unfold weightedVariance + rw [Fintype.sum_prod_type] + simp_rw [variance_translate_nonneg _ _ (fun b => hw (_,b)) (weightedMean w H)] + rw [Finset.sum_add_distrib] + rw [hmean] + rfl + +end Decomposition + + + +def Profiles (C : ℕ) : ℕ → Type + | 0 => PUnit + | n+1 => Fin (C+1) × Profiles C n + +instance profilesFintype (C : ℕ) : (n : ℕ) → Fintype (Profiles C n) + | 0 => inferInstanceAs (Fintype PUnit) + | n+1 => letI := profilesFintype C n + inferInstanceAs (Fintype (Fin (C+1) × Profiles C n)) + + + +def ExposureEnergies (C : ℕ) : ℕ → Type + | 0 => PUnit + | n+1 => ℝ × (Fin (C+1) → ExposureEnergies C n) + +noncomputable def exposureEnergy (C : ℕ) : (n : ℕ) → ExposureEnergies C n → ℝ + | 0, _ => 0 + | n+1, E => E.1 + ∑ j, exposureEnergy C n (E.2 j) + + + +def ChildVarianceBounds (C : ℕ) (A : ℝ) : (n : ℕ) → + (Profiles C n → ℝ) → (Profiles C n → ℝ) → ExposureEnergies C n → Prop + | 0, _, _, _ => True + | n+1, w, H, E => + weightedVariance (fun j => totalWeight (fun b => w (j,b))) + (fun j => weightedMean (fun b => w (j,b)) (fun b => H (j,b))) ≤ A*E.1 ∧ + ∀ j, ChildVarianceBounds C A n (fun b => w (j,b)) (fun b => H (j,b)) (E.2 j) + + + +theorem exposure_variance_bound (C : ℕ) (A : ℝ) (n : ℕ) + (w H : Profiles C n → ℝ) (hw : ∀ x, 0 ≤ w x) (E : ExposureEnergies C n) + (h : ChildVarianceBounds C A n w H E) : + weightedVariance w H ≤ A*exposureEnergy C n E := by + induction n with + | zero => + simp only [exposureEnergy,mul_zero] + let : Unique (Profiles C 0) := inferInstanceAs (Unique PUnit) + by_cases hz : w (default : Profiles C 0)=0 + · simp [weightedVariance,hz] + · simp [weightedVariance,weightedMean,totalWeight, + mul_div_cancel_left₀ _ hz] + | succ n ih => + have hd := variance_decompose (α:=Fin (C+1)) (β:=Profiles C n) w H hw + change weightedVariance w H = _ at hd + rw [hd] + change _ ≤ A*(E.1 + ∑ j, exposureEnergy C n (E.2 j)) + have hb : (∑ j, weightedVariance (fun b => w (j,b)) (fun b => H (j,b))) ≤ + ∑ j, A*exposureEnergy C n (E.2 j) := by + apply Finset.sum_le_sum + intro j hj + exact ih _ _ (fun b => hw (j,b)) (E.2 j) (h.2 j) + rw [← Finset.mul_sum] at hb + dsimp only [ChildVarianceBounds] at h + nlinarith [h.1] + + + +noncomputable def exposureLevel (C : ℕ) : (n : ℕ) → ExposureEnergies C n → ℕ → ℝ + | 0, _, _ => 0 + | _+1, E, 0 => E.1 + | n+1, E, k+1 => ∑ j, exposureLevel C n (E.2 j) k + +theorem exposureEnergy_levels (C n : ℕ) (E : ExposureEnergies C n) : + exposureEnergy C n E = ∑ k ∈ Finset.range n, exposureLevel C n E k := by + induction n with + | zero => simp [exposureEnergy] + | succ n ih => + rw [Finset.sum_range_succ'] + simp only [exposureEnergy,exposureLevel] + simp_rw [ih] + rw [Finset.sum_comm] + ring + +theorem exposure_variance_level_bound (C : ℕ) (A : ℝ) (hA : 0 ≤ A) (n : ℕ) + (w H : Profiles C n → ℝ) (hw : ∀ x, 0 ≤ w x) (E : ExposureEnergies C n) + (h : ChildVarianceBounds C A n w H E) (G : ℝ) + (hlevel : ∀ k < n, exposureLevel C n E k ≤ G) : + weightedVariance w H ≤ (n:ℝ)*A*G := by + have he : exposureEnergy C n E ≤ (n:ℝ)*G := by + rw [exposureEnergy_levels] + calc + _ ≤ ∑ k ∈ Finset.range n, G := Finset.sum_le_sum fun k hk => hlevel k (Finset.mem_range.mp hk) + _ = _ := by simp + calc + _ ≤ A*exposureEnergy C n E := exposure_variance_bound C A n w H hw E h + _ ≤ A*((n:ℝ)*G) := mul_le_mul_of_nonneg_left he hA + _ = _ := by ring + +end Contingency + + + + + +open scoped BigOperators + +namespace Contingency + +noncomputable def nodeMass (C n : ℕ) (f : (PairCoords Bool n → ℤ) → ℝ) (j : ℕ) : ℝ := + allBalance C n f (childProfile C j) + +noncomputable def nodeMean (C n : ℕ) (f H : (PairCoords Bool n → ℤ) → ℝ) (j : ℕ) : ℝ := + nodeMass C n (fun x => f x*H x) j / nodeMass C n f j + +def adjacentDisplay (C j : ℕ) : Bool → ℤ := fun b => if b then (j:ℤ)+1 else (C:ℤ)-j + +@[simp] theorem adjacent_minus (C j : ℕ) : + removeOne (adjacentDisplay C j) true = childProfile C j := by + funext b; cases b <;> simp [removeOne,adjacentDisplay,childProfile] + +@[simp] theorem adjacent_plus (C j : ℕ) : + removeOne (adjacentDisplay C j) false = childProfile C (j+1:ℕ) := by + funext b; cases b <;> simp [removeOne,adjacentDisplay,childProfile] + ring + +theorem nodeMass_min (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : ℝ → (PairCoords Bool n → ℤ) → ℝ) + (hc : ∀ x, Continuous (fun η => f η x)) + (hf : ∀ η, 0 < η → η < 1 → PositiveSlice (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (hs : ∀ η, 0 < η → η < 1 → HasSignature (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (a b j : ℕ) (haj : a ≤ j) (hjb : j ≤ b) (hb : b ≤ C) : + min (nodeMass C n (f 0) a) (nodeMass C n (f 0) b) ≤ nodeMass C n (f 0) j := by + have hcl (η : ℝ) (hη : 0 < η) (hη' : η < 1) := + allBalance_closure C hC n (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C) + (by simpa only [pairBox_const] using hf η hη hη') + (by simpa only [pairBox_const] using hs η hη hη') + have ht : ((n+1:ℕ):ℤ)*C-(n:ℤ)*C = C := by push_cast; ring + simp only [ht] at hcl + exact zero_child_min C (fun η => allBalance C n (f η)) + (allBalance_continuous C n f hc) (fun η hη hη' => (hcl η hη hη').1) + (fun η hη hη' => (hcl η hη hη').2) a b j (by positivity) + (by exact_mod_cast haj) (by exact_mod_cast hjb) (by exact_mod_cast hb) + + + +theorem node_adjacent_bound (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : ℝ → (PairCoords Bool n → ℤ) → ℝ) + (hc : ∀ x, Continuous (fun η => f η x)) + (hf : ∀ η, 0 < η → η < 1 → PositiveSlice (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (hs : ∀ η, 0 < η → η < 1 → HasSignature (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (hz : ∀ x, 0 ≤ f 0 x) (H : (PairCoords Bool n → ℤ) → ℝ) + (d : ℝ) (hd : 0 ≤ d) (j : ℕ) (hj : j < C) + (ha : auxiliaryMass n C (f 0) (adjacentDisplay C j) ≤ + d*max (nodeMass C n (f 0) j) (nodeMass C n (f 0) (j+1))) : + min (nodeMass C n (f 0) j) (nodeMass C n (f 0) (j+1)) * + (nodeMean C n (f 0) H j-nodeMean C n (f 0) H (j+1))^2 ≤ + (2+2*d*((C:ℝ)+1)^2) * ∑ e ∈ smallUnitEdges C n, edgeEnergy (f 0) H e := by + have hzm (i : ℕ) : 0 ≤ nodeMass C n (f 0) i := allBalance_nonneg C n (f 0) hz _ + have hE : 0 ≤ ∑ e ∈ smallUnitEdges C n, edgeEnergy (f 0) H e := + Finset.sum_nonneg fun e _ => edgeEnergy_nonneg (f 0) H hz e + have hA : 0 ≤ 2+2*d*((C:ℝ)+1)^2 := by positivity + by_cases hm : nodeMass C n (f 0) j = 0 + · rw [hm,min_eq_left (hzm (j+1)),zero_mul] + exact mul_nonneg hA hE + by_cases hp : nodeMass C n (f 0) (j+1) = 0 + · rw [hp,min_eq_right (hzm j),zero_mul] + exact mul_nonneg hA hE + have hm' : 0 < nodeMass C n (f 0) j := lt_of_le_of_ne (hzm j) (Ne.symm hm) + have hp' : 0 < nodeMass C n (f 0) (j+1) := lt_of_le_of_ne (hzm (j+1)) (Ne.symm hp) + have hb : InBox (fun _ => (C:ℤ)) (adjacentDisplay C j) := by + intro b; cases b <;> dsimp [adjacentDisplay] <;> omega + have ht : adjacentDisplay C j true+adjacentDisplay C j false = (C:ℤ)+1 := by + simp [adjacentDisplay]; ring + have hv := zero_root_transport C hC n f hc hf hs H (adjacentDisplay C j) hb ht + (by simpa only [minusMass,adjacent_minus,nodeMass] using hm') + (by simpa only [plusMass,adjacent_plus,nodeMass] using hp') + simp only [minusMass,plusMass,adjacent_minus,adjacent_plus] at hv + exact transport_repair_arithmetic _ _ _ _ _ d C hm' hp' hE hd ha hv + + + +theorem node_variance_bound (C : ℕ) (z H : ℕ → ℝ) (A E : ℝ) + (hz : ∀ j ≤ C, 0 ≤ z j) (hA : 0 ≤ A) (hE : 0 ≤ E) + (hmin : ∀ a b j, a ≤ j → j ≤ b → b ≤ C → min (z a) (z b) ≤ z j) + (hadj : ∀ j < C, min (z j) (z (j+1))*(H j-H (j+1))^2 ≤ A*E) : + weightedVariance (fun j : Fin (C+1) => z j) (fun j => H j) ≤ + ((C:ℝ)+1)^4*A*E := by + let w : Fin (C+1) → ℝ := fun j => z j + have hw : ∀ j, 0 ≤ w j := fun j => hz j (by omega) + have hZ : 0 ≤ totalWeight w := Finset.sum_nonneg fun j _ => hw j + by_cases hZ0 : totalWeight w = 0 + · have hh := weight_zero_of_total_zero w hw hZ0 + have he : weightedVariance w (fun j => H j)=0 := by + unfold weightedVariance; simp only [hh,zero_mul,Finset.sum_const_zero] + change weightedVariance w _ ≤ _ + rw [he]; positivity + have hZ' : 0 < totalWeight w := lt_of_le_of_ne hZ (Ne.symm hZ0) + have hzZ (j : ℕ) (hj : j ≤ C) : z j ≤ totalWeight w := by + exact Finset.single_le_sum (fun i _ => hw i) (Finset.mem_univ (⟨j,by omega⟩ : Fin (C+1))) + have hp (a b : Fin (C+1)) : + w a*w b/totalWeight w*(H a-H b)^2 ≤ (C:ℝ)^2*A*E := by + rcases le_total a.val b.val with hab | hba + · exact child_pair_bound C z H (totalWeight w) A E hZ' hz hzZ hA hE hmin hadj a b hab (by omega) + · have hh := child_pair_bound C z H (totalWeight w) A E hZ' hz hzZ hA hE hmin hadj b a hba (by omega) + have he : w a*w b/totalWeight w*(H a-H b)^2 = + z b*z a/totalWeight w*(H b-H a)^2 := by dsimp [w]; ring + rw [he]; exact hh + have hv := variance_le_card_sq w (fun j => H j) hZ' ((C:ℝ)^2*A*E) (by positivity) hp + have hf : ((C:ℝ)+1)^2*(C:ℝ)^2 ≤ ((C:ℝ)+1)^4 := by + have hh : (C:ℝ)^2 ≤ ((C:ℝ)+1)^2 := by nlinarith [Nat.cast_nonneg (α:=ℝ) C] + calc + _ ≤ ((C:ℝ)+1)^2*((C:ℝ)+1)^2 := mul_le_mul_of_nonneg_left hh (sq_nonneg _) + _ = _ := by ring + calc + _ ≤ (Fintype.card (Fin (C+1)):ℝ)^2*((C:ℝ)^2*A*E) := hv + _ = (((C:ℝ)+1)^2*(C:ℝ)^2)*(A*E) := by simp; ring + _ ≤ ((C:ℝ)+1)^4*(A*E) := mul_le_mul_of_nonneg_right hf (mul_nonneg hA hE) + _ = _ := by ring + +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/ConditionalTransport.lean b/lean/OAI/Probability/Contingency/ConditionalTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..db78e512cfa40853e80740e1c795ef1486981399 --- /dev/null +++ b/lean/OAI/Probability/Contingency/ConditionalTransport.lean @@ -0,0 +1,679 @@ +import Mathlib +import OAI.Probability.Contingency.ConcreteContexts + +namespace OAI + +/-! Conditional Transport. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} +variable (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + +noncomputable def repairedChild (j : ℕ) (t : Fin a) : ℕ := + if (suffixSlot U r c k a h t.succ).val.1=(suffixSlot U r c k a h 0).val.1 then j+1 else j + +abbrev FeasibleBranches (j : ℕ) (t : Fin a) := + {α : ∀ v, Fin (surplusCaps U a t v+1) // Feasible U r c (defectState U r c k a h σ j t α)} + +noncomputable instance feasibleBranchesFintype (j : ℕ) (t : Fin a) : + Fintype (FeasibleBranches U r c k a h σ j t) := by + classical + unfold FeasibleBranches + infer_instance + +noncomputable def repairedBranch (j : ℕ) (t : Fin a) (α : FeasibleBranches U r c k a h σ j t) : + Fin a → Fin (U+1) := + stateSuffix U r c k a h + (repair U r c (suffixSlot U r c k a h 0).val (suffixSlot U r c k a h t.succ).val + (defectState U r c k a h σ j t α.val)) + (repair_feasible U r c _ _ _ α.property (defectState_defect U r c k a h σ j t α.val)) + +theorem repairedBranch_state (j : ℕ) (t : Fin a) (α : FeasibleBranches U r c k a h σ j t) : + contextState U r c k a h σ (mixedDisplay a (fun _ => U) + (childProfile U (repairedChild U r c k a h j t)) (repairedBranch U r c k a h σ j t α)) = + repair U r c (suffixSlot U r c k a h 0).val (suffixSlot U r c k a h t.succ).val + (defectState U r c k a h σ j t α.val) := by + apply contextState_reconstruct + · exact repair_transversal U r c _ _ _ + · intro v + have hp := repair_prefix U r c _ _ _ (defectState_defect U r c k a h σ j t α.val) + (suffix_before U r c k a h 0 t.succ (Fin.succ_pos t)) + (prefixSlot U r c k a h v).val (prefix_before_suffix U r c k a h v 0) + exact hp.1.trans (contextState_prefix U r c k a h σ _ v).1 + · have hs := repair_special U r c _ _ _ (defectState_defect U r c k a h σ j t α.val) + ((j:ℤ)+1) (by simp) + simpa only [repairedChild, Nat.cast_ite,Nat.cast_add,Nat.cast_one,add_sub_cancel_right] using hs + +theorem repairedBranch_injective (j : ℕ) (t : Fin a) : + Function.Injective (repairedBranch U r c k a h σ j t) := by + intro α β he + apply Subtype.ext + have hs := congrArg (fun v => contextState U r c k a h σ (mixedDisplay a (fun _ => U) + (childProfile U (repairedChild U r c k a h j t)) v)) he + rw [repairedBranch_state,repairedBranch_state] at hs + have hx := repair_injective U r c _ _ _ _ (defectState_defect U r c k a h σ j t α.val) + (defectState_defect U r c k a h σ j t β.val) hs + exact mixedDisplay_injective a _ _ (contextState_injective U r c k a h σ hx) + + + +theorem mixedBalance_repair (hrc : (∑ i, r i)=∑ j, c j) + (hC : ∀ i, paddedRow U L r c i ≤ C) (j : ℕ) (t : Fin a) : + mixedBalance a (surplusCaps U a t) (contextKernel 0 U L C r c k a h σ) (defectProfile U j) ≤ + nodeMass U a (contextKernel 0 U L C r c k a h σ) (repairedChild U r c k a h j t) := by + classical + let P : (∀ v, Fin (surplusCaps U a t v+1)) → Prop := + fun α => Feasible U r c (defectState U r c k a h σ j t α) + let F := fun α => contextKernel 0 U L C r c k a h σ + (mixedDisplay a (surplusCaps U a t) (defectProfile U j) α) + let G := fun β => contextKernel 0 U L C r c k a h σ + (mixedDisplay a (fun _ => U) (childProfile U (repairedChild U r c k a h j t)) β) + have h0 (α : ∀ v, Fin (surplusCaps U a t v+1)) (hα : ¬P α) : F α=0 := + smallKernel_zero_infeasible U L C r c _ hα + have hsum : (∑ α : FeasibleBranches U r c k a h σ j t, F α.val) = ∑ α, F α := by + have he := Fintype.sum_subtype_add_sum_subtype P F + have hz : (∑ α : {α // ¬P α}, F α.val)=0 := + Finset.sum_eq_zero fun α _ => h0 α.val α.property + rw [hz,add_zero] at he + exact he + have hle (α : FeasibleBranches U r c k a h σ j t) : + F α.val ≤ G (repairedBranch U r c k a h σ j t α) := by + dsimp [F,G] + rw [contextKernel_weight U L C r c hrc hC,contextKernel_weight U L C r c hrc hC, + repairedBranch_state] + exact_mod_cast weight_repair_le U L r c _ _ _ (defectState_defect U r c k a h σ j t α.val) + have hg (β : Fin a → Fin (U+1)) : 0 ≤ G β := contextKernel_nonneg U L C r c k a h σ _ + change (∑ α, F α) ≤ _ + rw [← hsum] + change _ ≤ allBalance U a (contextKernel 0 U L C r c k a h σ) + (childProfile U (repairedChild U r c k a h j t)) + rw [allBalance_mixed] + change _ ≤ ∑ β, G β + calc + _ ≤ ∑ α : FeasibleBranches U r c k a h σ j t, G (repairedBranch U r c k a h σ j t α) := + Finset.sum_le_sum fun α _ => hle α + _ = ∑ β ∈ Finset.univ.image (repairedBranch U r c k a h σ j t), G β := by + rw [Finset.sum_image (fun x _ y _ he => repairedBranch_injective U r c k a h σ j t he)] + _ ≤ ∑ β, G β := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun β _ _ => hg β) + +theorem mixedBalance_repair_max (hrc : (∑ i, r i)=∑ j, c j) + (hC : ∀ i, paddedRow U L r c i ≤ C) (j : ℕ) (t : Fin a) : + mixedBalance a (surplusCaps U a t) (contextKernel 0 U L C r c k a h σ) (defectProfile U j) ≤ + max (nodeMass U a (contextKernel 0 U L C r c k a h σ) j) + (nodeMass U a (contextKernel 0 U L C r c k a h σ) (j+1)) := by + have hh := mixedBalance_repair U L C r c k a h σ hrc hC j t + unfold repairedChild at hh + split_ifs at hh + · exact hh.trans (le_max_right _ _) + · exact hh.trans (le_max_left _ _) + +theorem context_auxiliary_bound (hrc : (∑ i, r i)=∑ j, c j) + (hC : ∀ i, paddedRow U L r c i ≤ C) (j : ℕ) : + auxiliaryMass a U (contextKernel 0 U L C r c k a h σ) (adjacentDisplay U j) ≤ + (a:ℝ)*max (nodeMass U a (contextKernel 0 U L C r c k a h σ) j) + (nodeMass U a (contextKernel 0 U L C r c k a h σ) (j+1)) := by + rw [auxiliaryMass,adjacent_removePair,allSurplus_sum_types] + calc + _ ≤ ∑ t : Fin a, max (nodeMass U a (contextKernel 0 U L C r c k a h σ) j) + (nodeMass U a (contextKernel 0 U L C r c k a h σ) (j+1)) := + Finset.sum_le_sum fun t _ => mixedBalance_repair_max U L C r c k a h σ hrc hC j t + _ = _ := by simp + +theorem concrete_conditional_transport (hU : 2 ≤ U) (hC2 : 2 ≤ C) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (H : (PairCoords Bool a → ℤ) → ℝ) (j : ℕ) (hj : j (contextKernel_signature η hη hη' U L C hC2 r c k a h σ).1) + (fun η hη hη' => (contextKernel_signature η hη hη' U L C hC2 r c k a h σ).2) + (contextKernel_nonneg U L C r c k a h σ) H a (by positivity) j hj + (context_auxiliary_bound U L C r c k a h σ hrc hC j) + + + +theorem concrete_node_variance (hU : 2 ≤ U) (hC2 : 2 ≤ C) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (H : (PairCoords Bool a → ℤ) → ℝ) : + weightedVariance (fun j : Fin (U+1) => nodeMass U a (contextKernel 0 U L C r c k a h σ) j) + (fun j => nodeMean U a (contextKernel 0 U L C r c k a h σ) H j) ≤ + ((U:ℝ)+1)^4*(2+2*(a:ℝ)*((U:ℝ)+1)^2) * ∑ e ∈ smallUnitEdges U a, + edgeEnergy (contextKernel 0 U L C r c k a h σ) H e := by + apply node_variance_bound + · intro j hj + exact allBalance_nonneg U a _ (contextKernel_nonneg U L C r c k a h σ) _ + · positivity + · exact Finset.sum_nonneg fun e _ => + edgeEnergy_nonneg _ H (contextKernel_nonneg U L C r c k a h σ) e + · exact context_child_no_holes U L C hU hC2 r c k a h σ + · exact concrete_conditional_transport U L C r c k a h σ hU hC2 hrc hC H + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency + +noncomputable def profileEquiv (C : ℕ) : (n : ℕ) → Profiles C n ≃ (Fin n → Fin (C+1)) + | 0 => { toFun := fun _ i => Fin.elim0 i + invFun := fun _ => PUnit.unit + left_inv := fun x => by cases x; rfl + right_inv := fun x => by funext i; exact Fin.elim0 i } + | n+1 => ((Equiv.refl (Fin (C+1))).prodCongr (profileEquiv C n)).trans + (piHeadEquiv (fun _ : Fin (n+1) => Fin (C+1))).symm + +@[simp] theorem profileEquiv_succ (C n : ℕ) (j : Fin (C+1)) (α : Profiles C n) : + profileEquiv C (n+1) (j,α) = Fin.cons j (profileEquiv C n α) := rfl + +namespace PaddedGraph +variable {m n : ℕ} + +noncomputable def tupleState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (α : SmallSlot U r c → Fin (U+1)) : State m n := + coordinatesState U r c (fun w => if w.2 then (α w.1:ℕ) else (U:ℤ)-(α w.1:ℕ)) + +@[simp] theorem tupleState_x (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (α : SmallSlot U r c → Fin (U+1)) (s : SmallSlot U r c) : + (tupleState U r c α).x s.val=(α s:ℕ) := by simp [tupleState] + +@[simp] theorem tupleState_q (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (α : SmallSlot U r c → Fin (U+1)) (s : SmallSlot U r c) : + (tupleState U r c α).q s.val=(α s:ℕ) := by simp [tupleState] + +noncomputable def appendAssignment (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+a) + (σ : Fin k → Fin (U+1)) (τ : Fin a → Fin (U+1)) : SmallSlot U r c → Fin (U+1) := + Fin.append σ τ ∘ finCongr h ∘ (smallIndex U r c).symm + +@[simp] theorem appendAssignment_prefix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (τ : Fin (a+1) → Fin (U+1)) (s : Fin k) : + appendAssignment U r c k (a+1) h σ τ (prefixSlot U r c k a h s)=σ s := by + simp only [appendAssignment,Function.comp_apply,prefixSlot,splitSlots,Equiv.symm_trans_apply, + Equiv.symm_symm,Equiv.symm_apply_apply,Equiv.apply_symm_apply] + exact Fin.append_left σ τ s + +@[simp] theorem appendAssignment_suffix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (τ : Fin (a+1) → Fin (U+1)) (s : Fin (a+1)) : + appendAssignment U r c k (a+1) h σ τ (suffixSlot U r c k a h s)=τ s := by + simp only [appendAssignment,Function.comp_apply,suffixSlot,splitSlots,Equiv.symm_trans_apply, + Equiv.symm_symm,Equiv.symm_apply_apply,Equiv.apply_symm_apply] + exact Fin.append_right σ τ s + +@[simp] theorem appendAssignment_cons (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (j : Fin (U+1)) (τ : Fin a → Fin (U+1)) : + appendAssignment U r c k (a+1) h σ (Fin.cons j τ) = + appendAssignment U r c (k+1) a (by omega) (Fin.snoc σ j) τ := by + funext s + simp only [appendAssignment,Function.comp_apply,Fin.append_right_cons] + rfl + + + +noncomputable def profileState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+a) (σ : Fin k → Fin (U+1)) + (τ : Profiles U a) : State m n := + tupleState U r c (appendAssignment U r c k a h σ (profileEquiv U a τ)) + +@[simp] theorem profileState_succ (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (j : Fin (U+1)) (τ : Profiles U a) : + profileState U r c k (a+1) h σ (j,τ) = + profileState U r c (k+1) a (by omega) (Fin.snoc σ j) τ := by + simp only [profileState,profileEquiv_succ,appendAssignment_cons] + + + +theorem contextState_profile (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (j : Fin (U+1)) (τ : Profiles U a) : + contextState U r c k a h σ + (mixedDisplay a (fun _ => U) (childProfile U j) (profileEquiv U a τ)) = + profileState U r c k (a+1) h σ (j,τ) := by + apply State.ext <;> funext w + all_goals + by_cases hw : IsSmall U r c w + · rcases slot_cases U r c k a h ⟨w,hw⟩ with ⟨s,hs⟩ | ⟨s,hs⟩ + · have he : w = _ := congrArg Subtype.val hs + subst w + simp only [profileState,profileEquiv_succ,tupleState_x,tupleState_q, + appendAssignment_prefix] + first | exact (contextState_prefix U r c k a h σ _ s).1 | + exact (contextState_prefix U r c k a h σ _ s).2 + · have he : w = _ := congrArg Subtype.val hs + subst w + simp only [profileState,profileEquiv_succ,tupleState_x,tupleState_q, + appendAssignment_suffix] + first + | rw [(contextState_suffix U r c k a h σ _ s).1] + | rw [(contextState_suffix U r c k a h σ _ s).2] + all_goals + refine Fin.cases ?_ (fun v => ?_) s + · simp [mixedDisplay_current,childProfile] + · simp [mixedDisplay_ordinary] + · have hl : IsLarge U r c w := Classical.not_not.mp hw + have h1 := contextState_supported U r c k a h σ + (mixedDisplay a (fun _ => U) (childProfile U j) (profileEquiv U a τ)) w hl + have h2 := coordinatesState_supported U r c + (fun w => if w.2 then + (appendAssignment U r c k (a+1) h σ (profileEquiv U (a+1) (j,τ)) w.1:ℕ) + else (U:ℤ)-(appendAssignment U r c k (a+1) h σ (profileEquiv U (a+1) (j,τ)) w.1:ℕ)) w hl + first | exact h1.1.trans h2.1.symm | exact h1.2.trans h2.2.symm + +theorem nodeMass_profile (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (j : Fin (U+1)) : + nodeMass U a (contextKernel 0 U L C r c k a h σ) j = + totalWeight (fun τ : Profiles U a => + (weight U L r c (profileState U r c k (a+1) h σ (j,τ)):ℝ)) := by + rw [nodeMass,allBalance_mixed] + unfold mixedBalance totalWeight + rw [← Equiv.sum_comp (profileEquiv U a)] + apply Finset.sum_congr rfl + intro τ hτ + rw [contextKernel_weight U L C r c hrc hC,contextState_profile] + +theorem nodeMean_profile (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (H : State m n → ℝ) (j : Fin (U+1)) : + nodeMean U a (contextKernel 0 U L C r c k a h σ) + (H ∘ contextState U r c k a h σ) j = + weightedMean (fun τ : Profiles U a => + (weight U L r c (profileState U r c k (a+1) h σ (j,τ)):ℝ)) + (fun τ => H (profileState U r c k (a+1) h σ (j,τ))) := by + rw [nodeMean,nodeMass_profile U L C r c hrc hC] + unfold weightedMean + congr 1 + rw [nodeMass,allBalance_mixed] + unfold mixedBalance + rw [← Equiv.sum_comp (profileEquiv U a)] + apply Finset.sum_congr rfl + intro τ hτ + simp only [Function.comp_apply,contextKernel_weight U L C r c hrc hC,contextState_profile] + +end PaddedGraph +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +noncomputable def contextEnergy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (H : State m n → ℝ) : ℝ := + ∑ e ∈ smallUnitEdges U a, edgeEnergy (contextKernel 0 U L C r c k a h σ) + (H ∘ contextState U r c k a h σ) e + +theorem contextEnergy_nonneg (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (H : State m n → ℝ) : 0 ≤ contextEnergy U L C r c k a h σ H := + Finset.sum_nonneg fun e _ => edgeEnergy_nonneg _ _ (contextKernel_nonneg U L C r c k a h σ) e + +noncomputable def contextTree (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : (a k : ℕ) → + (h : Fintype.card (SmallSlot U r c)=k+a) → (Fin k → Fin (U+1)) → ExposureEnergies U a + | 0, _, _, _ => PUnit.unit + | a+1, k, h, σ => (contextEnergy U L C r c k a h σ H, + fun j => contextTree U L C r c H a (k+1) (by omega) (Fin.snoc σ j)) + +theorem local_constant_le (U d a : ℕ) (_hd : 1 ≤ d) (ha : a (weight U L r c (profileState U r c k a h σ τ):ℝ)) + (fun τ => H (profileState U r c k a h σ τ)) + (contextTree U L C r c H a k h σ) := by + induction a generalizing k with + | zero => trivial + | succ a ih => + constructor + · change weightedVariance + (fun j => totalWeight (fun τ : Profiles U a => + (weight U L r c (profileState U r c k (a+1) h σ (j,τ)):ℝ))) + (fun j => weightedMean + (fun τ : Profiles U a => (weight U L r c (profileState U r c k (a+1) h σ (j,τ)):ℝ)) + (fun τ => H (profileState U r c k (a+1) h σ (j,τ)))) ≤ + (4*(d:ℝ)*((U:ℝ)+1)^6)*contextEnergy U L C r c k a h σ H + simp_rw [← nodeMass_profile U L C r c hrc hC, ← nodeMean_profile U L C r c hrc hC] + have hb := concrete_node_variance U L C r c k a h σ hU hC2 hrc hC + (H ∘ contextState U r c k a h σ) + exact hb.trans (mul_le_mul_of_nonneg_right (local_constant_le U d a hd (by omega)) + (contextEnergy_nonneg U L C r c k a h σ H)) + · intro j + simpa only [profileState_succ,contextTree] using ih (k+1) (by omega) (Fin.snoc σ j) + + + +theorem concrete_exposure_variance (U L C d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hU : 2 ≤ U) (hC2 : 2 ≤ C) (hd : 1 ≤ d) (hslots : Fintype.card (SmallSlot U r c) ≤ d) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (H : State m n → ℝ) (a k : ℕ) (h : Fintype.card (SmallSlot U r c)=k+a) + (σ : Fin k → Fin (U+1)) : + weightedVariance + (fun τ => (weight U L r c (profileState U r c k a h σ τ):ℝ)) + (fun τ => H (profileState U r c k a h σ τ)) ≤ + 4*(d:ℝ)*((U:ℝ)+1)^6 * exposureEnergy U a (contextTree U L C r c H a k h σ) := + exposure_variance_bound U _ a _ _ (fun τ => by positivity) _ + (contextTree_childBounds U L C d r c hU hC2 hd hslots hrc hC H a k h σ) + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +noncomputable def fullOccupancy (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) (s : SmallSlot U r c) : ℤ := p (s,true)+p (s,false) + +def fullPattern (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (p : SmallCoord U r c → ℤ) : Prop := + (∀ s, fullOccupancy U r c p s=U) ∨ + ∃ s t, s≠t ∧ fullOccupancy U r c p s=(U:ℤ)-1 ∧ fullOccupancy U r c p t=(U:ℤ)+1 ∧ + ∀ v, v≠s → v≠t → fullOccupancy U r c p v=U + +noncomputable def fullVertices (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finset (SmallCoord U r c → ℤ) := by + classical + exact (Fintype.piFinset (fun _ => Finset.Icc 0 (U:ℤ))).filter (fullPattern U r c) + +theorem mem_fullVertices (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (p : SmallCoord U r c → ℤ) : + p∈fullVertices U r c ↔ InBox (fun _ => (U:ℤ)) p ∧ fullPattern U r c p := by + classical + simp [fullVertices,Fintype.mem_piFinset,InBox] + + + +noncomputable def fullUnitEdges (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finset (Sym2 (SmallCoord U r c → ℤ)) := by + classical + exact (fullVertices U r c).sym2.filter (fun e => ∃ D i j, i≠j ∧ + e=s(removeOne D i,removeOne D j)) + +noncomputable def contextDisplay (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) : SmallCoord U r c → ℤ := + Sum.elim (balanceProfile (fun _ => U) σ) p ∘ contextCoordinates U r c k a h + +@[simp] theorem contextDisplay_prefix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (s : Fin k) (b : Bool) : + contextDisplay U r c k a h σ p (prefixSlot U r c k a h s,b) = + if b then ((σ s:ℕ):ℤ) else (U:ℤ)-(σ s:ℕ) := by simp [contextDisplay,balanceProfile] + +@[simp] theorem contextDisplay_suffix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (s : Fin (a+1)) (b : Bool) : + contextDisplay U r c k a h σ p (suffixSlot U r c k a h s,b) = + p ((smallCoords a).symm (s,b)) := by simp [contextDisplay] + +theorem contextDisplay_joint_inj (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) + (σ τ : Fin k → Fin (U+1)) (p q : PairCoords Bool a → ℤ) + (he : contextDisplay U r c k a h σ p=contextDisplay U r c k a h τ q) : σ=τ ∧ p=q := by + constructor + · funext s + have hh := congrFun he (prefixSlot U r c k a h s,true) + simp only [contextDisplay_prefix,ite_true] at hh + apply Fin.ext + exact_mod_cast hh + · funext i + have hh := congrFun he ((contextCoordinates U r c k a h).symm (.inr i)) + simpa [contextDisplay] using hh + +theorem contextDisplay_box (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (hp : InBox (fun _ => (U:ℤ)) p) : + InBox (fun _ => (U:ℤ)) (contextDisplay U r c k a h σ p) := by + intro w + obtain ⟨z,rfl⟩ := (contextCoordinates U r c k a h).symm.surjective w + cases z with + | inl z => simpa [contextDisplay] using balanceProfile_box U k σ z + | inr z => simpa [contextDisplay] using hp z + +theorem contextDisplay_pattern (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (hp : smallPattern U a p) : + fullPattern U r c (contextDisplay U r c k a h σ p) := by + have hpre (s : Fin k) : fullOccupancy U r c (contextDisplay U r c k a h σ p) + (prefixSlot U r c k a h s)=U := by simp [fullOccupancy] + have hsuf (s : Fin (a+1)) : fullOccupancy U r c (contextDisplay U r c k a h σ p) + (suffixSlot U r c k a h s)=smallOccupancy a p s := by simp [fullOccupancy,smallOccupancy] + rcases hp with ht | ⟨s,t,hst,hs,ht,hrest⟩ + · left + intro w + rcases slot_cases U r c k a h w with ⟨s,rfl⟩ | ⟨s,rfl⟩ + · exact hpre s + · rw [hsuf,ht] + · right + refine ⟨suffixSlot U r c k a h s,suffixSlot U r c k a h t,?_,?_,?_,?_⟩ + · intro he + have hh := congrArg Subtype.val he + exact hst ((suffixSlot_val_inj U r c k a h s t).mp hh) + · rw [hsuf,hs] + · rw [hsuf,ht] + · intro w hws hwt + rcases slot_cases U r c k a h w with ⟨v,rfl⟩ | ⟨v,rfl⟩ + · exact hpre v + · rw [hsuf] + exact hrest v (fun he => hws (congrArg _ he)) (fun he => hwt (congrArg _ he)) + +theorem contextDisplay_vertex (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (hp : p∈smallVertexSet U a) : + contextDisplay U r c k a h σ p∈fullVertices U r c := by + rw [mem_smallVertexSet] at hp + exact (mem_fullVertices U r c _).mpr ⟨contextDisplay_box U r c k a h σ p hp.1, + contextDisplay_pattern U r c k a h σ p hp.2⟩ + +theorem contextDisplay_removeOne (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (p : PairCoords Bool a → ℤ) (i : PairCoords Bool a) : + contextDisplay U r c k a h σ (removeOne p i) = + removeOne (contextDisplay U r c k a h σ p) ((contextCoordinates U r c k a h).symm (.inr i)) := by + funext w + obtain ⟨z,rfl⟩ := (contextCoordinates U r c k a h).symm.surjective w + cases z with + | inl z => simp [contextDisplay,removeOne] + | inr z => simp [contextDisplay,removeOne] + +noncomputable def contextEdge (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) + (e : (Fin k → Fin (U+1)) × Sym2 (PairCoords Bool a → ℤ)) : Sym2 (SmallCoord U r c → ℤ) := + Sym2.map (contextDisplay U r c k a h e.1) e.2 + +theorem contextEdge_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) : + Function.Injective (contextEdge U r c k a h) := by + rintro ⟨σ,e⟩ ⟨τ,f⟩ he + refine Sym2.inductionOn₂ e f (fun x y z w => ?_) he + intro he + change s(contextDisplay U r c k a h σ x,contextDisplay U r c k a h σ y)= + s(contextDisplay U r c k a h τ z,contextDisplay U r c k a h τ w) at he + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · obtain ⟨rfl,rfl⟩ := contextDisplay_joint_inj U r c k a h σ τ x z hx + obtain ⟨_,rfl⟩ := contextDisplay_joint_inj U r c k a h σ σ y w hy + rfl + · obtain ⟨rfl,rfl⟩ := contextDisplay_joint_inj U r c k a h σ τ x w hx + obtain ⟨_,rfl⟩ := contextDisplay_joint_inj U r c k a h σ σ y z hy + exact Prod.ext rfl Sym2.eq_swap + +theorem contextEdge_mem (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (e : Sym2 (PairCoords Bool a → ℤ)) (he : e∈smallUnitEdges U a) : + contextEdge U r c k a h (σ,e)∈fullUnitEdges U r c := by + classical + obtain ⟨hv,D,i,j,hij,rfl⟩ := Finset.mem_filter.mp he + rw [Finset.mk_mem_sym2_iff] at hv + apply Finset.mem_filter.mpr + constructor + · change s(contextDisplay U r c k a h σ (removeOne D i), + contextDisplay U r c k a h σ (removeOne D j)) ∈ (fullVertices U r c).sym2 + exact Finset.mk_mem_sym2_iff.mpr ⟨contextDisplay_vertex U r c k a h σ _ hv.1, + contextDisplay_vertex U r c k a h σ _ hv.2⟩ + · refine ⟨contextDisplay U r c k a h σ D, + (contextCoordinates U r c k a h).symm (.inr i), + (contextCoordinates U r c k a h).symm (.inr j),?_,?_⟩ + · intro he + exact hij (Sum.inr.inj ((contextCoordinates U r c k a h).symm.injective he)) + · change s(contextDisplay U r c k a h σ (removeOne D i), + contextDisplay U r c k a h σ (removeOne D j)) = _ + rw [contextDisplay_removeOne,contextDisplay_removeOne] + +@[simp] theorem contextEdge_energy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (σ : Fin k → Fin (U+1)) + (H : State m n → ℝ) (e : Sym2 (PairCoords Bool a → ℤ)) : + edgeEnergy (smallKernel 0 U L C r c) (H ∘ coordinatesState U r c) + (contextEdge U r c k a h (σ,e)) = + edgeEnergy (contextKernel 0 U L C r c k a h σ) + (H ∘ contextState U r c k a h σ) e := by + induction e using Sym2.ind with + | _ x y => rfl + +noncomputable def fullUnitEnergy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : ℝ := + ∑ e ∈ fullUnitEdges U r c, edgeEnergy (smallKernel 0 U L C r c) (H ∘ coordinatesState U r c) e + +theorem fullUnitEnergy_nonneg (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : 0 ≤ fullUnitEnergy U L C r c H := + Finset.sum_nonneg fun e _ => edgeEnergy_nonneg _ _ (smallKernel_nonneg 0 (by positivity) U L C r c) e + + + +theorem contextEnergy_sum_le (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (k a : ℕ) (h : Fintype.card (SmallSlot U r c)=k+(a+1)) (H : State m n → ℝ) : + (∑ σ : Fin k → Fin (U+1), contextEnergy U L C r c k a h σ H) ≤ fullUnitEnergy U L C r c H := by + classical + let E := edgeEnergy (smallKernel 0 U L C r c) (H ∘ coordinatesState U r c) + have hh : (∑ σ : Fin k → Fin (U+1), contextEnergy U L C r c k a h σ H) = + ∑ q ∈ Finset.univ ×ˢ smallUnitEdges U a, E (contextEdge U r c k a h q) := by + rw [Finset.sum_product] + simp only [E,contextEdge_energy,contextEnergy] + rw [hh] + rw [← Finset.sum_image (fun x _ y _ he => contextEdge_injective U r c k a h he)] + apply Finset.sum_le_sum_of_subset_of_nonneg + · intro e he + obtain ⟨⟨σ,e⟩,hq,rfl⟩ := Finset.mem_image.mp he + exact contextEdge_mem U r c k a h σ e (Finset.mem_product.mp hq).2 + · intro e he hne + exact edgeEnergy_nonneg _ _ (smallKernel_nonneg 0 (by positivity) U L C r c) e + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +theorem sum_snoc (U k : ℕ) (F : (Fin (k+1) → Fin (U+1)) → ℝ) : + (∑ σ : Fin k → Fin (U+1), ∑ j : Fin (U+1), F (Fin.snoc σ j)) = ∑ τ, F τ := by + rw [Finset.sum_comm] + have he := Equiv.sum_comp (Fin.snocEquiv (fun _ : Fin (k+1) => Fin (U+1))) F + rw [Fintype.sum_prod_type] at he + exact he + + + +theorem contextTree_level_sum_le (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) (l a k : ℕ) (h : Fintype.card (SmallSlot U r c)=k+a) (hl : l + cases a with + | zero => omega + | succ a => exact contextEnergy_sum_le U L C r c k a h H + | succ l ih => + cases a with + | zero => omega + | succ a => + simp only [contextTree,exposureLevel] + have h' : Fintype.card (SmallSlot U r c) = (k+1)+a := by omega + change (∑ σ : Fin k → Fin (U+1), ∑ j : Fin (U+1), + exposureLevel U a (contextTree U L C r c H a (k+1) h' (Fin.snoc σ j)) l) ≤ _ + rw [sum_snoc U k (fun τ => exposureLevel U a + (contextTree U L C r c H a (k+1) h' τ) l)] + exact ih a (k+1) h' (by omega) + +theorem root_level_le (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) (l : ℕ) (hl : l (weight U L r c (profileState U r c 0 (Fintype.card (SmallSlot U r c)) + (by omega) Fin.elim0 τ):ℝ)) + (fun τ => H (profileState U r c 0 (Fintype.card (SmallSlot U r c)) (by omega) Fin.elim0 τ)) ≤ + 4*(d:ℝ)^2*((U:ℝ)+1)^6 * fullUnitEnergy U L C r c H := by + have hb := exposure_variance_level_bound U (4*(d:ℝ)*((U:ℝ)+1)^6) (by positivity) + (Fintype.card (SmallSlot U r c)) + (fun τ => (weight U L r c (profileState U r c 0 (Fintype.card (SmallSlot U r c)) + (by omega) Fin.elim0 τ):ℝ)) + (fun τ => H (profileState U r c 0 (Fintype.card (SmallSlot U r c)) (by omega) Fin.elim0 τ)) + (fun τ => by positivity) _ + (contextTree_childBounds U L C d r c hU hC2 hd hslots hrc hC H _ 0 (by omega) Fin.elim0) + (fullUnitEnergy U L C r c H) (root_level_le U L C r c H) + refine hb.trans ?_ + have hs : (Fintype.card (SmallSlot U r c):ℝ) ≤ d := by exact_mod_cast hslots + have hm := mul_le_mul_of_nonneg_right hs + (show 0 ≤ (4*(d:ℝ)*((U:ℝ)+1)^6)*fullUnitEnergy U L C r c H from + mul_nonneg (by positivity) (fullUnitEnergy_nonneg U L C r c H)) + nlinarith only [hm] + +end Contingency.PaddedGraph + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/DenseAnalytic.lean b/lean/OAI/Probability/Contingency/DenseAnalytic.lean new file mode 100644 index 0000000000000000000000000000000000000000..46274906f43ce9842d1728c9bc7aafe49f76b40f --- /dev/null +++ b/lean/OAI/Probability/Contingency/DenseAnalytic.lean @@ -0,0 +1,681 @@ +import Mathlib +import OAI.Probability.Contingency.PieceQuantiles + +namespace OAI + +/-! Dense Analytic. -/ + +noncomputable section + +open Set MeasureTheory +open scoped Pointwise +open Set MeasureTheory +open scoped Pointwise +namespace Contingency.Dense +noncomputable section +variable {a c q : ℕ} + +theorem normalized_continuous (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (i : Fin (a+1)) (j : Fin (c+1)) : + Continuous (fun u => normalized R P w u i j) := by + refine Fin.lastCases ?_ (fun i => ?_) i <;> refine Fin.lastCases ?_ (fun j => ?_) j + all_goals simp only [normalized,scaled,complete_corner,complete_bottom,complete_right,complete_free] + all_goals fun_prop + +theorem penalty_continuous (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) : Continuous (penalty R P w B d) := by + apply continuous_const.max + exact Continuous.finset_sup'_apply Finset.univ_nonempty fun s _ => + (normalized_continuous R P w s.1 s.2).neg.sub continuous_const + +theorem density_continuous (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d A : ℝ) : Continuous (density R P w B d A) := by + unfold density + exact continuous_const.rpow (continuous_const.mul (penalty_continuous _ _ _ _ _)) (fun _ => Or.inl (by norm_num)) + +theorem density_le_one (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d A : ℝ) (hA : 0 ≤ A) (u) : density R P w B d A u ≤ 1 := by + unfold density + exact Real.rpow_le_one_of_one_le_of_nonpos (by norm_num) (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hA) (penalty_nonneg _ _ _ _ _ _)) + +def densityWeight (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d A : ℝ) (hA : 0 ≤ A) : Interpolation.GoodWeight q where + f u := density R P w B d A (fun s => u (e.symm s)) + continuous := (density_continuous _ _ _ _ _ _).comp (continuous_pi fun s => continuous_apply _) + positive u := density_pos _ _ _ _ _ _ _ + bound := 1 + bounded u := by rw [Real.norm_eq_abs,abs_of_pos (density_pos _ _ _ _ _ _ _)]; exact density_le_one _ _ _ _ _ _ hA _ + +theorem densityWeight_logconcave (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d A : ℝ) (hA : 0 ≤ A) + (u v : Fin q → ℝ) (α β : ℝ) (ha : 0 ≤ α) (hb : 0 ≤ β) (hab : α+β=1) : + (densityWeight e R P w B d A hA).f u^α*(densityWeight e R P w B d A hA).f v^β ≤ + (densityWeight e R P w B d A hA).f (α • u+β • v) := + density_logconcave R P w B d A hA (fun s => u (e.symm s)) (fun s => v (e.symm s)) α β ha hb hab + +end +end Contingency.Dense + +namespace Contingency.Interpolation +noncomputable section +variable {q : ℕ} + +theorem mix_contains (S T : Finset (OpenBox q)) (hsub : boxUnion S ⊆ boxUnion T) + (t : ℝ) (ht : 0 isClosed_le continuous_const (hf i) |>.measurableSet + +omit [Fintype I] in +theorem homothety_affine (f : I → (Fin q → ℝ) → ℝ) + (hf : ∀ i x y (α β : ℝ),α+β=1 → f i (α • x+β • y)=α*f i x+β*f i y) + (i : I) (u x : Fin q → ℝ) (r : ℝ) : + f i (AffineMap.homothety u r x)=r*f i x+(1-r)*f i u := by + have he : AffineMap.homothety u r x=r • x+(1-r) • u := by + ext j + simp only [AffineMap.homothety_apply, vadd_eq_add,vsub_eq_sub,Pi.add_apply,Pi.sub_apply,Pi.smul_apply,smul_eq_mul] + ring + rw [he,hf i x u r (1-r) (by ring)] + +omit [Fintype I] in +theorem inner_image_subset (f : I → (Fin q → ℝ) → ℝ) + (hf : ∀ i x y (α β : ℝ),α+β=1 → f i (α • x+β • y)=α*f i x+β*f i y) + (u : Fin q → ℝ) (s α : ℝ) (hu : ∀ i,s ≤ f i u) + (ha : 0 ≤ α) (ha1 : α ≤ 1) : + AffineMap.homothety u (1-α) '' region f 0 ⊆ region f (α*s) := by + rintro z ⟨x,hx,rfl⟩ i + rw [homothety_affine f hf,sub_sub_cancel] + exact add_le_add (mul_nonneg (by linarith) (hx i)) (mul_le_mul_of_nonneg_left (hu i) ha) |>.trans' (by ring_nf; rfl) + +omit [Fintype I] in +theorem relaxed_subset_image (f : I → (Fin q → ℝ) → ℝ) + (hf : ∀ i x y (α β : ℝ),α+β=1 → f i (α • x+β • y)=α*f i x+β*f i y) + (u : Fin q → ℝ) (s γ : ℝ) (hs : 0 x (e.symm s)) s.1 s.2 + +theorem constraints_affine (e : Fin q ≃ Fin a×Fin c) (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (i) (x y : Fin q → ℝ) (α β : ℝ) (hab : α+β=1) : + constraints e R P w i (α • x+β • y)=α*constraints e R P w i x+β*constraints e R P w i y := + normalized_affine R P w _ _ α β hab _ _ + +theorem constraints_continuous (e : Fin q ≃ Fin a×Fin c) (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (i) : Continuous (constraints e R P w i) := + (normalized_continuous R P w _ _).comp (continuous_pi fun coordinate => continuous_apply (e.symm coordinate)) + +theorem constraints_lipschitz (e : Fin q ≃ Fin a×Fin c) (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (hB : 0 Set.Icc 0 (2*B)) := by + intro x hx + have hh := polytope_bounded R P w B hB hR hP heq hw (fun s => x (e.symm s)) (fun i j => hx (i,j)) + intro i _ + simpa only [e.symm_apply_apply,Set.mem_Icc] using hh (e i) + +theorem region_volume_finite (e : Fin q ≃ Fin a×Fin c) (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B : ℝ) (hB : 0 isCompact_Icc).measure_lt_top + +theorem region_interior (e : Fin q ≃ Fin a×Fin c) (d : ℝ) (hd : 0 u (e i),fun i => ?_⟩ + simpa only [constraints,e.apply_symm_apply] using hu i.1 i.2 + +theorem inner_half_volume (f : (Fin (a+1)×Fin (c+1)) → (Fin q → ℝ) → ℝ) + (hf : ∀ i x y (α β : ℝ),α+β=1 → f i (α • x+β • y)=α*f i x+β*f i y) + (d : ℝ) (hd : 2 ≤ d) (hq : (q:ℝ) ≤ d) (u : Fin q → ℝ) + (hu : ∀ i,1/(2*d) ≤ f i u) : + (1/2:ENNReal)*volume (region f 0) ≤ volume (region f (2*d/d^8)) := by + have hd0 : 0 (x : ENNReal)) h + simpa only [ENNReal.coe_mul,ENNReal.coe_div (by norm_num : (2:NNReal)≠0),ENNReal.coe_div (by norm_num : (3:NNReal)≠0),ENNReal.coe_one,ENNReal.coe_ofNat] using hh +theorem geometric_constant : (1-(2/3:ENNReal))⁻¹*(4/3)=4 := by + have hs : (1-(2/3:NNReal))=1/3 := by + apply NNReal.eq + rw [NNReal.coe_sub (by norm_num [div_le_one (by norm_num : (0:NNReal)<3)] : (2/3:NNReal) ≤ 1)] + norm_num + have h : (1-(2/3:NNReal))⁻¹*(4/3)=4 := by rw [hs]; norm_num + have hh := congrArg (fun x : NNReal => (x : ENNReal)) h + simpa only [ENNReal.coe_mul,ENNReal.coe_inv (show (1-(2/3:NNReal))≠0 by rw [hs]; norm_num),ENNReal.coe_sub,ENNReal.coe_div (by norm_num : (3:NNReal)≠0),ENNReal.coe_one,ENNReal.coe_ofNat] using hh + +theorem decay_nat (j : ℕ) : ENNReal.ofReal ((2:ℝ)^(-(j:ℝ)))=(1/2:ENNReal)^j := by + rw [Real.rpow_neg (by norm_num),Real.rpow_natCast,← inv_pow,ENNReal.ofReal_pow (by positivity)] + rw [ENNReal.ofReal_inv_of_pos (by norm_num : (0:ℝ)<2)] + norm_num + + + +theorem density_layer_bound (p : (Fin q → ℝ) → ℝ) (hp : Measurable p) + (hp0 : ∀ x,0 ≤ p x) (A : ℝ) (hA : 0 (1/2:ENNReal)^j) + have hf (j : ℕ) : Measurable (f j) := measurable_const.indicator (hm j) + have hpoint (x : Fin q → ℝ) : ENNReal.ofReal ((2:ℝ)^(-A*p x)) ≤ ∑' j,f j x := by + let j := ⌊A*p x⌋₊ + have hj : x∈T j := by + apply (lt_div_iff₀ hA).mpr + simpa only [mul_comm] using Nat.lt_floor_add_one (A*p x) + apply le_trans _ (ENNReal.le_tsum j) + rw [show f j x=(1/2:ENNReal)^j from Set.indicator_of_mem hj _] + rw [← decay_nat] + apply ENNReal.ofReal_le_ofReal + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + have hh := Nat.floor_le (mul_nonneg hA.le (hp0 x)) + dsimp [j] + linarith only [hh] + calc + _ ≤ ∫⁻ x in S,∑' j,f j x := lintegral_mono hpoint + _ = ∑' j, (1/2:ENNReal)^j*volume (T j∩S) := by + rw [lintegral_tsum fun j => (hf j).aemeasurable] + congr 1 + funext j + rw [lintegral_indicator (hm j),lintegral_const,Measure.restrict_apply MeasurableSet.univ] + rw [Set.univ_inter,Measure.restrict_apply (hm j)] + _ ≤ ∑' j,(1/2:ENNReal)^j*((4/3:ENNReal)^(j+1)*V) := + ENNReal.tsum_le_tsum fun j => by gcongr; exact hvol j + _ = 4*V := by + have hterm (j : ℕ) : (1/2:ENNReal)^j*((4/3:ENNReal)^(j+1)*V)= + (2/3:ENNReal)^j*((4/3)*V) := by + rw [pow_succ] + calc + _ = ((1/2:ENNReal)*(4/3))^j*((4/3)*V) := by rw [mul_pow]; ring + _ = _ := by rw [half_times_four_thirds] + simp_rw [hterm] + rw [ENNReal.tsum_mul_right,ENNReal.tsum_geometric] + rw [← mul_assoc,geometric_constant] + +theorem exp_quarter_bound (x : ℝ) (hx : x ≤ 1/4) : Real.exp x ≤ 4/3 := by + apply (Real.exp_le_exp.mpr hx).trans + have hh := Real.exp_bound_div_one_sub_of_interval (x := 1/4) (by norm_num) (by norm_num) + norm_num at hh ⊢ + exact hh + +theorem dense_exponent_layer (d : ℝ) (hd : 4 ≤ d) (j : ℕ) : + Real.exp (2*d^2*(d/d^8+((j:ℝ)+1)/d^4)) ≤ (4/3:ℝ)^(j+1) := by + have hd0 : 0 if i.val exact (h rfl).elim + | succ n ih => + by_cases hh : f 0=f n + · exact ⟨n,Nat.lt_succ_self n,fun he => h (hh.trans he)⟩ + · obtain ⟨k,hk,he⟩ := ih hh + exact ⟨k,hk.trans (Nat.lt_succ_self n),he⟩ + +theorem path_step (v w : Fin q → ℕ) (k : Fin q) : + path v w (k.val+1)=Function.update (path v w k.val) k (w k) := by + ext i + by_cases hi : i=k + · subst i; simp [path] + · have hh : i.val ≠ k.val := fun h => hi (Fin.ext h) + simp only [path,Function.update_of_ne hi] + split_ifs <;> omega + +def neighbors (v w : Fin q → ℕ) (i : Fin q) : Prop := + (v i+1=w i ∨ w i+1=v i) ∧ ∀ j,j ≠ i → v j=w j + + +def face (v w : Fin q → ℕ) (i : Fin q) : Set (Fin q → ℝ) := + {z | z i=(max (v i) (w i):ℕ) ∧ ∀ j,j ≠ i → (v j:ℝ) ≤ z j ∧ z j ≤ (v j:ℝ)+1} + +theorem adjacent_of_close (v w : ℕ) (x z r : ℝ) + (hx : (v:ℝ) label (path v w n)) q hp + let i : Fin q := ⟨k,hk⟩ + have hiv : path v w k i=v i := by simp [path,i] + have hiw : path v w (k+1) i=w i := by simp [path,i] + have hj (j : Fin q) (hji : j ≠ i) : path v w k j=path v w (k+1) j := by + have hh := congrFun (path_step v w i) j + simpa only [i,Function.update_of_ne hji] using hh.symm + have hne : v i ≠ w i := by + intro hh + apply hstep + congr 1 + ext j + by_cases hji : j=i + · subst j; rw [hiv,hiw,hh] + · exact hj j hji + have hn := adjacent_of_close (v i) (w i) (x i) (z i) r (hx i) (hz i) (hc i) hr hne + let p : Fin q → ℝ := fun j => if j=i then (max (v i) (w i):ℕ) else if j.val simp + · intro j; simp only [path]; split_ifs <;> simp + · constructor + · simp [p,hiv,hiw] + · intro j hji + simp only [p,ite_eq_right hji,path] + split_ifs with h + · exact ⟨(hz j).1.le,(hz j).2.le⟩ + · exact ⟨(hx j).1.le,(hx j).2.le⟩ + · intro j + by_cases hji : j=i + · subst j + simp only [p,ite_eq_left rfl] + rcases hn with hh | hh + · have hle : v i ≤ w i := by omega + rw [max_eq_right hle,abs_of_nonpos (by linarith [(hz i).1] : (w i:ℝ)-z i ≤ 0)] + have hc' := (abs_lt.mp (hc i)).1 + have he : (v i:ℝ)+1=(w i:ℝ) := by exact_mod_cast hh + linarith [(hx i).2] + · have hle : w i ≤ v i := by omega + have he : (w i:ℝ)+1=(v i:ℝ) := by exact_mod_cast hh + have hnz : 0 ≤ (v i:ℝ)-z i := by linarith [(hz i).2] + rw [max_eq_left hle,abs_of_nonneg hnz] + have hc' := (abs_lt.mp (hc i)).2 + linarith [(hx i).1] + · simp only [p,ite_eq_right hji] + split_ifs + · simpa only [sub_self,abs_zero] using (lt_of_le_of_lt (abs_nonneg (x j-z j)) (hc j)) + · exact hc j + +end +end Contingency.Grid + + + + + +open Set MeasureTheory +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} +abbrev Vertex (q K : ℕ) := Fin q → Fin K + +def corner (v : Vertex q K) : Fin q → ℕ := fun i => v i + +def bin (v : Vertex q K) : Interpolation.OpenBox q := + ⟨fun i => v i,fun i => (v i:ℝ)+1⟩ + +@[simp] theorem mem_bin (v : Vertex q K) (x : Fin q → ℝ) : x∈(bin v).carrier ↔ inside (corner v) x := by + simp [bin,Interpolation.OpenBox.carrier,inside,corner] + +def cube (q K : ℕ) : Interpolation.OpenBox q := ⟨fun _ => 0,fun _ => K⟩ + +@[simp] theorem mem_cube (x : Fin q → ℝ) : x∈(cube q K).carrier ↔ ∀ i,0 Disjoint (bin v).carrier (bin w).carrier) := by + intro v w hne + apply Set.disjoint_left.mpr + intro x hx hy + exact hne (bin_unique v w x ((mem_bin v x).mp hx) ((mem_bin w x).mp hy)) + + +theorem ae_no_grid : ∀ᵐ x : Fin q → ℝ ∂volume,∀ i : Fin q,∀ n : ℕ,x i ≠ (n:ℝ) := by + apply ae_all_iff.mpr + intro i + apply ae_all_iff.mpr + intro n + exact Measure.ae_eval_ne (fun _ : Fin q => (volume : Measure ℝ)) i (n:ℝ) + +theorem exists_bin (x : Fin q → ℝ) (hx : x∈(cube q K).carrier) + (hgrid : ∀ i : Fin q,∀ n : ℕ,x i ≠ (n:ℝ)) : + ∃ v : Vertex q K,inside (corner v) x := by + have hc := (mem_cube x).mp hx + have hf (i : Fin q) : ⌊x i⌋₊ ⟨⌊x i⌋₊,hf i⟩ + refine ⟨v,fun i => ⟨?_,?_⟩⟩ + · exact lt_of_le_of_ne (Nat.floor_le (hc i).1.le) (Ne.symm (hgrid i _)) + · exact Nat.lt_floor_add_one (x i) + +theorem cube_ae_union : Interpolation.boxUnion (boxes (Finset.univ : Finset (Vertex q K))) =ᵐ[volume] + (cube q K).carrier := by + filter_upwards [ae_no_grid (q:=q)] with x hx + apply propext + constructor + · intro hx + exact bins_subset_cube (Finset.univ : Finset (Vertex q K)) hx + · intro hc + obtain ⟨v,hv⟩ := exists_bin x hc hx + exact (mem_boxes _ x).mpr ⟨v,Finset.mem_univ _,hv⟩ + +def faceBox (v w : Vertex q K) (i : Fin q) (r : ℝ) : Interpolation.OpenBox q := + ⟨fun j => if j=i then (max (v i:ℕ) (w i:ℕ):ℕ)-r else (v j:ℝ)-r, + fun j => if j=i then (max (v i:ℕ) (w i:ℕ):ℕ)+r else (v j:ℝ)+1+r⟩ + +theorem mem_faceBox (v w : Vertex q K) (i : Fin q) (r : ℝ) (p z : Fin q → ℝ) + (hp : p∈face (corner v) (corner w) i) (hc : ∀ j,|p j-z j| linarith + · simp only [faceBox,ite_eq_right hj] + have he := hp.2 j hj + dsimp [corner] at he + constructor <;> linarith + + + +theorem bounded_cut_face (V : Finset (Vertex q K)) (v w : Vertex q K) (hv : v∈V) (hw : w∉V) + (x z : Fin q → ℝ) (hx : inside (corner v) x) (hz : inside (corner w) z) + (r : ℝ) (hr : r ≤ 1) (hc : ∀ i,|x i-z i| ⟨a i,ha i⟩ + let label (a : Fin q → ℕ) : Bool := if ha : ∀ i,a i (v i).isLt + have hwb : ∀ i,corner w i (w i).isLt + have hl : label (corner v) ≠ label (corner w) := by simp [label,lift,corner,hv,hw] + obtain ⟨u,u',i,hn,hl',hu,hu',p,hp,hclose⟩ := cut_face_close (corner v) (corner w) label hl x z hx hz r hr hc + have hub : ∀ j,u j by rcases hu j with h | h <;> rw [h]; exact hvb j; exact hwb j + have hu'b : ∀ j,u' j by rcases hu' j with h | h <;> rw [h]; exact hvb j; exact hwb j + refine ⟨lift u hub,lift u' hu'b,i,hn,?_,?_⟩ + · simp only [label,dite_eq_left hub,dite_eq_left hu'b] at hl' + by_cases h : lift u hub∈V + · exact Or.inl ⟨h,fun h' => hl' (by simp [h,h'])⟩ + · exact Or.inr ⟨h,by by_contra h'; exact hl' (by simp [h,h'])⟩ + · exact mem_faceBox _ _ _ _ p z hp hclose + +end +end Contingency.Grid + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/DenseDyadic.lean b/lean/OAI/Probability/Contingency/DenseDyadic.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b77b02e20d38477bac3fdd3a7fbafbf69dc2639 --- /dev/null +++ b/lean/OAI/Probability/Contingency/DenseDyadic.lean @@ -0,0 +1,699 @@ +import Mathlib +import OAI.Probability.Contingency.DenseWeightBounds + +namespace OAI + +/-! Dense Dyadic. -/ + +noncomputable section + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +noncomputable section +open Contingency.Grid Contingency.FiniteChain +variable {a c q K : ℕ} (D : BinProblem a c q K) +attribute [local instance] tableFintype tableNonempty +local instance : DecidableRel (@Adj q K) := Classical.decRel _ + +def exponent (v : Vertex q K) : ℕ := + (⌊binExponent D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths D.d (realCorner v)⌋:ℤ).toNat + +theorem floor_nonneg (v : Vertex q K) : + 0≤(⌊binExponent D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths D.d (realCorner v)⌋:ℤ) := by + exact Int.floor_nonneg.mpr (mul_nonneg (by positivity) (penalty_nonneg _ _ _ _ _ _)) + +theorem weight_exponent (v : Vertex q K) : D.weight v=1/(2:ℝ)^D.exponent v := by + change (2:ℝ)^(-(⌊binExponent D.e _ _ D.widths D.d (realCorner v)⌋:ℝ))=_ + rw [← Int.toNat_of_nonneg (D.floor_nonneg v)] + simp only [Int.cast_natCast,Real.rpow_neg (by norm_num : (0:ℝ)≤2),Real.rpow_natCast,one_div,exponent] + +theorem exponent_bound (d : ℕ) (hD : D.d=d) (hK : (K:ℝ)=4*D.d^8) (v : Vertex q K) : + D.exponent v≤8*d^5 := by + apply Int.toNat_le.mpr + have hh := Int.floor_le (binExponent D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths D.d (realCorner v)) + have hb := mul_le_mul_of_nonneg_left (D.corner_penalty_bound hK v) (show 0≤D.d^4 by positivity) + have hle : (⌊binExponent D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths D.d (realCorner v)⌋:ℝ)≤8*(d:ℝ)^5 := by + unfold binExponent at hh ⊢ + rw [hD] at hh hb ⊢ + nlinarith only [hh,hb,show 0≤(d:ℝ)^5 by positivity] + exact_mod_cast hle + +theorem neighbor_bound (d : ℕ) (hD : D.d=d) (v : Vertex q K) : + (Finset.univ.filter (Adj v)).card≤2^Nat.clog 2 (8*d) := by + classical + have he : (Finset.univ.filter (Adj v)).card=Nat.card {w : Vertex q K // Adj v w} := by + rw [Nat.card_eq_fintype_card,Fintype.card_subtype] + rw [he] + have hq : q≤d := by + have hq' := D.hq + rw [hD] at hq' + exact_mod_cast hq' + exact (neighbor_card v).trans ((by omega : 2*q≤8*d).trans (Nat.le_pow_clog (by norm_num) (8*d))) + +def bitKernel (d : ℕ) (hD : D.d=d) (v : Vertex q K) : DyadicLaw (Vertex q K) := by + classical + exact (DyadicLaw.neighborProposal Adj v (Nat.clog 2 (8*d)) (adj_irrefl v) (D.neighbor_bound d hD v)).accept D.exponent (8*d^5) v + +theorem bitKernel_bits (d : ℕ) (hD : D.d=d) (v : Vertex q K) : + (D.bitKernel d hD v).bits=Nat.clog 2 (8*d)+8*d^5 := rfl + +theorem bitKernel_law (d : ℕ) (hD : D.d=d) (hK : (K:ℝ)=4*D.d^8) + (hp0 : 0≤proposalRate (8*d)) (hp : proposalRate (8*d)≤1/(8*D.d)) (v : Vertex q K) : + (D.bitKernel d hD v).toLaw=(D.chain (proposalRate (8*d)) hp0 hp).transition v := by + classical + apply DyadicLaw.accepted_neighbor_kernel Adj D.exponent (8*d^5) (Nat.clog 2 (8*d)) (D.exponent_bound d hD hK) v + intro w hvw + change (if v=w then _ else _) = _ + rw [ite_eq_right hvw] + change proposalRate (8*d)*edgeWeight D.weight v w/D.weight v=_ + simp only [edgeWeight,D.weight_exponent,proposalRate] + +def bitOffsets (h d : ℕ) : DyadicLaw (Offsets D.w) := + DyadicLaw.pi (fun i => offsetLaw (D.w i) (D.hw i) (Nat.clog 2 (D.w i+1)+4*(h+d))) + +theorem bitOffsets_law (h d : ℕ) : (D.bitOffsets h d).toLaw=D.implementedOffsets h d := by + exact DyadicLaw.toLaw_pi _ + +def bitTrial (h d : ℕ) (hD : D.d=d) (t : ℕ) : DyadicLaw (Option (Tables D.R D.P)) := by + classical + let walk := DyadicLaw.walk (D.bitKernel d hD) (Nat.clog 2 (8*d)+8*d^5) (D.bitKernel_bits d hD) (fun _ => ⟨0,D.Kpos⟩) t + exact (walk.bind (fun v => (D.bitOffsets h d).map (fun β => (v,β))) (D.bitOffsets h d).bits + (fun _ => DyadicLaw.map_bits _ _)).map D.decode + +theorem bitTrial_law (h d : ℕ) (hD : D.d=d) (hK : (K:ℝ)=4*D.d^8) + (hp0 : 0≤proposalRate (8*d)) (hp : proposalRate (8*d)≤1/(8*D.d)) (t : ℕ) : + (D.bitTrial h d hD t).toLaw=D.implementedTrial (proposalRate (8*d)) hp0 hp h d t := by + classical + have hw : (DyadicLaw.walk (D.bitKernel d hD) (Nat.clog 2 (8*d)+8*d^5) (D.bitKernel_bits d hD) + (fun _ => ⟨0,D.Kpos⟩) t).toLaw=(D.chain (proposalRate (8*d)) hp0 hp).walk (fun _ => ⟨0,D.Kpos⟩) t := by + induction t with + | zero => exact DyadicLaw.toLaw_pure _ _ + | succ t ih => + simp only [DyadicLaw.walk,DyadicLaw.toLaw_bind,Chain.walk] + rw [ih] + congr 1 + funext x + exact D.bitKernel_law d hD hK hp0 hp x + simp only [bitTrial,DyadicLaw.toLaw_map,DyadicLaw.toLaw_bind,D.bitOffsets_law] + rw [hw] + congr 1 + apply Law.ext; funext s + rcases s with ⟨v,β⟩ + simp only [Law.bind,Law.map,Law.pure,Law.prod] + simp [Prod.mk.injEq,ite_and,Finset.sum_ite_irrel,mul_ite] + +def bitDraw (h d : ℕ) (hD : D.d=d) (fallback : Tables D.R D.P) : DyadicLaw (Tables D.R D.P) := by + classical + exact stoppedLaw (D.bitTrial h d hD (d^50*(h+1)^2)) fallback (d^4*(h+1)) + +theorem bitDraw_tv (d : ℕ) (hd : 14≤d) (hD : D.d=d) (hK : (K:ℝ)=4*D.d^8) + (h : ℕ) (hh : 1≤h) (fallback : Tables D.R D.P) : + (D.bitDraw h d hD fallback).toLaw.tv (Law.uniform (Tables D.R D.P))≤(2:ℝ)^(-(h:ℤ)) := by + classical + have hb := binProposal_bounds d (by omega) + have hp : proposalRate (8*d)≤1/(8*D.d) := by simpa only [hD] using hb.2 + have hp0 : 0≤proposalRate (8*d) := by unfold proposalRate; positivity + rw [bitDraw,stoppedLaw_toLaw,D.bitTrial_law h d hD hK hp0 hp] + exact D.draw_tv d hd hD hK _ hp0 hp (by simpa only [hD] using hb.1) h hh fallback + +end +end Contingency.Dense.BinProblem + + + + + +namespace Contingency +namespace Schedule + +def h (d b k : ℕ) := d^4*(k+b)^2 +def T (d b k : ℕ) := d^200*(k+b)^2 +def Jo (d k : ℕ) := d^4*(k+1) +def Q (d : ℕ) := Nat.clog 2 (8*d)+8*d^5 +def qs (d : ℕ) := Nat.clog 2 (32*d^2) +def rmax (d b k : ℕ) := b+1+4*(h d b k+d) +def H (d b k : ℕ) := d^50*(h d b k+1)^2 +def JD (d b k : ℕ) := d^4*(h d b k+1) +def R1 (d b k : ℕ) := H d b k*Q d+d*rmax d b k +def RD (d b k : ℕ) := JD d b k*R1 d b k +def RT (d b k : ℕ) := T d b k*(RD d b k+qs d)+RD d b k +def R (d b k : ℕ) := Jo d k*RT d b k + +theorem clog_self_bound (x : ℕ) : Nat.clog 2 x≤x := + Nat.clog_le_of_le_pow (Nat.lt_two_pow_self (n:=x)).le + +theorem qs_bound (d : ℕ) : qs d≤2*d+5 := by + apply Nat.clog_le_of_le_pow + calc + 32*d^2 ≤ 32*(2^d)^2 := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left (Nat.lt_two_pow_self (n:=d)).le 2) + _ = 2^(2*d+5) := by rw [← pow_mul,Nat.mul_comm d 2,pow_add]; norm_num; ring + + + +theorem bounds (d b k : ℕ) (hd : 14≤d) (hb : d≤b) (hk : 1≤k) : + let q := d+b+k+2 + h d b k≤q^6 ∧ h d b k+1≤q^7 ∧ Q d≤q^6 ∧ rmax d b k≤q^7 ∧ + H d b k≤q^64 ∧ R1 d b k≤q^71 ∧ RD d b k≤q^82 ∧ + RT d b k≤q^285 ∧ R d b k≤q^290 ∧ R d b k≤q^300 := by + dsimp only + set q := d+b+k+2 + have hq : 31≤q := by dsimp [q]; omega + have hq0 : 0 R (marginOrder R i) +abbrev sortedP := fun j => P (marginOrder P j) + +def literalWidth (i : Fin (a*c)) : ℕ := + min (sortedR R ((finProdFinEquiv.symm i).1.castSucc)) + (sortedP P ((finProdFinEquiv.symm i).2.castSucc))/(d^8) + +include hd in +theorem padding_scale : 2*d^8 ≤ d^12 := by + have hh : 2 ≤ d^4 := (by norm_num : 2 ≤ 14^4).trans (Nat.pow_le_pow_left hd _) + nlinarith only [Nat.mul_le_mul_left (d^8) hh,show d^12=d^8*d^4 by ring] + +abbrev literalProblem : BinProblem a c (a*c) (4*d^8) where + e := finProdFinEquiv.symm + R := sortedR R + P := sortedP P + w := literalWidth d R P + d := d + hd := by exact_mod_cast (show 4 ≤ d by omega) + hq := by exact_mod_cast (Nat.mul_le_mul (Nat.le_add_right a 1) (Nat.le_add_right c 1)).trans hac + ha := by exact_mod_cast ha + hc := by exact_mod_cast hc + hK := by + push_cast + have hp : (0:ℝ) < (d:ℝ)^8 := by positivity + linarith + hR i := (pow_pos (by omega : 0 < d) 12).trans_le (hR _) + hP j := (pow_pos (by omega : 0 < d) 12).trans_le (hP _) + heq := by rw [(marginOrder R).sum_comp R,(marginOrder P).sum_comp P]; exact heq + hRmax := marginOrder_max R + hPmax := marginOrder_max P + hw i := (floor_width_bounds _ (d^8) (by positivity) ((padding_scale d hd).trans (le_min (hR _) (hP _)))).1 + hwlo i := by + have hh := (floor_width_bounds + (min (sortedR R (finProdFinEquiv.symm i).1.castSucc) (sortedP P (finProdFinEquiv.symm i).2.castSucc)) + (d^8) (by positivity) ((padding_scale d hd).trans (le_min (hR _) (hP _)))).2.1 + simpa only [scale,literalWidth,Nat.cast_min,Nat.cast_pow] using hh + hwhi i := by + have hh := (floor_width_bounds + (min (sortedR R (finProdFinEquiv.symm i).1.castSucc) (sortedP P (finProdFinEquiv.symm i).2.castSucc)) + (d^8) (by positivity) ((padding_scale d hd).trans (le_min (hR _) (hP _)))).2.2 + simpa only [scale,literalWidth,Nat.cast_min,Nat.cast_pow] using hh + +theorem literalWidth_bound (_hd : 14 ≤ d) (b : ℕ) (hRb : ∀ i,R i ≤ 2^b) (i : Fin (a*c)) : literalWidth d R P i ≤ 2^b := by + exact (Nat.div_le_self _ _).trans ((min_le_left _ _).trans (hRb _)) + +attribute [local instance] BinProblem.tableFintype + +def literalDraw (b k : ℕ) (hRb : ∀ i,R i ≤ 2^b) (fallback : Tables R P) : DyadicLaw (Tables R P) := by + classical + let e := permuteTableEquiv R P (marginOrder R) (marginOrder P) + let D := literalProblem d R P hd ha hc hac hR hP heq + exact (D.reservedDraw d b k rfl (literalWidth_bound d R P hd b hRb) (e fallback)).map e.symm + +theorem literalDraw_bits (b k : ℕ) (hRb : ∀ i,R i ≤ 2^b) (fallback : Tables R P) : + (literalDraw d R P hd ha hc hac hR hP heq b k hRb fallback).bits=Schedule.RD d b k := by + classical + simp only [literalDraw,DyadicLaw.map_bits,BinProblem.reservedDraw_bits] + +theorem literalDraw_tv (b k : ℕ) (hk : 1 ≤ k) (hRb : ∀ i,R i ≤ 2^b) (fallback : Tables R P) : + letI := tables_nonempty R P heq + (literalDraw d R P hd ha hc hac hR hP heq b k hRb fallback).toLaw.tv (Law.uniform (Tables R P)) ≤ + (2:ℝ)^(-(Schedule.h d b k:ℤ)) := by + classical + let := tables_nonempty R P heq + let e := permuteTableEquiv R P (marginOrder R) (marginOrder P) + let D := literalProblem d R P hd ha hc hac hR hP heq + let := tables_nonempty D.R D.P D.heq + have hK : ((4*d^8:ℕ):ℝ)=4*D.d^8 := by simp [D] + have hh := D.reservedDraw_tv d b k hd hk rfl hK (literalWidth_bound d R P hd b hRb) (e fallback) + change ((D.reservedDraw d b k rfl _ (e fallback)).map e.symm).toLaw.tv _ ≤ _ + rw [DyadicLaw.toLaw_map,← Law.uniform_map_equiv e.symm] + exact (Law.tv_map e.symm _ _).trans hh + +end +end Contingency.Dense + + + + + +open scoped BigOperators + +namespace Contingency +namespace PaddedGraph + +variable {m n : ℕ} + + +def IsLarge (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (s : Cell m n) : Prop := + U ≤ r s.1 ∧ U ≤ c s.2 + +def IsSmall (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (s : Cell m n) : Prop := + ¬IsLarge U r c s + +instance (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (s : Cell m n) : + Decidable (IsLarge U r c s) := inferInstanceAs (Decidable (_ ∧ _)) +instance (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (s : Cell m n) : + Decidable (IsSmall U r c s) := inferInstanceAs (Decidable (¬_)) + + + +structure State (m n : ℕ) where + x : Cell m n → ℤ + q : Cell m n → ℤ + deriving DecidableEq + +def rowSum (x : Cell m n → ℤ) (i : Fin m) : ℤ := ∑ j, x (i,j) +def colSum (x : Cell m n → ℤ) (j : Fin n) : ℤ := ∑ i, x (i,j) + +def Feasible (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) (X : State m n) : Prop := + (∀ s, 0 ≤ X.x s ∧ X.x s ≤ U ∧ 0 ≤ X.q s ∧ X.q s ≤ U) ∧ + (∀ s, IsLarge U r c s → X.x s = 0 ∧ X.q s = 0) ∧ + (∀ i, rowSum X.x i ≤ r i ∧ ((∀ j, ¬IsLarge U r c (i,j)) → rowSum X.x i = r i)) ∧ + (∀ j, colSum X.q j ≤ c j ∧ ((∀ i, ¬IsLarge U r c (i,j)) → colSum X.q j = c j)) + +def Transversal (X : State m n) : Prop := X.q = X.x + +def unit (s : Cell m n) : Cell m n → ℤ := fun v => if v = s then 1 else 0 + +def DefectAt (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) : Prop := + IsSmall U r c s ∧ IsSmall U r c t ∧ s ≠ t ∧ + X.q = fun v => X.x v - unit t v + unit s v + +def receiver (s t : Cell m n) : Cell m n := (t.1,s.2) + + +noncomputable def repair (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) : State m n := + let x' := fun w => X.x w - unit t w + if IsSmall U r c (receiver s t) then unit (receiver s t) w else 0 + ⟨x',x'⟩ + +@[simp] theorem repair_transversal (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) : Transversal (repair U r c s t X) := rfl + +@[simp] theorem rowSum_unit (s : Cell m n) (i : Fin m) : + rowSum (unit s) i = if i = s.1 then 1 else 0 := by + classical + rcases s with ⟨a,b⟩ + unfold rowSum unit + by_cases hi : i = a + · subst i; simp + · simp [hi] + +@[simp] theorem colSum_unit (s : Cell m n) (j : Fin n) : + colSum (unit s) j = if j = s.2 then 1 else 0 := by + classical + rcases s with ⟨a,b⟩ + unfold colSum unit + by_cases hj : j = b + · subst j; simp + · simp [hj] + +theorem rowSum_sub_add (x y z : Cell m n → ℤ) (i : Fin m) : + rowSum (fun v => x v-y v+z v) i = rowSum x i-rowSum y i+rowSum z i := by + simp [rowSum,Finset.sum_add_distrib,Finset.sum_sub_distrib] + +theorem colSum_sub_add (x y z : Cell m n → ℤ) (j : Fin n) : + colSum (fun v => x v-y v+z v) j = colSum x j-colSum y j+colSum z j := by + simp [colSum,Finset.sum_add_distrib,Finset.sum_sub_distrib] + +theorem donor_positive (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hx : Feasible U r c X) (hd : DefectAt U r c s t X) : + 1 ≤ X.x t := by + have h := congrFun hd.2.2.2 t + have hq := (hx.1 t).2.2.1 + change X.q t = X.x t - (if t = t then 1 else 0) + (if t = s then 1 else 0) at h + simp [Ne.symm hd.2.2.1] at h + omega + +theorem repair_nonneg (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hx : Feasible U r c X) (hd : DefectAt U r c s t X) : + ∀ w, 0 ≤ (repair U r c s t X).x w := by + intro w + have h0 := (hx.1 w).1 + have ht := donor_positive U r c s t X hx hd + dsimp [repair,unit] + by_cases hw : w = t + · subst w; split_ifs <;> omega + · simp only [ite_eq_right hw,sub_zero] + split_ifs <;> omega + +theorem repair_support (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hx : Feasible U r c X) (hd : DefectAt U r c s t X) : + ∀ w, IsLarge U r c w → (repair U r c s t X).x w = 0 := by + intro w hw + have hwt : w ≠ t := by intro he; exact hd.2.1 (he ▸ hw) + have hx0 := (hx.2.1 w hw).1 + dsimp [repair,unit] + rw [hx0,ite_eq_right hwt] + by_cases hv : IsSmall U r c (receiver s t) + · rw [ite_eq_left hv] + have hwv : w ≠ receiver s t := by intro he; exact hv (he ▸ hw) + rw [ite_eq_right hwv] + ring + · rw [ite_eq_right hv] + ring + +theorem repair_rowSum (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (i : Fin m) : + rowSum (repair U r c s t X).x i = rowSum X.x i - + if IsLarge U r c (receiver s t) ∧ i = t.1 then 1 else 0 := by + by_cases hv : IsSmall U r c (receiver s t) + · change rowSum (fun w => X.x w - unit t w + if IsSmall U r c (receiver s t) then unit (receiver s t) w else 0) i = _ + simp only [ite_eq_left hv,rowSum_sub_add,rowSum_unit] + have hv' : ¬IsLarge U r c (receiver s t) := hv + have hnot : ¬(IsLarge U r c (receiver s t) ∧ i = t.1) := fun h => hv' h.1 + rw [ite_eq_right hnot] + dsimp [receiver] + omega + · have hv' : IsLarge U r c (receiver s t) := Classical.not_not.mp hv + simp only [repair,ite_eq_right hv] + change rowSum (fun w => X.x w-unit t w+0) i = _ + rw [rowSum_sub_add,rowSum_unit] + simp [rowSum,hv'] + +theorem repair_q_identity (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) : + (repair U r c s t X).q = fun w => X.q w - unit s w + + if IsSmall U r c (receiver s t) then unit (receiver s t) w else 0 := by + funext w + have h := congrFun hd.2.2.2 w + dsimp [repair] + rw [h] + ring + +theorem repair_colSum (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) (j : Fin n) : + colSum (repair U r c s t X).q j = colSum X.q j - + if IsLarge U r c (receiver s t) ∧ j = s.2 then 1 else 0 := by + rw [repair_q_identity U r c s t X hd] + by_cases hv : IsSmall U r c (receiver s t) + · simp only [ite_eq_left hv,colSum_sub_add,colSum_unit] + have hv' : ¬IsLarge U r c (receiver s t) := hv + have hnot : ¬(IsLarge U r c (receiver s t) ∧ j = s.2) := fun h => hv' h.1 + rw [ite_eq_right hnot] + dsimp [receiver] + omega + · have hv' : IsLarge U r c (receiver s t) := Classical.not_not.mp hv + simp only [ite_eq_right hv] + rw [colSum_sub_add,colSum_unit] + simp [colSum,hv'] + +theorem coordinate_le_rowSum (x : Cell m n → ℤ) (hx : ∀ v, 0 ≤ x v) (s : Cell m n) : + x s ≤ rowSum x s.1 := by + apply Finset.single_le_sum (fun j _ => hx (s.1,j)) (Finset.mem_univ s.2) + +theorem coordinate_le_colSum (x : Cell m n → ℤ) (hx : ∀ v, 0 ≤ x v) (s : Cell m n) : + x s ≤ colSum x s.2 := by + apply Finset.single_le_sum (fun i _ => hx (i,s.2)) (Finset.mem_univ s.1) + + + +theorem repair_feasible (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hx : Feasible U r c X) (hd : DefectAt U r c s t X) : + Feasible U r c (repair U r c s t X) := by + have hnn := repair_nonneg U r c s t X hx hd + have hsup := repair_support U r c s t X hx hd + have hr (i) : rowSum (repair U r c s t X).x i ≤ r i ∧ + ((∀ j, ¬IsLarge U r c (i,j)) → rowSum (repair U r c s t X).x i = r i) := by + rw [repair_rowSum] + constructor + · have h := (hx.2.2.1 i).1 + split_ifs <;> omega + · intro hi + have h := (hx.2.2.1 i).2 hi + have hn : ¬(IsLarge U r c (receiver s t) ∧ i = t.1) := by + rintro ⟨hl, rfl⟩ + exact hi s.2 hl + rw [ite_eq_right hn,h] + omega + have hc (j) : colSum (repair U r c s t X).q j ≤ c j ∧ + ((∀ i, ¬IsLarge U r c (i,j)) → colSum (repair U r c s t X).q j = c j) := by + rw [repair_colSum U r c s t X hd] + constructor + · have h := (hx.2.2.2 j).1 + split_ifs <;> omega + · intro hj + have h := (hx.2.2.2 j).2 hj + have hn : ¬(IsLarge U r c (receiver s t) ∧ j = s.2) := by + rintro ⟨hl, rfl⟩ + exact hj t.1 hl + rw [ite_eq_right hn,h] + omega + have hcap (w) : (repair U r c s t X).x w ≤ U := by + by_cases hw : IsLarge U r c w + · rw [hsup w hw]; positivity + · have hw' : ¬(U ≤ r w.1 ∧ U ≤ c w.2) := hw + have h1 := coordinate_le_rowSum _ hnn w + have h2 := coordinate_le_colSum _ hnn w + have h3 := (hr w.1).1 + have h4 := (hc w.2).1 + change colSum (repair U r c s t X).x w.2 ≤ c w.2 at h4 + omega + exact ⟨fun w => ⟨hnn w,hcap w,hnn w,hcap w⟩, + fun w hw => ⟨hsup w hw,hsup w hw⟩,hr,hc⟩ + + +theorem repair_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X Y : State m n) + (hX : DefectAt U r c s t X) (hY : DefectAt U r c s t Y) + (he : repair U r c s t X = repair U r c s t Y) : X = Y := by + have hx : X.x = Y.x := by + funext w + have h := congrArg (fun Z : State m n => Z.x w) he + dsimp [repair] at h + linarith + have hq : X.q = Y.q := by rw [hX.2.2.2,hY.2.2.2,hx] + cases X; cases Y + simp_all + + + +def Before (s t : Cell m n) : Prop := s.1 < t.1 ∨ s.1 = t.1 ∧ s.2 < t.2 + +theorem before_ne (s t : Cell m n) (h : Before s t) : s ≠ t := by + intro he + subst t + rcases h with h | h + · exact (lt_irrefl _ h) + · exact (lt_irrefl _ h.2) + +theorem before_trans (s t v : Cell m n) (hst : Before s t) (htv : Before t v) : Before s v := by + rcases hst with hst | ⟨hst,hst'⟩ <;> rcases htv with htv | ⟨htv,htv'⟩ + · exact Or.inl (lt_trans hst htv) + · exact Or.inl (htv ▸ hst) + · exact Or.inl (hst ▸ htv) + · exact Or.inr ⟨hst.trans htv,lt_trans hst' htv'⟩ + +theorem receiver_order (s t : Cell m n) (hst : Before s t) : + receiver s t = s ∨ Before s (receiver s t) := by + rcases hst with hst | ⟨hst,_⟩ + · exact Or.inr (Or.inl hst) + · exact Or.inl (Prod.ext hst.symm rfl) + +theorem repair_prefix (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) + (hst : Before s t) (w : Cell m n) (hws : Before w s) : + (repair U r c s t X).x w = X.x w ∧ (repair U r c s t X).q w = X.q w := by + have hwt := before_ne w t (before_trans w s t hws hst) + have hws' := before_ne w s hws + have hwv : w ≠ receiver s t := by + rcases receiver_order s t hst with he | he + · rwa [he] + · exact before_ne w _ (before_trans w s _ hws he) + constructor + · simp [repair,unit,hwt,hwv] + · rw [repair_q_identity U r c s t X hd] + simp [unit,hws',hwv] + +theorem repair_special (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) (l : ℤ) + (hl : X.x s = l-1) : + (repair U r c s t X).x s = if t.1 = s.1 then l else l-1 := by + have hst := hd.2.2.1 + by_cases hi : t.1=s.1 + · have hv : receiver s t = s := Prod.ext hi rfl + simp [repair,unit,hst,hi,hv,hd.1,hl] + · have hv : s ≠ receiver s t := by + intro he + exact hi (congrArg Prod.fst he).symm + simp [repair,unit,hst,hi,hv,hl] + +end PaddedGraph +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/DenseRegularity.lean b/lean/OAI/Probability/Contingency/DenseRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..c141e2c70556c66b01c2625e8f6f5c06f8c79445 --- /dev/null +++ b/lean/OAI/Probability/Contingency/DenseRegularity.lean @@ -0,0 +1,693 @@ +import Mathlib +import OAI.Probability.Contingency.LawComposition + +namespace OAI + +/-! Dense Regularity. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +variable {a c : ℕ} + +theorem scaled_affine (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (u v : Fin a×Fin c → ℝ) (α β : ℝ) (hab : α+β=1) + (i : Fin (a+1)) (j : Fin (c+1)) : + scaled R P w (α • u+β • v) i j=α*scaled R P w u i j+β*scaled R P w v i j := by + have hs (i j) : w i j*(α*u (i,j)+β*v (i,j))=α*(w i j*u (i,j))+β*(w i j*v (i,j)) := by ring + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j + all_goals simp only [scaled,complete_corner,complete_bottom,complete_right,complete_free, + Pi.add_apply,Pi.smul_apply,smul_eq_mul,hs,Finset.sum_add_distrib,← Finset.mul_sum] + all_goals have hb : β=1-α := by linarith only [hab] + all_goals rw [hb]; ring + +theorem normalized_affine (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (u v : Fin a×Fin c → ℝ) (α β : ℝ) (hab : α+β=1) + (i : Fin (a+1)) (j : Fin (c+1)) : + normalized R P w (α • u+β • v) i j=α*normalized R P w u i j+β*normalized R P w v i j := by + simp only [normalized,scaled_affine R P w u v α β hab] + ring + +theorem polytope_convex (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) : + Convex ℝ (polytope R P w) := by + intro u hu v hv α β hα hβ hab i j + rw [normalized_affine R P w u v α β hab] + exact add_nonneg (mul_nonneg hα (hu i j)) (mul_nonneg hβ (hv i j)) + + + +def coefficient (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (i : Fin (a+1)) (j : Fin (c+1)) (k : Fin a) (l : Fin c) : ℝ := + Fin.lastCases + (Fin.lastCases (w k l/scale R P (Fin.last a) (Fin.last c)) + (fun j => if l=j then -(w k l/scale R P (Fin.last a) j.castSucc) else 0) j) + (fun i => Fin.lastCases (if k=i then -(w k l/scale R P i.castSucc (Fin.last c)) else 0) + (fun j => if k=i ∧ l=j then w k l/scale R P i.castSucc j.castSucc else 0) j) i + +theorem normalized_difference (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (u v : Fin a×Fin c → ℝ) (i : Fin (a+1)) (j : Fin (c+1)) : + normalized R P w u i j-normalized R P w v i j= + ∑ k,∑ l,coefficient R P w i j k l*(u (k,l)-v (k,l)) := by + refine Fin.lastCases ?_ (fun i => ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j + all_goals simp only [normalized,scaled,complete_corner,complete_bottom,complete_right, + complete_free,coefficient,Fin.lastCases_last,Fin.lastCases_castSucc] + · simp only [div_mul_eq_mul_div,mul_sub,Finset.sum_sub_distrib,← Finset.sum_div] + ring + · simp only [ite_mul,zero_mul,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + simp only [neg_mul,div_mul_eq_mul_div,mul_sub,Finset.sum_sub_distrib,← Finset.sum_div,Finset.sum_neg_distrib] + ring + · simp only [ite_mul,zero_mul,Finset.sum_ite_irrel,Finset.sum_const_zero,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + simp only [neg_mul,div_mul_eq_mul_div,mul_sub,Finset.sum_sub_distrib,← Finset.sum_div,Finset.sum_neg_distrib] + ring + · simp only [ite_and,ite_mul,zero_mul,Finset.sum_ite_irrel,Finset.sum_const_zero, + Finset.sum_ite_eq',Finset.mem_univ,ite_true] + ring + +theorem normalized_width_bound (w s t B : ℝ) (hw0 : 0 ≤ w) (hB : 0 ?_) i <;> + refine Fin.lastCases ?_ (fun j => ?_) j + all_goals simp only [coefficient,Fin.lastCases_last,Fin.lastCases_castSucc] + · exact hbase _ _ (min_le_min (hRmax _) (hPmax _)) + · split_ifs with h + · subst l; rw [abs_neg]; exact hbase _ _ (min_le_min_right _ (hRmax _)) + · simp only [abs_zero]; positivity + · split_ifs with h + · subst k; rw [abs_neg]; exact hbase _ _ (min_le_min_left _ (hPmax _)) + · simp only [abs_zero]; positivity + · split_ifs with h + · rcases h with ⟨rfl,rfl⟩; exact hbase _ _ le_rfl + · simp only [abs_zero]; positivity + + + +theorem normalized_lipschitz (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (hB : 0 Finset.abs_sum_le_sum_abs _ _) + _ ≤ ∑ k : Fin a,∑ l : Fin c,(1/B)*‖u-v‖ := by + apply Finset.sum_le_sum; intro k _ + apply Finset.sum_le_sum; intro l _ + rw [abs_mul] + apply mul_le_mul (coefficient_bound R P w B hB hR hP hRmax hPmax hw0 hw i j k l) + · simpa only [Real.norm_eq_abs,Pi.sub_apply] using norm_le_pi_norm (u-v) (k,l) + · exact abs_nonneg _ + · positivity + _ = (a*c:ℕ)/B*‖u-v‖ := by simp; ring + _ ≤ d/B*‖u-v‖ := mul_le_mul_of_nonneg_right (div_le_div_of_nonneg_right he hB.le) (norm_nonneg _) + +end +end Contingency.Dense + + + + + +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +variable {a c : ℕ} + + +def penalty (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (u : Fin a×Fin c → ℝ) : ℝ := + max 0 (Finset.univ.sup' Finset.univ_nonempty fun s : Fin (a+1)×Fin (c+1) => + -normalized R P w u s.1 s.2-d/B) + +theorem penalty_nonneg (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (u : Fin a×Fin c → ℝ) : + 0 ≤ penalty R P w B d u := le_max_left _ _ + +theorem le_penalty (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (u : Fin a×Fin c → ℝ) (i j) : + -normalized R P w u i j-d/B ≤ penalty R P w B d u := by + exact (Finset.le_sup' (fun s : Fin (a+1)×Fin (c+1) => + -normalized R P w u s.1 s.2-d/B) (Finset.mem_univ (i,j))).trans (le_max_right _ _) + +theorem penalty_le_iff (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (u : Fin a×Fin c → ℝ) (z : ℝ) : + penalty R P w B d u ≤ z ↔ 0 ≤ z ∧ ∀ i j,-normalized R P w u i j-d/B ≤ z := by + simp only [penalty,max_le_iff,Finset.sup'_le_iff,Finset.mem_univ,forall_const] + exact and_congr_right (fun _ => ⟨fun h i j => h (i,j),fun h s => h s.1 s.2⟩) + +theorem penalty_convex (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) : ConvexOn ℝ Set.univ (penalty R P w B d) := by + refine ⟨convex_univ,?_⟩ + intro u _ v _ α β ha hb hab + rw [smul_eq_mul,smul_eq_mul,penalty_le_iff] + constructor + · exact add_nonneg (mul_nonneg ha (penalty_nonneg _ _ _ _ _ _)) + (mul_nonneg hb (penalty_nonneg _ _ _ _ _ _)) + · intro i j + rw [normalized_affine R P w u v α β hab] + have h1 := mul_le_mul_of_nonneg_left (le_penalty R P w B d u i j) ha + have h2 := mul_le_mul_of_nonneg_left (le_penalty R P w B d v i j) hb + have h3 := congrArg (fun t : ℝ => t*(d/B)) hab + nlinarith only [h1,h2,h3] + +theorem penalty_zero_of_slack (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d : ℝ) (u : Fin a×Fin c → ℝ) + (hu : ∀ i j,-d/B ≤ normalized R P w u i j) : penalty R P w B d u=0 := by + apply le_antisymm _ (penalty_nonneg _ _ _ _ _ _) + rw [penalty_le_iff] + exact ⟨le_rfl,fun i j => by have hh := hu i j; rw [neg_div] at hh; linarith only [hh]⟩ + +theorem penalty_difference (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d K : ℝ) (hK : 0 ≤ K) + (u v : Fin a×Fin c → ℝ) + (hv : ∀ i j,|normalized R P w u i j-normalized R P w v i j| ≤ K) : + |penalty R P w B d u-penalty R P w B d v| ≤ K := by + have h (u v : Fin a×Fin c → ℝ) + (hh : ∀ i j,normalized R P w v i j-normalized R P w u i j ≤ K) : + penalty R P w B d u ≤ penalty R P w B d v+K := by + rw [penalty_le_iff] + refine ⟨add_nonneg (penalty_nonneg _ _ _ _ _ _) hK,fun i j => ?_⟩ + linarith only [hh i j,le_penalty R P w B d v i j] + rw [abs_le] + constructor + · have hv' := h v u (fun i j => (abs_le.mp (hv i j)).2) + linarith only [hv'] + · have hu' := h u v (fun i j => by have := (abs_le.mp (hv i j)).1; linarith) + linarith only [hu'] + + + +def density (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d A : ℝ) (u : Fin a×Fin c → ℝ) : ℝ := + (2:ℝ)^(-A*penalty R P w B d u) + +theorem density_pos (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B d A : ℝ) (u : Fin a×Fin c → ℝ) : + 0 Ioo (B.lower i) (B.upper i) + +def boxUnion {q : ℕ} (S : Finset (OpenBox q)) : Set (Fin q → ℝ) := + ⋃ B∈S, B.carrier + + + +def FiniteBoxInterpolation : Prop := + ∀ (q : ℕ) (S₁ S₂ S₀ : Finset (OpenBox q)) (t : ℝ), 0 isOpen_Ioo + +theorem OpenBox.isBounded (B : OpenBox q) : Bornology.IsBounded B.carrier := by + exact (Bornology.isBounded_pi).mpr (Or.inr fun _ => Metric.isBounded_Ioo _ _) + +theorem boxUnion_isOpen (S : Finset (OpenBox q)) : IsOpen (boxUnion S) := + isOpen_iUnion fun B => isOpen_iUnion fun _ => B.isOpen + +theorem boxUnion_isBounded (S : Finset (OpenBox q)) : Bornology.IsBounded (boxUnion S) := by + classical + induction S using Finset.induction_on with + | empty => simp [boxUnion] + | @insert B S hB ih => + have he : boxUnion (insert B S)=B.carrier ∪ boxUnion S := by simp [boxUnion] + rw [he] + exact B.isBounded.union ih + +theorem boxUnion_measurable (S : Finset (OpenBox q)) : MeasurableSet (boxUnion S) := + (boxUnion_isOpen S).measurableSet + +theorem boxUnion_volume_finite (S : Finset (OpenBox q)) : volume (boxUnion S)<⊤ := + (boxUnion_isBounded S).measure_lt_top + +theorem boxUnion_volume_pos (S : Finset (OpenBox q)) (hS : (boxUnion S).Nonempty) : + 0 B.lower i.succ,fun i => B.upper i.succ⟩ + +def slices (S : Finset (OpenBox (q+1))) (x : ℝ) : Finset (OpenBox q) := by + classical + exact (S.filter (fun B => B.lower 0 {B.lower 0,B.upper 0} + +theorem lower_mem_endpoints (S : Finset (OpenBox (q+1))) (B : OpenBox (q+1)) (hB : B∈S) : + B.lower 0∈endpoints S := by + classical + simp only [endpoints,Finset.mem_biUnion,Finset.mem_insert,Finset.mem_singleton] + exact ⟨B,hB,Or.inl rfl⟩ + +theorem upper_mem_endpoints (S : Finset (OpenBox (q+1))) (B : OpenBox (q+1)) (hB : B∈S) : + B.upper 0∈endpoints S := by + classical + simp only [endpoints,Finset.mem_biUnion,Finset.mem_insert,Finset.mem_singleton] + exact ⟨B,hB,Or.inr rfl⟩ + + + +structure GoodWeight (q : ℕ) where + f : (Fin q → ℝ) → ℝ + continuous : Continuous f + positive : ∀ x,0 (F.positive x).le + +theorem integral_pos (F : GoodWeight q) (S : Finset (OpenBox q)) (hS : (boxUnion S).Nonempty) : + 0 < ∫ x in boxUnion S,F.f x := by + apply (integral_pos_iff_support_of_nonneg (fun x => (F.positive x).le) (F.integrable S)).mpr + have he : Function.support F.f=univ := by ext x; simp [Function.mem_support,(F.positive x).ne'] + rw [he,Measure.restrict_apply_univ] + exact boxUnion_volume_pos S hS + +def slice (F : GoodWeight (q+1)) (x : ℝ) : GoodWeight q := + ⟨fun y => F.f (Fin.cons x y),F.continuous.comp (continuous_const.finCons continuous_id), + fun point => F.positive (Fin.cons x point),F.bound,fun point => F.bounded (Fin.cons x point)⟩ + + + +theorem marginal_continuous (F : GoodWeight (q+1)) (S : Finset (OpenBox q)) : + Continuous (fun x : ℝ => ∫ y in boxUnion S,F.f (Fin.cons x y)) := by + apply continuous_of_dominated (bound := fun _ => F.bound) + · intro x + exact (F.slice x).continuous.aestronglyMeasurable + · intro x + exact Filter.Eventually.of_forall fun y => F.bounded _ + · exact integrableOn_const (boxUnion_volume_finite S).ne + · exact Filter.Eventually.of_forall fun y => + F.continuous.comp (by fun_prop) + +end GoodWeight +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory +namespace Contingency.Interpolation +noncomputable section +variable {q : ℕ} + + +def marginal (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) (x : ℝ) : ℝ := + ∫ y in boxUnion (slices S x),F.f (Fin.cons x y) + +theorem marginal_nonneg (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) (x : ℝ) : + 0 ≤ marginal S F x := (F.slice x).integral_nonneg _ + + +theorem marginal_fubini (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) : + Integrable (marginal S F) ∧ (∫ x,marginal S F x)=∫ z in boxUnion S,F.f z := by + classical + let e : ℝ × (Fin q → ℝ) ≃ᵐ (Fin (q+1) → ℝ) := + (MeasurableEquiv.piFinSuccAbove (fun _ => ℝ) 0).symm + have hp : MeasurePreserving e := (volume_preserving_piFinSuccAbove (fun _ : Fin (q+1) => ℝ) 0).symm _ + have he (p : ℝ × (Fin q → ℝ)) : e p=Fin.cons p.1 p.2 := by + simp [e,MeasurableEquiv.piFinSuccAbove_symm_apply,Fin.insertNthEquiv] + let I := (boxUnion S).indicator F.f + have hi : Integrable I := (F.integrable S).integrable_indicator (boxUnion_measurable S) + have hpull : Integrable (fun p : ℝ × (Fin q → ℝ) => I (Fin.cons p.1 p.2)) (volume.prod volume) := by + simpa only [Function.comp_def,he,Measure.volume_eq_prod] using (hp.integrable_comp_emb e.measurableEmbedding).mpr hi + have hind (x : ℝ) : (fun y => I (Fin.cons x y))= + (boxUnion (slices S x)).indicator (fun y => F.f (Fin.cons x y)) := by + funext y + by_cases hy : y∈boxUnion (slices S x) + · simp only [I,Set.indicator_of_mem hy,Set.indicator_of_mem ((mem_slices S x y).mp hy)] + · simp only [I,Set.indicator_of_notMem hy,Set.indicator_of_notMem (mt (mem_slices S x y).mpr hy)] + have hm (x : ℝ) : (∫ y,I (Fin.cons x y))=marginal S F x := by + rw [hind x,integral_indicator (boxUnion_measurable _)]; rfl + refine ⟨?_,?_⟩ + · simpa only [hm] using hpull.integral_prod_left + · have hprod := integral_prod (fun p : ℝ × (Fin q → ℝ) => I (Fin.cons p.1 p.2)) hpull + simp only [hm] at hprod + rw [← hprod] + have heq := hp.integral_comp' I + simp only [he,Measure.volume_eq_prod] at heq + rw [heq,integral_indicator (boxUnion_measurable S)] + +end +end Contingency.Interpolation + + + + + +open Set +namespace Contingency.Interpolation +noncomputable section + + + +def nextEndpoint (E : Finset ℝ) (x : ℝ) : ℝ := + if h : (E.filter (x < ·)).Nonempty then (E.filter (x < ·)).min' h else x + +theorem nextEndpoint_le (E : Finset ℝ) (x y : ℝ) (hy : y∈E) (hxy : x constructor <;> constructor <;> intro h <;> linarith + + + +theorem grid_covers (E : Finset ℝ) (x a b : ℝ) (ha : a∈E) (hb : b∈E) + (hax : a ?_⟩ + obtain ⟨hyq,heq⟩ := hq y hy + have hcont : ContinuousAt Q y := by + apply hmono.continuousAt_of_image_mem_nhds (isOpen_Ioo.mem_nhds hy) + rw [himage] + exact isOpen_Ioo.mem_nhds hyq + refine ⟨heq,hyq,?_⟩ + apply (hd _ hyq).of_local_left_inverse hcont (hp _ hyq).ne' + filter_upwards [isOpen_Ioo.mem_nhds hy] with z hz + exact (hq z hz).2 + + + +theorem positive_quantile (F : ℝ → ℝ) (a b : ℝ) (hab : a (hp x (Ioc_subset_Icc_self hx)).le) ⟨a,left_mem_Icc.mpr hab.le,hp a (left_mem_Icc.mpr hab.le)⟩ + let C := fun x => (∫ t in a..x,F t)/M + have hi : IntervalIntegrable F volume a b := hc.intervalIntegrable_of_Icc hab.le + have hci : ContinuousOn (fun x => ∫ t in a..x,F t) (Icc a b) := by + simpa only [uIcc_of_le hab.le] using intervalIntegral.continuousOn_primitive_interval' hi (left_mem_uIcc : a∈uIcc a b) + have hC : ContinuousOn C (Icc a b) := hci.div_const M + have hmono : StrictMonoOn C (Icc a b) := by + intro x hx y hy hxy + apply (div_lt_div_iff_of_pos_right hM).mpr + have hxint : IntervalIntegrable F volume a x := hi.mono_set (by + simp only [uIcc_of_le hab.le,uIcc_of_le hx.1]; exact Icc_subset_Icc le_rfl hx.2) + have hyint : IntervalIntegrable F volume x y := hi.mono_set (by + simp only [uIcc_of_le hab.le,uIcc_of_le hxy.le]; exact Icc_subset_Icc hx.1 hy.2) + have he := intervalIntegral.integral_add_adjacent_intervals hxint hyint + have hpos : 0<∫ t in x..y,F t := intervalIntegral.integral_pos hxy + (hc.mono (Icc_subset_Icc hx.1 hy.2)) + (fun z hz => (hp z ⟨hx.1.trans hz.1.le,hz.2.trans hy.2⟩).le) + ⟨x,left_mem_Icc.mpr hxy.le,hp x hx⟩ + linarith only [he,hpos] + have hder (x) (hx : x∈Ioo a b) : HasDerivAt C (F x/M) x := by + have hint : IntervalIntegrable F volume a x := hi.mono_set (by + simp only [uIcc_of_le hab.le,uIcc_of_le hx.1.le]; exact Icc_subset_Icc le_rfl hx.2.le) + have hfc : ContinuousAt F x := hc.continuousAt (Icc_mem_nhds hx.1 hx.2) + apply HasDerivAt.div_const + exact intervalIntegral.integral_hasDerivAt_right hint + (ContinuousOn.stronglyMeasurableAtFilter isOpen_Ioo (hc.mono Ioo_subset_Icc_self) x hx) hfc + have hCa : C a=0 := by simp [C] + have hCb : C b=1 := by simp [C,M,hM.ne'] + obtain ⟨Q,hqm,hqi,hqd⟩ := interval_inverse C (fun x => F x/M) a b hab hC hmono hder + (fun x hx => div_pos (hp x (Ioo_subset_Icc_self hx)) hM) + rw [hCa,hCb] at hqm hqi hqd + refine ⟨hM,Q,hqm,hqi,fun y hy => ?_⟩ + have hh := hqd y hy + refine ⟨hh.2.1,?_⟩ + simpa only [inv_div] using hh.2.2 + + + +theorem transport_amgm (M N F G α β : ℝ) (hM : 0 j < i), m j + +def totalMass (m : Fin n → ℝ) : ℝ := ∑ i,m i + +theorem prefix_nonneg (m : Fin n → ℝ) (hm : ∀ i,0 ≤ m i) (i : Fin n) : + 0 ≤ prefixMass m i := Finset.sum_nonneg fun j _ => hm j + +theorem prefix_next_le (m : Fin n → ℝ) (hm : ∀ i,0 ≤ m i) (i j : Fin n) (hij : i k < i),m k := by + rw [Finset.sum_insert (by simp)] + simp only [prefixMass]; ring + rw [he] + apply Finset.sum_le_sum_of_subset_of_nonneg + · intro k hk + rcases Finset.mem_insert.mp hk with rfl|hk + · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hij⟩ + · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp hk).2.trans hij⟩ + · intro k _ _; exact hm k + +theorem prefix_add_le_total (m : Fin n → ℝ) (hm : ∀ i,0 ≤ m i) (i : Fin n) : + prefixMass m i+m i ≤ totalMass m := by + classical + have he : prefixMass m i+m i=∑ k ∈ insert i (Finset.univ.filter fun k => k < i),m k := by + rw [Finset.sum_insert (by simp)] + simp only [prefixMass]; ring + rw [he] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun k _ _ => hm k) + +def probabilityPiece (m : Fin n → ℝ) (i : Fin n) : Set ℝ := + Ioo (prefixMass m i/totalMass m) ((prefixMass m i+m i)/totalMass m) + +theorem probabilityPiece_subset (m : Fin n → ℝ) (hm : ∀ i,0 ≤ m i) + (hM : 0 Disjoint (probabilityPiece m i) (probabilityPiece m j)) := by + intro i j hij + rcases lt_or_gt_of_ne hij with hij|hij + · apply disjoint_left.mpr + intro t ht1 ht2 + have hh := div_le_div_of_nonneg_right (prefix_next_le m hm i j hij) hM.le + exact not_lt_of_ge (ht1.2.le.trans hh) ht2.1 + · apply disjoint_left.mpr + intro t ht1 ht2 + have hh := div_le_div_of_nonneg_right (prefix_next_le m hm j i hij) hM.le + exact not_lt_of_ge (ht2.2.le.trans hh) ht1.1 + + + +theorem probabilityPieces_volume (m : Fin n → ℝ) (hm : ∀ i,0 ≤ m i) + (hM : 0 measurableSet_Ioo)] + simp only [tsum_fintype,probabilityPiece,Real.volume_Ioo] + have he (i) : (prefixMass m i+m i)/totalMass m-prefixMass m i/totalMass m=m i/totalMass m := by ring + simp only [he] + rw [← ENNReal.ofReal_sum_of_nonneg (fun i _ => div_nonneg (hm i) hM.le),← Finset.sum_div] + change ENNReal.ofReal (totalMass m / totalMass m) = 1 + rw [div_self hM.ne', ENNReal.ofReal_one] + +end +end Contingency.Interpolation + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/DenseWeightBounds.lean b/lean/OAI/Probability/Contingency/DenseWeightBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4a793025051bab78cd0c6dc631aaa0511ae07da --- /dev/null +++ b/lean/OAI/Probability/Contingency/DenseWeightBounds.lean @@ -0,0 +1,683 @@ +import Mathlib +import OAI.Probability.Contingency.AcceptedChain + +namespace OAI + +/-! Dense Weight Bounds. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.Dense.BinProblem +noncomputable section +open Contingency.Grid Contingency.Interpolation Contingency.FiniteChain +variable {a c q K : ℕ} (D : BinProblem a c q K) + +theorem corner_penalty_bound (hK : (K:ℝ)=4*D.d^8) (v : Vertex q K) : + penalty (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths (D.d^8) D.d + (fun s => realCorner v (D.e.symm s)) ≤ 4*D.d := by + have hd : 0 (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths u i j := + (by positivity : (0:ℝ)≤1/(2*D.d)).trans (hu i j) + have hb := polytope_bounded _ _ D.widths (D.d^8) (by positivity) hr hp heq D.widthlo u hu0 + have hnorm : ‖(fun s => realCorner v (D.e.symm s))-u‖ ≤ K := by + apply (pi_norm_le_iff_of_nonneg (Nat.cast_nonneg K)).mpr + intro s + have hv0 : (0:ℝ)≤realCorner v (D.e.symm s) := Nat.cast_nonneg _ + have hvK : realCorner v (D.e.symm s) ≤ K := by + change ((v (D.e.symm s)).val:ℝ)≤K + exact_mod_cast (v (D.e.symm s)).isLt.le + have hbu := hb s + have hhalf : 2*D.d^8 ≤ (K:ℝ) := by rw [hK]; nlinarith [show 0≤D.d^8 by positivity] + simp only [Pi.sub_apply,Real.norm_eq_abs] + rw [abs_le] + constructor <;> linarith [hbu.1,hbu.2] + have hz : penalty (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths (D.d^8) D.d u=0 := + penalty_zero_of_slack _ _ _ _ _ _ (fun i j => + (div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hd.le) (show 0≤D.d^8 by positivity)).trans (hu0 i j)) + have hdiff := penalty_difference (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths (D.d^8) D.d + (D.d/D.d^8*‖(fun s => realCorner v (D.e.symm s))-u‖) (by positivity) + (fun s => realCorner v (D.e.symm s)) u + (fun i j => normalized_lipschitz _ _ _ _ _ (by positivity) D.dim hr hp + (fun i => by exact_mod_cast D.hRmax i) (fun j => by exact_mod_cast D.hPmax j) + (fun i j => (hw i j).le) D.widthhi _ _ i j) + rw [hz,sub_zero,abs_of_nonneg (penalty_nonneg _ _ _ _ _ _)] at hdiff + calc + _ ≤ _ := hdiff + _ ≤ D.d/D.d^8*K := mul_le_mul_of_nonneg_left hnorm (by positivity) + _ = 4*D.d := by rw [hK]; field_simp + +theorem weight_upper (v : Vertex q K) : D.weight v ≤ 1 := by + change (2:ℝ)^(-(⌊binExponent D.e _ _ D.widths D.d (realCorner v)⌋:ℝ))≤1 + apply Real.rpow_le_one_of_one_le_of_nonpos (by norm_num) + apply neg_nonpos.mpr + exact_mod_cast Int.floor_nonneg.mpr (mul_nonneg (by positivity) (penalty_nonneg _ _ _ _ _ _)) + +theorem weight_lower (hK : (K:ℝ)=4*D.d^8) (v : Vertex q K) : + (2:ℝ)^(-(4*D.d^5)) ≤ D.weight v := by + change _≤(2:ℝ)^(-(⌊binExponent D.e _ _ D.widths D.d (realCorner v)⌋:ℝ)) + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + have hh := Int.floor_le (binExponent D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths D.d (realCorner v)) + have hb := mul_le_mul_of_nonneg_left (D.corner_penalty_bound hK v) (show 0≤D.d^4 by positivity) + unfold binExponent at hh ⊢ + nlinarith only [hh,hb] + +theorem normalizer_upper : D.Z ≤ (K:ℝ)^q := by + calc + _ ≤ ∑ v : Vertex q K,(1:ℝ) := Finset.sum_le_sum fun v _ => D.weight_upper v + _ = _ := by simp [Vertex] + +theorem stationary_lower (hK : (K:ℝ)=4*D.d^8) (p : ℝ) (hp0 : 0 ≤ p) (hp : p ≤ 1/(8*D.d)) + (v : Vertex q K) : (2:ℝ)^(-(4*D.d^5))/(K:ℝ)^q ≤ (D.chain p hp0 hp).π v := by + change _ ≤ D.weight v/D.Z + exact div_le_div₀ (Real.rpow_nonneg (by norm_num) _) (D.weight_lower hK v) D.Zpos D.normalizer_upper + +end +end Contingency.Dense.BinProblem + + + + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +noncomputable section +open Contingency.Grid Contingency.FiniteChain +variable {a c q K : ℕ} (D : BinProblem a c q K) + +def inverseGap : ℝ := 2/D.kappa^2 + +theorem inverseGap_eq (hK : (K:ℝ)=4*D.d^8) : D.inverseGap=320000000000*D.d^20 := by + have hd : D.d≠0 := by linarith [D.hd] + unfold inverseGap kappa + rw [hK] + field_simp + ring + +theorem inverseGap_bounds (hd : 14 ≤ D.d) (hK : (K:ℝ)=4*D.d^8) : + 1 ≤ D.inverseGap ∧ D.inverseGap ≤ D.d^32 := by + rw [D.inverseGap_eq hK] + have h1 : 1 ≤ D.d^20 := one_le_pow₀ (by linarith) + have h12 : 320000000000 ≤ D.d^12 := by + have hh := pow_le_pow_left₀ (by norm_num : (0:ℝ)≤14) hd 12 + norm_num at hh + linarith only [hh] + constructor + · linarith only [h1] + · have hh := mul_le_mul_of_nonneg_right h12 (show 0 ≤ D.d^20 by positivity) + calc + _ ≤ D.d^12*D.d^20 := hh + _ = _ := by ring + +theorem log_stationary_bound (hd : 14 ≤ D.d) (hK : (K:ℝ)=4*D.d^8) : + 4*D.d^5*Real.log 2+(q:ℝ)*Real.log K ≤ 4*D.d^5 := by + have hd0 : 0 (C.positive x).le,C.normalized⟩ +def transition (x : V) : Law V := ⟨C.P x,C.nonneg x,C.stochastic x⟩ +def walk (x : V) : ℕ → Law V + | 0 => Law.pure x + | n+1 => (walk x n).bind C.transition + +theorem walk_mass [DecidableEq V] (x y : V) (n : ℕ) : + (C.walk x n).mass y=C.law n x y := by + induction n generalizing y with + | zero => by_cases h : x=y <;> simp [walk,Law.pure,law,h] + | succ n ih => + simp only [walk,Law.bind,transition,law] + apply Finset.sum_congr rfl; intro z _ + rw [ih] + +theorem walk_tv [DecidableEq V] (x : V) (n : ℕ) : + (C.walk x n).tv C.invariant=C.tv n x := by + simp only [Law.tv,walk_mass,invariant,tv] + +end +end Contingency.FiniteChain.Chain + + + + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +noncomputable section +open Contingency.Grid Contingency.FiniteChain +variable {a c q K : ℕ} (D : BinProblem a c q K) + +local instance tableFintype (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) : Fintype (Tables R P) := Fintype.ofFinite _ +local instance tableNonempty : Nonempty (Tables D.R D.P) := tables_nonempty D.R D.P D.heq +local instance offsetNonempty : Nonempty (Offsets D.w) := ⟨fun i => ⟨0,D.hw i⟩⟩ + +def idealSamples : Law (Sample (K:=K) D.w) := ⟨D.sampleMass,D.sampleMass_nonneg,D.sampleMass_total⟩ + +def decode (s : Sample (K:=K) D.w) : Option (Tables D.R D.P) := by + classical + exact if hs : D.good s then some ((acceptedEquiv D.e D.w D.hw D.heq D.bound) ⟨s,hs⟩) else none + +theorem decode_eq_some (s : Sample (K:=K) D.w) (X : Tables D.R D.P) : + D.decode s=some X ↔ s=D.tableSample X := by + classical + unfold decode + split_ifs with hs + · rw [Option.some.injEq] + constructor + · intro h + have hh := congrArg (acceptedEquiv D.e D.w D.hw D.heq D.bound).symm h + rw [Equiv.symm_apply_apply] at hh + exact congrArg Subtype.val hh + · intro h + subst s + exact (acceptedEquiv D.e D.w D.hw D.heq D.bound).apply_symm_apply X + · simp only [false_iff] + intro h + subst s + exact hs (encodeSample_accepted D.e D.w D.hw D.bound X) + +def idealTrial : Law (Option (Tables D.R D.P)) := D.idealSamples.map D.decode + +theorem idealTrial_some (X : Tables D.R D.P) : + D.idealTrial.mass (some X)=D.sampleMass (D.tableSample X) := by + classical + simp only [idealTrial,Law.map,Law.bind,Law.pure,mul_ite,mul_one,mul_zero,D.decode_eq_some] + simp [idealSamples] + +theorem idealTrial_none : D.idealTrial.mass none=1-D.success := by + have ht := D.idealTrial.total + rw [Fintype.sum_option] at ht + have he : (∑ X : Tables D.R D.P,D.idealTrial.mass (some X))=D.success := by + simp only [D.idealTrial_some,D.table_mass,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,D.success_eq_card] + rw [Nat.card_eq_fintype_card] + ring + rw [he] at ht + linarith + +theorem idealTrial_uniform (X : Tables D.R D.P) : + D.idealTrial.mass (some X)=(1-D.idealTrial.mass none)*(Law.uniform (Tables D.R D.P)).mass X := by + rw [D.idealTrial_some,D.idealTrial_none] + have h := D.conditional_uniform X + have hs : D.success≠0 := ne_of_gt (lt_of_lt_of_le (by norm_num) D.success_lower) + rw [div_eq_iff hs] at h + simp only [Law.uniform,Nat.card_eq_fintype_card] at h ⊢ + linarith + + +def implementedOffsets (h d : ℕ) : Law (Offsets D.w) := + Law.pi (fun i => (offsetLaw (D.w i) (D.hw i) (Nat.clog 2 (D.w i+1)+4*(h+d))).toLaw) + +def uniformOffsets : Law (Offsets D.w) := + Law.pi (fun i => @Law.uniform (Fin (D.w i)) inferInstance ⟨⟨0,D.hw i⟩⟩) + +theorem offset_tv (h d : ℕ) : + (D.implementedOffsets h d).tv D.uniformOffsets ≤ (q:ℝ)*(2:ℝ)^(-((4*(h+d):ℕ):ℤ)) := by + apply (Law.tv_pi _ _).trans + calc + _ ≤ ∑ _ : Fin q,(2:ℝ)^(-((4*(h+d):ℕ):ℤ)) := + Finset.sum_le_sum fun i _ => rounded_offset_accuracy (D.w i) h d (D.hw i) + _ = _ := by simp + +theorem uniformOffsets_mass (β : Offsets D.w) : D.uniformOffsets.mass β=1/(D.offsetCount:ℝ) := by + simp only [uniformOffsets,Law.pi,Law.uniform,Fintype.card_fin,one_div] + have he : (∏ i,(D.w i:ℝ))=(D.offsetCount:ℝ) := by + simp only [offsetCount,Offsets] + rw [Fintype.card_pi,Nat.cast_prod] + simp only [Fintype.card_fin] + rw [Finset.prod_inv_distrib,he] + +theorem idealSamples_prod (p : ℝ) (hp0 : 0≤p) (hp : p≤1/(8*D.d)) : + D.idealSamples=(D.chain p hp0 hp).invariant.prod D.uniformOffsets := by + apply Law.ext; funext s + simp only [idealSamples,sampleMass,Law.prod,D.uniformOffsets_mass,Chain.invariant,chain, + AcceptedData.chain,Grid.metropolis,AcceptedData.total] + change D.weight s.1/(D.Z*D.offsetCount)=D.weight s.1/D.Z*(1/D.offsetCount) + ring + + +def implementedTrial (p : ℝ) (hp0 : 0≤p) (hp : p≤1/(8*D.d)) (h d t : ℕ) : Law (Option (Tables D.R D.P)) := + (((D.chain p hp0 hp).walk (fun _ => ⟨0,D.Kpos⟩) t).prod (D.implementedOffsets h d)).map D.decode + +end +end Contingency.Dense.BinProblem + + + + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +noncomputable section +open Contingency.Grid Contingency.FiniteChain +variable {a c q K : ℕ} (D : BinProblem a c q K) +attribute [local instance] tableFintype tableNonempty + + +theorem implementedTrial_tv (d : ℕ) (hd : 14≤d) (hD : D.d=d) (hK : (K:ℝ)=4*D.d^8) + (p : ℝ) (hp0 : 0≤p) (hp : p≤1/(8*D.d)) (hplo : 1/(16*D.d)≤p) + (h : ℕ) (hh : 1≤h) : + (D.implementedTrial p hp0 hp h d (d^50*(h+1)^2)).tv D.idealTrial ≤ + (1+(d:ℝ))*(2:ℝ)^(-((4*(h+d):ℕ):ℤ)) := by + have he : (2:ℝ)^(-4*((h:ℝ)+D.d))=(2:ℝ)^(-((4*(h+d):ℕ):ℤ)) := by + rw [← Real.rpow_intCast] + push_cast + rw [hD] + congr 1 + ring + have hc := D.scheduled_mixing (by rw [hD]; exact_mod_cast hd) hK p hp0 hp hplo h + (d^50*(h+1)^2) hh (by rw [hD]; push_cast; rfl) (fun _ => ⟨0,D.Kpos⟩) + rw [he,← Chain.walk_tv] at hc + have ho := D.offset_tv h d + have hf := Law.tv_prod ((D.chain p hp0 hp).walk (fun _ => ⟨0,D.Kpos⟩) (d^50*(h+1)^2)) + (D.chain p hp0 hp).invariant (D.implementedOffsets h d) D.uniformOffsets + have hm := Law.tv_map D.decode + (((D.chain p hp0 hp).walk (fun _ => ⟨0,D.Kpos⟩) (d^50*(h+1)^2)).prod (D.implementedOffsets h d)) + ((D.chain p hp0 hp).invariant.prod D.uniformOffsets) + rw [← D.idealSamples_prod] at hm hf + have hq : (q:ℝ)≤d := by simpa only [hD] using D.hq + change (D.implementedTrial p hp0 hp h d (d^50*(h+1)^2)).tv D.idealTrial ≤ _ at hm + apply (hm.trans hf).trans + have hq' := mul_le_mul_of_nonneg_right hq (by positivity : (0:ℝ)≤(2:ℝ)^(-((4*(h+d):ℕ):ℤ))) + nlinarith only [hc,ho,hq'] + +end +end Contingency.Dense.BinProblem + + + + + +open scoped BigOperators +namespace Contingency + + +theorem square_le_two_pow (d : ℕ) (hd : 4≤d) : d^2≤2^d := by + obtain ⟨n,rfl⟩ := Nat.exists_eq_add_of_le hd + induction n with + | zero => norm_num + | succ n ih => + have h : (4+n+1)^2≤2*(4+n)^2 := by nlinarith + calc + (4+(n+1))^2 = (4+n+1)^2 := by congr 1 + _ ≤ 2*(4+n)^2 := h + _ ≤ 2*2^(4+n) := Nat.mul_le_mul_left 2 (ih (by omega)) + _ = 2^(4+(n+1)) := by rw [show 4+(n+1)=4+n+1 by omega,pow_succ]; omega + +theorem dense_schedule_offset (d h : ℕ) (hd : 14≤d) : + ((d^4*(h+1):ℕ):ℝ)*(1+(d:ℝ))*(2:ℝ)^(-((4*(h+d):ℕ):ℤ)) ≤ + (2:ℝ)^(-((h+2:ℕ):ℤ)) := by + have hd4 : d^4≤2^(2*d) := by + calc + d^4 = (d^2)^2 := by ring + _ ≤ (2^d)^2 := Nat.pow_le_pow_left (square_le_two_pow d (by omega)) 2 + _ = 2^(2*d) := by rw [← pow_mul]; congr 1; omega + have hh : h+1≤2^h := Nat.lt_two_pow_self (n:=h) + have hdp : d+1≤2^d := Nat.lt_two_pow_self (n:=d) + have hn : d^4*(h+1)*(d+1)≤2^(h+3*d) := by + calc + _ ≤ 2^(2*d)*2^h*2^d := Nat.mul_le_mul (Nat.mul_le_mul hd4 hh) hdp + _ = _ := by rw [← pow_add,← pow_add]; congr 1; omega + have hmul : d^4*(h+1)*(d+1)*2^(h+2)≤2^(4*(h+d)) := by + calc + _ ≤ 2^(h+3*d)*2^(h+2) := Nat.mul_le_mul_right _ hn + _ = 2^((h+3*d)+(h+2)) := by rw [← pow_add] + _ ≤ _ := Nat.pow_le_pow_right (by decide) (by omega) + have hr : (((d^4*(h+1):ℕ):ℝ)*(1+(d:ℝ)))*(2:ℝ)^(h+2)≤(2:ℝ)^(4*(h+d)) := by + have hc : ((d^4*(h+1)*(d+1):ℕ):ℝ)*(2:ℝ)^(h+2)≤(2:ℝ)^(4*(h+d)) := by exact_mod_cast hmul + push_cast at hc ⊢ + nlinarith only [hc] + rw [zpow_neg,zpow_natCast,zpow_neg,zpow_natCast] + rw [← div_eq_mul_inv,inv_eq_one_div] + apply (div_le_div_iff₀ (by positivity) (by positivity)).mpr + simpa only [one_mul] using hr + +theorem dense_schedule_failure (d h : ℕ) (hd : 14≤d) : + (63/64:ℝ)^(d^4*(h+1)) ≤ (2:ℝ)^(-((h+2:ℕ):ℤ)) := by + have hd4 : 128≤d^4 := by + have hh := Nat.pow_le_pow_left hd 4 + norm_num at hh + omega + have hJ : 64*(h+2)≤d^4*(h+1) := by nlinarith + calc + _ ≤ (63/64:ℝ)^(64*(h+2)) := pow_le_pow_of_le_one (by norm_num) (by norm_num) hJ + _ = ((63/64:ℝ)^64)^(h+2) := by rw [pow_mul] + _ ≤ (1/2:ℝ)^(h+2) := pow_le_pow_left₀ (by positivity) (by norm_num) (h+2) + _ = _ := by rw [one_div,inv_pow,zpow_neg,zpow_natCast] + +theorem dense_schedule_total (d h : ℕ) (hd : 14≤d) : + (63/64:ℝ)^(d^4*(h+1))+((d^4*(h+1):ℕ):ℝ)*(1+(d:ℝ))*(2:ℝ)^(-((4*(h+d):ℕ):ℤ)) ≤ + (2:ℝ)^(-(h:ℤ)) := by + have hf := dense_schedule_failure d h hd + have ho := dense_schedule_offset d h hd + have he : (2:ℝ)^(-((h+2:ℕ):ℤ))=(2:ℝ)^(-(h:ℤ))/4 := by + rw [zpow_neg,zpow_natCast,zpow_neg,zpow_natCast,pow_add] + norm_num + ring + rw [he] at hf ho + have hn : (0:ℝ)≤(2:ℝ)^(-(h:ℤ)) := by positivity + linarith + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.Dense.BinProblem +noncomputable section +open Contingency.Grid +variable {a c q K : ℕ} (D : BinProblem a c q K) +attribute [local instance] tableFintype tableNonempty + + +def draw (p : ℝ) (hp0 : 0≤p) (hp : p≤1/(8*D.d)) (h d : ℕ) + (fallback : Tables D.R D.P) : Law (Tables D.R D.P) := + Law.first (D.implementedTrial p hp0 hp h d (d^50*(h+1)^2)) fallback (d^4*(h+1)) + + +theorem draw_tv (d : ℕ) (hd : 14≤d) (hD : D.d=d) (hK : (K:ℝ)=4*D.d^8) + (p : ℝ) (hp0 : 0≤p) (hp : p≤1/(8*D.d)) (hplo : 1/(16*D.d)≤p) + (h : ℕ) (hh : 1≤h) (fallback : Tables D.R D.P) : + (D.draw p hp0 hp h d fallback).tv (Law.uniform (Tables D.R D.P)) ≤ (2:ℝ)^(-(h:ℤ)) := by + have ht := D.implementedTrial_tv d hd hD hK p hp0 hp hplo h hh + have hfirst := Law.first_tv (D.implementedTrial p hp0 hp h d (d^50*(h+1)^2)) D.idealTrial fallback (d^4*(h+1)) + have hideal := Law.first_ideal_tv D.idealTrial fallback (Law.uniform (Tables D.R D.P)) D.idealTrial_uniform (d^4*(h+1)) + have hfail : D.idealTrial.mass none≤63/64 := by rw [D.idealTrial_none]; linarith [D.success_lower] + have hf := pow_le_pow_left₀ (D.idealTrial.nonneg none) hfail (d^4*(h+1)) + have hm := mul_le_mul_of_nonneg_left ht (Nat.cast_nonneg (d^4*(h+1))) + have htri := Law.tv_triangle (D.draw p hp0 hp h d fallback) + (Law.first D.idealTrial fallback (d^4*(h+1))) (Law.uniform (Tables D.R D.P)) + change (D.draw p hp0 hp h d fallback).tv (Law.first D.idealTrial fallback (d^4*(h+1)))≤_ at hfirst + have htot := dense_schedule_total d h hd + nlinarith only [hfirst,hideal,hf,hm,htri,htot] + +end +end Contingency.Dense.BinProblem + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section + + +def acceptCount (B ex ey : ℕ) : ℕ := 2^(B-(ey-ex)) + +theorem acceptCount_le (B ex ey : ℕ) : acceptCount B ex ey≤2^B := + Nat.pow_le_pow_right (by decide) (Nat.sub_le _ _) + +def acceptCoin (B ex ey : ℕ) : DyadicLaw Bool where + bits := B + count b := if b then acceptCount B ex ey else 2^B-acceptCount B ex ey + total := by + simp only [Fintype.sum_bool,Bool.false_eq_true,ite_false,ite_true] + have := acceptCount_le B ex ey + omega + +theorem acceptCoin_true (B ex ey : ℕ) : + (acceptCoin B ex ey).toLaw.mass true=(acceptCount B ex ey:ℝ)/(2:ℝ)^B := rfl + + +theorem acceptCount_ratio (B ex ey : ℕ) (hey : ey≤B) : + (acceptCount B ex ey:ℝ)/(2:ℝ)^B=min (1/(2:ℝ)^ex) (1/(2:ℝ)^ey)/(1/(2:ℝ)^ex) := by + have he : ey-ex≤B := le_trans (Nat.sub_le _ _) hey + have hp : (2:ℝ)^B=(2:ℝ)^(B-(ey-ex))*(2:ℝ)^(ey-ex) := by + rw [← pow_add,Nat.sub_add_cancel he] + simp only [acceptCount,Nat.cast_pow,Nat.cast_ofNat] + rw [hp] + rcases le_total ex ey with h|h + · have hm : 1/(2:ℝ)^ey≤1/(2:ℝ)^ex := + one_div_le_one_div_of_le (by positivity) (pow_le_pow_right₀ (by norm_num) h) + rw [min_eq_right hm] + have hq : (2:ℝ)^ey=(2:ℝ)^ex*(2:ℝ)^(ey-ex) := by rw [← pow_add,Nat.add_sub_of_le h] + rw [hq] + field_simp + · have hm : 1/(2:ℝ)^ex≤1/(2:ℝ)^ey := + one_div_le_one_div_of_le (by positivity) (pow_le_pow_right₀ (by norm_num) h) + rw [min_eq_left hm,Nat.sub_eq_zero_of_le h] + simp + +namespace Law +variable {α : Type*} [Fintype α] [DecidableEq α] + +def accept (proposal : Law α) (coin : α → Law Bool) (x : α) : Law α := + proposal.bind (fun y => (coin y).map (fun b => if b then y else x)) + +theorem accept_offdiag (proposal : Law α) (coin : α → Law Bool) (x y : α) (h : x≠y) : + (proposal.accept coin x).mass y=proposal.mass y*(coin y).mass true := by + simp only [accept,bind,map,pure,Fintype.sum_bool,Bool.false_eq_true,ite_false,ite_true] + simp [h] + +theorem ext_offdiag (p r : Law α) (x : α) (h : ∀ y,x≠y → p.mass y=r.mass y) : p=r := by + apply Law.ext; funext y + by_cases he : x=y + · subst y + have hp := Finset.sum_erase_add Finset.univ p.mass (Finset.mem_univ x) + have hr := Finset.sum_erase_add Finset.univ r.mass (Finset.mem_univ x) + have hs : (∑ y∈Finset.univ.erase x,p.mass y)=∑ y∈Finset.univ.erase x,r.mass y := + Finset.sum_congr rfl fun y hy => h y (Ne.symm (Finset.mem_erase.mp hy).1) + rw [p.total] at hp + rw [r.total] at hr + linarith + · exact h y he +end Law + +namespace DyadicLaw +variable {α : Type*} [Fintype α] [DecidableEq α] + +def accept (proposal : DyadicLaw α) (e : α → ℕ) (B : ℕ) (x : α) : DyadicLaw α := + proposal.bind (fun y => (acceptCoin B (e x) (e y)).map (fun b => if b then y else x)) B + (fun y => by rw [map_bits]; rfl) + +theorem toLaw_accept (proposal : DyadicLaw α) (e : α → ℕ) (B : ℕ) (x : α) : + (proposal.accept e B x).toLaw=proposal.toLaw.accept (fun y => (acceptCoin B (e x) (e y)).toLaw) x := by + unfold accept + rw [toLaw_bind] + simp only [toLaw_map,Law.accept] +end DyadicLaw + +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace DyadicLaw +variable {α : Type*} [Fintype α] [DecidableEq α] + +def neighborProposal (E : α → α → Prop) [DecidableRel E] (x : α) (R : ℕ) + (_hirr : ¬E x x) (hb : (Finset.univ.filter (E x)).card≤2^R) : DyadicLaw α where + bits := R + count y := (if x=y then 2^R-(Finset.univ.filter (E x)).card else 0)+(if E x y then 1 else 0) + total := by + rw [Finset.sum_add_distrib] + have hs : (∑ y : α, if E x y then (1:ℕ) else 0) = (Finset.univ.filter (E x)).card := by + rw [← Finset.sum_filter] + simp + rw [hs] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] + omega + +theorem neighborProposal_offdiag (E : α → α → Prop) [DecidableRel E] (x : α) (R : ℕ) + (hirr : ¬E x x) (hb : (Finset.univ.filter (E x)).card≤2^R) (y : α) (h : x≠y) : + (neighborProposal E x R hirr hb).toLaw.mass y=(if E x y then 1 else 0)/(2:ℝ)^R := by + simp [neighborProposal,toLaw,h] + + +theorem accepted_neighbor_kernel (E : α → α → Prop) [DecidableRel E] + (e : α → ℕ) (B R : ℕ) (he : ∀ y,e y≤B) (x : α) + (hirr : ¬E x x) (hb : (Finset.univ.filter (E x)).card≤2^R) + (P : Law α) (hP : ∀ y,x≠y → P.mass y= + (1/(2:ℝ)^R)*(if E x y then min (1/(2:ℝ)^e x) (1/(2:ℝ)^e y) else 0)/(1/(2:ℝ)^e x)) : + ((neighborProposal E x R hirr hb).accept e B x).toLaw=P := by + rw [toLaw_accept] + apply Law.ext_offdiag _ _ x + intro y hxy + rw [Law.accept_offdiag _ _ _ _ hxy,neighborProposal_offdiag _ _ _ _ _ _ hxy, + acceptCoin_true,acceptCount_ratio _ _ _ (he y),hP y hxy] + by_cases h : E x y <;> simp [h] + ring + +end DyadicLaw +end +end Contingency + + + + + +namespace Contingency +noncomputable section + +def proposalRate (M : ℕ) : ℝ := 1/(2:ℝ)^Nat.clog 2 M + +theorem proposalRate_bounds (M : ℕ) (hM : 1 rw [show Nat.clog 2 M=Nat.clog 2 M-1+1 by omega,pow_succ] + exact Nat.mul_comm _ _ + have hle : 2^Nat.clog 2 M ≤ 2*M := by rw [he]; omega + unfold proposalRate + constructor + · apply one_div_le_one_div_of_le (by positivity) + exact_mod_cast hle + · apply one_div_le_one_div_of_le hM0 + exact_mod_cast hge + +theorem binProposal_bounds (d : ℕ) (hd : 1≤d) : + 1/(16*(d:ℝ)) ≤ proposalRate (8*d) ∧ proposalRate (8*d) ≤ 1/(8*(d:ℝ)) := by + have hh := proposalRate_bounds (8*d) (by omega) + push_cast at hh + simpa only [show (2:ℝ)*(8*d)=16*d by ring] using hh + +theorem smallProposal_bounds (d : ℕ) (hd : 1≤d) : + 1/(64*(d:ℝ)^2) ≤ proposalRate (32*d^2) ∧ proposalRate (32*d^2) ≤ 1/(32*(d:ℝ)^2) := by + have hd2 : 1≤d^2 := one_le_pow₀ hd + have hh := proposalRate_bounds (32*d^2) (by omega) + push_cast at hh + simpa only [show (2:ℝ)*(32*(d:ℝ)^2)=64*(d:ℝ)^2 by ring] using hh + +end +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/DirectCases.lean b/lean/OAI/Probability/Contingency/DirectCases.lean new file mode 100644 index 0000000000000000000000000000000000000000..730ce3026eaa71f7e5552557e9fd3de0853984d8 --- /dev/null +++ b/lean/OAI/Probability/Contingency/DirectCases.lean @@ -0,0 +1,600 @@ +import Mathlib +import OAI.Probability.Contingency.GreedyTable + +namespace OAI + +/-! Direct Cases. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency +noncomputable section +variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + +def DirectCase (_c : Fin n → ℕ) : Prop := m=0 ∨ n=0 ∨ (∑ i,r i)=0 ∨ m=1 ∨ n=1 + +theorem table_subsingleton_of_direct (h : DirectCase r c) : Subsingleton (Tables r c) := by + constructor + intro X Y + apply Subtype.ext + funext i j + rcases h with hm | hn | hN | hm | hn + · exact Fin.elim0 (hm ▸ i) + · exact Fin.elim0 (hn ▸ j) + · have hi : r i=0 := by + have hh := Finset.single_le_sum (fun i _ => Nat.zero_le (r i)) (Finset.mem_univ i) + omega + have hx := Finset.single_le_sum (fun j _ => Nat.zero_le (X.val i j)) (Finset.mem_univ j) + have hy := Finset.single_le_sum (fun j _ => Nat.zero_le (Y.val i j)) (Finset.mem_univ j) + rw [X.property.1 i,hi] at hx + rw [Y.property.1 i,hi] at hy + omega + · subst m + have hx := X.property.2 j + have hy := Y.property.2 j + simp only [Fin.sum_univ_one] at hx hy + have hi : i=0 := Fin.eq_zero i + simp only [hi,hx,hy] + · subst n + have hx := X.property.1 i + have hy := Y.property.1 i + simp only [Fin.sum_univ_one] at hx hy + have hj : j=0 := Fin.eq_zero j + simp only [hj,hx,hy] + +namespace Law +variable {α : Type*} [Fintype α] [Nonempty α] [Subsingleton α] + +theorem uniform_subsingleton (x : α) : uniform α=pure x := by + classical + apply Law.ext + funext a + have hcard : Fintype.card α=1 := by rw [← Nat.card_eq_fintype_card]; exact Nat.card_unique + simp [uniform,pure,hcard,Subsingleton.elim a x] + +end Law + +local instance directCasesTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + + + +def arbitraryDraw (hrc : (∑ i,r i)=∑ j,c j) (k : ℕ) : DyadicLaw (Tables r c) := by + classical + by_cases h : DirectCase r c + · exact DyadicLaw.pure (greedyTable r c hrc) 0 + · have hm : 0 < m := by by_contra hh; exact h (Or.inl (by omega)) + have hn : 0 < n := by by_contra hh; exact h (Or.inr (Or.inl (by omega))) + exact PaddedGraph.canonicalDraw r c hm hn hrc k + +theorem arbitraryDraw_bits (hrc : (∑ i,r i)=∑ j,c j) (k : ℕ) : + (arbitraryDraw r c hrc k).bits≤Schedule.R (Parameters.dim m n) (Parameters.bits m n (∑ i,r i)) k := by + classical + unfold arbitraryDraw + split_ifs + · exact Nat.zero_le _ + · exact (PaddedGraph.canonicalDraw_bits _ _ _ _ _ _).le + + + +theorem arbitraryDraw_tv (hrc : (∑ i,r i)=∑ j,c j) (k : ℕ) (hk : 1≤k) : + letI := tables_nonempty r c hrc + (arbitraryDraw r c hrc k).toLaw.tv (Law.uniform (Tables r c))≤(2:ℝ)^(-(k:ℤ)) := by + classical + let := tables_nonempty r c hrc + unfold arbitraryDraw + split_ifs with h + · have huni : Law.uniform (Tables r c)=Law.pure (greedyTable r c hrc) := by + let := table_subsingleton_of_direct r c h + exact Law.uniform_subsingleton _ + rw [DyadicLaw.toLaw_pure,huni,Law.tv_self] + positivity + · exact PaddedGraph.canonicalDraw_tv _ _ _ _ _ _ hk + +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.IntegerTabulation + + + +def step {s : ℕ} (A : Fin s → Fin s → ℕ) (v : Fin s → ℕ) (j : Fin s) : ℕ := + ∑ i,v i*A i j + +def propagate {s : ℕ} (A : Fin s → Fin s → ℕ) (v : Fin s → ℕ) : ℕ → (Fin s → ℕ) + | 0 => v + | t+1 => step A (propagate A v t) + + + +def propagationOps (s : ℕ) : ℕ → ℕ + | 0 => 0 + | t+1 => propagationOps s t+2*s*s + +theorem propagationOps_eq (s t : ℕ) : propagationOps s t=2*t*s^2 := by + induction t with + | zero => simp [propagationOps] + | succ t ih => rw [propagationOps,ih]; ring + +theorem step_total {s : ℕ} (A : Fin s → Fin s → ℕ) (v : Fin s → ℕ) (Q : ℕ) + (hA : ∀ i,∑ j,A i j=2^Q) : (∑ j,step A v j)=(∑ i,v i)*2^Q := by + unfold step + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum,hA] + rw [Finset.sum_mul] + +theorem propagate_total {s : ℕ} (A : Fin s → Fin s → ℕ) (v : Fin s → ℕ) (Q R : ℕ) + (hA : ∀ i,∑ j,A i j=2^Q) (hv : ∑ i,v i=2^R) (t : ℕ) : + (∑ i,propagate A v t i)=2^(R+t*Q) := by + induction t with + | zero => simpa [propagate] using hv + | succ t ih => rw [propagate,step_total _ _ Q hA,ih,← pow_add]; congr 1; ring + +theorem propagate_entry_bound {s : ℕ} (A : Fin s → Fin s → ℕ) (v : Fin s → ℕ) (Q R : ℕ) + (hA : ∀ i,∑ j,A i j=2^Q) (hv : ∑ i,v i=2^R) (t : ℕ) (i : Fin s) : + propagate A v t i≤2^(R+t*Q) := by + rw [← propagate_total A v Q R hA hv t] + exact Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ i) + + + +theorem partial_step_bound {s : ℕ} (A : Fin s → Fin s → ℕ) (v : Fin s → ℕ) (Q R : ℕ) + (hA : ∀ i,∑ j,A i j=2^Q) (hv : ∑ i,v i=2^R) (t : ℕ) (j : Fin s) (I : Finset (Fin s)) : + (∑ i∈I,propagate A v t i*A i j)≤2^(R+(t+1)*Q) := by + apply (Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ I) (fun _ _ _ => Nat.zero_le _)).trans + exact propagate_entry_bound A v Q R hA hv (t+1) j + + + +theorem propagate_walk {s : ℕ} (q : Fin s → DyadicLaw (Fin s)) (Q : ℕ) + (hq : ∀ i,(q i).bits=Q) (i₀ : Fin s) (t : ℕ) : + propagate (fun i j => (q i).count j) (fun i => if i=i₀ then 1 else 0) t= + (DyadicLaw.walk q Q hq i₀ t).count := by + induction t with + | zero => rfl + | succ t ih => + funext j + simp only [propagate,step,DyadicLaw.walk,DyadicLaw.bind,ih] + + + +def stoppedVector {s : ℕ} (R φ : ℕ) (a : Fin s → ℕ) (z₀ : Fin s) : ℕ → (Fin s → ℕ) + | 0 => fun z => if z=z₀ then 1 else 0 + | j+1 => fun z => a z*2^(R*j)+φ*stoppedVector R φ a z₀ j z + +theorem stoppedVector_eq {s : ℕ} (R φ : ℕ) (a : Fin s → ℕ) (z₀ : Fin s) (J : ℕ) (z : Fin s) : + stoppedVector R φ a z₀ J z=stoppedNumerator R φ a z₀ z J := by + induction J with + | zero => rfl + | succ J ih => simp only [stoppedVector,stoppedNumerator,ih] + +theorem stoppedVector_total {s : ℕ} (R φ : ℕ) (a : Fin s → ℕ) (z₀ : Fin s) + (ht : (∑ z,a z)+φ=2^R) (J : ℕ) : (∑ z,stoppedVector R φ a z₀ J z)=2^(R*J) := by + simp_rw [stoppedVector_eq] + exact stoppedNumerator_total R φ a z₀ ht J + + + +theorem stoppedVector_bound {s : ℕ} (R φ : ℕ) (a : Fin s → ℕ) (z₀ : Fin s) + (ht : (∑ z,a z)+φ=2^R) (J : ℕ) (z : Fin s) : stoppedVector R φ a z₀ J z≤2^(R*J) := by + rw [← stoppedVector_total R φ a z₀ ht J] + exact Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ z) + +end Contingency.IntegerTabulation + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + + + +def graphArray (X : GraphState U r c) : Bool×Cell m n → Fin (U+1) := + fun w => ⟨(if w.1 then (graphUnderlying U r c X).x w.2 else (graphUnderlying U r c X).q w.2).toNat,by + have h := (graph_feasible U r c X).1 w.2 + cases w.1 <;> simp only [Bool.false_eq_true,ite_false,ite_true] <;> omega⟩ + +theorem graphArray_injective : Function.Injective (graphArray U r c) := by + intro X Y h + apply graphUnderlying_injective U r c + have hx : (graphUnderlying U r c X).x=(graphUnderlying U r c Y).x := by + funext w + have hh := congrArg Fin.val (congrFun h (true,w)) + dsimp [graphArray] at hh + have hX := ((graph_feasible U r c X).1 w).1 + have hY := ((graph_feasible U r c Y).1 w).1 + omega + have hq : (graphUnderlying U r c X).q=(graphUnderlying U r c Y).q := by + funext w + have hh := congrArg Fin.val (congrFun h (false,w)) + dsimp [graphArray] at hh + have hX := ((graph_feasible U r c X).1 w).2.2.1 + have hY := ((graph_feasible U r c Y).1 w).2.2.1 + omega + exact congrArg₂ State.mk hx hq + +theorem graph_card_array : Nat.card (GraphState U r c)≤(U+1)^(2*(m*n)) := by + rw [Nat.card_eq_fintype_card] + simpa [Cell] using Fintype.card_le_of_injective (graphArray U r c) (graphArray_injective U r c) + +theorem graph_card_dyadic (d b C : ℕ) (hmn : m*n≤d) (hU : U≤C) (hCb : C+1≤2^b) : + Nat.card (GraphState U r c)≤2^(2*d*b) := by + calc + _ ≤ (U+1)^(2*(m*n)) := graph_card_array U r c + _ ≤ (C+1)^(2*(m*n)) := Nat.pow_le_pow_left (by omega) _ + _ ≤ (C+1)^(2*d) := Nat.pow_le_pow_right (by omega) (by omega) + _ ≤ (2^b)^(2*d) := Nat.pow_le_pow_left hCb _ + _ = _ := by rw [← pow_mul]; congr 1; ring + + + +def completionArray (C : ℕ) (hC : ∀ i,paddedRow U L r c i≤C) + (X : GraphState U r c) (A : Completion U L r c (graphUnderlying U r c X)) : + Cell m n → Fin (C+1) := fun w => ⟨(A.val w).toNat,by + have hlo := A.property.1 w + have hhi := (completion_cell_le U L r c _ (graph_feasible U r c X) A w).trans (hC w.1) + omega⟩ + +theorem completion_card_cap (C : ℕ) (hC : ∀ i,paddedRow U L r c i≤C) (X : GraphState U r c) : + Nat.card (Completion U L r c (graphUnderlying U r c X))≤(C+1)^(m*n) := by + let : Fintype (Completion U L r c (graphUnderlying U r c X)) := Fintype.ofFinite _ + have hinj : Function.Injective (completionArray U L r c C hC X) := by + intro A B h + apply Subtype.ext + funext w + have hh := congrArg Fin.val (congrFun h w) + dsimp [completionArray] at hh + have ha := A.property.1 w + have hb := B.property.1 w + omega + rw [Nat.card_eq_fintype_card] + simpa [Cell] using Fintype.card_le_of_injective _ hinj + +theorem completion_card_dyadic (d b C : ℕ) (hmn : m*n≤d) + (hC : ∀ i,paddedRow U L r c i≤C) (hCb : C+1≤2^b) (X : GraphState U r c) : + Nat.card (Completion U L r c (graphUnderlying U r c X))≤2^(d*b) := by + calc + _ ≤ (C+1)^(m*n) := completion_card_cap U L r c C hC X + _ ≤ (C+1)^d := Nat.pow_le_pow_right (by omega) hmn + _ ≤ (2^b)^d := Nat.pow_le_pow_left hCb _ + _ = _ := by rw [← pow_mul]; congr 1; ring + +end +end Contingency.PaddedGraph + + + + + + + +namespace Contingency.BinaryArithmetic + +open PosNum + + +def succCost : PosNum → ℕ + | .one => 1 + | .bit0 _ => 1 + | .bit1 a => succCost a+1 + +theorem succCost_le (a : PosNum) : succCost a≤a.natSize := by + induction a <;> simp_all [succCost,PosNum.natSize] + +theorem succ_size_le (a : PosNum) : a.succ.natSize≤a.natSize+1 := by + induction a <;> simp_all [PosNum.succ,PosNum.natSize] + + +theorem add_size_le (a b : PosNum) : (a+b).natSize≤a.natSize+b.natSize := by + induction a generalizing b with + | one => + change (PosNum.succ b).natSize≤1+b.natSize + simpa [Nat.add_comm] using succ_size_le b + | bit0 a ih => + cases b with + | one => exact (succ_size_le a.bit0) + | bit0 b => change (a+b).natSize+1≤(a.natSize+1)+(b.natSize+1); have := ih b; omega + | bit1 b => change (a+b).natSize+1≤(a.natSize+1)+(b.natSize+1); have := ih b; omega + | bit1 a ih => + cases b with + | one => exact (succ_size_le a.bit1) + | bit0 b => change (a+b).natSize+1≤(a.natSize+1)+(b.natSize+1); have := ih b; omega + | bit1 b => + change (a+b).succ.natSize+1≤(a.natSize+1)+(b.natSize+1) + have := succ_size_le (a+b) + have := ih b + omega + + + +def addCost : PosNum → PosNum → ℕ + | .one,b => succCost b+1 + | a,.one => succCost a+1 + | .bit0 a,.bit0 b => addCost a b+1 + | .bit1 a,.bit1 b => addCost a b+succCost (a+b)+2 + | .bit0 a,.bit1 b => addCost a b+1 + | .bit1 a,.bit0 b => addCost a b+1 + +theorem addCost_le (a b : PosNum) : addCost a b≤(a.natSize+b.natSize+1)^2 := by + induction a generalizing b with + | one => + have := succCost_le b + simp only [addCost,PosNum.natSize] + nlinarith + | bit0 a ih => + cases b with + | one => have := succCost_le a.bit0; simp only [addCost,PosNum.natSize,Nat.succ_eq_add_one] at *; nlinarith + | bit0 b => have := ih b; simp only [addCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize] + | bit1 b => have := ih b; simp only [addCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize] + | bit1 a ih => + cases b with + | one => have := succCost_le a.bit1; simp only [addCost,PosNum.natSize,Nat.succ_eq_add_one] at *; nlinarith + | bit0 b => have := ih b; simp only [addCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize] + | bit1 b => + have h := ih b + have hs := (succCost_le (a+b)).trans (add_size_le a b) + simp only [addCost,PosNum.natSize,Nat.succ_eq_add_one] + nlinarith + + +def mulCost (a : PosNum) : PosNum → ℕ + | .one => a.natSize+1 + | .bit0 b => mulCost a b+1 + | .bit1 b => mulCost a b+addCost ((a*b).bit0) a+2 + +theorem mul_size_le (a b : PosNum) : (a*b).natSize≤a.natSize+b.natSize := by + have ha : (a:ℕ)<2^a.natSize := by rw [PosNum.natSize_to_nat]; exact Nat.size_le.mp le_rfl + have hb : (b:ℕ)<2^b.natSize := by rw [PosNum.natSize_to_nat]; exact Nat.size_le.mp le_rfl + rw [PosNum.natSize_to_nat,PosNum.mul_to_nat,Nat.size_le,pow_add] + exact Nat.mul_lt_mul_of_lt_of_le ha hb.le (by positivity) + +theorem mulCost_le (a b : PosNum) : + mulCost a b≤4*(a.natSize+b.natSize+1)^3 := by + induction b with + | one => simp only [mulCost,PosNum.natSize]; nlinarith [Nat.zero_le (a.natSize^3)] + | bit0 b ih => simp only [mulCost,PosNum.natSize,Nat.succ_eq_add_one]; nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize,Nat.zero_le (a.natSize*b.natSize)] + | bit1 b ih => + have ha := addCost_le ((a*b).bit0) a + have hs := mul_size_le a b + simp only [PosNum.natSize] at ha + have hh : ((a*b).natSize+1+a.natSize+1)^2≤(2*(a.natSize+b.natSize+1))^2 := by + apply Nat.pow_le_pow_left + omega + have ha' := ha.trans hh + simp only [mulCost,PosNum.natSize,Nat.succ_eq_add_one] + nlinarith + + + +theorem add_certificate (a b : PosNum) : + ((a+b:PosNum):ℕ)=(a:ℕ)+(b:ℕ) ∧ addCost a b≤(a.natSize+b.natSize+1)^2 := + ⟨PosNum.add_to_nat a b,addCost_le a b⟩ + +theorem mul_certificate (a b : PosNum) : + ((a*b:PosNum):ℕ)=(a:ℕ)*(b:ℕ) ∧ mulCost a b≤4*(a.natSize+b.natSize+1)^3 := + ⟨PosNum.mul_to_nat a b,mulCost_le a b⟩ + +end Contingency.BinaryArithmetic + + + + + +open scoped BigOperators +namespace Contingency.BinaryArithmetic + + + +def numAddCost : Num → Num → ℕ + | .zero, b => b.natSize+1 + | a, .zero => a.natSize+1 + | .pos a, .pos b => addCost a b+1 + +def numMulCost : Num → Num → ℕ + | .zero, _ => 1 + | _, .zero => 1 + | .pos a, .pos b => mulCost a b+1 + +theorem numAddCost_le (a b : Num) : numAddCost a b≤(a.natSize+b.natSize+2)^2 := by + cases a with + | zero => simp only [numAddCost,Num.natSize,zero_add]; nlinarith [Nat.zero_le b.natSize] + | pos a => + cases b with + | zero => simp only [numAddCost,Num.natSize,add_zero]; nlinarith [Nat.zero_le a.natSize] + | pos b => + have h := addCost_le a b + simp only [numAddCost,Num.natSize] + nlinarith [Nat.zero_le a.natSize,Nat.zero_le b.natSize] + +theorem numMulCost_le (a b : Num) : numMulCost a b≤5*(a.natSize+b.natSize+2)^3 := by + cases a with + | zero => + have h := Nat.one_le_pow 3 (b.natSize+2) (by omega) + have hh : 1≤5*(b.natSize+2)^3 := by omega + simpa only [numMulCost,Num.natSize,zero_add] using hh + | pos a => + cases b with + | zero => + change 1≤5*(a.natSize+2)^3 + have h := Nat.one_le_pow 3 (a.natSize+2) (by omega) + omega + | pos b => + have h := mulCost_le a b + simp only [numMulCost,Num.natSize] + nlinarith [Nat.zero_le ((a.natSize+b.natSize)^2),Nat.zero_le ((a.natSize+b.natSize)^3),Nat.zero_le a.natSize,Nat.zero_le b.natSize] + +theorem numSize_le_of_lt (a : Num) (L : ℕ) (h : (a:ℕ)<2^L) : a.natSize≤L := by + cases a with + | zero => exact Nat.zero_le _ + | pos a => + change a.natSize≤L + rw [PosNum.natSize_to_nat,Nat.size_le] + exact h + + + +def binaryDot : List (Num×Num) → Num×ℕ + | [] => (.zero,1) + | (a,b)::xs => + let t := binaryDot xs + let p := a*b + (p+t.1,t.2+numMulCost a b+numAddCost p t.1+3) + +def dotValue (xs : List (Num×Num)) : ℕ := (xs.map (fun ab => (ab.1:ℕ)*(ab.2:ℕ))).sum + +theorem binaryDot_value (xs : List (Num×Num)) : ((binaryDot xs).1:ℕ)=dotValue xs := by + induction xs with + | nil => rfl + | cons ab xs ih => + rcases ab with ⟨a,b⟩ + simp only [binaryDot,Num.add_to_nat,Num.mul_to_nat,dotValue,List.map_cons,List.sum_cons] at * + rw [ih] + + + +theorem binaryDot_cost (xs : List (Num×Num)) (L : ℕ) + (hx : ∀ ab∈xs,ab.1.natSize≤L ∧ ab.2.natSize≤L) + (hv : dotValue xs<2^L) : + (binaryDot xs).2≤1+xs.length*(10*(2*L+2)^3) := by + induction xs with + | nil => simp [binaryDot] + | cons ab xs ih => + rcases ab with ⟨a,b⟩ + have hv' : (a:ℕ)*(b:ℕ)+dotValue xs<2^L := hv + have hp : (a:ℕ)*(b:ℕ)<2^L := (Nat.le_add_right _ _).trans_lt hv' + have ht : dotValue xs<2^L := (Nat.le_add_left _ _).trans_lt hv' + have hab := hx (a,b) (by simp) + dsimp only at hab + have hc := ih (fun ab h => hx ab (by simp [h])) ht + have hs := numSize_le_of_lt (a*b) L (by simpa only [Num.mul_to_nat] using hp) + have hst := numSize_le_of_lt (binaryDot xs).1 L (by simpa only [binaryDot_value] using ht) + have hm := (numMulCost_le a b).trans (Nat.mul_le_mul_left 5 (Nat.pow_le_pow_left (by omega : a.natSize+b.natSize+2≤2*L+2) 3)) + have ha := (numAddCost_le (a*b) (binaryDot xs).1).trans + (Nat.pow_le_pow_left (by omega : (a*b).natSize+(binaryDot xs).1.natSize+2≤2*L+2) 2) + have he : (2*L+2)^2≤(2*L+2)^3 := Nat.pow_le_pow_right (by omega) (by omega) + have hu : 1≤(2*L+2)^3 := Nat.one_le_pow _ _ (by omega) + simp only [binaryDot,List.length_cons] + nlinarith only [hc,hm,ha,he,hu] + + +def binaryColumn {s : ℕ} (A : Fin s → Fin s → Num) (v : Fin s → Num) (j : Fin s) : Num×ℕ := + binaryDot (List.ofFn (fun i => (v i,A i j))) + +theorem binaryColumn_value {s : ℕ} (A : Fin s → Fin s → Num) (v : Fin s → Num) (j : Fin s) : + ((binaryColumn A v j).1:ℕ)=IntegerTabulation.step (fun i j => (A i j:ℕ)) (fun i => (v i:ℕ)) j := by + rw [binaryColumn,binaryDot_value] + simp [dotValue,IntegerTabulation.step,List.map_ofFn,List.sum_ofFn] + + +def binaryPropagate {s : ℕ} (A : Fin s → Fin s → Num) (v : Fin s → Num) : ℕ → (Fin s → Num) + | 0 => v + | t+1 => + let previous := binaryPropagate A v t + fun j => (binaryColumn A previous j).1 + +theorem binaryPropagate_value {s : ℕ} (A : Fin s → Fin s → Num) (v : Fin s → Num) (t : ℕ) : + (fun i => (binaryPropagate A v t i:ℕ))= + IntegerTabulation.propagate (fun i j => (A i j:ℕ)) (fun i => (v i:ℕ)) t := by + induction t with + | zero => rfl + | succ t ih => + funext j + simp only [binaryPropagate,binaryColumn_value,IntegerTabulation.propagate,ih] + +end Contingency.BinaryArithmetic + + + + + +open scoped BigOperators +namespace Contingency.BinaryArithmetic + +variable {s : ℕ} (A : Fin s → Fin s → Num) (v : Fin s → Num) (Q R : ℕ) + (hA : ∀ i,∑ j,(A i j:ℕ)=2^Q) (hv : ∑ i,(v i:ℕ)=2^R) + + +theorem denominator_size (x B : ℕ) (hx : x≤2^B) : x<2^(B+1) := by + exact hx.trans_lt (Nat.pow_lt_pow_right (by norm_num) (Nat.lt_succ_self B)) + +include hA hv in +theorem binaryColumn_cost (t : ℕ) (j : Fin s) : + (binaryColumn A (binaryPropagate A v t) j).2≤ + 1+s*(10*(2*(R+(t+1)*Q+1)+2)^3) := by + let L := R+(t+1)*Q+1 + have hval := binaryPropagate_value A v t + have hvec (i : Fin s) : (binaryPropagate A v t i:ℕ)≤2^(R+t*Q) := by + rw [show (binaryPropagate A v t i:ℕ)= + IntegerTabulation.propagate (fun i j => (A i j:ℕ)) (fun i => (v i:ℕ)) t i from congrFun hval i] + exact IntegerTabulation.propagate_entry_bound _ _ Q R hA hv t i + have hentry (i l : Fin s) : (A i l:ℕ)≤2^Q := by + rw [← hA i] + exact Finset.single_le_sum (fun l _ => Nat.zero_le (A i l:ℕ)) (Finset.mem_univ l) + have hi : Q≤R+(t+1)*Q := by nlinarith only [Nat.zero_le R,Nat.zero_le (t*Q)] + unfold binaryColumn + have hh := binaryDot_cost (List.ofFn (fun i => (binaryPropagate A v t i,A i j))) L + rw [List.length_ofFn] at hh + apply hh + · intro ab hab + rcases List.mem_ofFn.mp hab with ⟨i,rfl⟩ + constructor + · apply numSize_le_of_lt + change (binaryPropagate A v t i:ℕ)<2^(R+(t+1)*Q+1) + apply denominator_size + exact (hvec i).trans (Nat.pow_le_pow_right (by norm_num) (by gcongr; omega)) + · apply numSize_le_of_lt + change (A i j:ℕ)<2^(R+(t+1)*Q+1) + exact denominator_size _ _ ((hentry i j).trans (Nat.pow_le_pow_right (by norm_num) hi)) + · change _<2^(R+(t+1)*Q+1) + apply denominator_size + rw [← binaryDot_value] + change ((binaryColumn A (binaryPropagate A v t) j).1:ℕ)≤_ + rw [binaryColumn_value,hval] + exact IntegerTabulation.propagate_entry_bound _ _ Q R hA hv (t+1) j + + + +def binaryPropagationCost : ℕ → ℕ + | 0 => 0 + | t+1 => binaryPropagationCost t+∑ j,(binaryColumn A (binaryPropagate A v t) j).2 + +include hA hv in +theorem binaryPropagationCost_le_aux (T : ℕ) (t : ℕ) (ht : t≤T) : + binaryPropagationCost A v t≤t*s*(1+s*(10*(2*(R+T*Q+1)+2)^3)) := by + induction t with + | zero => simp [binaryPropagationCost] + | succ t ih => + have hi := ih (by omega) + have hcol (j : Fin s) := binaryColumn_cost A v Q R hA hv t j + have hb : R+(t+1)*Q+1≤R+T*Q+1 := by gcongr + have hm : (∑ j,(binaryColumn A (binaryPropagate A v t) j).2)≤ + s*(1+s*(10*(2*(R+T*Q+1)+2)^3)) := by + calc + _ ≤ ∑ _ : Fin s,(1+s*(10*(2*(R+T*Q+1)+2)^3)) := by + apply Finset.sum_le_sum + intro j _ + exact (hcol j).trans (by gcongr) + _ = _ := by simp + rw [binaryPropagationCost] + nlinarith only [hi,hm] + +include hA hv in +theorem binaryPropagationCost_le (T : ℕ) : + binaryPropagationCost A v T≤T*s*(1+s*(10*(2*(R+T*Q+1)+2)^3)) := + binaryPropagationCost_le_aux A v Q R hA hv T T le_rfl + +end Contingency.BinaryArithmetic + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/DyadicLaws.lean b/lean/OAI/Probability/Contingency/DyadicLaws.lean new file mode 100644 index 0000000000000000000000000000000000000000..a38cabe0735fd4b9b03d5ca918543afd113670d7 --- /dev/null +++ b/lean/OAI/Probability/Contingency/DyadicLaws.lean @@ -0,0 +1,696 @@ +import Mathlib + +namespace OAI + +/-! Dyadic Laws. -/ + +noncomputable section + + + + + + + +open scoped BigOperators + +namespace Contingency + + + +structure DyadicLaw (α : Type*) [Fintype α] where + bits : ℕ + count : α → ℕ + total : ∑ z, count z = 2 ^ bits + +namespace DyadicLaw + +variable {α β γ : Type*} [Fintype α] [Fintype β] [Fintype γ] + + +def pure [DecidableEq α] (z : α) (R : ℕ := 0) : DyadicLaw α where + bits := R + count x := if x = z then 2 ^ R else 0 + total := by simp + + + +def bind (p : DyadicLaw α) (q : α → DyadicLaw β) (S : ℕ) + (hq : ∀ x, (q x).bits = S) : DyadicLaw β where + bits := p.bits + S + count y := ∑ x, p.count x * (q x).count y + total := by + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, DyadicLaw.total, hq] + rw [← Finset.sum_mul, p.total, pow_add] + + +def map [DecidableEq β] (f : α → β) (p : DyadicLaw α) : DyadicLaw β := + p.bind (fun x => pure (f x)) 0 (fun _ => rfl) + +@[simp] theorem map_bits [DecidableEq β] (f : α → β) (p : DyadicLaw α) : + (p.map f).bits = p.bits := by simp [map, bind] + +@[simp] theorem map_count [DecidableEq β] (f : α → β) (p : DyadicLaw α) (y : β) : + (p.map f).count y = ∑ x, if f x = y then p.count x else 0 := by + simp only [map, bind, pure, pow_zero, mul_ite, mul_one, mul_zero] + apply Finset.sum_congr rfl + intro x _ + by_cases h : f x = y + · simp [h] + · simp [h, Ne.symm h] + + +def walk [DecidableEq α] (q : α → DyadicLaw α) (S : ℕ) + (hq : ∀ x, (q x).bits = S) (x₀ : α) : ℕ → DyadicLaw α + | 0 => pure x₀ + | t + 1 => (walk q S hq x₀ t).bind q S hq + +@[simp] theorem walk_bits [DecidableEq α] (q : α → DyadicLaw α) (S : ℕ) + (hq : ∀ x, (q x).bits = S) (x₀ : α) (t : ℕ) : + (walk q S hq x₀ t).bits = t * S := by + induction t with + | zero => simp [walk, pure] + | succ t ih => simp [walk, bind, ih, Nat.succ_mul] + +def probability (p : DyadicLaw α) (x : α) : ℚ := p.count x / 2 ^ p.bits + +@[simp] theorem probability_nonneg (p : DyadicLaw α) (x : α) : + 0 ≤ p.probability x := by + unfold probability + positivity + +@[simp] theorem probability_total (p : DyadicLaw α) : + ∑ x, p.probability x = 1 := by + unfold probability + rw [← Finset.sum_div] + norm_cast + rw [p.total] + norm_num + +end DyadicLaw + + +def bitWordLaw (r : ℕ) : DyadicLaw (Fin (2 ^ r)) where + bits := r + count _ := 1 + total := by simp + + +def roundedOffset (w : ℕ) (hw : 0 < w) (r : ℕ) (z : Fin (2 ^ r)) : Fin w := + ⟨w * z.val / 2 ^ r, by + apply (Nat.div_lt_iff_lt_mul (pow_pos (by omega) _)).mpr + exact Nat.mul_lt_mul_of_pos_left z.isLt hw⟩ + + +def offsetLaw (w : ℕ) (hw : 0 < w) (r : ℕ) : DyadicLaw (Fin w) := + (bitWordLaw r).map (roundedOffset w hw r) + + +def offsetNumerator (w r u : ℕ) : ℕ := + ((u + 1) * 2 ^ r) ⌈/⌉ w - (u * 2 ^ r) ⌈/⌉ w + +theorem offset_preimage (w : ℕ) (hw : 0 < w) (r u : ℕ) (hu : u < w) : + {z ∈ Finset.range (2 ^ r) | w * z / 2 ^ r = u} = + Finset.Ico ((u * 2 ^ r) ⌈/⌉ w) (((u + 1) * 2 ^ r) ⌈/⌉ w) := by + ext z + have hpow : 0 < 2 ^ r := pow_pos (by omega) _ + have hlo : (u * 2 ^ r) ⌈/⌉ w ≤ z ↔ u ≤ w * z / 2 ^ r := by + rw [ceilDiv_le_iff_le_mul hw, Nat.le_div_iff_mul_le hpow] + have hhi : z < ((u + 1) * 2 ^ r) ⌈/⌉ w ↔ w * z / 2 ^ r < u + 1 := by + rw [lt_iff_not_ge, ceilDiv_le_iff_le_mul hw, not_le, + Nat.div_lt_iff_lt_mul hpow] + simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ico, hlo, hhi] + constructor + · rintro ⟨_, heq⟩ + omega + · rintro ⟨h1, h2⟩ + have heq : w * z / 2 ^ r = u := by omega + refine ⟨?_, heq⟩ + have hlt : w * z < w * 2 ^ r := + (Nat.div_lt_iff_lt_mul hpow).mp (by omega) + exact (Nat.mul_lt_mul_left hw).mp hlt + +theorem offsetLaw_count (w : ℕ) (hw : 0 < w) (r : ℕ) (u : Fin w) : + (offsetLaw w hw r).count u = offsetNumerator w r u.val := by + rw [offsetLaw, DyadicLaw.map_count] + simp only [bitWordLaw, roundedOffset, Fin.ext_iff] + rw [Fin.sum_univ_eq_sum_range (fun z : ℕ => + if w * z / 2 ^ r = u.val then (1 : ℕ) else 0) (2 ^ r)] + rw [← Finset.card_filter, offset_preimage w hw r u u.isLt, Nat.card_Ico] + rfl + + + +def stoppedNumerator {α : Type*} [DecidableEq α] (R φ : ℕ) (a : α → ℕ) + (fallback z : α) : ℕ → ℕ + | 0 => if z = fallback then 1 else 0 + | J + 1 => a z * 2 ^ (R * J) + φ * stoppedNumerator R φ a fallback z J + +theorem stoppedNumerator_total {α : Type*} [Fintype α] [DecidableEq α] + (R φ : ℕ) (a : α → ℕ) (fallback : α) (ht : (∑ z, a z) + φ = 2 ^ R) + (J : ℕ) : ∑ z, stoppedNumerator R φ a fallback z J = 2 ^ (R * J) := by + induction J with + | zero => simp [stoppedNumerator] + | succ J ih => + simp only [stoppedNumerator, Finset.sum_add_distrib, ← Finset.sum_mul, + ← Finset.mul_sum, ih] + rw [← add_mul, ht, Nat.mul_succ, pow_add] + ring + + + +def stoppedLaw {α : Type*} [Fintype α] [DecidableEq α] + (trial : DyadicLaw (Option α)) (fallback : α) (J : ℕ) : DyadicLaw α where + bits := trial.bits * J + count z := stoppedNumerator trial.bits (trial.count none) + (fun z => trial.count (some z)) fallback z J + total := stoppedNumerator_total _ _ _ _ (by + have ht := trial.total + rw [Fintype.sum_option] at ht + omega) J + + +theorem stoppedNumerator_closed {α : Type*} [DecidableEq α] + (R φ : ℕ) (a : α → ℕ) (fallback z : α) (J : ℕ) : + stoppedNumerator R φ a fallback z J = + (∑ j ∈ Finset.range J, φ ^ j * a z * 2 ^ (R * (J - j - 1))) + + (if z = fallback then φ ^ J else 0) := by + induction J with + | zero => simp [stoppedNumerator] + | succ J ih => + rw [stoppedNumerator, ih, Finset.sum_range_succ'] + simp only [pow_zero, one_mul, Nat.sub_zero, Nat.add_sub_cancel] + have hs : (∑ j ∈ Finset.range J, + φ ^ (j + 1) * a z * 2 ^ (R * (J + 1 - (j + 1) - 1))) = + φ * ∑ j ∈ Finset.range J, φ ^ j * a z * 2 ^ (R * (J - j - 1)) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + rw [Nat.add_sub_add_right, pow_succ] + ring + rw [hs] + by_cases hz : z = fallback <;> simp [hz, pow_succ] <;> ring + + +def residualNumerator (M R D a : ℕ) : ℤ := + (2 : ℤ) ^ (R + D) - M * ((2 : ℤ) ^ D - 1) * a + +theorem residual_integers {α : Type*} [Fintype α] (R D : ℕ) (a : α → ℕ) + (htotal : ∑ z, a z = 2 ^ R) + (hdom : ∀ z, (Fintype.card α : ℤ) * ((2 : ℤ) ^ D - 1) * a z ≤ + (2 : ℤ) ^ (R + D)) : + (∀ z, 0 ≤ residualNumerator (Fintype.card α) R D (a z)) ∧ + (∑ z, residualNumerator (Fintype.card α) R D (a z) = + (Fintype.card α : ℤ) * 2 ^ R) := by + constructor + · intro z + exact sub_nonneg.mpr (hdom z) + · have ht : ∑ z, (a z : ℤ) = (2 : ℤ) ^ R := by exact_mod_cast htotal + simp only [residualNumerator, Finset.sum_sub_distrib, Finset.sum_const, + Finset.card_univ, nsmul_eq_mul, ← Finset.mul_sum] + rw [ht, pow_add] + ring + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section + +structure Law (α : Type*) [Fintype α] where + mass : α → ℝ + nonneg : ∀ x,0 ≤ mass x + total : ∑ x,mass x=1 + +namespace Law +variable {α β γ : Type*} [Fintype α] [Fintype β] [Fintype γ] + +@[ext] theorem ext {p r : Law α} (h : p.mass=r.mass) : p=r := by cases p; cases r; cases h; rfl + +def pure (x : α) : Law α := by + classical + exact ⟨fun y => if x=y then 1 else 0,fun y => by split_ifs <;> norm_num,by simp⟩ + +def bind (p : Law α) (k : α → Law β) : Law β where + mass y := ∑ x,p.mass x*(k x).mass y + nonneg y := Finset.sum_nonneg fun x _ => mul_nonneg (p.nonneg x) ((k x).nonneg y) + total := by rw [Finset.sum_comm]; simp only [← Finset.mul_sum,Law.total,mul_one] + +def map (f : α → β) (p : Law α) : Law β := p.bind (fun x => pure (f x)) + +def tv (p r : Law α) : ℝ := (∑ x,|p.mass x-r.mass x|)/2 + +theorem tv_nonneg (p r : Law α) : 0 ≤ p.tv r := by unfold tv; positivity +@[simp] theorem tv_self (p : Law α) : p.tv p=0 := by simp [tv] +theorem tv_symm (p r : Law α) : p.tv r=r.tv p := by simp only [tv,abs_sub_comm] + +theorem tv_triangle (p r s : Law α) : p.tv s ≤ p.tv r+r.tv s := by + unfold tv + rw [← add_div,← Finset.sum_add_distrib] + apply div_le_div_of_nonneg_right _ (by norm_num) + exact Finset.sum_le_sum fun x _ => abs_sub_le _ _ _ + +theorem tv_le_one (p r : Law α) : p.tv r ≤ 1 := by + have h : (∑ x,|p.mass x-r.mass x|) ≤ 2 := by + calc + _ ≤ ∑ x,(p.mass x+r.mass x) := Finset.sum_le_sum fun x _ => by + rw [abs_le]; constructor <;> linarith [p.nonneg x,r.nonneg x] + _ = 2 := by rw [Finset.sum_add_distrib,p.total,r.total]; norm_num + unfold tv; linarith + +theorem tv_bind_left (p r : Law α) (k : α → Law β) : + (p.bind k).tv (r.bind k) ≤ p.tv r := by + unfold tv + apply div_le_div_of_nonneg_right _ (by norm_num) + calc + _ = ∑ y,|∑ x,(p.mass x-r.mass x)*(k x).mass y| := by + simp only [bind,sub_mul,Finset.sum_sub_distrib] + _ ≤ ∑ y,∑ x,|p.mass x-r.mass x| *(k x).mass y := by + apply Finset.sum_le_sum; intro y _ + have hh := Finset.abs_sum_le_sum_abs (s:=Finset.univ) (f:=fun x => (p.mass x-r.mass x)*(k x).mass y) + simpa only [abs_mul,abs_of_nonneg ((k _).nonneg _)] using hh + _ = _ := by rw [Finset.sum_comm]; simp only [← Finset.mul_sum,Law.total,mul_one] + +theorem tv_bind_right (p : Law α) (k l : α → Law β) : + (p.bind k).tv (p.bind l) ≤ ∑ x,p.mass x*(k x).tv (l x) := by + unfold tv + rw [show (∑ x,p.mass x*((∑ y,|(k x).mass y-(l x).mass y|)/2))= + (∑ x,∑ y,p.mass x*|(k x).mass y-(l x).mass y|)/2 by simp only [mul_div_assoc,Finset.mul_sum,Finset.sum_div]] + apply div_le_div_of_nonneg_right _ (by norm_num) + calc + _ = ∑ y,|∑ x,p.mass x*((k x).mass y-(l x).mass y)| := by simp only [bind,mul_sub,Finset.sum_sub_distrib] + _ ≤ ∑ y,∑ x,p.mass x*|(k x).mass y-(l x).mass y| := by + apply Finset.sum_le_sum; intro y _ + have hh := Finset.abs_sum_le_sum_abs (s:=Finset.univ) (f:=fun x => p.mass x*((k x).mass y-(l x).mass y)) + simpa only [abs_mul,abs_of_nonneg (p.nonneg _)] using hh + _ = _ := Finset.sum_comm + +theorem tv_bind_right_bound (p : Law α) (k l : α → Law β) (δ : ℝ) + (hδ : ∀ x,(k x).tv (l x) ≤ δ) : (p.bind k).tv (p.bind l) ≤ δ := by + apply (tv_bind_right p k l).trans + calc + _ ≤ ∑ x,p.mass x*δ := Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_left (hδ x) (p.nonneg x) + _ = δ := by rw [← Finset.sum_mul,p.total,one_mul] + +theorem tv_bind (p r : Law α) (k l : α → Law β) (δ : ℝ) + (hδ : ∀ x,(k x).tv (l x) ≤ δ) : (p.bind k).tv (r.bind l) ≤ p.tv r+δ := by + exact (tv_triangle _ (r.bind k) _).trans (add_le_add (tv_bind_left p r k) (tv_bind_right_bound r k l δ hδ)) + +theorem tv_map (f : α → β) (p r : Law α) : (p.map f).tv (r.map f) ≤ p.tv r := + tv_bind_left _ _ _ + +def first (p : Law (Option α)) (fallback : α) : ℕ → Law α + | 0 => pure fallback + | J+1 => p.bind (fun o => match o with | none => first p fallback J | some x => pure x) + + +theorem first_tv (p r : Law (Option α)) (fallback : α) (J : ℕ) : + (first p fallback J).tv (first r fallback J) ≤ J*p.tv r := by + induction J with + | zero => simp [first] + | succ J ih => + have h := tv_bind p r + (fun o => match o with | none => first p fallback J | some x => pure x) + (fun o => match o with | none => first r fallback J | some x => pure x) + (J*p.tv r) (by intro o; cases o; exact ih; simpa only [tv_self] using mul_nonneg (Nat.cast_nonneg J) (tv_nonneg p r)) + simpa only [first,Nat.cast_add,Nat.cast_one,add_mul,one_mul,add_comm] using h + +@[simp] theorem bind_pure_mass (p : Law α) (y : α) : (p.bind pure).mass y=p.mass y := by + classical + simp [bind,pure] + +theorem first_mass (p : Law (Option α)) (fallback : α) (u : Law α) + (h : ∀ x,p.mass (some x)=(1-p.mass none)*u.mass x) (J : ℕ) (x : α) : + (first p fallback J).mass x=(1-p.mass none^J)*u.mass x+p.mass none^J*(pure fallback).mass x := by + induction J with + | zero => simp [first] + | succ J ih => + change (∑ o : Option α,p.mass o*(match o with | none => first p fallback J | some y => pure y).mass x)=_ + rw [Fintype.sum_option] + simp only [h] + have he : (∑ y,(1-p.mass none)*u.mass y*(pure y).mass x)=(1-p.mass none)*u.mass x := by + simp only [mul_assoc] + rw [← Finset.mul_sum] + change (1-p.mass none)*(u.bind pure).mass x=_ + rw [bind_pure_mass] + rw [he,ih,pow_succ] + ring + +theorem first_ideal_tv (p : Law (Option α)) (fallback : α) (u : Law α) + (h : ∀ x,p.mass (some x)=(1-p.mass none)*u.mass x) (J : ℕ) : + (first p fallback J).tv u ≤ p.mass none^J := by + have he : (first p fallback J).tv u=p.mass none^J*(pure fallback).tv u := by + unfold tv + simp only [first_mass p fallback u h J] + have hh (x) : (1-p.mass none^J)*u.mass x+p.mass none^J*(pure fallback).mass x-u.mass x= + p.mass none^J*((pure fallback).mass x-u.mass x) := by ring + simp only [hh,abs_mul,abs_of_nonneg (pow_nonneg (p.nonneg none) J),← Finset.mul_sum] + ring + rw [he] + have hh := mul_le_mul_of_nonneg_left (tv_le_one (pure fallback) u) (pow_nonneg (p.nonneg none) J) + simpa only [mul_one] using hh + +end Law +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace DyadicLaw +variable {α β : Type*} [Fintype α] [Fintype β] +def toLaw (p : DyadicLaw α) : Law α where + mass x := (p.count x:ℝ)/2^p.bits + nonneg x := by positivity + total := by + rw [← Finset.sum_div] + have hh : (∑ x,(p.count x:ℝ))=(2:ℝ)^p.bits := by exact_mod_cast p.total + rw [hh] + exact div_self (by positivity) + +theorem toLaw_bind (p : DyadicLaw α) (k : α → DyadicLaw β) (S : ℕ) + (hk : ∀ x,(k x).bits=S) : (p.bind k S hk).toLaw=p.toLaw.bind (fun x => (k x).toLaw) := by + apply Law.ext + funext y + simp only [toLaw,bind,Law.bind,Nat.cast_sum,Nat.cast_mul,pow_add,hk,Finset.sum_div] + apply Finset.sum_congr rfl + intro x _ + ring +end DyadicLaw + +namespace Law + +def uniform (α : Type*) [Fintype α] [Nonempty α] : Law α where + mass _ := 1/Fintype.card α + nonneg _ := by positivity + total := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]; field_simp + +end Law + +theorem ceilDiv_error (a w : ℕ) (hw : 0 nlinarith only [hlo.1,hlo.2,hhi.1,hhi.2] + +theorem offsetLaw_point_error (w : ℕ) (hw : 0 offsetLaw_point_error w hw r u + _ = _ := by simp [div_eq_mul_inv] + have hn : (0:ℝ)≤(w:ℝ)/(2:ℝ)^r := by positivity + linarith + + +theorem rounded_offset_accuracy (w h d : ℕ) (hw : 0 (p i).nonneg (x i) + total := by + rw [← Fintype.prod_sum] + simp only [Law.total,Finset.prod_const_one] + +theorem tv_overlap {β : Type*} [Fintype β] (p r : Law β) : + p.tv r = 1-∑ x,min (p.mass x) (r.mass x) := by + have hh : (∑ x,|p.mass x-r.mass x|)=2-2*(∑ x,min (p.mass x) (r.mass x)) := by + calc + _ = ∑ x,(p.mass x+r.mass x-2*min (p.mass x) (r.mass x)) := by + apply Finset.sum_congr rfl; intro x _ + rcases le_total (p.mass x) (r.mass x) with h|h + · rw [min_eq_left h,abs_of_nonpos (sub_nonpos.mpr h)]; ring + · rw [min_eq_right h,abs_of_nonneg (sub_nonneg.mpr h)]; ring + _ = _ := by rw [Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum,p.total,r.total]; norm_num + unfold tv; rw [hh]; ring + +omit [Fintype ι] in +theorem deficit_prod_le_sum (f : ι → ℝ) (hf : ∀ i,0≤f i ∧ f i≤1) (s : Finset ι) : + 1-∏ i∈s,f i ≤ ∑ i∈s,(1-f i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => + rw [Finset.prod_insert ha,Finset.sum_insert ha] + have hp : (∏ i∈s,f i)≤1 := Finset.prod_le_one₀ (fun index _ => (hf index).1) (fun index _ => (hf index).2) + have hn := mul_nonneg (by linarith [(hf a).2] : 0≤1-f a) (by linarith : 0≤1-∏ i∈s,f i) + nlinarith + + +theorem tv_pi (p r : ∀ i,Law (α i)) : + (pi p).tv (pi r) ≤ ∑ i,(p i).tv (r i) := by + classical + have hs : (∏ i,∑ x,min ((p i).mass x) ((r i).mass x)) ≤ + ∑ x,min ((pi p).mass x) ((pi r).mass x) := by + rw [Fintype.prod_sum] + apply Finset.sum_le_sum + intro x _ + apply le_min + · exact Finset.prod_le_prod₀ (fun index _ => le_min ((p index).nonneg _) ((r index).nonneg _)) + (fun index _ => min_le_left _ _) + · exact Finset.prod_le_prod₀ (fun index _ => le_min ((p index).nonneg _) ((r index).nonneg _)) + (fun index _ => min_le_right _ _) + have he (i) : (∑ x,min ((p i).mass x) ((r i).mass x))=1-(p i).tv (r i) := by rw [tv_overlap]; ring + simp only [he] at hs + have hb := deficit_prod_le_sum (fun i => 1-(p i).tv (r i)) (fun i => + ⟨by linarith [tv_le_one (p i) (r i)],by linarith [tv_nonneg (p i) (r i)]⟩) Finset.univ + simp only [sub_sub_cancel] at hb + rw [tv_overlap] + linarith + +variable {β γ : Type*} [Fintype β] [Fintype γ] +def prod (p : Law β) (r : Law γ) : Law (β×γ) where + mass x := p.mass x.1*r.mass x.2 + nonneg x := mul_nonneg (p.nonneg _) (r.nonneg _) + total := by rw [Fintype.sum_prod_type]; simp only [← Finset.mul_sum,r.total,mul_one,p.total] + +theorem prod_eq_bind (p : Law β) (r : Law γ) : p.prod r=p.bind (fun x => r.map (x,·)) := by + classical + apply Law.ext; funext y + simp only [prod,bind,map,pure,Prod.ext_iff] + have hh (x : β) : (∑ z : γ,r.mass z*(if x=y.1 ∧ z=y.2 then 1 else 0))= + if x=y.1 then r.mass y.2 else 0 := by + by_cases h : x=y.1 <;> simp [h] + simp only [hh] + simp + +theorem tv_prod (p p' : Law β) (r r' : Law γ) : + (p.prod r).tv (p'.prod r') ≤ p.tv p'+r.tv r' := by + rw [prod_eq_bind,prod_eq_bind] + exact tv_bind p p' _ _ _ (fun x => tv_map (x,·) r r') + +end +end Contingency.Law + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace DyadicLaw +variable {α β : Type*} [Fintype α] [Fintype β] + +theorem toLaw_pure [DecidableEq α] (x : α) (R : ℕ) : (pure x R).toLaw=Law.pure x := by + apply Law.ext; funext y + by_cases h : x=y + · subst y; simp [toLaw,pure,Law.pure] + · simp [toLaw,pure,Law.pure,h,Ne.symm h] + +theorem toLaw_map [DecidableEq β] (f : α → β) (p : DyadicLaw α) : + (p.map f).toLaw=p.toLaw.map f := by + change (p.bind (fun x => pure (f x)) 0 (fun _ => rfl)).toLaw=p.toLaw.map f + exact (toLaw_bind p (fun x => pure (f x)) 0 (fun _ => rfl)).trans (by + simp only [toLaw_pure,Law.map]) + +def pad (p : DyadicLaw α) (R : ℕ) (hR : p.bits≤R) : DyadicLaw α where + bits := R + count x := p.count x*2^(R-p.bits) + total := by rw [← Finset.sum_mul,p.total,← pow_add,Nat.add_sub_of_le hR] + +theorem toLaw_pad (p : DyadicLaw α) (R : ℕ) (hR : p.bits≤R) : (p.pad R hR).toLaw=p.toLaw := by + apply Law.ext; funext x + change ((p.count x*2^(R-p.bits):ℕ):ℝ)/(2:ℝ)^R=(p.count x:ℝ)/(2:ℝ)^p.bits + push_cast + have he : (2:ℝ)^R=(2:ℝ)^p.bits*(2:ℝ)^(R-p.bits) := by rw [← pow_add,Nat.add_sub_of_le hR] + rw [he] + field_simp + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {γ : ι → Type*} [∀ i,Fintype (γ i)] +def pi (p : ∀ i,DyadicLaw (γ i)) : DyadicLaw (∀ i,γ i) where + bits := ∑ i,(p i).bits + count x := ∏ i,(p i).count (x i) + total := by rw [← Fintype.prod_sum]; simp only [DyadicLaw.total,Finset.prod_pow_eq_pow_sum] + +theorem toLaw_pi (p : ∀ i,DyadicLaw (γ i)) : (pi p).toLaw=Law.pi (fun i => (p i).toLaw) := by + apply Law.ext; funext x + simp only [toLaw,pi,Law.pi,Nat.cast_prod,Finset.prod_div_distrib,Finset.prod_pow_eq_pow_sum] + +variable [DecidableEq α] +theorem toLaw_walk (q : α → DyadicLaw α) (S : ℕ) (hq : ∀ x,(q x).bits=S) (x₀ : α) : + ∀ t,(walk q S hq x₀ t).toLaw=Nat.rec (Law.pure x₀) (fun _ p => p.bind (fun x => (q x).toLaw)) t := by + intro t + induction t with + | zero => simp [walk,toLaw_pure] + | succ t ih => rw [walk,toLaw_bind,ih] + +end DyadicLaw + + +theorem stoppedLaw_toLaw {α : Type*} [Fintype α] [DecidableEq α] + (p : DyadicLaw (Option α)) (fallback : α) (J : ℕ) : + (stoppedLaw p fallback J).toLaw=Law.first p.toLaw fallback J := by + apply Law.ext; funext z + induction J with + | zero => + by_cases h : z=fallback + · subst z; simp [stoppedLaw,stoppedNumerator,DyadicLaw.toLaw,Law.first,Law.pure] + · simp [stoppedLaw,stoppedNumerator,DyadicLaw.toLaw,Law.first,Law.pure,h,Ne.symm h] + | succ J ih => + have hr : (Law.first p.toLaw fallback (J+1)).mass z= + p.toLaw.mass none*(Law.first p.toLaw fallback J).mass z+p.toLaw.mass (some z) := by + change (∑ o : Option α,p.toLaw.mass o*(match o with | none => Law.first p.toLaw fallback J | some y => Law.pure y).mass z)=_ + rw [Fintype.sum_option] + simp [Law.pure] + rw [hr,← ih] + change ((p.count (some z)*2^(p.bits*J)+p.count none*stoppedNumerator p.bits (p.count none) (fun z => p.count (some z)) fallback z J:ℕ):ℝ)/(2:ℝ)^(p.bits*(J+1))=_ + simp only [DyadicLaw.toLaw,stoppedLaw] + push_cast + rw [Nat.mul_succ,pow_add] + field_simp + ring + +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace Law +variable {α : Type*} [Fintype α] {β : α → Type*} [∀ x,Fintype (β x)] + +def sigma (p : Law α) (q : ∀ x, Law (β x)) : Law (Sigma β) where + mass z := p.mass z.1 * (q z.1).mass z.2 + nonneg z := mul_nonneg (p.nonneg _) ((q _).nonneg _) + total := by + rw [Fintype.sum_sigma] + simp_rw [← Finset.mul_sum, (q _).total, mul_one] + exact p.total + +theorem sigma_eq_bind (p : Law α) (q : ∀ x,Law (β x)) : + p.sigma q=p.bind (fun x => (q x).map (Sigma.mk x)) := by + classical + let : DecidableEq (Sigma β) := fun _ _ => Classical.propDecidable _ + apply Law.ext; funext ⟨x,y⟩ + simp only [sigma,bind,map,pure] + have hh (z : α) : (∑ w : β z, (q z).mass w * (if Sigma.mk z w=Sigma.mk x y then 1 else 0))= + if h : z=x then (q x).mass y else 0 := by + by_cases h : z=x + · subst z; simp + · have hn (w : β z) : Sigma.mk z w ≠ Sigma.mk x y := by intro he; exact h (congrArg Sigma.fst he) + simp [h,hn] + change p.mass x * (q x).mass y = ∑ z, p.mass z * (∑ w : β z, (q z).mass w * (if Sigma.mk z w = Sigma.mk x y then 1 else 0)) + simp_rw [hh] + simp + +theorem tv_sigma (p p' : Law α) (q q' : ∀ x,Law (β x)) (δ : ℝ) + (hq : ∀ x,(q x).tv (q' x) ≤ δ) : + (p.sigma q).tv (p'.sigma q') ≤ p.tv p'+δ := by + rw [sigma_eq_bind,sigma_eq_bind] + exact tv_bind p p' _ _ δ (fun x => (tv_map _ _ _).trans (hq x)) + +end Law +namespace DyadicLaw +variable {α : Type*} [Fintype α] {β : α → Type*} [∀ x,Fintype (β x)] + +def sigma (p : DyadicLaw α) (q : ∀ x,DyadicLaw (β x)) (S : ℕ) (hS : ∀ x,(q x).bits=S) : DyadicLaw (Sigma β) where + bits := p.bits+S + count z := p.count z.1*(q z.1).count z.2 + total := by + rw [Fintype.sum_sigma] + simp_rw [← Finset.mul_sum, (q _).total, hS] + rw [← Finset.sum_mul,p.total,pow_add] + +theorem sigma_bits (p : DyadicLaw α) (q : ∀ x,DyadicLaw (β x)) (S : ℕ) (hS : ∀ x,(q x).bits=S) : + (p.sigma q S hS).bits=p.bits+S := rfl + +theorem toLaw_sigma (p : DyadicLaw α) (q : ∀ x,DyadicLaw (β x)) (S : ℕ) (hS : ∀ x,(q x).bits=S) : + (p.sigma q S hS).toLaw=p.toLaw.sigma (fun x => (q x).toLaw) := by + apply Law.ext; funext z + simp only [sigma,toLaw,Law.sigma,Nat.cast_mul,pow_add,hS] + ring + +end DyadicLaw +end +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/GreedyTable.lean b/lean/OAI/Probability/Contingency/GreedyTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b8ee6fddda4e3aa36d6cbc4d19fb32ea48945c4 --- /dev/null +++ b/lean/OAI/Probability/Contingency/GreedyTable.lean @@ -0,0 +1,661 @@ +import Mathlib +import OAI.Probability.Contingency.OuterAccuracy + +namespace OAI + +/-! Greedy Table. -/ + +noncomputable section + + +open scoped BigOperators +namespace Contingency + + +def marginPrefix {m : ℕ} (r : Fin m → ℕ) (t : ℕ) : ℕ := + ∑ i, if i.val < t then r i else 0 + +@[simp] theorem marginPrefix_zero {m : ℕ} (r : Fin m → ℕ) : marginPrefix r 0=0 := by + simp [marginPrefix] + +@[simp] theorem marginPrefix_total {m : ℕ} (r : Fin m → ℕ) : marginPrefix r m=∑ i,r i := by + simp [marginPrefix] + +theorem marginPrefix_mono {m : ℕ} (r : Fin m → ℕ) : Monotone (marginPrefix r) := by + intro a b hab + apply Finset.sum_le_sum + intro i _ + by_cases ha : i.val < a + · simp only [ite_eq_left ha,ite_eq_left (ha.trans_le hab)] + exact le_rfl + · simp only [ite_eq_right ha] + exact Nat.zero_le _ + +theorem marginPrefix_succ {m : ℕ} (r : Fin m → ℕ) (i : Fin m) : + marginPrefix r (i.val+1)=marginPrefix r i.val+r i := by + have he : (fun j : Fin m => if j.val < i.val+1 then r j else 0)= + fun j => (if j.val < i.val then r j else 0)+(if j=i then r i else 0) := by + funext j + by_cases h : j=i + · subst j; simp + · have hj : j.val≠i.val := fun hv => h (Fin.ext hv) + by_cases hji : j.val < i.val + · simp [h,hji,show j.val < i.val+1 by omega] + · simp [h,hji,show ¬ j.val < i.val+1 by omega] + unfold marginPrefix + rw [he,Finset.sum_add_distrib] + simp + + +def intervalOverlap (a b c d : ℕ) : ℕ := min b d-max a c + +theorem intervalOverlap_symm (a b c d : ℕ) : + intervalOverlap a b c d=intervalOverlap c d a b := by + simp [intervalOverlap,min_comm,max_comm] + +theorem intervalOverlap_increment (a b c d : ℕ) (hab : a≤b) (hcd : c≤d) : + intervalOverlap a b c d+(min a d-min a c)=min b d-min b c := by + unfold intervalOverlap + omega + +theorem prefix_increments_sum {n : ℕ} (c : Fin n → ℕ) (a : ℕ) : + (∑ j : Fin n, (min a (marginPrefix c (j.val+1))-min a (marginPrefix c j.val)))= + min a (∑ j,c j) := by + rw [Fin.sum_univ_eq_sum_range (fun t => min a (marginPrefix c (t+1))-min a (marginPrefix c t)) n] + have hm : Monotone (fun t => min a (marginPrefix c t)) := by + intro x y hxy + exact min_le_min_left a (marginPrefix_mono c hxy) + simpa using Finset.sum_range_tsub hm n + + + +def greedyEntries {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) (i : Fin m) (j : Fin n) : ℕ := + intervalOverlap (marginPrefix r i.val) (marginPrefix r (i.val+1)) + (marginPrefix c j.val) (marginPrefix c (j.val+1)) + +theorem greedyEntries_row {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i,r i)=∑ j,c j) (i : Fin m) : ∑ j,greedyEntries r c i j=r i := by + have hs := Finset.sum_congr (s₁:=Finset.univ) (g:=fun j : Fin n => + min (marginPrefix r (i.val+1)) (marginPrefix c (j.val+1))- + min (marginPrefix r (i.val+1)) (marginPrefix c j.val)) rfl + (fun j _ => intervalOverlap_increment (marginPrefix r i.val) + (marginPrefix r (i.val+1)) (marginPrefix c j.val) (marginPrefix c (j.val+1)) + (marginPrefix_mono r (Nat.le_succ _)) (marginPrefix_mono c (Nat.le_succ _))) + rw [Finset.sum_add_distrib,prefix_increments_sum,prefix_increments_sum,← hrc] at hs + have ha : marginPrefix r i.val ≤ ∑ i,r i := by + rw [← marginPrefix_total r] + exact marginPrefix_mono r i.isLt.le + have hb : marginPrefix r (i.val+1) ≤ ∑ i,r i := by + rw [← marginPrefix_total r] + exact marginPrefix_mono r i.isLt + rw [min_eq_left ha,min_eq_left hb] at hs + change (∑ j,greedyEntries r c i j)+marginPrefix r i.val=marginPrefix r (i.val+1) at hs + have hi := marginPrefix_succ r i + omega + +theorem greedyEntries_col {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i,r i)=∑ j,c j) (j : Fin n) : ∑ i,greedyEntries r c i j=c j := by + have he : (fun i => greedyEntries r c i j)=fun i => greedyEntries c r j i := by + funext i + exact intervalOverlap_symm _ _ _ _ + rw [he] + exact greedyEntries_row c r hrc.symm j + +def greedyTable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i,r i)=∑ j,c j) : Tables r c := + ⟨greedyEntries r c,greedyEntries_row r c hrc,greedyEntries_col r c hrc⟩ + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + + + +def greedyCompletion (hrc : (∑ i,r i)=∑ j,c j) (X : GraphState U r c) : + Completion U L r c (graphUnderlying U r c X) := by + have hf := graph_feasible U r c X + have ht : (∑ i,rowNat U L r c (graphUnderlying U r c X) i)= + ∑ j,colNat U L r c (graphUnderlying U r c X) j := by + apply Int.ofNat_inj.mp + push_cast + simp only [rowNat_cast U L r c _ hf,colNat_cast U L r c _ hf] + exact residual_totals U L r c X hrc + exact tableCompletion U L r c _ hf (greedyTable _ _ ht) + + +def positiveLargeEquiv {m : ℕ} (U : ℕ) (r : Fin m → ℕ) (h : ∃ i,U≤r i) : + Fin ((Fintype.card {i // U≤r i}-1)+1) ≃ {i // U≤r i} := by + letI : Nonempty {i // U≤r i} := ⟨⟨h.choose,h.choose_spec⟩⟩ + have hp : 0 < Fintype.card {i // U≤r i} := Fintype.card_pos + exact (Fintype.orderIsoFinOfCardEq _ (by omega)).toEquiv + +section positive +variable (hm : 0 < m) (hn : 0 < n) (hrc : (∑ i,r i)=∑ j,c j) (k : ℕ) +local notation "d" => Parameters.dim m n +local notation "b" => Parameters.bits m n (∑ i,r i) +local notation "C" => Parameters.cap m n (∑ i,r i) +local instance greedyCanonicalTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ +local notation "hdims" => Parameters.dimensions hm hn + + + +def canonicalDraw : DyadicLaw (Tables r c) := by + classical + letI : Nonempty (GraphState (d^20) r c) := graph_nonempty _ r c hrc + let Z := greedyTable r c hrc + let X₀ : GraphState (d^20) r c := Sum.inl (initialTransversal _ r c Z) + let fs := greedyCompletion (d^20) (d^12) r c hrc + by_cases he : EmptyBlock (d^20) r c + · exact emptyOuter d b k r c hdims.1 hdims.2.2.2 fs X₀ Z + · have hlarge : ∃ w : Cell m n,IsLarge (d^20) r c w := by + simpa only [EmptyBlock,IsSmall,not_forall,not_not] using he + have hr : ∃ i,d^20≤r i := ⟨hlarge.choose.1,hlarge.choose_spec.1⟩ + have hc : ∃ j,d^20≤c j := ⟨hlarge.choose.2,hlarge.choose_spec.2⟩ + exact literalOuter d b k C r c (positiveLargeEquiv _ r hr) (positiveLargeEquiv _ c hc) + hrc hdims.1 hdims.2.1 hdims.2.2.1 hdims.2.2.2 + (Parameters.paddedRow_le_cap r c) (by have := Parameters.cap_pow_bits m n (∑ i,r i); omega) fs X₀ Z + +theorem canonicalDraw_bits : (canonicalDraw r c hm hn hrc k).bits=Schedule.R d b k := by + classical + let : Nonempty (GraphState (d^20) r c) := graph_nonempty _ r c hrc + unfold canonicalDraw + split_ifs + · exact emptyOuter_bits _ _ _ _ _ _ _ _ _ _ + · exact literalOuter_bits _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + +theorem canonicalDraw_tv (hk : 1≤k) : + letI := tables_nonempty r c hrc + (canonicalDraw r c hm hn hrc k).toLaw.tv (Law.uniform (Tables r c)) ≤ (2:ℝ)^(-(k:ℤ)) := by + classical + let := tables_nonempty r c hrc + let : Nonempty (GraphState (d^20) r c) := graph_nonempty _ r c hrc + unfold canonicalDraw + split_ifs with he + · exact emptyOuter_tv d b k C r c he hrc hdims.1 hdims.2.1 hdims.2.2.1 hdims.2.2.2 + (Parameters.dimension_le_bits _ _ _) hk (Parameters.cap_pos _ _ _) (Parameters.threshold_le_cap _ _ _) + (Parameters.paddedRow_le_cap r c) (Parameters.cap_pow_bits _ _ _) _ _ _ + · exact literalOuter_tv d b k C r c _ _ hrc hdims.1 hdims.2.1 hdims.2.2.1 hdims.2.2.2 + (Parameters.dimension_le_bits _ _ _) hk (Parameters.cap_pos _ _ _) (Parameters.threshold_le_cap _ _ _) + (Parameters.paddedRow_le_cap r c) (Parameters.cap_pow_bits _ _ _) _ _ _ + +end positive +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace Law +variable {α : Type*} [Fintype α] + +theorem point_tv (p q : Law α) (x : α) : |p.mass x-q.mass x|≤p.tv q := by + classical + let f := fun y => p.mass y-q.mass y + have hz : (∑ y,f y)=0 := by simp [f,Finset.sum_sub_distrib,p.total,q.total] + have he : (∑ y∈Finset.univ.erase x,f y)= -f x := by + have hh := Finset.sum_erase_add (s:=Finset.univ) f (Finset.mem_univ x) + rw [hz] at hh + linarith + have ha := Finset.abs_sum_le_sum_abs (s:=Finset.univ.erase x) (f:=f) + rw [he,abs_neg] at ha + have hh := Finset.sum_erase_add (s:=Finset.univ) (fun y => |f y|) (Finset.mem_univ x) + change |f x|≤(∑ y,|f y|)/2 + linarith + + +theorem correction_domination [Nonempty α] (p : Law α) (δ : ℝ) + (hδ0 : 0≤δ) (hδ1 : δ≤1) (hM : (Fintype.card α:ℝ)*δ≤1) + (hTV : p.tv (uniform α)≤δ^2) (x : α) : + (1-δ)*p.mass x≤1/(Fintype.card α:ℝ) := by + have hN : (0:ℝ) 0 + | aw::xs => aw.2+total xs + + + +def scan : List (α×ℕ) → ℕ → Option α + | [], _ => none + | aw::xs,z => if z if aw.1=a then aw.2 else 0)).sum + +theorem scan_none_iff (xs : List (α×ℕ)) (z : ℕ) : scan xs z=none ↔ total xs≤z := by + induction xs generalizing z with + | nil => simp [scan,total] + | cons aw xs ih => + simp only [scan,total] + split_ifs with h + · simp; omega + · rw [ih]; omega + +theorem scan_some_lt (xs : List (α×ℕ)) (z : ℕ) (a : α) (h : scan xs z=some a) : + z simp [total,weight] + | cons aw xs ih => + rw [total,Finset.sum_range_add] + have hlo : (∑ z∈Finset.range aw.2,if scan (aw::xs) z=some a then 1 else 0)= + if aw.1=a then aw.2 else 0 := by + calc + _ = ∑ _∈Finset.range aw.2,if aw.1=a then 1 else 0 := by + apply Finset.sum_congr rfl + intro z hz + have he : scan (aw::xs) z=some aw.1 := by simp [scan,Finset.mem_range.mp hz] + rw [he]; simp + _ = _ := by by_cases h : aw.1=a <;> simp [h] + have hhi : (∑ z∈Finset.range (total xs),if scan (aw::xs) (aw.2+z)=some a then 1 else 0)=weight xs a := by + simpa only [scan,show ∀ z,¬aw.2+z scan xs z.val) + +theorem trial_count [DecidableEq α] [Fintype α] (xs : List (α×ℕ)) (bits : ℕ) + (hb : total xs≤2^bits) (a : α) : (trial xs bits).count (some a)=weight xs a := by + rw [trial,DyadicLaw.map_count] + change (∑ z : Fin (2^bits),if scan xs z.val=some a then 1 else 0)=_ + rw [Fin.sum_univ_eq_sum_range (fun z : ℕ => if scan xs z=some a then 1 else 0) (2^bits)] + exact scan_count_padded xs a _ hb + + +def visits : List (α×ℕ) → ℕ → ℕ + | [],_ => 0 + | aw::xs,z => if z simp [visits] + | cons aw xs ih => + simp only [visits,List.length_cons] + split_ifs + · omega + · have := ih (z-aw.2); omega + + +theorem subtraction_bound (z w bits : ℕ) (hz : z<2^bits) : z-w<2^bits := + (Nat.sub_le z w).trans_lt hz + +end IntegerDraw +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.IntegerDraw +noncomputable section +variable {α : Type*} [Fintype α] [DecidableEq α] + +def entries (v : α → ℕ) : List (α×ℕ) := Finset.univ.toList.map (fun a => (a,v a)) + +omit [Fintype α] [DecidableEq α] in +theorem total_eq_sum (xs : List (α×ℕ)) : total xs=(xs.map Prod.snd).sum := by + induction xs with + | nil => rfl + | cons aw xs ih => simp [total,ih] + +omit [DecidableEq α] in +theorem entries_total (v : α → ℕ) : total (entries v)=∑ a,v a := by + rw [total_eq_sum] + simp only [entries,List.map_map,Function.comp_def,Finset.sum_map_toList] + +theorem entries_weight (v : α → ℕ) (a : α) : weight (entries v) a=v a := by + simp [weight,entries,List.map_map,Finset.sum_map_toList] + +theorem word_bound (V : ℕ) (hV : 0 (failure v)^j) Filter.atTop (nhds 0) := + tendsto_pow_atTop_nhds_zero_of_lt_one (failure_bounds v hv).1 (by linarith [(failure_bounds v hv).2]) + +theorem rejection_summable (hv : 0<∑ a,v a) : Summable (fun j : ℕ => (failure v)^j) := by + apply summable_geometric_of_abs_lt_one + rw [abs_of_nonneg (failure_bounds v hv).1] + linarith [(failure_bounds v hv).2] + +theorem expected_words (hv : 0<∑ a,v a) : (∑' j : ℕ,(failure v)^j)<2 := by + have hf := failure_bounds v hv + rw [tsum_geometric_of_abs_lt_one (by rw [abs_of_nonneg hf.1]; linarith : |failure v|<1)] + rw [← one_div,div_lt_iff₀ (by linarith : 0<1-failure v)] + linarith + +theorem rejection_exact (hv : 0<∑ a,v a) (a : α) : + (∑' j : ℕ,stoppingMass v j a)=(v a:ℝ)/(∑ a,v a:ℕ) := by + have hf := failure_bounds v hv + have hsum : (0:ℝ)<(∑ a,v a:ℕ) := by exact_mod_cast hv + simp only [stoppingMass,tsum_mul_right] + rw [tsum_geometric_of_abs_lt_one (by rw [abs_of_nonneg hf.1]; linarith : |failure v|<1)] + simp only [failure,DyadicLaw.toLaw,drawTrial_none,drawTrial_some] + have hle : (∑ a,v a)≤2^bits v := Nat.le_pow_clog (by omega) _ + change (1-((2^bits v-(∑ a,v a):ℕ):ℝ)/(2:ℝ)^bits v)⁻¹*((v a:ℝ)/(2:ℝ)^bits v)=_ + rw [Nat.cast_sub hle,Nat.cast_pow,Nat.cast_ofNat] + field_simp [hsum.ne'] + ring_nf + field_simp [hsum.ne'] + +end +end Contingency.IntegerDraw + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section + +variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + +theorem table_entry_le_total (X : Tables r c) (i : Fin m) (j : Fin n) : X.val i j≤∑ i,r i := by + have hx := Finset.single_le_sum (fun j _ => Nat.zero_le (X.val i j)) (Finset.mem_univ j) + rw [X.property.1 i] at hx + exact hx.trans (Finset.single_le_sum (fun i _ => Nat.zero_le (r i)) (Finset.mem_univ i)) + +theorem table_card_cap (C : ℕ) (hN : (∑ i,r i)≤C) : Nat.card (Tables r c)≤(C+1)^(m*n) := by + let : Fintype (Tables r c) := Fintype.ofFinite _ + let f : Tables r c → (Fin m×Fin n → Fin (C+1)) := + fun X w => ⟨X.val w.1 w.2,by have := (table_entry_le_total r c X w.1 w.2).trans hN; omega⟩ + have hinj : Function.Injective f := by + intro X Y h + apply Subtype.ext + funext i j + exact congrArg Fin.val (congrFun h (i,j)) + have hh := Fintype.card_le_of_injective f hinj + rw [Nat.card_eq_fintype_card] + simpa using hh + +theorem table_card_dyadic {d b C : ℕ} (hmn : m*n≤d) (hN : (∑ i,r i)≤C) (hCb : C+1≤2^b) : + Nat.card (Tables r c)≤2^(d*b) := by + calc + _ ≤ (C+1)^(m*n) := table_card_cap r c C hN + _ ≤ (C+1)^d := Nat.pow_le_pow_right (by omega) hmn + _ ≤ (2^b)^d := Nat.pow_le_pow_left hCb _ + _ = _ := by rw [← pow_mul]; congr 1; ring + +namespace Parameters + +def D (m n N : ℕ) : ℕ := dim m n^6*bits m n N^2 + +theorem rare_exponent {d b : ℕ} (hd : 14≤d) (hb : d≤b) : 500*(d*b)≤d^6*b^2 := by + have hp : 14^5≤d^5 := Nat.pow_le_pow_left hd _ + have hb1 : 1≤b := by omega + have hh : 500≤d^5*b := by nlinarith + have hmul := Nat.mul_le_mul_left (d*b) hh + calc + _ = (d*b)*500 := by ring + _ ≤ (d*b)*(d^5*b) := hmul + _ = _ := by ring + +theorem rare_weight {d b : ℕ} (hd : 14≤d) (hb : d≤b) : + (2:ℝ)^(-((d^6*b^2:ℕ):ℤ))*(2:ℝ)^(500*(d*b))≤1 := by + rw [zpow_neg,zpow_natCast,← div_eq_inv_mul] + apply (div_le_one (by positivity)).mpr + exact pow_le_pow_right₀ (by norm_num) (rare_exponent hd hb) + +theorem table_card_D (hm : 0 < m) (hn : 0 < n) : + Nat.card (Tables r c)≤2^D m n (∑ i,r i) := by + have dims := dimensions hm hn + have hN : (∑ i,r i)≤cap m n (∑ i,r i) := by unfold cap; omega + apply (table_card_dyadic r c dims.2.2.2 hN (cap_pow_bits _ _ _)).trans + apply Nat.pow_le_pow_right (by norm_num) + have h := rare_exponent dims.1 (dimension_le_bits m n (∑ i,r i)) + unfold D + omega + +end Parameters +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + (hm : 0 < m) (hn : 0 < n) (hrc : (∑ i,r i)=∑ j,c j) +local instance greedyResidualTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ +local notation "D" => Parameters.D m n (∑ i,r i) +local notation "p" => PaddedGraph.canonicalDraw r c hm hn hrc (2*D) + +include hm hn in +theorem correction_accuracy_positive : 1≤2*D := by + have hd := (Parameters.dimensions hm hn).1 + have hb := Parameters.dimension_le_bits m n (∑ i,r i) + have hD : 0 (IntegerDraw.failure (canonicalResidual r c hm hn hrc))^j) + Filter.atTop (nhds 0) ∧ + Summable (fun j : ℕ => (IntegerDraw.failure (canonicalResidual r c hm hn hrc))^j) ∧ + (∑' j : ℕ,(IntegerDraw.failure (canonicalResidual r c hm hn hrc))^j)<2 := by + classical + exact ⟨IntegerDraw.rejection_tail _ (canonicalResidual_pos_total r c hm hn hrc), + IntegerDraw.rejection_summable _ (canonicalResidual_pos_total r c hm hn hrc), + IntegerDraw.expected_words _ (canonicalResidual_pos_total r c hm hn hrc)⟩ + +end +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/GridCover.lean b/lean/OAI/Probability/Contingency/GridCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..15e07f7521fbbf8d9bee5c33c5ca22fabd4d7b23 --- /dev/null +++ b/lean/OAI/Probability/Contingency/GridCover.lean @@ -0,0 +1,675 @@ +import Mathlib +import OAI.Probability.Contingency.DenseAnalytic + +namespace OAI + +/-! Grid Cover. -/ + +noncomputable section + +open Set MeasureTheory +open Set MeasureTheory +open scoped Pointwise +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} +open Contingency.Interpolation + +theorem neighbors_symm (v w : Fin q → ℕ) (i : Fin q) (hn : neighbors v w i) : neighbors w v i := + ⟨hn.1.symm,fun j hj => (hn.2 j hj).symm⟩ + +theorem neighbors_unique (v w : Fin q → ℕ) (i j : Fin q) + (hi : neighbors v w i) (hj : neighbors v w j) : i=j := by + by_contra hne + have he := hj.2 i hne + rcases hi.1 with h | h <;> omega + +theorem faceBox_swap (v w : Vertex q K) (i : Fin q) (r : ℝ) + (hn : neighbors (corner v) (corner w) i) : faceBox v w i r=faceBox w v i r := by + unfold faceBox + congr 1 <;> funext j <;> split_ifs with hj + · rw [max_comm] + · have hh := hn.2 j hj + dsimp [corner] at hh + rw [hh] + · rw [max_comm] + · have hh := hn.2 j hj + dsimp [corner] at hh + rw [hh] + +def Cut (V : Finset (Vertex q K)) := + {e : Vertex q K×Vertex q K // e.1∈V ∧ e.2∉V ∧ ∃ i,neighbors (corner e.1) (corner e.2) i} + +instance cutFintype (V : Finset (Vertex q K)) : Fintype (Cut V) := by unfold Cut; exact Fintype.ofFinite _ + +def Cut.coord {V : Finset (Vertex q K)} (e : Cut V) : Fin q := Classical.choose e.property.2.2 + +theorem Cut.adjacent {V : Finset (Vertex q K)} (e : Cut V) : + neighbors (corner e.val.1) (corner e.val.2) e.coord := Classical.choose_spec e.property.2.2 + +def Cut.neighborhood {V : Finset (Vertex q K)} (e : Cut V) (r : ℝ) : OpenBox q := faceBox e.val.1 e.val.2 e.coord r + +theorem cut_cover_endpoints (V : Finset (Vertex q K)) (v w : Vertex q K) (hv : v∈V) (hw : w∉V) + (x z : Fin q → ℝ) (hx : inside (corner v) x) (hz : inside (corner w) z) + (r : ℝ) (hr : r ≤ 1) (hc : ∀ i,|x i-z i| hnz ((mem_boxes V z).mpr ⟨w,hh,hwz⟩) + apply cut_cover_endpoints V v w hv hw x z hvx hwz (t*K) hr + intro i + have hd : |x i-y i|<(K:ℝ) := by rw [abs_lt]; constructor <;> linarith [(hx' i).1,(hx' i).2,(hy' i).1,(hy' i).2] + rw [he'] + have heq : x i-((1-t)*x i+t*y i)=t*(x i-y i) := by ring + rw [heq,abs_mul,abs_of_pos ht] + exact mul_lt_mul_of_pos_left hd ht + +end +end Contingency.Grid + + + + + +open Set MeasureTheory +open scoped BigOperators +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} +open Contingency.Interpolation + +theorem box_integrable (F : GoodWeight q) (B : OpenBox q) : IntegrableOn F.f B.carrier := by + simpa only [boxUnion,Finset.mem_singleton,iUnion_iUnion_eq_left] using F.integrable {B} + +theorem bin_volume (v : Vertex q K) : volume (bin v).carrier=1 := by + simp [bin,OpenBox.carrier,volume_pi_pi] + +theorem box_volume_real (B : OpenBox q) (hp : ∀ i,B.lower i ≤ B.upper i) : + (volume B.carrier).toReal=∏ i,(B.upper i-B.lower i) := by + simp only [OpenBox.carrier,volume_pi_pi,Real.volume_Ioo,ENNReal.toReal_prod] + congr 1 + funext i + exact ENNReal.toReal_ofReal (sub_nonneg.mpr (hp i)) + +theorem faceBox_volume (v w : Vertex q K) (i : Fin q) (r : ℝ) (hr : 0 ≤ r) : + (volume (faceBox v w i r).carrier).toReal=2*r*(1+2*r)^(q-1) := by + have hlen (j : Fin q) : (faceBox v w i r).upper j-(faceBox v w i r).lower j= + if j=i then 2*r else 1+2*r := by + dsimp [faceBox] + split_ifs <;> ring + rw [box_volume_real _ (fun j => sub_nonneg.mp (by rw [hlen]; split_ifs <;> positivity))] + simp_rw [hlen] + classical + rw [← Finset.mul_prod_erase Finset.univ (fun j => if j=i then 2*r else 1+2*r) (Finset.mem_univ i)] + simp only [ite_true] + have he : (∏ j∈Finset.univ.erase i,if j=i then 2*r else 1+2*r)=(1+2*r)^(q-1) := by + calc + _ = ∏ _j∈Finset.univ.erase i,(1+2*r) := Finset.prod_congr rfl (fun j hj => ite_eq_right (Finset.ne_of_mem_erase hj)) + _ = _ := by simp + rw [he] + +theorem integral_boxes (F : GoodWeight q) (V : Finset (Vertex q K)) : + (∫ x in boxUnion (boxes V),F.f x)=∑ v∈V,∫ x in (bin v).carrier,F.f x := by + have hs : boxUnion (boxes V)=⋃ v∈V,(bin v).carrier := by + ext x + simp only [mem_boxes,Set.mem_iUnion,mem_bin] + constructor <;> rintro ⟨v,hv,hx⟩ <;> exact ⟨v,hv,hx⟩ + rw [hs] + apply integral_biUnion_finset V + · intro v _; exact (bin v).isOpen.measurableSet + · intro v _ w _ hne; exact bins_disjoint hne + · intro v _; exact box_integrable F (bin v) + +theorem bin_integral_bounds (F : GoodWeight q) (W : Vertex q K → ℝ) + (hp : ∀ v x,x∈(bin v).carrier → W v/4 ≤ F.f x ∧ F.f x ≤ 4*W v) (v : Vertex q K) : + W v/4 ≤ ∫ x in (bin v).carrier,F.f x ∧ (∫ x in (bin v).carrier,F.f x) ≤ 4*W v := by + have hi := box_integrable F (bin v) + have hj (a : ℝ) : IntegrableOn (fun _ : Fin q → ℝ => a) (bin v).carrier := + integrableOn_const (by rw [bin_volume]; exact ENNReal.one_ne_top) + have hc (a : ℝ) : (∫ _ in (bin v).carrier,a)=a := by simp [bin_volume,Measure.real] + constructor + · rw [← hc (W v/4)] + exact setIntegral_mono_on (hj _) hi (bin v).isOpen.measurableSet (fun x hx => (hp v x hx).1) + · rw [← hc (4*W v)] + exact setIntegral_mono_on hi (hj _) (bin v).isOpen.measurableSet (fun x hx => (hp v x hx).2) + +theorem boxes_integral_bounds (F : GoodWeight q) (W : Vertex q K → ℝ) + (hp : ∀ v x,x∈(bin v).carrier → W v/4 ≤ F.f x ∧ F.f x ≤ 4*W v) (V : Finset (Vertex q K)) : + (∑ v∈V,W v)/4 ≤ ∫ x in boxUnion (boxes V),F.f x ∧ + (∫ x in boxUnion (boxes V),F.f x) ≤ 4*∑ v∈V,W v := by + rw [integral_boxes] + constructor + · rw [Finset.sum_div] + exact Finset.sum_le_sum fun v _ => (bin_integral_bounds F W hp v).1 + · rw [Finset.mul_sum] + exact Finset.sum_le_sum fun v _ => (bin_integral_bounds F W hp v).2 + +end +end Contingency.Grid + + + + + +open Set MeasureTheory +open scoped BigOperators Pointwise +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} +open Contingency.Interpolation + +theorem face_volume_bound (d : ℝ) (hd : 1 ≤ d) (hq : (q:ℝ) ≤ d) + (v w : Vertex q K) (i : Fin q) : + (volume (faceBox v w i (1/(4*d))).carrier).toReal ≤ 1 := by + have hd0 : 0 hi e)) + filter_upwards [minkowski_cut_cover V t ht ht1 hr] with z hz + have hnon (e : Cut V) : 0 ≤ (e.neighborhood (t*K)).carrier.indicator F.f z := by + by_cases he : z∈(e.neighborhood (t*K)).carrier <;> simp [he,(F.positive z).le] + by_cases hzG : z∈G + · obtain ⟨e,he⟩ := hz hzG + rw [Set.indicator_of_mem hzG] + calc + _ = (e.neighborhood (t*K)).carrier.indicator F.f z := (Set.indicator_of_mem he _).symm + _ ≤ _ := Finset.single_le_sum (fun e _ => hnon e) (Finset.mem_univ e) + · rw [Set.indicator_of_notMem hzG] + exact Finset.sum_nonneg fun e _ => hnon e + rw [integral_indicator hG,integral_finsetSum _ (fun e _ => hi e)] at hh + simp_rw [integral_indicator ((Cut.neighborhood _ _).isOpen.measurableSet)] at hh + exact hh + +end +end Contingency.Grid + + + + + +open Set MeasureTheory +open scoped BigOperators Pointwise +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} +open Contingency.Interpolation + +def border (V : Finset (Vertex q K)) (W : Vertex q K → ℝ) : ℝ := + ∑ e : Cut V,min (W e.val.1) (W e.val.2) + +def Cut.reverse (V : Finset (Vertex q K)) : Cut V ≃ Cut Vᶜ where + toFun e := ⟨(e.val.2,e.val.1),by + refine ⟨by simpa using e.property.2.1,by simpa using e.property.1,?_⟩ + exact ⟨e.coord,neighbors_symm _ _ _ e.adjacent⟩⟩ + invFun e := ⟨(e.val.2,e.val.1),by + refine ⟨by simpa using e.property.2.1,by simpa using e.property.1,?_⟩ + exact ⟨e.coord,neighbors_symm _ _ _ e.adjacent⟩⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem border_compl (V : Finset (Vertex q K)) (W : Vertex q K → ℝ) : + border Vᶜ W=border V W := by + unfold border + rw [← (Cut.reverse V).sum_comp (fun e => min (W e.val.1) (W e.val.2))] + apply Finset.sum_congr rfl + intro e _ + exact min_comm _ _ + +theorem mass_partition (F : GoodWeight q) (V : Finset (Vertex q K)) : + (∫ x in boxUnion (boxes V),F.f x)+(∫ x in boxUnion (boxes Vᶜ),F.f x)= + ∫ x in (cube q K).carrier,F.f x := by + rw [integral_boxes,integral_boxes,Finset.sum_add_sum_compl] + rw [← integral_boxes F Finset.univ] + exact setIntegral_congr_set cube_ae_union + +theorem boxes_nonempty (V : Finset (Vertex q K)) (hV : V.Nonempty) : + (boxUnion (boxes V)).Nonempty := by + obtain ⟨v,hv⟩ := hV + refine ⟨fun i => (v i:ℝ)+1/2,(mem_boxes V _).mpr ⟨v,hv,?_⟩⟩ + intro i + dsimp [corner] + constructor <;> linarith + +theorem face_integral_bound (F : GoodWeight q) (W : Vertex q K → ℝ) + (hW : ∀ v,0 ≤ W v) (d : ℝ) (hd : 1 ≤ d) (hq : (q:ℝ) ≤ d) + (hp : ∀ (v w : Vertex q K) (i : Fin q),neighbors (corner v) (corner w) i → + ∀ x,x∈(faceBox v w i (1/(4*d))).carrier → F.f x ≤ 4*min (W v) (W w)) + (V : Finset (Vertex q K)) (e : Cut V) : + (∫ x in (e.neighborhood (1/(4*d))).carrier,F.f x) ≤ 4*min (W e.val.1) (W e.val.2) := by + let B := e.neighborhood (1/(4*d)) + calc + _ ≤ ∫ _x in B.carrier,4*min (W e.val.1) (W e.val.2) := + setIntegral_mono_on (box_integrable F B) (integrableOn_const B.isBounded.measure_lt_top.ne) B.isOpen.measurableSet + (hp _ _ _ e.adjacent) + _ = (volume B.carrier).toReal*(4*min (W e.val.1) (W e.val.2)) := by simp [Measure.real] + _ ≤ _ := by + exact mul_le_of_le_one_left (mul_nonneg (by norm_num) (le_min (hW _) (hW _))) (face_volume_bound d hd hq _ _ _) + +theorem small_side_border (F : GoodWeight q) (W : Vertex q K → ℝ) + (hW : ∀ v,0 ≤ W v) (d : ℝ) (hd : 1 ≤ d) (hq : (q:ℝ) ≤ d) (hK : 1 ≤ K) + (hc : ∀ x y (α β : ℝ),0 ≤ α → 0 ≤ β → α+β=1 → F.f x^α*F.f y^β ≤ F.f (α • x+β • y)) + (hb : ∀ v x,x∈(bin v).carrier → W v/4 ≤ F.f x ∧ F.f x ≤ 4*W v) + (hp : ∀ (v w : Vertex q K) (i : Fin q),neighbors (corner v) (corner w) i → + ∀ x,x∈(faceBox v w i (1/(4*d))).carrier → F.f x ≤ 4*min (W v) (W w)) + (V : Finset (Vertex q K)) (hV : V.Nonempty) + (hsmall : 2*(∫ x in boxUnion (boxes V),F.f x) ≤ ∫ x in (cube q K).carrier,F.f x) : + Real.log 2/(64*d*K)*(∑ v∈V,W v) ≤ border V W := by + let t : ℝ := 1/(4*d*K) + have hd0 : 0 hc x y (1-t) t (by linarith) ht.le (by ring)) + have hcover := integral_cover F V t ht ht1 hr1 + rw [hr] at hcover + have hface : (∑ e : Cut V,∫ x in (e.neighborhood (1/(4*d))).carrier,F.f x) ≤ 4*border V W := by + unfold border + rw [Finset.mul_sum] + exact Finset.sum_le_sum fun e _ => face_integral_bound F W hW d hd hq hp V e + have hlower := (boxes_integral_bounds F W hb V).1 + have hlog : 0 v i + + +def exponentWeight (g : (Fin q → ℝ) → ℝ) (v : Vertex q K) : ℝ := + (2:ℝ)^(-(⌊g (realCorner v)⌋:ℝ)) + +theorem exponentWeight_pos (g : (Fin q → ℝ) → ℝ) (v : Vertex q K) : + 0 linarith [hh.1,hh.2] + +theorem face_distance (v w : Vertex q K) (i : Fin q) (r : ℝ) (hr : 0 ≤ r) + (hn : neighbors (corner v) (corner w) i) (x : Fin q → ℝ) + (hx : x∈(faceBox v w i r).carrier) : ‖x-realCorner v‖ ≤ 1+r := by + apply (pi_norm_le_iff_of_nonneg (by linarith : (0:ℝ) ≤ 1+r)).mpr + intro j + have hh := (Set.mem_pi.mp hx) j (Set.mem_univ j) + simp only [Set.mem_Ioo,faceBox] at hh + simp only [Pi.sub_apply,realCorner,Real.norm_eq_abs,abs_le] + by_cases hj : j=i + · subst j + simp only [ite_true,Nat.cast_max] at hh + have hn' := hn.1 + dsimp [corner] at hn' + rcases hn' with h | h + · have he : (v i:ℝ)+1=(w i:ℝ) := by exact_mod_cast h + have hm : max (v i:ℝ) (w i:ℝ)=(w i:ℝ) := max_eq_right (by linarith) + rw [hm] at hh + constructor <;> linarith [hh.1,hh.2] + · have he : (w i:ℝ)+1=(v i:ℝ) := by exact_mod_cast h + have hm : max (v i:ℝ) (w i:ℝ)=(v i:ℝ) := max_eq_left (by linarith) + rw [hm] at hh + constructor <;> linarith [hh.1,hh.2] + · simp only [hj,ite_false] at hh + constructor <;> linarith [hh.1,hh.2] + +theorem weight_bin_comparison (g : (Fin q → ℝ) → ℝ) (L : ℝ) (hL : 0 ≤ L) (hL1 : L ≤ 1) + (hg : ∀ x y,|g x-g y| ≤ L*‖x-y‖) + (v : Vertex q K) (x : Fin q → ℝ) (hx : x∈(bin v).carrier) : + exponentWeight g v/4 ≤ (2:ℝ)^(-g x) ∧ (2:ℝ)^(-g x) ≤ 4*exponentWeight g v := by + have hh : |g x-g (realCorner v)| ≤ 1 := + (hg x (realCorner v)).trans ((mul_le_mul_of_nonneg_left (bin_distance v x hx) hL).trans (by simpa using hL1)) + constructor + · exact exponentWeight_lower g v x (abs_le.mp hh).2 + · apply exponentWeight_upper + linarith only [(abs_le.mp hh).1] + +theorem weight_face_comparison (g : (Fin q → ℝ) → ℝ) (L r : ℝ) (hL : 0 ≤ L) (hr : 0 ≤ r) + (hLr : L*(1+r) ≤ 2) (hg : ∀ x y,|g x-g y| ≤ L*‖x-y‖) + (v w : Vertex q K) (i : Fin q) (hn : neighbors (corner v) (corner w) i) + (x : Fin q → ℝ) (hx : x∈(faceBox v w i r).carrier) : + (2:ℝ)^(-g x) ≤ 4*min (exponentWeight g v) (exponentWeight g w) := by + have hv : (2:ℝ)^(-g x) ≤ 4*exponentWeight g v := by + apply exponentWeight_upper + have hh := (hg x (realCorner v)).trans ((mul_le_mul_of_nonneg_left (face_distance v w i r hr hn x hx) hL).trans hLr) + linarith only [(abs_le.mp hh).1] + have hw : (2:ℝ)^(-g x) ≤ 4*exponentWeight g w := by + apply exponentWeight_upper + have hx' : x∈(faceBox w v i r).carrier := by rw [← faceBox_swap v w i r hn]; exact hx + have hh := (hg x (realCorner w)).trans ((mul_le_mul_of_nonneg_left (face_distance w v i r hr (neighbors_symm _ _ _ hn) x hx') hL).trans hLr) + linarith only [(abs_le.mp hh).1] + rw [mul_min_of_nonneg _ _ (by norm_num : (0:ℝ) ≤ 4)] + exact le_min hv hw + +end +end Contingency.Grid + + + + + +open Set MeasureTheory +open scoped BigOperators Pointwise +namespace Contingency.Dense +noncomputable section +variable {a c q K : ℕ} +open Contingency.Grid Contingency.Interpolation + +def binExponent (e : Fin q ≃ Fin a×Fin c) (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (d : ℝ) (x : Fin q → ℝ) : ℝ := + d^4*penalty R P w (d^8) d (fun s => x (e.symm s)) + +def binWeight (e : Fin q ≃ Fin a×Fin c) (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (d : ℝ) : Vertex q K → ℝ := exponentWeight (binExponent e R P w d) + +theorem exponent_lipschitz (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 1 ≤ d) (he : (a*c:ℕ) ≤ d) + (hR : ∀ i,0 x (e.symm s) + let v : Fin a×Fin c → ℝ := fun s => y (e.symm s) + have hn : ‖u-v‖ ≤ ‖x-y‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr + intro s + exact norm_le_pi_norm (x-y) (e.symm s) + have hh := penalty_difference R P w (d^8) d (d/d^8*‖u-v‖) (by positivity) u v + (fun i j => normalized_lipschitz R P w (d^8) d (by positivity) he hR hP hRmax hPmax hw0 hw u v i j) + have hcoef : d^4*(d/d^8) ≤ 1 := by + have hid : d^4*(d/d^8)=1/d^3 := by field_simp + rw [hid] + exact (div_le_one (by positivity)).mpr (one_le_pow₀ hd) + unfold binExponent + rw [← mul_sub,abs_mul,abs_of_nonneg (by positivity : 0 ≤ d^4)] + calc + _ ≤ d^4*(d/d^8*‖u-v‖) := mul_le_mul_of_nonneg_left hh (by positivity) + _ ≤ ‖u-v‖ := by nlinarith only [mul_le_mul_of_nonneg_right hcoef (norm_nonneg (u-v))] + _ ≤ _ := hn + +theorem bin_density_eq (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (x : Fin q → ℝ) : + (densityWeight e R P w (d^8) d (d^4) (by positivity)).f x=(2:ℝ)^(-binExponent e R P w d x) := by + simp only [densityWeight,density,binExponent,neg_mul] + + + +theorem bin_border_bound (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 1 ≤ d) (he : (a*c:ℕ) ≤ d) (hq : (q:ℝ) ≤ d) (hK : 1 ≤ K) + (hR : ∀ i,0 (exponentWeight_pos _ v).le) d hd hq hK + · intro x y α β ha hb hab + exact densityWeight_logconcave e R P w (d^8) d (d^4) (by positivity) x y α β ha hb hab + · intro v x hx + rw [show F.f x=(2:ℝ)^(-binExponent e R P w d x) from bin_density_eq _ _ _ _ _ _] + exact weight_bin_comparison _ 1 (by norm_num) le_rfl hlip v x hx + · intro v w' i hn x hx + rw [show F.f x=(2:ℝ)^(-binExponent e R P w d x) from bin_density_eq _ _ _ _ _ _] + apply weight_face_comparison _ 1 (1/(4*d)) (by norm_num) (by + have hd0 : 0 le_min (exponentWeight_pos _ _).le (exponentWeight_pos _ _).le + have hc : 1/(100000*d^2*K) ≤ (1/(16*d))*(Real.log 2/(64*d*K)) := by + apply (div_le_iff₀ (by positivity : 0 < 100000*d^2*K)).mpr + have hh : (1/(16*d))*(Real.log 2/(64*d*K))*(100000*d^2*K)=3125/32*Real.log 2 := by field_simp; norm_num + rw [hh] + linarith only [Real.log_two_gt_d9] + have hmin : 0 ≤ min (∑ v∈V,binWeight e R P w d v) (∑ v∈Vᶜ,binWeight e R P w d v) := + le_min (Finset.sum_nonneg fun v _ => (exponentWeight_pos _ v).le) (Finset.sum_nonneg fun v _ => (exponentWeight_pos _ v).le) + calc + _ ≤ (1/(16*d))*(Real.log 2/(64*d*K))*min (∑ v∈V,binWeight e R P w d v) (∑ v∈Vᶜ,binWeight e R P w d v) := mul_le_mul_of_nonneg_right hc hmin + _ ≤ (1/(16*d))*border V (binWeight e R P w d) := by rw [mul_assoc]; exact mul_le_mul_of_nonneg_left hb (by positivity) + _ ≤ _ := mul_le_mul_of_nonneg_right hp hn + +end +end Contingency.Dense + + + + + +open Set MeasureTheory +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +variable {a c q K : ℕ} +open Contingency.Grid Contingency.Interpolation + +theorem region_volume_pos (f : (Fin (a+1)×Fin (c+1)) → (Fin q → ℝ) → ℝ) + (hf : ∀ i,Continuous (f i)) (u : Fin q → ℝ) (hu : ∀ i,0 isOpen_lt continuous_const (hf i) + exact (ho.measure_pos volume ⟨u,hu⟩).trans_le (measure_mono (fun x hx i => (hx i).le)) + +theorem dense_density_volume (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 4 ≤ d) (hq : (q:ℝ) ≤ d) (u : Fin q → ℝ) + (hu : ∀ i,1/(2*d) ≤ constraints e R P w i u) (S : Set (Fin q → ℝ)) : + (∫⁻ x in S,ENNReal.ofReal ((densityWeight e R P w (d^8) d (d^4) (by positivity)).f x)) ≤ + 4*volume (region (constraints e R P w) 0) := by + let p (x : Fin q → ℝ) := penalty R P w (d^8) d (fun s => x (e.symm s)) + have hd0 : 0 continuous_apply _)).measurable + (fun x => penalty_nonneg _ _ _ _ _ _) (d^4) (by positivity) S + intro j + have hsub : {x | p x < ((j:ℝ)+1)/d^4} ∩ S ⊆ + region (constraints e R P w) (-(d/d^8+((j:ℝ)+1)/d^4)) := by + intro x hx i + have hh := le_penalty R P w (d^8) d (fun s => x (e.symm s)) i.1 i.2 + have hj := hx.1 + change p x < _ at hj + change -constraints e R P w i x-d/d^8 ≤ p x at hh + linarith only [hh,hj] + calc + _ ≤ volume (region (constraints e R P w) (-(d/d^8+((j:ℝ)+1)/d^4))) := measure_mono hsub + _ ≤ ENNReal.ofReal (Real.exp (2*d^2*(d/d^8+((j:ℝ)+1)/d^4)))*volume (region (constraints e R P w) 0) := + relaxed_volume_dense _ (constraints_affine e R P w) d hd0 hq u hu _ (by positivity) + _ ≤ ENNReal.ofReal ((4/3:ℝ)^(j+1))*volume (region (constraints e R P w) 0) := by + gcongr + exact dense_exponent_layer d hd j + _ = _ := by + rw [ENNReal.ofReal_pow (by norm_num),ENNReal.ofReal_div_of_pos (by norm_num : (0:ℝ)<3)] + norm_num + +theorem dense_bin_normalizer_bound (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 4 ≤ d) (he : (a*c:ℕ) ≤ d) (hq : (q:ℝ) ≤ d) + (hR : ∀ i,0 (F.positive x).le)] + norm_num [S] + _ ≤ 4*(4*volume (region (constraints e R P w) 0)) := by + gcongr + exact dense_density_volume e R P w d hd hq u hu S + _ = _ := by rw [← mul_assoc]; norm_num + +end +end Contingency.Dense + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/IntegerDraw.lean b/lean/OAI/Probability/Contingency/IntegerDraw.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4ef56b6930ce59fab0b639f9309331fa6104a74 --- /dev/null +++ b/lean/OAI/Probability/Contingency/IntegerDraw.lean @@ -0,0 +1,610 @@ +import Mathlib +import OAI.Probability.Contingency.CompletionTranslation +import OAI.Probability.Contingency.StackCompiler + +namespace OAI + +/-! Integer Draw. -/ + +noncomputable section + +open scoped BigOperators +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +inductive Q + | read + | store (b : Bool) + | restore + | restorePlace (b : Bool) + | start (s : Cmp) + | save (s : Cmp) (v : Bool) + | choose (s : Cmp) (v : Bool) + | place (s : Cmp) (v b : Bool) + | decide (s : Cmp) + | discard + | reverseDraw + | reversePlace (b : Bool) + | output + | emit (b : Bool) + | halt + deriving DecidableEq, Fintype + +def label (q : Q) : Fin (Fintype.card Q) := Fintype.equivFin Q q + +def code : Q → Op (Fintype.card Q) 4 + | .read => .read (label .restore) (label (.store false)) (label (.store true)) + | .store b => .push 2 b (label .read) + | .restore => .pop 2 (label (.start .eq)) (label (.restorePlace false)) (label (.restorePlace true)) + | .restorePlace b => .push 0 b (label .restore) + | .start s => .pop 0 (label (.decide s)) (label (.save s false)) (label (.save s true)) + | .save s v => .push 2 v (label (.choose s v)) + | .choose s v => .coin (label (.place s v false)) (label (.place s v true)) + | .place s v b => .push 1 b (label (.start (advance s v b))) + | .decide s => .jump (label (if accept s then .reverseDraw else .discard)) + | .discard => .pop 1 (label .restore) (label .discard) (label .discard) + | .reverseDraw => .pop 1 (label .output) (label (.reversePlace false)) (label (.reversePlace true)) + | .reversePlace b => .push 0 b (label .reverseDraw) + | .output => .pop 0 (label .halt) (label (.emit false)) (label (.emit true)) + | .emit b => .emit b (label .output) + | .halt => .halt + +def program : Program := ⟨Fintype.card Q,4,label .read,fun pc => code ((Fintype.equivFin Q).symm pc)⟩ + +def config (q : Q) (m : Memory 4) : Config program := ⟨some (label q),m⟩ + +theorem one_step (q : Q) (m : Memory 4) (coin : Bool) : + step program coin (config q m)= + ⟨(effect (code q) coin m).1,(effect (code q) coin m).2⟩ := by + simp [step,config,program,label] + +theorem four_steps (s : Cmp) (m : Memory 4) (v b n₀ n₁ n₃ : Bool) (rest : List Bool) + (hm : m.stack 0=v::rest) : + [n₀,n₁,b,n₃].foldl (fun c z => step program z c) (config (.start s) m)= + config (.start (advance s v b)) (digitMemory m v b) := by + cases v <;> cases b <;> + simp [List.foldl_cons,List.foldl_nil,code,effect,branch,hm,config,digitMemory, + step,program,label] + +theorem pass (ds : List Digit) (s : Cmp) (m : Memory 4) + (hm : m.stack 0=ds.map Digit.bound) : + (ds.flatMap bits).foldl (fun c b => step program b c) (config (.start s) m)= + config (.start (wordCmp ds s)) (wordMemory ds m) := by + induction ds generalizing s m with + | nil => rfl + | cons d ds ih => + simp only [List.flatMap_cons,List.foldl_append] + rw [show bits d=[d.noise₀,d.noise₁,d.coin,d.noise₃] from rfl] + rw [four_steps s m d.bound d.coin d.noise₀ d.noise₁ d.noise₃ _ hm] + rw [ih] + · rfl + · simp [hm] + +theorem decision (s : Cmp) (m : Memory 4) (hn : m.stack 0=[]) (b₀ b₁ : Bool) : + [b₀,b₁].foldl (fun c b => step program b c) (config (.start s) m)= + config (if accept s then .reverseDraw else .discard) (m.pop 0) := by + simp [List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hn] + + +structure Pair where + bit : Bool + noise₀ : Bool + noise₁ : Bool + +def pairBits (p : Pair) : List Bool := [p.noise₀,p.noise₁] + +def moveMemory (m : Memory 4) (i j : Fin 4) (b : Bool) : Memory 4 := (m.pop i).push j b + +@[simp] theorem move_from (m : Memory 4) (i j : Fin 4) (b : Bool) (h : i≠j) : + (moveMemory m i j b).stack i=(m.stack i).tail := by + simp [moveMemory,Memory.pop,Memory.push,h] +@[simp] theorem move_to (m : Memory 4) (i j : Fin 4) (b : Bool) (h : i≠j) : + (moveMemory m i j b).stack j=b::m.stack j := by + simp [moveMemory,Memory.pop,Memory.push,Ne.symm h] +@[simp] theorem move_other (m : Memory 4) (i j k : Fin 4) (b : Bool) (hi : k≠i) (hj : k≠j) : + (moveMemory m i j b).stack k=m.stack k := by simp [moveMemory,Memory.pop,Memory.push,hi,hj] + +def moveWord (ps : List Pair) (i j : Fin 4) (m : Memory 4) : Memory 4 := + ps.foldl (fun m p => moveMemory m i j p.bit) m + +theorem moveWord_stacks (ps : List Pair) (i j : Fin 4) (m : Memory 4) + (hij : i≠j) (hm : m.stack i=ps.map Pair.bit) : + (moveWord ps i j m).stack i=[] ∧ + (moveWord ps i j m).stack j=(ps.map Pair.bit).reverse++m.stack j ∧ + (∀ k, k≠i → k≠j → (moveWord ps i j m).stack k=m.stack k) := by + induction ps generalizing m with + | nil => simp_all [moveWord] + | cons p ps ih => + have ht : (moveMemory m i j p.bit).stack i=ps.map Pair.bit := by simp [hij,hm] + have hs := ih (moveMemory m i j p.bit) ht + refine ⟨hs.1,?_,?_⟩ + · simpa [moveWord,List.reverse_cons,List.append_assoc,hij] using hs.2.1 + · intro k hi hj + exact (hs.2.2 k hi hj).trans (move_other m i j k p.bit hi hj) + +theorem restore_two (m : Memory 4) (p : Pair) (rest : List Bool) + (hm : m.stack 2=p.bit::rest) : + (pairBits p).foldl (fun c b => step program b c) (config .restore m)= + config .restore (moveMemory m 2 0 p.bit) := by + cases p with + | mk v b₀ b₁ => cases v <;> + simp [pairBits,List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hm,moveMemory] + +theorem restore_pass (ps : List Pair) (m : Memory 4) (hm : m.stack 2=ps.map Pair.bit) : + (ps.flatMap pairBits).foldl (fun c b => step program b c) (config .restore m)= + config .restore (moveWord ps 2 0 m) := by + induction ps generalizing m with + | nil => rfl + | cons p ps ih => + simp only [List.flatMap_cons,List.foldl_append] + rw [restore_two m p _ hm,ih] + · rfl + · simp [hm] + +theorem restore_finish (m : Memory 4) (hm : m.stack 2=[]) (b : Bool) : + step program b (config .restore m)=config (.start .eq) (m.pop 2) := by + rw [one_step] + simp [code,effect,branch,hm,config] + rfl + +theorem reverse_two (m : Memory 4) (p : Pair) (rest : List Bool) + (hm : m.stack 1=p.bit::rest) : + (pairBits p).foldl (fun c b => step program b c) (config .reverseDraw m)= + config .reverseDraw (moveMemory m 1 0 p.bit) := by + cases p with + | mk v b₀ b₁ => cases v <;> + simp [pairBits,List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hm,moveMemory] + +theorem reverse_pass (ps : List Pair) (m : Memory 4) (hm : m.stack 1=ps.map Pair.bit) : + (ps.flatMap pairBits).foldl (fun c b => step program b c) (config .reverseDraw m)= + config .reverseDraw (moveWord ps 1 0 m) := by + induction ps generalizing m with + | nil => rfl + | cons p ps ih => + simp only [List.flatMap_cons,List.foldl_append] + rw [reverse_two m p _ hm,ih] + · rfl + · simp [hm] + +theorem reverse_finish (m : Memory 4) (hm : m.stack 1=[]) (b : Bool) : + step program b (config .reverseDraw m)=config .output (m.pop 1) := by + rw [one_step] + simp [code,effect,branch,hm,config] + rfl + +def emitMemory (m : Memory 4) (b : Bool) : Memory 4 := + {m.pop 0 with outputRev := b::m.outputRev} + +def emitWord (ps : List Pair) (m : Memory 4) : Memory 4 := + ps.foldl (fun m p => emitMemory m p.bit) m + +theorem emit_two (m : Memory 4) (p : Pair) (rest : List Bool) + (hm : m.stack 0=p.bit::rest) : + (pairBits p).foldl (fun c b => step program b c) (config .output m)= + config .output (emitMemory m p.bit) := by + cases p with + | mk v b₀ b₁ => cases v <;> + simp [pairBits,List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hm,emitMemory] <;> rfl + +theorem emit_pass (ps : List Pair) (m : Memory 4) (hm : m.stack 0=ps.map Pair.bit) : + (ps.flatMap pairBits).foldl (fun c b => step program b c) (config .output m)= + config .output (emitWord ps m) := by + induction ps generalizing m with + | nil => rfl + | cons p ps ih => + simp only [List.flatMap_cons,List.foldl_append] + rw [emit_two m p _ hm,ih] + · rfl + · simp [emitMemory,Memory.pop,hm] + +theorem emitWord_stacks (ps : List Pair) (m : Memory 4) (hm : m.stack 0=ps.map Pair.bit) : + (emitWord ps m).stack 0=[] ∧ + (emitWord ps m).outputRev=(ps.map Pair.bit).reverse++m.outputRev := by + induction ps generalizing m with + | nil => simp_all [emitWord] + | cons p ps ih => + have ht : (emitMemory m p.bit).stack 0=ps.map Pair.bit := by simp [emitMemory,Memory.pop,hm] + have hs := ih (emitMemory m p.bit) ht + simpa [emitWord,emitMemory,List.reverse_cons,List.append_assoc] using hs + +theorem emit_finish (m : Memory 4) (hm : m.stack 0=[]) (b₀ b₁ : Bool) : + [b₀,b₁].foldl (fun c b => step program b c) (config .output m)=⟨none,m.pop 0⟩ := by + simp [List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hm] + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +@[simp] theorem push_input (m : Memory 4) (i : Fin 4) (b : Bool) : (m.push i b).input=m.input := rfl +@[simp] theorem pop_input (m : Memory 4) (i : Fin 4) : (m.pop i).input=m.input := rfl +@[simp] theorem push_output (m : Memory 4) (i : Fin 4) (b : Bool) : (m.push i b).outputRev=m.outputRev := rfl +@[simp] theorem pop_output (m : Memory 4) (i : Fin 4) : (m.pop i).outputRev=m.outputRev := rfl +@[simp] theorem pop_stack (m : Memory 4) (i : Fin 4) : (m.pop i).stack i=(m.stack i).tail := by simp [Memory.pop] +@[simp] theorem pop_other (m : Memory 4) (i j : Fin 4) (h : i≠j) : (m.pop i).stack j=m.stack j := by simp [Memory.pop,Ne.symm h] +@[simp] theorem moveWord_output (ps : List Pair) (i j : Fin 4) (m : Memory 4) : + (moveWord ps i j m).outputRev=m.outputRev := by + induction ps generalizing m with + | nil => rfl + | cons p ps ih => exact ih (moveMemory m i j p.bit) +@[simp] theorem wordMemory_output (ds : List Digit) (m : Memory 4) : + (wordMemory ds m).outputRev=m.outputRev := by + induction ds generalizing m with + | nil => rfl + | cons d ds ih => exact ih (digitMemory m d.bound d.coin) + +def loadMemory (m : Memory 4) (b : Bool) : Memory 4 := m.read.push 2 b + +def loadWord (ps : List Pair) (m : Memory 4) : Memory 4 := ps.foldl (fun m p => loadMemory m p.bit) m + +theorem load_two (m : Memory 4) (p : Pair) (rest : List Bool) (hm : m.input=p.bit::rest) : + (pairBits p).foldl (fun c b => step program b c) (config .read m)= + config .read (loadMemory m p.bit) := by + cases p with + | mk v b₀ b₁ => cases v <;> + simp [pairBits,List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hm,loadMemory] + +theorem load_pass (ps : List Pair) (m : Memory 4) (hm : m.input=ps.map Pair.bit) : + (ps.flatMap pairBits).foldl (fun c b => step program b c) (config .read m)= + config .read (loadWord ps m) := by + induction ps generalizing m with + | nil => rfl + | cons p ps ih => + simp only [List.flatMap_cons,List.foldl_append] + rw [load_two m p _ hm,ih] + · rfl + · simp [loadMemory,Memory.read,hm] + +theorem loadWord_stacks (ps : List Pair) (m : Memory 4) (hm : m.input=ps.map Pair.bit) : + (loadWord ps m).input=[] ∧ + (loadWord ps m).stack 2=(ps.map Pair.bit).reverse++m.stack 2 ∧ + (∀ k, k≠2 → (loadWord ps m).stack k=m.stack k) ∧ + (loadWord ps m).outputRev=m.outputRev := by + induction ps generalizing m with + | nil => simp_all [loadWord] + | cons p ps ih => + have ht : (loadMemory m p.bit).input=ps.map Pair.bit := by simp [loadMemory,Memory.read,hm] + have hs := ih (loadMemory m p.bit) ht + refine ⟨hs.1,?_,?_,hs.2.2.2⟩ + · simpa [loadWord,loadMemory,Memory.push,Memory.read,List.reverse_cons,List.append_assoc] using hs.2.1 + · intro k hk + simpa [loadWord,loadMemory,Memory.push,Memory.read,hk] using hs.2.2.1 k hk + +theorem load_finish (m : Memory 4) (hm : m.input=[]) (b : Bool) : + step program b (config .read m)=config .restore m.read := by + rw [one_step] + simp [code,effect,branch,hm,config] + rfl + +def clearWord (bs : List Bool) (m : Memory 4) : Memory 4 := bs.foldl (fun m _ => m.pop 1) m + +theorem discard_one (m : Memory 4) (v : Bool) (rest : List Bool) (hm : m.stack 1=v::rest) (b : Bool) : + step program b (config .discard m)=config .discard (m.pop 1) := by + rw [one_step] + cases v <;> simp [code,effect,branch,hm,config] <;> rfl + +theorem discard_pass (bs : List Bool) (m : Memory 4) (hm : (m.stack 1).length=bs.length) : + bs.foldl (fun c b => step program b c) (config .discard m)= + config .discard (clearWord bs m) := by + induction bs generalizing m with + | nil => rfl + | cons b bs ih => + obtain ⟨v,rest,hs⟩ := List.exists_cons_of_length_pos (l:=m.stack 1) (by simp_all) + simp only [List.foldl_cons] + rw [discard_one m v rest hs b,ih] + · rfl + · simp [hs] at hm ⊢; omega + +theorem clearWord_stacks (bs : List Bool) (m : Memory 4) (hm : (m.stack 1).length=bs.length) : + (clearWord bs m).stack 1=[] ∧ + (∀ k, k≠1 → (clearWord bs m).stack k=m.stack k) ∧ + (clearWord bs m).outputRev=m.outputRev := by + induction bs generalizing m with + | nil => simpa [clearWord] using hm + | cons b bs ih => + have ht : ((m.pop 1).stack 1).length=bs.length := by simp at hm; simp; omega + have hs := ih (m.pop 1) ht + refine ⟨hs.1,?_,hs.2.2⟩ + intro k hk + simpa [clearWord,Memory.pop,hk] using hs.2.1 k hk + +theorem discard_finish (m : Memory 4) (hm : m.stack 1=[]) (b : Bool) : + step program b (config .discard m)=config .restore (m.pop 1) := by + rw [one_step] + simp [code,effect,branch,hm,config] + rfl + +theorem pairBits_length (ps : List Pair) : (ps.flatMap pairBits).length=2*ps.length := by + induction ps with + | nil => rfl + | cons p ps ih => simp [pairBits,ih]; omega + + +def successBits (ds : List Digit) (rev out : List Pair) (a b c d e : Bool) : List Bool := + ds.flatMap bits ++ [a,b] ++ rev.flatMap pairBits ++ [c] ++ out.flatMap pairBits ++ [d,e] + +def successMemory (ds : List Digit) (rev out : List Pair) (m : Memory 4) : Memory 4 := + (emitWord out ((moveWord rev 1 0 ((wordMemory ds m).pop 0)).pop 1)).pop 0 + +theorem success_run (ds : List Digit) (rev out : List Pair) (m : Memory 4) + (hm0 : m.stack 0=ds.map Digit.bound) (hm1 : m.stack 1=[]) + (hr : rev.map Pair.bit=(ds.map Digit.coin).reverse) + (ho : out.map Pair.bit=ds.map Digit.coin) + (ha : beValue (ds.map Digit.coin)≤beValue (ds.map Digit.bound)) + (a b c d e : Bool) : + (successBits ds rev out a b c d e).foldl (fun c b => step program b c) (config (.start .eq) m)= + ⟨none,successMemory ds rev out m⟩ := by + have hs := pass_stacks ds m hm0 + have h0 : ((wordMemory ds m).pop 0).stack 0=[] := by simp [hs.1] + have h1 : ((wordMemory ds m).pop 0).stack 1=rev.map Pair.bit := by simp [hs.2.1,hm1,hr] + have hrst := moveWord_stacks rev 1 0 ((wordMemory ds m).pop 0) (by decide) h1 + have hr0 : ((moveWord rev 1 0 ((wordMemory ds m).pop 0)).pop 1).stack 0=out.map Pair.bit := by + simp [hrst.2.1,hs.1,hr,ho] + have he := emitWord_stacks out _ hr0 + unfold successBits + simp only [List.foldl_append] + rw [pass ds .eq m hm0,decision _ _ hs.1 a b,comparison_correct,ite_eq_left (by simpa using ha)] + rw [reverse_pass rev _ h1] + simp only [List.foldl_cons,List.foldl_nil] + rw [reverse_finish _ hrst.1 c,emit_pass out _ hr0] + exact emit_finish _ he.1 d e + +theorem success_output (ds : List Digit) (rev out : List Pair) (m : Memory 4) + (hm0 : m.stack 0=ds.map Digit.bound) (hm1 : m.stack 1=[]) + (hr : rev.map Pair.bit=(ds.map Digit.coin).reverse) + (ho : out.map Pair.bit=ds.map Digit.coin) : + (successMemory ds rev out m).outputRev.reverse=m.outputRev.reverse++ds.map Digit.coin := by + have hs := pass_stacks ds m hm0 + have h0 : ((wordMemory ds m).pop 0).stack 0=[] := by simp [hs.1] + have h1 : ((wordMemory ds m).pop 0).stack 1=rev.map Pair.bit := by simp [hs.2.1,hm1,hr] + have hrst := moveWord_stacks rev 1 0 ((wordMemory ds m).pop 0) (by decide) h1 + have hr0 : ((moveWord rev 1 0 ((wordMemory ds m).pop 0)).pop 1).stack 0=out.map Pair.bit := by + simp [hrst.2.1,hs.1,hr,ho] + have he := emitWord_stacks out _ hr0 + simp [successMemory,he.2,ho] + +theorem success_length (ds : List Digit) (rev out : List Pair) + (hr : rev.map Pair.bit=(ds.map Digit.coin).reverse) + (ho : out.map Pair.bit=ds.map Digit.coin) (a b c d e : Bool) : + (successBits ds rev out a b c d e).length=8*ds.length+5 := by + have hlr := congrArg List.length hr + have hlo := congrArg List.length ho + simp only [List.length_map,List.length_reverse] at hlr hlo + simp only [successBits,List.length_append,List.length_cons,List.length_nil,pass_length,pairBits_length,hlr,hlo] + omega + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +def rejectBits (ds : List Digit) (clear : List Bool) (restore : List Pair) (a b c d : Bool) : List Bool := + ds.flatMap bits ++ [a,b] ++ clear ++ [c] ++ restore.flatMap pairBits ++ [d] + +def rejectMemory (ds : List Digit) (clear : List Bool) (restore : List Pair) (m : Memory 4) : Memory 4 := + (moveWord restore 2 0 ((clearWord clear ((wordMemory ds m).pop 0)).pop 1)).pop 2 + +theorem reject_run (ds : List Digit) (clear : List Bool) (restore : List Pair) (m : Memory 4) + (hm0 : m.stack 0=ds.map Digit.bound) (hm1 : m.stack 1=[]) (hm2 : m.stack 2=[]) + (hc : clear.length=ds.length) (hr : restore.map Pair.bit=(ds.map Digit.bound).reverse) + (ha : ¬beValue (ds.map Digit.coin)≤beValue (ds.map Digit.bound)) + (a b c d : Bool) : + (rejectBits ds clear restore a b c d).foldl (fun c b => step program b c) (config (.start .eq) m)= + config (.start .eq) (rejectMemory ds clear restore m) := by + have hs := pass_stacks ds m hm0 + have h0 : ((wordMemory ds m).pop 0).stack 0=[] := by simp [hs.1] + have h1 : (((wordMemory ds m).pop 0).stack 1).length=clear.length := by simp [hs.2.1,hm1,hc] + have hcs := clearWord_stacks clear _ h1 + have h2 : ((clearWord clear ((wordMemory ds m).pop 0)).pop 1).stack 2=restore.map Pair.bit := by + simp [hcs.2.1 2 (by decide),hs.2.2.1,hm2,hr] + have hrst := moveWord_stacks restore 2 0 _ (by decide) h2 + unfold rejectBits + simp only [List.foldl_append] + rw [pass ds .eq m hm0,decision _ _ hs.1 a b,comparison_correct,ite_eq_right (by simpa using ha)] + rw [discard_pass clear _ h1] + simp only [List.foldl_cons,List.foldl_nil] + rw [discard_finish _ hcs.1 c,restore_pass restore _ h2,restore_finish _ hrst.1 d] + rfl + +theorem reject_stacks (ds : List Digit) (clear : List Bool) (restore : List Pair) (m : Memory 4) + (hm0 : m.stack 0=ds.map Digit.bound) (hm1 : m.stack 1=[]) (hm2 : m.stack 2=[]) + (hc : clear.length=ds.length) (hr : restore.map Pair.bit=(ds.map Digit.bound).reverse) : + (rejectMemory ds clear restore m).stack 0=m.stack 0 ∧ + (rejectMemory ds clear restore m).stack 1=[] ∧ + (rejectMemory ds clear restore m).stack 2=[] ∧ + (rejectMemory ds clear restore m).outputRev=m.outputRev := by + have hs := pass_stacks ds m hm0 + have h0 : ((wordMemory ds m).pop 0).stack 0=[] := by simp [hs.1] + have h1 : (((wordMemory ds m).pop 0).stack 1).length=clear.length := by simp [hs.2.1,hm1,hc] + have hcs := clearWord_stacks clear _ h1 + have h2 : ((clearWord clear ((wordMemory ds m).pop 0)).pop 1).stack 2=restore.map Pair.bit := by + simp [hcs.2.1 2 (by decide),hs.2.2.1,hm2,hr] + have hrst := moveWord_stacks restore 2 0 _ (by decide) h2 + simp [rejectMemory,hrst.1,hrst.2.1,hrst.2.2 1 (by decide) (by decide),hcs.1, + hcs.2.1 0 (by decide),hcs.2.2,hs.1,hr,hm0] + +theorem reject_length (ds : List Digit) (clear : List Bool) (restore : List Pair) + (hc : clear.length=ds.length) (hr : restore.map Pair.bit=(ds.map Digit.bound).reverse) (a b c d : Bool) : + (rejectBits ds clear restore a b c d).length=7*ds.length+4 := by + have hlr := congrArg List.length hr + simp only [List.length_map,List.length_reverse] at hlr + simp only [rejectBits,List.length_append,List.length_cons,List.length_nil,pass_length,pairBits_length,hlr,hc] + omega + +def prepareBits (load restore : List Pair) (a b : Bool) : List Bool := + load.flatMap pairBits ++ [a] ++ restore.flatMap pairBits ++ [b] + +def prepareMemory (load restore : List Pair) (m : Memory 4) : Memory 4 := + (moveWord restore 2 0 (loadWord load m).read).pop 2 + +theorem prepare_run (load restore : List Pair) (m : Memory 4) + (hm : m.input=load.map Pair.bit) (hm2 : m.stack 2=[]) + (hr : restore.map Pair.bit=(load.map Pair.bit).reverse) (a b : Bool) : + (prepareBits load restore a b).foldl (fun c b => step program b c) (config .read m)= + config (.start .eq) (prepareMemory load restore m) := by + have hl := loadWord_stacks load m hm + have h2 : (loadWord load m).read.stack 2=restore.map Pair.bit := by + simpa [Memory.read,hm2,hr] using hl.2.1 + have hrst := moveWord_stacks restore 2 0 _ (by decide) h2 + unfold prepareBits + simp only [List.foldl_append] + rw [load_pass load m hm] + simp only [List.foldl_cons,List.foldl_nil] + rw [load_finish _ hl.1 a,restore_pass restore _ h2,restore_finish _ hrst.1 b] + rfl + +theorem prepare_stacks (load restore : List Pair) (m : Memory 4) + (hm : m.input=load.map Pair.bit) (hm0 : m.stack 0=[]) (hm2 : m.stack 2=[]) + (hr : restore.map Pair.bit=(load.map Pair.bit).reverse) : + (prepareMemory load restore m).stack 0=m.input ∧ + (prepareMemory load restore m).stack 1=m.stack 1 ∧ + (prepareMemory load restore m).stack 2=[] ∧ + (prepareMemory load restore m).outputRev=m.outputRev := by + have hl := loadWord_stacks load m hm + have h2 : (loadWord load m).read.stack 2=restore.map Pair.bit := by + simpa [Memory.read,hm2,hr] using hl.2.1 + have hrst := moveWord_stacks restore 2 0 _ (by decide) h2 + simp only [prepareMemory,pop_stack,pop_other _ 2 0 (by decide),pop_other _ 2 1 (by decide),pop_output] + rw [hrst.1,hrst.2.1,hrst.2.2 1 (by decide) (by decide)] + simp [Memory.read,hl.2.2.1 0 (by decide),hl.2.2.1 1 (by decide),hl.2.2.2,hr,hm0,hm] + +theorem prepare_length (load restore : List Pair) + (hr : restore.map Pair.bit=(load.map Pair.bit).reverse) (a b : Bool) : + (prepareBits load restore a b).length=4*load.length+2 := by + have hlr := congrArg List.length hr + simp only [List.length_map,List.length_reverse] at hlr + simp only [prepareBits,List.length_append,List.length_cons,List.length_nil,pairBits_length,hlr] + omega + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +open scoped BigOperators +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +def digitCoord {n : ℕ} (i : Fin n) (j : Fin 4) : Fin (n*4) := finProdFinEquiv (i,j) + +def digitNoise (j : Fin 3) : Fin 4 := if j=0 then 0 else if j=1 then 1 else 3 + +def blockEquiv (n : ℕ) : (Fin (n*4) → Bool) ≃ (Fin n → Bool)×((Fin n×Fin 3)→Bool) where + toFun f := (fun i => f (digitCoord i 2),fun ij => f (digitCoord ij.1 (digitNoise ij.2))) + invFun p k := let ij := finProdFinEquiv.symm k + if ij.2=2 then p.1 ij.1 else if ij.2=0 then p.2 (ij.1,0) + else if ij.2=1 then p.2 (ij.1,1) else p.2 (ij.1,2) + left_inv f := by + funext k + obtain ⟨⟨i,j⟩,rfl⟩ := finProdFinEquiv.surjective k + fin_cases j <;> simp [digitCoord,digitNoise] + right_inv p := by + rcases p with ⟨f,g⟩ + apply Prod.ext + · funext i; simp [digitCoord] + · funext ⟨i,j⟩; fin_cases j <;> simp [digitCoord,digitNoise] + +theorem block_count (n : ℕ) (p : (Fin n→Bool)→Prop) [DecidablePred p] : + (Finset.univ.filter fun c : Fin (n*4)→Bool => p (fun i => c (digitCoord i 2))).card= + 2^(n*3)*(Finset.univ.filter p).card := by + classical + simp only [Finset.card_filter] + change (∑ c,if p ((blockEquiv n c).1) then 1 else 0)=_ + rw [(blockEquiv n).sum_comp (fun ab => if p ab.1 then (1:ℕ) else 0),Fintype.sum_prod_type] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro bs _ + by_cases hp : p bs + · simp [hp] + · simp [hp] + +def digits {n : ℕ} (bound : Fin n → Bool) (coins : Fin (n*4)→Bool) : List Digit := + List.ofFn fun i => ⟨bound i,coins (digitCoord i 2),coins (digitCoord i 0), + coins (digitCoord i 1),coins (digitCoord i 3)⟩ + +@[simp] theorem digits_length {n : ℕ} (bound : Fin n → Bool) (coins : Fin (n*4)→Bool) : + (digits bound coins).length=n := by simp [digits] +@[simp] theorem digits_bound {n : ℕ} (bound : Fin n → Bool) (coins : Fin (n*4)→Bool) : + (digits bound coins).map Digit.bound=List.ofFn bound := by simp [digits,Function.comp_def] +@[simp] theorem digits_coin {n : ℕ} (bound : Fin n → Bool) (coins : Fin (n*4)→Bool) : + (digits bound coins).map Digit.coin=List.ofFn (fun i => coins (digitCoord i 2)) := by simp [digits,Function.comp_def] + +theorem digits_bits {n : ℕ} (bound : Fin n → Bool) (coins : Fin (n*4)→Bool) : + (digits bound coins).flatMap bits=List.ofFn coins := by + rw [List.ofFn_mul] + unfold digits + rw [List.flatMap_def,List.map_ofFn] + congr 1 + apply congrArg List.ofFn + funext i + simp [bits,List.ofFn_succ,digitCoord,finProdFinEquiv,Nat.mul_comm,Nat.add_comm] + + +theorem pass_uniform {n : ℕ} (bound : Fin n→Bool) (coins : Fin (n*4)→Bool) (m : Memory 4) + (hm : m.stack 0=List.ofFn bound) : + (List.ofFn coins).foldl (fun c b => step program b c) (config (.start .eq) m)= + config (.start (wordCmp (digits bound coins) .eq)) (wordMemory (digits bound coins) m) := by + rw [← digits_bits bound coins] + exact pass _ _ _ (by simpa using hm) + + +theorem candidate_count (n : ℕ) (u : Fin (2^n)) : + (Finset.univ.filter fun c : Fin (n*4)→Bool => wordFin (fun i => c (digitCoord i 2))=u).card=2^(n*3) := by + rw [block_count n (fun bs => wordFin bs=u),word_count] + omega + +theorem bounded_words (n M : ℕ) (hM : M<2^n) : + (Finset.univ.filter fun bs : Fin n→Bool => wordValue bs≤M).card=M+1 := by + classical + simp only [Finset.card_filter] + change (∑ bs,if (wordEquiv n bs).val≤M then 1 else 0)=_ + rw [(wordEquiv n).sum_comp (fun u => if u.val≤M then (1:ℕ) else 0)] + rw [← Finset.card_filter] + have he : (Finset.univ.filter fun u : Fin (2^n) => u.val≤M)=Finset.Iic ⟨M,hM⟩ := by ext u; simp [Fin.le_def] + rw [he] + simp + +theorem accepted_count {n : ℕ} (bound : Fin n→Bool) : + (Finset.univ.filter fun c : Fin (n*4)→Bool => accept (wordCmp (digits bound c) .eq)=true).card= + 2^(n*3)*(wordValue bound+1) := by + simp only [comparison_correct,digits_coin,digits_bound,decide_eq_true_eq] + change (Finset.univ.filter fun c : Fin (n*4)→Bool => wordValue (fun i => c (digitCoord i 2))≤wordValue bound).card=_ + rw [block_count n (fun bs => wordValue bs≤wordValue bound),bounded_words n _ (wordValue_lt bound)] + + +theorem accepted_probability {n : ℕ} (bound : Fin n→Bool) : + ((Finset.univ.filter fun c : Fin (n*4)→Bool => accept (wordCmp (digits bound c) .eq)=true).card:ℝ)/2^(n*4)= + (wordValue bound+1:ℝ)/2^n := by + rw [accepted_count] + push_cast + rw [show n*4=n*3+n by omega,pow_add] + field_simp + +end +end Contingency.BitModel.StackCode.IntegerDraw + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/IntegerDrawMachine.lean b/lean/OAI/Probability/Contingency/IntegerDrawMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed942136b47bebe1a07c4b7e5364a40a612fd927 --- /dev/null +++ b/lean/OAI/Probability/Contingency/IntegerDrawMachine.lean @@ -0,0 +1,657 @@ +import Mathlib +import OAI.Probability.Contingency.IntegerDraw + +namespace OAI + +/-! Integer Draw Machine. -/ + +noncomputable section + +open scoped BigOperators +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +structure RejectFrame (bound : List Bool) where + draw : List Digit + bound_eq : draw.map Digit.bound=bound + clear : List Bool + clear_length : clear.length=draw.length + restore : List Pair + restore_eq : restore.map Pair.bit=bound.reverse + a : Bool + b : Bool + c : Bool + d : Bool + +def RejectFrame.coins {B : List Bool} (f : RejectFrame B) : List Bool := + rejectBits f.draw f.clear f.restore f.a f.b f.c f.d + +def RejectFrame.rejected {B : List Bool} (f : RejectFrame B) : Prop := + ¬beValue (f.draw.map Digit.coin)≤beValue B + +def RejectFrame.next {B : List Bool} (f : RejectFrame B) (m : Memory 4) : Memory 4 := + rejectMemory f.draw f.clear f.restore m + +theorem RejectFrame.run {B : List Bool} (f : RejectFrame B) (m : Memory 4) + (hm0 : m.stack 0=B) (hm1 : m.stack 1=[]) (hm2 : m.stack 2=[]) (hf : f.rejected) : + f.coins.foldl (fun c b => step program b c) (config (.start .eq) m)= + config (.start .eq) (f.next m) := by + exact reject_run _ _ _ _ (hm0.trans f.bound_eq.symm) hm1 hm2 f.clear_length + (by rw [f.bound_eq,f.restore_eq]) (by simpa [RejectFrame.rejected,f.bound_eq] using hf) _ _ _ _ + +theorem RejectFrame.invariant {B : List Bool} (f : RejectFrame B) (m : Memory 4) + (hm0 : m.stack 0=B) (hm1 : m.stack 1=[]) (hm2 : m.stack 2=[]) : + (f.next m).stack 0=B ∧ (f.next m).stack 1=[] ∧ (f.next m).stack 2=[] ∧ + (f.next m).outputRev=m.outputRev := by + have hh := reject_stacks _ _ _ m (hm0.trans f.bound_eq.symm) hm1 hm2 f.clear_length + (by rw [f.bound_eq,f.restore_eq]) + simpa [RejectFrame.next,hm0] using hh + +theorem RejectFrame.length {B : List Bool} (f : RejectFrame B) : f.coins.length=7*B.length+4 := by + have hl := congrArg List.length f.bound_eq + simp only [List.length_map] at hl + simpa [RejectFrame.coins,hl] using reject_length f.draw f.clear f.restore f.clear_length + (by rw [f.bound_eq,f.restore_eq]) f.a f.b f.c f.d + +def rejectedMemory {B : List Bool} (fs : List (RejectFrame B)) (m : Memory 4) : Memory 4 := + fs.foldl (fun m f => f.next m) m + +theorem rejected_run {B : List Bool} (fs : List (RejectFrame B)) (m : Memory 4) + (hm0 : m.stack 0=B) (hm1 : m.stack 1=[]) (hm2 : m.stack 2=[]) + (hf : ∀ f∈fs,f.rejected) : + (fs.flatMap RejectFrame.coins).foldl (fun c b => step program b c) (config (.start .eq) m)= + config (.start .eq) (rejectedMemory fs m) := by + induction fs generalizing m with + | nil => rfl + | cons f fs ih => + have hi := f.invariant m hm0 hm1 hm2 + simp only [List.flatMap_cons,List.foldl_append] + rw [f.run m hm0 hm1 hm2 (hf f (by simp)),ih _ hi.1 hi.2.1 hi.2.2.1] + · rfl + · intro g hg + exact hf g (by simp [hg]) + +theorem rejected_invariant {B : List Bool} (fs : List (RejectFrame B)) (m : Memory 4) + (hm0 : m.stack 0=B) (hm1 : m.stack 1=[]) (hm2 : m.stack 2=[]) : + (rejectedMemory fs m).stack 0=B ∧ (rejectedMemory fs m).stack 1=[] ∧ + (rejectedMemory fs m).stack 2=[] ∧ (rejectedMemory fs m).outputRev=m.outputRev := by + induction fs generalizing m with + | nil => exact ⟨hm0,hm1,hm2,rfl⟩ + | cons f fs ih => + have hi := f.invariant m hm0 hm1 hm2 + have hs := ih _ hi.1 hi.2.1 hi.2.2.1 + exact ⟨hs.1,hs.2.1,hs.2.2.1,hs.2.2.2.trans hi.2.2.2⟩ + +theorem rejected_length {B : List Bool} (fs : List (RejectFrame B)) : + (fs.flatMap RejectFrame.coins).length=fs.length*(7*B.length+4) := by + induction fs with + | nil => simp + | cons f fs ih => + simp only [List.flatMap_cons,List.length_append,f.length,ih,List.length_cons,Nat.add_mul] + omega + +structure AcceptFrame (bound : List Bool) where + draw : List Digit + bound_eq : draw.map Digit.bound=bound + rev : List Pair + rev_eq : rev.map Pair.bit=(draw.map Digit.coin).reverse + out : List Pair + out_eq : out.map Pair.bit=draw.map Digit.coin + a : Bool + b : Bool + c : Bool + d : Bool + e : Bool + +def AcceptFrame.coins {B : List Bool} (f : AcceptFrame B) : List Bool := + successBits f.draw f.rev f.out f.a f.b f.c f.d f.e + +def AcceptFrame.accepted {B : List Bool} (f : AcceptFrame B) : Prop := + beValue (f.draw.map Digit.coin)≤beValue B + +def AcceptFrame.next {B : List Bool} (f : AcceptFrame B) (m : Memory 4) : Memory 4 := + successMemory f.draw f.rev f.out m + +theorem AcceptFrame.run {B : List Bool} (f : AcceptFrame B) (m : Memory 4) + (hm0 : m.stack 0=B) (hm1 : m.stack 1=[]) (hf : f.accepted) : + f.coins.foldl (fun c b => step program b c) (config (.start .eq) m)=⟨none,f.next m⟩ := by + exact success_run _ _ _ _ (hm0.trans f.bound_eq.symm) hm1 f.rev_eq f.out_eq + (by simpa [AcceptFrame.accepted,f.bound_eq] using hf) _ _ _ _ _ + +theorem AcceptFrame.output {B : List Bool} (f : AcceptFrame B) (m : Memory 4) + (hm0 : m.stack 0=B) (hm1 : m.stack 1=[]) : + (f.next m).outputRev.reverse=m.outputRev.reverse++f.draw.map Digit.coin := + success_output _ _ _ _ (hm0.trans f.bound_eq.symm) hm1 f.rev_eq f.out_eq + +theorem AcceptFrame.length {B : List Bool} (f : AcceptFrame B) : f.coins.length=8*B.length+5 := by + have hl := congrArg List.length f.bound_eq + simp only [List.length_map] at hl + simpa [AcceptFrame.coins,hl] using success_length f.draw f.rev f.out f.rev_eq f.out_eq f.a f.b f.c f.d f.e + +structure PrepareFrame (bound : List Bool) where + load : List Pair + load_eq : load.map Pair.bit=bound + restore : List Pair + restore_eq : restore.map Pair.bit=bound.reverse + a : Bool + b : Bool + +def PrepareFrame.coins {B : List Bool} (f : PrepareFrame B) : List Bool := + prepareBits f.load f.restore f.a f.b + +def PrepareFrame.prepared {B : List Bool} (f : PrepareFrame B) : Memory 4 := + prepareMemory f.load f.restore (initial program B).memory + +theorem PrepareFrame.run {B : List Bool} (f : PrepareFrame B) : + f.coins.foldl (fun c b => step program b c) (initial program B)= + config (.start .eq) f.prepared := by + have hh := prepare_run f.load f.restore (initial program B).memory + f.load_eq.symm rfl (by rw [f.load_eq,f.restore_eq]) f.a f.b + exact hh + +theorem PrepareFrame.invariant {B : List Bool} (f : PrepareFrame B) : + f.prepared.stack 0=B ∧ f.prepared.stack 1=[] ∧ f.prepared.stack 2=[] ∧ f.prepared.outputRev=[] := by + exact prepare_stacks f.load f.restore (initial program B).memory f.load_eq.symm rfl rfl + (by rw [f.load_eq,f.restore_eq]) + +theorem PrepareFrame.length {B : List Bool} (f : PrepareFrame B) : f.coins.length=4*B.length+2 := by + have hl := congrArg List.length f.load_eq + simp only [List.length_map] at hl + simpa [PrepareFrame.coins,hl] using prepare_length f.load f.restore + (by rw [f.load_eq,f.restore_eq]) f.a f.b + +def executionBits {B : List Bool} (p : PrepareFrame B) (fs : List (RejectFrame B)) (a : AcceptFrame B) : List Bool := + p.coins ++ fs.flatMap RejectFrame.coins ++ a.coins + +theorem execution_run {B : List Bool} (p : PrepareFrame B) (fs : List (RejectFrame B)) (a : AcceptFrame B) + (hf : ∀ f∈fs,f.rejected) (ha : a.accepted) : + let result := (executionBits p fs a).foldl (fun c b => step program b c) (initial program B) + result.state=none ∧ result.memory.outputRev.reverse=a.draw.map Digit.coin := by + have hi := p.invariant + have hj := rejected_invariant fs p.prepared hi.1 hi.2.1 hi.2.2.1 + dsimp only + simp only [executionBits,List.foldl_append] + rw [p.run,rejected_run fs _ hi.1 hi.2.1 hi.2.2.1 hf,a.run _ hj.1 hj.2.1 ha] + constructor + · rfl + · rw [a.output _ hj.1 hj.2.1,hj.2.2.2,hi.2.2.2] + rfl + +theorem execution_length {B : List Bool} (p : PrepareFrame B) (fs : List (RejectFrame B)) (a : AcceptFrame B) : + (executionBits p fs a).length=12*B.length+7+fs.length*(7*B.length+4) := by + simp only [executionBits,List.length_append,p.length,rejected_length,a.length] + omega + + + +def machine : Machine := compile program + +def pairedBits (ps : List (Bool×Bool)) : List Bool := ps.flatMap (fun p => [p.1,p.2]) + +theorem compiled_execution {B : List Bool} (p : PrepareFrame B) (fs : List (RejectFrame B)) (a : AcceptFrame B) + (hf : ∀ f∈fs,f.rejected) (ha : a.accepted) (ps : List (Bool×Bool)) + (hp : ps.map Prod.snd=executionBits p fs a) : + let result := (pairedBits ps).foldl (fun c b => machine.step b c) (machine.initial B) + result.state=none ∧ result.outputRev.reverse=a.draw.map Digit.coin := by + have hh := execution_run p fs a hf ha + dsimp only [machine,pairedBits] + rw [← initial_eq,fold_pairs] + have hm := List.foldl_map (f:=Prod.snd) (g:=fun c b => step program b c) (l:=ps) (init:=initial program B) + rw [hp] at hm + rw [← hm] + simpa only [encode_halt,encode_output] using hh + +theorem pairedBits_length (ps : List (Bool×Bool)) : (pairedBits ps).length=2*ps.length := by + induction ps with + | nil => rfl + | cons p ps ih => + simp only [pairedBits,List.flatMap_cons,List.length_append,List.length_cons,List.length_nil] at ih ⊢ + omega + +theorem compiled_length {B : List Bool} (p : PrepareFrame B) (fs : List (RejectFrame B)) (a : AcceptFrame B) + (ps : List (Bool×Bool)) (hp : ps.map Prod.snd=executionBits p fs a) : + (pairedBits ps).length=2*(12*B.length+7+fs.length*(7*B.length+4)) := by + have hh := congrArg List.length hp + simp only [List.length_map,execution_length] at hh + rw [pairedBits_length,hh] + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +def trace (f : ℕ→Bool) (s n : ℕ) : List Bool := List.ofFn (fun i : Fin n => f (s+i)) + +@[simp] theorem trace_length (f : ℕ→Bool) (s n : ℕ) : (trace f s n).length=n := by simp [trace] + +theorem trace_append (f : ℕ→Bool) (s a b : ℕ) : + trace f s a ++ trace f (s+a) b=trace f s (a+b) := by + unfold trace + rw [List.ofFn_add] + simp [Nat.add_assoc] + +@[simp] theorem trace_one (f : ℕ→Bool) (s : ℕ) : trace f s 1=[f s] := by simp [trace,List.ofFn_succ] +@[simp] theorem trace_two (f : ℕ→Bool) (s : ℕ) : trace f s 2=[f s,f (s+1)] := by simp [trace,List.ofFn_succ] + +def makePairs (xs : List Bool) (f : ℕ→Bool) (s : ℕ) : List Pair := + List.ofFn fun i : Fin xs.length => ⟨xs.get i,f (s+i*2),f (s+i*2+1)⟩ + +@[simp] theorem makePairs_bits (xs : List Bool) (f : ℕ→Bool) (s : ℕ) : + (makePairs xs f s).map Pair.bit=xs := by simp [makePairs,Function.comp_def] + +@[simp] theorem makePairs_length (xs : List Bool) (f : ℕ→Bool) (s : ℕ) : + (makePairs xs f s).length=xs.length := by simp [makePairs] + +theorem makePairs_coins (xs : List Bool) (f : ℕ→Bool) (s : ℕ) : + (makePairs xs f s).flatMap pairBits=trace f s (xs.length*2) := by + unfold makePairs trace + rw [List.ofFn_mul,List.flatMap_def,List.map_ofFn] + congr 1 + +def streamDigits (B : List Bool) (f : ℕ→Bool) (s : ℕ) : List Digit := + digits B.get (fun i => f (s+i)) + +@[simp] theorem streamDigits_bound (B : List Bool) (f : ℕ→Bool) (s : ℕ) : + (streamDigits B f s).map Digit.bound=B := by simp [streamDigits,List.ofFn_get] +@[simp] theorem streamDigits_length (B : List Bool) (f : ℕ→Bool) (s : ℕ) : + (streamDigits B f s).length=B.length := by simp [streamDigits] + +theorem streamDigits_coins (B : List Bool) (f : ℕ→Bool) (s : ℕ) : + (streamDigits B f s).flatMap bits=trace f s (B.length*4) := by + exact digits_bits B.get (fun i => f (s+i)) + +def streamPrepare (B : List Bool) (f : ℕ→Bool) : PrepareFrame B where + load := makePairs B f 0 + load_eq := makePairs_bits _ _ _ + restore := makePairs B.reverse f (B.length*2+1) + restore_eq := makePairs_bits _ _ _ + a := f (B.length*2) + b := f (B.length*2+1+B.length*2) + +theorem streamPrepare_coins (B : List Bool) (f : ℕ→Bool) : + (streamPrepare B f).coins=trace f 0 (4*B.length+2) := by + unfold PrepareFrame.coins prepareBits streamPrepare + rw [makePairs_coins,makePairs_coins] + simp only [List.length_reverse] + rw [← trace_one f (B.length*2),← trace_one f (B.length*2+1+B.length*2)] + rw [show trace f 0 (B.length*2) ++ trace f (B.length*2) 1 = + trace f 0 (B.length*2+1) by simpa using trace_append f 0 (B.length*2) 1] + rw [show trace f 0 (B.length*2+1) ++ trace f (B.length*2+1) (B.length*2)= + trace f 0 (B.length*2+1+B.length*2) by simpa using trace_append f 0 (B.length*2+1) (B.length*2)] + rw [show trace f 0 (B.length*2+1+B.length*2) ++ + trace f (B.length*2+1+B.length*2) 1=trace f 0 (B.length*2+1+B.length*2+1) by + simpa using trace_append f 0 (B.length*2+1+B.length*2) 1] + congr 1 + omega + +def streamReject (B : List Bool) (f : ℕ→Bool) (s : ℕ) : RejectFrame B where + draw := streamDigits B f s + bound_eq := streamDigits_bound _ _ _ + clear := trace f (s+B.length*4+2) B.length + clear_length := by simp + restore := makePairs B.reverse f (s+B.length*4+2+B.length+1) + restore_eq := makePairs_bits _ _ _ + a := f (s+B.length*4) + b := f (s+B.length*4+1) + c := f (s+B.length*4+2+B.length) + d := f (s+B.length*4+2+B.length+1+B.length*2) + +theorem streamReject_coins (B : List Bool) (f : ℕ→Bool) (s : ℕ) : + (streamReject B f s).coins=trace f s (7*B.length+4) := by + unfold RejectFrame.coins rejectBits streamReject + rw [streamDigits_coins,makePairs_coins] + simp only [List.length_reverse] + rw [← trace_two,← trace_one f (s+B.length*4+2+B.length), + ← trace_one f (s+B.length*4+2+B.length+1+B.length*2)] + simp only [Nat.add_assoc,trace_append] + congr 1 + omega + +def streamAccept (B : List Bool) (f : ℕ→Bool) (s : ℕ) : AcceptFrame B where + draw := streamDigits B f s + bound_eq := streamDigits_bound _ _ _ + rev := makePairs ((streamDigits B f s).map Digit.coin).reverse f (s+B.length*4+2) + rev_eq := makePairs_bits _ _ _ + out := makePairs ((streamDigits B f s).map Digit.coin) f (s+B.length*4+2+B.length*2+1) + out_eq := makePairs_bits _ _ _ + a := f (s+B.length*4) + b := f (s+B.length*4+1) + c := f (s+B.length*4+2+B.length*2) + d := f (s+B.length*4+2+B.length*2+1+B.length*2) + e := f (s+B.length*4+2+B.length*2+1+B.length*2+1) + +theorem streamAccept_coins (B : List Bool) (f : ℕ→Bool) (s : ℕ) : + (streamAccept B f s).coins=trace f s (8*B.length+5) := by + unfold AcceptFrame.coins successBits streamAccept + rw [streamDigits_coins,makePairs_coins,makePairs_coins] + simp only [List.length_reverse,List.length_map,streamDigits_length] + rw [← trace_two f (s+B.length*4),← trace_one f (s+B.length*4+2+B.length*2), + ← trace_two f (s+B.length*4+2+B.length*2+1+B.length*2)] + simp only [Nat.add_assoc,trace_append] + congr 1 + omega + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +def prepTime (B : List Bool) : ℕ := 4*B.length+2 +def retryTime (B : List Bool) : ℕ := 7*B.length+4 +def successTime (B : List Bool) : ℕ := 8*B.length+5 +def startTime (B : List Bool) (j : ℕ) : ℕ := prepTime B+j*retryTime B + +def candidate (B : List Bool) (f : ℕ→Bool) (j : ℕ) : List Bool := + (streamDigits B f (startTime B j)).map Digit.coin + +def accepted (B : List Bool) (f : ℕ→Bool) (j : ℕ) : Prop := beValue (candidate B f j)≤beValue B + +def retries (B : List Bool) (f : ℕ→Bool) (j : ℕ) : List (RejectFrame B) := + List.ofFn fun i : Fin j => streamReject B f (startTime B i) + +@[simp] theorem retries_length (B : List Bool) (f : ℕ→Bool) (j : ℕ) : (retries B f j).length=j := by simp [retries] + +theorem retries_coins (B : List Bool) (f : ℕ→Bool) (j : ℕ) : + ((retries B f j).flatMap RejectFrame.coins)=trace f (prepTime B) (j*retryTime B) := by + induction j with + | zero => simp [retries,trace] + | succ j ih => + simp only [retries,List.ofFn_succ',List.concat_eq_append,List.flatMap_append,List.flatMap_cons,List.flatMap_nil,List.append_nil] + change (retries B f j).flatMap RejectFrame.coins ++ (streamReject B f (startTime B j)).coins=_ + rw [ih,streamReject_coins] + change trace f (prepTime B) (j*retryTime B) ++ trace f (prepTime B+j*retryTime B) (retryTime B)=_ + rw [trace_append,Nat.succ_mul] + +theorem first_accept (B : List Bool) (f : ℕ→Bool) (j : ℕ) + (hj : accepted B f j) (hp : ∀ i step program b c) (initial program B) + result.state=none ∧ result.memory.outputRev.reverse=candidate B f j := by + have hr : ∀ a∈retries B f j,a.rejected := by + intro a ha + obtain ⟨i,hi⟩ := List.mem_ofFn.mp ha + subst a + exact hp i i.isLt + have hh := execution_run (streamPrepare B f) (retries B f j) + (streamAccept B f (startTime B j)) hr hj + have he : executionBits (streamPrepare B f) (retries B f j) (streamAccept B f (startTime B j))= + trace f 0 (startTime B j+successTime B) := by + unfold executionBits + rw [streamPrepare_coins,retries_coins,streamAccept_coins] + change trace f 0 (prepTime B) ++ trace f (prepTime B) (j*retryTime B) ++ + trace f (prepTime B+j*retryTime B) (successTime B)=_ + rw [show trace f 0 (prepTime B) ++ trace f (prepTime B) (j*retryTime B)= + trace f 0 (prepTime B+j*retryTime B) by simpa using trace_append f 0 (prepTime B) (j*retryTime B)] + simpa [startTime] using trace_append f 0 (prepTime B+j*retryTime B) (successTime B) + rw [he] at hh + exact hh + + theorem halted_fold (P : Program) (bs : List Bool) (m : Memory P.work) : + bs.foldl (fun c b => step P b c) ⟨none,m⟩=⟨none,m⟩ := by + induction bs with + | nil => rfl + | cons b bs ih => exact ih + + theorem first_accept_later (B : List Bool) (f : ℕ→Bool) (j t : ℕ) + (hj : accepted B f j) (hp : ∀ i step program b c) (initial program B) + result.state=none ∧ result.memory.outputRev.reverse=candidate B f j := by + have hh := first_accept B f j hj hp + let T := startTime B j+successTime B + have he : trace f 0 t=trace f 0 T ++ trace f T (t-T) := by + have := trace_append f 0 T (t-T) + have hT : T+(t-T)=t := by omega + simpa only [Nat.zero_add,hT] using this.symm + rw [he,List.foldl_append] + generalize hc : (trace f 0 T).foldl (fun c b => step program b c) (initial program B)=c at hh ⊢ + rcases c with ⟨s,m⟩ + change s=none ∧ _ at hh + rcases hh with ⟨rfl,ho⟩ + dsimp only + rw [halted_fold] + exact ⟨rfl,ho⟩ + + theorem accepts_halt (B : List Bool) (f : ℕ→Bool) (k t : ℕ) + (ha : ∃ j step program b c) (initial program B)).state=none := by + classical + let j := Nat.find ha + have hj := Nat.find_spec ha + have hp : ∀ i p (f∘e)).card= + 2^(Nat.card {b : β // b∉Set.range e})*(Finset.univ.filter p).card := by + classical + simp only [Finset.card_filter] + change (∑ f,if p ((split e he f).1) then 1 else 0)=_ + rw [(split e he).sum_comp (fun ab => if p ab.1 then (1:ℕ) else 0),Fintype.sum_prod_type,Finset.mul_sum] + apply Finset.sum_congr rfl + intro bs _ + by_cases hp : p bs <;> simp [hp,Nat.card_eq_fintype_card] + +omit [DecidableEq α] in +theorem cardinal_split (e : α→β) (he : Injective e) : + Fintype.card β=Fintype.card α+Nat.card {b : β // b∉Set.range e} := by + classical + simpa [Nat.card_eq_fintype_card] using (Fintype.card_congr (indexEquiv e he)).symm + +theorem probability_restrict (e : α→β) (he : Injective e) (p : (α→Bool)→Prop) [DecidablePred p] : + ((Finset.univ.filter fun f : β→Bool => p (f∘e)).card:ℝ)/2^(Fintype.card β)= + ((Finset.univ.filter p).card:ℝ)/2^(Fintype.card α) := by + rw [count_restrict e he p,cardinal_split e he] + push_cast + rw [pow_add] + field_simp + +theorem count_all {γ : Type*} [Fintype γ] (k : ℕ) (p : γ→Prop) [DecidablePred p] : + (Finset.univ.filter fun f : Fin k→γ => ∀ i,p (f i)).card=(Finset.univ.filter p).card^k := by + classical + rw [← Fintype.card_subtype] + rw [Fintype.card_congr (Equiv.subtypePiEquivPi (p:=fun (_ : Fin k) (v : γ) => p v))] + simp [Fintype.card_subtype] + +end +end Contingency.BitModel.CoordinateLaw + + + + + + + +open Filter +namespace Contingency.BitModel.StackCode + + theorem prepare_observe (P : Program) (c : Config P) (b : Bool) : + ((compile P).step b (encode P c)).state=none ↔ c.state=none := by + rcases c with ⟨s,m⟩ + cases s with + | none => + dsimp only [encode,compile] + simp [Machine.step] + | some pc => + dsimp only [Machine.step,encode] + dsimp only [compile] + cases h : P.code pc <;> simp [first,prepare,h,active,preserved] + + theorem prepare_output (P : Program) (c : Config P) (b : Bool) : + ((compile P).step b (encode P c)).outputRev=c.memory.outputRev := by + rcases c with ⟨s,m⟩ + cases s with + | none => + dsimp only [encode,compile] + simp [Machine.step] + | some pc => + dsimp only [Machine.step,encode] + dsimp only [compile] + cases h : P.code pc <;> simp [first,prepare,h,active,preserved] + + theorem machine_run_succ (M : Machine) (xs : List Bool) {t : ℕ} (coins : Fin (t+1)→Bool) : + M.run xs coins=M.step (coins (Fin.last t)) (M.run xs (fun i : Fin t => coins i.castSucc)) := by + unfold Machine.run + rw [List.ofFn_succ',List.concat_eq_append,List.foldl_append] + rfl + + def coinLast (t : ℕ) : (Fin (t+1)→Bool) ≃ (Fin t→Bool)×Bool where + toFun f := (fun i => f i.castSucc,f (Fin.last t)) + invFun p := Fin.lastCases p.2 p.1 + left_inv f := by + funext i + refine Fin.lastCases ?_ (fun j => ?_) i <;> simp + right_inv p := by rcases p with ⟨f,b⟩; simp + + theorem count_last (t : ℕ) (p : (Fin t→Bool)→Prop) [DecidablePred p] : + (Finset.univ.filter fun c : Fin (t+1)→Bool => p (fun i => c i.castSucc)).card= + 2*(Finset.univ.filter p).card := by + classical + simp only [Finset.card_filter] + change (∑ c,if p ((coinLast t c).1) then 1 else 0)=_ + rw [(coinLast t).sum_comp (fun ab => if p ab.1 then (1:ℕ) else 0),Fintype.sum_prod_type,Finset.mul_sum] + apply Finset.sum_congr rfl + intro bs _ + by_cases hp : p bs <;> simp [hp] + + theorem mass_compile_odd (P : Program) (xs out : List Bool) (t : ℕ) : + (compile P).mass xs out (t*2+1)=mass P xs out t := by + classical + unfold Machine.mass + simp only [machine_run_succ,run_eq,prepare_observe,prepare_output] + rw [count_last (t*2) (fun c => (run P xs (fun i => c (second i))).state=none ∧ + (run P xs (fun i => c (second i))).memory.outputRev.reverse=out)] + rw [count_second t (fun c => (run P xs c).state=none ∧ + (run P xs c).memory.outputRev.reverse=out)] + unfold mass + push_cast + rw [pow_succ,pow_mul,pow_two] + field_simp + + theorem tail_compile_odd (P : Program) (xs : List Bool) (t : ℕ) : + (compile P).tail xs (t*2+1)=tail P xs t := by + classical + unfold Machine.tail + simp only [machine_run_succ,run_eq,ne_eq,prepare_observe] + rw [count_last (t*2) (fun c => (run P xs (fun i => c (second i))).state≠none)] + rw [count_second t (fun c => (run P xs c).state≠none)] + unfold tail + push_cast + rw [pow_succ,pow_mul,pow_two] + field_simp + + theorem mass_compile_all (P : Program) (xs out : List Bool) (t : ℕ) : + (compile P).mass xs out t=mass P xs out (t/2) := by + have hm := Nat.mod_lt t (by decide : 0<2) + have hd := Nat.mod_add_div t 2 + rcases (show t%2=0 ∨ t%2=1 by omega) with h|h + · have ht : t=t/2*2 := by omega + conv_lhs => rw [ht] + exact mass_compile P xs out (t/2) + · have ht : t=t/2*2+1 := by omega + conv_lhs => rw [ht] + exact mass_compile_odd P xs out (t/2) + + theorem tail_compile_all (P : Program) (xs : List Bool) (t : ℕ) : + (compile P).tail xs t=tail P xs (t/2) := by + have hm := Nat.mod_lt t (by decide : 0<2) + have hd := Nat.mod_add_div t 2 + rcases (show t%2=0 ∨ t%2=1 by omega) with h|h + · have ht : t=t/2*2 := by omega + conv_lhs => rw [ht] + exact tail_compile P xs (t/2) + · have ht : t=t/2*2+1 := by omega + conv_lhs => rw [ht] + exact tail_compile_odd P xs (t/2) + + theorem half_tendsto : Tendsto (fun t : ℕ => t/2) atTop atTop := by + apply tendsto_atTop.2 + intro b + filter_upwards [eventually_ge_atTop (2*b)] with t ht + omega + + theorem mass_limit_compile (P : Program) (xs out : List Bool) (r : ℝ) + (h : Tendsto (mass P xs out) atTop (nhds r)) : + Tendsto ((compile P).mass xs out) atTop (nhds r) := by + simpa only [Function.comp_def,← mass_compile_all] using h.comp half_tendsto + + theorem tail_limit_compile (P : Program) (xs : List Bool) (r : ℝ) + (h : Tendsto (tail P xs) atTop (nhds r)) : + Tendsto ((compile P).tail xs) atTop (nhds r) := by + simpa only [Function.comp_def,← tail_compile_all] using h.comp half_tendsto + + theorem tail_summable_compile (P : Program) (xs : List Bool) (h : Summable (tail P xs)) : + Summable ((compile P).tail xs) := by + apply Summable.even_add_odd + · simpa only [Nat.mul_comm 2,tail_compile] using h + · simpa only [Nat.mul_comm 2,tail_compile_odd] using h + + + + theorem expected_compile (P : Program) (xs : List Bool) (h : Summable (tail P xs)) : + (∑' t,(compile P).tail xs t)=2*(∑' t,tail P xs t) := by + have he : Summable (fun t => (compile P).tail xs (2*t)) := by + simpa only [Nat.mul_comm 2,tail_compile] using h + have ho : Summable (fun t => (compile P).tail xs (2*t+1)) := by + simpa only [Nat.mul_comm 2,tail_compile_odd] using h + rw [← tsum_even_add_odd he ho] + simp only [Nat.mul_comm 2,tail_compile,tail_compile_odd] + ring + +end Contingency.BitModel.StackCode + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/IntegerDrawTail.lean b/lean/OAI/Probability/Contingency/IntegerDrawTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..23e8fbf8c1f5976770e62be749a87e629d361604 --- /dev/null +++ b/lean/OAI/Probability/Contingency/IntegerDrawTail.lean @@ -0,0 +1,684 @@ +import Mathlib +import OAI.Probability.Contingency.IntegerDrawMachine + +namespace OAI + +/-! Integer Draw Tail. -/ + +noncomputable section + +open Filter +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +instance (B : List Bool) (f : ℕ→Bool) (j : ℕ) : Decidable (accepted B f j) := + inferInstanceAs (Decidable (beValue (candidate B f j)≤beValue B)) + +def extend {t : ℕ} (f : Fin t→Bool) (i : ℕ) : Bool := if h:i hn (Fin.ext h) + rcases lt_or_gt_of_ne hn' with hh|hh + · have hm := Nat.mul_le_mul_right (retryTime B) (Nat.succ_le_of_lt hh) + rw [Nat.succ_mul] at hm + dsimp [startTime,retryTime] at hv hm + omega + · have hm := Nat.mul_le_mul_right (retryTime B) (Nat.succ_le_of_lt hh) + rw [Nat.succ_mul] at hm + dsimp [startTime,retryTime] at hv hm + omega + apply Prod.ext hj + apply Fin.ext + rw [hj] at hv + omega + + theorem candidate_coord (B : List Bool) (k t : ℕ) (ht : startTime B k+successTime B≤t) + (f : Fin t→Bool) (j : Fin k) : + candidate B (extend f) j=List.ofFn (fun i => f (coord B k t ht (j,i))) := by + unfold candidate streamDigits + rw [digits_coin] + congr 1 + funext i + simp only [digitCoord,finProdFinEquiv] + have hc := (coord B k t ht (j,i)).isLt + dsimp [coord] at hc + have hi : startTime B ↑j+(2+4*↑i)=startTime B ↑j+↑i*4+2 := by omega + change extend f (startTime B ↑j+(2+4*↑i))=f (coord B k t ht (j,i)) + rw [hi] + simp [extend,hc,coord] + + theorem bound_lt (B : List Bool) : beValue B<2^B.length := by + simpa [wordValue] using wordValue_lt B.get + +def badCount (B : List Bool) : ℕ := 2^B.length-(beValue B+1) + +def rejectRate (B : List Bool) : ℝ := badCount B/2^B.length + + theorem bad_words (B : List Bool) : + (Finset.univ.filter fun bs : Fin B.length→Bool => ¬wordValue bs≤beValue B).card=badCount B := by + classical + have h := Finset.card_filter_add_card_filter_not + (s:=Finset.univ) (p:=fun bs : Fin B.length→Bool => wordValue bs≤beValue B) + rw [bounded_words _ _ (bound_lt B)] at h + simp only [Finset.card_univ,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin] at h + unfold badCount + omega + + theorem all_bad (B : List Bool) (k : ℕ) : + (Finset.univ.filter fun f : (Fin k×Fin B.length)→Bool => + ∀ j,¬wordValue (fun i => f (j,i))≤beValue B).card=(badCount B)^k := by + classical + simp only [Finset.card_filter] + change (∑ f,if (∀ j,¬wordValue ((Equiv.curry _ _ _ f) j)≤beValue B) then 1 else 0)=_ + rw [(Equiv.curry (Fin k) (Fin B.length) Bool).sum_comp + (fun f => if (∀ j,¬wordValue (f j)≤beValue B) then (1:ℕ) else 0)] + rw [← Finset.card_filter] + calc + _ = (Finset.univ.filter fun bs : Fin B.length→Bool => ¬wordValue bs≤beValue B).card^k := + CoordinateLaw.count_all k (fun bs : Fin B.length→Bool => ¬wordValue bs≤beValue B) + _ = _ := by rw [bad_words] + + theorem bad_probability (B : List Bool) (k t : ℕ) (ht : startTime B k+successTime B≤t) : + ((Finset.univ.filter fun f : Fin t→Bool => ∀ j : Fin k,¬accepted B (extend f) j).card:ℝ)/2^t= + rejectRate B^k := by + classical + have he : (fun f : Fin t→Bool => ∀ j : Fin k,¬accepted B (extend f) j)= + (fun f : Fin t→Bool => ∀ j : Fin k,¬wordValue (fun i => (f∘coord B k t ht) (j,i))≤beValue B) := by + funext f + simp only [accepted,candidate_coord B k t ht f,wordValue,Function.comp_def] + simp only [he] + have hh := CoordinateLaw.probability_restrict (coord B k t ht) (coord_injective B k t ht) + (fun g : (Fin k×Fin B.length)→Bool => ∀ j,¬wordValue (fun i => g (j,i))≤beValue B) + simp only [Fintype.card_fin,Fintype.card_prod] at hh + rw [hh,all_bad] + push_cast + rw [show k*B.length=B.length*k from Nat.mul_comm _ _,pow_mul] + exact (div_pow _ _ _).symm + + theorem tail_bound (B : List Bool) (k t : ℕ) (ht : startTime B k+successTime B≤t) : + tail program B t≤rejectRate B^k := by + classical + rw [← bad_probability B k t ht] + unfold tail + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast Finset.card_le_card (show + (Finset.univ.filter fun f : Fin t→Bool => (run program B f).state≠none) ⊆ + (Finset.univ.filter fun f : Fin t→Bool => ∀ j : Fin k,¬accepted B (extend f) j) from by + intro f hf + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hf ⊢ + intro j hj + apply hf + have hh := accepts_halt B (extend f) k t ⟨j,j.isLt,hj⟩ ht + simpa only [trace_extend,run] using hh) + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + +namespace Contingency.BitModel.CoordinateLaw +open scoped BigOperators +noncomputable section + + theorem count_snoc {γ : Type*} [Fintype γ] (k : ℕ) + (p : (Fin k→γ)→Prop) (q : γ→Prop) [DecidablePred p] [DecidablePred q] : + (Finset.univ.filter fun f : Fin (k+1)→γ => p (fun i => f i.castSucc) ∧ q (f (Fin.last k))).card= + (Finset.univ.filter q).card*(Finset.univ.filter p).card := by + classical + simp only [Finset.card_filter] + rw [← (Fin.snocEquiv (fun _ : Fin (k+1) => γ)).sum_comp + (fun f => if p (fun i => f i.castSucc) ∧ q (f (Fin.last k)) then (1:ℕ) else 0)] + simp only [Fintype.sum_prod_type,Fin.snocEquiv_apply,Fin.snoc_castSucc,Fin.snoc_last] + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro v _ + by_cases hq : q v + · simp [hq] + · simp [hq] + +end +end Contingency.BitModel.CoordinateLaw + + + + + + + +open scoped BigOperators +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +def word (B : List Bool) (u : Fin (2^B.length)) : List Bool := List.ofFn ((wordEquiv B.length).symm u) + +@[simp] theorem word_value (B : List Bool) (u : Fin (2^B.length)) : beValue (word B u)=u.val := by + have hh := congrArg Fin.val ((wordEquiv B.length).apply_symm_apply u) + exact hh + + theorem word_injective (B : List Bool) : Function.Injective (word B) := by + intro u v he + apply Fin.ext + simpa only [word_value] using congrArg beValue he + +def hit (B : List Bool) (f : ℕ→Bool) (j : ℕ) (u : Fin (2^B.length)) : Prop := + (∀ i : Fin j,¬accepted B f i) ∧ candidate B f j=word B u + +instance (B : List Bool) (f : ℕ→Bool) (j : ℕ) (u : Fin (2^B.length)) : Decidable (hit B f j u) := by + unfold hit + infer_instance + + theorem hit_halts (B : List Bool) (f : ℕ→Bool) (j t : ℕ) (u : Fin (2^B.length)) + (hu : u.val≤beValue B) (hh : hit B f j u) (ht : startTime B j+successTime B≤t) : + let result := (trace f 0 t).foldl (fun c b => step program b c) (initial program B) + result.state=none ∧ result.memory.outputRev.reverse=word B u := by + have ha : accepted B f j := by unfold accepted; rw [hh.2,word_value]; exact hu + have hp : ∀ i hh.1 ⟨i,hi⟩ + simpa only [hh.2] using first_accept_later B f j t ha hp ht + + theorem hit_disjoint (B : List Bool) (f : ℕ→Bool) (i j : ℕ) (u : Fin (2^B.length)) + (hu : u.val≤beValue B) (hi : hit B f i u) (hj : hit B f j u) : i=j := by + have hai : accepted B f i := by unfold accepted; rw [hi.2,word_value]; exact hu + have haj : accepted B f j := by unfold accepted; rw [hj.2,word_value]; exact hu + rcases lt_trichotomy i j with h|h|h + · exact False.elim (hj.1 ⟨i,h⟩ hai) + · exact h + · exact False.elim (hi.1 ⟨j,h⟩ haj) + + theorem hit_coordinates_count (B : List Bool) (j : ℕ) (u : Fin (2^B.length)) : + (Finset.univ.filter fun f : (Fin (j+1)×Fin B.length)→Bool => + (∀ i : Fin j,¬wordValue (fun a => f (i.castSucc,a))≤beValue B) ∧ + (fun a => f (Fin.last j,a))=(wordEquiv B.length).symm u).card=badCount B^j := by + classical + simp only [Finset.card_filter] + change (∑ f,if (∀ i : Fin j,¬wordValue ((Equiv.curry _ _ _ f) i.castSucc)≤beValue B) ∧ + ((Equiv.curry _ _ _ f) (Fin.last j))=(wordEquiv B.length).symm u then 1 else 0)=_ + rw [(Equiv.curry (Fin (j+1)) (Fin B.length) Bool).sum_comp + (fun f => if (∀ i : Fin j,¬wordValue (f i.castSucc)≤beValue B) ∧ + f (Fin.last j)=(wordEquiv B.length).symm u then (1:ℕ) else 0)] + rw [← Finset.card_filter] + rw [CoordinateLaw.count_snoc j (fun f : Fin j→Fin B.length→Bool => ∀ i,¬wordValue (f i)≤beValue B) + (fun bs => bs=(wordEquiv B.length).symm u)] + simp only [Finset.filter_eq',Finset.mem_univ,ite_true,Finset.card_singleton,one_mul] + rw [CoordinateLaw.count_all j (fun bs : Fin B.length→Bool => ¬wordValue bs≤beValue B),bad_words] + + theorem hit_probability (B : List Bool) (j t : ℕ) (ht : startTime B (j+1)+successTime B≤t) + (u : Fin (2^B.length)) : + ((Finset.univ.filter fun f : Fin t→Bool => hit B (extend f) j u).card:ℝ)/2^t= + rejectRate B^j/2^B.length := by + classical + let e := coord B (j+1) t ht + let p : ((Fin (j+1)×Fin B.length)→Bool)→Prop := fun g => + (∀ i : Fin j,¬wordValue (fun a => g (i.castSucc,a))≤beValue B) ∧ + (fun a => g (Fin.last j,a))=(wordEquiv B.length).symm u + have he : (Finset.univ.filter fun f : Fin t→Bool => hit B (extend f) j u)= + (Finset.univ.filter fun f : Fin t→Bool => p (f∘e)) := by + apply Finset.filter_congr + intro f _ + dsimp only [hit,accepted,p,e,Function.comp_def] + have hl := candidate_coord B (j+1) t ht f (Fin.last j) + have hp := fun i : Fin j => candidate_coord B (j+1) t ht f i.castSucc + simp only [Fin.val_last,Fin.val_castSucc] at hl hp + simp only [hl,hp,word,List.ofFn_inj,wordValue] + rw [he] + have hh := CoordinateLaw.probability_restrict e (coord_injective B (j+1) t ht) p + simp only [Fintype.card_fin,Fintype.card_prod] at hh + rw [hh] + change ((Finset.univ.filter _).card:ℝ)/2^((j+1)*B.length)=_ + rw [hit_coordinates_count] + push_cast + rw [Nat.add_mul,Nat.one_mul,pow_add,Nat.mul_comm j B.length,pow_mul] + unfold rejectRate + rw [div_pow] + field_simp + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + + theorem rate_nonneg (B : List Bool) : 0≤rejectRate B := by unfold rejectRate; positivity + theorem rate_lt_one (B : List Bool) : rejectRate B<1 := by + have hp : 0<2^B.length := by positivity + have hb : badCount B<2^B.length := by unfold badCount; omega + unfold rejectRate + apply (div_lt_one (by positivity)).2 + exact_mod_cast hb + + theorem rate_le_half (B : List Bool) (h : 2^B.length≤2*(beValue B+1)) : rejectRate B≤1/2 := by + have hb := Nat.sub_add_cancel (Nat.succ_le_of_lt (bound_lt B)) + change badCount B+(beValue B+1)=2^B.length at hb + have hn : 2*badCount B≤2^B.length := by omega + have hr : (2:ℝ)*(badCount B:ℝ)≤(2:ℝ)^B.length := by exact_mod_cast hn + unfold rejectRate + apply (div_le_iff₀ (by positivity : (0:ℝ)<2^B.length)).2 + nlinarith + + theorem grouped_geometric (C : ℕ) (hC : 0 q^(t/C)) ∧ (∑' t : ℕ,q^(t/C))=(C:ℝ)/(1-q) := by + let : NeZero C := ⟨by omega⟩ + have hs : Summable (fun p : ℕ×Fin C => q^p.1) := by + apply (summable_prod_of_nonneg (fun _ => pow_nonneg hq _)).2 + constructor + · intro n; exact Summable.of_finite + · simpa [tsum_fintype] using (summable_geometric_of_lt_one hq hq1).mul_left (C:ℝ) + have hh : Summable (fun t : ℕ => q^(t/C)) := by + simpa [Function.comp_def,Nat.divModEquiv_apply] using (Nat.divModEquiv C).summable_iff.mpr hs + refine ⟨hh,?_⟩ + have he := (Nat.divModEquiv C).tsum_eq (fun p : ℕ×Fin C => q^p.1) + simp only [Nat.divModEquiv_apply] at he + rw [he,hs.tsum_prod] + simp only [tsum_fintype,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + rw [tsum_mul_left,tsum_geometric_of_lt_one hq hq1] + rfl + + theorem tail_nonneg (P : Program) (xs : List Bool) (t : ℕ) : 0≤tail P xs t := by + unfold tail + positivity + + theorem tail_le_one (P : Program) (xs : List Bool) (t : ℕ) : tail P xs t≤1 := by + classical + unfold tail + apply (div_le_one (by positivity)).2 + have hc := Finset.card_filter_le (Finset.univ : Finset (Fin t→Bool)) (fun f => (run P xs f).state≠none) + simp only [Finset.card_univ,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin] at hc + exact_mod_cast hc + + theorem shifted_tail_bound (B : List Bool) (t : ℕ) : + tail program B (t+(prepTime B+successTime B))≤rejectRate B^(t/retryTime B) := by + apply tail_bound + have hh := Nat.div_mul_le_self t (retryTime B) + dsimp [startTime] + omega + + theorem stack_summable (B : List Bool) : Summable (tail program B) := by + have hp : 0 tail_nonneg _ _ _) (shifted_tail_bound B) + + theorem stack_expected (B : List Bool) : + (∑' t,tail program B t)≤(prepTime B+successTime B:ℕ)+(retryTime B:ℝ)/(1-rejectRate B) := by + have hp : 0 f ⟨i,lt_of_lt_of_le i.isLt hst⟩)).state=none) : + run P xs f=run P xs (fun i : Fin s => f ⟨i,lt_of_lt_of_le i.isLt hst⟩) := by + have hp : trace (extend f) 0 s=List.ofFn (fun i : Fin s => f ⟨i,lt_of_lt_of_le i.isLt hst⟩) := by + unfold trace + congr 1 + funext i + simp [extend,lt_of_lt_of_le i.isLt hst] + have ht : List.ofFn f=trace (extend f) 0 s ++ trace (extend f) s (t-s) := by + rw [← trace_extend f] + have hh := trace_append (extend f) 0 s (t-s) + simpa [Nat.add_sub_cancel' hst] using hh.symm + unfold run + rw [ht,List.foldl_append,hp] + change (trace (extend f) s (t-s)).foldl (fun c b => step P b c) _=_ + generalize hc : run P xs (fun i : Fin s => f ⟨i,lt_of_lt_of_le i.isLt hst⟩)=c at hs + change (trace (extend f) s (t-s)).foldl (fun c b => step P b c) (run P xs _)=run P xs _ + rw [hc] + rcases c with ⟨state,m⟩ + change state=none at hs + subst state + exact halted_fold P _ m + + theorem mass_nonneg (P : Program) (xs out : List Bool) (t : ℕ) : 0 ≤ mass P xs out t := by + unfold mass + positivity + + theorem mass_le_one (P : Program) (xs out : List Bool) (t : ℕ) : mass P xs out t≤1 := by + classical + unfold mass + apply (div_le_one (by positivity)).2 + have hh := Finset.card_filter_le (Finset.univ : Finset (Fin t→Bool)) + (fun f => (run P xs f).state=none ∧ (run P xs f).memory.outputRev.reverse=out) + simp only [Finset.card_univ,Fintype.card_fun,Fintype.card_bool,Fintype.card_fin] at hh + exact_mod_cast hh + + theorem mass_mono (P : Program) (xs out : List Bool) : Monotone (mass P xs out) := by + classical + intro s t hst + let e : Fin s→Fin t := fun i => ⟨i,lt_of_lt_of_le i.isLt hst⟩ + have hi : Function.Injective e := by + intro i j h + exact Fin.ext (congrArg (fun x : Fin t => x.val) h) + let p : (Fin s→Bool)→Prop := fun f => (run P xs f).state=none ∧ (run P xs f).memory.outputRev.reverse=out + have he := CoordinateLaw.probability_restrict e hi p + simp only [Fintype.card_fin] at he + unfold mass + change ((Finset.univ.filter p).card:ℝ)/2^s≤_ + rw [← he] + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast Finset.card_le_card (show + (Finset.univ.filter fun f : Fin t→Bool => p (f∘e)) ⊆ + (Finset.univ.filter fun f : Fin t→Bool => (run P xs f).state=none ∧ (run P xs f).memory.outputRev.reverse=out) from by + intro f hf + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hf ⊢ + have hh := run_prefix_halt P xs s t hst f hf.1 + rw [hh] + exact hf) + + theorem mass_limit_exists (P : Program) (xs out : List Bool) : + ∃ r : ℝ,Tendsto (mass P xs out) atTop (nhds r) := + ⟨_,tendsto_atTop_ciSup (mass_mono P xs out) ⟨1,by + rintro _ ⟨t,rfl⟩ + exact mass_le_one P xs out t⟩⟩ + + theorem sum_mass_le_one {ι : Type*} [Fintype ι] [DecidableEq ι] + (P : Program) (xs : List Bool) (out : ι→List Bool) (ho : Function.Injective out) (t : ℕ) : + ∑ i,mass P xs (out i) t≤1 := by + classical + simp only [mass,Finset.card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + rw [← Finset.sum_div,Finset.sum_comm] + apply (div_le_one (by positivity)).2 + calc + _ ≤ ∑ _f : Fin t→Bool,(1:ℝ) := by + apply Finset.sum_le_sum + intro f _ + have hc : (Finset.univ.filter fun i : ι => (run P xs f).state=none ∧ + (run P xs f).memory.outputRev.reverse=out i).card≤1 := by + apply Finset.card_le_one.mpr + intro i hi j hj + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hi hj + exact ho (hi.2.symm.trans hj.2) + have hcr : ((Finset.univ.filter fun i : ι => (run P xs f).state=none ∧ + (run P xs f).memory.outputRev.reverse=out i).card:ℝ)≤1 := by exact_mod_cast hc + simpa only [Finset.card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] using hcr + _ = _ := by simp + +end +end Contingency.BitModel.StackCode + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + + theorem initial_mass_lower (B : List Bool) (k t : ℕ) (ht : startTime B k+successTime B≤t) + (u : Fin (2^B.length)) (hu : u.val≤beValue B) : + (∑ j∈Finset.range k,rejectRate B^j/2^B.length) ≤ mass program B (word B u) t := by + classical + let s : ℕ→Finset (Fin t→Bool) := fun j => Finset.univ.filter fun f => hit B (extend f) j u + have hsub : (Finset.range k).biUnion s ⊆ + (Finset.univ.filter fun f : Fin t→Bool => (run program B f).state=none ∧ + (run program B f).memory.outputRev.reverse=word B u) := by + intro f hf + obtain ⟨j,hj,hf⟩ := Finset.mem_biUnion.mp hf + have hhit : hit B (extend f) j u := (Finset.mem_filter.mp hf).2 + have hjk : j rejectRate B^j/2^B.length) (1/(beValue B+1:ℝ)) := by + have hh := (hasSum_geometric_of_lt_one (rate_nonneg B) (rate_lt_one B)).div_const ((2:ℝ)^B.length) + have hb := Nat.sub_add_cancel (Nat.succ_le_of_lt (bound_lt B)) + change badCount B+(beValue B+1)=2^B.length at hb + have hr : (badCount B:ℝ)+(beValue B+1:ℝ)=(2:ℝ)^B.length := by exact_mod_cast hb + have hm : (beValue B+1:ℝ)≠0 := by positivity + have he : (1 - rejectRate B)⁻¹ / (2:ℝ)^B.length = 1/(beValue B+1:ℝ) := by + unfold rejectRate + field_simp + rw [show (2:ℝ)^B.length - badCount B = beValue B+1 by linarith] + exact div_self hm + simpa only [he] using hh + + theorem limit_lower (B : List Bool) (u : Fin (2^B.length)) (hu : u.val≤beValue B) + (r : ℝ) (hr : Tendsto (mass program B (word B u)) atTop (nhds r)) : 1/(beValue B+1:ℝ)≤r := by + apply le_of_tendsto' (hit_series B).tendsto_sum_nat + intro k + apply ge_of_tendsto hr + filter_upwards [eventually_ge_atTop (startTime B k+successTime B)] with t ht + exact initial_mass_lower B k t ht u hu + + def validWord (B : List Bool) (u : Fin (beValue B+1)) : List Bool := + word B ⟨u,Nat.lt_of_lt_of_le u.isLt (Nat.succ_le_of_lt (bound_lt B))⟩ + + theorem validWord_injective (B : List Bool) : Function.Injective (validWord B) := by + intro u v he + have hh := word_injective B he + exact Fin.ext (congrArg (fun x : Fin (2^B.length) => x.val) hh) + + theorem stack_uniform (B : List Bool) (u : Fin (beValue B+1)) : + Tendsto (mass program B (validWord B u)) atTop (nhds (1/(beValue B+1:ℝ))) := by + choose r hr using fun v : Fin (beValue B+1) => mass_limit_exists program B (validWord B v) + have hlo : ∀ v,1/(beValue B+1:ℝ)≤r v := by + intro v + exact limit_lower B ⟨v,Nat.lt_of_lt_of_le v.isLt (Nat.succ_le_of_lt (bound_lt B))⟩ (Nat.le_of_lt_succ v.isLt) (r v) (hr v) + have hsum : ∑ v,r v≤1 := by + apply le_of_tendsto' (tendsto_finsetSum Finset.univ (fun v _ => hr v)) + intro t + exact sum_mass_le_one program B (validWord B) (validWord_injective B) t + have he : ∑ v : Fin (beValue B+1),(1/(beValue B+1:ℝ))=1 := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] + field_simp + have heach : ∀ v,r v=1/(beValue B+1:ℝ) := by + intro v + apply le_antisymm _ (hlo v) + have hh := Finset.sum_le_sum (s:=Finset.univ.erase v) (fun i _ => hlo i) + have h1 := Finset.sum_erase_add Finset.univ r (Finset.mem_univ v) + have h2 := Finset.sum_erase_add Finset.univ (fun _ : Fin (beValue B+1) => 1/(beValue B+1:ℝ)) (Finset.mem_univ v) + linarith + simpa only [heach u] using hr u + + theorem machine_uniform (B : List Bool) (u : Fin (beValue B+1)) : + Tendsto (machine.mass B (validWord B u)) atTop (nhds (1/(beValue B+1:ℝ))) := + mass_limit_compile program B (validWord B u) _ (stack_uniform B u) + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +def drawBits (B : List Bool) (f : ℕ→Bool) (j : ℕ) (i : Fin B.length) : Bool := + f (startTime B j+i*4+2) + +theorem candidate_bits (B : List Bool) (f : ℕ→Bool) (j : ℕ) : + candidate B f j=List.ofFn (drawBits B f j) := by + unfold candidate streamDigits + rw [digits_coin] + congr 1 + funext i + change f (startTime B j+(2+4*i.val))=f (startTime B j+i.val*4+2) + congr 1 + omega + +theorem wordValue_false (n : ℕ) : wordValue (fun _ : Fin n => false)=0 := by + induction n with + | zero => rfl + | succ n ih => rw [wordValue_succ]; simp [ih] + +theorem extend_accepts (B : List Bool) {t : ℕ} (f : Fin t→Bool) : + accepted B (extend f) t := by + have hg : drawBits B (extend f) t = fun _ => false := by + funext i + have hr : 1≤retryTime B := by unfold retryTime; omega + have ht : t ≤ startTime B t := by + unfold startTime + have hm := Nat.mul_le_mul_left t hr + omega + simp [drawBits,extend,show ¬startTime B t+i*4+2 false)≤_ + rw [wordValue_false] + exact Nat.zero_le _ + +theorem validWord_bits (B : List Bool) (f : Fin B.length→Bool) (hf : wordValue f≤beValue B) : + validWord B ⟨wordValue f,Nat.lt_succ_of_le hf⟩=List.ofFn f := by + unfold validWord word + congr 1 + apply (wordEquiv B.length).injective + rw [Equiv.apply_symm_apply] + apply Fin.ext + rfl + +theorem halted_trace (P : Program) (B : List Bool) (f : ℕ→Bool) (t T : ℕ) (htT : t≤T) + (hh : ((trace f 0 t).foldl (fun c b => step P b c) (initial P B)).state=none) : + (trace f 0 T).foldl (fun c b => step P b c) (initial P B)= + (trace f 0 t).foldl (fun c b => step P b c) (initial P B) := by + have he : trace f 0 T=trace f 0 t ++ trace f t (T-t) := by + simpa only [Nat.zero_add,Nat.add_sub_cancel' htT] using (trace_append f 0 t (T-t)).symm + rw [he,List.foldl_append] + generalize hc : (trace f 0 t).foldl (fun c b => step P b c) (initial P B)=c at hh ⊢ + rcases c with ⟨s,m⟩ + change s=none at hh + subst s + exact halted_fold P _ m + +theorem stack_safe (B : List Bool) {t : ℕ} (f : Fin t→Bool) (hh : (run program B f).state=none) : + ∃ u : Fin (beValue B+1),(run program B f).memory.outputRev.reverse=validWord B u := by + classical + have ha : ∃ j,accepted B (extend f) j := ⟨t,extend_accepts B f⟩ + let j := Nat.find ha + have hj : accepted B (extend f) j := Nat.find_spec ha + have hp : ∀ i Nat.find_min ha hi + let T := max t (startTime B j+successTime B) + have hr := first_accept_later B (extend f) j T hj hp (le_max_right _ _) + have he := halted_trace program B (extend f) t T (le_max_left _ _) (by simpa only [trace_extend,run] using hh) + rw [he] at hr + simp only [trace_extend] at hr + have hv : wordValue (drawBits B (extend f) j)≤beValue B := by + simpa only [accepted,candidate_bits,wordValue] using hj + refine ⟨⟨wordValue (drawBits B (extend f) j),Nat.lt_succ_of_le hv⟩,?_⟩ + rw [validWord_bits B _ hv] + simpa only [candidate_bits,run] using hr.2 + +end +end Contingency.BitModel.StackCode.IntegerDraw + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/LawComposition.lean b/lean/OAI/Probability/Contingency/LawComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..01bd2295de8b8688cae2996450ca7fa91070471b --- /dev/null +++ b/lean/OAI/Probability/Contingency/LawComposition.lean @@ -0,0 +1,681 @@ +import Mathlib +import OAI.Probability.Contingency.DyadicLaws + +namespace OAI + +/-! Law Composition. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.Law +noncomputable section +variable {α β γ : Type*} [Fintype α] [Fintype β] [Fintype γ] + +theorem pure_bind (x : α) (f : α → Law β) : (pure x).bind f=f x := by + classical + apply Law.ext; funext y + simp [bind,pure] + +theorem bind_assoc (p : Law α) (f : α → Law β) (g : β → Law γ) : + (p.bind f).bind g=p.bind (fun x => (f x).bind g) := by + apply Law.ext; funext y + simp only [bind,Finset.sum_mul,Finset.mul_sum,mul_assoc] + exact Finset.sum_comm + +theorem map_bind (p : Law α) (f : α → β) (g : β → Law γ) : + (p.map f).bind g=p.bind (fun x => g (f x)) := by + simp only [map,bind_assoc,pure_bind] + +theorem map_map (p : Law α) (f : α → β) (g : β → γ) : + (p.map f).map g=p.map (fun x => g (f x)) := by + change (p.map f).bind _=_ + rw [map_bind] + rfl + +end +end Contingency.Law + + + + + +open scoped BigOperators +open Filter + +namespace Contingency + + +def Tables {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) := + {X : Fin m → Fin n → ℕ // + (∀ i, ∑ j, X i j = r i) ∧ (∀ j, ∑ i, X i j = c j)} + +instance tablesFinite {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finite (Tables r c) := by + let f : Tables r c → (i : Fin m) → Fin n → Fin (r i + 1) := + fun X i j => ⟨X.val i j, by + have := Finset.single_le_sum (fun (j : Fin n) _ => Nat.zero_le (X.val i j)) + (Finset.mem_univ j) + rw [X.property.1 i] at this + omega⟩ + apply Finite.of_injective f + intro X Y h + apply Subtype.ext + funext i j + exact congrArg Fin.val (congrFun (congrFun h i) j) + + + +def encodeNat (x : ℕ) : List Bool := + List.replicate x.bits.length true ++ false :: x.bits + +def encodeList (xs : List ℕ) : List Bool := xs.flatMap encodeNat + +def inputBits {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) (k : ℕ) : List Bool := + encodeList ([m, n, k] ++ List.ofFn r ++ List.ofFn c) + +def outputBits {m n : ℕ} {r : Fin m → ℕ} {c : Fin n → ℕ} + (X : Tables r c) : List Bool := + encodeList ((List.ofFn fun i => List.ofFn (X.val i)).flatten) + +namespace BitModel + +inductive Move | left | stay | right + deriving DecidableEq + + + +structure Tape where + left : List (Option Bool) + head : Option Bool + right : List (Option Bool) + deriving DecidableEq + +def Tape.blank : Tape := ⟨[], none, []⟩ + +def Tape.ofInput (xs : List Bool) : Tape := + match xs with + | [] => .blank + | x :: xs => ⟨[], some x, xs.map some⟩ + +def Tape.move (d : Move) (a : Option Bool) (t : Tape) : Tape := + match d with + | .stay => ⟨t.left, a, t.right⟩ + | .left => match t.left with + | [] => ⟨[], none, a :: t.right⟩ + | x :: xs => ⟨xs, x, a :: t.right⟩ + | .right => match t.right with + | [] => ⟨a :: t.left, none, []⟩ + | x :: xs => ⟨a :: t.left, x, xs⟩ + + + +structure Instruction (states tapes : ℕ) where + next : Option (Fin states) + write : Fin tapes → Option Bool + move : Fin tapes → Move + emit : Option Bool + + + +structure Machine where + states : ℕ + tapes : ℕ + start : Fin states + inputTape : Fin tapes + transition : Fin states → Bool → (Fin tapes → Option Bool) → Instruction states tapes + +structure Config (M : Machine) where + state : Option (Fin M.states) + tape : Fin M.tapes → Tape + outputRev : List Bool + +def Machine.initial (M : Machine) (xs : List Bool) : Config M := + ⟨some M.start, fun i => if i = M.inputTape then .ofInput xs else .blank, []⟩ + +def Machine.step (M : Machine) (coin : Bool) (c : Config M) : Config M := + match c.state with + | none => c + | some s => + let a := M.transition s coin (fun i => (c.tape i).head) + ⟨a.next, fun i => (c.tape i).move (a.move i) (a.write i), + match a.emit with | none => c.outputRev | some b => b :: c.outputRev⟩ + +def Machine.run (M : Machine) (xs : List Bool) {t : ℕ} (coins : Fin t → Bool) : Config M := + (List.ofFn coins).foldl (fun c b => M.step b c) (M.initial xs) + + + +noncomputable def Machine.mass (M : Machine) (xs out : List Bool) (t : ℕ) : ℝ := + ((Finset.univ.filter fun coins : Fin t → Bool => + (M.run xs coins).state = none ∧ (M.run xs coins).outputRev.reverse = out).card : ℝ) / + 2 ^ t + + +noncomputable def Machine.tail (M : Machine) (xs : List Bool) (t : ℕ) : ℝ := + ((Finset.univ.filter fun coins : Fin t → Bool => + (M.run xs coins).state ≠ none).card : ℝ) / 2 ^ t + +end BitModel + + + +def inputSize (m n N : ℕ) : ℕ := m + n + Nat.log2 (N + 1) + 1 + +noncomputable def variationBy {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + (M : BitModel.Machine) (k t : ℕ) : ℝ := by + letI := Fintype.ofFinite (Tables r c) + exact (∑ X : Tables r c, + |M.mass (inputBits r c k) (outputBits X) t - 1 / Fintype.card (Tables r c)|) / 2 + + + +def BoundedMain : Prop := + ∃ (M : BitModel.Machine) (A q : ℕ), + ∀ (m n : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ), + (∑ i, r i) = (∑ j, c j) → ∀ k : ℕ, 1 ≤ k → + ∃ t : ℕ, t ≤ A * (inputSize m n (∑ i, r i) + k) ^ q ∧ + (∀ coins : Fin t → Bool, + (M.run (inputBits r c k) coins).state = none ∧ + ∃ X : Tables r c, + (M.run (inputBits r c k) coins).outputRev.reverse = outputBits X) ∧ + variationBy r c M k t ≤ (2 : ℝ) ^ (-(k : ℤ)) + + + +def ExactMain : Prop := + ∃ (M : BitModel.Machine) (A q : ℕ), + ∀ (m n : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ), + (∑ i, r i) = (∑ j, c j) → + (∀ (t : ℕ) (coins : Fin t → Bool), + (M.run (inputBits r c 0) coins).state = none → ∃ X : Tables r c, + (M.run (inputBits r c 0) coins).outputRev.reverse = outputBits X) ∧ + Tendsto (M.tail (inputBits r c 0)) atTop (nhds 0) ∧ + (∀ X : Tables r c, Tendsto (M.mass (inputBits r c 0) (outputBits X)) + atTop (nhds (1 / (Nat.card (Tables r c) : ℝ)))) ∧ + Summable (M.tail (inputBits r c 0)) ∧ + (∑' t, M.tail (inputBits r c 0) t) ≤ + (A * (inputSize m n (∑ i, r i)) ^ q : ℕ) + + + +def MainTheorem : Prop := BoundedMain ∧ ExactMain + +end Contingency + + + + + +open scoped BigOperators + +namespace Contingency + + + +theorem tables_nonempty {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i) = ∑ j, c j) : Nonempty (Tables r c) := by + classical + let e : (Σ i, Fin (r i)) ≃ (Σ j, Fin (c j)) := + Fintype.equivOfCardEq (by simpa [Fintype.card_sigma] using hrc) + let X (i : Fin m) (j : Fin n) : ℕ := ∑ z : (Σ i, Fin (r i)), + (if z.1=i then 1 else 0)*(if (e z).1=j then 1 else 0) + refine ⟨⟨X,?_,?_⟩⟩ + · intro i + change (∑ j, ∑ z : (Σ i, Fin (r i)), + (if z.1=i then 1 else 0)*(if (e z).1=j then 1 else 0)) = r i + rw [Finset.sum_comm] + simp only [← Finset.mul_sum] + have hz (z : Σ i, Fin (r i)) : (∑ j, if (e z).1=j then (1:ℕ) else 0)=1 := by simp + simp only [hz,mul_one] + rw [Fintype.sum_sigma] + change (∑ a, ∑ _t : Fin (r a), if a=i then (1:ℕ) else 0)=r i + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_ite,mul_one,mul_zero] + simp + · intro j + change (∑ i, ∑ z : (Σ i, Fin (r i)), + (if z.1=i then 1 else 0)*(if (e z).1=j then 1 else 0)) = c j + rw [Finset.sum_comm] + simp only [← Finset.sum_mul] + have hz (z : Σ i, Fin (r i)) : (∑ i, if z.1=i then (1:ℕ) else 0)=1 := by simp + simp only [hz,one_mul] + calc + _ = ∑ z : (Σ j, Fin (c j)), if z.1=j then (1:ℕ) else 0 := + e.sum_comp (fun z : (Σ j, Fin (c j)) => if z.1=j then (1:ℕ) else 0) + _ = _ := by + rw [Fintype.sum_sigma] + change (∑ a, ∑ _t : Fin (c a), if a=j then (1:ℕ) else 0)=c j + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_ite,mul_one,mul_zero] + simp + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section + +lemma sum_dite_subtype {α M : Type*} [Fintype α] [AddCommMonoid M] + (p : α → Prop) [DecidablePred p] (f : {x // p x} → M) : + (∑ x, if h : p x then f ⟨x,h⟩ else 0)=∑ x,f x := by + symm + apply Fintype.sum_of_injective Subtype.val Subtype.val_injective + · intro i hi + split_ifs with h + · exact (hi ⟨⟨i,h⟩,rfl⟩).elim + · rfl + · intro i; simp [i.property] + +variable {m n a b : ℕ} {r : Fin m → ℕ} {c : Fin n → ℕ} + +theorem table_cell_le_row (X : Tables r c) (i : Fin m) (j : Fin n) : X.val i j≤r i := by + rw [← X.property.1 i] + exact Finset.single_le_sum (fun j _ => Nat.zero_le (X.val i j)) (Finset.mem_univ j) + +theorem table_cell_le_col (X : Tables r c) (i : Fin m) (j : Fin n) : X.val i j≤c j := by + rw [← X.property.2 j] + exact Finset.single_le_sum (fun i _ => Nat.zero_le (X.val i j)) (Finset.mem_univ i) + +variable (p : Fin m → Prop) (q : Fin n → Prop) [DecidablePred p] [DecidablePred q] + (er : Fin a ≃ {i // p i}) (ec : Fin b ≃ {j // q j}) + (hr : ∀ i,¬p i → r i=0) (hc : ∀ j,¬q j → c j=0) + +def restrictTable (X : Tables r c) : + Tables (fun i => r (er i).val) (fun j => c (ec j).val) := by + refine ⟨fun i j => X.val (er i).val (ec j).val,?_,?_⟩ + · intro i + rw [ec.sum_comp (fun j => X.val (er i).val j.val)] + calc + _ = ∑ j,X.val (er i).val j := by + apply Fintype.sum_of_injective Subtype.val Subtype.val_injective + · intro j hj + have hn : ¬q j := fun h => hj ⟨⟨j,h⟩,rfl⟩ + have h := table_cell_le_col X (er i).val j + rw [hc j hn] at h + omega + · intro j; rfl + _ = _ := X.property.1 _ + · intro j + rw [er.sum_comp (fun i => X.val i.val (ec j).val)] + calc + _ = ∑ i,X.val i (ec j).val := by + apply Fintype.sum_of_injective Subtype.val Subtype.val_injective + · intro i hi + have hn : ¬p i := fun h => hi ⟨⟨i,h⟩,rfl⟩ + have h := table_cell_le_row X i (ec j).val + rw [hr i hn] at h + omega + · intro i; rfl + _ = _ := X.property.2 _ + +def expandTable (X : Tables (fun i => r (er i).val) (fun j => c (ec j).val)) : Tables r c := by + refine ⟨fun i j => if hi : p i then if hj : q j then X.val (er.symm ⟨i,hi⟩) (ec.symm ⟨j,hj⟩) else 0 else 0,?_,?_⟩ + · intro i + by_cases hi : p i + · simp only [dite_eq_left hi] + rw [sum_dite_subtype q (fun j => X.val (er.symm ⟨i,hi⟩) (ec.symm j))] + rw [← ec.sum_comp (fun j => X.val (er.symm ⟨i,hi⟩) (ec.symm j))] + simp only [Equiv.symm_apply_apply] + simp only [X.property.1,Equiv.apply_symm_apply] + · simp [hi,hr i hi] + · intro j + by_cases hj : q j + · simp only [dite_eq_left hj] + rw [sum_dite_subtype p (fun i => X.val (er.symm i) (ec.symm ⟨j,hj⟩))] + rw [← er.sum_comp (fun i => X.val (er.symm i) (ec.symm ⟨j,hj⟩))] + simp only [Equiv.symm_apply_apply] + simp only [X.property.2,Equiv.apply_symm_apply] + · simp [hj,hc j hj] + + + +def restrictTableEquiv : Tables r c ≃ Tables (fun i => r (er i).val) (fun j => c (ec j).val) where + toFun := restrictTable p q er ec hr hc + invFun := expandTable p q er ec hr hc + left_inv X := by + apply Subtype.ext; funext i j + by_cases hi : p i + · by_cases hj : q j + · simp [expandTable,restrictTable,hi,hj] + · have hz : X.val i j=0 := by have h := table_cell_le_col X i j; rw [hc j hj] at h; omega + simp [expandTable,hi,hj,hz] + · have hz : X.val i j=0 := by have h := table_cell_le_row X i j; rw [hr i hi] at h; omega + simp [expandTable,hi,hz] + right_inv X := by + apply Subtype.ext; funext i j + simp [restrictTable,expandTable,(er i).property,(ec j).property] + +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section + +def maximizers {a : ℕ} (R : Fin (a+1) → ℕ) : Finset (Fin (a+1)) := + Finset.univ.filter (fun i => ∀ j,R j≤R i) + +theorem maximizers_nonempty {a : ℕ} (R : Fin (a+1) → ℕ) : (maximizers R).Nonempty := by + obtain ⟨i,_,hi⟩ := Finset.exists_max_image Finset.univ R Finset.univ_nonempty + exact ⟨i,by simpa [maximizers] using hi⟩ + + +def maximumIndex {a : ℕ} (R : Fin (a+1) → ℕ) : Fin (a+1) := (maximizers R).min' (maximizers_nonempty R) + +theorem maximumIndex_max {a : ℕ} (R : Fin (a+1) → ℕ) (i : Fin (a+1)) : R i≤R (maximumIndex R) := by + have hh := Finset.min'_mem (maximizers R) (maximizers_nonempty R) + exact (Finset.mem_filter.mp hh).2 i + +theorem maximumIndex_first {a : ℕ} (R : Fin (a+1) → ℕ) (i : Fin (a+1)) + (hi : ∀ j,R j≤R i) : maximumIndex R ≤ i := Finset.min'_le _ i (by simp [maximizers,hi]) + +def marginOrder {a : ℕ} (R : Fin (a+1) → ℕ) : Fin (a+1) ≃ Fin (a+1) := + Equiv.swap (maximumIndex R) (Fin.last a) + +theorem marginOrder_max {a : ℕ} (R : Fin (a+1) → ℕ) (i : Fin (a+1)) : + R (marginOrder R i)≤R (marginOrder R (Fin.last a)) := by + rw [marginOrder,Equiv.swap_apply_right] + exact maximumIndex_max _ _ + +variable {m n a b : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) (er : Fin a ≃ Fin m) (ec : Fin b ≃ Fin n) + +def permuteTable (X : Tables r c) : Tables (fun i => r (er i)) (fun j => c (ec j)) := + ⟨fun i j => X.val (er i) (ec j),fun row => (ec.sum_comp _).trans (X.property.1 (er row)), + fun column => (er.sum_comp _).trans (X.property.2 (ec column))⟩ + +def permuteTableEquiv : Tables r c ≃ Tables (fun i => r (er i)) (fun j => c (ec j)) where + toFun := permuteTable r c er ec + invFun X := ⟨fun i j => X.val (er.symm i) (ec.symm j),by + constructor + · intro i + rw [ec.symm.sum_comp (fun j => X.val (er.symm i) j),X.property.1] + simp + · intro j + rw [er.symm.sum_comp (fun i => X.val i (ec.symm j)),X.property.2] + simp⟩ + left_inv X := by apply Subtype.ext; funext i j; simp [permuteTable] + right_inv X := by apply Subtype.ext; funext i j; simp [permuteTable] + +namespace Law +variable {α β : Type*} [Fintype α] [Fintype β] [Nonempty α] [Nonempty β] + +theorem uniform_map_equiv (e : α ≃ β) : (uniform α).map e=uniform β := by + classical + apply Law.ext; funext y + have he (x : α) : e x=y ↔ x=e.symm y := e.eq_symm_apply.symm + simp only [map,bind,pure,mul_ite,mul_one,mul_zero,he] + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true,uniform,Fintype.card_congr e] + +end Law +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +variable {a c : ℕ} + + + +def complete (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (x : Fin a → Fin c → ℝ) : + Fin (a+1) → Fin (c+1) → ℝ := + Fin.lastCases + (Fin.lastCases (R (Fin.last a)-(∑ j : Fin c,P j.castSucc)+(∑ i,∑ j,x i j)) + (fun j => P j.castSucc-∑ i,x i j)) + (fun i => Fin.lastCases (R i.castSucc-∑ j,x i j) (fun j => x i j)) + +@[simp] theorem complete_free (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (x : Fin a → Fin c → ℝ) (i : Fin a) (j : Fin c) : + complete R P x i.castSucc j.castSucc=x i j := by simp [complete] + +@[simp] theorem complete_right (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (x : Fin a → Fin c → ℝ) (i : Fin a) : + complete R P x i.castSucc (Fin.last c)=R i.castSucc-∑ j,x i j := by simp [complete] + +@[simp] theorem complete_bottom (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (x : Fin a → Fin c → ℝ) (j : Fin c) : + complete R P x (Fin.last a) j.castSucc=P j.castSucc-∑ i,x i j := by simp [complete] + +@[simp] theorem complete_corner (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (x : Fin a → Fin c → ℝ) : + complete R P x (Fin.last a) (Fin.last c)= + R (Fin.last a)-(∑ j : Fin c,P j.castSucc)+(∑ i,∑ j,x i j) := by simp [complete] + +@[simp] theorem complete_row (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (x : Fin a → Fin c → ℝ) (i : Fin (a+1)) : ∑ j,complete R P x i j=R i := by + refine Fin.lastCases ?_ (fun i => ?_) i + · rw [Fin.sum_univ_castSucc] + simp only [complete_bottom,complete_corner,Finset.sum_sub_distrib] + rw [Finset.sum_comm (f:=fun i j => x i j)] + ring + · rw [Fin.sum_univ_castSucc] + simp only [complete_free,complete_right] + ring + +@[simp] theorem complete_col (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (x : Fin a → Fin c → ℝ) (h : (∑ i,R i)=∑ j,P j) (j : Fin (c+1)) : + ∑ i,complete R P x i j=P j := by + refine Fin.lastCases ?_ (fun j => ?_) j + · rw [Fin.sum_univ_castSucc] + simp only [complete_right,complete_corner,Finset.sum_sub_distrib] + rw [Fin.sum_univ_castSucc,Fin.sum_univ_castSucc] at h + linarith + · rw [Fin.sum_univ_castSucc] + simp only [complete_free,complete_bottom] + ring + + +theorem complete_represents (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (X : Fin (a+1) → Fin (c+1) → ℝ) + (hR : ∀ i,∑ j,X i j=R i) (hP : ∀ j,∑ i,X i j=P j) : + complete R P (fun i j => X i.castSucc j.castSucc)=X := by + funext i j + refine Fin.lastCases ?_ (fun i => ?_) i + · refine Fin.lastCases ?_ (fun j => ?_) j + · have hr := hR (Fin.last a) + rw [Fin.sum_univ_castSucc] at hr + have hp (j : Fin c) := hP j.castSucc + simp only [Fin.sum_univ_castSucc] at hp + have he : (∑ j : Fin c,X (Fin.last a) j.castSucc)= + (∑ j : Fin c,P j.castSucc)-(∑ i : Fin a,∑ j : Fin c,X i.castSucc j.castSucc) := by + rw [Finset.sum_comm (f:=fun (i : Fin a) (j : Fin c) => X i.castSucc j.castSucc),← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl; intro j _; linarith [hp j] + rw [he] at hr + rw [complete_corner] + linarith + · rw [complete_bottom] + have hp := hP j.castSucc + rw [Fin.sum_univ_castSucc] at hp + linarith + · refine Fin.lastCases ?_ (fun j => ?_) j + · rw [complete_right] + have hr := hR i.castSucc + rw [Fin.sum_univ_castSucc] at hr + linarith + · exact complete_free R P _ i j + +def scale (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (i : Fin (a+1)) (j : Fin (c+1)) : ℝ := + min (R i) (P j) + +def scaled (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (u : Fin a×Fin c → ℝ) := + complete R P (fun i j => w i j*u (i,j)) + +def normalized (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (u : Fin a×Fin c → ℝ) (i : Fin (a+1)) (j : Fin (c+1)) : ℝ := + scaled R P w u i j/scale R P i j + +def polytope (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) : Set (Fin a×Fin c → ℝ) := + {u | ∀ i j, 0 ≤ normalized R P w u i j} + + +theorem width_bounds (s B : ℕ) (hB : 0 hX i j) (Finset.mem_univ j) + · simpa only [hP] using Finset.single_le_sum (fun i _ => hX i j) (Finset.mem_univ i) + + +theorem polytope_bounded (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) + (w : Fin a → Fin c → ℝ) (B : ℝ) (hB : 0 complete_row R P _ i) (fun j => complete_col R P _ heq j) i.castSucc j.castSucc + rw [he] at hl + constructor + · exact nonneg_of_mul_nonneg_right h0 (hpos i j) + · have hw' : scale R P i.castSucc j.castSucc ≤ w i j*(2*B) := + (div_le_iff₀ (by positivity)).mp (hw i j) + exact (mul_le_mul_iff_right₀ (hpos i j)).mp (hl.trans hw') + +end +end Contingency.Dense + + + + + +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +variable {a c : ℕ} + + + +theorem real_completion {I J : Type*} [Fintype I] [Fintype J] + (R : I → ℝ) (P : J → ℝ) (hR : ∀ i,0 ≤ R i) (hP : ∀ j,0 ≤ P j) + (heq : (∑ i,R i)=∑ j,P j) : + ∃ X : I → J → ℝ, (∀ i j,0 ≤ X i j) ∧ (∀ i,∑ j,X i j=R i) ∧ (∀ j,∑ i,X i j=P j) := by + classical + by_cases h0 : (∑ i,R i)=0 + · have hR0 (i) : R i=0 := by + have := Finset.single_le_sum (fun i _ => hR i) (Finset.mem_univ i) + rw [h0] at this; linarith [hR i] + have hP0 (j) : P j=0 := by + have := Finset.single_le_sum (fun j _ => hP j) (Finset.mem_univ j) + rw [← heq,h0] at this; linarith [hP j] + refine ⟨fun _ _ => 0,fun _ _ => le_rfl,?_,?_⟩ + · intro i; simp [hR0] + · intro j; simp [hP0] + · have hS : 0<(∑ i,R i) := lt_of_le_of_ne (Finset.sum_nonneg (fun i _ => hR i)) (Ne.symm h0) + refine ⟨fun i j => R i*P j/(∑ i,R i),?_,?_,?_⟩ + · intro i j; exact div_nonneg (mul_nonneg (hR i) (hP j)) hS.le + · intro i + rw [← Finset.sum_div,← Finset.mul_sum,← heq] + field_simp + · intro j + rw [← Finset.sum_div,← Finset.sum_mul] + field_simp + + + +theorem interior_table (d : ℝ) (hd : 0 scale R P i j/(2*d) + have hBn (i j) : 0 ≤ B i j := div_nonneg (le_min (hR i).le (hP j).le) (by positivity) + have hrow (i) : (∑ j,B i j) ≤ R i/2 := by + calc + _ ≤ ∑ j : Fin (c+1), R i/(2*d) := by + apply Finset.sum_le_sum; intro j _ + exact div_le_div_of_nonneg_right (min_le_left _ _) (by positivity) + _ = (c+1:ℕ)*(R i/(2*d)) := by simp + _ ≤ d*(R i/(2*d)) := mul_le_mul_of_nonneg_right hc (div_nonneg (hR i).le (by positivity)) + _ = R i/2 := by field_simp + have hcol (j) : (∑ i,B i j) ≤ P j/2 := by + calc + _ ≤ ∑ i : Fin (a+1), P j/(2*d) := by + apply Finset.sum_le_sum; intro i _ + exact div_le_div_of_nonneg_right (min_le_right _ _) (by positivity) + _ = (a+1:ℕ)*(P j/(2*d)) := by simp + _ ≤ d*(P j/(2*d)) := mul_le_mul_of_nonneg_right ha (div_nonneg (hP j).le (by positivity)) + _ = P j/2 := by field_simp + let R' := fun i => R i-∑ j,B i j + let P' := fun j => P j-∑ i,B i j + have hR' (i) : 0 ≤ R' i := by dsimp [R']; linarith [hrow i,hR i] + have hP' (j) : 0 ≤ P' j := by dsimp [P']; linarith [hcol j,hP j] + have heq' : (∑ i,R' i)=∑ j,P' j := by + simp only [R',P',Finset.sum_sub_distrib,heq] + rw [Finset.sum_comm] + obtain ⟨Y,hY,hYR,hYP⟩ := real_completion R' P' hR' hP' heq' + refine ⟨fun i j => B i j+Y i j,?_,?_,?_⟩ + · intro i j; exact le_add_of_nonneg_right (hY i j) + · intro i; rw [Finset.sum_add_distrib,hYR]; dsimp [R']; ring + · intro j; rw [Finset.sum_add_distrib,hYP]; dsimp [P']; ring + + +theorem interior_point (d : ℝ) (hd : 0 X s.1.castSucc s.2.castSucc/w s.1 s.2 + have he : scaled R P w u=X := by + unfold scaled + have hx : (fun i j => w i j*u (i,j))=fun i j => X i.castSucc j.castSucc := by + funext i j + dsimp [u] + field_simp [(hw i j).ne'] + rw [hx] + exact complete_represents R P X hXR hXP + refine ⟨u,fun i j => ?_⟩ + unfold normalized + rw [he] + have hs : 0 Y.x w + unit t w - + if IsSmall U r c (receiver s t) then unit (receiver s t) w else 0 + ⟨x, fun w => x w - unit t w + unit s w⟩ + +theorem inverseRepair_repair (s t : Cell m n) (X : State m n) + (h : DefectAt U r c s t X) : + inverseRepair U r c s t (repair U r c s t X) = X := by + have hx : (inverseRepair U r c s t (repair U r c s t X)).x = X.x := by + funext w; dsimp [inverseRepair,repair]; ring + have hq : (inverseRepair U r c s t (repair U r c s t X)).q = X.q := by + funext w + change (inverseRepair U r c s t (repair U r c s t X)).x w - unit t w + unit s w = X.q w + rw [hx,h.2.2.2] + exact congrArg₂ State.mk hx hq + +theorem repair_inverseRepair (s t : Cell m n) (Y : State m n) + (h : Transversal Y) : + repair U r c s t (inverseRepair U r c s t Y) = Y := by + have hx : (repair U r c s t (inverseRepair U r c s t Y)).x = Y.x := by + funext w; dsimp [inverseRepair,repair]; ring + have hq : (repair U r c s t (inverseRepair U r c s t Y)).q = Y.q := by + change (repair U r c s t (inverseRepair U r c s t Y)).x = Y.q + exact hx.trans h.symm + exact congrArg₂ State.mk hx hq + +theorem inverseRepair_defect (s t : Cell m n) (Y : State m n) + (hs : IsSmall U r c s) (ht : IsSmall U r c t) (hst : s ≠ t) : + DefectAt U r c s t (inverseRepair U r c s t Y) := ⟨hs,ht,hst,rfl⟩ + + +def slotList (m n : ℕ) : List (Cell m n) := + (List.ofFn fun i : Fin m => List.ofFn fun j : Fin n => (i,j)).flatten + +@[simp] theorem mem_slotList (s : Cell m n) : s ∈ slotList m n := by + rcases s with ⟨i,j⟩ + simp [slotList] + +@[simp] theorem length_slotList : (slotList m n).length = m*n := by + simp [slotList,List.length_flatten,Function.comp_def] + +def typeList (m n : ℕ) : List (Cell m n × Cell m n) := + (slotList m n).flatMap fun s => (slotList m n).map fun t => (s,t) + +@[simp] theorem mem_typeList (st : Cell m n × Cell m n) : st ∈ typeList m n := by + rcases st with ⟨s,t⟩; simp [typeList] + +@[simp] theorem length_typeList : (typeList m n).length=(m*n)^2 := by + simp [typeList,List.length_flatMap,pow_two] + +instance feasibleDecidable (X : State m n) : Decidable (Feasible U r c X) := + by unfold Feasible; infer_instance + +instance transversalDecidable (X : State m n) : Decidable (Transversal X) := + inferInstanceAs (Decidable (X.q = X.x)) + +instance defectAtDecidable (s t : Cell m n) (X : State m n) : + Decidable (DefectAt U r c s t X) := + inferInstanceAs (Decidable (IsSmall U r c s ∧ IsSmall U r c t ∧ s ≠ t ∧ _)) + + + +def inverseNeighbors (Y : State m n) : List (State m n) := + if Transversal Y then + ((typeList m n).filter fun st => + IsSmall U r c st.1 ∧ IsSmall U r c st.2 ∧ st.1 ≠ st.2 ∧ + Feasible U r c (inverseRepair U r c st.1 st.2 Y)).map + fun st => inverseRepair U r c st.1 st.2 Y + else [] + +theorem length_inverseNeighbors (Y : State m n) : + (inverseNeighbors U r c Y).length ≤ (m*n)^2 := by + unfold inverseNeighbors + split_ifs + · simpa only [List.length_map,length_typeList] using List.length_filter_le + (p:=fun st : Cell m n × Cell m n => decide + (IsSmall U r c st.1 ∧ IsSmall U r c st.2 ∧ st.1 ≠ st.2 ∧ + Feasible U r c (inverseRepair U r c st.1 st.2 Y))) (typeList m n) + · simp + +theorem repairedState_eq (s t : Cell m n) (X : DefectiveState U r c) + (h : DefectAt U r c s t X.val) : + (repairedState U r c X).val = repair U r c s t X.val := by + obtain ⟨hs,ht⟩ := defect_type_unique U r c X.val _ _ s t (defectPair_spec U r c X) h + change repair U r c _ _ X.val = _ + rw [hs,ht] + + + +theorem mem_inverseNeighbors (X Y : GraphState U r c) : + graphUnderlying U r c Y ∈ inverseNeighbors U r c (graphUnderlying U r c X) ↔ + Y ∈ (incomingDefects U r c X).image Sum.inr := by + classical + constructor + · intro hh + unfold inverseNeighbors at hh + split_ifs at hh with ht + · obtain ⟨⟨s,t⟩,hst,he⟩ := List.mem_map.mp hh + have hst' := (List.mem_filter.mp hst).2 + simp only [decide_eq_true_eq] at hst' + have hd := inverseRepair_defect U r c s t (graphUnderlying U r c X) hst'.1 hst'.2.1 hst'.2.2.1 + let Z : DefectiveState U r c := ⟨inverseRepair U r c s t (graphUnderlying U r c X), + hst'.2.2.2,⟨s,t,hd⟩⟩ + have hy : Sum.inr Z=Y := graphUnderlying_injective U r c he + have hx : Sum.inl (repairedState U r c Z)=X := by + apply graphUnderlying_injective U r c + change (repairedState U r c Z).val = _ + rw [repairedState_eq U r c s t Z hd] + exact repair_inverseRepair U r c s t _ ht + exact Finset.mem_image.mpr ⟨Z,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hx⟩,hy⟩ + · simp at hh + · intro hh + obtain ⟨Z,hZ,rfl⟩ := Finset.mem_image.mp hh + have hx := (Finset.mem_filter.mp hZ).2 + rw [← hx] + change Z.val ∈ inverseNeighbors U r c (repairedState U r c Z).val + unfold inverseNeighbors + rw [ite_eq_left (repairedState U r c Z).property.2] + let s := (defectPair U r c Z).1 + let t := (defectPair U r c Z).2 + have hd : DefectAt U r c s t Z.val := defectPair_spec U r c Z + have hi : inverseRepair U r c s t (repairedState U r c Z).val=Z.val := + inverseRepair_repair U r c s t Z.val hd + apply List.mem_map.mpr + refine ⟨(s,t),List.mem_filter.mpr ⟨mem_typeList _,?_⟩,hi⟩ + simp only [decide_eq_true_eq] + exact ⟨hd.1,hd.2.1,hd.2.2.1,hi ▸ Z.property.1⟩ + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def smallList : List (SmallSlot U r c) := + (slotList m n).filterMap fun s => if hs : IsSmall U r c s then some ⟨s,hs⟩ else none + +@[simp] theorem mem_smallList (s : SmallSlot U r c) : s ∈ smallList U r c := by + apply List.mem_filterMap.mpr + exact ⟨s.val,mem_slotList _,by simp [s.property]⟩ + +theorem length_smallList : (smallList U r c).length ≤ m*n := by + simpa only [smallList,length_slotList] using List.length_filterMap_le + (f:=fun s => if hs : IsSmall U r c s then some (⟨s,hs⟩ : SmallSlot U r c) else none) + (l:=slotList m n) + +def coordList : List (SmallCoord U r c) := (smallList U r c).product [false,true] + +@[simp] theorem mem_coordList (i : SmallCoord U r c) : i ∈ coordList U r c := by + rcases i with ⟨s,b⟩; cases b <;> simp [coordList] + +theorem length_coordList : (coordList U r c).length ≤ 2*(m*n) := by + have hh := length_smallList U r c + change ((smallList U r c) ×ˢ [false,true]).length ≤ _ + rw [List.length_product] + simp only [List.length_cons,List.length_nil] + omega + +def allowedState (X : State m n) : Prop := + Feasible U r c X ∧ (Transversal X ∨ ∃ s t, DefectAt U r c s t X) + +instance allowedStateDecidable (X : State m n) : Decidable (allowedState U r c X) := by + unfold allowedState; infer_instance + +theorem graph_allowed (X : GraphState U r c) : allowedState U r c (graphUnderlying U r c X) := by + cases X with + | inl X => exact ⟨X.property.1,Or.inl X.property.2⟩ + | inr X => exact ⟨X.property.1,Or.inr X.property.2⟩ + + + +def localExchange (X : State m n) (i j : SmallCoord U r c) : State m n := + let v := fun w : SmallCoord U r c => + (if w.2 then X.x w.1.val else (U:ℤ)-X.q w.1.val) + + (if w=i then 1 else 0) - (if w=j then 1 else 0) + ⟨fun w => if hw : IsSmall U r c w then v (⟨w,hw⟩,true) else 0, + fun w => if hw : IsSmall U r c w then (U:ℤ)-v (⟨w,hw⟩,false) else 0⟩ + +theorem localExchange_eq (X : State m n) (i j : SmallCoord U r c) : + localExchange U r c X i j = coordinatesState U r c + (fun w => stateCoordinates U r c X w + (if w=i then 1 else 0) - (if w=j then 1 else 0)) := rfl + +theorem localExchange_coordinates (X : State m n) (i j : SmallCoord U r c) : + stateCoordinates U r c (localExchange U r c X i j) = + fun w => stateCoordinates U r c X w + (if w=i then 1 else 0) - (if w=j then 1 else 0) := by + rw [localExchange_eq,stateCoordinates_coordinatesState] + +def unitNeighbors (X : State m n) : List (State m n) := + (((coordList U r c).product (coordList U r c)).filter fun ij => + ij.1 ≠ ij.2 ∧ allowedState U r c (localExchange U r c X ij.1 ij.2)).map + fun ij => localExchange U r c X ij.1 ij.2 + +theorem length_unitNeighbors (X : State m n) : + (unitNeighbors U r c X).length ≤ 4*(m*n)^2 := by + have hh := List.length_filter_le + (p:=fun ij : SmallCoord U r c × SmallCoord U r c => decide + (ij.1 ≠ ij.2 ∧ allowedState U r c (localExchange U r c X ij.1 ij.2))) + ((coordList U r c).product (coordList U r c)) + have hc := length_coordList U r c + change _ ≤ ((coordList U r c) ×ˢ (coordList U r c)).length at hh + rw [List.length_product] at hh + simp only [unitNeighbors,List.length_map] + nlinarith + +theorem unitNeighbors_allowed (X Y : State m n) (h : Y ∈ unitNeighbors U r c X) : + allowedState U r c Y := by + obtain ⟨ij,hij,rfl⟩ := List.mem_map.mp h + exact (of_decide_eq_true (List.mem_filter.mp hij).2).2 + +theorem graph_vertex (X : GraphState U r c) : graphCoordinates U r c X ∈ fullVertices U r c := by + cases X with + | inl X => exact stateCoordinates_transverse_vertex U r c X + | inr X => exact stateCoordinates_defect_vertex U r c X + +theorem unitEdge_of_exchange (X Y : GraphState U r c) (i j : SmallCoord U r c) + (hij : i ≠ j) (he : graphCoordinates U r c Y = + fun w => graphCoordinates U r c X w+(if w=i then 1 else 0)-(if w=j then 1 else 0)) : + s(graphCoordinates U r c X,graphCoordinates U r c Y) ∈ fullUnitEdges U r c := by + classical + apply Finset.mem_filter.mpr + refine ⟨Finset.mk_mem_sym2_iff.mpr ⟨graph_vertex U r c X,graph_vertex U r c Y⟩,?_⟩ + let D := fun w => graphCoordinates U r c X w+(if w=i then 1 else 0) + have hi : removeOne D i=graphCoordinates U r c X := by funext w; simp [D,removeOne] + have hj : removeOne D j=graphCoordinates U r c Y := by rw [he]; rfl + exact ⟨D,i,j,hij,by rw [hi,hj]⟩ + + + +theorem mem_unitNeighbors (X Y : GraphState U r c) : + graphUnderlying U r c Y ∈ unitNeighbors U r c (graphUnderlying U r c X) ↔ + s(graphCoordinates U r c X,graphCoordinates U r c Y) ∈ fullUnitEdges U r c := by + classical + constructor + · intro hh + obtain ⟨⟨i,j⟩,hij,he⟩ := List.mem_map.mp hh + have h := of_decide_eq_true (List.mem_filter.mp hij).2 + apply unitEdge_of_exchange U r c X Y i j h.1 + change stateCoordinates U r c (graphUnderlying U r c Y) = _ + rw [← he,localExchange_coordinates] + rfl + · intro hh + obtain ⟨_,D,i,j,hij,he⟩ := Finset.mem_filter.mp hh + have mk (i j : SmallCoord U r c) (hij : i ≠ j) + (h : graphCoordinates U r c Y = fun w => graphCoordinates U r c X w+ + (if w=i then 1 else 0)-(if w=j then 1 else 0)) : + graphUnderlying U r c Y ∈ unitNeighbors U r c (graphUnderlying U r c X) := by + have he : localExchange U r c (graphUnderlying U r c X) i j=graphUnderlying U r c Y := by + rw [localExchange_eq] + change coordinatesState U r c (fun w => graphCoordinates U r c X w+_ - _) = _ + rw [← h] + exact coordinates_state_inverse U r c _ (graph_feasible U r c Y).2.1 + apply List.mem_map.mpr + refine ⟨(i,j),List.mem_filter.mpr ⟨List.mem_product.mpr ⟨mem_coordList U r c i,mem_coordList U r c j⟩,?_⟩,he⟩ + simp only [decide_eq_true_eq] + exact ⟨hij,he ▸ graph_allowed U r c Y⟩ + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · apply mk i j hij + funext w; rw [hx,hy]; simp only [removeOne]; ring + · apply mk j i hij.symm + funext w; rw [hx,hy]; simp only [removeOne]; ring + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + + + +def localRepair (s t : Cell m n) (X : State m n) : State m n := + let x' := fun w => X.x w-unit t w+ + if IsSmall U r c (receiver s t) then unit (receiver s t) w else 0 + ⟨x',x'⟩ + +theorem localRepair_eq (s t : Cell m n) (X : State m n) : + localRepair U r c s t X=repair U r c s t X := rfl + + +def findDefect (X : State m n) : Option (Cell m n × Cell m n) := + (typeList m n).find? fun st => DefectAt U r c st.1 st.2 X + +theorem findDefect_some (X : State m n) (st : Cell m n × Cell m n) + (h : findDefect U r c X=some st) : DefectAt U r c st.1 st.2 X := + of_decide_eq_true (List.find?_some + (p:=fun ij : Cell m n × Cell m n => decide (DefectAt U r c ij.1 ij.2 X)) h) + +theorem findDefect_none (X : State m n) : + findDefect U r c X=none ↔ ∀ s t, ¬DefectAt U r c s t X := by + rw [findDefect,List.find?_eq_none] + simp only [mem_typeList,decide_eq_true_eq,true_implies,Prod.forall] + +theorem findDefect_transverse (X : TransverseState U r c) : findDefect U r c X.val=none := by + apply (findDefect_none U r c X.val).mpr + intro s t h + exact defect_not_transversal U r c s t X.val h X.property.2 + +theorem findDefect_defective (X : DefectiveState U r c) : + findDefect U r c X.val=some (defectPair U r c X) := by + cases he : findDefect U r c X.val with + | none => + have hh := (findDefect_none U r c X.val).mp he + exact (hh _ _ (defectPair_spec U r c X)).elim + | some st => + have hd := findDefect_some U r c X.val st he + obtain ⟨hs,ht⟩ := defect_type_unique U r c X.val st.1 st.2 _ _ hd (defectPair_spec U r c X) + rw [Prod.ext hs ht] + +def localOutgoing (X : State m n) : List (State m n) := + match findDefect U r c X with + | none => [] + | some st => [localRepair U r c st.1 st.2 X] + +theorem length_localOutgoing (X : State m n) : (localOutgoing U r c X).length≤1 := by + unfold localOutgoing + split <;> simp + +theorem localOutgoing_transverse (X : TransverseState U r c) : + localOutgoing U r c X.val=[] := by rw [localOutgoing,findDefect_transverse] + +theorem localOutgoing_defective (X : DefectiveState U r c) : + localOutgoing U r c X.val=[(repairedState U r c X).val] := by + rw [localOutgoing,findDefect_defective]; rfl + +theorem mem_localOutgoing (X Y : GraphState U r c) : + graphUnderlying U r c Y ∈ localOutgoing U r c (graphUnderlying U r c X) ↔ + Y ∈ outgoing U r c X := by + classical + cases X with + | inl X => simp [graphUnderlying,localOutgoing_transverse,outgoing] + | inr X => + change graphUnderlying U r c Y ∈ localOutgoing U r c X.val ↔ _ + rw [localOutgoing_defective] + simp only [List.mem_singleton,outgoing,Finset.mem_singleton] + exact (graphUnderlying_injective U r c).eq_iff (a:=Y) (b:=Sum.inl (repairedState U r c X)) + +theorem repairAdj_iff (X Y : GraphState U r c) : + s(graphCoordinates U r c X,graphCoordinates U r c Y)∈fullRepairEdges U r c ↔ + Y ∈ outgoing U r c X ∨ Y ∈ (incomingDefects U r c X).image Sum.inr := by + classical + constructor + · intro hh + obtain ⟨Z,_,he⟩ := Finset.mem_image.mp hh + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · have hx' : Sum.inr Z=X := graphCoordinates_injective U r c hx + have hy' : Sum.inl (repairedState U r c Z)=Y := graphCoordinates_injective U r c hy + left + rw [← hx',← hy']; simp [outgoing] + · have hx' : Sum.inr Z=Y := graphCoordinates_injective U r c hx + have hy' : Sum.inl (repairedState U r c Z)=X := graphCoordinates_injective U r c hy + right + exact Finset.mem_image.mpr ⟨Z,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hy'⟩,hx'⟩ + · intro hh + rcases hh with ho | hi + · cases X with + | inl X => simp [outgoing] at ho + | inr X => + simp only [outgoing,Finset.mem_singleton] at ho + subst Y + exact Finset.mem_image.mpr ⟨X,Finset.mem_univ _,rfl⟩ + · obtain ⟨Z,hZ,rfl⟩ := Finset.mem_image.mp hi + have hx := (Finset.mem_filter.mp hZ).2 + rw [← hx] + exact Finset.mem_image.mpr ⟨Z,Finset.mem_univ _,Sym2.eq_swap⟩ + + + +def localNeighbors (X : State m n) : List (State m n) := + (unitNeighbors U r c X ++ localOutgoing U r c X ++ inverseNeighbors U r c X).dedup + +theorem localNeighbors_nodup (X : State m n) : (localNeighbors U r c X).Nodup := + List.nodup_dedup _ + +theorem length_localNeighbors (X : State m n) : + (localNeighbors U r c X).length≤5*(m*n)^2+1 := by + have hh := (List.dedup_sublist + (unitNeighbors U r c X ++ localOutgoing U r c X ++ inverseNeighbors U r c X)).length_le + have hu := length_unitNeighbors U r c X + have ho := length_localOutgoing U r c X + have hi := length_inverseNeighbors U r c X + simp only [List.length_append] at hh + exact hh.trans (by omega) + + + +theorem mem_localNeighbors (X Y : GraphState U r c) : + graphUnderlying U r c Y ∈ localNeighbors U r c (graphUnderlying U r c X) ↔ + GraphAdj U r c X Y := by + classical + simp only [localNeighbors,List.mem_dedup,List.mem_append,mem_unitNeighbors, + mem_localOutgoing,mem_inverseNeighbors,GraphAdj,fullEdges,Finset.mem_union,repairAdj_iff] + exact or_assoc + +theorem localNeighbors_allowed (X : GraphState U r c) (Y : State m n) + (h : Y ∈ localNeighbors U r c (graphUnderlying U r c X)) : allowedState U r c Y := by + simp only [localNeighbors,List.mem_dedup,List.mem_append] at h + rcases h with (hu | ho) | hi + · exact unitNeighbors_allowed U r c _ _ hu + · cases X with + | inl X => simp [graphUnderlying,localOutgoing_transverse] at ho + | inr X => + change Y ∈ localOutgoing U r c X.val at ho + rw [localOutgoing_defective] at ho + have he := List.mem_singleton.mp ho + rw [he] + exact graph_allowed U r c (Sum.inl (repairedState U r c X)) + · unfold inverseNeighbors at hi + split_ifs at hi + · obtain ⟨⟨s,t⟩,hst,rfl⟩ := List.mem_map.mp hi + have hh := of_decide_eq_true (List.mem_filter.mp hst).2 + exact ⟨hh.2.2.2,Or.inr ⟨s,t,inverseRepair_defect U r c s t _ hh.1 hh.2.1 hh.2.2.1⟩⟩ + · simp at hi + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +namespace IntegerDraw +variable {α : Type*} + +def unitWeights (xs : List α) : List (α×ℕ) := xs.map fun x => (x,1) + +theorem unitWeights_total (xs : List α) : total (unitWeights xs)=xs.length := by + induction xs with + | nil => simp [unitWeights,total] + | cons x xs ih => + change 1 + total (unitWeights xs) = xs.length + 1 + rw [ih]; omega + +theorem unitWeights_weight [DecidableEq α] (xs : List α) (h : xs.Nodup) (a : α) : + weight (unitWeights xs) a = if a∈xs then 1 else 0 := by + simp only [weight,unitWeights,List.map_map,Function.comp_def] + rw [← List.sum_toFinset (fun x => if x=a then (1:ℕ) else 0) h] + simp + +end IntegerDraw +namespace PaddedGraph +variable {m n : ℕ} (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def graphStateOf (X : State m n) (h : allowedState U r c X) : GraphState U r c := + if ht : Transversal X then Sum.inl ⟨X,h.1,ht⟩ else Sum.inr ⟨X,h.1,h.2.resolve_left ht⟩ + +@[simp] theorem graphStateOf_underlying (X : State m n) (h : allowedState U r c X) : + graphUnderlying U r c (graphStateOf U r c X h)=X := by + unfold graphStateOf; split <;> rfl + + + +def graphNeighborList (X : GraphState U r c) : List (GraphState U r c) := + (localNeighbors U r c (graphUnderlying U r c X)).attach.map fun Y => + graphStateOf U r c Y.val (localNeighbors_allowed U r c X Y.val Y.property) + +theorem graphNeighborList_nodup (X : GraphState U r c) : (graphNeighborList U r c X).Nodup := by + apply List.Nodup.map _ (localNeighbors_nodup U r c (graphUnderlying U r c X)).attach + intro Y Z he + apply Subtype.ext + have hh := congrArg (graphUnderlying U r c) he + simpa only [graphStateOf_underlying] using hh + +@[simp] theorem mem_graphNeighborList (X Y : GraphState U r c) : + Y ∈ graphNeighborList U r c X ↔ GraphAdj U r c X Y := by + constructor + · intro hh + obtain ⟨Z,_,rfl⟩ := List.mem_map.mp hh + apply (mem_localNeighbors U r c X _).mp + simpa only [graphStateOf_underlying] using Z.property + · intro hh + have hY := (mem_localNeighbors U r c X Y).mpr hh + apply List.mem_map.mpr + refine ⟨⟨graphUnderlying U r c Y,hY⟩,List.mem_attach _ _,?_⟩ + apply graphUnderlying_injective U r c + exact graphStateOf_underlying U r c _ _ + +theorem graphNeighborList_length (X : GraphState U r c) : + (graphNeighborList U r c X).length≤5*(m*n)^2+1 := by + simpa only [graphNeighborList,List.length_map,List.length_attach] using + length_localNeighbors U r c (graphUnderlying U r c X) + +theorem graphNeighborList_card (X : GraphState U r c) : + (graphNeighborList U r c X).length=(Finset.univ.filter (GraphAdj U r c X)).card := by + classical + have he : (graphNeighborList U r c X).toFinset=Finset.univ.filter (GraphAdj U r c X) := by + ext Y; simp + rw [← he,List.toFinset_card_of_nodup (graphNeighborList_nodup U r c X)] + + + +def selectLocalNeighbor (X : GraphState U r c) (z : ℕ) : GraphState U r c := + (IntegerDraw.scan (IntegerDraw.unitWeights (graphNeighborList U r c X)) z).getD X + +noncomputable def localProposal (X : GraphState U r c) (R : ℕ) : DyadicLaw (GraphState U r c) := + (bitWordLaw R).map (fun z => selectLocalNeighbor U r c X z.val) + + + +theorem localProposal_actual (X : GraphState U r c) (R : ℕ) : + localProposal U r c X R=(bitWordLaw R).map (fun z => selectLocalNeighbor U r c X z.val) := rfl + +theorem localProposal_count_offdiag (X Y : GraphState U r c) (R : ℕ) + (hR : (graphNeighborList U r c X).length≤2^R) (hxy : X≠Y) : + (localProposal U r c X R).count Y = if GraphAdj U r c X Y then 1 else 0 := by + classical + have hb : IntegerDraw.total (IntegerDraw.unitWeights (graphNeighborList U r c X))≤2^R := by + simpa only [IntegerDraw.unitWeights_total] using hR + rw [localProposal,DyadicLaw.map_count] + change (∑ z : Fin (2^R), if + (IntegerDraw.scan (IntegerDraw.unitWeights (graphNeighborList U r c X)) z.val).getD X=Y + then 1 else 0)=_ + simp only [Option.getD_eq_iff,hxy,and_false,or_false] + rw [Fin.sum_univ_eq_sum_range (fun z : ℕ => if + IntegerDraw.scan (IntegerDraw.unitWeights (graphNeighborList U r c X)) z=some Y then (1:ℕ) else 0)] + rw [IntegerDraw.scan_count_padded _ _ _ hb, + IntegerDraw.unitWeights_weight _ (graphNeighborList_nodup U r c X)] + simp only [mem_graphNeighborList] + + + +theorem localProposal_toLaw (X : GraphState U r c) (R : ℕ) + (hb : (Finset.univ.filter (GraphAdj U r c X)).card≤2^R) : + (localProposal U r c X R).toLaw= + (DyadicLaw.neighborProposal (GraphAdj U r c) X R (GraphAdj.irrefl U r c X) hb).toLaw := by + classical + apply Law.ext_offdiag _ _ X + intro Y hxy + rw [DyadicLaw.neighborProposal_offdiag _ _ _ _ _ _ hxy] + change ((localProposal U r c X R).count Y:ℝ)/(2:ℝ)^(localProposal U r c X R).bits=_ + rw [localProposal_count_offdiag U r c X Y R (by rw [graphNeighborList_card]; exact hb) hxy] + have hbits : (localProposal U r c X R).bits=R := by + simp [localProposal,DyadicLaw.map_bits,bitWordLaw] + rw [hbits] + split_ifs <;> norm_cast + +end PaddedGraph +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/OuterAccuracy.lean b/lean/OAI/Probability/Contingency/OuterAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd850a545af839c640e5bf80acf8b6455279fd5a --- /dev/null +++ b/lean/OAI/Probability/Contingency/OuterAccuracy.lean @@ -0,0 +1,636 @@ +import Mathlib +import OAI.Probability.Contingency.Unpadding + +namespace OAI + +/-! Outer Accuracy. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n a c' : ℕ} (d b k C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // d^20 ≤ r i}) (ec : Fin c' ≃ {j // d^20 ≤ c j}) (i₀ : Fin a) (j₀ : Fin c') + (hrc : (∑ i,r i)=∑ j,c j) (hd : 14 ≤ d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n ≤ d) + [Nonempty (GraphState (d^20) r c)] +local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) +local instance outerAccuracyDrawCompletionFintype (X : GraphState (d^20) r c) : + Fintype (Comp X) := Fintype.ofFinite _ +local instance outerAccuracyDrawTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + +include hd hm hn hmn hrc in +omit [Nonempty (GraphState (d^20) r c)] in +theorem stationary_failure_power (J : ℕ) : + letI := tables_nonempty r c hrc + (stationaryTrial r c (d^20) (d^12)).mass none^J≤Real.exp (-((J:ℝ)/(2*(1+(d:ℝ)^2)))) := by + let := tables_nonempty r c hrc + have hf := stationary_success_probability d r c hd hm hn hmn hrc + have hh : (stationaryTrial r c (d^20) (d^12)).mass none≤Real.exp (-(1/(2*(1+(d:ℝ)^2)))) := by + rw [stationaryTrial_none] + have he := Real.add_one_le_exp (-(1/(2*(1+(d:ℝ)^2)))) + linarith + have hp := pow_le_pow_left₀ ((stationaryTrial r c (d^20) (d^12)).nonneg none) hh J + rw [← Real.exp_nat_mul] at hp + convert hp using 1 + congr 1 + ring + +def outerDraw (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : DyadicLaw (Tables r c) := by + classical + exact stoppedLaw (implementedTrial (d^20) (d^12) d r c er ec i₀ j₀ (smallDim_one d hd) hmn μ S hS X₀ (Schedule.T d b k)) fallback (Schedule.Jo d k) + +omit [Nonempty (GraphState (d^20) r c)] in +theorem outerDraw_bits (μ : ∀ X,DyadicLaw (Comp X)) (hS : ∀ X,(μ X).bits=Schedule.RD d b k) + (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : + (outerDraw d b k r c er ec i₀ j₀ hd hmn μ (Schedule.RD d b k) hS X₀ fallback).bits=Schedule.R d b k := by + classical + change (implementedTrial _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _).bits*Schedule.Jo d k=_ + rw [implementedTrial_bits] + unfold Schedule.R Schedule.RT Schedule.qs + ring + +include hm hn in +theorem outerDraw_tv (hb : d ≤ b) (hk : 1 ≤ k) (hC2 : 2 ≤ C) (hU : d^20 ≤ C) + (hC : ∀ i,paddedRow (d^20) (d^12) r c i ≤ C) (hCb : C+1 ≤ 2^b) + (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (hμ : ∀ X,(μ X).toLaw.tv (idealCompletion (d^20) (d^12) r c hrc X) ≤ (2:ℝ)^(-(Schedule.h d b k:ℤ))) + (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : + letI := tables_nonempty r c hrc + (outerDraw d b k r c er ec i₀ j₀ hd hmn μ S hS X₀ fallback).toLaw.tv (Law.uniform (Tables r c))≤(2:ℝ)^(-(k:ℤ)) := by + classical + let := tables_nonempty r c hrc + let p := implementedTrial (d^20) (d^12) d r c er ec i₀ j₀ (smallDim_one d hd) hmn μ S hS X₀ (Schedule.T d b k) + let s := stationaryTrial r c (d^20) (d^12) + have ht := implementedTrial_tv (d^20) (d^12) d r c er ec i₀ j₀ (smallDim_one d hd) hmn hrc μ S hS _ hμ X₀ (Schedule.T d b k) + have hmix := small_mixing d C r c er ec i₀ j₀ hrc hd hm hn hmn hC2 hU hC (Schedule.T d b k) X₀ + have hfirst := Law.first_tv p.toLaw s fallback (Schedule.Jo d k) + have hideal := Law.first_ideal_tv s fallback (Law.uniform (Tables r c)) (stationaryTrial_uniform r c (d^20) (d^12)) (Schedule.Jo d k) + have hfail := stationary_failure_power d r c hrc hd hm hn hmn (Schedule.Jo d k) + have htri := Law.tv_triangle (Law.first p.toLaw fallback (Schedule.Jo d k)) (Law.first s fallback (Schedule.Jo d k)) (Law.uniform (Tables r c)) + have hmul := mul_le_mul_of_nonneg_left ht (Nat.cast_nonneg (Schedule.Jo d k)) + have hmm := mul_le_mul_of_nonneg_left hmix (Nat.cast_nonneg (Schedule.Jo d k)) + have htotal := Schedule.outer_error_schedule d b k hd hb hk C hCb + unfold outerDraw + rw [stoppedLaw_toLaw] + change (Law.first p.toLaw fallback (Schedule.Jo d k)).tv _ ≤ _ + change _≤_ at hfail + dsimp only [p,s] at hfirst hideal htri + dsimp only [p] + rw [neg_div] at hmm + nlinarith only [hfirst,hideal,hfail,htri,hmul,hmm,htotal] + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n a c' : ℕ} (d b k C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin (a+1) ≃ {i // d^20 ≤ r i}) (ec : Fin (c'+1) ≃ {j // d^20 ≤ c j}) + (hrc : (∑ i,r i)=∑ j,c j) (hd : 14 ≤ d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n ≤ d) + [Nonempty (GraphState (d^20) r c)] +local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) +local instance outerAccuracyLiteralCompletionFintype (X : GraphState (d^20) r c) : + Fintype (Comp X) := Fintype.ofFinite _ +local instance outerAccuracyLiteralTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + + + +def literalOuter (hC : ∀ i,paddedRow (d^20) (d^12) r c i ≤ C) (hCb : C ≤ 2^b) + (fallbacks : ∀ X,Comp X) (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : DyadicLaw (Tables r c) := + outerDraw d b k r c er ec 0 0 hd hmn + (fun X => blockDraw d b k C r c er ec hrc hd hm hn hmn hC hCb X (fallbacks X)) + (Schedule.RD d b k) + (fun X => blockDraw_bits d b k C r c er ec hrc hd hm hn hmn hC hCb X (fallbacks X)) X₀ fallback + +omit [Nonempty (GraphState (d^20) r c)] in +theorem literalOuter_bits (hC : ∀ i,paddedRow (d^20) (d^12) r c i ≤ C) (hCb : C ≤ 2^b) + (fallbacks : ∀ X,Comp X) (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : + (literalOuter d b k C r c er ec hrc hd hm hn hmn hC hCb fallbacks X₀ fallback).bits = Schedule.R d b k := by + apply outerDraw_bits + +theorem literalOuter_tv (hb : d ≤ b) (hk : 1 ≤ k) (hC2 : 2 ≤ C) (hU : d^20 ≤ C) + (hC : ∀ i,paddedRow (d^20) (d^12) r c i ≤ C) (hCb : C+1 ≤ 2^b) + (fallbacks : ∀ X,Comp X) (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : + letI := tables_nonempty r c hrc + (literalOuter d b k C r c er ec hrc hd hm hn hmn hC (by omega) fallbacks X₀ fallback).toLaw.tv + (Law.uniform (Tables r c)) ≤ (2:ℝ)^(-(k:ℤ)) := by + apply outerDraw_tv d b k C r c er ec 0 0 hrc hd hm hn hmn hb hk hC2 hU hC hCb + intro X + exact blockDraw_tv d b k C r c er ec hrc hd hm hn hmn hC (by omega) hk X (fallbacks X) + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n : ℕ} (U L d C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + + +def EmptyBlock : Prop := ∀ w : Cell m n, IsSmall U r c w + +theorem empty_completion_subsingleton (h : EmptyBlock U r c) (X : State m n) : + Subsingleton (Completion U L r c X) := by + constructor + intro A B + apply Subtype.ext + funext w + rw [A.property.2.1 w (h w),B.property.2.1 w (h w)] + +theorem empty_weight (h : EmptyBlock U r c) (hrc : (∑ i,r i)=∑ j,c j) + (X : GraphState U r c) : weight U L r c (graphUnderlying U r c X)=1 := by + let := empty_completion_subsingleton U L r c h (graphUnderlying U r c X) + let := completion_nonempty U L r c X hrc + rw [weight,ite_eq_left (graph_feasible U r c X)] + exact Nat.card_unique + +def emptyCount (X Y : GraphState U r c) : ℝ := if GraphAdj U r c X Y then 1 else 0 + +theorem emptyCount_nonneg (X Y : GraphState U r c) : 0 ≤ emptyCount U r c X Y := by + unfold emptyCount; split_ifs <;> norm_num + +def emptyData (h : EmptyBlock U r c) (hrc : (∑ i,r i)=∑ j,c j) + (hd : 1 ≤ d) (hmn : m*n ≤ d) : AcceptedData (GraphState U r c) where + f X := weight U L r c (graphUnderlying U r c X) + fpos X := by exact_mod_cast graph_weight_pos U L r c X hrc + count := emptyCount U r c + nonneg := emptyCount_nonneg U r c + symmetric X Y := by + unfold emptyCount + have he : GraphAdj U r c X Y ↔ GraphAdj U r c Y X := ⟨GraphAdj.symm U r c,GraphAdj.symm U r c⟩ + simp only [he] + diagonal X := by simp [emptyCount,GraphAdj.irrefl] + q := proposalRate (32*d^2) + qpos := by unfold proposalRate; positivity + hold X := by + rw [empty_weight U L r c h hrc X] + have hs : (∑ Y,emptyCount U r c X Y) ≤ 5*(d:ℝ)^2+1 := by + simp only [emptyCount,← Finset.sum_filter] + simpa using (show ((Finset.univ.filter (GraphAdj U r c X)).card:ℝ) ≤ 5*(d:ℝ)^2+1 by + exact_mod_cast graph_degree U r c d hmn X) + have hp : 0 ≤ proposalRate (32*d^2) := by unfold proposalRate; positivity + exact (mul_le_mul_of_nonneg_left hs hp).trans (by simpa using proposal_hold d hd) + +theorem graphEnergy_le_empty (h : EmptyBlock U r c) (hrc : (∑ i,r i)=∑ j,c j) + (hC : ∀ i,paddedRow U L r c i ≤ C) (H : GraphState U r c → ℝ) : + graphEnergy U L C r c (extendGraph U r c H) ≤ + 2*(∑ X,∑ Y,emptyCount U r c X Y*(H X-H Y)^2) := by + apply (graphEnergy_le_ordered U L C r c hrc hC H).trans + simp only [empty_weight U L r c h hrc,Nat.cast_one,min_self,one_mul] + have he : (∑ X,∑ Y,if GraphAdj U r c X Y then (H X-H Y)^2 else 0) = + ∑ X,∑ Y,emptyCount U r c X Y*(H X-H Y)^2 := by + simp [emptyCount,ite_mul] + rw [he] + have hn : 0 ≤ ∑ X,∑ Y,emptyCount U r c X Y*(H X-H Y)^2 := Finset.sum_nonneg + (fun X _ => Finset.sum_nonneg (fun Y _ => mul_nonneg (emptyCount_nonneg U r c X Y) (sq_nonneg _))) + linarith + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n : ℕ} (d C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hempty : EmptyBlock (d^20) r c) + (hrc : (∑ i,r i)=∑ j,c j) (hd : 14≤d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n≤d) + [Nonempty (GraphState (d^20) r c)] + +local notation "A" => emptyData (d^20) (d^12) d r c hempty hrc (smallDim_one d hd) hmn + +theorem empty_poincare (hC2 : 2≤C) (hC : ∀ i,paddedRow (d^20) (d^12) r c i≤C) + (H : GraphState (d^20) r c → ℝ) : + (A).chain.variance H ≤ (d:ℝ)^160*(A).chain.energy H := by + have hd' : (1:ℝ)≤d := by exact_mod_cast (smallDim_one d hd) + have hd0 : (0:ℝ) Finset.sum_nonneg (fun Y _ => + mul_nonneg (emptyCount_nonneg (d^20) r c X Y) (sq_nonneg _))) + have hvar : (A).chain.variance H=graphVariance (d^20) (d^12) r c (extendGraph (d^20) r c H)/(A).total := by + rw [AcceptedData.variance_formula] + congr 1 + unfold graphVariance + have hh : extendGraph (d^20) r c H ∘ graphUnderlying (d^20) r c=H := by + funext X; exact extendGraph_apply (d^20) r c H X + rw [hh]; rfl + have hEn : (A).chain.energy H=(proposalRate (32*d^2)/(A).total)*S/2 := by + rw [AcceptedData.energy_formula]; rfl + have hq := (smallProposal_bounds d (by omega)).1 + have hrate : S/(A).total ≤128*(d:ℝ)^2*(A).chain.energy H := by + rw [hEn] + have hsum := mul_le_mul_of_nonneg_right hq hs + apply (div_le_iff₀ (A).total_pos).mpr + field_simp [(A).total_pos.ne'] + have hh : S≤64*(d:ℝ)^2*(proposalRate (32*d^2)*S) := by + have hh := hsum + rw [one_div_mul_eq_div,div_le_iff₀ (by positivity : 0<64*(d:ℝ)^2)] at hh + nlinarith only [hh] + nlinarith only [hh] + have hpow : 770*(d:ℝ)^4*((d^20:ℕ):ℝ)^6*2=1540*(d:ℝ)^124 := by + push_cast + rw [← pow_mul] + ring + have hvarS : (A).chain.variance H ≤1540*(d:ℝ)^124*(S/(A).total) := by + rw [hvar] + apply (div_le_iff₀ (A).total_pos).mpr + have hh := hv.trans (mul_le_mul_of_nonneg_left he (by positivity)) + change graphVariance (d^20) (d^12) r c (extendGraph (d^20) r c H) ≤ _ at hh + calc + _ ≤ 770*(d:ℝ)^4*((d^20:ℕ):ℝ)^6*(2*S) := hh + _ = (1540*(d:ℝ)^124)*S := by rw [← mul_assoc,hpow] + _ = _ := by field_simp [(A).total_pos.ne'] + have hconst : 197120*(d:ℝ)^126≤(d:ℝ)^160 := by + have hh : (197120:ℝ)≤(d:ℝ)^34 := by + calc + _ ≤ (14:ℝ)^34 := by norm_num + _ ≤ _ := pow_le_pow_left₀ (by norm_num) (by exact_mod_cast hd) _ + have hh' := mul_le_mul_of_nonneg_right hh (pow_nonneg hd0.le 126) + calc + _ ≤ (d:ℝ)^34*(d:ℝ)^126 := hh' + _ = _ := by rw [← pow_add] + calc + _ ≤ 1540*(d:ℝ)^124*(S/(A).total) := hvarS + _ ≤ 1540*(d:ℝ)^124*(128*(d:ℝ)^2*(A).chain.energy H) := mul_le_mul_of_nonneg_left hrate (by positivity) + _ = (197120*(d:ℝ)^126)*(A).chain.energy H := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hconst (by rw [hEn]; have hp : 0 ≤ proposalRate (32*d^2) := le_trans (by positivity) hq; exact div_nonneg (mul_nonneg (div_nonneg hp (A).total_pos.le) hs) (by norm_num)) + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n : ℕ} (d C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hempty : EmptyBlock (d^20) r c) + (hrc : (∑ i,r i)=∑ j,c j) (hd : 14≤d) (hm : m≤d) (hn : n≤d) (hmn : m*n≤d) + [Nonempty (GraphState (d^20) r c)] +local notation "A" => emptyData (d^20) (d^12) d r c hempty hrc (smallDim_one d hd) hmn + +omit [Nonempty (GraphState (d^20) r c)] in +theorem empty_total : (A).total=(graphMass (d^20) (d^12) r c:ℝ) := by + simp [AcceptedData.total,emptyData,graphMass,Nat.cast_sum] + + +theorem empty_mixing (hC2 : 2≤C) (hU : d^20≤C) + (hC : ∀ i,paddedRow (d^20) (d^12) r c i≤C) (t : ℕ) (X : GraphState (d^20) r c) : + ((A).chain.walk X t).tv (A).chain.invariant≤ + (C+1:ℝ)^(2*d)*Real.exp (-(t:ℝ)/(d:ℝ)^160) := by + rw [Chain.walk_tv] + have hk : (1:ℝ)≤(d:ℝ)^160 := one_le_pow₀ (by exact_mod_cast smallDim_one d hd) + have hvar := empty_poincare d C r c hempty hrc hd hmn hC2 hC + have hmin (Y : GraphState (d^20) r c) : 1/(C+1:ℝ)^(2*d)≤(A).chain.π Y := by + change _≤(weight (d^20) (d^12) r c (graphUnderlying (d^20) r c Y):ℝ)/(A).total + rw [empty_total d r c hempty hrc hd hmn] + exact stationary_lower (d^20) (d^12) C r c d hrc hmn hU hC Y + have hh := (A).chain.mixing_bound_min ((d:ℝ)^160) hk hvar + (1/(C+1:ℝ)^(2*d)) (by positivity) hmin t X + simpa only [one_div,inv_inv] using hh + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace DyadicLaw +open FiniteChain +variable {α : Type*} [Fintype α] [DecidableEq α] +theorem walk_toLaw_chain (q : α → DyadicLaw α) (S : ℕ) (hS : ∀ x,(q x).bits=S) + (C : Chain α) (hq : ∀ x,(q x).toLaw=C.transition x) (x₀ : α) (t : ℕ) : + (walk q S hS x₀ t).toLaw=C.walk x₀ t := by + induction t with + | zero => exact toLaw_pure _ _ + | succ t ih => + rw [walk,toLaw_bind,Chain.walk,ih] + congr 1 + funext x + exact hq x +end DyadicLaw +end +end Contingency +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n : ℕ} (U L d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hempty : EmptyBlock U r c) (hrc : (∑ i,r i)=∑ j,c j) + (hd : 1 ≤ d) (hmn : m*n ≤ d) +local notation "Comp" => fun X : GraphState U r c => Completion U L r c (graphUnderlying U r c X) +local instance outerAccuracyEmptyTrialCompletionFintype (X : GraphState U r c) : + Fintype (Comp X) := Fintype.ofFinite _ +local instance (X : GraphState U r c) : DecidableEq (Comp X) := Classical.decEq _ +local instance outerAccuracyEmptyTrialTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + +theorem smallProposal_bits (X : GraphState U r c) : + (smallProposal U d r c hd hmn X).bits=Nat.clog 2 (32*d^2) := rfl + +theorem proposal_pad_bound (S : ℕ) (X : GraphState U r c) : + (smallProposal U d r c hd hmn X).bits ≤ Nat.clog 2 (32*d^2)+S := by + rw [smallProposal_bits] + omega + +theorem completion_pure_bits (S : ℕ) (X : GraphState U r c) (A : Comp X) : + (DyadicLaw.pure A S).bits=S := rfl + +def emptyTransition (S : ℕ) (X : GraphState U r c) : DyadicLaw (GraphState U r c) := + (smallProposal U d r c hd hmn X).pad (Nat.clog 2 (32*d^2)+S) (proposal_pad_bound U d r c hd hmn S X) + +theorem emptyTransition_bits (S : ℕ) (X : GraphState U r c) : + (emptyTransition U d r c hd hmn S X).bits=Nat.clog 2 (32*d^2)+S := rfl + +variable [Nonempty (GraphState U r c)] + +theorem emptyTransition_toLaw (S : ℕ) (X : GraphState U r c) : + (emptyTransition U d r c hd hmn S X).toLaw = (emptyData U L d r c hempty hrc hd hmn).chain.transition X := by + classical + rw [emptyTransition,DyadicLaw.toLaw_pad] + apply Law.ext_offdiag _ _ X + intro Y hXY + rw [DyadicLaw.neighborProposal_offdiag] + simp only [Chain.transition,AcceptedData.chain_P,AcceptedData.kernel,ite_eq_right hXY] + change _=(proposalRate (32*d^2)*emptyCount U r c X Y)/weight U L r c (graphUnderlying U r c X) + rw [empty_weight U L r c hempty hrc X] + simp only [Nat.cast_one,div_one,emptyCount,proposalRate] + ring + exact hXY + +def emptyWalk (S : ℕ) (X₀ : GraphState U r c) (t : ℕ) : DyadicLaw (GraphState U r c) := by + classical + exact DyadicLaw.walk (emptyTransition U d r c hd hmn S) (Nat.clog 2 (32*d^2)+S) (emptyTransition_bits U d r c hd hmn S) X₀ t + +theorem emptyWalk_toLaw (S : ℕ) (X₀ : GraphState U r c) (t : ℕ) : + (emptyWalk U d r c hd hmn S X₀ t).toLaw=(emptyData U L d r c hempty hrc hd hmn).chain.walk X₀ t := by + classical + exact DyadicLaw.walk_toLaw_chain _ _ _ _ (emptyTransition_toLaw U L d r c hempty hrc hd hmn S) X₀ t + +theorem empty_invariant_joint : + letI := tables_nonempty r c hrc + letI : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance + (emptyData U L d r c hempty hrc hd hmn).chain.invariant.sigma + (idealCompletion U L r c hrc)=Law.uniform (Joint U L r c) := by + classical + let := tables_nonempty r c hrc + let : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance + apply Law.ext; funext ⟨X,A⟩ + simp only [Law.sigma,Chain.invariant,AcceptedData.chain,emptyData,idealCompletion,Law.uniform] + have htotal : (∑ X : GraphState U r c,(weight U L r c (graphUnderlying U r c X):ℝ))=(graphMass U L r c:ℝ) := by + simp [graphMass,Nat.cast_sum] + change (weight U L r c (graphUnderlying U r c X):ℝ)/ + (∑ X : GraphState U r c,(weight U L r c (graphUnderlying U r c X):ℝ)) * + (1/(Fintype.card (Comp X):ℝ)) = 1/(Fintype.card (Joint U L r c):ℝ) + rw [htotal,← Nat.card_eq_fintype_card,← Nat.card_eq_fintype_card,joint_card] + have he : weight U L r c (graphUnderlying U r c X)=Nat.card (Comp X) := by + rw [weight,ite_eq_left (graph_feasible U r c X)] + rw [← he] + have hp : (weight U L r c (graphUnderlying U r c X):ℝ)≠0 := by + exact_mod_cast (graph_weight_pos U L r c X hrc).ne' + field_simp + +def emptyTrial (S : ℕ) (fallbacks : ∀ X,Comp X) (X₀ : GraphState U r c) (t : ℕ) : DyadicLaw (Option (Tables r c)) := by + classical + exact ((emptyWalk U d r c hd hmn S X₀ t).sigma (fun X => DyadicLaw.pure (fallbacks X) S) S (fun X => completion_pure_bits U L r c S X (fallbacks X))).map (decodeJoint r c U L) + +omit [Nonempty (GraphState U r c)] in +theorem emptyTrial_bits (S : ℕ) (fallbacks : ∀ X,Comp X) (X₀ : GraphState U r c) (t : ℕ) : + (emptyTrial U L d r c hd hmn S fallbacks X₀ t).bits=t*(Nat.clog 2 (32*d^2)+S)+S := by + classical + simp only [emptyTrial,DyadicLaw.map_bits,DyadicLaw.sigma_bits,emptyWalk,DyadicLaw.walk_bits] + +include hempty in +omit [Nonempty (GraphState U r c)] in +theorem empty_completion_law (S : ℕ) (X : GraphState U r c) (fallback : Comp X) : + (DyadicLaw.pure fallback S).toLaw=idealCompletion U L r c hrc X := by + let := empty_completion_subsingleton U L r c hempty (graphUnderlying U r c X) + let := completion_nonempty U L r c X hrc + rw [DyadicLaw.toLaw_pure] + apply Law.ext + funext x + have hx : x=fallback := Subsingleton.elim _ _ + subst x + simp only [Law.pure,idealCompletion,Law.uniform] + rw [← Nat.card_eq_fintype_card,Nat.card_unique] + norm_num + +theorem emptyTrial_tv (S : ℕ) (fallbacks : ∀ X,Comp X) (X₀ : GraphState U r c) (t : ℕ) : + letI := tables_nonempty r c hrc + (emptyTrial U L d r c hd hmn S fallbacks X₀ t).toLaw.tv (stationaryTrial r c U L) ≤ + ((emptyData U L d r c hempty hrc hd hmn).chain.walk X₀ t).tv (emptyData U L d r c hempty hrc hd hmn).chain.invariant := by + classical + let := tables_nonempty r c hrc + unfold emptyTrial stationaryTrial + rw [DyadicLaw.toLaw_map,DyadicLaw.toLaw_sigma,emptyWalk_toLaw U L d r c hempty hrc hd hmn, + ← empty_invariant_joint U L d r c hempty hrc hd hmn] + simp only [empty_completion_law U L r c hempty hrc] + apply (Law.tv_map _ _ _).trans + have hh := Law.tv_sigma ((emptyData U L d r c hempty hrc hd hmn).chain.walk X₀ t) + (emptyData U L d r c hempty hrc hd hmn).chain.invariant (idealCompletion U L r c hrc) + (idealCompletion U L r c hrc) 0 (fun _ => by simp [Law.tv_self]) + simpa using hh + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n : ℕ} (d b k C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hempty : EmptyBlock (d^20) r c) (hrc : (∑ i,r i)=∑ j,c j) + (hd : 14 ≤ d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n ≤ d) + [Nonempty (GraphState (d^20) r c)] +local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) +local instance outerAccuracyEmptyOuterCompletionFintype (X : GraphState (d^20) r c) : + Fintype (Comp X) := Fintype.ofFinite _ +local instance outerAccuracyEmptyOuterTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + +def emptyOuter (fallbacks : ∀ X,Comp X) (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : DyadicLaw (Tables r c) := by + classical + exact stoppedLaw (emptyTrial (d^20) (d^12) d r c (smallDim_one d hd) hmn (Schedule.RD d b k) + fallbacks X₀ (Schedule.T d b k)) fallback (Schedule.Jo d k) + +omit [Nonempty (GraphState (d^20) r c)] in +theorem emptyOuter_bits (fallbacks : ∀ X,Comp X) (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : + (emptyOuter d b k r c hd hmn fallbacks X₀ fallback).bits=Schedule.R d b k := by + classical + change (emptyTrial _ _ _ _ _ _ _ _ _ _ _).bits*Schedule.Jo d k=_ + rw [emptyTrial_bits] + unfold Schedule.R Schedule.RT Schedule.qs + ring + +include hempty hm hn in +theorem emptyOuter_tv (hb : d ≤ b) (hk : 1 ≤ k) (hC2 : 2 ≤ C) (hU : d^20 ≤ C) + (hC : ∀ i,paddedRow (d^20) (d^12) r c i ≤ C) (hCb : C+1 ≤ 2^b) + (fallbacks : ∀ X,Comp X) (X₀ : GraphState (d^20) r c) (fallback : Tables r c) : + letI := tables_nonempty r c hrc + (emptyOuter d b k r c hd hmn fallbacks X₀ fallback).toLaw.tv (Law.uniform (Tables r c)) ≤ (2:ℝ)^(-(k:ℤ)) := by + classical + let := tables_nonempty r c hrc + let p := emptyTrial (d^20) (d^12) d r c (smallDim_one d hd) hmn (Schedule.RD d b k) fallbacks X₀ (Schedule.T d b k) + let s := stationaryTrial r c (d^20) (d^12) + have ht := emptyTrial_tv (d^20) (d^12) d r c hempty hrc (smallDim_one d hd) hmn (Schedule.RD d b k) fallbacks X₀ (Schedule.T d b k) + have hmix := empty_mixing d C r c hempty hrc hd hmn hC2 hU hC (Schedule.T d b k) X₀ + have hfirst := Law.first_tv p.toLaw s fallback (Schedule.Jo d k) + have hideal := Law.first_ideal_tv s fallback (Law.uniform (Tables r c)) (stationaryTrial_uniform r c (d^20) (d^12)) (Schedule.Jo d k) + have hfail := stationary_failure_power d r c hrc hd hm hn hmn (Schedule.Jo d k) + have htri := Law.tv_triangle (Law.first p.toLaw fallback (Schedule.Jo d k)) (Law.first s fallback (Schedule.Jo d k)) (Law.uniform (Tables r c)) + have hmul := mul_le_mul_of_nonneg_left (ht.trans hmix) (Nat.cast_nonneg (Schedule.Jo d k)) + have htotal := Schedule.outer_error_schedule d b k hd hb hk C hCb + have hnerr : 0 ≤ (Schedule.Jo d k:ℝ)*((Schedule.T d b k:ℝ)+1)*(2:ℝ)^(-(Schedule.h d b k:ℤ)) := by positivity + unfold emptyOuter + rw [stoppedLaw_toLaw] + change (Law.first p.toLaw fallback (Schedule.Jo d k)).tv _ ≤ _ + change _≤_ at hfail + dsimp only [p,s] at hfirst hideal htri + dsimp only [p] + rw [neg_div] at hmul + nlinarith only [hfirst,hideal,hfail,htri,hmul,htotal,hnerr] + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +namespace Parameters + + +def dim (m n : ℕ) : ℕ := 10+(m+1)*(n+1) +def L (m n : ℕ) : ℕ := dim m n^12 +def U (m n : ℕ) : ℕ := dim m n^20 +def cap (m n N : ℕ) : ℕ := N+dim m n*L m n+U m n+2 +def bits (m n N : ℕ) : ℕ := dim m n+Nat.clog 2 (cap m n N+2) + +theorem dimensions {m n : ℕ} (hm : 0 < m) (hn : 0 < n) : + 14 ≤ dim m n ∧ m ≤ dim m n ∧ n ≤ dim m n ∧ m*n ≤ dim m n := by + unfold dim + have hh : 4 ≤ (m+1)*(n+1) := by nlinarith + refine ⟨by omega, ?_, ?_, ?_⟩ <;> nlinarith + +theorem cap_pos (m n N : ℕ) : 2 ≤ cap m n N := by unfold cap; omega + +theorem threshold_le_cap (m n N : ℕ) : U m n ≤ cap m n N := by unfold cap; omega + +theorem dimension_le_bits (m n N : ℕ) : dim m n ≤ bits m n N := by unfold bits; omega + +theorem cap_pow_bits (m n N : ℕ) : cap m n N+1 ≤ 2^bits m n N := by + have h := Nat.le_pow_clog (by norm_num : 1 < 2) (cap m n N+2) + apply (show cap m n N+1 ≤ cap m n N+2 by omega).trans + apply h.trans + exact Nat.pow_le_pow_right (by norm_num) (by unfold bits; omega) + + +theorem paddedRow_le_cap {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) (i : Fin m) : + PaddedGraph.paddedRow (U m n) (L m n) r c i ≤ cap m n (∑ i,r i) := by + have hi : r i ≤ ∑ i,r i := Finset.single_le_sum (fun j _ => Nat.zero_le (r j)) (Finset.mem_univ i) + have hn : n ≤ dim m n := by unfold dim; nlinarith + have hp : PaddedGraph.rowPadding (U m n) (L m n) r c i ≤ (n:ℤ)*(L m n:ℤ) := by + unfold PaddedGraph.rowPadding + calc + _ ≤ ∑ _j : Fin n,(L m n:ℤ) := Finset.sum_le_sum (fun j _ => by split_ifs <;> simp) + _ = _ := by simp + have hn' : (n:ℤ) ≤ dim m n := by exact_mod_cast hn + have hi' : (r i:ℤ) ≤ (∑ i,r i:ℕ) := by exact_mod_cast hi + have hx := mul_le_mul_of_nonneg_right hn' (Int.natCast_nonneg (L m n)) + unfold PaddedGraph.paddedRow cap + push_cast at hi' ⊢ + omega + +end Parameters +end Contingency + + + + + +namespace Contingency.Parameters + + +theorem bits_le (m n N : ℕ) : bits m n N ≤ 21*dim m n+Nat.log2 (N+1)+4 := by + let d := dim m n + let B := 20*d+Nat.log2 (N+1)+1 + have hd : d ≤ 2^d := Nat.lt_two_pow_self.le + have h13 : d^13 ≤ 2^(20*d) := by + calc + _ ≤ (2^d)^13 := Nat.pow_le_pow_left hd _ + _ = 2^(d*13) := (pow_mul _ _ _).symm + _ ≤ _ := Nat.pow_le_pow_right (by norm_num) (by omega) + have h20 : d^20 ≤ 2^(20*d) := by + calc + _ ≤ (2^d)^20 := Nat.pow_le_pow_left hd _ + _ = 2^(20*d) := by rw [← pow_mul]; congr 1; omega + have hN : N ≤ 2^(Nat.log2 (N+1)+1) := by + have hh := Nat.lt_pow_succ_log_self (by norm_num : 1<2) (N+1) + rw [← Nat.log2_eq_log_two] at hh + omega + have hpow : 2^(20*d) ≤ 2^B := Nat.pow_le_pow_right (by norm_num) (by dsimp [B]; omega) + have hpow' : 2^(Nat.log2 (N+1)+1) ≤ 2^B := Nat.pow_le_pow_right (by norm_num) (by dsimp [B]; omega) + have hpos : 1 ≤ 2^B := Nat.one_le_pow _ _ (by norm_num) + have hcap : cap m n N+2 ≤ 2^(B+3) := by + have h := h13.trans hpow + have h' := h20.trans hpow + have h'' := hN.trans hpow' + have he : cap m n N+2=N+d^13+d^20+4 := by + unfold cap L U + dsimp only [d] + rw [pow_succ] + ring + rw [he,pow_add] + norm_num + omega + have hc : Nat.clog 2 (cap m n N+2) ≤ B+3 := + (Nat.clog_le_iff_le_pow (by norm_num)).mpr hcap + unfold bits + dsimp [B,d] at hc + omega + + +theorem dim_le_size_square (m n N : ℕ) : dim m n ≤ (inputSize m n N+3)^2 := by + unfold dim inputSize + nlinarith [Nat.zero_le (Nat.log2 (N+1))] + +end Contingency.Parameters + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/ParseNatRuns.lean b/lean/OAI/Probability/Contingency/ParseNatRuns.lean new file mode 100644 index 0000000000000000000000000000000000000000..d40362d7db32b8a0a099b4e68d20aaf9e44ec54a --- /dev/null +++ b/lean/OAI/Probability/Contingency/ParseNatRuns.lean @@ -0,0 +1,628 @@ +import Mathlib +import OAI.Probability.Contingency.StackSequence + +namespace OAI + +/-! Parse Nat Runs. -/ + +noncomputable section + + +namespace Contingency.BitModel.StackCode.ParseNat +noncomputable section + +theorem data_done (m : Memory 4) (h2 : m.stack 2=[]) : + exec 1 (config .data m)=config .restore (m.pop 2) := by + rw [exec_one,one_step] + simp [code,effect,branch,h2,config]; rfl + +theorem restore_empty (m : Memory 4) (h1 : m.stack 1=[]) : + exec 1 (config .restore m)=config .done (m.pop 1) := by + rw [exec_one,one_step] + simp [code,effect,branch,h1,config]; rfl + +theorem restore_bit (m : Memory 4) (b : Bool) (bs : List Bool) (h1 : m.stack 1=b::bs) : + exec 2 (config .restore m)=config .restore ((m.pop 1).push 0 b) := by + change step program false (step program false (config .restore m))=_ + rw [one_step] + have he : (⟨(effect (code .restore) false m).1,(effect (code .restore) false m).2⟩ : Config program)=config (.place b) (m.pop 1) := by + cases b <;> simp [code,effect,branch,h1,config] <;> rfl + rw [he,one_step]; rfl + +def restoreMemory : List Bool→Memory 4→Memory 4 + | [],m => m.pop 1 + | b::bs,m => restoreMemory bs ((m.pop 1).push 0 b) + +theorem restore_run (bs : List Bool) (m : Memory 4) (h1 : m.stack 1=bs) : + exec (2*bs.length+1) (config .restore m)=config .done (restoreMemory bs m) := by + induction bs generalizing m with + | nil => exact restore_empty m h1 + | cons b bs ih => + have he : 2*(b::bs).length+1=2+(2*bs.length+1) := by simp; omega + rw [he,exec_add,restore_bit m b bs h1,ih] + · rfl + · simp [Memory.push,Memory.pop,h1] + +theorem restoreMemory_fields (bs : List Bool) (m : Memory 4) (h1 : m.stack 1=bs) : + (restoreMemory bs m).input=m.input ∧ + (restoreMemory bs m).stack 0=bs.reverse++m.stack 0 ∧ + (restoreMemory bs m).stack 1=[] ∧ + (restoreMemory bs m).stack 2=m.stack 2 ∧ + (restoreMemory bs m).stack 3=m.stack 3 ∧ + (restoreMemory bs m).outputRev=m.outputRev := by + induction bs generalizing m with + | nil => simp [restoreMemory,Memory.pop,h1] + | cons b bs ih => + have hh := ih ((m.pop 1).push 0 b) (by simp [Memory.pop,Memory.push,h1]) + simpa [restoreMemory,Memory.pop,Memory.push,List.reverse_cons,List.append_assoc] using hh + +theorem halt (m : Memory 4) : exec 1 (config .done m)=⟨none,m⟩ := by + rw [exec_one,one_step]; rfl + + + +theorem parse_word (bs : List Bool) (m : Memory 4) (rest : List Bool) + (hi : m.input=List.replicate bs.length true++false::(bs++rest)) + (h1 : m.stack 1=[]) (h2 : m.stack 2=[]) : + ∃ m' : Memory 4,exec (7*bs.length+4) (config .prefix m)=⟨none,m'⟩ ∧ + m'.input=rest ∧ m'.stack 0=bs++m.stack 0 ∧ + m'.stack 1=[] ∧ m'.stack 2=[] ∧ m'.stack 3=m.stack 3 ∧ m'.outputRev=m.outputRev := by + let p := prefixMemory bs.length m + have hp := prefixMemory_fields bs.length m (bs++rest) hi + have hp2 : p.stack 2=List.replicate bs.length false := by simpa [p,h2] using hp.2.2.2.1 + let d := dataMemory bs p + have hd := dataMemory_fields bs p rest hp.1 hp2 + have hd1 : (d.pop 2).stack 1=bs.reverse := by + simpa [d,Memory.pop,p,hp.2.2.1,h1] using hd.2.2.1 + let r := restoreMemory bs.reverse (d.pop 2) + have hr := restoreMemory_fields bs.reverse (d.pop 2) hd1 + refine ⟨r,?_,?_,?_,hr.2.2.1,?_,?_,?_⟩ + · have he : 7*bs.length+4=(((2*bs.length+1)+3*bs.length)+1)+(2*bs.reverse.length+1)+1 := by simp; omega + rw [he,exec_add _ 1,exec_add (((2*bs.length+1)+3*bs.length)+1) (2*bs.reverse.length+1),exec_add ((2*bs.length+1)+3*bs.length) 1,exec_add (2*bs.length+1) (3*bs.length)] + rw [prefix_run bs.length m (bs++rest) hi,data_run bs p rest hp.1 hp2,data_done _ hd.2.2.2.1,restore_run bs.reverse (d.pop 2) hd1,halt] + · exact hr.1.trans hd.1 + · calc + r.stack 0=bs.reverse.reverse++(d.pop 2).stack 0 := hr.2.1 + _ = bs++m.stack 0 := by + simp only [List.reverse_reverse] + congr 1 + simpa [Memory.pop] using hd.2.1.trans hp.2.1 + · have hd2 : d.stack 2=[] := hd.2.2.2.1 + exact hr.2.2.2.1.trans (by simp [Memory.pop,hd2]) + · exact hr.2.2.2.2.1.trans (hd.2.2.2.2.1.trans hp.2.2.2.2.1) + · exact hr.2.2.2.2.2.trans (hd.2.2.2.2.2.trans hp.2.2.2.2.2) + +theorem step_independent (cfg : Config program) (b b' : Bool) : + step program b cfg=step program b' cfg := by + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some pc => + unfold step + dsimp only [program] + cases (Fintype.equivFin Q).symm pc <;> rfl + +theorem fold_independent (xs ys : List Bool) (hl : xs.length=ys.length) (cfg : Config program) : + xs.foldl (fun cfg b => step program b cfg) cfg=ys.foldl (fun cfg b => step program b cfg) cfg := by + induction xs generalizing ys cfg with + | nil => cases ys <;> simp_all + | cons x xs ih => + cases ys with + | nil => simp at hl + | cons y ys => + simp only [List.length_cons,Nat.add_right_cancel_iff] at hl + simp only [List.foldl_cons] + rw [step_independent _ x y] + exact ih _ hl _ + + + +theorem parse_nat_tape (x : ℕ) (rest : List Bool) : + ∃ m' : Memory 4,m'.input=rest ∧ m'.stack 0=x.bits ∧ + m'.stack 1=[] ∧ m'.stack 2=[] ∧ m'.stack 3=[] ∧ m'.outputRev=[] ∧ + ∀ coins : Fin ((7*x.size+4)*2)→Bool, + (compile program).run (encodeNat x++rest) coins=encode program ⟨none,m'⟩ := by + let m : Memory 4 := ⟨encodeNat x++rest,0,fun _ => [],fun _ => 0,[]⟩ + have hi : m.input=List.replicate x.bits.length true++false::(x.bits++rest) := by + simp [m,encodeNat,List.append_assoc] + obtain ⟨m',hr,hi',h0,h1,h2,h3,ho⟩ := parse_word x.bits m rest hi rfl rfl + refine ⟨m',hi',by simpa [m] using h0,h1,h2,h3,ho,?_⟩ + intro coins + rw [run_eq] + unfold run + have he := fold_independent (List.ofFn fun i : Fin (7*x.size+4) => coins (second i)) (List.replicate (7*x.size+4) false) (by simp) (initial program (encodeNat x++rest)) + rw [he] + change encode program (exec (7*x.size+4) (config .prefix m))=_ + simpa only [Nat.size_eq_bits_len] using congrArg (encode program) hr + +end +end Contingency.BitModel.StackCode.ParseNat + + + + + + + +namespace Contingency.BitModel.StackCode.PrepareMaximum +noncomputable section + +def reg (i : Fin 4) : Fin 6 := i.castAdd 2 + +theorem reg_injective : Function.Injective reg := by + intro i j h + apply Fin.ext + exact congrArg (fun x : Fin 6 => x.val) h + +abbrev parser : Program := + ⟨ParseNat.program.labels,6,ParseNat.program.start,fun q => Registers.op reg (ParseNat.program.code q)⟩ + +def program : Program := Sequence.program parser 4 0 (Transfer.code (0 : Fin 6) 4) + +theorem parser_noCoin : ∀ q,NoCoin (parser.code q) := by + intro q + apply noCoin_registers + change NoCoin (ParseNat.code ((Fintype.equivFin ParseNat.Q).symm q)) + cases (Fintype.equivFin ParseNat.Q).symm q <;> trivial + +theorem noCoin : ∀ q,NoCoin (program.code q) := by + apply noCoin_sequence _ _ _ _ parser_noCoin + intro q + fin_cases q <;> trivial + + + +theorem prepare (N : ℕ) (rest : List Bool) : + ∃ (t : ℕ) (m' : Memory 6),t≤9*N.size+6 ∧ + (∀ i : Fin 4,m'.stack (reg i)=[]) ∧ + m'.stack 4=IntegerDraw.rawMaximum N ∧ m'.stack 5=[] ∧ + m'.input=rest ∧ m'.outputRev=[] ∧ + ∀ coins : List Bool,coins.length=t → + coins.foldl (fun c b => step program b c) (initial program (encodeNat N++rest))=⟨none,m'⟩ := by + let xs := encodeNat N++rest + let m₄ : Memory 4 := (initial ParseNat.program xs).memory + have hi : m₄.input=List.replicate N.bits.length true++false::(N.bits++rest) := by + simp [m₄,initial,xs,encodeNat,List.append_assoc] + obtain ⟨m₄',hp,hi',h0,h1,h2,h3,ho⟩ := ParseNat.parse_word N.bits m₄ rest hi rfl rfl + let T := 7*N.size+4 + have hp' : (List.replicate T false).foldl (fun c b => step ParseNat.program b c) + (initial ParseNat.program xs)=⟨none,m₄'⟩ := by + simpa only [ParseNat.exec,T,Nat.size_eq_bits_len,ParseNat.config,m₄,initial,ParseNat.program] using hp + let c₆ := (List.replicate T false).foldl (fun c b => step parser b c) (initial parser xs) + have hr₀ : Registers.ConfigRel ParseNat.program reg (initial ParseNat.program xs) (initial parser xs) := + ⟨rfl,fun _ => rfl,rfl,rfl,rfl⟩ + have hr := Registers.fold_rel ParseNat.program reg reg_injective (List.replicate T false) hr₀ + rw [hp'] at hr + have hc : c₆.state=none := hr.1 + have hs : ∀ i : Fin 4,c₆.memory.stack (reg i)=m₄'.stack i := hr.2.1 + have hs0 : c₆.memory.stack 0=N.bits := by simpa [reg,m₄,initial] using (hs 0).trans h0 + have hs1 : c₆.memory.stack 1=[] := (hs 1).trans h1 + have hs2 : c₆.memory.stack 2=[] := (hs 2).trans h2 + have hs3 : c₆.memory.stack 3=[] := by simpa [reg,m₄,initial] using (hs 3).trans h3 + have frame (j : Fin 6) (hj : ∀ i,reg i≠j) : c₆.memory.stack j=[] := + Registers.fold_frame ParseNat.program reg (List.replicate T false) (initial parser xs) j hj + have hs4 : c₆.memory.stack 4=[] := frame 4 (by intro i h; have hv := congrArg Fin.val h; have hi := i.isLt; change i.val=4 at hv; omega) + have hs5 : c₆.memory.stack 5=[] := frame 5 (by intro i h; have hv := congrArg Fin.val h; have hi := i.isLt; change i.val=5 at hv; omega) + obtain ⟨t,ht,hfirst⟩ := Sequence.deterministic_first_time parser + (noCoin_deterministic parser parser_noCoin) (initial parser xs) T hc + have hf := hfirst (List.replicate t false) (by simp) + let m' := Transfer.memory (0 : Fin 6) 4 N.bits c₆.memory + have hm := Transfer.memory_fields (0 : Fin 6) 4 (by decide) N.bits c₆.memory hs0 + refine ⟨t+(2*N.bits.length+2),m',?_,?_,?_,?_,?_,?_,?_⟩ + · simp only [Nat.size_eq_bits_len] + dsimp only [T] at ht + omega + · intro i + fin_cases i + · exact hm.1 + · exact (hm.2.2.1 1 (by decide) (by decide)).trans hs1 + · exact (hm.2.2.1 2 (by decide) (by decide)).trans hs2 + · exact (hm.2.2.1 3 (by decide) (by decide)).trans hs3 + · simpa only [m',IntegerDraw.rawMaximum,hs4,List.append_nil] using hm.2.1 + · exact (hm.2.2.1 5 (by decide) (by decide)).trans hs5 + · exact hm.2.2.2.1.trans (hr.2.2.1.trans hi') + · exact hm.2.2.2.2.1.trans (hr.2.2.2.1.trans ho) + · intro coins hlen + rw [Sequence.deterministic_fold program (noCoin_deterministic program noCoin) _ _ + (List.replicate (t+(2*N.bits.length+2)) false) (by simpa using hlen)] + rw [List.replicate_add] + have hl := Sequence.link_run parser 4 0 (Transfer.code (0 : Fin 6) 4) + (initial parser xs) (List.replicate t false) (List.replicate (2*N.bits.length+2) false) hf.1 + rw [hf.2] at hl + change (List.replicate t false++List.replicate (2*N.bits.length+2) false).foldl + (fun c b => step program b c) (initial program xs)=⟨none,m'⟩ + have ht_run := Transfer.run (0 : Fin 6) 4 (by decide) N.bits c₆.memory hs0 + change (List.replicate (2*N.bits.length+2) false).foldl + (fun c b => step (Transfer.program (0 : Fin 6) 4) b c) + (Transfer.config (0 : Fin 6) 4 0 c₆.memory)=⟨none,m'⟩ at ht_run + change (List.replicate t false++List.replicate (2*N.bits.length+2) false).foldl + (fun c b => step program b c) (initial program xs)= + Sequence.right parser 4 0 (Transfer.code (0 : Fin 6) 4) + ((List.replicate (2*N.bits.length+2) false).foldl + (fun c b => step (Transfer.program (0 : Fin 6) 4) b c) + (Transfer.config (0 : Fin 6) 4 0 c₆.memory)) at hl + exact hl.trans (congrArg (fun c : Config (Transfer.program (0 : Fin 6) 4) => + Sequence.right parser 4 0 (Transfer.code (0 : Fin 6) 4) c) ht_run) + +end +end Contingency.BitModel.StackCode.PrepareMaximum + + + + + + + +namespace Contingency.BitModel.StackCode.PreparedIntegerCall +noncomputable section + +abbrev callee : Program := + ⟨IntegerDraw.program.labels,6,IntegerDraw.program.start, + fun q => Internal.op (IntegerDraw.program.code q)⟩ + +def program : Program := Sequence.program PrepareMaximum.program + callee.labels callee.start callee.code + +def result (c : Config callee) : Config program := + Sequence.right PrepareMaximum.program callee.labels callee.start callee.code c + + +theorem prepared_first (N : ℕ) (rest : List Bool) : + ∃ (t : ℕ) (m : Memory 6),t≤9*N.size+6 ∧ + (∀ i : Fin 4,m.stack (PrepareMaximum.reg i)=[]) ∧ + m.stack 4=IntegerDraw.rawMaximum N ∧ m.stack 5=[] ∧ + m.input=rest ∧ m.outputRev=[] ∧ + ∀ a : List Bool,a.length=t → + Sequence.FirstHalt PrepareMaximum.program + (initial PrepareMaximum.program (encodeNat N++rest)) a ∧ + a.foldl (fun c b => step PrepareMaximum.program b c) + (initial PrepareMaximum.program (encodeNat N++rest))=⟨none,m⟩ := by + obtain ⟨T,m,hT,hw,hi,ho,he,hout,hr⟩ := PrepareMaximum.prepare N rest + have hrun := hr (List.replicate T false) (by simp) + obtain ⟨t,ht,hf⟩ := Sequence.deterministic_first_time PrepareMaximum.program + (noCoin_deterministic _ PrepareMaximum.noCoin) + (initial PrepareMaximum.program (encodeNat N++rest)) T + (by rw [hrun]) + refine ⟨t,m,ht.trans hT,hw,hi,ho,he,hout,?_⟩ + intro a ha + exact ⟨(hf a ha).1,((hf a ha).2).trans hrun⟩ + + + +theorem refinement (N : ℕ) (rest : List Bool) : + ∃ t≤9*N.size+6,∀ a : List Bool,a.length=t → ∀ b : List Bool, + ∃ c : Config callee, + (a++b).foldl (fun c x => step program x c) + (initial program (encodeNat N++rest))=result c ∧ + Internal.ConfigRel IntegerDraw.program + (b.foldl (fun c x => step IntegerDraw.program x c) + (initial IntegerDraw.program (IntegerDraw.rawMaximum N))) c ∧ + c.memory.input=rest ∧ c.memory.outputRev=[] := by + obtain ⟨t,m,ht,hw,hi,ho,he,hout,hr⟩ := prepared_first N rest + refine ⟨t,ht,?_⟩ + intro a ha b + let start : Config callee := ⟨some callee.start,m⟩ + have hrel : Internal.ConfigRel IntegerDraw.program + (initial IntegerDraw.program (IntegerDraw.rawMaximum N)) start := by + refine ⟨rfl,?_,hi,ho⟩ + intro i + exact hw i + let c := b.foldl (fun c x => step callee x c) start + have hc := Internal.fold_rel IntegerDraw.program b hrel + have hf := Internal.fold_frame IntegerDraw.program b start + refine ⟨c,?_,hc,hf.1.trans he,hf.2.1.trans hout⟩ + have hh := Sequence.link_run PrepareMaximum.program callee.labels callee.start callee.code + (initial PrepareMaximum.program (encodeNat N++rest)) a b (hr a ha).1 + rw [(hr a ha).2] at hh + exact hh + + + +theorem tape_refinement (N : ℕ) (rest : List Bool) : + ∃ t≤9*N.size+6,∀ (s : ℕ) (coins : Fin ((t+s)*2)→Bool), + ∃ c : Config callee, + (compile program).run (encodeNat N++rest) coins=encode program (result c) ∧ + Internal.ConfigRel IntegerDraw.program + (((List.ofFn fun i : Fin (t+s) => coins (second i)).drop t).foldl + (fun c x => step IntegerDraw.program x c) + (initial IntegerDraw.program (IntegerDraw.rawMaximum N))) c ∧ + c.memory.input=rest ∧ c.memory.outputRev=[] := by + obtain ⟨t,ht,hr⟩ := refinement N rest + refine ⟨t,ht,?_⟩ + intro s coins + let xs := List.ofFn fun i : Fin (t+s) => coins (second i) + obtain ⟨c,hc,hm,hi,ho⟩ := hr (xs.take t) (by simp [xs]) (xs.drop t) + rw [List.take_append_drop] at hc + refine ⟨c,?_,hm,hi,ho⟩ + rw [run_eq] + exact congrArg (encode program) hc + +end +end Contingency.BitModel.StackCode.PreparedIntegerCall + + + + + + + +namespace Contingency.BitModel.StackCode.InputCall +open Internal (work input) + +def op {l w : ℕ} : Op l w→Op l (w+2) + | .push i b q => .push (work i) b q + | .pop i e z o => .pop (work i) e z o + | .read e z o => .pop (input w) e z o + | .coin z o => .coin z o + | .emit b q => .emit b q + | .jump q => .jump q + | .halt => .halt + +def program (P : Program) : Program := ⟨P.labels,P.work+2,P.start,fun q => op (P.code q)⟩ + + + +def MemoryRel {w : ℕ} (a : Memory w) (b : Memory (w+2)) : Prop := + (∀ i,b.stack (work i)=a.stack i) ∧ + b.stack (input w)=a.input ∧ b.outputRev=a.outputRev + +theorem push_work {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) + (i : Fin w) (v : Bool) : MemoryRel (a.push i v) (b.push (work i) v) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simp [Memory.push,Function.update_apply,hw] + · simpa [Memory.push] using hi + · simpa [Memory.push] using ho + +theorem pop_work {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) + (i : Fin w) : MemoryRel (a.pop i) (b.pop (work i)) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simp [Memory.pop,Function.update_apply,hw] + · simpa [Memory.pop] using hi + · simpa [Memory.pop] using ho + +theorem read_input {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) : + MemoryRel a.read (b.pop (input w)) := by + rcases h with ⟨hw,hi,ho⟩ + refine ⟨?_,?_,?_⟩ + · intro j + simpa [Memory.pop,Memory.read] using hw j + · simp [Memory.pop,Memory.read,hi] + · simpa [Memory.pop,Memory.read] using ho + +theorem emit_output {w : ℕ} {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) (v : Bool) : + MemoryRel {a with outputRev:=v::a.outputRev} {b with outputRev:=v::b.outputRev} := by + exact ⟨h.1,h.2.1,congrArg (v::·) h.2.2⟩ + +theorem effect_rel {l w : ℕ} (code : Op l w) (coin : Bool) + {a : Memory w} {b : Memory (w+2)} (h : MemoryRel a b) : + (effect (op code) coin b).1=(effect code coin a).1 ∧ + MemoryRel (effect code coin a).2 (effect (op code) coin b).2 := by + cases code with + | push i v q => exact ⟨rfl,push_work h i v⟩ + | pop i e z o => exact ⟨by simp [op,effect,h.1 i],pop_work h i⟩ + | read e z o => exact ⟨by simp [op,effect,h.2.1],read_input h⟩ + | coin z o => exact ⟨rfl,h⟩ + | emit v q => exact ⟨rfl,emit_output h v⟩ + | jump q => exact ⟨rfl,h⟩ + | halt => exact ⟨rfl,h⟩ + +def ConfigRel (P : Program) (a : Config P) (b : Config (program P)) : Prop := + b.state=a.state ∧ MemoryRel a.memory b.memory + +theorem step_rel (P : Program) (coin : Bool) {a : Config P} {b : Config (program P)} + (h : ConfigRel P a b) : ConfigRel P (step P coin a) (step (program P) coin b) := by + rcases a with ⟨sa,ma⟩ + rcases b with ⟨sb,mb⟩ + obtain ⟨hs,hm⟩ := h + dsimp only at hs hm + subst sb + cases sa with + | none => exact ⟨rfl,hm⟩ + | some pc => exact effect_rel (P.code pc) coin hm + +theorem fold_rel (P : Program) (coins : List Bool) {a : Config P} {b : Config (program P)} + (h : ConfigRel P a b) : + ConfigRel P (coins.foldl (fun c v => step P v c) a) + (coins.foldl (fun c v => step (program P) v c) b) := by + induction coins generalizing a b with + | nil => exact h + | cons v coins ih => exact ih (step_rel P v h) + +end Contingency.BitModel.StackCode.InputCall + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.EncodedInteger +noncomputable section + +abbrev callee : Program := + ⟨IntegerDraw.program.labels,6,IntegerDraw.program.start, + fun q => InputCall.op (IntegerDraw.program.code q)⟩ + +def program : Program := Sequence.program PrepareMaximum.program + callee.labels callee.start callee.code + +def result (c : Config callee) : Config program := + Sequence.right PrepareMaximum.program callee.labels callee.start callee.code c + + + +theorem refinement (N : ℕ) (rest : List Bool) : + ∃ t≤9*N.size+6,∀ (s : ℕ) (f : Fin (t+s)→Bool), + ((run program (encodeNat N++rest) f).state=none ↔ + (run IntegerDraw.program (IntegerDraw.rawMaximum N) (fun i => f (Fin.natAdd t i))).state=none) ∧ + (run program (encodeNat N++rest) f).memory.outputRev= + (run IntegerDraw.program (IntegerDraw.rawMaximum N) (fun i => f (Fin.natAdd t i))).memory.outputRev := by + obtain ⟨t,m,ht,hw,hi,ho,he,hout,hr⟩ := PreparedIntegerCall.prepared_first N rest + refine ⟨t,ht,?_⟩ + intro s f + let a := List.ofFn fun i : Fin t => f (i.castAdd s) + let b := List.ofFn fun i : Fin s => f (Fin.natAdd t i) + have ha := hr a (by simp [a]) + let start : Config callee := ⟨some callee.start,m⟩ + have hrel : InputCall.ConfigRel IntegerDraw.program + (initial IntegerDraw.program (IntegerDraw.rawMaximum N)) start := by + refine ⟨rfl,?_,hi,hout⟩ + intro i + exact hw i + have hc := InputCall.fold_rel IntegerDraw.program b hrel + have hh := Sequence.link_run PrepareMaximum.program callee.labels callee.start callee.code + (initial PrepareMaximum.program (encodeNat N++rest)) a b ha.1 + rw [ha.2] at hh + have hr' : run program (encodeNat N++rest) f= + result (b.foldl (fun c x => step callee x c) start) := by + unfold run + rw [List.ofFn_add] + exact hh + rw [hr'] + constructor + · change Option.map (Fin.natAdd PrepareMaximum.program.labels) + (b.foldl (fun c x => step callee x c) start).state=none ↔ _ + rw [Option.map_eq_none_iff] + exact (congrArg (fun v => v=none) hc.1).to_iff + · exact hc.2.2.2 + + +theorem shifted_laws (N : ℕ) (rest : List Bool) : + ∃ t≤9*N.size+6,∀ s : ℕ, + (∀ out,mass program (encodeNat N++rest) out (t+s)= + mass IntegerDraw.program (IntegerDraw.rawMaximum N) out s) ∧ + tail program (encodeNat N++rest) (t+s)= + tail IntegerDraw.program (IntegerDraw.rawMaximum N) s := by + classical + obtain ⟨t,ht,hr⟩ := refinement N rest + refine ⟨t,ht,?_⟩ + intro s + have hi : Function.Injective (Fin.natAdd t : Fin s→Fin (t+s)) := by + intro i j h + simpa using h + constructor + · intro out + unfold mass + simp only [(hr s _).1,(hr s _).2] + simpa only [Fintype.card_fin,Function.comp_def] using CoordinateLaw.probability_restrict (Fin.natAdd t) hi + (fun f => (run IntegerDraw.program (IntegerDraw.rawMaximum N) f).state=none ∧ + (run IntegerDraw.program (IntegerDraw.rawMaximum N) f).memory.outputRev.reverse=out) + · unfold tail + simp only [ne_eq,(hr s _).1] + simpa only [Fintype.card_fin,Function.comp_def] using CoordinateLaw.probability_restrict (Fin.natAdd t) hi + (fun f => (run IntegerDraw.program (IntegerDraw.rawMaximum N) f).state≠none) + + + +theorem stack_safe (N : ℕ) (rest : List Bool) {s : ℕ} (f : Fin s→Bool) + (h : (run program (encodeNat N++rest) f).state=none) : + ∃ u : Fin (N+1),(run program (encodeNat N++rest) f).memory.outputRev.reverse= + IntegerDraw.integerWord N u := by + obtain ⟨t,ht,hr⟩ := refinement N rest + let g : Fin (t+s)→Bool := fun i => if h : i.val g ⟨i,lt_of_lt_of_le i.isLt (by omega : s≤t+s)⟩)=f := by + funext i + simp [g,i.isLt] + have hp := run_prefix_halt program (encodeNat N++rest) s (t+s) (by omega) g (by simpa [hg] using h) + rw [hg] at hp + have hh := (hr s g).1.mp (by rw [hp]; exact h) + obtain ⟨u,hu⟩ := IntegerDraw.stack_safe (IntegerDraw.rawMaximum N) + (fun i => g (Fin.natAdd t i)) hh + refine ⟨⟨u,by simpa using u.isLt⟩,?_⟩ + rw [← hp,(hr s g).2] + exact hu + +end +end Contingency.BitModel.StackCode.EncodedInteger + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.EncodedInteger +noncomputable section + +def machine : Machine := compile program + +theorem stack_summable (N : ℕ) (rest : List Bool) : + Summable (tail program (encodeNat N++rest)) := by + obtain ⟨t,ht,hl⟩ := shifted_laws N rest + apply (summable_nat_add_iff t).1 + simpa only [Nat.add_comm, (hl _).2] using + IntegerDraw.stack_summable (IntegerDraw.rawMaximum N) + +theorem stack_expected (N : ℕ) (rest : List Bool) : + (∑' s,tail program (encodeNat N++rest) s)≤35*(N.size:ℝ)+21 := by + obtain ⟨t,ht,hl⟩ := shifted_laws N rest + have hs := stack_summable N rest + rw [← hs.sum_add_tsum_nat_add t] + have hb : (∑ s∈Finset.range t,tail program (encodeNat N++rest) s)≤(t:ℝ) := by + calc + _ ≤ ∑ s∈Finset.range t,(1:ℝ) := by + exact Finset.sum_le_sum fun _ _ => IntegerDraw.tail_le_one _ _ _ + _ = _ := by simp + have he : (∑' s,tail program (encodeNat N++rest) (s+t))= + ∑' s,tail IntegerDraw.program (IntegerDraw.rawMaximum N) s := by + congr 1 + funext s + simpa only [Nat.add_comm] using (hl s).2 + rw [he] + have hw : 2^(IntegerDraw.rawMaximum N).length≤ + 2*(BinaryTrial.beValue (IntegerDraw.rawMaximum N)+1) := by + simpa using IntegerDraw.minimal_width N + have hi := IntegerDraw.stack_linear_expected (IntegerDraw.rawMaximum N) hw + simp only [IntegerDraw.rawMaximum_length] at hi + have ht' : (t:ℝ)≤9*(N.size:ℝ)+6 := by exact_mod_cast ht + push_cast at hi + linarith + +theorem stack_uniform (N : ℕ) (rest : List Bool) (u : Fin (N+1)) : + Tendsto (mass program (encodeNat N++rest) (IntegerDraw.integerWord N u)) + atTop (nhds (1/(N+1:ℝ))) := by + obtain ⟨t,ht,hl⟩ := shifted_laws N rest + apply (tendsto_add_atTop_iff_nat t).1 + have he : (fun s => mass program (encodeNat N++rest) (IntegerDraw.integerWord N u) (s+t))= + mass IntegerDraw.program (IntegerDraw.rawMaximum N) (IntegerDraw.integerWord N u) := by + funext s + simpa only [Nat.add_comm] using (hl s).1 (IntegerDraw.integerWord N u) + rw [he] + simpa only [IntegerDraw.rawMaximum_value,IntegerDraw.integerWord] using + IntegerDraw.stack_uniform (IntegerDraw.rawMaximum N) ⟨u,by simpa using u.isLt⟩ + + + +theorem integer_sampler (N : ℕ) (rest : List Bool) : + (∀ (t : ℕ) (coins : Fin t→Bool),(machine.run (encodeNat N++rest) coins).state=none → + ∃ u : Fin (N+1),(machine.run (encodeNat N++rest) coins).outputRev.reverse=IntegerDraw.integerWord N u) ∧ + Tendsto (machine.tail (encodeNat N++rest)) atTop (nhds 0) ∧ + (∀ u : Fin (N+1),Tendsto (machine.mass (encodeNat N++rest) (IntegerDraw.integerWord N u)) + atTop (nhds (1/(N+1:ℝ)))) ∧ + Summable (machine.tail (encodeNat N++rest)) ∧ + (∑' t,machine.tail (encodeNat N++rest) t)≤70*(N.size:ℝ)+42 := by + have hs := tail_summable_compile program (encodeNat N++rest) (stack_summable N rest) + refine ⟨?_,hs.tendsto_atTop_zero,?_,hs,?_⟩ + · exact safe_compile program (encodeNat N++rest) + (fun out => ∃ u : Fin (N+1),out=IntegerDraw.integerWord N u) + (fun _ f h => stack_safe N rest f h) + · intro u + exact mass_limit_compile program (encodeNat N++rest) (IntegerDraw.integerWord N u) _ + (stack_uniform N rest u) + · rw [machine,expected_compile program (encodeNat N++rest) (stack_summable N rest)] + linarith [stack_expected N rest] + +end +end Contingency.BitModel.StackCode.EncodedInteger + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/PieceQuantiles.lean b/lean/OAI/Probability/Contingency/PieceQuantiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..38c904d489c474664870881a8cc8945c560424cc --- /dev/null +++ b/lean/OAI/Probability/Contingency/PieceQuantiles.lean @@ -0,0 +1,654 @@ +import Mathlib +import OAI.Probability.Contingency.DenseRegularity + +namespace OAI + +/-! Piece Quantiles. -/ + +noncomputable section + +open Set MeasureTheory Filter +open scoped BigOperators Topology +open Set MeasureTheory Filter +open scoped BigOperators Topology +namespace Contingency.Interpolation +noncomputable section + + + +structure SourcePieces (n : ℕ) where + lo : Fin n → ℝ + hi : Fin n → ℝ + lt : ∀ i,lo i < hi i + ordered : ∀ i j,i < j → hi i ≤ lo j + f : Fin n → ℝ → ℝ + continuous : ∀ i,ContinuousOn (f i) (Icc (lo i) (hi i)) + positive : ∀ i x,x∈Icc (lo i) (hi i) → 0 < f i x + +namespace SourcePieces +variable {n : ℕ} + +def mass (P : SourcePieces n) (i : Fin n) : ℝ := ∫ x in P.lo i..P.hi i,P.f i x + +def total (P : SourcePieces n) : ℝ := totalMass P.mass + +theorem mass_pos (P : SourcePieces n) (i : Fin n) : 0 < P.mass i := + intervalIntegral.integral_pos (P.lt i) (P.continuous i) + (fun x hx => (P.positive i x (Ioc_subset_Icc_self hx)).le) + ⟨P.lo i,left_mem_Icc.mpr (P.lt i).le,P.positive i _ (left_mem_Icc.mpr (P.lt i).le)⟩ + +theorem total_pos (P : SourcePieces n) (hn : 0 < n) : 0 < P.total := by + dsimp [total,totalMass] + apply Finset.sum_pos (fun i _ => P.mass_pos i) + exact ⟨⟨0,hn⟩,Finset.mem_univ _⟩ + +def good (P : SourcePieces n) : Set ℝ := ⋃ i,probabilityPiece P.mass i + +theorem good_measurable (P : SourcePieces n) : MeasurableSet P.good := + MeasurableSet.iUnion fun _ => measurableSet_Ioo + +theorem good_subset (P : SourcePieces n) (hn : 0 < n) : P.good ⊆ Ioo 0 1 := by + intro t ht + obtain ⟨i,hi⟩ := mem_iUnion.mp ht + exact probabilityPiece_subset P.mass (fun i => (P.mass_pos i).le) (P.total_pos hn) i hi + +theorem good_volume (P : SourcePieces n) (hn : 0 < n) : volume P.good=1 := + probabilityPieces_volume P.mass (fun i => (P.mass_pos i).le) (P.total_pos hn) + +theorem good_ae (P : SourcePieces n) (hn : 0 < n) : P.good =ᵐ[volume] Ioo (0:ℝ) 1 := by + apply ae_eq_of_subset_of_measure_ge (P.good_subset hn) + · rw [P.good_volume hn]; simp + · exact P.good_measurable.nullMeasurableSet + · simp + + +theorem local_quantiles (P : SourcePieces n) (hn : 0 < n) : + ∃ Q : Fin n → ℝ → ℝ, + (∀ i,StrictMonoOn (Q i) (probabilityPiece P.mass i)) ∧ + ∀ i t,t∈probabilityPiece P.mass i → Q i t∈Ioo (P.lo i) (P.hi i) ∧ + HasDerivAt (Q i) (P.total/P.f i (Q i t)) t := by + have hM := P.total_pos hn + have hq (i) := positive_quantile (P.f i) (P.lo i) (P.hi i) (P.lt i) (P.continuous i) (P.positive i) + choose hmi Q hmQ himQ hdQ using hq + let A := fun (i : Fin n) (t : ℝ) => (P.total*t-prefixMass P.mass i)/P.mass i + have hA (i t) (ht : t∈probabilityPiece P.mass i) : A i t∈Ioo 0 1 := by + have h1 := (div_lt_iff₀ hM).mp ht.1 + have h2 := (lt_div_iff₀ hM).mp ht.2 + dsimp [A] + constructor + · apply div_pos _ (P.mass_pos i); nlinarith only [h1] + · apply (div_lt_one (P.mass_pos i)).mpr; nlinarith only [h2] + refine ⟨fun i t => Q i (A i t),fun i => ?_,fun i t ht => ?_⟩ + · intro t ht s hs hts + apply hmQ i (hA i t ht) (hA i s hs) + apply (div_lt_div_iff_of_pos_right (P.mass_pos i)).mpr + have := mul_lt_mul_of_pos_left hts hM + linarith + · have hh := hdQ i (A i t) (hA i t ht) + refine ⟨hh.1,?_⟩ + have hAd : HasDerivAt (A i) (P.total/P.mass i) t := by + simpa only [A,mul_one,id_eq] using (((hasDerivAt_id t).const_mul P.total).sub_const (prefixMass P.mass i)).div_const (P.mass i) + have hder := hh.2.comp t hAd + apply hder.congr_deriv + change P.mass i / P.f i (Q i (A i t)) * (P.total / P.mass i) = P.total / P.f i (Q i (A i t)) + field_simp [(P.mass_pos i).ne'] + + + +theorem quantile (P : SourcePieces n) (hn : 0 < n) : + ∃ Q V : ℝ → ℝ, + StrictMonoOn Q P.good ∧ + ∀ t∈P.good, 0 < V t ∧ HasDerivAt Q (P.total/V t) t ∧ + ∃ i,Q t∈Ioo (P.lo i) (P.hi i) ∧ V t=P.f i (Q t) := by + classical + obtain ⟨qi,hmi,hdi⟩ := P.local_quantiles hn + let idx := fun t => if h : ∃ i,t∈probabilityPiece P.mass i then h.choose else ⟨0,hn⟩ + let Q := fun t => qi (idx t) t + let V := fun t => P.f (idx t) (Q t) + have hind (t i) (ht : t∈probabilityPiece P.mass i) : idx t=i := by + dsimp [idx] + have he : ∃ i,t∈probabilityPiece P.mass i := ⟨i,ht⟩ + rw [dite_eq_left he] + by_contra hne + have hdis := probabilityPiece_disjoint P.mass (fun i => (P.mass_pos i).le) (P.total_pos hn) hne + exact disjoint_left.mp hdis he.choose_spec ht + have hin (t) (ht : t∈P.good) : t∈probabilityPiece P.mass (idx t) := by + obtain ⟨i,hi⟩ := mem_iUnion.mp ht + rw [hind t i hi] + exact hi + have hQ (i t) (ht : t∈probabilityPiece P.mass i) : Q t=qi i t := by + dsimp [Q]; rw [hind t i ht] + refine ⟨Q,V,?_,fun t ht => ?_⟩ + · intro t ht s hs hts + have hit := hin t ht + have his := hin s hs + have hti := (hdi _ _ hit).1 + have hsi := (hdi _ _ his).1 + change qi (idx t) t < qi (idx s) s + rcases lt_trichotomy (idx t) (idx s) with hlt|heq|hgt + · exact hti.2.trans_le ((P.ordered _ _ hlt).trans hsi.1.le) + · rw [heq] at hit ⊢ + exact hmi _ hit his hts + · have hh := div_le_div_of_nonneg_right + (prefix_next_le P.mass (fun i => (P.mass_pos i).le) (idx s) (idx t) hgt) (P.total_pos hn).le + exact False.elim (not_lt_of_ge (his.2.le.trans (hh.trans hit.1.le)) hts) + · have hi := hin t ht + have hh := hdi _ _ hi + refine ⟨P.positive _ _ (Ioo_subset_Icc_self hh.1),?_,idx t,hh.1,rfl⟩ + have hevent : Q =ᶠ[𝓝 t] qi (idx t) := by + filter_upwards [isOpen_Ioo.mem_nhds hi] with u hu + exact hQ _ _ hu + exact hh.2.congr_of_eventuallyEq hevent + +end SourcePieces +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory +namespace Contingency.Interpolation +noncomputable section +variable {q : ℕ} + +theorem slices_constant (S : Finset (OpenBox (q+1))) (l x y : ℝ) + (hx : x∈Ioo l (nextEndpoint (endpoints S) l)) + (hy : y∈Ioo l (nextEndpoint (endpoints S) l)) : slices S x=slices S y := by + classical + unfold slices + congr 1 + ext B + simp only [Finset.mem_filter] + by_cases hB : B∈S + · have h1 := endpoint_comparisons (endpoints S) l x y (B.lower 0) hx hy (lower_mem_endpoints S B hB) + have h2 := endpoint_comparisons (endpoints S) l x y (B.upper 0) hx hy (upper_mem_endpoints S B hB) + simp only [hB,true_and,h1.1,h2.2] + · simp [hB] + +def activeEndpoints (S : Finset (OpenBox (q+1))) : Finset ℝ := by + classical + exact (endpoints S).filter fun l => + ∃ x∈Ioo l (nextEndpoint (endpoints S) l),(boxUnion (slices S x)).Nonempty + +theorem activeEndpoint_mem (S : Finset (OpenBox (q+1))) (l : ℝ) (hl : l∈activeEndpoints S) : + l∈endpoints S := by + classical + exact (Finset.mem_filter.mp hl).1 + +theorem activeEndpoint_lt (S : Finset (OpenBox (q+1))) (l : ℝ) (hl : l∈activeEndpoints S) : + l dsimp [gridMidpoint] <;> linarith + +theorem activeSlice_nonempty (S : Finset (OpenBox (q+1))) (l : ℝ) (hl : l∈activeEndpoints S) : + (boxUnion (slices S (gridMidpoint S l))).Nonempty := by + classical + obtain ⟨x,hx,hs⟩ := (Finset.mem_filter.mp hl).2 + rw [← slices_constant S l x (gridMidpoint S l) hx (midpoint_mem S l hl)] + exact hs + +def gridLower (S : Finset (OpenBox (q+1))) : Fin (activeEndpoints S).card ↪o ℝ := + (activeEndpoints S).orderEmbOfFin rfl + +theorem gridLower_mem (S : Finset (OpenBox (q+1))) (i : Fin (activeEndpoints S).card) : + gridLower S i∈activeEndpoints S := Finset.orderEmbOfFin_mem _ _ _ + +def boxPieces (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) : SourcePieces (activeEndpoints S).card where + lo := gridLower S + hi := fun i => nextEndpoint (endpoints S) (gridLower S i) + lt := fun i => activeEndpoint_lt S _ (gridLower_mem S i) + ordered := fun left right hij => nextEndpoint_le (endpoints S) (gridLower S left) (gridLower S right) + (activeEndpoint_mem S _ (gridLower_mem S right)) ((gridLower S).strictMono hij) + f := fun i x => ∫ y in boxUnion (slices S (gridMidpoint S (gridLower S i))),F.f (Fin.cons x y) + continuous := fun index => (F.marginal_continuous (slices S (gridMidpoint S (gridLower S index)))).continuousOn + positive := fun i x _ => (F.slice x).integral_pos _ (activeSlice_nonempty S _ (gridLower_mem S i)) + +theorem boxPieces_slice (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) + (i : Fin (activeEndpoints S).card) (x : ℝ) + (hx : x∈Ioo ((boxPieces S F).lo i) ((boxPieces S F).hi i)) : + (boxPieces S F).f i x=∫ y in boxUnion (slices S x),F.f (Fin.cons x y) := by + change (∫ y in boxUnion (slices S (gridMidpoint S (gridLower S i))),F.f (Fin.cons x y))=_ + rw [slices_constant S (gridLower S i) _ x (midpoint_mem S _ (gridLower_mem S i)) hx] + +theorem boxPieces_cover (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) (x : ℝ) + (hx : x∉endpoints S) (hs : (boxUnion (slices S x)).Nonempty) : + ∃ i,x∈Ioo ((boxPieces S F).lo i) ((boxPieces S F).hi i) := by + classical + obtain ⟨y,hy⟩ := hs + obtain ⟨B,hB,hBy⟩ := (mem_boxUnion S (Fin.cons x y)).mp ((mem_slices S x y).mp hy) + have hxB := hBy 0 + simp only [Fin.cons_zero] at hxB + obtain ⟨l,hl,hxl⟩ := grid_covers (endpoints S) x _ _ + (lower_mem_endpoints S B hB) (upper_mem_endpoints S B hB) hxB.1 hxB.2 hx + have hlA : l∈activeEndpoints S := Finset.mem_filter.mpr ⟨hl,x,hxl,y,hy⟩ + have hr : Set.range (gridLower S)=(activeEndpoints S : Set ℝ) := Finset.range_orderEmbOfFin _ _ + have hrl : l∈Set.range (gridLower S) := by rw [hr]; exact hlA + obtain ⟨i,hi⟩ := hrl + refine ⟨i,?_⟩ + change x∈Ioo (gridLower S i) (nextEndpoint (endpoints S) (gridLower S i)) + rw [hi] + exact hxl + +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory +open scoped BigOperators +namespace Contingency.Interpolation.SourcePieces +noncomputable section +variable {n : ℕ} + +def source (P : SourcePieces n) (x : ℝ) : ℝ := + ∑ i,(Ioo (P.lo i) (P.hi i)).indicator (P.f i) x + +theorem support_disjoint (P : SourcePieces n) : + Pairwise (fun i j => Disjoint (Ioo (P.lo i) (P.hi i)) (Ioo (P.lo j) (P.hi j))) := by + intro i j hij + rcases lt_or_gt_of_ne hij with hh|hh + · exact Set.disjoint_left.mpr fun x hx hy => not_lt_of_ge (hx.2.le.trans (P.ordered i j hh)) hy.1 + · exact Set.disjoint_left.mpr fun x hx hy => not_lt_of_ge (hy.2.le.trans (P.ordered j i hh)) hx.1 + +theorem source_on (P : SourcePieces n) (i : Fin n) (x : ℝ) (hx : x∈Ioo (P.lo i) (P.hi i)) : + P.source x=P.f i x := by + classical + rw [source,Finset.sum_eq_single i] + · exact Set.indicator_of_mem hx _ + · intro j _ hji + apply Set.indicator_of_notMem + intro hj + exact Set.disjoint_left.mp (P.support_disjoint hji) hj hx + · simp + +theorem source_off (P : SourcePieces n) (x : ℝ) (hx : ∀ i,x∉Ioo (P.lo i) (P.hi i)) : + P.source x=0 := by simp [source,hx] + +theorem piece_integrable (P : SourcePieces n) (i : Fin n) : + IntegrableOn (P.f i) (Ioo (P.lo i) (P.hi i)) := + ((P.continuous i).integrableOn_compact isCompact_Icc).mono_set Ioo_subset_Icc_self + +theorem source_integrable (P : SourcePieces n) : Integrable P.source := + integrable_finsetSum _ fun i _ => (P.piece_integrable i).integrable_indicator measurableSet_Ioo + +theorem source_integral (P : SourcePieces n) : (∫ x,P.source x)=P.total := by + dsimp only [source,total,totalMass] + rw [integral_finsetSum] + · apply Finset.sum_congr rfl + intro i _ + rw [integral_indicator measurableSet_Ioo,← integral_Ioc_eq_integral_Ioo, + ← intervalIntegral.integral_of_le (P.lt i).le] + rfl + · intro i _ + exact (P.piece_integrable i).integrable_indicator measurableSet_Ioo + +end +end Contingency.Interpolation.SourcePieces + + + + + +open Set MeasureTheory +namespace Contingency.Interpolation +noncomputable section +variable {q : ℕ} + + + +theorem boxPieces_source_eq (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) (x : ℝ) + (hx : x∉endpoints S) : (boxPieces S F).source x=marginal S F x := by + classical + by_cases hs : (boxUnion (slices S x)).Nonempty + · obtain ⟨i,hi⟩ := boxPieces_cover S F x hx hs + rw [(boxPieces S F).source_on i x hi,boxPieces_slice S F i x hi] + rfl + · have hzero : marginal S F x=0 := by + rw [marginal,Set.not_nonempty_iff_eq_empty.mp hs] + simp + rw [hzero] + apply SourcePieces.source_off + intro i hi + have hne := activeSlice_nonempty S _ (gridLower_mem S i) + rw [slices_constant S (gridLower S i) _ x (midpoint_mem S _ (gridLower_mem S i)) hi] at hne + exact hs hne + +theorem boxPieces_source_ae (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) : + (boxPieces S F).source =ᵐ[volume] marginal S F := by + filter_upwards [(endpoints S).finite_toSet.countable.ae_notMem volume] with x hx + exact boxPieces_source_eq S F x hx + + + +theorem boxPieces_total (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) : + (boxPieces S F).total=∫ z in boxUnion S,F.f z := by + rw [← SourcePieces.source_integral,integral_congr_ae (boxPieces_source_ae S F)] + exact (marginal_fubini S F).2 + +theorem activeEndpoints_nonempty (S : Finset (OpenBox (q+1))) (F : GoodWeight (q+1)) + (hs : (boxUnion S).Nonempty) : 0 < (activeEndpoints S).card := by + by_contra hh + have he : (activeEndpoints S).card=0 := Nat.eq_zero_of_not_pos hh + have hm : (boxPieces S F).total=0 := by + dsimp [SourcePieces.total,totalMass] + have : IsEmpty (Fin (activeEndpoints S).card) := he ▸ inferInstanceAs (IsEmpty (Fin 0)) + exact Finset.sum_eq_zero fun i _ => isEmptyElim i + rw [boxPieces_total S F] at hm + exact (F.integral_pos S hs).ne' hm + +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory Filter +open scoped Topology +namespace Contingency.Interpolation +noncomputable section + + + +theorem piece_interpolation {n m : ℕ} (P : SourcePieces n) (Q : SourcePieces m) + (hn : 0 < n) (hm : 0 < m) (H : ℝ → ℝ) (S : Set ℝ) + (α β : ℝ) (ha : 0 < α) (hb : 0 < β) (hsum : α+β=1) + (hS : MeasurableSet S) (hH : IntegrableOn H S) (hpH : ∀ x∈S,0 ≤ H x) + (hmem : ∀ i x,x∈Ioo (P.lo i) (P.hi i) → + ∀ j y,y∈Ioo (Q.lo j) (Q.hi j) → α*x+β*y∈S) + (hcomp : ∀ i x,x∈Ioo (P.lo i) (P.hi i) → + ∀ j y,y∈Ioo (Q.lo j) (Q.hi j) → P.f i x^α*Q.f j y^β ≤ H (α*x+β*y)) : + P.total^α*Q.total^β ≤ ∫ x in S,H x := by + obtain ⟨U,F,hu,hud⟩ := P.quantile hn + obtain ⟨V,G,hv,hvd⟩ := Q.quantile hm + let D := P.good ∩ Q.good + have hD : MeasurableSet D := P.good_measurable.inter Q.good_measurable + have hdae : D =ᵐ[volume] Ioo (0:ℝ) 1 := by + filter_upwards [P.good_ae hn,Q.good_ae hm] with x hx hy + change (x∈P.good) = (x∈Ioo (0:ℝ) 1) at hx + change (x∈Q.good) = (x∈Ioo (0:ℝ) 1) at hy + change (x∈P.good ∧ x∈Q.good) = (x∈Ioo (0:ℝ) 1) + rw [hx,hy]; simp + have hdvol : volume D=1 := by rw [measure_congr hdae]; simp + let z := fun t => α*U t+β*V t + let z' := fun t => α*(P.total/F t)+β*(Q.total/G t) + have hz : StrictMonoOn z D := by + intro x hx y hy hxy + exact add_lt_add (mul_lt_mul_of_pos_left (hu hx.1 hy.1 hxy) ha) + (mul_lt_mul_of_pos_left (hv hx.2 hy.2 hxy) hb) + have hzder (t) (ht : t∈D) : HasDerivAt z (z' t) t := by + exact ((hud t ht.1).2.1.const_mul α).add ((hvd t ht.2).2.1.const_mul β) + have hzpos (t) (ht : t∈D) : 0 < z' t := + add_pos (mul_pos ha (div_pos (P.total_pos hn) (hud t ht.1).1)) + (mul_pos hb (div_pos (Q.total_pos hm) (hvd t ht.2).1)) + have hsub : z '' D ⊆ S := by + rintro _ ⟨t,ht,rfl⟩ + obtain ⟨i,hi,_⟩ := (hud t ht.1).2.2 + obtain ⟨j,hj,_⟩ := (hvd t ht.2).2.2 + exact hmem i _ hi j _ hj + have hzwi (t) (ht : t∈D) : HasDerivWithinAt z (z' t) D t := + (hzder t ht).hasDerivWithinAt + have hjint := (integrableOn_image_iff_integrableOn_abs_deriv_smul hD hzwi hz.injOn H).mp (hH.mono_set hsub) + have heq := integral_image_eq_integral_abs_deriv_smul hD hzwi hz.injOn H + have hecomp (t) (ht : t∈D) : P.total^α*Q.total^β ≤ |z' t| • H (z t) := by + rw [smul_eq_mul,abs_of_pos (hzpos t ht)] + obtain ⟨i,hi,hFi⟩ := (hud t ht.1).2.2 + obtain ⟨j,hj,hGj⟩ := (hvd t ht.2).2.2 + have h1 := transport_amgm P.total Q.total (F t) (G t) α β + (P.total_pos hn) (Q.total_pos hm) (hud t ht.1).1 (hvd t ht.2).1 ha.le hb.le hsum + have h2 := mul_le_mul_of_nonneg_left (hcomp i _ hi j _ hj) (hzpos t ht).le + rw [← hFi,← hGj] at h2 + dsimp [z,z'] at * + nlinarith only [h1,h2] + have hinter : (∫ t in D,P.total^α*Q.total^β) ≤ ∫ t in D,|z' t| • H (z t) := by + exact setIntegral_mono_on (integrableOn_const (by rw [hdvol]; exact ENNReal.one_ne_top)) hjint hD hecomp + have hcint : (∫ t in D,P.total^α*Q.total^β)=P.total^α*Q.total^β := by + simp [Measure.real,hdvol] + rw [hcint,← heq] at hinter + exact hinter.trans (setIntegral_mono_set hH (by + filter_upwards [ae_restrict_mem hS] with x hx + exact hpH x hx) hsub.eventuallyLE) + +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory +open scoped Pointwise +namespace Contingency.Interpolation +noncomputable section + + +theorem cons_interpolation {q : ℕ} (α β x y : ℝ) (u v : Fin q → ℝ) : + α • Fin.cons x u+β • Fin.cons y v=Fin.cons (α*x+β*y) (α • u+β • v) := by + funext i + refine Fin.cases ?_ (fun j => ?_) i <;> simp + + + +theorem good_box_interpolation (q : ℕ) (S₁ S₂ S₀ : Finset (OpenBox q)) + (F₁ F₂ F₀ : GoodWeight q) (α β : ℝ) (ha : 0<α) (hb : 0<β) (hsum : α+β=1) + (hmem : ∀ x∈boxUnion S₁,∀ y∈boxUnion S₂,α • x+β • y∈boxUnion S₀) + (hcomp : ∀ x∈boxUnion S₁,∀ y∈boxUnion S₂,F₁.f x^α*F₂.f y^β ≤ F₀.f (α • x+β • y)) : + (∫ x in boxUnion S₁,F₁.f x)^α*(∫ x in boxUnion S₂,F₂.f x)^β ≤ ∫ x in boxUnion S₀,F₀.f x := by + induction q with + | zero => + by_cases h₁ : (boxUnion S₁).Nonempty + · by_cases h₂ : (boxUnion S₂).Nonempty + · obtain ⟨x,hx⟩ := h₁ + obtain ⟨y,hy⟩ := h₂ + have hint (S : Finset (OpenBox 0)) (F : GoodWeight 0) (z : Fin 0 → ℝ) (hz : z∈boxUnion S) : + (∫ w in boxUnion S,F.f w)=F.f z := by + rw [← integral_indicator (boxUnion_measurable S),Measure.volume_pi_eq_dirac z,integral_dirac] + exact Set.indicator_of_mem hz _ + rw [hint S₁ F₁ x hx,hint S₂ F₂ y hy,hint S₀ F₀ _ (hmem x hx y hy)] + exact hcomp x hx y hy + · rw [Set.not_nonempty_iff_eq_empty.mp h₂] + simp only [setIntegral_empty,Real.zero_rpow hb.ne',mul_zero] + exact F₀.integral_nonneg S₀ + · rw [Set.not_nonempty_iff_eq_empty.mp h₁] + simp only [setIntegral_empty,Real.zero_rpow ha.ne',zero_mul] + exact F₀.integral_nonneg S₀ + | succ q ih => + by_cases h₁ : (boxUnion S₁).Nonempty + · by_cases h₂ : (boxUnion S₂).Nonempty + · have hinter := piece_interpolation (boxPieces S₁ F₁) (boxPieces S₂ F₂) + (activeEndpoints_nonempty S₁ F₁ h₁) (activeEndpoints_nonempty S₂ F₂ h₂) + (marginal S₀ F₀) univ α β ha hb hsum MeasurableSet.univ + (integrableOn_univ.mpr (marginal_fubini S₀ F₀).1) + (fun x _ => marginal_nonneg S₀ F₀ x) (fun _ _ _ _ _ _ => mem_univ _) (by + intro i x hx j y hy + rw [boxPieces_slice S₁ F₁ i x hx,boxPieces_slice S₂ F₂ j y hy] + apply ih (slices S₁ x) (slices S₂ y) (slices S₀ (α*x+β*y)) + (F₁.slice x) (F₂.slice y) (F₀.slice (α*x+β*y)) + · intro u hu v hv + apply (mem_slices S₀ _ _).mpr + rw [← cons_interpolation] + exact hmem _ ((mem_slices S₁ x u).mp hu) _ ((mem_slices S₂ y v).mp hv) + · intro u hu v hv + have hh := hcomp _ ((mem_slices S₁ x u).mp hu) _ ((mem_slices S₂ y v).mp hv) + rw [cons_interpolation] at hh + exact hh) + simpa only [boxPieces_total,setIntegral_univ,(marginal_fubini S₀ F₀).2] using hinter + · rw [Set.not_nonempty_iff_eq_empty.mp h₂] + simp only [setIntegral_empty,Real.zero_rpow hb.ne',mul_zero] + exact F₀.integral_nonneg S₀ + · rw [Set.not_nonempty_iff_eq_empty.mp h₁] + simp only [setIntegral_empty,Real.zero_rpow ha.ne',zero_mul] + exact F₀.integral_nonneg S₀ + +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory +open scoped Pointwise +namespace Contingency.Interpolation +noncomputable section +variable {q : ℕ} + +def clampBox (l u x : Fin q → ℝ) : Fin q → ℝ := fun i => max (l i) (min (u i) (x i)) + +theorem clampBox_mem (l u : Fin q → ℝ) (hle : l ≤ u) (x : Fin q → ℝ) : + clampBox l u x∈Icc l u := by + constructor + · intro i; exact le_max_left _ _ + · intro i; exact max_le (hle i) (min_le_left _ _) + +theorem clampBox_eq (l u x : Fin q → ℝ) (hx : x∈Icc l u) : clampBox l u x=x := by + funext i + exact (congrArg (max (l i)) (min_eq_right (hx.2 i))).trans (max_eq_right (hx.1 i)) + +theorem clampBox_continuous (l u : Fin q → ℝ) : Continuous (clampBox l u) := + continuous_pi fun i => continuous_const.max (continuous_const.min (continuous_apply i)) + + + +theorem good_extension (l u : Fin q → ℝ) (hle : l ≤ u) (f : (Fin q → ℝ) → ℝ) + (hc : ContinuousOn f (Icc l u)) (hp : ∀ x∈Icc l u,0 f (clampBox l u x),?_,?_,C,?_⟩,?_⟩ + · exact hc.comp_continuous (clampBox_continuous l u) (clampBox_mem l u hle) + · intro x; exact hp _ (clampBox_mem l u hle x) + · intro x; exact hC ⟨clampBox l u x,clampBox_mem l u hle x,rfl⟩ + · intro x hx; exact congrArg f (clampBox_eq l u x hx) + + + +theorem finiteBoxInterpolation : FiniteBoxInterpolation := by + intro q S₁ S₂ S₀ t ht ht1 l u hbox f₁ f₂ f₀ hc₁ hc₂ hc₀ hp hmem hcomp + have hsub₁ : boxUnion S₁ ⊆ Icc l u := fun x hx => hbox (subset_closure (Or.inl (Or.inl hx))) + have hsub₂ : boxUnion S₂ ⊆ Icc l u := fun x hx => hbox (subset_closure (Or.inl (Or.inr hx))) + have hsub₀ : boxUnion S₀ ⊆ Icc l u := fun x hx => hbox (subset_closure (Or.inr hx)) + have hnon : 0 ≤ ∫ x in boxUnion S₀,f₀ x := + setIntegral_nonneg (boxUnion_measurable _) (fun x hx => (hp x (hsub₀ hx)).2.2.le) + by_cases h₁ : (boxUnion S₁).Nonempty + · by_cases h₂ : (boxUnion S₂).Nonempty + · obtain ⟨z,hz⟩ := h₁ + have hlu : l ≤ u := (hsub₁ hz).1.trans (hsub₁ hz).2 + obtain ⟨F₁,he₁⟩ := good_extension l u hlu f₁ hc₁ (fun x hx => (hp x hx).1) + obtain ⟨F₂,he₂⟩ := good_extension l u hlu f₂ hc₂ (fun x hx => (hp x hx).2.1) + obtain ⟨F₀,he₀⟩ := good_extension l u hlu f₀ hc₀ (fun x hx => (hp x hx).2.2) + have hinter := good_box_interpolation q S₁ S₂ S₀ F₁ F₂ F₀ (1-t) t (by linarith) ht (by ring) hmem (by + intro x hx y hy + rw [he₁ x (hsub₁ hx),he₂ y (hsub₂ hy),he₀ _ (hsub₀ (hmem x hx y hy))] + exact hcomp x hx y hy) + have hi₁ : (∫ x in boxUnion S₁,F₁.f x)=∫ x in boxUnion S₁,f₁ x := + setIntegral_congr_fun (boxUnion_measurable _) (fun x hx => he₁ x (hsub₁ hx)) + have hi₂ : (∫ x in boxUnion S₂,F₂.f x)=∫ x in boxUnion S₂,f₂ x := + setIntegral_congr_fun (boxUnion_measurable _) (fun x hx => he₂ x (hsub₂ hx)) + have hi₀ : (∫ x in boxUnion S₀,F₀.f x)=∫ x in boxUnion S₀,f₀ x := + setIntegral_congr_fun (boxUnion_measurable _) (fun x hx => he₀ x (hsub₀ hx)) + rwa [hi₁,hi₂,hi₀] at hinter + · rw [Set.not_nonempty_iff_eq_empty.mp h₂] + simpa only [setIntegral_empty,Real.zero_rpow ht.ne',mul_zero] using hnon + · rw [Set.not_nonempty_iff_eq_empty.mp h₁] + simpa only [setIntegral_empty,Real.zero_rpow (show 1-t ≠ 0 by linarith),zero_mul] using hnon + +end +end Contingency.Interpolation + + + + + +open Set MeasureTheory +open scoped Pointwise +namespace Contingency.Interpolation +noncomputable section +variable {q : ℕ} + +def OpenBox.proper (B : OpenBox q) : Prop := ∀ i,B.lower i α*B.lower i+β*C.lower i,fun i => α*B.upper i+β*C.upper i⟩ + +theorem OpenBox.proper_of_mem (B : OpenBox q) (x : Fin q → ℝ) (hx : x∈B.carrier) : B.proper := + fun i => (hx i (mem_univ i)).1.trans (hx i (mem_univ i)).2 + +theorem interval_mix (l u l' u' z α β : ℝ) (hlu : l hx i,y,fun i _ => hy i,funext he⟩ + · rintro ⟨x,hx,y,hy,rfl⟩ + intro i _ + exact ⟨add_lt_add (mul_lt_mul_of_pos_left (hx i (mem_univ i)).1 ha) + (mul_lt_mul_of_pos_left (hy i (mem_univ i)).1 hb), + add_lt_add (mul_lt_mul_of_pos_left (hx i (mem_univ i)).2 ha) + (mul_lt_mul_of_pos_left (hy i (mem_univ i)).2 hb)⟩ + +def mixBoxes (S T : Finset (OpenBox q)) (α β : ℝ) : Finset (OpenBox q) := by + classical + exact ((S.filter OpenBox.proper) ×ˢ (T.filter OpenBox.proper)).image fun p => p.1.mix p.2 α β + +theorem mem_mixBoxes (S T : Finset (OpenBox q)) (α β : ℝ) (ha : 0<α) (hb : 0<β) (z : Fin q → ℝ) : + z∈boxUnion (mixBoxes S T α β) ↔ ∃ x∈boxUnion S,∃ y∈boxUnion T,α • x+β • y=z := by + classical + simp only [boxUnion,mem_iUnion,mixBoxes,Finset.mem_image,Finset.mem_product,Finset.mem_filter] + constructor + · rintro ⟨B,⟨⟨B₁,B₂⟩,⟨⟨h₁,hp₁⟩,⟨h₂,hp₂⟩⟩,rfl⟩,hz⟩ + obtain ⟨x,hx,y,hy,he⟩ := (B₁.mem_mix_iff B₂ hp₁ hp₂ α β ha hb z).mp hz + exact ⟨x,⟨B₁,h₁,hx⟩,y,⟨B₂,h₂,hy⟩,he⟩ + · rintro ⟨x,⟨B₁,h₁,hx⟩,y,⟨B₂,h₂,hy⟩,he⟩ + refine ⟨B₁.mix B₂ α β,⟨(B₁,B₂),⟨⟨h₁,B₁.proper_of_mem x hx⟩,⟨h₂,B₂.proper_of_mem y hy⟩⟩,rfl⟩,?_⟩ + exact (B₁.mem_mix_iff B₂ (B₁.proper_of_mem x hx) (B₂.proper_of_mem y hy) α β ha hb z).mpr ⟨x,hx,y,hy,he⟩ + + +theorem logconcave_interpolation (S T : Finset (OpenBox q)) (F : GoodWeight q) + (α β : ℝ) (ha : 0<α) (hb : 0<β) (hab : α+β=1) + (hc : ∀ x y,F.f x^α*F.f y^β ≤ F.f (α • x+β • y)) : + (∫ x in boxUnion S,F.f x)^α*(∫ x in boxUnion T,F.f x)^β ≤ + ∫ x in boxUnion (mixBoxes S T α β),F.f x := by + apply good_box_interpolation q S T (mixBoxes S T α β) F F F α β ha hb hab + · intro x hx y hy + exact (mem_mixBoxes S T α β ha hb _).mpr ⟨x,hx,y,hy,rfl⟩ + · intro x _ y _; exact hc x y + +end +end Contingency.Interpolation + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/PreparedResidual.lean b/lean/OAI/Probability/Contingency/PreparedResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..10fd955962e348213bb44323b5f22fda85117e8b --- /dev/null +++ b/lean/OAI/Probability/Contingency/PreparedResidual.lean @@ -0,0 +1,563 @@ +import Mathlib +import OAI.Probability.Contingency.WeightedSampler + +namespace OAI + +/-! Prepared Residual. -/ + +noncomputable section + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +noncomputable section + +def groupMass (N : ℕ) (ws : List (List Bool)) (rest : List Bool) (j s : ℕ) : ℝ := + ((Finset.univ.filter fun f : Fin s→Bool => (run draw (encodeNat N++(ws.flatten++rest)) f).state=none ∧ + Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) + (BinarySubtract.value ((run draw (encodeNat N++(ws.flatten++rest)) f).memory.stack 5))=some j).card:ℝ)/2^s + +theorem group_sum (N : ℕ) (ws : List (List Bool)) (rest : List Bool) (j s : ℕ) : + groupMass N ws rest j s=∑ u : Fin (N+1), + if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then + WeightedSampler.storedMass N (ws.flatten++rest) u s else 0 := by + classical + let input := encodeNat N++(ws.flatten++rest) + have point (f : Fin s→Bool) : + (if (run draw input f).state=none ∧ Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) + (BinarySubtract.value ((run draw input f).memory.stack 5))=some j then (1:ℝ) else 0)= + ∑ u : Fin (N+1),if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then + (if (run draw input f).state=none ∧ (run draw input f).memory.stack 5=(IntegerDraw.integerWord N u).reverse then (1:ℝ) else 0) else 0 := by + by_cases hh : (run draw input f).state=none + · obtain ⟨u,hu,h6,h7,hi,ho⟩ := WeightedSampler.first_safe N (ws.flatten++rest) (List.ofFn f) hh + change (run draw input f).memory.stack 5=(IntegerDraw.integerWord N u).reverse at hu + have hv : BinarySubtract.value ((run draw input f).memory.stack 5)=u.val := by + rw [hu,WeightedSampler.reverse_value,IntegerDraw.integerWord_value] + rw [Finset.sum_eq_single u] + · simp only [hh,true_and,hu,ite_true,WeightedSampler.reverse_value,IntegerDraw.integerWord_value] + · intro v _ hne + have hn : (run draw input f).memory.stack 5≠(IntegerDraw.integerWord N v).reverse := by + intro he + have hvu : u.val=v.val := by + have hh' := congrArg (fun bs => BinaryTrial.beValue bs.reverse) (hu.symm.trans he) + simpa using hh' + exact hne (Fin.ext hvu.symm) + simp [hn] + · simp + · simp [hh] + unfold groupMass + simp only [Finset.card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + change (∑ f : Fin s→Bool,if (run draw input f).state=none ∧ _ then (1:ℝ) else 0)/2^s=_ + rw [show (∑ f : Fin s→Bool,if (run draw input f).state=none ∧ Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) (BinarySubtract.value ((run draw input f).memory.stack 5))=some j then (1:ℝ) else 0)=_ from Finset.sum_congr rfl (fun f _ => point f)] + rw [Finset.sum_comm,Finset.sum_div] + apply Finset.sum_congr rfl + intro u _ + by_cases hs : Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j + · simp only [hs,ite_true,WeightedSampler.storedMass,Finset.card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + rfl + · simp [hs] + + +theorem group_limit (N : ℕ) (ws : List (List Bool)) (rest : List Bool) (j : ℕ) + (htotal : WeightedScan.weightTotal ws=N+1) : + Tendsto (groupMass N ws rest j) atTop + (nhds ((Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j:ℝ)/(N+1:ℝ))) := by + classical + have hc : (∑ u : Fin (N+1),if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then (1:ℕ) else 0)= + Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j := by + change (∑ u : Fin (N+1),(fun x : ℕ => if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) x=some j then (1:ℕ) else 0) u.val)=_ + rw [Fin.sum_univ_eq_sum_range (fun x => if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) x=some j then (1:ℕ) else 0) (N+1)] + have ht : Contingency.IntegerDraw.total (WeightedScan.indexedWeights ws 0)=N+1 := + (WeightedScan.indexed_total ws 0).trans htotal + rw [← ht] + exact Contingency.IntegerDraw.scan_count _ _ + have hcr : (∑ u : Fin (N+1),if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then (1:ℝ) else 0)= + (Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j:ℝ) := by exact_mod_cast hc + have he : (∑ u : Fin (N+1),if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then + (1/(N+1:ℝ)) else 0)=(Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j:ℝ)/(N+1:ℝ) := by + rw [← hcr,Finset.sum_div] + apply Finset.sum_congr rfl + intro u _ + split_ifs <;> simp + rw [← he] + have hh := tendsto_finsetSum (Finset.univ : Finset (Fin (N+1))) (fun u _ => + show Tendsto (fun s => if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then + WeightedSampler.storedMass N (ws.flatten++rest) u s else 0) atTop + (nhds (if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then 1/(N+1:ℝ) else 0)) from by + split_ifs + · exact WeightedSampler.stored_uniform N (ws.flatten++rest) u + · exact tendsto_const_nhds) + have heq : groupMass N ws rest j=(fun s => ∑ u : Fin (N+1),if Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j then WeightedSampler.storedMass N (ws.flatten++rest) u s else 0) := by + funext s + exact group_sum N ws rest j s + rw [heq] + exact hh + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +noncomputable section + +theorem mass_upper (N : ℕ) (ws : List (List Bool)) (rest : List Bool) (j s : ℕ) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + mass program (encodeNat N++(ws.flatten++rest)) (List.replicate j false) s ≤ groupMass N ws rest j s := by + classical + unfold mass groupMass + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast Finset.card_le_card (show + (Finset.univ.filter fun f : Fin s→Bool => (run program (encodeNat N++(ws.flatten++rest)) f).state=none ∧ + (run program (encodeNat N++(ws.flatten++rest)) f).memory.outputRev.reverse=List.replicate j false) ⊆ + (Finset.univ.filter fun f : Fin s→Bool => (run draw (encodeNat N++(ws.flatten++rest)) f).state=none ∧ + Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) + (BinarySubtract.value ((run draw (encodeNat N++(ws.flatten++rest)) f).memory.stack 5))=some j) from by + intro f hf + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hf ⊢ + obtain ⟨k,u,hk,hscan,hu,ho⟩ := halted_output N ws rest (List.ofFn f) hlen htotal hf.1 + change (run program (encodeNat N++(ws.flatten++rest)) f).memory.outputRev=List.replicate k false at ho + have hkj : k=j := by + have he := congrArg List.length hf.2 + simpa only [List.length_reverse,ho,List.length_replicate] using he + subst k + refine ⟨first_returned (List.ofFn f) _ hf.1,?_⟩ + change (run draw (encodeNat N++(ws.flatten++rest)) f).memory.stack 5=(IntegerDraw.integerWord N u).reverse at hu + rw [hu,WeightedSampler.reverse_value,IntegerDraw.integerWord_value] + exact hscan) + +theorem mass_lower (N : ℕ) (ws : List (List Bool)) (rest : List Bool) (j s : ℕ) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + groupMass N ws rest j s ≤ mass program (encodeNat N++(ws.flatten++rest)) (List.replicate j false) (s+delay N ws) := by + classical + let e : Fin s→Fin (s+delay N ws) := Fin.castAdd (delay N ws) + have hi : Function.Injective e := by + intro i j h; exact Fin.ext (congrArg (fun k : Fin (s+delay N ws) => k.val) h) + let p : (Fin s→Bool)→Prop := fun f => (run draw (encodeNat N++(ws.flatten++rest)) f).state=none ∧ + Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) + (BinarySubtract.value ((run draw (encodeNat N++(ws.flatten++rest)) f).memory.stack 5))=some j + have he := CoordinateLaw.probability_restrict e hi p + simp only [Fintype.card_fin] at he + unfold groupMass mass + change ((Finset.univ.filter p).card:ℝ)/2^s≤_ + rw [← he] + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast Finset.card_le_card (show + (Finset.univ.filter fun f : Fin (s+delay N ws)→Bool => p (f∘e)) ⊆ + (Finset.univ.filter fun f : Fin (s+delay N ws)→Bool => (run program (encodeNat N++(ws.flatten++rest)) f).state=none ∧ + (run program (encodeNat N++(ws.flatten++rest)) f).memory.outputRev.reverse=List.replicate j false) from by + intro f hf + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hf ⊢ + change (run draw (encodeNat N++(ws.flatten++rest)) (f∘e)).state=none ∧ _ at hf + obtain ⟨u,hu,h6,h7,hin,hout⟩ := WeightedSampler.first_safe N (ws.flatten++rest) (List.ofFn (f∘e)) hf.1 + change (run draw (encodeNat N++(ws.flatten++rest)) (f∘e)).memory.stack 5=(IntegerDraw.integerWord N u).reverse at hu + have hs : Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j := by + have hg := hf.2 + rw [hu,WeightedSampler.reverse_value,IntegerDraw.integerWord_value] at hg + exact hg + have ht : (List.ofFn f).take s=List.ofFn (f∘e) := by + rw [List.ofFn_add] + simp only [List.take_append,List.length_ofFn,Nat.sub_self,List.take_zero,List.append_nil] + rw [List.take_of_length_le (by simp)] + congr 2 + have hc := completes N ws rest (List.ofFn f) s j u hlen htotal + ((List.length_ofFn (f:=f)).symm.le) + (by rw [ht]; exact hf.1) (by rw [ht]; exact hu) hs + refine ⟨hc.1,?_⟩ + have ho : (run program (encodeNat N++(ws.flatten++rest)) f).memory.outputRev=List.replicate j false := hc.2 + rw [ho,List.reverse_replicate]) + +theorem stack_law (N : ℕ) (ws : List (List Bool)) (rest : List Bool) (j : ℕ) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + Tendsto (mass program (encodeNat N++(ws.flatten++rest)) (List.replicate j false)) atTop + (nhds ((Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j:ℝ)/(N+1:ℝ))) := by + obtain ⟨r,hr⟩ := mass_limit_exists program (encodeNat N++(ws.flatten++rest)) (List.replicate j false) + have hg := group_limit N ws rest j htotal + have hu : r≤(Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j:ℝ)/(N+1:ℝ) := + le_of_tendsto_of_tendsto' hr hg (fun s => mass_upper N ws rest j s hlen htotal) + have hl : (Contingency.IntegerDraw.weight (WeightedScan.indexedWeights ws 0) j:ℝ)/(N+1:ℝ)≤r := + le_of_tendsto_of_tendsto' hg (hr.comp (tendsto_add_atTop_nat (delay N ws))) (fun s => mass_lower N ws rest j s hlen htotal) + simpa only [le_antisymm hu hl] using hr + + + +theorem cached_selector (N : ℕ) (ws : List (List Bool)) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + (∀ (t : ℕ) (f : Fin t→Bool),(machine.run (encodeNat N++(ws.flatten++rest)) f).state=none → + ∃ j ∃ j [] + | w::ws,i => (i,w)::integerEntries ws (i+1) + +theorem member_le_sum (weights : List ℕ) (x : ℕ) (hx : x∈weights) : x≤weights.sum := by + induction weights with + | nil => simp at hx + | cons a as ih => + simp only [List.mem_cons] at hx + simp only [List.sum_cons] + rcases hx with rfl|hx + · omega + · have hh := ih hx; omega + +theorem cache_width (weights : List ℕ) (hp : 0 x)=weights := by induction weights <;> simp_all + rw [he] + +theorem cache_entries (weights : List ℕ) (i : ℕ) : + WeightedScan.indexedWeights (cacheWords weights) i=integerEntries weights i := by + have hh (n : ℕ) (as : List ℕ) (j : ℕ) : + WeightedScan.indexedWeights (as.map (BinarySubtract.bits n)) j=integerEntries as j := by + induction as generalizing j with + | nil => rfl + | cons a as ih => simp [WeightedScan.indexedWeights,integerEntries,ih] + exact hh _ _ _ + + + +theorem integer_cache_sampler (weights : List ℕ) (rest : List Bool) (hp : 0 rfl + | cons a as ih => + have hn : i≠j := by omega + simp [integerEntries,Contingency.IntegerDraw.weight,hn] + exact ih (i+1) (by omega) + +theorem entries_lookup (ws : List ℕ) (i j : ℕ) : + Contingency.IntegerDraw.weight (integerEntries ws i) (i+j)=ws.getD j 0 := by + induction ws generalizing i j with + | nil => simp [integerEntries,Contingency.IntegerDraw.weight] + | cons a as ih => + cases j with + | zero => + have hz := entries_below as (i+1) i (by omega) + simp only [Nat.add_zero,integerEntries,Contingency.IntegerDraw.weight,List.map_cons,List.sum_cons,ite_true] + change a+Contingency.IntegerDraw.weight (integerEntries as (i+1)) i=_ + rw [hz] + simp + | succ j => + have hn : i≠i+(j+1) := by omega + simp only [integerEntries,Contingency.IntegerDraw.weight,List.map_cons,List.sum_cons,hn,ite_false,Nat.zero_add] + change Contingency.IntegerDraw.weight (integerEntries as (i+1)) (i+(j+1))=_ + rw [show i+(j+1)=(i+1)+j by omega,ih] + simp + +theorem finite_weights_law {M : ℕ} (w : Fin M→ℕ) (hw : 0<∑ j,w j) (rest : List Bool) (j : Fin M) : + Tendsto (machine.mass (cacheInput (List.ofFn w) rest) (List.replicate j.val false)) atTop + (nhds ((w j:ℝ)/(∑ a,w a:ℕ))) := by + have hp : 0<(List.ofFn w).sum := by simpa only [List.sum_ofFn] using hw + have h := (integer_cache_sampler (List.ofFn w) rest hp).2.1 j.val + have hl := entries_lookup (List.ofFn w) 0 j.val + simp only [Nat.zero_add] at hl + rw [hl,List.getD_eq_getElem _ _ (by simp)] at h + simpa only [List.getElem_ofFn,List.sum_ofFn] using h + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + +namespace Contingency +open BitModel.StackCode.PaddedWeightedSampler +noncomputable section +variable {m n : ℕ} (r : Fin m→ℕ) (c : Fin n→ℕ) +local instance preparedResidualVectorTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ +variable (hrc : (∑ i,r i)=∑ j,c j) + + + +def residualVector : Fin (Fintype.card (Tables r c))→ℕ := + fun j => arbitraryResidual r c hrc ((Fintype.equivFin (Tables r c)).symm j) + +theorem residualVector_sum : (∑ j,residualVector r c hrc j)=∑ X,arbitraryResidual r c hrc X := by + unfold residualVector + exact Equiv.sum_comp (Fintype.equivFin (Tables r c)).symm _ + + + +theorem residual_cache_law (rest : List Bool) (X : Tables r c) : + Tendsto (machine.mass (cacheInput (List.ofFn (residualVector r c hrc)) rest) + (List.replicate ((Fintype.equivFin (Tables r c)) X).val false)) atTop + (nhds ((arbitraryResidual r c hrc X:ℝ)/(Fintype.card (Tables r c)*2^(arbitraryDraw r c hrc (2*Parameters.D m n (∑ i,r i))).bits:ℝ))) := by + have hp : 0<∑ j,residualVector r c hrc j := by + rw [residualVector_sum] + exact arbitraryResidual_total_pos r c hrc + have hh := BitModel.StackCode.PaddedWeightedSampler.finite_weights_law (residualVector r c hrc) hp rest + ((Fintype.equivFin (Tables r c)) X) + have hw : residualVector r c hrc ((Fintype.equivFin (Tables r c)) X)=arbitraryResidual r c hrc X := by + simp [residualVector] + rw [hw,residualVector_sum,(arbitraryResidual_data r c hrc).2] at hh + simpa only [Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] using hh + +end +end Contingency + + + + + +open scoped BigOperators +open Filter + +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +noncomputable section + + + +theorem cache_maximum_size_le (weights : List ℕ) (D R : ℕ) + (hp : 0 < (weights).sum) (hM : (weights).length ≤ 2 ^ D) + (hs : (weights).sum = (weights).length * 2 ^ R) : + (cacheMaximum weights).size ≤ D + R := by + apply Nat.size_le.mpr + have hsum : (weights).sum ≤ 2 ^ (D + R) := by + rw [hs, pow_add] + exact Nat.mul_le_mul_right _ hM + dsimp only [cacheMaximum] + exact (Nat.sub_lt hp (by omega)).trans_le hsum + + + +theorem integer_cache_rare_time (weights : List ℕ) (rest : List Bool) (D R : ℕ) + (hp : 0 < (weights).sum) (hM : (weights).length ≤ 2 ^ D) + (hs : (weights).sum = (weights).length * 2 ^ R) : + (1 / (2 : ℝ) ^ D) * (∑' t, machine.tail (cacheInput weights rest) t) ≤ + (100 * (D + R + 1) : ℕ) := by + have ht := (integer_cache_sampler weights rest hp).2.2.2.2 + have hsize := cache_maximum_size_le weights D R hp hM hs + have hδ0 : (0 : ℝ) ≤ 1 / 2 ^ D := by positivity + have hδ1 : (1 : ℝ) / 2 ^ D ≤ 1 := + (div_le_one (by positivity)).mpr (one_le_pow₀ (by norm_num)) + have hδM : (1 / (2 : ℝ) ^ D) * (weights).length ≤ 1 := by + calc + _ = ((weights).length : ℝ) / 2 ^ D := by ring + _ ≤ 1 := (div_le_one (by positivity)).mpr (by exact_mod_cast hM) + have hfirst := mul_le_mul_of_nonneg_right hδ1 + (show (0 : ℝ) ≤ 78 * (cacheMaximum weights).size + 58 by positivity) + have hsecond := mul_le_mul_of_nonneg_left hδM + (show (0 : ℝ) ≤ 10 * ((cacheMaximum weights).size + 2) by positivity) + have hsizeR : ((cacheMaximum weights).size : ℝ) ≤ (D + R : ℕ) := by + exact_mod_cast hsize + have hsum0 : (0 : ℝ) ≤ (D + R : ℕ) := Nat.cast_nonneg _ + calc + _ ≤ (1 / (2 : ℝ) ^ D) * + (78 * (cacheMaximum weights).size + 58 + + 10 * ((cacheMaximum weights).size + 2) * (weights).length) := + mul_le_mul_of_nonneg_left ht hδ0 + _ = (1 / (2 : ℝ) ^ D) * (78 * (cacheMaximum weights).size + 58) + + 10 * ((cacheMaximum weights).size + 2) * + ((1 / (2 : ℝ) ^ D) * (weights).length) := by ring + _ ≤ (78 * (cacheMaximum weights).size + 58) + + 10 * ((cacheMaximum weights).size + 2) := by + simpa only [one_mul, mul_one] using add_le_add hfirst hsecond + _ ≤ (100 * (D + R + 1) : ℕ) := by + simp only [Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] at * + nlinarith only [hsizeR, hsum0] + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + +namespace Contingency +open BitModel.StackCode.PaddedWeightedSampler +noncomputable section + + + +def residualSelectionBudget (s : ℕ) : ℕ := + 100 * (26 ^ 2 * (s + 3) ^ 16 + + (32 * (s + 2 * (26 ^ 2 * (s + 3) ^ 16) + 3) ^ 2) ^ 300 + 1) + +variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) +local instance preparedResidualBudgetTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ +variable (hrc : (∑ i, r i) = ∑ j, c j) +local notation "D" => Parameters.D m n (∑ i, r i) +local notation "p" => arbitraryDraw r c hrc (2 * D) +local notation "weights" => List.ofFn (residualVector r c hrc) + + + +theorem residual_cache_rare_time (rest : List Bool) : + (1 / (2 : ℝ) ^ D) * (∑' t, machine.tail (cacheInput weights rest) t) ≤ + (residualSelectionBudget (inputSize m n (∑ i, r i)) : ℕ) := by + have hp : 0 < (weights).sum := by + rw [List.sum_ofFn, residualVector_sum] + exact arbitraryResidual_total_pos r c hrc + have hM : (weights).length ≤ 2 ^ D := by + simpa only [List.length_ofFn, Nat.card_eq_fintype_card] using + Parameters.table_card_D_all r c hrc + have hs : (weights).sum = (weights).length * 2 ^ (p).bits := by + rw [List.sum_ofFn, residualVector_sum, (arbitraryResidual_data r c hrc).2, + List.length_ofFn] + have ht := integer_cache_rare_time weights rest D (p).bits hp hM hs + have hD := Parameters.D_le_input m n (∑ i, r i) + have hk : 1 ≤ 2 * D := by + have := Parameters.D_positive m n (∑ i, r i) + omega + have hR := arbitraryDraw_bits_input r c hrc (2 * D) hk + have hbase : inputSize m n (∑ i, r i) + 2 * D + 3 ≤ + inputSize m n (∑ i, r i) + + 2 * (26 ^ 2 * (inputSize m n (∑ i, r i) + 3) ^ 16) + 3 := by omega + have hR' : (p).bits ≤ + (32 * (inputSize m n (∑ i, r i) + + 2 * (26 ^ 2 * (inputSize m n (∑ i, r i) + 3) ^ 16) + 3) ^ 2) ^ 300 := by + calc + _ ≤ (32 * (inputSize m n (∑ i, r i) + 2 * D + 3) ^ 2) ^ 300 := hR + _ ≤ _ := by gcongr + refine ht.trans ?_ + apply Nat.cast_le.mpr + unfold residualSelectionBudget + apply Nat.mul_le_mul_left + omega + + + +theorem residual_cache_corrected_limit (rest : List Bool) (X : Tables r c) : + Tendsto + (fun t => (1 - 1 / (2 : ℝ) ^ D) * (p).toLaw.mass X + + (1 / (2 : ℝ) ^ D) * + machine.mass (cacheInput weights rest) + (List.replicate ((Fintype.equivFin (Tables r c)) X).val false) t) + atTop (nhds (1 / (Nat.card (Tables r c) : ℝ))) := by + classical + let := tables_nonempty r c hrc + have hM : Fintype.card (Tables r c) ≤ 2 ^ D := by + simpa only [Nat.card_eq_fintype_card] using Parameters.table_card_D_all r c hrc + have hk : 1 ≤ 2 * D := by + have := Parameters.D_positive m n (∑ i, r i) + omega + have he := corrected_exact p D hM (arbitraryDraw_tv r c hrc (2 * D) hk) X + change (1 - 1 / (2 : ℝ) ^ D) * (p).toLaw.mass X + + (1 / (2 : ℝ) ^ D) * ((arbitraryResidual r c hrc X : ℝ) / + (Fintype.card (Tables r c) * 2 ^ (p).bits : ℝ)) = + 1 / (Fintype.card (Tables r c) : ℝ) at he + have hl := ((residual_cache_law r c hrc rest X).const_mul ((1 : ℝ) / 2 ^ D)).const_add + ((1 - 1 / (2 : ℝ) ^ D) * (p).toLaw.mass X) + simpa only [he, Nat.card_eq_fintype_card] using hl + + + +theorem prepared_residual_stage (rest : List Bool) : + (∀ (t : ℕ) (coins : Fin t → Bool), + (machine.run (cacheInput weights rest) coins).state = none → + ∃ j < Fintype.card (Tables r c), + (machine.run (cacheInput weights rest) coins).outputRev.reverse = + List.replicate j false) ∧ + Summable (machine.tail (cacheInput weights rest)) ∧ + Tendsto (machine.tail (cacheInput weights rest)) atTop (nhds 0) ∧ + (1 / (2 : ℝ) ^ D) * (∑' t, machine.tail (cacheInput weights rest) t) ≤ + (residualSelectionBudget (inputSize m n (∑ i, r i)) : ℕ) ∧ + (∀ X : Tables r c, + Tendsto + (fun t => (1 - 1 / (2 : ℝ) ^ D) * (p).toLaw.mass X + + (1 / (2 : ℝ) ^ D) * + machine.mass (cacheInput weights rest) + (List.replicate ((Fintype.equivFin (Tables r c)) X).val false) t) + atTop (nhds (1 / (Nat.card (Tables r c) : ℝ)))) := by + have hp : 0 < (weights).sum := by + rw [List.sum_ofFn, residualVector_sum] + exact arbitraryResidual_total_pos r c hrc + have hc := integer_cache_sampler weights rest hp + exact ⟨by simpa only [List.length_ofFn] using hc.1, hc.2.2.1, hc.2.2.2.1, + residual_cache_rare_time r c hrc rest, residual_cache_corrected_limit r c hrc rest⟩ + +end +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/RecursiveTransport.lean b/lean/OAI/Probability/Contingency/RecursiveTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..914104230122b5cd7d449e46cb4384ed2b891a6e --- /dev/null +++ b/lean/OAI/Probability/Contingency/RecursiveTransport.lean @@ -0,0 +1,521 @@ +import Mathlib +import OAI.Probability.Contingency.Transport + +namespace OAI + +/-! Recursive Transport. -/ + +noncomputable section + +open scoped BigOperators +open QuadraticMap +open scoped BigOperators +open QuadraticMap + +namespace Contingency + +universe u + + + +@[reducible] def PairCoords (ι : Type u) : ℕ → Type u + | 0 => ι + | n+1 => PairCoords (ι ⊕ Bool) n + +instance pairCoordsFintype (ι : Type u) [Fintype ι] : (n : ℕ) → Fintype (PairCoords ι n) + | 0 => inferInstanceAs (Fintype ι) + | n+1 => pairCoordsFintype (ι ⊕ Bool) n + +instance pairCoordsDecidableEq (ι : Type u) [DecidableEq ι] : + (n : ℕ) → DecidableEq (PairCoords ι n) + | 0 => inferInstanceAs (DecidableEq ι) + | n+1 => pairCoordsDecidableEq (ι ⊕ Bool) n + +noncomputable def pairBox {ι : Type u} (C : ℕ) : + (n : ℕ) → (ι → ℤ) → PairCoords ι n → ℤ + | 0, B => B + | n+1, B => pairBox C n (pairAssembly B (C:ℤ) C) + +noncomputable def allBalance {ι : Type u} (C : ℕ) : + (n : ℕ) → ((PairCoords ι n → ℤ) → ℝ) → (ι → ℤ) → ℝ + | 0, f => f + | n+1, f => balancedMarginal (allBalance C n f) C + + + +noncomputable def allRaise {ι : Type u} (C : ℕ) : + (n : ℕ) → ((PairCoords ι n → ℤ) → ℝ) → (ι → ℤ) → ℝ + | 0, _ => fun _ => 0 + | n+1, f => fun p => raisedFull (allBalance C n f) C p + + balancedMarginal (allRaise C n f) C p + +section Closure +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +theorem allBalance_closure (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) + (hp : PositiveSlice f (pairBox C n B) T) + (hs : HasSignature f (pairBox C n B) T) : + PositiveSlice (allBalance C n f) B (T-(n:ℤ)*C) ∧ + HasSignature (allBalance C n f) B (T-(n:ℤ)*C) := by + induction n generalizing ι with + | zero => simpa only [allBalance, Nat.cast_zero, zero_mul, sub_zero] using ⟨hp,hs⟩ + | succ n ih => + obtain ⟨hp',hs'⟩ := ih f (pairAssembly B (C:ℤ) C) hp hs + have hp'' := balancedMarginal_positive _ B C (T-(n:ℤ)*C) hp' + have hs'' := balancedMarginal_signature _ B C hC (T-(n:ℤ)*C) hp' hs' + have ht : T-(n:ℤ)*C-C = T-((n+1:ℕ):ℤ)*C := by push_cast; ring + simpa only [allBalance, ht] using And.intro hp'' hs'' + +theorem allRaise_positive (C : ℕ) (hC : 2 ≤ C) (n : ℕ) (hn : 0 < n) + (f : (PairCoords ι n → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) + (hp : PositiveSlice f (pairBox C n B) T) + (hs : HasSignature f (pairBox C n B) T) : + PositiveSlice (allRaise C n f) B (T-(n:ℤ)*C-1) := by + induction n generalizing ι with + | zero => omega + | succ n ih => + have hg := (allBalance_closure C hC n f (pairAssembly B (C:ℤ) C) T hp hs).1 + have hr := raisedFull_positive _ B C (by omega) (T-(n:ℤ)*C) hg + have ht : T-(n:ℤ)*C-(C+1:ℕ) = T-((n+1:ℕ):ℤ)*C-1 := by push_cast; ring + rw [ht] at hr + cases n with + | zero => + simpa only [allRaise, balancedMarginal, Finset.sum_const_zero, add_zero] using hr + | succ n => + have hg' := ih (by omega) f (pairAssembly B (C:ℤ) C) hp hs + have hb := balancedMarginal_positive _ B C (T-((n+1:ℕ):ℤ)*C-1) hg' + have ht' : T-((n+1:ℕ):ℤ)*C-1-C = T-((n+1+1:ℕ):ℤ)*C-1 := by push_cast; ring + rw [ht'] at hb + exact hr.add hb + +end Closure + + + +@[reducible] def Branches (C : ℕ) : ℕ → Type + | 0 => PUnit + | n+1 => Fin (C+1) × Branches C n + +instance branchesFintype (C : ℕ) : (n : ℕ) → Fintype (Branches C n) + | 0 => inferInstanceAs (Fintype PUnit) + | n+1 => @instFintypeProd _ _ inferInstance (branchesFintype C n) + +noncomputable def leafDisplay {ι : Type u} (C : ℕ) : + (n : ℕ) → (ι → ℤ) → Branches C n → PairCoords ι n → ℤ + | 0, p, _ => p + | n+1, p, a => leafDisplay C n (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) a.2 + +noncomputable def leafCoefficient {ι : Type u} [Fintype ι] [DecidableEq ι] (C : ℕ) : + (n : ℕ) → ((PairCoords ι n → ℤ) → ℝ) → (ι → ℤ) → (ι → ℝ) → + Branches C n → PairCoords ι n → ℝ + | 0, _, _, h, _ => h + | n+1, f, p, h, a => + let F := allBalance C n f + let g := pairCumulative (C+1) (pairU F p (C+1)) (pairS F p (C+1)) h + leafCoefficient C n f (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) + (pairAssembly h (g (a.1:ℕ)) (-g ((a.1:ℕ)+1))) a.2 + +section LeafConservation +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +def BoxSupported {κ : Type*} (f : (κ → ℤ) → ℝ) (B : κ → ℤ) : Prop := + ∀ p, ¬InBox B p → f p = 0 + +omit [DecidableEq ι] in +theorem PositiveSlice.boxSupported {f : (ι → ℤ) → ℝ} {B : ι → ℤ} {T : ℤ} + (hf : PositiveSlice f B T) : BoxSupported f B := by + intro p hp + exact hf.2 p (fun h => hp h.1) + +theorem allBalance_boxSupported (C n : ℕ) (f : (PairCoords ι n → ℤ) → ℝ) + (B : ι → ℤ) (hf : BoxSupported f (pairBox C n B)) : + BoxSupported (allBalance C n f) B := by + induction n generalizing ι with + | zero => exact hf + | succ n ih => + intro p hp + change (∑ j ∈ Finset.range (C+1), + allBalance C n f (pairAssembly p (j:ℤ) ((C:ℤ)-j))) = 0 + apply Finset.sum_eq_zero + intro j _ + apply ih f (pairAssembly B (C:ℤ) C) hf + intro hh + rw [pairAssembly_inBox] at hh + exact hp hh.1 + + + +theorem leaf_demand_conservation (C n : ℕ) (f : (PairCoords ι n → ℤ) → ℝ) + (B : ι → ℤ) (hf : BoxSupported f (pairBox C n B)) + (H : (PairCoords ι n → ℤ) → ℝ) (p : ι → ℤ) (h : ι → ℝ) : + (∑ a : Branches C n, holeFunctional (fun x => f x * H x) + (leafDisplay C n p a) (leafCoefficient C n f p h a)) = + holeFunctional (allBalance C n (fun x => f x * H x)) p h := by + induction n generalizing ι with + | zero => + change (∑ _ : PUnit, holeFunctional (fun x => f x * H x) p h) = + holeFunctional (fun x => f x * H x) p h + simp + | succ n ih => + let F := allBalance C n f + let g := pairCumulative (C+1) (pairU F p (C+1)) (pairS F p (C+1)) h + let FH := allBalance C n (fun x => f x * H x) + have hFH : BoxSupported FH (pairAssembly B (C:ℤ) C) := by + apply allBalance_boxSupported + intro x hx + simp only [hf x hx, zero_mul] + have hz0 : pairU FH p (C+1) 0 = 0 := by + apply hFH + intro hb + have ht := hb (Sum.inr true) + simp [pairAssembly] at ht + have hzC : pairU FH p (C+1) (C+1) = 0 := by + apply hFH + intro hb + have ht := hb (Sum.inr false) + simp [pairAssembly] at ht + change (∑ a : Fin (C+1) × Branches C n, + holeFunctional (fun x => f x * H x) + (leafDisplay C n (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) a.2) + (leafCoefficient C n f (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) + (pairAssembly h (g (a.1:ℕ)) (-g ((a.1:ℕ)+1))) a.2)) = _ + rw [Fintype.sum_prod_type] + simp_rw [ih f (pairAssembly B (C:ℤ) C) hf H] + rw [Fin.sum_univ_eq_sum_range (fun j => holeFunctional FH + (pairAssembly p (j:ℤ) ((C:ℤ)-j)) (pairAssembly h (g j) (-g (j+1))))] + exact branch_demand_conservation_endpoints FH C p h g hz0 hzC + +end LeafConservation + +section LeafPotential +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + + + +theorem allRaise_future_monotone (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : (PairCoords (ι ⊕ Bool) n → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) + (hp : PositiveSlice f (pairBox C n (pairAssembly B (C:ℤ) C)) T) + (hs : HasSignature f (pairBox C n (pairAssembly B (C:ℤ) C)) T) + (p : ι → ℤ) (h : ι → ℝ) (g : ℕ → ℝ) : + matrixForm (twoRemoval (balancedMarginal (allRaise C n f) C) p) h ≤ + ∑ j ∈ Finset.range (C+1), + matrixForm (twoRemoval (allRaise C n f) (pairAssembly p (j:ℤ) ((C:ℤ)-j))) + (pairAssembly h (g j) (-g (j+1))) := by + by_cases hn : n = 0 + · subst n + have hz : balancedMarginal (fun _ : ι ⊕ Bool → ℤ => (0:ℝ)) C = fun _ => 0 := by + funext x + simp [balancedMarginal] + simp only [allRaise, hz, matrixForm_zero, Finset.sum_const_zero, le_refl] + · exact actual_future_monotone _ B (C:ℤ) (T-(n:ℤ)*C-1) + (allRaise_positive C hC n (Nat.pos_of_ne_zero hn) f _ T hp hs) p C h g + + + +theorem leaf_potential_bound (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) + (hf : PositiveSlice f (pairBox C n B) T) + (hs : HasSignature f (pairBox C n B) T) + (p : ι → ℤ) (hp : InBox B p) (ht : (∑ i, p i)+(n:ℤ)*C = T+1) + (h : ι → ℝ) (hbal : holeFunctional (allBalance C n f) p h = 0) : + (∑ a : Branches C n, holePotential f (leafDisplay C n p a) + (leafCoefficient C n f p h a)) ≤ + holePotential (allBalance C n f) p h - matrixForm (twoRemoval (allRaise C n f) p) h := by + induction n generalizing ι with + | zero => + change (∑ _ : PUnit, holePotential f p h) ≤ holePotential f p h - + matrixForm (twoRemoval (fun _ => 0) p) h + simp [matrixForm_zero] + | succ n ih => + let F := allBalance C n f + let g := pairCumulative (C+1) (pairU F p (C+1)) (pairS F p (C+1)) h + obtain ⟨hF,hFs⟩ := allBalance_closure C hC n f (pairAssembly B (C:ℤ) C) T hf hs + have htotal : (∑ i, p i)+(C+1:ℕ) = (T-(n:ℤ)*C)+2 := by + push_cast at ht ⊢ + nlinarith + have hb (j : Fin (C+1)) : holeFunctional F + (pairAssembly p (j:ℕ) ((C:ℤ)-(j:ℕ))) + (pairAssembly h (g (j:ℕ)) (-g ((j:ℕ)+1))) = 0 := + balanced_child F B C hC (T-(n:ℤ)*C) hF p hp htotal h hbal j (by omega) + have hi (j : Fin (C+1)) := ih f (pairAssembly B (C:ℤ) C) hf hs + (pairAssembly p (j:ℕ) ((C:ℤ)-(j:ℕ))) + (by rw [pairAssembly_inBox]; exact ⟨hp, by omega, by omega⟩) + (by rw [pairAssembly_sum]; push_cast at ht ⊢; nlinarith) + (pairAssembly h (g (j:ℕ)) (-g ((j:ℕ)+1))) (hb j) + have hinc := balanced_potential_bound F B C hC (T-(n:ℤ)*C) hF hFs p hp htotal h hbal + have hfuture := allRaise_future_monotone C hC n f B T hf hs p h g + have hsums : (∑ a : Branches C (n+1), holePotential f (leafDisplay C (n+1) p a) + (leafCoefficient C (n+1) f p h a)) ≤ + (∑ j ∈ Finset.range (C+1), holePotential F + (pairAssembly p (j:ℤ) ((C:ℤ)-j)) (pairAssembly h (g j) (-g (j+1)))) - + (∑ j ∈ Finset.range (C+1), matrixForm (twoRemoval (allRaise C n f) + (pairAssembly p (j:ℤ) ((C:ℤ)-j))) (pairAssembly h (g j) (-g (j+1)))) := by + change (∑ a : Fin (C+1) × Branches C n, _) ≤ _ + rw [Fintype.sum_prod_type, ← Finset.sum_sub_distrib, ← Fin.sum_univ_eq_sum_range] + exact Finset.sum_le_sum (fun j _ => hi j) + have he : matrixForm (twoRemoval (allRaise C (n+1) f) p) h = + (∑ j ∈ Finset.range (C+2), ((j:ℝ)*(C+1-j)) • pairQ F p (C+1) j) h + + matrixForm (twoRemoval (balancedMarginal (allRaise C n f) C) p) h := by + rw [allRaise, matrixForm_twoRemoval_add, matrixForm_raisedFull] + rw [he] + change _ ≤ holePotential (balancedMarginal F C) p h - _ + dsimp only at hinc + linarith + + + +theorem leaf_balanced (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : (PairCoords ι n → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) + (hf : PositiveSlice f (pairBox C n B) T) + (hs : HasSignature f (pairBox C n B) T) + (p : ι → ℤ) (hp : InBox B p) (ht : (∑ i, p i)+(n:ℤ)*C = T+1) + (h : ι → ℝ) (hbal : holeFunctional (allBalance C n f) p h = 0) + (a : Branches C n) : + holeFunctional f (leafDisplay C n p a) (leafCoefficient C n f p h a) = 0 := by + induction n generalizing ι with + | zero => exact hbal + | succ n ih => + let F := allBalance C n f + let g := pairCumulative (C+1) (pairU F p (C+1)) (pairS F p (C+1)) h + obtain ⟨hF,hFs⟩ := allBalance_closure C hC n f (pairAssembly B (C:ℤ) C) T hf hs + have htotal : (∑ i, p i)+(C+1:ℕ) = (T-(n:ℤ)*C)+2 := by + push_cast at ht ⊢ + nlinarith + have hb : holeFunctional F + (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) + (pairAssembly h (g (a.1:ℕ)) (-g ((a.1:ℕ)+1))) = 0 := + balanced_child F B C hC (T-(n:ℤ)*C) hF p hp htotal h hbal a.1 (by omega) + exact ih f (pairAssembly B (C:ℤ) C) hf hs + (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) + (by rw [pairAssembly_inBox]; exact ⟨hp, by omega, by omega⟩) + (by rw [pairAssembly_sum]; push_cast at ht ⊢; nlinarith) + (pairAssembly h (g (a.1:ℕ)) (-g ((a.1:ℕ)+1))) hb a.2 + +noncomputable def leafStarEnergy (C n : ℕ) (f H : (PairCoords ι n → ℤ) → ℝ) + (p : ι → ℤ) (center : Branches C n → ℝ) : ℝ := + ∑ a : Branches C n, ∑ i : PairCoords ι n, + f (removeOne (leafDisplay C n p a) i) * + (H (removeOne (leafDisplay C n p a) i) - center a)^2 + + + +theorem recursive_star_transport (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f H : (PairCoords ι n → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) + (hf : PositiveSlice f (pairBox C n B) T) + (hs : HasSignature f (pairBox C n B) T) + (p : ι → ℤ) (hp : InBox B p) (ht : (∑ i, p i)+(n:ℤ)*C = T+1) + (h : ι → ℝ) (hbal : holeFunctional (allBalance C n f) p h = 0) + (center : Branches C n → ℝ) : + (holeFunctional (allBalance C n (fun x => f x * H x)) p h)^2 ≤ + (holePotential (allBalance C n f) p h - matrixForm (twoRemoval (allRaise C n f) p) h) * + leafStarEnergy C n f H p center := by + have hleaf (a : Branches C n) : + (holeFunctional (fun x => f x * H x) (leafDisplay C n p a) + (leafCoefficient C n f p h a))^2 ≤ + holePotential f (leafDisplay C n p a) (leafCoefficient C n f p h a) * + ∑ i, f (removeOne (leafDisplay C n p a) i) * + (H (removeOne (leafDisplay C n p a) i) - center a)^2 := by + have hh := weighted_star_bound (fun i => f (removeOne (leafDisplay C n p a) i)) + (leafCoefficient C n f p h a) (fun i => H (removeOne (leafDisplay C n p a) i)) + (fun i => hf.nonneg _) (leaf_balanced C hC n f B T hf hs p hp ht h hbal a) (center a) + have he : holeFunctional (fun x => f x * H x) (leafDisplay C n p a) + (leafCoefficient C n f p h a) = + ∑ i, f (removeOne (leafDisplay C n p a) i) * leafCoefficient C n f p h a i * + H (removeOne (leafDisplay C n p a) i) := by + apply Finset.sum_congr rfl + intro i _ + ring + rw [he] + exact hh + have he (a : Branches C n) : 0 ≤ ∑ i, f (removeOne (leafDisplay C n p a) i) * + (H (removeOne (leafDisplay C n p a) i) - center a)^2 := + Finset.sum_nonneg (fun i _ => mul_nonneg (hf.nonneg _) (sq_nonneg _)) + have hphi (a : Branches C n) : + 0 ≤ holePotential f (leafDisplay C n p a) (leafCoefficient C n f p h a) := + Finset.sum_nonneg (fun i _ => mul_nonneg (hf.nonneg _) (sq_nonneg _)) + have hc := Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul (Finset.univ : Finset (Branches C n)) + (fun a _ => hphi a) (fun a _ => he a) (fun a _ => hleaf a) + rw [leaf_demand_conservation C n f B hf.boxSupported H p h] at hc + exact hc.trans (mul_le_mul_of_nonneg_right + (leaf_potential_bound C hC n f B T hf hs p hp ht h hbal) + (Finset.sum_nonneg (fun a _ => he a))) + +end LeafPotential + +end Contingency + + + + + +open scoped BigOperators + +namespace Contingency + +universe u + +section Holes +variable {ι : Type u} [DecidableEq ι] + +theorem removeOne_injective (p : ι → ℤ) : Function.Injective (removeOne p) := by + intro i j he + by_contra hn + have hi := congrFun he i + simp [removeOne, hn] at hi + +theorem removeOne_sup (p : ι → ℤ) (i j : ι) (hij : i ≠ j) : + removeOne p i ⊔ removeOne p j = p := by + funext k + change max (p k - if k = i then 1 else 0) (p k - if k = j then 1 else 0) = p k + by_cases hki : k = i + · subst k + simp only [ite_eq_right hij, sub_zero] + exact max_eq_right (by omega) + · simp only [ite_eq_right hki, sub_zero] + exact max_eq_left (by split_ifs <;> omega) + + + +theorem holeEdge_display {p q : ι → ℤ} {i j k l : ι} (hij : i ≠ j) (hkl : k ≠ l) + (he : s(removeOne p i, removeOne p j) = s(removeOne q k, removeOne q l)) : p = q := by + have hm := congrArg (Sym2.lift ⟨fun x y : ι → ℤ => x ⊔ y, fun x y => sup_comm x y⟩) he + simpa only [Sym2.lift_mk, removeOne_sup p i j hij, removeOne_sup q k l hkl] using hm + +end Holes + + + +theorem leafDisplay_inj {ι : Type u} (C n : ℕ) (p q : ι → ℤ) + (a b : Branches C n) (he : leafDisplay C n p a = leafDisplay C n q b) : + p = q ∧ a = b := by + induction n generalizing ι with + | zero => exact ⟨he, Subsingleton.elim _ _⟩ + | succ n ih => + obtain ⟨hp,ht⟩ := ih (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) + (pairAssembly q (b.1:ℕ) ((C:ℤ)-(b.1:ℕ))) a.2 b.2 he + have hbase : p = q := funext fun i => congrFun hp (Sum.inl i) + have hhead : a.1 = b.1 := by + apply Fin.ext + have hh := congrFun hp (Sum.inr true) + simp only [pairAssembly_first] at hh + exact_mod_cast hh + exact ⟨hbase, Prod.ext hhead ht⟩ + + +noncomputable def edgeEnergy {X : Type*} (f H : X → ℝ) : Sym2 X → ℝ := + Sym2.lift ⟨fun x y => min (f x) (f y) * (H x-H y)^2, by + intro x y + dsimp only + rw [min_comm] + ring⟩ + +@[simp] theorem edgeEnergy_mk {X : Type*} (f H : X → ℝ) (x y : X) : + edgeEnergy f H s(x,y) = min (f x) (f y) * (H x-H y)^2 := rfl + +theorem edgeEnergy_nonneg {X : Type*} (f H : X → ℝ) (hf : ∀ x, 0 ≤ f x) (e : Sym2 X) : + 0 ≤ edgeEnergy f H e := by + induction e using Sym2.ind with + | _ x y => exact mul_nonneg (le_min (hf x) (hf y)) (sq_nonneg _) + +section LeafStars +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +noncomputable def starEdge (C n : ℕ) (p : ι → ℤ) + (hub : Branches C n → PairCoords ι n) (a : Branches C n × PairCoords ι n) : + Sym2 (PairCoords ι n → ℤ) := + s(removeOne (leafDisplay C n p a.1) a.2, removeOne (leafDisplay C n p a.1) (hub a.1)) + +noncomputable def starIndices (C n : ℕ) (hub : Branches C n → PairCoords ι n) : + Finset (Branches C n × PairCoords ι n) := by + classical + exact Finset.univ.filter (fun a => a.2 ≠ hub a.1) + +noncomputable def leafStarEdges (C n : ℕ) (p : ι → ℤ) + (hub : Branches C n → PairCoords ι n) : Finset (Sym2 (PairCoords ι n → ℤ)) := by + classical + exact (starIndices C n hub).image (starEdge C n p hub) + + + +theorem starEdge_injOn (C n : ℕ) (p : ι → ℤ) (hub : Branches C n → PairCoords ι n) : + Set.InjOn (starEdge C n p hub) (starIndices C n hub : Set _) := by + classical + intro a ha b hb he + have ha' : a.2 ≠ hub a.1 := (Finset.mem_filter.mp ha).2 + have hb' : b.2 ≠ hub b.1 := (Finset.mem_filter.mp hb).2 + have hd := holeEdge_display ha' hb' he + have hl := (leafDisplay_inj C n p p a.1 b.1 hd).2 + rcases a with ⟨a,i⟩ + rcases b with ⟨b,j⟩ + dsimp only at hl ha' hb' + subst b + have hij : i = j := by + rcases Sym2.eq_iff.mp he with h | h + · exact removeOne_injective _ h.1 + · exact (ha' (removeOne_injective _ h.1)).elim + exact congrArg (fun k => (a,k)) hij + + + +theorem leafStarEnergy_eq_edges (C n : ℕ) (f H : (PairCoords ι n → ℤ) → ℝ) + (p : ι → ℤ) (hub : Branches C n → PairCoords ι n) + (hmax : ∀ a i, f (removeOne (leafDisplay C n p a) i) ≤ + f (removeOne (leafDisplay C n p a) (hub a))) : + leafStarEnergy C n f H p (fun a => H (removeOne (leafDisplay C n p a) (hub a))) = + ∑ e ∈ leafStarEdges C n p hub, edgeEnergy f H e := by + classical + rw [leafStarEdges, Finset.sum_image (starEdge_injOn C n p hub)] + rw [starIndices, Finset.sum_filter, leafStarEnergy, Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro i _ + by_cases he : i = hub a + · simp [he] + · simp only [ite_eq_left he, starEdge, edgeEnergy_mk, + min_eq_left (hmax a i)] + + + +theorem leafStarEnergy_le_graph (C n : ℕ) (f H : (PairCoords ι n → ℤ) → ℝ) + (hf : ∀ x, 0 ≤ f x) (p : ι → ℤ) (hub : Branches C n → PairCoords ι n) + (hmax : ∀ a i, f (removeOne (leafDisplay C n p a) i) ≤ + f (removeOne (leafDisplay C n p a) (hub a))) + (E : Finset (Sym2 (PairCoords ι n → ℤ))) + (hE : ∀ a i, i ≠ hub a → 0 < f (removeOne (leafDisplay C n p a) i) → + starEdge C n p hub (a,i) ∈ E) : + leafStarEnergy C n f H p (fun a => H (removeOne (leafDisplay C n p a) (hub a))) ≤ + ∑ e ∈ E, edgeEnergy f H e := by + classical + rw [leafStarEnergy_eq_edges C n f H p hub hmax] + let S := (leafStarEdges C n p hub).filter (fun e => edgeEnergy f H e ≠ 0) + have he : (∑ e ∈ S, edgeEnergy f H e) = ∑ e ∈ leafStarEdges C n p hub, edgeEnergy f H e := by + apply Finset.sum_subset (Finset.filter_subset _ _) + intro e he hnot + have hn := not_and.mp (fun hh => hnot (Finset.mem_filter.mpr hh)) he + exact Classical.not_not.mp hn + rw [← he] + apply Finset.sum_le_sum_of_subset_of_nonneg + · intro e he + obtain ⟨he,hne⟩ := Finset.mem_filter.mp he + obtain ⟨a,ha,rfl⟩ := Finset.mem_image.mp he + have hi : a.2 ≠ hub a.1 := (Finset.mem_filter.mp ha).2 + apply hE a.1 a.2 hi + have hw : f (removeOne (leafDisplay C n p a.1) a.2) ≠ 0 := by + intro hz + apply hne + change min (f (removeOne (leafDisplay C n p a.1) a.2)) + (f (removeOne (leafDisplay C n p a.1) (hub a.1))) * _ = 0 + rw [min_eq_left (hmax a.1 a.2), hz, zero_mul] + exact lt_of_le_of_ne (hf _) (Ne.symm hw) + · intro e _ _ + exact edgeEnergy_nonneg f H hf e + +end LeafStars + +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/RepairVariance.lean b/lean/OAI/Probability/Contingency/RepairVariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a3b5c551b029ae3fd46ad5b4a4c059357af410d --- /dev/null +++ b/lean/OAI/Probability/Contingency/RepairVariance.lean @@ -0,0 +1,629 @@ +import Mathlib +import OAI.Probability.Contingency.ConditionalTransport + +namespace OAI + +/-! Repair Variance. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency + + +theorem variance_le_center {α : Type*} [Fintype α] (w H : α → ℝ) + (hw : ∀ x, 0 ≤ w x) (a : ℝ) : + weightedVariance w H ≤ ∑ x, w x*(H x-a)^2 := by + by_cases h : totalWeight w = 0 + · have hz : ∀ x, w x=0 := by + intro x + have hh := Finset.single_le_sum (fun y _ => hw y) (Finset.mem_univ x) + change w x ≤ totalWeight w at hh + rw [h] at hh + exact le_antisymm hh (hw x) + simp [weightedVariance,hz] + · rw [variance_translate w H h a] + exact le_add_of_nonneg_right (mul_nonneg (Finset.sum_nonneg fun x _ => hw x) (sq_nonneg _)) + + + +theorem variance_repair_extension {T D P K : Type*} + [Fintype T] [Fintype D] [Fintype P] [Fintype K] + (wT hT : T → ℝ) (wD hD : D → ℝ) (wP hP : P → ℝ) + (_hwT : ∀ t, 0 ≤ wT t) (hwD : ∀ x, 0 ≤ wD x) (hwP : ∀ p, 0 ≤ wP p) + (f : T → P) (hf : Function.Injective f) + (hTw : ∀ t, wT t=wP (f t)) (hTh : ∀ t, hT t=hP (f t)) + (g : D → K × P) (hg : Function.Injective g) (hDw : ∀ x, wD x≤wP (g x).2) + (E : ℝ) (hE : (∑ x, wD x*(hD x-hP (g x).2)^2) ≤ E) : + weightedVariance (Sum.elim wT wD) (Sum.elim hT hD) ≤ + (1+2*(Fintype.card K:ℝ))*weightedVariance wP hP+2*E := by + classical + let a := weightedMean wP hP + have ht : (∑ t, wT t*(hT t-a)^2) ≤ weightedVariance wP hP := by + simp_rw [hTw,hTh] + rw [← Finset.sum_image (s := Finset.univ) (f := fun p => wP p*(hP p-a)^2) + (fun x _ y _ h => hf h)] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun x _ _ => mul_nonneg (hwP x) (sq_nonneg _)) + have hd : (∑ x, wD x*(hP (g x).2-a)^2) ≤ + (Fintype.card K:ℝ)*weightedVariance wP hP := by + calc + _ ≤ ∑ x, wP (g x).2*(hP (g x).2-a)^2 := + Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_right (hDw x) (sq_nonneg _) + _ = ∑ kp ∈ Finset.univ.image g, wP kp.2*(hP kp.2-a)^2 := by + rw [Finset.sum_image (fun x _ y _ h => hg h)] + _ ≤ ∑ kp : K × P, wP kp.2*(hP kp.2-a)^2 := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun x _ _ => mul_nonneg (hwP x.2) (sq_nonneg _)) + _ = _ := by simp [Fintype.sum_prod_type,weightedVariance,a] + have hx : (∑ x, wD x*(hD x-a)^2) ≤ + 2*(∑ x, wD x*(hD x-hP (g x).2)^2) + + 2*(∑ x, wD x*(hP (g x).2-a)^2) := by + rw [Finset.mul_sum,Finset.mul_sum,← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro x _ + have hs : (hD x-a)^2 ≤ 2*(hD x-hP (g x).2)^2+2*(hP (g x).2-a)^2 := by + nlinarith [sq_nonneg (hD x-2*hP (g x).2+a)] + have hm := mul_le_mul_of_nonneg_left hs (hwD x) + nlinarith only [hm] + have hb := variance_le_center (Sum.elim wT wD) (Sum.elim hT hD) + (by intro x; cases x <;> simp_all) a + rw [Fintype.sum_sum_type] at hb + simp only [Sum.elim_inl,Sum.elim_inr] at hb + nlinarith only [hb,ht,hd,hx,hE] + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +abbrev TransverseState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + {X : State m n // Feasible U r c X ∧ Transversal X} +abbrev DefectiveState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + {X : State m n // Feasible U r c X ∧ ∃ s t, DefectAt U r c s t X} + +abbrev GraphState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) := + TransverseState U r c ⊕ DefectiveState U r c + +instance transverseFinite (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finite (TransverseState U r c) := + Finite.of_injective (fun X => (⟨X.val,X.property.1⟩ : {X // Feasible U r c X})) + (fun _ _ h => Subtype.ext (congrArg (fun Y : {X // Feasible U r c X} => Y.val) h)) +instance defectiveFinite (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finite (DefectiveState U r c) := + Finite.of_injective (fun X => (⟨X.val,X.property.1⟩ : {X // Feasible U r c X})) + (fun _ _ h => Subtype.ext (congrArg (fun Y : {X // Feasible U r c X} => Y.val) h)) +noncomputable instance transverseFintype (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Fintype (TransverseState U r c) := Fintype.ofFinite _ +noncomputable instance defectiveFintype (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Fintype (DefectiveState U r c) := Fintype.ofFinite _ + +noncomputable def defectPair (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : DefectiveState U r c) : Cell m n × Cell m n := + (X.property.2.choose, X.property.2.choose_spec.choose) + +theorem defectPair_spec (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : DefectiveState U r c) : + DefectAt U r c (defectPair U r c X).1 (defectPair U r c X).2 X.val := + X.property.2.choose_spec.choose_spec + +theorem defect_not_transversal (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (s t : Cell m n) (X : State m n) (hd : DefectAt U r c s t X) : ¬Transversal X := by + intro hT + have h := congrFun hd.2.2.2 s + change X.q=X.x at hT + rw [hT] at h + simp [unit,hd.2.2.1] at h + +noncomputable def repairedState (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : DefectiveState U r c) : TransverseState U r c := + ⟨repair U r c (defectPair U r c X).1 (defectPair U r c X).2 X.val, + repair_feasible U r c _ _ _ X.property.1 (defectPair_spec U r c X),rfl⟩ + +theorem coordinates_state_inverse (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hX : ∀ w, IsLarge U r c w → X.x w=0 ∧ X.q w=0) : + coordinatesState U r c (stateCoordinates U r c X)=X := by + have hx : (coordinatesState U r c (stateCoordinates U r c X)).x=X.x := by + funext w + by_cases hw : IsSmall U r c w + · simp [coordinatesState,stateCoordinates,hw] + · simp [coordinatesState,hw,(hX w (Classical.not_not.mp hw)).1] + have hq : (coordinatesState U r c (stateCoordinates U r c X)).q=X.q := by + funext w + by_cases hw : IsSmall U r c w + · simp [coordinatesState,stateCoordinates,hw] + · simp [coordinatesState,hw,(hX w (Classical.not_not.mp hw)).2] + exact congrArg₂ State.mk hx hq + +noncomputable def transverseTuple (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : TransverseState U r c) : SmallSlot U r c → Fin (U+1) := + fun s => ⟨(X.val.x s.val).toNat,by have h := X.property.1.1 s.val; omega⟩ + +@[simp] theorem tuple_transverseTuple (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : TransverseState U r c) : tupleState U r c (transverseTuple U r c X)=X.val := by + have hh : (fun w : SmallCoord U r c => if w.2 then + ((transverseTuple U r c X w.1:ℕ):ℤ) else (U:ℤ)-(transverseTuple U r c X w.1:ℕ)) = + stateCoordinates U r c X.val := by + funext ⟨s,b⟩ + have hnn := (X.property.1.1 s.val).1 + have hT : X.val.q=X.val.x := X.property.2 + cases b <;> simp [transverseTuple,stateCoordinates,Int.toNat_of_nonneg hnn,hT] + unfold tupleState + rw [hh] + exact coordinates_state_inverse U r c X.val X.property.1.2.1 + +noncomputable def rootProfile (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (α : SmallSlot U r c → Fin (U+1)) : Profiles U (Fintype.card (SmallSlot U r c)) := + (profileEquiv U _).symm (α ∘ smallIndex U r c) + +@[simp] theorem rootProfile_state (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (α : SmallSlot U r c → Fin (U+1)) : + profileState U r c 0 (Fintype.card (SmallSlot U r c)) (by omega) Fin.elim0 + (rootProfile U r c α)=tupleState U r c α := by + unfold profileState rootProfile + rw [Equiv.apply_symm_apply] + congr 1 + funext s + simp [appendAssignment] + +noncomputable def transverseProfile (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : TransverseState U r c) : Profiles U (Fintype.card (SmallSlot U r c)) := + rootProfile U r c (transverseTuple U r c X) + +@[simp] theorem transverseProfile_state (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : TransverseState U r c) : + profileState U r c 0 (Fintype.card (SmallSlot U r c)) (by omega) Fin.elim0 + (transverseProfile U r c X)=X.val := by + simp [transverseProfile] + +theorem transverseProfile_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Function.Injective (transverseProfile U r c) := by + intro X Y he + have hh := congrArg (profileState U r c 0 (Fintype.card (SmallSlot U r c)) (by omega) Fin.elim0) he + simpa only [transverseProfile_state,Subtype.val_inj] using hh + +noncomputable def taggedRepair (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : DefectiveState U r c) : (Cell m n × Cell m n) × Profiles U (Fintype.card (SmallSlot U r c)) := + (defectPair U r c X,transverseProfile U r c (repairedState U r c X)) + +theorem taggedRepair_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Function.Injective (taggedRepair U r c) := by + intro X Y he + have hp : defectPair U r c X=defectPair U r c Y := congrArg Prod.fst he + have ht := transverseProfile_injective U r c (congrArg Prod.snd he) + have ht' := congrArg Subtype.val ht + change repair U r c _ _ X.val=repair U r c _ _ Y.val at ht' + rw [← hp] at ht' + apply Subtype.ext + apply repair_injective U r c _ _ X.val Y.val (defectPair_spec U r c X) _ ht' + rw [hp] + exact defectPair_spec U r c Y + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +theorem defect_type_unique (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (s t s' t' : Cell m n) + (h : DefectAt U r c s t X) (h' : DefectAt U r c s' t' X) : s=s' ∧ t=t' := by + have hs := congrFun h.2.2.2 s + have hs' := congrFun h'.2.2.2 s + have ht := congrFun h.2.2.2 t + have ht' := congrFun h'.2.2.2 t + simp [unit,h.2.2.1,Ne.symm h.2.2.1] at hs ht + constructor + · by_contra he + simp only [unit,ite_eq_right he] at hs' + split_ifs at hs' <;> omega + · by_contra he + simp only [unit,ite_eq_right he] at ht' + split_ifs at ht' <;> omega + +theorem stateCoordinates_box (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (hX : Feasible U r c X) : + InBox (fun _ => (U:ℤ)) (stateCoordinates U r c X) := by + intro ⟨s,b⟩ + have h := hX.1 s.val + cases b <;> simp only [stateCoordinates,Bool.false_eq_true,ite_false,ite_true] <;> omega + +@[simp] theorem fullOccupancy_state (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : State m n) (s : SmallSlot U r c) : + fullOccupancy U r c (stateCoordinates U r c X) s = (U:ℤ)+X.x s.val-X.q s.val := by + simp [fullOccupancy,stateCoordinates] + ring + +theorem stateCoordinates_transverse_vertex (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : TransverseState U r c) : stateCoordinates U r c X.val∈fullVertices U r c := by + apply (mem_fullVertices U r c _).mpr + refine ⟨stateCoordinates_box U r c X.val X.property.1,Or.inl ?_⟩ + intro s + rw [fullOccupancy_state,show X.val.q=X.val.x from X.property.2] + omega + +theorem stateCoordinates_defect_vertex (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : DefectiveState U r c) : stateCoordinates U r c X.val∈fullVertices U r c := by + obtain ⟨s,t,hd⟩ := X.property.2 + apply (mem_fullVertices U r c _).mpr + refine ⟨stateCoordinates_box U r c X.val X.property.1,Or.inr ?_⟩ + refine ⟨⟨s,hd.1⟩,⟨t,hd.2.1⟩,?_,?_,?_,?_⟩ + · intro he; exact hd.2.2.1 (congrArg Subtype.val he) + · rw [fullOccupancy_state] + change (U:ℤ)+X.val.x s-X.val.q s=(U:ℤ)-1 + rw [hd.2.2.2] + simp [unit,hd.2.2.1] + ring + · rw [fullOccupancy_state] + change (U:ℤ)+X.val.x t-X.val.q t=(U:ℤ)+1 + rw [hd.2.2.2] + simp [unit,Ne.symm hd.2.2.1] + ring + · intro v hvs hvt + have hvs' : v.val≠s := fun he => hvs (Subtype.ext he) + have hvt' : v.val≠t := fun he => hvt (Subtype.ext he) + rw [fullOccupancy_state,hd.2.2.2] + simp [unit,hvs',hvt'] + +theorem state_kernel_weight (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (X : State m n) (hX : Feasible U r c X) : + smallKernel 0 U L C r c (stateCoordinates U r c X)=(weight U L r c X:ℝ) := by + classical + rw [weight,ite_eq_left hX] + exact smallKernel_zero_count U L C r c hrc X hX hC + +noncomputable def repairEdge (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X : DefectiveState U r c) : Sym2 (SmallCoord U r c → ℤ) := + s(stateCoordinates U r c X.val,stateCoordinates U r c (repairedState U r c X).val) + +theorem stateCoordinates_inj_feasible (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (X Y : State m n) (hX : Feasible U r c X) (hY : Feasible U r c Y) + (he : stateCoordinates U r c X=stateCoordinates U r c Y) : X=Y := by + have hh := congrArg (coordinatesState U r c) he + simpa only [coordinates_state_inverse U r c X hX.2.1, + coordinates_state_inverse U r c Y hY.2.1] using hh + +theorem repairEdge_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Function.Injective (repairEdge U r c) := by + intro X Y he + rcases Sym2.eq_iff.mp he with ⟨h,_⟩ | ⟨h,_⟩ + · exact Subtype.ext (stateCoordinates_inj_feasible U r c _ _ X.property.1 Y.property.1 h) + · have hh := stateCoordinates_inj_feasible U r c _ _ X.property.1 + (repairedState U r c Y).property.1 h + have ht : Transversal X.val := hh ▸ (repairedState U r c Y).property.2 + exact (defect_not_transversal U r c _ _ X.val (defectPair_spec U r c X) ht).elim + +noncomputable def fullRepairEdges (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finset (Sym2 (SmallCoord U r c → ℤ)) := by + classical + exact Finset.univ.image (repairEdge U r c) + + + +noncomputable def fullEdges (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Finset (Sym2 (SmallCoord U r c → ℤ)) := by + classical + exact fullUnitEdges U r c ∪ fullRepairEdges U r c + +noncomputable def graphEnergy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : ℝ := + ∑ e ∈ fullEdges U r c, edgeEnergy (smallKernel 0 U L C r c) + (H ∘ coordinatesState U r c) e + +theorem graphEnergy_nonneg (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : 0≤graphEnergy U L C r c H := + Finset.sum_nonneg fun e _ => edgeEnergy_nonneg _ _ (smallKernel_nonneg 0 (by positivity) U L C r c) e + +theorem unitEnergy_le_graphEnergy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : fullUnitEnergy U L C r c H ≤ graphEnergy U L C r c H := by + classical + apply Finset.sum_le_sum_of_subset_of_nonneg + · exact Finset.subset_union_left + · intro e _ _ + exact edgeEnergy_nonneg _ _ (smallKernel_nonneg 0 (by positivity) U L C r c) e + +theorem repairEdge_energy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (H : State m n → ℝ) (X : DefectiveState U r c) : + edgeEnergy (smallKernel 0 U L C r c) (H ∘ coordinatesState U r c) (repairEdge U r c X) = + (weight U L r c X.val:ℝ)*(H X.val-H (repairedState U r c X).val)^2 := by + change min (smallKernel 0 U L C r c (stateCoordinates U r c X.val)) + (smallKernel 0 U L C r c (stateCoordinates U r c (repairedState U r c X).val)) * + (H (coordinatesState U r c (stateCoordinates U r c X.val))- + H (coordinatesState U r c (stateCoordinates U r c (repairedState U r c X).val)))^2 = _ + rw [state_kernel_weight U L C r c hrc hC X.val X.property.1, + state_kernel_weight U L C r c hrc hC _ (repairedState U r c X).property.1, + coordinates_state_inverse U r c _ X.property.1.2.1, + coordinates_state_inverse U r c _ (repairedState U r c X).property.1.2.1] + rw [min_eq_left] + exact_mod_cast weight_repair_le U L r c _ _ X.val (defectPair_spec U r c X) + +theorem repairEnergy_le_graphEnergy (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (H : State m n → ℝ) : + (∑ X : DefectiveState U r c, + (weight U L r c X.val:ℝ)*(H X.val-H (repairedState U r c X).val)^2) ≤ + graphEnergy U L C r c H := by + classical + simp_rw [← repairEdge_energy U L C r c hrc hC H] + rw [← Finset.sum_image (fun X _ Y _ he => repairEdge_injective U r c he)] + apply Finset.sum_le_sum_of_subset_of_nonneg + · exact Finset.subset_union_right + · intro e _ _ + exact edgeEnergy_nonneg _ _ (smallKernel_nonneg 0 (by positivity) U L C r c) e + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +variable {m n : ℕ} + +def graphUnderlying (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + GraphState U r c → State m n := Sum.elim Subtype.val Subtype.val + +theorem graphUnderlying_injective (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) : + Function.Injective (graphUnderlying U r c) := by + intro X Y h + cases X with + | inl X => + cases Y with + | inl Y => exact congrArg Sum.inl (Subtype.ext h) + | inr Y => + change X.val=Y.val at h + have ht : Transversal Y.val := h ▸ X.property.2 + exact (defect_not_transversal U r c _ _ Y.val (defectPair_spec U r c Y) ht).elim + | inr X => + cases Y with + | inl Y => + change X.val=Y.val at h + have ht : Transversal X.val := h.symm ▸ Y.property.2 + exact (defect_not_transversal U r c _ _ X.val (defectPair_spec U r c X) ht).elim + | inr Y => exact congrArg Sum.inr (Subtype.ext h) + +noncomputable def graphVariance (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (H : State m n → ℝ) : ℝ := + weightedVariance (fun X : GraphState U r c => (weight U L r c (graphUnderlying U r c X):ℝ)) + (H ∘ graphUnderlying U r c) + + + +theorem graph_poincare_exact (U L C d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hU : 2 ≤ U) (hC2 : 2 ≤ C) (hd : 1 ≤ d) (hmn : m*n≤d) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i ≤ C) + (H : State m n → ℝ) : + graphVariance U L r c H ≤ ((1+2*(d:ℝ)^2)*4*(d:ℝ)^2*((U:ℝ)+1)^6+2)* + graphEnergy U L C r c H := by + let P := profileState U r c 0 (Fintype.card (SmallSlot U r c)) (by omega) Fin.elim0 + let wP := fun p => (weight U L r c (P p):ℝ) + let hP := H ∘ P + have hs : Fintype.card (SmallSlot U r c)≤d := by + have hh := Fintype.card_le_of_injective (smallRank U r c) (smallRank_injective U r c) + simp only [Fintype.card_fin] at hh + omega + have hv := concrete_transversal_variance U L C d r c hU hC2 hd hs hrc hC H + change weightedVariance wP hP ≤ _ at hv + have he := unitEnergy_le_graphEnergy U L C r c H + have hv' : weightedVariance wP hP ≤ 4*(d:ℝ)^2*((U:ℝ)+1)^6*graphEnergy U L C r c H := + hv.trans (mul_le_mul_of_nonneg_left he (by positivity)) + have hb := variance_repair_extension + (fun X : TransverseState U r c => (weight U L r c X.val:ℝ)) (fun X => H X.val) + (fun X : DefectiveState U r c => (weight U L r c X.val:ℝ)) (fun X => H X.val) + wP hP (fun X => by positivity) (fun X => by positivity) (fun p => by positivity) + (transverseProfile U r c) (transverseProfile_injective U r c) + (fun X => by simp [wP,P]) (fun X => by simp [hP,P]) + (taggedRepair U r c) (taggedRepair_injective U r c) + (fun X => by + dsimp [wP,P,taggedRepair] + rw [transverseProfile_state] + exact_mod_cast weight_repair_le U L r c _ _ X.val (defectPair_spec U r c X)) + (graphEnergy U L C r c H) (by + simpa only [hP,P,taggedRepair,Function.comp_apply,transverseProfile_state] using + repairEnergy_le_graphEnergy U L C r c hrc hC H) + have heq : graphVariance U L r c H = weightedVariance + (Sum.elim (fun X : TransverseState U r c => (weight U L r c X.val:ℝ)) + (fun X : DefectiveState U r c => (weight U L r c X.val:ℝ))) + (Sum.elim (fun X => H X.val) (fun X => H X.val)) := by + unfold graphVariance + congr 1 <;> funext X <;> cases X <;> rfl + rw [← heq] at hb + have hc : (Fintype.card (Cell m n × Cell m n):ℝ) ≤ (d:ℝ)^2 := by + simp only [Fintype.card_prod,Fintype.card_fin] + exact_mod_cast (show m*n*(m*n)≤d^2 by + simpa only [pow_two] using Nat.mul_self_le_mul_self hmn) + have hn := variance_nonneg wP hP (fun p => by positivity) + have hm := mul_le_mul_of_nonneg_right hc hn + have hv'' := mul_le_mul_of_nonneg_left hv' (show 0≤1+2*(d:ℝ)^2 by positivity) + nlinarith only [hb,hm,hv''] + +theorem poincare_constant_le (d U : ℕ) (hd : 1≤d) (hU : 1≤U) : + (1+2*(d:ℝ)^2)*4*(d:ℝ)^2*((U:ℝ)+1)^6+2 ≤ 770*(d:ℝ)^4*(U:ℝ)^6 := by + have hd' : (1:ℝ)≤d := by exact_mod_cast hd + have hU' : (1:ℝ)≤U := by exact_mod_cast hU + have hd2 : (1:ℝ)≤(d:ℝ)^2 := one_le_pow₀ hd' + have hd4 : (1:ℝ)≤(d:ℝ)^4 := one_le_pow₀ hd' + have hU6 : (1:ℝ)≤(U:ℝ)^6 := one_le_pow₀ hU' + have hu : ((U:ℝ)+1)^6≤64*(U:ℝ)^6 := by + calc + _ ≤ (2*(U:ℝ))^6 := by gcongr; linarith + _ = _ := by ring + calc + _ ≤ (3*(d:ℝ)^2)*4*(d:ℝ)^2*(64*(U:ℝ)^6)+2 := by + gcongr + nlinarith only [hd2] + _ ≤ _ := by nlinarith [mul_le_mul hd4 hU6 (by positivity) (by positivity)] + + +theorem graph_poincare (U L C d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (hU : 2≤U) (hC2 : 2≤C) (hd : 1≤d) (hmn : m*n≤d) + (hrc : (∑ i, r i)=∑ j, c j) (hC : ∀ i, paddedRow U L r c i≤C) + (H : State m n → ℝ) : + graphVariance U L r c H ≤ 770*(d:ℝ)^4*(U:ℝ)^6*graphEnergy U L C r c H := + (graph_poincare_exact U L C d r c hU hC2 hd hmn hrc hC H).trans + (mul_le_mul_of_nonneg_right (poincare_constant_le d U hd (by omega)) + (graphEnergy_nonneg U L C r c H)) + +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def graphCoordinates (X : GraphState U r c) : SmallCoord U r c → ℤ := + stateCoordinates U r c (graphUnderlying U r c X) + +theorem graph_feasible (X : GraphState U r c) : Feasible U r c (graphUnderlying U r c X) := by + cases X with + | inl X => exact X.property.1 + | inr X => exact X.property.1 + +theorem graphCoordinates_injective : Function.Injective (graphCoordinates U r c) := by + intro X Y h + apply graphUnderlying_injective U r c + exact stateCoordinates_inj_feasible U r c _ _ (graph_feasible U r c X) (graph_feasible U r c Y) h + +def GraphAdj (X Y : GraphState U r c) : Prop := + s(graphCoordinates U r c X,graphCoordinates U r c Y)∈fullEdges U r c + +noncomputable instance graphAdjDecidable : DecidableRel (GraphAdj U r c) := fun _ _ => Classical.propDecidable _ + +theorem GraphAdj.symm {X Y : GraphState U r c} (h : GraphAdj U r c X Y) : GraphAdj U r c Y X := by + simpa only [GraphAdj,Sym2.eq_swap] using h + +theorem GraphAdj.irrefl (X : GraphState U r c) : ¬GraphAdj U r c X X := by + classical + intro hh + rcases Finset.mem_union.mp hh with hu | hr + · obtain ⟨_,D,i,j,hij,he⟩ := Finset.mem_filter.mp hu + have he' : removeOne D i=removeOne D j := by + rcases Sym2.eq_iff.mp he with ⟨h1,h2⟩ | ⟨h1,h2⟩ + · exact h1.symm.trans h2 + · exact h2.symm.trans h1 + have h := congrFun he' i + simp [removeOne,hij] at h + · obtain ⟨Y,_,hy⟩ := Finset.mem_image.mp hr + have he' : stateCoordinates U r c Y.val=stateCoordinates U r c (repairedState U r c Y).val := by + rcases Sym2.eq_iff.mp hy with ⟨h1,h2⟩ | ⟨h1,h2⟩ <;> exact h1.trans h2.symm + have h := stateCoordinates_inj_feasible U r c _ _ Y.property.1 (repairedState U r c Y).property.1 he' + exact defect_not_transversal U r c _ _ Y.val (defectPair_spec U r c Y) (h ▸ (repairedState U r c Y).property.2) + +def unitCandidates (X : GraphState U r c) : Finset (SmallCoord U r c → ℤ) := by + classical + exact Finset.univ.image (fun ij : SmallCoord U r c × SmallCoord U r c => + fun w => graphCoordinates U r c X w + (if w=ij.1 then 1 else 0) - (if w=ij.2 then 1 else 0)) + +def outgoing (X : GraphState U r c) : Finset (GraphState U r c) := by + classical + exact match X with | .inl _ => ∅ | .inr Y => {Sum.inl (repairedState U r c Y)} + +def incomingDefects (X : GraphState U r c) : Finset (DefectiveState U r c) := by + classical + exact Finset.univ.filter (fun Y => Sum.inl (repairedState U r c Y)=X) + +theorem incoming_card (X : GraphState U r c) : (incomingDefects U r c X).card≤(m*n)^2 := by + classical + have hi : Set.InjOn (defectPair U r c) (incomingDefects U r c X : Set _) := by + intro Y hY Z hZ h + apply taggedRepair_injective U r c + apply Prod.ext h + have hY' := (Finset.mem_filter.mp hY).2 + have hZ' := (Finset.mem_filter.mp hZ).2 + have he := Sum.inl.inj (hY'.trans hZ'.symm) + exact congrArg (transverseProfile U r c) he + have hh := Finset.card_le_card_of_injOn (defectPair U r c) (s:=incomingDefects U r c X) + (t:=Finset.univ) (fun _ _ => Finset.mem_univ _) hi + simpa [Cell,Fintype.card_prod,pow_two] using hh + +theorem neighbors_cover (X Y : GraphState U r c) (h : GraphAdj U r c X Y) : + graphCoordinates U r c Y∈unitCandidates U r c X ∨ + Y∈outgoing U r c X ∨ Y∈(incomingDefects U r c X).image Sum.inr := by + classical + rcases Finset.mem_union.mp h with hu | hr + · left + obtain ⟨_,D,i,j,hij,he⟩ := Finset.mem_filter.mp hu + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · apply Finset.mem_image.mpr + refine ⟨(i,j),Finset.mem_univ _,?_⟩ + funext w + rw [hx,hy] + simp only [removeOne] + ring + · apply Finset.mem_image.mpr + refine ⟨(j,i),Finset.mem_univ _,?_⟩ + funext w + rw [hx,hy] + simp only [removeOne] + ring + · obtain ⟨Z,_,he⟩ := Finset.mem_image.mp hr + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · have hx' : Sum.inr Z=X := graphCoordinates_injective U r c hx + have hy' : Sum.inl (repairedState U r c Z)=Y := graphCoordinates_injective U r c hy + right; left + rw [← hx',← hy']; simp [outgoing] + · have hx' : Sum.inr Z=Y := graphCoordinates_injective U r c hx + have hy' : Sum.inl (repairedState U r c Z)=X := graphCoordinates_injective U r c hy + right; right + exact Finset.mem_image.mpr ⟨Z,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hy'⟩,hx'⟩ + + + +theorem graph_degree (d : ℕ) (hmn : m*n≤d) (X : GraphState U r c) : + (Finset.univ.filter (GraphAdj U r c X)).card≤5*d^2+1 := by + classical + let A := Finset.univ.filter (fun Y => graphCoordinates U r c Y∈unitCandidates U r c X) + let B := outgoing U r c X + let C : Finset (GraphState U r c) := (incomingDefects U r c X).image Sum.inr + have hsub : Finset.univ.filter (GraphAdj U r c X) ⊆ A ∪ B ∪ C := by + intro Y hY + rcases neighbors_cover U r c X Y (Finset.mem_filter.mp hY).2 with h | h | h + · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨Finset.mem_univ _,h⟩)) + · exact Finset.mem_union_left _ (Finset.mem_union_right _ h) + · exact Finset.mem_union_right _ h + have ha : A.card≤4*d^2 := by + have hh := Finset.card_le_card_of_injOn (graphCoordinates U r c) + (s:=A) (t:=unitCandidates U r c X) (fun _ h => (Finset.mem_filter.mp h).2) + (fun _ _ _ _ h => graphCoordinates_injective U r c h) + have hc : (unitCandidates U r c X).card≤(Fintype.card (SmallCoord U r c))^2 := by + simpa [unitCandidates,Fintype.card_prod,pow_two] using (Finset.card_image_le + (s:=(Finset.univ : Finset (SmallCoord U r c × SmallCoord U r c))) + (f:=fun ij => fun w => graphCoordinates U r c X w+(if w=ij.1 then (1:ℤ) else 0)-(if w=ij.2 then 1 else 0))) + have hs : Fintype.card (SmallSlot U r c)≤d := by + have hh := Fintype.card_le_of_injective (smallRank U r c) (smallRank_injective U r c) + simp only [Fintype.card_fin] at hh + omega + have hc' : Fintype.card (SmallCoord U r c)≤2*d := by + simp only [SmallCoord,Fintype.card_prod,Fintype.card_bool] + omega + exact hh.trans (hc.trans (by nlinarith)) + have hb : B.card≤1 := by cases X <;> simp [B,outgoing] + have hc : C.card≤d^2 := by + exact Finset.card_image_le.trans ((incoming_card U r c X).trans (Nat.pow_le_pow_left hmn 2)) + exact (Finset.card_le_card hsub).trans ((Finset.card_union_le _ _).trans (by + have hh := Finset.card_union_le A B + omega)) + +end +end Contingency.PaddedGraph + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/ResidualMargins.lean b/lean/OAI/Probability/Contingency/ResidualMargins.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9929779cc5e485b09190f65948f6907b47f6cd6 --- /dev/null +++ b/lean/OAI/Probability/Contingency/ResidualMargins.lean @@ -0,0 +1,618 @@ +import Mathlib +import OAI.Probability.Contingency.RepairVariance + +namespace OAI + +/-! Residual Margins. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def residualRow (X : State m n) (i : Fin m) : ℤ := r i-rowSum X.x i+rowPadding U L r c i +def residualCol (X : State m n) (j : Fin n) : ℤ := c j-colSum X.q j+colPadding U L r c j + +theorem residualRow_nonneg (X : State m n) (hX : Feasible U r c X) (i : Fin m) : + 0≤residualRow U L r c X i := by + have hp : 0≤rowPadding U L r c i := Finset.sum_nonneg (fun _ _ => by split_ifs <;> positivity) + have hh := (hX.2.2.1 i).1 + dsimp [residualRow]; omega + +theorem residualCol_nonneg (X : State m n) (hX : Feasible U r c X) (j : Fin n) : + 0≤residualCol U L r c X j := by + have hp : 0≤colPadding U L r c j := Finset.sum_nonneg (fun _ _ => by split_ifs <;> positivity) + have hh := (hX.2.2.2 j).1 + dsimp [residualCol]; omega + +theorem residualRow_zero (X : State m n) (hX : Feasible U r c X) (i : Fin m) + (hi : r i by have h : U≤r i := h.1; omega + simp only [residualRow,(hX.2.2.1 i).2 he,sub_self,zero_add,rowPadding,ite_eq_right (he _),Finset.sum_const_zero] + +theorem residualCol_zero (X : State m n) (hX : Feasible U r c X) (j : Fin n) + (hj : c j by have h : U≤c j := h.2; omega + simp only [residualCol,(hX.2.2.2 j).2 he,sub_self,zero_add,colPadding,ite_eq_right (he _),Finset.sum_const_zero] + +theorem graph_small_totals (X : GraphState U r c) : + (∑ w,(graphUnderlying U r c X).x w)=∑ w,(graphUnderlying U r c X).q w := by + cases X with + | inl X => rw [show (graphUnderlying U r c (.inl X)).q=X.val.x from X.property.2]; rfl + | inr X => + change (∑ w,X.val.x w)=∑ w,X.val.q w + rw [(defectPair_spec U r c X).2.2.2] + simp only [Finset.sum_add_distrib,Finset.sum_sub_distrib,unit] + simp + +theorem residual_totals (X : GraphState U r c) (hrc : (∑ i,r i)=∑ j,c j) : + (∑ i,residualRow U L r c (graphUnderlying U r c X) i)= + ∑ j,residualCol U L r c (graphUnderlying U r c X) j := by + have ht := graph_small_totals U r c X + have hp := padding_totals U L r c + have hr : (∑ i,(r i:ℤ))=∑ j,(c j:ℤ) := by exact_mod_cast hrc + simp only [residualRow,residualCol,Finset.sum_add_distrib,Finset.sum_sub_distrib] + rw [hr,hp] + congr 2 + simp only [rowSum,colSum] + rw [← Fintype.sum_prod_type,Finset.sum_comm,← Fintype.sum_prod_type] + exact ht + +def rowNat (X : State m n) (i : Fin m) : ℕ := (residualRow U L r c X i).toNat +def colNat (X : State m n) (j : Fin n) : ℕ := (residualCol U L r c X j).toNat + +@[simp] theorem rowNat_cast (X : State m n) (hX : Feasible U r c X) (i : Fin m) : + (rowNat U L r c X i:ℤ)=residualRow U L r c X i := Int.toNat_of_nonneg (residualRow_nonneg U L r c X hX i) +@[simp] theorem colNat_cast (X : State m n) (hX : Feasible U r c X) (j : Fin n) : + (colNat U L r c X j:ℤ)=residualCol U L r c X j := Int.toNat_of_nonneg (residualCol_nonneg U L r c X hX j) + +def completionTable (X : State m n) (hX : Feasible U r c X) (A : Completion U L r c X) : + Tables (rowNat U L r c X) (colNat U L r c X) := by + refine ⟨fun i j => (A.val (i,j)).toNat,?_,?_⟩ + · intro i + apply Int.ofNat_inj.mp + push_cast + simp only [Int.toNat_of_nonneg (A.property.1 _),rowNat_cast U L r c X hX] + exact A.property.2.2.1 i + · intro j + apply Int.ofNat_inj.mp + push_cast + simp only [Int.toNat_of_nonneg (A.property.1 _),colNat_cast U L r c X hX] + exact A.property.2.2.2 j + +def tableCompletion (X : State m n) (hX : Feasible U r c X) + (A : Tables (rowNat U L r c X) (colNat U L r c X)) : Completion U L r c X := by + refine ⟨fun w => (A.val w.1 w.2:ℤ),fun _ => by positivity,?_,?_,?_⟩ + · intro ⟨i,j⟩ h + have h : ¬(U≤r i ∧ U≤c j) := h + have hz : A.val i j=0 := by + by_cases hi : U≤r i + · have hj : c j Nat.zero_le (A.val i j)) (Finset.mem_univ i) + omega + · have hi : r i Nat.zero_le (A.val i j)) (Finset.mem_univ j) + omega + simp [hz] + · intro i + change (∑ j,(A.val i j:ℤ))=residualRow U L r c X i + rw [← Nat.cast_sum,A.property.1,rowNat_cast U L r c X hX] + · intro j + change (∑ i,(A.val i j:ℤ))=residualCol U L r c X j + rw [← Nat.cast_sum,A.property.2,colNat_cast U L r c X hX] + + + +def completionTableEquiv (X : State m n) (hX : Feasible U r c X) : + Completion U L r c X ≃ Tables (rowNat U L r c X) (colNat U L r c X) where + toFun := completionTable U L r c X hX + invFun := tableCompletion U L r c X hX + left_inv A := by + apply Subtype.ext; funext w + exact Int.toNat_of_nonneg (A.property.1 w) + right_inv A := by apply Subtype.ext; funext i j; simp [completionTable,tableCompletion] + +theorem completion_nonempty (X : GraphState U r c) (hrc : (∑ i,r i)=∑ j,c j) : + Nonempty (Completion U L r c (graphUnderlying U r c X)) := by + have hf := graph_feasible U r c X + have ht : (∑ i,rowNat U L r c (graphUnderlying U r c X) i)= + ∑ j,colNat U L r c (graphUnderlying U r c X) j := by + apply Int.ofNat_inj.mp + push_cast + simp only [rowNat_cast U L r c _ hf,colNat_cast U L r c _ hf] + exact residual_totals U L r c X hrc + obtain ⟨A⟩ := tables_nonempty _ _ ht + exact ⟨(completionTableEquiv U L r c _ hf).symm A⟩ + +theorem graph_weight_pos (X : GraphState U r c) (hrc : (∑ i,r i)=∑ j,c j) : + 0 p w+t*(if w=z then 1 else 0) + +theorem shift_x (p : SmallCoord U r c → ℤ) (z : SmallCoord U r c) (t : ℤ) (w : Cell m n) : + (coordinatesState U r c (shiftCoord U r c p z t)).x w= + (coordinatesState U r c p).x w+(if z.2 then t*unit z.1.val w else 0) := by + rcases z with ⟨s,b⟩ + by_cases hw : IsSmall U r c w + · cases b <;> simp [coordinatesState,shiftCoord,hw,unit,Subtype.ext_iff] + · have hne : w≠s.val := fun h => hw (h ▸ s.property) + cases b <;> simp [coordinatesState,shiftCoord,hw,unit,hne] + +theorem shift_q (p : SmallCoord U r c → ℤ) (z : SmallCoord U r c) (t : ℤ) (w : Cell m n) : + (coordinatesState U r c (shiftCoord U r c p z t)).q w= + (coordinatesState U r c p).q w-(if z.2 then 0 else t*unit z.1.val w) := by + rcases z with ⟨s,b⟩ + by_cases hw : IsSmall U r c w + · cases b <;> simp [coordinatesState,shiftCoord,hw,unit,Subtype.ext_iff] + ring + · have hne : w≠s.val := fun h => hw (h ▸ s.property) + cases b <;> simp [coordinatesState,shiftCoord,hw,unit,hne] + +theorem shift_row (p : SmallCoord U r c → ℤ) (z : SmallCoord U r c) (t : ℤ) (i : Fin m) : + rowSum (coordinatesState U r c (shiftCoord U r c p z t)).x i= + rowSum (coordinatesState U r c p).x i+(if z.2 then t*(if i=z.1.val.1 then 1 else 0) else 0) := by + simp only [rowSum,shift_x,Finset.sum_add_distrib] + rw [Finset.sum_ite_irrel] + congr 1 + rw [← Finset.mul_sum] + simp only [Finset.sum_const_zero] + change (if z.2 then t*rowSum (unit z.1.val) i else 0)=_ + rw [rowSum_unit] + +theorem shift_col (p : SmallCoord U r c → ℤ) (z : SmallCoord U r c) (t : ℤ) (j : Fin n) : + colSum (coordinatesState U r c (shiftCoord U r c p z t)).q j= + colSum (coordinatesState U r c p).q j-(if z.2 then 0 else t*(if j=z.1.val.2 then 1 else 0)) := by + simp only [colSum,shift_q,Finset.sum_sub_distrib] + rw [Finset.sum_ite_irrel] + congr 1 + rw [← Finset.mul_sum] + simp only [Finset.sum_const_zero] + change (if z.2 then 0 else t*colSum (unit z.1.val) j)=_ + rw [colSum_unit] + +theorem unit_margin_movement (X Y : State m n) (hX : Feasible U r c X) (hY : Feasible U r c Y) + (hu : s(stateCoordinates U r c X,stateCoordinates U r c Y)∈fullUnitEdges U r c) : + (∀ i,|residualRow U L r c Y i-residualRow U L r c X i|≤2) ∧ + (∀ j,|residualCol U L r c Y j-residualCol U L r c X j|≤2) := by + classical + have hh : ∃ i j,stateCoordinates U r c Y = + shiftCoord U r c (shiftCoord U r c (stateCoordinates U r c X) i 1) j (-1) := by + obtain ⟨_,D,i,j,hij,he⟩ := Finset.mem_filter.mp hu + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · refine ⟨i,j,?_⟩ + rw [hx,hy]; funext w; simp only [shiftCoord,removeOne]; ring + · refine ⟨j,i,?_⟩ + rw [hx,hy]; funext w; simp only [shiftCoord,removeOne]; ring + obtain ⟨s,t,he⟩ := hh + have hstate := congrArg (coordinatesState U r c) he + rw [coordinates_state_inverse U r c Y hY.2.1] at hstate + constructor + · intro i + have hh := congrArg (fun Z : State m n => rowSum Z.x i) hstate + rw [shift_row,shift_row,coordinates_state_inverse U r c X hX.2.1] at hh + dsimp [residualRow] + rw [hh] + rw [abs_le] + split_ifs <;> omega + · intro j + have hh := congrArg (fun Z : State m n => colSum Z.q j) hstate + rw [shift_col,shift_col,coordinates_state_inverse U r c X hX.2.1] at hh + dsimp [residualCol] + rw [hh] + rw [abs_le] + split_ifs <;> omega + +theorem repair_margin_movement (X : DefectiveState U r c) : + (∀ i,|residualRow U L r c (repairedState U r c X).val i-residualRow U L r c X.val i|≤2) ∧ + (∀ j,|residualCol U L r c (repairedState U r c X).val j-residualCol U L r c X.val j|≤2) := by + constructor + · intro i + dsimp [residualRow,repairedState] + rw [repair_rowSum,abs_le] + split_ifs <;> omega + · intro j + dsimp [residualCol,repairedState] + rw [repair_colSum U r c _ _ _ (defectPair_spec U r c X),abs_le] + split_ifs <;> omega + + +theorem graph_margin_movement (X Y : GraphState U r c) (h : GraphAdj U r c X Y) : + (∀ i,|residualRow U L r c (graphUnderlying U r c Y) i- + residualRow U L r c (graphUnderlying U r c X) i|≤2) ∧ + (∀ j,|residualCol U L r c (graphUnderlying U r c Y) j- + residualCol U L r c (graphUnderlying U r c X) j|≤2) := by + classical + rcases Finset.mem_union.mp h with hu | hr + · exact unit_margin_movement U L r c _ _ (graph_feasible U r c X) (graph_feasible U r c Y) hu + · obtain ⟨Z,_,he⟩ := Finset.mem_image.mp hr + rcases Sym2.eq_iff.mp he with ⟨hx,hy⟩ | ⟨hx,hy⟩ + · have hx' : Sum.inr Z=X := graphCoordinates_injective U r c hx + have hy' : Sum.inl (repairedState U r c Z)=Y := graphCoordinates_injective U r c hy + rw [← hx',← hy'] + exact repair_margin_movement U L r c Z + · have hx' : Sum.inr Z=Y := graphCoordinates_injective U r c hx + have hy' : Sum.inl (repairedState U r c Z)=X := graphCoordinates_injective U r c hy + rw [← hx',← hy'] + simpa only [graphUnderlying,Sum.elim_inl,Sum.elim_inr,abs_sub_comm] using repair_margin_movement U L r c Z + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +theorem pattern_graphState (p : SmallCoord U r c → ℤ) + (hp : fullPattern U r c p) (hf : Feasible U r c (coordinatesState U r c p)) : + ∃ X : GraphState U r c,graphCoordinates U r c X=p := by + rcases hp with ht | ⟨s,t,hst,hs,ht,ho⟩ + · have hT : Transversal (coordinatesState U r c p) := by + funext w + by_cases hw : IsSmall U r c w + · have hh := ht ⟨w,hw⟩ + simp only [fullOccupancy] at hh + simp only [coordinatesState,dite_eq_left hw] + omega + · simp [coordinatesState,hw] + exact ⟨Sum.inl ⟨_,hf,hT⟩,stateCoordinates_coordinatesState U r c p⟩ + · have hD : DefectAt U r c s.val t.val (coordinatesState U r c p) := by + refine ⟨s.property,t.property,fun h => hst (Subtype.ext h),?_⟩ + funext w + by_cases hw : IsSmall U r c w + · simp only [coordinatesState,dite_eq_left hw] + by_cases hws : w=s.val + · subst w + have hst' : s.val≠t.val := fun h => hst (Subtype.ext h) + simp only [unit,ite_true,ite_eq_right hst'] + change (U:ℤ)-p (s,false)=p (s,true)-0+1 + dsimp [fullOccupancy] at hs + omega + · by_cases hwt : w=t.val + · subst w + simp only [unit,ite_eq_right hws,ite_true] + change (U:ℤ)-p (t,false)=p (t,true)-1+0 + dsimp [fullOccupancy] at ht + omega + · have hh := ho ⟨w,hw⟩ (fun h => hws (congrArg Subtype.val h)) + (fun h => hwt (congrArg Subtype.val h)) + simp only [fullOccupancy] at hh + simp only [unit,ite_eq_right hws,ite_eq_right hwt] + omega + · have hws : w≠s.val := fun h => hw (h ▸ s.property) + have hwt : w≠t.val := fun h => hw (h ▸ t.property) + simp [coordinatesState,hw,unit,hws,hwt] + exact ⟨Sum.inr ⟨_,hf,s.val,t.val,hD⟩,stateCoordinates_coordinatesState U r c p⟩ + +theorem positive_vertex (p : SmallCoord U r c → ℤ) (hv : p∈fullVertices U r c) + (hp : smallKernel 0 U L C r c p≠0) : + ∃ X : GraphState U r c,graphCoordinates U r c X=p := by + apply pattern_graphState U r c p ((mem_fullVertices U r c p).mp hv).2 + by_contra hf + exact hp (smallKernel_zero_infeasible U L C r c p hf) + +theorem positive_edge (H : State m n → ℝ) (e : Sym2 (SmallCoord U r c → ℤ)) + (he : e∈fullEdges U r c) + (hp : edgeEnergy (smallKernel 0 U L C r c) (H ∘ coordinatesState U r c) e≠0) : + ∃ X Y : GraphState U r c,e=s(graphCoordinates U r c X,graphCoordinates U r c Y) := by + classical + rcases Finset.mem_union.mp he with hu | hr + · induction e using Sym2.inductionOn with | _ p q => + have hv := Finset.mem_filter.mp hu + have hpq := Finset.mk_mem_sym2_iff.mp hv.1 + have hn := smallKernel_nonneg 0 (by positivity) U L C r c + have hkp : smallKernel 0 U L C r c p≠0 := by + intro h + apply hp + rw [edgeEnergy_mk] + rw [h,min_eq_left (hn q),zero_mul] + have hkq : smallKernel 0 U L C r c q≠0 := by + intro h + apply hp + rw [edgeEnergy_mk] + rw [h,min_eq_right (hn p),zero_mul] + obtain ⟨X,hX⟩ := positive_vertex U L C r c p hpq.1 hkp + obtain ⟨Y,hY⟩ := positive_vertex U L C r c q hpq.2 hkq + exact ⟨X,Y,by rw [hX,hY]⟩ + · obtain ⟨Z,_,hz⟩ := Finset.mem_image.mp hr + exact ⟨Sum.inr Z,Sum.inl (repairedState U r c Z),hz.symm⟩ + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +open PaddedGraph +variable {m n : ℕ} + +def tableInt {r : Fin m → ℕ} {c : Fin n → ℕ} (X : Tables r c) (w : Cell m n) : ℤ := + X.val w.1 w.2 + +@[simp] theorem tableInt_row {r : Fin m → ℕ} {c : Fin n → ℕ} (X : Tables r c) (i : Fin m) : + rowSum (tableInt X) i = r i := by + unfold rowSum tableInt + exact_mod_cast X.property.1 i +@[simp] theorem tableInt_col {r : Fin m → ℕ} {c : Fin n → ℕ} (X : Tables r c) (j : Fin n) : + colSum (tableInt X) j = c j := by + unfold colSum tableInt + exact_mod_cast X.property.2 j + +def switchDirection (i i' : Fin m) (j j' : Fin n) : Cell m n → ℤ := + fun w => unit (i,j) w+unit (i',j') w-unit (i,j') w-unit (i',j) w + +@[simp] theorem switchDirection_row (i i' : Fin m) (j j' : Fin n) (k : Fin m) : + rowSum (switchDirection i i' j j') k=0 := by + simp only [switchDirection,rowSum,Finset.sum_sub_distrib,Finset.sum_add_distrib] + change rowSum (unit (i,j)) k+rowSum (unit (i',j')) k- + rowSum (unit (i,j')) k-rowSum (unit (i',j)) k=0 + simp + +@[simp] theorem switchDirection_col (i i' : Fin m) (j j' : Fin n) (k : Fin n) : + colSum (switchDirection i i' j j') k=0 := by + simp only [switchDirection,colSum,Finset.sum_sub_distrib,Finset.sum_add_distrib] + change colSum (unit (i,j)) k+colSum (unit (i',j')) k- + colSum (unit (i,j')) k-colSum (unit (i',j)) k=0 + simp + +@[simp] theorem switchDirection_mark (i i' : Fin m) (j j' : Fin n) + (hi : i≠i') (hj : j≠j') : switchDirection i i' j j' (i,j)=1 := by + simp [switchDirection,unit,hi,hj] + +theorem switch_nonneg {r : Fin m → ℕ} {c : Fin n → ℕ} + (X : Tables r c) (i i' : Fin m) (j j' : Fin n) (hi : i≠i') (hj : j≠j') + (v : ℕ) (hr : v≤X.val i j') (hc : v≤X.val i' j) (w : Cell m n) : + 0 ≤ tableInt X w+(v:ℤ)*switchDirection i i' j j' w := by + have h0 : 0≤tableInt X w := by unfold tableInt; positivity + by_cases hw : w=(i,j') + · subst w + simp [switchDirection,unit,hi,Ne.symm hj,tableInt] + exact_mod_cast hr + · by_cases hw' : w=(i',j) + · subst w + simp [switchDirection,unit,Ne.symm hi,hj,tableInt] + exact_mod_cast hc + · simp only [switchDirection,unit,ite_eq_right hw,ite_eq_right hw',sub_zero] + split_ifs <;> omega + + + +noncomputable def switchTable {r : Fin m → ℕ} {c : Fin n → ℕ} + (X : Tables r c) (i i' : Fin m) (j j' : Fin n) (hi : i≠i') (hj : j≠j') + (v : ℕ) (hr : v≤X.val i j') (hc : v≤X.val i' j) : Tables r c := + ⟨fun a b => (tableInt X (a,b)+(v:ℤ)*switchDirection i i' j j' (a,b)).toNat, by + constructor + · intro a + have hn (b) := switch_nonneg X i i' j j' hi hj v hr hc (a,b) + have he : (∑ b, (tableInt X (a,b)+(v:ℤ)*switchDirection i i' j j' (a,b))) = r a := by + rw [Finset.sum_add_distrib,← Finset.mul_sum] + change rowSum (tableInt X) a+(v:ℤ)*rowSum (switchDirection i i' j j') a= r a + simp + exact_mod_cast (show (∑ b, ((tableInt X (a,b)+(v:ℤ)*switchDirection i i' j j' (a,b)).toNat:ℤ)) = r a by + simpa only [Int.toNat_of_nonneg (hn _)] using he) + · intro b + have hn (a) := switch_nonneg X i i' j j' hi hj v hr hc (a,b) + have he : (∑ a, (tableInt X (a,b)+(v:ℤ)*switchDirection i i' j j' (a,b))) = c b := by + rw [Finset.sum_add_distrib,← Finset.mul_sum] + change colSum (tableInt X) b+(v:ℤ)*colSum (switchDirection i i' j j') b= c b + simp + exact_mod_cast (show (∑ a, ((tableInt X (a,b)+(v:ℤ)*switchDirection i i' j j' (a,b)).toNat:ℤ)) = c b by + simpa only [Int.toNat_of_nonneg (hn _)] using he)⟩ + +@[simp] theorem switchTable_int {r : Fin m → ℕ} {c : Fin n → ℕ} + (X : Tables r c) (i i' : Fin m) (j j' : Fin n) (hi : i≠i') (hj : j≠j') + (v : ℕ) (hr : v≤X.val i j') (hc : v≤X.val i' j) (w : Cell m n) : + tableInt (switchTable X i i' j j' hi hj v hr hc) w = + tableInt X w+(v:ℤ)*switchDirection i i' j j' w := by + exact Int.toNat_of_nonneg (switch_nonneg X i i' j j' hi hj v hr hc w) + +theorem switch_injective_with_labels {r : Fin m → ℕ} {c : Fin n → ℕ} + (X Y : Tables r c) (i i' : Fin m) (j j' : Fin n) (hi : i≠i') (hj : j≠j') + (v u : ℕ) (hrX : v≤X.val i j') (hcX : v≤X.val i' j) + (hrY : u≤Y.val i j') (hcY : u≤Y.val i' j) + (hs : X.val i j=Y.val i j) + (he : switchTable X i i' j j' hi hj v hrX hcX = + switchTable Y i i' j j' hi hj u hrY hcY) : X=Y ∧ v=u := by + have hm := congrArg (fun Z => tableInt Z (i,j)) he + change tableInt (switchTable X i i' j j' hi hj v hrX hcX) (i,j) = + tableInt (switchTable Y i i' j j' hi hj u hrY hcY) (i,j) at hm + rw [switchTable_int,switchTable_int,switchDirection_mark i i' j j' hi hj] at hm + simp only [mul_one,tableInt,hs] at hm + have hv : v=u := by omega + subst u + refine ⟨?_,rfl⟩ + apply Subtype.ext + funext a b + have hh := congrArg (fun Z => tableInt Z (a,b)) he + change tableInt (switchTable X i i' j j' hi hj v hrX hcX) (a,b) = + tableInt (switchTable Y i i' j j' hi hj v hrY hcY) (a,b) at hh + rw [switchTable_int,switchTable_int] at hh + simp only [tableInt] at hh + omega + +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +variable {m n : ℕ} + + + +theorem line_donor (d a t : ℕ) (x : Fin n → ℕ) (j : Fin n) + (hn : n≤d) (ha : a≤∑ k, x k) (ht : 2*t≤a) (hj : x j X.val.val k j) i hm (X.val.property.2 j ▸ ha) ht X.property).choose + +theorem colDonor_spec (d a t : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (i : Fin m) (j : Fin n) (hm : m≤d) (ha : a≤c j) (ht : 2*t≤a) + (X : SmallEntryBad r c i j t) : + colDonor d a t r c i j hm ha ht X≠i ∧ + a/(2*d)≤X.val.val (colDonor d a t r c i j hm ha ht X) j := + (line_donor d a t (fun k => X.val.val k j) i hm (X.val.property.2 j ▸ ha) ht X.property).choose_spec + +noncomputable def smallEntryMoves (d a t : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (i : Fin m) (j : Fin n) (hm : m≤d) (hn : n≤d) (hr : a≤r i) (hc : a≤c j) (ht : 2*t≤a) + (z : SmallEntryBad r c i j t × Fin (a/(2*d))) : Tables r c × (Cell m n × Fin t) := + let i' := colDonor d a t r c i j hm hc ht z.1 + let j' := rowDonor d a t r c i j hn hr ht z.1 + let hi := colDonor_spec d a t r c i j hm hc ht z.1 + let hj := rowDonor_spec d a t r c i j hn hr ht z.1 + (switchTable z.1.val i i' j j' hi.1.symm hj.1.symm (z.2.val+1) + (by exact (Nat.add_one_le_iff.mpr z.2.isLt).trans hj.2) + (by exact (Nat.add_one_le_iff.mpr z.2.isLt).trans hi.2), + ((i',j'),⟨z.1.val.val i j,z.1.property⟩)) + +theorem smallEntryMoves_injective (d a t : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (i : Fin m) (j : Fin n) (hm : m≤d) (hn : n≤d) (hr : a≤r i) (hc : a≤c j) (ht : 2*t≤a) : + Function.Injective (smallEntryMoves d a t r c i j hm hn hr hc ht) := by + rintro ⟨X,v⟩ ⟨Y,u⟩ he + have hi : colDonor d a t r c i j hm hc ht X=colDonor d a t r c i j hm hc ht Y := + congrArg (fun z => z.2.1.1) he + have hj : rowDonor d a t r c i j hn hr ht X=rowDonor d a t r c i j hn hr ht Y := + congrArg (fun z => z.2.1.2) he + have hs : X.val.val i j=Y.val.val i j := congrArg (fun z => z.2.2.val) he + have htab := congrArg Prod.fst he + dsimp only [smallEntryMoves] at htab + have he' := congrArg (fun Z : Tables r c => tableInt Z (i,j)) htab + + change tableInt (switchTable _ _ _ _ _ _ _ _ _ _) (i,j) = + tableInt (switchTable _ _ _ _ _ _ _ _ _ _) (i,j) at he' + rw [switchTable_int,switchTable_int, + switchDirection_mark _ _ _ _ (colDonor_spec d a t r c i j hm hc ht X).1.symm + (rowDonor_spec d a t r c i j hn hr ht X).1.symm, + switchDirection_mark _ _ _ _ (colDonor_spec d a t r c i j hm hc ht Y).1.symm + (rowDonor_spec d a t r c i j hn hr ht Y).1.symm] at he' + simp only [tableInt,hs,mul_one] at he' + have hv : v=u := Fin.ext (by omega) + subst u + have hXY : X=Y := by + apply Subtype.ext + apply Subtype.ext + funext k l + have h := congrArg (fun Z : Tables r c => tableInt Z (k,l)) htab + change tableInt (switchTable _ _ _ _ _ _ _ _ _ _) (k,l) = + tableInt (switchTable _ _ _ _ _ _ _ _ _ _) (k,l) at h + rw [switchTable_int,switchTable_int,hi,hj] at h + simp only [tableInt] at h + omega + subst Y + rfl + +theorem small_entry_count_floor (d a t : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (i : Fin m) (j : Fin n) (hm : m≤d) (hn : n≤d) (hr : a≤r i) (hc : a≤c j) (ht : 2*t≤a) : + Nat.card (SmallEntryBad r c i j t)*(a/(2*d)) ≤ Nat.card (Tables r c)*(m*n*t) := by + have hh := Nat.card_le_card_of_injective _ (smallEntryMoves_injective d a t r c i j hm hn hr hc ht) + simpa only [Nat.card_prod,Nat.card_fin] using hh + +theorem floor_donor_lower (d a : ℕ) (hd : 1≤d) (ha : 4*d≤a) : + a≤4*d*(a/(2*d)) := by + have hq : 0 fun _ => 0 + | n+1, f => fun p => balancedMarginal (allBalance C n f) (C+1) p + + balancedMarginal (allSurplus C n f) C p + +section NonnegativeKernels +variable {ι : Type u} + +theorem allBalance_nonneg (C n : ℕ) (f : (PairCoords ι n → ℤ) → ℝ) + (hf : ∀ x, 0 ≤ f x) : ∀ p, 0 ≤ allBalance C n f p := by + induction n generalizing ι with + | zero => exact hf + | succ n ih => + intro p + change 0 ≤ balancedMarginal (allBalance C n f) C p + unfold balancedMarginal + exact Finset.sum_nonneg (fun j _ => ih f hf _) + +theorem allSurplus_nonneg (C n : ℕ) (f : (PairCoords ι n → ℤ) → ℝ) + (hf : ∀ x, 0 ≤ f x) : ∀ p, 0 ≤ allSurplus C n f p := by + induction n generalizing ι with + | zero => intro p; exact le_rfl + | succ n ih => + intro p + exact add_nonneg + (Finset.sum_nonneg (fun j _ => allBalance_nonneg C n f hf _)) + (Finset.sum_nonneg (fun j _ => ih f hf _)) + +theorem raisedFull_le_surplus (f : (ι ⊕ Bool → ℤ) → ℝ) (C : ℕ) + (hf : ∀ x, 0 ≤ f x) (p : ι → ℤ) : + raisedFull f C p ≤ ((C:ℝ)+1)^2 * balancedMarginal f (C+1) p := by + unfold raisedFull balancedMarginal + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro j hj + have hj' : j ≤ C+1 := by exact Nat.le_of_lt_succ (Finset.mem_range.mp hj) + have hrj : (j:ℝ) ≤ (C:ℝ)+1 := by exact_mod_cast hj' + have hj0 : 0 ≤ (j:ℝ) := Nat.cast_nonneg _ + have hC0 : 0 ≤ (C:ℝ)+1 := by positivity + have hw : (j:ℝ) * ((C:ℝ)+1-j) ≤ ((C:ℝ)+1)^2 := by + nlinarith [sq_nonneg ((C:ℝ)+1-j)] + simpa only [Nat.cast_add, Nat.cast_one] using mul_le_mul_of_nonneg_right hw + (hf (pairAssembly p (j:ℤ) ((C:ℤ)+1-j))) + + + +theorem allRaise_le_surplus (C n : ℕ) (f : (PairCoords ι n → ℤ) → ℝ) + (hf : ∀ x, 0 ≤ f x) (p : ι → ℤ) : + allRaise C n f p ≤ ((C:ℝ)+1)^2 * allSurplus C n f p := by + induction n generalizing ι with + | zero => simp [allRaise, allSurplus] + | succ n ih => + have hfirst := raisedFull_le_surplus (allBalance C n f) C (allBalance_nonneg C n f hf) p + have hsecond : balancedMarginal (allRaise C n f) C p ≤ + ((C:ℝ)+1)^2 * balancedMarginal (allSurplus C n f) C p := by + unfold balancedMarginal + rw [Finset.mul_sum] + exact Finset.sum_le_sum (fun j _ => ih f hf _) + change raisedFull (allBalance C n f) C p + balancedMarginal (allRaise C n f) C p ≤ _ + simpa only [allSurplus, mul_add] using add_le_add hfirst hsecond + +end NonnegativeKernels + + + +noncomputable def rootCoeff (zm zp : ℝ) (b : Bool) : ℝ := if b then 1/zm else -(1/zp) + +section Root +variable (n C : ℕ) (f : (PairCoords Bool n → ℤ) → ℝ) (p : Bool → ℤ) + +noncomputable def minusMass : ℝ := allBalance C n f (removeOne p true) +noncomputable def plusMass : ℝ := allBalance C n f (removeOne p false) +noncomputable def auxiliaryMass : ℝ := allSurplus C n f (removePair p true false) + +theorem root_balance (hm : 0 < minusMass n C f p) (hp : 0 < plusMass n C f p) : + holeFunctional (allBalance C n f) p + (rootCoeff (minusMass n C f p) (plusMass n C f p)) = 0 := by + simp only [holeFunctional, Fintype.sum_bool, rootCoeff, Bool.false_eq_true, + ite_false, ite_true] + change minusMass n C f p * (1/minusMass n C f p) + + plusMass n C f p * (-(1/plusMass n C f p)) = 0 + field_simp [hm.ne', hp.ne'] + norm_num + +theorem root_potential (hm : 0 < minusMass n C f p) (hp : 0 < plusMass n C f p) : + holePotential (allBalance C n f) p + (rootCoeff (minusMass n C f p) (plusMass n C f p)) = + 1/minusMass n C f p + 1/plusMass n C f p := by + simp only [holePotential, Fintype.sum_bool, rootCoeff, Bool.false_eq_true, + ite_false, ite_true] + change minusMass n C f p * (1/minusMass n C f p)^2 + + plusMass n C f p * (-(1/plusMass n C f p))^2 = _ + field_simp [hm.ne', hp.ne'] + +theorem root_test_demand (H : (PairCoords Bool n → ℤ) → ℝ) : + holeFunctional (allBalance C n (fun x => f x * H x)) p + (rootCoeff (minusMass n C f p) (plusMass n C f p)) = + minusMass n C (fun x => f x * H x) p / minusMass n C f p - + plusMass n C (fun x => f x * H x) p / plusMass n C f p := by + simp [holeFunctional, rootCoeff, minusMass, plusMass] + ring + +theorem root_quadratic_bound + (hf : ∀ x, 0 ≤ f x) + (hm : 0 < minusMass n C f p) (hp : 0 < plusMass n C f p) + (hnonneg : ∀ x, 0 ≤ allRaise C n f x) : + -matrixForm (twoRemoval (allRaise C n f) p) + (rootCoeff (minusMass n C f p) (plusMass n C f p)) ≤ + 2*((C:ℝ)+1)^2*auxiliaryMass n C f p / + (minusMass n C f p * plusMass n C f p) := by + let zm := minusMass n C f p + let zp := plusMass n C f p + let A := allRaise C n f (removePair p true true) + let B := allRaise C n f (removePair p true false) + let D := allRaise C n f (removePair p false false) + have he : matrixForm (twoRemoval (allRaise C n f) p) (rootCoeff zm zp) = + A*(1/zm)^2 - 2*B*(1/zm)*(1/zp) + D*(1/zp)^2 := by + simp only [matrixForm_apply, twoRemoval, Fintype.sum_bool, rootCoeff, + Bool.false_eq_true, ite_false, ite_true] + rw [removePair_comm p false true] + dsimp [A,B,D] + ring + have hA := mul_nonneg (hnonneg (removePair p true true)) (sq_nonneg (1/zm)) + have hD := mul_nonneg (hnonneg (removePair p false false)) (sq_nonneg (1/zp)) + have hB := allRaise_le_surplus C n f hf (removePair p true false) + have hm' : 0 ≤ (1/zm) := (one_div_pos.mpr hm).le + have hp' : 0 ≤ (1/zp) := (one_div_pos.mpr hp).le + have hc := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hB (by norm_num : (0:ℝ) ≤ 2)) hm') hp' + change -matrixForm (twoRemoval (allRaise C n f) p) (rootCoeff zm zp) ≤ _ + rw [he] + have hr : 2*((C:ℝ)+1)^2*auxiliaryMass n C f p / + (minusMass n C f p * plusMass n C f p) = + 2 * (((C:ℝ)+1)^2 * allSurplus C n f (removePair p true false)) * (1/zm) * (1/zp) := by + dsimp [zm,zp,auxiliaryMass] + ring + rw [hr] + dsimp only [A,B,D] at * + nlinarith + +instance pairCoordsNonempty (ι : Type u) [Nonempty ι] : (n : ℕ) → Nonempty (PairCoords ι n) + | 0 => inferInstanceAs (Nonempty ι) + | n+1 => pairCoordsNonempty (ι ⊕ Bool) n + + + +theorem softened_root_transport (hC : 2 ≤ C) + (H : (PairCoords Bool n → ℤ) → ℝ) (B : Bool → ℤ) (T : ℤ) + (hf : PositiveSlice f (pairBox C n B) T) + (hs : HasSignature f (pairBox C n B) T) + (hb : InBox B p) (ht : (∑ i, p i)+(n:ℤ)*C = T+1) + (hm : 0 < minusMass n C f p) (hp : 0 < plusMass n C f p) + (E : Finset (Sym2 (PairCoords Bool n → ℤ))) + (hE : ∀ a i j, i ≠ j → + 0 < f (removeOne (leafDisplay C n p a) i) → + 0 < f (removeOne (leafDisplay C n p a) j) → + s(removeOne (leafDisplay C n p a) i, removeOne (leafDisplay C n p a) j) ∈ E) : + (minusMass n C (fun x => f x * H x) p / minusMass n C f p - + plusMass n C (fun x => f x * H x) p / plusMass n C f p)^2 ≤ + (1/minusMass n C f p + 1/plusMass n C f p + + 2*((C:ℝ)+1)^2*auxiliaryMass n C f p / + (minusMass n C f p * plusMass n C f p)) * + ∑ e ∈ E, edgeEnergy f H e := by + classical + have hmaxex (a : Branches C n) : ∃ k : PairCoords Bool n, + ∀ i, f (removeOne (leafDisplay C n p a) i) ≤ f (removeOne (leafDisplay C n p a) k) := by + obtain ⟨k,_,hk⟩ := Finset.exists_max_image Finset.univ + (fun i : PairCoords Bool n => f (removeOne (leafDisplay C n p a) i)) Finset.univ_nonempty + exact ⟨k, fun i => hk i (Finset.mem_univ _)⟩ + choose hub hmax using hmaxex + have hflow := recursive_star_transport C hC n f H B T hf hs p hb ht + (rootCoeff (minusMass n C f p) (plusMass n C f p)) (root_balance n C f p hm hp) + (fun a => H (removeOne (leafDisplay C n p a) (hub a))) + rw [root_test_demand, root_potential n C f p hm hp] at hflow + have hraise : ∀ x, 0 ≤ allRaise C n f x := by + cases n with + | zero => intro x; exact le_rfl + | succ n => exact (allRaise_positive C hC (n+1) (by omega) f B T hf hs).nonneg + have hroot := root_quadratic_bound n C f p hf.nonneg hm hp hraise + have henergy := leafStarEnergy_le_graph C n f H hf.nonneg p hub hmax E + (fun a i hn hi => hE a i (hub a) hn hi (hi.trans_le (hmax a i))) + have henergy0 : 0 ≤ leafStarEnergy C n f H p + (fun a => H (removeOne (leafDisplay C n p a) (hub a))) := + Finset.sum_nonneg (fun a _ => Finset.sum_nonneg + (fun i _ => mul_nonneg (hf.nonneg _) (sq_nonneg _))) + have hc0 : 0 ≤ 1/minusMass n C f p + 1/plusMass n C f p + + 2*((C:ℝ)+1)^2*auxiliaryMass n C f p / + (minusMass n C f p * plusMass n C f p) := by + have ha0 : 0 ≤ auxiliaryMass n C f p := allSurplus_nonneg C n f hf.nonneg _ + positivity + have hcoeff : 1/minusMass n C f p + 1/plusMass n C f p - + matrixForm (twoRemoval (allRaise C n f) p) + (rootCoeff (minusMass n C f p) (plusMass n C f p)) ≤ + 1/minusMass n C f p + 1/plusMass n C f p + + 2*((C:ℝ)+1)^2*auxiliaryMass n C f p / + (minusMass n C f p * plusMass n C f p) := by linarith + exact hflow.trans ((mul_le_mul_of_nonneg_right hcoeff henergy0).trans + (mul_le_mul_of_nonneg_left henergy hc0)) + +end Root + +end Contingency + + + + + +open scoped BigOperators + +namespace Contingency +universe u + + + +def joinPairHead (ι : Type u) (n : ℕ) : + ((ι ⊕ Bool) ⊕ (Fin n × Bool)) ≃ (ι ⊕ (Fin (n+1) × Bool)) where + toFun x := match x with + | .inl (.inl i) => .inl i + | .inl (.inr b) => .inr (0,b) + | .inr (s,b) => .inr (s.succ,b) + invFun x := match x with + | .inl i => .inl (.inl i) + | .inr (s,b) => Fin.cases (.inl (.inr b)) (fun t => .inr (t,b)) s + left_inv x := by rcases x with (i | b) | ⟨s,b⟩ <;> rfl + right_inv x := by + rcases x with i | ⟨s,b⟩ + · rfl + · refine Fin.cases ?_ (fun t => ?_) s <;> rfl + +def pairCoordsEquiv (ι : Type u) : (n : ℕ) → PairCoords ι n ≃ (ι ⊕ (Fin n × Bool)) + | 0 => (Equiv.sumEmpty ι (Fin 0 × Bool)).symm + | n+1 => (pairCoordsEquiv (ι ⊕ Bool) n).trans (joinPairHead ι n) + +@[simp] theorem pairCoordsEquiv_zero (ι : Type u) (i : ι) : + pairCoordsEquiv ι 0 i = Sum.inl i := rfl + +noncomputable def branchValue (C : ℕ) : (n : ℕ) → Branches C n → Fin n → Fin (C+1) + | 0, _, s => Fin.elim0 s + | n+1, a, s => Fin.cases a.1 (fun t => branchValue C n a.2 t) s + +theorem leafDisplay_base {ι : Type u} (C n : ℕ) (p : ι → ℤ) (a : Branches C n) (i : ι) : + leafDisplay C n p a ((pairCoordsEquiv ι n).symm (.inl i)) = p i := by + induction n generalizing ι with + | zero => rfl + | succ n ih => exact ih (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) a.2 (.inl i) + +theorem leafDisplay_slot {ι : Type u} (C n : ℕ) (p : ι → ℤ) (a : Branches C n) + (s : Fin n) (b : Bool) : + leafDisplay C n p a ((pairCoordsEquiv ι n).symm (.inr (s,b))) = + if b then ((branchValue C n a s:ℕ):ℤ) else (C:ℤ)-(branchValue C n a s:ℕ) := by + induction n generalizing ι with + | zero => exact Fin.elim0 s + | succ n ih => + refine Fin.cases ?_ (fun t => ?_) s + · change leafDisplay C n (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) a.2 + ((pairCoordsEquiv (ι ⊕ Bool) n).symm (.inl (.inr b))) = _ + rw [leafDisplay_base] + cases b <;> rfl + · exact ih (pairAssembly p (a.1:ℕ) ((C:ℤ)-(a.1:ℕ))) a.2 t + + +def smallCoordsTail (n : ℕ) : (Bool ⊕ (Fin n × Bool)) ≃ (Fin (n+1) × Bool) where + toFun x := match x with + | .inl b => (0,b) + | .inr (s,b) => (s.succ,b) + invFun x := Fin.cases (.inl x.2) (fun s => .inr (s,x.2)) x.1 + left_inv x := by rcases x with b | ⟨s,b⟩ <;> rfl + right_inv x := by rcases x with ⟨s,b⟩; refine Fin.cases ?_ (fun t => ?_) s <;> rfl + +def smallCoords (n : ℕ) : PairCoords Bool n ≃ (Fin (n+1) × Bool) := + (pairCoordsEquiv Bool n).trans (smallCoordsTail n) + +noncomputable def smallOccupancy (n : ℕ) (X : PairCoords Bool n → ℤ) (s : Fin (n+1)) : ℤ := + X ((smallCoords n).symm (s,true)) + X ((smallCoords n).symm (s,false)) + +@[simp] theorem leaf_occupancy_special (C n : ℕ) (p : Bool → ℤ) (a : Branches C n) : + smallOccupancy n (leafDisplay C n p a) 0 = p true + p false := by + unfold smallOccupancy smallCoords + change leafDisplay C n p a ((pairCoordsEquiv Bool n).symm (.inl true)) + + leafDisplay C n p a ((pairCoordsEquiv Bool n).symm (.inl false)) = _ + rw [leafDisplay_base,leafDisplay_base] + +@[simp] theorem leaf_occupancy_ordinary (C n : ℕ) (p : Bool → ℤ) (a : Branches C n) (s : Fin n) : + smallOccupancy n (leafDisplay C n p a) s.succ = (C:ℤ) := by + unfold smallOccupancy smallCoords + change leafDisplay C n p a ((pairCoordsEquiv Bool n).symm (.inr (s,true))) + + leafDisplay C n p a ((pairCoordsEquiv Bool n).symm (.inr (s,false))) = _ + rw [leafDisplay_slot,leafDisplay_slot] + simp + + + +def smallPattern (C n : ℕ) (X : PairCoords Bool n → ℤ) : Prop := + (∀ s, smallOccupancy n X s = (C:ℤ)) ∨ + ∃ s t : Fin (n+1), s ≠ t ∧ smallOccupancy n X s = (C:ℤ)-1 ∧ + smallOccupancy n X t = (C:ℤ)+1 ∧ + ∀ v, v ≠ s → v ≠ t → smallOccupancy n X v = (C:ℤ) + +theorem removeOne_occupancy (n : ℕ) (X : PairCoords Bool n → ℤ) + (i : PairCoords Bool n) (s : Fin (n+1)) : + smallOccupancy n (removeOne X i) s = smallOccupancy n X s - + if s = (smallCoords n i).1 then 1 else 0 := by + classical + + have hi : i = (smallCoords n).symm (smallCoords n i) := by simp + rw [hi] + generalize he : smallCoords n i = q + rcases q with ⟨t,b⟩ + simp only [Equiv.apply_symm_apply] + unfold smallOccupancy removeOne + have ht : ((smallCoords n).symm (s,true) = (smallCoords n).symm (t,b)) ↔ + s = t ∧ true = b := by simp only [Equiv.apply_eq_iff_eq, Prod.mk.injEq] + have hf : ((smallCoords n).symm (s,false) = (smallCoords n).symm (t,b)) ↔ + s = t ∧ false = b := by simp only [Equiv.apply_eq_iff_eq, Prod.mk.injEq] + simp only [ht,hf] + cases b <;> by_cases hh : s = t <;> simp [hh] <;> ring + +theorem leaf_hole_pattern (C n : ℕ) (p : Bool → ℤ) (a : Branches C n) + (hp : p true + p false = (C:ℤ)+1) (i : PairCoords Bool n) : + smallPattern C n (removeOne (leafDisplay C n p a) i) := by + have hd (v : Fin (n+1)) : smallOccupancy n (leafDisplay C n p a) v = + if v = 0 then (C:ℤ)+1 else C := by + refine Fin.cases ?_ (fun s => ?_) v + · simpa using hp + · simp + by_cases hi : (smallCoords n i).1 = 0 + · left + intro v + rw [removeOne_occupancy,hd,hi] + split_ifs <;> omega + · right + refine ⟨(smallCoords n i).1,0,hi,?_,?_,?_⟩ + · rw [removeOne_occupancy,hd] + simp [hi] + · rw [removeOne_occupancy,hd] + simp [Ne.symm hi] + · intro v hv hv0 + rw [removeOne_occupancy,hd] + simp [hv,hv0] + +theorem pairBox_const {ι : Type u} (C n : ℕ) : + pairBox C n (fun _ : ι => (C:ℤ)) = fun _ => (C:ℤ) := by + induction n generalizing ι with + | zero => rfl + | succ n ih => + have he : pairAssembly (fun _ : ι => (C:ℤ)) (C:ℤ) C = fun _ => (C:ℤ) := by + funext i + rcases i with i | b + · rfl + · cases b <;> rfl + rw [pairBox,he] + exact ih + +noncomputable def smallVertexSet (C n : ℕ) : Finset (PairCoords Bool n → ℤ) := by + classical + exact (Fintype.piFinset (fun _ => Finset.Icc 0 (C:ℤ))).filter (smallPattern C n) + +theorem mem_smallVertexSet (C n : ℕ) (X : PairCoords Bool n → ℤ) : + X ∈ smallVertexSet C n ↔ InBox (fun _ => (C:ℤ)) X ∧ smallPattern C n X := by + classical + simp [smallVertexSet,Fintype.mem_piFinset,InBox] + + + +noncomputable def smallUnitEdges (C n : ℕ) : Finset (Sym2 (PairCoords Bool n → ℤ)) := by + classical + exact (smallVertexSet C n).sym2.filter (fun e => ∃ D i j, i ≠ j ∧ + e = s(removeOne D i, removeOne D j)) + +theorem leaf_edge_mem (C n : ℕ) (f : (PairCoords Bool n → ℤ) → ℝ) + (hf : BoxSupported f (fun _ => (C:ℤ))) (p : Bool → ℤ) (a : Branches C n) + (hp : p true + p false = (C:ℤ)+1) (i j : PairCoords Bool n) (hij : i ≠ j) + (hi : 0 < f (removeOne (leafDisplay C n p a) i)) + (hj : 0 < f (removeOne (leafDisplay C n p a) j)) : + s(removeOne (leafDisplay C n p a) i,removeOne (leafDisplay C n p a) j) ∈ smallUnitEdges C n := by + classical + apply Finset.mem_filter.mpr + refine ⟨?_,⟨leafDisplay C n p a,i,j,hij,rfl⟩⟩ + have hv (k : PairCoords Bool n) (hk : 0 < f (removeOne (leafDisplay C n p a) k)) : + removeOne (leafDisplay C n p a) k ∈ smallVertexSet C n := by + apply (mem_smallVertexSet C n _).mpr + refine ⟨?_,leaf_hole_pattern C n p a hp k⟩ + by_contra hh + rw [hf _ hh] at hk + exact lt_irrefl _ hk + simp only [Finset.mk_mem_sym2_iff] + exact ⟨hv i hi,hv j hj⟩ + + + +theorem small_soft_transport (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f H : (PairCoords Bool n → ℤ) → ℝ) + (hf : PositiveSlice f (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (hs : HasSignature f (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (p : Bool → ℤ) (hb : InBox (fun _ => (C:ℤ)) p) + (ht : p true+p false = (C:ℤ)+1) + (hm : 0 < minusMass n C f p) (hp : 0 < plusMass n C f p) : + (minusMass n C (fun x => f x * H x) p / minusMass n C f p - + plusMass n C (fun x => f x * H x) p / plusMass n C f p)^2 ≤ + (1/minusMass n C f p + 1/plusMass n C f p + + 2*((C:ℝ)+1)^2*auxiliaryMass n C f p / + (minusMass n C f p * plusMass n C f p)) * + ∑ e ∈ smallUnitEdges C n, edgeEnergy f H e := by + have hb' := hf + have hs' := hs + rw [← pairBox_const C n] at hb' hs' + refine softened_root_transport n C f p hC H (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C) + hb' hs' hb ?_ hm hp (smallUnitEdges C n) ?_ + · rw [Fintype.sum_bool,ht] + push_cast + ring + · intro a i j hij hi hj + exact leaf_edge_mem C n f hf.boxSupported p a ht i j hij hi hj + +end Contingency + + + + + +open scoped BigOperators +open Filter + +namespace Contingency +universe u v + +section Continuity +variable {ι : Type u} {K : Type v} [TopologicalSpace K] + +theorem allBalance_continuous (C n : ℕ) (f : K → (PairCoords ι n → ℤ) → ℝ) + (hf : ∀ x, Continuous (fun η => f η x)) (p : ι → ℤ) : + Continuous (fun η => allBalance C n (f η) p) := by + induction n generalizing ι with + | zero => exact hf p + | succ n ih => + change Continuous (fun η => ∑ j ∈ Finset.range (C+1), + allBalance C n (f η) (pairAssembly p (j:ℤ) ((C:ℤ)-j))) + exact continuous_finsetSum _ (fun j _ => ih f hf _) + +theorem allSurplus_continuous (C n : ℕ) (f : K → (PairCoords ι n → ℤ) → ℝ) + (hf : ∀ x, Continuous (fun η => f η x)) (p : ι → ℤ) : + Continuous (fun η => allSurplus C n (f η) p) := by + induction n generalizing ι with + | zero => exact continuous_const + | succ n ih => + change Continuous (fun η => (∑ j ∈ Finset.range (C+1+1), + allBalance C n (f η) (pairAssembly p (j:ℤ) (((C+1:ℕ):ℤ)-j))) + + ∑ j ∈ Finset.range (C+1), + allSurplus C n (f η) (pairAssembly p (j:ℤ) ((C:ℤ)-j))) + exact (continuous_finsetSum _ (fun j _ => allBalance_continuous C n f hf _)).add + (continuous_finsetSum _ (fun j _ => ih f hf _)) + +theorem edgeEnergy_continuous {X : Type*} (f : K → X → ℝ) (hf : ∀ x, Continuous (fun η => f η x)) + (H : X → ℝ) (e : Sym2 X) : Continuous (fun η => edgeEnergy (f η) H e) := by + induction e using Sym2.ind with + | _ x y => exact ((hf x).min (hf y)).mul continuous_const + +end Continuity + + + +theorem root_masses_positive (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : (PairCoords Bool n → ℤ) → ℝ) + (hf : PositiveSlice f (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (hs : HasSignature f (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (p : Bool → ℤ) (hb : InBox (fun _ => (C:ℤ)) p) + (ht : p true+p false = (C:ℤ)+1) : + 0 < minusMass n C f p ∧ 0 < plusMass n C f p := by + have hf' := hf + have hs' := hs + rw [← pairBox_const C n] at hf' hs' + have hpos := (allBalance_closure C hC n f (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C) hf' hs').1 + have hT : ((n+1:ℕ):ℤ)*C-(n:ℤ)*C = C := by push_cast; ring + rw [hT] at hpos + have hb' (b : Bool) : InBox (fun _ => (C:ℤ)) (removeOne p b) := by + intro k + have hb0 := hb false + have hb1 := hb true + dsimp at hb0 hb1 + cases b <;> cases k <;> simp only [removeOne, ite_eq_left, Bool.false_eq_true, + Bool.true_eq_false, ite_false, sub_zero] <;> omega + have hsum (b : Bool) : (∑ i, removeOne p b i) = (C:ℤ) := by + rw [Fintype.sum_bool] + cases b <;> simp only [removeOne, ite_eq_left, Bool.false_eq_true, + Bool.true_eq_false, ite_false, sub_zero] <;> omega + exact ⟨hpos.1 _ (hb' true) (hsum true),hpos.1 _ (hb' false) (hsum false)⟩ + + + +noncomputable def softSequence (j : ℕ) : ℝ := (1 / ((j:ℝ)+1))/2 + +theorem softSequence_range (j : ℕ) : 0 < softSequence j ∧ softSequence j < 1 := by + have h : 1 / ((j:ℝ)+1) ≤ 1 := (div_le_one (by positivity)).mpr (by linarith [Nat.cast_nonneg (α:=ℝ) j]) + constructor + · unfold softSequence; positivity + · unfold softSequence; linarith + +theorem softSequence_tendsto : Tendsto softSequence atTop (nhds 0) := by + change Tendsto (fun j : ℕ => (1 / ((j:ℝ)+1))/2) atTop (nhds 0) + have h := (@tendsto_one_div_add_atTop_nhds_zero_nat ℝ _ _ _ _).div_const 2 + simpa only [zero_div,softSequence] using h + + + +theorem zero_root_transport (C : ℕ) (hC : 2 ≤ C) (n : ℕ) + (f : ℝ → (PairCoords Bool n → ℤ) → ℝ) + (hc : ∀ x, Continuous (fun η => f η x)) + (hf : ∀ η, 0 < η → η < 1 → PositiveSlice (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (hs : ∀ η, 0 < η → η < 1 → HasSignature (f η) (fun _ => (C:ℤ)) (((n+1:ℕ):ℤ)*C)) + (H : (PairCoords Bool n → ℤ) → ℝ) + (p : Bool → ℤ) (hb : InBox (fun _ => (C:ℤ)) p) + (ht : p true+p false = (C:ℤ)+1) + (hm : 0 < minusMass n C (f 0) p) (hp : 0 < plusMass n C (f 0) p) : + (minusMass n C (fun x => f 0 x * H x) p / minusMass n C (f 0) p - + plusMass n C (fun x => f 0 x * H x) p / plusMass n C (f 0) p)^2 ≤ + (1/minusMass n C (f 0) p + 1/plusMass n C (f 0) p + + 2*((C:ℝ)+1)^2*auxiliaryMass n C (f 0) p / + (minusMass n C (f 0) p * plusMass n C (f 0) p)) * + ∑ e ∈ smallUnitEdges C n, edgeEnergy (f 0) H e := by + have hcm : ContinuousAt (fun η => minusMass n C (f η) p) 0 := + (allBalance_continuous C n f hc _).continuousAt + have hcp : ContinuousAt (fun η => plusMass n C (f η) p) 0 := + (allBalance_continuous C n f hc _).continuousAt + have hcH (x) : Continuous (fun η => f η x * H x) := (hc x).mul continuous_const + have hnm : ContinuousAt (fun η => minusMass n C (fun x => f η x * H x) p) 0 := + (allBalance_continuous C n _ hcH _).continuousAt + have hnp : ContinuousAt (fun η => plusMass n C (fun x => f η x * H x) p) 0 := + (allBalance_continuous C n _ hcH _).continuousAt + have hca : ContinuousAt (fun η => auxiliaryMass n C (f η) p) 0 := + (allSurplus_continuous C n f hc _).continuousAt + have hce : ContinuousAt (fun η => ∑ e ∈ smallUnitEdges C n, edgeEnergy (f η) H e) 0 := + (continuous_finsetSum _ (fun e _ => edgeEnergy_continuous f hc H e)).continuousAt + have hl := ((hnm.div hcm hm.ne').sub (hnp.div hcp hp.ne')).pow 2 + have hr : ContinuousAt (fun η => (1/minusMass n C (f η) p + 1/plusMass n C (f η) p + + 2*((C:ℝ)+1)^2*auxiliaryMass n C (f η) p / + (minusMass n C (f η) p * plusMass n C (f η) p)) * + ∑ e ∈ smallUnitEdges C n, edgeEnergy (f η) H e) 0 := + (((continuousAt_const.div hcm hm.ne').add (continuousAt_const.div hcp hp.ne')).add + ((continuousAt_const.mul hca).div (hcm.mul hcp) (mul_ne_zero hm.ne' hp.ne'))).mul hce + apply le_of_tendsto_of_tendsto (hl.tendsto.comp softSequence_tendsto) + (hr.tendsto.comp softSequence_tendsto) + apply Filter.Eventually.of_forall + intro j + have hj := softSequence_range j + obtain ⟨hm',hp'⟩ := root_masses_positive C hC n (f (softSequence j)) + (hf _ hj.1 hj.2) (hs _ hj.1 hj.2) p hb ht + exact small_soft_transport C hC n (f (softSequence j)) H + (hf _ hj.1 hj.2) (hs _ hj.1 hj.2) p hb ht hm' hp' + + + +theorem transport_repair_arithmetic (zm zp a E v d U : ℝ) + (hm : 0 < zm) (hp : 0 < zp) (hE : 0 ≤ E) (_hd : 0 ≤ d) + (ha : a ≤ d * max zm zp) + (hv : v ^ 2 ≤ (1/zm + 1/zp + 2*(U+1)^2*a/(zm*zp))*E) : + min zm zp * v^2 ≤ (2+2*d*(U+1)^2)*E := by + have hmin : 0 ≤ min zm zp := le_min hm.le hp.le + have hcoef : min zm zp * (1/zm + 1/zp + 2*(U+1)^2*a/(zm*zp)) ≤ + 2+2*d*(U+1)^2 := by + have h1 : min zm zp / zm ≤ 1 := (div_le_one hm).mpr (min_le_left _ _) + have h2 : min zm zp / zp ≤ 1 := (div_le_one hp).mpr (min_le_right _ _) + have h3 : min zm zp * a / (zm*zp) ≤ d := by + apply (div_le_iff₀ (mul_pos hm hp)).mpr + calc + min zm zp * a ≤ min zm zp * (d * max zm zp) := mul_le_mul_of_nonneg_left ha hmin + _ = d * (min zm zp * max zm zp) := by ring + _ = d*(zm*zp) := by rw [min_mul_max] + have hh := mul_le_mul_of_nonneg_left h3 (mul_nonneg (show (0:ℝ) ≤ 2 by norm_num) (sq_nonneg (U+1))) + have he : min zm zp * (1/zm + 1/zp + 2*(U+1)^2*a/(zm*zp)) = + min zm zp / zm + min zm zp / zp + 2*(U+1)^2 * (min zm zp*a/(zm*zp)) := by ring + rw [he] + nlinarith + + calc + min zm zp * v^2 ≤ min zm zp * ((1/zm + 1/zp + 2*(U+1)^2*a/(zm*zp))*E) := + mul_le_mul_of_nonneg_left hv hmin + _ = (min zm zp * (1/zm + 1/zp + 2*(U+1)^2*a/(zm*zp)))*E := by ring + _ ≤ (2+2*d*(U+1)^2)*E := mul_le_mul_of_nonneg_right hcoef hE + +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/SafeBins.lean b/lean/OAI/Probability/Contingency/SafeBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8b70b45bb9f414fb2e1cdcfe85f95b88e559f0e --- /dev/null +++ b/lean/OAI/Probability/Contingency/SafeBins.lean @@ -0,0 +1,594 @@ +import Mathlib +import OAI.Probability.Contingency.GridCover + +namespace OAI + +/-! Safe Bins. -/ + +noncomputable section + +open Set MeasureTheory +open scoped BigOperators +open Set MeasureTheory +open scoped BigOperators +namespace Contingency.Grid +noncomputable section +variable {q K : ℕ} {I : Type*} +open Contingency.Interpolation Contingency.Dense + +def closedBin (v : Vertex q K) : Set (Fin q → ℝ) := + Set.pi Set.univ (fun i => Set.Icc (v i:ℝ) ((v i:ℝ)+1)) + +def safeBins (f : I → (Fin q → ℝ) → ℝ) : Finset (Vertex q K) := by + classical + exact Finset.univ.filter fun v => closedBin v ⊆ region f 0 + +@[simp] theorem mem_safeBins (f : I → (Fin q → ℝ) → ℝ) (v : Vertex q K) : + v∈safeBins f ↔ closedBin v ⊆ region f 0 := by classical simp [safeBins] + +theorem closedBin_distance (v : Vertex q K) (x y : Fin q → ℝ) + (hx : x∈(bin v).carrier) (hy : y∈closedBin v) : ‖y-x‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0:ℝ) ≤ 1)).mpr + intro i + have h1 := (mem_bin v x).mp hx i + have h2 := hy i (Set.mem_univ i) + dsimp [inside,corner] at h1 + simp only [Set.mem_Icc] at h2 + simp only [Pi.sub_apply,Real.norm_eq_abs,abs_le] + constructor <;> linarith [h1.1,h1.2,h2.1,h2.2] + +theorem inner_bin_safe (f : I → (Fin q → ℝ) → ℝ) (L τ : ℝ) + (hL : 0 ≤ L) (hτ : L ≤ τ) (hlip : ∀ i x y,|f i x-f i y| ≤ L*‖x-y‖) + (v : Vertex q K) (x : Fin q → ℝ) (hx : x∈region f τ) (hbin : x∈(bin v).carrier) : + v∈safeBins f := by + rw [mem_safeBins] + intro y hy i + have hh := (hlip i y x).trans (mul_le_mul_of_nonneg_left (closedBin_distance v x y hbin hy) hL) + have hi := hx i + rw [mul_one] at hh + linarith only [(abs_le.mp hh).1,hi,hτ] + +theorem boxes_volume_le_card (V : Finset (Vertex q K)) : + volume (boxUnion (boxes V)) ≤ V.card := by + have he : boxUnion (boxes V)=⋃ v∈V,(bin v).carrier := by + ext x + simp only [mem_boxes,mem_iUnion,mem_bin,exists_prop] + rw [he] + apply (measure_biUnion_finset_le V (fun v => (bin v).carrier)).trans_eq + simp [bin_volume] + +theorem safe_bin_count (f : I → (Fin q → ℝ) → ℝ) (L τ bound : ℝ) + (hL : 0 ≤ L) (hτ : L ≤ τ) (hlip : ∀ i x y,|f i x-f i y| ≤ L*‖x-y‖) + (hbound : region f 0 ⊆ Set.pi Set.univ (fun _ => Set.Icc 0 bound)) + (hK : bound < K) : volume (region f τ) ≤ (safeBins (K:=K) f).card := by + apply le_trans _ (boxes_volume_le_card (safeBins f)) + apply measure_mono_ae + filter_upwards [ae_no_grid (q:=q)] with x hgrid + intro hx + have hx0 : x∈region f 0 := fun i => (hL.trans hτ).trans (hx i) + have hxcube : x∈(cube q K).carrier := by + rw [mem_cube] + intro i + have hh := hbound hx0 i (Set.mem_univ i) + exact ⟨lt_of_le_of_ne hh.1 (Ne.symm (by simpa only [Nat.cast_zero] using hgrid i 0)),hh.2.trans_lt hK⟩ + obtain ⟨v,hv⟩ := exists_bin x hxcube hgrid + exact (mem_boxes _ _).mpr ⟨v,inner_bin_safe f L τ hL hτ hlip v x hx ((mem_bin v x).mpr hv),hv⟩ + +theorem corner_mem_closedBin (v : Vertex q K) : realCorner v∈closedBin v := by + intro i _ + exact ⟨le_rfl,by dsimp [realCorner]; linarith⟩ + +theorem safe_bin_weight_one {a c : ℕ} (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 0 ≤ d) (v : Vertex q K) + (hv : v∈safeBins (constraints e R P w)) : binWeight e R P w d v=1 := by + have hs := (mem_safeBins _ v).mp hv (corner_mem_closedBin v) + have hz : penalty R P w (d^8) d (fun s => realCorner v (e.symm s))=0 := by + apply penalty_zero_of_slack + intro i j + have hh := hs (i,j) + have hn : 0 ≤ d/d^8 := by positivity + change 0 ≤ normalized R P w _ i j at hh + rw [neg_div] + linarith + simp [binWeight,exponentWeight,binExponent,hz] + +end +end Contingency.Grid + + + + + +open Set MeasureTheory +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +variable {a c q K : ℕ} +open Contingency.Grid Contingency.Interpolation + + + +theorem dense_safe_bin_bound (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 4 ≤ d) (hq : (q:ℝ) ≤ d) + (ha : (a+1:ℕ) ≤ d) (hc : (c+1:ℕ) ≤ d) (hK : 2*d^8 < K) + (hR : ∀ i,0 constraints_lipschitz e R P w (d^8) d (by positivity) hd0.le he + hR hP hRmax hPmax (fun i j => (hw i j).le) hwhi x y i + have hcubes := region_bounded e R P w (d^8) (by positivity) hR hP heq hwlo + have hcount := safe_bin_count (K:=K) (constraints e R P w) (d/d^8) (2*d/d^8) (2*d^8) + (by positivity) (div_le_div_of_nonneg_right (by linarith : d ≤ 2*d) (by positivity)) hlip hcubes hK + have hlow := hinner.trans hcount + have hnorm := dense_bin_normalizer_bound (K:=K) e R P w d hd he hq hR hP hRmax hPmax + (fun i j => (hw i j).le) hwhi u hu + have hcoef : (32:ENNReal)*(1/2)=16 := by + have h : (32:NNReal)*(1/2)=16 := by norm_num + have hh := congrArg (fun x : NNReal => (x:ENNReal)) h + simpa only [ENNReal.coe_mul,ENNReal.coe_div (by norm_num : (2:NNReal)≠0),ENNReal.coe_one,ENNReal.coe_ofNat] using hh + have hupper : ENNReal.ofReal (∑ v : Vertex q K,binWeight e R P w d v) ≤ + 32*((safeBins (K:=K) (constraints e R P w)).card:ENNReal) := by + calc + _ ≤ 16*volume (region (constraints e R P w) 0) := hnorm + _ = 32*((1/2:ENNReal)*volume (region (constraints e R P w) 0)) := by rw [← mul_assoc,hcoef] + _ ≤ _ := by gcongr + have he' : ENNReal.ofReal (32*((safeBins (K:=K) (constraints e R P w)).card:ℝ)) = + 32*((safeBins (K:=K) (constraints e R P w)).card:ENNReal) := by + rw [ENNReal.ofReal_mul (by norm_num),ENNReal.ofReal_natCast] + norm_num + rw [← he'] at hupper + have hreal := (ENNReal.ofReal_le_ofReal_iff (by positivity : 0 ≤ 32*((safeBins (K:=K) (constraints e R P w)).card:ℝ))).mp hupper + apply (div_le_iff₀ (by norm_num : (0:ℝ)<32)).mpr + simpa only [mul_comm] using hreal + +end +end Contingency.Dense + + + + + +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +open Contingency.Grid +variable {a c q K : ℕ} + + +def integerComplete (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) + (x : Fin a → Fin c → ℕ) : Fin (a+1) → Fin (c+1) → ℤ := + Fin.lastCases + (Fin.lastCases ((R (Fin.last a):ℤ)-(∑ j : Fin c,(P j.castSucc:ℤ))+(∑ i,∑ j,(x i j:ℤ))) + (fun j => (P j.castSucc:ℤ)-∑ i,(x i j:ℤ))) + (fun i => Fin.lastCases ((R i.castSucc:ℤ)-∑ j,(x i j:ℤ)) (fun j => (x i j:ℤ))) + +theorem integerComplete_cast (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) + (x : Fin a → Fin c → ℕ) (i j) : + (integerComplete R P x i j:ℝ)=complete (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) + (fun i j => (x i j:ℝ)) i j := by + refine Fin.lastCases ?_ (fun i => ?_) i <;> refine Fin.lastCases ?_ (fun j => ?_) j <;> + simp [integerComplete,complete] + +theorem integerComplete_nonneg (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) + (x : Fin a → Fin c → ℕ) : + (∀ i j,0 ≤ integerComplete R P x i j) ↔ + ∀ i j,0 ≤ complete (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (x i j:ℝ)) i j := by + simp only [← integerComplete_cast,Int.cast_nonneg_iff] + +def tableOfFree (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) + (heq : (∑ i,R i)=∑ j,P j) (x : Fin a → Fin c → ℕ) + (hx : ∀ i j,0 ≤ integerComplete R P x i j) : Tables R P := by + refine ⟨fun i j => (integerComplete R P x i j).toNat,?_,?_⟩ + · intro i + have hh := complete_row (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (x i j:ℝ)) i + simp only [← integerComplete_cast] at hh + have hc (j) : (((integerComplete R P x i j).toNat:ℕ):ℝ)=(integerComplete R P x i j:ℝ) := by + rw [← Int.cast_natCast,Int.toNat_of_nonneg (hx i j)] + exact_mod_cast (show (∑ j,((integerComplete R P x i j).toNat:ℝ))=(R i:ℝ) by simpa only [hc] using hh) + · intro j + have hreal : (∑ i,(R i:ℝ))=∑ j,(P j:ℝ) := by exact_mod_cast heq + have hh := complete_col (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (x i j:ℝ)) hreal j + simp only [← integerComplete_cast] at hh + have hc (i) : (((integerComplete R P x i j).toNat:ℕ):ℝ)=(integerComplete R P x i j:ℝ) := by + rw [← Int.cast_natCast,Int.toNat_of_nonneg (hx i j)] + exact_mod_cast (show (∑ i,((integerComplete R P x i j).toNat:ℝ))=(P j:ℝ) by simpa only [hc] using hh) + +@[simp] theorem tableOfFree_free (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) + (heq : (∑ i,R i)=∑ j,P j) (x : Fin a → Fin c → ℕ) + (hx : ∀ i j,0 ≤ integerComplete R P x i j) (i j) : + (tableOfFree R P heq x hx).val i.castSucc j.castSucc=x i j := by + simp [tableOfFree,integerComplete] + +theorem tables_free_injective (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) : + Function.Injective (fun X : Tables R P => fun i : Fin a => fun j : Fin c => X.val i.castSucc j.castSucc) := by + intro X Y h + have hx := complete_represents (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (X.val i j:ℝ)) + (fun i => by exact_mod_cast X.property.1 i) (fun j => by exact_mod_cast X.property.2 j) + have hy := complete_represents (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (Y.val i j:ℝ)) + (fun i => by exact_mod_cast Y.property.1 i) (fun j => by exact_mod_cast Y.property.2 j) + apply Subtype.ext + funext i j + have he : (fun i : Fin a => fun j : Fin c => (X.val i.castSucc j.castSucc:ℝ))= + (fun i : Fin a => fun j : Fin c => (Y.val i.castSucc j.castSucc:ℝ)) := by + funext i j; exact_mod_cast congrFun (congrFun h i) j + rw [he,hy] at hx + exact_mod_cast congrFun (congrFun hx i) j |>.symm + +abbrev Offsets (w : Fin q → ℕ) := (i : Fin q) → Fin (w i) +abbrev Sample (w : Fin q → ℕ) := Vertex q K × Offsets w + +def freeSample (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (s : Sample (K:=K) w) : Fin a → Fin c → ℕ := + fun i j => w (e.symm (i,j))*(s.1 (e.symm (i,j))).val+(s.2 (e.symm (i,j))).val + +def samplePoint (w : Fin q → ℕ) (s : Sample (K:=K) w) : Fin q → ℝ := + fun i => (s.1 i:ℝ)+(s.2 i:ℝ)/w i + +theorem samplePoint_mem (w : Fin q → ℕ) (hw : ∀ i,0 (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (w (e.symm (i,j)):ℝ)) + (fun ij => samplePoint w s (e.symm ij))= + complete (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (freeSample e w s i j:ℝ)) := by + unfold scaled + congr 1 + funext i j + simp only [samplePoint,freeSample,Nat.cast_add,Nat.cast_mul,mul_add] + rw [mul_div_cancel₀ _ (by exact_mod_cast (hw (e.symm (i,j))).ne')] + +theorem freeSample_injective (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 z/w i) (hh i) + simpa only [Nat.mul_add_div (hw i),Nat.div_eq_of_lt (s.2 i).isLt,Nat.div_eq_of_lt (t.2 i).isLt,Nat.add_zero] using hi + apply Prod.ext + · funext i; exact Fin.ext (hb i) + · funext i; apply Fin.ext; have := hh i; rw [hb i] at this; omega + +end +end Contingency.Dense + + + + + +open scoped BigOperators +namespace Contingency.Dense +noncomputable section +open Contingency.Grid Contingency.Interpolation +variable {a c q K : ℕ} + +theorem closedBin_corner_distance (v : Vertex q K) (x : Fin q → ℝ) (hx : x∈closedBin v) : + ‖x-realCorner v‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0:ℝ) ≤ 1)).mpr + intro i + have hh := hx i (Set.mem_univ i) + simp only [Set.mem_Icc] at hh + simp only [Pi.sub_apply,realCorner,Real.norm_eq_abs,abs_le] + constructor <;> linarith [hh.1,hh.2] + + +theorem feasible_bin_weight_one (e : Fin q ≃ Fin a×Fin c) + (R : Fin (a+1) → ℝ) (P : Fin (c+1) → ℝ) (w : Fin a → Fin c → ℝ) + (d : ℝ) (hd : 0 realCorner v (e.symm s))=0 := by + apply penalty_zero_of_slack + intro i j + have hh := constraints_lipschitz e R P w (d^8) d (by positivity) hd.le he hR hP hRmax hPmax hw0 hw + x (realCorner v) (i,j) + have hd' : 0 ≤ d/d^8 := by positivity + have hdist := mul_le_mul_of_nonneg_left (closedBin_corner_distance v x hx) hd' + have hf := hx0 (i,j) + change 0 ≤ constraints e R P w (i,j) x at hf + rw [neg_div] + change -(d/d^8) ≤ constraints e R P w (i,j) (realCorner v) + linarith only [(abs_le.mp hh).2,hdist,hf] + simp [binWeight,exponentWeight,binExponent,hz] + +def Accepted (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) + (R : Fin (a+1) → ℕ) (P : Fin (c+1) → ℕ) (s : Sample (K:=K) w) : Prop := + ∀ i j,0 ≤ integerComplete R P (freeSample e w s) i j + +theorem accepted_iff_point (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 (R i:ℝ)) (fun j => (P j:ℝ)) + (fun i j => (w (e.symm (i,j)):ℝ))) 0 := by + rw [Accepted,integerComplete_nonneg] + have hs (i j) : (0:ℝ) (R i:ℝ)) (fun j => (P j:ℝ)) i j := + lt_min (by dsimp; exact_mod_cast hR i) (by dsimp; exact_mod_cast hP j) + constructor + · intro h ij + change 0 ≤ scaled _ _ _ _ ij.1 ij.2/scale _ _ _ _ + rw [samplePoint_complete e w hw R P s] + exact div_nonneg (h _ _) (hs _ _).le + · intro h i j + have hi := h (i,j) + change 0 ≤ scaled _ _ _ _ i j/scale _ _ _ _ at hi + rw [samplePoint_complete e w hw R P s] at hi + have hh := (le_div_iff₀ (hs i j)).mp hi + simpa only [zero_mul] using hh + +theorem safe_bin_accepted (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 (R i:ℝ)) (fun j => (P j:ℝ)) + (fun i j => (w (e.symm (i,j)):ℝ)))) (β : Offsets w) : Accepted e w R P (v,β) := by + apply (accepted_iff_point e w hw R P hR hP (v,β)).mpr + exact (mem_safeBins _ v).mp hv (samplePoint_mem w hw (v,β)) + + +theorem table_bin_bound (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 (R i:ℝ)) (fun j => (P j:ℝ)) (e i).1.castSucc (e i).2.castSucc/(2*B) ≤ w i) + (X : Tables R P) (i : Fin q) : X.val (e i).1.castSucc (e i).2.castSucc/w i (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (X.val i j:ℝ)) + (fun i j => by positivity) (fun i => by exact_mod_cast X.property.1 i) + (fun j => by exact_mod_cast X.property.2 j) (e i).1.castSucc (e i).2.castSucc + have hw' : (0:ℝ) ⟨X.val (e i).1.castSucc (e i).2.castSucc/w i,bound X i⟩, + fun i => ⟨X.val (e i).1.castSucc (e i).2.castSucc%w i,Nat.mod_lt _ (hw i)⟩) + +@[simp] theorem encodeSample_free (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 X.val i.castSucc j.castSucc := by + funext i j + simp only [freeSample,encodeSample,e.apply_symm_apply] + exact Nat.div_add_mod _ _ + +theorem encodeSample_accepted (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 (R i:ℝ)) (fun j => (P j:ℝ)) (fun i j => (X.val i j:ℝ)) + (fun i => by exact_mod_cast X.property.1 i) (fun j => by exact_mod_cast X.property.2 j) + rw [he] + exact fun i j => Nat.cast_nonneg _ + + +def acceptedEquiv (e : Fin q ≃ Fin a×Fin c) (w : Fin q → ℕ) (hw : ∀ i,0 (R i:ℝ)) (fun j => (P j:ℝ)) (e i).1.castSucc (e i).2.castSucc/(2*d^8) ≤ w i + hwhi : ∀ i,(w i:ℝ) ≤ scale (fun i => (R i:ℝ)) (fun j => (P j:ℝ)) (e i).1.castSucc (e i).2.castSucc/d^8 + +namespace BinProblem +variable (D : BinProblem a c q K) + +def widths (i : Fin a) (j : Fin c) : ℝ := D.w (D.e.symm (i,j)) +def weight : Vertex q K → ℝ := binWeight D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths D.d +def Z : ℝ := ∑ v,D.weight v +def offsetCount : ℕ := Fintype.card (Offsets D.w) +def sampleMass (s : Sample (K:=K) D.w) : ℝ := D.weight s.1/(D.Z*D.offsetCount) +def good (s : Sample (K:=K) D.w) : Prop := Accepted D.e D.w D.R D.P s + +def success : ℝ := by + classical + exact ∑ s : Sample (K:=K) D.w,if D.good s then D.sampleMass s else 0 + +theorem offsetCount_pos : 0 ⟨0,D.hw i⟩⟩ + exact Fintype.card_pos + +include D in +theorem Kpos : 0 ⟨0,D.Kpos⟩⟩ + exact Finset.sum_pos (fun v _ => D.weight_pos v) Finset.univ_nonempty + +theorem sampleMass_nonneg (s : Sample (K:=K) D.w) : 0 ≤ D.sampleMass s := by + apply div_nonneg (D.weight_pos s.1).le + exact mul_nonneg D.Zpos.le (Nat.cast_nonneg _) + +theorem sampleMass_total : (∑ s : Sample (K:=K) D.w,D.sampleMass s)=1 := by + simp only [sampleMass,Fintype.sum_prod_type,Finset.sum_const,Finset.card_univ,nsmul_eq_mul, + ← Finset.sum_div,← Finset.mul_sum] + change (D.offsetCount:ℝ)*D.Z/(D.Z*D.offsetCount)=1 + field_simp [D.Zpos.ne',Nat.cast_ne_zero.mpr D.offsetCount_pos.ne'] + +theorem widthlo (i j) : scale (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) + i.castSucc j.castSucc/(2*D.d^8) ≤ D.widths i j := by + simpa only [widths,D.e.apply_symm_apply] using D.hwlo (D.e.symm (i,j)) + +theorem widthhi (i j) : D.widths i j ≤ scale (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) + i.castSucc j.castSucc/D.d^8 := by + simpa only [widths,D.e.apply_symm_apply] using D.hwhi (D.e.symm (i,j)) + +theorem dim : (a*c:ℕ) ≤ D.d := by + have he : q=a*c := by simpa using Fintype.card_congr D.e + simpa only [he] using D.hq + +theorem accepted_weight (s : Sample (K:=K) D.w) (hs : D.good s) : D.weight s.1=1 := by + apply feasible_bin_weight_one D.e _ _ _ D.d (by linarith [D.hd]) D.dim + (fun i => by exact_mod_cast D.hR i) (fun j => by exact_mod_cast D.hP j) + (fun i => by exact_mod_cast D.hRmax i) (fun j => by exact_mod_cast D.hPmax j) + (fun i j => by exact Nat.cast_nonneg _) D.widthhi s.1 (samplePoint D.w s) + (samplePoint_mem D.w D.hw s) + exact (accepted_iff_point D.e D.w D.hw D.R D.P D.hR D.hP s).mp hs + +def safe : Finset (Vertex q K) := safeBins (constraints D.e (fun i => (D.R i:ℝ)) (fun j => (D.P j:ℝ)) D.widths) + +theorem safe_count : D.Z/32 ≤ (D.safe.card:ℝ) := by + exact dense_safe_bin_bound D.e _ _ D.widths D.d D.hd D.hq D.ha D.hc D.hK + (fun i => by exact_mod_cast D.hR i) (fun j => by exact_mod_cast D.hP j) + (by exact_mod_cast D.heq) + (fun i => by exact_mod_cast D.hRmax i) (fun j => by exact_mod_cast D.hPmax j) + D.widthlo D.widthhi + +theorem safe_success (v : Vertex q K) (hv : v∈D.safe) (β : Offsets D.w) : D.good (v,β) := + safe_bin_accepted D.e D.w D.hw D.R D.P D.hR D.hP v hv β + + +theorem success_lower : 1/32 ≤ D.success := by + classical + have hl : (D.safe.card:ℝ)/D.Z ≤ D.success := by + calc + _ = ∑ v∈D.safe,∑ β : Offsets D.w,D.sampleMass (v,β) := by + have hw (v) (hv : v∈D.safe) : D.weight v=1 := + D.accepted_weight (v,fun i => ⟨0,D.hw i⟩) (D.safe_success v hv _) + simp only [sampleMass] + rw [Finset.sum_congr rfl (fun v hv => by rw [hw v hv])] + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + change (D.safe.card:ℝ)/D.Z=(D.safe.card:ℝ)*((D.offsetCount:ℝ)*(1/(D.Z*D.offsetCount))) + field_simp [D.Zpos.ne',Nat.cast_ne_zero.mpr D.offsetCount_pos.ne'] + _ = ∑ v∈D.safe,∑ β : Offsets D.w,if D.good (v,β) then D.sampleMass (v,β) else 0 := by + apply Finset.sum_congr rfl; intro v hv + apply Finset.sum_congr rfl; intro β _ + rw [ite_eq_left (D.safe_success v hv β)] + _ ≤ ∑ v,∑ β : Offsets D.w,if D.good (v,β) then D.sampleMass (v,β) else 0 := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + intro v _ _ + exact Finset.sum_nonneg (fun β _ => by split_ifs; exact D.sampleMass_nonneg _; rfl) + _ = D.success := by simp only [success,Fintype.sum_prod_type] + apply le_trans _ hl + apply (le_div_iff₀ D.Zpos).mpr + linarith [D.safe_count] + +theorem success_upper : D.success ≤ 1 := by + rw [← D.sampleMass_total] + apply Finset.sum_le_sum + intro s _ + split_ifs + · rfl + · exact D.sampleMass_nonneg s + +theorem bound (X : Tables D.R D.P) (i : Fin q) : X.val (D.e i).1.castSucc (D.e i).2.castSucc/D.w i h x hx) + have hd := l.finrank_range_add_finrank_ker + have hr := (LinearMap.range l).finrank_le + simp only [Module.finrank_self] at hr + omega + + +omit [FiniteDimensional ℝ V] in +theorem quadratic_add (Q : QuadraticForm ℝ V) (x y : V) : + Q (x + y) = Q x + Q y + 2 * Q.associated x y := by + have h := Q.associated_apply ℝ x y + norm_num at h + linarith + + + +theorem sigPos_two_of_orthogonal_positive (Q : QuadraticForm ℝ V) (e v : V) + (he : 0 < Q e) (hv : 0 < Q v) (hev : Q.associated e v = 0) : + 2 ≤ sigPos Q := by + let f : (ℝ × ℝ) →ₗ[ℝ] V := + (LinearMap.fst ℝ ℝ ℝ).smulRight e + (LinearMap.snd ℝ ℝ ℝ).smulRight v + have hf (p : ℝ × ℝ) : Q (f p) = p.1 ^ 2 * Q e + p.2 ^ 2 * Q v := by + change Q (p.1 • e + p.2 • v) = _ + rw [quadratic_add] + simp [QuadraticMap.map_smul, map_smul, hev, pow_two] + have hpos (p : ℝ × ℝ) (hp : p ≠ 0) : 0 < Q (f p) := by + rw [hf] + have hp' : p.1 ≠ 0 ∨ p.2 ≠ 0 := by + by_contra h + push Not at h + apply hp + exact Prod.ext h.1 h.2 + rcases hp' with hp' | hp' + · exact add_pos_of_pos_of_nonneg (mul_pos (sq_pos_of_ne_zero hp') he) + (mul_nonneg (sq_nonneg _) hv.le) + · exact add_pos_of_nonneg_of_pos (mul_nonneg (sq_nonneg _) he.le) + (mul_pos (sq_pos_of_ne_zero hp') hv) + have hinj : Function.Injective f := by + apply (LinearMap.ker_eq_bot).mp + apply LinearMap.ker_eq_bot'.mpr + intro p hp + by_contra hp' + have := hpos p hp' + rw [hp, QuadraticMap.map_zero] at this + exact lt_irrefl _ this + have hdef : (Q.restrict (LinearMap.range f)).PosDef := by + rintro ⟨x, hx⟩ hne + obtain ⟨p, rfl⟩ := hx + apply hpos + intro hp + apply hne + apply Subtype.ext + simp [hp] + have hs := le_sigPos_of_posDef Q hdef + have hr := LinearEquiv.finrank_eq (LinearEquiv.ofInjective f hinj) + have htwo : Module.finrank ℝ (LinearMap.range f) = 2 := by + rw [← hr] + simp [Module.finrank_prod] + rwa [htwo] at hs + + +theorem positive_projection (Q : QuadraticForm ℝ V) (hs : sigPos Q ≤ 1) + (e v : V) (he : 0 < Q e) : + Q v ≤ (Q.associated v e) ^ 2 / Q e := by + let a := Q.associated v e / Q e + let w := v - a • e + have hee : Q.associated e e = Q e := Q.associated_eq_self_apply ℝ e + have hew : Q.associated e w = 0 := by + simp only [w, map_sub, map_smul] + rw [QuadraticMap.associated_isSymm ℝ Q e v, hee] + simp [a, div_mul_cancel₀ _ he.ne'] + have hw : Q w ≤ 0 := by + by_contra h + have := sigPos_two_of_orthogonal_positive Q e w he (lt_of_not_ge h) hew + omega + have hexp : Q w = Q v - 2 * a * Q.associated v e + a ^ 2 * Q e := by + rw [show w = v + (-a) • e by simp [w, sub_eq_add_neg], quadratic_add] + simp only [QuadraticMap.map_smul, map_smul, smul_eq_mul] + ring + rw [hexp] at hw + dsimp [a] at hw + field_simp at hw ⊢ + nlinarith [sq_pos_of_pos he] + + +noncomputable def pairForm (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) : QuadraticForm ℝ (V × ℝ × ℝ) := + let old := LinearMap.fst ℝ V (ℝ × ℝ) + let x := (LinearMap.fst ℝ ℝ ℝ).comp (LinearMap.snd ℝ V (ℝ × ℝ)) + let y := (LinearMap.snd ℝ ℝ ℝ).comp (LinearMap.snd ℝ V (ℝ × ℝ)) + Q.comp old + 2 • linMulLin (Sa.comp old) x + 2 • linMulLin (Sb.comp old) y + + a • linMulLin x x + (2 * b) • linMulLin x y + c • linMulLin y y + +omit [FiniteDimensional ℝ V] in +theorem pairForm_apply (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) (h : V) (x y : ℝ) : + pairForm Q Sa Sb a b c (h, x, y) = + Q h + 2 * Sa h * x + 2 * Sb h * y + a * x ^ 2 + 2 * b * x * y + c * y ^ 2 := by + simp [pairForm, linMulLin_apply, pow_two, mul_assoc] + +omit [FiniteDimensional ℝ V] in +theorem pairForm_first (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) : pairForm Q Sa Sb a b c (0, 1, 0) = a := by + simp [pairForm_apply] + +omit [FiniteDimensional ℝ V] in +theorem pairForm_second (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) : pairForm Q Sa Sb a b c (0, 0, 1) = c := by + simp [pairForm_apply] + +omit [FiniteDimensional ℝ V] in +theorem pairForm_both (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) : pairForm Q Sa Sb a b c (0, 1, 1) = a + 2 * b + c := by + simp [pairForm_apply] + +omit [FiniteDimensional ℝ V] in +theorem pairForm_associated_first (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) (h : V) (x y : ℝ) : + (pairForm Q Sa Sb a b c).associated (h, x, y) (0, 1, 0) = + Sa h + a * x + b * y := by + rw [QuadraticMap.associated_apply] + simp [pairForm_apply] + ring + +omit [FiniteDimensional ℝ V] in +theorem pairForm_associated_second (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) (h : V) (x y : ℝ) : + (pairForm Q Sa Sb a b c).associated (h, x, y) (0, 0, 1) = + Sb h + b * x + c * y := by + rw [QuadraticMap.associated_apply] + simp [pairForm_apply] + ring + + + +theorem pair_one (Q : QuadraticForm ℝ V) (Sa Sb : V →ₗ[ℝ] ℝ) + (a b c : ℝ) (ha : 0 ≤ a) (hc : 0 ≤ c) + (hpositive : 0 < a ∨ 0 < c ∨ 0 < b) + (hs : sigPos (pairForm Q Sa Sb a b c) ≤ 1) + (h : V) (gp g gn : ℝ) + (hSa : Sa h = b * g - a * gp) (hSb : Sb h = c * gn - b * g) : + 2 * b * g ^ 2 - a * gp ^ 2 - c * gn ^ 2 ≤ -Q h := by + let M := pairForm Q Sa Sb a b c + have hfirst : M.associated (h, g, -g) (0, 1, 0) = a * (g - gp) := by + rw [pairForm_associated_first, hSa] + ring + have hsecond : M.associated (h, g, -g) (0, 0, 1) = c * (gn - g) := by + rw [pairForm_associated_second, hSb] + ring + have hbound : M (h, g, -g) ≤ a * (g - gp) ^ 2 + c * (g - gn) ^ 2 := by + by_cases ha' : 0 < a + · have ht := positive_projection M hs (0, 1, 0) (h, g, -g) + (by simpa [M, pairForm_first] using ha') + rw [hfirst, pairForm_first] at ht + have heq : (a * (g - gp)) ^ 2 / a = a * (g - gp) ^ 2 := by + field_simp + rw [heq] at ht + exact ht.trans (le_add_of_nonneg_right (mul_nonneg hc (sq_nonneg _))) + · by_cases hc' : 0 < c + · have ht := positive_projection M hs (0, 0, 1) (h, g, -g) + (by simpa [M, pairForm_second] using hc') + rw [hsecond, pairForm_second] at ht + have heq : (c * (gn - g)) ^ 2 / c = c * (g - gn) ^ 2 := by + field_simp + ring + rw [heq] at ht + exact ht.trans (le_add_of_nonneg_left (mul_nonneg ha (sq_nonneg _))) + · have hae : a = 0 := le_antisymm (le_of_not_gt ha') ha + have hce : c = 0 := le_antisymm (le_of_not_gt hc') hc + have hb : 0 < b := hpositive.resolve_left ha' |>.resolve_left hc' + have ht := positive_projection M hs (0, 1, 1) (h, g, -g) + (by rw [pairForm_both, hae, hce]; linarith) + have heq : M.associated (h, g, -g) (0, 1, 1) = 0 := by + have hsum : ((0 : V), (1 : ℝ), (1 : ℝ)) = (0, 1, 0) + (0, 0, 1) := by + ext <;> simp + rw [hsum, map_add, hfirst, hsecond, hae, hce] + ring + simpa [heq, hae, hce] using ht + rw [pairForm_apply, hSa, hSb] at hbound + nlinarith + + +noncomputable def pairCumulative (D : ℕ) (u : ℕ → ℝ) (S : ℕ → V →ₗ[ℝ] ℝ) + (h : V) (j : ℕ) : ℝ := + if 0 < j ∧ j < D then (∑ l ∈ Finset.range j, S l h) / u j else 0 + +omit [FiniteDimensional ℝ V] in +theorem pairCumulative_mul (D : ℕ) (u : ℕ → ℝ) (S : ℕ → V →ₗ[ℝ] ℝ) + (hu : ∀ j, 0 < j → j < D → 0 < u j) (h : V) + (hbal : ∑ l ∈ Finset.range D, S l h = 0) (j : ℕ) (hj : j ≤ D) : + u j * pairCumulative D u S h j = ∑ l ∈ Finset.range j, S l h := by + by_cases h0 : j = 0 + · simp [h0, pairCumulative] + by_cases hD : j = D + · simp [hD, pairCumulative, hbal] + have hj' : 0 < j ∧ j < D := by omega + simp only [pairCumulative, ite_eq_left hj'] + exact mul_div_cancel₀ _ (hu j hj'.1 hj'.2).ne' + + +omit [FiniteDimensional ℝ V] in +theorem pairCumulative_difference (D : ℕ) (u : ℕ → ℝ) (S : ℕ → V →ₗ[ℝ] ℝ) + (hu : ∀ j, 0 < j → j < D → 0 < u j) (h : V) + (hbal : ∑ l ∈ Finset.range D, S l h = 0) (j : ℕ) (hj : j < D) : + S j h = u (j+1) * pairCumulative D u S h (j+1) - + u j * pairCumulative D u S h j := by + rw [pairCumulative_mul D u S hu h hbal _ (by omega), + pairCumulative_mul D u S hu h hbal _ (by omega), Finset.sum_range_succ] + ring + + +noncomputable def pairPrevious (S : ℕ → V →ₗ[ℝ] ℝ) (j : ℕ) : V →ₗ[ℝ] ℝ := + if j = 0 then 0 else S (j-1) + + + +theorem pair_sequence_one (D : ℕ) (hD : 2 ≤ D) (u : ℕ → ℝ) + (S : ℕ → V →ₗ[ℝ] ℝ) (Q : ℕ → QuadraticForm ℝ V) + (hu : ∀ j, 0 < j → j < D → 0 < u j) + (uzero : ∀ j, j = 0 ∨ D ≤ j → u j = 0) (sD : S D = 0) + (h : V) (hbal : ∑ l ∈ Finset.range D, S l h = 0) + (j : ℕ) (hj : j ≤ D) + (hs : sigPos (pairForm (Q j) (pairPrevious S j) (S j) + (u (j-1)) (u j) (u (j+1))) ≤ 1) : + 2 * u j * pairCumulative D u S h j ^ 2 - + u (j-1) * pairCumulative D u S h (j-1) ^ 2 - + u (j+1) * pairCumulative D u S h (j+1) ^ 2 ≤ -(Q j) h := by + have hunonneg (i : ℕ) : 0 ≤ u i := by + by_cases hi : i = 0 ∨ D ≤ i + · rw [uzero i hi] + · push Not at hi + exact (hu i (by omega) (by omega)).le + have hpos : 0 < u (j-1) ∨ 0 < u (j+1) ∨ 0 < u j := by + by_cases h0 : j = 0 + · subst j + exact Or.inr (Or.inl (hu 1 (by omega) (by omega))) + by_cases hjD : j = D + · exact Or.inl (hu (j-1) (by omega) (by omega)) + · exact Or.inr (Or.inr (hu j (by omega) (by omega))) + have ha : (pairPrevious S j) h = + u j * pairCumulative D u S h j - u (j-1) * pairCumulative D u S h (j-1) := by + by_cases hj0 : j = 0 + · simp [hj0, pairPrevious, pairCumulative] + · rw [pairPrevious, ite_eq_right hj0] + have ht := pairCumulative_difference D u S hu h hbal (j-1) (by omega) + simpa [Nat.sub_add_cancel (by omega : 1 ≤ j)] using ht + have hb : S j h = u (j+1) * pairCumulative D u S h (j+1) - + u j * pairCumulative D u S h j := by + by_cases hjD : j = D + · simp [hjD, sD, pairCumulative] + · exact pairCumulative_difference D u S hu h hbal j (by omega) + exact pair_one (Q j) (pairPrevious S j) (S j) _ _ _ + (hunonneg _) (hunonneg _) hpos hs h _ _ _ ha hb + + +theorem discrete_laplacian_sum (a : ℕ → ℝ) (D : ℕ) + (h0 : a 0 = 0) (hD : a D = 0) (hnext : a (D+1) = 0) : + ∑ j ∈ Finset.range (D+1), (2 * a j - a (j-1) - a (j+1)) = 0 := by + have hp : ∑ j ∈ Finset.range (D+1), a (j-1) = ∑ j ∈ Finset.range (D+1), a j := by + rw [Finset.sum_range_succ', Finset.sum_range_succ] + simp [h0, hD] + have hn : ∑ j ∈ Finset.range (D+1), a (j+1) = ∑ j ∈ Finset.range (D+1), a j := by + have ht := Finset.sum_range_succ' a (D+1) + rw [Finset.sum_range_succ, hnext, h0, add_zero, add_zero] at ht + exact ht.symm + simp only [Finset.sum_sub_distrib, ← Finset.mul_sum, hp, hn] + ring + + + +theorem pair_summation_signature (D : ℕ) (hD : 2 ≤ D) (u : ℕ → ℝ) + (S : ℕ → V →ₗ[ℝ] ℝ) (Q : ℕ → QuadraticForm ℝ V) + (hu : ∀ j, 0 < j → j < D → 0 < u j) + (uzero : ∀ j, j = 0 ∨ D ≤ j → u j = 0) (sD : S D = 0) + (hs : ∀ j, j ≤ D → sigPos (pairForm (Q j) (pairPrevious S j) (S j) + (u (j-1)) (u j) (u (j+1))) ≤ 1) : + sigPos (∑ j ∈ Finset.range (D+1), Q j) ≤ 1 := by + apply sigPos_le_one_of_kernel _ (∑ l ∈ Finset.range D, S l) + intro h hbal + have hb : ∑ l ∈ Finset.range D, S l h = 0 := by simpa using hbal + let a := fun j => u j * pairCumulative D u S h j ^ 2 + have ht : ∑ j ∈ Finset.range (D+1), (2 * a j - a (j-1) - a (j+1)) = 0 := by + apply discrete_laplacian_sum + all_goals simp [a, pairCumulative] + have hsum : ∑ j ∈ Finset.range (D+1), (2 * a j - a (j-1) - a (j+1)) ≤ + ∑ j ∈ Finset.range (D+1), -(Q j) h := by + apply Finset.sum_le_sum + intro j hj + have hj' : j ≤ D := by simpa using Finset.mem_range.mp hj + simpa only [a, mul_assoc] using + pair_sequence_one D hD u S Q hu uzero sD h hb j hj' (hs j hj') + rw [ht, Finset.sum_neg_distrib] at hsum + simpa using neg_nonneg.mp hsum + + + +theorem discrete_summation_by_parts (a w : ℕ → ℝ) (D : ℕ) + (h0 : a 0 = 0) (hD : a D = 0) (hnext : a (D+1) = 0) : + (∑ j ∈ Finset.range (D+1), w j * (2 * a j - a (j-1) - a (j+1))) = + ∑ j ∈ Finset.range (D+1), (2 * w j - w (j-1) - w (j+1)) * a j := by + have hp : ∑ j ∈ Finset.range (D+1), w j * a (j-1) = + ∑ j ∈ Finset.range (D+1), w (j+1) * a j := by + rw [Finset.sum_range_succ', Finset.sum_range_succ] + simp [h0, hD] + have hn : ∑ j ∈ Finset.range (D+1), w j * a (j+1) = + ∑ j ∈ Finset.range (D+1), w (j-1) * a j := by + have ht := Finset.sum_range_succ' (fun j => w (j-1) * a j) (D+1) + rw [Finset.sum_range_succ] at ht + simpa [h0, hnext] using ht.symm + simp only [mul_sub, sub_mul, Finset.sum_sub_distrib] + rw [hp, hn] + have ht : ∑ j ∈ Finset.range (D+1), w j * (2 * a j) = + ∑ j ∈ Finset.range (D+1), 2 * w j * a j := by + apply Finset.sum_congr rfl + intros + ring + rw [ht] + ring + +theorem discrete_quadratic_weight (a : ℕ → ℝ) (D : ℕ) + (h0 : a 0 = 0) (hD : a D = 0) (hnext : a (D+1) = 0) : + (∑ j ∈ Finset.range (D+1), (j : ℝ) * (D - j) * + (2 * a j - a (j-1) - a (j+1))) = 2 * ∑ j ∈ Finset.range (D+1), a j := by + rw [discrete_summation_by_parts a (fun j => (j : ℝ) * (D-j)) D h0 hD hnext, + Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + by_cases hj0 : j = 0 + · simp [hj0, h0] + · rw [Nat.cast_sub (by omega : 1 ≤ j), Nat.cast_one, Nat.cast_add, Nat.cast_one] + ring + + + +theorem pair_summation_weighted (D : ℕ) (hD : 2 ≤ D) (u : ℕ → ℝ) + (S : ℕ → V →ₗ[ℝ] ℝ) (Q : ℕ → QuadraticForm ℝ V) + (hu : ∀ j, 0 < j → j < D → 0 < u j) + (uzero : ∀ j, j = 0 ∨ D ≤ j → u j = 0) (sD : S D = 0) + (hs : ∀ j, 0 < j → j < D → sigPos (pairForm (Q j) (pairPrevious S j) (S j) + (u (j-1)) (u j) (u (j+1))) ≤ 1) + (h : V) (hbal : ∑ l ∈ Finset.range D, S l h = 0) : + 2 * (∑ j ∈ Finset.range (D+1), u j * pairCumulative D u S h j ^ 2) ≤ + -(∑ j ∈ Finset.range (D+1), ((j : ℝ) * (D-j)) • Q j) h := by + let a := fun j => u j * pairCumulative D u S h j ^ 2 + have ha0 : a 0 = 0 := by simp [a, pairCumulative] + have haD : a D = 0 := by simp [a, pairCumulative] + have haN : a (D+1) = 0 := by simp [a, pairCumulative] + have ht := discrete_quadratic_weight a D ha0 haD haN + have hsum : + (∑ j ∈ Finset.range (D+1), (j : ℝ) * (D-j) * (2*a j-a (j-1)-a (j+1))) ≤ + ∑ j ∈ Finset.range (D+1), -((j : ℝ) * (D-j)) * (Q j) h := by + apply Finset.sum_le_sum + intro j hj + have hj' : j ≤ D := by simpa using Finset.mem_range.mp hj + by_cases hj0 : j = 0 + · simp [hj0] + by_cases hjD : j = D + · simp [hjD] + have h := pair_sequence_one D hD u S Q hu uzero sD h hbal j hj' + (hs j (by omega) (by omega)) + have hw : 0 ≤ (j : ℝ) * (D-j) := + mul_nonneg (Nat.cast_nonneg _) (sub_nonneg.mpr (Nat.cast_le.mpr hj')) + simpa only [a, mul_assoc, mul_neg, neg_mul] using mul_le_mul_of_nonneg_left h hw + rw [ht] at hsum + simpa only [a, sum_apply, smul_apply, smul_eq_mul, + neg_mul, Finset.sum_neg_distrib] using hsum + +section Laminar +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + + +omit [Fintype ι] in +theorem chain_product_telescope (s : Finset (Finset ι)) (g : Finset ι → ℝ) + (hc : ∀ G ∈ s, ∀ H ∈ s, G ⊆ H ∨ H ⊆ G) : + ∏ G ∈ s, g G = 1 - ∑ G ∈ s, (1-g G) * ∏ H ∈ s.filter (G ⊂ ·), g H := by + classical + induction s using Finset.strongInductionOn with + | _ s ih => + by_cases he : s = ∅ + · simp [he] + obtain ⟨G, hG, hmin⟩ := s.exists_min_image Finset.card (Finset.nonempty_iff_ne_empty.mpr he) + have hsmall (H) (hH : H ∈ s.erase G) : G ⊂ H := by + obtain ⟨hHG, hHs⟩ := Finset.mem_erase.mp hH + rcases hc G hG H hHs with h | h + · exact Finset.ssubset_iff_subset_ne.mpr ⟨h, Ne.symm hHG⟩ + · have heq := Finset.eq_of_subset_of_card_le h (hmin H hHs) + exact (hHG heq).elim + have hfilter (H) (hH : H ∈ s.erase G) : + s.filter (H ⊂ ·) = (s.erase G).filter (H ⊂ ·) := by + ext J + simp only [Finset.mem_filter, Finset.mem_erase] + constructor + · rintro ⟨hJ, hHJ⟩ + refine ⟨⟨?_, hJ⟩, hHJ⟩ + intro heq + subst J + have hGH := Finset.ssubset_iff_subset_ne.mp (hsmall H hH) + exact hGH.2 (Finset.Subset.antisymm hGH.1 (Finset.ssubset_iff_subset_ne.mp hHJ).1) + · tauto + have hGeq : s.filter (G ⊂ ·) = s.erase G := by + ext H + simp only [Finset.mem_filter, Finset.mem_erase] + constructor + · rintro ⟨hH, hGH⟩ + exact ⟨(Finset.ssubset_iff_subset_ne.mp hGH).2.symm, hH⟩ + · intro hH + exact ⟨hH.2, hsmall H (Finset.mem_erase.mpr hH)⟩ + have ht := ih (s.erase G) (Finset.erase_ssubset hG) + (fun H hH J hJ => hc H (Finset.mem_of_mem_erase hH) J (Finset.mem_of_mem_erase hJ)) + have hp : ∏ H ∈ s, g H = g G * ∏ H ∈ s.erase G, g H := + (Finset.mul_prod_erase s g hG).symm + have hs : ∑ H ∈ s, (1-g H) * ∏ J ∈ s.filter (H ⊂ ·), g J = + (1-g G) * (∏ H ∈ s.erase G, g H) + + ∑ H ∈ s.erase G, (1-g H) * ∏ J ∈ (s.erase G).filter (H ⊂ ·), g J := by + rw [← Finset.add_sum_erase s _ hG, hGeq] + congr 1 + apply Finset.sum_congr rfl + intro H hH + rw [hfilter H hH] + rw [hp, hs] + linarith + + +def IsLaminar (s : Finset (Finset ι)) : Prop := + ∀ G ∈ s, ∀ H ∈ s, G ⊆ H ∨ H ⊆ G ∨ Disjoint G H + +noncomputable def laminarCoefficient (s : Finset (Finset ι)) + (g : Finset ι → ℝ) (G : Finset ι) : ℝ := + (1-g G) * ∏ H ∈ s.filter (G ⊂ ·), g H + + +omit [Fintype ι] in +theorem laminar_blocks (s : Finset (Finset ι)) (g : Finset ι → ℝ) + (hl : IsLaminar s) (i j : ι) : + (∏ G ∈ s.filter (fun G => i ∈ G ∧ j ∈ G), g G) = + 1 - ∑ G ∈ s, if i ∈ G ∧ j ∈ G then laminarCoefficient s g G else 0 := by + classical + let t := s.filter (fun G => i ∈ G ∧ j ∈ G) + have hc : ∀ G ∈ t, ∀ H ∈ t, G ⊆ H ∨ H ⊆ G := by + intro G hG H hH + obtain ⟨hGs, hiG, _⟩ := Finset.mem_filter.mp hG + obtain ⟨hHs, hiH, _⟩ := Finset.mem_filter.mp hH + rcases hl G hGs H hHs with h | h | h + · exact Or.inl h + · exact Or.inr h + · exact (Finset.disjoint_left.mp h hiG hiH).elim + have hf (G) (hG : G ∈ t) : t.filter (G ⊂ ·) = s.filter (G ⊂ ·) := by + obtain ⟨hGs, hiG, hjG⟩ := Finset.mem_filter.mp hG + ext H + simp only [t, Finset.mem_filter] + constructor + · tauto + · rintro ⟨hH, hGH⟩ + exact ⟨⟨hH, (Finset.ssubset_iff_subset_ne.mp hGH).1 hiG, + (Finset.ssubset_iff_subset_ne.mp hGH).1 hjG⟩, hGH⟩ + rw [show (∑ G ∈ s, if i ∈ G ∧ j ∈ G then laminarCoefficient s g G else 0) = + ∑ G ∈ t, laminarCoefficient s g G by simp [t, Finset.sum_filter]] + rw [chain_product_telescope t g hc] + congr 1 + apply Finset.sum_congr rfl + intro G hG + rw [hf G hG] + rfl + + + +noncomputable def matrixForm (M : ι → ι → ℝ) : QuadraticForm ℝ (ι → ℝ) := + ∑ i, ∑ j, M i j • linMulLin (LinearMap.proj i) (LinearMap.proj j) + +omit [DecidableEq ι] in +theorem matrixForm_apply (M : ι → ι → ℝ) (x : ι → ℝ) : + matrixForm M x = ∑ i, ∑ j, M i j * x i * x j := by + simp [matrixForm, linMulLin_apply, mul_assoc] + + +theorem laminar_quadratic (s : Finset (Finset ι)) (g : Finset ι → ℝ) + (hl : IsLaminar s) (z : ι → ℝ) : + (∑ i, ∑ j, (∏ G ∈ s.filter (fun G => i ∈ G ∧ j ∈ G), g G) * z i * z j) = + (∑ i, z i)^2 - ∑ G ∈ s, laminarCoefficient s g G * (∑ i ∈ G, z i)^2 := by + classical + simp_rw [laminar_blocks s g hl, sub_mul, one_mul] + simp_rw [Finset.sum_sub_distrib] + have hfirst : (∑ i, ∑ j, z i * z j) = (∑ i, z i)^2 := by + rw [pow_two, Finset.sum_mul] + apply Finset.sum_congr rfl + intro i hi + rw [Finset.mul_sum] + rw [hfirst] + congr 1 + simp_rw [Finset.sum_mul] + conv_lhs => + arg 2 + ext i + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro G hG + have he (i j : ι) : + (if i ∈ G ∧ j ∈ G then laminarCoefficient s g G else 0) * z i * z j = + laminarCoefficient s g G * (if i ∈ G then z i else 0) * + (if j ∈ G then z j else 0) := by + by_cases hi : i ∈ G <;> by_cases hj : j ∈ G <;> simp [hi, hj] + simp_rw [he, ← Finset.mul_sum, ← Finset.sum_mul] + simp [pow_two, ← Finset.mul_sum, mul_assoc] + + +omit [Fintype ι] in +theorem laminarCoefficient_nonneg (s : Finset (Finset ι)) + (g : Finset ι → ℝ) (hg : ∀ G ∈ s, 0 ≤ g G ∧ g G ≤ 1) + (G : Finset ι) (hG : G ∈ s) : 0 ≤ laminarCoefficient s g G := by + apply mul_nonneg (sub_nonneg.mpr (hg G hG).2) + exact Finset.prod_nonneg fun H hH => (hg H (Finset.mem_filter.mp hH).1).1 + + + +theorem laminar_matrix_signature (s : Finset (Finset ι)) (g : Finset ι → ℝ) + (hl : IsLaminar s) (hg : ∀ G ∈ s, 0 ≤ g G ∧ g G ≤ 1) + (W : ℝ) (hW : 0 ≤ W) (α e : ι → ℝ) (he : ∀ i, 0 ≤ e i) : + sigPos (matrixForm (fun i j => + W * α i * α j * (∏ G ∈ s.filter (fun G => i ∈ G ∧ j ∈ G), g G) - + if i = j then e i else 0)) ≤ 1 := by + classical + apply sigPos_le_one_of_kernel _ (∑ i, α i • LinearMap.proj i) + intro x hx + have hx' : ∑ i, α i * x i = 0 := by simpa using hx + rw [matrixForm_apply] + have hexp : + (∑ i, ∑ j, (W * α i * α j * + (∏ G ∈ s.filter (fun G => i ∈ G ∧ j ∈ G), g G) - + if i = j then e i else 0) * x i * x j) = + W * ((∑ i, α i * x i)^2 - + ∑ G ∈ s, laminarCoefficient s g G * (∑ i ∈ G, α i * x i)^2) - + ∑ i, e i * x i^2 := by + simp_rw [sub_mul, Finset.sum_sub_distrib] + congr 1 + · rw [← laminar_quadratic s g hl (fun i => α i * x i), Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + ring + · apply Finset.sum_congr rfl + intro i hi + simp [ite_mul, pow_two, mul_assoc] + rw [hexp, hx', zero_pow (by decide : 2 ≠ 0), zero_sub] + have ha : 0 ≤ ∑ G ∈ s, laminarCoefficient s g G * (∑ i ∈ G, α i * x i)^2 := + Finset.sum_nonneg fun G hG => mul_nonneg (laminarCoefficient_nonneg s g hg G hG) (sq_nonneg _) + have hd : 0 ≤ ∑ i, e i * x i^2 := + Finset.sum_nonneg fun i _ => mul_nonneg (he i) (sq_nonneg _) + nlinarith + + +noncomputable def factorRemoval (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (t : Finset ι → ℤ) (i j : ι) : ℝ := + ∏ G ∈ s, ψ G (t G - (if i ∈ G then 1 else 0) - (if j ∈ G then 1 else 0)) + +noncomputable def factorRatio (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (t : Finset ι → ℤ) (i : ι) : ℝ := + ∏ G ∈ s.filter (i ∈ ·), ψ G (t G-1) / ψ G (t G) + +noncomputable def factorGamma (ψ : Finset ι → ℤ → ℝ) (t : Finset ι → ℤ) + (G : Finset ι) : ℝ := ψ G (t G) * ψ G (t G-2) / ψ G (t G-1)^2 + + + +omit [Fintype ι] in +theorem factorRemoval_eq (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (t : Finset ι → ℤ) + (hψ : ∀ G ∈ s, ∀ z, 0 < ψ G z) (i j : ι) : + factorRemoval s ψ t i j = (∏ G ∈ s, ψ G (t G)) * + factorRatio s ψ t i * factorRatio s ψ t j * + ∏ G ∈ s.filter (fun G => i ∈ G ∧ j ∈ G), factorGamma ψ t G := by + classical + simp only [factorRemoval, factorRatio, Finset.prod_filter] + rw [← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro G hG + have ha : ψ G (t G) ≠ 0 := (hψ G hG _).ne' + have hb : ψ G (t G-1) ≠ 0 := (hψ G hG _).ne' + by_cases hi : i ∈ G <;> by_cases hj : j ∈ G + · simp only [hi, hj, and_self, ↓reduceIte, factorGamma] + rw [show t G-1-1 = t G-2 by omega] + field_simp + · simp only [hi, hj, and_false, ↓reduceIte, sub_zero, mul_one, sub_zero] + field_simp + · simp only [hi, hj, false_and, ↓reduceIte, sub_zero, mul_one, sub_zero] + field_simp + · simp [hi, hj] + + + +noncomputable def truncatedFactorMatrix (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (t : Finset ι → ℤ) (p : ι → ℤ) (i j : ι) : ℝ := + if p i = 0 ∨ p j = 0 ∨ (i = j ∧ p i = 1) then 0 else factorRemoval s ψ t i j + + + +theorem truncated_laminar_signature (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (t : Finset ι → ℤ) (p : ι → ℤ) + (hl : IsLaminar s) (hψ : ∀ G ∈ s, ∀ z, 0 < ψ G z) + (hc : ∀ G ∈ s, ψ G (t G) * ψ G (t G-2) ≤ ψ G (t G-1)^2) : + sigPos (matrixForm (truncatedFactorMatrix s ψ t p)) ≤ 1 := by + classical + let g := factorGamma ψ t + let W := ∏ G ∈ s, ψ G (t G) + let α := fun i => if p i = 0 then 0 else factorRatio s ψ t i + let e := fun i => if p i = 1 then + W * α i * α i * (∏ G ∈ s.filter (fun G => i ∈ G ∧ i ∈ G), g G) else 0 + have hg : ∀ G ∈ s, 0 ≤ g G ∧ g G ≤ 1 := by + intro G hG + dsimp [g, factorGamma] + exact ⟨div_nonneg (mul_pos (hψ G hG _) (hψ G hG _)).le (sq_nonneg _), + (div_le_one (sq_pos_of_pos (hψ G hG _))).mpr (hc G hG)⟩ + have hW : 0 ≤ W := (Finset.prod_pos fun G hG => hψ G hG _).le + have he : ∀ i, 0 ≤ e i := by + intro i + dsimp [e] + split_ifs + · rw [mul_assoc W, ← pow_two] + apply mul_nonneg (mul_nonneg hW (sq_nonneg _)) + exact Finset.prod_nonneg fun G hG => (hg G (Finset.mem_filter.mp hG).1).1 + · exact le_rfl + have hM : truncatedFactorMatrix s ψ t p = fun i j => + W * α i * α j * (∏ G ∈ s.filter (fun G => i ∈ G ∧ j ∈ G), g G) - + if i = j then e i else 0 := by + funext i j + rw [truncatedFactorMatrix] + by_cases hi : p i = 0 + · simp [hi, α, e] + by_cases hj : p j = 0 + · by_cases hij : i = j + · subst j; contradiction + · simp [hj, hij, α, e] + by_cases hij : i = j + · subst j + by_cases hi1 : p i = 1 + · simp [hi1, e] + · simp [hi, hi1, α, e, factorRemoval_eq s ψ t hψ, W, g] + · simp [hi, hj, hij, α, factorRemoval_eq s ψ t hψ, W, g] + rw [hM] + exact laminar_matrix_signature s g hl hg W hW α e he + + + +def removePair (p : ι → ℤ) (i j : ι) : ι → ℤ := + fun k => p k - (if k = i then 1 else 0) - (if k = j then 1 else 0) + +def InBox (B p : ι → ℤ) : Prop := ∀ i, 0 ≤ p i ∧ p i ≤ B i + +noncomputable def twoRemoval (f : (ι → ℤ) → ℝ) (p : ι → ℤ) : ι → ι → ℝ := + fun i j => f (removePair p i j) + + +def HasSignature (f : (ι → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) : Prop := + ∀ p, InBox B p → (∑ i, p i) = T+2 → sigPos (matrixForm (twoRemoval f p)) ≤ 1 + + +def PositiveSlice (f : (ι → ℤ) → ℝ) (B : ι → ℤ) (T : ℤ) : Prop := + (∀ p, InBox B p → (∑ i, p i) = T → 0 < f p) ∧ + (∀ p, ¬(InBox B p ∧ (∑ i, p i) = T) → f p = 0) + +omit [Fintype ι] in +theorem sum_removePair (G : Finset ι) (p : ι → ℤ) (i j : ι) : + (∑ k ∈ G, removePair p i j k) = + (∑ k ∈ G, p k) - (if i ∈ G then 1 else 0) - (if j ∈ G then 1 else 0) := by + simp [removePair, Finset.sum_sub_distrib] + +omit [Fintype ι] in +theorem removePair_comm (p : ι → ℤ) (i j : ι) : removePair p i j = removePair p j i := by + funext k + simp only [removePair] + omega + +omit [Fintype ι] in +theorem removePair_inBox_iff (B p : ι → ℤ) (hp : InBox B p) (i j : ι) : + InBox B (removePair p i j) ↔ ¬(p i = 0 ∨ p j = 0 ∨ (i = j ∧ p i = 1)) := by + constructor + · intro h hbad + obtain h1 := (h i).1 + obtain h2 := (h j).1 + simp only [removePair, ↓reduceIte] at h1 h2 + rcases hbad with hi | hj | ⟨rfl, hi⟩ + · split_ifs at h1 <;> omega + · split_ifs at h2 <;> omega + · simp [hi] at h1 + · intro h k + obtain ⟨hk0, hkB⟩ := hp k + dsimp [removePair] + by_cases hki : k = i <;> by_cases hkj : k = j + · subst i; subst j + simp only [not_or, not_and, true_implies] at h + simp only [↓reduceIte] + omega + · subst i + simp only [↓reduceIte, hkj, sub_zero] + have : p k ≠ 0 := fun hh => h (Or.inl hh) + omega + · subst j + simp only [hki, ↓reduceIte, sub_zero] + have : p k ≠ 0 := fun hh => h (Or.inr (Or.inl hh)) + omega + · simpa [hki, hkj] using hp k + +noncomputable def factorSlice (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (B : ι → ℤ) (T : ℤ) (p : ι → ℤ) : ℝ := by + classical + exact if InBox B p ∧ (∑ i, p i) = T then ∏ G ∈ s, ψ G (∑ i ∈ G, p i) else 0 + +omit [DecidableEq ι] in +theorem factorSlice_positive (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (B : ι → ℤ) (T : ℤ) + (hψ : ∀ G ∈ s, ∀ z, 0 < ψ G z) : PositiveSlice (factorSlice s ψ B T) B T := by + constructor + · intro p hb ht + simp only [factorSlice, hb, ht, and_self, ↓reduceIte] + exact Finset.prod_pos fun G hG => hψ G hG _ + · intro p h + simp [factorSlice, h] + + + +theorem factorSlice_signature (s : Finset (Finset ι)) + (ψ : Finset ι → ℤ → ℝ) (B : ι → ℤ) (T : ℤ) + (hl : IsLaminar s) (hψ : ∀ G ∈ s, ∀ z, 0 < ψ G z) + (hc : ∀ G ∈ s, ∀ z, ψ G z * ψ G (z-2) ≤ ψ G (z-1)^2) : + HasSignature (factorSlice s ψ B T) B T := by + intro p hp ht + have hM : twoRemoval (factorSlice s ψ B T) p = + truncatedFactorMatrix s ψ (fun G => ∑ i ∈ G, p i) p := by + funext i j + have htotal : (∑ k, removePair p i j k) = T := by + rw [sum_removePair] + simpa [ht] using (show T+2-1-1 = T by omega) + simp only [twoRemoval, factorSlice, truncatedFactorMatrix, htotal, and_true, + removePair_inBox_iff B p hp i j] + split_ifs <;> simp_all [factorRemoval, sum_removePair] + rw [hM] + exact truncated_laminar_signature s ψ _ p hl hψ (fun G hG => hc G hG _) + +end Laminar + +section ScalarFactors + + +def PosLogConcave (ψ : ℤ → ℝ) : Prop := + (∀ z, 0 < ψ z) ∧ (∀ z, ψ z * ψ (z-2) ≤ ψ (z-1)^2) + +theorem posLogConcave_of_convex_exponent (η : ℝ) (hη : 0 < η) (hη1 : η < 1) + (D : ℤ → ℕ) (hD : ∀ z, 2 * D (z-1) ≤ D z + D (z-2)) : + PosLogConcave (fun z => η ^ D z) := by + refine ⟨fun z => pow_pos hη _, ?_⟩ + intro z + rw [← pow_add, ← pow_mul] + apply pow_le_pow_of_le_one hη.le hη1.le + simpa [Nat.mul_comm] using hD z + +theorem posLogConcave_abs (η : ℝ) (hη : 0 < η) (hη1 : η < 1) : + PosLogConcave (fun z : ℤ => η ^ z.natAbs) := by + apply posLogConcave_of_convex_exponent η hη hη1 + intro z + have ht := Int.natAbs_add_le z (z-2) + rw [show z+(z-2) = 2*(z-1) by ring, Int.natAbs_mul] at ht + simpa using ht + +theorem posLogConcave_positive_part (η : ℝ) (hη : 0 < η) (hη1 : η < 1) : + PosLogConcave (fun z : ℤ => η ^ z.toNat) := by + apply posLogConcave_of_convex_exponent η hη hη1 + intro z + omega + +theorem PosLogConcave.translate {ψ : ℤ → ℝ} (h : PosLogConcave ψ) (a : ℤ) : + PosLogConcave (fun z => ψ (z+a)) := by + refine ⟨fun z => h.1 _, ?_⟩ + intro z + have ht := h.2 (z+a) + convert ht using 1 <;> congr 2 <;> ring_nf + +theorem PosLogConcave.reflect {ψ : ℤ → ℝ} (h : PosLogConcave ψ) : + PosLogConcave (fun z => ψ (-z)) := by + refine ⟨fun z => h.1 _, ?_⟩ + intro z + have ht := h.2 (2-z) + rw [show 2-z-2 = -z by ring, show 2-z-1 = -(z-1) by ring] at ht + rw [show 2-z = -(z-2) by ring, mul_comm] at ht + exact ht + +theorem posLogConcave_prod {α : Type*} (s : Finset α) (ψ : α → ℤ → ℝ) + (hψ : ∀ a ∈ s, PosLogConcave (ψ a)) : + PosLogConcave (fun z => ∏ a ∈ s, ψ a z) := by + refine ⟨fun z => Finset.prod_pos fun a ha => (hψ a ha).1 z, ?_⟩ + intro z + rw [← Finset.prod_mul_distrib, ← Finset.prod_pow] + exact Finset.prod_le_prod₀ + (fun a ha => mul_nonneg ((hψ a ha).1 _).le ((hψ a ha).1 _).le) + (fun a ha => (hψ a ha).2 z) + +end ScalarFactors + +section IndexedFactors +variable {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] [DecidableEq α] + +noncomputable def groupedSequence (G : α → Finset ι) (ψ : α → ℤ → ℝ) + (H : Finset ι) (z : ℤ) : ℝ := ∏ a ∈ Finset.univ.filter (fun a => G a = H), ψ a z + +noncomputable def indexedFactorSlice (G : α → Finset ι) (ψ : α → ℤ → ℝ) + (B : ι → ℤ) (T : ℤ) (p : ι → ℤ) : ℝ := by + classical + exact if InBox B p ∧ (∑ i, p i) = T then ∏ a, ψ a (∑ i ∈ G a, p i) else 0 + + + +omit [DecidableEq α] in +theorem indexedFactorSlice_eq (G : α → Finset ι) (ψ : α → ℤ → ℝ) + (B : ι → ℤ) (T : ℤ) : indexedFactorSlice G ψ B T = + factorSlice (Finset.univ.image G) (groupedSequence G ψ) B T := by + classical + funext p + dsimp [indexedFactorSlice, factorSlice] + split_ifs + · symm + calc + (∏ H ∈ Finset.univ.image G, groupedSequence G ψ H (∑ i ∈ H, p i)) = + ∏ H ∈ Finset.univ.image G, ∏ a ∈ Finset.univ.filter (fun a => G a = H), + ψ a (∑ i ∈ G a, p i) := by + apply Finset.prod_congr rfl + intro H hH + apply Finset.prod_congr rfl + intro a ha + rw [(Finset.mem_filter.mp ha).2] + _ = ∏ a, ψ a (∑ i ∈ G a, p i) := + Finset.prod_fiberwise_of_maps_to (fun a _ => Finset.mem_image.mpr ⟨a, Finset.mem_univ _, rfl⟩) _ + · rfl + +omit [DecidableEq α] in +theorem indexedFactorSlice_signature (G : α → Finset ι) (ψ : α → ℤ → ℝ) + (B : ι → ℤ) (T : ℤ) + (hl : ∀ a b, G a ⊆ G b ∨ G b ⊆ G a ∨ Disjoint (G a) (G b)) + (hψ : ∀ a, PosLogConcave (ψ a)) : HasSignature (indexedFactorSlice G ψ B T) B T := by + rw [indexedFactorSlice_eq] + have hp (H : Finset ι) : PosLogConcave (groupedSequence G ψ H) := + posLogConcave_prod _ ψ (fun a _ => hψ a) + apply factorSlice_signature + · rintro H hH J hJ + obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hH + obtain ⟨b, _, rfl⟩ := Finset.mem_image.mp hJ + exact hl a b + · exact fun H _ => (hp H).1 + · exact fun H _ => (hp H).2 + +end IndexedFactors + +section SoftWeight +variable {m n : ℕ} + +abbrev Cell (m n : ℕ) := Fin m × Fin n +abbrev Coordinate (m n : ℕ) := Bool × Cell m n +abbrev FactorLabel (m n : ℕ) := (Fin m ⊕ Fin n) × Bool + + + +def coordinateLine (a : Coordinate m n) : Fin m ⊕ Fin n := + if a.1 then Sum.inl a.2.1 else Sum.inr a.2.2 + +def softFactorSet (small : Finset (Cell m n)) (a : FactorLabel m n) : + Finset (Coordinate m n) := + Finset.univ.filter fun v => coordinateLine v = a.1 ∧ (a.2 = true → v.2 ∈ small) + +theorem softFactorSet_laminar (small : Finset (Cell m n)) : + ∀ a b, softFactorSet small a ⊆ softFactorSet small b ∨ + softFactorSet small b ⊆ softFactorSet small a ∨ + Disjoint (softFactorSet small a) (softFactorSet small b) := by + rintro ⟨l, a⟩ ⟨k, b⟩ + by_cases h : l = k + · subst k + cases a <;> cases b + · exact Or.inl (Finset.Subset.refl _) + · right; left + intro v hv + simp only [softFactorSet, Finset.mem_filter, Finset.mem_univ, true_and, + Bool.false_eq_true, false_implies, and_true] at * + exact hv.1 + · left + intro v hv + simp only [softFactorSet, Finset.mem_filter, Finset.mem_univ, true_and, + Bool.false_eq_true, false_implies, and_true] at * + exact hv.1 + · exact Or.inl (Finset.Subset.refl _) + · right; right + apply Finset.disjoint_left.mpr + intro v hv hk + have hv' := (Finset.mem_filter.mp hv).2.1 + have hk' := (Finset.mem_filter.mp hk).2.1 + exact h (hv'.symm.trans hk') + + + +def softFactorExponent (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) + (a : FactorLabel m n) (z : ℤ) : ℕ := + match a with + | (Sum.inl i, false) => (z - rb i).natAbs + | (Sum.inl i, true) => (z - r i).toNat + | (Sum.inr j, false) => ((∑ i, B (i,j)) - z - cb j).natAbs + | (Sum.inr j, true) => ((∑ i, if (i,j) ∈ small then B (i,j) else 0) - z - c j).toNat + +noncomputable def softFactor (η : ℝ) (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) (a : FactorLabel m n) : ℤ → ℝ := + fun z => η ^ softFactorExponent r rb c cb B small a z + +theorem softFactor_logconcave (η : ℝ) (hη : 0 < η) (hη1 : η < 1) + (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) (B : Cell m n → ℤ) + (small : Finset (Cell m n)) (a : FactorLabel m n) : + PosLogConcave (softFactor η r rb c cb B small a) := by + obtain ⟨l, b⟩ := a + cases l with + | inl i => + cases b + · change PosLogConcave (fun z => η ^ (z - rb i).natAbs) + simpa only [sub_eq_add_neg] using + (posLogConcave_abs η hη hη1).translate (-rb i) + · change PosLogConcave (fun z => η ^ (z - r i).toNat) + simpa only [sub_eq_add_neg] using + (posLogConcave_positive_part η hη hη1).translate (-r i) + | inr j => + cases b + · have h := ((posLogConcave_abs η hη hη1).translate + ((∑ i, B (i,j)) - cb j)).reflect + convert h using 1 + funext z + dsimp [softFactor, softFactorExponent] + congr 2 + ring + · have h := ((posLogConcave_positive_part η hη hη1).translate + ((∑ i, if (i,j) ∈ small then B (i,j) else 0) - c j)).reflect + convert h using 1 + funext z + dsimp [softFactor, softFactorExponent] + congr 2 + ring + + + +def softPenalty (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) : ℕ := + ∑ a : FactorLabel m n, softFactorExponent r rb c cb B small a + (∑ v ∈ softFactorSet small a, p v) + +noncomputable def softWeight (η : ℝ) (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) : ℝ := by + classical + exact if InBox (fun v => B v.2) p ∧ (∑ v, p v) = ∑ s, B s + then η ^ softPenalty r rb c cb B small p else 0 + +theorem softWeight_eq_factorSlice (η : ℝ) (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) : + softWeight η r rb c cb B small = indexedFactorSlice (softFactorSet small) + (softFactor η r rb c cb B small) (fun v => B v.2) (∑ s, B s) := by + classical + funext p + simp only [softWeight, indexedFactorSlice] + split_ifs + · simp [softPenalty, softFactor, Finset.prod_pow_eq_pow_sum] + · rfl + +theorem softWeight_signature (η : ℝ) (hη : 0 < η) (hη1 : η < 1) + (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) (B : Cell m n → ℤ) + (small : Finset (Cell m n)) : + HasSignature (softWeight η r rb c cb B small) (fun v => B v.2) (∑ s, B s) := by + rw [softWeight_eq_factorSlice] + apply indexedFactorSlice_signature + · exact softFactorSet_laminar small + · exact softFactor_logconcave η hη hη1 r rb c cb B small + +theorem softFactorSet_sum_row (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) + (i : Fin m) (b : Bool) : + (∑ v ∈ softFactorSet small (Sum.inl i,b), p v) = + ∑ j, if b = true → (i,j) ∈ small then p (true,(i,j)) else 0 := by + cases b <;> + simp [softFactorSet, coordinateLine, Finset.sum_filter, Fintype.sum_prod_type, + ite_and, Finset.sum_ite_irrel] + +theorem softFactorSet_sum_col (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) + (j : Fin n) (b : Bool) : + (∑ v ∈ softFactorSet small (Sum.inr j,b), p v) = + ∑ i, if b = true → (i,j) ∈ small then p (false,(i,j)) else 0 := by + cases b <;> + simp [softFactorSet, coordinateLine, Finset.sum_filter, Fintype.sum_prod_type, + ite_and] + + + +theorem softPenalty_expansion (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) : + softPenalty r rb c cb B small p = + (∑ i, ((∑ j, p (true,(i,j))) - rb i).natAbs) + + (∑ j, ((∑ i, (B (i,j) - p (false,(i,j)))) - cb j).natAbs) + + (∑ i, ((∑ j, if (i,j) ∈ small then p (true,(i,j)) else 0) - r i).toNat) + + (∑ j, ((∑ i, if (i,j) ∈ small then B (i,j) - p (false,(i,j)) else 0) - c j).toNat) := by + simp only [softPenalty, Fintype.sum_prod_type, Fintype.sum_sum_type, Fintype.sum_bool] + simp only [softFactorSet_sum_row, softFactorSet_sum_col, Bool.false_eq_true, + false_implies, ite_true, true_implies, softFactorExponent] + simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib] + have hsplit (j : Fin n) : + (∑ i, if (i,j) ∈ small then B (i,j) - p (false,(i,j)) else 0) = + (∑ i, if (i,j) ∈ small then B (i,j) else 0) - + (∑ i, if (i,j) ∈ small then p (false,(i,j)) else 0) := by + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i _ + split_ifs <;> ring + have hcol (j : Fin n) : + (∑ i, (B (i,j) - p (false,(i,j)))) = (∑ i, B (i,j)) - (∑ i, p (false,(i,j))) := + Finset.sum_sub_distrib (s := Finset.univ) (fun i : Fin m => B (i,j)) + (fun i => p (false,(i,j))) + simp only [hsplit] + omega + +end SoftWeight + +section BalancedClosure +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + + +def pairAssembly {R : Type*} (p : ι → R) (a b : R) : ι ⊕ Bool → R := + Sum.elim p (fun t => if t then a else b) + +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem pairAssembly_old {R : Type*} (p : ι → R) (a b : R) (i : ι) : + pairAssembly p a b (Sum.inl i) = p i := rfl +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem pairAssembly_first {R : Type*} (p : ι → R) (a b : R) : + pairAssembly p a b (Sum.inr true) = a := rfl +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem pairAssembly_second {R : Type*} (p : ι → R) (a b : R) : + pairAssembly p a b (Sum.inr false) = b := rfl + +noncomputable def pairAssemblyLinear : ((ι → ℝ) × ℝ × ℝ) →ₗ[ℝ] (ι ⊕ Bool → ℝ) where + toFun v := pairAssembly v.1 v.2.1 v.2.2 + map_add' := by intros; funext i; cases i with + | inl i => rfl + | inr b => cases b <;> rfl + map_smul' := by intros; funext i; cases i with + | inl i => rfl + | inr b => cases b <;> rfl + + + +theorem signature_comp {W : Type*} [AddCommGroup W] [Module ℝ W] + [FiniteDimensional ℝ W] (Q : QuadraticForm ℝ V) (hs : sigPos Q ≤ 1) + (L : W →ₗ[ℝ] V) : sigPos (Q.comp L) ≤ 1 := by + by_cases h : ∃ e, 0 < Q e + · obtain ⟨e, he⟩ := h + apply sigPos_le_one_of_kernel _ ((Q.associated e).comp L) + intro x hx + have hp := positive_projection Q hs e (L x) he + have hc : Q.associated (L x) e = 0 := by + rw [QuadraticMap.associated_isSymm ℝ Q] + exact hx + simpa [hc] using hp + · push Not at h + apply sigPos_le_one_of_kernel _ 0 + intro x _ + exact h (L x) + +noncomputable def columnLinear (s : ι → ℝ) : (ι → ℝ) →ₗ[ℝ] ℝ := + ∑ i, (s i) • LinearMap.proj i + +omit [DecidableEq ι] in +@[simp] theorem columnLinear_apply (s h : ι → ℝ) : + columnLinear s h = ∑ i, s i * h i := by simp [columnLinear] + + +omit [DecidableEq ι] in +theorem matrixForm_pairAssembly (M : (ι ⊕ Bool) → (ι ⊕ Bool) → ℝ) + (hsym : ∀ i j, M i j = M j i) : + (matrixForm M).comp pairAssemblyLinear = + pairForm (matrixForm (fun i j => M (Sum.inl i) (Sum.inl j))) + (columnLinear fun i => M (Sum.inl i) (Sum.inr true)) + (columnLinear fun i => M (Sum.inl i) (Sum.inr false)) + (M (Sum.inr true) (Sum.inr true)) (M (Sum.inr true) (Sum.inr false)) + (M (Sum.inr false) (Sum.inr false)) := by + ext v + obtain ⟨h,a,b⟩ := v + simp only [QuadraticMap.comp_apply, pairAssemblyLinear, LinearMap.coe_mk, AddHom.coe_mk, + matrixForm_apply, Fintype.sum_sum_type, Fintype.sum_bool, pairAssembly_old, + pairAssembly_first, pairAssembly_second, pairForm_apply, columnLinear_apply] + simp_rw [hsym (Sum.inr true) (Sum.inl _), hsym (Sum.inr false) (Sum.inl _), + hsym (Sum.inr false) (Sum.inr true)] + have h1 : (∑ i, M (Sum.inl i) (Sum.inr true) * a * h i) = + (∑ i, M (Sum.inl i) (Sum.inr true) * h i) * a := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + ring + have h2 : (∑ i, M (Sum.inl i) (Sum.inr false) * b * h i) = + (∑ i, M (Sum.inl i) (Sum.inr false) * h i) * b := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + ring + rw [h1, h2] + simp only [Finset.sum_add_distrib, ← Finset.sum_mul] + ring + +def removeOne (p : ι → ℤ) (i : ι) : ι → ℤ := + fun k => p k - if k = i then 1 else 0 + +omit [DecidableEq ι] in +theorem pairAssembly_sum (p : ι → ℤ) (a b : ℤ) : + (∑ i, pairAssembly p a b i) = (∑ i, p i) + a + b := by + simp [Fintype.sum_sum_type, pairAssembly, add_assoc] + +omit [Fintype ι] [DecidableEq ι] in +theorem pairAssembly_inBox (B p : ι → ℤ) (C a b : ℤ) : + InBox (pairAssembly B C C) (pairAssembly p a b) ↔ + InBox B p ∧ (0 ≤ a ∧ a ≤ C) ∧ (0 ≤ b ∧ b ≤ C) := by + constructor + · intro h + exact ⟨fun i => h (Sum.inl i), h (Sum.inr true), h (Sum.inr false)⟩ + · rintro ⟨hp, ha, hb⟩ i + cases i with + | inl i => exact hp i + | inr b => cases b + · exact hb + · exact ha + +theorem PositiveSlice.zero_of_negative {κ : Type*} [Fintype κ] + {f : (κ → ℤ) → ℝ} {B : κ → ℤ} {T : ℤ} + (hf : PositiveSlice f B T) (p : κ → ℤ) (i : κ) (hi : p i < 0) : f p = 0 := by + apply hf.2 + rintro ⟨h, _⟩ + exact (not_lt_of_ge (h i).1) hi + +omit [Fintype ι] in +theorem removePair_pair_old (p : ι → ℤ) (a b : ℤ) (i j : ι) : + removePair (pairAssembly p a b) (Sum.inl i) (Sum.inl j) = + pairAssembly (removePair p i j) a b := by + funext k + cases k with + | inl k => simp [removePair, pairAssembly] + | inr k => cases k <;> simp [removePair, pairAssembly] + +omit [Fintype ι] in +theorem removePair_pair_first (p : ι → ℤ) (a b : ℤ) (i : ι) : + removePair (pairAssembly p a b) (Sum.inl i) (Sum.inr true) = + pairAssembly (removeOne p i) (a-1) b := by + funext k + cases k with + | inl k => simp [removePair, pairAssembly, removeOne] + | inr k => cases k <;> simp [removePair, pairAssembly] + +omit [Fintype ι] in +theorem removePair_pair_second (p : ι → ℤ) (a b : ℤ) (i : ι) : + removePair (pairAssembly p a b) (Sum.inl i) (Sum.inr false) = + pairAssembly (removeOne p i) a (b-1) := by + funext k + cases k with + | inl k => simp [removePair, pairAssembly, removeOne] + | inr k => cases k <;> simp [removePair, pairAssembly] + +omit [Fintype ι] in +theorem removePair_pair_fresh (p : ι → ℤ) (a b : ℤ) (s t : Bool) : + removePair (pairAssembly p a b) (Sum.inr s) (Sum.inr t) = + pairAssembly p (a - (if s then 1 else 0) - (if t then 1 else 0)) + (b - (if s then 0 else 1) - (if t then 0 else 1)) := by + funext k + cases k with + | inl k => simp [removePair, pairAssembly] + | inr k => cases k <;> cases s <;> cases t <;> simp [removePair, pairAssembly] + +noncomputable def pairQ (f : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (D j : ℕ) : + QuadraticForm ℝ (ι → ℝ) := + matrixForm (twoRemoval (fun q => f (pairAssembly q (j:ℤ) ((D:ℤ)-j))) p) + +noncomputable def pairS (f : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (D j : ℕ) : + (ι → ℝ) →ₗ[ℝ] ℝ := + columnLinear (fun i => f (pairAssembly (removeOne p i) (j:ℤ) ((D:ℤ)-1-j))) + +noncomputable def pairU (f : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (D j : ℕ) : ℝ := + f (pairAssembly p ((j:ℤ)-1) ((D:ℤ)-1-j)) + + + +theorem pair_block_identity (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C T : ℤ) + (hf : PositiveSlice f (pairAssembly B C C) T) (p : ι → ℤ) (D j : ℕ) : + (matrixForm (twoRemoval f (pairAssembly p (j:ℤ) ((D:ℤ)-j)))).comp pairAssemblyLinear = + pairForm (pairQ f p D j) (pairPrevious (pairS f p D) j) (pairS f p D j) + (pairU f p D (j-1)) (pairU f p D j) (pairU f p D (j+1)) := by + rw [matrixForm_pairAssembly (twoRemoval f (pairAssembly p (j:ℤ) ((D:ℤ)-j))) + (fun i k => congrArg f (removePair_comm _ i k))] + simp only [twoRemoval, removePair_pair_old, removePair_pair_first, + removePair_pair_second, removePair_pair_fresh, ↓reduceIte, sub_zero] + have hSa : (columnLinear fun i => f (pairAssembly (removeOne p i) ((j:ℤ)-1) ((D:ℤ)-j))) = + pairPrevious (pairS f p D) j := by + by_cases hj : j = 0 + · subst j + apply LinearMap.ext + intro h + simp only [pairPrevious, ↓reduceIte, LinearMap.zero_apply, columnLinear_apply] + apply Finset.sum_eq_zero + intro i _ + have hz := hf.zero_of_negative (pairAssembly (removeOne p i) ((0:ℤ)-1) ((D:ℤ)-0)) + (Sum.inr true) (by simp) + calc + _ = 0 * h i := congrArg (fun z => z * h i) hz + _ = 0 := zero_mul _ + · simp only [pairPrevious, ite_eq_right hj, pairS] + congr 1 + funext i + congr 2 + · simp [Nat.cast_sub (by omega : 1 ≤ j)] + · simp [Nat.cast_sub (by omega : 1 ≤ j)] + have haa : f (pairAssembly p ((j:ℤ)-1-1) ((D:ℤ)-j)) = pairU f p D (j-1) := by + by_cases hj : j = 0 + · subst j + dsimp [pairU] + rw [hf.zero_of_negative _ (Sum.inr true) (by simp), + hf.zero_of_negative _ (Sum.inr true) (by simp)] + · simp only [pairU, Nat.cast_sub (by omega : 1 ≤ j), Nat.cast_one] + congr 2 + ring + rw [hSa, haa] + congr 1 + · dsimp [pairS] + congr 1 + funext i + congr 2 + ring + · dsimp [pairU] + congr 2 <;> ring + · dsimp [pairU] + congr 2 <;> ring + +omit [DecidableEq ι] in +theorem pairU_positive (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C : ℕ) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) (p : ι → ℤ) + (hp : InBox B p) (D : ℕ) (hDC : D ≤ C+1) + (ht : (∑ i, p i) + (D:ℤ) = T+2) (j : ℕ) (hj : 0 < j) (hjD : j < D) : + 0 < pairU f p D j := by + apply hf.1 + · rw [pairAssembly_inBox] + exact ⟨hp, by omega, by omega⟩ + · rw [pairAssembly_sum] + omega + +omit [DecidableEq ι] in +theorem pairU_zero (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C T : ℤ) + (hf : PositiveSlice f (pairAssembly B C C) T) (p : ι → ℤ) (D j : ℕ) + (hj : j = 0 ∨ D ≤ j) : pairU f p D j = 0 := by + rcases hj with rfl | hj + · exact hf.zero_of_negative _ (Sum.inr true) (by simp [pairAssembly]) + · exact hf.zero_of_negative _ (Sum.inr false) (by dsimp [pairAssembly]; omega) + +theorem pairS_top (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C T : ℤ) + (hf : PositiveSlice f (pairAssembly B C C) T) (p : ι → ℤ) (D : ℕ) : + pairS f p D D = 0 := by + apply LinearMap.ext + intro h + simp only [pairS, columnLinear_apply, LinearMap.zero_apply] + apply Finset.sum_eq_zero + intro i _ + rw [hf.zero_of_negative _ (Sum.inr false) (by dsimp [pairAssembly]; omega), zero_mul] + +theorem pair_block_signature (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C : ℕ) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (hs : HasSignature f (pairAssembly B (C:ℤ) C) T) + (p : ι → ℤ) (hp : InBox B p) (D : ℕ) + (ht : (∑ i, p i) + (D:ℤ) = T+2) + (j : ℕ) (hj : j ≤ D) (hjC : j ≤ C) (hDj : D ≤ C+j) : + sigPos (pairForm (pairQ f p D j) (pairPrevious (pairS f p D) j) (pairS f p D j) + (pairU f p D (j-1)) (pairU f p D j) (pairU f p D (j+1))) ≤ 1 := by + rw [← pair_block_identity f B (C:ℤ) T hf p D j] + apply signature_comp + apply hs + · rw [pairAssembly_inBox] + exact ⟨hp, by omega, by omega⟩ + · rw [pairAssembly_sum] + omega + +noncomputable def balancedMarginal (f : (ι ⊕ Bool → ℤ) → ℝ) (C : ℕ) + (p : ι → ℤ) : ℝ := ∑ j ∈ Finset.range (C+1), + f (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + +omit [DecidableEq ι] in +theorem matrixForm_sum {α : Type*} (s : Finset α) (M : α → ι → ι → ℝ) : + matrixForm (fun i k => ∑ a ∈ s, M a i k) = ∑ a ∈ s, matrixForm (M a) := by + ext h + simp only [matrixForm_apply, sum_apply, Finset.sum_mul] + calc + _ = ∑ i, ∑ a ∈ s, ∑ k, M a i k * h i * h k := by + apply Finset.sum_congr rfl + intro i _ + exact Finset.sum_comm + _ = _ := Finset.sum_comm + +theorem balancedMarginal_signature (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (hC : 2 ≤ C) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (hs : HasSignature f (pairAssembly B (C:ℤ) C) T) : + HasSignature (balancedMarginal f C) B (T-C) := by + intro p hp ht + have htotal : (∑ i, p i) + (C:ℤ) = T+2 := by omega + have heq : matrixForm (twoRemoval (balancedMarginal f C) p) = + ∑ j ∈ Finset.range (C+1), pairQ f p C j := by + exact matrixForm_sum (Finset.range (C+1)) + (fun j i k => f (pairAssembly (removePair p i k) (j:ℤ) ((C:ℤ)-j))) + rw [heq] + apply pair_summation_signature C hC (pairU f p C) (pairS f p C) (pairQ f p C) + · exact pairU_positive f B C T hf p hp C (by omega) htotal + · exact pairU_zero f B (C:ℤ) T hf p C + · exact pairS_top f B (C:ℤ) T hf p C + · intro j hj + exact pair_block_signature f B C T hf hs p hp C htotal j hj hj (by omega) + +omit [DecidableEq ι] in +theorem balancedMarginal_positive (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (T : ℤ) (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) : + PositiveSlice (balancedMarginal f C) B (T-C) := by + constructor + · intro p hp ht + apply Finset.sum_pos + · intro j hj + have hjC : j ≤ C := by simpa using Finset.mem_range.mp hj + apply hf.1 + · rw [pairAssembly_inBox] + exact ⟨hp, by omega, by omega⟩ + · rw [pairAssembly_sum] + omega + · exact ⟨0, by simp⟩ + · intro p hp + apply Finset.sum_eq_zero + intro j _ + apply hf.2 + rintro ⟨hb, ht⟩ + apply hp + rw [pairAssembly_inBox] at hb + rw [pairAssembly_sum] at ht + exact ⟨hb.1, by omega⟩ + + + +theorem actual_pair_weighted (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (hC : 2 ≤ C) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (hs : HasSignature f (pairAssembly B (C:ℤ) C) T) + (p : ι → ℤ) (hp : InBox B p) (ht : (∑ i, p i) + (C+1:ℕ) = T+2) + (h : ι → ℝ) (hbal : ∑ j ∈ Finset.range (C+1), pairS f p (C+1) j h = 0) : + 2 * (∑ j ∈ Finset.range (C+2), pairU f p (C+1) j * + pairCumulative (C+1) (pairU f p (C+1)) (pairS f p (C+1)) h j ^ 2) ≤ + -(∑ j ∈ Finset.range (C+2), ((j:ℝ) * (C+1-j)) • pairQ f p (C+1) j) h := by + have hw := pair_summation_weighted (C+1) (by omega) + (pairU f p (C+1)) (pairS f p (C+1)) (pairQ f p (C+1)) + (pairU_positive f B C T hf p hp (C+1) (by omega) ht) + (pairU_zero f B (C:ℤ) T hf p (C+1)) + (pairS_top f B (C:ℤ) T hf p (C+1)) + (fun j hj hjC => pair_block_signature f B C T hf hs p hp (C+1) ht j + (by omega) (by omega) (by omega)) h hbal + simpa only [Nat.cast_add, Nat.cast_one] using hw + +end BalancedClosure + +section ReindexAndContext +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + +noncomputable def coordinatePullback (e : ι ≃ κ) : (κ → ℝ) →ₗ[ℝ] (ι → ℝ) where + toFun p := p ∘ e + map_add' := by intros; rfl + map_smul' := by intros; rfl + +omit [Fintype ι] [Fintype κ] in +theorem removePair_reindex (e : ι ≃ κ) (p : κ → ℤ) (i j : ι) : + removePair (p ∘ e) i j = (removePair p (e i) (e j)) ∘ e := by + funext k + simp [removePair, e.injective.eq_iff] + +omit [DecidableEq ι] [DecidableEq κ] in +theorem matrixForm_reindex (e : ι ≃ κ) (M : κ → κ → ℝ) : + (matrixForm fun i j => M (e i) (e j)) = (matrixForm M).comp (coordinatePullback e.symm) := by + ext h + simp only [matrixForm_apply, QuadraticMap.comp_apply, coordinatePullback, + LinearMap.coe_mk, AddHom.coe_mk, Function.comp_apply] + rw [← Equiv.sum_comp e] + apply Finset.sum_congr rfl + intro i _ + rw [← Equiv.sum_comp e] + simp + + + +theorem HasSignature.reindex {f : (ι → ℤ) → ℝ} {B : ι → ℤ} {T : ℤ} + (hf : HasSignature f B T) (e : ι ≃ κ) : + HasSignature (fun p => f (p ∘ e)) (B ∘ e.symm) T := by + intro p hp ht + have hb : InBox B (p ∘ e) := by + intro i + simpa [Function.comp_def] using hp (e i) + have htotal : (∑ i, (p ∘ e) i) = T+2 := by simpa [Function.comp_def, Equiv.sum_comp e] using ht + have hs := hf (p ∘ e) hb htotal + have hM : twoRemoval (fun p => f (p ∘ e)) p = + fun i j => twoRemoval f (p ∘ e) (e.symm i) (e.symm j) := by + funext i j + simp [twoRemoval, removePair_reindex] + rw [hM, matrixForm_reindex e.symm] + exact signature_comp _ hs _ + +omit [DecidableEq ι] [DecidableEq κ] in +theorem PositiveSlice.reindex {f : (ι → ℤ) → ℝ} {B : ι → ℤ} {T : ℤ} + (hf : PositiveSlice f B T) (e : ι ≃ κ) : + PositiveSlice (fun p => f (p ∘ e)) (B ∘ e.symm) T := by + have hbox (p : κ → ℤ) : InBox (B ∘ e.symm) p ↔ InBox B (p ∘ e) := by + constructor + · intro hp i + simpa [Function.comp_def] using hp (e i) + · intro hp i + simpa [Function.comp_def] using hp (e.symm i) + have hsum (p : κ → ℤ) : (∑ i, (p ∘ e) i) = ∑ i, p i := Equiv.sum_comp e p + constructor + · intro p hp ht + apply hf.1 _ ((hbox p).mp hp) + rw [hsum, ht] + · intro p hp + apply hf.2 + simpa only [← hbox, hsum] using hp + +noncomputable def rightCoordinates : (κ → ℝ) →ₗ[ℝ] (ι ⊕ κ → ℝ) where + toFun p := Sum.elim 0 p + map_add' := by intros; funext i; cases i <;> simp + map_smul' := by intros; funext i; cases i <;> simp + +omit [DecidableEq ι] [DecidableEq κ] in +theorem matrixForm_right (M : (ι ⊕ κ) → (ι ⊕ κ) → ℝ) : + matrixForm (fun i j => M (Sum.inr i) (Sum.inr j)) = + (matrixForm M).comp rightCoordinates := by + ext h + simp [matrixForm_apply, rightCoordinates, Fintype.sum_sum_type] + +omit [Fintype ι] [Fintype κ] in +theorem removePair_fixed (σ : ι → ℤ) (p : κ → ℤ) (i j : κ) : + removePair (Sum.elim σ p) (Sum.inr i) (Sum.inr j) = Sum.elim σ (removePair p i j) := by + funext k + cases k <;> simp [removePair] + +theorem HasSignature.fixedContext {f : (ι ⊕ κ → ℤ) → ℝ} {A : ι → ℤ} {B : κ → ℤ} {T : ℤ} + (hf : HasSignature f (Sum.elim A B) T) (σ : ι → ℤ) (hσ : InBox A σ) : + HasSignature (fun p => f (Sum.elim σ p)) B (T - ∑ i, σ i) := by + intro p hp ht + have hb : InBox (Sum.elim A B) (Sum.elim σ p) := by + intro i + cases i with + | inl i => exact hσ i + | inr i => exact hp i + have htotal : (∑ i, Sum.elim σ p i) = T+2 := by + simp only [Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr] + omega + have hs := hf (Sum.elim σ p) hb htotal + have hM : twoRemoval (fun p => f (Sum.elim σ p)) p = + fun i j => twoRemoval f (Sum.elim σ p) (Sum.inr i) (Sum.inr j) := by + funext i j + simp [twoRemoval, removePair_fixed] + rw [hM, matrixForm_right] + exact signature_comp _ hs _ + +omit [DecidableEq ι] [DecidableEq κ] in +theorem PositiveSlice.fixedContext {f : (ι ⊕ κ → ℤ) → ℝ} {A : ι → ℤ} {B : κ → ℤ} {T : ℤ} + (hf : PositiveSlice f (Sum.elim A B) T) (σ : ι → ℤ) (hσ : InBox A σ) : + PositiveSlice (fun p => f (Sum.elim σ p)) B (T - ∑ i, σ i) := by + constructor + · intro p hp ht + apply hf.1 + · intro i + cases i with + | inl i => exact hσ i + | inr i => exact hp i + · simp only [Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr] + omega + · intro p hp + apply hf.2 + rintro ⟨hb, ht⟩ + apply hp + refine ⟨fun i => hb (Sum.inr i), ?_⟩ + simp only [Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr] at ht + omega + +end ReindexAndContext + +section ManyBalanced +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def balanceBox {k : ℕ} (A : ι → ℤ) (C : Fin k → ℕ) : + ι ⊕ (Fin k × Bool) → ℤ := Sum.elim A (fun sb => (C sb.1 : ℤ)) + +def balanceProfile {k : ℕ} (C : Fin k → ℕ) (a : ∀ s, Fin (C s+1)) : + Fin k × Bool → ℤ := fun sb => if sb.2 then (a sb.1:ℕ) else (C sb.1:ℤ) - (a sb.1:ℕ) + +noncomputable def balancedSlots {k : ℕ} (f : (ι ⊕ (Fin k × Bool) → ℤ) → ℝ) + (C : Fin k → ℕ) (p : ι → ℤ) : ℝ := + ∑ a : ∀ s, Fin (C s+1), f (Sum.elim p (balanceProfile C a)) + +def splitSlot (k : ℕ) : (ι ⊕ (Fin (k+1) × Bool)) ≃ ((ι ⊕ (Fin k × Bool)) ⊕ Bool) where + toFun := Sum.elim (fun i => Sum.inl (Sum.inl i)) + (fun sb => Fin.cases (Sum.inr sb.2) (fun s => Sum.inl (Sum.inr (s,sb.2))) sb.1) + invFun := Sum.elim (Sum.elim Sum.inl (fun sb => Sum.inr (sb.1.succ, sb.2))) + (fun b => Sum.inr (0,b)) + left_inv := by + intro i + rcases i with i | ⟨s,b⟩ + · rfl + · refine Fin.cases ?_ (fun j => ?_) s <;> rfl + right_inv := by + intro i + rcases i with (i | ⟨s,b⟩) | b <;> rfl + +def piHeadEquiv {k : ℕ} (D : Fin (k+1) → Type*) : + (∀ s, D s) ≃ D 0 × (∀ s : Fin k, D s.succ) where + toFun a := (a 0, fun s => a s.succ) + invFun a := Fin.cons a.1 a.2 + left_inv := by + intro a + funext s + refine Fin.cases ?_ (fun j => ?_) s <;> rfl + right_inv := by intro a; rfl + +omit [Fintype ι] [DecidableEq ι] in +theorem balanceBox_split {k : ℕ} (A : ι → ℤ) (C : Fin (k+1) → ℕ) : + balanceBox A C ∘ (splitSlot k).symm = + pairAssembly (balanceBox A (fun s => C s.succ)) (C 0) (C 0) := by + funext i + rcases i with (i | ⟨s,b⟩) | b + · rfl + · rfl + · cases b <;> rfl + +omit [Fintype ι] [DecidableEq ι] in +theorem balancedSlots_succ {k : ℕ} + (f : (ι ⊕ (Fin (k+1) × Bool) → ℤ) → ℝ) (C : Fin (k+1) → ℕ) : + balancedSlots f C = balancedSlots + (balancedMarginal (fun q => f (q ∘ splitSlot k)) (C 0)) (fun s => C s.succ) := by + funext p + unfold balancedSlots + rw [← Equiv.sum_comp (piHeadEquiv (fun s => Fin (C s+1))).symm] + rw [Fintype.sum_prod_type, Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [balancedMarginal, ← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl + intro j _ + congr 1 + funext i + rcases i with i | ⟨s,b⟩ + · rfl + · refine Fin.cases ?_ (fun t => ?_) s <;> cases b <;> rfl + + + +theorem balancedSlots_closure (k : ℕ) (f : (ι ⊕ (Fin k × Bool) → ℤ) → ℝ) + (A : ι → ℤ) (C : Fin k → ℕ) (hC : ∀ s, 2 ≤ C s) (T : ℤ) + (hp : PositiveSlice f (balanceBox A C) T) + (hs : HasSignature f (balanceBox A C) T) : + PositiveSlice (balancedSlots f C) A (T - ∑ s, (C s:ℤ)) ∧ + HasSignature (balancedSlots f C) A (T - ∑ s, (C s:ℤ)) := by + induction k generalizing T with + | zero => + let e : (ι ⊕ (Fin 0 × Bool)) ≃ ι := Equiv.sumEmpty _ _ + have hbox : balanceBox A C ∘ e.symm = A := by funext i; rfl + have hf : balancedSlots f C = (fun p => f (p ∘ e)) := by + funext p + simp only [balancedSlots, Finset.univ_unique, Finset.sum_singleton] + congr 1 + funext i + rcases i with i | ⟨s,b⟩ + · rfl + · exact Fin.elim0 s + have hsum : (∑ s, (C s:ℤ)) = 0 := by simp + rw [hsum, sub_zero, hf] + simpa only [hbox] using And.intro (hp.reindex e) (hs.reindex e) + | succ k ih => + rw [balancedSlots_succ] + have hp' := hp.reindex (splitSlot k) + have hs' := hs.reindex (splitSlot k) + rw [balanceBox_split] at hp' hs' + have hp'' := balancedMarginal_positive _ _ (C 0) T hp' + have hs'' := balancedMarginal_signature _ _ (C 0) (hC 0) T hp' hs' + have h := ih (balancedMarginal (fun q => f (q ∘ splitSlot k)) (C 0)) + (fun s => C s.succ) (fun s => hC s.succ) (T - (C 0:ℤ)) hp'' hs'' + rw [Fin.sum_univ_succ] + convert h using 1 <;> ring_nf + +end ManyBalanced + +section SoftClosure +attribute [local instance] Classical.propDecidable +variable {m n k : ℕ} {ι κ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + +theorem softWeight_positive (η : ℝ) (hη : 0 < η) + (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) (B : Cell m n → ℤ) + (small : Finset (Cell m n)) : + PositiveSlice (softWeight η r rb c cb B small) (fun v => B v.2) (∑ s, B s) := by + classical + constructor + · intro p hp ht + simp only [softWeight] + rw [ite_eq_left ⟨hp,ht⟩] + exact pow_pos hη _ + · intro p hp + simp only [softWeight, ite_eq_right hp] + + + +theorem softWeight_context_balanced_signature + (η : ℝ) (hη : 0 < η) (hη1 : η < 1) + (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) (B : Cell m n → ℤ) + (small : Finset (Cell m n)) + (e : Coordinate m n ≃ (κ ⊕ (ι ⊕ (Fin k × Bool)))) + (A : κ → ℤ) (D : ι → ℤ) (C : Fin k → ℕ) (hC : ∀ s, 2 ≤ C s) + (he : (fun v => B v.2) ∘ e.symm = Sum.elim A (balanceBox D C)) + (σ : κ → ℤ) (hσ : InBox A σ) : + let Φ := balancedSlots (fun p => softWeight η r rb c cb B small ((Sum.elim σ p) ∘ e)) C + PositiveSlice Φ D ((∑ s, B s) - (∑ i, σ i) - ∑ s, (C s:ℤ)) ∧ + HasSignature Φ D ((∑ s, B s) - (∑ i, σ i) - ∑ s, (C s:ℤ)) := by + have hp := (softWeight_positive η hη r rb c cb B small).reindex e + have hs := (softWeight_signature η hη hη1 r rb c cb B small).reindex e + rw [he] at hp hs + exact balancedSlots_closure k _ D C hC _ (hp.fixedContext σ hσ) (hs.fixedContext σ hσ) + +theorem softWeight_continuous (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) : + Continuous (fun η : ℝ => softWeight η r rb c cb B small p) := by + classical + unfold softWeight + split_ifs + · fun_prop + · fun_prop + + + +theorem softWeight_zero (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) + (B : Cell m n → ℤ) (small : Finset (Cell m n)) (p : Coordinate m n → ℤ) : + softWeight 0 r rb c cb B small p = + if InBox (fun v => B v.2) p ∧ (∑ v, p v) = ∑ s, B s ∧ + softPenalty r rb c cb B small p = 0 then 1 else 0 := by + classical + unfold softWeight + by_cases hb : InBox (fun v => B v.2) p ∧ (∑ v, p v) = ∑ s, B s + · by_cases hd : softPenalty r rb c cb B small p = 0 + · simp [hb.1, hb.2, hd] + · simp [hb.1, hb.2, hd, zero_pow hd] + · simp only [ite_eq_right hb] + symm + apply ite_eq_right + exact fun h => hb ⟨h.1,h.2.1⟩ + +omit [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] in +theorem balancedSoft_continuous + (r rb : Fin m → ℤ) (c cb : Fin n → ℤ) (B : Cell m n → ℤ) + (small : Finset (Cell m n)) + (e : Coordinate m n ≃ (κ ⊕ (ι ⊕ (Fin k × Bool)))) + (σ : κ → ℤ) (C : Fin k → ℕ) (p : ι → ℤ) : + Continuous (fun η : ℝ => balancedSlots + (fun q => softWeight η r rb c cb B small ((Sum.elim σ q) ∘ e)) C p) := by + unfold balancedSlots + apply continuous_finsetSum + intro a _ + exact softWeight_continuous r rb c cb B small _ + +end SoftClosure + +end Signature +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/SmallPoincare.lean b/lean/OAI/Probability/Contingency/SmallPoincare.lean new file mode 100644 index 0000000000000000000000000000000000000000..5373b20ab0ccc377cf23ddd60514eb50722b8e08 --- /dev/null +++ b/lean/OAI/Probability/Contingency/SmallPoincare.lean @@ -0,0 +1,615 @@ +import Mathlib +import OAI.Probability.Contingency.CompletionTranslation + +namespace OAI + +/-! Small Poincare. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n a b : ℕ} (d C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // d^20≤r i}) (ec : Fin b ≃ {j // d^20≤c j}) + (i₀ : Fin a) (j₀ : Fin b) + (hrc : (∑ i,r i)=∑ j,c j) (hd : 14≤d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n≤d) + [Nonempty (GraphState (d^20) r c)] + +theorem smallDim_one (d : ℕ) (hd : 14≤d) : 1≤d := by omega + +local notation "A" => smallData (d^20) (d^12) d r c er ec i₀ j₀ hrc (smallDim_one d hd) hmn + +include hm hn in +theorem small_poincare (hC2 : 2≤C) (hC : ∀ i,paddedRow (d^20) (d^12) r c i≤C) + (H : GraphState (d^20) r c → ℝ) : + (A).chain.variance H ≤ (d:ℝ)^160*(A).chain.energy H := by + have hd' : (1:ℝ)≤d := by exact_mod_cast (smallDim_one d hd) + have hd0 : (0:ℝ) Finset.sum_nonneg (fun Y _ => + mul_nonneg (edgeCount_nonneg (d^20) (d^12) r c er ec i₀ j₀ X Y) (sq_nonneg _))) + have hvar : (A).chain.variance H=graphVariance (d^20) (d^12) r c (extendGraph (d^20) r c H)/(A).total := by + rw [AcceptedData.variance_formula] + congr 1 + unfold graphVariance + have hh : extendGraph (d^20) r c H ∘ graphUnderlying (d^20) r c=H := by + funext X; exact extendGraph_apply (d^20) r c H X + rw [hh]; rfl + have hEn : (A).chain.energy H=(proposalRate (32*d^2)/(A).total)*S/2 := by + rw [AcceptedData.energy_formula]; rfl + have hq := (smallProposal_bounds d (by omega)).1 + have hrate : S/(A).total ≤128*(d:ℝ)^2*(A).chain.energy H := by + rw [hEn] + have hsum := mul_le_mul_of_nonneg_right hq hs + apply (div_le_iff₀ (A).total_pos).mpr + field_simp [(A).total_pos.ne'] + have hh : S≤64*(d:ℝ)^2*(proposalRate (32*d^2)*S) := by + have hh := hsum + rw [one_div_mul_eq_div,div_le_iff₀ (by positivity : 0<64*(d:ℝ)^2)] at hh + nlinarith only [hh] + nlinarith only [hh] + have hpow : 770*(d:ℝ)^4*((d^20:ℕ):ℝ)^6*2=1540*(d:ℝ)^124 := by + push_cast + rw [← pow_mul] + ring + have hvarS : (A).chain.variance H ≤1540*(d:ℝ)^124*(S/(A).total) := by + rw [hvar] + apply (div_le_iff₀ (A).total_pos).mpr + have hh := hv.trans (mul_le_mul_of_nonneg_left he (by positivity)) + change graphVariance (d^20) (d^12) r c (extendGraph (d^20) r c H) ≤ _ at hh + calc + _ ≤ 770*(d:ℝ)^4*((d^20:ℕ):ℝ)^6*(2*S) := hh + _ = (1540*(d:ℝ)^124)*S := by rw [← mul_assoc,hpow] + _ = _ := by field_simp [(A).total_pos.ne'] + have hconst : 197120*(d:ℝ)^126≤(d:ℝ)^160 := by + have hh : (197120:ℝ)≤(d:ℝ)^34 := by + calc + _ ≤ (14:ℝ)^34 := by norm_num + _ ≤ _ := pow_le_pow_left₀ (by norm_num) (by exact_mod_cast hd) _ + have hh' := mul_le_mul_of_nonneg_right hh (pow_nonneg hd0.le 126) + calc + _ ≤ (d:ℝ)^34*(d:ℝ)^126 := hh' + _ = _ := by rw [← pow_add] + calc + _ ≤ 1540*(d:ℝ)^124*(S/(A).total) := hvarS + _ ≤ 1540*(d:ℝ)^124*(128*(d:ℝ)^2*(A).chain.energy H) := mul_le_mul_of_nonneg_left hrate (by positivity) + _ = (197120*(d:ℝ)^126)*(A).chain.energy H := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hconst (by rw [hEn]; have hp : 0 ≤ proposalRate (32*d^2) := le_trans (by positivity) hq; exact div_nonneg (mul_nonneg (div_nonneg hp (A).total_pos.le) hs) (by norm_num)) + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def smallPart (Z : Tables r c) (w : Cell m n) : ℤ := + if IsSmall U r c w then Z.val w.1 w.2 else 0 + +theorem table_row_bound (Z : Tables r c) (i : Fin m) (j : Fin n) : Z.val i j≤r i := by + rw [← Z.property.1 i] + exact Finset.single_le_sum (fun j _ => Nat.zero_le (Z.val i j)) (Finset.mem_univ j) + +theorem table_col_bound (Z : Tables r c) (i : Fin m) (j : Fin n) : Z.val i j≤c j := by + rw [← Z.property.2 j] + exact Finset.single_le_sum (fun i _ => Nat.zero_le (Z.val i j)) (Finset.mem_univ i) + +theorem smallPart_bounds (Z : Tables r c) (w : Cell m n) : + 0≤ smallPart U r c Z w ∧ smallPart U r c Z w≤U := by + unfold smallPart + split_ifs with h + · constructor + · positivity + · have hr := table_row_bound r c Z w.1 w.2 + have hc := table_col_bound r c Z w.1 w.2 + simp only [IsSmall,IsLarge,not_and_or,not_le] at h + rcases h with h | h <;> exact_mod_cast (by omega : Z.val w.1 w.2≤U) + · constructor <;> positivity + +theorem smallPart_row (Z : Tables r c) (i : Fin m) : + rowSum (smallPart U r c Z) i≤r i ∧ + ((∀ j,¬IsLarge U r c (i,j)) → rowSum (smallPart U r c Z) i=r i) := by + have he : (∑ j,(Z.val i j:ℤ))=r i := by exact_mod_cast Z.property.1 i + constructor + · rw [← he] + apply Finset.sum_le_sum; intro j _ + dsimp [smallPart] + split_ifs + · rfl + · positivity + · intro h + simpa only [rowSum,smallPart,show ∀ j,IsSmall U r c (i,j) from h,ite_true] using he + +theorem smallPart_col (Z : Tables r c) (j : Fin n) : + colSum (smallPart U r c Z) j≤c j ∧ + ((∀ i,¬IsLarge U r c (i,j)) → colSum (smallPart U r c Z) j=c j) := by + have he : (∑ i,(Z.val i j:ℤ))=c j := by exact_mod_cast Z.property.2 j + constructor + · rw [← he] + apply Finset.sum_le_sum; intro i _ + dsimp [smallPart] + split_ifs + · rfl + · positivity + · intro h + simpa only [colSum,smallPart,show ∀ i,IsSmall U r c (i,j) from h,ite_true] using he + + + +def initialTransversal (Z : Tables r c) : TransverseState U r c := by + refine ⟨⟨smallPart U r c Z,smallPart U r c Z⟩,?_,rfl⟩ + refine ⟨?_,?_,smallPart_row U r c Z,smallPart_col U r c Z⟩ + · intro w + exact ⟨(smallPart_bounds U r c Z w).1,(smallPart_bounds U r c Z w).2,smallPart_bounds U r c Z w⟩ + · intro w hw + simp [smallPart,IsSmall,hw] + +theorem transverse_nonempty (hrc : (∑ i,r i)=∑ j,c j) : Nonempty (TransverseState U r c) := by + obtain ⟨Z⟩ := tables_nonempty r c hrc + exact ⟨initialTransversal U r c Z⟩ + +theorem graph_nonempty (hrc : (∑ i,r i)=∑ j,c j) : Nonempty (GraphState U r c) := by + obtain ⟨X⟩ := transverse_nonempty U r c hrc + exact ⟨Sum.inl X⟩ + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def transverseMass : ℕ := ∑ X : TransverseState U r c,weight U L r c X.val +def graphMass : ℕ := ∑ X : GraphState U r c,weight U L r c (graphUnderlying U r c X) + +theorem transverseMass_pos (hrc : (∑ i,r i)=∑ j,c j) : 0 p.1) h + · exact congrArg (fun p : (Cell m n × Cell m n) × TransverseState U r c => transverseProfile U r c p.2) h + +theorem defectMass_le (hmn : m*n≤d) : + (∑ X : DefectiveState U r c,weight U L r c X.val)≤d^2*transverseMass U L r c := by + classical + calc + _ ≤ ∑ X : DefectiveState U r c,weight U L r c (repairedState U r c X).val := by + apply Finset.sum_le_sum; intro X _ + exact weight_repair_le U L r c _ _ X.val (defectPair_spec U r c X) + _ = ∑ pp∈Finset.univ.image (taggedState U r c),weight U L r c pp.2.val := by + rw [Finset.sum_image (fun X _ Y _ h => taggedState_injective U r c h)] + rfl + _ ≤ ∑ pp : (Cell m n × Cell m n) × TransverseState U r c,weight U L r c pp.2.val := + Finset.sum_le_sum_of_subset (Finset.subset_univ _) + _ = (m*n)^2*transverseMass U L r c := by + simp [Fintype.sum_prod_type,transverseMass,Cell,pow_two,Nat.mul_assoc] + _ ≤ _ := Nat.mul_le_mul_right _ (Nat.pow_le_pow_left hmn 2) + +theorem graphMass_bounds (hrc : (∑ i,r i)=∑ j,c j) (hmn : m*n≤d) : + 0.1, + (graph_feasible U r c Q.1).2.1 w (Classical.not_not.mp hw) |>.1] + · funext w + by_cases hw : IsSmall U r c w + · exact (hsmall w hw).2 + · rw [(graph_feasible U r c P.1).2.1 w (Classical.not_not.mp hw) |>.2, + (graph_feasible U r c Q.1).2.1 w (Classical.not_not.mp hw) |>.2] + have hA : P.2.val=Q.2.val := by + funext w + have hx := congrFun h (true,w) + simp only [jointCoordinates,fullCoordinates,ite_true,hX] at hx + omega + have he := graphUnderlying_injective U r c hX + cases P with | mk X A => + cases Q with | mk Y B => + dsimp only at he + subst Y + congr 1 + exact Subtype.ext hA + +def jointCode (hU : U≤C) (hC : ∀ i,paddedRow U L r c i≤C) + (P : Joint U L r c) : Coordinate m n → Fin (C+1) := fun w => + ⟨(jointCoordinates U L C r c P w).toNat,by + have hh := fullCoordinates_inBox U L C r c _ (graph_feasible U r c P.1) P.2 hC w + have hc : capacity U C r c w.2≤C := by unfold capacity; split_ifs <;> omega + change 0≤jointCoordinates U L C r c P w ∧ jointCoordinates U L C r c P w≤capacity U C r c w.2 at hh + omega⟩ + +theorem jointCode_injective (hU : U≤C) (hC : ∀ i,paddedRow U L r c i≤C) : + Function.Injective (jointCode U L C r c hU hC) := by + intro P Q h + apply jointCoordinates_injective U L C r c + funext w + have hh := congrArg (fun f : Coordinate m n → Fin (C+1) => (f w).val) h + have hP := (fullCoordinates_inBox U L C r c _ (graph_feasible U r c P.1) P.2 hC w).1 + have hQ := (fullCoordinates_inBox U L C r c _ (graph_feasible U r c Q.1) Q.2 hC w).1 + change (jointCoordinates U L C r c P w).toNat=(jointCoordinates U L C r c Q w).toNat at hh + change 0≤jointCoordinates U L C r c P w at hP + change 0≤jointCoordinates U L C r c Q w at hQ + omega + +theorem graphMass_upper (d : ℕ) (hmn : m*n≤d) + (hU : U≤C) (hC : ∀ i,paddedRow U L r c i≤C) : graphMass U L r c≤(C+1)^(2*d) := by + rw [← joint_card U L r c] + calc + _ ≤ Nat.card (Coordinate m n → Fin (C+1)) := + Nat.card_le_card_of_injective _ (jointCode_injective U L C r c hU hC) + _ = (C+1)^(2*(m*n)) := by simp [Coordinate,Cell] + _ ≤ _ := Nat.pow_le_pow_right (by omega) (Nat.mul_le_mul_left 2 hmn) + +theorem stationary_lower (d : ℕ) (hrc : (∑ i,r i)=∑ j,c j) (hmn : m*n≤d) + (hU : U≤C) (hC : ∀ i,paddedRow U L r c i≤C) (X : GraphState U r c) : + 1/(C+1:ℝ)^(2*d) ≤ (weight U L r c (graphUnderlying U r c X):ℝ)/graphMass U L r c := by + have hM := graphMass_upper U L C r c d hmn hU hC + have hpos := graphMass_bounds U L d r c hrc hmn + have hMp : (0:ℝ) smallData (d^20) (d^12) d r c er ec i₀ j₀ hrc (smallDim_one d hd) hmn + +omit [Nonempty (GraphState (d^20) r c)] in +theorem small_total : (A).total=(graphMass (d^20) (d^12) r c:ℝ) := by + simp [AcceptedData.total,smallData,graphMass,Nat.cast_sum] + +include hm hn in + +theorem small_mixing (hC2 : 2≤C) (hU : d^20≤C) + (hC : ∀ i,paddedRow (d^20) (d^12) r c i≤C) (t : ℕ) (X : GraphState (d^20) r c) : + ((A).chain.walk X t).tv (A).chain.invariant≤ + (C+1:ℝ)^(2*d)*Real.exp (-(t:ℝ)/(d:ℝ)^160) := by + rw [Chain.walk_tv] + have hk : (1:ℝ)≤(d:ℝ)^160 := one_le_pow₀ (by exact_mod_cast smallDim_one d hd) + have hvar := small_poincare d C r c er ec i₀ j₀ hrc hd hm hn hmn hC2 hC + have hmin (Y : GraphState (d^20) r c) : 1/(C+1:ℝ)^(2*d)≤(A).chain.π Y := by + change _≤(weight (d^20) (d^12) r c (graphUnderlying (d^20) r c Y):ℝ)/(A).total + rw [small_total d r c er ec i₀ j₀ hrc hd hmn] + exact stationary_lower (d^20) (d^12) C r c d hrc hmn hU hC Y + have hh := (A).chain.mixing_bound_min ((d:ℝ)^160) hk hvar + (1/(C+1:ℝ)^(2*d)) (by positivity) hmin t X + simpa only [one_div,inv_inv] using hh + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n a c' : ℕ} (d b k C : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin (a+1) ≃ {i // d^20 ≤ r i}) (ec : Fin (c'+1) ≃ {j // d^20 ≤ c j}) + (hrc : (∑ i,r i)=∑ j,c j) (hd : 14 ≤ d) (hm : m ≤ d) (hn : n ≤ d) (hmn : m*n ≤ d) + (hC : ∀ i,paddedRow (d^20) (d^12) r c i ≤ C) (hCb : C ≤ 2^b) + +local notation "Comp" => fun X : GraphState (d^20) r c => Completion (d^20) (d^12) r c (graphUnderlying (d^20) r c X) +local instance (X : GraphState (d^20) r c) : Fintype (Comp X) := Fintype.ofFinite _ +attribute [local instance] Dense.BinProblem.tableFintype + +include hrc in +lemma comp_nonempty (X : GraphState (d^20) r c) : Nonempty (Comp X) := completion_nonempty _ _ _ _ _ hrc + +include hC hCb in +lemma blockRow_upper (X : GraphState (d^20) r c) (i : Fin (a+1)) : + blockRow (d^20) (d^12) r c er X i ≤ 2^b := by + have hf := graph_feasible (d^20) r c X + have hn : 0 ≤ rowSum (graphUnderlying (d^20) r c X).x (er i).val := + Finset.sum_nonneg (fun j _ => (hf.1 ((er i).val,j)).1) + have hh := hC (er i).val + have hb' : (C:ℤ) ≤ 2^b := by exact_mod_cast hCb + apply Int.ofNat_le.mp + change (rowNat (d^20) (d^12) r c _ _:ℤ) ≤ ((2^b:ℕ):ℤ) + rw [rowNat_cast _ _ _ _ _ hf] + unfold paddedRow at hh + unfold residualRow + push_cast + omega + +abbrev blockDraw (X : GraphState (d^20) r c) (fallback : Comp X) : DyadicLaw (Comp X) := by + classical + let e := blockEquiv (d^20) (d^12) r c er ec X + let ha := (block_dimensions (d^20) r c er ec).1.trans hm + let hc := (block_dimensions (d^20) r c er ec).2.trans hn + let hac := (Nat.mul_le_mul (block_dimensions (d^20) r c er ec).1 + (block_dimensions (d^20) r c er ec).2).trans hmn + let hR := fun i => block_row_lower (d^20) (d^12) r c er ec X i 0 + let hP := fun j => block_col_lower (d^20) (d^12) r c er ec X 0 j + exact (Dense.literalDraw d _ _ hd ha hc hac hR hP (block_totals _ _ _ _ er ec X hrc) b k + (blockRow_upper d b C r c er hC hCb X) (e fallback)).map e.symm + +theorem blockDraw_bits (X : GraphState (d^20) r c) (fallback : Comp X) : + (blockDraw d b k C r c er ec hrc hd hm hn hmn hC hCb X fallback).bits=Schedule.RD d b k := by + classical + simp only [blockDraw,DyadicLaw.map_bits,Dense.literalDraw_bits] + +theorem blockDraw_tv (hk : 1 ≤ k) (X : GraphState (d^20) r c) (fallback : Comp X) : + letI := completion_nonempty (d^20) (d^12) r c X hrc + (blockDraw d b k C r c er ec hrc hd hm hn hmn hC hCb X fallback).toLaw.tv (Law.uniform (Comp X)) ≤ + (2:ℝ)^(-(Schedule.h d b k:ℤ)) := by + classical + let := completion_nonempty (d^20) (d^12) r c X hrc + let e := blockEquiv (d^20) (d^12) r c er ec X + let := tables_nonempty _ _ (block_totals (d^20) (d^12) r c er ec X hrc) + unfold blockDraw + rw [DyadicLaw.toLaw_map,← Law.uniform_map_equiv e.symm] + exact (Law.tv_map e.symm _ _).trans (Dense.literalDraw_tv _ _ _ _ _ _ _ _ _ _ b k hk _ _) + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +namespace Law + +theorem uniform_event {α : Type*} [Fintype α] [Nonempty α] (p : α → Prop) [DecidablePred p] : + ((uniform α).map (fun x => decide (p x))).mass true=(Nat.card {x // p x}:ℝ)/Nat.card α := by + classical + simp only [map,bind,pure,uniform,decide_eq_true_eq,mul_ite,mul_one,mul_zero] + rw [← Finset.sum_filter] + simp only [Finset.sum_const,nsmul_eq_mul,← Nat.card_eq_fintype_card] + have he : (Finset.univ.filter p).card=Nat.card {x // p x} := by + rw [Nat.card_eq_fintype_card,Fintype.card_subtype] + rw [he] + ring + +end Law +namespace PaddedGraph +open CompletionTranslation FiniteChain +variable {m n a c' : ℕ} (U L d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // U ≤ r i}) (ec : Fin c' ≃ {j // U ≤ c j}) (i₀ : Fin a) (j₀ : Fin c') + (hrc : (∑ i,r i)=∑ j,c j) (hd : 1 ≤ d) (hmn : m*n ≤ d) + +local notation "Comp" => fun X : GraphState U r c => Completion U L r c (graphUnderlying U r c X) +local instance (X : GraphState U r c) : Fintype (Comp X) := Fintype.ofFinite _ +attribute [local instance] Dense.BinProblem.tableFintype + +include hd hmn in +lemma proposal_degree (X : GraphState U r c) : + (Finset.univ.filter (GraphAdj U r c X)).card ≤ 2^(Nat.clog 2 (32*d^2)) := by + have hh := graph_degree U r c d hmn X + have hp : 1 ≤ d^2 := one_le_pow₀ hd + exact (hh.trans (by omega)).trans (Nat.le_pow_clog (by norm_num) _) + +abbrev smallProposal (X : GraphState U r c) : DyadicLaw (GraphState U r c) := + DyadicLaw.neighborProposal (GraphAdj U r c) X (Nat.clog 2 (32*d^2)) + (GraphAdj.irrefl U r c X) (proposal_degree U d r c hd hmn X) + +def completionTest (X Y : GraphState U r c) (A : Comp X) : Bool := + decide (∀ i j,0 ≤ (((blockEquiv U L r c er ec X A).val i j):ℤ)+blockD U L r c er ec i₀ j₀ X Y i j) + +def completionKernel (μ : ∀ X,Law (Comp X)) (X : GraphState U r c) : Law (GraphState U r c) := + (smallProposal U d r c hd hmn X).toLaw.accept + (fun Y => (μ X).map (completionTest U L r c er ec i₀ j₀ X Y)) X + +def implementedTransition (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X : GraphState U r c) : DyadicLaw (GraphState U r c) := by + classical + exact (smallProposal U d r c hd hmn X).bind + (fun Y => (μ X).map (fun A => if completionTest U L r c er ec i₀ j₀ X Y A then Y else X)) S + (fun _ => by rw [DyadicLaw.map_bits,hS]) + +theorem implementedTransition_bits (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X : GraphState U r c) : + (implementedTransition U L d r c er ec i₀ j₀ hd hmn μ S hS X).bits=Nat.clog 2 (32*d^2)+S := rfl + +theorem toLaw_implementedTransition (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X : GraphState U r c) : + (implementedTransition U L d r c er ec i₀ j₀ hd hmn μ S hS X).toLaw= + completionKernel U L d r c er ec i₀ j₀ hd hmn (fun X => (μ X).toLaw) X := by + classical + simp only [implementedTransition,DyadicLaw.toLaw_bind,DyadicLaw.toLaw_map, + completionKernel,Law.accept,Law.map_map] + +theorem completionKernel_tv (μ ν : ∀ X,Law (Comp X)) (X : GraphState U r c) : + (completionKernel U L d r c er ec i₀ j₀ hd hmn μ X).tv + (completionKernel U L d r c er ec i₀ j₀ hd hmn ν X) ≤ (μ X).tv (ν X) := by + unfold completionKernel Law.accept + apply Law.tv_bind_right_bound + intro Y + exact (Law.tv_map _ _ _).trans (Law.tv_map _ _ _) + +abbrev idealCompletion (X : GraphState U r c) : Law (Comp X) := + @Law.uniform (Comp X) inferInstance (completion_nonempty U L r c X hrc) + +theorem idealCompletion_test (X Y : GraphState U r c) : + ((idealCompletion U L r c hrc X).map (completionTest U L r c er ec i₀ j₀ X Y)).mass true= + (acceptCount U L r c er ec i₀ j₀ X Y:ℝ)/weight U L r c (graphUnderlying U r c X) := by + classical + let := completion_nonempty U L r c X hrc + let : Fintype (Tables (blockRow U L r c er X) (blockCol U L r c ec X)) := Fintype.ofFinite _ + let := tables_nonempty _ _ (block_totals U L r c er ec X hrc) + let e := blockEquiv U L r c er ec X + let p := fun A : Tables (blockRow U L r c er X) (blockCol U L r c ec X) => + ∀ i j,0 ≤ (A.val i j:ℤ)+blockD U L r c er ec i₀ j₀ X Y i j + have he : completionTest U L r c er ec i₀ j₀ X Y = fun A => decide (p (e A)) := rfl + rw [he] + change ((Law.uniform (Comp X)).map (fun A => decide (p (e A)))).mass true=_ + rw [← Law.map_map (Law.uniform (Comp X)) e (fun A => decide (p A)),Law.uniform_map_equiv e,Law.uniform_event] + rw [block_card U L r c er ec X] + rfl + +variable [Nonempty (GraphState U r c)] +theorem idealCompletion_kernel (X : GraphState U r c) : + completionKernel U L d r c er ec i₀ j₀ hd hmn (idealCompletion U L r c hrc) X= + (smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.transition X := by + classical + apply Law.ext_offdiag _ _ X + intro Y hXY + rw [completionKernel,Law.accept_offdiag _ _ _ _ hXY, + DyadicLaw.neighborProposal_offdiag _ _ _ _ _ _ hXY,idealCompletion_test] + simp only [FiniteChain.Chain.transition,AcceptedData.chain,AcceptedData.kernel,ite_eq_right hXY, + AcceptedData.rate,smallData,edgeCount,proposalRate] + split_ifs <;> ring + +end PaddedGraph +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +open FiniteChain +namespace DyadicLaw +variable {α : Type*} [Fintype α] [DecidableEq α] + + +theorem walk_tv_chain (q : α → DyadicLaw α) (S : ℕ) (hS : ∀ x,(q x).bits=S) + (C : Chain α) (δ : ℝ) (hq : ∀ x,(q x).toLaw.tv (C.transition x)≤δ) (x₀ : α) (t : ℕ) : + (walk q S hS x₀ t).toLaw.tv (C.walk x₀ t)≤(t:ℝ)*δ := by + induction t with + | zero => simp [walk,toLaw_pure,Chain.walk] + | succ t ih => + rw [walk,toLaw_bind,Chain.walk] + have hh := Law.tv_bind (walk q S hS x₀ t).toLaw (C.walk x₀ t) + (fun x => (q x).toLaw) C.transition δ hq + push_cast + linarith + +end DyadicLaw +namespace PaddedGraph +variable {m n a c' : ℕ} (U L d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // U ≤ r i}) (ec : Fin c' ≃ {j // U ≤ c j}) (i₀ : Fin a) (j₀ : Fin c') + (hrc : (∑ i,r i)=∑ j,c j) (hd : 1 ≤ d) (hmn : m*n ≤ d) + [Nonempty (GraphState U r c)] +local notation "Comp" => fun X : GraphState U r c => Completion U L r c (graphUnderlying U r c X) +local instance (X : GraphState U r c) : Fintype (Comp X) := Fintype.ofFinite _ + +abbrev implementedWalk (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X₀ : GraphState U r c) (t : ℕ) : DyadicLaw (GraphState U r c) := by + classical + exact DyadicLaw.walk (implementedTransition U L d r c er ec i₀ j₀ hd hmn μ S hS) + (Nat.clog 2 (32*d^2)+S) (implementedTransition_bits U L d r c er ec i₀ j₀ hd hmn μ S hS) X₀ t + +theorem implementedWalk_tv (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (δ : ℝ) (hμ : ∀ X,(μ X).toLaw.tv (idealCompletion U L r c hrc X)≤δ) + (X₀ : GraphState U r c) (t : ℕ) : + (implementedWalk U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).toLaw.tv + ((smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.walk X₀ t)≤(t:ℝ)*δ := by + classical + apply DyadicLaw.walk_tv_chain + intro X + rw [toLaw_implementedTransition,← idealCompletion_kernel U L d r c er ec i₀ j₀ hrc hd hmn] + exact (completionKernel_tv U L d r c er ec i₀ j₀ hd hmn _ _ X).trans (hμ X) + +end PaddedGraph +end +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/StackCompiler.lean b/lean/OAI/Probability/Contingency/StackCompiler.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9c0328a7ee00855c804009d3e9eeab6a3e63e1d --- /dev/null +++ b/lean/OAI/Probability/Contingency/StackCompiler.lean @@ -0,0 +1,589 @@ +import Mathlib +import OAI.Probability.Contingency.DenseWeightBounds + +namespace OAI + +/-! Stack Compiler. -/ + +noncomputable section + +open scoped BigOperators +namespace Contingency.BitModel.StackCode + +inductive Op (labels work : ℕ) where + | push (i : Fin work) (b : Bool) (next : Fin labels) + | pop (i : Fin work) (empty zero one : Fin labels) + | read (empty zero one : Fin labels) + | coin (zero one : Fin labels) + | emit (b : Bool) (next : Fin labels) + | jump (next : Fin labels) + | halt + +structure Program where + labels : ℕ + work : ℕ + start : Fin labels + code : Fin labels → Op labels work + + + +structure Memory (work : ℕ) where + input : List Bool + consumed : ℕ + stack : Fin work → List Bool + blanks : Fin work → ℕ + outputRev : List Bool + +structure Config (P : Program) where + state : Option (Fin P.labels) + memory : Memory P.work + +def branch {n : ℕ} (empty zero one : Fin n) : Option Bool → Fin n + | none => empty + | some false => zero + | some true => one + +def stackTape (xs : List Bool) (r : ℕ) : Tape := + ⟨xs.map some,none,List.replicate r none⟩ + +def inputTape : List Bool → ℕ → Tape + | [],p => ⟨List.replicate p none,none,[]⟩ + | b::xs,p => ⟨List.replicate p none,some b,xs.map some⟩ + +@[simp] theorem tape_keep (t : Tape) : t.move .stay t.head=t := by cases t; rfl + +theorem stack_push (xs : List Bool) (r : ℕ) (b : Bool) : + (stackTape xs r).move .right (some b)=stackTape (b::xs) (r-1) := by + cases r <;> simp [stackTape,Tape.move,List.replicate_succ] + +theorem stack_pop_empty (r : ℕ) : + ((stackTape [] r).move .left none).move .stay none=stackTape [] (r+1) := by + simp [stackTape,Tape.move,List.replicate_succ] + +theorem stack_pop_cons (b : Bool) (xs : List Bool) (r : ℕ) : + ((stackTape (b::xs) r).move .left none).move .stay none=stackTape xs (r+1) := by + simp [stackTape,Tape.move,List.replicate_succ] + +theorem stack_pop_head (xs : List Bool) (r : ℕ) : + ((stackTape xs r).move .left none).head=xs.head? := by cases xs <;> rfl + +theorem input_read (xs : List Bool) (p : ℕ) : + (inputTape xs p).move .right none=inputTape xs.tail (p+1) := by + cases xs with + | nil => simp [inputTape,Tape.move,List.replicate_succ] + | cons b xs => cases xs <;> simp [inputTape,Tape.move,List.replicate_succ] + +@[simp] theorem inputTape_head (xs : List Bool) (p : ℕ) : + (inputTape xs p).head=xs.head? := by cases xs <;> rfl + +def Memory.tapes {w : ℕ} (m : Memory w) : Fin (w+1) → Tape := + Fin.lastCases (inputTape m.input m.consumed) (fun i => stackTape (m.stack i) (m.blanks i)) + +@[simp] theorem tapes_work {w : ℕ} (m : Memory w) (i : Fin w) : + m.tapes i.castSucc=stackTape (m.stack i) (m.blanks i) := by simp [Memory.tapes] + +@[simp] theorem tapes_input {w : ℕ} (m : Memory w) : + m.tapes (Fin.last w)=inputTape m.input m.consumed := by simp [Memory.tapes] + +def Memory.push {w : ℕ} (m : Memory w) (i : Fin w) (b : Bool) : Memory w := + {m with stack := Function.update m.stack i (b::m.stack i) + blanks := Function.update m.blanks i (m.blanks i-1)} + +def Memory.pop {w : ℕ} (m : Memory w) (i : Fin w) : Memory w := + {m with stack := Function.update m.stack i (m.stack i).tail + blanks := Function.update m.blanks i (m.blanks i+1)} + +def Memory.read {w : ℕ} (m : Memory w) : Memory w := + {m with input := m.input.tail,consumed := m.consumed+1} + +def effect {l w : ℕ} (op : Op l w) (coin : Bool) (m : Memory w) : Option (Fin l) × Memory w := + match op with + | .push i b next => (some next,m.push i b) + | .pop i e z o => (some (branch e z o (m.stack i).head?),m.pop i) + | .read e z o => (some (branch e z o m.input.head?),m.read) + | .coin z o => (some (if coin then o else z),m) + | .emit b next => (some next,{m with outputRev := b::m.outputRev}) + | .jump next => (some next,m) + | .halt => (none,m) + +def step (P : Program) (coin : Bool) (c : Config P) : Config P := + match c.state with + | none => c + | some pc => let e := effect (P.code pc) coin c.memory; ⟨e.1,e.2⟩ + +def first {l : ℕ} (pc : Fin l) : Fin (l*2) := finProdFinEquiv (pc,0) +def second {l : ℕ} (pc : Fin l) : Fin (l*2) := finProdFinEquiv (pc,1) + +def preserved {l t : ℕ} (next : Option (Fin l)) (heads : Fin t → Option Bool) + (emit : Option Bool := none) : Instruction l t := + ⟨next,heads,fun _ => .stay,emit⟩ + +def active {l t : ℕ} (next : Option (Fin l)) (heads : Fin t → Option Bool) + (i : Fin t) (write : Option Bool) (move : Move) : Instruction l t := + ⟨next,Function.update heads i write,Function.update (fun _ => .stay) i move,none⟩ + +def prepare (P : Program) (pc : Fin P.labels) (heads : Fin (P.work+1) → Option Bool) : + Instruction (P.labels*2) (P.work+1) := + match P.code pc with + | .pop i _ _ _ => active (some (second pc)) heads i.castSucc (heads i.castSucc) .left + | _ => preserved (some (second pc)) heads + +def execute (P : Program) (pc : Fin P.labels) (coin : Bool) + (heads : Fin (P.work+1) → Option Bool) : Instruction (P.labels*2) (P.work+1) := + match P.code pc with + | .push i b next => active (some (first next)) heads i.castSucc (some b) .right + | .pop i e z o => active (some (first (branch e z o (heads i.castSucc)))) heads i.castSucc none .stay + | .read e z o => active (some (first (branch e z o (heads (Fin.last P.work))))) heads (Fin.last P.work) none .right + | .coin z o => preserved (some (first (if coin then o else z))) heads + | .emit b next => preserved (some (first next)) heads (some b) + | .jump next => preserved (some (first next)) heads + | .halt => preserved none heads + + + +def compile (P : Program) : Machine where + states := P.labels*2 + tapes := P.work+1 + start := first P.start + inputTape := Fin.last P.work + transition s coin heads := + let cp := finProdFinEquiv.symm s + if cp.2=0 then prepare P cp.1 heads else execute P cp.1 coin heads + +def encode (P : Program) (c : Config P) : BitModel.Config (compile P) := + ⟨c.state.map first,c.memory.tapes,c.memory.outputRev⟩ + +@[simp] theorem compile_first (P : Program) (pc : Fin P.labels) (coin : Bool) (heads) : + (compile P).transition (first pc) coin heads=prepare P pc heads := by + simp [compile,first] + +@[simp] theorem compile_second (P : Program) (pc : Fin P.labels) (coin : Bool) (heads) : + (compile P).transition (second pc) coin heads=execute P pc coin heads := by + simp [compile,second] + +theorem move_preserved {t : ℕ} (ts : Fin t → Tape) : + (fun i => (ts i).move .stay (ts i).head)=ts := by funext i; exact tape_keep _ + +theorem move_active {t : ℕ} (ts : Fin t → Tape) (i : Fin t) (a : Option Bool) (d : Move) : + (fun j => (ts j).move (Function.update (fun _ => Move.stay) i d j) + (Function.update (fun k => (ts k).head) i a j)) = + Function.update ts i ((ts i).move d a) := by + funext j + by_cases h : j=i <;> simp [h] + +theorem tapes_push {w : ℕ} (m : Memory w) (i : Fin w) (b : Bool) : + (m.push i b).tapes=Function.update m.tapes i.castSucc + ((m.tapes i.castSucc).move .right (some b)) := by + funext j + refine Fin.lastCases ?_ (fun k => ?_) j + · simp [Memory.tapes,Memory.push,Function.update_apply, ne_of_gt (Fin.castSucc_lt_last i)] + · by_cases h : k=i + · subst k; simp [Memory.push,stack_push] + · simp [Memory.push,h] + +theorem tapes_pop {w : ℕ} (m : Memory w) (i : Fin w) : + (m.pop i).tapes=Function.update m.tapes i.castSucc + (((m.tapes i.castSucc).move .left none).move .stay none) := by + funext j + refine Fin.lastCases ?_ (fun k => ?_) j + · simp [Memory.tapes,Memory.pop,Function.update_apply, ne_of_gt (Fin.castSucc_lt_last i)] + · by_cases h : k=i + · subst k + simp only [tapes_work,Memory.pop,Function.update_self] + cases m.stack i <;> simp [stack_pop_empty,stack_pop_cons] + · simp [Memory.pop,h] + +theorem tapes_read {w : ℕ} (m : Memory w) : + m.read.tapes=Function.update m.tapes (Fin.last w) + ((m.tapes (Fin.last w)).move .right none) := by + funext j + refine Fin.lastCases ?_ (fun k => ?_) j + · simp [Memory.read,input_read] + · simp [Memory.read] + + +theorem two_steps (P : Program) (noise coin : Bool) (c : Config P) : + (compile P).step coin ((compile P).step noise (encode P c)) = + encode P (step P coin c) := by + rcases c with ⟨state,m⟩ + cases state with + | none => rfl + | some pc => + change (compile P).step coin ((compile P).step noise + ⟨some (first pc),m.tapes,m.outputRev⟩) = + encode P ⟨(effect (P.code pc) coin m).1,(effect (P.code pc) coin m).2⟩ + cases h : P.code pc <;> + simp [Machine.step,compile_first,prepare,h,active,preserved, + compile_second,execute,encode,effect,Option.map] <;> try rfl + case push i b next => + congr 1 + exact (move_active m.tapes i.castSucc (some b) .right).trans (tapes_push m i b).symm + case read e z o => + congr 1 + exact (move_active m.tapes (Fin.last P.work) none .right).trans (tapes_read m).symm + case pop i e z o => + congr 1 + · dsimp only [compile] at * + simp only [Function.update_self] + change some (first (branch e z o ((stackTape (m.stack i) (m.blanks i)).move .left none).head))=_ + rw [stack_pop_head] + · dsimp only [compile] at * + funext j + refine Fin.lastCases ?_ (fun k => ?_) j + · have hi : Fin.last P.work ≠ i.castSucc := ne_of_gt (Fin.castSucc_lt_last i) + simp [Function.update_apply,hi,Memory.pop] + simpa using tape_keep (inputTape m.input m.consumed) + · by_cases hk : k=i + · subst k + simp only [Function.update_self,tapes_work,Memory.pop] + change ((stackTape (m.stack i) (m.blanks i)).move .left none).move .stay none=_ + cases hxs : m.stack i <;> + simp [stack_pop_empty,stack_pop_cons] + · simp [Function.update_apply,hk,Memory.pop] + +end Contingency.BitModel.StackCode + + + + + + + +open scoped BigOperators +namespace Contingency.BitModel.StackCode + +def initial (P : Program) (xs : List Bool) : Config P := + ⟨some P.start,⟨xs,0,fun _ => [],fun _ => 0,[]⟩⟩ + +def run (P : Program) (xs : List Bool) {t : ℕ} (coins : Fin t → Bool) : Config P := + (List.ofFn coins).foldl (fun c b => step P b c) (initial P xs) + +theorem initial_eq (P : Program) (xs : List Bool) : + encode P (initial P xs)=(compile P).initial xs := by + unfold encode initial Machine.initial compile + congr 1 + funext j + refine Fin.lastCases ?_ (fun i => ?_) j + · simp only [tapes_input,ite_true] + cases xs <;> rfl + · simp only [tapes_work,Fin.castSucc_ne_last,ite_false] + rfl + +theorem fold_pairs (P : Program) (ps : List (Bool×Bool)) (c : Config P) : + (ps.flatMap fun p => [p.1,p.2]).foldl (fun c b => (compile P).step b c) (encode P c) = + encode P (ps.foldl (fun c p => step P p.2 c) c) := by + induction ps generalizing c with + | nil => rfl + | cons p ps ih => + simp only [List.flatMap_cons,List.foldl_append,List.foldl_cons,List.foldl_nil] + rw [two_steps,ih] + +theorem coins_as_pairs {t : ℕ} (coins : Fin (t*2) → Bool) : + List.ofFn coins=(List.ofFn fun i : Fin t => (coins (first i),coins (second i))).flatMap + (fun p => [p.1,p.2]) := by + rw [List.ofFn_mul,List.flatMap_def,List.map_ofFn] + congr 1 + apply congrArg List.ofFn + funext i + simp [List.ofFn_succ,first,second,finProdFinEquiv,Nat.mul_comm,Nat.add_comm] + + +theorem run_eq (P : Program) (xs : List Bool) {t : ℕ} (coins : Fin (t*2) → Bool) : + (compile P).run xs coins=encode P (run P xs (fun i => coins (second i))) := by + unfold Machine.run + rw [← initial_eq,coins_as_pairs,fold_pairs] + unfold run + congr 1 + have hh := List.foldl_map (f:=Prod.snd) (g:=fun c b => step P b c) + (l:=List.ofFn fun i : Fin t => (coins (first i),coins (second i))) (init:=initial P xs) + simpa only [List.map_ofFn,Function.comp_def] using hh.symm + +def coinPairs (t : ℕ) : (Fin (t*2) → Bool) ≃ (Fin t → Bool)×(Fin t → Bool) where + toFun f := (fun i => f (first i),fun i => f (second i)) + invFun p j := let q := finProdFinEquiv.symm j + if q.2=0 then p.1 q.1 else p.2 q.1 + left_inv f := by + funext j + obtain ⟨⟨i,k⟩,rfl⟩ := finProdFinEquiv.surjective j + fin_cases k <;> simp [first,second] + right_inv p := by + rcases p with ⟨a,b⟩ + apply Prod.ext <;> funext i <;> simp [first,second] + + +theorem count_second (t : ℕ) (p : (Fin t → Bool) → Prop) [DecidablePred p] : + (Finset.univ.filter fun c : Fin (t*2) → Bool => p (fun i => c (second i))).card = + 2^t*(Finset.univ.filter p).card := by + classical + simp only [Finset.card_filter] + change (∑ c,if p ((coinPairs t c).2) then 1 else 0)=_ + rw [(coinPairs t).sum_comp (fun ab => if p ab.2 then (1:ℕ) else 0),Fintype.sum_prod_type] + simp + +noncomputable def mass (P : Program) (xs out : List Bool) (t : ℕ) : ℝ := + ((Finset.univ.filter fun coins : Fin t → Bool => (run P xs coins).state=none ∧ + (run P xs coins).memory.outputRev.reverse=out).card:ℝ)/2^t + +noncomputable def tail (P : Program) (xs : List Bool) (t : ℕ) : ℝ := + ((Finset.univ.filter fun coins : Fin t → Bool => (run P xs coins).state≠none).card:ℝ)/2^t + +@[simp] theorem encode_halt (P : Program) (c : Config P) : + (encode P c).state=none ↔ c.state=none := by cases h : c.state <;> simp [encode,h,Option.map] + +@[simp] theorem encode_output (P : Program) (c : Config P) : + (encode P c).outputRev=c.memory.outputRev := rfl + +theorem mass_compile (P : Program) (xs out : List Bool) (t : ℕ) : + (compile P).mass xs out (t*2)=mass P xs out t := by + classical + unfold Machine.mass + simp only [run_eq,encode_halt,encode_output] + rw [count_second t (fun c => (run P xs c).state=none ∧ + (run P xs c).memory.outputRev.reverse=out)] + unfold mass + push_cast + rw [pow_mul,pow_two] + field_simp + +theorem tail_compile (P : Program) (xs : List Bool) (t : ℕ) : + (compile P).tail xs (t*2)=tail P xs t := by + classical + unfold Machine.tail + simp only [run_eq,ne_eq,encode_halt] + rw [count_second t (fun c => (run P xs c).state≠none)] + unfold tail + push_cast + rw [pow_mul,pow_two] + field_simp + +end Contingency.BitModel.StackCode + + + + + + + +namespace Contingency.BitModel.StackCode.BinaryTrial +noncomputable section + +inductive Cmp | lt | eq | gt + deriving DecidableEq + +instance : Fintype Cmp where + elems := {.lt,.eq,.gt} + complete := by intro s; cases s <;> simp + +def advance (s : Cmp) (bound coin : Bool) : Cmp := + match s with + | .lt => .lt + | .gt => .gt + | .eq => if coin=bound then .eq else if coin then .gt else .lt + +def accept : Cmp → Bool + | .lt | .eq => true + | .gt => false + +inductive Q + | start (s : Cmp) + | save (s : Cmp) (bound : Bool) + | choose (s : Cmp) (bound : Bool) + | place (s : Cmp) (bound coin : Bool) + | finish (s : Cmp) + | halt + deriving DecidableEq, Fintype + +def label (q : Q) : Fin (Fintype.card Q) := Fintype.equivFin Q q + +def code : Q → Op (Fintype.card Q) 4 + | .start s => .pop 0 (label (.finish s)) (label (.save s false)) (label (.save s true)) + | .save s v => .push 2 v (label (.choose s v)) + | .choose s v => .coin (label (.place s v false)) (label (.place s v true)) + | .place s v b => .push 1 b (label (.start (advance s v b))) + | .finish s => .push 3 (accept s) (label .halt) + | .halt => .halt + +def program : Program := + ⟨Fintype.card Q,4,label (.start .eq),fun pc => code ((Fintype.equivFin Q).symm pc)⟩ + +def config (q : Q) (m : Memory 4) : Config program := ⟨some (label q),m⟩ + +@[simp] theorem program_code (q : Q) : program.code (label q)=code q := by + simp [program,label] + + +theorem one_step (q : Q) (m : Memory 4) (coin : Bool) : + step program coin (config q m)= + ⟨(effect (code q) coin m).1,(effect (code q) coin m).2⟩ := by + simp [step,config,program,label] + +def digitMemory (m : Memory 4) (v b : Bool) : Memory 4 := ((m.pop 0).push 2 v).push 1 b + +@[simp] theorem digit_stack0 (m : Memory 4) (v b : Bool) : + (digitMemory m v b).stack 0=(m.stack 0).tail := by simp [digitMemory,Memory.pop,Memory.push] +@[simp] theorem digit_stack1 (m : Memory 4) (v b : Bool) : + (digitMemory m v b).stack 1=b::m.stack 1 := by simp [digitMemory,Memory.pop,Memory.push] +@[simp] theorem digit_stack2 (m : Memory 4) (v b : Bool) : + (digitMemory m v b).stack 2=v::m.stack 2 := by simp [digitMemory,Memory.pop,Memory.push] +@[simp] theorem digit_stack3 (m : Memory 4) (v b : Bool) : + (digitMemory m v b).stack 3=m.stack 3 := by simp [digitMemory,Memory.pop,Memory.push] + +theorem four_steps (s : Cmp) (m : Memory 4) (v b n₀ n₁ n₃ : Bool) (rest : List Bool) + (hm : m.stack 0=v::rest) : + [n₀,n₁,b,n₃].foldl (fun c z => step program z c) (config (.start s) m)= + config (.start (advance s v b)) (digitMemory m v b) := by + cases v <;> cases b <;> + simp [List.foldl_cons,List.foldl_nil,code,effect,branch,hm,config,digitMemory, + step,program,label] + +structure Digit where + bound : Bool + coin : Bool + noise₀ : Bool + noise₁ : Bool + noise₃ : Bool + +def bits (d : Digit) : List Bool := [d.noise₀,d.noise₁,d.coin,d.noise₃] + +def wordMemory (ds : List Digit) (m : Memory 4) : Memory 4 := + ds.foldl (fun m d => digitMemory m d.bound d.coin) m + +def wordCmp (ds : List Digit) (s : Cmp) : Cmp := + ds.foldl (fun s d => advance s d.bound d.coin) s + +theorem pass (ds : List Digit) (s : Cmp) (m : Memory 4) + (hm : m.stack 0=ds.map Digit.bound) : + (ds.flatMap bits).foldl (fun c b => step program b c) (config (.start s) m)= + config (.start (wordCmp ds s)) (wordMemory ds m) := by + induction ds generalizing s m with + | nil => rfl + | cons d ds ih => + simp only [List.flatMap_cons,List.foldl_append] + rw [show bits d=[d.noise₀,d.noise₁,d.coin,d.noise₃] from rfl] + rw [four_steps s m d.bound d.coin d.noise₀ d.noise₁ d.noise₃ _ hm] + rw [ih] + · rfl + · simp [hm] + +theorem pass_stacks (ds : List Digit) (m : Memory 4) (hm : m.stack 0=ds.map Digit.bound) : + (wordMemory ds m).stack 0=[] ∧ + (wordMemory ds m).stack 1=(ds.map Digit.coin).reverse++m.stack 1 ∧ + (wordMemory ds m).stack 2=(ds.map Digit.bound).reverse++m.stack 2 ∧ + (wordMemory ds m).stack 3=m.stack 3 := by + induction ds generalizing m with + | nil => simp_all [wordMemory] + | cons d ds ih => + have htail : (digitMemory m d.bound d.coin).stack 0=ds.map Digit.bound := by simp [hm] + have hh := ih (digitMemory m d.bound d.coin) htail + simpa [wordMemory,List.reverse_cons,List.append_assoc] using hh + + +theorem pass_length (ds : List Digit) : (ds.flatMap bits).length=4*ds.length := by + induction ds with + | nil => rfl + | cons d ds ih => simp [bits,ih]; omega + +theorem finish (s : Cmp) (m : Memory 4) (hn : m.stack 0=[]) (b₀ b₁ b₂ : Bool) : + [b₀,b₁,b₂].foldl (fun c b => step program b c) (config (.start s) m)= + ⟨none,(m.pop 0).push 3 (accept s)⟩ := by + simp [List.foldl_cons,List.foldl_nil,step,program,label,config,code,effect,branch,hn] + +end +end Contingency.BitModel.StackCode.BinaryTrial + + + + + +open scoped BigOperators +namespace Contingency.BitModel.StackCode.BinaryTrial + +def cmpNat (x y : ℕ) : Cmp := if x 2*a+b.toNat) 0 + +theorem advance_cmpNat (x y : ℕ) (v b : Bool) : + advance (cmpNat x y) v b=cmpNat (2*x+b.toNat) (2*y+v.toNat) := by + cases v <;> cases b <;> + unfold cmpNat <;> split_ifs <;> simp_all [advance] <;> omega + +theorem cmp_fold (ds : List Digit) (x y : ℕ) : + wordCmp ds (cmpNat x y)= + cmpNat ((ds.map Digit.coin).foldl (fun n b => 2*n+b.toNat) x) + ((ds.map Digit.bound).foldl (fun n b => 2*n+b.toNat) y) := by + induction ds generalizing x y with + | nil => rfl + | cons d ds ih => + change wordCmp ds (advance (cmpNat x y) d.bound d.coin)=_ + rw [advance_cmpNat,ih] + rfl + +theorem comparison_correct (ds : List Digit) : + accept (wordCmp ds .eq)=decide (beValue (ds.map Digit.coin)≤beValue (ds.map Digit.bound)) := by + have hh : wordCmp ds .eq=cmpNat (beValue (ds.map Digit.coin)) + (beValue (ds.map Digit.bound)) := cmp_fold ds 0 0 + rw [hh] + unfold cmpNat + split_ifs <;> simp_all [accept] <;> omega + +def wordValue {n : ℕ} (bs : Fin n → Bool) : ℕ := beValue (List.ofFn bs) + +theorem wordValue_succ {n : ℕ} (bs : Fin (n+1) → Bool) : + wordValue bs=2*wordValue (fun i : Fin n => bs i.castSucc)+(bs (Fin.last n)).toNat := by + unfold wordValue beValue + rw [List.ofFn_succ',List.concat_eq_append,List.foldl_append] + rfl + +theorem wordValue_lt {n : ℕ} (bs : Fin n → Bool) : wordValue bs<2^n := by + induction n with + | zero => simp [wordValue,beValue] + | succ n ih => + have hh := ih (fun i => bs i.castSucc) + rw [wordValue_succ,pow_succ] + cases hb : bs (Fin.last n) <;> simp only [Bool.toNat_false,Bool.toNat_true] <;> omega + +theorem wordValue_injective (n : ℕ) : Function.Injective (@wordValue n) := by + induction n with + | zero => intro f g _; funext i; exact Fin.elim0 i + | succ n ih => + intro f g h + rw [wordValue_succ,wordValue_succ] at h + have hb : f (Fin.last n)=g (Fin.last n) := by + cases hf : f (Fin.last n) <;> cases hg : g (Fin.last n) <;> try rfl + all_goals simp only [hf,hg,Bool.toNat_true,Bool.toNat_false] at h; omega + have hp : wordValue (fun i : Fin n => f i.castSucc)=wordValue (fun i : Fin n => g i.castSucc) := by + rw [hb] at h; omega + have hh := ih hp + funext i + exact Fin.lastCases hb (fun i => congrFun hh i) i + +def wordFin {n : ℕ} (bs : Fin n → Bool) : Fin (2^n) := ⟨wordValue bs,wordValue_lt bs⟩ + +theorem wordFin_bijective (n : ℕ) : Function.Bijective (@wordFin n) := by + apply (Fintype.bijective_iff_injective_and_card _).mpr + constructor + · intro f g h + exact wordValue_injective n (congrArg Fin.val h) + · simp + +noncomputable def wordEquiv (n : ℕ) : (Fin n → Bool) ≃ Fin (2^n) := + Equiv.ofBijective wordFin (wordFin_bijective n) + + + +theorem word_count (n : ℕ) (u : Fin (2^n)) : + (Finset.univ.filter fun bs : Fin n → Bool => wordFin bs=u).card=1 := by + classical + change (Finset.univ.filter fun bs => wordEquiv n bs=u).card=1 + have hh (bs) : wordEquiv n bs=u ↔ bs=(wordEquiv n).symm u := by + exact (Equiv.eq_symm_apply _).symm + have he : Finset.univ.filter (fun bs => wordEquiv n bs=u) = {(wordEquiv n).symm u} := by + ext bs + simp only [Finset.mem_filter,Finset.mem_univ,true_and,Finset.mem_singleton,hh] + rw [he,Finset.card_singleton] + +end Contingency.BitModel.StackCode.BinaryTrial + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/StackSafety.lean b/lean/OAI/Probability/Contingency/StackSafety.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f7300f6d17a6900d6320eed39569a4b63bb4bdc --- /dev/null +++ b/lean/OAI/Probability/Contingency/StackSafety.lean @@ -0,0 +1,662 @@ +import Mathlib +import OAI.Probability.Contingency.IntegerDrawTail + +namespace OAI + +/-! Stack Safety. -/ + +noncomputable section + + +namespace Contingency.BitModel.StackCode +noncomputable section + +theorem mass_eq_zero_of_safe (P : Program) (xs : List Bool) (Safe : List Bool→Prop) + (hs : ∀ (t : ℕ) (f : Fin t→Bool),(run P xs f).state=none → Safe (run P xs f).memory.outputRev.reverse) + (out : List Bool) (ho : ¬Safe out) (t : ℕ) : mass P xs out t=0 := by + classical + unfold mass + have he : (Finset.univ.filter fun f : Fin t→Bool => (run P xs f).state=none ∧ + (run P xs f).memory.outputRev.reverse=out)=∅ := by + apply Finset.filter_eq_empty_iff.mpr + intro f _ hh + apply ho + rw [← hh.2] + exact hs t f hh.1 + rw [he] + simp + +theorem safe_compile (P : Program) (xs : List Bool) (Safe : List Bool→Prop) + (hs : ∀ (t : ℕ) (f : Fin t→Bool),(run P xs f).state=none → Safe (run P xs f).memory.outputRev.reverse) + (t : ℕ) (f : Fin t→Bool) (hh : ((compile P).run xs f).state=none) : + Safe ((compile P).run xs f).outputRev.reverse := by + classical + by_contra hn + have hm := mass_compile_all P xs ((compile P).run xs f).outputRev.reverse t + rw [mass_eq_zero_of_safe P xs Safe hs _ hn] at hm + have hc : 0<(Finset.univ.filter fun g : Fin t→Bool => ((compile P).run xs g).state=none ∧ + ((compile P).run xs g).outputRev.reverse=((compile P).run xs f).outputRev.reverse).card := by + apply Finset.card_pos.mpr + exact ⟨f,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hh,rfl⟩⟩ + have hp : 0<(compile P).mass xs ((compile P).run xs f).outputRev.reverse t := by + unfold Machine.mass + apply div_pos _ (by positivity) + exact_mod_cast hc + linarith + +end +end Contingency.BitModel.StackCode + + + + + + + +open Filter +namespace Contingency.BitModel.StackCode.IntegerDraw +open BinaryTrial +noncomputable section + +theorem beValue_snoc (xs : List Bool) (b : Bool) : + beValue (xs++[b])=2*beValue xs+b.toNat := by + unfold beValue + rw [List.foldl_append] + rfl + +theorem beValue_bits_reverse (N : ℕ) : beValue N.bits.reverse=N := by + induction N using Nat.binaryRec' with + | zero => rfl + | bit b n h ih => + rw [Nat.bits_append_bit _ _ h,List.reverse_cons,beValue_snoc,ih] + cases b <;> simp [Nat.bit] + +theorem minimal_width (N : ℕ) : 2^N.size≤2*(N+1) := by + by_cases hn : N.size=0 + · rw [hn] + simp only [pow_zero] + omega + have hh := Nat.lt_size.mp (show N.size-1 rw [he]; rw [pow_succ] + _ ≤ N*2 := Nat.mul_le_mul_right 2 hh + _ ≤ 2*(N+1) := by omega + +def rawMaximum (N : ℕ) : List Bool := N.bits.reverse + +@[simp] theorem rawMaximum_length (N : ℕ) : (rawMaximum N).length=N.size := by + simp [rawMaximum,Nat.size_eq_bits_len] +@[simp] theorem rawMaximum_value (N : ℕ) : beValue (rawMaximum N)=N := beValue_bits_reverse N + +def integerWord (N : ℕ) (u : Fin (N+1)) : List Bool := + validWord (rawMaximum N) ⟨u,by simpa using u.isLt⟩ + +@[simp] theorem integerWord_value (N : ℕ) (u : Fin (N+1)) : beValue (integerWord N u)=u.val := by + unfold integerWord validWord + rw [word_value] + +@[simp] theorem integerWord_length (N : ℕ) (u : Fin (N+1)) : (integerWord N u).length=N.size := by + simp [integerWord,validWord,word] + +theorem machine_safe (B : List Bool) (t : ℕ) (f : Fin t→Bool) (hh : (machine.run B f).state=none) : + ∃ u : Fin (beValue B+1),(machine.run B f).outputRev.reverse=validWord B u := + safe_compile program B (fun out => ∃ u : Fin (beValue B+1),out=validWord B u) + (fun _ f hh => stack_safe B f hh) t f hh + + + +theorem integer_sampler (N : ℕ) : + (∀ (t : ℕ) (coins : Fin t→Bool),(machine.run (rawMaximum N) coins).state=none → + ∃ u : Fin (N+1),(machine.run (rawMaximum N) coins).outputRev.reverse=integerWord N u) ∧ + Tendsto (machine.tail (rawMaximum N)) atTop (nhds 0) ∧ + (∀ u : Fin (N+1),Tendsto (machine.mass (rawMaximum N) (integerWord N u)) atTop (nhds (1/(N+1:ℝ)))) ∧ + Summable (machine.tail (rawMaximum N)) ∧ + (∑' t,machine.tail (rawMaximum N) t)≤52*(N.size:ℝ)+30 := by + refine ⟨?_,machine_halts_ae _,?_,machine_summable _,?_⟩ + · intro t coins hh + obtain ⟨u,hu⟩ := machine_safe (rawMaximum N) t coins hh + refine ⟨⟨u,by simpa using u.isLt⟩,?_⟩ + exact hu + · intro u + simpa only [rawMaximum_value,integerWord] using machine_uniform (rawMaximum N) ⟨u,by simpa using u.isLt⟩ + · have hw : 2^(rawMaximum N).length≤2*(beValue (rawMaximum N)+1) := by + simpa using minimal_width N + simpa using machine_linear_expected (rawMaximum N) hw + +end +end Contingency.BitModel.StackCode.IntegerDraw + + + + + + + +namespace Contingency.BitModel.StackCode.BinarySubtract +noncomputable section + +def outBit (a b carry : Bool) : Bool := xor (xor a b) carry +def nextBorrow (a b carry : Bool) : Bool := (!a && (b || carry)) || (b && carry) + +theorem digit_identity (a b carry : Bool) : + a.toNat+2*(nextBorrow a b carry).toNat = b.toNat+carry.toNat+(outBit a b carry).toNat := by + cases a <;> cases b <;> cases carry <;> decide + +def value : List Bool→ℕ + | [] => 0 + | b::bs => b.toNat+2*value bs + +structure Digit where + a : Bool + b : Bool + +def output : List Digit → Bool → List Bool + | [],_ => [] + | d::ds,c => outBit d.a d.b c :: output ds (nextBorrow d.a d.b c) + +def borrow : List Digit → Bool → Bool + | [],c => c + | d::ds,c => borrow ds (nextBorrow d.a d.b c) + +@[simp] theorem output_length (ds : List Digit) (c : Bool) : (output ds c).length=ds.length := by + induction ds generalizing c with + | nil => rfl + | cons d ds ih => simp [output,ih] + +theorem value_lt (bs : List Bool) : value bs<2^bs.length := by + induction bs with + | nil => decide + | cons b bs ih => + change b.toNat+2*value bs<2^(bs.length+1) + rw [pow_succ] + cases b <;> simp only [Bool.toNat_false,Bool.toNat_true] <;> omega + +theorem word_identity (ds : List Digit) (c : Bool) : + value (ds.map Digit.a)+2^ds.length*(borrow ds c).toNat = + value (ds.map Digit.b)+c.toNat+value (output ds c) := by + induction ds generalizing c with + | nil => simp [value,borrow,output] + | cons d ds ih => + have hd := digit_identity d.a d.b c + have hh := ih (nextBorrow d.a d.b c) + simp only [List.map_cons,value,List.length_cons,pow_succ,borrow,output] + nlinarith + +theorem subtract_correct (ds : List Digit) (h : value (ds.map Digit.b)≤value (ds.map Digit.a)) : + borrow ds false=false ∧ value (output ds false)=value (ds.map Digit.a)-value (ds.map Digit.b) := by + have hh := word_identity ds false + have ho := value_lt (output ds false) + rw [output_length] at ho + cases hb : borrow ds false <;> simp only [hb,Bool.toNat_false,Bool.toNat_true,Nat.mul_zero,Nat.mul_one,Nat.add_zero] at hh + · exact ⟨rfl,by omega⟩ + · omega + +inductive Q + | start (carry : Bool) + | second (carry a : Bool) + | place (carry a b : Bool) + | done (carry : Bool) + deriving DecidableEq, Fintype + +def label (q : Q) : Fin (Fintype.card Q) := Fintype.equivFin Q q + +def code : Q→Op (Fintype.card Q) 4 + | .start c => .pop 0 (label (.done c)) (label (.second c false)) (label (.second c true)) + | .second c a => .pop 1 (label (.place c a false)) (label (.place c a false)) (label (.place c a true)) + | .place c a b => .push 2 (outBit a b c) (label (.start (nextBorrow a b c))) + | .done _ => .halt + +def program : Program := ⟨Fintype.card Q,4,label (.start false),fun pc => code ((Fintype.equivFin Q).symm pc)⟩ +def config (q : Q) (m : Memory 4) : Config program := ⟨some (label q),m⟩ + +def digitMemory (d : Digit) (c : Bool) (m : Memory 4) : Memory 4 := + ((m.pop 0).pop 1).push 2 (outBit d.a d.b c) + +def wordMemory : List Digit→Bool→Memory 4→Memory 4 + | [],_,m => m + | d::ds,c,m => wordMemory ds (nextBorrow d.a d.b c) (digitMemory d c m) + +theorem one_step (q : Q) (m : Memory 4) (coin : Bool) : + step program coin (config q m)= + ⟨(effect (code q) coin m).1,(effect (code q) coin m).2⟩ := by + simp [step,config,program,label] + +theorem first_step (m : Memory 4) (c a x : Bool) (as : List Bool) (ha : m.stack 0=a::as) : + step program x (config (.start c) m)=config (.second c a) (m.pop 0) := by + rw [one_step] + cases a <;> simp [code,effect,branch,ha,config] <;> rfl + +theorem second_step (m : Memory 4) (c a b x : Bool) (bs : List Bool) (hb : m.stack 1=b::bs) : + step program x (config (.second c a) m)=config (.place c a b) (m.pop 1) := by + rw [one_step] + cases b <;> simp [code,effect,branch,hb,config] <;> rfl + +theorem third_step (m : Memory 4) (c a b x : Bool) : + step program x (config (.place c a b) m)= + config (.start (nextBorrow a b c)) (m.push 2 (outBit a b c)) := by + rw [one_step] + rfl + +theorem three_steps (m : Memory 4) (d : Digit) (c x y z : Bool) (as bs : List Bool) + (ha : m.stack 0=d.a::as) (hb : m.stack 1=d.b::bs) : + [x,y,z].foldl (fun cfg b => step program b cfg) (config (.start c) m)= + config (.start (nextBorrow d.a d.b c)) (digitMemory d c m) := by + simp only [List.foldl_cons,List.foldl_nil] + rw [first_step m c d.a x as ha,second_step _ c d.a d.b y bs,third_step] + · rfl + · simpa using hb + +theorem pass (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) : + (List.replicate (3*ds.length) false).foldl (fun cfg b => step program b cfg) (config (.start c) m)= + config (.start (borrow ds c)) (wordMemory ds c m) := by + induction ds generalizing c m with + | nil => rfl + | cons d ds ih => + have he : 3*(d::ds).length=3+3*ds.length := by simp; omega + rw [he,List.replicate_add,List.foldl_append] + change (List.replicate (3*ds.length) false).foldl _ + ([false,false,false].foldl _ (config (.start c) m))=_ + rw [three_steps m d c false false false _ _ ha hb,ih] + · rfl + · simp [digitMemory,Memory.push,Memory.pop,ha] + · simp [digitMemory,Memory.push,Memory.pop,hb] + +end +end Contingency.BitModel.StackCode.BinarySubtract + + + + + + + +namespace Contingency.BitModel.StackCode.BinarySubtract +noncomputable section + +theorem step_independent (cfg : Config program) (b b' : Bool) : step program b cfg=step program b' cfg := by + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some pc => + unfold step + dsimp only [program] + cases (Fintype.equivFin Q).symm pc <;> rfl + +theorem fold_independent (xs ys : List Bool) (hl : xs.length=ys.length) (cfg : Config program) : + xs.foldl (fun cfg b => step program b cfg) cfg=ys.foldl (fun cfg b => step program b cfg) cfg := by + induction xs generalizing ys cfg with + | nil => cases ys <;> simp_all + | cons x xs ih => + cases ys with + | nil => simp at hl + | cons y ys => + simp only [List.length_cons,Nat.add_right_cancel_iff] at hl + simp only [List.foldl_cons] + rw [step_independent _ x y] + exact ih _ hl _ + +theorem pass_any (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (coins : List Bool) (hl : coins.length=3*ds.length) : + coins.foldl (fun cfg b => step program b cfg) (config (.start c) m)= + config (.start (borrow ds c)) (wordMemory ds c m) := by + rw [fold_independent coins (List.replicate (3*ds.length) false) (by simpa using hl)] + exact pass ds c m ha hb + +theorem wordMemory_stacks (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) : + (wordMemory ds c m).stack 0=[] ∧ (wordMemory ds c m).stack 1=[] ∧ + (wordMemory ds c m).stack 2=(output ds c).reverse++m.stack 2 ∧ + (wordMemory ds c m).stack 3=m.stack 3 ∧ + (wordMemory ds c m).input=m.input ∧ (wordMemory ds c m).outputRev=m.outputRev := by + induction ds generalizing c m with + | nil => exact ⟨ha,hb,rfl,rfl,rfl,rfl⟩ + | cons d ds ih => + have h0 : (digitMemory d c m).stack 0=ds.map Digit.a := by + simp [digitMemory,Memory.push,Memory.pop,ha] + have h1 : (digitMemory d c m).stack 1=ds.map Digit.b := by + simp [digitMemory,Memory.push,Memory.pop,hb] + have hh := ih (nextBorrow d.a d.b c) (digitMemory d c m) h0 h1 + refine ⟨hh.1,hh.2.1,?_,?_,hh.2.2.2.2.1,hh.2.2.2.2.2⟩ + · simpa [wordMemory,output,List.reverse_cons,List.append_assoc,digitMemory,Memory.push,Memory.pop,Function.update_apply] using hh.2.2.1 + · simpa [wordMemory,digitMemory,Memory.push,Memory.pop,Function.update_apply] using hh.2.2.2.1 + +theorem finish (m : Memory 4) (c b : Bool) (hm : m.stack 0=[]) : + step program b (config (.start c) m)=config (.done c) (m.pop 0) := by + simp [step,program,config,label,code,effect,branch,hm] + +theorem halt (m : Memory 4) (c b : Bool) : + step program b (config (.done c) m)=⟨none,m⟩ := by + simp [step,program,config,label,code,effect] + +theorem finish_run (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (coins : List Bool) (hl : coins.length=3*ds.length) (b b' : Bool) : + (coins++[b,b']).foldl (fun cfg b => step program b cfg) (config (.start c) m)= + ⟨none,(wordMemory ds c m).pop 0⟩ := by + rw [List.foldl_append,pass_any ds c m ha hb coins hl] + simp only [List.foldl_cons,List.foldl_nil] + rw [finish _ _ _ (wordMemory_stacks ds c m ha hb).1,halt] + +theorem fold_compiled (P : Program) (cfg : Config P) {t : ℕ} (coins : Fin (t*2)→Bool) : + (List.ofFn coins).foldl (fun cfg b => (compile P).step b cfg) (encode P cfg)= + encode P ((List.ofFn (fun i : Fin t => coins (second i))).foldl (fun cfg b => step P b cfg) cfg) := by + rw [coins_as_pairs,fold_pairs] + congr 1 + have hh := List.foldl_map (f:=Prod.snd) (g:=fun cfg b => step P b cfg) + (l:=List.ofFn fun i : Fin t => (coins (first i),coins (second i))) (init:=cfg) + simpa only [List.map_ofFn,Function.comp_def] using hh.symm + + + +theorem tape_pass (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (coins : Fin ((3*ds.length)*2)→Bool) : + (List.ofFn coins).foldl (fun cfg b => (compile program).step b cfg) (encode program (config (.start c) m))= + encode program (config (.start (borrow ds c)) (wordMemory ds c m)) := by + rw [fold_compiled,pass_any ds c m ha hb _ (by simp)] + +end +end Contingency.BitModel.StackCode.BinarySubtract + + + + + + + +namespace Contingency.BitModel.StackCode.BinaryAdd +open BinarySubtract +noncomputable section + +def nextCarry (a b c : Bool) : Bool := (a && b) || (a && c) || (b && c) + +theorem digit_identity (a b c : Bool) : + a.toNat+b.toNat+c.toNat = (outBit a b c).toNat+2*(nextCarry a b c).toNat := by + cases a <;> cases b <;> cases c <;> decide + +def output : List Digit → Bool → List Bool + | [],_ => [] + | d::ds,c => outBit d.a d.b c :: output ds (nextCarry d.a d.b c) + +def carry : List Digit → Bool → Bool + | [],c => c + | d::ds,c => carry ds (nextCarry d.a d.b c) + +@[simp] theorem output_length (ds : List Digit) (c : Bool) : (output ds c).length=ds.length := by + induction ds generalizing c with + | nil => rfl + | cons d ds ih => simp [output,ih] + +theorem word_identity (ds : List Digit) (c : Bool) : + value (ds.map Digit.a)+value (ds.map Digit.b)+c.toNat = + value (output ds c)+2^ds.length*(carry ds c).toNat := by + induction ds generalizing c with + | nil => simp [value,carry,output] + | cons d ds ih => + have hd := digit_identity d.a d.b c + have hh := ih (nextCarry d.a d.b c) + simp only [List.map_cons,value,List.length_cons,pow_succ,carry,output] + nlinarith + +inductive Q + | start (carry : Bool) + | second (carry a : Bool) + | place (carry a b : Bool) + | done (carry : Bool) + | halt + deriving DecidableEq, Fintype + +def label (q : Q) : Fin (Fintype.card Q) := Fintype.equivFin Q q + +def code : Q→Op (Fintype.card Q) 4 + | .start c => .pop 0 (label (.done c)) (label (.second c false)) (label (.second c true)) + | .second c a => .pop 1 (label (.place c a false)) (label (.place c a false)) (label (.place c a true)) + | .place c a b => .push 2 (outBit a b c) (label (.start (nextCarry a b c))) + | .done c => .push 2 c (label .halt) + | .halt => .halt + +def program : Program := ⟨Fintype.card Q,4,label (.start false),fun pc => code ((Fintype.equivFin Q).symm pc)⟩ +def config (q : Q) (m : Memory 4) : Config program := ⟨some (label q),m⟩ + +def digitMemory (d : Digit) (c : Bool) (m : Memory 4) : Memory 4 := + ((m.pop 0).pop 1).push 2 (outBit d.a d.b c) + +def wordMemory : List Digit→Bool→Memory 4→Memory 4 + | [],_,m => m + | d::ds,c,m => wordMemory ds (nextCarry d.a d.b c) (digitMemory d c m) + +theorem one_step (q : Q) (m : Memory 4) (coin : Bool) : + step program coin (config q m)= + ⟨(effect (code q) coin m).1,(effect (code q) coin m).2⟩ := by + simp [step,config,program,label] + +theorem first_step (m : Memory 4) (c a x : Bool) (as : List Bool) (ha : m.stack 0=a::as) : + step program x (config (.start c) m)=config (.second c a) (m.pop 0) := by + rw [one_step] + cases a <;> simp [code,effect,branch,ha,config] <;> rfl + +theorem second_step (m : Memory 4) (c a b x : Bool) (bs : List Bool) (hb : m.stack 1=b::bs) : + step program x (config (.second c a) m)=config (.place c a b) (m.pop 1) := by + rw [one_step] + cases b <;> simp [code,effect,branch,hb,config] <;> rfl + +theorem third_step (m : Memory 4) (c a b x : Bool) : + step program x (config (.place c a b) m)= + config (.start (nextCarry a b c)) (m.push 2 (outBit a b c)) := by + rw [one_step] + rfl + +theorem three_steps (m : Memory 4) (d : Digit) (c x y z : Bool) (as bs : List Bool) + (ha : m.stack 0=d.a::as) (hb : m.stack 1=d.b::bs) : + [x,y,z].foldl (fun cfg b => step program b cfg) (config (.start c) m)= + config (.start (nextCarry d.a d.b c)) (digitMemory d c m) := by + simp only [List.foldl_cons,List.foldl_nil] + rw [first_step m c d.a x as ha,second_step _ c d.a d.b y bs,third_step] + · rfl + · simpa using hb + +theorem pass (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) : + (List.replicate (3*ds.length) false).foldl (fun cfg b => step program b cfg) (config (.start c) m)= + config (.start (carry ds c)) (wordMemory ds c m) := by + induction ds generalizing c m with + | nil => rfl + | cons d ds ih => + have he : 3*(d::ds).length=3+3*ds.length := by simp; omega + rw [he,List.replicate_add,List.foldl_append] + change (List.replicate (3*ds.length) false).foldl _ + ([false,false,false].foldl _ (config (.start c) m))=_ + rw [three_steps m d c false false false _ _ ha hb,ih] + · rfl + · simp [digitMemory,Memory.push,Memory.pop,ha] + · simp [digitMemory,Memory.push,Memory.pop,hb] + +end +end Contingency.BitModel.StackCode.BinaryAdd + + + + + + + +namespace Contingency.BitModel.StackCode.BinaryAdd +open BinarySubtract +noncomputable section + +theorem step_independent (cfg : Config program) (b b' : Bool) : step program b cfg=step program b' cfg := by + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some pc => + unfold step + dsimp only [program] + cases (Fintype.equivFin Q).symm pc <;> rfl + +theorem fold_independent (xs ys : List Bool) (hl : xs.length=ys.length) (cfg : Config program) : + xs.foldl (fun cfg b => step program b cfg) cfg=ys.foldl (fun cfg b => step program b cfg) cfg := by + induction xs generalizing ys cfg with + | nil => cases ys <;> simp_all + | cons x xs ih => + cases ys with + | nil => simp at hl + | cons y ys => + simp only [List.length_cons,Nat.add_right_cancel_iff] at hl + simp only [List.foldl_cons] + rw [step_independent _ x y] + exact ih _ hl _ + +theorem pass_any (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (coins : List Bool) (hl : coins.length=3*ds.length) : + coins.foldl (fun cfg b => step program b cfg) (config (.start c) m)= + config (.start (carry ds c)) (wordMemory ds c m) := by + rw [fold_independent coins (List.replicate (3*ds.length) false) (by simpa using hl)] + exact pass ds c m ha hb + +theorem wordMemory_stacks (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) : + (wordMemory ds c m).stack 0=[] ∧ (wordMemory ds c m).stack 1=[] ∧ + (wordMemory ds c m).stack 2=(output ds c).reverse++m.stack 2 ∧ + (wordMemory ds c m).stack 3=m.stack 3 ∧ + (wordMemory ds c m).input=m.input ∧ (wordMemory ds c m).outputRev=m.outputRev := by + induction ds generalizing c m with + | nil => exact ⟨ha,hb,rfl,rfl,rfl,rfl⟩ + | cons d ds ih => + have h0 : (digitMemory d c m).stack 0=ds.map Digit.a := by + simp [digitMemory,Memory.push,Memory.pop,ha] + have h1 : (digitMemory d c m).stack 1=ds.map Digit.b := by + simp [digitMemory,Memory.push,Memory.pop,hb] + have hh := ih (nextCarry d.a d.b c) (digitMemory d c m) h0 h1 + refine ⟨hh.1,hh.2.1,?_,?_,hh.2.2.2.2.1,hh.2.2.2.2.2⟩ + · simpa [wordMemory,output,List.reverse_cons,List.append_assoc,digitMemory,Memory.push,Memory.pop,Function.update_apply] using hh.2.2.1 + · simpa [wordMemory,digitMemory,Memory.push,Memory.pop,Function.update_apply] using hh.2.2.2.1 + +theorem finish (m : Memory 4) (c b : Bool) (hm : m.stack 0=[]) : + step program b (config (.start c) m)=config (.done c) (m.pop 0) := by + simp [step,program,config,label,code,effect,branch,hm] + +theorem final_carry (m : Memory 4) (c b : Bool) : + step program b (config (.done c) m)=config .halt (m.push 2 c) := by + rw [one_step]; rfl + +theorem halt (m : Memory 4) (b : Bool) : + step program b (config .halt m)=⟨none,m⟩ := by + rw [one_step]; rfl + +theorem finish_run (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (coins : List Bool) (hl : coins.length=3*ds.length) (b b' b'' : Bool) : + (coins++[b,b',b'']).foldl (fun cfg b => step program b cfg) (config (.start c) m)= + ⟨none,((wordMemory ds c m).pop 0).push 2 (carry ds c)⟩ := by + rw [List.foldl_append,pass_any ds c m ha hb coins hl] + simp only [List.foldl_cons,List.foldl_nil] + rw [finish _ _ _ (wordMemory_stacks ds c m ha hb).1,final_carry,halt] + + + +theorem tape_pass (ds : List Digit) (c : Bool) (m : Memory 4) + (ha : m.stack 0=ds.map Digit.a) (hb : m.stack 1=ds.map Digit.b) + (coins : Fin ((3*ds.length)*2)→Bool) : + (List.ofFn coins).foldl (fun cfg b => (compile program).step b cfg) (encode program (config (.start c) m))= + encode program (config (.start (carry ds c)) (wordMemory ds c m)) := by + rw [BinarySubtract.fold_compiled,pass_any ds c m ha hb _ (by simp)] + +end +end Contingency.BitModel.StackCode.BinaryAdd + + + + + + + +namespace Contingency.BitModel.StackCode.BinarySubtract +noncomputable section + +theorem value_append_false (xs : List Bool) (n : ℕ) : + value (xs++List.replicate n false)=value xs := by + induction xs with + | nil => + simp only [List.nil_append,value] + induction n with + | zero => rfl + | succ n ih => simp [List.replicate_succ,value,ih] + | cons b xs ih => simp [value,ih] + +theorem value_bits (x : ℕ) : value x.bits=x := by + induction x using Nat.binaryRec' with + | zero => rfl + | bit b n h ih => + rw [Nat.bits_append_bit _ _ h] + change b.toNat+2*value n.bits=Nat.bit b n + rw [ih] + cases b <;> simp [Nat.bit] + omega + +def bits (n x : ℕ) : List Bool := x.bits++List.replicate (n-x.size) false + +@[simp] theorem bits_length (n x : ℕ) (h : x<2^n) : (bits n x).length=n := by + have hh := Nat.size_le.mpr h + simp only [bits,List.length_append,List.length_replicate] + have he := Nat.size_eq_bits_len x + omega + +@[simp] theorem bits_value (n x : ℕ) : value (bits n x)=x := by + rw [bits,value_append_false,value_bits] + +def digits (as bs : List Bool) : List Digit := List.zipWith Digit.mk as bs + +theorem digits_maps (as bs : List Bool) (h : as.length=bs.length) : + (digits as bs).map Digit.a=as ∧ (digits as bs).map Digit.b=bs ∧ + (digits as bs).length=as.length := by + induction as generalizing bs with + | nil => + have he : bs=[] := List.length_eq_zero_iff.mp (by simpa using h.symm) + subst bs + exact ⟨rfl,rfl,rfl⟩ + | cons a as ih => + cases bs with + | nil => simp at h + | cons b bs => + have hh := ih bs (by simpa using h) + simpa [digits,List.zipWith_cons_cons] using hh + +theorem borrow_iff (ds : List Digit) : + borrow ds false=true ↔ value (ds.map Digit.a) + simp only [hb,Bool.toNat_false,Bool.toNat_true,Nat.mul_zero,Nat.mul_one,Nat.add_zero] at hi + · constructor + · intro h; cases h + · intro h; omega + · constructor + · intro h; omega + · intro h; rfl + + + +theorem padded_subtraction (n x y : ℕ) (hx : x<2^n) (hy : y<2^n) : + let ds := digits (bits n x) (bits n y) + ds.length=n ∧ (borrow ds false=true ↔ x .push i b (f q) + | .pop i e z o => .pop i (f e) (f z) (f o) + | .read e z o => .read (f e) (f z) (f o) + | .coin z o => .coin (f z) (f o) + | .emit b q => .emit b (f q) + | .jump q => .jump (f q) + | .halt => stop + +def next (f : Fin l→Fin L) (stop : Option (Fin L)) : Option (Fin l)→Option (Fin L) + | none => stop + | some q => some (f q) + +theorem branch_map (f : Fin l→Fin L) (e z o : Fin l) (b : Option Bool) : + branch (f e) (f z) (f o) b=f (branch e z o b) := by + cases b with + | none => rfl + | some b => cases b <;> rfl + +theorem effect_jump (f : Fin l→Fin L) (q : Fin L) (op : Op l w) (b : Bool) (m : Memory w) : + effect (relabel f (.jump q) op) b m=(next f (some q) (effect op b m).1,(effect op b m).2) := by + cases op <;> simp only [relabel,effect,next,branch_map] + case coin z o => cases b <;> rfl + +theorem effect_halt (f : Fin l→Fin L) (op : Op l w) (b : Bool) (m : Memory w) : + effect (relabel f .halt op) b m=(Option.map f (effect op b m).1,(effect op b m).2) := by + cases op <;> simp only [relabel,effect,Option.map_some,Option.map_none,branch_map] + case coin z o => cases b <;> rfl + +variable (P : Program) (q : ℕ) (start : Fin q) (code : Fin q→Op q P.work) + +def rightProgram : Program := ⟨q,P.work,start,code⟩ + +def program : Program := + ⟨P.labels+q,P.work,P.start.castAdd q, + Fin.addCases + (fun i => relabel (Fin.castAdd q) (.jump (Fin.natAdd P.labels start)) (P.code i)) + (fun i => relabel (Fin.natAdd P.labels) .halt (code i))⟩ + +def left (cfg : Config P) : Config (program P q start code) := + ⟨next (Fin.castAdd q) (some (Fin.natAdd P.labels start)) cfg.state,cfg.memory⟩ + +def right (cfg : Config (rightProgram P q start code)) : Config (program P q start code) := + ⟨Option.map (Fin.natAdd P.labels) cfg.state,cfg.memory⟩ + +theorem step_left (cfg : Config P) (b : Bool) (live : cfg.state≠none) : + step (program P q start code) b (left P q start code cfg)= + left P q start code (step P b cfg) := by + rcases cfg with ⟨s,m⟩ + cases s with + | none => exact (live rfl).elim + | some pc => + simp only [left,next,step,program,Fin.addCases_left,effect_jump] + + theorem step_right (cfg : Config (rightProgram P q start code)) (b : Bool) : + step (program P q start code) b (right P q start code cfg)= + right P q start code (step (rightProgram P q start code) b cfg) := by + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some pc => + change Fin q at pc + change Memory P.work at m + change (let e := effect ((program P q start code).code (Fin.natAdd P.labels pc)) b m; (⟨e.1,e.2⟩ : Config (program P q start code))) = + ⟨Option.map (Fin.natAdd P.labels) (effect (code pc) b m).1,(effect (code pc) b m).2⟩ + simp only [program,Fin.addCases_right,effect_halt] + + +def FirstHalt (cfg : Config P) : List Bool→Prop + | [] => cfg.state=none + | b::bs => cfg.state≠none ∧ FirstHalt (step P b cfg) bs + +theorem firstHalt_result (cfg : Config P) (bs : List Bool) (h : FirstHalt P cfg bs) : + (bs.foldl (fun c b => step P b c) cfg).state=none := by + induction bs generalizing cfg with + | nil => exact h + | cons b bs ih => exact ih _ h.2 + +theorem fold_left (cfg : Config P) (bs : List Bool) (h : FirstHalt P cfg bs) : + bs.foldl (fun c b => step (program P q start code) b c) (left P q start code cfg)= + left P q start code (bs.foldl (fun c b => step P b c) cfg) := by + induction bs generalizing cfg with + | nil => rfl + | cons b bs ih => + simp only [List.foldl_cons] + rw [step_left P q start code cfg b h.1] + exact ih _ h.2 + +theorem fold_right (cfg : Config (rightProgram P q start code)) (bs : List Bool) : + bs.foldl (fun c b => step (program P q start code) b c) (right P q start code cfg)= + right P q start code (bs.foldl (fun c b => step (rightProgram P q start code) b c) cfg) := by + induction bs generalizing cfg with + | nil => rfl + | cons b bs ih => + simp only [List.foldl_cons] + rw [step_right P q start code] + exact ih _ + + + +theorem link_run (cfg : Config P) (a b : List Bool) (h : FirstHalt P cfg a) : + (a++b).foldl (fun c v => step (program P q start code) v c) (left P q start code cfg)= + right P q start code (b.foldl (fun c v => step (rightProgram P q start code) v c) + ⟨some start,(a.foldl (fun c v => step P v c) cfg).memory⟩) := by + rw [List.foldl_append,fold_left P q start code cfg a h] + have hs := firstHalt_result P cfg a h + have he : left P q start code (a.foldl (fun c v => step P v c) cfg)= + right P q start code ⟨some start,(a.foldl (fun c v => step P v c) cfg).memory⟩ := by + simp only [left,right,next,hs] + rfl + rw [he,fold_right] + +end Contingency.BitModel.StackCode.Sequence + + + + + +namespace Contingency.BitModel.StackCode.Sequence + +variable (P : Program) + +theorem halted_fold (cfg : Config P) (h : cfg.state=none) (xs : List Bool) : + xs.foldl (fun c b => step P b c) cfg=cfg := by + induction xs with + | nil => rfl + | cons x xs ih => + have hs : step P x cfg=cfg := by rcases cfg with ⟨s,m⟩; dsimp only at h; subst s; rfl + simpa only [List.foldl_cons,hs] using ih + + + +theorem first_prefix (cfg : Config P) (xs : List Bool) + (h : (xs.foldl (fun c b => step P b c) cfg).state=none) : + ∃ a b : List Bool,xs=a++b ∧ FirstHalt P cfg a ∧ + a.foldl (fun c b => step P b c) cfg=xs.foldl (fun c b => step P b c) cfg := by + induction xs generalizing cfg with + | nil => exact ⟨[],[],rfl,h,rfl⟩ + | cons x xs ih => + by_cases hc : cfg.state=none + · refine ⟨[],x::xs,rfl,hc,?_⟩ + exact (halted_fold P cfg hc (x::xs)).symm + · obtain ⟨a,b,hab,hh,he⟩ := ih (step P x cfg) h + exact ⟨x::a,b,by simp [hab],⟨hc,hh⟩,he⟩ + +def Deterministic : Prop := ∀ (cfg : Config P) (a b : Bool),step P a cfg=step P b cfg + +theorem deterministic_fold (hd : Deterministic P) (cfg : Config P) (a b : List Bool) + (hl : a.length=b.length) : + a.foldl (fun c v => step P v c) cfg=b.foldl (fun c v => step P v c) cfg := by + induction a generalizing cfg b with + | nil => have hb : b=[] := List.length_eq_zero_iff.mp hl.symm; subst b; rfl + | cons a as ih => + cases b with + | nil => simp at hl + | cons b bs => + simp only [List.length_cons,Nat.add_right_cancel_iff] at hl + simp only [List.foldl_cons] + rw [hd cfg a b] + exact ih _ _ hl + +theorem deterministic_first (hd : Deterministic P) (cfg : Config P) (a b : List Bool) + (hl : a.length=b.length) (h : FirstHalt P cfg a) : FirstHalt P cfg b := by + induction a generalizing cfg b with + | nil => have hb : b=[] := List.length_eq_zero_iff.mp hl.symm; subst b; exact h + | cons a as ih => + cases b with + | nil => simp at hl + | cons b bs => + refine ⟨h.1,?_⟩ + rw [← hd cfg a b] + exact ih _ _ (by simpa using hl) h.2 + + + +theorem deterministic_first_time (hd : Deterministic P) (cfg : Config P) (T : ℕ) + (h : ((List.replicate T false).foldl (fun c b => step P b c) cfg).state=none) : + ∃ t≤T,∀ coins : List Bool,coins.length=t → FirstHalt P cfg coins ∧ + coins.foldl (fun c b => step P b c) cfg= + (List.replicate T false).foldl (fun c b => step P b c) cfg := by + obtain ⟨a,b,he,ha,hr⟩ := first_prefix P cfg (List.replicate T false) h + refine ⟨a.length,?_,?_⟩ + · have hh := congrArg List.length he + simp only [List.length_replicate,List.length_append] at hh + omega + · intro coins hc + exact ⟨deterministic_first P hd cfg a coins hc.symm ha, + (deterministic_fold P hd cfg coins a hc).trans hr⟩ + +variable (q : ℕ) (start : Fin q) (code : Fin q→Op q P.work) + + + +theorem tape_link (cfg : Config P) {t : ℕ} (coins : Fin (t*2)→Bool) (k : ℕ) + (h : FirstHalt P cfg ((List.ofFn fun i : Fin t => coins (second i)).take k)) : + (List.ofFn coins).foldl (fun c b => (compile (program P q start code)).step b c) + (encode (program P q start code) (left P q start code cfg))= + encode (program P q start code) + (right P q start code (((List.ofFn fun i : Fin t => coins (second i)).drop k).foldl + (fun c b => step (rightProgram P q start code) b c) + ⟨some start,(((List.ofFn fun i : Fin t => coins (second i)).take k).foldl + (fun c b => step P b c) cfg).memory⟩)) := by + rw [Internal.tape_fold] + have hs := link_run P q start code cfg + ((List.ofFn fun i : Fin t => coins (second i)).take k) + ((List.ofFn fun i : Fin t => coins (second i)).drop k) h + rw [List.take_append_drop] at hs + rw [hs] + +end Contingency.BitModel.StackCode.Sequence + + + + + + + +namespace Contingency.BitModel.StackCode.Registers + +variable {l w v : ℕ} + +def op (f : Fin w→Fin v) : Op l w→Op l v + | .push i b q => .push (f i) b q + | .pop i e z o => .pop (f i) e z o + | .read e z o => .read e z o + | .coin z o => .coin z o + | .emit b q => .emit b q + | .jump q => .jump q + | .halt => .halt + +def program (P : Program) (f : Fin P.work→Fin v) : Program := + ⟨P.labels,v,P.start,fun q => op f (P.code q)⟩ + +def MemoryRel (f : Fin w→Fin v) (a : Memory w) (b : Memory v) : Prop := + (∀ i,b.stack (f i)=a.stack i) ∧ b.input=a.input ∧ + b.outputRev=a.outputRev ∧ b.consumed=a.consumed + +theorem push_rel (f : Fin w→Fin v) (hf : Function.Injective f) + {a : Memory w} {b : Memory v} (h : MemoryRel f a b) (i : Fin w) (x : Bool) : + MemoryRel f (a.push i x) (b.push (f i) x) := by + refine ⟨?_,h.2⟩ + intro j + simp [Memory.push,Function.update_apply,hf.eq_iff,h.1] + +theorem pop_rel (f : Fin w→Fin v) (hf : Function.Injective f) + {a : Memory w} {b : Memory v} (h : MemoryRel f a b) (i : Fin w) : + MemoryRel f (a.pop i) (b.pop (f i)) := by + refine ⟨?_,h.2⟩ + intro j + simp [Memory.pop,Function.update_apply,hf.eq_iff,h.1] + +theorem read_rel (f : Fin w→Fin v) + {a : Memory w} {b : Memory v} (h : MemoryRel f a b) : + MemoryRel f a.read b.read := by + exact ⟨h.1,congrArg List.tail h.2.1,h.2.2.1,congrArg (·+1) h.2.2.2⟩ + +theorem effect_rel (f : Fin w→Fin v) (hf : Function.Injective f) (code : Op l w) (coin : Bool) + {a : Memory w} {b : Memory v} (h : MemoryRel f a b) : + (effect (op f code) coin b).1=(effect code coin a).1 ∧ + MemoryRel f (effect code coin a).2 (effect (op f code) coin b).2 := by + cases code with + | push i x q => exact ⟨rfl,push_rel f hf h i x⟩ + | pop i e z o => exact ⟨by simp [op,effect,h.1],pop_rel f hf h i⟩ + | read e z o => exact ⟨by simp [op,effect,h.2.1],read_rel f h⟩ + | coin z o => exact ⟨rfl,h⟩ + | emit x q => exact ⟨rfl,h.1,h.2.1,congrArg (x::·) h.2.2.1,h.2.2.2⟩ + | jump q => exact ⟨rfl,h⟩ + | halt => exact ⟨rfl,h⟩ + +def ConfigRel (P : Program) (f : Fin P.work→Fin v) + (a : Config P) (b : Config (program P f)) : Prop := + b.state=a.state ∧ MemoryRel f a.memory b.memory + +theorem step_rel (P : Program) (f : Fin P.work→Fin v) (hf : Function.Injective f) + (coin : Bool) {a : Config P} {b : Config (program P f)} (h : ConfigRel P f a b) : + ConfigRel P f (step P coin a) (step (program P f) coin b) := by + rcases a with ⟨s,a⟩ + rcases b with ⟨t,b⟩ + obtain ⟨hs,hr⟩ := h + dsimp only at hs hr + subst t + cases s with + | none => exact ⟨rfl,hr⟩ + | some q => exact effect_rel f hf (P.code q) coin hr + +theorem fold_rel (P : Program) (f : Fin P.work→Fin v) (hf : Function.Injective f) + (coins : List Bool) {a : Config P} {b : Config (program P f)} (h : ConfigRel P f a b) : + ConfigRel P f (coins.foldl (fun c v => step P v c) a) + (coins.foldl (fun c v => step (program P f) v c) b) := by + induction coins generalizing a b with + | nil => exact h + | cons x xs ih => exact ih (step_rel P f hf x h) + +theorem effect_frame (f : Fin w→Fin v) (code : Op l w) (coin : Bool) (m : Memory v) + (j : Fin v) (hj : ∀ i,f i≠j) : (effect (op f code) coin m).2.stack j=m.stack j := by + cases code <;> simp [op,effect,Memory.push,Memory.pop,Memory.read,fun i => (hj i).symm] + +theorem step_frame (P : Program) (f : Fin P.work→Fin v) (coin : Bool) + (cfg : Config (program P f)) (j : Fin v) (hj : ∀ i,f i≠j) : + (step (program P f) coin cfg).memory.stack j=cfg.memory.stack j := by + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some q => exact effect_frame f (P.code q) coin m j hj + +theorem fold_frame (P : Program) (f : Fin P.work→Fin v) (coins : List Bool) + (cfg : Config (program P f)) (j : Fin v) (hj : ∀ i,f i≠j) : + (coins.foldl (fun c x => step (program P f) x c) cfg).memory.stack j=cfg.memory.stack j := by + induction coins generalizing cfg with + | nil => rfl + | cons x xs ih => exact (ih (step (program P f) x cfg)).trans (step_frame P f x cfg j hj) + + + +theorem tape_refinement (P : Program) (f : Fin P.work→Fin v) (hf : Function.Injective f) + {a : Config P} {b : Config (program P f)} (h : ConfigRel P f a b) + {t : ℕ} (coins : Fin (t*2)→Bool) : + ∃ b' : Config (program P f), + (List.ofFn coins).foldl (fun c x => (compile (program P f)).step x c) (encode (program P f) b)= + encode (program P f) b' ∧ + ConfigRel P f ((List.ofFn fun i : Fin t => coins (second i)).foldl (fun c x => step P x c) a) b' ∧ + ∀ j,(∀ i,f i≠j) → b'.memory.stack j=b.memory.stack j := by + let xs := List.ofFn fun i : Fin t => coins (second i) + refine ⟨xs.foldl (fun c x => step (program P f) x c) b,Internal.tape_fold _ _ coins, + fold_rel P f hf xs h,?_⟩ + exact fun j hj => fold_frame P f xs b j hj + +end Contingency.BitModel.StackCode.Registers + + + + + + + +namespace Contingency.BitModel.StackCode.Transfer + +variable {w : ℕ} (src dst : Fin w) + +def code : Fin 4→Op 4 w + | 0 => .pop src 3 1 2 + | 1 => .push dst false 0 + | 2 => .push dst true 0 + | _ => .halt + +def program : Program := ⟨4,w,0,code src dst⟩ +def config (q : Fin 4) (m : Memory w) : Config (program src dst) := ⟨some q,m⟩ +def exec (n : ℕ) (cfg : Config (program src dst)) : Config (program src dst) := + (List.replicate n false).foldl (fun c b => step (program src dst) b c) cfg + +theorem exec_add (s t : ℕ) (cfg : Config (program src dst)) : + exec src dst (s+t) cfg=exec src dst t (exec src dst s cfg) := by + simp only [exec,List.replicate_add,List.foldl_append] + +def memory : List Bool→Memory w→Memory w + | [],m => m.pop src + | b::bs,m => memory bs ((m.pop src).push dst b) + +theorem two_steps (m : Memory w) (b : Bool) (bs : List Bool) (h : m.stack src=b::bs) : + exec src dst 2 (config src dst 0 m)=config src dst 0 ((m.pop src).push dst b) := by + cases b <;> simp [exec,step,config,program,code,effect,branch,h,List.replicate_succ] + +theorem empty_run (m : Memory w) (h : m.stack src=[]) : + exec src dst 2 (config src dst 0 m)=⟨none,m.pop src⟩ := by + simp [exec,step,config,program,code,effect,branch,h,List.replicate_succ] + +theorem run (hij : src≠dst) (bs : List Bool) (m : Memory w) (h : m.stack src=bs) : + exec src dst (2*bs.length+2) (config src dst 0 m)=⟨none,memory src dst bs m⟩ := by + induction bs generalizing m with + | nil => exact empty_run src dst m h + | cons b bs ih => + have he : 2*(b::bs).length+2=2+(2*bs.length+2) := by simp; omega + rw [he,exec_add,two_steps src dst m b bs h,ih] + · rfl + · simp [Memory.push,Memory.pop,h,hij] + +theorem memory_fields (hij : src≠dst) (bs : List Bool) (m : Memory w) (h : m.stack src=bs) : + (memory src dst bs m).stack src=[] ∧ + (memory src dst bs m).stack dst=bs.reverse++m.stack dst ∧ + (∀ i,i≠src → i≠dst → (memory src dst bs m).stack i=m.stack i) ∧ + (memory src dst bs m).input=m.input ∧ + (memory src dst bs m).outputRev=m.outputRev ∧ + (memory src dst bs m).consumed=m.consumed := by + induction bs generalizing m with + | nil => + refine ⟨by simp [memory,Memory.pop,h],by simp [memory,Memory.pop,hij.symm],?_,rfl,rfl,rfl⟩ + intro i hi hj + simp [memory,Memory.pop,hi] + | cons b bs ih => + have hs : ((m.pop src).push dst b).stack src=bs := by simp [Memory.pop,Memory.push,h,hij] + have hh := ih ((m.pop src).push dst b) hs + refine ⟨hh.1,?_,?_,hh.2.2.2⟩ + · simpa [memory,Memory.pop,Memory.push,hij.symm,List.reverse_cons,List.append_assoc] using hh.2.1 + · intro i hi hj + simpa [memory,Memory.pop,Memory.push,hi,hj] using hh.2.2.1 i hi hj + +theorem deterministic : Sequence.Deterministic (program src dst) := by + intro cfg a b + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some q => + change Fin 4 at q + fin_cases q <;> rfl + + + +theorem tape (hij : src≠dst) (bs : List Bool) (m : Memory w) (h : m.stack src=bs) + (coins : Fin ((2*bs.length+2)*2)→Bool) : + (List.ofFn coins).foldl (fun c b => (compile (program src dst)).step b c) + (encode (program src dst) (config src dst 0 m))= + encode (program src dst) ⟨none,memory src dst bs m⟩ := by + rw [Internal.tape_fold] + rw [Sequence.deterministic_fold _ (deterministic src dst) _ _ + (List.replicate (2*bs.length+2) false) (by simp)] + exact congrArg (encode (program src dst)) (run src dst hij bs m h) + +end Contingency.BitModel.StackCode.Transfer + + + + + +namespace Contingency.BitModel.StackCode + + +def NoCoin {l w : ℕ} : Op l w→Prop + | .coin _ _ => False + | _ => True + +theorem noCoin_effect {l w : ℕ} (op : Op l w) (h : NoCoin op) (a b : Bool) (m : Memory w) : + effect op a m=effect op b m := by + cases op <;> try rfl + exact h.elim + +theorem noCoin_deterministic (P : Program) (h : ∀ q,NoCoin (P.code q)) : Sequence.Deterministic P := by + intro cfg a b + rcases cfg with ⟨s,m⟩ + cases s with + | none => rfl + | some q => + change (⟨(effect (P.code q) a m).1,(effect (P.code q) a m).2⟩ : Config P)= + ⟨(effect (P.code q) b m).1,(effect (P.code q) b m).2⟩ + rw [noCoin_effect _ (h q) a b m] + +theorem noCoin_registers {l w v : ℕ} (f : Fin w→Fin v) (op : Op l w) (h : NoCoin op) : + NoCoin (Registers.op f op) := by + cases op <;> exact h + +theorem noCoin_relabel {l L w : ℕ} (f : Fin l→Fin L) (stop : Op L w) (hs : NoCoin stop) + (op : Op l w) (h : NoCoin op) : NoCoin (Sequence.relabel f stop op) := by + cases op <;> first | exact h | exact hs + +theorem noCoin_sequence (P : Program) (q : ℕ) (start : Fin q) (code : Fin q→Op q P.work) + (hp : ∀ i,NoCoin (P.code i)) (hq : ∀ i,NoCoin (code i)) : + ∀ i,NoCoin ((Sequence.program P q start code).code i) := by + intro i + refine Fin.addCases ?_ ?_ i + · intro j + simpa only [Sequence.program,Fin.addCases_left] using + noCoin_relabel (Fin.castAdd q) (.jump (Fin.natAdd P.labels start)) trivial (P.code j) (hp j) + · intro j + simpa only [Sequence.program,Fin.addCases_right] using + noCoin_relabel (Fin.natAdd P.labels) .halt trivial (code j) (hq j) + +end Contingency.BitModel.StackCode + + + + + + + +namespace Contingency.BitModel.StackCode.ParseNat +noncomputable section + +inductive Q | prefix | count | data | bit | store (b : Bool) | restore | place (b : Bool) | done + deriving DecidableEq,Fintype + +def label (q : Q) : Fin (Fintype.card Q) := Fintype.equivFin Q q + +def code : Q→Op (Fintype.card Q) 4 + | .prefix => .read (label .done) (label .data) (label .count) + | .count => .push 2 false (label .prefix) + | .data => .pop 2 (label .restore) (label .bit) (label .bit) + | .bit => .read (label (.store false)) (label (.store false)) (label (.store true)) + | .store b => .push 1 b (label .data) + | .restore => .pop 1 (label .done) (label (.place false)) (label (.place true)) + | .place b => .push 0 b (label .restore) + | .done => .halt + +def program : Program := ⟨Fintype.card Q,4,label .prefix,fun pc => code ((Fintype.equivFin Q).symm pc)⟩ +def config (q : Q) (m : Memory 4) : Config program := ⟨some (label q),m⟩ +def exec (t : ℕ) (cfg : Config program) : Config program := + (List.replicate t false).foldl (fun cfg b => step program b cfg) cfg + +theorem exec_add (s t : ℕ) (cfg : Config program) : exec (s+t) cfg=exec t (exec s cfg) := by + simp only [exec,List.replicate_add,List.foldl_append] + +@[simp] theorem exec_zero (cfg : Config program) : exec 0 cfg=cfg := rfl +@[simp] theorem exec_one (cfg : Config program) : exec 1 cfg=step program false cfg := rfl + +theorem one_step (q : Q) (m : Memory 4) (coin : Bool) : + step program coin (config q m)=⟨(effect (code q) coin m).1,(effect (code q) coin m).2⟩ := by + simp [step,program,config,label] + +theorem prefix_zero (m : Memory 4) (rest : List Bool) (h : m.input=false::rest) : + exec 1 (config .prefix m)=config .data m.read := by + rw [exec_one,one_step] + simp [code,effect,branch,h,config] + rfl + +theorem prefix_one (m : Memory 4) (rest : List Bool) (h : m.input=true::rest) : + exec 2 (config .prefix m)=config .prefix (m.read.push 2 false) := by + change step program false (step program false (config .prefix m))=_ + rw [one_step] + have he : (⟨(effect (code .prefix) false m).1,(effect (code .prefix) false m).2⟩ : Config program)=config .count m.read := by + simp [code,effect,branch,h,config]; rfl + rw [he,one_step] + rfl + +def prefixMemory : ℕ→Memory 4→Memory 4 + | 0,m => m.read + | n+1,m => prefixMemory n (m.read.push 2 false) + +theorem prefix_run (n : ℕ) (m : Memory 4) (rest : List Bool) + (hi : m.input=List.replicate n true++false::rest) : + exec (2*n+1) (config .prefix m)=config .data (prefixMemory n m) := by + induction n generalizing m with + | zero => exact prefix_zero m rest hi + | succ n ih => + have he : 2*(n+1)+1=2+(2*n+1) := by omega + rw [he,exec_add,prefix_one m _ hi,ih] + · rfl + · simp [Memory.push,Memory.read,hi,List.replicate_succ] + +theorem prefixMemory_fields (n : ℕ) (m : Memory 4) (rest : List Bool) + (hi : m.input=List.replicate n true++false::rest) : + (prefixMemory n m).input=rest ∧ + (prefixMemory n m).stack 0=m.stack 0 ∧ + (prefixMemory n m).stack 1=m.stack 1 ∧ + (prefixMemory n m).stack 2=List.replicate n false++m.stack 2 ∧ + (prefixMemory n m).stack 3=m.stack 3 ∧ + (prefixMemory n m).outputRev=m.outputRev := by + induction n generalizing m with + | zero => simp [prefixMemory,Memory.read,hi] + | succ n ih => + have hh := ih (m.read.push 2 false) (by simp [Memory.push,Memory.read,hi,List.replicate_succ]) + have he : List.replicate n false++false::m.stack 2=List.replicate (n+1) false++m.stack 2 := by + rw [show List.replicate (n+1) false=List.replicate n false++[false] by rw [List.replicate_add]; rfl,List.append_assoc]; rfl + simpa [prefixMemory,Memory.push,Memory.read,he] using hh + +def digitMemory (b : Bool) (m : Memory 4) : Memory 4 := ((m.pop 2).read).push 1 b + +theorem digit_run (b : Bool) (m : Memory 4) (rest count : List Bool) + (hi : m.input=b::rest) (h2 : m.stack 2=false::count) : + exec 3 (config .data m)=config .data (digitMemory b m) := by + change step program false (step program false (step program false (config .data m)))=_ + rw [one_step] + have he : (⟨(effect (code .data) false m).1,(effect (code .data) false m).2⟩ : Config program)=config .bit (m.pop 2) := by + simp [code,effect,branch,h2,config]; rfl + rw [he,one_step] + have he' : (⟨(effect (code .bit) false (m.pop 2)).1,(effect (code .bit) false (m.pop 2)).2⟩ : Config program)=config (.store b) (m.pop 2).read := by + cases b <;> simp [code,effect,branch,hi,config,Memory.pop] <;> rfl + rw [he',one_step] + rfl + +def dataMemory : List Bool→Memory 4→Memory 4 + | [],m => m + | b::bs,m => dataMemory bs (digitMemory b m) + +theorem data_run (bs : List Bool) (m : Memory 4) (rest : List Bool) + (hi : m.input=bs++rest) (h2 : m.stack 2=List.replicate bs.length false) : + exec (3*bs.length) (config .data m)=config .data (dataMemory bs m) := by + induction bs generalizing m with + | nil => rfl + | cons b bs ih => + have he : 3*(b::bs).length=3+3*bs.length := by simp; omega + rw [he,exec_add,digit_run b m _ _ hi h2,ih] + · rfl + · simp [digitMemory,Memory.push,Memory.read,Memory.pop,hi] + · simp [digitMemory,Memory.push,Memory.read,Memory.pop,h2,List.replicate_succ] + +theorem dataMemory_fields (bs : List Bool) (m : Memory 4) (rest : List Bool) + (hi : m.input=bs++rest) (h2 : m.stack 2=List.replicate bs.length false) : + (dataMemory bs m).input=rest ∧ + (dataMemory bs m).stack 0=m.stack 0 ∧ + (dataMemory bs m).stack 1=bs.reverse++m.stack 1 ∧ + (dataMemory bs m).stack 2=[] ∧ + (dataMemory bs m).stack 3=m.stack 3 ∧ + (dataMemory bs m).outputRev=m.outputRev := by + induction bs generalizing m with + | nil => exact ⟨hi,rfl,rfl,h2,rfl,rfl⟩ + | cons b bs ih => + have hh := ih (digitMemory b m) (by simp [digitMemory,Memory.push,Memory.read,Memory.pop,hi]) + (by simp [digitMemory,Memory.push,Memory.read,Memory.pop,h2,List.replicate_succ]) + simpa [dataMemory,digitMemory,Memory.push,Memory.read,Memory.pop,List.reverse_cons,List.append_assoc] using hh + +end +end Contingency.BitModel.StackCode.ParseNat + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/Transport.lean b/lean/OAI/Probability/Contingency/Transport.lean new file mode 100644 index 0000000000000000000000000000000000000000..e77435468c37047b51f0770f97692294176de03f --- /dev/null +++ b/lean/OAI/Probability/Contingency/Transport.lean @@ -0,0 +1,463 @@ +import Mathlib +import OAI.Probability.Contingency.Signature + +namespace OAI + +/-! Transport. -/ + +noncomputable section + +open scoped BigOperators +open QuadraticMap +open scoped BigOperators +open QuadraticMap + +namespace Contingency + + + +section FutureSquare +variable {V : Type*} [AddCommGroup V] [Module ℝ V] [FiniteDimensional ℝ V] + + + +omit [FiniteDimensional ℝ V] in +theorem pair_mixed_telescope (D : ℕ) (S : ℕ → V →ₗ[ℝ] ℝ) (sD : S D = 0) + (h : V) (g : ℕ → ℝ) : + (∑ j ∈ Finset.range (D+1), pairPrevious S j h * g j) = + ∑ j ∈ Finset.range (D+1), S j h * g (j+1) := by + rw [Finset.sum_range_succ', Finset.sum_range_succ] + simp [pairPrevious, sD] + + + +omit [FiniteDimensional ℝ V] in +theorem future_square_sequence (D : ℕ) (u : ℕ → ℝ) + (S : ℕ → V →ₗ[ℝ] ℝ) (Q : ℕ → QuadraticForm ℝ V) + (u0 : u 0 = 0) (uD : u D = 0) (uNext : u (D+1) = 0) (sD : S D = 0) + (h : V) (g : ℕ → ℝ) : + (∑ j ∈ Finset.range (D+1), + pairForm (Q j) (pairPrevious S j) (S j) + (u (j-1)) (u j) (u (j+1)) (h,g j,-g (j+1))) - + (∑ j ∈ Finset.range (D+1), Q j h) = + ∑ j ∈ Finset.range (D+1), u j * (g (j+1) - g j)^2 := by + have hm := pair_mixed_telescope D S sD h g + have hp : (∑ j ∈ Finset.range (D+1), u (j-1) * g j ^ 2) = + ∑ j ∈ Finset.range (D+1), u j * g (j+1)^2 := by + rw [Finset.sum_range_succ', Finset.sum_range_succ] + simp [u0,uD] + have hn : (∑ j ∈ Finset.range (D+1), u (j+1) * g (j+1)^2) = + ∑ j ∈ Finset.range (D+1), u j * g j^2 := by + have hw := Finset.sum_range_succ' (fun j => u j * g j^2) (D+1) + rw [Finset.sum_range_succ, uNext, u0] at hw + simpa using hw.symm + simp only [pairForm_apply] + have he (j : ℕ) : + Q j h + 2 * (pairPrevious S j) h * g j + 2 * S j h * -g (j+1) + + u (j-1) * g j^2 + 2 * u j * g j * -g (j+1) + u (j+1) * (-g (j+1))^2 = + Q j h + 2 * ((pairPrevious S j) h * g j) - 2 * (S j h * g (j+1)) + + u (j-1) * g j^2 - 2 * (u j * g j * g (j+1)) + u (j+1) * g (j+1)^2 := by ring + simp_rw [he] + simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum, hm, hp, hn] + symm + calc + _ = ∑ j ∈ Finset.range (D+1), + (u j * g (j+1)^2 - 2 * (u j * g j * g (j+1)) + u j * g j^2) := by + apply Finset.sum_congr rfl + intro j _ + ring + _ = _ := by simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, + ← Finset.mul_sum]; ring + +omit [FiniteDimensional ℝ V] in +theorem future_square_nonneg (D : ℕ) (u : ℕ → ℝ) + (S : ℕ → V →ₗ[ℝ] ℝ) (Q : ℕ → QuadraticForm ℝ V) + (hu : ∀ j, 0 ≤ u j) (u0 : u 0 = 0) (uD : u D = 0) + (uNext : u (D+1) = 0) (sD : S D = 0) (h : V) (g : ℕ → ℝ) : + (∑ j ∈ Finset.range (D+1), Q j h) ≤ + ∑ j ∈ Finset.range (D+1), pairForm (Q j) (pairPrevious S j) (S j) + (u (j-1)) (u j) (u (j+1)) (h,g j,-g (j+1)) := by + have he := future_square_sequence D u S Q u0 uD uNext sD h g + have hn : 0 ≤ ∑ j ∈ Finset.range (D+1), u j * (g (j+1)-g j)^2 := by + exact Finset.sum_nonneg (fun j _ => mul_nonneg (hu j) (sq_nonneg _)) + linarith + +end FutureSquare + +section ActualFuture +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [DecidableEq ι] in +theorem PositiveSlice.nonneg {f : (ι → ℤ) → ℝ} {B : ι → ℤ} {T : ℤ} + (hf : PositiveSlice f B T) (p : ι → ℤ) : 0 ≤ f p := by + by_cases h : InBox B p ∧ (∑ i, p i) = T + · exact (hf.1 p h.1 h.2).le + · rw [hf.2 p h] + + + +theorem actual_future_square (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C T : ℤ) + (hf : PositiveSlice f (pairAssembly B C C) T) (p : ι → ℤ) (D : ℕ) + (h : ι → ℝ) (g : ℕ → ℝ) : + (∑ j ∈ Finset.range (D+1), + matrixForm (twoRemoval f (pairAssembly p (j:ℤ) ((D:ℤ)-j))) + (pairAssembly h (g j) (-g (j+1)))) - + matrixForm (twoRemoval (balancedMarginal f D) p) h = + ∑ j ∈ Finset.range (D+1), pairU f p D j * (g (j+1)-g j)^2 := by + have hb (j : ℕ) := congrArg (fun Q : QuadraticForm ℝ ((ι → ℝ) × ℝ × ℝ) => + Q (h,g j,-g (j+1))) (pair_block_identity f B C T hf p D j) + have hp : matrixForm (twoRemoval (balancedMarginal f D) p) = + ∑ j ∈ Finset.range (D+1), pairQ f p D j := + matrixForm_sum (Finset.range (D+1)) + (fun j i k => f (pairAssembly (removePair p i k) (j:ℤ) ((D:ℤ)-j))) + simp only [QuadraticMap.comp_apply, pairAssemblyLinear, LinearMap.coe_mk, + AddHom.coe_mk] at hb + simp only [hb, hp, sum_apply] + exact future_square_sequence D (pairU f p D) (pairS f p D) (pairQ f p D) + (pairU_zero f B C T hf p D 0 (Or.inl rfl)) + (pairU_zero f B C T hf p D D (Or.inr le_rfl)) + (pairU_zero f B C T hf p D (D+1) (Or.inr (by omega))) + (pairS_top f B C T hf p D) h g + +theorem actual_future_monotone (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C T : ℤ) + (hf : PositiveSlice f (pairAssembly B C C) T) (p : ι → ℤ) (D : ℕ) + (h : ι → ℝ) (g : ℕ → ℝ) : + matrixForm (twoRemoval (balancedMarginal f D) p) h ≤ + ∑ j ∈ Finset.range (D+1), + matrixForm (twoRemoval f (pairAssembly p (j:ℤ) ((D:ℤ)-j))) + (pairAssembly h (g j) (-g (j+1))) := by + have he := actual_future_square f B C T hf p D h g + have hn : 0 ≤ ∑ j ∈ Finset.range (D+1), pairU f p D j * (g (j+1)-g j)^2 := + Finset.sum_nonneg fun j _ => mul_nonneg (hf.nonneg _) (sq_nonneg _) + linarith + + + +noncomputable def raisedMarginal (f : (ι ⊕ Bool → ℤ) → ℝ) (C : ℕ) (p : ι → ℤ) : ℝ := + ∑ j : Fin C, ((j.val+1:ℕ):ℝ) * ((C-j.val:ℕ):ℝ) * + f (pairAssembly p ((j.val+1:ℕ):ℤ) ((C-j.val:ℕ):ℤ)) + +omit [DecidableEq ι] in +theorem raisedMarginal_positive (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (hC : 0 < C) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) : + PositiveSlice (raisedMarginal f C) B (T-(C+1:ℕ)) := by + constructor + · intro p hp ht + apply Finset.sum_pos + · intro j _ + have hj : j.val < C := j.isLt + apply mul_pos + · apply mul_pos <;> exact_mod_cast (by omega : 0 < _) + · apply hf.1 + · rw [pairAssembly_inBox] + exact ⟨hp, by omega, by omega⟩ + · rw [pairAssembly_sum] + omega + · exact ⟨⟨0,hC⟩, Finset.mem_univ _⟩ + · intro p hp + apply Finset.sum_eq_zero + intro j _ + have hj : j.val < C := j.isLt + have hz : f (pairAssembly p ((j.val+1:ℕ):ℤ) ((C-j.val:ℕ):ℤ)) = 0 := by + apply hf.2 + rintro ⟨hb, ht⟩ + rw [pairAssembly_inBox] at hb + rw [pairAssembly_sum] at ht + exact hp ⟨hb.1, by omega⟩ + simp only [hz, mul_zero] + +end ActualFuture + +section BalancedStep +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def holeFunctional (f : (ι → ℤ) → ℝ) (p : ι → ℤ) (h : ι → ℝ) : ℝ := + ∑ i, f (removeOne p i) * h i + +noncomputable def holePotential (f : (ι → ℤ) → ℝ) (p : ι → ℤ) (h : ι → ℝ) : ℝ := + ∑ i, f (removeOne p i) * h i ^ 2 + +omit [Fintype ι] in +theorem removeOne_pair_old (p : ι → ℤ) (a b : ℤ) (i : ι) : + removeOne (pairAssembly p a b) (Sum.inl i) = pairAssembly (removeOne p i) a b := by + funext j + rcases j with j | b' + · simp [removeOne, pairAssembly] + · cases b' <;> simp [removeOne, pairAssembly] + +omit [Fintype ι] in +theorem removeOne_pair_first (p : ι → ℤ) (a b : ℤ) : + removeOne (pairAssembly p a b) (Sum.inr true) = pairAssembly p (a-1) b := by + funext j + rcases j with j | b' + · simp [removeOne, pairAssembly] + · cases b' <;> simp [removeOne, pairAssembly] + +omit [Fintype ι] in +theorem removeOne_pair_second (p : ι → ℤ) (a b : ℤ) : + removeOne (pairAssembly p a b) (Sum.inr false) = pairAssembly p a (b-1) := by + funext j + rcases j with j | b' + · simp [removeOne, pairAssembly] + · cases b' <;> simp [removeOne, pairAssembly] + +theorem holeFunctional_pair (f : (ι ⊕ Bool → ℤ) → ℝ) + (p : ι → ℤ) (a b : ℤ) (h : ι → ℝ) (x y : ℝ) : + holeFunctional f (pairAssembly p a b) (pairAssembly h x y) = + (∑ i, f (pairAssembly (removeOne p i) a b) * h i) + + f (pairAssembly p (a-1) b) * x + f (pairAssembly p a (b-1)) * y := by + simp [holeFunctional, Fintype.sum_sum_type, + removeOne_pair_old, removeOne_pair_first, removeOne_pair_second] + ring + +theorem holePotential_pair (f : (ι ⊕ Bool → ℤ) → ℝ) + (p : ι → ℤ) (a b : ℤ) (h : ι → ℝ) (x y : ℝ) : + holePotential f (pairAssembly p a b) (pairAssembly h x y) = + (∑ i, f (pairAssembly (removeOne p i) a b) * h i^2) + + f (pairAssembly p (a-1) b) * x^2 + f (pairAssembly p a (b-1)) * y^2 := by + simp [holePotential, Fintype.sum_sum_type, + removeOne_pair_old, removeOne_pair_first, removeOne_pair_second] + ring + + + +theorem holeFunctional_branch (f : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (C j : ℕ) + (h : ι → ℝ) (g : ℕ → ℝ) : + holeFunctional f (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1))) = + pairS f p (C+1) j h + pairU f p (C+1) j * g j - + pairU f p (C+1) (j+1) * g (j+1) := by + rw [holeFunctional_pair] + simp only [pairS, columnLinear_apply, pairU, Nat.cast_add, Nat.cast_one] + have he1 : (C:ℤ)+1-1-j = C-j := by ring + have he2 : (C:ℤ)+1-1-(j+1) = C-j-1 := by ring + have he3 : (j:ℤ)+1-1 = j := by ring + simp only [he1,he2,he3] + ring + +theorem parent_balance_sum (f : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (C : ℕ) + (h : ι → ℝ) : + holeFunctional (balancedMarginal f C) p h = + ∑ j ∈ Finset.range (C+1), pairS f p (C+1) j h := by + simp only [holeFunctional, balancedMarginal, pairS, columnLinear_apply, + Nat.cast_add, Nat.cast_one, Finset.sum_mul] + simp only [add_sub_cancel_right] + exact Finset.sum_comm + +theorem balanced_child (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (_hC : 2 ≤ C) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (p : ι → ℤ) (hp : InBox B p) (ht : (∑ i, p i) + (C+1:ℕ) = T+2) + (h : ι → ℝ) (hbal : holeFunctional (balancedMarginal f C) p h = 0) + (j : ℕ) (hj : j ≤ C) : + let g := pairCumulative (C+1) (pairU f p (C+1)) (pairS f p (C+1)) h + holeFunctional f (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1))) = 0 := by + dsimp only + rw [holeFunctional_branch] + have hb : ∑ j ∈ Finset.range (C+1), pairS f p (C+1) j h = 0 := by + rwa [parent_balance_sum] at hbal + have hd := pairCumulative_difference (C+1) (pairU f p (C+1)) (pairS f p (C+1)) + (pairU_positive f B C T hf p hp (C+1) (by omega) ht) h hb j (by omega) + linarith + +theorem holePotential_branch (f : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (C j : ℕ) + (h : ι → ℝ) (g : ℕ → ℝ) : + holePotential f (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1))) = + (∑ i, f (pairAssembly (removeOne p i) (j:ℤ) ((C:ℤ)-j)) * h i^2) + + pairU f p (C+1) j * g j^2 + pairU f p (C+1) (j+1) * g (j+1)^2 := by + rw [holePotential_pair] + simp only [pairU, Nat.cast_add, Nat.cast_one, neg_sq] + congr 2 <;> congr 2 <;> ring_nf + + +theorem child_potential_increment (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) (C : ℕ) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (p : ι → ℤ) (h : ι → ℝ) (g : ℕ → ℝ) : + (∑ j ∈ Finset.range (C+1), holePotential f (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1)))) - holePotential (balancedMarginal f C) p h = + 2 * ∑ j ∈ Finset.range (C+2), pairU f p (C+1) j * g j^2 := by + have h0 := pairU_zero f B (C:ℤ) T hf p (C+1) 0 (Or.inl rfl) + have htop := pairU_zero f B (C:ℤ) T hf p (C+1) (C+1) (Or.inr le_rfl) + have hmain : (∑ j ∈ Finset.range (C+1), + ∑ i, f (pairAssembly (removeOne p i) (j:ℤ) ((C:ℤ)-j)) * h i^2) = + holePotential (balancedMarginal f C) p h := by + simp only [holePotential, balancedMarginal, Finset.sum_mul] + exact Finset.sum_comm + have hn : (∑ j ∈ Finset.range (C+1), pairU f p (C+1) (j+1) * g (j+1)^2) = + ∑ j ∈ Finset.range (C+2), pairU f p (C+1) j * g j^2 := by + have hw := Finset.sum_range_succ' (fun j => pairU f p (C+1) j * g j^2) (C+1) + simpa only [h0, zero_mul, add_zero] using hw.symm + have hp' : (∑ j ∈ Finset.range (C+1), pairU f p (C+1) j * g j^2) = + ∑ j ∈ Finset.range (C+2), pairU f p (C+1) j * g j^2 := by + have hw := Finset.sum_range_succ (fun j => pairU f p (C+1) j * g j^2) (C+1) + simpa only [htop, zero_mul, add_zero] using hw.symm + simp only [holePotential_branch, Finset.sum_add_distrib, hmain, hn, hp'] + ring + + +theorem balanced_potential_bound (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (hC : 2 ≤ C) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (hs : HasSignature f (pairAssembly B (C:ℤ) C) T) + (p : ι → ℤ) (hp : InBox B p) (ht : (∑ i, p i) + (C+1:ℕ) = T+2) + (h : ι → ℝ) (hbal : holeFunctional (balancedMarginal f C) p h = 0) : + let g := pairCumulative (C+1) (pairU f p (C+1)) (pairS f p (C+1)) h + (∑ j ∈ Finset.range (C+1), holePotential f (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1)))) ≤ + holePotential (balancedMarginal f C) p h - + (∑ j ∈ Finset.range (C+2), ((j:ℝ) * (C+1-j)) • pairQ f p (C+1) j) h := by + have hb : ∑ j ∈ Finset.range (C+1), pairS f p (C+1) j h = 0 := by + rwa [parent_balance_sum] at hbal + have hi := actual_pair_weighted f B C hC T hf hs p hp ht h hb + have he := child_potential_increment f B C T hf p h + (pairCumulative (C+1) (pairU f p (C+1)) (pairS f p (C+1)) h) + dsimp + linarith + + + +theorem branch_demand_conservation_endpoints (F : (ι ⊕ Bool → ℤ) → ℝ) + (C : ℕ) (p : ι → ℤ) (h : ι → ℝ) (g : ℕ → ℝ) + (h0 : pairU F p (C+1) 0 = 0) (hC : pairU F p (C+1) (C+1) = 0) : + (∑ j ∈ Finset.range (C+1), + holeFunctional F (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1)))) = + holeFunctional (balancedMarginal F C) p h := by + have ht : (∑ j ∈ Finset.range (C+1), pairU F p (C+1) j * g j) = + ∑ j ∈ Finset.range (C+1), pairU F p (C+1) (j+1) * g (j+1) := by + have hleft := Finset.sum_range_succ (fun j => pairU F p (C+1) j * g j) (C+1) + have hright := Finset.sum_range_succ' (fun j => pairU F p (C+1) j * g j) (C+1) + rw [hC, zero_mul, add_zero] at hleft + rw [h0, zero_mul, add_zero] at hright + exact hleft.symm.trans hright + simp only [holeFunctional_branch, Finset.sum_sub_distrib, Finset.sum_add_distrib, + ht, add_sub_cancel_right, parent_balance_sum] + + + +theorem branch_demand_conservation (f : (ι ⊕ Bool → ℤ) → ℝ) + (B : ι → ℤ) (C : ℕ) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) + (H : (ι ⊕ Bool → ℤ) → ℝ) (p : ι → ℤ) (h : ι → ℝ) (g : ℕ → ℝ) : + (∑ j ∈ Finset.range (C+1), + holeFunctional (fun x => f x * H x) (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1)))) = + holeFunctional (balancedMarginal (fun x => f x * H x) C) p h := by + let F := fun x => f x * H x + have hz (j : ℕ) (hj : j = 0 ∨ C+1 ≤ j) : pairU F p (C+1) j = 0 := by + change f _ * H _ = 0 + change pairU f p (C+1) j * H _ = 0 + rw [pairU_zero f B (C:ℤ) T hf p (C+1) j hj, zero_mul] + have ht : (∑ j ∈ Finset.range (C+1), pairU F p (C+1) j * g j) = + ∑ j ∈ Finset.range (C+1), pairU F p (C+1) (j+1) * g (j+1) := by + have hleft := Finset.sum_range_succ (fun j => pairU F p (C+1) j * g j) (C+1) + have hright := Finset.sum_range_succ' (fun j => pairU F p (C+1) j * g j) (C+1) + rw [hz (C+1) (Or.inr le_rfl), zero_mul, add_zero] at hleft + rw [hz 0 (Or.inl rfl), zero_mul, add_zero] at hright + exact hleft.symm.trans hright + change (∑ j ∈ Finset.range (C+1), + holeFunctional F (pairAssembly p (j:ℤ) ((C:ℤ)-j)) + (pairAssembly h (g j) (-g (j+1)))) = holeFunctional (balancedMarginal F C) p h + simp only [holeFunctional_branch, Finset.sum_sub_distrib, Finset.sum_add_distrib, + ht, add_sub_cancel_right, parent_balance_sum] + +end BalancedStep + +section Star +variable {ι : Type*} [Fintype ι] + + + +theorem weighted_star_bound (s h H : ι → ℝ) (hs : ∀ i, 0 ≤ s i) + (hbal : ∑ i, s i * h i = 0) (a : ℝ) : + (∑ i, s i * h i * H i)^2 ≤ + (∑ i, s i * h i^2) * (∑ i, s i * (H i-a)^2) := by + have he : (∑ i, s i * h i * (H i-a)) = ∑ i, s i * h i * H i := by + simp only [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul, hbal, zero_mul, + sub_zero] + rw [← he] + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul + · intro i _ + exact mul_nonneg (hs i) (sq_nonneg _) + · intro i _ + exact mul_nonneg (hs i) (sq_nonneg _) + · intro i _ + exact le_of_eq (by ring) + +end Star + +section WeightedKernel +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def raisedFull (f : (ι ⊕ Bool → ℤ) → ℝ) (C : ℕ) (p : ι → ℤ) : ℝ := + ∑ j ∈ Finset.range (C+2), (j:ℝ) * ((C:ℝ)+1-j) * + f (pairAssembly p (j:ℤ) ((C:ℤ)+1-j)) + +omit [Fintype ι] [DecidableEq ι] in +theorem raisedFull_eq (f : (ι ⊕ Bool → ℤ) → ℝ) (C : ℕ) : + raisedFull f C = raisedMarginal f C := by + funext p + rw [raisedFull, Finset.sum_range_succ, Finset.sum_range_succ'] + simp only [Nat.cast_add, Nat.cast_one, sub_self, mul_zero, + zero_mul, Nat.cast_zero, sub_zero, add_zero] + rw [raisedMarginal, ← Fin.sum_univ_eq_sum_range] + apply Finset.sum_congr rfl + intro j _ + have hj : j.val ≤ C := Nat.le_of_lt j.isLt + simp only [Nat.cast_add, Nat.cast_one, Nat.cast_sub hj] + congr 2 <;> ring_nf + +omit [DecidableEq ι] in +theorem raisedFull_positive (f : (ι ⊕ Bool → ℤ) → ℝ) (B : ι → ℤ) + (C : ℕ) (hC : 0 < C) (T : ℤ) + (hf : PositiveSlice f (pairAssembly B (C:ℤ) C) T) : + PositiveSlice (raisedFull f C) B (T-(C+1:ℕ)) := by + rw [raisedFull_eq] + exact raisedMarginal_positive f B C hC T hf + +theorem matrixForm_raisedFull (f : (ι ⊕ Bool → ℤ) → ℝ) (C : ℕ) (p : ι → ℤ) : + matrixForm (twoRemoval (raisedFull f C) p) = + ∑ j ∈ Finset.range (C+2), ((j:ℝ) * (C+1-j)) • pairQ f p (C+1) j := by + change matrixForm (fun i k => ∑ j ∈ Finset.range (C+2), + (j:ℝ) * ((C:ℝ)+1-j) * f (pairAssembly (removePair p i k) (j:ℤ) ((C:ℤ)+1-j))) = _ + rw [matrixForm_sum] + apply Finset.sum_congr rfl + intro j _ + ext h + simp only [matrixForm_apply, pairQ, twoRemoval, smul_apply, smul_eq_mul, + Nat.cast_add, Nat.cast_one, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro k _ + ring + +theorem matrixForm_twoRemoval_add (f g : (ι → ℤ) → ℝ) (p : ι → ℤ) (h : ι → ℝ) : + matrixForm (twoRemoval (fun x => f x + g x) p) h = + matrixForm (twoRemoval f p) h + matrixForm (twoRemoval g p) h := by + simp only [matrixForm_apply, twoRemoval, add_mul, Finset.sum_add_distrib] + +theorem matrixForm_zero (p : ι → ℤ) (h : ι → ℝ) : + matrixForm (twoRemoval (fun _ => 0) p) h = 0 := by + simp [matrixForm_apply, twoRemoval] + +omit [DecidableEq ι] in +theorem PositiveSlice.add {f g : (ι → ℤ) → ℝ} {B : ι → ℤ} {T : ℤ} + (hf : PositiveSlice f B T) (hg : PositiveSlice g B T) : + PositiveSlice (fun x => f x + g x) B T := by + constructor + · intro p hp ht + exact add_pos (hf.1 p hp ht) (hg.1 p hp ht) + · intro p hp + simp only [hf.2 p hp, hg.2 p hp, add_zero] + +end WeightedKernel + +end Contingency + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/Unpadding.lean b/lean/OAI/Probability/Contingency/Unpadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..b47963a271f181b8fcdae7911df50252a4203960 --- /dev/null +++ b/lean/OAI/Probability/Contingency/Unpadding.lean @@ -0,0 +1,666 @@ +import Mathlib +import OAI.Probability.Contingency.SmallPoincare + +namespace OAI + +/-! Unpadding. -/ + +noncomputable section + +open scoped BigOperators +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def cellPadding (w : Cell m n) : ℤ := if IsLarge U r c w then L else 0 + +def largePart (Z : Tables r c) (w : Cell m n) : ℤ := + if IsLarge U r c w then (Z.val w.1 w.2:ℤ)+L else 0 + +theorem split_padding (Z : Tables r c) (w : Cell m n) : + smallPart U r c Z w+largePart U L r c Z w=(Z.val w.1 w.2:ℤ)+cellPadding U L r c w := by + by_cases hw : IsLarge U r c w <;> simp [smallPart,largePart,cellPadding,IsSmall,hw] + +def paddedCompletion (Z : Tables r c) : Completion U L r c (initialTransversal U r c Z).val := by + refine ⟨largePart U L r c Z,?_,?_,?_,?_⟩ + · intro w; unfold largePart; split_ifs <;> positivity + · intro w hw; simp [largePart,show ¬IsLarge U r c w from hw] + · intro i + have hh : rowSum (smallPart U r c Z) i+rowSum (largePart U L r c Z) i= + (r i:ℤ)+rowPadding U L r c i := by + rw [rowSum,rowSum,← Finset.sum_add_distrib] + simp only [split_padding,Finset.sum_add_distrib] + congr 1 + exact_mod_cast Z.property.1 i + change rowSum (largePart U L r c Z) i=(r i:ℤ)-rowSum (smallPart U r c Z) i+rowPadding U L r c i + omega + · intro j + have hh : colSum (smallPart U r c Z) j+colSum (largePart U L r c Z) j= + (c j:ℤ)+colPadding U L r c j := by + rw [colSum,colSum,← Finset.sum_add_distrib] + simp only [split_padding,Finset.sum_add_distrib] + congr 1 + exact_mod_cast Z.property.2 j + change colSum (largePart U L r c Z) j=(c j:ℤ)-colSum (smallPart U r c Z) j+colPadding U L r c j + omega + +abbrev SuccessPair := Σ X : TransverseState U r c, + {A : Completion U L r c X.val // ∀ w,IsLarge U r c w → (L:ℤ)≤A.val w} + +theorem successPair_ext (P Q : SuccessPair U L r c) (hX : P.1=Q.1) + (hA : P.2.val.val=Q.2.val.val) : P=Q := by + cases P with | mk X A => + cases Q with | mk Y B => + dsimp only at hX + subst Y + congr 1 + exact Subtype.ext (Subtype.ext hA) + +def padOriginal (Z : Tables r c) : SuccessPair U L r c := + ⟨initialTransversal U r c Z,paddedCompletion U L r c Z,by + intro w hw; simp [paddedCompletion,largePart,hw]⟩ + +def unpadEntry (P : SuccessPair U L r c) (w : Cell m n) : ℤ := + P.1.val.x w+P.2.val.val w-cellPadding U L r c w + +theorem unpadEntry_nonneg (P : SuccessPair U L r c) (w : Cell m n) : + 0≤unpadEntry U L r c P w := by + by_cases hw : IsLarge U r c w + · have hx := (P.1.property.1.2.1 w hw).1 + have ha := P.2.property w hw + simp only [unpadEntry,cellPadding,ite_eq_left hw,hx,zero_add] + omega + · have hx := (P.1.property.1.1 w).1 + have ha := P.2.val.property.1 w + simp only [unpadEntry,cellPadding,ite_eq_right hw,sub_zero] + omega + +def unpadOriginal (P : SuccessPair U L r c) : Tables r c := by + refine ⟨fun i j => (unpadEntry U L r c P (i,j)).toNat,?_,?_⟩ + · intro i + apply Int.ofNat_inj.mp + simp only [Nat.cast_sum] + have hh (w : Cell m n) : ((unpadEntry U L r c P w).toNat:ℤ)=unpadEntry U L r c P w := Int.toNat_of_nonneg (unpadEntry_nonneg U L r c P w) + simp only [hh] + simp only [unpadEntry,Finset.sum_sub_distrib,Finset.sum_add_distrib] + change rowSum P.1.val.x i+rowSum P.2.val.val i-rowPadding U L r c i= r i + rw [P.2.val.property.2.2.1 i] + ring + · intro j + apply Int.ofNat_inj.mp + simp only [Nat.cast_sum] + have hh (w : Cell m n) : ((unpadEntry U L r c P w).toNat:ℤ)=unpadEntry U L r c P w := Int.toNat_of_nonneg (unpadEntry_nonneg U L r c P w) + simp only [hh] + simp only [unpadEntry,Finset.sum_sub_distrib,Finset.sum_add_distrib] + change colSum P.1.val.x j+colSum P.2.val.val j-colPadding U L r c j=c j + rw [P.2.val.property.2.2.2 j] + have ht : P.1.val.q=P.1.val.x := P.1.property.2 + rw [ht] + ring + +@[simp] theorem unpad_pad (Z : Tables r c) : unpadOriginal U L r c (padOriginal U L r c Z)=Z := by + apply Subtype.ext; funext i j + change (smallPart U r c Z (i,j)+largePart U L r c Z (i,j)-cellPadding U L r c (i,j)).toNat=Z.val i j + rw [split_padding,add_sub_cancel_right,Int.toNat_natCast] + +@[simp] theorem pad_unpad (P : SuccessPair U L r c) : padOriginal U L r c (unpadOriginal U L r c P)=P := by + have hv (w : Cell m n) : ((unpadOriginal U L r c P).val w.1 w.2:ℤ)=unpadEntry U L r c P w := + Int.toNat_of_nonneg (unpadEntry_nonneg U L r c P w) + have hs : smallPart U r c (unpadOriginal U L r c P)=P.1.val.x := by + funext w + by_cases hw : IsLarge U r c w + · simp [smallPart,IsSmall,hw,(P.1.property.1.2.1 w hw).1] + · simp only [smallPart,IsSmall,ite_eq_left hw,hv,unpadEntry,cellPadding,ite_eq_right hw,sub_zero, + P.2.val.property.2.1 w hw,add_zero] + have ha : largePart U L r c (unpadOriginal U L r c P)=P.2.val.val := by + funext w + by_cases hw : IsLarge U r c w + · simp [largePart,hw,hv,unpadEntry,cellPadding,(P.1.property.1.2.1 w hw).1] + · simp [largePart,hw,P.2.val.property.2.1 w hw] + have hx : initialTransversal U r c (unpadOriginal U L r c P)=P.1 := by + apply Subtype.ext + apply State.ext + · exact hs + · exact hs.trans P.1.property.2.symm + exact successPair_ext U L r c _ _ hx ha + + + +def successEquiv : Tables r c ≃ SuccessPair U L r c where + toFun := padOriginal U L r c + invFun := unpadOriginal U L r c + left_inv := unpad_pad U L r c + right_inv := pad_unpad U L r c + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency +noncomputable section +variable {m n : ℕ} (r : Fin m → ℕ) (c : Fin n → ℕ) (p : Fin m → Fin n → ℕ) + +def shiftedRow (i : Fin m) : ℕ := r i+∑ j,p i j +def shiftedCol (j : Fin n) : ℕ := c j+∑ i,p i j +abbrev ShiftPassing := {A : Tables (shiftedRow r p) (shiftedCol c p) // ∀ i j,p i j≤A.val i j} + +def shiftTable (Z : Tables r c) : ShiftPassing r c p := by + refine ⟨⟨fun i j => Z.val i j+p i j,?_,?_⟩,?_⟩ + · intro i; simp only [Finset.sum_add_distrib,Z.property.1,shiftedRow] + · intro j; simp only [Finset.sum_add_distrib,Z.property.2,shiftedCol] + · intro i j; dsimp; omega + +def unshiftTable (A : ShiftPassing r c p) : Tables r c := by + refine ⟨fun i j => A.val.val i j-p i j,?_,?_⟩ + · intro i + apply Nat.add_right_cancel (m:=∑ j,p i j) + calc + _ = ∑ j,(A.val.val i j-p i j+p i j) := by rw [Finset.sum_add_distrib] + _ = ∑ j,A.val.val i j := Finset.sum_congr rfl (fun j _ => Nat.sub_add_cancel (A.property i j)) + _ = r i+∑ j,p i j := A.val.property.1 i + · intro j + apply Nat.add_right_cancel (m:=∑ i,p i j) + calc + _ = ∑ i,(A.val.val i j-p i j+p i j) := by rw [Finset.sum_add_distrib] + _ = ∑ i,A.val.val i j := Finset.sum_congr rfl (fun i _ => Nat.sub_add_cancel (A.property i j)) + _ = c j+∑ i,p i j := A.val.property.2 j + +def shiftEquiv : Tables r c ≃ ShiftPassing r c p where + toFun := shiftTable r c p + invFun := unshiftTable r c p + left_inv Z := by apply Subtype.ext; funext i j; exact Nat.add_sub_cancel_right _ _ + right_inv A := by apply Subtype.ext; apply Subtype.ext; funext i j; exact Nat.sub_add_cancel (A.property i j) + +theorem shift_card : Nat.card (ShiftPassing r c p)=Nat.card (Tables r c) := + Nat.card_congr (shiftEquiv r c p).symm + +end +end Contingency + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (U L : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +def naturalPadding (i : Fin m) (j : Fin n) : ℕ := if IsLarge U r c (i,j) then L else 0 +abbrev Enlarged := Tables (shiftedRow r (naturalPadding U L r c)) (shiftedCol c (naturalPadding U L r c)) +abbrev EnlargedBad := {A : Enlarged U L r c // ¬∀ i j,naturalPadding U L r c i j≤A.val i j} +abbrev LargeCell := {w : Cell m n // IsLarge U r c w} + +theorem enlarged_partition : Nat.card (Tables r c)+Nat.card (EnlargedBad U L r c)=Nat.card (Enlarged U L r c) := by + classical + have hh := Nat.card_congr (Equiv.sumCompl (fun A : Enlarged U L r c => ∀ i j,naturalPadding U L r c i j≤A.val i j)) + rw [Nat.card_sum,shift_card] at hh + exact hh + +theorem enlarged_bad_union : Nat.card (EnlargedBad U L r c) ≤ + ∑ w : LargeCell U r c, Nat.card (SmallEntryBad + (shiftedRow r (naturalPadding U L r c)) (shiftedCol c (naturalPadding U L r c)) w.val.1 w.val.2 L) := by + classical + have hb (A : EnlargedBad U L r c) : ∃ w : LargeCell U r c,A.val.val w.val.1 w.val.2 ⟨(hb A).choose,⟨A.val,(hb A).choose_spec⟩⟩ + have hi : Function.Injective F := by + intro A B h + apply Subtype.ext + exact congrArg (fun z : Σ w : LargeCell U r c, SmallEntryBad + (shiftedRow r (naturalPadding U L r c)) (shiftedCol c (naturalPadding U L r c)) w.val.1 w.val.2 L => z.2.val) h + have hh := Nat.card_le_card_of_injective F hi + rwa [Nat.card_sigma] at hh + +theorem enlarged_bad_count (d : ℕ) (hd : 1≤d) (hm : m≤d) (hn : n≤d) (hmn : m*n≤d) + (hU : 4*d≤U) (hL : 2*L≤U) : + Nat.card (EnlargedBad U L r c)*U ≤ 4*L*d^4*Nat.card (Enlarged U L r c) := by + classical + have hdim : Fintype.card (LargeCell U r c)≤d := by + have hh := Fintype.card_subtype_le (fun w : Cell m n => IsLarge U r c w) + simpa [Cell] using hh.trans (by simpa [Cell] using hmn) + calc + _ ≤ (∑ w : LargeCell U r c,Nat.card (SmallEntryBad + (shiftedRow r (naturalPadding U L r c)) (shiftedCol c (naturalPadding U L r c)) w.val.1 w.val.2 L))*U := + Nat.mul_le_mul_right U (enlarged_bad_union U L r c) + _ ≤ ∑ _w : LargeCell U r c,4*L*d^3*Nat.card (Enlarged U L r c) := by + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro w _ + exact small_entry_count d U L _ _ w.val.1 w.val.2 hd hm hn hU + (w.property.1.trans (Nat.le_add_right _ _)) (w.property.2.trans (Nat.le_add_right _ _)) hL + _ ≤ d*(4*L*d^3*Nat.card (Enlarged U L r c)) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + exact Nat.mul_le_mul_right _ hdim + _ = _ := by ring + +abbrev TransverseJoint := Σ X : TransverseState U r c,Completion U L r c X.val + +def enlargedOfTransverse (P : TransverseJoint U L r c) : Enlarged U L r c := by + refine ⟨fun i j => (P.1.val.x (i,j)+P.2.val (i,j)).toNat,?_,?_⟩ + · intro i + apply Int.ofNat_inj.mp + simp only [Nat.cast_sum] + have hh (w : Cell m n) : ((P.1.val.x w+P.2.val w).toNat:ℤ)=P.1.val.x w+P.2.val w := + Int.toNat_of_nonneg (add_nonneg (P.1.property.1.1 w).1 (P.2.property.1 w)) + simp only [hh,Finset.sum_add_distrib] + change rowSum P.1.val.x i+rowSum P.2.val i=(shiftedRow r (naturalPadding U L r c) i:ℤ) + rw [P.2.property.2.2.1 i] + simp only [shiftedRow,Nat.cast_add,Nat.cast_sum,naturalPadding,Nat.cast_ite,Nat.cast_zero,rowPadding] + ring + · intro j + apply Int.ofNat_inj.mp + simp only [Nat.cast_sum] + have hh (w : Cell m n) : ((P.1.val.x w+P.2.val w).toNat:ℤ)=P.1.val.x w+P.2.val w := + Int.toNat_of_nonneg (add_nonneg (P.1.property.1.1 w).1 (P.2.property.1 w)) + simp only [hh,Finset.sum_add_distrib] + change colSum P.1.val.x j+colSum P.2.val j=(shiftedCol c (naturalPadding U L r c) j:ℤ) + rw [P.2.property.2.2.2 j,P.1.property.2] + simp only [shiftedCol,Nat.cast_add,Nat.cast_sum,naturalPadding,Nat.cast_ite,Nat.cast_zero,colPadding] + ring + +theorem enlargedOfTransverse_injective : Function.Injective (enlargedOfTransverse U L r c) := by + intro P Q h + have he (w : Cell m n) : P.1.val.x w+P.2.val w=Q.1.val.x w+Q.2.val w := by + have hh := congrArg (fun Z : Enlarged U L r c => Z.val w.1 w.2) h + change (P.1.val.x w+P.2.val w).toNat=(Q.1.val.x w+Q.2.val w).toNat at hh + have hp := add_nonneg (P.1.property.1.1 w).1 (P.2.property.1 w) + have hq := add_nonneg (Q.1.property.1.1 w).1 (Q.2.property.1 w) + omega + have hx : P.1.val.x=Q.1.val.x := by + funext w + by_cases hw : IsLarge U r c w + · rw [(P.1.property.1.2.1 w hw).1,(Q.1.property.1.2.1 w hw).1] + · have hh := he w + rw [P.2.property.2.1 w hw,Q.2.property.2.1 w hw] at hh + simpa using hh + have hX : P.1=Q.1 := by + apply Subtype.ext + apply State.ext hx + rw [P.1.property.2,Q.1.property.2,hx] + have hA : P.2.val=Q.2.val := by funext w; have hh := he w; have hw := congrFun hx w; omega + cases P with | mk X A => + cases Q with | mk Y B => + dsimp only at hX + subst Y + congr 1 + exact Subtype.ext hA + +theorem transverseMass_enlarged : transverseMass U L r c≤Nat.card (Enlarged U L r c) := by + have hh := Nat.card_le_card_of_injective _ (enlargedOfTransverse_injective U L r c) + rw [Nat.card_sigma] at hh + convert hh using 1 + unfold transverseMass + apply Finset.sum_congr rfl + intro X _ + rw [weight,ite_eq_left X.property.1] + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +variable {m n : ℕ} (d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + +theorem enlarged_half (hd : 14≤d) (hm : m≤d) (hn : n≤d) (hmn : m*n≤d) : + Nat.card (Enlarged (d^20) (d^12) r c)≤2*Nat.card (Tables r c) := by + have hd1 : 1≤d := by omega + have h19 : 4≤d^19 := (by norm_num : 4≤14^19).trans (Nat.pow_le_pow_left hd _) + have h8 : 2≤d^8 := (by norm_num : 2≤14^8).trans (Nat.pow_le_pow_left hd _) + have h4 : 8≤d^4 := (by norm_num : 8≤14^4).trans (Nat.pow_le_pow_left hd _) + have hU : 4*d≤d^20 := by nlinarith only [Nat.mul_le_mul_right d h19,show d^20=d^19*d by ring] + have hL : 2*d^12≤d^20 := by nlinarith only [Nat.mul_le_mul_left (d^12) h8,show d^20=d^12*d^8 by ring] + have hhalf : 2*(4*d^12*d^4)≤d^20 := by + nlinarith only [Nat.mul_le_mul_left (d^16) h4,show d^20=d^16*d^4 by ring,show d^12*d^4=d^16 by ring] + have hh := enlarged_bad_count (d^20) (d^12) r c d hd1 hm hn hmn hU hL + have hwhole := enlarged_partition (d^20) (d^12) r c + have hc' := Nat.mul_le_mul_right (Nat.card (Enlarged (d^20) (d^12) r c)) hhalf + have hb : 2*Nat.card (EnlargedBad (d^20) (d^12) r c)≤Nat.card (Enlarged (d^20) (d^12) r c) := by + by_contra h + have hpos : 0 exact if h : ∀ w,IsLarge U r c w → (L:ℤ)≤A.val w then some (unpadOriginal U L r c ⟨X,A,h⟩) else none + | ⟨Sum.inr _,_⟩ => exact none + +theorem decodeJoint_eq_some (P : Joint U L r c) (Z : Tables r c) : + decodeJoint r c U L P=some Z ↔ P=successfulJoint r c U L Z := by + classical + cases P with | mk X A => + cases X with + | inr X => + simp only [decodeJoint,reduceCtorEq,false_iff] + intro h + have hh := congrArg (fun s : Joint U L r c => s.1) h + change Sum.inr X=Sum.inl (initialTransversal U r c Z) at hh + cases hh + | inl X => + change (if h : ∀ w,IsLarge U r c w → (L:ℤ)≤A.val w then some (unpadOriginal U L r c ⟨X,A,h⟩) else none)=some Z ↔ _ + split_ifs with h + · rw [Option.some.injEq] + constructor + · intro he + have hh := congrArg (padOriginal U L r c) he + rw [pad_unpad] at hh + have hx := congrArg (fun s : SuccessPair U L r c => s.1) hh + have ha := congrArg (fun s : SuccessPair U L r c => s.2.val.val) hh + change X=initialTransversal U r c Z at hx + subst X + congr 1 + exact Subtype.ext ha + · intro he + have hx := congrArg (fun s : Joint U L r c => s.1) he + have hX : X=initialTransversal U r c Z := Sum.inl.inj hx + have hA := congrArg (fun s : Joint U L r c => s.2.val) he + have hh := successPair_ext U L r c ⟨X,A,h⟩ (padOriginal U L r c Z) hX hA + rw [hh,unpad_pad] + · simp only [false_iff] + intro he + have ha := congrArg (fun s : Joint U L r c => s.2.val) he + apply h + intro w hw + have hew := congrFun ha w + change A.val w=largePart U L r c Z w at hew + rw [hew] + simp [largePart,hw] + +variable [Nonempty (Tables r c)] +local instance unpaddingJointNonempty : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance + +def stationaryTrial : Law (Option (Tables r c)) := (Law.uniform (Joint U L r c)).map (decodeJoint r c U L) + +theorem stationaryTrial_some (Z : Tables r c) : + (stationaryTrial r c U L).mass (some Z)=1/(graphMass U L r c:ℝ) := by + classical + simp only [stationaryTrial,Law.map,Law.bind,Law.pure,mul_ite,mul_one,mul_zero,decodeJoint_eq_some] + simp only [Law.uniform,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rw [← Nat.card_eq_fintype_card,joint_card] + +theorem stationaryTrial_none : (stationaryTrial r c U L).mass none= + 1-(Nat.card (Tables r c):ℝ)/graphMass U L r c := by + have ht := (stationaryTrial r c U L).total + rw [Fintype.sum_option] at ht + simp only [stationaryTrial_some,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] at ht + rw [← Nat.card_eq_fintype_card] at ht + simp only [one_div,← div_eq_mul_inv] at ht + linarith + +theorem stationaryTrial_uniform (Z : Tables r c) : + (stationaryTrial r c U L).mass (some Z)= + (1-(stationaryTrial r c U L).mass none)*(Law.uniform (Tables r c)).mass Z := by + rw [stationaryTrial_some,stationaryTrial_none] + simp only [Law.uniform,sub_sub_cancel,← Nat.card_eq_fintype_card] + have hp : (Nat.card (Tables r c):ℝ)≠0 := by exact_mod_cast (Nat.card_pos (α:=Tables r c)).ne' + field_simp + +end +end Contingency.PaddedGraph + + + + + +open scoped BigOperators +namespace Contingency.PaddedGraph +noncomputable section +open FiniteChain +variable {m n a c' : ℕ} (U L d : ℕ) (r : Fin m → ℕ) (c : Fin n → ℕ) + (er : Fin a ≃ {i // U ≤ r i}) (ec : Fin c' ≃ {j // U ≤ c j}) (i₀ : Fin a) (j₀ : Fin c') + (hrc : (∑ i,r i)=∑ j,c j) (hd : 1 ≤ d) (hmn : m*n ≤ d) + [Nonempty (GraphState U r c)] + +local notation "Comp" => fun X : GraphState U r c => Completion U L r c (graphUnderlying U r c X) +local instance unpaddingInvariantCompFintype (X : GraphState U r c) : Fintype (Comp X) := Fintype.ofFinite _ +local instance unpaddingInvariantTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + +theorem invariant_joint : + letI := tables_nonempty r c hrc + letI : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance + ((smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.invariant).sigma + (idealCompletion U L r c hrc)=Law.uniform (Joint U L r c) := by + classical + let := tables_nonempty r c hrc + let : Nonempty (Joint U L r c) := Nonempty.map (successfulJoint r c U L) inferInstance + apply Law.ext; funext ⟨X,A⟩ + simp only [Law.sigma,Chain.invariant,AcceptedData.chain,smallData,idealCompletion,Law.uniform] + have htotal : (∑ X : GraphState U r c,(weight U L r c (graphUnderlying U r c X):ℝ))=(graphMass U L r c:ℝ) := by + simp [graphMass,Nat.cast_sum] + change (weight U L r c (graphUnderlying U r c X):ℝ)/ + (∑ X : GraphState U r c,(weight U L r c (graphUnderlying U r c X):ℝ)) * + (1/(Fintype.card (Comp X):ℝ)) = 1/(Fintype.card (Joint U L r c):ℝ) + rw [htotal,← Nat.card_eq_fintype_card,← Nat.card_eq_fintype_card,joint_card] + have he : weight U L r c (graphUnderlying U r c X)=Nat.card (Comp X) := by + rw [weight,ite_eq_left (graph_feasible U r c X)] + rw [← he] + have hp : (weight U L r c (graphUnderlying U r c X):ℝ)≠0 := by + exact_mod_cast (graph_weight_pos U L r c X hrc).ne' + field_simp + +def jointTrial (p : Law (GraphState U r c)) (μ : ∀ X,Law (Comp X)) : Law (Option (Tables r c)) := + (p.sigma μ).map (decodeJoint r c U L) + +theorem jointTrial_tv (p : Law (GraphState U r c)) (μ : ∀ X,Law (Comp X)) (δ : ℝ) + (hμ : ∀ X,(μ X).tv (idealCompletion U L r c hrc X) ≤ δ) : + letI := tables_nonempty r c hrc + (jointTrial U L r c p μ).tv (stationaryTrial r c U L) ≤ + p.tv (smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.invariant+δ := by + classical + let := tables_nonempty r c hrc + unfold jointTrial stationaryTrial + rw [← invariant_joint U L d r c er ec i₀ j₀ hrc hd hmn] + exact (Law.tv_map _ _ _).trans (Law.tv_sigma _ _ _ _ δ hμ) + +end +end Contingency.PaddedGraph + + + + + +namespace Contingency.Schedule + +theorem exp_neg_binary (x : ℝ) (N : ℕ) (hx : (N:ℝ)≤x) : + Real.exp (-x)≤(2:ℝ)^(-(N:ℤ)) := by + have hl : Real.log 2≤1 := by + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2) + linarith + have he : (2:ℝ)^(-(N:ℤ)) = Real.exp (-((N:ℝ)*Real.log 2)) := by + rw [Real.exp_neg, Real.exp_nat_mul, Real.exp_log (by norm_num : (0:ℝ)<2), zpow_neg, zpow_natCast] + rw [he] + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_left hl (Nat.cast_nonneg N : (0:ℝ)≤N)] + +variable (d b k : ℕ) (hd : 14≤d) (hb : d≤b) (hk : 1≤k) + +include hd hk in +theorem failure_schedule : Real.exp (-((Jo d k:ℝ)/(2*(1+(d:ℝ)^2))))≤(2:ℝ)^(-((k+2:ℕ):ℤ)) := by + apply exp_neg_binary + apply (le_div_iff₀ (by positivity : (0:ℝ)<2*(1+(d:ℝ)^2))).mpr + have hd2 : (4:ℝ)≤(d:ℝ)^2 := by exact_mod_cast (show 4≤d^2 from (by norm_num : 4≤14^2).trans (Nat.pow_le_pow_left hd _)) + have hk' : (1:ℝ)≤k := by exact_mod_cast hk + simp only [Jo,Nat.cast_mul,Nat.cast_pow,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat] + have he : (d:ℝ)^4=((d:ℝ)^2)^2 := by ring + nlinarith [mul_nonneg (show 0≤(d:ℝ)^2-4 by linarith) (show 0≤(d:ℝ)^2-1 by linarith)] + +theorem jo_binary : Jo d k≤2^(4*d+k) := by + calc + _ ≤ (2^d)^4*2^k := Nat.mul_le_mul (Nat.pow_le_pow_left (Nat.lt_two_pow_self (n:=d)).le 4) (Nat.lt_two_pow_self (n:=k)) + _ = _ := by rw [← pow_mul,← pow_add]; congr 1; omega + +theorem transition_binary : T d b k≤2^(200*d+2*(k+b)) := by + calc + _ ≤ (2^d)^200*(2^(k+b))^2 := Nat.mul_le_mul (Nat.pow_le_pow_left (Nat.lt_two_pow_self (n:=d)).le 200) (Nat.pow_le_pow_left (Nat.lt_two_pow_self (n:=k+b)).le 2) + _ = _ := by rw [← pow_mul,← pow_mul,← pow_add]; congr 1; omega + +include hd hb hk in +theorem offset_schedule : (Jo d k:ℝ)*(T d b k+1)*(2:ℝ)^(-(h d b k:ℤ))≤(2:ℝ)^(-((k+2:ℕ):ℤ)) := by + have hT : 1≤T d b k := by unfold T; exact Nat.one_le_iff_ne_zero.mpr (by positivity) + have hJ := jo_binary d k + have ht := transition_binary d b k + have he : Jo d k*(T d b k+1)*2^(k+2)≤2^(204*d+2*k+2*(k+b)+3) := by + calc + _ ≤ (2^(4*d+k))*(2*2^(200*d+2*(k+b)))*2^(k+2) := + Nat.mul_le_mul_right _ (Nat.mul_le_mul hJ (by omega)) + _ = _ := by rw [show 2*2^(200*d+2*(k+b))=2^(200*d+2*(k+b)+1) by rw [pow_succ]; omega,← pow_add,← pow_add]; congr 1; omega + have hd4 : 209≤d^4 := (by norm_num : 209≤14^4).trans (Nat.pow_le_pow_left hd _) + have hexp : 204*d+2*k+2*(k+b)+3≤h d b k := by + have ht1 : 1≤k+b := by omega + have htt : k+b≤(k+b)^2 := Nat.le_self_pow (by omega) _ + have hh := Nat.mul_le_mul hd4 htt + unfold h + nlinarith only [hh,hb,hk,hd] + have H := he.trans (Nat.pow_le_pow_right (by omega) hexp) + rw [zpow_neg,zpow_natCast,zpow_neg,zpow_natCast,← div_eq_mul_inv,inv_eq_one_div] + apply (div_le_div_iff₀ (by positivity) (by positivity)).mpr + simpa only [Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_pow,Nat.cast_ofNat,one_mul] using (show ((Jo d k*(T d b k+1)*2^(k+2):ℕ):ℝ)≤(2:ℝ)^(h d b k) by exact_mod_cast H) + +include hd hb hk in +theorem mixing_schedule (C : ℕ) (hC : C+1≤2^b) : + (Jo d k:ℝ)*(C+1:ℝ)^(2*d)*Real.exp (-((T d b k:ℝ)/(d:ℝ)^160))≤(2:ℝ)^(-((k+2:ℕ):ℤ)) := by + let E := 4*d+k+2*d*b + have hcoeff : Jo d k*(C+1)^(2*d)≤2^E := by + calc + _ ≤ 2^(4*d+k)*(2^b)^(2*d) := Nat.mul_le_mul (jo_binary d k) (Nat.pow_le_pow_left hC _) + _ = _ := by rw [← pow_mul,← pow_add]; congr 1; dsimp [E]; ring + have hdp : (0:ℝ) fun X : GraphState U r c => Completion U L r c (graphUnderlying U r c X) +local instance unpaddingTrialCompFintype (X : GraphState U r c) : Fintype (Comp X) := Fintype.ofFinite _ +local instance unpaddingTrialTablesFintype : Fintype (Tables r c) := Fintype.ofFinite _ + +def implementedTrial (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X₀ : GraphState U r c) (t : ℕ) : DyadicLaw (Option (Tables r c)) := by + classical + exact ((implementedWalk U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).sigma μ S hS).map (decodeJoint r c U L) + +theorem implementedTrial_bits (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X₀ : GraphState U r c) (t : ℕ) : + (implementedTrial U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).bits=t*(Nat.clog 2 (32*d^2)+S)+S := by + classical + simp only [implementedTrial,DyadicLaw.map_bits,DyadicLaw.sigma_bits,implementedWalk,DyadicLaw.walk_bits] + +theorem toLaw_implementedTrial (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (X₀ : GraphState U r c) (t : ℕ) : + (implementedTrial U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).toLaw= + jointTrial U L r c (implementedWalk U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).toLaw (fun X => (μ X).toLaw) := by + classical + simp only [implementedTrial,DyadicLaw.toLaw_map,DyadicLaw.toLaw_sigma,jointTrial] + +variable (hrc : (∑ i,r i)=∑ j,c j) [Nonempty (GraphState U r c)] + +theorem implementedTrial_tv (μ : ∀ X,DyadicLaw (Comp X)) (S : ℕ) (hS : ∀ X,(μ X).bits=S) + (δ : ℝ) (hμ : ∀ X,(μ X).toLaw.tv (idealCompletion U L r c hrc X)≤δ) + (X₀ : GraphState U r c) (t : ℕ) : + letI := tables_nonempty r c hrc + (implementedTrial U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).toLaw.tv (stationaryTrial r c U L)≤ + ((smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.walk X₀ t).tv + (smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.invariant+((t:ℝ)+1)*δ := by + classical + let := tables_nonempty r c hrc + rw [toLaw_implementedTrial] + have hj := jointTrial_tv U L d r c er ec i₀ j₀ hrc hd hmn (implementedWalk U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).toLaw (fun X => (μ X).toLaw) δ hμ + have hw := implementedWalk_tv U L d r c er ec i₀ j₀ hrc hd hmn μ S hS δ hμ X₀ t + have ht := Law.tv_triangle (implementedWalk U L d r c er ec i₀ j₀ hd hmn μ S hS X₀ t).toLaw + ((smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.walk X₀ t) + (smallData U L d r c er ec i₀ j₀ hrc hd hmn).chain.invariant + linarith + +end +end Contingency.PaddedGraph + +end + +end OAI diff --git a/lean/OAI/Probability/Contingency/WeightedSampler.lean b/lean/OAI/Probability/Contingency/WeightedSampler.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd1c48c92896eac61ccbe8c5897c65777304df64 --- /dev/null +++ b/lean/OAI/Probability/Contingency/WeightedSampler.lean @@ -0,0 +1,682 @@ +import Mathlib +import OAI.Probability.Contingency.AllMarginLaw + +namespace OAI + +/-! Weighted Sampler. -/ + +noncomputable section + + +namespace Contingency.BitModel.StackCode.WeightedSampler +noncomputable section + +def preg (i : Fin PreparedIntegerCall.program.work) : Fin 8 := ⟨i.val,by have := i.isLt; change i.val<6 at this; omega⟩ +abbrev first : Program := ⟨PreparedIntegerCall.program.labels,8,PreparedIntegerCall.program.start, + fun q => Registers.op preg (PreparedIntegerCall.program.code q)⟩ +def sreg : Fin 4→Fin 8 := ![5,4,6,7] +abbrev second : Program := ⟨WeightedScan.program.labels,8,WeightedScan.program.start, + fun q => Registers.op sreg (WeightedScan.program.code q)⟩ +def program : Program := Sequence.program first second.labels second.start second.code + +theorem preg_injective : Function.Injective preg := by + intro i j h + exact Fin.ext (congrArg (fun k : Fin 8 => k.val) h) +theorem sreg_injective : Function.Injective sreg := by + intro i j + fin_cases i <;> fin_cases j <;> decide + +theorem reverse_value (xs : List Bool) : BinarySubtract.value xs.reverse=BinaryTrial.beValue xs := by + refine List.reverseRecOn xs rfl ?_ + intro xs b ih + simp only [List.reverse_append,List.reverse_singleton,List.singleton_append,BinarySubtract.value, + IntegerDraw.beValue_snoc,ih] + omega + +theorem first_safe (N : ℕ) (rest a : List Bool) + (h : (a.foldl (fun c b => step first b c) (initial first (encodeNat N++rest))).state=none) : + ∃ u : Fin (N+1), + (a.foldl (fun c b => step first b c) (initial first (encodeNat N++rest))).memory.stack 5= + (IntegerDraw.integerWord N u).reverse ∧ + (a.foldl (fun c b => step first b c) (initial first (encodeNat N++rest))).memory.stack 6=[] ∧ + (a.foldl (fun c b => step first b c) (initial first (encodeNat N++rest))).memory.stack 7=[] ∧ + (a.foldl (fun c b => step first b c) (initial first (encodeNat N++rest))).memory.input=rest ∧ + (a.foldl (fun c b => step first b c) (initial first (encodeNat N++rest))).memory.outputRev=[] := by + have hr := Registers.fold_rel PreparedIntegerCall.program preg preg_injective a + (show Registers.ConfigRel PreparedIntegerCall.program preg + (initial PreparedIntegerCall.program (encodeNat N++rest)) (initial first (encodeNat N++rest)) from + ⟨rfl,(fun _ => rfl),rfl,rfl,rfl⟩) + obtain ⟨u,hu,hi,ho⟩ := PreparedIntegerCall.finite_memory_safe N rest a (hr.1.symm.trans h) + refine ⟨u,(hr.2.1 PreparedIntegerCall.outputRegister).trans hu,?_,?_,hr.2.2.1.trans hi,hr.2.2.2.1.trans ho⟩ + · exact Registers.fold_frame PreparedIntegerCall.program preg a (initial first (encodeNat N++rest)) 6 + (by intro i he; have hh := congrArg Fin.val he; have := i.isLt; change i.val<6 at this; simp [preg] at hh; omega) + · exact Registers.fold_frame PreparedIntegerCall.program preg a (initial first (encodeNat N++rest)) 7 + (by intro i he; have hh := congrArg Fin.val he; have := i.isLt; change i.val<6 at this; simp [preg] at hh; omega) + +def project (m : Memory 8) : Memory 4 := + ⟨m.input,m.consumed,fun i => m.stack (sreg i),fun i => m.blanks (sreg i),m.outputRev⟩ + + + +theorem select_run (N : ℕ) (ws : List (List Bool)) (u : Fin (N+1)) (m : Memory 8) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size) (htotal : WeightedScan.weightTotal ws=N+1) + (ha : m.stack 5=(IntegerDraw.integerWord N u).reverse) + (h6 : m.stack 6=[]) (h7 : m.stack 7=[]) + (hi : m.input=ws.flatten++rest) (ho : m.outputRev=[]) : + ∃ t j : ℕ,t*2≤10*(N.size+1)*ws.length ∧ j step second x c) ⟨some second.start,m⟩).state=none ∧ + (b.foldl (fun c x => step second x c) ⟨some second.start,m⟩).memory.outputRev=List.replicate j false := by + let as := (IntegerDraw.integerWord N u).reverse + have hv : BinarySubtract.value as=u.val := by simp [as,reverse_value] + have hl : as.length=N.size := by simp [as] + obtain ⟨j,m',hj,hs,hex,heout⟩ := WeightedScan.scan_run ws as (project m) rest 0 + (fun w hw => (hlen w hw).trans hl.symm) ha hi h6 h7 + (by rw [hv,htotal]; exact u.isLt) + let t := 3*as.length+2*0+3+j*(5*as.length+5) + refine ⟨t,j,?_,hj,?_,?_⟩ + · have hm := Nat.mul_le_mul_left (5*as.length+5) (Nat.succ_le_iff.mpr hj) + dsimp only [t] + rw [← hl] + nlinarith only [hm] + · simpa only [hv,Nat.zero_add] using hs + · intro b hb + have hcfg : Registers.ConfigRel WeightedScan.program sreg + (WeightedScan.config (.start false) (project m)) (⟨some second.start,m⟩ : Config second) := + ⟨rfl,(fun _ => rfl),rfl,rfl,rfl⟩ + have hr := Registers.fold_rel WeightedScan.program sreg sreg_injective b hcfg + have he : b.foldl (fun c x => step WeightedScan.program x c) + (WeightedScan.config (.start false) (project m))=⟨none,m'⟩ := by + rw [WeightedScan.fold_independent b (List.replicate t false) (by simpa using hb)] + exact hex + rw [he] at hr + refine ⟨hr.1,?_⟩ + exact hr.2.2.2.1.trans (by simpa [project,ho] using heout) + +end +end Contingency.BitModel.StackCode.WeightedSampler + + + + + + + +namespace Contingency.BitModel.StackCode.WeightedSampler +noncomputable section + + + +theorem after_first (N : ℕ) (ws : List (List Bool)) (rest a : List Bool) + (hlen : ∀ w∈ws,w.length=N.size) (htotal : WeightedScan.weightTotal ws=N+1) + (hfirst : Sequence.FirstHalt first (initial first (encodeNat N++(ws.flatten++rest))) a) : + ∃ (t j : ℕ) (u : Fin (N+1)),t≤5*(N.size+1)*ws.length ∧ j step first x c) (initial first (encodeNat N++(ws.flatten++rest)))).memory.stack 5= + (IntegerDraw.integerWord N u).reverse ∧ + ∀ b : List Bool,b.length=t → + ((a++b).foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).state=none ∧ + ((a++b).foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).memory.outputRev= + List.replicate j false := by + have hh := Sequence.firstHalt_result first _ a hfirst + obtain ⟨u,hu,h6,h7,hi,ho⟩ := first_safe N (ws.flatten++rest) a hh + obtain ⟨t,j,ht,hj,hs,hr⟩ := select_run N ws u _ rest hlen htotal hu h6 h7 hi ho + refine ⟨t,j,u,by nlinarith only [ht],hj,hs,hu,?_⟩ + intro b hb + have he := Sequence.link_run first second.labels second.start second.code + (initial first (encodeNat N++(ws.flatten++rest))) a b hfirst + change (a++b).foldl (fun c x => step program x c) + (initial program (encodeNat N++(ws.flatten++rest)))=_ at he + rw [he] + obtain ⟨hs,ho⟩ := hr b hb + constructor + · change Option.map (Fin.natAdd first.labels) _=none + have hs' : (b.foldl (fun c v => + step (Sequence.rightProgram first second.labels second.start second.code) v c) + ⟨some second.start,(a.foldl (fun c v => step first v c) + (initial first (encodeNat N++(ws.flatten++rest)))).memory⟩).state=none := hs + rw [hs'] + rfl + · exact ho + + + +theorem finishes_after (N : ℕ) (ws : List (List Bool)) (rest xs : List Bool) (s : ℕ) + (hlen : ∀ w∈ws,w.length=N.size) (htotal : WeightedScan.weightTotal ws=N+1) + (hl : s+5*(N.size+1)*ws.length≤xs.length) + (hh : ((xs.take s).foldl (fun c x => step first x c) + (initial first (encodeNat N++(ws.flatten++rest)))).state=none) : + (xs.foldl (fun c x => step program x c) + (initial program (encodeNat N++(ws.flatten++rest)))).state=none := by + obtain ⟨a,z,haz,hfirst,he⟩ := Sequence.first_prefix first _ (xs.take s) hh + obtain ⟨t,j,u,ht,hj,hscan,hu,hr⟩ := after_first N ws rest a hlen htotal hfirst + have ha : a.length ≤ s := by + have h₁ := congrArg List.length haz + have h₂ := List.length_take_le s xs + simp only [List.length_append] at h₁ + omega + have hpre : xs.take a.length=a := by + have h₁ := congrArg (List.take a.length) haz + simpa [List.take_take,Nat.min_eq_left ha] using h₁ + let b := (xs.drop a.length).take t + let c := (xs.drop a.length).drop t + have hb : b.length=t := by + simp only [b,List.length_take,List.length_drop] + exact Nat.min_eq_left (by omega) + have hdecomp : xs=(a++b)++c := by + rw [List.append_assoc] + change xs=a++((xs.drop a.length).take t++(xs.drop a.length).drop t) + rw [List.take_append_drop] + exact (List.take_append_drop a.length xs).symm.trans (congrArg (fun z => z++xs.drop a.length) hpre) + obtain ⟨hd,ho⟩ := hr b hb + rw [hdecomp,List.foldl_append] + rw [Sequence.halted_fold program _ hd c] + exact hd + +end +end Contingency.BitModel.StackCode.WeightedSampler + + + + + + + +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +open WeightedSampler +noncomputable section + +abbrev draw : Program := WeightedSampler.first +abbrev selector : Program := WeightedSampler.second + +theorem padded_select (N : ℕ) (ws : List (List Bool)) (u : Fin (N+1)) (m : Memory 8) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) + (ha : m.stack 5=(IntegerDraw.integerWord N u).reverse++[false]) + (h6 : m.stack 6=[]) (h7 : m.stack 7=[]) + (hi : m.input=ws.flatten++rest) (ho : m.outputRev=[]) : + ∃ t j : ℕ,t*2≤10*(N.size+2)*ws.length ∧ j step selector x c) ⟨some selector.start,m⟩).state=none ∧ + (b.foldl (fun c x => step selector x c) ⟨some selector.start,m⟩).memory.outputRev=List.replicate j false := by + let as := (IntegerDraw.integerWord N u).reverse++[false] + have hv : BinarySubtract.value as=u.val := by + simpa only [as,← List.replicate_one] using (BinarySubtract.value_append_false (IntegerDraw.integerWord N u).reverse 1).trans (by simp [WeightedSampler.reverse_value]) + have hl : as.length=N.size+1 := by simp [as] + obtain ⟨j,m',hj,hs,hex,heout⟩ := WeightedScan.scan_run ws as (project m) rest 0 + (fun w hw => (hlen w hw).trans hl.symm) ha hi h6 h7 + (by rw [hv,htotal]; exact u.isLt) + let t := 3*as.length+2*0+3+j*(5*as.length+5) + refine ⟨t,j,?_,hj,?_,?_⟩ + · have hm := Nat.mul_le_mul_left (5*as.length+5) (Nat.succ_le_iff.mpr hj) + dsimp only [t] + have he : N.size+2=as.length+1 := by omega + rw [he] + nlinarith only [hm] + · simpa only [hv,Nat.zero_add] using hs + · intro b hb + have hcfg : Registers.ConfigRel WeightedScan.program sreg + (WeightedScan.config (.start false) (project m)) (⟨some selector.start,m⟩ : Config selector) := + ⟨rfl,(fun _ => rfl),rfl,rfl,rfl⟩ + have hr := Registers.fold_rel WeightedScan.program sreg sreg_injective b hcfg + have he : b.foldl (fun c x => step WeightedScan.program x c) + (WeightedScan.config (.start false) (project m))=⟨none,m'⟩ := by + rw [WeightedScan.fold_independent b (List.replicate t false) (by simpa using hb)] + exact hex + rw [he] at hr + refine ⟨hr.1,?_⟩ + exact hr.2.2.2.1.trans (by simpa [project,ho] using heout) + +abbrev post : Program := Sequence.program HighPad.program selector.labels selector.start selector.code +def program : Program := Sequence.program draw post.labels post.start post.code + +theorem post_run (N : ℕ) (ws : List (List Bool)) (u : Fin (N+1)) (m : Memory 8) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) + (ha : m.stack 5=(IntegerDraw.integerWord N u).reverse) + (h6 : m.stack 6=[]) (h7 : m.stack 7=[]) + (hi : m.input=ws.flatten++rest) (ho : m.outputRev=[]) : + ∃ t j : ℕ,t≤4*N.size+8+5*(N.size+2)*ws.length ∧ j step post x c) ⟨some post.start,m⟩).state=none ∧ + (b.foldl (fun c x => step post x c) ⟨some post.start,m⟩).memory.outputRev=List.replicate j false := by + obtain ⟨T,m',hT,h5',h6',hframe,hi',ho',hr⟩ := HighPad.pad (IntegerDraw.integerWord N u).reverse m ha h6 + have hpad := hr (List.replicate T false) (by simp) + obtain ⟨k,hk,hfirst⟩ := Sequence.deterministic_first_time HighPad.program + (noCoin_deterministic _ HighPad.noCoin) ⟨some HighPad.program.start,m⟩ T + (by rw [hpad]) + obtain ⟨s,j,hs,hj,hscan,hsel⟩ := padded_select N ws u m' rest hlen htotal h5' h6' + ((hframe 7 (by decide) (by decide)).trans h7) (hi'.trans hi) (ho'.trans ho) + refine ⟨k+s,j,?_,hj,hscan,?_⟩ + · simp only [List.length_reverse,IntegerDraw.integerWord_length] at hT + nlinarith only [hk,hT,hs] + · intro b hb + let a := b.take k + let c := b.drop k + have ha' : a.length=k := by simp only [a,List.length_take,hb]; omega + have hc : c.length=s := by simp [c,hb] + have hf := hfirst a ha' + have hf' := hf.2.trans hpad + have he := Sequence.link_run HighPad.program selector.labels selector.start selector.code + ⟨some HighPad.program.start,m⟩ a c hf.1 + rw [hf'] at he + have hbc : a++c=b := List.take_append_drop k b + rw [hbc] at he + obtain ⟨hd,hout⟩ := hsel c hc + have hresult : (c.foldl (fun cfg x => step (Sequence.rightProgram HighPad.program selector.labels selector.start selector.code) x cfg) + ⟨some selector.start,m'⟩).state=none := hd + change b.foldl (fun cfg x => step post x cfg) ⟨some post.start,m⟩=_ at he + rw [he] + constructor + · change Option.map (Fin.natAdd HighPad.program.labels) _=none + rw [hresult]; rfl + · exact hout + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + + + + + + + +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +open WeightedSampler +noncomputable section + + + +theorem after_first (N : ℕ) (ws : List (List Bool)) (rest a : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) + (hfirst : Sequence.FirstHalt draw (initial draw (encodeNat N++(ws.flatten++rest))) a) : + ∃ (t j : ℕ) (u : Fin (N+1)),t≤(4*N.size+8+5*(N.size+2)*ws.length) ∧ j step draw x c) (initial draw (encodeNat N++(ws.flatten++rest)))).memory.stack 5= + (IntegerDraw.integerWord N u).reverse ∧ + ∀ b : List Bool,b.length=t → + ((a++b).foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).state=none ∧ + ((a++b).foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).memory.outputRev= + List.replicate j false := by + have hh := Sequence.firstHalt_result draw _ a hfirst + obtain ⟨u,hu,h6,h7,hi,ho⟩ := first_safe N (ws.flatten++rest) a hh + obtain ⟨t,j,ht,hj,hs,hr⟩ := post_run N ws u _ rest hlen htotal hu h6 h7 hi ho + refine ⟨t,j,u,ht,hj,hs,hu,?_⟩ + intro b hb + have he := Sequence.link_run draw post.labels post.start post.code + (initial draw (encodeNat N++(ws.flatten++rest))) a b hfirst + change (a++b).foldl (fun c x => step program x c) + (initial program (encodeNat N++(ws.flatten++rest)))=_ at he + rw [he] + obtain ⟨hs,ho⟩ := hr b hb + constructor + · change Option.map (Fin.natAdd draw.labels) _=none + have hs' : (b.foldl (fun c v => + step (Sequence.rightProgram draw post.labels post.start post.code) v c) + ⟨some post.start,(a.foldl (fun c v => step draw v c) + (initial draw (encodeNat N++(ws.flatten++rest)))).memory⟩).state=none := hs + rw [hs'] + rfl + · exact ho + + + +theorem finishes_after (N : ℕ) (ws : List (List Bool)) (rest xs : List Bool) (s : ℕ) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) + (hl : s+(4*N.size+8+5*(N.size+2)*ws.length)≤xs.length) + (hh : ((xs.take s).foldl (fun c x => step draw x c) + (initial draw (encodeNat N++(ws.flatten++rest)))).state=none) : + (xs.foldl (fun c x => step program x c) + (initial program (encodeNat N++(ws.flatten++rest)))).state=none := by + obtain ⟨a,z,haz,hfirst,he⟩ := Sequence.first_prefix draw _ (xs.take s) hh + obtain ⟨t,j,u,ht,hj,hscan,hu,hr⟩ := after_first N ws rest a hlen htotal hfirst + have ha : a.length ≤ s := by + have h₁ := congrArg List.length haz + have h₂ := List.length_take_le s xs + simp only [List.length_append] at h₁ + omega + have hpre : xs.take a.length=a := by + have h₁ := congrArg (List.take a.length) haz + simpa [List.take_take,Nat.min_eq_left ha] using h₁ + let b := (xs.drop a.length).take t + let c := (xs.drop a.length).drop t + have hb : b.length=t := by + simp only [b,List.length_take,List.length_drop] + exact Nat.min_eq_left (by omega) + have hdecomp : xs=(a++b)++c := by + rw [List.append_assoc] + change xs=a++((xs.drop a.length).take t++(xs.drop a.length).drop t) + rw [List.take_append_drop] + exact (List.take_append_drop a.length xs).symm.trans (congrArg (fun z => z++xs.drop a.length) hpre) + obtain ⟨hd,ho⟩ := hr b hb + rw [hdecomp,List.foldl_append] + rw [Sequence.halted_fold program _ hd c] + exact hd + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.WeightedSampler +noncomputable section + +def storedMass (N : ℕ) (rest : List Bool) (u : Fin (N+1)) (s : ℕ) : ℝ := + ((Finset.univ.filter fun f : Fin s→Bool => (run first (encodeNat N++rest) f).state=none ∧ + (run first (encodeNat N++rest) f).memory.stack 5=(IntegerDraw.integerWord N u).reverse).card:ℝ)/2^s + +theorem stored_refinement (N : ℕ) (rest : List Bool) : + ∃ t≤9*N.size+6,∀ (s : ℕ) (f : Fin (t+s)→Bool), + ((run first (encodeNat N++rest) f).state=none ↔ + (run IntegerDraw.program (IntegerDraw.rawMaximum N) (fun i => f (Fin.natAdd t i))).state=none) ∧ + (run first (encodeNat N++rest) f).memory.stack 5= + (run IntegerDraw.program (IntegerDraw.rawMaximum N) (fun i => f (Fin.natAdd t i))).memory.outputRev := by + obtain ⟨t,ht,hr⟩ := PreparedIntegerCall.refinement N rest + refine ⟨t,ht,?_⟩ + intro s f + let a := List.ofFn fun i : Fin t => f (i.castAdd s) + let b := List.ofFn fun i : Fin s => f (Fin.natAdd t i) + obtain ⟨c,hc,hm,hi,ho⟩ := hr a (by simp [a]) b + have he : a++b=List.ofFn f := by + dsimp only [a,b] + rw [List.ofFn_add] + congr 2 + rw [he] at hc + have hg := Registers.fold_rel PreparedIntegerCall.program preg preg_injective (List.ofFn f) + (show Registers.ConfigRel PreparedIntegerCall.program preg + (initial PreparedIntegerCall.program (encodeNat N++rest)) (initial first (encodeNat N++rest)) from + ⟨rfl,(fun _ => rfl),rfl,rfl,rfl⟩) + rw [hc] at hg + constructor + · have hgs : (run first (encodeNat N++rest) f).state=Option.map (Fin.natAdd PrepareMaximum.program.labels) c.state := hg.1 + constructor + · intro hh + have hz : c.state=none := Option.map_eq_none_iff.mp (hgs.symm.trans hh) + exact hm.1.symm.trans hz + · intro hh + have hz : c.state=none := hm.1.trans hh + exact hgs.trans (Option.map_eq_none_iff.mpr hz) + · exact (hg.2.1 PreparedIntegerCall.outputRegister).trans hm.2.2.2 + +theorem stored_shifted (N : ℕ) (rest : List Bool) : + ∃ t≤9*N.size+6,∀ s : ℕ, + (∀ u : Fin (N+1),storedMass N rest u (t+s)= + mass IntegerDraw.program (IntegerDraw.rawMaximum N) (IntegerDraw.integerWord N u) s) ∧ + tail first (encodeNat N++rest) (t+s)=tail IntegerDraw.program (IntegerDraw.rawMaximum N) s := by + classical + obtain ⟨t,ht,hr⟩ := stored_refinement N rest + have hi : ∀ s,Function.Injective (Fin.natAdd t : Fin s→Fin (t+s)) := by + intro s i j h; simpa using h + refine ⟨t,ht,?_⟩ + intro s + constructor + · intro u + unfold storedMass mass + have hre (x : List Bool) : (x=(IntegerDraw.integerWord N u).reverse) ↔ x.reverse=IntegerDraw.integerWord N u := by + constructor + · intro h; simp only [h,List.reverse_reverse] + · intro h; simpa only [List.reverse_reverse] using congrArg List.reverse h + simp only [(hr s _).1,(hr s _).2,hre] + simpa only [Fintype.card_fin,Function.comp_def] using CoordinateLaw.probability_restrict (Fin.natAdd t) (hi s) + (fun f => (run IntegerDraw.program (IntegerDraw.rawMaximum N) f).state=none ∧ + (run IntegerDraw.program (IntegerDraw.rawMaximum N) f).memory.outputRev.reverse=IntegerDraw.integerWord N u) + · unfold tail + simp only [ne_eq,(hr s _).1] + simpa only [Fintype.card_fin,Function.comp_def] using CoordinateLaw.probability_restrict (Fin.natAdd t) (hi s) + (fun f => (run IntegerDraw.program (IntegerDraw.rawMaximum N) f).state≠none) + +theorem stored_summable (N : ℕ) (rest : List Bool) : Summable (tail first (encodeNat N++rest)) := by + obtain ⟨t,ht,hl⟩ := stored_shifted N rest + apply (summable_nat_add_iff t).1 + simpa only [Nat.add_comm,(hl _).2] using IntegerDraw.stack_summable (IntegerDraw.rawMaximum N) + +theorem stored_uniform (N : ℕ) (rest : List Bool) (u : Fin (N+1)) : + Tendsto (storedMass N rest u) atTop (nhds (1/(N+1:ℝ))) := by + obtain ⟨t,ht,hl⟩ := stored_shifted N rest + apply (tendsto_add_atTop_iff_nat t).1 + simpa only [Nat.add_comm,(hl _).1,IntegerDraw.rawMaximum_value,IntegerDraw.integerWord] using + IntegerDraw.stack_uniform (IntegerDraw.rawMaximum N) ⟨u,by simpa using u.isLt⟩ + +theorem stored_expected (N : ℕ) (rest : List Bool) : + (∑' s,tail first (encodeNat N++rest) s)≤35*(N.size:ℝ)+21 := by + obtain ⟨t,ht,hl⟩ := stored_shifted N rest + have hs := stored_summable N rest + rw [← hs.sum_add_tsum_nat_add t] + have hb : (∑ s∈Finset.range t,tail first (encodeNat N++rest) s)≤(t:ℝ) := by + calc + _ ≤ ∑ s∈Finset.range t,(1:ℝ) := by + exact Finset.sum_le_sum fun _ _ => IntegerDraw.tail_le_one _ _ _ + _ = _ := by simp + have he : (∑' s,tail first (encodeNat N++rest) (s+t))= + ∑' s,tail IntegerDraw.program (IntegerDraw.rawMaximum N) s := by + congr 1 + funext s + simpa only [Nat.add_comm] using (hl s).2 + rw [he] + have hw : 2^(IntegerDraw.rawMaximum N).length≤ + 2*(BinaryTrial.beValue (IntegerDraw.rawMaximum N)+1) := by + simpa using IntegerDraw.minimal_width N + have hi := IntegerDraw.stack_linear_expected (IntegerDraw.rawMaximum N) hw + simp only [IntegerDraw.rawMaximum_length] at hi + have ht' : (t:ℝ)≤9*(N.size:ℝ)+6 := by exact_mod_cast ht + push_cast at hi + linarith + +end +end Contingency.BitModel.StackCode.WeightedSampler + + + + + + + +open scoped BigOperators +open Filter +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +noncomputable section + +def delay (N : ℕ) (ws : List (List Bool)) : ℕ := 4*N.size+8+5*(N.size+2)*ws.length + +theorem tail_delay (N : ℕ) (ws : List (List Bool)) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) (s : ℕ) : + tail program (encodeNat N++(ws.flatten++rest)) (s+delay N ws) ≤ + tail draw (encodeNat N++(ws.flatten++rest)) s := by + classical + let e : Fin s→Fin (s+delay N ws) := Fin.castAdd (delay N ws) + have hi : Function.Injective e := by + intro i j h; exact Fin.ext (congrArg (fun k : Fin (s+delay N ws) => k.val) h) + let p : (Fin s→Bool)→Prop := fun f => (run draw (encodeNat N++(ws.flatten++rest)) f).state≠none + have he := CoordinateLaw.probability_restrict e hi p + simp only [Fintype.card_fin] at he + unfold tail + change _≤((Finset.univ.filter p).card:ℝ)/2^s + rw [← he] + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast Finset.card_le_card (show + (Finset.univ.filter fun f : Fin (s+delay N ws)→Bool => (run program (encodeNat N++(ws.flatten++rest)) f).state≠none) ⊆ + (Finset.univ.filter fun f : Fin (s+delay N ws)→Bool => p (f∘e)) from by + intro f hf + simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hf ⊢ + intro hn + apply hf + have ht : (List.ofFn f).take s=List.ofFn (f∘e) := by + rw [List.ofFn_add] + simp only [List.take_append,List.length_ofFn,Nat.sub_self,List.take_zero,List.append_nil] + rw [List.take_of_length_le (by simp)] + congr 2 + exact finishes_after N ws rest (List.ofFn f) s hlen htotal (by rw [List.length_ofFn]; exact le_refl _) (by + rw [ht] + exact hn)) + +theorem stack_summable (N : ℕ) (ws : List (List Bool)) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + Summable (tail program (encodeNat N++(ws.flatten++rest))) := by + apply (summable_nat_add_iff (delay N ws)).1 + exact (WeightedSampler.stored_summable N (ws.flatten++rest)).of_nonneg_of_le + (fun _ => IntegerDraw.tail_nonneg _ _ _) (fun s => tail_delay N ws rest hlen htotal s) + +theorem stack_expected (N : ℕ) (ws : List (List Bool)) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + (∑' s,tail program (encodeNat N++(ws.flatten++rest)) s)≤ + 35*(N.size:ℝ)+21+delay N ws := by + have hp := stack_summable N ws rest hlen htotal + rw [← hp.sum_add_tsum_nat_add (delay N ws)] + have hb : (∑ s∈Finset.range (delay N ws),tail program (encodeNat N++(ws.flatten++rest)) s)≤(delay N ws:ℝ) := by + calc + _ ≤ ∑ s∈Finset.range (delay N ws),(1:ℝ) := Finset.sum_le_sum fun _ _ => IntegerDraw.tail_le_one _ _ _ + _ = _ := by simp + have hs := WeightedSampler.stored_summable N (ws.flatten++rest) + have he : (∑' s,tail program (encodeNat N++(ws.flatten++rest)) (s+delay N ws)) ≤ + ∑' s,tail draw (encodeNat N++(ws.flatten++rest)) s := by + exact ((summable_nat_add_iff _).2 hp).tsum_le_tsum + (fun s => tail_delay N ws rest hlen htotal s) hs + have hw := WeightedSampler.stored_expected N (ws.flatten++rest) + linarith + +def machine : Machine := compile program + + + +theorem charged_time (N : ℕ) (ws : List (List Bool)) (rest : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) : + Summable (machine.tail (encodeNat N++(ws.flatten++rest))) ∧ + Tendsto (machine.tail (encodeNat N++(ws.flatten++rest))) atTop (nhds 0) ∧ + (∑' s,machine.tail (encodeNat N++(ws.flatten++rest)) s)≤ + 70*(N.size:ℝ)+42+2*delay N ws := by + have hs := stack_summable N ws rest hlen htotal + have hc := tail_summable_compile program _ hs + refine ⟨hc,hc.tendsto_atTop_zero,?_⟩ + change (∑' s,(compile program).tail _ s)≤_ + rw [expected_compile program _ hs] + have he := stack_expected N ws rest hlen htotal + linarith + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + + + + + +namespace Contingency.BitModel.StackCode.PaddedWeightedSampler +noncomputable section + + +theorem live_fold (P : Program) (q : ℕ) (start : Fin q) (code : Fin q→Op q P.work) + (cfg : Config P) (xs : List Bool) + (h : (xs.foldl (fun c b => step P b c) cfg).state≠none) : + xs.foldl (fun c b => step (Sequence.program P q start code) b c) (Sequence.left P q start code cfg)= + Sequence.left P q start code (xs.foldl (fun c b => step P b c) cfg) := by + induction xs generalizing cfg with + | nil => rfl + | cons a xs ih => + have hc : cfg.state≠none := by + intro hn + have hz := Sequence.halted_fold P cfg hn (a::xs) + exact h (by rw [hz]; exact hn) + simp only [List.foldl_cons] + rw [Sequence.step_left P q start code cfg a hc] + exact ih _ h + + +theorem live_left (cfg : Config draw) (xs : List Bool) + (h : (xs.foldl (fun c b => step draw b c) cfg).state≠none) : + xs.foldl (fun c b => step program b c) (Sequence.left draw post.labels post.start post.code cfg)= + Sequence.left draw post.labels post.start post.code (xs.foldl (fun c b => step draw b c) cfg) := + live_fold draw post.labels post.start post.code cfg xs h + +theorem first_returned (xs : List Bool) (input : List Bool) + (h : (xs.foldl (fun c b => step program b c) (initial program input)).state=none) : + (xs.foldl (fun c b => step draw b c) (initial draw input)).state=none := by + by_contra hn + have he := live_left (initial draw input) xs hn + change xs.foldl (fun c b => step program b c) (initial program input)=_ at he + rw [he] at h + change Sequence.next (Fin.castAdd post.labels) (some (Fin.natAdd draw.labels post.start)) _=none at h + cases hc : (xs.foldl (fun c b => step draw b c) (initial draw input)).state <;> simp [Sequence.next,hc] at h + +theorem word_injective (N : ℕ) : Function.Injective (fun u : Fin (N+1) => (IntegerDraw.integerWord N u).reverse) := by + intro u v h + apply Fin.ext + have hh := congrArg (fun xs => BinaryTrial.beValue xs.reverse) h + simpa using hh + + + +theorem completes (N : ℕ) (ws : List (List Bool)) (rest xs : List Bool) (s j : ℕ) (u : Fin (N+1)) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) + (hl : s+delay N ws≤xs.length) + (hh : ((xs.take s).foldl (fun c x => step draw x c) (initial draw (encodeNat N++(ws.flatten++rest)))).state=none) + (hu : ((xs.take s).foldl (fun c x => step draw x c) (initial draw (encodeNat N++(ws.flatten++rest)))).memory.stack 5= + (IntegerDraw.integerWord N u).reverse) + (hscan : Contingency.IntegerDraw.scan (WeightedScan.indexedWeights ws 0) u.val=some j) : + (xs.foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).state=none ∧ + (xs.foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).memory.outputRev=List.replicate j false := by + obtain ⟨a,z,haz,hfirst,he⟩ := Sequence.first_prefix draw _ (xs.take s) hh + obtain ⟨t,k,v,ht,hk,hscanf,hv,hr⟩ := after_first N ws rest a hlen htotal hfirst + have he' := congrArg (fun c : Config draw => c.memory.stack 5) he + have hvu : v=u := word_injective N (hv.symm.trans (he'.trans hu)) + subst v + have hkj : k=j := Option.some.inj (hscanf.symm.trans hscan) + subst k + have ha : a.length ≤ s := by + have h₁ := congrArg List.length haz + have h₂ := List.length_take_le s xs + simp only [List.length_append] at h₁ + omega + have hpre : xs.take a.length=a := by + have h₁ := congrArg (List.take a.length) haz + simpa [List.take_take,Nat.min_eq_left ha] using h₁ + let b := (xs.drop a.length).take t + let c := (xs.drop a.length).drop t + have hb : b.length=t := by + simp only [b,List.length_take,List.length_drop] + dsimp only [delay] at hl + exact Nat.min_eq_left (by omega) + have hdecomp : xs=(a++b)++c := by + rw [List.append_assoc] + change xs=a++((xs.drop a.length).take t++(xs.drop a.length).drop t) + rw [List.take_append_drop] + exact (List.take_append_drop a.length xs).symm.trans (congrArg (fun z => z++xs.drop a.length) hpre) + obtain ⟨hd,ho⟩ := hr b hb + rw [hdecomp,List.foldl_append,Sequence.halted_fold program _ hd c] + exact ⟨hd,ho⟩ + + + +theorem halted_output (N : ℕ) (ws : List (List Bool)) (rest xs : List Bool) + (hlen : ∀ w∈ws,w.length=N.size+1) (htotal : WeightedScan.weightTotal ws=N+1) + (hh : (xs.foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).state=none) : + ∃ (j : ℕ) (u : Fin (N+1)),j step draw x c) (initial draw (encodeNat N++(ws.flatten++rest)))).memory.stack 5= + (IntegerDraw.integerWord N u).reverse ∧ + (xs.foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))).memory.outputRev=List.replicate j false := by + have hf := first_returned xs _ hh + obtain ⟨a,z,haz,hfirst,he⟩ := Sequence.first_prefix draw _ xs hf + obtain ⟨t,j,u,ht,hj,hscan,hu,hr⟩ := after_first N ws rest a hlen htotal hfirst + have heu := (congrArg (fun c : Config draw => c.memory.stack 5) he).symm.trans hu + let ys := xs++List.replicate (delay N ws) false + have htake : ys.take xs.length=xs := by simp [ys] + have hc := completes N ws rest ys xs.length j u hlen htotal (by simp [ys]) + (by rw [htake]; exact hf) (by rw [htake]; exact heu) hscan + have hp : ys.foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest)))= + xs.foldl (fun c x => step program x c) (initial program (encodeNat N++(ws.flatten++rest))) := by + dsimp only [ys] + rw [List.foldl_append,Sequence.halted_fold program _ hh] + exact ⟨j,u,hj,hscan,heu,by rw [← hp]; exact hc.2⟩ + +end +end Contingency.BitModel.StackCode.PaddedWeightedSampler + +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ActiveLimits.lean b/lean/OAI/Probability/ContinuumTransition/ActiveLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..b12cf17cf37581720a4a72520fb9879129932cbb --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ActiveLimits.lean @@ -0,0 +1,72 @@ +import OAI.Probability.ContinuumTransition.ConvolutionLimit + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +lemma active_subseq_of_density_bound {Q : ℕ → Parameter → ℝ} {q : Parameter → ℝ} + {P : ℕ → Parameter → ℝ} {p : Parameter → ℝ} {a : ℕ → ℝ} {a₀ : ℝ} + (hQ : TendstoLocallyUniformlyOn Q q atTop pressureDomain) + (hconv : ∀ n, ConvexOn ℝ pressureDomain (Q n)) (hq : ContinuousOn q pressureDomain) + (ha : Tendsto a atTop (𝓝 a₀)) (hP : ∀ n, IsMeanField (Q n) (a n) (P n)) + (hp : IsMeanField q a₀ p) {X W : ℕ → Parameter} {x : Parameter} + (hx : x ∈ pressureDomain) (hX : Tendsto X atTop (𝓝 x)) (hXS : ∀ n, X n ∈ pressureDomain) + (hA : ∀ n, W n ∈ activeLifts (Q n) (a n) (P n) (X n)) + {D : ℝ} (hD : ∀ n, (W n).2 ∈ Icc 0 D) : + ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∃ w ∈ activeLifts q a₀ p x, + Tendsto (W ∘ φ) atTop (𝓝 w) := by + obtain ⟨d,_,φ,hφ,hd⟩ := (isCompact_Icc : IsCompact (Icc (0:ℝ) D)).tendsto_subseq hD + let V : ℕ → Parameter := fun n => unlift (a (φ n)) (W (φ n)) + let Y : ℕ → Parameter := fun n => shiftedField (a (φ n)) (X (φ n)) (W (φ n)).2 + let y := shiftedField a₀ x d + have hy : y ∈ pressureDomain := hx + have hXφ := hX.comp hφ.tendsto_atTop + have haφ := ha.comp hφ.tendsto_atTop + have hY : Tendsto Y atTop (𝓝 y) := by + have hh := ((continuous_fst.tendsto x).comp hXφ).prodMk_nhds + (((continuous_snd.tendsto x).comp hXφ).add + ((((continuous_fst.tendsto x).comp hXφ).mul haφ).mul hd)) + simpa only [Y,y,shiftedField,Function.comp_def] using hh + obtain ⟨C,hC⟩ := eventually_subgradients_bounded isOpen_pressureDomain + (Eventually.of_forall fun n => hconv (φ n)) + (fun z hz => (hQ.tendsto_at hz).comp hφ.tendsto_atTop) hy hY + have hVC : ∀ᶠ n in atTop, V n ∈ closedBall 0 C := by + filter_upwards [hC] with n hn + simpa only [mem_closedBall,dist_zero_right] using hn _ (hA (φ n)).2 + obtain ⟨v,_,ψ,hψ,hv⟩ := (isCompact_closedBall (0 : Parameter) C).tendsto_subseq' hVC.frequently + let θ := φ ∘ ψ + have hθ := (hφ.comp hψ).tendsto_atTop + let w : Parameter := (v.1+a₀*v.2^2/2,v.2) + have hV2 := (continuous_snd.tendsto v).comp hv + have hW : Tendsto (W ∘ θ) atTop (𝓝 w) := by + have hh := (((continuous_fst.tendsto v).comp hv).add + (((ha.comp hθ).mul (hV2.pow 2)).div_const 2)).prodMk_nhds hV2 + simpa only [V,unlift,w,θ,Function.comp_def,sub_add_cancel,Prod.mk.eta] using hh + have hxl := hX.comp hθ + have hwl := (continuous_snd.tendsto w).comp hW + have hpl := meanField_tendsto_of_bounded_maximizers (locallyUniform_reindex hQ hθ) hq + (ha.comp hθ) (fun n => hP (θ n)) hp hx hxl (fun n => hXS (θ n)) + (fun n => ⟨(W (θ n)).2,hD (θ n),(hA (θ n)).1⟩) + have hcost := quadraticCost_tendsto (locallyUniform_reindex hQ hθ) hq (ha.comp hθ) hwl hx hxl + have hshift : Tendsto (fun n => shiftedField (a (θ n)) (X (θ n)) (W (θ n)).2) atTop + (𝓝 (shiftedField a₀ x w.2)) := + ((continuous_fst.tendsto x).comp hxl).prodMk_nhds + (((continuous_snd.tendsto x).comp hxl).add + ((((continuous_fst.tendsto x).comp hxl).mul (ha.comp hθ)).mul hwl)) + have hunlift : Tendsto (fun n => unlift (a (θ n)) (W (θ n))) atTop (𝓝 (unlift a₀ w)) := by + exact (((continuous_fst.tendsto w).comp hW).sub + (((ha.comp hθ).mul (hwl.pow 2)).div_const 2)).prodMk_nhds hwl + refine ⟨θ,hφ.comp hψ,w,⟨?_,?_⟩,hW⟩ + · exact tendsto_nhds_unique (hcost.congr (fun n => (hA (θ n)).1)) hpl + · exact supportOn_varying_limit isOpen_pressureDomain (locallyUniform_reindex hQ hθ) hq + (show shiftedField a₀ x w.2 ∈ pressureDomain from hx) hshift hunlift (Eventually.of_forall fun n => (hA (θ n)).2) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ActiveSupports.lean b/lean/OAI/Probability/ContinuumTransition/ActiveSupports.lean new file mode 100644 index 0000000000000000000000000000000000000000..6524d4f5c40b8bbd07df14eaf1b2d7c81626b11e --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ActiveSupports.lean @@ -0,0 +1,104 @@ +import OAI.Probability.ContinuumTransition.MeanFieldAttainment + +namespace OAI + +section +open scoped Topology +open Set Filter +noncomputable section +namespace ContinuumTemperature + +def unlift (a : ℝ) (w : Parameter) : Parameter := (w.1-a*w.2^2/2,w.2) + +def activeLifts (Q : Parameter → ℝ) (a : ℝ) (P : Parameter → ℝ) + (x : Parameter) : Set Parameter := {w | + quadraticCost Q a x w.2 = P x ∧ + SupportOn pressureDomain Q (shiftedField a x w.2) (unlift a w)} + +lemma activeLifts_subset {Q P : Parameter → ℝ} {a : ℝ} + (hP : IsMeanField Q a P) {x : Parameter} (hx : x ∈ pressureDomain) : + activeLifts Q a P x ⊆ subgradients pressureDomain P x := by + intro w hw + have hh := lifted_support hP hx hw.1 (rfl : (unlift a w).2 = w.2) hw.2 + have he : ((unlift a w).1+a*w.2^2/2,w.2) = w := by + ext <;> dsimp [unlift]; ring + rw [he] at hh + exact hh + +lemma activeLifts_nonempty {Q P : Parameter → ℝ} {a : ℝ} (ha : 0 < a) + (hQ : ConvexOn ℝ pressureDomain Q) (hP : IsMeanField Q a P) + {x : Parameter} (hx : x ∈ pressureDomain) + (hatt : ∃ d, quadraticCost Q a x d = P x) : (activeLifts Q a P x).Nonempty := by + obtain ⟨d,hd⟩ := hatt + obtain ⟨v,hv⟩ := convex_exists_support isOpen_pressureDomain hQ + (show shiftedField a x d ∈ pressureDomain from hx) + have he := maximizing_density_eq ha hP hx hd hv + refine ⟨(v.1+a*d^2/2,d),hd,?_⟩ + convert hv using 1 + ext <;> dsimp [unlift] <;> linarith only [he] + +lemma activeLifts_closed_graph {Q P : Parameter → ℝ} {a : ℝ} + (hQ : ContinuousOn Q pressureDomain) (hP : ContinuousOn P pressureDomain) + {X V : ℕ → Parameter} {x v : Parameter} (hx : x ∈ pressureDomain) + (hX : Tendsto X atTop (𝓝 x)) (hV : Tendsto V atTop (𝓝 v)) + (hXS : ∀ n, X n ∈ pressureDomain) (hA : ∀ n, V n ∈ activeLifts Q a P (X n)) : + v ∈ activeLifts Q a P x := by + have hshift : Tendsto (fun n => shiftedField a (X n) (V n).2) atTop + (𝓝 (shiftedField a x v.2)) := + (show Continuous (fun p : Parameter × Parameter => shiftedField a p.1 p.2.2) by unfold shiftedField; fun_prop).tendsto + (x,v) |>.comp (hX.prodMk_nhds hV) + have hunlift : Tendsto (fun n => unlift a (V n)) atTop (𝓝 (unlift a v)) := + (show Continuous (unlift a) by unfold unlift; fun_prop).tendsto v |>.comp hV + have hQlim : Tendsto (fun n => Q (shiftedField a (X n) (V n).2)) atTop + (𝓝 (Q (shiftedField a x v.2))) := + (hQ (shiftedField a x v.2) (show shiftedField a x v.2 ∈ pressureDomain from hx)).tendsto.comp (tendsto_nhdsWithin_iff.2 ⟨hshift,Eventually.of_forall (fun n => show shiftedField a (X n) (V n).2 ∈ pressureDomain from hXS n)⟩) + have hPlim := (hP x hx).tendsto.comp + (tendsto_nhdsWithin_iff.2 ⟨hX,Eventually.of_forall hXS⟩) + have hquad : Tendsto (fun n => (X n).1*a*(V n).2^2/2) atTop (𝓝 (x.1*a*v.2^2/2)) := by + exact ((((continuous_fst.tendsto x).comp hX).mul_const a).mul (((continuous_snd.tendsto v).comp hV).pow 2)).div_const 2 + constructor + · exact tendsto_nhds_unique ((hQlim.sub hquad).congr (fun n => (hA n).1)) hPlim + · exact supportOn_limit hQ (show shiftedField a x v.2 ∈ pressureDomain from hx) hshift hunlift (Eventually.of_forall hXS) + (Eventually.of_forall fun n => (hA n).2) + +lemma meanField_subgradients {Q P : Parameter → ℝ} {a : ℝ} (ha : 0 < a) + (hQ : ConvexOn ℝ pressureDomain Q) (hP : IsMeanField Q a P) + (hatt : ∀ x ∈ pressureDomain, ∃ d, quadraticCost Q a x d = P x) + {x : Parameter} (hx : x ∈ pressureDomain) : + subgradients pressureDomain P x = closedConvexHull ℝ (activeLifts Q a P x) := by + have hc := meanField_convex hQ hP + exact support_generators_closedHull isOpen_pressureDomain hc (activeLifts Q a P) + (fun _ hx => activeLifts_subset hP hx) + (fun _ hx => activeLifts_nonempty ha hQ hP hx (hatt _ hx)) + (fun hx hX hV hXS hA => activeLifts_closed_graph (hQ.continuousOn isOpen_pressureDomain) + (hc.continuousOn isOpen_pressureDomain) hx hX hV hXS hA) hx + +lemma support_density_nonneg {Q : Parameter → ℝ} + (hm : ∀ β, 0 < β → Monotone (fun h => Q (β,h))) {x v : Parameter} + (hx : x ∈ pressureDomain) (hv : SupportOn pressureDomain Q x v) : 0 ≤ v.2 := by + have hh := hv (x.1,x.2-1) hx + have hl := hm x.1 hx (show x.2-1 ≤ x.2 by linarith) + dsimp [pDot] at hh + simpa only [Prod.mk.eta] using (show 0 ≤ v.2 by linarith) + +lemma active_density_nonneg {Q P : Parameter → ℝ} {a : ℝ} + (hm : ∀ β, 0 < β → Monotone (fun h => Q (β,h))) {x w : Parameter} + (hx : x ∈ pressureDomain) (hw : w ∈ activeLifts Q a P x) : 0 ≤ w.2 := + support_density_nonneg (v := unlift a w) hm (show shiftedField a x w.2 ∈ pressureDomain from hx) hw.2 + +lemma active_canonical_eq {Q P : Parameter → ℝ} {H : ℝ → ℝ → ℝ} {a : ℝ} + (hH : IsPartialConjugate Q H) + (hm : ∀ β, 0 < β → Monotone (fun h => Q (β,h))) {x w : Parameter} + (hx : x ∈ pressureDomain) (hw : w ∈ activeLifts Q a P x) : + P x = x.2*w.2+x.1*a*w.2^2/2-H x.1 w.2 := by + have hd := active_density_nonneg hm hx hw + have he := fenchel_eq_of_support hH hx hd (supports_iff_supportOn.mpr hw.2) + have hlow := hw.1 + dsimp [shiftedField,unlift,quadraticCost] at he hlow + nlinarith only [he,hlow] + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ActiveUniform.lean b/lean/OAI/Probability/ContinuumTransition/ActiveUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf2fdad1bbee3d10d16614ab88934ceadce566af --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ActiveUniform.lean @@ -0,0 +1,48 @@ +import OAI.Probability.ContinuumTransition.ActiveLimits + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +lemma active_uniform_near {Q : ℕ → Parameter → ℝ} {q : Parameter → ℝ} + {P : ℕ → Parameter → ℝ} {p : Parameter → ℝ} {a : ℝ} + (hQ : TendstoLocallyUniformlyOn Q q atTop pressureDomain) + (hconv : ∀ n, ConvexOn ℝ pressureDomain (Q n)) (hq : ContinuousOn q pressureDomain) + (hP : ∀ n, IsMeanField (Q n) a (P n)) (hp : IsMeanField q a p) + {x : Parameter} (hx : x ∈ pressureDomain) {r : ℝ} (hr : 0 < r) + (hball : ball x r ⊆ pressureDomain) {D : ℝ} + (hD : ∀ n, ∀ y ∈ ball x r, ∀ w ∈ activeLifts (Q n) a (P n) y, w.2 ∈ Icc 0 D) + {U : Set Parameter} (hU : IsOpen U) (hAU : activeLifts q a p x ⊆ U) : + ∃ δ > 0, δ < r ∧ ∃ N : ℕ, ∀ n ≥ N, ∀ y ∈ ball x δ, activeLifts (Q n) a (P n) y ⊆ U := by + by_contra hn + push Not at hn + have hex : ∀ m : ℕ, ∃ n ≥ m, ∃ y ∈ ball x (min (r/2) ((1/2 : ℝ)^m)), + ∃ w ∈ activeLifts (Q n) a (P n) y, w ∉ U := by + intro m + have hd : 0 < min (r/2) ((1/2 : ℝ)^m) := lt_min (by positivity) (pow_pos (by norm_num) _) + have hdr : min (r/2) ((1/2 : ℝ)^m) < r := (min_le_left _ _).trans_lt (by linarith) + obtain ⟨n,hn,y,hy,hbad⟩ := hn _ hd hdr m + obtain ⟨w,hw,hwu⟩ := Set.not_subset.mp hbad + exact ⟨n,hn,y,hy,w,hw,hwu⟩ + choose k hk X hX W hW hbad using hex + have hk' : Tendsto k atTop atTop := tendsto_atTop_mono hk tendsto_id + have hXr : ∀ n, X n ∈ ball x r := fun n => (hX n).trans_le ((min_le_left _ _).trans (show r/2 ≤ r by linarith)) + have hXt : Tendsto X atTop (𝓝 x) := by + apply tendsto_iff_dist_tendsto_zero.mpr + exact squeeze_zero (fun n => dist_nonneg) (fun n => (hX n).le.trans (min_le_right _ _)) + (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num)) + obtain ⟨φ,_,w,hw,hwt⟩ := active_subseq_of_density_bound (locallyUniform_reindex hQ hk') + (fun n => hconv (k n)) hq tendsto_const_nhds (fun n => hP (k n)) hp hx hXt + (fun n => hball (hXr n)) hW (fun n => hD (k n) _ (hXr n) _ (hW n)) + obtain ⟨n,hn⟩ := (hwt.eventually (hU.mem_nhds (hAU hw))).exists + exact hbad (φ n) hn + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/AppendAttraction.lean b/lean/OAI/Probability/ContinuumTransition/AppendAttraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4dd09590605215ddb70ec018e001bb060803e86 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/AppendAttraction.lean @@ -0,0 +1,65 @@ +import OAI.Probability.ContinuumTransition.MaskedComparison + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature + +def prepend (a : ℝ) (σ : ℕ → ℝ) : ℕ → ℝ + | 0 => a + | n+1 => σ n + +@[simp] theorem prepend_zero (a : ℝ) (σ : ℕ → ℝ) : prepend a σ 0 = a := rfl +@[simp] theorem prepend_succ (a : ℝ) (σ : ℕ → ℝ) (n : ℕ) : prepend a σ (n+1) = σ n := rfl + +theorem summable_prepend (a : ℝ) {σ : ℕ → ℝ} (hs : Summable σ) : Summable (prepend a σ) := by + exact (summable_nat_add_iff 1).mp hs + +theorem tsum_prepend (a : ℝ) {σ : ℕ → ℝ} (hs : Summable σ) : + ∑' n, prepend a σ n = a+∑' n, σ n := by + exact (summable_prepend a hs).tsum_eq_zero_add + +theorem prepend_nonneg {a : ℝ} {σ : ℕ → ℝ} (ha : 0 ≤ a) (hσ : ∀ n, 0 ≤ σ n) : + ∀ n, 0 ≤ prepend a σ n + | 0 => ha + | n+1 => hσ n + +theorem prepend_ge_one {a : ℝ} {σ : ℕ → ℝ} (ha : 1 ≤ a) (hσ : ∀ n, 1 ≤ σ n) : + ∀ n, 1 ≤ prepend a σ n + | 0 => ha + | n+1 => hσ n + +theorem attraction_prepend (t : ℝ) {a S : ℝ} {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) (r : ℝ) : + attraction t (prepend a σ) (prepend S R) r = t*a*scaledKernelProfile S r+attraction t σ R r := by + unfold attraction + have he : (fun n => prepend a σ n*scaledKernelProfile (prepend S R n) r) = + prepend (a*scaledKernelProfile S r) (fun n => σ n*scaledKernelProfile (R n) r) := by + funext n; cases n <;> rfl + rw [he, tsum_prepend _ (summable_attraction_terms hσ hR hs r)] + ring + +theorem physicalProfile_prepend (t : ℝ) {a S : ℝ} {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) (r : ℝ) : + physicalProfile t (prepend a σ) (prepend S R) r = physicalProfile t σ R r-t*a*scaledKernelProfile S r := by + unfold physicalProfile + rw [attraction_prepend t hσ hR hs] + ring + +theorem attraction_zero (t : ℝ) (R : ℕ → ℝ) (r : ℝ) : attraction t (fun _ => 0) R r = 0 := by + simp [attraction] + +theorem cutReference_prepend (t a S : ℝ) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) (q : ℕ) (x y : Space) : + cutReference t (prepend 0 σ) (prepend a (fun _ => 0)) (prepend S R) q x y = + blockCut q (fun x y => physicalProfile t σ R ‖x-y‖) x y-t*a*scaledKernelProfile S ‖x-y‖ := by + unfold cutReference + simp only [physicalProfile_prepend t hσ hR hs, mul_zero, zero_mul, sub_zero] + rw [attraction_prepend t (fun _ => le_refl 0) hR (summable_zero), attraction_zero, add_zero] + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ApproximateSupports.lean b/lean/OAI/Probability/ContinuumTransition/ApproximateSupports.lean new file mode 100644 index 0000000000000000000000000000000000000000..c64bef376a8eb2ac14cfc8282603f0f301f4893c --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ApproximateSupports.lean @@ -0,0 +1,49 @@ +import OAI.Probability.ContinuumTransition.ConstructionBounds + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +lemma uniform_square_error_tendsto {F : Parameter → ℝ} {Q : ℕ → Parameter → ℝ} + {a : ℕ → ℝ} (ha : Tendsto a atTop (𝓝 0)) {x : Parameter} {r : ℝ} + (happ : ∀ n, ∀ y ∈ ball x r, |Q n y-F y| ≤ (a n)^2) + {Y : ℕ → Parameter} {y : Parameter} (hy : y ∈ ball x r) + (hY : Tendsto Y atTop (𝓝 y)) (hF : ContinuousAt F y) : + Tendsto (fun n => Q n (Y n)) atTop (𝓝 (F y)) := by + have he : Tendsto (fun n => Q n (Y n)-F (Y n)) atTop (𝓝 0) := by + apply (tendsto_zero_iff_abs_tendsto_zero _).mpr + exact squeeze_zero' (Eventually.of_forall fun n => abs_nonneg (Q n (Y n)-F (Y n))) + ((hY.eventually (isOpen_ball.mem_nhds hy)).mono fun n hn => happ n _ hn) (by simpa using ha.pow 2) + have hh := he.add (hF.tendsto.comp hY) + simpa only [Function.comp_def,sub_add_cancel,zero_add] using hh + +lemma approximate_support_limit {F : Parameter → ℝ} (hF : ConvexOn ℝ pressureDomain F) + {Q : ℕ → Parameter → ℝ} {a : ℕ → ℝ} (ha : Tendsto a atTop (𝓝 0)) + {x : Parameter} (hx : x ∈ pressureDomain) {r : ℝ} (hr : 0 < r) + (hball : ball x r ⊆ pressureDomain) + (happ : ∀ n, ∀ y ∈ ball x r, |Q n y-F y| ≤ (a n)^2) + {Y V : ℕ → Parameter} {v : Parameter} + (hY : Tendsto Y atTop (𝓝 x)) (hV : Tendsto V atTop (𝓝 v)) + (hs : ∀ n, SupportOn pressureDomain (Q n) (Y n) (V n)) : + SupportOn pressureDomain F x v := by + apply supportOn_of_ball hF hx hr + intro y hy + have hcont := hF.continuousOn isOpen_pressureDomain + have hqx := uniform_square_error_tendsto ha happ (mem_ball_self hr) hY + (hcont.continuousAt (isOpen_pressureDomain.mem_nhds hx)) + have hqy := uniform_square_error_tendsto ha happ hy (tendsto_const_nhds (x := y)) + (hcont.continuousAt (isOpen_pressureDomain.mem_nhds (hball hy))) + have hd : Tendsto (fun n => pDot (V n) (y-Y n)) atTop (𝓝 (pDot v (y-x))) := by + exact (show Continuous (fun p : Parameter × Parameter => pDot p.1 (y-p.2)) by unfold pDot; fun_prop).tendsto + (v,x) |>.comp (hV.prodMk_nhds hY) + exact le_of_tendsto_of_tendsto (hqx.add hd) hqy (Eventually.of_forall fun n => hs n y (hball hy)) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/Assignments.lean b/lean/OAI/Probability/ContinuumTransition/Assignments.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a2ea31290cb8846f344fca7c781b119b7466a88 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/Assignments.lean @@ -0,0 +1,316 @@ +import OAI.Probability.ContinuumTransition.PairEnergy + +namespace OAI + +universe u_1 u_2 + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature + +section Assignments +variable {X : Type u_1} [MeasurableSpace X] {ι : Type u_2} [Fintype ι] [DecidableEq ι] + +def assignmentRegion (B : ι → Set X) (e : Equiv.Perm ι) : Set (ι → X) := + {x | ∀ i, x i ∈ B (e i)} + +omit [DecidableEq ι] in +theorem measurableSet_assignmentRegion {B : ι → Set X} (hB : ∀ i, MeasurableSet (B i)) + (e : Equiv.Perm ι) : MeasurableSet (assignmentRegion B e) := by + convert MeasurableSet.iInter (fun i => (hB (e i)).preimage (measurable_pi_apply i)) using 1 + ext x + simp [assignmentRegion] + +omit [MeasurableSpace X] in +theorem assignmentRegion_pairwiseDisjoint {B : ι → Set X} + (hB : Pairwise (fun i j => Disjoint (B i) (B j))) : + Pairwise (fun e f : Equiv.Perm ι => Disjoint (assignmentRegion B e) (assignmentRegion B f)) := by + intro e f hef + apply Set.disjoint_left.mpr + intro x hx hy + have hne : ∃ i, e i ≠ f i := by + by_contra! h + exact hef (Equiv.ext h) + obtain ⟨i, hi⟩ := hne + exact Set.disjoint_left.mp (hB hi) (hx i) (hy i) + +theorem measure_assignment_union (μ : Measure X) [SigmaFinite μ] {B : ι → Set X} + (hB : ∀ i, MeasurableSet (B i)) + (hd : Pairwise (fun i j => Disjoint (B i) (B j))) : + (Measure.pi (fun _ : ι => μ)) (⋃ e : Equiv.Perm ι, assignmentRegion B e) = + (Fintype.card ι).factorial * ∏ i, μ (B i) := by + rw [measure_iUnion (assignmentRegion_pairwiseDisjoint hd) + (measurableSet_assignmentRegion hB), tsum_fintype] + have hh (e : Equiv.Perm ι) : + (Measure.pi (fun _ : ι => μ)) (assignmentRegion B e) = ∏ i, μ (B i) := by + have heq : assignmentRegion B e = Set.univ.pi (fun i => B (e i)) := by + ext x + simp [assignmentRegion] + rw [heq, Measure.pi_pi, Equiv.prod_comp e (fun i => μ (B i))] + simp_rw [hh] + simp [Fintype.card_perm] + +theorem integral_lower_of_disjoint_assignments (μ : Measure X) [SigmaFinite μ] + {B : ι → Set X} (hB : ∀ i, MeasurableSet (B i)) + (hd : Pairwise (fun i j => Disjoint (B i) (B j))) + (hfinite : ∀ i, μ (B i) ≠ ⊤) {Ω : Set (ι → X)} {F : (ι → X) → ℝ} + (hF : IntegrableOn F Ω (Measure.pi (fun _ : ι => μ))) + (hF0 : ∀ x, 0 ≤ F x) {c : ℝ} + (hinc : ∀ e, assignmentRegion B e ⊆ Ω) + (hbound : ∀ e, ∀ x ∈ assignmentRegion B e, c ≤ F x) : + (Fintype.card ι).factorial * (∏ i, (μ (B i)).toReal) * c ≤ + ∫ x in Ω, F x ∂(Measure.pi (fun _ : ι => μ)) := by + let S := ⋃ e : Equiv.Perm ι, assignmentRegion B e + have hS : MeasurableSet S := MeasurableSet.iUnion (measurableSet_assignmentRegion hB) + have hsub : S ⊆ Ω := iUnion_subset hinc + have hmass := measure_assignment_union μ hB hd + have hSfin : (Measure.pi (fun _ : ι => μ)) S ≠ ⊤ := by + rw [hmass] + exact ENNReal.mul_ne_top (by simp) (ENNReal.prod_ne_top (fun i _ => hfinite i)) + have hconst : IntegrableOn (fun _ : ι → X => c) S (Measure.pi (fun _ : ι => μ)) := + integrableOn_const hSfin + have hle : (∫ x in S, c ∂(Measure.pi (fun _ : ι => μ))) ≤ + ∫ x in S, F x ∂(Measure.pi (fun _ : ι => μ)) := by + apply setIntegral_mono_on hconst (hF.mono_set hsub) hS + intro x hx + obtain ⟨e, he⟩ := mem_iUnion.mp hx + exact hbound e x he + have hle' := setIntegral_mono_set hF (Filter.Eventually.of_forall hF0) + (Filter.Eventually.of_forall hsub) + have hval : (∫ x in S, c ∂(Measure.pi (fun _ : ι => μ))) = + (Fintype.card ι).factorial * (∏ i, (μ (B i)).toReal) * c := by + rw [setIntegral_const, Measure.real, hmass, ENNReal.toReal_mul, ENNReal.toReal_natCast, + ENNReal.toReal_prod, smul_eq_mul] + rw [hval] at hle + exact hle.trans hle' + +omit [DecidableEq ι] in + +theorem setIntegral_coordinatePerm (μ : Measure X) [SigmaFinite μ] + (e : Equiv.Perm ι) (S : Set (ι → X)) (F : (ι → X) → ℝ) + (hsym : ∀ x, F (x ∘ e) = F x) : + (∫ x in {x | (x ∘ e) ∈ S}, F x ∂(Measure.pi (fun _ : ι => μ))) = + ∫ x in S, F x ∂(Measure.pi (fun _ : ι => μ)) := by + let p : (ι → X) ≃ᵐ (ι → X) := MeasurableEquiv.piCongrLeft (fun _ : ι => X) e.symm + have hpx (x : ι → X) : p x = x ∘ e := by + ext i + simpa only [p, Equiv.symm_apply_apply, Function.comp_apply] using + (MeasurableEquiv.piCongrLeft_apply_apply e.symm (β := fun _ : ι => X) x (e i)) + have hp : MeasurePreserving p (Measure.pi (fun _ : ι => μ)) + (Measure.pi (fun _ : ι => μ)) := measurePreserving_piCongrLeft (fun _ : ι => μ) e.symm + have heq := hp.setIntegral_preimage_emb p.measurableEmbedding F S + simpa only [hpx, hsym, Set.preimage] using heq + +def binaryRegion (A B : Set X) (s : Finset ι) : Set (ι → X) := + {x | ∀ i, if i ∈ s then x i ∈ A else x i ∈ B} + +theorem measurableSet_binaryRegion {A B : Set X} (hA : MeasurableSet A) + (hB : MeasurableSet B) (s : Finset ι) : MeasurableSet (binaryRegion A B s) := by + have hh (i : ι) : MeasurableSet ((fun x : ι → X => x i) ⁻¹' (if i ∈ s then A else B)) := by + by_cases hi : i ∈ s + · simpa only [ite_eq_left hi] using hA.preimage (measurable_pi_apply i) + · simpa only [ite_eq_right hi] using hB.preimage (measurable_pi_apply i) + convert MeasurableSet.iInter hh using 1 + ext x + simp only [binaryRegion, mem_ofPred_eq, mem_iInter, mem_preimage] + apply forall_congr' + intro i + split_ifs <;> rfl + +omit [MeasurableSpace X] [Fintype ι] in +theorem binaryRegion_pairwiseDisjoint {A B : Set X} (hd : Disjoint A B) : + Pairwise (fun s t : Finset ι => Disjoint (binaryRegion A B s) (binaryRegion A B t)) := by + intro s t hst + apply Set.disjoint_left.mpr + intro x hx hy + apply hst + ext i + constructor + · intro hi + by_contra ht + exact Set.disjoint_left.mp hd (by simpa only [ite_eq_left hi] using hx i) + (by simpa only [ite_eq_right ht] using hy i) + · intro hi + by_contra hs + exact Set.disjoint_left.mp hd (by simpa only [ite_eq_left hi] using hy i) + (by simpa only [ite_eq_right hs] using hx i) + +theorem setIntegral_binaryRegion_eq (μ : Measure X) [SigmaFinite μ] + {A B : Set X} {s t : Finset ι} (hst : s.card = t.card) (F : (ι → X) → ℝ) + (hsym : ∀ (e : Equiv.Perm ι) x, F (x ∘ e) = F x) : + (∫ x in binaryRegion A B s, F x ∂(Measure.pi (fun _ : ι => μ))) = + ∫ x in binaryRegion A B t, F x ∂(Measure.pi (fun _ : ι => μ)) := by + obtain ⟨e, he⟩ := Equiv.Perm.exists_map_finset_eq s t hst + have hmem (i : ι) : e i ∈ t ↔ i ∈ s := by + rw [← he] + simp only [Finset.mem_map, Equiv.toEmbedding_apply] + constructor + · rintro ⟨j, hj, hji⟩ + exact e.injective hji ▸ hj + · exact fun hi => ⟨i, hi, rfl⟩ + have hpre : {x : ι → X | (x ∘ e) ∈ binaryRegion A B s} = binaryRegion A B t := by + ext x + change (∀ i, if i ∈ s then x (e i) ∈ A else x (e i) ∈ B) ↔ + (∀ i, if i ∈ t then x i ∈ A else x i ∈ B) + simp_rw [← hmem] + constructor + · intro hh j + obtain ⟨i, rfl⟩ := e.surjective j + exact hh i + · intro hh i + exact hh (e i) + have hh := setIntegral_coordinatePerm μ e (binaryRegion A B s) F (hsym e) + rw [hpre] at hh + exact hh.symm + +theorem integral_lower_binary_assignments (μ : Measure X) [SigmaFinite μ] + {A B : Set X} (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + (s : Finset ι) {Ω : Set (ι → X)} {F : (ι → X) → ℝ} + (hF : IntegrableOn F Ω (Measure.pi (fun _ : ι => μ))) + (hF0 : ∀ x, 0 ≤ F x) + (hsym : ∀ (e : Equiv.Perm ι) x, F (x ∘ e) = F x) + (hinc : ∀ t : Finset ι, t.card = s.card → binaryRegion A B t ⊆ Ω) : + (Fintype.card ι).choose s.card * + (∫ x in binaryRegion A B s, F x ∂(Measure.pi (fun _ : ι => μ))) ≤ + ∫ x in Ω, F x ∂(Measure.pi (fun _ : ι => μ)) := by + classical + let T := (Finset.univ : Finset ι).powersetCard s.card + have hcard (t : Finset ι) (ht : t ∈ T) : t.card = s.card := (Finset.mem_powersetCard.mp ht).2 + have hsub : (⋃ t ∈ T, binaryRegion A B t) ⊆ Ω := by + intro x hx + obtain ⟨t, ht, hx⟩ := mem_iUnion₂.mp hx + exact hinc t (hcard t ht) hx + have hh := integral_biUnion_finset T (fun t _ => measurableSet_binaryRegion hA hB t) + (fun _ _ _ _ hne => binaryRegion_pairwiseDisjoint hd hne) + (fun t ht => hF.mono_set (hinc t (hcard t ht))) + have hEq : (∫ x in ⋃ t ∈ T, binaryRegion A B t, F x ∂(Measure.pi (fun _ : ι => μ))) = + (Fintype.card ι).choose s.card * + (∫ x in binaryRegion A B s, F x ∂(Measure.pi (fun _ : ι => μ))) := by + rw [hh] + calc + _ = ∑ _t ∈ T, ∫ x in binaryRegion A B s, F x ∂(Measure.pi (fun _ : ι => μ)) := by + apply Finset.sum_congr rfl + intro t ht + exact setIntegral_binaryRegion_eq μ (hcard t ht) F hsym + _ = _ := by simp [T] + rw [← hEq] + exact setIntegral_mono_set hF (Filter.Eventually.of_forall hF0) + (Filter.Eventually.of_forall hsub) + +theorem setIntegral_binary_product (μ : Measure X) [SigmaFinite μ] + (A B : Set X) (s : Finset ι) + (f : ({i : ι // i ∈ s} → X) → ℝ) (g : ({i : ι // i ∉ s} → X) → ℝ) : + (∫ x in binaryRegion A B s, + f (fun i : {i : ι // i ∈ s} => x i) * g (fun i : {i : ι // i ∉ s} => x i) + ∂(Measure.pi (fun _ : ι => μ))) = + (∫ x in {x : {i : ι // i ∈ s} → X | ∀ i, x i ∈ A}, f x ∂(Measure.pi (fun _ : {i : ι // i ∈ s} => μ))) * + (∫ x in {x : {i : ι // i ∉ s} → X | ∀ i, x i ∈ B}, g x + ∂(Measure.pi (fun _ : {i : ι // i ∉ s} => μ))) := by + let p := MeasurableEquiv.piEquivPiSubtypeProd (fun _ : ι => X) (fun i => i ∈ s) + let SA := {x : {i : ι // i ∈ s} → X | ∀ i, x i ∈ A} + let SB := {x : {i : ι // i ∉ s} → X | ∀ i, x i ∈ B} + have hp := measurePreserving_piEquivPiSubtypeProd (fun _ : ι => μ) (fun i => i ∈ s) + have hfi : Subtype.fintype (fun i : ι => i ∈ s) = Finset.Subtype.fintype s := + Subsingleton.elim _ _ + rw [hfi] at hp + have hpre : p ⁻¹' (SA ×ˢ SB) = binaryRegion A B s := by + ext x + change ((∀ i : {i : ι // i ∈ s}, x i ∈ A) ∧ (∀ i : {i : ι // i ∉ s}, x i ∈ B)) ↔ + (∀ i, if i ∈ s then x i ∈ A else x i ∈ B) + constructor + · rintro ⟨ha, hb⟩ i + split_ifs with hi + · exact ha ⟨i, hi⟩ + · exact hb ⟨i, hi⟩ + · intro hh + constructor + · intro i + simpa only [ite_eq_left i.property] using hh i + · intro i + simpa only [ite_eq_right i.property] using hh i + have heq := hp.setIntegral_preimage_emb p.measurableEmbedding + (fun z => f z.1 * g z.2) (SA ×ˢ SB) + rw [hpre, setIntegral_prod_mul] at heq + exact heq + +theorem integrableOn_binary_product (μ : Measure X) [SigmaFinite μ] + (A B : Set X) (s : Finset ι) + {f : ({i : ι // i ∈ s} → X) → ℝ} {g : ({i : ι // i ∉ s} → X) → ℝ} + (hf : IntegrableOn f {x | ∀ i, x i ∈ A} (Measure.pi (fun _ : {i : ι // i ∈ s} => μ))) + (hg : IntegrableOn g {x | ∀ i, x i ∈ B} + (Measure.pi (fun _ : {i : ι // i ∉ s} => μ))) : + IntegrableOn (fun x : ι → X => + f (fun i : {i : ι // i ∈ s} => x i) * g (fun i : {i : ι // i ∉ s} => x i)) + (binaryRegion A B s) (Measure.pi (fun _ : ι => μ)) := by + let p := MeasurableEquiv.piEquivPiSubtypeProd (fun _ : ι => X) (fun i => i ∈ s) + let SA := {x : {i : ι // i ∈ s} → X | ∀ i, x i ∈ A} + let SB := {x : {i : ι // i ∉ s} → X | ∀ i, x i ∈ B} + have hp := measurePreserving_piEquivPiSubtypeProd (fun _ : ι => μ) (fun i => i ∈ s) + have hfi : Subtype.fintype (fun i : ι => i ∈ s) = Finset.Subtype.fintype s := + Subsingleton.elim _ _ + rw [hfi] at hp + have hpre : p ⁻¹' (SA ×ˢ SB) = binaryRegion A B s := by + ext x + change ((∀ i : {i : ι // i ∈ s}, x i ∈ A) ∧ (∀ i : {i : ι // i ∉ s}, x i ∈ B)) ↔ + (∀ i, if i ∈ s then x i ∈ A else x i ∈ B) + constructor + · rintro ⟨ha, hb⟩ i + split_ifs with hi + · exact ha ⟨i, hi⟩ + · exact hb ⟨i, hi⟩ + · intro hh + constructor + · intro i + simpa only [ite_eq_left i.property] using hh i + · intro i + simpa only [ite_eq_right i.property] using hh i + have hprod : IntegrableOn (fun z => f z.1 * g z.2) (SA ×ˢ SB) + ((Measure.pi (fun _ : {i : ι // i ∈ s} => μ)).prod + (Measure.pi (fun _ : {i : ι // i ∉ s} => μ))) := by + rw [IntegrableOn, ← Measure.prod_restrict] + exact hf.mul_prod hg + have hh := (hp.integrableOn_comp_preimage p.measurableEmbedding).2 hprod + rw [hpre] at hh + exact hh + +theorem integral_lower_separated_product (μ : Measure X) [SigmaFinite μ] + {A B : Set X} (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + (s : Finset ι) {Ω : Set (ι → X)} {F : (ι → X) → ℝ} + (hF : IntegrableOn F Ω (Measure.pi (fun _ : ι => μ))) + (hF0 : ∀ x, 0 ≤ F x) + (hsym : ∀ (e : Equiv.Perm ι) x, F (x ∘ e) = F x) + (hinc : ∀ t : Finset ι, t.card = s.card → binaryRegion A B t ⊆ Ω) + {f : ({i : ι // i ∈ s} → X) → ℝ} {g : ({i : ι // i ∉ s} → X) → ℝ} + (hf : IntegrableOn f {x | ∀ i, x i ∈ A} (Measure.pi (fun _ : {i : ι // i ∈ s} => μ))) + (hg : IntegrableOn g {x | ∀ i, x i ∈ B} + (Measure.pi (fun _ : {i : ι // i ∉ s} => μ))) + (hbound : ∀ x ∈ binaryRegion A B s, + f (fun i : {i : ι // i ∈ s} => x i) * g (fun i : {i : ι // i ∉ s} => x i) ≤ F x) : + (Fintype.card ι).choose s.card * + ((∫ x in {x : {i : ι // i ∈ s} → X | ∀ i, x i ∈ A}, f x ∂(Measure.pi (fun _ : {i : ι // i ∈ s} => μ))) * + (∫ x in {x : {i : ι // i ∉ s} → X | ∀ i, x i ∈ B}, g x + ∂(Measure.pi (fun _ : {i : ι // i ∉ s} => μ)))) ≤ + ∫ x in Ω, F x ∂(Measure.pi (fun _ : ι => μ)) := by + have hle := setIntegral_mono_on (integrableOn_binary_product μ A B s hf hg) + (hF.mono_set (hinc s rfl)) (measurableSet_binaryRegion hA hB s) hbound + rw [setIntegral_binary_product] at hle + exact (mul_le_mul_of_nonneg_left hle (Nat.cast_nonneg _)).trans + (integral_lower_binary_assignments μ hA hB hd s hF hF0 hsym hinc) + +omit [MeasurableSpace X] [Fintype ι] [DecidableEq ι] in + +theorem binomial_factorial_cancel {n k : ℕ} (hk : k ≤ n) {a b I : ℝ} + (h : (n.choose k : ℝ) * (a * b) ≤ I) : + (a / (k.factorial : ℝ)) * (b / ((n-k).factorial : ℝ)) ≤ I / (n.factorial : ℝ) := by + have hn : (0 : ℝ) < n.factorial := by exact_mod_cast Nat.factorial_pos n + apply (le_div_iff₀ hn).2 + rw [Nat.cast_choose ℝ hk] at h + simpa only [div_eq_mul_inv, mul_inv_rev, mul_assoc, mul_comm, mul_left_comm] using h + +end Assignments + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/BadEndpoints.lean b/lean/OAI/Probability/ContinuumTransition/BadEndpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..2813cce974e864b48ba787171b69bd6a259bff3b --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/BadEndpoints.lean @@ -0,0 +1,91 @@ +import OAI.Probability.ContinuumTransition.FreeGrand + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +noncomputable def badEndpoints {ι : Type} [Fintype ι] (t : ℝ) (x : ι → Space) : Finset ι := + Finset.univ.filter (fun i => ∃ j, i ≠ j ∧ ‖x i-x j‖ < 1 ∧ + ¬(Real.exp (-t) ≤ ‖x i-x j‖ ∧ ‖x i-x j‖ ≤ (1+shellDelta)*Real.exp (-t))) + +lemma badEndpoints_complement_free {ι : Type} [Fintype ι] [DecidableEq ι] (t : ℝ) (x : ι → Space) : + FreeConfig t (fun i : {i : ι // i ∉ badEndpoints t x} => x i) := by + intro i j hij hd + by_contra hh + apply i.property + simp only [badEndpoints, Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨j,fun he => hij (Subtype.ext he),hd,hh⟩ + +lemma badEndpoints_energy {ι : Type} [Fintype ι] (t : ℝ) (x : ι → Space) : + t^2/2*(badEndpoints t x).card ≤ gibbsEnergy (fun x y => coreProfile t ‖x-y‖) x := by + have hn (i j : ι) : 0 ≤ if i=j then (0 : ℝ) else coreProfile t ‖x i-x j‖ := by + split_ifs + · rfl + · exact coreProfile_nonneg _ _ + have hr (i : ι) : (if i ∈ badEndpoints t x then t^2 else 0) ≤ + ∑ j, if i=j then (0 : ℝ) else coreProfile t ‖x i-x j‖ := by + split_ifs with hi + · obtain ⟨j,hij,hd,hs⟩ := (Finset.mem_filter.mp hi).2 + calc + _ ≤ coreProfile t ‖x i-x j‖ := coreProfile_ge_of_not_shell t _ hd hs + _ = (if i=j then (0 : ℝ) else coreProfile t ‖x i-x j‖) := by rw [ite_eq_right hij] + _ ≤ _ := Finset.single_le_sum (fun j _ => hn i j) (Finset.mem_univ j) + · exact Finset.sum_nonneg (fun j _ => hn i j) + have hh := Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset ι)) => hr i) + have he : (∑ i : ι, if i ∈ badEndpoints t x then t^2 else 0) = + ((badEndpoints t x).card : ℝ)*t^2 := by + rw [← Finset.sum_filter] + simp only [Finset.filter_mem_eq_inter, Finset.univ_inter, Finset.sum_const, nsmul_eq_mul] + rw [he] at hh + unfold gibbsEnergy + linarith only [hh] + +noncomputable def idealFamily (d : ℝ) : ConfigFamily := + fun ι _ _ => Real.exp (d*Fintype.card ι) + +lemma idealFamily_nonneg (d : ℝ) (ι : Type) [Fintype ι] (x : ι → Space) : + 0 ≤ idealFamily d ι x := (Real.exp_pos _).le + +lemma idealFamily_relabel (d : ℝ) : RelabelInvariant (idealFamily d) := by + intro ι κ _ _ e x + simp only [idealFamily, Fintype.card_congr e] + +theorem core_gibbs_bad_endpoints {ι : Type} [Fintype ι] [DecidableEq ι] (t d : ℝ) {β : ℝ} (hβ : 0 ≤ β) + (x : ι → Space) : + gibbsFamily (fun x y => coreProfile t ‖x-y‖) β d ι x ≤ + ∑ s : Finset ι, idealFamily (d-β*t^2/2) {i : ι // i ∈ s} (fun i => x i)* + freeFamily t d {i : ι // i ∉ s} (fun i => x i) := by + let s := badEndpoints t x + have hterm : gibbsFamily (fun x y => coreProfile t ‖x-y‖) β d ι x ≤ + idealFamily (d-β*t^2/2) {i : ι // i ∈ s} (fun i => x i)* + freeFamily t d {i : ι // i ∉ s} (fun i => x i) := by + have hsfree : FreeConfig t (fun i : {i : ι // i ∉ s} => x i) := badEndpoints_complement_free t x + simp only [idealFamily, freeFamily, ite_eq_left hsfree, Fintype.card_coe] + have he : (Fintype.card ι : ℝ) = (s.card : ℝ)+(Fintype.card {i : ι // i ∉ s} : ℝ) := by + have hh := Fintype.card_subtype_compl (fun i : ι => i ∈ s) + rw [Fintype.card_coe] at hh + have hh' : Fintype.card ι = s.card+Fintype.card {i : ι // i ∉ s} := by + rw [hh]; exact (Nat.add_sub_of_le (Finset.card_le_univ s)).symm + exact_mod_cast hh' + unfold gibbsFamily + split_ifs with hinj + · rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left (badEndpoints_energy t x) hβ + rw [he] + dsimp only [s] at hh ⊢ + nlinarith only [hh] + · positivity + exact hterm.trans (Finset.single_le_sum + (fun r _ => mul_nonneg + (idealFamily_nonneg (d-β*t^2/2) {i : ι // i ∈ r} (fun i => x i)) + (freeFamily_nonneg t d {i : ι // i ∉ r} (fun i => x i))) (Finset.mem_univ s)) + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/BlockEnergy.lean b/lean/OAI/Probability/ContinuumTransition/BlockEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..027a694227cd36b5b35344134a1f4035bdfa15b5 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/BlockEnergy.lean @@ -0,0 +1,80 @@ +import OAI.Probability.ContinuumTransition.GibbsQuadratic + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +theorem gibbsEnergy_mul_left (V : Space → Space → ℝ) (a : ℝ) {ι : Type} [Fintype ι] (x : ι → Space) : + gibbsEnergy (fun x y => a*V x y) x = a*gibbsEnergy V x := by + have he (i j : ι) : (if i = j then 0 else a*V (x i) (x j)) = + a*(if i = j then 0 else V (x i) (x j)) := by split_ifs <;> ring + simp only [gibbsEnergy, he, ← Finset.mul_sum] + ring + +theorem gibbsEnergy_block_constant {q : ℕ} (hq : 0 < q) (γ : ℝ) + {ι : Type} [Fintype ι] (s : Finset Lattice) (c : ι → s) (x : ι → Space) + (hx : ∀ i, x i ∈ gridBox ((q : ℝ)/4) (c i)) : + gibbsEnergy (blockCut q (fun _ _ => γ)) x = + γ*((∑ k : s, (Fintype.card {i // c i = k} : ℝ)^2)-Fintype.card ι)/2 := by + have hu : 0 < (q : ℝ)/4 := by positivity + have he (i j : ι) : blockCut q (fun _ _ => γ) (x i) (x j) = if c i = c j then γ else 0 := by + simp only [blockCut, (mem_gridBox_iff hu _ _).1 (hx i), + (mem_gridBox_iff hu _ _).1 (hx j), Subtype.coe_inj] + rw [gibbsEnergy_eq_sum_sub_diag] + simp only [he, ite_true, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [double_sum_comp_eq c (fun k l => if k = l then γ else 0)] + have hs : (∑ k : s, ∑ l : s, (if k = l then γ else 0)* + (Fintype.card {i // c i = k} : ℝ)*(Fintype.card {i // c i = l} : ℝ)) = + γ*∑ k : s, (Fintype.card {i // c i = k} : ℝ)^2 := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + simp only [ite_mul, zero_mul, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + ring + rw [hs] + ring + +theorem quadraticBlock_eq_sub (q : ℕ) (φ : ℝ → ℝ) (γ : ℝ) : + quadraticBlock q φ γ = fun x y => blockCut q (fun x y => φ ‖x-y‖) x y- + blockCut q (fun _ _ => γ) x y := by + funext x y + unfold quadraticBlock blockCut + split_ifs <;> ring + +theorem kac_gibbsFamily_le_quadratic {C : NNReal} (hC : LipschitzWith C kernel) + {R β a μ : ℝ} (hR : 0 < R) (hβ : 0 ≤ β) (ha : 0 ≤ a) + {q : ℕ} (hq : 0 < q) (φ : ℝ → ℝ) + {ι : Type} [Fintype ι] (s : Finset Lattice) (c : ι → s) (x : ι → Space) + (hx : ∀ i, x i ∈ gridBox ((q : ℝ)/4) (c i)) : + let u := (q : ℝ)/4 + let γ := a*(1+(6*(C : ℝ)*u/R^4)*(2*(R+6*u))^3)/u^3 + gibbsFamily (fun x y => blockCut q (fun x y => φ ‖x-y‖) x y-a*scaledKernel R (x-y)) β μ ι x ≤ + gibbsFamily (quadraticBlock q φ γ) β (μ+β*γ/2) ι x := by + dsimp only + let u := (q : ℝ)/4 + let γ := a*(1+(6*(C : ℝ)*u/R^4)*(2*(R+6*u))^3)/u^3 + have hu : 0 < u := by dsimp only [u]; positivity + have he := kac_energy_upper hC hR hu s c x hx + have hb : a*gibbsEnergy (fun x y => scaledKernel R (x-y)) x ≤ + γ/2*∑ k : s, (Fintype.card {i // c i = k} : ℝ)^2 := by + apply (mul_le_mul_of_nonneg_left he ha).trans_eq + dsimp only [γ] + ring + unfold gibbsFamily + split_ifs + · rw [gibbsEnergy_sub, gibbsEnergy_mul_left, quadraticBlock_eq_sub, + gibbsEnergy_sub, gibbsEnergy_block_constant hq γ s c x hx] + apply Real.exp_le_exp.mpr + change μ*(Fintype.card ι : ℝ)-β*(_-a*_) ≤ + (μ+β*γ/2)*(Fintype.card ι : ℝ)-β*(_-γ*(_-Fintype.card ι)/2) + nlinarith only [mul_le_mul_of_nonneg_left hb hβ] + · rfl + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/BlockPartition.lean b/lean/OAI/Probability/ContinuumTransition/BlockPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..c673bf738f921032ef89d36f7e119ba2f285b5f4 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/BlockPartition.lean @@ -0,0 +1,118 @@ +import OAI.Probability.ContinuumTransition.BlockEnergy + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +theorem gridBox_subset_translate_cube {u : ℝ} (_hu : 0 < u) (k : Lattice) : + gridBox u k ⊆ (fun x : Space => x+gridCenter u k) '' cube u := by + intro x hx + refine ⟨x-gridCenter u k, ?_, sub_add_cancel _ _⟩ + intro i + have hxi := hx i + change -u/2 ≤ x i-u*((k i : ℝ)+1/2) ∧ x i-u*((k i : ℝ)+1/2) ≤ u/2 + constructor <;> linarith [hxi.1, hxi.2] + +theorem volume_translate (A : Set Space) (a : Space) : + volume ((fun x : Space => x+a) '' A) = volume A := by + have he : (fun x : Space => x+a) '' A = (fun x : Space => x-a) ⁻¹' A := by + ext x + constructor + · rintro ⟨y, hy, rfl⟩ + simpa only [mem_preimage, add_sub_cancel_right] using hy + · intro hx + exact ⟨x-a, hx, sub_add_cancel _ _⟩ + rw [he, show (fun x : Space => x-a) = (fun x => x+(-a)) by funext; rw [sub_eq_add_neg], + measure_preimage_add_right] + +theorem setPartition_mono {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B : ℝ} (hβ : 0 ≤ β) + (hst : ∀ (n : ℕ) (x : Fin n → Space), ((-B*n : ℝ) : EReal) ≤ energy φ x) + {A D : Set Space} (hD : volume D ≠ ⊤) (hAD : A ⊆ D) (n : ℕ) : + setPartition φ β A n ≤ setPartition φ β D n := by + unfold setPartition generalPartition + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + refine setIntegral_mono_set (integrableOn_symmetricWeight hφ hβ hst ?_) + (Filter.Eventually.of_forall (symmetricWeight_nonneg φ β)) ?_ + · rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hD + · exact Filter.Eventually.of_forall (fun _ hx i => hAD (hx i)) + +theorem setPartition_gridBox_le {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B u : ℝ} (hβ : 0 ≤ β) (hu : 0 < u) + (hst : ∀ (n : ℕ) (x : Fin n → Space), ((-B*n : ℝ) : EReal) ≤ energy φ x) + (k : Lattice) (n : ℕ) : setPartition φ β (gridBox u k) n ≤ partition φ β u n := by + have hfin : volume ((fun x : Space => x+gridCenter u k) '' cube u) ≠ ⊤ := by + rw [volume_translate, volume_cube] + exact ENNReal.pow_ne_top ENNReal.ofReal_ne_top + have hh := setPartition_mono hφ hβ hst hfin (gridBox_subset_translate_cube hu k) n + rw [setPartition_translate] at hh + simp only [setPartition, generalPartition_eq_partition] at hh + exact hh + +theorem physicalProfile_ge_constant {t : ℝ} (ht : 0 ≤ t) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) (r : ℝ) : + -(t*(∑' n, σ n)*kernelHeight) ≤ physicalProfile t σ R r := by + have ha := attraction_le ht hσ hR hs r + have hc := coreProfile_nonneg t r + change _ ≤ coreProfile t r-attraction t σ R r + linarith + +theorem quadraticBlock_lower {φ : ℝ → ℝ} {C γ : ℝ} (hC : 0 ≤ C) (hγ : 0 ≤ γ) + (hφ : ∀ r, -C ≤ φ r) (q : ℕ) (x y : Space) : + -(C+γ) ≤ quadraticBlock q φ γ x y := by + unfold quadraticBlock blockCut + split_ifs + · linarith [hφ ‖x-y‖] + · linarith + +theorem volume_gridBlocks_ne_top {u : ℝ} (hu : 0 ≤ u) (s : Finset Lattice) : + volume (⋃ k ∈ s, gridBox u k) ≠ ⊤ := by + apply ne_top_of_le_ne_top ?_ (measure_biUnion_finset_le s (gridBox u)) + apply ENNReal.sum_ne_top.mpr + intro k _ + rw [volume_gridBox hu] + exact ENNReal.ofReal_ne_top + +theorem quadraticBlock_familyTerm_le {t β μ γ : ℝ} (ht : 0 ≤ t) (hβ : 0 ≤ β) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n)/2 ≤ t^2/8) + {q : ℕ} (hq : 0 < q) (k : Lattice) (n : ℕ) : + familyTerm (gibbsFamily (quadraticBlock q (physicalProfile t σ R) γ) β (μ+β*γ/2)) + (gridBox ((q : ℝ)/4) k) n ≤ + quadraticGrandTerm (physicalProfile t σ R) β μ (β*γ/2*((q : ℝ)/4)^3) ((q : ℝ)/4) n := by + have hu : 0 < (q : ℝ)/4 := by positivity + rw [familyTerm_quadraticBlock hq] + unfold quadraticGrandTerm + rw [show β*γ/2*((q : ℝ)/4)^3*(n : ℝ)^2/((q : ℝ)/4)^3 = β*γ/2*(n : ℝ)^2 by field_simp] + exact mul_le_mul_of_nonneg_left + (setPartition_gridBox_le (measurable_radialPotential (measurable_physicalProfile t hσ hR hs)) + hβ hu (physicalProfile_stable ht hσ hR hs hsmall) k n) (Real.exp_pos _).le + +theorem grandFinite_quadraticBlock_box {t β μ γ : ℝ} (ht : 0 ≤ t) (hβ : 0 ≤ β) (hγ : 0 ≤ γ) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n)/2 ≤ t^2/8) {q : ℕ} (hq : 0 < q) + (hcoeff : β*γ/2*((q : ℝ)/4)^3 ≤ + β*(t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/(4+2/((q : ℝ)/4))^3) (k : Lattice) : + GrandFinite (gibbsFamily (quadraticBlock q (physicalProfile t σ R) γ) β (μ+β*γ/2)) + (gridBox ((q : ℝ)/4) k) := by + have hu : 0 < (q : ℝ)/4 := by positivity + have hC : 0 ≤ t*(∑' n, σ n)*kernelHeight := + mul_nonneg (mul_nonneg ht (tsum_nonneg hσ)) kernelHeight_pos.le + refine ⟨fun ι _ => integrableOn_gibbs_of_lower + (measurable_quadraticBlock q (measurable_physicalProfile t hσ hR hs) γ) + (add_nonneg hC hγ) hβ + (quadraticBlock_lower hC hγ (physicalProfile_ge_constant ht hσ hR hs) q) ?_ ι, ?_⟩ + · rw [volume_gridBox hu.le]; exact ENNReal.ofReal_ne_top + · exact Summable.of_nonneg_of_le (familyTerm_nonneg _ _ (gibbsFamily_nonneg _ _ _)) + (quadraticBlock_familyTerm_le ht hβ hσ hR hs hsmall hq k) + (summable_quadraticGrandTerm ht hβ hu hσ hR hs hsmall hcoeff) + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/BoundarySum.lean b/lean/OAI/Probability/ContinuumTransition/BoundarySum.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ea78ddb9207935c0564e1f197f0c1860ca08459 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/BoundarySum.lean @@ -0,0 +1,31 @@ +import OAI.Probability.ContinuumTransition.KacBlocks + +namespace OAI + +universe u_1 + +section +open scoped BigOperators +namespace ContinuumTemperature +open Classical + +theorem sum_supported_rows_le {α : Type u_1} [DecidableEq α] (s T : Finset α) (M : ℝ) (hM : 0 ≤ M) + (J : α → α → ℝ) (hrow : ∀ k : s, (∑ l : s, J k l) ≤ M) : + (∑ k : s, ∑ l : s, if (k : α) ∈ T then J k l else 0) ≤ T.card*M := by + have hh : (∑ k : s, ∑ l : s, if (k : α) ∈ T then J k l else 0) ≤ + ∑ k : s, if (k : α) ∈ T then M else 0 := by + apply Finset.sum_le_sum + intro k _ + split_ifs with hk + · simpa only [ite_eq_left hk] using hrow k + · simp only [Finset.sum_const_zero, le_refl] + apply hh.trans + rw [Finset.sum_coe_sort s (fun k : α => if k ∈ T then M else 0), ← Finset.sum_filter] + simp only [Finset.sum_const, nsmul_eq_mul] + have hs : s.filter (fun k => k ∈ T) ⊆ T := fun _ hk => (Finset.mem_filter.mp hk).2 + exact mul_le_mul_of_nonneg_right (by exact_mod_cast Finset.card_le_card hs) hM + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean b/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean new file mode 100644 index 0000000000000000000000000000000000000000..534dc2449a90d9d1c927ce6c80f5663a18842a32 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/BoxTiling.lean @@ -0,0 +1,240 @@ +import OAI.Probability.ContinuumTransition.SpatialProducts + +namespace OAI + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature + +noncomputable def tileCenter (ℓ L : ℝ) {k : ℕ} (i : Fin 3 → Fin k) : Space := + WithLp.toLp 2 (fun j => (ℓ+2)*((i j : ℝ)+1/2)-L/2) + +noncomputable def tileBox (ℓ L : ℝ) {k : ℕ} (i : Fin 3 → Fin k) : Set Space := + (fun x => x + tileCenter ℓ L i) '' cube ℓ + +theorem isCompact_tileBox (ℓ L : ℝ) {k : ℕ} (i : Fin 3 → Fin k) : + IsCompact (tileBox ℓ L i) := + (isCompact_cube ℓ).image (continuous_id.add continuous_const) + +theorem tileBox_subset {ℓ L : ℝ} {k : ℕ} (hℓ : 0 ≤ ℓ) + (hk : (k : ℝ)*(ℓ+2) ≤ L) (i : Fin 3 → Fin k) : tileBox ℓ L i ⊆ cube L := by + rintro x ⟨y, hy, rfl⟩ j + have hyj := hy j + have hij : (i j : ℝ)+1 ≤ k := by exact_mod_cast (i j).isLt + have h0 : (0 : ℝ) ≤ (i j : ℝ) := Nat.cast_nonneg _ + change y j + ((ℓ+2)*((i j : ℝ)+1/2)-L/2) ∈ Icc (-L/2) (L/2) + constructor <;> nlinarith [hyj.1, hyj.2] + +theorem tileBox_separation {ℓ L : ℝ} {k : ℕ} (hℓ : 0 ≤ ℓ) + {i j : Fin 3 → Fin k} (hij : i ≠ j) {x y : Space} + (hx : x ∈ tileBox ℓ L i) (hy : y ∈ tileBox ℓ L j) : 2 ≤ ‖x-y‖ := by + obtain ⟨a, ha, rfl⟩ := hx + obtain ⟨b, hb, rfl⟩ := hy + obtain ⟨r, hr⟩ : ∃ r, i r ≠ j r := by + by_contra! h + exact hij (funext h) + have har := ha r + have hbr := hb r + have hnorm : |(a+tileCenter ℓ L i) r - (b+tileCenter ℓ L j) r| ≤ + ‖(a+tileCenter ℓ L i)-(b+tileCenter ℓ L j)‖ := by + simpa only [PiLp.sub_apply, Real.norm_eq_abs] using + PiLp.norm_apply_le ((a+tileCenter ℓ L i)-(b+tileCenter ℓ L j)) r + change |a r + ((ℓ+2)*((i r : ℝ)+1/2)-L/2) - + (b r + ((ℓ+2)*((j r : ℝ)+1/2)-L/2))| ≤ + ‖(a+tileCenter ℓ L i)-(b+tileCenter ℓ L j)‖ at hnorm + rw [abs_le] at hnorm + rcases lt_or_gt_of_ne hr with h | h + · have hh : (i r : ℝ)+1 ≤ (j r : ℝ) := by exact_mod_cast h + have hmul := mul_le_mul_of_nonneg_left hh (by linarith : 0 ≤ ℓ+2) + nlinarith [har.1, har.2, hbr.1, hbr.2] + · have hh : (j r : ℝ)+1 ≤ (i r : ℝ) := by exact_mod_cast h + have hmul := mul_le_mul_of_nonneg_left hh (by linarith : 0 ≤ ℓ+2) + nlinarith [har.1, har.2, hbr.1, hbr.2] + +theorem tileBox_pairwiseDisjoint {ℓ L : ℝ} {k : ℕ} (hℓ : 0 ≤ ℓ) : + Pairwise (fun i j : Fin 3 → Fin k => Disjoint (tileBox ℓ L i) (tileBox ℓ L j)) := by + intro i j hij + apply Set.disjoint_left.mpr + intro x hx hy + have hh := tileBox_separation hℓ hij hx hy + simp only [sub_self, norm_zero] at hh + norm_num at hh + +theorem partition_tiling_lower {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B ℓ L : ℝ} (hβ : 0 ≤ β) (hℓ : 0 ≤ ℓ) (hL : 0 ≤ L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hsign : ∀ r, 1 ≤ r → φ r ≤ 0) + (n : (Fin 3 → Fin ⌊L/(ℓ+2)⌋₊) → ℕ) : + (∏ i, partition φ β ℓ (n i)) ≤ partition φ β L (∑ i, n i) := by + classical + have hden : 0 < ℓ+2 := by linarith + have hk : (⌊L/(ℓ+2)⌋₊ : ℝ)*(ℓ+2) ≤ L := by + apply (le_div_iff₀ hden).mp + exact Nat.floor_le (div_nonneg hL hden.le) + have hh := setPartition_product_lower hφ hβ hstable (tileBox ℓ L) n Finset.univ + (fun i _ => (isCompact_tileBox ℓ L i).measurableSet) + (fun i _ j _ hij => tileBox_pairwiseDisjoint hℓ hij) + (fun i _ j _ hij a ha b hb => hsign _ (le_trans (by norm_num) + (tileBox_separation hℓ hij ha hb))) + (isCompact_cube L).measure_lt_top.ne (fun i _ => tileBox_subset hℓ hk i) + have hv (i : Fin 3 → Fin ⌊L/(ℓ+2)⌋₊) : + setPartition φ β (tileBox ℓ L i) (n i) = partition φ β ℓ (n i) := by + rw [tileBox, setPartition_translate, setPartition, generalPartition_eq_partition] + simp_rw [hv] at hh + simpa only [setPartition, generalPartition_eq_partition] using hh + +theorem exists_concentrated_counts (K H N : ℕ) (hN : N ≤ K*H) : + ∃ r : Fin K → ℕ, (∑ i, r i) = N ∧ (∀ i, r i ≤ H) ∧ + (∑ i, if r i = 0 then 0 else 1) * H ≤ N+H := by + induction K generalizing N with + | zero => + have hzero : N = 0 := by omega + subst N + exact ⟨Fin.elim0, by simp, (fun i => Fin.elim0 i), by simp⟩ + | succ K ih => + by_cases hh : N ≤ H + · refine ⟨Fin.cons N (fun _ => 0), ?_, ?_, ?_⟩ + · simp [Fin.sum_univ_succ] + · intro i + refine Fin.cases hh (fun _ => Nat.zero_le _) i + · simp only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, ite_true, Finset.sum_const_zero, + add_zero] + split_ifs <;> omega + · have hHK : N-H ≤ K*H := by + rw [Nat.succ_mul] at hN + omega + obtain ⟨r, hr, hbound, hc⟩ := ih (N-H) hHK + have hH : 0 < H := by + by_contra hzero + have hz : H = 0 := by omega + simp only [hz, Nat.mul_zero, Nat.le_zero] at hN + omega + refine ⟨Fin.cons H r, ?_, ?_, ?_⟩ + · simp only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, hr] + omega + · intro i + exact Fin.cases (le_refl H) hbound i + · simp only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, ite_eq_right hH.ne'] + have hsub := Nat.sub_add_cancel (show H ≤ N by omega) + nlinarith + +theorem exists_adjusted_counts (K b H N : ℕ) (hb : 0 < b) (hH : 2*b ≤ H) + (hN : N ≤ K*H) : + ∃ r : Fin K → ℕ, (∑ i, r i) = N ∧ (∀ i, r i ≤ H) ∧ + ((∑ i, if r i = b then 0 else 1 : ℕ) : ℝ) * b ≤ + |(N : ℝ) - (K : ℝ)*b| + H := by + have hbH : b ≤ H := by omega + by_cases hNb : K*b ≤ N + · have hdel : N-K*b ≤ K*(H-b) := by + rw [Nat.mul_sub_left_distrib] + omega + obtain ⟨d, hsum, hbound, hc⟩ := exists_concentrated_counts K (H-b) (N-K*b) hdel + refine ⟨fun i => b+d i, ?_, ?_, ?_⟩ + · simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, smul_eq_mul, hsum] + omega + · intro i + change b+d i ≤ H + have hh := hbound i + omega + · have heq : (∑ i, if b+d i = b then 0 else 1 : ℕ) = + ∑ i, if d i = 0 then 0 else 1 := by + apply Finset.sum_congr rfl + intro i _ + simp only [Nat.add_eq_left] + rw [heq] + have hineq : (∑ i, if d i = 0 then 0 else 1) * b ≤ (N-K*b)+H := by + have hh := Nat.mul_le_mul_left (∑ i, if d i = 0 then 0 else 1) (show b ≤ H-b by omega) + omega + have hsub : ((N-K*b : ℕ) : ℝ) = (N : ℝ)-(K : ℝ)*b := by + rw [Nat.cast_sub hNb, Nat.cast_mul] + have hsgn : 0 ≤ (N : ℝ)-(K : ℝ)*b := by + have hh : (K : ℝ)*b ≤ (N : ℝ) := by exact_mod_cast hNb + linarith + rw [abs_of_nonneg hsgn] + have hh : ((∑ i, if d i = 0 then 0 else 1 : ℕ) : ℝ)*b ≤ ((N-K*b : ℕ) : ℝ)+H := by + exact_mod_cast hineq + rwa [hsub] at hh + · have hNb' : N ≤ K*b := by omega + obtain ⟨d, hsum, hbound, hc⟩ := exists_concentrated_counts K b (K*b-N) (Nat.sub_le _ _) + refine ⟨fun i => b-d i, ?_, ?_, ?_⟩ + · have hh : (∑ i : Fin K, (b - d i)) + (∑ i : Fin K, d i) = K*b := by + rw [← Finset.sum_add_distrib] + simp only [Nat.sub_add_cancel (hbound _), Finset.sum_const, Finset.card_univ, + Fintype.card_fin, smul_eq_mul] + change (∑ i : Fin K, (b - d i)) = N + rw [hsum] at hh + omega + · intro i + exact (Nat.sub_le b _).trans hbH + · have heq : (∑ i, if b-d i = b then 0 else 1 : ℕ) = + ∑ i, if d i = 0 then 0 else 1 := by + apply Finset.sum_congr rfl + intro i _ + have hh : b-d i = b ↔ d i = 0 := by omega + simp only [hh] + rw [heq] + have hineq : (∑ i, if d i = 0 then 0 else 1) * b ≤ (K*b-N)+H := by omega + have hsub : ((K*b-N : ℕ) : ℝ) = (K : ℝ)*b-N := by + rw [Nat.cast_sub hNb', Nat.cast_mul] + have hsgn : (N : ℝ)-(K : ℝ)*b ≤ 0 := by + have hh : (N : ℝ) ≤ (K : ℝ)*b := by exact_mod_cast hNb' + linarith + rw [abs_of_nonpos hsgn] + have hh : ((∑ i, if d i = 0 then 0 else 1 : ℕ) : ℝ)*b ≤ ((K*b-N : ℕ) : ℝ)+H := by + exact_mod_cast hineq + rw [hsub] at hh + linarith + +noncomputable def tileCount (ℓ L : ℝ) : ℕ := ⌊L/(ℓ+2)⌋₊ ^ 3 + +theorem sum_baseline_le {K b H : ℕ} {r : Fin K → ℕ} {a : ℕ → ℝ} {M : ℝ} + (hr : ∀ i, r i ≤ H) (ha : ∀ n, n ≤ H → a n ≤ M) (hb : -M ≤ a b) : + ∑ i, a (r i) ≤ K*a b + 2*M*(∑ i, if r i = b then 0 else 1 : ℕ) := by + classical + calc + ∑ i, a (r i) ≤ ∑ i, (a b + 2*M*(if r i = b then 0 else 1 : ℕ)) := by + apply Finset.sum_le_sum + intro i _ + by_cases hh : r i = b + · simp [hh] + · simp only [ite_eq_right hh, Nat.cast_one, mul_one] + linarith [ha (r i) (hr i)] + _ = _ := by + rw [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + nsmul_eq_mul, ← Finset.mul_sum, Nat.cast_sum] + +theorem adjusted_box_comparison (a : ℝ → ℕ → ℝ) {ℓ L M : ℝ} {b H N : ℕ} + (hℓ : 0 < ℓ) (hL : 0 < L) (hM : 0 ≤ M) (hb : 0 < b) (hH : 2*b ≤ H) + (hN : N ≤ tileCount ℓ L * H) + (hbox : ∀ r : Fin (tileCount ℓ L) → ℕ, (∑ i, r i) = N → + a L N ≤ ℓ^3/L^3 * ∑ i, a ℓ (r i)) + (hbound : ∀ n, n ≤ H → a ℓ n ≤ M) (hbase : -M ≤ a ℓ b) : + a L N ≤ ((tileCount ℓ L : ℝ)/L^3)*ℓ^3*a ℓ b + + (2*M*ℓ^3/(b : ℝ)) * (|(N : ℝ)/L^3 - ((tileCount ℓ L : ℝ)/L^3)*b| + H/L^3) := by + classical + obtain ⟨r, hr, hcounts, hchange⟩ := exists_adjusted_counts (tileCount ℓ L) b H N hb hH hN + have hs := sum_baseline_le hcounts hbound hbase + have hm : 0 ≤ ℓ^3/L^3 := div_nonneg (pow_nonneg hℓ.le _) (pow_nonneg hL.le _) + have hbR : (0 : ℝ) < b := by exact_mod_cast hb + have hc : (∑ i, if r i = b then 0 else 1 : ℕ) ≤ + (|(N : ℝ) - (tileCount ℓ L : ℝ)*b|+H)/(b : ℝ) := + (le_div_iff₀ hbR).2 hchange + calc + a L N ≤ ℓ^3/L^3 * ∑ i, a ℓ (r i) := hbox r hr + _ ≤ ℓ^3/L^3 * ((tileCount ℓ L : ℝ)*a ℓ b + + 2*M*((|(N : ℝ)-(tileCount ℓ L : ℝ)*b|+H)/(b : ℝ))) := by + apply mul_le_mul_of_nonneg_left _ hm + exact hs.trans (add_le_add le_rfl (mul_le_mul_of_nonneg_left hc (show 0 ≤ 2*M by positivity))) + _ = _ := by + have heq : (N : ℝ)/L^3 - ((tileCount ℓ L : ℝ)/L^3)*b = + ((N : ℝ)-(tileCount ℓ L : ℝ)*b)/L^3 := by ring + rw [heq, abs_div, abs_of_pos (pow_pos hL 3)] + ring + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CanonicalIntegral.lean b/lean/OAI/Probability/ContinuumTransition/CanonicalIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..a744046b4812fa0c79baf060703d547ede2fcfa9 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CanonicalIntegral.lean @@ -0,0 +1,359 @@ +import OAI.Probability.ContinuumTransition.CubeCoercivity + +namespace OAI + +universe u_1 + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set + +namespace ContinuumTemperature + +@[simp] theorem radialPotential_ne_bot (φ : ℝ → ℝ) (x : Space) : + radialPotential φ x ≠ ⊥ := by + unfold radialPotential + split_ifs + · exact top_ne_bot + · exact EReal.coe_ne_bot _ + +theorem ereal_sum_ne_bot {α : Type u_1} (s : Finset α) (f : α → EReal) + (hf : ∀ i ∈ s, f i ≠ ⊥) : ∑ i ∈ s, f i ≠ ⊥ := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + rw [Finset.sum_insert hi, EReal.add_ne_bot_iff] + exact ⟨hf i (Finset.mem_insert_self i s), ih (fun j hj => hf j (Finset.mem_insert_of_mem hj))⟩ + +theorem measurable_energy {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + (N : ℕ) : Measurable (fun x : Fin N → Space => energy φ x) := by + classical + unfold energy + fun_prop + +theorem measurable_boltzmann {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + (β : ℝ) (N : ℕ) : Measurable (fun x : Fin N → Space => boltzmann φ β x) := by + have hE := measurable_energy hφ N + exact Measurable.ite (hE (measurableSet_singleton ⊤)) measurable_const + ((measurable_const.mul hE.ereal_toReal).exp) + +theorem boltzmann_nonneg (φ : ℝ → ℝ) (β : ℝ) {N : ℕ} (x : Fin N → Space) : + 0 ≤ boltzmann φ β x := by + unfold boltzmann + split_ifs + · rfl + · exact (Real.exp_pos _).le + +theorem boltzmann_le_of_stable {φ : ℝ → ℝ} {β B : ℝ} (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + {N : ℕ} (x : Fin N → Space) : + boltzmann φ β x ≤ Real.exp (β * B * N) := by + unfold boltzmann + split_ifs with htop + · exact (Real.exp_pos _).le + · apply Real.exp_le_exp.mpr + have he := EReal.toReal_le_toReal (hstable N x) (EReal.coe_ne_bot _) htop + simp only [EReal.toReal_coe] at he + nlinarith [mul_le_mul_of_nonneg_left he hβ] + +theorem isCompact_cube (L : ℝ) : IsCompact (cube L) := by + have h := isCompact_pi_infinite (fun _ : Fin 3 => isCompact_Icc (a := -L / 2) (b := L / 2)) + exact (PiLp.homeomorph 2 (fun _ : Fin 3 => ℝ)).isCompact_preimage.mpr h + +theorem measurableSet_cube (L : ℝ) : MeasurableSet (cube L) := + (isCompact_cube L).measurableSet + +theorem isCompact_configurations (L : ℝ) (N : ℕ) : + IsCompact {x : Fin N → Space | ∀ i, x i ∈ cube L} := + isCompact_pi_infinite (fun _ => isCompact_cube L) + +theorem integrableOn_boltzmann {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B : ℝ} (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (L : ℝ) (N : ℕ) : + IntegrableOn (fun x : Fin N → Space => boltzmann φ β x) + {x : Fin N → Space | ∀ i, x i ∈ cube L} := by + have hK := isCompact_configurations L N + have : IsFiniteMeasure (volume.restrict {x : Fin N → Space | ∀ i, x i ∈ cube L}) := + ⟨by simpa only [Measure.restrict_apply_univ] using hK.measure_lt_top (μ := volume)⟩ + apply (integrable_const (Real.exp (β * B * N))).mono' + (measurable_boltzmann hφ β N).aestronglyMeasurable + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_nonneg (boltzmann_nonneg φ β x)] + exact boltzmann_le_of_stable hβ hstable x + +theorem energy_eq_real_of_injective (φ : ℝ → ℝ) {N : ℕ} {x : Fin N → Space} + (hx : Function.Injective x) : + energy φ x = ((∑ i : Fin N, ∑ j ∈ Finset.univ.filter (fun j : Fin N => i < j), + φ ‖x i - x j‖ : ℝ) : EReal) := by + classical + unfold energy + simp only [ereal_coe_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j hj + have hij : i ≠ j := ne_of_lt (Finset.mem_filter.mp hj).2 + exact ite_eq_right (sub_ne_zero.mpr (hx.ne hij)) + +theorem boltzmann_pos_of_injective (φ : ℝ → ℝ) (β : ℝ) {N : ℕ} + {x : Fin N → Space} (hx : Function.Injective x) : 0 < boltzmann φ β x := by + unfold boltzmann + rw [ite_eq_right (by rw [energy_eq_real_of_injective φ hx]; exact EReal.coe_ne_top _)] + exact Real.exp_pos _ + +def openConfigurations (L : ℝ) (N : ℕ) : Set (Fin N → Space) := + {x | (∀ i k, x i k ∈ Ioo (-L / 2) (L / 2)) ∧ Function.Injective x} + +theorem isOpen_openConfigurations (L : ℝ) (N : ℕ) : + IsOpen (openConfigurations L N) := by + have hbox : IsOpen {x : Fin N → Space | ∀ i k, x i k ∈ Ioo (-L / 2) (L / 2)} := by + simp only [ofPred_forall] + apply isOpen_iInter_of_finite + intro i + apply isOpen_iInter_of_finite + intro k + exact isOpen_Ioo.preimage ((PiLp.continuous_apply 2 (fun _ : Fin 3 => ℝ) k).comp + (continuous_apply i)) + have hinj : IsOpen {x : Fin N → Space | Function.Injective x} := by + have heq : {x : Fin N → Space | Function.Injective x} = + ⋂ i, ⋂ j, ⋂ (_ : i ≠ j), {x | x i ≠ x j} := by + ext x + simp only [mem_ofPred_eq, mem_iInter] + exact ⟨fun h i j hij => h.ne hij, fun h i j hij => by_contra fun hij' => h i j hij' hij⟩ + rw [heq] + apply isOpen_iInter_of_finite + intro i + apply isOpen_iInter_of_finite + intro j + apply isOpen_iInter_of_finite + intro _ + exact (isClosed_eq (continuous_apply i) (continuous_apply j)).isOpen_compl + exact hbox.inter hinj + +theorem openConfigurations_nonempty {L : ℝ} (hL : 0 < L) (N : ℕ) : + (openConfigurations L N).Nonempty := by + let c : ℝ := L / (4 * ((N : ℝ) + 1)) + have hc : 0 < c := by dsimp [c]; positivity + let x : Fin N → Space := fun i => WithLp.toLp 2 (fun _ : Fin 3 => (i : ℝ) * c) + refine ⟨x, ?_, ?_⟩ + · intro i k + change -L / 2 < (i : ℝ) * c ∧ (i : ℝ) * c < L / 2 + have hi : (i : ℝ) < N := by exact_mod_cast i.isLt + have hinonneg : 0 ≤ (i : ℝ) := by positivity + constructor + · nlinarith [mul_nonneg hinonneg hc.le] + · dsimp [c] + rw [← mul_div_assoc, div_lt_iff₀ (by positivity)] + nlinarith [mul_pos hL (by exact_mod_cast Nat.zero_lt_succ N : 0 < (N : ℝ) + 1)] + · intro i j he + have hij := congrArg (fun y : Space => y 0) he + change (i : ℝ) * c = (j : ℝ) * c at hij + have hij' := mul_right_cancel₀ hc.ne' hij + exact Fin.ext (by exact_mod_cast hij') + +theorem partition_pos {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B L : ℝ} (hβ : 0 ≤ β) (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (N : ℕ) : 0 < partition φ β L N := by + classical + unfold partition + split_ifs + · norm_num + · apply mul_pos (by positivity) + rw [setIntegral_pos_iff_support_of_nonneg_ae + (ae_of_all _ (boltzmann_nonneg φ β)) (integrableOn_boltzmann hφ hβ hstable L N)] + apply lt_of_lt_of_le ((isOpen_openConfigurations L N).measure_pos volume + (openConfigurations_nonempty hL N)) + apply measure_mono + intro x hx + exact ⟨(boltzmann_pos_of_injective φ β hx.2).ne', + fun i k => ⟨(hx.1 i k).1.le, (hx.1 i k).2.le⟩⟩ + +theorem boltzmann_add (φ : ℝ → ℝ) (β γ : ℝ) {N : ℕ} (x : Fin N → Space) : + boltzmann φ (β + γ) x = boltzmann φ β x * boltzmann φ γ x := by + unfold boltzmann + split_ifs + · ring + · rw [← Real.exp_add] + congr 1 + ring + +theorem boltzmann_rpow (φ : ℝ → ℝ) (β : ℝ) {p : ℝ} (hp : 0 < p) + {N : ℕ} (x : Fin N → Space) : + boltzmann φ β x ^ p = boltzmann φ (p * β) x := by + unfold boltzmann + split_ifs + · exact Real.zero_rpow hp.ne' + · rw [← Real.exp_mul] + congr 1 + ring + +theorem integral_boltzmann_logconvex {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {B : ℝ} + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (L : ℝ) (N : ℕ) {β γ a b : ℝ} + (hβ : 0 < β) (hγ : 0 < γ) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) : + (∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ (a * β + b * γ) x) ≤ + (∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ β x) ^ a * + (∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ γ x) ^ b := by + let μ : Measure (Fin N → Space) := + volume.restrict {x : Fin N → Space | ∀ i, x i ∈ cube L} + have hp (c u : ℝ) (hc : 0 < c) (x : Fin N → Space) : + ‖boltzmann φ (c * u) x‖ ^ (1 / c) = boltzmann φ u x := by + rw [Real.norm_eq_abs, abs_of_nonneg (boltzmann_nonneg φ (c * u) x), + boltzmann_rpow φ (c * u) (one_div_pos.mpr hc)] + congr 1 + field_simp + have hLp (c u : ℝ) (hc : 0 < c) (hu : 0 < u) : + MemLp (fun x : Fin N → Space => boltzmann φ (c * u) x) (ENNReal.ofReal (1 / c)) μ := by + have A : ENNReal.ofReal (1 / c) ≠ 0 := by positivity + have B' : ENNReal.ofReal (1 / c) ≠ ∞ := ENNReal.ofReal_ne_top + rw [← memLp_norm_rpow_iff _ A B', ENNReal.toReal_ofReal (by positivity : 0 ≤ 1 / c), + ENNReal.div_self A B', memLp_one_iff_integrable] + · apply (integrableOn_boltzmann hφ hu.le hstable L N).congr + exact ae_of_all _ (fun x => (hp c u hc x).symm) + · exact (measurable_boltzmann hφ (c * u) N).aestronglyMeasurable + have hHolder := integral_mul_le_Lp_mul_Lq_of_nonneg + (Real.holderConjugate_one_div ha hb hab) + (ae_of_all μ (boltzmann_nonneg φ (a * β))) + (ae_of_all μ (boltzmann_nonneg φ (b * γ))) + (hLp a β ha hβ) (hLp b γ hb hγ) + simp only [one_div_one_div] at hHolder + convert hHolder using 1 + · exact integral_congr_ae (ae_of_all μ (boltzmann_add φ (a * β) (b * γ))) + · congr 2 + · apply integral_congr_ae + filter_upwards [] with x + simpa only [Real.norm_eq_abs, abs_of_nonneg (boltzmann_nonneg φ (a * β) x)] + using (hp a β ha x).symm + · apply integral_congr_ae + filter_upwards [] with x + simpa only [Real.norm_eq_abs, abs_of_nonneg (boltzmann_nonneg φ (b * γ) x)] + using (hp b γ hb x).symm + +theorem integral_boltzmann_pos {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B L : ℝ} (hβ : 0 ≤ β) (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (N : ℕ) : + 0 < ∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ β x := by + rw [setIntegral_pos_iff_support_of_nonneg_ae + (ae_of_all _ (boltzmann_nonneg φ β)) (integrableOn_boltzmann hφ hβ hstable L N)] + apply lt_of_lt_of_le ((isOpen_openConfigurations L N).measure_pos volume + (openConfigurations_nonempty hL N)) + apply measure_mono + intro x hx + exact ⟨(boltzmann_pos_of_injective φ β hx.2).ne', + fun i k => ⟨(hx.1 i k).1.le, (hx.1 i k).2.le⟩⟩ + +theorem convexOn_log_integral_boltzmann {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {B L : ℝ} (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (N : ℕ) : ConvexOn ℝ (Ioi 0) (fun β => Real.log + (∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ β x)) := by + refine convexOn_iff_forall_pos.mpr ⟨convex_Ioi _, ?_⟩ + intro β hβ γ hγ a b ha hb hab + simp only [smul_eq_mul] + have hβ' := integral_boltzmann_pos hφ hβ.le hL hstable N + have hγ' := integral_boltzmann_pos hφ hγ.le hL hstable N + have hac : 0 < a * β + b * γ := add_pos (mul_pos ha hβ) (mul_pos hb hγ) + have hc := integral_boltzmann_pos hφ hac.le hL hstable N + have hHolder := integral_boltzmann_logconvex hφ hstable L N hβ hγ ha hb hab + calc + _ ≤ Real.log ((∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ β x) ^ a * + (∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ γ x) ^ b) := + Real.log_le_log hc hHolder + _ = _ := by rw [Real.log_mul (Real.rpow_pos_of_pos hβ' a).ne' (Real.rpow_pos_of_pos hγ' b).ne', + Real.log_rpow hβ', Real.log_rpow hγ'] + +theorem convexOn_log_partition {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {B L : ℝ} (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (N : ℕ) : ConvexOn ℝ (Ioi 0) (fun β => Real.log (partition φ β L N)) := by + by_cases hN : N = 0 + · simp only [hN, partition, ↓reduceIte, Real.log_one] + exact convexOn_const _ (convex_Ioi _) + · have hlog (β : ℝ) (hβ : 0 < β) : Real.log (partition φ β L N) = + Real.log (1 / (N.factorial : ℝ)) + Real.log + (∫ x in {x : Fin N → Space | ∀ i, x i ∈ cube L}, boltzmann φ β x) := by + unfold partition + rw [ite_eq_right hN, Real.log_mul (one_div_ne_zero (Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero N))) + (integral_boltzmann_pos hφ hβ.le hL hstable N).ne'] + have hc := convexOn_log_integral_boltzmann hφ hL hstable N + refine convexOn_iff_forall_pos.mpr ⟨convex_Ioi _, ?_⟩ + intro β hβ γ hγ a b ha hb hab + simp only [smul_eq_mul] + rw [hlog _ (add_pos (mul_pos ha hβ) (mul_pos hb hγ)), hlog β hβ, hlog γ hγ] + have hi := hc.2 hβ hγ ha.le hb.le hab + simp only [smul_eq_mul] at hi + have hcst : a * Real.log (1 / (N.factorial : ℝ)) + + b * Real.log (1 / (N.factorial : ℝ)) = Real.log (1 / (N.factorial : ℝ)) := by + rw [← add_mul, hab, one_mul] + nlinarith only [hi, hcst] + +theorem volume_cube (L : ℝ) : volume (cube L) = (ENNReal.ofReal L) ^ 3 := by + have heq : cube L = (@WithLp.ofLp 2 (Fin 3 → ℝ)) ⁻¹' + (Set.pi Set.univ (fun _ : Fin 3 => Icc (-L / 2) (L / 2))) := by + ext x + simp only [cube, mem_preimage, mem_ofPred_eq, Set.mem_pi, mem_univ, forall_const] + rw [heq, (PiLp.volume_preserving_ofLp (Fin 3)).measure_preimage + ((MeasurableSet.pi Set.countable_univ (fun _ _ => measurableSet_Icc)).nullMeasurableSet)] + change (Measure.pi (fun _ : Fin 3 => (volume : Measure ℝ))) _ = _ + rw [Measure.pi_pi] + simp only [Real.volume_Icc] + have ha : L / 2 - -L / 2 = L := by ring + simp [ha] + +theorem volume_configurations (L : ℝ) (N : ℕ) : + volume {x : Fin N → Space | ∀ i, x i ∈ cube L} = (ENNReal.ofReal L) ^ (3 * N) := by + have heq : {x : Fin N → Space | ∀ i, x i ∈ cube L} = + Set.pi Set.univ (fun _ : Fin N => cube L) := by ext x; simp + rw [heq] + change (Measure.pi (fun _ : Fin N => (volume : Measure Space))) _ = _ + rw [Measure.pi_pi] + simp only [volume_cube, Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← pow_mul] + +theorem partition_nonneg (φ : ℝ → ℝ) (β L : ℝ) (N : ℕ) : + 0 ≤ partition φ β L N := by + unfold partition + split_ifs + · norm_num + · apply mul_nonneg (by positivity) + exact integral_nonneg (boltzmann_nonneg φ β) + +theorem partition_le_exp_of_stable {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B L : ℝ} (hβ : 0 ≤ β) (hL : 0 ≤ L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) (N : ℕ) : + partition φ β L N ≤ (L ^ 3 * Real.exp (β * B)) ^ N / (N.factorial : ℝ) := by + by_cases hN : N = 0 + · simp [hN, partition] + · have : IsFiniteMeasure (volume.restrict {x : Fin N → Space | ∀ i, x i ∈ cube L}) := + ⟨by simpa only [Measure.restrict_apply_univ] using + (isCompact_configurations L N).measure_lt_top (μ := volume)⟩ + have hi := integral_mono_ae (integrableOn_boltzmann hφ hβ hstable L N) + (integrable_const (Real.exp (β * B * N))) + (ae_of_all _ (boltzmann_le_of_stable hβ hstable (N := N))) + rw [integral_const] at hi + simp only [Measure.real, Measure.restrict_apply_univ, volume_configurations, + ENNReal.toReal_pow, ENNReal.toReal_ofReal hL, smul_eq_mul] at hi + unfold partition + rw [ite_eq_right hN] + have hfac : 0 ≤ (1 / (N.factorial : ℝ)) := by positivity + apply (mul_le_mul_of_nonneg_left hi hfac).trans_eq + rw [show β * B * (N : ℝ) = (N : ℝ) * (β * B) by ring, Real.exp_nat_mul, + mul_pow, pow_mul] + ring + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CanonicalLimit.lean b/lean/OAI/Probability/ContinuumTransition/CanonicalLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ed40b935706b7856fbf98bd83363a281cede3c1 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CanonicalLimit.lean @@ -0,0 +1,234 @@ +import OAI.Probability.ContinuumTransition.DensityLimit + +namespace OAI + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature + +noncomputable def finiteCanonical (φ : ℝ → ℝ) (β L : ℝ) (N : ℕ) : ℝ := + -Real.log (partition φ β L N)/L^3 + +@[simp] theorem finiteCanonical_zero (φ : ℝ → ℝ) (β L : ℝ) : + finiteCanonical φ β L 0 = 0 := by simp [finiteCanonical, partition] + +theorem finiteCanonical_lower_constant {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B L : ℝ} (hβ : 0 ≤ β) (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B*(N : ℝ) : ℝ) : EReal) ≤ energy φ x) (N : ℕ) : + -Real.exp (β*B) ≤ finiteCanonical φ β L N := by + have hc := (summable_grandPartition hφ hβ hL.le hstable 1 0).le_tsum N + (fun n _ => mul_nonneg (Real.exp_pos _).le (partition_nonneg φ β L n)) + have hc' : partition φ β L N ≤ grandPartition φ 1 β 0 L := by + simpa only [mul_zero, zero_mul, Real.exp_zero, one_mul, grandPartition] using hc + have hZ := hc'.trans (grandPartition_le_exp hφ hβ hL.le hstable 1 0) + simp only [mul_zero, zero_add] at hZ + have hlog := Real.log_le_log (partition_pos hφ hβ hL hstable N) hZ + rw [Real.log_exp] at hlog + unfold finiteCanonical + apply (le_div_iff₀ (pow_pos hL 3)).2 + nlinarith only [hlog] + +theorem finiteCanonical_upper_trial {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {q t β B L D : ℝ} (hq : 0 < q) (ht : 1 < t) (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B*(N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) + (hL : 8*q ≤ L) (hD : D ≤ (2*q)⁻¹^3) {N : ℕ} (hN : (N : ℝ) ≤ D*L^3) : + finiteCanonical φ β L N ≤ (β*trialEnergyConstant t q-Real.log (trialVolume q)) * (N : ℝ)/L^3 := by + have hpos : 0 < trialVolume q ^ N * Real.exp (-β*(trialEnergyConstant t q*N)) := by + exact mul_pos (pow_pos (trialVolume_pos hq) N) (Real.exp_pos _) + have hlow := partition_trial_lower hφ hq ht hβ hstable hcore hL hD hN + have hlog := Real.log_le_log hpos hlow + rw [Real.log_mul (pow_pos (trialVolume_pos hq) N).ne' (Real.exp_pos _).ne', + Real.log_pow, Real.log_exp] at hlog + unfold finiteCanonical + apply div_le_div_of_nonneg_right _ (pow_nonneg (by linarith : 0 ≤ L) 3) + nlinarith only [hlog] + +theorem finiteCanonical_densityBounded {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {t β B : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B*(N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) : + DensityBounded (finiteCanonical φ β) := by + intro D hD + let q : ℝ := (2*(D+1))⁻¹ + have hq : 0 < q := by dsimp [q]; positivity + have hdmesh : D ≤ (2*q)⁻¹^3 := by + have hh : (2*q)⁻¹ = D+1 := by dsimp [q]; field_simp + rw [hh] + nlinarith [sq_nonneg D] + let C : ℝ := |β*trialEnergyConstant t q-Real.log (trialVolume q)| + refine ⟨Real.exp (β*B)+C*D+1, 8*q, by dsimp [C]; positivity, by positivity, ?_⟩ + intro L hL N hN + have hLpos : 0 < L := lt_of_lt_of_le (by positivity) hL + have hlo := finiteCanonical_lower_constant hφ hβ hLpos hstable N + have hup := finiteCanonical_upper_trial hφ hq ht hβ hstable hcore hL hdmesh hN + have hup' : finiteCanonical φ β L N ≤ C*D := by + calc + _ ≤ (β*trialEnergyConstant t q-Real.log (trialVolume q)) * ((N : ℝ)/L^3) := by + simpa only [mul_div_assoc] using hup + _ ≤ C*((N : ℝ)/L^3) := mul_le_mul_of_nonneg_right (le_abs_self _) + (div_nonneg (Nat.cast_nonneg _) (pow_nonneg hLpos.le 3)) + _ ≤ C*D := mul_le_mul_of_nonneg_left ((div_le_iff₀ (pow_pos hLpos 3)).2 hN) (abs_nonneg _) + apply abs_le.mpr + have hCD : 0 ≤ C*D := mul_nonneg (abs_nonneg _) hD.le + have he := (Real.exp_pos (β*B)).le + constructor <;> linarith + +theorem finiteCanonical_hasBoxInequality {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {β B : ℝ} (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B*(N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hsign : ∀ r, 1 ≤ r → φ r ≤ 0) : HasBoxInequality (finiteCanonical φ β) := by + intro ℓ L hℓ hL r + classical + let e : (Fin 3 → Fin ⌊L/(ℓ+2)⌋₊) ≃ Fin (tileCount ℓ L) := + Fintype.equivFinOfCardEq (by simp [tileCount]) + have htile := partition_tiling_lower hφ hβ hℓ.le hL.le hstable hsign (fun i => r (e i)) + rw [e.sum_comp] at htile + have hprod := e.prod_comp (fun i => partition φ β ℓ (r i)) + rw [hprod] at htile + have hlog := Real.log_le_log (Finset.prod_pos (fun i _ => partition_pos hφ hβ hℓ hstable (r i))) htile + rw [Real.log_prod (fun i _ => (partition_pos hφ hβ hℓ hstable (r i)).ne')] at hlog + unfold finiteCanonical + calc + -Real.log (partition φ β L (∑ i, r i))/L^3 ≤ -(∑ i, Real.log (partition φ β ℓ (r i)))/L^3 := + div_le_div_of_nonneg_right (neg_le_neg hlog) (pow_nonneg hL.le 3) + _ = ℓ^3/L^3 * ∑ i, -Real.log (partition φ β ℓ (r i))/ℓ^3 := by + rw [← Finset.sum_div, Finset.sum_neg_distrib] + field_simp + +theorem exists_canonical_density_limit {φ : ℝ → ℝ} (hφ : Measurable (radialPotential φ)) + {t β B : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B*(N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) {d : ℝ} (hd : 0 < d) : + ∃ I : ℝ, Tendsto (fun p : ℝ × ℕ => finiteCanonical φ β p.1 p.2) (densityFilter d) (𝓝 I) := by + apply exists_density_limit (finiteCanonical_densityBounded hφ ht hβ hstable hcore) + (finiteCanonical_hasBoxInequality hφ hβ hstable _) hd + intro r hr + exact (hcore r (lt_of_lt_of_le (by norm_num) hr)).trans_eq (coreProfile_eq_zero ht hr) + +theorem finiteCanonical_lower_entropy {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B L : ℝ} (hβ : 0 ≤ β) (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) (N : ℕ) : + -β * B * ((N : ℝ) / L ^ 3) + ((N : ℝ) / L ^ 3) * Real.log ((N : ℝ) / L ^ 3) + - (N : ℝ) / L ^ 3 ≤ finiteCanonical φ β L N := by + by_cases hN : N = 0 + · simp [hN] + have hh := neg_log_partition_lower hφ hβ hL hstable hN + (fun x _ => hstable N x) + have hh' := div_le_div_of_nonneg_right hh (pow_pos hL 3).le + unfold finiteCanonical + calc + _ = (β * (-B * (N : ℝ)) + N * Real.log ((N : ℝ) / L ^ 3) - N) / L ^ 3 := by ring + _ ≤ _ := hh' + +theorem finiteCanonical_tendsto_zero_density {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {t β B : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) : + Tendsto (fun p : ℝ × ℕ => finiteCanonical φ β p.1 p.2) (densityFilter 0) (𝓝 0) := by + have hden := densityFilter_density 0 + have hlo : Tendsto (fun p : ℝ × ℕ => + -β * B * ((p.2 : ℝ) / p.1 ^ 3) + ((p.2 : ℝ) / p.1 ^ 3) * + Real.log ((p.2 : ℝ) / p.1 ^ 3) - (p.2 : ℝ) / p.1 ^ 3) + (densityFilter 0) (𝓝 0) := by + simpa only [mul_zero, Real.log_zero, add_zero, sub_zero, Function.comp_def] using + ((hden.const_mul (-β * B)).add (Real.continuous_mul_log.tendsto 0 |>.comp hden)).sub hden + let C := β * trialEnergyConstant t (1/2) - Real.log (trialVolume (1/2)) + have hup : Tendsto (fun p : ℝ × ℕ => C * ((p.2 : ℝ) / p.1 ^ 3)) + (densityFilter 0) (𝓝 0) := by + simpa only [mul_zero] using hden.const_mul C + apply tendsto_of_tendsto_of_tendsto_of_le_of_le' hlo hup + · filter_upwards [(densityFilter_length 0).eventually (eventually_gt_atTop 0)] with p hp + exact finiteCanonical_lower_entropy hφ hβ hp hstable p.2 + · filter_upwards [(densityFilter_length 0).eventually (eventually_ge_atTop 4), + hden.eventually (eventually_le_nhds (by norm_num : (0 : ℝ) < 1))] with p hp hpd + have hL : 0 < p.1 := by linarith + have hh := finiteCanonical_upper_trial hφ (by norm_num : (0 : ℝ) < 1 / 2) + ht hβ hstable hcore (by linarith : 8*(1/2 : ℝ) ≤ p.1) + (by norm_num : (1 : ℝ) ≤ (2*(1/2))⁻¹^3) + ((div_le_iff₀ (pow_pos hL 3)).1 hpd) + simpa only [C, mul_div_assoc] using hh + +noncomputable def canonicalDensity (φ : ℝ → ℝ) (β d : ℝ) : ℝ := + liminf (fun p : ℝ × ℕ => finiteCanonical φ β p.1 p.2) (densityFilter d) + +theorem finiteCanonical_tendsto {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {t β B d : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) (hd : 0 ≤ d) : + Tendsto (fun p : ℝ × ℕ => finiteCanonical φ β p.1 p.2) + (densityFilter d) (𝓝 (canonicalDensity φ β d)) := by + let : Fact (0 ≤ d) := ⟨hd⟩ + obtain hzero | hpos := hd.eq_or_lt + · subst d + have hz := finiteCanonical_tendsto_zero_density hφ ht hβ hstable hcore + simpa only [canonicalDensity, hz.liminf_eq] using hz + · obtain ⟨I, hI⟩ := exists_canonical_density_limit hφ ht hβ hstable hcore hpos + simpa only [canonicalDensity, hI.liminf_eq] using hI + +@[simp] theorem canonicalDensity_zero {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {t β B : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) : canonicalDensity φ β 0 = 0 := by + let : Fact (0 ≤ (0 : ℝ)) := ⟨le_rfl⟩ + exact (finiteCanonical_tendsto_zero_density hφ ht hβ hstable hcore).liminf_eq + +noncomputable def canonicalFreeEnergy (φ : ℝ → ℝ) (β d : ℝ) : ℝ := + canonicalDensity φ β d / β + +theorem hasCanonicalFreeEnergy_of_core {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {t B : ℝ} (ht : 1 < t) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) : + HasCanonicalFreeEnergy φ (canonicalFreeEnergy φ) := by + intro β d hβ hd + have hlim := (finiteCanonical_tendsto hφ ht hβ.le hstable hcore hd.le).comp + (floor_density_tendsto hd.le) + have hneg := hlim.neg + convert hneg using 1 + · ext L + simp only [Function.comp_def, finiteCanonical, div_eq_mul_inv, inv_pow] + ring + · simp only [canonicalFreeEnergy] + field_simp + +theorem concaveOn_canonicalDensity {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {t B d : ℝ} (ht : 1 < t) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + (hcore : ∀ r, 0 < r → φ r ≤ coreProfile t r) (hd : 0 ≤ d) : + ConcaveOn ℝ (Ioi 0) (fun β => canonicalDensity φ β d) := by + let : Fact (0 ≤ d) := ⟨hd⟩ + refine ⟨convex_Ioi _, ?_⟩ + intro β hβ γ hγ a b ha hb hab + simp only [smul_eq_mul] + have hc : 0 < a * β + b * γ := by + have hh := (convex_Ioi (0 : ℝ)) hβ hγ ha hb hab + exact hh + have hβlim := (finiteCanonical_tendsto hφ ht hβ.le hstable hcore hd) + have hγlim := (finiteCanonical_tendsto hφ ht hγ.le hstable hcore hd) + have hclim := (finiteCanonical_tendsto hφ ht hc.le hstable hcore hd) + apply le_of_tendsto_of_tendsto ((hβlim.const_mul a).add (hγlim.const_mul b)) hclim + filter_upwards [(densityFilter_length d).eventually (eventually_gt_atTop 0)] with p hp + have hh := (convexOn_log_partition hφ hp hstable p.2).2 hβ hγ ha hb hab + simp only [smul_eq_mul] at hh + dsimp [finiteCanonical] + have hden : 0 < p.1 ^ 3 := pow_pos hp 3 + rw [← mul_div_assoc, ← mul_div_assoc, ← add_div] + exact div_le_div_of_nonneg_right (by linarith only [hh]) hden.le + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CellEnergy.lean b/lean/OAI/Probability/ContinuumTransition/CellEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba5b3b563f01a71534bce24b944ab6d3ad2eeb66 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CellEnergy.lean @@ -0,0 +1,170 @@ +import OAI.Probability.ContinuumTransition.ShellGeometry + +namespace OAI + +universe u_1 u_2 + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature +noncomputable section +open scoped ContDiff +open scoped InnerProductSpace + +def pairSum {ι : Type u_1} [Fintype ι] [LinearOrder ι] (f : ι → ι → ℝ) : ℝ := + ∑ i, ∑ j ∈ Finset.univ.filter (fun j => i < j), f i j + +theorem two_mul_pairSum {ι : Type u_1} [Fintype ι] [LinearOrder ι] + (f : ι → ι → ℝ) (hsym : ∀ i j, f i j = f j i) : + 2 * pairSum f = ∑ i, ∑ j, if i = j then 0 else f i j := by + classical + have hsplit (i j : ι) : (if i = j then 0 else f i j) = + (if i < j then f i j else 0) + (if j < i then f j i else 0) := by + rcases lt_trichotomy i j with h | h | h + · simp [h, ne_of_lt h, not_lt_of_ge h.le] + · subst j; simp + · simp [h, ne_of_gt h, not_lt_of_ge h.le, hsym i j] + simp_rw [hsplit] + simp_rw [Finset.sum_add_distrib] + rw [Finset.sum_comm (f := fun i j : ι => if j < i then f j i else 0)] + simp only [pairSum, Finset.sum_filter] + ring + +theorem sum_adjacency_indicator {ι : Type u_1} [Fintype ι] (G : SimpleGraph ι) : + letI := Classical.decRel G.Adj + (∑ i, ∑ j, if G.Adj i j then (1 : ℝ) else 0) = 2 * (G.edgeFinset.card : ℝ) := by + classical + have h := congrArg (fun n : ℕ => (n : ℝ)) G.two_mul_card_edgeFinset + rw [Finset.card_filter] at h + simp only [Nat.cast_mul, Nat.cast_ofNat, Nat.cast_sum, Nat.cast_ite] at h + rw [Fintype.sum_prod_type] at h + simpa only [Nat.cast_one, Nat.cast_zero] using h.symm + +theorem core_one_cell_bound {ι : Type u_1} [Fintype ι] [LinearOrder ι] + (v : ι → EuclideanSpace ℝ (Fin 3)) (t : ℝ) + (hdiam : ∀ i j, ‖v i - v j‖ < 1) : + t ^ 2 / 8 * (Fintype.card ι : ℝ) ^ 2 - t ^ 2 / 2 * Fintype.card ι ≤ + pairSum (fun i j => coreProfile t ‖v i - v j‖) := by + classical + let G := shellGraph v (Real.exp (-t)) + have hpoint (i j : ι) : + t ^ 2 * (1 - (if G.Adj i j then 1 else 0) - (if i = j then 1 else 0)) ≤ + if i = j then 0 else coreProfile t ‖v i - v j‖ := by + by_cases hij : i = j + · subst j + simp + · simp only [ite_eq_right hij, sub_zero] + by_cases hadj : G.Adj i j + · simp only [ite_eq_left hadj, sub_self, mul_zero] + exact coreProfile_nonneg _ _ + · simp only [ite_eq_right hadj, sub_zero, mul_one] + apply coreProfile_ge_of_not_shell _ _ (hdiam i j) + intro hshell + exact hadj ⟨hij, hshell⟩ + have htotal := Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset ι)) => + Finset.sum_le_sum (fun j (_ : j ∈ (Finset.univ : Finset ι)) => hpoint i j)) + have horient := two_mul_pairSum (fun i j => coreProfile t ‖v i - v j‖) + (fun i j => by rw [norm_sub_rev]) + have hadj := sum_adjacency_indicator G + have hdiag : (∑ i : ι, ∑ j : ι, if i = j then (1 : ℝ) else 0) = Fintype.card ι := by simp + simp only [← Finset.mul_sum, Finset.sum_sub_distrib] at htotal + rw [hadj, hdiag, ← horient] at htotal + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] at htotal + have hedge := shellGraph_edge_bound v (Real.exp_pos (-t)) + have hedger : 8 * (G.edgeFinset.card : ℝ) ≤ 3 * (Fintype.card ι : ℝ) ^ 2 := by exact_mod_cast hedge + nlinarith [mul_nonneg (sq_nonneg t) (sub_nonneg.mpr hedger)] + +theorem row_sum_quadratic_bound {ι : Type u_1} [Fintype ι] + (J : ι → ι → ℝ) (n : ι → ℝ) (M : ℝ) + (hJ : ∀ i j, 0 ≤ J i j) (hsym : ∀ i j, J i j = J j i) + (hrow : ∀ i, ∑ j, J i j ≤ M) : + ∑ i, ∑ j, J i j * n i * n j ≤ M * ∑ i, n i ^ 2 := by + have hYoung (i j : ι) : 2 * (J i j * n i * n j) ≤ + J i j * n i ^ 2 + J i j * n j ^ 2 := by + nlinarith [mul_nonneg (hJ i j) (sq_nonneg (n i - n j))] + have hs := Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset ι)) => + Finset.sum_le_sum (fun j (_ : j ∈ (Finset.univ : Finset ι)) => hYoung i j)) + simp_rw [Finset.sum_add_distrib] at hs + simp only [← Finset.mul_sum] at hs + have hswap : (∑ i, ∑ j, J i j * n j ^ 2) = ∑ i, ∑ j, J i j * n i ^ 2 := by + rw [Finset.sum_comm] + congr 1 + funext i + congr 1 + funext j + rw [hsym j i] + rw [hswap] at hs + have hr : (∑ i, ∑ j, J i j * n i ^ 2) ≤ M * ∑ i, n i ^ 2 := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + rw [← Finset.sum_mul] + exact mul_le_mul_of_nonneg_right (hrow i) (sq_nonneg _) + linarith + +theorem superstable_algebra {ι : Type u_1} [Fintype ι] + (J : ι → ι → ℝ) (n : ι → ℝ) (M t N Ucore Uattr : ℝ) + (hJ : ∀ i j, 0 ≤ J i j) (hsym : ∀ i j, J i j = J j i) + (hrow : ∀ i, ∑ j, J i j ≤ M) + (hcore : t ^ 2 / 8 * (∑ i, n i ^ 2) - t ^ 2 / 2 * N ≤ Ucore) + (hattr : Uattr ≤ (1 / 2 : ℝ) * ∑ i, ∑ j, J i j * n i * n j) : + (t ^ 2 / 8 - M / 2) * (∑ i, n i ^ 2) - t ^ 2 / 2 * N ≤ Ucore - Uattr := by + have hq := row_sum_quadratic_bound J n M hJ hsym hrow + nlinarith + +theorem sum_subtype_le_of_nonneg {ι : Type u_1} [Fintype ι] + (p : ι → Prop) [DecidablePred p] (f : ι → ℝ) (hf : ∀ i, 0 ≤ f i) : + ∑ i : {i // p i}, f i ≤ ∑ i, f i := by + have h := Fintype.sum_subtype_add_sum_subtype p f + have hp : 0 ≤ ∑ i : {i // ¬ p i}, f i := Finset.sum_nonneg (fun i _ => hf i) + linarith + +theorem core_partition_bound {ι : Type u_1} {κ : Type u_2} [Fintype ι] [LinearOrder ι] + [Fintype κ] [DecidableEq κ] (c : ι → κ) (v : ι → EuclideanSpace ℝ (Fin 3)) (t : ℝ) + (hdiam : ∀ i j, c i = c j → ‖v i - v j‖ < 1) : + t ^ 2 / 8 * (∑ k, (Fintype.card {i // c i = k} : ℝ) ^ 2) - + t ^ 2 / 2 * Fintype.card ι ≤ pairSum (fun i j => coreProfile t ‖v i - v j‖) := by + classical + let f (i j : ι) : ℝ := if i = j then 0 else coreProfile t ‖v i - v j‖ + have hf (i j : ι) : 0 ≤ f i j := by + dsimp [f] + split_ifs + · rfl + · exact coreProfile_nonneg _ _ + let U (k : κ) : ℝ := pairSum (fun i j : {i // c i = k} => coreProfile t ‖v i - v j‖) + have htwocell (k : κ) : 2 * U k = ∑ i : {i // c i = k}, ∑ j : {j // c j = k}, f i j := by + dsimp [U] + rw [two_mul_pairSum _ (fun i j => by rw [norm_sub_rev])] + simp only [f, Subtype.ext_iff] + have htwototal : 2 * pairSum (fun i j => coreProfile t ‖v i - v j‖) = ∑ i, ∑ j, f i j := + two_mul_pairSum _ (fun i j => by rw [norm_sub_rev]) + have hu : 2 * (∑ k, U k) ≤ 2 * pairSum (fun i j => coreProfile t ‖v i - v j‖) := by + rw [Finset.mul_sum, htwototal] + simp_rw [htwocell] + calc + _ ≤ ∑ k : κ, ∑ i : {i // c i = k}, ∑ j : ι, f i j := by + apply Finset.sum_le_sum + intro k _ + apply Finset.sum_le_sum + intro i _ + exact sum_subtype_le_of_nonneg (fun j => c j = k) (f i) (hf i) + _ = _ := Fintype.sum_fiberwise c (fun i => ∑ j, f i j) + have hs (k : κ) : t ^ 2 / 8 * (Fintype.card {i // c i = k} : ℝ) ^ 2 - + t ^ 2 / 2 * Fintype.card {i // c i = k} ≤ U k := by + apply core_one_cell_bound + intro i j + exact hdiam i j (i.property.trans j.property.symm) + have hsum := Finset.sum_le_sum (fun k (_ : k ∈ (Finset.univ : Finset κ)) => hs k) + simp only [Finset.sum_sub_distrib, ← Finset.mul_sum] at hsum + have hcard : (∑ k, (Fintype.card {i // c i = k} : ℝ)) = Fintype.card ι := by + simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] using + Fintype.sum_fiberwise c (fun _ => (1 : ℝ)) + rw [hcard] at hsum + linarith + +end +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CoerciveCanonical.lean b/lean/OAI/Probability/ContinuumTransition/CoerciveCanonical.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbcc31f7c44b216f5e83266e077dd785309b42ef --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CoerciveCanonical.lean @@ -0,0 +1,61 @@ +import OAI.Probability.ContinuumTransition.PhysicalPerturbation + +namespace OAI + +section +open scoped Topology BigOperators +open Filter MeasureTheory Set +namespace ContinuumTemperature + +theorem finiteCanonical_lower_coercive {t β L : ℝ} (ht : 0 ≤ t) (hβ : 0 ≤ β) (hL : 0 < L) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n)/2 ≤ t^2/8) (N : ℕ) : + β*((t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/(4+2/L)^3)*((N : ℝ)/L^3)^2 + + ((N : ℝ)/L^3)*Real.log ((N : ℝ)/L^3)-(β*t^2/2+1)*((N : ℝ)/L^3) ≤ + finiteCanonical (physicalProfile t σ R) β L N := by + by_cases hN : N = 0 + · simp [hN] + have hφ := measurable_radialPotential (measurable_physicalProfile t hσ hR hs) + have hst := physicalProfile_stable ht hσ hR hs hsmall + have hh := neg_log_partition_lower hφ hβ hL hst hN + (physicalProfile_energy_coercive ht hL.le hσ hR hs hsmall N) + have hd := div_le_div_of_nonneg_right hh (pow_pos hL 3).le + unfold finiteCanonical + convert hd using 1; try rfl + field_simp + ring + +theorem canonicalDensity_lower_coercive {t β d : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n)/2 ≤ t^2/8) (hd : 0 ≤ d) : + β*((t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/64)*d^2 + + d*Real.log d-(β*t^2/2+1)*d ≤ canonicalDensity (physicalProfile t σ R) β d := by + let : Fact (0 ≤ d) := ⟨hd⟩ + have ht0 : 0 ≤ t := (lt_trans zero_lt_one ht).le + have hφ := measurable_radialPotential (measurable_physicalProfile t hσ hR hs) + have hst := physicalProfile_stable ht0 hσ hR hs hsmall + have hcore (r : ℝ) (_ : 0 < r) := physicalProfile_le_core ht0 hσ hR r + have hlim := finiteCanonical_tendsto hφ ht hβ hst hcore hd + have hi := tendsto_inv_atTop_zero.comp (densityFilter_length d) + have hc : Tendsto (fun p : ℝ × ℕ => + (t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/(4+2/p.1)^3) + (densityFilter d) (𝓝 ((t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/64)) := by + have hh := (tendsto_const_nhds (x := t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)).div + ((tendsto_const_nhds.add (hi.const_mul 2)).pow 3) + (by norm_num : (4+2*(0 : ℝ))^3 ≠ 0) + change Tendsto (fun p : ℝ × ℕ => + (t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/(4+2*(p.1)⁻¹)^3) + (densityFilter d) (𝓝 ((t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/((4+2*(0 : ℝ))^3))) at hh + simpa only [mul_zero, add_zero, div_eq_mul_inv, Function.comp_def, Pi.mul_apply, Pi.inv_apply, + show (4 : ℝ)^3 = 64 by norm_num] using hh + have he := (((hc.const_mul β).mul ((densityFilter_density d).pow 2)).add + (Real.continuous_mul_log.continuousAt.tendsto.comp (densityFilter_density d))).sub + ((densityFilter_density d).const_mul (β*t^2/2+1)) + apply le_of_tendsto_of_tendsto he hlim + filter_upwards [(densityFilter_length d).eventually (eventually_gt_atTop 0)] with p hp + exact finiteCanonical_lower_coercive ht0 hβ hp hσ hR hs hsmall p.2 + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CompactHulls.lean b/lean/OAI/Probability/ContinuumTransition/CompactHulls.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc83da2d2aaa46d74f3be6cf1f9f3af33852b353 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CompactHulls.lean @@ -0,0 +1,55 @@ +import OAI.Probability.ContinuumTransition.TransformBounds + +namespace OAI + +universe u_1 + +section +open scoped Topology +open Set +namespace ContinuumTemperature + +lemma isCompact_convexJoin {E : Type u_1} [AddCommGroup E] [Module ℝ E] + [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul ℝ E] + {S T : Set E} (hS : IsCompact S) (hT : IsCompact T) : + IsCompact (convexJoin ℝ S T) := by + have he : convexJoin ℝ S T = + (fun p : ℝ × E × E => (1-p.1) • p.2.1+p.1 • p.2.2) '' (Icc (0:ℝ) 1 ×ˢ S ×ˢ T) := by + ext z + simp only [mem_convexJoin,segment_eq_image,mem_image,mem_prod,Prod.exists] + constructor + · rintro ⟨x,hx,y,hy,c,hc,rfl⟩ + exact ⟨c,x,y,⟨hc,hx,hy⟩,rfl⟩ + · rintro ⟨c,x,y,⟨hc,hx,hy⟩,rfl⟩ + exact ⟨x,hx,y,hy,c,hc,rfl⟩ + rw [he] + exact (isCompact_Icc.prod (hS.prod hT)).image (by fun_prop) + +lemma compact_convexHull_union {E : Type u_1} [AddCommGroup E] [Module ℝ E] + [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul ℝ E] + {S T : Set E} (hS : IsCompact S) (hT : IsCompact T) + (hcS : Convex ℝ S) (hcT : Convex ℝ T) : IsCompact (convexHull ℝ (S ∪ T)) := by + by_cases hs : S.Nonempty + · by_cases ht : T.Nonempty + · rw [hcS.convexHull_union hcT hs ht] + exact isCompact_convexJoin hS hT + · rw [not_nonempty_iff_eq_empty.mp ht,union_empty,hcS.convexHull_eq] + exact hS + · rw [not_nonempty_iff_eq_empty.mp hs,empty_union,hcT.convexHull_eq] + exact hT + +lemma compact_convexHull_iUnion_fin {E : Type u_1} [AddCommGroup E] [Module ℝ E] + [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul ℝ E] + {n : ℕ} (K : Fin n → Set E) (hk : ∀ i, IsCompact (K i)) (hc : ∀ i, Convex ℝ (K i)) : + IsCompact (convexHull ℝ (⋃ i, K i)) := by + induction n with + | zero => simp + | succ n ih => + rw [Set.iUnion_fin_add_one_eq_iUnion_succ,← convexHull_convexHull_union_right] + exact compact_convexHull_union (hk 0) (ih _ (fun i => hk i.succ) (fun i => hc i.succ)) + (hc 0) (convex_convexHull _ _) + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CompactSequences.lean b/lean/OAI/Probability/ContinuumTransition/CompactSequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f057b058a49566cccef37e685669db0d400af40 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CompactSequences.lean @@ -0,0 +1,36 @@ +import OAI.Probability.ContinuumTransition.ConvexUniform + +namespace OAI + +universe u_1 + +section +open scoped Topology +open Set Filter +namespace ContinuumTemperature + +lemma eventually_of_subseq (P : ℕ → Prop) + (h : ∀ φ : ℕ → ℕ, StrictMono φ → ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ ∀ᶠ n in atTop, P (φ (ψ n))) : + ∀ᶠ n in atTop, P n := by + by_contra hh + obtain ⟨φ,hφ,hbad⟩ := extraction_of_frequently_atTop (not_eventually.mp hh) + obtain ⟨ψ,_,hgood⟩ := h φ hφ + obtain ⟨n,hn⟩ := hgood.exists + exact hbad (ψ n) hn + +lemma metric_tendsto_of_subseq {E : Type u_1} [PseudoMetricSpace E] {u : ℕ → E} {x : E} + (h : ∀ φ : ℕ → ℕ, StrictMono φ → ∃ ψ : ℕ → ℕ, StrictMono ψ ∧ + Tendsto (fun n => u (φ (ψ n))) atTop (𝓝 x)) : Tendsto u atTop (𝓝 x) := by + apply Metric.tendsto_atTop.mpr + intro ε hε + have hh : ∀ᶠ n in atTop, dist (u n) x < ε := by + apply eventually_of_subseq + intro φ hφ + obtain ⟨ψ,hψ,ht⟩ := h φ hφ + exact ⟨ψ,hψ,ht.eventually (Metric.ball_mem_nhds x hε)⟩ + exact eventually_atTop.mp hh + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionBounds.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..b72236c143732e76a84634826a0f578b6273c17f --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionBounds.lean @@ -0,0 +1,75 @@ +import OAI.Probability.ContinuumTransition.UniformMin + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +def moderateBox : Set Parameter := {x | 1/4 ≤ x.1 ∧ x.1 ≤ 2 ∧ x.2 ≤ 10} + +lemma initial_ball_moderate : closedBall initialPoint (1/2) ⊆ moderateBox := by + intro x hx + have hh : |x.1-1| ≤ 1/2 ∧ |x.2-(-3/4)| ≤ 1/2 := by + simpa only [mem_closedBall,dist_eq_norm_sub,Prod.norm_def,Prod.fst_sub,Prod.snd_sub, + Real.norm_eq_abs,max_le_iff,initialPoint] using hx + obtain ⟨h1,h2⟩ := hh + obtain ⟨h1,h1'⟩ := abs_le.mp h1 + obtain ⟨h2,h2'⟩ := abs_le.mp h2 + exact ⟨by linarith,by linarith,by linarith⟩ + +lemma moderateBox_subset : moderateBox ⊆ pressureDomain := by + intro x hx + change 0 < x.1 + linarith only [hx.1] + +lemma physicalProfile_zero (t : ℝ) (R : ℕ → ℝ) : + physicalProfile t (fun _ => 0) R = coreProfile t := by + funext r + simp [physicalProfile,attraction] + +lemma physical_convex_bounded {t : ℝ} (ht : 1 < t) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hm : 17576*kernelHeight*(∑' n, σ n) ≤ t) : + ConvexOn ℝ pressureDomain (physicalPressure (physicalProfile t σ R) t) := by + have ht0 := lt_trans zero_lt_one ht + exact convexOn_physicalPressure (measurable_radialPotential (measurable_physicalProfile t hσ hR hs)) ht + (physicalProfile_stable ht0.le hσ hR hs (strengthened_smallness ht0 hm).1) + (fun r _ => physicalProfile_le_core ht0.le hσ hR r) + +lemma physical_meanField_bounded {t a : ℝ} (ht : 1 < t) (ha : 0 < a) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hm : 17576*kernelHeight*(∑' n, σ n) ≤ t) (hat : 1024*a < t) : + IsMeanField (physicalPressure (physicalProfile t σ R) t) a + (meanField (physicalPressure (physicalProfile t σ R) t) a) ∧ + (∀ x ∈ pressureDomain, ∃ d, quadraticCost (physicalPressure (physicalProfile t σ R) t) a x d = + meanField (physicalPressure (physicalProfile t σ R) t) a x) := by + have ht0 := lt_trans zero_lt_one ht + have hsmall := (strengthened_smallness ht0 hm).1 + have hgap := strengthened_gap ht0 hm hat + exact ⟨isMeanField_meanField (physical_meanField ht ha.le hσ hR hs hsmall hgap.le), + fun _ hx => physical_meanField_attained ht ha hσ hR hs hsmall hgap hx⟩ + +lemma physical_meanField_bounded_attainment {t a : ℝ} (ht : 1 < t) (ha : 0 < a) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hm : 17576*kernelHeight*(∑' n, σ n) ≤ t) (hat : 1024*a < t) + {x : Parameter} (hx : x ∈ moderateBox) : + ∃ d ∈ Icc (0:ℝ) 1048576, quadraticCost (physicalPressure (physicalProfile t σ R) t) a x d = + meanField (physicalPressure (physicalProfile t σ R) t) a x := by + have hh := physical_meanField_bounded ht ha hσ hR hs hm hat + obtain ⟨w,hw⟩ := activeLifts_nonempty ha (physical_convex_bounded ht hσ hR hs hm) hh.1 + (moderateBox_subset hx) (hh.2 _ (moderateBox_subset hx)) + exact ⟨w.2,physical_transform_active_bound ht ha hσ hR hs hm hat hx.1 hx.2.1 hx.2.2 hw,hw.1⟩ + +lemma strong_smallness {t m : ℝ} (ht : 0 < t) + (hm : 140608*kernelHeight*m ≤ t) : 2197*t*kernelHeight*m ≤ (t^2/8)/8 := by + have h := mul_le_mul_of_nonneg_left hm ht.le + nlinarith only [h] + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionCap.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionCap.lean new file mode 100644 index 0000000000000000000000000000000000000000..b94fdd0a6bc33eeb22ec7c89bf5900349cf1c265 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionCap.lean @@ -0,0 +1,46 @@ +import OAI.Probability.ContinuumTransition.TripleState + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +structure ConstructionCap (t M : ℝ) : Prop where + t_large : 1 < t + mass_pos : 0 < M + strong : 140608*kernelHeight*M ≤ t + gap : 1024*M < t + +lemma ConstructionCap.weak {t M m : ℝ} (h : ConstructionCap t M) (hm : m ≤ M) : + 17576*kernelHeight*m ≤ t := by + calc + 17576*kernelHeight*m ≤ 17576*kernelHeight*M := mul_le_mul_of_nonneg_left hm (by positivity [kernelHeight_pos]) + _ ≤ 140608*kernelHeight*M := by nlinarith only [mul_pos kernelHeight_pos h.mass_pos] + _ ≤ t := h.strong + +lemma ConstructionCap.small {t M m : ℝ} (h : ConstructionCap t M) (hm : m ≤ M) : + 2197*t*kernelHeight*m ≤ (t^2/8)/8 := by + apply strong_smallness (lt_trans zero_lt_one h.t_large) + exact (mul_le_mul_of_nonneg_left hm (by positivity [kernelHeight_pos])).trans h.strong + +lemma ConstructionCap.lt_gap {t M a : ℝ} (h : ConstructionCap t M) (ha : a ≤ M) : + 1024*a < t := (mul_le_mul_of_nonneg_left ha (by norm_num)).trans_lt h.gap + +lemma exists_constructionCap {M : ℝ} (hM : 0 < M) : ∃ T : ℝ, ConstructionCap T M := by + obtain ⟨T,hT⟩ := exists_gt (max 1 (max (140608*kernelHeight*M) (1024*M))) + refine ⟨T,?_,hM,?_,?_⟩ + · exact (le_max_left _ _).trans_lt hT + · exact ((le_max_left _ _).trans (le_max_right _ _)).trans hT.le + · exact ((le_max_right _ _).trans (le_max_right _ _)).trans_lt hT + +lemma ConstructionCap.mono_t {t T M : ℝ} (h : ConstructionCap T M) (ht : T ≤ t) : + ConstructionCap t M := ⟨h.t_large.trans_le ht,h.mass_pos,h.strong.trans ht,h.gap.trans_le ht⟩ + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionLimit.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..d13fd0707b4d076b40fde4cd2d60042eb83efdba --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionLimit.lean @@ -0,0 +1,83 @@ +import OAI.Probability.ContinuumTransition.TailPressure + +namespace OAI + +section +open scoped Topology BigOperators +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +def ConstructionData.profile {p : ℝ} (C : ConstructionData p) : ℝ → ℝ := + physicalProfile C.t C.masses C.ranges + +def ConstructionData.pressure {p : ℝ} (C : ConstructionData p) : Parameter → ℝ := + physicalPressure C.profile C.t + +lemma ConstructionData.pressure_convex {p : ℝ} (C : ConstructionData p) : + ConvexOn ℝ pressureDomain C.pressure := + physical_convex_bounded C.cap.t_large C.masses_nonneg C.ranges_one C.masses_summable (C.cap.weak C.mass_bound) + +lemma ConstructionData.pressure_tendsto {p : ℝ} (C : ConstructionData p) {x : Parameter} (hx : x ∈ pressureDomain) : + Tendsto (fun n => (C.stages n).pressure x) atTop (𝓝 (C.pressure x)) := by + have hb (n : ℕ) := physical_pressure_tail_bound C.cap.t_large hx + (prefixMass_nonneg C.masses_nonneg n) (tailMass_nonneg C.masses_nonneg n) C.ranges_one + (prefixMass_summable C.masses_nonneg C.masses_summable n) + (tailMass_summable C.masses_nonneg C.masses_summable n) + (by rw [prefixMass_add_tailMass]; exact C.cap.small C.mass_bound) x.2 + have hb' (n : ℕ) : 0 ≤ C.pressure x-(C.stages n).pressure x ∧ + C.pressure x-(C.stages n).pressure x ≤ + 108*2197*x.1*kernelHeight*momentConstant C.t x.1 (C.t*x.2)*(∑' k, tailMass C.masses n k) := by + have hh := hb n + rw [prefixMass_add_tailMass,← C.reference_eq_prefix n] at hh + exact hh + have hd : Tendsto (fun n => C.pressure x-(C.stages n).pressure x) atTop (𝓝 0) := by + apply squeeze_zero (fun n => (hb' n).1) (fun n => (hb' n).2) + simpa only [mul_zero] using (tailMass_tsum_tendsto C.masses_nonneg C.masses_summable).const_mul + (108*2197*x.1*kernelHeight*momentConstant C.t x.1 (C.t*x.2)) + simpa only [sub_sub_cancel,sub_zero] using (tendsto_const_nhds (x := C.pressure x)).sub hd + +lemma initial_quarter_subset : ball initialPoint (1/4) ⊆ pressureDomain := + ball_subset_closedBall.trans ((closedBall_subset_closedBall (by norm_num : (1:ℝ)/4 ≤ 1/2)).trans + (initial_ball_moderate.trans moderateBox_subset)) + +lemma ConstructionData.ideal_tendsto {p : ℝ} (C : ConstructionData p) {x : Parameter} + (hx : x ∈ ball initialPoint (1/4)) : + Tendsto (fun n => (C.stages n).ideal x) atTop (𝓝 (C.pressure x)) := by + have hd : Tendsto (fun n => (C.stages n).ideal x-(C.stages (n+1)).pressure x) atTop (𝓝 0) := by + apply squeeze_zero_norm _ geometricBudget_tendsto + intro n + simpa only [Real.norm_eq_abs,abs_sub_comm] using (C.transitions n).approximation x (ball_subset_closedBall hx) + have hn := (C.pressure_tendsto (initial_quarter_subset hx)).comp (tendsto_add_atTop_nat 1) + simpa only [Function.comp_def,sub_add_cancel,zero_add] using hd.add hn + +lemma ConstructionData.ideal_locally_uniform {p : ℝ} (C : ConstructionData p) : + TendstoLocallyUniformlyOn (fun n => (C.stages n).ideal) C.pressure atTop (ball initialPoint (1/4)) := by + apply convex_pointwise_locally_uniform isOpen_ball + · exact Eventually.of_forall (fun n => ((C.stages n).convex C.cap).subset initial_quarter_subset (convex_ball _ _)) + · exact fun _ hx => C.ideal_tendsto hx + +lemma ConstructionData.limit_support_ball {p : ℝ} (C : ConstructionData p) (hp : 0 < p) + {x : Parameter} (hx : Tendsto (fun n => (C.stages n).x) atTop (𝓝 x)) + (hnear : dist x initialPoint ≤ 1/8) : + closedBall (triangleCenter p) C.γ ⊆ subgradients pressureDomain C.pressure x := by + have hxW : x ∈ ball initialPoint (1/4) := hnear.trans_lt (by norm_num : (1:ℝ)/8 < 1/4) + have hc := C.pressure_convex.continuousOn isOpen_pressureDomain + have heval := C.ideal_locally_uniform.tendsto_comp (hc.mono initial_quarter_subset x hxW) hxW + (tendsto_nhdsWithin_iff.mpr ⟨hx,Eventually.of_forall (fun n => + (C.stages n).x_near.trans (by norm_num : (1:ℝ)/8 < 1/4))⟩) + intro v hv + apply supportOn_of_local C.pressure_convex (initial_quarter_subset hxW) + filter_upwards [isOpen_ball.mem_nhds hxW] with y hy + have hd : Tendsto (fun n => pDot v (y-(C.stages n).x)) atTop (𝓝 (pDot v (y-x))) := by + exact (show Continuous (fun z : Parameter => pDot v (y-z)) by unfold pDot; fun_prop).continuousAt.tendsto.comp hx + apply le_of_tendsto_of_tendsto (heval.add hd) (C.ideal_tendsto hy) + exact Eventually.of_forall (fun n => + ((C.stages n).triple.support_ball hp (groupRadius_le C.τ_pos.le n) C.τ_small C.geometry hv) y + (initial_quarter_subset hy)) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionLocation.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionLocation.lean new file mode 100644 index 0000000000000000000000000000000000000000..8933d4aff475b9182e60f6ad4040b8d0cfe4c7f0 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionLocation.lean @@ -0,0 +1,46 @@ +import OAI.Probability.ContinuumTransition.ConstructionMasses + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +lemma geometricBudget_tendsto : Tendsto geometricBudget atTop (𝓝 0) := + tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num) + +lemma ConstructionData.positions_cauchy {p : ℝ} (C : ConstructionData p) : + CauchySeq (fun n => (C.stages n).x) := by + apply cauchySeq_of_le_geometric (1/2) (1/32) (by norm_num) + intro n + have hh := (C.transitions n).displacement.le + rw [dist_comm] at hh + simpa only [geometricBudget,div_eq_mul_inv,mul_comm,one_mul] using hh + +lemma ConstructionData.exists_limit_position {p : ℝ} (C : ConstructionData p) : + ∃ x : Parameter, Tendsto (fun n => (C.stages n).x) atTop (𝓝 x) ∧ + dist x initialPoint ≤ 1/8 := by + obtain ⟨x,hx⟩ := cauchySeq_tendsto_of_complete C.positions_cauchy + refine ⟨x,hx,?_⟩ + apply le_of_tendsto (hx.dist tendsto_const_nhds) + exact Eventually.of_forall (fun n => (C.stages n).x_near.le) + +lemma initial_near_beta {x : Parameter} (hx : dist x initialPoint ≤ 1/8) : + x.1 ∈ Ioo (1/2:ℝ) (3/2:ℝ) := by + have hh : |x.1-1| ≤ 1/8 ∧ |x.2-(-3/4)| ≤ 1/8 := by + simpa only [dist_eq_norm_sub,Prod.norm_def,Prod.fst_sub,Prod.snd_sub, + Real.norm_eq_abs,max_le_iff,initialPoint] using hx + have hb := hh.1 + rcases abs_le.mp hb with ⟨h₁,h₂⟩ + constructor <;> linarith + +lemma initial_near_moderate {x : Parameter} (hx : dist x initialPoint ≤ 1/8) : + x ∈ moderateBox := initial_ball_moderate (hx.trans (by norm_num : (1:ℝ)/8 ≤ 1/2)) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionMasses.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionMasses.lean new file mode 100644 index 0000000000000000000000000000000000000000..e46b8bf0f362b9bbd87a5e993c40e8ebb5ffc4fc --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionMasses.lean @@ -0,0 +1,129 @@ +import OAI.Probability.ContinuumTransition.ConstructionSequence + +namespace OAI + +section +open scoped Topology BigOperators +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +def ConstructionData.masses {p : ℝ} (C : ConstructionData p) (n : ℕ) : ℝ := (C.stages n).a + +def prefixMass (σ : ℕ → ℝ) (n k : ℕ) : ℝ := if k < n then σ k else 0 + +def tailMass (σ : ℕ → ℝ) (n k : ℕ) : ℝ := if n ≤ k then σ k else 0 + +lemma prefixMass_nonneg {σ : ℕ → ℝ} (hσ : ∀ k, 0 ≤ σ k) (n k : ℕ) : 0 ≤ prefixMass σ n k := by + unfold prefixMass + split_ifs + · exact hσ k + · exact le_refl _ + +lemma tailMass_nonneg {σ : ℕ → ℝ} (hσ : ∀ k, 0 ≤ σ k) (n k : ℕ) : 0 ≤ tailMass σ n k := by + unfold tailMass + split_ifs + · exact hσ k + · exact le_refl _ + +lemma prefixMass_add_tailMass (σ : ℕ → ℝ) (n : ℕ) : + (fun k => prefixMass σ n k+tailMass σ n k) = σ := by + funext k + by_cases hk : k < n + · simp [prefixMass,tailMass,hk,Nat.not_le.mpr hk] + · simp [prefixMass,tailMass,hk,Nat.le_of_not_gt hk] + +lemma prefixMass_summable {σ : ℕ → ℝ} (hσ : ∀ k, 0 ≤ σ k) (hs : Summable σ) (n : ℕ) : + Summable (prefixMass σ n) := by + apply hs.of_nonneg_of_le (prefixMass_nonneg hσ n) + intro k + unfold prefixMass + split_ifs <;> simp_all + +lemma tailMass_summable {σ : ℕ → ℝ} (hσ : ∀ k, 0 ≤ σ k) (hs : Summable σ) (n : ℕ) : + Summable (tailMass σ n) := by + apply hs.of_nonneg_of_le (tailMass_nonneg hσ n) + intro k + unfold tailMass + split_ifs <;> simp_all + +lemma tsum_prefixMass (σ : ℕ → ℝ) (n : ℕ) : + ∑' k, prefixMass σ n k = ∑ k ∈ Finset.range n, σ k := by + rw [tsum_eq_sum (s := Finset.range n) (fun k hk => by + simp only [Finset.mem_range] at hk + simp only [prefixMass,ite_eq_right hk])] + apply Finset.sum_congr rfl + intro k hk + simp only [prefixMass,Finset.mem_range.mp hk,ite_true] + +lemma tailMass_tsum_tendsto {σ : ℕ → ℝ} (hσ : ∀ k, 0 ≤ σ k) (hs : Summable σ) : + Tendsto (fun n => ∑' k, tailMass σ n k) atTop (𝓝 0) := by + have he (n : ℕ) : ∑' k, tailMass σ n k = (∑' k, σ k)-∑ k ∈ Finset.range n, σ k := by + have hh := (prefixMass_summable hσ hs n).tsum_add (tailMass_summable hσ hs n) + rw [prefixMass_add_tailMass,tsum_prefixMass] at hh + linarith + simp_rw [he] + simpa only [sub_self] using (tendsto_const_nhds (x := ∑' k, σ k)).sub hs.hasSum.tendsto_sum_nat + +lemma ConstructionData.reference_mass {p : ℝ} (C : ConstructionData p) (n : ℕ) : + ∑' k, (C.stages n).σ k = ∑ k ∈ Finset.range n, C.masses k := by + induction n with + | zero => simp [C.initial_zero] + | succ n ih => + rw [(C.transitions n).mass_eq,tsum_prepend _ (C.stages n).σ_summable,ih,Finset.sum_range_succ] + dsimp [ConstructionData.masses] + ring + +lemma ConstructionData.masses_nonneg {p : ℝ} (C : ConstructionData p) (n : ℕ) : 0 ≤ C.masses n := + (C.stages n).a_pos.le + +lemma ConstructionData.sum_masses_le {p : ℝ} (C : ConstructionData p) (n : ℕ) : + ∑ k ∈ Finset.range n, C.masses k ≤ firstMass p+1 := by + rw [← C.reference_mass] + exact (C.stages n).base_mass + +lemma ConstructionData.masses_summable {p : ℝ} (C : ConstructionData p) : Summable C.masses := + summable_of_sum_range_le C.masses_nonneg C.sum_masses_le + +lemma ConstructionData.mass_bound {p : ℝ} (C : ConstructionData p) : ∑' k, C.masses k ≤ firstMass p+1 := + Real.tsum_le_of_sum_range_le C.masses_nonneg C.sum_masses_le + +lemma ConstructionData.ranges_one {p : ℝ} (C : ConstructionData p) (n : ℕ) : 1 ≤ C.ranges n := by + have hh := (C.transitions n).range_large + linarith + +lemma ConstructionData.reference_profile {p : ℝ} (C : ConstructionData p) (n : ℕ) (r : ℝ) : + physicalProfile C.t (C.stages n).σ (C.stages n).R r = + coreProfile C.t r-C.t*∑ k ∈ Finset.range n, C.masses k*scaledKernelProfile (C.ranges k) r := by + induction n with + | zero => simp [C.initial_zero,physicalProfile_zero] + | succ n ih => + rw [(C.transitions n).mass_eq,(C.transitions n).range_eq, + physicalProfile_prepend C.t (C.stages n).σ_nonneg (C.stages n).R_one (C.stages n).σ_summable,ih, + Finset.sum_range_succ] + dsimp [ConstructionData.masses] + ring + +lemma attraction_prefixMass (t : ℝ) (σ R : ℕ → ℝ) (n : ℕ) (r : ℝ) : + attraction t (prefixMass σ n) R r = t*∑ k ∈ Finset.range n, σ k*scaledKernelProfile (R k) r := by + unfold attraction + congr 1 + rw [tsum_eq_sum (s := Finset.range n) (fun k hk => by + simp only [Finset.mem_range] at hk + simp only [prefixMass,ite_eq_right hk,zero_mul])] + apply Finset.sum_congr rfl + intro k hk + simp only [prefixMass,Finset.mem_range.mp hk,ite_true] + +lemma ConstructionData.reference_eq_prefix {p : ℝ} (C : ConstructionData p) (n : ℕ) : + physicalProfile C.t (C.stages n).σ (C.stages n).R = physicalProfile C.t (prefixMass C.masses n) C.ranges := by + funext r + rw [C.reference_profile] + unfold physicalProfile + rw [attraction_prefixMass] + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionSequence.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec94912a1fca863eb9acbba8f7f561b220bfda6f --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionSequence.lean @@ -0,0 +1,76 @@ +import OAI.Probability.ContinuumTransition.ConstructionStep + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +structure ConstructionData (p : ℝ) where + t : ℝ + τ : ℝ + γ : ℝ + τ_pos : 0 < τ + τ_small : τ ≤ p/100 + γ_pos : 0 < γ + cap : ConstructionCap t (firstMass p+1) + geometry : ∀ w : Fin 3 → Parameter, (∀ i, dist (w i) (triangleVertex p i) ≤ τ) → + closedBall (triangleCenter p) γ ⊆ convexHull ℝ (range w) + stages : ∀ n, ConstructionStage t p τ n + ranges : ℕ → ℝ + initial_zero : (stages 0).σ = fun _ => 0 + initial_mass : (stages 0).a = firstMass p + transitions : ∀ n, StageTransition (stages n) (stages (n+1)) (ranges n) + +lemma sequence_of_initial {t p τ γ : ℝ} (hp : 0 < p) (hτ : 0 < τ) (hτp : τ ≤ p/100) + (hγ : 0 < γ) (hcap : ConstructionCap t (firstMass p+1)) + (hgeom : ∀ w : Fin 3 → Parameter, (∀ i, dist (w i) (triangleVertex p i) ≤ τ) → + closedBall (triangleCenter p) γ ⊆ convexHull ℝ (range w)) + (s₀ : ConstructionStage t p τ 0) (hzero : s₀.σ = fun _ => 0) (hfirst : s₀.a = firstMass p) : + Nonempty (ConstructionData p) := by + have hex := fun n (s : ConstructionStage t p τ n) => construction_step hp hτ hτp hγ hcap hgeom s + let next := fun n (s : ConstructionStage t p τ n) => Classical.choose (hex n s) + let length := fun n (s : ConstructionStage t p τ n) => Classical.choose (Classical.choose_spec (hex n s)) + have hn (n) (s : ConstructionStage t p τ n) : StageTransition s (next n s) (length n s) := + Classical.choose_spec (Classical.choose_spec (hex n s)) + let seq : ∀ n, ConstructionStage t p τ n := Nat.rec s₀ (fun n s => next n s) + refine ⟨⟨t,τ,γ,hτ,hτp,hγ,hcap,hgeom,seq,(fun n => length n (seq n)),hzero,hfirst,?_⟩⟩ + intro n + exact hn n (seq n) + +lemma exists_constructionData : Nonempty (ConstructionData packingDensity) := by + have hp := packingDensity_pos + obtain ⟨τ₀,γ,hτ₀,hγ,hgeom₀⟩ := robust_vertex_triangle hp + let τ := min τ₀ (packingDensity/100) + have hτ : 0 < τ := lt_min hτ₀ (by positivity) + have hτp : τ ≤ packingDensity/100 := min_le_right _ _ + have hgeom : ∀ w : Fin 3 → Parameter, (∀ i, dist (w i) (triangleVertex packingDensity i) ≤ τ) → + closedBall (triangleCenter packingDensity) γ ⊆ convexHull ℝ (range w) := + fun w hw => hgeom₀ w (fun i => (hw i).trans (min_le_left _ _)) + have ha : 0 < firstMass packingDensity := firstMass_pos hp + obtain ⟨T,hT⟩ := exists_constructionCap (show 0 < firstMass packingDensity+1 by linarith) + obtain ⟨t,ht,x,hx,htr⟩ := physical_initial_triple hτ hγ (show (0:ℝ) < 1/64 by norm_num) + (show (1:ℝ)/64 < 1/2 by norm_num) hT.t_large (hT.lt_gap (by linarith : firstMass packingDensity ≤ firstMass packingDensity+1)) + (hgeom (triangleVertex packingDensity) (fun _ => by simp only [dist_self]; exact hτ.le)) + let s₀ : ConstructionStage t packingDensity τ 0 := { + σ := fun _ => 0, R := fun _ => 1, a := firstMass packingDensity, x := x, + σ_nonneg := fun _ => le_refl _, R_one := fun _ => le_refl _, σ_summable := summable_zero, + a_pos := ha, mass := by simp [geometricBudget], + referenceBounded := ⟨1,by norm_num,fun _ _ => le_refl _⟩, + location := by + change dist x initialPoint < 1/64 at hx + norm_num [locationRadius,geometricBudget] + linarith, + triple := by + have he : groupRadius τ 0 = τ/2 := by norm_num [groupRadius,geometricBudget]; ring + rw [he,physicalProfile_zero] + exact htr } + exact sequence_of_initial hp hτ hτp hγ (hT.mono_t ht) hgeom s₀ rfl rfl + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionStage.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f3a96e0afa8cd5bf8eda05e4ce80e0a2a91d8ee --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionStage.lean @@ -0,0 +1,87 @@ +import OAI.Probability.ContinuumTransition.InitialTriple + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +def geometricBudget (n : ℕ) : ℝ := (1/2)^n +def groupRadius (τ : ℝ) (n : ℕ) : ℝ := τ*(1-geometricBudget (n+1)) +def locationRadius (n : ℕ) : ℝ := 1/8-geometricBudget n/16 + +lemma geometricBudget_pos (n : ℕ) : 0 < geometricBudget n := pow_pos (by norm_num) _ +lemma geometricBudget_succ (n : ℕ) : geometricBudget (n+1) = geometricBudget n/2 := by + unfold geometricBudget + rw [pow_succ] + ring +lemma groupRadius_le {τ : ℝ} (hτ : 0 ≤ τ) (n : ℕ) : groupRadius τ n ≤ τ := by + dsimp [groupRadius] + nlinarith only [mul_nonneg hτ (geometricBudget_pos (n+1)).le] +lemma groupRadius_succ (τ : ℝ) (n : ℕ) : + groupRadius τ (n+1) = groupRadius τ n+τ*geometricBudget n/4 := by + simp only [groupRadius,geometricBudget_succ] + ring +lemma locationRadius_lt (n : ℕ) : locationRadius n < 1/8 := by + dsimp [locationRadius] + linarith only [geometricBudget_pos n] +lemma locationRadius_succ (n : ℕ) : locationRadius (n+1)=locationRadius n+geometricBudget n/32 := by + simp only [locationRadius,geometricBudget_succ] + ring + +structure ConstructionStage (t p τ : ℝ) (n : ℕ) where + σ : ℕ → ℝ + R : ℕ → ℝ + a : ℝ + x : Parameter + σ_nonneg : ∀ k, 0 ≤ σ k + R_one : ∀ k, 1 ≤ R k + σ_summable : Summable σ + a_pos : 0 < a + mass : a+∑' k, σ k ≤ firstMass p+1-geometricBudget n + referenceBounded : ∃ B ≥ 0, ∀ k, σ k ≠ 0 → R k ≤ B + location : dist x initialPoint < locationRadius n + triple : HasVertexTriple (meanField (physicalPressure (physicalProfile t σ R) t) a) x p (groupRadius τ n) + +def ConstructionStage.pressure {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : Parameter → ℝ := + physicalPressure (physicalProfile t s.σ s.R) t + +def ConstructionStage.ideal {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : Parameter → ℝ := + meanField s.pressure s.a + +lemma ConstructionStage.mass_total {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : + s.a+∑' k, s.σ k ≤ firstMass p+1 := + s.mass.trans (sub_le_self _ (geometricBudget_pos n).le) + +lemma ConstructionStage.base_mass {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : + ∑' k, s.σ k ≤ firstMass p+1 := by + linarith only [s.mass_total,s.a_pos] + +lemma ConstructionStage.a_le {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : + s.a ≤ firstMass p+1 := by + have hh : 0 ≤ ∑' k, s.σ k := tsum_nonneg s.σ_nonneg + linarith only [s.mass_total,hh] + +lemma ConstructionStage.x_near {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : + s.x ∈ ball initialPoint (1/8) := s.location.trans (locationRadius_lt n) + +lemma ConstructionStage.near_moderate {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) : + ball s.x (1/8) ⊆ closedBall initialPoint (1/4) := by + intro y hy + exact le_of_lt (calc + dist y initialPoint ≤ dist y s.x+dist s.x initialPoint := dist_triangle _ _ _ + _ < 1/4 := by have hh := s.x_near; change dist s.x initialPoint < 1/8 at hh; change dist y s.x < 1/8 at hy; linarith) + +lemma ConstructionStage.convex {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) + (hcap : ConstructionCap t (firstMass p+1)) : ConvexOn ℝ pressureDomain s.ideal := by + exact meanField_convex (physical_convex_bounded hcap.t_large s.σ_nonneg s.R_one s.σ_summable (hcap.weak s.base_mass)) + (physical_meanField_bounded hcap.t_large s.a_pos s.σ_nonneg s.R_one s.σ_summable + (hcap.weak s.base_mass) (hcap.lt_gap s.a_le)).1 + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConstructionStep.lean b/lean/OAI/Probability/ContinuumTransition/ConstructionStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..77f688845cb71fa5f28bd02df8644e7b87d7d0c3 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConstructionStep.lean @@ -0,0 +1,104 @@ +import OAI.Probability.ContinuumTransition.ConstructionStage + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +structure StageTransition {t p τ : ℝ} {n : ℕ} (s : ConstructionStage t p τ n) + (s' : ConstructionStage t p τ (n+1)) (Rnew : ℝ) : Prop where + range_large : 4 < Rnew + mass_eq : s'.σ = prepend s.a s.σ + range_eq : s'.R = prepend Rnew s.R + next_small : s'.a < geometricBudget n/2 + displacement : dist s'.x s.x < geometricBudget n/32 + approximation : ∀ y ∈ closedBall initialPoint (1/4), |s'.pressure y-s.ideal y| ≤ geometricBudget n + +lemma construction_step {t p τ γ : ℝ} (hp : 0 < p) (hτ : 0 < τ) (hτp : τ ≤ p/100) + (hγ : 0 < γ) (hcap : ConstructionCap t (firstMass p+1)) + (hgeom : ∀ w : Fin 3 → Parameter, (∀ i, dist (w i) (triangleVertex p i) ≤ τ) → + closedBall (triangleCenter p) γ ⊆ convexHull ℝ (range w)) + {n : ℕ} (s : ConstructionStage t p τ n) : + ∃ s' : ConstructionStage t p τ (n+1), ∃ Rnew, StageTransition s s' Rnew := by + have hWmod : closedBall initialPoint (1/4) ⊆ moderateBox := + (closedBall_subset_closedBall (by norm_num : (1:ℝ)/4 ≤ 1/2)).trans initial_ball_moderate + have hball := s.near_moderate.trans (hWmod.trans moderateBox_subset) + have hxmod : s.x ∈ moderateBox := hWmod (s.x_near.le.trans (by norm_num : (1:ℝ)/8 ≤ 1/4)) + have hxdom := moderateBox_subset hxmod + have hsl := s.triple.support_ball hp (groupRadius_le hτ.le n) hτp hgeom + have hb : groupRadius τ n ≤ p/100 := (groupRadius_le hτ.le n).trans hτp + let ε := τ*geometricBudget n/4 + have hε : 0 < ε := by dsimp [ε]; positivity [geometricBudget_pos n] + obtain ⟨S,hS,δ,hδ,hpersist⟩ := three_group_persistence (s.convex hcap) hxdom + (show (0:ℝ) < 1/8 by norm_num) hγ hball hsl + (slopeGroups_convex s.ideal s.x (triangleVertex p) (groupRadius τ n)) + (fun i j hij => HasVertexTriple.separated hp hb i j hij) s.triple.hull hε + (fun _ => inter_subset_right) (1048576^2) 1048576 + let ell := geometricBudget n/32 + have hell : 0 < ell := by dsimp [ell]; positivity [geometricBudget_pos n] + let a := min δ (min (ell/(S+1)) (geometricBudget n/2))/2 + have ha : 0 < a := by dsimp [a]; positivity [geometricBudget_pos n] + have ham : a < min δ (min (ell/(S+1)) (geometricBudget n/2)) := by dsimp [a] at ha ⊢; linarith + have haδ : a < δ := ham.trans_le (min_le_left _ _) + have haell : a < ell/(S+1) := ham.trans_le ((min_le_right _ _).trans (min_le_left _ _)) + have hapow : a < geometricBudget n/2 := ham.trans_le ((min_le_right _ _).trans (min_le_right _ _)) + have hSa : S*a < ell := by + have hh := (lt_div_iff₀ (show 0 < S+1 by linarith)).mp haell + nlinarith only [hh,ha] + obtain ⟨B,hB,hbound⟩ := s.referenceBounded + have hprec : 0 < min (a^2) (geometricBudget n) := lt_min (sq_pos_of_pos ha) (geometricBudget_pos n) + obtain ⟨Rnew,hRnew,hRbig,happ⟩ := physical_kac_approximate hcap s.a_pos s.σ_nonneg s.R_one s.σ_summable + s.mass_total hB hbound hprec (B+1) + let σ' := prepend s.a s.σ + let R' := prepend Rnew s.R + have hσ' : ∀ k, 0 ≤ σ' k := prepend_nonneg s.a_pos.le s.σ_nonneg + have hR' : ∀ k, 1 ≤ R' k := prepend_ge_one (by linarith) s.R_one + have hs' : Summable σ' := summable_prepend s.a s.σ_summable + have hmass' : ∑' k, σ' k = s.a+∑' k, s.σ k := tsum_prepend s.a s.σ_summable + have hm' : ∑' k, σ' k ≤ firstMass p+1 := hmass' ▸ s.mass_total + have htot : a+∑' k, σ' k ≤ firstMass p+1-geometricBudget (n+1) := by + rw [hmass',geometricBudget_succ] + linarith only [s.mass,hapow] + have haM : a ≤ firstMass p+1 := by + have hh : 0 ≤ ∑' k, σ' k := tsum_nonneg hσ' + have hh' := geometricBudget_pos (n+1) + linarith only [htot,hh,hh'] + let Q := physicalPressure (physicalProfile t σ' R') t + let P := meanField Q a + have hQ := physical_convex_bounded hcap.t_large hσ' hR' hs' (hcap.weak hm') + have hMF := physical_meanField_bounded hcap.t_large ha hσ' hR' hs' (hcap.weak hm') (hcap.lt_gap haM) + obtain ⟨z,hz,hzr,hg,hull⟩ := hpersist a ha haδ Q P hQ hMF.1 hMF.2 + (fun y hy => (happ y (s.near_moderate hy)).trans (min_le_left _ _)) + (physical_transform_gain hcap.t_large ha hσ' hR' hs' (hcap.weak hm') (hcap.lt_gap haM) + hxmod.1 hxmod.2.1 hxmod.2.2) + (fun y hy w hw => by + have hh := hWmod (s.near_moderate hy) + have hd := physical_transform_active_bound hcap.t_large ha hσ' hR' hs' (hcap.weak hm') (hcap.lt_gap haM) + hh.1 hh.2.1 hh.2.2 hw + simpa only [abs_of_nonneg hd.1] using hd.2) + have hdisp : dist z s.x < geometricBudget n/32 := hz.trans hSa + let s' : ConstructionStage t p τ (n+1) := { + σ := σ', R := R', a := a, x := z, + σ_nonneg := hσ', R_one := hR', σ_summable := hs', a_pos := ha, mass := htot, + referenceBounded := ⟨Rnew,by linarith,by + intro k hk + cases k with + | zero => exact le_refl _ + | succ k => exact (hbound k hk).trans (by linarith)⟩, + location := by + rw [locationRadius_succ] + have hh := dist_triangle z s.x initialPoint + linarith only [hh,hdisp,s.location], + triple := ⟨hg,by rw [groupRadius_succ]; exact hull⟩ } + refine ⟨s',Rnew,hRnew,rfl,rfl,hapow,hdisp,?_⟩ + intro y hy + exact (happ y hy).trans (min_le_right _ _) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConvexSupport.lean b/lean/OAI/Probability/ContinuumTransition/ConvexSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..147b2fe7cdb9dffe1c8c73f808419e01ee6b5454 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConvexSupport.lean @@ -0,0 +1,125 @@ +import OAI.Probability.ContinuumTransition.PressureGeometry + +namespace OAI + +universe u_1 + +section +open scoped Topology +open Filter Set +noncomputable section +namespace ContinuumTemperature + +def pDot (v w : Parameter) : ℝ := v.1*w.1+v.2*w.2 + +def SupportOn (S : Set Parameter) (F : Parameter → ℝ) (x v : Parameter) : Prop := + ∀ y ∈ S, F x + pDot v (y-x) ≤ F y + +def subgradients (S : Set Parameter) (F : Parameter → ℝ) (x : Parameter) : Set Parameter := + {v | SupportOn S F x v} + +lemma supports_iff_supportOn {F : Parameter → ℝ} {x v : Parameter} : + Supports F x v ↔ SupportOn pressureDomain F x v := by + simp only [Supports, SupportOn, pDot, Prod.fst_sub, Prod.snd_sub] + constructor <;> intro h y hy <;> have := h y hy <;> linarith + +lemma linear_parameter_eq (L : Parameter →L[ℝ] ℝ) (x : Parameter) : + L x = x.1*L (1,0)+x.2*L (0,1) := by + have he : x = x.1 • ((1,0) : Parameter) + x.2 • ((0,1) : Parameter) := by ext <;> simp + rw [he,L.map_add,L.map_smul,L.map_smul] + simp only [smul_eq_mul,Prod.fst_add,Prod.snd_add,Prod.smul_fst,Prod.smul_snd,mul_one,mul_zero,zero_add,add_zero] + +lemma linear_epigraph_eq (L : (Parameter × ℝ) →L[ℝ] ℝ) (x : Parameter) (r : ℝ) : + L (x,r) = x.1*L ((1,0),0)+x.2*L ((0,1),0)+r*L (0,1) := by + have he : (x,r) = x.1 • (((1,0),0) : Parameter × ℝ) + + x.2 • (((0,1),0) : Parameter × ℝ) + r • ((0,1) : Parameter × ℝ) := by ext <;> simp + rw [he,L.map_add,L.map_add,L.map_smul,L.map_smul,L.map_smul] + simp only [smul_eq_mul] + +lemma convex_exists_support {S : Set Parameter} (hS : IsOpen S) {F : Parameter → ℝ} + (hF : ConvexOn ℝ S F) {x : Parameter} (hx : x ∈ S) : + ∃ v, SupportOn S F x v := by + have hcont := hF.continuousOn hS + have hopen : IsOpen {p : Parameter × ℝ | p.1 ∈ S ∧ F p.1 < p.2} := by + apply isOpen_iff_mem_nhds.mpr + intro p hp + have hh : ContinuousAt (fun q : Parameter × ℝ => F q.1) p := + (hcont.continuousAt (hS.mem_nhds hp.1)).comp continuousAt_fst + have hlt := hh.eventually_lt continuousAt_snd hp.2 + filter_upwards [(hS.preimage continuous_fst).mem_nhds hp.1,hlt] with q hq hq' + exact ⟨hq,hq'⟩ + obtain ⟨L,hL⟩ := geometric_hahn_banach_point_open hF.convex_strict_epigraph hopen + (x := (x,F x)) (by simp) + let a := L (0,1) + let b := L ((1,0),0) + let c := L ((0,1),0) + have ha : 0 < a := by + have hh := hL (x,F x+1) ⟨hx,by linarith⟩ + rw [linear_epigraph_eq L x (F x),linear_epigraph_eq L x (F x+1)] at hh + dsimp [a] + nlinarith + have hle : ∀ y ∈ S, L (x,F x) ≤ L (y,F y) := by + intro y hy + apply le_of_forall_pos_le_add + intro ε hε + have hh := hL (y,F y+ε/a) ⟨hy,by have := div_pos hε ha; linarith⟩ + rw [linear_epigraph_eq L x (F x),linear_epigraph_eq L y (F y+ε/a)] at hh + rw [linear_epigraph_eq L x (F x),linear_epigraph_eq L y (F y)] + change x.1*b+x.2*c+F x*a < y.1*b+y.2*c+(F y+ε/a)*a at hh + change x.1*b+x.2*c+F x*a ≤ y.1*b+y.2*c+F y*a+ε + have he : (F y+ε/a)*a = F y*a+ε := by field_simp + rw [he] at hh + linarith only [hh] + refine ⟨(-b/a,-c/a),?_⟩ + intro y hy + have hh := hle y hy + rw [linear_epigraph_eq L x (F x),linear_epigraph_eq L y (F y)] at hh + change F x + ((-b/a)*(y.1-x.1)+(-c/a)*(y.2-x.2)) ≤ F y + apply (mul_le_mul_iff_left₀ ha).mp + dsimp [a,b,c] at * + field_simp + nlinarith + +lemma subgradients_closed (S : Set Parameter) (F : Parameter → ℝ) (x : Parameter) : + IsClosed (subgradients S F x) := by + simp only [subgradients,SupportOn,ofPred_forall] + apply isClosed_iInter + intro y + apply isClosed_iInter + intro _ + exact isClosed_le (by unfold pDot; fun_prop) continuous_const + +lemma subgradients_convex (S : Set Parameter) (F : Parameter → ℝ) (x : Parameter) : + Convex ℝ (subgradients S F x) := by + intro v hv w hw a b ha hb hab y hy + have hv' := hv y hy + have hw' := hw y hy + have hscaled := add_le_add (mul_le_mul_of_nonneg_left hv' ha) (mul_le_mul_of_nonneg_left hw' hb) + have hFx := congrArg (fun q : ℝ => q*F x) hab + have hFy := congrArg (fun q : ℝ => q*F y) hab + dsimp [pDot] at * + nlinarith only [hscaled,hFx,hFy] + +lemma supportOn_limit {ι : Type u_1} {l : Filter ι} [l.NeBot] + {S : Set Parameter} {F : Parameter → ℝ} (hF : ContinuousOn F S) + {x : Parameter} (hx : x ∈ S) {X V : ι → Parameter} {v : Parameter} + (hX : Tendsto X l (𝓝 x)) (hV : Tendsto V l (𝓝 v)) + (hXS : ∀ᶠ i in l, X i ∈ S) (h : ∀ᶠ i in l, SupportOn S F (X i) (V i)) : + SupportOn S F x v := by + intro y hy + have hf := hF x hx |>.tendsto.comp (tendsto_nhdsWithin_iff.2 ⟨hX,hXS⟩) + have hX1 : Tendsto (fun i => (X i).1) l (𝓝 x.1) := (continuous_fst.tendsto x).comp hX + have hX2 : Tendsto (fun i => (X i).2) l (𝓝 x.2) := (continuous_snd.tendsto x).comp hX + have hV1 : Tendsto (fun i => (V i).1) l (𝓝 v.1) := (continuous_fst.tendsto v).comp hV + have hV2 : Tendsto (fun i => (V i).2) l (𝓝 v.2) := (continuous_snd.tendsto v).comp hV + have hvv : Tendsto (fun i => pDot (V i) (y-X i)) l (𝓝 (pDot v (y-x))) := by + unfold pDot + exact (hV1.mul (tendsto_const_nhds.sub hX1)).add + (hV2.mul (tendsto_const_nhds.sub hX2)) + exact le_of_tendsto (hf.add hvv) (h.mono fun i hi => hi y hy) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConvexUniform.lean b/lean/OAI/Probability/ContinuumTransition/ConvexUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bd344318282fc0a750d5877ec5027c94ddc1de0 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConvexUniform.lean @@ -0,0 +1,116 @@ +import OAI.Probability.ContinuumTransition.ConvexSupport + +namespace OAI + +universe u_1 u_2 + +section +open scoped Topology NNReal +open Filter Set Metric +noncomputable section +namespace ContinuumTemperature + +variable {E : Type u_1} {ι : Type u_2} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + {l : Filter ι} [l.NeBot] {S : Set E} {F : ι → E → ℝ} {f : E → ℝ} + +omit [FiniteDimensional ℝ E] in +lemma convexOn_of_pointwise_tendsto (hconv : ∀ᶠ i in l, ConvexOn ℝ S (F i)) + (hlim : ∀ x ∈ S, Tendsto (fun i => F i x) l (𝓝 (f x))) : ConvexOn ℝ S f := by + obtain ⟨i,hi⟩ := hconv.exists + refine ⟨hi.1,?_⟩ + intro x hx y hy a b ha hb hab + have hz := hi.1 hx hy ha hb hab + exact le_of_tendsto_of_tendsto (hlim _ hz) + (((hlim x hx).const_mul a).add ((hlim y hy).const_mul b)) + (hconv.mono fun i hi => hi.2 hx hy ha hb hab) + +omit [l.NeBot] in + +lemma eventually_convex_lipschitz (hS : IsOpen S) + (hconv : ∀ᶠ i in l, ConvexOn ℝ S (F i)) + (hlim : ∀ x ∈ S, Tendsto (fun i => F i x) l (𝓝 (f x))) {x : E} (hx : x ∈ S) : + ∃ r > 0, ball x r ⊆ S ∧ ∃ C : ℝ≥0, ∀ᶠ i in l, LipschitzOnWith C (F i) (ball x r) := by + obtain ⟨b,hxb,hbS⟩ := exists_mem_interior_convexHull_affineBasis (hS.mem_nhds hx) + obtain ⟨M,hM⟩ := (finite_range (fun j => f (b j))).bddAbove + let C : ℝ := |M|+|f x|+2 + have hC : 0 < C := by dsimp [C]; positivity + have hv : ∀ᶠ i in l, ∀ j, F i (b j) ≤ C := by + apply eventually_all.mpr + intro j + have hb : b j ∈ S := hbS (subset_convexHull ℝ _ (mem_range_self j)) + filter_upwards [(hlim _ hb).eventually_lt_const (show f (b j) < f (b j)+1 by linarith)] with i hi + have hm := hM (mem_range_self j) + have hMle := le_abs_self M + have hxf := abs_nonneg (f x) + dsimp [C] + linarith + have hxlower : ∀ᶠ i in l, -C ≤ F i x := by + filter_upwards [(hlim _ hx).eventually_const_lt (show f x-1 < f x by linarith)] with i hi + have hxabs := neg_abs_le (f x) + have hm := abs_nonneg M + dsimp [C] + linarith + obtain ⟨r,hr,hrb⟩ := Metric.mem_nhds_iff.mp (isOpen_interior.mem_nhds hxb) + have hrh : ball x r ⊆ convexHull ℝ (range b) := hrb.trans interior_subset + refine ⟨r/2,by positivity,(ball_subset_ball (by linarith : r/2 ≤ r)).trans (hrh.trans hbS), + (2*(3*C)/(r/2)).toNNReal,?_⟩ + filter_upwards [hconv,hv,hxlower] with i hi hiv hix + have hub : ∀ y ∈ convexHull ℝ (range b), F i y ≤ C := by + have hh : convexHull ℝ (range b) ⊆ {y ∈ S | F i y ≤ C} := + convexHull_min (by rintro y ⟨j,rfl⟩; exact ⟨hbS (subset_convexHull ℝ _ (mem_range_self j)),hiv j⟩) + (hi.convex_le C) + exact fun y hy => (hh hy).2 + have habs : ∀ y, dist y x < r → |F i y| ≤ 3*C := by + intro y hy + have hyb := hrh hy + have hreflect : 2 • x-y ∈ ball x r := by + rw [mem_ball,dist_eq_norm_sub,show 2 • x-y-x = x-y by module,norm_sub_rev] + simpa only [dist_eq_norm_sub] using hy + have huby := hub y hyb + have hubr := hub _ (hrh hreflect) + have hmid := hi.2 (hbS hyb) (hbS (hrh hreflect)) + (show (0:ℝ) ≤ 1/2 by norm_num) (show (0:ℝ) ≤ 1/2 by norm_num) + (show (1/2:ℝ)+1/2=1 by norm_num) + have he : (1/2:ℝ) • y + (1/2:ℝ) • (2 • x-y) = x := by module + rw [he] at hmid + simp only [smul_eq_mul] at hmid + exact abs_le.mpr ⟨by linarith,by linarith⟩ + have hL := (hi.subset (hrh.trans hbS) (convex_ball x r)).lipschitzOnWith_of_abs_le + (show 0 < r/2 by positivity) habs + simpa only [show r-r/2=r/2 by ring] using hL + +theorem convex_pointwise_locally_uniform (hS : IsOpen S) + (hconv : ∀ᶠ i in l, ConvexOn ℝ S (F i)) + (hlim : ∀ x ∈ S, Tendsto (fun i => F i x) l (𝓝 (f x))) : + TendstoLocallyUniformlyOn F f l S := by + have hf := (convexOn_of_pointwise_tendsto hconv hlim).continuousOn hS + apply Metric.tendstoLocallyUniformlyOn_iff.mpr + intro ε hε x hx + obtain ⟨r,hr,_,C,hC⟩ := eventually_convex_lipschitz hS hconv hlim hx + have hfnear : ∀ᶠ y in 𝓝 x, dist (f y) (f x) < ε/3 := + (hf.continuousAt (hS.mem_nhds hx)).eventually (ball_mem_nhds _ (by positivity)) + let T := ball x r ∩ ball x (ε/(3*((C:ℝ)+1))) ∩ {y | dist (f y) (f x) < ε/3} + have hT : T ∈ 𝓝 x := inter_mem (inter_mem (ball_mem_nhds _ hr) + (ball_mem_nhds _ (by positivity))) hfnear + refine ⟨T,nhdsWithin_le_nhds hT,?_⟩ + filter_upwards [hC,(hlim x hx).eventually (ball_mem_nhds _ (show 0 < ε/3 by positivity))] + with i hi hxlim + intro y hy + have hd := lipschitzOnWith_iff_dist_le_mul.mp hi x (mem_ball_self hr) y hy.1.1 + have hεC : 0 < 3*((C:ℝ)+1) := by positivity + have hyd : dist x y < ε/(3*((C:ℝ)+1)) := by simpa only [mem_ball,dist_comm] using hy.1.2 + have hdd : (C:ℝ)*dist x y < ε/3 := by + have he := (lt_div_iff₀ hεC).mp hyd + have hnn := dist_nonneg (x := x) (y := y) + nlinarith + have hb : dist (f x) (F i x) < ε/3 := by simpa only [mem_ball,dist_comm] using hxlim + have hyf : dist (f y) (f x) < ε/3 := hy.2 + calc + dist (f y) (F i y) ≤ dist (f y) (f x)+dist (f x) (F i x)+dist (F i x) (F i y) := dist_triangle4 _ _ _ _ + _ < ε := by linarith only [hyf,hb,hd,hdd] + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ConvolutionLimit.lean b/lean/OAI/Probability/ContinuumTransition/ConvolutionLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..13269583cc4da322a14f011225b085740864606c --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ConvolutionLimit.lean @@ -0,0 +1,79 @@ +import OAI.Probability.ContinuumTransition.IdealSlopes + +namespace OAI + +universe u_1 u_2 + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +lemma locallyUniform_reindex {ι : Type u_1} {κ : Type u_2} {l : Filter ι} {k : Filter κ} + {Q : ι → Parameter → ℝ} {q : Parameter → ℝ} + (hQ : TendstoLocallyUniformlyOn Q q l pressureDomain) + {θ : κ → ι} (hθ : Tendsto θ k l) : + TendstoLocallyUniformlyOn (fun n => Q (θ n)) q k pressureDomain := by + intro u hu x hx + obtain ⟨t,ht,h⟩ := hQ u hu x hx + exact ⟨t,ht,hθ.eventually h⟩ + +lemma quadraticCost_tendsto {Q : ℕ → Parameter → ℝ} {q : Parameter → ℝ} + (hQ : TendstoLocallyUniformlyOn Q q atTop pressureDomain) + (hq : ContinuousOn q pressureDomain) + {a d : ℕ → ℝ} {a₀ d₀ : ℝ} (ha : Tendsto a atTop (𝓝 a₀)) + (hd : Tendsto d atTop (𝓝 d₀)) {X : ℕ → Parameter} {x : Parameter} + (hx : x ∈ pressureDomain) (hX : Tendsto X atTop (𝓝 x)) : + Tendsto (fun n => quadraticCost (Q n) (a n) (X n) (d n)) atTop + (𝓝 (quadraticCost q a₀ x d₀)) := by + have hX1 := (continuous_fst.tendsto x).comp hX + have hX2 := (continuous_snd.tendsto x).comp hX + have hf : Tendsto (fun n => shiftedField (a n) (X n) (d n)) atTop + (𝓝 (shiftedField a₀ x d₀)) := + hX1.prodMk_nhds (hX2.add ((hX1.mul ha).mul hd)) + have he : ∀ᶠ n in atTop, shiftedField (a n) (X n) (d n) ∈ pressureDomain := + (hX.eventually (isOpen_pressureDomain.mem_nhds hx)) + have hval := hQ.tendsto_comp (hq _ (show shiftedField a₀ x d₀ ∈ pressureDomain from hx)) + (show shiftedField a₀ x d₀ ∈ pressureDomain from hx) (tendsto_nhdsWithin_iff.2 ⟨hf,he⟩) + exact hval.sub (((hX1.mul ha).mul (hd.pow 2)).div_const 2) + +lemma meanField_tendsto_of_bounded_maximizers {Q : ℕ → Parameter → ℝ} {q : Parameter → ℝ} + {P : ℕ → Parameter → ℝ} {p : Parameter → ℝ} {a : ℕ → ℝ} {a₀ : ℝ} + (hQ : TendstoLocallyUniformlyOn Q q atTop pressureDomain) (hq : ContinuousOn q pressureDomain) + (ha : Tendsto a atTop (𝓝 a₀)) (hP : ∀ n, IsMeanField (Q n) (a n) (P n)) + (hp : IsMeanField q a₀ p) {X : ℕ → Parameter} {x : Parameter} + (hx : x ∈ pressureDomain) (hX : Tendsto X atTop (𝓝 x)) + (hXS : ∀ n, X n ∈ pressureDomain) {D : ℝ} + (hatt : ∀ n, ∃ d ∈ Icc 0 D, quadraticCost (Q n) (a n) (X n) d = P n (X n)) : + Tendsto (fun n => P n (X n)) atTop (𝓝 (p x)) := by + choose d hd he using hatt + apply metric_tendsto_of_subseq + intro φ hφ + obtain ⟨r,_,ψ,hψ,hr⟩ := (isCompact_Icc : IsCompact (Icc (0:ℝ) D)).tendsto_subseq + (fun n => hd (φ n)) + let θ := φ ∘ ψ + have hθ := (hφ.comp hψ).tendsto_atTop + have hlim := quadraticCost_tendsto (locallyUniform_reindex hQ hθ) hq (ha.comp hθ) hr hx (hX.comp hθ) + have hle : quadraticCost q a₀ x r ≤ p x := (hp x hx).1 (mem_range_self r) + have hge : p x ≤ quadraticCost q a₀ x r := by + apply (hp x hx).2 + rintro _ ⟨s,rfl⟩ + have hs := quadraticCost_tendsto (locallyUniform_reindex hQ hθ) hq (ha.comp hθ) + (tendsto_const_nhds (x := s)) hx (hX.comp hθ) + apply le_of_tendsto_of_tendsto hs hlim + exact Eventually.of_forall fun n => by + change quadraticCost (Q (θ n)) (a (θ n)) (X (θ n)) s ≤ + quadraticCost (Q (θ n)) (a (θ n)) (X (θ n)) (d (θ n)) + rw [he] + exact (hP (θ n) _ (hXS (θ n))).1 (mem_range_self s) + have heq := le_antisymm hle hge + refine ⟨ψ,hψ,?_⟩ + rw [heq] at hlim + exact hlim.congr (fun n => he (θ n)) + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CubeBoundary.lean b/lean/OAI/Probability/ContinuumTransition/CubeBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..405b6493b68ab2819fb43f38141c7e824daa3527 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CubeBoundary.lean @@ -0,0 +1,82 @@ +import OAI.Probability.ContinuumTransition.GridBoundary + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +noncomputable def gridIndices (m q : ℕ) : Finset Lattice := + Fintype.piFinset (fun _ : Fin 3 => indexInterval m q) + +noncomputable def boundaryIndices (m q H : ℕ) : Finset Lattice := + Finset.univ.biUnion (fun i : Fin 3 => Fintype.piFinset + (fun j : Fin 3 => if j = i then edgeIndices m q H else indexInterval m q)) + +theorem card_gridIndices (m q : ℕ) : (gridIndices m q).card = (2*m*q+1)^3 := by + simp only [gridIndices, Fintype.card_piFinset, card_indexInterval, Finset.prod_const, + Finset.card_univ, Fintype.card_fin] + +theorem card_boundaryIndices_le (m q H : ℕ) (hq : 0 < q) : + (boundaryIndices m q H).card ≤ 3*((2*m+1)*(2*H))*(2*m*q+1)^2 := by + have hc (i : Fin 3) : (Fintype.piFinset (fun j : Fin 3 => + if j = i then edgeIndices m q H else indexInterval m q)).card ≤ + ((2*m+1)*(2*H))*(2*m*q+1)^2 := by + rw [Fintype.card_piFinset] + have he : (∏ j : Fin 3, (if j = i then edgeIndices m q H else indexInterval m q).card) = + (edgeIndices m q H).card*(indexInterval m q).card^2 := by + fin_cases i <;> simp [Fin.prod_univ_succ] <;> ring + rw [he, card_indexInterval] + exact Nat.mul_le_mul_right _ (card_edgeIndices_le m q H hq) + have hh := Finset.card_biUnion_le (s := (Finset.univ : Finset (Fin 3))) + (t := fun i : Fin 3 => Fintype.piFinset + (fun j : Fin 3 => if j = i then edgeIndices m q H else indexInterval m q)) + have hh' := hh.trans (Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset (Fin 3))) => hc i)) + simpa only [boundaryIndices, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + smul_eq_mul, mul_assoc] using hh' + +theorem mem_boundaryIndices {m q H : ℕ} {k : Lattice} (hk : k ∈ gridIndices m q) + (he : ∃ i, k i ∈ edgeIndices m q H) : k ∈ boundaryIndices m q H := by + obtain ⟨i, hi⟩ := he + apply Finset.mem_biUnion.mpr ⟨i, Finset.mem_univ i, ?_⟩ + apply Fintype.mem_piFinset.mpr + intro j + by_cases hj : j = i + · simpa only [ite_eq_left hj, hj, ite_true] using hi + · simpa only [ite_eq_right hj] using (Fintype.mem_piFinset.mp hk j) + +theorem cellIndex_mem_gridIndices {m q : ℕ} {x : Space} + (hx : x ∈ cube ((m : ℝ)*(q : ℝ)/2)) : cellIndex x ∈ gridIndices m q := by + apply Fintype.mem_piFinset.mpr + intro i + apply Finset.mem_Icc.mpr + have hxi := hx i + change -↑m*↑q ≤ ⌊4*x i⌋ ∧ ⌊4*x i⌋ ≤ ↑m*↑q + constructor + · apply Int.le_floor.mpr + push_cast + change -((m : ℝ)*(q : ℝ)/2)/2 ≤ x i ∧ x i ≤ ((m : ℝ)*(q : ℝ)/2)/2 at hxi + linarith [hxi.1] + · apply Int.floor_le_iff.mpr + push_cast + change -((m : ℝ)*(q : ℝ)/2)/2 ≤ x i ∧ x i ≤ ((m : ℝ)*(q : ℝ)/2)/2 at hxi + linarith [hxi.2] + +theorem boundary_of_close_crossing {q H : ℕ} (hq : 0 < q) {m : ℕ} {x y : Space} + (hx : x ∈ cube ((m : ℝ)*(q : ℝ)/2)) + (hd : ∀ i, |cellIndex x i-cellIndex y i| ≤ (H : ℤ)) + (hc : gridIndex ((q : ℝ)/4) x ≠ gridIndex ((q : ℝ)/4) y) : + cellIndex x ∈ boundaryIndices m q H := by + have hk := cellIndex_mem_gridIndices hx + apply mem_boundaryIndices hk + rw [gridIndex_quarter_nat, gridIndex_quarter_nat] at hc + obtain ⟨i, hi⟩ := Function.ne_iff.mp hc + refine ⟨i, Finset.mem_filter.mpr ⟨Fintype.mem_piFinset.mp hk i, ?_⟩⟩ + exact edgeResidue_of_crossing hq (hd i) hi + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/CubeCoercivity.lean b/lean/OAI/Probability/ContinuumTransition/CubeCoercivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c5839bf5516d7f3930ccb17d402f42c8bfa6279 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/CubeCoercivity.lean @@ -0,0 +1,92 @@ +import OAI.Probability.ContinuumTransition.Stability + +namespace OAI + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature +noncomputable section +open scoped ContDiff +open scoped InnerProductSpace + +noncomputable def cubeCells (L : ℝ) : Finset Lattice := + Fintype.piFinset (fun _ : Fin 3 => Finset.Icc ⌊-2 * L⌋ ⌊2 * L⌋) + +theorem cellIndex_mem_cubeCells {L : ℝ} {x : Space} (hx : x ∈ cube L) : + cellIndex x ∈ cubeCells L := by + classical + simp only [cubeCells, Fintype.mem_piFinset, Finset.mem_Icc, cellIndex] + intro k + constructor + · apply Int.floor_mono + have h := (hx k).1 + linarith + · apply Int.floor_mono + have h := (hx k).2 + linarith + +theorem card_cubeCells_le {L : ℝ} (hL : 0 ≤ L) : + ((cubeCells L).card : ℝ) ≤ (4 * L + 2) ^ 3 := by + classical + let m := (Finset.Icc ⌊-2 * L⌋ ⌊2 * L⌋).card + have horder : ⌊-2 * L⌋ ≤ ⌊2 * L⌋ + 1 := by + have hh := Int.floor_mono (show -2 * L ≤ 2 * L by linarith) + omega + have hcInt := Int.card_Icc_of_le ⌊-2 * L⌋ ⌊2 * L⌋ horder + have hcReal : (m : ℝ) = (⌊2 * L⌋ : ℝ) + 1 - (⌊-2 * L⌋ : ℝ) := by + dsimp only [m] + exact_mod_cast hcInt + have hm : (m : ℝ) ≤ 4 * L + 2 := by + rw [hcReal] + have hu := Int.floor_le (2 * L) + have hl := Int.lt_floor_add_one (-2 * L) + linarith + have hc : ((cubeCells L).card : ℝ) = (m : ℝ) ^ 3 := by + simp [cubeCells, Fintype.card_piFinset, m] + rw [hc] + exact pow_le_pow_left₀ (Nat.cast_nonneg m) hm 3 + +theorem physicalProfile_energy_coercive {t L : ℝ} (ht : 0 ≤ t) (hL : 0 ≤ L) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197 * t * kernelHeight * (∑' n, σ n) / 2 ≤ t ^ 2 / 8) + (N : ℕ) (x : Fin N → Space) (hx : ∀ i, x i ∈ cube L) : + (((t ^ 2 / 8 - 2197 * t * kernelHeight * (∑' n, σ n) / 2) * + ((N : ℝ) ^ 2 / (4 * L + 2) ^ 3) - t ^ 2 / 2 * N : ℝ) : EReal) ≤ + energy (physicalProfile t σ R) x := by + classical + let κ := (cubeCells L : Type) + let c (i : Fin N) : κ := ⟨cellIndex (x i), cellIndex_mem_cubeCells (hx i)⟩ + let n (k : κ) : ℝ := Fintype.card {i // c i = k} + have hsN : (∑ k : κ, n k) = N := by + have hh := sum_comp_eq_sum_fibres c (fun _ => (1 : ℝ)) + simpa only [n, mul_one, Finset.sum_const, Finset.card_univ, Fintype.card_fin, + nsmul_eq_mul, mul_one] using hh.symm + have hquad : (N : ℝ) ^ 2 ≤ (Fintype.card κ : ℝ) * ∑ k, n k ^ 2 := by + have hh := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset κ) (fun _ => (1 : ℝ)) n + simpa only [one_mul, one_pow, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, + mul_one, hsN] using hh + have hquad' : (N : ℝ) ^ 2 ≤ (4 * L + 2) ^ 3 * ∑ k, n k ^ 2 := by + apply hquad.trans + apply mul_le_mul_of_nonneg_right _ (Finset.sum_nonneg (fun _ _ => sq_nonneg _)) + simpa only [κ, Fintype.card_coe] using card_cubeCells_le hL + have hden : 0 < (4 * L + 2) ^ 3 := by positivity + have hquot : (N : ℝ) ^ 2 / (4 * L + 2) ^ 3 ≤ ∑ k, n k ^ 2 := by + apply (div_le_iff₀ hden).mpr + simpa only [mul_comm] using hquad' + have hsuper := physicalProfile_superstable ht hσ hR hs x c + (fun k : κ => (k : Lattice)) Subtype.val_injective (fun _ => rfl) + have he := coe_pairSum_le_energy (physicalProfile t σ R) x + apply le_trans _ he + apply EReal.coe_le_coe_iff.mpr + have hm := mul_le_mul_of_nonneg_left hquot (sub_nonneg.mpr hsmall) + simp only [Fintype.card_fin] at hsuper + exact (sub_le_sub_right hm _).trans hsuper + +end + +end ContinuumTemperature + +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/DensityBounds.lean b/lean/OAI/Probability/ContinuumTransition/DensityBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..68d8f8608e608db56dbcaca21e345529e3639501 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/DensityBounds.lean @@ -0,0 +1,49 @@ +import OAI.Probability.ContinuumTransition.ActiveSupports + +namespace OAI + +section +open scoped Topology +open Set Filter MeasureTheory +noncomputable section +namespace ContinuumTemperature + +lemma physicalCanonical_quadratic_lower {t β d : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n)/2 ≤ t^2/8) (hd : 0 ≤ d) : + (β*((t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/64)/t)*d^2- + (β*t/2)*d-1/t ≤ physicalCanonical (physicalProfile t σ R) t β d := by + have hh := canonicalDensity_lower_coercive ht hβ hσ hR hs hsmall hd + have he := entropy_dual_bound 0 hd + norm_num only [zero_mul,Real.exp_zero,zero_sub] at he + apply (le_div_iff₀ (lt_trans zero_lt_one ht)).mpr + have hne : t ≠ 0 := (lt_trans zero_lt_one ht).ne' + field_simp [hne] + nlinarith only [he,hh] + +lemma physical_meanField_attained {t a : ℝ} (ht : 1 < t) (ha : 0 < a) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n)/2 ≤ t^2/8) + (hgap : t*a/2 < (t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/64) + {x : Parameter} (hx : x ∈ pressureDomain) : + ∃ d, quadraticCost (physicalPressure (physicalProfile t σ R) t) a x d = + meanField (physicalPressure (physicalProfile t σ R) t) a x := by + have ht0 : 0 < t := lt_trans zero_lt_one ht + have hφ := measurable_radialPotential (measurable_physicalProfile t hσ hR hs) + have hst := physicalProfile_stable ht0.le hσ hR hs hsmall + have hcore := fun r (_ : 0 < r) => physicalProfile_le_core ht0.le hσ hR r + have hP := isMeanField_meanField (physical_meanField ht ha.le hσ hR hs hsmall hgap.le) + apply meanField_attained ha (continuousOn_physicalPressure hφ ht hst hcore) hP hx + (fun h => physicalPressure_isLUB hφ ht (le_of_lt hx) hst hcore (h := h)) + (c := x.1*((t^2/8-2197*t*kernelHeight*(∑' n, σ n)/2)/64)/t) + (b := x.1*t/2) (k := 1/t) + · apply (lt_div_iff₀ ht0).mpr + have hh := mul_lt_mul_of_pos_left hgap hx + nlinarith only [hh] + · exact fun d hd => physicalCanonical_quadratic_lower ht (le_of_lt hx) hσ hR hs hsmall hd + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/DensityLimit.lean b/lean/OAI/Probability/ContinuumTransition/DensityLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdf25165d660f5853e881440676cdfec93041286 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/DensityLimit.lean @@ -0,0 +1,195 @@ +import OAI.Probability.ContinuumTransition.BoxTiling + +namespace OAI + +universe u_1 + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature + +noncomputable def densityFilter (d : ℝ) : Filter (ℝ × ℕ) := + Filter.comap (fun p : ℝ × ℕ => (p.1, (p.2 : ℝ)/p.1^3)) (atTop ×ˢ 𝓝 d) + +instance densityFilter_countablyGenerated (d : ℝ) : (densityFilter d).IsCountablyGenerated := + inferInstanceAs (Filter.comap _ _).IsCountablyGenerated + +theorem densityFilter_length (d : ℝ) : + Tendsto (fun p : ℝ × ℕ => p.1) (densityFilter d) atTop := by + have h : Tendsto (fun p : ℝ × ℕ => (p.1, (p.2 : ℝ)/p.1^3)) + (densityFilter d) (atTop ×ˢ 𝓝 d) := Filter.tendsto_comap + simpa only [Function.comp_def] using + (tendsto_fst : Tendsto (Prod.fst : ℝ × ℝ → ℝ) (atTop ×ˢ 𝓝 d) atTop).comp h + +theorem densityFilter_density (d : ℝ) : + Tendsto (fun p : ℝ × ℕ => (p.2 : ℝ)/p.1^3) (densityFilter d) (𝓝 d) := + tendsto_snd.comp (Filter.tendsto_comap : Tendsto _ (densityFilter d) _) + +theorem tendsto_densityFilter_iff {α : Type u_1} {l : Filter α} {d : ℝ} {p : α → ℝ × ℕ} : + Tendsto p l (densityFilter d) ↔ + Tendsto (fun x => (p x).1) l atTop ∧ + Tendsto (fun x => ((p x).2 : ℝ)/(p x).1^3) l (𝓝 d) := by + rw [densityFilter, tendsto_comap_iff, tendsto_prod_iff'] + rfl + +theorem floor_density_tendsto {d : ℝ} (hd : 0 ≤ d) : + Tendsto (fun L : ℝ => (L, ⌊d*L^3⌋₊)) atTop (densityFilter d) := by + apply tendsto_densityFilter_iff.2 + exact ⟨tendsto_id, (tendsto_nat_floor_mul_div_atTop hd).comp + (tendsto_pow_atTop (by norm_num : 3 ≠ 0))⟩ + +instance densityFilter_neBot (d : ℝ) [Fact (0 ≤ d)] : (densityFilter d).NeBot := + (floor_density_tendsto (Fact.out : 0 ≤ d)).neBot + +theorem tileCount_asymptotic {ℓ : ℝ} (hℓ : 0 ≤ ℓ) : + Tendsto (fun L : ℝ => (tileCount ℓ L : ℝ)/L^3) atTop (𝓝 ((ℓ+2)⁻¹^3)) := by + have hh : 0 ≤ (ℓ+2)⁻¹ := inv_nonneg.mpr (by linarith) + have ht := (tendsto_nat_floor_mul_div_atTop hh).pow 3 + simpa only [tileCount, Nat.cast_pow, div_pow, div_eq_mul_inv, mul_comm, + mul_pow, inv_pow] using ht + +theorem length_inv_cube_tendsto (d : ℝ) : + Tendsto (fun p : ℝ × ℕ => (p.1^3)⁻¹) (densityFilter d) (𝓝 0) := by + simpa only [Function.comp_def, ← inv_pow, zero_pow (by norm_num : 3 ≠ 0)] using + (tendsto_inv_atTop_zero.pow 3).comp (densityFilter_length d) + +def DensityBounded (a : ℝ → ℕ → ℝ) : Prop := + ∀ D : ℝ, 0 < D → ∃ M R : ℝ, 0 < M ∧ 0 < R ∧ + ∀ L : ℝ, R ≤ L → ∀ n : ℕ, (n : ℝ) ≤ D*L^3 → |a L n| ≤ M + +def HasBoxInequality (a : ℝ → ℕ → ℝ) : Prop := + ∀ ℓ L : ℝ, 0 < ℓ → 0 < L → ∀ r : Fin (tileCount ℓ L) → ℕ, + a L (∑ i, r i) ≤ ℓ^3/L^3 * ∑ i, a ℓ (r i) + +theorem density_eventually_bounded {a : ℝ → ℕ → ℝ} (ha : DensityBounded a) + {d : ℝ} (hd : 0 ≤ d) : + ∃ M : ℝ, ∀ᶠ p in densityFilter d, |a p.1 p.2| ≤ M := by + obtain ⟨M, R, -, hR, hb⟩ := ha (d+1) (by linarith) + refine ⟨M, ?_⟩ + filter_upwards [(densityFilter_length d).eventually (eventually_ge_atTop R), + (densityFilter_density d).eventually (eventually_le_nhds (by linarith : d < d+1))] with p hp hpd + exact hb p.1 hp p.2 ((div_le_iff₀ (pow_pos (hR.trans_le hp) 3)).1 hpd) + +theorem densityFilter_bounded {a : ℝ → ℕ → ℝ} (ha : DensityBounded a) + {d : ℝ} (hd : 0 ≤ d) : + (densityFilter d).IsBoundedUnder (· ≤ ·) (fun p => a p.1 p.2) ∧ + (densityFilter d).IsBoundedUnder (· ≥ ·) (fun p => a p.1 p.2) := by + obtain ⟨M, hM⟩ := density_eventually_bounded ha hd + exact ⟨⟨M, hM.mono (fun _ h => (abs_le.mp h).2)⟩, + ⟨-M, hM.mono (fun _ h => (abs_le.mp h).1)⟩⟩ + +theorem limsup_box_comparison {a : ℝ → ℕ → ℝ} (ha : DensityBounded a) + (hbox : HasBoxInequality a) {d ℓ M : ℝ} {b H : ℕ} + (hd : 0 ≤ d) (hℓ : 0 < ℓ) (hM : 0 ≤ M) (hb : 0 < b) (hH : 2*b ≤ H) + (hcap : d < (ℓ+2)⁻¹^3 * H) + (hbound : ∀ n, n ≤ H → a ℓ n ≤ M) (hbase : -M ≤ a ℓ b) : + limsup (fun p : ℝ × ℕ => a p.1 p.2) (densityFilter d) ≤ + (ℓ+2)⁻¹^3 * ℓ^3 * a ℓ b + (2*M*ℓ^3/(b : ℝ)) * |d-(ℓ+2)⁻¹^3*b| := by + let : Fact (0 ≤ d) := ⟨hd⟩ + have ht := (tileCount_asymptotic hℓ.le).comp (densityFilter_length d) + have hcap' := (densityFilter_density d).eventually_lt (ht.mul_const (H : ℝ)) hcap + have hcomp : (fun p : ℝ × ℕ => a p.1 p.2) ≤ᶠ[densityFilter d] + (fun p : ℝ × ℕ => ((tileCount ℓ p.1 : ℝ)/p.1^3)*ℓ^3*a ℓ b + + (2*M*ℓ^3/(b : ℝ)) * (|(p.2 : ℝ)/p.1^3 - ((tileCount ℓ p.1 : ℝ)/p.1^3)*b| + H/p.1^3)) := by + filter_upwards [(densityFilter_length d).eventually (eventually_gt_atTop 0), hcap'] with p hp hc + have hnc : p.2 ≤ tileCount ℓ p.1 * H := by + have hh : (p.2 : ℝ) < (tileCount ℓ p.1 : ℝ)*H := by + apply (div_lt_div_iff_of_pos_right (pow_pos hp 3)).mp + simpa only [div_mul_eq_mul_div, Function.comp_def] using hc + exact_mod_cast hh.le + exact adjusted_box_comparison a hℓ hp hM hb hH hnc + (fun r hr => hr ▸ hbox ℓ p.1 hℓ hp r) hbound hbase + have htail : Tendsto (fun p : ℝ × ℕ => (H : ℝ)/p.1^3) (densityFilter d) (𝓝 0) := by + simpa only [div_eq_mul_inv, mul_zero] using (length_inv_cube_tendsto d).const_mul (H : ℝ) + have hlim := ((ht.mul_const (ℓ^3)).mul_const (a ℓ b)).add + ((((densityFilter_density d).sub (ht.mul_const (b : ℝ))).abs.add htail).const_mul (2*M*ℓ^3/(b : ℝ))) + simp only [add_zero, Function.comp_def] at hlim + have hle := limsup_le_limsup hcomp (densityFilter_bounded ha hd).2.isCobounded_le hlim.isBoundedUnder_le + rwa [hlim.limsup_eq] at hle + + theorem dilution_tendsto_one : + Tendsto (fun L : ℝ => (L+2)⁻¹^3*L^3) atTop (𝓝 1) := by + have hh : Tendsto (fun L : ℝ => 1/(1+2*L⁻¹)) atTop (𝓝 1) := by + have hh := ((tendsto_const_nhds (x := (1 : ℝ))).div + (tendsto_const_nhds.add (tendsto_inv_atTop_zero.const_mul 2)) + (by norm_num : (1 : ℝ)+2*0 ≠ 0)) + change Tendsto (fun L : ℝ => 1/(1+2*L⁻¹)) atTop (𝓝 (1/(1+2*0))) at hh + simpa only [mul_zero, add_zero, div_one] using hh + have hpow : Tendsto (fun L : ℝ => (1/(1+2*L⁻¹))^3) atTop (𝓝 1) := by + simpa only [one_pow] using hh.pow 3 + apply hpow.congr' + filter_upwards [eventually_gt_atTop (0 : ℝ)] with L hL + have h1 : 1+2*L⁻¹ ≠ 0 := by positivity + have h2 : L+2 ≠ 0 := by linarith + field_simp + +theorem exists_density_limit {a : ℝ → ℕ → ℝ} (ha : DensityBounded a) + (hbox : HasBoxInequality a) {d : ℝ} (hd : 0 < d) : + ∃ I : ℝ, Tendsto (fun p : ℝ × ℕ => a p.1 p.2) (densityFilter d) (𝓝 I) := by + let : Fact (0 ≤ d) := ⟨hd.le⟩ + obtain ⟨hbup, hbdown⟩ := densityFilter_bounded ha hd.le + obtain ⟨p, hpA, hp⟩ := exists_seq_tendsto_liminf hbup.isCobounded_ge hbdown + obtain ⟨hpL, hpd⟩ := tendsto_densityFilter_iff.mp hp + let D : ℝ := 4*d+4 + have hD : 0 < D := by dsimp [D]; linarith + obtain ⟨M, R, hM, hR, hbound⟩ := ha D hD + let H : ℕ → ℕ := fun j => ⌊D*(p j).1^3⌋₊ + have hα : Tendsto (fun j => ((p j).1+2)⁻¹^3*(p j).1^3) atTop (𝓝 1) := by + simpa only [Function.comp_def] using dilution_tendsto_one.comp hpL + have hHratio : Tendsto (fun j => (H j : ℝ)/(p j).1^3) atTop (𝓝 D) := by + exact (tendsto_nat_floor_mul_div_atTop hD.le).comp + ((tendsto_pow_atTop (by norm_num : 3 ≠ 0)).comp hpL) + have hbd : Tendsto (fun j => ((p j).1+2)⁻¹^3*((p j).2 : ℝ)) atTop (𝓝 d) := by + have hh : Tendsto (fun j => (((p j).1+2)⁻¹^3*(p j).1^3)* + ((p j).2 : ℝ)/(p j).1^3) atTop (𝓝 d) := by + simpa only [one_mul, mul_div_assoc] using hα.mul hpd + apply hh.congr' + filter_upwards [hpL.eventually (eventually_gt_atTop 0)] with j hj + field_simp + have hHd : Tendsto (fun j => ((p j).1+2)⁻¹^3*(H j : ℝ)) atTop (𝓝 D) := by + have hh := hα.mul hHratio + simp only [one_mul] at hh + apply hh.congr' + filter_upwards [hpL.eventually (eventually_gt_atTop 0)] with j hj + field_simp + have hcoef : Tendsto (fun j => 2*M*(p j).1^3/((p j).2 : ℝ)) atTop (𝓝 (2*M/d)) := by + have hh := (tendsto_const_nhds : Tendsto (fun _ : ℕ => 2*M) atTop (𝓝 (2*M))).div hpd hd.ne' + change Tendsto (fun j => (2*M)/(((p j).2 : ℝ)/(p j).1^3)) atTop (𝓝 (2*M/d)) at hh + simpa only [div_div_eq_mul_div] using hh + have hfit : ∀ᶠ j in atTop, 2*(p j).2 ≤ H j := by + have hh := (hpd.const_mul 2).eventually_lt hHratio (show 2*d < D by dsimp [D]; linarith) + filter_upwards [hh, hpL.eventually (eventually_gt_atTop 0)] with j hj hL + have hh' : (2 : ℝ)*(p j).2 < H j := by + apply (div_lt_div_iff_of_pos_right (pow_pos hL 3)).mp + simpa only [mul_div_assoc] using hj + exact_mod_cast hh'.le + have hpositive : ∀ᶠ j in atTop, 0 < (p j).2 := by + filter_upwards [hpd.eventually (eventually_gt_nhds hd), + hpL.eventually (eventually_gt_atTop 0)] with j hj hL + have hh : (0 : ℝ) < (p j).2 := (div_pos_iff_of_pos_right (pow_pos hL 3)).1 hj + exact_mod_cast hh + have hcomp : ∀ᶠ j in atTop, + limsup (fun p : ℝ × ℕ => a p.1 p.2) (densityFilter d) ≤ + ((p j).1+2)⁻¹^3 * (p j).1^3 * a (p j).1 (p j).2 + + (2*M*(p j).1^3/((p j).2 : ℝ)) * |d-((p j).1+2)⁻¹^3*(p j).2| := by + filter_upwards [hpL.eventually (eventually_ge_atTop R), hfit, hpositive, + hHd.eventually (eventually_gt_nhds (show d < D by dsimp [D]; linarith))] with j hL hfit hb hcap + have hLpos := hR.trans_le hL + have hHle : (H j : ℝ) ≤ D*(p j).1^3 := Nat.floor_le (by positivity) + apply limsup_box_comparison ha hbox hd.le hLpos hM.le hb hfit hcap + · intro n hn + exact (abs_le.mp (hbound (p j).1 hL n ((by exact_mod_cast hn : (n : ℝ) ≤ H j).trans hHle))).2 + · have hn : (p j).2 ≤ H j := by omega + exact (abs_le.mp (hbound (p j).1 hL (p j).2 + ((by exact_mod_cast hn : ((p j).2 : ℝ) ≤ H j).trans hHle))).1 + have hlim := (hα.mul hpA).add (hcoef.mul (((tendsto_const_nhds (x := d)).sub hbd).abs)) + simp only [one_mul, sub_self, abs_zero, mul_zero, add_zero, Function.comp_def] at hlim + have hle := le_of_tendsto_of_tendsto tendsto_const_nhds hlim hcomp + exact ⟨liminf (fun p : ℝ × ℕ => a p.1 p.2) (densityFilter d), + tendsto_of_le_liminf_of_limsup_le le_rfl hle hbup hbdown⟩ + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/DensityUniform.lean b/lean/OAI/Probability/ContinuumTransition/DensityUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee26d6007c689bace470bb9e1c44c5b5fbf1e71a --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/DensityUniform.lean @@ -0,0 +1,70 @@ +import OAI.Probability.ContinuumTransition.DensityBounds + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +lemma physical_coefficient_lower {t β m : ℝ} (ht : 0 < t) (hβ : 0 ≤ β) + (hm : 17576*kernelHeight*m ≤ t) : + β*t/1024 ≤ (β*((t^2/8-2197*t*kernelHeight*m/2)/64)/t) := by + apply (le_div_iff₀ ht).mpr + have hh := mul_le_mul_of_nonneg_left hm ht.le + have hh' : t^2/16 ≤ t^2/8-2197*t*kernelHeight*m/2 := by nlinarith only [hh] + have hh'' := mul_le_mul_of_nonneg_left hh' hβ + nlinarith only [hh''] + +lemma bounded_density_of_quadratic {t β h a H P d : ℝ} + (ht : 1 ≤ t) (hβ : 1/4 ≤ β) (hβ' : β ≤ 2) (hh : h ≤ 10) + (ha : 1024*a ≤ t) (hd : 0 ≤ d) (hP : 0 ≤ P) + (hH : β*t/1024*d^2-(β*t/2)*d-1/t ≤ H) + (he : P = h*d+β*a*d^2/2-H) : d ≤ 1048576 := by + have ht0 : 0 < t := by linarith + have hc : t/8192 ≤ β*t/1024-β*a/2 := by + have hh1 := mul_le_mul_of_nonneg_left ha (show 0 ≤ β by linarith) + have hh2 := mul_le_mul_of_nonneg_right hβ ht0.le + nlinarith only [hh1,hh2] + have hlin : h+β*t/2 ≤ 11*t := by + have hh1 := mul_le_mul_of_nonneg_right hβ' ht0.le + nlinarith only [hh,hh1,ht] + have hinv : 1/t ≤ t := by + apply (div_le_iff₀ ht0).mpr + nlinarith only [sq_nonneg (t-1),ht] + have hh0 := mul_le_mul_of_nonneg_right hc (sq_nonneg d) + have hh1 := mul_le_mul_of_nonneg_right hlin hd + have hquad : t*(d^2/8192-11*d-1) ≤ 0 := by nlinarith only [hh0,hh1,hinv,hH,hP,he] + have hquad' : d^2/8192-11*d-1 ≤ 0 := by + by_contra hn + have hh := mul_pos ht0 (lt_of_not_ge hn) + linarith only [hh,hquad] + by_contra hn + have hg : 1048576 < d := lt_of_not_ge hn + have hh := mul_nonneg hd (le_of_lt (sub_pos.mpr hg)) + nlinarith only [hquad',hg,hh] + +lemma meanField_ge_base {Q P : Parameter → ℝ} {a : ℝ} + (hP : IsMeanField Q a P) {x : Parameter} (hx : x ∈ pressureDomain) : Q x ≤ P x := by + have hh := (hP x hx).1 (mem_range_self (0:ℝ)) + simpa only [quadraticCost,shiftedField,mul_zero,add_zero,zero_pow (by decide : 2 ≠ 0),zero_div,sub_zero,Prod.mk.eta] using hh + +lemma active_pressure_gap {Q P : Parameter → ℝ} {H : ℝ → ℝ → ℝ} {a D : ℝ} + (hH : IsPartialConjugate Q H) + (hm : ∀ β, 0 < β → Monotone (fun h => Q (β,h))) + (hQ : ∀ β, 0 < β → ∀ h, IsLUB ((fun d => h*d-H β d) '' Ici 0) (Q (β,h))) + {x w : Parameter} (hx : x ∈ pressureDomain) (ha : 0 ≤ a) + (hw : w ∈ activeLifts Q a P x) (hd : w.2 ≤ D) : P x ≤ Q x+x.1*a*D^2/2 := by + have hd0 := active_density_nonneg hm hx hw + have he := active_canonical_eq hH hm hx hw + have hl := (hQ x.1 hx x.2).1 (mem_image_of_mem (fun d => x.2*d-H x.1 d) hd0) + have hs : w.2^2 ≤ D^2 := sq_le_sq₀ hd0 (hd0.trans hd) |>.mpr hd + have hmul := mul_le_mul_of_nonneg_left hs (mul_nonneg (le_of_lt hx) ha) + nlinarith only [he,hl,hmul] + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/ExactAssignments.lean b/lean/OAI/Probability/ContinuumTransition/ExactAssignments.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd2494d46ac1f0668288058ea06215dc790d0f33 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/ExactAssignments.lean @@ -0,0 +1,56 @@ +import OAI.Probability.ContinuumTransition.PhysicalPressure + +namespace OAI + +universe u_1 u_2 + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +section +variable {X : Type u_1} [MeasurableSpace X] {ι : Type u_2} [Fintype ι] [DecidableEq ι] + +omit [MeasurableSpace X] [Fintype ι] in +theorem binaryRegion_subset_union (A B : Set X) (s : Finset ι) : + binaryRegion A B s ⊆ {x : ι → X | ∀ i, x i ∈ A ∪ B} := by + intro x hx i + by_cases hi : i ∈ s + · exact Or.inl (by simpa only [ite_eq_left hi] using hx i) + · exact Or.inr (by simpa only [ite_eq_right hi] using hx i) + +omit [MeasurableSpace X] in + +theorem iUnion_binaryRegion (A B : Set X) : + (⋃ s : Finset ι, binaryRegion A B s) = {x : ι → X | ∀ i, x i ∈ A ∪ B} := by + classical + ext x + constructor + · intro hx + obtain ⟨s, hs⟩ := mem_iUnion.mp hx + exact binaryRegion_subset_union A B s hs + · intro hx + refine mem_iUnion.mpr ⟨Finset.univ.filter (fun i => x i ∈ A), ?_⟩ + intro i + by_cases hi : x i ∈ A + · simpa only [Finset.mem_filter, Finset.mem_univ, true_and, ite_eq_left hi] using hi + · simpa only [Finset.mem_filter, Finset.mem_univ, true_and, ite_eq_right hi] using + (hx i).resolve_left hi + +theorem integral_binary_assignments_eq (μ : Measure X) [SigmaFinite μ] + {A B : Set X} (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + {F : (ι → X) → ℝ} + (hF : IntegrableOn F {x : ι → X | ∀ i, x i ∈ A ∪ B} (Measure.pi (fun _ : ι => μ))) : + (∫ x in {x : ι → X | ∀ i, x i ∈ A ∪ B}, F x ∂(Measure.pi (fun _ : ι => μ))) = + ∑ s : Finset ι, ∫ x in binaryRegion A B s, F x ∂(Measure.pi (fun _ : ι => μ)) := by + have hh := integral_biUnion_finset (Finset.univ : Finset (Finset ι)) + (fun s _ => measurableSet_binaryRegion hA hB s) + (fun _ _ _ _ hne => binaryRegion_pairwiseDisjoint hd hne) + (fun s _ => hF.mono_set (binaryRegion_subset_union A B s)) + simpa only [Finset.mem_univ, iUnion_true, iUnion_binaryRegion] using hh + +end +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FiniteBlocks.lean b/lean/OAI/Probability/ContinuumTransition/FiniteBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..caacc689e5da1bdbc913562c2932f12055066a30 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FiniteBlocks.lean @@ -0,0 +1,72 @@ +import OAI.Probability.ContinuumTransition.FiniteProduct + +namespace OAI + +universe u_1 + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +theorem familyTerm_gibbs_empty_ne_zero (U : Space → Space → ℝ) (β h : ℝ) {n : ℕ} (hn : n ≠ 0) : + familyTerm (gibbsFamily U β h) ∅ n = 0 := by + have hp : 0 < n := Nat.pos_of_ne_zero hn + have he : {x : Fin n → Space | ∀ i, x i ∈ (∅ : Set Space)} = ∅ := by + ext x + simp only [mem_ofPred_eq, mem_empty_iff_false, iff_false, not_forall] + exact ⟨⟨0, hp⟩, not_false⟩ + simp only [familyTerm, familyIntegral, he, setIntegral_empty, zero_div] + +theorem grandFinite_gibbs_blocks {κ : Type u_1} {U : Space → Space → ℝ} + (hU : ∀ x y, U x y = U y x) {β h : ℝ} (hβ : 0 ≤ β) + (A : κ → Set Space) (s : Finset κ) + (hA : ∀ i ∈ s, MeasurableSet (A i)) + (hd : (s : Set κ).Pairwise (fun i j => Disjoint (A i) (A j))) + (hcross : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → ∀ x ∈ A i, ∀ y ∈ A j, 0 ≤ U x y) + (hFi : ∀ (ι : Type) [Fintype ι], IntegrableOn (gibbsFamily U β h ι) + {x | ∀ i, x i ∈ ⋃ j ∈ s, A j}) + (hFA : ∀ i ∈ s, GrandFinite (gibbsFamily U β h) (A i)) : + GrandFinite (gibbsFamily U β h) (⋃ i ∈ s, A i) := by + induction s using Finset.induction_on with + | empty => + simp only [Finset.notMem_empty, iUnion_of_empty, iUnion_empty] at hFi ⊢ + refine ⟨hFi, ?_⟩ + apply summable_of_ne_finset_zero (s := {0}) + intro n hn + exact familyTerm_gibbs_empty_ne_zero U β h (by simpa only [Finset.mem_singleton] using hn) + | @insert i s hi ih => + let B := ⋃ j ∈ s, A j + have hB : MeasurableSet B := MeasurableSet.biUnion s.finite_toSet.countable + (fun j hj => hA j (Finset.mem_insert_of_mem hj)) + have hAi := hA i (Finset.mem_insert_self _ _) + have hAB : Disjoint (A i) B := by + apply Set.disjoint_iUnion₂_right.mpr + intro j hj + exact hd (Finset.mem_insert_self _ _) (Finset.mem_insert_of_mem hj) (fun hh => hi (hh ▸ hj)) + have hieq : (⋃ j ∈ insert i s, A j) = A i ∪ B := by simp only [Finset.mem_insert, iUnion_iUnion_eq_or_left]; rfl + have hFiB (ι : Type) [Fintype ι] : IntegrableOn (gibbsFamily U β h ι) + {x | ∀ a, x a ∈ B} := by + apply (hFi ι).mono_set + intro x hx a + rw [hieq] + exact Or.inr (hx a) + have hFB := ih (fun j hj => hA j (Finset.mem_insert_of_mem hj)) + (hd.mono (Finset.subset_insert _ _)) + (fun j hj k hk => hcross j (Finset.mem_insert_of_mem hj) k (Finset.mem_insert_of_mem hk)) + hFiB (fun j hj => hFA j (Finset.mem_insert_of_mem hj)) + rw [hieq] at hFi ⊢ + apply GrandFinite.union_product (gibbsFamily_relabel U β h) (gibbsFamily_relabel U β h) + hAi hB hAB (hFA i (Finset.mem_insert_self _ _)) hFB hFi (gibbsFamily_nonneg U β h) + intro n r x hx + apply gibbsFamily_binary_le hU hβ ?_ r hx + intro a ha b hb + obtain ⟨j, hj, hjb⟩ := mem_iUnion₂.mp hb + exact hcross i (Finset.mem_insert_self _ _) j (Finset.mem_insert_of_mem hj) + (fun hh => hi (hh ▸ hj)) a ha b hjb + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FiniteBounds.lean b/lean/OAI/Probability/ContinuumTransition/FiniteBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..50c82044cd474d1758b935243dc51f6f10504f02 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FiniteBounds.lean @@ -0,0 +1,80 @@ +import OAI.Probability.ContinuumTransition.GrandPartition + +namespace OAI + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature + +theorem log_factorial_lower (N : ℕ) : + (N : ℝ) * Real.log N - N ≤ Real.log (N.factorial : ℝ) := by + by_cases hN : N = 0 + · simp [hN] + · have hpos : (0 : ℝ) < N := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hN) + have hf : (0 : ℝ) < N.factorial := Nat.cast_pos.mpr (Nat.factorial_pos N) + have hh := Real.pow_div_factorial_le_exp (N : ℝ) hpos.le N + have hl := Real.log_le_log (div_pos (pow_pos hpos _) hf) hh + rw [Real.log_div (pow_ne_zero _ hpos.ne') hf.ne', Real.log_pow, Real.log_exp] at hl + linarith + +theorem boltzmann_le_of_energy_lower {φ : ℝ → ℝ} {β E : ℝ} (hβ : 0 ≤ β) + {N : ℕ} {x : Fin N → Space} (hE : (E : EReal) ≤ energy φ x) : + boltzmann φ β x ≤ Real.exp (-β * E) := by + unfold boltzmann + split_ifs with htop + · exact (Real.exp_pos _).le + · apply Real.exp_le_exp.mpr + have he := EReal.toReal_le_toReal hE (EReal.coe_ne_bot _) htop + simp only [EReal.toReal_coe] at he + exact mul_le_mul_of_nonpos_left he (neg_nonpos.mpr hβ) + +theorem partition_le_factorial_of_energy_bound {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B L E : ℝ} (hβ : 0 ≤ β) (hL : 0 ≤ L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) {N : ℕ} (hN : N ≠ 0) + (hE : ∀ x : Fin N → Space, (∀ i, x i ∈ cube L) → (E : EReal) ≤ energy φ x) : + partition φ β L N ≤ (L ^ 3) ^ N / (N.factorial : ℝ) * Real.exp (-β * E) := by + let S := {x : Fin N → Space | ∀ i, x i ∈ cube L} + have hS : MeasurableSet S := (isCompact_configurations L N).measurableSet + have hfin : IsFiniteMeasure (volume.restrict S) := + ⟨by simpa only [Measure.restrict_apply_univ] using + (isCompact_configurations L N).measure_lt_top (μ := volume)⟩ + have hh : ∀ᵐ x ∂volume.restrict S, boltzmann φ β x ≤ Real.exp (-β * E) := by + apply (ae_restrict_iff' hS).mpr + exact ae_of_all _ (fun x hx => boltzmann_le_of_energy_lower hβ (hE x hx)) + have hi := integral_mono_ae (integrableOn_boltzmann hφ hβ hstable L N) + (integrable_const (Real.exp (-β * E))) hh + have hc : (∫ x in S, Real.exp (-β * E)) = L ^ (3 * N) * Real.exp (-β * E) := by + rw [setIntegral_const, Measure.real, volume_configurations, ENNReal.toReal_pow, + ENNReal.toReal_ofReal hL, smul_eq_mul] + rw [hc] at hi + unfold partition + rw [ite_eq_right hN] + calc + _ ≤ (1 / (N.factorial : ℝ)) * (L ^ (3 * N) * Real.exp (-β * E)) := + mul_le_mul_of_nonneg_left hi (by positivity) + _ = _ := by rw [pow_mul]; ring + +theorem neg_log_partition_lower {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B L E : ℝ} (hβ : 0 ≤ β) (hL : 0 < L) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) {N : ℕ} (hN : N ≠ 0) + (hE : ∀ x : Fin N → Space, (∀ i, x i ∈ cube L) → (E : EReal) ≤ energy φ x) : + β * E + N * Real.log ((N : ℝ) / L ^ 3) - N ≤ -Real.log (partition φ β L N) := by + have hnpos : (0 : ℝ) < N := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hN) + have hfp : (0 : ℝ) < N.factorial := Nat.cast_pos.mpr (Nat.factorial_pos N) + have hLp : 0 < L ^ 3 := pow_pos hL _ + have hZ := partition_pos hφ hβ hL hstable N + have hu := partition_le_factorial_of_energy_bound hφ hβ hL.le hstable hN hE + have hl := Real.log_le_log hZ hu + rw [Real.log_mul (div_pos (pow_pos hLp _) hfp).ne' (Real.exp_pos _).ne', + Real.log_div (pow_pos hLp _).ne' hfp.ne', Real.log_pow, Real.log_exp] at hl + rw [Real.log_div hnpos.ne' hLp.ne'] + have hf := log_factorial_lower N + nlinarith + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FiniteProduct.lean b/lean/OAI/Probability/ContinuumTransition/FiniteProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3d18bdbf6766d7b20e409bf450991804ca89bb1 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FiniteProduct.lean @@ -0,0 +1,74 @@ +import OAI.Probability.ContinuumTransition.KacEnergy + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature + +theorem familyTerm_product_bound (F G H : ConfigFamily) + (hG : RelabelInvariant G) (hH : RelabelInvariant H) {A B : Set Space} + (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + (hGF : GrandFinite G A) (hHF : GrandFinite H B) (n : ℕ) + (hFi : IntegrableOn (F (Fin n)) {x | ∀ i, x i ∈ A ∪ B}) + (hbound : ∀ (s : Finset (Fin n)) (x : Fin n → Space), + x ∈ binaryRegion A B s → F (Fin n) x ≤ + G {i : Fin n // i ∈ s} (fun i => x i)*H {i : Fin n // i ∉ s} (fun i => x i)) : + familyTerm F (A ∪ B) n ≤ ∑ k ∈ Finset.range (n+1), familyTerm G A k*familyTerm H B (n-k) := by + have hb := integral_binary_bound hA hB hd + (fun k => familyIntegral G A (Fin k)) (fun k => familyIntegral H B (Fin k)) + hFi ?_ + swap + · intro s + have hprod := integrableOn_binary_product volume A B s + (by simpa only [← volume_pi] using hGF.integrable {i : Fin n // i ∈ s}) + (by simpa only [← volume_pi] using hHF.integrable {i : Fin n // i ∉ s}) + have hi := setIntegral_mono_on + (hFi.mono_set (binaryRegion_subset_union A B s)) + (by simpa only [← volume_pi] using hprod) + (measurableSet_binaryRegion hA hB s) (hbound s) + rw [show volume = Measure.pi (fun _ : Fin n => (volume : Measure Space)) by exact volume_pi, + setIntegral_binary_product volume A B s (G {i : Fin n // i ∈ s}) + (H {i : Fin n // i ∉ s})] at hi + simp only [← volume_pi] at hi + have heg := familyIntegral_eq_Fin G hG A {i : Fin n // i ∈ s} + have heh := familyIntegral_eq_Fin H hH B {i : Fin n // i ∉ s} + have hc : Fintype.card {i : Fin n // i ∈ s} = s.card := Fintype.card_coe s + rw [hc] at heg + have hcc : Fintype.card {i : Fin n // i ∉ s} = n-s.card := by + have hh := Fintype.card_subtype_compl (fun i : Fin n => i ∈ s) + simpa only [Fintype.card_fin, hc] using hh + rw [hcc] at heh + change (∫ x in binaryRegion A B s, F (Fin n) x) ≤ _ + calc + _ ≤ familyIntegral G A {i : Fin n // i ∈ s}* + familyIntegral H B {i : Fin n // i ∉ s} := hi + _ = _ := by rw [heg, heh, Fintype.card_fin] + have hh := div_le_div_of_nonneg_right hb (Nat.cast_nonneg (n.factorial) : (0 : ℝ) ≤ n.factorial) + rw [Fintype.card_fin, factorial_binomial_sum + (fun k => familyIntegral G A (Fin k)) (fun k => familyIntegral H B (Fin k)) n] at hh + exact hh + +theorem GrandFinite.union_product {F G H : ConfigFamily} + (hG : RelabelInvariant G) (hH : RelabelInvariant H) {A B : Set Space} + (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + (hGF : GrandFinite G A) (hHF : GrandFinite H B) + (hFi : ∀ (ι : Type) [Fintype ι], IntegrableOn (F ι) {x | ∀ i, x i ∈ A ∪ B}) + (h0 : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) + (hbound : ∀ (n : ℕ) (s : Finset (Fin n)) (x : Fin n → Space), + x ∈ binaryRegion A B s → F (Fin n) x ≤ + G {i : Fin n // i ∈ s} (fun i => x i)*H {i : Fin n // i ∉ s} (fun i => x i)) : + GrandFinite F (A ∪ B) := by + refine ⟨hFi, ?_⟩ + have hab : Summable (fun p : ℕ × ℕ => familyTerm G A p.1*familyTerm H B p.2) := + summable_mul_of_summable_norm (summable_norm_iff.mpr hGF.summable) + (summable_norm_iff.mpr hHF.summable) + exact Summable.of_nonneg_of_le (familyTerm_nonneg F (A ∪ B) h0) + (fun n => familyTerm_product_bound F G H hG hH hA hB hd hGF hHF n (hFi (Fin n)) (hbound n)) + (summable_sum_mul_range_of_summable_mul hab) + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FixedOccupation.lean b/lean/OAI/Probability/ContinuumTransition/FixedOccupation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b888fead9321c9fea01d8bf202d32257de97df0 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FixedOccupation.lean @@ -0,0 +1,158 @@ +import OAI.Probability.ContinuumTransition.GrandBlocks + +namespace OAI + +universe u_1 + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +noncomputable def countFamily (F : ConfigFamily) (n : ℕ) : ConfigFamily := + fun ι _ x => if Fintype.card ι = n then F ι x else 0 + +noncomputable def fixedOccupationFamily {κ : Type u_1} (A : κ → Set Space) (s : Finset κ) + (n : κ → ℕ) (F : ConfigFamily) : ConfigFamily := + fun ι _ x => if ∀ k ∈ s, occupation (A k) x = (n k : ℝ) then F ι x else 0 + +theorem countFamily_relabel (F : ConfigFamily) (hF : RelabelInvariant F) (n : ℕ) : + RelabelInvariant (countFamily F n) := by + intro ι κ _ _ e x + simp only [countFamily, Fintype.card_congr e, hF ι κ e x] + +theorem fixedOccupationFamily_relabel {κ : Type u_1} (A : κ → Set Space) (s : Finset κ) + (n : κ → ℕ) (F : ConfigFamily) (hF : RelabelInvariant F) : + RelabelInvariant (fixedOccupationFamily A s n F) := by + intro ι τ _ _ e x + simp only [fixedOccupationFamily, occupation_relabel, hF ι τ e x] + +theorem GrandFinite.count {F : ConfigFamily} {D : Set Space} (hF : GrandFinite F D) (n : ℕ) : + GrandFinite (countFamily F n) D := by + refine ⟨fun ι _ => ?_, ?_⟩ + · change IntegrableOn (fun x : ι → Space => if Fintype.card ι = n then F ι x else 0) _ + split_ifs + · exact hF.integrable ι + · exact integrableOn_zero + · have he (j : ℕ) : familyTerm (countFamily F n) D j = if j = n then familyTerm F D j else 0 := by + unfold familyTerm familyIntegral countFamily + simp only [Fintype.card_fin] + split_ifs <;> simp + change Summable (fun j => familyTerm (countFamily F n) D j) + simp_rw [he] + exact summable_of_ne_finset_zero (s := {n}) (fun j hj => ite_eq_right (by simpa only [Finset.mem_singleton] using hj)) + +theorem grandIntegral_countFamily (F : ConfigFamily) (D : Set Space) (n : ℕ) : + grandIntegral (countFamily F n) D = familyTerm F D n := by + have he (j : ℕ) : familyTerm (countFamily F n) D j = if j = n then familyTerm F D j else 0 := by + unfold familyTerm familyIntegral countFamily + simp only [Fintype.card_fin] + split_ifs <;> simp + simp only [grandIntegral, he, tsum_ite_eq] + +theorem fixedOccupationFamily_nonneg {κ : Type u_1} (A : κ → Set Space) (s : Finset κ) + (n : κ → ℕ) (F : ConfigFamily) + (hF : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) + (ι : Type) [Fintype ι] (x : ι → Space) : 0 ≤ fixedOccupationFamily A s n F ι x := by + unfold fixedOccupationFamily + split_ifs + · exact hF ι x + · rfl + +theorem GrandFinite.fixedOccupation {κ : Type u_1} {A : κ → Set Space} {s : Finset κ} + (n : κ → ℕ) (hA : ∀ k ∈ s, MeasurableSet (A k)) {F : ConfigFamily} {D : Set Space} + (hF : GrandFinite F D) (hm : ∀ (ι : Type) [Fintype ι], Measurable (F ι)) + (h0 : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) : + GrandFinite (fixedOccupationFamily A s n F) D := by + refine hF.of_le (fun ι _ => ?_) (fixedOccupationFamily_nonneg A s n F h0) ?_ + · apply Measurable.ite ?_ (hm ι) measurable_const + have hh := MeasurableSet.biInter s.finite_toSet.countable (fun k hk => + measurableSet_eq_fun (measurable_occupation (ι := ι) (hA k hk)) + (show Measurable (fun _ : ι → Space => (n k : ℝ)) from measurable_const)) + convert hh using 1 + ext x + simp only [mem_ofPred_eq, mem_iInter, Finset.mem_coe] + · intro ι _ x + unfold fixedOccupationFamily + split_ifs + · rfl + · exact h0 ι x + +theorem occupation_binary_left {ι : Type} [Fintype ι] [DecidableEq ι] {A B : Set Space} + (hd : Disjoint A B) (s : Finset ι) {x : ι → Space} (hx : x ∈ binaryRegion A B s) : + occupation A x = (Fintype.card {i : ι // i ∈ s} : ℝ) := by + rw [occupation_eq_sum] + have he (i : ι) : x i ∈ A ↔ i ∈ s := by + constructor + · intro hi + by_contra his + exact Set.disjoint_left.mp hd hi (by simpa only [ite_eq_right his] using hx i) + · intro hi + simpa only [ite_eq_left hi] using hx i + simp only [he] + simp only [Fintype.card_subtype, ← Finset.sum_boole] + +theorem occupation_binary_right {ι : Type} [Fintype ι] [DecidableEq ι] {A B C : Set Space} + (hd : Disjoint A C) (s : Finset ι) {x : ι → Space} (hx : x ∈ binaryRegion A B s) : + occupation C x = occupation C (fun i : {i : ι // i ∉ s} => x i) := by + have hh := (occupation_subtype_compl C s x (fun i hi hc => + Set.disjoint_left.mp hd (by simpa only [ite_eq_left hi] using hx i) hc)).symm + convert hh using 1 + congr! 3 + +theorem injective_binary_iff {ι : Type} [Fintype ι] [DecidableEq ι] {A B : Set Space} + (hd : Disjoint A B) (s : Finset ι) {x : ι → Space} (hx : x ∈ binaryRegion A B s) : + Function.Injective x ↔ Function.Injective (fun i : {i : ι // i ∈ s} => x i) ∧ + Function.Injective (fun i : {i : ι // i ∉ s} => x i) := by + constructor + · intro hh + exact ⟨hh.comp Subtype.val_injective, hh.comp Subtype.val_injective⟩ + · rintro ⟨h₁,h₂⟩ i j hij + by_cases hi : i ∈ s <;> by_cases hj : j ∈ s + · exact congrArg Subtype.val (h₁ (a₁ := ⟨i,hi⟩) (a₂ := ⟨j,hj⟩) hij) + · have hia : x i ∈ A := by simpa only [ite_eq_left hi] using hx i + have hjb : x j ∈ B := by simpa only [ite_eq_right hj] using hx j + exact False.elim (Set.disjoint_left.mp hd hia (hij.symm ▸ hjb)) + · have hja : x j ∈ A := by simpa only [ite_eq_left hj] using hx j + have hib : x i ∈ B := by simpa only [ite_eq_right hi] using hx i + exact False.elim (Set.disjoint_left.mp hd hja (hij ▸ hib)) + · exact congrArg Subtype.val (h₂ (a₁ := ⟨i,hi⟩) (a₂ := ⟨j,hj⟩) hij) + +theorem gibbsFamily_binary_eq {U : Space → Space → ℝ} (hU : ∀ x y, U x y = U y x) + (β h : ℝ) {A B : Set Space} (hd : Disjoint A B) + (hcross : ∀ x ∈ A, ∀ y ∈ B, U x y = 0) + {ι : Type} [Fintype ι] [DecidableEq ι] (s : Finset ι) {x : ι → Space} (hx : x ∈ binaryRegion A B s) : + gibbsFamily U β h ι x = gibbsFamily U β h {i : ι // i ∈ s} (fun i => x i)* + gibbsFamily U β h {i : ι // i ∉ s} (fun i => x i) := by + have he : gibbsEnergy U x = gibbsEnergy U (fun i : {i : ι // i ∈ s} => x i)+ + gibbsEnergy U (fun i : {i : ι // i ∉ s} => x i) := by + have hh := gibbsEnergy_split U hU (fun i => i ∈ s) x + have hz : (∑ i : {i : ι // i ∈ s}, ∑ j : {j : ι // j ∉ s}, U (x i) (x j)) = 0 := by + apply Finset.sum_eq_zero + intro i _ + apply Finset.sum_eq_zero + intro j _ + exact hcross (x i) (by simpa only [ite_eq_left i.property] using hx i) + (x j) (by simpa only [ite_eq_right j.property] using hx j) + have he' : gibbsEnergy U x = gibbsEnergy U (fun i : {i : ι // i ∈ s} => x i)+ + gibbsEnergy U (fun i : {i : ι // i ∉ s} => x i)+ + ∑ i : {i : ι // i ∈ s}, ∑ j : {j : ι // j ∉ s}, U (x i) (x j) := by + convert hh using 1 + congr! 5 + simpa only [hz, add_zero] using he' + have hc : (Fintype.card {i : ι // i ∈ s} : ℝ)+Fintype.card {i : ι // i ∉ s} = Fintype.card ι := by + have hh := Fintype.card_subtype_compl (fun i : ι => i ∈ s) + have hl := Fintype.card_subtype_le (fun i : ι => i ∈ s) + have hh' : Fintype.card {i : ι // i ∈ s}+Fintype.card {i : ι // i ∉ s} = Fintype.card ι := by omega + exact_mod_cast hh' + simp only [gibbsFamily, injective_binary_iff hd s hx] + split_ifs <;> try simp_all only [zero_mul, mul_zero, and_false, false_and, not_false_eq_true, and_self, not_true_eq_false] + rw [← Real.exp_add, ← hc] + congr 1 + ring + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeFamily.lean b/lean/OAI/Probability/ContinuumTransition/FreeFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..6088f3a377d63f1be3af1a9c5852dd0b75966682 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeFamily.lean @@ -0,0 +1,124 @@ +import OAI.Probability.ContinuumTransition.RootVolume + +namespace OAI + +section +open scoped BigOperators ENNReal +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +lemma measurableSet_freeConfig {ι : Type} [Fintype ι] (t : ℝ) : + MeasurableSet {x : ι → Space | FreeConfig t x} := by + apply measurableSet_forall_labels + intro i + apply measurableSet_forall_labels + intro j + by_cases hij : i = j + · simp only [hij, ne_eq, not_true_eq_false, false_implies, ofPred_true, MeasurableSet.univ] + have hm : Measurable (fun x : ι → Space => ‖x i-x j‖) := + ((measurable_pi_apply i).sub (measurable_pi_apply j)).norm + have he : {x : ι → Space | i ≠ j → ‖x i-x j‖ < 1 → + Real.exp (-t) ≤ ‖x i-x j‖ ∧ ‖x i-x j‖ ≤ (1+shellDelta)*Real.exp (-t)} = + {x | 1 ≤ ‖x i-x j‖} ∪ + ({x | Real.exp (-t) ≤ ‖x i-x j‖} ∩ {x | ‖x i-x j‖ ≤ (1+shellDelta)*Real.exp (-t)}) := by + ext x + simp only [mem_ofPred_eq, mem_union, mem_inter_iff, ne_eq, hij, not_false_eq_true, imp_iff_not_or, not_lt, not_true_eq_false, false_or] + rw [he] + exact (measurableSet_le measurable_const hm).union + ((measurableSet_le measurable_const hm).inter (measurableSet_le hm measurable_const)) + +noncomputable def freeFamily (t d : ℝ) : ConfigFamily := + fun ι _ x => if FreeConfig t x then Real.exp (d*Fintype.card ι) else 0 + +lemma freeFamily_relabel (t d : ℝ) : RelabelInvariant (freeFamily t d) := by + intro ι κ _ _ e x + have he : FreeConfig t (x ∘ e) ↔ FreeConfig t x := by + constructor + · intro hh i j hij hdist + have hn : e.symm i ≠ e.symm j := fun he => hij (e.symm.injective he) + simpa only [Function.comp_apply, Equiv.apply_symm_apply] using + hh (e.symm i) (e.symm j) hn (by simpa only [Function.comp_apply, Equiv.apply_symm_apply] using hdist) + · intro hh i j hij hdist + exact hh (e i) (e j) (fun he => hij (e.injective he)) hdist + simp only [freeFamily, he, Fintype.card_congr e] + +lemma freeFamily_measurable (t d : ℝ) (ι : Type) [Fintype ι] : Measurable (freeFamily t d ι) := + Measurable.ite (measurableSet_freeConfig t) measurable_const measurable_const + +lemma freeFamily_nonneg (t d : ℝ) (ι : Type) [Fintype ι] (x : ι → Space) : + 0 ≤ freeFamily t d ι x := by + unfold freeFamily + split_ifs <;> positivity + +lemma freeFamily_le_exp (t d : ℝ) (ι : Type) [Fintype ι] (x : ι → Space) : + freeFamily t d ι x ≤ Real.exp (d*Fintype.card ι) := by + unfold freeFamily + split_ifs + · exact le_rfl + · exact (Real.exp_pos _).le + +lemma freeFamily_summable (t d L : ℝ) : Summable (familyTerm (freeFamily t d) (cube L)) := + summable_familyTerm_of_bound _ (isCompact_cube L).measure_lt_top.ne (freeFamily_measurable t d) + (freeFamily_nonneg t d) (freeFamily_le_exp t d) + +lemma rootCover_volume_real {ι : Type} [Fintype ι] (s : Finset ι) (r L : ℝ) : + volume.real ({x : ι → Space | ∀ i, x i ∈ cube L} ∩ rootCover s r) ≤ + (volume.real (cube L))^s.card * + ((s.card : ℝ)*volume.real (Metric.closedBall (0 : Space) r))^(Fintype.card ι-s.card) := by + have hh := ENNReal.toReal_mono (show + (volume (cube L))^s.card * + ((s.card : ℝ≥0∞)*volume (Metric.closedBall (0 : Space) r))^(Fintype.card ι-s.card) ≠ ⊤ by + exact ENNReal.mul_ne_top (ENNReal.pow_ne_top (isCompact_cube L).measure_lt_top.ne) + (ENNReal.pow_ne_top (ENNReal.mul_ne_top (by simp) (measure_closedBall_lt_top.ne)))) (rootCover_volume s r L) + simpa only [Measure.real, ENNReal.toReal_mul, ENNReal.toReal_pow, ENNReal.toReal_natCast] using hh + +lemma freeConfig_volume_le {ι : Type} [Fintype ι] {t : ℝ} + (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (L : ℝ) : + volume.real ({x : ι → Space | ∀ i, x i ∈ cube L} ∩ {x | FreeConfig t x}) ≤ + ∑ k ∈ Finset.range (Fintype.card ι+1), + if k ≤ packingNumber L ∧ Fintype.card ι ≤ 4*k then + ((Fintype.card ι).choose k : ℝ)*(volume.real (cube L))^k * + ((k : ℝ)*volume.real (Metric.closedBall (0 : Space) ((1+shellDelta)*Real.exp (-t))))^(Fintype.card ι-k) + else 0 := by + let T : Finset (Finset ι) := Finset.univ.filter (fun s => s.card ≤ packingNumber L ∧ Fintype.card ι ≤ 4*s.card) + let A : Finset ι → Set (ι → Space) := fun s => + {x | ∀ i, x i ∈ cube L} ∩ rootCover s ((1+shellDelta)*Real.exp (-t)) + have hsub : ({x : ι → Space | ∀ i, x i ∈ cube L} ∩ {x | FreeConfig t x}) ⊆ ⋃ s ∈ T, A s := by + intro x hx + obtain ⟨s,hs,hn,hc⟩ := freeConfig_roots ht hx.2 hx.1 + apply mem_iUnion₂.mpr + refine ⟨s,by simp only [T, Finset.mem_filter, Finset.mem_univ, true_and]; exact ⟨hs,hn⟩,hx.1,?_⟩ + intro j + obtain ⟨i,hi,hij⟩ := hc j + exact ⟨⟨i,hi⟩,hij⟩ + have hfin : volume (⋃ s ∈ T, A s) ≠ ⊤ := by + apply ne_top_of_le_ne_top (show volume {x : ι → Space | ∀ i, x i ∈ cube L} ≠ ⊤ by + rw [volume_generalConfigurations]; exact ENNReal.pow_ne_top (isCompact_cube L).measure_lt_top.ne) + apply measure_mono + intro x hx + obtain ⟨s,_,hs⟩ := mem_iUnion₂.mp hx + exact hs.1 + calc + _ ≤ volume.real (⋃ s ∈ T, A s) := measureReal_mono hsub hfin + _ ≤ ∑ s ∈ T, volume.real (A s) := measureReal_biUnion_finset_le _ _ + _ ≤ ∑ s ∈ T, (volume.real (cube L))^s.card * + ((s.card : ℝ)*volume.real (Metric.closedBall (0 : Space) ((1+shellDelta)*Real.exp (-t))))^(Fintype.card ι-s.card) := by + exact Finset.sum_le_sum (fun s _ => rootCover_volume_real s _ L) + _ = _ := by + rw [Finset.sum_filter] + have hh := Finset.sum_powerset_apply_card + (fun k => if k ≤ packingNumber L ∧ Fintype.card ι ≤ 4*k then + (volume.real (cube L))^k * + ((k : ℝ)*volume.real (Metric.closedBall (0 : Space) ((1+shellDelta)*Real.exp (-t))))^(Fintype.card ι-k) else 0) + (x := (Finset.univ : Finset ι)) + simp only [Finset.powerset_univ, Finset.card_univ, nsmul_eq_mul] at hh + rw [hh] + apply Finset.sum_congr rfl + intro k hk + split_ifs <;> simp [mul_assoc] + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeGeometry.lean b/lean/OAI/Probability/ContinuumTransition/FreeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8b01118647a45eb08ee2d4f032f3a33cd38634b --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeGeometry.lean @@ -0,0 +1,88 @@ +import OAI.Probability.ContinuumTransition.PackingGeometry + +namespace OAI + +universe u_1 + +section +open scoped BigOperators +open Set +namespace ContinuumTemperature +open Classical + +def FreeConfig {ι : Type u_1} (t : ℝ) (x : ι → Space) : Prop := + ∀ i j, i ≠ j → ‖x i-x j‖ < 1 → + Real.exp (-t) ≤ ‖x i-x j‖ ∧ ‖x i-x j‖ ≤ (1+shellDelta)*Real.exp (-t) + +theorem freeConfig_injective {ι : Type u_1} {t : ℝ} {x : ι → Space} + (hx : FreeConfig t x) : Function.Injective x := by + intro i j hij + by_contra hne + have hh := (hx i j hne (by rw [hij, sub_self, norm_zero]; norm_num)).1 + rw [hij,sub_self,norm_zero] at hh + exact (not_le_of_gt (Real.exp_pos _)) hh + +theorem freeConfig_close_trans {ι : Type u_1} {t : ℝ} {x : ι → Space} + (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (hx : FreeConfig t x) + {i j k : ι} (hij : ‖x i-x j‖ < 1) (hjk : ‖x j-x k‖ < 1) : + ‖x i-x k‖ < 1 := by + by_cases he : i = j + · simpa only [he] using hjk + by_cases hf : j = k + · simpa only [hf] using hij + have hi := (hx i j he hij).2 + have hj := (hx j k hf hjk).2 + have hh := norm_sub_le_norm_sub_add_norm_sub (x i) (x j) (x k) + linarith only [hi,hj,hh,ht] + +noncomputable def freeSetoid {ι : Type u_1} {t : ℝ} {x : ι → Space} + (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (hx : FreeConfig t x) : Setoid ι where + r i j := ‖x i-x j‖ < 1 + iseqv := ⟨by intro i; simp, + by intro i j h; rwa [norm_sub_rev], + by intro i j k; exact freeConfig_close_trans ht hx⟩ + +noncomputable def freeCluster {ι : Type u_1} [Fintype ι] (x : ι → Space) (i : ι) : Finset ι := + Finset.univ.filter (fun j => ‖x i-x j‖ < 1) + +theorem mem_freeCluster {ι : Type u_1} [Fintype ι] {x : ι → Space} {i j : ι} : + j ∈ freeCluster x i ↔ ‖x i-x j‖ < 1 := by simp [freeCluster] + +theorem freeCluster_card_le_four {ι : Type u_1} [Fintype ι] {t : ℝ} {x : ι → Space} + (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (hx : FreeConfig t x) (i : ι) : + (freeCluster x i).card ≤ 4 := by + have hc : (shellGraph x (Real.exp (-t))).IsClique (freeCluster x i : Set ι) := by + intro j hj k hk hjk + have hi : ‖x j-x i‖ < 1 := by simpa only [norm_sub_rev] using mem_freeCluster.mp hj + have hh := freeConfig_close_trans ht hx hi (mem_freeCluster.mp hk) + exact ⟨hjk,hx j k hjk hh⟩ + have hcf := shellGraph_cliqueFree x (Real.exp_pos (-t)) + by_contra hn + obtain ⟨s,hs,hcard⟩ := Finset.exists_subset_card_eq (by omega : 5 ≤ (freeCluster x i).card) + exact hcf s ⟨hc.subset (by exact_mod_cast hs), hcard⟩ + +theorem freeCluster_close_root {ι : Type u_1} [Fintype ι] {t : ℝ} {x : ι → Space} + (hx : FreeConfig t x) {i j : ι} (hj : j ∈ freeCluster x i) : + ‖x i-x j‖ ≤ (1+shellDelta)*Real.exp (-t) := by + by_cases he : i=j + · rw [he,sub_self,norm_zero] + unfold shellDelta + positivity + exact (hx i j he (mem_freeCluster.mp hj)).2 + +theorem free_component_card_le_packing {ι : Type u_1} [Fintype ι] {t L : ℝ} {x : ι → Space} + (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (hx : FreeConfig t x) + (hL : ∀ i, x i ∈ cube L) : + Fintype.card (Quotient (freeSetoid ht hx)) ≤ packingNumber L := by + let f : Quotient (freeSetoid ht hx) → Space := fun c => x c.out + apply card_le_packingNumber f (fun c => hL c.out) + intro a b hab + by_contra hlt + have hh : (freeSetoid ht hx).r a.out b.out := lt_of_not_ge hlt + have he := Quotient.sound hh + exact hab (by simpa only [Quotient.out_eq] using he) + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeGrand.lean b/lean/OAI/Probability/ContinuumTransition/FreeGrand.lean new file mode 100644 index 0000000000000000000000000000000000000000..7734e1b8448a306269a89f8cf2cd03f65b32fd98 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeGrand.lean @@ -0,0 +1,107 @@ +import OAI.Probability.ContinuumTransition.FreeFamily + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +lemma freeFamily_integral (t d L : ℝ) (ι : Type) [Fintype ι] : + familyIntegral (freeFamily t d) (cube L) ι = + volume.real ({x : ι → Space | ∀ i, x i ∈ cube L} ∩ {x | FreeConfig t x})* + (Real.exp d)^Fintype.card ι := by + have he : freeFamily t d ι = {x : ι → Space | FreeConfig t x}.indicator + (fun _ => Real.exp (d*Fintype.card ι)) := by + funext x + simp only [freeFamily, indicator_apply, mem_ofPred_eq] + rw [familyIntegral, he, setIntegral_indicator (measurableSet_freeConfig t), setIntegral_const, + smul_eq_mul, mul_comm d, Real.exp_nat_mul] + +lemma power_trunc_bound {w : ℝ} (hw : 0 ≤ w) {j k : ℕ} (hjk : j ≤ 3*k) : + w^j ≤ (max 1 w)^ (3*k) := by + exact (pow_le_pow_left₀ hw (le_max_right 1 w) j).trans + (pow_le_pow_right₀ (le_max_left 1 w) hjk) + +theorem free_grand_upper {t : ℝ} (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (d L : ℝ) : + grandIntegral (freeFamily t d) (cube L) ≤ + (∑ k ∈ Finset.range (packingNumber L+1), + ((volume.real (cube L))*Real.exp d* + (max 1 (volume.real (Metric.closedBall (0 : Space) ((1+shellDelta)*Real.exp (-t)))*Real.exp d))^3)^k / + (k.factorial : ℝ))*Real.exp (packingNumber L) := by + let V := volume.real (cube L) + let z := Real.exp d + let w := volume.real (Metric.closedBall (0 : Space) ((1+shellDelta)*Real.exp (-t))) + let M := packingNumber L + let D := max 1 (w*z) + let a : ℕ → ℝ := fun k => if k ≤ M then (V*z*D^3)^k/(k.factorial : ℝ) else 0 + let b : ℕ → ℝ := fun j => (M : ℝ)^j/(j.factorial : ℝ) + have hV : 0 ≤ V := ENNReal.toReal_nonneg + have hz : 0 ≤ z := (Real.exp_pos _).le + have hw : 0 ≤ w := ENNReal.toReal_nonneg + have hD : 1 ≤ D := le_max_left _ _ + have ha : Summable a := summable_of_ne_finset_zero (s := Finset.range (M+1)) (by + intro k hk + have hh : ¬k ≤ M := by simpa only [Finset.mem_range, Nat.lt_add_one_iff] using hk + simp only [a, ite_eq_right hh]) + have hb : HasSum b (Real.exp (M : ℝ)) := by + simpa only [b, Real.exp_eq_exp_ℝ] using NormedSpace.expSeries_div_hasSum_exp (M : ℝ) + have hea : (∑' k, a k) = ∑ k ∈ Finset.range (M+1), (V*z*D^3)^k/(k.factorial : ℝ) := by + rw [tsum_eq_sum (s := Finset.range (M+1)) (by + intro k hk + have hh : ¬k ≤ M := by simpa only [Finset.mem_range, Nat.lt_add_one_iff] using hk + simp only [a, ite_eq_right hh])] + apply Finset.sum_congr rfl + intro k hk + exact ite_eq_left (by have := Finset.mem_range.mp hk; omega) + rw [show (∑ k ∈ Finset.range (packingNumber L+1), _) = ∑' k, a k by exact hea.symm, + ← hb.tsum_eq] + apply tsum_le_convolution (freeFamily_summable t d L) ha hb.summable + intro n + have hv := freeConfig_volume_le (ι := Fin n) ht L + rw [Fintype.card_fin] at hv + have hh := mul_le_mul_of_nonneg_right hv (pow_nonneg hz n) + have hh' := div_le_div_of_nonneg_right hh (Nat.cast_nonneg n.factorial : (0 : ℝ) ≤ n.factorial) + rw [familyTerm, freeFamily_integral, Fintype.card_fin] + apply hh'.trans + rw [Finset.sum_mul, Finset.sum_div] + apply Finset.sum_le_sum + intro k hk + have hkn : k ≤ n := by have := Finset.mem_range.mp hk; omega + by_cases hc : k ≤ M ∧ n ≤ 4*k + · simp only [show packingNumber L = M from rfl, ite_eq_left hc, a, ite_eq_left hc.1, b] + rw [Nat.cast_choose ℝ hkn] + have hf : (n.factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero n + have he : (((n.factorial : ℝ)/((k.factorial : ℝ)*((n-k).factorial : ℝ)))*V^k* + ((k : ℝ)*w)^(n-k)*z^n)/(n.factorial : ℝ) = + (V*z)^k/(k.factorial : ℝ)*((k : ℝ)^(n-k)*(w*z)^(n-k)/((n-k).factorial : ℝ)) := by + have hzpow : z^n = z^k*z^(n-k) := by rw [← pow_add, Nat.add_sub_of_le hkn] + rw [hzpow, mul_pow] + field_simp + ring + change (((n.factorial : ℝ)/((k.factorial : ℝ)*((n-k).factorial : ℝ)))*V^k* + ((k : ℝ)*w)^(n-k)*z^n)/(n.factorial : ℝ) ≤ _ + rw [he] + have hkM : (k : ℝ) ≤ M := by exact_mod_cast hc.1 + have hp := power_trunc_bound (mul_nonneg hw hz) (show n-k ≤ 3*k by omega) + have hpow : (k : ℝ)^(n-k)*(w*z)^(n-k) ≤ (M : ℝ)^(n-k)*D^(3*k) := + mul_le_mul (pow_le_pow_left₀ (Nat.cast_nonneg k) hkM _) hp + (pow_nonneg (mul_nonneg hw hz) _) (pow_nonneg (Nat.cast_nonneg M) _) + have hm := mul_le_mul_of_nonneg_left + (div_le_div_of_nonneg_right hpow (Nat.cast_nonneg (n-k).factorial)) + (div_nonneg (pow_nonneg (mul_nonneg hV hz) k) (Nat.cast_nonneg k.factorial)) + apply hm.trans_eq + rw [mul_pow, pow_mul] + ring + · simp only [show packingNumber L = M from rfl, ite_eq_right hc, zero_mul, zero_div] + apply mul_nonneg + · dsimp only [a] + split_ifs <;> positivity + · dsimp only [b] + positivity + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeIdeal.lean b/lean/OAI/Probability/ContinuumTransition/FreeIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..f65f48144aa2f7144ea6c47cd07ea1d01064eefb --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeIdeal.lean @@ -0,0 +1,140 @@ +import OAI.Probability.ContinuumTransition.PhysicalUniform + +namespace OAI + +section +open scoped Topology +open Set Filter Metric +noncomputable section +namespace ContinuumTemperature + +def threeCore (p : ℝ) (x : Parameter) : ℝ := max 0 (max (p*x.2) (4*p*x.2-9*p)) +def threeMeanField (p a : ℝ) (x : Parameter) : ℝ := + max 0 (max (p*x.2+x.1*a*p^2/2) (4*p*x.2-9*p+x.1*a*(4*p)^2/2)) +def firstMass (p : ℝ) : ℝ := 3/(2*p) +def initialPoint : Parameter := (1,-3/4) + +lemma threeCore_convex (p : ℝ) : ConvexOn ℝ pressureDomain (threeCore p) := by + have hdom : Convex ℝ pressureDomain := by + change Convex ℝ {x : Parameter | 0 < x.1} + exact (convex_Ioi (0 : ℝ)).linear_preimage (LinearMap.fst ℝ ℝ ℝ) + apply (convexOn_const (0 : ℝ) hdom).sup + apply ConvexOn.sup + · refine ⟨hdom,?_⟩ + intro x hx y hy a b ha hb hab + dsimp + nlinarith + · refine ⟨hdom,?_⟩ + intro x hx y hy a b ha hb hab + dsimp + have hh := congrArg (fun z : ℝ => z*(9*p)) hab + nlinarith only [hh] + +lemma three_meanField {p a : ℝ} (ha : 0 ≤ a) : IsMeanField (threeCore p) a (threeMeanField p a) := by + intro x hx + have hcoef : 0 ≤ x.1*a := mul_nonneg (le_of_lt hx) ha + have h0 : ∀ d : ℝ, -(x.1*a*d^2/2) ≤ 0 := fun d => neg_nonpos.mpr (div_nonneg (mul_nonneg hcoef (sq_nonneg d)) (by norm_num)) + have h1 : ∀ d : ℝ, p*(x.2+x.1*a*d)-x.1*a*d^2/2 ≤ p*x.2+x.1*a*p^2/2 := by + intro d + have hh := mul_nonneg hcoef (sq_nonneg (d-p)) + nlinarith only [hh] + have h2 : ∀ d : ℝ, 4*p*(x.2+x.1*a*d)-9*p-x.1*a*d^2/2 ≤ 4*p*x.2-9*p+x.1*a*(4*p)^2/2 := by + intro d + have hh := mul_nonneg hcoef (sq_nonneg (d-4*p)) + nlinarith only [hh] + constructor + · rintro _ ⟨d,rfl⟩ + change max 0 (max (p*(x.2+x.1*a*d)) (4*p*(x.2+x.1*a*d)-9*p))-x.1*a*d^2/2 ≤ _ + rw [← max_sub_sub_right,← max_sub_sub_right] + apply max_le + · exact (show 0-x.1*a*d^2/2 ≤ 0 by simpa using h0 d).trans (le_max_left _ _) + · apply max_le + · exact (h1 d).trans ((le_max_left _ _).trans (le_max_right _ _)) + · exact (h2 d).trans ((le_max_right _ _).trans (le_max_right _ _)) + · intro b hb + have he0 := hb (mem_range_self (0:ℝ)) + have he1 := hb (mem_range_self p) + have he2 := hb (mem_range_self (4*p)) + have hl0 : 0 ≤ quadraticCost (threeCore p) a x 0 := by + simp only [quadraticCost,shiftedField,mul_zero,add_zero,zero_pow (by decide : 2 ≠ 0),zero_div,sub_zero,threeCore] + exact le_max_left _ _ + have hl1 : p*x.2+x.1*a*p^2/2 ≤ quadraticCost (threeCore p) a x p := by + have hh := (le_max_left (p*(x.2+x.1*a*p)) (4*p*(x.2+x.1*a*p)-9*p)).trans (le_max_right (0:ℝ) _) + dsimp [quadraticCost,shiftedField,threeCore] + nlinarith only [hh] + have hl2 : 4*p*x.2-9*p+x.1*a*(4*p)^2/2 ≤ quadraticCost (threeCore p) a x (4*p) := by + have hh := (le_max_right (p*(x.2+x.1*a*(4*p))) (4*p*(x.2+x.1*a*(4*p))-9*p)).trans (le_max_right (0:ℝ) _) + dsimp [quadraticCost,shiftedField,threeCore] + nlinarith only [hh] + exact max_le (hl0.trans he0) (max_le (hl1.trans he1) (hl2.trans he2)) + +lemma support_first_zero {f : ℝ → ℝ} {x w : Parameter} (hx : x ∈ pressureDomain) + (hw : SupportOn pressureDomain (fun y => f y.2) x w) : w.1=0 := by + change 0 < x.1 at hx + have h1 := hw (2*x.1,x.2) (by change 0 < 2*x.1; positivity) + have h2 := hw (x.1/2,x.2) (by change 0 < x.1/2; positivity) + dsimp [pDot] at h1 h2 + nlinarith [hx] + +lemma firstMass_pos {p : ℝ} (hp : 0 < p) : 0 < firstMass p := by unfold firstMass; positivity +lemma firstMass_mul {p : ℝ} (hp : 0 < p) : firstMass p*p = 3/2 := by + unfold firstMass + field_simp + +lemma threeMeanField_initial {p : ℝ} (hp : 0 < p) : threeMeanField p (firstMass p) initialPoint=0 := by + have hh := firstMass_mul hp + have hh2 : firstMass p*p^2=3*p/2 := by linear_combination p*hh + have h1 : p*(-3/4)+firstMass p*p^2/2=0 := by nlinarith only [hh2] + have h2 : 4*p*(-3/4)-9*p+firstMass p*(4*p)^2/2=0 := by nlinarith only [hh2] + simp only [threeMeanField,initialPoint,one_mul,h1,h2,max_self] + +lemma three_active_initial {p : ℝ} (hp : 0 < p) : + activeLifts (threeCore p) (firstMass p) (threeMeanField p (firstMass p)) initialPoint ⊆ range (triangleVertex p) := by + intro w hw + have hβ : initialPoint ∈ pressureDomain := by norm_num [initialPoint,pressureDomain] + have he := support_first_zero (f := fun h => max 0 (max (p*h) (4*p*h-9*p))) (show shiftedField (firstMass p) initialPoint w.2 ∈ pressureDomain from hβ) hw.2 + have hc := hw.1 + rw [threeMeanField_initial hp] at hc + have ha := firstMass_pos hp + have hap := firstMass_mul hp + have hap2 : firstMass p*p^2=3*p/2 := by linear_combination p*hap + have hapd : firstMass p*p*w.2=3*w.2/2 := by linear_combination w.2*hap + change w.1-firstMass p*w.2^2/2=0 at he + simp only [quadraticCost,threeCore,shiftedField,initialPoint,one_mul] at hc + change max 0 (max (p*(-3/4+firstMass p*w.2)) (4*p*(-3/4+firstMass p*w.2)-9*p))-firstMass p*w.2^2/2=0 at hc + rcases le_total 0 (max (p*(-3/4+firstMass p*w.2)) (4*p*(-3/4+firstMass p*w.2)-9*p)) with h | h + · rw [max_eq_right h] at hc + rcases le_total (p*(-3/4+firstMass p*w.2)) (4*p*(-3/4+firstMass p*w.2)-9*p) with hh | hh + · rw [max_eq_right hh] at hc + have hd : w.2=4*p := by + have hh1 : firstMass p*(w.2-4*p)^2=0 := by nlinarith only [hc,hap2,hapd] + have := (mul_eq_zero.mp hh1).resolve_left ha.ne' + nlinarith [sq_nonneg (w.2-4*p)] + refine ⟨2,?_⟩ + ext <;> norm_num [triangleVertex,show (2:Fin 3) ≠ 0 by decide,show (2:Fin 3) ≠ 1 by decide] + · rw [hd] at he; nlinarith only [he,hap2] + · exact hd.symm + · rw [max_eq_left hh] at hc + have hd : w.2=p := by + have hh1 : firstMass p*(w.2-p)^2=0 := by nlinarith only [hc,hap2,hapd] + have := (mul_eq_zero.mp hh1).resolve_left ha.ne' + nlinarith [sq_nonneg (w.2-p)] + refine ⟨1,?_⟩ + ext <;> norm_num [triangleVertex] + · rw [hd] at he; nlinarith only [he,hap2] + · exact hd.symm + · rw [max_eq_left h] at hc + have hd : w.2=0 := by + have hm : firstMass p*w.2^2=0 := by linarith only [hc] + have hs := (mul_eq_zero.mp hm).resolve_left ha.ne' + nlinarith [sq_nonneg w.2] + refine ⟨0,?_⟩ + ext <;> norm_num [triangleVertex] + · rw [hd] at he; simpa using he.symm + · exact hd.symm + +end ContinuumTemperature +end +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeLimit.lean b/lean/OAI/Probability/ContinuumTransition/FreeLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f5a188a5bcbed800b39abb3a0d7e74102dcdc77 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeLimit.lean @@ -0,0 +1,43 @@ +import OAI.Probability.ContinuumTransition.LowerLimit + +namespace OAI + +section +open scoped Topology +open Filter Set +namespace ContinuumTemperature + +lemma core_pressure_nonneg {t β : ℝ} (ht : 1 < t) (hβ : 0 ≤ β) (h : ℝ) : + 0 ≤ physicalPressure (coreProfile t) t (β,h) := by + exact div_nonneg (canonicalPressure_nonneg + (measurable_radialPotential (measurable_coreProfile t)) ht hβ + (coreProfile_stable_zero t) (fun _ _ => le_refl _)) (by linarith) + +theorem core_pressure_tendsto {β : ℝ} (hβ : 0 < β) (h : ℝ) : + Tendsto (fun t : ℝ => physicalPressure (coreProfile t) t (β,h)) + atTop (𝓝 (idealCorePressure h)) := by + refine tendsto_order.2 ⟨?_,?_⟩ + · intro c hc + unfold idealCorePressure at hc + rcases lt_max_iff.mp hc with hc | hc + · filter_upwards [eventually_gt_atTop (1 : ℝ)] with t ht + exact hc.trans_le (core_pressure_nonneg ht hβ.le h) + · rcases lt_max_iff.mp hc with hc | hc + · obtain ⟨η,hη,he⟩ := exists_packing_dilate_lt hc + exact core_one_lower_eventually hβ.le hη h he + · have hc' : c < packingDensity*(4*h-9) := by nlinarith only [hc] + obtain ⟨η,hη,he⟩ := exists_packing_dilate_lt hc' + exact core_tetra_lower_eventually hβ.le hη h he + · intro c hc + have hsep : ∀ᶠ t : ℝ in atTop, 2*(1+shellDelta)*Real.exp (-t) < 1 := by + have hh := (Real.tendsto_exp_atBot.comp tendsto_neg_atTop_atBot).const_mul (2*(1+shellDelta)) + simp only [mul_zero] at hh + exact hh.eventually_lt_const zero_lt_one + filter_upwards [(core_upper_bound_tendsto hβ h).eventually_lt_const hc, + eventually_gt_atTop (1 : ℝ),hsep] with t ht h1 hs + exact (core_pressure_upper h1 hβ.le hs h).trans_lt ht + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeRoots.lean b/lean/OAI/Probability/ContinuumTransition/FreeRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf3800aa43694f1dbc5ba622f1e0af5f13eb50ea --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeRoots.lean @@ -0,0 +1,49 @@ +import OAI.Probability.ContinuumTransition.FreeGeometry + +namespace OAI + +section +open scoped BigOperators +open Set +namespace ContinuumTemperature +open Classical + +theorem freeConfig_roots {ι : Type} [Fintype ι] {t L : ℝ} {x : ι → Space} + (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) (hx : FreeConfig t x) + (hL : ∀ i, x i ∈ cube L) : + ∃ s : Finset ι, s.card ≤ packingNumber L ∧ Fintype.card ι ≤ 4*s.card ∧ + ∀ j, ∃ i ∈ s, ‖x j-x i‖ ≤ (1+shellDelta)*Real.exp (-t) := by + let Q := Quotient (freeSetoid ht hx) + let s : Finset ι := Finset.univ.image (fun c : Q => c.out) + have ho : Function.Injective (fun c : Q => c.out) := by + intro a b hab + have he := congrArg (Quotient.mk (freeSetoid ht hx)) hab + simpa only [Quotient.out_eq] using he + have hs : s.card = Fintype.card Q := by + exact (Finset.card_image_of_injective _ ho).trans (Finset.card_univ) + have hc (j : ι) : ∃ i ∈ s, j ∈ freeCluster x i := by + refine ⟨(Quotient.mk (freeSetoid ht hx) j).out, ?_, ?_⟩ + · exact Finset.mem_image.mpr ⟨Quotient.mk (freeSetoid ht hx) j, Finset.mem_univ _, rfl⟩ + · apply mem_freeCluster.mpr + exact Quotient.exact (Quotient.out_eq (Quotient.mk (freeSetoid ht hx) j)) + refine ⟨s, ?_, ?_, ?_⟩ + · rw [hs] + exact free_component_card_le_packing ht hx hL + · have hu : Finset.univ ⊆ s.biUnion (freeCluster x) := by + intro j _ + obtain ⟨i,hi,hj⟩ := hc j + exact Finset.mem_biUnion.mpr ⟨i,hi,hj⟩ + calc + Fintype.card ι = (Finset.univ : Finset ι).card := Finset.card_univ.symm + _ ≤ (s.biUnion (freeCluster x)).card := Finset.card_le_card hu + _ ≤ ∑ i ∈ s, (freeCluster x i).card := Finset.card_biUnion_le + _ ≤ ∑ _i ∈ s, 4 := Finset.sum_le_sum (fun i _ => freeCluster_card_le_four ht hx i) + _ = 4*s.card := by simp only [Finset.sum_const, smul_eq_mul, Nat.mul_comm] + · intro j + obtain ⟨i,hi,hj⟩ := hc j + exact ⟨i,hi,by simpa only [norm_sub_rev] using freeCluster_close_root hx hj⟩ + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/FreeUpper.lean b/lean/OAI/Probability/ContinuumTransition/FreeUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c2561b2976f95e4cc6e57e7ba3fff9ce3fccb52 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/FreeUpper.lean @@ -0,0 +1,112 @@ +import OAI.Probability.ContinuumTransition.GibbsIntegrability + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +theorem idealFamily_finite (d : ℝ) {D : Set Space} (hD : volume D ≠ ⊤) : + GrandFinite (idealFamily d) D := + GrandFinite.of_bound _ hD (fun _ _ => measurable_const) + (idealFamily_nonneg d) (fun _ _ _ => le_refl _) + +theorem grandIntegral_ideal (d : ℝ) (D : Set Space) : + grandIntegral (idealFamily d) D = Real.exp (volume.real D*Real.exp d) := by + have he (n : ℕ) : familyTerm (idealFamily d) D n = + (volume.real D*Real.exp d)^n/(n.factorial : ℝ) := by + simp only [familyTerm, familyIntegral, idealFamily, Fintype.card_fin, + setIntegral_const, smul_eq_mul, Measure.real, volume_generalConfigurations, + ENNReal.toReal_pow, mul_pow, mul_comm d, Real.exp_nat_mul] + simp_rw [grandIntegral, he] + simpa only [Real.exp_eq_exp_ℝ] using + (NormedSpace.expSeries_div_hasSum_exp (volume.real D*Real.exp d)).tsum_eq + +theorem core_gibbs_finite (t d : ℝ) {β : ℝ} (hβ : 0 ≤ β) + {D : Set Space} (hD : volume D ≠ ⊤) : + GrandFinite (gibbsFamily (fun x y => coreProfile t ‖x-y‖) β d) D := by + apply GrandFinite.of_bound _ hD + (fun ι _ => measurable_gibbsFamily (V := fun x y : Space => coreProfile t ‖x-y‖) ((measurable_coreProfile t).comp + ((measurable_fst.sub measurable_snd).norm)) β d ι) + (gibbsFamily_nonneg _ β d) + intro ι _ x + unfold gibbsFamily + split_ifs + · apply Real.exp_le_exp.mpr + have he : 0 ≤ gibbsEnergy (fun x y => coreProfile t ‖x-y‖) x := by + unfold gibbsEnergy + apply div_nonneg _ (by norm_num) + apply Finset.sum_nonneg + intro i _ + apply Finset.sum_nonneg + intro j _ + split_ifs + · rfl + · exact coreProfile_nonneg _ _ + exact sub_le_self _ (mul_nonneg hβ he) + · exact (Real.exp_pos _).le + +theorem core_grand_bad_bound (t d L : ℝ) {β : ℝ} (hβ : 0 ≤ β) : + grandIntegral (gibbsFamily (fun x y => coreProfile t ‖x-y‖) β d) (cube L) ≤ + Real.exp (volume.real (cube L)*Real.exp (d-β*t^2/2))* + grandIntegral (freeFamily t d) (cube L) := by + rw [← grandIntegral_ideal] + exact grandIntegral_label_convolution _ _ _ (idealFamily_relabel _) (freeFamily_relabel t d) + (measurableSet_cube L) (core_gibbs_finite t d hβ (isCompact_cube L).measure_lt_top.ne) + (idealFamily_finite _ (isCompact_cube L).measure_lt_top.ne) + (GrandFinite.of_bound _ (isCompact_cube L).measure_lt_top.ne + (freeFamily_measurable t d) (freeFamily_nonneg t d) (freeFamily_le_exp t d)) + (fun _ x _ => core_gibbs_bad_endpoints t d hβ x) + +lemma truncated_exp_poly_bound {V θ : ℝ} (hV : 0 ≤ V) (hθ : 0 ≤ θ) (M : ℕ) : + (∑ k ∈ Finset.range (M+1), (V*θ)^k/(k.factorial : ℝ)) ≤ + (M+1)*Real.exp V*(max 1 θ)^M := by + have hs : HasSum (fun k : ℕ => V^k/(k.factorial : ℝ)) (Real.exp V) := by + simpa only [Real.exp_eq_exp_ℝ] using NormedSpace.expSeries_div_hasSum_exp V + calc + _ ≤ ∑ _k ∈ Finset.range (M+1), Real.exp V*(max 1 θ)^M := by + apply Finset.sum_le_sum + intro k hk + have hkn : k ≤ M := by have := Finset.mem_range.mp hk; omega + have hp : V^k/(k.factorial : ℝ) ≤ Real.exp V := + hs.summable.le_tsum k (fun j _ => by positivity) |>.trans_eq hs.tsum_eq + rw [mul_pow, mul_div_right_comm] + exact mul_le_mul hp + ((pow_le_pow_left₀ hθ (le_max_right 1 θ) k).trans + (pow_le_pow_right₀ (le_max_left 1 θ) hkn)) + (pow_nonneg hθ k) (Real.exp_pos V).le + _ = _ := by simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul, Nat.cast_add, + Nat.cast_one]; ring + +noncomputable def clusterActivity (t d : ℝ) : ℝ := + Real.exp d*(max 1 (volume.real (Metric.closedBall (0 : Space) + ((1+shellDelta)*Real.exp (-t)))*Real.exp d))^3 + +theorem core_grand_upper {t : ℝ} (ht : 2*(1+shellDelta)*Real.exp (-t) < 1) + (d L : ℝ) {β : ℝ} (hβ : 0 ≤ β) : + grandIntegral (gibbsFamily (fun x y => coreProfile t ‖x-y‖) β d) (cube L) ≤ + Real.exp (volume.real (cube L)*(1+Real.exp (d-β*t^2/2))+(packingNumber L : ℝ))* + ((packingNumber L : ℝ)+1)*(max 1 (clusterActivity t d))^(packingNumber L) := by + have h1 := core_grand_bad_bound t d L hβ + have h2 := free_grand_upper ht d L + have h3 := truncated_exp_poly_bound (V := volume.real (cube L)) ENNReal.toReal_nonneg + (θ := clusterActivity t d) (by unfold clusterActivity; positivity) (packingNumber L) + have he : volume.real (cube L)*Real.exp d* + (max 1 (volume.real (Metric.closedBall (0 : Space) ((1+shellDelta)*Real.exp (-t)))*Real.exp d))^3 = + volume.real (cube L)*clusterActivity t d := by unfold clusterActivity; ring + rw [he] at h2 + apply h1.trans + apply (mul_le_mul_of_nonneg_left h2 (Real.exp_pos _).le).trans + apply (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right h3 (Real.exp_pos _).le) + (Real.exp_pos _).le).trans_eq + rw [show volume.real (cube L)*(1+Real.exp (d-β*t^2/2))+(packingNumber L : ℝ) = + volume.real (cube L)*Real.exp (d-β*t^2/2)+volume.real (cube L)+(packingNumber L : ℝ) by ring, + Real.exp_add, Real.exp_add] + ring + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/GeneralGrand.lean b/lean/OAI/Probability/ContinuumTransition/GeneralGrand.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a8ad4122f82f59e82e3b928caf914b187346669 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/GeneralGrand.lean @@ -0,0 +1,218 @@ +import OAI.Probability.ContinuumTransition.ExactAssignments + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature + +abbrev ConfigFamily := (ι : Type) → [Fintype ι] → (ι → Space) → ℝ + +def RelabelInvariant (F : ConfigFamily) : Prop := + ∀ (ι κ : Type) [Fintype ι] [Fintype κ] (e : ι ≃ κ) (x : κ → Space), + F ι (x ∘ e) = F κ x + +noncomputable def familyIntegral (F : ConfigFamily) (A : Set Space) + (ι : Type) [Fintype ι] : ℝ := + ∫ x in {x : ι → Space | ∀ i, x i ∈ A}, F ι x + +noncomputable def familyTerm (F : ConfigFamily) (A : Set Space) (n : ℕ) : ℝ := + familyIntegral F A (Fin n)/(n.factorial : ℝ) + +noncomputable def grandIntegral (F : ConfigFamily) (A : Set Space) : ℝ := + ∑' n : ℕ, familyTerm F A n + +theorem familyIntegral_relabel (F : ConfigFamily) (hF : RelabelInvariant F) + (A : Set Space) {ι κ : Type} [Fintype ι] [Fintype κ] (e : ι ≃ κ) : + familyIntegral F A ι = familyIntegral F A κ := by + let p : (ι → Space) ≃ᵐ (κ → Space) := MeasurableEquiv.piCongrLeft (fun _ : κ => Space) e + have hp : MeasurePreserving p volume volume := by + simpa only [volume_pi] using measurePreserving_piCongrLeft (fun _ : κ => volume) e + have hpx (x : ι → Space) : p x = x ∘ e.symm := by + funext i + simpa only [p, Equiv.apply_symm_apply, Function.comp_apply] using + (MeasurableEquiv.piCongrLeft_apply_apply e (β := fun _ : κ => Space) x (e.symm i)) + have heq := hp.setIntegral_preimage_emb p.measurableEmbedding (F κ) + {x : κ → Space | ∀ i, x i ∈ A} + have hpre : p ⁻¹' {x : κ → Space | ∀ i, x i ∈ A} = + {x : ι → Space | ∀ i, x i ∈ A} := by + ext x + simp only [mem_preimage, mem_ofPred_eq, hpx, Function.comp_apply] + constructor + · intro hh i + simpa only [Equiv.symm_apply_apply] using hh (e i) + · intro hh i + exact hh (e.symm i) + rw [hpre] at heq + simpa only [familyIntegral, hpx, hF κ ι e.symm] using heq + +theorem familyIntegral_eq_Fin (F : ConfigFamily) (hF : RelabelInvariant F) + (A : Set Space) (ι : Type) [Fintype ι] : + familyIntegral F A ι = familyIntegral F A (Fin (Fintype.card ι)) := + familyIntegral_relabel F hF A (Fintype.equivFin ι) + +theorem integral_binary_bound {ι : Type} [Fintype ι] [DecidableEq ι] + {A B : Set Space} (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + {F : (ι → Space) → ℝ} (a b : ℕ → ℝ) + (hF : IntegrableOn F {x : ι → Space | ∀ i, x i ∈ A ∪ B}) + (hbound : ∀ s : Finset ι, (∫ x in binaryRegion A B s, F x) ≤ + a s.card*b (Fintype.card ι-s.card)) : + (∫ x in {x : ι → Space | ∀ i, x i ∈ A ∪ B}, F x) ≤ + ∑ k ∈ Finset.range (Fintype.card ι+1), + ((Fintype.card ι).choose k : ℝ)*a k*b (Fintype.card ι-k) := by + rw [show volume = Measure.pi (fun _ : ι => (volume : Measure Space)) by exact volume_pi] + rw [integral_binary_assignments_eq volume hA hB hd (by simpa only [← volume_pi] using hF)] + calc + _ ≤ ∑ s : Finset ι, a s.card*b (Fintype.card ι-s.card) := by + apply Finset.sum_le_sum + intro s _ + simpa only [← volume_pi] using hbound s + _ = _ := by + have hh := Finset.sum_powerset_apply_card (fun k => a k*b (Fintype.card ι-k)) + (x := (Finset.univ : Finset ι)) + simpa only [Finset.powerset_univ, Finset.card_univ, nsmul_eq_mul, mul_assoc] using hh + +theorem factorial_binomial_sum (a b : ℕ → ℝ) (N : ℕ) : + (∑ k ∈ Finset.range (N+1), (N.choose k : ℝ)*a k*b (N-k))/(N.factorial : ℝ) = + ∑ k ∈ Finset.range (N+1), (a k/(k.factorial : ℝ))*(b (N-k)/((N-k).factorial : ℝ)) := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro k hk + rw [Nat.cast_choose ℝ (by have := Finset.mem_range.mp hk; omega)] + have hN : (N.factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero N + field_simp + +theorem familyTerm_nonneg (F : ConfigFamily) (A : Set Space) + (hF : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) (n : ℕ) : + 0 ≤ familyTerm F A n := by + apply div_nonneg (integral_nonneg (hF (Fin n))) + positivity + +theorem integrableOn_family_of_bound (F : ConfigFamily) {A : Set Space} + (hA : volume A ≠ ⊤) {ι : Type} [Fintype ι] + (hFm : Measurable (F ι)) (hF0 : ∀ x, 0 ≤ F ι x) + {C : ℝ} (hbound : ∀ x, F ι x ≤ C) : + IntegrableOn (F ι) {x : ι → Space | ∀ i, x i ∈ A} := by + have hvol : volume {x : ι → Space | ∀ i, x i ∈ A} ≠ ⊤ := by + rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hA + let : IsFiniteMeasure (volume.restrict {x : ι → Space | ∀ i, x i ∈ A}) := ⟨by + simpa only [Measure.restrict_apply_univ] using lt_top_iff_ne_top.mpr hvol⟩ + apply (integrable_const C).mono' hFm.aestronglyMeasurable + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_nonneg (hF0 x)] + exact hbound x + +theorem familyTerm_le_exponential (F : ConfigFamily) {A : Set Space} + (hA : volume A ≠ ⊤) {d : ℝ} + (hFm : ∀ (ι : Type) [Fintype ι], Measurable (F ι)) + (hF0 : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) + (hbound : ∀ (ι : Type) [Fintype ι] (x : ι → Space), + F ι x ≤ Real.exp (d*Fintype.card ι)) (n : ℕ) : + familyTerm F A n ≤ (volume.real A*Real.exp d)^n/(n.factorial : ℝ) := by + have hvol : volume {x : Fin n → Space | ∀ i, x i ∈ A} ≠ ⊤ := by + rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hA + let : IsFiniteMeasure (volume.restrict {x : Fin n → Space | ∀ i, x i ∈ A}) := ⟨by + simpa only [Measure.restrict_apply_univ] using lt_top_iff_ne_top.mpr hvol⟩ + have hh := integral_mono (integrableOn_family_of_bound F hA (hFm (Fin n)) + (hF0 (Fin n)) (hbound (Fin n))) (integrable_const _) (hbound (Fin n)) + have hn : (0 : ℝ) ≤ n.factorial := Nat.cast_nonneg _ + apply (div_le_div_of_nonneg_right hh hn).trans_eq + rw [setIntegral_const, Measure.real, volume_generalConfigurations, ENNReal.toReal_pow, + Fintype.card_fin, smul_eq_mul, mul_comm d (n : ℝ), Real.exp_nat_mul, mul_pow] + rfl + +theorem summable_familyTerm_of_bound (F : ConfigFamily) {A : Set Space} + (hA : volume A ≠ ⊤) {d : ℝ} + (hFm : ∀ (ι : Type) [Fintype ι], Measurable (F ι)) + (hF0 : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) + (hbound : ∀ (ι : Type) [Fintype ι] (x : ι → Space), + F ι x ≤ Real.exp (d*Fintype.card ι)) : Summable (familyTerm F A) := + Summable.of_nonneg_of_le (familyTerm_nonneg F A hF0) + (familyTerm_le_exponential F hA hFm hF0 hbound) + (Real.summable_pow_div_factorial _) + +theorem tsum_le_convolution {f a b : ℕ → ℝ} (hf : Summable f) + (ha : Summable a) (hb : Summable b) + (hle : ∀ n, f n ≤ ∑ k ∈ Finset.range (n+1), a k*b (n-k)) : + (∑' n, f n) ≤ (∑' n, a n)*(∑' n, b n) := by + have hab : Summable (fun p : ℕ × ℕ => a p.1*b p.2) := + summable_mul_of_summable_norm (summable_norm_iff.mpr ha) (summable_norm_iff.mpr hb) + rw [ha.tsum_mul_tsum_eq_tsum_sum_range hb hab] + exact hf.tsum_le_tsum hle (summable_sum_mul_range_of_summable_mul hab) + +theorem grandIntegral_insertion_bound (F G : ConfigFamily) + (hG : RelabelInvariant G) {A B : Set Space} + (hA : MeasurableSet A) (hB : MeasurableSet B) (hd : Disjoint A B) + (hAfin : volume A ≠ ⊤) + (hFi : ∀ n, IntegrableOn (F (Fin n)) {x | ∀ i, x i ∈ A ∪ B}) + (hGi : ∀ (ι : Type) [Fintype ι], IntegrableOn (G ι) {x | ∀ i, x i ∈ B}) + (hFs : Summable (familyTerm F (A ∪ B))) (hGs : Summable (familyTerm G B)) + {d : ℝ} + (hbound : ∀ (n : ℕ) (s : Finset (Fin n)) (x : Fin n → Space), + x ∈ binaryRegion A B s → F (Fin n) x ≤ + Real.exp (d*s.card) * G {i : Fin n // i ∉ s} (fun i => x i)) : + grandIntegral F (A ∪ B) ≤ + Real.exp (volume.real A*Real.exp d)*grandIntegral G B := by + let a (n : ℕ) := (volume.real A*Real.exp d)^n/(n.factorial : ℝ) + have ha : HasSum a (Real.exp (volume.real A*Real.exp d)) := + by + simpa only [a, Real.exp_eq_exp_ℝ] using + NormedSpace.expSeries_div_hasSum_exp (volume.real A*Real.exp d) + change (∑' n, familyTerm F (A ∪ B) n) ≤ + Real.exp (volume.real A*Real.exp d)*(∑' n, familyTerm G B n) + rw [← ha.tsum_eq] + apply tsum_le_convolution hFs ha.summable hGs + intro n + have hb := integral_binary_bound hA hB hd + (fun k => (volume.real A)^k*Real.exp (d*k)) + (fun k => familyIntegral G B (Fin k)) (hFi n) ?_ + swap + · intro s + have hv : volume {x : {i : Fin n // i ∈ s} → Space | ∀ i, x i ∈ A} ≠ ⊤ := by + rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hAfin + let : IsFiniteMeasure (volume.restrict + {x : {i : Fin n // i ∈ s} → Space | ∀ i, x i ∈ A}) := ⟨by + simpa only [Measure.restrict_apply_univ] using lt_top_iff_ne_top.mpr hv⟩ + have hprod := integrableOn_binary_product volume A B s + (integrable_const (Real.exp (d*s.card))) (by simpa only [← volume_pi] using hGi {i : Fin n // i ∉ s}) + have hi := setIntegral_mono_on + ((hFi n).mono_set (binaryRegion_subset_union A B s)) + (by simpa only [← volume_pi] using hprod) + (measurableSet_binaryRegion hA hB s) (hbound n s) + rw [show volume = Measure.pi (fun _ : Fin n => (volume : Measure Space)) by exact volume_pi, + setIntegral_binary_product volume A B s (fun _ => Real.exp (d*s.card)) + (G {i : Fin n // i ∉ s})] at hi + simp only [← volume_pi] at hi + have heg := familyIntegral_eq_Fin G hG B {i : Fin n // i ∉ s} + have hgc : familyIntegral G B {i : Fin n // i ∉ s} = + familyIntegral G B (Fin (n-s.card)) := by + have hc : Fintype.card {i : Fin n // i ∉ s} = n-s.card := by + rw [Fintype.card_subtype_compl (fun i : Fin n => i ∈ s), + Fintype.card_fin, Fintype.card_coe] + rw [hc] at heg + exact heg + rw [setIntegral_const, Measure.real, volume_generalConfigurations, ENNReal.toReal_pow, + Fintype.card_coe, smul_eq_mul] at hi + exact hi.trans_eq (by + change volume.real A ^ s.card * Real.exp (d*s.card) * + familyIntegral G B {i : Fin n // i ∉ s} = _ + rw [hgc, Fintype.card_fin]) + have hf : (0 : ℝ) ≤ n.factorial := Nat.cast_nonneg _ + have hh := div_le_div_of_nonneg_right hb hf + rw [Fintype.card_fin, factorial_binomial_sum + (fun k => (volume.real A)^k*Real.exp (d*k)) + (fun k => familyIntegral G B (Fin k)) n] at hh + apply hh.trans_eq + apply Finset.sum_congr rfl + intro k _ + dsimp only [a, familyTerm] + rw [mul_comm d (k : ℝ), Real.exp_nat_mul, mul_pow] + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/GeneralLabels.lean b/lean/OAI/Probability/ContinuumTransition/GeneralLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..790a1a86e1a79979958f3b826997618f6b568169 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/GeneralLabels.lean @@ -0,0 +1,131 @@ +import OAI.Probability.ContinuumTransition.Assignments + +namespace OAI + +universe u_1 u_2 + +section +open scoped Topology BigOperators ENNReal +open Filter MeasureTheory Set +namespace ContinuumTemperature + +section GeneralLabels +variable {ι : Type u_1} [Fintype ι] + +theorem measurable_symmetricWeight {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) (β : ℝ) : + Measurable (fun x : ι → Space => symmetricWeight φ β x) := by + let e : Fin (Fintype.card ι) ≃ ι := (Fintype.equivFin ι).symm + have hm : Measurable (fun x : ι → Space => x ∘ e) := by + apply Measurable.of_eval + intro i + exact measurable_pi_apply (e i) + have hh := (measurable_boltzmann hφ β (Fintype.card ι)).comp hm + change Measurable (fun x => boltzmann φ β (x ∘ e)) at hh + simpa only [boltzmann_eq_symmetricWeight, symmetricWeight_relabel] using hh + +theorem symmetricWeight_le_of_stable {φ : ℝ → ℝ} {β B : ℝ} (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) (x : ι → Space) : + symmetricWeight φ β x ≤ Real.exp (β * B * Fintype.card ι) := by + let e : Fin (Fintype.card ι) ≃ ι := (Fintype.equivFin ι).symm + have hh := boltzmann_le_of_stable hβ hstable (x ∘ e) + simpa only [boltzmann_eq_symmetricWeight, symmetricWeight_relabel] using hh + +theorem integrableOn_symmetricWeight {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B : ℝ} (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + {Ω : Set (ι → Space)} (hΩ : volume Ω ≠ ⊤) : + IntegrableOn (fun x : ι → Space => symmetricWeight φ β x) Ω := by + have : IsFiniteMeasure (volume.restrict Ω) := ⟨by + simpa only [Measure.restrict_apply_univ] using lt_top_iff_ne_top.mpr hΩ⟩ + apply (integrable_const (Real.exp (β * B * Fintype.card ι))).mono' + (measurable_symmetricWeight hφ β).aestronglyMeasurable + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_nonneg (symmetricWeight_nonneg φ β x)] + exact symmetricWeight_le_of_stable hβ hstable x + +noncomputable def generalPartition (φ : ℝ → ℝ) (β : ℝ) (A : Set Space) + (ι : Type u_2) [Fintype ι] : ℝ := + (∫ x in {x : ι → Space | ∀ i, x i ∈ A}, symmetricWeight φ β x) / + ((Fintype.card ι).factorial : ℝ) + +theorem generalPartition_nonneg (φ : ℝ → ℝ) (β : ℝ) (A : Set Space) : + 0 ≤ generalPartition φ β A ι := by + apply div_nonneg + · apply integral_nonneg + exact symmetricWeight_nonneg φ β + · positivity + +theorem generalPartition_eq_partition (φ : ℝ → ℝ) (β L : ℝ) (N : ℕ) : + generalPartition φ β (cube L) (Fin N) = partition φ β L N := by + classical + by_cases hN : N = 0 + · subst N + have hinj (x : Fin 0 → Space) : Function.Injective x := Function.injective_of_subsingleton x + have hv : volume.real (Set.univ : Set (Fin 0 → Space)) = 1 := by + simp [Measure.real, volume_pi] + simp [generalPartition, partition, symmetricWeight, realPairEnergy, hinj, hv] + · simp only [generalPartition, partition, hN, ite_false, Fintype.card_fin, + ← boltzmann_eq_symmetricWeight, div_eq_mul_inv, one_mul] + ring + +theorem volume_generalConfigurations (A : Set Space) : + volume {x : ι → Space | ∀ i, x i ∈ A} = (volume A) ^ Fintype.card ι := by + have heq : {x : ι → Space | ∀ i, x i ∈ A} = Set.univ.pi (fun _ : ι => A) := by + ext x + simp + rw [heq, volume_pi_pi] + simp + +theorem generalPartition_binary_lower [DecidableEq ι] {φ : ℝ → ℝ} + (hφ : Measurable (radialPotential φ)) {β B₀ : ℝ} (hβ : 0 ≤ β) + (hstable : ∀ (N : ℕ) (x : Fin N → Space), + ((-B₀ * (N : ℝ) : ℝ) : EReal) ≤ energy φ x) + {A B C : Set Space} (hA : MeasurableSet A) (hB : MeasurableSet B) + (hC : volume C ≠ ⊤) (hd : Disjoint A B) (haC : A ⊆ C) (hbC : B ⊆ C) + (hcross : ∀ a ∈ A, ∀ b ∈ B, φ ‖a - b‖ ≤ 0) + (s : Finset ι) : + generalPartition φ β A {i : ι // i ∈ s} * + generalPartition φ β B {i : ι // i ∉ s} ≤ generalPartition φ β C ι := by + classical + have hΩ : volume {x : ι → Space | ∀ i, x i ∈ C} ≠ ⊤ := by + rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hC + have hmA : volume A ≠ ⊤ := ne_top_of_le_ne_top hC (measure_mono haC) + have hmB : volume B ≠ ⊤ := ne_top_of_le_ne_top hC (measure_mono hbC) + have hΩA : volume {x : {i : ι // i ∈ s} → Space | ∀ i, x i ∈ A} ≠ ⊤ := by + rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hmA + have hΩB : volume {x : {i : ι // i ∉ s} → Space | ∀ i, x i ∈ B} ≠ ⊤ := by + rw [volume_generalConfigurations] + exact ENNReal.pow_ne_top hmB + have hInt := integral_lower_separated_product volume hA hB hd s + (integrableOn_symmetricWeight hφ hβ hstable hΩ) + (symmetricWeight_nonneg φ β) + (symmetricWeight_relabel φ β) + (fun t _ x hx i => by + by_cases hi : i ∈ t + · exact haC (by simpa only [ite_eq_left hi] using hx i) + · exact hbC (by simpa only [ite_eq_right hi] using hx i)) + (integrableOn_symmetricWeight hφ hβ hstable hΩA) + (integrableOn_symmetricWeight hφ hβ hstable hΩB) + (fun x hx => by + have hh := symmetricWeight_separated φ hβ (fun i => i ∈ s) hd hcross x + (fun i hi => by simpa only [ite_eq_left hi] using hx i) + (fun i hi => by simpa only [ite_eq_right hi] using hx i) + have hfi : Subtype.fintype (fun i : ι => i ∈ s) = Finset.Subtype.fintype s := + Subsingleton.elim _ _ + rw [hfi] at hh + exact hh) + have hh := binomial_factorial_cancel (Finset.card_le_univ s) hInt + simpa only [generalPartition, Fintype.card_subtype_compl, + Fintype.card_coe, volume_pi] using hh + +end GeneralLabels + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/GenericGibbs.lean b/lean/OAI/Probability/ContinuumTransition/GenericGibbs.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cddd4ee88df161e4cab6cbdceabd62d2bbaab20 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/GenericGibbs.lean @@ -0,0 +1,213 @@ +import OAI.Probability.ContinuumTransition.MomentExpectations + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +noncomputable def gibbsEnergy (V : Space → Space → ℝ) {ι : Type} [Fintype ι] + (x : ι → Space) : ℝ := + (∑ i, ∑ j, if i = j then 0 else V (x i) (x j))/2 + +noncomputable def gibbsFamily (V : Space → Space → ℝ) (β h : ℝ) : ConfigFamily := + fun ι _ x => if Function.Injective x then Real.exp (h*Fintype.card ι-β*gibbsEnergy V x) else 0 + +noncomputable def occupation {ι : Type} [Fintype ι] (C : Set Space) (x : ι → Space) : ℝ := + Fintype.card {i : ι // x i ∈ C} + +theorem occupation_nonneg {ι : Type} [Fintype ι] (C : Set Space) (x : ι → Space) : + 0 ≤ occupation C x := Nat.cast_nonneg _ + +theorem occupation_eq_sum {ι : Type} [Fintype ι] (C : Set Space) (x : ι → Space) : + occupation C x = ∑ i, if x i ∈ C then (1 : ℝ) else 0 := by + classical + simp only [occupation, ← Finset.sum_boole, Fintype.card_subtype] + +theorem measurable_occupation {ι : Type} [Fintype ι] {C : Set Space} (hC : MeasurableSet C) : + Measurable (fun x : ι → Space => occupation C x) := by + classical + simp_rw [occupation_eq_sum] + apply Finset.measurable_sum + intro i _ + apply Measurable.ite (hC.preimage (measurable_pi_apply i)) measurable_const measurable_const + +theorem occupation_relabel {ι κ : Type} [Fintype ι] [Fintype κ] + (C : Set Space) (e : ι ≃ κ) (x : κ → Space) : occupation C (x ∘ e) = occupation C x := by + classical + simp_rw [occupation_eq_sum, Function.comp_apply] + exact Equiv.sum_comp e (fun i => if x i ∈ C then (1 : ℝ) else 0) + +theorem occupation_subtype_compl {ι : Type} [Fintype ι] (C : Set Space) + (s : Finset ι) (x : ι → Space) (h : ∀ i ∈ s, x i ∉ C) : + occupation C (fun i : {i // i ∉ s} => x i) = occupation C x := by + classical + rw [occupation_eq_sum, occupation_eq_sum] + have hh := Fintype.sum_subtype_add_sum_subtype (fun i => i ∈ s) + (fun i => if x i ∈ C then (1 : ℝ) else 0) + have hz : (∑ i : {i // i ∈ s}, if x i ∈ C then (1 : ℝ) else 0) = 0 := by + apply Finset.sum_eq_zero + intro i _ + exact ite_eq_right (h i i.property) + have hfi : Subtype.fintype (fun i : ι => i ∈ s) = Finset.Subtype.fintype s := + Subsingleton.elim _ _ + rw [hfi] at hh + simpa only [hz, zero_add] using hh + +theorem gibbsEnergy_relabel (V : Space → Space → ℝ) {ι κ : Type} [Fintype ι] [Fintype κ] + (e : ι ≃ κ) (x : κ → Space) : gibbsEnergy V (x ∘ e) = gibbsEnergy V x := by + classical + unfold gibbsEnergy + simp only [Function.comp_apply, ← e.injective.eq_iff] + congr 1 + rw [← Equiv.sum_comp e] + apply Finset.sum_congr rfl + intro i _ + exact Equiv.sum_comp e (fun j => if e i = j then 0 else V (x (e i)) (x j)) + +theorem gibbsFamily_relabel (V : Space → Space → ℝ) (β h : ℝ) : + RelabelInvariant (gibbsFamily V β h) := by + intro ι κ _ _ e x + have hh : Function.Injective (x ∘ e) ↔ Function.Injective x := by + constructor + · intro hx i j hij + obtain ⟨i, rfl⟩ := e.surjective i + obtain ⟨j, rfl⟩ := e.surjective j + exact congrArg e (hx hij) + · exact fun hx => hx.comp e.injective + simp only [gibbsFamily, hh, gibbsEnergy_relabel, Fintype.card_congr e] + +theorem gibbsFamily_nonneg (V : Space → Space → ℝ) (β h : ℝ) (ι : Type) [Fintype ι] + (x : ι → Space) : 0 ≤ gibbsFamily V β h ι x := by + unfold gibbsFamily + split_ifs + · exact (Real.exp_pos _).le + · rfl + +theorem gibbsEnergy_split (V : Space → Space → ℝ) (hsym : ∀ x y, V x y = V y x) + {ι : Type} [Fintype ι] (p : ι → Prop) [DecidablePred p] (x : ι → Space) : + gibbsEnergy V x = gibbsEnergy V (fun i : {i // p i} => x i) + + gibbsEnergy V (fun i : {i // ¬p i} => x i) + + ∑ i : {i // p i}, ∑ j : {j // ¬p j}, V (x i) (x j) := by + classical + have heq := symmetric_matrix_split p (fun i j => if i = j then 0 else V (x i) (x j)) + (fun i j => by by_cases hh : i = j <;> simp [hh, eq_comm, hsym]) + have hcross (i : {i // p i}) (j : {j // ¬p j}) : (i : ι) ≠ j := by + intro hh + exact j.property (hh ▸ i.property) + have hself (a b : {i // p i}) : ((a : ι) = b) ↔ a = b := Subtype.coe_inj + have hself' (a b : {i // ¬p i}) : ((a : ι) = b) ↔ a = b := Subtype.coe_inj + unfold gibbsEnergy + rw [heq] + simp only [hself, hself', hcross, ite_false] + ring + +theorem measurable_gibbsEnergy {V : Space → Space → ℝ} + (hV : Measurable (Function.uncurry V)) {ι : Type} [Fintype ι] : + Measurable (fun x : ι → Space => gibbsEnergy V x) := by + unfold gibbsEnergy + apply Measurable.div_const + apply Finset.measurable_sum + intro i _ + apply Finset.measurable_sum + intro j _ + by_cases hij : i = j + · simp only [ite_eq_left hij] + exact measurable_const + · simp only [ite_eq_right hij] + have hp : Measurable (fun x : ι → Space => (x i, x j)) := + (measurable_pi_apply i).prodMk (measurable_pi_apply j) + exact hV.comp hp + +theorem measurableSet_injective_config (ι : Type) [Fintype ι] : + MeasurableSet {x : ι → Space | Function.Injective x} := by + have he : {x : ι → Space | Function.Injective x} = + ⋂ i : ι, ⋂ j : ι, {x : ι → Space | x i = x j → i = j} := by + ext x + simp only [mem_ofPred_eq, mem_iInter, Function.Injective] + rw [he] + apply MeasurableSet.iInter + intro i + apply MeasurableSet.iInter + intro j + by_cases hij : i = j + · simp only [hij, implies_true, ofPred_true] + exact MeasurableSet.univ + · have hm : MeasurableSet {x : ι → Space | x i = x j} := + measurableSet_eq_fun (measurable_pi_apply i) (measurable_pi_apply j) + convert hm.compl using 1 + ext x + simp [hij] + +theorem measurable_gibbsFamily {V : Space → Space → ℝ} + (hV : Measurable (Function.uncurry V)) (β h : ℝ) (ι : Type) [Fintype ι] : + Measurable (gibbsFamily V β h ι) := by + apply Measurable.ite (measurableSet_injective_config ι) _ measurable_const + exact (measurable_const.sub (measurable_const.mul (measurable_gibbsEnergy hV))).exp + +noncomputable def momentFamily (F : ConfigFamily) (C : Set Space) (c : ℝ) : ConfigFamily := + fun ι _ x => F ι x * Real.exp (c*(occupation C x)^2) + +theorem momentFamily_relabel (F : ConfigFamily) (hF : RelabelInvariant F) + (C : Set Space) (c : ℝ) : RelabelInvariant (momentFamily F C c) := by + intro ι κ _ _ e x + simp only [momentFamily, occupation_relabel, hF ι κ e x] + +theorem momentFamily_nonneg (F : ConfigFamily) + (hF : ∀ (ι : Type) [Fintype ι] (x : ι → Space), 0 ≤ F ι x) + (C : Set Space) (c : ℝ) (ι : Type) [Fintype ι] (x : ι → Space) : + 0 ≤ momentFamily F C c ι x := mul_nonneg (hF ι x) (Real.exp_pos _).le + +theorem measurable_momentFamily (F : ConfigFamily) {C : Set Space} (hC : MeasurableSet C) + (c : ℝ) {ι : Type} [Fintype ι] (hF : Measurable (F ι)) : + Measurable (momentFamily F C c ι) := + hF.mul ((measurable_occupation hC).pow_const 2 |>.const_mul c |>.exp) + +theorem gibbs_moment_stable_bound (V : Space → Space → ℝ) (β h B c : ℝ) + (C : Set Space) {ι : Type} [Fintype ι] (x : ι → Space) + (hbound : c*(occupation C x)^2 ≤ β*gibbsEnergy V x+β*B*Fintype.card ι) : + momentFamily (gibbsFamily V β h) C c ι x ≤ + Real.exp ((h+β*B)*Fintype.card ι) := by + by_cases hx : Function.Injective x + · simp only [momentFamily, gibbsFamily, ite_eq_left hx, ← Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith only [hbound] + · simp only [momentFamily, gibbsFamily, ite_eq_right hx, zero_mul] + exact (Real.exp_pos _).le + +theorem gibbs_moment_insertion (V : Space → Space → ℝ) + {A M J β B h : ℝ} (hA : 0 < A) (hM : M ≤ A/8) (hJ : J ≤ M) (hβ : 0 ≤ β) + (C : Set Space) {ι : Type} [Fintype ι] (s : Finset ι) (x : ι → Space) (X : ℝ) + (hn : occupation C x = s.card) + (hE : (A-J/2)*(s.card : ℝ)^2-B*s.card-s.card*X ≤ + gibbsEnergy V x-gibbsEnergy V (fun i : {i // i ∉ s} => x i)) : + momentFamily (gibbsFamily V β h) C (β*A/4) ι x ≤ + Real.exp ((h+β*B)*s.card) * + (gibbsFamily V β h {i : ι // i ∉ s} (fun i => x i)*Real.exp (β*X^2/A)) := by + by_cases hx : Function.Injective x + swap + · simp only [momentFamily, gibbsFamily, ite_eq_right hx, zero_mul] + exact mul_nonneg (Real.exp_pos _).le + (mul_nonneg (gibbsFamily_nonneg V β h _ _) (Real.exp_pos _).le) + have hout : Function.Injective (fun i : {i : ι // i ∉ s} => x i) := + hx.comp Subtype.val_injective + have hcard : (Fintype.card ι : ℝ) = s.card+Fintype.card {i : ι // i ∉ s} := by + have hc : Fintype.card {i : ι // i ∉ s} = Fintype.card ι-s.card := by + rw [Fintype.card_subtype_compl (fun i : ι => i ∈ s), Fintype.card_coe] + rw [hc] + rw [Nat.cast_sub (Finset.card_le_univ s)] + ring + have he := mul_le_mul_of_nonneg_left hE hβ + have hex := cell_insertion_exponent (B := B) (h := h) (n := (s.card : ℝ)) + (X := X) hA hM hJ hβ rfl + simp only [momentFamily, gibbsFamily, ite_eq_left hx, ite_eq_left hout, hn, ← Real.exp_add] + apply Real.exp_le_exp.mpr + rw [hcard] + nlinarith only [he, hex] + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/GibbsBridge.lean b/lean/OAI/Probability/ContinuumTransition/GibbsBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd401bf2e61903268de8381a5910cb03b1911899 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/GibbsBridge.lean @@ -0,0 +1,76 @@ +import OAI.Probability.ContinuumTransition.ModifiedEnergy + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +theorem gibbsEnergy_radial (φ : ℝ → ℝ) {ι : Type} [Fintype ι] (x : ι → Space) : + gibbsEnergy (fun x y => φ ‖x-y‖) x = realPairEnergy φ x := by + unfold gibbsEnergy realPairEnergy + ring + +theorem gibbsFamily_radial (φ : ℝ → ℝ) (β h : ℝ) (ι : Type) [Fintype ι] (x : ι → Space) : + gibbsFamily (fun x y => φ ‖x-y‖) β h ι x = + Real.exp (h*Fintype.card ι)*symmetricWeight φ β x := by + unfold gibbsFamily symmetricWeight + split_ifs + · rw [gibbsEnergy_radial, ← Real.exp_add] + congr 1 + ring + · simp + +theorem familyTerm_radial (φ : ℝ → ℝ) (β h L : ℝ) (n : ℕ) : + familyTerm (gibbsFamily (fun x y => φ ‖x-y‖) β h) (cube L) n = + Real.exp (h*n)*partition φ β L n := by + unfold familyTerm familyIntegral + simp_rw [gibbsFamily_radial, Fintype.card_fin] + rw [integral_const_mul, mul_div_assoc] + simpa only [generalPartition, Fintype.card_fin] using + congrArg (fun a : ℝ => Real.exp (h*n)*a) (generalPartition_eq_partition φ β L n) + +theorem grandIntegral_radial (φ : ℝ → ℝ) (t β h L : ℝ) : + grandIntegral (gibbsFamily (fun x y => φ ‖x-y‖) β (t*h)) (cube L) = + grandPartition φ t β h L := by + unfold grandIntegral grandPartition + simp_rw [familyTerm_radial] + +theorem CellLowerBound.mono {t : ℝ} {σ R : ℕ → ℝ} {U V : Space → Space → ℝ} + (hU : CellLowerBound t σ R U) (hUV : ∀ x y, U x y ≤ V x y) : CellLowerBound t σ R V := + fun x y => (hU x y).trans (hUV x y) + +theorem physical_cellLowerBound {t : ℝ} (ht : 0 ≤ t) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) : + CellLowerBound t σ R (fun x y => physicalProfile t σ R ‖x-y‖) := by + intro x y + have hb := attraction_le_mixedEnvelope ht hσ hR hs x y + change attraction t σ R ‖x-y‖ ≤ physicalCoupling t σ R (cellIndex x) (cellIndex y) at hb + dsimp only [physicalProfile] + split_ifs + · linarith only [hb] + · linarith only [hb, coreProfile_nonneg t ‖x-y‖] + +theorem masked_physical_cellLowerBound {t : ℝ} (ht : 0 ≤ t) {σ R : ℕ → ℝ} + (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (p q : Space → Space → ℝ) (hp : ∀ x y, 0 ≤ p x y) + (hpc : ∀ x y, cellIndex x = cellIndex y → p x y = 1) (hq : ∀ x y, q x y ≤ 1) : + CellLowerBound t σ R (fun x y => p x y*coreProfile t ‖x-y‖-q x y*attraction t σ R ‖x-y‖) := by + intro x y + have hb := attraction_le_mixedEnvelope ht hσ hR hs x y + have ha := attraction_nonneg ht hσ hR ‖x-y‖ + have hc := coreProfile_nonneg t ‖x-y‖ + have hq' := mul_le_mul_of_nonneg_right (hq x y) ha + change attraction t σ R ‖x-y‖ ≤ physicalCoupling t σ R (cellIndex x) (cellIndex y) at hb + dsimp only + split_ifs with hxy + · rw [hpc x y hxy] + nlinarith only [hb, hq'] + · nlinarith only [hb, hq', mul_nonneg (hp x y) hc] + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/GibbsIntegrability.lean b/lean/OAI/Probability/ContinuumTransition/GibbsIntegrability.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d148ccba719c311d00d8a09f3a732f92b455f8c --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/GibbsIntegrability.lean @@ -0,0 +1,87 @@ +import OAI.Probability.ContinuumTransition.LabelConvolution + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature +open Classical + +theorem volume_latticeCell_le_one (z : Lattice) : volume (latticeCell z) ≤ 1 := by + let a : Space := WithLp.toLp 2 (fun k => ((z k : ℝ)+1/2)/4) + have hsub : latticeCell z ⊆ (fun x : Space => x+(-a)) ⁻¹' cube 1 := by + intro x hx k + have he : ⌊4*x k⌋ = z k := congrFun hx k + have hlo := Int.floor_le (4*x k) + have hhi := Int.lt_floor_add_one (4*x k) + rw [he] at hlo hhi + change -(1 : ℝ)/2 ≤ x k-a k ∧ x k-a k ≤ 1/2 + dsimp only [a] + constructor <;> linarith + have hp := (measurePreserving_add_right volume (-a)).measure_preimage (measurableSet_cube 1).nullMeasurableSet + have hv : volume ((fun x : Space => x+(-a)) ⁻¹' cube 1) = 1 := by + rw [hp, volume_cube] + norm_num + exact (measure_mono hsub).trans_eq hv + +theorem real_volume_cropped_cell_le_one (D : Set Space) (z : Lattice) : + volume.real (D ∩ latticeCell z) ≤ 1 := by + have hh := (measure_mono (inter_subset_right : D ∩ latticeCell z ⊆ latticeCell z)).trans + (volume_latticeCell_le_one z) + simpa only [Measure.real, ENNReal.toReal_one] using ENNReal.toReal_mono (by norm_num) hh + +theorem gibbsFamily_term_zero (V : Space → Space → ℝ) (β h : ℝ) (D : Set Space) : + familyTerm (gibbsFamily V β h) D 0 = 1 := by + have hf : gibbsFamily V β h (Fin 0) = fun _ => 1 := by + funext x + simp only [gibbsFamily, ite_eq_left (Function.injective_of_subsingleton x), + gibbsEnergy, Fintype.card_fin, Nat.cast_zero, mul_zero, Finset.univ_eq_empty, + Finset.sum_empty, zero_div, sub_zero, Real.exp_zero] + dsimp only [familyTerm, familyIntegral] + rw [hf, setIntegral_const, Measure.real, volume_generalConfigurations] + norm_num + +theorem grandIntegral_gibbs_pos (V : Space → Space → ℝ) (β h : ℝ) (D : Set Space) + (hs : Summable (familyTerm (gibbsFamily V β h) D)) : + 0 < grandIntegral (gibbsFamily V β h) D := by + have hh := hs.le_tsum 0 (fun n _ => familyTerm_nonneg _ D (gibbsFamily_nonneg V β h) n) + rw [gibbsFamily_term_zero] at hh + exact lt_of_lt_of_le zero_lt_one hh + +theorem physical_gibbs_moment_finite {t β : ℝ} (ht : 0 ≤ t) (hβ : 0 ≤ β) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n) ≤ (t^2/8)/8) + {D : Set Space} (hDfin : volume D ≠ ⊤) (h : ℝ) (z : Lattice) + {c : ℝ} (hc : c ≤ β*(t^2/8)/4) : + GrandFinite (momentFamily + (gibbsFamily (fun x y => physicalProfile t σ R ‖x-y‖) β h) (latticeCell z) c) D := by + have hm : Measurable (Function.uncurry (fun x y : Space => physicalProfile t σ R ‖x-y‖)) := + (measurable_physicalProfile t hσ hR hs).comp ((measurable_fst.sub measurable_snd).norm) + apply GrandFinite.of_bound _ hDfin + (fun ι _ => measurable_momentFamily _ (measurableSet_latticeCell z) c (measurable_gibbsFamily hm β h ι)) + (momentFamily_nonneg _ (gibbsFamily_nonneg _ β h) _ _) + intro ι _ x + apply gibbs_moment_stable_bound _ β h (t^2/2) c _ x + have he := mul_le_mul_of_nonneg_left (physical_gibbs_moment_energy ht hσ hR hs hsmall x z) hβ + have hcc := mul_le_mul_of_nonneg_right hc (sq_nonneg (occupation (latticeCell z) x)) + nlinarith only [he, hcc] + +theorem physical_gibbs_finite {t β : ℝ} (ht : 0 ≤ t) (hβ : 0 ≤ β) + {σ R : ℕ → ℝ} (hσ : ∀ n, 0 ≤ σ n) (hR : ∀ n, 1 ≤ R n) (hs : Summable σ) + (hsmall : 2197*t*kernelHeight*(∑' n, σ n) ≤ (t^2/8)/8) + {D : Set Space} (hDfin : volume D ≠ ⊤) (h : ℝ) : + GrandFinite (gibbsFamily (fun x y => physicalProfile t σ R ‖x-y‖) β h) D := by + have h0 : (0 : ℝ) ≤ β*(t^2/8)/4 := by positivity + have hh := physical_gibbs_moment_finite ht hβ hσ hR hs hsmall hDfin h (fun _ => 0) h0 + have he : momentFamily (gibbsFamily (fun x y => physicalProfile t σ R ‖x-y‖) β h) + (latticeCell (fun _ => 0)) 0 = gibbsFamily (fun x y => physicalProfile t σ R ‖x-y‖) β h := by + funext ι inst x + simp only [momentFamily, zero_mul, Real.exp_zero, mul_one] + rw [he] at hh + exact hh + +end ContinuumTemperature +end + +end OAI diff --git a/lean/OAI/Probability/ContinuumTransition/GibbsMonotonicity.lean b/lean/OAI/Probability/ContinuumTransition/GibbsMonotonicity.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6729632d91adfcdbea6eadce4e9f29e122aa338 --- /dev/null +++ b/lean/OAI/Probability/ContinuumTransition/GibbsMonotonicity.lean @@ -0,0 +1,30 @@ +import OAI.Probability.ContinuumTransition.ModifiedComparison + +namespace OAI + +section +open scoped BigOperators +open MeasureTheory Set +namespace ContinuumTemperature + +theorem gibbsFamily_antitone {U V : Space → Space → ℝ} {β : ℝ} (hβ : 0 ≤ β) + (hUV : ∀ x y, U x y ≤ V x y) (h : ℝ) (ι : Type) [Fintype ι] (x : ι → Space) : + gibbsFamily V β h ι x ≤ gibbsFamily U β h ι x := by + unfold gibbsFamily + split_ifs + · apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left (gibbsEnergy_mono x (fun i j => hUV (x i) (x j))) hβ + linarith only [hh] + · rfl + +theorem grandIntegral_gibbs_antitone {U V : Space → Space → ℝ} {β : ℝ} (hβ : 0 ≤ β) + (hUV : ∀ x y, U x y ≤ V x y) (h : ℝ) {D : Set Space} (hD : MeasurableSet D) + (hU : GrandFinite (gibbsFamily U β h) D) (hV : GrandFinite (gibbsFamily V β h) D) : + grandIntegral (gibbsFamily V β h) D ≤ grandIntegral (gibbsFamily U β h) D := + grandIntegral_mono _ _ hD (fun n => hV.integrable (Fin n)) (fun n => hU.integrable (Fin n)) + hV.summable hU.summable (fun n x _ => gibbsFamily_antitone hβ hUV h (Fin n) x) + +end ContinuumTemperature +end + +end OAI