math / data /lean /OAI /Probability /Contingency /ChildLogConcavity.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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