code wiki / (root) / nx_derive.nx

nx_derive.nx

buildroot/runtime/nx_derive.nx

12821 B342 linesdepth 3pulls 4 transitivereach 35 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

syscalls.nx nx_axioms.nx nx_derive.nx nx_atp_to_derive.nx nx_atp_to_derive_test.nx nx_auto_verify.nx nx_derive_test.nx nx_proof_infinitude_primes.nx nx_proof_infinitude_primes_test.nx nx_proof_methods.nx nx_proof_sqrt2_irrational.nx nx_proof_sqrt2_irrational_test.nx nx_proofs_comprehensive.nx

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

115struct DerivationNode
127struct DerivationChain

consts

46const NX_DRULE_AXIOM_CITATION: i64 = 0
47const NX_DRULE_MODUS_PONENS: i64 = 1
48const NX_DRULE_MODUS_TOLLENS: i64 = 2
49const NX_DRULE_UNIVERSAL_INSTANT: i64 = 3
50const NX_DRULE_EXISTENTIAL_GEN: i64 = 4
51const NX_DRULE_SUBSTITUTION: i64 = 5
52const NX_DRULE_INDUCTION: i64 = 6
53const NX_DRULE_CONJ_INTRO: i64 = 7
54const NX_DRULE_CONJ_ELIM: i64 = 8
55const NX_DRULE_DISJ_INTRO: i64 = 9
56const NX_DRULE_CONTRADICTION: i64 = 10
57const NX_DRULE_CONTRAPOSITION: i64 = 11
58const NX_DRULE_TRANSITIVITY_EQ: i64 = 12
59const NX_DRULE_TRANS_INEQUALITY: i64 = 13
60const NX_DRULE_ALGEBRA_REWRITE: i64 = 14 // e.g., distributivity application
61const NX_DRULE_DEFINITION: i64 = 15 // expansion of a definition
125const NX_DERIV_NODE_BYTES: i64 = 56
217const NX_DERIV_VERIFY_OK: i64 = 0
218const NX_DERIV_VERIFY_NO_NODES: i64 = -10
219const NX_DERIV_VERIFY_UNKNOWN_AXIOM: i64 = -11
220const NX_DERIV_VERIFY_UNKNOWN_RULE: i64 = -12
221const NX_DERIV_VERIFY_ARITY_MISMATCH: i64 = -13
222const NX_DERIV_VERIFY_PREMISE_OUT_OF_ORDER: i64 = -14
223const NX_DERIV_VERIFY_NO_THEOREM: i64 = -15
224const NX_DERIV_VERIFY_MULTIPLE_THEOREMS: i64 = -16

functions

63func nx_drule_name(code: i64) -> *u8
called by 1: nx_deriv_walk
84func nx_drule_arity(code: i64) -> i64
133func nx_deriv_chain_alloc(capacity: i64) -> *DerivationChain
142func nx_deriv_node_at(ch: *DerivationChain, i: i64) -> *DerivationNode
147func nx_deriv_add_axiom(ch: *DerivationChain, stmt_id: i64,
165func nx_deriv_add_step(ch: *DerivationChain, stmt_id: i64,
200func nx_deriv_mark_theorem(ch: *DerivationChain) -> i64
226func nx_deriv_verify(ch: *DerivationChain) -> i64
267func dw_putc(fd: i64, c: i64) -> i64
called by 1: dw_i64
274func dw_str(fd: i64, s: *u8, len: i64) -> i64
called by 1: nx_deriv_walk
279func dw_strz(fd: i64, s: *u8) -> i64
called by 1: nx_deriv_walk
286func dw_i64(fd: i64, n: i64) -> i64
called by 2: dw_i64nx_deriv_walk calls 2: dw_putcdw_i64
310func nx_deriv_walk(fd: i64, ch: *DerivationChain) -> i64