Zama is an open-source framework for the Boolean circuit-complexity units of pequalnp.com. For each unit it finds the circuit or the lower-bound certificate, writes the Lean 4 proof, checks it with the Lean kernel on your machine and opens the pull request, without an LLM in the loop. It ships 21 solvers; docs/SOLVERS.md explains what each one proves, how, which Lean template it uses and how long it takes.
pequalnp.com is an open, collaborative attack on circuit lower bounds related to P vs NP. Its desk splits the work into thousands of small Lean 4 units: "this 6-input function needs exactly k AND/OR/NOT gates", "no circuit of at most k gates computes this 5x5 table", and so on. Each accepted proof is merged into open-goat/pequalnp-proofs and earns points.
- Zama is an exact-synthesis and certificate engine for those units: native C/C++ search (iterative deepening, CGP, frontier BFS, SAT where useful) finds the optimal circuit and the lower-bound certificate, a family template turns it into a Lean 4 file, and the official checker (
tools/pnp.sh check) must accept it before anything is sent. - Zama is not a proof of P vs NP, and it does not prove arbitrary theorems. It covers the theorem families it has a solver for (21 today, listed below); everything else is skipped, never guessed.
- No AI is required. Every solver is deterministic and runs offline at $0. An LLM adapter exists only as an optional helper for drafting a solver when a new family appears.
desk board ──▶ match a solver ──▶ solve (C/C++) ──▶ emit .lean ──▶ prelint ──▶ Lean kernel check ──▶ PR
│ no match: skip │ fail: record, never send
└─ desk gate: skip units already proved, reserved or with an open PR
Details, failure modes and debug commands: docs/ARCHITECTURE.md.
| What | Result | Evidence |
|---|---|---|
10 value6 units (exact 6-input circuit size) |
10/10 solved and pre-linted in 12.0 s vs 501.1 s for the SAT baseline (0/10), 41.8x | make bench on Apple M4, 2026-12-03 |
| Lean kernel | every proof is checked locally (lake env lean) before a PR; typical 10-25 s per unit |
./zama verify --standalone |
| Clean clone | build + 54 tests + one full Lean check from a fresh clone | make verify |
| Token cost | 0 tokens for every supported family | no network call besides the desk and GitHub |
pequalnp.comcontributors who want to go from zero to verified, merged Lean 4 PRs in 3 minutes — on a single Mac/Linux machine or across an SSH fleet.- Lean 4 & formal verification engineers looking for reusable kernel-checked Boolean circuit lower-bound templates (
LowU,ExactFront,bitLaneDAGs,noptNB,rootFree_split). - AI + math researchers who want a reproducible, zero-dependency harness where deterministic math engines handle bulk proving and LLMs are reserved for discovering new solver families.
- Clone your fork of
pequalnpand set up Lean 4 once:git clone https://github.com/<you>/pequalnp ../pequalnp (cd ../pequalnp && tools/pnp.sh setup)
- Initialize Zama, compile native solvers, and verify your setup:
make init # creates .env from .env.example — set PNP_REPO and PNP_HANDLE make build # compiles all native C/C++20 solvers under solvers/ make test # runs the full 50-test unit & integration suite make bench # runs the reproducible 10-unit value6 benchmark (~10.6s) make doctor # checks python3, c++, lake, gh, upstream repo, and solvers
- Run a local Lean 4 verification on the included fixture (no account or lease needed):
make verify-fixture
- Launch the full autonomous stack in one command:
./zama ship # dry-run + live TUI (verifies locally, no PRs) ./zama ship --submit # live autonomous mode (verifies + opens PRs) ./zama ship --submit --detach # unattended overnight mode (auto-caffeinate on macOS)
- Control or inspect anytime:
./zama ui # attach live terminal dashboard (or --snapshot) ./zama stealth on|off # pause/resume proving while monitors stay active ./zama vigia --once # check board status and new waves ./zama fleet # check single-machine vs multi-node SSH fleet ./zama stop # stop detached supervisor cleanly
pequalnp.com (/desk/board + tools/pnp.sh)
│
├──▶ Autoprobe (tests new waves) ──▶ runs/auto_waves.json (hot-reloaded)
▼
┌───────────┐ match? ┌──────────────────────────────┐
│ Zama │ ─── yes ───▶ │ Deterministic Solvers (0 tok)│
│Race/Runner│ │ C/C++20 + Lean 4 Templates │
└───────────┘ └──────────────┬───────────────┘
│ novel family │
▼ ▼
┌─────────────────────────┐ ┌────────────────────────┐
│ Optional AI Fallback │ ───▶ │ 0.1ms Pre-Lint + │
│ Ollama · OpenAI · CLI │ │ Official Lean 4 Kernel │
└─────────────────────────┘ └───────────┬────────────┘
▼
┌────────────────────────┐
│ Zero-Dup PR Guard + │
│ Submit + SQLite Ledger │
└────────────────────────┘
| Solver | Stack | Theorem Family |
|---|---|---|
value6 |
C/C++17 + Python + Lean | 6-input exact AND/OR/NOT circuit size (HasCircuitSize 6): LB-first lowu_gen + multi-thread cgp6_fast + v6front chunked-BFS (k=12..14) + gen10_dev fallback |
value7 |
C + Python + Lean | 7-input exact AND/OR/NOT circuit size (HasCircuitSize 7, u128 CGP + cut oracle) |
foud6 |
C++20 + Lean | 6×6 circuits (≤1 NOT, ≤2 NOT, or unrestricted NOT) via foud6 → foud6nb → foud6split cascade |
notcover6 |
Python | 6-bit subcube non-coverability (pigeonhole clique + LP dual) |
cover6 |
Python | 6-bit exact minimum axis-aligned subcube cover |
sixl |
C++20 + Lean | 6×6 monotone one-active-row-and-column (LiveL+gkey DAG) |
onerow |
C++20 + Lean | 5×5 one-active-row-and-column exact circuit size |
onerowl |
C++20 + Lean | 5×5 one-active-row-and-column LiveL+gkey (k=2..12) |
andcount |
Python + Lean | Partial-function AND-gate lower bounds via MIS |
oneside |
Python + Lean | One-a-side bipartite graph AND/OR lower bounds via induced P4 |
twolit |
Python + Lean | Two-literal monotone function refute certificates |
hull |
Python | Affine hull modulo k decision & certificates |
sixrow |
C++17 + Python + Lean | 6×6 monotone one-active-row-and-column value (homomorphic projection + BST DAG) |
sixub |
Python + Lean | 6-input AND/OR/NOT circuit upper bound via cgp6_fast |
inc7 |
C + Lean-compiled C + Python | Increasing 7-input function circuit size (gate elimination + monotone CGP + native kids search) |
onenot8 |
Python + C + kissat | 8-vertex edge function, one NOT saves nothing |
t2b |
Python + C (sa6_dec, v4_gen) |
Table 2 monotone 6-input prove |
foud6lb |
C++20 + Python + Lean | 6×6 lower-bound child units (unrestricted or one NOT): foud6 lower-bound-only DAG split into ≤2,000-node kernel chunks |
foud6ub |
C++17 + Python + Lean | 6×6 upper-bound child units (one NOT, unrestricted NOT, monotone): 273-table cert6 cache, then CGP or kissat |
mono6lb |
C++17 + Lean | 6×6 monotone lower-bound child units (LiveL+gkey DAG, lower-bound fork of sixl) |
side5 |
C++17 + Python + Lean | Side-five table prove/refute units: exact minimum from minc, witness + decide |
Reproducible 10-unit benchmark from wave e2c6b99338 (benchmarks/corpus_value6.json):
make bench # solve + pre-lint all 10 units (~12 s on Apple M4)
./zama bench --lean ../pequalnp-proofs/lean # also run independent Lean 4 kernel checksMeasured on Apple M4 against the pre-refactor SAT (kissat + unpatched gen10) baseline:
- Solved + pre-linted: 10/10 (baseline: 0/10)
- Total wall time: 12.0 s vs 501.1 s baseline (41.8× faster, measured 2026-12-03 with another pipeline running; Zama v1.2 took 37.5 s, see
benchmarks/results_value6.json) - Typical per-unit generation time: 0.04–0.43 s on 9 of 10 units via LB-first
lowu_gen+ multi-threadedcgp6_fast - Independent Lean 4 kernel checks (
lake env lean,rc=0): verified onL-meta-125881(16.2 s),L-meta-125860(11.6 s), andL-meta-125861(24.9 s).
Zama is built to run unattended all night without babysitting:
- One-command detached mode:
./zama ship --submit --detachacquires an exclusiveflock(runs/.supervisor.lock) and automatically wrapszama watchwithcaffeinate -ison macOS so your machine never sleeps mid-run. - Built-in mechanical self-healing (
watch.py): clears stale.git/index.lockfiles (>60 s with no livegitprocess), terminates hungtools/pnp.sh(>420 s) or runaway solver subprocesses (>240 s), and enforces a scoped240 sLean guard so Zama never touches unrelated processes. - OS service templates (
templates/overnight/): ready-to-install macOSlaunchdagent (install-launchd.sh), Linuxsystemduser service (zama-ship.service), and zero-tokennight_watch.shguardian.
- Playbook (
docs/PLAYBOOK.md): Step-by-step workflow from zero to merged PRs, template-first solver creation, mechanical-first vs agent-second discipline, and overnight operation. - Best Practices (
docs/BEST_PRACTICES.md): Field-tested lessons from shipping hundreds of PRs (differential rival-PR extraction, generate-before-lease, macOS E-core/QoS pitfall, second-pass escalation, launchd process-group safety). - Solvers (
docs/SOLVERS.md): What each solver proves, its method and Lean template, and measured generation and Lean check times. - Field Notes (
docs/FIELD_NOTES.md): Measured lessons from a week of racing: leases vs merge speed, twin units, when the race happens, Lean kernel memory per search node, the 6x6 frontier and dead ends. - Persistent Rules (
docs/RULES.md): Engineering invariants extracted from real production failures and bottlenecks. - All 14 Lean 4 Proof Templates (
templates/lean/): Complete dump of verified Lean 4 proof engines (lowu_engine,v6front_head,foud6*,six1not*,six_livel,one_livel,onerow_live,oneside_p4,andcount). - Reference C++ Engines (
templates/engines/): Additional standalone C++17 searchers (cgp6_1not,ge_nopt,minc6,minc6p,minc6p2). - Solver Skeleton (
templates/solver_skeleton/): Copy-and-adapt starter (solver.json,solve.py,template.lean) so you never write a solver from scratch. - Overnight Templates (
templates/overnight/): macOSlaunchd, Linuxsystemd, andnight_watch.sh. - Verifiable Research Ledger & Wave Catalog (
ledger/): Exported SHA-256receipts.jsonl, 55 observed waves (waves.json), and 212pequalnp.comstatement shapes (shapes.json).
Leave ZAMA_AI_PROVIDERS empty in .env for 100% deterministic, zero-token mode. To enable AI fallback only for genuinely new theorem families, set any combination in priority order:
ollama— local models viaOLLAMA_HOSTandOLLAMA_MODELopenai— any OpenAI-compatible API (vLLM, LM Studio, OpenRouter, OpenAI)claude— localclaudeCLIcodex— localcodexCLI
Does Zama require paid AI APIs or external Python packages? No. Zama uses only the Python 3.10+ standard library and C/C++20. All 12 built-in solvers run locally at $0 / 0 tokens.
How does Zama guarantee proofs are mathematically valid?
Every generated .lean file passes local pre-linting and exact statement-signature checks, then is independently compiled by the official Lean 4 kernel (lake env lean / tools/pnp.sh check) before any PR is opened.
Can I run Zama on one laptop or across multiple machines?
Both. By default it runs on one machine (ZAMA_FLEET empty). To scale across multiple Macs or Linux boxes, set ZAMA_FLEET="local:2,user@host:4" in .env — unreachable nodes enter cooldown automatically and fall back to local with zero stalls.
How do I add a solver for a new theorem family?
Copy templates/solver_skeleton/ to solvers/<name>/, adapt the closest Lean template under solvers/, and run make build && make test. See docs/PLAYBOOK.md and CONTRIBUTING.md.
See CONTRIBUTING.md for the solver plugin contract, Lean 4 compliance rules, and PR checklist.
make build && make test
./zama verify <unit_id> <path/to/proof.lean> --standaloneMIT — see LICENSE.
Keywords: Lean 4 automated theorem prover · pequalnp.com autopilot · P vs NP formal verification · Boolean circuit complexity lower bounds · deterministic C++20 proof generator · zero-dependency Python CLI · overnight Lean 4 PR bot · local LLM theorem proving (Ollama, OpenAI, Claude, Codex) · reproducible open-science ledger.