Using the API¶
Application and proof-authoring code works through Session, importing from
judgment (or judgment_shell); see the
proof-authoring guide. Low-level
checking and storage clients import the stateless checking kernel from
judgment_core and proof-DAG storage from termbank and termbank.dag.
Every checked result is established by judgment_core's stateless checker over
rows stored in termbank.dag. This guide explains how the layers fit together;
the judgment_core reference and
termbank reference supply the exact signatures and
docstrings from the sources.
Read the language tabs¶
The public authoring API and maintained example ports have synchronized Mojo and Python tabs. Your browser remembers the choice across pages. The Python signatures come from the shipped Python client, including its keyword-only arguments and overload dispatch. Low-level APIs without a Python binding retain their Mojo signatures; unbound overloads of a shared type are identified in the Python tab.
Descriptions are shared with the Mojo source docstrings. Mojo ownership
qualifiers and compile-time parameters apply to Mojo. Python uses int for
exact integers and fractions.Fraction for rationals; see
what differs from Mojo for errors,
records, and object lifetimes. Record constructors are shown separately because
Python does not mirror Mojo's constructor overloads. Defaults such as []
and FilterConfig() describe the value when an argument is omitted; mutable
defaults are created for each call.
Choose an operation¶
| Task | Main entry points | Reference |
|---|---|---|
| Author theories, definitions, and proofs | Session, Proof, Goal, Expr, Step, Fact (judgment) |
Proof-authoring guide |
| Scope speculative work or branch | Session.transaction, Session.snapshot, Session.fork |
Scoped work tutorial |
| Store proof-DAG rows and workspaces | DagBank, Workspace, DagWriter, DagView (termbank.dag) |
termbank reference |
| Construct canonical terms and derivations | Constructor, Derivations, WriterSource (judgment_core) |
judgment_core reference |
| Check proof rows and chunks (parallel) | check_proof, check_chunk, check_dag_chunk, Scratch |
judgment_core reference |
| Check declarations and theories | check_declaration, check_theory, core_prefix |
judgment_core reference |
| Decode/encode exact literals | LiteralImpl, LiteralValue, PolyValue, encode, decode |
Conversion theory |
| Inspect rule operand layouts | RuleTag, rule_layout |
judgment_core reference |
| Persist or import format-2.2 libraries | Library, LibraryChange, Article, reuse (judgment_store) |
Store overview |
Handles and ownership¶
Persistent tables live in termbank.dag's DagBank; judgment_core holds
no tables:
- DAG row references (
termbank.dag): committed rows carry strictly increasing sequence numbers, and every reference points to a smaller sequence number. Rows below a bank's verified watermark have been accepted byjudgment_coreand hold aVerdict(rows_verdict,ChunkVerdict,TheoryVerdict). - Workspace isolation: uncommitted speculative rows live in a
termbank.dagWorkspace(used bySession.transaction()andSession.fork()). Discarding a workspace never modifies committed rows. - Session handles (
judgment_shell):Expr,TypeExpr,Step,Fact, andFramename rows of one session's workspace. A handle is valid while its rows are; another session refuses it (WRONG_KERNEL), and a stale one is refused withKERNEL.
Never synthesize a Verdict or bypass the checker: only judgment_core
constructs verified verdicts that advance a bank's watermark
(trusted base).
Theories and declarations¶
Every bank starts with the logic core prefix (core_prefix), checked through
the same theory pass as any user declaration. Declarations are stored as
termbank.dag declaration rows and validated by check_declaration and
check_theory (judgment_core reference):
| Form | Effect |
|---|---|
| Type constructor, constant | Introduce vocabulary with the declared arity or type. |
| Definition | Introduce a constant with a checked closed body and a defining equation. |
| Axiom | Admit a closed proposition as an assumption of the theory. |
| Proven | Store a closed checked proof's statement as a reusable theorem with its dependency closure. |
| Type definition, specification | Introduce types or constants from checked witness facts and side conditions. |
| Class, instance, class relation | Declare class constraints and checked evidence for instances or subclass relations. |
| Overloaded constant, instance definition | Define a constant at admissible type instances, subject to global overloading checks. |
| ACU operator, literal kind | Register canonical operations and exact literal kinds with their required law declarations. |
In Session, declarations are made by its methods: declare_type,
type_constructor, symbol, prop, define, axiom, theorem and
lemma (declared by finish), prove_step, subset, specification,
class_, instance, class_relation, instance_definition,
acu_operator, and literal_kind. Each writes rows into the session's workspace and has them
checked before it returns.
Types, terms, and literal arithmetic¶
Constructor (judgment_core) builds canonical types and terms into a
termbank.dag Workspace or DagWriter through a WriterSource, enforcing
typing, scope, ACU canonical order, and literal folding
(conversion theory).
The root logic supplies Prop, equality, connectives, and quantifiers, not a
default number system. Literal arithmetic (exact integers, exact rationals, and
formal polynomials via LiteralImpl, LiteralValue, PolyValue, encode,
decode) becomes active only in a theory that registers the carrier,
operations, and required laws for that literal kind. Literal folding is limited
to operations justified by the registered laws; it is not a general symbolic
simplifier. See the arithmetic tutorial and
polynomial theory.
Contexts and reusable results¶
Contexts are chains of frame rows in termbank.dag fixing locals and assuming
hypotheses (termbank reference). Constructor builds frames
(nd_fix, nd_assume) and natural-deduction rows (nd_row); Derivations
adds the derived equality and existential rules.
A local is its binding site: the frame it extends, its type, and its name. Fixing one name at one type over one frame twice gives one local and one fix frame, and assuming one proposition twice over one frame gives one assume frame; locals printed alike at different binding sites stay distinct.
In Session, frames come from base, fix, and assume. A second
fix(frame, name, type) returns the frame and variable of the first; a name
the session used for another variable, or one that begins with ·
(reserved for internal helpers), is refused with SHAPE. imp_intro,
forall_intro, and discharge move a derivation to an enclosing frame by
discharging used hypotheses and quantifying used locals; lift_to moves a
step into an extending frame, and transport substitutes a step's locals
and hypotheses. A closed step can be declared as a Proven theorem
(prove_step, or finish of a named proof). Session.seal closes the
session and returns its declarations as a checked Snapshot for later
sessions, and Session.export gives a theorem's checked proof for library
publication.
Inspect what a result depends on¶
The checker establishes verified Fact records about nodes for a signature
(judgment_core reference); term_info and th_includes query verified facts
and theory inclusion on a CheckView. statement_key keys a closed
statement, canonical for a signature, up to renaming of its type variables
(StatementKey); type_params lists a node's type variables in order of
first occurrence.
In Session, Step and Fact expose statement(), axioms(),
admissions(), and dependencies(), and a Step also lists its
hypotheses(). Empty hypotheses mean no local assumptions remain; inspect
the axioms and dependencies to see which theory declarations a result
relies on.
Errors and work limits¶
Session operations raise LibError with a LibErrorKind. A refusal from
the kernel has kind KERNEL and keeps the kernel's ErrorKind in
kernel_kind and, for a checker refusal, the Refusal itself; exhausting a
session's work allowance is LIMIT
(troubleshooting).
The stateless checker returns typed Refusal values (RefusalKind,
refusal_code) from pure checking functions (check_proof, check_chunk,
check_dag_chunk, check_declaration, check_theory), and raises
CheckFail / KernelError (ErrorKind) or BankError (BankErrorKind) at
fallible boundaries. Branch on the structured kind rather than message text:
| Kind | How to interpret it |
|---|---|
ILL_TYPED, NOT_A_PROP |
An expression does not have the type the operation requires. |
SCOPE |
A declaration, local, hypothesis, or context is unavailable where it is used. |
BAD_HANDLE, WRONG_KERNEL |
A handle or reference is invalid, stale, or belongs to another owner. |
MISMATCH, SIDE_CONDITION |
A proof's shape, promised result, or required rule condition does not fit. |
DECLARATION, NAME_CLASH |
A proposed declaration violates the declaration rules. |
LIMIT |
The call exhausted its work allowance (Budget, chunk_allowance). It did not settle the question. |
CAPACITY |
A table or representation limit (ScratchLimits, DagBank bounds) was reached. |
See the error reference for all error
kinds. In checking, chunk_allowance and ScratchLimits bound per-chunk work
and scratch memory deterministically (G1–G4); LIMIT is always an undecided
refusal, never a claim of falsity or inequality.