code wiki / (root) / nx_ot_replay.nx

nx_ot_replay.nx

buildroot/runtime/nx_ot_replay.nx

10287 B281 linesdepth 7pulls 7 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_ot_replay.nx -- OpenTheory replay engine. Per user 2026-05-15: "world class". Per the comparison-engine commit's named improvement for library_size LOSE_BIG vs HOL Light. OpenTheory is the kernel-independent proof-exchange format from gilith.com/opentheory/article.html. HOL kernels (HOL Light, HOL4, ProofPower, Isabelle/HOL) export their proofs as a list of stack machine instructions; any HOL-compatible kernel can replay them and re-derive each theorem natively. THIS ENGINE: a stack-based interpreter that executes OpenTheory- style instructions. Each opcode that produces a Theorem dispatches to a v2 kernel emitter, so every replayed theorem becomes a real kernel-checked chain in our K2Chain. No third-party trust: the source is the input, OUR kernel is the verifier. Every successful `thm` opcode registers an entry in the supplied LemmaLib with NX_LEMMA_PROVED_NATIVE_REPLAYED status. This is the honest framing per [[feedback-no-third-party-trust-native-or-nothing]]: the proof BODY was replayed natively; the SOURCE is preserved as provenance metadata. What this commit ships: - Stack machine + 8 opcodes (num, term, axiom, refl, mp, assume, imp_intro, thm) - Programmatic replay (caller assembles an instruction array) Named follow-up: - .ot file parser (read ASCII OpenTheory format from file) - Full opcode coverage (absTerm, appTerm, defineConst, subst, deductAntisym, eqMp, etc. -- ~30 total)

dependencies 1 imports · 1 importers

nx_lemma_import.nx nx_ot_replay.nx nx_ot_replay_test.nx

imports: nx_lemma_import.nx

imported by: nx_ot_replay_test.nx

structs

56struct OTInstr
71struct OTValue
87struct OTStack

consts

42const NX_OT_OP_NUM: nx_int = 1
43const NX_OT_OP_TERM: nx_int = 2
44const NX_OT_OP_AXIOM: nx_int = 3
45const NX_OT_OP_REFL: nx_int = 4
46const NX_OT_OP_MP: nx_int = 5
47const NX_OT_OP_ASSUME: nx_int = 6
48const NX_OT_OP_IMP_INTRO: nx_int = 7
49const NX_OT_OP_AND_INTRO: nx_int = 8
50const NX_OT_OP_THM: nx_int = 9
51const NX_OT_OP_NAME: nx_int = 10
63const NX_OT_INSTR_BYTES: nx_int = 40
78const NX_OT_VAL_BYTES: nx_int = 40
80const NX_OT_VAL_NUM: nx_int = 1
81const NX_OT_VAL_TERM: nx_int = 2
82const NX_OT_VAL_THM: nx_int = 3
83const NX_OT_VAL_NAME: nx_int = 4
85const NX_OT_STACK_CAP: nx_int = 256
92const NX_OT_STACK_BYTES: nx_int = 24
151const NX_OT_OK: nx_int = 0
152const NX_OT_ERR_STACK: nx_int = -1
153const NX_OT_ERR_BAD_OP: nx_int = -2
154const NX_OT_ERR_KIND: nx_int = -3
155const NX_OT_ERR_KERNEL: nx_int = -4

functions

65func nx_ot_instr_at(prog: *OTInstr, i: nx_int) -> *OTInstr
94func nx_ot_stack_new() -> *OTStack
called by 1: nx_ot_replay
102func nx_ot_stack_at(s: *OTStack, i: nx_int) -> *OTValue
106func nx_ot_stack_push_num(s: *OTStack, n: nx_int) -> nx_int
called by 1: nx_ot_step calls 1: nx_ot_stack_at
115func nx_ot_stack_push_term(s: *OTStack, t: *Term) -> nx_int
called by 1: nx_ot_step calls 1: nx_ot_stack_at
124func nx_ot_stack_push_thm(s: *OTStack, chain_idx: nx_int) -> nx_int
called by 1: nx_ot_step calls 1: nx_ot_stack_at
133func nx_ot_stack_push_name(s: *OTStack, name: *u8, name_len: nx_int) -> nx_int
called by 1: nx_ot_step calls 1: nx_ot_stack_at
143func nx_ot_stack_pop(s: *OTStack) -> *OTValue
called by 1: nx_ot_step calls 1: nx_ot_stack_at
157func nx_ot_step(
268func nx_ot_replay(