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