code wiki / _hdl_build / nx_neuro.nx

nx_neuro.nx source

↩ module page · 495 lines · 25020 B

1// nx_neuro.nx -- ★THE INNERVATION PLANE: the nervous system as a MAPPED TOPOLOGY, and autonomic 2// responses (arousal among them) COMPUTED FROM IT rather than painted on top. 3// 4// ★THE GAP THIS CLOSES, measured 2026-07-27 by nx_bodyatlas_gate: the atlas carries NERVOUS as system 7 5// with SEVEN ellipsoid proxy parts against 12 cranial + 31 spinal nerve PAIRS = 86 nerves before a 6// single branch (~8 percent), and -- the part that actually matters -- NOTHING ANYWHERE SAYS WHAT ANY 7// NERVE CONNECTS TO. A nerve drawn as a blob is scenery. A nerve is a ROUTE: a root level, a division, 8// and a target it drives. Until the route exists, no response can be caused by anatomy. 9// 10// ★★AND IT CLOSES THE SAME CLASS ONE LEVEL OUT. This lane's standing finding is 'our face is PAINTED, 11// not sculpted' -- colour where geometry belonged. The physiological equivalent is a response that is a 12// GLOBAL SCALAR with a suggestive name. Flush, tumescence, sweat and pupil are not one knob: they are 13// separate effectors on separate outflows, and the proof is that they DISSOCIATE under a lesion. So the 14// discriminating tooth in this organ is a LESION: cut S2-S4 and genital vasocongestion must fall to 15// EXACTLY ZERO while cutaneous flush is UNCHANGED. ★A single arousal scalar cannot pass that tooth. 16// 17// ★★★THE MODEL CANNOT EXPRESS AN IMPOSSIBLE NERVOUS SYSTEM, BY CONSTRUCTION. Two structural laws are 18// checked on every row rather than trusted: 19// THORACOLUMBAR OUTFLOW -- a SYMPATHETIC fibre leaves the cord only between T1 and L2. 20// CRANIOSACRAL OUTFLOW -- a PARASYMPATHETIC fibre leaves only via a cranial nerve or S2-S4. 21// These are not conventions, they are where the preganglionic cell columns physically are. Encoding 22// them as containment means a sacral sympathetic or a thoracic parasympathetic is REFUSED at the gate, 23// the way nx_skelgen's joint constraints make a hyperextended knee unrequestable. 24// 25// ★COMPOSES, DOES NOT DUPLICATE (the audit ran FIRST, as it now does every round): nx_myoattach owns 26// muscle ATTACHMENT; nx_bodyatlas owns the peelable systems; nx_fascia owns soft-tissue transmission. 27// NONE of them owns INNERVATION. Muscle indices below are nx_myoattach's own 0..20, READ from that 28// table before a row was written, not assumed. 29// 30// nx_neuro selftest 31// license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26). 32import "nx_gate_verdict.nx" 33 34// ---- ROOT LEVELS ----------------------------------------------------------------------------- 35// ★A LEVEL IS AN INTEGER SO THAT ROSTRAL-TO-CAUDAL ORDER IS ARITHMETIC. Bands are spaced with gaps so 36// that an off-by-one past the end of a band (a 'T13', which does not exist) lands on an ILLEGAL value 37// instead of silently becoming the first root of the next band. The gap IS the check. 38const NR_CN0: i64 = 0 39const NR_C0: i64 = 20 40const NR_T0: i64 = 40 41const NR_L0: i64 = 60 42const NR_S0: i64 = 80 43const NR_CO: i64 = 91 44const NR_MAXLVL: i64 = 96 45const NR_BAD: i64 = 0 - 1 46const NR_ROOTS: i64 = 43 47 48const NR_MOTOR: i64 = 1 49const NR_SENS: i64 = 2 50const NR_MIXED: i64 = 3 51const NR_SYMP: i64 = 4 52const NR_PARA: i64 = 5 53 54const NR_TMUSCLE: i64 = 1 55const NR_TEFF: i64 = 2 56const NR_TTERR: i64 = 3 57 58const NR_NPX: i64 = 10 59const NR_PS: i64 = 2 60func nr_pxtable(P: *i64) -> i64 { 61 var i: i64 = 0 62 P[i]=1; P[i+1]=12; i=i+NR_PS 63 P[i]=21; P[i+1]=24; i=i+NR_PS 64 P[i]=25; P[i+1]=41; i=i+NR_PS 65 P[i]=41; P[i+1]=52; i=i+NR_PS 66 P[i]=61; P[i+1]=64; i=i+NR_PS 67 P[i]=64; P[i+1]=84; i=i+NR_PS 68 P[i]=41; P[i+1]=62; i=i+NR_PS 69 P[i]=82; P[i+1]=84; i=i+NR_PS 70 P[i]=1; P[i+1]=12; i=i+NR_PS 71 P[i]=21; P[i+1]=85; i=i+NR_PS 72 return 0 73} 74 75func nr_root_ok(l: i64) -> i64 { 76 if l >= 1 { if l <= 12 { return 1 } } 77 if l >= 21 { if l <= 28 { return 1 } } 78 if l >= 41 { if l <= 52 { return 1 } } 79 if l >= 61 { if l <= 65 { return 1 } } 80 if l >= 81 { if l <= 85 { return 1 } } 81 if l == NR_CO { return 1 } 82 return 0 83} 84func nr_root_count() -> i64 { return NR_ROOTS } 85 86// ★THE STRUCTURAL CHECK. Takes a ROW, not a row INDEX, so the gate can hand it deliberately wrong 87// anatomy and prove the check is capable of failing. A checker that has never rejected anything is a 88// decoration. 89func nr_check_row(px: i64, lo: i64, hi: i64, kind: i64, P: *i64) -> i64 { 90 if px < 0 { return 0 } 91 if px >= NR_NPX { return 0 } 92 if nr_root_ok(lo) == 0 { return 0 } 93 if nr_root_ok(hi) == 0 { return 0 } 94 if lo > hi { return 0 } 95 if lo < P[px*NR_PS] { return 0 } 96 if hi > P[px*NR_PS+1] { return 0 } 97 if kind == NR_SYMP { 98 if lo < 41 { return 0 } 99 if hi > 62 { return 0 } 100 } 101 if kind == NR_PARA { 102 var okp: i64 = 0 103 if hi <= 12 { okp = 1 } 104 if lo >= 82 { if hi <= 84 { okp = 1 } } 105 if okp == 0 { return 0 } 106 } 107 return 1 108} 109 110const NR_NN: i64 = 37 111const NR_NS: i64 = 8 112func nr_ntable(N: *i64) -> i64 { 113 var i: i64 = 0 114 N[i]=2; N[i+1]=25; N[i+2]=41; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=0; N[i+6]=0; N[i+7]=0; i=i+NR_NS 115 N[i]=2; N[i+1]=25; N[i+2]=26; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=1; N[i+6]=1; N[i+7]=0; i=i+NR_NS 116 N[i]=2; N[i+1]=26; N[i+2]=28; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=2; N[i+6]=2; N[i+7]=0; i=i+NR_NS 117 N[i]=3; N[i+1]=47; N[i+2]=52; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=3; N[i+6]=3; N[i+7]=0; i=i+NR_NS 118 N[i]=2; N[i+1]=25; N[i+2]=27; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=4; N[i+6]=4; N[i+7]=0; i=i+NR_NS 119 N[i]=5; N[i+1]=65; N[i+2]=82; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=5; N[i+6]=5; N[i+7]=0; i=i+NR_NS 120 N[i]=4; N[i+1]=62; N[i+2]=64; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=6; N[i+6]=6; N[i+7]=0; i=i+NR_NS 121 N[i]=5; N[i+1]=81; N[i+2]=82; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=7; N[i+6]=7; N[i+7]=0; i=i+NR_NS 122 N[i]=0; N[i+1]=11; N[i+2]=11; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=8; N[i+6]=8; N[i+7]=0; i=i+NR_NS 123 N[i]=2; N[i+1]=26; N[i+2]=28; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=9; N[i+6]=9; N[i+7]=0; i=i+NR_NS 124 N[i]=2; N[i+1]=27; N[i+2]=41; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=10; N[i+6]=10; N[i+7]=0; i=i+NR_NS 125 N[i]=0; N[i+1]=11; N[i+2]=11; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=11; N[i+6]=8; N[i+7]=0; i=i+NR_NS 126 N[i]=9; N[i+1]=21; N[i+2]=85; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=12; N[i+6]=11; N[i+7]=0; i=i+NR_NS 127 N[i]=4; N[i+1]=61; N[i+2]=63; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=13; N[i+6]=12; N[i+7]=0; i=i+NR_NS 128 N[i]=4; N[i+1]=62; N[i+2]=64; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=14; N[i+6]=13; N[i+7]=0; i=i+NR_NS 129 N[i]=5; N[i+1]=64; N[i+2]=81; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=15; N[i+6]=14; N[i+7]=0; i=i+NR_NS 130 N[i]=5; N[i+1]=65; N[i+2]=82; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=16; N[i+6]=15; N[i+7]=0; i=i+NR_NS 131 N[i]=4; N[i+1]=62; N[i+2]=63; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=17; N[i+6]=6; N[i+7]=0; i=i+NR_NS 132 N[i]=5; N[i+1]=64; N[i+2]=65; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=18; N[i+6]=16; N[i+7]=0; i=i+NR_NS 133 N[i]=5; N[i+1]=81; N[i+2]=82; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=19; N[i+6]=7; N[i+7]=0; i=i+NR_NS 134 N[i]=2; N[i+1]=25; N[i+2]=26; N[i+3]=NR_MOTOR; N[i+4]=NR_TMUSCLE; N[i+5]=20; N[i+6]=17; N[i+7]=0; i=i+NR_NS 135 N[i]=5; N[i+1]=82; N[i+2]=84; N[i+3]=NR_MIXED; N[i+4]=NR_TTERR; N[i+5]=0; N[i+6]=18; N[i+7]=1; i=i+NR_NS 136 N[i]=7; N[i+1]=82; N[i+2]=84; N[i+3]=NR_PARA; N[i+4]=NR_TEFF; N[i+5]=0; N[i+6]=19; N[i+7]=1; i=i+NR_NS 137 N[i]=6; N[i+1]=51; N[i+2]=62; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=1; N[i+6]=20; N[i+7]=1; i=i+NR_NS 138 N[i]=8; N[i+1]=10; N[i+2]=10; N[i+3]=NR_PARA; N[i+4]=NR_TEFF; N[i+5]=6; N[i+6]=21; N[i+7]=0; i=i+NR_NS 139 N[i]=6; N[i+1]=41; N[i+2]=44; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=6; N[i+6]=22; N[i+7]=0; i=i+NR_NS 140 N[i]=6; N[i+1]=41; N[i+2]=62; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=2; N[i+6]=23; N[i+7]=0; i=i+NR_NS 141 N[i]=6; N[i+1]=41; N[i+2]=62; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=3; N[i+6]=24; N[i+7]=0; i=i+NR_NS 142 N[i]=6; N[i+1]=41; N[i+2]=62; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=4; N[i+6]=25; N[i+7]=0; i=i+NR_NS 143 N[i]=6; N[i+1]=44; N[i+2]=46; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=5; N[i+6]=26; N[i+7]=0; i=i+NR_NS 144 N[i]=8; N[i+1]=3; N[i+2]=3; N[i+3]=NR_PARA; N[i+4]=NR_TEFF; N[i+5]=7; N[i+6]=27; N[i+7]=0; i=i+NR_NS 145 N[i]=6; N[i+1]=41; N[i+2]=42; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=7; N[i+6]=28; N[i+7]=0; i=i+NR_NS 146 N[i]=8; N[i+1]=7; N[i+2]=7; N[i+3]=NR_PARA; N[i+4]=NR_TEFF; N[i+5]=8; N[i+6]=29; N[i+7]=0; i=i+NR_NS 147 N[i]=0; N[i+1]=7; N[i+2]=7; N[i+3]=NR_MOTOR; N[i+4]=NR_TTERR; N[i+5]=1; N[i+6]=30; N[i+7]=1; i=i+NR_NS 148 N[i]=0; N[i+1]=7; N[i+2]=7; N[i+3]=NR_MOTOR; N[i+4]=NR_TTERR; N[i+5]=2; N[i+6]=31; N[i+7]=1; i=i+NR_NS 149 N[i]=1; N[i+1]=22; N[i+2]=23; N[i+3]=NR_SENS; N[i+4]=NR_TTERR; N[i+5]=3; N[i+6]=32; N[i+7]=1; i=i+NR_NS 150 N[i]=6; N[i+1]=51; N[i+2]=62; N[i+3]=NR_SYMP; N[i+4]=NR_TEFF; N[i+5]=0; N[i+6]=33; N[i+7]=1; i=i+NR_NS 151 return 0 152} 153 154const NR_NE: i64 = 9 155const NR_ES: i64 = 8 156func nr_etable(E: *i64) -> i64 { 157 var i: i64 = 0 158 E[i]=0; E[i+1]=51; E[i+2]=62; E[i+3]=0-300; E[i+4]=82; E[i+5]=84; E[i+6]=1000; E[i+7]=100; i=i+NR_ES 159 E[i]=0; E[i+1]=51; E[i+2]=62; E[i+3]=1000; E[i+4]=0; E[i+5]=0; E[i+6]=0; E[i+7]=101; i=i+NR_ES 160 E[i]=0; E[i+1]=41; E[i+2]=62; E[i+3]=600; E[i+4]=0; E[i+5]=0; E[i+6]=0; E[i+7]=102; i=i+NR_ES 161 E[i]=0; E[i+1]=41; E[i+2]=62; E[i+3]=500; E[i+4]=0; E[i+5]=0; E[i+6]=0; E[i+7]=103; i=i+NR_ES 162 E[i]=0; E[i+1]=41; E[i+2]=62; E[i+3]=400; E[i+4]=0; E[i+5]=0; E[i+6]=0; E[i+7]=104; i=i+NR_ES 163 E[i]=0; E[i+1]=44; E[i+2]=46; E[i+3]=700; E[i+4]=0; E[i+5]=0; E[i+6]=0; E[i+7]=105; i=i+NR_ES 164 E[i]=300; E[i+1]=41; E[i+2]=44; E[i+3]=600; E[i+4]=10; E[i+5]=10; E[i+6]=0-250;E[i+7]=106; i=i+NR_ES 165 E[i]=300; E[i+1]=41; E[i+2]=42; E[i+3]=400; E[i+4]=3; E[i+5]=3; E[i+6]=0-200;E[i+7]=107; i=i+NR_ES 166 E[i]=100; E[i+1]=0; E[i+2]=0; E[i+3]=0; E[i+4]=7; E[i+5]=7; E[i+6]=700; E[i+7]=108; i=i+NR_ES 167 return 0 168} 169 170func nr_ncount() -> i64 { return NR_NN } 171func nr_ecount() -> i64 { return NR_NE } 172func nr_nok(n: i64) -> i64 { if n < 0 { return 0 } if n >= NR_NN { return 0 } return 1 } 173func nr_eok(e: i64) -> i64 { if e < 0 { return 0 } if e >= NR_NE { return 0 } return 1 } 174func nr_nlo(N: *i64, n: i64) -> i64 { if nr_nok(n)==0 { return NR_BAD } return N[n*NR_NS+1] } 175func nr_nkind(N: *i64, n: i64) -> i64 { if nr_nok(n)==0 { return NR_BAD } return N[n*NR_NS+3] } 176func nr_ebase(E: *i64, e: i64) -> i64 { if nr_eok(e)==0 { return NR_BAD } return E[e*NR_ES] } 177 178// ★CONDUCTION: a lesion is a set of ROOT LEVELS that no longer conduct, and the drive surviving to a 179// target is the fraction of that route's OWN legal roots still intact. This is what makes a lesion 180// DISSOCIATE effectors instead of dimming all of them together. 181func nr_drive(lo: i64, hi: i64, L: *i64) -> i64 { 182 var n: i64 = 0 183 var live: i64 = 0 184 var l: i64 = lo 185 while l <= hi { 186 if nr_root_ok(l) == 1 { 187 n = n + 1 188 if L[l] == 0 { live = live + 1 } 189 } 190 l = l + 1 191 } 192 if n <= 0 { return 0 } 193 return live * 1000 / n 194} 195 196// ★★★THE BUG THIS SIGNATURE FIXES, CAUGHT BY READING THE GATE'S OWN PRINTED EVIDENCE WHILE IT READ 197// 11/11 GREEN. PARASYMPATHETIC TONE IS NOT ONE SCALAR. The first version routed a single `para` 198// through the sacral afferent gate, so cutting S2-S4 also silenced the VAGUS, the OCULOMOTOR and the 199// FACIAL nerve -- cranial outflows that leave the BRAINSTEM and never pass within a foot of the 200// sacrum. Measured fallout on a sacral lesion: heart rate 249->499, pupil 233->433, lacrimation 201// 800->100. All three are anatomically impossible, and every tooth still passed. 202// ★THE TWO OUTFLOWS WERE ALREADY DISTINGUISHED BY THE EFFECTOR TABLE'S OWN ROOT WINDOWS, so the fix 203// needs no new data -- only that the code stop collapsing what the data had kept apart. T12 below is 204// the tooth whose absence let this ship green. 205func nr_out(E: *i64, e: i64, sym: i64, pcr: i64, psa: i64, L: *i64) -> i64 { 206 if nr_eok(e) == 0 { return NR_BAD } 207 let b: i64 = e*NR_ES 208 var v: i64 = E[b] 209 let sd: i64 = E[b+3] 210 if sd != 0 { v = v + sd * sym / 1000 * nr_drive(E[b+1], E[b+2], L) / 1000 } 211 let pd: i64 = E[b+6] 212 if pd != 0 { 213 var pt: i64 = 0 214 if E[b+4] >= 82 { pt = psa } 215 if E[b+5] <= 12 { pt = pcr } 216 v = v + pd * pt / 1000 * nr_drive(E[b+4], E[b+5], L) / 1000 217 } 218 if v < 0 { v = 0 } 219 if v > 1000 { v = 1000 } 220 return v 221} 222 223// ★★AROUSAL AS A REFLEX ARC RATHER THAN A SLIDER. The afferent limb is the PUDENDAL nerve (S2-S4) and 224// the efferent limb that produces tumescence is the PELVIC SPLANCHNIC parasympathetic outflow -- THE 225// SAME ROOTS. So one lesion abolishes both limbs, which is the clinical picture in a complete sacral 226// lesion and precisely what a global scalar gets wrong. The generalised sympathetic tone carrying 227// flush, sweat, pupil and heart rate rises with the same stimulus on a DIFFERENT outflow, and survives. 228const NR_SYMFRAC: i64 = 3 229func nr_arousal(E: *i64, stim: i64, L: *i64, out: *i64) -> i64 { 230 var s: i64 = stim 231 if s < 0 { s = 0 } 232 if s > 1000 { s = 1000 } 233 let aff: i64 = nr_drive(82, 84, L) 234 let psa: i64 = s * aff / 1000 235 let sym: i64 = s / NR_SYMFRAC 236 // ★CRANIAL parasympathetic tone is NOT part of this reflex arc. Resting vagal, oculomotor and 237 // facial tone is folded into each effector's own BASELINE, and arousal acts by RAISING the 238 // thoracolumbar sympathetic drive -- which is why heart rate rises rather than vagal tone being 239 // switched off from the sacrum. Passing 0 here is a STATEMENT, not a stub: a sacral event must 240 // never reach a brainstem outflow. 241 let pcr: i64 = 0 242 var e: i64 = 0 243 while e < NR_NE { 244 out[e] = nr_out(E, e, sym, pcr, psa, L) 245 e = e + 1 246 } 247 return 0 248} 249 250func nr_name(id: i64) -> *u8 { 251 if id == 0 { return "pectoral C5-T1" as *u8 } 252 if id == 1 { return "axillary C5-C6" as *u8 } 253 if id == 2 { return "thoracodorsal C6-C8" as *u8 } 254 if id == 3 { return "segmental intercostal T7-T12" as *u8 } 255 if id == 4 { return "musculocutaneous C5-C7" as *u8 } 256 if id == 5 { return "inferior gluteal L5-S2" as *u8 } 257 if id == 6 { return "femoral L2-L4" as *u8 } 258 if id == 7 { return "tibial S1-S2" as *u8 } 259 if id == 8 { return "accessory CN XI" as *u8 } 260 if id == 9 { return "radial C6-C8" as *u8 } 261 if id == 10 { return "median plus ulnar C7-T1" as *u8 } 262 if id == 11 { return "dorsal rami C1-S5" as *u8 } 263 if id == 12 { return "lumbar plexus L1-L3" as *u8 } 264 if id == 13 { return "obturator L2-L4" as *u8 } 265 if id == 14 { return "superior gluteal L4-S1" as *u8 } 266 if id == 15 { return "sciatic-tibial L5-S2" as *u8 } 267 if id == 16 { return "deep fibular L4-L5" as *u8 } 268 if id == 17 { return "lower subscapular C5-C6" as *u8 } 269 if id == 18 { return "PUDENDAL S2-S4 afferent" as *u8 } 270 if id == 19 { return "PELVIC SPLANCHNIC S2-S4 para" as *u8 } 271 if id == 20 { return "hypogastric T11-L2 emission" as *u8 } 272 if id == 21 { return "vagus CN X para" as *u8 } 273 if id == 22 { return "cardiac sympathetic T1-T4" as *u8 } 274 if id == 23 { return "cutaneous vasomotor T1-L2" as *u8 } 275 if id == 24 { return "sudomotor T1-L2" as *u8 } 276 if id == 25 { return "pilomotor T1-L2" as *u8 } 277 if id == 26 { return "thoracic sympathetic T4-T6" as *u8 } 278 if id == 27 { return "oculomotor CN III Edinger-Westphal" as *u8 } 279 if id == 28 { return "cervical sympathetic T1-T2" as *u8 } 280 if id == 29 { return "facial CN VII secretomotor" as *u8 } 281 if id == 30 { return "CN VII TEMPORAL branch brow-lift" as *u8 } 282 if id == 31 { return "CN VII MARGINAL MANDIBULAR facelift" as *u8 } 283 if id == 32 { return "GREAT AURICULAR C2-C3 facelift" as *u8 } 284 if id == 33 { return "hypogastric T11-L2 detumescence" as *u8 } 285 if id == 100 { return "genital vasocongestion" as *u8 } 286 if id == 101 { return "genital emission " as *u8 } 287 if id == 102 { return "cutaneous flush " as *u8 } 288 if id == 103 { return "sudomotor sweat " as *u8 } 289 if id == 104 { return "piloerection " as *u8 } 290 if id == 105 { return "nipple erection " as *u8 } 291 if id == 106 { return "heart rate " as *u8 } 292 if id == 107 { return "pupil diameter " as *u8 } 293 if id == 108 { return "lacrimation " as *u8 } 294 return "REFUSED-UNKNOWN-NAME" as *u8 295} 296 297func main(argc: i64, argv: *i64) -> i64 { 298 let ctr: *i64 = gv_ctr() 299 gv_head("nx_neuro selftest -- innervation as a checkable map, responses CAUSED by it" as *u8) 300 let P: *i64 = sys_mmap(NR_NPX*NR_PS*8) as *i64 301 let N: *i64 = sys_mmap(NR_NN*NR_NS*8) as *i64 302 let E: *i64 = sys_mmap(NR_NE*NR_ES*8) as *i64 303 let L: *i64 = sys_mmap(NR_MAXLVL*8) as *i64 304 let o1: *i64 = sys_mmap(NR_NE*8) as *i64 305 let o2: *i64 = sys_mmap(NR_NE*8) as *i64 306 nr_pxtable(P) 307 nr_ntable(N) 308 nr_etable(E) 309 var z: i64 = 0 310 while z < NR_MAXLVL { L[z] = 0; z = z + 1 } 311 312 var t1: i64 = 1 313 var n: i64 = 0 314 while n < NR_NN { 315 if nr_check_row(N[n*NR_NS], N[n*NR_NS+1], N[n*NR_NS+2], N[n*NR_NS+3], P) == 0 { t1 = 0 } 316 n = n + 1 317 } 318 gv_check("T1 STRUCTURE: all 37 shipped routes satisfy legal-root, ordering, plexus and outflow" as *u8, t1, ctr) 319 320 // ★★THE REFUTATION. Five deliberately impossible routes, each isolating ONE law, and a POSITIVE 321 // control -- because a checker that refuses everything would pass the five and be worthless. 322 var t2: i64 = 1 323 if nr_check_row(2, 62, 64, NR_MOTOR, P) != 0 { t2 = 0 } 324 if nr_check_row(7, 82, 84, NR_SYMP, P) != 0 { t2 = 0 } 325 if nr_check_row(3, 45, 45, NR_PARA, P) != 0 { t2 = 0 } 326 if nr_check_row(9, 53, 53, NR_MOTOR, P) != 0 { t2 = 0 } 327 if nr_check_row(2, 27, 25, NR_MOTOR, P) != 0 { t2 = 0 } 328 if nr_check_row(2, 25, 27, NR_MOTOR, P) != 1 { t2 = 0 } 329 gv_check("T2 REFUTATION: 5 impossible routes REJECTED one per law, and a real one ACCEPTED" as *u8, t2, ctr) 330 331 let MU: *i64 = sys_mmap(21*8) as *i64 332 var m: i64 = 0 333 while m < 21 { MU[m] = 0; m = m + 1 } 334 n = 0 335 while n < NR_NN { 336 if N[n*NR_NS+4] == NR_TMUSCLE { 337 let id: i64 = N[n*NR_NS+5] 338 if id >= 0 { if id < 21 { MU[id] = MU[id] + 1 } } 339 } 340 n = n + 1 341 } 342 var t3: i64 = 1 343 m = 0 344 while m < 21 { if MU[m] != 1 { t3 = 0 } m = m + 1 } 345 gv_check("T3 COMPLETENESS: all 21 nx_myoattach muscles innervated EXACTLY once" as *u8, t3, ctr) 346 347 // ★CROSS-TABLE: every non-zero drive an effector declares must be CARRIED by a real nerve with the 348 // same division and the same root window. Two independent statements that must agree. 349 var t4: i64 = 1 350 var e: i64 = 0 351 while e < NR_NE { 352 let b: i64 = e*NR_ES 353 if E[b+3] != 0 { 354 var found: i64 = 0 355 n = 0 356 while n < NR_NN { 357 if N[n*NR_NS+3] == NR_SYMP { if N[n*NR_NS+4] == NR_TEFF { if N[n*NR_NS+5] == e { 358 if N[n*NR_NS+1] == E[b+1] { if N[n*NR_NS+2] == E[b+2] { found = 1 } } } } } 359 n = n + 1 360 } 361 if found == 0 { t4 = 0 } 362 } 363 if E[b+6] != 0 { 364 var f2: i64 = 0 365 n = 0 366 while n < NR_NN { 367 if N[n*NR_NS+3] == NR_PARA { if N[n*NR_NS+4] == NR_TEFF { if N[n*NR_NS+5] == e { 368 if N[n*NR_NS+1] == E[b+4] { if N[n*NR_NS+2] == E[b+5] { f2 = 1 } } } } } 369 n = n + 1 370 } 371 if f2 == 0 { t4 = 0 } 372 } 373 e = e + 1 374 } 375 gv_check("T4 CROSS-TABLE: every effector drive is carried by a real nerve on the same roots" as *u8, t4, ctr) 376 377 var t5: i64 = 1 378 if nr_nlo(N, NR_NN) != NR_BAD { t5 = 0 } 379 if nr_nlo(N, 999) != NR_BAD { t5 = 0 } 380 if nr_nkind(N, 0-1) != NR_BAD { t5 = 0 } 381 if nr_ebase(E, NR_NE) != NR_BAD { t5 = 0 } 382 if nr_out(E, 999, 1000, 1000, 1000, L) != NR_BAD { t5 = 0 } 383 if nr_root_ok(53) != 0 { t5 = 0 } 384 if nr_root_ok(29) != 0 { t5 = 0 } 385 if nr_root_ok(25) != 1 { t5 = 0 } 386 gv_check("T5 FAIL-CLOSED: unknown nerve, effector and non-existent root level all REFUSED" as *u8, t5, ctr) 387 388 nr_arousal(E, 0, L, o1) 389 var t6: i64 = 1 390 e = 0 391 while e < NR_NE { if o1[e] != E[e*NR_ES] { t6 = 0 } e = e + 1 } 392 gv_check("T6 ZERO: no stimulus leaves every effector EXACTLY at baseline" as *u8, t6, ctr) 393 394 nr_arousal(E, 250, L, o1) 395 let a25: i64 = o1[0] 396 nr_arousal(E, 500, L, o1) 397 let a50: i64 = o1[0] 398 nr_arousal(E, 1000, L, o1) 399 let a100: i64 = o1[0] 400 var t7: i64 = 0 401 if a25 < a50 { if a50 < a100 { if a100 <= 1000 { if a25 > 0 { t7 = 1 } } } } 402 gv_check("T7 MONOTONE: response rises strictly with stimulus and never exceeds full scale" as *u8, t7, ctr) 403 404 // ★★★THE LESION -- THE TOOTH A GLOBAL AROUSAL SCALAR CANNOT PASS. Cut S2,S3,S4. The pudendal 405 // afferent limb and the pelvic splanchnic efferent limb BOTH run those roots, so vasocongestion 406 // must fall to EXACTLY zero while cutaneous flush, on the thoracolumbar outflow, is UNCHANGED. 407 nr_arousal(E, 1000, L, o1) 408 L[82] = 1 409 L[83] = 1 410 L[84] = 1 411 nr_arousal(E, 1000, L, o2) 412 var t8: i64 = 0 413 if o2[0] == 0 { if o1[0] > 0 { if o2[2] == o1[2] { if o1[2] > 0 { t8 = 1 } } } } 414 gv_check("T8 LESION DISSOCIATES: S2-S4 cut zeroes vasocongestion, leaves flush UNCHANGED" as *u8, t8, ctr) 415 416 // ★★★T12 IS THE TOOTH WHOSE ABSENCE LET A WRONG MODEL SHIP 11/11 GREEN. T8 only asked about TWO 417 // effectors, so it never noticed that the same lesion was also stopping the heart from being 418 // braked, the pupil from being constricted and the eye from being wetted. The correct assertion is 419 // about the lesion's BLAST RADIUS: cutting S2-S4 may change the ONE effector that has a sacral 420 // parasympathetic supply and NOTHING ELSE. ★LAW: a dissociation tooth must count the effectors that 421 // DID NOT move, not only the two you had in mind. 422 var changed: i64 = 0 423 e = 0 424 while e < NR_NE { 425 if o1[e] != o2[e] { changed = changed + 1 } 426 e = e + 1 427 } 428 var t12: i64 = 0 429 if changed == 1 { if o2[0] != o1[0] { t12 = 1 } } 430 gv_check("T12 CRANIAL SPARING: a sacral lesion moves EXACTLY the one sacral effector, nothing else" as *u8, t12, ctr) 431 432 L[82] = 0 433 L[83] = 0 434 L[84] = 0 435 436 var t9: i64 = 0 437 var diff: i64 = 0 438 e = 0 439 while e < NR_NE { 440 if nr_out(E,e,1000,0,0,L) != nr_out(E,e,0,1000,1000,L) { diff = diff + 1 } 441 e = e + 1 442 } 443 if diff >= 3 { t9 = 1 } 444 gv_check("T9 DIVISIONS DISTINCT: sympathetic and parasympathetic differ on 3 or more effectors" as *u8, t9, ctr) 445 446 let hr_s: i64 = nr_out(E, 6, 1000, 0, 0, L) 447 let hr_p: i64 = nr_out(E, 6, 0, 1000, 0, L) 448 let hr_b: i64 = nr_ebase(E, 6) 449 var t10: i64 = 0 450 if hr_s > hr_b { if hr_p < hr_b { t10 = 1 } } 451 gv_check("T10 ANTAGONISM: sympathetic RAISES and parasympathetic LOWERS the same effector" as *u8, t10, ctr) 452 453 var t11: i64 = 0 454 var risk: i64 = 0 455 n = 0 456 while n < NR_NN { 457 if N[n*NR_NS+7] == 1 { risk = risk + 1 } 458 n = n + 1 459 } 460 if risk >= 6 { t11 = 1 } 461 gv_check("T11 SURGICAL: the map names its own danger-zone nerves" as *u8, t11, ctr) 462 463 gv_puts("\n AROUSAL PROFILE, per-mille of each effector's own range, stimulus 1000:\n" as *u8) 464 gv_puts(" effector intact S2-S4 cut\n" as *u8) 465 nr_arousal(E, 1000, L, o1) 466 L[82] = 1 467 L[83] = 1 468 L[84] = 1 469 nr_arousal(E, 1000, L, o2) 470 L[82] = 0 471 L[83] = 0 472 L[84] = 0 473 e = 0 474 while e < NR_NE { 475 gv_puts(" " as *u8) 476 gv_puts(nr_name(E[e*NR_ES+7])) 477 gv_puts(" " as *u8) 478 gv_num(o1[e]) 479 gv_puts(" " as *u8) 480 gv_num(o2[e]) 481 gv_puts("\n" as *u8) 482 e = e + 1 483 } 484 gv_puts("\n HONEST COVERAGE: " as *u8) 485 gv_num(nr_ncount()) 486 gv_puts(" named routes over " as *u8) 487 gv_num(nr_root_count()) 488 gv_puts(" root pairs, driving " as *u8) 489 gv_num(nr_ecount()) 490 gv_puts(" effectors and all 21 modelled muscles. That is 21 of ~700 named muscles and 37 of 86-plus nerve pairs BEFORE branching -- the MAP is checkable now, the COVERAGE is still small, and the next rows must arrive SOURCED, never typed to raise the count.\n" as *u8) 491 gv_puts(" DECLARED RESIDUAL: nerve COURSES are not geometry yet -- a route knows its roots and its target, not the path between them. Courses should be derived as joint-a/joint-b/t stations from nx_skelgen, exactly as nx_myoattach derives attachments, so no coordinate is ever typed.\n" as *u8) 492 493 return gv_verdict("NEURO-GATE" as *u8, ctr, 494 "innervation as a checkable map: outflow laws refuse impossible routes, every muscle wired, and a sacral lesion dissociates arousal from flush" as *u8) 495}