code wiki / _hdl_build / nx_tex_gate.nx

nx_tex_gate.nx

buildroot/runtime/_hdl_build/nx_tex_gate.nx

16484 B309 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic tex
docsdependenciesstructsconstsfunctions

about

nx_tex_gate.nx -- REFEREE for the sovereign LaTeX-math -> MathML renderer (nx_tex). Proves the renderer is CORRECT + produces WELL-FORMED MathML on a battery of hand-verified Known-Answer Tests, and degrades GRACEFULLY on bad input. GREEN iff every check holds. CHECKS (all on REAL tx_render output, nothing hand-faked): A. EXACT-MATHML KATs (11): each LaTeX input must render byte-for-byte to the hand-verified expected MathML. Covers: x^2 (msup), \frac{a}{b} (mfrac), \sqrt{x+1} (msqrt over mrow), \sum_{i=1}^{n} i (munderover, sum-style limits), \int_{0}^{\infty} x (msubsup, integral limits + greek \infty), \alpha+\beta (greek entities), the BM25-style \frac{f}{f+k} (the exact shape of the ranker the wiki search uses), a_i^2 (msubsup -- sub AND sup on one base, NOT nested), a relations chain (\le \neq \approx as proper <mo> entities), and \left( a+b \right) (fenced mrow). B. WELL-FORMEDNESS: every KAT output passes a balanced-tag check (a tag stack: every opener is closed by the matching closer in order, no underflow, empty at end) AND is wrapped in a single <math>...</math>. This is asserted INDEPENDENTLY of the exact-string check, so even a future renderer change that still produces balanced output is verified structurally. C. NEGATIVE CONTROL (graceful degradation): an UNSUPPORTED command (\badcmd{x}) must NOT crash and must yield balanced MathML containing an <merror> fallback (no malformed bytes). A second teeth case proves the well-formedness checker has TEETH: a deliberately UNBALANCED string (<math><mrow></math>) must be REJECTED by the checker (else greens are fabricatable). VERIFICATION DOCTRINE: MathML is a STANDARD (non-novel) format. The renderer is sovereign; rigor comes from these hand-verified expected-MathML KATs + the balanced-tag well-formedness proof. A 3rd-party structural cross-check (latexml / node+mathjax) is the NEXT rigor step -- this gate probes for those tools and logs the cross-check as PENDING when (as here) none is runnable. We do NOT claim a 3rd-party comparison was made. Evidence -> knowledge/status/tex_gate.log. Sovereign: imports nx_tex + nx_framed_append + nx_syscalls. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_tex.nx nx_framed_append.nx nx_syscalls.nx nx_tex_gate.nx

imports: nx_tex.nxnx_framed_append.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main tg_w sys_write sys_mmap tg_kat sys_mmap ↻ tx_render tx_slen sys_mmap ↻ tx_emit tg_streq well_formed sys_mmap ↻ tg_slen tg_streq ↻ tg_w ↻ tg_num sys_mmap ↻ sys_write ↻ tg_cat tg_catn sys_mmap ↻ fa_appendz fa_append sys_mmap ↻ sys_openat_append sys_flock fa_write_all sys_write ↻ sys_close fa_len

structs

none

consts

32const TG_LOG: *u8 = "knowledge/status/tex_gate.log"
33const TG_RECCAP: i64 = 1024
34const TG_OUT_CAP: i64 = 65536
65const C_LT: i64 = 60 // <
66const C_GT: i64 = 62 // >
67const C_SLASH: i64 = 47 // /
68const C_SP: i64 = 32 // space
69const C_NUL: i64 = 0
79const WF_STACK_MAX: i64 = 256
80const WF_NAME_MAX: i64 = 32

functions

37func tg_w(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 2: tg_katmain calls 1: sys_write
38func tg_num(v: i64) -> i64
called by 1: tg_kat calls 2: sys_mmapsys_write
47func tg_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != 0 as u8 { dst[off + i] = s[i]; i = i + 1 } return off + i }
called by 1: tg_kat
48func tg_catn(dst: *u8, off: i64, v: i64) -> i64
called by 1: tg_kat calls 1: sys_mmap
57func tg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: well_formed
58func tg_streq(a: *u8, b: *u8) -> i64
called by 2: well_formedtg_kat
81func well_formed(s: *u8) -> i64
called by 1: tg_kat calls 3: sys_mmaptg_slentg_streq
143func tg_kat(name: *u8, latex: *u8, expect: *u8) -> i64
176func main() -> i64