code wiki / _hdl_build / nx_research_flip_discover_gate.nx

nx_research_flip_discover_gate.nx

buildroot/runtime/_hdl_build/nx_research_flip_discover_gate.nx

12083 B214 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic research
docsdependenciesstructsconstsfunctions

about

nx_research_flip_discover_gate.nx -- the FLAGSHIP discovery: genuinely DISCOVER a faster matrix-multiplication scheme by SEARCH (not certify a supplied one), the modern AlphaTensor-class method done sovereignly. Exhaustive search can't reach Strassen's rank-7 for <2,2,2> (the coefficient space is astronomical). The FLIP-GRAPH local search (Kauers & Moosbauer 2022 -- how recent matmul rank records were set WITHOUT RL) can: a decomposition of the matmul tensor T over GF(2) is a multiset of rank-1 triples (u_r,v_r,w_r) summing to T. FLIP : two triples sharing one factor, e.g. (a,v1,w1)+(a,v2,w2) = (a,v1,w1+w2)+(a,v1+v2,w2) over GF(2) -- rank-preserving (2 terms -> 2 terms), a random-walk neighbor. REDUCE : when a flip makes a factor 0 (term vanishes) or two triples coincide (cancel over GF(2)), the rank DROPS. Flips never raise rank, reductions only lower it -> rank is monotone non-increasing, so the walk only needs to find ONE 8->7 reduction (easy for <2,2,2>; 6 is impossible -> floor 7). Start from the naive rank-8 scheme, random-walk with a deterministic PRNG until rank 7 is DISCOVERED, then the Brent-equation verifier (over GF(2)) certifies the discovered scheme computes <2,2,2> exactly + a random-input cross-check. LIAR-KILL: a broken scheme is rejected. HONEST SCOPE: 7 is the proven optimum for 2x2 (Hopcroft-Kerr/Winograd, cited); we discover it sovereignly -- we do NOT claim AlphaTensor's larger records. GREEN iff 7/7. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_research_flip_discover_gate

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap g_w sys_write build_t build_naive brent_gf2 bitof copy_scheme do_flip rpos xrng run_search sys_mmap ↻ build_naive ↻ copy_scheme ↻ do_flip ↻ reduce_pass g_n g_w ↻ sys_mmap ↻ sys_write ↻ mm_verify_gf2 sys_mmap ↻ rpos ↻ bitof ↻ g_row g_w ↻ sys_exit

structs

none

consts

none

functions

19func g_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 3: g_ng_rowmain calls 1: sys_write
20func g_n(v: i64) -> i64 { var m: i64=v; if m<0{g_w("-");m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1}; sys_write(1,o,k); return 0 }
called by 1: main calls 3: g_wsys_mmapsys_write
21func g_row(id: *u8, ok: i64, pass: *i64) -> i64 { g_w(" "); g_w(id); g_w(": "); if ok==1 { g_w("OK\n"); pass[0]=pass[0]+1 } else { g_w("FAIL\n") } return 0 }
called by 1: main calls 1: g_w
23func bitof(x: i64, i: i64) -> i64 { return (x>>i)&1 }
24func xrng(s: *i64) -> i64 { var x: i64=s[0]; x = x ^ (x << 13); x = x ^ (x >> 7); x = x ^ (x << 17); s[0]=x; return x }
called by 1: rpos
25func rpos(s: *i64) -> i64 { let v: i64 = xrng(s); return v & 0x3FFFFFFFFFFFFFFF }
called by 2: do_flipmm_verify_gf2 calls 1: xrng
28func build_t(t: *i64) -> i64
called by 1: main
40func build_naive(U: *i64, V: *i64, W: *i64) -> i64
called by 2: run_searchmain
50func brent_gf2(U: *i64, V: *i64, W: *i64, R: i64, t: *i64) -> i64
called by 1: main calls 1: bitof
63func copy_scheme(sU: *i64, sV: *i64, sW: *i64, dU: *i64, dV: *i64, dW: *i64, R: i64) -> i64 { var i: i64=0; while i<R { dU[i]=sU[i]; dV[i]=sV[i]; dW[i]=sW[i]; i=i+1 } return 0 }
called by 2: run_searchmain
66func reduce_pass(U: *i64, V: *i64, W: *i64, rp: *i64) -> i64
called by 1: run_search
96func do_flip(U: *i64, V: *i64, W: *i64, rp: *i64, st: *i64, cand: *i64) -> i64
called by 2: run_searchmain calls 1: rpos
136func mm_verify_gf2(U: *i64, V: *i64, W: *i64, R: i64, st: *i64) -> i64
called by 1: main calls 3: sys_mmaprposbitof
158func main() -> i64