# Sweep: automatic schedules for checkable BDD proofs

Can the schedule that turns a BDD-based SAT solver into a generator of short, checkable proofs be found from the
clauses alone, with no knowledge of the problem? This folder holds a proof-generating BDD prover, an automatic way of
choosing its two orders, a proof of what it does on pigeonhole, and five registered evaluations, including one
against the CDCL solver Kissat. The work was done on 29 November 2026.

**Evidence label: measured, with one family proved.** Every "unsat" answer here comes with an LRAT proof
that an independent checker (`lrat-check` from drat-trim) verified. Proof sizes are measured on finite ranges of n;
growth rates are fits to those measurements. For direct-encoded pigeonhole, which orders the method picks, the exact
size of every state it builds and an O(n^4) bound on the proof are proved (`THEORY.md`).

## Status (29 November 2026)

| protocol, frozen before its runs | what it tests | outcome |
|---|---|---|
| `PROTOCOL.md` (commit `d010c61`; addenda 1–2) | the automatic sweep | soundness, held-out families and invariance passed; H1 failed (direct-encoded pigeonhole stopped at n = 32); H2 failed where the generators' own numbering is already a sweep order; the random control was inconclusive |
| `PROTOCOL2.md` (`7ae9282`) | the ordered sweep (one change, made after profiling protocol 1) | every domino and Tseitin family to n = 64, exactly invariant to shuffling; the three pigeonhole families failed at n = 28–48 because the spectral step computed only 24 eigenpairs; the random control inconclusive again |
| `PROTOCOL3.md` (`808d474`) | adaptive eigenpairs (one change, made after scoring protocol 2), a repaired random control | all six hypotheses passed |
| `PROTOCOL4.md` (`3a07fb8`; addendum 1) | proof steps of at most two clauses; Kissat on the same formulas; the pigeonhole theorem at new sizes | four of five passed: soundness, scaling on six families, the CDCL comparison and the theorem; T1 failed on the Tseitin grid, where proof sizes depend on the shuffle |
| `PROTOCOL5.md` (`7da0938`) | rotating nearly tied sweep directions; keeping small constraints in one slice; quantifying as early as possible | all five hypotheses passed: on the chessboard within 1.5 times the hand-made schedule (it was 2.0 to 2.4), nothing worse on the other nine families, all ten polynomial |

Results in detail, with every number traced to its result file: [`RESULTS.md`](RESULTS.md).

## The question

Ordinary (CDCL) SAT solvers produce resolution proofs, and resolution needs proofs of exponential length for the
pigeonhole problem (Haken 1985), the mutilated chessboard (Alekhnovich 2004) and Tseitin parity formulas on
expanders (Urquhart 1987). Extended resolution, which may name new variables, has proofs of polynomial size for all
of them (Cook 1976 for pigeonhole). A BDD-based solver writes extended-resolution proofs naturally: every BDD node is
a new variable (Biere, Jussila and Sinz 2006; Bryant and Heule 2021).

Whether the proofs are short depends on two orders: the order of variables in the BDD, and the order in which clauses
are conjoined and variables quantified away. Bryant and Heule obtained polynomial proofs for the chessboard and for
pigeonhole (Sinz encoding) only with a schedule and order designed by hand for each problem, and wrote: "It remains an
open question whether column scanning can be made more general and whether a suitable schedule and variable ordering
can be generated automatically" (ACM TOCL 24(4), 2023, §5.5). For pigeonhole in the ordinary direct encoding, Mengel
(SAT 2023) showed that two different orders, one for the BDD and one for elimination, give polynomial proofs; Bryant
measured O(n^5) with such orders chosen by hand, and ended: "It would be interesting to find an automated algorithm
that could improve on our O(n^5) scaling" (arXiv:2306.10337).

## The method

1. **Orders from the clauses alone** (`spectral.py`). The variable graph joins variables that share a clause (a clause
   of k variables gives each pair weight 1/(k − 1)). Its slowest-varying Laplacian eigenvectors give a time direction
   t to sweep along and a transverse direction s across it: the first later cluster of eigenvalues whose modes vary
   inside slices of equal t. The BDD order sorts by (s, t); the elimination order sorts by (t, s), cut into √N slices.
   Equal eigenvalues (symmetries) are handled by a fixed random combination within the cluster, and eigenpairs are
   computed until both clusters are complete (protocol 3). When t and s are single, nearly tied directions (as on a
   square board), the pair is rotated to the angle with the narrowest sweep (protocol 5).
