code wiki / (root) / nx_autoformalize_lib.nx

nx_autoformalize_lib.nx

buildroot/runtime/nx_autoformalize_lib.nx

19392 B408 linesdepth 7pulls 7 transitivereach 11 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_autoformalize_lib.nx -- the CANONICAL autoformalization library (pure funcs, no main), extracted 2026-07-15 from nx_autoformalize.nx so other organs can compose the verifier (the propose->verify loop: an LLM PROPOSES, this kernel-backed checker DISPOSES). Same code, zero behavior change; the organ's own gate battery re-proves it after the split. af_decide(claim, vb) -> 1 PROVED · 2 REFUTED · 3 UNSUPPORTED · 5 NO-SOLUTION · -1 kernel failure Grammar: "<n|what> [plus|times <n|what>] =|equals|is|<|under|<= <n>", digits or words zero..twelve; plus operands <= 12, times operands <= 6, rhs <= 144. Everything derives through the LCF v2 kernel (nx_k2_verify checks the whole chain; a wrong claim CANNOT certify -- soundness by construction). license_tier: ORIGINAL (lib: no main -- build standalone gives rc=102 by design)

dependencies 1 imports · 3 importers

nx_arith.nx nx_autoformalize_lib.nx nx_autoformalize.nx nx_autoformalize_cap_probe.nx nx_propose_verify_lib.nx

imports: nx_arith.nx

imported by: nx_autoformalize.nxnx_autoformalize_cap_probe.nxnx_propose_verify_lib.nx

structs

none

consts

none

functions

12func af_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
13func af_n(v: i64) -> i64
called by 2: mainaf_decide calls 1: af_w
26func af_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 }
29func af_tok_num(t: *u8) -> i64
called by 1: af_parse calls 1: af_streq
53func af_tok_plus(t: *u8) -> i64 { if af_streq(t, "+" as *u8) == 1 { return 1 } if af_streq(t, "plus" as *u8) == 1 { return 1 } return 0 }
called by 1: af_parse calls 1: af_streq
54func af_tok_times(t: *u8) -> i64 { if af_streq(t, "*" as *u8) == 1 { return 1 } if af_streq(t, "times" as *u8) == 1 { return 1 } return 0 }
called by 1: af_parse calls 1: af_streq
55func af_tok_eqw(t: *u8) -> i64 { if af_streq(t, "=" as *u8) == 1 { return 1 } if af_streq(t, "equals" as *u8) == 1 { return 1 } if af_streq(t, "is" as *u8) == 1 { return 1 } return 0 }
called by 1: af_parse calls 1: af_streq
56func af_tok_lt(t: *u8) -> i64 { if af_streq(t, "<" as *u8) == 1 { return 1 } if af_streq(t, "under" as *u8) == 1 { return 1 } return 0 }
called by 1: af_parse calls 1: af_streq
57func af_tok_unknown(t: *u8) -> i64 { if af_streq(t, "what" as *u8) == 1 { return 1 } if af_streq(t, "x" as *u8) == 1 { return 1 } return 0 }
called by 1: af_parse calls 1: af_streq
58func af_tok_le(t: *u8) -> i64 { if af_streq(t, "<=" as *u8) == 1 { return 1 } return 0 }
called by 1: af_parse calls 1: af_streq
66func af_parse(s: *u8, res: *i64) -> i64
160func af_rel_term(sym: i64, x: *Term, y: *Term) -> *Term
172func af_derive_lt(ch: *K2Chain, u: i64, v: i64, stepsbox: *i64) -> i64
190func af_derive_le(ch: *K2Chain, u: i64, v: i64, stepsbox: *i64) -> i64
216func af_derive_sum(ch: *K2Chain, a: i64, b: i64, stepsbox: *i64) -> i64
252func af_derive_mult(ch: *K2Chain, a: i64, b: i64, stepsbox: *i64) -> i64
286func af_decide(claim: *u8, vb: i64) -> i64