code wiki / _hdl_build / nx_research_strassen4_gate.nx

nx_research_strassen4_gate.nx

buildroot/runtime/_hdl_build/nx_research_strassen4_gate.nx

8274 B133 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic research
docsdependenciesstructsconstsfunctions

about

nx_research_strassen4_gate.nx -- from REPRODUCTION toward DISCOVERY: show WHY finding low-multiplication schemes matters. Strassen's 2x2 saving (7 mults instead of 8) COMPOUNDS recursively: a 4x4 product done by block-Strassen (2x2 blocks of 2x2 blocks) costs 7x7 = 49 scalar multiplications instead of the naive 4^3 = 64. The TESTING-TEAM runs both, proves block-Strassen == naive bit-exact (independent KAT A*I=A and I*B=B, plus random matrices), COUNTS the multiplications (49 vs 64 = the compounding payoff), and the VERIFIER liar-kill rejects a deliberately-broken recursive scheme. This is the substrate an alphatensor-class search rides on: a candidate scheme is only "discovered" once this exact-comparison gate certifies it. Exact integer, no float, deterministic. GREEN iff 6/6. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_research_strassen4_gate.nx

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 mm4_strassen blk get_block bl_add bl_strassen rs_mul bl_sub set_block eq16 rs_rng mm4_naive rs_mul ↻ g_n g_w ↻ sys_mmap ↻ sys_write ↻ g_row g_w ↻ sys_exit

structs

none

consts

none

functions

11func 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
12func 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
13func 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
15func rs_mul(cnt: *i64, a: i64, b: i64) -> i64 { cnt[0] = cnt[0] + 1; return a * b }
16func rs_rng(state: *i64) -> i64 { var x: i64 = state[0]; x = x ^ (x << 13); x = x ^ (x >> 7); x = x ^ (x << 17); state[0] = x; return x }
called by 1: main
19func bl_add(x: *i64, y: *i64, o: *i64) -> i64 { o[0]=x[0]+y[0]; o[1]=x[1]+y[1]; o[2]=x[2]+y[2]; o[3]=x[3]+y[3]; return 0 }
called by 1: mm4_strassen
20func bl_sub(x: *i64, y: *i64, o: *i64) -> i64 { o[0]=x[0]-y[0]; o[1]=x[1]-y[1]; o[2]=x[2]-y[2]; o[3]=x[3]-y[3]; return 0 }
called by 1: mm4_strassen
22func bl_strassen(x: *i64, y: *i64, o: *i64, cnt: *i64) -> i64
called by 1: mm4_strassen calls 1: rs_mul
35func blk(sc: *i64, i: i64) -> *i64 { return ((sc as i64) + i*32) as *i64 }
called by 1: mm4_strassen
37func get_block(m16: *i64, br: i64, bc: i64, out: *i64) -> i64
called by 1: mm4_strassen
41func set_block(m16: *i64, br: i64, bc: i64, b: *i64) -> i64
called by 1: mm4_strassen
47func mm4_naive(a: *i64, b: *i64, c: *i64, cnt: *i64) -> i64
called by 1: main calls 1: rs_mul
53func mm4_strassen(a: *i64, b: *i64, c: *i64, cnt: *i64, sc: *i64, bad: i64) -> i64
77func eq16(x: *i64, y: *i64) -> i64 { var i: i64=0; while i<16 { if x[i]!=y[i]{return 0} i=i+1 } return 1 }
called by 1: main
79func main() -> i64