code wiki / _hdl_build / nx_mulchain_deep_test.nx

nx_mulchain_deep_test.nx

buildroot/runtime/_hdl_build/nx_mulchain_deep_test.nx

3432 B61 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/prooftopic mulchain
docsdependenciesstructsconstsfunctions

about

nx_mulchain_deep_test.nx -- GATE for the deepened, cost-bounded chain search (the escalation resolution). Proves three things, exit 0 only if ALL hold: (A) COST SELECTION is correct under a LATENCY model (cap=5, tie_thresh=3): constants with a <=3-op chain pick the chain; constants needing >3 ops (incl. the escalated 466/683/691) and primes with no short chain pick IMUL. This is the per-constant cost decision that replaces the blunt depth-4 "expensive -> escalate". (B) every chain the selector keeps is VERIFIED to compute c*x on a fresh held-out input (independent of the search's own check) -- verify, don't trust. (C) TRACTABLE: the run completes (the primes that hung at depth 6/12 fail-fast at the cap). Memory-backed verdict tally in small helpers (mitigates the non-deterministic compiler's fat-main register clobber). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_mulchain_deep.nx nx_syscalls.nx nx_mulchain_deep_test.nx

imports: nx_mulchain_deep.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main dt_puts sys_write sys_mmap dt_check sys_mmap ↻ mc_cost_select mulchain_deep_verified mulchain_find_deep mc_abs mcd_enum mcd_reach mcd_maxmag mc_avslot mc_abs ↻ mcd_enum ↻ mc_eval sg_decide dt_puts ↻ dt_num sys_mmap ↻ sys_write ↻ dt_num ↻ sys_exit

structs

none

consts

none

functions

16func dt_puts(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 2: dt_checkmain calls 1: sys_write
17func dt_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 }
called by 2: dt_checkmain calls 2: sys_mmapsys_write
21func dt_check(c: i64, expect: i64) -> i64
36func main() -> i64