introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.32 kB
import Mathlib
import OAI.Probability.CriticalPercolation.Modular.WeightedCauchy
import OAI.Probability.CriticalPercolation.ProductMeasure.QueryMartingale
namespace OAI
section
section
noncomputable section
namespace CriticalPercolation.FiniteProduct
open scoped Classical
variable {E : Type*} [Fintype E]
lemma expect_abs_sq_le (w : E β†’ Prop β†’ ℝ) (hw : βˆ€ e, βˆ‘ b, w e b = 1)
(hn : βˆ€ e b, 0≀w e b) (f : (E β†’ Prop) β†’ ℝ) :
(expect w (fun Ο‰ => |f Ο‰|))^2 ≀ expect w (fun Ο‰ => (f Ο‰)^2) := by
have h := FiniteEntropy.weighted_cauchy (density w) (fun Ο‰ => |f Ο‰|) (fun _ => 1)
(fun Ο‰ => density_nonneg hn Ο‰)
simp only [mul_one,one_pow,sq_abs] at h
have hw1 : βˆ‘ Ο‰, density w Ο‰ = 1 := by
simpa only [expect,mul_one] using expect_const w hw (1:ℝ)
simpa only [hw1,mul_one,expect] using h
lemma expect_abs_le_of_second_le (w : E β†’ Prop β†’ ℝ) (hw : βˆ€ e, βˆ‘ b, w e b = 1)
(hn : βˆ€ e b, 0≀w e b) (f : (E β†’ Prop) β†’ ℝ) {a : ℝ} (ha : 0≀a)
(hf : expect w (fun Ο‰ => (f Ο‰)^2) ≀ a^2) : expect w (fun Ο‰ => |f Ο‰|) ≀ a := by
nlinarith [expect_abs_sq_le w hw hn f]
end CriticalPercolation.FiniteProduct
namespace CriticalPercolation.SearchTree
open scoped Classical
open FiniteProduct
variable {E R : Type*}
lemma queryCount_eq_reads_length (t : SearchTree E R) (Ο‰ : E β†’ Prop) :
t.queryCount Ο‰ = (t.reads (fun e => decide (Ο‰ e))).length := by
induction t with
| done r => rfl
| ask e l r hl hr =>
by_cases he : Ο‰ e <;> simp [queryCount,reads,he,hl,hr,Nat.add_comm]
lemma centeredSum_eq_zero_of_count (t : SearchTree E R) (Ο‰ : E β†’ Prop)
(h : t.queryCount Ο‰ = 0) (p : ℝ) : t.centeredSum p Ο‰ = 0 := by
cases t with
| done r => rfl
| ask e l r => simp [queryCount] at h
variable [Fintype E] [DecidableEq E]
lemma queryCount_le_card (t : SearchTree E R) (used : Finset E) (ht : t.Valid used)
(Ο‰ : E β†’ Prop) : t.queryCount Ο‰ ≀ Fintype.card E := by
rw [queryCount_eq_reads_length]
exact List.Nodup.length_le_card (t.reads_nodup used ht _)
lemma band_centered_bound (t : SearchTree E R) (used : Finset E) (ht : t.Valid used)
(p : ℝ) (hp : p ∈ Set.Icc 0 1) (w : E β†’ Prop β†’ ℝ)
(hw : βˆ€ e, βˆ‘ b, w e b = 1) (hn : βˆ€ e b, 0≀w e b)
(hf : LazyDFS.Fresh w p used) (k : β„•) :
expect w (fun Ο‰ => if 4^k ≀ t.queryCount Ο‰ ∧ t.queryCount Ο‰ < 4^(k+1)
then |t.centeredSum p Ο‰| else 0) ≀ (2:ℝ)^(k+1) := by
calc
_ ≀ expect w (fun Ο‰ => |(t.truncate (4^(k+1))).centeredSum p Ο‰|) := by
apply expect_mono hn
intro Ο‰
split_ifs with h
Β· rw [t.centeredSum_truncate_eq _ Ο‰ h.2.le p]
Β· exact abs_nonneg _
_ ≀ (2:ℝ)^(k+1) := by
apply expect_abs_le_of_second_le w hw hn _ (by positivity)
have ht' := t.truncated_second_le used ht p hp w hw hn hf (4^(k+1))
have hpp : p*(1-p) ≀ 1 := by nlinarith [hp.2,sq_nonneg p]
have hN : (4^(k+1) : ℝ) = ((2:ℝ)^(k+1))^2 := by
rw [← pow_mul, mul_comm (k+1) 2, pow_mul]
norm_num
calc _ ≀ p*(1-p)*(4^(k+1) : β„•) := ht'
_ ≀ (4^(k+1) : ℝ) := by
simpa using mul_le_mul_of_nonneg_right hpp (by positivity : 0≀(4^(k+1):ℝ))
_ = _ := hN
end CriticalPercolation.SearchTree
end
end
end
end OAI