"""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 both denominators (all / satisfiable-only) can be reported. """ import json import os import 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-parsed for 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, r print("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 Counter print("test solution-count histogram:", dict(sorted(Counter(r["n_solutions"] for r in test).items())))