code wiki / (root) / nx_phash_index_gate.nx

nx_phash_index_gate.nx

buildroot/runtime/nx_phash_index_gate.nx

8741 B154 linesdepth 6pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic phash
docsdependenciesstructsconstsfunctions

about

nx_phash_index_gate.nx -- referee for the sublinear Hamming index (nx_phash_index, BK-tree). PROVES, in-process (no external elf, no shell orchestration), what a TinEye-scale index must guarantee: row1 EXACTNESS (clustered): over K clustered near-dup queries the BK-tree match SET equals the linear O(N) brute-force set -- no false positives, no recall loss. row2 MEASURED-EXCEED: average candidates examined by the BK-tree << N (sublinear pruning), printed as an honest ratio on a realistic clustered corpus. row3 EXACTNESS (adversarial uniform-random): correctness HOLDS even where pruning is weak -- the answer is exact regardless of speed (the liar-kill that separates "fast" from "right"). row4 DETERMINISM: identical query -> identical candidates-examined AND identical match count, twice (bit-exact; the sovereign moat over float ANN indexes). row5 BUILD INTEGRITY: every one of the N fingerprints is present in the tree. GREEN iff 5/5. Deterministic corpus (MMIX LCG, fixed seed) so the verdict is reproducible. Durable verdict -> knowledge/status/phash_index_gate.log. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_phash_index.nx nx_phash_index_gate.nx

imports: nx_phash_index.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 g_rng g_jitter g_bitpos g_rng ↻ pi_init_children pi_insert nx_simhash_hamming nx_bits_popcount64_soft pi_query nx_simhash_hamming ↻ g_brute nx_simhash_hamming ↻ g_memzero g_memmark g_memeq g_num sys_openat_append g_w g_wn

structs

none

consts

none

functions

17func g_puts(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
18func 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
19func 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
20func g_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; 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
23func g_rng(s: *i64) -> i64 { let x: i64 = s[0] * 0x5851F42D4C957F2D + 0x14057B7EF767814F; s[0]=x; return x }
called by 2: g_bitposmain
25func g_bitpos(s: *i64) -> i64 { return (g_rng(s) >> 20) & 63 }
called by 1: g_jitter calls 1: g_rng
27func g_jitter(s: *i64, center: i64, k: i64) -> i64 { var v: i64=center; var i: i64=0; while i<k { v = v ^ (1 << g_bitpos(s)); i=i+1 } return v }
called by 1: main calls 1: g_bitpos
30func g_brute(fp: *i64, pay: *i64, n: i64, q: i64, r: i64, out: *i64, out_cap: i64) -> i64
called by 1: main calls 1: nx_simhash_hamming
35func g_memzero(memb: *u8, n: i64) -> i64 { var i: i64=0; while i<n { memb[i]=0 as u8; i=i+1 } return 0 }
called by 1: main
36func g_memmark(memb: *u8, out: *i64, cnt: i64) -> i64 { var i: i64=0; while i<cnt { memb[out[i]]=1 as u8; i=i+1 } return 0 }
called by 1: main
37func g_memeq(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
39func main() -> i64