File size: 7,228 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import OAI.Algorithms.SubexponentialSAT.LeanCompat
import OAI.Algorithms.SubexponentialSAT.SqrtLog.AsymptoticOverhead
import OAI.Algorithms.SubexponentialSAT.SqrtLog.StatementScale

namespace OAI.Algorithms

/-! Conversion to the exact natural-logarithm target and absorption of
fixed polylogarithmic construction, search, and arithmetic overheads. -/

namespace SubexponentialSAT.SqrtLog.Asymptotic

open Filter
open scoped Topology

theorem log_two_bounds : (1 : ℝ) / 2 ≀ Real.log 2 ∧ Real.log 2 ≀ 1 := by
  constructor
  Β· have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2)
    norm_num at h ⊒
    linarith
  Β· have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)
    norm_num at h ⊒
    exact h

theorem logSize_natural_bounds (n : β„•) :
    Real.log ((n : ℝ) + 16) ≀ logSize n ∧
      logSize n ≀ 2 * Real.log ((n : ℝ) + 16) := by
  have hpos := Statement.log_shift_pos n
  have hb := log_two_bounds
  have htwo : 0 < Real.log (2 : ℝ) := by linarith
  unfold logSize Real.logb
  constructor
  Β· apply (le_div_iffβ‚€ htwo).2
    nlinarith
  Β· apply (div_le_iffβ‚€ htwo).2
    nlinarith

theorem logLogSize_le_natural (n : β„•) :
    logLogSize n ≀ 4 * Real.log (Real.log ((n : ℝ) + 16)) := by
  have ha := Statement.two_le_log_shift n
  have hap := Statement.log_shift_pos n
  have hb := log_two_bounds
  have htwo : 0 < Real.log (2 : ℝ) := by linarith
  have hlog : Real.log 2 ≀ Real.log (Real.log ((n : ℝ) + 16)) :=
    Real.log_le_log (by norm_num) ha
  have ht : 0 < logSize n := by have := four_le_logSize n; linarith
  have htlog : Real.log (logSize n) ≀
      Real.log 2 + Real.log (Real.log ((n : ℝ) + 16)) := by
    calc
      Real.log (logSize n) ≀ Real.log (2 * Real.log ((n : ℝ) + 16)) :=
        Real.log_le_log ht (logSize_natural_bounds n).2
      _ = _ := Real.log_mul (by norm_num : (2 : ℝ) β‰  0) hap.ne'
  unfold logLogSize Real.logb
  apply (div_le_iffβ‚€ htwo).2
  nlinarith

theorem binaryScale_le_target (n : β„•) :
    binaryScale n ≀ 16 * Statement.runtimeScale n := by
  have hW := logLogSize_le_natural n
  have hW0 : 0 ≀ logLogSize n := by have := two_le_logLogSize n; linarith
  have hroot := Real.sqrt_le_sqrt (logSize_natural_bounds n).1
  have ha := Statement.sqrt_log_shift_pos n
  have hb : 0 < Real.sqrt (logSize n) := by linarith
  have hsq : logLogSize n ^ 2 ≀
      16 * Real.log (Real.log ((n : ℝ) + 16)) ^ 2 := by nlinarith
  unfold binaryScale Statement.runtimeScale
  calc
    (n : ℝ) * logLogSize n ^ 2 / Real.sqrt (logSize n) ≀
        (n : ℝ) * (16 * Real.log (Real.log ((n : ℝ) + 16)) ^ 2) /
          Real.sqrt (Real.log ((n : ℝ) + 16)) := by gcongr
    _ = _ := by ring

theorem eventually_inverse_schedule_target :
    βˆ€αΆ  n : β„• in atTop, (n : ℝ) / s n ≀ 128 * Statement.runtimeScale n := by
  filter_upwards [eventually_inverse_schedule_le] with n hn
  have h := binaryScale_le_target n
  linarith

theorem eventually_polylog_le_target (q : β„•) {C : ℝ} (hC : 0 < C) :
    βˆ€αΆ  n : β„• in atTop, C * logSize n ^ q ≀ Statement.runtimeScale n := by
  filter_upwards [eventually_logSize_power_le q (show 0 < 16 * C by positivity)] with n hn
  have h := binaryScale_le_target n
  nlinarith

theorem eventually_search_exponent_target (q : β„•) {C : ℝ} (hC : 0 < C) :
    βˆ€αΆ  n : β„• in atTop,
      C * ((s n : ℝ) + 2) ^ q * Real.logb 2 ((n : ℝ) + 1) ≀
        Statement.runtimeScale n := by
  filter_upwards [eventually_schedule_search_exponent q
    (show 0 < 16 * C by positivity)] with n hn
  have h := binaryScale_le_target n
  nlinarith

