Skip to content
Caliko06Public

About

Open-source, model-agnostic Lean 4 automated theorem-proving harness for pequalnp.com (P vs NP): zero-token C++20/Python solvers, zero-day wave autoprobe, solve-ahead Shipping TUI, multi-node SSH fleet & verifiable proof ledger.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Zama

CI Release License: MIT Python 3.10+ Lean 4 Dependencies: Zero

Open-source, model-agnostic Lean 4 automated theorem-proving & formal verification harness for pequalnp.com (P vs NP).

Reproducible Lean 4 proof generation, zero-token deterministic C++20/Python circuit-complexity solvers, zero-day wave autoprobing, solve-ahead PR racing, multi-node SSH fleets, pluggable AI agents (ollama, openai, claude, codex), Shipping curses TUI, and a SHA-256 verifiable research ledger for collaborative mathematics.


What is Zama?

pequalnp.com breaks P vs NP research into bite-sized Lean 4 theorems. Every proof only counts when Lean 4's kernel independently verifies it.

Zama turns that into a clean, reproducible workbench anyone can run in 3 minutes:

  1. Fast math tools first (0 tokens): Before calling any AI, Zama checks if a deterministic C++20/Python solver in solvers/ already cracks that theorem family.
  2. Zero-day wave autoprobe: When a new wave drops on the board, ./zama autoprobe tests existing solvers in isolated directories, verifies exact statement predicates (ReadsBack, Fin, notCount, Monotone2, FanInTwo), imports, pre-lint, and Lean 4, then hot-registers winning patterns into runs/auto_waves.json with zero restarts.
  3. Any AI model second (no lock-in): Only when a theorem family is genuinely new or stuck does Zama call your chosen provider (local Ollama, OpenAI-compatible API, Claude CLI, or Codex CLI) to explore or distill a new solver plugin.
  4. One official referee: Zama delegates directly to pequalnp's official tools/pnp.sh and Lean 4 toolchain, enforcing CONTRIBUTING.md rules locally before Lean even starts.
  5. Shared memory of wins and dead ends: Every attempt—verified proof or failed hypothesis—is hashed (SHA-256) into a local SQLite ledger and exported as portable JSONL so researchers don't waste compute repeating dead ends.

Why Zama?

  • Portable & dependency-free: Python 3.10+ standard library only + C++20 native solvers. Works on macOS and Linux with zero cloud lock-in.
  • Upstream-native & Zero-Duplicate PR Guard: Wraps <PNP_REPO>/tools/pnp.sh (setup, next, check, submit, release) with bounded submit concurrency, automatic retry on transient GitHub push errors, and a strict pre-submit guard (has_existing_pr) checking both live GitHub GraphQL (OPEN/MERGED PRs) and pequalnp.com/desk/row right before submission so Zama never opens duplicate PRs.
  • Drop-in solver plugins: Add a folder under solvers/<name>/ with a solver.json manifest; Zama auto-discovers, builds, pre-lints, and verifies it.
  • Verifiable collective intelligence: Export receipts.jsonl, share it with peers, and import theirs with automatic deduplication by statement + proof hash.

Quickstart (3 minutes)

  1. Clone your fork of pequalnp and set up Lean 4 once:
    git clone https://github.com/<you>/pequalnp ../pequalnp
    (cd ../pequalnp && tools/pnp.sh setup)
  2. Initialize Zama, compile native solvers, and verify your environment:
    make init          # creates .env from .env.example — edit PNP_REPO and PNP_HANDLE
    make build         # compiles native C/C++20 solvers (foud6, sixl, onerow, onerowl, value6/cgp6)
    make bench         # runs reproducible 10-unit value6 (HasCircuitSize 6) benchmark
    make test          # runs the full unit & integration test suite
    make doctor        # verifies python3, c++, lake, gh, upstream repo, and solvers
  3. Run a local reproducible Lean 4 check on the included fixture (no desk lease needed):
    make verify-fixture
  4. Launch the full Shipping stack in 1 command (parallel race + zero-day autoprobe + auto-distiller + watchdog/Lean guard + live TUI):
    ./zama ship                  # dry-run by default (no PR submission)
    ./zama ship --submit         # full autonomous mode with PR submission
    ./zama ship --submit --detach
  5. Or run individual subsystems separately:
    ./zama race --workers 6 --lean-slots 3 --submit-slots 1 --once
    ./zama autoprobe --once                         # probe uncovered waves with existing solvers
    ./zama distill --once                           # synthesize Lean-verified solvers for novel families
    ./zama vigia --once                             # silent event-driven lookout (CHAMBA, PIPE_CAIDO, etc.)
    ./zama stealth on|off|status                    # pause/resume solve & submit while lookouts stay on
    ./zama fleet                                    # check configured multi-node SSH fleet health
    ./zama watch --guard-only --dry-run             # watchdog + Lean RSS/timeout guard
    ./zama ui                                       # live Shipping TUI (stage bars, telemetry, [s] stealth)
    ./zama run --once                               # single sequential tools/pnp.sh next cycle
  6. Inspect or share your verifiable research ledger:
    ./zama ledger
    ./zama export receipts.jsonl
    ./zama import peer_receipts.jsonl

