nx_nofloat_multistep_gate.nx source
↩ module page · 62 lines · 4507 B
1// nx_nofloat_multistep_gate.nx -- WHY no-float wins the MULTI-STEP-LOGIC arena (operator thesis 2026-06-18).
2// The exceed isn't raw IQ -- it's that a long chain of EXACT, reproducible steps lets logic compound
3// reliably, where float DRIFTS step-by-step until the chain is wrong. Proof: a 1000-step chain where each
4// step is the trivial logical op "(s + BIG) - BIG + 1" = net +1. Integer does it EXACTLY (s = N every
5// length); float (BIG=2^24, ulp=2) loses each +1 inside the BIG+-BIG round-off -> s STAYS ~1 forever, the
6// error compounds, the chain is wrong -- and the gap GROWS with chain length. This is the capability that
7// matters for multi-step functional/math reasoning + for a system that builds capabilities PIECE BY PIECE
8// (each proven step must feed the next on solid ground). No hw writes (Rule 26). expect_exit: 0 tier: ORIGINAL
9import "nx_syscalls.nx"
10import "nx_gate_verdict.nx"
11
12const BIG: i64 = 16777216 // 2^24 -- ulp here is 2, so +1 vanishes in float
13
14func ms_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
15func ms_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); 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; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
16
17// integer chain: s = ((s+BIG)-BIG)+1, N steps -> exact N
18func int_chain(N: i64) -> i64 { var s: i64=0; var n: i64=0; while n<N { s=(s+BIG)-BIG+1; n=n+1 } return s }
19// float chain: same ops in hardware f32 -> drifts
20func flt_chain(N: i64) -> i64 {
21 let bigf: i64 = __f32_from_i64(BIG)
22 let nbigf: i64 = __f32_from_i64(0-BIG)
23 let onef: i64 = __f32_from_i64(1)
24 var s: i64 = __f32_from_i64(0)
25 var n: i64 = 0
26 while n<N { s = __f32_add(__f32_add(s, bigf), nbigf); s = __f32_add(s, onef); n=n+1 }
27 return __f32_to_i64(s)
28}
29
30func main() -> i64 {
31 ms_puts("MULTI-STEP LOGIC arena: 1000-step chain (each step nets +1) -- integer EXACT vs float DRIFT\n\n" as *u8)
32
33 let i10: i64=int_chain(10); let f10: i64=flt_chain(10)
34 let i100: i64=int_chain(100); let f100: i64=flt_chain(100)
35 let i1k: i64=int_chain(1000); let f1k: i64=flt_chain(1000)
36 let i1k2: i64=int_chain(1000) // reproduce
37
38 ms_puts(" steps no-float(exact) float(drift) gap\n");
39 ms_puts(" 10 "); ms_num(i10); ms_puts(" "); ms_num(f10); ms_puts(" "); ms_num(i10-f10); ms_puts("\n");
40 ms_puts(" 100 "); ms_num(i100); ms_puts(" "); ms_num(f100); ms_puts(" "); ms_num(i100-f100); ms_puts("\n");
41 ms_puts(" 1000 "); ms_num(i1k); ms_puts(" "); ms_num(f1k); ms_puts(" "); ms_num(i1k-f1k); ms_puts("\n\n");
42 ms_puts(" float is STUCK (~1) -- every +1 erased inside BIG+-BIG round-off; the longer the chain the more wrong.\n");
43 ms_puts(" no-float is EXACT at every length AND reproducible -> a logical chain you can build on, step after step.\n\n");
44
45 var pass: i64=0
46 var ttl: i64=0
47 ttl=ttl+1; ms_puts(" T1 no-float EXACT over a 1000-step chain (s == 1000): "); if i1k==1000 { pass=pass+1; ms_puts("PASS\n") } else { ms_puts("FAIL\n") }
48 ttl=ttl+1; ms_puts(" T2 no-float REPRODUCIBLE (rerun bit-identical): "); if i1k==i1k2 { pass=pass+1; ms_puts("PASS\n") } else { ms_puts("FAIL\n") }
49 ttl=ttl+1; ms_puts(" T3 FLOAT chain COLLAPSED (drifted to <=2, lost ~all 1000 increments): "); if f1k<=2 { pass=pass+1; ms_puts("PASS\n") } else { ms_puts("FAIL\n") }
50 ttl=ttl+1; ms_puts(" T4 the error COMPOUNDS with chain length (gap grows 9 -> 99 -> 999): "); if (i1k-f1k) > (i100-f100) { if (i100-f100) > (i10-f10) { pass=pass+1; ms_puts("PASS\n") } else { ms_puts("FAIL\n") } } else { ms_puts("FAIL\n") }
51
52 ms_puts("NX-NOFLOAT-MULTISTEP-GATE passed "); ms_num(pass); ms_puts("/"); ms_num(ttl)
53 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
54 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
55 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
56 let ctr__dry: *i64 = gv_ctr()
57 ctr__dry[0] = pass
58 ctr__dry[1] = ttl
59 let rc__dry: i64 = gv_verdict("NOFLOAT-MULTISTEP-GATE" as *u8, ctr__dry, "no-float = reliable multi-step logic where float compounds error -- the arena we exceed in)" as *u8)
60 sys_exit(rc__dry)
61 return rc__dry
62}