theorem eventually_variable_search_target (degree : β„• β†’ β„•) (q : β„•)
    {C : ℝ} (hC : 0 < C)
    (hdegree : βˆ€αΆ  n : β„• in atTop, (degree n : ℝ) ≀ C * ((s n : ℝ) + 2) ^ q) :
    βˆ€αΆ  n : β„• in atTop,
      (((n + 1) ^ degree n : β„•) : ℝ) ≀ (2 : ℝ) ^ Statement.runtimeScale n := by
  filter_upwards [hdegree, eventually_search_exponent_target q hC] with n hd hn
  have hl0 : 0 ≀ Real.logb 2 ((n : ℝ) + 1) :=
    Real.logb_nonneg (by norm_num) (by have := Nat.cast_nonneg (Ξ± := ℝ) n; linarith)
  have hexp := (mul_le_mul_of_nonneg_right hd hl0).trans hn
  have heq : (((n + 1) ^ degree n : β„•) : ℝ) =
      (2 : ℝ) ^ ((degree n : ℝ) * Real.logb 2 ((n : ℝ) + 1)) := by
    simp only [Nat.cast_pow, Nat.cast_add, Nat.cast_one]
    rw [← Real.rpow_natCast]
    exact SubexpExponentArithmetic.rpow_eq_two_rpow_logb (by positivity) _
  rw [heq]
  exact Real.rpow_le_rpow_of_exponent_le (by norm_num) hexp

/-- Any explicitly bounded fixed polylogarithm is absorbed, irrespective of
which stage of the construction produced it. -/
theorem eventually_polylog_bounded_target (f : β„• β†’ ℝ) (q : β„•)
    {C : ℝ} (hC : 0 < C)
    (hf : βˆ€αΆ  n : β„• in atTop, f n ≀ C * logSize n ^ q) :
    βˆ€αΆ  n : β„• in atTop, f n ≀ Statement.runtimeScale n := by
  filter_upwards [hf, eventually_polylog_le_target q hC] with n hn hb
  exact hn.trans hb

theorem eventually_exp_polylog_target (f : β„• β†’ ℝ) (q : β„•)
    {C : ℝ} (hC : 0 < C)
    (hf : βˆ€αΆ  n : β„• in atTop, f n ≀ C * logSize n ^ q) :
    βˆ€αΆ  n : β„• in atTop, (2 : ℝ) ^ f n ≀ (2 : ℝ) ^ Statement.runtimeScale n := by
  filter_upwards [eventually_polylog_bounded_target f q hC hf] with n hn
  exact Real.rpow_le_rpow_of_exponent_le (by norm_num) hn

theorem eventually_natural_log_power_target (q : β„•) {C : ℝ} (hC : 0 < C) :
    βˆ€αΆ  n : β„• in atTop,
      C * Real.log ((n : ℝ) + 16) ^ q ≀ Statement.runtimeScale n := by
  filter_upwards [eventually_polylog_le_target q hC] with n hn
  exact (mul_le_mul_of_nonneg_left
    (pow_le_pow_leftβ‚€ (Statement.log_shift_pos n).le (logSize_natural_bounds n).1 q)
    hC.le).trans hn

/-- Numerical finite-prefix absorption. This does not construct or dispatch
a small-input machine; it only supplies the uniform multiplicative constant
once the work at each exceptional dimension has already been bounded. -/
theorem finite_prefix_absorption (f : β„• β†’ ℝ) {A : ℝ} (hA : 0 ≀ A)
    (hf : βˆ€αΆ  n : β„• in atTop, f n ≀ (2 : ℝ) ^ (A * Statement.runtimeScale n)) :
    βˆƒ C : ℝ, 0 < C ∧ βˆ€ n, f n ≀ C * (2 : ℝ) ^ (A * Statement.runtimeScale n) := by
  obtain ⟨N, hN⟩ := eventually_atTop.1 hf
  let C : ℝ := (βˆ‘ i ∈ Finset.range N, |f i|) + 1
  have hsum : 0 ≀ βˆ‘ i ∈ Finset.range N, |f i| :=
    Finset.sum_nonneg (fun _ _ => abs_nonneg _)
  have hC : 1 ≀ C := by dsimp [C]; linarith
  refine ⟨C, by linarith, ?_⟩
  intro n
  have he : 1 ≀ (2 : ℝ) ^ (A * Statement.runtimeScale n) :=
    Real.one_le_rpow (by norm_num) (mul_nonneg hA (Statement.runtimeScale_nonneg n))
  by_cases hn : N ≀ n
  Β· exact (hN n hn).trans (le_mul_of_one_le_left (by positivity) hC)
  · have hnmem : n ∈ Finset.range N := Finset.mem_range.2 (by omega)
    have hfn : |f n| ≀ βˆ‘ i ∈ Finset.range N, |f i| :=
      Finset.single_le_sum (f := fun i : β„• => |f i|) (fun _ _ => abs_nonneg _) hnmem
    have hsmall : f n ≀ C := by have := le_abs_self (f n); dsimp [C]; linarith
    exact hsmall.trans (le_mul_of_one_le_right (by linarith) he)

end SubexponentialSAT.SqrtLog.Asymptotic

end OAI.Algorithms