code wiki / _hdl_build / nx_rule_soundness_test.nx
nx_rule_soundness_test.nx
buildroot/runtime/_hdl_build/nx_rule_soundness_test.nx
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
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
structs
| none |
consts
| 49 | const RW: i64 = 8 // representative width: sweep x in [0,2^8) |
functions
| 51 | func _emit_num(v: i64) -> i64 called by 1: main |
| 59 | func _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 |
| 60 | func _nl() -> i64 { let z: *u8 = sys_mmap(2); z[0] = 10; sys_write(1, z, 1); return 0 } called by 1: main |
| 64 | func sweep_unary(rule: i64, hi: i64, |
| 78 | func main() -> i64 |