code wiki / _hdl_build / nx_rans_gate.nx
nx_rans_gate.nx
buildroot/runtime/_hdl_build/nx_rans_gate.nx
about
nx_rans_gate.nx -- SOVEREIGN liar-kill gate for nx_rans (the patent-free rANS entropy keystone).
Proves ENTIRELY within Nishi (no python, no 3rd party): for an entropy stage whose encoder AND
decoder we both own, lossless round-trip IS the complete correctness criterion.
T1 round-trip bit-exact on a skewed 3-symbol buffer (decode(encode(x)) == x)
T2 it actually COMPRESSES (enc < raw) -- honest entropy coding, not a memcpy
T3 round-trip bit-exact on a 64-symbol buffer (full pipeline over a wide alphabet)
T4 degenerate single-symbol round-trip + near-zero output (entropy-correct: 0 bits/sym -> 4-byte state)
T5 determinism: re-encoding the same input yields byte-identical output
T6 LIAR-KILL: a CORRUPTED stream does NOT reproduce the input -- the decoder genuinely depends on
the bitstream, so the gate cannot pass by echoing
GREEN iff 6/6. Durable knowledge/status/rans_gate.log. license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_gate_emit_lib.nxnx_rans.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
| 16 | func g_num(v: i64) -> i64 { let bb: *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{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 } |
| 17 | func g_w(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 } |
| 18 | func g_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; 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 } |
| 19 | func bufeq(a: *u8, b: *u8, 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 |
| 22 | func enc_pipeline(data: *u8, n: i64, sb: i64, freqs: *i64, cum: *i64, slot2sym: *i64, out: *u8, outcap: i64) -> i64 |
| 31 | func main() -> i64 |