ProofScaffold
A layered, sanity-checked scaffold for building modular Metamath artifacts.
ProofScaffold treats Python as the builder (compiler/linker) and Metamath as the verifier (semantic authority).
It follows a Transient Monolith strategy: build modular packages into IR (LIR), then concatenate them into an ephemeral .mm file for verification by one or more verifiers (e.g. metamath-exe, mmverify, metamath-knife).
Install: pip install proof-scaffold
Import: import skfd
CLI: python -m skfd.cli ... (or skfd ... if installed)
Note: the PyPI distribution name is
proof-scaffold, while the Python import package isskfd.
Why ProofScaffold
If you are maintaining a growing Metamath codebase, ProofScaffold aims to make it:
- Modular by construction: proofs live in explicit Python packages with declared dependencies.
- Traceable: symbol interning + origin tracking keep generated artifacts debuggable.
- Sanity-checked: the builder can enforce invariants before invoking verifiers.
- Verifier-agnostic: run multiple verifiers consistently via a single config (
.skfd). - Deterministic: canonical builds enable stable caching and reproducible verification.
Unicode authoring, canonical builds
Proofs are authored in Unicode (e.g. ¬, →, ∨, ∧) for readability.
Internally, the builder canonicalizes formulas into a stable ASCII representation for IR, caching, and verifier interop.
Canonicalization is deterministic and whitespace-insensitive: the same formula always maps to the same canonical token stream.
Quickstart
pip install proof-scaffold
mkdir my-proofs
cd my-proofs
python -m skfd.cli init-pkg my-proofs
python -m skfd.cli doctor check
python -m skfd.cli verify my-proofs
This will:
- Discover package build modules under
src/(_build.pypreferred;build.pysupported for compatibility). - Topologically sort packages by declared deps.
- Build each package in memory (LIR).
- Emit
target/<project-name>_full.mm(Transient Monolith). - Run configured verifiers (if available).
Tip:
my-proofsis a project name (frompyproject.toml→[project].name).verify <project-name>targets that project’s build unit (and its dependency closure).
Example: a tiny proof script
from typing import Any
def prove_modus_tollens(sys: Any) -> Any:
"""
Modus Tollens: φ → ψ, ¬ψ ⊢ ¬φ
"""
from skfd.proof import ProofBuilder
lb = ProofBuilder(sys, "modus_tollens")
h1 = lb.hyp("h1", "φ → ψ")
h2 = lb.hyp("h2", "¬ ψ")
s1 = lb.ref("s1", "( φ → ψ ) -> ( ¬ ψ → ¬ φ )", ref="con3", note="con3")
s2 = lb.mp("s2", h1, s1, note="MP h1, s1")
s3 = lb.mp("s3", h2, s2, note="MP h2, s2")
return lb.build(s3)
Verify:
python -m skfd.cli verify <project-name>
For a larger proof that showcases lifting/distribution patterns and origin tracking, see examples/.
Concepts and layout
Terminology
- Project: a ProofScaffold workspace root (contains
pyproject.toml+src/). - Build unit: what
skfd verifytargets; named bypyproject.toml→[project].name. - Package (Python): the import package under
src/<name>/(often<project-name>with-→_). - Driver: resolves deps, builds packages, emits transient monolith
.mm. - LIR: the builder’s intermediate representation emitted by packages.
Key components
1) Generic Logic Driver (skfd.driver)
Manages the build lifecycle of logic packages.
- Explicit dependencies: packages declare deps in
_build.pyor the backwards-compatiblebuild.py(e.g.metamath-prelude,metamath-logic). - No implicit globals: dependencies are injected by the driver.
- Primary command:
python -m skfd.cli verify <project-name>
2) Builder API (skfd.builder)
A fluent Python API for constructing Metamath databases.
- Atomic LIR generation.
- Symbol interning + origin tracking (for debuggability).
3) Engineering standards (AGENT.md)
CI-enforced discipline:
- Ruff (lint/format)
- MyPy (strict typing)
- Pytest
See AGENT.md for the contributor protocol.
Verifier configuration (.skfd)
ProofScaffold can run multiple verifiers in a single verify pass. The active set is controlled by .skfd.
Minimal config (single verifier)
Example: only metamath-exe (adapt command to your environment)
active = ["metamath-exe"]
[verifiers.metamath-exe]
command = "metamath"
args = ["target/<project-name>_full.mm"]
Advanced config (multiple verifiers + shims)
Example (mmverify + metamath-knife + metamath-exe + shim):
active = ["mmverify", "metamath-knife", "metamath-exe"]
[verifiers.metamath-knife]
command = "../metamath-knife/target/release/metamath-knife"
args = ["--verify"]
[verifiers.metamath-exe]
command = "/usr/bin/env"
args = [
"METAMATH_BIN=../metamath-exe/src/metamath",
"./.venv/bin/python",
"./verifier/shims/metamath.py"
]
Environment check:
python -m skfd.cli doctor check
Usage
Dev mode vs. user mode
User mode (installed via PyPI)
- Dependencies are installed packages; no
PYTHONPATHneeded. .skfdcan be minimal and extended only if desired.- Typical usage:
python -m skfd.cli verify <project-name>.
Dev mode (multi-repo / local path deps)
- Repos may live side-by-side; dependencies can be pulled via local path (e.g.
uvsources). - You may need
PYTHONPATHdepending on your workspace layout. .skfdoften points to local binaries and shims (multi-verifier runs).
Initialize a project
Package mode: creates src/ + pyproject.toml + .skfd
mkdir my-proofs
cd my-proofs
python -m skfd.cli init-pkg my-proofs
Standalone proof script: creates my_proof.py (no src/)
python -m skfd.cli init-proof my_proof.py
Build & verify a project
python -m skfd.cli verify <project-name>
verify checks the generated transient monolith. If a package exposes a
larger authoring-facing theorem registry than it emits in build(ctx), validate
that registry in the package's own tests:
from skfd.proof import assert_valid_proof_registry
def test_public_proof_registry() -> None:
system = System.make(interner=interner, names=names)
assert_valid_proof_registry(
system=system,
constructors=SETMM_TO_HILBERT_LEMMAS,
axioms=system.compile_axioms(),
reserved={"wi", "wn", "wa", "mp"},
)
This catches dangling lb.ref(..., ref="...") labels, constructor-time proof
errors, self-references, and dependency cycles before verifier invocation.
Packages can also declare their intended proof surface during build(ctx):
def build(ctx: BuildContextV2) -> None:
...
ctx.coverage.declare_registry("hilbert", SETMM_TO_HILBERT_LEMMAS)
ctx.coverage.require_all_declared_verified()
Then run:
python -m skfd.cli verify --coverage declared <project-name>
--coverage declared fails if any declared label is missing from the emitted
verification monolith. Packages without coverage declarations keep the existing
behavior and report that coverage is limited to the emitted monolith.
Browse theorem dependency chains (local web)
python -m skfd.cli serve <project-name> --port 8000
Then open http://127.0.0.1:8000/ and search/click assertions to inspect direct and reverse dependencies.
Run tests:
pytest
If you use uv:
uv run pytest
See CONTRIBUTING.md for development workflow and contribution guidelines.
Documentation
Start here:
projects/009-logic_driver.md— driver design, IR, and the Transient Monolith strategy.examples/— minimal and larger proof examples.src/skfd/— core toolchain implementation.
License
See LICENSE.
Metadata
Release files for proof-scaffold 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| proof_scaffold-0.0.13.tar.gz | 144.5 kB | With provenance | Details for proof_scaffold-0.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| proof_scaffold-0.0.13-py3-none-any.whl | Python 3 | none | any | Details for proof_scaffold-0.0.13-py3-none-any.whl |
Total release size: 314.2 kB
Release files / proof_scaffold-0.0.13.tar.gz
| Download URL | proof_scaffold-0.0.13.tar.gz |
|---|---|
| Size | 144.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e64863b07861d8bf621cec029e26ba06f8b51c8107180610898013a88e395353
|
|
BLAKE2b-256 checksum How to use checksums |
1987c7af6bf2149a6241f96f6c63ea8767881b4d19410527c1529993899477e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / proof_scaffold-0.0.13-py3-none-any.whl
| Download URL | proof_scaffold-0.0.13-py3-none-any.whl |
|---|---|
| Size | 169.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c00b70e61ef3e0b3827c1a8ed72295f79c509f10b6fb048bd1df55d1b94274e
|
|
BLAKE2b-256 checksum How to use checksums |
ebebae6c65de31981530ee9779de7811f550c3751a34b8e9344ce5f350bf5ad0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logSecurity for proof-scaffold 0.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for proof_scaffold-0.0.13.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.