code wiki / (root) / nx_kernel_v2.nx

nx_kernel_v2.nx

buildroot/runtime/nx_kernel_v2.nx

28006 B725 linesdepth 5pulls 5 transitivereach 137 importersview sourcekind librarytopic kernel
docsdependenciesstructsconstsfunctions

about

nx_kernel_v2.nx -- SEMANTIC proof kernel. Real verification, not structural box-checking. Per user 2026-05-15: "nishi lang must generate superior to all other systems proofs not just two level i tlooks good bullshit". HOL Light's kernel is ~500 lines OCaml that implements ~10 primitive inference rules with formal correctness arguments. Every rule does SEMANTIC verification: modus ponens checks that the conclusion is the consequent of the implication premise. Coq, Lean, Isabelle all follow the same LCF discipline. nx_derive (v1) only checks STRUCTURE (rule arity, premise ordering, axiom code validity). Statements were opaque i64 IDs. That was "two-level it looks good bullshit" -- structurally a derivation chain, but the kernel never verifies the statements actually fit the rules' semantics. THIS KERNEL IS DIFFERENT: - Statements are first-class *Term values (real logical formulas) - Each inference rule does SEMANTIC verification of its premises against its claimed conclusion - Built on existing nx_unify Term + nx_subst infrastructure Semantic rules implemented (this commit): AXIOM leaf, must cite a registered axiom Term ASSUMPTION leaf, marks discharged assumptions MODUS_PONENS premise (A => B), premise A; conclusion = B -- kernel CHECKS: premise1 is App(=>, A, B); A == premise2 AND_INTRO premise A, premise B; conclusion = And(A, B) -- kernel CHECKS: conclusion is App(&, premise1, premise2) AND_ELIM_L premise And(A, B); conclusion = A AND_ELIM_R premise And(A, B); conclusion = B IMP_INTRO premise B (under assumption A); conclusion = A => B -- kernel CHECKS: conclusion is App(=>, A, B) SUBST premise (a == b), premise P[a]; conclusion = P[b] -- kernel CHECKS: conclusion = P with a replaced by b REFL no premise; conclusion = (a == a) CONTRADICTION premise A, premise (~A); conclusion = false

dependencies 5 imports · 70 importers

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_result.nx nx_unify.nx nx_kernel_v2.nx _min2.nx _pp_minimal.nx _pp_minimal2.nx nx_arith.nx nx_atomic_intrinsic_test.nx nx_calc.nx nx_chan_mpmc_test.nx nx_chem.nx nx_chem_molecule.nx nx_chem_smiles.nx

diagram shows first 10 each side; +0 more imports, +60 more importers in the complete lists below.

imports: nx_syscalls.nxnx_runtime.nxnx_tier.nxnx_result.nxnx_unify.nx

imported by: _min2.nx_pp_minimal.nx_pp_minimal2.nxnx_arith.nxnx_atomic_intrinsic_test.nxnx_calc.nxnx_chan_mpmc_test.nxnx_chem.nxnx_chem_molecule.nxnx_chem_smiles.nxnx_classical.nxnx_compare_systems.nxnx_dot_simd_demo.nxnx_fn_ptr_assign_test.nxnx_fn_ptr_test.nxnx_fn_ptr_typed_test.nxnx_hw_simd_caps_test.nxnx_ident_len_gate.nxnx_kernel_v2_discharge_test.nxnx_kernel_v2_test.nxnx_legal_audit.nxnx_lemma_import.nxnx_lia.nxnx_linalg.nxnx_log_v2_test.nxnx_macro_argcap_probe.nxnx_macro_axis_gate.nxnx_macro_nest_gate.nxnx_macro_test.nxnx_macro_v2_test.nxnx_macro_v3_test.nxnx_macro_v4_test.nxnx_macro_v5_test.nxnx_macro_v6_test.nxnx_macro_v7_test.nxnx_macro_v8_test.nxnx_mutex_race_test.nxnx_net_chan_blob_test.nxnx_net_chan_test.nxnx_parallel_simd_reduce.nxnx_parallel_test.nxnx_pipeline_test.nxnx_primitive_registry.nxnx_probability.nxnx_proof_emit.nxnx_proof_sqrt2_v2.nxnx_proof_sqrt2_v2_test.nxnx_proof_sqrt2_v3.nxnx_proof_sqrt2_v3_test.nxnx_prove_propositional.nxnx_remote_worker_test.nxnx_render_cli.nxnx_render_svg.nxnx_rewrite.nxnx_rpc_test.nxnx_simd_bench.nxnx_simd_i16x16_test.nxnx_simd_i32x8_test.nxnx_simd_i8x32_test.nxnx_simd_minmax_test.nxnx_simd_sat_test.nxnx_simd_usat_shift_test.nxnx_simd_vdot_test.nxnx_socket_pingpong_test.nxnx_sum_bench.nxnx_sum_bench_all.nxnx_task_graph_test.nxnx_thread_pool_test.nxnx_thread_spawn_test.nxnx_units.nx

structs

112struct K2Thm
122struct K2Chain

consts

63const NX_K2_AXIOM: nx_int = 1
64const NX_K2_ASSUMPTION: nx_int = 2
65const NX_K2_MODUS_PONENS: nx_int = 3
66const NX_K2_AND_INTRO: nx_int = 4
67const NX_K2_AND_ELIM_L: nx_int = 5
68const NX_K2_AND_ELIM_R: nx_int = 6
69const NX_K2_IMP_INTRO: nx_int = 7
70const NX_K2_SUBST: nx_int = 8
71const NX_K2_REFL: nx_int = 9
72const NX_K2_CONTRADICTION: nx_int = 10
73const NX_K2_NOT_INTRO: nx_int = 11
74const NX_K2_OR_INTRO_L: nx_int = 12
75const NX_K2_OR_INTRO_R: nx_int = 13
76const NX_K2_OR_ELIM: nx_int = 14
77const NX_K2_EQ_SYM: nx_int = 15
78const NX_K2_EQ_TRANS: nx_int = 16
79const NX_K2_EX_FALSO: nx_int = 17
85const NX_K2_SYM_IMP: nx_int = 400001 // implication =>
86const NX_K2_SYM_AND: nx_int = 400002 // conjunction &
87const NX_K2_SYM_OR: nx_int = 400003 // disjunction |
88const NX_K2_SYM_NOT: nx_int = 400004 // negation ~
89const NX_K2_SYM_EQ: nx_int = 400005 // equality ==
90const NX_K2_SYM_FALSE: nx_int = 400006 // contradiction false
93const NX_K2_OK: nx_int = 0
94const NX_K2_ERR_BAD_ARITY: nx_int = 1
95const NX_K2_ERR_BAD_PREMISE: nx_int = 2
96const NX_K2_ERR_NOT_IMPL: nx_int = 3
97const NX_K2_ERR_NOT_AND: nx_int = 4
98const NX_K2_ERR_MISMATCH: nx_int = 5
99const NX_K2_ERR_BAD_INDEX: nx_int = 6
100const NX_K2_ERR_NO_THEOREM: nx_int = 7
101const NX_K2_ERR_NOT_ASSUMP: nx_int = 8
102const NX_K2_ERR_NOT_FALSE: nx_int = 9
103const NX_K2_ERR_NOT_OR: nx_int = 10
104const NX_K2_ERR_NOT_EQ: nx_int = 11
105const NX_K2_ERR_HYP_NOT_FND: nx_int = 12
120const NX_K2_THM_BYTES: nx_int = 48
128const NX_K2_CHAIN_BYTES: nx_int = 24

functions

130func nx_k2_chain_new(cap: nx_int) -> *K2Chain
139func nx_k2_at(ch: *K2Chain, i: nx_int) -> *K2Thm
145func nx_k2_imp(a: *Term, b: *Term) -> *Term
154func nx_k2_and(a: *Term, b: *Term) -> *Term
163func nx_k2_or(a: *Term, b: *Term) -> *Term
172func nx_k2_not(a: *Term) -> *Term
178func nx_k2_eq(a: *Term, b: *Term) -> *Term
187func nx_k2_false() -> *Term
called by 1: nx_k2_contradiction calls 1: nx_term_app
196func nx_k2_hyps_alloc(cap: nx_int) -> *Term
201func nx_k2_hyps_at(hyps: *Term, i: nx_int) -> *Term
205func nx_k2_hyps_copy_in(dst: *Term, di: nx_int, src: *Term)
214func nx_k2_hyps_contains(hyps: *Term, n: nx_int, t: *Term) -> nx_int
227func nx_k2_hyps_union(a: *Term, na: nx_int, b: *Term, nb: nx_int, out_n: *nx_int) -> *Term
261func nx_k2_hyps_remove(src: *Term, n: nx_int, target: *Term, out_n: *nx_int) -> *Term
304func nx_k2_inherit_2(ch: *K2Chain, t: *K2Thm, pa_idx: nx_int, pb_idx: nx_int)
314func nx_k2_inherit_1(ch: *K2Chain, t: *K2Thm, pa_idx: nx_int)
332func nx_k2_axiom(ch: *K2Chain, stmt: *Term) -> nx_int
348func nx_k2_assume(ch: *K2Chain, stmt: *Term) -> nx_int
366func nx_k2_imp_intro(ch: *K2Chain, prem_assumption: nx_int, prem_b: nx_int) -> nx_int
398func nx_k2_not_intro(ch: *K2Chain, prem_assumption: nx_int, prem_false: nx_int) -> nx_int
428func nx_k2_or_intro_l(ch: *K2Chain, prem_a: nx_int, b: *Term) -> nx_int
450func nx_k2_or_intro_r(ch: *K2Chain, a: *Term, prem_b: nx_int) -> nx_int
472func nx_k2_eq_sym(ch: *K2Chain, prem: nx_int) -> nx_int
496func nx_k2_ex_falso(ch: *K2Chain, prem_false: nx_int, c: *Term) -> nx_int
517func nx_k2_eq_trans(ch: *K2Chain, prem_ab: nx_int, prem_bc: nx_int) -> nx_int
550func nx_k2_modus_ponens(ch: *K2Chain, prem_imp: nx_int, prem_a: nx_int) -> nx_int
579func nx_k2_and_intro(ch: *K2Chain, prem_a: nx_int, prem_b: nx_int) -> nx_int
602func nx_k2_and_elim_l(ch: *K2Chain, prem: nx_int) -> nx_int
623func nx_k2_and_elim_r(ch: *K2Chain, prem: nx_int) -> nx_int
644func nx_k2_refl(ch: *K2Chain, a: *Term) -> nx_int
660func nx_k2_contradiction(ch: *K2Chain, prem_a: nx_int, prem_neg: nx_int) -> nx_int
689func nx_k2_mark_theorem(ch: *K2Chain) -> nx_int
701func nx_k2_mark_theorem_open(ch: *K2Chain) -> nx_int
710func nx_k2_verify(ch: *K2Chain) -> nx_int