Problem
pequalnp is a public project where thousands of AI agents prove small lemmas in circuit complexity. A typical step asks whether some small function has an AND/OR/NOT circuit of at most k gates. A central desk hands out each step as a short lease, and a strict Lean checker grades every submission. Nothing here settles P vs NP. The value is a steady supply of small, real, machine-checked results.
The hard part is not any single proof. Leases expire, small steps are races, and every pull request is public under my name. Paid model quota runs out. I needed a system that picks the steps it can win, routes each to the cheapest model that can do it, and never submits anything the checker would reject.
Architecture
- Mac (orchestrator). The only machine that talks to the desk. A poller takes steps and filters out ones we can’t win:
search-scale steps, known-false twins, steps already on main and steps that don’t accept reductions.
A lease loop keeps leases alive, and per-step agents work in their own scratch folders, each with a
progress.mdhand-off. - Desktop (compute node). A Ryzen 5900X with an RTX 5060 Ti, reached over Tailscale. It runs Lean and Mathlib, kissat and CaDiCaL in WSL2, and local CUDA models on the Windows side. All heavy SAT and brute-force work goes here.
- Model routing. Free models do the bulk drafting, because Lean grades the work regardless of who wrote it. Mid-tier models build tooling and searches. Frontier models only take the math that is actually hard. One model per step: racing two expensive models on the same step burned quota and both hit the same wall.
- Fast path. For the recurring small-circuit steps: the poller leases, a desktop agent runs exact SAT synthesis at several sizes in parallel, a generator writes the Lean file and replays the circuit on every input, then the checker and submit run. Lease to open PR in about 2-3 minutes, which matters because rival agents’ PRs show up within minutes.
- Gates before submit. Every file must pass the project’s intake guard and its real Lean checker locally before a PR goes out.
Tools built for it
- A validated SAT encoder for exact circuit size, using the Lean definitions’ own semantics. It is checked against brute force on random functions and uses cube-and-conquer across cores.
- A certificate generator that turns a SAT lower bound into a kernel-checked Lean proof.
- An LRAT pipeline that turns SAT lower bounds into kernel-checked proofs. It works on tiny instances and showed why larger ones are out of reach: one “no 9-gate circuit” certificate came to 2.5 GB against a 512 KiB file cap.
- A “ladder bank” of circuits already below the desk’s posted records, so a new record step becomes an instant proof.
- A bench for comparing free models against paid ones on the same step. On one circuit search, two free models and a paid reference all reached the same 28-gate circuit, which is why free models now do the routine work.
Results
Four proofs merged: L-meta-16985, L-meta-18113 (a 95-gate 3-colouring circuit built on the desktop), L-meta-58573 and L-meta-59330. The last two came through the fast path and beat the desk’s own circuits: 13 gates where the desk had 15, and 15 where it had 19. The ladder bank holds circuits below the current records: 3-colouring on 5 vertices in 21 gates against a record of 24, triangle detection on 6 vertices in 45 gates against 47, and Hamiltonicity on 6 vertices in 73 against 75. Dozens more steps were settled with evidence and handed back, including eight shown false with an exact minimum size from exhaustive SAT over every smaller size.
What broke
- A laptop is a bad lease holder: closing the lid for 30 minutes expired three leases at once.
- Background jobs in the agent harness stop at two hours, so the poller needed restarting every cycle; one missed restart lost three leases overnight.
- Cross-machine quirks: PowerShell expanding
$in commands meant for WSL, and a remote agent shell with a broken home path. - GitHub search lags behind new PRs, so race checks list recent PRs directly instead.