Included Deterministic Solvers (12 plugins)

Solver Type Target family
value6 C + Python + Lean 6-input exact AND/OR/NOT fan-in-2 circuit size (HasCircuitSize 6, native u64 CGP + slice-cut kernel certificate)
value7 C + Python + Lean 7-input exact AND/OR/NOT fan-in-2 circuit size (HasCircuitSize 7, native u128 CGP + LRAT-free cut oracle)
notcover6 Python 6-bit subcube non-coverability (pigeonhole clique + LP dual)
cover6 Python 6-bit exact minimum axis-aligned subcube cover
foud6 C++20 + Lean 6x6 circuits (≤1 NOT, ≤2 NOT, or unrestricted NOT) via compact bitLane DAG
sixl C++20 + Lean 6x6 monotone one-active-row-and-column (LiveL+gkey DAG)
onerow C++20 + Lean 5x5 one-active-row-and-column exact circuit size
onerowl C++20 + Lean 5x5 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

Reproducible Benchmark (value6 / HasCircuitSize 6)

Run the 10-unit corpus from wave e2c6b99338 (benchmarks/corpus_value6.json) in one command:

make bench                                      # fast generation + pre-lint (~38s for all 10 units)
./zama bench --lean ../pequalnp-proofs/lean     # add independent Lean 4 kernel verification

Measured on Apple M4 against the pre-refactor kissat + unpatched gen10 baseline (all 10 units previously failed in production):

  • Solved + pre-linted: 10/10 (baseline: 0/10)
  • Total wall time: 37.52 s vs 501.1 s baseline (13.4× faster)
  • Independent Lean 4 kernel checks (lake env lean, rc=0):
    • L-meta-125881 (k=10, 151 KB): generated in 3.62 s, kernel-verified in 16.2 s
    • L-meta-125860 (k=8, 147 KB): generated in 3.42 s, kernel-verified in 11.6 s
    • L-meta-125861 (k=10, 203 KB): generated in 4.22 s, kernel-verified in 24.9 s
  • Key engineering fixes: native 64-bit cgp6.c upper-bound search (~0.3–1.1 s vs 20–85 s SAT), XOR non-unate boundary edges (u ^ (1 << PHYS[i]) in gen10_dev.py, fixing proper_failG and shrinking proofs 37–80%), and subs[:8] bit-pack guard in find_cut (eliminating AssertionError on k=10).

Architecture

pequalnp.com (tools/pnp.sh + /desk/board)
        │
        ├──▶ Autoprobe (zero-day wave hunter) ──▶ runs/auto_waves.json (hot-reloaded)
        ▼
  ┌───────────┐    match?    ┌──────────────────────────────┐
  │   Zama    │ ─── yes ───▶ │ Deterministic Solvers (0 tok)│
  │Race/Runner│              │  solvers/notcover6, foud6... │
  └───────────┘              └──────────────┬───────────────┘
        │ no / fail                         │
        ▼                                   ▼
  ┌─────────────────────────┐      ┌────────────────────────┐
  │ Model-Agnostic Adapters │ ───▶ │ Statement + Pre-Lint + │
  │ ollama · openai · cli   │      │    Lean 4 Verification │
  └─────────────────────────┘      └───────────┬────────────┘
                                               ▼
                                   ┌────────────────────────┐
                                   │ Bounded Submit + Retry │
                                   │ SQLite + JSONL Ledger  │
                                   └────────────────────────┘

Model-Agnostic AI Fallback

Configure ZAMA_AI_PROVIDERS in .env in priority order (leave empty for 100% deterministic mode):

  • ollama — local models via OLLAMA_HOST and OLLAMA_MODEL
  • openai — any OpenAI-compatible API (vLLM, LM Studio, OpenRouter, OpenAI) via OPENAI_BASE_URL, OPENAI_API_KEY, OPENAI_MODEL
  • claude — local claude CLI
  • codex — local codex CLI

Contributing & Independent Verification

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> --standalone

License

MIT — see LICENSE.


Topics: Lean 4 automated theorem proving · formal verification · P vs NP · pequalnp.com harness · Boolean circuit complexity lower bounds · deterministic C++20 solvers · zero-dependency Python CLI · local LLM theorem prover (Ollama, OpenAI, Claude, Codex) · reproducible open-science ledger.

About

Open-source, model-agnostic Lean 4 automated theorem-proving harness for pequalnp.com (P vs NP): zero-token C++20/Python solvers, zero-day wave autoprobe, solve-ahead Shipping TUI, multi-node SSH fleet & verifiable proof ledger.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages