add gen_data.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738"""Generate the seeded 3-SAT inventories with exhaustive-oracle labels.
Train/val: SAT-only formulas (paper never states what UNSAT formulas train on --recorded as a deviation). Test: 512 formulas of ALL types, oracle-labelled so bothdenominators (all / satisfiable-only) can be reported."""import jsonimport osimport time
import sat_core as S
os.makedirs("/work/data", exist_ok=True)
t0 = time.time()trainval = S.make_inventory(21000, seed=1234, keep="sat")print(f"trainval: {len(trainval)} SAT formulas in {time.time()-t0:.1f}s", flush=True)train, val = trainval[:20000], trainval[20000:]
t0 = time.time()test = S.make_inventory(512, seed=777, keep="all")n_sat = sum(1 for r in test if r["is_sat"])print(f"test: {len(test)} formulas, {n_sat} satisfiable ({100.0*n_sat/len(test):.2f}%) " f"in {time.time()-t0:.1f}s", flush=True)
# sanity: train targets are verified satisfying, independently re-parsedfor r in train[:200] + val[:200] + test[:100]: if r["train_target"]: unsat, total = S.check_assignment(r["text"], r["train_target"]) assert unsat == 0 and total == 45, rprint("sanity checks passed", flush=True)
for name, rows in (("train_sat", train), ("val_sat", val), ("test_all", test)): S.write_jsonl(f"/work/data/{name}.jsonl", rows) print(name, len(rows), flush=True)
from collections import Counterprint("test solution-count histogram:", dict(sorted(Counter(r["n_solutions"] for r in test).items())))gen_data.pyAdded+38