code wiki / _hdl_build / nx_research_discover_chem_gate.nx

nx_research_discover_chem_gate.nx

buildroot/runtime/_hdl_build/nx_research_discover_chem_gate.nx

6780 B106 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic research
docsdependenciesstructsconstsfunctions

about

nx_research_discover_chem_gate.nx -- DISCOVERY in CHEMISTRY (operator: "discover new capabilities through different math/chem/physics via simulations"). The chem reproduction gate (nx_research_chem_gate) replays KNOWN molar masses. This gate DISCOVERS something it was never given: the stoichiometric coefficients that BALANCE a chemical reaction. A balanced reaction conserves every element: with reactants counted + and products counted -, the integer coefficient vector x must satisfy A x = 0 for the element-count matrix A (rows=elements, cols=species). That is an integer-nullspace problem. The TESTING-TEAM SEARCHES the small positive-integer lattice for the fundamental solution, reduces it to the smallest whole-number ratio (gcd=1), and the VERIFIER independently rechecks atom conservation per element. Liar-kill: the naive all-ones guess (and any unbalanced vector) is REJECTED -- conservation can't be rubber-stamped. Discovered coefficients are compared to the textbook canonical for three classic reactions. Pure integer, deterministic, reproducible. GREEN iff 6/6. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_research_discover_chem_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 balance sys_mmap ↻ balanced_ok gcd balanced_ok ↻ veq gcd_vec gcd ↻ g_n g_w ↻ sys_mmap ↻ sys_write ↻ g_row g_w ↻ sys_exit

structs

none

consts

none

functions

16func 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
17func 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
18func 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
20func gcd(a: i64, b: i64) -> i64 { var x: i64=a; var y: i64=b; if x<0{x=0-x} if y<0{y=0-y} while y!=0 { let t: i64=x%y; x=y; y=t } return x }
called by 2: balancegcd_vec
22func balanced_ok(A: *i64, E: i64, S: i64, x: *i64) -> i64
called by 2: balancemain
27func veq(a: *i64, b: *i64, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 }
called by 1: main
31func balance(A: *i64, E: i64, S: i64, B: i64, xout: *i64) -> i64
called by 1: main calls 3: sys_mmapbalanced_okgcd
47func gcd_vec(x: *i64, n: i64) -> i64 { var g: i64=x[0]; var i: i64=1; while i<n { g=gcd(g,x[i]); i=i+1 } return g }
called by 1: main calls 1: gcd
49func main() -> i64