code wiki / (root) / nx_theorem_ingest.nx

nx_theorem_ingest.nx

buildroot/runtime/nx_theorem_ingest.nx

17572 B416 linesdepth 5pulls 9 transitivereach 6 importersview sourcekind librarytopic theorem
docsdependenciesstructsconstsfunctions

about

nx_theorem_ingest.nx -- ingest machine-readable theorem corpora. Strategy doc: docs/THEOREM_INGESTION_STRATEGY.md Phase P0 implementation: minimal MetaMath-style tokenizer + chain builder + ingestion driver. Reads a corpus from disk via sys_read_file, parses statements, translates proof tokens into DerivationChain objects, runs nx_deriv_verify, emits ledger entry. MetaMath statement grammar (subset we accept in P0): $c c1 c2 ... $. declare constants $v v1 v2 ... $. declare variables $f label v term $. variable-type hypothesis $e label term $. logical hypothesis $a label term $. axiom assertion $p label term $= proof-tokens $. provable theorem with proof $( comment $) comment block ${ ... $} scope block We focus on $a / $p / $e since those carry the substrate-relevant structure. $c / $v / $f are tracked as a symbol table. genealogy_id: megill_metamath_1992 + russell_whitehead_1910 (formal_proof) lineage_id: formal_proof_theory + token_substitution

dependencies 5 imports · 5 importers

syscalls.nx nx_axioms.nx nx_derive.nx nx_lex.nx nx_loop.nx nx_theorem_ingest.nx nx_corpus_drive.nx nx_five_systems_test.nx nx_ingest_at_scale.nx nx_ingest_pipeline.nx nx_theorem_ingest_test.nx

imports: syscalls.nxnx_axioms.nxnx_derive.nxnx_lex.nxnx_loop.nx

imported by: nx_corpus_drive.nxnx_five_systems_test.nxnx_ingest_at_scale.nxnx_ingest_pipeline.nxnx_theorem_ingest_test.nx

structs

75struct IngestTheorem
82struct IngestDb

consts

41const NX_INGEST_OK: i64 = 0
42const NX_INGEST_TOKENIZE_ERROR: i64 = -1
43const NX_INGEST_UNKNOWN_STATEMENT: i64 = -2
44const NX_INGEST_UNMAPPED_AXIOM: i64 = -3
45const NX_INGEST_VERIFY_FAILED: i64 = -4
46const NX_INGEST_OUT_OF_CAPACITY: i64 = -5
47const NX_INGEST_BAD_PROOF_TOKEN: i64 = -6
51const NX_MM_TOK_NONE: i64 = 0
52const NX_MM_TOK_LABEL: i64 = 1 // identifier
53const NX_MM_TOK_DOLLAR_A: i64 = 2 // $a
54const NX_MM_TOK_DOLLAR_P: i64 = 3 // $p
55const NX_MM_TOK_DOLLAR_E: i64 = 4 // $e
56const NX_MM_TOK_DOLLAR_F: i64 = 5 // $f
57const NX_MM_TOK_DOLLAR_C: i64 = 6 // $c
58const NX_MM_TOK_DOLLAR_V: i64 = 7 // $v
59const NX_MM_TOK_DOLLAR_EQ: i64 = 8 // $=
60const NX_MM_TOK_DOLLAR_DOT: i64 = 9 // $.
61const NX_MM_TOK_DOLLAR_LBR: i64 = 10 // $
62const NX_MM_TOK_DOLLAR_RBR: i64 = 11 // $}
63const NX_MM_TOK_DOLLAR_LPAREN: i64 = 12 // $(
64const NX_MM_TOK_DOLLAR_RPAREN: i64 = 13 // $)
71const NX_INGEST_MAX_THEOREMS: i64 = 1024
72const NX_INGEST_MAX_LABEL_LEN: i64 = 64
73const NX_INGEST_THEOREM_BYTES: i64 = 88 // label(64) + kind(8) + n_proof(8) + chain(8)

functions

90func nx_ingest_db_alloc() -> *IngestDb
101func nx_ingest_th_at(db: *IngestDb, i: i64) -> *IngestTheorem
115func nx_mm_skip_ws(buf: *u8, pos: *i64, len: i64) -> i64
165func nx_mm_next_token(buf: *u8, pos: *i64, len: i64,
214func nx_ingest_axiom_lookup(name: *u8) -> i64
called by 1: nx_ingest_corpus
278func nx_ingest_corpus(buf: *u8, len: i64) -> *IngestDb
407func nx_ingest_file(path: *u8) -> *IngestDb