File size: 5,664 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import OAI.Combinatorics.EditApproximation.Geometry.CellGroupSelection
import OAI.Combinatorics.EditApproximation.Refinement.ComputedGroupNumerical
import OAI.Combinatorics.EditApproximation.Refinement.ComputedBandSpacing

namespace OAI

/-! One actual whole cell has simultaneous gamma*b accuracy with failure at most H^-4. -/

namespace EditApproximation

open MeasureTheory ProbabilityTheory

theorem computed_cellGroupEstimate_failure {Ξ± : Type*} (source target : List Ξ±)
    (N : β„•) (hN : 0 < N) (hell : 1764 ≀ inputSmallLog N)
    {M P b Q thetaExponent T : β„•} [NeZero M]
    [MeasurableSpace (Fin M)] [MeasurableSingletonClass (Fin M)]
    (hM : 0 < M) (hMeq : M = (integerParameters N).M)
    (hPeq : P = (integerParameters N).P) (eb : β„•) (hbeq : b = 2 ^ eb)
    (hQeq : Q = inputSmallLog N ^ 80) (hthetaeq : thetaExponent = 40 * smallLogExponent N)
    (parent : TargetInterval source.length) (a : β„š)
    (parentInitial : TargetInterval target.length β†’ β„š)
    (child initial value : Fin M β†’ TargetInterval target.length β†’ β„š) (cell : β„• Γ— β„•)
    (scales : Fin T β†’ β„š) (count : Fin T β†’ β„•)
    (hscales : List.ofFn scales = groupDyadicScales M b (inputSmallLog N))
    (hcount : βˆ€ scale, count scale = groupSampleCount M Q b (scales scale))
    (hspatial : βˆ€ i s t, initial i s ≀ initial i t +
      (32 * inputSmallLog N : β„š) * targetEndpointDistance s t)
    (hvalue : βˆ€ i s, 0 ≀ value i s ∧ value i s ≀ initial i s)
    (bernstein : βˆ€ scale : Fin T, FiniteBernsteinInput
      (Measure.pi fun _ : Fin (count scale) => (PMF.uniformOfFintype (Fin M)).toMeasure)) :
    let members := cellUnskippedBands source target parent b P (inputSmallLog N) thetaExponent
      (rationalParameters (inputSmallLog N)).tau a parentInitial child initial cell
    (groupSharedDrawLaw count).real
      {draw | βˆƒ member ∈ members, ((rationalParameters (inputSmallLog N)).gamma : ℝ) * b <
        |((unskippedGroupEstimate scales count value member draw -
          rationalEndpointActionValue member.center member.rounded value : β„š) : ℝ)|} ≀
      1 / (inputHeight N : ℝ) ^ 4 := by
  let ell := inputSmallLog N
  let members := cellUnskippedBands source target parent b P ell thetaExponent
    (rationalParameters ell).tau a parentInitial child initial cell
  let deviation : β„š := 1 / (2 * (ell : β„š) ^ 21)
  let ΞΌ := groupSharedDrawLaw (M := M) count
  let : IsProbabilityMeasure ΞΌ := by dsimp only [ΞΌ]; infer_instance
  have hellQ : (2 : β„š) ≀ ell := by exact_mod_cast (show 2 ≀ ell from by omega)
  have hellpos : (0 : β„š) < ell := by linarith only [hellQ]
  have hb : 0 < b := hbeq β–Έ Nat.two_pow_pos eb
  have hQ : 0 < Q := by rw [hQeq]; exact pow_pos (by omega : 0 < inputSmallLog N) 80
  have htheta : (2 : β„š) ^ (-(thetaExponent : β„€)) = 1 / (ell : β„š) ^ 40 := by
    rw [hthetaeq]
    exact (computed_theta_dyadic N).symm
  have hsmall : 2 * (32 * ell : β„š) * (2 : β„š) ^ (-(thetaExponent : β„€)) ≀ 1 := by
    rw [htheta]
    have h := (basic_band_small_constants hellQ).2.2.2.2
    convert h using 1
    ring
  have hdev : 0 < deviation := by dsimp only [deviation]; positivity
  have htail := unskippedGroupEstimate_failure scales count Q hscales hcount value members hM hQ hb
    hellpos (32 * ell) (mul_nonneg (by norm_num) (Nat.cast_nonneg _)) hsmall hspatial hvalue deviation hdev bernstein
  have hT : T ≀ 2 * ell := by
    have hlength := congrArg List.length hscales
    simp only [List.length_ofFn] at hlength
    rw [hlength, hMeq, hbeq]
    exact computed_group_scale_count N eb hN (by omega)
  have hTQ : (T : β„š) ≀ 2 * ell := by exact_mod_cast hT
  have hbudget : (T : β„š) * deviation ≀ (rationalParameters ell).gamma := by
    have h := mul_le_mul_of_nonneg_right hTQ hdev.le
    have hid : (2 * ell : β„š) * deviation = (rationalParameters ell).gamma := by
      dsimp only [deviation, rationalParameters]
      field_simp
    exact h.trans_eq hid
  have hbudgetR : (T : ℝ) * (deviation : ℝ) * b ≀
      ((rationalParameters ell).gamma : ℝ) * b := by
    have h := mul_le_mul_of_nonneg_right hbudget (Nat.cast_nonneg (Ξ± := β„š) b)
    exact_mod_cast h
  have hsubset : {draw | βˆƒ member ∈ members, ((rationalParameters ell).gamma : ℝ) * b <
        |((unskippedGroupEstimate scales count value member draw -
          rationalEndpointActionValue member.center member.rounded value : β„š) : ℝ)|} βŠ†
      {draw | βˆƒ member ∈ members, (T : ℝ) * (deviation : ℝ) * b <
        |((unskippedGroupEstimate scales count value member draw -
          rationalEndpointActionValue member.center member.rounded value : β„š) : ℝ)|} := by
    rintro draw ⟨member, hm, he⟩
    exact ⟨member, hm, hbudgetR.trans_lt he⟩
  have hmembers : members.length ≀ ((integerParameters N).P + 1) ^ 2 := by
    rw [← hPeq]
    exact cellUnskippedBands_length_le source target parent b P ell thetaExponent _ a parentInitial
      child initial cell ⟨eb, hbeq⟩ ⟨_, hPeq.trans (computed_P_dyadic N)⟩
  have hnumerical := computed_group_union_failure N eb members.length hN hell hmembers
  dsimp only at hnumerical
  have hTeq : T = (groupDyadicScales (integerParameters N).M (2 ^ eb) ell).length := by
    have hlength := congrArg List.length hscales
    simpa only [List.length_ofFn, hMeq, hbeq] using hlength
  change ΞΌ.real _ ≀ _
  apply (measureReal_mono hsubset (measure_ne_top ΞΌ _)).trans
  apply htail.trans
  rw [hQeq, hTeq]
  simpa only [deviation, ell, Rat.cast_div, Rat.cast_mul, Rat.cast_ofNat, Rat.cast_pow,
    Rat.cast_natCast, Rat.cast_one, Nat.cast_pow, neg_mul, neg_div] using hnumerical

end EditApproximation

end OAI