File size: 4,111 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 | import OAI.Algorithms.SubexponentialSAT.LeanCompat
import OAI.Algorithms.SubexponentialSAT.SqrtLog.AsymptoticTarget
namespace OAI.Algorithms
/-! Integer layout parameters agreed with the layout and spectral components.
The occurrence bound `b` is an explicit argument. Positivity assumptions are
kept on theorems rather than built into an opaque choice. -/
namespace SubexponentialSAT.SqrtLog.Asymptotic
open Filter
open scoped Topology
def layoutR (n : β) : β := max 2 (s n)
def layoutDen (n : β) : β := 64 * (Nat.log2 (layoutR n) + 1)
def layoutQ (n : β) : β := L n / layoutDen n
def layoutEnergy (n b : β) : β := Nat.log2 (64 * b * layoutR n * L n ^ 2) + 1
def layoutCutoff (n b : β) : β := Nat.sqrt (128 * layoutQ n * layoutEnergy n b) + 4
def layoutEpsilon (n b : β) : β := 1 / (32 * b * layoutR n * L n ^ 2 : β)
theorem layoutR_ge_two (n : β) : 2 β€ layoutR n := le_max_left _ _
theorem layoutDen_pos (n : β) : 0 < layoutDen n := by
unfold layoutDen
positivity
theorem layoutCutoff_ge_four (n b : β) : 4 β€ layoutCutoff n b := by
unfold layoutCutoff
omega
theorem layoutEnergy_pos (n b : β) : 0 < layoutEnergy n b := by
unfold layoutEnergy
omega
theorem layoutEpsilon_pos (n : β) {b : β} (hb : 0 < b) : 0 < layoutEpsilon n b := by
have hr := layoutR_ge_two n
have hL := L_pos n
unfold layoutEpsilon
positivity
theorem eventually_layoutR_eq_s : βαΆ n : β in Filter.atTop, layoutR n = s n := by
filter_upwards [eventually_le_s 2] with n hn
exact max_eq_right hn
theorem layoutCutoff_square (n b : β) :
128 * layoutQ n * layoutEnergy n b β€ layoutCutoff n b ^ 2 := by
have h := Nat.lt_succ_sqrt' (128 * layoutQ n * layoutEnergy n b)
simp only [Nat.succ_eq_add_one] at h
unfold layoutCutoff
exact h.le.trans (Nat.pow_le_pow_left (by omega) 2)
theorem layout_log_epsilon_le (n : β) {b : β} (hb : 0 < b) :
Real.log (2 / (layoutEpsilon n b : β)) β€ layoutEnergy n b := by
have hr : 0 < layoutR n := by have := layoutR_ge_two n; omega
have hL := L_pos n
have hb' : (0 : β) < b := by exact_mod_cast hb
have hr' : (0 : β) < layoutR n := by exact_mod_cast hr
have hL' : (0 : β) < L n := by exact_mod_cast hL
have he : (layoutEpsilon n b : β) = 1 / (32 * (b : β) * layoutR n * (L n : β) ^ 2) := by
norm_num [layoutEpsilon]
have hid : 2 / (layoutEpsilon n b : β) = (64 * b * layoutR n * L n ^ 2 : β) := by
rw [he]
push_cast
field_simp
; ring
rw [hid]
have hx : 1 β€ (64 * b * layoutR n * L n ^ 2 : β) := by
have : 0 < 64 * b * layoutR n * L n ^ 2 := by positivity
omega
have hx' : (1 : β) β€ (64 * b * layoutR n * L n ^ 2 : β) := by exact_mod_cast hx
have hlog := Real.log_nonneg hx'
have htwo := log_two_bounds
have hl : Real.log (64 * b * layoutR n * L n ^ 2 : β) β€
Real.logb 2 (64 * b * layoutR n * L n ^ 2 : β) := by
unfold Real.logb
apply (le_div_iffβ (show 0 < Real.log (2 : β) by linarith)).2
nlinarith
apply hl.trans
have hh := (SubexpExponentArithmetic.logb_lt_natLog2_add_one
(64 * b * layoutR n * L n ^ 2)).le
push_cast at hh
dsimp only [layoutEnergy]
push_cast
exact hh
theorem layout_spectral_square (n : β) {b : β} (hb : 0 < b) :
32 * ((layoutQ n - 1 : β) : β) * Real.log (2 / (layoutEpsilon n b : β)) β€
(layoutCutoff n b : β) ^ 2 := by
have hlog := layout_log_epsilon_le n hb
have hQ : ((layoutQ n - 1 : β) : β) β€ layoutQ n := by exact_mod_cast Nat.sub_le (layoutQ n) 1
have hsq : (128 : β) * layoutQ n * layoutEnergy n b β€ (layoutCutoff n b : β) ^ 2 := by
exact_mod_cast layoutCutoff_square n b
calc
32 * ((layoutQ n - 1 : β) : β) * Real.log (2 / (layoutEpsilon n b : β)) β€
32 * ((layoutQ n - 1 : β) : β) * layoutEnergy n b :=
mul_le_mul_of_nonneg_left hlog (by positivity)
_ β€ 32 * (layoutQ n : β) * layoutEnergy n b := by gcongr
_ β€ 128 * (layoutQ n : β) * layoutEnergy n b := by gcongr ; norm_num
_ β€ _ := hsq
end SubexponentialSAT.SqrtLog.Asymptotic
end OAI.Algorithms
|