judgment_shell API¶
Import these names from judgment_shell; the public judgment package
re-exports the authoring names. L1 supplies typed errors, the head index,
term and type views, builders, and bounded printing. L2 supplies recipes,
execution, derived rules, labels, and claims. L3 adds matching,
metavariables, guards, supports, the theorem store, and law bundles. L4
supplies equality conversions and the checked engine protocol. The
design pages give the contracts.
Use the Mojo / Python tabs to select call signatures throughout the site.
Python imports these names from judgment. The
API guide explains shared
descriptions, Python defaults, and overload availability.
Every structure and function works over one Session, passed explicitly.
Its handles (Expr, TypeExpr, Step, Fact, Frame, and the others)
name rows of that session's workspace and are valid while those rows are:
a handle of another session is refused with library WRONG_KERNEL, and a
stale one, such as a handle made inside a discarded transaction, with
KERNEL. A function with a mut budget: Budget argument charges that
caller-owned termbank.Budget for its traversals; the session's own
operations also charge the session's allowance. A failed session operation
leaves the session's rows as they were (G9); work already charged stays
charged.
Proof authoring¶
The Session guide describes the surface and
its runnable examples; the specification gives its
contracts and scope. Symbolic equality (==, eq) constructs an
expression, never a Boolean; same_as compares identity. A session's
Snapshot is a checked theory that Session.open starts from and
Session.seal extends.
Session¶
Mojo
struct Session(Movable)
Python
from judgment import Session
A session over a bank snapshot and a workspace; private, wrapped by Session.
Defined in src/judgment_shell/ws_session.mojo.
Session.__init__¶
Mojo
def __init__(out self, work: UInt64 = 1000000) raises LibError
Python
def __init__(self, work=1000000)
Create an independent session over the core prefix without adding mathematical axioms.
Arguments.
work: Initial work allowance for authoring operations.
Raises.
LibError: On kernel or budget failure.
Session.open¶
Mojo
@staticmethod
def open(snapshot: Snapshot, work: UInt64 = 1000000) raises LibError -> Self
Python
@staticmethod
def open(snapshot, work=1000000)
Open a session over a checked snapshot.
The session records the snapshot's profile axioms as PROFILE_AXIOM and a library version's declarations
as its imports from that version.
Arguments.
snapshot: A sealed snapshot frombuild_scalarorLibrary.work: Initial work allowance.
Returns. A live session.
Raises.
LibError: On snapshot or budget errors.
Session.seal¶
Mojo
def seal(self, marker: Optional[ProfileMarker] = None) raises LibError -> Snapshot
Python
def seal(self, marker=None)
Seal this session into an immutable checked snapshot, closing the session.
Past the refusals made before any change, the session is closed whatever happens (its workspace is the
bank's or gone; handles stale, operations SHAPE). The rows are
committed into the bank (Workspace.commit, which rolls the bank back on its own failure), then checked by
the theory pass and the row checks as any base rows are; the new snapshot is the bank's verified prefix with
marker. Earlier snapshots keep their prefix. The new snapshot keeps the earlier one's names, library
imports and profile axioms, and lists the session's own profile axioms (profile_axiom) after them; a
statement-only import the session made (import_theorem) becomes one of the bank's declarations
and is not an import of the new snapshot, so a later export citing it is refused: export first.
The marker is checked against the session's own prefix and the seal's whole bounded work (one unit per row
to commit, one per row checked; finding the session's profile axioms reads one entry per declaration it
commits, within that charge) charged before any change, so a LIMIT or a wrong marker leaves the session
open and the bank sealable. A bank whose memory share cannot hold the rows refuses the commit and rolls itself
back, the session closed. Only a disagreement after the commit (the bank's checks refusing rows the session's
checks passed, or the marker no longer matching) poisons the bank: its rows past the earlier prefix stay
unverified, earlier snapshots stay valid (and open: their prefixes are verified), and no later seal builds
on it. That disagreement is unreachable by construction, the session's checks being the bank's; the poison
is a guard.
Not thread-safe against another seal of the same snapshot's bank: seal a bank's sessions from one thread.
Arguments.
marker: Optional profile marker.
Returns. The sealed snapshot.
Raises.
LibError:SHAPE, before any change, for a session not opened over a snapshot, a fork, a closed session, a transaction or a fork of it open, or a bank that has advanced since the session's snapshot;UNSUPPORTEDfor a session that imported a trusted layer (the bank's pass trusts none);KERNELfor a marker that does not match the session's prefix (before any change), a poisoned bank, or a disagreement after the commit (which poisons it);LIMITfor an allowance that cannot pay for the seal (before any change) or a bank that cannot hold the rows.
Session.fork¶
Mojo
def fork(self, work: UInt64 = 1000000) raises LibError -> Self
Python
def fork(self, work=1000000)
Fork this session into an independent child workspace.
The two then evolve independently: neither sees the other's later
rows, and handles of one are foreign to the other. Each can still
roll back its own failed operations: a workspace truncates with a
child open to a mark taken after the child was made (dag-storage
item 4), and every operation takes its mark when it starts, after
any fork. Forks may run on worker threads, one thread per fork, only
under the fork rule of ws_fork (ForkUnit): every fork made
before any is moved, and this session idle until every fork is
joined, since its rollback must not run while a fork reads the rows
they share (CG4). Otherwise the two are driven from one thread.
Arguments.
work: Work allowance for the fork.
Returns. The forked session.
Raises.
LibError:SHAPEwhile a transaction is open;LIMITwhen this session's allowance cannot pay for copying its tables (one unit per entry), or the fork's for adopting the snapshot;KERNELwhen the workspace refuses a child. This session's rows and tables are then unchanged; after the child was made, its count of children made has grown by one (D8), and the copy's charge is spent.
Session.fork_cost¶
Mojo
def fork_cost(self) -> UInt64
Python
def fork_cost(self)
Work units required from this session to fork it.
Returns. The fork copy cost.
Session.work_remaining¶
Mojo
def work_remaining(self) -> UInt64
Python
def work_remaining(self)
Remaining work units in this session's allowance.
Returns. Remaining units.
Session.memory_limit¶
Mojo
def memory_limit(self) raises LibError -> UInt64
Python
def memory_limit(self)
Return the current workspace's tracked-storage byte limit, excluding its shared snapshot and scratch.
Returns. The workspace allowance; UInt64.MAX means unlimited.
Raises.
LibError:SHAPEfor a closed session.
Session.memory_used¶
Mojo
def memory_used(self) raises LibError -> UInt64
Python
def memory_used(self)
Return the current workspace's charged allocation bytes, including retained chunk capacity.
Returns. Tracked workspace bytes, not process RSS or the shared snapshot's storage.
Raises.
LibError:SHAPEfor a closed session.
Session.set_memory_limit¶
Mojo
def set_memory_limit(self, bytes: UInt64) raises LibError
Python
def set_memory_limit(self, bytes)
Set the live session workspace's tracked-storage limit in bytes.
Existing rows are kept. A limit below memory_used() is refused without changing the old limit. Raising
it permits retry after allocation exhaustion. This setting is independent of work units and process RAM;
it excludes the shared snapshot, authoring metadata and checker scratch. New forks inherit the remaining
workspace allowance. Configure each new session opened after sealing separately.
Checkpoint rollback keeps this operational setting; the setter consumes no proof work units.
Arguments.
bytes: The workspace byte limit;UInt64.MAXremoves it.
Raises.
LibError:LIMITif existing charges do not fit;SHAPEfor a closed session, transaction or open fork.
Session.set_spill_directory¶
Mojo
def set_spill_directory(self, directory: String) raises LibError
Python
def set_spill_directory(self, directory)
Choose an existing directory for the shared snapshot bank's private spill file.
Call spill() to move eligible verified bank pages there; active workspace rows remain resident. The setting is
shared by every session opened over this bank. A unique bank filename is created exclusively on the first
spill and removed with the bank. Changing or disabling the directory is allowed only before file/cache
activity; repeating the same directory is harmless. Serialize configuration with other sessions' seals
and storage setters over the same snapshot bank.
Directory validation and configuration consume no proof work units.
Arguments.
directory: Existing spill directory; empty disables spilling before it starts.
Raises.
LibError:SHAPEfor a closed session, transaction, fork, missing backing snapshot, or relocation after spilling starts, or an invalid directory;KERNELfor a filesystem error. Refusal keeps the old setting.
Session.spill¶
Mojo
def spill(self) raises LibError -> UInt64
Python
def spill(self)
Spill eligible verified pages of the shared snapshot bank to its configured directory.
Seal authored rows and open the returned snapshot before spilling those rows. Active workspace rows never spill. All sessions over the bank share its storage; serialize this pass with its seals and storage setters. A failure may have spilled some pages but keeps the session open and every checked row valid. Reads verify spilled data against its in-memory digest. Disabled spilling is a no-op. This maintenance pass scans the backing bank and performs synchronous I/O outside the proof work allowance.
Returns. Bytes of resident chunks and index runs retired; this excludes the bank's spill cache allocation.
Raises.
LibError:SHAPEfor a closed session, transaction, fork or missing backing snapshot;LIMITwhen the bank cannot allocate its spill cache;KERNELfor spill I/O or integrity errors.
Session.spend¶
Mojo
def spend(self, amount: UInt64) raises LibError
Python
def spend(self, amount)
Consume work units from this session's allowance.
Arguments.
amount: Units to spend.
Raises.
LibError:LIMIT, charging nothing, when the allowance is smaller;SHAPEfor a closed session.
Session.add_work¶
Mojo
def add_work(self, amount: UInt64) raises LibError
Python
def add_work(self, amount)
Add work units to this session's allowance.
Arguments.
amount: Units to add.
Raises.
LibError:LIMIT, granting nothing, when the allowance would overflow;SHAPEfor a closed session.
Session.__init__¶
Mojo
def __init__(out self, *, var _state: ArcPointer[_DagState])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal: a session over a state, for fork.
Arguments.
_state: The state.
Session.import_theorems¶
Mojo
def import_theorems[S: TheoremSource](self, source: S, names: List[String]) raises LibError -> List[Fact]
Python
def import_theorems(self, source, names)
Requires the Python core built with Store support.
The source can be Article or Library.
Import multiple theorems statement-only from a library source.
The source declares their providers' closure and the whole class layer; the session decides and checks those rows, the class layer's coregularity taken from the library only when nothing but the core and the profile lies below the import (as the Store's import does). On any failure the workspace and the engine return to their state before the call, and nothing is registered.
Parameters.
S: Library source type.
Arguments.
source: Library source.names: Export names.
Returns. The imported facts in order.
Raises.
LibError:NO_MATCHfor a name the source does not resolve;SHAPEfor a used name;LIMITwhen the session's allowance runs out;KERNELwhen the source fails or the kernel refuses a row.
Session.import_theorem¶
Mojo
def import_theorem[S: TheoremSource](self, source: S, name: String) raises LibError -> Fact
Python
def import_theorem(self, source, name)
Requires the Python core built with Store support.
The source can be Article or Library.
Import a single theorem statement-only from a library source.
Parameters.
S: Library source type.
Arguments.
source: Library source.name: Export name.
Returns. The imported fact.
Raises.
LibError: On missing/invalid theorem or exhaustion.
Session.prove¶
Mojo
def prove(self, name: String, var proof: UInt64) raises LibError -> Fact
Python
def prove(self, name, proof)
Declare a closed theorem from a workspace proof row.
Arguments.
name: Fresh theorem name.proof: Workspace proof row concluding a closed proposition.
Returns. The declared theorem fact.
Raises.
LibError:SHAPEfor a used name or a proof with hypotheses;KERNELwhen the kernel refuses a row.
Session.export¶
Mojo
def export(self, thm: Fact, name: String) raises LibError -> TheoremExport
Python
def export(self, thm, name)
Export a theorem with its checked proof over its imports for library publication.
Rows of the core prefix are cited by id, the profile's declarations by position, imported ones by identity and version; every other row of the closure is exported by content.
Arguments.
thm: Theorem declared in this session.name: Publication theorem name.
Returns. The checked theorem export.
Raises.
LibError:FORMATfor a name that is neither a theorem name (dot-separated snake_case components, each[a-z][a-z0-9_]*, the first notjudgment) nor a canonicaljudgment.stmt.<sid>with a sid of 64 hex digits;KERNELfor a stale handle;SHAPEfor an imported fact;UNSUPPORTEDwhen the closure holds a declaration of the session's other than the theorem, or one of the snapshot outside the profile.
Session.prop_type¶
Mojo
def prop_type(self) raises LibError -> TypeExpr
Python
def prop_type(self)
Built-in proposition type Prop.
Returns. The Prop type.
Raises.
LibError: On closed session or exhaustion.
Session.true_¶
Mojo
def true_(self) raises LibError -> Expr
Python
def true_(self)
Built-in truth constant True.
Returns. True.
Raises.
LibError: On closed session or exhaustion.
Session.false_¶
Mojo
def false_(self) raises LibError -> Expr
Python
def false_(self)
Built-in falsehood constant False.
Returns. False.
Raises.
LibError: On closed session or exhaustion.
Session.declare_type¶
Mojo
def declare_type(self, name: String) raises LibError -> TypeExpr
Python
def declare_type(self, name)
Declare a nullary opaque type.
Arguments.
name: Fresh type name.
Returns. The declared type.
Raises.
LibError:SHAPEforProp;KERNELfor a used name or a refused row;LIMIT.
Session.import_type¶
Mojo
def import_type(self, name: String) raises LibError -> TypeExpr
Python
def import_type(self, name)
Import a nullary type declared in the snapshot or earlier imports.
Arguments.
name: Type name.
Returns. The type handle.
Raises.
LibError:NO_MATCHfor an unknown name;KERNELfor a type operator of arguments;LIMIT.
Session.symbol¶
Mojo
def symbol(self, name: String, kind: TypeExpr, *, overloaded: Bool = False) raises LibError -> Expr
Python
def symbol(self, name, kind, *, overloaded=False)
Declare a constant of a concrete or generic type.
Arguments.
name: Fresh constant name.kind: Constant type.overloaded: Whether to declare an overloaded constant.
Returns. The constant expression.
Raises.
LibError:SHAPEforPropor a standard constant's name (declared at its own type);KERNELfor a used name, a stale type or a refused row;LIMIT.
Session.prop¶
Mojo
def prop(self, name: String) raises LibError -> Expr
Python
def prop(self, name)
Declare a constant of type Prop.
Arguments.
name: Fresh constant name.
Returns. The proposition constant.
Raises.
LibError: Assymbol.
Session.find¶
Mojo
def find(self, prefix: String = "", limit: Int = 20) raises LibError -> List[String]
Python
def find(self, prefix='', limit=20)
Find registered fact names matching a prefix.
Arguments.
prefix: Required prefix.limit: Maximum names returned.
Returns. Sorted matching fact names.
Raises.
LibError:SHAPEfor a closed session;LIMITon exhaustion.
Session.import_symbol¶
Mojo
def import_symbol(self, name: String, type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Expr
Python
def import_symbol(self, name, type_args=[])
Import a constant declared in the snapshot, earlier imports, or this session.
Arguments.
name: Constant name.type_args: Explicit type arguments for polymorphic constants.
Returns. The constant expression.
Raises.
LibError:NO_MATCHfor an unknown name;UNSUPPORTEDfor a polymorphic constant without type arguments;SHAPEfor a number of type arguments other than its parameters';KERNELfor a stale or foreign handle or an instance the kernel refuses (one outside a parameter's sort);LIMIT.
Session.validate_type_arguments¶
Mojo
def validate_type_arguments(self, types: List[TypeExpr]) raises LibError
Python
def validate_type_arguments(self, types)
Validate that every type argument belongs to this live session.
Ordinary session variables can occur alongside a proof's variables. Traversal reads the verified type DAG and charges the session allowance. A foreign owner, stale type, incompatible scopes or exhaustion raises its corresponding library error.
Arguments.
types: Type expressions to validate.
Raises.
LibError: On foreign or stale type handles, or exhaustion.
Session.parameter_formal¶
Mojo
def parameter_formal(self, parameter: Declaration) raises LibError -> Expr
Python
def parameter_formal(self, parameter)
Read an overloaded class parameter at its declaration's formal type parameters.
Arguments.
parameter: Live overloaded parameter declaration.
Returns. The checked constant expression at its formal type parameters.
Raises.
LibError:WRONG_KERNELfor another session,KERNELfor a stale handle or a refused term,SHAPEfor another declaration kind, orLIMITfor exhausted work.
Session.bound_var¶
Mojo
def bound_var(self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def bound_var(self, name, kind)
Construct a bound variable for quantifiers and lambdas.
An expression may mix it with fixed variables (fix): where it meets them, the session
uses the variable's copy fixed on their chain (one per frame, under the same name), and binding the variable
(dag_lambda, forall, dag_exists) binds its copies too, so the text and the bound term are as if
the variable itself had been used. Fixed variables of sibling frames still cannot meet (SHAPE).
The variable is a new local, distinct from every variable the session records: it is the
construction engine's variable of variant_e(kind, name), the first of name, name′, … that the engine
holds no variable of, and name is its label. Names stay session-unique: a name is used until a truncation
drops its variable.
Arguments.
name: Variable name.kind: Variable type.
Returns. The bound variable expression.
Raises.
LibError:SHAPEfor a used or reserved name (one that begins with·);KERNELfor a stale type;LIMIT.
Session.import_fact¶
Mojo
def import_fact(self, name: String) raises LibError -> Fact
Python
def import_fact(self, name)
Import an axiom, theorem, or definition equation by name.
Its statement is authored from the stored one when first needed (by this call, cite or use): the
connectives, equality and quantifiers in their authored forms, constants under their names, bound variables
under fresh names. The fact is the snapshot's, so it stays valid across the session's rollbacks (G6). A name
the snapshot does not hold is looked up among the declarations the session imported statement-only
(import_theorem(s), their signature closure included); such a fact is the session's, at its generation.
Arguments.
name: Fact name.
Returns. The fact handle.
Raises.
LibError:NO_MATCHfor a name no axiom, theorem or definition of the snapshot has;UNSUPPORTEDfor a statement the session cannot author (a let, a class predicate's head, a free local, or a statement stored before an ACU declaration whose canonical form no longer rebuilds it), or for a name the snapshot gives a fact of another kind (a type definition's);SHAPEfor a name the session registered for another fact;KERNELfor an unreadable snapshot;LIMIT. A name the snapshot declares twice resolves to the later declaration; a name the snapshot gives a fact (a library's theorem name) resolves to that fact first. A bare statement identity (64 hexadecimal digits) is not a name: a library statement's canonical name isjudgment.stmt.<sid>.
Session.snapshot_fact¶
Mojo
def snapshot_fact(self, name: String) raises LibError -> Fact
Python
def snapshot_fact(self, name)
Look up a fact declared in this session's immutable base snapshot.
An axiom's or a theorem's handle is at generation 0 over its stored statement, which is the snapshot's own
row; a definition's equation is its defining row's conclusion at the session's signature, made in the session
as an operation, at the session's generation, as import_fact issues them. A declaration the session imported
statement-only (import_theorem(s), its signature closure included) is found by name too, at the session's
generation: a rollback can drop it.
Arguments.
name: Fact name in the base snapshot.
Returns. The checked snapshot fact.
Raises.
LibError:NO_MATCHfor a name no axiom, theorem or definition of the snapshot has;UNSUPPORTEDfor a name the snapshot gives a fact of another kind (a type definition's);KERNELfor an unreadable snapshot;LIMIT. A name the snapshot declares twice resolves to the later declaration; a name the snapshot gives a fact (a library's theorem name) resolves to that fact first.
Session.snapshot_declares¶
Mojo
def snapshot_declares(self, declaration: UInt32) raises LibError -> Bool
Python
def snapshot_declares(self, declaration)
Report whether a declaration id lies within this session's base snapshot.
Arguments.
declaration: Declaration index to test.
Returns. True when declared in the base snapshot.
Raises.
LibError:KERNELfor an unreadable workspace.
Session.fact¶
Mojo
def fact(self, name: String) raises LibError -> Fact
Python
def fact(self, name)
Look up a registered or snapshot fact by name.
Arguments.
name: Fact name.
Returns. The fact handle.
Raises.
LibError:NO_MATCHfor an unknown name;KERNELfor a stale one; whatsnapshot_factraises.
Session.require_expression_signature¶
Mojo
def require_expression_signature(self, frame: Frame, expression: Expr) raises LibError
Python
def require_expression_signature(self, frame, expression)
Verify that expression is valid under frame's canonical signature.
Arguments.
frame: Target frame.expression: Expression to check.
Raises.
LibError: SHAPE for a later signature, WRONG_KERNEL for a foreign handle, KERNEL for stale or unreadable rows, or LIMIT for exhausted work.
Session.equal_at¶
Mojo
def equal_at(self, frame: Frame, left: Expr, right: Expr) raises LibError -> Expr
Python
def equal_at(self, frame, left, right)
Construct an equality left = right at frame's canonical signature.
Arguments.
frame: Authenticated frame.left: Left-hand expression.right: Right-hand expression.
Returns. The checked equality proposition.
Raises.
LibError: On type/signature mismatch or exhaustion.
Session.apply_at¶
Mojo
def apply_at(self, frame: Frame, function: Expr, arguments: List[Expr]) raises LibError -> Expr
Python
def apply_at(self, frame, function, arguments)
Construct an application at frame's canonical signature.
Arguments.
frame: Authenticated frame.function: Function expression.arguments: Argument expressions.
Returns. The checked application expression.
Raises.
LibError: On type/signature mismatch or exhaustion.
Session.lambda_at¶
Mojo
def lambda_at(self, frame: Frame, variable: Expr, body: Expr) raises LibError -> Expr
Python
def lambda_at(self, frame, variable, body)
Abstract variable over body at frame's canonical signature.
Arguments.
frame: Authenticated frame.variable: Bound variable expression.body: Lambda body expression.
Returns. The checked lambda expression.
Raises.
LibError: On invalid variable, signature mismatch, or exhaustion.
Session.replace_positions_at¶
Mojo
def replace_positions_at(self, frame: Frame, source: Expr, original: Expr, replacement: Expr, positions: List[List[Int]]) raises LibError -> Expr
Python
def replace_positions_at(self, frame, source, original, replacement, positions)
Replace occurrences of original by replacement at canonical paths of source under frame.
Interprets every path on source's original canonical node (including under binders), rejects
negative, duplicate, overlapping, out-of-bounds, and type-slot paths, checks that each selected
occurrence equals original exactly (rejecting bound-open occurrences), preserves distinct
occurrences of shared subterms, rebuilds under frame's canonical signature using checked kernel
constructors, and retains authored hidden-parameter provenance from the inputs.
Arguments.
frame: Authenticated occurrence frame.source: Canonical source expression.original: Closed term expected at every selected occurrence.replacement: Replacement term of the same type.positions: Distinct, nonoverlapping canonical slot paths.
Returns. Rebuilt expression at frame's canonical signature.
Raises.
LibError:WRONG_KERNELfor foreign handles;KERNELfor stale handles, scope violations, or mismatched replacement types;SHAPEfor invalid/overlapping/non-matching paths, non-canonical source, or unavailable declarations/signatures;LIMITon exhaustion.
Session.root¶
Mojo
def root(self) raises LibError -> Frame
Python
def root(self)
Unconditional empty root frame rebased to the current theory.
Used explicitly for theorem construction and export even when a session has selected a default frame with ambient hypotheses (e.g. Scalar's finite hypotheses).
Returns. The empty root frame.
Raises.
LibError:SHAPEfor a closed session;KERNELfor a refused row;LIMIT.
Session.select_default_frame¶
Mojo
def select_default_frame(self, frame: Frame) raises LibError
Python
def select_default_frame(self, frame)
Nominate a checked frame as the default returned by base().
Preserves the order and exact identities of the frame's hypotheses across ordinary theory extensions,
checkpoints/restores, retained transaction commits, and fork/merge. root() remains the explicit
unconditional empty root for theorem construction and export.
Arguments.
frame: Live checked frame at the current canonical signature.
Raises.
LibError:WRONG_KERNELfor a foreign frame;KERNELfor a stale frame;SHAPEfor a closed session or a frame from another canonical signature;LIMITon exhaustion (leaving the selection unchanged).
Session.base¶
Mojo
def base(self) raises LibError -> Frame
Python
def base(self)
Default base frame (selected default frame if nominated, else root()).
It is not the engine's top, which carries the fix frames of bound_var and variable and the rebases of
declarations: on an ordinary session, a derivation over base() cites none of them and exports cleanly.
Returns. The base frame.
Raises.
LibError:SHAPEif the canonical signature changed after a default frame was selected, or if the session is closed;KERNELfor a refused row;LIMIT.
Session.fix¶
Mojo
def fix(self, frame: Frame, name: String, kind: TypeExpr) raises LibError -> Tuple[Frame, Expr]
Python
def fix(self, frame, name, kind)
Extend a frame with a fixed variable, or return the variable this session fixed with that name, frame and type.
The variable is a local over frame, distinct from every variable the session records over it: its
key is (frame, type, variant(name)), and name is its label. A second call with the same name, frame and
type returns the frame and the expression of the first.
Arguments.
frame: Parent frame.name: The variable's name: one the session has not used, or one it fixed overframeatkind.kind: Variable type.
Returns. (extended_frame, variable_expr).
Raises.
LibError:SHAPEfor a reserved name (one that begins with·) or a name the session used for another variable;KERNELfor a stale handle or a refused row;LIMIT.
Session.assume¶
Mojo
def assume(self, frame: Frame, proposition: Expr, name: String = "") raises LibError -> Frame
Python
def assume(self, frame, proposition, name='')
Extend a frame with an assumption.
Arguments.
frame: Parent frame.proposition: Assumed proposition.name: Optional display label.
Returns. The assumption frame.
Raises.
LibError:KERNELfor a term that is not a proposition, a stale handle or a refused row;LIMIT.
Session.register_claim¶
Mojo
def register_claim(self, frame: Frame, proposition: Expr, query: String, decider: String, version: String) raises LibError
Python
def register_claim(self, frame, proposition, query, decider, version)
Record an external decider claim at frame for proposition.
Arguments.
frame: Frame at which the claim holds.proposition: Claimed proposition.query: Decider query string.decider: Decider identifier.version: Decider version string.
Raises.
LibError:SHAPEfor another frame or another proposition than the frame's assumption;FORMATfor a claim of the same decider on the frame with another query or version;KERNELfor a stale handle;WRONG_KERNELfor another session's;LIMIT. Failure leaves the table as it was.
Session.hypothesis¶
Mojo
def hypothesis(self, assumed: Frame) raises LibError -> Step
Python
def hypothesis(self, assumed)
Read the hypothesis step introduced by an assumption frame.
Arguments.
assumed: Assumption frame.
Returns. Checked hypothesis step.
Raises.
LibError:SHAPEfor another frame;KERNELfor a stale handle, a frame that does not extend the assumption's, or a refused row;LIMIT.
Session.hypothesis¶
Mojo
def hypothesis(self, assumed: Frame, at: Frame) raises LibError -> Step
Python
def hypothesis(self, assumed, at)
Read an assumption frame's hypothesis at an extending frame.
Arguments.
assumed: Assumption frame.at: Extending frame.
Returns. Checked hypothesis step at at.
Raises.
LibError:SHAPEfor another frame;KERNELfor a stale handle, a frame that does not extend the assumption's, or a refused row;LIMIT.
Session.truth¶
Mojo
def truth(self, frame: Frame) raises LibError -> Step
Python
def truth(self, frame)
Prove True at a frame.
Arguments.
frame: Target frame.
Returns. Checked step concluding True.
Raises.
LibError:KERNELfor a stale handle or a refused row;LIMIT.
Session.imp_intro¶
Mojo
def imp_intro(self, frame: Frame, step: Step) raises LibError -> Step
Python
def imp_intro(self, frame, step)
Discharge an assumption frame into an implication.
Arguments.
frame: Assumption frame.step: Consequent step.
Returns. Checked implication step.
Raises.
LibError:SHAPEfor another frame;KERNELfor a stale handle or a refused row;LIMIT.
Session.imp_elim¶
Mojo
def imp_elim(self, implication: Step, antecedent: Step) raises LibError -> Step
Python
def imp_elim(self, implication, antecedent)
Apply modus ponens.
Arguments.
implication:φ → ψ.antecedent:φ.
Returns. ψ.
Raises.
LibError:SHAPEfor an implication not authored as one;KERNELfor a stale handle or a refused row;LIMIT.
Session.and_intro¶
Mojo
def and_intro(self, left: Step, right: Step) raises LibError -> Step
Python
def and_intro(self, left, right)
Introduce a conjunction.
Arguments.
left:φ.right:ψ.
Returns. φ ∧ ψ.
Raises.
LibError:KERNELfor a stale handle or a refused row;LIMIT.
Session.and_left¶
Mojo
def and_left(self, step: Step) raises LibError -> Step
Python
def and_left(self, step)
Project the left conjunct.
Arguments.
step:φ ∧ ψ.
Returns. φ.
Raises.
LibError:SHAPEfor a step not authored as a conjunction;KERNELfor a stale handle or a refused row;LIMIT.
Session.and_right¶
Mojo
def and_right(self, step: Step) raises LibError -> Step
Python
def and_right(self, step)
Project the right conjunct.
Arguments.
step:φ ∧ ψ.
Returns. ψ.
Raises.
LibError:SHAPEfor a step not authored as a conjunction;KERNELfor a stale handle or a refused row;LIMIT.
Session.or_left¶
Mojo
def or_left(self, step: Step, right: Expr) raises LibError -> Step
Python
def or_left(self, step, right)
Introduce a disjunction on the left.
Arguments.
step:φ.right:ψ.
Returns. φ ∨ ψ.
Raises.
LibError:KERNELfor a stale handle or a refused row (ψnot a proposition);LIMIT.
Session.or_right¶
Mojo
def or_right(self, left: Expr, step: Step) raises LibError -> Step
Python
def or_right(self, left, step)
Introduce a disjunction on the right.
Arguments.
left:φ.step:ψ.
Returns. φ ∨ ψ.
Raises.
LibError:KERNELfor a stale handle or a refused row (φnot a proposition);LIMIT.
Session.or_elim¶
Mojo
def or_elim(self, disjunction: Step, left: Step, right: Step) raises LibError -> Step
Python
def or_elim(self, disjunction, left, right)
Eliminate a disjunction using two implications.
Arguments.
disjunction:φ ∨ ψ.left:φ → χ.right:ψ → χ.
Returns. χ.
Raises.
LibError:SHAPEfor a left case not authored as an implication;KERNELfor a stale handle or a refused row;LIMIT.
Session.false_elim¶
Mojo
def false_elim(self, falsehood: Step, proposition: Expr) raises LibError -> Step
Python
def false_elim(self, falsehood, proposition)
Derive any proposition from False.
Arguments.
falsehood:False.proposition: Target proposition.
Returns. Checked step concluding proposition.
Raises.
LibError:KERNELfor a stale handle or a refused row (a premise that is notFalse, a target that is not a proposition);LIMIT.
Session.eq_refl¶
Mojo
def eq_refl(self, frame: Frame, term: Expr) raises LibError -> Step
Python
def eq_refl(self, frame, term)
Prove term = term at a frame.
Arguments.
frame: Target frame.term: Expression.
Returns. Reflexivity step.
Raises.
LibError:SHAPEfor a term authored at a later canonical signature,KERNELfor a stale handle or a refused row, orLIMITwhen the allowance is exhausted.
Session.eq_sym¶
Mojo
def eq_sym(self, step: Step) raises LibError -> Step
Python
def eq_sym(self, step)
Reverse an equality step.
Arguments.
step:a = b.
Returns. b = a.
Raises.
LibError:SHAPEfor a step not authored as an equation;KERNELfor a stale handle or a refused row;LIMIT.
Session.eq_trans¶
Mojo
def eq_trans(self, first: Step, second: Step) raises LibError -> Step
Python
def eq_trans(self, first, second)
Compose two equalities transitively.
Arguments.
first:a = b.second:b = c.
Returns. a = c.
Raises.
LibError:SHAPEfor a step not authored as an equation;KERNELfor a stale handle or a refused row (middle terms that differ);LIMIT.
Session.congruence¶
Mojo
def congruence(self, function: Step, arguments: List[Step]) raises LibError -> Step
Python
def congruence(self, function, arguments)
Apply equality congruence across a function and argument equalities.
Arguments.
function:f = g.arguments:[a_1 = b_1, ...].
Returns. f(a_1, ...) = g(b_1, ...).
Raises.
LibError:SHAPEfor a step not authored as an equation;KERNELfor a stale handle or a refused row (an argument of the wrong type);LIMIT.
Session.eq_subst¶
Mojo
def eq_subst(self, predicate: Expr, equation: Step, premise: Step) raises LibError -> Step
Python
def eq_subst(self, predicate, equation, premise)
Substitute along an equality through a lambda motive.
Arguments.
predicate: Lambda motiveλx. φ.equation:a = b.premise:φ[a/x].
Returns. φ[b/x]. For a lambda motive it is authored as the substituted body, so that a step reading the statement's connective (eq_sym, and_left, …) applies to it; for any other predicate P, and for an instance a binder of φ would capture, it is authored as the application P b.
Raises.
LibError:SHAPEfor an equation not authored as one;KERNELfor a stale handle or a refused row (a premise other thanP a, a predicate of the wrong type);LIMIT.
Session.eq_abstract¶
Mojo
def eq_abstract(self, frame: Frame, step: Step) raises LibError -> Step
Python
def eq_abstract(self, frame, step)
Abstract an equality over a fixed variable frame.
Arguments.
frame: Fix frame.step:a = b.
Returns. (λx. a) = (λx. b).
Raises.
LibError:SHAPEfor another frame or a step not authored as an equation;KERNELfor a stale handle or a refused row (the eigenvariable condition);LIMIT.
Session.lift¶
Mojo
def lift(self, step: Step) raises LibError -> Step
Python
def lift(self, step)
Lift a checked step to the current theory signature at its frame.
Arguments.
step: Checked step.
Returns. The lifted step.
Raises.
LibError:KERNELfor a stale handle or a refused row;LIMIT.
Session.lift_to¶
Mojo
def lift_to(self, step: Step, target: Frame) raises LibError -> Step
Python
def lift_to(self, step, target)
Lift a step into an extending frame.
Arguments.
step: Checked step.target: Extending frame.
Returns. Checked step at target.
Raises.
LibError: SHAPE for an inaccessible premise, WRONG_KERNEL for a foreign handle, KERNEL for a stale handle or refused inference, or LIMIT for exhausted work.
Session.convert¶
Mojo
def convert(self, step: Step, target: Expr, unfold: List[Expr] = List[Expr]()) raises LibError -> Step
Python
def convert(self, step, target, unfold=[])
Convert a step to a definitionally equal target proposition.
Arguments.
step: Checked step.target: Target proposition.unfold: Transparent definitions to unfold.
Returns. Checked step concluding target.
Raises.
LibError:SHAPEfor an unfolding entry that is not a defined constant;KERNELfor a stale handle or a refused row (terms that do not convert, a definition that is not transparent);LIMIT.
Session.use¶
Mojo
def use(self, frame: Frame, fact: Fact, terms: List[Expr] = List[Expr](), type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Step
Python
def use(self, frame, fact, terms=[], type_args=[])
Instantiate a fact at a frame with optional type and leading universal term arguments.
The type arguments instantiate the fact's own parameters, in its declaration's order: the type variables of
its statement in order of first occurrence (Definition S-3), or, for an instance definition, those of its
type arguments, not the overloaded constant's. Authoring does not check sorts: a τ outside its parameter's
sort is refused by the row (KERNEL, admissibility, Definition Y-11).
A class-level fact used at a type its declaration does not apply to (an ACU operator at a function type,
K2.9) concludes its stored normal form instantiated, which can order the operands otherwise than the authored
statement does at that type. The step's statement is then the conclusion authored, with the terms as written
and each remaining universal named x·k.
Arguments.
frame: Target frame.fact: Fact handle.terms: Term arguments for leading universals.type_args: Type arguments in header order.
Returns. Checked step.
Raises.
LibError:UNSUPPORTEDfor a statement the session cannot author (a snapshot's or a statement-only import's is authored when first needed), a later part (a law: cite it), or a conclusion the session cannot author;SHAPEfor more terms than authored universals, another number of type arguments than the fact's parameters, or a statement whose fixed variable's type mentions a parameter;KERNELfor a stale handle or a refused row (an instance of the wrong type or outside a sort, a polymorphic fact used without type arguments);LIMIT.
Session.transport¶
Mojo
def transport(self, step: Step, target: Frame, locals: List[Tuple[Frame, Expr]], hypotheses: List[Tuple[Frame, Step]]) raises LibError -> Step
Python
def transport(self, step, target, locals, hypotheses)
Transport a checked step into target by substituting its locals and hypotheses.
Arguments.
step: Source checked step.target: Target frame.locals: Pairs of source fix frame and replacement expression.hypotheses: Pairs of source assumption frame and justifying step.
Returns. The transported checked step at target.
Raises.
LibError:SHAPEfor a frame of the wrong kind;KERNELfor a stale handle or a refused row (a variable or an assumption used and not mapped, a judgment of another proposition);LIMIT.
Session.discharge¶
Mojo
def discharge(self, step: Step, frames: List[Frame]) raises LibError -> Step
Python
def discharge(self, step, frames)
Discharge a suffix of assumption and fix frames.
Arguments.
step: Checked step.frames: Frames to discharge, innermost first.
Returns. Discharged step.
Raises.
LibError:SHAPEfor frames that are not the step's chain;KERNELfor a stale handle or a refused row (a variable a kept assumption mentions);LIMIT.
Session.forall_intro¶
Mojo
def forall_intro(self, frame: Frame, step: Step) raises LibError -> Step
Python
def forall_intro(self, frame, step)
Generalize a fixed variable frame into a universal quantifier.
Arguments.
frame: Fix frame.step: Body step.
Returns. Universal step.
Raises.
LibError:SHAPEfor another frame;KERNELfor a stale handle or a refused row;LIMIT.
Session.forall_elim¶
Mojo
def forall_elim(self, step: Step, term: Expr) raises LibError -> Step
Python
def forall_elim(self, step, term)
Instantiate a leading universal quantifier at a term.
Arguments.
step: Universal step.term: Instance term.
Returns. Instantiated step.
Raises.
LibError:SHAPEfor a step not authored as a universal, or an instance that the statement's binders would capture;KERNELfor a stale handle or a refused row;LIMIT.
Session.refl¶
Mojo
def refl(self, term: Expr) raises LibError -> Step
Python
def refl(self, term)
Prove ⊢ term = term as a sequent step.
Arguments.
term: Expression to relate to itself.
Returns. The checked reflexivity step.
Raises.
LibError:KERNELfor a stale handle or a refused row;LIMIT.
Session.sequent_assume¶
Mojo
def sequent_assume(self, proposition: Expr) raises LibError -> Step
Python
def sequent_assume(self, proposition)
Prove proposition ⊢ proposition as a sequent step.
Arguments.
proposition: Proposition to assume.
Returns. The checked assumption step.
Raises.
LibError:KERNELfor a term that is not a proposition, a stale handle or a refused row;LIMIT.
Session.sym¶
Mojo
def sym(self, step: Step) raises LibError -> Step
Python
def sym(self, step)
Reverse an equality step Γ ⊢ a = b to Γ ⊢ b = a.
Arguments.
step: Checked equality step.
Returns. The reversed equality step.
Raises.
LibError:SHAPEfor a step not authored as an equation;KERNELfor a stale handle or a refused row;LIMIT.
Session.trans¶
Mojo
def trans(self, first: Step, second: Step) raises LibError -> Step
Python
def trans(self, first, second)
Chain Γ ⊢ a = b and Δ ⊢ b = c into Γ ∪ Δ ⊢ a = c.
Arguments.
first: First equality step.second: Second equality step.
Returns. The transitive equality step.
Raises.
LibError:SHAPEfor a step not authored as an equation;KERNELfor a stale handle or a refused row;LIMIT.
Session.eq_mp¶
Mojo
def eq_mp(self, equation: Step, premise: Step) raises LibError -> Step
Python
def eq_mp(self, equation, premise)
Apply propositional equality Γ ⊢ P = Q to Δ ⊢ P yielding Γ ∪ Δ ⊢ Q.
Arguments.
equation: Checked propositional equality step.premise: Checked premise step.
Returns. The derived step concluding Q.
Raises.
LibError:SHAPEfor a step not authored as an equation;KERNELfor a stale handle or a refused row;LIMIT.
Session.abs_thm¶
Mojo
def abs_thm(self, variable: Expr, step: Step) raises LibError -> Step
Python
def abs_thm(self, variable, step)
Abstract variable over both sides of an equality step.
Arguments.
variable: Local variable not free in the step's hypotheses.step: Checked equality step.
Returns. The abstracted equality step.
Raises.
LibError:SHAPEfor a step not authored as an equation or a term that is no variable;KERNELfor a stale handle or a refused row (xfree in a hypothesis);LIMIT.
Session.app_thm¶
Mojo
def app_thm(self, function: Step, argument: Step) raises LibError -> Step
Python
def app_thm(self, function, argument)
Combine Γ ⊢ f = g and Δ ⊢ x = y into Γ ∪ Δ ⊢ f x = g y.
Arguments.
function: Function equality step.argument: Argument equality step.
Returns. The application congruence step.
Raises.
LibError:SHAPEfor a step not authored as an equation, or a conclusion the kernel normalizes away from the authored one;KERNELfor a stale handle or a refused row;LIMIT.
Session.deduct_antisym¶
Mojo
def deduct_antisym(self, first: Step, second: Step) raises LibError -> Step
Python
def deduct_antisym(self, first, second)
Derive propositional equality P = Q from mutual deductions Γ, P ⊢ Q and Δ, Q ⊢ P.
Arguments.
first: First deduction step.second: Second deduction step.
Returns. The checked propositional equality step.
Raises.
LibError:KERNELfor a stale handle or a refused row;LIMIT.
Session.prove_hyp¶
Mojo
def prove_hyp(self, first: Step, second: Step) raises LibError -> Step
Python
def prove_hyp(self, first, second)
Cut a proven premise Γ ⊢ P into Δ ⊢ Q eliminating hypothesis P.
Arguments.
first: Proof of the hypothesis.second: Step possibly depending on that hypothesis.
Returns. The cut step.
Raises.
LibError:KERNELfor a stale handle or a refused row;LIMIT.
Session.axiom¶
Mojo
def axiom(self, name: String, proposition: Expr, *, header_params: Optional[List[TypeExpr]] = None) raises LibError -> Fact
Python
def axiom(self, name, proposition, *, header_params=None)
Declare an axiom with a closed proposition.
Arguments.
name: Fresh axiom name.proposition: Closed proposition.header_params: Optional explicit type parameter order.
Returns. The axiom fact.
Raises.
LibError:SHAPE, before anything is built, for a used name, a term that is not a proposition, or a proposition that is not closed;KERNELfor a stale handle or a refused row;LIMIT.
Session.profile_axiom¶
Mojo
def profile_axiom(self, name: String, proposition: Expr, *, header_params: Optional[List[TypeExpr]] = None) raises LibError -> Fact
Python
def profile_axiom(self, name, proposition, *, header_params=None)
Declare an axiom of a semantic profile: axiom, with its dependency class recorded as PROFILE_AXIOM.
The row, the checks and the refusals are axiom's. The class lives in the session's provenance table, so a
rollback, checkout or discarded transaction that drops the axiom drops it, and forks, merges and seals keep
it; a session opened over the sealed snapshot classifies the axiom the same way.
Profile builders (Scalar's axioms and classical principles) call it; an axiom declared with axiom stays
UNCLASSIFIED. The class goes with the declaration: a rollback that drops the axiom drops it, and forks,
merges, seals and sessions opened over the sealed snapshot keep it.
Arguments.
name: Fresh axiom name.proposition: Closed proposition.header_params: Optional explicit type parameter order.
Returns. The axiom fact.
Raises.
LibError: Asaxiom: on invalid name, open/ill-typed proposition, or exhaustion.
Session.definition_equation¶
Mojo
def definition_equation(self, symbol: Expr) raises LibError -> Step
Python
def definition_equation(self, symbol)
Read the checked defining equation of a defined constant expression.
Arguments.
symbol: Defined constant expression (possibly instantiated at type arguments).
Returns. The checked defining equation step.
Raises.
LibError: SHAPE for another form, WRONG_KERNEL for another session, KERNEL for a stale handle or refused proof, UNSUPPORTED for an unreadable snapshot body, or LIMIT on exhaustion.
Session.prove_step¶
Mojo
def prove_step(self, name: String, step: Step, *, keep_evidence: Bool = False) raises LibError -> Fact
Python
def prove_step(self, name, step, *, keep_evidence=False)
Publish a closed checked step as a named proven theorem.
Arguments.
name: Fresh theorem name.step: Closed checked step.keep_evidence: Retain captured judgment alongside publication.
Returns. The proven fact.
Raises.
LibError:SHAPEfor a used name, a local step or one with hypotheses;KERNELfor a stale handle or a refused row;LIMIT.
Session.cite¶
Mojo
def cite(self, fact: Fact, type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Step
Python
def cite(self, fact, type_args=[])
Cite a fact as a checked step.
An explicitly declared header supplies the type argument order, including unused parameters. Otherwise the
order is first occurrence in the statement (Definition S-3). Subset laws use the subset constructor's header;
specification laws use the witness's header.
The instance is an inst row of the cited row (a type definition's law: of its open row, then restated closed
through convert), and its statement the authored one at the types (_substitute_types). A type outside a
parameter's sort is refused by the inst row (admissibility, Definition Y-11).
Arguments.
fact: Fact handle.type_args: Explicit type arguments.
Returns. Checked step.
Raises.
LibError:UNSUPPORTEDfor a snapshot's or a statement-only import's statement the session cannot author (a let; either is authored when first needed);SHAPEfor another number of type arguments than parameters;KERNELfor a stale handle or a refused row (a type outside a sort);WRONG_KERNELfor another session's type;LIMIT.
Session.type_var¶
Mojo
def type_var(self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Construct a type variable with an optional class sort.
A type variable is its name and sort: the same name and sort give the same variable. Statements are keyed up to renaming their type variables (Definition I-5), so the name chosen changes no identity.
Arguments.
name: Variable name.sort: Class constraints.
Returns. The type variable.
Raises.
LibError:SHAPEfor an empty name;KERNELfor a stale class;WRONG_KERNELfor another session's;LIMIT.
Session.class_¶
Mojo
def class_(self, name: String) raises LibError -> ClassBuilder
Python
def class_(self, name)
Start a type-class declaration.
Arguments.
name: Fresh class name.
Returns. A class builder whose parameter returns Constant.
Raises.
LibError:SHAPEfor an empty name or a merged fork.
Session.import_class¶
Mojo
def import_class(self, name: String) raises LibError -> Class
Python
def import_class(self, name)
Import a class declared in the snapshot or earlier imports by name.
Arguments.
name: Class name.
Returns. The class handle.
Raises.
LibError:NO_MATCHfor an unknown name;SHAPEfor a name that is not a class's;LIMIT.
Session.of_class¶
Mojo
def of_class(self, kind: TypeExpr, class_: Class) raises LibError -> Step
Python
def of_class(self, kind, class_)
Prove class(TYPE[kind]) using the session's checked instance declarations.
Arguments.
kind: Type to check membership for.class_: Target class.
Returns. Checked membership step.
Raises.
LibError:KERNELfor a type not of the class (the kernel's side condition), a stale handle or a refused row;WRONG_KERNELfor another session's handle;LIMIT.
Session.import_constructor¶
Mojo
def import_constructor(self, name: String) raises LibError -> TypeConstructor
Python
def import_constructor(self, name)
Import a type constructor declared in the snapshot or earlier imports.
Lookup uses the checked theory's declaration namespace (K1.3), not its type-operator aliases. It declares nothing. Display text never supplies type identity (LG1).
Arguments.
name: Constructor name.
Returns. The type constructor handle.
Raises.
LibError:NO_MATCHfor an absent declaration;SHAPEfor another kind or a closed session;UNSUPPORTEDfor an unsafe display label;KERNELfor unreadable storage;LIMIT.
Session.import_type_constructor¶
Mojo
def import_type_constructor(self, name: String) raises LibError -> TypeConstructor
Python
def import_type_constructor(self, name)
Look up a type constructor of this session by name.
A snapshot's constructor is issued at generation 0, valid whatever the session's transactions do; one the session or an import declared has the session's generation.
Arguments.
name: Qualified type constructor name.
Returns. The checked type constructor handle.
Raises.
LibError:NO_MATCHfor an unknown name;SHAPEforProp, a built-in constructor or a closed session;KERNELfor an unreadable workspace;LIMIT.
Session.type_constructor¶
Mojo
def type_constructor(self, name: String, arity: Int) raises LibError -> TypeConstructor
Python
def type_constructor(self, name, arity)
Declare a type constructor of given arity.
Arguments.
name: Fresh type constructor name.arity: Number of type parameters.
Returns. The type constructor handle.
Raises.
LibError:SHAPEfor an arity out of range, an empty name orProp;KERNELfor a used name or a refused row;LIMIT.
Session.instance¶
Mojo
def instance(self, constructor: TypeConstructor, argument_sorts: List[List[Class]], class_: Class, witness: Fact) raises LibError
Python
def instance(self, constructor, argument_sorts, class_, witness)
Declare a parametric class instance for a type constructor.
Arguments.
constructor: Type constructor.argument_sorts: Required class sort per type argument.class_: Target class.witness: Checked membership witness fact.
Raises.
LibError:KERNELfor another statement, a wrong number of sorts, an arity that adds no membership, arities no longer coregular (Definition Y-9), a stale handle or a refused row;WRONG_KERNELfor another session's handle;LIMIT. Failure leaves the session as it was.
Session.instance¶
Mojo
def instance(self, kind: TypeExpr, class_: Class, witness: Fact) raises LibError
Python
def instance(self, kind, class_, witness)
Declare a ground class instance for a concrete type.
Arguments.
kind: Concrete type.class_: Target class.witness: Checked membership witness fact.
Raises.
LibError:SHAPEfor a type that is not a declared type without arguments; otherwise as the constructor form.
Session.class_relation¶
Mojo
def class_relation(self, sub: Class, super_: Class, witness: Fact) raises LibError
Python
def class_relation(self, sub, super_, witness)
Declare a derived subclass relation between two classes.
Arguments.
sub: Subclass.super_: Superclass.witness: Checked implication witness fact.
Raises.
LibError:KERNELfor another statement, a cycle, arities no longer coregular, a stale handle or a refused row;WRONG_KERNELfor another session's handle;LIMIT. Failure leaves the session as it was.
Session.instance_definition¶
Mojo
def instance_definition(self, constant: Expr, type_args: List[TypeExpr], body: Expr) raises LibError -> Fact
Python
def instance_definition(self, constant, type_args, body)
Define an instance of an overloaded constant at explicit types.
Type arguments with type variables give a generic instance definition, over those variables (as
InstanceDefinitionBuilder makes); the body's type variables must be among them.
Arguments.
constant: Overloaded constant expression.type_args: Target type arguments.body: Defining body expression.
Returns. The checked instance equation fact.
Raises.
LibError:SHAPEfor an expression that is not an overloaded constant at its declared type (an applied one, or an instanceop[τ]), another number of type arguments, or a body that is not closed;KERNELfor an overlapping instance definition, a body of another type or with another type variable, a stale handle or a refused row;WRONG_KERNELfor another session's handle;LIMIT. Failure leaves the session as it was.
Session.specification¶
Mojo
def specification(self, names: List[String], witness: Fact) raises LibError -> Specification
Python
def specification(self, names, witness)
Declare constants by existential specification from a checked witness.
Arguments.
names: Fresh constant names matching the existential binders.witness: Checked existential fact.
Returns. The specification handle.
Raises.
LibError:SHAPEfor no names, an empty or repeated name,Prop, or a witness not authored with k leading universals and k antecedents;UNSUPPORTEDfor a witness without an authored statement, or one that is itself a declaration's later part (a law), which the kernel might accept, for now;KERNELfor a used name, a witness of another form, a stale handle or a refused row;WRONG_KERNELfor another session's witness;LIMIT. Failure leaves the session as it was.
Session.subset¶
Mojo
def subset(self, name: String, predicate: Expr, inhabited: Fact, abs_name: Optional[String] = None, rep_name: Optional[String] = None) raises LibError -> Subset
Python
def subset(self, name, predicate, inhabited, abs_name=None, rep_name=None)
Declare a subset type directly from a predicate and nonemptiness witness.
Arguments.
name: Fresh subset type name.predicate: Characteristic predicateP : τ -> Prop.inhabited: Checked witness∃x. P(x).abs_name: Optional abstraction constant name.rep_name: Optional representation constant name.
Returns. The subset type handle.
Raises.
LibError:SHAPEfor an empty name,Prop, a predicate that is not closed or not a predicate, empty or equal abstraction and representation names, or a name a constant already has;UNSUPPORTEDfor a predicate not authored as a λ;KERNELfor a used type name, a witness of another statement, a predicate with type variables, a stale handle or a refused row;WRONG_KERNELfor another session's handle;LIMIT. Failure leaves the session as it was.
Session.subset¶
Mojo
def subset(self, name: String, predicate: Expr, inhabited: Fact, type_params: List[TypeExpr], abs_name: Optional[String] = None, rep_name: Optional[String] = None) raises LibError -> Subset
Python
def subset(self, name, predicate, inhabited, type_params, abs_name=None, rep_name=None)
Declare a subset type with explicit type parameters from a predicate and witness.
Arguments.
name: Fresh subset type name.predicate: Characteristic predicateP : τ -> Prop.inhabited: Checked witness∃x. P(x).type_params: Ordered type parameters.abs_name: Optional abstraction constant name.rep_name: Optional representation constant name.
Returns. The subset type handle.
Raises.
LibError:SHAPEfor an empty name,Prop, a predicate that is not closed or not a predicate, empty or equal abstraction and representation names, or a name a constant already has;UNSUPPORTEDfor a predicate not authored as a λ;KERNELfor a used type name, a witness of another statement, a predicate with type variables, a stale handle or a refused row;WRONG_KERNELfor another session's handle;LIMIT. Failure leaves the session as it was.
Session.subset¶
Mojo
def subset(self, name: String) raises LibError -> SubsetBuilder
Python
def subset(self, name)
Start a generic subset type builder.
Arguments.
name: Fresh subset type name.
Returns. A subset builder.
Raises.
LibError:SHAPEfor an empty name orProp.
Session.instance_definition¶
Mojo
def instance_definition(self, constant: Expr) raises LibError -> InstanceDefinitionBuilder
Python
def instance_definition(self, constant)
Start an instance definition builder for an overloaded constant expression.
Arguments.
constant: Overloaded constant expression at its declared type.
Returns. An instance definition builder.
Raises.
LibError:KERNELfor a stale handle;WRONG_KERNELfor another session's.
Session.define¶
Mojo
def define(self, name: String, body: Expr, transparent: Bool = True, *, header_params: Optional[List[TypeExpr]] = None) raises LibError -> Definition
Python
def define(self, name, body, transparent=True, *, header_params=None)
Define a closed constant by a body expression.
Arguments.
name: Fresh constant name.body: Closed defining expression.transparent: Whether explicit conversion may unfold this definition.header_params: Optional explicit type parameter order.
Returns. The definition handle.
Raises.
LibError:SHAPEfor a used name or a body that is not closed;KERNELfor a stale handle or a refused row;LIMIT.
Session.acu_operator¶
Mojo
def acu_operator(self, operator: Expr, unit: Optional[Expr], associativity: Fact, commutativity: Fact, identity: Optional[Fact] = None) raises LibError -> Declaration
Python
def acu_operator(self, operator, unit, associativity, commutativity, identity=None)
Register an associative-commutative(-unital) canonical operator.
Arguments.
operator: Binary operator expression.unit: Optional identity element.associativity: Checked associativity fact.commutativity: Checked commutativity fact.identity: Optional checked identity fact.
Returns. The ACU registration declaration handle.
Raises.
LibError:SHAPEfor a unit without its law or a law without its unit, or a law that is a part of a declaration (a specification's or a type definition's law);KERNELfor a stale or foreign handle, or a declaration the kernel refuses (a law of another statement, an operator that is not an instance);LIMIT.
Session.literal_kind¶
Mojo
def literal_kind(self, name: String, implementation: LiteralImpl, carrier: TypeExpr, domain: Optional[Expr], bindings: List[Tuple[LiteralOp, Expr]], laws: List[Tuple[LiteralLaw, Fact]], base: Optional[Declaration] = None) raises LibError -> Declaration
Python
def literal_kind(self, name, implementation, carrier, domain, bindings, laws, base=None)
Declare a checked literal kind on a carrier type.
Arguments.
name: Fresh kind name.implementation: Kernel literal implementation.carrier: Carrier type.domain: Optional domain predicate.bindings: Operation bindings.laws: Checked law facts.base: Optional base literal kind for polynomials.
Returns. The literal-kind declaration handle.
Raises.
LibError:SHAPEfor a law that does not exist or a law that is a part of a declaration;KERNELfor a stale or foreign handle, or a kind the kernel refuses (a missing or wrong law, a binding of another type);LIMIT.
Session.literal_kind_named¶
Mojo
def literal_kind_named(self, name: String) raises LibError -> Declaration
Python
def literal_kind_named(self, name)
Look up a registered literal kind declaration by name.
The handle is the kind's declaration row, valid while the row is (G6); literal takes it. A session reopened
over a sealed snapshot finds its kinds this way, as import_fact finds its facts.
Arguments.
name: Registered literal kind name.
Returns. The checked literal kind declaration handle.
Raises.
LibError:NO_MATCHfor a name no literal kind the session sees has;SHAPEfor a closed session;KERNELfor an unreadable workspace;LIMIT.
Session.literal¶
Mojo
def literal(self, kind: Declaration, value: LiteralValue) raises LibError -> Expr
Python
def literal(self, kind, value)
Construct a checked literal expression.
Arguments.
kind: Literal-kind declaration handle.value: Literal value.
Returns. The literal expression.
Raises.
LibError:SHAPEfor a declaration that is not a literal kind or a value of another form;KERNELfor a stale or foreign handle;LIMIT.
Session.transaction¶
Mojo
def transaction(self) raises LibError -> Transaction
Python
def transaction(self)
Open a nested transaction scope.
Returns. The transaction handle.
Raises.
LibError:KERNELwhen the workspace refuses a child;LIMIT.
Session.snapshot¶
Mojo
def snapshot(self) raises LibError -> TheorySnapshot
Python
def snapshot(self)
Take a lightweight rollback snapshot of the current session state.
Every row built so far is decided and checked first, so the snapshot lies at the verified end of the workspace.
Returns. The theory snapshot.
Raises.
LibError:SHAPEwhile a transaction is open or for a merged fork;LIMITwhen the allowance cannot pay for copying the tables (one unit per entry);KERNELwhen the kernel refuses a row built so far.
Session.checkout¶
Mojo
def checkout(self, snapshot: TheorySnapshot) raises LibError
Python
def checkout(self, snapshot)
Return to an earlier snapshot, charging rollback work.
Arguments.
snapshot: Snapshot taken from this session.
Raises.
LibError:WRONG_KERNELfor another session's snapshot;SHAPEwhile a transaction is open, when a fork was made after the snapshot (its rows lie over the snapshot's; this holds even once that fork is merged or dropped, since forks are counted, not tracked) or for a merged fork;KERNELfor a stale snapshot, one a later return went below, or a truncation the workspace refuses;LIMITwhen the allowance cannot pay for copying the tables back, before anything changes.
Session.rollback¶
Mojo
def rollback(self, snapshot: TheorySnapshot) raises LibError
Python
def rollback(self, snapshot)
Return to an earlier snapshot without charging rollback work.
Arguments.
snapshot: Snapshot taken from this session.
Raises.
LibError: On invalid snapshot, open transaction, or later fork.
Session.merge¶
Mojo
def merge(self, fork: Self) raises LibError
Python
def merge(self, fork)
Merge a forked child session back into this session.
This session must not have declared or made a variable since the fork, so that the fork's theory and frame chain extend this session's.
Arguments.
fork: A live fork of this session.
Raises.
LibError:SHAPEfor a session that is not this session's fork, a merged fork, a transaction open in either session, a declaration or a variable this session made since the fork, or a variable name both made since the fork;FORMATfor a claim the two sessions registered differently on a frame from before the fork;LIMITwhen the allowance cannot pay for the merge, before anything changes;KERNELwhen the kernel refuses a row of the fork or the workspace refuses the commit. Decided after the fork's rows are committed (D11):SHAPEfor a variable the fork recorded that is one this session recorded since the fork (the same binding site, also when it is the same variable, such as one copy made in two sibling forks), andFORMATfor claims of one decider on one frame that differ. These close the fork and leave this session unchanged: the committed rows are truncated before any table changes.
Session.symbol¶
Mojo
def symbol(self, name: String) raises LibError -> ConstantBuilder
Python
def symbol(self, name)
Start a generic constant declaration header.
Arguments.
name: Fresh constant name.
Returns. A constant builder accepting type_var and finish.
Raises.
LibError: On invalid/duplicate name or exhaustion.
Session.overloaded¶
Mojo
def overloaded(self, name: String) raises LibError -> ConstantBuilder
Python
def overloaded(self, name)
Start an overloaded constant declaration header.
Arguments.
name: Fresh constant name.
Returns. An overloaded constant builder accepting type_var and finish.
Raises.
LibError: On invalid/duplicate name or exhaustion.
Session.axiom¶
Mojo
def axiom(self, name: String) raises LibError -> AxiomBuilder
Python
def axiom(self, name)
Start a generic axiom header.
Arguments.
name: Fresh axiom name.
Returns. An axiom builder accepting type_var, var, given, and finish.
Raises.
LibError: On invalid/duplicate name or exhaustion.
Session.definition¶
Mojo
def definition(self, name: String, transparent: Bool = True) raises LibError -> DefinitionBuilder
Python
def definition(self, name, transparent=True)
Start a generic definition header.
Arguments.
name: Fresh definition name.transparent: Whether explicit conversion may unfold this definition.
Returns. A definition builder accepting type_var, var, and finish.
Raises.
LibError: On invalid/duplicate name or exhaustion.
Session.theorem¶
Mojo
def theorem(self, name: String) raises LibError -> _DagProof
Python
def theorem(self, name)
Start a named theorem header before declaring its goal.
Arguments.
name: Fresh theorem name.
Returns. An unfinished proof header.
Raises.
LibError: On invalid/duplicate name or exhaustion.
Session.theorem¶
Mojo
def theorem(self, name: String, target: Expr) raises LibError -> _DagProof
Python
def theorem(self, name, target)
Start a named theorem with its target proposition fixed.
Arguments.
name: Fresh theorem name.target: Goal proposition.
Returns. An unfinished proof.
Raises.
LibError: On invalid name, target, or exhaustion.
Session.lemma¶
Mojo
def lemma(self, name: String) raises LibError -> _DagProof
Python
def lemma(self, name)
Start a named lemma header before declaring its goal.
Arguments.
name: Fresh lemma name.
Returns. An unfinished proof header.
Raises.
LibError: On invalid/duplicate name or exhaustion.
Session.lemma¶
Mojo
def lemma(self, name: String, target: Expr) raises LibError -> _DagProof
Python
def lemma(self, name, target)
Start a named lemma with its target proposition fixed.
Arguments.
name: Fresh lemma name.target: Goal proposition.
Returns. An unfinished proof.
Raises.
LibError: On invalid name, target, or exhaustion.
Session.proof¶
Mojo
def proof(self) raises LibError -> _DagProof
Python
def proof(self)
Start a forward proof whose conclusion is supplied to finish.
Returns. A forward proof handle.
Raises.
LibError: On closed session or exhaustion.
Session.transform¶
Mojo
def transform(self, expression: Expr) raises LibError -> Transformation
Python
def transform(self, expression)
Start an independent checked expression transformation.
Arguments.
expression: Starting expression.
Returns. A transformation handle.
Raises.
LibError: On foreign/stale expression or exhaustion.
Session.arithmetic¶
Mojo
def arithmetic(self, kind: TypeExpr) raises LibError -> Arithmetic
Python
def arithmetic(self, kind)
Look up the bound arithmetic profile for a concrete carrier type.
Arguments.
kind: Carrier type.
Returns. The carrier's arithmetic profile.
Raises.
LibError: If unbound or on invalid type/exhaustion.
Session.arithmetic¶
Mojo
def arithmetic(self, kind: TypeExpr, zero: Expr, one: Expr, add: Expr, mul: Expr, neg: Optional[Expr] = None) raises LibError -> Arithmetic
Python
def arithmetic(self, kind, zero, one, add, mul, neg=None)
Bind arithmetic notation on a concrete carrier type.
Arguments.
kind: Concrete carrier type.zero: Additive identity.one: Multiplicative identity.add: Binary addition.mul: Binary multiplication.neg: Optional unary negation.
Returns. The carrier's arithmetic profile.
Raises.
LibError: On type mismatch, duplicate binding, or exhaustion.
Session.class_parameters¶
Mojo
def class_parameters(self, class_: Class) raises LibError -> List[Constant]
Python
def class_parameters(self, class_)
Read a class's own overloaded parameters in declaration order.
Arguments.
class_: Live class of this session.
Returns. Pinned Constant handles.
Raises.
LibError: On foreign/stale class or exhaustion.
Session.specification_symbols¶
Mojo
def specification_symbols(self, specification: Specification) raises LibError -> List[Constant]
Python
def specification_symbols(self, specification)
Read a specification's constants as pinned Constant handles in witness order.
Arguments.
specification: Live specification of this session.
Returns. Pinned Constant handles.
Raises.
LibError: On foreign/stale specification or exhaustion.
Session.instance¶
Mojo
def instance(self, kind: TypeExpr, class_: Class, witness: Step) raises LibError
Python
def instance(self, kind, class_, witness)
Declare a ground class instance from a closed checked step (such as of_class).
Arguments.
kind: Concrete type.class_: Target class.witness: Closed checked membership step.
Raises.
LibError: On open/invalid witness or exhaustion.
Session.class_relation¶
Mojo
def class_relation(self, sub: Class, super_: Class, witness: Step) raises LibError
Python
def class_relation(self, sub, super_, witness)
Declare a derived subclass relation from a closed checked step.
Arguments.
sub: Subclass.super_: Superclass.witness: Closed checked implication step.
Raises.
LibError: On open/invalid witness, cycle, or exhaustion.
Session.instance_definition¶
Mojo
def instance_definition(self, constant: Constant) raises LibError -> InstanceDefinitionBuilder
Python
def instance_definition(self, constant)
Start an instance definition builder for an overloaded Constant.
Arguments.
constant: Overloaded constant handle.
Returns. An instance definition builder.
Raises.
LibError:SHAPEif not overloaded, or handle/exhaustion errors.
Session.instance_definition¶
Mojo
def instance_definition(self, constant: Constant, type_args: List[TypeExpr], body: Expr) raises LibError -> Fact
Python
def instance_definition(self, constant, type_args, body)
Define an instance of an overloaded Constant at explicit types.
Arguments.
constant: Overloaded constant handle.type_args: Target type arguments in header order.body: Defining body expression.
Returns. The checked instance equation fact.
Raises.
LibError:SHAPEif not overloaded, or handle/exhaustion errors.
Snapshot¶
Mojo
struct Snapshot(Copyable)
Python
from judgment import Snapshot
A checked theory a session opens over: a bank's verified prefix and its profile.
Opaque: only the Store's Library and scalar.build_scalar make one, and
a session opened over it never changes it. Copies share the storage; a
seal (Session.seal) makes a new snapshot over a longer prefix of the
same bank, and the earlier one stays valid over its own prefix. It lists
its profile axioms: those its maker names and those a sealed session
declared with profile_axiom. A session opened over it classifies each
PROFILE_AXIOM (Definition E-1).
Defined in src/judgment_shell/_ws_snapshots.mojo.
Snapshot.__init__¶
Mojo
def __init__(out self, *, store: ArcPointer[_SnapshotStore], var view: _SnapshotView, marker: Optional[ProfileMarker], var aliases: Dict[String, UInt32] = Dict[String, UInt32](), var unresolved: Dict[String, String] = Dict[String, String](), var import_identity: Dict[Int, TheoremIdentity] = Dict[Int, TheoremIdentity](), import_version: Optional[TheoremIdentity] = None, var profile_axioms: List[UInt32] = List[UInt32]())
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; snapshots come from _snapshot and Session.seal.
Arguments.
store: The storage.view: The verified prefix.marker: The profile's extent, checked against the prefix.aliases: Further names of its facts: a name → the axiom, theorem or definition it names (import_fact).unresolved: Further names that name no such fact: a name → whyimport_factrefuses it.import_identity: Its declarations a library version provides: each → the library's identity of it.import_version: That library version.profile_axioms: Its profile axioms, strictly increasing: a session over it classifies eachPROFILE_AXIOM.
Snapshot.profile¶
Mojo
def profile(self) -> Int
Python
def profile(self)
The profile the snapshot was built over.
Returns. The profile.
TypeExpr¶
Mojo
struct TypeExpr(ImplicitlyCopyable)
Python
from judgment import TypeExpr
A type authored in a Session: its node and how its author built it; valid while its node is (G6).
Defined in src/judgment_shell/_ws_rows.mojo.
TypeExpr.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, row: Int)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; types come from session operations.
Arguments.
state: The session's state.generation: The workspace's generation when made.row: Its authored-syntax row.
TypeExpr.node¶
Mojo
def node(self) raises LibError -> UInt32
Python
def node(self)
The type's node in the session's workspace.
Returns. The node.
Raises.
LibError:KERNELfor a stale handle.
TypeExpr.same_as¶
Mojo
def same_as(self, other: Self) raises LibError -> Bool
Python
def same_as(self, other)
Compare canonical type identity in its owning session.
Arguments.
other: The type to compare.
Returns. True when both live handles name the same node in the same session.
Raises.
LibError: A stale handle on either side.
TypeExpr.format¶
Mojo
def format(self) raises LibError -> String
Python
def format(self)
The type as authored: arrows to the right, constructors' arguments delimited.
Returns. The text.
Raises.
LibError:KERNELfor a stale handle;LIMITwhen the allowance runs out.
Expr¶
Mojo
struct Expr(ImplicitlyCopyable)
Python
from judgment import Expr
An expression authored in a Session, checked when built; its node and explicit type arguments must
remain live, including arguments erased from the canonical term (G6).
Defined in src/judgment_shell/_ws_handles.mojo.
Expr.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, row: Int)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; expressions come from session operations.
Arguments.
state: The session's state.generation: The workspace's generation when made.row: Its authored-syntax row.
Expr.node¶
Mojo
def node(self) raises LibError -> UInt32
Python
def node(self)
The expression's node in the session's workspace.
Returns. The node.
Raises.
LibError:KERNELfor a stale handle.
Expr.same_as¶
Mojo
def same_as(self, other: Self) raises LibError -> Bool
Python
def same_as(self, other)
Compare canonical expression identity in its owning session.
Arguments.
other: The expression to compare.
Returns. True when both live handles name the same node in the same session.
Raises.
LibError: A stale handle on either side.
Expr.format¶
Mojo
def format(self) raises LibError -> String
Python
def format(self)
The expression as authored, parenthesized where precedence or grouping requires; as Expr.format.
Returns. The text.
Raises.
LibError:KERNELfor a stale handle;LIMITwhen the allowance runs out.
Expr.apply¶
Mojo
def apply(self, arguments: List[Self]) raises LibError -> Self
Python
def apply(self, arguments)
Apply a function to arguments, in order.
Each argument is copied out of the list and checked (same session, live) before its row is read.
Arguments.
arguments: The arguments, of this session.
Returns. The application.
Raises.
LibError:KERNELfor an ill-typed application or a stale handle;WRONG_KERNELacross sessions;LIMIT.
Frame¶
Mojo
struct Frame(ImplicitlyCopyable)
Python
from judgment import Frame
A frame of a Session's natural-deduction derivations: the session's base, a fixed variable, or an
assumption; valid while its row is (G6).
Defined in src/judgment_shell/_ws_handles.mojo.
Frame.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, context: UInt32, kind: Int, row: Int, local: Bool, parent_local: Bool, name: String = "")
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; frames come from session operations.
Arguments.
state: The session's state.generation: The workspace's generation when made.context: ItsCONTEXTrow.kind: Base 0, fix 1, assume 2.row: The fixed variable's or the assumption's authored-syntax row; -1 for the base.local: Whether steps under it print[local]: false for the base, true for a fix or an assumption.parent_local: The same for its parent, which a step that discharges it lies under.name: An assumption's name, which its hypothesis prints; empty for none and never checked for uniqueness, so two assumptions of one name print alike.
Frame.context¶
Mojo
def context(self) raises LibError -> UInt32
Python
def context(self)
The frame's CONTEXT row.
Returns. The row.
Raises.
LibError:KERNELfor a stale handle.
Step¶
Mojo
struct Step(ImplicitlyCopyable, Writable)
Python
from judgment import Step
A checked proof step of a Session: its proof row and its statement as authored; valid while its row is
(G6).
Defined in src/judgment_shell/_ws_handles.mojo.
Step.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, proof: UInt32, row: Int, var hyps: List[Int], local: Bool, name: String = "")
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; steps come from session operations.
Arguments.
state: The session's state.generation: The workspace's generation when made.proof: ItsPROOFrow.row: Its conclusion's authored-syntax row.hyps: Its hypotheses' rows, in the row's order.local: Whether it lies under a fixed variable or an assumption.name: A named assumption's name, which it prints first; empty for none.
Step.proof¶
Mojo
def proof(self) raises LibError -> UInt32
Python
def proof(self)
The step's proof row, for Session.prove.
Returns. The row.
Raises.
LibError:KERNELfor a stale handle.
Step.hypotheses¶
Mojo
def hypotheses(self) raises LibError -> List[Expr]
Python
def hypotheses(self)
The step's hypotheses as authored, as Proof's premises: a sequent step's, or the assumptions of the
assume frames a natural-deduction step rests on (tag-4 items of its D-set), in frame order.
Returns. The hypotheses.
Raises.
LibError:KERNELfor a stale handle;UNSUPPORTEDfor an assumption not made through this session;LIMIT.
Step.claims¶
Mojo
def claims(self) raises LibError -> List[ClaimAttachment]
Python
def claims(self)
The external claims the step rests on: those registered on the assume frames among its hypotheses, one per frame and decider, in frame order and then by the decider's bytes. Untrusted metadata, never a proof.
Returns. The attachments.
Raises.
LibError:KERNELfor a stale handle;UNSUPPORTEDfor a claimed frame with no authored assumption;LIMIT.
Step.dependencies¶
Mojo
def dependencies(self) raises LibError -> List[Dependency]
Python
def dependencies(self)
The declarations the step rests on, transitively, with their classes: its captured canonical signature and citations, through theorems' proofs and declaration witnesses, in declaration order.
Returns. The dependencies.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Step.axioms¶
Mojo
def axioms(self) raises LibError -> List[String]
Python
def axioms(self)
The axioms the step assumes, as Fact.axioms of the evidence: distinct names in declaration order, through
its captured canonical signature and cited proofs. Its local hypotheses are not axioms.
Returns. The names.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Step.admissions¶
Mojo
def admissions(self) raises LibError -> List[String]
Python
def admissions(self)
The labeled admissions the step rests on, in declaration order, as name: reason.
Returns. Admission descriptions.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Step.depends_on_instance_of¶
Mojo
def depends_on_instance_of(self, constructor: TypeConstructor) raises LibError -> Bool
Python
def depends_on_instance_of(self, constructor)
Whether this proof's evidence uses a class instance for the given type constructor.
Arguments.
constructor: A live constructor of this session.
Returns. True if a checked dependency is an instance for this constructor, including dependencies of cited proofs and declaration witnesses in the underlying snapshot.
Raises.
LibError: WRONG_KERNEL for another session, KERNEL for a stale handle, or LIMIT for exhausted work.
Step.statement¶
Mojo
def statement(self) raises LibError -> Expr
Python
def statement(self)
The step's conclusion as authored.
Returns. The expression.
Raises.
LibError:KERNELfor a stale handle.
Step.format¶
Mojo
def format(self, details: Bool = False) raises LibError -> String
Python
def format(self, details=False)
The step as Fact.format renders a fact without global assumptions: ⊢ φ, [local] ⊢ φ under a fixed
variable or an assumption, h: [local] ⊢ φ for a named assumption's hypothesis, and a sequent's hypotheses
before the turnstile.
Arguments.
details: When True, append global axiom and admission summaries.
Returns. The text.
Raises.
LibError:KERNELfor a stale handle;LIMITwhen the allowance runs out.
Step.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
def __str__(self)
Use str(value) or print(value) in Python.
Write the step's formatted judgment to a writer (Writable).
Arguments.
writer: Destination writer.
Fact¶
Mojo
struct Fact(ImplicitlyCopyable, Writable)
Python
from judgment import Fact
A checked fact of a session, valid while its declaration is live (G6).
A finished monomorphic authoring proof also retains the judgment at its captured signature. Its
statement and evidence inspection use that judgment. as_declared reads its published declaration.
Defined in src/judgment_shell/_ws_handles.mojo.
Fact.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32, statement: UInt32, part: UInt32 = 0)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; facts come from session operations.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: The declaration.statement: Its statement's node.part: The declaration's part that states it.
Fact.as_declared¶
Mojo
def as_declared(self) raises LibError -> Self
Python
def as_declared(self)
Read the theorem as published in its declaring theory, including that signature's witnesses.
Returns. The declaration-backed fact used by session citation, theorem application and Store export.
Raises.
LibError: If the fact is stale.
Fact.declaration¶
Mojo
def declaration(self) raises LibError -> UInt32
Python
def declaration(self)
The declaration that states the fact.
Returns. Its id in the session's workspace.
Raises.
LibError:KERNELfor a stale handle.
Fact.statement_node¶
Mojo
def statement_node(self) raises LibError -> UInt32
Python
def statement_node(self)
The proposition's canonical node identifier in the session's workspace.
Returns. Its node in the session's workspace.
Raises.
LibError:KERNELfor a stale handle.
Fact.statement¶
Mojo
def statement(self) raises LibError -> Expr
Python
def statement(self)
The proposition as an authored session expression.
Returns. An expression handle for this fact's proposition.
Raises.
LibError:KERNELfor a stale handle;UNSUPPORTEDif the statement cannot be authored;LIMIT.
Fact.type_params¶
Mojo
def type_params(self) raises LibError -> List[TypeExpr]
Python
def type_params(self)
Read the type parameters of the fact in authored header order, or first-occurrence order when no explicit header was recorded.
Returns. Owned type handles for the fact's type parameters.
Raises.
LibError: A stale fact or exhausted allowance.
Fact.dependencies¶
Mojo
def dependencies(self) raises LibError -> List[Dependency]
Python
def dependencies(self)
The declarations supporting the captured judgment or the published declaration, with their classes in declaration order. The declaration view includes its publication signature and the declaration itself.
Returns. The dependencies.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Fact.axioms¶
Mojo
def axioms(self) raises LibError -> List[String]
Python
def axioms(self)
The axioms the fact assumes, as Fact.axioms: distinct names in declaration order, through theorems'
proofs, the judgment's signature and declaration witnesses. A declared axiom assumes itself.
Returns. The names.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Fact.imported¶
Mojo
def imported(self) raises LibError -> Optional[String]
Python
def imported(self)
The provenance of an imported statement: library|version|identity; none for the session's own.
Returns. The source, for an IMPORTED_STATEMENT.
Raises.
LibError:KERNELfor a stale handle.
Fact.trusted_class_layer¶
Mojo
def trusted_class_layer(self) raises LibError -> Optional[String]
Python
def trusted_class_layer(self)
For a fact of an import whose class layer took the trusted pass: library|version it was trusted from.
That import's instances and class relations were not checked for coregularity pairwise; their library's producer is trusted for it.
Returns. The library and version; none otherwise.
Raises.
LibError:KERNELfor a stale handle.
Fact.statement_expr¶
Mojo
def statement_expr(self) raises LibError -> Expr
Python
def statement_expr(self)
The proposition as an authored session expression.
Returns. An expression handle for this fact's proposition.
Raises.
LibError:KERNELfor a stale handle;UNSUPPORTEDif the statement cannot be authored;LIMIT.
Fact.step¶
Mojo
def step(self) raises LibError -> Step
Python
def step(self)
The checked step backing this fact: its captured judgment if retained, else its citation.
Returns. A checked step concluding this fact's statement.
Raises.
LibError:KERNELfor a stale handle or refused citation;LIMIT.
Fact.admissions¶
Mojo
def admissions(self) raises LibError -> List[String]
Python
def admissions(self)
Transitive explicit admissions used by this fact, as Fact.admissions: "name: reason" in
declaration order. Ordinary mathematical axioms are returned separately by axioms.
Returns. The admission names and explanations.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Fact.format¶
Mojo
def format(self, details: Bool = False) raises LibError -> String
Python
def format(self, details=False)
The fact as Fact.format renders it: its labels, ⊢ φ as authored, and the summary of the axioms it
assumes. With details=True, expands all global axioms and admissions in declaration order.
Arguments.
details: Expand all original axiom statements and admission reasons.
Returns. The text.
Raises.
LibError:KERNELfor a stale handle;UNSUPPORTEDfor a snapshot's or an import's statement the session cannot author (a let, a free local);LIMIT.
Fact.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
def __str__(self)
Use str(value) or print(value) in Python.
Write the checked fact's display snapshot.
Arguments.
writer: Destination for the formatted fact.
Declaration¶
Mojo
struct Declaration(ImplicitlyCopyable)
Python
from judgment import Declaration
A checked declaration identity returned by session operations, including class parameters, ACU operators and literal kinds; valid while its row and owning scope are (G6).
Defined in src/judgment_shell/_ws_handles.mojo.
Declaration.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; declarations come from session operations.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: ItsDECLrow.
Declaration.same_as¶
Mojo
def same_as(self, other: Self) raises LibError -> Bool
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Compare live declaration identities within one owner.
Arguments.
other: Another checked declaration handle.
Returns. Whether both handles name the same declaration.
Raises.
LibError: WRONG_KERNEL for another owner or KERNEL for a stale handle.
Declaration.declaration¶
Mojo
def declaration(self) raises LibError -> UInt32
Python
This overload is available only in Mojo; it is not exposed by the Python client.
The DECL row, for immediate use.
Returns. The row.
Raises.
LibError:KERNELfor a stale handle.
Dependency¶
Mojo
@fieldwise_init
struct Dependency(Copyable, Movable)
| Field | Type | Description |
|---|---|---|
declaration |
UInt32 |
The declaration, in the session's workspace. |
cls |
DependencyClass |
Its class: CORE for propext, a registered provenance's, or the structural class of its kind. |
source |
String |
Its registered source (library|version|identity for an imported statement); empty for none. |
Python
from judgment import Dependency
A declaration evidence rests on: its id, class and registered source.
Defined in src/judgment_shell/_ws_details.mojo.
Proof¶
Mojo
struct Proof(Movable)
Python
from judgment import Proof
An incremental proof over a Session, or an explicitly selected subgoal, as Proof.
Every step is a checked session step. A failed operation leaves the goal tree and the session's rows as they were (G9); spent work remains.
Defined in src/judgment_shell/_dag_proof.mojo.
Proof.__init__¶
Mojo
def __init__(out self, var _state: ArcPointer[_DagProofState], _goal: Int, _root: Bool, _premise: Optional[Step] = None)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; create proofs with dag_theorem or dag_proof.
Arguments.
_state: Owned proof state._goal: Selected goal index._root: Whether this handle may finish the complete proof._premise: The retained local premise of a handle from have, rewrite or cases.
Proof.type_var¶
Mojo
def type_var(mut self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Declare a type parameter in this proof's header, as Proof.type_var.
Arguments.
name: A unique name within this header.sort: The classes the parameter belongs to (Definition Y-11); empty by default.
Returns. The type parameter. The theorem's positional type arguments follow the header's order, unused parameters included.
Raises.
LibError: For a fixed header, a used name, a class of another session, or exhaustion.
Proof.var¶
Mojo
def var(mut self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def var(self, name, kind)
Introduce an arbitrary term parameter before declaring the goal.
Arguments.
name: A unique header name.kind: Its type, global or parameterized in this proof's scope.
Returns. A local expression; named completion universally quantifies it, including an unused parameter.
Raises.
LibError: For a fixed header, invalid name, stale or foreign type, incompatible proof scope, an invisible type, or exhausted work. Failure leaves the header and session rows unchanged.
Proof.bound_var¶
Mojo
def bound_var(self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def bound_var(self, name, kind)
Create a proof-owned syntax variable for an explicit lambda, forall or exists expression.
Arguments.
name: A fresh syntax name, distinct from this proof's header and visible local/declaration names.kind: A live type available in the selected context, with only this proof's rigid parameters.
Returns. A construction variable below the selected context, distinct from every variable the session records over that frame (its local's name is variant of name), without a theorem parameter, assumption, goal-frame change or new proof authority. Bind it before using the result as a goal or evidence; create syntax variables after the header parameters they may reference.
Raises.
LibError: For an inactive proof, invalid name, foreign/stale/invisible type, incompatible rigid scope, stale construction frame or exhausted work. Failure leaves reservations and construction frames unchanged. Spent work stays spent.
Proof.vars¶
Mojo
def vars(mut self, names: String, kind: TypeExpr) raises LibError -> List[Expr]
Python
def vars(self, names, kind)
Introduce a whitespace-separated batch of term parameters atomically.
Arguments.
names: Nonempty whitespace-separated unique names.kind: Their common type.
Returns. The parameters in input order.
Raises.
LibError: Asvar, or for an empty batch or repeated name. No partial batch is published.
Proof.prop¶
Mojo
def prop(mut self, name: String) raises LibError -> Expr
Python
def prop(self, name)
Introduce an arbitrary proposition parameter in the proof header.
Arguments.
name: Its unique header name.
Returns. A local proposition, generalized on named completion.
Raises.
LibError: For a fixed header, invalid name, or exhausted work.
Proof.props¶
Mojo
def props(mut self, names: String) raises LibError -> List[Expr]
Python
def props(self, names)
Introduce a whitespace-separated batch of proposition parameters atomically.
Arguments.
names: Nonempty whitespace-separated unique header names.
Returns. An ordered list of arbitrary proposition parameters.
Raises.
LibError: For invalid names, a fixed header, or exhausted work.
Proof.format_fact¶
Mojo
def format_fact(self, fact: Step) raises LibError -> String
Python
def format_fact(self, fact)
Render a fact, with what the proof knows of it.
A premise of this proof (given, intro, have, rewrite, cases, obtain, define, assume) prints
as a premise, a claim's with its [claim] marker; any other step prints as Step.format.
Arguments.
fact: A step of this proof's session.
Returns. The text.
Raises.
LibError:WRONG_KERNELfor another session's step;KERNELfor a stale one;LIMIT.
Proof.format_fact¶
Mojo
def format_fact(self, fact: Fact) raises LibError -> String
Python
def format_fact(self, fact)
Render a declared fact: a theorem a proof declared with type parameters lists
them in its header's order, [B, A] ⊢ φ; any other fact prints as Fact.format.
Arguments.
fact: A fact of this proof's session.
Returns. The text.
Raises.
LibError:WRONG_KERNELfor another session's fact;KERNELfor a stale one;LIMIT.
Proof.given¶
Mojo
def given(mut self, name: String, proposition: Expr) raises LibError -> Step
Python
def given(self, name, proposition)
Declare a named header premise, preserved even when unused.
Arguments.
name: A unique header name for the premise.proposition: A proposition in the current header context.
Returns. Its hypothesis, usable in the eventual proof body.
Raises.
LibError: For a fixed or forward header, an invalid name, proposition or scope, or limits.
Proof.goal¶
Mojo
def goal(mut self, target: Expr) raises LibError
Python
def goal(self, target)
Fix the theorem header and its expected body proposition.
Arguments.
target: The proposition to prove in the complete header context.
Raises.
LibError: For a fixed or forward header, an invalid target or scope, or limits. Failure leaves the header editable.
Proof.target¶
Mojo
def target(self) raises LibError -> Expr
Python
def target(self)
Read the selected goal's current statement.
Returns. Its authored expression.
Raises.
LibError: For a forward proof or a header without a declared target.
Proof.obligations¶
Mojo
def obligations(self) raises LibError -> List[Goal]
Python
def obligations(self)
Snapshot every open or deferred obligation in the whole proof.
Returns. Goals in stable creation order. A finished proof returns an empty list; an empty list before finish means ready for reconstruction.
Raises.
LibError: For a forward or header proof, or exhausted work. Inspection changes nothing.
Proof.current_goal¶
Mojo
def current_goal(self) raises LibError -> Goal
Python
def current_goal(self)
Snapshot exactly this handle's selected outstanding goal and context.
Returns. An immutable goal with its identity, path, status, target, variables and assumptions.
Raises.
LibError: For a header, forward or finished proof, a solved or replaced selection, or limits.
Proof.select¶
Mojo
def select(self, name: String) raises LibError -> Self
Python
def select(self, name)
Select the unique outstanding goal with this final path component.
Arguments.
name: A branch name; the main continuation uses the theorem name when its path is empty.
Returns. A subgoal handle, without changing this handle or proving anything.
Raises.
LibError:SHAPEfor an ambiguous name or an unavailable proof;NO_MATCHwhen absent;LIMIT.
Proof.select¶
Mojo
def select(self, path: List[String]) raises LibError -> Self
Python
def select(self, path)
Select an outstanding goal by its complete structural path.
Arguments.
path: Components returned byGoal.path, relative to the theorem root; the empty path selects the main continuation.
Returns. An ordinary subgoal handle, from a fresh lookup in the current tree.
Raises.
LibError:NO_MATCHwhen the path is not outstanding;SHAPEfor an unavailable proof;LIMIT.
Proof.select¶
Mojo
def select(self, goal: Goal) raises LibError -> Self
Python
def select(self, goal)
Open a handle to the current state of the same outstanding goal.
Arguments.
goal: A snapshot from this proof's obligations.
Returns. An ordinary subgoal handle; solved or replaced goals are refused instead of retargeted.
Raises.
LibError:WRONG_KERNELfor another session's goal;SHAPEfor another proof's, a finished proof or a goal no longer outstanding;LIMIT.
Proof.format¶
Mojo
def format(self) raises LibError -> String
Python
def format(self)
Describe all outstanding goals and their local contexts.
Returns. Text distinguishing outstanding obligations, ready to finish, and finished.
Raises.
LibError: For a forward or header proof, or limits.
Proof.intro¶
Mojo
def intro(mut self, var name: String = "h", fresh: Bool = False) raises LibError -> Step
Python
def intro(self, name='h', fresh=False)
Introduce an implication or negation premise.
Arguments.
name: A display name for the returned assumption.fresh: Use the first of name, name_1, name_2, ... that no visible header name, premise, variable or declaration uses; it depends only on those names. Without it the name is taken as given.
Returns. The assumption's hypothesis, under the new goal's frame. A negation introduces its positive proposition and leaves False to prove.
Raises.
LibError: Unless the active target is an implication or negation, for an empty or reserved fresh name, or on exhaustion. Failure preserves the goal and context.
Proof.intro_var¶
Mojo
def intro_var(mut self, var name: String = "x", fresh: Bool = False) raises LibError -> Expr
Python
def intro_var(self, name='x', fresh=False)
Open a universal goal with an arbitrary variable fixed over the goal's frame.
The variable is distinct from every variable the session records over that frame: its local's name is
variant of name, and name its label. It occurs in no term usable at the goal's frame, so the
eigenvariable condition holds whatever its name.
Arguments.
name: A fresh proof-local name; it may reuse the target binder's name. A reserved name (one that begins with·) is refused.fresh: Use the first of name, name_1, name_2, ... that no visible header name, premise, variable or declaration uses, instead of refusing a used name.
Returns. The variable, usable in the new goal. Finish restores the original universal statement.
Raises.
LibError: For a nonuniversal or inactive goal, an invalid name, or limits. Failure leaves the selected goal and the proof's names unchanged.
Proof.witness¶
Mojo
def witness(mut self, value: Expr) raises LibError
Python
def witness(self, value)
Reduce an existential goal to its predicate at an explicit witness.
Arguments.
value: A correctly typed expression available in the selected context.
Raises.
LibError: For a nonexistential or inactive goal, an invalid witness, or limits. Failure leaves the selected goal unchanged; success still requires a proof of the resulting predicate.
Proof.split¶
Mojo
def split(mut self) raises LibError -> List[Self]
Python
def split(self)
Split a conjunction or equivalence into two explicit subgoals.
Returns. Left and right conjuncts, or the forward and backward implications of an equivalence, in that order.
Raises.
LibError: Unless the target is a conjunction or equivalence, or on exhaustion. Failure preserves the goal tree and selection.
Proof.choose_left¶
Mojo
def choose_left(mut self) raises LibError
Python
def choose_left(self)
Reduce a disjunction goal to its left proposition.
The same handle selects the new obligation in the unchanged context; finish reconstructs the disjunction by ∨-introduction once the selected proposition is proved.
Raises.
LibError: For an inactive or forward goal, a target other than a disjunction, or exhausted work. Failure preserves the goal tree and selection.
Proof.choose_right¶
Mojo
def choose_right(mut self) raises LibError
Python
def choose_right(self)
Reduce a disjunction goal to its right proposition.
The same handle selects the new obligation in the unchanged context; finish reconstructs the disjunction by ∨-introduction once the selected proposition is proved.
Raises.
LibError: For an inactive or forward goal, a target other than a disjunction, or exhausted work. Failure preserves the goal tree and selection.
Proof.assume¶
Mojo
def assume(mut self, proposition: Expr) raises LibError -> Step
Python
def assume(self, proposition)
Add an assumption to a forward proof.
Arguments.
proposition: The proposition to assume.
Returns. Its hypothesis.
Raises.
LibError: For a declared goal, an invalid scope or owner, or exhausted work.
Proof.left¶
Mojo
def left(self, fact: Step) raises LibError -> Step
Python
def left(self, fact)
Extract a left conjunct or an equivalence's forward implication.
Arguments.
fact: Conjunction or equivalence evidence visible in this context.
Returns. Its left conjunct, or the implication from left to right, under the goal's frame.
Raises.
LibError: For an incorrect shape, owner or scope, or exhausted work.
Proof.right¶
Mojo
def right(self, fact: Step) raises LibError -> Step
Python
def right(self, fact)
Extract a right conjunct or an equivalence's reverse implication.
Arguments.
fact: Conjunction or equivalence evidence visible in this context.
Returns. Its right conjunct, or the implication from right to left, under the goal's frame.
Raises.
LibError: For an incorrect shape, owner or scope, or exhausted work.
Proof.conjoin¶
Mojo
def conjoin(self, left: Step, right: Step) raises LibError -> Step
Python
def conjoin(self, left, right)
Combine two visible facts by conjunction introduction.
Arguments.
left: Evidence for the left conjunct.right: Evidence for the right conjunct.
Returns. Evidence for their conjunction, under the goal's frame.
Raises.
LibError: For an incompatible scope or owner, or exhausted work.
Proof.exact¶
Mojo
def exact(mut self, fact: Step) raises LibError
Python
def exact(self, fact)
Close the selected goal with evidence of its stated proposition.
Arguments.
fact: Evidence available in this goal's context.
Raises.
LibError: For an inactive or mismatched goal, a wrong scope, or exhausted work.
Proof.exact¶
Mojo
def exact(mut self, fact: Fact) raises LibError
Python
def exact(self, fact)
Close the selected goal with a declared fact of its stated proposition.
Arguments.
fact: An axiom or theorem of this session, cited in the goal's context.
Raises.
LibError: For an inactive or mismatched goal, a generic fact, or exhausted work.
Proof.refresh¶
Mojo
def refresh(mut self) raises LibError
Python
def refresh(self)
Adopt later declarations in every surviving goal of this draft.
The canonical signature must agree with the captured one. Success invalidates earlier foci and suggestions while preserving the identities of the proof's fixed variables and assumptions.
Raises.
LibError: SHAPE for a forward, header or finished proof, incompatible theory, or changed canonical signature; LIMIT for exhausted work or revision capacity; KERNEL for a stale or refused frame.
Proof.finish¶
Mojo
def finish(mut self) raises LibError -> Fact
Python
def finish(self)
Check every subgoal and declare the exact original theorem.
Returns. The theorem, its statement the header's premises over the declared goal.
Raises.
LibError: For open or deferred goals, a repeated finish, a child handle, a registered theorem name, or exhaustion. Failure leaves the proof and the session's rows unchanged.
Proof.finish¶
Mojo
def finish(mut self, fact: Step) raises LibError -> Step
Python
def finish(self, fact)
Finish a forward proof, discharging only its used assumptions.
Arguments.
fact: The final visible fact.
Returns. The closed step, its unused assumptions skipped. The session declares a theorem only under a name (prove_step), so the evidence is returned as a step; exact and the session's rules take it as they take any step.
Raises.
LibError: For declared or inactive proofs, scope or owner errors, or exhaustion.
Proof.finish¶
Mojo
def finish(mut self, fact: Fact) raises LibError -> Step
Python
def finish(self, fact)
Finish a forward proof with a declared fact.
Arguments.
fact: An axiom or theorem of this session.
Returns. The closed step, its unused assumptions skipped: a Step, as finish(step).
Raises.
LibError: For declared or inactive proofs, a generic fact, or exhaustion.
Proof.fact¶
Mojo
def fact(self) raises LibError -> Step
Python
def fact(self)
Read the retained local premise of a handle from have, rewrite or cases.
Returns. For have or rewrite, the continuation's claim premise; for cases, the branch's assumption.
Raises.
LibError: Unless this handle came from have, rewrite or cases, or on exhaustion.
Proof.fact¶
Mojo
def fact(self, name: String) raises LibError -> Step
Python
def fact(self, name)
Find a unique named local premise in the selected outstanding context.
Arguments.
name: The name given by given, intro, cases, have, rewrite, or obtain's property.
Returns. Its hypothesis, in this goal's context.
Raises.
LibError:NO_MATCHfor an absent name;SHAPEfor duplicate visible names or an inactive selection;LIMIT.
Proof.variable¶
Mojo
def variable(self, name: String) raises LibError -> Expr
Python
def variable(self, name)
Find a unique named variable in the selected outstanding context.
Arguments.
name: The name given by intro_var, obtain or define.
Returns. The variable, usable in this goal and its descendants.
Raises.
LibError:NO_MATCHfor an absent name;SHAPEfor duplicate visible names or an inactive selection;LIMIT.
Proof.truth¶
Mojo
def truth(self) raises LibError -> Step
Python
def truth(self)
Construct evidence of True in the selected context.
Returns. A step usable with exact or forward proof operations.
Raises.
LibError: For an inactive proof or exhausted resources.
Proof.false_elim¶
Mojo
def false_elim(self, contradiction: Step, target: Expr) raises LibError -> Step
Python
def false_elim(self, contradiction, target)
Derive a proposition from evidence of False.
Arguments.
contradiction: Visible evidence of False.target: The proposition to derive in this proof context.
Returns. Evidence of the target.
Raises.
LibError: For wrong owners, scopes, types, evidence, or limits.
Proof.contradiction¶
Mojo
def contradiction(self, negative: Step, positive: Step) raises LibError -> Step
Python
def contradiction(self, negative, positive)
Derive False from evidence of a proposition and of its negation.
Arguments.
negative: Visible evidence of a negation.positive: Visible evidence of exactly its proposition.
Returns. False, for exact, false_elim or a forward proof.
Raises.
LibError: For mismatched propositions, unavailable evidence, owners, scopes, or exhausted work.
Proof.refl¶
Mojo
def refl(self, expression: Expr) raises LibError -> Step
Python
def refl(self, expression)
Construct reflexivity evidence without closing the goal.
Arguments.
expression: A visible expression of this session.
Returns. Its equality to itself.
Raises.
LibError: For an incorrect owner or scope, or exhausted work.
Proof.lhs¶
Mojo
def lhs(self) raises LibError -> Focus
Python
def lhs(self)
Select the left side of the active equality goal.
Returns. A versioned focus.
Raises.
LibError: Unless this is an active equality goal.
Proof.rhs¶
Mojo
def rhs(self) raises LibError -> Focus
Python
def rhs(self)
Select the right side of the active equality goal.
Returns. A versioned focus.
Raises.
LibError: Unless this is an active equality goal.
Proof.transform¶
Mojo
def transform(self, expression: Expr) raises LibError -> Transformation
Python
def transform(self, expression)
Start an independent expression transformation in the selected proof context.
Arguments.
expression: The visible expression to transform.
Returns. A transformation with checked equality evidence, leaving this proof unchanged.
Raises.
LibError: For an inactive proof, invalid ownership, lifetime or scope, or exhausted work.
Proof.calc¶
Mojo
def calc(self, start: Expr) raises LibError -> Calculation
Python
def calc(self, start)
Start an independent equality chain with checked or deferred steps in the selected context.
Arguments.
start: The first expression, visible in this selected context.
Returns. A calculation yielding a checked local step without changing or finishing its parent proof.
Raises.
LibError: For an inactive goal, invalid ownership, lifetime or scope, or exhausted work.
Proof.focus¶
Mojo
def focus(self) raises LibError -> Focus
Python
def focus(self)
Select the entire active proposition.
Returns. A versioned focus.
Raises.
LibError: For inactive or forward goals, or exhaustion.
Proof.change¶
Mojo
def change(mut self, target: Expr, unfold: List[Definition] = List[Definition]()) raises LibError
Python
def change(self, target, unfold=[])
Replace the target by a convertible one, as Proof.change.
Arguments.
target: The convertible replacement proposition.unfold: Transparent definitions the conversion may unfold; none by default.
Raises.
LibError: For an inactive goal, scope or owner errors, or a failed conversion. Failure leaves the goal and the session's rows unchanged.
Proof.unfold¶
Mojo
def unfold(mut self, definition: Definition) raises LibError
Python
def unfold(self, definition)
Expand one definition at the root of the active target, as Proof.unfold(definition).
Arguments.
definition: The transparent or opaque definition at the target's head.
Raises.
LibError: For an inactive goal, a different head, scope errors, or limits. Failure leaves the goal and the session's rows unchanged; nested calls are not expanded.
Proof.unfold¶
Mojo
def unfold(mut self, symbol: Expr) raises LibError
Python
def unfold(self, symbol)
Expand a local definition at the root of the selected proposition, as Proof.unfold(symbol).
Arguments.
symbol: A visible symbol returned by define.
Raises.
LibError: For an inactive goal, a different head, an invalid scope, or limits. Failure leaves the goal and the session's rows unchanged.
Proof.rfl¶
Mojo
def rfl(mut self) raises LibError
Python
def rfl(self)
Close an equality goal by reflexivity and conversion.
Raises.
LibError: If the sides differ, the goal is inactive, or work is exhausted.
Proof.assumption¶
Mojo
def assumption(mut self) raises LibError
Python
def assumption(self)
Close the selected goal with an exactly matching visible assumption.
Raises.
LibError:NO_MATCHwhen no assumption matches; for inactive goals or exhausted work.
Proof.sorry¶
Mojo
def sorry(mut self) raises LibError
Python
def sorry(self)
Defer this goal without creating evidence or allowing finish.
Raises.
LibError: If the goal is inactive, forward, or work is exhausted.
Proof.admit¶
Mojo
def admit(mut self, name: String, reason: String) raises LibError
Python
def admit(self, name, reason)
Explicitly assume this scoped obligation and record its admission, as Proof.admit.
Arguments.
name: A fresh global admission name, distinct from the theorem name.reason: A nonempty explanation retained in dependency inspection.
Raises.
LibError: For inactive/forward goals, invalid names, changed canonical signatures, or exhaustion.
Proof.refine¶
Mojo
def refine(mut self, plan: ProofRecipe) raises LibError -> Refinement
Python
def refine(self, plan)
Check a typed partial recipe and expose its named proof obligations.
Arguments.
plan: A recipe of checked facts and explicit proposition holes.
Returns. Stable named handles. Equal names share an obligation only for the same proposition.
Raises.
LibError: For a wrong conclusion, malformed rule, unavailable fact, invalid hole name or scope, foreign ownership, or exhaustion. Failure publishes no goals or names.
Proof.resume¶
Mojo
def resume(mut self) raises LibError
Python
def resume(self)
Reactivate the deferred goal selected by this handle.
Raises.
LibError: Unless this handle selects an unfinished deferred goal, or on exhausted work or revisions. Failure preserves the draft; success invalidates its old foci and candidate revision token.
Proof.have¶
Mojo
def have(mut self, name: String, proposition: Expr) raises LibError -> Self
Python
def have(self, name, proposition)
Create a named intermediate claim and continue under its local premise.
Arguments.
name: A fresh name in the selected context.proposition: The claim to prove, well scoped in that context.
Returns. A separate handle for the claim. The receiving handle advances to a continuation where the claim's fact() is a local premise. Both obligations must be proved before the root can finish.
Raises.
LibError: For inactive or forward goals, invalid names, proposition owner, type or scope errors, or exhaustion. Failure changes no goal or name reservation.
Proof.rewrite¶
Mojo
def rewrite(mut self, name: String, at: Focus, to: Expr) raises LibError -> Self
Python
def rewrite(self, name, at, to)
Rewrite one occurrence and keep its equality as a named obligation.
Arguments.
name: A fresh claim name, as have's.at: A current focus on this handle's selected goal.to: The replacement, of the same type and visible in the original context.
Returns. A claim handle whose target is the selected expression's equality with the replacement. The receiving handle advances to the rewritten continuation, where the claim's fact() is a local premise.
Raises.
LibError: For inactive or forward goals, mismatched or stale selections, invalid names, types, scopes, owners, or exhausted work. Failure preserves the goal tree, the focus and the names.
Proof.define¶
Mojo
def define(mut self, name: String, body: Expr) raises LibError -> Expr
Python
def define(self, name, body)
Name a local expression and continue in its definition's scope.
Arguments.
name: A fresh name in the selected goal's context.body: The expression to abbreviate, visible there.
Returns. A local symbol of the body's type. defining_eq reads its equation. Completion eliminates the symbol and the equation through the session's rules, with no global axiom.
Raises.
LibError: For inactive or forward goals, invalid names, owner or scope errors, or exhaustion. Failure preserves all logical state.
Proof.defining_eq¶
Mojo
def defining_eq(self, symbol: Expr) raises LibError -> Step
Python
def defining_eq(self, symbol)
Read a local definition's equation in the selected scope.
Arguments.
symbol: A symbol returned by define on this proof.
Returns. Its equation's hypothesis.
Raises.
LibError: For foreign, unavailable or non-definition symbols, a finished proof, or exhaustion.
Proof.cases¶
Mojo
def cases(mut self, disjunction: Step, left_name: String = "left", right_name: String = "right") raises LibError -> List[Self]
Python
def cases(self, disjunction, left_name="left", right_name="right")
Prove the selected goal in two separately scoped cases of a disjunction.
Arguments.
disjunction: Visible evidence of a disjunction.left_name: A fresh name for the left case's assumption.right_name: A fresh name for the right case's assumption; the two may coincide.
Returns. The left and right handles, each retaining its assumption through fact().
Raises.
LibError: For inactive or forward goals, invalid evidence, a non-disjunction, conflicting names, or exhausted work. Failure publishes neither case.
Proof.cases¶
Mojo
def cases(mut self, disjunction: Fact, left_name: String = "left", right_name: String = "right") raises LibError -> List[Self]
Python
def cases(self, disjunction, left_name="left", right_name="right")
Prove the selected goal in the cases of a declared disjunction, as cases of a step.
Arguments.
disjunction: A declared disjunction.left_name: A fresh name for the left case's assumption.right_name: A fresh name for the right case's assumption.
Returns. The left and right handles.
Raises.
LibError: Ascasesof a step.
Proof.obtain¶
Mojo
def obtain(mut self, existence: Step, var name: String = "w", var property: String = "", fresh: Bool = False) raises LibError -> Tuple[Expr, Step]
Python
def obtain(self, existence, name="w", property="", fresh=False)
Use an existential fact through a scoped witness and its property.
Arguments.
existence: Visible evidence of an existential proposition.name: A fresh local name for the witness.property: A fresh name for the property's assumption; empty leaves it unnamed. It differs fromname.fresh: Use, for the witness and then for a named property, the first of name, name_1, name_2, ... that no visible name uses, instead of refusing a used name.
Returns. The witness and its property's hypothesis. The selected goal continues in their scope.
Raises.
LibError: For an inactive or forward goal, non-existential or unavailable evidence, invalid names, or exhausted work. Failure changes no goal or name reservation.
Proof.obtain¶
Mojo
def obtain(mut self, existence: Fact, var name: String = "w", var property: String = "", fresh: Bool = False) raises LibError -> Tuple[Expr, Step]
Python
def obtain(self, existence, name="w", property="", fresh=False)
Use a declared existential fact, as obtain of a step.
Arguments.
existence: A declared existential.name: A fresh local name for the witness.property: A fresh name for the property's assumption, or empty.fresh: Choose fresh names instead of refusing used ones.
Returns. The witness and its property's hypothesis.
Raises.
LibError: Asobtainof a step.
Proof.use¶
Mojo
def use(self, theorem: Step, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Step
Python
def use(self, theorem, type_args=[], terms=[], using=[])
Specialize a proof-local fact and discharge a prefix of its premises.
Arguments.
theorem: A visible local fact.type_args: Explicit type arguments; a local fact has none.terms: Arguments for successive outer universal quantifiers.using: Evidence for successive outer implications; a terminal negation consumes its proposition and yields False.
Returns. Evidence of the residual statement, under the goal's frame.
Raises.
LibError: For a finished proof, wrong argument counts, types or scopes, or exhausted work. Failure changes nothing.
Proof.use¶
Mojo
def use(self, theorem: Fact, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Step
Python
def use(self, theorem, type_args=[], terms=[], using=[])
Specialize a declared fact and discharge a prefix of its premises.
Arguments.
theorem: An axiom or theorem of this session.type_args: Explicit type arguments in its parameters' order; when omitted, every parameter the terms and premises determine is inferred.terms: Arguments for successive outer universal quantifiers.using: Evidence for successive outer implications.
Returns. Evidence of the residual statement, under the goal's frame.
Raises.
LibError: Asuseof a step;SHAPEfor type arguments that cannot be inferred.
Proof.suggest¶
Mojo
def suggest(self, prefix: String = "", limit: Int = 20) raises LibError -> List[Suggestion]
Python
def suggest(self, prefix='', limit=20)
Inspect applicable registered facts without changing the draft.
Arguments.
prefix: Optional name prefix.limit: Maximum candidates, in registration order.
Returns. Application plans with their inferred arguments and remaining premises.
Raises.
LibError: For inactive goals, negative limits, or exhaustion. No candidate changes the proof.
Proof.apply¶
Mojo
def apply(mut self, suggestion: Suggestion) raises LibError -> List[Self]
Python
def apply(self, suggestion)
Apply a discovered plan after rechecking its goal and evidence.
Arguments.
suggestion: A candidate from this exact selected goal and revision.
Returns. The premise obligations of the application.
Raises.
LibError: For foreign or stale plans, invalid evidence, or exhaustion.
Proof.apply¶
Mojo
def apply(mut self, theorem: Fact, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> List[Self]
Python
def apply(self, theorem, type_args=[], terms=[], using=[])
Reduce the selected goal to a declared fact's unproved premises.
Arguments.
theorem: An axiom or theorem of this session.type_args: Explicit type arguments, or omitted for unambiguous inference.terms: Arguments for successive outer universal quantifiers; when omitted, inferred from the conclusion.using: Evidence for a prefix of the implication premises; the others become subgoals. Applying a negation to False exposes its proposition as a premise.
Returns. Subgoal handles in premise order, in the original context; none means the goal is solved.
Raises.
LibError: For inactive or forward goals, invalid arguments or evidence, missing universal arguments,NO_MATCHfor a different conclusion, or exhausted work. Failure preserves the proof.
Proof.apply¶
Mojo
def apply(mut self, theorem: Step, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> List[Self]
Python
def apply(self, theorem, type_args=[], terms=[], using=[])
Reduce the selected goal to a local fact's unproved premises, as apply of a declared fact.
Arguments.
theorem: A visible local fact.type_args: Explicit type arguments; a local fact has none.terms: Arguments for successive outer universal quantifiers.using: Evidence for a prefix of the implication premises.
Returns. Subgoal handles in premise order.
Raises.
LibError: Asapplyof a declared fact.
Proof.tactics¶
Mojo
def tactics(self) -> Tactics
Python
def tactics(self)
Obtain explicit tactic constructors sharing this session's budget.
Returns. A factory for composable, untrusted tactic values.
Proof.by¶
Mojo
def by(mut self, tactic: Tactic) raises LibError -> TacticReport
Python
def by(self, tactic)
Run a composed tactic atomically and report its logical outcome.
Arguments.
tactic: An explicit tactic value from this session.
Returns. A report distinguishing solved, progress, no_change, no_match, and resource_exhausted, with the paths of the goals it leaves active and the work it spent. A failed attempt preserves the whole draft and the session's rows; a successful one retains existing goal identities and selects the first goal it leaves.
Raises.
LibError: For inactive or forward goals, foreign tactics, invalid evidence, a step the session's proof does not provide yet (UNSUPPORTED), or implementation errors. These are not alternatives.
Proof.by¶
Mojo
def by(mut self, tactic: Tactic, work: UInt64) raises LibError -> TacticReport
Python
def by(self, tactic, work)
Run a tactic atomically with at most work units of authoring work.
Arguments.
tactic: An explicit tactic value from this session.work: The cap for this attempt; work it does not spend stays in the session's allowance.
Returns. As by(tactic); an attempt that reaches its cap reports resource_exhausted and changes nothing.
Raises.
LibError: As by(tactic).
Proof.by¶
Mojo
def by(mut self, candidate: Candidate) raises LibError -> TacticReport
Python
def by(self, candidate)
Run a candidate's data program on the goal it names, if that goal is unchanged.
Arguments.
candidate: A program bound to a goal's path and revision token (Goal.data).
Returns. As by(tactic) on the selected goal. After a change this handle selects the first goal the program left active; otherwise its selection is unchanged.
Raises.
LibError:SHAPEfor an obsolete revision token (another revision, goal or proof), a goal that is no longer outstanding at the path, or an ambiguous path;NO_MATCHfor an absent path; otherwise as compile and by(tactic).
Proof.trial¶
Mojo
def trial(mut self, tactic: Tactic) raises LibError -> TacticReport
Python
def trial(self, tactic)
Run a tactic on a staged copy of the draft and report, committing nothing.
Arguments.
tactic: An explicit tactic value from this session.
Returns. The status, goal paths, and work by(tactic) would report, with changed() false; the draft, this handle's selection and the session's rows are unchanged.
Raises.
LibError: As by(tactic).
Proof.compile¶
Mojo
def compile(self, data: TacticData) raises LibError -> Tactic
Python
def compile(self, data)
Turn a data program into a tactic of this session.
Combinators are translated as they stand; each step stays data until it runs, when its names and expressions are resolved in each selected goal. Compiling resolves nothing, so the same data compiles in any session.
Arguments.
data: The program.
Returns. A tactic; compiling charges in proportion to the program's size and the bytes of its names.
Raises.
LibError:SHAPEfor a negative repeat bound;LIMITon exhaustion.
Proof.resolve¶
Mojo
def resolve(self, data: ExprData) raises LibError -> Expr
Python
def resolve(self, data)
Resolve an expression description in the selected goal or unfinished header's context.
Arguments.
data: The description, using visible variables, header type parameters and session declarations.
Returns. The resolved expression, without asserting it or changing the draft.
Raises.
LibError: NO_MATCH for an absent name; SHAPE for a forward, finished, or inactive selection; otherwise as a data step's resolution. Failure restores the header and leaves no session rows.
Proof.fork¶
Mojo
def fork(self, work: UInt64, stop: Optional[StopSignal] = None) raises LibError -> Self
Python
def fork(self, work, stop=None)
Copy this draft into a fork of its session (Session.fork), selecting the same goal, as Proof.fork.
Goal paths, identities, and revision tokens are the same in the copy, so a Candidate made from this draft's goal data runs there with by(candidate). The copy and its session share nothing mutable with this draft; this draft is not changed. With a stop signal, every tactic step in the copy first reads it, and once it is requested the attempt reports resource_exhausted.
Arguments.
work: The fork's own allowance.stop: An optional stop request shared with the caller.
Returns. The copy, a handle of the fork's draft.
Raises.
LibError: AsSession.fork;SHAPEwhile a transaction is open;KERNELwhen the draft or this handle holds a stale handle (a fork's draft holds no handle of its parent);LIMITwhen this session's allowance cannot pay forfork_cost. Every refusal charges nothing and leaves this draft and the session's rows unchanged; a fork charges exactlyfork_cost.
Proof.fork_cost¶
Mojo
def fork_cost(self) -> UInt64
Python
def fork_cost(self)
Read what fork would charge this draft's session now.
Returns. The current session/draft copy allowance, including owned syntax-name bytes and the checked-handle reads. Reading it charges nothing. UInt64.MAX when the total exceeds capacity; fork separately detects overflow and refuses it even when the remaining allowance is UInt64.MAX.
Proof.work_remaining¶
Mojo
def work_remaining(self) -> UInt64
Python
def work_remaining(self)
Read the remaining allowance of this draft's session.
Returns. Remaining units, as Session.work_remaining.
Proof.spend¶
Mojo
def spend(self, amount: UInt64) raises LibError
Python
def spend(self, amount)
Charge this draft's session for work done on its behalf elsewhere, such as in its forks.
Arguments.
amount: Units to charge.
Raises.
LibError:LIMIT, charging nothing, when the allowance is smaller.
Proof.checkpoint¶
Mojo
def checkpoint(self) raises LibError -> Checkpoint
Python
def checkpoint(self)
Capture the entire draft's logical state and this handle's selection.
Returns. An owned checkpoint usable only with this unfinished declared proof. Work and the session's rows are deliberately not rolled back by a restore.
Raises.
LibError:SHAPEfor forward, header, or finished proofs or a closed session;LIMIT, charging nothing, on exhaustion.
Proof.restore¶
Mojo
def restore(mut self, checkpoint: Checkpoint) raises LibError
Python
def restore(self, checkpoint)
Restore a draft checkpoint without refunding spent work.
Arguments.
checkpoint: A checkpoint from this exact proof. The proof's syntax-name reservations and construction frames return to the saved state. Syntax expressions already returned remain live when their session rows do; no bank row or spent work is rolled back.
Raises.
LibError:WRONG_KERNELfor another session's checkpoint;SHAPEfor another proof's, a finished proof, a closed session, or a checkpoint taken in a transaction that has closed;KERNELfor a checkpoint that a later return of the session went below;LIMITon exhaustion. Success invalidates all old foci and discards later goals without reusing their identities. Failed restoration changes nothing and charges nothing.
Goal¶
Mojo
struct Goal(ImplicitlyCopyable, Writable)
Python
from judgment import Goal
An owned snapshot of an outstanding obligation of a _DagProof and its context, as Goal.
Snapshots do not update when the proof changes. Select one through _DagProof.select to work on the same goal;
consumed goals never retarget.
Defined in src/judgment_shell/_dag_proof_state.mojo.
Goal.__init__¶
Mojo
def __init__(out self, var _data: ArcPointer[_DagGoalData])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal snapshot constructor; use the proof's inspection.
Arguments.
_data: Owned inspection data.
Goal.id¶
Mojo
def id(self) -> Int
Python
def id(self)
Read the stable proof-local goal identity.
Returns. Its creation index, for display rather than cross-proof selection.
Goal.name¶
Mojo
def name(self) raises LibError -> String
Python
def name(self)
Read the enclosing claim name or the theorem name.
Returns. An owned display name. Sibling goals can share this name; ids differ.
Raises.
LibError: If the copying allowance is exhausted.
Goal.path¶
Mojo
def path(self) raises LibError -> List[String]
Python
def path(self)
Read the captured structural address of this outstanding goal.
Returns. Owned components for the proof's select, relative to its root and independent of sibling completion.
Raises.
LibError: If the copying allowance is exhausted.
Goal.status¶
Mojo
def status(self) -> String
Python
def status(self)
Read the status captured when this snapshot was created.
Returns. The string open or deferred.
Goal.target¶
Mojo
def target(self) -> Expr
Python
def target(self)
Read the captured target without asserting it.
Returns. The authored proposition.
Goal.type_params¶
Mojo
def type_params(self) raises LibError -> List[TypeExpr]
Python
def type_params(self)
Read the proof's rigid type parameters in header order.
Returns. An owned list of type expressions, including unused parameters.
Raises.
LibError: If the copying allowance is exhausted.
Goal.variables¶
Mojo
def variables(self) raises LibError -> List[Expr]
Python
def variables(self)
Read the proof's local variables in outermost-first context order.
Returns. An owned list of expressions.
Raises.
LibError: If the copying allowance is exhausted.
Goal.assumptions¶
Mojo
def assumptions(self) raises LibError -> List[Step]
Python
def assumptions(self)
Read the local premises in outermost-first context order.
Returns. An owned list of their hypotheses, steps under their own frames.
Raises.
LibError: If the copying allowance is exhausted.
Goal.data¶
Mojo
def data(self) raises LibError -> GoalData
Python
def data(self)
Describe the captured goal as plain data, as Goal.data: what a search program reads and resolves.
Returns. Its path, status, revision token, target, and visible variables and premises, with the names the goal displays. Names are not qualified: resolving them in the goal's context gives back the same expressions.
Raises.
LibError: LIMIT on exhausted work; UNSUPPORTED for a target, variable or premise holding arithmetic, which the session does not author yet.
Goal.format¶
Mojo
def format(self) raises LibError -> String
Python
def format(self)
Copy the captured goal and context display.
Returns. Owned text, unchanged by subsequent tactics.
Raises.
LibError: If the copying allowance is exhausted.
Goal.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
def __str__(self)
Use str(value) or print(value) in Python.
Write the already-budgeted snapshot text.
Arguments.
writer: Destination for the captured goal and local context.
Focus¶
Mojo
struct Focus(Copyable)
Python
from judgment import Focus
A versioned occurrence within a _DagProof goal's authored syntax, as Focus.
Selection counts occurrences, not shared DAG nodes. A focus records its goal's revision and is refused once the goal changes in place.
Defined in src/judgment_shell/_dag_proof_rules.mojo.
Focus.__init__¶
Mojo
def __init__(out self, var _state: ArcPointer[_DagProofState], _goal: Int, var _path: List[Int], _revision: UInt64)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain a focus through the proof's lhs, rhs or focus, or at.
Arguments.
_state: Owning proof state._goal: Selected goal._path: Authored argument positions from that goal (-1 for an application's function)._revision: The goal's revision at selection time.
Focus.expression¶
Mojo
def expression(self) raises LibError -> Expr
Python
def expression(self)
Read the current focused expression.
Returns. The expression at this occurrence.
Raises.
LibError: For a stale or inactive focus, or exhausted work.
Focus.under¶
Mojo
def under(self, name: String = "x") raises LibError -> BinderFocus
Python
def under(self, name='x')
Open one lambda or quantifier in an isolated body transformation.
Arguments.
name: A fresh local name; an existing syntax binder name may be reused.
Returns. A body transformation whose finish closes the local through checked congruence.
Raises.
LibError: For a nonbinder, stale focus, invalid name or exhausted work. Failure preserves the parent and session rows. Opening neither changes the parent goal nor reserves its names.
Focus.at¶
Mojo
def at(self, expression: Expr, occurrence: Int = 0) raises LibError -> Self
Python
def at(self, expression, occurrence=0)
Select a matching subexpression within this focus.
Arguments.
expression: The expression to match, by its term.occurrence: One-based authored preorder occurrence; zero requires uniqueness. Quantifier and lambda bodies are opaque.
Returns. A nested occurrence focus.
Raises.
LibError: For no match, ambiguity, a negative occurrence, a foreign owner, a stale focus, exhausted work, or a search requiring binder traversal. Selection does not change the goal.
Focus.to¶
Mojo
def to(self, replacement: Expr, using: Step, premises: List[Step] = List[Step]()) raises LibError -> Self
Python
def to(self, replacement, using, premises=[])
Replace this occurrence using a chosen checked equality.
Arguments.
replacement: The desired expression at this occurrence.using: Evidence of focused expression = replacement, or a step concluding an equality whose universal arguments the endpoints and the premises determine.premises: Evidence for every implication premise, in order; none is searched or assumed.
Returns. The refreshed focus, allowing fluent chains.
Raises.
LibError: For invalid evidence, conflicting or unresolved arguments, missing, extra or incorrect premises, owner or scope errors, a stale focus, or limits. Failure leaves the goal, the focus and the session's rows unchanged.
Focus.to¶
Mojo
def to(self, replacement: Expr, using: Fact, premises: List[Step] = List[Step]()) raises LibError -> Self
Python
def to(self, replacement, using, premises=[])
Replace this occurrence using a declared equality theorem.
Arguments.
replacement: The desired expression at this occurrence.using: A theorem concluding an equality whose type and universal arguments the endpoints and the premises determine.premises: Evidence for every implication premise, in order; none is searched or assumed.
Returns. The refreshed focus, allowing fluent chains.
Raises.
LibError: As the otherto. Failure leaves the goal, the focus and the session's rows unchanged.
Focus.rw¶
Mojo
def rw(self, rule: Step, reverse: Bool = False, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Self
Python
def rw(self, rule, reverse=False, type_args=[], terms=[], using=[])
Rewrite this occurrence with an explicitly selected equality.
Arguments.
rule: Equality evidence, or a step concluding an equality.reverse: Swap the rule's endpoints by symmetry.type_args: Explicit types; none infers them.terms: Explicit universal arguments in order; the rest are inferred from this occurrence and the premises.using: Evidence for every condition of the rule; none is searched or assumed.
Returns. The refreshed focus at the rule's other endpoint.
Raises.
LibError: For a non-equality, ambiguous or conflicting arguments, missing premises, wrong endpoints or scopes, a stale focus, or limits. Failure leaves the goal, the focus and the session's rows unchanged.
Focus.rw¶
Mojo
def rw(self, rule: Fact, reverse: Bool = False, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Self
Python
def rw(self, rule, reverse=False, type_args=[], terms=[], using=[])
Rewrite this occurrence with a declared equality theorem.
Arguments.
rule: A theorem concluding an equality.reverse: Swap the rule's endpoints by symmetry.type_args: Explicit types; none infers them.terms: Explicit universal arguments in order; the rest are inferred from this occurrence and the premises.using: Evidence for every condition of the theorem; none is searched or assumed.
Returns. The refreshed focus at the rule's other endpoint.
Raises.
LibError: As the otherrw. Failure leaves the goal, the focus and the session's rows unchanged.
Focus.change¶
Mojo
def change(self, replacement: Expr, unfold: List[Definition] = List[Definition]()) raises LibError -> Self
Python
def change(self, replacement, unfold=[])
Restate this occurrence by conversion.
Arguments.
replacement: The convertible replacement expression.unfold: Transparent definitions the conversion may unfold; none by default.
Returns. A refreshed focus, its equation carried through the surroundings by congruence.
Raises.
LibError: For a replacement that does not convert, a stale selection, invalid types, scopes or owners, or exhaustion. Failure leaves the goal and the session's rows unchanged.
Focus.fold¶
Mojo
def fold(self, symbol: Expr, all: Bool = False) raises LibError -> Self
Python
def fold(self, symbol, all=False)
Fold a checked local definition into this selected expression or scope.
Arguments.
symbol: A visible symbol introduced by this proof'sdefine.all: Replace every original outermost matching occurrence in this selection. Otherwise the selected expression itself must match. Matching uses canonical identity; binder bodies remain opaque.
Returns. A refreshed focus at the same subtree. Replacements are never searched again.
Raises.
LibError: NO_MATCH if no eligible occurrence exists; also for invalid, stale, foreign or unavailable symbols or selections, revision capacity, or exhausted work. Failure preserves the proof, session rows and all existing selection versions. Traversal follows the finite authored tree, charging each visited occurrence and copied path to the shared allowance (G2).
Focus.unfold¶
Mojo
def unfold(self, symbol: Expr) raises LibError -> Self
Python
def unfold(self, symbol)
Expand a local definition at this occurrence's head by its equation.
Arguments.
symbol: The visible local definition at this focus's head.
Returns. A refreshed focus with the symbol replaced by its body; applications are expanded through congruence.
Raises.
LibError: For a different head, a stale focus, owner or scope errors, or exhaustion. Failure leaves the goal, the selection and the session's rows unchanged.
Focus.unfold¶
Mojo
def unfold(self, definition: Definition) raises LibError -> Self
Python
def unfold(self, definition)
Expand one application of a definition at this occurrence's head by its equation.
Arguments.
definition: The transparent or opaque definition at this focus's head.
Returns. A refreshed focus at the expanded body; the arguments are substituted without capture, nested calls stay.
Raises.
LibError: For a different head, a stale focus, invalid scope or owner, or exhausted work. Failure leaves the goal, the selection and the session's rows unchanged.
Calculation¶
Mojo
struct Calculation(Movable)
Python
from judgment import Calculation
An equality chain with independent named obligations, yielding evidence only through checked completion.
Defined in src/judgment_shell/_dag_proof.mojo.
Calculation.__init__¶
Mojo
def __init__(out self, var data: _DagCalculation)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain a captured chain through _DagProof.calc.
Arguments.
data: The owned endpoints, captured context, and checked or deferred edges.
Calculation.eq¶
Mojo
def eq(mut self, to: Expr, using: Step, label: String = "", premises: List[Step] = List[Step]()) raises LibError
Python
def eq(self, to, using, label="", premises=[])
Append a checked equality, specializing its theorem from both endpoints and explicit premises.
Arguments.
to: The next endpoint in the original captured context.using: Checked local evidence or a theorem step.label: Owned display text with no proof authority.premises: Checked implication premises in order.
Raises.
LibError: For invalid endpoints, evidence, inference, scope, ownership, lifetime, or exhaustion.
Calculation.eq¶
Mojo
def eq(mut self, to: Expr, using: Fact, label: String = "", premises: List[Step] = List[Step]()) raises LibError
Python
def eq(self, to, using, label="", premises=[])
Append a checked equality using a declared theorem.
Arguments.
to: The next endpoint in the original captured context.using: A declared equality or equality theorem.label: Owned display text, which reserves no step name.premises: Checked implication premises in order.
Raises.
LibError: For invalid endpoints, evidence, inference, scope, ownership, lifetime, or exhaustion.
Calculation.change¶
Mojo
def change(mut self, to: Expr, unfold: List[Definition] = List[Definition](), label: String = "") raises LibError
Python
def change(self, to, unfold=[], label='')
Append an endpoint justified only by checked definitional equality.
Arguments.
to: The convertible next expression in the captured context.unfold: Visible definitions explicitly permitted for conversion.label: Owned display text without logical authority.
Raises.
LibError: For unavailable definitions, invalid conversion, scope, type, owner, lifetime, or limits.
Calculation.step¶
Mojo
def step(mut self, name: String, to: Expr) raises LibError -> _DagProof
Python
def step(self, name, to)
Append a named equality obligation without assuming or proving its equality.
Arguments.
name: A nonempty literal name unique among this chain's named steps.to: The next expression, visible in the original captured context.
Returns. An independent proof of the previous endpoint equals to, without a retained fact or publication rights.
Raises.
LibError: For invalid names or endpoints, scope, ownership, lifetime, or exhaustion. Failure appends nothing.
Calculation.obligations¶
Mojo
def obligations(self) raises LibError -> List[Goal]
Python
def obligations(self)
Snapshot open and deferred leaves in chain order, then creation order within each named step.
Returns. Owned goals with step-qualified paths and their actual owning proof identities.
Raises.
LibError: For expired contexts, invalid inspection metadata, or exhausted work. Inspection mutates nothing.
Calculation.select¶
Mojo
def select(self, name: String) raises LibError -> _DagProof
Python
def select(self, name)
Recover the unique outstanding goal with this final path component or main-continuation step name.
Arguments.
name: The literal short name, without parsing.
Returns. A selected step handle with deferred status preserved and no retained fact or publication rights.
Raises.
LibError: SHAPE for ambiguity, NO_MATCH when absent, or for expired contexts or exhausted work.
Calculation.select¶
Mojo
def select(self, path: List[String]) raises LibError -> _DagProof
Python
def select(self, path)
Recover an outstanding goal by its complete literal step-qualified structural path.
Arguments.
path: The step name followed by components returned byobligations.
Returns. A fresh lookup, preserving deferred status. After restoration the same path may identify new work.
Raises.
LibError: NO_MATCH when absent, or for invalid contexts or exhausted work. Lookup changes no state.
Calculation.select¶
Mojo
def select(self, goal: Goal) raises LibError -> _DagProof
Python
def select(self, goal)
Recover the same outstanding goal in its actual owning step, including after rewriting or resumption.
Arguments.
goal: A snapshot from this calculation or a direct step handle.
Returns. That exact goal, never another goal with the same numeric ID or path; no extra authority is granted.
Raises.
LibError: For foreign owners/steps, solved, replaced or restored-away identities, expired contexts, or limits.
Calculation.current¶
Mojo
def current(self) -> Expr
Python
def current(self)
Read the last authored endpoint without asserting any deferred equality.
Returns. The current expression with its original session lifetime.
Calculation.format¶
Mojo
def format(self) raises LibError -> String
Python
def format(self)
Display the chain's literal labels and live checked/open/deferred/solved construction statuses.
Returns. Owned text; solved means no outstanding leaves, not reconstructed or assumption-free evidence.
Raises.
LibError: For expired contexts, endpoints, reasons or solved-leaf evidence, or exhaustion.
Calculation.finish¶
Mojo
def finish(self) raises LibError -> Step
Python
def finish(self)
Reconstruct every solved named step and compose checked equality of the chain's endpoints.
Returns. Local checked evidence, reflexivity for an empty chain. Neither a theorem nor a cached solution is published.
Raises.
LibError: For open/deferred work, inconsistent or expired evidence, or limits. The chain remains retryable.
Checkpoint¶
Mojo
struct Checkpoint(ImplicitlyCopyable)
Python
from judgment import Checkpoint
An owned logical snapshot of one unfinished declared _DagProof, as Checkpoint.
Restoring never refunds work or rolls back the session's rows or declarations. A checkpoint taken inside a transaction expires when that transaction closes, and one that a later return of the session (a checkout or a discard) went below expires too.
Defined in src/judgment_shell/_dag_proof_tactics.mojo.
Checkpoint.__init__¶
Mojo
def __init__(out self, var owner: ArcPointer[_DagProofState], var saved: ArcPointer[_DagProofState], goal: Int, generation: UInt32, counts: Array[UInt32, TABLES])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain a checkpoint through _DagProof.checkpoint.
Arguments.
owner: The exact originating proof.saved: The copied logical state.goal: The originating handle's selected goal.generation: The session's epoch when it was taken.counts: The session's workspace counts when it was taken.
Suggestion¶
Mojo
struct Suggestion(ImplicitlyCopyable)
Python
from judgment import Suggestion
A read-only theorem application candidate with its remaining premises, as Suggestion.
Defined in src/judgment_shell/_dag_proof_rules.mojo.
Suggestion.__init__¶
Mojo
def __init__(out self, var data: ArcPointer[_DagSuggestionData])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain candidates through _DagProof.suggest.
Arguments.
data: The application plan and its originating goal and revision.
Suggestion.name¶
Mojo
def name(self) raises LibError -> String
Python
def name(self)
Read the candidate's registered theorem name.
Returns. An owned name.
Raises.
LibError: On exhausted work.
Suggestion.theorem¶
Mojo
def theorem(self) -> Fact
Python
def theorem(self)
Read the original theorem.
Returns. The unspecialized theorem, not evidence of the current goal.
Suggestion.type_args¶
Mojo
def type_args(self) raises LibError -> List[TypeExpr]
Python
def type_args(self)
Read the type instantiation found by discovery.
Returns. Arguments in the theorem's parameter order.
Raises.
LibError: On exhausted work.
Suggestion.terms¶
Mojo
def terms(self) raises LibError -> List[Expr]
Python
def terms(self)
Read the term instantiation found by discovery.
Returns. Arguments in universal-binder order.
Raises.
LibError: On exhausted work.
Suggestion.premises¶
Mojo
def premises(self) raises LibError -> List[Expr]
Python
def premises(self)
Read the remaining obligations without adding them to the proof.
Returns. Expected premise propositions in application order.
Raises.
LibError: On exhausted work.
Transformation¶
Mojo
struct Transformation(ImplicitlyCopyable)
Python
from judgment import Transformation
An expression and its checked edits in an independent captured proof context.
Defined in src/judgment_shell/_dag_proof_rules.mojo.
Transformation.__init__¶
Mojo
def __init__(out self, var proof: ArcPointer[_DagProofState], input: Expr)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use the private proof transformation factory.
Arguments.
proof: The isolated equality draft.input: Its original expression.
Transformation.input¶
Mojo
def input(self) -> Expr
Python
def input(self)
Read the original expression.
Returns. The immutable starting endpoint.
Transformation.output¶
Mojo
def output(self) raises LibError -> Expr
Python
def output(self)
Read the current endpoint.
Returns. The expression after the checked edits.
Raises.
LibError: For an invalid captured state or exhausted work.
Transformation.focus¶
Mojo
def focus(self) raises LibError -> Focus
Python
def focus(self)
Select the complete current output for an explicit edit.
Returns. A versioned focus in this transformation's equality draft.
Raises.
LibError: For an invalid captured state or exhausted work.
Transformation.at¶
Mojo
def at(self, expression: Expr, occurrence: Int = 0) raises LibError -> Focus
Python
def at(self, expression, occurrence=0)
Select an authored occurrence in the current output.
Arguments.
expression: The subexpression to select.occurrence: One-based occurrence, or zero to require uniqueness.
Returns. A checked versioned occurrence focus.
Raises.
LibError: For ambiguity, no match, invalid ownership or scope, or exhaustion.
Transformation.use¶
Mojo
def use(self, theorem: Step, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Step
Python
def use(self, theorem, type_args=[], terms=[], using=[])
Specialize local evidence in the captured context without editing the expression.
Arguments.
theorem: A visible checked step.type_args: Explicit types; a local step has none.terms: Universal arguments.using: Checked implication premises.
Returns. The specialized local step.
Raises.
LibError: For invalid arguments, ownership or scope, or exhausted work. Failure leaves no rows.
Transformation.use¶
Mojo
def use(self, theorem: Fact, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Step
Python
def use(self, theorem, type_args=[], terms=[], using=[])
Specialize a declared fact in the captured context without editing the expression.
Arguments.
theorem: A visible declared fact.type_args: Explicit types, or omitted for unambiguous inference.terms: Universal arguments.using: Checked implication premises.
Returns. The specialized local step.
Raises.
LibError: For invalid arguments, ownership or scope, or exhausted work. Failure leaves no rows.
Transformation.evidence¶
Mojo
def evidence(self) raises LibError -> Step
Python
def evidence(self)
Reconstruct the checked equality from input to output with every used dependency.
Returns. Equality evidence in the captured frame; no theorem is declared.
Raises.
LibError: For invalid reconstruction or exhausted work. Failure leaves no rows.
Transformation.apply¶
Mojo
def apply(self, fact: Step) raises LibError -> Step
Python
def apply(self, fact)
Transport evidence of the original proposition to the output.
Arguments.
fact: Checked evidence of the original proposition in the captured scope.
Returns. New evidence of the output, retaining the premise and rewrite dependencies.
Raises.
LibError: For a wrong statement, type, context or owner, or exhaustion. Failure leaves no rows.
Transformation.apply¶
Mojo
def apply(self, fact: Fact) raises LibError -> Step
Python
def apply(self, fact)
Transport a declared fact of the original proposition to the output.
Arguments.
fact: A visible monomorphic fact of the original proposition.
Returns. New local evidence of the output with every checked dependency.
Raises.
LibError: Asapplyof a step; a generic fact needs explicit specialization withusefirst.
Transformation.context¶
Mojo
def context(self) raises LibError -> Goal
Python
def context(self)
Inspect the captured variables and assumptions.
Returns. An owned goal snapshot. Its equality target is internal, not an assumed fact.
Raises.
LibError: For invalid captured records or exhausted work.
TheorySnapshot¶
Mojo
struct TheorySnapshot(ImplicitlyCopyable)
Python
from judgment import TheorySnapshot
A point of a Session to return to, wrapped by TheorySnapshot: the workspace's and the engine's marks
and the session's names, facts and imports.
Defined in src/judgment_shell/_ws_transactions.mojo.
TheorySnapshot.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], var data: _SnapshotData)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; snapshots come from Session.snapshot.
Arguments.
state: The session's state.data: What the snapshot restores.
TheorySnapshot.fact¶
Mojo
def fact(self, name: String) raises LibError -> Fact
Python
def fact(self, name)
Look up a registered fact visible in this session.
Arguments.
name: Fact name.
Returns. The checked fact handle.
Raises.
LibError:NO_MATCHif absent, or session errors.
TheorySnapshot.theorem¶
Mojo
def theorem(self, name: String) raises LibError -> _DagProof
Python
def theorem(self, name)
Start a named theorem header on the snapshot's owning session.
Arguments.
name: Fresh theorem name.
Returns. An unfinished proof header.
Raises.
LibError: On invalid name or exhaustion.
TheorySnapshot.theorem¶
Mojo
def theorem(self, name: String, target: Expr) raises LibError -> _DagProof
Python
def theorem(self, name, target)
Start a named theorem with target proposition on the snapshot's owning session.
Arguments.
name: Fresh theorem name.target: Goal proposition.
Returns. An unfinished proof.
Raises.
LibError: On invalid name, target, or exhaustion.
Transaction¶
Mojo
struct Transaction(ImplicitlyCopyable)
Python
from judgment import Transaction
A nested scope of a Session over a child workspace, as Session.transaction: commit or
discard it, innermost first.
Defined in src/judgment_shell/_ws_transactions.mojo.
Transaction.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], open_epoch: UInt32)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; transactions come from Session.transaction.
Arguments.
state: The session's state.open_epoch: The session's epoch when it opened, which names it.
Transaction.discard¶
Mojo
def discard(self) raises LibError
Python
def discard(self)
Discard this transaction and invalidate handles created inside it.
Raises.
LibError:SHAPEfor a closed transaction or one with an open transaction inside;KERNELwhen the workspace refuses.
Transaction.commit¶
Mojo
def commit(self, expressions: List[Expr] = List[Expr](), facts: List[Fact] = List[Fact](), types: List[TypeExpr] = List[TypeExpr](), definitions: List[Definition] = List[Definition](), subsets: List[Subset] = List[Subset](), steps: List[Step] = List[Step](), declarations: List[Declaration] = List[Declaration](), exprs: List[Expr] = List[Expr]()) raises LibError -> Retained
Python
def commit(self, expressions=[], facts=[], types=[], definitions=[], subsets=[], steps=[], declarations=[], exprs=[])
Commit this transaction and return retained replacement handles.
Retained facts and steps always keep their proof rows.
Arguments.
expressions: Expressions to retain.facts: Facts to retain.types: Types to retain.definitions: Definitions to retain.subsets: Subsets to retain.steps: Steps to retain.declarations: Declarations to retain.exprs: Alias forexpressions.
Returns. Replacement handles in the parent scope.
Raises.
LibError:SHAPEfor a closed transaction or one with an open transaction inside;KERNELfor a stale or foreign handle, or a commit the workspace refuses, which discards the scope;LIMITwhen the allowance cannot pay for the commit's adoption, raised before anything changes and leaving the scope open. The adoption is charged what the scope spent (a bound; it may overcharge until adoption translates the engine's caches instead of re-keying): a scope that spent more than half of what remained when it opened cannot commit, and must be discarded.
Retained¶
Mojo
struct Retained(Movable)
Python
from judgment import Retained
What a committed transaction retains: replacement handles in the parent, in the order requested.
Defined in src/judgment_shell/_ws_transactions.mojo.
Retained.__init__¶
Mojo
def __init__(out self)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; returned by Transaction.commit.
Retained.expressions¶
Mojo
def expressions(self) -> List[Expr]
Python
def expressions(self)
Retained expressions in commit order.
Returns. Replacement expression handles.
Retained.types¶
Mojo
def types(self) -> List[TypeExpr]
Python
def types(self)
Retained types in commit order.
Returns. Replacement type handles.
Retained.facts¶
Mojo
def facts(self) -> List[Fact]
Python
def facts(self)
Retained facts in commit order.
Returns. Replacement fact handles.
Retained.steps¶
Mojo
def steps(self) -> List[Step]
Python
def steps(self)
Retained checked steps in commit order.
Returns. Replacement step handles.
Retained.declarations¶
Mojo
def declarations(self) -> List[Declaration]
Python
def declarations(self)
Retained declarations in commit order.
Returns. Replacement declaration handles.
Retained.definitions¶
Mojo
def definitions(self) -> List[Definition]
Python
def definitions(self)
Retained definitions in commit order.
Returns. Replacement definition handles.
Retained.subsets¶
Mojo
def subsets(self) -> List[Subset]
Python
def subsets(self)
Retained subset types in commit order.
Returns. Replacement subset handles.
Subset¶
Mojo
struct Subset(ImplicitlyCopyable)
Python
from judgment import Subset
A subset type of a session (Definition Y-1): its type, its functions and its two laws.
Defined in src/judgment_shell/_ws_handles.mojo.
Subset.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32, kind: Int, abs: Int, rep: Int, abs_rep: Fact, rep_abs: Fact, head: UInt64, name: String, arity: Int, retained: Bool = False)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; subsets come from Session.subset.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: ItsDECLrow.kind: The type's authored row.abs: The abstraction's authored row.rep: The representation's authored row.abs_rep:∀value. abs(rep(value)) = value.rep_abs:∀value. P(value) = (rep(abs(value)) = value).head: The type constructor's head.name: The type's name.arity: Its number of type parameters.retained: Whether a transaction reissued this handle in its parent.
Subset.has_symbol_adapters¶
Mojo
def has_symbol_adapters(self) raises LibError -> Bool
Python
def has_symbol_adapters(self)
Whether the public Subset can expose its generic constructor and Constant handles.
Returns. True for a parameterized subset returned directly by its builder.
Raises.
LibError:KERNELfor a stale subset.
Subset.constructor¶
Mojo
def constructor(self) raises LibError -> TypeConstructor
Python
def constructor(self)
The type constructor κ, as Subset.constructor: a generic subset's type at other arguments.
Returns. The constructor.
Raises.
LibError:KERNELfor a stale handle.
Subset.kind¶
Mojo
def kind(self) raises LibError -> TypeExpr
Python
def kind(self)
The new type, as Subset.kind.
Returns. The type.
Raises.
LibError:KERNELfor a stale handle.
Subset.abstraction¶
Mojo
def abstraction(self) raises LibError -> Expr
Python
def abstraction(self)
abs : σ → κ, as Subset.abstraction.
Returns. The constant.
Raises.
LibError:KERNELfor a stale handle.
Subset.representation¶
Mojo
def representation(self) raises LibError -> Expr
Python
def representation(self)
rep : κ → σ, as Subset.representation.
Returns. The constant.
Raises.
LibError:KERNELfor a stale handle.
Subset.abs_rep¶
Mojo
def abs_rep(self) raises LibError -> Fact
Python
def abs_rep(self)
The law ∀value. abs(rep(value)) = value, the type definition's part 3, as Subset.abs_rep.
Returns. The fact; cite gives it closed.
Raises.
LibError:KERNELfor a stale handle.
Subset.rep_abs¶
Mojo
def rep_abs(self) raises LibError -> Fact
Python
def rep_abs(self)
The law ∀value. P(value) = (rep(abs(value)) = value), part 4, as Subset.rep_abs.
Returns. The fact; cite gives it closed.
Raises.
LibError:KERNELfor a stale handle.
Subset.abstract¶
Mojo
def abstract(self, value: Expr) raises LibError -> Expr
Python
def abstract(self, value)
Apply this subset's abstraction function to a value of its carrier type, as Subset.abstract.
Arguments.
value: Expression of the subset's carrier type.
Returns. abs(value) of this subset type.
Raises.
LibError: On stale/foreign handles, type mismatch, or exhaustion.
Subset.represent¶
Mojo
def represent(self, value: Expr) raises LibError -> Expr
Python
def represent(self, value)
Apply this subset's representation function to a value of this subset type, as Subset.represent.
Arguments.
value: Expression of this subset type.
Returns. rep(value) of the subset's carrier type.
Raises.
LibError: On stale/foreign handles, type mismatch, or exhaustion.
BinderFocus¶
Mojo
struct BinderFocus(ImplicitlyCopyable)
Python
from judgment import BinderFocus
A scoped body transformation committed through checked binder congruence.
Defined in src/judgment_shell/_dag_proof_rules.mojo.
BinderFocus.__init__¶
Mojo
def __init__(out self, var data: ArcPointer[_DagBinderFocusData])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain the scope with Focus.under.
Arguments.
data: The original selection, fresh fix frame, and independent body edits.
BinderFocus.variable¶
Mojo
def variable(self) -> Expr
Python
def variable(self)
Read the fresh variable, valid only within the body context.
Returns. The local expression that checked scope rules prevent from escaping to the parent.
BinderFocus.body¶
Mojo
def body(self) -> Transformation
Python
def body(self)
Read the independent transformation of the opened body.
Returns. A transformation supporting targeted edits and captured-context theorem use.
BinderFocus.finish¶
Mojo
def finish(self) raises LibError -> Focus
Python
def finish(self)
Close the fresh local and commit the edited binder at the original occurrence.
Returns. A refreshed focus in the parent goal.
Raises.
LibError: For a stale parent, repeated finish, escaped conditions, invalid evidence or exhausted work. Failure preserves the parent and leaves the body available for retry.
lambda_¶
Mojo
def lambda_(variable: Expr, body: Expr) raises LibError -> Expr
Python
def lambda_(variable, body)
Build the lambda abstraction λvariable. body.
Arguments.
variable: Bound variable expression.body: Abstraction body.
Returns. Checked lambda expression.
Raises.
LibError: On invalid variable or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
Tactic¶
Mojo
struct Tactic(ImplicitlyCopyable)
Python
from judgment import Tactic
A bounded explicit tactic program of a Session, as Tactic; running it adds no trusted inference.
Defined in src/judgment_shell/_dag_proof_tactics.mojo.
Tactic.__init__¶
Mojo
def __init__(out self, session: ArcPointer[_DagState], var tree: ArcPointer[_DagTacticNode], weight: UInt64)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain primitives through _DagProof.tactics.
Arguments.
session: The session the program belongs to.tree: Its immutable instructions.weight: The construction charge of every instruction, saturating.
Tactic.then¶
Mojo
def then(self, next: Self) raises LibError -> Self
Python
def then(self, next)
Sequence the next tactic on every resulting active subgoal.
Arguments.
next: The tactic applied to each remaining child, in order.
Returns. An atomic sequence; any no-match rolls back the whole attempt.
Raises.
LibError: For foreign tactics or exhausted construction work.
Tactic.or_else¶
Mojo
def or_else(self, alternative: Self) raises LibError -> Self
Python
def or_else(self, alternative)
Try an alternative only when this tactic reports no match.
Arguments.
alternative: The fallback, run from the original logical state.
Returns. An alternative program. Limits and invalid evidence stay visible.
Raises.
LibError: For foreign tactics or exhausted construction work.
Tactic.repeat¶
Mojo
def repeat(self, max_steps: Int = 64) raises LibError -> Self
Python
def repeat(self, max_steps=64)
Repeat with an explicit bound and a logical-progress check.
Arguments.
max_steps: Maximum iterations; zero performs no work on the draft.
Returns. A tactic that stops on no match, no change, closure, or its bound.
Raises.
LibError: For negative bounds or exhausted construction work.
Tactic.all_goals¶
Mojo
def all_goals(self) raises LibError -> Self
Python
def all_goals(self)
Apply this tactic to every active goal in the draft.
Returns. An atomic program. Deferred obligations remain deferred.
Raises.
LibError: On exhausted construction work.
Tactic.require_closed¶
Mojo
def require_closed(self) raises LibError -> Self
Python
def require_closed(self)
Require the entire draft to have no open or deferred obligations.
Returns. A tactic reporting no_match and rolling back unless closure holds.
Raises.
LibError: On exhausted construction work.
Tactics¶
Mojo
struct Tactics(ImplicitlyCopyable)
Python
from judgment import Tactics
Session-owned constructors for explicit tactic values, as Tactics.
Defined in src/judgment_shell/_dag_proof_tactics.mojo.
Tactics.__init__¶
Mojo
def __init__(out self, session: ArcPointer[_DagState])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain a factory through _DagProof.tactics.
Arguments.
session: The session and its request budget.
Tactics.exact¶
Mojo
def exact(self, fact: Step) raises LibError -> Tactic
Python
def exact(self, fact)
Construct a tactic that checks explicit evidence against its goal.
Arguments.
fact: The evidence; invalid evidence is an error, not no_match.
Returns. An exact tactic.
Raises.
LibError: For foreign evidence or exhausted construction work.
Tactics.exact¶
Mojo
def exact(self, fact: Fact) raises LibError -> Tactic
Python
def exact(self, fact)
Construct a tactic that closes its goal with a declared fact.
Arguments.
fact: The fact, checked in each goal's context when the tactic runs.
Returns. An exact tactic.
Raises.
LibError: For a foreign fact or exhausted construction work.
Tactics.exact¶
Mojo
def exact(self, premise: String) raises LibError -> Tactic
Python
def exact(self, premise)
Construct a tactic closing its goal with the premise of this name.
Arguments.
premise: A premise name, looked up in each goal's context when the tactic runs, so it may name one an earlier step introduced.
Returns. A tactic reporting no_match where no premise has the name; otherwise it behaves as exact with that premise's evidence.
Raises.
LibError: For an empty name or exhausted construction work.
Tactics.apply¶
Mojo
def apply(self, theorem: Fact, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Tactic
Python
def apply(self, theorem, type_args=[], terms=[], using=[])
Construct a checked application followed by explicit premise tactics.
Arguments.
theorem: The chosen theorem, checked in each execution.type_args: Complete declared type arguments, or omitted for inference.terms: Universal arguments, as for apply.using: Evidence for a contiguous prefix of implication premises.
Returns. An immutable tactic owning copies of the argument lists. Remaining premises become active children, in order, for a following then. A verified conclusion mismatch is recoverable; ambiguous inference and invalid supplied evidence remain errors, including NO_MATCH errors.
Raises.
LibError: For foreign inputs or exhausted construction work. Execution also checks liveness, visibility, scope, and evidence.
Tactics.apply¶
Mojo
def apply(self, theorem: Step, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Tactic
Python
def apply(self, theorem, type_args=[], terms=[], using=[])
Construct a checked application of a local fact.
Arguments.
theorem: The fact, checked in each execution.type_args: As for apply with a theorem.terms: As for apply with a theorem.using: As for apply with a theorem.
Returns. As apply with a theorem.
Raises.
LibError: As apply with a theorem.
Tactics.apply¶
Mojo
def apply(self, premise: String, type_args: List[TypeExpr] = List[TypeExpr](), terms: List[Expr] = List[Expr](), using: List[Step] = List[Step]()) raises LibError -> Tactic
Python
def apply(self, premise, type_args=[], terms=[], using=[])
Construct a checked application of the premise of this name.
Arguments.
premise: A premise name, looked up in each goal's context when the tactic runs, so it may name one an earlier step introduced.type_args: As for apply with a theorem.terms: As for apply with a theorem.using: As for apply with a theorem.
Returns. A tactic reporting no_match where no premise has the name; otherwise it behaves as apply with that premise's evidence.
Raises.
LibError: For an empty name, foreign inputs, or exhausted construction work.
Tactics.rfl¶
Mojo
def rfl(self) raises LibError -> Tactic
Python
def rfl(self)
Construct a reflexivity tactic with a recoverable nonmatch outcome.
Returns. A tactic closing an equality whose sides convert.
Raises.
LibError: On exhausted construction work.
Tactics.assumption¶
Mojo
def assumption(self) raises LibError -> Tactic
Python
def assumption(self)
Construct an exact visible-assumption tactic.
Returns. A tactic reporting no_match when no assumption matches.
Raises.
LibError: On exhausted construction work.
Tactics.intro¶
Mojo
def intro(self, name: String = "h", fresh: Bool = False) raises LibError -> Tactic
Python
def intro(self, name='h', fresh=False)
Construct an implication- or negation-introduction tactic.
Arguments.
name: The fresh premise name.fresh: In each goal, use the first of name, name_1, name_2, ... that no visible name uses.
Returns. A tactic exposing the premise in its continuation context.
Raises.
LibError: On exhausted construction work.
Tactics.split¶
Mojo
def split(self) raises LibError -> Tactic
Python
def split(self)
Construct a conjunction- or equivalence-splitting tactic.
Returns. A tactic exposing both conjuncts or equivalence directions in order.
Raises.
LibError: On exhausted construction work.
Tactics.choose_left¶
Mojo
def choose_left(self) raises LibError -> Tactic
Python
def choose_left(self)
Construct a tactic selecting a disjunction's left side.
Returns. The explicit left-choice tactic.
Raises.
LibError: On exhausted construction work.
Tactics.choose_right¶
Mojo
def choose_right(self) raises LibError -> Tactic
Python
def choose_right(self)
Construct a tactic selecting a disjunction's right side.
Returns. The explicit right-choice tactic.
Raises.
LibError: On exhausted construction work.
Tactics.skip¶
Mojo
def skip(self) raises LibError -> Tactic
Python
def skip(self)
Construct an applicable tactic that makes no logical change.
Returns. A no-change tactic useful in explicit alternatives.
Raises.
LibError: On exhausted construction work.
Tactics.rw¶
Mojo
def rw(self, equality: Step) raises LibError -> Tactic
Python
def rw(self, equality)
Construct an explicit rewrite of an equality goal's left side.
Arguments.
equality: A specialized equality whose left endpoint must match.
Returns. A tactic retaining checked congruence and reporting endpoint misses as no_match.
Raises.
LibError: For foreign evidence or exhausted construction work.
Tactics.rw¶
Mojo
def rw(self, equality: Fact) raises LibError -> Tactic
Python
def rw(self, equality)
Construct an explicit rewrite of an equality goal's left side by a declared equality.
Arguments.
equality: A monomorphic equality theorem whose left endpoint must match.
Returns. A tactic retaining checked congruence and reporting endpoint misses as no_match.
Raises.
LibError: For a foreign fact or exhausted construction work.
Tactics.rw¶
Mojo
def rw(self, premise: String) raises LibError -> Tactic
Python
def rw(self, premise)
Construct a rewrite of an equality goal's left side by the premise of this name.
Arguments.
premise: The name of an equality premise, looked up in each goal's context when the tactic runs.
Returns. A tactic reporting no_match where no premise has the name; otherwise it behaves as rw with that premise's evidence.
Raises.
LibError: For an empty name or exhausted construction work.
Tactics.intro_var¶
Mojo
def intro_var(self, name: String = "x", fresh: Bool = False) raises LibError -> Tactic
Python
def intro_var(self, name='x', fresh=False)
Construct a universal-introduction tactic.
Arguments.
name: The fresh variable name; variable(name) finds it afterwards.fresh: In each goal, use the first of name, name_1, name_2, ... that no visible name uses.
Returns. A tactic reporting no_match unless its goal is universal.
Raises.
LibError: On exhausted construction work. Running it refuses an invalid name as intro_var does.
Tactics.witness¶
Mojo
def witness(self, value: Expr) raises LibError -> Tactic
Python
def witness(self, value)
Construct an existential-introduction tactic with an explicit witness.
Arguments.
value: The witness, checked in each goal's context when the tactic runs.
Returns. A tactic reporting no_match unless its goal is existential over the witness's type; a witness out of scope is an error, as for witness.
Raises.
LibError: For a foreign witness or exhausted construction work.
Tactics.witness¶
Mojo
def witness(self, variable: String) raises LibError -> Tactic
Python
def witness(self, variable)
Construct an existential-introduction tactic witnessed by the variable of this name.
Arguments.
variable: A variable name, looked up in each goal's context when the tactic runs.
Returns. A tactic reporting no_match where no variable has the name or the goal is not existential over its type.
Raises.
LibError: For an empty name or exhausted construction work.
Tactics.cases¶
Mojo
def cases(self, disjunction: Step, left_name: String = "left", right_name: String = "right") raises LibError -> Tactic
Python
def cases(self, disjunction, left_name="left", right_name="right")
Construct a case analysis on disjunction evidence.
Arguments.
disjunction: The evidence, checked in each goal's context when the tactic runs.left_name: The left branch's assumption name.right_name: The right branch's assumption name.
Returns. A tactic leaving the left and then the right branch active, each with the original target and its named assumption. Evidence that is not a visible disjunction is an error, as for cases.
Raises.
LibError: For foreign evidence or exhausted construction work.
Tactics.cases¶
Mojo
def cases(self, premise: String, left_name: String = "left", right_name: String = "right") raises LibError -> Tactic
Python
def cases(self, premise, left_name="left", right_name="right")
Construct a case analysis on the disjunction premise of this name.
Arguments.
premise: A premise name, looked up in each goal's context when the tactic runs.left_name: The left branch's assumption name.right_name: The right branch's assumption name.
Returns. A tactic reporting no_match where no premise has the name; otherwise it behaves as cases with that premise's evidence.
Raises.
LibError: For an empty name or exhausted construction work.
Tactics.obtain¶
Mojo
def obtain(self, existence: Step, name: String = "w", property: String = "", fresh: Bool = False) raises LibError -> Tactic
Python
def obtain(self, existence, name="w", property="", fresh=False)
Construct an existential elimination of explicit evidence.
Arguments.
existence: The evidence, checked in each goal's context when the tactic runs.name: The witness's fresh name; variable(name) finds it afterwards.property: The property assumption's name, or empty for none; fact(property) finds it.fresh: In each goal, freshen the witness's and the property's names as obtain(..., fresh=True) does.
Returns. A tactic continuing its goal with the witness and its property in scope.
Raises.
LibError: For foreign evidence or exhausted construction work.
Tactics.obtain¶
Mojo
def obtain(self, premise: String, name: String = "w", property: String = "", fresh: Bool = False) raises LibError -> Tactic
Python
def obtain(self, premise, name="w", property="", fresh=False)
Construct an existential elimination of the premise of this name.
Arguments.
premise: A premise name, looked up in each goal's context when the tactic runs.name: The witness's fresh name.property: The property assumption's name, or empty for none.fresh: In each goal, freshen the witness's and the property's names.
Returns. A tactic reporting no_match where no premise has the name; otherwise it behaves as obtain with that premise's evidence.
Raises.
LibError: For an empty name or exhausted construction work.
Tactics.have¶
Mojo
def have(self, name: String, proposition: Expr) raises LibError -> Tactic
Python
def have(self, name, proposition)
Construct a named intermediate claim.
Arguments.
name: The claim's fresh name; fact(name) finds its premise in the continuation.proposition: The claim, checked in each goal's context when the tactic runs.
Returns. A tactic leaving the claim and then the continuation active.
Raises.
LibError: For a foreign proposition or exhausted construction work.
Tactics.define¶
Mojo
def define(self, name: String, body: Expr) raises LibError -> Tactic
Python
def define(self, name, body)
Construct a local definition.
Arguments.
name: The symbol's fresh name; variable(name) finds it afterwards.body: The abbreviated expression, checked in each goal's context.
Returns. A tactic continuing its goal in the definition's scope.
Raises.
LibError: For a foreign body or exhausted construction work.
Tactics.change¶
Mojo
def change(self, target: Expr, unfold: List[Definition] = List[Definition]()) raises LibError -> Tactic
Python
def change(self, target, unfold=[])
Construct a replacement of the target by a convertible one.
Arguments.
target: The replacement proposition.unfold: Transparent definitions the conversion may unfold.
Returns. A tactic reporting no_match where the replacement does not convert to the target; scope errors are errors.
Raises.
LibError: For foreign inputs or exhausted construction work.
Tactics.unfold¶
Mojo
def unfold(self, definition: Definition) raises LibError -> Tactic
Python
def unfold(self, definition)
Construct an expansion of a definition at the target's head.
Arguments.
definition: The definition to expand.
Returns. A tactic reporting no_match where the target's head is another.
Raises.
LibError: For a foreign definition or exhausted construction work.
Tactics.unfold¶
Mojo
def unfold(self, symbol: Expr) raises LibError -> Tactic
Python
def unfold(self, symbol)
Construct an expansion of a local definition at the target's head.
Arguments.
symbol: A symbol returned by define.
Returns. A tactic reporting no_match where the target's head is another.
Raises.
LibError: For a foreign symbol or exhausted construction work.
Tactics.refine¶
Mojo
def refine(self, plan: ProofRecipe) raises LibError -> Tactic
Python
def refine(self, plan)
Construct a checked refinement leaving its named holes active in recipe order.
Arguments.
plan: The partial recipe, checked against each selected goal when the tactic runs.
Returns. A tactic reporting no_match only for a well-typed recipe with another conclusion.
Raises.
LibError: For foreign recipe ownership or exhausted construction work.
Tactics.sorry¶
Mojo
def sorry(self) raises LibError -> Tactic
Python
def sorry(self)
Construct a tactic deferring its goal without evidence.
Returns. A tactic leaving its goal deferred: not active, and blocking finish.
Raises.
LibError: On exhausted construction work.
TacticReport¶
Mojo
struct TacticReport(ImplicitlyCopyable)
Python
from judgment import TacticReport
The outcome of an atomic tactic attempt, separate from checked evidence, as TacticReport.
Defined in src/judgment_shell/_dag_proof_tactics.mojo.
TacticReport.__init__¶
Mojo
def __init__(out self, var status: String, changed: Bool, var goals: List[List[String]] = List[List[String]](), work: UInt64 = 0)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor for an execution report.
Arguments.
status: One of solved, progress, no_change, no_match, or resource_exhausted.changed: Whether the public logical state changed.goals: Paths of the goals the attempt leaves active.work: Authoring work the attempt spent.
TacticReport.goals¶
Mojo
def goals(self) -> List[List[String]]
Python
def goals(self)
Read the paths of the goals the attempt leaves active, in order.
Returns. Paths from the theorem root, the first being the one the handle selects afterwards; empty when the attempt changed nothing or closed every goal it reached.
TacticReport.work_spent¶
Mojo
def work_spent(self) -> UInt64
Python
def work_spent(self)
Read the authoring work the attempt spent.
Returns. Work units charged by the attempt, including a failed or exhausted one and reading the remaining goals' paths.
TacticReport.status¶
Mojo
def status(self) -> String
Python
def status(self)
Read the explicit execution outcome.
Returns. A status label; solved still requires finish for theorem publication.
TacticReport.changed¶
Mojo
def changed(self) -> Bool
Python
def changed(self)
Report whether the draft changed.
Returns. False for no_change, no_match, and resource_exhausted, and for a trial.
Constant¶
Mojo
struct Constant(ImplicitlyCopyable)
Python
from judgment import Constant
A declared constant with an ordered type header and a pinned declaration lifetime.
Defined in src/judgment_shell/_dag_constants.mojo.
Constant.__init__¶
Mojo
def __init__(out self, var data: ArcPointer[_DagConstantData])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; finish a constant builder.
Arguments.
data: The checked formal symbol, pinned declaration and parameter order.
Constant.symbol¶
Mojo
def symbol(self, type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Expr
Python
def symbol(self, type_args=[])
Instantiate the original declaration at explicit types in header order.
Arguments.
type_args: One live type per header parameter; rigid variables must share one proof scope.
Returns. The checked constant instance, callable when its type is a function.
Raises.
LibError: For a stale declaration, wrong count, foreign or stale types, incompatible rigid scopes, a refused instance or exhaustion. Failure leaves no rows.
Constant.is_overloaded¶
Mojo
def is_overloaded(self) -> Bool
Python
def is_overloaded(self)
Report whether the declaration admits checked instance definitions.
Returns. True for an overloaded constant, False for an ordinary generic constant.
ConstantBuilder¶
Mojo
struct ConstantBuilder(Movable)
Python
from judgment import ConstantBuilder
A type-only header for a generic or overloaded constant; every parameter must occur in its type.
Defined in src/judgment_shell/_dag_constants.mojo.
ConstantBuilder.__init__¶
Mojo
def __init__(out self, var header: _DagProof, overloaded: Bool)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use dag_constant.
Arguments.
header: The existing proof header that owns the type parameters.overloaded: Whether the declaration admits instance definitions.
ConstantBuilder.type_var¶
Mojo
def type_var(mut self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Declare a type parameter in header order.
Arguments.
name: A fresh header name.sort: Explicit class constraints; empty by default.
Returns. This header's rigid type parameter.
Raises.
LibError: For an invalid name, a finished or stale header, foreign classes or exhaustion.
ConstantBuilder.finish¶
Mojo
def finish(mut self, kind: TypeExpr) raises LibError -> Constant
Python
def finish(self, kind)
Declare a constant whose type uses exactly this header's type parameters.
Arguments.
kind: A live session type using every header parameter and no other type variables.
Returns. The pinned constant; symbol takes its instances in header order.
Raises.
LibError: For an unused or foreign parameter, invalid ownership/lifetime, duplicate name, finished header, refused declaration or exhaustion. Failure leaves the header open and declares nothing.
Specification¶
Mojo
struct Specification(Copyable, Movable)
Python
from judgment import Specification
A specification of a session (Definition Y-2): its constants and its law.
Defined in src/judgment_shell/_ws_handles.mojo.
Specification.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32, var constants: List[Int], law: Fact)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; specifications come from Session.specification.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: ItsDECLrow.constants: The constants' authored rows, in order.law: Its law.
Specification.constants¶
Mojo
def constants(self) raises LibError -> List[Expr]
Python
def constants(self)
The specified constants, one per name, each at its own type parameters, as Specification.constants.
Returns. The constants.
Raises.
LibError:KERNELfor a stale handle;LIMITbefore allocating the result.
Specification.symbol_type_params¶
Mojo
def symbol_type_params(self, index: Int) raises LibError -> List[TypeExpr]
Python
def symbol_type_params(self, index)
Read a specified symbol's header in the witness's declared order (Definition Y-2).
Arguments.
index: Zero-based position inconstants().
Returns. An independent list, filtered to the variables of this symbol's type.
Raises.
LibError:SHAPEfor an invalid index;KERNELfor a stale specification;LIMIT.
Specification.law¶
Mojo
def law(self) raises LibError -> Fact
Python
def law(self)
The law φ[c̄/v̄], as Specification.law; cite takes it.
Returns. The fact.
Raises.
LibError:KERNELfor a stale handle.
TypeConstructor¶
Mojo
struct TypeConstructor(ImplicitlyCopyable)
Python
from judgment import TypeConstructor
A type constructor κ of a session.
Defined in src/judgment_shell/_ws_handles.mojo.
TypeConstructor.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32, head: UInt64, name: String, arity: Int)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; constructors come from Session.type_constructor.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: ItsDECLrow.head: Its head.name: Its name.arity: Its number of type arguments.
TypeConstructor.name¶
Mojo
def name(self) raises LibError -> String
Python
def name(self)
The constructor's name.
Returns. The name.
Raises.
LibError:KERNELfor a stale handle.
TypeConstructor.arity¶
Mojo
def arity(self) raises LibError -> Int
Python
def arity(self)
The constructor's number of type arguments.
Returns. The arity.
Raises.
LibError:KERNELfor a stale handle.
TypeConstructor.apply¶
Mojo
def apply(self, args: List[TypeExpr]) raises LibError -> TypeExpr
Python
def apply(self, args)
The type κ(τ̄), as TypeConstructor.apply.
Arguments.
args: One type per argument, with rigid variables from at most one proof header.
Returns. The type.
Raises.
LibError:SHAPEfor incompatible proof headers, another number of arguments or a merged fork's constructor;KERNELfor a stale handle;WRONG_KERNELfor another session's type;LIMIT.
Class¶
Mojo
struct Class(ImplicitlyCopyable)
Python
from judgment import Class
A class of a session (Definition Y-8).
Defined in src/judgment_shell/_ws_handles.mojo.
Class.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32, name: String)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; classes come from ClassBuilder.finish and Session.import_class.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: ItsDECLrow.name: Its name.
Class.name¶
Mojo
def name(self) raises LibError -> String
Python
def name(self)
The class's name.
Returns. The name.
Raises.
LibError:KERNELfor a stale handle.
Class.membership¶
Mojo
def membership(self, kind: TypeExpr) raises LibError -> Expr
Python
def membership(self, kind)
The proposition that a type belongs to the class, class.c(TYPE[τ]), as Class.membership; evidence of
nothing.
Arguments.
kind: A type of this session.
Returns. The proposition.
Raises.
LibError:KERNELfor a stale handle;WRONG_KERNELfor another session's type;LIMIT.
Class.token¶
Mojo
def token(self, kind: TypeExpr) raises LibError -> Expr
Python
def token(self, kind)
A type's token TYPE[τ] (Definition Y-7), the argument of membership's predicate.
Arguments.
kind: A type of this session.
Returns. The token.
Raises.
LibError:KERNELfor a stale handle;WRONG_KERNELfor another session's type;LIMIT.
Class.predicate¶
Mojo
def predicate(self) raises LibError -> Expr
Python
def predicate(self)
The class predicate class.c as a constant, an instance at Prop. It is not a transparent definition:
Session.convert does not unfold it; a membership is proved from definition_at.
Returns. The predicate.
Raises.
LibError:KERNELfor a stale handle;LIMIT.
Class.definition¶
Mojo
def definition(self) raises LibError -> Step
Python
def definition(self)
The class predicate's defining equation, ⊢ class.c = λt. ⟨the class's axioms at t⟩ (Definition Y-8), as an
article's definitionThm of it gives it.
The equation is over the predicate's type variable; definition_at(τ) gives it at a type, from which a
membership is proved under the base frame: congruence with
eq_refl(base, token(τ)), β (convert), eq_sym, and eq_subst along λb. b onto evidence of the axioms at
τ (truth for a class without axioms), then β.
Returns. The equation, under the base frame (transported there when the engine made it at its top).
Raises.
LibError:KERNELfor a stale handle or a refused row;UNSUPPORTEDfor an equation the session cannot author;LIMIT.
Class.definition_at¶
Mojo
def definition_at(self, kind: TypeExpr) raises LibError -> Step
Python
def definition_at(self, kind)
The class predicate's defining equation at a type τ: ⊢ class.c = λt. ⟨the axioms at t⟩ with the
predicate's type variable instantiated at τ (Definition Q-8's inst), so that app_thm with
refl(token(τ)) applies it to τ's token.
Arguments.
kind: The type τ.
Returns. The equation at τ, under the base frame.
Raises.
LibError:KERNELfor a stale handle or a refused row;WRONG_KERNELfor another session's type;UNSUPPORTEDfor an equation the session cannot author;LIMIT;KERNELtoo for a stored equation with other than the predicate's one type variable. The session's rows are then unchanged; work charged before the refusal (reading the equation's type variables) stays spent.
Class.intro¶
Mojo
def intro(self) raises LibError -> Fact
Python
def intro(self)
Read (deriving and publishing once if needed) the generic introduction law for this class.
Returns. [α] ⊢ class.c₁(TYPE[α]) ∧ … ∧ A(α) → class.c(TYPE[α]).
Raises.
LibError: On stale class or exhaustion.
Class.elim¶
Mojo
def elim(self) raises LibError -> Fact
Python
def elim(self)
Read (deriving and publishing once if needed) the generic elimination law for this class.
Returns. [α] ⊢ class.c(TYPE[α]) → class.c₁(TYPE[α]) ∧ … ∧ A(α).
Raises.
LibError: On stale class or exhaustion.
ClassBuilder¶
Mojo
struct ClassBuilder(Movable)
Python
from judgment import ClassBuilder
A class being declared: its type variable, superclasses and overloaded parameters, then finish with its
axiom. parameter returns a pinned Constant.
Defined in src/judgment_shell/_ws_handles.mojo.
ClassBuilder.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], name: String)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; builders come from Session.class_.
Arguments.
state: The session's state.name: The class's name.
ClassBuilder.type_var¶
Mojo
def type_var(mut self, name: String) raises LibError -> TypeExpr
Python
def type_var(self, name)
Declare the class's unique unsorted type variable α.
Arguments.
name: Variable name.
Returns. The class's type variable.
Raises.
LibError:SHAPEfor a second type variable, an empty name or a finished class;LIMIT.
ClassBuilder.bound_var¶
Mojo
def bound_var(self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def bound_var(self, name, kind)
Create a bound variable for quantifying the class axiom.
Arguments.
name: Variable name.kind: Variable type.
Returns. The bound variable expression.
Raises.
LibError:SHAPEfor a finished class or duplicate variable name;KERNELfor stale handles;LIMIT.
ClassBuilder.superclass¶
Mojo
def superclass(mut self, class_: Class) raises LibError
Python
def superclass(self, class_)
Add a direct superclass (deduplicated in first-occurrence order).
Arguments.
class_: Superclass of this session.
Raises.
LibError:SHAPEfor a finished class;KERNELfor a stale class or builder;WRONG_KERNELfor another session's.
ClassBuilder.parameter¶
Mojo
def parameter(mut self, name: String, kind: TypeExpr) raises LibError -> Constant
Python
def parameter(self, name, kind)
Declare an overloaded parameter of the class and return it as a Constant.
Arguments.
name: Fresh parameter name.kind: Type mentioning the class's type variable and no other.
Returns. The overloaded constant handle supporting .symbol([τ]).
Raises.
LibError: On missingtype_var, invalid name/type, or exhaustion.
ClassBuilder.finish¶
Mojo
def finish(mut self, axiom: Expr) raises LibError -> Class
Python
def finish(self, axiom)
Declare the class with its axiom, publish its generic intro/elim laws, and return its Class handle.
Arguments.
axiom: Closed class axiom over the class's type variable.
Returns. The declared class handle (with published intro() and elim() laws).
Raises.
LibError:SHAPEbeforetype_var, for an open axiom or a finished class;KERNELfor another type variable, a superclass that is not visible, a used name, a stale handle or a refused row;WRONG_KERNELfor another session's axiom;LIMIT. Failure leaves the session as it was, its parameters declared.
InstanceDefinitionBuilder¶
Mojo
struct InstanceDefinitionBuilder(Movable)
Python
from judgment import InstanceDefinitionBuilder
An instance definition with type parameters being made in a session: its parameters, then finish with the
type arguments and the body.
Defined in src/judgment_shell/_ws_handles.mojo.
InstanceDefinitionBuilder.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], constant: Expr)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; builders come from Session.instance_definition(constant).
Arguments.
state: The session's state.constant: The overloaded constant at its declared type.
InstanceDefinitionBuilder.type_var¶
Mojo
def type_var(mut self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Declare a type parameter of the instance, as InstanceDefinitionBuilder.type_var.
Arguments.
name: A name no other parameter of this definition uses.sort: Its classes; empty by default.
Returns. The parameter, for the type arguments and the body.
Raises.
LibError:SHAPEfor a repeated or empty name; asSession.type_var.
InstanceDefinitionBuilder.finish¶
Mojo
def finish(mut self, type_args: List[TypeExpr], body: Expr) raises LibError -> Fact
Python
def finish(self, type_args, body)
Declare c[τ̄] = body, generic over the parameters, as InstanceDefinitionBuilder.finish.
Arguments.
type_args: One type per parameter of the constant, built from the session's types and the parameters.body: A closed expression of the constant's type at those arguments.
Returns. The equation.
Raises.
LibError:SHAPEfor a parameter missing from the type arguments; asSession.instance_definition.
SubsetBuilder¶
Mojo
struct SubsetBuilder(Movable)
Python
from judgment import SubsetBuilder
A generic subset type being defined in a session: its type parameters, then finish with the predicate and the
nonemptiness witness.
Defined in src/judgment_shell/_ws_handles.mojo.
SubsetBuilder.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], name: String)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; builders come from Session.subset(name).
Arguments.
state: The session's state.name: The type's name.
SubsetBuilder.type_var¶
Mojo
def type_var(mut self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Declare a type parameter of the subset, as SubsetBuilder.type_var.
Arguments.
name: A name no other parameter of this subset uses.sort: Its classes; empty by default.
Returns. The parameter, for the predicate.
Raises.
LibError:SHAPEfor a repeated or empty name; asSession.type_var.
SubsetBuilder.bound_var¶
Mojo
def bound_var(self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def bound_var(self, name, kind)
A variable for the predicate's binders, as SubsetBuilder.bound_var.
Arguments.
name: A fresh name.kind: Its type.
Returns. The variable.
Raises.
LibError: AsSession.bound_var.
SubsetBuilder.finish¶
Mojo
def finish(mut self, predicate: Expr, inhabited: Fact, abs_name: Optional[String] = None, rep_name: Optional[String] = None) raises LibError -> Subset
Python
def finish(self, predicate, inhabited, abs_name=None, rep_name=None)
Define the generic subset κ(ᾱ), as SubsetBuilder.finish.
Arguments.
predicate: A closed λ of typeσ → Propwhose type variables are exactly the parameters.inhabited: A theorem (or an axiom) stating∃x:σ. predicate(x), over type variables of its own: its key form is compared (Proposition I-5).abs_name: The abstraction function's name;<name>_absby default.rep_name: The representation function's name;<name>_repby default.
Returns. The subset; kind() is κ(ᾱ) and constructor() gives it at other arguments.
Raises.
LibError:SHAPEwithout parameters (useSession.subset(name, predicate, inhabited)); asSession.subset, the kernel refusing a predicate with another type variable or a witness of another statement.
TacticData¶
Mojo
struct TacticData(ImplicitlyCopyable, Movable, Deinitable)
Python
from judgment import TacticData
An owned, immutable tactic program with no session reference.
It mirrors the Tactics steps and combinators with names, ExprData, and TypeData in place of session values. Proof.compile turns it into a Tactic; names are resolved when each step runs, in each selected goal. An absent name makes that step report no_match; ill-typed or ambiguous data raises a typed error. Data is never evidence: every step runs the checked step it describes. Values are shared by reference count and can cross threads.
Defined in src/judgment_shell/tactic_data.mojo.
TacticData.__init__¶
Mojo
def __init__(out self, var node: _TacticDataNode)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use the static constructors.
Arguments.
node: The immutable node.
TacticData.__init__¶
Mojo
def __init__(out self, *, shared: ArcPointer[_TacticDataNode])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor sharing an existing node.
Arguments.
shared: The node.
TacticData.intro¶
Mojo
@staticmethod
def intro(name: String = "h", fresh: Bool = False) -> TacticData
Python
@staticmethod
def intro(name='h', fresh=False)
Describe Tactics.intro.
Arguments.
name: The premise name.fresh: Freshen the name in each goal.
Returns. The step.
TacticData.intro_var¶
Mojo
@staticmethod
def intro_var(name: String = "x", fresh: Bool = False) -> TacticData
Python
@staticmethod
def intro_var(name='x', fresh=False)
Describe Tactics.intro_var.
Arguments.
name: The variable name.fresh: Freshen the name in each goal.
Returns. The step.
TacticData.split¶
Mojo
@staticmethod
def split() -> TacticData
Python
@staticmethod
def split()
Describe Tactics.split.
Returns. The step.
TacticData.choose_left¶
Mojo
@staticmethod
def choose_left() -> TacticData
Python
@staticmethod
def choose_left()
Describe Tactics.choose_left.
Returns. The step.
TacticData.choose_right¶
Mojo
@staticmethod
def choose_right() -> TacticData
Python
@staticmethod
def choose_right()
Describe Tactics.choose_right.
Returns. The step.
TacticData.witness¶
Mojo
@staticmethod
def witness(value: ExprData) -> TacticData
Python
@staticmethod
def witness(value)
Describe Tactics.witness.
Arguments.
value: The witness, resolved in each goal.
Returns. The step.
TacticData.cases¶
Mojo
@staticmethod
def cases(evidence: String, left_name: String = "left", right_name: String = "right") -> TacticData
Python
@staticmethod
def cases(evidence, left_name='left', right_name='right')
Describe Tactics.cases.
Arguments.
evidence: A premise name, else a registered theorem's name.left_name: The left branch's assumption name.right_name: The right branch's assumption name.
Returns. The step.
TacticData.obtain¶
Mojo
@staticmethod
def obtain(evidence: String, name: String = "w", property: String = "", fresh: Bool = False) -> TacticData
Python
@staticmethod
def obtain(evidence, name='w', property='', fresh=False)
Describe Tactics.obtain.
Arguments.
evidence: A premise name, else a registered theorem's name.name: The witness's name.property: The property's name, or empty.fresh: Freshen the names in each goal.
Returns. The step.
TacticData.have¶
Mojo
@staticmethod
def have(name: String, proposition: ExprData) -> TacticData
Python
@staticmethod
def have(name, proposition)
Describe Tactics.have.
Arguments.
name: The claim's name.proposition: The claim, resolved in each goal.
Returns. The step.
TacticData.define¶
Mojo
@staticmethod
def define(name: String, body: ExprData) -> TacticData
Python
@staticmethod
def define(name, body)
Describe Tactics.define.
Arguments.
name: The local definition's name.body: Its body, resolved in each goal.
Returns. The step.
TacticData.exact¶
Mojo
@staticmethod
def exact(evidence: String) -> TacticData
Python
@staticmethod
def exact(evidence)
Describe Tactics.exact.
Arguments.
evidence: A premise name, else a registered theorem's name.
Returns. The step.
TacticData.apply¶
Mojo
@staticmethod
def apply(theorem: String, type_args: List[TypeData] = List[TypeData](), terms: List[ExprData] = List[ExprData](), using: List[String] = List[String]()) -> TacticData
Python
@staticmethod
def apply(theorem, type_args=[], terms=[], using=[])
Describe Tactics.apply.
Arguments.
theorem: A premise name, else a registered theorem's name.type_args: Explicit type arguments.terms: Explicit leading terms.using: Premise or theorem names discharging leading premises.
Returns. The step.
TacticData.rfl¶
Mojo
@staticmethod
def rfl() -> TacticData
Python
@staticmethod
def rfl()
Describe Tactics.rfl.
Returns. The step.
TacticData.assumption¶
Mojo
@staticmethod
def assumption() -> TacticData
Python
@staticmethod
def assumption()
Describe Tactics.assumption.
Returns. The step.
TacticData.rw¶
Mojo
@staticmethod
def rw(equality: String) -> TacticData
Python
@staticmethod
def rw(equality)
Describe Tactics.rw.
Arguments.
equality: A premise name, else a registered theorem's name.
Returns. The step.
TacticData.change¶
Mojo
@staticmethod
def change(target: ExprData, unfold: List[String] = List[String]()) -> TacticData
Python
@staticmethod
def change(target, unfold=[])
Describe Tactics.change.
Arguments.
target: The replacement goal, resolved in each goal.unfold: Names of global definitions conversion may expand.
Returns. The step.
TacticData.unfold¶
Mojo
@staticmethod
def unfold(definition: String) -> TacticData
Python
@staticmethod
def unfold(definition)
Describe Tactics.unfold.
Arguments.
definition: A local definition visible in the goal, else a global definition.
Returns. The step.
TacticData.sorry¶
Mojo
@staticmethod
def sorry() -> TacticData
Python
@staticmethod
def sorry()
Describe Tactics.sorry.
Returns. The step.
TacticData.skip¶
Mojo
@staticmethod
def skip() -> TacticData
Python
@staticmethod
def skip()
Describe Tactics.skip.
Returns. The step.
TacticData.then¶
Mojo
def then(self, next: TacticData) -> TacticData
Python
def then(self, next)
Describe Tactic.then.
Arguments.
next: The program for each goal this one leaves.
Returns. The sequence.
TacticData.or_else¶
Mojo
def or_else(self, alternative: TacticData) -> TacticData
Python
def or_else(self, alternative)
Describe Tactic.or_else.
Arguments.
alternative: The program tried when this one does not match.
Returns. The choice.
TacticData.repeat¶
Mojo
def repeat(self, max_steps: Int = 64) -> TacticData
Python
def repeat(self, max_steps=64)
Describe Tactic.repeat.
Arguments.
max_steps: The bound; a negative one is refused when compiled.
Returns. The repetition.
TacticData.all_goals¶
Mojo
def all_goals(self) -> TacticData
Python
def all_goals(self)
Describe Tactic.all_goals.
Returns. The program over every active goal.
TacticData.require_closed¶
Mojo
def require_closed(self) -> TacticData
Python
def require_closed(self)
Describe Tactic.require_closed.
Returns. The program that must close the whole draft.
ExprData¶
Mojo
struct ExprData(ImplicitlyCopyable, Movable, Deinitable)
Python
from judgment import ExprData
An owned, immutable description of an expression, with no session reference.
Nothing is parsed and display strings are never input. Names are resolved when a data program runs, in the selected goal: an enclosing binder of the description, then a visible local or header parameter of the goal, then a global of the goal's theory. Values are shared by reference count and can cross threads.
Defined in src/judgment_shell/tactic_data.mojo.
ExprData.__init__¶
Mojo
def __init__(out self, var node: _ExprNode)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use the static constructors.
Arguments.
node: The immutable node.
ExprData.__init__¶
Mojo
def __init__(out self, *, shared: ArcPointer[_ExprNode])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor sharing an existing node.
Arguments.
shared: The node.
ExprData.name¶
Mojo
@staticmethod
def name(name: String) -> ExprData
Python
@staticmethod
def name(name)
Describe a variable, parameter, or constant by name.
Arguments.
name: The name to resolve in each goal.
Returns. The description.
ExprData.app¶
Mojo
@staticmethod
def app(function: ExprData, args: List[ExprData]) -> ExprData
Python
@staticmethod
def app(function, args)
Describe a function applied to arguments.
Arguments.
function: The function.args: Its arguments, in order.
Returns. The description.
ExprData.forall¶
Mojo
@staticmethod
def forall(variable: String, type: TypeData, body: ExprData) -> ExprData
Python
@staticmethod
def forall(variable, type, body)
Describe a universal statement.
Arguments.
variable: The bound variable's name, visible in the body.type: Its type.body: The quantified proposition.
Returns. The description of ∀variable:type. body.
ExprData.exists¶
Mojo
@staticmethod
def exists(variable: String, type: TypeData, body: ExprData) -> ExprData
Python
@staticmethod
def exists(variable, type, body)
Describe an existential statement.
Arguments.
variable: The bound variable's name, visible in the body.type: Its type.body: The quantified proposition.
Returns. The description of ∃variable:type. body.
ExprData.lambda_¶
Mojo
@staticmethod
def lambda_(variable: String, type: TypeData, body: ExprData) -> ExprData
Python
@staticmethod
def lambda_(variable, type, body)
Describe a function by abstraction.
Arguments.
variable: The bound variable's name, visible in the body.type: Its type.body: The function's value.
Returns. The description of λvariable:type. body.
ExprData.infix¶
Mojo
@staticmethod
def infix(symbol: String, left: ExprData, right: ExprData) -> ExprData
Python
@staticmethod
def infix(symbol, left, right)
Describe an infix operation.
Arguments.
symbol: =, ∧, ∨, →, ↔ for the logical core, or +, *, - through the operands' arithmetic profile.left: The left operand.right: The right operand.
Returns. The description.
ExprData.prefix¶
Mojo
@staticmethod
def prefix(symbol: String, operand: ExprData) -> ExprData
Python
@staticmethod
def prefix(symbol, operand)
Describe a prefix operation.
Arguments.
symbol: ¬ for negation, or - through the operand's arithmetic profile.operand: The operand.
Returns. The description.
ExprData.integer¶
Mojo
@staticmethod
def integer(value: Int) -> ExprData
Python
@staticmethod
def integer(value)
Describe an integer numeral, typed by the other operand of an infix operation.
Arguments.
value: The numeral.
Returns. The description.
ExprData.rational¶
Mojo
@staticmethod
def rational(numerator: Int, denominator: Int) -> ExprData
Python
@staticmethod
def rational(numerator, denominator)
Describe a rational numeral.
Rational numerals describe goals faithfully; running one is not supported yet and raises UNSUPPORTED.
Arguments.
numerator: Its numerator.denominator: Its denominator.
Returns. The description.
ExprData.power¶
Mojo
@staticmethod
def power(base: ExprData, exponent: Int) -> ExprData
Python
@staticmethod
def power(base, exponent)
Describe a natural power through the base's arithmetic profile.
Arguments.
base: The base.exponent: A nonnegative exponent.
Returns. The description of base ** exponent.
ExprData.format¶
Mojo
def format(self) -> String
Python
def format(self)
Render the description, fully parenthesized, without resolving it.
Returns. The text; it is display only and is never read back.
TypeData¶
Mojo
struct TypeData(ImplicitlyCopyable, Movable, Deinitable)
Python
from judgment import TypeData
An owned, immutable description of a type, with no session reference.
A name is resolved when a data program runs: a type parameter of the selected goal's proof header, then a nullary type of the goal's theory. Values are shared by reference count and can cross threads.
Defined in src/judgment_shell/tactic_data.mojo.
TypeData.__init__¶
Mojo
def __init__(out self, var node: _TypeNode)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use the static constructors.
Arguments.
node: The immutable node.
TypeData.__init__¶
Mojo
def __init__(out self, *, shared: ArcPointer[_TypeNode])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor sharing an existing node.
Arguments.
shared: The node.
TypeData.name¶
Mojo
@staticmethod
def name(name: String) -> TypeData
Python
@staticmethod
def name(name)
Describe a type by name.
Arguments.
name: A proof type parameter or a nullary type of the theory.
Returns. The description; nothing is resolved yet.
TypeData.arrow¶
Mojo
@staticmethod
def arrow(domain: TypeData, codomain: TypeData) -> TypeData
Python
@staticmethod
def arrow(domain, codomain)
Describe a function type.
Arguments.
domain: The argument type.codomain: The result type.
Returns. The description of domain → codomain.
TypeData.prop¶
Mojo
@staticmethod
def prop() -> TypeData
Python
@staticmethod
def prop()
Describe the built-in proposition type.
Returns. The description of Prop.
TypeData.format¶
Mojo
def format(self) -> String
Python
def format(self)
Render the description, without resolving it.
Returns. Names, Prop, and right-associated arrows with parentheses on the left.
GoalData¶
Mojo
struct GoalData(ImplicitlyCopyable, Movable, Deinitable)
Python
from judgment import GoalData
An owned, session-free description of an outstanding goal, for producers without kernel access.
Variables and premises are listed in context order, outermost first.
Defined in src/judgment_shell/tactic_data.mojo.
GoalData.__init__¶
Mojo
def __init__(out self, var path: List[String], var status: String, revision: UInt64, target: ExprData, var type_params: List[String], var variables: List[String], var variable_types: List[TypeData], var premises: List[String], var statements: List[ExprData])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use Goal.data.
Arguments.
path: The goal's path.status: "open" or "deferred".revision: The goal's revision token.target: Its target.type_params: The proof's type parameter names.variables: Visible variable names.variable_types: Their types.premises: Visible premise names, empty for an unnamed one.statements: Their statements.
GoalData.path¶
Mojo
def path(self) -> List[String]
Python
def path(self)
Read the goal's path from the theorem root.
Returns. Owned components; Candidate selects the goal by them.
GoalData.status¶
Mojo
def status(self) -> String
Python
def status(self)
Read whether the goal is open or deferred.
Returns. "open" or "deferred".
GoalData.revision¶
Mojo
def revision(self) -> UInt64
Python
def revision(self)
Read the goal's revision token.
Returns. An opaque token naming this goal at this revision; a Candidate carrying an older token is refused.
GoalData.target¶
Mojo
def target(self) -> ExprData
Python
def target(self)
Read the target.
Returns. Its description, with the names the goal displays.
GoalData.type_params¶
Mojo
def type_params(self) -> List[String]
Python
def type_params(self)
Read the proof's type parameter names.
Returns. Names, in header order.
GoalData.variables¶
Mojo
def variables(self) -> List[String]
Python
def variables(self)
Read the names of the visible variables.
Returns. Names, outermost first.
GoalData.variable_types¶
Mojo
def variable_types(self) -> List[TypeData]
Python
def variable_types(self)
Read the types of the visible variables.
Returns. One description per variable, in the same order.
GoalData.premises¶
Mojo
def premises(self) -> List[String]
Python
def premises(self)
Read the names of the visible premises.
Returns. Names, outermost first; empty for an unnamed premise.
GoalData.statements¶
Mojo
def statements(self) -> List[ExprData]
Python
def statements(self)
Read the statements of the visible premises.
Returns. One description per premise, in the same order.
Candidate¶
Mojo
struct Candidate(ImplicitlyCopyable, Movable, Deinitable)
Python
from judgment import Candidate
A tactic program for one goal at one revision, as a remote producer proposes it.
Defined in src/judgment_shell/tactic_data.mojo.
Candidate.__init__¶
Mojo
def __init__(out self, path: List[String], revision: UInt64, tactic: TacticData)
Python
def __init__(self, path, revision, tactic)
Bind a data program to a goal.
Arguments.
path: The goal's path, from GoalData.path.revision: Its revision token, from GoalData.revision.tactic: The program to run on it.
Candidate.path¶
Mojo
def path(self) -> List[String]
Python
def path(self)
Read the goal's path.
Returns. Owned components.
Candidate.revision¶
Mojo
def revision(self) -> UInt64
Python
def revision(self)
Read the revision token.
Returns. The token the program was made for.
Candidate.tactic¶
Mojo
def tactic(self) -> TacticData
Python
def tactic(self)
Read the program.
Returns. The shared, immutable program.
StopSignal¶
Mojo
struct StopSignal(ImplicitlyCopyable, Movable, ThreadTransferable)
Python
from judgment import StopSignal
A one-way flag that any copy can raise and every copy reads.
Copies share one atomic flag, so a copy may move to, be read on, and be
destroyed on another thread; that is the reviewed basis of its
ThreadTransferable claim. A raised flag is never lowered.
Defined in src/judgment_shell/stop.mojo.
StopSignal.__init__¶
Mojo
def __init__(out self)
Python
def __init__(self)
Make a flag that is not raised.
StopSignal.request¶
Mojo
def request(self)
Python
def request(self)
Raise the flag; every copy then reports it as requested.
StopSignal.requested¶
Mojo
def requested(self) -> Bool
Python
def requested(self)
Read the flag.
Returns. True once any copy has called request.
ProofRecipe¶
Mojo
struct ProofRecipe(ImplicitlyCopyable)
Python
from judgment import ProofRecipe
An immutable partial derivation; only refinement checks its rules and exposes its missing proofs.
Defined in src/judgment_shell/_dag_refinement.mojo.
ProofRecipe.__init__¶
Mojo
def __init__(out self, session: ArcPointer[_DagState], var tree: ArcPointer[_DagRecipeNode], weight: UInt64)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use recipe or hole.
Arguments.
session: The owning session.tree: The immutable recipe tree.weight: Its saturating construction charge.
ProofRecipe.conjoin¶
Mojo
def conjoin(self, other: Self) raises LibError -> Self
Python
def conjoin(self, other)
Compose conjunction introduction.
Arguments.
other: The right conjunct's recipe.
Returns. A partial conjunction derivation, still without checked authority.
Raises.
LibError: For foreign ownership or exhausted work.
ProofRecipe.left¶
Mojo
def left(self) raises LibError -> Self
Python
def left(self)
Compose left conjunction projection.
Returns. A partial derivation whose premise shape is checked by refine.
Raises.
LibError: On exhausted work.
ProofRecipe.right¶
Mojo
def right(self) raises LibError -> Self
Python
def right(self)
Compose right conjunction projection.
Returns. A partial derivation whose premise shape is checked by refine.
Raises.
LibError: On exhausted work.
ProofRecipe.apply¶
Mojo
def apply(self, premise: Self) raises LibError -> Self
Python
def apply(self, premise)
Compose implication elimination.
Arguments.
premise: The antecedent's partial derivation.
Returns. A partial derivation of the consequent, checked by refine.
Raises.
LibError: For foreign ownership or exhausted work.
ProofRecipe.symm¶
Mojo
def symm(self) raises LibError -> Self
Python
def symm(self)
Compose equality symmetry.
Returns. A partial derivation of the reversed equality, checked by refine.
Raises.
LibError: On exhausted work.
ProofRecipe.trans¶
Mojo
def trans(self, other: Self) raises LibError -> Self
Python
def trans(self, other)
Compose equality transitivity.
Arguments.
other: The next equality's recipe.
Returns. A partial derivation whose middle terms are checked by refine.
Raises.
LibError: For foreign ownership or exhausted work.
Refinement¶
Mojo
struct Refinement(Movable)
Python
from judgment import Refinement
Stable named handles for the obligations of a checked partial recipe.
Defined in src/judgment_shell/_dag_proof.mojo.
Refinement.__init__¶
Mojo
def __init__(out self, var data: _DagRefinement)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; obtain named holes through _DagProof.refine.
Arguments.
data: The checked refinement's owned names and goal identities.
Refinement.names¶
Mojo
def names(self) raises LibError -> List[String]
Python
def names(self)
Copy distinct labels in deterministic recipe order, including solved holes.
Returns. An owned list of labels.
Raises.
LibError: LIMIT on exhausted work.
recipe¶
Mojo
def recipe(fact: Step) raises LibError -> ProofRecipe
Python
def recipe(fact)
Wrap a checked step as a proof recipe.
Arguments.
fact: Checked step.
Returns. Proof recipe discharging the matching goal.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_refinement.mojo.
hole¶
Mojo
def hole(name: String, proposition: Expr) raises LibError -> ProofRecipe
Python
def hole(name, proposition)
Create a named proof-recipe hole for proposition.
Arguments.
name: Hole name.proposition: Goal proposition.
Returns. Proof recipe leaving an open hole.
Raises.
LibError: On invalid proposition or exhaustion.
Defined in src/judgment_shell/_dag_refinement.mojo.
Definition¶
Mojo
struct Definition(ImplicitlyCopyable)
Python
from judgment import Definition
A definition a session declared: its constant and its defining equation.
Defined in src/judgment_shell/_ws_handles.mojo.
Definition.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], generation: UInt32, decl: UInt32, atom: Int, equation: Int, statement: UInt32, params: Int)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; definitions come from Session.define.
Arguments.
state: The session's state.generation: The workspace's generation when made.decl: ItsDECLrow.atom: The constant's authored-syntax row, at its declared type.equation: The equation's authored-syntax row.statement: The equation's node.params: Its type-parameter count.
Definition.symbol¶
Mojo
def symbol(self, type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Expr
Python
def symbol(self, type_args=[])
The defined constant, as Definition.symbol: at its declared type, or at type arguments.
Arguments.
type_args: Its type parameters' instances, in order; none for a monomorphic definition.
Returns. The constant, or its instance.
Raises.
LibError:KERNELfor a stale handle or a refused instance;UNSUPPORTEDfor a polymorphic definition without type arguments;SHAPEfor another number of type arguments;LIMIT.
Definition.equation¶
Mojo
def equation(self) raises LibError -> Fact
Python
def equation(self)
The checked defining equation c = t, as Definition.equation.
Returns. The fact.
Raises.
LibError:KERNELfor a stale handle.
DefinitionBuilder¶
Mojo
struct DefinitionBuilder(Movable)
Python
from judgment import DefinitionBuilder
A captured parameter header for a definition with inferred type and a checked defining equation.
Defined in src/judgment_shell/_dag_authoring_builders.mojo.
DefinitionBuilder.__init__¶
Mojo
def __init__(out self, var header: _DagProof, transparent: Bool)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use dag_definition.
Arguments.
header: The captured proof header.transparent: Whether explicit conversion may unfold the declaration.
DefinitionBuilder.type_var¶
Mojo
def type_var(mut self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Declare a rigid type parameter, including one the definition will not use.
Arguments.
name: A fresh header name.sort: Explicit class constraints.
Returns. The parameter in its declared header position.
Raises.
LibError: For invalid name, owner, lifetime, completed header or exhausted work.
DefinitionBuilder.var¶
Mojo
def var(mut self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def var(self, name, kind)
Declare a term parameter that completion lambda-abstracts even when unused.
Arguments.
name: A fresh header name.kind: A type in this header's scope.
Returns. The fixed parameter.
Raises.
LibError: For invalid name, type, scope, lifetime, completed header or exhaustion.
DefinitionBuilder.vars¶
Mojo
def vars(mut self, names: String, kind: TypeExpr) raises LibError -> List[Expr]
Python
def vars(self, names, kind)
Declare a batch of term parameters atomically.
Arguments.
names: Nonempty whitespace-separated unique names.kind: Their common type in this header's scope.
Returns. The parameters in input order.
Raises.
LibError: For invalid names, type, scope, lifetime, completed header or exhaustion.
DefinitionBuilder.prop¶
Mojo
def prop(mut self, name: String) raises LibError -> Expr
Python
def prop(self, name)
Declare a proposition parameter.
Arguments.
name: A fresh header name.
Returns. The fixed proposition parameter.
Raises.
LibError: For invalid name, completed or stale header, or exhaustion.
DefinitionBuilder.props¶
Mojo
def props(mut self, names: String) raises LibError -> List[Expr]
Python
def props(self, names)
Declare proposition parameters atomically.
Arguments.
names: Nonempty whitespace-separated unique names.
Returns. The parameters in input order.
Raises.
LibError: For invalid names, completed or stale header, or exhaustion.
DefinitionBuilder.finish¶
Mojo
def finish(mut self, body: Expr) raises LibError -> Definition
Python
def finish(self, body)
Close the header and publish the checked definition; failed completion remains retryable.
Arguments.
body: An expression in the captured authored scope.
Returns. The original declaration's symbol and checked equation, retaining ordered unused type parameters.
Raises.
LibError: For invalid body, scope, lifetime, a used name, hidden body type parameters or exhaustion.
Arithmetic¶
Mojo
struct Arithmetic(ImplicitlyCopyable)
Python
from judgment import Arithmetic
Bind arithmetic notation to explicit operations on one concrete type, as Arithmetic.
Initial notation binding assumes no laws and changes no theory. Explicit integers, rationals, and
polynomials registration checks supplied laws and enables canonical literal arithmetic.
Defined in src/judgment_shell/_dag_arithmetic.mojo.
Arithmetic.__init__¶
Mojo
def __init__(out self, state: ArcPointer[_DagState], carrier: TypeExpr)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use dag_arithmetic or Session.arithmetic.
Arguments.
state: Owning session state.carrier: Carrier type handle.
Arithmetic.integers¶
Mojo
def integers(self, name: String, lt: Expr, le: Expr, laws: ArithmeticLaws) raises LibError -> Self
Python
def integers(self, name, lt, le, laws)
Explicitly enable compact integer literals and canonical arithmetic.
Arguments.
name: Fresh literal-kind name.lt: Strict order on this carrier.le: Nonstrict order on this carrier.laws: The fifteen named, closed law facts required by the kernel.
Returns. This carrier's reusable exact integer profile.
Raises.
LibError: For missing/misstated laws, invalid operations, duplicate names, or limits.
Arithmetic.rationals¶
Mojo
def rationals(self, name: String, lt: Expr, le: Expr, inv: Expr, laws: ArithmeticLaws) raises LibError -> Self
Python
def rationals(self, name, lt, le, inv, laws)
Explicitly enable compact rational literals and canonical arithmetic.
Arguments.
name: Fresh literal-kind name.lt: Strict order on this carrier.le: Nonstrict order on this carrier.inv: Unary inverse operation.laws: The sixteen named, closed law facts required by the kernel.
Returns. This carrier's reusable exact rational profile.
Raises.
LibError: For missing/misstated laws, invalid operations, duplicate names, or limits.
Arithmetic.polynomials¶
Mojo
def polynomials(self, name: String, base: Self, coeff: Expr, indet: Expr, laws: ArithmeticLaws) raises LibError -> Self
Python
def polynomials(self, name, base, coeff, indet, laws)
Enable formal polynomial literals over an explicit rational base.
Arguments.
name: Fresh literal-kind name.base: An exact rational profile in this session.coeff: Coefficient embedding from the base to this carrier.indet: Indeterminate operation.laws: The twelve named ring and coefficient laws.
Returns. This carrier's exact polynomial profile.
Raises.
LibError: For invalid owners, operations, laws, names, or limits.
Arithmetic.indeterminate¶
Mojo
def indeterminate(self, index: Int = 0) raises LibError -> Expr
Python
def indeterminate(self, index=0)
Construct a polynomial indeterminate as literal data.
Arguments.
index: Signed identifier of the indeterminate.
Returns. A polynomial literal.
Raises.
LibError: For a non-polynomial profile or exhausted resources.
Arithmetic.polynomial¶
Mojo
def polynomial(self, coefficients: List[Rational], variable: Int = 0) raises LibError -> Expr
Python
def polynomial(self, coefficients, variable=0)
Construct a univariate polynomial from coefficients in ascending degree order.
Arguments.
coefficients: Coefficients in ascending degree order, including zeros.variable: Indeterminate identifier, defaulting to zero.
Returns. A canonical polynomial literal.
Raises.
LibError: For a non-polynomial profile, excessive degree, or limits.
Arithmetic.number¶
Mojo
def number(self, value: Integer) raises LibError -> Expr
Python
def number(self, value)
Selected for Python integers outside the signed 64-bit range.
Construct a compact arbitrary-precision integer in an exact profile.
Arguments.
value: The exact integer.
Returns. A kernel literal displayed in decimal.
Raises.
LibError: For a symbolic-only profile, exhausted work, or kernel refusal.
Arithmetic.number¶
Mojo
def number(self, text: String) raises LibError -> Expr
Python
def number(self, text)
Parse a decimal integer into a compact exact literal.
Arguments.
text: Decimal digits with an optional sign, without whitespace.
Returns. The normalized integer literal.
Raises.
LibError: For malformed input, a symbolic-only profile, or limits.
Arithmetic.number¶
Mojo
def number(self, value: Int) raises LibError -> Expr
Python
def number(self, value)
Selected for Python integers from -2**63 through 2**63 - 1.
Construct an integer numeral in this profile without adding laws.
Arguments.
value: A signed integer; negative values require bound negation.
Returns. A compact kernel literal after exact registration, else symbolic repeated-one addition.
Raises.
LibError: For missing negation, exhausted work, or kernel refusal.
Arithmetic.rational¶
Mojo
def rational(self, numerator: Integer, denominator: Integer) raises LibError -> Expr
Python
def rational(self, numerator, denominator)
Construct a reduced exact fraction without floating-point conversion.
Arguments.
numerator: Signed numerator.denominator: Nonzero signed denominator.
Returns. A normalized literal with positive denominator.
Raises.
LibError: For zero denominator, missing rational profile, or limits.
Arithmetic.rational¶
Mojo
def rational(self, numerator: Int, denominator: Int) raises LibError -> Expr
Python
def rational(self, numerator, denominator)
Python routes this call through its arbitrary-precision integer overload.
Construct an exact fraction from machine integers.
Arguments.
numerator: Signed numerator.denominator: Nonzero signed denominator.
Returns. A reduced rational literal in this profile.
Raises.
LibError: For zero denominator, missing rational profile, or limits.
Arithmetic.inverse¶
Mojo
def inverse(self, value: Expr) raises LibError -> Expr
Python
def inverse(self, value)
Apply the exact rational profile's bound inverse operation.
Arguments.
value: An expression of this carrier from the same session.
Returns. The inverse expression.
Raises.
LibError: For missing inverse, invalid owner/type, or exhausted work.
ArithmeticLaws¶
Mojo
struct ArithmeticLaws(ImplicitlyCopyable)
Python
from judgment import ArithmeticLaws
Named law evidence for exact integer, rational, or polynomial registration, as ArithmeticLaws.
Defined in src/judgment_shell/_dag_arithmetic.mojo.
ArithmeticLaws.__init__¶
Mojo
def __init__(out self, var entries: List[Tuple[String, Fact]]) raises LibError
Python
def __init__(self, entries)
Retain named law evidence without assuming or registering anything.
Arguments.
entries: Law-slot names and closed, monomorphic facts from one session. Integers need fifteen slots, rationals sixteen, polynomials twelve.
Raises.
LibError:FORMATfor empty or duplicate slots;WRONG_KERNELfor mixed owners;KERNELfor stale facts;LIMITon exhaustion.
AxiomBuilder¶
Mojo
struct AxiomBuilder(Movable)
Python
from judgment import AxiomBuilder
A captured parameter header for an explicit axiom, distinct from a derivation or admission.
Defined in src/judgment_shell/_dag_authoring_builders.mojo.
AxiomBuilder.__init__¶
Mojo
def __init__(out self, var header: _DagProof)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal constructor; use dag_axiom.
Arguments.
header: The captured proof header.
AxiomBuilder.type_var¶
Mojo
def type_var(mut self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Python
def type_var(self, name, sort=[])
Declare a rigid type parameter, including an unused one.
Arguments.
name: A fresh header name.sort: Explicit class constraints.
Returns. The parameter in its declared header position.
Raises.
LibError: For invalid name, owner, lifetime, completed header or exhausted work.
AxiomBuilder.var¶
Mojo
def var(mut self, name: String, kind: TypeExpr) raises LibError -> Expr
Python
def var(self, name, kind)
Declare a term parameter that completion universally quantifies even when unused.
Arguments.
name: A fresh header name.kind: A type in this header's scope.
Returns. The fixed parameter.
Raises.
LibError: For invalid name, type, scope, lifetime, completed header or exhaustion.
AxiomBuilder.vars¶
Mojo
def vars(mut self, names: String, kind: TypeExpr) raises LibError -> List[Expr]
Python
def vars(self, names, kind)
Declare a batch of term parameters atomically.
Arguments.
names: Nonempty whitespace-separated unique names.kind: Their common type in this header's scope.
Returns. The parameters in input order.
Raises.
LibError: For invalid names, type, scope, lifetime, completed header or exhaustion.
AxiomBuilder.prop¶
Mojo
def prop(mut self, name: String) raises LibError -> Expr
Python
def prop(self, name)
Declare a proposition parameter.
Arguments.
name: A fresh header name.
Returns. The fixed proposition parameter.
Raises.
LibError: For invalid name, completed or stale header, or exhaustion.
AxiomBuilder.props¶
Mojo
def props(mut self, names: String) raises LibError -> List[Expr]
Python
def props(self, names)
Declare proposition parameters atomically.
Arguments.
names: Nonempty whitespace-separated unique names.
Returns. The parameters in input order.
Raises.
LibError: For invalid names, completed or stale header, or exhaustion.
AxiomBuilder.finish¶
Mojo
def finish(mut self, proposition: Expr) raises LibError -> Fact
Python
def finish(self, proposition)
Close the header and declare an explicit axiom; failed completion remains retryable.
Arguments.
proposition: A proposition in the captured authored scope.
Returns. Checked evidence of the declared assumption with its full ordered type header.
Raises.
LibError: For invalid proposition, scope, lifetime, a used name, completed header or exhaustion.
arrow¶
Mojo
def arrow(domain: TypeExpr, codomain: TypeExpr) raises LibError -> TypeExpr
Python
def arrow(domain, codomain)
Build the function type domain → codomain.
Arguments.
domain: Argument type.codomain: Result type.
Returns. Checked function type expression.
Raises.
LibError: On invalid handles or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
eq¶
Mojo
def eq(left: Expr, right: Expr) raises LibError -> Expr
Python
def eq(left, right)
Build the equality proposition left = right.
Arguments.
left: Left-hand expression.right: Right-hand expression of the same type.
Returns. Checked equality proposition.
Raises.
LibError: On type mismatch, invalid handles, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
implies¶
Mojo
def implies(left: Expr, right: Expr) raises LibError -> Expr
Python
def implies(left, right)
Build the implication left → right.
Arguments.
left: Antecedent proposition.right: Consequent proposition.
Returns. Checked implication proposition.
Raises.
LibError: On non-propositions, invalid handles, or exhaustion.
Defined in src/judgment_shell/_ws_handles.mojo.
not_¶
Mojo
def not_(proposition: Expr) raises LibError -> Expr
Python
def not_(proposition)
Build the negation ¬proposition.
Arguments.
proposition: Proposition expression.
Returns. Checked negation proposition.
Raises.
LibError: On non-proposition, invalid handle, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
iff¶
Mojo
def iff(left: Expr, right: Expr) raises LibError -> Expr
Python
def iff(left, right)
Build the biconditional left ↔ right.
Arguments.
left: Left proposition.right: Right proposition.
Returns. Checked equivalence proposition.
Raises.
LibError: On non-propositions, invalid handles, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
forall¶
Mojo
def forall(variable: Expr, body: Expr) raises LibError -> Expr
Python
def forall(variable, body)
Build the universal quantification ∀variable. body.
Arguments.
variable: Bound variable expression.body: Quantified proposition.
Returns. Checked universal proposition.
Raises.
LibError: On invalid variable, non-proposition body, or exhaustion.
Defined in src/judgment_shell/_ws_handles.mojo.
exists¶
Mojo
def exists(variable: Expr, body: Expr) raises LibError -> Expr
Python
def exists(variable, body)
Build the existential quantification ∃variable. body.
Arguments.
variable: Bound variable expression.body: Quantified proposition.
Returns. Checked existential proposition.
Raises.
LibError: On invalid variable, non-proposition body, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
Theorem imports and exports¶
A session over a bank snapshot imports a library's theorems through a
TheoremSource, which declares them as one layer over the session's theory,
and exports a proven theorem as a bank-independent closure of rows, which a
library's change replays and rechecks in full. export takes a theorem
name (valid_theorem_name, Definition L-3a of the
library theory) or a canonical name
judgment.stmt.<sid>.
A NODE row's head reference is always a head; elsewhere a REF_CORE
declaration operand is a declaration's id.
TheoremIdentity¶
Mojo
@fieldwise_init
struct TheoremIdentity(Equatable, Hashable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
bytes |
Array[UInt8, 32] |
The digest's bytes. |
Python
from judgment import TheoremIdentity
A library's 32-byte identity of a declaration, a statement or a version; never evidence.
Defined in src/judgment_shell/_ws_snapshots.mojo.
TheoremIdentity.__init__¶
Mojo
def __init__(out self, *, copy: Self)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Copy the identity.
Arguments.
copy: The identity to copy.
TheoremIdentity.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Write 64 lowercase hexadecimal digits.
Arguments.
writer: The destination.
TheoremSource¶
trait TheoremSource
A library that gives theorems statement-only: the Store's Library implements it.
A source is in the trusted base for what it imports: its statements
(stand-ins, recorded as IMPORTED_STATEMENT with their library, version
and identity) and, when it claims whole_layer_in_order, its class
layer's coregularity, which the session then does not check pairwise
and records as trusted (Fact.trusted_class_layer, TheoremExport.trusted_layers).
Defined in src/judgment_shell/_ws_snapshots.mojo.
TheoremSource.resolve¶
def resolve(self, names: List[String], mut budget: Budget) raises LibError -> List[TheoremIdentity]
Name the statements of theorems, by their export names.
Arguments.
names: Export names.budget: Charged.
Returns. Each name's statement identity, in order.
Raises.
LibError: For a name the library does not export, exhausted work or a typed source failure.
TheoremSource.declare¶
def declare(self, wanted: List[TheoremIdentity], mut w: DagWriter, base: ImportBase, mut budget: Budget) raises LibError -> ImportedLayer
Write the closure of the wanted statements' providers, and the whole class layer, into w.
Declarations go in the library's commit order into one new segment
over base.theory, each parented on the theory just after the one before; a Proven as an Axiom with the same fields,
its stand-in. The rows are untrusted: the session decides and checks
them.
Arguments.
wanted: Statement identities.w: The workspace's writer.base: What the workspace holds.budget: Charged.
Returns. The layer written.
Raises.
LibError: For a missing statement, unreadable version, exhausted work or a typed source failure.
ImportBase¶
struct ImportBase(Movable)
| Field | Type | Description |
|---|---|---|
view |
DagView |
The workspace's rows: the core prefix, the profile, and whatever the session added. |
profile |
Int |
The profile the session's bank was built over, as the library names profiles. |
theory |
UInt32 |
The theory the import's segment extends: the session's current one. |
imported |
Dict[TheoremIdentity, UInt32] |
The declarations earlier imports declared, by their library identities. |
What a session's workspace holds when a source declares into it: the source resolves its references from it.
Defined in src/judgment_shell/_ws_snapshots.mojo.
ImportBase.__init__¶
def __init__(out self, view: DagView, profile: Int, theory: UInt32, imported: Dict[TheoremIdentity, UInt32])
A base for one import.
Arguments.
view: The workspace's view.profile: The profile.theory: The theory the segment extends.imported: Earlier imports' declarations by identity.
ImportedLayer¶
struct ImportedLayer(Movable)
| Field | Type | Description |
|---|---|---|
decls |
List[UInt32] |
The declarations written, in commit order. |
identities |
List[TheoremIdentity] |
Their library identities, in the same order. |
standins |
Dict[TheoremIdentity, UInt32] |
Each library Proven's identity → its Axiom stand-in. |
providers |
Dict[TheoremIdentity, UInt32] |
Each statement identity whose provider was declared → that declaration. |
version |
TheoremIdentity |
The library version read. |
source |
String |
The library's name, for provenance. |
whole_layer_in_order |
Bool |
The source's claim that the class layer written is the library's whole layer, in its commit order. |
segment |
Optional[Tuple[UInt32, UInt32]] |
The import's segment, over ImportBase.theory, and its declaration count; none when nothing was written. |
What a source declared into a workspace: its untrusted account, which the session decides and checks.
Defined in src/judgment_shell/_ws_snapshots.mojo.
ImportedLayer.__init__¶
def __init__(out self, version: TheoremIdentity, var source: String)
An empty layer of a version.
Arguments.
version: The version.source: The library's name.
ImportedLayer.snapshot¶
@staticmethod
def snapshot(var bank: DagBank, writer: ArcPointer[DagWriter], profile: Int, core_end: UInt64, marker: Optional[ProfileMarker] = None, var aliases: Dict[String, UInt32] = Dict[String, UInt32](), var unresolved: Dict[String, String] = Dict[String, String](), var imports: Dict[Int, TheoremIdentity] = Dict[Int, TheoremIdentity](), version: Optional[TheoremIdentity] = None, var profile_axioms: List[UInt32] = List[UInt32]()) raises LibError -> Snapshot
Build a Snapshot over a verified bank (Store implementer interface).
Arguments.
bank: Verified bank transferred to the snapshot.writer: Bank writer for subsequent seals.profile: Profile id.core_end: Sequence number ending the core prefix.marker: Optional profile marker.aliases: Optional fact alias map.unresolved: Optional unresolved alias reasons.imports: Optional imported declaration identities.version: Optional library version identity.profile_axioms: The profile's axioms, strictly increasing, each past the core; sessions over the snapshot classify themPROFILE_AXIOM.
Returns. Checked Snapshot.
Raises.
LibError: On invalid bank, writer, marker, or profile axiom.
snapshot_rows reads a sealed snapshot's rows for the Store's
LibraryChange.add_snapshot: an immutable view of exactly the snapshot's
verified prefix, with its profile, its core and profile extent and its
profile axioms. Nothing writable is reachable from it, and the public
judgment facade does not export it.
SnapshotRows¶
struct SnapshotRows(Copyable)
| Field | Type | Description |
|---|---|---|
view |
DagView |
The snapshot's verified prefix: every row below view.top() is published, verified and decided. |
profile |
Int |
The profile the snapshot's bank was built over, as the library names profiles. |
core_end |
UInt64 |
The sequence number that ends the core prefix. |
profile_end |
UInt32 |
The first declaration past the core and the profile: the profile marker's extent, or the core's end without one. |
profile_axioms |
List[UInt32] |
The snapshot's profile axioms, strictly increasing: a session over it classifies each PROFILE_AXIOM. |
imports |
Bool |
Whether the snapshot holds declarations of a library version (Library.snapshot), which belong to that library. |
A sealed snapshot's rows, read-only (Store implementer interface): what LibraryChange.add_snapshot reads.
It holds an immutable DagView of exactly the snapshot's verified prefix,
and the snapshot's profile, core extent and profile axioms. No writer, bank or
session is reachable from it: a reader can neither add a row nor change
one, and rows a later seal of the same bank adds lie beyond its view.
Defined in src/judgment_shell/_ws_snapshots.mojo.
SnapshotRows.__init__¶
def __init__(out self, *, var view: DagView, profile: Int, core_end: UInt64, profile_end: UInt32, var profile_axioms: List[UInt32], imports: Bool)
Internal; snapshot_rows makes one.
Arguments.
view: The verified prefix.profile: The profile.core_end: The end of the core prefix.profile_end: The first declaration past the core and the profile.profile_axioms: The profile axioms.imports: Whether the snapshot holds a library version's declarations.
snapshot_rows¶
def snapshot_rows(snapshot: Snapshot) raises LibError -> SnapshotRows
Read a sealed snapshot's rows (Store implementer interface): its verified prefix as an immutable view.
Arguments.
snapshot: The snapshot.
Returns. Its rows, its profile, its core and profile extent, and its profile axioms.
Raises.
LibError:KERNELwhen the snapshot's profile marker does not match its prefix (unreachable for a snapshot_snapshotchecked).
Defined in src/judgment_shell/_ws_snapshots.mojo.
TheoremExport¶
Mojo
struct TheoremExport(Copyable)
| Field | Type | Description |
|---|---|---|
name |
String |
The theorem's name. |
profile |
Int |
The profile the session's bank was built over. |
imports |
List[ExportImport] |
The library declarations the closure cites. |
rows |
List[ExportRow] |
The theorem's closure above the core, the profile and the imports, in an order where each row follows its references. |
statement |
UInt64 |
The statement's ref. |
proof |
UInt64 |
The ref of the proof row the theorem was declared from. |
decl |
UInt64 |
The ref of the Proven row. |
trusted_layers |
List[String] |
Each import of the session whose class layer took the trusted pass, as library|version: the theorem's sort facts may rest on its coregularity, which the library's producer is trusted for. |
Python
from judgment import TheoremExport
A session theorem with its checked proof over its imports, for a library to publish.
The receiver replays it: each proof row through the construction engine from its rule and operands, which recomputes the conclusion, hypotheses, dependencies, context, signature and home in the receiver's theory, and the library's load (Algorithm L-5) rechecks every row. So the value carries no trust, and those fields are not exported.
Defined in src/judgment_shell/_ws_snapshots.mojo.
TheoremExport.__init__¶
Mojo
def __init__(out self, var name: String, profile: Int)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
An empty export.
Arguments.
name: The name.profile: The profile.
ExportRow¶
@fieldwise_init
struct ExportRow(Copyable)
| Field | Type | Description |
|---|---|---|
table |
UInt8 |
The row's table. |
fields |
List[UInt64] |
Its fields. |
One row of an export's closure, in bank-independent fields.
By table: POOL its bytes; NODE (head ref, payload, children refs),
the head ref always a head (REF_CORE with a core head's id, or a
declaration's part by REF_PROFILE or REF_IMPORT) while elsewhere a
REF_CORE declaration operand is a declaration's id;
a pooled payload or a local node's local as a ref; LOCAL (name ref,
or (REF_CORE, NONE) for an unnamed local, type ref); CONTEXT (parent ref, entry kind, entry ref), a rebase as
(REF_CORE NONE, 0, 0); HSET its node refs; DSET (tag, ref) pairs;
PROOF (rule, operands), each reference operand of the rule's layout a
ref; DECL the Proven's (name ref, statement ref, proof ref).
Defined in src/judgment_shell/_ws_snapshots.mojo.
ExportImport¶
@fieldwise_init
struct ExportImport(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
identity |
TheoremIdentity |
The declaration's library identity. |
version |
TheoremIdentity |
The library version it was imported from. |
A library declaration an export cites: its identity (a stand-in's library Proven) and the version read.
Defined in src/judgment_shell/_ws_snapshots.mojo.
export_ref¶
def export_ref(kind: UInt64, index: UInt32, part: UInt32 = 0) -> UInt64
Tag a reference: kind << 62 | part << 32 | index.
Arguments.
kind:REF_OWN,REF_IMPORT,REF_PROFILEorREF_CORE.index: The row, import or profile position.part: A head's part of its declaration; 0 otherwise.
Returns. The reference.
Defined in src/judgment_shell/_ws_snapshots.mojo.
valid_theorem_name¶
def valid_theorem_name(name: String) -> Bool
Whether a name is a theorem name (Definition L-3a of the library theory, docs/content/store/theory/library.md):
dot-separated components, each in snake_case ([a-z][a-z0-9_]*), such as
hol_probability.martingale.martingale_convergence, whose first component is not judgment, which canonical
names judgment.stmt.<sid> use. Session.export takes a theorem name or a canonical name.
Arguments.
name: The name.
Returns. True for a theorem name.
Defined in src/judgment_shell/_ws_snapshots.mojo.
REF_OWN¶
comptime REF_OWN: UInt64 = 0
A reference to an earlier row of TheoremExport.rows.
Defined in src/judgment_shell/_ws_snapshots.mojo.
REF_IMPORT¶
comptime REF_IMPORT: UInt64 = 1
A reference to TheoremExport.imports[i], a library declaration (with a part, for a head).
Defined in src/judgment_shell/_ws_snapshots.mojo.
REF_PROFILE¶
comptime REF_PROFILE: UInt64 = 2
A reference to the profile's k-th declaration in commit order (with a part, for a head).
Defined in src/judgment_shell/_ws_snapshots.mojo.
REF_CORE¶
comptime REF_CORE: UInt64 = 3
A reference to a row of the core prefix by its id: in a NODE row's head field a head, as a declaration operand a
declaration; for a context, the id NONE is the session's base frame, the empty frame rebased onto its theory.
Defined in src/judgment_shell/_ws_snapshots.mojo.
Errors¶
A library failure has its own LibErrorKind. A refusal received from the
kernel has kind KERNEL, keeps the original message, and carries the
kernel's kind in kernel_kind. A KernelError converts implicitly, so
library code calls the kernel directly inside a raises LibError function;
plain Error does not convert. from_refusal wraps a stateless checker's
Refusal as KERNEL and keeps the structured value in refusal, as the
program below shows.
"""Preserve a stateless checker refusal at a library's typed error boundary."""
from std.testing import assert_equal, assert_true
from judgment_core import Refusal, RefusalKind
from judgment_shell import LibError, LibErrorKind, from_refusal
def checked_step() raises LibError:
"""Wrap a stateless checker refusal as a typed library error."""
raise from_refusal(Refusal(RefusalKind.MISMATCH, 1, 0, 0, 0))
def main() raises:
var refused = False
try:
checked_step()
except error:
assert_equal(error.kind, LibErrorKind.KERNEL)
assert_true(Bool(error.refusal))
assert_equal(error.refusal.value().kind, RefusalKind.MISMATCH)
assert_true(error.message.byte_length() > 0)
print(error.kind, "/", error.refusal.value().kind)
refused = True
assert_true(refused)
Run from the repository root pixi run mojo run -I src docs/examples/library/errors.mojo
Output
KERNEL / MISMATCH
LibErrorKind¶
Mojo
@fieldwise_init
struct LibErrorKind(Equatable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
code |
UInt8 |
The kind's internal number; compare named kinds, not these numbers. |
Python
from judgment import LibErrorKind
Classify a library failure or a wrapped kernel refusal.
Defined in src/judgment_shell/errors.mojo.
LibErrorKind.KERNEL¶
Mojo
comptime KERNEL = LibErrorKind(1)
Python
LibErrorKind.KERNEL
A kernel call refused the operation; kernel_kind records why.
LibErrorKind.SHAPE¶
Mojo
comptime SHAPE = LibErrorKind(2)
Python
LibErrorKind.SHAPE
A term or judgment has the wrong form for the operation.
LibErrorKind.NO_MATCH¶
Mojo
comptime NO_MATCH = LibErrorKind(3)
Python
LibErrorKind.NO_MATCH
A pattern does not match the target.
LibErrorKind.LIMIT¶
Mojo
comptime LIMIT = LibErrorKind(4)
Python
LibErrorKind.LIMIT
The library exhausted its caller's work budget.
LibErrorKind.WRONG_KERNEL¶
Mojo
comptime WRONG_KERNEL = LibErrorKind(5)
Python
LibErrorKind.WRONG_KERNEL
A library structure received a handle belonging to another kernel.
LibErrorKind.UNSUPPORTED¶
Mojo
comptime UNSUPPORTED = LibErrorKind(6)
Python
LibErrorKind.UNSUPPORTED
The library does not implement the requested operation.
LibErrorKind.FORMAT¶
Mojo
comptime FORMAT = LibErrorKind(7)
Python
LibErrorKind.FORMAT
A recipe or other library input has a malformed representation.
LibErrorKind.BAD_HANDLE¶
Mojo
comptime BAD_HANDLE = LibErrorKind(8)
Python
LibErrorKind.BAD_HANDLE
A prebuilt-core client passed a freed, stale or foreign handle; the Mojo API never raises it.
LibErrorKind.BUSY¶
Mojo
comptime BUSY = LibErrorKind(9)
Python
LibErrorKind.BUSY
A prebuilt-core client called a session busy with another call; the Mojo API never raises it.
LibErrorKind.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write the kind's name.
Arguments.
writer: The writer receiving the name.
LibError¶
Mojo
struct LibError(ConstructionFailure, Movable)
| Field | Type | Description |
|---|---|---|
kind |
LibErrorKind |
The library's classification of the failure. |
message |
String |
A description for people; clients branch on the kinds. |
kernel_kind |
Optional[ErrorKind] |
The original kernel kind, retained when an operation gives the failure a library classification. |
refusal |
Optional[Refusal] |
The stateless checker’s original kind, row, tag, detail and operand, when available. |
check_fail |
Optional[CheckFail] |
A term checker failure retaining kind, detail and operand, without inventing a row coordinate. |
Python
from judgment import JudgmentError
Python constructor:
def __init__(self, kind, kernel_kind, message)
| Field | Description |
|---|---|
kind |
The library's classification of the failure. |
message |
A description for people; clients branch on the kinds. |
kernel_kind |
The original kernel kind, retained when an operation gives the failure a library classification. |
Carry a library failure and, for a kernel refusal, its original kind.
Defined in src/judgment_shell/errors.mojo.
LibError.__init__¶
Mojo
def __init__(out self, kind: LibErrorKind, message: String, kernel_kind: Optional[ErrorKind] = None)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Make an error with explicit provenance.
A kernel refusal converts through the KernelError constructor. For
a library failure, supply its kind and message and leave
kernel_kind absent.
Arguments.
kind: The library error kind.message: The failure's description.kernel_kind: The original kernel kind for aKERNELerror.
LibError.__init__¶
Mojo
@implicit
def __init__(out self, error: KernelError)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Wrap a kernel refusal as KERNEL, keeping its kind and message verbatim.
The conversion is implicit: a kernel call inside a function declared
raises LibError converts its refusal where it raises.
Arguments.
error: The kernel refusal to preserve.
LibError.__init__¶
Mojo
@implicit
def __init__(out self, error: BankError)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Preserve a bank failure through the typed kernel mapping.
Arguments.
error: The bank's typed cause.
LibError.__init__¶
Mojo
@implicit
def __init__(out self, error: CheckFail)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Preserve a term failure's kind, detail and operand.
Arguments.
error: The checker failure before any diagnostic formatting.
LibError.__init__¶
Mojo
@implicit
def __init__[K: KeyElement & Writable](out self, error: DictKeyError[K])
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Classify a missing internal lookup without interpreting its key.
Parameters.
K: The dictionary's key type.
Arguments.
error: The failed lookup.
LibError.from_kind¶
Mojo
@staticmethod
def from_kind(kind: ErrorKind, message: String) -> Self
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Retain the construction algorithm's typed refusal.
Arguments.
kind: The kernel category.message: The diagnostic for people.
Returns. A KERNEL error with the original kind.
LibError.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write the kind, optional kernel kind, and message.
Arguments.
writer: The writer receiving the diagnostic.
from_refusal¶
def from_refusal(refusal: Refusal) -> LibError
Wrap a stateless checker refusal with its full row diagnostic.
Arguments.
refusal: The checker’s recorded failure.
Returns. A KERNEL error. Its refusal retains the original structured value.
Defined in src/judgment_shell/errors.mojo.
Head index¶
HeadIndex(session, budget) resolves constant and type-constructor heads to
the declarations they name, in the session's theory as it stands when the
index is built; construction charges one unit. declaration(session, head)
returns the declaration, or None for an unknown head or one outside that
theory. The index does not follow later declarations: build a new one after
extending the session, as the example does. view, type_view, and show
accept an index, and also work without one.
"""Look up declaration heads and refresh after extending the session."""
from std.testing import assert_true
from judgment_shell import HeadIndex, Session, TermView, TypeView, type_view, view
from termbank import Budget
def main() raises:
var s = Session()
var budget = Budget(10000)
var index = HeadIndex(s, budget)
var tv = view(s, index, s.true_(), budget)
assert_true(tv.kind() == TermView.CONSTANT)
var scalar_ty = s.declare_type("Scalar")
var before = budget.remaining
var index2 = HeadIndex(s, budget)
var tyv = type_view(s, index2, scalar_ty, budget)
assert_true(tyv.kind() == TypeView.CONSTRUCTOR)
assert_true(budget.remaining < before)
print("head lookup and refresh: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/heads.mojo
Output
head lookup and refresh: ok
HeadIndex¶
struct HeadIndex(Movable)
Map constant and type-constructor heads back to their declarations over a Session.
Defined in src/judgment_shell/_dag_views.mojo.
HeadIndex.__init__¶
def __init__(out self, session: Session, mut budget: Budget) raises LibError
Index the heads visible in session.
Arguments.
session: Owning session.budget: Work allowance.
Raises.
LibError: On closed session or exhaustion.
HeadIndex.declaration¶
def declaration(self, session: Session, head: UInt64) raises LibError -> Optional[Declaration]
Look up the declaration of a head id in session.
Arguments.
session: Owning session.head: Raw head id.
Returns. The matching declaration handle, or None.
Raises.
LibError: WRONG_KERNEL for another owner or KERNEL for a stale index or reused head.
HeadIndex.declaration¶
def declaration(self, head: UInt64) raises LibError -> Optional[UInt32]
Look up the declaration index of a head id.
Arguments.
head: Raw head id.
Returns. The matching declaration index, or None.
Raises.
LibError:KERNELwhen the bank cannot be read.
Term and type views¶
view returns one TermView; type_view returns one TypeView. Compare
kind() with the struct's named tags, then call the corresponding accessor;
another variant's accessor raises SHAPE.
| View tag | Accessor | Payload |
|---|---|---|
TermView.CONSTANT |
constant() |
the constant's head and its type arguments |
TermView.APPLY |
apply() |
the function and its term arguments |
TermView.LAMBDA |
lambda_() |
the binder's type and a display hint |
TermView.LET |
let_() |
the bound value's type |
TermView.LOCAL |
local() |
the local |
TermView.LITERAL |
literal() |
the literal kind's declaration and the value, if it reads one |
TypeView.VARIABLE |
variable() |
the name and the sort's classes |
TypeView.ARROW |
arrow() |
the domain and the codomain |
TypeView.CONSTRUCTOR |
constructor() |
the constructor's head and its type arguments |
A view shows one layer. It charges one unit, plus one per child it exposes,
whatever the term's size. Each child is an ordinary session handle. A
constant applied to term arguments is an application of its instance
c[τ̄], and ACU spines keep their flat, canonical argument order. A lambda's
display hint is x: the bound variable's name is not stored.
open_binder fixes a variable under the given frame, distinct from the
variables the session records there
(L1.6), and returns the
new frame, the variable, and the body instantiated at it; a name the session
already used, or one that begins with ·, is SHAPE. let_value reads a
let-expression's bound value. expr_type reads an expression's type.
"""Inspect terms and types, and open a binder through the session."""
from std.testing import assert_equal, assert_true
from judgment_shell import (
HeadIndex, Session, TermView, TypeView, expr_type, lambda_, let_, let_value, open_binder, type_view, view,
)
from termbank import Budget
def main() raises:
var s = Session()
var prop = s.prop_type()
var p = s.prop("p")
var context = s.base()
var x = s.bound_var("x", prop)
var lam = lambda_(x, x)
var budget = Budget(10000)
var index = HeadIndex(s, budget)
var term = view(s, index, lam, budget)
assert_equal(term.kind(), TermView.LAMBDA)
assert_true(term.lambda_()[0].same_as(prop))
var ty = type_view(s, index, expr_type(s, lam, budget), budget)
assert_equal(ty.kind(), TypeView.ARROW)
assert_true(ty.arrow()[0].same_as(prop))
var opened = open_binder(s, context, lam, "fresh", budget)
assert_true(s.lambda_at(context, opened[1], opened[2]).same_as(lam))
var let_expr = let_(s, x, p, x, budget)
assert_true(let_value(s, let_expr, budget).same_as(p))
print("term and type views: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/views.mojo
Output
term and type views: ok
TermView¶
@fieldwise_init
struct TermView(Movable)
One layer of a session's term, as TermView: compare kind() with the tags before reading an accessor.
An accessor for another variant raises SHAPE. Declarations are the session's DECL rows and locals its LOCAL
rows, checked identities: the view keeps the workspace generation it was made at, and an accessor
refuses (KERNEL, stale) once a row it names is gone, as a handle does (G6).
Defined in src/judgment_shell/_dag_views.mojo.
TermView.CONSTANT¶
comptime CONSTANT = UInt8(0)
The constant's declaration and its type arguments: an instance without term arguments.
TermView.APPLY¶
comptime APPLY = UInt8(1)
The function and its term arguments, in canonical order; a constant's spine applies its instance.
TermView.LAMBDA¶
comptime LAMBDA = UInt8(2)
The binder's type and a display hint, x; open the body with open_binder.
TermView.LET¶
comptime LET = UInt8(3)
The bound value's type; read the value with let_value and open the body with open_binder.
TermView.LOCAL¶
comptime LOCAL = UInt8(4)
The local, by its row: identity, not its display name.
TermView.LITERAL¶
comptime LITERAL = UInt8(5)
The literal kind's declaration and the value read in the session's signature, if it reads one.
TermView.kind¶
def kind(self) -> UInt8
This view's variant tag.
Returns. One of the named tags.
TermView.constant¶
def constant(self) raises LibError -> ref[self._data] Tuple[DagHead, List[TypeExpr]]
The CONSTANT payload.
Returns. The declaration and its type arguments.
Raises.
LibError:SHAPEfor another variant;KERNELonce its declaration is stale.
TermView.constant_name¶
def constant_name(self, mut budget: Budget) raises LibError -> String
The CONSTANT payload's declaration by name, as its DECL row names it: a constant at type arguments is
a composite child, which formats as …, so a client names it by this instead, without reading storage.
Arguments.
budget: The caller's allowance: one unit and the name's bytes, charged before the name is read.
Returns. The name; empty for an unnamed declaration (a specification's constants), as dag_declarations lists one. A declaration's later part (a type definition's abstraction or representation) answers its declaration's name.
Raises.
LibError:SHAPEfor another variant;KERNELonce its declaration is stale (G6) or when the bank cannot be read;LIMITon exhaustion.
TermView.apply¶
def apply(self) raises LibError -> ref[self._data] Tuple[Expr, List[Expr]]
The APPLY payload.
Returns. The function and its term arguments.
Raises.
LibError:SHAPEfor another variant.
TermView.lambda_¶
def lambda_(self) raises LibError -> ref[self._data] Tuple[TypeExpr, String]
The LAMBDA payload.
Returns. The binder's type and the display hint.
Raises.
LibError:SHAPEfor another variant.
TermView.let_¶
def let_(self) raises LibError -> TypeExpr
The LET payload.
Returns. The bound value's type.
Raises.
LibError:SHAPEfor another variant.
TermView.local¶
def local(self) raises LibError -> DagLocal
The LOCAL payload.
Returns. The checked local identity.
Raises.
LibError:SHAPEfor another variant;KERNELonce the local is stale.
TermView.literal¶
def literal(self) raises LibError -> ref[self._data] Tuple[Declaration, Optional[LiteralValue]]
The LITERAL payload.
Returns. The kind's declaration and the value, if the session's signature reads one.
Raises.
LibError:SHAPEfor another variant;KERNELonce the kind is stale.
TypeView¶
@fieldwise_init
struct TypeView(Movable)
One layer of a session's type, as TypeView: compare kind() with the tags before reading an accessor.
Its declaration ids are checked on every access, as TermView's are (G6).
Defined in src/judgment_shell/_dag_views.mojo.
TypeView.VARIABLE¶
comptime VARIABLE = UInt8(0)
The name and the sort's classes, as stored: the minimal classes, in the bank's order (K2.8).
TypeView.ARROW¶
comptime ARROW = UInt8(1)
The domain and the codomain.
TypeView.CONSTRUCTOR¶
comptime CONSTRUCTOR = UInt8(2)
The type constructor's declaration and its arguments.
TypeView.kind¶
def kind(self) -> UInt8
This view's variant tag.
Returns. One of the named tags.
TypeView.variable¶
def variable(self) raises LibError -> ref[self._data] Tuple[String, List[Declaration]]
The VARIABLE payload.
Returns. The name and the sort's class declarations.
Raises.
LibError:SHAPEfor another variant;KERNELonce a class is stale.
TypeView.arrow¶
def arrow(self) raises LibError -> ref[self._data] Tuple[TypeExpr, TypeExpr]
The ARROW payload.
Returns. The domain and the codomain.
Raises.
LibError:SHAPEfor another variant.
TypeView.constructor¶
def constructor(self) raises LibError -> ref[self._data] Tuple[DagHead, List[TypeExpr]]
The CONSTRUCTOR payload.
Returns. The type constructor's declaration and its arguments.
Raises.
LibError:SHAPEfor another variant;KERNELonce its declaration is stale.
view¶
def view(session: Session, e: Expr, mut budget: Budget) raises LibError -> TermView
Inspect the top-level structure of e in session.
Arguments.
session: Owning session.e: Expression to inspect.budget: Work allowance.
Returns. Structural TermView.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
type_view¶
def type_view(session: Session, t: TypeExpr, mut budget: Budget) raises LibError -> TypeView
Inspect the top-level structure of type t in session.
Arguments.
session: Owning session.t: Type expression.budget: Work allowance.
Returns. Structural TypeView.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
open_binder¶
def open_binder(session: Session, frame: Frame, e: Expr, name: String, mut budget: Budget, internal: Bool = False) raises LibError -> Tuple[Frame, Expr, Expr]
Open a lambda binder e into a fresh fix frame under frame.
The local is fixed over frame, distinct from the variables the session records there: its name is
variant(frame, type, name) and name is its label. An internal opening fixes it under the reserved name ·
and name instead, shared by every internal opening of that name, type and frame. The body is instantiated at
the local; a let's value is not substituted (read it with let_value). The opened body is a new expression built now, so it is canonical for
the current signature: a statement declared before an ACU declaration opens re-canonicalized for it, and a reader
that needs the statement as declared reads its stored node instead. Atomic: the local and its frame are published only when the whole
operation succeeds. The frame must contain the term's locals.
Arguments.
session: Owning session.frame: Enclosing frame.e: Lambda expression.name: Fresh local name.budget: Work allowance.internal: Whether to bypass user-name restrictions: the name is not recorded as the session's.
Returns. Tuple (child_frame, local_expr, body_expr).
Raises.
LibError:WRONG_KERNELfor foreign handles;SHAPEfor another form, a used or reserved name (one that begins with·) or a frame without the term's locals;KERNELfor a stale handle or a refused row;LIMITon exhaustion.
Defined in src/judgment_shell/_dag_views.mojo.
let_value¶
def let_value(session: Session, e: Expr, mut budget: Budget) raises LibError -> Expr
Read the bound value of a let-expression e.
Arguments.
session: Owning session.e: Let expression.budget: Work allowance.
Returns. The bound value expression.
Raises.
LibError:WRONG_KERNELfor a foreign handle;SHAPEfor a non-let;KERNELfor a stale handle or an unreadable node;LIMITon exhaustion.
Defined in src/judgment_shell/_dag_views.mojo.
Proposition and term builders¶
Props(session) and Terms(session) build expressions in one session.
Props constructs the core connectives, equality, and quantifiers; binary
imp, or_, and and_ keep the nesting the caller supplies.
all_([a, b, c], budget) gives a ∧ (b ∧ c) and any_ gives
a ∨ (b ∨ c); empty lists give True and False, and a singleton gives
its element. Every element is validated, and a non-proposition raises
SHAPE.
Terms builds type variables, constants by name at type arguments,
applications, lambdas, and integer and rational literals of a registered
literal kind. Application includes beta reduction and ACU normalization.
"""Build propositions and terms through session-bound helpers."""
from std.testing import assert_true
from judgment_shell import Props, Session, Terms
from termbank import Budget
def main() raises:
var s = Session()
var prop = s.prop_type()
var p = s.bound_var("p", prop)
var a = s.prop("a")
var terms = Terms(s)
var identity = terms.lam(p, p)
assert_true(terms.app(identity, [a]).same_as(a))
var props = Props(s)
var implication = props.imp(p, p)
var statement = props.forall_(p, implication)
var budget = Budget(100)
var conjunction = props.all_([statement, props.true_()], budget)
assert_true(conjunction.same_as(props.and_(statement, props.true_())))
assert_true(props.any_([], budget).same_as(props.false_()))
assert_true(budget.remaining < 100)
print("proposition and term builders: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/builders.mojo
Output
proposition and term builders: ok
Props¶
struct Props(Movable)
Proposition builders over a Session.
Defined in src/judgment_shell/_dag_builders.mojo.
Props.__init__¶
def __init__(out self, session: Session, frame: Optional[Frame] = None)
Bind proposition builders to session and an optional frame.
Arguments.
session: Owning session.frame: Optional frame for signature-aware constructors.
Props.true_¶
def true_(self) raises LibError -> Expr
Return True.
Returns. Truth proposition.
Raises.
LibError: On exhaustion.
Props.false_¶
def false_(self) raises LibError -> Expr
Return False.
Returns. Falsehood proposition.
Raises.
LibError: On exhaustion.
Props.not_¶
def not_(self, a: Expr) raises LibError -> Expr
Build ¬a.
Arguments.
a: Proposition.
Returns. Negation.
Raises.
LibError:KERNELfor an ill-typed or stale operand;WRONG_KERNELacross sessions;LIMIT.
Props.and_¶
def and_(self, a: Expr, b: Expr) raises LibError -> Expr
Build a ∧ b.
Arguments.
a: Left conjunct.b: Right conjunct.
Returns. Conjunction.
Raises.
LibError: On non-propositions or exhaustion.
Props.or_¶
def or_(self, a: Expr, b: Expr) raises LibError -> Expr
Build a ∨ b.
Arguments.
a: Left disjunct.b: Right disjunct.
Returns. Disjunction.
Raises.
LibError: On non-propositions or exhaustion.
Props.imp¶
def imp(self, a: Expr, b: Expr) raises LibError -> Expr
Build a → b.
Arguments.
a: Antecedent.b: Consequent.
Returns. Implication.
Raises.
LibError: On non-propositions or exhaustion.
Props.iff¶
def iff(self, a: Expr, b: Expr) raises LibError -> Expr
Build a ↔ b.
Arguments.
a: Left proposition.b: Right proposition.
Returns. Biconditional.
Raises.
LibError: On non-propositions or exhaustion.
Props.eq¶
def eq(self, a: Expr, b: Expr) raises LibError -> Expr
Build a = b.
Arguments.
a: Left expression.b: Right expression.
Returns. Equality proposition.
Raises.
LibError: On type mismatch or exhaustion.
Props.forall_¶
def forall_(self, x: Expr, body: Expr) raises LibError -> Expr
Build ∀x. body.
Arguments.
x: Bound variable.body: Quantified proposition.
Returns. Universal proposition.
Raises.
LibError: On invalid variable, non-proposition body, or exhaustion.
Props.exists_¶
def exists_(self, x: Expr, body: Expr) raises LibError -> Expr
Build ∃x. body.
Arguments.
x: Bound variable.body: Quantified proposition.
Returns. Existential proposition.
Raises.
LibError: On invalid variable, non-proposition body, or exhaustion.
Props.all_¶
def all_(self, parts: List[Expr], mut budget: Budget) raises LibError -> Expr
Build a right-associated conjunction of parts (or True if empty).
Arguments.
parts: Conjunct propositions.budget: Work allowance.
Returns. Conjunction proposition.
Raises.
LibError:LIMITon exhaustion;SHAPEfor a non-proposition; asnot_.
Props.any_¶
def any_(self, parts: List[Expr], mut budget: Budget) raises LibError -> Expr
Build a right-associated disjunction of parts (or False if empty).
Arguments.
parts: Disjunct propositions.budget: Work allowance.
Returns. Disjunction proposition.
Raises.
LibError: On non-propositions or exhaustion.
Terms¶
struct Terms(Movable)
Term builders over a Session.
Defined in src/judgment_shell/_dag_builders.mojo.
Terms.__init__¶
def __init__(out self, session: Session)
Bind term builders to session.
Arguments.
session: Owning session.
Terms.tvar¶
def tvar(self, name: String, sort: List[Class] = List[Class]()) raises LibError -> TypeExpr
Construct a type variable with optional sort constraints.
Arguments.
name: Type variable name.sort: Class constraints.
Returns. Checked type variable.
Raises.
LibError: On invalid name/classes or exhaustion.
Terms.const¶
def const(self, name: String, type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Expr
Import a constant at optional type arguments.
Arguments.
name: Qualified constant name.type_args: Type instantiations.
Returns. Checked constant expression.
Raises.
LibError: On missing constant, bad arity, or exhaustion.
Terms.app¶
def app(self, f: Expr, args: List[Expr]) raises LibError -> Expr
Apply f to args left-associatively.
Arguments.
f: Function expression.args: Argument expressions.
Returns. Checked application expression.
Raises.
LibError:KERNELfor an ill-typed application or a stale handle;WRONG_KERNELacross sessions;LIMIT.
Terms.lam¶
def lam(self, x: Expr, body: Expr) raises LibError -> Expr
Build λx. body.
Arguments.
x: Bound variable.body: Lambda body.
Returns. Checked lambda expression.
Raises.
LibError: On invalid variable or exhaustion.
Terms.integer¶
def integer(self, kind: Declaration, n: Integer) raises LibError -> Expr
Build an integer literal of kind.
Arguments.
kind: Registered literal kind declaration.n: Integer value.
Returns. Checked literal expression.
Raises.
LibError:WRONG_KERNELfor another session;KERNELfor a stale kind;SHAPEfor a wrong declaration or literal form;LIMITon exhaustion. Failure leaves no authored rows.
Terms.integer¶
def integer(self, kind: String, n: Integer) raises LibError -> Expr
Build an integer literal of the named literal kind.
Arguments.
kind: Registered literal kind name.n: Integer value.
Returns. Checked literal expression.
Raises.
LibError:NO_MATCHfor an unknown kind; otherwise as the declaration overload.
Terms.integer¶
def integer(self, kind: Declaration, n: Int) raises LibError -> Expr
Build an integer literal of kind from Int.
Arguments.
kind: Registered literal kind declaration.n: Integer value.
Returns. Checked literal expression.
Raises.
LibError: As the arbitrary-precision overload.
Terms.integer¶
def integer(self, kind: String, n: Int) raises LibError -> Expr
Build an integer literal of the named literal kind from Int.
Arguments.
kind: Registered literal kind name.n: Integer value.
Returns. Checked literal expression.
Raises.
LibError: As the arbitrary-precision overload.
Terms.rational¶
def rational(self, kind: Declaration, q: Rational) raises LibError -> Expr
Build a rational literal of kind.
Arguments.
kind: Registered literal kind declaration.q: Exact rational value.
Returns. Checked literal expression.
Raises.
LibError: Asinteger; an integer-only kind refuses rational values.
Terms.rational¶
def rational(self, kind: String, q: Rational) raises LibError -> Expr
Build a rational literal of the named literal kind.
Arguments.
kind: Registered literal kind name.q: Exact rational value.
Returns. Checked literal expression.
Raises.
LibError:NO_MATCHfor an unknown kind; otherwise as the declaration overload.
Terms.rational¶
def rational(self, kind: Declaration, numerator: Int, denominator: Int) raises LibError -> Expr
Build a rational literal numerator / denominator of kind.
Arguments.
kind: Registered literal kind declaration.numerator: Numerator.denominator: Nonzero denominator.
Returns. Checked literal expression.
Raises.
LibError:SHAPEfor a zero denominator; otherwise as the exact-rational overload.
Terms.rational¶
def rational(self, kind: String, numerator: Int, denominator: Int) raises LibError -> Expr
Build a rational literal numerator / denominator of the named literal kind.
Arguments.
kind: Registered literal kind name.numerator: Numerator.denominator: Nonzero denominator.
Returns. Checked literal expression.
Raises.
LibError:NO_MATCHfor an unknown kind; otherwise as the declaration overload.
Debug printer¶
show(session, e, budget, max_nodes=10000) renders diagnostic text. Core
logic uses its usual symbols, connectives infix and prefix; binders are
named x0, x1, … in traversal order; a local prints as v0, v1, … by
its first occurrence in the printout, whatever its name; literals print by
value. A non-core declaration prints as its name and the session's
declaration index
(name#42), so same-named declarations differ; these labels are stable
within the session, not a serialization. max_nodes bounds the nodes
displayed, the rest replaced by …; exhausting the budget raises LIMIT,
never a truncated success. The printer writes nothing to the session.
"""Print checked propositions with deterministic identity labels and bounds."""
from std.testing import assert_equal
from judgment_shell import HeadIndex, Props, Session, show
from termbank import Budget
def main() raises:
var s = Session()
var props = Props(s)
var formula = props.imp(props.true_(), props.not_(props.false_()))
var budget = Budget(10000)
var index = HeadIndex(s, budget)
assert_equal(show(s, index, formula, budget), "(True → (¬False))")
assert_equal(show(s, index, formula, budget, 0), "…")
print("bounded debug printing: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/show.mojo
Output
bounded debug printing: ok
show¶
def show(session: Session, e: Expr, mut budget: Budget, max_nodes: Int = 10000) raises LibError -> String
Format expression e with bounded work and node count.
Arguments.
session: Owning session.e: Expression to format.budget: Work allowance.max_nodes: Maximum visited nodes.
Returns. Human-readable representation.
Raises.
LibError:WRONG_KERNELfor another session's term;KERNELfor a stale handle or an unreadable node;SHAPEfor a negative bound or a literal that does not decode;LIMITon exhaustion.
Defined in src/judgment_shell/_dag_show.mojo.
Recipes and registries¶
A Recipe(session) is untrusted data for one session: add appends a
RecipeStep and returns its RecipeStepRef, and the caller assigns
recipe.root. A step refers only to earlier steps. A recipe is not
evidence; its handles stay valid while their rows do.
A RecipeStep is one of seven forms: rule, theorem, cite, stored,
derived, certificate, and search. An Operand is one of ten:
step, term, type_, decl, local, hyp, context, decls,
position, and positions. A term is an Expr, a type a TypeExpr, a
stored judgment a Step, and a declaration operand a Fact; a local, a
hypothesis, and a context are each a Frame, a fix frame standing for its
variable and an assume frame for its hypothesis. decls lists the defined
constants a conversion may unfold. Each value holds one form of a closed
sum (RecipeStepForm, RecipeOperandForm), which form() borrows;
kind() derives the numeric tag from the form, and the checked
as_<form>() accessors raise SHAPE for the wrong variant. An
OperandVisitor, one method per form, reads an operand through
visit_operand. A rule step's operands follow the checker's rule_layout.
FactTable(session).add(frame, proposition, recipe) stores a provisional
fact and returns a table-local FactId; its advertised frame and
proposition are checked when it is cited. inspect validates and copies one
fact as a FactSnapshot without expanding its citations.
ExpanderRegistry maps derived-rule names and certificate kinds, in
separate namespaces, to RecipeExpander callbacks with a determinism flag;
register_derived_versioned and register_certificate_versioned also
record a persistence version, and inspect returns an ExpanderInfo. A
duplicate name raises FORMAT. EngineRegistry maps engine names to
RecipeEngine callbacks. Both callbacks return a recipe, which execution
checks like any other.
Recipe.is_closed(facts, expanders, budget) walks every step and cited fact
iteratively. It returns False for a search step or a nondeterministic
expander; invalid roots, references, and citation cycles raise FORMAT, and
unknown expanders UNSUPPORTED.
run_persistent executes a closed recipe for persistence: it refuses
search steps and unversioned or nondeterministic expanders at any depth
before calling any expander, and returns the result with every expander it
actually used.
run_persistent¶
def run_persistent(session: Session, recipe: Recipe, facts: FactTable, expanders: ExpanderRegistry, mut budget: Budget) raises RunFailure -> Tuple[RunResult, List[ExpanderInfo]]
Execute recipe deterministically for persistence, recording used expander versions.
Arguments.
session: Owning session.recipe: Proof recipe.facts: Provisional fact table.expanders: Expander registry.budget: Work allowance.
Returns. (RunResult, used_expanders).
Raises.
RunFailure: On nondeterministic expander, recipe failure, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
RecipeStep¶
@fieldwise_init
struct RecipeStep(Copyable)
Carry one untrusted rule application, fact instance, citation, stored step, or expansion request.
Defined in src/judgment_shell/_dag_recipes.mojo.
RecipeStep.RULE¶
comptime RULE = UInt8(0)
The rule step tag.
RecipeStep.THEOREM¶
comptime THEOREM = UInt8(1)
The theorem step tag.
RecipeStep.CITE¶
comptime CITE = UInt8(2)
The cite step tag.
RecipeStep.STORED¶
comptime STORED = UInt8(3)
The stored step tag.
RecipeStep.DERIVED¶
comptime DERIVED = UInt8(4)
The derived step tag.
RecipeStep.CERTIFICATE¶
comptime CERTIFICATE = UInt8(5)
The certificate step tag.
RecipeStep.SEARCH¶
comptime SEARCH = UInt8(6)
The search step tag.
RecipeStep.kind¶
def kind(self) -> UInt8
Read this step's tag, derived from its form.
Returns. One of the named step tags.
RecipeStep.form¶
def form(self) -> ref[self._data] Choice[RecipeStepForm]
Borrow the step's form, for isa and [C].
Returns. The stored form, without copying it.
RecipeStep.rule¶
@staticmethod
def rule(tag: RuleTag, var operands: List[Operand]) -> Self
Make a rule step.
Arguments.
tag: The rule, validated by recipe consumers.operands: Its operands, validated by recipe consumers.
Returns. The step, taking ownership of the operands.
RecipeStep.theorem¶
@staticmethod
def theorem(fact: Fact, var type_args: List[TypeExpr], var terms: List[Expr], frame: Frame) -> Self
Make a theorem step.
Arguments.
fact: The fact.type_args: Its type arguments.terms: Its term arguments.frame: The result frame.
Returns. The step, taking ownership of the lists.
RecipeStep.cite¶
@staticmethod
def cite(fact: FactId) -> Self
Make a cite step.
Arguments.
fact: The cited fact, validated by recipe consumers.
Returns. The step.
RecipeStep.stored¶
@staticmethod
def stored(step: Step) -> Self
Make a stored step.
Arguments.
step: The checked step, validated by recipe consumers.
Returns. The step.
RecipeStep.derived¶
@staticmethod
def derived(name: String, var operands: List[Operand]) -> Self
Make a derived step.
Arguments.
name: The derived-rule name.operands: Its operands.
Returns. The step, taking ownership of the operands.
RecipeStep.certificate¶
@staticmethod
def certificate(kind: String, var data: List[UInt8], claim: Expr, frame: Frame) -> Self
Make a certificate step.
Arguments.
kind: The certificate kind.data: The certificate's bytes.claim: The claimed proposition.frame: The claimed frame.
Returns. The step, taking ownership of the bytes.
RecipeStep.search¶
@staticmethod
def search(engine: String, query: Expr, frame: Frame) -> Self
Make a search step.
Arguments.
engine: The engine name.query: The proposition to search for.frame: The query's frame.
Returns. The step.
RecipeStep.as_rule¶
def as_rule(self) raises LibError -> ref[self._data._value] RuleStep
Read the rule payload without copying it.
Returns. The borrowed payload.
Raises.
LibError:SHAPEfor another step form.
RecipeStep.as_theorem¶
def as_theorem(self) raises LibError -> ref[self._data._value] TheoremStep
Read the theorem payload without copying it.
Returns. The borrowed payload.
Raises.
LibError:SHAPEfor another step form.
RecipeStep.as_cite¶
def as_cite(self) raises LibError -> FactId
Read the cited fact.
Returns. Its table-local identity.
Raises.
LibError:SHAPEfor another step form.
RecipeStep.as_stored¶
def as_stored(self) raises LibError -> Step
Read the stored step.
Returns. The step.
Raises.
LibError:SHAPEfor another step form.
RecipeStep.as_derived¶
def as_derived(self) raises LibError -> ref[self._data._value] DerivedStep
Read the derived payload without copying it.
Returns. The borrowed payload.
Raises.
LibError:SHAPEfor another step form.
RecipeStep.as_certificate¶
def as_certificate(self) raises LibError -> ref[self._data._value] CertificateStep
Read the certificate payload without copying it.
Returns. The borrowed payload.
Raises.
LibError:SHAPEfor another step form.
RecipeStep.as_search¶
def as_search(self) raises LibError -> ref[self._data._value] SearchStep
Read the search payload without copying it.
Returns. The borrowed payload.
Raises.
LibError:SHAPEfor another step form.
RecipeStepRef¶
@fieldwise_init
struct RecipeStepRef(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
index |
Int |
The zero-based step position. |
Name an earlier step in the same recipe; consumers validate its index.
Defined in src/judgment_shell/_dag_recipes.mojo.
FactId¶
@fieldwise_init
struct FactId(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
index |
Int |
The table-local slot; meaningful only with that fact table. |
Name a provisional fact in its originating session's FactTable.
Defined in src/judgment_shell/_dag_recipes.mojo.
Operand¶
@fieldwise_init
struct Operand(Copyable)
Carry one operand; handle ownership is validated by recipe consumers.
Defined in src/judgment_shell/_dag_recipes.mojo.
Operand.STEP¶
comptime STEP = UInt8(0)
The step operand tag.
Operand.TERM¶
comptime TERM = UInt8(1)
The term operand tag.
Operand.TYPE¶
comptime TYPE = UInt8(2)
The type operand tag.
Operand.DECL¶
comptime DECL = UInt8(3)
The fact (declaration) operand tag.
Operand.LOCAL¶
comptime LOCAL = UInt8(4)
The fix-frame (local) operand tag.
Operand.HYP¶
comptime HYP = UInt8(5)
The assume-frame (hypothesis) operand tag.
Operand.CONTEXT¶
comptime CONTEXT = UInt8(6)
The frame (context) operand tag.
Operand.DECLS¶
comptime DECLS = UInt8(7)
The constants-to-unfold (declaration list) operand tag.
Operand.POSITION¶
comptime POSITION = UInt8(8)
One path through a term's argument slots, for derived rules.
Operand.POSITIONS¶
comptime POSITIONS = UInt8(9)
Several nonoverlapping paths, for derived rewriting.
Operand.kind¶
def kind(self) -> UInt8
Read the operand's tag, derived from its form.
Returns. One of the named operand tags.
Operand.form¶
def form(self) -> ref[self._data] Choice[RecipeOperandForm]
Borrow the operand's form, for isa and [C].
Returns. The stored form, without copying it.
Operand.step¶
@staticmethod
def step(value: RecipeStepRef) -> Self
Make a step operand.
Arguments.
value: An earlier step; validated when the recipe is consumed.
Returns. The operand.
Operand.term¶
@staticmethod
def term(value: Expr) -> Self
Make a term operand.
Arguments.
value: The expression.
Returns. The operand.
Operand.type_¶
@staticmethod
def type_(value: TypeExpr) -> Self
Make a type operand.
Arguments.
value: The type.
Returns. The operand.
Operand.decl¶
@staticmethod
def decl(value: Fact) -> Self
Make a fact operand.
Arguments.
value: The fact.
Returns. The operand.
Operand.local¶
@staticmethod
def local(value: Frame) -> Self
Make a local operand: a fix frame standing for its variable.
Arguments.
value: The fix frame.
Returns. The operand.
Operand.hyp¶
@staticmethod
def hyp(value: Frame) -> Self
Make a hypothesis operand: an assume frame standing for its hypothesis.
Arguments.
value: The assume frame.
Returns. The operand.
Operand.context¶
@staticmethod
def context(value: Frame) -> Self
Make a context operand.
Arguments.
value: The frame.
Returns. The operand.
Operand.decls¶
@staticmethod
def decls(var value: List[Expr]) -> Self
Make a list of defined constants for a conversion to unfold.
Arguments.
value: The constants.
Returns. The operand, taking ownership of the list.
Operand.position¶
@staticmethod
def position(var value: List[Int]) -> Self
Make an argument path for a derived step.
Arguments.
value: Argument indices; an empty list selects the whole term.
Returns. The operand, taking ownership of the path.
Operand.positions¶
@staticmethod
def positions(var value: List[List[Int]]) -> Self
Make a collection of paths for derived rewriting.
Arguments.
value: Paths in the original term, checked on expansion.
Returns. The operand, taking ownership of the paths.
Operand.as_step¶
def as_step(self) raises LibError -> ref[self._data._value] RecipeStepRef
Read a step operand.
Returns. The borrowed payload.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_term¶
def as_term(self) raises LibError -> Expr
Read a term operand.
Returns. The expression.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_type_¶
def as_type_(self) raises LibError -> TypeExpr
Read a type operand.
Returns. The type.
Raises.
LibError:SHAPEfor another operand kind.
Operand.class_¶
@staticmethod
def class_(value: Class) -> Self
Make a class operand, in the declaration slot OF_CLASS reads.
Arguments.
value: The class.
Returns. The operand: a declaration operand holding the class's declaration row.
Operand.as_decl¶
def as_decl(self) raises LibError -> Fact
Read a fact operand.
Returns. The fact.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_local¶
def as_local(self) raises LibError -> Frame
Read a local operand.
Returns. The fix frame.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_hyp¶
def as_hyp(self) raises LibError -> Frame
Read a hypothesis operand.
Returns. The assume frame.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_context¶
def as_context(self) raises LibError -> Frame
Read a context operand.
Returns. The frame.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_decls¶
def as_decls(self) raises LibError -> ref[origin_of(self._data[DeclList].constants)] List[Expr]
Borrow a list of constants to unfold.
Returns. The list, without copying it.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_position¶
def as_position(self) raises LibError -> ref[origin_of(self._data[TermPath].path)] List[Int]
Borrow a position payload.
Returns. The path, without copying it.
Raises.
LibError:SHAPEfor another operand kind.
Operand.as_positions¶
def as_positions(self) raises LibError -> ref[origin_of(self._data[TermPaths].paths)] List[List[Int]]
Borrow a collection of position paths.
Returns. The paths, without copying them.
Raises.
LibError:SHAPEfor another operand kind.
RecipeOperandForm¶
struct RecipeOperandForm(Data)
The forms of a Operand: a closed sum, in operand-code order.
Defined in src/judgment_shell/_dag_recipes.mojo.
RecipeOperandForm.Layer¶
comptime Layer[R: Value] = Cases[RecipeStepRef, TermArg, TypeArg, DeclArg, LocalArg, HypArg, ContextArg, DeclList, TermPath, TermPaths]
The constructors, in operand-code order.
Parameters.
R: The recursive position, unused: the type is not recursive.
OperandVisitor¶
trait OperandVisitor
A read of a recipe operand that tells its forms apart: one method per form, all required.
The compiler admits a visitor only when it implements every method, so a
read cannot omit a form; visit_operand runs it.
Defined in src/judgment_shell/_dag_recipes.mojo.
OperandVisitor.Out¶
comptime Out: Movable & Deinitable
What each method returns.
OperandVisitor.Err¶
comptime Err: Movable & Deinitable
What each method raises; Never for a read that does not raise.
OperandVisitor.step¶
def step(mut self, form: RecipeStepRef) raises Self.Err -> Self.Out
Handle an earlier step.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.term¶
def term(mut self, form: TermArg) raises Self.Err -> Self.Out
Handle a term.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.type_¶
def type_(mut self, form: TypeArg) raises Self.Err -> Self.Out
Handle a type.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.decl¶
def decl(mut self, form: DeclArg) raises Self.Err -> Self.Out
Handle a fact (the declaration operand).
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.local¶
def local(mut self, form: LocalArg) raises Self.Err -> Self.Out
Handle a fix frame (the local operand).
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.hyp¶
def hyp(mut self, form: HypArg) raises Self.Err -> Self.Out
Handle an assume frame (the hypothesis operand).
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.context¶
def context(mut self, form: ContextArg) raises Self.Err -> Self.Out
Handle a context.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.decls¶
def decls(mut self, form: DeclList) raises Self.Err -> Self.Out
Handle the defined constants a conversion unfolds.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.position¶
def position(mut self, form: TermPath) raises Self.Err -> Self.Out
Handle one path through canonical term arguments.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
OperandVisitor.positions¶
def positions(mut self, form: TermPaths) raises Self.Err -> Self.Out
Handle several nonoverlapping paths.
Arguments.
form: Its fields.
Returns. The visitor's result.
Raises. Whatever the visitor raises.
visit_operand¶
@always_inline
def visit_operand[V: OperandVisitor](operand: Operand, mut visitor: V) raises V.Err -> V.Out
Dispatch a recipe operand to a typed visitor.
The arms test the forms in their declaration order, which compile-time assertions fix, so the last form needs no test and no form reaches another's method.
Parameters.
V: Visitor implementingOperandVisitor.
Arguments.
operand: Operand to inspect.visitor: Visitor receiving the unpacked variant.
Returns. Visitor result.
Raises. V.Err: Propagated from the visitor.
Defined in src/judgment_shell/_dag_recipes.mojo.
TermArg¶
@fieldwise_init
struct TermArg(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
term |
Expr |
The handle; its owner and liveness are validated when the recipe is consumed. |
A Operand holding an expression.
Defined in src/judgment_shell/_dag_recipes.mojo.
TypeArg¶
@fieldwise_init
struct TypeArg(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
type |
TypeExpr |
The handle; its owner and liveness are validated when the recipe is consumed. |
A Operand holding a type.
Defined in src/judgment_shell/_dag_recipes.mojo.
DeclArg¶
@fieldwise_init
struct DeclArg(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
fact |
Fact |
The handle; its owner and liveness are validated when the recipe is consumed. |
A Operand holding a fact: a theorem, an axiom or a law.
Defined in src/judgment_shell/_dag_recipes.mojo.
LocalArg¶
@fieldwise_init
struct LocalArg(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The handle; its owner, liveness and kind are validated when the recipe is consumed. |
A Operand holding a fix frame, which stands for its variable.
Defined in src/judgment_shell/_dag_recipes.mojo.
HypArg¶
@fieldwise_init
struct HypArg(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The handle; its owner, liveness and kind are validated when the recipe is consumed. |
A Operand holding an assume frame, which stands for its hypothesis.
Defined in src/judgment_shell/_dag_recipes.mojo.
ContextArg¶
@fieldwise_init
struct ContextArg(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The handle; its owner and liveness are validated when the recipe is consumed. |
A Operand holding a frame as a context.
Defined in src/judgment_shell/_dag_recipes.mojo.
DeclList¶
@fieldwise_init
struct DeclList(Copyable)
| Field | Type | Description |
|---|---|---|
constants |
List[Expr] |
The constants, as expressions whose type arguments are ignored; validated when the recipe is consumed. |
A Operand holding the defined constants a conversion unfolds.
Defined in src/judgment_shell/_dag_recipes.mojo.
TermPath¶
@fieldwise_init
struct TermPath(Copyable)
| Field | Type | Description |
|---|---|---|
path |
List[Int] |
Argument indices; an empty path selects the whole term. |
A Operand holding one path through a term's argument slots, for derived rules.
Defined in src/judgment_shell/_dag_recipes.mojo.
TermPaths¶
@fieldwise_init
struct TermPaths(Copyable)
| Field | Type | Description |
|---|---|---|
paths |
List[List[Int]] |
Paths in the original term, checked on expansion. |
A Operand holding several nonoverlapping paths, for derived rewriting.
Defined in src/judgment_shell/_dag_recipes.mojo.
RecipeStepForm¶
struct RecipeStepForm(Data)
The forms of a RecipeStep: a closed sum, in step-code order.
Defined in src/judgment_shell/_dag_recipes.mojo.
RecipeStepForm.Layer¶
comptime Layer[R: Value] = Cases[RuleStep, TheoremStep, CiteStep, StoredStep, DerivedStep, CertificateStep, SearchStep]
The constructors, in step-code order.
Parameters.
R: The recursive position, unused: the type is not recursive.
RuleStep¶
@fieldwise_init
struct RuleStep(Copyable)
| Field | Type | Description |
|---|---|---|
tag |
RuleTag |
The rule, validated by recipe consumers. |
operands |
List[Operand] |
The rule's operands in rule_layout order, validated by recipe consumers. |
A RecipeStep applying one checker rule, by its RuleTag, through the session's method for it.
Defined in src/judgment_shell/_dag_recipes.mojo.
TheoremStep¶
@fieldwise_init
struct TheoremStep(Copyable)
| Field | Type | Description |
|---|---|---|
fact |
Fact |
The fact. |
type_args |
List[TypeExpr] |
The type arguments, in parameter order. |
terms |
List[Expr] |
The term arguments, outermost universal first. |
frame |
Frame |
The result frame. |
A RecipeStep instantiating a fact (the session's use).
Defined in src/judgment_shell/_dag_recipes.mojo.
CiteStep¶
@fieldwise_init
struct CiteStep(Copyable)
| Field | Type | Description |
|---|---|---|
fact |
FactId |
The cited fact's table-local identity. |
A RecipeStep citing a provisional fact of the originating session.
Defined in src/judgment_shell/_dag_recipes.mojo.
StoredStep¶
@fieldwise_init
struct StoredStep(Copyable)
| Field | Type | Description |
|---|---|---|
step |
Step |
The step, of the recipe's session. |
A RecipeStep reusing an existing checked step.
Defined in src/judgment_shell/_dag_recipes.mojo.
DerivedStep¶
@fieldwise_init
struct DerivedStep(Copyable)
| Field | Type | Description |
|---|---|---|
name |
String |
The exact derived-rule name. |
operands |
List[Operand] |
The operands passed to the expander. |
A RecipeStep expanded by the registered derived-rule expander of its name.
Defined in src/judgment_shell/_dag_recipes.mojo.
CertificateStep¶
@fieldwise_init
struct CertificateStep(Copyable)
| Field | Type | Description |
|---|---|---|
name |
String |
The exact certificate kind. |
certificate |
List[UInt8] |
The certificate's bytes, interpreted by the expander. |
proposition |
Expr |
The claimed proposition, checked against the expansion's result. |
frame |
Frame |
The claimed frame, checked against the expansion's result. |
A RecipeStep expanded by a certificate expander, whose result must prove its stated claim.
Defined in src/judgment_shell/_dag_recipes.mojo.
SearchStep¶
@fieldwise_init
struct SearchStep(Copyable)
| Field | Type | Description |
|---|---|---|
engine |
String |
The exact engine name. |
query |
Expr |
The proposition to search for, checked against the engine's result. |
frame |
Frame |
The query's frame. |
A RecipeStep asking a registered engine for a recipe; never closed or persistent.
Defined in src/judgment_shell/_dag_recipes.mojo.
Recipe¶
struct Recipe(Copyable)
| Field | Type | Description |
|---|---|---|
steps |
List[RecipeStep] |
Steps in execution order, including steps after the designated root. |
root |
RecipeStepRef |
The designated result, invalid until assigned by the caller. |
Own untrusted steps of one session; its handles stay valid while their rows do (G6).
A recipe is not evidence. Consumers check all references and owners.
Defined in src/judgment_shell/_dag_recipes.mojo.
Recipe.__init__¶
def __init__(out self, session: Session)
Start an empty recipe for a session.
Arguments.
session: The owner of all handles the recipe will use.
Recipe.add¶
def add(mut self, var step: RecipeStep) -> RecipeStepRef
Append a step without claiming that it is well formed.
Arguments.
step: The step, moved into the recipe.
Returns. Its reference; set root explicitly when selecting the result.
Recipe.is_closed¶
def is_closed(self, facts: FactTable, expanders: ExpanderRegistry, mut budget: Budget) raises LibError -> Bool
Decide closedness by a bounded, iterative walk of cited facts.
Arguments.
facts: The originating session's fact table.expanders: The expander names and determinism declarations.budget: Shared work allowance, never reset by nested traversal.
Returns. False for SEARCH or a nondeterministic expander; True otherwise.
Raises.
LibError:FORMATfor invalid roots, references, or citation cycles;UNSUPPORTEDfor an unknown expander;WRONG_KERNELfor mixed owners;LIMITfor exhausted work.
FactTable¶
struct FactTable(Movable)
Own session-local facts whose claimed conclusions are checked during execution.
Defined in src/judgment_shell/_dag_recipes.mojo.
FactTable.__init__¶
def __init__(out self, session: Session)
Start an empty fact table for one session.
Arguments.
session: The handles' owner.
FactTable.add¶
def add(mut self, frame: Frame, proposition: Expr, var recipe: Recipe) raises LibError -> FactId
Store a provisional fact; execution must verify its advertised conclusion.
Arguments.
frame: The intended result frame.proposition: The intended proposition.recipe: The recipe, moved into the table.
Returns. A stable table-local fact id.
Raises.
LibError:WRONG_KERNELfor mixed owners;LIMITat the slot ceiling.
FactTable.inspect¶
def inspect(self, d: Session, fact: FactId, mut budget: Budget) raises LibError -> FactSnapshot
Validate and copy one provisional fact without expanding citations.
Arguments.
d: The owning session.fact: A slot in this table.budget: Shared allowance for validation and payload copying.
Returns. An owned snapshot; cited facts keep their table-local identities.
Raises.
LibError:FORMATfor missing facts or malformed references,WRONG_KERNELfor foreign owners,LIMITon exhaustion, orKERNELfor a stale handle. Citation cycles are checked by closedness or execution, not by inspection.
FactSnapshot¶
@fieldwise_init
struct FactSnapshot(Copyable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The advertised result frame. |
proposition |
Expr |
The advertised proposition, not evidence. |
recipe |
Recipe |
An independent copy of the untrusted recipe. |
Own a provisional fact's data. Inspection validates handles and references, not the advertised conclusion; only successful execution establishes it.
Defined in src/judgment_shell/_dag_recipes.mojo.
ExpanderInfo¶
@fieldwise_init
struct ExpanderInfo(Copyable)
| Field | Type | Description |
|---|---|---|
name |
String |
The exact derived name or certificate kind. |
certificate |
Bool |
True for the certificate namespace; False for derived rules. |
version |
String |
The caller-declared version; empty for unversioned registrations. |
deterministic |
Bool |
Whether the callback declares deterministic expansion. |
Describe a registered callback without exposing executable code.
Defined in src/judgment_shell/_dag_recipes.mojo.
RecipeExpander¶
comptime RecipeExpander = def( Session, RecipeStep, List[Step], mut Budget ) raises LibError thin -> Recipe
An expander receives the session, the step, earlier steps' results by RecipeStepRef index, and shared work.
Defined in src/judgment_shell/_dag_recipes.mojo.
RecipeEngine¶
comptime RecipeEngine = def(Session, Expr, Frame, mut Budget) raises LibError thin -> Recipe
An engine callback returns an untrusted recipe for its query in its frame.
Defined in src/judgment_shell/_dag_recipes.mojo.
ExpanderRegistry¶
struct ExpanderRegistry(Movable)
Map derived-rule names and certificate kinds to their declared expanders.
Defined in src/judgment_shell/_dag_recipes.mojo.
ExpanderRegistry.__init__¶
def __init__(out self)
Start with no registered expanders.
ExpanderRegistry.register_derived¶
def register_derived(mut self, name: String, callback: RecipeExpander, deterministic: Bool, mut budget: Budget) raises LibError
Register an unversioned derived-rule expander.
Arguments.
name: The exact step name.callback: The function producing a recipe, using only supplied premises.deterministic: Whether output depends only on operands and session answers.budget: Shared allowance charged for the name.
Raises.
LibError:FORMATfor a duplicate name;LIMITfor exhausted work.
ExpanderRegistry.register_certificate¶
def register_certificate(mut self, kind: String, callback: RecipeExpander, deterministic: Bool, mut budget: Budget) raises LibError
Register an unversioned certificate expander whose result must prove its stated claim.
Arguments.
kind: The exact certificate kind.callback: The function producing a recipe for the claim and frame.deterministic: Whether expansion is deterministic.budget: Shared allowance charged for the name.
Raises.
LibError:FORMATfor a duplicate kind;LIMITfor exhausted work.
ExpanderRegistry.register_derived_versioned¶
def register_derived_versioned(mut self, name: String, version: String, callback: RecipeExpander, deterministic: Bool, mut budget: Budget) raises LibError
Register a derived expander with an explicit persistence version.
Arguments.
name: The nonempty derived name.version: The nonempty version identifying callback behavior.callback: The recipe-producing callback, still checked on execution.deterministic: Whether expansion is deterministic.budget: Shared allowance for copying metadata.
Raises.
LibError:FORMATfor empty metadata or duplicate names;LIMITon exhaustion. Failure leaves the registry unchanged.
ExpanderRegistry.register_certificate_versioned¶
def register_certificate_versioned(mut self, kind: String, version: String, callback: RecipeExpander, deterministic: Bool, mut budget: Budget) raises LibError
Register a certificate expander with an explicit persistence version.
Arguments.
kind: The nonempty certificate kind.version: The nonempty version identifying callback behavior.callback: The recipe-producing callback, still checked on execution.deterministic: Whether expansion is deterministic.budget: Shared allowance for copying metadata.
Raises.
LibError:FORMATfor empty metadata or duplicate kinds;LIMITon exhaustion. Failure leaves the registry unchanged.
ExpanderRegistry.inspect¶
def inspect(self, name: String, certificate: Bool, mut budget: Budget) raises LibError -> ExpanderInfo
Read public metadata for one exact name and namespace.
Arguments.
name: The derived name or certificate kind.certificate: Select the certificate namespace when True.budget: Shared allowance for lookup and metadata copying.
Returns. An independent metadata value. Persistence consumers must reject an empty version or a nondeterministic callback.
Raises.
LibError:UNSUPPORTEDfor a missing name;LIMITon exhaustion.
EngineRegistry¶
struct EngineRegistry(Movable)
Map engine names to recipe-producing callbacks.
Defined in src/judgment_shell/_dag_recipes.mojo.
EngineRegistry.__init__¶
def __init__(out self)
Start with no registered engines.
EngineRegistry.register¶
def register(mut self, name: String, callback: RecipeEngine, mut budget: Budget) raises LibError
Register a recipe-producing engine callback.
Arguments.
name: The exact SEARCH name.callback: The function receiving the session, query, frame and budget.budget: Shared allowance charged for the name.
Raises.
LibError:FORMATfor a duplicate name;LIMITfor exhausted work.
Recipe execution¶
run executes a recipe through the session's checked operations, step by
step and iteratively, with citations memoized within one call. A rule step
names its checker rule by RuleTag and is dispatched to the session's
method for it; rules with no session counterpart are UNSUPPORTED.
Citations, certificates, and searches must prove exactly their advertised
proposition at their advertised frame. Execution is atomic: a run opens a
nested transaction, commits it with the root's step retained on success,
and discards it on failure, so a failed run leaves no rows. A failure
(RunFailure) names the first failing outer step and keeps the original
library error. A successful RunResult holds the root's checked step and
the number of completed steps. To keep the result as a theorem, declare it
with Session.prove_step.
"""Execute a closed recipe in a session and verify its checked conclusion."""
from std.testing import assert_equal, assert_true
from judgment_core import RuleTag
from judgment_shell import EngineRegistry, ExpanderRegistry, FactTable, Operand, Recipe, RecipeStep, Session, run
from termbank import Budget
def main() raises:
var s = Session()
var context = s.base()
var recipe = Recipe(s)
var truth = recipe.add(RecipeStep.rule(RuleTag.TRUTH, [Operand.context(context)]))
var both = recipe.add(RecipeStep.rule(RuleTag.AND_INTRO, [Operand.step(truth), Operand.step(truth)]))
recipe.root = recipe.add(RecipeStep.rule(RuleTag.AND_LEFT, [Operand.step(both)]))
var facts = FactTable(s)
var expanders = ExpanderRegistry()
var engines = EngineRegistry()
var budget = Budget(10000)
assert_equal(recipe.is_closed(facts, expanders, budget), True)
var direct = run(s, recipe, facts, expanders, engines, budget)
assert_true(direct.step.statement().same_as(s.true_()))
assert_equal(len(direct.step.hypotheses()), 0)
print("recipe execution and checking: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/recipes.mojo
Output
recipe execution and checking: ok
RunResult¶
@fieldwise_init
struct RunResult(Copyable)
| Field | Type | Description |
|---|---|---|
step |
Step |
The root's checked step. |
steps_run |
Int |
Completed source steps, including expansion wrappers and memoized citations. |
The designated root's checked step and the number of executed recipe steps.
Defined in src/judgment_shell/_dag_run.mojo.
RunFailure¶
@fieldwise_init
struct RunFailure(Copyable, Movable, Writable)
| Field | Type | Description |
|---|---|---|
step |
RecipeStepRef |
The outer recipe's step; the root reference for recipe-level errors. |
error |
LibError |
The original library error, including any kernel kind and message. |
Identify the first failing top-level step and preserve its library error.
Defined in src/judgment_shell/_dag_run.mojo.
RunFailure.write_to¶
def write_to(self, mut writer: Some[Writer])
Write the step and failure.
Arguments.
writer: The destination.
run¶
def run(session: Session, recipe: Recipe, facts: FactTable, expanders: ExpanderRegistry, engines: EngineRegistry, mut budget: Budget) raises RunFailure -> RunResult
Execute recipe atomically on session and return its checked step.
Arguments.
session: Owning session.recipe: Proof recipe.facts: Provisional fact table.expanders: Expander registry.engines: Engine registry.budget: Work allowance.
Returns. Checked RunResult.
Raises.
RunFailure: On recipe failure or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
Derived rules¶
Derived rules compose the session's checked rules and return checked steps.
register_derived_rules(registry, budget) installs their 26 recipe forms,
deterministic and at version 1, each expanded by the same helper as the
direct function; registration fails with FORMAT on a name already
registered and leaves the registry unchanged. The recipe names are the
functions' names, and connective_laws.<field> for the eight connective
laws.
congruence selects one occurrence of an equality's left side; rewrite
selects several nonoverlapping occurrences in a proved proposition. Paths
index the canonical syntax: a constant's type arguments occupy slots but
cannot be selected, a nonconstant application has its function in slot 0,
and a lambda's body is reached through the lambda. The empty path selects
the root.
exists_elim discharges a witness's assumption frame and its fix frame;
the result cannot mention the witness. classical_cases and
by_contradiction require an explicit excluded-middle fact, which remains a
dependency, and funext_of an explicit extensionality fact.
equal_of_iff uses the core's propositional-extensionality axiom.
apply_theorem instantiates a fact and eliminates its leading implications
with the supplied evidence. guarded_export discharges assumption frames
into one guarded implication.
connective_laws proves eight universally quantified biconditionals for
conjunction and disjunction associativity, commutativity, idempotence, and
right units. They are constructive: they depend on the core iff
definition and no profile axiom.
Invalid shapes or paths raise SHAPE, malformed recipe operands FORMAT,
and kernel refusals keep their kind under KERNEL. The complete
signatures are in the L2.3 design.
"""Use direct derived rules and check their recipe forms in a session."""
from std.testing import assert_true
from judgment_shell import (
EngineRegistry, ExpanderRegistry, FactTable, Operand, Props, Recipe,
RecipeStep, Session, connective_laws, equal_of_iff, iff_intro,
register_derived_rules, run,
)
from termbank import Budget
def main() raises:
var s = Session()
var root = s.base()
var truth = s.true_()
var assumed = s.assume(root, truth)
var identity = s.imp_intro(assumed, s.hypothesis(assumed))
var equivalent = iff_intro(s, identity, identity)
var equal = equal_of_iff(s, equivalent)
var props = Props(s)
var expected = props.eq(truth, truth)
assert_true(equal.statement().same_as(expected))
var budget = Budget(100000)
var expanders = ExpanderRegistry()
register_derived_rules(expanders, budget)
var recipe = Recipe(s)
var premise = recipe.add(RecipeStep.stored(identity))
var iff_step = recipe.add(RecipeStep.derived("iff_intro", [Operand.step(premise), Operand.step(premise)]))
recipe.root = recipe.add(RecipeStep.derived("equal_of_iff", [Operand.step(iff_step)]))
var facts = FactTable(s)
var engines = EngineRegistry()
var result = run(s, recipe, facts, expanders, engines, budget)
assert_true(result.step.statement().same_as(expected))
var laws = connective_laws(s, budget)
_ = laws.and_assoc.statement()
_ = laws.or_unit.statement()
print("derived rules and constructive laws: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/derived.mojo
Output
derived rules and constructive laws: ok
move_to¶
def move_to(session: Session, step: Step, frame: Frame) raises LibError -> Step
Move a checked step to an extending frame.
Arguments.
session: Owning session.step: Checked step.frame: Target frame extendingstep's frame.
Returns. Checked step at frame.
Raises.
LibError:SHAPEwhen the frame does not extend the step's; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
chain¶
def chain(session: Session, steps: List[Step]) raises LibError -> Step
Chain a non-empty list of equalities or implications.
Arguments.
session: Owning session.steps: Steps to chain in order.
Returns. Chained checked step.
Raises.
LibError: On empty list, mismatched endpoints, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
congruence¶
def congruence(session: Session, equation: Step, term: Expr, position: List[Int]) raises LibError -> Step
Lift an equality equation into term at canonical position.
Arguments.
session: Owning session.equation: Checked equality step.term: Enclosing expression.position: Canonical slot path.
Returns. Checked equality on the enclosing expression.
Raises.
LibError:SHAPEfor an equation not authored as one, or a bad or non-matching position; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
rewrite¶
def rewrite(session: Session, equation: Step, step: Step, positions: List[List[Int]]) raises LibError -> Step
Rewrite selected canonical positions of step using equation.
Arguments.
session: Owning session.equation: Checked equality step.step: Target step.positions: Non-overlapping canonical slot paths.
Returns. Rewritten checked step.
Raises.
LibError: On invalid paths or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
apply_theorem¶
def apply_theorem(session: Session, frame: Frame, fact: Fact, terms: List[Expr], evidence: List[Step], type_args: List[TypeExpr] = List[TypeExpr]()) raises LibError -> Step
Instantiate fact at frame and eliminate its leading implications with evidence.
Arguments.
session: Owning session.frame: Proof frame.fact: Declared fact.terms: Term instantiations.evidence: Premise steps.type_args: Optional type instantiations.
Returns. Derived conclusion step.
Raises.
LibError: Whatuse,and_introandimp_elimraise.
Defined in src/judgment_shell/_dag_derived.mojo.
exists_intro¶
def exists_intro(session: Session, frame: Frame, variable: Expr, body: Expr, witness: Expr, evidence: Step) raises LibError -> Step
Introduce an existential ∃variable. body from witness and evidence.
Arguments.
session: Owning session.frame: Proof frame.variable: Bound variable.body: Existential body.witness: Witness term.evidence: Proof ofbody[witness/variable].
Returns. Checked existential step.
Raises.
LibError: On mismatch or exhaustion.
Defined in src/judgment_shell/_dag_derived.mojo.
exists_elim¶
def exists_elim(session: Session, existence: Step, fixed: Frame, assumed: Frame, branch: Step) raises LibError -> Step
Eliminate an existential existence using witness frame fixed and body assumption assumed.
Arguments.
session: Owning session.existence: Proof of∃x. P x.fixed: Fix frame introducing freshx.assumed: Assumption frame forP x.branch: Conclusion step not mentioningx.
Returns. Discharged conclusion step.
Raises.
LibError:SHAPEfor an existence not authored as an existential; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
iff_intro¶
def iff_intro(session: Session, forward: Step, backward: Step) raises LibError -> Step
Introduce P ↔ Q from P → Q and Q → P.
Arguments.
session: Owning session.forward: Proof ofP → Q.backward: Proof ofQ → P.
Returns. Checked biconditional step.
Raises.
LibError:SHAPEfor a forward step not authored as an implication; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
iff_left¶
def iff_left(session: Session, step: Step) raises LibError -> Step
Project P → Q from P ↔ Q.
Arguments.
session: Owning session.step: Proof ofP ↔ Q.
Returns. Checked implication P → Q.
Raises.
LibError:SHAPEfor a step not authored as a biconditional; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
iff_right¶
def iff_right(session: Session, step: Step) raises LibError -> Step
Project Q → P from P ↔ Q.
Arguments.
session: Owning session.step: Proof ofP ↔ Q.
Returns. Checked implication Q → P.
Raises.
LibError:SHAPEfor a step not authored as a biconditional; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
not_intro¶
def not_intro(session: Session, frame: Frame, falsehood: Step) raises LibError -> Step
Introduce ¬P from an assumption frame frame for P deriving False.
Arguments.
session: Owning session.frame: Assumption frame forP.falsehood: Proof ofFalseunderframe.
Returns. Checked step concluding ¬P.
Raises.
LibError: On non-assumption frame or exhaustion.
Defined in src/judgment_shell/_dag_derived.mojo.
contradiction¶
def contradiction(session: Session, negative: Step, positive: Step) raises LibError -> Step
Derive False from ¬P and P.
Arguments.
session: Owning session.negative: Proof of¬P.positive: Proof ofP.
Returns. Checked step concluding False.
Raises.
LibError: On mismatch or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
cases¶
def cases(session: Session, disjunction: Step, left_frame: Frame, left: Step, right_frame: Frame, right: Step) raises LibError -> Step
Eliminate P ∨ Q using case frames left_frame and right_frame.
Arguments.
session: Owning session.disjunction: Proof ofP ∨ Q.left_frame: Assumption frame forP.left: Proof ofCunderleft_frame.right_frame: Assumption frame forQ.right: Proof ofCunderright_frame.
Returns. Checked step concluding C.
Raises.
LibError: On mismatch or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
classical_cases¶
def classical_cases(session: Session, excluded_middle: Fact, parent: Frame, left_frame: Frame, left: Step, right_frame: Frame, right: Step) raises LibError -> Step
Perform classical case split using excluded_middle.
Arguments.
session: Owning session.excluded_middle: Excluded-middle fact.parent: Enclosing frame.left_frame: Assumption frame forP.left: Proof ofCunderleft_frame.right_frame: Assumption frame for¬P.right: Proof ofCunderright_frame.
Returns. Checked step concluding C.
Raises.
LibError:SHAPEfor a right assumption that is not the left one's negation, or a fact whose instance is notφ ∨ ¬φ; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
by_contradiction¶
def by_contradiction(session: Session, excluded_middle: Fact, parent: Frame, negated: Frame, falsehood: Step) raises LibError -> Step
Prove P classically from ¬P ⊢ False.
Arguments.
session: Owning session.excluded_middle: Excluded-middle fact.parent: Enclosing frame.negated: Assumption frame for¬P.falsehood: Proof ofFalseundernegated.
Returns. Checked step concluding P.
Raises.
LibError:SHAPEfor an assumption that is not a negation or a fact whose instance is notφ ∨ ¬φ; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
equal_of_iff¶
def equal_of_iff(session: Session, step: Step) raises LibError -> Step
Convert P ↔ Q into propositional equality P = Q.
Arguments.
session: Owning session.step: Proof ofP ↔ Q.
Returns. Checked step concluding P = Q.
Raises.
LibError:SHAPEfor a step not authored as a biconditional; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
funext_of¶
def funext_of(session: Session, extensionality: Fact, type_args: List[TypeExpr], f: Expr, g: Expr, fixed: Frame, pointwise: Step) raises LibError -> Step
Derive f = g from a pointwise proof f x = g x under fixed.
Arguments.
session: Owning session.extensionality: Function extensionality fact.type_args: Domain and codomain type arguments.f: Left function.g: Right function.fixed: Fix frame introducingx.pointwise: Proof off x = g xatfixed.
Returns. Checked step concluding f = g.
Raises.
LibError:SHAPEfor a fact that does not concludef = g; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
guarded_export¶
def guarded_export(session: Session, step: Step, frames: List[Frame]) raises LibError -> Step
Export step across assumption frames as a guarded implication.
Arguments.
session: Owning session.step: Checked step.frames: Assumption frames to discharge.
Returns. Guarded implication step.
Raises.
LibError:SHAPEfor a frame that is not an assumption; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
ConnectiveLaws¶
struct ConnectiveLaws(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
and_assoc |
Step |
∀a b c. (a ∧ b) ∧ c ↔ a ∧ (b ∧ c). |
and_comm |
Step |
∀a b. a ∧ b ↔ b ∧ a. |
and_idem |
Step |
∀a. a ∧ a ↔ a. |
and_unit |
Step |
∀a. a ∧ True ↔ a. |
or_assoc |
Step |
∀a b c. (a ∨ b) ∨ c ↔ a ∨ (b ∨ c). |
or_comm |
Step |
∀a b. a ∨ b ↔ b ∨ a. |
or_idem |
Step |
∀a. a ∨ a ↔ a. |
or_unit |
Step |
∀a. a ∨ False ↔ a. |
Eight constructive biconditionals, as ConnectiveLaws: their variables quantified in argument order,
associativity left to right, units (True, False) on the right. Closed steps at the session's base frame.
Defined in src/judgment_shell/_dag_connective_laws.mojo.
ConnectiveLaws.__init__¶
def __init__(out self, laws: List[Step])
The laws in field order.
Arguments.
laws: Eight steps.
connective_laws¶
def connective_laws(session: Session, mut budget: Budget) raises LibError -> ConnectiveLaws
Derive standard associativity, commutativity, idempotence, and unit laws for ∧ and ∨.
Arguments.
session: Owning session.budget: Work allowance.
Returns. Checked ConnectiveLaws.
Raises.
LibError:LIMITon exhaustion;KERNELfor a refused row.
Defined in src/judgment_shell/_dag_connective_laws.mojo.
register_derived_rules¶
def register_derived_rules(mut registry: ExpanderRegistry, mut budget: Budget) raises LibError
Register the standard derived-rule expanders in registry.
Arguments.
registry: Expander registry to populate.budget: Work allowance.
Raises.
LibError: On duplicate registration or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
Evidence labels and external claims¶
label(session, claims, step, budget) describes what a step rests on: the
classes of the declarations it depends on, read from the step's
dependencies (Step.dependencies), each declaration classified from the
provenance the session records, CORE for the core's propositional
extensionality and UNCLASSIFIED for an ordinary axiom; and its external
claims. An axiom is PROFILE_AXIOM only when it was declared with
Session.profile_axiom, as Scalar's axioms and the classical principles
are, or when the snapshot the session was opened over lists it as a
profile axiom: a seal lists the sealed session's, and the Store's
Library.snapshot and profile_snapshot list the profile's classical
principles. The class goes with the declaration through rollbacks,
transactions, forks, merges, and seals. label_unchecked() returns an UNCHECKED marker without reading
anything; its empty lists mean unknown, not dependency-free. Labels are
descriptive metadata; the checked step remains the authority.
An external claim is an assumption a decider vouches for, with its query,
decider, and version. assume_claim(session, table, frame, proposition,
query, decider, version, budget) assumes the proposition and registers the
claim on the assumption frame. Claims are keyed by frame and decider: one
proposition assumed twice over one frame is one frame, which can carry one
claim of each decider, and the same decider with another query or version is
FORMAT. A step that uses the hypothesis carries its claims, and label
adds EXTERNAL with one attachment per claim.
export_claims(session, table, step, frames, budget) discharges the frames
and records which implications of the result are claimed guards;
discharge(session, table, guarded, proof, budget) proves the outermost
guard and keeps the deeper ones. The example then discharges the claim with
an axiom, so the final label names no claim.
The associations are keyed by the result's proof row and are untrusted
metadata, never evidence. A rollback, checkout, or discard that drops the
row drops its association, and so does a transaction's commit: a step
exported inside a transaction loses its exported guards when the
transaction commits. Export after the commit to keep them. Conflicting
registrations raise FORMAT, a mismatched claim proposition SHAPE.
"""Preserve sources and track an external claim through export and discharge."""
from std.testing import assert_equal, assert_true
from judgment_shell import (
ClaimTable, DependencyClass, EvidenceLevel, Session,
assume_claim, discharge, export_claims, implies, label, label_unchecked,
)
from termbank import Budget
def main() raises:
var s = Session()
var budget = Budget(100000)
var claims = ClaimTable(s)
var p = s.prop("example.P")
var imported = s.axiom("example.imported", p)
var context = s.base()
var step = s.use(context, imported)
var checked = label(s, claims, step, budget)
assert_equal(checked.level, EvidenceLevel.CHECKED)
assert_true(DependencyClass.UNCLASSIFIED in checked.classes)
var assumed = assume_claim(s, claims, context, p, "prove P", "example-decider", "1", budget)
var result = s.hypothesis(assumed)
var guarded = export_claims(s, claims, result, [assumed], budget)
var expected = implies(p, p)
assert_true(guarded.statement().same_as(expected))
assert_equal(len(guarded.hypotheses()), 0)
var conditional = label(s, claims, guarded, budget)
assert_true(DependencyClass.EXTERNAL in conditional.classes)
assert_equal(conditional.claims[0].decider, "example-decider")
var discharged = discharge(s, claims, guarded, step, budget)
var final_label = label(s, claims, discharged, budget)
assert_true(discharged.statement().same_as(p))
assert_equal(len(final_label.claims), 0)
assert_equal(label_unchecked().level, EvidenceLevel.UNCHECKED)
print("evidence labels and provenance: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/labels.mojo
Output
evidence labels and provenance: ok
DependencyClass¶
@fieldwise_init
struct DependencyClass(Equatable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
code |
UInt8 |
The category number; compare named constants instead. |
Name a dependency category in stable label display order.
Defined in src/judgment_shell/dependency_class.mojo.
DependencyClass.CORE¶
comptime CORE = DependencyClass(0)
The core's propositional extensionality axiom.
DependencyClass.PROFILE_AXIOM¶
comptime PROFILE_AXIOM = DependencyClass(1)
An explicitly registered semantic or classical axiom.
DependencyClass.LITERAL_KIND¶
comptime LITERAL_KIND = DependencyClass(2)
A literal kind or an axiom registered as one of its laws.
DependencyClass.ACU¶
comptime ACU = DependencyClass(3)
An ACU declaration or an axiom registered as one of its laws.
DependencyClass.DEFINITION¶
comptime DEFINITION = DependencyClass(4)
A definition, definitional extension, class, or generated fact.
DependencyClass.THEOREM¶
comptime THEOREM = DependencyClass(5)
A Proven declaration whose dependencies are also labeled.
DependencyClass.INSTANCE¶
comptime INSTANCE = DependencyClass(6)
A class instance or an axiom registered as an instance witness.
DependencyClass.IMPORTED_STATEMENT¶
comptime IMPORTED_STATEMENT = DependencyClass(7)
An unproved imported axiom with a named external source.
DependencyClass.EXTERNAL¶
comptime EXTERNAL = DependencyClass(8)
An open hypothesis or tracked exported guard recorded as a claim.
DependencyClass.CHECKER¶
comptime CHECKER = DependencyClass(9)
A reserved category; the pinned kernel admits no checkers.
DependencyClass.UNCLASSIFIED¶
comptime UNCLASSIFIED = DependencyClass(10)
A dependency with no structural or registered classification.
DependencyClass.write_to¶
def write_to(self, mut writer: Some[Writer])
Write the category's stable name.
Arguments.
writer: The destination for the name.
EvidenceLevel¶
@fieldwise_init
struct EvidenceLevel(Equatable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
code |
UInt8 |
The level number; compare the named constants. |
Distinguish a checked judgment from an unexecuted recipe.
Defined in src/judgment_shell/dependency_class.mojo.
EvidenceLevel.CHECKED¶
comptime CHECKED = EvidenceLevel(0)
The label was read from a live kernel judgment.
EvidenceLevel.UNCHECKED¶
comptime UNCHECKED = EvidenceLevel(1)
The recipe has not supplied checked evidence; dependencies are unknown.
EvidenceLevel.write_to¶
def write_to(self, mut writer: Some[Writer])
Write the checking level.
Arguments.
writer: The destination for the name.
EvidenceLabel¶
struct EvidenceLabel(Copyable)
| Field | Type | Description |
|---|---|---|
level |
EvidenceLevel |
CHECKED for a step; UNCHECKED for a recipe. |
classes |
List[DependencyClass] |
Distinct classes, in their code order. |
declarations |
List[Dependency] |
Distinct declarations, in declaration order. |
claims |
List[ClaimAttachment] |
Open claims in frame order, then tracked exported ones by depth. |
A description of evidence, never a replacement for it, as EvidenceLabel. For an UNCHECKED label the empty
lists mean unknown.
Defined in src/judgment_shell/_dag_labels.mojo.
EvidenceLabel.__init__¶
def __init__(out self, level: EvidenceLevel, var classes: List[DependencyClass], var declarations: List[Dependency], var claims: List[ClaimAttachment])
A label.
Arguments.
level: Its level.classes: Its classes.declarations: Its declarations.claims: Its claims.
label¶
def label(session: Session, claims: ClaimTable, step: Step, mut budget: Budget) raises LibError -> EvidenceLabel
Compute the evidence label of step with respect to claims.
Its claims are the step's open claims, then its exported ones, each listed once by its original frame (and decider), in first-occurrence order.
Arguments.
session: Owning session.claims: Claim table.step: Checked step.budget: Work allowance.
Returns. Computed EvidenceLabel.
Raises.
LibError:WRONG_KERNELfor another session's table;KERNELfor a stale step;LIMIT.
Defined in src/judgment_shell/_dag_labels.mojo.
label_unchecked¶
def label_unchecked() -> EvidenceLabel
Return an unchecked evidence label marker.
Returns. An unchecked EvidenceLabel.
Defined in src/judgment_shell/_dag_labels.mojo.
ExternalClaim¶
@fieldwise_init
struct ExternalClaim(Copyable)
| Field | Type | Description |
|---|---|---|
proposition |
Expr |
The proposition's syntax; checking syntax does not prove it. |
query |
String |
The query sent to the external procedure. |
decider |
String |
The procedure's name. |
version |
String |
The procedure's version. |
Describe an uncertified external assertion, never a proof of it, as ExternalClaim.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
ClaimTable¶
struct ClaimTable(Movable)
Track external decider claims on a Session.
Defined in src/judgment_shell/_dag_claims.mojo.
ClaimTable.__init__¶
def __init__(out self, session: Session)
Create an empty claim table for session.
Arguments.
session: Owning session.
ClaimTable.register¶
def register(self, session: Session, frame: Frame, proposition: Expr, query: String, decider: String, version: String, mut budget: Budget) raises LibError
Register an external decider claim at frame.
Arguments.
session: Owning session.frame: Assumption frame.proposition: Claimed proposition.query: Decider query text.decider: Decider identifier.version: Decider version string.budget: Work allowance.
Raises.
LibError:WRONG_KERNELorKERNELfor foreign or stale handles,SHAPEfor a different assumption,FORMATfor conflicting metadata, orLIMIT.
ClaimTable.inspect¶
def inspect(self, session: Session, step: Step, mut budget: Budget) raises LibError -> ClaimSnapshot
Inspect claims attached to step.
Arguments.
session: Owning session.step: Checked step.budget: Work allowance.
Returns. Snapshot of claims attached to step.
Raises.
LibError:WRONG_KERNELfor another session;KERNELfor a stale step;LIMIT.
ClaimTable.restore¶
def restore(mut self, session: Session, step: Step, snapshot: ClaimSnapshot, mut budget: Budget) raises LibError
Restore claim metadata from snapshot onto step.
Open claims are the session's own (Step.claims) and are only compared. Each guard must name a claimed
assume frame at an implication of the statement's binder prefix, by increasing depth; a frame's claims are
one occurrence each, in the order of the deciders' bytes, at one depth, and must be the frame's claims.
Arguments.
session: Owning session.step: Checked step.snapshot: Previously captured claim snapshot.budget: Work allowance.
Raises.
LibError:SHAPEfor another statement, open claims or positions;FORMATfor unordered or conflicting guards or a frame without a claim;WRONG_KERNEL;KERNEL;LIMIT. Failure leaves the table unchanged; the same restoration again is harmless.
claims.inspect(session, step, budget) returns a ClaimSnapshot of the
step's statement and its exact ClaimAttachments. claims.restore(session,
step, snapshot, budget) puts the associations back on a step with the same
statement, after validating them; an identical restoration is harmless, and
a conflicting one is refused. Restoration never infers an association from
an equal proposition. See the
persistence interfaces.
ClaimAttachment¶
Mojo
@fieldwise_init
struct ClaimAttachment(Copyable, Movable)
| Field | Type | Description |
|---|---|---|
frame |
UInt32 |
The assume frame (the DAG's hypothesis identity, a CONTEXT row). |
position |
Int |
Its index among the step's hypotheses, in frame order. |
proposition |
Expr |
The assumption as authored. |
query |
String |
The query sent to the external procedure. |
decider |
String |
The procedure's name. |
version |
String |
The procedure's version. |
Python
from judgment import ClaimAttachment
An external claim a step rests on: the assume frame whose hypothesis carries it (CONTEXT), its position
among the step's hypotheses, its proposition and the untrusted external metadata.
Defined in src/judgment_shell/_ws_handles.mojo.
ClaimSnapshot¶
struct ClaimSnapshot(Copyable)
| Field | Type | Description |
|---|---|---|
statement |
Expr |
The step's statement. |
context |
List[ClaimAttachment] |
Open claims among its hypotheses, in frame order (position: the hypothesis index). |
guards |
List[ClaimAttachment] |
Exported claims, by increasing depth in its implication/universal prefix (position: the depth). |
A step's claim occurrences, as ClaimSnapshot: untrusted metadata, not a proof.
Defined in src/judgment_shell/_dag_claims.mojo.
ClaimSnapshot.__init__¶
def __init__(out self, statement: Expr, var context: List[ClaimAttachment], var guards: List[ClaimAttachment])
A snapshot.
Arguments.
statement: The step's statement.context: Its open claims.guards: Its exported claims.
assume_claim¶
def assume_claim(session: Session, table: ClaimTable, parent: Frame, proposition: Expr, query: String, decider: String, version: String, mut budget: Budget) raises LibError -> Frame
Assume a proposition and record its external decider claim in table.
Arguments.
session: Owning session.table: Claim table.parent: Parent frame.proposition: Claimed proposition.query: Decider query text.decider: Decider identifier.version: Decider version string.budget: Work allowance.
Returns. Assumption frame carrying the claim.
Raises.
LibError: As for assuming and registering. On failure no frame or registration is published.
Defined in src/judgment_shell/_dag_claims.mojo.
export_claims¶
def export_claims(session: Session, mut table: ClaimTable, step: Step, frames: List[Frame], mut budget: Budget) raises LibError -> Step
Export step across claimed assumption frames.
Used assumptions become implications and used variables universals (the session's discharge); unused frames
are skipped. Guards the step already carries move beneath the new prefix.
Arguments.
session: Owning session.table: Claim table.step: Checked step.frames: Claimed assumption frames.budget: Work allowance.
Returns. Exported guarded step.
Raises.
LibError: Whatdischargeraises;WRONG_KERNEL;LIMIT. Failure records nothing.
Defined in src/judgment_shell/_dag_claims.mojo.
discharge¶
def discharge(session: Session, mut table: ClaimTable, guarded: Step, proof: Step, mut budget: Budget) raises LibError -> Step
Discharge a claimed premise of guarded with proof.
Arguments.
session: Owning session.table: Claim table.guarded: Guarded step.proof: Checked premise proof.budget: Work allowance.
Returns. Discharged step.
Raises.
LibError: Whatimp_elimraises;WRONG_KERNEL;LIMIT. Failure records nothing.
Defined in src/judgment_shell/_dag_claims.mojo.
Matching and metavariables¶
match_terms returns deterministic simultaneous term and type assignments,
each verified by rebuilding the pattern with the session's substitution and
comparing it with the target. Pattern variables are session variables,
normally fixed with fix; every other local is rigid. Matching supports
first-order ACU matching with units, binds a sorted type variable only to
an admissible type, and never splits a literal arithmetically. Results are
ordered, duplicate-free, and capped by limit; the budget bounds the
partition search.
MetaStore represents each placeholder by a variable fixed under its frame;
an assignment must lie under that frame. Assignments are acyclic, failures
leave the assignments and the trail unchanged, and undo restores the exact
trail. instantiate expands assigned placeholders and leaves unassigned
ones as variables.
Pattern¶
struct Pattern(Copyable)
| Field | Type | Description |
|---|---|---|
term |
Expr |
The pattern's syntax. |
variables |
List[Expr] |
Variables to instantiate; all other locals remain rigid. |
Designate variables as first-order pattern variables in a session's term, as Pattern.
Ownership, liveness, duplicate variables, and first-order shape are validated by match_terms; unused
designated variables need no assignment. The term must be authored syntax (as the session's operations build it):
its rebuilding under an assignment follows the authored rows.
Defined in src/judgment_shell/_dag_matching.mojo.
Pattern.__init__¶
def __init__(out self, term: Expr, var variables: List[Expr])
Describe a pattern without performing session operations.
Arguments.
term: The pattern term, of its owning session.variables: Designated variables, moved into the record.
Match¶
struct Match(Copyable)
| Field | Type | Description |
|---|---|---|
assignment |
List[Tuple[Expr, Expr]] |
Used pattern variables and their values, sorted by the variables' local rows. |
type_assignment |
List[Tuple[TypeExpr, TypeExpr]] |
Inferred type variables and values, in the type variables' structural order (T1.6). |
A verified simultaneous term and type assignment in one session, as Match.
Values are subterms of the target, free of the target's bound variables; handles are valid while their rows are (G6).
Defined in src/judgment_shell/_dag_matching.mojo.
Match.__init__¶
def __init__(out self, state: ArcPointer[_DagState], var assignment: List[Tuple[Expr, Expr]], var type_assignment: List[Tuple[TypeExpr, TypeExpr]])
Internal; matches come from match_terms.
Arguments.
state: The session's state.assignment: The term assignment.type_assignment: The type assignment.
match_terms¶
def match_terms(session: Session, p: Pattern, target: Expr, mut budget: Budget, limit: Int = 1, frame: Optional[Frame] = None) raises LibError -> List[Match]
Match pattern p against target.
Search uses an explicit depth-first stack and deterministic multiset partitions. Literals are never arithmetically split. Each candidate is rebuilt with the session's substitution and compared with the target's canonical node. Inputs are the session's terms, canonical as the session builds them; they are not re-certified.
Arguments.
session: Owning session.p: Pattern to match.target: Target expression.budget: Work allowance.limit: Maximum matches to return.frame: Optional scope frame.
Returns. List of Match bindings.
Raises.
LibError:UNSUPPORTEDfor a variable in function position,FORMATfor a negative limit or duplicate variables,SHAPEfor a variable that is not a session variable or a pattern atom standing for a composite term,WRONG_KERNELfor another session's handle,LIMITon exhaustion, orKERNELfor a stale handle or a refused row. Exhaustion never returns a partial result list.
Defined in src/judgment_shell/_dag_matching.mojo.
MetaId¶
struct MetaId(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
index |
Int |
The stable zero-based position in the store. |
A placeholder of its store, by index and variable, as MetaId.
Defined in src/judgment_shell/_dag_metavars.mojo.
MetaId.__init__¶
def __init__(out self, index: Int, row: Int)
Internal; identifiers come from MetaStore.fresh.
Arguments.
index: The position.row: The variable's authored row.
MetaStore¶
struct MetaStore(Movable)
Search assignments of one session, as MetaStore.
A fresh placeholder is a variable fixed under its frame; its value must lie under that frame, before the
variable. Terms and later placeholders that mention it lie under its scope. Unresolved dependencies thus have a
strict allocation order, and expansion in reverse order is finite and iterative. Undo removes assignments only.
Defined in src/judgment_shell/_dag_metavars.mojo.
MetaStore.__init__¶
def __init__(out self, d: Session)
An empty store of a session.
Arguments.
d: The session that allocates its placeholders.
MetaStore.fresh¶
def fresh(mut self, d: Session, type: TypeExpr, frame: Frame, mut budget: Budget) raises LibError -> MetaId
Allocate a typed placeholder whose value must lie under the frame.
A later placeholder whose value may mention this one must be allocated under this one's scope: placeholders
fixed side by side under one frame lie on two chains, and a value mentioning both is refused (KERNEL).
Arguments.
d: The session.type: The type of every assignment.frame: The frame available to the eventual value.budget: Charged before allocation.
Returns. A stable identifier; variable and scope give its session form.
Raises.
LibError:WRONG_KERNELfor another session;LIMIT; whatfixraises.
MetaStore.variable¶
def variable(self, d: Session, m: MetaId) raises LibError -> Expr
The variable that mentions a placeholder in terms.
Arguments.
d: The session.m: An identifier of this store.
Returns. The fixed variable, of the placeholder's type.
Raises.
LibError:FORMAT,WRONG_KERNEL, orKERNELfor a stale handle.
MetaStore.scope¶
def scope(self, d: Session, m: MetaId) raises LibError -> Frame
The frame extended with the placeholder's variable.
Arguments.
d: The session.m: An identifier of this store.
Returns. The frame for search terms and later dependent placeholders.
Raises.
LibError:FORMAT,WRONG_KERNEL, orKERNELfor a stale handle.
MetaStore.value¶
def value(self, d: Session, m: MetaId) raises LibError -> Optional[Expr]
The saved assignment, not expanded.
Arguments.
d: The session.m: An identifier of this store.
Returns. The saved term, or none; instantiate expands.
Raises.
LibError:FORMAT,WRONG_KERNEL, orKERNELfor a stale handle.
MetaStore.mark¶
def mark(self) -> Int
The current undo position.
Returns. The number of accepted assignments on the trail.
MetaStore.undo_to¶
def undo_to(mut self, mark: Int, mut budget: Budget) raises LibError
Restore an earlier assignment state, keeping the placeholders.
Arguments.
mark: An earlier trail length, from zero to the current mark.budget: Precharged before any change.
Raises.
LibError:FORMATfor an invalid mark;LIMITwith no change.
MetaStore.assign¶
def assign(mut self, d: Session, m: MetaId, t: Expr, mut budget: Budget) raises LibError
Validate and trail one assignment, after expanding existing values.
Arguments.
d: The session.m: An unassigned placeholder of this store.t: The proposed value, possibly mentioning placeholders, under the scope of the last one it mentions.budget: Shared by expansion and the occurs check.
Raises.
LibError:SHAPEfor a reassignment, another type, or a value that contains its placeholder;KERNELfor a value outside the placeholder's frame or a stale handle;FORMAT,WRONG_KERNEL,LIMIT. Failure leaves the assignments and the trail unchanged; spent work stays spent.
instantiate¶
def instantiate(session: Session, store: MetaStore, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Expr
Instantiate metavariables in t from store at frame.
Arguments.
session: Owning session.store: Metavariable store.frame: Target frame.t: Template expression.budget: Work allowance.
Returns. Instantiated expression.
Raises.
LibError:WRONG_KERNELfor another session's store;KERNELfor a term outside the frame or a stale handle;LIMIT.
Defined in src/judgment_shell/_dag_metavars.mojo.
Definition transport¶
replace_definitions rewrites a term using an explicit list of constants
and checked equations, preserving binder scope, and returns a checked
Equality. Optional eta contraction requires an explicit extensionality
fact. The helper performs no name lookup or declaration. Scalar's model and
class adapters supply their own equation lists.
replace_definitions¶
def replace_definitions(session: Session, frame: Frame, term: Expr, equations: List[Tuple[Expr, Fact]], mut budget: Budget, extensionality: Optional[Fact] = None, binary: List[Expr] = List[Expr](), monomorphic: Bool = False) raises LibError -> Equality
Rewrite occurrences of constants in term using checked equations.
Replacements apply once to the original constants' occurrences; replacement bodies are not rewritten. Every reconstructed equality is checked. No declaration is found by name and no axiom is introduced.
Arguments.
session: Owning session.frame: Proof frame.term: Expression to rewrite.equations: Constant-to-equation-fact pairs.budget: Work allowance.extensionality: Optional function extensionality fact.binary: Optional binary operator hints.monomorphic: Whether equations are monomorphic.
Returns. Checked Equality.
Raises.
LibError:KERNELfor a stale handle or unusable evidence;SHAPEfor a key that is not a constant;LIMITon exhaustion.
Defined in src/judgment_shell/_dag_transport.mojo.
unfold_definition proves the equality of a term with its unfolding by one
supplied definition.
unfold_definition¶
def unfold_definition(session: Session, frame: Frame, term: Expr, definition: Definition, mut budget: Budget) raises LibError -> Equality
Unfold all occurrences of definition in term with a checked equality proof.
Arguments and the resulting body are not rewritten.
Arguments.
session: Owning session.frame: Proof frame.term: Target expression.definition: Definition to unfold.budget: Work allowance.
Returns. Checked Equality.
Raises.
LibError:SHAPEfor another head;LIMITon exhaustion;KERNELfor a stale handle or a refused row.
Defined in src/judgment_shell/_dag_transport.mojo.
Choice conditionals¶
conditional_body constructs a conditional from a caller-supplied
polymorphic choice operator. conditional_branch proves either branch law,
ite True x y = x or ite False x y = y, from an explicit choice law.
These helpers declare no axioms and perform no name lookup.
conditional_body¶
def conditional_body(session: Session, epsilon: Expr, alpha: TypeExpr) raises LibError -> Expr
Build the standard choice-based ite definition body at type alpha.
Arguments.
session: Owning session.epsilon: Choice constant atalpha.alpha: Branch type.
Returns. Lambda body for ite.
Raises.
LibError:KERNELfor a stale handle or an ill-typed operator.
Defined in src/judgment_shell/_dag_conditionals.mojo.
conditional_branch¶
def conditional_branch(session: Session, frame: Frame, ite: Expr, choice: Fact, alpha: TypeExpr, positive: Bool, mut budget: Budget) raises LibError -> Step
Prove ite True x y = x (or ite False x y = y) using choice.
Arguments.
session: Owning session.frame: Proof frame.ite: Conditional constant atalpha.choice: Choice axiom/theorem fact.alpha: Branch type.positive: True for theTruebranch, False for theFalsebranch.budget: Work allowance.
Returns. Checked branch equation step.
Raises.
LibError:LIMITon exhaustion;KERNELfor a conditional or law of another form.
Defined in src/judgment_shell/_dag_conditionals.mojo.
Guards and supports¶
decide_proposition(session, frame, proposition, facts, budget) returns
checked evidence for a proposition or its negation, or None when unknown.
It recognizes supplied facts, True, False, reflexive equality, and the
connectives ¬, ∧, and ∨; other propositions remain opaque. Every
supplied fact is moved into the requested frame before any shortcut, so it
is validated even when unused, and a fact matches a leaf by conversion
without unfolding. Optional definitions and replacements allow
unfolding and equation replacement at opaque leaves; no declaration name
decides what unfolds.
simplify_proposition uses that decision to prove an equality with a truth
value, or removes a top-level True from a conjunction or False from a
disjunction. It is a local step: callers such as an EqualityWalker
control traversal.
PropositionDecision¶
struct PropositionDecision(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
positive |
Bool |
True when the evidence proves the proposition; False for its negation. |
proof |
Step |
Evidence under the requested frame, retaining only used assumptions. |
A proved truth value, with evidence for the proposition or its negation, as PropositionDecision.
Defined in src/judgment_shell/_dag_propositions.mojo.
PropositionDecision.__init__¶
def __init__(out self, positive: Bool, proof: Step)
A decision.
Arguments.
positive: Whether the evidence proves the proposition.proof: The evidence.
decide_proposition¶
def decide_proposition(session: Session, frame: Frame, proposition: Expr, facts: List[Step], mut budget: Budget, definitions: List[Definition] = List[Definition](), replacements: List[Tuple[Expr, Fact]] = List[Tuple[Expr, Fact]](), monomorphic: Bool = False) raises LibError -> Optional[PropositionDecision]
Attempt bounded propositional decision of proposition from facts.
Recognizes supplied facts, True, False, reflexive equality, and trees of not/and/or. Selected definitions
unfold at proposition heads; quantified bodies stay opaque. At other leaves, replacement equations apply once
before conversion-based fact matching. All facts are validated before any shortcut, unused and duplicate ones
included. The first applicable fact wins; only used evidence contributes assumptions. Traversal is iterative and
memoized per invocation, with caller-charged work; a conversion attempt is charged one unit, its own work bounded
by the checker's scratch rather than the budget.
Arguments.
session: Owning session.frame: Proof frame.proposition: Target proposition.facts: Known checked steps.budget: Work allowance.definitions: Optional definitions to unfold.replacements: Optional equation replacements.monomorphic: Whether replacement equations are monomorphic.
Returns. Checked PropositionDecision or None.
Raises.
LibError:SHAPEfor a non-proposition, a fact under another frame, conflicting replacements or a cyclic unfolding;LIMITon exhaustion;KERNELfor stale handles or refused rows.
Defined in src/judgment_shell/_dag_propositions.mojo.
simplify_proposition¶
def simplify_proposition(session: Session, frame: Frame, proposition: Expr, facts: List[Step], mut budget: Budget) raises LibError -> Optional[Equality]
Simplify proposition relative to facts, returning a checked equality when simplified.
Decides the proposition, then handles True ∧ P, P ∧ True, False ∨ P and P ∨ False when it is undecided.
A local step: callers control descent into other expressions.
Arguments.
session: Owning session.frame: Proof frame.proposition: Proposition to simplify.facts: Known checked steps.budget: Work allowance.
Returns. Checked Equality or None.
Raises.
LibError: Asdecide_proposition.
Defined in src/judgment_shell/_dag_propositions.mojo.
A Guard keeps its factorization in a flat arena. meaning builds its
proposition, and normalize returns the normal form with constructive
implications in both directions. Conjuncts and disjuncts are ordered by the
structural term order.
Support buckets check exact witness statements before retaining a bounded antichain. Eviction drops whole entries; it never weakens an obligation set. Activation accepts checked evidence for immediate children or the whole guard, including a whole disjunction with neither disjunct known.
Guard¶
@fieldwise_init
struct Guard(Movable)
Structured propositional guard over a Session.
Defined in src/judgment_shell/_dag_guards.mojo.
Guard.TOP¶
comptime TOP = UInt8(0)
The always-satisfied guard, with meaning True.
Guard.BOTTOM¶
comptime BOTTOM = UInt8(1)
The impossible guard, with meaning False.
Guard.ATOM¶
comptime ATOM = UInt8(2)
An opaque proposition.
Guard.ALL¶
comptime ALL = UInt8(3)
A conjunction of child guards, preserving their order.
Guard.ANY¶
comptime ANY = UInt8(4)
A disjunction of child guards, preserving their order.
Guard.top¶
@staticmethod
def top(session: Session) -> Self
Return the unconditionally true guard.
Arguments.
session: Owning session.
Returns. TOP guard.
Guard.bottom¶
@staticmethod
def bottom(session: Session) -> Self
Return the unsatisfiable guard.
Arguments.
session: Owning session.
Returns. BOTTOM guard.
Guard.atom¶
@staticmethod
def atom(proposition: Expr) -> Self
Wrap an atomic proposition as a guard.
Arguments.
proposition: Proposition expression.
Returns. ATOM guard.
Guard.all_¶
@staticmethod
def all_(session: Session, var children: List[Self], mut budget: Budget) raises LibError -> Self
Conjoin child guards.
Arguments.
session: Owning session.children: Child guards.budget: Work allowance.
Returns. Conjunction guard.
Raises.
LibError:WRONG_KERNELfor another session's child, orLIMIT.
Guard.any_¶
@staticmethod
def any_(session: Session, var children: List[Self], mut budget: Budget) raises LibError -> Self
Disjoin child guards.
Arguments.
session: Owning session.children: Child guards.budget: Work allowance.
Returns. Disjunction guard.
Raises.
LibError:WRONG_KERNELfor another session's child, orLIMIT.
Guard.kind¶
def kind(self) -> UInt8
Return the guard tag (TOP, BOTTOM, ATOM, ALL, or ANY).
Returns. Guard kind code.
Guard.atom_term¶
def atom_term(self) raises LibError -> Expr
Read the atomic proposition of an ATOM guard.
Returns. Atomic proposition expression.
Raises.
LibError:SHAPEif the root is not ATOM.
Guard.child_count¶
def child_count(self) -> Int
Number of child guards.
Returns. Child count.
Guard.child¶
def child(self, index: Int, mut budget: Budget) raises LibError -> Self
Read the index-th child guard.
Arguments.
index: Zero-based child index.budget: Work allowance.
Returns. Child guard.
Raises.
LibError:FORMATfor an invalid position, orLIMIT.
Guard.clone¶
def clone(self, mut budget: Budget) raises LibError -> Self
Copy this guard, charging budget.
Arguments.
budget: Work allowance.
Returns. Deep copy of this guard.
Raises.
LibError:LIMITon exhaustion.
GuardProofs¶
struct GuardProofs(Movable)
| Field | Type | Description |
|---|---|---|
normalized |
Guard |
The factored normal form; no distribution or classical simplification. |
forward |
Step |
A proof of the original meaning implying the normalized meaning. |
backward |
Step |
A proof of the normalized meaning implying the original meaning. |
Retain a normalized guard and constructive proofs in both directions, as GuardProofs.
Defined in src/judgment_shell/_dag_guards.mojo.
GuardProofs.__init__¶
def __init__(out self, var normalized: Guard, forward: Step, backward: Step)
Retain the normal form and the two implication proofs.
Arguments.
normalized: The normalized guard, consumed by construction.forward: The checked forward implication.backward: The checked backward implication.
meaning¶
def meaning(session: Session, g: Guard, mut budget: Budget, frame: Optional[Frame] = None) raises LibError -> Expr
Build the propositional meaning of guard g.
Arguments.
session: Owning session.g: Structured guard.budget: Work allowance.frame: Optional frame.
Returns. Guard proposition expression.
Raises.
LibError:WRONG_KERNELfor another session's guard or atom,SHAPEfor a non-proposition atom,KERNELfor a stale atom, orLIMIT.
Defined in src/judgment_shell/_dag_guards.mojo.
normalize¶
def normalize(session: Session, frame: Frame, g: Guard, mut budget: Budget) raises LibError -> GuardProofs
Normalize guard g at frame with bidirectional equivalence proofs.
Children of ALL and ANY nodes are flattened, ordered by their meanings' structural order (compare, which
does not depend on interning history), and deduplicated by node.
Arguments.
session: Owning session.frame: Proof frame.g: Structured guard.budget: Work allowance.
Returns. Normalized GuardProofs.
Raises.
LibError:WRONG_KERNELfor another session's guard, atom or frame,SHAPEfor a non-proposition atom,KERNELfor a stale handle or an atom whose locals lie outside the frame,LIMIT, or a refused step.
Defined in src/judgment_shell/_dag_guards.mojo.
SupportEntry¶
struct SupportEntry(Copyable)
| Field | Type | Description |
|---|---|---|
obligations |
List[Expr] |
Propositions treated as a finite set in structural order. |
witness |
Step |
The checked implication, validated by insertion into a bucket. |
Retain obligations and a session witness of their conjunction implying C, as SupportEntry.
Defined in src/judgment_shell/_dag_supports.mojo.
SupportEntry.__init__¶
def __init__(out self, var obligations: List[Expr], witness: Step)
Describe one support for validation by its bucket.
Arguments.
obligations: Proposed obligation set, consumed by construction.witness: The session implication that supplies the owning session.
SupportBucket¶
struct SupportBucket(Movable)
Retain a bounded antichain of independently checked sufficient supports, as SupportBucket.
Entries are sorted by cardinality and then by the obligations' bank node ids; eviction removes the last entry. A bound loses opportunities only: it never removes an obligation from a retained witness. All handles are valid while their rows are; discard or rebuild this bucket after a rollback.
Defined in src/judgment_shell/_dag_supports.mojo.
SupportBucket.__init__¶
def __init__(out self, conclusion: Expr, bound: Int) raises LibError
Create an empty bucket for one fixed conclusion.
Arguments.
conclusion: The proposition, validated at insertion/use.bound: Maximum retained entries; zero retains none.
Raises.
LibError:FORMATfor a negative bound.
SupportBucket.insert¶
def insert(mut self, d: Session, entry: SupportEntry, mut budget: Budget) raises LibError -> Bool
Validate a witness and atomically update the bounded antichain.
Arguments.
d: The owning session.entry: Obligations and their implication witness.budget: Shared allowance for validation, set comparison, and copies.
Returns. True exactly when the retained applicability sets change.
Raises.
LibError:SHAPEfor a mismatched witness or non-proposition,WRONG_KERNEL,KERNELfor a stale handle or an obligation outside the witness's frame,LIMIT, or a refused step. Failure leaves all retained entries unchanged.
SupportBucket.entries¶
def entries(self, mut budget: Budget) raises LibError -> List[SupportEntry]
Copy the retained entries in deterministic applicability order.
Arguments.
budget: Shared allowance charged for each entry and obligation.
Returns. Independent records sharing the same session handles.
Raises.
LibError:LIMITon exhaustion.
SupportBucket.disjunction_proof¶
def disjunction_proof(self, d: Session, frame: Frame, mut budget: Budget) raises LibError -> Step
Prove that the disjunction of retained supports implies the conclusion.
Arguments.
d: The owning session.frame: A frame extending every retained witness's frame.budget: Shared allowance for traversal and constructive cases.
Returns. A session implication; an empty bucket proves False implies C.
Raises.
LibError:SHAPEfor incompatible witness frames,WRONG_KERNEL,KERNELfor a stale handle or a conclusion outside the frame,LIMIT, or a refused step.
Activation¶
struct Activation(Movable)
Track child evidence and expose activation only as a checked step, as Activation.
This record keeps its guard, frame and proofs, valid while their rows are. Whole-disjunction evidence suffices without choosing a disjunct (A13).
Defined in src/judgment_shell/_dag_supports.mojo.
Activation.__init__¶
def __init__(out self, d: Session, var guard: Guard, frame: Frame, mut budget: Budget) raises LibError
Validate a guard and create a frame-specific evidence record.
Arguments.
d: The owning session.guard: The factored guard, consumed by construction.frame: Scope for evidence and the activated step.budget: Shared allowance for validating the guard and its children.
Raises.
LibError:WRONG_KERNEL,SHAPEfor a non-proposition atom,KERNELfor a stale handle or a guard outside the frame,LIMIT, or a refused step.
Activation.evidence¶
def evidence(self, d: Session, mut budget: Budget) raises LibError -> Optional[Step]
Read a validated whole-guard proof if activation has completed.
Arguments.
d: The owning session.budget: Shared work allowance.
Returns. The checked whole guard, or no step while it is unresolved.
Raises.
LibError:WRONG_KERNEL,KERNELfor a stale handle,LIMIT, or a refused step.
Activation.offer_whole¶
def offer_whole(mut self, d: Session, evidence: Step, mut budget: Budget) raises LibError -> Optional[Step]
Activate directly from a proof of the complete guard.
Arguments.
d: The owning session.evidence: A proof at this frame or a frame it extends.budget: Shared allowance for validation and weakening.
Returns. A checked proof of the whole guard at the activation frame.
Raises.
LibError:SHAPEfor another proposition or an incompatible frame,WRONG_KERNEL,KERNELfor a stale handle,LIMIT, or a refused step.
Activation.offer¶
def offer(mut self, d: Session, child: Int, evidence: Step, mut budget: Budget) raises LibError -> Optional[Step]
Offer evidence for one immediate ALL or ANY child.
Arguments.
d: The owning session.child: A zero-based immediate child position.evidence: A proof of that exact child's proposition.budget: Shared allowance for validation and proof construction.
Returns. A whole-guard proof when all conjunction children, one disjunction child, or earlier whole evidence suffice; otherwise no step.
Raises.
LibError:FORMATfor an invalid child,SHAPEfor unsuitable evidence,WRONG_KERNEL,KERNELfor a stale handle,LIMIT, or a refused step. Failure does not publish the proposed child proof.
Theorem store and discrimination index¶
TheoremStore reads records from facts, axioms or theorems used as stated:
the leading universals are opened at fresh variables, the first implication
is the guard, normalized constructively, and the conclusion's left side,
for an equation, is the index key. get returns a record's variables for
matching; instantiate is the session's use of the fact at the given
type and term arguments; apply also discharges the guard with evidence in
the requested frame. A store made with a ClaimTable carries the exported
claim guards of the optional source step a record was registered with.
DiscriminationIndex and the store's candidates return a sorted,
duplicate-free, conservative superset of the matching records: pattern
variables, type variables, and ACU-headed nodes match any subtree, and
literal payloads are not keyed. Check candidates with match_terms.
"""Match a stored claim-backed theorem and discharge its exact guard."""
from std.testing import assert_equal, assert_true
from judgment_shell import (
ClaimTable, LawBundle, Pattern, Session, TheoremStore,
assume_claim, export_claims, match_terms, schemas, validate,
)
from termbank import Budget
def main() raises:
var s = Session()
var budget = Budget(1000000)
var prop = s.prop_type()
var p = s.prop("P")
var root = s.base()
var x = s.fix(root, "X", prop)
var claims = ClaimTable(s)
var h = assume_claim(s, claims, x[0], x[1], "prove X", "example", "1", budget)
var source = export_claims(s, claims, s.hypothesis(h), [h, x[0]], budget)
var fact = s.prove_step("identity", source)
var after = s.base()
var store = TheoremStore(s, claims^)
var id = store.register(s, fact, Optional(source), budget)
var record = store.get(id, budget)
var matches = match_terms(s, Pattern(record.conclusion, record.variables.copy()), p, budget)
assert_equal(len(matches), 1)
assert_true(matches[0].assignment[0][1].same_as(p))
var instance = store.instantiate(s, id, after, [], [p], budget)
assert_equal(len(store.label(s, instance, budget).claims), 1)
var evidence = s.assume(after, p)
var result = store.apply(s, id, evidence, [], [p], s.hypothesis(evidence), budget)
assert_true(result.statement().same_as(p))
assert_equal(len(result.hypotheses()), 1)
assert_equal(len(store.label(s, result, budget).claims), 0)
var bundle = LawBundle(s, "Generic", [("P", p)], [("identity", fact)])
var standard = schemas()
validate(s, bundle, standard[3], budget)
print("matching, guarded theorem use, and bundles: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/store.mojo
Output
matching, guarded theorem use, and bundles: ok
TheoremId¶
@fieldwise_init
struct TheoremId(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
index |
Int |
The zero-based, store-local position. |
Identify a theorem by its stable slot in its originating store.
Defined in src/judgment_shell/_theorem_ids.mojo.
GuardedTheorem¶
struct GuardedTheorem(Movable)
| Field | Type | Description |
|---|---|---|
fact |
Fact |
The registered fact. |
parameters |
List[Tuple[String, TypeExpr]] |
Term parameter names and types, outermost first. |
variables |
List[Expr] |
The opened parameters, fixed variables to match with. |
guard |
Guard |
The normalized antecedent, or TOP for an unguarded fact. |
conclusion |
Expr |
The proposition after the quantifier prefix and the first implication, over the variables. |
frame |
Frame |
The innermost opened parameter's frame (the base for none). |
guarded |
Bool |
Whether the fact has an outer implication after its universals. |
A fact's quantified interface, normalized guard and conclusion, as GuardedTheorem.
Defined in src/judgment_shell/_dag_store.mojo.
GuardedTheorem.__init__¶
def __init__(out self, fact: Fact, var parameters: List[Tuple[String, TypeExpr]], var variables: List[Expr], var guard: Guard, conclusion: Expr, frame: Frame, guarded: Bool, source: Optional[Step])
A record.
Arguments.
fact: The fact.parameters: Its parameters.variables: Its opened parameters.guard: Its normalized guard.conclusion: Its conclusion.frame: The innermost parameter's frame.guarded: Whether it has a guard.source: The step its exported claims are tracked on, if any.
TheoremStore¶
struct TheoremStore(Movable)
Guarded theorem store indexed by conclusion head over a Session.
Defined in src/judgment_shell/_dag_store.mojo.
TheoremStore.__init__¶
def __init__(out self, session: Session)
Create an empty theorem store for session.
Arguments.
session: Owning session.
TheoremStore.__init__¶
def __init__(out self, session: Session, var claims: ClaimTable) raises LibError
Create a theorem store backed by claims.
Arguments.
session: Owning session.claims: Claim table owned bysession.
Raises.
LibError:WRONG_KERNELfor another session's table.
TheoremStore.register¶
def register(mut self, session: Session, fact: Fact, source: Optional[Step], mut budget: Budget) raises LibError -> TheoremId
Register a guarded theorem from fact (and optional provenance source).
Arguments.
session: Owning session.fact: Checked fact to index.source: Optional step carrying claims.budget: Work allowance.
Returns. Assigned TheoremId.
Raises.
LibError:SHAPEfor a source of another statement;KERNELfor a stale handle;LIMIT.
TheoremStore.get¶
def get(self, id: TheoremId, mut budget: Budget) raises LibError -> GuardedTheorem
Look up a registered GuardedTheorem by id.
Arguments.
id: Theorem identifier.budget: Work allowance.
Returns. The stored GuardedTheorem.
Raises.
LibError:FORMATfor another id;KERNELfor a stale handle;LIMIT.
TheoremStore.candidates¶
def candidates(self, session: Session, target: Expr, mut budget: Budget) raises LibError -> List[TheoremId]
Look up candidate theorem ids matching target.
Arguments.
session: Owning session.target: Target expression.budget: Work allowance.
Returns. Candidate theorem identifiers.
Raises.
LibError:WRONG_KERNEL;KERNEL;LIMIT.
TheoremStore.instantiate¶
def instantiate(mut self, session: Session, id: TheoremId, frame: Frame, type_args: List[TypeExpr], terms: List[Expr], mut budget: Budget) raises LibError -> Step
Instantiate theorem id at frame, type_args, and terms.
Arguments.
session: Owning session.id: Theorem identifier.frame: Target frame.type_args: Type instantiations.terms: Term instantiations.budget: Work allowance.
Returns. Instantiated checked step.
Raises.
LibError:FORMATfor another number of terms;SHAPEfor a failed guard readback; whatuseraises;LIMIT.
TheoremStore.apply¶
def apply(mut self, session: Session, id: TheoremId, frame: Frame, type_args: List[TypeExpr], terms: List[Expr], evidence: Step, mut budget: Budget) raises LibError -> Step
Instantiate theorem id and discharge its guard with evidence.
Arguments.
session: Owning session.id: Theorem identifier.frame: Target frame.type_args: Type instantiations.terms: Term instantiations.evidence: Checked guard proof.budget: Work allowance.
Returns. Checked conclusion step.
Raises.
LibError: Whatinstantiateraises;SHAPEfor non-Trueevidence of an unguarded fact.
TheoremStore.label¶
def label(self, session: Session, step: Step, mut budget: Budget) raises LibError -> EvidenceLabel
Label step using the external claims tracked by this store.
Arguments.
session: Owning session.step: Checked step to label.budget: Work allowance.
Returns. The step's evidence label.
Raises.
LibError: On invalid handles or exhaustion.
DiscriminationIndex¶
struct DiscriminationIndex(Movable)
Term-indexing discrimination tree over a Session.
Defined in src/judgment_shell/_dag_index.mojo.
DiscriminationIndex.__init__¶
def __init__(out self, session: Session)
Create an empty index for session.
Arguments.
session: Owning session.
DiscriminationIndex.add¶
def add(mut self, session: Session, id: TheoremId, key_term: Expr, variables: List[Expr], mut budget: Budget) raises LibError
Index id under pattern key_term with pattern variables.
Arguments.
session: Owning session.id: Theorem identifier.key_term: Pattern term.variables: Pattern variables.budget: Work allowance.
Raises.
LibError:FORMATfor a negative id;WRONG_KERNEL;KERNELfor a stale term;LIMIT. Failure leaves the trie unchanged; repeated additions are harmless.
DiscriminationIndex.candidates¶
def candidates(self, session: Session, target: Expr, mut budget: Budget) raises LibError -> List[TheoremId]
Retrieve candidate theorem ids that may match target.
Arguments.
session: Owning session.target: Target expression.budget: Work allowance.
Returns. Candidate theorem identifiers.
Raises.
LibError:WRONG_KERNEL;KERNELfor a stale term;LIMIT.
Law bundles¶
Bundles name constant instances and law facts. Standard schemas build expected types and complete propositions in the session, including domain guards and class instantiations. The specification lists every slot and the canonical class-library mapping. Schema callbacks, name matching, traversal, and construction share the caller's budget.
LawBundle¶
struct LawBundle(Copyable)
| Field | Type | Description |
|---|---|---|
schema |
String |
The schema name this bundle proposes to fill. |
constants |
List[Tuple[String, Expr]] |
Named constant slots, each a constant at its type arguments. |
laws |
List[Tuple[String, Fact]] |
Named statement law slots and their facts. |
acu_laws |
List[Tuple[String, Declaration]] |
Named ACU law slots and their ACU operator declarations. |
law_type_args |
List[Tuple[String, List[TypeExpr]]] |
Optional type instantiations keyed by statement law slot; absent means no arguments. |
Name a session's concrete constants and laws, as LawBundle.
The carrier is inferred from the zero constant's type by the standard
schemas. Type arguments on statement laws support class-theorem
instantiation; they are use's, in its order.
Defined in src/judgment_shell/_dag_bundle_records.mojo.
LawBundle.__init__¶
def __init__(out self, d: Session, var schema: String, var constants: List[Tuple[String, Expr]], var laws: List[Tuple[String, Fact]], var acu_laws: List[Tuple[String, Declaration]] = List[Tuple[String, Declaration]](), var law_type_args: List[Tuple[String, List[TypeExpr]]] = List[Tuple[String, List[TypeExpr]]]())
Retain a proposed bundle for explicit validation.
Arguments.
d: The owning session.schema: The schema name, consumed by construction.constants: Named constant instances, consumed by construction.laws: Named statement law facts, consumed by construction.acu_laws: Named ACU operator declarations, consumed by construction.law_type_args: Type arguments for polymorphic law slots, consumed.
LawBundle.constant¶
def constant(self, d: Session, name: String, mut budget: Budget) raises LibError -> Expr
A named constant instance, checked against the owning Session.
Arguments.
d: The owning session.name: The constant slot to read.budget: Shared allowance for names.
Returns. The slot's constant.
Raises.
LibError:FORMATfor a missing or duplicate slot;WRONG_KERNELfor another session's bundle or slot;KERNELfor a stale handle;LIMIT.
TypePattern¶
struct TypePattern(Copyable)
| Field | Type | Description |
|---|---|---|
build |
TypePatternBuilder |
The budgeted session-building callback. |
optional |
Bool |
Whether omitting this constant slot is valid. |
Describe a constant's expected type and whether the slot is optional, as TypePattern.
Defined in src/judgment_shell/_dag_bundle_records.mojo.
TypePattern.__init__¶
def __init__(out self, build: TypePatternBuilder, optional: Bool = False)
Create a type pattern callback.
Arguments.
build: A callback returning the exact type expected.optional: Whether the schema permits this slot to be absent.
StatementPattern¶
struct StatementPattern(Copyable)
| Field | Type | Description |
|---|---|---|
build |
Optional[StatementPatternBuilder] |
The proposition builder; absent only for an ACU declaration slot. |
requires_domain |
Bool |
Whether the law is required only when a domain slot is present. |
acu_operator |
String |
The constant slot whose ACU declaration fills this law slot. |
acu_unit |
String |
The constant slot supplying that ACU declaration's required unit. |
Describe an exact law proposition or an ACU declaration for a constant, as StatementPattern.
Defined in src/judgment_shell/_dag_bundle_records.mojo.
StatementPattern.__init__¶
def __init__(out self, build: Optional[StatementPatternBuilder], requires_domain: Bool = False, var acu_operator: String = "", var acu_unit: String = "")
Create a statement callback or an ACU record pattern.
Arguments.
build: A full-statement builder, or None for an ACU record.requires_domain: Whether this law is omitted without a domain.acu_operator: The operator slot for an ACU record pattern.acu_unit: The unit slot for an ACU record pattern.
BundleSchema¶
struct BundleSchema(Copyable)
| Field | Type | Description |
|---|---|---|
name |
String |
The stable schema name. |
constants |
List[Tuple[String, TypePattern]] |
Named required or optional constant type patterns. |
laws |
List[Tuple[String, StatementPattern]] |
Named statement or ACU declaration patterns. |
Specify constant types and exact law statements independently of a session, as BundleSchema.
Defined in src/judgment_shell/_dag_bundle_records.mojo.
BundleSchema.__init__¶
def __init__(out self, var name: String, var constants: List[Tuple[String, TypePattern]], var laws: List[Tuple[String, StatementPattern]])
Create a schema from budgeted session-building patterns.
Arguments.
name: The schema name, consumed by construction.constants: Constant slots and expected types, consumed.laws: Law slots and expected statements, consumed.
schemas¶
def schemas() -> List[BundleSchema]
Return the standard algebraic law-bundle schemas.
Returns. Built-in BundleSchema definitions.
Defined in src/judgment_shell/_dag_bundles.mojo.
validate¶
def validate(session: Session, bundle: LawBundle, schema: BundleSchema, mut budget: Budget) raises LibError
Validate that bundle satisfies schema in session.
Arguments.
session: Owning session.bundle: Candidate law bundle.schema: Expected schema.budget: Work allowance.
Raises.
LibError:FORMATfor duplicate, missing, or unexpected slots;SHAPEfor a slot that is not a constant instance, a law that is not an axiom or theorem (or an ACU declaration in an ACU slot), a wrong type, a wrong ACU declaration, or a misstated law;WRONG_KERNELfor another session's bundle or handle;KERNELfor a stale handle or a refused instance;UNSUPPORTEDfor type arguments on a law with no authored statement;LIMIT. Slot diagnostics identify the failing constant or law. Generic schemas check liveness and supplied type arguments without asserting particular law statements.
Defined in src/judgment_shell/_dag_bundles.mojo.
bundle_from_instance¶
def bundle_from_instance(session: Session, schema: BundleSchema, carrier: TypeExpr, classes: List[Tuple[String, Class]], mut budget: Budget) raises LibError -> LawBundle
Assemble and validate a LawBundle from class instances for carrier.
Arguments.
session: Owning session.schema: Target schema.carrier: Carrier type expression.classes: Named classes providing instances.budget: Work allowance.
Returns. Validated LawBundle.
Raises.
LibError:FORMATfor missing mappings;SHAPEfor a carrier outside a class, wrong types, or misstated laws;WRONG_KERNEL,KERNEL, orLIMITasvalidate. A refusal leaves the session as it was (the membership evidence made on the way is dropped).
Defined in src/judgment_shell/_dag_bundles.mojo.
TypePatternBuilder¶
comptime TypePatternBuilder = def(Session, LawBundle, mut Budget) raises LibError thin -> TypeExpr
Build a constant slot's expected type from the bundle's concrete instances.
Defined in src/judgment_shell/_dag_bundle_records.mojo.
StatementPatternBuilder¶
comptime StatementPatternBuilder = def(Session, LawBundle, mut Budget) raises LibError thin -> Expr
Build a law slot's full expected closed proposition in the session.
Defined in src/judgment_shell/_dag_bundle_records.mojo.
Equality conversions¶
Conversion components return checked equality proofs and explicit guards.
A result's proof is validated against the actual input and frame before it
is used: the input's free locals must lie on the frame's chain, and the
statement must be the advertised guarded equality. UnderBinder closes a
body guard universally. Repeat stops at a validated fixed point or raises
LIMIT; it never returns a partial result on exhaustion. RewriteWith
copies one record of a TheoremStore into a store of its own.
"""Apply checked equality rewrites and inspect read-only engine query views over a session."""
from std.testing import assert_equal, assert_true
from judgment_shell import (
EngineEvent, EngineRegistry, ExpanderRegistry, FactTable, GoalRequest,
LawBundle, Session, TheoremStore, arrow, lambda_, query_view, rewrite,
)
from termbank import Budget
def main() raises:
var s = Session()
var prop = s.prop_type()
var a = s.prop("a")
var b = s.prop("b")
var f = s.symbol("f", arrow(prop, prop))
var eq_ab = s.axiom("ab", a == b)
var root = s.base()
var eq_step = s.use(root, eq_ab)
var rewritten = rewrite(s, eq_step, s.eq_refl(root, f(a)), [[2, 0]])
assert_true(rewritten.statement().same_as(f(a) == f(b)))
var x = s.bound_var("x", prop)
var lam = lambda_(x, x)
var expected = lam == lam
var store = TheoremStore(s)
var facts = FactTable(s)
var bundles = List[LawBundle]()
var expanders = ExpanderRegistry()
var engines = EngineRegistry()
var query = query_view(s, store, facts, bundles, expanders, engines)
var event = EngineEvent.new_goal(GoalRequest(root, expected, 100000))
assert_equal(event.kind(), EngineEvent.NEW_GOAL)
assert_equal(query.fact_count(), 0)
print("conversions and checked engine candidates: ok")
Run from the repository root pixi run mojo run -I src docs/examples/library/engines.mojo
Output
conversions and checked engine candidates: ok
Converted¶
@fieldwise_init
struct Converted(Movable)
| Field | Type | Description |
|---|---|---|
output |
Expr |
The proposed output term. |
guard |
Guard |
The equality's condition, or TOP for an unconditional conversion. |
proof |
Step |
A step concluding guard implies input equals output, or the bare equality for TOP. |
An equality conversion's output, guard and step.
Combinators validate every component against the actual input and frame before using its step.
Defined in src/judgment_shell/_dag_conversion_core.mojo.
Conversion¶
trait Conversion(Movable, Deinitable)
Rewrite a session term with evidence under an explicit guard, as Conversion.
Defined in src/judgment_shell/_dag_conversion_core.mojo.
Conversion.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Attempt one conversion in the supplied frame.
Arguments.
d: The session owning all syntax and evidence.frame: The frame where the input and result must be usable.t: The input term.budget: Shared allowance for search, traversal, and construction.
Returns. A checked guarded equality result, or None when inapplicable.
Raises.
LibError: Typed ownership, scope, shape, and budget refusals.
Then¶
@fieldwise_init
struct Then[A: Conversion, B: Conversion](Conversion)
| Field | Type | Description |
|---|---|---|
first |
Self.A |
The conversion applied to the input. |
second |
Self.B |
The conversion applied to the first result. |
Compose two conversions, requiring both to apply and conjoining guards, as Then.
Parameters.
A: The first conversion's type.B: The second conversion's type.
Defined in src/judgment_shell/_dag_conversions.mojo.
Then.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Apply both components and compose their validated equality proofs.
Arguments.
d: The owning session.frame: The result frame.t: The input term.budget: Shared component and proof allowance.
Returns. A guarded composed equality, or None if either component declines.
Raises.
LibError: Invalid component results or propagated component refusals.
OrElse¶
@fieldwise_init
struct OrElse[A: Conversion, B: Conversion](Conversion)
| Field | Type | Description |
|---|---|---|
first |
Self.A |
The preferred conversion. |
second |
Self.B |
The fallback used only for inapplicability, never for an error. |
Try the second conversion only when the first returns None, as OrElse.
Parameters.
A: The preferred conversion's type.B: The fallback conversion's type.
Defined in src/judgment_shell/_dag_conversions.mojo.
OrElse.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Return the first applicable, validated conversion result.
Arguments.
d: The owning session.frame: The result frame.t: The input term.budget: Shared component and validation allowance.
Returns. A component result, or None if both decline.
Raises.
LibError: Invalid component results or propagated component refusals.
Try¶
@fieldwise_init
struct Try[A: Conversion](Conversion)
| Field | Type | Description |
|---|---|---|
inner |
Self.A |
The conversion to attempt. |
Use reflexivity when the component conversion is inapplicable, as Try.
Parameters.
A: The component conversion's type.
Defined in src/judgment_shell/_dag_conversions.mojo.
Try.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Return a validated component result or unconditional identity.
Arguments.
d: The owning session.frame: The result frame.t: The input term.budget: Shared component and proof allowance.
Returns. A present conversion result, including when the component declines.
Raises.
LibError: Invalid component results or propagated component refusals.
Repeat¶
@fieldwise_init
struct Repeat[A: Conversion](Conversion)
| Field | Type | Description |
|---|---|---|
inner |
Self.A |
The conversion attempted at each step. |
max_steps |
Int |
The maximum number of component calls before LIMIT. |
Repeat until inapplicable or unchanged, within a caller-set step limit, as Repeat.
Parameters.
A: The repeated conversion's type.
Defined in src/judgment_shell/_dag_conversions.mojo.
Repeat.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Compose successful steps and stop at a verified fixed point.
Arguments.
d: The owning session.frame: The result frame.t: The input term.budget: One shared allowance for all attempts and proofs.
Returns. A present conversion result on normal termination; identity if the first attempt declines or leaves its input unchanged.
Raises.
LibError:FORMATfor a negative step limit;LIMITif no fixed point is reached within either limit; invalid component results or propagated component refusals. Exhaustion returns no partial conversion.
UnderHead¶
@fieldwise_init
struct UnderHead[A: Conversion](Conversion)
| Field | Type | Description |
|---|---|---|
inner |
Self.A |
The conversion attempted on arguments in the view's spine order. |
Apply a conversion to each argument of an application spine, as UnderHead.
Parameters.
A: The argument conversion's type.
Defined in src/judgment_shell/_dag_conversions.mojo.
UnderHead.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Lift argument equalities through the unchanged application head.
Arguments.
d: The owning session.frame: The result frame.t: The input term.budget: Shared traversal, component, and proof allowance.
Returns. A guarded congruence result, or None for a non-application or when every argument conversion declines. Outputs are session-rebuilt.
Raises.
LibError: Invalid component results or propagated typed refusals.
UnderBinder¶
@fieldwise_init
struct UnderBinder[A: Conversion](Conversion)
| Field | Type | Description |
|---|---|---|
inner |
Self.A |
The conversion attempted with a fresh, scoped body variable. |
Rewrite a lambda body and universally close its guard over the binder, as UnderBinder.
Parameters.
A: The body conversion's type.
Defined in src/judgment_shell/_dag_conversions.mojo.
UnderBinder.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Lift a body equality while preventing free guard variables from escaping.
Arguments.
d: The owning session.frame: The result frame, outside the lambda.t: A lambda term.budget: Shared opening, conversion, instantiation, and proof allowance.
Returns. A lambda equality with a universally closed guard, or None for a non-lambda or an inapplicable body conversion. TOP stays TOP.
Raises.
LibError: Invalid component results,LIMIT, or session refusals.
RewriteWith¶
struct RewriteWith(Conversion)
Match a snapshot of one stored equation and retain its instantiated guard, as RewriteWith.
Construction makes an independent one-record store, so several conversions from the same source store compose without mutable aliasing.
Defined in src/judgment_shell/_dag_conversions.mojo.
RewriteWith.__init__¶
def __init__(out self, d: Session, store: TheoremStore, id: TheoremId, mut budget: Budget) raises LibError
Snapshot a selected forward equation and its source's exported claim guards.
Arguments.
d: The owning session.store: The source theorem store, read without changing it.id: The source store's theorem to match from left to right.budget: Shared allowance for the independent snapshot.
Raises.
LibError: Invalid ids, ownership, budget, or session refusals.
RewriteWith.convert¶
def convert(mut self, d: Session, frame: Frame, t: Expr, mut budget: Budget) raises LibError -> Optional[Converted]
Instantiate the first verified root match and read its actual equation.
Arguments.
d: The owning session.frame: The target frame.t: The input term.budget: Shared lookup, matching, instantiation, and validation work.
Returns. The instantiated right side and guard; None for a non-equation, no match, or a match that leaves a term parameter undetermined.
Raises.
LibError: Store or matching refusals, or invalid reconstructed equalities (SHAPE).
Engine protocol¶
query_view creates a QueryView over the session's theory as it stands,
together with the caller's theorem store, fact table, law bundles, and
registries. A query can also select an explicit captured theory. Engines pass
view.theory(d, budget) to inspection and use the returned typed handles for
declaration lookup. Fact reads execute and check
their citations; bundle reads copy validated handles for an engine to check
against its required schema. run_one validates the event, descriptor,
goals, claims, and every candidate's recipe, which runs atomically through
run and must prove its advertised proposition at its advertised frame. A
goal's allowance caps the shared budget, while unused outer allowance
remains available.
engine_recipe adapts a protocol engine to a RecipeEngine callback: it
returns a one-step recipe whose root is the matching evidence candidate's
checked step. Scheduling, policy selection, and publication remain the
caller's work. TransformResult is a protocol carrier; its factories check
ownership and its accessors check variants. The coordinator validates the
supplied proof's meaning before publishing an outcome. In particular, a
piecewise result requires checked coverage and a checked relation to the
piecewise expression; branch-local equalities alone are insufficient
(architecture-note §25.2).
Capability¶
@fieldwise_init
struct Capability(Equatable, ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
code |
UInt8 |
The stable tag; use named constants when constructing descriptors. |
Name an engine capability, as Capability.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
Capability.PROVE¶
comptime PROVE = Capability(1)
Produce evidence for a proposition.
Capability.REWRITE¶
comptime REWRITE = Capability(2)
Propose guarded equality rewrites.
Capability.NORMALIZE¶
comptime NORMALIZE = Capability(3)
Propose a normal form with equality evidence.
Capability.PROPAGATE¶
comptime PROPAGATE = Capability(4)
Derive consequences of newly available facts.
Capability.DECIDE¶
comptime DECIDE = Capability(5)
Attempt a decision with explicit evidence or external claims.
EngineDescriptor¶
@fieldwise_init
struct EngineDescriptor(Copyable)
| Field | Type | Description |
|---|---|---|
name |
String |
The engine's stable dispatch name. |
version |
String |
The implementation version used in provenance and caches. |
capabilities |
List[Capability] |
The supported operations, with no duplicate entries. |
Identify an engine implementation and its declared capabilities, as EngineDescriptor.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
GoalRequest¶
@fieldwise_init
struct GoalRequest(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The frame in which evidence is requested. |
proposition |
Expr |
The proposed goal; the harness checks its scope and Prop type. |
budget |
UInt64 |
Maximum shared work to spend on this goal event. |
Request evidence for a scoped proposition with a finite work allowance, as GoalRequest.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
EvidenceCandidate¶
@fieldwise_init
struct EvidenceCandidate(Copyable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The advertised result frame. |
proposition |
Expr |
The advertised conclusion, verified by recipe execution. |
recipe |
Recipe |
The untrusted proof-building recipe. |
Propose a recipe whose advertised frame and proposition need checking, as EvidenceCandidate.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
ConversionCandidate¶
@fieldwise_init
struct ConversionCandidate(Movable)
| Field | Type | Description |
|---|---|---|
frame |
Frame |
The frame where both terms and the guard must be usable. |
input |
Expr |
The original term. |
output |
Expr |
The proposed result. |
guard |
Guard |
The condition under which the equality must hold. |
recipe |
Recipe |
A recipe for guard implying input equals output, or bare TOP equality. |
Propose a guarded equality recipe for an explicit input and output, as ConversionCandidate.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
EngineEvent¶
struct EngineEvent(Movable)
Carry one tagged input event for a single engine invocation, as EngineEvent.
Events hold session handles. Factories build messages; the harness validates their actual scope, liveness, and ownership.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
EngineEvent.NEW_GOAL¶
comptime NEW_GOAL: UInt8 = 1
A new scoped proof goal.
EngineEvent.NEW_FACT¶
comptime NEW_FACT: UInt8 = 2
A newly checked session step.
EngineEvent.TRANSFORM¶
comptime TRANSFORM: UInt8 = 3
A request to transform a term in a frame.
EngineEvent.RESUME¶
comptime RESUME: UInt8 = 4
Resume private engine state without a new input.
EngineEvent.__init__¶
def __init__(out self, kind: UInt8, goal: Optional[GoalRequest], fact: Optional[Step], frame: Optional[Frame], term: Optional[Expr])
Build a raw event representation for explicit harness validation.
Arguments.
kind: One of the named event tags.goal: Present only for NEW_GOAL.fact: Present only for NEW_FACT.frame: Present only for TRANSFORM.term: Present only for TRANSFORM.
EngineEvent.new_goal¶
@staticmethod
def new_goal(goal: GoalRequest) -> Self
Create a goal event.
Arguments.
goal: The scoped request and allowance.
Returns. The corresponding event message.
EngineEvent.new_fact¶
@staticmethod
def new_fact(fact: Step) -> Self
Create a checked-fact event.
Arguments.
fact: The newly available session step.
Returns. The corresponding event message.
EngineEvent.transform¶
@staticmethod
def transform(frame: Frame, term: Expr) -> Self
Create a term transformation event.
Arguments.
frame: The target frame.term: The term to transform.
Returns. The corresponding event message.
EngineEvent.resume¶
@staticmethod
def resume() -> Self
Create a resume event.
Returns. An event with no session payload.
EngineEvent.kind¶
def kind(self) -> UInt8
Read the event tag.
Returns. A tag to compare with the named constants.
EngineEvent.as_goal¶
def as_goal(self) raises LibError -> GoalRequest
Read a NEW_GOAL payload.
Returns. The goal request.
Raises.
LibError:SHAPEfor another tag or a missing payload.
EngineEvent.as_fact¶
def as_fact(self) raises LibError -> Step
Read a NEW_FACT payload.
Returns. The checked step handle.
Raises.
LibError:SHAPEfor another tag or a missing payload.
EngineEvent.as_transform¶
def as_transform(self) raises LibError -> Tuple[Frame, Expr]
Read a TRANSFORM payload.
Returns. The target frame and input term.
Raises.
LibError:SHAPEfor another tag or a missing payload.
EngineDelta¶
struct EngineDelta(Movable)
| Field | Type | Description |
|---|---|---|
goals |
List[GoalRequest] |
New scoped obligations, for the caller that schedules engines. |
evidence |
List[EvidenceCandidate] |
Proposed proposition proofs, checked by the harness. |
conversions |
List[ConversionCandidate] |
Proposed guarded equalities, checked by the harness. |
claims |
List[ExternalClaim] |
External claim metadata, requiring explicit tracked assumption later. |
Collect one engine step's untrusted proposals for harness validation, as EngineDelta.
The caller retains scheduling, evidence policy, and publication decisions. No candidate or external claim becomes an assumption through this record.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
EngineDelta.__init__¶
def __init__(out self, session: Session)
Create an empty delta owned by one session.
Arguments.
session: The owner of all subsequently added handles.
TransformResult¶
struct TransformResult(Movable)
Represent a proposed transform outcome for a coordinator to publish, as TransformResult.
These tagged records preserve session handles and guard syntax. The caller must validate the proof's meaning and apply its request's evidence policy; constructing a record does not certify its advertised outcome.
Defined in src/judgment_shell/_dag_protocol_records.mojo.
TransformResult.STRICT¶
comptime STRICT: UInt8 = 1
An unconditional proposed output with its equality proof.
TransformResult.CONDITIONAL¶
comptime CONDITIONAL: UInt8 = 2
A proposed output whose equality has an explicit guard.
TransformResult.PIECEWISE¶
comptime PIECEWISE: UInt8 = 3
A collection of guarded outputs with a supplied combined step.
TransformResult.NO_RESULT¶
comptime NO_RESULT: UInt8 = 4
No result, with a diagnostic reason.
TransformResult.INCONSISTENT¶
comptime INCONSISTENT: UInt8 = 5
A supplied contradiction step for policy validation.
TransformResult.__init__¶
def __init__(out self)
Create an empty NO_RESULT record.
TransformResult.strict¶
@staticmethod
def strict(output: Expr, judgment: Step) raises LibError -> Self
Wrap an unconditional proposed result, checking handle ownership.
Arguments.
output: The proposed output.judgment: The supplied equality proof.
Returns. A STRICT record holding both handles.
Raises.
LibError:WRONG_KERNELfor mixed owners.
TransformResult.conditional¶
@staticmethod
def conditional(output: Expr, var guard: Guard, judgment: Step) raises LibError -> Self
Wrap a conditional proposed result, checking handle ownership.
Arguments.
output: The proposed output.guard: The condition, consumed by construction.judgment: The supplied guarded equality proof.
Returns. A CONDITIONAL record.
Raises.
LibError:WRONG_KERNELfor mixed owners.
TransformResult.piecewise¶
@staticmethod
def piecewise(var branches: List[Tuple[Guard, Expr]], judgment: Step, mut budget: Budget) raises LibError -> Self
Wrap proposed branches and their combined step.
Arguments.
branches: Guard/output pairs, consumed by construction.judgment: The supplied combined proof, interpreted by the caller.budget: Shared allowance for checking every branch owner.
Returns. A PIECEWISE record.
Raises.
LibError:WRONG_KERNELfor mixed owners, orLIMIT.
TransformResult.no_result¶
@staticmethod
def no_result(var reason: String) -> Self
Describe an attempt that produced no result.
Arguments.
reason: The diagnostic message, consumed by construction.
Returns. A NO_RESULT record with no session handle.
TransformResult.inconsistent¶
@staticmethod
def inconsistent(judgment: Step) -> Self
Wrap a proposed contradiction for the caller's policy checks.
Arguments.
judgment: The supplied proof of False.
Returns. An INCONSISTENT record holding the proof's handle.
TransformResult.kind¶
def kind(self) -> UInt8
Read the outcome tag.
Returns. A tag to compare with the named constants.
TransformResult.output¶
def output(self) raises LibError -> Expr
Read the single proposed output.
Returns. The output of STRICT or CONDITIONAL.
Raises.
LibError:SHAPEfor another variant.
TransformResult.judgment¶
def judgment(self) raises LibError -> Step
Read the supplied session step.
Returns. The proof handle of any variant except NO_RESULT.
Raises.
LibError:SHAPEfor NO_RESULT.
TransformResult.guard¶
def guard(self, mut budget: Budget) raises LibError -> Guard
Copy the condition of a CONDITIONAL result under a shared budget.
Arguments.
budget: Shared allowance for copying the flat guard arena.
Returns. An independent guard holding the same session handles.
Raises.
LibError:SHAPEfor another variant, orLIMIT.
TransformResult.branches¶
def branches(self) raises LibError -> ref[self._branches] List[Tuple[Guard, Expr]]
Borrow the branches of a PIECEWISE result.
Returns. The owned guard/output list, without copying.
Raises.
LibError:SHAPEfor another variant.
TransformResult.reason¶
def reason(self) raises LibError -> ref[self._reason] String
Borrow the diagnostic of a NO_RESULT outcome.
Returns. The owned diagnostic string.
Raises.
LibError:SHAPEfor another variant.
QueryView¶
struct QueryView[ store_origin: Origin[mut=False], facts_origin: Origin[mut=False], bundles_origin: Origin[mut=False], expanders_origin: Origin[mut=False], engines_origin: Origin[mut=False], ]
Borrow a caller-selected workspace without exposing mutation, as QueryView.
The caller supplies only facts and bundles eligible for its request's evidence policy. This view has no scheduler or publication authority. Fact reads execute their recipes and validate their advertised statements. Borrowed structures must outlive this view; handles are checked when read.
Parameters.
store_origin: The immutable origin of the theorem store.facts_origin: The immutable origin of the provisional fact table.bundles_origin: The immutable origin of the bundle list.expanders_origin: The immutable origin of the expander registry.engines_origin: The immutable origin of the recipe engine registry.
Defined in src/judgment_shell/_dag_query.mojo.
QueryView.__init__¶
def __init__(out self, d: Session, ref[Self.store_origin] store: TheoremStore, ref[Self.facts_origin] facts: FactTable, ref[Self.bundles_origin] bundles: List[LawBundle], ref[Self.expanders_origin] expanders: ExpanderRegistry, ref[Self.engines_origin] engines: EngineRegistry)
Borrow the workspace and execution registries without copying them.
Arguments.
d: The workspace owner.store: The visible theorem store.facts: The caller-selected fact recipes and advertised statements.bundles: Caller-selected law bundle records.expanders: The authorized recipe expansion callbacks.engines: The authorized L2 SEARCH callbacks.
QueryView.__init__¶
def __init__(out self, d: Session, theory: DagTheory, ref[Self.store_origin] store: TheoremStore, ref[Self.facts_origin] facts: FactTable, ref[Self.bundles_origin] bundles: List[LawBundle], ref[Self.expanders_origin] expanders: ExpanderRegistry, ref[Self.engines_origin] engines: EngineRegistry)
Borrow the workspace and execution registries without copying them.
Arguments.
d: The workspace owner.theory: The fixed checked theory, validated when read.store: The visible theorem store.facts: The caller-selected fact recipes and advertised statements.bundles: Caller-selected law bundle records.expanders: The authorized recipe expansion callbacks.engines: The authorized L2 SEARCH callbacks.
QueryView.theory¶
def theory(self, d: Session, mut budget: Budget) raises LibError -> DagTheory
Read the checked construction-time theory.
Arguments.
d: The owning session.budget: Shared validation allowance.
Returns. The fixed checked theory handle.
Raises.
LibError: Ownership, stale capture or budget refusal.
QueryView.store¶
def store(self) -> ref[Self.store_origin] TheoremStore
Borrow the theorem store immutably.
Returns. A read-only store for lookup and records.
QueryView.fact_count¶
def fact_count(self) -> Int
Count the caller-selected provisional facts.
Returns. The number of valid table-local slots; use fact to check one.
QueryView.fact¶
def fact(self, d: Session, id: FactId, mut budget: Budget) raises LibError -> Step
Read a fact only after checking its recipe and advertised conclusion.
Arguments.
d: The owning session.id: A table-local fact identifier.budget: Shared allowance for citation and recipe execution.
Returns. The session step, validated at its advertised frame's entry.
Raises.
LibError: Invalid ids (FORMAT), false fact claims (SHAPE), recipe errors, ownership, liveness and budget refusals, preserving kernel kinds.
QueryView.bundle_count¶
def bundle_count(self) -> Int
Count the caller-selected bundle records.
Returns. The number of list-indexed bundles.
QueryView.bundle¶
def bundle(self, d: Session, at: Int, mut budget: Budget) raises LibError -> LawBundle
Copy one live bundle record for validation against an engine's schema.
Arguments.
d: The owning session.at: The zero-based bundle index.budget: Shared allowance for names, type arguments, and copying.
Returns. An independent record. The engine still calls dag_validate with the schema it requires before relying on the bundle's law patterns.
Raises.
LibError:FORMATfor an invalid slot,WRONG_KERNELfor a foreign bundle or handle,KERNELfor a stale handle, orLIMIT.
query_view¶
def query_view[ store_origin: Origin[mut=False], facts_origin: Origin[mut=False], bundles_origin: Origin[mut=False], expanders_origin: Origin[mut=False], engines_origin: Origin[mut=False], ](session: Session, ref[store_origin] store: TheoremStore, ref[facts_origin] facts: FactTable, ref[bundles_origin] bundles: List[LawBundle], ref[expanders_origin] expanders: ExpanderRegistry, ref[engines_origin] engines: EngineRegistry) -> QueryView[ store_origin, facts_origin, bundles_origin, expanders_origin, engines_origin ]
Build a read-only QueryView over a session's theorem store, facts, bundles, and registries.
Parameters.
store_origin: Origin ofstore.facts_origin: Origin offacts.bundles_origin: Origin ofbundles.expanders_origin: Origin ofexpanders.engines_origin: Origin ofengines.
Arguments.
session: Owning session.store: Theorem store.facts: Fact table.bundles: Law bundles.expanders: Expander registry.engines: Engine registry.
Returns. Read-only QueryView.
Defined in src/judgment_shell/_dag_public.mojo.
Engine¶
trait Engine(Movable, Deinitable)
Describe an engine and propose one bounded step without publication, as Engine.
Defined in src/judgment_shell/_dag_protocol.mojo.
Engine.descriptor¶
def descriptor(self) -> EngineDescriptor
Read the implementation's stable identity and capabilities.
Returns. Fixed engine metadata, independent of workspace-sized input.
Engine.step¶
def step(mut self, d: Session, view: QueryView, event: EngineEvent, mut budget: Budget) raises LibError -> EngineDelta
Handle one event using a read-only, caller-selected workspace.
Arguments.
d: The session for constructing syntax and genuine evidence.view: Read access to eligible store records, facts, and bundles.event: The event to process, borrowed for this call.budget: Shared work allowance, including any returned recipes.
Returns. Untrusted requests, candidates, and claims for harness validation.
Raises.
LibError: Typed refusals and exhaustion; no publication occurs.
run_one¶
def run_one[E: Engine](session: Session, mut engine: E, view: QueryView, event: EngineEvent, mut budget: Budget) raises LibError -> EngineDelta
Execute one bounded step of engine on event and validate its proposed delta.
This harness checks messages and proofs; it does not schedule goals, assume external claims, classify evidence policy, or publish facts.
Parameters.
E: Engine type implementingEngine.
Arguments.
session: Owning session.engine: Engine instance.view: Read-only query view.event: Input event.budget: Work allowance.
Returns. Validated EngineDelta.
Raises.
LibError: Malformed messages, mismatched candidate proofs, ownership, scope, budget, or kernel refusals. No partial delta is returned. Engine-private state and session rows the engine built are not rolled back; each candidate recipe's run is atomic.
Defined in src/judgment_shell/_dag_protocol.mojo.
engine_recipe¶
def engine_recipe[E: Engine](session: Session, mut engine: E, view: QueryView, goal: GoalRequest, mut budget: Budget) raises LibError -> Recipe
Ask engine for a checked recipe solving goal.
Call this helper from a RecipeEngine thin callback registered with
EngineRegistry.register. The callback creates or owns the engine and
query view; registry callbacks do not secretly retain borrowed state.
Parameters.
E: Engine type implementingEngine.
Arguments.
session: Owning session.engine: Engine instance.view: Read-only query view.goal: Goal request.budget: Work allowance.
Returns. Validated Recipe.
Raises.
LibError:NO_MATCHwhen the delta has no evidence for the goal's proposition at its frame's entry frame; other refusals fromrun_one, including recipe failures.
Defined in src/judgment_shell/_dag_protocol.mojo.
Shared constructive folds and equality traversal¶
conjunction folds an ordered list of proofs into a right-associated
conjunction, using True for an empty list. conjunct projects one member
of a right-associated conjunction. disjunction_elim consumes a nonempty
disjunction with one implication per disjunct. exists_elim_closed
eliminates an existential with a closed universal implication.
contradiction_convertible derives False from ¬P and a proposition
convertible to P.
conjunction¶
def conjunction(session: Session, frame: Frame, steps: List[Step]) raises LibError -> Step
Build a right-associated conjunction step from steps.
Arguments.
session: Owning session.frame: Proof frame.steps: Checked steps to conjoin.
Returns. Conjunction step (or True if empty).
Raises.
LibError: What the steps raise (frames on different chains).
Defined in src/judgment_shell/_dag_derived.mojo.
conjunct¶
def conjunct(session: Session, step: Step, index: Int, count: Int) raises LibError -> Step
Project the index-th conjunct from a count-way right-associated conjunction.
Arguments.
session: Owning session.step: Conjunction step.index: Zero-based conjunct index.count: Total conjunct count.
Returns. Projected conjunct step.
Raises.
LibError:SHAPEfor an index out of bounds or a step that is not the conjunction; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
disjunction_elim¶
def disjunction_elim(session: Session, disjunction: Step, propositions: List[Expr], branches: List[Step]) raises LibError -> Step
Eliminate an n-way right-associated disjunction given implication branches.
Arguments.
session: Owning session.disjunction: Proof ofP_0 ∨ ... ∨ P_{n-1}.propositions: Disjunct propositions.branches: Proofs ofP_i → C.
Returns. Checked step concluding C.
Raises.
LibError:SHAPEfor no alternatives or another number of branches; what the steps raise (a disjunction of other alternatives, branches with different conclusions).
Defined in src/judgment_shell/_dag_derived.mojo.
exists_elim_closed¶
def exists_elim_closed(session: Session, existence: Step, predicate: Expr, alpha: TypeExpr, branch: Step, conclusion: Expr) raises LibError -> Step
Eliminate an existential using a closed universal implication branch.
Only checked conversion, universal elimination and implication elimination establish the result. Fresh bound variables build the Church encoding of the existential; a transaction makes the whole derivation atomic. Its fixed number of operations and their session allowance bound the work (G3, G9).
Arguments.
session: Owning session.existence: Proof of∃x. predicate x.predicate: Existential predicate.alpha: Witness type.branch: Proof of∀x. predicate x → conclusion.conclusion: Target proposition.
Returns. Checked step concluding conclusion.
Raises.
LibError:WRONG_KERNELfor foreign handles;KERNELfor stale handles, mismatched premises or escaping variables;SHAPEfor malformed inputs;LIMIT. Any failure discards the derivation's rows.
Defined in src/judgment_shell/_dag_derived.mojo.
contradiction_convertible¶
def contradiction_convertible(session: Session, negative: Step, positive: Step) raises LibError -> Step
Derive False from ¬P and P' where P and P' are convertible.
Arguments.
session: Owning session.negative: Proof of¬P.positive: Proof ofP'.
Returns. Checked step concluding False.
Raises.
LibError:KERNELfor a negative step not convertible toφ → False; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
Equality retains both endpoints because canonical literal equality may
erase its equation syntax to True. Construct it with equality; every
composition operation also validates the advertised endpoints and evidence,
including reflexive shortcuts, which retain all proof dependencies.
read_equality requires equation-shaped syntax; callers must retain
endpoints separately if normalization can erase them.
Equality¶
struct Equality(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
left |
Expr |
The original term. |
right |
Expr |
The resulting term. |
proof |
Step |
Evidence: a step concluding left = right, or its canonical form (True, or False for an absurd one). |
An equality's endpoints and evidence.
Defined in src/judgment_shell/_dag_equalities.mojo.
Equality.__init__¶
def __init__(out self, left: Expr, right: Expr, proof: Step)
Endpoints and evidence, unvalidated: dag_equality validates.
Arguments.
left: The original term.right: The resulting term.proof: The evidence.
equality¶
def equality(session: Session, left: Expr, right: Expr, proof: Step) raises LibError -> Equality
Construct a checked Equality verifying proof concludes left = right.
Arguments.
session: Owning session.left: Left-hand expression.right: Right-hand expression.proof: Checked equality step.
Returns. Checked Equality.
Raises.
LibError: On mismatch or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
read_equality¶
def read_equality(proof: Step) raises LibError -> Equality
Read an equality step Γ ⊢ l = r into an Equality record.
Arguments.
proof: Checked equality step.
Returns. Checked Equality.
Raises.
LibError:SHAPEfor a statement not authored as an equation;KERNELfor a stale step.
Defined in src/judgment_shell/_dag_equalities.mojo.
reflexivity¶
def reflexivity(session: Session, frame: Frame, term: Expr) raises LibError -> Equality
Prove term = term at frame as an Equality.
Arguments.
session: Owning session.frame: Proof frame.term: Expression.
Returns. Reflexive Equality.
Raises.
LibError:KERNELfor a stale handle or a refused row.
Defined in src/judgment_shell/_dag_equalities.mojo.
symmetric¶
def symmetric(session: Session, equation: Equality) raises LibError -> Equality
Reverse an Equality.
Arguments.
session: Owning session.equation: Checked equality.
Returns. Reversed Equality.
Raises.
LibError:KERNELfor invalid evidence or a refused row.
Defined in src/judgment_shell/_dag_equalities.mojo.
transitive¶
def transitive(session: Session, first: Equality, second: Equality) raises LibError -> Equality
Chain two Equality values.
Arguments.
session: Owning session.first: Equalitya = b.second: Equalityb = c.
Returns. Chained Equality a = c.
Raises.
LibError:SHAPEfor different middle terms;KERNELfor invalid evidence or a refused row.
Defined in src/judgment_shell/_dag_equalities.mojo.
substitute¶
def substitute(session: Session, motive: Expr, equation: Equality, fact: Step) raises LibError -> Step
Substitute along equation in fact using motive.
Arguments.
session: Owning session.motive: Lambda predicateλx. P x.equation: Checked equalitya = b.fact: Proof ofP a.
Returns. Checked step concluding P b.
Raises.
LibError:KERNELfor mismatched premises or a refused row.
Defined in src/judgment_shell/_dag_equalities.mojo.
apply_equalities¶
def apply_equalities(session: Session, frame: Frame, function: Equality, arguments: List[Equality], mut budget: Budget) raises LibError -> Equality
Combine function and argument equalities by congruence.
Arguments.
session: Owning session.frame: Proof frame.function: Function equality.arguments: Argument equalities.budget: Work allowance.
Returns. Combined application Equality.
Raises.
LibError:LIMITon exhaustion;KERNELfor invalid evidence or a refused row.
Defined in src/judgment_shell/_dag_equalities.mojo.
abstract_equality¶
def abstract_equality(session: Session, binder: Frame, equation: Equality) raises LibError -> Equality
Abstract a fix frame binder over both sides of equation.
Arguments.
session: Owning session.binder: Fix frame.equation: Body equality.
Returns. Abstracted Equality.
Raises.
LibError:KERNELfor invalid evidence, an escaping variable or a refused row (absurd evidence included).
Defined in src/judgment_shell/_dag_equalities.mojo.
walk_equalities traverses a term iteratively with checked binder opening,
assembling a checked equality from an EqualityWalker policy, which supplies
entry replacements and application and binder handling. Every hook result
is validated before it is used. functions=False leaves function heads
unchanged. Traversal and reconstruction share the caller's budget.
EqualityWalker¶
trait EqualityWalker
Policy controlling recursive equality rewriting over a Session.
Defined in src/judgment_shell/_dag_traversal.mojo.
EqualityWalker.enter¶
def enter(mut self, d: Session, frame: Frame, term: Expr, mut budget: Budget) raises LibError -> Optional[Equality]
Inspect term before descending; return an Equality to stop descending, or None to recurse.
Arguments.
d: Owning session.frame: Current proof frame.term: Current sub-expression.budget: Work allowance.
Returns. Replacement equality or None.
Raises.
LibError: On invalid handles or exhaustion.
EqualityWalker.application¶
def application(mut self, d: Session, frame: Frame, original: Expr, function: Equality, arguments: List[Equality], mut budget: Budget) raises LibError -> Equality
Combine equalities for an application's head and arguments.
Arguments.
d: Owning session.frame: Current proof frame.original: Original application expression.function: Function equality.arguments: Argument equalities.budget: Work allowance.
Returns. Combined equality for the application.
Raises.
LibError: On invalid equalities or exhaustion.
EqualityWalker.abstraction¶
def abstraction(mut self, d: Session, frame: Frame, inner: Frame, body: Equality, mut budget: Budget) raises LibError -> Equality
Combine an equality derived under a binder into an abstraction equality.
Arguments.
d: Owning session.frame: Enclosing proof frame.inner: Opened binder frame.body: Body equality atinner.budget: Work allowance.
Returns. Equality between abstractions.
Raises.
LibError: On invalid equality or exhaustion.
walk_equalities¶
def walk_equalities[W: EqualityWalker](session: Session, frame: Frame, term: Expr, mut policy: W, mut budget: Budget, functions: Bool = True) raises LibError -> Equality
Walk term recursively with policy, assembling a checked equality.
Parameters.
W: Traversal policy implementingEqualityWalker.
Arguments.
session: Owning session.frame: Proof frame.term: Expression to rewrite.policy: Traversal policy.budget: Work allowance.functions: Whether to descend into application heads.
Returns. Checked Equality.
Raises.
LibError: On policy failure or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
ACU rearrangement at function types¶
A class-level ACU declaration does not apply at a function type (kernel
K2.9): there (f ⊕ g)(x) stays curried and f ⊕ g is not sorted, as in
Isabelle. A theorem proved where the declaration applies is stored in its
normal form at the type variable, so its instance at a function type can
reorder or renest the operands of the statement a client expects.
function_acu_move closes that gap by proof: it normalizes both statements
with the operators' laws at those types, under binders and inside curried
applications, and moves the step by the resulting equation when the normal
forms agree; it returns None otherwise. Proof authoring and Store article
realization call it before refusing a mismatch; it adds no trust, since
every step is a kernel rule. The law proofs (AcuLaws, acu_normalize,
acu_merge) are shared with Store's conversion elimination, which applies
the same laws in a theory without an ACU signature.
function_acu_move¶
def function_acu_move(session: Session, proof: Step, statement: Expr, mut budget: Budget, frame: Optional[Frame] = None) raises LibError -> Optional[Step]
Move a step to an ACU-equivalent statement modulo registered ACU operators.
A class-level ACU operator at a function type is not normalized by the kernel (Definition Y-15), so a theorem
stored in its normal form at the type variable can, at a function type, state a reordering or renesting of what a
client expects. Both statements are normalized with the operator's laws at that type, under binders, inside
curried applications, and through lets, which conversion reduces; when the normal forms agree the step is moved
to the statement by the equation the laws prove. A class-level ACU constant has one type parameter, its carrier,
and an instance at a function type is in the sort syntactically wherever use made it, so these are all the
instances that need it.
Arguments.
session: Owning session.proof: Checked step.statement: Target proposition.budget: Work allowance.frame: Optional proof frame.
Returns. Checked step concluding statement, or None.
Raises.
LibError:LIMITon exhaustion;WRONG_KERNELfor another session's handles;KERNELfor a stale handle. Other refusals give None, and so does a fault reading the bank inside the move: the session reports both asKERNEL, so a bank fault reads as no match. With a captured frame, all typed failures are propagated; only a law's checked scope refusal excludes that candidate. Atomic (G9): a failure or None leaves no rows.
Defined in src/judgment_shell/_dag_function_acu.mojo.
AcuLaws¶
struct AcuLaws(Copyable)
| Field | Type | Description |
|---|---|---|
operator |
Expr |
The operator instance c[τ̄]. |
types |
List[TypeExpr] |
The type arguments its laws are used at, in use's order; none for monomorphic laws. |
unit |
Optional[Expr] |
Its unit at those types, if any. |
associativity |
Fact |
Its associativity law, ∀a b c. c(c(a, b), c) = c(a, c(b, c)). |
commutativity |
Fact |
Its commutativity law, ∀a b. c(a, b) = c(b, a). |
unit_law |
Optional[Fact] |
Its unit law, ∀a. c(e, a) = a, with the unit. |
An associative, commutative operator with its laws, applied by proof where the kernel does not normalize it.
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
AcuLaws.__init__¶
def __init__(out self, operator: Expr, var types: List[TypeExpr], unit: Optional[Expr], associativity: Fact, commutativity: Fact, unit_law: Optional[Fact])
Collect an operator and its laws.
Arguments.
operator: The operator instance.types: The laws' type arguments, inuse's order.unit: The unit, if any.associativity: The associativity law.commutativity: The commutativity law.unit_law: The unit law, exactly when there is a unit.
acu_normalize¶
def acu_normalize(session: Session, frame: Frame, acu: AcuLaws, term: Expr, mut budget: Budget, atoms: Dict[UInt32, Bool] = Dict[UInt32, Bool]()) raises LibError -> Step
Prove term = NF_ACU(term) using only acu's checked laws.
The traversal descends the finite operand DAG and memoizes completed nodes, processing left before right. The budget bounds traversal and proof work.
Arguments.
session: Owning session.frame: Proof frame.acu: ACU law bundle.term: Expression to normalize.budget: Work allowance.atoms: Optional opaque atom node set.
Returns. Checked equality step.
Raises.
LibError: What the laws' steps raise;LIMIT. A failure leaves no rows (G9).
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
acu_merge¶
def acu_merge(session: Session, frame: Frame, acu: AcuLaws, left: Expr, right: Expr, mut budget: Budget, atoms: Dict[UInt32, Bool] = Dict[UInt32, Bool]()) raises LibError -> Step
Merge two ACU-normalized expressions into one normalized expression with proof.
Arguments.
session: Owning session.frame: Proof frame.acu: ACU law bundle.left: Left normalized expression.right: Right normalized expression.budget: Work allowance.atoms: Optional opaque atom node set.
Returns. Checked equality step.
Raises.
LibError: What the laws' steps raise;LIMIT. A failure leaves no rows (G9).
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
acu_split¶
def acu_split(session: Session, acu: AcuLaws, term: Expr, mut budget: Budget, atoms: Dict[UInt32, Bool] = Dict[UInt32, Bool]()) raises LibError -> Optional[Tuple[Expr, Expr]]
Split a binary application of acu.operator unless treated as atomic.
Arguments.
session: Owning session.acu: ACU law bundle.term: Candidate term.budget: Work allowance.atoms: Optional opaque atom node set.
Returns. (lhs, rhs) pair or None.
Raises.
LibError:KERNELfor a stale handle or an unreadable node;LIMIT.
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
acu_law¶
def acu_law(session: Session, frame: Frame, law: Fact, acu: AcuLaws, terms: List[Expr], mut budget: Budget) raises LibError -> Step
Instantiate an ACU law at frame and terms.
Arguments.
session: Owning session.frame: Proof frame.law: ACU law fact.acu: ACU law bundle.terms: Term arguments.budget: Work allowance.
Returns. Instantiated equality step.
Raises.
LibError: Whatuseraises;LIMIT.
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
acu_congruence¶
def acu_congruence(session: Session, frame: Frame, acu: AcuLaws, left: Step, right: Step, mut budget: Budget) raises LibError -> Step
Apply congruence for an ACU operator to left and right equalities.
Arguments.
session: Owning session.frame: Proof frame.acu: ACU law bundle.left: Left operand equality.right: Right operand equality.budget: Work allowance.
Returns. Combined equality step.
Raises.
LibError: What the equality steps raise;LIMIT.
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
acu_right¶
def acu_right(session: Session, proof: Step) raises LibError -> Expr
Read the right-hand side of an equality step.
Arguments.
session: Owning session.proof: Checked equality step.
Returns. Right-hand expression.
Raises.
LibError:SHAPEfor a step not authored as an equation;WRONG_KERNELfor another session's step;KERNELfor a stale handle.
Defined in src/judgment_shell/_dag_acu_proofs.mojo.
Selected syntax graphs¶
syntax_dag builds a bounded, read-only postorder graph of selected,
binder-free syntax. A SyntaxSelector chooses child slots or declines the
graph; the walker owns scheduling, memoization, capacity checks, and
ordered child indices. Duplicate nodes share rows, and repeated edges and
roots keep their order. A node is syntax, not an independently checked
term.
SyntaxSelector¶
trait SyntaxSelector(Movable)
Choose child slots using structural data only, as SyntaxSelector.
Defined in src/judgment_shell/_dag_syntax_dag.mojo.
SyntaxSelector.select¶
def select(mut self, d: Session, term: Expr, mut budget: Budget) raises LibError -> Optional[List[Int]]
Select children in traversal order, or decline the whole graph.
The selector may keep private metadata; callers discard it when traversal fails or declines.
Arguments.
d: The session.term: The node, an expression of the session.budget: Shared allowance, including the selector's work.
Returns. Child slots (0 an application's function, i its i-th argument), an empty list for a leaf, or none to decline.
Raises.
LibError: Invalid input or exhaustion.
SyntaxNode¶
struct SyntaxNode(Copyable)
| Field | Type | Description |
|---|---|---|
term |
Expr |
The node's expression. |
children |
List[Int] |
Child rows in the selector's order, repeated edges included. |
One inspected node, its children preceding it in the graph.
Defined in src/judgment_shell/_dag_syntax_dag.mojo.
SyntaxNode.__init__¶
def __init__(out self, term: Expr, var children: List[Int])
A node.
Arguments.
term: Its expression.children: Its child rows.
SyntaxDAG¶
struct SyntaxDAG(Copyable)
| Field | Type | Description |
|---|---|---|
nodes |
List[SyntaxNode] |
Shared nodes, each visited once without crossing a binding edge. |
roots |
List[Int] |
Rows in input order, repeated roots included. |
A per-invocation syntax graph with deterministic postorder rows, as SyntaxDAG.
Defined in src/judgment_shell/_dag_syntax_dag.mojo.
SyntaxDAG.__init__¶
def __init__(out self, var nodes: List[SyntaxNode], var roots: List[Int])
A graph.
Arguments.
nodes: Its nodes in postorder.roots: Its roots' rows.
syntax_dag¶
def syntax_dag[S: SyntaxSelector](session: Session, terms: List[Expr], mut selector: S, mut budget: Budget, capacity: Int = Int.MAX, reverse_roots: Bool = False) raises LibError -> Optional[SyntaxDAG]
Build a bounded postorder syntax DAG for terms guided by selector.
Every root is validated before selection, unused and duplicate ones included. Binding edges are refused, so node identity suffices for the memo. No proof or declaration is made.
Parameters.
S: Selection policy implementingSyntaxSelector.
Arguments.
session: Owning session.terms: Root expressions.selector: Selection policy.budget: Work allowance.capacity: Maximum node capacity.reverse_roots: Whether to visit roots in reverse order.
Returns. Built SyntaxDAG or None if declined.
Raises.
LibError:KERNELfor a stale root;SHAPEfor a bad slot or capacity;UNSUPPORTEDfor a binding edge;LIMITon exhaustion or capacity.
Defined in src/judgment_shell/_dag_syntax_dag.mojo.
Additional session and checked exports¶
These exports serve Scalar, Store, and other clients that read a session's declarations, rebuild syntax in another session over a shared snapshot, or eliminate conversion steps.
fresh_name(session, base) returns the first of base, base_1,
base_2, … that the session has not used as a variable name; a base that
begins with · is reserved for the library's own variables and is
SHAPE. transport_fix fixes a new local on every call, under a reserved
name, so a transport binder never coincides with a session variable or
another call's binder.
AcuBinding¶
@fieldwise_init
struct AcuBinding(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
operator |
Expr |
The constant at the registered type arguments. |
unit |
Optional[Expr] |
The unit when the registration includes a unit law. |
The exact constant instance and optional unit of a checked ACU registration.
Defined in src/judgment_shell/_dag_conversion_bindings.mojo.
ConversionEliminator¶
struct ConversionEliminator(Movable)
| Field | Type | Description |
|---|---|---|
acus |
List[EliminationAcu] |
Registered ACU operator eliminations and their target checked laws. |
rationals |
List[EliminationRational] |
Registered exact-rational literal eliminations and their target checked laws. |
Normalizes target expressions modulo eliminated ACU operators and exact rational literal kinds.
Defined in src/judgment_shell/_dag_conv_elim.mojo.
ConversionEliminator.__init__¶
def __init__(out self, var acus: List[EliminationAcu] = List[EliminationAcu](), var rationals: List[EliminationRational] = List[EliminationRational]())
Initialize an eliminator with zero or more eliminated ACU and exact-rational entries.
Arguments.
acus: Eliminated ACU operators with their target checked laws.rationals: Eliminated exact-rational literal kinds with their target checked operations and laws.
ConversionEliminator.is_empty¶
def is_empty(self) -> Bool
Report whether any ACU or literal elimination is configured.
Returns. True when no eliminations are registered.
ConversionEliminator.find_rational¶
def find_rational(self, source_decl: UInt32) -> Int
Find the index of an eliminated rational literal kind by its source declaration id.
Arguments.
source_decl: SourceDECL_LITERAL_KINDid.
Returns. Index in self.rationals, or -1 if absent.
ConversionEliminator.has_acu¶
def has_acu(self, source_decl: UInt32) -> Bool
Report whether a source ACU declaration is eliminated by this eliminator.
Arguments.
source_decl: SourceDECL_ACU_OPERATORid.
Returns. True if present.
ConversionEliminator.encode_literal¶
def encode_literal(mut self, source_decl: UInt32, q: Rational, mut budget: Budget) raises LibError -> Expr
Encode a source rational literal into its canonical target expression and cache its rational value.
Arguments.
source_decl: SourceDECL_LITERAL_KINDid.q: Exact rational value.budget: Work allowance.
Returns. Canonical target expression T(q).
Raises.
LibError:NO_MATCHifsource_declis not registered, or exhaustion.
ConversionEliminator.normalize¶
def normalize(mut self, d: Session, frame: Frame, expr: Expr, mut budget: Budget) raises LibError -> Step
Prove frame ⊢ expr = NF(expr) on a Session.
Arguments.
d: Target session.frame: Proof frame.expr: Target expression.budget: Work allowance.
Returns. Checked equality step frame ⊢ expr = NF(expr).
Raises.
LibError: On invalid handles or exhaustion.
ConversionEliminator.prove_equiv¶
def prove_equiv(mut self, d: Session, frame: Frame, lhs: Expr, rhs: Expr, mut budget: Budget) raises LibError -> Step
Prove frame ⊢ lhs = rhs on a Session.
Arguments.
d: Target session.frame: Proof frame.lhs: Left-hand target expression.rhs: Right-hand target expression.budget: Work allowance.
Returns. Checked equality step frame ⊢ lhs = rhs.
Raises.
LibError: On non-convertible normal forms or exhaustion.
ConversionEliminator.convert_step¶
def convert_step(mut self, d: Session, frame: Frame, step: Step, target_prop: Expr, mut budget: Budget) raises LibError -> Step
Convert a checked step to an equivalent proposition on a Session.
Arguments.
d: Target session.frame: Proof frame.step: Checked step concludingP.target_prop: Target propositionQequivalent toP.budget: Work allowance.
Returns. Checked step concluding Q.
Raises.
LibError: IfPandQare not equivalent or on exhaustion.
DeclInfo¶
@fieldwise_init
struct DeclInfo(Copyable, Movable)
| Field | Type | Description |
|---|---|---|
name |
String |
Its qualified name; empty for an unnamed one (an ACU operator, a specification, whose constants go by their own names). |
kind |
UInt8 |
Its DeclKind code (termbank's DECL_*). |
params |
Int |
Its type-parameter count. |
arity |
Int |
A type constructor's arity, or a type definition's parameter count; -1 for any other kind. |
transparent |
Bool |
A definition's transparency (whether convert may unfold it); false for any other kind. |
decl |
UInt32 |
The bank's declaration index, valid while the session's rows are (G6). |
One declaration of a session beyond the core, as dag_declarations lists it.
Defined in src/judgment_shell/_dag_views.mojo.
EliminationAcu¶
@fieldwise_init
struct EliminationAcu(Copyable, Movable)
| Field | Type | Description |
|---|---|---|
source_decl |
UInt32 |
Source DECL_ACU_OPERATOR declaration id. |
laws |
AcuLaws |
Target operator, optional unit, and checked associativity/commutativity/unit facts. |
Target checked ACU laws replacing a source DECL_ACU_OPERATOR without target registration.
Defined in src/judgment_shell/_dag_conv_elim.mojo.
EliminationRational¶
@fieldwise_init
struct EliminationRational(Copyable, Movable)
| Field | Type | Description |
|---|---|---|
source_decl |
UInt32 |
Source DECL_LITERAL_KIND declaration id. |
carrier |
TypeExpr |
Target carrier type. |
domain |
Optional[Expr] |
Optional target domain predicate (e.g., real). |
ops |
List[Expr] |
Ten target operations ordered by LiteralOp code (zero, one, add, mul, neg, inv, pow, exponent, lt, le). |
laws |
List[Fact] |
Twenty-four target checked facts ordered by LiteralLaw code 0..23 (R1..R7, O1..O7, F1..F2, E1..E4, P1..P4). |
add_acu |
AcuLaws |
Checked ACU laws for ops[_OP_ADD] with unit ops[_OP_ZERO]. |
mul_acu |
AcuLaws |
Checked ACU laws for ops[_OP_MUL] with unit ops[_OP_ONE]. |
Target checked operations and laws replacing a source EXACT_RATIONAL DECL_LITERAL_KIND.
Defined in src/judgment_shell/_dag_conv_elim.mojo.
ForkUnit¶
struct ForkUnit(Movable, ThreadTransferable)
One fork of a DAG session, owned by one worker thread at a time.
The reviewed basis of the ThreadTransferable claim: what the fork owns is
its own (its state's tables are deep copies; its workspace, writer, store
and construction engine are made for it, the engine's signature answers
included), and what it shares with its parent and its siblings is either
read-only while the parent is idle (the parent's rows and indexes beneath
the child workspace, the bank's columns, the snapshot of a session opened over one) or
written only through atomics or under a lock: reference counts, the bank
tree's reader-epoch table, the parent's child count and closed word on
drop, and the parent's count of children made, which only fork itself (on the
parent's thread, before any move) writes. Its raw-address fields (the
writer source, the overlay columns' parents, the epoch table) point into
heap memory that the fork owns or keeps alive through reference counts, as
for Workspace.
A session opened over a snapshot hands each fork a copy of the snapshot:
its alias tables, its view (a value whose storage is shared through
reference counts) and its store (shared). A fork's reads never use the
snapshot's view, only its alias tables; the bank storage that view and the
forks' workspaces read is read through reader epochs, and the only state a
read writes is the spill frames' cache, through compare-and-swap; and the
store's writer is touched only by seal, which a fork refuses before any
change. So the forks of such a session may run on threads too, under the
same rule.
The rule in the module documentation must hold, and the workers that hold
units at once must stay well below the bank's reader slots (128). A read
holds one slot; a commit into a fork's workspace (Workspace._into, a
transaction's commit) holds a second for its source while _ws_enter
holds the target's, so a worker holds at most two at once.
Defined in src/judgment_shell/ws_fork.mojo.
ForkUnit.__init__¶
def __init__(out self, var fork: Session)
Own a fork for a worker.
Arguments.
fork: A fork made bySession.fork; no handle of it may stay with another thread.
ForkUnit.take¶
def take(deinit self) -> Session
The fork, for the thread that holds the unit.
Returns. The fork; to move it on, wrap it in a unit again.
ForkUnit.prepare¶
@staticmethod
def prepare(parent: Session, work: UInt64, hidden: List[String]) raises LibError -> Self
Prepare a proof worker, hiding batch names outside its dependency closure.
Arguments.
parent: Idle coordinator session.work: This worker's allowance.hidden: Earlier batch names the job did not declare as dependencies.
Returns. One exclusively owned worker fork.
Raises.
LibError: AsSession.fork.
ForkUnit.work_remaining¶
def work_remaining(self) -> UInt64
Read the remaining work allowance.
Returns. Remaining work units.
ForkUnit.check_lemma¶
def check_lemma(mut self, name: String, statement: def(Session) thin raises LibError -> Expr, prove: def(mut _DagProof, List[Fact]) thin raises LibError -> None, uses: List[String]) raises LibError -> ForkProof
Run a statement and proof callback once, retaining a closed proof without declaring it.
Arguments.
name: Fresh theorem name for eventual integration.statement: Builds its goal from the shared vocabulary.prove: Solves the draft using the supplied dependencies.uses: Declared dependency names, in callback argument order.
Returns. Closed proof work owned by this fork.
Raises.
LibError: The callback's error, unfinished goals, or a callback that changes the theory or leaves a transaction open.
ForkUnit.integrate¶
def integrate(mut self, parent: Session, name: String, var result: ForkProof) raises LibError -> Fact
Transfer checked rows and register a theorem on the parent's current theory.
Siblings must all be joined first. Their proof DAGs contain no new declarations, so each result is registered in coordinator order using the ordinary checked theorem rule, without running either callback.
Arguments.
parent: Direct parent of this joined fork.name: Name to register.result: The proof work produced by this fork.
Returns. The parent's new fact.
Raises.
LibError: Wrong ownership, a changed theory in the worker, exhausted work or refused proof rows. Failure restores the parent.
ForkProof¶
struct ForkProof(Movable, ThreadTransferable)
A closed checked proof retained by its owning fork until ordered integration.
This is proof work, with no new theory declarations. Construction and proof callbacks must leave the theory unchanged; declare their shared vocabulary on the parent before preparing jobs. No worker handle escapes the fork.
Defined in src/judgment_shell/ws_fork.mojo.
ForkProof.__init__¶
def __init__(out self, proof: UInt32, capture: Bool, owner: UInt64)
Internal; produced by ForkUnit.check_lemma.
Arguments.
proof: The closed checked proof row.capture: Preserve its monomorphic judgment alongside publication.owner: Owning session identity.
InterpretationScope¶
struct InterpretationScope(ImplicitlyCopyable)
Checked lease on two innermost transactions and fixed signatures for interpretations.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
InterpretationScope.__init__¶
def __init__(out self, source: Session, target: Session, base: Snapshot, mut budget: Budget) raises LibError
Capture the live owning scopes of source and target over base.
Arguments.
source: Source session.target: Target session.base: Common immutable snapshot.budget: Work allowance.
Raises.
LibError: On missing transactions, unrelated bases, or exhaustion.
InterpretationScope.check¶
def check(self, source: Session, target: Session, base: Snapshot, mut budget: Budget) raises LibError
Verify that both endpoints, base, and transactions remain unchanged.
Arguments.
source: Source session.target: Target session.base: Common immutable snapshot.budget: Work allowance.
Raises.
LibError: On stale/rolled-back scopes, changed signatures, or exhaustion.
LiteralBinding¶
@fieldwise_init
struct LiteralBinding(Movable)
| Field | Type | Description |
|---|---|---|
kind |
Declaration |
The verified registration in its owner. |
implementation |
UInt8 |
The evaluator selected by this registration. |
carrier |
TypeExpr |
The type of the literal values. |
base |
UInt32 |
Underlying literal-kind declaration, or NONE for a primitive kind. |
domain |
Optional[Expr] |
The optional domain predicate. |
operations |
List[Tuple[Int, Expr]] |
Each operation code and its declared term in increasing code order. |
The carrier, optional domain/base and operation slots of a checked literal kind.
Defined in src/judgment_shell/_dag_conversion_bindings.mojo.
ProfileMarker¶
Mojo
@fieldwise_init
struct ProfileMarker(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
profile |
Int |
The profile. |
declarations |
Int |
Its declarations, which follow the core's in one segment over the root theory. |
Python
from judgment import ProfileMarker
The profile a session's snapshot holds above the core, recorded where it was installed or loaded.
The session checks it against the bank, but its count is the caller's word: build it only where the profile itself is installed (or loaded as a profile), never from a loaded library, whose declarations may have a profile's shape.
Defined in src/judgment_shell/_ws_snapshots.mojo.
ReplaySyntax¶
trait ReplaySyntax
The interpretation's translation of checked syntax operands, prior to target proof construction.
Defined in src/judgment_shell/_dag_replay.mojo.
ReplaySyntax.term¶
def term(mut self, source: Session, target: Session, expr: Expr, mut work: Budget) raises LibError -> Expr
Translate a closed source term into the target session.
Arguments.
source: Source session.target: Target session.expr: Source expression.work: Shared work allowance.
Returns. Translated target expression.
Raises.
LibError: On untranslatable term or exhaustion.
ReplaySyntax.scoped_term¶
def scoped_term(mut self, source: Session, target: Session, source_frame: Frame, target_frame: Frame, expr: Expr, locals: List[Tuple[Expr, Expr]], mut work: Budget) raises LibError -> Expr
Translate a scoped source term into the target session.
Arguments.
source: Source session.target: Target session.source_frame: Source frame.target_frame: Target frame.expr: Source expression.locals: Local variable pairs.work: Shared work allowance.
Returns. Translated target expression.
Raises.
LibError: On untranslatable term or exhaustion.
ReplaySyntax.conversion¶
def conversion(self, source: UInt32) -> Optional[UInt32]
Look up the target conversion declaration for a source conversion declaration.
Arguments.
source: Source declaration id.
Returns. Mapped target declaration id, or None.
ReplaySyntax.type_¶
def type_(mut self, source: Session, target: Session, t: TypeExpr, mut work: Budget) raises LibError -> TypeExpr
Translate a source type into the target session.
Arguments.
source: Source session.target: Target session.t: Source type expression.work: Shared work allowance.
Returns. Translated target type expression.
Raises.
LibError: On untranslatable type or exhaustion.
acu_binding¶
def acu_binding(session: Session, id: UInt32, mut work: Budget) raises LibError -> AcuBinding
Read the operator and optional unit of a registered ACU declaration.
Arguments.
session: Owning session.id: ACU declaration index.work: Work allowance.
Returns. Checked AcuBinding.
Raises.
LibError: On invalid declaration or exhaustion.
Defined in src/judgment_shell/_dag_conversion_bindings.mojo.
acu_constants¶
def acu_constants(session: Session, mut budget: Budget) raises LibError -> Dict[UInt32, Bool]
Return the set of registered ACU operator head ids visible in session.
A client keys its matching on declarations; this answers which are ACU without reading storage. An operator is
declared at some instance c[ρ̄] (the row's operands 1.. give which); a constant made ACU at one instance is
listed once, so a client treating every instance as ACU is conservative, its results checked.
Arguments.
session: Owning session.budget: Work allowance.
Returns. Map of ACU operator node/head ids.
Raises.
LibError:KERNELwhen the bank cannot be read;LIMITon exhaustion.
Defined in src/judgment_shell/_ws_handles.mojo.
acu_declaration¶
def acu_declaration(session: Session, operator: Expr, mut budget: Budget) raises LibError -> Optional[Declaration]
Find the ACU operator declaration for operator, if registered.
It is the first of the constant's ACU operator declarations, in declaration order, whose declared instance's type arguments match the operator's; the snapshot's and imports' declarations included.
Arguments.
session: Owning session.operator: Binary operator expression.budget: Work allowance.
Returns. ACU declaration handle, or None.
Raises.
LibError:WRONG_KERNELfor another session's operator;KERNELfor a stale handle or an unreadable bank;LIMIT.
Defined in src/judgment_shell/_dag_bundles.mojo.
base_literal_kind¶
def base_literal_kind(source: Session, target: Session, base: Snapshot, literal: Expr, mut budget: Budget) raises LibError -> Declaration
Resolve the shared-base literal kind declaration in target for a literal from source.
Arguments.
source: Source session.target: Target session.base: Common immutable snapshot.literal: Literal expression insource.budget: Work allowance.
Returns. Target literal kind declaration handle.
Raises.
LibError: On non-base literal or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
compare¶
def compare(session: Session, a: Expr, b: Expr) raises LibError -> Int
Compare two expressions by alpha-invariant structural order.
The order is T1.6's. Locals are ordered by their hash (of their binding depth, name and type), then binding
depth, which counts rebases and the engine's anchors, then name, then LOCAL row for locals that tie on all of
these on different chains; it is the same in every bank only for terms without locals.
Arguments.
session: Owning session.a: First expression.b: Second expression.
Returns. -1, 0, or 1.
Raises.
LibError:KERNELfor a stale handle or an unreadable node;LIMITwhen the session's allowance cannot cover the pairs visited (one unit each, as the checker charges).
Defined in src/judgment_shell/_ws_handles.mojo.
conditional_branch_fast¶
def conditional_branch_fast(session: Session, frame: Frame, ite: Expr, choice: Fact, alpha: TypeExpr, positive: Bool) raises LibError -> Step
Prove ite True x y = x (or ite False x y = y) charging session directly.
Under the fixed P x y and the guard, the choice law at the predicate λz. (P → z = x) ∧ (¬P → z = y) and the
selected value (whose two cases are proved, the other by contradiction) gives the predicate at the chosen value;
its selected conjunct at the guard is ε(…) = x, which unfolding ite restates; the guard and the variables are
then discharged. No name lookup or new axiom is used.
Arguments.
session: Owning session.frame: Proof frame.ite: Conditional constant atalpha.choice: Choice axiom/theorem fact.alpha: Branch type.positive: True for theTruebranch, False for theFalsebranch.
Returns. Checked branch equation step.
Raises.
LibError:KERNELfor a conditional or a choice law of another form; what the steps raise.
Defined in src/judgment_shell/_dag_derived.mojo.
constant_key¶
def constant_key(session: Session, constant: Expr, mut budget: Budget) raises LibError -> UInt64
Compute a unique key for a constant expression's declaration and head.
Arguments.
session: Owning session.constant: Constant expression.budget: Work allowance.
Returns. Canonical constant key.
Raises.
LibError: On non-constant or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
core_declarations¶
def core_declarations(session: Session, mut budget: Budget) raises LibError -> Dict[String, UInt32]
Return the map of core declaration names to declaration indices.
A client keys its tables on declarations; the core's are found here by name, once, so it reads no storage.
Arguments.
session: Owning session.budget: Work allowance.
Returns. Name-to-declaration-index map.
Raises.
LibError:KERNELwhen the bank cannot be read;LIMITon exhaustion.
Defined in src/judgment_shell/_dag_views.mojo.
declarations¶
def declarations(session: Session, mut budget: Budget) raises LibError -> List[DeclInfo]
List declarations visible in session past the core prefix.
Arguments.
session: Owning session.budget: Work allowance.
Returns. Declaration metadata entries in declaration order.
Raises.
LibError: On closed session or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
encode_rational¶
def encode_rational(rat: EliminationRational, q: Rational, mut budget: Budget) raises LibError -> Expr
Encode an exact rational q into its canonical target expression over rat.ops.
Arguments.
rat: Target rational operation table.q: Exact rational value.budget: Work allowance.
Returns. Canonical target expression T(q).
Raises.
LibError: On invalid handles or exhaustion.
Defined in src/judgment_shell/_dag_conv_elim.mojo.
expr_type¶
def expr_type(session: Session, expression: Expr, mut budget: Budget) raises LibError -> TypeExpr
Read the checked type of expression in session.
The typing operation uses the session's work allowance, in addition to this caller's query charge. Foreign or stale handles are refused before typing.
Arguments.
session: Owning session.expression: Checked expression.budget: Work allowance.
Returns. Checked type expression.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
expr_type_unchecked¶
def expr_type_unchecked(session: Session, e: Expr) raises LibError -> TypeExpr
Read the checked type of e in session charging the session directly.
Arguments.
session: Owning session.e: Checked expression.
Returns. Checked type expression.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_equalities.mojo.
fresh_name¶
def fresh_name(session: Session, base: StaticString) raises LibError -> String
Generate a fresh variable name prefixed with base.
Arguments.
session: Owning session.base: Name prefix.
Returns. Fresh variable name.
Raises.
LibError:SHAPEfor a reserved base (one that begins with·);LIMITon exhaustion.
Defined in src/judgment_shell/_dag_derived.mojo.
interpretation_members¶
def interpretation_members(session: Session, first: UInt32, correspondences_only: Bool, mut work: Budget) raises LibError -> List[DeclInfo]
List declarations from first onward in session for interpretation validation.
Arguments.
session: Owning session.first: Starting declaration index.correspondences_only: If True, return only conversion/class-relation declarations.work: Work allowance.
Returns. Declaration metadata entries.
Raises.
LibError: On exhaustion.
Defined in src/judgment_shell/_dag_conversion_bindings.mojo.
let_¶
def let_(session: Session, variable: Expr, value: Expr, body: Expr, mut budget: Budget, frame: Optional[Frame] = None) raises LibError -> Expr
Build a let-expression let variable = value in body.
The abstraction supplies the capture-free de Bruijn body; the let row is settled by the checker before the enclosing transaction retains it.
Arguments.
session: Owning session.variable: Bound variable.value: Bound value.body: Let body.budget: Work allowance.frame: Optional frame.
Returns. Checked let expression.
Raises.
LibError: On type mismatch or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
literal_at¶
def literal_at(session: Session, frame: Frame, kind: Declaration, value: LiteralValue, mut budget: Budget) raises LibError -> Expr
Construct a literal of kind with value at frame's signature.
Arguments.
session: Owning session.frame: Target frame.kind: Registered literal kind declaration.value: Literal value.budget: Work allowance.
Returns. Checked literal expression.
Raises.
LibError: Invalid kind, owner, lifetime, visibility, encoding or budget; failure is atomic.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
literal_binding¶
def literal_binding(session: Session, id: UInt32, mut work: Budget) raises LibError -> LiteralBinding
Read the carrier, domain, and operations of a registered literal kind declaration.
Arguments.
session: Owning session.id: Literal-kind declaration index.work: Work allowance.
Returns. Checked LiteralBinding.
Raises.
LibError: On invalid declaration or exhaustion.
Defined in src/judgment_shell/_dag_conversion_bindings.mojo.
literal_identity¶
def literal_identity(session: Session, kind: Declaration, mut budget: Budget) raises LibError -> UInt32
Read the declaration index of a literal kind handle in session.
Arguments.
session: Owning session.kind: Literal kind declaration handle.budget: Work allowance.
Returns. Declaration index.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
open_binder_at¶
def open_binder_at(session: Session, frame: Frame, e: Expr, name: String, mut budget: Budget, internal: Bool = False) raises LibError -> Tuple[Frame, Expr, Expr]
Open a lambda binder e at frame's canonical signature.
Arguments.
session: Owning session.frame: Enclosing frame.e: Lambda expression.name: Fresh local name.budget: Work allowance.internal: Whether to bypass user-name restrictions, as foropen_binder.
Returns. Tuple (child_frame, local_expr, body_expr).
Raises.
LibError: Ownership, lifetime, signature, ancestry, name or budget refusal, as foropen_binder. Failure is atomic.
Defined in src/judgment_shell/_dag_views.mojo.
rebuild_constant¶
def rebuild_constant(source: Session, target: Session, base: Snapshot, constant: Expr, arguments: List[TypeExpr], mut budget: Budget, frame: Optional[Frame] = None) raises LibError -> Expr
Rebuild a shared-base constant from source in target at translated arguments.
A shared head includes its declaration part. Names and coincident foreign positions never choose the target constant.
Arguments.
source: Source session.target: Target session.base: Common immutable snapshot.constant: Base constant insource.arguments: Translated type arguments intarget.budget: Work allowance.frame: Optional target frame.
Returns. Rebuilt constant expression in target.
Raises.
LibError: On non-base constant or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
rebuild_type¶
def rebuild_type(session: Session, template: TypeExpr, arguments: List[TypeExpr], mut budget: Budget) raises LibError -> TypeExpr
Instantiate a type template's type variables in order with arguments.
Names play no part, so a shadowing declaration cannot change its identity. The engine checks arity, constructs the type, and settles before publication.
Arguments.
session: Owning session.template: Type template.arguments: Replacement type arguments.budget: Work allowance.
Returns. Instantiated type expression.
Raises.
LibError: On arity mismatch or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
relation_endpoints¶
def relation_endpoints(session: Session, declaration: UInt32, mut work: Budget) raises LibError -> Tuple[UInt32, UInt32]
Read the (sub, super) class declaration indices of a class relation.
Arguments.
session: Owning session.declaration: Class-relation declaration index.work: Work allowance.
Returns. Pair of class declaration indices.
Raises.
LibError: On invalid declaration or exhaustion.
Defined in src/judgment_shell/_dag_conversion_bindings.mojo.
replay_closed¶
def replay_closed[M: ReplaySyntax](source: Session, target: Session, base: Snapshot, theorem: Fact, expected: Expr, name: String, images: List[Tuple[Fact, Fact, Step]], definitions: Dict[UInt32, Tuple[Expr, Fact]], mut syntax: M, mut work: Budget,) raises LibError -> Fact
Replay a closed theorem's proof from source into target using syntax.
Parameters.
M: Translation provider implementingReplaySyntax.
Arguments.
source: Source session.target: Target session (with an open transaction).base: Common immutable snapshot.theorem: Source theorem to replay.expected: Expected translated conclusion intarget.name: Publication name intarget.images: Checked proof images.definitions: Mapped definition equations.syntax: Term/type/conversion translator.work: Work allowance.
Returns. Newly checked theorem Fact in target.
Raises.
LibError: On translation or proof rejection, or exhaustion.
Defined in src/judgment_shell/_dag_replay.mojo.
replay_closed_eliminated¶
def replay_closed_eliminated[M: ReplaySyntax](source: Session, target: Session, base: Snapshot, theorem: Fact, expected: Expr, name: String, images: List[Tuple[Fact, Fact, Step]], definitions: Dict[UInt32, Tuple[Expr, Fact]], mut syntax: M, mut eliminator: ConversionEliminator, mut work: Budget,) raises LibError -> Fact
Replay a closed theorem's proof from source into target, eliminating ACU/rational conversions.
Parameters.
M: Translation provider implementingReplaySyntax.
Arguments.
source: Source session.target: Target session (with an open transaction).base: Common immutable snapshot.theorem: Source theorem to replay.expected: Expected translated conclusion intarget.name: Publication name intarget.images: Checked proof images.definitions: Mapped definition equations.syntax: Term/type/conversion translator.eliminator: Conversion eliminator for ACU and exact rationals.work: Work allowance.
Returns. Newly checked theorem Fact in target.
Raises.
LibError: On translation or proof rejection, or exhaustion.
Defined in src/judgment_shell/_dag_public.mojo.
require_closed¶
def require_closed(session: Session, expression: Expr, mut budget: Budget) raises LibError
Refuse expression if it contains any free local variable.
Verified node flags propagate free-local occurrence through the DAG; bound de Bruijn variables are distinct. Reflexivity is not a closure check because canonical equality can erase its operands to True.
Arguments.
session: Owning session.expression: Expression to check.budget: Work allowance.
Raises.
LibError:SHAPEif open, or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
require_scope¶
def require_scope(session: Session, frame: Frame, expression: Expr, mut budget: Budget) raises LibError
Verify every free local of expression lies on frame's ancestor chain.
Both allowances pay for every admitted node/edge before allocation or reads, including closed siblings and duplicates. Names never establish local identity.
Arguments.
session: Owning session.frame: Scope frame.expression: Expression to check.budget: Work allowance.
Raises.
LibError:SHAPEif out of scope, or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
same_session¶
def same_session(source: Session, target: Session) raises LibError -> Bool
Report whether source and target refer to the same underlying live session.
Arguments.
source: First session.target: Second session.
Returns. True if both wrap the same session state.
Raises.
LibError: On closed session.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
scoped_expression¶
def scoped_expression(session: Session, expression: Expr, mut budget: Budget) raises LibError -> Expr
Re-issue expression in the current transaction of session.
Arguments.
session: Owning session.expression: Live expression.budget: Work allowance.
Returns. Expression handle valid in the current transaction.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
scoped_type¶
def scoped_type(session: Session, kind: TypeExpr, mut budget: Budget) raises LibError -> TypeExpr
Re-issue kind in the current transaction of session.
Arguments.
session: Owning session.kind: Live type expression.budget: Work allowance.
Returns. Type handle valid in the current transaction.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
shared_base¶
def shared_base(source: Session, target: Session, base: Snapshot, mut budget: Budget) raises LibError -> UInt32
Verify source and target both descend from base and return base's declaration count.
Both retained snapshots must belong to the same storage as base and
include its immutable prefix. Coincident positions in unrelated banks do
not identify declarations. A stale or foreign handle is refused; this query publishes no rows.
Arguments.
source: Source session.target: Target session.base: Common immutable snapshot.budget: Work allowance.
Returns. Declaration count of base.
Raises.
LibError: On unrelated snapshots or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
step_part¶
def step_part(step: Step, k: Int) raises LibError -> Expr
Read the k-th immediate sub-expression of a step's authored statement.
Arguments.
step: Checked step.k: Zero-based sub-expression index.
Returns. The k-th sub-expression.
Raises.
LibError: On out-of-range index or exhaustion.
Defined in src/judgment_shell/_dag_derived.mojo.
theorem_statement¶
def theorem_statement(source: Session, theorem: Fact, mut work: Budget) raises LibError -> Expr
Read the stored closed statement of theorem including its authored type-variable names.
Arguments.
source: Owning session.theorem: Proven theorem fact.work: Work allowance.
Returns. Closed theorem statement expression.
Raises.
LibError:SHAPEif not a proven theorem, or exhaustion.
Defined in src/judgment_shell/_dag_replay.mojo.
fact_statement_frame¶
def fact_statement_frame(source: Session, fact: Fact, mut work: Budget) raises LibError -> Tuple[Frame, Expr]
Read fact's closed statement together with a root frame at its declaration's canonical signature.
Arguments.
source: Owning session.fact: Fact ofsource(proven theorem, axiom, or definition equation).work: Work allowance.
Returns. Root frame at fact's declaration theory and its closed statement expression.
Raises.
LibError: On foreign/stale handle, unreadable declaration, or exhaustion.
Defined in src/judgment_shell/_dag_replay.mojo.
transport_fix¶
def transport_fix(session: Session, frame: Frame, kind: TypeExpr, mut budget: Budget) raises LibError -> Tuple[Frame, Expr]
Open a new transport fix frame of type kind under frame: each call fixes a new local (reserved name ·port·k).
Arguments.
session: Owning session.frame: Parent frame.kind: Variable type.budget: Work allowance.
Returns. (child_frame, local_expr).
Raises.
LibError: On invalid handles or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
type_constructor_identity¶
def type_constructor_identity(session: Session, constructor: TypeConstructor, mut budget: Budget) raises LibError -> UInt32
Read the declaration index of constructor in session.
Arguments.
session: Owning session.constructor: Checked type constructor.budget: Work allowance.
Returns. Declaration index.
Raises.
LibError: On invalid handle or exhaustion.
Defined in src/judgment_shell/_dag_interpret_port.mojo.
view_at¶
def view_at(session: Session, frame: Frame, e: Expr, mut budget: Budget) raises LibError -> TermView
Inspect e at frame's canonical signature.
Arguments.
session: Owning session.frame: Proof frame.e: Expression to inspect.budget: Work allowance.
Returns. Structural TermView.
Raises.
LibError: Foreign or stale handles, unavailable signature, free-local ancestry or inspection refusal.
Defined in src/judgment_shell/_dag_views.mojo.