Download data/lean/OAI/Probability/Contingency/ChildLogConcavity.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 24.2 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Contingency/ChildLogConcavity.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Contingency/ChildLogConcavity.lean
-
curl -L -o ChildLogConcavity.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Contingency/ChildLogConcavity.lean
24.2 kB
| 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<K := by linarith | |
| apply (mul_le_mul_iff_leftβ hk0).mp | |
| have he : (1-1/K)*C.normSq f*K=(K-1)*C.normSq f := by field_simp [hk0.ne'] | |
| change C.inner f (C.step f)*K β€ _ | |
| rw [he] | |
| nlinarith only [h] | |
| theorem gap_normSq (K : β) (hK : 1β€K) | |
| (hvar : β f : V β β, C.variance f β€ K*C.energy f) | |
| (f : V β β) (hf : C.mean f=0) : | |
| C.normSq (C.step f) β€ (1-1/K)^2*C.normSq f := by | |
| have hr : 0β€1-1/K := by | |
| have : 1/Kβ€(1:β) := (div_le_one (by linarith)).mpr hK | |
| linarith | |
| have hg : C.mean (C.step f)=0 := by rw [C.step_mean,hf] | |
| have hb := C.step_cauchy f (C.step f) | |
| rw [C.step_selfadjoint,C.inner_self] at hb | |
| have hp := mul_le_mul (C.gap_inner K hK hvar f hf) | |
| (C.gap_inner K hK hvar (C.step f) hg) (C.step_positive (C.step f)) | |
| (mul_nonneg hr (C.normSq_nonneg f)) | |
| have hn := C.normSq_nonneg (C.step f) | |
| by_cases hz : C.normSq (C.step f)=0 | |
| Β· rw [hz]; exact mul_nonneg (sq_nonneg _) (C.normSq_nonneg f) | |
| Β· have hh : 0<C.normSq (C.step f) := lt_of_le_of_ne hn (Ne.symm hz) | |
| nlinarith only [hb,hp,hh] | |
| def iterate : β β (V β β) β V β β | |
| | 0, f => 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<K := by linarith | |
| have hr : 0β€1-1/K := by | |
| have : 1/Kβ€(1:β) := (div_le_one hk0).mpr hK | |
| linarith | |
| have he := pow_le_pow_leftβ hr (Real.one_sub_le_exp_neg (1/K)) (2*t) | |
| have hexp : Real.exp (-(1/K))^(2*t)=(Real.exp (-(t:β)/K))^2 := by | |
| rw [β Real.exp_nat_mul,β Real.exp_nat_mul] | |
| congr 1 | |
| push_cast | |
| ring | |
| rw [hexp] at he | |
| have hn := C.iterate_normSq K hK hvar t (C.initialDensity x) (C.density_mean x) | |
| have hp := mul_le_mul_of_nonneg_right he (C.normSq_nonneg (C.initialDensity x)) | |
| rw [C.density_normSq] at hn hp | |
| have hΟ : C.Ο xβ€1 := by | |
| calc | |
| _ β€ β y, C.Ο y := Finset.single_le_sum (fun y _ => (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<pmin) (hmin : β x, pminβ€C.Ο x) | |
| (t : β) (x : V) : | |
| C.tv t x β€ pminβ»ΒΉ*Real.exp (-(t:β)/K) := by | |
| apply (C.mixing_bound K hK hvar t x).trans | |
| apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le | |
| exact inv_antiβ hpmin (hmin x) | |
| end | |
| end Contingency.FiniteChain.Chain | |
| end | |
| end OAI | |