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