code wiki / (root) / nx_term_order.nx

nx_term_order.nx

buildroot/runtime/nx_term_order.nx

9688 B256 linesdepth 5pulls 5 transitivereach 7 importersview sourcekind librarytopic term
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_result.nx nx_unify.nx nx_term_order.nx nx_demodulation.nx nx_demodulation_test.nx nx_lpo.nx nx_lpo_test.nx nx_selection.nx nx_selection_test.nx nx_term_order_test.nx

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

56struct KboState

consts

46const NX_KBO_GT: nx_int = 1
47const NX_KBO_EQ: nx_int = 2
48const NX_KBO_LT: nx_int = 3
49const NX_KBO_INCOMP: nx_int = 4
54const NX_KBO_MAX_SYM: nx_int = 1024
64const NX_KBO_STATE_BYTES: nx_int = 40

functions

66func nx_kbo_new(w0: nx_int) -> *KboState
called by 4: mk_kbomk_statemainmain calls 1: sys_mmap
78func nx_kbo_register(st: *KboState, sym_id: nx_int, weight: nx_int,
97func nx_kbo_check_admissibility(st: *KboState) -> *NxResult
called by 1: main calls 2: nx_result_errnx_result_ok
136func nx_kbo_weight(st: *KboState, t: *Term) -> nx_int
155func nx_kbo_var_count(t: *Term, var_id: nx_int) -> nx_int
173func nx_kbo_var_dominates(s: *Term, t: *Term, max_var_id: nx_int) -> nx_int
called by 1: nx_kbo_compare calls 1: nx_kbo_var_count
187func nx_kbo_prec_cmp(st: *KboState, a_sym: nx_int, b_sym: nx_int) -> nx_int
called by 1: nx_kbo_compare
199func nx_kbo_compare(st: *KboState, s: *Term, t: *Term, max_var_id: nx_int) -> nx_int
250func nx_kbo_verdict_name(v: nx_int) -> *u8
called by 1: report