math / data /lean /OAI /Algorithms /SubexponentialSAT /SqrtLog /AsymptoticLayoutParameters.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.11 kB
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