Download data/lean/OAI/Probability/Contingency/DenseAnalytic.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 29.2 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Contingency/DenseAnalytic.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Contingency/DenseAnalytic.lean
-
curl -L -o DenseAnalytic.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Contingency/DenseAnalytic.lean
29.2 kB
| 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<t) (ht1 : t<1) : boxUnion S β boxUnion (mixBoxes S T (1-t) t) := by | |
| intro x hx | |
| apply (mem_mixBoxes S T (1-t) t (by linarith) ht x).mpr | |
| refine β¨x,hx,x,hsub hx,?_β© | |
| ext i | |
| simp only [Pi.add_apply,Pi.smul_apply,smul_eq_mul] | |
| ring | |
| theorem mass_gain (S T : Finset (OpenBox q)) (F : GoodWeight q) | |
| (hsub : boxUnion S β boxUnion T) (hS : (boxUnion S).Nonempty) | |
| (hsmall : 2*(β« x in boxUnion S,F.f x) β€ β« x in boxUnion T,F.f x) | |
| (t : β) (ht : 0<t) (ht1 : t<1) | |
| (hc : β x y,F.f x^(1-t)*F.f y^t β€ F.f ((1-t) β’ x+t β’ y)) : | |
| t*Real.log 2*(β« x in boxUnion S,F.f x) β€ | |
| β« x in boxUnion (mixBoxes S T (1-t) t) \ boxUnion S,F.f x := by | |
| let m := β« x in boxUnion S,F.f x | |
| have hm : 0 < m := F.integral_pos S hS | |
| have hinter := logconcave_interpolation S T F (1-t) t (by linarith) ht (by ring) hc | |
| have hlower : (2:β)^t*m β€ β« x in boxUnion (mixBoxes S T (1-t) t),F.f x := by | |
| calc | |
| _ = m^(1-t)*(2*m)^t := by | |
| rw [Real.mul_rpow (by norm_num : (0:β) β€ 2) hm.le] | |
| rw [mul_left_comm,β Real.rpow_add hm] | |
| simp | |
| _ β€ m^(1-t)*(β« x in boxUnion T,F.f x)^t := | |
| mul_le_mul_of_nonneg_left (Real.rpow_le_rpow (by positivity) hsmall ht.le) (Real.rpow_nonneg hm.le _) | |
| _ β€ _ := hinter | |
| have hexp : 1+t*Real.log 2 β€ (2:β)^t := by | |
| rw [Real.rpow_def_of_pos (by norm_num : (0:β)<2)] | |
| nlinarith only [Real.add_one_le_exp (Real.log 2*t)] | |
| rw [setIntegral_sdiff (boxUnion_measurable S) (F.integrable _) (mix_contains S T hsub t ht ht1)] | |
| have hh := mul_le_mul_of_nonneg_right hexp hm.le | |
| dsimp [m] at hh hlower | |
| nlinarith only [hh,hlower] | |
| end | |
| end Contingency.Interpolation | |
| open Set MeasureTheory | |
| open scoped Pointwise BigOperators | |
| namespace Contingency.Dense | |
| noncomputable section | |
| variable {q : β} {I : Type*} [Fintype I] | |
| def region (f : I β (Fin q β β) β β) (Ο : β) : Set (Fin q β β) := | |
| {x | β i,Ο β€ f i x} | |
| theorem region_measurable (f : I β (Fin q β β) β β) (hf : β i,Continuous (f i)) (Ο : β) : | |
| MeasurableSet (region f Ο) := by | |
| have he : region f Ο=β i,{x | Ο β€ f i x} := by ext x; simp [region] | |
| rw [he] | |
| exact MeasurableSet.iInter fun i => 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<s) (hu : β i,s β€ f i u) (hg : 0 β€ Ξ³) : | |
| region f (-Ξ³) β AffineMap.homothety u (1+Ξ³/s) '' region f 0 := by | |
| intro x hx | |
| let r := 1+Ξ³/s | |
| have hr : 0<r := by dsimp [r]; positivity | |
| let z := AffineMap.homothety u (1/r) x | |
| refine β¨z,?_,?_β© | |
| Β· intro i | |
| dsimp [z] | |
| rw [homothety_affine f hf] | |
| have hr1 : 1 β€ r := by | |
| dsimp [r] | |
| have hh : 0 β€ Ξ³/s := by positivity | |
| linarith | |
| have hcoef : 0 β€ 1-1/r := by have := (div_le_one hr).mpr hr1; linarith | |
| have h1 := mul_le_mul_of_nonneg_left (hx i) (show 0 β€ 1/r by positivity) | |
| have h2 := mul_le_mul_of_nonneg_left (hu i) hcoef | |
| have he : (1/r)*(-Ξ³)+(1-1/r)*s=0 := by dsimp [r]; field_simp; ring | |
| linarith only [h1,h2,he] | |
| Β· ext j | |
| simp only [z,AffineMap.homothety_apply,vadd_eq_add,vsub_eq_sub,Pi.add_apply,Pi.sub_apply,Pi.smul_apply,smul_eq_mul] | |
| change r*((1/r*(x j-u j)+u j)-u j)+u j=x j | |
| field_simp | |
| ring | |
| theorem homothety_volume (u : Fin q β β) (r : β) (hr : 0 β€ r) (S : Set (Fin q β β)) : | |
| volume (AffineMap.homothety u r '' S)=ENNReal.ofReal (r^q)*volume S := by | |
| rw [Measure.addHaar_image_homothety] | |
| simp [abs_of_nonneg (pow_nonneg hr _)] | |
| omit [Fintype I] in | |
| theorem inner_volume (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) : | |
| ENNReal.ofReal ((1-Ξ±)^q)*volume (region f 0) β€ volume (region f (Ξ±*s)) := by | |
| rw [β homothety_volume u (1-Ξ±) (by linarith)] | |
| exact measure_mono (inner_image_subset f hf u s Ξ± hu ha ha1) | |
| omit [Fintype I] in | |
| theorem relaxed_volume (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<s) (hu : β i,s β€ f i u) (hg : 0 β€ Ξ³) : | |
| volume (region f (-Ξ³)) β€ ENNReal.ofReal (Real.exp ((q:β)*Ξ³/s))*volume (region f 0) := by | |
| have hh := measure_mono (ΞΌ:=volume) (relaxed_subset_image f hf u s Ξ³ hs hu hg) | |
| rw [homothety_volume u (1+Ξ³/s) (by positivity)] at hh | |
| apply hh.trans | |
| gcongr | |
| calc | |
| (1+Ξ³/s)^q β€ (Real.exp (Ξ³/s))^q := pow_le_pow_leftβ (by positivity) (by linarith only [Real.add_one_le_exp (Ξ³/s)]) q | |
| _ = _ := by rw [β Real.exp_nat_mul]; congr 1; ring | |
| end | |
| end Contingency.Dense | |
| open Set MeasureTheory | |
| open scoped Pointwise BigOperators | |
| namespace Contingency.Dense | |
| noncomputable section | |
| variable {a c q : β} | |
| def constraints (e : Fin q β Fin aΓFin c) (R : Fin (a+1) β β) (P : Fin (c+1) β β) | |
| (w : Fin a β Fin c β β) (s : Fin (a+1)ΓFin (c+1)) (x : Fin q β β) : β := | |
| normalized R P w (fun s => 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<B) (hd : 0 β€ d) (hdim : (a*c:β) β€ d) | |
| (hR : β i,0<R i) (hP : β j,0<P j) | |
| (hRmax : β i,R i β€ R (Fin.last a)) (hPmax : β j,P j β€ P (Fin.last c)) | |
| (hw0 : β i j,0 β€ w i j) (hw : β i j,w i j β€ scale R P i.castSucc j.castSucc/B) | |
| (x y : Fin q β β) (i) : | |
| |constraints e R P w i x-constraints e R P w i y| β€ d/B*βx-yβ := by | |
| apply (normalized_lipschitz R P w B d hB hdim hR hP hRmax hPmax hw0 hw _ _ _ _).trans | |
| apply mul_le_mul_of_nonneg_left _ (div_nonneg hd hB.le) | |
| apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr | |
| intro s | |
| exact norm_le_pi_norm (x-y) (e.symm s) | |
| theorem region_bounded (e : Fin q β Fin aΓFin c) (R : Fin (a+1) β β) (P : Fin (c+1) β β) | |
| (w : Fin a β Fin c β β) (B : β) (hB : 0<B) | |
| (hR : β i,0<R i) (hP : β j,0<P j) (heq : (β i,R i)=β j,P j) | |
| (hw : β i j,scale R P i.castSucc j.castSucc/(2*B) β€ w i j) : | |
| region (constraints e R P w) 0 β Set.pi Set.univ (fun _ => 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<B) | |
| (hR : β i,0<R i) (hP : β j,0<P j) (heq : (β i,R i)=β j,P j) | |
| (hw : β i j,scale R P i.castSucc j.castSucc/(2*B) β€ w i j) : | |
| volume (region (constraints e R P w) 0)<β€ := by | |
| apply (measure_mono (region_bounded e R P w B hB hR hP heq hw)).trans_lt | |
| exact (isCompact_univ_pi fun _ => isCompact_Icc).measure_lt_top | |
| theorem region_interior (e : Fin q β Fin aΓFin c) (d : β) (hd : 0<d) | |
| (R : Fin (a+1) β β) (P : Fin (c+1) β β) (w : Fin a β Fin c β β) | |
| (hR : β i,0<R i) (hP : β j,0<P j) (heq : (β i,R i)=β j,P j) | |
| (ha : (a+1:β) β€ d) (hc : (c+1:β) β€ d) (hw : β i j,0<w i j) : | |
| β u : Fin q β β,β i,1/(2*d) β€ constraints e R P w i u := by | |
| obtain β¨u,huβ© := interior_point d hd R P w hR hP heq ha hc hw | |
| refine β¨fun i => 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<d := by linarith | |
| let Ξ± := 4*d^2/d^8 | |
| have ha : 0 β€ Ξ± := by dsimp [Ξ±]; positivity | |
| have had : Ξ±*d β€ 1/2 := by | |
| have he : Ξ±*d=4/d^5 := by dsimp [Ξ±]; field_simp | |
| rw [he] | |
| apply (div_le_iffβ (by positivity)).mpr | |
| have hp : (2:β)^5 β€ d^5 := pow_le_pow_leftβ (by norm_num) hd 5 | |
| norm_num at hp | |
| linarith | |
| have ha1 : Ξ± β€ 1 := by nlinarith | |
| have hpow : 1/2 β€ (1-Ξ±)^q := by | |
| have hh := one_add_mul_le_pow (a := -Ξ±) (by linarith) q | |
| have hq' := mul_le_mul_of_nonneg_right hq ha | |
| have he : 1+-Ξ±=1-Ξ± := by ring | |
| rw [he] at hh | |
| nlinarith only [hh,hq',had] | |
| have hh := inner_volume f hf u (1/(2*d)) Ξ± hu ha ha1 | |
| have he : Ξ±*(1/(2*d))=2*d/d^8 := by dsimp [Ξ±]; field_simp; ring | |
| rw [he] at hh | |
| have hlo : (1/2:ENNReal) β€ ENNReal.ofReal ((1-Ξ±)^q) := by | |
| have ht := ENNReal.ofReal_le_ofReal hpow | |
| simpa only [ENNReal.ofReal_div_of_pos (by norm_num : (0:β)<2),ENNReal.ofReal_one,ENNReal.ofReal_ofNat] using ht | |
| calc | |
| _ β€ ENNReal.ofReal ((1-Ξ±)^q)*volume (region f 0) := by gcongr | |
| _ β€ _ := hh | |
| theorem relaxed_volume_dense (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 : 0<d) (hq : (q:β) β€ d) (u : Fin q β β) | |
| (hu : β i,1/(2*d) β€ f i u) (Ξ³ : β) (hg : 0 β€ Ξ³) : | |
| volume (region f (-Ξ³)) β€ ENNReal.ofReal (Real.exp (2*d^2*Ξ³))*volume (region f 0) := by | |
| apply (relaxed_volume f hf u (1/(2*d)) Ξ³ (by positivity) hu hg).trans | |
| gcongr | |
| have he : (q:β)*Ξ³/(1/(2*d))=(q:β)*(2*d*Ξ³) := by field_simp | |
| rw [he] | |
| have hh := mul_le_mul_of_nonneg_right hq (show 0 β€ 2*d*Ξ³ by positivity) | |
| nlinarith only [hh] | |
| end | |
| end Contingency.Dense | |
| open Set MeasureTheory | |
| open scoped BigOperators | |
| namespace Contingency.Dense | |
| noncomputable section | |
| variable {q : β} | |
| theorem half_times_four_thirds : (1/2:ENNReal)*(4/3)=2/3 := by | |
| have h : (1/2:NNReal)*(4/3)=2/3 := 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_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<A) (S : Set (Fin q β β)) | |
| (V : ENNReal) (hvol : β j : β, | |
| volume ({x | p x < ((j:β)+1)/A} β© S) β€ (4/3:ENNReal)^(j+1)*V) : | |
| (β«β» x in S,ENNReal.ofReal ((2:β)^(-A*p x))) β€ 4*V := by | |
| let T (j : β) := {x | p x < ((j:β)+1)/A} | |
| have hm (j : β) : MeasurableSet (T j) := measurableSet_lt hp measurable_const | |
| let f (j : β) := (T j).indicator (fun _ => (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<d := by linarith | |
| let Ξ± := 2/d^2 | |
| let Ξ² := 2/d^5 | |
| have hΞ± : Ξ± β€ 1/8 := by | |
| dsimp [Ξ±] | |
| apply (div_le_iffβ (by positivity)).mpr | |
| nlinarith [sq_nonneg (d-4)] | |
| have hΞ² : Ξ² β€ 1/8 := by | |
| dsimp [Ξ²] | |
| apply (div_le_iffβ (by positivity)).mpr | |
| have hh := pow_le_pow_leftβ (by norm_num : (0:β) β€ 4) hd 5 | |
| norm_num at hh | |
| linarith | |
| have he : 2*d^2*(d/d^8+((j:β)+1)/d^4)=Ξ²+((j:β)+1)*Ξ± := by | |
| dsimp [Ξ±,Ξ²] | |
| field_simp | |
| have hΞ²0 : 0 β€ Ξ² := by dsimp [Ξ²]; positivity | |
| calc | |
| _ = Real.exp (Ξ²+((j:β)+1)*Ξ±) := by rw [he] | |
| _ β€ Real.exp (((j:β)+1)*(Ξ±+Ξ²)) := by | |
| apply Real.exp_le_exp.mpr | |
| nlinarith only [mul_nonneg (show 0 β€ (j:β) by positivity) hΞ²0] | |
| _ = Real.exp (Ξ±+Ξ²)^(j+1) := by rw [β Real.exp_nat_mul]; congr 1; push_cast; ring | |
| _ β€ _ := pow_le_pow_leftβ (Real.exp_pos _).le (exp_quarter_bound _ (by linarith)) _ | |
| end | |
| end Contingency.Dense | |
| open Set | |
| namespace Contingency.Grid | |
| noncomputable section | |
| variable {q : β} | |
| def inside (v : Fin q β β) (x : Fin q β β) : Prop := | |
| β i,(v i:β)<x i β§ x i<(v i:β)+1 | |
| def path (v w : Fin q β β) (n : β) : Fin q β β := | |
| fun i => if i.val<n then w i else v i | |
| @[simp] theorem path_zero (v w : Fin q β β) : path v w 0=v := by ext i; simp [path] | |
| @[simp] theorem path_end (v w : Fin q β β) : path v w q=w := by ext i; simp [path,i.isLt] | |
| theorem exists_label_step {Ξ± : Type*} (f : β β Ξ±) (n : β) (h : f 0 β f n) : | |
| β k,k<n β§ f k β f (k+1) := by | |
| induction n with | |
| | zero => 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:β)<x β§ x<(v:β)+1) (hz : (w:β)<z β§ z<(w:β)+1) | |
| (hclose : |x-z|<r) (hr : r β€ 1) (hne : v β w) : | |
| v+1=w β¨ w+1=v := by | |
| have hc := abs_lt.mp hclose | |
| have hvw : (v:β)<(w:β)+2 := by linarith | |
| have hwv : (w:β)<(v:β)+2 := by linarith | |
| have hvw' : v<w+2 := by exact_mod_cast hvw | |
| have hwv' : w<v+2 := by exact_mod_cast hwv | |
| omega | |
| theorem cut_face_close (v w : Fin q β β) (label : (Fin q β β) β Bool) | |
| (hl : label v β label w) (x z : Fin q β β) (hx : inside v x) (hz : inside w z) | |
| (r : β) (hr : r β€ 1) (hc : β i,|x i-z i|<r) : | |
| β u u' : Fin q β β,β i : Fin q, | |
| neighbors u u' i β§ label u β label u' β§ | |
| (β j,u j=v j β¨ u j=w j) β§ (β j,u' j=v j β¨ u' j=w j) β§ | |
| β pβface u u' i,β j,|p j-z j|<r := by | |
| have hp : label (path v w 0) β label (path v w q) := by simpa using hl | |
| obtain β¨k,hk,hstepβ© := exists_label_step (fun n => 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<k then z j else x j | |
| refine β¨path v w k,path v w (k+1),i,?_,hstep,?_,?_,p,?_,?_β© | |
| Β· exact β¨by simpa only [hiv,hiw] using hn,hjβ© | |
| Β· intro j; simp only [path]; split_ifs <;> 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<x i β§ x i<(K:β) := by | |
| simp [cube,Interpolation.OpenBox.carrier] | |
| def boxes (V : Finset (Vertex q K)) : Finset (Interpolation.OpenBox q) := by classical exact V.image bin | |
| @[simp] theorem mem_boxes (V : Finset (Vertex q K)) (x : Fin q β β) : | |
| xβInterpolation.boxUnion (boxes V) β β vβV,inside (corner v) x := by | |
| classical | |
| simp [Interpolation.boxUnion,boxes,mem_bin] | |
| theorem bins_subset_cube (V : Finset (Vertex q K)) : Interpolation.boxUnion (boxes V) β (cube q K).carrier := by | |
| intro x hx | |
| obtain β¨v,_,hvβ© := (mem_boxes V x).mp hx | |
| apply (mem_cube x).mpr | |
| intro i | |
| have hh : (v i:β)+1 β€ (K:β) := by exact_mod_cast (v i).isLt | |
| exact β¨lt_of_le_of_lt (Nat.cast_nonneg _) (hv i).1,lt_of_lt_of_le (hv i).2 hhβ© | |
| theorem bin_unique (v w : Vertex q K) (x : Fin q β β) | |
| (hv : inside (corner v) x) (hw : inside (corner w) x) : v=w := by | |
| ext i | |
| apply le_antisymm | |
| Β· by_contra hn | |
| have hn' : (w i:β)+1 β€ (v i:β) := by omega | |
| have hh : (w i:β)+1 β€ (v i:β) := by exact_mod_cast hn' | |
| have h1 := (hv i).1; have h2 := (hw i).2 | |
| dsimp [corner] at h1 h2 | |
| linarith | |
| Β· by_contra hn | |
| have hn' : (v i:β)+1 β€ (w i:β) := by omega | |
| have hh : (v i:β)+1 β€ (w i:β) := by exact_mod_cast hn' | |
| have h1 := (hw i).1; have h2 := (hv i).2 | |
| dsimp [corner] at h1 h2 | |
| linarith | |
| theorem bins_disjoint : Pairwise (fun v w : Vertex q K => 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ββ<K := by | |
| have hh := (Nat.floor_le (hc i).1.le).trans_lt (hc i).2 | |
| exact_mod_cast hh | |
| let v : Vertex q K := fun 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|<r) : | |
| zβ(faceBox v w i r).carrier := by | |
| intro j _ | |
| have hh := abs_lt.mp (hc j) | |
| by_cases hj : j=i | |
| Β· subst j | |
| simp only [faceBox,Set.mem_Ioo,ite_true] | |
| have he := hp.1 | |
| dsimp [corner] at he | |
| constructor <;> 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|<r) : | |
| β u u' : Vertex q K,β i : Fin q,neighbors (corner u) (corner u') i β§ | |
| (uβV β§ u'βV β¨ uβV β§ u'βV) β§ zβ(faceBox u u' i r).carrier := by | |
| classical | |
| let lift (a : Fin q β β) (ha : β i,a i<K) : Vertex q K := fun i => β¨a i,ha iβ© | |
| let label (a : Fin q β β) : Bool := if ha : β i,a i<K then decide (lift a haβV) else false | |
| have hvb : β i,corner v i<K := fun i => (v i).isLt | |
| have hwb : β i,corner w i<K := fun 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<K := fun j => by rcases hu j with h | h <;> rw [h]; exact hvb j; exact hwb j | |
| have hu'b : β j,u' j<K := fun 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 | |