nx_term_order.nx
buildroot/runtime/nx_term_order.nx
about
nx_term_order.nx -- Knuth-Bendix Order (KBO) over first-order Terms.
Per Vampire-displacement roadmap Phase 1 step 1: KBO is the foundation
every saturation prover uses to orient rewrites, pick the smaller half
of a critical pair, and prune redundant clauses (forward subsumption,
demodulation, tautology deletion all depend on it).
Knuth + Bendix 1970. Standard formulation:
Given:
- weight function w : Symbol -> nx_int
- precedence > on symbols (total order)
- constant w_0 >= 1 (minimum weight; weight of a variable)
Admissibility (KBO is well-founded iff):
(A1) for every constant c, w(c) >= w_0
(A2) if f is a unary symbol with w(f) = 0, then f is maximal in >
weight(x) = w_0 for variables x
weight(f(t1,..,tn)) = w(f) + sum_i weight(t_i)
s >_KBO t iff (for every variable x, count(x, s) >= count(x, t))
AND ONE OF:
(W1) weight(s) > weight(t)
(W2) weight(s) = weight(t) AND
(P1) head(s) > head(t) in precedence,
(P2) head(s) = head(t) AND args(s) >_lex args(t)
Result is a sealed verdict {GT, EQ, LT, INCOMPARABLE}.
Bits-up: pure nx_int arithmetic, no f64, no external library.
Result-typed for all fallible API. Scale-agnostic via nx_tier.
dependencies 5 imports · 7 importers
imports: nx_syscalls.nxnx_runtime.nxnx_tier.nxnx_result.nxnx_unify.nx
imported by: nx_demodulation.nxnx_demodulation_test.nxnx_lpo.nxnx_lpo_test.nxnx_selection.nxnx_selection_test.nxnx_term_order_test.nx
structs
| 56 | struct KboState |
consts
| 46 | const NX_KBO_GT: nx_int = 1 |
| 47 | const NX_KBO_EQ: nx_int = 2 |
| 48 | const NX_KBO_LT: nx_int = 3 |
| 49 | const NX_KBO_INCOMP: nx_int = 4 |
| 54 | const NX_KBO_MAX_SYM: nx_int = 1024 |
| 64 | const NX_KBO_STATE_BYTES: nx_int = 40 |
functions
| 66 | func nx_kbo_new(w0: nx_int) -> *KboState |
| 78 | func nx_kbo_register(st: *KboState, sym_id: nx_int, weight: nx_int, |
| 97 | func nx_kbo_check_admissibility(st: *KboState) -> *NxResult |
| 136 | func nx_kbo_weight(st: *KboState, t: *Term) -> nx_int |
| 155 | func nx_kbo_var_count(t: *Term, var_id: nx_int) -> nx_int |
| 173 | func nx_kbo_var_dominates(s: *Term, t: *Term, max_var_id: nx_int) -> nx_int |
| 187 | func nx_kbo_prec_cmp(st: *KboState, a_sym: nx_int, b_sym: nx_int) -> nx_int called by 1: nx_kbo_compare |
| 199 | func nx_kbo_compare(st: *KboState, s: *Term, t: *Term, max_var_id: nx_int) -> nx_int |
| 250 | func nx_kbo_verdict_name(v: nx_int) -> *u8 called by 1: report |