nx_theorem_ingest.nx
buildroot/runtime/nx_theorem_ingest.nx
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
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
| 75 | struct IngestTheorem |
| 82 | struct IngestDb |
consts
| 41 | const NX_INGEST_OK: i64 = 0 |
| 42 | const NX_INGEST_TOKENIZE_ERROR: i64 = -1 |
| 43 | const NX_INGEST_UNKNOWN_STATEMENT: i64 = -2 |
| 44 | const NX_INGEST_UNMAPPED_AXIOM: i64 = -3 |
| 45 | const NX_INGEST_VERIFY_FAILED: i64 = -4 |
| 46 | const NX_INGEST_OUT_OF_CAPACITY: i64 = -5 |
| 47 | const NX_INGEST_BAD_PROOF_TOKEN: i64 = -6 |
| 51 | const NX_MM_TOK_NONE: i64 = 0 |
| 52 | const NX_MM_TOK_LABEL: i64 = 1 // identifier |
| 53 | const NX_MM_TOK_DOLLAR_A: i64 = 2 // $a |
| 54 | const NX_MM_TOK_DOLLAR_P: i64 = 3 // $p |
| 55 | const NX_MM_TOK_DOLLAR_E: i64 = 4 // $e |
| 56 | const NX_MM_TOK_DOLLAR_F: i64 = 5 // $f |
| 57 | const NX_MM_TOK_DOLLAR_C: i64 = 6 // $c |
| 58 | const NX_MM_TOK_DOLLAR_V: i64 = 7 // $v |
| 59 | const NX_MM_TOK_DOLLAR_EQ: i64 = 8 // $= |
| 60 | const NX_MM_TOK_DOLLAR_DOT: i64 = 9 // $. |
| 61 | const NX_MM_TOK_DOLLAR_LBR: i64 = 10 // $ |
| 62 | const NX_MM_TOK_DOLLAR_RBR: i64 = 11 // $} |
| 63 | const NX_MM_TOK_DOLLAR_LPAREN: i64 = 12 // $( |
| 64 | const NX_MM_TOK_DOLLAR_RPAREN: i64 = 13 // $) |
| 71 | const NX_INGEST_MAX_THEOREMS: i64 = 1024 |
| 72 | const NX_INGEST_MAX_LABEL_LEN: i64 = 64 |
| 73 | const NX_INGEST_THEOREM_BYTES: i64 = 88 // label(64) + kind(8) + n_proof(8) + chain(8) |
functions
| 90 | func nx_ingest_db_alloc() -> *IngestDb |
| 101 | func nx_ingest_th_at(db: *IngestDb, i: i64) -> *IngestTheorem |
| 115 | func nx_mm_skip_ws(buf: *u8, pos: *i64, len: i64) -> i64 |
| 165 | func nx_mm_next_token(buf: *u8, pos: *i64, len: i64, |
| 214 | func nx_ingest_axiom_lookup(name: *u8) -> i64 called by 1: nx_ingest_corpus |
| 278 | func nx_ingest_corpus(buf: *u8, len: i64) -> *IngestDb |
| 407 | func nx_ingest_file(path: *u8) -> *IngestDb |