Part 2 — Structuring proofs & automation

2.7 Admissions, transactions, and sealed theories

Tutorial sequence · Previous: 2.6 Checked term transformations

Goal: distinguish deferred obligations (sorry()) from recorded admissions (admit(...)), and seal a checked session theory into an immutable Snapshot for reuse in fresh sessions.

sorry() vs. admit(...)

Operation Allows proof.finish()? Recorded in theorem.admissions()? Intended use
proof.sorry() No (blocks completion until resumed and proved). No Deferring a subgoal while working on another branch.
proof.admit(label, reason) Yes (closes the goal as an admitted obligation). Yes (label, statement, and reason) Prototyping downstream proofs while keeping an auditable list of unproved obligations.

Mojo

explicit_admission.mojo Download
"""Separate deferred work from an explicitly labeled mathematical assumption."""

from judgment import Session, implies


def main() raises:
    var s = Session()
    var P = s.prop("P")
    var Q = s.prop("Q")
    var proof = s.theorem("conditional", implies(P, Q))
    _ = proof.intro("h")
    proof.sorry()
    print("Deferred obligations:", len(proof.obligations()))
    proof.resume()
    proof.admit("missing_lemma", "Awaiting the mathematical proof")
    var theorem = proof.finish()
    print(theorem.format(details=True))

Run from the repository root pixi run core-run docs/examples/library/explicit_admission.mojo

Output

Deferred obligations: 1
[admitted] ⊢ P → Q
Admissions (1):
  missing_lemma: P → Q
    reason: Awaiting the mathematical proof

Python

explicit_admission.py Download
"""Separate deferred work from an explicitly labeled mathematical assumption."""

from judgment import Session, implies


def main():
    s = Session()
    P = s.prop("P")
    Q = s.prop("Q")
    proof = s.theorem("conditional", implies(P, Q))
    _ = proof.intro("h")
    proof.sorry()
    print("Deferred obligations:", len(proof.obligations()))
    proof.resume()
    proof.admit("missing_lemma", "Awaiting the mathematical proof")
    theorem = proof.finish()
    print(theorem.format(details=True))


if __name__ == "__main__":
    main()

Run from the repository root PYTHONPATH=bindings/python:docs/examples/python/library pixi run python docs/examples/python/library/explicit_admission.py

Output

Deferred obligations: 1
[admitted] ⊢ P → Q
Admissions (1):
  missing_lemma: P → Q
    reason: Awaiting the mathematical proof

theorem.format(details=True) marks admitted theorems [admitted] with their label, statement, and reason. Every downstream theorem citing conditional inherits that admission in its dependency closure.

Sealing a theory (Snapshot)

Calling base.seal() closes the authoring session and produces an immutable, kernel-checked Snapshot of its declarations and proved theorems. Fresh sessions opened via Session.open(snapshot) import declarations selectively with import_type, import_symbol, and import_fact:

Mojo

imported_theory.mojo Download
"""Seal a base theory snapshot, then open a new Session over it and import its declarations."""

from judgment import Session, arrow, forall


def main() raises:
    # Build a base theory in one session and seal it into an immutable Snapshot.
    var base = Session()
    var nat = base.declare_type("nat")
    var zero = base.symbol("zero", nat)
    var succ = base.symbol("succ", arrow(nat, nat))
    var n = base.bound_var("n", nat)
    _ = base.axiom("succ_ne_zero", forall(n, ~(succ(n) == zero)))
    var snapshot = base.seal()

    # Open a new session over the snapshot and import the declarations it needs.
    var s = Session.open(snapshot)
    var N = s.import_type("nat")
    var z = s.import_symbol("zero")
    var S = s.import_symbol("succ")
    var axiom = s.import_fact("succ_ne_zero")
    print(axiom)
    var proof = s.theorem("one_ne_zero", ~(S(z) == z))
    proof.exact(proof.use(axiom, terms=[z]))
    var result = proof.finish()
    print(result)
    print(result.axioms()[0], N.format())
    var exported = result.step()
    print(len(exported.hypotheses()) == 0)

Run from the repository root pixi run core-run docs/examples/library/imported_theory.mojo

Output

[axiom] ⊢ ∀x·1:nat. ¬(succ(x·1) = zero)
  axioms: succ_ne_zero
[assuming 1 axiom] ⊢ ¬(succ(zero) = zero)
  axioms: succ_ne_zero
succ_ne_zero nat
True

Python

imported_theory.py Download
"""Seal a base theory snapshot, then open a new Session over it and import its declarations."""

from judgment import Session, arrow, forall


def main():
    # Build a base theory in one session and seal it into an immutable Snapshot.
    base = Session()
    nat = base.declare_type("nat")
    zero = base.symbol("zero", nat)
    succ = base.symbol("succ", arrow(nat, nat))
    n = base.bound_var("n", nat)
    _ = base.axiom("succ_ne_zero", forall(n, ~(succ(n) == zero)))
    snapshot = base.seal()

    # Open a new session over the snapshot and import the declarations it needs.
    s = Session.open(snapshot)
    N = s.import_type("nat")
    z = s.import_symbol("zero")
    S = s.import_symbol("succ")
    axiom = s.import_fact("succ_ne_zero")
    print(axiom)
    proof = s.theorem("one_ne_zero", ~(S(z) == z))
    proof.exact(proof.use(axiom, terms=[z]))
    result = proof.finish()
    print(result)
    print(result.axioms()[0], N.format())
    exported = result.step()
    print(len(exported.hypotheses()) == 0)


if __name__ == "__main__":
    main()

Run from the repository root PYTHONPATH=bindings/python:docs/examples/python/library pixi run python docs/examples/python/library/imported_theory.py

Output

[axiom] ⊢ ∀x·1:nat. ¬(succ(x·1) = zero)
  axioms: succ_ne_zero
[assuming 1 axiom] ⊢ ¬(succ(zero) = zero)
  axioms: succ_ne_zero
succ_ne_zero nat
True
  • Provenance across snapshots: one_ne_zero records succ_ne_zero in result.axioms(), even though that axiom was declared in base.
  • Shared DAG storage: sessions opened over snapshot share its verified DAG prefix without copying or re-checking those rows.

For isolating speculative work inside a live session before sealing, see Lesson 5.1: Transactions, snapshots, and forks.

Exercise

In explicit_admission, omit proof.resume() before proof.admit(...). Does admit accept a deferred goal?

Answer

No. admit requires an active goal; a goal deferred with sorry() must be resumed first.

Next: 3.1 Instantiate polymorphic theorems.

judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub