code wiki / _hdl_build / _rational_gate.nx

_rational_gate.nx

buildroot/runtime/_hdl_build/_rational_gate.nx

3572 B76 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

_rational_gate.nx -- self-validating gate for EXACT rational arithmetic (ME4). Proves results f64 CANNOT get exactly (free algebraic oracle): (1) 1/3 + 1/3 + 1/3 == 1 (f64: 0.999...) (2) sum_{k=1}^1000 1/(k(k+1)) == 1000/1001 (telescoping identity) (3) 1/10 + 2/10 == 3/10 EXACTLY (while f64 0.1+0.2 != 0.3 -- shown) (4) (1/7) * 7 == 1 GREEN iff all exact identities hold AND the f64 0.1+0.2!=0.3 contrast is real (so the exactness is demonstrably non-trivial). Durable: RATIONAL-GATE -> math_engine.log. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_rational.nx nx_f64.nx _rational_gate.nx

imports: nx_syscalls.nxnx_rational.nxnx_f64.nx

imported by: nobody (leaf or entry point)

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

main rg_p sys_write rat_new sys_mmap rat_set rat_norm rat_gcd rat_add rat_norm ↻ nx_f64_add nx_f64_classify nx_f64_exp_field nx_f64_mant_field nx_f64_sign nx_f64_mant_field ↻ nx_f64_exp_field ↻ _f64_round_pack rat_mul rat_norm ↻ sys_openat_append rg_f sys_write ↻ rg_n sys_mmap ↻ sys_write ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_close sys_exit

structs

none

consts

none

functions

14func rg_p(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 1: main calls 1: sys_write
15func rg_f(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
16func rg_n(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" 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{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
18func main() -> i64