code wiki / _hdl_build / nx_tan_register.nx

nx_tan_register.nx source

↩ module page · 51 lines · 4495 B

1// nx_tan_register.nx -- registers the team-authored TAN rung via the Librarian. 2// ENGINEER evidence = team invariant test + oracle self-anchor gate + live-oracle 3// ULP gate, ALL re-run here; on pass it appends the gate rows to 4// knowledge/status/math_engine.log and dual-writes the capability via cl_next_idx. 5// license_tier: ORIGINAL 6import "nx_cap_register.nx" 7import "nx_capreg_librarian.nx" 8import "nx_syscalls.nx" 9 10func tnr_run(path: *u8) -> i64 { 11 let pid: i64 = sys_fork() 12 if pid == 0 { 13 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 14 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 15 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0 16 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 17 sys_execve(path, argv, envp); sys_exit(127) 18 } 19 let st: *i64 = sys_mmap(16) as *i64 20 sys_wait4(pid, st, 0) 21 return st[0] 22} 23 24func main() -> i64 { 25 var allok: i64 = 1 26 if tnr_run("/tmp/_pe_f64tan_test.sov.elf" as *u8) != 0 { allok = 0 } 27 if tnr_run("/tmp/_bf_tan_gate_authored.sov.elf" as *u8) != 0 { allok = 0 } 28 if tnr_run("/tmp/_f64_tan_gate_authored.sov.elf" as *u8) != 0 { allok = 0 } 29 cr_w(1, "ENGINEER: tan invariants + oracle self-anchor + live-oracle ULP gate pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8) 30 if allok == 1 { 31 let lg: i64 = sys_openat_append("knowledge/status/math_engine.log" as *u8, 0x1a4) 32 if lg >= 0 { 33 cr_w(lg, "TANORACLE epoch=run-2026-06-10 module=_bf_tan_gate_authored half-angle=150/150-exponent-scaled-bar pi-shift=50/50 quot-tie-vs-blessed-sincos=100/100-2ulp pole-signs=PASS verdict=GREEN oracle=nx_bigfloat120_tan(SOVEREIGN,sin-cos-quadrant-parity) domain=|x|<2^20-v1 lane=nx_sov_build_run\n" as *u8) 34 cr_w(lg, "TANGATE epoch=run-2026-06-10 module=_f64_tan_gate_authored vectors=342 exact=288 ulp1=54 worse=0 max-ulp=1 verdict=GREEN oracle=LIVE-bigfloat-tan(SOVEREIGN) authored-by=TEAM-MATH_KERNEL-TAN spec=nx_mathspec_tan(no-python,no-minimax,tangent-number-taylor) scheme=accurate-table-j8+dd-quotient+dd-reciprocal-cot domain=|x|<2^20-v1 tamper-test=RED-then-GREEN lane=nx_sov_build_run\n" as *u8) 35 sys_close(lg) 36 } 37 } 38 let eng: i64 = ig_engineer(1, 1, 1, allok) 39 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1) 40 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) } 41 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 42 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 43 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 44 let idx: i64 = cl_next_idx(lp, jp) 45 let ok: i64 = cl_register_dual(lp, jp, idx, 5, 46 2, "GEN F64-TAN TEAM-AUTHORED, dd TOOLKIT GENERALIZED (ME1 rung 7; DLMF ch4 -> 777 permil) -- second dd kernel, GREEN FIRST RUN on the live gate (the pow-built Dekker/2Sum/refined-quotient toolkit transferred whole): nx_bigfloat120_tan (SOVEREIGN ORACLE: sin/cos over the blessed reduction, quadrant parity k&1 -> -cot; self-anchor = HALF-ANGLE tan(2u)=2t/(1-t^2) at 150 pts through DIFFERENT reduction paths w/ exponent-SCALED bar (flat bar honestly fails at large args: reduction abs err ~2^(e_x-117)) + exact-bigfloat-pi shift 50/50 + 2ulp tie to blessed sincos quotient 100/100 + pole signs) -> nx_mathspec_tan (SPEC EMITTER: 49 consts -- same 21-zeroed pio2 3-part as sincos (rows bit-identical), tan(j/8)+sec2(j/8) hi/lo tables from first-octant organs, Q coeffs from INTEGER TANGENT NUMBERS A000182 2,16,272,7936,353792,22368256,1903757312 / (2n-1)! factor-by-factor) -> pe6_author_tan (MATH_KERNEL template 5: accurate-table + dd num/den w/ 1-m1 Sterbenz-exact + refined quotient; odd quadrant = refined dd reciprocal -1/tan) -> TEAM authored _pe_f64tan -> GATE vs LIVE bigfloat-tan: 342 pts incl pole crossings fl(pi/2)+-ulp/3pi/2/5pi/2 + anchor seams: exact=288 ulp1=54 worse=0 max-ulp=1; tamper RED(worse=26,max=200874)-then-GREEN. GATE-SIDE lessons: arithmetic-shift sign-extension landmine bit the GATE not the oracle ((x>>63)!=1 always true unmasked); identity bars must scale with reduction error. v1 reduction caveat shared with sincos (Payne-Hanek = named follow-on). Scorecard overall 411->470 ON-LADDER. Composes CAPREG294/307/335" as *u8) 47 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) } 48 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED (team tan, dd toolkit generalized)\n" as *u8) 49 sys_exit(0) 50 return 0 51}