code wiki / _hdl_build / nx_rule_soundness_test.nx

nx_rule_soundness_test.nx

buildroot/runtime/_hdl_build/nx_rule_soundness_test.nx

11851 B229 linesdepth 9pulls 14 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_rule_soundness_test.nx -- FAIL-LOUD driver that PROVES the nx_eqsat rewrite rules SOUND (algebraic identities mod 2^W) via nx_rule_soundness.nx. Strategy (winning): width-independent induction (reuses the divider-proof template) + EXHAUSTIVE small-width at W=8, with nx_triangulate as the independent cross-check, and TWO independent witnesses per vector ANDed. CERTIFIED-LIVE SET (this rung): the SIX width-trivial unary rules {add_zero, sub_self, add_self, and_self, or_zero, mul_one} swept exhaustively over x in [0,2^8). They have NO k boundary and ZERO owed guards, so they are fully certifiable now. Known answer: total_unary == 1536 (= 6 * 256), all certified. mul_pow2 (NEXT rung -- theorem proven here but NOT in the certified-live set): IN-RANGE: for all x in [0,2^8) and all k in [0,8), MUL(x,2^k) == SHL(x,k) mod 2^8. Known answer: in_range == 2048 (= 256 * 8), all certified. BOUNDARY (k>=W): the rule MUST NOT fire -- the identity is FALSE. We PROVE unsoundness for k in [8,16) over all x (the owed k<W guard's location). Known answer: neg_caught == neg_total == 2048 (= 256 * 8). mul_pow2 stays OUT of the live-certified set until the k<W guard lands in nx_eqsat.nx. EXIT CODES (FAIL LOUD): 1 a certified-unary rule vector failed (proven_unary != total_unary) 2 unary total mismatch (total_unary != 1536) 3 a mul_pow2 in-range vector failed (proven_ir != in_range) 4 mul_pow2 in-range total mismatch (in_range != 2048) 5 a mul_pow2 boundary vector did NOT demonstrate unsoundness (neg_caught != neg_total) 6 boundary total mismatch (neg_total != 2048) 0 ALL pass. KNOWN-ANSWER LINE printed (FAIL LOUD): the per-rule pass counts then the exhaustive totals: "<add_zero> <sub_self> <add_self> <and_self> <or_zero> <mul_one> | <rules_proven> <proven_unary> <total_unary> | <proven_ir> <in_range> | <neg_caught> <neg_total>" SOVEREIGN: no SMT, no .sh, no foreign oracle -- runs on the pinned compiler.

dependencies 2 imports · 0 importers

nx_rule_soundness.nx nx_eqsat_membership_proof.nx nx_rule_soundness_test.nx

imports: nx_rule_soundness.nxnx_eqsat_membership_proof.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sweep_unary nx_rs_certify_unary nx_rs_oracle nx_rs_mask nx_rs_eval_lhs nx_rs_mask ↻ nx_rs_mk div_const div_op2 nx_gsim_run nx_gsim_kind_supported nx_gsim_eval_cell nx_rs_eval_rhs nx_rs_mask ↻ nx_rs_mk ↻ div_const ↻ div_op2 ↻ nx_gsim_run ↻ nx_tri_pass_strict nx_tri_check nx_rs_witness_a nx_rs_mask ↻ nx_rs_certify_mulpow2 nx_rs_mask ↻ nx_rs_pow2 nx_rs_mask ↻ nx_rs_mulpow2_oracle nx_rs_mask ↻ nx_rs_mk ↻ div_const ↻ div_op2 ↻ nx_gsim_run ↻ nx_tri_pass_strict ↻ nx_rs_mulpow2_witness_a nx_rs_mask ↻ nx_rs_pow2 ↻ nx_rs_mulpow2_boundary_uns nx_rs_mask ↻ nx_rs_mulpow2_oracle ↻

structs

none

consts

49const RW: i64 = 8 // representative width: sweep x in [0,2^8)

functions

51func _emit_num(v: i64) -> i64
called by 1: main
59func _bar() -> i64 { let z: *u8 = sys_mmap(4); z[0] = 124; z[1] = 32; sys_write(1, z, 2); return 0 }
called by 1: main
60func _nl() -> i64 { let z: *u8 = sys_mmap(2); z[0] = 10; sys_write(1, z, 1); return 0 }
called by 1: main
64func sweep_unary(rule: i64, hi: i64,
called by 1: main calls 1: nx_rs_certify_unary
78func main() -> i64