code wiki / _hdl_build / nx_rans_gate.nx

nx_rans_gate.nx

buildroot/runtime/_hdl_build/nx_rans_gate.nx

6520 B112 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_emit_lib.nx nx_rans.nx nx_rans_gate.nx

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

main g_puts sys_write sys_mmap enc_pipeline sys_mmap ↻ rans_count rans_normalize rans_cum rans_build_slot2sym rans_encode sys_mmap ↻ rans_decode bufeq g_check g_puts ↻ g_num sys_mmap ↻ sys_write ↻ sys_openat_append g_w sys_write ↻ g_wn sys_mmap ↻ sys_write ↻ sys_close sys_exit

structs

none

consts

none

functions

16func 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 }
called by 1: main calls 2: sys_mmapsys_write
17func 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 }
called by 1: main calls 1: sys_write
18func 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 }
called by 1: main calls 2: sys_mmapsys_write
19func 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
22func enc_pipeline(data: *u8, n: i64, sb: i64, freqs: *i64, cum: *i64, slot2sym: *i64, out: *u8, outcap: i64) -> i64
31func main() -> i64