verify¶
The verification report and the shared verifier: compile a candidate project in a sandbox
and judge whether it compiles, is sorry-free, and is axiom-clean. Every prover
funnels its output through the Verifier.
Verifier¶
- class open_atp.verify.Verifier(backend: ComputeBackend)[source]¶
Compiles projects in a
ComputeBackendand reports their status.Shared by every prover for the final compile/sorry/axiom check. Use
docker_verifier()ormodal_verifier()for the common cases.- Parameters:
- backend
ComputeBackend The sandbox the candidate project is compiled in. Its image carries the Lean toolchain + Mathlib pins every project is checked against.
- backend
- Attributes:
imageImageThe image the backend runs – the compatibility contract projects match.
- check_compatible(project: LeanProject) None[source]¶
Reject a project whose pins differ from the backend image’s.
Matches the project’s
lean_toolchainagainst the image’slean_toolchain, and its lockedmathlib_rev(when the project records one) against the image’smathlib_rev. RaisesToolchainMismatchorMathlibRevMismatchon the first mismatch.- Parameters:
- project
LeanProject The candidate project whose toolchain (and locked Mathlib revision, when recorded) must match the backend image’s pins.
- project
- Raises:
ToolchainMismatchIf the project’s toolchain differs from the image’s.
MathlibRevMismatchIf the project records a Mathlib revision that differs from the image’s.
Examples
>>> import tempfile >>> from pathlib import Path >>> from open_atp.backends.docker import DockerBackend >>> from open_atp.images import Image >>> from open_atp.lean import LeanProject >>> from open_atp.verify import Verifier >>> root = Path(tempfile.mkdtemp()) >>> _ = (root / "lakefile.toml").write_text('name = "demo"\n') >>> _ = (root / "lean-toolchain").write_text("leanprover/lean4:v4.31.0\n") >>> project = LeanProject(root)
A matching pin passes silently:
>>> image = Image(lean_toolchain="leanprover/lean4:v4.31.0") >>> ok = Verifier(DockerBackend(image=image)) >>> ok.check_compatible(project)
A differing pin is rejected up front:
>>> bad = Verifier(DockerBackend(image=Image())) >>> bad.check_compatible(project) Traceback (most recent call last): ... open_atp.lean.ToolchainMismatch: Project pins ...
- verify(project: LeanProject, *, session: ComputeSession | None = None) VerificationReport[source]¶
Compile
projectand return aVerificationReport.Standalone (
session is None) the compile spins up its own sandbox viabackend.run– the path Aristotle and the split-backend case take. When a caller passes a livesession(the agent/verify backend-reuse path), the compile runs in that already-hot sandbox instead, avoiding a second spin-up.- Parameters:
- project
LeanProject The candidate project to compile. Checked for compatibility first.
- session
ComputeSession, optional A live, already-hot sandbox to compile in. When
None(the default),backend.runspins up a fresh sandbox for this compile.
- project
- Returns:
VerificationReportThe compile/
sorry/axiom verdict. A project with no.leanfiles short-circuits to a trivial passing report without touching the sandbox.
- Raises:
ToolchainMismatchIf the project’s pins differ from the backend image’s (via
check_compatible()).MathlibRevMismatchIf the project’s locked Mathlib revision differs from the image’s.
Examples
A real project compiles in the backend; a project with no
.leanfiles short-circuits to a trivial passing report without touching the sandbox:>>> import tempfile >>> from pathlib import Path >>> from open_atp.backends.docker import DockerBackend >>> from open_atp.images import Image >>> from open_atp.lean import LeanProject >>> from open_atp.verify import Verifier >>> root = Path(tempfile.mkdtemp()) >>> _ = (root / "lakefile.toml").write_text('name = "demo"\n') >>> _ = (root / "lean-toolchain").write_text("leanprover/lean4:v4.31.0\n") >>> image = Image(lean_toolchain="leanprover/lean4:v4.31.0") >>> verifier = Verifier(DockerBackend(image=image)) >>> report = verifier.verify(LeanProject(root)) >>> report.verified True
Report¶
- class open_atp.verify.VerificationReport(compiles: bool, sorry_free: bool, axioms: tuple[str, ...]=(), compile_log: str = '', per_file: dict[str, bool]=<factory>)[source]¶
Result of compiling a candidate project in a sandbox.
Produced by
Verifierand shared by every prover, including Aristotle.- Attributes:
- compilesbool
Whether the whole project built successfully.
- sorry_freebool
Whether the build is free of
sorry(no incomplete proofs remain).- axioms
tuple[str, …] Every axiom the compiled project depends on, as reported by Lean.
- compile_log
str The full build log. Omitted from
to_dict().- per_file
dict[str, bool] Per-file compile status, keyed by file path relative to the project root.
non_standard_axiomstuple[str, …]The depended-on axioms outside
STANDARD_AXIOMS.verifiedboolTrue iff the project compiles, has no sorry, and no foreign axioms.
Standard Verifiers¶
- open_atp.verify.docker_verifier(image: Image = Image(name='open-atp:latest', lean_toolchain='leanprover/lean4:v4.28.0', mathlib_rev='v4.28.0')) Verifier[source]¶
A
Verifierbacked by a local Docker sandbox runningimage.- Parameters:
- image
Image, optional The image whose Lean toolchain + Mathlib pins projects are checked against. Default
DEFAULT_IMAGE.
- image
- Returns:
VerifierA verifier over a
DockerBackend.
- open_atp.verify.modal_verifier(image: Image = Image(name='open-atp:latest', lean_toolchain='leanprover/lean4:v4.28.0', mathlib_rev='v4.28.0')) Verifier[source]¶
A
Verifierbacked by a Modal Sandbox running the publishedimage.Needs Modal credentials and the image published via
open-atp build-modal-image. The image’s:tagis dropped for the Modal name lookup.- Parameters:
- image
Image, optional The published image whose Lean toolchain + Mathlib pins projects are checked against. Default
DEFAULT_IMAGE.
- image
- Returns:
VerifierA verifier over a
ModalBackend.
Axioms¶
- open_atp.verify.STANDARD_AXIOMS = frozenset({'Classical.choice', 'Quot.sound', 'propext'})¶
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.