code wiki / _hdl_build / _rational_gate.nx
_rational_gate.nx
buildroot/runtime/_hdl_build/_rational_gate.nx
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
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
structs
| none |
consts
| none |
functions
| 14 | func 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 } |
| 15 | func 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 } |
| 16 | func 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 } |
| 18 | func main() -> i64 |