File size: 3,774 Bytes
2f887db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Computability.PerfectCompleteness.Construction.OriginalChildScalarAssemblyLemmas
import OAI.Computability.PerfectCompleteness.Reduction.FixedCallBudgetLemmas
import OAI.Computability.PerfectCompleteness.Repetition.CutChildCleanLawLemmas

namespace OAI

section

namespace PerfectCompleteness.FixedCleanRate

open ChildBlockCardinality ProjectedCleanRate

noncomputable section

theorem zeroProbability_lower (branch : Nat → Nat) (height t calls : Nat)
    (rows : Nat → Nat) :
    1 / (bound branch height t calls rows : ℝ) ≤
      zeroProbability branch height t calls rows := by
  let ids : RecursiveSpaces.Slots branch height → Fin t → Nat := fun _ _ => 0
  rw [← raw_zero_probability branch height t calls rows ids,
    CleanTreeFactors.rawLaw_uniform]
  exact cleanLowerBound_le_probability
    (slots := ProjectedCardinality.projectedSlots ids)

theorem conservative_coefficient_le {calls budget cost : Nat}
    (hcalls : calls ≤ budget) (hcost : 0 < cost)
    (branch : Nat → Nat) (height t : Nat) (rows : Nat → Nat) :
    FixedBranching.cleanRate cost (bound branch height t budget rows : ℝ) ≤
      coefficient cost branch height t calls rows := by
  have hbound : (bound branch height t calls rows : ℝ) ≤
      (bound branch height t budget rows : ℝ) := by
    exact_mod_cast FixedCallBudget.child_bound_mono hcalls branch height t rows
  have hpositive : (0 : ℝ) < bound branch height t calls rows :=
    Nat.cast_pos.mpr (shape_bound_pos branch height t calls rows)
  have hzero : 1 / (bound branch height t budget rows : ℝ) ≤
      zeroProbability branch height t calls rows :=
    (one_div_le_one_div_of_le hpositive hbound).trans
      (zeroProbability_lower branch height t calls rows)
  have hden : (0 : ℝ) < 48000 * cost := by
    have : (0 : ℝ) < cost := by exact_mod_cast hcost
    positivity
  calc
    _ = (1 / (bound branch height t budget rows : ℝ)) / (48000 * cost) := by
      unfold FixedBranching.cleanRate
      ring
    _ ≤ _ := div_le_div_of_nonneg_right hzero hden.le

theorem decay_le_conservative {calls budget cost cube : Nat}
    (hcalls : calls ≤ budget) (hcost : 0 < cost) (hcube : 2 ≤ cube)
    (branch : Nat → Nat) (height t : Nat) (rows : Nat → Nat) :
    (1 - coefficient cost branch height t calls rows / (cube : ℝ) ^ 2) ^ (cube ^ 3) ≤
      (1 - FixedBranching.cleanRate cost
        (bound branch height t budget rows : ℝ) / (cube : ℝ) ^ 2) ^ (cube ^ 3) := by
  have hc : (2 : ℝ) ≤ cube := by exact_mod_cast hcube
  have hsquare : (1 : ℝ) ≤ (cube : ℝ) ^ 2 := by nlinarith
  have hden : (0 : ℝ) < (cube : ℝ) ^ 2 := by positivity
  have hcoef := (coefficient_bounds hcost branch height t calls rows).2
  have hbase : 0 ≤ 1 - coefficient cost branch height t calls rows / (cube : ℝ) ^ 2 := by
    have := (div_le_one hden).mpr (hcoef.trans hsquare)
    linarith
  apply pow_le_pow_left₀ hbase
  have h := div_le_div_of_nonneg_right
    (conservative_coefficient_le hcalls hcost branch height t rows) hden.le
  linarith

variable {δ : ℚ} {hδ : 0 < δ} (p : FixedParameters.Parameters δ hδ)

theorem actual_clean_error {calls : Nat} (hcalls : calls ≤ FixedParameters.calls p.plan)
    (height : Nat) :
    (1 - coefficient p.alphabetCost (FixedParameters.branch p) height
      (FixedRows.sourceLength p.plan hδ) calls (FixedRows.rows p.plan) /
        (p.cubeSize height : ℝ) ^ 2) ^ (p.cubeSize height ^ 3) < p.accuracy := by
  have hdecay := decay_le_conservative hcalls p.alphabetCost_pos
    (p.cube_errors height).1 (FixedParameters.branch p) height
    (FixedRows.sourceLength p.plan hδ) (FixedRows.rows p.plan)
  exact hdecay.trans_lt (p.cube_errors height).2.2.2.2

end
end PerfectCompleteness.FixedCleanRate

end

end OAI