nx_derive.nx
buildroot/runtime/nx_derive.nx
about
nx_derive.nx -- verifiable derivation chains from axioms to theorems.
"A mathematician can start from zero and build all the way into what
they are proposing or proving." -- user, 2026-05-10
This primitive enforces that discipline: every theorem the substrate
claims must show a derivation chain rooted in the foundational
axioms (nx_axioms.nx). Substrate runs nx_derive_verify on each
chain; any chain with an unrecognized axiom OR an unsupported rule
is REJECTED.
A derivation is a DAG of DerivationNode nodes:
- LEAF nodes cite an axiom (axiom_code != 0)
- INTERNAL nodes cite a rule_id + premise_ids
- One node is marked as the THEOREM (the derivation's conclusion)
Rules supported (closed enum):
modus_ponens A, A->B |- B
modus_tollens ~B, A->B |- ~A
universal_instant forall x P(x) |- P(t)
existential_gen P(t) |- exists x P(x)
substitution A=B, P(A) |- P(B)
induction P(0), P(n)->P(n+1) |- forall n P(n)
conjunction_intro A, B |- A^B
conjunction_elim A^B |- A (or B)
disjunction_intro A |- A v B
contradiction A, ~A |- false
contraposition A->B |- ~B->~A
transitivity_eq A=B, B=C |- A=C
trans_inequality A<=B, B<=C |- A<=C
genealogy_id: hilbert_1899 + frege_1879 + russell_whitehead_1910
lineage_id: formal_proof_theory
dependencies 2 imports · 23 importers
diagram shows first 10 each side; +0 more imports, +13 more importers in the complete lists below.
imports: syscalls.nxnx_axioms.nx
imported by: nx_atp_to_derive.nxnx_atp_to_derive_test.nxnx_auto_verify.nxnx_derive_test.nxnx_proof_infinitude_primes.nxnx_proof_infinitude_primes_test.nxnx_proof_methods.nxnx_proof_sqrt2_irrational.nxnx_proof_sqrt2_irrational_test.nxnx_proofs_comprehensive.nxnx_proofs_machine_checked.nxnx_proofs_pvsnp_pending.nxnx_proofs_top100.nxnx_proofs_top100_batch2.nxnx_proofs_top100_batch3.nxnx_proofs_top100_batch4.nxnx_proofs_top100_batch5.nxnx_proofs_top100_batch6_closing.nxnx_prover.nxnx_prover_a1.nxnx_prover_eval.nxnx_prover_test.nxnx_theorem_ingest.nx
structs
| 115 | struct DerivationNode |
| 127 | struct DerivationChain |
consts
| 46 | const NX_DRULE_AXIOM_CITATION: i64 = 0 |
| 47 | const NX_DRULE_MODUS_PONENS: i64 = 1 |
| 48 | const NX_DRULE_MODUS_TOLLENS: i64 = 2 |
| 49 | const NX_DRULE_UNIVERSAL_INSTANT: i64 = 3 |
| 50 | const NX_DRULE_EXISTENTIAL_GEN: i64 = 4 |
| 51 | const NX_DRULE_SUBSTITUTION: i64 = 5 |
| 52 | const NX_DRULE_INDUCTION: i64 = 6 |
| 53 | const NX_DRULE_CONJ_INTRO: i64 = 7 |
| 54 | const NX_DRULE_CONJ_ELIM: i64 = 8 |
| 55 | const NX_DRULE_DISJ_INTRO: i64 = 9 |
| 56 | const NX_DRULE_CONTRADICTION: i64 = 10 |
| 57 | const NX_DRULE_CONTRAPOSITION: i64 = 11 |
| 58 | const NX_DRULE_TRANSITIVITY_EQ: i64 = 12 |
| 59 | const NX_DRULE_TRANS_INEQUALITY: i64 = 13 |
| 60 | const NX_DRULE_ALGEBRA_REWRITE: i64 = 14 // e.g., distributivity application |
| 61 | const NX_DRULE_DEFINITION: i64 = 15 // expansion of a definition |
| 125 | const NX_DERIV_NODE_BYTES: i64 = 56 |
| 217 | const NX_DERIV_VERIFY_OK: i64 = 0 |
| 218 | const NX_DERIV_VERIFY_NO_NODES: i64 = -10 |
| 219 | const NX_DERIV_VERIFY_UNKNOWN_AXIOM: i64 = -11 |
| 220 | const NX_DERIV_VERIFY_UNKNOWN_RULE: i64 = -12 |
| 221 | const NX_DERIV_VERIFY_ARITY_MISMATCH: i64 = -13 |
| 222 | const NX_DERIV_VERIFY_PREMISE_OUT_OF_ORDER: i64 = -14 |
| 223 | const NX_DERIV_VERIFY_NO_THEOREM: i64 = -15 |
| 224 | const NX_DERIV_VERIFY_MULTIPLE_THEOREMS: i64 = -16 |
functions
| 63 | func nx_drule_name(code: i64) -> *u8 called by 1: nx_deriv_walk |
| 84 | func nx_drule_arity(code: i64) -> i64 |
| 133 | func nx_deriv_chain_alloc(capacity: i64) -> *DerivationChain |
| 142 | func nx_deriv_node_at(ch: *DerivationChain, i: i64) -> *DerivationNode |
| 147 | func nx_deriv_add_axiom(ch: *DerivationChain, stmt_id: i64, |
| 165 | func nx_deriv_add_step(ch: *DerivationChain, stmt_id: i64, |
| 200 | func nx_deriv_mark_theorem(ch: *DerivationChain) -> i64 called by 13: mainnx_proof_infinitude_primesnx_proof_sqrt2_irrationalmainmainmain+7 calls 1: nx_deriv_node_at |
| 226 | func nx_deriv_verify(ch: *DerivationChain) -> i64 |
| 267 | func dw_putc(fd: i64, c: i64) -> i64 called by 1: dw_i64 |
| 274 | func dw_str(fd: i64, s: *u8, len: i64) -> i64 called by 1: nx_deriv_walk |
| 279 | func dw_strz(fd: i64, s: *u8) -> i64 called by 1: nx_deriv_walk |
| 286 | func dw_i64(fd: i64, n: i64) -> i64 |
| 310 | func nx_deriv_walk(fd: i64, ch: *DerivationChain) -> i64 |