code wiki / (root) / nx_kubelka_gate.nx

nx_kubelka_gate.nx

buildroot/runtime/nx_kubelka_gate.nx

7487 B150 linesdepth 4pulls 7 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_kubelka_gate.nx -- THE GATE FOR THE KUBELKA-MUNK CHROMOPHORE SUBSTRATE, 2026-09-03. SUBJECT: km_r_from_ks / km_ks_from_r / km_ks_mix / km_r_of_mix in-process (the lib has no main). WHAT MAKES THESE TEETH NON-VACUOUS. This model needs no external table to be falsifiable: it carries its own oracle. The forward and the inverse are independent closed forms, so a ROUND TRIP over a ladder of reflectances convicts either one of them being wrong -- a mistyped forward cannot invert back to where it started. The physical checks are the ones that matter for skin: more melanin must be DARKER, more haemoglobin must be DARKER, and reflectance must stay inside [0,1] for every input on the ladder. Teeth, in order: T1 zero absorption is unit reflectance, EXACTLY (not within a tolerance -- the algebra is exact there). T2 the ladder is NON-DEGENERATE: it spans real range. Without this, T3 and T4 could pass on a constant. T3 ROUND TRIP r -> K/S -> r over the whole ladder, every rung, no sampling. T4 monotone: reflectance falls as K/S rises, strictly, across every adjacent pair. T5 bounds: every reflectance on the ladder lies in [0,1]. T6 PHYSICAL: more melanin is strictly darker. T7 PHYSICAL: more haemoglobin is strictly darker. T8 NEG-CONTROL: a non-positive scattering coefficient REFUSES rather than dividing by zero. T9 NEG-CONTROL: inverting a reflectance of zero REFUSES rather than returning an infinity as a number. T10 NEG-CONTROL: inverting a reflectance above one REFUSES (outside the model's domain). PROVEN 10/10 GREEN on the laptop build farm 2026-09-03 while the NAS build lane was storm-refused. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_kubelka_lib.nx nx_kubelka_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_kubelka_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ km_r_from_ks fq_mul fq_sqrt fq_bitlen fq_isqrt vm_isqrt gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap fq_to_micro gv_check gv_puts ↻ sys_mmap ↻ kg_q fq_div fq_from_int km_ks_from_r fq_mul ↻

structs

none

consts

28const KG_SLOT: i64 = 8
29const KG_N: i64 = 9
30const KG_MICRO: i64 = 1000000
31const KG_RT_TOL_MICRO: i64 = 300
32const KG_SPAN_MIN_MICRO: i64 = 400000
33const KG_BAD_R_HIGH_MICRO: i64 = 1500000

functions

35func kg_q(micro: i64) -> i64 { return fq_div(fq_from_int(micro), fq_from_int(KG_MICRO)) }
called by 1: main calls 2: fq_divfq_from_int
36func kg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
38func main(argc: i64, argv: *i64) -> i64