2. **The sweep** (`schedule.py`, `sweep3`). Each clause joins the slice of its earliest variable, or of a slightly
   larger clause containing it, so that a small constraint stays in one slice. For each slice: conjoin its clauses
   in the order of the BDD levels they use, quantify the variables used only there, conjoin the result into the
   running state, and quantify every variable whose clauses are all in. The state is the set of frontier
   configurations that the past allows.
3. **Proofs** (`prover.py`). Every node is an extension variable with four defining clauses; every conjunction,
   quantification and implication step is written in LRAT with at most two clauses and exact hints, each simulated
   before it is written (protocol 4).

## What it shows

On every structured family tested, with the formulas renamed and reordered at random before each run, the method
wrote verified proofs whose size fits a low power of n far better than an exponential:

| family | largest n verified | proof size grows like | protocol |
|---|---|---|---|
| pigeonhole, direct encoding (n holes, n + 1 pigeons) | 56 (29,033,552 clauses) | n^3.73 | 3 |
| pigeonhole, surjective, direct encoding | 48 | n^3.63 | 3 |
| pigeonhole, Sinz encoding | 48 | n^4.38 | 3 |
| mutilated chessboard, n × n | 64 (4,198,749 clauses) | n^2.69 | 5 |
| boards with two random same-coloured squares removed; n × (n + 2) boards; boards with four random squares removed | 64 | n^2.61 to n^2.70 | 5 |
| Tseitin parity on the grid, the torus and an n × 2n cylinder | 64 | n^2.11 to n^2.42 | 5 |

For direct-encoded pigeonhole at n = 36 the proof has 4,321,717 clauses with the input counted, as Bryant counts
(protocol 4; 5,439,563 in protocol 3, before the compact proof steps); his best, with hand-chosen orders, has
95,494,509, 22.1 times more. The two orders the spectrum picks are the ones
he found best by hand: eliminate hole by hole, order the BDD pigeon by pigeon. Three different shuffles of the same
formula give proofs of exactly the same size.

Against Kissat 4.0.4, given the same shuffled formulas and the same 1,800 seconds (protocol 4): Kissat solved
pigeonhole up to n = 10 (direct and surjective) and n = 14 (Sinz; 1,791 s and a 5.8 GB proof), the chessboard and the
four-square boards up to n = 16, and the Tseitin grid up to n = 12; at its first unsolved size the sweep
proves and checks in 0.66 to 1.6 seconds, and it continues to n = 40–64.

On random 3-SAT at clause ratio 6.0 the proofs grow exponentially (about e^(0.23 n); the protocol-3 control), as they
must: random formulas have no low-dimensional structure to find. On Tseitin formulas over random 4-regular graphs and
on Chew and Heule's parity formulas, bucket elimination reached larger sizes than the sweep (protocol 1, H6).

## What is proved

For direct-encoded pigeonhole, [`THEORY.md`](THEORY.md) proves that the spectrum's first two clusters are the hole
modes (eigenvalue n/(n − 1)) and the pigeon modes (n + 1), so the method sweeps hole by hole and orders the BDD
pigeon by pigeon on any renaming of the formula; that the state after hole i is "at most i pigeons have nothing left
in the remaining holes"; and that its BDD has exactly (n − i)(i + 1)(n + 1 − i) nodes, n^4/12 + O(n^3) in total.
`theory.py` checks every state the sweep builds against the formula, and every measured run agrees. Theorem 2 then
bounds the whole proof: every residual inside a slice is determined by a few counts, so each slice makes O(n^3)
memoised calls and the proof has O(n^4) clauses, like Cook's hand-built proof (Bryant measured O(n^5) with hand-chosen
orders). `theory.py` counts the calls in every slice and finds at most 2.17 per level and pigeon, against the 54 the
proof allows. For the chessboard and the Tseitin families the growth is measured, not proved.

## What is prior work, and what is not claimed

- The prover's construction (a variable per node, proofs of AND and of implication) is Biere, Jussila and Sinz's and
  Bryant and Heule's. Two orders for BDD and elimination is Mengel's insight; scanning one direction while ordering
  the other is Bryant and Heule's column scanning. Spectral orderings are a classical tool (the Fiedler vector).
