code wiki / (root) / nx_zstd_huf_gate.nx

nx_zstd_huf_gate.nx

buildroot/runtime/nx_zstd_huf_gate.nx

8481 B187 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic zstd
docsdependenciesstructsconstsfunctions

about

nx_zstd_huf_gate.nx -- proves the zstd Huffman decode table. T2 pins the EXACT table layout for a known weight set, index by index. Weights {2,1,4,3,1} at tableLog 4 must tile 16 entries as: 0..7 symbol 2, 1 bit (weight 4, the shortest code, LOWEST indices) 8..11 symbol 3, 2 bits 12..13 symbol 0, 3 bits 14 symbol 1, 4 bits 15 symbol 4, 4 bits Laying ranks out in SYMBOL order instead of DESCENDING WEIGHT produces a table that decodes self-consistently and disagrees with every other zstd implementation -- a file only this decoder can read. Asserting the indices directly is the only way to catch that. T3 requires the slots to TILE EXACTLY. A weight set that sums to 15 of 16 leaves an entry no symbol ever claims, and a peek landing there would decode as symbol 0 forever. The build refuses rather than leaving the hole. T5 decodes a hand-assembled backward stream. Bits were placed so the reader emits 0 | 10 | 110 | 1111, which must come out as symbols 2, 3, 0, 4 -- four codes of four different lengths, so a decoder that consumes tableLog bits per symbol instead of the code's true length fails on the second one. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_zstd_bits.nx nx_zstd_huf.nx nx_zstd_huf_gate.nx

imports: nx_syscalls.nxnx_zstd_bits.nxnx_zstd_huf.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 nx_zstd_huf_build sys_mmap ↻ nx_zstd_huf_symbol_at nx_zstd_huf_nbits_at nx_zstd_bits_init nx_zb_at nx_zb_highbit8 sys_mmap ↻ nx_zstd_bits_remaining nx_zstd_bits_peek nx_zb_at ↻ nx_zstd_bits_skip nx_zstd_huf_decode nx_zstd_bits_peek ↻ nx_zstd_huf_symbol_at ↻ nx_zstd_huf_nbits_at ↻ nx_zstd_bits_skip ↻ g_puts sys_write sys_exit g_putn sys_mmap ↻ g_puts ↻ sys_write ↻

structs

none

consts

none

functions

29func g_puts(s: *u8) -> i64
called by 2: g_putnmain calls 1: sys_write
36func g_putn(v: i64) -> i64
called by 1: main calls 3: sys_mmapg_putssys_write
50func main() -> i64