#!/usr/bin/env python3 """Wave 42 regression: the generalised driver must not move any already-decided instance, and must reproduce the staged Wave 40 / Wave 41 case lists exactly. Enumeration only — no solver runs.""" import importlib.util import json import sys ROOT = "/home/hatch/workspace/matmul-pilot/" def load_mod(name, path): spec = importlib.util.spec_from_file_location(name, path) m = importlib.util.module_from_spec(spec) spec.loader.exec_module(m) return m stock = load_mod("paritysplit_stock", ROOT + "wave7/parity/paritysplit.py") gen = load_mod("paritysplit_gen", ROOT + "wave42/paritysplit_gen.py") fails = [] def check(name, cond, detail=""): print(f"{'PASS' if cond else 'FAIL'} {name} {detail}") if not cond: fails.append(name) def norm_gen(cases): """gen cases (tuples of 1-tuples) -> stock shape (tuples of ints).""" return [tuple(vec[0] for vec in case) for case in cases] # --- 1. decided standard instance: Laderman free-4 {2,3,4,9}, coeff "1" seed = ROOT + "wave4/laderman/anneal_best_r22.json" Fs, rs, Ds, als, Rs, e_s, t_s = stock.build_instance(seed, [2, 3, 4, 9], "1") P_s, cases_s = stock.enumerate_cases([2, 3, 4, 9], als, t_s) Fg, rg, Dg, alg, Rg, entries_g, targets_g = gen.build_instance( seed, [2, 3, 4, 9], "1") VS_g, cases_g = gen.enumerate_cases([2, 3, 4, 9], alg, entries_g, targets_g) check("std free-4 entries/targets", entries_g == [e_s] and targets_g == [t_s], f"e={e_s} target={t_s}") check("std free-4 vector set", [v[0] for v in VS_g] == P_s, f"P={P_s}") check("std free-4 case list identical", norm_gen(cases_g) == cases_s, f"{len(cases_s)} cases") # --- 2. decided instance at coeff "h1": Laderman free-3 {2,3,4} Fs, rs, Ds, als, Rs, e_s, t_s = stock.build_instance(seed, [2, 3, 4], "h1") P_s, cases_s = stock.enumerate_cases([2, 3, 4], als, t_s) Fg, rg, Dg, alg, Rg, entries_g, targets_g = gen.build_instance( seed, [2, 3, 4], "h1") VS_g, cases_g = gen.enumerate_cases([2, 3, 4], alg, entries_g, targets_g) check("h1 free-3 case list identical", entries_g == [e_s] and targets_g == [t_s] and [v[0] for v in VS_g] == P_s and norm_gen(cases_g) == cases_s, f"{len(cases_s)} cases, P={P_s}") # --- 3. Wave 40 staged list: 19 cases, exact strings w40seed = ROOT + "compute-repo/seeds/wave40_proj24_minus0.json" Fg, rg, Dg, alg, Rg, entries_g, targets_g = gen.build_instance( w40seed, [0, 1, 3, 13], "1") VS_g, cases_g = gen.enumerate_cases([0, 1, 3, 13], alg, entries_g, targets_g) der = json.load(open(ROOT + "wave40/free4_derivations.json")) want = [s.split(": ", 1)[1].strip("[]") for s in der["paritysplit_cases"]] got = [gen.case_spec([0, 1, 3, 13], c) for c in cases_g] check("wave40 entries/targets", entries_g == [(5, 8, 4)] and targets_g == [0], f"entries={entries_g} targets={targets_g}") check("wave40 19-case list identical", got == want, f"{len(cases_g)} cases") # --- 4. Wave 41 staged lists: 6 x 304 cases, exact order w41 = json.load(open(ROOT + "wave41/wrong2_derivations.json")) for d in w41["derivations"]: sd = ROOT + d["staged_seed"] free = d["free4_seed_coords"] Fg, rg, Dg, alg, Rg, entries_g, targets_g = gen.build_instance( sd, free, "1") VS_g, cases_g = gen.enumerate_cases(free, alg, entries_g, targets_g) got = [[list(vec) for vec in case] for case in cases_g] ok = (got == d["cases"] and entries_g == [tuple(x) for x in d["wrong_entries"]] and targets_g == d["target_pair_scaled"]) check(f"wave41 {d['parent']} minus{d['dropped_term_parent_coords']} " f"304-case list identical", ok, f"entries={entries_g} targets={targets_g} ncases={len(cases_g)}") print("REGRESSION:", "ALL PASS" if not fails else f"FAILURES {fails}") sys.exit(1 if fails else 0)