- What is new here, as far as the literature searched shows: computing both orders automatically, from the clauses
  alone, by one procedure that serves the chessboard, all three pigeonhole encodings and the Tseitin families, and
  improving on the best published BDD proofs for direct-encoded pigeonhole. Cook's hand-built extended-resolution
  proof is O(n^4), and Grosof, Zhang and Heule's O(n^3) is optimal; this method's measured rate is close to n^4.
- Kissat's own DRAT proofs were counted, not checked, but each of its 16 answers is confirmed by a verified proof of
  the same formula (`kissat_crosscheck.py`). The comparison covers these families only; CDCL solvers are much stronger
  on most other formulas.
- On the chessboard, Bryant and Heule's own column scan still writes proofs 1.43 to 1.49 times smaller than the
  automatic method (772,523 clauses at n = 40 in their artifact; 1,153,974 here, protocol 5; 2.0 to 2.4 times before
  protocol 5). Run through this prover with compact steps, their own schedule and order reproduce their published
  sizes to within 1.2% at n = 8 to 40 (`column_scan.py`, post hoc), so the remaining gap is in the automatic schedule,
  and its growth rate is the same as theirs.
- On Tseitin grids and Sinz pigeonhole the automatic orders, and so the proof sizes, change with the shuffle (by up
  to 1.4 times on the grid in protocol 1, and more on Sinz pigeonhole).

## How it connects to the rest of the repository

RRLS (in the library) began as a search for coordinates in which a hidden relation becomes short. Its v0.16 report
concluded that the wall is extension synthesis, the naming of new variables; its v0.29 report built a BDD
canonicaliser and found that "variable order is a real coordinate problem". Its reading path ends by asking whether a
canonical quotient of all live futures can be kept current by polynomial local updates, without exponential order
search. The sweep's state is such a quotient, updated slice by slice, with orders found from the spectrum, and every
step is a checked proof. For these structured families the measured answer is yes; for random formulas it is no.
Each BDD node stands for all the partial assignments that leave the same function to satisfy: the quotient by
observable future that DRCT computes by partition refinement on explicit states, here computed symbolically.

## File map

| file | role |
|---|---|
| `prover.py` | the BDD package and LRAT proof writer |
| `schedule.py` | linear conjunction, bucket elimination, the sweep and the ordered sweep |
| `spectral.py`, `orders.py` | the automatic orders; the generators' numbering; the hand-designed column scan |
| `families.py` | the benchmark formulas |
| `theory.py`, `THEORY.md` | the pigeonhole theorem and its checks |
| `cdcl.py` | Kissat on the same shuffled formulas (protocol 4) |
| `kissat_crosscheck.py` | confirms each of Kissat's answers with a verified proof of the same formula (post hoc) |
| `column_scan.py` | Bryant and Heule's hand-made chessboard schedule, rebuilt and run through this prover (post hoc) |
| `run.py` | one run: formula, orders, proof, check, one JSON line |
| `solve.py` | refute any DIMACS file and write its proof |
| `experiment.py`, `analyze.py` | the registered evaluations and their scoring (`--protocol 1` to `4`) |
| `PROTOCOL.md` … `PROTOCOL5.md` | the five frozen protocols (do not edit; corrections are dated addenda) |
| `RESULTS.md`, `results/`, `figures/` | results, raw run records, summaries, figures |
| `test_sweep.py` | tests: every family verifies under every schedule, damaged proofs are rejected |

## How to run

Build the checker once, from drat-trim (github.com/marijnheule/drat-trim, commit `2e3b2dc`; `lrat-check.c` has
SHA-256 `bf07c2ac…a8f4a95`), and, for the CDCL baseline, Kissat (github.com/arminbiere/kissat, commit `8af8e56`:
`./configure && make`, then copy `build/kissat` to `bin/`):

```sh
gcc -O2 -o bin/lrat-check path/to/drat-trim/lrat-check.c
python3 -m unittest test_sweep                       # about four minutes
python3 theory.py                                    # the pigeonhole theorem against the code
python3 run.py chess 24 --orders auto5 --method sweep3 --compact --shuffle 1   # the method of protocol 5
python3 solve.py formula.cnf proof.lrat && bin/lrat-check formula.cnf proof.lrat
python3 cdcl.py chess 16 --shuffle 10                # Kissat on the same formula
python3 experiment.py --protocol 5 && python3 analyze.py --protocol 5     # hours; needs about 15 GB
```

Needs Python 3 with NumPy and SciPy (matplotlib for the figures).
