Download data/lean/OAI/Probability/DirectionalWalk/DyadicBounds.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.98 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/DirectionalWalk/DyadicBounds.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/DirectionalWalk/DyadicBounds.lean
-
curl -L -o DyadicBounds.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/DirectionalWalk/DyadicBounds.lean
9.98 kB
| import OAI.Probability.DirectionalWalk.ContactBins | |
| namespace OAI | |
| open MeasureTheory ProbabilityTheory Filter Preorder | |
| open scoped ENNReal BigOperators Topology | |
| namespace DirectionalZeroOne | |
| open scoped Classical | |
| noncomputable def dyad (j : β) : ββ₯0β := ENNReal.ofReal ((1/2 : β)^(j+1)) | |
| lemma dyad_pos (j : β) : 0 < dyad j := ENNReal.ofReal_pos.mpr (pow_pos (by norm_num) _) | |
| lemma dyad_ne_top (j : β) : dyad j β β := ENNReal.ofReal_ne_top | |
| lemma exists_dyad_bin {q : ββ₯0β} (hq : 0 < q) (h1 : q < 1) : | |
| β j : β, dyad j β€ q β§ q < 2*dyad j := by | |
| have hqf : q β β := ne_of_lt (h1.trans (by norm_num)) | |
| have hqr : 0 < q.toReal := ENNReal.toReal_pos (ne_of_gt hq) hqf | |
| have hqr1 : q.toReal < 1 := by exact_mod_cast (ENNReal.toReal_lt_toReal hqf (by norm_num)).mpr h1 | |
| have ht := tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : 0 β€ (1/2 : β)) (by norm_num : (1/2 : β) < 1) | |
| have hex : β n : β, (1/2 : β)^n β€ q.toReal := by | |
| obtain β¨n,hnβ© := (ht.eventually (eventually_lt_nhds hqr)).exists | |
| exact β¨n,hn.leβ© | |
| let n := Nat.find hex | |
| have hn : (1/2 : β)^n β€ q.toReal := Nat.find_spec hex | |
| have hn0 : 0 < n := by | |
| by_contra h | |
| have he : n = 0 := by omega | |
| rw [he,pow_zero] at hn | |
| linarith | |
| refine β¨n-1,?_,?_β© | |
| Β· unfold dyad | |
| rw [Nat.sub_add_cancel hn0] | |
| exact (ENNReal.ofReal_le_iff_le_toReal hqf).mpr hn | |
| Β· have hp : q.toReal < (1/2 : β)^(n-1) := lt_of_not_ge (Nat.find_min hex (by omega)) | |
| have he : (2 : β) * (1/2 : β)^n = (1/2 : β)^(n-1) := by | |
| conv_lhs => rw [β Nat.sub_add_cancel hn0,pow_succ] | |
| ring | |
| rw [dyad,Nat.sub_add_cancel hn0,β ENNReal.ofReal_ofNat,β ENNReal.ofReal_mul (by norm_num),he] | |
| exact (ENNReal.lt_ofReal_iff_toReal_lt hqf).mpr hp | |
| lemma return_bins_cover {d : β} (e : Step d) (k N : β€) (Ο : Environment d) | |
| (hΟ : β x f, 0 < (Ο x).val f) (y : Site d) | |
| (hy : k β€ axisHeight e y β§ axisHeight e y < N) : | |
| β j, y β returnBin e k N (dyad j) Ο := by | |
| obtain β¨j,hj,hj'β© := exists_dyad_bin (quenchedReturn_pos_lt_one e k N Ο hΟ y hy).1 | |
| (quenchedReturn_pos_lt_one e k N Ο hΟ y hy).2 | |
| exact β¨j,β¨hy.1,hy.2,hjβ©,hj'β© | |
| lemma tsum_subtype_cover {Ξ± : Type*} [Countable Ξ±] (A : Set Ξ±) (B : β β Set Ξ±) | |
| (h : A β β n, B n) (f : Ξ± β ββ₯0β) : | |
| (β' a : A, f a) β€ β' n, β' a : B n, f a := by | |
| classical | |
| have hex (a : A) : β n, a.val β B n := Set.mem_iUnion.mp (h a.property) | |
| let g : A β (Ξ£ n, B n) := fun a => β¨(hex a).choose,β¨a.val,(hex a).choose_specβ©β© | |
| have hg : Function.Injective g := by | |
| intro a b hab | |
| have hv : ((g a).2 : Ξ±) = ((g b).2 : Ξ±) := congrArg (fun i : Ξ£ n, B n => i.2.val) hab | |
| exact Subtype.ext hv | |
| calc | |
| _ β€ β' i : Ξ£ n, B n, f i.2 := Summable.tsum_le_tsum_of_inj g hg (fun _ _ => zero_le) (fun _ => le_rfl) ENNReal.summable ENNReal.summable | |
| _ = _ := ENNReal.tsum_sigma (fun n (a : B n) => f a) | |
| lemma half_geometric_sum_le (s : Finset β) : (β j β s, (1/2 : β)^(j+1)) β€ 1 := by | |
| have hs : HasSum (fun j : β => (1/2 : β)^(j+1)) 1 := by | |
| have hh := (hasSum_geometric_of_norm_lt_one (by norm_num : β(1/2 : β)β < 1)).mul_right (1/2) | |
| norm_num [pow_succ] at hh β’ | |
| exact hh | |
| exact (hs.summable.sum_le_tsum s (fun j _ => by positivity)).trans_eq hs.tsum_eq | |
| lemma half_geometric_tail_sum_le (s : Finset β) (m : β) : | |
| (β j β s.filter (m β€ Β·), (1/2 : β)^(j+1)) β€ (1/2 : β)^m := by | |
| classical | |
| let t := (s.filter (m β€ Β·)).image (fun j => j-m) | |
| have he : (β j β s.filter (m β€ Β·), (1/2 : β)^(j+1)) = | |
| (1/2 : β)^m * β j β t, (1/2 : β)^(j+1) := by | |
| rw [Finset.mul_sum,Finset.sum_image] | |
| Β· apply Finset.sum_congr rfl | |
| intro j hj | |
| rw [β pow_add] | |
| congr 1 | |
| have := (Finset.mem_filter.mp hj).2 | |
| omega | |
| Β· intro a ha b hb hab | |
| have := (Finset.mem_filter.mp ha).2 | |
| have := (Finset.mem_filter.mp hb).2 | |
| change a-m=b-m at hab | |
| omega | |
| rw [he] | |
| exact (mul_le_mul_of_nonneg_left (half_geometric_sum_le t) (by positivity)).trans_eq (mul_one _) | |
| lemma dyadic_weighted_mass_sum {v : β β β} (_hv0 : β j, 0 β€ v j) (hv1 : β j, v j β€ 1) | |
| (m : β) (hv : β j, (1/2 : β)^(j+1)*v j β€ (1/2 : β)^m) (s : Finset β) : | |
| (β j β s, (1/2 : β)^(j+1)*v j) β€ (m+1)*(1/2 : β)^m := by | |
| classical | |
| have hsmall : (β j β s.filter (Β· < m), (1/2 : β)^(j+1)*v j) β€ m*(1/2 : β)^m := by | |
| calc | |
| _ β€ β _ β s.filter (Β· < m), (1/2 : β)^m := Finset.sum_le_sum (fun j _ => hv j) | |
| _ = ((s.filter (Β· < m)).card : β)*(1/2 : β)^m := by simp | |
| _ β€ m*(1/2 : β)^m := by | |
| apply mul_le_mul_of_nonneg_right _ (by positivity) | |
| have hh : (s.filter (Β· < m)).card β€ m := by | |
| simpa using (Finset.card_le_card (show s.filter (Β· < m) β Finset.range m by | |
| intro j hj;exact Finset.mem_range.mpr (Finset.mem_filter.mp hj).2)) | |
| exact_mod_cast hh | |
| have hlarge : (β j β s.filter (m β€ Β·), (1/2 : β)^(j+1)*v j) β€ (1/2 : β)^m := by | |
| apply (Finset.sum_le_sum (s := s.filter (m β€ Β·)) (fun j _ => | |
| mul_le_of_le_one_right (by positivity) (hv1 j))).trans | |
| exact half_geometric_tail_sum_le s m | |
| have he : (β j β s.filter (Β· < m), (1/2 : β)^(j+1)*v j) + | |
| (β j β s.filter (m β€ Β·), (1/2 : β)^(j+1)*v j) = β j β s, (1/2 : β)^(j+1)*v j := by | |
| simpa only [not_lt] using Finset.sum_filter_add_sum_filter_not s (fun j => j < m) | |
| (fun j => (1/2 : β)^(j+1)*v j) | |
| linarith | |
| lemma dyadic_event_weight_bound {Ξ© : Type*} [MeasurableSpace Ξ©] | |
| (Ξ½ : Measure Ξ©) [IsProbabilityMeasure Ξ½] (S : Ξ© β β) (hS : Integrable S Ξ½) | |
| (hS0 : β ΞΎ, 0 β€ S ΞΎ) (c : β) (hc : 0 < c) | |
| (hExp : Integrable (fun ΞΎ => Real.exp (c*S ΞΎ)) Ξ½) | |
| (hExp12 : (β« ΞΎ, Real.exp (c*S ΞΎ) βΞ½) β€ 12) | |
| (V : β β Set Ξ©) (m : β) | |
| (hV : β j, dyad j * Ξ½ (V j) β€ ENNReal.ofReal ((1/2 : β)^m)) : | |
| (β' j, 2*dyad j * β«β» ΞΎ in V j, ENNReal.ofReal (S ΞΎ) βΞ½) β€ | |
| ENNReal.ofReal ((24/c)*(m+1)^2*(1/2 : β)^m) := by | |
| classical | |
| let t := (1/2 : β)^m | |
| have ht : 0 < t := pow_pos (by norm_num) _ | |
| have ht1 : t β€ 1 := pow_le_oneβ (by norm_num) (by norm_num) | |
| have hl : Real.log t β€ 0 := Real.log_nonpos ht.le ht1 | |
| have hv (j : β) : (1/2 : β)^(j+1)*Ξ½.real (V j) β€ t := by | |
| have hh := ENNReal.toReal_mono (ENNReal.ofReal_ne_top) (hV j) | |
| simpa only [ENNReal.toReal_mul,dyad,ENNReal.toReal_ofReal (pow_nonneg (by norm_num : (0 : β) β€ 1/2) _),Measure.real,t] using hh | |
| have hlog : -Real.log t β€ m := by | |
| dsimp [t] | |
| rw [Real.log_pow,Real.log_div (by norm_num) (by norm_num),Real.log_one] | |
| have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : β) < 2) | |
| nlinarith [mul_le_mul_of_nonneg_left h (Nat.cast_nonneg m)] | |
| rw [ENNReal.tsum_eq_iSup_sum] | |
| apply iSup_le | |
| intro s | |
| have hI (j : β) : c*(β« ΞΎ in V j, S ΞΎ βΞ½) β€ 12*t - Ξ½.real (V j)*Real.log t := by | |
| have hp (ΞΎ : Ξ©) : c*S ΞΎ β€ t*Real.exp (c*S ΞΎ)-Real.log t := by | |
| have h := Real.add_one_le_exp (c*S ΞΎ + Real.log t) | |
| rw [Real.exp_add,Real.exp_log ht] at h | |
| nlinarith | |
| have hi := integral_mono (hS.restrict (s := V j) |>.const_mul c) | |
| ((hExp.restrict.const_mul t).sub (integrable_const (Real.log t))) hp | |
| simp only [Pi.sub_apply] at hi | |
| rw [integral_const_mul,integral_sub (hExp.restrict (s := V j) |>.const_mul t) (integrable_const _), | |
| integral_const_mul,integral_const,measureReal_restrict_apply_univ,smul_eq_mul] at hi | |
| have he : (β« ΞΎ in V j, Real.exp (c*S ΞΎ) βΞ½) β€ 12 := | |
| (setIntegral_le_integral hExp (Filter.Eventually.of_forall (fun ΞΎ => Real.exp_nonneg _))).trans hExp12 | |
| nlinarith [mul_le_mul_of_nonneg_left he ht.le] | |
| let B := β j β s, (1/2 : β)^(j+1)*(β« ΞΎ in V j, S ΞΎ βΞ½) | |
| have hB : c*B β€ 12*t + m*((m+1)*t) := by | |
| have hsum := Finset.sum_le_sum (s := s) (fun j _ => mul_le_mul_of_nonneg_left (hI j) | |
| (pow_nonneg (by norm_num : (0 : β) β€ 1/2) (j+1))) | |
| have he1 : (β j β s, (1/2 : β)^(j+1)*(c*(β« ΞΎ in V j, S ΞΎ βΞ½))) = c*B := by | |
| dsimp [B];rw [Finset.mul_sum];apply Finset.sum_congr rfl;intro j _;ring | |
| have he2 : (β j β s, (1/2 : β)^(j+1)*(12*t-Ξ½.real (V j)*Real.log t)) = | |
| 12*t*(β j β s, (1/2 : β)^(j+1)) + (-Real.log t)*(β j β s, (1/2 : β)^(j+1)*Ξ½.real (V j)) := by | |
| rw [Finset.mul_sum,Finset.mul_sum,β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl;intro j _;ring | |
| rw [he1,he2] at hsum | |
| have hmass := dyadic_weighted_mass_sum (fun j => measureReal_nonneg) (fun j => measureReal_le_one) m hv s | |
| have hh := mul_le_mul_of_nonneg_left (half_geometric_sum_le s) (show 0 β€ 12*t by positivity) | |
| have hh' := mul_le_mul hlog hmass (Finset.sum_nonneg (fun j _ => mul_nonneg (by positivity) measureReal_nonneg)) (Nat.cast_nonneg m) | |
| dsimp [t] at * | |
| nlinarith | |
| have hbound : 2*B β€ (24/c)*(m+1)^2*t := by | |
| have hm : (0 : β) β€ m := Nat.cast_nonneg m | |
| have hpoly : 12*t + m*((m+1)*t) β€ 12*(m+1)^2*t := by | |
| nlinarith [sq_nonneg (m : β)] | |
| have hcc : c*(2*B) β€ c*((24/c)*(m+1)^2*t) := by | |
| field_simp | |
| nlinarith [hB.trans hpoly] | |
| exact (mul_le_mul_iff_rightβ hc).mp hcc | |
| have he (j : β) : 2*dyad j * (β«β» ΞΎ in V j, ENNReal.ofReal (S ΞΎ) βΞ½) = | |
| ENNReal.ofReal (2*(1/2 : β)^(j+1)*(β« ΞΎ in V j, S ΞΎ βΞ½)) := by | |
| rw [β ofReal_integral_eq_lintegral_ofReal hS.restrict (Filter.Eventually.of_forall hS0),dyad] | |
| rw [ENNReal.ofReal_mul (by positivity),ENNReal.ofReal_mul (by norm_num)] | |
| norm_num | |
| simp_rw [he] | |
| rw [β ENNReal.ofReal_sum_of_nonneg (fun j _ => mul_nonneg (by positivity) | |
| (integral_nonneg hS0))] | |
| apply ENNReal.ofReal_le_ofReal | |
| convert hbound using 1 | |
| dsimp [B,t] | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| ring | |
| end DirectionalZeroOne | |
| end OAI | |