File size: 5,425 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
103
104
105
106
107
108
109
110
111
112
113
114
import OAI.NumberTheory.Ostmann.Arithmetic.VariableModulusSupport

namespace OAI

/-! # The numerical rate after the actual arithmetic frequency sum -/

namespace Ostmann
open Filter

/-- The divisor constant is chosen uniformly before the history-dependent
modulus. This is the numerical estimate used by the same-assignment norm. -/
theorem arithmetic_frequency_budget_rate (n : β„•) (K C Ξ΅ : ℝ) (hC : 0 ≀ C) (hΞ΅ : 0 < Ξ΅) :
    βˆ€αΆ  m : ℝ in atTop, βˆƒ D : ℝ, 0 ≀ D ∧
      (βˆ€ q : β„•, q β‰  0 β†’ (q : ℝ) ≀ Real.exp (2 * C * m) β†’ (q.divisors.card : ℝ) ≀ D) ∧
      βˆ€ N V : β„•, βˆ€ Ξ” : ℝ, (N : ℝ) ≀ Real.exp (C * m) β†’
      (V : ℝ) ≀ Real.exp (Ξ” + Real.sqrt (4 * m)) β†’
      Real.exp (-(2 ^ n : β„•) * Ξ” + K) *
        ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) *
          (2 * (V : ℝ)) ^ (2 * 2 ^ n)) ≀
        Real.exp ((2 ^ n : β„•) * Ξ” + Ξ΅ * m) := by
  let r : β„• := 2 ^ n
  have hr : (0 : ℝ) < r := by exact_mod_cast (Nat.two_pow_pos n)
  let Ξ΄ : ℝ := Ξ΅ / (2 * r)
  have hΞ΄ : 0 < Ξ΄ := div_pos hΞ΅ (by positivity)
  have hΞ΄r : Ξ΄ * r = Ξ΅ / 2 := by dsimp [Ξ΄]; field_simp
  obtain ⟨M, hM⟩ := leaf_frequency_budget_sublinear r K (Ρ / 8) (by positivity)
  filter_upwards [frequency_budget_subexponential C Ξ΄ hC hΞ΄,
    eventually_ge_atTop (M / 4), eventually_ge_atTop (0 : ℝ)] with m hrate hm hm0
  obtain ⟨D, hD, hdiv, hcost⟩ := hrate
  refine ⟨D, hD, hdiv, ?_⟩
  intro N V Ξ” hN hV
  have hC0 : 0 ≀ 8 * D ^ 4 * (1 + Real.log N) ^ 3 := by
    have := Real.log_natCast_nonneg N
    positivity
  have hnode : (8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (r - 1) ≀
      Real.exp ((Ξ΅ / 2) * m) := by
    calc
      _ ≀ Real.exp (Ξ΄ * m) ^ (r - 1) := pow_le_pow_leftβ‚€ hC0 (hcost N hN) _
      _ = Real.exp ((r - 1 : β„•) * (Ξ΄ * m)) := (Real.exp_nat_mul _ _).symm
      _ ≀ _ := by
        apply Real.exp_le_exp.mpr
        have hcount : ((r - 1 : β„•) : ℝ) ≀ r := by exact_mod_cast Nat.sub_le r 1
        have h := mul_le_mul_of_nonneg_right hcount (mul_nonneg hΞ΄.le hm0)
        nlinarith [hΞ΄r]
  have hleaf : (2 * (V : ℝ)) ^ (2 * r) * Real.exp (-(r : ℝ) * Ξ” + K) ≀
      Real.exp ((r : ℝ) * Ξ” + (Ξ΅ / 2) * m) := by
    convert hM (4 * m) (by linarith) Ξ” V hV using 1
    congr 1
    ring
  calc
    _ = (8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (r - 1) *
        ((2 * (V : ℝ)) ^ (2 * r) * Real.exp (-(r : ℝ) * Ξ” + K)) := by ring
    _ ≀ Real.exp ((Ξ΅ / 2) * m) * Real.exp ((r : ℝ) * Ξ” + (Ξ΅ / 2) * m) :=
      mul_le_mul hnode hleaf (by positivity) (Real.exp_pos _).le
    _ = _ := by rw [← Real.exp_add]; dsimp [r]; congr 1; ring

/-- There are `r*m` bulk Page factors and `m` spectators. Their combined
loss is exactly `2 * 6^(r*m)`, independently of the depth. -/
theorem arithmetic_norm_page_spectator_cost (n m : β„•) :
    (2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m) =
      2 * Real.exp (Real.log 6 * (2 ^ n : β„•) * m) := by
  rw [mul_right_comm _ 2, ← mul_pow, show (2 : ℝ) * 3 = 6 by norm_num, mul_comm _ 2]
  congr 1
  rw [show Real.log 6 * (2 ^ n : β„•) * m = ((2 ^ n * m : β„•) : ℝ) * Real.log 6 by
    push_cast
    ring, Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 6)]

/-- Fixed profile constants are absorbed without changing the coefficient
`log 6` of the bulk cost. -/
theorem arithmetic_norm_budget_rate (n : β„•) (A C Ξ΅ : ℝ) (hA : 0 ≀ A) (hC : 0 ≀ C) (hΞ΅ : 0 < Ξ΅) :
    βˆ€αΆ  m : ℝ in atTop, βˆƒ D : ℝ, 0 ≀ D ∧
      (βˆ€ q : β„•, q β‰  0 β†’ (q : ℝ) ≀ Real.exp (2 * C * m) β†’ (q.divisors.card : ℝ) ≀ D) ∧
      βˆ€ N V : β„•, βˆ€ Ξ” : ℝ, (N : ℝ) ≀ Real.exp (C * m) β†’
      (V : ℝ) ≀ Real.exp (Ξ” + Real.sqrt (4 * m)) β†’
      (A * Real.exp (-(2 ^ n : β„•) * Ξ”)) *
        ((2 * Real.exp (Real.log 6 * (2 ^ n : β„•) * m)) *
          ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) *
            (2 * (V : ℝ)) ^ (2 * 2 ^ n))) ≀
        Real.exp ((2 ^ n : β„•) * Ξ” + Real.log 6 * (2 ^ n : β„•) * m + Ξ΅ * m) := by
  let K := Real.log (2 * A + 1)
  have hK : 2 * A ≀ Real.exp K := by
    dsimp only [K]
    rw [Real.exp_log (by positivity : 0 < 2 * A + 1)]
    linarith
  filter_upwards [arithmetic_frequency_budget_rate n K C Ξ΅ hC hΞ΅] with m hm
  obtain ⟨D, hD, hdiv, hcost⟩ := hm
  refine ⟨D, hD, hdiv, ?_⟩
  intro N V Ξ” hN hV
  have hb : 0 ≀ (8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) *
      (2 * (V : ℝ)) ^ (2 * 2 ^ n) := by
    have := Real.log_natCast_nonneg N
    positivity
  calc
    _ = Real.exp (Real.log 6 * (2 ^ n : β„•) * m) *
        ((2 * A) * Real.exp (-(2 ^ n : β„•) * Ξ”) *
          ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) *
            (2 * (V : ℝ)) ^ (2 * 2 ^ n))) := by ring
    _ ≀ Real.exp (Real.log 6 * (2 ^ n : β„•) * m) *
        (Real.exp (-(2 ^ n : β„•) * Ξ” + K) *
          ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) *
            (2 * (V : ℝ)) ^ (2 * 2 ^ n))) := by
      apply mul_le_mul_of_nonneg_left _ (Real.exp_pos _).le
      rw [Real.exp_add]
      exact mul_le_mul_of_nonneg_right
        ((mul_le_mul_of_nonneg_right hK (Real.exp_pos _).le).trans_eq (mul_comm _ _)) hb
    _ ≀ Real.exp (Real.log 6 * (2 ^ n : β„•) * m) *
        Real.exp ((2 ^ n : β„•) * Ξ” + Ξ΅ * m) :=
      mul_le_mul_of_nonneg_left (hcost N V Ξ” hN hV) (Real.exp_pos _).le
    _ = _ := by rw [← Real.exp_add]; congr 1; ring

end Ostmann

end OAI