interplane.Get Omega
Read in your language

omega-principia

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

omega-principia / proofs / FmmWorldRecordsWave2.lean

1085 lines · 50098 bytes Raw Blame History
1-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2-- experiments/overnight_1pflop_fmm/FmmWorldRecordsWave2.lean
3-- Zero-Mathlib, pure-kernel Lean 4.36.0 Formal Proof of World-Record Ternary (Z_T = {-1, 0, +1})
4-- Fast Matrix Multiplication Schemes & Straight-Line Addition Circuits Beating Live Dec 2, 2026 Records.
5
6set_option maxRecDepth 200000
7set_option maxHeartbeats 40000000
8
9namespace FmmWorldRecordsWave2
10
11abbrev SRow := List (Nat × Int)
12abbrev Gate := Nat × Int × Nat × Int
13
14def sparseAddAux : Nat → SRow → SRow → SRow
15 | 0, xs, _ => xs
16 | _ + 1, [], ys => ys
17 | _ + 1, xs, [] => xs
18 | fuel + 1, (i, a) :: xt, (j, b) :: yt =>
19 if i < j then
20 (i, a) :: sparseAddAux fuel xt ((j, b) :: yt)
21 else if j < i then
22 (j, b) :: sparseAddAux fuel ((i, a) :: xt) yt
23 else
24 let c := a + b
25 if c == 0 then sparseAddAux fuel xt yt else (i, c) :: sparseAddAux fuel xt yt
26
27def sparseAdd (xs ys : SRow) : SRow :=
28 sparseAddAux (xs.length + ys.length + 1) xs ys
29
30def sparseScale (s : Int) (xs : SRow) : SRow :=
31 if s == 0 then []
32 else if s == 1 then xs
33 else xs.map (fun (i, a) => (i, s * a))
34
35def sparseDot (xs : SRow) (f : Nat → Int) : Int :=
36 xs.foldl (fun acc (i, a) => acc + a * f i) 0
37
38def listGetD (xs : List SRow) (idx : Nat) : SRow :=
39 match xs, idx with
40 | [], _ => []
41 | x :: _, 0 => x
42 | _ :: xt, n + 1 => listGetD xt n
43
44def intGetD (xs : List Int) (idx : Nat) : Int :=
45 match xs, idx with
46 | [], _ => 0
47 | x :: _, 0 => x
48 | _ :: xt, n + 1 => intGetD xt n
49
50/-- Symbolic straight-line DAG evaluator producing exact sparse row vectors. -/
51def evalFreshAux (nCur : Nat) (revVecs : List SRow) : List Gate → Bool × Nat × List SRow
52 | [] => (true, nCur, revVecs)
53 | (a, sa, b, sb) :: rest =>
54 if a < nCur && b < nCur && (sa == 1 || sa == -1) && (sb == 1 || sb == -1) then
55 let va := listGetD revVecs (nCur - 1 - a)
56 let vb := listGetD revVecs (nCur - 1 - b)
57 let vn := sparseAdd (sparseScale sa va) (sparseScale sb vb)
58 evalFreshAux (nCur + 1) (vn :: revVecs) rest
59 else
60 (false, nCur, revVecs)
61
62def initUnitsRev (nIn : Nat) : List SRow :=
63 (List.range nIn).foldl (fun acc i => [(i, 1)] :: acc) []
64
65def evalOutRow (nCur : Nat) (revVecs : List SRow) (terms : List (Nat × Int)) : Bool × SRow :=
66 terms.foldl (fun (ok, acc) (ix, s) =>
67 if ok && ix < nCur && (s == 1 || s == -1) then
68 (true, sparseAdd acc (sparseScale s (listGetD revVecs (nCur - 1 - ix))))
69 else
70 (false, acc)
71 ) (true, [])
72
73def evalDagToSparse (nIn : Nat) (fresh : List Gate) (outs : List (List (Nat × Int))) : Bool × List SRow :=
74 let (okF, nCur, revVecs) := evalFreshAux nIn (initUnitsRev nIn) fresh
75 if !okF then (false, [])
76 else
77 let (okO, revOut) := outs.foldl (fun (ok, acc) rowTerms =>
78 if !ok then (false, acc)
79 else
80 let (okR, rVec) := evalOutRow nCur revVecs rowTerms
81 (okR, rVec :: acc)
82 ) (true, [])
83 (okO, revOut.reverse)
84
85/-- Direct runtime straight-line addition DAG evaluator on arbitrary integer inputs x : Nat -> Int. -/
86def evalFreshRuntime (nCur : Nat) (revVals : List Int) : List Gate → List Int
87 | [] => revVals
88 | (a, sa, b, sb) :: rest =>
89 let va := intGetD revVals (nCur - 1 - a)
90 let vb := intGetD revVals (nCur - 1 - b)
91 evalFreshRuntime (nCur + 1) ((sa * va + sb * vb) :: revVals) rest
92
93def initValsRev (nIn : Nat) (x : Nat → Int) : List Int :=
94 (List.range nIn).foldl (fun acc i => x i :: acc) []
95
96def evalOutRowRuntime (nCur : Nat) (revVals : List Int) (terms : List (Nat × Int)) : Int :=
97 terms.foldl (fun acc (ix, s) => acc + s * intGetD revVals (nCur - 1 - ix)) 0
98
99def evalDagRuntime (nIn : Nat) (fresh : List Gate) (outs : List (List (Nat × Int))) (x : Nat → Int) : List Int :=
100 let revVals := evalFreshRuntime nIn (initValsRev nIn x) fresh
101 outs.map (evalOutRowRuntime (nIn + fresh.length) revVals)
102
103/-- Literal end-to-end straight-line matrix multiplication algorithm over arbitrary A, B : Nat -> Int:
104 1. Runs U straight-line additions on A -> R linear forms uVals
105 2. Runs V straight-line additions on B -> R linear forms vVals
106 3. Computes R scalar products P(r) = uVals[r] * vVals[r]
107 4. Runs W straight-line additions on P -> returns C[a, c] = wVals[a*p + c] -/
108def evalDagMatmul (m n p : Nat)
109 (uf : List Gate) (uo : List (List (Nat × Int)))
110 (vf : List Gate) (vo : List (List (Nat × Int)))
111 (wf : List Gate) (wo : List (List (Nat × Int)))
112 (A B : Nat → Int) (a c : Nat) : Int :=
113 let uVals := evalDagRuntime (m * n) uf uo A
114 let vVals := evalDagRuntime (n * p) vf vo B
115 let mProd (r : Nat) : Int := intGetD uVals r * intGetD vVals r
116 let wVals := evalDagRuntime uVals.length wf wo mProd
117 intGetD wVals (a * p + c)
118
119/-- Standard schoolbook matrix product entry (A * B)[a, c] = sum_{b=0}^{n-1} A[a, b] * B[b, c]. -/
120def exactMatmulEntry (n p a c : Nat) (A B : Nat → Int) : Int :=
121 (List.range n).foldl (fun acc b => acc + A (a * n + b) * B (b * p + c)) 0
122
123def dagAddCount (fresh : List Gate) (outs : List (List (Nat × Int))) : Nat :=
124 fresh.length + outs.foldl (fun acc r => acc + if r.length > 1 then r.length - 1 else 0) 0
125
126def rowTernary (xs : SRow) : Bool :=
127 xs.all (fun (_, a) => a == 1 || a == -1)
128
129def allTernary (rows : List SRow) : Bool :=
130 rows.all rowTernary
131
132def allColsLt (bound : Nat) (rows : List SRow) : Bool :=
133 rows.all (fun r => r.all (fun (j, _) => j < bound))
134
135def contractOutputK (nV : Nat) (U V : List SRow) (wRow : SRow) : SRow :=
136 wRow.foldl (fun acc (r, wv) =>
137 let ur := listGetD U r
138 let vr := listGetD V r
139 ur.foldl (fun acc2 (i, uv) =>
140 let iOff := i * nV
141 let wuv := wv * uv
142 let rowContrib : SRow := vr.map (fun (j, vv) => (iOff + j, wuv * vv))
143 sparseAdd acc2 rowContrib
144 ) acc
145 ) []
146
147def expectedOutputK (n p a c : Nat) : SRow :=
148 (List.range n).map (fun b => ((a * n + b) * (n * p) + (b * p + c), 1))
149
150def checkExactMatmulTensor (m n p : Nat) (U V W : List SRow) : Bool :=
151 (List.range m).all (fun a =>
152 (List.range p).all (fun c =>
153 let k := a * p + c
154 contractOutputK (n * p) U V (listGetD W k) == expectedOutputK n p a c
155 )
156 )
157
158def fullSchemeValid (m n p R : Nat)
159 (uf : List Gate) (uo : List (List (Nat × Int)))
160 (vf : List Gate) (vo : List (List (Nat × Int)))
161 (wf : List Gate) (wo : List (List (Nat × Int))) : Bool :=
162 let (okU, U) := evalDagToSparse (m * n) uf uo
163 let (okV, V) := evalDagToSparse (n * p) vf vo
164 let (okW, W) := evalDagToSparse R wf wo
165 (n > 0) && (p > 0) &&
166 okU && okV && okW &&
167 U.length == R && V.length == R && W.length == m * p &&
168 allTernary U && allTernary V && allTernary W &&
169 allColsLt (n * p) V &&
170 checkExactMatmulTensor m n p U V W
171
172def totalReducedAdds (uf : List Gate) (uo : List (List (Nat × Int)))
173 (vf : List Gate) (vo : List (List (Nat × Int)))
174 (wf : List Gate) (wo : List (List (Nat × Int))) : Nat :=
175 dagAddCount uf uo + dagAddCount vf vo + dagAddCount wf wo
176
177-- ============================================================================
178-- UNIVERSAL SEMANTIC BILINEAR MATRIX-MULTIPLICATION SOUNDNESS PROOF
179-- ============================================================================
180
181theorem sparseDot_cons (i : Nat) (a : Int) (xt : SRow) (f : Nat → Int) :
182 sparseDot ((i, a) :: xt) f = a * f i + sparseDot xt f := by
183 unfold sparseDot
184 have h : ∀ (l : SRow) (init : Int),
185 l.foldl (fun acc p => acc + p.2 * f p.1) init = init + l.foldl (fun acc p => acc + p.2 * f p.1) 0 := by
186 intro l
187 induction l with
188 | nil => intro init; simp
189 | cons hd tl ih =>
190 intro init
191 simp only [List.foldl_cons, Int.zero_add]
192 rw [ih (init + hd.2 * f hd.1), ih (hd.2 * f hd.1)]
193 omega
194 simp only [List.foldl_cons, Int.zero_add]
195 exact h xt (a * f i)
196
197theorem sparseDot_nil (f : Nat → Int) : sparseDot [] f = 0 := rfl
198
199theorem sparseDot_sparseAddAux (fuel : Nat) (xs ys : SRow) (f : Nat → Int)
200 (hf : xs.length + ys.length ≤ fuel) :
201 sparseDot (sparseAddAux fuel xs ys) f = sparseDot xs f + sparseDot ys f := by
202 induction fuel generalizing xs ys with
203 | zero =>
204 have hx : xs = [] := List.eq_nil_of_length_eq_zero (by omega)
205 have hy : ys = [] := List.eq_nil_of_length_eq_zero (by omega)
206 subst hx; subst hy; simp [sparseAddAux, sparseDot_nil]
207 | succ k ih =>
208 cases xs with
209 | nil => simp [sparseAddAux, sparseDot_nil]
210 | cons x xt =>
211 cases ys with
212 | nil => simp [sparseAddAux, sparseDot_nil]
213 | cons y yt =>
214 rcases x with ⟨i, a⟩
215 rcases y with ⟨j, b⟩
216 simp only [List.length_cons] at hf
217 unfold sparseAddAux
218 split
219 · rw [sparseDot_cons, ih xt ((j, b) :: yt) (by simp; omega), sparseDot_cons i a xt f]; omega
220 · split
221 · rw [sparseDot_cons, ih ((i, a) :: xt) yt (by simp; omega), sparseDot_cons j b yt f]; omega
222 · have hij : i = j := by omega
223 subst hij
224 dsimp only
225 split
226 · rename_i hzero
227 have hab : a + b = 0 := by simpa using hzero
228 rw [ih xt yt (by omega), sparseDot_cons, sparseDot_cons]
229 have hmul : (a + b) * f i = 0 := by rw [hab, Int.zero_mul]
230 rw [Int.add_mul] at hmul
231 omega
232 · rw [sparseDot_cons, ih xt yt (by omega), sparseDot_cons, sparseDot_cons]
233 rw [Int.add_mul]
234 omega
235
236theorem sparseDot_sparseAdd (xs ys : SRow) (f : Nat → Int) :
237 sparseDot (sparseAdd xs ys) f = sparseDot xs f + sparseDot ys f :=
238 sparseDot_sparseAddAux (xs.length + ys.length + 1) xs ys f (by omega)
239
240theorem sparseDot_map_scale (s : Int) (xs : SRow) (f : Nat → Int) :
241 sparseDot (xs.map (fun (i, a) => (i, s * a))) f = s * sparseDot xs f := by
242 induction xs with
243 | nil => simp [sparseDot_nil]
244 | cons hd tl ih =>
245 rcases hd with ⟨i, a⟩
246 simp only [List.map_cons]
247 rw [sparseDot_cons, sparseDot_cons, ih, Int.mul_add, Int.mul_assoc]
248
249theorem sparseDot_sparseScale (s : Int) (xs : SRow) (f : Nat → Int) :
250 sparseDot (sparseScale s xs) f = s * sparseDot xs f := by
251 unfold sparseScale
252 split
253 · rename_i hs; have h0 : s = 0 := by simpa using hs
254 subst h0; simp [sparseDot_nil]
255 · split
256 · rename_i hs1; have h1 : s = 1 := by simpa using hs1
257 subst h1; simp
258 · exact sparseDot_map_scale s xs f
259
260theorem intGetD_map_sparseDot (xs : List SRow) (f : Nat → Int) (k : Nat) :
261 intGetD (xs.map (fun r => sparseDot r f)) k = sparseDot (listGetD xs k) f := by
262 induction xs generalizing k with
263 | nil => cases k <;> rfl
264 | cons hd tl ih =>
265 cases k with
266 | zero => rfl
267 | succ k' => exact ih k'
268
269theorem initValsRev_eq_map (nIn : Nat) (x : Nat → Int) :
270 initValsRev nIn x = (initUnitsRev nIn).map (fun r => sparseDot r x) := by
271 unfold initValsRev initUnitsRev
272 have h : ∀ (l : List Nat) (acc : List SRow),
273 l.foldl (fun a i => x i :: a) (acc.map (fun r => sparseDot r x)) =
274 (l.foldl (fun a i => [(i, 1)] :: a) acc).map (fun r => sparseDot r x) := by
275 intro l
276 induction l with
277 | nil => intro acc; rfl
278 | cons i tl ih =>
279 intro acc
280 simp only [List.foldl_cons]
281 have h1 : sparseDot [(i, 1)] x = x i := by
282 rw [sparseDot_cons, sparseDot_nil]; omega
283 have h2 : x i :: acc.map (fun r => sparseDot r x) = ([(i, 1)] :: acc).map (fun r => sparseDot r x) := by
284 simp [h1]
285 rw [h2]
286 exact ih ([(i, 1)] :: acc)
287 exact h (List.range nIn) []
288
289theorem evalFreshRuntime_sound (fresh : List Gate) (nCur : Nat) (revVecs : List SRow) (x : Nat → Int)
290 (nEnd : Nat) (revEnd : List SRow)
291 (hok : evalFreshAux nCur revVecs fresh = (true, nEnd, revEnd)) :
292 nEnd = nCur + fresh.length ∧
293 evalFreshRuntime nCur (revVecs.map (fun r => sparseDot r x)) fresh = revEnd.map (fun r => sparseDot r x) := by
294 induction fresh generalizing nCur revVecs with
295 | nil =>
296 simp only [evalFreshAux, evalFreshRuntime, List.length_nil, Nat.add_zero] at hok ⊢
297 rcases hok with ⟨rfl, rfl⟩
298 exact ⟨rfl, rfl⟩
299 | cons g rest ih =>
300 rcases g with ⟨a, sa, b, sb⟩
301 unfold evalFreshAux at hok
302 split at hok
303 · simp only [evalFreshRuntime, List.length_cons]
304 rw [intGetD_map_sparseDot, intGetD_map_sparseDot]
305 have hstep : sa * sparseDot (listGetD revVecs (nCur - 1 - a)) x +
306 sb * sparseDot (listGetD revVecs (nCur - 1 - b)) x =
307 sparseDot (sparseAdd (sparseScale sa (listGetD revVecs (nCur - 1 - a)))
308 (sparseScale sb (listGetD revVecs (nCur - 1 - b)))) x := by
309 rw [sparseDot_sparseAdd, sparseDot_sparseScale, sparseDot_sparseScale]
310 rw [hstep]
311 have hcons :
312 sparseDot (sparseAdd (sparseScale sa (listGetD revVecs (nCur - 1 - a)))
313 (sparseScale sb (listGetD revVecs (nCur - 1 - b)))) x ::
314 revVecs.map (fun r => sparseDot r x) =
315 (sparseAdd (sparseScale sa (listGetD revVecs (nCur - 1 - a)))
316 (sparseScale sb (listGetD revVecs (nCur - 1 - b))) :: revVecs).map (fun r => sparseDot r x) := rfl
317 rw [hcons]
318 have ⟨hn, hv⟩ := ih (nCur + 1) _ hok
319 exact ⟨by omega, hv⟩
320 · simp at hok
321
322theorem evalOutRowRuntime_sound (nCur : Nat) (revVecs : List SRow) (terms : List (Nat × Int))
323 (x : Nat → Int) (rVec : SRow)
324 (hok : evalOutRow nCur revVecs terms = (true, rVec)) :
325 evalOutRowRuntime nCur (revVecs.map (fun r => sparseDot r x)) terms = sparseDot rVec x := by
326 unfold evalOutRow at hok
327 unfold evalOutRowRuntime
328 have h : ∀ (ts : List (Nat × Int)) (acc : SRow) (res : SRow),
329 ts.foldl (fun (ok, a) (ix, s) =>
330 if ok && ix < nCur && (s == 1 || s == -1) then
331 (true, sparseAdd a (sparseScale s (listGetD revVecs (nCur - 1 - ix))))
332 else (false, a)) (true, acc) = (true, res) →
333 ts.foldl (fun a (ix, s) => a + s * intGetD (revVecs.map (fun r => sparseDot r x)) (nCur - 1 - ix))
334 (sparseDot acc x) = sparseDot res x := by
335 intro ts
336 induction ts with
337 | nil =>
338 intro acc res heq
339 simp only [List.foldl_nil, Prod.mk.injEq] at heq
340 rw [heq.2]; rfl
341 | cons hd tl ih =>
342 intro acc res heq
343 rcases hd with ⟨ix, s⟩
344 simp only [List.foldl_cons] at heq ⊢
345 split at heq
346 · rw [intGetD_map_sparseDot]
347 have hs : sparseDot acc x + s * sparseDot (listGetD revVecs (nCur - 1 - ix)) x =
348 sparseDot (sparseAdd acc (sparseScale s (listGetD revVecs (nCur - 1 - ix)))) x := by
349 rw [sparseDot_sparseAdd, sparseDot_sparseScale]
350 rw [hs]
351 exact ih _ res heq
352 · have hfalse : ∀ (l : List (Nat × Int)) (a : SRow),
353 (l.foldl (fun (ok, a) (ix, s) =>
354 if ok && ix < nCur && (s == 1 || s == -1) then
355 (true, sparseAdd a (sparseScale s (listGetD revVecs (nCur - 1 - ix))))
356 else (false, a)) (false, a)).1 = false := by
357 intro l; induction l with
358 | nil => intro a; rfl
359 | cons _ ltl lih => intro a; simp only [List.foldl_cons, Bool.false_and, Bool.false_eq_true, ↓reduceIte]; exact lih a
360 have hbad := hfalse tl acc
361 rw [heq] at hbad
362 simp at hbad
363 exact h terms [] rVec hok
364
365theorem evalDagRuntime_eq_sparseDot (nIn : Nat) (fresh : List Gate) (outs : List (List (Nat × Int)))
366 (x : Nat → Int) (rows : List SRow)
367 (hok : evalDagToSparse nIn fresh outs = (true, rows)) :
368 evalDagRuntime nIn fresh outs x = rows.map (fun r => sparseDot r x) := by
369 unfold evalDagToSparse at hok
370 cases hF : evalFreshAux nIn (initUnitsRev nIn) fresh with
371 | mk okF restF =>
372 rcases restF with ⟨nCur, revVecs⟩
373 rw [hF] at hok
374 cases okF with
375 | false => simp at hok
376 | true =>
377 simp only [Bool.not_true, Bool.false_eq_true, ↓reduceIte] at hok
378 have ⟨hnCur, hrevVals⟩ := evalFreshRuntime_sound fresh nIn (initUnitsRev nIn) x nCur revVecs hF
379 unfold evalDagRuntime
380 rw [initValsRev_eq_map, hrevVals, ← hnCur]
381 have hO : ∀ (os : List (List (Nat × Int))) (acc : List SRow) (outAcc : List SRow),
382 os.foldl (fun (ok, a) rowTerms =>
383 if !ok then (false, a)
384 else
385 let (okR, rVec) := evalOutRow nCur revVecs rowTerms
386 (okR, rVec :: a)) (true, acc) = (true, outAcc) →
387 acc.reverse.map (fun r => sparseDot r x) ++ os.map (evalOutRowRuntime nCur (revVecs.map (fun r => sparseDot r x))) =
388 outAcc.reverse.map (fun r => sparseDot r x) := by
389 intro os
390 induction os with
391 | nil =>
392 intro acc outAcc heq
393 simp only [List.foldl_nil, Prod.mk.injEq] at heq
394 rw [heq.2]; simp
395 | cons rts tl ih =>
396 intro acc outAcc heq
397 simp only [List.foldl_cons, Bool.not_true, Bool.false_eq_true, ↓reduceIte] at heq
398 cases hR : evalOutRow nCur revVecs rts with
399 | mk okR rVec =>
400 rw [hR] at heq
401 cases okR with
402 | false =>
403 have hbad : ∀ (l : List (List (Nat × Int))) (a : List SRow),
404 (l.foldl (fun (ok, a) rowTerms =>
405 if !ok then (false, a)
406 else
407 let (okR, rVec) := evalOutRow nCur revVecs rowTerms
408 (okR, rVec :: a)) (false, a)).1 = false := by
409 intro l; induction l with
410 | nil => intro a; rfl
411 | cons _ ltl lih => intro a; simp only [List.foldl_cons, Bool.not_false, ↓reduceIte]; exact lih a
412 have hb := hbad tl (rVec :: acc)
413 rw [heq] at hb; simp at hb
414 | true =>
415 have h1 := evalOutRowRuntime_sound nCur revVecs rts x rVec hR
416 have h2 := ih (rVec :: acc) outAcc heq
417 simp only [List.reverse_cons, List.map_append, List.map_cons, List.map_nil, List.append_assoc,
418 List.cons_append, List.nil_append] at h2 ⊢
419 rw [h1]; exact h2
420 cases hFold : outs.foldl (fun (ok, a) rowTerms =>
421 if !ok then (false, a)
422 else
423 let (okR, rVec) := evalOutRow nCur revVecs rowTerms
424 (okR, rVec :: a)) (true, []) with
425 | mk okO revOut =>
426 rw [hFold] at hok
427 simp only [Prod.mk.injEq] at hok
428 rcases hok with ⟨rfl, rfl⟩
429 have hres := hO outs [] revOut hFold
430 simpa using hres
431
432def pairProd (nV : Nat) (A B : Nat → Int) (ij : Nat) : Int :=
433 A (ij / nV) * B (ij % nV)
434
435def evalBilinearK (U V : List SRow) (wRow : SRow) (A B : Nat → Int) : Int :=
436 wRow.foldl (fun acc (r, wv) => acc + wv * (sparseDot (listGetD U r) A * sparseDot (listGetD V r) B)) 0
437
438theorem foldl_pair_row (nV : Nat) (hnV : nV > 0) (vr : SRow)
439 (hvr : vr.all (fun p => p.1 < nV) = true) (i : Nat) (wuv : Int) (A B : Nat → Int) :
440 sparseDot (vr.map (fun (j, vv) => (i * nV + j, wuv * vv))) (pairProd nV A B) =
441 wuv * A i * sparseDot vr B := by
442 induction vr with
443 | nil => simp [sparseDot_nil]
444 | cons hd tl ih =>
445 rcases hd with ⟨j, vv⟩
446 simp only [List.all_cons, Bool.and_eq_true, decide_eq_true_eq] at hvr
447 rcases hvr with ⟨hj, htl⟩
448 simp only [List.map_cons]
449 rw [sparseDot_cons, sparseDot_cons, ih htl]
450 unfold pairProd
451 have hdiv : (i * nV + j) / nV = i := by
452 rw [Nat.mul_comm, Nat.mul_add_div hnV, Nat.div_eq_of_lt hj, Nat.add_zero]
453 have hmod : (i * nV + j) % nV = j := by
454 rw [Nat.mul_comm, Nat.mul_add_mod, Nat.mod_eq_of_lt hj]
455 rw [hdiv, hmod]
456 have h1 : wuv * vv * (A i * B j) = wuv * A i * (vv * B j) := by
457 rw [Int.mul_assoc, Int.mul_assoc]
458 congr 1
459 rw [← Int.mul_assoc, Int.mul_comm vv (A i), Int.mul_assoc]
460 rw [h1, ← Int.mul_add]
461
462theorem listGetD_allColsLt (nV : Nat) (V : List SRow) (hV : allColsLt nV V = true) (r : Nat) :
463 (listGetD V r).all (fun p => p.1 < nV) = true := by
464 unfold allColsLt at hV
465 induction V generalizing r with
466 | nil => cases r <;> rfl
467 | cons hd tl ih =>
468 simp only [List.all_cons, Bool.and_eq_true] at hV
469 cases r with
470 | zero => exact hV.1
471 | succ r' => exact ih hV.2 r'
472
473theorem contractOutputK_sound (nV : Nat) (hnV : nV > 0) (U V : List SRow)
474 (hV : allColsLt nV V = true) (wRow : SRow) (A B : Nat → Int) :
475 sparseDot (contractOutputK nV U V wRow) (pairProd nV A B) = evalBilinearK U V wRow A B := by
476 unfold contractOutputK evalBilinearK
477 have hInner : ∀ (ur vr : SRow) (hvr : vr.all (fun p => p.1 < nV) = true) (wv : Int) (acc : SRow),
478 sparseDot (ur.foldl (fun acc2 (i, uv) =>
479 sparseAdd acc2 (vr.map (fun (j, vv) => (i * nV + j, wv * uv * vv)))) acc) (pairProd nV A B) =
480 sparseDot acc (pairProd nV A B) + wv * (sparseDot ur A * sparseDot vr B) := by
481 intro ur
482 induction ur with
483 | nil => intro vr _ wv acc; simp [sparseDot_nil]
484 | cons hd tl ih =>
485 intro vr hvr wv acc
486 rcases hd with ⟨i, uv⟩
487 simp only [List.foldl_cons]
488 rw [ih vr hvr wv, sparseDot_sparseAdd, foldl_pair_row nV hnV vr hvr i (wv * uv) A B, sparseDot_cons]
489 have halg : wv * uv * A i * sparseDot vr B + wv * (sparseDot tl A * sparseDot vr B) =
490 wv * ((uv * A i + sparseDot tl A) * sparseDot vr B) := by
491 rw [Int.add_mul, Int.mul_add, Int.mul_assoc, Int.mul_assoc, Int.mul_assoc uv (A i) (sparseDot vr B)]
492 omega
493 have hOuter : ∀ (ws : SRow) (acc : SRow),
494 sparseDot (ws.foldl (fun a (r, wv) =>
495 (listGetD U r).foldl (fun acc2 (i, uv) =>
496 sparseAdd acc2 ((listGetD V r).map (fun (j, vv) => (i * nV + j, wv * uv * vv)))) a) acc) (pairProd nV A B) =
497 ws.foldl (fun a (r, wv) => a + wv * (sparseDot (listGetD U r) A * sparseDot (listGetD V r) B))
498 (sparseDot acc (pairProd nV A B)) := by
499 intro ws
500 induction ws with
501 | nil => intro acc; rfl
502 | cons hd tl ih =>
503 intro acc
504 rcases hd with ⟨r, wv⟩
505 simp only [List.foldl_cons]
506 rw [ih, hInner (listGetD U r) (listGetD V r) (listGetD_allColsLt nV V hV r) wv acc]
507 exact hOuter wRow []
508
509theorem sparseDot_expectedOutputK (n p a c : Nat) (hc : c < p) (A B : Nat → Int) :
510 sparseDot (expectedOutputK n p a c) (pairProd (n * p) A B) = exactMatmulEntry n p a c A B := by
511 unfold expectedOutputK exactMatmulEntry sparseDot
512 have h : ∀ (bs : List Nat) (hbs : ∀ b ∈ bs, b < n) (init : Int),
513 (bs.map (fun b => ((a * n + b) * (n * p) + (b * p + c), (1 : Int)))).foldl
514 (fun acc q => acc + q.2 * pairProd (n * p) A B q.1) init =
515 bs.foldl (fun acc b => acc + A (a * n + b) * B (b * p + c)) init := by
516 intro bs
517 induction bs with
518 | nil => intro _ init; rfl
519 | cons b tl ih =>
520 intro hbs init
521 have hb : b < n := hbs b (List.mem_cons_self ..)
522 have htl : ∀ x ∈ tl, x < n := fun x hx => hbs x (List.mem_cons_of_mem b hx)
523 simp only [List.map_cons, List.foldl_cons, Int.one_mul]
524 have hnp : n * p > 0 := Nat.mul_pos (Nat.lt_of_le_of_lt (Nat.zero_le b) hb) (Nat.lt_of_le_of_lt (Nat.zero_le c) hc)
525 have hlt : b * p + c < n * p := by
526 have h1 : (b + 1) * p ≤ n * p := Nat.mul_le_mul_right p hb
527 rw [Nat.add_mul, Nat.one_mul] at h1
528 omega
529 have hp : pairProd (n * p) A B ((a * n + b) * (n * p) + (b * p + c)) = A (a * n + b) * B (b * p + c) := by
530 unfold pairProd
531 have hdiv : ((a * n + b) * (n * p) + (b * p + c)) / (n * p) = a * n + b := by
532 rw [Nat.mul_comm (a * n + b) (n * p), Nat.mul_add_div hnp, Nat.div_eq_of_lt hlt, Nat.add_zero]
533 have hmod : ((a * n + b) * (n * p) + (b * p + c)) % (n * p) = b * p + c := by
534 rw [Nat.mul_comm (a * n + b) (n * p), Nat.mul_add_mod, Nat.mod_eq_of_lt hlt]
535 rw [hdiv, hmod]
536 rw [hp]
537 exact ih htl _
538 exact h (List.range n) (fun b hb => List.mem_range.mp hb) 0
539
540theorem fullSchemeValid_semantic_matmul (m n p R : Nat)
541 (uf : List Gate) (uo : List (List (Nat × Int)))
542 (vf : List Gate) (vo : List (List (Nat × Int)))
543 (wf : List Gate) (wo : List (List (Nat × Int)))
544 (hvalid : fullSchemeValid m n p R uf uo vf vo wf wo = true) :
545 ∀ (A B : Nat → Int) (a c : Nat), a < m → c < p →
546 evalDagMatmul m n p uf uo vf vo wf wo A B a c = exactMatmulEntry n p a c A B := by
547 unfold fullSchemeValid at hvalid
548 cases hU : evalDagToSparse (m * n) uf uo with
549 | mk okU U =>
550 cases hV : evalDagToSparse (n * p) vf vo with
551 | mk okV V =>
552 cases hW : evalDagToSparse R wf wo with
553 | mk okW W =>
554 rw [hU, hV, hW] at hvalid
555 simp only [Bool.and_eq_true, decide_eq_true_eq, beq_iff_eq] at hvalid
556 rcases hvalid with ⟨⟨⟨⟨⟨⟨⟨⟨⟨⟨⟨⟨hn, hp⟩, rfl⟩, rfl⟩, rfl⟩, hUlen⟩, hVlen⟩, _⟩, _⟩, _⟩, _⟩, hVcols⟩, hTensor⟩
557 intro A B a c ha hc
558 unfold evalDagMatmul
559 dsimp only
560 have hUrt := evalDagRuntime_eq_sparseDot (m * n) uf uo A U hU
561 have hVrt := evalDagRuntime_eq_sparseDot (n * p) vf vo B V hV
562 rw [hUrt, hVrt]
563 have hLenU : (U.map (fun r => sparseDot r A)).length = R := by rw [List.length_map, hUlen]
564 rw [hLenU]
565 have hWrt := evalDagRuntime_eq_sparseDot R wf wo
566 (fun r => intGetD (U.map (fun r => sparseDot r A)) r * intGetD (V.map (fun r => sparseDot r B)) r) W hW
567 rw [hWrt, intGetD_map_sparseDot]
568 have hDotEq :
569 sparseDot (listGetD W (a * p + c))
570 (fun r => intGetD (U.map (fun r => sparseDot r A)) r * intGetD (V.map (fun r => sparseDot r B)) r) =
571 evalBilinearK U V (listGetD W (a * p + c)) A B := by
572 have hf : (fun r => intGetD (U.map (fun r => sparseDot r A)) r * intGetD (V.map (fun r => sparseDot r B)) r) =
573 (fun r => sparseDot (listGetD U r) A * sparseDot (listGetD V r) B) := by
574 funext r
575 rw [intGetD_map_sparseDot, intGetD_map_sparseDot]
576 rw [hf]; rfl
577 rw [hDotEq]
578 have hnV : n * p > 0 := Nat.mul_pos hn hp
579 rw [← contractOutputK_sound (n * p) hnV U V hVcols (listGetD W (a * p + c)) A B]
580 unfold checkExactMatmulTensor at hTensor
581 have hA := List.all_eq_true.mp hTensor a (List.mem_range.mpr ha)
582 have hC := List.all_eq_true.mp hA c (List.mem_range.mpr hc)
583 have hSlice : contractOutputK (n * p) U V (listGetD W (a * p + c)) = expectedOutputK n p a c := by
584 simpa using hC
585 rw [hSlice]
586 exact sparseDot_expectedOutputK n p a c hc A B
587
588
589-- ============================================================================
590-- WORLD RECORD: 4x5x5 (R=76, Z_T): 258 additions < live Dec 2, 2026 record 268
591-- Source JSON: WR_wave2_4x5x5_m76_cr258_ZT.json
592-- ============================================================================
593def wr_w2_4x5x5_cr258_uf : List Gate := [(6, 1, 9, 1), (16, 1, 19, 1), (0, 1, 10, 1), (17, 1, 19, (-1 : Int)), (18, 1, 19, 1), (5, 1, 9, 1), (7, 1, 9, (-1 : Int)), (5, 1, 15, 1), (22, 1, 11, (-1 : Int)), (9, 1, 18, (-1 : Int)), (23, 1, 4, (-1 : Int)), (30, 1, 17, (-1 : Int)), (28, 1, 1, (-1 : Int)), (31, 1, 18, (-1 : Int)), (22, 1, 12, 1), (10, 1, 13, (-1 : Int)), (35, 1, 15, (-1 : Int)), (24, 1, 14, (-1 : Int)), (31, 1, 16, (-1 : Int)), (23, 1, 14, 1), (34, 1, 2, 1), (35, 1, 0, 1), (39, 1, 12, (-1 : Int)), (27, 1, 25, (-1 : Int)), (31, 1, 15, (-1 : Int)), (21, 1, 14, (-1 : Int)), (8, 1, 9, 1), (41, 1, 3, (-1 : Int)), (30, 1, 2, 1), (47, 1, 32, (-1 : Int)), (9, 1, 17, 1), (48, 1, 26, 1), (51, 1, 9, 1), (52, 1, 5, 1), (26, 1, 20, 1), (36, 1, 18, 1), (54, 1, 23, 1), (9, 1, 16, (-1 : Int)), (54, 1, 42, 1), (54, 1, 48, 1), (52, 1, 8, 1), (56, 1, 21, 1), (40, 1, 32, (-1 : Int)), (36, 1, 5, (-1 : Int)), (25, 1, 46, (-1 : Int)), (64, 1, 55, (-1 : Int)), (65, 1, 47, 1), (66, 1, 32, (-1 : Int)), (3, 1, 60, 1), (68, 1, 33, (-1 : Int)), (69, 1, 66, 1), (69, 1, 62, (-1 : Int)), (45, 1, 58, 1), (72, 1, 11, (-1 : Int)), (73, 1, 62, 1), (74, 1, 69, (-1 : Int)), (6, 1, 8, (-1 : Int)), (76, 1, 56, (-1 : Int)), (76, 1, 58, (-1 : Int)), (78, 1, 64, (-1 : Int)), (0, 1, 27, 1), (80, 1, 28, (-1 : Int)), (80, 1, 34, (-1 : Int)), (81, 1, 5, (-1 : Int)), (15, 1, 17, 1), (84, 1, 39, (-1 : Int))]
594def wr_w2_4x5x5_cr258_uo : List (List (Nat × Int)) := [
595 [(10, 1)],
596 [(21, (-1 : Int))],
597 [(16, (-1 : Int))],
598 [(44, 1)],
599 [(15, (-1 : Int))],
600 [(56, (-1 : Int))],
601 [(41, 1)],
602 [(37, (-1 : Int))],
603 [(11, 1)],
604 [(74, 1)],
605 [(70, 1)],
606 [(42, (-1 : Int))],
607 [(82, (-1 : Int))],
608 [(46, 1)],
609 [(27, (-1 : Int))],
610 [(55, 1)],
611 [(69, 1)],
612 [(75, 1)],
613 [(83, (-1 : Int))],
614 [(22, 1)],
615 [(18, (-1 : Int))],
616 [(73, (-1 : Int))],
617 [(32, 1)],
618 [(15, (-1 : Int))],
619 [(0, 1)],
620 [(9, 1)],
621 [(36, 1)],
622 [(71, (-1 : Int))],
623 [(31, (-1 : Int))],
624 [(77, 1)],
625 [(26, 1)],
626 [(25, 1)],
627 [(49, 1)],
628 [(79, 1)],
629 [(4, 1)],
630 [(61, (-1 : Int))],
631 [(40, 1)],
632 [(62, 1)],
633 [(14, 1)],
634 [(24, (-1 : Int))],
635 [(30, (-1 : Int))],
636 [(57, 1)],
637 [(59, 1)],
638 [(48, 1)],
639 [(50, (-1 : Int))],
640 [(20, 1)],
641 [(39, (-1 : Int))],
642 [(81, (-1 : Int))],
643 [(60, 1)],
644 [(13, 1)],
645 [(38, 1)],
646 [(43, (-1 : Int))],
647 [(75, 1)],
648 [(52, 1)],
649 [(67, (-1 : Int))],
650 [(35, 1)],
651 [(51, 1)],
652 [(23, (-1 : Int))],
653 [(66, 1)],
654 [(53, 1)],
655 [(54, 1)],
656 [(65, (-1 : Int))],
657 [(29, 1)],
658 [(58, (-1 : Int))],
659 [(34, 1)],
660 [(33, 1)],
661 [(45, (-1 : Int))],
662 [(28, 1)],
663 [(47, 1)],
664 [(85, (-1 : Int))],
665 [(12, 1)],
666 [(63, 1)],
667 [(78, 1)],
668 [(23, (-1 : Int))],
669 [(49, 1)],
670 [(14, 1)]
671]
672def wr_w2_4x5x5_cr258_vf : List Gate := [(5, 1, 8, 1), (8, 1, 13, (-1 : Int)), (5, 1, 15, 1), (27, 1, 10, (-1 : Int)), (13, 1, 14, 1), (29, 1, 10, 1), (25, 1, 6, (-1 : Int)), (26, 1, 23, (-1 : Int)), (30, 1, 11, (-1 : Int)), (28, 1, 20, (-1 : Int)), (4, 1, 19, 1), (17, 1, 19, (-1 : Int)), (34, 1, 0, 1), (3, 1, 4, 1), (38, 1, 2, (-1 : Int)), (39, 1, 37, 1), (29, 1, 26, 1), (41, 1, 24, 1), (32, 1, 15, (-1 : Int)), (27, 1, 25, (-1 : Int)), (44, 1, 16, (-1 : Int)), (31, 1, 14, 1), (7, 1, 17, 1), (47, 1, 2, 1), (33, 1, 12, (-1 : Int)), (49, 1, 48, 1), (34, 1, 1, 1), (51, 1, 37, (-1 : Int)), (38, 1, 35, (-1 : Int)), (40, 1, 20, 1), (33, 1, 22, 1), (55, 1, 49, (-1 : Int)), (55, 1, 11, 1), (35, 1, 7, 1), (45, 1, 13, 1), (46, 1, 24, 1), (58, 1, 4, (-1 : Int)), (51, 1, 20, 1), (46, 1, 6, 1), (59, 1, 23, 1), (63, 1, 24, 1), (50, 1, 11, 1), (53, 1, 17, 1), (59, 1, 16, 1), (9, 1, 31, 1), (69, 1, 60, (-1 : Int)), (70, 1, 7, (-1 : Int)), (69, 1, 35, 1), (72, 1, 6, 1), (72, 1, 4, (-1 : Int)), (71, 1, 24, 1), (50, 1, 72, (-1 : Int)), (18, 1, 32, 1), (77, 1, 36, (-1 : Int)), (77, 1, 64, 1), (79, 1, 3, 1), (78, 1, 23, 1), (78, 1, 17, 1), (80, 1, 16, 1), (40, 1, 78, 1), (20, 1, 22, (-1 : Int)), (23, 1, 85, 1), (86, 1, 24, 1), (87, 1, 21, (-1 : Int)), (76, 1, 80, (-1 : Int)), (89, 1, 52, 1), (56, 1, 71, 1), (91, 1, 84, 1), (88, 1, 92, 1), (93, 1, 90, 1)]
673def wr_w2_4x5x5_cr258_vo : List (List (Nat × Int)) := [
674 [(0, 1)],
675 [(42, (-1 : Int))],
676 [(70, 1)],
677 [(51, (-1 : Int))],
678 [(37, (-1 : Int))],
679 [(41, (-1 : Int))],
680 [(80, (-1 : Int))],
681 [(43, 1)],
682 [(73, 1)],
683 [(31, (-1 : Int))],
684 [(1, 1)],
685 [(30, 1)],
686 [(48, 1)],
687 [(81, 1)],
688 [(39, (-1 : Int))],
689 [(19, (-1 : Int))],
690 [(45, (-1 : Int))],
691 [(8, (-1 : Int))],
692 [(35, 1)],
693 [(90, 1)],
694 [(82, 1)],
695 [(25, 1)],
696 [(74, (-1 : Int))],
697 [(38, (-1 : Int))],
698 [(52, (-1 : Int))],
699 [(92, (-1 : Int))],
700 [(53, (-1 : Int))],
701 [(44, (-1 : Int))],
702 [(94, 1)],
703 [(26, (-1 : Int))],
704 [(12, 1)],
705 [(54, (-1 : Int))],
706 [(15, (-1 : Int))],
707 [(28, (-1 : Int))],
708 [(88, 1)],
709 [(8, (-1 : Int))],
710 [(49, (-1 : Int))],
711 [(27, (-1 : Int))],
712 [(87, 1)],
713 [(32, (-1 : Int))],
714 [(55, (-1 : Int))],
715 [(71, (-1 : Int))],
716 [(46, (-1 : Int))],
717 [(33, (-1 : Int))],
718 [(56, 1)],
719 [(75, (-1 : Int))],
720 [(57, (-1 : Int))],
721 [(58, 1)],
722 [(59, (-1 : Int))],
723 [(83, (-1 : Int))],
724 [(60, (-1 : Int))],
725 [(40, (-1 : Int))],
726 [(7, 1)],
727 [(94, 1)],
728 [(61, (-1 : Int))],
729 [(3, (-1 : Int))],
730 [(21, 1)],
731 [(22, (-1 : Int))],
732 [(47, (-1 : Int))],
733 [(62, (-1 : Int))],
734 [(14, 1)],
735 [(36, (-1 : Int))],
736 [(78, 1)],
737 [(63, 1)],
738 [(50, 1)],
739 [(64, (-1 : Int))],
740 [(65, 1)],
741 [(72, (-1 : Int))],
742 [(79, 1)],
743 [(34, (-1 : Int))],
744 [(66, 1)],
745 [(67, (-1 : Int))],
746 [(68, (-1 : Int))],
747 [(29, (-1 : Int))],
748 [(19, (-1 : Int))],
749 [(21, (-1 : Int))]
750]
751def wr_w2_4x5x5_cr258_wf : List Gate := [(11, 1, 63, (-1 : Int)), (61, 1, 71, (-1 : Int)), (14, 1, 77, 1), (35, 1, 39, (-1 : Int)), (79, 1, 55, (-1 : Int)), (29, 1, 80, (-1 : Int)), (5, 1, 80, (-1 : Int)), (1, 1, 39, (-1 : Int)), (83, 1, 57, 1), (84, 1, 82, 1), (23, 1, 26, (-1 : Int)), (86, 1, 57, (-1 : Int)), (18, 1, 87, 1), (73, 1, 82, (-1 : Int)), (72, 1, 76, 1), (67, 1, 88, 1), (43, 1, 64, (-1 : Int)), (92, 1, 70, 1), (43, 1, 48, (-1 : Int)), (11, 1, 46, 1), (8, 1, 88, 1), (7, 1, 76, (-1 : Int)), (6, 1, 43, 1), (0, 1, 49, (-1 : Int)), (15, 1, 60, 1), (50, 1, 85, (-1 : Int)), (21, 1, 63, (-1 : Int)), (102, 1, 66, (-1 : Int)), (103, 1, 85, (-1 : Int)), (47, 1, 88, (-1 : Int)), (4, 1, 89, (-1 : Int)), (2, 1, 87, (-1 : Int)), (107, 1, 100, 1), (20, 1, 26, (-1 : Int)), (109, 1, 89, (-1 : Int)), (110, 1, 100, (-1 : Int)), (62, 1, 77, 1), (112, 1, 81, 1), (113, 1, 111, (-1 : Int)), (14, 1, 51, (-1 : Int)), (115, 1, 81, (-1 : Int)), (116, 1, 106, 1), (41, 1, 108, 1), (17, 1, 81, (-1 : Int)), (27, 1, 119, 1), (16, 1, 65, 1), (121, 1, 94, 1), (122, 1, 119, (-1 : Int)), (9, 1, 42, (-1 : Int)), (124, 1, 101, 1), (54, 1, 74, 1), (126, 1, 105, 1), (38, 1, 95, 1), (128, 1, 97, 1), (129, 1, 104, 1), (33, 1, 90, (-1 : Int)), (52, 1, 118, 1), (132, 1, 127, (-1 : Int)), (34, 1, 40, (-1 : Int)), (69, 1, 130, (-1 : Int)), (59, 1, 131, 1), (32, 1, 49, 1), (137, 1, 90, 1), (138, 1, 120, (-1 : Int)), (3, 1, 134, 1), (140, 1, 135, (-1 : Int)), (25, 1, 114, 1), (142, 1, 117, 1), (12, 1, 70, (-1 : Int)), (144, 1, 78, (-1 : Int)), (10, 1, 37, (-1 : Int)), (146, 1, 120, 1), (147, 1, 136, 1), (148, 1, 141, (-1 : Int))]
752def wr_w2_4x5x5_cr258_wo : List (List (Nat × Int)) := [
753 [(24, 1), (134, 1), (149, 1)],
754 [(123, 1), (125, 1), (149, 1)],
755 [(36, 1), (40, (-1 : Int)), (58, 1), (93, (-1 : Int)), (127, 1), (145, (-1 : Int))],
756 [(68, (-1 : Int)), (98, (-1 : Int)), (123, 1)],
757 [(22, 1), (74, 1), (91, (-1 : Int)), (125, 1)],
758 [(31, (-1 : Int)), (117, (-1 : Int)), (131, (-1 : Int))],
759 [(42, 1), (53, (-1 : Int)), (56, (-1 : Int)), (94, (-1 : Int)), (136, (-1 : Int))],
760 [(30, 1), (133, 1), (143, (-1 : Int))],
761 [(13, 1), (114, (-1 : Int))],
762 [(45, (-1 : Int)), (133, 1)],
763 [(99, 1), (130, 1), (139, 1)],
764 [(19, 1), (24, 1), (75, (-1 : Int)), (91, (-1 : Int)), (93, 1), (96, 1), (98, (-1 : Int)), (99, 1)],
765 [(61, 1), (95, 1), (105, (-1 : Int)), (145, 1)],
766 [(97, (-1 : Int)), (139, (-1 : Int))],
767 [(96, 1), (104, (-1 : Int))],
768 [(21, (-1 : Int)), (106, 1), (135, (-1 : Int))],
769 [(21, (-1 : Int)), (28, (-1 : Int)), (65, (-1 : Int)), (101, (-1 : Int)), (141, 1)],
770 [(44, (-1 : Int)), (78, (-1 : Int)), (118, (-1 : Int)), (143, 1)],
771 [(111, (-1 : Int))],
772 [(85, 1), (108, (-1 : Int))]
773]
774
775theorem wr_w2_4x5x5_cr258_exact_bilinear_and_dag_valid :
776 fullSchemeValid 4 5 5 76 wr_w2_4x5x5_cr258_uf wr_w2_4x5x5_cr258_uo wr_w2_4x5x5_cr258_vf wr_w2_4x5x5_cr258_vo wr_w2_4x5x5_cr258_wf wr_w2_4x5x5_cr258_wo = true := by
777 decide
778
779/-- Universal Semantic Matrix-Multiplication Theorem for 4x5x5 (R=76, 258 additions):
780 For ALL arbitrary integer matrices A, B : Nat -> Int and ALL a < 4, c < 5,
781 executing the 258-addition straight-line DAG equals exact schoolbook (A * B)[a, c]! -/
782theorem wr_w2_4x5x5_cr258_semantic_matmul :
783 ∀ (A B : Nat → Int) (a c : Nat), a < 4 → c < 5 →
784 evalDagMatmul 4 5 5 wr_w2_4x5x5_cr258_uf wr_w2_4x5x5_cr258_uo wr_w2_4x5x5_cr258_vf wr_w2_4x5x5_cr258_vo wr_w2_4x5x5_cr258_wf wr_w2_4x5x5_cr258_wo A B a c =
785 exactMatmulEntry 5 5 a c A B :=
786 fullSchemeValid_semantic_matmul 4 5 5 76 _ _ _ _ _ _ wr_w2_4x5x5_cr258_exact_bilinear_and_dag_valid
787
788theorem wr_w2_4x5x5_cr258_beats_live_2026_record :
789 totalReducedAdds wr_w2_4x5x5_cr258_uf wr_w2_4x5x5_cr258_uo wr_w2_4x5x5_cr258_vf wr_w2_4x5x5_cr258_vo wr_w2_4x5x5_cr258_wf wr_w2_4x5x5_cr258_wo = 258 ∧ 258 < 268 := by
790 decide
791
792-- ============================================================================
793-- WORLD RECORD: 4x4x8 (R=96, Z_T): 323 additions < live Dec 2, 2026 record 330
794-- Source JSON: WR_wave2_4x4x8_m96_cr323_ZT.json
795-- ============================================================================
796def wr_w2_4x4x8_cr323_uf : List Gate := [(0, 1, 3, 1), (8, 1, 12, 1), (4, 1, 7, 1), (17, 1, 14, (-1 : Int)), (16, 1, 1, 1), (14, 1, 15, 1), (2, 1, 3, 1), (18, 1, 5, 1), (5, 1, 9, (-1 : Int)), (21, 1, 11, 1), (4, 1, 6, (-1 : Int)), (19, 1, 2, 1), (0, 1, 8, 1), (28, 1, 27, (-1 : Int)), (29, 1, 22, 1), (30, 1, 21, (-1 : Int)), (18, 1, 11, (-1 : Int)), (31, 1, 13, (-1 : Int)), (25, 1, 10, 1), (33, 1, 1, 1), (35, 1, 21, 1), (4, 1, 8, (-1 : Int)), (31, 1, 29, (-1 : Int)), (3, 1, 15, (-1 : Int)), (26, 1, 10, 1), (19, 1, 6, (-1 : Int)), (39, 1, 21, 1), (19, 1, 10, (-1 : Int)), (34, 1, 31, 1), (32, 1, 12, 1), (43, 1, 27, (-1 : Int)), (35, 1, 34, 1), (39, 1, 34, 1), (4, 1, 9, 1), (37, 1, 24, 1), (46, 1, 34, 1), (41, 1, 17, (-1 : Int)), (43, 1, 17, (-1 : Int)), (53, 1, 46, (-1 : Int)), (54, 1, 48, 1), (32, 1, 0, 1), (53, 1, 52, (-1 : Int)), (40, 1, 0, 1), (50, 1, 4, (-1 : Int)), (23, 1, 16, 1), (60, 1, 1, 1), (23, 1, 22, 1), (26, 1, 5, 1), (63, 1, 62, (-1 : Int)), (64, 1, 38, 1), (65, 1, 39, (-1 : Int)), (65, 1, 35, (-1 : Int)), (59, 1, 12, (-1 : Int)), (5, 1, 13, 1), (69, 1, 68, (-1 : Int)), (70, 1, 53, 1), (71, 1, 47, 1), (72, 1, 1, (-1 : Int)), (73, 1, 0, (-1 : Int)), (71, 1, 57, (-1 : Int)), (74, 1, 2, 1), (54, 1, 51, 1), (59, 1, 0, (-1 : Int)), (32, 1, 4, (-1 : Int)), (63, 1, 6, 1), (67, 1, 64, (-1 : Int)), (79, 1, 65, 1), (75, 1, 6, 1), (62, 1, 2, (-1 : Int)), (1, 1, 5, 1), (33, 1, 0, (-1 : Int)), (83, 1, 2, 1), (65, 1, 31, (-1 : Int)), (85, 1, 23, (-1 : Int))]
797def wr_w2_4x4x8_cr323_uo : List (List (Nat × Int)) := [
798 [(22, 1)],
799 [(34, 1)],
800 [(49, 1)],
801 [(75, (-1 : Int))],
802 [(76, 1)],
803 [(28, 1)],
804 [(66, 1)],
805 [(5, (-1 : Int))],
806 [(30, 1)],
807 [(50, 1)],
808 [(51, (-1 : Int))],
809 [(37, 1)],
810 [(52, (-1 : Int))],
811 [(1, 1)],
812 [(65, (-1 : Int))],
813 [(20, 1)],
814 [(38, 1)],
815 [(53, (-1 : Int))],
816 [(32, 1)],
817 [(17, 1)],
818 [(67, (-1 : Int))],
819 [(24, (-1 : Int))],
820 [(54, 1)],
821 [(55, 1)],
822 [(56, 1)],
823 [(57, 1)],
824 [(58, 1)],
825 [(59, (-1 : Int))],
826 [(68, (-1 : Int))],
827 [(60, 1)],
828 [(77, (-1 : Int))],
829 [(64, (-1 : Int))],
830 [(13, 1)],
831 [(69, 1)],
832 [(4, 1)],
833 [(78, (-1 : Int))],
834 [(79, (-1 : Int))],
835 [(35, 1)],
836 [(24, (-1 : Int))],
837 [(80, 1)],
838 [(81, (-1 : Int))],
839 [(61, 1)],
840 [(39, (-1 : Int))],
841 [(26, 1)],
842 [(70, 1)],
843 [(21, (-1 : Int))],
844 [(33, 1)],
845 [(40, 1)],
846 [(27, 1)],
847 [(82, (-1 : Int))],
848 [(62, 1)],
849 [(44, 1)],
850 [(72, 1)],
851 [(1, (-1 : Int))],
852 [(37, 1)],
853 [(63, 1)],
854 [(18, 1)],
855 [(3, (-1 : Int))],
856 [(83, 1)],
857 [(22, 1)],
858 [(9, (-1 : Int))],
859 [(16, 1)],
860 [(36, 1)],
861 [(73, 1)],
862 [(84, 1)],
863 [(41, (-1 : Int))],
864 [(20, 1)],
865 [(46, (-1 : Int))],
866 [(10, 1)],
867 [(14, (-1 : Int))],
868 [(85, (-1 : Int))],
869 [(17, 1)],
870 [(31, 1)],
871 [(25, (-1 : Int))],
872 [(42, (-1 : Int))],
873 [(86, 1)],
874 [(34, 1)],
875 [(23, 1)],
876 [(45, 1)],
877 [(8, 1)],
878 [(23, 1)],
879 [(47, 1)],
880 [(87, 1)],
881 [(19, 1)],
882 [(57, 1)],
883 [(35, 1)],
884 [(71, 1)],
885 [(29, 1)],
886 [(4, 1)],
887 [(88, (-1 : Int))],
888 [(89, (-1 : Int))],
889 [(5, (-1 : Int))],
890 [(74, 1)],
891 [(43, 1)],
892 [(54, 1)],
893 [(48, (-1 : Int))]
894]
895def wr_w2_4x4x8_cr323_vf : List Gate := [(8, 1, 26, (-1 : Int)), (10, 1, 15, (-1 : Int)), (19, 1, 27, (-1 : Int)), (0, 1, 8, (-1 : Int)), (32, 1, 18, 1), (22, 1, 29, (-1 : Int)), (4, 1, 12, (-1 : Int)), (24, 1, 26, (-1 : Int)), (29, 1, 30, (-1 : Int)), (22, 1, 31, 1), (33, 1, 2, (-1 : Int)), (42, 1, 15, 1), (43, 1, 14, 1), (33, 1, 26, (-1 : Int)), (34, 1, 11, 1), (9, 1, 12, 1), (4, 1, 28, (-1 : Int)), (40, 1, 37, 1), (40, 1, 6, 1), (43, 1, 13, 1), (22, 1, 23, 1), (21, 1, 22, (-1 : Int)), (51, 1, 5, (-1 : Int)), (34, 1, 3, 1), (55, 1, 48, (-1 : Int)), (53, 1, 52, 1), (56, 1, 20, (-1 : Int)), (47, 1, 11, (-1 : Int)), (2, 1, 8, (-1 : Int)), (59, 1, 26, (-1 : Int)), (50, 1, 5, (-1 : Int)), (45, 1, 18, 1), (47, 1, 4, (-1 : Int)), (35, 1, 1, 1), (64, 1, 25, (-1 : Int)), (56, 1, 28, (-1 : Int)), (61, 1, 18, 1), (62, 1, 57, (-1 : Int)), (42, 1, 7, 1), (40, 1, 14, 1), (44, 1, 6, (-1 : Int)), (39, 1, 22, (-1 : Int)), (65, 1, 9, (-1 : Int)), (69, 1, 52, 1), (67, 1, 12, 1), (70, 1, 1, 1), (65, 1, 25, (-1 : Int)), (78, 1, 17, 1), (71, 1, 13, (-1 : Int)), (76, 1, 46, (-1 : Int)), (77, 1, 25, (-1 : Int)), (82, 1, 17, 1), (83, 1, 70, (-1 : Int)), (81, 1, 9, 1), (85, 1, 25, (-1 : Int)), (86, 1, 17, 1), (84, 1, 54, 1), (88, 1, 17, (-1 : Int)), (63, 1, 83, (-1 : Int)), (17, 1, 20, 1), (91, 1, 16, 1), (92, 1, 19, (-1 : Int)), (93, 1, 34, 1), (78, 1, 92, 1), (24, 1, 95, (-1 : Int)), (96, 1, 8, (-1 : Int)), (97, 1, 20, 1), (97, 1, 28, 1), (99, 1, 12, (-1 : Int)), (30, 1, 31, 1), (101, 1, 6, (-1 : Int)), (101, 1, 14, (-1 : Int)), (36, 1, 60, 1), (104, 1, 44, 1), (104, 1, 51, 1), (106, 1, 18, (-1 : Int)), (23, 1, 90, (-1 : Int)), (108, 1, 31, (-1 : Int)), (109, 1, 20, 1), (110, 1, 28, (-1 : Int)), (7, 1, 102, (-1 : Int)), (112, 1, 69, (-1 : Int)), (113, 1, 110, (-1 : Int)), (31, 1, 102, (-1 : Int)), (115, 1, 39, 1), (25, 1, 28, 1), (27, 1, 117, (-1 : Int)), (118, 1, 26, 1), (118, 1, 24, (-1 : Int)), (16, 1, 22, (-1 : Int)), (121, 1, 18, (-1 : Int)), (23, 1, 91, 1), (123, 1, 18, (-1 : Int))]
896def wr_w2_4x4x8_cr323_vo : List (List (Nat × Int)) := [
897 [(124, (-1 : Int))],
898 [(22, 1)],
899 [(76, 1)],
900 [(36, (-1 : Int))],
901 [(34, (-1 : Int))],
902 [(54, (-1 : Int))],
903 [(97, (-1 : Int))],
904 [(74, 1)],
905 [(82, (-1 : Int))],
906 [(60, 1)],
907 [(37, 1)],
908 [(55, 1)],
909 [(98, (-1 : Int))],
910 [(80, (-1 : Int))],
911 [(39, 1)],
912 [(33, (-1 : Int))],
913 [(29, (-1 : Int))],
914 [(58, 1)],
915 [(102, 1)],
916 [(72, (-1 : Int))],
917 [(32, (-1 : Int))],
918 [(46, (-1 : Int))],
919 [(114, (-1 : Int))],
920 [(19, 1)],
921 [(50, (-1 : Int))],
922 [(122, 1)],
923 [(62, (-1 : Int))],
924 [(42, (-1 : Int))],
925 [(44, (-1 : Int))],
926 [(65, 1)],
927 [(49, (-1 : Int))],
928 [(92, 1)],
929 [(38, (-1 : Int))],
930 [(14, (-1 : Int))],
931 [(113, 1)],
932 [(51, (-1 : Int))],
933 [(116, 1)],
934 [(47, 1)],
935 [(43, (-1 : Int))],
936 [(100, (-1 : Int))],
937 [(107, (-1 : Int))],
938 [(8, 1)],
939 [(48, 1)],
940 [(57, (-1 : Int))],
941 [(105, (-1 : Int))],
942 [(31, 1)],
943 [(64, 1)],
944 [(69, (-1 : Int))],
945 [(88, (-1 : Int))],
946 [(73, 1)],
947 [(94, (-1 : Int))],
948 [(86, (-1 : Int))],
949 [(59, 1)],
950 [(9, 1)],
951 [(35, (-1 : Int))],
952 [(93, 1)],
953 [(103, 1)],
954 [(111, 1)],
955 [(63, (-1 : Int))],
956 [(27, 1)],
957 [(81, 1)],
958 [(77, 1)],
959 [(45, (-1 : Int))],
960 [(85, 1)],
961 [(99, (-1 : Int))],
962 [(79, 1)],
963 [(40, (-1 : Int))],
964 [(53, (-1 : Int))],
965 [(52, 1)],
966 [(109, 1)],
967 [(13, (-1 : Int))],
968 [(84, 1)],
969 [(66, (-1 : Int))],
970 [(41, 1)],
971 [(110, 1)],
972 [(4, (-1 : Int))],
973 [(119, (-1 : Int))],
974 [(14, 1)],
975 [(6, 1)],
976 [(70, (-1 : Int))],
977 [(120, (-1 : Int))],
978 [(61, (-1 : Int))],
979 [(106, (-1 : Int))],
980 [(83, (-1 : Int))],
981 [(75, 1)],
982 [(26, (-1 : Int))],
983 [(68, (-1 : Int))],
984 [(89, (-1 : Int))],
985 [(38, (-1 : Int))],
986 [(78, 1)],
987 [(71, (-1 : Int))],
988 [(15, 1)],
989 [(67, 1)],
990 [(87, (-1 : Int))],
991 [(20, (-1 : Int))],
992 [(56, 1)]
993]
994def wr_w2_4x4x8_cr323_wf : List Gate := [(1, 1, 38, 1), (69, 1, 74, (-1 : Int)), (57, 1, 97, 1), (5, 1, 48, (-1 : Int)), (99, 1, 94, (-1 : Int)), (87, 1, 100, (-1 : Int)), (79, 1, 83, (-1 : Int)), (8, 1, 102, (-1 : Int)), (61, 1, 103, 1), (15, 1, 62, (-1 : Int)), (27, 1, 91, (-1 : Int)), (58, 1, 105, (-1 : Int)), (107, 1, 106, (-1 : Int)), (28, 1, 33, 1), (44, 1, 108, (-1 : Int)), (110, 1, 109, (-1 : Int)), (71, 1, 111, 1), (60, 1, 95, 1), (92, 1, 98, 1), (114, 1, 113, 1), (75, 1, 98, 1), (53, 1, 94, (-1 : Int)), (46, 1, 116, (-1 : Int)), (32, 1, 116, 1), (10, 1, 16, (-1 : Int)), (120, 1, 24, (-1 : Int)), (45, 1, 73, (-1 : Int)), (18, 1, 122, 1), (56, 1, 123, (-1 : Int)), (90, 1, 124, (-1 : Int)), (35, 1, 70, (-1 : Int)), (82, 1, 108, (-1 : Int)), (127, 1, 126, (-1 : Int)), (52, 1, 81, 1), (77, 1, 124, 1), (33, 1, 78, (-1 : Int)), (131, 1, 130, 1), (72, 1, 118, 1), (133, 1, 119, 1), (51, 1, 60, 1), (135, 1, 63, 1), (14, 1, 49, (-1 : Int)), (42, 1, 119, (-1 : Int)), (20, 1, 41, 1), (6, 1, 12, 1), (3, 1, 139, (-1 : Int)), (2, 1, 60, 1), (142, 1, 88, (-1 : Int)), (4, 1, 59, (-1 : Int)), (144, 1, 115, 1), (23, 1, 145, 1), (31, 1, 50, 1), (147, 1, 59, (-1 : Int)), (37, 1, 118, (-1 : Int)), (38, 1, 86, (-1 : Int)), (150, 1, 129, (-1 : Int)), (36, 1, 137, 1), (11, 1, 115, 1), (153, 1, 143, (-1 : Int)), (84, 1, 152, (-1 : Int)), (47, 1, 68, (-1 : Int)), (156, 1, 155, (-1 : Int)), (64, 1, 98, 1), (158, 1, 140, 1), (80, 1, 148, 1), (160, 1, 159, 1), (29, 1, 104, (-1 : Int)), (162, 1, 161, (-1 : Int)), (89, 1, 163, (-1 : Int)), (65, 1, 164, (-1 : Int)), (54, 1, 165, 1), (40, 1, 128, 1), (13, 1, 43, (-1 : Int)), (168, 1, 125, 1), (169, 1, 157, (-1 : Int)), (26, 1, 155, (-1 : Int)), (171, 1, 170, 1), (67, 1, 121, (-1 : Int)), (173, 1, 172, (-1 : Int))]
995def wr_w2_4x4x8_cr323_wo : List (List (Nat × Int)) := [
996 [(31, 1), (41, 1), (101, 1), (140, 1), (163, 1)],
997 [(101, (-1 : Int)), (104, 1), (117, (-1 : Int))],
998 [(167, (-1 : Int))],
999 [(52, (-1 : Int)), (63, 1), (113, 1), (145, (-1 : Int)), (149, 1)],
1000 [(117, 1), (149, 1)],
1001 [(174, (-1 : Int))],
1002 [(66, 1), (121, 1), (125, 1)],
1003 [(0, (-1 : Int)), (15, 1), (97, (-1 : Int)), (101, 1), (103, (-1 : Int)), (167, (-1 : Int))],
1004 [(166, (-1 : Int))],
1005 [(7, 1), (161, 1), (166, 1)],
1006 [(9, 1), (108, (-1 : Int)), (141, (-1 : Int))],
1007 [(21, 1), (55, 1), (143, 1), (148, 1)],
1008 [(39, 1), (88, (-1 : Int)), (159, (-1 : Int))],
1009 [(70, 1), (170, (-1 : Int))],
1010 [(130, 1), (152, 1)],
1011 [(34, 1), (91, (-1 : Int)), (123, 1), (157, (-1 : Int))],
1012 [(25, (-1 : Int)), (96, 1), (137, (-1 : Int)), (141, 1), (151, (-1 : Int)), (165, (-1 : Int))],
1013 [(93, 1), (104, (-1 : Int)), (136, 1)],
1014 [(108, (-1 : Int)), (151, (-1 : Int))],
1015 [(146, 1), (154, (-1 : Int))],
1016 [(17, (-1 : Int)), (154, (-1 : Int))],
1017 [(5, 1), (24, 1), (96, 1), (126, (-1 : Int)), (172, (-1 : Int))],
1018 [(19, 1), (96, 1), (109, (-1 : Int)), (132, 1)],
1019 [(68, 1), (79, (-1 : Int)), (96, (-1 : Int)), (106, 1), (122, 1)],
1020 [(12, 1), (14, 1), (71, (-1 : Int)), (85, 1), (139, 1), (164, (-1 : Int))],
1021 [(71, 1), (104, 1), (134, (-1 : Int))],
1022 [(85, 1), (111, (-1 : Int))],
1023 [(76, (-1 : Int)), (85, (-1 : Int)), (129, (-1 : Int)), (134, (-1 : Int)), (136, 1), (138, (-1 : Int)), (146, (-1 : Int))],
1024 [(138, (-1 : Int))],
1025 [(16, 1), (22, 1), (100, (-1 : Int)), (112, 1), (128, (-1 : Int)), (174, (-1 : Int))],
1026 [(30, (-1 : Int)), (132, (-1 : Int))],
1027 [(45, (-1 : Int)), (69, (-1 : Int)), (102, 1), (105, 1), (112, (-1 : Int))]
1028]
1029
1030theorem wr_w2_4x4x8_cr323_exact_bilinear_and_dag_valid :
1031 fullSchemeValid 4 4 8 96 wr_w2_4x4x8_cr323_uf wr_w2_4x4x8_cr323_uo wr_w2_4x4x8_cr323_vf wr_w2_4x4x8_cr323_vo wr_w2_4x4x8_cr323_wf wr_w2_4x4x8_cr323_wo = true := by
1032 decide
1033
1034/-- Universal Semantic Matrix-Multiplication Theorem for 4x4x8 (R=96, 323 additions):
1035 For ALL arbitrary integer matrices A, B : Nat -> Int and ALL a < 4, c < 8,
1036 executing the 323-addition straight-line DAG equals exact schoolbook (A * B)[a, c]! -/
1037theorem wr_w2_4x4x8_cr323_semantic_matmul :
1038 ∀ (A B : Nat → Int) (a c : Nat), a < 4 → c < 8 →
1039 evalDagMatmul 4 4 8 wr_w2_4x4x8_cr323_uf wr_w2_4x4x8_cr323_uo wr_w2_4x4x8_cr323_vf wr_w2_4x4x8_cr323_vo wr_w2_4x4x8_cr323_wf wr_w2_4x4x8_cr323_wo A B a c =
1040 exactMatmulEntry 4 8 a c A B :=
1041 fullSchemeValid_semantic_matmul 4 4 8 96 _ _ _ _ _ _ wr_w2_4x4x8_cr323_exact_bilinear_and_dag_valid
1042
1043theorem wr_w2_4x4x8_cr323_beats_live_2026_record :
1044 totalReducedAdds wr_w2_4x4x8_cr323_uf wr_w2_4x4x8_cr323_uo wr_w2_4x4x8_cr323_vf wr_w2_4x4x8_cr323_vo wr_w2_4x4x8_cr323_wf wr_w2_4x4x8_cr323_wo = 323 ∧ 323 < 330 := by
1045 decide
1046
1047-- ============================================================================
1048-- BROKEN-MODEL NEGATIVE CONTROLS (>= 4 mandatory controls, pure kernel decide)
1049-- ============================================================================
1050def flipGate0 : List Gate → List Gate
1051 | (a, sa, b, sb) :: rest => (a, sa, b, -sb) :: rest
1052 | [] => []
1053
1054def flipOut0 : List (List (Nat × Int)) → List (List (Nat × Int))
1055 | ((ix, s) :: rt) :: rest => ((ix, -s) :: rt) :: rest
1056 | other => other
1057
1058theorem neg_ctrl_1_wr_w2_4x5x5_cr258_corrupt_u_fresh_gate :
1059 fullSchemeValid 4 5 5 76 (flipGate0 wr_w2_4x5x5_cr258_uf) wr_w2_4x5x5_cr258_uo wr_w2_4x5x5_cr258_vf wr_w2_4x5x5_cr258_vo wr_w2_4x5x5_cr258_wf wr_w2_4x5x5_cr258_wo = false := by
1060 decide
1061
1062theorem neg_ctrl_2_wr_w2_4x5x5_cr258_corrupt_v_fresh_gate :
1063 fullSchemeValid 4 5 5 76 wr_w2_4x5x5_cr258_uf wr_w2_4x5x5_cr258_uo (flipGate0 wr_w2_4x5x5_cr258_vf) wr_w2_4x5x5_cr258_vo wr_w2_4x5x5_cr258_wf wr_w2_4x5x5_cr258_wo = false := by
1064 decide
1065
1066theorem neg_ctrl_3_wr_w2_4x5x5_cr258_corrupt_w_fresh_gate :
1067 fullSchemeValid 4 5 5 76 wr_w2_4x5x5_cr258_uf wr_w2_4x5x5_cr258_uo wr_w2_4x5x5_cr258_vf wr_w2_4x5x5_cr258_vo (flipGate0 wr_w2_4x5x5_cr258_wf) wr_w2_4x5x5_cr258_wo = false := by
1068 decide
1069
1070theorem neg_ctrl_4_wr_w2_4x5x5_cr258_corrupt_u_output_sign :
1071 fullSchemeValid 4 5 5 76 wr_w2_4x5x5_cr258_uf (flipOut0 wr_w2_4x5x5_cr258_uo) wr_w2_4x5x5_cr258_vf wr_w2_4x5x5_cr258_vo wr_w2_4x5x5_cr258_wf wr_w2_4x5x5_cr258_wo = false := by
1072 decide
1073
1074theorem neg_ctrl_5_wr_w2_4x4x8_cr323_corrupt_w_output_sign :
1075 fullSchemeValid 4 4 8 96 wr_w2_4x4x8_cr323_uf wr_w2_4x4x8_cr323_uo wr_w2_4x4x8_cr323_vf wr_w2_4x4x8_cr323_vo wr_w2_4x4x8_cr323_wf (flipOut0 wr_w2_4x4x8_cr323_wo) = false := by
1076 decide
1077
1078end FmmWorldRecordsWave2
1079
1080#print axioms FmmWorldRecordsWave2.fullSchemeValid_semantic_matmul
1081#print axioms FmmWorldRecordsWave2.wr_w2_4x5x5_cr258_semantic_matmul
1082#print axioms FmmWorldRecordsWave2.wr_w2_4x5x5_cr258_beats_live_2026_record
1083#print axioms FmmWorldRecordsWave2.wr_w2_4x4x8_cr323_semantic_matmul
1084#print axioms FmmWorldRecordsWave2.wr_w2_4x4x8_cr323_beats_live_2026_record
1085#print axioms FmmWorldRecordsWave2.neg_ctrl_1_wr_w2_4x5x5_cr258_corrupt_u_fresh_gate