P vs NP: the fewest gates
Easy to check, easy to find? Exact small circuits, proofs that none smaller exists, and the 2026 claims around P vs NP, rerun and read

| 1 | #!/usr/bin/env python3 |
| 2 | """The `circuit` check: the circuits and lower-bound proofs a route hands in, verified exactly. |
| 3 | |
| 4 | Usage: verify.py FOLDER |
| 5 | |
| 6 | Only files directly in FOLDER (the route's folder) are judged: |
| 7 | <id>.ckt a circuit for function <id> (checks/circuits.py: mod3_<n>_<r>, sum<n>, maj<n>, thr<k>_<n>), |
| 8 | checked on all 2^n inputs; it shows the function can be computed with that many gates |
| 9 | <id>.gt<s>.lrat[.gz] an LRAT proof that no circuit of at most s gates computes <id>: the check builds the CNF |
| 10 | itself with the approved encoder (circuits.encode) and checks every step of the proof |
| 11 | Other files are left alone; a .ckt or .lrat file whose name is not of this form is named as ignored. |
| 12 | |
| 13 | The last line is what the site shows on the commit, and the board reads it: each function the project tables |
| 14 | (scienceslack.json `instances`) as "<name>: <gates>", in the table's order, with "(exact)" when a proof shows one gate |
| 15 | fewer is impossible; other functions after it, by id. Lower bounds are written with the id, never with a table name, |
| 16 | so the board never reads one as a circuit's size. Exit 0 with that line (or "Nothing to check yet"); exit 1 with the |
| 17 | first thing wrong, the file and the line to fix. |
| 18 | """ |
| 19 | import json |
| 20 | import re |
| 21 | import sys |
| 22 | import time |
| 23 | from pathlib import Path |
| 24 | |
| 25 | sys.path.insert(0, str(Path(__file__).resolve().parent)) |
| 26 | from circuits import Wrong, computes, encode, proof_lines, shown, unsat # noqa: E402 |
| 27 | |
| 28 | MAX_PROOF = 60_000_000 # bytes on disk; a larger proof is checked by the maintainers' own runner (docs/submission.md) |
| 29 | CKT = re.compile(r"(mod3_\d+_[012]|sum\d+|maj\d+|thr\d+_\d+)\.ckt") |
| 30 | LRAT = re.compile(r"(mod3_\d+_[012]|sum\d+|maj\d+|thr\d+_\d+)\.gt(\d+)\.lrat(\.gz)?") |
| 31 | |
| 32 | |
| 33 | def table(): |
| 34 | spec = json.loads((Path(__file__).resolve().parents[1] / "scienceslack.json").read_text(encoding="utf-8")) |
| 35 | return spec.get("instances", []) |
| 36 | |
| 37 | |
| 38 | def judge(folder): |
| 39 | up, low, ignored = {}, {}, [] |
| 40 | for f in sorted(p for p in folder.iterdir() if p.is_file()): |
| 41 | if CKT.fullmatch(f.name): |
| 42 | fid = f.name[:-4] |
| 43 | up[fid] = computes(fid, f.read_text(encoding="utf-8", errors="replace"), f.name) |
| 44 | elif m := LRAT.fullmatch(f.name): |
| 45 | fid, s = m[1], int(m[2]) |
| 46 | if f.stat().st_size > MAX_PROOF: |
| 47 | raise Wrong(f"{f.name}: {f.stat().st_size // 1_000_000} MB, over this check's {MAX_PROOF // 1_000_000} MB; see docs/submission.md for larger proofs") |
| 48 | nv, clauses, _ = encode(fid, s) |
| 49 | unsat(clauses, proof_lines(f), f.name) |
| 50 | low[fid] = max(low.get(fid, 0), s) |
| 51 | elif f.suffix in (".ckt", ".lrat", ".gz"): |
| 52 | ignored.append(f.name) |
| 53 | return up, low, ignored |
| 54 | |
| 55 | |
| 56 | def line(up, low): |
| 57 | rows = table() |
| 58 | said = [] |
| 59 | for fid in sorted(set(up) | set(low), key=lambda x: (shown(x) not in rows, rows.index(shown(x)) if shown(x) in rows else 0, x)): |
| 60 | exact = fid in up and low.get(fid) == up[fid] - 1 |
| 61 | if shown(fid) in rows and fid in up: |
| 62 | said.append(f"{shown(fid)}: {up[fid]}{' (exact)' if exact else ''}") |
| 63 | elif fid in up: |
| 64 | said.append(f"{fid} in {up[fid]} gates{' (exact)' if exact else ''}") |
| 65 | if fid in low and not exact: |
| 66 | said.append(f"size({fid}) > {low[fid]}") |
| 67 | return "; ".join(said) |
| 68 | |
| 69 | |
| 70 | def main(argv): |
| 71 | if len(argv) != 1: |
| 72 | sys.exit(__doc__) |
| 73 | folder = Path(argv[0]) |
| 74 | if not folder.is_dir(): |
| 75 | print(f"Nothing to check yet: no folder {folder.name} on this commit (a route's files go in routes/<name>/).") |
| 76 | return 0 |
| 77 | t = time.time() |
| 78 | try: |
| 79 | up, low, ignored = judge(folder) |
| 80 | except Wrong as e: |
| 81 | print(f"FAILED: {e}", file=sys.stderr) |
| 82 | print(f"FAILED: {e}") |
| 83 | return 1 |
| 84 | for name in ignored: |
| 85 | print(f"ignored {name}: not <id>.ckt or <id>.gt<s>.lrat[.gz]") |
| 86 | if not up and not low: |
| 87 | print("Nothing to check yet: no <id>.ckt or <id>.gt<s>.lrat file directly in the route's folder.") |
| 88 | return 0 |
| 89 | print(f"checked {len(up)} circuit(s) and {len(low)} proof(s) in {time.time() - t:.2f} s") |
| 90 | print(line(up, low)) |
| 91 | return 0 |
| 92 | |
| 93 | |
| 94 | if __name__ == "__main__": |
| 95 | sys.exit(main(sys.argv[1:])) |