judgment_store API¶
Import public names from judgment_store. ST1
specifies the typed errors, the container and identities;
ST7 and ST9 proof libraries,
versioned directories of proof-DAG partitions; ST6
and ST5 OpenTheory import and export; and
ST4 re-checking and interpretations between
sessions.
Errors¶
Match on error.kind, not the diagnostic text. An offset is zero-based
and optional: offset zero is a real location, distinct from no location.
Constructing StoreError(kernel_error, offset) wraps a KernelError as
KERNEL and includes the original kernel kind and message. The conversion
is also implicit: a kernel call inside a function declared raises
StoreError raises the converted error, without an offset. LIBRARY wraps judgment_shell refusals and preserves their original kind;
library budget exhaustion becomes LIMIT.
StoreErrorKind¶
Mojo
@fieldwise_init
struct StoreErrorKind(Equatable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
code |
UInt8 |
The category's number; compare named kinds rather than numeric codes. |
Python
from judgment import StoreErrorKind
Classify a failed store operation independently of its diagnostic text.
Defined in src/judgment_store/errors.mojo.
StoreErrorKind.FORMAT¶
Mojo
comptime FORMAT = StoreErrorKind(1)
Python
StoreErrorKind.FORMAT
Malformed bytes, including an unknown container format version.
StoreErrorKind.DIGEST¶
Mojo
comptime DIGEST = StoreErrorKind(2)
Python
StoreErrorKind.DIGEST
A container's checksum does not match its contents.
StoreErrorKind.IDENTITY¶
Mojo
comptime IDENTITY = StoreErrorKind(3)
Python
StoreErrorKind.IDENTITY
A declaration's identity does not match its canonical content.
StoreErrorKind.MISSING_DEPENDENCY¶
Mojo
comptime MISSING_DEPENDENCY = StoreErrorKind(4)
Python
StoreErrorKind.MISSING_DEPENDENCY
A referenced declaration or result is unavailable.
StoreErrorKind.KERNEL¶
Mojo
comptime KERNEL = StoreErrorKind(5)
Python
StoreErrorKind.KERNEL
The kernel refused a declaration, term, or proof.
StoreErrorKind.LIBRARY¶
Mojo
comptime LIBRARY = StoreErrorKind(6)
Python
StoreErrorKind.LIBRARY
The recipe or provenance library refused an operation.
StoreErrorKind.REPLAY¶
Mojo
comptime REPLAY = StoreErrorKind(7)
Python
StoreErrorKind.REPLAY
A record or stored proof cannot be replayed.
StoreErrorKind.VERSION¶
Mojo
comptime VERSION = StoreErrorKind(8)
Python
StoreErrorKind.VERSION
The termbank format or another required dependency version is incompatible.
StoreErrorKind.LIMIT¶
Mojo
comptime LIMIT = StoreErrorKind(9)
Python
StoreErrorKind.LIMIT
A work budget or an input-size limit was exceeded.
StoreErrorKind.IO¶
Mojo
comptime IO = StoreErrorKind(10)
Python
StoreErrorKind.IO
An operating-system file operation failed or made inconsistent progress.
StoreErrorKind.CONFLICT¶
Mojo
comptime CONFLICT = StoreErrorKind(11)
Python
StoreErrorKind.CONFLICT
A library's CURRENT is not the writer's base, or the writer's own LOCK was removed (ST7.2): rebuild on the current version.
StoreErrorKind.LOCKED¶
Mojo
comptime LOCKED = StoreErrorKind(12)
Python
StoreErrorKind.LOCKED
Another writer or collector holds a library's LOCK (ST7.2): retry when it finishes, or unlock a stale one.
StoreErrorKind.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write the category's stable name.
Arguments.
writer: The destination for the name.
StoreError¶
Mojo
struct StoreError(ConstructionFailure)
| Field | Type | Description |
|---|---|---|
kind |
StoreErrorKind |
The category callers should match on. |
message |
String |
A human-readable explanation, including the original kind for wrapped errors. |
offset |
Optional[Int] |
The zero-based byte offset in the input, when the failure has one. |
Python
from judgment import StoreError
Python constructor:
def __init__(self, kind, message, offset=None)
| Field | Description |
|---|---|
kind |
The category callers should match on. |
message |
A human-readable explanation, including the original kind for wrapped errors. |
offset |
The zero-based byte offset in the input, when the failure has one. |
Report a store failure with its category, diagnostic, and optional byte offset.
Kernel failures are explicitly wrapped as KERNEL, preserving their
original kind in the message. There is no conversion from plain Error.
Defined in src/judgment_store/errors.mojo.
StoreError.__init__¶
Mojo
def __init__(out self, kind: StoreErrorKind, message: String, offset: Optional[Int] = None)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Construct an error, optionally locating it in an input.
Arguments.
kind: The failure category.message: A description of the failure.offset: The input byte offset, or absent for a failure without a byte location.
StoreError.__init__¶
Mojo
@implicit
def __init__(out self, error: KernelError, offset: Optional[Int] = None)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Wrap a kernel failure, retaining its kind and message.
The conversion is implicit: a kernel call inside a function declared
raises StoreError converts its refusal where it raises, without a
byte offset. Construct it explicitly to attach an offset.
Arguments.
error: The kernel error to wrap asKERNEL.offset: The input byte offset, if known at the call site.
StoreError.__init__¶
Mojo
@implicit
def __init__(out self, error: BankError)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Wrap a bank failure, identifying resource exhaustion by its typed kind.
Arguments.
error: The bank failure; LIMIT and CAPACITY become Store LIMIT.
StoreError.__init__¶
Mojo
@implicit
def __init__(out self, error: LibError)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Wrap an authoring failure without parsing its diagnostic.
Arguments.
error: The failure, including its optional typed kernel/checker cause.
StoreError.__init__¶
Mojo
@implicit
def __init__(out self, error: CheckFail)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Retain a construction checker's resource refusal without parsing its text.
Arguments.
error: The typed checker failure, with its coordinates.
StoreError.__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 an absent internal lookup entry without interpreting its key text.
Parameters.
K: The dictionary's key type.
Arguments.
error: The missing key reported by the dictionary.
StoreError.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.
The construction algorithm's typed Store boundary.
Arguments.
kind: The failure's kernel category.message: Its unchanged diagnostic.
Returns. LIMIT for exhausted resources, LIBRARY for other construction refusals.
StoreError.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write the category, optional byte offset, and diagnostic.
Arguments.
writer: The destination for the diagnostic.
SHA-256¶
The one-shot and incremental interfaces use the same FIPS 180-4 compression function. Each update copies or processes its bytes before returning; it never retains the caller's span. Empty updates are harmless. Working memory is fixed-size, independent of the input length.
InlineArray in the design and signatures is an import alias for
std.collections.Array, a fixed-size inline array. A digest is
32 bytes in big-endian word order, as required by SHA-256; the
container's little-endian integer encoding does not change digest bytes.
state^.finish() consumes a state. state.copy().finish() finalizes a
snapshot and leaves the original available for more updates. As in FIPS
180-4, the message must contain fewer than 264 bits (261 bytes).
The hash API is non-raising and has no budget argument; callers must
admit and charge input bytes before hashing them in a budgeted reader.
sha256¶
def sha256(data: Span[UInt8, _]) -> InlineArray[UInt8, 32]
Hash a byte span with SHA-256 (FIPS 180-4).
Arguments.
data: The complete message, fewer than 2**61 bytes.
Returns. The 32 digest bytes in network byte order.
Defined in src/termbank/sha256.mojo.
Sha256¶
struct Sha256(Copyable, Movable)
Accumulate a SHA-256 digest in fixed working space.
Feed byte spans with update, then obtain the digest with finish.
The FIPS 180-4 message domain is fewer than 264 bits (261 bytes)
across all updates. Callers enforce their input limits before hashing.
Defined in src/termbank/sha256.mojo.
Sha256.__init__¶
def __init__(out self)
Initialize the eight chaining words for an empty message (FIPS 180-4 section 5.3.3).
Sha256.update¶
def update(mut self, data: Span[UInt8, _])
Append bytes to the message without retaining the input span.
Empty updates do nothing. Work is linear in the input length; storage is fixed and independent of message size or chunking.
Arguments.
data: The next bytes; total message length must remain below 2**61 bytes.
Sha256.finish¶
def finish(var self) -> InlineArray[UInt8, 32]
Pad the message and return its SHA-256 digest in network byte order.
Transfer the state with state^.finish(), or finalize an explicit
copy with state.copy().finish() to keep appending to the original.
Returns. The 32 digest bytes, most significant byte of each word first.
Containers¶
Writers emit container version two. The known kinds are 4, a library
manifest (ST7.3), and 6, a
proof-DAG partition (ST9.1),
with tags 1 to 8 and 1 to 10. Every other container version or kind is refused
at its field. The default section count limit
is nine; a partition's reader and writer raise it to ten. format_version()
reports the validated version.
ContainerWriter(kind, kernel_commit, budget, limits) writes a version-two
JDGB envelope. Add sections in increasing tag order, then call
writer^.finish(budget) for owned bytes. The kernel revision must contain
40 ASCII hexadecimal digits; it is recorded verbatim. The writer copies
payloads, and rejected additions leave it unchanged. Finalization consumes
the writer even if its budget is insufficient.
ContainerReader.open(data, budget, limits) validates the entire envelope
and checksum, then owns a copy. Changing or releasing the input cannot
change the validated reader. section(tag) borrows immutable bytes tied
to the reader's lifetime. has_section(tag) tests presence, while kind,
kernel_commit, format_version, and section_count expose header metadata.
Pass a mutable termbank.Budget to each operation. Defaults cap total
serialized bytes and individual payloads at 64 MiB and the section count
at nine; all limits are configurable and nonnegative, and are applied as
given. A successful reader open spends twice the input length. The writer
spends 61 for the header, 12 plus payload length for each section, and body
length plus 32 at finalization. See
ST1.3 for validation order and
precise error offsets.
Payloads are opaque here: an accepted envelope is not yet a checked library
manifest or partition. Different kernel revisions are accepted; a
termbank format other than this build's (termbank.TERMBANK_FORMAT, 2)
is refused with VERSION, so the files of a library written before format
2.2 are refused at their envelope.
ContainerLimits¶
struct ContainerLimits(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
max_bytes |
Int |
Maximum container length including the header and digest; defaults to 64 MiB. |
max_section_bytes |
Int |
Maximum payload length of one section; defaults to 64 MiB. |
max_sections |
Int |
Maximum number of sections; defaults to nine. A proof-DAG partition (kind 6, ST9.1) needs ten. |
Bound serialized bytes, individual payloads, and the number of sections.
Defined in src/judgment_store/container.mojo.
ContainerLimits.__init__¶
def __init__(out self, max_bytes: Int = 67108864, max_section_bytes: Int = 67108864, max_sections: Int = 9)
Configure limits that the reader and writer validate before use.
Arguments.
max_bytes: Nonnegative limit on the complete serialized length.max_section_bytes: Nonnegative limit on each section's payload.max_sections: Nonnegative section-count limit; this does not enable unknown tags.
ContainerWriter¶
struct ContainerWriter(Movable)
Write sections in strictly increasing tag order and append their container digest.
Validation and budget admission precede each mutation. A refused section leaves this writer unchanged. Finalization consumes the writer.
Defined in src/judgment_store/container.mojo.
ContainerWriter.__init__¶
def __init__(out self, kind: UInt8, kernel_commit: String, mut budget: Budget, limits: ContainerLimits = ContainerLimits()) raises StoreError
Write the version-two header using the current termbank format.
Arguments.
kind: Four for a library manifest or six for a proof-DAG partition.kernel_commit: The writer's 40-digit hexadecimal kernel revision, recorded verbatim.budget: Charged 61 steps before the header is allocated and written.limits: Limits retained for subsequent section additions and finalization.
Raises.
StoreError:FORMATfor invalid metadata, orLIMITfor invalid limits or insufficient resources.
ContainerWriter.section¶
def section(mut self, tag: UInt32, data: List[UInt8], mut budget: Budget) raises StoreError
Append a permitted section after validating its order, size, and budget.
Arguments.
tag: A known tag allowed by this kind, greater than every previously added tag.data: The opaque payload to copy; the writer retains no reference to this list.budget: Charged the 12-byte section header plus its payload before any mutation.
Raises.
StoreError:FORMATfor an unknown, disallowed, duplicate, or out-of-order tag;LIMITfor size, count, or budget exhaustion.
ContainerWriter.finish¶
def finish(var self, mut budget: Budget) raises StoreError -> List[UInt8]
Consume the writer and return the envelope with its SHA-256 digest.
Arguments.
budget: Charged one step per body byte hashed and 32 for the digest before finalization.
Returns. The complete header, sections, and digest as owned bytes.
Raises.
StoreError:LIMITwhen the budget cannot pay for finalization.
ContainerReader¶
struct ContainerReader(Movable)
Own a validated envelope and expose immutable section spans tied to its lifetime.
Opening checks structure before the digest and copies the bytes only after both checks succeed. Payload interpretation belongs to later phases.
Defined in src/judgment_store/container.mojo.
ContainerReader.__init__¶
def __init__(out self, data: Span[UInt8, _], mut budget: Budget, limits: ContainerLimits = ContainerLimits()) raises StoreError
Validate an envelope and copy it into private storage, as open does.
Arguments.
data: The complete serialized envelope, including its digest.budget: Charged once per input byte before validation and again before copying on success.limits: Nonnegative byte, payload, and section-count limits.
Raises.
StoreError:FORMATwith an offset for malformed structure,VERSIONfor an incompatible termbank,DIGESTfor a bad checksum, orLIMITfor exhausted resources.
ContainerReader.open¶
@staticmethod
def open(data: Span[UInt8, _], mut budget: Budget, limits: ContainerLimits = ContainerLimits()) raises StoreError -> Self
Check structure and checksum, then return an owned validated container.
Arguments.
data: The complete serialized envelope.budget: Charged per byte for validation/hashing and again for the owned copy.limits: Maximum serialized length, individual payload size, and section count.
Returns. A reader independent of the source buffer's later changes or lifetime.
Raises.
StoreError:FORMAT,VERSION,DIGEST, orLIMITas described by the constructor.
ContainerReader.format_version¶
def format_version(self) -> UInt32
Read the validated envelope version.
Returns. Two, the supported envelope version.
ContainerReader.kind¶
def kind(self) -> UInt8
Read the envelope kind.
Returns. Four for a library manifest or six for a proof-DAG partition.
ContainerReader.kernel_commit¶
def kernel_commit(self) -> String
Read the informational kernel revision without comparing it to the current kernel.
Returns. The 40 validated hexadecimal digits exactly as recorded.
ContainerReader.section_count¶
def section_count(self) -> Int
Read the number of sections.
Returns. The validated section count.
ContainerReader.has_section¶
def has_section(self, tag: UInt32) -> Bool
Check whether a permitted section occurs in this envelope.
Arguments.
tag: The section tag to look up.
Returns. True if the tag is present; false for absent, unknown, or disallowed tags.
ContainerReader.section¶
def section(self, tag: UInt32) raises StoreError -> Span[UInt8, origin_of(self._data[0])]
Borrow a section's immutable payload from this reader's owned bytes.
Arguments.
tag: The section to read.
Returns. A read-only span that cannot outlive the reader, including a valid empty span for an empty payload.
Raises.
StoreError:FORMATwithout a byte offset when the requested section is absent or invalid.
Identities¶
Identity holds 32 digest bytes, prints 64 hexadecimal digits, and
Identity.from_hex parses them. Reference pairs a declaration's identity
with part zero for the declaration itself or the part number defined by
Definition I-1. identity
hashes a serialized declaration and core_identity a core declaration's
name, in separate version-one domains. A digest is a content key, not
validation evidence, and the non-raising hash primitives require callers to
budget their hashing work. See
ST1.4 for the
byte layouts.
Identity¶
Mojo
@fieldwise_init
struct Identity(Equatable, Hashable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
bytes |
Array[UInt8, 32] |
The SHA-256 digest in its original byte order. |
Python
from judgment import Identity
Python constructor:
def __init__(self, bytes)
| Field | Description |
|---|---|
bytes |
The SHA-256 digest in its original byte order. |
Requires the Python core built with Store support.
A 32-byte content key, never evidence that a declaration was checked.
Defined in src/judgment_store/_identity_types.mojo.
Identity.__init__¶
Mojo
def __init__(out self, *, copy: Self)
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Copy the fixed-size key.
Arguments.
copy: The key to copy.
Identity.from_hex¶
Mojo
@staticmethod
def from_hex(text: String) raises StoreError -> Identity
Python
@staticmethod
def from_hex(text)
Requires the Python core built with Store support.
Parse the 64 hexadecimal digits an identity is written as.
This is the inverse of writing an identity: a manifest name, a
CURRENT file's digits, or the hexadecimal part of a canonical
provider name judgment.stmt.<hex>.
Arguments.
text: Exactly 64 hexadecimal digits, in either case.
Returns. The identity whose bytes they denote.
Raises.
StoreError:FORMATfor any other text.
Identity.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write 64 lowercase hexadecimal digits.
Arguments.
writer: The destination.
Reference¶
Mojo
@fieldwise_init
struct Reference(Equatable, Hashable, ImplicitlyCopyable, Writable)
| Field | Type | Description |
|---|---|---|
identity |
Identity |
The containing block's content key. |
part |
UInt32 |
Zero for the block, or the specified one-based part number. |
Python
from judgment import Reference
Python constructor:
def __init__(self, identity, part)
| Field | Description |
|---|---|
identity |
The containing block's content key. |
part |
Zero for the block, or the specified one-based part number. |
Requires the Python core built with Store support.
Name a declaration block or one of its derived parts (Definition I-1).
Defined in src/judgment_store/_identity_types.mojo.
Reference.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write the identity followed by its part number.
Arguments.
writer: The destination.
identity¶
def identity(serialized: Span[UInt8, _]) -> Identity
Hash declaration bytes with the version-one declaration domain.
Arguments.
serialized: Canonical declaration bytes; callers budget this linear work.
Returns. SHA-256 of judgment/decl/1, a zero byte, and the serialization.
Defined in src/judgment_store/_identity_types.mojo.
core_identity¶
def core_identity(name: String) -> Identity
Hash a logic-core name with the version-one core domain.
Arguments.
name: The fully qualified core declaration name, encoded as UTF-8.
Returns. SHA-256 of judgment/core/1, a zero byte, and the name.
Defined in src/judgment_store/_identity_types.mojo.
Proof libraries¶
A proof library is a versioned directory of proof-DAG partitions (ST7, ST9, Proof libraries). The proof library guides explain the model and show each operation in a program you can run.
The theorem database¶
Library.create publishes a library's first version over a profile.
Library.open reads one version from its manifest alone, without reading
partition files or proof rows (ST7.3).
It reads library format 2.2 only, and refuses a library of another format
with VERSION.
theorems and categories list the statements the version provides and
its catalogue, find looks one up by name or by statement identity, and
dependents lists the statements whose providers cite it, by record or by
proof (Definition L-4), from the manifest's declaration index.
Copies of a Library and its pending changes share the immutable catalog and
lookup indexes for that version. They remain valid when another version is
published. A failed rebase keeps the change's original catalog and base.
Library.snapshot loads the opened version whole into a fresh bank and
rechecks it, as the snapshot a proof session opens over: its theorems are
the session's own, imported by any name find takes, and a theorem proved
from them is exported for the next version. Library.recheck checks the
version whole and reports what it verified, the same at any worker count
(guide: re-checking).
Library.profile_snapshot seals the version's profile alone, built and
checked in a fresh bank under the caller's budget, for a session that then
imports the library's theorems statement-only. A session over either snapshot
classifies the profile's axioms PROFILE_AXIOM. A Library is a
TheoremSource: a session imports its theorems statement-only (ST9.8),
trusting the version's producer for them.
Library.change starts a pending change over the opened version: articles
or session theorems to add, theorems whose proofs to replace, and
statements to withdraw, or a whole sealed snapshot to add
(add_snapshot). LibraryChange.publish writes it as the next
version, atomically, and is refused with CONFLICT when another version was
published since; rebase moves the change onto the current version. Guide:
changing a library.
Library¶
Mojo
struct Library(Copyable, Movable, TheoremSource)
| Field | Type | Description |
|---|---|---|
path |
String |
The library directory. |
current |
Identity |
The version's manifest hash. |
Python
from judgment import Library
Requires the Python core built with Store support.
A proof-DAG library's version, read from its manifest: its statements, their names and dependencies.
It is a TheoremSource: a session imports its theorems statement-only, from the version it was opened at
(ST9.8). The library's producer is then in the session's trusted base for the statements imported.
Copies and pending changes share this version's immutable catalog; later publications do not change it.
Defined in src/judgment_store/theorem_library.mojo.
Library.__init__¶
Mojo
def __init__(out self, var path: String, current: Identity, var manifest: _Manifest)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Wrap a decoded manifest; open reads and checks one.
Arguments.
path: The library directory.current: The manifest's hash.manifest: The decoded manifest.
Library.open¶
Mojo
@staticmethod
def open(path: String, version: Optional[Identity] = None) raises StoreError -> Library
Python
@staticmethod
def open(path, version=None)
Requires the Python core built with Store support.
Open a library's version from its manifest; no partition file is read.
Arguments.
path: The library directory.version: A manifest hash,CURRENTor an ancestor of it; none forCURRENT.
Returns. The library at that version.
Raises.
StoreError:FORMATfor a missingCURRENT, a malformed manifest or one that is not a proof-DAG library's (format 2.2);VERSIONfor another library format;DIGESTfor a manifest whose hash differs;MISSING_DEPENDENCYfor an absent manifest;LIMITfor an oversized manifest;IO.
Library.open_io¶
Mojo
@staticmethod
def open_io(path: String, version: Optional[Identity] = None) -> IO[Library, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer opening a manifest until the returned IO runs.
Arguments.
path: The library directory, copied into the action.version: A pinned version, or absent to select CURRENT at execution.
Returns. An owned IO with the same result and errors as open.
Library.create¶
Mojo
@staticmethod
def create(path: String, profile: String) raises StoreError -> Library
Python
@staticmethod
def create(path, profile)
Requires the Python core built with Store support.
Publish a new library's first version, over a profile and with no theorem of its own.
Its theorems come with later versions: change().add_article and
change().add.
Arguments.
path: The library directory; created (one level) if absent.profile:none(the logic core alone),classicalorisabelle.
Returns. The library at its first version.
Raises.
StoreError:LIBRARYfor an unknown profile;CONFLICTwhen the directory already holds a library;LOCKED,IO.
Library.create_io¶
Mojo
@staticmethod
def create_io(path: String, profile: String) -> IO[Library, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer creating and publishing an empty library.
Arguments.
path: The destination directory.profile:none,classicalorisabelle.
Returns. An owned IO with the same result and errors as create.
Library.version¶
Mojo
def version(self) -> Identity
Python
def version(self)
Requires the Python core built with Store support.
The version this library was opened at.
Returns. Its manifest hash.
Library.is_current¶
Mojo
def is_current(self) raises StoreError -> Bool
Python
def is_current(self)
Requires the Python core built with Store support.
Whether the library's CURRENT still names this version.
Returns. False when a later version was published since open.
Raises.
StoreError:FORMATorIOfrom readingCURRENT.
Library.is_current_io¶
Mojo
def is_current_io(self) -> IO[Bool, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer comparing the pinned version with CURRENT.
Returns. An IO producing the comparison, or the read's StoreError.
Library.theorems¶
Mojo
def theorems(self, under: String = "") -> List[TheoremInfo]
Python
def theorems(self, under='')
Requires the Python core built with Store support.
The statements the version provides, in the manifest's order (section 3: by statement identity).
Arguments.
under: A category, a dotted name such ashol_probability.martingale: only the theorems whose names lie below it. Empty for every statement.
Returns. One entry per statement.
Library.categories¶
Mojo
def categories(self, under: String = "") -> List[String]
Python
def categories(self, under='')
Requires the Python core built with Store support.
The catalogue: the categories directly below a category, from the theorems' dotted names.
A theorem a.b.c lies in category a.b, which lies in a. So
categories() gives a and categories(under="a") gives b; the
last component, the theorem's own, is not a category.
Arguments.
under: A category, or empty for the top level.
Returns. The distinct next components, in byte order.
Library.find¶
Mojo
def find(self, key: String) -> Optional[TheoremInfo]
Python
def find(self, key)
Requires the Python core built with Store support.
Look a statement up by its statement identity (64 hexadecimal digits) or by name.
A canonical name judgment.stmt.<sid> names its statement; another name is matched against the aliases
first, then against the providers' declaration names.
Arguments.
key: A statement identity or a name.
Returns. The statement's entry, or None when the version provides no such statement.
Library.dependents¶
Mojo
def dependents(self, key: String) raises StoreError -> List[TheoremInfo]
Python
def dependents(self, key)
Requires the Python core built with Store support.
The statements whose providers cite a statement's provider directly, by their records or by their current proofs (section 7, Definition L-4).
A record citation is statement-level: a statement that mentions the provider's constant or cites its declaration. A proof citation is a use of the provider in the provider's current proof; a replaced proof's rows do not count (I4b).
Arguments.
key: A statement identity or a name, as forfind.
Returns. The dependents' entries, in the manifest's order.
Raises.
StoreError:MISSING_DEPENDENCYwhen the version provides no such statement.
Library.snapshot¶
Mojo
def snapshot(self, mut budget: Budget, workers: Int = 1) raises StoreError -> Snapshot
Python
def snapshot(self, budget, workers=1)
Requires the Python core built with Store support.
This version loaded in full and rechecked, as a snapshot a session opens over (Session.open).
A fresh bank gets the logic core and the library's profile, as the writer's bank did, then every partition of
the version, each row checked (Algorithm L-5 for format 2.2); the snapshot owns that bank. The profile's extent
is the one installed here. No file of the library is written. Unlike a statement-only import (declare), the
snapshot holds the library's proofs, and its theorems are the session's own declarations: import_fact takes a
theorem's library name (section 4), which names its declaration before any declaration name does, or its
declaration's name. They are also the session's imports from this version, by identity: a theorem proved from
them is exported citing them (Session.export) and added to a later version (change().add), as one
proved over a statement-only import is. The profile's axioms, the classical principles, are the snapshot's
profile axioms: a session over it classifies them PROFILE_AXIOM.
Arguments.
budget: Charged for the load.workers: Parallel check workers.
Returns. The snapshot.
Raises.
StoreError: The load's kind:FORMAT,DIGEST,IOfor a version or partition that is missing or malformed,LIBRARYfor a row the recheck refuses,LIMIT;KERNELfor a bank the snapshot refuses.
Library.snapshot_io¶
Mojo
def snapshot_io(self, steps: UInt64 = UInt64.MAX, workers: Int = 1) -> IO[Snapshot, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer snapshot with an owned work allowance and pinned manifest.
Arguments.
steps: Maximum work steps for this action.workers: Parallel check workers.
Returns. An IO with snapshot's result and typed errors. The action retains no caller budget or mutable session.
Library.profile_snapshot¶
Mojo
def profile_snapshot(self, mut budget: Budget) raises StoreError -> Snapshot
Python
def profile_snapshot(self, budget)
Requires the Python core built with Store support.
The library's profile alone, sealed as a snapshot a session opens over (Session.open).
A fresh bank gets the logic core and the profile this version's manifest names (none, classical or
isabelle), built by the same builders as snapshot's load, its theories decided and every row checked; no
partition is read. The snapshot holds no declaration of the library's own, so a session over it imports the
library's theorems statement-only (Session.import_theorems), and their statement identities line up
with this library's. The profile's axioms, the classical principles, are the snapshot's profile axioms: a
session over it classifies them PROFILE_AXIOM. No file of the library is written.
The work is charged to budget (G3): building the profile, in proportion to its declarations, which are fixed
by the profile. On a failure nothing of the library or of the caller changes (G9); the fresh bank is dropped.
Arguments.
budget: Charged for building the profile.
Returns. The snapshot, with the profile's marker.
Raises.
StoreError:LIMITwhen the budget runs out;LIBRARYfor an unknown profile or a profile row the check refuses;KERNELfor a bank the snapshot refuses. The captured manifest identifies the profile: this operation does not reread the library path.
Library.profile_snapshot_io¶
Mojo
def profile_snapshot_io(self, steps: UInt64 = UInt64.MAX) -> IO[Snapshot, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer profile_snapshot with an owned work allowance and pinned manifest.
Arguments.
steps: Maximum work steps for this action.
Returns. An IO with profile_snapshot's result and typed errors. The action retains no caller budget or mutable session.
Library.recheck¶
Mojo
def recheck(self, mut budget: Budget, workers: Int = 1) raises StoreError -> LibraryRecheck
Python
def recheck(self, budget, workers=1)
Requires the Python core built with Store support.
Recheck this version whole (Algorithm L-5 for format 2.2): load it into a fresh bank and check every row.
The fresh bank gets the logic core and the library's profile, then every partition, as snapshot loads it;
every row is checked, the theory pass decides every theory, and the load compares each partition's sections
with what it loaded. The report does not depend on workers: a version gives the same report at any count.
No file of the library is written.
Arguments.
budget: Charged for the load.workers: Parallel check workers.
Returns. What the recheck verified.
Raises.
StoreError: The load's kind:FORMAT,DIGEST,IOfor a version or partition that is missing or malformed,LIBRARYfor a row the recheck refuses,LIMIT;KERNELotherwise.
Library.recheck_io¶
Mojo
def recheck_io(self, steps: UInt64 = UInt64.MAX, workers: Int = 1) -> IO[LibraryRecheck, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer recheck with an owned work allowance and pinned manifest.
Arguments.
steps: Maximum work steps for this action.workers: Parallel check workers.
Returns. An IO with recheck's result and typed errors. The action retains no caller budget or mutable session.
Library.change¶
Mojo
def change(self) -> LibraryChange
Python
def change(self)
Requires the Python core built with Store support.
Start a pending change sharing this version's catalog: nothing is written until LibraryChange.publish.
Returns. An empty change whose base is version().
Library.resolve¶
Mojo
def resolve(self, names: List[String], mut budget: Budget) raises LibError -> List[TheoremIdentity]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Name the statements of theorems, for a session's import: each name as find takes it.
Arguments.
names: Theorem names, canonical names or statement identities.budget: Charged.
Returns. Each name's statement identity, in order.
Raises.
LibError: NO_MATCH for an unavailable name; LIMIT for exhausted work.
Library.declare¶
Mojo
def declare(self, wanted: List[TheoremIdentity], mut w: DagWriter, base: ImportBase, mut budget: Budget) raises LibError -> ImportedLayer
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Declare the wanted statements' providers' closure and the class layer into a session's workspace.
The declarations come from this version's partitions (section 2 only), each one's bytes checked against
the identity the index lists; a Proven is declared as its Axiom stand-in. Declarations an earlier
import of the session holds are not declared again.
Arguments.
wanted: Statement identities, fromresolve.w: The workspace's writer.base: What the workspace holds.budget: Charged.
Returns. The layer written; the session decides and checks it.
Raises.
LibError: LIMIT for exhausted work; KERNEL for a refused statement-only import, retaining the Store category and optional byte offset in its diagnostic.
LibraryChange¶
Mojo
struct LibraryChange(Movable)
| Field | Type | Description |
|---|---|---|
library |
Library |
The base version, as opened. |
articles |
List[String] |
Each article to add, in order. |
sources |
List[String] |
Each article's axiom provenance, PROVER|RELEASE|SESSION|THEORY (convert_dag --source), or empty. |
exports |
List[TheoremExport] |
Each session theorem to add, in order. |
withdrawals |
List[Identity] |
The statements to withdraw. |
replaces |
List[Identity] |
The theorems whose proofs replace replaces, by statement identity. |
replaced_by |
List[Int] |
For each of replaces, the position in exports of the export that replaces its proof. |
published |
Optional[Identity] |
The version publish wrote; None while pending. |
snapshot |
Optional[ArcPointer[_SnapshotBank]] |
The snapshot add_snapshot transcribed and checked, ready to write; None when the change adds none. |
snapshot_rows |
Optional[SnapshotRows] |
That snapshot's rows, read again by rebase. |
snapshot_source |
String |
That snapshot's axiom provenance. |
Python
from judgment import LibraryChange
Requires the Python core built with Store support.
A pending change to a library: articles and session theorems to add, proofs to replace, statements to withdraw.
publish writes it as the version after its base, atomically: CURRENT
changes only once the whole version is installed. A change holds either
articles or exports, not both; withdrawals go with either. A change that
adds a snapshot (add_snapshot) holds nothing else.
Defined in src/judgment_store/theorem_library.mojo.
LibraryChange.__init__¶
Mojo
def __init__(out self, var library: Library)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
An empty change over a version; Library.change makes one.
Arguments.
library: The base version.
LibraryChange.base¶
Mojo
def base(self) -> Identity
Python
def base(self)
Requires the Python core built with Store support.
The version the change extends.
Returns. Its manifest hash.
LibraryChange.add_snapshot¶
Mojo
def add_snapshot(mut self, snapshot: Snapshot, source: String, mut budget: Budget) raises StoreError
Python
def add_snapshot(self, snapshot, source, budget)
Requires the Python core built with Store support.
Add every declaration of a sealed snapshot past the core and the library's profile, in commit order.
The snapshot's rows are read through judgment_shell.snapshot_rows
(an immutable view of its verified prefix) and transcribed now into a
fresh bank over the base: each declaration rebuilt from its ST1.4
bytes and every other row committed by its key, as a load commits a
partition. The theory pass and the row checks then run over every
row, so nothing of the snapshot is trusted; every later load
(snapshot, recheck) checks every row again. publish writes the
declarations as the version after the base; the same snapshot gives
the same version. As in any library, each axiom and theorem is written
under its statement's canonical name, and its own name becomes an
alias: as it is when it is a theorem name (valid_theorem_name),
else normalized (normalized_theorem_name), so that find and
Session.import_fact over snapshot take it. Other declarations
keep their names.
Each own axiom's section-4 provenance is its dependency class in the
snapshot (PROFILE_AXIOM for an axiom the snapshot's maker declared
with profile_axiom, UNCLASSIFIED otherwise) and source. A label
is not evidence, so a load does not restore the class: in a session
over snapshot, the snapshot's axioms past the library's profile,
Scalar's G1–G7 among them, are ordinary library axioms, not
PROFILE_AXIOM (Definition E-1). Their statements, and every
theorem's axioms, are unchanged; only the label differs.
The work is charged to budget (G3). On any refusal the change, the
library's files and CURRENT are unchanged, and so is budget (G9).
Arguments.
snapshot: A sealed snapshot over the library's profile (nonefor one built over the logic core, such asscalar.build_scalar's), holding no library version's declarations.source: The provenance of its axioms past the profile; required when it has any.budget: Charged for the transcription and its checks.
Raises.
StoreError:LIBRARYonce published, for a snapshot over another profile, one holding a library version's declarations (Library.snapshot), one with nothing past the profile, a base version that has declarations of its own, an axiom withoutsource, or a row or declaration the encoding refuses;CONFLICTwhen the change already holds anything;KERNELwhen the kernel refuses a row;LIMITwhenbudgetruns out.
LibraryChange.add_snapshot_io¶
Mojo
def add_snapshot_io(deinit self, snapshot: Snapshot, source: String, steps: UInt64 = UInt64.MAX) -> IO[LibraryChangeResult, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer transcription, retaining the change and remaining allowance on failure.
Arguments.
snapshot: Its immutable row view is captured now; no mutable snapshot writer enters the IO.source: The axiom provenance.steps: Maximum work steps for transcription and checking.
Returns. An IO returning the pending change, remaining steps, and its base version or StoreError.
LibraryChange.add_article¶
Mojo
def add_article(mut self, path: String, source: String = "") raises StoreError
Python
def add_article(self, path, source='')
Requires the Python core built with Store support.
Add an OpenTheory article: its declarations are converted over the base as convert_dag --base does.
Arguments.
path: The article file.source: Its axioms' provenance,PROVER|RELEASE|SESSION|THEORY; empty for none (an axiom without one is refused at publication).
Raises.
StoreError:LIBRARYonce published, or when the change holds exports.
LibraryChange.add¶
Mojo
def add(mut self, var export: TheoremExport) raises StoreError
Python
def add(self, export)
Requires the Python core built with Store support.
Add a session theorem (Session.export): its rows are replayed and checked at publication.
Its name becomes an alias of its statement (section 4), so find
takes it once the change is published. A name that already names
another statement in the version refuses the publication with
CONFLICT; the same name for the same statement is kept once. A
name is dot-separated snake_case (valid_theorem_name); a canonical
name judgment.stmt.<sid> is taken too, and adds no alias.
A statement that the version, the profile or an earlier export of the change already provides is not declared again (Rule L1): the export's proof is checked but not kept as the statement's proof, and its name aliases the existing provider's statement. When that provider is an axiom, the name's dependencies are the axiom's.
Arguments.
export: The theorem with its proof over its imports.
Raises.
StoreError:LIBRARYonce published, or when the change holds articles;MISSING_DEPENDENCYwhen it cites a declaration the base does not hold (by the declaration index);LIBRARYfor a name that is not a theorem name.
LibraryChange.replace¶
Mojo
def replace(mut self, name: String, var export: TheoremExport) raises StoreError
Python
def replace(self, name, export)
Requires the Python core built with Store support.
Replace a theorem's proof by a session theorem's (I4b, Rule L1 as amended).
The theorem keeps its statement, its declaration identity and its name; its new proof is replayed and checked at publication. The old proof's rows stay in their partition, but no longer count as citations, so a lemma only the old proof used can then be withdrawn.
Arguments.
name: The theorem: a statement identity or a name, as forLibrary.find.export: Its new proof, concluding the same statement.
Raises.
StoreError:MISSING_DEPENDENCYfor no such statement, or a proof citing a declaration the base does not hold;LIBRARYonce published, when the change holds articles, for a statement that is not a theorem or that the change already replaces or withdraws, or for a name that is not a theorem name. At publication,LIBRARYwhen the export proves another statement, or when its proof cites the theorem or a declaration that depends on it (Definition L-4).
LibraryChange.withdraw¶
Mojo
def withdraw(mut self, key: String) raises StoreError
Python
def withdraw(self, key)
Requires the Python core built with Store support.
Withdraw a statement (Rule L1).
Refused (LIBRARY) while any declaration of the version cites the
statement's provider, by its record or by its current proof
(section 7, Definition L-4; Library.dependents). A section-3 reuse
count can be positive for a statement that can be withdrawn, since it
also counts the rows of replaced proofs.
Arguments.
key: A statement identity or a name, as forLibrary.find.
Raises.
StoreError:MISSING_DEPENDENCYfor no such statement;LIBRARYonce published, for a profile statement, or while a declaration not withdrawn by this change cites it.
LibraryChange.publish¶
Mojo
def publish(mut self) raises StoreError -> Identity
Python
def publish(self)
Requires the Python core built with Store support.
Write the change as the version after its base and make it CURRENT, atomically.
A change that adds a snapshot writes its transcribed, checked declarations as one detached addition.
Returns. The new version's manifest hash.
Raises.
StoreError:CONFLICTwhen the base is no longerCURRENT(rebase, then publish again) or a session theorem's name names another statement or is a provider's declaration name, before anything is written;LIBRARYfor a session theorem over another profile than the library's;KERNELwhen an article is refused;REPLAYwhen a session theorem does not replay or a row of it is refused;LIBRARYfor an empty change or once published; what the writer raises. On failure the base staysCURRENT.
LibraryChange.publish_io¶
Mojo
def publish_io(deinit self) -> IO[LibraryChangeResult, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer publication, transferring ownership of this pending change.
Returns. An IO returning the change and its publication result, including on conflict or refusal. Inspect result before reusing change. Canceling an unopened action drops its pending change; running blocking publication cannot be interrupted midway or rolled back by cancellation.
LibraryChange.rebase¶
Mojo
def rebase(mut self) raises StoreError
Python
def rebase(self)
Requires the Python core built with Store support.
Move the pending change onto the library's CURRENT version, checking it again there.
After a CONFLICT, the change's articles, theorems and withdrawals
are the same; its base becomes the current version, and each
withdrawal and each theorem's imports are checked against it. A
snapshot is transcribed and checked again over the new base, which
must have no declarations of its own.
Raises.
StoreError:LIBRARYonce published; whatLibrary.open,withdrawandaddraise against the new base. On failure the change keeps its old base.
LibraryChange.rebase_io¶
Mojo
def rebase_io(deinit self) -> IO[LibraryChangeResult, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer rebasing while retaining the pending change on domain failure.
Returns. An IO returning the updated change and its base version, or the unchanged change and a StoreError.
LibraryChangeResult¶
@fieldwise_init
struct LibraryChangeResult(Movable)
| Field | Type | Description |
|---|---|---|
change |
LibraryChange |
The pending or published change, available for inspection or retry after a conflict. |
result |
Result[Identity, StoreError] |
The published version, rebased version, or snapshot's base; otherwise the exact refusal. |
remaining |
UInt64 |
The operation's unspent work allowance. |
A completed change operation, retaining its pending state even after a domain failure.
On a returned value completed, use completed.result.copy().raise_on_err()
to obtain the version or raise the original StoreError while retaining completed.change.
The synchronous adapters restore change and the work allowance before raising.
Defined in src/judgment_store/theorem_library.mojo.
LibraryChangeResult.into_change¶
def into_change(deinit self) -> LibraryChange
Recover ownership of the pending or published change.
Inspect result and remaining first; this discards the operation's
result without raising it. The returned change can enter another IO action.
Returns. The change retained by the completed operation, without copying it.
LibraryRecheck¶
Mojo
@fieldwise_init
struct LibraryRecheck(Copyable, Movable, Writable)
| Field | Type | Description |
|---|---|---|
version |
Identity |
The version's manifest hash. |
rows |
UInt64 |
The rows the fresh bank committed and verified: the core's, the profile's and the version's. |
declarations |
List[Identity] |
The version's declarations' identities, in load order. |
providers |
Int |
The statements the version's declarations provide. |
exports |
Int |
The theorems the version proves. |
Python
from judgment import LibraryRecheck
Python constructor:
def __init__(self, version, rows, declarations, providers, exports)
| Field | Description |
|---|---|
version |
The version's manifest hash. |
rows |
The rows the fresh bank committed and verified: the core's, the profile's and the version's. |
declarations |
The version's declarations' identities, in load order. |
providers |
The statements the version's declarations provide. |
exports |
The theorems the version proves. |
Requires the Python core built with Store support.
What a whole recheck of a library version verified (Library.recheck): the same at any worker count.
Defined in src/judgment_store/theorem_library.mojo.
LibraryRecheck.write_to¶
Mojo
def write_to(self, mut writer: Some[Writer])
Python
str(value)
Use str(value) or print(value) in Python.
Write the version, rows, declarations, providers and exports.
Arguments.
writer: The writer to write to.
TheoremInfo¶
Mojo
struct TheoremInfo(Copyable, Movable, Writable)
| Field | Type | Description |
|---|---|---|
name |
String |
Its alias, else its provider declaration's name, else its canonical name judgment.stmt.<sid>. |
sid |
Identity |
The statement identity (Definition I-6). |
kind |
String |
theorem, axiom, definitional or profile. |
partition |
Int |
The sub-partition that declares the provider; -1 for a profile statement. |
provider |
Reference |
The provider's declaration identity and part. |
citations |
List[Identity] |
The library declarations the provider's record cites (statement-level dependencies, section 7). |
Python
from judgment import TheoremInfo
Python constructor:
def __init__(self, name, sid, kind, partition, provider, citations)
| Field | Description |
|---|---|
name |
Its alias, else its provider declaration's name, else its canonical name judgment.stmt.<sid>. |
sid |
The statement identity (Definition I-6). |
kind |
theorem, axiom, definitional or profile. |
partition |
The sub-partition that declares the provider; -1 for a profile statement. |
provider |
The provider's declaration identity and part. |
citations |
The library declarations the provider's record cites (statement-level dependencies, section 7). |
Requires the Python core built with Store support.
One statement a library version provides, as its manifest records it.
Defined in src/judgment_store/theorem_library.mojo.
TheoremInfo.__init__¶
Mojo
def __init__(out self, var name: String, sid: Identity, var kind: String, partition: Int, provider: Reference, var citations: List[Identity])
Python
Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.
Make a statement's entry.
Arguments.
name: Its name.sid: Its statement identity.kind: Its kind.partition: Its provider's sub-partition, or -1.provider: Its provider's declaration identity and part.citations: The declarations its provider's record cites.
TheoremInfo.write_to¶
Mojo
def write_to[W: Writer](self, mut writer: W)
Python
str(value)
Use str(value) or print(value) in Python.
Write the entry as name kind sid.
Parameters.
W: The writer's type.
Arguments.
writer: The writer.
Theorem names¶
A theorem name is a dotted name of snake_case components whose first
component is not judgment (Definition L-3a). normalized_theorem_name
turns a source's long name into its theorem name (Definition L-3b), as a
conversion names the theorems it adds.
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.
normalized_theorem_name¶
def normalized_theorem_name(long: String) -> Optional[String]
A source's long name as a theorem name (Definition L-3b), as a library names a theorem converted from it.
Each .-separated component is normalized (- to _, word boundaries to _, lowercase, a prime to _prime),
such as Judgment_Mathlib.Judgment_Mathlib.scalar_x82_G1 to judgment_mathlib.judgment_mathlib.scalar_x82_g1.
Arguments.
long: The long name.
Returns. The theorem name, or None when a component has no normalized form or the result is not a theorem name.
Defined in src/judgment_store/theorem_library.mojo.
OpenTheory articles¶
Article.open checks an OpenTheory article (version 6) into a private
temporary library and serves its theorems to a session as a TheoremSource;
Article.write and write_article write session theorems as one, verified
by reading it back. LibraryChange.add_article adds an article to a
library. Guides: importing articles and
changing a library.
Article¶
Mojo
struct Article(Movable, TheoremSource)
| Field | Type | Description |
|---|---|---|
library |
Library |
The article's temporary library, at its one version. |
directory |
String |
The temporary directory that holds it, removed with the value. |
Python
from judgment import Article
Requires the Python core built with Store support.
An OpenTheory article (version 6), checked, as a source of theorems for a session.
open checks every row of the file and keeps the result in a private
temporary library; resolve and declare import its theorems
statement-only, as from a Library. The article's own axioms are
imported like any library's, with the provenance open was given.
A theorem proved from an article's theorem cites the temporary
library's declaration, by identity and version: publishing it to a
library (Library.change().add) needs the article added to that library
first (add_article), which gives the same declaration identities.
Defined in src/judgment_store/article_source.mojo.
Article.__init__¶
Mojo
def __init__(out self, var library: Library, var directory: String)
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Take a converted article's library; open makes one.
Arguments.
library: The article's library.directory: The temporary directory to remove with the value.
Article.open¶
Mojo
@staticmethod
def open(path: String, profile: String = "none", source: String = "", scratch: String = "") raises StoreError -> Article
Python
@staticmethod
def open(path, profile='none', source='', scratch='')
Requires the Python core built with Store support.
Check an article and hold its theorems for import.
Arguments.
path: The article file.profile: The profile it is read over, asLibrary.createnames them:none,classicalorisabelle; a session imports from it only over the same profile.source: The provenance of the article's axioms,PROVER|RELEASE|SESSION|THEORY; empty for none, and then an article with an axiom of its own is refused.scratch: The directory to make the temporary library in; empty for the system's temporary directory.
Returns. The article.
Raises.
StoreError:KERNELwhen a row of the article is refused;LIBRARYfor an unknown profile, an axiom without provenance, or an article the converter does not read;IO. Nothing is left inscratch.
Article.open_io¶
Mojo
@staticmethod
def open_io(path: String, profile: String = "none", source: String = "", scratch: String = "") -> IO[Article, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Defer checking an article and acquiring its temporary library.
Arguments.
path: The input file.profile: The profile used to check it.source: The provenance of its own axioms.scratch: The parent of its exclusive temporary directory.
Returns. An IO owning its inputs. The returned Article owns cleanup; use resource to bind cleanup to an IO scope.
Article.resource¶
Mojo
@staticmethod
def resource(path: String, profile: String = "none", source: String = "", scratch: String = "") -> Resource[Article, StoreError]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Acquire and remove a checked article's temporary files within an fp IO resource scope.
Arguments.
path: The input file.profile: The profile used to check it.source: The provenance of its own axioms.scratch: The parent of its exclusive temporary directory.
Returns. A deferred resource. use releases its files after success, failure, or cancellation, after workers join.
Article.write¶
Mojo
@staticmethod
def write(path: String, exports: List[TheoremExport], mut budget: Budget, library: String = "", profile: String = "none", verify: Bool = True, scratch: String = "") raises StoreError
Python
@staticmethod
def write(path, exports, budget, library='', profile='none', verify=True, scratch='')
Requires the Python core built with Store support.
Write session theorems as an OpenTheory article (version 6).
The synchronous adapter copies the borrowed export data into an owned IO action.
Use write_article_io to transfer that data without a copy.
Each theorem's proof rows are replayed and checked (as Library.change().add does), then written as
OpenTheory commands: the sequent rules as the primitives of the same names, the declarations a proof cites
(imported theorems, the profile's and the core's) as axioms of their statements, and each theorem as a
thm. The same theorems give the same bytes.
The writer is not trusted. With verify (the default), the file is read back through the checking
converter (Article.open) before it is written, and must provide each theorem as a theorem with its
statement identity, and as axioms exactly the statements of the theorems' imports: a writer that dropped a
step or added an assumption is refused, and no file is written.
Natural-deduction rows are written over the classical profile, as instances of schemas the article proves
once from the profile's definitions of the connectives; over none a row that needs a schema is refused.
A definition's, a specification's or a type definition's fact that a proof uses is an axiom, as an
import's statement is. The natural-deduction use, of_class and unconstrain, ofClass, the
witnesses of instances and class relations, a class, a class predicate's definition and sorted type
variables have no version-6 form here and are refused.
Arguments.
path: The article to write.exports: The theorems (Session.export).budget: Charged one step per command written.library: The library the theorems' imports come from, at its current version; empty when they have none.profile:noneorclassical;isabelleis refused (no OpenTheory form).verify: Read the article back and check it before writing it.scratch: Where the read-back's temporary library goes; empty for the system's temporary directory.
Raises.
StoreError:LIBRARYfor a construct with no version-6 form, an Isabelle profile, or an article whose read-back does not provide exactly the theorems and assumptions;REPLAYwhen a theorem does not replay;LIMIT;IO. No file is left atpath.
Article.theorems¶
Mojo
def theorems(self) -> List[TheoremInfo]
Python
def theorems(self)
Requires the Python core built with Store support.
The article's theorems and axioms, as its temporary library lists them.
Returns. One entry per statement.
Article.resolve¶
Mojo
def resolve(self, names: List[String], mut budget: Budget) raises LibError -> List[TheoremIdentity]
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Name the statements of theorems: by statement identity or canonical name, as Library.resolve.
Arguments.
names: Statement identities or canonical names.budget: Charged.
Returns. Each name's statement identity, in order.
Raises.
LibError: For a statement the article does not provide.
Article.declare¶
Mojo
def declare(self, wanted: List[TheoremIdentity], mut w: DagWriter, base: ImportBase, mut budget: Budget) raises LibError -> ImportedLayer
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Declare the wanted statements' providers into a session's workspace, as Library.declare.
Arguments.
wanted: Statement identities, fromresolve.w: The workspace's writer.base: What the workspace holds.budget: Charged.
Returns. The layer written.
Raises.
LibError: AsLibrary.declare.
write_article¶
def write_article(path: String, exports: List[TheoremExport], mut budget: Budget, library: String = "", profile: String = "none", verify: Bool = True, scratch: String = "") raises StoreError
Write session theorems as an OpenTheory article: Article.write.
This synchronous adapter copies its borrowed exports into an owned IO action.
write_article_io consumes them without that copy.
Arguments.
path: The article to write.exports: The theorems (Session.export).budget: Charged one step per command written.library: The library the theorems' imports come from, at its current version; empty when they have none.profile:noneorclassical;isabelleis refused (no OpenTheory form).verify: Read the article back and check it before writing it.scratch: Where the read-back's temporary library goes; empty for the system's temporary directory.
Raises.
StoreError: AsArticle.write.
Defined in src/judgment_store/article_source.mojo.
write_article_io¶
def write_article_io(path: String, var exports: List[TheoremExport], steps: UInt64 = UInt64.MAX, library: String = "", profile: String = "none", verify: Bool = True, scratch: String = "") -> IO[NoneType, StoreError]
Defer encoding, optional read-back, and atomic article publication.
Arguments.
path: The output file.exports: Proof exports transferred into the action, without copying their DAG rows.steps: Maximum work steps for writing.library: The imports' library, if any.profile:noneorclassical.verify: Check the encoded article before publication.scratch: The parent for temporary verification files.
Returns. An IO with the same errors as write_article. Construction and dropping an unopened action touch no files.
Defined in src/judgment_store/article_source.mojo.
Source names an external theorem's origin; ArticleLimits bounds an
article read, and ArticleInput and SeekableArticleInput are the bounded
inputs of the article reader (ST6).
Source¶
@fieldwise_init
struct Source(Copyable)
| Field | Type | Description |
|---|---|---|
prover |
String |
The originating prover or interchange system. |
release |
String |
Its release or package version. |
session |
String |
The source session or package collection. |
theory |
String |
The source theory or package. |
theorem |
String |
The theorem identifier; standard article readers fill in its position. |
Identify an external theorem without treating its source as evidence.
Defined in src/judgment_store/sources.mojo.
ArticleLimits¶
struct ArticleLimits(ImplicitlyCopyable)
| Field | Type | Description |
|---|---|---|
bytes |
Int |
Maximum complete input length in bytes; defaults to 16 MiB. |
token_bytes |
Int |
Maximum token length in bytes; defaults to 1 MiB. |
objects |
Int |
Maximum size of each object table, including variables and theorems; defaults to one million. |
stack |
Int |
Maximum number of live stack entries; defaults to 65,536. |
dictionary |
Int |
Maximum number of live dictionary entries; defaults to 65,536. |
term_nodes |
Int |
Maximum nodes in semantic term traversals; defaults to one million. |
Bound article allocations independently of the shared work budget.
Defined in src/judgment_store/article_limits.mojo.
ArticleLimits.__init__¶
def __init__(out self, bytes: Int = 16777216, token_bytes: Int = 1048576, objects: Int = 1000000, stack: Int = 65536, dictionary: Int = 65536, term_nodes: Int = 1000000)
Configure bounds that the reader validates before processing input.
Arguments.
bytes: Nonnegative maximum input length.token_bytes: Nonnegative maximum token length.objects: Nonnegative maximum count per object table.stack: Nonnegative maximum live stack size.dictionary: Nonnegative maximum live dictionary size.term_nodes: Nonnegative maximum semantic term size.
ArticleInput¶
trait ArticleInput(Movable)
Supply owned, complete-line UTF-8 chunks under the importer's budget.
The importer reads two passes and compares their complete byte identities. Input implementations own their resources, charge input-dependent work, and return at most four MiB per chunk. They confer no proof authority.
Defined in src/judgment_store/article_input.mojo.
ArticleInput.reset¶
def reset(mut self, mut budget: Budget) raises StoreError
Rewind to the first byte, charging input work to budget.
Arguments.
budget: Allowance for validating and repositioning the source.
Raises.
StoreError: Unusable input, IO failure, or exhausted work.
ArticleInput.next¶
def next(mut self, mut budget: Budget) raises StoreError -> Optional[String]
Return a nonempty newline-terminated chunk, or None at EOF.
Arguments.
budget: Allowance for input-dependent read and copy work.
Returns. Owned complete-line UTF-8 bytes, or None at EOF.
Raises.
StoreError: Malformed input, IO failure, or exhausted resources.
ArticleInput.finish¶
def finish(mut self) raises StoreError
Release input resources before semantic publication.
Cleanup is idempotent and does not need remaining work allowance. A cleanup error on successful input makes the entire import fail. Resource-free inputs may use this default implementation.
Raises.
StoreError: An implementation could not release its resources.
SeekableArticleInput¶
trait SeekableArticleInput(ArticleInput)
Own an article source that can resume at a complete-line cursor.
Positioning confers neither content authentication nor proof authority. The caller must authenticate skipped input and reconstruct proof state.
Defined in src/judgment_store/article_input.mojo.
SeekableArticleInput.seek¶
def seek(mut self, offset: Int, mut budget: Budget) raises StoreError
Position at zero, EOF, or an interior offset immediately after LF.
Validate bounds and the pinned source before changing the cursor. Implementations retain ownership through any joined read-ahead cleanup. reset still rewinds to absolute zero. Closed/failed sources refuse; a failed seek closes the source, and finish remains idempotent.
Arguments.
offset: Global byte position at zero, EOF, or a complete-line cut.budget: Allowance for source and boundary validation.
Raises.
StoreError: Invalid position, unusable input, IO failure, or exhausted work.
Interpretations¶
An interpretation carries results of one judgment_shell session to
another over a common base snapshot (ST4.2,
Definition IN-1). prepare_interpretation checks a map of constants, type
constructors and literal kinds once; transport_term,
transport_scoped_term and transport_type translate syntax, which proves
nothing by itself; reuse translates a source theorem's derivation and
checks it in the target session, and reuse_eliminated and
reuse_batch_eliminated also eliminate ACU and rational conversions on the
way.
PreparedInterpretation¶
Mojo
struct PreparedInterpretation(Movable)
Python
from judgment import PreparedInterpretation
Requires the Python core built with Store support.
Validated IN-1 syntax mappings reusable inside the caller's owning transactions.
Construct with prepare_interpretation. Both endpoint transactions must
stay innermost, with unchanged signatures. A refusal requires the enclosing
operation to discard its transactions. Returned handles belong to the target
transaction, including results that reuse an older node; retain them at its
commit. No prepared state or unretained result survives scope closure.
The declaration-name index and image tables are prepared once. Types share a memo while the scopes remain valid; term memos are fresh for each operand and distinguish binder environments. This object creates no proof authority.
Defined in src/judgment_store/_dag_interpret_terms.mojo.
PreparedInterpretation.__init__¶
Mojo
def __init__(out self, scope: DagInterpretationScope, var types: _BaseTypes, var constants: Dict[UInt64, _ConstantImage], var literals: Dict[UInt32, DagDeclaration])
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Internal; the factory validates tables before moving them into this object.
PreparedInterpretation.type_¶
Mojo
def type_(mut self, source: _DagSession, target: _DagSession, base: Snapshot, kind: DagType, mut budget: Budget) raises LibError -> DagType
Python
def type_(self, source, target, base, kind, budget)
Requires the Python core built with Store support.
Translate another type using the checked mappings and the scope's type memo.
PreparedInterpretation.term¶
Mojo
def term(mut self, source: _DagSession, target: _DagSession, base: Snapshot, term: DagExpr, mut budget: Budget) raises LibError -> DagExpr
Python
def term(self, source, target, base, term, budget)
Requires the Python core built with Store support.
Translate a closed operand without rescanning the signature or revalidating image tables.
PreparedInterpretation.scoped_term¶
Mojo
def scoped_term(mut self, source: _DagSession, target: _DagSession, base: Snapshot, source_frame: DagFrame, target_frame: DagFrame, term: DagExpr, locals: List[Tuple[DagExpr, DagExpr]], mut budget: Budget) raises LibError -> DagExpr
Python
def scoped_term(self, source, target, base, source_frame, target_frame, term, locals, budget)
Requires the Python core built with Store support.
Translate an operand at checked existing frames with an operand-specific local mapping.
PreparedInterpretation.bind_literal¶
Mojo
def bind_literal(mut self, source: _DagSession, target: _DagSession, base: Snapshot, source_kind: DagDeclaration, target_kind: DagDeclaration, mut budget: Budget) raises LibError
Python
def bind_literal(self, source, target, base, source_kind, target_kind, budget)
Requires the Python core built with Store support.
Register a literal correspondence after the enclosing interpretation validates its conversion laws.
Both registrations must already exist in the fixed endpoint signatures, so no table is rebuilt.
PreparedInterpretation.bind_eliminated_rational¶
Mojo
def bind_eliminated_rational(mut self, source: _DagSession, target: _DagSession, base: Snapshot, source_kind: DagDeclaration, rat: DagEliminationRational, mut budget: Budget) raises LibError
Python
This overload is available only in Mojo; it is not exposed by the Python client.
Register an eliminated exact-rational literal kind whose atoms translate to plain target expressions.
TypeImage¶
Mojo
@fieldwise_init
struct TypeImage(Copyable, Movable)
| Field | Type | Description |
|---|---|---|
constructor |
DagTypeConstructor |
The checked source constructor. |
parameters |
List[DagType] |
Distinct unsorted target variables, in source argument order. |
body |
DagType |
The target type template. |
Python
from judgment import TypeImage
Python constructor:
def __init__(self, constructor, parameters, body)
| Field | Description |
|---|---|
constructor |
The checked source constructor. |
parameters |
Distinct unsorted target variables, in source argument order. |
body |
The target type template. |
Requires the Python core built with Store support.
An IN-1 constructor image with ordered designated target variables.
parameters has the source constructor's arity. The target body may repeat,
permute or omit them; it may not introduce another free type variable.
Defined in src/judgment_store/_dag_interpret_terms.mojo.
prepare_interpretation¶
def prepare_interpretation(source: _DagSession, target: _DagSession, base: Snapshot, constants: List[Tuple[DagExpr, DagExpr]], mut budget: Budget, type_images: List[DagTypeImage] = List[DagTypeImage](), literal_images: List[Tuple[DagDeclaration, DagDeclaration]] = List[Tuple[DagDeclaration, DagDeclaration]]()) raises LibError -> DagPreparedInterpretation
Prepare checked syntax mappings once for the enclosing Store operation.
The caller must have active transactions at both endpoints (one suffices for
a shared session), and owns their rollback on any refusal. Use term,
scoped_term and type_ before closing either scope. To retain results,
discard cross-session source readback before committing the target scope.
Defined in src/judgment_store/_dag_interpret_terms.mojo.
transport_term¶
def transport_term(source: _DagSession, target: _DagSession, base: Snapshot, term: DagExpr, constants: List[Tuple[DagExpr, DagExpr]], mut budget: Budget, type_images: List[DagTypeImage] = List[DagTypeImage](), literal_images: List[Tuple[DagDeclaration, DagDeclaration]] = List[Tuple[DagDeclaration, DagDeclaration]]()) raises LibError -> DagExpr
Translate closed IN-1 syntax across explicitly authenticated sessions and a common base.
Constant images are closed target terms of the translated type. Name a polymorphic source constant at distinct type variables and use their target translations in its image. Type images have ordered designated variables. Literal images name bindings whose conversion-law correspondence is checked by the interpretation owner; this call grants no proof authority.
Walks charge the caller's budget; checked construction also spends each session's allowance. Source readback is discarded and only the target result handle is retained. Failure publishes no declarations and discards both scopes. In one session a single target scope performs both roles.
Defined in src/judgment_store/_dag_interpret_terms.mojo.
transport_scoped_term¶
def transport_scoped_term(source: _DagSession, target: _DagSession, base: Snapshot, source_frame: DagFrame, target_frame: DagFrame, term: DagExpr, constants: List[Tuple[DagExpr, DagExpr]], locals: List[Tuple[DagExpr, DagExpr]], mut budget: Budget, type_images: List[DagTypeImage] = List[DagTypeImage](), literal_images: List[Tuple[DagDeclaration, DagDeclaration]] = List[Tuple[DagDeclaration, DagDeclaration]]()) raises LibError -> DagExpr
Translate IN-1 syntax under existing proof frames using checked fixed-local correspondences.
Both frames, every mapping and the result are owner/lifetime checked. Each local must belong to the supplied frame's ancestor chain and have the translated type; names are irrelevant. A missing local is refused. Constant images remain closed. Binder environments extend the initial local mapping.
Source readback is discarded before the final target commit. Failure rolls
back both sides without publishing declarations. The result is syntax usable
at target_frame, and supplies no proof authority.
Defined in src/judgment_store/_dag_interpret_terms.mojo.
transport_type¶
def transport_type(source: _DagSession, target: _DagSession, base: Snapshot, kind: DagType, images: List[DagTypeImage], mut budget: Budget) raises LibError -> DagType
Translate an IN-1 type with simultaneous constructor substitution and base-sort identity.
Repeated, permuted and unused image parameters are allowed. No declaration is created. Source readback is discarded; a failed target scope is discarded too. Both caller and session work allowances are enforced.
Defined in src/judgment_store/_dag_interpret_terms.mojo.
reuse¶
def reuse(source: _DagSession, target: _DagSession, base: Snapshot, theorem: DagFact, name: String, constants: List[Tuple[DagExpr, DagExpr]], proofs: List[Tuple[DagFact, DagFact]], mut work: Budget, type_images: List[DagTypeImage] = List[DagTypeImage]()) raises LibError -> DagFact
Translate a source theorem and check its derivation in the target session (ST4.2, IN-1 and IN-2).
Arguments.
source: Owner of the theorem and declaration keys.target: Owner of the supplied images and the new theorem.base: Common immutable snapshot.theorem: A source theorem with a recorded derivation.name: The target name to publish on success.constants: Source constants and their closed target expressions.proofs: Source axioms or definition equations and the target facts offered for them, plus optional proved facts.work: Shared allowance for signature validation, translation and traversal of the source proof DAG.type_images: Target type templates for the source's additional constructors.
Returns. The target fact with a newly checked proof of the translated statement.
Raises.
LibError: A missing or invalid image, unavailable translation, rejected proof, occupied name or exhausted allowance.
Defined in src/judgment_store/_dag_interpret_proofs.mojo.
reuse_eliminated¶
def reuse_eliminated(source: _DagSession, target: _DagSession, base: Snapshot, theorem: DagFact, name: String, constants: List[Tuple[DagExpr, DagExpr]], proofs: List[Tuple[DagFact, DagFact]], mut work: Budget, type_images: List[DagTypeImage] = List[DagTypeImage](), eliminated_acu: List[DagEliminationAcu] = List[DagEliminationAcu](), eliminated_rationals: List[DagEliminationRational] = List[DagEliminationRational]()) raises LibError -> DagFact
Translate and check a source theorem while eliminating source ACU/rational conversions in the target.
Arguments.
source: Owner of the theorem and declaration keys.target: Owner of the supplied images and the new theorem.base: Common immutable snapshot.theorem: A source theorem with a recorded derivation.name: Target theorem name.constants: Source constants and their closed target expressions.proofs: Source axioms/definitions and their checked target facts.work: Shared work allowance.type_images: Target type templates for source constructors.eliminated_acu: Checked target ACU laws replacing source ACU declarations without target registrations.eliminated_rationals: Checked target rational laws replacing source literal kinds without target registrations.
Returns. The target fact with a newly checked proof of the translated statement.
Raises.
LibError: On missing/invalid images, failed elimination, rejected proof, or exhaustion.
Defined in src/judgment_store/_dag_interpret_proofs.mojo.
reuse_batch_eliminated¶
def reuse_batch_eliminated(source: _DagSession, target: _DagSession, base: Snapshot, theorems: List[Tuple[DagFact, String]], constants: List[Tuple[DagExpr, DagExpr]], proofs: List[Tuple[DagFact, DagFact]], mut work: Budget, type_images: List[DagTypeImage] = List[DagTypeImage](), eliminated_acu: List[DagEliminationAcu] = List[DagEliminationAcu](), eliminated_rationals: List[DagEliminationRational] = List[DagEliminationRational]()) raises LibError -> List[DagFact]
Translate and check a batch of source theorems atomically, reusing each replayed theorem for later ones.
Arguments.
source: Owner of the theorems and declaration keys.target: Owner of the supplied images and the new target theorems.base: Common immutable snapshot.theorems: Ordered(source_fact, target_name)pairs to replay in dependency order.constants: Source constants and their closed target expressions.proofs: Source axioms, definitions, and previously replayed theorems with their checked target facts.work: Shared work allowance.type_images: Target type templates for source constructors.eliminated_acu: Checked target ACU laws replacing source ACU declarations without target registrations.eliminated_rationals: Checked target rational laws replacing source literal kinds without target registrations.
Returns. Ordered list of newly checked target facts matching theorems.
Raises.
LibError: On missing/invalid images, failed elimination, rejected proof, or exhaustion.
Defined in src/judgment_store/_dag_interpret_proofs.mojo.