code wiki / (root) / nx_vasc_gate.nx

nx_vasc_gate.nx source

↩ module page · 165 lines · 9330 B

1// nx_vasc_gate.nx -- THE GATE FOR THE VASCULATURE-TO-CHROMOPHORE JOIN, 2026-09-03. 2// 3// SUBJECT: va_seg_visible / va_field in-process, and their COMPOSITION with nx_kubelka_lib. 4// 5// THE TOOTH THAT MATTERS IS T8. Everything above it is arithmetic hygiene; T8 is the operator's law made 6// falsifiable. Feed a grown vessel network through va_field into km_r_of_mix and the tissue must get REDDER 7// as vessel density rises -- specifically the GREEN channel must fall faster than the RED, because that is 8// what haemoglobin does to light. If that separation does not appear, the join is decorative and the vessels 9// would still have to be painted. 10// 11// T9 IS THE ANTI-PAINTING PROOF. The same vessel at increasing depth must walk the surface colour back to 12// the vessel-free baseline, and a deep enough vessel must vanish into it exactly. A painted texture cannot 13// do that: its appearance is not a function of where the structure is. If T9 passes, appearance is being 14// DERIVED from anatomy rather than drawn on top of it. 15// 16// Teeth, in order: 17// T1 a segment at zero depth contributes its full volume fraction, EXACTLY (transmittance is one there). 18// T2 monotone in depth: the same vessel deeper is less visible. 19// T3 monotone in volume: a larger vessel at the same depth is more visible. 20// T4 additive: a second segment raises the field. 21// T5 CLAMPED: an absurd network saturates at unity and never exceeds it -- a fraction above one would sail 22// into km_ks_mix and yield a confident reflectance for tissue that cannot exist. 23// T6 NEG-CONTROL: a negative depth REFUSES. 24// T7 NEG-CONTROL: a non-positive attenuation REFUSES. 25// T8 COMPOSITION: more vessel density makes the tissue redder -- green falls faster than red. 26// T9 ANTI-PAINTING: the same vessel buried deep returns the surface to its vessel-free baseline. 27// MEASURED 9/9 GREEN 2026-09-03: R-G separation 89,090 sparse -> 196,295 dense, and the deep vessel returns 28// 70,497 against a vessel-free baseline of 70,497. 29// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 30import "nx_syscalls.nx" 31import "nx_gate_verdict.nx" 32import "nx_vasc_lib.nx" 33import "nx_kubelka_lib.nx" 34 35const VG_SLOT: i64 = 8 36const VG_CH: i64 = 3 37const VG_R: i64 = 0 38const VG_G: i64 = 1 39const VG_MICRO: i64 = 1000000 40const VG_SEP_MIN_MICRO: i64 = 2000 41const VG_BASELINE_TOL_MICRO: i64 = 3000 42 43func vg_q(micro: i64) -> i64 { return fq_div(fq_from_int(micro), fq_from_int(VG_MICRO)) } 44func vg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } 45 46func main(argc: i64, argv: *i64) -> i64 { 47 let ctr: *i64 = gv_ctr() 48 gv_head("nx_vasc gate -- a grown vessel network becomes a haemoglobin field, and the skin above it turns red because of it" as *u8) 49 50 let fq: *i64 = fq_ctx() 51 let atten: i64 = vg_q(3000000) 52 53 let vol: i64 = vg_q(120000) 54 let c0: i64 = va_seg_visible(fq, vol, 0, atten) 55 gv_puts(" [T1] vol_micro=120000 depth=0 -> visible_micro=" as *u8); gv_num(fq_to_micro(c0)); gv_puts("\n" as *u8) 56 gv_check("a-segment-at-zero-depth-contributes-its-full-volume-fraction-exactly" as *u8, (c0 == vol) as i64, ctr) 57 58 let cA: i64 = va_seg_visible(fq, vol, vg_q(100000), atten) 59 let cB: i64 = va_seg_visible(fq, vol, vg_q(400000), atten) 60 let cC: i64 = va_seg_visible(fq, vol, vg_q(1200000), atten) 61 gv_puts(" [T2] depth 0.1/0.4/1.2 -> " as *u8); gv_num(fq_to_micro(cA)); gv_puts(" " as *u8); gv_num(fq_to_micro(cB)); gv_puts(" " as *u8); gv_num(fq_to_micro(cC)); gv_puts("\n" as *u8) 62 var t2: i64 = 0 63 if cA > cB { if cB > cC { t2 = 1 } } 64 gv_check("the-same-vessel-deeper-is-less-visible" as *u8, t2, ctr) 65 66 let cSmall: i64 = va_seg_visible(fq, vg_q(50000), vg_q(200000), atten) 67 let cBig: i64 = va_seg_visible(fq, vg_q(250000), vg_q(200000), atten) 68 gv_check("a-larger-vessel-at-the-same-depth-is-more-visible" as *u8, (cBig > cSmall) as i64, ctr) 69 70 let vols: *i64 = sys_mmap(4 * VG_SLOT) as *i64 71 let deps: *i64 = sys_mmap(4 * VG_SLOT) as *i64 72 vols[0] = vg_q(80000) 73 deps[0] = vg_q(150000) 74 vols[1] = vg_q(60000) 75 deps[1] = vg_q(300000) 76 vols[2] = vg_q(40000) 77 deps[2] = vg_q(500000) 78 vols[3] = vg_q(30000) 79 deps[3] = vg_q(900000) 80 let f1: i64 = va_field(fq, vols, deps, 1, atten) 81 let f4: i64 = va_field(fq, vols, deps, 4, atten) 82 gv_puts(" [T4] field n=1 -> " as *u8); gv_num(fq_to_micro(f1)); gv_puts(" n=4 -> " as *u8); gv_num(fq_to_micro(f4)); gv_puts("\n" as *u8) 83 gv_check("a-second-segment-raises-the-haemoglobin-field" as *u8, (f4 > f1) as i64, ctr) 84 85 let bigv: *i64 = sys_mmap(4 * VG_SLOT) as *i64 86 let bigd: *i64 = sys_mmap(4 * VG_SLOT) as *i64 87 var z: i64 = 0 88 while z < 4 { 89 bigv[z] = FQ_ONE 90 bigd[z] = 0 91 z = z + 1 92 } 93 let fsat: i64 = va_field(fq, bigv, bigd, 4, atten) 94 gv_puts(" [T5] saturating network -> " as *u8); gv_num(fq_to_micro(fsat)); gv_puts(" want=1000000\n" as *u8) 95 gv_check("an-absurd-network-clamps-at-unity-and-never-exceeds-it" as *u8, (fsat == FQ_ONE) as i64, ctr) 96 97 let rneg: i64 = va_seg_visible(fq, vol, 0 - vg_q(100000), atten) 98 gv_puts(" [T6] negative depth -> " as *u8); gv_num(rneg); gv_puts("\n" as *u8) 99 gv_check("neg-control-a-negative-depth-refuses" as *u8, (rneg == VA_REFUSED) as i64, ctr) 100 101 let ratt: i64 = va_field(fq, vols, deps, 4, 0) 102 gv_puts(" [T7] zero attenuation -> " as *u8); gv_num(ratt); gv_puts("\n" as *u8) 103 gv_check("neg-control-a-non-positive-attenuation-refuses" as *u8, (ratt == VA_REFUSED) as i64, ctr) 104 105 // fair-skin case: melanin fixed and LOW, which is exactly where grown vasculature is supposed to read. 106 // Haemoglobin absorbs green far more than red. 107 let kbase: *i64 = sys_mmap(VG_CH * VG_SLOT) as *i64 108 let kmel: *i64 = sys_mmap(VG_CH * VG_SLOT) as *i64 109 let khem: *i64 = sys_mmap(VG_CH * VG_SLOT) as *i64 110 let s: *i64 = sys_mmap(VG_CH * VG_SLOT) as *i64 111 kbase[0] = vg_q(30000) 112 kbase[1] = vg_q(40000) 113 kbase[2] = vg_q(60000) 114 kmel[0] = vg_q(500000) 115 kmel[1] = vg_q(1200000) 116 kmel[2] = vg_q(2500000) 117 khem[0] = vg_q(300000) 118 khem[1] = vg_q(2600000) 119 khem[2] = vg_q(900000) 120 s[0] = vg_q(1000000) 121 s[1] = vg_q(1000000) 122 s[2] = vg_q(1000000) 123 let mel_fair: i64 = vg_q(40000) 124 125 let sparse: *i64 = sys_mmap(2 * VG_SLOT) as *i64 126 let sparsed: *i64 = sys_mmap(2 * VG_SLOT) as *i64 127 sparse[0] = vg_q(20000) 128 sparsed[0] = vg_q(200000) 129 let dense: *i64 = sys_mmap(2 * VG_SLOT) as *i64 130 let densed: *i64 = sys_mmap(2 * VG_SLOT) as *i64 131 dense[0] = vg_q(220000) 132 densed[0] = vg_q(200000) 133 let hs: i64 = va_field(fq, sparse, sparsed, 1, atten) 134 let hd: i64 = va_field(fq, dense, densed, 1, atten) 135 let r_s: i64 = km_r_of_mix(kbase[VG_R], kmel[VG_R], mel_fair, khem[VG_R], hs, s[VG_R]) 136 let g_s: i64 = km_r_of_mix(kbase[VG_G], kmel[VG_G], mel_fair, khem[VG_G], hs, s[VG_G]) 137 let r_d: i64 = km_r_of_mix(kbase[VG_R], kmel[VG_R], mel_fair, khem[VG_R], hd, s[VG_R]) 138 let g_d: i64 = km_r_of_mix(kbase[VG_G], kmel[VG_G], mel_fair, khem[VG_G], hd, s[VG_G]) 139 let sep_s: i64 = fq_to_micro(r_s) - fq_to_micro(g_s) 140 let sep_d: i64 = fq_to_micro(r_d) - fq_to_micro(g_d) 141 gv_puts(" [T8] sparse hem=" as *u8); gv_num(fq_to_micro(hs)); gv_puts(" R=" as *u8); gv_num(fq_to_micro(r_s)); gv_puts(" G=" as *u8); gv_num(fq_to_micro(g_s)); gv_puts(" R-G=" as *u8); gv_num(sep_s); gv_puts("\n" as *u8) 142 gv_puts(" dense hem=" as *u8); gv_num(fq_to_micro(hd)); gv_puts(" R=" as *u8); gv_num(fq_to_micro(r_d)); gv_puts(" G=" as *u8); gv_num(fq_to_micro(g_d)); gv_puts(" R-G=" as *u8); gv_num(sep_d); gv_puts("\n" as *u8) 143 var t8: i64 = 0 144 if sep_d > sep_s { if sep_d - sep_s >= VG_SEP_MIN_MICRO { t8 = 1 } } 145 gv_check("denser-grown-vasculature-makes-the-skin-above-it-redder (green falls faster than red)" as *u8, t8, ctr) 146 147 let one: *i64 = sys_mmap(2 * VG_SLOT) as *i64 148 let oned: *i64 = sys_mmap(2 * VG_SLOT) as *i64 149 one[0] = vg_q(220000) 150 oned[0] = vg_q(2500000) 151 let hdeep: i64 = va_field(fq, one, oned, 1, atten) 152 let r_deep: i64 = km_r_of_mix(kbase[VG_R], kmel[VG_R], mel_fair, khem[VG_R], hdeep, s[VG_R]) 153 let g_deep: i64 = km_r_of_mix(kbase[VG_G], kmel[VG_G], mel_fair, khem[VG_G], hdeep, s[VG_G]) 154 let sep_deep: i64 = fq_to_micro(r_deep) - fq_to_micro(g_deep) 155 let r_none: i64 = km_r_of_mix(kbase[VG_R], kmel[VG_R], mel_fair, khem[VG_R], 0, s[VG_R]) 156 let g_none: i64 = km_r_of_mix(kbase[VG_G], kmel[VG_G], mel_fair, khem[VG_G], 0, s[VG_G]) 157 let sep_none: i64 = fq_to_micro(r_none) - fq_to_micro(g_none) 158 gv_puts(" [T9] same vessel deep hem=" as *u8); gv_num(fq_to_micro(hdeep)); gv_puts(" R-G=" as *u8); gv_num(sep_deep) 159 gv_puts(" no-vessel baseline R-G=" as *u8); gv_num(sep_none); gv_puts("\n" as *u8) 160 var t9: i64 = 0 161 if vg_abs(sep_deep - sep_none) <= VG_BASELINE_TOL_MICRO { if sep_d - sep_deep >= VG_SEP_MIN_MICRO { t9 = 1 } } 162 gv_check("the-same-vessel-buried-deep-returns-the-surface-to-its-vessel-free-baseline (appearance derives from anatomy, it is not painted)" as *u8, t9, ctr) 163 164 return gv_verdict("vasc" as *u8, ctr, "a grown vessel network is converted to a haemoglobin field by double-pass attenuation, and the skin above it reddens because of the structure rather than because anything was drawn on it" as *u8) 165}