File size: 4,188 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 | import OAI.Algorithms.SubexponentialSAT.LeanCompat
import OAI.Algorithms.SubexponentialSAT.SqrtLog.AsymptoticLayoutFeasibility
import OAI.Algorithms.SubexponentialSAT.SqrtLog.AsymptoticLayoutLabels
namespace OAI.Algorithms
namespace SubexponentialSAT.SqrtLog.Asymptotic
open Filter
open scoped Topology
theorem eventually_layout_inverse_target :
βαΆ n : β in atTop, (n : β) / layoutR n β€ 128 * Statement.runtimeScale n := by
filter_upwards [eventually_inverse_schedule_target, eventually_le_s 1] with n hn hs
have hs' : (0 : β) < s n := by exact_mod_cast (by omega : 0 < s n)
have hr : (s n : β) β€ layoutR n := by exact_mod_cast le_max_right 2 (s n)
exact (div_le_div_of_nonneg_left (Nat.cast_nonneg n) hs' hr).trans hn
theorem eventually_cutoff_ratio (b : β β β) (q : β)
(hb : βαΆ n : β in atTop, b n β€ L n ^ q) :
βαΆ n : β in atTop,
(layoutCutoff n (b n) : β) / layoutQ n β€
(128 * (28 * q + 312) : β) * (w n : β) / Real.sqrt (L n : β) := by
filter_upwards [eventually_layoutCutoff_sq_le b q hb,
eventually_layoutQ_comparison, eventually_layoutQ_ge 1] with n hsq hcomp hQ
have hQ' : (0 : β) < layoutQ n := by exact_mod_cast (by omega : 0 < layoutQ n)
have hL : (0 : β) < L n := by exact_mod_cast L_pos n
have hroot0 : 0 < Real.sqrt (L n : β) := Real.sqrt_pos.2 hL
have hroot := Real.sq_sqrt hL.le
have hsq' : (layoutCutoff n (b n) : β) ^ 2 β€ (28 * q + 312 : β) * (L n : β) := by
exact_mod_cast hsq
have hK : (1 : β) β€ (28 * q + 312 : β) := by norm_cast; omega
have hR : (layoutCutoff n (b n) : β) β€
(28 * q + 312 : β) * Real.sqrt (L n : β) := by
apply (sq_le_sqβ (by positivity) (by positivity)).mp
calc
(layoutCutoff n (b n) : β) ^ 2 β€ (28 * q + 312 : β) * (L n : β) := hsq'
_ β€ ((28 * q + 312 : β) : β) ^ 2 * (L n : β) :=
mul_le_mul_of_nonneg_right (by nlinarith) hL.le
_ = ((28 * q + 312 : β) * Real.sqrt (L n : β)) ^ 2 := by rw [mul_pow, hroot]
have hprod := mul_le_mul_of_nonneg_right hR hroot0.le
have hprod' : (layoutCutoff n (b n) : β) * Real.sqrt (L n : β) β€
(28 * q + 312 : β) * (L n : β) := by
calc
_ β€ (28 * q + 312 : β) * Real.sqrt (L n : β) * Real.sqrt (L n : β) := hprod
_ = _ := by rw [mul_assoc, β pow_two, hroot]
have hcomp' : (L n : β) β€ 128 * (layoutQ n : β) * w n := by exact_mod_cast hcomp.1
have hm := mul_le_mul_of_nonneg_left hcomp' (show (0 : β) β€ (28 * q + 312 : β) by positivity)
apply (div_le_div_iffβ hQ' hroot0).2
convert hprod'.trans hm using 1 ; push_cast ; ring
/-- The spectral numerator times the logarithmic support-entropy loss fits
the exact target. Any further fixed coefficient may multiply this bound. -/
theorem eventually_layout_spectral_cost (b : β β β) (q : β)
(hb : βαΆ n : β in atTop, b n β€ L n ^ q) :
βαΆ n : β in atTop,
(n : β) * ((layoutCutoff n (b n) : β) / layoutQ n) * w n β€
(8192 * (28 * q + 312) : β) * Statement.runtimeScale n := by
filter_upwards [eventually_cutoff_ratio b q hb] with n hn
have ht := four_le_logSize n
have hW := two_le_logLogSize n
have hroots : Real.sqrt (logSize n) β€ Real.sqrt (L n : β) :=
Real.sqrt_le_sqrt (logSize_lt_L n).le
have hrootpos : 0 < Real.sqrt (logSize n) := Real.sqrt_pos.2 (by linarith)
have hw := w_le_twice_logLogSize n
have hmain : (n : β) * ((layoutCutoff n (b n) : β) / layoutQ n) * w n β€
(512 * (28 * q + 312) : β) * binaryScale n := by
calc
_ β€ (n : β) * (((128 * (28 * q + 312) : β) : β) * w n /
Real.sqrt (L n : β)) * w n := by gcongr
_ β€ (n : β) * (((128 * (28 * q + 312) : β) : β) * (2 * logLogSize n) /
Real.sqrt (logSize n)) * (2 * logLogSize n) := by gcongr
_ = _ := by unfold binaryScale; push_cast; ring
have htarget := binaryScale_le_target n
have hm := mul_le_mul_of_nonneg_left htarget
(show (0 : β) β€ (512 * (28 * q + 312) : β) by positivity)
push_cast at hmain hm β’
nlinarith
end SubexponentialSAT.SqrtLog.Asymptotic
end OAI.Algorithms
|