File size: 3,321 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | 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
|